|
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) { |
@@ -646,7 +653,7 @@ export function createPermissionGate(options: PermissionGateOptions): Permission |
646 | 653 | const requestForOperator = anySecret ? { ...request, scopes: [] } : request; |
647 | 654 | return { |
648 | 655 | kind: "ask", |
649 | | - request: requestForOperator, |
| 656 | + request: withRequestId(requestForOperator), |
650 | 657 | anySecret, |
651 | 658 | segmentCount: segments.length, |
652 | 659 | }; |
@@ -674,7 +681,7 @@ export function createPermissionGate(options: PermissionGateOptions): Permission |
674 | 681 | }; |
675 | 682 | } |
676 | 683 |
|
677 | | - return { kind: "ask", request, anySecret: false, segmentCount: 0 }; |
| 684 | + return { kind: "ask", request: withRequestId(request), anySecret: false, segmentCount: 0 }; |
678 | 685 | } |
679 | 686 | return { kind: "allow" }; |
680 | 687 | }; |
|
0 commit comments