@sema-agent/core 7.29.0 → 7.30.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 +361 -0
- package/dist/agents/child-model-seat.d.ts +59 -7
- package/dist/agents/child-model-seat.js +33 -7
- package/dist/agents/cross-session-judge.d.ts +27 -5
- package/dist/agents/cross-session-judge.js +23 -12
- package/dist/agents/list-agents-tool.d.ts +31 -6
- package/dist/agents/list-agents-tool.js +66 -14
- package/dist/agents/peer-admission.d.ts +20 -8
- package/dist/agents/peer-admission.js +21 -12
- package/dist/agents/peer-directory.d.ts +29 -0
- package/dist/agents/peer-directory.js +20 -0
- package/dist/agents/peer-held-queue.d.ts +31 -4
- package/dist/agents/peer-held-queue.js +32 -1
- package/dist/agents/peer-session-drain.d.ts +91 -13
- package/dist/agents/peer-session-drain.js +409 -102
- package/dist/agents/read-inbox-tool.d.ts +22 -0
- package/dist/agents/read-inbox-tool.js +39 -0
- package/dist/agents/roster-store.d.ts +2 -4
- package/dist/agents/roster-store.js +1 -1
- package/dist/agents/send-message-tool.d.ts +4 -4
- package/dist/agents/send-message-tool.js +22 -2
- package/dist/agents/subagent.js +62 -44
- package/dist/agents/team-role.d.ts +34 -0
- package/dist/agents/team-role.js +17 -0
- package/dist/agents/verify.js +2 -2
- package/dist/core/auto-compaction.d.ts +42 -0
- package/dist/core/auto-compaction.js +35 -2
- package/dist/core/child-clamp-seats.d.ts +11 -0
- package/dist/core/child-clamp-seats.js +3 -0
- package/dist/core/context-edit.d.ts +3 -2
- package/dist/core/context-edit.js +6 -5
- package/dist/core/context-guard.d.ts +2 -1
- package/dist/core/context-guard.js +3 -2
- package/dist/core/context-settings.d.ts +103 -0
- package/dist/core/context-settings.js +60 -0
- package/dist/core/engine-notice.d.ts +11 -1
- package/dist/core/frame-settlement.d.ts +97 -0
- package/dist/core/frame-settlement.js +36 -0
- package/dist/core/governance-codes.d.ts +1 -1
- package/dist/core/governance-codes.js +2 -0
- package/dist/core/hooks.d.ts +10 -10
- package/dist/core/mailbox-store.d.ts +41 -7
- package/dist/core/mailbox-store.js +9 -3
- package/dist/core/parent-spec-seat.d.ts +14 -1
- package/dist/core/parent-spec-seat.js +6 -0
- package/dist/core/permission-rule-model.js +1 -1
- package/dist/core/roles.d.ts +20 -0
- package/dist/core/roles.js +35 -16
- package/dist/core/runner/assemble-result.d.ts +2 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/compaction-call-options.d.ts +26 -2
- package/dist/core/runner/compaction-call-options.js +9 -0
- package/dist/core/runner/compaction-seams.d.ts +4 -3
- package/dist/core/runner/compaction-seams.js +13 -6
- package/dist/core/runner/contracts.d.ts +56 -7
- package/dist/core/runner/decide-continuation.d.ts +2 -1
- package/dist/core/runner/decide-continuation.js +11 -10
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/prepare-caps-and-workflow.js +9 -1
- package/dist/core/runner/prepare-config-doors.js +4 -1
- package/dist/core/runner/prepare-context-lane.d.ts +9 -2
- package/dist/core/runner/prepare-context-lane.js +15 -10
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -2
- package/dist/core/runner/prepare-delegation-surface.js +9 -3
- package/dist/core/runner/prepare-file-history.js +10 -8
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +3 -1
- package/dist/core/runner/prepare-inherited-gate.js +1 -0
- package/dist/core/runner/prepare-prompt-inputs.d.ts +6 -0
- package/dist/core/runner/prepare-prompt-inputs.js +2 -1
- package/dist/core/runner/prepare-task.js +22 -9
- package/dist/core/runner/prepare-wiring-manifest.d.ts +6 -1
- package/dist/core/runner/prepare-wiring-manifest.js +6 -1
- package/dist/core/runner/retired-runner-deps.d.ts +3 -1
- package/dist/core/runner/retired-runner-deps.js +1 -0
- package/dist/core/runner/run-compaction-machinery.d.ts +4 -2
- package/dist/core/runner/run-compaction-machinery.js +5 -3
- package/dist/core/runner/run-harness-handlers.js +1 -1
- package/dist/core/runner/run-identity-wiring.js +19 -1
- package/dist/core/runner/run-leg.js +1 -1
- package/dist/core/runner/run-notification-lane.js +8 -2
- package/dist/core/runner/run-recovery-lanes.js +9 -5
- package/dist/core/runner/run-settle-and-teardown.d.ts +4 -22
- package/dist/core/runner/run-settle-and-teardown.js +6 -10
- package/dist/core/runner/run-stop-and-final-verify.js +1 -0
- package/dist/core/runner/run-terminal-adoption.js +5 -5
- package/dist/core/runner/run-turn-boundary.js +32 -5
- package/dist/core/runner/runtask.d.ts +8 -1
- package/dist/core/runner/runtask.js +32 -1
- package/dist/core/runner-deps.d.ts +44 -13
- package/dist/core/swappable-deps.d.ts +20 -4
- package/dist/core/swappable-deps.js +6 -1
- package/dist/core/task-event.d.ts +5 -0
- package/dist/core/task-notification.d.ts +144 -2
- package/dist/core/task-notification.js +154 -5
- package/dist/core/task-result.d.ts +14 -0
- package/dist/core/task-spec.d.ts +7 -0
- package/dist/core/tool-catalog-entries.js +2 -1
- package/dist/core/tool-conformance.js +1 -0
- package/dist/core/tool-policy.d.ts +9 -4
- package/dist/core/tool-spec.d.ts +14 -0
- package/dist/core/wiring-manifest.d.ts +12 -0
- package/dist/core/wiring-manifest.js +5 -1
- package/dist/engine/harness/agent-harness.d.ts +14 -1
- package/dist/engine/harness/agent-harness.js +28 -3
- package/dist/engine/harness/types.d.ts +3 -1
- package/dist/engine/llm/types.d.ts +8 -7
- package/dist/engine/llm/types.js +1 -1
- package/dist/engine/session/import-validate.js +4 -0
- package/dist/index.d.ts +10 -7
- package/dist/index.js +7 -5
- package/dist/orchestration/run-workflow-tool.d.ts +4 -4
- package/dist/orchestration/workflow.d.ts +1 -1
- package/dist/orchestration/workflow.js +8 -5
- package/dist/shell/lex.d.ts +30 -51
- package/dist/shell/lex.js +237 -284
- package/dist/stores/cc/mailbox-store.js +3 -2
- package/dist/stores/file/corrupt-read-sink.d.ts +28 -2
- package/dist/stores/file/file-history-store.d.ts +2 -4
- package/dist/stores/file/file-history-store.js +1 -1
- package/dist/stores/file/fs-atomic.d.ts +16 -11
- package/dist/stores/file/fs-atomic.js +17 -6
- package/dist/stores/file/index.d.ts +5 -6
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/mailbox-store.d.ts +4 -9
- package/dist/stores/file/mailbox-store.js +29 -30
- package/dist/stores/file/session-policy-store.d.ts +2 -0
- package/dist/stores/file/session-policy-store.js +1 -1
- package/dist/stores/file/session-store.d.ts +11 -7
- package/dist/stores/file/session-store.js +23 -16
- package/dist/stores/file/shared-ledger.js +3 -14
- package/dist/stores/file/tool-result-store.d.ts +2 -0
- package/dist/stores/file/tool-result-store.js +5 -2
- package/dist/stores/file/workflow-journal-store.js +14 -9
- package/dist/tools/fs/bash-program-position.d.ts +15 -24
- package/dist/tools/fs/bash-program-position.js +11 -29
- package/dist/tools/fs/bash-readonly-classifier.d.ts +125 -117
- package/dist/tools/fs/bash-readonly-classifier.js +400 -272
- package/dist/tools/fs/shell-read-check.js +3 -3
- package/dist/tools/fs/shell-read-establish.js +1 -1
- package/dist/tools/fs/shell-read-plan.d.ts +11 -6
- package/dist/tools/fs/shell-read-plan.js +167 -183
- package/dist/tools/fs/shell-read-word.d.ts +50 -0
- package/dist/tools/fs/shell-read-word.js +59 -0
- package/dist/tools/fs/shell-reentry-text.d.ts +10 -0
- package/dist/tools/fs/shell-reentry-text.js +73 -0
- package/package.json +1 -1
- package/test/export-surface.snapshot.json +58 -8
- package/wire-changes/core@7.30.0.json +1821 -0
|
@@ -74,24 +74,25 @@ export function assertOutcomeText(value, field) {
|
|
|
74
74
|
throw new CheckpointError("checkpoint.invalid_outcome", `resume \`${field}\` is not a plain string (got ${typeof value}) — a decide's text payload is an operator's plain data, not a live object; refusing pre-CAS, the checkpoint stays pending`);
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
|
-
|
|
77
|
+
function reorientClause(fullShellReachable) {
|
|
78
|
+
const source = fullShellReachable
|
|
79
|
+
? "re-orient from the workspace: run `git status` and review your recent changes / last commits"
|
|
80
|
+
: "re-orient from the conversation: re-read your most recent messages and tool results";
|
|
81
|
+
return `Before continuing, ${source} to confirm what is already done, then continue the remaining work. ` +
|
|
82
|
+
"Do NOT restart the task or re-run work that is already committed.";
|
|
83
|
+
}
|
|
84
|
+
export function resumeContinuation(resume, mark, fullShellReachable) {
|
|
78
85
|
if (resume.outcome.gate === "wake") {
|
|
79
|
-
return formatHookFeedback(
|
|
80
|
-
"run `git status` and review your recent changes / last commits to confirm what is already done, then " +
|
|
81
|
-
"continue the remaining work. Do NOT restart the task or re-run work that is already committed.", mark);
|
|
86
|
+
return formatHookFeedback(`You were WOKEN from a parked pause by an operator. ${reorientClause(fullShellReachable)}`, mark);
|
|
82
87
|
}
|
|
83
88
|
if (resume.outcome.gate === "resource_limit") {
|
|
84
|
-
return formatHookFeedback(
|
|
85
|
-
"review your recent changes / last commits to confirm what is already done, then continue the " +
|
|
86
|
-
"remaining work. Do NOT restart the task or re-run work that is already committed.", mark);
|
|
89
|
+
return formatHookFeedback(`You were resumed after a pause. ${reorientClause(fullShellReachable)}`, mark);
|
|
87
90
|
}
|
|
88
91
|
if (resume.outcome.gate === "dry_run_review") {
|
|
89
92
|
const verdict = resume.outcome.decision === "approve"
|
|
90
93
|
? "Your predicted change was REVIEWED and APPROVED; it has been applied"
|
|
91
94
|
: `Your predicted change was REVIEWED and REJECTED${resume.outcome.reason ? `: ${delimitUntrusted("reviewer note", resume.outcome.reason, REVIEWER_NOTE_MAX_BODY)}` : ""}; it was NOT applied`;
|
|
92
|
-
return formatHookFeedback(`You were resumed after a dry-run review. ${verdict}.
|
|
93
|
-
"(run `git status` and review your recent changes) to confirm the current state, then continue the " +
|
|
94
|
-
"remaining work. Do NOT restart the task or re-run work that is already done.", mark);
|
|
95
|
+
return formatHookFeedback(`You were resumed after a dry-run review. ${verdict}. ${reorientClause(fullShellReachable)}`, mark);
|
|
95
96
|
}
|
|
96
97
|
if (resume.outcome.gate === "plan_review") {
|
|
97
98
|
if (resume.outcome.decision === "approve") {
|
|
@@ -5,7 +5,7 @@ export function createRunState() {
|
|
|
5
5
|
limits: { turnsExceeded: false, budgetHit: undefined, budgetAxis: undefined, platformTerminal: undefined, outputRetryCap: 0, effectiveMaxTurns: undefined },
|
|
6
6
|
budget: { remainingMicroUsd: undefined, maxCostMicroUsd: undefined, remainingTokens: undefined, maxTokensWindow: undefined, overBudget: () => undefined, streamCancel: false, callOutputChars: 0, lastStreamBudgetCheck: 0, projectedOverBudget: () => undefined },
|
|
7
7
|
turn: { callStartAt: undefined, firstTokenAt: undefined, turnUsage: undefined, turnUsageMissing: false, turnStopReason: undefined, turnResponseModel: undefined, lastTurnHadToolCalls: false, toolBatch: [] },
|
|
8
|
-
counters: { approachNoticesSent: 0, walltimeSyncBackstopFired: false, compactionFloor: 0, trimForceBackoff: false, repetitionCuts: 0, repetitionSpared: 0, repetitionEvents: [], REPETITION_EVENTS_CAP: 0, preemptIgnoredReported: false, wroteThisRun: false, finalVerifyInjections: 0, groundingSignalPreR9: false, groundingSignalPostR9: false, cadenceTurns: 0 },
|
|
8
|
+
counters: { approachNoticesSent: 0, walltimeSyncBackstopFired: false, compactionFloor: 0, trimForceBackoff: false, compactionPasses: 0, repetitionCuts: 0, repetitionSpared: 0, repetitionEvents: [], REPETITION_EVENTS_CAP: 0, preemptIgnoredReported: false, wroteThisRun: false, finalVerifyInjections: 0, groundingSignalPreR9: false, groundingSignalPostR9: false, cadenceTurns: 0 },
|
|
9
9
|
attach: { attachmentsCfg: undefined, agentListingOn: false, skillsListingOn: false, attachState: undefined, dateState: undefined, instrProbe: undefined, instrState: undefined, sizeGuidelineState: undefined, attachmentsInjected: 0 },
|
|
10
10
|
};
|
|
11
11
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { isSyntheticApiErrorMessage } from "../../internal/harness.js";
|
|
2
2
|
import { createHash } from "node:crypto";
|
|
3
3
|
import { childThinkingSeat, deploymentSubagentThinking, deploymentSubagentTierModel, forkGovernanceDenial } from "../../agents/subagent.js";
|
|
4
|
+
import { inheritedParentModel } from "../../agents/child-model-seat.js";
|
|
4
5
|
import { CROSS_SESSION_CLASSIFIER_RULE } from "../../agents/cross-session-envelope.js";
|
|
5
6
|
import { createRunWorkflowTool } from "../../orchestration/run-workflow-tool.js";
|
|
6
7
|
import { isSelfOrchestrationActive } from "../../orchestration/workflow-script-runner.js";
|
|
@@ -287,7 +288,14 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
287
288
|
taskOwner: hostTaskId,
|
|
288
289
|
limits: deps.workflowLimits,
|
|
289
290
|
sourceTaskId: hostTaskId,
|
|
290
|
-
parentModel: () =>
|
|
291
|
+
parentModel: () => {
|
|
292
|
+
const stated = deploymentSubagentTierModel(runnerSelf.agentCatalog);
|
|
293
|
+
if (stated !== undefined)
|
|
294
|
+
return stated;
|
|
295
|
+
const ref = harnessRef.current?.getModelRef();
|
|
296
|
+
const model = inheritedParentModel(ref, runnerSelf.agentCatalog.models);
|
|
297
|
+
return model === undefined ? undefined : { model, ...(typeof ref === "string" ? { modelRef: ref } : {}) };
|
|
298
|
+
},
|
|
291
299
|
...(spec.getApiKeyAndHeaders !== undefined ? { parentGetApiKeyAndHeaders: spec.getApiKeyAndHeaders } : {}),
|
|
292
300
|
...(frozenOnAsk !== undefined ? { parentOnAsk: frozenOnAsk } : {}),
|
|
293
301
|
...(spec.durableApproval !== undefined ? { parentDurableApproval: { ...spec.durableApproval } } : {}),
|
|
@@ -13,6 +13,7 @@ import { describeRejectedValue } from "../tool-search-setting.js";
|
|
|
13
13
|
import { applyToolModelGate, assertRestoreGatedToolsValue, modelIdTail } from "../tool-model-gate.js";
|
|
14
14
|
import { resolveUsageWindows } from "../usage-window-store.js";
|
|
15
15
|
import { deriveAskEffective, resolveAskSeamForm, resolveQuestionSeam } from "../wiring-manifest.js";
|
|
16
|
+
import { assertPeerPresenceValue } from "../../agents/peer-directory.js";
|
|
16
17
|
import { TOTAL_TOKENS_REMINDER_MODES } from "./turn-attachments.js";
|
|
17
18
|
const TASK_LIMIT_KEY_DICT = {
|
|
18
19
|
maxTokens: true,
|
|
@@ -144,6 +145,7 @@ export function prepareConfigDoors(input) {
|
|
|
144
145
|
const { deps, sessions, resume, internals } = input;
|
|
145
146
|
let spec = input.spec;
|
|
146
147
|
assertNoRetiredRunnerDeps(deps);
|
|
148
|
+
assertPeerPresenceValue(spec.peerPresence);
|
|
147
149
|
assertRestoreGatedToolsValue(spec.restoreGatedTools);
|
|
148
150
|
const microCompactKnob = resolveMicroCompactKnob(deps.microCompact);
|
|
149
151
|
const assertToolNameListValue = (value, seat) => {
|
|
@@ -368,7 +370,8 @@ export function prepareConfigDoors(input) {
|
|
|
368
370
|
}),
|
|
369
371
|
};
|
|
370
372
|
}
|
|
371
|
-
const
|
|
373
|
+
const resolvedRoleRaw = resolveTaskModel(spec, deps);
|
|
374
|
+
const resolvedRole = internals?.inheritedModelRef !== undefined ? { ...resolvedRoleRaw, modelRef: internals.inheritedModelRef } : resolvedRoleRaw;
|
|
372
375
|
const model = resolvedRole.model;
|
|
373
376
|
if (usageWindows !== undefined && deps.usageWindowStore !== undefined) {
|
|
374
377
|
const costed = usageWindows.find((w) => w.maxCostUsd !== undefined);
|
|
@@ -18,6 +18,7 @@
|
|
|
18
18
|
import { type AgentHarness, type AgentMessage } from "../../internal/harness.js";
|
|
19
19
|
import type { Model } from "../../internal/llm.js";
|
|
20
20
|
import { type ClearedProjectionLedger, type MicroCompactMachine, type OccurrenceFingerprint, type OccurrenceIndex } from "../context-edit.js";
|
|
21
|
+
import type { ContextWindowOverlay } from "../context-settings.js";
|
|
21
22
|
import { type ToolResultStore } from "../tool-result-store.js";
|
|
22
23
|
import { type RunnerDeps } from "../types.js";
|
|
23
24
|
import type { Prepared, PreparedMicroCompact } from "./contracts.js";
|
|
@@ -72,13 +73,19 @@ export interface PrepareContextLaneInput {
|
|
|
72
73
|
trimPressureRef: {
|
|
73
74
|
droppedMessages: boolean;
|
|
74
75
|
};
|
|
76
|
+
/** borrowed-readonly — a CALL-TIME getter for the deployment's per-model window overlay in force for this
|
|
77
|
+
* leg ({@link RunnerDeps.contextSettings} keyed by the leg's catalog word). A getter and not a value: this
|
|
78
|
+
* is the one deployment seat an in-flight leg re-reads, and the request-layer frontiers below are asked
|
|
79
|
+
* per request. Absent (a standalone prepare exercise, no Runner behind it) ⇒ no overlay, ever. */
|
|
80
|
+
contextOverlay?: () => ContextWindowOverlay | undefined;
|
|
75
81
|
}
|
|
76
82
|
export interface PrepareContextLaneResult {
|
|
77
83
|
/** owned — the per-run microCompact machine state (`Prepared.microCompact`): machine, MC-R flag, ledger, the projection
|
|
78
84
|
* and in-turn-compaction seats the handler and the runtask arms fill. */
|
|
79
85
|
microCompact: PreparedMicroCompact;
|
|
80
|
-
/** owned — the model's structural coefficient (`charsPerToken ?? DEFAULT`), the
|
|
81
|
-
*
|
|
86
|
+
/** owned — the PREPARE-time model's structural coefficient (`charsPerToken ?? DEFAULT`), the coordinate the
|
|
87
|
+
* prompt-overhead term downstream is computed in. The per-REQUEST defenses read the CURRENT model's
|
|
88
|
+
* instead (`requestGeometry`), beside the window they compare against — one snapshot, one coordinate. */
|
|
82
89
|
charsPerToken: number;
|
|
83
90
|
}
|
|
84
91
|
/** The M21 phase body — prepareTask's context-lane stretch, verbatim (see the module header). */
|
|
@@ -10,14 +10,19 @@ import { applyGitFrameGuard } from "./git-status-frame.js";
|
|
|
10
10
|
import { applyContextShrinkToReadFileState } from "../../tools/fs/index.js";
|
|
11
11
|
export function prepareContextLane(input) {
|
|
12
12
|
const { model, deps, sessionId, runId, hostTaskId, offloadStore, microCompactKnob, harness, batchHaltRef, gitStatusRef, postureFrameRef, requestLossyRef, trimPressureRef, readFileState } = input;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
|
|
13
|
+
const contextOverlay = input.contextOverlay ?? (() => undefined);
|
|
14
|
+
const requestGeometry = () => {
|
|
15
|
+
const current = harness.getModel();
|
|
16
|
+
const overlay = contextOverlay();
|
|
17
|
+
return { editAt: editBudget(current, overlay), guardAt: guardBudget(current, overlay), charsPerToken: current.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN };
|
|
18
|
+
};
|
|
19
|
+
const microCompact = buildMicroCompactState(deps, model, sessionId, runId, offloadStore, microCompactKnob, contextOverlay());
|
|
16
20
|
const charsPerToken = model.charsPerToken ?? DEFAULT_CHARS_PER_TOKEN;
|
|
17
21
|
harness.on("context", async ({ messages, recheck, signal }) => {
|
|
18
22
|
batchHaltRef.current = undefined;
|
|
19
23
|
const pendingProjectionObservations = [];
|
|
20
24
|
try {
|
|
25
|
+
const { editAt, guardAt, charsPerToken: cpt } = requestGeometry();
|
|
21
26
|
const healed = dropEmptyFailureAssistants(messages);
|
|
22
27
|
const replay = replayClearedProjection(healed, microCompact.ledger);
|
|
23
28
|
const replayed = replay.messages;
|
|
@@ -47,8 +52,8 @@ export function prepareContextLane(input) {
|
|
|
47
52
|
budgetTokens: editAt,
|
|
48
53
|
clearSource: replayed,
|
|
49
54
|
onCleared: (pass) => { ccPass = pass; },
|
|
50
|
-
anchoredTotalTokens: estimateContextTokens(mediaCapped,
|
|
51
|
-
charsPerToken,
|
|
55
|
+
anchoredTotalTokens: estimateContextTokens(mediaCapped, cpt).tokens,
|
|
56
|
+
charsPerToken: cpt,
|
|
52
57
|
...(offloadStore
|
|
53
58
|
? {
|
|
54
59
|
offload: {
|
|
@@ -61,7 +66,7 @@ export function prepareContextLane(input) {
|
|
|
61
66
|
recordFrontierClears({ pass: ccPass, index: replay.index, edited, ledger: microCompact.ledger, tracer: deps.tracer, taskId: hostTaskId, trigger: "frontier", ...(readFileState !== undefined ? { readFileState } : {}) });
|
|
62
67
|
}
|
|
63
68
|
const chain = await runGuardChain({
|
|
64
|
-
edited, replayed, index: replay.index, microCompact, guardAt, charsPerToken, offloadStore,
|
|
69
|
+
edited, replayed, index: replay.index, microCompact, guardAt, charsPerToken: cpt, offloadStore,
|
|
65
70
|
sessionId, taskId: hostTaskId, deps, trimPressureRef, recheck, signal,
|
|
66
71
|
pendingProjectionObservations,
|
|
67
72
|
...(readFileState !== undefined ? { readFileState } : {}),
|
|
@@ -76,7 +81,7 @@ export function prepareContextLane(input) {
|
|
|
76
81
|
trimmed,
|
|
77
82
|
budgetTokens: guardAt,
|
|
78
83
|
ref: gitStatusRef,
|
|
79
|
-
charsPerToken,
|
|
84
|
+
charsPerToken: cpt,
|
|
80
85
|
onDegrade: (message) => {
|
|
81
86
|
try {
|
|
82
87
|
deps.onError?.(new Error(message), { phase: "degraded", sessionId, classification: "env-git-snapshot" });
|
|
@@ -86,7 +91,7 @@ export function prepareContextLane(input) {
|
|
|
86
91
|
},
|
|
87
92
|
});
|
|
88
93
|
if (postureFrameRef.protectedText !== undefined) {
|
|
89
|
-
const kept = protectGitFrame(working, trimmed, guardAt, { protectedText: postureFrameRef.protectedText },
|
|
94
|
+
const kept = protectGitFrame(working, trimmed, guardAt, { protectedText: postureFrameRef.protectedText }, cpt);
|
|
90
95
|
if (kept.action === "kept" || kept.action === "reinserted")
|
|
91
96
|
trimmed = kept.messages;
|
|
92
97
|
}
|
|
@@ -119,8 +124,8 @@ export function prepareContextLane(input) {
|
|
|
119
124
|
});
|
|
120
125
|
return { microCompact, charsPerToken };
|
|
121
126
|
}
|
|
122
|
-
function buildMicroCompactState(deps, model, sessionId, runId, offloadStore, knob) {
|
|
123
|
-
const triggerWindow = resolveTriggerWindow(model);
|
|
127
|
+
function buildMicroCompactState(deps, model, sessionId, runId, offloadStore, knob, overlay) {
|
|
128
|
+
const triggerWindow = resolveTriggerWindow(model, overlay);
|
|
124
129
|
if (triggerWindow.clamped) {
|
|
125
130
|
deliverEngineNotice(deps.onNotice, {
|
|
126
131
|
code: "config.autocompact_window_clamped",
|
|
@@ -14,9 +14,9 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
14
14
|
* `handsReadOnly` is NOT read here (the hands mount decided the surface). Never mutated. */
|
|
15
15
|
spec: Pick<TaskSpec, "tools" | "oneShot" | "retainBackgroundProcesses">;
|
|
16
16
|
/** borrowed-readonly — the deployment seats the mounts read: `workflowRunStore` / `backgroundAgentStore` / `mailboxStore` (the
|
|
17
|
-
* read/kill faces and the tier-3 revival seams), `rosterStore`, `
|
|
17
|
+
* read/kill faces and the tier-3 revival seams), `rosterStore`, `peerLane`, `peerDirectory`, `onNotice`,
|
|
18
18
|
* `onBackgroundChildEvent`, `tracer`. */
|
|
19
|
-
deps: Pick<RunnerDeps, "workflowRunStore" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "
|
|
19
|
+
deps: Pick<RunnerDeps, "workflowRunStore" | "backgroundAgentStore" | "mailboxStore" | "rosterStore" | "peerLane" | "peerDirectory" | "onNotice" | "onBackgroundChildEvent" | "tracer">;
|
|
20
20
|
/** borrowed-readonly — the trusted spawn-side channel: `parentNotify` (the delegated-child door), the uplink / sibling /
|
|
21
21
|
* identity seats the SendMessage mount forwards, `onTaskNotification`, `onSubagentSpawn`. Never mutated. */
|
|
22
22
|
internals: Pick<RunInternals, "parentNotify" | "parentPeerRef" | "uplinkSessionId" | "parentRetainLedger" | "explicitAgentName" | "parentTaskId" | "parentSessionId" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn"> | undefined;
|
|
@@ -52,6 +52,7 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
52
52
|
/** borrowed-mutable — the lane's late-bound facts; the SendMessage mount hands the SAME object to its peer seats (identity is
|
|
53
53
|
* the contract: the wiring station fills `askEffective` later). Not written here. */
|
|
54
54
|
peerLaneRefs: PeerLaneRefs;
|
|
55
|
+
/** borrowed-readonly — the session-box drain's mount judgment (the `ReadInbox` door: a box drained by this leg). */ sessionBox?: import("../task-notification.js").SessionBoxBinding | undefined;
|
|
55
56
|
/** borrowed-mutable — the run's roster builder (`Prepared.tools` is its read face; the writer table is on that field).
|
|
56
57
|
* Writers here: the eight mounts (TaskOutput, TaskStop, SendMessage, AgentTranscript, ListAgents, Monitor, the worktree
|
|
57
58
|
* pair, the offload reader), every one a `mount`. */
|
|
@@ -2,6 +2,8 @@ import { randomBytes } from "node:crypto";
|
|
|
2
2
|
import { createAgentTranscriptTool, AGENT_TRANSCRIPT_TOOL_NAME } from "../../agents/agent-transcript-tool.js";
|
|
3
3
|
import { createSendMessageTool, SEND_MESSAGE_TOOL_NAME } from "../../agents/send-message-tool.js";
|
|
4
4
|
import { listAgentsMountable, mountListAgents, peerLaneSendMessageSeats } from "../../agents/peer-session-drain.js";
|
|
5
|
+
import { resolvePeerLaneConfig } from "../../agents/peer-admission.js";
|
|
6
|
+
import { createReadInboxTool, READ_INBOX_TOOL_NAME } from "../../agents/read-inbox-tool.js";
|
|
5
7
|
import { createMonitorTool } from "../../tools/monitor.js";
|
|
6
8
|
import { createWorktreeTools } from "../../tools/worktree.js";
|
|
7
9
|
import { createTaskOutputTool, createTaskStopTool, defaultTaskRegistry } from "../task-registry.js";
|
|
@@ -30,7 +32,7 @@ function buildTier3ReviveSpawn(delegationForRevive, enrichSpecToolCtx) {
|
|
|
30
32
|
};
|
|
31
33
|
}
|
|
32
34
|
export function prepareDelegationSurface(input) {
|
|
33
|
-
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, roster, toolEffects, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle } = input;
|
|
35
|
+
const { spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, toolEffects, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle } = input;
|
|
34
36
|
let worktreeSessionRef;
|
|
35
37
|
const delegationSurfaceActive = backgroundTaskToolsActive || workflowToolsActive;
|
|
36
38
|
if (delegationSurfaceActive || internals?.parentNotify !== undefined || peerLaneActive) {
|
|
@@ -63,7 +65,7 @@ export function prepareDelegationSurface(input) {
|
|
|
63
65
|
...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}),
|
|
64
66
|
enrichCtx: enrichSpecToolCtx,
|
|
65
67
|
...(deps.rosterStore !== undefined ? { roster: deps.rosterStore } : {}),
|
|
66
|
-
...(deps.
|
|
68
|
+
...(deps.peerLane !== undefined ? { lane: deps.peerLane } : {}),
|
|
67
69
|
...(deps.onNotice !== undefined ? { onNotice: deps.onNotice } : {}),
|
|
68
70
|
...(internals?.peerSelfRef !== undefined ? { peerSelf: internals.peerSelfRef } : {}),
|
|
69
71
|
...(internals?.peerInboundChainRef !== undefined ? { peerInbound: internals.peerInboundChainRef } : {}),
|
|
@@ -97,7 +99,11 @@ export function prepareDelegationSurface(input) {
|
|
|
97
99
|
}
|
|
98
100
|
}
|
|
99
101
|
}
|
|
100
|
-
|
|
102
|
+
if (sessionBox !== undefined && internals?.onTaskNotification !== undefined && !(toolFaceSnapshot.exclude ?? []).includes(READ_INBOX_TOOL_NAME) && !(spec.tools ?? []).some((t) => t.name === READ_INBOX_TOOL_NAME)) {
|
|
103
|
+
toolEffects.set(READ_INBOX_TOOL_NAME, "read");
|
|
104
|
+
roster.mount(firstPartyOffload(createReadInboxTool({ pull: () => peerLaneRefs.pull })), { source: "builtin", mountedBy: "peerLane" });
|
|
105
|
+
}
|
|
106
|
+
const listAgents = (peerLaneActive || delegationSurfaceActive) && peerSendMessageBuiltIn && listAgentsMountable({ exclude: toolFaceSnapshot.exclude, specTools: spec.tools ?? [] }) ? mountListAgents({ ...(peerLaneActive ? { peerDirectory: deps.peerDirectory } : {}), freshWindowMs: resolvePeerLaneConfig(deps.peerLane, deps.onNotice).listingFreshWindowMs, sessionId, scope: taskScope, hostTaskId, ...(internals?.parentTaskId !== undefined ? { parentTaskId: internals.parentTaskId } : {}), ...(internals?.parentSessionId !== undefined ? { parentSessionId: internals.parentSessionId } : {}), registry: defaultTaskRegistry, ...(deps.rosterStore !== undefined ? { roster: deps.rosterStore } : {}), specTools: spec.tools ?? [], toolEffects }) : undefined;
|
|
101
107
|
if (listAgents !== undefined)
|
|
102
108
|
roster.mount(firstPartyOffload(listAgents), { source: "builtin", mountedBy: "peerLane" });
|
|
103
109
|
if (backgroundTaskToolsActive) {
|
|
@@ -10,7 +10,8 @@ export async function prepareFileHistory(input) {
|
|
|
10
10
|
e.code = "config.invalid_on_track_failure";
|
|
11
11
|
throw e;
|
|
12
12
|
}
|
|
13
|
-
const
|
|
13
|
+
const wiredSeat = resolveWiredFileHistoryStore(deps.fileHistoryStore);
|
|
14
|
+
const fileHistoryStore = wiredSeat === "disabled" ? undefined : wiredSeat;
|
|
14
15
|
const legacyRewindFiles = spec.rewindFiles;
|
|
15
16
|
if (legacyRewindFiles === true) {
|
|
16
17
|
if (spec.resumeAt !== undefined) {
|
|
@@ -43,12 +44,13 @@ export async function prepareFileHistory(input) {
|
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
const fileHistoryEnabled = fileHistoryStore !== undefined && handsEnabled;
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
47
|
+
const livenessArm = fileHistoryStore === undefined ? "file-history-no-store" : "file-history-no-env";
|
|
48
|
+
if (!fileHistoryEnabled && wiredSeat !== "disabled" && (handsEnabled || fileHistoryStore !== undefined) && deps.onError !== undefined && !toldAlready(deps.onError, livenessArm)) {
|
|
49
|
+
const reason = livenessArm === "file-history-no-store"
|
|
50
|
+
? `this deployment wired no RunnerDeps.fileHistoryStore, so NOTHING is recorded: no first-touch snapshot before an edit, no turn boundary, and a later restoreFiles / rewindFilesTo has nothing to restore from and will refuse (rewind.store_unconfigured). Supply a store, or accept an unrecoverable working tree knowingly (fileHistoryStore: "disabled" says so and silences this line)`
|
|
49
51
|
: `RunnerDeps.fileHistoryStore is wired but this run mounts no filesystem-capable ExecutionEnv, so the store is INERT: there is no working tree to snapshot and nothing will ever be written to it. Wire RunnerDeps.executionEnv, or drop the store from this deployment shape`;
|
|
50
52
|
try {
|
|
51
|
-
deps.onError(new Error(`file history is not live for this run — ${reason}.`), { phase: "config", sessionId });
|
|
53
|
+
deps.onError(new Error(`file history is not live for this run — ${reason}.`), { phase: "config", sessionId, classification: livenessArm });
|
|
52
54
|
}
|
|
53
55
|
catch {
|
|
54
56
|
}
|
|
@@ -180,8 +182,8 @@ function restoredAbsPathsOf(restored, root) {
|
|
|
180
182
|
return out;
|
|
181
183
|
}
|
|
182
184
|
function resolveWiredFileHistoryStore(candidate) {
|
|
183
|
-
if (candidate === undefined)
|
|
184
|
-
return
|
|
185
|
+
if (candidate === undefined || candidate === "disabled")
|
|
186
|
+
return candidate;
|
|
185
187
|
const verbs = ["trackEdit", "annulTrack", "snapshot", "restore", "canRestore", "reap", "adoptScope"];
|
|
186
188
|
const verbOf = (v) => {
|
|
187
189
|
try {
|
|
@@ -195,7 +197,7 @@ function resolveWiredFileHistoryStore(candidate) {
|
|
|
195
197
|
const missing = probeable ? verbs.filter((v) => typeof verbOf(v) !== "function") : [...verbs];
|
|
196
198
|
if (missing.length > 0) {
|
|
197
199
|
const shape = candidate === null ? "null" : probeable ? "a value that is not a FileHistoryStore" : `a ${typeof candidate}`;
|
|
198
|
-
const e = new Error(`RunnerDeps.fileHistoryStore was wired with ${shape} — missing contract verbs: ${missing.join(", ")}. Refusing prepare rather than half-wiring the rewind seat (a present-but-unusable store makes every Edit/Write/NotebookEdit fail its first-touch backup while restore requests report "no store wired").
|
|
200
|
+
const e = new Error(`RunnerDeps.fileHistoryStore was wired with ${shape} — missing contract verbs: ${missing.join(", ")}. Refusing prepare rather than half-wiring the rewind seat (a present-but-unusable store makes every Edit/Write/NotebookEdit fail its first-touch backup while restore requests report "no store wired"). Write "disabled" (or omit the key) to run without file history.`);
|
|
199
201
|
e.code = "config.invalid_file_history_store";
|
|
200
202
|
throw e;
|
|
201
203
|
}
|
|
@@ -36,6 +36,7 @@ import type { CwdRef } from "../../tools/fs/fs-shared.js";
|
|
|
36
36
|
import type { AskLane, IrreversibilityTier, ParkAsk, Prepared, ReversibilityProbes, StopForDenialLimit } from "./contracts.js";
|
|
37
37
|
import type { PermissionRuleLanes } from "./permission-rule-lanes.js";
|
|
38
38
|
import { type ToolRosterDeltaSeat } from "../tool-roster.js";
|
|
39
|
+
import { type FrameSettlement } from "../frame-settlement.js";
|
|
39
40
|
/**
|
|
40
41
|
* The parent-thread human-rejection boundary — judged ONCE here, from the pass's own record (CC parity:
|
|
41
42
|
* the reference CLI's reject path aborts exactly when there is no feedback and the run is not a
|
|
@@ -201,6 +202,9 @@ export interface PrepareGateStationsInput {
|
|
|
201
202
|
};
|
|
202
203
|
/** borrowed-readonly — the own hook-crash reporter (an expired post seat is reported through it). */
|
|
203
204
|
notifyOwnHookCrash: (err: unknown) => void;
|
|
205
|
+
/** borrowed-mutable — the leg's settlement seam. Writer here: the `tool_result` station marks a carrier whose output
|
|
206
|
+
* a host hook rewrote (`noteHostRewrite`), so a frame the rewrite removed settles as the host's decision. */
|
|
207
|
+
frameSettlement: FrameSettlement;
|
|
204
208
|
}
|
|
205
209
|
export interface PrepareGateStationsResult {
|
|
206
210
|
/** owned — whether the `tool_call` station registered (the arming predicate's value; observation seat only). */
|
|
@@ -9,6 +9,7 @@ import { deliverEngineNotice } from "../engine-notice.js";
|
|
|
9
9
|
import { askUnresolvableNotice } from "../ask-unresolvable-notice.js";
|
|
10
10
|
import { PATH_CONFINABLE_WRITE_TOOLS } from "./session-rule-policy.js";
|
|
11
11
|
import { toolCallFaceOf } from "../tool-roster.js";
|
|
12
|
+
import { noteHostRewrite } from "../frame-settlement.js";
|
|
12
13
|
function screenGateResult(result) {
|
|
13
14
|
if (result.suspend !== undefined)
|
|
14
15
|
return { defects: [] };
|
|
@@ -41,7 +42,7 @@ export function maybeHumanRejectionHalt(input) {
|
|
|
41
42
|
};
|
|
42
43
|
}
|
|
43
44
|
export function prepareGateStations(input) {
|
|
44
|
-
const { askLane, parkAsk, tools, toolRosterDeltas, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, writeProtectionCheck, shellReadCheck, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash } = input;
|
|
45
|
+
const { askLane, parkAsk, tools, toolRosterDeltas, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, writeProtectionCheck, shellReadCheck, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash, frameSettlement } = input;
|
|
45
46
|
if (askLane !== undefined && parkAsk !== undefined) {
|
|
46
47
|
const { adjudicate, resolveAskBound, notifyPermissionDenied, notifyHookError } = askLane;
|
|
47
48
|
const { resolveContentAsk, suspendAsk } = parkAsk;
|
|
@@ -261,6 +262,7 @@ export function prepareGateStations(input) {
|
|
|
261
262
|
if (patch?.updatedOutput) {
|
|
262
263
|
content = patch.updatedOutput;
|
|
263
264
|
changed = true;
|
|
265
|
+
noteHostRewrite(frameSettlement, e.toolCallId);
|
|
264
266
|
}
|
|
265
267
|
if (patch?.additionalContext) {
|
|
266
268
|
content = [...content, { type: "text", text: formatHookFeedback(patch.additionalContext, reminderMark) }];
|
|
@@ -194,6 +194,7 @@ export function prepareInheritedGate(input) {
|
|
|
194
194
|
delegationEntryCaps: delegationEntryCapsResolved,
|
|
195
195
|
reportUsage,
|
|
196
196
|
model: harnessRef.current?.getModel(),
|
|
197
|
+
modelRef: harnessRef.current?.getModelRef(),
|
|
197
198
|
thinkingLevel: harnessRef.current?.getThinkingLevel(),
|
|
198
199
|
principal: spec.principal,
|
|
199
200
|
...(frozenOnAsk !== undefined ? { onAsk: frozenOnAsk } : {}),
|
|
@@ -30,6 +30,7 @@ import type { RunnerDeps, TaskSpec } from "../types.js";
|
|
|
30
30
|
import type { PrepareResume, PromptFeatureFlags, RunInternals, ToolFaceSnapshot } from "./contracts.js";
|
|
31
31
|
import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
32
32
|
import { type GitStatusLaneRef } from "./git-status-frame.js";
|
|
33
|
+
import { type ContextWindowOverlay } from "../context-settings.js";
|
|
33
34
|
export interface PreparePromptInputsInput {
|
|
34
35
|
/** borrowed-readonly — the REBOUND spec (`spec′`). Read: `promptProvider`, `hooks` (flag), `systemPrompt`
|
|
35
36
|
* / `appendSystemPrompt` (the user prompt sources), `clientContext` (zone, email), `envFacts` (the
|
|
@@ -98,6 +99,11 @@ export interface PreparePromptInputsInput {
|
|
|
98
99
|
advertisedWritableDirs?: AdvertisedWritableDirs;
|
|
99
100
|
/** borrowed-readonly — the acquired session's id (operator-line context). */
|
|
100
101
|
sessionId: string;
|
|
102
|
+
/** borrowed-readonly — the deployment's window overlay for this leg, as it reads at PREPARE. The prompt's
|
|
103
|
+
* context-management sentence must not claim mid-task summarization a deployment has turned off for this
|
|
104
|
+
* model; the seat is live, so a later swap's effect on the SENTENCE lands at the next prepare while its
|
|
105
|
+
* effect on the BEHAVIOR lands at the next boundary — stated, not sworn away. */
|
|
106
|
+
contextOverlay?: ContextWindowOverlay;
|
|
101
107
|
}
|
|
102
108
|
export interface PreparePromptInputsResult {
|
|
103
109
|
/** owned — the prompt provider in force (`spec` ?? `deps` ?? the default). */
|
|
@@ -3,6 +3,7 @@ import { isIsolated } from "../remote-env.js";
|
|
|
3
3
|
import { probeGitStatusLane } from "./git-status-frame.js";
|
|
4
4
|
import { fenceMcpServerInstructions } from "./turn-attachments.js";
|
|
5
5
|
const ULTRA_REASONING_TIERS = new Set(["xhigh", "max"]);
|
|
6
|
+
import { compactionEnabled } from "../context-settings.js";
|
|
6
7
|
export async function preparePromptInputs(input) {
|
|
7
8
|
const { spec, deps, failClosedReason, lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, promptProfile, fableMitigations, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, advertisedWritableDirs } = input;
|
|
8
9
|
const provider = spec.promptProvider ?? deps.promptProvider ?? defaultPromptProvider;
|
|
@@ -26,7 +27,7 @@ export async function preparePromptInputs(input) {
|
|
|
26
27
|
goalEnabled: internals?.goalMode === true,
|
|
27
28
|
awarenessEnabled: thinking !== undefined && ULTRA_REASONING_TIERS.has(thinking),
|
|
28
29
|
worktreeIsolated: internals?.isolation === "worktree" && ownedEnv !== undefined,
|
|
29
|
-
withinTaskCompactionEnabled: (spec.compaction?.enabled
|
|
30
|
+
withinTaskCompactionEnabled: compactionEnabled(spec.compaction?.enabled, input.contextOverlay) && (spec.compaction?.withinTask ?? true),
|
|
30
31
|
isSubagent: delegation.isNonForkChild,
|
|
31
32
|
};
|
|
32
33
|
const userSystemPrompt = spec.systemPrompt ?? resolvedRole.systemPrompt ?? internals?.defaultSystemPrompt;
|
|
@@ -68,6 +68,7 @@ import { isRemoteExecutionEnv } from "../remote-env.js";
|
|
|
68
68
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
69
69
|
import { defaultTaskRegistry } from "../task-registry.js";
|
|
70
70
|
import { announcePeerLaneMount, judgeSessionBoxDrain } from "../../agents/peer-session-drain.js";
|
|
71
|
+
import { createFrameSettlement } from "../frame-settlement.js";
|
|
71
72
|
import { createSchedulerTools } from "../../tools/scheduler-tools.js";
|
|
72
73
|
import { selfOrchestrationFailClosedReason } from "../../orchestration/workflow-script-runner.js";
|
|
73
74
|
import { remainingBudgetMicroUsd, resolveCheckpointStore } from "../checkpoint-store.js";
|
|
@@ -82,11 +83,11 @@ import { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
|
82
83
|
import { resolveTaskRootCanonical } from "./task-root-canonical.js";
|
|
83
84
|
import { createStructuredProjector } from "./tool-output-projection.js";
|
|
84
85
|
import { asThrownError, thrownText } from "../thrown-value.js";
|
|
85
|
-
function warnCompactionWindowHazard(tracer, spec, model, compModel, hostTaskId) {
|
|
86
|
+
function warnCompactionWindowHazard(tracer, spec, model, compModel, hostTaskId, overlay) {
|
|
86
87
|
if (compModel === undefined)
|
|
87
88
|
return;
|
|
88
89
|
const compWindow = compModel.contextTokens ?? compModel.contextWindow;
|
|
89
|
-
const mainWindow = resolveTriggerWindow(model).window;
|
|
90
|
+
const mainWindow = resolveTriggerWindow(model, overlay).window;
|
|
90
91
|
if (compWindow > 0 && mainWindow > 0 && compWindow < mainWindow) {
|
|
91
92
|
const merged = { ...DEFAULT_COMPACTION_SETTINGS, ...spec.compaction };
|
|
92
93
|
const sanitized = sanitizeCompactionSettings(merged, mainWindow);
|
|
@@ -247,6 +248,14 @@ function refuseRequireExistingWithoutSession(spec) {
|
|
|
247
248
|
throw e;
|
|
248
249
|
}
|
|
249
250
|
}
|
|
251
|
+
function refuseRegistryScopeMismatch(spec, internals) {
|
|
252
|
+
const registryScope = internals?.registryScope;
|
|
253
|
+
if (registryScope === undefined || spec.principal === undefined || registryScope === spec.principal)
|
|
254
|
+
return;
|
|
255
|
+
const e = new Error(`registry scope mismatch: principal "${spec.principal}" vs RunInternals.registryScope "${registryScope}" — a delegated run's registry domain is its principal, so the two must be equal (or only one given)`);
|
|
256
|
+
e.code = "config.registry_scope_mismatch";
|
|
257
|
+
throw e;
|
|
258
|
+
}
|
|
250
259
|
function validateInputFaultNotice(onError, sessionId) {
|
|
251
260
|
return ({ toolName, toolCallId, error }) => onError?.(new Error(`tool input pre-validation (validateInput) threw for ${toolName} (call ${toolCallId}) — read as no verdict; the call proceeded to the gate: ${thrownText(error)}`), { phase: "hook", sessionId });
|
|
252
261
|
}
|
|
@@ -273,6 +282,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
273
282
|
const { toolEffects, egressTools, irreversibleTools, irreversibilityTier, axisExplicitNegatives, reversibilityProbes } = prepareSafetyScan({ spec, deps });
|
|
274
283
|
let shellGatedTools = new Set();
|
|
275
284
|
refuseRequireExistingWithoutSession(spec);
|
|
285
|
+
refuseRegistryScopeMismatch(spec, internals);
|
|
276
286
|
const { acquired, session, conflictRef, wakeRecovered, resumeAtBeforeParentId } = await prepareAcquireReconcile({ sessions, spec, resume, toolEffects, ...(internals?.sessionPlacement !== undefined ? { placement: internals.sessionPlacement } : {}), ...(() => { const g = durableParkGapFor(deps, spec); return g !== undefined ? { durableParkGap: g } : {}; })() });
|
|
277
287
|
const sessionId = acquired.sessionId;
|
|
278
288
|
const onceLedger = await loadAnnounceOnceLedger(session, resume?.seed.announcedListings, deps.onError);
|
|
@@ -285,13 +295,14 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
285
295
|
(await derivedRouteFallsBack({ seat: "compaction-summary", derived: compModel, primary: model, brain: deps.brain, getApiKeyAndHeaders: spec.getApiKeyAndHeaders, onNotice: deps.onNotice, sessionId, runId }))) {
|
|
286
296
|
effectiveCompModel = undefined;
|
|
287
297
|
}
|
|
288
|
-
warnCompactionWindowHazard(deps.tracer, spec, model, effectiveCompModel, hostTaskId);
|
|
298
|
+
warnCompactionWindowHazard(deps.tracer, spec, model, effectiveCompModel, hostTaskId, runnerSelf?.contextOverlayOf?.(resolvedRole.modelRef));
|
|
289
299
|
const taskScope = internals?.registryScope ?? spec.principal ?? "default";
|
|
290
300
|
internals?.peerSelfRef?.addAxis("s", sessionId);
|
|
291
301
|
internals?.peerSelfRef?.addAxis("t", hostTaskId);
|
|
292
302
|
const peerLaneActive = announcePeerLaneMount(deps, { sessionId, runId });
|
|
293
303
|
const sessionBox = judgeSessionBoxDrain(deps, { sessionId, scope: taskScope, isDelegatedChild: delegation.isDelegatedChild });
|
|
294
304
|
const peerLaneRefs = {};
|
|
305
|
+
const frameSettlement = createFrameSettlement();
|
|
295
306
|
const peerSendMessageBuiltIn = runnerSelf !== undefined && !(toolFaceSnapshot.exclude ?? []).includes(SEND_MESSAGE_TOOL_NAME) && !(spec.tools ?? []).some((t) => t.name === SEND_MESSAGE_TOOL_NAME);
|
|
296
307
|
const { reminderMark, reminderDisclosureCounts } = await adoptReminderMark(session, sessionId, resume?.seed.reminderMark, internals?.reminderMark, deps.onError);
|
|
297
308
|
const offloadScope = spec.principal ?? "default";
|
|
@@ -373,6 +384,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
373
384
|
const { canonical: taskRootCanonical } = await resolveTaskRootCanonical({ env: executionEnv, given: taskRootFinal, onNotice: deps.onNotice, sessionId, runId });
|
|
374
385
|
const { trackFileEdit, fileHistoryBoundary, restoredFilePaths, rewindNotes, fileHistoryEnabled, historyScope, historyRoot, historyFs } = await prepareFileHistory({ deps, spec, internals, executionEnv, taskRootFinal, handsEnabled, sessionId, session, resumeAtBeforeParentId, abortController });
|
|
375
386
|
const { noteFileEdited, editedFilesSnapshot, harnessRef, toolProgressRef, skillScope, forwardEvent, reviewRequestRef, requestReview, stopRequestedRef, requestStopAfterTurn, planModeRef, enterPlanMode, subagentRetain, worktreeIsolation } = prepareRunRefs({ spec, internals, executionEnv, taskRootFinal });
|
|
387
|
+
const legContextOverlay = () => runnerSelf?.contextOverlayOf?.(harnessRef.current?.getModelRef() ?? resolvedRole.modelRef);
|
|
376
388
|
let resolvedReadFace;
|
|
377
389
|
let resolvedWriteFace;
|
|
378
390
|
let readDenyAdditionsNormalized = [];
|
|
@@ -523,7 +535,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
523
535
|
handsLessResolvedFace = handsReadFace.handsLessResolvedFace;
|
|
524
536
|
handsLessResolvedWriteFace = handsReadFace.handsLessResolvedWriteFace;
|
|
525
537
|
shellGatedTools = handsReadFace.shellGatedTools;
|
|
526
|
-
const { worktreeSessionRef } = prepareDelegationSurface({ spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, shellReadAdmission, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, roster, toolEffects, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle });
|
|
538
|
+
const { worktreeSessionRef } = prepareDelegationSurface({ spec, deps, internals, resume, sessionId, hostTaskId, taskScope, taskRootFinal, taskRootCanonical, executionEnv, runnerSelf, backgroundTaskToolsActive, shellReadAdmission, workflowToolsActive, peerLaneActive, peerSendMessageBuiltIn, peerLaneRefs, sessionBox, roster, toolEffects, axisExplicitNegatives, envHandToolNames, toolFaceSnapshot, firstPartyOffload, offloadStore, subagentRetain, enrichSpecToolCtx, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle });
|
|
527
539
|
const { liveQuestionFace, contentAskBindings, contentAskRoutable, lateStrandedAnswers, discloseStrandedAnswers, settleContentAskBindings, durableQuestionFace, questionToolMounted, mountedQuestionTool } = prepareQuestionFace({ frozenOnQuestion, spec, deps, checkpointStore, runtimeCaps, resolvedInteractionPosture, resume, sessionId, roster, inheritedUnavailableAsks: () => inheritedUnavailableAsks });
|
|
528
540
|
if (spec.handsReadOnly !== true) {
|
|
529
541
|
const sessionScope = sessionId ?? spec.principal ?? spec.taskId ?? "default";
|
|
@@ -582,7 +594,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
582
594
|
}
|
|
583
595
|
const projectContext = await prepareProjectContext({ deps, spec, internals, session, sessionId, hostTaskId, taskRootFinal, handsEnabled, delegation, seedContextFiles, memoryBlockFromEngine, skillScope, roster, toolFaceSnapshot, onceLedger, memoryTools, memoryEngineSession, memorySearchToolsPlanned, memoryPairExcludedName, memoryPairOccupiedName, resume, skillListingBudget: doors.skillListingBudget });
|
|
584
596
|
const { memoryBlock: memoryBlockWithProject, instructionSources, projectInstructionContent, hasSkillManifest, skillsListing, sharedMemoryPairMounted, memoryEnginePairMounted } = projectContext;
|
|
585
|
-
const { provider, featureFlags, userSystemPrompt, userAppendSystemPrompt, mcpInstructionsBlock, envFacts, tzValid, userTz, gitStatusRef } = await preparePromptInputs({ spec, deps, failClosedReason: selfOrchestrationFailClosedReason(spec, deps), lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, promptProfile, fableMitigations, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}) });
|
|
597
|
+
const { provider, featureFlags, userSystemPrompt, userAppendSystemPrompt, mcpInstructionsBlock, envFacts, tzValid, userTz, gitStatusRef } = await preparePromptInputs({ spec, deps, contextOverlay: legContextOverlay(), failClosedReason: selfOrchestrationFailClosedReason(spec, deps), lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace, toolFaceSnapshot, promptProfile, fableMitigations, internals, thinking, ownedEnv, delegation, resolvedRole, mcp, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical, sessionId, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}) });
|
|
586
598
|
const { deferred, memoryBlock, toolSearch: toolSearchPolicy } = prepareDeferClassify({ spec, deps, roster, toolFaceSnapshot, handsEnabled, fullShellReachable, promptProfile, model, mcp, a2a, sharedMemoryPairMounted, memoryEnginePairMounted, memoryBlock: memoryBlockWithProject, memoryRecallSegment, onceLedger, sessionId });
|
|
587
599
|
prepareMemoryEngineSession({ memoryEngineSession, internals, memoryDelegationEvidence, externalContentTargetActive, lockedPreflight, mcp, sessionId, runId, deps, provenanceForChildrenRef, delegationSettlementRef, spec, envHandToolNames, roster, contentOriginWrapRef });
|
|
588
600
|
const { systemPromptSeat, renderWithDate, systemBlocks, promptManifest, epochDeclaredSections, epochArtifactDigestForSnapshot, buildAssembleInputs, centerAdoptionRef } = await preparePromptAssembly({ session, deps, internals, resume, provider, userSystemPrompt, userAppendSystemPrompt, featureFlags, mcpInstructionsBlock, memoryBlock, envFacts, promptProfile, fableMitigations, tools, model, sessionId, reminderMark, onceLedger });
|
|
@@ -658,6 +670,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
658
670
|
session,
|
|
659
671
|
tools: [...harnessTools],
|
|
660
672
|
model,
|
|
673
|
+
modelRef: resolvedRole.modelRef,
|
|
661
674
|
thinkingLevel: thinking,
|
|
662
675
|
systemPrompt: systemPromptSeat.current,
|
|
663
676
|
...(systemBlocks ? { systemBlocks } : {}),
|
|
@@ -694,7 +707,7 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
694
707
|
}
|
|
695
708
|
}
|
|
696
709
|
const { hooks, hookTimeoutMs, preToolUseObservational, ownGatePreToolUse, basePolicyForResumeEdit, denyNarrowingPolicy, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, permissionRuleLane, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions } = await preparePolicyChain({ spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, executionEnv, lockedPreflight, tools, harnessTools, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, envHandToolNames, handsCwdRef, readDenyMatcher, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, hasSkillManifest, skillScope, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, autoModeDecider, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef });
|
|
697
|
-
const { onAsk, preToolContexts, blockedToolCalls, gateOutcomes, batchHaltRef, blockedTracked, incompleteSuspendAdapter, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, writeProtectionCheck, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, hooks, preToolUseObservational, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, mcp, irreversibleTools, egressTools, shellReadStationArmed: shellReadCheck !== undefined, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, lockedPreflight, peerLaneRefs, harness, pausedRef, frozenOnAsk, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, sessionBox });
|
|
710
|
+
const { onAsk, preToolContexts, blockedToolCalls, gateOutcomes, batchHaltRef, blockedTracked, incompleteSuspendAdapter, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, writeProtectionCheck, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, hooks, preToolUseObservational, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, mcp, irreversibleTools, egressTools, shellReadStationArmed: shellReadCheck !== undefined, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, lockedPreflight, peerLaneRefs, frameSettlement, harness, pausedRef, frozenOnAsk, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, sessionBox });
|
|
698
711
|
if (fileHistoryBoundary !== undefined) {
|
|
699
712
|
harness.on("tool_call", async () => {
|
|
700
713
|
await fileHistoryBoundary.settle();
|
|
@@ -705,13 +718,13 @@ export async function prepareTask(spec, deps, sessions, resume, internals, runne
|
|
|
705
718
|
const { saga } = prepareSuspendSaga({ gateMachineryActive, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, reminderMark, handsCwdRef, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, autoModeIntent, approverPosture: approverPostureResolved, inheritedAdmittedOrgScopes, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter });
|
|
706
719
|
const { suspendForResource, suspendForPlatformLimit, suspendForReview } = prepareBoundaryParks({ saga, spec, checkpointStore, abortController, harness, session, sessions, sessionId, deps, priorLedger, maxSlices, maxSuspends, resourceTotal, priorSuspendCount, suspendChainBase, humanReviewRef, liveSpendRef, now, faceCheckpointState, f012CheckpointState, orgAdmissionCheckpointState, pausedRef, remoteEnvFailures, resourceSuspendEligible, durableSuspendInfraReady, incompleteSuspendAdapter });
|
|
707
720
|
const { parkAsk } = prepareParkAsk({ askLane, saga, spec, deps, sessionId, checkpointStore, toolRosterDeltas: rosterSeat, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, advertisedWritableDirs, offloadStore, ownedEnv, incompleteSuspendAdapter, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, faceCheckpointState, f012CheckpointState, orgAdmissionCheckpointState, ruleOffersOf, now, humanReviewRef, abortController, harness, pausedRef });
|
|
708
|
-
prepareGateStations({ askLane, parkAsk, tools, toolRosterDeltas: rosterSeat, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, writeProtectionCheck, shellReadCheck, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash });
|
|
721
|
+
prepareGateStations({ askLane, parkAsk, tools, toolRosterDeltas: rosterSeat, toolEffects, deps, toolCallGateArmedRef, effectivePolicy, hooks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, gateOutcomes, batchHaltRef, blockedTracked, hookIdentity, reminderMark, planModeRef, hostTaskId, sessionId, ownGatePreToolUse, hookTimeoutMs, handsCwdRef, hookEnvFace, writeProtectionCheck, shellReadCheck, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, notifyOwnHookCrash, frameSettlement });
|
|
709
722
|
const postureFrameRef = {};
|
|
710
|
-
const { microCompact, charsPerToken } = prepareContextLane({ model, deps, sessionId, runId, hostTaskId, offloadStore, microCompactKnob, harness, batchHaltRef, gitStatusRef, postureFrameRef, requestLossyRef, trimPressureRef, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}) });
|
|
723
|
+
const { microCompact, charsPerToken } = prepareContextLane({ model, deps, sessionId, runId, hostTaskId, offloadStore, microCompactKnob, harness, batchHaltRef, gitStatusRef, postureFrameRef, requestLossyRef, trimPressureRef, contextOverlay: legContextOverlay, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}) });
|
|
711
724
|
const preparedHolder = {};
|
|
712
725
|
const { cacheBreakDetector, cacheFingerprint, promptOverheadTokens, readTaskFile, normalizeAttachmentPath, isDedupStubResult, recentlyReadFiles, onCompactionApplied, detectExternalChanges, listBackgroundTasks, centerCompactionCandidate, effectiveReadFaceObserved, effectiveWriteFaceObserved, effectiveReadDenyObserved } = prepareTurnWiring({ deps, systemPromptSeat, harnessTools, fpRef, model, epochArtifactDigestForSnapshot, promptProfile, fableMitigations, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, additionalRootsCanonical, additionalReadRootsCanonical, readDenyMatcher, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, abortController, hostTaskId, taskScope, buildAssembleInputs, centerAdoptionRef, harnessRef, epochDeclaredSections, carrierReadFace, carrierWriteFace, readDenyAdditionsNormalized, preparedHolder });
|
|
713
726
|
await onceLedger.settle(session, announcedListingsRef);
|
|
714
|
-
const buildPrepared = () => ({ harness, session, sessionId, runId, reminderMark, reminderDisclosureCounts, approvalPosture: { autoMode: autoModeIntent, ...(approverPostureResolved !== undefined ? { approverPosture: approverPostureResolved } : {}) }, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, compModel: effectiveCompModel, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, gateOutcomes, batchHaltRef, nestedStats, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), effectiveMemoryScopes: memoryEffectiveScopes, cwdRef: handsCwdRef, toolProgressRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, settleContentAskBindings, cacheBreakDetector, cacheFingerprint, wiringManifest, promptManifest, epochDeclaredSections, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, readTaskFile, recentlyReadFiles, normalizeAttachmentPath, isDedupStubResult, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent } } : {}), planModeRef, stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(instructionSources ? { instructionSources } : {}), ...(projectInstructionContent !== undefined ? { projectInstructionContent } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts: { pending: [], listingSnapshotOwed: false }, gitStatusRef, postureFrameRef, listBackgroundTasks, hookIdentity, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), hookTimeoutMs, ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}) });
|
|
727
|
+
const buildPrepared = () => ({ harness, session, sessionId, runId, registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, reminderDisclosureCounts, fullShellReachable, approvalPosture: { autoMode: autoModeIntent, ...(approverPostureResolved !== undefined ? { approverPosture: approverPostureResolved } : {}) }, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, compModel: effectiveCompModel, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, gateOutcomes, batchHaltRef, nestedStats, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), effectiveMemoryScopes: memoryEffectiveScopes, cwdRef: handsCwdRef, toolProgressRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, settleContentAskBindings, cacheBreakDetector, cacheFingerprint, wiringManifest, promptManifest, epochDeclaredSections, activeTools, ...(deferred.size > 0 ? { deferredToolNames: deferred } : {}), toolMaterializeStatic, deferDirectCall, ...(staticFaceForRef.current !== undefined ? { staticFaceFor: staticFaceForRef.current } : {}), ownedEnv, pausedRef, undeliveredContinuationRef, suspendProgressRef, remoteEnvFailures, reviewRequestRef, suspendLoopRef, suspendForResource, ...(suspendForPlatformLimit !== undefined ? { suspendForPlatformLimit } : {}), ...(envLifetimeSuspendAt !== undefined ? { envLifetimeSuspendAt } : {}), ...(usageGovernance !== undefined ? { usageGovernance } : {}), callIssuedAtRef, workCutRef, brainCallGuardrailRef, gateStopRef, stopForDenialLimit, suspendForReview, ...(readFileStateForCheckpoint !== undefined ? { readFileState: readFileStateForCheckpoint } : {}), resourceLedger: priorLedger, liveSpendRef, humanReviewRef, now, tools, toolRoster, toolRosterDeltas: rosterSeat, structuredProjector, toolEffects, wakeRecovered, promptOverheadTokens, lastBrainContext, readTaskFile, recentlyReadFiles, normalizeAttachmentPath, isDedupStubResult, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent } } : {}), planModeRef, stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(instructionSources ? { instructionSources } : {}), ...(projectInstructionContent !== undefined ? { projectInstructionContent } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts: { pending: [], listingSnapshotOwed: false }, frameSettlement, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, listBackgroundTasks, hookIdentity, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), hookTimeoutMs, ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}) });
|
|
715
728
|
rollback.commit();
|
|
716
729
|
const prepared = buildPrepared();
|
|
717
730
|
preparedHolder.current = prepared;
|
|
@@ -39,7 +39,7 @@ export interface PrepareWiringManifestInput {
|
|
|
39
39
|
* `resourceSuspend` (the task-axis lane), `durableApproval` / `principal` (the synthesis and the notice), `interactiveTools` /
|
|
40
40
|
* `mcp` / `checkpointStore` (manifest cells and the notice's cause), `enablePlanMode` (the gate-machinery predicate's
|
|
41
41
|
* plan-mode term). Never mutated. */
|
|
42
|
-
spec: Pick<TaskSpec, "onAsk" | "onQuestion" | "handsReadOnly" | "tools" | "resourceSuspend" | "durableApproval" | "principal" | "interactiveTools" | "mcp" | "checkpointStore" | "enablePlanMode" | "hooks">;
|
|
42
|
+
spec: Pick<TaskSpec, "onAsk" | "onQuestion" | "handsReadOnly" | "tools" | "resourceSuspend" | "durableApproval" | "principal" | "interactiveTools" | "mcp" | "checkpointStore" | "enablePlanMode" | "hooks" | "peerPresence">;
|
|
43
43
|
/** borrowed-readonly — the deployment seats, whole: `onAsk` (the seat's deps half), `onError` (the warning), `executionEnv`
|
|
44
44
|
* (the hook-env predicate), `checkpointStore` (durable infra), the manifest's dozen wiring facts (`backgroundAgentStore`,
|
|
45
45
|
* `permissionRuleStore`, `permissionRuleSyncWired`, `onBackgroundChildEvent`, `lockedConfig`, `compliancePostureResolver`,
|
|
@@ -125,6 +125,11 @@ export interface PrepareWiringManifestInput {
|
|
|
125
125
|
/** borrowed-mutable — the peer lane's late-bound facts. Writer here: `askEffective` ← the manifest's ask derivation (the
|
|
126
126
|
* one fold of this session's permission-mode class). */
|
|
127
127
|
peerLaneRefs: PeerLaneRefs;
|
|
128
|
+
/** borrowed-mutable — #1036's settlement seam, minted by the orchestrator. This phase writes
|
|
129
|
+
* its two predicate seats (`boxBacked` / `wantsEffects`) when it binds the drain; the ledgers
|
|
130
|
+
* themselves are written later, by the harness receipt sink, the compaction commit beat and the
|
|
131
|
+
* drain's own passes. */
|
|
132
|
+
frameSettlement: import("../frame-settlement.js").FrameSettlement;
|
|
128
133
|
/** borrowed-readonly — the session-box drain's mount verdict (prepare-task's one judgment): present ⇒ this leg drains its own box. */
|
|
129
134
|
sessionBox: SessionBoxBinding | undefined;
|
|
130
135
|
/** borrowed-readonly — the built harness the peer drain binds to. */
|