@stigmer/runner 3.1.3 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/dist/.build-fingerprint +1 -1
  2. package/dist/activities/execute-cursor/capture-flow.d.ts +26 -15
  3. package/dist/activities/execute-cursor/capture-flow.js +56 -18
  4. package/dist/activities/execute-cursor/capture-flow.js.map +1 -1
  5. package/dist/activities/execute-cursor/command-provenance.d.ts +11 -25
  6. package/dist/activities/execute-cursor/command-provenance.js +25 -115
  7. package/dist/activities/execute-cursor/command-provenance.js.map +1 -1
  8. package/dist/activities/execute-cursor/index.js +296 -477
  9. package/dist/activities/execute-cursor/index.js.map +1 -1
  10. package/dist/activities/execute-cursor/todo-tracker.d.ts +6 -1
  11. package/dist/activities/execute-cursor/todo-tracker.js +15 -43
  12. package/dist/activities/execute-cursor/todo-tracker.js.map +1 -1
  13. package/dist/activities/execute-cursor/turn-stream.d.ts +141 -0
  14. package/dist/activities/execute-cursor/turn-stream.js +249 -0
  15. package/dist/activities/execute-cursor/turn-stream.js.map +1 -0
  16. package/dist/activities/execute-deep-agent/command-provenance.d.ts +61 -0
  17. package/dist/activities/execute-deep-agent/command-provenance.js +72 -0
  18. package/dist/activities/execute-deep-agent/command-provenance.js.map +1 -0
  19. package/dist/activities/execute-deep-agent/index.js +60 -18
  20. package/dist/activities/execute-deep-agent/index.js.map +1 -1
  21. package/dist/activities/execute-deep-agent/status-builder.js +8 -1
  22. package/dist/activities/execute-deep-agent/status-builder.js.map +1 -1
  23. package/dist/activities/execute-deep-agent/v3-status-builder.js +12 -1
  24. package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -1
  25. package/dist/otel.js +10 -0
  26. package/dist/otel.js.map +1 -1
  27. package/dist/shared/filereview/cas-progress.d.ts +63 -0
  28. package/dist/shared/filereview/cas-progress.js +128 -0
  29. package/dist/shared/filereview/cas-progress.js.map +1 -0
  30. package/dist/shared/filereview/cas-substrate.d.ts +29 -0
  31. package/dist/shared/filereview/cas-substrate.js +46 -21
  32. package/dist/shared/filereview/cas-substrate.js.map +1 -1
  33. package/dist/shared/filereview/command-provenance.d.ts +93 -0
  34. package/dist/shared/filereview/command-provenance.js +132 -0
  35. package/dist/shared/filereview/command-provenance.js.map +1 -0
  36. package/dist/shared/filereview/git-substrate.d.ts +9 -3
  37. package/dist/shared/filereview/git-substrate.js.map +1 -1
  38. package/dist/shared/filereview/index.d.ts +4 -3
  39. package/dist/shared/filereview/index.js +3 -2
  40. package/dist/shared/filereview/index.js.map +1 -1
  41. package/dist/shared/filereview/progress.d.ts +105 -34
  42. package/dist/shared/filereview/progress.js +96 -34
  43. package/dist/shared/filereview/progress.js.map +1 -1
  44. package/dist/shared/plan-mode-prompt.d.ts +9 -0
  45. package/dist/shared/plan-mode-prompt.js +18 -0
  46. package/dist/shared/plan-mode-prompt.js.map +1 -1
  47. package/dist/shared/todos.d.ts +56 -0
  48. package/dist/shared/todos.js +98 -0
  49. package/dist/shared/todos.js.map +1 -0
  50. package/dist/shared/tool-row.d.ts +16 -0
  51. package/dist/shared/tool-row.js +31 -0
  52. package/dist/shared/tool-row.js.map +1 -1
  53. package/package.json +2 -2
  54. package/src/__tests__/otel-turn-span.test.ts +61 -0
  55. package/src/activities/execute-cursor/__tests__/progress-substrate.test.ts +169 -0
  56. package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +349 -0
  57. package/src/activities/execute-cursor/capture-flow.ts +71 -25
  58. package/src/activities/execute-cursor/command-provenance.ts +25 -120
  59. package/src/activities/execute-cursor/index.ts +344 -504
  60. package/src/activities/execute-cursor/todo-tracker.ts +17 -59
  61. package/src/activities/execute-cursor/turn-stream.ts +418 -0
  62. package/src/activities/execute-deep-agent/__tests__/command-provenance.test.ts +252 -0
  63. package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +78 -0
  64. package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +105 -1
  65. package/src/activities/execute-deep-agent/command-provenance.ts +102 -0
  66. package/src/activities/execute-deep-agent/index.ts +74 -18
  67. package/src/activities/execute-deep-agent/status-builder.ts +9 -0
  68. package/src/activities/execute-deep-agent/v3-status-builder.ts +13 -0
  69. package/src/otel.ts +8 -0
  70. package/src/shared/__tests__/todos.test.ts +216 -0
  71. package/src/shared/filereview/__tests__/cas-progress.test.ts +228 -0
  72. package/src/shared/filereview/__tests__/cas-substrate.test.ts +66 -0
  73. package/src/shared/filereview/__tests__/command-provenance.test.ts +252 -0
  74. package/src/shared/filereview/__tests__/progress.test.ts +112 -10
  75. package/src/shared/filereview/cas-progress.ts +170 -0
  76. package/src/shared/filereview/cas-substrate.ts +69 -24
  77. package/src/shared/filereview/command-provenance.ts +180 -0
  78. package/src/shared/filereview/git-substrate.ts +9 -3
  79. package/src/shared/filereview/index.ts +15 -1
  80. package/src/shared/filereview/progress.ts +171 -47
  81. package/src/shared/plan-mode-prompt.ts +18 -0
  82. package/src/shared/todos.ts +126 -0
  83. package/src/shared/tool-row.ts +34 -0
