@sema-agent/core 7.71.1 → 7.73.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 +500 -0
- package/dist/agents/cross-session-ref.d.ts +2 -2
- package/dist/agents/cross-session-ref.js +7 -2
- package/dist/agents/inherited-tool-pool.d.ts +30 -2
- package/dist/agents/inherited-tool-pool.js +53 -7
- package/dist/agents/parked-resume-drive.d.ts +10 -0
- package/dist/agents/parked-resume-drive.js +9 -0
- package/dist/agents/retain-ledger.d.ts +3 -0
- package/dist/agents/send-message-tool.js +7 -2
- package/dist/agents/send-user-message-tool.d.ts +12 -0
- package/dist/agents/send-user-message-tool.js +67 -0
- package/dist/agents/subagent-steps.d.ts +9 -0
- package/dist/agents/subagent-steps.js +38 -0
- package/dist/agents/subagent.d.ts +2 -0
- package/dist/agents/subagent.js +47 -12
- package/dist/agents/verify.js +23 -7
- package/dist/agents/yield-adoption.js +3 -1
- package/dist/brain/anthropic.js +14 -9
- package/dist/brain/open-responses.js +4 -5
- package/dist/brain/openai.js +30 -23
- package/dist/brain/stream-engine.js +159 -151
- package/dist/core/a2a.d.ts +24 -3
- package/dist/core/a2a.js +27 -8
- package/dist/core/actions-digest.d.ts +43 -0
- package/dist/core/actions-digest.js +22 -0
- package/dist/core/agent-state.d.ts +28 -7
- package/dist/core/agent-state.js +19 -6
- package/dist/core/allow-entry.js +3 -3
- package/dist/core/approval-object.d.ts +7 -3
- package/dist/core/approval-object.js +30 -9
- package/dist/core/auto-mode.d.ts +7 -9
- package/dist/core/auto-mode.js +114 -8
- package/dist/core/checkpoint-features.d.ts +16 -5
- package/dist/core/checkpoint-features.js +35 -6
- package/dist/core/checkpoint-rekey.d.ts +1 -1
- package/dist/core/checkpoint-rekey.js +6 -1
- package/dist/core/checkpoint-requirements.d.ts +23 -3
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -1
- package/dist/core/checkpoint-row-verdict.js +10 -4
- package/dist/core/checkpoint-store.d.ts +24 -2
- package/dist/core/checkpoint-store.js +1 -0
- package/dist/core/child-clamp-seats.d.ts +15 -0
- package/dist/core/child-clamp-seats.js +15 -0
- package/dist/core/delegation-frames.d.ts +1 -0
- package/dist/core/delegation-frames.js +1 -1
- package/dist/core/effective-path-target.d.ts +19 -0
- package/dist/core/effective-path-target.js +95 -38
- package/dist/core/engine-capabilities.d.ts +5 -1
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +34 -23
- package/dist/core/engine-version.js +1 -1
- package/dist/core/entries-not-applied.d.ts +19 -7
- package/dist/core/entries-not-applied.js +33 -1
- package/dist/core/file-history-store.d.ts +15 -4
- package/dist/core/file-history-store.js +53 -23
- package/dist/core/gate-fold.js +3 -1
- package/dist/core/governance-codes.d.ts +10 -1
- package/dist/core/governance-codes.js +17 -5
- package/dist/core/hooks.d.ts +3 -0
- package/dist/core/hooks.js +1 -0
- package/dist/core/host-instance.d.ts +23 -0
- package/dist/core/host-instance.js +69 -0
- package/dist/core/instruction-preview.d.ts +63 -0
- package/dist/core/instruction-preview.js +406 -0
- package/dist/core/judged-read.d.ts +57 -0
- package/dist/core/judged-read.js +1 -0
- package/dist/core/leg-budget.d.ts +26 -0
- package/dist/core/leg-budget.js +9 -0
- package/dist/core/leg-identity.d.ts +51 -1
- package/dist/core/leg-identity.js +45 -2
- package/dist/core/manager-launch-check.d.ts +48 -0
- package/dist/core/manager-launch-check.js +64 -0
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-host-seat.d.ts +5 -0
- package/dist/core/mcp-host-seat.js +7 -1
- package/dist/core/mcp-injection-drop.d.ts +20 -10
- package/dist/core/mcp-injection-drop.js +9 -3
- package/dist/core/mcp-server-spec.d.ts +2 -1
- package/dist/core/mcp.js +3 -1
- package/dist/core/member-outcome.d.ts +3 -2
- package/dist/core/member-outcome.js +1 -1
- package/dist/core/memory-engine/deletion-record.d.ts +46 -0
- package/dist/core/memory-engine/deletion-record.js +96 -0
- package/dist/core/memory-engine/engine.js +24 -16
- package/dist/core/memory-engine/file-backend.js +7 -5
- package/dist/core/memory-engine/index.d.ts +1 -1
- package/dist/core/memory-engine/index.js +1 -1
- package/dist/core/memory-engine/layout.js +6 -4
- package/dist/core/memory-engine/projection-ledger.d.ts +1 -1
- package/dist/core/memory-engine/projection-ledger.js +1 -1
- package/dist/core/memory-engine/scope-contract.d.ts +69 -11
- package/dist/core/memory-engine/scope-contract.js +99 -34
- package/dist/core/memory-engine/sync-client.js +26 -6
- package/dist/core/memory-engine/sync.d.ts +20 -2
- package/dist/core/memory-engine/sync.js +18 -17
- package/dist/core/mode-policy.d.ts +21 -6
- package/dist/core/mode-policy.js +15 -6
- package/dist/core/mounted-mcp.d.ts +7 -2
- package/dist/core/mounted-mcp.js +10 -1
- package/dist/core/own-property-receipt.js +11 -4
- package/dist/core/param-rule-reach.d.ts +8 -3
- package/dist/core/param-rule-reach.js +9 -1
- package/dist/core/parent-spec-seat.d.ts +13 -1
- package/dist/core/parent-spec-seat.js +18 -0
- package/dist/core/peer-registration.d.ts +52 -0
- package/dist/core/peer-registration.js +37 -0
- package/dist/core/peer-seat.d.ts +3 -1
- package/dist/core/peer-seat.js +3 -3
- package/dist/core/peer-task-store.d.ts +365 -0
- package/dist/core/peer-task-store.js +682 -0
- package/dist/core/permission-rule-consent.js +6 -11
- package/dist/core/permission-rule-model.d.ts +27 -0
- package/dist/core/permission-rule-model.js +34 -6
- package/dist/core/permission-rule-provider.d.ts +35 -33
- package/dist/core/permission-rule-provider.js +38 -295
- package/dist/core/permission-rule-store.d.ts +181 -8
- package/dist/core/permission-rule-store.js +420 -17
- package/dist/core/permission-rule-sync.js +15 -1
- package/dist/core/project-seat.d.ts +55 -0
- package/dist/core/project-seat.js +96 -0
- package/dist/core/protocol-http-auth.d.ts +3 -2
- package/dist/core/protocol-http-auth.js +26 -18
- package/dist/core/remote-env.d.ts +4 -4
- package/dist/core/retired-keys.js +1 -0
- package/dist/core/rule-offer-read.d.ts +1 -1
- package/dist/core/rule-offer-read.js +32 -4
- package/dist/core/run-ledger-seat.d.ts +66 -0
- package/dist/core/run-ledger-seat.js +70 -0
- package/dist/core/run-ledger.d.ts +332 -0
- package/dist/core/run-ledger.js +550 -0
- package/dist/core/runner/chain-mismatch.d.ts +32 -0
- package/dist/core/runner/chain-mismatch.js +29 -0
- package/dist/core/runner/changes-history.d.ts +1 -0
- package/dist/core/runner/changes-history.js +2 -2
- package/dist/core/runner/checkpoint-scope.d.ts +13 -3
- package/dist/core/runner/checkpoint-scope.js +12 -4
- package/dist/core/runner/construction-doors.js +6 -0
- package/dist/core/runner/contracts.d.ts +22 -3
- package/dist/core/runner/delegation-owner.d.ts +30 -0
- package/dist/core/runner/delegation-owner.js +20 -4
- package/dist/core/runner/file-history-restore.d.ts +3 -1
- package/dist/core/runner/file-history-restore.js +9 -6
- package/dist/core/runner/finish-reason-seat.js +4 -2
- package/dist/core/runner/leg-frame.js +3 -0
- package/dist/core/runner/loaded-skills.d.ts +2 -0
- package/dist/core/runner/loaded-skills.js +10 -0
- package/dist/core/runner/nested-memory-lane.d.ts +22 -5
- package/dist/core/runner/nested-memory-lane.js +91 -30
- package/dist/core/runner/person-path-rows.d.ts +23 -20
- package/dist/core/runner/person-path-rows.js +82 -18
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +4 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +105 -90
- package/dist/core/runner/prepare-config-doors.d.ts +1 -0
- package/dist/core/runner/prepare-config-doors.js +5 -3
- package/dist/core/runner/prepare-context-lane.js +1 -0
- package/dist/core/runner/prepare-delegation-surface.d.ts +3 -0
- package/dist/core/runner/prepare-delegation-surface.js +6 -0
- package/dist/core/runner/prepare-execution-env.d.ts +3 -3
- package/dist/core/runner/prepare-file-history.js +1 -1
- package/dist/core/runner/prepare-hands-readface.d.ts +10 -2
- package/dist/core/runner/prepare-hands-readface.js +36 -22
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -5
- package/dist/core/runner/prepare-inherited-gate.js +14 -6
- package/dist/core/runner/prepare-memory-engine-session.d.ts +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +2 -2
- package/dist/core/runner/prepare-memory.js +3 -15
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +3 -7
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -0
- package/dist/core/runner/prepare-protocol-tools.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +1 -1
- package/dist/core/runner/prepare-run-refs.js +3 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +6 -2
- package/dist/core/runner/prepare-suspend-saga.js +4 -2
- package/dist/core/runner/prepare-task.js +50 -37
- package/dist/core/runner/prepare-turn-wiring.d.ts +4 -3
- package/dist/core/runner/prepare-turn-wiring.js +2 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +5 -1
- package/dist/core/runner/prepare-wiring-manifest.js +8 -4
- package/dist/core/runner/read-session-changes.js +1 -1
- package/dist/core/runner/resume-apply.js +11 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +8 -7
- package/dist/core/runner/resume-checkpoint-screen.js +7 -6
- package/dist/core/runner/resume-review-outcome.d.ts +3 -0
- package/dist/core/runner/resume-review-outcome.js +24 -1
- package/dist/core/runner/rewind-files.js +3 -2
- package/dist/core/runner/run-harness-handlers.js +3 -0
- package/dist/core/runner/run-identity-wiring.js +3 -2
- package/dist/core/runner/run-leg.js +9 -2
- package/dist/core/runner/run-notification-lane.js +20 -1
- package/dist/core/runner/run-settle-and-teardown.js +21 -12
- package/dist/core/runner/run-stop-and-final-verify.js +6 -0
- package/dist/core/runner/run-telemetry-and-budget-seats.js +1 -1
- package/dist/core/runner/runtask.d.ts +6 -2
- package/dist/core/runner/runtask.js +21 -9
- package/dist/core/runner/shell-env-withheld.d.ts +3 -2
- package/dist/core/runner/shell-env-withheld.js +1 -2
- package/dist/core/runner/stop-tail-notice.d.ts +10 -2
- package/dist/core/runner/stop-tail-notice.js +9 -2
- package/dist/core/runner/stream-settle-backstop.d.ts +1 -0
- package/dist/core/runner/stream-settle-backstop.js +1 -0
- package/dist/core/runner/task-start-doors.js +6 -3
- package/dist/core/runner/terminal-account.d.ts +10 -1
- package/dist/core/runner/terminal-account.js +23 -3
- package/dist/core/runner/tool-face-overlay.d.ts +2 -11
- package/dist/core/runner/tool-face-overlay.js +39 -0
- package/dist/core/runner/trim-stretch.js +7 -2
- package/dist/core/runner/unreadable-person-rows.d.ts +2 -1
- package/dist/core/runner-deps.d.ts +13 -10
- package/dist/core/scheduler.d.ts +47 -7
- package/dist/core/scheduler.js +19 -7
- package/dist/core/secret-env.d.ts +60 -37
- package/dist/core/secret-env.js +45 -48
- package/dist/core/sensitive-path-policy.js +14 -7
- package/dist/core/session-checkout.d.ts +3 -0
- package/dist/core/session-checkout.js +1 -0
- package/dist/core/session-store.d.ts +12 -6
- package/dist/core/session-store.js +26 -6
- package/dist/core/session.d.ts +31 -8
- package/dist/core/shell-read-silence.js +1 -0
- package/dist/core/store-contracts/checkpoint-store-contract.js +17 -0
- package/dist/core/store-contracts/peer-task-store-contract.d.ts +21 -0
- package/dist/core/store-contracts/peer-task-store-contract.js +516 -0
- package/dist/core/store-contracts/session-store-contract.d.ts +15 -2
- package/dist/core/store-contracts/session-store-contract.js +87 -3
- package/dist/core/store-contracts/workflow-journal-store-contract.d.ts +19 -1
- package/dist/core/store-contracts/workflow-journal-store-contract.js +89 -1
- package/dist/core/task-event.d.ts +11 -3
- package/dist/core/task-notification.d.ts +97 -10
- package/dist/core/task-notification.js +129 -5
- package/dist/core/task-registry-shared.d.ts +12 -1
- package/dist/core/task-registry-shared.js +3 -1
- package/dist/core/task-registry-workflow.d.ts +1 -1
- package/dist/core/task-registry-workflow.js +9 -1
- package/dist/core/task-registry.d.ts +39 -2
- package/dist/core/task-registry.js +76 -12
- package/dist/core/task-result.d.ts +13 -0
- package/dist/core/task-spec-members.d.ts +3 -1
- package/dist/core/task-spec-members.js +11 -3
- package/dist/core/task-spec.d.ts +57 -23
- package/dist/core/tool-catalog-entries.js +4 -0
- package/dist/core/tool-face-reader.js +1 -1
- package/dist/core/tool-face.d.ts +7 -0
- package/dist/core/tool-face.js +1 -0
- package/dist/core/tool-mount-facts.d.ts +5 -3
- package/dist/core/tool-mount-facts.js +4 -3
- package/dist/core/tool-mount-plan.d.ts +7 -3
- package/dist/core/tool-mount-plan.js +11 -5
- package/dist/core/tool-mount-static.d.ts +2 -2
- package/dist/core/tool-mount-static.js +28 -14
- package/dist/core/tool-registry.d.ts +33 -1
- package/dist/core/tool-registry.js +33 -0
- package/dist/core/tool-result-store.d.ts +19 -2
- package/dist/core/tool-result-store.js +51 -2
- package/dist/core/tool-roster.d.ts +16 -0
- package/dist/core/tool-roster.js +6 -0
- package/dist/core/tool-spec.d.ts +13 -4
- package/dist/core/tools.d.ts +6 -0
- package/dist/core/tools.js +1 -1
- package/dist/core/user-attachment.d.ts +5 -1
- package/dist/core/user-attachment.js +14 -7
- package/dist/core/wiring-manifest.d.ts +89 -29
- package/dist/core/wiring-manifest.js +44 -4
- package/dist/core/workflow-journal-store.d.ts +53 -10
- package/dist/core/workflow-journal-store.js +27 -4
- package/dist/core/workflow-run-store-contract.js +16 -0
- package/dist/core/workflow-run-store.d.ts +9 -7
- package/dist/core/workflow-run-store.js +4 -1
- package/dist/engine/execution-env/node-execution-env.js +3 -1
- package/dist/engine/harness/messages.d.ts +1 -1
- package/dist/engine/harness/messages.js +2 -1
- package/dist/engine/harness/types.d.ts +24 -1
- package/dist/engine/harness/types.js +10 -0
- package/dist/engine/llm/types.d.ts +5 -7
- package/dist/engine/loop/types.d.ts +2 -0
- package/dist/engine/lsp/node-lsp-manager.js +2 -1
- package/dist/engine/session/import-validate.js +6 -1
- package/dist/engine/session/session.d.ts +15 -2
- package/dist/engine/session/session.js +35 -5
- package/dist/index.d.ts +27 -12
- package/dist/index.js +20 -8
- package/dist/orchestration/run-workflow-tool.js +40 -32
- package/dist/orchestration/workflow-park-adoption.d.ts +51 -12
- package/dist/orchestration/workflow-park-adoption.js +47 -12
- package/dist/orchestration/workflow-stop.d.ts +128 -0
- package/dist/orchestration/workflow-stop.js +156 -0
- package/dist/orchestration/workflow.d.ts +30 -6
- package/dist/orchestration/workflow.js +117 -54
- package/dist/prompts/manager-recipe.d.ts +18 -0
- package/dist/prompts/manager-recipe.js +24 -0
- package/dist/stores/file/adoption/marker.d.ts +2 -27
- package/dist/stores/file/adoption/marker.js +12 -0
- package/dist/stores/file/index.d.ts +1 -1
- package/dist/stores/file/index.js +1 -1
- package/dist/stores/file/permission-rule-store.d.ts +3 -1
- package/dist/stores/file/permission-rule-store.js +0 -1
- package/dist/stores/file/workflow-journal-store.d.ts +16 -3
- package/dist/stores/file/workflow-journal-store.js +93 -5
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/tools/artifact/artifact-tool.js +11 -6
- package/dist/tools/fs/file-read-check.d.ts +45 -11
- package/dist/tools/fs/file-read-check.js +200 -57
- package/dist/tools/fs/file-write-check.js +9 -3
- package/dist/tools/fs/index.d.ts +8 -7
- package/dist/tools/fs/index.js +4 -4
- package/dist/tools/fs/judged-reads.d.ts +51 -0
- package/dist/tools/fs/judged-reads.js +68 -0
- package/dist/tools/fs/read-deny-home.d.ts +1 -1
- package/dist/tools/fs/read-deny-home.js +5 -5
- package/dist/tools/fs/read-deny.d.ts +33 -8
- package/dist/tools/fs/read-deny.js +114 -25
- package/dist/tools/fs/safety.d.ts +12 -1
- package/dist/tools/fs/safety.js +16 -3
- package/dist/tools/fs/shell-read-check.d.ts +25 -5
- package/dist/tools/fs/shell-read-check.js +100 -15
- package/dist/tools/fs/shell-read-establish.d.ts +9 -0
- package/dist/tools/fs/shell-read-establish.js +34 -14
- package/dist/tools/fs/shell-read-judge.d.ts +13 -1
- package/dist/tools/fs/shell-read-judge.js +26 -7
- package/dist/tools/fs/shell-read-plan.d.ts +5 -0
- package/dist/tools/fs/shell-read-write-targets.js +17 -9
- package/dist/tools/scheduler-store-move.d.ts +74 -0
- package/dist/tools/scheduler-store-move.js +103 -0
- package/dist/tools/scheduler-tools.d.ts +43 -29
- package/dist/tools/scheduler-tools.js +161 -118
- package/package.json +2 -2
- package/test/export-surface.snapshot.json +173 -3
- package/wire-changes/answers/core-stores-sql@7.72.0.json +12 -0
- package/wire-changes/answers/core-stores-sql@7.73.0.json +28 -0
- package/wire-changes/answers/core@7.72.0.json +84 -0
- package/wire-changes/answers/core@7.73.0.json +216 -0
- package/wire-changes/answers/mods-kernel@7.72.0.json +7 -0
- package/wire-changes/answers/mods-kernel@7.73.0.json +7 -0
- package/wire-changes/answers/primitives@7.72.0.json +6 -0
- package/wire-changes/answers/primitives@7.73.0.json +12 -0
- package/wire-changes/answers/wiki-gate@7.72.0.json +7 -0
- package/wire-changes/answers/wiki-gate@7.73.0.json +7 -0
- package/wire-changes/core-stores-sql@7.72.0.json +215 -0
- package/wire-changes/core-stores-sql@7.73.0.json +326 -0
- package/wire-changes/core@7.72.0.json +2426 -0
- package/wire-changes/core@7.73.0.json +6480 -0
- package/wire-changes/mods-kernel@7.72.0.json +147 -0
- package/wire-changes/mods-kernel@7.73.0.json +147 -0
- package/wire-changes/primitives@7.72.0.json +143 -0
- package/wire-changes/primitives@7.73.0.json +227 -0
- package/wire-changes/wiki-gate@7.72.0.json +145 -0
- package/wire-changes/wiki-gate@7.73.0.json +145 -0
|
@@ -38,6 +38,7 @@ import { enterConfigDoor, refusalAbout } from "../config-refusal-input.js";
|
|
|
38
38
|
import { callerEntryOrigin, rebindProductEntry, specArmCanBuild } from "./caller-roster.js";
|
|
39
39
|
import { rootAnchorOf } from "../leg-identity.js";
|
|
40
40
|
import { workflowCatalogOfFactory } from "../../orchestration/workflow-catalog.js";
|
|
41
|
+
import { withJudgedReads } from "../../tools/fs/judged-reads.js";
|
|
41
42
|
function assembleParentCaptureState(o, i, ctl, ancestors) {
|
|
42
43
|
const build = (optedOut, indeterminate) => ({
|
|
43
44
|
optedOut: optedOut === true,
|
|
@@ -127,7 +128,11 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
127
128
|
roster.mount(mounted, { source: callerMountSource(mounted), mountedBy: "scenario", ...(t.perTurn === true ? { perTurn: true } : {}) });
|
|
128
129
|
}
|
|
129
130
|
function mountCallerTool(t) {
|
|
130
|
-
const
|
|
131
|
+
const declaresRead = t.pathTarget?.access === "read";
|
|
132
|
+
if (declaresRead)
|
|
133
|
+
(input.judgedReadsSeat.ported ??= new Set()).add(t.name);
|
|
134
|
+
const enrich = declaresRead ? (ctx) => withJudgedReads(enrichSpecToolCtx(ctx), input.judgedReadsSeat) : enrichSpecToolCtx;
|
|
135
|
+
const rebound = rebindProductEntry(t, enrich);
|
|
131
136
|
if (rebound !== undefined)
|
|
132
137
|
return maybeOffload(rebound, t);
|
|
133
138
|
if (!specArmCanBuild(t)) {
|
|
@@ -139,7 +144,7 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
139
144
|
const execute = t.execute, self = callerEntryOrigin(t);
|
|
140
145
|
return maybeOffload(defineTool({
|
|
141
146
|
...t,
|
|
142
|
-
execute: (args, ctx) => execute.call(self, args,
|
|
147
|
+
execute: (args, ctx) => execute.call(self, args, enrich(ctx)),
|
|
143
148
|
}), t);
|
|
144
149
|
}
|
|
145
150
|
const blockedRef = {};
|
|
@@ -224,96 +229,106 @@ export async function prepareCapsAndWorkflow(input) {
|
|
|
224
229
|
return;
|
|
225
230
|
if (permissionMode.receipt().effective !== "auto" || autoModeFace === undefined)
|
|
226
231
|
return;
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
classifierModel
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
const
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
if (userPrompt === undefined) {
|
|
270
|
-
throw new Error("the auto-mode classifier was asked with no assembled question, which this arming builds once per classification");
|
|
271
|
-
}
|
|
272
|
-
const classifierAuth = await askPerModelAuth(spec.getApiKeyAndHeaders, rungModel, spec);
|
|
273
|
-
const request = async (seat, suffix) => {
|
|
274
|
-
const book = paidHere ? sideCallBookRef.book : NOT_BOOKED_HERE;
|
|
275
|
-
if (book === undefined)
|
|
276
|
-
throw new Error("the auto-mode classifier was asked before the run body bound the leg's usage account, which it does before any tool call");
|
|
277
|
-
let replied = false;
|
|
278
|
-
const cut = () => {
|
|
279
|
-
if (!replied)
|
|
280
|
-
book("classifier", rungModel, undefined);
|
|
281
|
-
};
|
|
282
|
-
signal?.addEventListener("abort", cut, { once: true });
|
|
283
|
-
let response;
|
|
284
|
-
try {
|
|
285
|
-
response = await runtime.completeSimple(rungModel, { systemPrompt: classifierSystemPrompt(), messages: [{ role: "user", content: userPrompt + suffix, timestamp: Date.now() }] }, {
|
|
286
|
-
signal,
|
|
287
|
-
maxRetries: AUTO_MODE_CLASSIFIER_MAX_RETRIES,
|
|
288
|
-
...classifierSeatOptions(rungModel, seat),
|
|
289
|
-
...classifierAuth,
|
|
290
|
-
});
|
|
232
|
+
try {
|
|
233
|
+
const am = autoModeFace;
|
|
234
|
+
const classifierSeat = classifierSeatModel({ deps, main: model });
|
|
235
|
+
let classifierModel = classifierSeat.model;
|
|
236
|
+
if ((await derivedRouteFallsBack({ seat: "auto-mode-classifier", derived: classifierModel, primary: model, brain: modelLaneBrainOf(deps), getApiKeyAndHeaders: spec.getApiKeyAndHeaders, onNotice: deps.onNotice, sessionId, runId, onBrokenPairing: autoModeClassifierFallbackOf(am.classifierFallback) === "none" ? "refuse" : "fall_back" })).action === "fall_back") {
|
|
237
|
+
classifierModel = model;
|
|
238
|
+
}
|
|
239
|
+
announceClassifierRoleDefaulted({ onNotice: deps.onNotice, seat: { ...classifierSeat, model: classifierModel }, ...(sessionId !== undefined ? { sessionId } : {}), ...(runId !== undefined ? { runId } : {}) });
|
|
240
|
+
const classifierLaneRule = peerLaneActive && peerSendMessageBuiltIn;
|
|
241
|
+
const table = await readDenyEntries();
|
|
242
|
+
const derivedDenyRules = readDenyClassifierRules(table.entries, table.ruleRows);
|
|
243
|
+
let classifierSystemPromptMemo;
|
|
244
|
+
const classifierSystemPrompt = () => (classifierSystemPromptMemo ??= buildAutoModePrompt({ ...am, derivedDenyRules, ...(classifierLaneRule ? { crossSessionMessagesRule: CROSS_SESSION_CLASSIFIER_RULE } : {}) }));
|
|
245
|
+
const classifierRuntime = brainToRuntime(observingBrain(modelLaneBrainOf(deps), observeSideRequest));
|
|
246
|
+
const runtimeByAccount = new WeakMap();
|
|
247
|
+
const classifierRuntimeFor = (seat) => {
|
|
248
|
+
const account = spendAccountOf(seat);
|
|
249
|
+
if (account === undefined)
|
|
250
|
+
return classifierRuntime;
|
|
251
|
+
let rt = runtimeByAccount.get(account);
|
|
252
|
+
if (rt === undefined)
|
|
253
|
+
runtimeByAccount.set(account, (rt = brainToRuntime(observingBrain(modelLaneBrainOf(meteredDepsOf(deps, account)), observeSideRequest))));
|
|
254
|
+
return rt;
|
|
255
|
+
};
|
|
256
|
+
const classifierRungs = classifierLadderRungs(am.classifierFallback, classifierModel, model);
|
|
257
|
+
const denialTracking = createAutoModeDenialTracker(am.denialLimit);
|
|
258
|
+
const decider = createAutoModeDecider({
|
|
259
|
+
...(am.timeoutMs !== undefined ? { timeoutMs: am.timeoutMs } : {}), ...(am.rateLimitBreakAfter !== undefined ? { rateLimitBreakAfter: am.rateLimitBreakAfter } : {}),
|
|
260
|
+
candidates: classifierRungs.map((m) => m.id),
|
|
261
|
+
onClassified: classifierRoundObserver({ tracer: deps.tracer, onNotice: deps.onNotice, taskId: hostTaskId, seatModelId: classifierModel.id, ...(sessionId !== undefined ? { sessionId } : {}), ...(runId !== undefined ? { runId } : {}) }),
|
|
262
|
+
assemble: async (input) => {
|
|
263
|
+
const ctx = await session.buildContext();
|
|
264
|
+
const known = ctx.messages.filter((m) => !isSyntheticApiErrorMessage(m) && (m.role === "user" || m.role === "assistant" || m.role === "toolResult"));
|
|
265
|
+
return renderAutoModeWindow(known, am.window, { delegated }) + renderAutoModeAction(input);
|
|
266
|
+
},
|
|
267
|
+
classify: async (classifyInput, signal, rung, userPrompt) => {
|
|
268
|
+
const runtime = classifierRuntimeFor(classifyInput.spendSeat);
|
|
269
|
+
const payer = spendAccountOf(classifyInput.spendSeat);
|
|
270
|
+
const paidHere = payer === undefined || payer === meterOf(deps)?.account;
|
|
271
|
+
const rungModel = rung !== undefined ? classifierRungs[rung.index] : undefined;
|
|
272
|
+
if (rung === undefined || rungModel === undefined) {
|
|
273
|
+
throw new Error(`the auto-mode classifier was asked at ladder position ${JSON.stringify(rung?.index)}, which this arming did not build`);
|
|
291
274
|
}
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
signal?.removeEventListener("abort", cut);
|
|
275
|
+
if (userPrompt === undefined) {
|
|
276
|
+
throw new Error("the auto-mode classifier was asked with no assembled question, which this arming builds once per classification");
|
|
295
277
|
}
|
|
296
|
-
|
|
297
|
-
const
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
278
|
+
const classifierAuth = await askPerModelAuth(spec.getApiKeyAndHeaders, rungModel, spec);
|
|
279
|
+
const request = async (seat, suffix) => {
|
|
280
|
+
const book = paidHere ? sideCallBookRef.book : NOT_BOOKED_HERE;
|
|
281
|
+
if (book === undefined)
|
|
282
|
+
throw new Error("the auto-mode classifier was asked before the run body bound the leg's usage account, which it does before any tool call");
|
|
283
|
+
let replied = false;
|
|
284
|
+
const cut = () => {
|
|
285
|
+
if (!replied)
|
|
286
|
+
book("classifier", rungModel, undefined);
|
|
287
|
+
};
|
|
288
|
+
signal?.addEventListener("abort", cut, { once: true });
|
|
289
|
+
let response;
|
|
290
|
+
try {
|
|
291
|
+
response = await runtime.completeSimple(rungModel, { systemPrompt: classifierSystemPrompt(), messages: [{ role: "user", content: userPrompt + suffix, timestamp: Date.now() }] }, {
|
|
292
|
+
signal,
|
|
293
|
+
maxRetries: AUTO_MODE_CLASSIFIER_MAX_RETRIES,
|
|
294
|
+
...classifierSeatOptions(rungModel, seat),
|
|
295
|
+
...classifierAuth,
|
|
296
|
+
});
|
|
297
|
+
}
|
|
298
|
+
finally {
|
|
299
|
+
replied = true;
|
|
300
|
+
signal?.removeEventListener("abort", cut);
|
|
301
|
+
}
|
|
302
|
+
book("classifier", rungModel, response);
|
|
303
|
+
const refused = spendRefusalOf(response);
|
|
304
|
+
if (refused !== undefined)
|
|
305
|
+
throw autoModeSpendRefused(refused.stop.reason);
|
|
306
|
+
const failure = classifierReplyFailure(response);
|
|
307
|
+
if (failure !== undefined)
|
|
308
|
+
throw failure;
|
|
309
|
+
return response;
|
|
310
|
+
};
|
|
311
|
+
let response = await request(classifierRungSeat(rungModel), CLASSIFIER_ATTEMPT_SUFFIX.first);
|
|
312
|
+
if (classifierReplyAsksAgain(response) && signal?.aborted !== true)
|
|
313
|
+
response = await request(CLASSIFIER_THINK_SEAT, CLASSIFIER_ATTEMPT_SUFFIX.reask);
|
|
314
|
+
return classifierReplyVerdictText(response);
|
|
315
|
+
},
|
|
316
|
+
});
|
|
317
|
+
const arming = am.persistArming === true ? mintPersistedArming(am, classifierLaneRule, classifierSystemPrompt(), derivedDenyRules, deps.onError, sessionId) : undefined;
|
|
318
|
+
if (autoModeDeciderRef.current !== undefined)
|
|
319
|
+
return;
|
|
320
|
+
autoModeDeciderRef.current = decider;
|
|
321
|
+
autoModeDenialTrackingRef.current = denialTracking;
|
|
322
|
+
autoModeArmingRef.current = arming;
|
|
323
|
+
}
|
|
324
|
+
catch (e) {
|
|
325
|
+
const err = asThrownError(e);
|
|
326
|
+
const code = err.code;
|
|
327
|
+
const wrapped = new Error(`Auto-mode classifier could not be armed — check RunnerDeps.autoMode and roles.classifier (${err.message}).`, { cause: err });
|
|
328
|
+
if (typeof code === "string")
|
|
329
|
+
wrapped.code = code;
|
|
330
|
+
throw wrapped;
|
|
331
|
+
}
|
|
317
332
|
};
|
|
318
333
|
permissionMode.bindArming({ caps: runtimeCaps, autoFacePresent: autoModeFace !== undefined, capsFaulted: runtimeCapsFaulted, armAuto: armAutoMode, onArmFault: (e) => deps.onError?.(asThrownError(e), { phase: "config", sessionId }) });
|
|
319
334
|
const deploymentWorkflowReady = runnerSelf !== undefined && isSelfOrchestrationActive(spec, deps);
|
|
@@ -284,6 +284,7 @@ type ConfigValueDoorsResult = Pick<PrepareConfigDoorsResult, "toolFaceLists" | "
|
|
|
284
284
|
skills: TaskSpec["skills"];
|
|
285
285
|
projectMemory: TaskSpec["projectMemory"];
|
|
286
286
|
deploymentRoles: RunnerDeps["roles"];
|
|
287
|
+
hostInstance: RunnerDeps["host"];
|
|
287
288
|
taskRoles: TaskSpec["roles"];
|
|
288
289
|
interactionPostureInput: ConfigRefusalInput;
|
|
289
290
|
};
|
|
@@ -5,6 +5,7 @@ import { MICRO_COMPACT_MACHINES } from "../context-edit.js";
|
|
|
5
5
|
import { assertAddOnlySeats } from "../child-clamp-seats.js";
|
|
6
6
|
import { CROSS_BOUNDARY_POSTURES } from "../cross-boundary-taint.js";
|
|
7
7
|
import { compileHostFloor } from "../host-floor.js";
|
|
8
|
+
import { receiveHostInstance } from "../host-instance.js";
|
|
8
9
|
import { assertNoRetiredRunnerDeps } from "./retired-runner-deps.js";
|
|
9
10
|
import { resolveCheckpointStore } from "../checkpoint-store.js";
|
|
10
11
|
import { refuseUncountedOwnModel } from "./own-model-money-door.js";
|
|
@@ -254,6 +255,7 @@ export function configValueDoors(input) {
|
|
|
254
255
|
const startedBy = holderSeatStarterOf(input.leg);
|
|
255
256
|
let deps = input.deps;
|
|
256
257
|
enterConfigDoor("deps", () => assertNoRetiredRunnerDeps(deps));
|
|
258
|
+
const hostInstance = enterConfigDoor("deps", () => receiveHostInstance(deps.host, "RunnerDeps.host"));
|
|
257
259
|
enterConfigDoor("taskConfig", () => assertPrincipalValue(spec.principal));
|
|
258
260
|
enterConfigDoor("taskConfig", () => assertPrincipalIsNotUsageKey(spec.principal));
|
|
259
261
|
enterConfigDoor("taskConfig", () => assertPrincipalValue(spec.isolationScope, "isolationScope"));
|
|
@@ -400,7 +402,7 @@ export function configValueDoors(input) {
|
|
|
400
402
|
enterConfigDoor("taskConfig", () => assertRetentionWords({ ...retention, stores: [{ name: "checkpointStore", store: taskStore }] }));
|
|
401
403
|
const { posture: resolvedInteractionPosture, input: interactionPostureInput } = interactionPostureDoor(spec, input.parentInteractionPosture, deps, input.discloseInteractionPosture);
|
|
402
404
|
enterConfigDoor("taskConfig", () => screenModelRole(spec.modelRole));
|
|
403
|
-
return { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, taskRoles, resolvedInteractionPosture, interactionPostureInput };
|
|
405
|
+
return { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, hostInstance, taskRoles, resolvedInteractionPosture, interactionPostureInput };
|
|
404
406
|
}
|
|
405
407
|
function holderSeatStarterOf(internals) {
|
|
406
408
|
return engineLaneLegOf(internals) ? "engine" : "host";
|
|
@@ -438,9 +440,9 @@ export function prepareConfigDoors(input) {
|
|
|
438
440
|
}
|
|
439
441
|
};
|
|
440
442
|
const tellFastTier = input.refusalSink !== undefined ? fastTierNoticeTo(input.refusalSink, callerSpec.sessionId ?? "(pre-session)") : undefined;
|
|
441
|
-
const { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, taskRoles, resolvedInteractionPosture, interactionPostureInput } = configValueDoors({ spec: callerSpec, deps: input.deps, resumeLeg: resume !== undefined, sessions, leg: internals, parentInteractionPosture: internals?.parentInteractionPosture, discloseInteractionPosture: discloseInteractionPostureRefusal, ...(tellFastTier !== undefined ? { tellFastTier } : {}), receivedPeers: input.receipt, ...(resume !== undefined ? { resumedRow: { recorded: screenRecordedRunOrigin(resume.seed.runOrigin), ...(resume.opening !== undefined ? { opening: resume.opening } : {}) } } : {}) });
|
|
443
|
+
const { toolFaceLists, promptHost, promptBinding, promptLocale, promptLean, lockedPreflight, skillListingSeats, skills, projectMemory, microCompactKnob, memoryDelegationEvidence, memoryProvenance, memoryCapturePolicy, usageWindows, brainCallGuardrailMs, crossBoundaryPosture, advisorTool, hostFloor, runOrigin, nestedMemory, deploymentRoles, hostInstance, taskRoles, resolvedInteractionPosture, interactionPostureInput } = configValueDoors({ spec: callerSpec, deps: input.deps, resumeLeg: resume !== undefined, sessions, leg: internals, parentInteractionPosture: internals?.parentInteractionPosture, discloseInteractionPosture: discloseInteractionPostureRefusal, ...(tellFastTier !== undefined ? { tellFastTier } : {}), receivedPeers: input.receipt, ...(resume !== undefined ? { resumedRow: { recorded: screenRecordedRunOrigin(resume.seed.runOrigin), ...(resume.opening !== undefined ? { opening: resume.opening } : {}) } } : {}) });
|
|
442
444
|
const doorRead = (value) => ({ value, enumerable: value !== undefined, writable: false, configurable: false });
|
|
443
|
-
const deps = deploymentRoles !== undefined ? { ...input.deps, roles: deploymentRoles } : input.deps;
|
|
445
|
+
const deps = deploymentRoles !== undefined || hostInstance !== undefined ? { ...input.deps, ...(deploymentRoles !== undefined ? { roles: deploymentRoles } : {}), ...(hostInstance !== undefined ? { host: hostInstance } : {}) } : input.deps;
|
|
444
446
|
const declaredDurableApproval = callerSpec.durableApproval;
|
|
445
447
|
const hostApprovalParksNotResumable = declaredDurableApproval === false;
|
|
446
448
|
let spec = Object.create(Object.getPrototypeOf(callerSpec), { ...Object.getOwnPropertyDescriptors(callerSpec), skills: doorRead(skills), projectMemory: doorRead(projectMemory), runOrigin: doorRead(runOrigin), durableApproval: doorRead(hostApprovalParksNotResumable ? undefined : declaredDurableApproval), ...(taskRoles !== undefined ? { roles: doorRead(taskRoles) } : {}) });
|
|
@@ -267,6 +267,7 @@ export function prepareContextLane(input) {
|
|
|
267
267
|
turnSnapshotRef.current?.declare({ cause: "history_rewrite" });
|
|
268
268
|
pointedBefore = pointedNow;
|
|
269
269
|
await clearedResults.record(microCompact.ledger);
|
|
270
|
+
await microCompact.offloadPersist?.flush(signal);
|
|
270
271
|
return { messages: trimmed, ...(chain.partial ? { trimmedRequestTokens: overheadTokens + sentRows } : {}) };
|
|
271
272
|
}
|
|
272
273
|
finally {
|
|
@@ -131,6 +131,9 @@ export interface PrepareDelegationSurfaceInput {
|
|
|
131
131
|
* reads it through its one reader `currentCheckoutOf`). The worktree mount seeds `current` here and hands THIS object to
|
|
132
132
|
* the tools — a copy would strand their writes from every write-root reader. */
|
|
133
133
|
worktreeSeat: WorktreeSessionRef;
|
|
134
|
+
/** borrowed-readonly — the run's member ledger seats (`TaskSpec.runLedger`): the book and the session recorder the report tool
|
|
135
|
+
* delivers through; undefined on a run without a ledger (the report tool's row does not hold there). */
|
|
136
|
+
runLedger?: import("../../agents/send-user-message-tool.js").SendUserMessageSeats | undefined;
|
|
134
137
|
}
|
|
135
138
|
export interface PrepareDelegationSurfaceResult {
|
|
136
139
|
/** owned — whether the delegation door is open (TaskStop / AgentTranscript ride it). */
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createAgentTranscriptTool } from "../../agents/agent-transcript-tool.js";
|
|
2
2
|
import { createSendMessageTool, SEND_MESSAGE_TOOL_NAME } from "../../agents/send-message-tool.js";
|
|
3
|
+
import { createSendUserMessageTool } from "../../agents/send-user-message-tool.js";
|
|
3
4
|
import { listAgentsMountable, mountListAgents, peerDrainLanesOf, peerLaneSendMessageSeats, principalInboxSeatRefusal } from "../../agents/peer-session-drain.js";
|
|
4
5
|
import { resolvePeerLaneConfig } from "../../agents/peer-admission.js";
|
|
5
6
|
import { createReadInboxTool, READ_INBOX_TOOL_NAME } from "../../agents/read-inbox-tool.js";
|
|
@@ -99,6 +100,11 @@ export function prepareDelegationSurface(input) {
|
|
|
99
100
|
if (listAgents !== undefined)
|
|
100
101
|
roster.mount(firstPartyOffload(listAgents), { source: "builtin", mountedBy: "peerLane" });
|
|
101
102
|
}
|
|
103
|
+
if (roster.mounts.judge("send-user-message")) {
|
|
104
|
+
if (input.runLedger === undefined)
|
|
105
|
+
throw Object.assign(new Error("the report tool's row holds but this leg has no member ledger book"), { code: "internal.tool_mount_plan_mismatch" });
|
|
106
|
+
roster.mount(createSendUserMessageTool(input.runLedger), { source: "builtin", mountedBy: "optional" });
|
|
107
|
+
}
|
|
102
108
|
if (roster.mounts.judge("monitor")) {
|
|
103
109
|
roster.mount(firstPartyOffload(createMonitorTool(executionEnv, {
|
|
104
110
|
registry: defaultTaskRegistry,
|
|
@@ -84,9 +84,9 @@ export type FactoryAsk = "ask" | "not_needed" | "not_answered";
|
|
|
84
84
|
/**
|
|
85
85
|
* Whether THIS acquisition asks the deployment's factory — the one judgment of it, read on a deployment that has a factory
|
|
86
86
|
* (a Runner with none has nothing to ask; the env fold is its answer, whatever the purpose):
|
|
87
|
-
* · `"not_answered"` — the purpose is `"read_changes"`
|
|
88
|
-
* (`RunnerDeps.executionEnvFactoryHonorsReadChanges` is not `true`): no hands — the
|
|
89
|
-
* not where the session's runs work), no cwd door, the factory not called;
|
|
87
|
+
* · `"not_answered"` — the purpose is `"read_changes"` (read-only out-of-run reads: `readSessionChanges`, `previewInstructions`) and the
|
|
88
|
+
* deployment does not state its factory answers it (`RunnerDeps.executionEnvFactoryHonorsReadChanges` is not `true`): no hands — the
|
|
89
|
+
* no-I/O stub, never the static env (it is not where the session's runs work), no cwd door, the factory not called;
|
|
90
90
|
* · `"not_needed"` — the leg needs no environment (`startsEnv` false): the factory is not asked and the fold stands (a static
|
|
91
91
|
* env, else the stub);
|
|
92
92
|
* · `"ask"` — the factory is called.
|
|
@@ -82,7 +82,7 @@ export async function prepareFileHistory(input) {
|
|
|
82
82
|
throw own.refused ?? unaddressedRewindRefusal(sessionId, rewindTarget);
|
|
83
83
|
await refuseTargetOutsideOwnLog(session, sessionId, rewindTarget, rewindBefore ? "before" : "restore");
|
|
84
84
|
refuseRestoreOnForkWithOwnTree(forkWithOwnTree, sessionId, rewindTarget, rewindBefore ? "before" : "restore");
|
|
85
|
-
const restored = await settleFileHistoryRestore({ store: fileHistoryStore, sessionId, scope: own.scope, target: rewindTarget, before: rewindBefore, env: executionEnv, root: historyRoot, signal: restoreSignal, readStates: internals?.sessionReadStates, options: request.restoreOptions, wholeOrNothing: spec.acceptPartialRestore !== true, ...(input.rewindOutcome !== undefined ? { outcome: input.rewindOutcome } : {}) });
|
|
85
|
+
const restored = await settleFileHistoryRestore({ store: fileHistoryStore, sessionId, scope: own.scope, target: rewindTarget, before: rewindBefore, env: executionEnv, root: historyRoot, signal: restoreSignal, readStates: internals?.sessionReadStates, options: request.restoreOptions, wholeOrNothing: spec.acceptPartialRestore !== true, ...(row !== undefined && row.origin !== undefined && row.origin !== sessionId ? { forkedSession: true } : {}), ...(input.rewindOutcome !== undefined ? { outcome: input.rewindOutcome } : {}) });
|
|
86
86
|
tellLeftAsIs({ restored, target: rewindTarget, scope: own.scope, sessionId, rewindNotes, onceLedger, onNotice: deps.onNotice });
|
|
87
87
|
const outsideRoot = restoreOutsideRootNote(restored, rewindTarget);
|
|
88
88
|
if (outsideRoot !== undefined)
|
|
@@ -6,6 +6,7 @@ import type { HeadLeads } from "../path-rule-binding.js";
|
|
|
6
6
|
import { type ShellReadAdmission, type ShellReadCheck, type ShellReadLandings } from "../../tools/fs/shell-read-check.js";
|
|
7
7
|
import { type ReadFloorSeat } from "../../tools/fs/read-floor.js";
|
|
8
8
|
import type { CommandSandboxSeat } from "../command-sandbox.js";
|
|
9
|
+
import type { JudgedReadsSeat } from "../../tools/fs/judged-reads.js";
|
|
9
10
|
import type { ShellReadBoundary } from "../../tools/fs/shell-read-judge.js";
|
|
10
11
|
import { type SeenFiles } from "../existing-target.js";
|
|
11
12
|
import type { RunnerDeps, ShellGateDoctrine, TaskSpec } from "../types.js";
|
|
@@ -16,7 +17,7 @@ import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
|
16
17
|
import type { DeclaredRoot } from "./nested-memory-lane.js";
|
|
17
18
|
import { type ArtifactStoreRef, type GrantReadRoot } from "./read-root-grant.js";
|
|
18
19
|
import type { StoredSession } from "../session.js";
|
|
19
|
-
import type { IrreversibilityTier, PrepareResume, ReversibilityProbes, RunInternals, ToolFaceSnapshot, ToolProgressLane, WriteFaceSeat } from "./contracts.js";
|
|
20
|
+
import type { CarriedFaces, IrreversibilityTier, PrepareResume, ReversibilityProbes, RunInternals, ToolFaceSnapshot, ToolProgressLane, WriteFaceSeat } from "./contracts.js";
|
|
20
21
|
import type { ToolOccurrenceTable } from "./tool-occurrence.js";
|
|
21
22
|
import { RosterBuilder } from "../tool-roster.js";
|
|
22
23
|
import type { PermissionMode } from "../ask-origin.js";
|
|
@@ -27,6 +28,8 @@ import type { PermissionMode } from "../ask-origin.js";
|
|
|
27
28
|
* phase; prepare-task.ts keeps a re-export so the existing import sites stand. */
|
|
28
29
|
export declare function __resetReadFaceClampAnnouncement(): void;
|
|
29
30
|
export interface PrepareHandsReadFaceInput {
|
|
31
|
+
/** borrowed-readonly — the leg's judged-read port seat: which tools read through the port (`ported`); absent ⇒ none does. */
|
|
32
|
+
judgedReadsSeat?: JudgedReadsSeat;
|
|
30
33
|
/** owned (value) — `ownedEnv !== undefined || deps.executionEnv !== undefined`, computed in the
|
|
31
34
|
* driver: the phase's own branch condition (hands mount vs the hands-less resolver arm). */
|
|
32
35
|
handsEnabled: boolean;
|
|
@@ -114,7 +117,7 @@ export interface PrepareHandsReadFaceInput {
|
|
|
114
117
|
/** borrowed-readonly — the task-spec seats this phase reads, as a Pick over the SAME spec object
|
|
115
118
|
* (R-4). `tools` feeds only the band shadow check; `envFacts` only the advertised scratchpad; `planFile` only the
|
|
116
119
|
* advertised session plan file; `retainBackgroundProcesses` only the band's retain lane (Bash's lifetime sentence + row stamp). */
|
|
117
|
-
spec: Pick<TaskSpec, "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "planFile" | "handsReadOnly" | "blockReadsOutsideRoots" | "readDenyPatterns" | "readFace" | "writeFace" | "oneShot" | "resumeAt" | "retainBackgroundProcesses" | "sessionId" | "tools">;
|
|
120
|
+
spec: Pick<TaskSpec, "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "planFile" | "handsReadOnly" | "ownHandsReadOnly" | "blockReadsOutsideRoots" | "readDenyPatterns" | "readFace" | "writeFace" | "oneShot" | "resumeAt" | "retainBackgroundProcesses" | "sessionId" | "tools">;
|
|
118
121
|
/** borrowed-readonly — the deployment seats this phase reads, as a Pick over the SAME deps
|
|
119
122
|
* object (R-4: `deps.onError?.()` keeps its receiver; a new deps read must widen this Pick).
|
|
120
123
|
* `readDenyBuiltinTiers`/`readDenyBuiltinExclude` are SNAPSHOTTED before the first await that
|
|
@@ -259,6 +262,8 @@ export interface PrepareHandsReadFaceResult {
|
|
|
259
262
|
* (an out-of-root Read / Grep / Glob target is a question) and the file write tools' (a target their fence refuses is refused).
|
|
260
263
|
* ⇔ hands with a real shell, or hands with an approval face, or the write half. */
|
|
261
264
|
shellReadCheck: ShellReadCheck | undefined;
|
|
265
|
+
/** owned — the file read station's judged-read port per call (`ToolExecuteContext.judgedReads`); absent ⇔ no file read station. */
|
|
266
|
+
judgedReadsOf: ((toolCallId: string) => readonly import("../judged-read.js").JudgedRead[] | undefined) | undefined;
|
|
262
267
|
/** owned — the shell read station is mounted (⇔ a real shell): the wiring manifest's cell. */
|
|
263
268
|
shellReadStationArmed: boolean;
|
|
264
269
|
/** owned — the same station's pre-spawn ADMISSION, published for the P11 face that spawns a shell command
|
|
@@ -288,6 +293,9 @@ export interface PrepareHandsReadFaceResult {
|
|
|
288
293
|
/** write-back — the hands-LESS legs' write face in force (the posture is a property of the RUN, not the mount): the
|
|
289
294
|
* delegation carriers and the checkpoint mint read it on every leg. */
|
|
290
295
|
handsLessResolvedWriteFace: WriteFaceSeat | undefined;
|
|
296
|
+
/** write-back — a leg that narrowed only its OWN hands (`TaskSpec.ownHandsReadOnly`): the two faces its children are handed,
|
|
297
|
+
* resolved without that narrowing ({@link carriedFacesOf}); absent on every other leg (its children are handed its own faces). */
|
|
298
|
+
carriedFaces: CarriedFaces | undefined;
|
|
291
299
|
/** write-back (D-3 hold) — the NORMALIZED deny-set additions in force (deployment ∪ task ∪
|
|
292
300
|
* resume-seed; zero-builtin compile — the persisted/carrier form, never the judged union's
|
|
293
301
|
* post-dedup remainder). Driver assigns onto its outer `let`. */
|
|
@@ -8,7 +8,7 @@ import { EMPTY_READ_ROOTS, afterCallTables, boundaryRowsOver, denySeatsOf, onNew
|
|
|
8
8
|
import { bindRetiredReads, createShellOverflowSpoolFence } from "../../tools/fs/fs-shared.js";
|
|
9
9
|
import { createShellReadStation } from "../../tools/fs/shell-read-check.js";
|
|
10
10
|
import { judgeReadFloorKept, readFloorSeat } from "../../tools/fs/read-floor.js";
|
|
11
|
-
import { createFileReadStation, outsideReadDisposition } from "../../tools/fs/file-read-check.js";
|
|
11
|
+
import { createFileReadStation, outsideReadDisposition, unjudgedReadsMember } from "../../tools/fs/file-read-check.js";
|
|
12
12
|
import { createFileWriteStation } from "../../tools/fs/file-write-check.js";
|
|
13
13
|
import { readBlockLeg, readBlockOf } from "./read-block-judge.js";
|
|
14
14
|
import { isShellFaceToolName, readTargetToolNames, writeTargetToolNames } from "../tool-registry.js";
|
|
@@ -22,7 +22,7 @@ import { redeemSessionReadRoot } from "../permission-rule-consent.js";
|
|
|
22
22
|
import { legReadCarrier, readSeatLeaf, sessionLogWhole } from "./session-read-file-states.js";
|
|
23
23
|
import { rebaseWorkspacePath } from "./workspace-path.js";
|
|
24
24
|
import { RosterBuilder, survivorsByName } from "../tool-roster.js";
|
|
25
|
-
import { unionAddOnly } from "../child-clamp-seats.js";
|
|
25
|
+
import { handsReadOnlyCarried, unionAddOnly } from "../child-clamp-seats.js";
|
|
26
26
|
import { assertStringArraySeat, screenReadDenySeat } from "../read-face-seats.js";
|
|
27
27
|
import { modePolicyOf } from "../mode-policy.js";
|
|
28
28
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
@@ -54,6 +54,15 @@ function writeFaceReader(input, onDeploymentClamp) {
|
|
|
54
54
|
const faceUnder = (modeFace) => resolveContainmentFace({ ...seats, specFace: folded(spec.writeFace), depsFace: folded(deps.writeFace), ...(modeFace !== undefined ? { modeFace } : {}) });
|
|
55
55
|
return { inForce: () => faceUnder(modePolicyOf(permissionMode.current).writeFace), fenced: faceUnder("open") === "roots" };
|
|
56
56
|
}
|
|
57
|
+
function carriedFacesOf(input, readBlock) {
|
|
58
|
+
const { spec, deps, resume, fullShellReachable } = input;
|
|
59
|
+
if (spec.ownHandsReadOnly !== true)
|
|
60
|
+
return undefined;
|
|
61
|
+
const handed = { ...spec, handsReadOnly: handsReadOnlyCarried(spec) };
|
|
62
|
+
const live = resolveContainmentFace({ kind: "read", specFace: spec.readFace, depsFace: deps.readFace, readOnlyMount: handed.handsReadOnly === true, readBlock, orgGoverned: deps.permissionRuleStore?.partitions.org === true, fullShellReachable });
|
|
63
|
+
const seed = resume?.seed.readFace;
|
|
64
|
+
return { read: resume !== undefined && (seed === undefined || seed.face === "roots") ? "roots" : live, write: writeFaceReader({ ...input, spec: handed }) };
|
|
65
|
+
}
|
|
57
66
|
const FLOOR_NEVER_UNKEPT = Object.freeze({ current: false, judged: false });
|
|
58
67
|
export function resolveHandsLessReadFace(input) {
|
|
59
68
|
const { resume, fullShellReachable, spec, deps } = input;
|
|
@@ -92,7 +101,8 @@ export function resolveHandsLessReadFace(input) {
|
|
|
92
101
|
wsSnapshot: undefined,
|
|
93
102
|
rebaseWsPath: (p) => p,
|
|
94
103
|
backgroundTaskToolsActive: false,
|
|
95
|
-
shellReadCheck:
|
|
104
|
+
shellReadCheck: unjudgedReadsMember((name) => input.judgedReadsSeat?.ported?.has(name) === true).check,
|
|
105
|
+
judgedReadsOf: undefined,
|
|
96
106
|
shellReadStationArmed: false,
|
|
97
107
|
shellReadAdmission: undefined,
|
|
98
108
|
runReadFloor: undefined,
|
|
@@ -108,6 +118,7 @@ export function resolveHandsLessReadFace(input) {
|
|
|
108
118
|
readFloorUnkept: FLOOR_NEVER_UNKEPT,
|
|
109
119
|
handsLessResolvedFace,
|
|
110
120
|
handsLessResolvedWriteFace,
|
|
121
|
+
carriedFaces: carriedFacesOf(input, readBlock),
|
|
111
122
|
additionalRootsCanonical: [],
|
|
112
123
|
commandWriteRootsCanonical: [],
|
|
113
124
|
declaredAdditionalRoots: [],
|
|
@@ -144,6 +155,7 @@ export async function prepareHandsMount(input) {
|
|
|
144
155
|
let runReadFloor;
|
|
145
156
|
let shellReadTools = new Set();
|
|
146
157
|
let fileReadStation;
|
|
158
|
+
let fileToolAdmission;
|
|
147
159
|
let readBlockJudge;
|
|
148
160
|
let fileWriteStation;
|
|
149
161
|
let resolvedReadFace;
|
|
@@ -392,23 +404,23 @@ export async function prepareHandsMount(input) {
|
|
|
392
404
|
});
|
|
393
405
|
}
|
|
394
406
|
const outsideReads = outsideReadDisposition({ readOnlyMount: handsReadOnly, readBlock });
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
407
|
+
const bgOutputExempt = backgroundOutputReadExemption(defaultTaskRegistry, { taskOwner: hostTaskId, taskScope, ...(sessionId !== undefined ? { sessionId } : {}), occupant: input.legOccupant }, executionEnv);
|
|
408
|
+
fileReadStation = createFileReadStation({
|
|
409
|
+
outsideReads,
|
|
410
|
+
env: executionEnv,
|
|
411
|
+
rootCanonical,
|
|
412
|
+
roots: readRoots,
|
|
413
|
+
readDeny: tables.readDeny,
|
|
414
|
+
...(liveReadFace !== undefined ? { readFace: liveReadFace } : {}),
|
|
415
|
+
...("homeDir" in executionEnv && executionEnv.homeDir !== undefined ? { homeDir: executionEnv.homeDir } : {}),
|
|
416
|
+
tools: outsideReads === "tool_fence" ? new Set() : readTargetToolNames(),
|
|
417
|
+
excluded: (key) => artifactStoreRef.current !== undefined && rootAdmittingArtifactStore(artifactStoreRef.current, [key]) !== undefined,
|
|
418
|
+
exempt: (key) => bgOutputExempt?.(key) === true,
|
|
419
|
+
});
|
|
420
|
+
if (outsideReads === "refusal")
|
|
421
|
+
readBlockJudge = onNewestRead(input.personRows, fileReadStation);
|
|
422
|
+
if (outsideReads !== "tool_fence")
|
|
423
|
+
fileToolAdmission = fileReadStation.admitted;
|
|
412
424
|
const writeContainmentSeat = {};
|
|
413
425
|
const valveLeft = valveLeaves(toolFaceSnapshot.selector);
|
|
414
426
|
const band = createHandsToolkit(executionEnv, readFileState, rootCanonical, {
|
|
@@ -430,7 +442,7 @@ export async function prepareHandsMount(input) {
|
|
|
430
442
|
readOnly: handsReadOnly,
|
|
431
443
|
...(shellReadStation !== undefined ? { shellReadAdmission: shellReadStation.admit } : {}),
|
|
432
444
|
...(input.commandSandbox !== undefined ? { commandSandbox: input.commandSandbox } : {}),
|
|
433
|
-
...(
|
|
445
|
+
...(fileToolAdmission !== undefined ? { readAdmission: fileToolAdmission } : {}),
|
|
434
446
|
...(handsCwdRef ? { cwdRef: handsCwdRef } : {}),
|
|
435
447
|
taskRegistry: defaultTaskRegistry,
|
|
436
448
|
taskOwner: hostTaskId,
|
|
@@ -521,17 +533,19 @@ export async function prepareHandsMount(input) {
|
|
|
521
533
|
rebaseWsPath,
|
|
522
534
|
backgroundTaskToolsActive,
|
|
523
535
|
shellReadCheck: onPinnedRead(input.personRows, [...(shellReadStation !== undefined ? [{ check: shellReadStation.check, tools: shellReadTools }] : []), ...(fileReadStation !== undefined ? [fileReadStation] : []), ...(fileWriteStation !== undefined ? [fileWriteStation] : [])]),
|
|
536
|
+
judgedReadsOf: fileReadStation?.judgedReadsOf,
|
|
524
537
|
shellReadStationArmed: shellReadStation !== undefined,
|
|
525
538
|
shellReadAdmission: shellReadStation?.admit,
|
|
526
539
|
runReadFloor,
|
|
527
540
|
shellReadLandings: shellReadStation?.landings,
|
|
528
|
-
readAdmission:
|
|
541
|
+
readAdmission: fileToolAdmission,
|
|
529
542
|
readBlock,
|
|
530
543
|
readBlockJudge,
|
|
531
544
|
outsideReadRemedy,
|
|
532
545
|
resolvedReadFace,
|
|
533
546
|
resolvedWriteFace,
|
|
534
547
|
handsLessResolvedWriteFace,
|
|
548
|
+
carriedFaces: carriedFacesOf(input, readBlock),
|
|
535
549
|
readDenyAdditionsNormalized,
|
|
536
550
|
readDenyBuiltinTiersActive,
|
|
537
551
|
readFloorUnkept,
|
|
@@ -52,7 +52,7 @@ import type { PathRuleBases } from "../permission-rule-model.js";
|
|
|
52
52
|
import type { PermissionMode, RunnerDeps, RuntimeCaps, ShellGateDoctrine, TaskEvent, TaskSpec, ToolExecuteContext, ToolSpec } from "../types.js";
|
|
53
53
|
import { PermissionModeController } from "../mode-policy.js";
|
|
54
54
|
import { type SkillGrantTable } from "../skill-grant.js";
|
|
55
|
-
import type { InheritedGate, Prepared, PrepareResume, RunInternals, StopForDenialLimit, ToolFaceSnapshot, WriteFaceSeat } from "./contracts.js";
|
|
55
|
+
import type { CarriedFaces, InheritedGate, Prepared, PrepareResume, RunInternals, StopForDenialLimit, ToolFaceSnapshot, WriteFaceSeat } from "./contracts.js";
|
|
56
56
|
import type { RosterSpec } from "./caller-roster.js";
|
|
57
57
|
import type { DelegationSettlementSeat } from "../tool-spec.js";
|
|
58
58
|
import type { ToolMountFacts } from "../tool-mount-facts.js";
|
|
@@ -62,7 +62,7 @@ export interface PrepareInheritedGateInput {
|
|
|
62
62
|
* / `oneShot` / `clientContext` / `principal` / `additionalDirectories` / `additionalReadDirectories` / `envFacts` /
|
|
63
63
|
* `memoryPersistenceCapable` / `getApiKeyAndHeaders` / `backgroundScope` / `enablePlanMode` (the ctx enrichment's
|
|
64
64
|
* trusted seats). Never mutated. */
|
|
65
|
-
spec: Pick<RosterSpec, "durableApproval"> & Pick<TaskSpec, "shellGate" | "onQuestion" | "handsReadOnly" | "interactiveTools" | "oneShot" | "clientContext" | "principal" | "isolationScope" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "getApiKeyAndHeaders" | "backgroundScope" | "enablePlanMode">;
|
|
65
|
+
spec: Pick<RosterSpec, "durableApproval"> & Pick<TaskSpec, "shellGate" | "onQuestion" | "handsReadOnly" | "ownHandsReadOnly" | "interactiveTools" | "oneShot" | "clientContext" | "principal" | "isolationScope" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "getApiKeyAndHeaders" | "backgroundScope" | "enablePlanMode">;
|
|
66
66
|
/** borrowed-readonly — the seat this run hands its children (`checkpointSeatOf`, minted once by the driver after the config doors): the ctx's `checkpointStoreForChildren`, absent when the run has no seat. */
|
|
67
67
|
checkpointSeat: import("../checkpoint-seat.js").CheckpointSeat | undefined;
|
|
68
68
|
/** borrowed-readonly — the command sandbox requirement this run runs under (a resumed leg's: the parked one as a floor under the
|
|
@@ -96,7 +96,7 @@ export interface PrepareInheritedGateInput {
|
|
|
96
96
|
/** borrowed-readonly — the trusted spawn-side channel: `inheritedGate` (the LIVE half of the chain fold), `ownOrgAdmissionRef`
|
|
97
97
|
* (the same-session continuation's freeze), `delegationProvenance` (the F-012 stamp), and the identity / peer / notification
|
|
98
98
|
* seats the ctx enrichment forwards. Never mutated. */
|
|
99
|
-
internals: Pick<RunInternals, "inheritedGate" | "isDelegatedChild" | "observerLeg" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "rootSessionIncarnation" | "rootSessionScope" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "onSubtreeActivity" | "insideFork" | "questionFaceStripped"> | undefined;
|
|
99
|
+
internals: Pick<RunInternals, "inheritedGate" | "isDelegatedChild" | "observerLeg" | "sessionModeSeats" | "ownOrgAdmissionRef" | "delegationProvenance" | "memoryCaptureAncestors" | "parentTaskId" | "parentSessionId" | "rootSessionId" | "rootSessionIncarnation" | "rootSessionScope" | "placementRoot" | "explicitAgentName" | "peerSelfRef" | "peerInboundChainRef" | "onTaskNotification" | "onSubagentSpawn" | "onSubtreeActivity" | "insideFork" | "questionFaceStripped" | "runLedgerBook"> | undefined;
|
|
100
100
|
/** borrowed-readonly — the resume leg, or undefined on a fresh one: `seed.inheritedGate` is the CHECKPOINT half of the chain
|
|
101
101
|
* fold (the trust floor the live half may only tighten), `seed.readFace` the hands-less re-park's carried section. */
|
|
102
102
|
resume: Pick<PrepareResume, "seed" | "outcome"> | undefined;
|
|
@@ -140,8 +140,8 @@ export interface PrepareInheritedGateInput {
|
|
|
140
140
|
toolFaceSnapshot: ToolFaceSnapshot;
|
|
141
141
|
/** borrowed-readonly — the ctx's `mountsCallerTool` seat: identity membership in the caller's `spec.tools`, pre-gate. */
|
|
142
142
|
mountsCallerTool: (tool: ToolSpec) => boolean;
|
|
143
|
-
/** borrowed-readonly — the ctx's `mountedMcp` seat: the MCP surface the run mounts right now (call-time; the roster is minted after this phase)
|
|
144
|
-
mountedMcp
|
|
143
|
+
/** borrowed-readonly — the ctx's `mountedMcp` seat: the MCP surface the run mounts right now (call-time; the roster is minted after this phase), on every leg — `servers: []` on one that declares none. */
|
|
144
|
+
mountedMcp: () => import("../mounted-mcp.js").MountedMcp;
|
|
145
145
|
/** borrowed-readonly — the task-level lean switch (ctx seat; absent ⇒ no key). */
|
|
146
146
|
promptLean: ToolExecuteContext["promptLean"];
|
|
147
147
|
/** borrowed-readonly — the resolved interaction posture (ctx seat; absent ⇒ no key). */
|
|
@@ -236,6 +236,9 @@ export interface PrepareInheritedGateInput {
|
|
|
236
236
|
handsLessResolvedFace: () => ContainmentFace | undefined;
|
|
237
237
|
/** borrowed-readonly — LATE-BOUND: the hands-less legs' resolved WRITE face (same second source, write seat). */
|
|
238
238
|
handsLessResolvedWriteFace: () => WriteFaceSeat | undefined;
|
|
239
|
+
/** borrowed-readonly — LATE-BOUND: a leg that narrowed only its own hands (`TaskSpec.ownHandsReadOnly`): the faces its children
|
|
240
|
+
* are handed, resolved without that narrowing; undefined on every other leg (its children take its own faces). */
|
|
241
|
+
carriedFaces: () => CarriedFaces | undefined;
|
|
239
242
|
/** borrowed-readonly — LATE-BOUND: the leg's resolved `blockReadsOutsideRoots` (the hands phase's one answer, on either
|
|
240
243
|
* branch: the declaration, or the resumed row's record of it) — what the children's clamp takes, never the spec's word. */
|
|
241
244
|
readBlock: () => boolean;
|