@sema-agent/core 7.67.3 → 7.68.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +1516 -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 +25 -1
- package/dist/core/checkpoint-requirements.js +5 -1
- package/dist/core/checkpoint-row-verdict.d.ts +1 -0
- package/dist/core/checkpoint-row-verdict.js +4 -0
- package/dist/core/checkpoint-store.d.ts +66 -38
- package/dist/core/checkpoint-store.js +15 -6
- package/dist/core/child-clamp-seats.d.ts +6 -0
- package/dist/core/child-clamp-seats.js +1 -0
- package/dist/core/config-refusal-codes.d.ts +1 -1
- package/dist/core/config-refusal-codes.js +1 -0
- package/dist/core/delegation-frames.d.ts +9 -12
- package/dist/core/delegation-frames.js +9 -8
- package/dist/core/engine-capabilities.d.ts +21 -8
- package/dist/core/engine-capabilities.js +1 -1
- package/dist/core/engine-notice.d.ts +147 -34
- package/dist/core/engine-notice.js +27 -16
- package/dist/core/engine-storage-backend.d.ts +2 -1
- package/dist/core/env-budget.js +3 -3
- package/dist/core/env-knob-announce.d.ts +10 -10
- package/dist/core/env-knob-announce.js +3 -6
- package/dist/core/file-history-store.d.ts +29 -4
- package/dist/core/file-history-store.js +13 -0
- package/dist/core/frame-settlement.d.ts +2 -1
- package/dist/core/gate-fold.js +1 -1
- package/dist/core/gate-lanes.js +56 -49
- package/dist/core/governance-codes.d.ts +39 -3
- package/dist/core/governance-codes.js +61 -3
- package/dist/core/hooks.d.ts +29 -11
- package/dist/core/hooks.js +5 -2
- package/dist/core/human-input-projection.js +3 -3
- package/dist/core/input-author.d.ts +17 -3
- package/dist/core/input-author.js +15 -3
- package/dist/core/leg-identity.d.ts +10 -28
- package/dist/core/leg-identity.js +1 -21
- package/dist/core/lsp.d.ts +18 -13
- package/dist/core/lsp.js +30 -22
- package/dist/core/mailbox-store.d.ts +1 -1
- package/dist/core/mailbox-store.js +4 -4
- package/dist/core/mcp-connection-pool.d.ts +93 -4
- package/dist/core/mcp-connection-pool.js +104 -1
- package/dist/core/mcp-failure.d.ts +38 -12
- package/dist/core/mcp-failure.js +9 -13
- package/dist/core/mcp-probe.d.ts +4 -3
- package/dist/core/mcp-server-link.d.ts +4 -2
- package/dist/core/mcp-server-link.js +4 -5
- package/dist/core/mcp-server-spec.d.ts +3 -3
- package/dist/core/mcp-server-unavailable-notice.d.ts +22 -8
- package/dist/core/mcp-server-unavailable-notice.js +18 -4
- package/dist/core/mcp.d.ts +40 -6
- package/dist/core/mcp.js +39 -13
- package/dist/core/memory-engine/content-origin.js +2 -2
- package/dist/core/memory-engine/control-objects.d.ts +2 -4
- package/dist/core/memory-engine/control-objects.js +2 -10
- package/dist/core/memory-engine/delegation-settlement.js +6 -1
- package/dist/core/memory-engine/dual-root.js +3 -0
- package/dist/core/memory-engine/engine.d.ts +6 -4
- package/dist/core/memory-engine/engine.js +32 -29
- package/dist/core/memory-engine/file-backend.d.ts +20 -5
- package/dist/core/memory-engine/file-backend.js +21 -31
- package/dist/core/memory-engine/frontmatter.d.ts +2 -0
- package/dist/core/memory-engine/frontmatter.js +4 -0
- package/dist/core/memory-engine/layout.d.ts +114 -20
- package/dist/core/memory-engine/layout.js +340 -22
- package/dist/core/memory-engine/memory-deployment.d.ts +7 -5
- package/dist/core/memory-engine/mount-failed-notice.d.ts +19 -7
- package/dist/core/memory-engine/mount-failed-notice.js +43 -10
- package/dist/core/memory-engine/sync-client.js +4 -5
- package/dist/core/model-fallbacks.d.ts +5 -1
- package/dist/core/model-fallbacks.js +3 -3
- package/dist/core/model-receipt.d.ts +2 -1
- package/dist/core/model-receipt.js +12 -1
- package/dist/core/mods/kernel/dispatch.d.ts +2 -2
- package/dist/core/mods/kernel/dispatch.js +14 -6
- package/dist/core/mods/kernel/events.d.ts +8 -5
- package/dist/core/mods/kernel/events.js +2 -2
- package/dist/core/mods/kernel/index.d.ts +1 -1
- package/dist/core/mods/kernel/registration.d.ts +9 -0
- package/dist/core/mods/package.js +1 -1
- package/dist/core/mods/session-append.d.ts +4 -2
- package/dist/core/mods/session-append.js +3 -0
- package/dist/core/mods/stations.d.ts +7 -11
- package/dist/core/mods/stations.js +4 -7
- package/dist/core/mods/tool-call.d.ts +10 -8
- package/dist/core/mods/tool-call.js +15 -18
- package/dist/core/mounted-mcp.d.ts +0 -4
- package/dist/core/mounted-mcp.js +1 -1
- package/dist/core/park-noun.d.ts +24 -0
- package/dist/core/park-noun.js +21 -0
- package/dist/core/park-resumability.d.ts +60 -0
- package/dist/core/park-resumability.js +30 -0
- package/dist/core/permission-rule-provider.d.ts +24 -2
- package/dist/core/permission-rule-provider.js +11 -8
- package/dist/core/permission-rule-store.d.ts +8 -1
- package/dist/core/permission-rule-store.js +2 -3
- package/dist/core/permission-rules.d.ts +2 -1
- package/dist/core/permission-rules.js +8 -4
- package/dist/core/persisted-rule-arms.d.ts +3 -0
- package/dist/core/persisted-rule-arms.js +2 -1
- package/dist/core/present-plan-tool.d.ts +47 -3
- package/dist/core/present-plan-tool.js +62 -4
- package/dist/core/principal-name.d.ts +1 -1
- package/dist/core/principal-name.js +5 -5
- package/dist/core/process-identity.js +10 -5
- package/dist/core/protocol-http-auth.d.ts +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 +6 -0
- package/dist/core/tool-roster.js +18 -0
- package/dist/core/tool-spec.d.ts +17 -8
- package/dist/core/trace.d.ts +35 -31
- package/dist/core/types.d.ts +2 -2
- package/dist/core/untrusted-egress.d.ts +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@7.68.0.json +4257 -0
- package/wire-changes/mods-kernel@7.68.0.json +129 -0
- package/wire-changes/primitives@7.68.0.json +253 -0
- package/wire-changes/wiki-gate@7.68.0.json +39 -0
- package/dist/core/runner/credential-origin-seat.d.ts +0 -2
- package/dist/core/runner/credential-origin-seat.js +0 -20
|
@@ -1,22 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
1
|
+
import { storeFormRefusalReadingOf } from "./layout.js";
|
|
2
|
+
const OPERATOR_TAIL = "Whoever runs this deployment can do this (the service log names the exact step); the next run mounts it again.";
|
|
3
|
+
const OUTSIDE = {
|
|
4
|
+
act_outside: {
|
|
5
|
+
clause: "a folder inside the memory store is a link that points to a place outside it",
|
|
6
|
+
restore: "replace that link inside the memory store with a real directory",
|
|
7
|
+
tail: OPERATOR_TAIL,
|
|
8
|
+
},
|
|
9
|
+
root_moved: {
|
|
10
|
+
clause: "the memory store's directory now leads to a different place than the one it was set up in",
|
|
11
|
+
restore: "put the memory directory back where it was — or, if it was moved on purpose, confirm its new location",
|
|
12
|
+
tail: OPERATOR_TAIL,
|
|
13
|
+
},
|
|
14
|
+
root_gone: {
|
|
15
|
+
clause: "the memory store's directory is no longer where it was set up",
|
|
16
|
+
restore: "put the memory directory back — or, if it was moved on purpose, confirm its new location (to start over, create it again and confirm it there)",
|
|
17
|
+
tail: OPERATOR_TAIL,
|
|
18
|
+
},
|
|
19
|
+
root_reanchored: {
|
|
20
|
+
clause: "the memory this conversation opened has been moved to another place since",
|
|
21
|
+
restore: "start a new conversation, which opens it in its new place",
|
|
22
|
+
tail: "Nothing else needs doing.",
|
|
23
|
+
},
|
|
24
|
+
};
|
|
3
25
|
const CLAUSE = {
|
|
4
|
-
"memory.target_outside_store": "a path of the memory store resolves outside the store (a symbolic link points out of it, or its root moved)",
|
|
5
26
|
"memory.scope_home_not_directory": "a memory scope's directory is a symbolic link or not a real directory",
|
|
6
27
|
"memory.control_plane_links_unsupported": "the file system under the memory store cannot make hard links",
|
|
7
|
-
"memory.control_plane_strays": "
|
|
28
|
+
"memory.control_plane_strays": "memory records from an earlier setup are still kept beside the current ones, and nothing reads them",
|
|
8
29
|
"memory.store_root_sensitive": "the memory store is configured inside a directory the engine's write guard protects (a credential or access-control directory)",
|
|
30
|
+
"memory.control_plane_split": "since the memory store's location was moved, what is kept beside it stands in two places that disagree",
|
|
9
31
|
unclassified: "the memory store could not be opened",
|
|
10
32
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
33
|
+
const RESTORE = {
|
|
34
|
+
"memory.scope_home_not_directory": "replace that link or file with a real directory",
|
|
35
|
+
"memory.control_plane_links_unsupported": "move the memory store to a disk that supports hard links",
|
|
36
|
+
"memory.control_plane_strays": "merge the memory records the earlier setup left beside the current ones",
|
|
37
|
+
"memory.store_root_sensitive": "point the memory store at a directory outside the protected one",
|
|
38
|
+
"memory.control_plane_split": "keep one of the two copies of each record the service log names and remove the other",
|
|
39
|
+
unclassified: "check the service log for why the memory store could not be opened",
|
|
40
|
+
};
|
|
41
|
+
export function memoryMountFailedReadingOf(thrown) {
|
|
42
|
+
const refusal = storeFormRefusalReadingOf(thrown);
|
|
43
|
+
if (refusal === undefined)
|
|
44
|
+
return { cause: "unclassified" };
|
|
45
|
+
return "outsideReason" in refusal ? { cause: refusal.code, outsideReason: refusal.outsideReason } : { cause: refusal.code };
|
|
14
46
|
}
|
|
15
47
|
export function memoryMountFailedNotice(input) {
|
|
48
|
+
const words = "outsideReason" in input ? OUTSIDE[input.outsideReason] : { clause: CLAUSE[input.cause], restore: RESTORE[input.cause], tail: OPERATOR_TAIL };
|
|
16
49
|
return {
|
|
17
50
|
code: "memory.mount_failed",
|
|
18
|
-
message: `Memory did not mount for this session: ${
|
|
19
|
-
`and nothing is saved into that memory store in this session
|
|
20
|
-
detail: { sessionId: input.sessionId, scopes: [...input.scopes], cause: input.cause },
|
|
51
|
+
message: `Memory did not mount for this session: ${words.clause}. The task runs without it — stored memory is not available to the assistant, ` +
|
|
52
|
+
`and nothing is saved into that memory store in this session. To restore it: ${words.restore}. ${words.tail}`,
|
|
53
|
+
detail: { sessionId: input.sessionId, scopes: [...input.scopes], cause: input.cause, ...("outsideReason" in input ? { outsideReason: input.outsideReason } : {}) },
|
|
21
54
|
};
|
|
22
55
|
}
|
|
@@ -7,8 +7,7 @@ import { MEMORY_ORIGIN_CAUSES } from "./types.js";
|
|
|
7
7
|
import { directoryPinOf } from "./dual-root.js";
|
|
8
8
|
import { landingPathOf } from "./layout.js";
|
|
9
9
|
import { egressText } from "../untrusted-egress.js";
|
|
10
|
-
import { userinfoHolds } from "@sema-agent/primitives";
|
|
11
|
-
import { REDACTION_MARKS } from "../redaction-marks.js";
|
|
10
|
+
import { REDACTION_MARKS, userinfoHolds } from "@sema-agent/primitives";
|
|
12
11
|
import { isReplicableScope } from "./scope-contract.js";
|
|
13
12
|
const DROP_THE_CURSOR = "drop the cursor to accept re-convergence from an empty baseline — entries changed on both sides are reported as conflicts, " +
|
|
14
13
|
"and entries deleted on one side since the last round come back from the other side";
|
|
@@ -63,7 +62,7 @@ function syncRefusal(on, head, want) {
|
|
|
63
62
|
}
|
|
64
63
|
else {
|
|
65
64
|
e.code = "config.memory_sync_cursor_mismatch";
|
|
66
|
-
e.detail = Object.freeze({ axis: on.axis, found: on.found, want: carriesCredential(want) ? REDACTION_MARKS.
|
|
65
|
+
e.detail = Object.freeze({ axis: on.axis, found: on.found, want: carriesCredential(want) ? REDACTION_MARKS.bare : want });
|
|
67
66
|
}
|
|
68
67
|
e.outs = outs;
|
|
69
68
|
MINTED_REFUSALS.add(e);
|
|
@@ -109,7 +108,7 @@ const namesSomething = (v) => typeof v === "string" && v.trim().length > 0;
|
|
|
109
108
|
function quoted(v) {
|
|
110
109
|
if (typeof v !== "string")
|
|
111
110
|
return JSON.stringify(typeof v);
|
|
112
|
-
return carriesCredential(v) ? REDACTION_MARKS.
|
|
111
|
+
return carriesCredential(v) ? REDACTION_MARKS.bare : JSON.stringify(v);
|
|
113
112
|
}
|
|
114
113
|
const isAsciiLetter = (c) => (c >= 65 && c <= 90) || (c >= 97 && c <= 122);
|
|
115
114
|
const isSchemeChar = (c) => isAsciiLetter(c) || (c >= 48 && c <= 57) || c === 43 || c === 45 || c === 46;
|
|
@@ -354,7 +353,7 @@ export async function syncMemoryScope(opts) {
|
|
|
354
353
|
throw new Error("memory sync: scope must be a non-empty string");
|
|
355
354
|
if (!isReplicableScope(scope)) {
|
|
356
355
|
const e = new Error(egressText("same-principal", `memory sync: scope ${quoted(scope)} is a userlocal: key — its layer never leaves the store it is written in, so no sync carries it; ` +
|
|
357
|
-
"nothing was read or sent. Leave this
|
|
356
|
+
"nothing was read or sent. Leave this scope out of what you sync; memory meant to travel goes under a scope that does not start with userlocal:."));
|
|
358
357
|
e.code = "config.memory_scope_key";
|
|
359
358
|
throw e;
|
|
360
359
|
}
|
|
@@ -30,7 +30,11 @@ export declare const DEGRADE_REASONS: readonly ["breaker_open", "rate_limit", "b
|
|
|
30
30
|
export type DegradeReason = (typeof DEGRADE_REASONS)[number];
|
|
31
31
|
/** Whether a value is one of the reason words. */
|
|
32
32
|
export declare function isDegradeReason(value: unknown): value is DegradeReason;
|
|
33
|
-
/** The
|
|
33
|
+
/** The words a gate may hold: every reason but `budget`. The one list the policy door judges a gate against and every refusal
|
|
34
|
+
* sentence that names the words reads, and the one a deployment's own documentation or completion reads at runtime
|
|
35
|
+
* (a root export, frozen). */
|
|
36
|
+
export declare const MODEL_FALLBACK_GATE_WORDS: readonly Exclude<DegradeReason, "budget">[];
|
|
37
|
+
/** The gate a deployment that configures none walks on: the four reactive classes (a root export, frozen). */
|
|
34
38
|
export declare const DEFAULT_FALLBACK_GATE: readonly DegradeReason[];
|
|
35
39
|
/** What a gate row may admit besides a list of reason words: every failure the shared judge lets through at all. */
|
|
36
40
|
export declare const ANY_HOP_FAILURE: "any";
|
|
@@ -6,6 +6,7 @@ const DEGRADE_REASON_SET = new Set(DEGRADE_REASONS);
|
|
|
6
6
|
export function isDegradeReason(value) {
|
|
7
7
|
return typeof value === "string" && DEGRADE_REASON_SET.has(value);
|
|
8
8
|
}
|
|
9
|
+
export const MODEL_FALLBACK_GATE_WORDS = Object.freeze(DEGRADE_REASONS.filter((r) => r !== "budget"));
|
|
9
10
|
export const DEFAULT_FALLBACK_GATE = Object.freeze(["rate_limit", "breaker_open", "server_error", "last_resort"]);
|
|
10
11
|
export const ANY_HOP_FAILURE = "any";
|
|
11
12
|
export const GATEWAY_HOP_GATE = Object.freeze({ on: ANY_HOP_FAILURE });
|
|
@@ -35,7 +36,6 @@ const RECEIVED_POLICIES = new WeakSet();
|
|
|
35
36
|
export const DEFAULT_MODEL_FALLBACK_POLICY = Object.freeze({ on: DEFAULT_FALLBACK_GATE });
|
|
36
37
|
RECEIVED_POLICIES.add(DEFAULT_MODEL_FALLBACK_POLICY);
|
|
37
38
|
const POLICY_KEYS = ["on", "firstTokenMs"];
|
|
38
|
-
const GATE_WORDS = DEGRADE_REASONS.filter((r) => r !== "budget");
|
|
39
39
|
export function receiveModelFallbackPolicy(value, field) {
|
|
40
40
|
if (value === undefined)
|
|
41
41
|
return DEFAULT_MODEL_FALLBACK_POLICY;
|
|
@@ -49,12 +49,12 @@ export function receiveModelFallbackPolicy(value, field) {
|
|
|
49
49
|
let on = DEFAULT_MODEL_FALLBACK_POLICY.on;
|
|
50
50
|
if (held.on !== undefined) {
|
|
51
51
|
if (!Array.isArray(held.on))
|
|
52
|
-
throw modelFallbackRefusal(`${field}.on`, `${field}.on is ${describeRejectedValue(held.on)} — it lists reason words (${
|
|
52
|
+
throw modelFallbackRefusal(`${field}.on`, `${field}.on is ${describeRejectedValue(held.on)} — it lists reason words (${MODEL_FALLBACK_GATE_WORDS.join(", ")}).`);
|
|
53
53
|
const listed = held.on;
|
|
54
54
|
const seen = [];
|
|
55
55
|
for (const word of listed) {
|
|
56
56
|
if (!isDegradeReason(word) || word === "budget") {
|
|
57
|
-
throw modelFallbackRefusal(`${field}.on`, `${field}.on holds ${describeRejectedValue(word)}, which is not a fallback reason — the words are ${
|
|
57
|
+
throw modelFallbackRefusal(`${field}.on`, `${field}.on holds ${describeRejectedValue(word)}, which is not a fallback reason — the words are ${MODEL_FALLBACK_GATE_WORDS.join(", ")} (\`budget\` is the run's near-budget switch, never a gate word).`);
|
|
58
58
|
}
|
|
59
59
|
if (seen.includes(word))
|
|
60
60
|
throw modelFallbackRefusal(`${field}.on`, `${field}.on names ${JSON.stringify(word)} twice.`);
|
|
@@ -41,7 +41,8 @@ export declare function forkModelSnapshot(snapshot: Model): Model;
|
|
|
41
41
|
* `not_a_model_ref`; a retired member — `config.deps_retired_key` (its own sentence); a member outside the contract — `not_a_model_ref`
|
|
42
42
|
* (a provider's own parameters belong in `Model.params`); an `id` that is not a non-empty string or an `api` that is not a string —
|
|
43
43
|
* `not_a_model_ref`, naming the member; a `defaultThinking` that is present but not one of the seven tiers — `not_a_model_ref`, naming
|
|
44
|
-
* the member; a `fallbacks` that is present but not a list of non-empty strings — `not_a_model_ref`, naming the member
|
|
44
|
+
* the member; a `fallbacks` that is present but not a list of non-empty strings — `not_a_model_ref`, naming the member; a
|
|
45
|
+
* `compat.thinkingFormat` that is present, not `null` and not a chat-completions dialect name — `not_a_model_ref`, naming the member.
|
|
45
46
|
*
|
|
46
47
|
* `fallbacks` is a CATALOG member: its words are resolved by the catalog door over the catalog it receives
|
|
47
48
|
* (`model-fallbacks.ts`), so only the catalog door's own receipt (`catalogEntry`: a catalog entry, a tier's model object) takes a
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { types } from "node:util";
|
|
2
|
-
import { isThinkingLevel, THINKING_LEVELS } from "../brain/reasoning.js";
|
|
2
|
+
import { COMPLETIONS_THINKING_FORMATS, declaredCompletionsFormat, isThinkingLevel, THINKING_LEVELS } from "../brain/reasoning.js";
|
|
3
3
|
import { describeFault, receive } from "./mods/kernel/receive.js";
|
|
4
4
|
import { DECLARATION_RECEIPT_MODE } from "./own-property-receipt.js";
|
|
5
5
|
import { assertNoRetiredKeys, RETIRED_MODEL_KEYS } from "./retired-keys.js";
|
|
@@ -121,6 +121,17 @@ function judgeModelCopy(copy, seat, what, note) {
|
|
|
121
121
|
if (defaultThinking !== undefined && !isThinkingLevel(defaultThinking)) {
|
|
122
122
|
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`defaultThinking\` is ${bindingShown(defaultThinking)} — a model's default thinking level is one of ${THINKING_LEVELS.join(", ")} ("off" spells thinking off), or absent for no default.${note}`);
|
|
123
123
|
}
|
|
124
|
+
const compat = copy["compat"];
|
|
125
|
+
if (typeof compat === "object" && compat !== null) {
|
|
126
|
+
try {
|
|
127
|
+
declaredCompletionsFormat(compat);
|
|
128
|
+
}
|
|
129
|
+
catch (e) {
|
|
130
|
+
if (e.code !== "config.invalid_argument")
|
|
131
|
+
throw e;
|
|
132
|
+
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`compat.thinkingFormat\` is ${bindingShown(compat.thinkingFormat)} — a chat-completions thinking dialect is one of ${COMPLETIONS_THINKING_FORMATS.join(", ")}, or absent for "openai".${note}`);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
124
135
|
const fallbacks = copy["fallbacks"];
|
|
125
136
|
if (fallbacks !== undefined && (!isList(fallbacks) || !fallbacks.every((w) => typeof w === "string" && w !== ""))) {
|
|
126
137
|
throw modelBindingRefusal(seat, "not_a_model_ref", `${seat} is ${what} whose \`fallbacks\` is ${bindingShown(fallbacks)} — a model's fallbacks are a list of catalog words (non-empty strings), or absent for none.${note}`);
|
|
@@ -43,8 +43,8 @@ export type ModDispatchOutcome = {
|
|
|
43
43
|
readonly answeredBy?: string;
|
|
44
44
|
readonly skipped: readonly ModSkip[];
|
|
45
45
|
}
|
|
46
|
-
/** `bottomStarted`: the chain's bottom had started when the handler failed — on
|
|
47
|
-
*
|
|
46
|
+
/** `bottomStarted`: the chain's bottom had started when the handler failed — on a `refuse` event, what it did happened
|
|
47
|
+
* (a `refuse_until_run` event never fails once the failing handler's own `next` started it: that handler is skipped). */
|
|
48
48
|
| {
|
|
49
49
|
readonly kind: "failed";
|
|
50
50
|
readonly registration: string;
|
|
@@ -401,6 +401,9 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
401
401
|
}
|
|
402
402
|
const observers = all.filter((p) => !p.reentry && p.h.observe).map((p) => p.h);
|
|
403
403
|
const chain = all.filter((p) => !p.h.observe).map((p) => p.h);
|
|
404
|
+
const roster = chain.map(participantOf);
|
|
405
|
+
const belows = [];
|
|
406
|
+
const belowOf = (i) => (belows[i] ??= Object.freeze(roster.slice(i + 1)));
|
|
404
407
|
const reentered = new Set(all.filter((p) => p.reentry).map((p) => p.h));
|
|
405
408
|
const skipped = [];
|
|
406
409
|
const producers = new Map();
|
|
@@ -580,6 +583,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
580
583
|
origin: { value: origin, enumerable: true },
|
|
581
584
|
signal: { value: base.signal, enumerable: true },
|
|
582
585
|
trace: { get: base.trace, enumerable: true },
|
|
586
|
+
below: { value: base.below, enumerable: true },
|
|
583
587
|
budget: { get: () => base.budget.reading(), enumerable: true },
|
|
584
588
|
...(caught !== undefined ? { error: { value: caught.error, enumerable: true }, called: { value: caught.called, enumerable: true } } : {}),
|
|
585
589
|
});
|
|
@@ -630,7 +634,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
630
634
|
failure = { cause: "reentry", reason: "not run: the dispatch re-entered a frame it is part of" };
|
|
631
635
|
}
|
|
632
636
|
else {
|
|
633
|
-
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => descend(x, floors), to);
|
|
637
|
+
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]), below: belowOf(i) }, (x) => descend(x, floors), to);
|
|
634
638
|
handlerP = runWithDollar(h.reg, myFrames, budget, ac.signal, engines, ($) => h.fn($, e, next));
|
|
635
639
|
try {
|
|
636
640
|
const raced = await Promise.race([handlerP, budget.expired]);
|
|
@@ -735,7 +739,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
735
739
|
};
|
|
736
740
|
const message = failure.cause === "threw" ? describe(failure.error) : failure.cause === "violation" ? failure.reason : undefined;
|
|
737
741
|
const error = Object.freeze({ kind: failure.cause, ...(message !== undefined ? { message } : {}), budget: catchMs });
|
|
738
|
-
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]) }, (x) => replay(x, floors), (x, tier) => {
|
|
742
|
+
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([...state.below]), below: belowOf(i) }, (x) => replay(x, floors), (x, tier) => {
|
|
739
743
|
const why = nextToRefusal(h.reg.tier, tier);
|
|
740
744
|
return why !== undefined ? Promise.reject(new Error(`${h.reg.name}: ${why}`)) : replay(x, [...floors, { from: h.reg.tier, to: tier }]);
|
|
741
745
|
}, { error, called: state.called });
|
|
@@ -766,7 +770,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
766
770
|
const budget = createSelfBudget(budgetMs, () => ac.abort(new Error(`${name} ran past its ${budgetMs}ms budget`)));
|
|
767
771
|
const myFrames = handlerFrame(fr, name, h.index, event);
|
|
768
772
|
const refuse = () => Promise.reject(new Error(`${name}: an observe handler is not in the chain; next() is unavailable`));
|
|
769
|
-
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([]) }, refuse, refuse);
|
|
773
|
+
const next = makeNext({ budget, signal: ac.signal, trace: () => Object.freeze([]), below: NOTHING_BELOW }, refuse, refuse);
|
|
770
774
|
const verdict = (r) => {
|
|
771
775
|
if (r === undefined)
|
|
772
776
|
return;
|
|
@@ -790,7 +794,7 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
790
794
|
live.add(cac);
|
|
791
795
|
const catchMs = ownMs(CATCH_BUDGET_MS);
|
|
792
796
|
const catchBudget = createSelfBudget(catchMs, () => cac.abort(new Error(`${name}: its .catch ran past its ${catchMs}ms budget`)));
|
|
793
|
-
const cnext = makeNext({ budget: catchBudget, signal: cac.signal, trace: () => Object.freeze([]) }, refuse, refuse, {
|
|
797
|
+
const cnext = makeNext({ budget: catchBudget, signal: cac.signal, trace: () => Object.freeze([]), below: NOTHING_BELOW }, refuse, refuse, {
|
|
794
798
|
error: Object.freeze({ kind: cause, ...(cause === "threw" ? { message: describe(err) } : {}), budget: catchMs }),
|
|
795
799
|
called: false,
|
|
796
800
|
});
|
|
@@ -847,13 +851,17 @@ function createBus(side, mounted, bottoms, entries, report, records, describe, i
|
|
|
847
851
|
return bus;
|
|
848
852
|
}
|
|
849
853
|
function admits(participant, h) {
|
|
850
|
-
return participant === undefined || participant(
|
|
854
|
+
return participant === undefined || participant(participantOf(h));
|
|
851
855
|
}
|
|
856
|
+
function participantOf(h) {
|
|
857
|
+
return Object.freeze({ plugin: h.reg.name, seat: h.reg.seat, observe: h.observe });
|
|
858
|
+
}
|
|
859
|
+
const NOTHING_BELOW = Object.freeze([]);
|
|
852
860
|
function answererOf(h) {
|
|
853
861
|
return { plugin: h.reg.name, seat: h.reg.seat, tier: h.reg.tier };
|
|
854
862
|
}
|
|
855
863
|
function hasNextShape(f) {
|
|
856
|
-
return typeof f === "function" && "to" in f && "trace" in f && "budget" in f && "signal" in f && "origin" in f;
|
|
864
|
+
return typeof f === "function" && "to" in f && "trace" in f && "below" in f && "budget" in f && "signal" in f && "origin" in f;
|
|
857
865
|
}
|
|
858
866
|
function invokeNow(f) {
|
|
859
867
|
try {
|
|
@@ -52,8 +52,11 @@
|
|
|
52
52
|
* that same frame and the bus's lifetime (`ModBusInput.lifetime`), and is refused once the lifetime ends.
|
|
53
53
|
* `classic.Stop` / `classic.SubagentStop` take `{ end }`, and each seat is judged in its own pass (task, then deployment): a
|
|
54
54
|
* handler's `next` reaches its own seat and the engine's bottom.
|
|
55
|
+
* 11: `tool.call`'s failure column is `refuse_until_run` again — a handler that fails once its own `next` ran the tool's body is
|
|
56
|
+
* skipped and its last `next()` run's result stands — and its station takes a `{ deny }` given over what that `next` answered
|
|
57
|
+
* once the body ran: the call ran and its result is withheld.
|
|
55
58
|
*/
|
|
56
|
-
export declare const KERNEL_CONTRACT_VERSION =
|
|
59
|
+
export declare const KERNEL_CONTRACT_VERSION = 11;
|
|
57
60
|
/** The five tiers in run order (CC names). `builtin` and `core` are the engine's own. */
|
|
58
61
|
export declare const MOD_TIERS: readonly ["prepend", "user", "append", "builtin", "core"];
|
|
59
62
|
export type ModTier = (typeof MOD_TIERS)[number];
|
|
@@ -69,10 +72,10 @@ export type ModEventSide = (typeof MOD_EVENT_SIDES)[number];
|
|
|
69
72
|
export type ModBusSide = Exclude<ModEventSide, "both">;
|
|
70
73
|
/**
|
|
71
74
|
* What a handler's failure means for the dispatch: the station's refusal (final); skip the handler; or — on an event whose
|
|
72
|
-
* bottom
|
|
73
|
-
* while the bottom has not started and, once
|
|
74
|
-
*
|
|
75
|
-
* dispatch's `failed` outcome says
|
|
75
|
+
* bottom, once started, is what stands (`agent.spawn`: the subagent is let start; `tool.call`: the tool ran) — the refusal
|
|
76
|
+
* while the bottom has not started and, once the handler's own `next` has started it, the handler is skipped and its last
|
|
77
|
+
* `next()` run's answer stands (the failure is reported beside it). A `refuse` station refuses whether or not its bottom has
|
|
78
|
+
* started; the dispatch's `failed` outcome says when it had.
|
|
76
79
|
*/
|
|
77
80
|
export declare const MOD_FAILURE_ANSWERS: readonly ["refuse", "skip", "refuse_until_run"];
|
|
78
81
|
export type ModFailureAnswer = (typeof MOD_FAILURE_ANSWERS)[number];
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export const KERNEL_CONTRACT_VERSION =
|
|
1
|
+
export const KERNEL_CONTRACT_VERSION = 11;
|
|
2
2
|
export const MOD_TIERS = Object.freeze(["prepend", "user", "append", "builtin", "core"]);
|
|
3
3
|
export const MOD_SEATS = Object.freeze(["deployment", "task"]);
|
|
4
4
|
export const MOD_EVENT_SIDES = Object.freeze(["engine", "surface", "both"]);
|
|
@@ -82,7 +82,7 @@ export const MOD_EVENT_TABLE = Object.freeze({
|
|
|
82
82
|
"classic.FileChanged": engine(),
|
|
83
83
|
"classic.DirectoryAdded": engine(),
|
|
84
84
|
"classic.MessageDisplay": engine(station("skip", "immediate", ["messageId", "turn", "index", "final", "agentId"], { budgetMs: 10_000 })),
|
|
85
|
-
"tool.call": engine(station("
|
|
85
|
+
"tool.call": engine(station("refuse_until_run", "immediate", ["tool", "tool_use_id", "agentId", "input"], { call: true })),
|
|
86
86
|
"tool.check": engine(station("refuse", "immediate", ["tool", "input", "tool_use_id", "agentId", "ceiling"])),
|
|
87
87
|
"ui.render": surface(station("skip", "grace", RENDER_PINNED)),
|
|
88
88
|
"ui.resolve": surface(station("skip", "grace", ["surface", "component"])),
|
|
@@ -3,4 +3,4 @@ export { KERNEL_CONTRACT_VERSION, MOD_TIERS, MOD_SEATS, MOD_EVENT_SIDES, MOD_FAI
|
|
|
3
3
|
export { DEFAULT_MOD_BUDGET_MS, CATCH_BUDGET_MS, RUNAWAY_AFTER_MS, POST_ABORT_GRACE_MS, MAX_TIMER_MS, clockMsRefusal, resolveModBudgetMs, type ModBudgetReading, } from "./budget.js";
|
|
4
4
|
export { MOD_FAILURE_CAUSES, type ModFailureCause, type ModEventPayload, type ModAnswerCheck, type ModAnswerRanks, type ModDispatchRun, type ModAnswerer, type ModMatcher, type ModSkip, } from "./site-rules.js";
|
|
5
5
|
export { ENGINE_ORIGIN, MODS_INVALID_CODE, MODS_REGISTRATION_REFUSED_CODE, MOD_TRACE_OUTCOMES, type ModTraceOutcome, type ModUses, type ModOrigin, type ModPluginFacts, type ModDollarBase, type ModTraceEntry, type ModCaughtError, type ModNext, type ModHandler, type ModHandlerOptions, type ModEventPair, type ModEventMap, type ModTypedNext, type ModTypedHandler, type On, type MappedOn, type ModRegistration, type ModAdmissionRecord, type ModSeats, } from "./registration.js";
|
|
6
|
-
export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModCallEntry, type ModCallEntries, type ModDispatchOutcome, type ModDispatchOptions, type ModBus, type ModMountedHandler, type ModBusInput, type ModTimer, } from "./dispatch.js";
|
|
6
|
+
export { admitMods, type ModFrame, type ModBottomContext, type ModMethodBottom, type ModMethodSeat, type ModMethodBottoms, type ModCallEntry, type ModCallEntries, type ModDispatchOutcome, type ModDispatchOptions, type ModParticipant, type ModBus, type ModMountedHandler, type ModBusInput, type ModTimer, } from "./dispatch.js";
|
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
*/
|
|
5
5
|
import { type ModBusSide, type ModEventName, type ModRegistrationTier, type ModSeat, type ModTier } from "./events.js";
|
|
6
6
|
import { type ModBudgetReading } from "./budget.js";
|
|
7
|
+
import type { ModParticipant } from "./dispatch.js";
|
|
7
8
|
import type { ModEventPayload, ModFailureCause, ModMatcher, ModSkip } from "./site-rules.js";
|
|
8
9
|
/** The configuration refusal: a registration the kernel cannot take refuses the whole prepare. */
|
|
9
10
|
export declare const MODS_INVALID_CODE = "config.mods_invalid";
|
|
@@ -63,6 +64,13 @@ export interface ModNext {
|
|
|
63
64
|
readonly signal: AbortSignal;
|
|
64
65
|
/** What ran beneath this handler's last `next`. */
|
|
65
66
|
readonly trace: readonly ModTraceEntry[];
|
|
67
|
+
/**
|
|
68
|
+
* Who stands in this dispatch's chain beneath this handler, in chain order — the chain as the dispatch assembled it, before
|
|
69
|
+
* anything ran (`trace` records those the run reached). A handler a matcher leaves out of the event is not a member; one the
|
|
70
|
+
* dispatch re-entered (asked through its `.catch`) is. An observer is outside the chain — it ran before it, detached — so it
|
|
71
|
+
* is beneath no one, and an observer's own `below` is empty. Always present and frozen; empty when nothing stands beneath.
|
|
72
|
+
*/
|
|
73
|
+
readonly below: readonly ModParticipant[];
|
|
66
74
|
readonly budget: ModBudgetReading;
|
|
67
75
|
/** Present on a `.catch`'s `next` only. */
|
|
68
76
|
readonly error?: ModCaughtError;
|
|
@@ -92,6 +100,7 @@ export interface ModTypedNext<P extends ModEventPair> {
|
|
|
92
100
|
readonly origin: ModOrigin;
|
|
93
101
|
readonly signal: AbortSignal;
|
|
94
102
|
readonly trace: readonly ModTraceEntry[];
|
|
103
|
+
readonly below: readonly ModParticipant[];
|
|
95
104
|
readonly budget: ModBudgetReading;
|
|
96
105
|
readonly error?: ModCaughtError;
|
|
97
106
|
readonly called?: boolean;
|
|
@@ -56,7 +56,7 @@ export async function loadModPackage(dir, host = {}) {
|
|
|
56
56
|
}
|
|
57
57
|
async function realRoot(dir) {
|
|
58
58
|
try {
|
|
59
|
-
const root = await physicalPathOfAsync(
|
|
59
|
+
const root = await physicalPathOfAsync(dir);
|
|
60
60
|
if ((await stat(root)).isDirectory())
|
|
61
61
|
return root;
|
|
62
62
|
}
|
|
@@ -4,8 +4,10 @@
|
|
|
4
4
|
* THE RULE. A row enters the conversation at one point: its first commit point, before the live context reads it again and
|
|
5
5
|
* before the store keeps it. Every writer calls the seat there, once — the harness for the rows it commits (a row the loop
|
|
6
6
|
* ends, the record of an API failure, a row handed to its port), every direct writer of the leg through
|
|
7
|
-
* `appendAdmittedRow` (`row-admission.ts`).
|
|
8
|
-
* the
|
|
7
|
+
* `appendAdmittedRow` (`row-admission.ts`). There a user row that does not yet say what it is is stamped with its origin
|
|
8
|
+
* (`stampUserRowOrigin`, `user-row-origin.ts`: the one place every engine row gets the member the store keeps). With a handler on
|
|
9
|
+
* `session.append` the seat raises the event once per row; with none, or before the leg's bus is bound, the row passes as made and
|
|
10
|
+
* nothing is raised.
|
|
9
11
|
*
|
|
10
12
|
* `e = { door, origin, agentId?, message }` plus the identity envelope; `door`, `origin` and `agentId` are pinned. `door` and
|
|
11
13
|
* `origin` are read off the row's own typed facts ({@link doorOf}, {@link originOf}) — no writer names them; an extension's
|
|
@@ -2,6 +2,7 @@ import { answeredWithoutModel } from "../../internal/llm.js";
|
|
|
2
2
|
import { noteHostRewrite } from "../frame-settlement.js";
|
|
3
3
|
import { describeThrown } from "../tool-policy.js";
|
|
4
4
|
import { extensionWords } from "../untrusted-egress.js";
|
|
5
|
+
import { stampUserRowOrigin } from "../user-row-origin.js";
|
|
5
6
|
import { isPlainRecord } from "./kernel/receive.js";
|
|
6
7
|
import { NEXT_IN_FLIGHT, receiveEvent, sameModData } from "./kernel/site-rules.js";
|
|
7
8
|
import { classicEventBase, seatHears } from "./stations.js";
|
|
@@ -256,6 +257,8 @@ export function createRowSeat() {
|
|
|
256
257
|
};
|
|
257
258
|
return {
|
|
258
259
|
admitRows: (rows, raising) => {
|
|
260
|
+
for (const row of rows)
|
|
261
|
+
stampUserRowOrigin(row);
|
|
259
262
|
const raised = raising !== undefined ? raisings.get(raising) : undefined;
|
|
260
263
|
if (seatHears(bound, "session.append"))
|
|
261
264
|
return admitAll(rows, raised);
|
|
@@ -205,23 +205,19 @@ export declare function stringMembersOf<M extends string>(answer: unknown, membe
|
|
|
205
205
|
export declare function failedHandlerClause(f: Pick<Extract<ModDispatchOutcome, {
|
|
206
206
|
kind: "failed";
|
|
207
207
|
}>, "registration" | "cause" | "reason">): string;
|
|
208
|
-
/** The clause without the bus's reason, `crashed (extension "x")`: for a sentence in place of a result the handler saw (its
|
|
209
|
-
* reason may quote that result; the reason is said on the report sink). */
|
|
210
|
-
export declare function failedHandlerName(f: Extract<ModDispatchOutcome, {
|
|
211
|
-
kind: "failed";
|
|
212
|
-
}>): string;
|
|
213
208
|
/**
|
|
214
|
-
* The PermissionDenied station: the leg's `classic.PermissionDenied` handlers, then a host's
|
|
215
|
-
* driving the tool gate
|
|
216
|
-
* of a deny runs under
|
|
217
|
-
* abort) and none can hold the deny it reports. The raw observer's failure goes to `onHostObserverFailure`.
|
|
209
|
+
* The PermissionDenied station, the one body every refusal exit raises: the leg's `classic.PermissionDenied` handlers, then a host's
|
|
210
|
+
* own raw observer (a host driving the tool gate) as one more observe handler of the event on a bus of its own, so every observer
|
|
211
|
+
* of a deny runs under the station's columns (budget, skip on failure, grace past an abort) and none can hold the deny it reports.
|
|
218
212
|
*/
|
|
219
213
|
export declare function observePermissionDenied(input: {
|
|
220
214
|
readonly legBus: LegModBus | undefined;
|
|
221
|
-
readonly
|
|
215
|
+
readonly host?: {
|
|
216
|
+
readonly observe: (payload: PermissionDeniedPayload) => void | Promise<void>;
|
|
217
|
+
readonly onFailure: (err: Error) => void;
|
|
218
|
+
};
|
|
222
219
|
readonly payload: PermissionDeniedPayload;
|
|
223
220
|
readonly signal: AbortSignal | undefined;
|
|
224
|
-
readonly onHostObserverFailure: (err: Error) => void;
|
|
225
221
|
}): Promise<void>;
|
|
226
222
|
/** What a prompt's screen came to, as the four entrances read it: `text` is what the entrance delivers (the prompt as it
|
|
227
223
|
* came, or as `prompt.submit` handed it on — `rewrittenBy` then names who changed it, in the order they did); `block` the
|
|
@@ -182,15 +182,12 @@ const FAILURE_CLAUSE = Object.freeze({
|
|
|
182
182
|
export function failedHandlerClause(f) {
|
|
183
183
|
return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), ` ${extensionWords(f.reason, 200)}`);
|
|
184
184
|
}
|
|
185
|
-
export function failedHandlerName(f) {
|
|
186
|
-
return FAILURE_CLAUSE[f.cause](extensionWords(f.registration, 80), "");
|
|
187
|
-
}
|
|
188
185
|
export async function observePermissionDenied(input) {
|
|
189
|
-
const { payload,
|
|
186
|
+
const { payload, host } = input;
|
|
190
187
|
const e = { ...payload, ...classicEventBase(payload.identity, payload.permissionMode) };
|
|
191
188
|
if (input.legBus?.hasHandlers("classic.PermissionDenied") === true)
|
|
192
189
|
await observeClassic(input.legBus, "classic.PermissionDenied", e, input.signal);
|
|
193
|
-
if (
|
|
190
|
+
if (host === undefined)
|
|
194
191
|
return;
|
|
195
192
|
const own = await admitModChain({
|
|
196
193
|
deployment: [
|
|
@@ -198,10 +195,10 @@ export async function observePermissionDenied(input) {
|
|
|
198
195
|
name: "toolGate.permissionDenied",
|
|
199
196
|
tier: "user",
|
|
200
197
|
uses: { events: ["classic.PermissionDenied"], calls: [] },
|
|
201
|
-
register: (on) => on("classic.PermissionDenied", async () => void (await
|
|
198
|
+
register: (on) => on("classic.PermissionDenied", async () => void (await host.observe(payload)), { observe: true }),
|
|
202
199
|
},
|
|
203
200
|
],
|
|
204
|
-
},
|
|
201
|
+
}, host.onFailure);
|
|
205
202
|
await observeClassic(own, "classic.PermissionDenied", e, input.signal);
|
|
206
203
|
}
|
|
207
204
|
const USER_PROMPT_RANKS = Object.freeze({ of: (a) => (stringMembersOf(a, ["block"]).block ? 1 : 0), top: 1 });
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The `tool.call` station: raised on the leg's bus between the gate letting a call go and the tool's body, for every
|
|
3
3
|
* execution of a call (the live loop's lanes through the loop's execution seat, the resumed leg's approved call through
|
|
4
|
-
* the same function). The chain's bottom is the tool's body; the event's failure column is `
|
|
5
|
-
* failure refuses the call while the body has not started
|
|
6
|
-
*
|
|
7
|
-
* hand back its answer instead of the result.
|
|
4
|
+
* the same function). The chain's bottom is the tool's body; the event's failure column is `refuse_until_run`: a handler's
|
|
5
|
+
* failure refuses the call while the body has not started; once its own `next(e)` ran it, the handler is skipped and the
|
|
6
|
+
* result stands (said on the bus's failure sink). Only a `{ deny }` withholds a result that ran.
|
|
8
7
|
*
|
|
9
8
|
* `e = { tool, tool_use_id, agentId?, input }` (all four pinned — what the gate judged is what runs; a rewrite belongs to
|
|
10
9
|
* `classic.PreToolUse`) plus the identity envelope; a handler may hand on `requestMeta` too (a record of strings an MCP call carries
|
|
11
10
|
* as `_meta["sema/requestMeta"]`, judged where it is handed on — `mcp-call-meta.ts`). A handler answers:
|
|
12
11
|
* - `next(e)` — the body runs; what came up is `{ result: { content, isError } }`, a frozen view of the real result;
|
|
13
|
-
* - `{ deny: <reason> }` —
|
|
14
|
-
*
|
|
12
|
+
* - `{ deny: <reason> }` — in place of `next` (before the body): refused, not executed, the record names the extension; over
|
|
13
|
+
* what its `next` answered once the body ran: WITHHELD — the call ran (no `notExecuted`), the model reads who withheld it
|
|
14
|
+
* and why. Over a `next` still running, or over a body that threw (its throw is the outcome): a violation;
|
|
15
15
|
* - `{ result }` — an extension's own result in place of the body (a string, or a list of text blocks), taken only when
|
|
16
16
|
* both facts hold: the gate let this call go without anyone being asked about it (its latest gate record is an allow
|
|
17
17
|
* with no settlement, release or clearance — a person's or a rule's yes is a yes to running the tool), and the body
|
|
18
18
|
* has not started (the kernel's own record). Either missing, the answer is a violation: before the body the call is
|
|
19
|
-
* refused, after it the
|
|
20
|
-
* and names the extension (`tool_end.notExecuted`, `tool_end.answeredBy`).
|
|
19
|
+
* refused, after it the handler is skipped and the result stands. A taken result is the call's result; the record says
|
|
20
|
+
* the body never ran and names the extension (`tool_end.notExecuted`, `tool_end.answeredBy`).
|
|
21
21
|
* Context for the model is added at `classic.PostToolUse`, not here. Whatever an extension answered in place of the body,
|
|
22
22
|
* the call's post-execution stations stay silent, as for a call the gate blocked.
|
|
23
23
|
*
|
|
@@ -56,6 +56,8 @@ export interface ToolCallStationInput {
|
|
|
56
56
|
/** The leg's settlement seam: a result this station withholds settles the frames it carried as withheld by the host side
|
|
57
57
|
* (`settleWithheldResult`), so none is owed again through another lane. Absent ⇒ no frame rides a call of this station. */
|
|
58
58
|
readonly frameSettlement?: FrameSettlement;
|
|
59
|
+
/** The leg's report sink: a deny that gave no readable reason is said there. */
|
|
60
|
+
readonly report: (err: Error) => void;
|
|
59
61
|
}
|
|
60
62
|
/** The station over the leg's bus, or undefined when no handler hangs on `tool.call` (nothing is raised; the body runs). */
|
|
61
63
|
export declare function createToolCallStation(input: ToolCallStationInput): ToolCallStation | undefined;
|
|
@@ -7,11 +7,11 @@ import { readHandedRequestMeta } from "../mcp-call-meta.js";
|
|
|
7
7
|
import { ENGINE_ORIGIN } from "./kernel/index.js";
|
|
8
8
|
import { isPlainRecord } from "./kernel/receive.js";
|
|
9
9
|
import { NEXT_IN_FLIGHT } from "./kernel/site-rules.js";
|
|
10
|
-
import { classicEventBase, failedHandlerClause,
|
|
10
|
+
import { classicEventBase, failedHandlerClause, judgedInputOf } from "./stations.js";
|
|
11
11
|
import { mintExtensionCallId, runExtensionCall } from "./extension-call.js";
|
|
12
12
|
import { settleWithheldResult } from "../frame-settlement.js";
|
|
13
13
|
const FORM = "tool.call takes next(e), { deny: <reason> } or { result } (a string, or a list of text blocks)";
|
|
14
|
-
const denyOf = (a) => isPlainRecord(a)
|
|
14
|
+
const denyOf = (a) => !isPlainRecord(a) || !Object.hasOwn(a, "deny") ? undefined : typeof a["deny"] === "string" && a["deny"] !== "" ? { reason: a["deny"] } : {};
|
|
15
15
|
function substituteOf(a) {
|
|
16
16
|
if (!isPlainRecord(a) || Object.keys(a).length !== 1 || !Object.hasOwn(a, "result"))
|
|
17
17
|
return undefined;
|
|
@@ -87,8 +87,10 @@ export function createToolCallStation(input) {
|
|
|
87
87
|
const denied = denyOf(a) !== undefined;
|
|
88
88
|
if (!denied && substituteOf(a) === undefined)
|
|
89
89
|
return FORM;
|
|
90
|
+
if (denied && ran.bottomStarted)
|
|
91
|
+
return below.some((b) => b !== NEXT_IN_FLIGHT) ? undefined : "a deny after the tool started with no answer from its next(e) to withhold (it still runs, or the tool threw: the throw stands)";
|
|
90
92
|
if (ran.bottomStarted)
|
|
91
|
-
return
|
|
93
|
+
return "a result after the tool started (once the tool runs, nothing answers in its place)";
|
|
92
94
|
if (denied)
|
|
93
95
|
return below.some((b) => denyOf(b) === undefined) ? "a deny while its next(e) still runs or after it was answered (deny in place of next)" : undefined;
|
|
94
96
|
if (below.includes(NEXT_IN_FLIGHT))
|
|
@@ -109,27 +111,22 @@ export function createToolCallStation(input) {
|
|
|
109
111
|
return body;
|
|
110
112
|
return { content: [{ type: "text", text: "Operation aborted" }], details: {}, isError: true };
|
|
111
113
|
}
|
|
112
|
-
if (outcome.kind === "failed")
|
|
113
|
-
if (outcome.bottomStarted === true && body !== undefined) {
|
|
114
|
-
try {
|
|
115
|
-
await body;
|
|
116
|
-
}
|
|
117
|
-
catch {
|
|
118
|
-
return body;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
if (outcome.bottomStarted === true)
|
|
122
|
-
return stationAnswer(call, undefined, `a tool.call extension ${failedHandlerName(outcome)} after this call to "${extensionWords(call.toolName, 80)}" ran: a hook that checks this result could not hand back its answer, so the result is withheld — the call ran (fail-closed)`);
|
|
114
|
+
if (outcome.kind === "failed")
|
|
123
115
|
return stationAnswer(call, outcome.registration, `a tool.call extension ${failedHandlerClause(outcome)} before this call to "${extensionWords(call.toolName, 80)}" ran; the call was NOT executed (fail-closed)`);
|
|
124
|
-
}
|
|
125
116
|
const answer = outcome.answer;
|
|
126
117
|
const ran = typeof answer === "object" && answer !== null ? bodies.get(answer) : undefined;
|
|
127
118
|
if (ran !== undefined)
|
|
128
119
|
return ran;
|
|
129
120
|
const by = outcome.answeredBy ?? ENGINE_ORIGIN.plugin;
|
|
130
|
-
const
|
|
131
|
-
if (
|
|
132
|
-
|
|
121
|
+
const deny = denyOf(answer);
|
|
122
|
+
if (deny !== undefined) {
|
|
123
|
+
if (deny.reason === undefined)
|
|
124
|
+
input.report(new Error(`${by}: tool.call: its deny gave no readable reason (a reason is a non-empty string) — the deny stands`));
|
|
125
|
+
const why = deny.reason !== undefined ? `: ${extensionWords(deny.reason, 300)}` : " (it gave no readable reason)";
|
|
126
|
+
if (body !== undefined)
|
|
127
|
+
return stationAnswer(call, undefined, `this call to "${extensionWords(call.toolName, 80)}" ran, and extension "${extensionWords(by, 80)}" withheld its result${why} — the call was executed and whatever it did has happened; it is only its result that is not shown`);
|
|
128
|
+
return stationAnswer(call, by, `extension "${extensionWords(by, 80)}" refused this call to "${extensionWords(call.toolName, 80)}" before it ran${why}`);
|
|
129
|
+
}
|
|
133
130
|
const content = substituteOf(answer);
|
|
134
131
|
if (content === undefined)
|
|
135
132
|
return stationAnswer(call, by, `extension "${extensionWords(by, 80)}" answered this call in a form tool.call does not take; the call was NOT executed (fail-closed)`);
|
|
@@ -9,7 +9,6 @@
|
|
|
9
9
|
*/
|
|
10
10
|
import type { McpServerSpec } from "./mcp-server-spec.js";
|
|
11
11
|
import type { ToolContentOrigin } from "./tool-spec.js";
|
|
12
|
-
import type { McpConnectionPool } from "./mcp-connection-pool.js";
|
|
13
12
|
import type { McpHostSeat } from "./mcp-host-seat.js";
|
|
14
13
|
import type { McpInstructionsEntry } from "./prompt-section-seat.js";
|
|
15
14
|
/**
|
|
@@ -103,8 +102,6 @@ export interface MountedMcpServer {
|
|
|
103
102
|
export interface MountedMcp {
|
|
104
103
|
readonly servers: ReadonlyArray<MountedMcpServer>;
|
|
105
104
|
readonly aggregate: ReadonlyArray<string>;
|
|
106
|
-
/** The run tree's connection pool: a child that inherits the mount leases its connections from it. */
|
|
107
|
-
readonly pool?: McpConnectionPool;
|
|
108
105
|
/** The run's host seats by declaration name: a child declared a host-transport server (inherited or its definition's own) is handed that server's seat. */
|
|
109
106
|
readonly hostSeats?: ReadonlyMap<string, McpHostSeat>;
|
|
110
107
|
}
|
|
@@ -144,7 +141,6 @@ export declare function mountedMcpOf(input: {
|
|
|
144
141
|
readonly declared: ReadonlyArray<McpServerSpec> | undefined;
|
|
145
142
|
readonly roster: ReadonlyArray<RosterEntry>;
|
|
146
143
|
readonly aggregateNames: ReadonlySet<string>;
|
|
147
|
-
readonly pool?: McpConnectionPool;
|
|
148
144
|
readonly hostSeats?: ReadonlyMap<string, McpHostSeat>;
|
|
149
145
|
}): MountedMcp;
|
|
150
146
|
/**
|