@@ -1 +1 @@
1
- {"hash":"21af7d0537f439ed","builtAt":"2026-07-05T14:32:49.617Z","fileCount":237}
1
+ {"hash":"4a20d226fffa581f","builtAt":"2026-07-06T13:51:05.592Z","fileCount":242}
@@ -21,7 +21,7 @@ import type { AgentMessage } from "@stigmer/protos/ai/stigmer/agentic/agentexecu
21
21
  import type { AgentExecutionStatus } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/api_pb";
22
22
  import type { FileChangeSet, TurnCommandProvenance } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
23
23
  import { type CaptureResumeResult } from "../../shared/filereview/capture.js";
24
- import { type ProgressCaptureState } from "../../shared/filereview/progress.js";
24
+ import { type ProgressSubstrate } from "../../shared/filereview/progress.js";
25
25
  import type { GitSubstrateChange as GitCapturedChange } from "../../shared/filereview/git-substrate.js";
26
26
  import type { ArtifactStorage } from "../../shared/artifact-storage.js";
27
27
  export type { CaptureResumeResult };
@@ -102,22 +102,33 @@ export declare function captureTurnToLedger(opts: {
102
102
  readonly commandProvenance?: TurnCommandProvenance;
103
103
  }): Promise<readonly GitCapturedChange[]>;
104
104
  /**
105
- * Mid-run: attach the live "N files changed so far" snapshot onto
106
- * `status.file_change_progress` (DD-32), throttled by the floor + tree-sha
107
- * short-circuit inside {@link captureFileChangeProgress}. The Cursor adapter binds
108
- * `CURSOR_RUNNER_OWNED_PATHS` so the progress diff excludes the gate's own files —
109
- * the SAME exclusion {@link captureTurnToLedger} uses for the turn-boundary
110
- * candidate, so the live count and the reviewed set agree. Content-free and
111
- * secret-safe; a no-op when nothing changed since the last capture.
105
+ * Choose the mid-run progress substrate for this turn's workspace shape (DD-32 /
106
+ * DD-33), returning `undefined` when there is nothing to observe (not capture
107
+ * mode, or no workspace). Built ONCE per turn — the substrate owns its own
108
+ * short-circuit cache across the loop's persists; the floor lives in the caller's
109
+ * `ProgressCaptureState`. The live count and the turn-boundary reviewed set agree
110
+ * by construction: the git slice binds the SAME `CURSOR_RUNNER_OWNED_PATHS`
111
+ * exclusion {@link captureTurnToLedger} uses, and the CAS slice reads the SAME
112
+ * hook sidecar ({@link readCasObservations}) the boundary reads.
113
+ *
114
+ * - git tree, no storage -> git substrate only (tracked-file `--numstat`);
115
+ * - git tree, storage (HYBRID) -> git + CAS (the gitignored writes the hook staged);
116
+ * - non-git workspace -> CAS only (every tool-mediated write is CAS-staged).
117
+ *
118
+ * The CAS slice needs the hook sidecar, which exists only when `captureIgnored`
119
+ * is on (storage configured). A non-git capture already required storage
120
+ * (`deriveCaptureMode`), so its sidecar is always present; a git tree with no
121
+ * storage simply gets the git-only substrate (parity with the pre-DD-33 behavior).
112
122
  */
