@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
|
@@ -14,16 +14,18 @@ import { createRapidRefillState } from "../auto-compaction.js";
|
|
|
14
14
|
import { boundInputHashOf } from "../canonical-json.js";
|
|
15
15
|
import { emitTrace } from "../trace.js";
|
|
16
16
|
import { emitTaskOutcome } from "../task-outcome.js";
|
|
17
|
-
import { runWithCapabilityWithheld
|
|
17
|
+
import { runWithCapabilityWithheld } from "../../brain/status-sink.js";
|
|
18
18
|
import { receiveModelCatalog } from "../roles.js";
|
|
19
19
|
import { announceReadDenySwap, catalogGenerationOf, screenSwappableDeps } from "../swappable-deps.js";
|
|
20
20
|
import { runSideQuery } from "../side-query.js";
|
|
21
21
|
import { PushQueue } from "../push-queue.js";
|
|
22
22
|
import { TtlSessionStore } from "../session-store.js";
|
|
23
23
|
import { claimedRowPendingOf, compensateUnstarted, unstartedRowSentence } from "../resume-startup-cause.js";
|
|
24
|
+
import { parkNounOf, resumeCancelledSentence } from "../park-noun.js";
|
|
24
25
|
import { effectiveDelegationFacts, prepareTask } from "./prepare-task.js";
|
|
25
26
|
import { SessionReadFileStates } from "./session-read-file-states.js";
|
|
26
27
|
import { SessionModeSeats } from "./session-mode-seats.js";
|
|
28
|
+
import { forgetSessionMcpFailure, sessionMcpPoolsOf } from "../mcp-connection-pool.js";
|
|
27
29
|
import { RunnerSharedToolResultStore } from "../tool-result-store.js";
|
|
28
30
|
import { PAUSE_REGISTRY } from "../pause-registry.js";
|
|
29
31
|
import { wrapToolPolicy } from "../tool-policy.js";
|
|
@@ -91,6 +93,7 @@ export class Runner {
|
|
|
91
93
|
verbLockSeats = { sessionBusy: (id) => this.sessionLocks.has(id) || this.sessionWrites.busy(id), takeSessionLock: (id) => this.acquireSessionLock(id) };
|
|
92
94
|
sessionReadStates = new SessionReadFileStates();
|
|
93
95
|
sessionModeSeats = new SessionModeSeats();
|
|
96
|
+
sessionMcpPools;
|
|
94
97
|
pendingSessionNotifications = new PendingSessionNotifications({ onNotice: () => this.deps.onNotice, boxFor: (address) => sessionBoxVerdictOf(this.deps, { sessionId: address.sessionId, scope: address.scope, sessions: this.sessions }) });
|
|
95
98
|
parentConstraintRegistry = new Map();
|
|
96
99
|
suspendedEnvReaps = new Map();
|
|
@@ -143,6 +146,7 @@ export class Runner {
|
|
|
143
146
|
this.deps = { ...this.deps, toolResultStore: new RunnerSharedToolResultStore({ maxTotalChars: 64_000_000 }) };
|
|
144
147
|
}
|
|
145
148
|
this.sessions = this.deps.sessionStore ?? new TtlSessionStore();
|
|
149
|
+
this.sessionMcpPools = sessionMcpPoolsOf(this.sessions);
|
|
146
150
|
}
|
|
147
151
|
emitTaskOutcome(outcome) {
|
|
148
152
|
emitTaskOutcome(this.deps, outcome);
|
|
@@ -262,10 +266,11 @@ export class Runner {
|
|
|
262
266
|
announceReadDenySwap(this.deps.onNotice, seats, this.deps);
|
|
263
267
|
}
|
|
264
268
|
sideQuery(spec) {
|
|
265
|
-
return
|
|
269
|
+
return runWithCapabilityWithheld(() => { }, () => runSideQuery(spec, this.deps));
|
|
266
270
|
}
|
|
267
271
|
rewindFiles(request) { return rewindSessionFiles({ deps: this.deps, sessions: this.sessions, readStates: this.sessionReadStates, ...this.verbLockSeats }, request); }
|
|
268
272
|
compactSession(request) { return compactIdleSession({ deps: this.deps, sessions: this.sessions, ...this.verbLockSeats }, request); }
|
|
273
|
+
forgetMcpFailure(request) { return forgetSessionMcpFailure(this.sessionMcpPools, request); }
|
|
269
274
|
runTaskStream(spec, resume, internals) {
|
|
270
275
|
return this.streamLeg(spec, resume, admitLegFrameSeat(internals, "runTaskStream"), undefined);
|
|
271
276
|
}
|
|
@@ -282,6 +287,7 @@ export class Runner {
|
|
|
282
287
|
let resultValue;
|
|
283
288
|
let suggestionsDone = Promise.resolve([]);
|
|
284
289
|
let handle;
|
|
290
|
+
let bodySettled = false;
|
|
285
291
|
let publishReady;
|
|
286
292
|
const ready = new Promise((res) => {
|
|
287
293
|
publishReady = res;
|
|
@@ -379,7 +385,7 @@ export class Runner {
|
|
|
379
385
|
legWrites.close();
|
|
380
386
|
releaseLock?.();
|
|
381
387
|
publishReady(handle);
|
|
382
|
-
|
|
388
|
+
bodySettled = true;
|
|
383
389
|
if (manualCompactRef.waiters.length > 0)
|
|
384
390
|
manualCompactRef.emitMooted?.("task_ending");
|
|
385
391
|
manualCompactRef.emitMooted = undefined;
|
|
@@ -391,6 +397,7 @@ export class Runner {
|
|
|
391
397
|
set resultValue(v) { resultValue = v; },
|
|
392
398
|
get handle() { return handle; },
|
|
393
399
|
get reapHandle() { return reapHandle; },
|
|
400
|
+
get bodySettled() { return bodySettled; },
|
|
394
401
|
};
|
|
395
402
|
const settled = run.catch(streamSettleBackstop({
|
|
396
403
|
spec, resume, queue, taskIdRef, entryTracer, runStartedAt, live, runner: this.depsSeat, sessions: this.sessions,
|
|
@@ -404,7 +411,7 @@ export class Runner {
|
|
|
404
411
|
});
|
|
405
412
|
const { steer, authoredSteer, inputWindow } = streamSteerVerb({ spec, internals, queue, acceptedSteerInputs, live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, steeringError, runner: this.depsSeat });
|
|
406
413
|
promptSubmitRef.seat = Object.freeze({ relay: authoredSteer, inputWindow });
|
|
407
|
-
const { notify, optOutMemoryCapture, reconnectMcpServer, compact, detach, interrupt } = streamLifecycleVerbs({ live, ready, orTimeout, steeringError, notifyRef, captureOptOutRef, mcpRedialRef, manualCompactRef, detachHub });
|
|
414
|
+
const { notify, optOutMemoryCapture, reconnectMcpServer, compact, detach, interrupt } = streamLifecycleVerbs({ live, ready, orTimeout, steeringError, inputWindow, notifyRef, captureOptOutRef, mcpRedialRef, manualCompactRef, detachHub });
|
|
408
415
|
const { halt, destroy } = streamHaltVerbs({ live, ready, orTimeout, readyTimeoutMs: READY_TIMEOUT_MS, run, reapSuspended, runner: this.depsSeat });
|
|
409
416
|
const { setPermissionMode } = streamModeVerb({ live, ready, orTimeout, steeringError });
|
|
410
417
|
const stream = {
|
|
@@ -423,6 +430,7 @@ export class Runner {
|
|
|
423
430
|
setPermissionMode,
|
|
424
431
|
reconnectMcpServer,
|
|
425
432
|
compact,
|
|
433
|
+
inputWindow,
|
|
426
434
|
detach,
|
|
427
435
|
interrupt,
|
|
428
436
|
halt,
|
|
@@ -435,7 +443,7 @@ export class Runner {
|
|
|
435
443
|
const { spec, queue, setResult, onSuggestions, onReady, onSuspend, manualCompactRef, taskIdRef, holdSessionLock, legWrites, resume, internals, notifyRef, promptSubmitRef, captureOptOutRef, mcpRedialRef, entryActor, entryTracer } = input;
|
|
436
444
|
return runNotificationLane({
|
|
437
445
|
spec, queue, resume, internals, taskIdRef, holdSessionLock, legWrites, promptSubmitRef,
|
|
438
|
-
runner: this.depsSeat, self: this, sessions: this.sessions, sessionReadStates: this.sessionReadStates, sessionModeSeats: this.sessionModeSeats, pendingSessionNotifications: this.pendingSessionNotifications,
|
|
446
|
+
runner: this.depsSeat, self: this, sessions: this.sessions, sessionReadStates: this.sessionReadStates, sessionModeSeats: this.sessionModeSeats, sessionMcpPools: this.sessionMcpPools, pendingSessionNotifications: this.pendingSessionNotifications,
|
|
439
447
|
prepareTask,
|
|
440
448
|
next: ({ prepared, injectTaskNotification, deliveredAtTurnOpen, peerInboundChainRef, modelCatalog, notificationLane, unsubscribeTaskNotifications, deliveryObligations }) => {
|
|
441
449
|
const { runSourceTaskId, parentToolCallId, ident, emitDelegationLifecycle, loopLatch, stats, internalsNotifier, undrainedUserAtEnd, userInputLostAtEnd, offerLegFrame } = runIdentityWiring({
|
|
@@ -448,7 +456,7 @@ export class Runner {
|
|
|
448
456
|
spec, prepared, resume, rs,
|
|
449
457
|
next: () => {
|
|
450
458
|
const { todoToolMounted, taskToolsMounted, writeFamilyOf, toolStartAt, startedToolCallIds } = runToolMountFacts({ spec, prepared, rs });
|
|
451
|
-
const {
|
|
459
|
+
const { observeReasoningMessage, reasoningResolution } = runReasoningSeat({ prepared, rs, taskIdRef });
|
|
452
460
|
const { effectiveTimeoutMs, walltimeMonotonicDeadline, timeout, pushContent, ownCommittedTailRef, emitCommitted } = runClockAndContent({ spec, prepared, queue, internals, rs, ident, parentToolCallId, startedToolCallIds, offerLegFrame });
|
|
453
461
|
const display = openMessageDisplay({
|
|
454
462
|
bus: prepared.modBus,
|
|
@@ -484,10 +492,10 @@ export class Runner {
|
|
|
484
492
|
});
|
|
485
493
|
return { kind: "cut" };
|
|
486
494
|
};
|
|
487
|
-
const { withBrainSinks, withLegRequestSinks } = runBrainSinks({ offerLegFrame, rs, ident,
|
|
495
|
+
const { withBrainSinks, withLegRequestSinks } = runBrainSinks({ offerLegFrame, rs, ident, notice: { onNotice: this.deps.onNotice, sessionId: prepared.sessionId, runId: prepared.runId }, announced: prepared });
|
|
488
496
|
const toolLabels = new Map(prepared.tools.flatMap((t) => (t.label !== undefined && t.label !== t.name ? [[t.name, t.label]] : [])));
|
|
489
497
|
for (const orphan of prepared.wakeRecovered) {
|
|
490
|
-
emitSettled(prepared.toolOccurrences, { toolCallId: orphan.toolCallId, spelledName: orphan.toolName, ...(toolLabels.has(orphan.toolName) ? { label: toolLabels.get(orphan.toolName) } : {}), args: orphan.args }, reconciledEnd(orphan), { push: (f) => queue.push({ ...f, ...ident() }), structured: prepared.structuredProjector, mediaBudgetBase64Chars: this.deps.mediaBudgetBase64Chars });
|
|
498
|
+
emitSettled(prepared.toolOccurrences, { toolCallId: orphan.toolCallId, spelledName: orphan.toolName, ...(toolLabels.has(orphan.toolName) ? { label: toolLabels.get(orphan.toolName) } : {}), args: orphan.args }, reconciledEnd(orphan), { push: (f) => queue.push({ ...f, ...ident() }), structured: prepared.structuredProjector, mediaBudgetBase64Chars: this.deps.mediaBudgetBase64Chars, reviewRequest: prepared.reviewRequestRef });
|
|
491
499
|
emitCommitted(orphan.entryId, "toolResult", orphan.toolCallId);
|
|
492
500
|
}
|
|
493
501
|
const postToolBatchArmed = prepared.modBus.hasHandlers("classic.PostToolBatch");
|
|
@@ -522,7 +530,7 @@ export class Runner {
|
|
|
522
530
|
runner: this.depsSeat,
|
|
523
531
|
},
|
|
524
532
|
});
|
|
525
|
-
const { flushGitMirror, unsubGitRetry, unsubBoundary, unsub } = runGitLane({ prepared, queue, rs, ident, onMessageStart, onMessageUpdate, onMessageEnd, onToolStart, onToolEnd, onTurnEnd, onTurnStart, onTurnBoundary, runner: this.depsSeat });
|
|
533
|
+
const { flushGitMirror, unsubGitRetry, unsubBoundary, unsub } = runGitLane({ prepared, queue, rs, ident, onMessageStart, onMessageUpdate, onMessageEnd, observeReasoningMessage, onToolStart, onToolEnd, onTurnEnd, onTurnStart, onTurnBoundary, runner: this.depsSeat });
|
|
526
534
|
return withLegRequestSinks(() => runLeg({
|
|
527
535
|
spec, queue, prepared, resume, rs, entryActor, objectiveAuthor: internals?.objectiveAuthor, effectiveTimeoutMs, timeout, pushContent, ident, emitCommitted, taskIdRef, writeFamilyOf, startedToolCallIds,
|
|
528
536
|
announceWorkspaceMove, withBrainSinks, flushGitMirror, loopLatch, notificationLane, unsubscribeTaskNotifications, unsubGitRetry, unsubBoundary, unsub,
|
|
@@ -599,7 +607,7 @@ export class Runner {
|
|
|
599
607
|
const { resumeInternals } = resumeCheckpointScreen({ cp, resumeSignal, internals, tools: config.tools, runner: this.depsSeat });
|
|
600
608
|
const { recheckGovernanceWindow } = resumeInternalsAndConfig({ cp, config, internals, outcomeGate, runner: this.depsSeat, resumeSignal });
|
|
601
609
|
const hold = cp.sessionId
|
|
602
|
-
? { sessionId: cp.sessionId, release: await sessionLockUnlessAborted(this.acquireSessionLock(cp.sessionId), resumeSignal), adopted: false }
|
|
610
|
+
? { sessionId: cp.sessionId, release: await sessionLockUnlessAborted(this.acquireSessionLock(cp.sessionId), resumeSignal, cp), adopted: false }
|
|
603
611
|
: undefined;
|
|
604
612
|
try {
|
|
605
613
|
if (recheckGovernanceWindow !== undefined)
|
|
@@ -628,11 +636,9 @@ export class Runner {
|
|
|
628
636
|
}
|
|
629
637
|
async resumeHandoff(claimed) {
|
|
630
638
|
const { token, cp, readGeneration, store, config, internals, resumeInternals, plainPolicyOutcome, redeemedAnswer, outcomeForStore, wakeMessage, wakeRewrittenBy, wakeHookContext, legMods, resumeSignal, hold } = claimed;
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
consumeFlipDone = true;
|
|
635
|
-
}
|
|
639
|
+
const stated = internals?.afterCheckpointResolve !== undefined ? await internals.afterCheckpointResolve() : undefined;
|
|
640
|
+
const consumeFlipDone = internals?.afterCheckpointResolve !== undefined;
|
|
641
|
+
const legInternals = stated !== undefined ? { ...resumeInternals, cycleSeq: stated.cycleSeq } : resumeInternals;
|
|
636
642
|
const answerFace = plainPolicyOutcome !== undefined && redeemedAnswer !== undefined
|
|
637
643
|
? answerFaceForRedeemedCall(redeemedAnswer, plainPolicyOutcome.boundCallId, config.onQuestion ?? this.deps.onQuestion, boundInputHashOf(cp.pendingAction.args?.questions))
|
|
638
644
|
: undefined;
|
|
@@ -640,6 +646,7 @@ export class Runner {
|
|
|
640
646
|
...config,
|
|
641
647
|
...((config.principal || undefined) === undefined && (cp.principal || undefined) !== undefined ? { principal: cp.principal } : {}),
|
|
642
648
|
...((config.isolationScope || undefined) === undefined && (cp.isolationScope || undefined) !== undefined ? { isolationScope: cp.isolationScope } : {}),
|
|
649
|
+
...(config.durableApproval === undefined && cp.durableApproval === false ? { durableApproval: cp.durableApproval } : {}),
|
|
643
650
|
objective: "",
|
|
644
651
|
sessionId: cp.sessionId,
|
|
645
652
|
requireExistingSession: true,
|
|
@@ -649,19 +656,19 @@ export class Runner {
|
|
|
649
656
|
const reopenUnstarted = async (reason) => ((await store.reopen(token, cp.scope, reason, { rev: checkpointClaimRevOf({ rev: readGeneration }) })) ? "reopened" : "declined");
|
|
650
657
|
const recordExecutionOutcome = (gate) => store.recordExecutionOutcome(token, cp.scope, gate);
|
|
651
658
|
if (resumeSignal?.aborted === true && consumeFlipDone) {
|
|
652
|
-
throw new CheckpointError("checkpoint.resume_aborted",
|
|
659
|
+
throw new CheckpointError("checkpoint.resume_aborted", `the resume was cancelled after it had already taken ${parkNounOf(cp).waiting} to carry it out: it is no longer waiting, and it is not known whether ${parkNounOf(cp).started} began — check what the run left behind before deciding anything (putting it back to waiting here could leave a request nobody can answer)`);
|
|
653
660
|
}
|
|
654
661
|
if (resumeSignal?.aborted === true) {
|
|
655
662
|
const row = await compensateUnstarted(reopenUnstarted, "env_failed", claimedRowPendingOf(store, token, { rev: readGeneration }));
|
|
656
|
-
const said = `the resume was
|
|
663
|
+
const said = `the resume was cancelled before ${parkNounOf(cp).started} could run — ${unstartedRowSentence(row, cp)}`;
|
|
657
664
|
if (row.kind === "reopened")
|
|
658
|
-
throw new CheckpointError("checkpoint.resume_aborted", said);
|
|
659
|
-
throw new CheckpointError("checkpoint.reopen_failed", said);
|
|
665
|
+
throw new CheckpointError("checkpoint.resume_aborted", said, { unstartedRow: row.kind });
|
|
666
|
+
throw new CheckpointError("checkpoint.reopen_failed", said, { unstartedRow: row.kind });
|
|
660
667
|
}
|
|
661
|
-
return this.streamLeg(spec, { cp, outcome: outcomeForStore, reopenUnstarted, claimedRowPending: claimedRowPendingOf(store, token, { rev: readGeneration }), recordExecutionOutcome, ...(wakeMessage !== undefined ? { wakeMessage } : {}), ...(wakeRewrittenBy !== undefined ? { wakeMessageRewrittenBy: wakeRewrittenBy } : {}), ...(wakeHookContext !== undefined ? { wakeMessageHookContext: wakeHookContext } : {}), ...(legMods !== undefined ? { legMods } : {}) },
|
|
668
|
+
return this.streamLeg(spec, { cp, outcome: outcomeForStore, reopenUnstarted, claimedRowPending: claimedRowPendingOf(store, token, { rev: readGeneration }), recordExecutionOutcome, ...(wakeMessage !== undefined ? { wakeMessage } : {}), ...(wakeRewrittenBy !== undefined ? { wakeMessageRewrittenBy: wakeRewrittenBy } : {}), ...(wakeHookContext !== undefined ? { wakeMessageHookContext: wakeHookContext } : {}), ...(legMods !== undefined ? { legMods } : {}) }, legInternals, hold);
|
|
662
669
|
}
|
|
663
670
|
}
|
|
664
|
-
async function sessionLockUnlessAborted(taken, signal) {
|
|
671
|
+
async function sessionLockUnlessAborted(taken, signal, row) {
|
|
665
672
|
if (signal === undefined)
|
|
666
673
|
return taken;
|
|
667
674
|
const raced = await raceSettlementAgainstSignal(taken, signal);
|
|
@@ -670,7 +677,7 @@ async function sessionLockUnlessAborted(taken, signal) {
|
|
|
670
677
|
if (raced.tag === "threw")
|
|
671
678
|
throw raced.error;
|
|
672
679
|
void taken.then((release) => release(), () => { });
|
|
673
|
-
throw new CheckpointError("checkpoint.resume_aborted", "
|
|
680
|
+
throw new CheckpointError("checkpoint.resume_aborted", resumeCancelledSentence("while it waited for the session to be free", row));
|
|
674
681
|
}
|
|
675
682
|
export function runTask(spec, deps) {
|
|
676
683
|
return new Runner(deps).runTask(spec);
|
|
@@ -50,7 +50,17 @@ export declare function isWithin(root: string, p: string): boolean;
|
|
|
50
50
|
* hands a plain rules object gets.
|
|
51
51
|
*/
|
|
52
52
|
export interface SessionRuleSource {
|
|
53
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* The prepare-time snapshot: the audit's view, and the floor no live read may loosen.
|
|
55
|
+
*
|
|
56
|
+
* @contract session_rules.snapshot_grammar — the grammar a snapshot's entries are read in is one rule for every reader of rules
|
|
57
|
+
* (this layer, `readSessionRulesShape`, `normalizeRules`, `loosenReasons`): the value's own `grammar` stamp when it carries one;
|
|
58
|
+
* with none, a value beside a store's `rev` of 1 or more is a row stored before the stamp existed (grammar 0), and any other value
|
|
59
|
+
* (no `rev`, or the `rev: 0` record of a key nobody wrote) is read in the grammar of the engine that enforces it. A plain rules
|
|
60
|
+
* object handed straight to `createSessionRulePolicy`, or a constant source's seed, is therefore neither a write nor a stored row:
|
|
61
|
+
* only a WRITER must declare a grammar, because a row outlives the engine that wrote it, while a snapshot is enforced by the engine
|
|
62
|
+
* that reads it and cannot outlive that process — a host that wants a literal to keep its reading across an engine upgrade stamps it.
|
|
63
|
+
*/
|
|
54
64
|
seed: SessionPermissionRules;
|
|
55
65
|
/** The live read, asked at every judgment and bounded by the gate's own signal; `toolCallId` names the call being
|
|
56
66
|
* judged. Absent ⇒ the seed is the whole source. */
|
|
@@ -2,7 +2,7 @@ import { deliverEngineNotice } from "../engine-notice.js";
|
|
|
2
2
|
import { withheldEnvUserNotice } from "../secret-env.js";
|
|
3
3
|
import { isEngineShellFace } from "../tool-catalog-entries.js";
|
|
4
4
|
import { toolCallFaceOf } from "../tool-roster.js";
|
|
5
|
-
import { announceDigest,
|
|
5
|
+
import { announceDigest, tellOncePerSession } from "./announce-once-ledger.js";
|
|
6
6
|
const isFinding = (f) => typeof f === "object" && f !== null && typeof Reflect.get(f, "key") === "string" && typeof Reflect.get(f, "kind") === "string";
|
|
7
7
|
function readWithheldEnv(env) {
|
|
8
8
|
try {
|
|
@@ -40,12 +40,7 @@ export function createWithheldShellEnvSeat(prepared, onNotice) {
|
|
|
40
40
|
return;
|
|
41
41
|
const d = notice.detail;
|
|
42
42
|
const digest = announceDigest(notice.code, `${d.state}\n${[...(d.names ?? [])].sort().join("\n")}\n\n${[...(d.ownCredentials ?? [])].sort().join("\n")}${d.sourceSessionId !== undefined ? `\n\n${d.sourceSessionId}` : ""}`);
|
|
43
|
-
|
|
44
|
-
if (record.advisories?.includes(digest) === true)
|
|
45
|
-
return;
|
|
46
|
-
deliverEngineNotice(onNotice, notice, prepared.legNotice.admission);
|
|
47
|
-
record.advisories = withAnnounceDigests(record.advisories, [digest]);
|
|
48
|
-
prepared.frameReceipts.listingSnapshotOwed = true;
|
|
43
|
+
tellOncePerSession(prepared, digest, () => deliverEngineNotice(onNotice, notice, prepared.legNotice.admission));
|
|
49
44
|
},
|
|
50
45
|
};
|
|
51
46
|
}
|
|
@@ -73,14 +73,13 @@ export interface SideCallCall {
|
|
|
73
73
|
export declare function recordSideCallUsage(stats: Stats, usage: Usage | undefined, lane: SideCallLane, call: SideCallCall): void;
|
|
74
74
|
/**
|
|
75
75
|
* The accounted brain of a DERIVED LEG — a model call made beside the main loop on the leg's behalf (the compaction summary,
|
|
76
|
-
* the advisor consultation): every reply is booked through `book` exactly once, under `lane`, and the call runs behind
|
|
77
|
-
* NO-OP status
|
|
76
|
+
* the advisor consultation): every reply is booked through `book` exactly once, under `lane`, and the call runs behind a
|
|
77
|
+
* NO-OP status sink. Both arms obey the same law, whichever one the caller uses.
|
|
78
78
|
*
|
|
79
|
-
* The
|
|
79
|
+
* The shield: a derived call fires inside the leg's `runWithStatusSink` scope (the compaction hook from `turn_boundary`
|
|
80
80
|
* within `harness.prompt`, the advisor from a tool call), so a 429/retry on it must not surface as a `status` event on the
|
|
81
|
-
* user's turn (status-sink.ts / TaskEvent.status)
|
|
82
|
-
*
|
|
83
|
-
* leg's one correction.
|
|
81
|
+
* user's turn (status-sink.ts / TaskEvent.status). Its reply never reaches the leg's harness `message_end`, so it cannot
|
|
82
|
+
* restate the leg's reasoning posture either.
|
|
84
83
|
*
|
|
85
84
|
* `complete` is ALWAYS provided (brainToRuntime prefers it), so the booking is awaited INLINE on both the native-complete and
|
|
86
85
|
* derived-from-stream paths, and the message is returned UNCHANGED (its `errorKind` is what the summary path's
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { runWithStatusSink } from "../../brain/status-sink.js";
|
|
2
2
|
import { emitTrace } from "../trace.js";
|
|
3
3
|
import { billsOf, priceReply } from "./reply-pricing.js";
|
|
4
4
|
import { bookCacheOperands, cacheTraceMembersOf } from "./cache-hit-account.js";
|
|
@@ -40,7 +40,7 @@ export function recordSideCallUsage(stats, usage, lane, call) {
|
|
|
40
40
|
}));
|
|
41
41
|
}
|
|
42
42
|
export function derivedLegBrain(brainOf, lane, book) {
|
|
43
|
-
const shielded = (fn) => runWithStatusSink(() => { },
|
|
43
|
+
const shielded = (fn) => runWithStatusSink(() => { }, fn);
|
|
44
44
|
return {
|
|
45
45
|
stream: (m, c, o) => shielded(async () => {
|
|
46
46
|
const inner = await Promise.resolve(brainOf().stream(m, c, o));
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { InputWindow } from "../input-author.js";
|
|
1
2
|
import type { ToolDetachHub } from "../tool-detach.js";
|
|
2
3
|
import type { TaskStream } from "../types.js";
|
|
3
4
|
import type { CaptureOptOutRef, LiveHandle, ManualCompactRef, McpRedialRef, NotifyRef, TaskStreamLiveSeat } from "./contracts.js";
|
|
@@ -10,6 +11,8 @@ export interface StreamLifecycleVerbsInput {
|
|
|
10
11
|
orTimeout: <T>(p: Promise<T>) => Promise<T | undefined>;
|
|
11
12
|
/** borrowed-readonly — the driver's typed steering refusal (`steering.not_running` by default); the opt-out and compact verbs share it. */
|
|
12
13
|
steeringError: (msg: string, code?: string) => Error;
|
|
14
|
+
/** borrowed-readonly — the stream's one input judge (the steer lane's `inputWindow`): `compact` takes a request exactly when it does not read `"over"`. */
|
|
15
|
+
inputWindow: () => InputWindow;
|
|
13
16
|
/** borrowed-readonly — the notify bridge; `inject` is bound by the run body once the notification lane exists. */
|
|
14
17
|
notifyRef: NotifyRef;
|
|
15
18
|
/** borrowed-readonly — the capture opt-out bridge; `flip` is bound by the run body when a memory session mounted. */
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isSystemInjectionPriority, SYSTEM_INJECTION_PRIORITIES, TASK_NOTIFICATION_TERMINAL_STATUSES } from "../task-notification.js";
|
|
2
2
|
export function streamLifecycleVerbs(input) {
|
|
3
|
-
const { live, ready, orTimeout, steeringError, notifyRef, captureOptOutRef, mcpRedialRef, manualCompactRef, detachHub } = input;
|
|
3
|
+
const { live, ready, orTimeout, steeringError, inputWindow, notifyRef, captureOptOutRef, mcpRedialRef, manualCompactRef, detachHub } = input;
|
|
4
4
|
const notify = async (input, opts) => {
|
|
5
5
|
const notifyError = (msg, code) => {
|
|
6
6
|
const e = new Error(`cannot notify: ${msg}`);
|
|
@@ -91,7 +91,7 @@ export function streamLifecycleVerbs(input) {
|
|
|
91
91
|
return mcpRedialRef.redial(serverIn);
|
|
92
92
|
};
|
|
93
93
|
const compact = async (opts) => {
|
|
94
|
-
if (
|
|
94
|
+
if (inputWindow() === "over")
|
|
95
95
|
throw steeringError("the task has already finished");
|
|
96
96
|
if (opts?.signal?.aborted)
|
|
97
97
|
return "mooted";
|
|
@@ -100,8 +100,10 @@ export function streamLifecycleVerbs(input) {
|
|
|
100
100
|
throw steeringError("the task is not running");
|
|
101
101
|
if (opts?.signal?.aborted)
|
|
102
102
|
return "mooted";
|
|
103
|
-
if (
|
|
103
|
+
if (inputWindow() === "over") {
|
|
104
|
+
manualCompactRef.emitMooted?.("task_ending");
|
|
104
105
|
return "mooted";
|
|
106
|
+
}
|
|
105
107
|
return new Promise((resolve) => {
|
|
106
108
|
const signal = opts?.signal;
|
|
107
109
|
const entry = {
|
|
@@ -3,7 +3,7 @@ import { compensateUnstarted, reopenReasonOf, resumeStartupCauseOf, unstartedRow
|
|
|
3
3
|
import { resumeDecisionWasNegative } from "./decide-continuation.js";
|
|
4
4
|
import { drainForwardedFramesBeforeDone, forwardsSubagentEvents } from "./prepare-run-refs.js";
|
|
5
5
|
import { hasDestroy } from "../remote-env.js";
|
|
6
|
-
import {
|
|
6
|
+
import { hostSinkNotifier } from "./forward-sink.js";
|
|
7
7
|
import { settleTeardownLeg } from "./teardown-bounded.js";
|
|
8
8
|
import { emitTrace } from "../trace.js";
|
|
9
9
|
import { deliverDelegationLifecycle } from "../types.js";
|
|
@@ -22,13 +22,13 @@ export function streamSettleBackstop(input) {
|
|
|
22
22
|
unstartedRow = row.kind;
|
|
23
23
|
if (row.kind === "reopened") {
|
|
24
24
|
reopenCommitted = true;
|
|
25
|
-
message = `${message} — ${unstartedRowSentence(row)}`;
|
|
25
|
+
message = `${message} — ${unstartedRowSentence(row, resume.cp)}`;
|
|
26
26
|
}
|
|
27
27
|
else {
|
|
28
28
|
parentConstraintRegistry.delete(resume.cp.token);
|
|
29
29
|
const original = asThrownError(err);
|
|
30
30
|
reopenStateUnknown = row.kind === "unknown";
|
|
31
|
-
err = Object.assign(new Error(`${original.message} — ${unstartedRowSentence(row)}`, { cause: original }), { code: "checkpoint.reopen_failed" });
|
|
31
|
+
err = Object.assign(new Error(`${original.message} — ${unstartedRowSentence(row, resume.cp)}`, { cause: original }), { code: "checkpoint.reopen_failed" });
|
|
32
32
|
const replacement = thrownFailureOf(err, thrownText(err));
|
|
33
33
|
code = replacement.code;
|
|
34
34
|
message = replacement.message;
|
|
@@ -106,9 +106,7 @@ export function streamSettleBackstop(input) {
|
|
|
106
106
|
const owedTerminal = taskIdRef.delegationTerminalOwed;
|
|
107
107
|
if (owedTerminal !== undefined) {
|
|
108
108
|
taskIdRef.delegationTerminalOwed = undefined;
|
|
109
|
-
deliverDelegationLifecycle(runner.deps.onDelegationLifecycle, { phase: "terminal", identity: owedTerminal, status: "failed", turns: 0, ...(code !== undefined ? { errorCode: code } : {}) },
|
|
110
|
-
onError: (f) => console.warn(`[sema-core] ${f.site}: delegation-lifecycle observer threw (contained; further failures counted, not re-disclosed): ${f.error.message}`),
|
|
111
|
-
}), "runtask.onDelegationLifecycle");
|
|
109
|
+
deliverDelegationLifecycle(runner.deps.onDelegationLifecycle, { phase: "terminal", identity: owedTerminal, status: "failed", turns: 0, ...(code !== undefined ? { errorCode: code } : {}) }, hostSinkNotifier(runner.deps.onNotice, "delegation_lifecycle"), "runtask.onDelegationLifecycle", runner.deps.onNotice);
|
|
112
110
|
}
|
|
113
111
|
if (forwardsSubagentEvents(spec))
|
|
114
112
|
await drainForwardedFramesBeforeDone();
|
|
@@ -31,7 +31,7 @@ export interface StreamSteerVerbResult {
|
|
|
31
31
|
/** The same verb under an author the engine states (an observer's report, an extension's prompt) — registered on the stream
|
|
32
32
|
* object and handed to the leg's `$.prompt.submit` entry, never on the package face. */
|
|
33
33
|
authoredSteer: AuthoredSteer;
|
|
34
|
-
/** Where the leg's loop stands for an input, read now ({@link InputWindow}) — the
|
|
34
|
+
/** Where the leg's loop stands for an input, read now ({@link InputWindow}) — the stream's one input judge (`TaskStream.inputWindow`). */
|
|
35
35
|
inputWindow: () => InputWindow;
|
|
36
36
|
}
|
|
37
37
|
export declare function streamSteerVerb(input: StreamSteerVerbInput): StreamSteerVerbResult;
|
|
@@ -114,7 +114,7 @@ export function streamSteerVerb(input) {
|
|
|
114
114
|
if (typeof inputId === "string") {
|
|
115
115
|
const prior = acceptedSteerInputs.get(inputId);
|
|
116
116
|
if (prior !== undefined) {
|
|
117
|
-
if (
|
|
117
|
+
if (inputWindow() === "over")
|
|
118
118
|
throw steeringError("the task is no longer running");
|
|
119
119
|
const refusal = steerReplayRefusal(prior, parkRecord, { seat: "accepted" });
|
|
120
120
|
if (refusal !== undefined)
|
|
@@ -122,7 +122,7 @@ export function streamSteerVerb(input) {
|
|
|
122
122
|
return { entered };
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
|
-
if (
|
|
125
|
+
if (inputWindow() === "over")
|
|
126
126
|
throw steeringError("the task is no longer running");
|
|
127
127
|
if (!countsAsOperator(author) && h.harness.engineInjectionsHeld?.() === true) {
|
|
128
128
|
throw steeringError("the run stopped on the person's own refusal and they have not spoken since — an input that is not theirs does not restart it");
|
|
@@ -196,7 +196,7 @@ export function streamSteerVerb(input) {
|
|
|
196
196
|
throw e;
|
|
197
197
|
}
|
|
198
198
|
const birthDeadline = Date.now() + READY_TIMEOUT_MS;
|
|
199
|
-
while (
|
|
199
|
+
while (inputWindow() !== "over" && Date.now() < birthDeadline) {
|
|
200
200
|
try {
|
|
201
201
|
await injectFramed();
|
|
202
202
|
return taken();
|
|
@@ -224,7 +224,7 @@ export function streamSteerVerb(input) {
|
|
|
224
224
|
}
|
|
225
225
|
};
|
|
226
226
|
const inputWindow = () => {
|
|
227
|
-
if (live.resultValue !== undefined)
|
|
227
|
+
if (live.resultValue !== undefined || live.bodySettled)
|
|
228
228
|
return "over";
|
|
229
229
|
const h = live.handle;
|
|
230
230
|
if (h === undefined)
|
|
@@ -151,12 +151,17 @@ export declare function ownListsWhereOf(ownBy: RunInternals["ownToolLists"]): st
|
|
|
151
151
|
* answers differently the second time is not asked a second time, and the selector's layers (handed to the leg's children as their
|
|
152
152
|
* ceiling) are the frozen product. Built before anything reads it, and before the session is acquired, so a refusal needs nothing given
|
|
153
153
|
* back. `where` is whose lists the own layer is ({@link ownListsWhereOf}). (A ceiling a resumed row restored was read by the same reader
|
|
154
|
-
* before the claim — `persistedToolNamesRefusal`.)
|
|
154
|
+
* before the claim — `persistedToolNamesRefusal`.) `spec` carries the run's whole-face switch: the own layer is read as written first
|
|
155
|
+
* (a malformed allowlist beside the switch refuses here as it does without it), and only what was read becomes the layer the switch
|
|
156
|
+
* empties ({@link ownSelectorLayer}).
|
|
155
157
|
*/
|
|
156
158
|
export declare function readToolSelector(input: {
|
|
157
159
|
readonly layers: readonly unknown[];
|
|
158
160
|
readonly where: string | undefined;
|
|
159
161
|
readonly legs: readonly ToolLegKind[];
|
|
162
|
+
readonly spec?: {
|
|
163
|
+
readonly excludeAllTools?: true;
|
|
164
|
+
};
|
|
160
165
|
}): ToolSelector;
|
|
161
166
|
/** The digest of the lists a record of the delegation tool that wrote a leg's own lists carries, or `undefined` when it records none or
|
|
162
167
|
* is not one ({@link readOwnToolListsRecord}): the fingerprint the resume ladder compares a row's record and the live seat's by. */
|
|
@@ -199,8 +204,8 @@ export declare function boundOwnToolLists(record: unknown, own: {
|
|
|
199
204
|
readonly exclude: readonly string[] | undefined;
|
|
200
205
|
}): RunInternals["ownToolLists"];
|
|
201
206
|
export interface RunToolListsInput {
|
|
202
|
-
/** borrowed-readonly — the REBOUND spec: `agents` (the task's definitions)
|
|
203
|
-
spec: Pick<TaskSpec, "agents" | "tools"
|
|
207
|
+
/** borrowed-readonly — the REBOUND spec: `agents` (the task's definitions) and `tools` (the caller's tools and the mounted delegation tools; the selector's valve decides which of them are left — under the whole-face switch, none). */
|
|
208
|
+
spec: Pick<TaskSpec, "agents" | "tools">;
|
|
204
209
|
/** borrowed-readonly — the assembled mount array BEFORE the selector's valve (names + aliases = the roster half of the universe). */
|
|
205
210
|
tools: ReadonlyArray<AgentTool>;
|
|
206
211
|
/** borrowed-readonly — the peers the task declares, per protocol of the protocol table (its MCP servers, its A2A peers): a namespaced
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { compileToolSelector, valveLeaves, deniedProtocolTools, delegationListWhere, isCanonicalToolName, isToolSelectorLayer, listReaches, notAListSentence, toolListsDigest, notAStringSentence, readAllowedToolList, readDeniedEntry, readDeniedToolList } from "../../agents/tool-filter.js";
|
|
1
|
+
import { compileToolSelector, ownSelectorLayer, valveLeaves, deniedProtocolTools, delegationListWhere, isCanonicalToolName, isToolSelectorLayer, listReaches, notAListSentence, toolListsDigest, notAStringSentence, readAllowedToolList, readDeniedEntry, readDeniedToolList } from "../../agents/tool-filter.js";
|
|
2
2
|
import { readToolNameList, valueTypeLabel } from "../tool-name-list.js";
|
|
3
3
|
import { compileAllowList, inertEntryPhrase, isRetiredLeftOut, renderListEntry, rootFacingToolNames } from "../allow-entry.js";
|
|
4
4
|
import { inlineUntrusted } from "../untrusted-text.js";
|
|
@@ -247,6 +247,9 @@ export function readToolSelector(input) {
|
|
|
247
247
|
const inherited = i === ceilings ? undefined : inheritedListsWhere(ceilings, i);
|
|
248
248
|
return readSelectorLayer(layer, inherited ?? "this run's own tool lists", (side) => inherited ?? input.where ?? (side === "allowed" ? "TaskSpec.allowTools" : "TaskSpec.excludeTools"), false);
|
|
249
249
|
});
|
|
250
|
+
const own = read[ceilings];
|
|
251
|
+
if (own !== undefined)
|
|
252
|
+
read[ceilings] = Object.freeze(ownSelectorLayer({ allow: own.allow, exclude: own.deny }, input.spec ?? {}));
|
|
250
253
|
return compileToolSelector(read, input.legs);
|
|
251
254
|
}
|
|
252
255
|
function readOwnToolListsRecord(value) {
|
|
@@ -398,7 +401,7 @@ export function judgeRunToolLists(input) {
|
|
|
398
401
|
const by = [...deniedBy(denied, true, ownWhere ?? "this run's own excludeTools"), ...deniedBy(deniedByDefinition, false, definitionWhere), ...deniedBy(denied, false, "an inherited list (the spawning run's excludeTools, or one it inherits)")];
|
|
399
402
|
throw refused(`This kind of leg (${input.legs.join(", ")}) relies on ${names.join(", ")}, but ${by.join(" and ")} — the leg cannot work without ${one ? "it" : "them"}. Remove the entry from the list that names it.`, "config.tool_face_control", "protocol_denied");
|
|
400
403
|
}
|
|
401
|
-
const pool = delegationPoolReading(spec.tools ?? [], valveLeaves(
|
|
404
|
+
const pool = delegationPoolReading(spec.tools ?? [], valveLeaves(selector));
|
|
402
405
|
const mounted = mountedToolNames([...tools, ...(spec.tools ?? [])]);
|
|
403
406
|
const withOwnServers = (servers) => servers === undefined || servers.length === 0 ? input.declaredPeers : { ...input.declaredPeers, mcp: [...(input.declaredPeers.mcp ?? []), ...servers] };
|
|
404
407
|
const definitionServers = [...(spec.agents ?? []).flatMap((d) => d.mcp ?? []), ...pool.tools.flatMap((t) => (t.agentToolFaces ?? []).flatMap((f) => f.servers ?? []))];
|
|
@@ -447,9 +450,9 @@ export function judgeHostToolCeiling(layers, agent, above = []) {
|
|
|
447
450
|
const where = (i) => `RunWorkflowOptions.toolCeiling, layer ${i + 1}`;
|
|
448
451
|
layers.forEach((layer, i) => readSelectorLayer(layer, where(i), () => where(i), false));
|
|
449
452
|
const callerTools = agent.tools ?? [];
|
|
450
|
-
const own =
|
|
453
|
+
const own = ownSelectorLayer({ allow: agent.allowTools ?? undefined, exclude: agent.excludeTools ?? undefined }, agent);
|
|
451
454
|
const selector = compileToolSelector([...above, ...layers, own], ["delegated"]);
|
|
452
|
-
const pool = delegationPoolReading(callerTools, valveLeaves(
|
|
455
|
+
const pool = delegationPoolReading(callerTools, valveLeaves(selector));
|
|
453
456
|
const universe = rootFacingUniverse(mountedToolNames(callerTools), pool, { mcp: undefined, a2a: undefined });
|
|
454
457
|
const unannounced = () => undefined;
|
|
455
458
|
layers.forEach((layer, i) => {
|
|
@@ -46,3 +46,10 @@ export declare function settleTeardownLeg(leg: () => Promise<unknown> | unknown,
|
|
|
46
46
|
* means. {@link settleTeardownLeg} is this race with every outcome routed to a report; one bound, one race.
|
|
47
47
|
*/
|
|
48
48
|
export declare function raceTeardownLeg<T>(leg: () => Promise<T> | T, label: string): Promise<T>;
|
|
49
|
+
/**
|
|
50
|
+
* The same bound for a leg whose own failure keeps its path: only THIS bound's timeout is turned into something — `onTimeout`'s
|
|
51
|
+
* value (the report the caller makes, the reading it falls back to) — and whatever the leg itself throws or rejects with, a timeout
|
|
52
|
+
* of another bound inside it included, comes out unchanged. {@link settleTeardownLeg} sends every outcome to a report and never
|
|
53
|
+
* throws; this one sends the timeout alone, so a failure the caller's own path was built for still reaches it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function raceTeardownLegOr<T, R>(leg: () => Promise<T> | T, label: string, onTimeout: (timeout: TeardownLegTimeoutError) => R | Promise<R>): Promise<T | R>;
|
|
@@ -41,3 +41,10 @@ export async function raceTeardownLeg(leg, label) {
|
|
|
41
41
|
clearTimeout(timer);
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
+
export function raceTeardownLegOr(leg, label, onTimeout) {
|
|
45
|
+
return raceTeardownLeg(leg, label).catch((e) => {
|
|
46
|
+
if (e instanceof TeardownLegTimeoutError && e.leg === label)
|
|
47
|
+
return onTimeout(e);
|
|
48
|
+
throw e;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
@@ -6,9 +6,9 @@ import { admittedRequestRoute } from "../../brain/request-route.js";
|
|
|
6
6
|
import { REFUSED_REQUEST_PARTS } from "../terminal-cause.js";
|
|
7
7
|
import { readMember } from "../thrown-value.js";
|
|
8
8
|
import { egressText } from "../untrusted-egress.js";
|
|
9
|
-
import { REDACTION_MARK } from "../redaction-marks.js";
|
|
10
9
|
import { isSensitiveName, looksLikeCredentialValue } from "../secret-env.js";
|
|
11
|
-
import { isSensitiveRecordKey } from "@sema-agent/primitives";
|
|
10
|
+
import { isSensitiveRecordKey, REDACTION_MARKS } from "@sema-agent/primitives";
|
|
11
|
+
const CREDENTIAL_LEAF = REDACTION_MARKS.bare;
|
|
12
12
|
const LOOP_EXIT_FAILURE = {
|
|
13
13
|
completed: undefined,
|
|
14
14
|
aborted_before_stream: undefined,
|
|
@@ -75,26 +75,34 @@ function namesCredential(name) {
|
|
|
75
75
|
const NAME_POSITION_KEYS = new Set(["name", "key", "header", "field"]);
|
|
76
76
|
const VALUE_POSITION_KEYS = new Set(["value", "val"]);
|
|
77
77
|
function charge(budget, chars) {
|
|
78
|
-
if (budget.values >= CODED_DETAIL_VALUES || budget.chars + chars > CODED_DETAIL_CHARS)
|
|
78
|
+
if (budget.values >= CODED_DETAIL_VALUES || budget.chars + chars > CODED_DETAIL_CHARS) {
|
|
79
|
+
budget.cuts++;
|
|
79
80
|
return false;
|
|
81
|
+
}
|
|
80
82
|
budget.values++;
|
|
81
83
|
budget.chars += chars;
|
|
82
84
|
return true;
|
|
83
85
|
}
|
|
84
86
|
function leafOf(keyContext, read, depth, budget) {
|
|
85
87
|
if (keyContext !== undefined && namesCredential(keyContext))
|
|
86
|
-
return charge(budget,
|
|
88
|
+
return charge(budget, CREDENTIAL_LEAF.length) ? CREDENTIAL_LEAF : undefined;
|
|
87
89
|
const value = read();
|
|
88
90
|
if (value === null || typeof value === "boolean" || (typeof value === "number" && Number.isFinite(value)))
|
|
89
91
|
return charge(budget, 0) ? value : undefined;
|
|
90
92
|
if (typeof value === "string") {
|
|
91
|
-
if (value.length > CODED_DETAIL_STRING)
|
|
93
|
+
if (value.length > CODED_DETAIL_STRING) {
|
|
94
|
+
budget.cuts++;
|
|
92
95
|
return undefined;
|
|
93
|
-
|
|
96
|
+
}
|
|
97
|
+
const shown = carriesCredential(value) ? CREDENTIAL_LEAF : value;
|
|
94
98
|
return charge(budget, shown.length) ? shown : undefined;
|
|
95
99
|
}
|
|
96
|
-
if (typeof value !== "object"
|
|
100
|
+
if (typeof value !== "object")
|
|
101
|
+
return undefined;
|
|
102
|
+
if (depth >= CODED_DETAIL_DEPTH) {
|
|
103
|
+
budget.cuts++;
|
|
97
104
|
return undefined;
|
|
105
|
+
}
|
|
98
106
|
let isArray;
|
|
99
107
|
try {
|
|
100
108
|
if (ArrayBuffer.isView(value))
|
|
@@ -107,17 +115,29 @@ function leafOf(keyContext, read, depth, budget) {
|
|
|
107
115
|
if (!isArray)
|
|
108
116
|
return recordOf(value, depth, budget);
|
|
109
117
|
const length = readMember(value, "length");
|
|
110
|
-
if (typeof length !== "number" || !Number.isInteger(length) || length < 0
|
|
118
|
+
if (typeof length !== "number" || !Number.isInteger(length) || length < 0)
|
|
119
|
+
return undefined;
|
|
120
|
+
if (length > CODED_DETAIL_ENTRIES) {
|
|
121
|
+
budget.cuts++;
|
|
111
122
|
return undefined;
|
|
123
|
+
}
|
|
124
|
+
const entered = { values: budget.values, chars: budget.chars, cuts: budget.cuts };
|
|
112
125
|
if (!charge(budget, 0))
|
|
113
126
|
return undefined;
|
|
114
127
|
const items = [];
|
|
128
|
+
const dropped = () => {
|
|
129
|
+
const cutIn = budget.cuts > entered.cuts;
|
|
130
|
+
budget.values = entered.values;
|
|
131
|
+
budget.chars = entered.chars;
|
|
132
|
+
budget.cuts = entered.cuts + (cutIn ? 1 : 0);
|
|
133
|
+
return undefined;
|
|
134
|
+
};
|
|
115
135
|
const handed = Array.from({ length }, (_, i) => readMember(value, String(i)));
|
|
116
136
|
for (let i = 0; i < length; i++) {
|
|
117
137
|
const before = handed[i - 1];
|
|
118
138
|
const item = leafOf(typeof before === "string" && namesCredential(before) ? before : keyContext, () => handed[i], depth + 1, budget);
|
|
119
|
-
if (item === undefined)
|
|
120
|
-
return
|
|
139
|
+
if (item === undefined || budget.cuts > entered.cuts)
|
|
140
|
+
return dropped();
|
|
121
141
|
items.push(item);
|
|
122
142
|
}
|
|
123
143
|
return items;
|
|
@@ -144,14 +164,22 @@ function recordOf(value, depth, budget) {
|
|
|
144
164
|
catch {
|
|
145
165
|
return undefined;
|
|
146
166
|
}
|
|
147
|
-
if (keys.length > CODED_DETAIL_ENTRIES
|
|
167
|
+
if (keys.length > CODED_DETAIL_ENTRIES) {
|
|
168
|
+
budget.cuts++;
|
|
169
|
+
return undefined;
|
|
170
|
+
}
|
|
171
|
+
if ((keys.length > 0 && keys.every((k) => INDEX_KEY_RE.test(k))) || !charge(budget, 0))
|
|
148
172
|
return undefined;
|
|
149
173
|
const nameMembers = new Map();
|
|
150
174
|
const paired = pairedNameOf(value, keys, nameMembers);
|
|
151
175
|
const out = {};
|
|
152
176
|
for (const key of keys) {
|
|
153
|
-
if (!isProviderEchoShape(key) || carriesCredential(key)
|
|
177
|
+
if (!isProviderEchoShape(key) || carriesCredential(key))
|
|
178
|
+
continue;
|
|
179
|
+
if (budget.chars + key.length > CODED_DETAIL_CHARS) {
|
|
180
|
+
budget.cuts++;
|
|
154
181
|
continue;
|
|
182
|
+
}
|
|
155
183
|
const charsBefore = budget.chars;
|
|
156
184
|
budget.chars += key.length;
|
|
157
185
|
const context = paired !== undefined && VALUE_POSITION_KEYS.has(key.toLowerCase()) ? paired : key;
|
|
@@ -171,7 +199,7 @@ function detailRecordOf(detail) {
|
|
|
171
199
|
catch {
|
|
172
200
|
return undefined;
|
|
173
201
|
}
|
|
174
|
-
return recordOf(detail, 0, { values: 0, chars: 0 });
|
|
202
|
+
return recordOf(detail, 0, { values: 0, chars: 0, cuts: 0 });
|
|
175
203
|
}
|
|
176
204
|
function codedFailureDetailOf(link) {
|
|
177
205
|
const detail = detailRecordOf(readMember(link, "detail"));
|