@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.
- package/dist/.build-fingerprint +1 -1
- package/dist/activities/execute-cursor/capture-flow.d.ts +26 -15
- package/dist/activities/execute-cursor/capture-flow.js +56 -18
- package/dist/activities/execute-cursor/capture-flow.js.map +1 -1
- package/dist/activities/execute-cursor/command-provenance.d.ts +11 -25
- package/dist/activities/execute-cursor/command-provenance.js +25 -115
- package/dist/activities/execute-cursor/command-provenance.js.map +1 -1
- package/dist/activities/execute-cursor/index.js +296 -477
- package/dist/activities/execute-cursor/index.js.map +1 -1
- package/dist/activities/execute-cursor/todo-tracker.d.ts +6 -1
- package/dist/activities/execute-cursor/todo-tracker.js +15 -43
- package/dist/activities/execute-cursor/todo-tracker.js.map +1 -1
- package/dist/activities/execute-cursor/turn-stream.d.ts +141 -0
- package/dist/activities/execute-cursor/turn-stream.js +249 -0
- package/dist/activities/execute-cursor/turn-stream.js.map +1 -0
- package/dist/activities/execute-deep-agent/command-provenance.d.ts +61 -0
- package/dist/activities/execute-deep-agent/command-provenance.js +72 -0
- package/dist/activities/execute-deep-agent/command-provenance.js.map +1 -0
- package/dist/activities/execute-deep-agent/index.js +60 -18
- package/dist/activities/execute-deep-agent/index.js.map +1 -1
- package/dist/activities/execute-deep-agent/status-builder.js +8 -1
- package/dist/activities/execute-deep-agent/status-builder.js.map +1 -1
- package/dist/activities/execute-deep-agent/v3-status-builder.js +12 -1
- package/dist/activities/execute-deep-agent/v3-status-builder.js.map +1 -1
- package/dist/otel.js +10 -0
- package/dist/otel.js.map +1 -1
- package/dist/shared/filereview/cas-progress.d.ts +63 -0
- package/dist/shared/filereview/cas-progress.js +128 -0
- package/dist/shared/filereview/cas-progress.js.map +1 -0
- package/dist/shared/filereview/cas-substrate.d.ts +29 -0
- package/dist/shared/filereview/cas-substrate.js +46 -21
- package/dist/shared/filereview/cas-substrate.js.map +1 -1
- package/dist/shared/filereview/command-provenance.d.ts +93 -0
- package/dist/shared/filereview/command-provenance.js +132 -0
- package/dist/shared/filereview/command-provenance.js.map +1 -0
- package/dist/shared/filereview/git-substrate.d.ts +9 -3
- package/dist/shared/filereview/git-substrate.js.map +1 -1
- package/dist/shared/filereview/index.d.ts +4 -3
- package/dist/shared/filereview/index.js +3 -2
- package/dist/shared/filereview/index.js.map +1 -1
- package/dist/shared/filereview/progress.d.ts +105 -34
- package/dist/shared/filereview/progress.js +96 -34
- package/dist/shared/filereview/progress.js.map +1 -1
- package/dist/shared/plan-mode-prompt.d.ts +9 -0
- package/dist/shared/plan-mode-prompt.js +18 -0
- package/dist/shared/plan-mode-prompt.js.map +1 -1
- package/dist/shared/todos.d.ts +56 -0
- package/dist/shared/todos.js +98 -0
- package/dist/shared/todos.js.map +1 -0
- package/dist/shared/tool-row.d.ts +16 -0
- package/dist/shared/tool-row.js +31 -0
- package/dist/shared/tool-row.js.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/otel-turn-span.test.ts +61 -0
- package/src/activities/execute-cursor/__tests__/progress-substrate.test.ts +169 -0
- package/src/activities/execute-cursor/__tests__/turn-stream.test.ts +349 -0
- package/src/activities/execute-cursor/capture-flow.ts +71 -25
- package/src/activities/execute-cursor/command-provenance.ts +25 -120
- package/src/activities/execute-cursor/index.ts +344 -504
- package/src/activities/execute-cursor/todo-tracker.ts +17 -59
- package/src/activities/execute-cursor/turn-stream.ts +418 -0
- package/src/activities/execute-deep-agent/__tests__/command-provenance.test.ts +252 -0
- package/src/activities/execute-deep-agent/__tests__/status-builder.test.ts +78 -0
- package/src/activities/execute-deep-agent/__tests__/v3-status-builder.test.ts +105 -1
- package/src/activities/execute-deep-agent/command-provenance.ts +102 -0
- package/src/activities/execute-deep-agent/index.ts +74 -18
- package/src/activities/execute-deep-agent/status-builder.ts +9 -0
- package/src/activities/execute-deep-agent/v3-status-builder.ts +13 -0
- package/src/otel.ts +8 -0
- package/src/shared/__tests__/todos.test.ts +216 -0
- package/src/shared/filereview/__tests__/cas-progress.test.ts +228 -0
- package/src/shared/filereview/__tests__/cas-substrate.test.ts +66 -0
- package/src/shared/filereview/__tests__/command-provenance.test.ts +252 -0
- package/src/shared/filereview/__tests__/progress.test.ts +112 -10
- package/src/shared/filereview/cas-progress.ts +170 -0
- package/src/shared/filereview/cas-substrate.ts +69 -24
- package/src/shared/filereview/command-provenance.ts +180 -0
- package/src/shared/filereview/git-substrate.ts +9 -3
- package/src/shared/filereview/index.ts +15 -1
- package/src/shared/filereview/progress.ts +171 -47
- package/src/shared/plan-mode-prompt.ts +18 -0
- package/src/shared/todos.ts +126 -0
- package/src/shared/tool-row.ts +34 -0
package/dist/.build-fingerprint
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"hash":"
|
|
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
|
|
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
|
-
*
|
|
106
|
-
*
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
*
|
|
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
|
|
114
|
-
readonly
|
|
115
|
-
readonly
|
|
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
|
|
118
|
-
readonly
|
|
119
|
-
|
|
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 {
|
|
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
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
*
|
|
141
|
-
*
|
|
142
|
-
*
|
|
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
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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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,GAAG,CAAC,EAAE,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)
|
|
3
|
-
*
|
|
2
|
+
* Approved-command turn provenance (DD-28) — the CURSOR harness adapter over the
|
|
3
|
+
* shared qualification rule ({@link qualifyTurnCommandProvenance}).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
-
*
|
|
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
|
|
59
|
-
*
|
|
60
|
-
*
|
|
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)
|
|
3
|
-
*
|
|
2
|
+
* Approved-command turn provenance (DD-28) — the CURSOR harness adapter over the
|
|
3
|
+
* shared qualification rule ({@link qualifyTurnCommandProvenance}).
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
* the
|
|
8
|
-
*
|
|
9
|
-
*
|
|
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
|
-
*
|
|
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 {
|
|
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
|
|
50
|
-
*
|
|
51
|
-
*
|
|
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
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
1
|
+
{"version":3,"file":"command-provenance.js","sourceRoot":"","sources":["../../../src/activities/execute-cursor/command-provenance.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,EAAE,4BAA4B,EAAE,MAAM,+CAA+C,CAAC;AAC7F,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AA8BhE;;;;;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,6EAA6E;IAC7E,yEAAyE;IACzE,MAAM,aAAa,GAAG,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC;IAEjF,OAAO,4BAA4B,CAAC;QAClC,aAAa;QACb,QAAQ;QACR,yEAAyE;QACzE,mDAAmD;QACnD,iBAAiB,EAAE,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"}
|