113
- export declare function captureProgressToStatus(opts: {
114
- readonly status: AgentExecutionStatus;
115
- readonly gitRoot: string;
123
+ export declare function buildCursorProgressSubstrate(opts: {
124
+ readonly captureMode: boolean;
125
+ readonly gitWorkspace: boolean;
126
+ readonly workspaceRoot: string | undefined;
127
+ readonly baselineTree: string | undefined;
116
128
  readonly executionId: string;
117
- readonly changeSetId: string;
118
- readonly baselineTree: string;
119
- readonly state: ProgressCaptureState;
120
- }): Promise<void>;
129
+ readonly hitlDir: string | undefined;
130
+ readonly storage: ArtifactStorage | undefined;
131
+ }): ProgressSubstrate | undefined;
121
132
  /**
122
133
  * Resume: reconcile the working tree to the change set's DECIDED decisions
123
134
  * (keep approved "after" bytes, snap rejected/undecided back to baseline,
@@ -26,7 +26,8 @@ import { readCasObservations } from "./cas-observations.js";
26
26
  import { contentDigest } from "../../shared/file-tools.js";
27
27
  import { isToolCallRowHidden, stampFileEditRow } from "../../shared/tool-row.js";
28
28
  import { applyCaptureDecisions as sharedApplyCaptureDecisions, captureBaselineToLedger as sharedCaptureBaselineToLedger, captureCandidateToLedger as sharedCaptureCandidateToLedger, } from "../../shared/filereview/capture.js";
29
- import { captureFileChangeProgress, } from "../../shared/filereview/progress.js";
29
+ import { createGitProgressSubstrate, createHybridProgressSubstrate, } from "../../shared/filereview/progress.js";
30
+ import { createCasProgressSubstrate, } from "../../shared/filereview/cas-progress.js";
30
31
  import { hasCandidateCaptured } from "../../shared/filereview/events.js";
31
32
  import { partitionIgnoredPathsBySecret } from "../../shared/filereview/secret-paths.js";
32
33
  import { casBlobReader } from "../../shared/filereview/cas-substrate.js";
@@ -133,24 +134,61 @@ export async function captureTurnToLedger(opts) {
133
134
  return changes;
134
135
  }
135
136
  /**
136
- * Mid-run: attach the live "N files changed so far" snapshot onto
137
- * `status.file_change_progress` (DD-32), throttled by the floor + tree-sha
138
- * short-circuit inside {@link captureFileChangeProgress}. The Cursor adapter binds
139
- * `CURSOR_RUNNER_OWNED_PATHS` so the progress diff excludes the gate's own files —
140
- * the SAME exclusion {@link captureTurnToLedger} uses for the turn-boundary
141
- * candidate, so the live count and the reviewed set agree. Content-free and
142
- * secret-safe; a no-op when nothing changed since the last capture.
137
+ * Choose the mid-run progress substrate for this turn's workspace shape (DD-32 /
138
+ * DD-33), returning `undefined` when there is nothing to observe (not capture
139
+ * mode, or no workspace). Built ONCE per turn — the substrate owns its own
140
+ * short-circuit cache across the loop's persists; the floor lives in the caller's
141
+ * `ProgressCaptureState`. The live count and the turn-boundary reviewed set agree
142
+ * by construction: the git slice binds the SAME `CURSOR_RUNNER_OWNED_PATHS`
143
+ * exclusion {@link captureTurnToLedger} uses, and the CAS slice reads the SAME
144
+ * hook sidecar ({@link readCasObservations}) the boundary reads.
145
+ *
146
+ * - git tree, no storage -> git substrate only (tracked-file `--numstat`);
147
+ * - git tree, storage (HYBRID) -> git + CAS (the gitignored writes the hook staged);
148
+ * - non-git workspace -> CAS only (every tool-mediated write is CAS-staged).
149
+ *
150
+ * The CAS slice needs the hook sidecar, which exists only when `captureIgnored`
151
+ * is on (storage configured). A non-git capture already required storage
152
+ * (`deriveCaptureMode`), so its sidecar is always present; a git tree with no
153
+ * storage simply gets the git-only substrate (parity with the pre-DD-33 behavior).
143
154
  */
