@sema-agent/core 7.67.2 → 7.68.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 +1533 -0
- package/README.md +18 -9
- package/README.zh-CN.md +16 -8
- package/dist/agents/agent-definition.d.ts +1 -1
- package/dist/agents/agent-definition.js +4 -1
- package/dist/agents/cascade.d.ts +2 -2
- package/dist/agents/cascade.js +3 -1
- package/dist/agents/cumulative-stats.d.ts +2 -1
- package/dist/agents/cumulative-stats.js +4 -1
- package/dist/agents/list-agents-tool.d.ts +30 -0
- package/dist/agents/list-agents-tool.js +45 -3
- package/dist/agents/peer-admission.d.ts +2 -2
- package/dist/agents/peer-session-drain.d.ts +2 -0
- package/dist/agents/peer-session-drain.js +1 -0
- package/dist/agents/repair-loop.js +3 -1
- package/dist/agents/retain-ledger.d.ts +61 -8
- package/dist/agents/retain-ledger.js +25 -3
- package/dist/agents/roster-store.d.ts +4 -2
- package/dist/agents/send-message-tool.d.ts +1 -1
- package/dist/agents/send-message-tool.js +20 -15
- package/dist/agents/subagent-steps.js +2 -10
- package/dist/agents/subagent.d.ts +3 -0
- package/dist/agents/subagent.js +106 -76
- package/dist/agents/tool-filter.d.ts +20 -11
- package/dist/agents/tool-filter.js +8 -4
- package/dist/agents/verify.d.ts +3 -1
- package/dist/agents/verify.js +2 -0
- package/dist/brain/anthropic.js +4 -4
- package/dist/brain/errors.d.ts +20 -0
- package/dist/brain/errors.js +114 -0
- package/dist/brain/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- package/dist/brain/provider-message.d.ts +5 -3
- package/dist/brain/provider-message.js +35 -8
- package/dist/brain/reasoning-request.d.ts +73 -19
- package/dist/brain/reasoning-request.js +164 -72
- package/dist/brain/reasoning-stamp.d.ts +26 -0
- package/dist/brain/reasoning-stamp.js +10 -0
- package/dist/brain/reasoning.d.ts +95 -162
- package/dist/brain/reasoning.js +31 -86
- package/dist/brain/route-adjudicator.d.ts +9 -7
- package/dist/brain/route-adjudicator.js +12 -10
- package/dist/brain/status-sink.d.ts +19 -64
- package/dist/brain/status-sink.js +5 -21
- package/dist/brain/stream-engine.d.ts +11 -2
- package/dist/brain/stream-engine.js +10 -0
- package/dist/core/a2a.d.ts +17 -5
- package/dist/core/a2a.js +11 -3
- package/dist/core/allow-entry.d.ts +35 -15
- package/dist/core/allow-entry.js +47 -60
- package/dist/core/ask-headline.d.ts +68 -0
- package/dist/core/ask-headline.js +23 -0
- package/dist/core/ask-origin.d.ts +36 -8
- package/dist/core/ask-origin.js +17 -10
- package/dist/core/ask-question.d.ts +34 -7
- package/dist/core/ask-question.js +10 -1
- package/dist/core/ask-unresolvable-notice.d.ts +7 -0
- package/dist/core/ask-unresolvable-notice.js +9 -3
- package/dist/core/auto-strip.d.ts +53 -0
- package/dist/core/auto-strip.js +76 -0
- package/dist/core/background-agent-store.d.ts +45 -5
- package/dist/core/background-agent-store.js +69 -15
- package/dist/core/background-shell.d.ts +2 -2
- package/dist/core/caller-text.js +2 -2
- package/dist/core/canonical-json.d.ts +13 -0
- package/dist/core/canonical-json.js +7 -0
- package/dist/core/checkpoint-features.d.ts +66 -20
- package/dist/core/checkpoint-features.js +12 -1
- package/dist/core/checkpoint-generation.d.ts +1 -1
- package/dist/core/checkpoint-queries.d.ts +1 -1
- package/dist/core/checkpoint-queries.js +4 -1
- package/dist/core/checkpoint-requirements.d.ts +25 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -0
- package/dist/core/checkpoint-row-verdict.js +4 -0
- package/dist/core/checkpoint-store.d.ts +66 -38
- package/dist/core/checkpoint-store.js +15 -6
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +1 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/delegation-frames.d.ts +9 -12
- package/dist/core/delegation-frames.js +9 -8
- package/dist/core/engine-capabilities.d.ts +21 -8
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +147 -34
- package/dist/core/engine-notice.js +27 -16
- package/dist/core/engine-storage-backend.d.ts +2 -1
- package/dist/core/env-budget.js +3 -3
- package/dist/core/env-knob-announce.d.ts +10 -10
- package/dist/core/env-knob-announce.js +3 -6
- package/dist/core/file-history-store.d.ts +29 -4
- package/dist/core/file-history-store.js +13 -0
- package/dist/core/frame-settlement.d.ts +2 -1
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +56 -49
- package/dist/core/governance-codes.d.ts +39 -3
- package/dist/core/governance-codes.js +61 -3
- package/dist/core/hooks.d.ts +29 -11
- package/dist/core/hooks.js +5 -2
- package/dist/core/human-input-projection.js +3 -3
- package/dist/core/input-author.d.ts +17 -3
- package/dist/core/input-author.js +15 -3
- package/dist/core/leg-identity.d.ts +10 -28
- package/dist/core/leg-identity.js +1 -21
- package/dist/core/lsp.d.ts +18 -13
- package/dist/core/lsp.js +30 -22
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mailbox-store.js +4 -4
- package/dist/core/mcp-connection-pool.d.ts +93 -4
- package/dist/core/mcp-connection-pool.js +104 -1
- package/dist/core/mcp-failure.d.ts +38 -12
- package/dist/core/mcp-failure.js +9 -13
- package/dist/core/mcp-probe.d.ts +4 -3
- package/dist/core/mcp-server-link.d.ts +4 -2
- package/dist/core/mcp-server-link.js +4 -5
- package/dist/core/mcp-server-spec.d.ts +3 -3
- package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
- package/dist/core/mcp-server-unavailable-notice.js +18 -4
- package/dist/core/mcp.d.ts +40 -6
- package/dist/core/mcp.js +39 -13
- package/dist/core/memory-engine/content-origin.js +2 -2
- package/dist/core/memory-engine/control-objects.d.ts +2 -4
- package/dist/core/memory-engine/control-objects.js +2 -10
- package/dist/core/memory-engine/delegation-settlement.js +6 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +6 -4
- package/dist/core/memory-engine/engine.js +32 -29
- package/dist/core/memory-engine/file-backend.d.ts +20 -5
- package/dist/core/memory-engine/file-backend.js +21 -31
- package/dist/core/memory-engine/frontmatter.d.ts +2 -0
- package/dist/core/memory-engine/frontmatter.js +4 -0
- package/dist/core/memory-engine/layout.d.ts +114 -20
- package/dist/core/memory-engine/layout.js +340 -22
- package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
- package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
- package/dist/core/memory-engine/mount-failed-notice.js +43 -10
- package/dist/core/memory-engine/sync-client.js +4 -5
- package/dist/core/model-fallbacks.d.ts +5 -1
- package/dist/core/model-fallbacks.js +3 -3
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +12 -1
- package/dist/core/mods/kernel/dispatch.d.ts +2 -2
- package/dist/core/mods/kernel/dispatch.js +14 -6
- package/dist/core/mods/kernel/events.d.ts +8 -5
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/registration.d.ts +9 -0
- package/dist/core/mods/package.js +1 -1
- package/dist/core/mods/session-append.d.ts +4 -2
- package/dist/core/mods/session-append.js +3 -0
- package/dist/core/mods/stations.d.ts +7 -11
- package/dist/core/mods/stations.js +4 -7
- package/dist/core/mods/tool-call.d.ts +10 -8
- package/dist/core/mods/tool-call.js +15 -18
- package/dist/core/mounted-mcp.d.ts +0 -4
- package/dist/core/mounted-mcp.js +1 -1
- package/dist/core/park-noun.d.ts +24 -0
- package/dist/core/park-noun.js +21 -0
- package/dist/core/park-resumability.d.ts +60 -0
- package/dist/core/park-resumability.js +30 -0
- package/dist/core/permission-rule-provider.d.ts +24 -2
- package/dist/core/permission-rule-provider.js +11 -8
- package/dist/core/permission-rule-store.d.ts +8 -1
- package/dist/core/permission-rule-store.js +2 -3
- package/dist/core/permission-rules.d.ts +2 -1
- package/dist/core/permission-rules.js +8 -4
- package/dist/core/persisted-rule-arms.d.ts +3 -0
- package/dist/core/persisted-rule-arms.js +2 -1
- package/dist/core/present-plan-tool.d.ts +47 -3
- package/dist/core/present-plan-tool.js +62 -4
- package/dist/core/principal-name.d.ts +1 -1
- package/dist/core/principal-name.js +5 -5
- package/dist/core/process-identity.js +10 -5
- package/dist/core/protocol-http-auth.d.ts +30 -9
- package/dist/core/protocol-http-auth.js +113 -59
- package/dist/core/read-only-shell.js +9 -5
- package/dist/core/redaction-marks.d.ts +4 -26
- package/dist/core/redaction-marks.js +9 -21
- package/dist/core/remote-env.d.ts +43 -16
- package/dist/core/remote-env.js +1 -1
- package/dist/core/request-copy-projection.d.ts +1 -1
- package/dist/core/request-copy-projection.js +40 -50
- package/dist/core/resume-config-judge.js +1 -1
- package/dist/core/resume-startup-cause.d.ts +35 -18
- package/dist/core/resume-startup-cause.js +13 -10
- package/dist/core/retention.d.ts +167 -25
- package/dist/core/retention.js +100 -20
- package/dist/core/roles.d.ts +6 -0
- package/dist/core/roles.js +11 -5
- package/dist/core/rule-lane-reads.d.ts +3 -0
- package/dist/core/rule-lane-reads.js +5 -1
- package/dist/core/rule-store-fault.d.ts +70 -0
- package/dist/core/rule-store-fault.js +102 -0
- package/dist/core/runner/advertised-writable-dirs.js +16 -31
- package/dist/core/runner/announce-once-ledger.d.ts +19 -2
- package/dist/core/runner/announce-once-ledger.js +24 -2
- package/dist/core/runner/assemble-result.d.ts +6 -0
- package/dist/core/runner/assemble-result.js +1 -1
- package/dist/core/runner/auto-strip-notice.d.ts +36 -0
- package/dist/core/runner/auto-strip-notice.js +59 -0
- package/dist/core/runner/branch-window.d.ts +3 -0
- package/dist/core/runner/branch-window.js +37 -0
- package/dist/core/runner/caller-roster.d.ts +8 -3
- package/dist/core/runner/capability-withheld-seat.js +3 -9
- package/dist/core/runner/clock-and-limits.d.ts +22 -1
- package/dist/core/runner/clock-and-limits.js +30 -0
- package/dist/core/runner/contracts.d.ts +58 -35
- package/dist/core/runner/credential-refusal-seat.d.ts +2 -0
- package/dist/core/runner/credential-refusal-seat.js +47 -0
- package/dist/core/runner/cross-boundary-lane.js +6 -4
- package/dist/core/runner/decide-continuation.js +1 -1
- package/dist/core/runner/file-history-restore.d.ts +53 -2
- package/dist/core/runner/file-history-restore.js +29 -10
- package/dist/core/runner/forward-sink.d.ts +14 -1
- package/dist/core/runner/forward-sink.js +14 -12
- package/dist/core/runner/gate-exit.d.ts +8 -7
- package/dist/core/runner/gate-exit.js +13 -13
- package/dist/core/runner/git-status-frame.js +2 -4
- package/dist/core/runner/initial-run-state.js +1 -1
- package/dist/core/runner/main-call-account.d.ts +3 -1
- package/dist/core/runner/main-call-account.js +5 -3
- package/dist/core/runner/mcp-redial.d.ts +2 -5
- package/dist/core/runner/mcp-redial.js +2 -2
- package/dist/core/runner/nested-memory-content.d.ts +7 -1
- package/dist/core/runner/nested-memory-content.js +73 -13
- package/dist/core/runner/nested-memory-lane.d.ts +44 -19
- package/dist/core/runner/nested-memory-lane.js +152 -76
- package/dist/core/runner/park-commit.js +3 -1
- package/dist/core/runner/permission-rule-lanes.d.ts +8 -2
- package/dist/core/runner/permission-rule-lanes.js +29 -3
- package/dist/core/runner/person-path-rows.d.ts +3 -11
- package/dist/core/runner/person-path-rows.js +21 -24
- package/dist/core/runner/prepare-acquire-reconcile.js +3 -1
- package/dist/core/runner/prepare-artifact.d.ts +1 -1
- package/dist/core/runner/prepare-artifact.js +20 -14
- package/dist/core/runner/prepare-ask-lane.d.ts +9 -6
- package/dist/core/runner/prepare-ask-lane.js +6 -5
- package/dist/core/runner/prepare-boundary-parks.d.ts +7 -1
- package/dist/core/runner/prepare-boundary-parks.js +27 -24
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +5 -2
- package/dist/core/runner/prepare-caps-and-workflow.js +4 -3
- package/dist/core/runner/prepare-config-doors.d.ts +9 -24
- package/dist/core/runner/prepare-config-doors.js +58 -41
- package/dist/core/runner/prepare-context-lane.d.ts +2 -2
- package/dist/core/runner/prepare-context-lane.js +3 -5
- package/dist/core/runner/prepare-defer-classify.d.ts +1 -1
- package/dist/core/runner/prepare-defer-classify.js +1 -1
- package/dist/core/runner/prepare-delegation-surface.d.ts +2 -2
- package/dist/core/runner/prepare-delegation-surface.js +3 -2
- package/dist/core/runner/prepare-file-history.d.ts +62 -26
- package/dist/core/runner/prepare-file-history.js +117 -46
- package/dist/core/runner/prepare-gate-stations.d.ts +4 -0
- package/dist/core/runner/prepare-gate-stations.js +6 -5
- package/dist/core/runner/prepare-hands-readface.d.ts +9 -4
- package/dist/core/runner/prepare-hands-readface.js +8 -4
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +6 -6
- package/dist/core/runner/prepare-listings.d.ts +1 -1
- package/dist/core/runner/prepare-listings.js +1 -1
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-offload-wrappers.d.ts +1 -1
- package/dist/core/runner/prepare-offload-wrappers.js +1 -1
- package/dist/core/runner/prepare-park-ask.d.ts +10 -3
- package/dist/core/runner/prepare-park-ask.js +7 -9
- package/dist/core/runner/prepare-policy-chain.d.ts +18 -9
- package/dist/core/runner/prepare-policy-chain.js +18 -13
- package/dist/core/runner/prepare-project-context.d.ts +1 -1
- package/dist/core/runner/prepare-project-context.js +5 -3
- package/dist/core/runner/prepare-prompt-assembly.js +2 -1
- package/dist/core/runner/prepare-prompt-inputs.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.js +1 -1
- package/dist/core/runner/prepare-protocol-tools.d.ts +4 -5
- package/dist/core/runner/prepare-protocol-tools.js +7 -7
- package/dist/core/runner/prepare-question-face.d.ts +4 -2
- package/dist/core/runner/prepare-run-refs.d.ts +7 -2
- package/dist/core/runner/prepare-run-refs.js +8 -7
- package/dist/core/runner/prepare-safety-scan.d.ts +4 -3
- package/dist/core/runner/prepare-suspend-saga.d.ts +3 -7
- package/dist/core/runner/prepare-suspend-saga.js +4 -3
- package/dist/core/runner/prepare-task.js +66 -53
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +3 -2
- package/dist/core/runner/prepare-tool-disclosure-mount.js +2 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +3 -1
- package/dist/core/runner/prepare-turn-wiring.js +1 -1
- package/dist/core/runner/prepare-wiring-manifest.d.ts +9 -4
- package/dist/core/runner/prepare-wiring-manifest.js +14 -6
- package/dist/core/runner/prepare-workspace-restore.d.ts +4 -4
- package/dist/core/runner/prepare-workspace-restore.js +15 -6
- package/dist/core/runner/remote-env-retry.d.ts +3 -3
- package/dist/core/runner/restore-seat.d.ts +41 -0
- package/dist/core/runner/restore-seat.js +38 -0
- package/dist/core/runner/resume-admission.js +1 -1
- package/dist/core/runner/resume-apply.js +4 -3
- package/dist/core/runner/resume-checkpoint-screen.js +2 -1
- package/dist/core/runner/resume-internals-and-config.js +2 -1
- package/dist/core/runner/resume-preflight.js +2 -1
- package/dist/core/runner/rewind-files.js +22 -6
- package/dist/core/runner/rule-store-unreadable-notice.d.ts +8 -0
- package/dist/core/runner/rule-store-unreadable-notice.js +11 -0
- package/dist/core/runner/run-brain-sinks.d.ts +3 -6
- package/dist/core/runner/run-brain-sinks.js +6 -6
- package/dist/core/runner/run-compaction-machinery.d.ts +2 -2
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +2 -1
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.js +20 -12
- package/dist/core/runner/run-leg.js +31 -72
- package/dist/core/runner/run-notification-lane.d.ts +3 -0
- package/dist/core/runner/run-notification-lane.js +2 -4
- package/dist/core/runner/run-reasoning-seat.d.ts +5 -6
- package/dist/core/runner/run-reasoning-seat.js +13 -18
- package/dist/core/runner/run-settle-and-teardown.js +13 -9
- package/dist/core/runner/run-terminal-adoption.js +4 -8
- package/dist/core/runner/run-turn-boundary.js +6 -3
- package/dist/core/runner/runtask.d.ts +9 -4
- package/dist/core/runner/runtask.js +29 -22
- package/dist/core/runner/session-rule-policy.d.ts +11 -1
- package/dist/core/runner/shell-env-withheld.js +2 -7
- package/dist/core/runner/side-call-account.d.ts +5 -6
- package/dist/core/runner/side-call-account.js +2 -2
- package/dist/core/runner/stream-lifecycle-verbs.d.ts +3 -0
- package/dist/core/runner/stream-lifecycle-verbs.js +5 -3
- package/dist/core/runner/stream-settle-backstop.js +4 -6
- package/dist/core/runner/stream-steer-verb.d.ts +1 -1
- package/dist/core/runner/stream-steer-verb.js +4 -4
- package/dist/core/runner/sub-agent-deny-lists.d.ts +8 -3
- package/dist/core/runner/sub-agent-deny-lists.js +7 -4
- package/dist/core/runner/teardown-bounded.d.ts +7 -0
- package/dist/core/runner/teardown-bounded.js +7 -0
- package/dist/core/runner/terminal-account.js +41 -13
- package/dist/core/runner/terminal-projection.d.ts +1 -5
- package/dist/core/runner/tool-end-body.d.ts +9 -3
- package/dist/core/runner/tool-end-body.js +6 -3
- package/dist/core/runner/tool-output-projection.d.ts +13 -4
- package/dist/core/runner/tool-output-projection.js +10 -14
- package/dist/core/runner/turn-attachments.d.ts +3 -2
- package/dist/core/runner/turn-attachments.js +12 -5
- package/dist/core/runner-deps.d.ts +6 -6
- package/dist/core/runtime-caps.d.ts +2 -1
- package/dist/core/secret-env.d.ts +20 -3
- package/dist/core/secret-env.js +13 -15
- package/dist/core/session-checkout.d.ts +115 -15
- package/dist/core/session-checkout.js +435 -136
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.js +1 -0
- package/dist/core/session-store.js +2 -0
- package/dist/core/session.d.ts +11 -1
- package/dist/core/shell-run-candidates.d.ts +1 -0
- package/dist/core/shell-run-candidates.js +1 -1
- package/dist/core/shutdown-debug.d.ts +6 -5
- package/dist/core/shutdown-debug.js +5 -1
- package/dist/core/skill-grant.js +4 -1
- package/dist/core/skills-directory.js +5 -3
- package/dist/core/spec-contract.d.ts +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.js +2 -7
- package/dist/core/store-contracts/file-history-store-contract.js +26 -2
- package/dist/core/store-contracts/session-deletion-cascade-contract.js +130 -14
- package/dist/core/store-contracts/task-list-store-contract.d.ts +2 -1
- package/dist/core/store-contracts/task-list-store-contract.js +28 -1
- package/dist/core/task-event.d.ts +48 -27
- package/dist/core/task-notification.d.ts +15 -9
- package/dist/core/task-notification.js +12 -0
- package/dist/core/task-registry-agent.d.ts +24 -22
- package/dist/core/task-registry-agent.js +65 -46
- package/dist/core/task-registry-shared.d.ts +17 -5
- package/dist/core/task-registry.d.ts +17 -6
- package/dist/core/task-registry.js +6 -1
- package/dist/core/task-result.d.ts +71 -25
- package/dist/core/task-spec-members.d.ts +0 -1
- package/dist/core/task-spec-members.js +1 -1
- package/dist/core/task-spec.d.ts +60 -52
- package/dist/core/task-stream.d.ts +45 -12
- package/dist/core/terminal-cause.d.ts +45 -8
- package/dist/core/terminal-cause.js +5 -0
- package/dist/core/tool-card-bound.d.ts +32 -0
- package/dist/core/tool-card-bound.js +33 -0
- package/dist/core/tool-catalog-entries.d.ts +9 -0
- package/dist/core/tool-catalog-entries.js +48 -0
- package/dist/core/tool-errors.d.ts +4 -3
- package/dist/core/tool-face.d.ts +3 -3
- package/dist/core/tool-mount-facts.d.ts +3 -2
- package/dist/core/tool-mount-facts.js +1 -1
- package/dist/core/tool-mount-static.js +7 -5
- package/dist/core/tool-policy.d.ts +21 -19
- package/dist/core/tool-policy.js +5 -6
- package/dist/core/tool-registry.d.ts +3 -1
- package/dist/core/tool-registry.js +15 -1
- package/dist/core/tool-result-store.d.ts +9 -3
- package/dist/core/tool-result-store.js +14 -1
- package/dist/core/tool-roster.d.ts +6 -0
- package/dist/core/tool-roster.js +18 -0
- package/dist/core/tool-spec.d.ts +17 -8
- package/dist/core/trace.d.ts +35 -31
- package/dist/core/types.d.ts +2 -2
- package/dist/core/untrusted-egress.d.ts +19 -7
- package/dist/core/untrusted-egress.js +26 -7
- package/dist/core/untrusted-text.d.ts +6 -18
- package/dist/core/untrusted-text.js +11 -4
- package/dist/core/user-attachment.d.ts +9 -6
- package/dist/core/user-attachment.js +12 -10
- package/dist/core/user-row-origin.d.ts +44 -25
- package/dist/core/user-row-origin.js +30 -20
- package/dist/core/wiring-manifest.d.ts +26 -7
- package/dist/core/wiring-manifest.js +14 -11
- package/dist/core/workspace-snapshot.d.ts +3 -1
- package/dist/core/workspace-snapshot.js +1 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +23 -16
- package/dist/engine/execution-env/node-execution-env.js +127 -67
- package/dist/engine/harness/agent-harness.d.ts +4 -5
- package/dist/engine/harness/agent-harness.js +2 -7
- package/dist/engine/harness/types.d.ts +51 -19
- package/dist/engine/harness/types.js +28 -1
- package/dist/engine/llm/types.d.ts +26 -14
- package/dist/engine/llm/types.js +2 -2
- package/dist/engine/loop/agent-loop.d.ts +2 -2
- package/dist/engine/loop/agent-loop.js +51 -275
- package/dist/engine/loop/types.d.ts +0 -18
- package/dist/engine/session/import-validate.d.ts +3 -0
- package/dist/engine/session/import-validate.js +34 -2
- package/dist/engine/session/repo-utils.d.ts +42 -4
- package/dist/engine/session/repo-utils.js +33 -5
- package/dist/engine/session/session.d.ts +41 -14
- package/dist/engine/session/session.js +96 -25
- package/dist/index.d.ts +21 -16
- package/dist/index.js +16 -10
- package/dist/orchestration/run-spec.d.ts +1 -1
- package/dist/orchestration/run-workflow-tool.d.ts +12 -9
- package/dist/orchestration/run-workflow-tool.js +15 -19
- package/dist/orchestration/workflow-governance.js +13 -21
- package/dist/orchestration/workflow-observe.d.ts +4 -3
- package/dist/orchestration/workflow-primitives.d.ts +1 -1
- package/dist/orchestration/workflow-record-artifact.d.ts +14 -0
- package/dist/orchestration/workflow-record-artifact.js +32 -0
- package/dist/orchestration/workflow-script-store.d.ts +9 -0
- package/dist/orchestration/workflow-script-store.js +20 -1
- package/dist/orchestration/workflow-types.d.ts +33 -3
- package/dist/orchestration/workflow.d.ts +24 -14
- package/dist/orchestration/workflow.js +52 -23
- package/dist/prompt-assembly/artifact.js +4 -8
- package/dist/prompt-assembly/catalog/engine.d.ts +263 -0
- package/dist/prompt-assembly/catalog/engine.js +30 -0
- package/dist/prompt-assembly/catalog/index.d.ts +1 -1
- package/dist/prompt-assembly/catalog/index.js +2 -2
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.d.ts +1 -1
- package/dist/prompt-assembly/catalog/locales/zh-Hans/engine.js +29 -0
- package/dist/prompt-assembly/epoch.js +6 -8
- package/dist/prompt-assembly/turn-snapshot.js +8 -9
- package/dist/stores/file/background-agent-store.js +5 -6
- package/dist/stores/file/checkpoint-store.d.ts +0 -4
- package/dist/stores/file/checkpoint-store.js +7 -3
- package/dist/stores/file/file-history-store.d.ts +8 -0
- package/dist/stores/file/file-history-store.js +72 -0
- package/dist/stores/file/fs-atomic.js +17 -12
- package/dist/stores/file/index.js +11 -5
- package/dist/stores/file/mailbox-store.js +13 -4
- package/dist/stores/file/permission-rule-store.js +14 -13
- package/dist/stores/file/shared-ledger.d.ts +4 -0
- package/dist/stores/file/shared-ledger.js +4 -0
- package/dist/stores/file/task-list-store.js +12 -3
- package/dist/stores/file/workflow-run-store.js +1 -0
- package/dist/tools/fs/bash-program-position.d.ts +4 -2
- package/dist/tools/fs/bash-program-position.js +1 -1
- package/dist/tools/fs/bash-readonly-classifier.js +1 -1
- package/dist/tools/fs/bound-open.d.ts +97 -0
- package/dist/tools/fs/bound-open.js +103 -0
- package/dist/tools/fs/containment-face.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.d.ts +7 -1
- package/dist/tools/fs/fs-pdf.js +31 -23
- package/dist/tools/fs/fs-read.d.ts +24 -17
- package/dist/tools/fs/fs-read.js +84 -53
- package/dist/tools/fs/fs-shared.d.ts +14 -12
- package/dist/tools/fs/fs-shared.js +5 -4
- package/dist/tools/fs/fs-write.d.ts +2 -2
- package/dist/tools/fs/fs-write.js +20 -12
- package/dist/tools/fs/index.d.ts +4 -4
- package/dist/tools/fs/index.js +2 -2
- package/dist/tools/fs/notebook.d.ts +1 -1
- package/dist/tools/fs/pdf.d.ts +12 -3
- package/dist/tools/fs/pdf.js +22 -9
- package/dist/tools/fs/read-deny-home.d.ts +3 -2
- package/dist/tools/fs/read-deny-home.js +8 -11
- package/dist/tools/fs/safety.d.ts +3 -2
- package/dist/tools/fs/shell-read-check.js +10 -9
- package/dist/tools/monitor.d.ts +6 -5
- package/dist/tools/task-list.d.ts +16 -6
- package/dist/tools/task-list.js +4 -0
- package/dist/tools/web.d.ts +9 -1
- package/dist/tools/web.js +8 -3
- package/dist/tools/worktree.d.ts +7 -5
- package/dist/tools/worktree.js +4 -3
- package/package.json +4 -3
- package/test/export-surface.snapshot.json +93 -7
- package/wire-changes/core-stores-sql@7.67.3.json +39 -0
- package/wire-changes/core-stores-sql@7.68.0.json +39 -0
- package/wire-changes/core@7.67.3.json +65 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/mods-kernel@7.67.3.json +39 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/primitives@7.67.3.json +39 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/wiki-gate@7.67.3.json +39 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
import { isRemoteExecutionEnv, pathsAreHostLocal } from "../remote-env.js";
|
|
2
|
+
import { fileHistoryScopeOf, isOccupantToken } from "../../engine/session/repo-utils.js";
|
|
2
3
|
import { FILE_HISTORY_ERROR_CODES, FileHistoryStoreError } from "../file-history-store.js";
|
|
3
4
|
import { readMember, thrownText } from "../thrown-value.js";
|
|
4
5
|
import { isGovernanceRetryClass } from "../governance-codes.js";
|
|
5
|
-
import { boundaryUnrecordedNotice, fileHistoryRestoreLedgerLine, settleFileHistoryRestore } from "./file-history-restore.js";
|
|
6
|
+
import { boundaryUnrecordedNotice, fileHistoryRestoreLedgerLine, refuseRestoreOnForkWithOwnTree, refuseTargetOutsideOwnLog, restoreFailedError, settleFileHistoryRestore } from "./file-history-restore.js";
|
|
6
7
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
8
|
+
import { canonicalOrSelf } from "./child-tree.js";
|
|
7
9
|
export async function prepareFileHistory(input) {
|
|
8
|
-
const { deps, spec, request, internals, executionEnv,
|
|
10
|
+
const { deps, spec, request, internals, executionEnv, sessionRoot, forkSourceRoot, handsEnabled, sessionId, session, forkWithOwnTree, row, abortController } = input;
|
|
9
11
|
const rewindNotes = [];
|
|
10
12
|
const { onTrackFailure, captureOff, declaredOff, fileHistoryStore, captureStore, rewindTarget, rewindBefore } = request;
|
|
13
|
+
const own = row !== undefined ? ownScopeOf(sessionId, row) : { unaddressed: "this session's row was not read (the run has no history store)" };
|
|
14
|
+
const ownScope = "scope" in own ? own.scope : undefined;
|
|
11
15
|
if (spec.resumeAt !== undefined && spec.restoreFiles !== true) {
|
|
12
16
|
rewindNotes.push({
|
|
13
17
|
code: "conversation_only",
|
|
14
18
|
message: `the conversation was branched at entry "${spec.resumeAt}" but the working tree was NOT rewound — this task set resumeAt without restoreFiles, so files remain at their current state`,
|
|
15
19
|
});
|
|
16
20
|
}
|
|
17
|
-
const
|
|
21
|
+
const live = captureStore !== undefined && handsEnabled && !forkWithOwnTree;
|
|
18
22
|
const livenessArm = fileHistoryStore === undefined ? "file-history-no-store" : "file-history-no-env";
|
|
19
|
-
if (!
|
|
23
|
+
if (!live && !forkWithOwnTree && !declaredOff && !captureOff && (handsEnabled || fileHistoryStore !== undefined) && deps.onError !== undefined && !toldAlready(deps.onError, livenessArm)) {
|
|
20
24
|
const reason = livenessArm === "file-history-no-store"
|
|
21
25
|
? `this deployment wired no RunnerDeps.fileHistoryStore, so NOTHING is recorded: no first-touch snapshot before an edit, no turn boundary, and a later restoreFiles / rewindFilesTo has nothing to restore from and will refuse (rewind.store_unconfigured). Supply a store, or accept an unrecoverable working tree knowingly (fileHistoryStore: "disabled" says so and silences this line)`
|
|
22
26
|
: `RunnerDeps.fileHistoryStore is wired but this run mounts no filesystem-capable ExecutionEnv, so the store is INERT: there is no working tree to snapshot and nothing will ever be written to it. Wire RunnerDeps.executionEnv, or drop the store from this deployment shape`;
|
|
@@ -26,10 +30,30 @@ export async function prepareFileHistory(input) {
|
|
|
26
30
|
catch {
|
|
27
31
|
}
|
|
28
32
|
}
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
+
let keyedRead;
|
|
34
|
+
const keyedRoot = () => (keyedRead ??= sessionRoot());
|
|
35
|
+
const keyed = live || (rewindTarget !== undefined && fileHistoryStore !== undefined && handsEnabled) ? await keyedRoot() : undefined;
|
|
36
|
+
const outside = keyed !== undefined && "outside" in keyed ? keyed.outside : undefined;
|
|
37
|
+
if (outside !== undefined && rewindTarget !== undefined)
|
|
38
|
+
throw outside.refusal;
|
|
39
|
+
try {
|
|
40
|
+
if (outside !== undefined)
|
|
41
|
+
deps.onError?.(new Error(outside.notice), { phase: "config", sessionId, classification: "file-history-outside-checkout" });
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
}
|
|
45
|
+
const fileHistoryEnabled = live && outside === undefined;
|
|
46
|
+
const { historyRoot, historyScope, historyFs } = await resolveFileHistoryCoordinates(executionEnv, keyed !== undefined && "root" in keyed ? keyed.root : undefined, internals?.fileHistoryLineage, ownScope, internals?.callerRoot);
|
|
47
|
+
try {
|
|
48
|
+
if (fileHistoryEnabled && historyScope === undefined && "unaddressed" in own)
|
|
49
|
+
deps.onError?.(new Error(`file history has no scope for this run — ${own.unaddressed}: first-touch backups fail (track_failed), no turn boundary is recorded, and a rewind is refused.`), { phase: "rewind", sessionId });
|
|
50
|
+
}
|
|
51
|
+
catch {
|
|
52
|
+
}
|
|
53
|
+
const carryRoots = { own: async () => (await keyedRoot().then((k) => ("root" in k ? canonicalOrSelf(executionEnv, k.root) : undefined), () => undefined)), source: async (origin) => { const r = await forkSourceRoot(origin); return r === undefined ? undefined : canonicalOrSelf(executionEnv, r); } };
|
|
54
|
+
if (captureStore !== undefined && row !== undefined && internals?.fileHistoryLineage === undefined && ownScope !== undefined)
|
|
55
|
+
await adoptForkedFileHistory(captureStore, row, sessionId, ownScope, deps.onError, carryRoots);
|
|
56
|
+
if (rewindTarget !== undefined && historyScope !== undefined && historyScope !== ownScope)
|
|
33
57
|
throw childScopeRewindRefusal(historyScope, rewindTarget);
|
|
34
58
|
if (fileHistoryStore !== undefined && !handsEnabled) {
|
|
35
59
|
if (rewindTarget !== undefined) {
|
|
@@ -41,7 +65,11 @@ export async function prepareFileHistory(input) {
|
|
|
41
65
|
}
|
|
42
66
|
if (rewindTarget !== undefined && fileHistoryStore !== undefined && handsEnabled) {
|
|
43
67
|
const restoreSignal = spec.signal ? AbortSignal.any([abortController.signal, spec.signal]) : abortController.signal;
|
|
44
|
-
|
|
68
|
+
if ("unaddressed" in own)
|
|
69
|
+
throw own.refused ?? unaddressedRewindRefusal(sessionId, rewindTarget);
|
|
70
|
+
await refuseTargetOutsideOwnLog(session, sessionId, rewindTarget, rewindBefore ? "before" : "restore");
|
|
71
|
+
refuseRestoreOnForkWithOwnTree(forkWithOwnTree, sessionId, rewindTarget, rewindBefore ? "before" : "restore");
|
|
72
|
+
const restored = await settleFileHistoryRestore({ store: fileHistoryStore, sessionId, scope: own.scope, target: rewindTarget, before: rewindBefore, env: executionEnv, root: historyRoot, signal: restoreSignal, readStates: internals?.sessionReadStates });
|
|
45
73
|
const ledgerLine = fileHistoryRestoreLedgerLine;
|
|
46
74
|
if (restored.outcome === "partial") {
|
|
47
75
|
if (spec.acceptPartialRestore === true) {
|
|
@@ -51,22 +79,21 @@ export async function prepareFileHistory(input) {
|
|
|
51
79
|
});
|
|
52
80
|
}
|
|
53
81
|
else {
|
|
54
|
-
|
|
55
|
-
e.code = "rewind.restore_failed";
|
|
56
|
-
throw e;
|
|
82
|
+
throw restoreFailedError(restored, `rewind-files: restore to entry "${rewindTarget}" was PARTIAL — ledger: ${ledgerLine(restored)}. The task is refused rather than run on a mixed-state tree (set acceptPartialRestore: true to tolerate and disclose instead); re-running the same restore converges (per-file idempotent).`);
|
|
57
83
|
}
|
|
58
84
|
}
|
|
59
85
|
}
|
|
60
86
|
const trackFileEdit = fileHistoryEnabled
|
|
61
87
|
? async (req) => {
|
|
62
|
-
const
|
|
88
|
+
const scope = historyScope;
|
|
89
|
+
const r = scope === undefined ? unaddressedTrack("unaddressed" in own ? own.unaddressed : "") : await answerOf(() => fileHistoryStore.trackEdit(scope, req.key, executionEnv, historyRoot, req.signal), "track_failed");
|
|
63
90
|
if (r.ok) {
|
|
64
91
|
if (!r.minted)
|
|
65
92
|
return { ok: true };
|
|
66
93
|
return {
|
|
67
94
|
ok: true,
|
|
68
95
|
annul: async (proof) => {
|
|
69
|
-
const a = await answerOf(() => fileHistoryStore.annulTrack(
|
|
96
|
+
const a = await answerOf(() => fileHistoryStore.annulTrack(scope, req.key, historyRoot, proof === "verify" ? { env: executionEnv, ...(req.signal !== undefined ? { signal: req.signal } : {}) } : undefined), "track_failed");
|
|
70
97
|
if (a.ok)
|
|
71
98
|
return;
|
|
72
99
|
try {
|
|
@@ -89,14 +116,23 @@ export async function prepareFileHistory(input) {
|
|
|
89
116
|
return { ok: false, refusal: `Error (${req.tool}): the edit was refused because its first-touch file-history backup could not be persisted (${r.error.code}). ${lead} Proceeding would leave the file with no durable pristine record. ${r.error.message}` };
|
|
90
117
|
}
|
|
91
118
|
: undefined;
|
|
92
|
-
const fileHistoryBoundary = fileHistoryEnabled && historyScope ===
|
|
93
|
-
? createFileHistoryBoundarySeat({ store: fileHistoryStore, sessionId, env: executionEnv, root: historyRoot, onError: deps.onError, onNotice: deps.onNotice })
|
|
119
|
+
const fileHistoryBoundary = fileHistoryEnabled && ownScope !== undefined && historyScope === ownScope
|
|
120
|
+
? createFileHistoryBoundarySeat({ store: fileHistoryStore, sessionId, scope: ownScope, env: executionEnv, root: historyRoot, onError: deps.onError, onNotice: deps.onNotice })
|
|
94
121
|
: undefined;
|
|
95
122
|
const fileHistoryFact = fileHistoryEnabled ? "on" : "disabled";
|
|
96
123
|
return { trackFileEdit, fileHistoryBoundary, rewindNotes, fileHistoryEnabled, fileHistoryFact, historyScope, historyRoot, historyFs };
|
|
97
124
|
}
|
|
98
125
|
const FILE_HISTORY_BOUNDARY_TIMEOUT_MS = 30_000;
|
|
99
126
|
const FILE_HISTORY_LIVENESS_MEMO = new WeakMap();
|
|
127
|
+
export function announceForkCheckoutUnrecorded(onceOnError, request, sessionId) {
|
|
128
|
+
if (request.declaredOff || request.captureOff)
|
|
129
|
+
return;
|
|
130
|
+
try {
|
|
131
|
+
onceOnError(new Error(`file history is not live for this session — session "${sessionId}" is a fork that works in a tree of its own (TaskSpec.workspace): in this version such a session records no file history (no first-touch backup before an edit, no turn boundary) and a rewind of its files is refused; its edits in the tree are not recoverable by a rewind, and its conversation is still branched by resumeAt.`), { phase: "config", sessionId, classification: "file-history-fork-checkout" });
|
|
132
|
+
}
|
|
133
|
+
catch {
|
|
134
|
+
}
|
|
135
|
+
}
|
|
100
136
|
function toldAlready(sink, arm) {
|
|
101
137
|
const heard = FILE_HISTORY_LIVENESS_MEMO.get(sink) ?? new Set();
|
|
102
138
|
FILE_HISTORY_LIVENESS_MEMO.set(sink, heard);
|
|
@@ -121,50 +157,83 @@ function answerOf(call, code) {
|
|
|
121
157
|
return { ok: false, error: { code: known, message: text, ...(isGovernanceRetryClass(permanence) ? { permanence } : {}) } };
|
|
122
158
|
}, (value) => unanswered(`the history store threw: ${thrownText(value)}`, { value }));
|
|
123
159
|
}
|
|
124
|
-
export async function adoptForkedFileHistory(store,
|
|
160
|
+
export async function adoptForkedFileHistory(store, lineage, sessionId, ownScope, onError, roots) {
|
|
125
161
|
const memo = FILE_HISTORY_CARRY_MEMO.get(store) ?? { settled: new Set(), disclosed: new Set(), inFlight: new Map() };
|
|
126
162
|
FILE_HISTORY_CARRY_MEMO.set(store, memo);
|
|
127
163
|
const discloseOnce = (err) => {
|
|
128
|
-
if (memo.disclosed.has(
|
|
164
|
+
if (memo.disclosed.has(ownScope))
|
|
129
165
|
return;
|
|
130
|
-
memo.disclosed.add(
|
|
166
|
+
memo.disclosed.add(ownScope);
|
|
131
167
|
onError?.(err, { phase: "rewind", sessionId });
|
|
132
168
|
};
|
|
133
|
-
const
|
|
169
|
+
const { origin: forkedFrom, originIncarnation: forkedFromIncarnation } = lineage;
|
|
134
170
|
try {
|
|
135
|
-
if (memo.settled.has(sessionId))
|
|
136
|
-
return;
|
|
137
|
-
const forkedFrom = (await session.getMetadata()).forkedFrom;
|
|
138
171
|
if (forkedFrom === undefined || forkedFrom === sessionId)
|
|
139
172
|
return;
|
|
140
|
-
|
|
173
|
+
if (memo.settled.has(ownScope))
|
|
174
|
+
return;
|
|
175
|
+
let sourceScope;
|
|
176
|
+
let why = "this fork's row records no occupant of its source (it was cut before rows named their occupants, or its store mints none), so the source's history has no address";
|
|
177
|
+
try {
|
|
178
|
+
if (isOccupantToken(forkedFromIncarnation))
|
|
179
|
+
sourceScope = fileHistoryScopeOf(forkedFrom, forkedFromIncarnation);
|
|
180
|
+
}
|
|
181
|
+
catch (refused) {
|
|
182
|
+
why = thrownText(refused);
|
|
183
|
+
}
|
|
184
|
+
if (sourceScope === undefined) {
|
|
185
|
+
memo.settled.add(ownScope);
|
|
186
|
+
discloseOnce(new FileHistoryStoreError({ code: "adopt_failed" }, `file-history fork carry from session "${forkedFrom}" was not made — ${why}. Nothing was carried into this session (the run itself proceeds; a fork that already holds history keeps it)`));
|
|
187
|
+
return;
|
|
188
|
+
}
|
|
189
|
+
const [own, source] = [await roots.own(), await roots.source(forkedFrom)];
|
|
190
|
+
if (own === undefined || source === undefined || own !== source) {
|
|
191
|
+
if (own !== undefined && source !== undefined)
|
|
192
|
+
memo.settled.add(ownScope);
|
|
193
|
+
const apart = source === undefined ? "this session's copy of the source's log shows the source working in a tree of its own, or cannot vouch for where its history is keyed" : own === undefined ? "where this session's history is keyed cannot be read" : `the source's history is keyed against ${source} and this session's against ${own}`;
|
|
194
|
+
discloseOnce(new FileHistoryStoreError({ code: "adopt_failed" }, `file-history fork carry from session "${forkedFrom}" was not made — ${apart}: carried records are joined back on this session's root, so they would restore the source's files there. Nothing was carried; a rewind to a point before the fork is refused as a point with no boundary on this session (the run itself proceeds)`));
|
|
195
|
+
return;
|
|
196
|
+
}
|
|
197
|
+
const shared = memo.inFlight.get(ownScope);
|
|
141
198
|
if (shared !== undefined)
|
|
142
199
|
return await shared;
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
const attempt = answerOf(() => store.adoptScope(forkedFrom, sessionId), "adopt_failed").then((carried) => {
|
|
200
|
+
const attempt = (async () => {
|
|
201
|
+
const carried = await answerOf(() => store.adoptScope(sourceScope, ownScope), "adopt_failed");
|
|
146
202
|
if (carried.ok || carried.error.code === "conflict") {
|
|
147
|
-
memo.settled.add(
|
|
203
|
+
memo.settled.add(ownScope);
|
|
148
204
|
return;
|
|
149
205
|
}
|
|
150
206
|
discloseOnce(new FileHistoryStoreError(carried.error, `file-history fork carry from session "${forkedFrom}" failed (${carried.error.code}): ${carried.error.message} — the parent's history was not carried, so boundaries recorded before the fork are not restorable from this session (the run itself proceeds; the carry is retried on this session's next turn)`, "thrown" in carried ? carried.thrown : undefined));
|
|
151
|
-
});
|
|
152
|
-
memo.inFlight.set(
|
|
207
|
+
})();
|
|
208
|
+
memo.inFlight.set(ownScope, attempt);
|
|
153
209
|
try {
|
|
154
210
|
await attempt;
|
|
155
211
|
}
|
|
156
212
|
finally {
|
|
157
|
-
memo.inFlight.delete(
|
|
213
|
+
memo.inFlight.delete(ownScope);
|
|
158
214
|
}
|
|
159
215
|
}
|
|
216
|
+
catch {
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
function ownScopeOf(sessionId, row) {
|
|
220
|
+
if (row.fault)
|
|
221
|
+
return { unaddressed: "this session's row could not be read" };
|
|
222
|
+
try {
|
|
223
|
+
return { scope: fileHistoryScopeOf(sessionId, row.own) };
|
|
224
|
+
}
|
|
160
225
|
catch (err) {
|
|
161
|
-
|
|
162
|
-
discloseOnce(threw(err));
|
|
163
|
-
}
|
|
164
|
-
catch {
|
|
165
|
-
}
|
|
226
|
+
return { unaddressed: thrownText(err), refused: err instanceof Error ? err : new Error(thrownText(err)) };
|
|
166
227
|
}
|
|
167
228
|
}
|
|
229
|
+
function unaddressedTrack(why) {
|
|
230
|
+
return { ok: false, error: { code: "track_failed", message: `${why} — the run has no file-history scope to record the backup in` } };
|
|
231
|
+
}
|
|
232
|
+
export function unaddressedRewindRefusal(sessionId, target) {
|
|
233
|
+
const e = new Error(`rewind-files: the row of session "${sessionId}" could not be read, so its file history has no address and nothing can be restored to entry "${target}" — the working tree was NOT rewound; retry once the session store answers`);
|
|
234
|
+
e.code = "rewind.restore_failed";
|
|
235
|
+
return e;
|
|
236
|
+
}
|
|
168
237
|
function createFileHistoryBoundarySeat(opts) {
|
|
169
238
|
let inFlight;
|
|
170
239
|
let begun = false;
|
|
@@ -181,7 +250,7 @@ function createFileHistoryBoundarySeat(opts) {
|
|
|
181
250
|
resolve({ ok: false });
|
|
182
251
|
}, FILE_HISTORY_BOUNDARY_TIMEOUT_MS);
|
|
183
252
|
});
|
|
184
|
-
const work = answerOf(() => opts.store.snapshot(opts.
|
|
253
|
+
const work = answerOf(() => opts.store.snapshot(opts.scope, entryId, opts.env, opts.root, ac.signal), "snapshot_failed");
|
|
185
254
|
const disclose = (failure, what, thrown) => new FileHistoryStoreError(failure, `file-history ${what} — this turn has no boundary and cannot be rewound to (the turn itself proceeds)`, thrown);
|
|
186
255
|
inFlight = Promise.race([
|
|
187
256
|
work.then((r) => (r.ok ? undefined : disclose(r.error, `boundary capture failed (${r.error.code}): ${r.error.message}`, "thrown" in r ? r.thrown : undefined))),
|
|
@@ -209,17 +278,19 @@ function createFileHistoryBoundarySeat(opts) {
|
|
|
209
278
|
},
|
|
210
279
|
};
|
|
211
280
|
}
|
|
212
|
-
export async function resolveFileHistoryCoordinates(
|
|
213
|
-
if (
|
|
214
|
-
return { historyRoot:
|
|
215
|
-
const canonRoot = await env.canonicalPath(
|
|
216
|
-
const
|
|
281
|
+
export async function resolveFileHistoryCoordinates(env, sessionRoot, lineage, ownScope, callerRoot) {
|
|
282
|
+
if (sessionRoot === undefined)
|
|
283
|
+
return { historyRoot: "", historyScope: ownScope, historyFs: "" };
|
|
284
|
+
const canonRoot = await env.canonicalPath(sessionRoot);
|
|
285
|
+
const ownRoot = canonRoot.ok ? canonRoot.value : sessionRoot;
|
|
217
286
|
const historyFs = fileHistoryFilesystemIdentity(env);
|
|
218
|
-
|
|
287
|
+
const atCaller = lineage !== undefined && lineage.fs === historyFs && callerRoot !== undefined && ownRoot === (await canonicalOrSelf(env, callerRoot));
|
|
288
|
+
const historyRoot = atCaller ? lineage.root : ownRoot;
|
|
289
|
+
return { historyRoot, historyScope: resolveFileHistoryScope(lineage, historyRoot, historyFs, ownScope), historyFs };
|
|
219
290
|
}
|
|
220
|
-
export function resolveFileHistoryScope(lineage, historyRoot, historyFs,
|
|
291
|
+
export function resolveFileHistoryScope(lineage, historyRoot, historyFs, ownScope) {
|
|
221
292
|
if (lineage === undefined || lineage.scope === "" || lineage.root !== historyRoot || lineage.fs !== historyFs)
|
|
222
|
-
return
|
|
293
|
+
return ownScope;
|
|
223
294
|
return lineage.scope;
|
|
224
295
|
}
|
|
225
296
|
const envFilesystemTokens = new WeakMap();
|
|
@@ -243,7 +314,7 @@ export function fileHistoryFilesystemIdentity(env) {
|
|
|
243
314
|
return token;
|
|
244
315
|
}
|
|
245
316
|
function childScopeRewindRefusal(rootScope, target) {
|
|
246
|
-
const e = new Error(`rewind-files: this run is a delegated child recording its edits into
|
|
317
|
+
const e = new Error(`rewind-files: this run is a delegated child recording its edits into its ROOT session's file history (scope "${rootScope}"), so restoring files to entry "${target}" is the root session's action (rewindFilesTo / resumeAt+restoreFiles on that session), not the child's — the files were NOT rewound`);
|
|
247
318
|
e.code = "rewind.child_scope_unsupported";
|
|
248
319
|
return e;
|
|
249
320
|
}
|
|
@@ -209,6 +209,10 @@ export interface PrepareGateStationsInput {
|
|
|
209
209
|
};
|
|
210
210
|
/** borrowed-readonly — the leg's ONE ask derivation (`wiring_manifest.ask`: form + effective), read for the classifier's seat. */
|
|
211
211
|
askRoute: WiringManifest["ask"];
|
|
212
|
+
/** borrowed-readonly — the leg's fact "its parks cannot be resumed" as the driver derived it (source + forced gate); the gate's deny
|
|
213
|
+
* exit and question refusal read it. Absent ⇔ the leg's parks can be resumed. */
|
|
214
|
+
notResumable: import("../park-resumability.js").NotResumableLeg | undefined;
|
|
215
|
+
/** borrowed-mutable — the run's refused-ask list (`TaskResult.refusedAsks`), one entry per refused call. */ refusedAsks: import("../task-result.js").RefusedAsk[];
|
|
212
216
|
/** borrowed-readonly — the leg's live permission-mode seat: the gate's arbitration point reads `current` per call. */
|
|
213
217
|
permissionMode: PermissionModeController;
|
|
214
218
|
/** borrowed-readonly — WHO marked each tool's seat (the safety scan's map, the protocol fold's rows); read per call into
|
|
@@ -4,10 +4,10 @@ import { heldWhileClassifying } from "../auto-mode.js";
|
|
|
4
4
|
import { complianceCallDenial } from "../compliance.js";
|
|
5
5
|
import { formatHookFeedback, runToolGate } from "../hooks.js";
|
|
6
6
|
import { screenGateOutcome } from "../gate-outcome.js";
|
|
7
|
-
import {
|
|
7
|
+
import { directDeny, frozenInputSnapshot, permissionDeniedOf } from "./gate-exit.js";
|
|
8
8
|
import { emitTrace } from "../trace.js";
|
|
9
9
|
import { deliverEngineNotice } from "../engine-notice.js";
|
|
10
|
-
import { askUnresolvableNotice } from "../ask-unresolvable-notice.js";
|
|
10
|
+
import { askUnresolvableNotice, refusedAskOf } from "../ask-unresolvable-notice.js";
|
|
11
11
|
import { approvalRouteOf } from "../wiring-manifest.js";
|
|
12
12
|
import { classifierUnavailableSeat } from "./classifier-ladder.js";
|
|
13
13
|
import { PATH_CONFINABLE_WRITE_TOOLS } from "./session-rule-policy.js";
|
|
@@ -51,7 +51,7 @@ export function maybeHumanRejectionHalt(input) {
|
|
|
51
51
|
};
|
|
52
52
|
}
|
|
53
53
|
export function prepareGateStations(input) {
|
|
54
|
-
const { askLane, parkAsk, tools, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, permissionMode, toolMarkSources, a2aIsolatePeers, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations, commandSandboxArmed, sandboxPlanOf } = input;
|
|
54
|
+
const { askLane, parkAsk, tools, refusedAsks, toolRosterDeltas, deps, toolCallGateArmedRef, effectivePolicy, egressTools, irreversibleTools, spec, complianceDenies, harness, blockedToolCalls, inheritedAskGrants, inheritedUnavailableAsks, deferredAskIdentities, foldAskClasses, ancestorSandboxAdmissions, preToolContexts, toolOccurrences, batchHaltRef, blockedTracked, hookIdentity, reminderMark, hostTaskId, sessionId, legNotice, handsCwdRef, stampCallTarget, hookEnvFace, writeProtectionCheck, shellReadCheck, crossBoundaryCheck, readFace, irreversibilityTier, reversibilityProbes, abortController, shellGatedTools, autoModeDecider, autoModeDenialTracking, askRoute, notResumable, permissionMode, toolMarkSources, a2aIsolatePeers, ancestorArbitrations, runId, stopForDenialLimit, permissionRuleLane, permissionRuleOrgLane, questionToolMounted, sandboxAdmissionArmed, sandboxBoundaryCapable, emitSandboxAdmitted, delegation, frameSettlement, seatInputsFor, modBus, inheritedInstallations, commandSandboxArmed, sandboxPlanOf } = input;
|
|
55
55
|
const noticeAddress = legNotice.route.address;
|
|
56
56
|
const admitsLegNotice = legNotice.admission;
|
|
57
57
|
const releasesAnnounced = new Map();
|
|
@@ -111,7 +111,7 @@ export function prepareGateStations(input) {
|
|
|
111
111
|
const finalInput = frozenInputSnapshot(e.input);
|
|
112
112
|
toolOccurrences.gateRound(e.toolCallId, gate, finalInput);
|
|
113
113
|
if (notifyPermissionDenied) {
|
|
114
|
-
await notifyPermissionDenied({ toolName: e.toolName,
|
|
114
|
+
await notifyPermissionDenied(permissionDeniedOf({ toolName: e.toolName, finalInput, toolCallId: e.toolCallId, reason: complianceDeny, gate, identity: hookIdentity, permissionMode: permissionMode.observed }));
|
|
115
115
|
}
|
|
116
116
|
return { block: true, reason: formatHookFeedback(complianceDeny, reminderMark), preToolContext: [] };
|
|
117
117
|
}
|
|
@@ -147,6 +147,7 @@ export function prepareGateStations(input) {
|
|
|
147
147
|
shellGated: tierSeat?.shellGated(shellGatedTools, toolMarkSources) === true,
|
|
148
148
|
...(autoModeDecider.current !== undefined ? { autoMode: { decider: heldWhileClassifying(autoModeDecider.current, toolOccurrences.whileClassifying), ...(autoModeDenialTracking.current !== undefined ? { denialTracking: autoModeDenialTracking.current } : {}), unavailable: classifierUnavailableSeat({ station: "leg", ...(autoModeDecider.current.timeoutMs !== undefined ? { budgetMs: autoModeDecider.current.timeoutMs } : {}), route: approvalRouteOf(askRoute), onNotice: deps.onNotice, admission: admitsLegNotice, ...noticeAddress, runId }) } } : {}),
|
|
149
149
|
permissionMode: () => permissionMode.current, askSeatForm: askRoute.form,
|
|
150
|
+
...(notResumable !== undefined ? { notResumable } : {}),
|
|
150
151
|
...(markSources.size > 0 ? { toolMarkSources: markSources } : {}),
|
|
151
152
|
...seatInputsFor(e.toolName, wireOf("gate.skillActivationSeat", call)),
|
|
152
153
|
...(mountedToolRequiresUserInteraction(tools, e.toolName) ? { requiresUserInteraction: true } : {}),
|
|
@@ -154,7 +155,7 @@ export function prepareGateStations(input) {
|
|
|
154
155
|
onModeReleased,
|
|
155
156
|
ancestorArbitrationOf: (toolCallId) => ancestorArbitrations.get(toolCallId),
|
|
156
157
|
onHeadlessDenialLimit: stopForDenialLimit,
|
|
157
|
-
onAskUnresolvable: (info) => deliverEngineNotice(deps.onNotice, askUnresolvableNotice({ ...noticeAddress, ...info }), admitsLegNotice),
|
|
158
|
+
onAskUnresolvable: (info) => (refusedAsks.push(refusedAskOf(info)), deliverEngineNotice(deps.onNotice, askUnresolvableNotice({ ...noticeAddress, ...info }), admitsLegNotice)),
|
|
158
159
|
...(permissionRuleLane
|
|
159
160
|
? {
|
|
160
161
|
persistedRules: {
|
|
@@ -10,6 +10,7 @@ import type { RunnerDeps, ShellGateDoctrine, TaskSpec } from "../types.js";
|
|
|
10
10
|
import { type Model } from "../../internal/llm.js";
|
|
11
11
|
import type { AgentHarness, AgentTool, ExecutionEnv, WorkspaceState } from "../../internal/harness.js";
|
|
12
12
|
import type { AdvertisedWritableDirs } from "./advertised-writable-dirs.js";
|
|
13
|
+
import type { DeclaredRoot } from "./nested-memory-lane.js";
|
|
13
14
|
import { type ArtifactStoreRef, type GrantReadRoot } from "./read-root-grant.js";
|
|
14
15
|
import type { StoredSession } from "../session.js";
|
|
15
16
|
import type { IrreversibilityTier, PrepareResume, ReversibilityProbes, RunInternals, ToolFaceSnapshot, ToolProgressLane, WriteFaceSeat } from "./contracts.js";
|
|
@@ -100,7 +101,7 @@ export interface PrepareHandsReadFaceInput {
|
|
|
100
101
|
/** borrowed-readonly — the task-spec seats this phase reads, as a Pick over the SAME spec object
|
|
101
102
|
* (R-4). `tools` feeds only the band shadow check; `envFacts` only the advertised scratchpad; `planFile` only the
|
|
102
103
|
* advertised session plan file; `retainBackgroundProcesses` only the band's retain lane (Bash's lifetime sentence + row stamp). */
|
|
103
|
-
spec: Pick<TaskSpec, "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "planFile" | "handsReadOnly" | "readDenyPatterns" | "readFace" | "writeFace" | "oneShot" | "resumeAt" | "retainBackgroundProcesses" | "sessionId" | "tools"
|
|
104
|
+
spec: Pick<TaskSpec, "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "planFile" | "handsReadOnly" | "readDenyPatterns" | "readFace" | "writeFace" | "oneShot" | "resumeAt" | "retainBackgroundProcesses" | "sessionId" | "tools">;
|
|
104
105
|
/** borrowed-readonly — the deployment seats this phase reads, as a Pick over the SAME deps
|
|
105
106
|
* object (R-4: `deps.onError?.()` keeps its receiver; a new deps read must widen this Pick).
|
|
106
107
|
* `readDenyBuiltinTiers`/`readDenyBuiltinExclude` are SNAPSHOTTED before the first await that
|
|
@@ -205,9 +206,9 @@ export interface PrepareHandsReadFaceResult {
|
|
|
205
206
|
content: string;
|
|
206
207
|
}>) => Promise<void>) | undefined;
|
|
207
208
|
/** owned — the leg's startup seed table, filled by {@link seedContextFiles}: canonical key → the whole-file content
|
|
208
|
-
* hash this leg's system prompt holds. The request's copy projection reads it (a whole
|
|
209
|
-
* unchanged file is carried as the "already in your context" sentence
|
|
210
|
-
* hands-less task. */
|
|
209
|
+
* hash this leg's system prompt holds. The request's copy projection reads it (a whole attachment frame of a seeded,
|
|
210
|
+
* unchanged file is carried as the "already in your context" sentence; a Read of it is its contents); no other leg's
|
|
211
|
+
* seed is in it. Empty on a hands-less task. */
|
|
211
212
|
seededCopies: ReadonlyMap<string, string>;
|
|
212
213
|
/** owned — the per-task logical cwd ref (observable `cd`), minted when a real
|
|
213
214
|
* writable shell mounts. The driver stamps it into checkpoints, threads it into worktree tools
|
|
@@ -275,6 +276,10 @@ export interface PrepareHandsReadFaceResult {
|
|
|
275
276
|
* scratchpad), deduped; the driver's envFacts advertisement and attachment readers share the
|
|
276
277
|
* ARRAY identity. Settled here (no mutation after return). */
|
|
277
278
|
additionalRootsCanonical: string[];
|
|
279
|
+
/** owned — the entries the SPEC declared through `additionalDirectories` and nothing else, each its spelling and the canonical form above,
|
|
280
|
+
* in declaration order (an entry that could not be resolved is not here): the instruction-file lane's additional roots — a person-declared
|
|
281
|
+
* working directory can be one, ground the model itself may write (the scratchpad, the memory root, the plan file) cannot. `[]` hands-less. */
|
|
282
|
+
declaredAdditionalRoots: readonly DeclaredRoot[];
|
|
278
283
|
/** owned — the read-only arm of the fence widening (2026-08-05 both-arms ruling); same identity
|
|
279
284
|
* contract as above, and the run's LIVE read-root set: {@link grantReadRoot} is its one writer after prepare,
|
|
280
285
|
* and every read face reads it per call (never a copy). */
|
|
@@ -97,6 +97,7 @@ export function resolveHandsLessReadFace(input) {
|
|
|
97
97
|
handsLessResolvedFace,
|
|
98
98
|
handsLessResolvedWriteFace,
|
|
99
99
|
additionalRootsCanonical: [],
|
|
100
|
+
declaredAdditionalRoots: [],
|
|
100
101
|
additionalReadRootsCanonical: [],
|
|
101
102
|
grantReadRoot: undefined,
|
|
102
103
|
artifactStoreRef: undefined,
|
|
@@ -136,6 +137,7 @@ export async function prepareHandsMount(input) {
|
|
|
136
137
|
const handsLessResolvedWriteFace = undefined;
|
|
137
138
|
const shellGatedTools = new Set();
|
|
138
139
|
const additionalRootsCanonical = [];
|
|
140
|
+
const declaredAdditionalRoots = [];
|
|
139
141
|
const additionalReadRootsCanonical = [];
|
|
140
142
|
let grantReadRoot;
|
|
141
143
|
const artifactStoreRef = { current: undefined };
|
|
@@ -146,13 +148,14 @@ export async function prepareHandsMount(input) {
|
|
|
146
148
|
if (handsEnabled) {
|
|
147
149
|
const rootCanonical = taskRootCanonical;
|
|
148
150
|
attachmentRootCanonical = rootCanonical;
|
|
149
|
-
const canonicalizeExtraDirs = async (dirs, field, sink) => {
|
|
151
|
+
const canonicalizeExtraDirs = async (dirs, field, sink, declared) => {
|
|
150
152
|
for (const dir of dirs ?? []) {
|
|
151
153
|
if (!dir || !dir.trim())
|
|
152
154
|
continue;
|
|
153
155
|
const c = await (advertisedWritableDirs?.canonicalizeDeclaredRoot(dir) ?? executionEnv.canonicalPath(dir));
|
|
154
156
|
if (c.ok) {
|
|
155
157
|
sink.push(c.value);
|
|
158
|
+
declared?.push(Object.freeze({ directory: dir, canonical: c.value }));
|
|
156
159
|
}
|
|
157
160
|
else {
|
|
158
161
|
deps.onError?.(new Error(`${field} entry skipped (cannot canonicalize): ${dir}`), {
|
|
@@ -171,7 +174,7 @@ export async function prepareHandsMount(input) {
|
|
|
171
174
|
}
|
|
172
175
|
}
|
|
173
176
|
};
|
|
174
|
-
await canonicalizeExtraDirs(spec.additionalDirectories, "additionalDirectories", additionalRootsCanonical);
|
|
177
|
+
await canonicalizeExtraDirs(spec.additionalDirectories, "additionalDirectories", additionalRootsCanonical, declaredAdditionalRoots);
|
|
175
178
|
await canonicalizeExtraDirs(spec.additionalReadDirectories, "additionalReadDirectories", additionalReadRootsCanonical);
|
|
176
179
|
if (advertisedWritableDirs !== undefined) {
|
|
177
180
|
if (spec.envFacts?.scratchpadDir)
|
|
@@ -285,7 +288,7 @@ export async function prepareHandsMount(input) {
|
|
|
285
288
|
const entry = readFileState.get(k);
|
|
286
289
|
if (entry === undefined)
|
|
287
290
|
continue;
|
|
288
|
-
const cur = await executionEnv.readTextFile(
|
|
291
|
+
const cur = await executionEnv.readTextFile(k);
|
|
289
292
|
if (cur.ok && entry.hash === sha256(normalizeFileText(cur.value)))
|
|
290
293
|
continue;
|
|
291
294
|
readFileState.delete(k);
|
|
@@ -348,7 +351,7 @@ export async function prepareHandsMount(input) {
|
|
|
348
351
|
exempt: (key) => bgOutputExempt?.(key) === true,
|
|
349
352
|
});
|
|
350
353
|
}
|
|
351
|
-
const valveLeft = valveLeaves(
|
|
354
|
+
const valveLeft = valveLeaves(toolFaceSnapshot.selector);
|
|
352
355
|
const band = createHandsToolkit(executionEnv, readFileState, rootCanonical, {
|
|
353
356
|
...(additionalRootsCanonical.length > 0 ? { additionalRoots: additionalRootsCanonical } : {}),
|
|
354
357
|
writeRoot: input.writeLocation,
|
|
@@ -465,6 +468,7 @@ export async function prepareHandsMount(input) {
|
|
|
465
468
|
readDenyBuiltinTiersActive,
|
|
466
469
|
handsLessResolvedFace,
|
|
467
470
|
additionalRootsCanonical,
|
|
471
|
+
declaredAdditionalRoots,
|
|
468
472
|
additionalReadRootsCanonical,
|
|
469
473
|
grantReadRoot,
|
|
470
474
|
artifactStoreRef,
|
|
@@ -46,11 +46,13 @@ import type { SessionPermissionRules } from "../session-policy-store.js";
|
|
|
46
46
|
import { type SessionStore } from "../session.js";
|
|
47
47
|
import type { PlacementTarget } from "../remote-env.js";
|
|
48
48
|
import { type OnAsk, type ToolPolicy } from "../tool-policy.js";
|
|
49
|
+
import type { ApprovalParkNotResumable } from "../park-resumability.js";
|
|
49
50
|
import type { PathRuleBases } from "../permission-rule-model.js";
|
|
50
51
|
import type { PermissionMode, RunnerDeps, RuntimeCaps, ShellGateDoctrine, TaskEvent, TaskSpec, ToolExecuteContext, ToolSpec } from "../types.js";
|
|
51
52
|
import { PermissionModeController } from "../mode-policy.js";
|
|
52
53
|
import { type SkillGrantTable } from "../skill-grant.js";
|
|
53
54
|
import type { InheritedGate, Prepared, PrepareResume, RunInternals, StopForDenialLimit, ToolFaceSnapshot, WriteFaceSeat } from "./contracts.js";
|
|
55
|
+
import type { RosterSpec } from "./caller-roster.js";
|
|
54
56
|
import type { DelegationSettlementSeat } from "../tool-spec.js";
|
|
55
57
|
import type { ToolMountFacts } from "../tool-mount-facts.js";
|
|
56
58
|
export interface PrepareInheritedGateInput {
|
|
@@ -59,7 +61,7 @@ export interface PrepareInheritedGateInput {
|
|
|
59
61
|
* / `oneShot` / `clientContext` / `principal` / `additionalDirectories` / `additionalReadDirectories` / `envFacts` /
|
|
60
62
|
* `memoryPersistenceCapable` / `getApiKeyAndHeaders` / `backgroundScope` / `enablePlanMode` (the ctx enrichment's
|
|
61
63
|
* trusted seats). Never mutated. */
|
|
62
|
-
spec: Pick<
|
|
64
|
+
spec: Pick<RosterSpec, "durableApproval"> & Pick<TaskSpec, "shellGate" | "onQuestion" | "handsReadOnly" | "interactiveTools" | "oneShot" | "clientContext" | "principal" | "isolationScope" | "additionalDirectories" | "additionalReadDirectories" | "envFacts" | "memoryPersistenceCapable" | "getApiKeyAndHeaders" | "backgroundScope" | "enablePlanMode">;
|
|
63
65
|
/** 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. */
|
|
64
66
|
checkpointSeat: import("../checkpoint-seat.js").CheckpointSeat | undefined;
|
|
65
67
|
/** borrowed-readonly — this leg's checkpoint scope (the driver's one `checkpointScopeOf` derivation): the ctx's `checkpointScopeForChildren`, which every delegation lane copies into its children's internals. */
|
|
@@ -127,6 +129,8 @@ export interface PrepareInheritedGateInput {
|
|
|
127
129
|
mountsCallerTool: (tool: ToolSpec) => boolean;
|
|
128
130
|
/** borrowed-readonly — the ctx's `mountedMcp` seat: the MCP surface the run mounts right now (call-time; the roster is minted after this phase). Present iff the run declared a server. */
|
|
129
131
|
mountedMcp?: () => import("../mounted-mcp.js").MountedMcp;
|
|
132
|
+
/** borrowed-readonly — the ctx's `mcpPool` seat: the run tree's MCP connection pool, which every leg the run spawns leases from. */
|
|
133
|
+
mcpPool?: import("../mcp-connection-pool.js").McpConnectionPool;
|
|
130
134
|
/** borrowed-readonly — the task-level lean switch (ctx seat; absent ⇒ no key). */
|
|
131
135
|
promptLean: ToolExecuteContext["promptLean"];
|
|
132
136
|
/** borrowed-readonly — the resolved interaction posture (ctx seat; absent ⇒ no key). */
|
|
@@ -166,8 +170,9 @@ export interface PrepareInheritedGateInput {
|
|
|
166
170
|
reminderDisclosureCounts: Prepared["reminderDisclosureCounts"];
|
|
167
171
|
/** borrowed-readonly — the file-history fixed point the ctx threads to delegation tools (only when enabled). */
|
|
168
172
|
fileHistoryEnabled: boolean;
|
|
169
|
-
/** borrowed-readonly — see `fileHistoryEnabled
|
|
170
|
-
|
|
173
|
+
/** borrowed-readonly — see `fileHistoryEnabled`; `undefined` when the run has no history scope (its row could not be read), and then no
|
|
174
|
+
* fixed point is threaded. */
|
|
175
|
+
historyScope: string | undefined;
|
|
171
176
|
/** borrowed-readonly — see `fileHistoryEnabled`. */
|
|
172
177
|
historyRoot: string;
|
|
173
178
|
/** borrowed-readonly — see `fileHistoryEnabled`. */
|
|
@@ -178,7 +183,9 @@ export interface PrepareInheritedGateInput {
|
|
|
178
183
|
/** borrowed-readonly — LATE-BOUND: the per-principal entitlements the caps phase resolves after this one; read only inside
|
|
179
184
|
* `inheritedGateForChildren` (the two mandate tests), at spawn time. */
|
|
180
185
|
runtimeCaps: () => RuntimeCaps | undefined;
|
|
181
|
-
/** borrowed-readonly — the driver's one leg fact `approvalParkNotResumable`: the opt-in this leg forwards is its EFFECTIVE one (`effectiveDurableApprovalOf`). */ approvalParkNotResumable:
|
|
186
|
+
/** borrowed-readonly — the driver's one leg fact `approvalParkNotResumable`: the opt-in this leg forwards is its EFFECTIVE one (`effectiveDurableApprovalOf`). */ approvalParkNotResumable: ApprovalParkNotResumable | undefined;
|
|
187
|
+
/** borrowed-readonly — the doors' reading of the host's `durableApproval: false` (the rebound spec carries the opt-in alone): the run's
|
|
188
|
+
* clamp source hands it to every child (`CLAMP_SET.durableApproval`). */ hostApprovalParksNotResumable: boolean;
|
|
182
189
|
/** borrowed-readonly — what the leg hands its descendants of its mods bus (`LegMods.handedDown`: without the skills' own
|
|
183
190
|
* registrations): the chain assembly hands it down as this leg's screening installation. */
|
|
184
191
|
modBus: LegModBus;
|
|
@@ -19,6 +19,7 @@ import { frozenSkillGrants } from "../skill-grant.js";
|
|
|
19
19
|
import { attachRebuiltDenialTrackers, createDenialLimitStop } from "./denial-limit-arms.js";
|
|
20
20
|
import { valveLeaves } from "../../agents/tool-filter.js";
|
|
21
21
|
import { mountRowVerdict } from "../tool-mount-plan.js";
|
|
22
|
+
import { reviewRequestFor } from "../present-plan-tool.js";
|
|
22
23
|
export function prepareInheritedGate(input) {
|
|
23
24
|
const { spec, deps, askSeat, internals, resume, sessions, sessionId, runId, hostTaskId, taskRootFinal, delegationCwd, executionEnv, ownedEnv, lockedPreflight, pathRuleAnchors, toolFaceSnapshot, mountsCallerTool, promptLean, resolvedInteractionPosture, permissionModeSeat, reportUsage, harnessRef, skillGrants, forwardEvent, subagentRetain, taskArtifacts, worktreeIsolation, requestReview, requestStopAfterTurn, enterPlanMode, reminderMark, reminderDisclosureCounts, fileHistoryEnabled, historyScope, historyRoot, historyFs, abortRun } = input;
|
|
24
25
|
const liveInheritedGate = internals?.inheritedGate;
|
|
@@ -179,8 +180,9 @@ export function prepareInheritedGate(input) {
|
|
|
179
180
|
writeFace: carrierWriteFace(),
|
|
180
181
|
readDenyPatterns: input.readDenyAdditionsNormalized(),
|
|
181
182
|
approvalReach: askSeat.reach,
|
|
183
|
+
durableApproval: input.hostApprovalParksNotResumable ? false : undefined,
|
|
182
184
|
});
|
|
183
|
-
const fullShellReachable = mountRowVerdict("bash", input.mountFacts, valveLeaves(
|
|
185
|
+
const fullShellReachable = mountRowVerdict("bash", input.mountFacts, valveLeaves(toolFaceSnapshot.selector));
|
|
184
186
|
const { gateStopRef, stopForDenialLimit } = createDenialLimitStop({ sessionId, runId, onNotice: deps.onNotice, abort: abortRun });
|
|
185
187
|
const delegationEntryCapsResolved = resolveDelegationEntryCaps(deps.delegationEntryCaps);
|
|
186
188
|
const isolationScope = isolationScopeOf(spec);
|
|
@@ -210,6 +212,7 @@ export function prepareInheritedGate(input) {
|
|
|
210
212
|
oneShot: spec.oneShot,
|
|
211
213
|
mountsCallerTool,
|
|
212
214
|
...(input.mountedMcp !== undefined ? { mountedMcp: input.mountedMcp } : {}),
|
|
215
|
+
...(input.mcpPool !== undefined ? { mcpPool: input.mcpPool } : {}),
|
|
213
216
|
parentSpecSeat,
|
|
214
217
|
...(internals?.questionFaceStripped === true ? { questionFaceStripped: true } : {}),
|
|
215
218
|
toolSelector: toolFaceSnapshot.selector,
|
|
@@ -238,7 +241,7 @@ export function prepareInheritedGate(input) {
|
|
|
238
241
|
callerRoot: taskRootFinal,
|
|
239
242
|
...(input.ownTarget !== undefined ? { placementTarget: input.ownTarget } : {}),
|
|
240
243
|
...(input.hostFloor !== undefined ? { hostFloor: input.hostFloor } : {}),
|
|
241
|
-
...(fileHistoryEnabled ? { fileHistoryLineage: { scope: historyScope, root: historyRoot, fs: historyFs } } : {}),
|
|
244
|
+
...(fileHistoryEnabled && historyScope !== undefined ? { fileHistoryLineage: { scope: historyScope, root: historyRoot, fs: historyFs } } : {}),
|
|
242
245
|
reminderMark,
|
|
243
246
|
reminderDisclosureCounts,
|
|
244
247
|
...(centerAdoption !== undefined ? { centerArtifactDigest: centerAdoption.artifact.artifactDigest } : {}),
|
|
@@ -297,10 +300,7 @@ export function prepareInheritedGate(input) {
|
|
|
297
300
|
...(internals?.insideFork === true ? { insideFork: true } : {}),
|
|
298
301
|
...(agentForkDenial !== undefined ? { forkAccess: { denied: agentForkDenial } } : {}),
|
|
299
302
|
...(observersActive ? { observersAllowed: true } : {}),
|
|
300
|
-
requestReview: (opts) => requestReview(
|
|
301
|
-
...(opts?.reason !== undefined ? { reason: opts.reason } : {}),
|
|
302
|
-
...(ctx.reviveClaim === undefined && typeof ctx.toolCallId === "string" && ctx.toolCallId !== "" ? { requestedByCallId: ctx.toolCallId } : {}),
|
|
303
|
-
}),
|
|
303
|
+
requestReview: (opts) => requestReview(reviewRequestFor(ctx, opts?.reason)),
|
|
304
304
|
requestStopAfterTurn,
|
|
305
305
|
...(spec.enablePlanMode === true ? { enterPlanMode } : {}),
|
|
306
306
|
};
|
|
@@ -5,7 +5,7 @@ import type { ResolvedSkillListingBudget } from "../skill-listing-budget.js";
|
|
|
5
5
|
export interface PrepareListingsInput {
|
|
6
6
|
/** borrowed-readonly — the REBOUND spec (`spec′`). Read: `tools` (the roster-bearing delegation tool, by its `agentListing`
|
|
7
7
|
* marker), `sessionId` (continuation ⇒ seeded/removal projections), `attachments` (the two opt-outs). Never mutated. */
|
|
8
|
-
spec: Pick<TaskSpec, "agents" | "tools" | "sessionId" | "attachments"
|
|
8
|
+
spec: Pick<TaskSpec, "agents" | "tools" | "sessionId" | "attachments">;
|
|
9
9
|
/** borrowed-readonly — the once-per-session ledger: its deduplicated operator sink (`onError`) and
|
|
10
10
|
* the whole announced snapshot (`arms()`) the mirror is seeded from. */
|
|
11
11
|
onceLedger: AnnounceOnceSink & {
|
|
@@ -5,7 +5,7 @@ import { renderAgentListingDelta } from "./turn-attachments.js";
|
|
|
5
5
|
export function prepareListings(input) {
|
|
6
6
|
const { spec, onceLedger, sessionId, toolFaceSnapshot, activeTools, deferred, resume, skillsListing, listingBudget, listingRideRef, renderWithDate, envFacts, tzValid, userTz, dateAnchor } = input;
|
|
7
7
|
const rosterBearingSpec = (spec.tools ?? []).find((t) => t.agentListing !== undefined && t.agentListing.length > 0);
|
|
8
|
-
const leaves = valveLeaves(
|
|
8
|
+
const leaves = valveLeaves(toolFaceSnapshot.selector);
|
|
9
9
|
const rosterFaceDeferred = rosterBearingSpec !== undefined &&
|
|
10
10
|
leaves(rosterBearingSpec) &&
|
|
11
11
|
(toolFaceSnapshot.defer?.includes(rosterBearingSpec.name) ?? false) &&
|
|
@@ -8,7 +8,7 @@ import { deriveSupersededSet, fileGovernanceStore, fileSessionCaptureRecordStore
|
|
|
8
8
|
import { shadowNamesOf } from "../memory-engine/shadowing.js";
|
|
9
9
|
import { mintSystemReminder } from "../reminder-mint.js";
|
|
10
10
|
import { MEMORY_ANNOUNCEMENT_CAPTURE_OPTOUT_CODA, MEMORY_ANNOUNCEMENT_READONLY_CODA, MEMORY_CAPTURE_OPTOUT_NOTICE, MEMORY_PREFERENCE_DISCIPLINE, MEMORY_READONLY_NOTICE, MemoryEngine, memoryCaptureOptedOutNotice, memoryCaptureOptOutUnpersistedNotice, memoryConsolidationRecommendedNotice, memoryHarvestConflictNotice, memoryHarvestQuarantinedNotice, memoryHarvestRefusedNotice, memoryHoldNotices, memoryRecallDisciplineSegment, memoryRestoreWithheldNotice, memorySessionPollutedNotice, memoryUnavailableNotice, pollutionContainmentCounts, } from "../memory-engine/engine.js";
|
|
11
|
-
import {
|
|
11
|
+
import { memoryMountFailedNotice, memoryMountFailedReadingOf } from "../memory-engine/mount-failed-notice.js";
|
|
12
12
|
import { adjudicateCaptureOptOut, captureOptOutDeniedError, captureOptOutUnpersistedError } from "./memory-capture-optout.js";
|
|
13
13
|
import { sessionIncarnationResolver } from "../memory-engine/session-incarnation.js";
|
|
14
14
|
import { createMemoryEngineTools } from "../memory-engine/tools.js";
|
|
@@ -799,7 +799,7 @@ export async function prepareMemory(input) {
|
|
|
799
799
|
writeScope: null,
|
|
800
800
|
...(materializedResidue.length > 0 ? { materializedResidue: [...new Set(materializedResidue)] } : {}),
|
|
801
801
|
};
|
|
802
|
-
deliverEngineNotice(deps.onNotice, memoryMountFailedNotice({ sessionId, scopes: [...new Set([...memorySpec.scopes, ...(memorySpec.writeScope !== null ? [memorySpec.writeScope] : [])])],
|
|
802
|
+
deliverEngineNotice(deps.onNotice, memoryMountFailedNotice({ sessionId, scopes: [...new Set([...memorySpec.scopes, ...(memorySpec.writeScope !== null ? [memorySpec.writeScope] : [])])], ...memoryMountFailedReadingOf(err) }));
|
|
803
803
|
}
|
|
804
804
|
}
|
|
805
805
|
}
|
|
@@ -6,7 +6,7 @@ import type { ToolSelector } from "../tool-face.js";
|
|
|
6
6
|
export interface PrepareOffloadWrappersInput {
|
|
7
7
|
/** borrowed-readonly — the REBOUND spec (the config-doors result); read for the per-task coarse
|
|
8
8
|
* offload knob only. */
|
|
9
|
-
spec: Pick<TaskSpec, "toolResultThresholdChars"
|
|
9
|
+
spec: Pick<TaskSpec, "toolResultThresholdChars">;
|
|
10
10
|
/** borrowed-readonly — the leg's compiled selector, read through the valve (`valveLeaves`): an offloaded result is read back through the
|
|
11
11
|
* reader tool, so a leg whose valve does not leave the reader (a sub-agent whose lists leave it out, a deployment that excludes it, a
|
|
12
12
|
* run whose whole face is switched off) offloads nothing — a preview that sends the model to a tool it does not have is a dead end. */
|