@sema-agent/core 7.59.0 → 7.61.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 +1169 -0
- package/README.md +2 -2
- package/dist/agents/agent-definition.d.ts +7 -0
- package/dist/agents/agent-definition.js +12 -0
- package/dist/agents/agent-transcript-tool.d.ts +4 -3
- package/dist/agents/agent-transcript-tool.js +4 -2
- package/dist/agents/cascade.d.ts +61 -10
- package/dist/agents/cascade.js +60 -20
- package/dist/agents/child-model-seat.js +6 -3
- package/dist/agents/composition-allowance.d.ts +53 -0
- package/dist/agents/composition-allowance.js +49 -0
- package/dist/agents/composition-placement.d.ts +29 -0
- package/dist/agents/composition-placement.js +24 -0
- package/dist/agents/cumulative-stats.d.ts +4 -0
- package/dist/agents/cumulative-stats.js +3 -1
- package/dist/agents/inherited-tool-pool.d.ts +28 -1
- package/dist/agents/inherited-tool-pool.js +22 -0
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-notice-route.d.ts +1 -1
- package/dist/agents/peer-notice-route.js +4 -3
- package/dist/agents/peer-notices.d.ts +4 -4
- package/dist/agents/peer-notices.js +8 -4
- package/dist/agents/peer-session-drain.d.ts +8 -1
- package/dist/agents/peer-session-drain.js +36 -7
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.d.ts +11 -1
- package/dist/agents/retain-ledger.js +16 -3
- package/dist/agents/roster-store.d.ts +2 -2
- package/dist/agents/roster-store.js +8 -3
- package/dist/agents/send-message-tool.d.ts +14 -27
- package/dist/agents/send-message-tool.js +47 -54
- package/dist/agents/subagent-completion-gate.d.ts +35 -0
- package/dist/agents/subagent-completion-gate.js +62 -0
- package/dist/agents/subagent-steps.d.ts +7 -6
- package/dist/agents/subagent.d.ts +52 -28
- package/dist/agents/subagent.js +276 -246
- package/dist/agents/suspend-guard.d.ts +9 -0
- package/dist/agents/suspend-guard.js +4 -0
- package/dist/agents/tool-filter.d.ts +1 -3
- package/dist/agents/tool-filter.js +4 -12
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +37 -27
- package/dist/bench/metrics.d.ts +3 -5
- package/dist/bench/metrics.js +0 -1
- package/dist/brain/anthropic.js +1 -0
- package/dist/brain/degrading.js +3 -1
- package/dist/brain/errors.d.ts +7 -1
- package/dist/brain/errors.js +6 -0
- package/dist/brain/failover.js +2 -1
- package/dist/brain/open-responses.js +1 -0
- package/dist/brain/openai.js +1 -0
- package/dist/brain/provider-dialect.d.ts +10 -0
- package/dist/brain/provider-dialect.js +13 -2
- package/dist/brain/route-adjudicator.js +3 -1
- package/dist/brain/status-sink.d.ts +7 -1
- package/dist/brain/status-sink.js +6 -0
- package/dist/brain/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/brain/timeout.d.ts +3 -1
- package/dist/brain/timeout.js +18 -5
- package/dist/core/a2a.d.ts +15 -5
- package/dist/core/a2a.js +34 -19
- package/dist/core/agent-definition.d.ts +20 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +61 -23
- package/dist/core/allow-entry.js +134 -39
- package/dist/core/artifact-host.d.ts +0 -2
- package/dist/core/artifact-host.js +0 -1
- package/dist/core/ask-origin.d.ts +79 -0
- package/dist/core/ask-origin.js +76 -0
- package/dist/core/ask-question.d.ts +19 -13
- package/dist/core/ask-question.js +8 -2
- package/dist/core/auto-compaction.d.ts +2 -0
- package/dist/core/auto-compaction.js +2 -1
- package/dist/core/auto-mode-defaults.d.ts +8 -0
- package/dist/core/auto-mode-defaults.js +1 -0
- package/dist/core/auto-mode-rebuild.d.ts +2 -1
- package/dist/core/auto-mode.d.ts +39 -4
- package/dist/core/auto-mode.js +66 -17
- package/dist/core/background-agent-store.d.ts +17 -6
- package/dist/core/background-agent-store.js +15 -13
- package/dist/core/background-shell.d.ts +12 -1
- package/dist/core/background-shell.js +12 -0
- package/dist/core/checkpoint-requirements.d.ts +24 -3
- package/dist/core/checkpoint-requirements.js +9 -1
- package/dist/core/checkpoint-store.d.ts +86 -32
- package/dist/core/checkpoint-store.js +10 -5
- package/dist/core/child-clamp-seats.d.ts +3 -2
- package/dist/core/child-clamp-seats.js +4 -3
- package/dist/core/closest-name.d.ts +13 -0
- package/dist/core/closest-name.js +35 -0
- package/dist/core/compliance.d.ts +1 -1
- package/dist/core/context-settings.js +3 -5
- package/dist/core/credential-echo.d.ts +52 -0
- package/dist/core/credential-echo.js +65 -0
- package/dist/core/credential-vocabulary.d.ts +13 -3
- package/dist/core/credential-vocabulary.js +12 -4
- package/dist/core/cross-boundary-taint.d.ts +5 -6
- package/dist/core/decision-receipt.d.ts +14 -1
- package/dist/core/decision-receipt.js +6 -3
- package/dist/core/delegation-frames.d.ts +13 -9
- package/dist/core/effective-path-target.js +2 -3
- package/dist/core/engine-attestation.d.ts +11 -1
- package/dist/core/engine-attestation.js +2 -0
- package/dist/core/engine-notice.d.ts +106 -32
- package/dist/core/file-history-retention.d.ts +8 -0
- package/dist/core/file-history-retention.js +14 -11
- package/dist/core/file-history-store.d.ts +31 -1
- package/dist/core/file-history-store.js +31 -2
- package/dist/core/frame-settlement.d.ts +15 -0
- package/dist/core/frame-settlement.js +10 -1
- package/dist/core/fs-write-gate-policy.d.ts +3 -3
- package/dist/core/fs-write-gate-policy.js +8 -7
- package/dist/core/gate-fold.js +9 -6
- package/dist/core/gate-lanes.js +46 -12
- package/dist/core/gate-outcome.d.ts +40 -1
- package/dist/core/gate-outcome.js +10 -0
- package/dist/core/git-worktree-env.d.ts +7 -3
- package/dist/core/git-worktree-env.js +16 -13
- package/dist/core/governance-codes.d.ts +19 -3
- package/dist/core/governance-codes.js +27 -3
- package/dist/core/hands-band-screen.js +0 -1
- package/dist/core/hands-band.d.ts +0 -3
- package/dist/core/hooks.d.ts +51 -60
- package/dist/core/hooks.js +131 -78
- package/dist/core/host-floor.js +3 -5
- package/dist/core/image-admission.d.ts +145 -52
- package/dist/core/image-admission.js +202 -47
- package/dist/core/image-downsample.d.ts +36 -69
- package/dist/core/image-downsample.js +111 -73
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -0
- package/dist/core/integer-option.d.ts +21 -0
- package/dist/core/integer-option.js +13 -0
- package/dist/core/leg-identity.d.ts +62 -0
- package/dist/core/leg-identity.js +18 -0
- package/dist/core/locked-config.d.ts +55 -3
- package/dist/core/locked-config.js +84 -51
- package/dist/core/lsp.d.ts +5 -3
- package/dist/core/lsp.js +3 -2
- package/dist/core/mailbox-store.d.ts +85 -10
- package/dist/core/mailbox-store.js +31 -10
- package/dist/core/mcp-call-meta.d.ts +2 -2
- package/dist/core/mcp-call-meta.js +9 -10
- package/dist/core/mcp-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +83 -16
- package/dist/core/mcp-failure.js +67 -30
- package/dist/core/mcp-host-seat.d.ts +131 -0
- package/dist/core/mcp-host-seat.js +305 -0
- package/dist/core/mcp-probe.d.ts +7 -2
- package/dist/core/mcp-probe.js +9 -4
- package/dist/core/mcp-server-link.d.ts +18 -6
- package/dist/core/mcp-server-link.js +19 -4
- package/dist/core/mcp-server-spec.d.ts +39 -9
- package/dist/core/mcp-server-spec.js +55 -21
- package/dist/core/mcp-session-end.d.ts +1 -2
- package/dist/core/mcp-session-end.js +1 -1
- package/dist/core/mcp.d.ts +23 -55
- package/dist/core/mcp.js +172 -156
- package/dist/core/media-byte-cap.d.ts +21 -46
- package/dist/core/media-byte-cap.js +55 -55
- package/dist/core/member-group.d.ts +7 -0
- package/dist/core/member-group.js +35 -0
- package/dist/core/memory-admission.d.ts +23 -6
- package/dist/core/memory-admission.js +19 -9
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- package/dist/core/memory-engine/content-origin.d.ts +13 -0
- package/dist/core/memory-engine/content-origin.js +21 -3
- package/dist/core/memory-engine/dual-root.d.ts +31 -0
- package/dist/core/memory-engine/dual-root.js +59 -11
- package/dist/core/memory-engine/engine.js +27 -24
- package/dist/core/memory-engine/file-backend.d.ts +13 -0
- package/dist/core/memory-engine/file-backend.js +35 -15
- package/dist/core/memory-engine/index.d.ts +2 -1
- package/dist/core/memory-engine/index.js +2 -1
- package/dist/core/memory-engine/layout.d.ts +3 -0
- package/dist/core/memory-engine/layout.js +13 -3
- package/dist/core/memory-engine/memory-deployment.d.ts +110 -0
- package/dist/core/memory-engine/memory-deployment.js +182 -0
- package/dist/core/memory-engine/scope-contract.d.ts +13 -3
- package/dist/core/memory-engine/scope-contract.js +2 -2
- package/dist/core/memory-engine/sync-client.d.ts +68 -13
- package/dist/core/memory-engine/sync-client.js +147 -18
- package/dist/core/memory-engine/sync-report.d.ts +106 -0
- package/dist/core/memory-engine/sync-report.js +119 -0
- package/dist/core/memory-engine/sync.d.ts +13 -3
- package/dist/core/mode-policy.d.ts +15 -7
- package/dist/core/mode-policy.js +18 -6
- package/dist/core/model-receipt.d.ts +39 -0
- package/dist/core/model-receipt.js +139 -0
- package/dist/core/mods/agent-stations.d.ts +100 -0
- package/dist/core/mods/agent-stations.js +154 -0
- package/dist/core/mods/dollar.d.ts +62 -0
- package/dist/core/mods/extension-call.d.ts +15 -1
- package/dist/core/mods/extension-call.js +7 -2
- package/dist/core/mods/kernel/dispatch.d.ts +9 -4
- package/dist/core/mods/kernel/dispatch.js +8 -8
- package/dist/core/mods/kernel/events.d.ts +13 -4
- package/dist/core/mods/kernel/events.js +14 -10
- package/dist/core/mods/kernel/receive.d.ts +5 -0
- package/dist/core/mods/kernel/receive.js +10 -0
- package/dist/core/mods/kernel/registration.d.ts +3 -0
- package/dist/core/mods/kernel/registration.js +5 -0
- package/dist/core/mods/kernel/site-rules.d.ts +6 -3
- package/dist/core/mods/kernel/site-rules.js +10 -2
- package/dist/core/mods/lifecycle-stations.d.ts +41 -0
- package/dist/core/mods/lifecycle-stations.js +35 -0
- package/dist/core/mods/session-append.d.ts +115 -0
- package/dist/core/mods/session-append.js +311 -0
- package/dist/core/mods/session-compact.d.ts +48 -0
- package/dist/core/mods/session-compact.js +194 -0
- package/dist/core/mods/session-receive.d.ts +93 -0
- package/dist/core/mods/session-receive.js +141 -0
- package/dist/core/mods/session-send.d.ts +72 -0
- package/dist/core/mods/session-send.js +88 -0
- package/dist/core/mods/stations.d.ts +89 -75
- package/dist/core/mods/stations.js +57 -53
- package/dist/core/mods/tool-call.d.ts +12 -4
- package/dist/core/mods/tool-call.js +32 -16
- package/dist/core/mounted-mcp.d.ts +5 -0
- package/dist/core/mounted-mcp.js +2 -2
- package/dist/core/namespaced-rule-name.d.ts +7 -1
- package/dist/core/namespaced-rule-name.js +13 -2
- package/dist/core/oracle-isolation.js +1 -1
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +62 -0
- package/dist/core/own-property-receipt.js +43 -0
- package/dist/core/park-selfcheck.js +12 -10
- package/dist/core/path-identity.d.ts +11 -0
- package/dist/core/path-identity.js +4 -0
- package/dist/core/path-rule-binding.d.ts +3 -1
- package/dist/core/path-rule-binding.js +3 -1
- package/dist/core/peer-seat.d.ts +66 -11
- package/dist/core/peer-seat.js +199 -42
- package/dist/core/permission-rule-consent.d.ts +21 -26
- package/dist/core/permission-rule-consent.js +22 -3
- package/dist/core/permission-rule-model.d.ts +38 -13
- package/dist/core/permission-rule-model.js +54 -16
- package/dist/core/permission-rule-org.d.ts +1 -1
- package/dist/core/permission-rule-provider.js +4 -1
- package/dist/core/permission-rules.d.ts +4 -0
- package/dist/core/permission-rules.js +11 -16
- package/dist/core/protocol-http-auth.d.ts +14 -2
- package/dist/core/protocol-http-auth.js +16 -7
- package/dist/core/read-face-seats.d.ts +7 -5
- package/dist/core/read-face-seats.js +4 -1
- package/dist/core/redaction-marks.d.ts +4 -3
- package/dist/core/redaction-marks.js +2 -2
- package/dist/core/remote-env.d.ts +218 -122
- package/dist/core/remote-env.js +133 -14
- package/dist/core/retention-policy.d.ts +24 -23
- package/dist/core/retention-policy.js +36 -2
- package/dist/core/retention.d.ts +4 -1
- package/dist/core/retention.js +37 -12
- package/dist/core/retired-keys.d.ts +8 -3
- package/dist/core/retired-keys.js +4 -1
- package/dist/core/rewrite-rejudge.d.ts +12 -5
- package/dist/core/rewrite-rejudge.js +9 -5
- package/dist/core/roles.d.ts +37 -3
- package/dist/core/roles.js +126 -78
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -0
- package/dist/core/rule-owner.d.ts +3 -0
- package/dist/core/runner/advisor-instructions.d.ts +2 -1
- package/dist/core/runner/advisor-instructions.js +2 -1
- package/dist/core/runner/announce-once-ledger.d.ts +4 -4
- package/dist/core/runner/assemble-result.d.ts +13 -8
- package/dist/core/runner/assemble-result.js +12 -8
- package/dist/core/runner/call-hook-stations.d.ts +17 -10
- package/dist/core/runner/call-hook-stations.js +21 -10
- package/dist/core/runner/caller-roster.d.ts +12 -9
- package/dist/core/runner/caller-roster.js +5 -2
- package/dist/core/runner/checkpoint-scope.d.ts +16 -1
- package/dist/core/runner/checkpoint-scope.js +21 -0
- package/dist/core/runner/child-tree.d.ts +7 -8
- package/dist/core/runner/child-tree.js +6 -6
- package/dist/core/runner/classifier-ladder.d.ts +10 -2
- package/dist/core/runner/classifier-ladder.js +39 -8
- package/dist/core/runner/compact-session.js +14 -2
- package/dist/core/runner/compaction-call-options.d.ts +1 -1
- package/dist/core/runner/compaction-restate.d.ts +2 -2
- package/dist/core/runner/compaction-restate.js +4 -3
- package/dist/core/runner/construction-doors.d.ts +2 -2
- package/dist/core/runner/construction-doors.js +7 -2
- package/dist/core/runner/contracts.d.ts +158 -65
- package/dist/core/runner/cross-boundary-lane.d.ts +4 -6
- package/dist/core/runner/cross-boundary-lane.js +11 -2
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/denial-limit-arms.d.ts +15 -21
- package/dist/core/runner/denial-limit-arms.js +17 -10
- package/dist/core/runner/env-capability-census.d.ts +15 -20
- package/dist/core/runner/env-capability-census.js +25 -34
- package/dist/core/runner/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/file-history-request.d.ts +2 -2
- package/dist/core/runner/file-history-request.js +0 -8
- package/dist/core/runner/gate-exit.d.ts +75 -7
- package/dist/core/runner/gate-exit.js +20 -1
- package/dist/core/runner/git-status-frame.d.ts +5 -2
- package/dist/core/runner/git-status-frame.js +4 -4
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- package/dist/core/runner/image.d.ts +7 -2
- package/dist/core/runner/image.js +14 -8
- package/dist/core/runner/inline-image.d.ts +10 -8
- package/dist/core/runner/inline-image.js +11 -9
- package/dist/core/runner/local-claims.d.ts +17 -0
- package/dist/core/runner/local-claims.js +18 -0
- package/dist/core/runner/media-removed-seat.d.ts +46 -0
- package/dist/core/runner/media-removed-seat.js +88 -0
- package/dist/core/runner/memory-consolidation-driver.js +4 -4
- package/dist/core/runner/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +5 -1
- package/dist/core/runner/permission-rule-lanes.js +29 -10
- package/dist/core/runner/person-path-rows.js +1 -1
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-ask-lane.d.ts +6 -12
- package/dist/core/runner/prepare-ask-lane.js +4 -4
- package/dist/core/runner/prepare-boundary-parks.d.ts +6 -3
- package/dist/core/runner/prepare-boundary-parks.js +4 -4
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +6 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +5 -3
- package/dist/core/runner/prepare-config-doors.d.ts +6 -1
- package/dist/core/runner/prepare-config-doors.js +30 -26
- package/dist/core/runner/prepare-context-lane.d.ts +6 -2
- package/dist/core/runner/prepare-context-lane.js +13 -13
- package/dist/core/runner/prepare-delegation-surface.d.ts +13 -11
- package/dist/core/runner/prepare-delegation-surface.js +7 -8
- package/dist/core/runner/prepare-execution-env.d.ts +5 -2
- package/dist/core/runner/prepare-execution-env.js +7 -4
- package/dist/core/runner/prepare-file-history.d.ts +10 -12
- package/dist/core/runner/prepare-file-history.js +3 -12
- package/dist/core/runner/prepare-gate-stations.d.ts +23 -17
- package/dist/core/runner/prepare-gate-stations.js +10 -7
- package/dist/core/runner/prepare-hands-readface.d.ts +8 -6
- package/dist/core/runner/prepare-hands-readface.js +19 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +11 -4
- package/dist/core/runner/prepare-inherited-gate.js +12 -5
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-memory-engine-session.js +1 -1
- package/dist/core/runner/prepare-memory.d.ts +2 -2
- package/dist/core/runner/prepare-memory.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +8 -7
- package/dist/core/runner/prepare-park-ask.js +6 -12
- package/dist/core/runner/prepare-policy-chain.d.ts +15 -25
- package/dist/core/runner/prepare-policy-chain.js +131 -128
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-project-context.js +8 -5
- package/dist/core/runner/prepare-prompt-inputs.d.ts +4 -0
- package/dist/core/runner/prepare-prompt-inputs.js +4 -2
- package/dist/core/runner/prepare-protocol-tools.d.ts +5 -3
- package/dist/core/runner/prepare-protocol-tools.js +9 -2
- package/dist/core/runner/prepare-question-face.d.ts +6 -4
- package/dist/core/runner/prepare-question-face.js +2 -2
- package/dist/core/runner/prepare-run-refs.d.ts +3 -0
- package/dist/core/runner/prepare-run-refs.js +2 -2
- package/dist/core/runner/prepare-suspend-saga.d.ts +11 -9
- package/dist/core/runner/prepare-suspend-saga.js +21 -13
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +84 -42
- package/dist/core/runner/prepare-tool-disclosure-mount.d.ts +6 -0
- package/dist/core/runner/prepare-tool-disclosure-mount.js +3 -1
- package/dist/core/runner/prepare-turn-wiring.d.ts +2 -0
- package/dist/core/runner/prepare-turn-wiring.js +7 -2
- package/dist/core/runner/prepare-wiring-manifest.d.ts +7 -3
- package/dist/core/runner/prepare-wiring-manifest.js +34 -19
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +12 -8
- package/dist/core/runner/read-root-grant.d.ts +1 -1
- package/dist/core/runner/read-root-grant.js +2 -1
- package/dist/core/runner/resume-admission.d.ts +5 -3
- package/dist/core/runner/resume-admission.js +17 -3
- package/dist/core/runner/resume-apply.js +3 -1
- package/dist/core/runner/resume-checkpoint-screen.js +4 -4
- package/dist/core/runner/resume-claim.d.ts +8 -3
- package/dist/core/runner/resume-claim.js +28 -12
- package/dist/core/runner/resume-internals-and-config.d.ts +2 -2
- package/dist/core/runner/resume-internals-and-config.js +10 -1
- package/dist/core/runner/resume-preflight.d.ts +3 -2
- package/dist/core/runner/resume-preflight.js +13 -26
- package/dist/core/runner/retired-runner-deps.js +6 -1
- package/dist/core/runner/run-attachment-seats.js +3 -3
- package/dist/core/runner/run-brain-sinks.js +1 -0
- package/dist/core/runner/run-git-lane.d.ts +3 -1
- package/dist/core/runner/run-git-lane.js +3 -2
- package/dist/core/runner/run-harness-handlers.d.ts +3 -1
- package/dist/core/runner/run-harness-handlers.js +5 -3
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +15 -6
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +65 -56
- package/dist/core/runner/run-notification-lane.d.ts +3 -1
- package/dist/core/runner/run-notification-lane.js +36 -12
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +14 -8
- package/dist/core/runner/run-stop-and-final-verify.d.ts +4 -0
- package/dist/core/runner/run-stop-and-final-verify.js +12 -4
- package/dist/core/runner/run-telemetry-and-budget-seats.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.d.ts +1 -1
- package/dist/core/runner/run-terminal-adoption.js +26 -17
- package/dist/core/runner/run-turn-boundary.js +37 -19
- package/dist/core/runner/runtask.d.ts +25 -7
- package/dist/core/runner/runtask.js +46 -22
- package/dist/core/runner/session-rule-policy.d.ts +1 -1
- package/dist/core/runner/session-rule-policy.js +6 -1
- package/dist/core/runner/shell-env-withheld.d.ts +1 -1
- package/dist/core/runner/skills-seat.js +2 -2
- package/dist/core/runner/stream-halt-verbs.d.ts +1 -14
- package/dist/core/runner/stream-halt-verbs.js +4 -3
- package/dist/core/runner/stream-reap.d.ts +7 -6
- package/dist/core/runner/stream-reap.js +13 -16
- package/dist/core/runner/stream-settle-backstop.d.ts +3 -2
- package/dist/core/runner/stream-settle-backstop.js +5 -3
- package/dist/core/runner/stream-steer-verb.d.ts +5 -2
- package/dist/core/runner/stream-steer-verb.js +8 -7
- package/dist/core/runner/sub-agent-deny-lists.js +10 -7
- package/dist/core/runner/synthetic-tools.js +2 -2
- package/dist/core/runner/terminal-account.d.ts +11 -1
- package/dist/core/runner/terminal-account.js +20 -0
- package/dist/core/runner/terminal-projection.d.ts +8 -2
- package/dist/core/runner/terminal-projection.js +2 -2
- package/dist/core/runner/tool-disclosure.d.ts +3 -0
- package/dist/core/runner/tool-disclosure.js +5 -4
- package/dist/core/runner/tool-end-body.d.ts +3 -3
- package/dist/core/runner/tool-end-body.js +1 -1
- package/dist/core/runner/tool-face-overlay.d.ts +1 -1
- package/dist/core/runner/tool-face-overlay.js +26 -19
- package/dist/core/runner/tool-output-projection.d.ts +3 -3
- package/dist/core/runner/tool-output-projection.js +7 -6
- package/dist/core/runner/tool-result-media-seat.d.ts +9 -1
- package/dist/core/runner/tool-result-media-seat.js +17 -1
- package/dist/core/runner/tool-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +6 -7
- package/dist/core/runner/turn-attachments.js +4 -17
- package/dist/core/runner/void-verifier-pause.d.ts +33 -0
- package/dist/core/runner/void-verifier-pause.js +41 -0
- package/dist/core/runner-deps.d.ts +55 -43
- package/dist/core/secret-env.d.ts +14 -13
- package/dist/core/secret-env.js +8 -9
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +10 -3
- package/dist/core/session-policy-store.js +21 -3
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +5 -2
- package/dist/core/session-store.js +53 -16
- package/dist/core/session.d.ts +2 -1
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.d.ts +9 -0
- package/dist/core/skill-grant.js +18 -0
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +2 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +15 -2
- package/dist/core/store-contracts/file-history-store-contract.d.ts +5 -2
- package/dist/core/store-contracts/file-history-store-contract.js +25 -1
- package/dist/core/store-contracts/mailbox-store-contract.d.ts +12 -5
- package/dist/core/store-contracts/mailbox-store-contract.js +156 -9
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +67 -0
- package/dist/core/stub-env.d.ts +5 -5
- package/dist/core/stub-env.js +11 -1
- package/dist/core/swappable-deps.d.ts +17 -43
- package/dist/core/swappable-deps.js +15 -5
- package/dist/core/synthetic-read-verdict.d.ts +1 -1
- package/dist/core/task-event.d.ts +35 -10
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +172 -12
- package/dist/core/task-notification.js +209 -12
- package/dist/core/task-registry-agent.d.ts +23 -55
- package/dist/core/task-registry-agent.js +41 -56
- package/dist/core/task-registry-monitor.d.ts +8 -1
- package/dist/core/task-registry-monitor.js +43 -61
- package/dist/core/task-registry-shared.d.ts +52 -114
- package/dist/core/task-registry-shared.js +24 -48
- package/dist/core/task-registry-workflow.js +5 -22
- package/dist/core/task-registry.d.ts +64 -90
- package/dist/core/task-registry.js +73 -119
- package/dist/core/task-result.d.ts +27 -19
- package/dist/core/task-spec-members.d.ts +39 -0
- package/dist/core/task-spec-members.js +92 -0
- package/dist/core/task-spec.d.ts +13 -16
- package/dist/core/task-stream.d.ts +1 -1
- package/dist/core/task-tool-shape.d.ts +7 -57
- package/dist/core/task-tool-shape.js +7 -66
- package/dist/core/terminal-cause.d.ts +30 -0
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +3 -6
- package/dist/core/tool-check-reading.js +16 -10
- package/dist/core/tool-conformance.js +1 -2
- package/dist/core/tool-errors.d.ts +6 -3
- package/dist/core/tool-errors.js +2 -0
- package/dist/core/tool-face-reader.d.ts +7 -6
- package/dist/core/tool-face-reader.js +6 -4
- package/dist/core/tool-face.d.ts +2 -3
- package/dist/core/tool-name-aliases.d.ts +23 -28
- package/dist/core/tool-name-aliases.js +63 -7
- package/dist/core/tool-name-readings.d.ts +14 -3
- package/dist/core/tool-name-readings.js +2 -0
- package/dist/core/tool-policy.d.ts +113 -22
- package/dist/core/tool-policy.js +85 -15
- package/dist/core/tool-registry.d.ts +5 -5
- package/dist/core/tool-registry.js +2 -2
- package/dist/core/tool-result-store.d.ts +111 -5
- package/dist/core/tool-result-store.js +52 -12
- package/dist/core/tool-spec.d.ts +39 -10
- package/dist/core/trace.d.ts +18 -2
- package/dist/core/types.d.ts +3 -3
- package/dist/core/types.js +1 -1
- package/dist/core/untrusted-text.js +1 -1
- package/dist/core/user-attachment.d.ts +10 -5
- package/dist/core/user-attachment.js +40 -27
- package/dist/core/workflow-journal-store.d.ts +1 -1
- package/dist/core/workflow-run-store.d.ts +2 -0
- package/dist/core/workflow-run-store.js +6 -5
- package/dist/core/workflow-settled-run.d.ts +5 -0
- package/dist/core/workflow-settled-run.js +7 -0
- package/dist/engine/execution-env/node-execution-env.d.ts +37 -7
- package/dist/engine/execution-env/node-execution-env.js +224 -21
- package/dist/engine/harness/agent-harness.d.ts +66 -19
- package/dist/engine/harness/agent-harness.js +98 -27
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +151 -34
- package/dist/engine/llm/media-removed.d.ts +14 -0
- package/dist/engine/llm/media-removed.js +9 -0
- package/dist/engine/llm/rejected-images.d.ts +35 -25
- package/dist/engine/llm/rejected-images.js +59 -10
- package/dist/engine/llm/types.d.ts +24 -3
- package/dist/engine/llm/types.js +7 -3
- package/dist/engine/loop/agent-loop.d.ts +18 -13
- package/dist/engine/loop/agent-loop.js +173 -32
- package/dist/engine/loop/types.d.ts +21 -5
- package/dist/engine/lsp/node-lsp-manager.d.ts +3 -3
- package/dist/engine/lsp/node-lsp-manager.js +32 -13
- package/dist/engine/session/import-validate.js +7 -0
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +41 -23
- package/dist/index.js +29 -16
- package/dist/internal/harness-types.d.ts +3 -1
- package/dist/internal/llm.d.ts +2 -1
- package/dist/internal/llm.js +1 -0
- package/dist/orchestration/goal.d.ts +6 -2
- package/dist/orchestration/goal.js +6 -3
- package/dist/orchestration/run-workflow-tool.d.ts +20 -20
- package/dist/orchestration/run-workflow-tool.js +63 -56
- package/dist/orchestration/workflow-governance.d.ts +1 -1
- package/dist/orchestration/workflow-governance.js +2 -1
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +8 -0
- package/dist/orchestration/workflow.js +33 -9
- package/dist/prompts/default.d.ts +1 -10
- package/dist/prompts/default.js +0 -2
- package/dist/stores/file/background-agent-store.d.ts +1 -1
- package/dist/stores/file/background-agent-store.js +19 -14
- package/dist/stores/file/checkpoint-store.d.ts +127 -2
- package/dist/stores/file/checkpoint-store.js +24 -16
- package/dist/stores/file/file-history-store.d.ts +1 -1
- package/dist/stores/file/file-history-store.js +4 -1
- package/dist/stores/file/index.d.ts +9 -6
- package/dist/stores/file/index.js +33 -9
- package/dist/stores/file/ledger-tuning.d.ts +23 -0
- package/dist/stores/file/ledger-tuning.js +21 -0
- package/dist/stores/file/mailbox-store.d.ts +1 -1
- package/dist/stores/file/mailbox-store.js +43 -21
- package/dist/stores/file/memory-store.d.ts +1 -1
- package/dist/stores/file/memory-store.js +4 -1
- package/dist/stores/file/permission-rule-adopt.js +24 -21
- package/dist/stores/file/permission-rule-store.js +6 -3
- package/dist/stores/file/session-policy-store.d.ts +1 -1
- package/dist/stores/file/session-policy-store.js +4 -1
- package/dist/stores/file/session-store.d.ts +17 -4
- package/dist/stores/file/session-store.js +22 -19
- package/dist/stores/file/shared-ledger.d.ts +26 -0
- package/dist/stores/file/shared-ledger.js +38 -9
- package/dist/stores/file/tool-result-store.d.ts +31 -2
- package/dist/stores/file/tool-result-store.js +129 -7
- package/dist/stores/file/usage-window-store.d.ts +1 -1
- package/dist/stores/file/usage-window-store.js +4 -1
- package/dist/stores/file/workflow-journal-store.d.ts +1 -13
- package/dist/stores/file/workflow-journal-store.js +4 -18
- package/dist/stores/file/workflow-run-store.d.ts +1 -1
- package/dist/stores/file/workflow-run-store.js +15 -10
- package/dist/tools/fs/containment-face.d.ts +5 -0
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/encoding.d.ts +13 -4
- package/dist/tools/fs/encoding.js +17 -2
- package/dist/tools/fs/fs-bash-background-text.d.ts +13 -0
- package/dist/tools/fs/fs-bash-background-text.js +7 -0
- package/dist/tools/fs/fs-bash.d.ts +11 -22
- package/dist/tools/fs/fs-bash.js +58 -154
- package/dist/tools/fs/fs-pdf.d.ts +2 -2
- package/dist/tools/fs/fs-pdf.js +34 -27
- package/dist/tools/fs/fs-read.d.ts +5 -4
- package/dist/tools/fs/fs-read.js +35 -18
- package/dist/tools/fs/fs-search-tools.js +4 -1
- package/dist/tools/fs/fs-shared.d.ts +39 -16
- package/dist/tools/fs/fs-shared.js +25 -6
- package/dist/tools/fs/fs-write.js +5 -5
- package/dist/tools/fs/index.d.ts +15 -9
- package/dist/tools/fs/index.js +12 -18
- package/dist/tools/fs/pdf.d.ts +4 -4
- package/dist/tools/fs/pdf.js +6 -6
- package/dist/tools/fs/read-deny-home.js +8 -1
- package/dist/tools/fs/read-deny.d.ts +26 -2
- package/dist/tools/fs/read-deny.js +9 -2
- package/dist/tools/fs/read-floor.d.ts +57 -6
- package/dist/tools/fs/read-floor.js +241 -2
- package/dist/tools/fs/removal-targets.d.ts +9 -4
- package/dist/tools/fs/removal-targets.js +17 -9
- package/dist/tools/fs/search.d.ts +6 -5
- package/dist/tools/fs/search.js +10 -10
- package/dist/tools/fs/shell-read-establish.js +3 -1
- package/dist/tools/fs/shell-read-identity.d.ts +3 -1
- package/dist/tools/fs/shell-read-identity.js +4 -2
- package/dist/tools/fs/shell-read-judge.d.ts +7 -1
- package/dist/tools/fs/shell-read-judge.js +1 -1
- package/dist/tools/monitor.d.ts +12 -10
- package/dist/tools/monitor.js +22 -13
- package/dist/tools/scheduler-tools.js +42 -4
- package/dist/tools/web.d.ts +0 -10
- package/dist/tools/web.js +1 -4
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +8 -3
- package/test/export-surface.snapshot.json +166 -30
- package/wire-changes/core-stores-sql@7.60.0.json +30 -0
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core@7.60.0.json +3274 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/mods-kernel@7.60.0.json +62 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/primitives@7.60.0.json +30 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
|
@@ -19,32 +19,18 @@
|
|
|
19
19
|
* peer seat's, asked under this same identity, so every holder of a connection sends what the one seat answers for it. A server that opted in to elicitation never enters the pool — the
|
|
20
20
|
* answer to its questions belongs to the leg that is waiting on it.
|
|
21
21
|
*/
|
|
22
|
-
import type { Client } from "@modelcontextprotocol/
|
|
22
|
+
import type { Client } from "@modelcontextprotocol/client";
|
|
23
23
|
import { ConnectionListing, type LenientListedTool } from "./mcp-server-link.js";
|
|
24
24
|
import type { McpServerSpec } from "./mcp-server-spec.js";
|
|
25
|
-
/** The
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
readonly outputSchema?: unknown;
|
|
29
|
-
readonly execution?: unknown;
|
|
30
|
-
}
|
|
31
|
-
/** Records one `tools/list` result on a pooled connection (see {@link McpLease.openListing}): the tools the leg mounted from it, of which
|
|
32
|
-
* `retained` names the ones the listing did not return (an incomplete walk keeps them mounted) — those join the membership only. */
|
|
33
|
-
export type McpListingWriter = (tools: ReadonlyArray<McpToolMeta>, apply: (all: McpToolMeta[]) => void, retained?: ReadonlySet<string>) => void;
|
|
25
|
+
/** The engine's own dial of `client` under `key` (the key {@link McpConnectionPool.keyOf} gives its declaration): the one connection a pool
|
|
26
|
+
* entry for that key may take. */
|
|
27
|
+
export declare function recordEngineDial(client: Client, key: string): void;
|
|
34
28
|
/** One leg's hold on a pooled connection. */
|
|
35
29
|
export interface McpLease {
|
|
36
30
|
readonly client: Client;
|
|
37
|
-
/** The connection's listing, one record shared by every holder (mcp-server-link.ts `ConnectionListing`)
|
|
31
|
+
/** The connection's listing, one record shared by every holder (mcp-server-link.ts `ConnectionListing`): what every holder's tools are
|
|
32
|
+
* checked against and what their calls hand the SDK as the tool's definition, each through its own leg's intake. */
|
|
38
33
|
readonly listing: ConnectionListing<LenientListedTool>;
|
|
39
|
-
/**
|
|
40
|
-
* Open a `tools/list` round trip on the connection — call it BEFORE the request. The returned writer records the result twice over:
|
|
41
|
-
* as the connection's metadata for each listed tool, at this listing's version (its place in the order listings were opened on the
|
|
42
|
-
* connection: a listing opened earlier never overwrites what a later one wrote, whichever answer arrives first; an entry the listing
|
|
43
|
-
* did not return — `retained` — writes no record), and as THIS leg's membership (the names it mounted). It then rewrites the client's per-connection tool cache with the current metadata of every name
|
|
44
|
-
* some holder mounted: the SDK clears and refills that cache on each write, so a leg that mounted a subset must not erase what its
|
|
45
|
-
* siblings' tools need. A release changes the membership only and rewrites the cache from the same metadata.
|
|
46
|
-
*/
|
|
47
|
-
openListing(): McpListingWriter;
|
|
48
34
|
/** Run `fn` when the connection closes under the lease (the server died, the transport dropped). Never called for this lease's own release. */
|
|
49
35
|
onClose(fn: () => void): void;
|
|
50
36
|
/** Give the hold back; the last holder's release closes the connection. Idempotent. */
|
|
@@ -1,6 +1,10 @@
|
|
|
1
1
|
import { canonicalize } from "./canonical-json.js";
|
|
2
2
|
import { ConnectionListing } from "./mcp-server-link.js";
|
|
3
3
|
import { carrierOf } from "./peer-seat.js";
|
|
4
|
+
const ENGINE_DIALS = new WeakMap();
|
|
5
|
+
export function recordEngineDial(client, key) {
|
|
6
|
+
ENGINE_DIALS.set(client, { key, entered: false });
|
|
7
|
+
}
|
|
4
8
|
export class McpConnectionPool {
|
|
5
9
|
entries = new Map();
|
|
6
10
|
dialing = new Map();
|
|
@@ -105,7 +109,12 @@ export class McpConnectionPool {
|
|
|
105
109
|
}
|
|
106
110
|
async dialNew(key, generation, dial) {
|
|
107
111
|
const client = await dial();
|
|
108
|
-
const
|
|
112
|
+
const dialled = ENGINE_DIALS.get(client);
|
|
113
|
+
if (dialled === undefined || dialled.key !== key || dialled.entered) {
|
|
114
|
+
throw Object.assign(new Error("McpConnectionPool: the dial answered a connection the engine did not dial for this declaration (a client built elsewhere, dialled for another declaration or principal, or already held by a pool entry) — refused, the pool keeps nothing of it; the pool holds only connections the engine dials itself"), { code: "config.mcp_pool_foreign_connection" });
|
|
115
|
+
}
|
|
116
|
+
dialled.entered = true;
|
|
117
|
+
const entry = { client, listing: new ConnectionListing(), refs: 0, listeners: new Set(), current: true, closed: false };
|
|
109
118
|
client.onclose = () => {
|
|
110
119
|
entry.closed = true;
|
|
111
120
|
if (this.entries.get(key) === entry)
|
|
@@ -128,10 +137,6 @@ export class McpConnectionPool {
|
|
|
128
137
|
entry.refs++;
|
|
129
138
|
const mine = new Set();
|
|
130
139
|
let released = false;
|
|
131
|
-
const cached = () => {
|
|
132
|
-
const held = new Set([...entry.holders.values()].flat());
|
|
133
|
-
return [...entry.meta].filter(([name]) => held.has(name)).map(([, r]) => r.tool);
|
|
134
|
-
};
|
|
135
140
|
const lease = {
|
|
136
141
|
client: entry.client,
|
|
137
142
|
listing: entry.listing,
|
|
@@ -139,27 +144,6 @@ export class McpConnectionPool {
|
|
|
139
144
|
mine.add(fn);
|
|
140
145
|
entry.listeners.add(fn);
|
|
141
146
|
},
|
|
142
|
-
openListing: () => {
|
|
143
|
-
const version = entry.nextVersion++;
|
|
144
|
-
return (tools, apply, retained) => {
|
|
145
|
-
for (const tool of tools) {
|
|
146
|
-
const prior = entry.meta.get(tool.name);
|
|
147
|
-
if (retained?.has(tool.name) === true) {
|
|
148
|
-
if (prior === undefined)
|
|
149
|
-
entry.meta.set(tool.name, { tool, version: -1 });
|
|
150
|
-
continue;
|
|
151
|
-
}
|
|
152
|
-
if (prior !== undefined && prior.version > version)
|
|
153
|
-
continue;
|
|
154
|
-
entry.meta.delete(tool.name);
|
|
155
|
-
entry.meta.set(tool.name, { tool, version });
|
|
156
|
-
}
|
|
157
|
-
if (!released)
|
|
158
|
-
entry.holders.set(lease, tools.map((t) => t.name));
|
|
159
|
-
entry.apply = apply;
|
|
160
|
-
apply(cached());
|
|
161
|
-
};
|
|
162
|
-
},
|
|
163
147
|
release: async () => {
|
|
164
148
|
if (released)
|
|
165
149
|
return;
|
|
@@ -167,8 +151,6 @@ export class McpConnectionPool {
|
|
|
167
151
|
for (const fn of mine)
|
|
168
152
|
entry.listeners.delete(fn);
|
|
169
153
|
entry.refs--;
|
|
170
|
-
if (entry.holders.delete(lease) && entry.refs > 0)
|
|
171
|
-
entry.apply?.(cached());
|
|
172
154
|
if (entry.refs > 0)
|
|
173
155
|
return;
|
|
174
156
|
entry.current = false;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { AssertAllKeysHandled } from "./ask-origin.js";
|
|
2
2
|
import type { AnnouncedMcpFailure } from "../internal/harness.js";
|
|
3
|
+
import type { McpTransportKind } from "./mcp-server-spec.js";
|
|
3
4
|
/**
|
|
4
5
|
* The closed set of failure classes ({@link McpFailure.kind}):
|
|
5
6
|
* · `connect_refused` — a connect-phase errno (ECONNREFUSED / ENOTFOUND / EAI_AGAIN / EHOSTUNREACH /
|
|
@@ -7,7 +8,7 @@ import type { AnnouncedMcpFailure } from "../internal/harness.js";
|
|
|
7
8
|
* request: the request provably never left;
|
|
8
9
|
* · `connection_failed` — any other errno / undici code on the cause chain (a reset or a timeout
|
|
9
10
|
* mid-exchange): the request may have run;
|
|
10
|
-
* · `connection_closed` — the SDK reported the transport closed (`
|
|
11
|
+
* · `connection_closed` — the SDK reported the transport closed (`SdkError` `ConnectionClosed`): in
|
|
11
12
|
* flight the fate is unknowable, and for a server already known dead the
|
|
12
13
|
* request was never attempted — the two are told apart by `delivered`;
|
|
13
14
|
* · `unauthorized` — the principal must authorize this server before it serves them: the endpoint
|
|
@@ -29,9 +30,14 @@ import type { AnnouncedMcpFailure } from "../internal/harness.js";
|
|
|
29
30
|
* · `credential_unavailable` — the deployment's peer seat did not furnish the request (it threw, did not
|
|
30
31
|
* answer in time, or answered something the engine cannot carry): that request
|
|
31
32
|
* was not sent — a fault for the deployment to fix, not an outage of the server;
|
|
32
|
-
* · `
|
|
33
|
+
* · `host_refused` — the host seat of a host-supplied transport (mcp-host-seat.ts) did not hand the request to the
|
|
34
|
+
* remote, or handed its dial no pipe the engine could take (it said so, or what it handed is no
|
|
35
|
+
* transport or was already taken): nothing ran, and nothing is said about whether the remote can be
|
|
36
|
+
* reached;
|
|
37
|
+
* · `unknown` — the thrown value carried no structure this table reads, or the host seat took the request
|
|
38
|
+
* and cannot tell how it ended (said at the dial, nothing of the caller's was sent either way).
|
|
33
39
|
*/
|
|
34
|
-
export declare const MCP_FAILURE_KINDS: readonly ["connect_refused", "connection_failed", "connection_closed", "unauthorized", "http_status", "not_mcp_response", "spawn_failed", "timeout", "protocol", "invalid_config", "credential_unavailable", "unknown"];
|
|
40
|
+
export declare const MCP_FAILURE_KINDS: readonly ["connect_refused", "connection_failed", "connection_closed", "unauthorized", "http_status", "not_mcp_response", "spawn_failed", "timeout", "protocol", "invalid_config", "credential_unavailable", "host_refused", "unknown"];
|
|
35
41
|
export type McpFailureKind = (typeof MCP_FAILURE_KINDS)[number];
|
|
36
42
|
/**
|
|
37
43
|
* Why a server is `unauthorized` ({@link McpAuthorization.reason}), closed:
|
|
@@ -83,6 +89,7 @@ export declare const DELIVERED_BY_KIND: {
|
|
|
83
89
|
readonly protocol: "yes";
|
|
84
90
|
readonly invalid_config: "no";
|
|
85
91
|
readonly credential_unavailable: "no";
|
|
92
|
+
readonly host_refused: "no";
|
|
86
93
|
readonly unknown: "unknown";
|
|
87
94
|
};
|
|
88
95
|
/** The fence over the delivery table: `never` while every kind has a verdict. */
|
|
@@ -146,6 +153,7 @@ export declare const LIVENESS_BY_FAILURE_KIND: {
|
|
|
146
153
|
readonly protocol: "reachable";
|
|
147
154
|
readonly invalid_config: undefined;
|
|
148
155
|
readonly credential_unavailable: undefined;
|
|
156
|
+
readonly host_refused: undefined;
|
|
149
157
|
readonly unknown: "unknown";
|
|
150
158
|
};
|
|
151
159
|
/** The fence over the liveness table: `never` while every kind has a verdict. */
|
|
@@ -172,7 +180,7 @@ export type McpRequestSite = {
|
|
|
172
180
|
* transport is the child process failing to spawn, or on a request over an established connection. */
|
|
173
181
|
export type McpFailureSite = {
|
|
174
182
|
phase: "connect";
|
|
175
|
-
transport:
|
|
183
|
+
transport: McpTransportKind | undefined;
|
|
176
184
|
} | McpRequestSite;
|
|
177
185
|
/**
|
|
178
186
|
* The one MCP failure record. Both fields are always present; `httpStatus` rides only with
|
|
@@ -234,16 +242,74 @@ export declare function failureFields(of: McpFailure | Partial<McpFailureFields>
|
|
|
234
242
|
*/
|
|
235
243
|
export declare function networkErrorCode(err: unknown, depth?: number): string | undefined;
|
|
236
244
|
/** What a row reads OFF the thrown value: the failure's class, the status the `http_status` class carries, the authorization fact
|
|
237
|
-
* the `unauthorized` class carries, and `unsent` — the thrown value is
|
|
238
|
-
* furnish the request: {@link PeerSeatFailure}
|
|
239
|
-
*
|
|
240
|
-
* ({@link DELIVERED_BY_KIND} + {@link classifyMcpFailure}),
|
|
245
|
+
* the `unauthorized` class carries, and `unsent` — the thrown value is a refusal on THIS side to send (the peer seat did not
|
|
246
|
+
* furnish the request: {@link PeerSeatFailure}; the SDK refused it before anything reached the transport: {@link SDK_ERROR_READINGS}),
|
|
247
|
+
* a structural fact about our side of the exchange that makes the verdict `"no"` whatever the class. A row does NOT write the delivery
|
|
248
|
+
* verdict — that follows from the kind, `unsent` and the SITE, in one place ({@link DELIVERED_BY_KIND} + {@link classifyMcpFailure}),
|
|
249
|
+
* so a row cannot spell it wrong. */
|
|
241
250
|
export type McpFailureClass = {
|
|
242
251
|
kind: McpFailureKind;
|
|
243
252
|
httpStatus?: number;
|
|
244
253
|
authorization?: McpAuthorization;
|
|
245
254
|
unsent?: true;
|
|
246
255
|
};
|
|
256
|
+
export declare const SDK_ERROR_READINGS: {
|
|
257
|
+
readonly NOT_CONNECTED: {
|
|
258
|
+
readonly kind: "connection_closed";
|
|
259
|
+
readonly unsent: true;
|
|
260
|
+
};
|
|
261
|
+
readonly ALREADY_CONNECTED: {
|
|
262
|
+
readonly kind: "unknown";
|
|
263
|
+
};
|
|
264
|
+
readonly NOT_INITIALIZED: {
|
|
265
|
+
readonly kind: "unknown";
|
|
266
|
+
};
|
|
267
|
+
readonly CAPABILITY_NOT_SUPPORTED: {
|
|
268
|
+
readonly kind: "unknown";
|
|
269
|
+
};
|
|
270
|
+
readonly REQUEST_TIMEOUT: {
|
|
271
|
+
readonly kind: "timeout";
|
|
272
|
+
};
|
|
273
|
+
readonly CONNECTION_CLOSED: {
|
|
274
|
+
readonly kind: "connection_closed";
|
|
275
|
+
};
|
|
276
|
+
readonly SEND_FAILED: {
|
|
277
|
+
readonly kind: "unknown";
|
|
278
|
+
};
|
|
279
|
+
readonly INVALID_RESULT: {
|
|
280
|
+
readonly kind: "protocol";
|
|
281
|
+
};
|
|
282
|
+
readonly UNSUPPORTED_RESULT_TYPE: {
|
|
283
|
+
readonly kind: "protocol";
|
|
284
|
+
};
|
|
285
|
+
readonly INPUT_REQUIRED_ROUNDS_EXCEEDED: {
|
|
286
|
+
readonly kind: "protocol";
|
|
287
|
+
};
|
|
288
|
+
readonly LIST_PAGINATION_EXCEEDED: {
|
|
289
|
+
readonly kind: "protocol";
|
|
290
|
+
};
|
|
291
|
+
readonly METHOD_NOT_SUPPORTED_BY_PROTOCOL_VERSION: {
|
|
292
|
+
readonly kind: "protocol";
|
|
293
|
+
readonly unsent: true;
|
|
294
|
+
};
|
|
295
|
+
readonly ERA_NEGOTIATION_FAILED: {
|
|
296
|
+
readonly kind: "unknown";
|
|
297
|
+
};
|
|
298
|
+
readonly CLIENT_HTTP_NOT_IMPLEMENTED: "status";
|
|
299
|
+
readonly CLIENT_HTTP_AUTHENTICATION: {
|
|
300
|
+
readonly kind: "unauthorized";
|
|
301
|
+
readonly reason: "rejected";
|
|
302
|
+
};
|
|
303
|
+
readonly CLIENT_HTTP_FORBIDDEN: {
|
|
304
|
+
readonly kind: "unauthorized";
|
|
305
|
+
readonly reason: "scope";
|
|
306
|
+
};
|
|
307
|
+
readonly CLIENT_HTTP_UNEXPECTED_CONTENT: {
|
|
308
|
+
readonly kind: "not_mcp_response";
|
|
309
|
+
};
|
|
310
|
+
readonly CLIENT_HTTP_FAILED_TO_OPEN_STREAM: "status";
|
|
311
|
+
readonly CLIENT_HTTP_FAILED_TO_TERMINATE_SESSION: "status";
|
|
312
|
+
};
|
|
247
313
|
/** One row of the classifier: `when` reads structure only; `reads` names the class it saw. */
|
|
248
314
|
export interface McpFailureRule {
|
|
249
315
|
/** The row's name, for the discrimination pins (one pin per row) and for a reader of a verdict. */
|
|
@@ -253,10 +319,11 @@ export interface McpFailureRule {
|
|
|
253
319
|
}
|
|
254
320
|
/**
|
|
255
321
|
* The ORDERED classifier. First match wins; the final row matches everything. The order is part of
|
|
256
|
-
* the contract —
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* (a
|
|
322
|
+
* the contract — this side's own refusals first (the peer seat's; the request fetch's reading of a
|
|
323
|
+
* refused authorization), then the SDK's typed errors, because they say where the failure arose (a
|
|
324
|
+
* `ProtocolError` is never a transport failure, whatever its text says; an `SdkError` reads by its code),
|
|
325
|
+
* then the cause-chain codes from most specific (a configuration fault, a spawn) to least (a
|
|
326
|
+
* connect-phase errno, any other network code).
|
|
260
327
|
*/
|
|
261
328
|
export declare const FAILURE_CLASSIFIER: ReadonlyArray<McpFailureRule>;
|
|
262
329
|
/**
|
|
@@ -285,21 +352,21 @@ export declare function readMcpFailure(err: unknown, at: McpFailureSite): {
|
|
|
285
352
|
export interface McpUnavailableEntry extends AnnouncedMcpFailure {
|
|
286
353
|
authorization?: McpAuthorization;
|
|
287
354
|
}
|
|
288
|
-
/** Where the user authorizes, as every model-facing line names it: the seat's URL
|
|
355
|
+
/** Where the user authorizes, as every model-facing line names it: the seat's URL when the seat gave one, else only that none was given. */
|
|
289
356
|
export declare function whereToAuthorize(authorizeUrl: string | undefined): string;
|
|
290
357
|
/**
|
|
291
358
|
* The `mcp_unavailable` frame's needs-authorization arm — the servers among `entries` whose failure record carries `authorization`, or
|
|
292
359
|
* `undefined` when there are none. CC 2.1.309's arm, minted as `needsAuthMcpServers` (cli309.js:265582), read back as `needsAuthMcpServers` (cli309.js:267398),
|
|
293
360
|
* worded (cli309.js:267399) "The following MCP servers require authentication before their tools can be used" — ahead of the
|
|
294
361
|
* failed-to-connect arm; this engine never runs an authorization flow itself, so it is always the reference's cannot-start-the-flow form.
|
|
295
|
-
* `<where>` is the deployment seat's `authorizeUrl` when it gave one (listed beside the server), else the
|
|
362
|
+
* `<where>` is the deployment seat's `authorizeUrl` when it gave one (listed beside the server), else only the fact that none was given; no error
|
|
296
363
|
* text rides it (the fact is the record's). At most `max` servers are named, the rest counted.
|
|
297
364
|
*/
|
|
298
365
|
export declare function needsAuthorizationArm(entries: readonly McpUnavailableEntry[], max: number): string | undefined;
|
|
299
366
|
/**
|
|
300
367
|
* The model's line for a request refused as `unauthorized` — the call-time twin of the needs-authorization arm the `mcp_unavailable`
|
|
301
368
|
* frame carries for a server that could not mount (turn-attachments.ts): who must act (the user), where ({@link whereToAuthorize}: the
|
|
302
|
-
* seat's URL
|
|
369
|
+
* seat's URL, or that none was given), what not to ask for, and the delivery tail (`writeTail`, the caller's write-class sentence) the verdict owes. A 401
|
|
303
370
|
* after which the deployment answered another credential that no request has carried yet (`renewed`: the first attempt, not sent again)
|
|
304
371
|
* may pass on a new call: the line says so, and that only a refusal of that call too is the user's — a seat that answers a fresh
|
|
305
372
|
* credential every time still reaches the user. A re-send refused again is the plain line.
|
|
@@ -308,7 +375,7 @@ export declare function unauthorizedLine(what: string, serverLabel: string, a: M
|
|
|
308
375
|
/**
|
|
309
376
|
* What a transport-level HTTP failure can be said to be, in words for a model-facing line: the
|
|
310
377
|
* condition to name, and the delivery verdict. `undefined` for every failure that is NOT of the HTTP
|
|
311
|
-
* transport family (
|
|
378
|
+
* transport family (a ProtocolError is an answer FROM the server; a bare error with no structure is
|
|
312
379
|
* `unknown` and gets no transport story). Shared with the A2A client leg, which faces the SAME `fetch`
|
|
313
380
|
* layer and owes the same outcome contract — one classifier, so the two protocols cannot drift on what
|
|
314
381
|
* "the request never reached them" means.
|
package/dist/core/mcp-failure.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { StreamableHTTPError } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
1
|
+
import { ProtocolError, SdkError, SdkErrorCode, SdkHttpError } from "@modelcontextprotocol/client";
|
|
3
2
|
import { proxyTunnelRefusedSentence, readConnectFailure } from "../brain/errors.js";
|
|
4
3
|
import { PeerAuthorizationRefused, PeerSeatFailure } from "./peer-seat.js";
|
|
4
|
+
import { hostSeatVerdictOf } from "./mcp-host-seat.js";
|
|
5
5
|
export const MCP_FAILURE_KINDS = Object.freeze([
|
|
6
6
|
"connect_refused",
|
|
7
7
|
"connection_failed",
|
|
@@ -14,6 +14,7 @@ export const MCP_FAILURE_KINDS = Object.freeze([
|
|
|
14
14
|
"protocol",
|
|
15
15
|
"invalid_config",
|
|
16
16
|
"credential_unavailable",
|
|
17
|
+
"host_refused",
|
|
17
18
|
"unknown",
|
|
18
19
|
]);
|
|
19
20
|
export const MCP_AUTHORIZATION_REASONS = Object.freeze(["rejected", "scope", "none"]);
|
|
@@ -30,6 +31,7 @@ export const DELIVERED_BY_KIND = {
|
|
|
30
31
|
protocol: "yes",
|
|
31
32
|
invalid_config: "no",
|
|
32
33
|
credential_unavailable: "no",
|
|
34
|
+
host_refused: "no",
|
|
33
35
|
unknown: "unknown",
|
|
34
36
|
};
|
|
35
37
|
export const MCP_LIVENESS_STATES = Object.freeze(["reachable", "unreachable", "unknown"]);
|
|
@@ -45,6 +47,7 @@ export const LIVENESS_BY_FAILURE_KIND = {
|
|
|
45
47
|
protocol: "reachable",
|
|
46
48
|
invalid_config: undefined,
|
|
47
49
|
credential_unavailable: undefined,
|
|
50
|
+
host_refused: undefined,
|
|
48
51
|
unknown: "unknown",
|
|
49
52
|
};
|
|
50
53
|
export function livenessOf(outcome, observedAt) {
|
|
@@ -80,7 +83,7 @@ const NETWORK_CODES_NEVER_DELIVERED = new Set([
|
|
|
80
83
|
export function networkErrorCode(err, depth = 0) {
|
|
81
84
|
if (depth > 5 || !(err instanceof Error))
|
|
82
85
|
return undefined;
|
|
83
|
-
const code = err.code;
|
|
86
|
+
const code = err instanceof SdkError ? undefined : err.code;
|
|
84
87
|
if (typeof code === "string" && /^(?:E[A-Z_]+|UND_ERR_[A-Z_]+)$/.test(code))
|
|
85
88
|
return code;
|
|
86
89
|
if (err instanceof AggregateError) {
|
|
@@ -94,6 +97,43 @@ export function networkErrorCode(err, depth = 0) {
|
|
|
94
97
|
}
|
|
95
98
|
const isNodeErrCode = (code) => code.startsWith("ERR_");
|
|
96
99
|
const isDeclarationFault = (code) => code === "ERR_INVALID_URL" || (typeof code === "string" && code.startsWith("config."));
|
|
100
|
+
export const SDK_ERROR_READINGS = {
|
|
101
|
+
[SdkErrorCode.NotConnected]: { kind: "connection_closed", unsent: true },
|
|
102
|
+
[SdkErrorCode.AlreadyConnected]: { kind: "unknown" },
|
|
103
|
+
[SdkErrorCode.NotInitialized]: { kind: "unknown" },
|
|
104
|
+
[SdkErrorCode.CapabilityNotSupported]: { kind: "unknown" },
|
|
105
|
+
[SdkErrorCode.RequestTimeout]: { kind: "timeout" },
|
|
106
|
+
[SdkErrorCode.ConnectionClosed]: { kind: "connection_closed" },
|
|
107
|
+
[SdkErrorCode.SendFailed]: { kind: "unknown" },
|
|
108
|
+
[SdkErrorCode.InvalidResult]: { kind: "protocol" },
|
|
109
|
+
[SdkErrorCode.UnsupportedResultType]: { kind: "protocol" },
|
|
110
|
+
[SdkErrorCode.InputRequiredRoundsExceeded]: { kind: "protocol" },
|
|
111
|
+
[SdkErrorCode.ListPaginationExceeded]: { kind: "protocol" },
|
|
112
|
+
[SdkErrorCode.MethodNotSupportedByProtocolVersion]: { kind: "protocol", unsent: true },
|
|
113
|
+
[SdkErrorCode.EraNegotiationFailed]: { kind: "unknown" },
|
|
114
|
+
[SdkErrorCode.ClientHttpNotImplemented]: "status",
|
|
115
|
+
[SdkErrorCode.ClientHttpAuthentication]: { kind: "unauthorized", reason: "rejected" },
|
|
116
|
+
[SdkErrorCode.ClientHttpForbidden]: { kind: "unauthorized", reason: "scope" },
|
|
117
|
+
[SdkErrorCode.ClientHttpUnexpectedContent]: { kind: "not_mcp_response" },
|
|
118
|
+
[SdkErrorCode.ClientHttpFailedToOpenStream]: "status",
|
|
119
|
+
[SdkErrorCode.ClientHttpFailedToTerminateSession]: "status",
|
|
120
|
+
};
|
|
121
|
+
function httpStatusClass(err) {
|
|
122
|
+
const status = err instanceof SdkHttpError ? err.status : undefined;
|
|
123
|
+
if (status === 401)
|
|
124
|
+
return { kind: "unauthorized", authorization: { reason: "rejected" } };
|
|
125
|
+
return typeof status === "number" && Number.isInteger(status) && status > 0 ? { kind: "http_status", httpStatus: status } : { kind: "not_mcp_response" };
|
|
126
|
+
}
|
|
127
|
+
function sdkErrorClass(err) {
|
|
128
|
+
const reading = SDK_ERROR_READINGS[err.code];
|
|
129
|
+
if (reading === undefined)
|
|
130
|
+
return { kind: "unknown" };
|
|
131
|
+
if (reading === "status")
|
|
132
|
+
return httpStatusClass(err);
|
|
133
|
+
if (reading.kind === "unauthorized")
|
|
134
|
+
return { kind: "unauthorized", authorization: { reason: reading.reason } };
|
|
135
|
+
return { kind: reading.kind, ...(reading.unsent === true ? { unsent: true } : {}) };
|
|
136
|
+
}
|
|
97
137
|
export const FAILURE_CLASSIFIER = [
|
|
98
138
|
{
|
|
99
139
|
name: "peer seat answered the principal is not authorized",
|
|
@@ -106,36 +146,27 @@ export const FAILURE_CLASSIFIER = [
|
|
|
106
146
|
reads: () => ({ kind: "credential_unavailable", unsent: true }),
|
|
107
147
|
},
|
|
108
148
|
{
|
|
109
|
-
name: "
|
|
110
|
-
when: (err) => err instanceof
|
|
111
|
-
reads: () =>
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
when: (err) => err instanceof McpError && err.code === ErrorCode.RequestTimeout,
|
|
116
|
-
reads: () => ({ kind: "timeout" }),
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: "server answered with a protocol error",
|
|
120
|
-
when: (err) => err instanceof McpError,
|
|
121
|
-
reads: () => ({ kind: "protocol" }),
|
|
149
|
+
name: "http endpoint refused the authorization",
|
|
150
|
+
when: (err) => err instanceof PeerAuthorizationRefused,
|
|
151
|
+
reads: (err) => {
|
|
152
|
+
const refused = err;
|
|
153
|
+
return { kind: "unauthorized", authorization: authorizationOf(refused.reason, refused.authorizeUrl, refused.resourceMetadataUrl) };
|
|
154
|
+
},
|
|
122
155
|
},
|
|
123
156
|
{
|
|
124
|
-
name: "
|
|
125
|
-
when: (err) =>
|
|
126
|
-
reads: (err) => err
|
|
127
|
-
? { kind: "unauthorized", authorization: authorizationOf(err.reason, err.authorizeUrl, err.resourceMetadataUrl) }
|
|
128
|
-
: { kind: "unauthorized", authorization: { reason: "rejected" } },
|
|
157
|
+
name: "host seat did not carry the request",
|
|
158
|
+
when: (err) => hostSeatVerdictOf(err) !== undefined,
|
|
159
|
+
reads: (err) => ({ kind: hostSeatVerdictOf(err)?.delivered === "no" ? "host_refused" : "unknown" }),
|
|
129
160
|
},
|
|
130
161
|
{
|
|
131
|
-
name: "
|
|
132
|
-
when: (err) => err instanceof
|
|
133
|
-
reads: (err) => (
|
|
162
|
+
name: "sdk error read by its code",
|
|
163
|
+
when: (err) => err instanceof SdkError,
|
|
164
|
+
reads: (err) => sdkErrorClass(err),
|
|
134
165
|
},
|
|
135
166
|
{
|
|
136
|
-
name: "
|
|
137
|
-
when: (err) => err instanceof
|
|
138
|
-
reads: () => ({ kind: "
|
|
167
|
+
name: "server answered with a protocol error",
|
|
168
|
+
when: (err) => err instanceof ProtocolError,
|
|
169
|
+
reads: () => ({ kind: "protocol" }),
|
|
139
170
|
},
|
|
140
171
|
{
|
|
141
172
|
name: "malformed declaration",
|
|
@@ -190,19 +221,24 @@ export function readMcpFailure(err, at) {
|
|
|
190
221
|
function authorizationOf(reason, authorizeUrl, resourceMetadataUrl) {
|
|
191
222
|
return { reason, ...(authorizeUrl !== undefined ? { authorizeUrl } : {}), ...(resourceMetadataUrl !== undefined ? { resourceMetadataUrl } : {}) };
|
|
192
223
|
}
|
|
224
|
+
const NO_AUTHORIZATION_ADDRESS = "no authorization address was given";
|
|
193
225
|
export function whereToAuthorize(authorizeUrl) {
|
|
194
|
-
return authorizeUrl !== undefined ? `at ${authorizeUrl}` :
|
|
226
|
+
return authorizeUrl !== undefined ? `at ${authorizeUrl}` : `(${NO_AUTHORIZATION_ADDRESS})`;
|
|
195
227
|
}
|
|
196
228
|
export function needsAuthorizationArm(entries, max) {
|
|
197
229
|
const named = entries.filter((f) => f.authorization !== undefined);
|
|
198
230
|
if (named.length === 0)
|
|
199
231
|
return undefined;
|
|
200
232
|
const withUrl = named.filter((f) => f.authorization?.authorizeUrl !== undefined).length;
|
|
201
|
-
const where = withUrl === named.length
|
|
233
|
+
const where = withUrl === named.length
|
|
234
|
+
? "— at the address listed beside it —"
|
|
235
|
+
: withUrl === 0
|
|
236
|
+
? whereToAuthorize(undefined)
|
|
237
|
+
: "— at the address listed beside it (a server listed without one was given no authorization address) —";
|
|
202
238
|
const lines = named.slice(0, max).map((f) => `${f.name}${f.authorization?.authorizeUrl !== undefined ? ` — authorize ${whereToAuthorize(f.authorization.authorizeUrl)}` : ""}`);
|
|
203
239
|
return (`The following MCP servers require authentication before their tools can be used:\n${lines.join("\n")}${named.length > max ? `\n…and ${named.length - max} more` : ""}\n\n` +
|
|
204
240
|
`You cannot start the authorization flow yourself. If the user's request depends on one of these servers (even if they didn't name it explicitly), ` +
|
|
205
|
-
`or they ask about it, tell them that it needs to be authorized
|
|
241
|
+
`or they ask about it, tell them that it needs to be authorized ${where} and that the capability is unavailable until they do. ` +
|
|
206
242
|
`Otherwise carry on with the request and do not mention these servers. Do not ask the user for authorization codes, tokens, or callback URLs.`);
|
|
207
243
|
}
|
|
208
244
|
export function unauthorizedLine(what, serverLabel, a, renewed, writeTail) {
|
|
@@ -248,6 +284,7 @@ export function describeHttpTransportFailure(err, at = { phase: "request" }) {
|
|
|
248
284
|
case "protocol":
|
|
249
285
|
case "invalid_config":
|
|
250
286
|
case "credential_unavailable":
|
|
287
|
+
case "host_refused":
|
|
251
288
|
case "unknown":
|
|
252
289
|
return undefined;
|
|
253
290
|
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The host seat: the source of the MCP pipe the HOST supplies for one leg, mounted by a declaration whose transport is `{ kind: "host" }`
|
|
3
|
+
* ({@link import("./mcp-server-spec.js").McpServerSpec}). The declaration is data (it rides `TaskSpec.mcp`, the wiring manifest and a
|
|
4
|
+
* resume config like any other entry); the seat is a live object and rides the trusted channel only (`RunInternals.mcpHostSeats`, keyed
|
|
5
|
+
* by the declaration's `name`), never a spec, a checkpoint or a retained child's snapshot.
|
|
6
|
+
*
|
|
7
|
+
* A seat hands one MCP SDK `Transport` per dial ({@link McpHostSeat.open}); the server behind it answers the whole protocol itself — its
|
|
8
|
+
* handshake, its instructions, its resources — and goes through the one MCP pipeline every server does (the dial, the listing intake,
|
|
9
|
+
* the call lane, the failure record), so its tool names, its listed `_meta` and its call `_meta` are what a stdio or http server's would
|
|
10
|
+
* be. Its server is the host's own code: it is not confined by the engine's sandbox, and what it reaches is not judged by the engine's
|
|
11
|
+
* host floor (that floor judges an http declaration's URL).
|
|
12
|
+
*
|
|
13
|
+
* THE PIPE'S OWNERSHIP — one rule, four checkpoints, all at the dial ({@link openHostPipe}, {@link hostMount}):
|
|
14
|
+
* · one open per dial: every dial (the first, a re-dial, a child's, a resumed leg's) asks the seat once; no pipe is kept across dials;
|
|
15
|
+
* · one deadline over the whole mount — the open, the pipe's `start`, the handshake, the first listing — raced against the dial's stop:
|
|
16
|
+
* the host's pipe can hold any of those steps, where the SDK's own timer covers the requests only. At the deadline the dial fails
|
|
17
|
+
* `timeout`, and the engine closes the pipe (one that arrives later too) without waiting on the host;
|
|
18
|
+
* · a pipe is taken once, at its arrival: one handed again — to another dial, or to this one after it stopped waiting — is refused
|
|
19
|
+
* and left alone (it is its first taker's); a late pipe nobody took is taken and closed;
|
|
20
|
+
* · a pipe is a transport: `start` / `send` / `close` functions, and no `sessionId` (the SDK skips the handshake on a pipe that holds one,
|
|
21
|
+
* and the server's capabilities and instructions would never be read).
|
|
22
|
+
* A pipe taken is the dial's: the engine connects it and the engine closes it — at once, for the engine: the connection reads closed when
|
|
23
|
+
* the engine closes it, and the host's own close runs on the host's time, never waited on, its failure nobody's (`TakenPipe`). A refusal is
|
|
24
|
+
* `host_refused` (nothing was sent), in the engine's own words.
|
|
25
|
+
*
|
|
26
|
+
* WHAT THE HOST CAN SAY — one class, {@link McpHostSeatFailure}, read by one classifier row wherever it surfaces: thrown by `open` (the
|
|
27
|
+
* dial fails, nothing was sent), or the rejection of the pipe's `send` of a request (that request fails). A request settles ONCE, by
|
|
28
|
+
* whichever comes first: the server's answer, its send's rejection, the engine's cancel (its abort, its timer, the idle watchdog), the
|
|
29
|
+
* pipe's close — a host that closes the pipe and then rejects a send reads as the closed connection. A cancellation the pipe fails to
|
|
30
|
+
* send is no request's ending (the cancelled request already ended as cancelled): cancelling a call on the host's server is best effort.
|
|
31
|
+
*
|
|
32
|
+
* A host that serves requests rather than messages hands {@link hostSeatOfRequests} of its {@link McpHostRequestSeat}: the one adapter
|
|
33
|
+
* answers the handshake itself, carries `tools/list` and `tools/call` only, and hands back the seat's failures through the same `send`
|
|
34
|
+
* rejection (see {@link hostSeatOfRequests}).
|
|
35
|
+
*/
|
|
36
|
+
import { type Transport } from "@modelcontextprotocol/client";
|
|
37
|
+
/**
|
|
38
|
+
* The host's pipe source for one leg (`RunInternals.mcpHostSeats`, TRUSTED, by declaration name). `open` is asked once per dial of that
|
|
39
|
+
* declaration and hands one transport (or a promise of one); `server` is the declaration's name, `signal` aborts when the engine stops
|
|
40
|
+
* waiting for this mount (the run's abort, the mount's deadline). What `open` hands is the dial's from its arrival (see the module note):
|
|
41
|
+
* a transport handed a second time is refused. `open` throws {@link McpHostSeatFailure} to say why there is no pipe; anything else it
|
|
42
|
+
* throws refuses the dial in the engine's words. The engine never disposes a seat: the host releases it when its leg ends.
|
|
43
|
+
*/
|
|
44
|
+
export interface McpHostSeat {
|
|
45
|
+
open(at: {
|
|
46
|
+
readonly server: string;
|
|
47
|
+
readonly signal: AbortSignal;
|
|
48
|
+
}): Transport | Promise<Transport>;
|
|
49
|
+
}
|
|
50
|
+
/** The requests a request-level host seat answers: a listing and a call. */
|
|
51
|
+
export type McpHostSeatMethod = "tools/list" | "tools/call";
|
|
52
|
+
/** A request-level host seat's answer to one request: the JSON-RPC result, or the JSON-RPC error the remote answered with. */
|
|
53
|
+
export type McpHostSeatAnswer = {
|
|
54
|
+
readonly result: unknown;
|
|
55
|
+
} | {
|
|
56
|
+
readonly error: {
|
|
57
|
+
readonly code: number;
|
|
58
|
+
readonly message: string;
|
|
59
|
+
readonly data?: unknown;
|
|
60
|
+
};
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* A host's seat that answers requests rather than messages — handed to the engine as {@link hostSeatOfRequests}`(seat)`. `request`
|
|
64
|
+
* answers one request; `signal` is that request's own cancellation. A request the host could not hand to the remote, or whose ending it
|
|
65
|
+
* cannot tell, is answered by throwing {@link McpHostSeatFailure}.
|
|
66
|
+
*/
|
|
67
|
+
export interface McpHostRequestSeat {
|
|
68
|
+
request(method: McpHostSeatMethod, params: Readonly<Record<string, unknown>>, signal: AbortSignal): Promise<McpHostSeatAnswer>;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* What a host says it could not carry, in the one fact the host knows: `delivered: "no"` — nothing was handed to the remote (no pipe was
|
|
72
|
+
* handed over, or the request was not sent; the failure word is `host_refused`); `delivered: "unknown"` — the request was handed on and
|
|
73
|
+
* the host cannot tell how it ended (the failure word is `unknown`; at the dial, nothing of the caller's was sent either way).
|
|
74
|
+
* `condition` is the host's own sentence about why, read as untrusted text and bounded here; the engine adds what the verdict owes the
|
|
75
|
+
* model (retry safety, the verify-first warning of a write-capable tool) itself, so the condition carries none of it. A value of this
|
|
76
|
+
* class whose two facts do not read as they were built is no verdict: it reads as any other thrown value does.
|
|
77
|
+
*/
|
|
78
|
+
export declare class McpHostSeatFailure extends Error {
|
|
79
|
+
readonly delivered: "no" | "unknown";
|
|
80
|
+
readonly condition: string;
|
|
81
|
+
constructor(o: {
|
|
82
|
+
delivered: "no" | "unknown";
|
|
83
|
+
condition: string;
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
/** The host's verdict a failure states: the delivery fact and the sentence a failure renders. */
|
|
87
|
+
export interface HostSeatVerdict {
|
|
88
|
+
readonly delivered: "no" | "unknown";
|
|
89
|
+
readonly condition: string;
|
|
90
|
+
}
|
|
91
|
+
/** The host's verdict a thrown value states — a {@link McpHostSeatFailure} whose two facts read as they were built, read once into the
|
|
92
|
+
* engine's own copy (the condition bounded again: re-bounding a bounded sentence leaves it as it is) — else `undefined`, also for a value
|
|
93
|
+
* whose inspection throws. Structure only: a remote's JSON cannot build one, and its shape is no verdict. */
|
|
94
|
+
export declare function hostSeatVerdictOf(err: unknown): HostSeatVerdict | undefined;
|
|
95
|
+
/** The sentence a host's verdict becomes on the call lane: who failed and why, then the tail the delivery fact owes. */
|
|
96
|
+
export declare function hostSeatLine(what: string, serverLabel: string, seat: HostSeatVerdict, writeTail: string): string;
|
|
97
|
+
/** A host-seat declaration whose leg holds no seat of its name: refused at its dial (`config.mcp_host_seat_missing`), nothing sent. */
|
|
98
|
+
export declare function hostSeatMissing(server: string): Error & {
|
|
99
|
+
code: string;
|
|
100
|
+
};
|
|
101
|
+
/**
|
|
102
|
+
* One host row's mount under ONE deadline (the module note): `signal` aborts when `ms` (the row's startup bound; absent, the SDK's own
|
|
103
|
+
* request default) has passed since the mount began — a `RequestTimeout`, which the dial reads as `timeout` — or when `run` (the run's
|
|
104
|
+
* abort) fires, with its reason. `end` stands both down once the first listing is in, or the dial failed.
|
|
105
|
+
*/
|
|
106
|
+
export declare function hostMount(ms: number | undefined, run: AbortSignal | undefined): {
|
|
107
|
+
readonly signal: AbortSignal;
|
|
108
|
+
end(): void;
|
|
109
|
+
};
|
|
110
|
+
/** `work`, unless `stop` fires first: then the stop's reason, at once — whatever `work` does later is dropped (never an unhandled
|
|
111
|
+
* rejection). Without a stop, `work` itself. A mount step on a host's pipe waits through here (the module note). */
|
|
112
|
+
export declare function settledBefore<T>(work: Promise<T>, stop: AbortSignal | undefined): Promise<T>;
|
|
113
|
+
/**
|
|
114
|
+
* The dial's pipe from the leg's seat (the module note's four checkpoints): `open` asked once, raced against `stop` (the mount's signal);
|
|
115
|
+
* what arrives is taken, then judged a transport. Throws the stop's reason when the dial stopped waiting (a pipe that arrives later is
|
|
116
|
+
* taken and closed, unless another dial took it), the host's own {@link McpHostSeatFailure} when `open` threw one, and the engine's
|
|
117
|
+
* refusal for everything else (an `open` that threw anything else or is not a function, a value that is no transport, a pipe already taken).
|
|
118
|
+
*/
|
|
119
|
+
export declare function openHostPipe(seat: McpHostSeat, server: string, stop: AbortSignal | undefined): Promise<Transport>;
|
|
120
|
+
/**
|
|
121
|
+
* The one adapter from a request-level seat to a pipe source: each `open` hands a fresh pipe over `seat`. What the pipe does itself:
|
|
122
|
+
* · answers `initialize` locally — the server's name is the dial's declaration name, its version the empty string (a host-seat declaration
|
|
123
|
+
* states no version), its capabilities `tools` only, no instructions — and swallows `notifications/initialized`;
|
|
124
|
+
* · hands `tools/list` and `tools/call` to the seat, one {@link McpHostRequestSeat.request} each, with a signal of the request's own —
|
|
125
|
+
* aborted when the engine cancels that request (its abort, its timeout, the idle watchdog) and when the pipe closes;
|
|
126
|
+
* · refuses every other method locally (the request is not handed on), and drops an answer that arrives after its request was cancelled.
|
|
127
|
+
* The seat's answer reaches the SDK as the JSON-RPC response it is; the seat's failure — its {@link McpHostSeatFailure}, anything else it
|
|
128
|
+
* throws (read as `unknown`, in the engine's words, never the thrown text), an answer the protocol cannot carry — as the rejection of that
|
|
129
|
+
* request's `send`, which the SDK hands to the waiting request as it is, clearing its handlers.
|
|
130
|
+
*/
|
|
131
|
+
export declare function hostSeatOfRequests(seat: McpHostRequestSeat): McpHostSeat;
|