@sema-agent/core 7.56.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 +926 -0
- package/LICENSE +1 -1
- package/dist/agents/org-delivery-gate.js +3 -4
- package/dist/agents/peer-held-queue.d.ts +69 -49
- package/dist/agents/peer-held-queue.js +255 -106
- package/dist/agents/peer-session-drain.js +63 -43
- package/dist/agents/send-message-tool.js +3 -2
- package/dist/agents/subagent-steps.js +2 -4
- package/dist/agents/subagent.js +8 -8
- package/dist/brain/anthropic.js +16 -8
- package/dist/brain/open-responses.js +10 -8
- package/dist/brain/openai.js +11 -9
- package/dist/brain/provider-dialect.d.ts +3 -2
- package/dist/brain/provider-dialect.js +2 -2
- package/dist/brain/request-params.d.ts +6 -0
- package/dist/brain/request-params.js +14 -1
- package/dist/brain/route-adjudicator.js +2 -1
- package/dist/brain/stream-engine.d.ts +9 -0
- package/dist/brain/stream-engine.js +24 -10
- package/dist/brain/stream-shared.d.ts +5 -4
- package/dist/brain/stream-shared.js +4 -4
- package/dist/core/a2a.d.ts +2 -1
- package/dist/core/a2a.js +23 -10
- package/dist/core/allow-entry.d.ts +5 -11
- package/dist/core/allow-entry.js +19 -26
- package/dist/core/approval-object.d.ts +21 -5
- package/dist/core/approval-object.js +44 -17
- package/dist/core/ask-origin.d.ts +23 -4
- package/dist/core/ask-origin.js +5 -1
- package/dist/core/auto-compaction.d.ts +75 -6
- package/dist/core/auto-compaction.js +43 -27
- package/dist/core/auto-mode-directive.d.ts +29 -5
- package/dist/core/auto-mode-directive.js +38 -8
- package/dist/core/background-agent-store.d.ts +6 -2
- package/dist/core/background-agent-store.js +1 -1
- package/dist/core/checkpoint-requirements.d.ts +13 -1
- package/dist/core/checkpoint-requirements.js +4 -0
- package/dist/core/checkpoint-store.d.ts +44 -40
- package/dist/core/checkpoint-store.js +32 -14
- package/dist/core/cross-boundary-taint.js +4 -2
- package/dist/core/engine-notice.d.ts +4 -3
- package/dist/core/engine-notice.js +6 -0
- package/dist/core/file-history-store.d.ts +14 -8
- package/dist/core/file-history-store.js +14 -4
- 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 +13 -5
- 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 +6 -3
- 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/mailbox-store.d.ts +62 -1
- package/dist/core/mailbox-store.js +59 -0
- 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-name-judge.d.ts +46 -0
- package/dist/core/mcp-name-judge.js +61 -0
- package/dist/core/mcp-probe.d.ts +5 -1
- package/dist/core/mcp-probe.js +3 -6
- 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 +85 -65
- package/dist/core/memory-engine/consolidation-driver.js +4 -3
- package/dist/core/memory-engine/distiller.js +26 -17
- package/dist/core/memory-engine/layout.js +5 -2
- 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/park-selfcheck.js +2 -0
- 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/permission-rule-consent.d.ts +5 -3
- package/dist/core/permission-rule-consent.js +20 -15
- package/dist/core/permission-rule-model.d.ts +43 -2
- package/dist/core/permission-rule-model.js +52 -8
- package/dist/core/permission-rule-org.js +1 -1
- 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 +56 -31
- package/dist/core/protocol-http-auth.js +71 -42
- package/dist/core/protocol-naming.d.ts +20 -0
- package/dist/core/protocol-naming.js +20 -3
- package/dist/core/read-only-shell.d.ts +20 -5
- package/dist/core/read-only-shell.js +29 -14
- 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/remote-env.d.ts +37 -1
- package/dist/core/remote-env.js +11 -0
- package/dist/core/resume-startup-cause.d.ts +24 -2
- package/dist/core/resume-startup-cause.js +20 -1
- 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/roles.js +50 -7
- 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/compact-session.d.ts +10 -0
- package/dist/core/runner/compact-session.js +202 -0
- package/dist/core/runner/compaction-call-options.d.ts +2 -2
- package/dist/core/runner/compaction-restate.d.ts +15 -6
- package/dist/core/runner/compaction-restate.js +28 -2
- package/dist/core/runner/compaction-seams.d.ts +21 -1
- package/dist/core/runner/compaction-seams.js +11 -8
- package/dist/core/runner/contracts.d.ts +36 -21
- package/dist/core/runner/derived-route-fallback.d.ts +13 -0
- package/dist/core/runner/derived-route-fallback.js +6 -0
- package/dist/core/runner/env-capability-census.d.ts +3 -2
- package/dist/core/runner/env-capability-census.js +9 -3
- package/dist/core/runner/gate-exit.d.ts +18 -4
- package/dist/core/runner/gate-exit.js +5 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +7 -7
- package/dist/core/runner/permission-rule-lanes.js +17 -11
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +3 -0
- package/dist/core/runner/prepare-acquire-reconcile.js +2 -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 +14 -5
- package/dist/core/runner/prepare-config-doors.js +16 -13
- 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 +10 -4
- package/dist/core/runner/prepare-hands-readface.js +6 -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-park-ask.d.ts +2 -0
- package/dist/core/runner/prepare-park-ask.js +2 -2
- package/dist/core/runner/prepare-policy-chain.d.ts +4 -4
- package/dist/core/runner/prepare-policy-chain.js +4 -6
- 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.d.ts +4 -1
- package/dist/core/runner/prepare-task.js +46 -37
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +13 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +13 -7
- 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/rewind-files.d.ts +2 -5
- package/dist/core/runner/rewind-files.js +9 -51
- 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 +15 -22
- package/dist/core/runner/run-notification-lane.d.ts +2 -0
- package/dist/core/runner/run-notification-lane.js +5 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -4
- package/dist/core/runner/run-settle-and-teardown.js +5 -11
- package/dist/core/runner/run-terminal-adoption.js +3 -4
- package/dist/core/runner/run-turn-boundary.js +3 -5
- package/dist/core/runner/runtask.d.ts +8 -1
- package/dist/core/runner/runtask.js +28 -34
- package/dist/core/runner/send-message-continuation.js +1 -1
- package/dist/core/runner/session-verb-doors.d.ts +28 -0
- package/dist/core/runner/session-verb-doors.js +48 -0
- package/dist/core/runner/session-write-ledger.d.ts +30 -0
- package/dist/core/runner/session-write-ledger.js +101 -0
- package/dist/core/runner/stream-settle-backstop.js +11 -14
- package/dist/core/runner/sub-agent-deny-lists.d.ts +25 -3
- package/dist/core/runner/sub-agent-deny-lists.js +21 -10
- package/dist/core/runner/teardown-bounded.d.ts +1 -0
- package/dist/core/runner/teardown-bounded.js +1 -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 +4 -4
- package/dist/core/secret-env.d.ts +4 -0
- package/dist/core/secret-env.js +3 -0
- 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-policy-store.d.ts +7 -2
- package/dist/core/session-policy-store.js +1 -1
- 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/shell-wrapper-projection.d.ts +1 -1
- package/dist/core/steer-replay.d.ts +4 -2
- package/dist/core/steer-replay.js +2 -1
- package/dist/core/store-contracts/background-agent-store-contract.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +19 -1
- package/dist/core/store-contracts/file-history-store-contract.js +9 -0
- package/dist/core/store-contracts/mailbox-store-contract.js +49 -1
- 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-agent.d.ts +8 -4
- package/dist/core/task-registry-agent.js +14 -8
- package/dist/core/task-registry-shared.d.ts +36 -6
- package/dist/core/task-registry-shared.js +11 -0
- package/dist/core/task-registry.d.ts +1 -1
- package/dist/core/task-registry.js +1 -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.d.ts +6 -0
- package/dist/core/tool-catalog-entries.js +2 -0
- package/dist/core/tool-name-aliases.d.ts +32 -2
- package/dist/core/tool-name-aliases.js +23 -0
- package/dist/core/tool-name-readings.d.ts +4 -0
- package/dist/core/tool-name-readings.js +1 -0
- package/dist/core/tool-policy.d.ts +10 -6
- package/dist/core/tool-policy.js +4 -7
- package/dist/core/tool-result-store.d.ts +17 -10
- package/dist/core/tool-result-store.js +3 -1
- package/dist/core/trace.d.ts +4 -1
- package/dist/core/trace.js +2 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/untrusted-egress.d.ts +18 -0
- package/dist/core/untrusted-egress.js +82 -12
- 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 +12 -5
- package/dist/engine/harness/agent-harness.js +13 -2
- 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/loop/agent-loop.d.ts +1 -4
- package/dist/engine/loop/agent-loop.js +26 -4
- 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 +23 -11
- package/dist/index.js +15 -6
- package/dist/internal/harness-types.d.ts +1 -1
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +0 -1
- package/dist/stores/file/file-history-store.js +12 -4
- package/dist/stores/file/index.d.ts +4 -1
- package/dist/stores/file/index.js +4 -1
- package/dist/stores/file/mailbox-store.d.ts +2 -1
- package/dist/stores/file/mailbox-store.js +26 -1
- package/dist/stores/file/session-store.d.ts +15 -8
- package/dist/stores/file/session-store.js +28 -13
- package/dist/tools/fs/bash-readonly-classifier.d.ts +15 -19
- package/dist/tools/fs/bash-readonly-classifier.js +5 -10
- package/dist/tools/fs/fs-bash.js +10 -3
- 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/pattern-kill-guard.d.ts +3 -2
- package/dist/tools/fs/pattern-kill-guard.js +68 -36
- 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 +18 -1
- package/dist/tools/fs/shell-read-check.js +66 -16
- package/dist/tools/fs/shell-read-establish.js +2 -1
- package/dist/tools/fs/shell-read-identity.d.ts +12 -9
- package/dist/tools/fs/shell-read-identity.js +10 -5
- package/dist/tools/fs/shell-read-judge.d.ts +10 -1
- package/dist/tools/web.js +9 -7
- 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 +141 -3
- package/wire-changes/core-stores-sql@7.57.0.json +29 -0
- package/wire-changes/core-stores-sql@7.58.0.json +29 -0
- package/wire-changes/core@7.57.0.json +1487 -0
- package/wire-changes/core@7.58.0.json +2188 -0
- package/wire-changes/mods-kernel@7.57.0.json +29 -0
- package/wire-changes/mods-kernel@7.58.0.json +81 -0
- package/wire-changes/primitives@7.57.0.json +245 -0
- package/wire-changes/primitives@7.58.0.json +29 -0
|
@@ -11,6 +11,7 @@ import { callerToolMembership } from "../../agents/inherited-tool-pool.js";
|
|
|
11
11
|
import { refuseLateRosterChanges, snapshotCallerRoster } from "./caller-roster.js";
|
|
12
12
|
import { toolPolicyPathRules, toolPolicyWriteGuardRows } from "../tool-policy.js";
|
|
13
13
|
import { dataRootSpellings } from "../sensitive-path-policy.js";
|
|
14
|
+
import { writeLocationOf } from "../../tools/worktree.js";
|
|
14
15
|
import { bindPathRules, createHeadLeads } from "../path-rule-binding.js";
|
|
15
16
|
import { whereItsAnsweredPrefixLeads } from "../../tools/fs/read-deny-home.js";
|
|
16
17
|
import { loadAnnounceOnceLedger } from "./announce-once-ledger.js";
|
|
@@ -74,7 +75,7 @@ export { compensateUnparkedPause } from "./prepare-suspend-saga.js";
|
|
|
74
75
|
import { checkpointScopeOf, placementValueOrAbsent } from "./checkpoint-scope.js";
|
|
75
76
|
export { DEFAULT_IRREVERSIBLE_SCOPE, checkpointScopeOf, placementValueOrAbsent } from "./checkpoint-scope.js";
|
|
76
77
|
export { mcpManifestEntries } from "./prepare-wiring-manifest.js";
|
|
77
|
-
import {
|
|
78
|
+
import { compactionSummaryFallback, compactionSummaryIsDerived } from "./derived-route-fallback.js";
|
|
78
79
|
import { prepareAdvisor } from "./prepare-advisor.js";
|
|
79
80
|
import { prepareProtocolTools } from "./prepare-protocol-tools.js";
|
|
80
81
|
import { prepareQuestionFace } from "./prepare-question-face.js";
|
|
@@ -91,21 +92,24 @@ import { announcePeerLaneMount, judgeSessionBoxDrain } from "../../agents/peer-s
|
|
|
91
92
|
import { createFrameSettlement } from "../frame-settlement.js";
|
|
92
93
|
import { createSchedulerTools } from "../../tools/scheduler-tools.js";
|
|
93
94
|
import { selfOrchestrationFailClosedReason } from "../../orchestration/workflow-script-runner.js";
|
|
94
|
-
import {
|
|
95
|
-
import { boundOwnToolLists, boundToolListsJudgment, judgeRunToolLists } from "./sub-agent-deny-lists.js";
|
|
95
|
+
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
96
|
+
import { boundOwnToolLists, boundToolListsJudgment, judgeRunToolLists, ownListsWhereOf, readToolSelector } from "./sub-agent-deny-lists.js";
|
|
96
97
|
import { remainingBudgetMicroUsd, resolveCheckpointStore } from "../checkpoint-store.js";
|
|
97
98
|
import { checkpointSeatOf } from "../checkpoint-seat.js";
|
|
98
99
|
import { handsWriteHalfMounts } from "../../tools/fs/index.js";
|
|
99
100
|
import { askSeatEffective } from "../wiring-manifest.js";
|
|
100
101
|
import { durableParkGapFor } from "../park-selfcheck.js";
|
|
101
102
|
import { createToolCallEntry, createToolCallStation } from "../mods/tool-call.js";
|
|
103
|
+
import { createMcpRequestMetaSeat } from "../mcp-call-meta.js";
|
|
102
104
|
import { deliverEngineNotice } from "../types.js";
|
|
103
105
|
import { toolCallFaceOf, ToolRosterDeltaSeat } from "../tool-roster.js";
|
|
104
106
|
import { mountedMcpOf } from "../mounted-mcp.js";
|
|
105
107
|
import { McpConnectionPool } from "../mcp-connection-pool.js";
|
|
106
108
|
import { rosterCanPersistMemory } from "../tool-registry.js";
|
|
107
|
-
import { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
109
|
+
import { AdvertisedWritableDirs, checkedPlanFileShape, planFileInvalid, planFileShown } from "./advertised-writable-dirs.js";
|
|
108
110
|
import { resolveTaskRootCanonical } from "./task-root-canonical.js";
|
|
111
|
+
import { projectMarkerFsOf, resolveSessionProject } from "../memory-engine/scope-contract.js";
|
|
112
|
+
import { createWorkspaceFrameSeat } from "../workspace-snapshot.js";
|
|
109
113
|
import { createStructuredProjector } from "./tool-output-projection.js";
|
|
110
114
|
import { toolResultMediaRefusedSeat } from "./tool-result-media-seat.js";
|
|
111
115
|
import { asThrownError, thrownText } from "../thrown-value.js";
|
|
@@ -288,7 +292,7 @@ function refuseRegistryScopeMismatch(spec, internals) {
|
|
|
288
292
|
function validateInputFaultNotice(onError, sessionId) {
|
|
289
293
|
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 });
|
|
290
294
|
}
|
|
291
|
-
export async function prepareTask(request, deps, sessions, resume, internals, runnerSelf, runIdSink, holdSessionLock) {
|
|
295
|
+
export async function prepareTask(request, deps, sessions, resume, internals, runnerSelf, runIdSink, holdSessionLock, legWrites) {
|
|
292
296
|
const runId = uuidv7();
|
|
293
297
|
if (runIdSink !== undefined)
|
|
294
298
|
runIdSink.runId = runId;
|
|
@@ -309,6 +313,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
309
313
|
})();
|
|
310
314
|
if (modePolicyOf(declaredModeAtDoor).enablePlanMode)
|
|
311
315
|
spec = { ...spec, enablePlanMode: true };
|
|
316
|
+
checkedPlanFileShape(spec.planFile);
|
|
312
317
|
const { toolFaceLists, promptLean, promptTraits, promptHost, promptBinding, lockedPreflight, resolvedInteractionPosture, microCompactKnob, resolvedRole, model, thinking, compModel, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailRef, brainCallGuardrailMs } = doors;
|
|
313
318
|
announceToolModelGate(deps.onNotice, model.id, doors.modelGate);
|
|
314
319
|
const modelGateManifest = toolModelGateManifest(doors.modelGate);
|
|
@@ -317,17 +322,6 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
317
322
|
refuseRequireExistingWithoutSession(spec);
|
|
318
323
|
refuseRegistryScopeMismatch(spec, internals);
|
|
319
324
|
const ownToolLists = boundOwnToolLists(internals?.ownToolLists ?? resume?.seed.ownToolLists, toolFaceLists);
|
|
320
|
-
const extraBodyRefusal = judgeExtraBody(model.extraBody, model.id).refused;
|
|
321
|
-
if (extraBodyRefusal !== undefined)
|
|
322
|
-
throw Object.assign(new Error(extraBodyRefusal.sentence), { code: extraBodyRefusal.code, ...(extraBodyRefusal.field !== undefined ? { detail: { field: extraBodyRefusal.field } } : {}) });
|
|
323
|
-
for (const cap of MODEL_CAPABILITIES)
|
|
324
|
-
capabilityOf(model, cap);
|
|
325
|
-
const fileHistoryRequest = resolveFileHistoryRequest(spec, deps);
|
|
326
|
-
const { acquired, session, conflictRef, wakeRecovered, branch } = await prepareAcquireReconcile({ sessions, spec, resume, wakeEffects, report: (e, id) => deps.onError?.(e, { phase: "config", sessionId: id }), ...(internals?.sessionPlacement !== undefined ? { placement: internals.sessionPlacement } : {}), ...(() => { const g = durableParkGapFor(deps, spec); return g !== undefined ? { durableParkGap: g } : {}; })() });
|
|
327
|
-
const sessionId = acquired.sessionId;
|
|
328
|
-
await holdSessionLock?.(sessionId);
|
|
329
|
-
const onceLedger = await loadAnnounceOnceLedger(session, resume?.seed.announcedListings, deps.onError);
|
|
330
|
-
const hostTaskId = spec.taskId ?? sessionId;
|
|
331
325
|
const delegation = effectiveDelegationFacts(internals, resume?.seed.isDelegatedChild);
|
|
332
326
|
const toolLegs = [
|
|
333
327
|
...(delegation.isDelegatedChild ? ["delegated"] : []),
|
|
@@ -339,18 +333,25 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
339
333
|
const toolCeiling = internals?.toolCeiling ?? resume?.seed.toolCeiling;
|
|
340
334
|
const toolListsJudged = boundToolListsJudgment(internals?.toolListsJudged ?? resume?.seed.toolListsJudged, toolFaceLists);
|
|
341
335
|
const toolFaceSnapshot = Object.freeze({
|
|
342
|
-
selector:
|
|
336
|
+
selector: readToolSelector({ layers: [...(toolCeiling ?? []), { ...(toolFaceLists.allow !== undefined ? { allow: toolFaceLists.allow } : {}), deny: toolFaceLists.exclude ?? [] }], where: ownListsWhereOf(ownToolLists), legs: toolLegs }),
|
|
343
337
|
defer: toolFaceLists.defer,
|
|
344
338
|
alwaysLoad: toolFaceLists.alwaysLoad,
|
|
345
339
|
restoreGated: toolFaceLists.restoreGated,
|
|
346
340
|
});
|
|
341
|
+
const toolCeilingRead = toolCeiling === undefined ? undefined : toolFaceSnapshot.selector.layers.slice(0, -1);
|
|
342
|
+
const extraBodyRefusal = judgeExtraBody(model.extraBody, model.id).refused;
|
|
343
|
+
if (extraBodyRefusal !== undefined)
|
|
344
|
+
throw Object.assign(new Error(extraBodyRefusal.sentence), { code: extraBodyRefusal.code, ...(extraBodyRefusal.field !== undefined ? { detail: { field: extraBodyRefusal.field } } : {}) });
|
|
345
|
+
for (const cap of MODEL_CAPABILITIES)
|
|
346
|
+
capabilityOf(model, cap);
|
|
347
|
+
const fileHistoryRequest = resolveFileHistoryRequest(spec, deps);
|
|
348
|
+
const { acquired, session, conflictRef, wakeRecovered, branch } = await prepareAcquireReconcile({ sessions, spec, resume, wakeEffects, report: (e, id) => deps.onError?.(e, { phase: "config", sessionId: id }), ...(legWrites !== undefined ? { legWrites } : {}), ...(internals?.sessionPlacement !== undefined ? { placement: internals.sessionPlacement } : {}), ...(() => { const g = durableParkGapFor(deps, spec); return g !== undefined ? { durableParkGap: g } : {}; })() });
|
|
349
|
+
const sessionId = acquired.sessionId;
|
|
350
|
+
await holdSessionLock?.(sessionId);
|
|
351
|
+
const onceLedger = await loadAnnounceOnceLedger(session, resume?.seed.announcedListings, deps.onError);
|
|
352
|
+
const hostTaskId = spec.taskId ?? sessionId;
|
|
347
353
|
const placementRootResolved = (internals = restorePlacementRoot(internals, resume?.seed.placementRootSessionId))?.placementRoot ?? internals?.rootSessionId ?? sessionId;
|
|
348
|
-
|
|
349
|
-
if (spec.compactionModel === undefined &&
|
|
350
|
-
compModel !== undefined &&
|
|
351
|
-
(await derivedRouteFallsBack({ seat: "compaction-summary", derived: compModel, primary: model, brain: deps.brain, getApiKeyAndHeaders: spec.getApiKeyAndHeaders, onNotice: deps.onNotice, sessionId, runId })).action === "fall_back") {
|
|
352
|
-
effectiveCompModel = undefined;
|
|
353
|
-
}
|
|
354
|
+
const effectiveCompModel = compactionSummaryIsDerived(spec.compactionModel !== undefined, compModel) ? await compactionSummaryFallback({ derived: compModel, primary: model, brain: deps.brain, getApiKeyAndHeaders: spec.getApiKeyAndHeaders, onNotice: deps.onNotice, sessionId, runId }) : compModel;
|
|
354
355
|
warnCompactionWindowHazard(deps.tracer, spec, model, effectiveCompModel, hostTaskId, runnerSelf?.contextOverlayOf?.(resolvedRole.modelRef));
|
|
355
356
|
const taskScope = internals?.registryScope ?? spec.principal ?? "default";
|
|
356
357
|
const checkpointScope = checkpointScopeOf(spec, internals?.checkpointScope || resume?.seed.legScope);
|
|
@@ -443,7 +444,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
443
444
|
}
|
|
444
445
|
}
|
|
445
446
|
const ownedEnv = ownedEnvSeat.current;
|
|
446
|
-
const { taskRootFinal, rebaseRestoredPath } = await prepareWorkspaceRestore({ ownedEnv, deps, spec, internals, resume, taskRootInitial, placement, abortController, sessionId });
|
|
447
|
+
const { taskRootFinal, rebaseRestoredPath, remote: workspaceRemote } = await prepareWorkspaceRestore({ ownedEnv, deps, spec, internals, resume, taskRootInitial, placement, abortController, sessionId });
|
|
447
448
|
const { canonical: taskRootCanonical } = await resolveTaskRootCanonical({ env: executionEnv, given: taskRootFinal, onNotice: deps.onNotice, sessionId, runId });
|
|
448
449
|
const legHome = validatePath(executionEnv.homeDir, { intent: "validate-coordinate" });
|
|
449
450
|
const legAnchors = { root: taskRootCanonical, ...(legHome !== undefined ? { home: legHome } : {}) };
|
|
@@ -480,11 +481,15 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
480
481
|
const effectivePathDenyRules = policyDenyRows.filter((r) => r.unanchored === undefined);
|
|
481
482
|
const writeTargetJudgeRef = {};
|
|
482
483
|
const legExemptRoots = Object.freeze(dataRootSpellings(deps.memoryEngineDir));
|
|
483
|
-
const
|
|
484
|
+
const { seat: worktreeSeat, writeLocation, checkout } = writeLocationOf({ spelled: taskRootFinal, canonical: taskRootCanonical });
|
|
485
|
+
const legWriteGuard = { exemptRoots: legExemptRoots, rows: toolPolicyWriteGuardRows([installedToolPolicy, ...(inheritedParentConstraints ?? []).map((c) => c.policy)]), checkout };
|
|
484
486
|
const sideCallBookRef = {};
|
|
485
|
-
const { roster, blockedRef, runtimeCaps, runtimeCapsFaulted, complianceDenies, complianceDegraded, agentForkDenial, observersActive, autoModeArmReason, autoModeDeciderRef, autoModeDenialTrackingRef, autoModeArmingRef, armAutoMode, selfOrchestrationActive, workflowToolsActive, workflowSizeGuideline } = await prepareCapsAndWorkflow({ spec, deps, askSeat: doors.askSeat, internals, crossBoundaryTree, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, model, thinking, lockedPreflight, checkpointSeat, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, parentSpecSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, requestReview, enterPlanMode, permissionMode, readDenyEntries: () => personRows.tablesReady().then(() => ({ entries: readDenyMatcher?.entries ?? [], ruleRows: pathTables?.ruleRows() ?? effectivePathDenyRules })), peerLaneActive, peerSendMessageBuiltIn, runnerSelf, memoryEngineSession: () => memoryEngineSession, centerAdoption: () => centerAdoptionRef.current, delegated: delegation.isDelegatedChild, sideCallBookRef });
|
|
487
|
+
const { roster, blockedRef, runtimeCaps, runtimeCapsFaulted, complianceDenies, complianceDegraded, agentForkDenial, observersActive, autoModeArmReason, autoModeDeciderRef, autoModeDenialTrackingRef, autoModeArmingRef, armAutoMode, selfOrchestrationActive, workflowToolsActive, workflowSizeGuideline } = await prepareCapsAndWorkflow({ spec, deps, askSeat: doors.askSeat, internals, crossBoundaryTree, session, sessionId, runId, hostTaskId, taskScope, taskRootFinal, model, thinking, lockedPreflight, checkpointSeat, toolEffects, toolFaceSnapshot, promptLean, resolvedInteractionPosture, harnessRef, parentSpecSeat, runClampSource, forwardEvent, inheritedGateForChildren, enrichSpecToolCtx, maybeOffload, requestReview, ...(spec.planFile !== undefined ? { planFileSource: { path: spec.planFile, shown: planFileShown(spec.planFile), read: (signal) => advertisedWritableDirs?.readPlanFile(signal) ?? Promise.resolve({ ok: false, reason: "this run admitted no plan file" }) } } : {}), enterPlanMode, permissionMode, readDenyEntries: () => personRows.tablesReady().then(() => ({ entries: readDenyMatcher?.entries ?? [], ruleRows: pathTables?.ruleRows() ?? effectivePathDenyRules })), peerLaneActive, peerSendMessageBuiltIn, runnerSelf, memoryEngineSession: () => memoryEngineSession, centerAdoption: () => centerAdoptionRef.current, delegated: delegation.isDelegatedChild, sideCallBookRef });
|
|
486
488
|
const tools = roster.tools;
|
|
487
489
|
const crossBoundary = await prepareCrossBoundaryLane({ token: crossBoundaryTree, posture: doors.crossBoundaryPosture, externalContentTargetActive, env: executionEnv, session, resumeLeg: resume !== undefined, sessionId, runId, hostTaskId, deps });
|
|
490
|
+
const sessionProject = await resolveSessionProject(projectMarkerFsOf(executionEnv), taskRootCanonical, spec.projectId);
|
|
491
|
+
if (sessionProject.markerFault !== undefined)
|
|
492
|
+
deps.onError?.(sessionProject.markerFault, { phase: "config", sessionId });
|
|
488
493
|
const pausedRef = {};
|
|
489
494
|
const undeliveredContinuationRef = { current: { parkedSteers: [], orphanTasks: [] } };
|
|
490
495
|
const remoteEnvFailures = [];
|
|
@@ -544,9 +549,12 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
544
549
|
roster.mount(createOutputTool(outputRef, spec.outputSchema, compiled.strict ? compiled.modelSchema : undefined), { source: "synthetic", mountedBy: "optional" });
|
|
545
550
|
}
|
|
546
551
|
const rosterSeat = new ToolRosterDeltaSeat();
|
|
547
|
-
const
|
|
552
|
+
const mcpRequestMeta = createMcpRequestMetaSeat(sessionId);
|
|
553
|
+
const { mcp, a2a, rebuildHarnessToolsRef, contentOriginWrapRef, toolCallGateArmedRef, mcpRedial } = await prepareProtocolTools({ lockedPreflight, hostFloor: doors.hostFloor, spec, deps, modBus: legMods.bus, ...(mcpPool !== undefined ? { mcpPool } : {}), reminderMark, reminderDisclosureCounts, mcpRequestMeta, runId, sessionId, onceLedger, roster, rosterSeat, remoteToolOffload, toolFaceSnapshot, toolEffects, axisExplicitNegatives, irreversibilityTier, irreversibleTools, egressTools, toolMarkSources, abortController, rollback });
|
|
548
554
|
const callIssuedAtRef = {};
|
|
549
555
|
const workCutRef = { continuation: false, abortedBeforeTurnEnd: false };
|
|
556
|
+
if (spec.planFile !== undefined && (!handsEnabled || spec.handsReadOnly === true))
|
|
557
|
+
throw planFileInvalid(spec.planFile, handsEnabled ? "is declared on a leg whose hands are read-only (handsReadOnly), so no file tool can write it" : "is declared on a leg with no execution environment, so no file tool can write it");
|
|
550
558
|
const advertisedWritableDirs = handsEnabled
|
|
551
559
|
? new AdvertisedWritableDirs(executionEnv, (dir, reason) => deps.onError?.(new Error(`${dir.advertiser} advertised writable directory skipped: ${dir.path} — ${reason}`), { phase: "config", sessionId }), taskRootCanonical, [...(spec.additionalDirectories ?? []), ...(spec.additionalReadDirectories ?? [])])
|
|
552
560
|
: undefined;
|
|
@@ -575,6 +583,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
575
583
|
sessionId,
|
|
576
584
|
...(captureLineage.own !== undefined ? { sessionIncarnation: captureLineage.own } : {}),
|
|
577
585
|
taskRootPath: taskRootFinal,
|
|
586
|
+
sessionProject,
|
|
578
587
|
reminderMark,
|
|
579
588
|
writeToolsMounted: (handsWriteHalfPlanned || tools.some((t) => t.name === "Write")) &&
|
|
580
589
|
valveLeaves(spec, toolFaceSnapshot.selector)({ name: "Write" }) &&
|
|
@@ -623,9 +632,9 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
623
632
|
internals.ownOrgAdmissionRef.current = ownOrgVerdictRef.current;
|
|
624
633
|
}
|
|
625
634
|
const modelFileReaderSeat = {};
|
|
626
|
-
const handsReadFaceInput = { permissionMode, denyRuleRows: effectivePathDenyRules, headLeads, writeTargetJudge: () => writeTargetJudgeRef.current, personRows, handsEnabled, executionEnv, taskRootFinal, taskRootCanonical, rebaseRestoredPath, resume, session, sessionId, hostTaskId, taskScope, fullShellReachable, effectiveShellGate, toolFaceSnapshot, model, spec, deps, internals, memoryWriteGate, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), firstPartyOffload, roster, egressTools, irreversibilityTier, irreversibleTools, reversibilityProbes, reminderMark, reminderDisclosureCounts, modelFileReaderSeat, ...(trackFileEdit !== undefined ? { trackFileEdit } : {}), onFileEdited: noteFileEdited, harnessRef, toolProgressRef, toolOccurrences };
|
|
635
|
+
const handsReadFaceInput = { permissionMode, denyRuleRows: effectivePathDenyRules, headLeads, writeTargetJudge: () => writeTargetJudgeRef.current, personRows, handsEnabled, executionEnv, taskRootFinal, taskRootCanonical, rebaseRestoredPath, resume, session, sessionId, hostTaskId, taskScope, fullShellReachable, effectiveShellGate, toolFaceSnapshot, model, spec, deps, internals, memoryWriteGate, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), firstPartyOffload, roster, egressTools, irreversibilityTier, irreversibleTools, reversibilityProbes, reminderMark, reminderDisclosureCounts, modelFileReaderSeat, ...(trackFileEdit !== undefined ? { trackFileEdit } : {}), onFileEdited: noteFileEdited, harnessRef, toolProgressRef, toolOccurrences, writeLocation };
|
|
627
636
|
const handsReadFace = handsEnabled ? await prepareHandsMount(handsReadFaceInput) : resolveHandsLessReadFace(handsReadFaceInput);
|
|
628
|
-
const { readFileStateForCheckpoint, seedContextFiles, handsCwdRef, workspaceStateSettle, wsSnapshot, rebaseWsPath, backgroundTaskToolsActive, shellReadCheck, shellReadAdmission, additionalRootsCanonical, attachmentRootCanonical, readDenyMatcher, readRoots, pathTables, envHandToolNames, sealReadStateSeat } = handsReadFace;
|
|
637
|
+
const { readFileStateForCheckpoint, seedContextFiles, handsCwdRef, workspaceStateSettle, wsSnapshot, rebaseWsPath, backgroundTaskToolsActive, shellReadCheck, shellReadAdmission, shellReadLandings, additionalRootsCanonical, attachmentRootCanonical, readDenyMatcher, readRoots, pathTables, envHandToolNames, sealReadStateSeat } = handsReadFace;
|
|
629
638
|
resolvedReadFace = handsReadFace.resolvedReadFace;
|
|
630
639
|
resolvedWriteFace = handsReadFace.resolvedWriteFace;
|
|
631
640
|
readDenyAdditionsNormalized = handsReadFace.readDenyAdditionsNormalized;
|
|
@@ -633,7 +642,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
633
642
|
handsLessResolvedWriteFace = handsReadFace.handsLessResolvedWriteFace;
|
|
634
643
|
shellGatedTools = handsReadFace.shellGatedTools;
|
|
635
644
|
await armAutoMode();
|
|
636
|
-
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, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle });
|
|
645
|
+
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, checkpointSeat, handsCwdRef, wsSnapshot, rebaseWsPath, rebaseRestoredPath, workspaceStateSettle, worktreeSeat });
|
|
637
646
|
const { liveQuestionFace, contentAskBindings, contentAskRoutable, lateStrandedAnswers, discloseStrandedAnswers, settleContentAskBindings, durableQuestionFace, questionToolMounted, mountedQuestionTool } = prepareQuestionFace({ frozenOnQuestion, spec, deps, checkpointStore, runtimeCaps, resolvedInteractionPosture, resume, sessionId, roster, toolFaceSnapshot, inheritedUnavailableAsks: () => inheritedUnavailableAsks });
|
|
638
647
|
if (spec.handsReadOnly !== true) {
|
|
639
648
|
const sessionScope = sessionId ?? spec.principal ?? spec.taskId ?? "default";
|
|
@@ -681,7 +690,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
681
690
|
const { memoryBlock: memoryBlockWithProject, instructionSources, projectMemoryFact, projectInstructionContent, skillSpecs, skillSeatOf, skillsListing, sharedMemoryPairMounted, memoryEnginePairMounted } = projectContext;
|
|
682
691
|
const { featureFlags, sugar, mcpInstructionsBlock, envFacts, tzValid, userTz, dateAnchor, gitStatusRef } = await preparePromptInputs({ modBus: legMods.bus, spec, deps, contextOverlay: legContextOverlay(), failClosedReason: selfOrchestrationFailClosedReason(spec, deps), lockedPreflight, selfOrchestrationActive, executionEnv, reminderMark, resolvedReadFace, resolvedWriteFace: resolvedWriteFace?.inForce(), toolFaceSnapshot, internals, thinking, ownedEnv, delegation, resolvedRole, taskRole: promptHost.role, mcp, roster, model, externalContentTargetActive, resume, handsEnabled, taskRootFinal, additionalRootsCanonical, additionalReadRootsCanonical: (await readRoots.ready().then(readRoots)).filter((r) => !additionalRootsCanonical.includes(r)), sessionId, session, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}) });
|
|
683
692
|
const advisor = await prepareAdvisor({ spec, advisorTool: doors.advisorTool, deps, model, roster, selector: toolFaceSnapshot.selector, session, onceLedger, rootLeg: !delegation.isDelegatedChild, sessionId, runId, sideCallBookRef, lastSentRequest: () => lastBrainContextRef.current, brainCallGuardrailMs });
|
|
684
|
-
judgeRunToolLists({ spec, tools: roster.tools, declaredPeers: { mcp: lockedPreflight.mcp, a2a: a2a.statuses }, own: { allow: toolFaceLists.allow, exclude: toolFaceLists.exclude },
|
|
693
|
+
judgeRunToolLists({ spec, tools: roster.tools, declaredPeers: { mcp: lockedPreflight.mcp, a2a: a2a.statuses }, own: { allow: toolFaceLists.allow, exclude: toolFaceLists.exclude }, selector: toolFaceSnapshot.selector, legs: toolLegs, judgedUpstream: toolListsJudged !== undefined, toldUpstream: internals?.ownToolLists !== undefined && ownToolLists !== undefined && toolCeiling !== undefined, ownBy: ownToolLists, onceLedger, sessionId });
|
|
685
694
|
const { deferred, memoryBlock, toolSearch: toolSearchPolicy } = prepareDeferClassify({ spec, deps, roster, toolFaceSnapshot, handsEnabled, fullShellReachable, promptTraits, model, mcp, a2a, sharedMemoryPairMounted, memoryEnginePairMounted, memoryBlock: memoryBlockWithProject, memoryRecallSegment, onceLedger, sessionId });
|
|
686
695
|
prepareMemoryEngineSession({ memoryEngineSession, internals, memoryDelegationEvidence, externalContentTargetActive, lockedPreflight, ...(mountedMcpNow !== undefined ? { mountedMcp: mountedMcpNow } : {}), sessionId, runId, deps, provenanceForChildrenRef, delegationSettlementRef, spec, envHandToolNames, roster, contentOriginWrapRef });
|
|
687
696
|
const { systemPromptSeat, renderWithDate, systemBlocks, promptManifest, promptIdentity, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef } = await preparePromptAssembly({ session, deps, internals, resume, sugar: sugar.overlays, host: { ...(sugar.hostRole !== undefined ? { role: sugar.hostRole } : {}), ...(promptHost.form !== undefined ? { form: promptHost.form } : {}) }, binding: promptBinding, modBus: legMods.bus, signal: abortController.signal, featureFlags, mcpInstructionsBlock, memoryBlock, envFacts, promptTraits, tools, model, sessionId, onceLedger });
|
|
@@ -793,9 +802,9 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
793
802
|
releaseSignal = () => sig.removeEventListener("abort", onExternalAbort);
|
|
794
803
|
}
|
|
795
804
|
}
|
|
796
|
-
const { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, grantBindingOf, permissionRuleLane, ruleLaneFacts, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations, inheritedToolChecks } = await preparePolicyChain({ hostFloor: doors.hostFloor, spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, executionEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { leg: legAnchors, chainTop }, headLeads, tools, harnessTools, selector: toolFaceSnapshot.selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus: legMods.bus, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, readFace: () => resolvedReadFace, permissionMode,
|
|
797
|
-
const { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, incompleteSuspendAdapter, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, askSeat: doors.askSeat, hostFloorPosture: doors.hostFloor?.posture, crossBoundaryStationEngaged: crossBoundary.stationEngaged, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus: legMods.bus, standingModBus: legMods.standing, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, legWriteGuard, mcp, irreversibleTools, egressTools, shellReadStationArmed: handsReadFace.shellReadStationArmed, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, lockedPreflight, peerLaneRefs, frameSettlement, harness, pausedRef, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive: ownSessionRulesRef.current !== undefined, sessionBox, checkpointScope, memoryPollution: () => memoryEngineSession?.pollution, advisorFact: advisor.manifest });
|
|
798
|
-
toolCallStationRef.current = createToolCallStation({ bus: legMods.bus, occurrences: toolOccurrences, blockedToolCalls, identity: hookIdentity, reminderMark });
|
|
805
|
+
const { basePolicyForResumeEdit, denyNarrowingPolicy, skillGrantLane, allowEntryLanes, policyLayers, effectivePolicy, inheritedUnavailableAsks, inheritedAskGrants, askSourceIdentity, riskAxesOf, ruleOffersOf, grantBindingOf, permissionRuleLane, ruleLaneFacts, permissionRuleOrgLane, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, foldAskClasses, ancestorSandboxAdmissions, ancestorArbitrations, inheritedToolChecks } = await preparePolicyChain({ hostFloor: doors.hostFloor, spec, deps, internals, sessionId, runId, hostTaskId, taskRootFinal, additionalRootsCanonical, writeLocation, executionEnv, lockedPreflight: installedPreflight, pathRuleAnchors: { leg: legAnchors, chainTop }, headLeads, tools, harnessTools, selector: toolFaceSnapshot.selector, toolEffects, egressTools, irreversibilityTier, axisExplicitNegatives, shellGatedTools, toolMarkSources, envHandToolNames, handsCwdRef, readDenyMatcher, personRows, questionToolMounted, runtimeCaps, inheritedAncestorRules, ancestorSessionRulesRef, inheritedParentConstraints, seedInheritedGate, skillGrants, skillSpecs, allowedToolTables, frozenOnAsk, hookEnvSource, notifyOwnHookCrash, modBus: legMods.bus, ownModChain, autoModeDecider: () => autoModeDeciderRef.current, readFace: () => resolvedReadFace, permissionMode, toolRosterDeltas: rosterSeat, stopForDenialLimit, delegation, abortController, now, ownSessionRulesRef });
|
|
806
|
+
const { onAsk, preToolContexts, blockedToolCalls, batchHaltRef, blockedTracked, incompleteSuspendAdapter, durableSuspendInfraReady, resourceSuspendEligible, usageGovernance, durableApproval, wiringManifest, writeProtection, parkLaneArmed, gateMachineryActive, hookIdentity, hookEnvFace, sessionBoxBound } = prepareWiringManifest({ spec, deps, askSeat: doors.askSeat, hostFloorPosture: doors.hostFloor?.posture, crossBoundaryStationEngaged: crossBoundary.stationEngaged, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus: legMods.bus, standingModBus: legMods.standing, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, legWriteGuard: advertisedWritableDirs?.planFile !== undefined ? { ...legWriteGuard, exemptFiles: [advertisedWritableDirs.planFile] } : legWriteGuard, mcp, irreversibleTools, egressTools, shellReadStationArmed: handsReadFace.shellReadStationArmed, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, lockedPreflight, peerLaneRefs, frameSettlement, harness, pausedRef, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive: handsReadFace.readDenyBuiltinTiersActive, lspManagerWired, lspDiagnosticsLive: lspDiagnostics !== undefined, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive: ownSessionRulesRef.current !== undefined, sessionBox, checkpointScope, memoryPollution: () => memoryEngineSession?.pollution, advisorFact: advisor.manifest, runOrigin: doors.runOrigin });
|
|
807
|
+
toolCallStationRef.current = createToolCallStation({ bus: legMods.bus, occurrences: toolOccurrences, blockedToolCalls, identity: hookIdentity, reminderMark, requestMeta: mcpRequestMeta });
|
|
799
808
|
const writeProtectionCheck = writeProtection.mount?.check;
|
|
800
809
|
writeTargetJudgeRef.current = writeProtection.judgeWriteTarget;
|
|
801
810
|
if (fileHistoryBoundary !== undefined) {
|
|
@@ -808,9 +817,9 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
808
817
|
const stampCallTarget = attachmentRootCanonical === undefined ? undefined : legCallTargetStamp({ env: executionEnv, root: attachmentRootCanonical, cwd: () => handsCwdRef?.current, judgesPaths: () => parkLaneArmed || effectivePolicy?.pathRules !== undefined || basePolicyForResumeEdit?.pathRules !== undefined || permissionRuleLane !== undefined || skillSpecs.some((s) => compileSkillGrant(s, "model").rows.some((r) => r.compiled.kind === "path")) || allowedToolTables.request.holdsPathRows() || allowedToolTables.deployment.holdsPathRows(), leads: () => headLeads.resolve([...toolPolicyPathRules([effectivePolicy, basePolicyForResumeEdit, ...(inheritedParentConstraints ?? []).map((c) => c.policy)], legAnchors), ...bindPathRules(listPathRows().map((rule) => ({ parsed: rule, ruleText: rule.rule })), legAnchors)]) });
|
|
809
818
|
const { askLane } = prepareAskLane({ gateMachineryActive, abortController, effectivePolicy, budgetSnapshot, handsCwdRef, handsRoot: attachmentRootCanonical, stampCallTarget, advertisedWritableDirs, exemptRoots: legExemptRoots, tools, inheritedUnavailableAsks, inheritedAskGrants, onAsk, humanReviewRef, now, ruleOffersOf, grantBindingOf, askSourceIdentity, riskAxesOf, autoModeDenialTracking: autoModeDenialTrackingRef, spec, deps, sessionId, runId, modBus: legMods.bus, notifyOwnHookCrash, grantReadRoot: handsReadFace.grantReadRoot });
|
|
810
819
|
const inheritedAnchorRecords = chainAnchorRecords(chainTop, inheritedParentConstraints ?? []);
|
|
811
|
-
const { saga } = prepareSuspendSaga({ gateMachineryActive, crossBoundary, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection: () => legMods.skillScopes.frozen(), reminderMark, handsCwdRef, handsRoot: attachmentRootCanonical, handsHome: attachmentRootCanonical !== undefined ? legAnchors.home : undefined, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors: chainTop !== legAnchors ? inheritedAnchorRecords.pathRuleAnchors : undefined, inheritedPathRuleInstallations: inheritedAnchorRecords.pathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, toolCeiling, toolListsJudged, ownToolLists, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter });
|
|
820
|
+
const { saga } = prepareSuspendSaga({ gateMachineryActive, crossBoundary, abortController, harness, checkpointStore, deps, sessionId, hostTaskId, taskScope, liveSpendRef, resume, nestedStats, internals, activeTools, outputRef, readFileStateForCheckpoint, faceCheckpointSection, writeFaceCheckpointSection, skillGrantCheckpointSection, skillScopesCheckpointSection: () => legMods.skillScopes.frozen(), reminderMark, handsCwdRef, handsRoot: attachmentRootCanonical, handsHome: attachmentRootCanonical !== undefined ? legAnchors.home : undefined, worktreeSessionRef, undeliveredContinuationRef, inheritedParentConstraints, seedInheritedGate, ancestorRulesNow, inheritedShellGate, permissionMode, inheritedAdmittedOrgScopes, inheritedPathRuleAnchors: chainTop !== legAnchors ? inheritedAnchorRecords.pathRuleAnchors : undefined, inheritedPathRuleInstallations: inheritedAnchorRecords.pathRuleInstallations, ownOrgVerdictRef, orgGovernedProvenance, announcedListingsRef, gitStatusRef, hookIdentity, placementRootResolved, checkpointScope, runOrigin: doors.runOrigin, toolCeiling: toolCeilingRead, toolListsJudged, ownToolLists, externalContentTargetActive, remoteEnvFailures, memoryEngineSession, suspendLoopRef, ownedEnv, incompleteSuspendAdapter });
|
|
812
821
|
const { suspendForResource, suspendForPlatformLimit, suspendForReview } = prepareBoundaryParks({ saga, spec, checkpointStore, checkpointScope, abortController, harness, session, sessions, sessionId, deps, priorLedger, maxSlices, maxSuspends, resourceTotal, priorSuspendCount, suspendChainBase, humanReviewRef, liveSpendRef, now, pausedRef, remoteEnvFailures, resourceSuspendEligible, durableSuspendInfraReady, incompleteSuspendAdapter });
|
|
813
|
-
const { parkAsk } = prepareParkAsk({ askLane, saga, spec, deps, sessionId, checkpointStore, checkpointScope, toolRosterDeltas: rosterSeat, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot: attachmentRootCanonical, stampCallTarget, advertisedWritableDirs, exemptRoots: legExemptRoots, offloadStore, ownedEnv, incompleteSuspendAdapter, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, irreversibilityTier, toolMarkSources, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, ruleOffersOf, grantBindingOf, now, humanReviewRef, abortController, harness, pausedRef });
|
|
822
|
+
const { parkAsk } = prepareParkAsk({ askLane, saga, spec, deps, sessionId, checkpointStore, checkpointScope, toolRosterDeltas: rosterSeat, parkLaneArmed, contentAskRoutable, liveQuestionFace, mountedQuestionTool, contentAskBindings, lateStrandedAnswers, discloseStrandedAnswers, onAsk, runtimeCaps, inheritedUnavailableAsks, basePolicyForResumeEdit, budgetSnapshot, handsCwdRef, handsRoot: attachmentRootCanonical, stampCallTarget, shellReadLandings, advertisedWritableDirs, exemptRoots: legExemptRoots, offloadStore, ownedEnv, incompleteSuspendAdapter, session, sessions, suspendChainBase, maxSuspends, remoteEnvFailures, shellGatedTools, irreversibilityTier, toolMarkSources, effectiveShellGate, durableApproval, priorLedger, liveSpendRef, resourceTotal, ruleOffersOf, grantBindingOf, now, humanReviewRef, abortController, harness, pausedRef });
|
|
814
823
|
const seatInputsFor = skillGateWiring({ tools, skillToolName: SKILL_TOOL_NAME, seatOf: skillSeatOf, mode: () => permissionMode.current, lane: skillGrantLane, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.skill_allowed", version: 1, taskId: hostTaskId, ...info, entries: [...info.entries], ts: Date.now() })), allowEntries: { deploymentAllows: { ...allowEntryLanes.deployment, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "deployment", ...info, entries: [...info.entries], ts: Date.now() })) }, requestAllows: { ...allowEntryLanes.request, onAllowed: (info) => emitTrace(deps.tracer, () => ({ kind: "permission.allowed_tools_allowed", version: 1, taskId: hostTaskId, source: "request", ...info, entries: [...info.entries], ts: Date.now() })) } } });
|
|
815
824
|
const { approvedCallScreen } = prepareGateStations({ askLane, parkAsk, tools, toolRosterDeltas: rosterSeat, crossBoundaryCheck: crossBoundary.seat({ tools, roster: rosterSeat }), deps, toolCallGateArmedRef, effectivePolicy, modBus: legMods.bus, inheritedToolChecks, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, handsCwdRef, stampCallTarget, readDenyInForce: (toolCallId) => ({ tiers: handsReadFace.readDenyBuiltinTiersActive, rows: [...readDenyAdditionsNormalized.map((e) => e.pattern), ...(pathTables?.forCall(toolCallId).ruleRows ?? handsReadFaceInput.denyRuleRows).filter((r) => r.faces.includes("read")).map((r) => r.rule)] }), hookEnvFace, writeProtectionCheck, shellReadCheck, readFace: () => resolvedReadFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider: autoModeDeciderRef, autoModeDenialTracking: autoModeDenialTrackingRef, askRoute: { ...wiringManifest.ask, effective: askSeatEffective(wiringManifest) }, permissionMode, toolMarkSources, ...(deps.a2a?.isolatePeers === true ? { a2aIsolatePeers: true } : {}), ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, seatInputsFor, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement });
|
|
816
825
|
const postureFrameRef = { report: (err) => deps.onError?.(err, { phase: "degraded", sessionId }) };
|
|
@@ -818,7 +827,7 @@ export async function prepareTask(request, deps, sessions, resume, internals, ru
|
|
|
818
827
|
const preparedHolder = {};
|
|
819
828
|
const { cacheBreakDetector, cacheFingerprint, promptOverheadTokens, compactionRestore, normalizeAttachmentPath, isDedupStubResult, recentlyReadFiles, onCompactionApplied, detectExternalChanges, syntheticReadVerdict, consolidationWriteJudge, listBackgroundTasks, centerCompactionCandidate, effectiveReadFaceObserved, effectiveWriteFaceObserved, effectiveReadDenyObserved } = prepareTurnWiring({ deps, systemPromptSeat, harnessTools, fpRef, model, promptIdentityDigest: promptManifest.identity.artifact, systemBlocks, thinking, spec, sessionId, turnSnapshotRef, promptManifest, charsPerToken, handsEnabled, executionEnv, attachmentRootCanonical, readRoots, modelFileReader: modelFileReaderSeat.current, reminderMark, reminderDisclosureCounts, resolvedReadFace, handsCwdRef, readFileStateForCheckpoint, denyNarrowingPolicy, skillGrants: skillGrantLane, callerPolicy: installedToolPolicy, inheritedPolicies: (inheritedParentConstraints ?? []).map((c) => c.policy), persistedRuleLane: permissionRuleLane, ruleLaneFacts, personRowsBeyondRun, orgRuleLane: permissionRuleOrgLane, stampCallTarget, abortController, hostTaskId, taskScope, buildAssembleInputs, identityFor, adoptsCandidates, centerAdoptionRef, harnessRef, carrierReadFace, carrierWriteFace, readDenyAdditionsNormalized, preparedHolder });
|
|
820
829
|
await onceLedger.settle(session, announcedListingsRef);
|
|
821
|
-
const buildPrepared = () => ({ harness, session, sessionId, runId, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatEffective(wiringManifest) }, ...(outputStyleFrame !== undefined ? { outputStyleFrame } : {}), permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, compModel: effectiveCompModel, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, toolOccurrences, batchHaltRef, nestedStats, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), effectiveMemoryScopes: memoryEffectiveScopes, cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, cacheBreakDetector, cacheFingerprint, wiringManifest, promptManifest, promptIdentity, 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, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, isDedupStubResult, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(instructionSources ? { instructionSources } : {}), ...(projectInstructionContent !== undefined ? { projectInstructionContent } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts: { pending: [], listingSnapshotOwed: false }, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, listBackgroundTasks, hookIdentity, modBus: legMods.bus, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}) });
|
|
830
|
+
const buildPrepared = () => ({ harness, session, sessionId, runId, crossBoundary, ...(doors.hostFloor !== undefined ? { hostFloor: doors.hostFloor } : {}), registryAccess: { owner: hostTaskId, scope: taskScope }, reminderMark, reminderDisclosureCounts, fullShellReachable, approvalPosture: { get mode() { return permissionMode.current; }, askEffective: askSeatEffective(wiringManifest) }, ...(outputStyleFrame !== undefined ? { outputStyleFrame } : {}), permissionMode, editedFilesSnapshot, taskRootPath: taskRootFinal, model, thinking, compModel: effectiveCompModel, mcp, ...(mcpRedial !== undefined ? { mcpRedial } : {}), ...(a2a.tools.length > 0 ? { a2a } : {}), blockedRef, outputRef, abortController, conflictRef, blockedToolCalls, toolOccurrences, batchHaltRef, nestedStats, ...(rewindNotes.length > 0 ? { rewindNotes } : {}), ...(fileHistoryBoundary !== undefined ? { fileHistoryBoundary } : {}), ...(effectiveReadFaceObserved !== undefined ? { effectiveReadFace: effectiveReadFaceObserved, effectiveWriteFace: effectiveWriteFaceObserved } : {}), ...(effectiveReadDenyObserved !== undefined ? { effectiveReadDenyPatterns: effectiveReadDenyObserved } : {}), effectiveMemoryScopes: memoryEffectiveScopes, cwdRef: handsCwdRef, ...(attachmentRootCanonical !== undefined ? { handsRoot: attachmentRootCanonical } : {}), ...(stampCallTarget !== undefined ? { stampCallTarget } : {}), toolProgressRef, ...(advertisedWritableDirs !== undefined ? { advertisedWritableDirs } : {}), exemptRoots: legExemptRoots, ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), workspaceFrame: createWorkspaceFrameSeat({ root: taskRootCanonical, ...(handsCwdRef !== undefined ? { cwdRef: handsCwdRef } : {}), ...(worktreeSessionRef !== undefined ? { worktreeSessionRef } : {}), ...(sessionProject.project !== undefined ? { project: sessionProject.project } : {}), remote: workspaceRemote }), ...(workspaceStateSettle !== undefined ? { workspaceStateSettle } : {}), ...(sealReadStateSeat !== undefined ? { sealReadStateSeat } : {}), denyNarrowingPolicy, skillGrants: skillGrantLane, skillSpecs, ...(permissionRuleLane !== undefined ? { persistedRuleLane: permissionRuleLane } : {}), ...(basePolicyForResumeEdit !== undefined ? { basePolicyForResumeEdit } : {}), consolidationWriteJudge, ...(permissionRuleOrgLane !== undefined ? { permissionRuleOrg: permissionRuleOrgLane } : {}), releaseSignal, endModeCeiling, settleContentAskBindings, cacheBreakDetector, cacheFingerprint, wiringManifest, promptManifest, promptIdentity, 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, lastSentRequest: () => lastBrainContextRef.current, ...(advisor.instruction !== undefined ? { advisorInstruction: advisor.instruction } : {}), ...(compactionRestore !== undefined ? { compactionRestore } : {}), recentlyReadFiles, normalizeAttachmentPath, isDedupStubResult, ...(onCompactionApplied ? { onCompactionApplied } : {}), compactionReuseRef, trimPressureRef, microCompact, ...(memoryEngineSession ? { memoryEngineSession } : {}), ...(subagentRetain ? { subagentRetain } : {}), ...(lspDiagnostics && nudgeLspOnEdit && withheldDiagnosticsOf ? { lspDiagnostics: { registry: lspDiagnostics, nudge: nudgeLspOnEdit, runIdent: lspRunIdent, withheldOf: withheldDiagnosticsOf } } : {}), stopRequestedRef, announcedSnapshotRecovered: onceLedger.recovered, ...(dateChange ? { dateChange } : {}), ...(instructionSources ? { instructionSources } : {}), ...(projectInstructionContent !== undefined ? { projectInstructionContent } : {}), ...(workflowSizeGuideline ? { workflowSizeGuideline } : {}), ...(detectExternalChanges ? { detectExternalChanges } : {}), ...(toolsDeltaRef ? { toolsDeltaRef } : {}), ...(mcpUnavailable ? { mcpUnavailable } : {}), ...(agentListing ? { agentListing } : {}), ...(skillsListing ? { skillsListing } : {}), announcedListingsRef, frameReceipts: { pending: [], listingSnapshotOwed: false }, frameSettlement, ...(userAttachmentsSeat !== undefined ? { userAttachments: userAttachmentsSeat } : {}), attachmentDelivery: createAttachmentDelivery(), ...(modelFileReaderSeat.current !== undefined ? { modelFileReader: modelFileReaderSeat.current } : {}), syntheticReadVerdict, ...(peerLaneRefs.boundaryRound !== undefined ? { peerBoundaryRound: peerLaneRefs.boundaryRound } : {}), gitStatusRef, postureFrameRef, listBackgroundTasks, hookIdentity, modBus: legMods.bus, sideCallBookRef, ...(sessionBoxBound !== undefined ? { sessionBox: sessionBoxBound } : {}), ...(turnSnapshotRef.current !== undefined ? { turnSnapshot: turnSnapshotRef.current } : {}), ...(centerCompactionCandidate !== undefined ? { centerCompactionCandidate } : {}), ...(shellReadCheck !== undefined ? { shellReadCheck } : {}), ...(shellReadLandings !== undefined ? { shellReadLandings } : {}), ...(toolDisclosureSeat !== undefined ? { toolDisclosure: toolDisclosureSeat } : {}), ...(approvedCallScreen !== undefined ? { approvedCallScreen } : {}), ...(toolCallStationRef.current !== undefined ? { toolCallStation: toolCallStationRef.current } : {}) });
|
|
822
831
|
refuseLateRosterChanges(callerRoster.roster);
|
|
823
832
|
rollback.commit();
|
|
824
833
|
commitModeSeats(abortController.signal);
|
|
@@ -114,6 +114,19 @@ export interface PrepareToolDisclosureMountResult {
|
|
|
114
114
|
/** owned — the deferral census seat, minted ONLY when something is deferred; absent ⇒ no `tool_disclosure` frame at all. */
|
|
115
115
|
toolDisclosureSeat?: ToolDisclosureSeat;
|
|
116
116
|
}
|
|
117
|
+
/**
|
|
118
|
+
* The ToolSearch activation set a branch's landed compactions restate: the union of every engine compaction entry's
|
|
119
|
+
* snapshot (activation is monotonic in-session and every snapshot restates the then-current set, so the union is the
|
|
120
|
+
* latest complete restatement plus whatever older names a snapshotless window preserved); hook-authored entries are
|
|
121
|
+
* skipped like every sibling carrier reader (their details are not engine shape). Unfiltered — a leg intersects it
|
|
122
|
+
* with its own deferred registry. The one reading for a leg's seed and for a pass with no leg (the out-of-run
|
|
123
|
+
* compaction restates it, so a wake whose floor sits at the newest compaction still sees it).
|
|
124
|
+
*/
|
|
125
|
+
export declare function compactionActivationSnapshot(branch: ReadonlyArray<{
|
|
126
|
+
readonly type: string;
|
|
127
|
+
readonly fromHook?: boolean;
|
|
128
|
+
readonly details?: unknown;
|
|
129
|
+
}>): string[];
|
|
117
130
|
/** Test seam (mirrors `__resetToolModelGateAnnouncements`): never called by production code.
|
|
118
131
|
* Re-arms BOTH arms (a WeakMap has no clear — it is re-minted). */
|
|
119
132
|
export declare function __resetMaterializeEnvAnnouncements(): void;
|
|
@@ -16,6 +16,16 @@ function materializeEnvLedger(onNotice) {
|
|
|
16
16
|
}
|
|
17
17
|
return lines;
|
|
18
18
|
}
|
|
19
|
+
export function compactionActivationSnapshot(branch) {
|
|
20
|
+
const names = new Set();
|
|
21
|
+
for (const entry of branch) {
|
|
22
|
+
if (entry.type !== "compaction" || entry.fromHook === true)
|
|
23
|
+
continue;
|
|
24
|
+
for (const n of readCompactionActiveTools(entry.details))
|
|
25
|
+
names.add(n);
|
|
26
|
+
}
|
|
27
|
+
return [...names];
|
|
28
|
+
}
|
|
19
29
|
export function __resetMaterializeEnvAnnouncements() {
|
|
20
30
|
announcedMaterializeEnvBySink = new WeakMap();
|
|
21
31
|
announcedMaterializeEnvConsole.clear();
|
|
@@ -144,13 +154,9 @@ export async function prepareToolDisclosureMount(input) {
|
|
|
144
154
|
if (deferred.has(n))
|
|
145
155
|
activeTools.add(n);
|
|
146
156
|
}
|
|
147
|
-
for (const
|
|
148
|
-
if (
|
|
149
|
-
|
|
150
|
-
for (const n of readCompactionActiveTools(entry.details)) {
|
|
151
|
-
if (deferred.has(n))
|
|
152
|
-
activeTools.add(n);
|
|
153
|
-
}
|
|
157
|
+
for (const n of compactionActivationSnapshot(await session.getBranch())) {
|
|
158
|
+
if (deferred.has(n))
|
|
159
|
+
activeTools.add(n);
|
|
154
160
|
}
|
|
155
161
|
if (resume) {
|
|
156
162
|
for (const n of resume.seed.activeTools)
|
|
@@ -129,6 +129,7 @@ export interface PrepareWiringManifestInput {
|
|
|
129
129
|
/** borrowed-readonly — from the file-history phase's one fold of the two off switches: the manifest's word, relayed. */ fileHistoryFact: NonNullable<WiringManifest["fileHistory"]>; /** borrowed-readonly — from the project-context phase: did it call the deployment's seam (the arm's own predicate), relayed. */
|
|
130
130
|
projectMemoryFact: NonNullable<WiringManifest["projectMemory"]>;
|
|
131
131
|
/** borrowed-readonly — from the policy-chain phase: this leg's own session-rule layer published its key for the children's chain (`ownSessionRulesRef.current !== undefined`), relayed as `sessionRules.childrenReadLive`. */ sessionRulesChildrenReadLive: boolean;
|
|
132
|
+
/** borrowed-readonly — the config doors' one reading of the leg's run origin, relayed into `leg` (absent ⇒ the host said nothing). */ runOrigin: NonNullable<WiringManifest["leg"]>["runOrigin"];
|
|
132
133
|
/** borrowed-readonly — the advisor phase's answer, relayed. */ advisorFact?: WiringManifest["advisor"]; /** borrowed-readonly — the config doors' compiled host floor's posture, relayed (absent ⇒ none declared). */
|
|
133
134
|
hostFloorPosture: WiringManifest["hostFloor"];
|
|
134
135
|
/** borrowed-readonly — the arming outcome the caps phase reads live (the manifest's auto-mode face at this leg's start). */
|
|
@@ -117,7 +117,7 @@ function announceDurableGateUnavailable(args) {
|
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
119
|
export function prepareWiringManifest(input) {
|
|
120
|
-
const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, legWriteGuard, mcp, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, lockedPreflight, peerLaneRefs, frameSettlement, sessionBox, harness, pausedRef, askSeat, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture } = input;
|
|
120
|
+
const { spec, deps, internals, resume, sessionId, runId, hostTaskId, taskScope, modBus, standingModBus, checkpointScope, policyLayers, effectivePolicy, handsEnabled, taskRootFinal, legWriteGuard, mcp, irreversibleTools, egressTools, toolEffects, ownedEnv, executionEnv, offloadStore, onceLedger, usageWindows, envLifetimeSuspendAt, runtimeCaps, resolvedInteractionPosture, durableQuestionFace, liveQuestionFace, checkpointStore, sessions, modelGateManifest, autoModeArmReason, permissionMode, lockedPreflight, peerLaneRefs, frameSettlement, sessionBox, harness, pausedRef, askSeat, liveInheritedGate, delegation, toolRoster, readDenyBuiltinTiersActive, lspManagerWired, shellReadStationArmed, crossBoundaryStationEngaged, lspDiagnosticsLive, fileHistoryFact, projectMemoryFact, sessionRulesChildrenReadLive, memoryPollution, advisorFact, hostFloorPosture, runOrigin } = input;
|
|
121
121
|
const onAsk = askSeat.value;
|
|
122
122
|
const handWriteTools = toolRoster.entries.filter((e) => e.mountedBy === "hands" && (e.effect === "write" || e.effect === "idempotent")).map((e) => e.name);
|
|
123
123
|
const hasEffectAwareGate = policyLayers.length > 0 || chainJudges(standingModBus);
|
|
@@ -182,7 +182,7 @@ export function prepareWiringManifest(input) {
|
|
|
182
182
|
const wiringQuestionStripped = internals?.questionFaceStripped === true;
|
|
183
183
|
const wiringManifest = deriveWiringManifest({
|
|
184
184
|
half: "effective",
|
|
185
|
-
leg: resume !== undefined ? "resume" : internals?.isDelegatedChild === true ? "child" : "root",
|
|
185
|
+
leg: resume !== undefined ? "resume" : internals?.isDelegatedChild === true ? "child" : "root", ...(runOrigin !== undefined ? { runOrigin } : {}),
|
|
186
186
|
teamRole: teamRoleOf({ isDelegatedChild: delegation.isDelegatedChild, ...(internals?.explicitAgentName !== undefined ? { spawnName: internals.explicitAgentName } : {}) }),
|
|
187
187
|
...(spec.peerPresence !== undefined ? { peerPresence: spec.peerPresence } : {}),
|
|
188
188
|
askForm: askSeat.form,
|
|
@@ -52,6 +52,9 @@ export interface PrepareWorkspaceRestoreResult {
|
|
|
52
52
|
* spelling of the old root); the identity function when no divergence was armed. Consumers (T7):
|
|
53
53
|
* the readFileState checkpoint seed, the handsCwd seed, the activeWorktree restore. */
|
|
54
54
|
rebaseRestoredPath: (p: string) => string;
|
|
55
|
+
/** owned — the leg's ONE remoteness reading: its paths name locations in a remote / non-host env (read by the
|
|
56
|
+
* observation sink below and the leg's `workspace_changed` frame alike). */
|
|
57
|
+
remote: boolean;
|
|
55
58
|
}
|
|
56
59
|
/** The B-4 phase body — the workspace-restore slice, verbatim (see the module header for the contract). */
|
|
57
60
|
export declare function prepareWorkspaceRestore(input: PrepareWorkspaceRestoreInput): Promise<PrepareWorkspaceRestoreResult>;
|
|
@@ -107,19 +107,19 @@ export async function prepareWorkspaceRestore(input) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
}
|
|
110
|
+
const workspaceEnv = ownedEnv ?? deps.executionEnv;
|
|
111
|
+
const remote = workspaceEnv !== undefined && workspaceEnv !== null && (isRemoteExecutionEnv(workspaceEnv) || workspaceEnv.hostLocalPaths === false);
|
|
110
112
|
if (internals?.onWorkspaceResolved !== undefined) {
|
|
111
113
|
try {
|
|
112
|
-
const workspaceEnv = ownedEnv ?? deps.executionEnv;
|
|
113
114
|
internals.onWorkspaceResolved({
|
|
114
115
|
cwd: taskRootPath,
|
|
115
116
|
isolated: internals.isolation === "worktree",
|
|
116
|
-
remote
|
|
117
|
-
(isRemoteExecutionEnv(workspaceEnv) || workspaceEnv.hostLocalPaths === false),
|
|
117
|
+
remote,
|
|
118
118
|
...(input.placement !== undefined ? { placement: input.placement } : {}),
|
|
119
119
|
});
|
|
120
120
|
}
|
|
121
121
|
catch {
|
|
122
122
|
}
|
|
123
123
|
}
|
|
124
|
-
return { taskRootFinal: taskRootPath, rebaseRestoredPath };
|
|
124
|
+
return { taskRootFinal: taskRootPath, rebaseRestoredPath, remote };
|
|
125
125
|
}
|
|
@@ -49,7 +49,7 @@ export async function resumeAdmission(input) {
|
|
|
49
49
|
const resumeSignal = config.signal;
|
|
50
50
|
let suppliedMessage;
|
|
51
51
|
refuseRetiredModeSeed(cp.state);
|
|
52
|
-
config = refuseResumeDoors(config, cp.state
|
|
52
|
+
config = refuseResumeDoors(config, cp.state, runner.deps, sessions, internals?.holder);
|
|
53
53
|
const parkedSteers = readPendingSteerQueue(cp.state);
|
|
54
54
|
if (outcomeGate === "wake") {
|
|
55
55
|
suppliedMessage = outcome.message;
|
|
@@ -10,6 +10,7 @@ import { chainInstallationGaps, chainInstallationRefusal } from "./child-tree.js
|
|
|
10
10
|
import { screeningInstallationsOf, unraisableGuardsOf } from "../mods/stations.js";
|
|
11
11
|
import { refusePersistedToolNames, refuseRenamedDelegationMounts } from "./sub-agent-deny-lists.js";
|
|
12
12
|
import { asResumeConfigRefusal } from "../mode-policy.js";
|
|
13
|
+
import { screenRecordedRunOrigin } from "../run-origin.js";
|
|
13
14
|
export function resumeCheckpointScreen(input) {
|
|
14
15
|
const { cp, resumeSignal, internals, tools, runner } = input;
|
|
15
16
|
const { realApproval: realApprovalRow, face: faceRow, f012: f012Row } = CHECKPOINT_FEATURES;
|
|
@@ -91,6 +92,7 @@ export function resumeCheckpointScreen(input) {
|
|
|
91
92
|
"(the checkpoint stays pending and is resumable without it).");
|
|
92
93
|
}
|
|
93
94
|
asResumeConfigRefusal("inheritedGate", () => refusePersistedToolNames((internals?.toolCeiling ?? undefined) === undefined ? cp.state.toolCeiling : undefined, cp.state.inheritedGate?.constraintChain, (internals?.ownToolLists ?? undefined) === undefined ? cp.state.ownToolLists : undefined));
|
|
95
|
+
asResumeConfigRefusal("inheritedGate", () => void screenRecordedRunOrigin(cp.state.runOrigin));
|
|
94
96
|
asResumeConfigRefusal("taskConfig", () => refuseRenamedDelegationMounts(tools));
|
|
95
97
|
if (cp.state.inheritedGate?.requiresParentConstraint === true) {
|
|
96
98
|
const supplied = internals?.inheritedGate?.parentConstraints?.length ?? 0;
|
|
@@ -2,14 +2,11 @@ import type { RewindFilesRequest, RewindFilesResult } from "../file-history-stor
|
|
|
2
2
|
import type { SessionStore } from "../session.js";
|
|
3
3
|
import type { RunnerDeps } from "../types.js";
|
|
4
4
|
import type { SessionReadFileStates } from "./session-read-file-states.js";
|
|
5
|
+
import { type SessionLockSeats } from "./session-verb-doors.js";
|
|
5
6
|
/** What the Runner lends the rewind: its current deps, its session store, its read-state seats, and its lock. */
|
|
6
|
-
export interface RewindFilesSeats {
|
|
7
|
+
export interface RewindFilesSeats extends SessionLockSeats {
|
|
7
8
|
deps: RunnerDeps;
|
|
8
9
|
sessions: SessionStore;
|
|
9
10
|
readStates: SessionReadFileStates;
|
|
10
|
-
/** Whether a leg of this Runner holds or awaits `sessionId`'s lock. */
|
|
11
|
-
sessionBusy(sessionId: string): boolean;
|
|
12
|
-
/** Take `sessionId`'s lock; called synchronously after `sessionBusy` answered false, so nothing slips in between. */
|
|
13
|
-
takeSessionLock(sessionId: string): Promise<() => void>;
|
|
14
11
|
}
|
|
15
12
|
export declare function rewindSessionFiles(seats: RewindFilesSeats, request: RewindFilesRequest): Promise<RewindFilesResult>;
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import { types } from "node:util";
|
|
2
|
-
import { isPlainRecord } from "../mods/kernel/receive.js";
|
|
3
1
|
import { hasDestroy } from "../remote-env.js";
|
|
4
|
-
import { readMember } from "../thrown-value.js";
|
|
5
2
|
import { resolveDeploymentFileHistory, storeUnconfiguredRefusal } from "./file-history-request.js";
|
|
6
3
|
import { prepareExecutionEnv } from "./prepare-execution-env.js";
|
|
7
4
|
import { noBoundaryRefusal, settleFileHistoryRestore } from "./file-history-restore.js";
|
|
8
5
|
import { adoptForkedFileHistory, resolveFileHistoryCoordinates } from "./prepare-file-history.js";
|
|
9
6
|
import { createRollbackStack } from "./rollback-stack.js";
|
|
7
|
+
import { acquireExistingSession, claimIdleSession, readPlainRequest, shownValue } from "./session-verb-doors.js";
|
|
10
8
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
11
9
|
const REQUEST_KEYS = new Set(["sessionId", "to", "dryRun", "signal"]);
|
|
12
10
|
export async function rewindSessionFiles(seats, request) {
|
|
@@ -15,12 +13,9 @@ export async function rewindSessionFiles(seats, request) {
|
|
|
15
13
|
const { wiredSeat, fileHistoryStore, captureStore } = resolveDeploymentFileHistory(deps);
|
|
16
14
|
if (fileHistoryStore === undefined)
|
|
17
15
|
throw storeUnconfiguredRefusal(wiredSeat, req.to);
|
|
18
|
-
|
|
19
|
-
throw sessionBusyRefusal(req.sessionId, req.to);
|
|
20
|
-
const lock = seats.takeSessionLock(req.sessionId);
|
|
21
|
-
const release = await lock;
|
|
16
|
+
const release = await claimIdleSession(seats, req.sessionId, () => sessionBusyRefusal(req.sessionId, req.to));
|
|
22
17
|
try {
|
|
23
|
-
const session = await acquireExistingSession(seats.sessions, req.sessionId);
|
|
18
|
+
const session = await acquireExistingSession(seats.sessions, req.sessionId, "Runner.rewindFiles", "nothing was rewound");
|
|
24
19
|
const report = (err) => {
|
|
25
20
|
try {
|
|
26
21
|
deps.onError?.(err, { phase: "config", sessionId: req.sessionId });
|
|
@@ -72,56 +67,19 @@ function screenRewindFilesRequest(request) {
|
|
|
72
67
|
e.code = "rewind.invalid_spec";
|
|
73
68
|
throw e;
|
|
74
69
|
};
|
|
75
|
-
|
|
76
|
-
return bad(`the request must be a plain object, got ${request === null ? "null" : typeof request}`);
|
|
77
|
-
if (types.isProxy(request) || !isPlainRecord(request))
|
|
78
|
-
return bad("the request must be a plain data object (not a Proxy, and with no prototype that could supply a member)");
|
|
79
|
-
let descriptors;
|
|
80
|
-
try {
|
|
81
|
-
descriptors = Object.getOwnPropertyDescriptors(request);
|
|
82
|
-
}
|
|
83
|
-
catch {
|
|
84
|
-
return bad("the request could not be read");
|
|
85
|
-
}
|
|
86
|
-
const keys = Reflect.ownKeys(descriptors);
|
|
87
|
-
const unknown = keys.filter((k) => typeof k !== "string" || !REQUEST_KEYS.has(k));
|
|
88
|
-
if (unknown.length > 0)
|
|
89
|
-
return bad(`unknown key ${unknown.map((k) => JSON.stringify(String(k))).join(", ")}`);
|
|
90
|
-
const read = {};
|
|
91
|
-
for (const k of keys) {
|
|
92
|
-
const d = descriptors[k];
|
|
93
|
-
if (!("value" in d))
|
|
94
|
-
return bad(`member ${JSON.stringify(k)} is an accessor, not a value`);
|
|
95
|
-
read[k] = d.value;
|
|
96
|
-
}
|
|
97
|
-
const { sessionId, to, dryRun, signal } = read;
|
|
70
|
+
const { sessionId, to, dryRun, signal } = readPlainRequest(request, REQUEST_KEYS, bad);
|
|
98
71
|
if (typeof sessionId !== "string" || sessionId === "")
|
|
99
|
-
return bad(`sessionId must be a non-empty string, got ${
|
|
72
|
+
return bad(`sessionId must be a non-empty string, got ${shownValue(sessionId)}`);
|
|
100
73
|
if (typeof to !== "string" || to === "")
|
|
101
|
-
return bad(`to must be a non-empty entry id, got ${
|
|
74
|
+
return bad(`to must be a non-empty entry id, got ${shownValue(to)}`);
|
|
102
75
|
if (dryRun !== undefined && typeof dryRun !== "boolean")
|
|
103
|
-
return bad(`dryRun must be a boolean when given, got ${
|
|
76
|
+
return bad(`dryRun must be a boolean when given, got ${shownValue(dryRun)}`);
|
|
104
77
|
if (signal !== undefined && !(signal instanceof AbortSignal))
|
|
105
|
-
return bad(`signal must be an AbortSignal when given, got ${
|
|
78
|
+
return bad(`signal must be an AbortSignal when given, got ${shownValue(signal)}`);
|
|
106
79
|
return { sessionId, to, dryRun: dryRun === true, signal };
|
|
107
80
|
}
|
|
108
|
-
function shown(v) {
|
|
109
|
-
return typeof v === "string" ? JSON.stringify(v.slice(0, 40)) : v === null || typeof v === "boolean" || typeof v === "number" ? String(v) : `a ${typeof v}`;
|
|
110
|
-
}
|
|
111
|
-
async function acquireExistingSession(sessions, sessionId) {
|
|
112
|
-
try {
|
|
113
|
-
return await sessions.acquire(sessionId, { requireExisting: true });
|
|
114
|
-
}
|
|
115
|
-
catch (err) {
|
|
116
|
-
if (readMember(err, "code") !== "not_found")
|
|
117
|
-
throw err;
|
|
118
|
-
const e = new Error(`Runner.rewindFiles: session "${sessionId}" does not exist — nothing was rewound`);
|
|
119
|
-
e.code = "resume.session_not_found";
|
|
120
|
-
throw e;
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
81
|
function sessionBusyRefusal(sessionId, target) {
|
|
124
|
-
const e = new Error(`Runner.rewindFiles: a task is running or queued on session "${sessionId}" in this Runner — rewinding its files to entry "${target}" now would move them under that
|
|
82
|
+
const e = new Error(`Runner.rewindFiles: a task is running or queued on session "${sessionId}" in this Runner, or a write one of its tasks issued has not settled — rewinding its files to entry "${target}" now would move them under that work, so nothing was rewound; retry once it has ended and its writes have settled`);
|
|
125
83
|
e.code = "rewind.session_busy";
|
|
126
84
|
return e;
|
|
127
85
|
}
|
|
@@ -34,13 +34,12 @@ export interface RunHarnessHandlersResult {
|
|
|
34
34
|
type: "tool_execution_end";
|
|
35
35
|
}>) => void;
|
|
36
36
|
onTurnEnd: () => void;
|
|
37
|
-
/** The
|
|
37
|
+
/** The leg's workspace-frame observation (`Prepared.workspaceFrame.observe`); the run body
|
|
38
38
|
* calls it after a resume's approved-call resolution, which bypasses onToolEnd. */
|
|
39
39
|
announceWorkspaceMove: () => void;
|
|
40
40
|
}
|
|
41
41
|
/** R5 抽取:runLocked 的五个 harness 事件处理器(onMessageUpdate/onMessageEnd/
|
|
42
42
|
* onToolStart/onToolEnd/onTurnEnd,~530 行)整块搬迁。正文逐字;唯一字面变化 = this.deps.onError →
|
|
43
|
-
* deps.runnerHooks.onError(1 处)
|
|
44
|
-
*
|
|
45
|
-
* (中间只有声明无执行)。*/
|
|
43
|
+
* deps.runnerHooks.onError(1 处)。工作区帧的去重状态住在腿的帧座(`Prepared.workspaceFrame`),
|
|
44
|
+
* 工厂体不持有、也不在调用时读 cwd。*/
|
|
46
45
|
export declare function createHarnessHandlers(input: RunHarnessHandlersInput): RunHarnessHandlersResult;
|
|
@@ -33,14 +33,7 @@ export function createHarnessHandlers(input) {
|
|
|
33
33
|
const label = toolLabels.get(e.toolName);
|
|
34
34
|
return { toolCallId: e.toolCallId, spelledName: e.toolName, wireName: rosterToolName(prepared.toolRosterDeltas.current, e.toolName), ...(label !== undefined ? { label } : {}), args: e.args, ...requesterOf(prepared.modBus, e.toolCallId) };
|
|
35
35
|
};
|
|
36
|
-
|
|
37
|
-
const announceWorkspaceMove = () => {
|
|
38
|
-
const cwdNow = prepared.cwdRef?.current;
|
|
39
|
-
if (cwdNow !== undefined && cwdNow !== lastWorkspaceCwd) {
|
|
40
|
-
lastWorkspaceCwd = cwdNow;
|
|
41
|
-
queue.push({ type: "workspace_changed", cwd: cwdNow, ...ident() });
|
|
42
|
-
}
|
|
43
|
-
};
|
|
36
|
+
const announceWorkspaceMove = () => prepared.workspaceFrame.observe();
|
|
44
37
|
const onMessageUpdate = (event) => {
|
|
45
38
|
const ev = event.assistantMessageEvent;
|
|
46
39
|
if (rs.turn.callStartAt === undefined)
|
|
@@ -28,6 +28,7 @@ export function runIdentityWiring(input) {
|
|
|
28
28
|
internalsNotifier.notify(() => observeThenableRejection(internals?.onWiringManifest?.(wiringManifest), internalsNotifier, "runtask.onWiringManifest"), "runtask.onWiringManifest");
|
|
29
29
|
prepared.toolRosterDeltas.subscribe((delta) => queue.push({ type: "tool_roster_delta", delta, ...ident() }));
|
|
30
30
|
prepared.toolDisclosure?.subscribe((snapshot) => queue.push({ type: "tool_disclosure", ...snapshot, ...ident() }));
|
|
31
|
+
prepared.workspaceFrame.subscribe((snapshot) => queue.push({ type: "workspace_changed", ...snapshot, ...ident() }));
|
|
31
32
|
const delegationLifecycleNotifier = createSafeNotifier({
|
|
32
33
|
onError: (f) => console.warn(`[sema-core] ${f.site}: delegation-lifecycle observer threw (contained; further failures counted, not re-disclosed): ${f.error.message}`),
|
|
33
34
|
});
|