144
- export async function captureProgressToStatus(opts) {
145
- await captureFileChangeProgress({
146
- status: opts.status,
147
- gitRoot: opts.gitRoot,
148
- executionId: opts.executionId,
149
- changeSetId: opts.changeSetId,
150
- baselineTree: opts.baselineTree,
151
- excludePaths: CURSOR_RUNNER_OWNED_PATHS,
152
- state: opts.state,
153
- });
155
+ export function buildCursorProgressSubstrate(opts) {
156
+ const { captureMode, gitWorkspace, workspaceRoot, baselineTree, executionId, hitlDir, storage } = opts;
157
+ if (!captureMode || !workspaceRoot)
158
+ return undefined;
159
+ const casReader = hitlDir && storage ? createSidecarTouchedReader(hitlDir) : undefined;
160
+ if (gitWorkspace) {
161
+ if (!baselineTree)
162
+ return undefined;
163
+ const git = createGitProgressSubstrate({
164
+ workspaceRoot,
165
+ executionId,
166
+ baselineTree,
167
+ excludePaths: CURSOR_RUNNER_OWNED_PATHS,
168
+ });
169
+ return casReader
170
+ ? createHybridProgressSubstrate(git, createCasProgressSubstrate({ workspaceRoot, read: casReader }))
171
+ : git;
172
+ }
173
+ // Non-git: every tool-mediated write is CAS-staged; there is no git slice.
174
+ return casReader ? createCasProgressSubstrate({ workspaceRoot, read: casReader }) : undefined;
175
+ }
176
+ /**
177
+ * A {@link CasTouchedReader} over the Cursor hook's on-disk sidecar. Each capture
178
+ * reads the current observations ({@link readCasObservations}) and maps them to
179
+ * the substrate's snapshot shape. Reads are bounded by the caller's capture floor
180
+ * (default 2s), and the sidecar is small (one small marker + before-blob per
181
+ * touched gitignored path), so re-reading per capture is cheap and always
182
+ * reflects sub-agent writes staged since the last one.
183
+ */
184
+ function createSidecarTouchedReader(hitlDir) {
185
+ return async () => {
186
+ const { captured, secretPaths } = await readCasObservations(hitlDir);
187
+ const before = new Map();
188
+ for (const c of captured)
189
+ before.set(c.path, c.before);
190
+ return { before, blockedSecretPaths: new Set(secretPaths) };
191
+ };
154
192
  }
155
193
  /**
156
194
  * Compose this turn's CAS captures from the sidecar the hook staged, mirroring
@@ -1 +1 @@
1
- {"version":3,"file":"capture-flow.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/capture-flow.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAIjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,8DAA8D,CAAC;AAChG,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AACjF,OAAO,EACL,qBAAqB,IAAI,2BAA2B,EACpD,uBAAuB,IAAI,6BAA6B,EACxD,wBAAwB,IAAI,8BAA8B,GAE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,CAAC,EAAE,CAAC;gBAAE,SAAS;YAC1C,IAAI,mBAAmB,CAAC,EAAE,CAAC;gBAAE,SAAS;YACtC,MAAM,QAAQ,GAAG,gBAAgB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC;YAC3C,IAAI,QAAQ,KAAK,OAAO,IAAI,QAAQ,KAAK,QAAQ;gBAAE,SAAS;YAC5D,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,EAAE,CAA4B,CAAC;YACxD,MAAM,EAAE,GAAG,YAAY,CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,aAAa,EAAE,IAAI,CAAC,CAAC;YACzD,MAAM,KAAK,GAAG,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,OAAO,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC,CAAC;YACpE,IAAI,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC;gBAAE,SAAS,CAAC,mCAAmC;YAC1E,gBAAgB,CAAC,EAAE,EAAE,WAAW,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;AACH,CAAC"}
@@ -1,28 +1,14 @@
1
1
  /**
2
- * Approved-command turn provenance (DD-28): the runner-owned qualification for
3
- * the auto-keep policy.
2
+ * Approved-command turn provenance (DD-28) the CURSOR harness adapter over the
3
+ * shared qualification rule ({@link qualifyTurnCommandProvenance}).
4
4
  *
5
- * A turn whose ONLY mutation source was shell commands the human had already
6
- * authorized should not re-gate its file effects at the turn-boundary review
7
- * the user consented to the command, and the command's file effects are the
8
- * consented outcome. The server cannot derive this itself (tool calls carry no
9
- * turn marker), so the runner the only component that owns turn scoping —
10
- * derives the facts here and attaches them to the CANDIDATE_CAPTURED event as
11
- * {@link TurnCommandProvenance}.
5
+ * The Cursor harness scopes a turn POSITIONALLY (messages from the turn's first
6
+ * streamed index onward) and maps an executed command to its consent row through
7
+ * the reinvocation grant tokens the deny-gate minted. Both mappings are Cursor's
8
+ * own; the DD-28 rule they feed lives in `shared/filereview/command-provenance.ts`
9
+ * so the Cursor and deep-agent qualifications cannot drift.
12
10
  *
13
- * TRUST BOUNDARY. This module asserts turn FACTS (which tools ran this turn),
14
- * the same trust level as the captured bytes themselves. It never asserts
15
- * CONSENT: `consentToolCallIds` merely POINT at transcript rows whose
16
- * `approval_action` was authored by the server's SubmitApproval (and is
17
- * preserved against runner writes) — the backend re-verifies every claimed row
18
- * against that server-owned record before authoring the policy decision, so a
19
- * runner cannot mint authorization it was never given.
20
- *
21
- * FAIL-CLOSED. Every uncertainty disqualifies (returns undefined → the set
22
- * reviews manually, exactly as before DD-28): a file-tool call, an MCP tool, a
23
- * sub-agent delegation, an unrecognized tool name, or an executed shell command
24
- * with no provable consent source. Being conservative here costs only an extra
25
- * review; being permissive would silently waive one.
11
+ * (Trust boundary + fail-closed contract: see the shared module.)
26
12
  */
27
13
  import type { AgentMessage } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/message_pb";
28
14
  import type { TurnCommandProvenance } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
@@ -55,8 +41,8 @@ export interface CommandProvenanceInputs {
55
41
  }
56
42
  /**
57
43
  * Derive the {@link TurnCommandProvenance} for the turn, or undefined when the
58
- * turn does not qualify (any non-shell mutation-capable call, any unknown tool,
59
- * any executed command without a provable consent source, or no executed
60
- * consented command at all).
44
+ * turn does not qualify. Scopes this turn's tool calls positionally, resolves
45
+ * consent through the deny-gate grant tokens, and delegates the DD-28 rule to
46
+ * {@link qualifyTurnCommandProvenance}.
61
47
  */
62
48
  export declare function deriveTurnCommandProvenance(inputs: CommandProvenanceInputs): TurnCommandProvenance | undefined;
@@ -1,128 +1,38 @@
1
1
  /**
2
- * Approved-command turn provenance (DD-28): the runner-owned qualification for
3
- * the auto-keep policy.
2
+ * Approved-command turn provenance (DD-28) the CURSOR harness adapter over the
3
+ * shared qualification rule ({@link qualifyTurnCommandProvenance}).
4
4
  *
5
- * A turn whose ONLY mutation source was shell commands the human had already
6
- * authorized should not re-gate its file effects at the turn-boundary review
7
- * the user consented to the command, and the command's file effects are the
8
- * consented outcome. The server cannot derive this itself (tool calls carry no
9
- * turn marker), so the runner the only component that owns turn scoping —
10
- * derives the facts here and attaches them to the CANDIDATE_CAPTURED event as
11
- * {@link TurnCommandProvenance}.
5
+ * The Cursor harness scopes a turn POSITIONALLY (messages from the turn's first
6
+ * streamed index onward) and maps an executed command to its consent row through
7
+ * the reinvocation grant tokens the deny-gate minted. Both mappings are Cursor's
8
+ * own; the DD-28 rule they feed lives in `shared/filereview/command-provenance.ts`
9
+ * so the Cursor and deep-agent qualifications cannot drift.
12
10
  *
13
- * TRUST BOUNDARY. This module asserts turn FACTS (which tools ran this turn),
14
- * the same trust level as the captured bytes themselves. It never asserts
15
- * CONSENT: `consentToolCallIds` merely POINT at transcript rows whose
16
- * `approval_action` was authored by the server's SubmitApproval (and is
17
- * preserved against runner writes) — the backend re-verifies every claimed row
18
- * against that server-owned record before authoring the policy decision, so a
19
- * runner cannot mint authorization it was never given.
20
- *
21
- * FAIL-CLOSED. Every uncertainty disqualifies (returns undefined → the set
22
- * reviews manually, exactly as before DD-28): a file-tool call, an MCP tool, a
23
- * sub-agent delegation, an unrecognized tool name, or an executed shell command
24
- * with no provable consent source. Being conservative here costs only an extra
25
- * review; being permissive would silently waive one.
11
+ * (Trust boundary + fail-closed contract: see the shared module.)
26
12
  */
27
- import { create } from "@bufbuild/protobuf";
28
- import { TurnCommandProvenanceSchema } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/filereview_pb";
29
- import { ApprovalAction, ToolKind } from "@stigmer/protos/ai/stigmer/agentic/agentexecution/v1/enum_pb";
30
- import { classifyTool, toolApprovalCategory } from "../../shared/tool-kind.js";
31
- import { isToolCallRowHidden } from "../../shared/tool-row.js";
13
+ import { qualifyTurnCommandProvenance } from "../../shared/filereview/command-provenance.js";
32
14
  import { toolCallIdentityToken } from "./message-translator.js";
33
- /**
34
- * Tool kinds that can never mutate the workspace: their presence in a turn is
35
- * irrelevant to change-set provenance. Everything OUTSIDE this set is either a
36
- * consent-mapped shell command or a disqualifier — never silently ignored.
37
- */
38
- const NON_MUTATING_KINDS = new Set([
39
- ToolKind.FILE_READ,
40
- ToolKind.SEARCH,
41
- ToolKind.LIST,
42
- ToolKind.FETCH,
43
- ToolKind.WEB_SEARCH,
44
- ToolKind.THINK,
45
- ToolKind.TODO,
46
- ]);
47
15
  /**
48
16
  * Derive the {@link TurnCommandProvenance} for the turn, or undefined when the
49
- * turn does not qualify (any non-shell mutation-capable call, any unknown tool,
50
- * any executed command without a provable consent source, or no executed
51
- * consented command at all).
17
+ * turn does not qualify. Scopes this turn's tool calls positionally, resolves
18
+ * consent through the deny-gate grant tokens, and delegates the DD-28 rule to
19
+ * {@link qualifyTurnCommandProvenance}.
52
20
  */
53
21
  export function deriveTurnCommandProvenance(inputs) {
54
22
  const { messages, turnStartIndex, deniedTokens, grantTokenToConsentId, globalBypass } = inputs;
55
- const consentIds = new Set();
56
- let authorizedByAutoApproveAll = false;
57
- let executedCommandCount = 0;
58
- for (let i = turnStartIndex; i < messages.length; i++) {
59
- for (const tc of messages[i].toolCalls) {
60
- // A hidden row is a collapsed twin/reaction — it never executed.
61
- if (isToolCallRowHidden(tc))
62
- continue;
63
- const kind = classifyTool(tc.name, tc.mcpServerSlug);
64
- if (NON_MUTATING_KINDS.has(kind))
65
- continue;
66
- if (kind !== ToolKind.SHELL) {
67
- // A file tool (mixed turn), a sub-agent (unattributable mutations), an
68
- // MCP tool (opaque side effects), or an unrecognized name — the turn's
69
- // mutations cannot be attributed to consented commands. Fail closed.
70
- return undefined;
71
- }
72
- const token = toolCallIdentityToken(tc);
73
- if (deniedTokens.has(token)) {
74
- // This turn's pending gate — denied by the hook, never executed.
75
- continue;
76
- }
77
- executedCommandCount++;
78
- const consentId = grantTokenToConsentId.get(token);
79
- if (consentId) {
80
- consentIds.add(consentId);
81
- continue;
82
- }
83
- const leaseConsentId = findLeaseConsentId(messages, tc.name);
84
- if (leaseConsentId) {
85
- consentIds.add(leaseConsentId);
86
- continue;
87
- }
88
- if (globalBypass) {
89
- authorizedByAutoApproveAll = true;
90
- continue;
91
- }
92
- // An executed shell command with no grant, no lease, and no bypass should
93
- // be impossible (the hook gates every un-consented shell); if it ever
94
- // happens, the honest answer is a manual review, not a waived one.
95
- return undefined;
96
- }
97
- }
98
- // A turn that executed no consented command has nothing to attribute the
99
- // change set to — whatever changed came from somewhere else. Manual review.
100
- if (executedCommandCount === 0)
101
- return undefined;
102
- return create(TurnCommandProvenanceSchema, {
103
- consentToolCallIds: [...consentIds],
104
- authorizedByAutoApproveAll,
23
+ // This turn's tool calls are the positional tail from the first message this
24
+ // turn's stream produced; everything before was seeded from prior turns.
25
+ const turnToolCalls = messages.slice(turnStartIndex).flatMap((m) => m.toolCalls);
26
+ return qualifyTurnCommandProvenance({
27
+ turnToolCalls,
28
+ messages,
29
+ // A shell whose identity token is in the denial ledger was denied by the
30
+ // hook — this turn's pending gate, never executed.
31
+ isExecutedCommand: (tc) => !deniedTokens.has(toolCallIdentityToken(tc)),
32
+ // A grant token maps back to the consent row (the row carrying the
33
+ // server-authored approval_action) that authorized this reinvocation.
34
+ resolveDirectConsent: (tc) => grantTokenToConsentId.get(toolCallIdentityToken(tc)),
35
+ globalBypass,
105
36
  });
106
37
  }
107
- /**
108
- * Find the transcript row whose APPROVE_ALL authored the run-lifetime lease
109
- * covering `toolName`'s category — the consent row a lease-executed command
110
- * cites. Searched across the whole transcript (a lease usually originates in a
111
- * prior turn); the first (earliest) APPROVE_ALL of the category is the lease's
112
- * origin. Returns undefined when no lease row exists for the category.
113
- */
114
- function findLeaseConsentId(messages, toolName) {
115
- const category = toolApprovalCategory(toolName);
116
- if (!category)
117
- return undefined;
118
- for (const msg of messages) {
119
- for (const tc of msg.toolCalls) {
120
- if (tc.approvalAction !== ApprovalAction.APPROVE_ALL)
121
- continue;
122
- if (toolApprovalCategory(tc.name) === category)
123
- return tc.id;
124
- }
125
- }
126
- return undefined;
127
- }
128
38
  //# sourceMappingURL=command-provenance.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"command-provenance.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/command-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,oEAAoE,CAAC;AAEjH,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,8DAA8D,CAAC;AACxG,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAC/E,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAEhE;;;;GAIG;AACH,MAAM,kBAAkB,GAA0B,IAAI,GAAG,CAAC;IACxD,QAAQ,CAAC,SAAS;IAClB,QAAQ,CAAC,MAAM;IACf,QAAQ,CAAC,IAAI;IACb,QAAQ,CAAC,KAAK;IACd,QAAQ,CAAC,UAAU;IACnB,QAAQ,CAAC,KAAK;IACd,QAAQ,CAAC,IAAI;CACd,CAAC,CAAC;AA8BH;;;;;GAKG;AACH,MAAM,UAAU,2BAA2B,CACzC,MAA+B;IAE/B,MAAM,EAAE,QAAQ,EAAE,cAAc,EAAE,YAAY,EAAE,qBAAqB,EAAE,YAAY,EAAE,GAAG,MAAM,CAAC;IAE/F,MAAM,UAAU,GAAG,IAAI,GAAG,EAAU,CAAC;IACrC,IAAI,0BAA0B,GAAG,KAAK,CAAC;IACvC,IAAI,oBAAoB,GAAG,CAAC,CAAC;IAE7B,KAAK,IAAI,CAAC,GAAG,cAAc,EAAE,CAAC,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACtD,KAAK,MAAM,EAAE,IAAI,QAAQ,CAAC,CAAC,CAAC,CAAC,SAAS,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AAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,YAAY,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;QACvE,mEAAmE;QACnE,sEAAsE;QACtE,oBAAoB,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,qBAAqB,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC,CAAC;QAClF,YAAY;KACb,CAAC,CAAC;AACL,CAAC"}