@sema-agent/core 7.67.3 → 7.68.1
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 +1537 -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/open-responses.js +3 -1
- package/dist/brain/openai.js +3 -1
- 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 +45 -2
- package/dist/core/checkpoint-requirements.js +16 -6
- 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 +20 -14
- package/dist/core/protocol-http-auth.js +70 -50
- 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 +18 -0
- package/dist/core/tool-roster.js +30 -1
- 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 +10 -9
- package/dist/core/untrusted-egress.js +9 -9
- package/dist/core/untrusted-text.d.ts +0 -18
- package/dist/core/untrusted-text.js +7 -3
- 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.68.0.json +39 -0
- package/wire-changes/core-stores-sql@7.68.1.json +39 -0
- package/wire-changes/core@7.68.0.json +4257 -0
- package/wire-changes/core@7.68.1.json +95 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/mods-kernel@7.68.1.json +39 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/primitives@7.68.1.json +39 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/wire-changes/wiki-gate@7.68.1.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
import { type AgentHarness } from "../../internal/harness.js";
|
|
17
17
|
import { type WindowBelowOverhead } from "../auto-compaction.js";
|
|
18
18
|
import type { PlatformLimitReason } from "../checkpoint-store.js";
|
|
19
|
-
import type { TaskSpec } from "../types.js";
|
|
19
|
+
import type { EngineNotice, TaskResult, TaskSpec } from "../types.js";
|
|
20
20
|
import type { Prepared, RunState } from "./contracts.js";
|
|
21
21
|
/**
|
|
22
22
|
* The LIMIT-APPROACH frames, the successor to the retired deadline-nudge family. Two facts
|
|
@@ -51,6 +51,27 @@ export declare function resolveMaxTurns(limits?: {
|
|
|
51
51
|
* monotonic clock? The one reading the boundary's resource-slice park and the stop gate's "is the run ending" share: past a
|
|
52
52
|
* crossed axis a run parks only while it owes a request, and no hook or verification may manufacture another one. */
|
|
53
53
|
export declare function taskAxisCrossed(limits: Pick<RunState["limits"], "turnsExceeded" | "budgetHit">, walltimeMonotonicDeadline: number | undefined): boolean;
|
|
54
|
+
/** The task axis a run ended past and the two figures its crossing compared — the ONE evaluation of "which axis" that the result's
|
|
55
|
+
* `limitCrossed` and the `task.completed_past_limit` notice both read, at the leg's settle. Strictly past: a ceiling met exactly, or a turn cap
|
|
56
|
+
* reached on the answer, is a run that used its allowance — nothing is reported (and a completed run cannot be past its turn cap: reaching it
|
|
57
|
+
* with a turn owed is a failure or a park). First of tokens, cost, walltime (the order a park attributes in). The operands are the crossing
|
|
58
|
+
* predicates' own: the effective token window against `stats.tokens`, the cost ceiling against `stats.costMicroUsd` — each read where the
|
|
59
|
+
* engine's budget check recorded it (the turn-end handler's hit, or, for a turn that also reached the cap, the same check at that instant) —
|
|
60
|
+
* and the declared window against the ms the boundary read (the timer's firing, with the settle's own elapsed ms, when no boundary saw it). */
|
|
61
|
+
export declare function limitCrossedOf(r: {
|
|
62
|
+
limits: Pick<RunState["limits"], "budgetHit" | "budgetAxis" | "budgetOverAtTurnCap" | "walltimeCrossedMs">;
|
|
63
|
+
budget: Pick<RunState["budget"], "maxTokensWindow" | "maxCostMicroUsd">;
|
|
64
|
+
stats: {
|
|
65
|
+
tokens: number;
|
|
66
|
+
costMicroUsd: number;
|
|
67
|
+
};
|
|
68
|
+
walltimeLimitMs: number | undefined;
|
|
69
|
+
walltimeTimerFired: boolean;
|
|
70
|
+
elapsedMs: number;
|
|
71
|
+
}): TaskResult["limitCrossed"];
|
|
72
|
+
/** The notice for a run that completed past a task axis: the axis, the ceiling, the figure, and why the verdict stands. `ids` are the run's
|
|
73
|
+
* attribution keys (`sessionId`, `runId`, the leg's task id), carried in `detail` beside the three facts. */
|
|
74
|
+
export declare function completedPastLimitNotice(crossed: NonNullable<TaskResult["limitCrossed"]>, ids: Record<string, string>): EngineNotice;
|
|
54
75
|
/**
|
|
55
76
|
* How long past the environment's suspend deadline the turn-boundary lane will keep waiting for the
|
|
56
77
|
* usage ledger's READ.
|
|
@@ -20,6 +20,36 @@ export function resolveMaxTurns(limits) {
|
|
|
20
20
|
export function taskAxisCrossed(limits, walltimeMonotonicDeadline) {
|
|
21
21
|
return limits.turnsExceeded || limits.budgetHit !== undefined || (walltimeMonotonicDeadline !== undefined && performance.now() >= walltimeMonotonicDeadline);
|
|
22
22
|
}
|
|
23
|
+
export function limitCrossedOf(r) {
|
|
24
|
+
const { limits, budget, stats } = r;
|
|
25
|
+
const budgetAxis = limits.budgetHit === "exceeded" ? limits.budgetAxis : limits.budgetOverAtTurnCap;
|
|
26
|
+
const walltimeCrossed = limits.walltimeCrossedMs !== undefined || r.walltimeTimerFired;
|
|
27
|
+
const walltimeObserved = limits.walltimeCrossedMs ?? r.elapsedMs;
|
|
28
|
+
const candidates = [
|
|
29
|
+
["budget_tokens", budget.maxTokensWindow, stats.tokens, budgetAxis === "tokens"],
|
|
30
|
+
["budget_cost", budget.maxCostMicroUsd, stats.costMicroUsd, budgetAxis === "cost"],
|
|
31
|
+
["walltime", r.walltimeLimitMs, walltimeObserved, walltimeCrossed],
|
|
32
|
+
];
|
|
33
|
+
for (const [axis, limit, observed, crossed] of candidates) {
|
|
34
|
+
if (!crossed || limit === undefined || observed <= limit)
|
|
35
|
+
continue;
|
|
36
|
+
return { axis, limit, observed };
|
|
37
|
+
}
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
const CROSSED_AXIS_PHRASE = {
|
|
41
|
+
budget_tokens: (c) => `its token ceiling (${c.limit} tokens; ${c.observed} used)`,
|
|
42
|
+
budget_cost: (c) => `its cost ceiling ($${c.limit / 1_000_000}; $${c.observed / 1_000_000} spent)`,
|
|
43
|
+
walltime: (c) => `its wall-clock window (${c.limit} ms; ${c.observed} ms elapsed)`,
|
|
44
|
+
};
|
|
45
|
+
export function completedPastLimitNotice(crossed, ids) {
|
|
46
|
+
return {
|
|
47
|
+
code: "task.completed_past_limit",
|
|
48
|
+
message: `The run completed past ${CROSSED_AXIS_PHRASE[crossed.axis](crossed)}: its last turn answered and owed no further request, so nothing was cut and nothing is owed — the run ends completed. ` +
|
|
49
|
+
"The axis and both figures are on the result's limitCrossed (tokens, micro-USD or milliseconds by axis).",
|
|
50
|
+
detail: { axis: crossed.axis, limit: crossed.limit, observed: crossed.observed, ...ids },
|
|
51
|
+
};
|
|
52
|
+
}
|
|
23
53
|
export const ENV_DUE_GOVERNANCE_READ_BUDGET_MS = 5_000;
|
|
24
54
|
const MAX_TIMER_DELAY_MS = 2_147_483_647;
|
|
25
55
|
const DEADLINE_TICK = Symbol("deadline-tick");
|
|
@@ -871,6 +871,9 @@ export interface Prepared {
|
|
|
871
871
|
* failed. Resume-leg failures do NOT land here (that leg throws out of prepare before a `Prepared`
|
|
872
872
|
* exists) — they ride the thrown error's `remoteEnvFailure` carrier instead. */
|
|
873
873
|
remoteEnvFailures: NonNullable<TaskResult["remoteEnvFailures"]>;
|
|
874
|
+
/** The asks this run refused because nobody could answer them, appended by the gate's deny exit (beside its notice) and echoed on
|
|
875
|
+
* `TaskResult.refusedAsks` when non-empty. */
|
|
876
|
+
refusedAsks: import("../task-result.js").RefusedAsk[];
|
|
874
877
|
/** Set when a suspend was REFUSED because the task already suspended `maxSuspends`
|
|
875
878
|
* times (a resume/restart loop) — the run is aborted and assembles as `failed`/`suspend.loop` instead
|
|
876
879
|
* of minting yet another checkpoint. */
|
|
@@ -980,18 +983,20 @@ export interface Prepared {
|
|
|
980
983
|
stopForDenialLimit: StopForDenialLimit;
|
|
981
984
|
/** Set by a tool calling `ctx.requestReview()` (the first-party `present_plan` tool, CC
|
|
982
985
|
* ExitPlanMode parity): the run loop honors it at the next CLEAN turn boundary by minting a `plan_review`
|
|
983
|
-
* checkpoint. `{ pending }` is set (with an optional reason) the moment a tool requests review
|
|
984
|
-
* reads
|
|
985
|
-
* engine-bound id of the call that asked, which the mint
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
986
|
+
* checkpoint. `{ pending }` is set (with an optional reason) the moment a tool requests review, the batch's other
|
|
987
|
+
* requests queue in `later`; the boundary reads `pending` and clears both. The first request in a batch that may still
|
|
988
|
+
* show a plan wins, and so does its `requestedByCallId` — the engine-bound id of the call that asked, which the mint
|
|
989
|
+
* writes onto the parked row — and what that call's final result showed, recorded where the call's end is projected:
|
|
990
|
+
* the plan its card carried (`presented`, whose digest the mint writes), or why it showed a reviewer nothing
|
|
991
|
+
* (`withdrawn`: it yields to the next request; the first, if all are withdrawn, the mint refuses). */
|
|
992
|
+
reviewRequestRef: import("../present-plan-tool.js").ReviewRequestCell;
|
|
989
993
|
/** Present (≠ undefined) ONLY when a `checkpointStore` is wired (the deployment can pause). The
|
|
990
|
-
* run loop calls it at a CLEAN turn boundary when `reviewRequestRef.pending` is set: it
|
|
991
|
-
* checkpoint (`status:"needs_review"` by its registry row) + pauses the workspace + aborts the loop,
|
|
992
|
-
* the SAME commit saga as the human/resource suspends. Returns true iff it committed a resumable checkpoint;
|
|
993
|
-
* false ⇒ the request could not be honored (caller drops it and continues)
|
|
994
|
-
|
|
994
|
+
* run loop calls it at a CLEAN turn boundary with the pending request, whole, when `reviewRequestRef.pending` is set: it
|
|
995
|
+
* mints a `plan_review` checkpoint (`status:"needs_review"` by its registry row) + pauses the workspace + aborts the loop,
|
|
996
|
+
* reusing the SAME commit saga as the human/resource suspends. Returns true iff it committed a resumable checkpoint;
|
|
997
|
+
* false ⇒ the request could not be honored (caller drops it and continues) — a `withdrawn` request among them, said on
|
|
998
|
+
* the error face in the one `plan_review park skipped: …` sentence. */
|
|
999
|
+
suspendForReview?: (request: import("../present-plan-tool.js").PendingReview) => Promise<boolean>;
|
|
995
1000
|
/** The prior cross-slice {@link ResourceLedger} (from the resumed checkpoint), so the run
|
|
996
1001
|
* loop can size this slice's effective budget = `min(maxCostUsd, remaining)`. Undefined on the first slice
|
|
997
1002
|
* (or a non-resource task). */
|
|
@@ -1077,12 +1082,12 @@ export interface Prepared {
|
|
|
1077
1082
|
*/
|
|
1078
1083
|
toolRosterDeltas: import("../tool-roster.js").ToolRosterDeltaSeat;
|
|
1079
1084
|
/**
|
|
1080
|
-
* The leg's `tool_end.structured`
|
|
1085
|
+
* The leg's card projector (`tool_end.structured` / `structuredSkeleton`): the engine card set ∪ the caller rows' declared
|
|
1081
1086
|
* `renderHints.resultCards`; an undeclared `details.type` is dropped and announced ONCE per leg
|
|
1082
1087
|
* (`config.tool_card_undeclared`). The ONE card port: every tool_end body projection (the live loop, the resumed
|
|
1083
1088
|
* batch, the reconcile-recovered orphan) takes it as a parameter; no module-level card set exists to fall back to.
|
|
1084
1089
|
*/
|
|
1085
|
-
structuredProjector: (
|
|
1090
|
+
structuredProjector: import("./tool-output-projection.js").CardProjector;
|
|
1086
1091
|
/** Name→effect map for every tool this task can call. Used by the abort-path orphan
|
|
1087
1092
|
* reconcile to make interrupted tool_results effect-aware (read/idempotent = safe to
|
|
1088
1093
|
* repeat; write/unknown = outcome unknown). Unknown names default to `write` (conservative). */
|
|
@@ -1405,11 +1410,6 @@ export interface PrepareResume {
|
|
|
1405
1410
|
/** Batch tool-call ids of the suspended turn — wake-reconcile SKIPS these (they are resumed, not
|
|
1406
1411
|
* crash-interrupted; closing them with `[INTERRUPTED]` would DESTROY the suspended batch, §15.2 #7). */
|
|
1407
1412
|
suspendedBatch: ReadonlySet<string>;
|
|
1408
|
-
/** The parked row's own synchronous-child block (`Checkpoint.parentSessionId` / `parentTaskId` / `rootSessionId` / `rootSessionIncarnation`),
|
|
1409
|
-
* for a synchronous child's resumed leg that is handed no spawner internals: the next row it parks records the same block. It is read
|
|
1410
|
-
* into the park mint only — never folded into the leg's internals, whose root and parent members steer notice routing and placement.
|
|
1411
|
-
* Absent ⇒ the row recorded none. */
|
|
1412
|
-
syncChildBlockOfRow?: import("../leg-identity.js").SyncChildBlock;
|
|
1413
1413
|
/** The §4.bis correctness-state snapshot to re-seed (activeTools / outputRef / nestedStats /
|
|
1414
1414
|
* readFileState). */
|
|
1415
1415
|
seed: CheckpointState;
|
|
@@ -1732,9 +1732,10 @@ export interface PromptFeatureFlags {
|
|
|
1732
1732
|
*/
|
|
1733
1733
|
export interface RunInternals {
|
|
1734
1734
|
/**
|
|
1735
|
-
* The MCP connection pool of this leg's run tree (a delegation tool
|
|
1736
|
-
*
|
|
1737
|
-
* releases the lease when its materialization is disposed
|
|
1735
|
+
* The MCP connection pool of this leg's run tree (a delegation tool and a workflow hand theirs down to every leg they spawn; a
|
|
1736
|
+
* Runner's root leg takes its session's, {@link sessionMcpPools}). A leg that declares a server leases the connection from it instead
|
|
1737
|
+
* of dialling a copy, releases the lease when its materialization is disposed, and reads the pool's memory of a failed attempt —
|
|
1738
|
+
* see `mcp-connection-pool.ts`. Trusted, never a TaskSpec field.
|
|
1738
1739
|
*/
|
|
1739
1740
|
mcpPool?: import("../mcp-connection-pool.js").McpConnectionPool;
|
|
1740
1741
|
/** This leg's host seats by declaration name: a `{ kind: "host" }` server of `TaskSpec.mcp` / `ResumeTaskConfig.mcp` dials through the
|
|
@@ -1776,6 +1777,12 @@ export interface RunInternals {
|
|
|
1776
1777
|
};
|
|
1777
1778
|
/** Set only on an observer sidecar's legs: the leg kind whose protocol is the observer's report tool. */
|
|
1778
1779
|
observerLeg?: true;
|
|
1780
|
+
/** Set by an engine lane that HOLDS this leg's parks — a background lane that can park the child (a durable row store, the store the
|
|
1781
|
+
* child parks in, durable child sessions) and a workflow whose park lane is armed (a run store and its checkpoint store), on every leg
|
|
1782
|
+
* they run (the first start, a revival, a parked-resume drive). A leg this run started on an engine lane ({@link isDelegatedChild},
|
|
1783
|
+
* {@link observerLeg}) WITHOUT it is a leg nobody resumes: none of its parks is minted (`approvalParkNotResumableOf`, source `lane`).
|
|
1784
|
+
* Never on a retained agent's snapshot: its wake cycle settles a pause as failed and holds no park. Trusted, never a TaskSpec field. */
|
|
1785
|
+
parkLaneHeld?: true;
|
|
1779
1786
|
/** The live repair bundle from a `runRepairLoop` attempt in flight (attemptCount>0). Serialized onto a
|
|
1780
1787
|
* checkpoint minted MID-attempt so a resume re-seeds it; undefined for any non-repair run. */
|
|
1781
1788
|
repairBundle?: RepairBundle;
|
|
@@ -1814,9 +1821,12 @@ export interface RunInternals {
|
|
|
1814
1821
|
* `resumeStream`): the checkpoint is already consumed, so the caller's compensation
|
|
1815
1822
|
* (`rollbackParkedClaim`) reads `resolved` and settles the honest failed/outcome-unknown terminal
|
|
1816
1823
|
* — never a silent run without an adopted row. Deployment/trusted-caller channel only, mirroring
|
|
1817
|
-
* every other RunInternals field.
|
|
1824
|
+
* every other RunInternals field. It may state back `cycleSeq`, the number its claim wrote on the row: the resumed leg
|
|
1825
|
+
* runs as that cycle ({@link RunInternals.cycleSeq}); the runner never computes one, and `void` leaves the internals as is.
|
|
1818
1826
|
*/
|
|
1819
|
-
afterCheckpointResolve?: () => Promise<void
|
|
1827
|
+
afterCheckpointResolve?: () => Promise<void | {
|
|
1828
|
+
cycleSeq: number;
|
|
1829
|
+
}>;
|
|
1820
1830
|
/**
|
|
1821
1831
|
* Parent effective-policy inheritance (tighten-only): the spawning parent's already-evaluated FINAL
|
|
1822
1832
|
* gate, threaded into a child task so the child inherits it as ADDITIONAL constraint layers — a child
|
|
@@ -2107,9 +2117,9 @@ export interface RunInternals {
|
|
|
2107
2117
|
*/
|
|
2108
2118
|
delegationTaskType?: import("../types.js").DelegationTaskType;
|
|
2109
2119
|
/**
|
|
2110
|
-
* The stop-cycle
|
|
2111
|
-
*
|
|
2112
|
-
*
|
|
2120
|
+
* The stop-cycle number this run executes as (fresh spawn = 1; a wake: the number its claim wrote on the row; a parked
|
|
2121
|
+
* resume: what its consume hook states; a synchronously born child's wake: its resume face's count), threaded by the
|
|
2122
|
+
* BACKGROUND delegation lanes and a retained child's wake from the registry's `cycleSeq`, so every `task_progress` tick the
|
|
2113
2123
|
* run mints carries it as `seq` (same axis as `TaskNotificationPayload.seq` / `BackgroundChildEvent.seq`). Absent
|
|
2114
2124
|
* on a first synchronous cycle, on workflow agents and top-level runs (INTEGRATION-CORE §1.6a), and on a delegated
|
|
2115
2125
|
* child's checkpoint a host redeems without the lane's internals (KL-3824-a). TRUSTED run-scoped channel (never a TaskSpec field).
|
|
@@ -2285,6 +2295,13 @@ export interface RunInternals {
|
|
|
2285
2295
|
* channel, same posture as every other field here.
|
|
2286
2296
|
*/
|
|
2287
2297
|
sessionReadStates?: SessionReadFileStates;
|
|
2298
|
+
/**
|
|
2299
|
+
* The per-session MCP pools of the Runner's session store (`sessionMcpPoolsOf(store)`, mcp-connection-pool.ts — every Runner over one
|
|
2300
|
+
* store reads one table): a leg handed no {@link mcpPool} leases from the pool of its own session, so a server whose connection attempt
|
|
2301
|
+
* failed is not dialed again by the session's next message, whichever of those Runners runs it. Always set by the Runner's own prepare call (overriding any caller value, like the seats
|
|
2302
|
+
* beside it); absent on a standalone prepareTask, whose leg makes a pool that dies with it. A CACHE, never an authority.
|
|
2303
|
+
*/
|
|
2304
|
+
sessionMcpPools?: import("../mcp-connection-pool.js").SessionMcpPools;
|
|
2288
2305
|
/**
|
|
2289
2306
|
* The Runner's per-session permission-mode seats ({@link SessionModeSeats}): the chain a leg hands its children
|
|
2290
2307
|
* carries its SESSION's seat as the children's ceiling, and each leg binds itself to that seat once its prepare
|
|
@@ -2381,7 +2398,7 @@ export interface RunInternals {
|
|
|
2381
2398
|
* identity of {@link fileHistoryFilesystemIdentity}) — threaded VERBATIM by core delegation
|
|
2382
2399
|
* callers from {@link import("../types.js").ToolExecuteContext.fileHistoryLineage} (NEVER a
|
|
2383
2400
|
* {@link TaskSpec} field). {@link resolveFileHistoryScope} is the ONE reading: this run records
|
|
2384
|
-
* into the lineage's scope iff its own tree coordinates BOTH equal the lineage's, and then
|
|
2401
|
+
* into the lineage's scope iff its own tree coordinates BOTH equal the lineage's (a run at its caller's root, {@link callerRoot}, on the lineage's filesystem keys against the lineage's root — a `workspace: null` caller's is its session's root, not where it stands), and then
|
|
2385
2402
|
* re-exposes the SAME triple on its own ctx, so every same-tree descendant of a root session — at
|
|
2386
2403
|
* any depth — lands in the root session's scope (the fixed point), while a descendant on another
|
|
2387
2404
|
* tree (worktree isolation, explicit `cwd`, a fresh per-task sandbox) becomes the root of its own
|
|
@@ -2609,11 +2626,6 @@ export interface SuspendSaga {
|
|
|
2609
2626
|
parkOnlyRemoteEnv: RemoteExecutionEnv | undefined;
|
|
2610
2627
|
/** The park-only identity capture (snapshotId stripped, `restoreMode: "park_only"`). */
|
|
2611
2628
|
parkOnlyHandle: (env: RemoteExecutionEnv) => WorkspaceHandle;
|
|
2612
|
-
/** The synchronous-child block every row this leg parks records beside its identity ({@link import("../leg-identity.js").syncChildBlockOf}):
|
|
2613
|
-
* the spawning run's session and task, the tree's root session and its occupant — present only on a synchronous child's leg, empty on a
|
|
2614
|
-
* root run's, a background child's and a workflow agent's. Read once at prepare, so the approval, `resource_limit` and `plan_review` mints stamp the one
|
|
2615
|
-
* value (`Checkpoint.parentSessionId` / `parentTaskId` / `rootSessionId` / `rootSessionIncarnation`). */
|
|
2616
|
-
syncChildBlock: import("../leg-identity.js").SyncChildBlock;
|
|
2617
2629
|
}
|
|
2618
2630
|
/** The park closure and the content-ask routing closure the gate station hands to `runToolGate`. Built as ONE value so
|
|
2619
2631
|
* "the park lane's closures exist" is one fact; `suspendAsk` stays optional INSIDE it because the park predicate (a store,
|
|
@@ -2710,6 +2722,13 @@ export interface RunState {
|
|
|
2710
2722
|
}) | undefined;
|
|
2711
2723
|
outputRetryCap: number;
|
|
2712
2724
|
effectiveMaxTurns: number | undefined;
|
|
2725
|
+
/** The ms the walltime window read as passed at the first turn boundary that found it passed (the boundary's own reading of the
|
|
2726
|
+
* monotonic clock, taken where the park decision reads it) — the figure `TaskResult.limitCrossed` reports for the walltime axis, so
|
|
2727
|
+
* work done after the answer cannot move it. `undefined` = no boundary has found the window passed. */
|
|
2728
|
+
walltimeCrossedMs: number | undefined;
|
|
2729
|
+
/** The budget axis over its ceiling at the instant a turn REACHED the turn cap — the turn-end handler records the cap and runs its budget check only on the other arm, so
|
|
2730
|
+
* a turn that does both leaves `budgetHit` unset; this is that same check, read where the cap is recorded, for `TaskResult.limitCrossed` alone. */
|
|
2731
|
+
budgetOverAtTurnCap: BudgetAxis | undefined;
|
|
2713
2732
|
};
|
|
2714
2733
|
budget: {
|
|
2715
2734
|
remainingMicroUsd: number | undefined;
|
|
@@ -2738,6 +2757,7 @@ export interface RunState {
|
|
|
2738
2757
|
cacheReadTokens: number;
|
|
2739
2758
|
cacheWriteTokens: number;
|
|
2740
2759
|
costMicroUsd: number;
|
|
2760
|
+
apiDurationMs: number;
|
|
2741
2761
|
} | undefined;
|
|
2742
2762
|
turnUsageMissing: boolean;
|
|
2743
2763
|
/** The turn's cache marks as `turn_end` carries them (some call of the turn did not report its cache reads / writes;
|
|
@@ -3188,8 +3208,8 @@ export interface TaskIdRef {
|
|
|
3188
3208
|
intake?: TaskResult["intake"];
|
|
3189
3209
|
}
|
|
3190
3210
|
/** The manual `/compact` request seat: the `requested` flag, the parked waiters (each with its
|
|
3191
|
-
* caller's cancel signal and per-call instructions)
|
|
3192
|
-
*
|
|
3211
|
+
* caller's cancel signal and per-call instructions) and the run body's mooted-frame channel. Whether a new request may
|
|
3212
|
+
* park at all is not kept here: it is the stream's input judge ({@link TaskStreamLiveSeat.bodySettled} is its run-end fact). */
|
|
3193
3213
|
export interface ManualCompactRef {
|
|
3194
3214
|
requested: boolean;
|
|
3195
3215
|
/** `requestedBy`: the extension a `$.session.compact` request came from (absent on a host `compact()` request) — the
|
|
@@ -3201,7 +3221,6 @@ export interface ManualCompactRef {
|
|
|
3201
3221
|
requestedBy?: import("../task-event.js").ExtensionRequester;
|
|
3202
3222
|
}>;
|
|
3203
3223
|
emitMooted?: (reason: string) => void;
|
|
3204
|
-
closed?: boolean;
|
|
3205
3224
|
}
|
|
3206
3225
|
/**
|
|
3207
3226
|
* The end-of-task compaction pass's outcome (`Runner.finish`'s return): what the terminal-adoption lane
|
|
@@ -3259,6 +3278,10 @@ export interface TaskStreamLiveSeat {
|
|
|
3259
3278
|
resultValue: TaskResult | undefined;
|
|
3260
3279
|
/** The live-task handle once `runLocked` published it; `undefined` before, and forever when prepare threw. */
|
|
3261
3280
|
readonly handle: LiveHandle | undefined;
|
|
3281
|
+
/** The run body has settled (normally or by a throw): set once, in the run's own `finally`, before its last drain of
|
|
3282
|
+
* parked compaction requests. The one run-end fact for a run that never published a handle — without it a stream whose
|
|
3283
|
+
* prepare threw would read "not started yet" until its result lands. */
|
|
3284
|
+
readonly bodySettled: boolean;
|
|
3262
3285
|
/** What `destroy()` reaps when the run SUSPENDED; unset for every other terminal state. */
|
|
3263
3286
|
readonly reapHandle: SuspendReap | undefined;
|
|
3264
3287
|
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { KEYLESS_EXIT } from "../../brain/route-adjudicator.js";
|
|
2
|
+
import { runWithCredentialRefusals } from "../../brain/status-sink.js";
|
|
3
|
+
import { deliverEngineNotice } from "../engine-notice.js";
|
|
4
|
+
function noticeOf(report, sessionId, runId) {
|
|
5
|
+
switch (report.code) {
|
|
6
|
+
case "route.credential_origin_mismatch": {
|
|
7
|
+
const { modelId, boundOrigin, requestOrigin } = report;
|
|
8
|
+
return {
|
|
9
|
+
code: "route.credential_origin_mismatch",
|
|
10
|
+
message: `A request for model "${modelId}" was not sent: the model's own credential belongs to ${boundOrigin} (the host it was ` +
|
|
11
|
+
`first sent to, or the one the deployment rebound it to), and this request was going to ${requestOrigin}. A credential does not follow its model to another host — ` +
|
|
12
|
+
`the deployment has to give the model a credential for ${requestOrigin} (or point it back at ${boundOrigin}). ` +
|
|
13
|
+
`If ${requestOrigin} takes no credential, ${KEYLESS_EXIT}. Said once per run for this model and these two hosts.`,
|
|
14
|
+
detail: { modelId, boundOrigin, requestOrigin, sessionId, runId },
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
case "route.credential_mismatch": {
|
|
18
|
+
const { modelId, requestBaseUrl, configBaseUrl } = report;
|
|
19
|
+
const pairedWith = configBaseUrl !== "" ? configBaseUrl : "its brain's own endpoint";
|
|
20
|
+
return {
|
|
21
|
+
code: "route.credential_mismatch",
|
|
22
|
+
message: `A request for model "${modelId}" was not sent: the deployment's credential belongs to ${pairedWith}, and this request was going to ` +
|
|
23
|
+
`${requestBaseUrl !== "" ? requestBaseUrl : "a host with no root of its own"}. A credential does not follow a model to another host — ` +
|
|
24
|
+
`the deployment has to give the model its own credential (a per-model key, or an auth header on the model) or serve it through a brain whose root is the model's own. ` +
|
|
25
|
+
`Said once per run for this model and these two roots.`,
|
|
26
|
+
detail: { modelId, requestBaseUrl, configBaseUrl, sessionId, runId },
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
default: {
|
|
30
|
+
const _exhaustive = report;
|
|
31
|
+
void _exhaustive;
|
|
32
|
+
throw new Error("unreachable credential refusal report");
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
export function createCredentialRefusalScope({ onNotice, sessionId, runId }) {
|
|
37
|
+
const announced = new Set();
|
|
38
|
+
return (fn) => runWithCredentialRefusals((report) => {
|
|
39
|
+
const key = report.code === "route.credential_origin_mismatch"
|
|
40
|
+
? `${report.code}\u0000${report.modelId}\u0000${report.boundOrigin}\u0000${report.requestOrigin}`
|
|
41
|
+
: `${report.code}\u0000${report.modelId}\u0000${report.requestBaseUrl}\u0000${report.configBaseUrl}`;
|
|
42
|
+
if (announced.has(key))
|
|
43
|
+
return;
|
|
44
|
+
announced.add(key);
|
|
45
|
+
deliverEngineNotice(onNotice, noticeOf(report, sessionId, runId));
|
|
46
|
+
}, fn);
|
|
47
|
+
}
|
|
@@ -5,6 +5,8 @@ import { personAnswered } from "../real-approval.js";
|
|
|
5
5
|
import { thrownText } from "../thrown-value.js";
|
|
6
6
|
import { rosterEntryNamed, survivorsByName } from "../tool-roster.js";
|
|
7
7
|
import { emitTrace } from "../trace.js";
|
|
8
|
+
import { isOccupantToken } from "../../engine/session/repo-utils.js";
|
|
9
|
+
import { raceTeardownLegOr } from "./teardown-bounded.js";
|
|
8
10
|
const CROSS_BOUNDARY_CLASSES = Object.freeze(["cross_boundary"]);
|
|
9
11
|
const TREE_STATE = new WeakMap();
|
|
10
12
|
export function mintCrossBoundaryTree() {
|
|
@@ -156,9 +158,9 @@ export async function prepareCrossBoundaryLane(input) {
|
|
|
156
158
|
return addedBy(records(ONE_OUTSIDE_READ));
|
|
157
159
|
}
|
|
158
160
|
};
|
|
159
|
-
const
|
|
160
|
-
const
|
|
161
|
-
const trace = (phase, call) => emitTrace(deps.tracer, () => ({ kind: "permission.cross_boundary_taint", version: 1, taskId: hostTaskId, runId, root: {
|
|
161
|
+
const { destination } = noticeRoute;
|
|
162
|
+
const filedRoot = destination === undefined ? { sessionId: noticeRoute.address.sessionId } : isOccupantToken(destination.occupant) ? { sessionId: destination.sessionId, occupant: destination.occupant } : { sessionId: destination.sessionId, occupantUnknown: true };
|
|
163
|
+
const trace = (phase, call) => emitTrace(deps.tracer, () => ({ kind: "permission.cross_boundary_taint", version: 1, taskId: hostTaskId, runId, root: { ...filedRoot }, phase, taint: bitsOf(ref.current), governed: ref.current.governed === true, ...(call !== undefined ? { toolName: call.toolName, ...(call.toolCallId !== undefined ? { toolCallId: call.toolCallId } : {}) } : {}), ts: Date.now() }));
|
|
162
164
|
if (tree.targetExecutionArmed === true) {
|
|
163
165
|
trace(resumeLeg ? "resume" : "prepare");
|
|
164
166
|
if (posture === undefined && tree.governed !== true)
|
|
@@ -220,7 +222,7 @@ export async function prepareCrossBoundaryLane(input) {
|
|
|
220
222
|
owe: (atLeaf, owed) => write("suspend", atLeaf, () => owedBit(owed)),
|
|
221
223
|
storeWaits: () => storeWaits,
|
|
222
224
|
recorded: () => ref.current.targetExecutionArmed === true,
|
|
223
|
-
settle: (owed) => write("settle", undefined, () => owedBit(owed)).then(() => undefined),
|
|
225
|
+
settle: (owed) => raceTeardownLegOr(() => write("settle", undefined, () => owedBit(owed)).then(() => undefined), "crossBoundary.settle (settle leg)", (timeout) => unwritten("settle", ref.current, timeout)),
|
|
224
226
|
};
|
|
225
227
|
return lane;
|
|
226
228
|
}
|
|
@@ -185,7 +185,7 @@ export function resumeContinuation(resume, mark, fullShellReachable, delegatedCh
|
|
|
185
185
|
return formatHookFeedback(`${humanRefusalSentence("tool use", resume.outcome.reason, delegatedChild)} ${resumed}${delegatedChild ? carryOn : "."}`, mark);
|
|
186
186
|
}
|
|
187
187
|
const decided = decision === "allow"
|
|
188
|
-
? "was APPROVED
|
|
188
|
+
? "was APPROVED — what came of the call (its result, or why it did not run) is in the tool results above"
|
|
189
189
|
: `was DENIED ${hostDecision.decidedBy === "policy" ? `by ${policyDeciderOf(hostDecision.decidedVia).name}` : "because its approval window elapsed with no answer"}, not by a person — the refusal and its reason are in the tool results above`;
|
|
190
190
|
return formatHookFeedback(`The pending tool call "${pendingAction.toolName}" ${decided}. ${resumed}${carryOn}`, mark);
|
|
191
191
|
}
|
|
@@ -23,14 +23,17 @@ export type AcceptedFileHistoryRestore = Extract<RewindFilesResult, {
|
|
|
23
23
|
* for them on the session's next leg;
|
|
24
24
|
* · `not_found` is "no boundary for that entry" — `rewind_snapshot.unresolvable` (in a "before" restore, the
|
|
25
25
|
* before-specific sentence);
|
|
26
|
-
* · any other `failed` outcome is `rewind.restore_failed`
|
|
27
|
-
* the coded `detail` channel
|
|
26
|
+
* · any other `failed` outcome is `rewind.restore_failed` ({@link restoreFailedError}: the ledger in its sentence
|
|
27
|
+
* and its members, and the store's own judgment, on the coded `detail` channel — a host reads those, never the prose).
|
|
28
28
|
* A `complete` or `partial` answer is returned for the caller to accept: only a run goes on to work on the tree,
|
|
29
29
|
* so only the run seat has a partial-restore policy.
|
|
30
30
|
*/
|
|
31
31
|
export declare function settleFileHistoryRestore(input: {
|
|
32
32
|
store: FileHistoryStore;
|
|
33
|
+
/** The session the restore is for: its read-state channel and every sentence name it. */
|
|
33
34
|
sessionId: string;
|
|
35
|
+
/** The session's own history scope (`fileHistoryScopeOf` of its row): the one the store restores from. */
|
|
36
|
+
scope: string;
|
|
34
37
|
target: string;
|
|
35
38
|
before: boolean;
|
|
36
39
|
env: ExecutionEnv;
|
|
@@ -38,6 +41,53 @@ export declare function settleFileHistoryRestore(input: {
|
|
|
38
41
|
signal: AbortSignal | undefined;
|
|
39
42
|
readStates: Pick<SessionReadFileStates, "noteRestored"> | undefined;
|
|
40
43
|
}): Promise<AcceptedFileHistoryRestore>;
|
|
44
|
+
/**
|
|
45
|
+
* What `rewind.restore_failed` carries on its coded `detail` (the error's own member, which a failed task's
|
|
46
|
+
* `terminal.detail` reads as its `coded` account): the store's judgment of the operation when it stated one
|
|
47
|
+
* (`code`, `permanence`), and the restore's ledger in the success arm's own row types — `refused` and `failed` as the
|
|
48
|
+
* store answered them, with the counts a host reads when a list does not fit the terminal's snapshot, which leaves an
|
|
49
|
+
* over-bound list out whole (`filesChangedCount` is the sentence's "applied N"; `refusedCount` / `failedCount` are the
|
|
50
|
+
* lists' lengths). The counts are declared before the lists on purpose: see {@link restoreFailedError}.
|
|
51
|
+
*/
|
|
52
|
+
export type FileHistoryRestoreFailureDetail = Partial<Pick<FileHistoryError, "code" | "permanence">> & {
|
|
53
|
+
filesChangedCount: number;
|
|
54
|
+
refusedCount: number;
|
|
55
|
+
failedCount: number;
|
|
56
|
+
} & Pick<FileHistoryRestoreResult, "refused" | "failed">;
|
|
57
|
+
/**
|
|
58
|
+
* THE `rewind.restore_failed` error — the one mint for both ways a restore can fail a task: the store's operation-level
|
|
59
|
+
* failure ({@link settleFileHistoryRestore}) and the run seat's default refusal of a partial restore. The sentence is the
|
|
60
|
+
* caller's (it states what only that arm knows); the member beside it is read here, once, off the restore's own answer, so
|
|
61
|
+
* the numbers in the sentence ({@link fileHistoryRestoreLedgerLine}) and the members a host reads cannot be two counts.
|
|
62
|
+
*/
|
|
63
|
+
export declare function restoreFailedError(restored: FileHistoryRestoreResult, message: string): Error & {
|
|
64
|
+
code: "rewind.restore_failed";
|
|
65
|
+
detail: FileHistoryRestoreFailureDetail;
|
|
66
|
+
};
|
|
67
|
+
/** How a boundary was asked for — the three spellings of the one refusal "the requested anchor has no boundary on this session". */
|
|
68
|
+
type BoundaryAsk = "restore" | "before" | "preview";
|
|
69
|
+
/** What {@link refuseTargetOutsideOwnLog} reads of the session: an entry by id. */
|
|
70
|
+
export interface OwnLogReader {
|
|
71
|
+
getEntry(id: string): Promise<unknown>;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* A rewind goes only to a boundary the session itself recorded, and a boundary is keyed by an entry of the session's own log. What the
|
|
75
|
+
* history store holds under a scope can outlive the row it was recorded for (a row whose occupant predates the address epoch shares its
|
|
76
|
+
* id's scope with every such occupant of that id, and an id erased and created again with the store not told leaves it there): the
|
|
77
|
+
* target must be an entry THIS session's log holds, read the way a branch target (`resumeAt`) is, before
|
|
78
|
+
* any history verb is asked about it. An entry the log does not hold gets the one refusal an entry with no boundary gets, whatever the cause —
|
|
79
|
+
* a different sentence would tell the caller that someone else's boundary is there.
|
|
80
|
+
* No history verb is asked about the target and no file is moved before this answers (a run's own fork carry, which every run of a fork
|
|
81
|
+
* makes whatever it rewinds to, can come first).
|
|
82
|
+
*/
|
|
83
|
+
export declare function refuseTargetOutsideOwnLog(session: OwnLogReader, sessionId: string, target: string, ask: BoundaryAsk): Promise<void>;
|
|
84
|
+
/**
|
|
85
|
+
* A fork that works in a tree of its own (`forkHasOwnTree`, `../session-checkout.ts`) restores no file: its history scope can hold
|
|
86
|
+
* rows keyed against the root it worked at before its tree, and nothing on a row says which root that was. The one refusal an entry
|
|
87
|
+
* with no boundary gets, in both rewinds and every way of asking; the run records nothing for such a session either, and no fork carry
|
|
88
|
+
* crosses a session tree (`recordedRootOf`).
|
|
89
|
+
*/
|
|
90
|
+
export declare function refuseRestoreOnForkWithOwnTree(forkWithOwnTree: boolean, sessionId: string, target: string, ask: BoundaryAsk): void;
|
|
41
91
|
/** The per-file ledger as one sentence (counts, then each refused / failed path with its reason). */
|
|
42
92
|
export declare function fileHistoryRestoreLedgerLine(r: FileHistoryRestoreResult): string;
|
|
43
93
|
/** A restore whose entry has no boundary on the session; a PREVIEW's form says "usable" — its probe
|
|
@@ -57,3 +107,4 @@ export declare function boundaryUnrecordedNotice(input: {
|
|
|
57
107
|
entryId: string;
|
|
58
108
|
cause: FileHistoryError["code"];
|
|
59
109
|
}): EngineNotice;
|
|
110
|
+
export {};
|
|
@@ -1,21 +1,40 @@
|
|
|
1
1
|
import { resolveTrackKey } from "../file-history-store.js";
|
|
2
2
|
import { isGovernanceRetryClass } from "../governance-codes.js";
|
|
3
3
|
export async function settleFileHistoryRestore(input) {
|
|
4
|
-
const { store, sessionId, target, env, root } = input;
|
|
5
|
-
const restored = await store.restore(
|
|
4
|
+
const { store, sessionId, scope, target, env, root } = input;
|
|
5
|
+
const restored = await store.restore(scope, target, env, root, input.signal);
|
|
6
6
|
input.readStates?.noteRestored(sessionId, restoredAbsPathsOf(restored, root));
|
|
7
7
|
if (restored.outcome !== "failed")
|
|
8
8
|
return restored;
|
|
9
9
|
if (restored.error?.code === "not_found") {
|
|
10
|
-
|
|
11
|
-
throw beforeWithoutBoundaryRefusal(target, sessionId);
|
|
12
|
-
throw noBoundaryRefusal(target, sessionId);
|
|
10
|
+
throw noBoundaryFor(target, sessionId, input.before ? "before" : "restore");
|
|
13
11
|
}
|
|
14
|
-
|
|
12
|
+
throw restoreFailedError(restored, `rewind-files restore failed (${restored.error?.code ?? "restore_failed"}): ${restored.error?.message ?? "unknown"} — ledger: ${fileHistoryRestoreLedgerLine(restored)}`);
|
|
13
|
+
}
|
|
14
|
+
export function restoreFailedError(restored, message) {
|
|
15
|
+
const detail = {
|
|
16
|
+
...(restored.error !== undefined ? { code: restored.error.code, ...(isGovernanceRetryClass(restored.error.permanence) ? { permanence: restored.error.permanence } : {}) } : {}),
|
|
17
|
+
filesChangedCount: restored.filesChanged.length,
|
|
18
|
+
refusedCount: restored.refused.length,
|
|
19
|
+
failedCount: restored.failed.length,
|
|
20
|
+
refused: restored.refused.map((f) => ({ path: f.path, reason: f.reason, class: f.class })),
|
|
21
|
+
failed: restored.failed.map((f) => ({ path: f.path, reason: f.reason })),
|
|
22
|
+
};
|
|
23
|
+
const e = new Error(message);
|
|
15
24
|
e.code = "rewind.restore_failed";
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
25
|
+
e.detail = detail;
|
|
26
|
+
return e;
|
|
27
|
+
}
|
|
28
|
+
function noBoundaryFor(target, sessionId, ask) {
|
|
29
|
+
return ask === "before" ? beforeWithoutBoundaryRefusal(target, sessionId) : noBoundaryRefusal(target, sessionId, ask === "preview");
|
|
30
|
+
}
|
|
31
|
+
export async function refuseTargetOutsideOwnLog(session, sessionId, target, ask) {
|
|
32
|
+
if (!(await session.getEntry(target)))
|
|
33
|
+
throw noBoundaryFor(target, sessionId, ask);
|
|
34
|
+
}
|
|
35
|
+
export function refuseRestoreOnForkWithOwnTree(forkWithOwnTree, sessionId, target, ask) {
|
|
36
|
+
if (forkWithOwnTree)
|
|
37
|
+
throw noBoundaryFor(target, sessionId, ask);
|
|
19
38
|
}
|
|
20
39
|
export function fileHistoryRestoreLedgerLine(r) {
|
|
21
40
|
return `applied ${r.filesChanged.length}, identical ${r.identicalSkipped.length}, refused ${r.refused.length}${r.refused.length > 0 ? ` (${r.refused.map((f) => `${f.path}: ${f.reason}`).join("; ")})` : ""}, failed ${r.failed.length}${r.failed.length > 0 ? ` (${r.failed.map((f) => `${f.path}: ${f.reason}`).join("; ")})` : ""}`;
|
|
@@ -45,7 +64,7 @@ function restoredAbsPathsOf(restored, root) {
|
|
|
45
64
|
return out;
|
|
46
65
|
}
|
|
47
66
|
function rewindRefusalTail() {
|
|
48
|
-
return `Boundaries are keyed by the entry of the person's input that opened a turn (an engine entry ahead of it, such as a task notification, has none) and exist only for turns that recorded history (a RunnerDeps.fileHistoryStore wired, capture on, and the run's file history not disabled); a boundary from the retired whole-tree snapshot era is not restorable by this seat, and reaped boundaries have none.`;
|
|
67
|
+
return `Boundaries are keyed by the entry of the person's input that opened a turn (an engine entry ahead of it, such as a task notification, has none) and exist only for turns that recorded history (a RunnerDeps.fileHistoryStore wired, capture on, and the run's file history not disabled); a fork holds its source's boundaries only when neither session works in a tree of its own (TaskSpec.workspace): a fork whose source has one, or whose source's checkout record cannot be read from its log, holds none of them — the file changes before the fork are not in its history — and a fork that has a tree of its own records no file history and restores none in this version (its conversation is still branched by resumeAt); a boundary from the retired whole-tree snapshot era is not restorable by this seat, and reaped boundaries have none.`;
|
|
49
68
|
}
|
|
50
69
|
function beforeWithoutBoundaryRefusal(target, sessionId) {
|
|
51
70
|
const e = new Error(`rewind-files: entry "${target}" has no file-history boundary on session "${sessionId}" — a before-restore needs the target's own boundary and never crosses into an earlier turn, so the working tree was NOT rewound. ${rewindRefusalTail()}`);
|
|
@@ -11,6 +11,19 @@ export interface ForwardSinkHolder {
|
|
|
11
11
|
onForwardEvent?: (event: TaskEvent) => void;
|
|
12
12
|
forwardScope?: ForwardSinkScope;
|
|
13
13
|
}
|
|
14
|
+
/** The host seats a run calls whose failure the engine contains and tells the operator about: the run-internals sinks
|
|
15
|
+
* (`RunInternals.onLegFrame`, `onActivity`, …), the delegation-lifecycle observer (`RunnerDeps.onDelegationLifecycle`) and
|
|
16
|
+
* the subagent display sink (`RunInternals.onForwardEvent`). The `detail.site` of `config.host_sink_failed`. */
|
|
17
|
+
export type HostSinkSite = "run_internals" | "delegation_lifecycle" | "forward";
|
|
18
|
+
/**
|
|
19
|
+
* The containment scope for one host seat of one run, bound to the deployment's notice seat: a throw or a rejection the
|
|
20
|
+
* scope contains is told ONCE per site name as `config.host_sink_failed` (later ones counted only). Composed here, at the
|
|
21
|
+
* one place the failure is known, so no site spells the code or the sentence. Audience `operator`: the seat is DEPLOYMENT
|
|
22
|
+
* wiring and nobody else can fix it. The cause is read through the total accessor: a failing seat may hand back an error
|
|
23
|
+
* whose own `message` throws, and composing the disclosure is where that would land — the notifier swallows a throwing
|
|
24
|
+
* channel, so the site would be marked reported and never announce again.
|
|
25
|
+
*/
|
|
26
|
+
export declare function hostSinkNotifier(onNotice: RunnerDeps["onNotice"], site: HostSinkSite): SafeNotifier;
|
|
14
27
|
/**
|
|
15
28
|
* Mint the forwarding scope for ONE run, bound to the deployment's notice seat. Called where the run's
|
|
16
29
|
* internals object is composed (`Runner.runTaskStream`), so every copy of that object made later — the
|
|
@@ -23,7 +36,7 @@ export declare function createForwardSinkScope(onNotice: RunnerDeps["onNotice"])
|
|
|
23
36
|
* @contract runtask.forward_sink_never_faults_the_run — a `RunInternals.onForwardEvent` that throws,
|
|
24
37
|
* or that returns a promise which rejects, never reaches the run's control flow: the frame is dropped,
|
|
25
38
|
* the failure is counted on the run's own `forwardScope`, and the FIRST one is announced once per run
|
|
26
|
-
* as `config.
|
|
39
|
+
* as `config.host_sink_failed` (later ones are counted only). Delivery is never awaited — describing
|
|
27
40
|
* a run is not part of it, so a sink that never settles cannot hold a turn open. An absent sink is a
|
|
28
41
|
* no-op, and a healthy sink sees the same call it always did, with the same receiver.
|
|
29
42
|
*/
|
|
@@ -2,20 +2,22 @@ import { deliverEngineNotice } from "../engine-notice.js";
|
|
|
2
2
|
import { createSafeNotifier, observeThenableRejection, safeErrorMessage } from "../safe-notify.js";
|
|
3
3
|
const FORWARD_SINK_SITE = "runtask.onForwardEvent";
|
|
4
4
|
const ORPHAN_SCOPES = new WeakMap();
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
5
|
+
const HOST_SINK_SENTENCE = {
|
|
6
|
+
run_internals: (at, cause) => `[sema-core] ${at}: run-internals sink threw (contained; further failures counted, not re-disclosed): ${cause}`,
|
|
7
|
+
delegation_lifecycle: (at, cause) => `[sema-core] ${at}: delegation-lifecycle observer threw (contained; further failures counted, not re-disclosed): ${cause}`,
|
|
8
|
+
forward: (_at, cause) => `The subagent display sink (RunInternals.onForwardEvent) failed and the frame was dropped: ${cause}. ` +
|
|
9
|
+
`The run is unaffected — forwarding is a render channel — and further failures of this run are counted, not repeated.`,
|
|
10
|
+
};
|
|
11
|
+
export function hostSinkNotifier(onNotice, site) {
|
|
12
|
+
return createSafeNotifier({
|
|
13
|
+
onError: (f) => {
|
|
14
|
+
const cause = safeErrorMessage(f.error);
|
|
15
|
+
deliverEngineNotice(onNotice, { code: "config.host_sink_failed", message: HOST_SINK_SENTENCE[site](f.site, cause), detail: { site, cause } });
|
|
16
|
+
},
|
|
17
|
+
});
|
|
12
18
|
}
|
|
13
19
|
export function createForwardSinkScope(onNotice) {
|
|
14
|
-
return {
|
|
15
|
-
notifier: createSafeNotifier({
|
|
16
|
-
onError: (f) => deliverEngineNotice(onNotice, forwardSinkFailedNotice(safeErrorMessage(f.error))),
|
|
17
|
-
}),
|
|
18
|
-
};
|
|
20
|
+
return { notifier: hostSinkNotifier(onNotice, "forward") };
|
|
19
21
|
}
|
|
20
22
|
function scopeOf(holder) {
|
|
21
23
|
if (holder.forwardScope !== undefined)
|
|
@@ -132,14 +132,15 @@ export declare function createSettlementLedger(call: {
|
|
|
132
132
|
toolName: string;
|
|
133
133
|
}): SettlementLedger;
|
|
134
134
|
/**
|
|
135
|
-
*
|
|
136
|
-
*
|
|
137
|
-
*
|
|
138
|
-
*
|
|
139
|
-
*
|
|
140
|
-
* a non-object primitive passes through as-is (immutable anyway).
|
|
135
|
+
* THE mint of a `classic.PermissionDenied` payload — every refusal exit that raises the station builds its `e` here (the
|
|
136
|
+
* gate's deny exit and its phase-1 fail-closed refusal, the compliance lock, the resumed leg's refusal of a parked call). The
|
|
137
|
+
* payload is a face of the refusal's one record: `gate` is the record the call's `tool_end` frame carries, `input` a writable
|
|
138
|
+
* copy ({@link cloneObserverInput}) of the exit's own frozen record of the refused args (`finalInput` — the record
|
|
139
|
+
* `tool_end.refusedInput` carries; never a second capture), `reason` the raw sentence (never `<system-reminder>`-wrapped).
|
|
141
140
|
*/
|
|
142
|
-
export declare function
|
|
141
|
+
export declare function permissionDeniedOf(refusal: Omit<PermissionDeniedPayload, "input" | "agentId"> & {
|
|
142
|
+
readonly finalInput: unknown;
|
|
143
|
+
}): PermissionDeniedPayload;
|
|
143
144
|
/**
|
|
144
145
|
* The input a gate exit decided on, as the call's record keeps it ({@link ToolGateResult.finalInput}): a PLAIN-DATA PROJECTION of
|
|
145
146
|
* it, deep and FROZEN — never the live input (a tool, a later layer or the caller writing into its own arguments cannot rewrite
|