|
1 | 1 | import type { ToolCall } from "@intx/types/runtime"; |
2 | 2 | import { isAbsolute, resolve } from "node:path"; |
| 3 | +import { randomUUID } from "node:crypto"; |
3 | 4 | import type { |
4 | 5 | Approval, |
5 | 6 | ApprovalOutcome, |
@@ -47,6 +48,12 @@ import { NOOP_APPROVAL_LOG, type ApprovalLog, type ApprovalOutcomeKind } from ". |
47 | 48 | // autoDeny in gate-wire.ts and the timeout branch in tui/request-approval.ts's |
48 | 49 | // finish() usage); anything else that denies is a plain operator/unavailable |
49 | 50 | // decision. |
| 51 | +function withRequestId(request: PermissionRequest): PermissionRequest { |
| 52 | + return request.id !== undefined && request.id.length > 0 |
| 53 | + ? request |
| 54 | + : { ...request, id: randomUUID() }; |
| 55 | +} |
| 56 | + |
50 | 57 | function classifyOutcome(outcome: ApprovalOutcome | undefined): ApprovalOutcomeKind { |
51 | 58 | if (outcome === undefined) return "deny"; |
52 | 59 | if (!outcome.allow) { |
@@ -664,7 +671,7 @@ export function createPermissionGate(options: PermissionGateOptions): Permission |
664 | 671 | const requestForOperator = anySecret ? { ...request, scopes: [] } : request; |
665 | 672 | return { |
666 | 673 | kind: "ask", |
667 | | - request: requestForOperator, |
| 674 | + request: withRequestId(requestForOperator), |
668 | 675 | anySecret, |
669 | 676 | segmentCount: segments.length, |
670 | 677 | }; |
@@ -692,7 +699,7 @@ export function createPermissionGate(options: PermissionGateOptions): Permission |
692 | 699 | }; |
693 | 700 | } |
694 | 701 |
|
695 | | - return { kind: "ask", request, anySecret: false, segmentCount: 0 }; |
| 702 | + return { kind: "ask", request: withRequestId(request), anySecret: false, segmentCount: 0 }; |
696 | 703 | } |
697 | 704 | return { kind: "allow" }; |
698 | 705 | }; |
|
0 commit comments