@sema-agent/core 7.57.0 → 7.58.0
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/CHANGELOG.md +385 -0
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/brain/route-adjudicator.js +2 -1
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/allow-entry.d.ts +2 -1
- package/dist/core/allow-entry.js +2 -1
- package/dist/core/ask-origin.d.ts +21 -2
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +4 -0
- package/dist/core/auto-compaction.js +1 -1
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/checkpoint-requirements.d.ts +7 -1
- package/dist/core/checkpoint-requirements.js +2 -0
- package/dist/core/checkpoint-store.d.ts +27 -11
- package/dist/core/checkpoint-store.js +13 -3
- package/dist/core/engine-notice.d.ts +1 -1
- package/dist/core/fs-write-gate-policy.d.ts +4 -2
- package/dist/core/fs-write-gate-policy.js +7 -3
- package/dist/core/gate-fold.js +6 -3
- package/dist/core/gate-lanes.js +11 -2
- package/dist/core/git-worktree-env.d.ts +53 -11
- package/dist/core/git-worktree-env.js +96 -12
- package/dist/core/hooks.d.ts +4 -1
- package/dist/core/hooks.js +12 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/locked-config.d.ts +15 -1
- package/dist/core/locked-config.js +38 -2
- package/dist/core/mcp-call-meta.d.ts +66 -0
- package/dist/core/mcp-call-meta.js +103 -0
- package/dist/core/mcp-connection-pool.d.ts +3 -1
- package/dist/core/mcp-connection-pool.js +3 -1
- package/dist/core/mcp-failure.d.ts +7 -1
- package/dist/core/mcp-failure.js +10 -0
- package/dist/core/mcp-probe.d.ts +4 -0
- package/dist/core/mcp-probe.js +1 -1
- package/dist/core/mcp-server-link.d.ts +5 -2
- package/dist/core/mcp-server-spec.d.ts +46 -18
- package/dist/core/mcp-server-spec.js +1 -18
- package/dist/core/mcp.d.ts +6 -14
- package/dist/core/mcp.js +77 -37
- package/dist/core/memory-engine/scope-contract.d.ts +45 -4
- package/dist/core/memory-engine/scope-contract.js +80 -11
- package/dist/core/mode-policy.d.ts +8 -5
- package/dist/core/mode-policy.js +5 -4
- package/dist/core/mods/host.js +1 -1
- package/dist/core/mods/kernel/dispatch.d.ts +3 -0
- package/dist/core/mods/kernel/dispatch.js +10 -8
- package/dist/core/mods/kernel/events.d.ts +5 -1
- package/dist/core/mods/kernel/events.js +1 -1
- package/dist/core/mods/kernel/registration.d.ts +5 -1
- package/dist/core/mods/kernel/site-rules.d.ts +3 -0
- package/dist/core/mods/kernel/site-rules.js +10 -0
- package/dist/core/mods/package.d.ts +23 -0
- package/dist/core/mods/package.js +118 -0
- package/dist/core/mods/stations.d.ts +2 -2
- package/dist/core/mods/stations.js +1 -1
- package/dist/core/mods/tool-call.d.ts +5 -1
- package/dist/core/mods/tool-call.js +12 -3
- package/dist/core/path-guard-rows.d.ts +20 -0
- package/dist/core/path-guard-rows.js +11 -0
- package/dist/core/peer-seat.d.ts +186 -0
- package/dist/core/peer-seat.js +307 -0
- package/dist/core/present-plan-tool.d.ts +10 -1
- package/dist/core/present-plan-tool.js +46 -2
- package/dist/core/protocol-http-auth.d.ts +40 -29
- package/dist/core/protocol-http-auth.js +30 -32
- package/dist/core/redaction-marks.d.ts +16 -0
- package/dist/core/redaction-marks.js +16 -0
- package/dist/core/redaction-passes.js +8 -9
- package/dist/core/retention.d.ts +41 -15
- package/dist/core/retention.js +59 -12
- package/dist/core/rewrite-rejudge.d.ts +37 -0
- package/dist/core/rewrite-rejudge.js +40 -0
- package/dist/core/run-origin.d.ts +40 -0
- package/dist/core/run-origin.js +37 -0
- package/dist/core/runner/advertised-writable-dirs.d.ts +57 -38
- package/dist/core/runner/advertised-writable-dirs.js +126 -0
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/contracts.d.ts +13 -5
- package/dist/core/runner/gate-exit.d.ts +18 -4
- package/dist/core/runner/gate-exit.js +5 -1
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +2 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +1 -1
- package/dist/core/runner/prepare-config-doors.d.ts +8 -5
- package/dist/core/runner/prepare-config-doors.js +12 -10
- package/dist/core/runner/prepare-delegation-surface.d.ts +4 -0
- package/dist/core/runner/prepare-delegation-surface.js +15 -18
- package/dist/core/runner/prepare-gate-stations.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +7 -3
- package/dist/core/runner/prepare-hands-readface.js +4 -1
- package/dist/core/runner/prepare-memory.d.ts +3 -0
- package/dist/core/runner/prepare-memory.js +19 -23
- package/dist/core/runner/prepare-policy-chain.d.ts +4 -4
- package/dist/core/runner/prepare-policy-chain.js +2 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -2
- package/dist/core/runner/prepare-protocol-tools.js +3 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +2 -0
- package/dist/core/runner/prepare-suspend-saga.js +2 -1
- package/dist/core/runner/prepare-task.js +25 -12
- package/dist/core/runner/prepare-wiring-manifest.d.ts +1 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -2
- package/dist/core/runner/prepare-workspace-restore.d.ts +3 -0
- package/dist/core/runner/prepare-workspace-restore.js +4 -4
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-checkpoint-screen.js +2 -0
- package/dist/core/runner/run-harness-handlers.d.ts +3 -4
- package/dist/core/runner/run-harness-handlers.js +1 -8
- package/dist/core/runner/run-identity-wiring.js +1 -0
- package/dist/core/runner/run-leg.js +5 -1
- package/dist/core/runner/run-notification-lane.js +3 -0
- package/dist/core/runner/terminal-account.js +3 -3
- package/dist/core/runner/tool-end-body.js +1 -0
- package/dist/core/runner/tool-occurrence.d.ts +4 -1
- package/dist/core/runner/tool-occurrence.js +2 -1
- package/dist/core/runner/write-protection-station.d.ts +8 -2
- package/dist/core/runner/write-protection-station.js +2 -0
- package/dist/core/runner-deps.d.ts +2 -2
- package/dist/core/sensitive-path-policy.js +6 -7
- package/dist/core/session-log-transfer.d.ts +24 -0
- package/dist/core/session-log-transfer.js +166 -0
- package/dist/core/session-store.d.ts +84 -19
- package/dist/core/session-store.js +162 -24
- package/dist/core/session.d.ts +92 -1
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/session-repo-contract.js +112 -5
- package/dist/core/store-contracts/session-store-contract.d.ts +4 -1
- package/dist/core/store-contracts/session-store-contract.js +236 -2
- package/dist/core/task-event.d.ts +68 -8
- package/dist/core/task-registry-shared.d.ts +2 -1
- package/dist/core/task-spec.d.ts +37 -0
- package/dist/core/task-stream.d.ts +2 -1
- package/dist/core/terminal-cause.d.ts +1 -1
- package/dist/core/tool-catalog-entries.js +1 -0
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +0 -2
- package/dist/core/untrusted-egress.js +10 -14
- package/dist/core/wiring-manifest.d.ts +12 -3
- package/dist/core/wiring-manifest.js +4 -3
- package/dist/core/workspace-snapshot.d.ts +44 -0
- package/dist/core/workspace-snapshot.js +34 -0
- package/dist/core/write-protect.d.ts +43 -3
- package/dist/core/write-protect.js +43 -16
- package/dist/engine/execution-env/node-execution-env.js +15 -11
- package/dist/engine/execution-env/symlink-chain.d.ts +7 -5
- package/dist/engine/harness/agent-harness.d.ts +5 -0
- package/dist/engine/harness/agent-harness.js +2 -0
- package/dist/engine/harness/types.d.ts +48 -7
- package/dist/engine/harness/types.js +5 -1
- package/dist/engine/llm/types.d.ts +12 -3
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/session/import-validate.js +3 -0
- package/dist/engine/session/memory-repo.d.ts +17 -9
- package/dist/engine/session/memory-repo.js +44 -34
- package/dist/engine/session/repo-utils.d.ts +22 -4
- package/dist/engine/session/repo-utils.js +49 -1
- package/dist/engine/session/storage-base.d.ts +10 -1
- package/dist/engine/session/storage-base.js +7 -1
- package/dist/index.d.ts +13 -6
- package/dist/index.js +10 -4
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +2 -2
- package/dist/internal/harness.js +2 -2
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/fs-write.d.ts +6 -3
- package/dist/tools/fs/fs-write.js +8 -7
- package/dist/tools/fs/index.d.ts +3 -0
- package/dist/tools/fs/index.js +1 -1
- package/dist/tools/fs/safety.js +40 -8
- package/dist/tools/fs/search.js +6 -24
- package/dist/tools/fs/shell-read-check.d.ts +8 -1
- package/dist/tools/fs/shell-read-check.js +59 -15
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.js +1 -1
- package/dist/tools/fs/shell-read-judge.d.ts +10 -1
- package/dist/tools/worktree.d.ts +42 -15
- package/dist/tools/worktree.js +60 -32
- package/package.json +4 -2
- package/test/export-surface.snapshot.json +63 -1
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
- package/dist/primitives/credential-ref.d.ts +0 -89
- package/dist/primitives/credential-ref.js +0 -125
- package/dist/primitives/index.d.ts +0 -2
- package/dist/primitives/index.js +0 -1
|
@@ -1,4 +1,43 @@
|
|
|
1
|
+
import { posix, win32 } from "node:path";
|
|
1
2
|
import { isWithin } from "./session-rule-policy.js";
|
|
3
|
+
import { isWinFormPath, normalizeAbsPathLexically } from "../../tools/fs/safety.js";
|
|
4
|
+
import { validatePath } from "../effective-path-target.js";
|
|
5
|
+
import { inlineUntrusted } from "../untrusted-text.js";
|
|
6
|
+
export const PLAN_FILE_INVALID_CODE = "config.plan_file_invalid";
|
|
7
|
+
export function planFileInvalid(value, why) {
|
|
8
|
+
let shown;
|
|
9
|
+
try {
|
|
10
|
+
shown = JSON.stringify(value) ?? String(value);
|
|
11
|
+
}
|
|
12
|
+
catch {
|
|
13
|
+
shown = typeof value;
|
|
14
|
+
}
|
|
15
|
+
const e = new Error(`TaskSpec.planFile ${shown} ${why} — the plan file must be the absolute path, in lexical normal form, of a regular file (or of a file not yet written) whose directory exists, on a leg whose file tools can write; ` +
|
|
16
|
+
`a plan file the gates cannot hold as declared would teach the model a file nobody can write, so the run is refused rather than started without it.`);
|
|
17
|
+
e.code = PLAN_FILE_INVALID_CODE;
|
|
18
|
+
e.detail = { planFile: value, reason: why };
|
|
19
|
+
return e;
|
|
20
|
+
}
|
|
21
|
+
export function checkedPlanFileShape(value) {
|
|
22
|
+
if (value === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
if (typeof value !== "string")
|
|
25
|
+
throw planFileInvalid(value, `is a ${value === null ? "null" : typeof value}, not a string`);
|
|
26
|
+
if (value.length === 0)
|
|
27
|
+
throw planFileInvalid(value, "is an empty string");
|
|
28
|
+
if (validatePath(value, { intent: "validate-coordinate" }) === undefined)
|
|
29
|
+
throw planFileInvalid(value, "is not an absolute path");
|
|
30
|
+
if (normalizeAbsPathLexically(value) !== value)
|
|
31
|
+
throw planFileInvalid(value, `is not in lexical normal form (it reads as ${normalizeAbsPathLexically(value)})`);
|
|
32
|
+
if (inlineUntrusted(value, PLAN_PATH_MAX) !== value)
|
|
33
|
+
throw planFileInvalid(value, `cannot be told to the model verbatim (a control character, a run of whitespace, an envelope marker, or more than ${PLAN_PATH_MAX} characters)`);
|
|
34
|
+
return value;
|
|
35
|
+
}
|
|
36
|
+
export const PLAN_PATH_MAX = 4096;
|
|
37
|
+
export function planFileShown(path) {
|
|
38
|
+
return inlineUntrusted(path, PLAN_PATH_MAX);
|
|
39
|
+
}
|
|
40
|
+
export const PLAN_FILE_MAX_BYTES = 1024 * 1024;
|
|
2
41
|
export function swallowedFenceRoot(domainCanonical, fenceRootsCanonical) {
|
|
3
42
|
for (const root of fenceRootsCanonical) {
|
|
4
43
|
if (root && isWithin(domainCanonical, root))
|
|
@@ -51,6 +90,93 @@ export class AdvertisedWritableDirs {
|
|
|
51
90
|
get roots() {
|
|
52
91
|
return this.admitted;
|
|
53
92
|
}
|
|
93
|
+
get planFile() {
|
|
94
|
+
return this.admittedPlanFile;
|
|
95
|
+
}
|
|
96
|
+
admittedPlanFile;
|
|
97
|
+
async admitPlanFile(spelled) {
|
|
98
|
+
const win = isWinFormPath(spelled);
|
|
99
|
+
const pathOps = win ? win32 : posix;
|
|
100
|
+
const parent = pathOps.dirname(spelled);
|
|
101
|
+
const name = pathOps.basename(spelled);
|
|
102
|
+
if (!name || parent === spelled)
|
|
103
|
+
throw planFileInvalid(spelled, "names no file below a directory");
|
|
104
|
+
const leaf = await this.env.fileInfo(spelled);
|
|
105
|
+
if (leaf.ok && leaf.value.kind !== "file")
|
|
106
|
+
throw planFileInvalid(spelled, leaf.value.kind === "symlink" ? "is a symbolic link (the plan file must be the file itself, not a link to one)" : `is a ${leaf.value.kind}, not a file`);
|
|
107
|
+
if (!leaf.ok && leaf.error.code !== "not_found")
|
|
108
|
+
throw planFileInvalid(spelled, `could not be examined (${leaf.error.code}: ${leaf.error.message})`);
|
|
109
|
+
const parentCanonical = await this.env.canonicalPath(parent);
|
|
110
|
+
if (!parentCanonical.ok)
|
|
111
|
+
throw planFileInvalid(spelled, `has a directory that does not resolve (${parentCanonical.error.code}: ${parentCanonical.error.message}) — the host creates the plan file's directory before the run`);
|
|
112
|
+
const parentInfo = await this.env.fileInfo(parentCanonical.value);
|
|
113
|
+
if (!parentInfo.ok || parentInfo.value.kind !== "directory")
|
|
114
|
+
throw planFileInvalid(spelled, `has a parent ${parentCanonical.value} that is not a directory`);
|
|
115
|
+
const own = leaf.ok ? await this.env.canonicalPath(spelled) : undefined;
|
|
116
|
+
if (own !== undefined && !own.ok)
|
|
117
|
+
throw planFileInvalid(spelled, `could not be resolved (${own.error.code}: ${own.error.message})`);
|
|
118
|
+
const joined = own?.ok === true ? own : await this.env.joinPath([parentCanonical.value, name]);
|
|
119
|
+
if (!joined.ok)
|
|
120
|
+
throw planFileInvalid(spelled, `could not be joined below its directory (${joined.error.code}: ${joined.error.message})`);
|
|
121
|
+
const key = joined.value;
|
|
122
|
+
await this.resolveDeclaredRoots();
|
|
123
|
+
const swallowed = swallowedFenceRoot(key, [...this.fenceRoots, ...this.admitted]);
|
|
124
|
+
if (swallowed !== undefined && swallowed !== key)
|
|
125
|
+
throw planFileInvalid(spelled, `resolves to ${key}, which holds the root ${swallowed}`);
|
|
126
|
+
if (!this.admitted.includes(key))
|
|
127
|
+
this.admitted.push(key);
|
|
128
|
+
this.admittedPlanFile = Object.freeze({ spelled, key });
|
|
129
|
+
this.verdicts.set("plan", "admitted");
|
|
130
|
+
return key;
|
|
131
|
+
}
|
|
132
|
+
async readPlanFile(signal) {
|
|
133
|
+
const planFile = this.admittedPlanFile;
|
|
134
|
+
if (planFile === undefined)
|
|
135
|
+
return { ok: false, reason: "this run admitted no plan file" };
|
|
136
|
+
const canonical = await this.env.canonicalPath(planFile.key, signal);
|
|
137
|
+
if (!canonical.ok)
|
|
138
|
+
return canonical.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${canonical.error.code}: ${canonical.error.message}` };
|
|
139
|
+
if (canonical.value !== planFile.key)
|
|
140
|
+
return { ok: false, reason: `it now resolves to ${canonical.value} (a link replaced it or one of its directories), which is not read through` };
|
|
141
|
+
let bytes;
|
|
142
|
+
if (this.env.openBound !== undefined) {
|
|
143
|
+
const held = await this.env.openBound(planFile.key, signal);
|
|
144
|
+
if (!held.ok)
|
|
145
|
+
return held.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${held.error.code}: ${held.error.message}` };
|
|
146
|
+
try {
|
|
147
|
+
if (held.value.kind !== "file")
|
|
148
|
+
return { ok: false, reason: `it is now a ${held.value.kind}` };
|
|
149
|
+
const read = await held.value.readBytes(PLAN_FILE_MAX_BYTES, signal);
|
|
150
|
+
if (!read.ok)
|
|
151
|
+
return { ok: false, reason: `${read.error.code}: ${read.error.message}` };
|
|
152
|
+
bytes = read.value;
|
|
153
|
+
}
|
|
154
|
+
finally {
|
|
155
|
+
await held.value.close();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
const leaf = await this.env.fileInfo(planFile.key, signal);
|
|
160
|
+
if (!leaf.ok)
|
|
161
|
+
return leaf.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${leaf.error.code}: ${leaf.error.message}` };
|
|
162
|
+
if (leaf.value.kind !== "file")
|
|
163
|
+
return { ok: false, reason: leaf.value.kind === "symlink" ? "it is now a symbolic link, which is not read through" : `it is now a ${leaf.value.kind}` };
|
|
164
|
+
if (leaf.value.size > PLAN_FILE_MAX_BYTES)
|
|
165
|
+
return { ok: false, reason: `it is ${leaf.value.size} bytes, over the ${PLAN_FILE_MAX_BYTES} a plan is read up to` };
|
|
166
|
+
const read = await this.env.readBinaryFile(planFile.key, signal);
|
|
167
|
+
if (!read.ok)
|
|
168
|
+
return read.error.code === "not_found" ? { ok: true, text: undefined } : { ok: false, reason: `${read.error.code}: ${read.error.message}` };
|
|
169
|
+
const after = await this.env.canonicalPath(planFile.key, signal);
|
|
170
|
+
const afterLeaf = await this.env.fileInfo(planFile.key, signal);
|
|
171
|
+
if (!after.ok || after.value !== planFile.key || !afterLeaf.ok || afterLeaf.value.kind !== "file")
|
|
172
|
+
return { ok: false, reason: "it changed while it was read (a link or another object replaced it), so it is not read through" };
|
|
173
|
+
if (read.value.length > PLAN_FILE_MAX_BYTES)
|
|
174
|
+
return { ok: false, reason: `it is ${read.value.length} bytes, over the ${PLAN_FILE_MAX_BYTES} a plan is read up to` };
|
|
175
|
+
bytes = read.value;
|
|
176
|
+
}
|
|
177
|
+
const text = new TextDecoder("utf-8").decode(bytes);
|
|
178
|
+
return { ok: true, text: text.trim() === "" ? undefined : text };
|
|
179
|
+
}
|
|
54
180
|
verdictOf(advertiser) {
|
|
55
181
|
return this.verdicts.get(advertiser) ?? "not-asked";
|
|
56
182
|
}
|
|
@@ -3,10 +3,10 @@ import { type PostureFacts } from "../auto-mode-directive.js";
|
|
|
3
3
|
import type { Prepared } from "./contracts.js";
|
|
4
4
|
/**
|
|
5
5
|
* The facts the posture composition reads, as the leg IS now: the live effective mode and ask answer, the plan-exit
|
|
6
|
-
* tool's presence on the minted roster,
|
|
6
|
+
* tool's presence on the minted roster, the minted delegation identity, and the session plan file the run admitted. The one place a leg's facts are assembled —
|
|
7
7
|
* the leg's first turn, a resumed continuation, a continuing boundary and a landed compaction all ask through it.
|
|
8
8
|
*/
|
|
9
|
-
export declare function postureFactsOf(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity">): PostureFacts;
|
|
9
|
+
export declare function postureFactsOf(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "advertisedWritableDirs">): PostureFacts;
|
|
10
10
|
/**
|
|
11
11
|
* The posture question, asked of the ACTIVE context: the frames the leg's mode facts owe now (exits of retired
|
|
12
12
|
* families, the owed frame or its cadence's restatement — `composePostureFrames`), minted as one carrier text —
|
|
@@ -18,7 +18,7 @@ export declare function postureFactsOf(prepared: Pick<Prepared, "approvalPosture
|
|
|
18
18
|
* function's own carriers and a landed compaction (which asks with `"always"`). A context that cannot be read
|
|
19
19
|
* answers "nothing standing": the owed frame is restated rather than withheld.
|
|
20
20
|
*/
|
|
21
|
-
export declare function owedPostureText(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "session" | "reminderMark" | "postureFrameRef">, ask: "always" | "on_change"): Promise<string | undefined>;
|
|
21
|
+
export declare function owedPostureText(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "advertisedWritableDirs" | "session" | "reminderMark" | "postureFrameRef">, ask: "always" | "on_change"): Promise<string | undefined>;
|
|
22
22
|
/** The posture's COMPACTION arm: after a landed compaction the runner asks the posture question of the compacted
|
|
23
23
|
* context and appends what it owes as one engine-minted message, before any reader of the new baseline (the next
|
|
24
24
|
* model request included). A leg that owes no posture registers nothing: a compaction only REMOVES frames, and a
|
|
@@ -35,7 +35,7 @@ export declare function postureRestateOption(prepared: Prepared): Pick<MaybeComp
|
|
|
35
35
|
* of every engine frame written at a boundary, the git frame's re-assert and the compaction itself: the run continues
|
|
36
36
|
* and the failure is reported, `onError` phase `degraded`). Never throws.
|
|
37
37
|
*/
|
|
38
|
-
export declare function appendOwedPosture(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "session" | "reminderMark" | "postureFrameRef" | "batchHaltRef" | "frameReceipts">, ask: "always" | "on_change"): Promise<void>;
|
|
38
|
+
export declare function appendOwedPosture(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "advertisedWritableDirs" | "session" | "reminderMark" | "postureFrameRef" | "batchHaltRef" | "frameReceipts">, ask: "always" | "on_change"): Promise<void>;
|
|
39
39
|
/** The declared output style's frame as one engine-marked reminder — the one spelling every site that states it directly
|
|
40
40
|
* (a resumed leg's continuation, a boundary a queued input continues) mints. */
|
|
41
41
|
export declare function mintOutputStyleReminder(prepared: Pick<Prepared, "outputStyleFrame" | "reminderMark">): string | undefined;
|
|
@@ -49,6 +49,15 @@ export declare function frameCarried(ledger: Prepared["frameReceipts"], source:
|
|
|
49
49
|
* carries it ({@link frameCarried}). Both frames keep the posture's halt rule. The guarantee is read synchronously, at
|
|
50
50
|
* the call, before any await — a boundary with nothing queued returns the posture's own promise.
|
|
51
51
|
*/
|
|
52
|
-
export declare function appendBoundaryFrames(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "session" | "reminderMark" | "postureFrameRef" | "batchHaltRef" | "outputStyleFrame" | "harness" | "frameReceipts">, turnOwesRequest: boolean): Promise<void>;
|
|
52
|
+
export declare function appendBoundaryFrames(prepared: Pick<Prepared, "approvalPosture" | "toolRoster" | "hookIdentity" | "advertisedWritableDirs" | "session" | "reminderMark" | "postureFrameRef" | "batchHaltRef" | "outputStyleFrame" | "harness" | "frameReceipts">, turnOwesRequest: boolean): Promise<void>;
|
|
53
|
+
/**
|
|
54
|
+
* The session plan file's post-compaction reference (the reference's `plan_file_reference`, CC 2.1.309 `Tmr` (cli309.js:265943)): a compaction
|
|
55
|
+
* summarizes away the turns that wrote the plan, so a leg whose run admitted a plan file that holds a plan is told where
|
|
56
|
+
* it is and what it says, in any mode — the reference's own sentences, the plan fenced as the untrusted model text it is.
|
|
57
|
+
* Read through the seat's one reader; an absent or blank file says nothing (there is no plan to refer to), and an
|
|
58
|
+
* unreadable one is not guessed at. One engine-minted message, appended like the posture's; a failed append is reported
|
|
59
|
+
* and never fails the landed compaction.
|
|
60
|
+
*/
|
|
61
|
+
export declare function planFileRestateOption(prepared: Prepared): Pick<MaybeCompactOptions, "planFileRestate">;
|
|
53
62
|
/** Every post-compaction restatement the turn boundary registers, at one spread site. */
|
|
54
|
-
export declare function compactionRestateOptions(prepared: Prepared): Pick<MaybeCompactOptions, "gitRestate" | "postureRestate" | "advisorRestate">;
|
|
63
|
+
export declare function compactionRestateOptions(prepared: Prepared): Pick<MaybeCompactOptions, "gitRestate" | "postureRestate" | "planFileRestate" | "advisorRestate">;
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { composePostureFrames, owedPostureRow, postureStandingOf } from "../auto-mode-directive.js";
|
|
2
|
+
import { planFileShown } from "./advertised-writable-dirs.js";
|
|
2
3
|
import { PRESENT_PLAN_TOOL_NAME } from "../present-plan-tool.js";
|
|
3
4
|
import { mintSystemReminder } from "../reminder-mint.js";
|
|
4
5
|
import { thrownText } from "../thrown-value.js";
|
|
5
6
|
import { rosterEntryNamed } from "../tool-roster.js";
|
|
6
|
-
import { sanitizeUntrustedText } from "../untrusted-text.js";
|
|
7
|
+
import { delimitUntrusted, sanitizeUntrustedText } from "../untrusted-text.js";
|
|
7
8
|
import { appendAdvisorRestate } from "./advisor-instructions.js";
|
|
8
9
|
import { gitRestateOption } from "./git-leg-delivery.js";
|
|
9
10
|
import { attachmentEnvelopeTags } from "./turn-attachments.js";
|
|
@@ -13,6 +14,7 @@ export function postureFactsOf(prepared) {
|
|
|
13
14
|
askEffective: prepared.approvalPosture.askEffective,
|
|
14
15
|
exitToolMounted: rosterEntryNamed(prepared.toolRoster, PRESENT_PLAN_TOOL_NAME) !== undefined,
|
|
15
16
|
isChildLeg: prepared.hookIdentity.isDelegatedChild,
|
|
17
|
+
...(prepared.advertisedWritableDirs?.planFile !== undefined ? { planFile: planFileShown(prepared.advertisedWritableDirs.planFile.spelled) } : {}),
|
|
16
18
|
};
|
|
17
19
|
}
|
|
18
20
|
export async function owedPostureText(prepared, ask) {
|
|
@@ -99,6 +101,30 @@ export function appendBoundaryFrames(prepared, turnOwesRequest) {
|
|
|
99
101
|
const posture = appendOwedPosture(prepared, "on_change");
|
|
100
102
|
return styleOwed ? posture.then(() => appendOutputStyleRestate(prepared)) : posture;
|
|
101
103
|
}
|
|
104
|
+
export function planFileRestateOption(prepared) {
|
|
105
|
+
const seat = prepared.advertisedWritableDirs;
|
|
106
|
+
const planFile = seat?.planFile;
|
|
107
|
+
if (seat === undefined || planFile === undefined)
|
|
108
|
+
return {};
|
|
109
|
+
return {
|
|
110
|
+
planFileRestate: async () => {
|
|
111
|
+
const read = await seat.readPlanFile();
|
|
112
|
+
if (!read.ok || read.text === undefined)
|
|
113
|
+
return;
|
|
114
|
+
const body = `A plan file exists from plan mode at: ${planFileShown(planFile.spelled)}\n\nPlan contents:\n\n${delimitUntrusted("plan", read.text)}\n\nIf this plan is relevant to the current work and not already complete, continue working on it.`;
|
|
115
|
+
try {
|
|
116
|
+
await prepared.session.appendMessage({ role: "user", content: [{ type: "text", text: mintSystemReminder(body, prepared.reminderMark) }], timestamp: Date.now(), engineMinted: true });
|
|
117
|
+
}
|
|
118
|
+
catch (err) {
|
|
119
|
+
try {
|
|
120
|
+
prepared.postureFrameRef.report?.(new Error(`the plan file reference could not be written to the transcript after the compaction: ${thrownText(err)}`));
|
|
121
|
+
}
|
|
122
|
+
catch {
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
},
|
|
126
|
+
};
|
|
127
|
+
}
|
|
102
128
|
export function compactionRestateOptions(prepared) {
|
|
103
|
-
return { ...gitRestateOption(prepared), ...postureRestateOption(prepared), ...(prepared.advisorInstruction?.mounted === true ? { advisorRestate: () => appendAdvisorRestate(prepared) } : {}) };
|
|
129
|
+
return { ...gitRestateOption(prepared), ...postureRestateOption(prepared), ...planFileRestateOption(prepared), ...(prepared.advisorInstruction?.mounted === true ? { advisorRestate: () => appendAdvisorRestate(prepared) } : {}) };
|
|
104
130
|
}
|
|
@@ -406,8 +406,10 @@ export interface Prepared {
|
|
|
406
406
|
* states are their own values); the seat is optional only so a Prepared shape without the phase
|
|
407
407
|
* cannot fabricate one. */
|
|
408
408
|
effectiveMemoryScopes?: import("../types.js").EffectiveMemoryScopes;
|
|
409
|
-
/** The per-task logical cwd ref when a real shell is mounted (else undefined);
|
|
409
|
+
/** The per-task logical cwd ref when a real shell is mounted (else undefined); the workspace frame reads it. */
|
|
410
410
|
cwdRef?: CwdRef;
|
|
411
|
+
/** The leg's `workspace_changed` seat (its one snapshot projection): the run binds the sink after `wiring_manifest` (the leg-start frame) and observes after each tool. */
|
|
412
|
+
workspaceFrame: import("../workspace-snapshot.js").WorkspaceFrameSeat;
|
|
411
413
|
/** The root the hand tools resolve root-relative spellings against (present with hands; read-only hands included). */
|
|
412
414
|
handsRoot?: string;
|
|
413
415
|
/** The leg's target-reading stamp (present with hands): the resume belts stamp the executed bytes' request with it. */
|
|
@@ -419,8 +421,8 @@ export interface Prepared {
|
|
|
419
421
|
toolProgressRef: {
|
|
420
422
|
current?: ToolProgressLane;
|
|
421
423
|
};
|
|
422
|
-
/** The run's advertised-writable-directory seat (present with hands): `roots` is what the prompt advertised as writable and the fence admitted. Read live wherever a policy is adjudicated off a resumed leg, so the write gate's exemption domain is that same list. */
|
|
423
|
-
advertisedWritableDirs?: Pick<import("./advertised-writable-dirs.js").AdvertisedWritableDirs, "roots">;
|
|
424
|
+
/** The run's advertised-writable-directory seat (present with hands): `roots` is what the prompt advertised as writable and the fence admitted. Read live wherever a policy is adjudicated off a resumed leg, so the write gate's exemption domain is that same list. `planFile` is the session plan file it admitted (`TaskSpec.planFile`) — the posture frames name it. */
|
|
425
|
+
advertisedWritableDirs?: Pick<import("./advertised-writable-dirs.js").AdvertisedWritableDirs, "roots" | "planFile" | "readPlanFile">;
|
|
424
426
|
/** The leg's ONE exempt root (its single resolution of `RunnerDeps.memoryEngineDir`), stamped wherever a policy is adjudicated off a resumed leg (`ToolCallRequest.exemptRoots`) — the same list the live gate stamps. */
|
|
425
427
|
exemptRoots: readonly string[];
|
|
426
428
|
/** The ACTIVE EnterWorktree session ref (mounted with the worktree tools; undefined without
|
|
@@ -1312,6 +1314,11 @@ export interface PrepareResume {
|
|
|
1312
1314
|
/** The decision this resume carries (the gate word and, for a review, approve / edit / reject) — read by the mode seed
|
|
1313
1315
|
* (`modeRequestAfterResume`: an approved or edited `plan_review` exits a recorded plan to its pre-plan word). Absent on a prepare that resumes nothing. */
|
|
1314
1316
|
outcome?: ResumeRun["outcome"];
|
|
1317
|
+
/** Present when the resume opens this leg with inputs it hands over — a wake: the newest of them (its message, else the parked
|
|
1318
|
+
* entry delivered last; `wakeOpening`): its run-origin word (absent = it said none) is the leg's word instead of the row's. */
|
|
1319
|
+
opening?: {
|
|
1320
|
+
readonly word: unknown;
|
|
1321
|
+
};
|
|
1315
1322
|
/** The leg's mods bus, when the resume entrance already admitted it (a wake message's screen raises
|
|
1316
1323
|
* `classic.UserPromptSubmit` before this leg prepares): prepare adopts it instead of admitting a second time. */
|
|
1317
1324
|
legMods?: LegMods;
|
|
@@ -2602,8 +2609,9 @@ export interface RunState {
|
|
|
2602
2609
|
* an internally-generated continuation, so both are omitted.
|
|
2603
2610
|
*/
|
|
2604
2611
|
/** A resume continues the suspended leg: it sends no new human message, so it takes neither an objective nor the
|
|
2605
|
-
* objective's attachments (a config that carries `userAttachments` anyway is
|
|
2606
|
-
|
|
2612
|
+
* objective's attachments nor the objective's run origin (a config that carries `userAttachments` or `runOrigin` anyway is
|
|
2613
|
+
* refused before the claim; a wake states its leg's word on the input it hands over). */
|
|
2614
|
+
export type ResumeTaskConfig = Omit<TaskSpec, "objective" | "sessionId" | "userAttachments" | "runOrigin">;
|
|
2607
2615
|
/** Resume plan threaded from {@link Runner.resume} into the shared run loop. */
|
|
2608
2616
|
export interface ResumeRun {
|
|
2609
2617
|
cp: Checkpoint;
|
|
@@ -26,6 +26,7 @@ import type { AllowRuleClearance } from "../allow-rule-shadow.js";
|
|
|
26
26
|
import type { AutoModeClassifierRound } from "../auto-mode.js";
|
|
27
27
|
import { type Arbitration, type AskClassification, type AskFace, type AskOrigin, type AskOriginFacts } from "../ask-origin.js";
|
|
28
28
|
import { type PermissionResult, type ResolvedAsk, type ToolCallRequest } from "../tool-policy.js";
|
|
29
|
+
import { type RewriteAccount } from "../rewrite-rejudge.js";
|
|
29
30
|
import type { SafeNotifier } from "../safe-notify.js";
|
|
30
31
|
import type { PermissionDeniedPayload, PreToolUseResult, ToolGateInput, ToolGateResult } from "../hooks.js";
|
|
31
32
|
/** The ask a gate pass settled, as the gate captured it at its resolution site: the settlement the
|
|
@@ -137,11 +138,13 @@ export declare function frozenInputSnapshot(input: unknown): unknown;
|
|
|
137
138
|
* engine's fail-closed refusal of the call with its sentence (a handler that failed or broke the site's contract,
|
|
138
139
|
* or a cancel). */
|
|
139
140
|
/** A screen's outcome; an answer names the registration whose answer the chain returned (`answeredBy`, absent when no
|
|
140
|
-
* handler spoke)
|
|
141
|
+
* handler spoke) and the extensions that authored its `updatedInput` (`rewrittenBy`, in the order they rewrote; absent
|
|
142
|
+
* when the answer carries no rewrite). */
|
|
141
143
|
export type PreToolUseScreen = {
|
|
142
144
|
readonly kind: "answered";
|
|
143
145
|
readonly answer: PreToolUseResult | undefined;
|
|
144
146
|
readonly answeredBy?: string;
|
|
147
|
+
readonly rewrittenBy?: readonly string[];
|
|
145
148
|
} | {
|
|
146
149
|
readonly kind: "refused";
|
|
147
150
|
readonly reason: string;
|
|
@@ -153,9 +156,12 @@ export type PreToolUseScreen = {
|
|
|
153
156
|
* event (an observe handler runs inside the screening too; it never decides).
|
|
154
157
|
*/
|
|
155
158
|
export interface PreToolUseScreening {
|
|
156
|
-
/** Raise `classic.PreToolUse` over `args`; `subject` names what is screened in a fail-closed sentence
|
|
157
|
-
*
|
|
158
|
-
|
|
159
|
+
/** Raise `classic.PreToolUse` over `args`; `subject` names what is screened in a fail-closed sentence; `readAs` is the call
|
|
160
|
+
* whose reading of its args the rewrite authors are compared under (absent ⇒ the values as given). What the gate does after
|
|
161
|
+
* the screen answers runs in the screen's own continuation. */
|
|
162
|
+
screen(args: unknown, subject: string, readAs?: {
|
|
163
|
+
readonly face?: object | undefined;
|
|
164
|
+
}): Promise<PreToolUseScreen>;
|
|
159
165
|
/** The model-facing text for the screen's OWN deny of this call (unwrapped; every exit wraps it with the leg's mark). */
|
|
160
166
|
deniedReason(answer: PreToolUseResult): string;
|
|
161
167
|
}
|
|
@@ -223,6 +229,9 @@ export interface GatePass {
|
|
|
223
229
|
* of a value nothing took ({@link untakenValueExit}), where it holds that value as given and only the deny exit's receipt
|
|
224
230
|
* reads it. Writers: the dispatch (phase 1), the lanes, the exits. */
|
|
225
231
|
currentInput: unknown;
|
|
232
|
+
/** borrowed-mutable — who replaced the args, against the bytes taken at the entry ({@link RewriteAccount}): every station that
|
|
233
|
+
* adopts other bytes names its author there; the allow exit reads it into the call's record. */
|
|
234
|
+
readonly rewrites: RewriteAccount;
|
|
226
235
|
/** borrowed-mutable — the adjudication request. Minted over the pass's args so the record is whole from
|
|
227
236
|
* the first station, and RE-MINTED by the adjudication station over the FINAL post-screen args (the
|
|
228
237
|
* pre-existing `const req` site); `args` is re-pointed at the policy rewrite on the ask path. Writers: the
|
|
@@ -318,6 +327,11 @@ export interface GatePass {
|
|
|
318
327
|
* on BOTH its arms (a write tool's target), and the fold's read station (a shell command's written targets,
|
|
319
328
|
* `ShellReadVerdict.writeProtected`). Reader: the lanes' mandate. */
|
|
320
329
|
writeProtected?: true;
|
|
330
|
+
/** borrowed-mutable — the same judge's table was met by a written target only where the path resolves on disk (the path as
|
|
331
|
+
* written names no row): the class the auto-mode classifier does not answer. Writers: the two writers of `writeProtected`
|
|
332
|
+
* (`writeProtectionReachOf` for a write tool's target, `ShellReadVerdict.writeProtectedOnDisk` for a command's). Reader: the
|
|
333
|
+
* lanes' mandate. */
|
|
334
|
+
writeProtectedOnDisk?: true;
|
|
321
335
|
/** borrowed-mutable — the READING of a written target could not say where it leads on disk (a target a shell command's
|
|
322
336
|
* program writes, placed, whose destination the read station could not resolve): no automatic lane may answer the ask.
|
|
323
337
|
* A fact of the reading, not of a judge. Writer: the fold's read station (`ShellReadVerdict.targetUnresolved`). Reader:
|
|
@@ -5,6 +5,7 @@ import { isProtectedWrite } from "../tool-registry.js";
|
|
|
5
5
|
import { attestationOf, decisionText, licenseCovers } from "../tool-policy.js";
|
|
6
6
|
import { pathDenialCardOf } from "../../tools/fs/safety.js";
|
|
7
7
|
import { argsAsTheToolReads } from "../effective-path-target.js";
|
|
8
|
+
import { rewriteRecordOf } from "../rewrite-rejudge.js";
|
|
8
9
|
import { askUnresolvableRemedySeat } from "../ask-unresolvable-notice.js";
|
|
9
10
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
10
11
|
import { formatHookFeedback } from "../reminder-mint.js";
|
|
@@ -319,10 +320,13 @@ export async function exitGate(pass) {
|
|
|
319
320
|
}
|
|
320
321
|
const release = pass.arbitration?.kind === "released" ? pass.arbitration : (() => { if (ledger.settled !== undefined)
|
|
321
322
|
return undefined; const a = pass.arbitration === undefined ? input.ancestorArbitrationOf?.(toolCallId) : undefined; return a?.kind === "released" ? a : undefined; })();
|
|
323
|
+
const finalInput = frozenInputSnapshot(pass.currentInput);
|
|
324
|
+
const rewrite = rewriteRecordOf(pass.rewrites, pass.req, pass.currentInput, finalInput);
|
|
322
325
|
return {
|
|
323
326
|
updatedInput: pass.currentInput,
|
|
324
327
|
gate: mintGateOutcome({ ...(ledger.settled !== undefined ? { settled: ledger.settled } : {}), ...(pass.classifierRound !== undefined ? { classifier: pass.classifierRound } : {}), ...(release !== undefined ? { released: releaseRecordOf(release) } : {}), ...(pass.clearedBy !== undefined && ledger.settled === undefined && release === undefined ? { clearedBy: pass.clearedBy } : {}) }),
|
|
325
|
-
finalInput
|
|
328
|
+
finalInput,
|
|
329
|
+
...(rewrite !== undefined ? { rewrite } : {}),
|
|
326
330
|
preToolContext: pass.preToolContext,
|
|
327
331
|
};
|
|
328
332
|
}
|
|
@@ -29,6 +29,7 @@ import { type AutoModeDecider, type AutoModeDenialTracker } from "../auto-mode.j
|
|
|
29
29
|
import { type CheckpointSeat } from "../checkpoint-seat.js";
|
|
30
30
|
import { type ComplianceCapability } from "../compliance.js";
|
|
31
31
|
import type { LockedPreflight } from "../locked-config.js";
|
|
32
|
+
import { type PlanFileSource } from "../present-plan-tool.js";
|
|
32
33
|
import type { StoredSession } from "../session.js";
|
|
33
34
|
import type { RunnerDeps, RuntimeCaps, TaskEvent, ToolExecuteContext } from "../types.js";
|
|
34
35
|
import type { AutoModeArmFact } from "../wiring-manifest.js";
|
|
@@ -108,6 +109,7 @@ export interface PrepareCapsAndWorkflowInput {
|
|
|
108
109
|
requestReview: (opts?: {
|
|
109
110
|
reason?: string;
|
|
110
111
|
}) => void;
|
|
112
|
+
/** borrowed-readonly — the declared session plan file as ExitPlanMode's FILE arm reads it (absent ⇒ the parameter arm). */ planFileSource?: PlanFileSource;
|
|
111
113
|
/** borrowed-readonly — the plan-mode primitive the EnterPlanMode tool calls: a steer of the leg's mode seat into `plan`. */
|
|
112
114
|
enterPlanMode: () => Promise<void>;
|
|
113
115
|
/** borrowed-readonly — the leg's live permission-mode seat: the arming's first arm is `declared === "auto"`, and the
|
|
@@ -149,7 +149,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
149
149
|
if (spec.enablePlanMode === true && spec.interactiveTools !== false) {
|
|
150
150
|
const planReviewFace = checkpointStoreOfSeat(checkpointSeat) !== undefined;
|
|
151
151
|
if (spec.interactiveTools === true || planReviewFace) {
|
|
152
|
-
roster.mount(defineTool(createPresentPlanTool(requestReview)), { source: "builtin", mountedBy: "optional" });
|
|
152
|
+
roster.mount(defineTool(createPresentPlanTool(requestReview, input.planFileSource)), { source: "builtin", mountedBy: "optional" });
|
|
153
153
|
if (planReviewFace) {
|
|
154
154
|
roster.mount(defineTool(createEnterPlanModeTool(enterPlanMode)), { source: "builtin", mountedBy: "optional" });
|
|
155
155
|
}
|
|
@@ -24,7 +24,8 @@ import type { ThinkingLevel } from "../../internal/harness.js";
|
|
|
24
24
|
import { type MicroCompactMachine } from "../context-edit.js";
|
|
25
25
|
import { type CrossBoundaryPosture } from "../cross-boundary-taint.js";
|
|
26
26
|
import { type HostFloor } from "../host-floor.js";
|
|
27
|
-
import {
|
|
27
|
+
import { type CheckpointState } from "../checkpoint-store.js";
|
|
28
|
+
import { runOriginOfLeg, type RunOrigin } from "../run-origin.js";
|
|
28
29
|
import { type ConfigDoorEntry, type LockedPreflight } from "../locked-config.js";
|
|
29
30
|
import { type ResolvedRole } from "../roles.js";
|
|
30
31
|
import { type ResolvedSkillListingBudget } from "../skill-listing-budget.js";
|
|
@@ -210,6 +211,7 @@ export interface PrepareConfigDoorsResult {
|
|
|
210
211
|
crossBoundaryPosture: CrossBoundaryPosture | undefined;
|
|
211
212
|
advisorTool: "disabled" | undefined;
|
|
212
213
|
hostFloor: HostFloor | undefined;
|
|
214
|
+
runOrigin: RunOrigin | undefined;
|
|
213
215
|
}
|
|
214
216
|
/** The microCompact knob door (坏值响亮度默认律, the sibling knob doors' form:
|
|
215
217
|
* interactionPosture / toolModelGate / staleToolResultOffload). Placement is load-bearing:
|
|
@@ -234,7 +236,7 @@ export declare const checkpointStoreSeat: (spec: {
|
|
|
234
236
|
export declare function assertResumeConfigRecord(config: unknown): void;
|
|
235
237
|
/** The spec the value doors read: a prepare's (its roster is faces) or a resume's re-supplied config (no objective, no session id). */
|
|
236
238
|
type ValueDoorSpec = Omit<TaskSpec, "tools" | "objective" | "sessionId" | "userAttachments"> & Partial<Pick<TaskSpec, "objective" | "sessionId">>;
|
|
237
|
-
type ConfigValueDoorsResult = Pick<PrepareConfigDoorsResult, "toolFaceLists" | "promptHost" | "promptBinding" | "lockedPreflight" | "microCompactKnob" | "memoryDelegationEvidence" | "memoryProvenance" | "memoryCapturePolicy" | "usageWindows" | "brainCallGuardrailMs" | "crossBoundaryPosture" | "advisorTool" | "promptLean" | "hostFloor"> & {
|
|
239
|
+
type ConfigValueDoorsResult = Pick<PrepareConfigDoorsResult, "toolFaceLists" | "promptHost" | "promptBinding" | "lockedPreflight" | "microCompactKnob" | "memoryDelegationEvidence" | "memoryProvenance" | "memoryCapturePolicy" | "usageWindows" | "brainCallGuardrailMs" | "crossBoundaryPosture" | "advisorTool" | "promptLean" | "hostFloor" | "runOrigin"> & {
|
|
238
240
|
skillListingSeats: {
|
|
239
241
|
fraction: unknown;
|
|
240
242
|
maxDescChars: unknown;
|
|
@@ -256,20 +258,21 @@ export declare function configValueDoors(input: {
|
|
|
256
258
|
resumeLeg: boolean;
|
|
257
259
|
sessions: SessionStore;
|
|
258
260
|
holder?: string | undefined;
|
|
261
|
+
resumedRow?: Parameters<typeof runOriginOfLeg>[1];
|
|
259
262
|
}, enter?: ConfigDoorEntry): ConfigValueDoorsResult;
|
|
260
263
|
/**
|
|
261
264
|
* The doors a RESUMED leg's prepare refuses at, run as one screen BEFORE the claim — prepare's own functions, so a refusal carries
|
|
262
265
|
* the very sentence and code prepare throws: the mode doors (`refusePermissionModeDoors`), the output-style seat, the approval
|
|
263
266
|
* reach, the skills invoked by name (the part no roster changes), the attachments (a resume sends no new human message, so any
|
|
264
267
|
* entry is refused), the leg declarations of the tools it re-supplies (this phase's first door), this phase's value doors over the config, the deployment's deps and the session store the Runner holds
|
|
265
|
-
* ({@link configValueDoors}, the retention capability door
|
|
266
|
-
* It leaves by the resume's ONE refusal channel (`asResumeConfigRefusal`:
|
|
268
|
+
* ({@link configValueDoors}, the retention capability door and the run-origin door over the row's recorded word included) and the mode
|
|
269
|
+
* words the row recorded (`recordedModeSeed`). It leaves by the resume's ONE refusal channel (`asResumeConfigRefusal`:
|
|
267
270
|
* `checkpoint.config_refused`, `detail.code` = prepare's code, `detail.field` = `"taskConfig"`, `"deps"` or `"inheritedGate"`)
|
|
268
271
|
* where prepare would end the leg `failed` after the claim — the row consumed on a store without `reopen`, replayed as a system
|
|
269
272
|
* retry on one with it, which a configuration fix cannot reach. Before the claim the row stays `pending` and byte-identical and the
|
|
270
273
|
* corrected resume redeems the same token. A throw that is none of prepare's codes leaves as it was thrown. Returns the config the
|
|
271
274
|
* leg is handed: the caller's, its MCP servers and A2A peers the frozen entries the lock layer judged (read once, dialed as judged).
|
|
272
275
|
*/
|
|
273
|
-
export declare function refuseResumeDoors<C extends ValueDoorSpec & Pick<TaskSpec, "userAttachments">>(config: C,
|
|
276
|
+
export declare function refuseResumeDoors<C extends ValueDoorSpec & Pick<TaskSpec, "userAttachments">>(config: C, recorded: Pick<CheckpointState, "inheritedGate" | "runOrigin"> | undefined, deps: RunnerDeps, sessions: SessionStore, holder?: string): C;
|
|
274
277
|
export declare function prepareConfigDoors(input: PrepareConfigDoorsInput): PrepareConfigDoorsResult;
|
|
275
278
|
export {};
|
|
@@ -6,6 +6,7 @@ import { CROSS_BOUNDARY_POSTURES } from "../cross-boundary-taint.js";
|
|
|
6
6
|
import { compileHostFloor } from "../host-floor.js";
|
|
7
7
|
import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
|
|
8
8
|
import { recordedModeSeed, resolveCheckpointStore } from "../checkpoint-store.js";
|
|
9
|
+
import { runOriginOfLeg, screenRecordedRunOrigin } from "../run-origin.js";
|
|
9
10
|
import { assertCheckpointStoreJudgesHolder, assertHolderValue } from "../checkpoint-generation.js";
|
|
10
11
|
import { asResumeConfigRefusal, refusePermissionModeDoors } from "../mode-policy.js";
|
|
11
12
|
import { resolveOutputStyleFrame } from "../output-style.js";
|
|
@@ -16,7 +17,7 @@ import { screenHandsBandOptions } from "../hands-band-screen.js";
|
|
|
16
17
|
import { assertAutoConsolidationWirable } from "./memory-consolidation-driver.js";
|
|
17
18
|
import { isModelPriced, malformedPricingField, modelCostToPricing } from "../pricing.js";
|
|
18
19
|
import { ENTER_AS_IS, preflightLockedConfig } from "../locked-config.js";
|
|
19
|
-
import {
|
|
20
|
+
import { assertRetentionWords } from "../retention.js";
|
|
20
21
|
import { resolveModel, resolveTaskModel, roleModelIfSet, screenRoleMap } from "../roles.js";
|
|
21
22
|
import { resolveSkillListingBudget } from "../skill-listing-budget.js";
|
|
22
23
|
import { describeRejectedValue } from "../tool-search-setting.js";
|
|
@@ -185,6 +186,7 @@ export function configValueDoors(input, enter = ENTER_AS_IS) {
|
|
|
185
186
|
const { spec, deps, resumeLeg, sessions, holder } = input;
|
|
186
187
|
enter("deps", () => assertNoRetiredRunnerDeps(deps));
|
|
187
188
|
enter("taskConfig", () => assertPrincipalValue(spec.principal));
|
|
189
|
+
const runOrigin = enter("taskConfig", () => runOriginOfLeg(spec.runOrigin, input.resumedRow));
|
|
188
190
|
enter("taskConfig", () => assertPeerPresenceValue(spec.peerPresence));
|
|
189
191
|
enter("taskConfig", () => assertRestoreGatedToolsValue(spec.restoreGatedTools));
|
|
190
192
|
const microCompactKnob = enter("deps", () => resolveMicroCompactKnob(deps.microCompact));
|
|
@@ -328,7 +330,7 @@ export function configValueDoors(input, enter = ENTER_AS_IS) {
|
|
|
328
330
|
enter(checkpointStoreSeat(spec), () => assertCheckpointStoreJudgesHolder(checkpointStoreSeat(spec) === "taskConfig" ? "TaskSpec.checkpointStore" : "RunnerDeps.checkpointStore", checkpointStore, holder));
|
|
329
331
|
const taskStore = checkpointStoreSeat(spec) === "taskConfig" ? checkpointStore : undefined;
|
|
330
332
|
const retention = { policy: deps.retentionPolicy, locked: lockedPreflight.lockedKeys.has("retentionPolicy") };
|
|
331
|
-
enter("deps", () =>
|
|
333
|
+
enter("deps", () => assertRetentionWords({
|
|
332
334
|
...retention,
|
|
333
335
|
stores: [
|
|
334
336
|
{ name: "sessionStore", store: sessions },
|
|
@@ -337,10 +339,10 @@ export function configValueDoors(input, enter = ENTER_AS_IS) {
|
|
|
337
339
|
],
|
|
338
340
|
}));
|
|
339
341
|
if (taskStore !== undefined)
|
|
340
|
-
enter("taskConfig", () =>
|
|
341
|
-
return { toolFaceLists, promptHost, promptBinding, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor };
|
|
342
|
+
enter("taskConfig", () => assertRetentionWords({ ...retention, stores: [{ name: "checkpointStore", store: taskStore }] }));
|
|
343
|
+
return { toolFaceLists, promptHost, promptBinding, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin };
|
|
342
344
|
}
|
|
343
|
-
export function refuseResumeDoors(config,
|
|
345
|
+
export function refuseResumeDoors(config, recorded, deps, sessions, holder) {
|
|
344
346
|
asResumeConfigRefusal("taskConfig", () => {
|
|
345
347
|
refusePermissionModeDoors(config);
|
|
346
348
|
resolveOutputStyleFrame(config.outputStyle);
|
|
@@ -350,8 +352,8 @@ export function refuseResumeDoors(config, recordedGate, deps, sessions, holder)
|
|
|
350
352
|
assertToolBoundaryLegs(config.tools);
|
|
351
353
|
assertToolCardDeclarations(config.tools);
|
|
352
354
|
});
|
|
353
|
-
const { lockedPreflight, skills } = configValueDoors({ spec: config, deps, resumeLeg: true, sessions, holder }, asResumeConfigRefusal);
|
|
354
|
-
asResumeConfigRefusal("inheritedGate", () => void recordedModeSeed(
|
|
355
|
+
const { lockedPreflight, skills } = configValueDoors({ spec: config, deps, resumeLeg: true, sessions, holder, ...(recorded !== undefined ? { resumedRow: { recorded: recorded.runOrigin } } : {}) }, asResumeConfigRefusal);
|
|
356
|
+
asResumeConfigRefusal("inheritedGate", () => void recordedModeSeed(recorded?.inheritedGate));
|
|
355
357
|
return { ...config, ...(config.mcp !== undefined ? { mcp: lockedPreflight.mcp ?? [] } : {}), ...(config.a2a !== undefined ? { a2a: lockedPreflight.a2a ?? [] } : {}), skills };
|
|
356
358
|
}
|
|
357
359
|
export function prepareConfigDoors(input) {
|
|
@@ -359,9 +361,9 @@ export function prepareConfigDoors(input) {
|
|
|
359
361
|
assertToolBoundaryLegs(input.spec.tools);
|
|
360
362
|
assertToolCardDeclarations(input.spec.tools);
|
|
361
363
|
let spec = input.spec;
|
|
362
|
-
const { toolFaceLists, promptHost, promptBinding, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor } = configValueDoors({ spec, deps, resumeLeg: resume !== undefined, sessions, holder: internals?.holder });
|
|
364
|
+
const { toolFaceLists, promptHost, promptBinding, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin } = configValueDoors({ spec, deps, resumeLeg: resume !== undefined, sessions, holder: internals?.holder, ...(resume !== undefined ? { resumedRow: { recorded: screenRecordedRunOrigin(resume.seed.runOrigin), ...(resume.opening !== undefined ? { opening: resume.opening } : {}) } } : {}) });
|
|
363
365
|
const doorRead = (value) => ({ value, enumerable: value !== undefined, writable: false, configurable: false });
|
|
364
|
-
spec = Object.create(Object.getPrototypeOf(spec), { ...Object.getOwnPropertyDescriptors(spec), skills: doorRead(skills), projectMemory: doorRead(projectMemory) });
|
|
366
|
+
spec = Object.create(Object.getPrototypeOf(spec), { ...Object.getOwnPropertyDescriptors(spec), skills: doorRead(skills), projectMemory: doorRead(projectMemory), runOrigin: doorRead(runOrigin) });
|
|
365
367
|
const resolvedInteractionPosture = spec.interactionPosture ?? internals?.parentInteractionPosture ?? deps.interactionPosture;
|
|
366
368
|
const askSeat = resolveAskSeat(spec, deps);
|
|
367
369
|
{
|
|
@@ -505,7 +507,7 @@ export function prepareConfigDoors(input) {
|
|
|
505
507
|
memoryDelegationEvidence,
|
|
506
508
|
skillListingBudget,
|
|
507
509
|
memoryProvenance,
|
|
508
|
-
memoryCapturePolicy, crossBoundaryPosture, advisorTool, hostFloor,
|
|
510
|
+
memoryCapturePolicy, crossBoundaryPosture, advisorTool, hostFloor, runOrigin,
|
|
509
511
|
usageWindows,
|
|
510
512
|
brainCallGuardrailRef,
|
|
511
513
|
brainCallGuardrailMs,
|
|
@@ -116,6 +116,10 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
116
116
|
workspaceStateSettle: {
|
|
117
117
|
restoredWorktreeDir?: string;
|
|
118
118
|
} | undefined;
|
|
119
|
+
/** borrowed-mutable — the leg's write-location seat (prepare-task mints it empty, before any write-root reader is built, and
|
|
120
|
+
* reads it through its one reader `currentCheckoutOf`). The worktree mount seeds `current` here and hands THIS object to
|
|
121
|
+
* the tools — a copy would strand their writes from every write-root reader. */
|
|
122
|
+
worktreeSeat: WorktreeSessionRef;
|
|
119
123
|
}
|
|
120
124
|
export interface PrepareDelegationSurfaceResult {
|
|
121
125
|
/** owned — whether the background/workflow door is open (TaskOutput / TaskStop / AgentTranscript ride it). */
|
|
@@ -13,7 +13,7 @@ import { deliverEngineNotice } from "../types.js";
|
|
|
13
13
|
import { RosterBuilder } from "../tool-roster.js";
|
|
14
14
|
import { sendMessageContinuationSeats } from "./send-message-continuation.js";
|
|
15
15
|
export function prepareDelegationSurface(input) {
|
|
16
|
-
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle } = input;
|
|
16
|
+
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat } = input;
|
|
17
17
|
let worktreeSessionRef;
|
|
18
18
|
const delegationSurfaceActive = backgroundTaskToolsActive || workflowToolsActive;
|
|
19
19
|
const leaves = valveLeaves(spec, toolFaceSnapshot.selector);
|
|
@@ -104,25 +104,22 @@ export function prepareDelegationSurface(input) {
|
|
|
104
104
|
})), { source: "builtin", mountedBy: "backgroundTasks" });
|
|
105
105
|
}
|
|
106
106
|
if (handsCwdRef !== undefined) {
|
|
107
|
-
worktreeSessionRef =
|
|
108
|
-
|
|
107
|
+
worktreeSessionRef = worktreeSeat;
|
|
108
|
+
const seeded = resume?.seed.activeWorktree
|
|
109
|
+
? {
|
|
110
|
+
...resume.seed.activeWorktree,
|
|
111
|
+
worktreeDir: rebaseRestoredPath(resume.seed.activeWorktree.worktreeDir),
|
|
112
|
+
originalCwd: rebaseRestoredPath(resume.seed.activeWorktree.originalCwd),
|
|
113
|
+
}
|
|
114
|
+
: wsSnapshot?.activeWorktree !== undefined
|
|
109
115
|
? {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
originalCwd: rebaseRestoredPath(resume.seed.activeWorktree.originalCwd),
|
|
114
|
-
},
|
|
116
|
+
...wsSnapshot.activeWorktree,
|
|
117
|
+
worktreeDir: rebaseWsPath(wsSnapshot.activeWorktree.worktreeDir),
|
|
118
|
+
originalCwd: rebaseWsPath(wsSnapshot.activeWorktree.originalCwd),
|
|
115
119
|
}
|
|
116
|
-
:
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
...wsSnapshot.activeWorktree,
|
|
120
|
-
worktreeDir: rebaseWsPath(wsSnapshot.activeWorktree.worktreeDir),
|
|
121
|
-
originalCwd: rebaseWsPath(wsSnapshot.activeWorktree.originalCwd),
|
|
122
|
-
},
|
|
123
|
-
}
|
|
124
|
-
: {}),
|
|
125
|
-
};
|
|
120
|
+
: undefined;
|
|
121
|
+
if (seeded !== undefined)
|
|
122
|
+
worktreeSessionRef.current = seeded;
|
|
126
123
|
if (workspaceStateSettle !== undefined)
|
|
127
124
|
workspaceStateSettle.restoredWorktreeDir = worktreeSessionRef.current?.worktreeDir;
|
|
128
125
|
roster.mountAll(createWorktreeTools(executionEnv, { repoRoot: taskRootFinal, cwdRef: handsCwdRef, session: worktreeSessionRef }).map((t) => (envHandToolNames.add(t.name), firstPartyOffload(t))), { source: "builtin", mountedBy: "hands" });
|
|
@@ -223,7 +223,7 @@ export function prepareGateStations(input) {
|
|
|
223
223
|
for (const defect of screened.defects)
|
|
224
224
|
deps.onError?.(new Error(defect), { phase: "config", sessionId });
|
|
225
225
|
if (screened.gate !== undefined)
|
|
226
|
-
toolOccurrences.gateRound(e.toolCallId, screened.gate, result.finalInput);
|
|
226
|
+
toolOccurrences.gateRound(e.toolCallId, screened.gate, result.finalInput, result.rewrite);
|
|
227
227
|
if (result.block) {
|
|
228
228
|
const haltRemaining = maybeHumanRejectionHalt({
|
|
229
229
|
gate: screened.gate,
|