@sema-agent/core 7.60.0 → 7.62.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 +917 -0
- package/README.md +2 -2
- package/dist/agents/agent-transcript-tool.d.ts +2 -2
- package/dist/agents/agent-transcript-tool.js +1 -1
- package/dist/agents/cascade.d.ts +71 -12
- package/dist/agents/cascade.js +61 -21
- 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 -0
- package/dist/agents/inherited-tool-pool.d.ts +5 -3
- package/dist/agents/inherited-tool-pool.js +2 -2
- package/dist/agents/list-agents-tool.d.ts +1 -1
- package/dist/agents/peer-held-queue.d.ts +27 -4
- package/dist/agents/peer-held-queue.js +81 -36
- 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 +49 -10
- package/dist/agents/repair-loop.js +16 -6
- package/dist/agents/retain-ledger.js +3 -1
- package/dist/agents/roster-store.d.ts +1 -1
- package/dist/agents/roster-store.js +7 -4
- package/dist/agents/send-message-tool.d.ts +8 -10
- package/dist/agents/send-message-tool.js +43 -23
- 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 +36 -41
- package/dist/agents/subagent.js +245 -200
- package/dist/agents/suspend-guard.d.ts +47 -16
- package/dist/agents/suspend-guard.js +13 -4
- package/dist/agents/verify.d.ts +41 -14
- package/dist/agents/verify.js +41 -30
- package/dist/brain/anthropic.js +1 -0
- 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/stream-engine.d.ts +3 -0
- package/dist/brain/stream-engine.js +4 -0
- package/dist/core/agent-state.d.ts +1 -1
- package/dist/core/allow-entry.d.ts +59 -23
- package/dist/core/allow-entry.js +131 -38
- 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.js +3 -5
- package/dist/core/background-agent-store.d.ts +7 -5
- package/dist/core/background-agent-store.js +12 -11
- package/dist/core/checkpoint-features.d.ts +722 -0
- package/dist/core/checkpoint-features.js +98 -0
- package/dist/core/checkpoint-requirements.d.ts +33 -5
- package/dist/core/checkpoint-requirements.js +18 -5
- package/dist/core/checkpoint-row-verdict.d.ts +99 -0
- package/dist/core/checkpoint-row-verdict.js +225 -0
- package/dist/core/checkpoint-store.d.ts +107 -738
- package/dist/core/checkpoint-store.js +45 -143
- 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/context-settings.js +3 -5
- package/dist/core/cross-boundary-taint.d.ts +1 -1
- 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 +68 -21
- package/dist/core/engine-notice.js +9 -2
- 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 +10 -0
- package/dist/core/frame-settlement.js +6 -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 +4 -3
- package/dist/core/gate-lanes.js +7 -4
- 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 +14 -4
- package/dist/core/governance-codes.js +19 -4
- package/dist/core/hooks.d.ts +25 -4
- package/dist/core/hooks.js +11 -4
- package/dist/core/host-floor.js +3 -5
- package/dist/core/human-input-projection.d.ts +1 -0
- package/dist/core/human-input-projection.js +3 -0
- package/dist/core/image-admission.d.ts +47 -7
- package/dist/core/image-admission.js +35 -4
- package/dist/core/input-author.d.ts +36 -0
- package/dist/core/input-author.js +39 -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 +4 -3
- package/dist/core/locked-config.js +5 -3
- 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-connection-pool.d.ts +6 -20
- package/dist/core/mcp-connection-pool.js +10 -28
- package/dist/core/mcp-failure.d.ts +76 -15
- package/dist/core/mcp-failure.js +60 -33
- package/dist/core/mcp-host-seat.d.ts +92 -53
- package/dist/core/mcp-host-seat.js +225 -46
- package/dist/core/mcp-probe.js +2 -2
- 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 +2 -1
- 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 +6 -49
- package/dist/core/mcp.js +115 -111
- 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-engine/consolidation-driver.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.d.ts +1 -1
- package/dist/core/memory-engine/consolidation.js +7 -1
- 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/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/sync-client.d.ts +39 -18
- package/dist/core/memory-engine/sync-client.js +72 -14
- package/dist/core/memory-engine/sync-report.d.ts +7 -4
- package/dist/core/memory-engine/sync.d.ts +9 -1
- package/dist/core/memory-vector.d.ts +1 -1
- package/dist/core/memory.d.ts +10 -10
- package/dist/core/mode-policy.d.ts +8 -8
- package/dist/core/mode-policy.js +8 -6
- package/dist/core/mods/agent-stations.d.ts +39 -4
- package/dist/core/mods/agent-stations.js +59 -10
- package/dist/core/mods/classic-events.d.ts +9 -1
- package/dist/core/mods/dollar.d.ts +94 -1
- package/dist/core/mods/dollar.js +13 -1
- 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 +4 -3
- package/dist/core/mods/kernel/dispatch.js +4 -4
- package/dist/core/mods/kernel/events.d.ts +14 -3
- package/dist/core/mods/kernel/events.js +18 -15
- 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 +36 -4
- package/dist/core/mods/lifecycle-stations.js +44 -9
- package/dist/core/mods/session-append.d.ts +118 -0
- package/dist/core/mods/session-append.js +318 -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 +138 -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 +88 -21
- package/dist/core/mods/stations.js +149 -11
- package/dist/core/mods/tool-call.d.ts +2 -0
- package/dist/core/mods/tool-call.js +4 -4
- package/dist/core/output-style.js +3 -4
- package/dist/core/own-property-receipt.d.ts +68 -2
- package/dist/core/own-property-receipt.js +45 -2
- package/dist/core/park-selfcheck.js +4 -2
- 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 +3 -3
- package/dist/core/peer-seat.js +20 -8
- package/dist/core/permission-rule-consent.d.ts +21 -5
- package/dist/core/permission-rule-consent.js +21 -1
- package/dist/core/permission-rule-model.d.ts +34 -11
- package/dist/core/permission-rule-model.js +47 -10
- 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/read-root-candidate.js +1 -1
- package/dist/core/remote-env.d.ts +74 -26
- package/dist/core/remote-env.js +20 -0
- package/dist/core/resume-startup-cause.d.ts +5 -4
- 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/retired-keys.d.ts +4 -4
- package/dist/core/row-admission.d.ts +10 -0
- package/dist/core/row-admission.js +5 -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 -3
- package/dist/core/runner/assemble-result.js +12 -7
- 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/compact-session.js +18 -3
- 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 +2 -2
- package/dist/core/runner/contracts.d.ts +116 -34
- package/dist/core/runner/cross-boundary-lane.d.ts +1 -1
- package/dist/core/runner/decide-continuation.d.ts +4 -2
- package/dist/core/runner/decide-continuation.js +7 -4
- package/dist/core/runner/delegation-owner.d.ts +43 -0
- package/dist/core/runner/delegation-owner.js +59 -0
- 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/expire-settle.d.ts +44 -0
- package/dist/core/runner/expire-settle.js +55 -0
- package/dist/core/runner/git-status-frame.d.ts +3 -3
- package/dist/core/runner/git-status-frame.js +2 -1
- package/dist/core/runner/halt-attribution.d.ts +2 -1
- package/dist/core/runner/halt-attribution.js +2 -1
- package/dist/core/runner/lineage-reroot-view.d.ts +56 -0
- package/dist/core/runner/lineage-reroot-view.js +108 -0
- 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/park-commit.d.ts +2 -2
- package/dist/core/runner/permission-rule-lanes.d.ts +7 -2
- package/dist/core/runner/permission-rule-lanes.js +28 -9
- package/dist/core/runner/person-path-rows.d.ts +15 -0
- package/dist/core/runner/person-path-rows.js +27 -4
- package/dist/core/runner/placement-fence.d.ts +26 -0
- package/dist/core/runner/placement-fence.js +38 -0
- package/dist/core/runner/prepare-acquire-reconcile.d.ts +4 -1
- package/dist/core/runner/prepare-acquire-reconcile.js +7 -2
- 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 +4 -1
- package/dist/core/runner/prepare-boundary-parks.js +2 -2
- package/dist/core/runner/prepare-caps-and-workflow.d.ts +3 -0
- package/dist/core/runner/prepare-caps-and-workflow.js +2 -1
- package/dist/core/runner/prepare-config-doors.d.ts +6 -6
- package/dist/core/runner/prepare-config-doors.js +19 -21
- 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 +9 -9
- package/dist/core/runner/prepare-delegation-surface.js +4 -5
- 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-gate-stations.d.ts +19 -14
- package/dist/core/runner/prepare-gate-stations.js +6 -4
- package/dist/core/runner/prepare-hands-readface.d.ts +6 -6
- package/dist/core/runner/prepare-hands-readface.js +32 -11
- package/dist/core/runner/prepare-inherited-gate.d.ts +8 -0
- package/dist/core/runner/prepare-inherited-gate.js +10 -3
- package/dist/core/runner/prepare-lsp.d.ts +3 -0
- package/dist/core/runner/prepare-lsp.js +2 -2
- package/dist/core/runner/prepare-park-ask.d.ts +5 -2
- package/dist/core/runner/prepare-park-ask.js +4 -5
- package/dist/core/runner/prepare-policy-chain.d.ts +10 -21
- package/dist/core/runner/prepare-policy-chain.js +16 -25
- package/dist/core/runner/prepare-project-context.d.ts +2 -2
- package/dist/core/runner/prepare-prompt-inputs.d.ts +5 -4
- package/dist/core/runner/prepare-prompt-inputs.js +3 -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 -7
- package/dist/core/runner/prepare-suspend-saga.js +17 -7
- package/dist/core/runner/prepare-task.d.ts +1 -1
- package/dist/core/runner/prepare-task.js +61 -30
- 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-wiring-manifest.d.ts +3 -0
- package/dist/core/runner/prepare-wiring-manifest.js +2 -1
- package/dist/core/runner/prepare-workspace-restore.d.ts +5 -0
- package/dist/core/runner/prepare-workspace-restore.js +10 -6
- 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 +8 -6
- package/dist/core/runner/resume-admission.js +23 -6
- package/dist/core/runner/resume-apply.d.ts +4 -0
- package/dist/core/runner/resume-apply.js +14 -5
- package/dist/core/runner/resume-checkpoint-screen.d.ts +9 -0
- package/dist/core/runner/resume-checkpoint-screen.js +4 -84
- 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 +2 -0
- package/dist/core/runner/run-git-lane.d.ts +2 -0
- package/dist/core/runner/run-git-lane.js +6 -2
- package/dist/core/runner/run-harness-handlers.d.ts +2 -0
- package/dist/core/runner/run-harness-handlers.js +5 -4
- package/dist/core/runner/run-identity-wiring.d.ts +2 -2
- package/dist/core/runner/run-identity-wiring.js +14 -5
- package/dist/core/runner/run-leg.d.ts +3 -3
- package/dist/core/runner/run-leg.js +64 -36
- package/dist/core/runner/run-notification-lane.js +20 -2
- package/dist/core/runner/run-recovery-lanes.js +3 -2
- package/dist/core/runner/run-settle-and-teardown.js +12 -9
- package/dist/core/runner/run-stop-and-final-verify.js +2 -1
- 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 +34 -18
- package/dist/core/runner/runtask.d.ts +18 -3
- package/dist/core/runner/runtask.js +33 -17
- 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/steering-preview.d.ts +9 -0
- package/dist/core/runner/steering-preview.js +5 -0
- 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 +16 -7
- 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 -2
- 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.js +2 -0
- 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-table-view.d.ts +56 -0
- package/dist/core/runner/tool-table-view.js +51 -0
- package/dist/core/runner/turn-attachments.d.ts +8 -2
- package/dist/core/runner/turn-attachments.js +2 -2
- 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 +26 -27
- package/dist/core/secret-env.d.ts +19 -16
- package/dist/core/secret-env.js +45 -27
- package/dist/core/session-log-transfer.js +9 -10
- package/dist/core/session-policy-store.d.ts +1 -1
- package/dist/core/session-policy-store.js +5 -2
- package/dist/core/session-reconcile.d.ts +3 -2
- package/dist/core/session-reconcile.js +7 -4
- package/dist/core/session-store.d.ts +3 -1
- package/dist/core/session-store.js +10 -8
- package/dist/core/session.d.ts +16 -5
- package/dist/core/shell-confinement.d.ts +37 -0
- package/dist/core/shell-confinement.js +56 -0
- package/dist/core/skill-grant.js +1 -1
- package/dist/core/store-contracts/checkpoint-store-contract.d.ts +8 -2
- package/dist/core/store-contracts/checkpoint-store-contract.js +83 -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/session-store-contract.js +22 -8
- package/dist/core/store-contracts/tool-result-store-contract.d.ts +1 -1
- package/dist/core/store-contracts/tool-result-store-contract.js +30 -0
- package/dist/core/task-event.d.ts +24 -9
- package/dist/core/task-limits.d.ts +5 -0
- package/dist/core/task-notification.d.ts +89 -12
- package/dist/core/task-notification.js +89 -14
- package/dist/core/task-registry-agent.d.ts +32 -50
- package/dist/core/task-registry-agent.js +36 -56
- package/dist/core/task-registry-monitor.d.ts +1 -1
- package/dist/core/task-registry-monitor.js +15 -60
- package/dist/core/task-registry-shared.d.ts +22 -112
- package/dist/core/task-registry-shared.js +3 -41
- package/dist/core/task-registry-workflow.js +5 -21
- package/dist/core/task-registry.d.ts +32 -62
- package/dist/core/task-registry.js +30 -110
- package/dist/core/task-result.d.ts +29 -12
- 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 +11 -11
- 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 +36 -6
- package/dist/core/terminal-cause.js +1 -0
- package/dist/core/tool-catalog-entries.js +2 -5
- 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.js +3 -2
- package/dist/core/tool-face.d.ts +8 -5
- package/dist/core/tool-face.js +1 -1
- package/dist/core/tool-name-aliases.d.ts +5 -29
- package/dist/core/tool-name-aliases.js +9 -5
- 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 +109 -18
- package/dist/core/tool-policy.js +84 -14
- package/dist/core/tool-result-store.d.ts +23 -0
- package/dist/core/tool-result-store.js +3 -2
- package/dist/core/tool-roster.d.ts +4 -4
- package/dist/core/tool-spec.d.ts +23 -6
- package/dist/core/trace.d.ts +18 -1
- package/dist/core/types.d.ts +1 -1
- package/dist/core/types.js +1 -1
- package/dist/core/user-attachment.js +26 -21
- 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 -9
- package/dist/engine/execution-env/node-execution-env.js +221 -22
- package/dist/engine/harness/agent-harness.d.ts +65 -18
- package/dist/engine/harness/agent-harness.js +90 -23
- package/dist/engine/harness/messages.d.ts +4 -3
- package/dist/engine/harness/messages.js +2 -2
- package/dist/engine/harness/types.d.ts +52 -7
- 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 +6 -1
- package/dist/engine/loop/agent-loop.js +20 -11
- package/dist/engine/loop/types.d.ts +12 -3
- package/dist/engine/session/import-validate.js +7 -0
- package/dist/engine/session/parent-chain-guard.d.ts +3 -3
- package/dist/engine/session/parent-chain-guard.js +1 -1
- package/dist/engine/session/path-to-root.d.ts +18 -3
- package/dist/engine/session/path-to-root.js +15 -1
- package/dist/engine/session/repo-utils.d.ts +12 -1
- package/dist/engine/session/repo-utils.js +41 -0
- package/dist/engine/session/session.js +1 -1
- package/dist/engine/session/storage-base.d.ts +20 -0
- package/dist/engine/session/storage-base.js +28 -9
- package/dist/fixtures/index.d.ts +7 -5
- package/dist/fixtures/index.js +5 -3
- package/dist/index.d.ts +29 -18
- package/dist/index.js +19 -11
- package/dist/internal/harness-types.d.ts +2 -0
- package/dist/internal/harness.d.ts +4 -3
- package/dist/internal/harness.js +3 -2
- 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 +14 -17
- package/dist/orchestration/run-workflow-tool.js +43 -50
- package/dist/orchestration/workflow-types.d.ts +2 -2
- package/dist/orchestration/workflow.d.ts +7 -0
- package/dist/orchestration/workflow.js +10 -12
- package/dist/stores/file/background-agent-store.js +18 -15
- package/dist/stores/file/checkpoint-store.d.ts +2 -0
- package/dist/stores/file/checkpoint-store.js +13 -9
- package/dist/stores/file/file-history-store.js +3 -2
- package/dist/stores/file/fs-atomic.d.ts +0 -22
- package/dist/stores/file/fs-atomic.js +0 -17
- package/dist/stores/file/index.d.ts +7 -12
- package/dist/stores/file/index.js +25 -12
- 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.js +42 -22
- package/dist/stores/file/memory-store.js +3 -2
- 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.js +3 -2
- package/dist/stores/file/session-store.d.ts +26 -7
- package/dist/stores/file/session-store.js +59 -35
- package/dist/stores/file/tool-result-store.d.ts +11 -0
- package/dist/stores/file/tool-result-store.js +57 -3
- package/dist/stores/file/usage-window-store.js +3 -2
- package/dist/stores/file/workflow-journal-store.d.ts +0 -2
- package/dist/stores/file/workflow-journal-store.js +3 -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/bash-program-position.d.ts +3 -2
- package/dist/tools/fs/bash-program-position.js +7 -7
- package/dist/tools/fs/dead-cwd.d.ts +5 -5
- package/dist/tools/fs/dead-cwd.js +4 -11
- package/dist/tools/fs/fs-bash-background-text.d.ts +6 -0
- package/dist/tools/fs/fs-bash-background-text.js +6 -0
- package/dist/tools/fs/fs-bash.d.ts +3 -18
- package/dist/tools/fs/fs-bash.js +37 -124
- package/dist/tools/fs/fs-pdf.js +8 -6
- package/dist/tools/fs/fs-read.js +2 -2
- package/dist/tools/fs/fs-shared.d.ts +28 -3
- package/dist/tools/fs/fs-shared.js +15 -0
- package/dist/tools/fs/index.d.ts +1 -1
- package/dist/tools/fs/index.js +4 -14
- 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 +13 -5
- package/dist/tools/fs/read-floor.js +206 -2
- package/dist/tools/fs/removal-targets.js +2 -2
- package/dist/tools/fs/search.d.ts +3 -2
- package/dist/tools/fs/search.js +6 -6
- package/dist/tools/fs/shell-read-argv.d.ts +4 -2
- package/dist/tools/fs/shell-read-argv.js +14 -3
- package/dist/tools/fs/shell-read-bindings.d.ts +18 -2
- package/dist/tools/fs/shell-read-bindings.js +148 -68
- package/dist/tools/fs/shell-read-check.js +20 -4
- package/dist/tools/fs/shell-read-establish.js +25 -9
- package/dist/tools/fs/shell-read-functions.js +2 -2
- 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/fs/shell-read-object-path.d.ts +59 -0
- package/dist/tools/fs/shell-read-object-path.js +119 -0
- package/dist/tools/fs/shell-read-plan.d.ts +8 -0
- package/dist/tools/fs/shell-read-plan.js +47 -30
- package/dist/tools/fs/shell-read-start.d.ts +66 -13
- package/dist/tools/fs/shell-read-start.js +89 -17
- package/dist/tools/fs/shell-read-workdir.d.ts +29 -8
- package/dist/tools/fs/shell-read-workdir.js +31 -8
- package/dist/tools/monitor.d.ts +8 -7
- package/dist/tools/monitor.js +12 -10
- package/dist/tools/worktree.d.ts +5 -1
- package/dist/tools/worktree.js +20 -17
- package/package.json +6 -3
- package/test/export-surface.snapshot.json +112 -42
- package/wire-changes/core-stores-sql@7.61.0.json +480 -0
- package/wire-changes/core-stores-sql@7.62.0.json +30 -0
- package/wire-changes/core@7.61.0.json +4405 -0
- package/wire-changes/core@7.62.0.json +2181 -0
- package/wire-changes/mods-kernel@7.61.0.json +65 -0
- package/wire-changes/mods-kernel@7.62.0.json +42 -0
- package/wire-changes/primitives@7.61.0.json +30 -0
- package/wire-changes/primitives@7.62.0.json +30 -0
- package/dist/core/consolidate-scope.d.ts +0 -93
- package/dist/core/consolidate-scope.js +0 -98
- package/dist/core/runner/image-removed-seat.d.ts +0 -12
- package/dist/core/runner/image-removed-seat.js +0 -19
- package/dist/core/runner/memory-consolidation.d.ts +0 -109
- package/dist/core/runner/memory-consolidation.js +0 -251
|
@@ -22,7 +22,8 @@ export interface McpServerSpec {
|
|
|
22
22
|
* peer seat ({@link RunnerDeps.peerSeat}). A `credentials` reference with no seat wired refuses the entry
|
|
23
23
|
* (`config.peer_seat_missing`); a declaration carrying the retired value members `headers` / `env` is refused at every
|
|
24
24
|
* entrance (`config.credential_in_declaration`). `host`: the host supplies the pipe itself — the leg's host seat of this
|
|
25
|
-
* declaration's `name` (`RunInternals.mcpHostSeats`, mcp-host-seat.ts)
|
|
25
|
+
* declaration's `name` (`RunInternals.mcpHostSeats`, mcp-host-seat.ts) hands one MCP transport per dial, and the server behind
|
|
26
|
+
* it answers the whole protocol (its handshake, instructions and resources included); the transport has no member beyond
|
|
26
27
|
* its kind (a host seat carries its own pieces, so a reference or a principal header has nothing to ride), and a server mounted
|
|
27
28
|
* this way cannot opt in to {@link elicitation} — both refused at every entrance (`config.invalid_argument`). It never enters
|
|
28
29
|
* the run tree's connection pool: its pipe is the leg's own.
|
|
@@ -10,8 +10,7 @@
|
|
|
10
10
|
* knows the session (404), cannot be reached or does not answer within {@link MCP_SESSION_END_WAIT_MS} costs the close that long at most
|
|
11
11
|
* and nothing else — the close runs regardless and aborts a request still in the air.
|
|
12
12
|
*/
|
|
13
|
-
import type
|
|
14
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/sdk/client/streamableHttp.js";
|
|
13
|
+
import { StreamableHTTPClientTransport, type Client } from "@modelcontextprotocol/client";
|
|
15
14
|
import type { McpRequestSite } from "./mcp-failure.js";
|
|
16
15
|
/** The longest a close waits for the server to answer the request that ends its session. */
|
|
17
16
|
export declare const MCP_SESSION_END_WAIT_MS = 2000;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/
|
|
1
|
+
import { StreamableHTTPClientTransport } from "@modelcontextprotocol/client";
|
|
2
2
|
export const MCP_SESSION_END_WAIT_MS = 2_000;
|
|
3
3
|
export class SessionEndingTransport extends StreamableHTTPClientTransport {
|
|
4
4
|
closing;
|
package/dist/core/mcp.d.ts
CHANGED
|
@@ -81,7 +81,7 @@ export interface McpDroppedTool {
|
|
|
81
81
|
* ({@link walkMcpListPages}'s `budgetMs`) had too little left to fund another request
|
|
82
82
|
* ({@link MIN_MCP_PAGE_BUDGET_MS}), so none was sent. Distinct from `page_error` on purpose — the
|
|
83
83
|
* server neither failed nor was asked. Issuing that request anyway would hand the SDK a
|
|
84
|
-
* near-zero timeout, and its
|
|
84
|
+
* near-zero timeout, and its `RequestTimeout` would arrive here wearing the server's failure clothes.
|
|
85
85
|
* `error` is SERVER-authored text — neutralize it before it rides any model/operator face.
|
|
86
86
|
*/
|
|
87
87
|
export interface McpListingIncomplete {
|
|
@@ -403,7 +403,7 @@ export declare function structuredContentErrorLine(structuredContent: unknown, c
|
|
|
403
403
|
export declare function truncateMcpErrorText(s: string): string;
|
|
404
404
|
/**
|
|
405
405
|
* Default per-call MCP tool timeout. The SDK's own default (60s) silently kills any long-running MCP tool
|
|
406
|
-
* with a
|
|
406
|
+
* with a `RequestTimeout` and offers the deployment no knob; a very large default (matching the behavior of the
|
|
407
407
|
* reference agent client) lets the task-level budget/abort govern instead, while `MCP_TOOL_TIMEOUT` (ms)
|
|
408
408
|
* remains available to tighten it per deployment.
|
|
409
409
|
*/
|
|
@@ -432,11 +432,11 @@ export declare function mcpToolTimeoutMs(): number;
|
|
|
432
432
|
* per-call timeout). The SDK's `resetTimeoutOnProgress` only re-arms the SDK's OWN per-call timer
|
|
433
433
|
* (`mcpToolTimeoutMs()` above — a different mechanism from {@link armMcpIdleWatchdog}'s idle watchdog
|
|
434
434
|
* below, despite the name-adjacent terms; disambiguated here on purpose, see that function's docstring
|
|
435
|
-
* for why sema needs both). It enforces a total bound ONLY when `maxTotalTimeout` is provided (protocol
|
|
436
|
-
* `_resetTimeout`), so without this a
|
|
435
|
+
* for why sema needs both). It enforces a total bound ONLY when `maxTotalTimeout` is provided (the protocol
|
|
436
|
+
* layer's `_resetTimeout`), so without this a
|
|
437
437
|
* misbehaving/stuck server emitting periodic progress notifications could extend a call forever. Defaulting
|
|
438
438
|
* the ceiling to the per-call timeout means progress can keep an active call alive only within the same
|
|
439
|
-
* window the deployment already accepted; the resulting failure is the same
|
|
439
|
+
* window the deployment already accepted; the resulting failure is the same `RequestTimeout` frame. Env
|
|
440
440
|
* parsing follows the `MCP_TOOL_TIMEOUT` discipline (unset/unparseable/non-positive → default). Exported
|
|
441
441
|
* for tests.
|
|
442
442
|
*/
|
|
@@ -448,7 +448,7 @@ export declare function mcpToolTotalTimeoutMs(perCallMs: number): number;
|
|
|
448
448
|
* from its total ceiling (`j7u` @345484: stdio 30min / http-sse 5min).
|
|
449
449
|
*
|
|
450
450
|
* Narrower than the audit's original framing: a CLOSED transport is already handled correctly by the SDK
|
|
451
|
-
* itself — `Protocol._onclose`
|
|
451
|
+
* itself — `Protocol._onclose` rejects every in-flight response handler immediately
|
|
452
452
|
* with `ConnectionClosed` the moment `onclose` fires, so this watchdog exists for the SILENT-but-open case
|
|
453
453
|
* only, not as a substitute for connection-close handling.
|
|
454
454
|
*/
|
|
@@ -470,15 +470,6 @@ export declare function mcpStartupTimeoutMs(server?: Pick<McpServerSpec, "name"
|
|
|
470
470
|
/** The protocol-range condition name for a JSON-RPC error code, or `undefined` for every other code
|
|
471
471
|
* (see {@link MCP_SPEC_ERROR_CODE_NAMES}). */
|
|
472
472
|
export declare function describeMcpSpecErrorCode(code: unknown): string | undefined;
|
|
473
|
-
/**
|
|
474
|
-
* The SDK stamps `MCP error <code>: ` onto an McpError's message IN ITS CONSTRUCTOR, and it
|
|
475
|
-
* does so at BOTH ends of the wire: a server built on an MCP SDK throws an McpError, its already-stamped
|
|
476
|
-
* `.message` goes out as the JSON-RPC `error.message`, and the client constructs its own McpError over
|
|
477
|
-
* that string — so the failure reaches the model as `MCP error -32602: MCP error -32602: …`. Collapse a
|
|
478
|
-
* repeat of the SAME code (a leading stamp carrying a DIFFERENT code is server data, not a duplicate of
|
|
479
|
-
* ours, and is left alone). Exported for unit testing; not part of the package index.
|
|
480
|
-
*/
|
|
481
|
-
export declare function collapseMcpErrorPrefix(message: string): string;
|
|
482
473
|
export { normalizeNameSegment as normalizeMcpName, clampNameSegment } from "./protocol-naming.js";
|
|
483
474
|
export * from "./image-downsample.js";
|
|
484
475
|
/**
|
|
@@ -735,37 +726,3 @@ export declare function walkMcpListPages<T>(fetchPage: (cursor: string | undefin
|
|
|
735
726
|
items: T[];
|
|
736
727
|
incomplete?: McpListingIncomplete;
|
|
737
728
|
}>;
|
|
738
|
-
/**
|
|
739
|
-
* RB-408 G12 — `tools/call` result parse that accepts the MCP `2026-07-28` widening of
|
|
740
|
-
* `structuredContent` from "a JSON object" to ANY JSON value (the same revision that relaxes
|
|
741
|
-
* `inputSchema`/`outputSchema` to the full JSON Schema 2020-12 keyword set).
|
|
742
|
-
*
|
|
743
|
-
* SDK 1.30.0's `CallToolResultSchema` still types the field as a record, so a spec-legal array / string /
|
|
744
|
-
* number / boolean / null fails validation for the WHOLE result — and the failure takes the `content`
|
|
745
|
-
* blocks down with it: a server returning perfectly usable text plus a scalar `structuredContent`
|
|
746
|
-
* produced nothing but `Invalid tools/call result: expected record, received number`. That is a silent
|
|
747
|
-
* capability loss dressed as a protocol error, and it gets WORSE as servers adopt the revision.
|
|
748
|
-
*
|
|
749
|
-
* The widening is deliberately surgical: `structuredContent` is lifted out, the SDK's own strict schema
|
|
750
|
-
* runs over the remainder (so content-block validation, the `content` default and the loose passthrough
|
|
751
|
-
* of unknown top-level keys are byte-for-byte what they were), and the lifted value is re-attached
|
|
752
|
-
* VERBATIM — same reference, no rebuild. An object-valued `structuredContent` therefore behaves exactly
|
|
753
|
-
* as before, and a malformed `content` array is still rejected: this must not become a validation bypass.
|
|
754
|
-
* Same duck-typing posture as {@link LenientListToolsResultSchema} (no direct `zod` dependency — the SDK's
|
|
755
|
-
* `zod-compat` shim calls `.safeParse(data)` on any object lacking a Zod-4 `_zod` marker).
|
|
756
|
-
*
|
|
757
|
-
* RESIDUAL, SDK-side and deliberately not widened here: `Client.callTool` guards its `outputSchema`
|
|
758
|
-
* validation with a TRUTHINESS test on `result.structuredContent`, so a tool that declares an
|
|
759
|
-
* `outputSchema` and returns a falsy scalar (`0`, `""`, `false`, `null`) is still rejected by the SDK with
|
|
760
|
-
* "has an output schema but did not return structured content". That path is LOUD (never a silent drop),
|
|
761
|
-
* is bounded to outputSchema-declaring tools, and widening it means replacing `callTool` itself — which
|
|
762
|
-
* would mean re-implementing the two guards it exists for (the output validator and the
|
|
763
|
-
* `taskSupport:"required"` refusal, both keyed off SDK-private caches).
|
|
764
|
-
*/
|
|
765
|
-
export declare function parseCallToolResultLenient(data: unknown): {
|
|
766
|
-
success: true;
|
|
767
|
-
data: unknown;
|
|
768
|
-
} | {
|
|
769
|
-
success: false;
|
|
770
|
-
error: unknown;
|
|
771
|
-
};
|
package/dist/core/mcp.js
CHANGED
|
@@ -7,26 +7,27 @@ import { PeerCarrier, Reauthorized, answeredUnauthorized, carrierOf, inFlight, m
|
|
|
7
7
|
import { disposeSectionEntry, sectionAnswerWarning } from "./prompt-section-seat.js";
|
|
8
8
|
import { createToolNameClaims, mintNamespacePrefix, normalizeNameSegment } from "./protocol-naming.js";
|
|
9
9
|
import { mcpToolDropReason, refuseCollidingMcpServerNames } from "./mcp-name-judge.js";
|
|
10
|
-
import { Client } from "@modelcontextprotocol/
|
|
11
|
-
import {
|
|
10
|
+
import { Client, ProtocolError, ProtocolErrorCode } from "@modelcontextprotocol/client";
|
|
11
|
+
import { AjvJsonSchemaValidator } from "@modelcontextprotocol/client/validators/ajv";
|
|
12
|
+
import { ListResourcesResultSchema } from "@modelcontextprotocol/core";
|
|
13
|
+
import { McpConnectionPool, recordEngineDial } from "./mcp-connection-pool.js";
|
|
12
14
|
import { SessionEndingTransport, requestSite } from "./mcp-session-end.js";
|
|
13
15
|
import { mcpToolGate, UNPROVEN_GATE } from "./mcp-listing-drift.js";
|
|
14
16
|
import { ConnectionListing, Flights, IDLE_WATCHDOG_ABORT_REASON, Resendable, armMcpIdleWatchdog, callThroughLink, listingRefusal, observedFailure, owedByAnswer, reach, refusalScope } from "./mcp-server-link.js";
|
|
15
17
|
import { underStartupBound } from "./mcp-startup-request.js";
|
|
16
18
|
import { LIST_MCP_RESOURCES, MCP_RESOURCE_LIST_ALLOW, MCP_RESOURCE_READ_ALLOW, READ_MCP_RESOURCE, READ_MCP_RESOURCE_DIR, retractInstructions, tellInstructions, toldOnDial, unretractInstructions, withdrawInstructionAdds } from "./mounted-mcp.js";
|
|
17
|
-
import { StdioClientTransport } from "@modelcontextprotocol/
|
|
19
|
+
import { StdioClientTransport } from "@modelcontextprotocol/client/stdio";
|
|
18
20
|
import { describeHttpTransportFailure, failureFields, livenessOf, namingLostSession, readMcpFailure, sessionGone, unauthorizedLine } from "./mcp-failure.js";
|
|
19
21
|
import { lstat, mkdir, writeFile } from "node:fs/promises";
|
|
20
22
|
import { tmpdir } from "node:os";
|
|
21
23
|
import { join } from "node:path";
|
|
22
|
-
import {
|
|
23
|
-
import { DEFAULT_REQUEST_TIMEOUT_MSEC } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
24
|
+
import { DEFAULT_REQUEST_TIMEOUT_MSEC } from "@modelcontextprotocol/client";
|
|
24
25
|
import { resolveImageProcessor } from "./image-downsample.js";
|
|
25
26
|
import { admitImageBytes, IMAGE_ADMISSION, unprocessedSizeClause } from "./image-admission.js";
|
|
26
27
|
import { sliceHeadSafe, sliceTailSafe } from "./surrogate-safe-slice.js";
|
|
27
28
|
import { truncateError } from "./tool-errors.js";
|
|
28
29
|
import { transportKindOf } from "./mcp-server-spec.js";
|
|
29
|
-
import {
|
|
30
|
+
import { hostMount, hostSeatLine, hostSeatMissing, hostSeatVerdictOf, openHostPipe, settledBefore } from "./mcp-host-seat.js";
|
|
30
31
|
import { peerRequestRefusal } from "./host-floor.js";
|
|
31
32
|
import { delimitUntrusted, inlineUntrusted, sanitizeUntrustedText } from "./untrusted-text.js";
|
|
32
33
|
import { discloseReminderShaped, observeReminderMarkEcho } from "./reminder-disclosure.js";
|
|
@@ -159,19 +160,10 @@ const MCP_SPEC_ERROR_CODE_NAMES = new Map([
|
|
|
159
160
|
export function describeMcpSpecErrorCode(code) {
|
|
160
161
|
return typeof code === "number" ? MCP_SPEC_ERROR_CODE_NAMES.get(code) : undefined;
|
|
161
162
|
}
|
|
162
|
-
export function collapseMcpErrorPrefix(message) {
|
|
163
|
-
let out = message;
|
|
164
|
-
for (;;) {
|
|
165
|
-
const m = /^MCP error (-?\d+): (?=MCP error \1: )/.exec(out);
|
|
166
|
-
if (m === null)
|
|
167
|
-
return out;
|
|
168
|
-
out = out.slice(m[0].length);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
163
|
function sanitizeMcpErrorTextInPlace(err, declared) {
|
|
172
164
|
if (!(err instanceof Error))
|
|
173
165
|
return;
|
|
174
|
-
const sanitized = remoteWords(err
|
|
166
|
+
const sanitized = remoteWords(err.message, declared);
|
|
175
167
|
if (sanitized !== err.message)
|
|
176
168
|
err.message = sanitized;
|
|
177
169
|
}
|
|
@@ -179,13 +171,13 @@ function namedMcpFailureText(err, declared) {
|
|
|
179
171
|
const seat = hostSeatVerdictOf(err);
|
|
180
172
|
if (seat !== undefined)
|
|
181
173
|
return seat.condition;
|
|
182
|
-
const detail = remoteErrorText(err, declared
|
|
183
|
-
const
|
|
184
|
-
|
|
174
|
+
const detail = remoteErrorText(err, declared);
|
|
175
|
+
const code = thrownIs(err, ProtocolError) ? readMember(err, "code") : undefined;
|
|
176
|
+
const condition = describeMcpSpecErrorCode(code);
|
|
177
|
+
return condition !== undefined ? `${condition} (MCP protocol error ${String(code)}): ${detail}` : detail;
|
|
185
178
|
}
|
|
186
|
-
function remoteErrorText(err, declared
|
|
187
|
-
|
|
188
|
-
return remoteWords(opts?.collapse === true ? collapseMcpErrorPrefix(raw) : raw, declared);
|
|
179
|
+
function remoteErrorText(err, declared) {
|
|
180
|
+
return remoteWords(thrownText(err), declared);
|
|
189
181
|
}
|
|
190
182
|
function writeEffectWarning(writeEffect) {
|
|
191
183
|
return writeEffect
|
|
@@ -221,8 +213,9 @@ function rethrowHonestMcpError(err, ctx) {
|
|
|
221
213
|
const details = (extra) => ({ code: failure.kind, delivered: failure.delivered, server: ctx.server, ...(failure.authorization !== undefined ? { authorization: { ...failure.authorization } } : {}), ...extra });
|
|
222
214
|
switch (failure.kind) {
|
|
223
215
|
case "timeout": {
|
|
224
|
-
const data = err
|
|
225
|
-
const
|
|
216
|
+
const data = readMember(err, "data");
|
|
217
|
+
const total = typeof data === "object" && data !== null ? readMember(data, "maxTotalTimeout") : undefined;
|
|
218
|
+
const totalMs = typeof total === "number" ? total : undefined;
|
|
226
219
|
finish(markMcpFailure(new Error(totalMs !== undefined
|
|
227
220
|
? `${ctx.what} on MCP server "${serverLabel}" exceeded its total time ceiling of ${totalMs}ms (the call stayed alive — e.g. via progress notifications — but ran past the total wall-clock budget). The client stopped waiting, but the server may still be executing the request — the outcome is unknown.${writeEffectWarning(ctx.writeEffect)} (Set the MCP_TOOL_TIMEOUT_TOTAL environment variable (ms) to change this ceiling; MCP_TOOL_TIMEOUT only tunes the per-call timer, currently ${ctx.timeoutMs}ms.)`
|
|
228
221
|
: `${ctx.what} on MCP server "${serverLabel}" timed out after ${ctx.timeoutMs}ms. The client stopped waiting, but the server may still be executing the request — the outcome is unknown.${writeEffectWarning(ctx.writeEffect)} (Set the MCP_TOOL_TIMEOUT environment variable (ms) to change this limit.)`, { cause: err }), totalMs !== undefined ? details({ timeoutMs: totalMs, totalTimeout: true }) : details({ timeoutMs: ctx.timeoutMs })));
|
|
@@ -243,10 +236,10 @@ function rethrowHonestMcpError(err, ctx) {
|
|
|
243
236
|
: `${ctx.what} failed at the transport layer of MCP server "${serverLabel}": ${httpFailure.condition}. The request may or may not have executed on the server — the outcome is unknown.${writeEffectWarning(ctx.writeEffect)}${fenced}`, { cause: err }), details(failure.httpStatus !== undefined ? { httpStatus: failure.httpStatus } : undefined)));
|
|
244
237
|
}
|
|
245
238
|
case "protocol": {
|
|
246
|
-
const code = err.code;
|
|
239
|
+
const code = thrownIs(err, ProtocolError) ? err.code : undefined;
|
|
247
240
|
const condition = describeMcpSpecErrorCode(code);
|
|
248
|
-
if (condition !== undefined) {
|
|
249
|
-
finish(markMcpFailure(new Error(`${ctx.what} on MCP server "${serverLabel}" was rejected with MCP protocol error ${code} — ${condition}. The server's error text follows as external/untrusted data:\n${fenceServerText(`${ctx.server} error`, err
|
|
241
|
+
if (condition !== undefined && typeof code === "number") {
|
|
242
|
+
finish(markMcpFailure(new Error(`${ctx.what} on MCP server "${serverLabel}" was rejected with MCP protocol error ${code} — ${condition}. The server's error text follows as external/untrusted data:\n${fenceServerText(`${ctx.server} error`, thrownText(err))}`, { cause: err }), details({ specErrorCode: code })));
|
|
250
243
|
}
|
|
251
244
|
if (ctx.attributeServer) {
|
|
252
245
|
finish(markMcpFailure(new Error(`${ctx.what} on MCP server "${serverLabel}" failed. The server's error text follows as external/untrusted data:\n${fenceServerText(`${ctx.server} error`, remoteErrorText(err, ctx.declared))}`, { cause: err }), details()));
|
|
@@ -374,10 +367,10 @@ export function inferCompactSchema(value, depth = 2) {
|
|
|
374
367
|
}
|
|
375
368
|
return typeof value;
|
|
376
369
|
}
|
|
377
|
-
function buildTransport(spec, principal, kind, carrier, pieces,
|
|
370
|
+
function buildTransport(spec, principal, kind, carrier, pieces, pipe) {
|
|
378
371
|
const t = spec.transport;
|
|
379
372
|
if (kind === "host")
|
|
380
|
-
return
|
|
373
|
+
return pipe;
|
|
381
374
|
if (kind === "stdio") {
|
|
382
375
|
if (!("command" in t))
|
|
383
376
|
throw new Error(`MCP server "${spec.name}": transport kind "stdio" carries no command`);
|
|
@@ -390,7 +383,7 @@ function buildTransport(spec, principal, kind, carrier, pieces, hostSeat) {
|
|
|
390
383
|
if (!("url" in t))
|
|
391
384
|
throw new Error(`MCP server "${spec.name}": transport kind "${String(kind)}" carries no url`);
|
|
392
385
|
resolveProtocolHttpHeaders(MCP_NAMESPACE.id, t.principalHeader !== undefined ? { principalHeader: t.principalHeader } : {}, principal);
|
|
393
|
-
return new SessionEndingTransport(new URL(t.url), { fetch: peerFetch(carrier, t.principalHeader, principal) });
|
|
386
|
+
return new SessionEndingTransport(new URL(t.url), { fetch: peerFetch(carrier, t.principalHeader, principal), requestInit: { redirect: "manual" } });
|
|
394
387
|
}
|
|
395
388
|
export async function mapContent(content, serverName, imageProcessor) {
|
|
396
389
|
const processor = await resolveImageProcessor(imageProcessor);
|
|
@@ -507,7 +500,7 @@ function sanitizeMcpModelFacingValue(value, seat = "schema") {
|
|
|
507
500
|
}
|
|
508
501
|
return value;
|
|
509
502
|
}
|
|
510
|
-
const MCP_TOOL_DESCRIPTION_MAX_CHARS =
|
|
503
|
+
const MCP_TOOL_DESCRIPTION_MAX_CHARS = 4096;
|
|
511
504
|
const MCP_TOOL_DESCRIPTION_TRUNCATION_MARK = "… [truncated]";
|
|
512
505
|
function capMcpToolDescription(description) {
|
|
513
506
|
if (description.length <= MCP_TOOL_DESCRIPTION_MAX_CHARS)
|
|
@@ -727,7 +720,7 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
727
720
|
const commitConnectedServer = (spec, s, transportKind) => {
|
|
728
721
|
const raised = [];
|
|
729
722
|
connections.push({ client: s.client, close: s.close });
|
|
730
|
-
const handle = { name: spec.name, spec, client: s.client,
|
|
723
|
+
const handle = { name: spec.name, spec, client: s.client, health: s.health, tools: s.tools, listing: s.listing, intakeAt: s.intakeAt, gates: () => intakeNow(handle).gates, definitions: () => intakeNow(handle).definitions, transportKind, announce: s.announce, instructions: s.instructions };
|
|
731
724
|
const hIdx = serverHandles.findIndex((h) => h.name === spec.name);
|
|
732
725
|
if (hIdx === -1)
|
|
733
726
|
serverHandles.push(handle);
|
|
@@ -781,11 +774,13 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
781
774
|
const readDialKind = transportKindOf;
|
|
782
775
|
const dialKinds = entries.map(readDialKind);
|
|
783
776
|
const liveOf = (server) => serverHandles.find((h) => h.name === server);
|
|
784
|
-
const
|
|
777
|
+
const intakeNow = (h) => {
|
|
785
778
|
const latest = h.listing.latest();
|
|
786
|
-
if (latest.at !== h.
|
|
787
|
-
|
|
788
|
-
|
|
779
|
+
if (latest.at !== h.intakeAt.at) {
|
|
780
|
+
const { gates, definitions } = intakeListedTools({ tools: [...latest.entries], unproven: latest.unproven }, h.spec, linkOf(h.name), echoOf(h.spec), outputSchemaValidatorOf(h.client), imageProcessor, mcpDisclosure, isServerRevoked, h.transportKind, seat, echoReadOf(h.spec));
|
|
781
|
+
h.intakeAt = { at: latest.at, gates, definitions };
|
|
782
|
+
}
|
|
783
|
+
return h.intakeAt;
|
|
789
784
|
};
|
|
790
785
|
const linkOf = (server) => ({
|
|
791
786
|
live: () => liveOf(server),
|
|
@@ -984,7 +979,6 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
984
979
|
const site = requestSite(h.client);
|
|
985
980
|
try {
|
|
986
981
|
const at = h.listing.open();
|
|
987
|
-
const cacheTools = h.openListing();
|
|
988
982
|
const listed = await listToolsLenient(h.client, undefined, echoOf(h.spec));
|
|
989
983
|
const answered = h.listing.answer(at, listed.tools, listed.incomplete !== undefined);
|
|
990
984
|
const mergedRaw = answered.view;
|
|
@@ -992,14 +986,13 @@ export async function materializeLegMcpTools(seat, ...[specs, principal, onElici
|
|
|
992
986
|
results.push({ server: h.name, prefix: prefixOf(h.name), status: "failed", toolCount: h.tools.length, added: [], removed: [], error: "a later listing of this server was opened and applied while this one was in the air — this one was discarded" });
|
|
993
987
|
continue;
|
|
994
988
|
}
|
|
995
|
-
const { serverTools, serverAxes, gates,
|
|
996
|
-
cacheTools(accepted, answered.kept);
|
|
989
|
+
const { serverTools, serverAxes, gates, definitions, dropped } = intakeListedTools({ tools: [...mergedRaw], unproven: answered.unproven }, h.spec, linkOf(h.name), echoOf(h.spec), outputSchemaValidatorOf(h.client), imageProcessor, mcpDisclosure, isServerRevoked, h.transportKind, seat, echoReadOf(h.spec));
|
|
997
990
|
const priorNames = h.tools.map((t) => t.name);
|
|
998
991
|
const newNames = serverTools.map((t) => t.name);
|
|
999
992
|
const added = newNames.filter((n) => !priorNames.includes(n));
|
|
1000
993
|
const removed = priorNames.filter((n) => !newNames.includes(n));
|
|
1001
994
|
h.tools = serverTools;
|
|
1002
|
-
h.
|
|
995
|
+
h.intakeAt = { at, gates, definitions };
|
|
1003
996
|
results.push({
|
|
1004
997
|
server: h.name,
|
|
1005
998
|
prefix: prefixOf(h.name),
|
|
@@ -1220,13 +1213,13 @@ async function readDirViaExtension(rs, uri, signal, timeoutMs, watchdog) {
|
|
|
1220
1213
|
page = await rs.client.request({ method: "resources/directory/read", params: { uri, ...(cursor !== undefined ? { cursor } : {}) } }, ListResourcesResultSchema, { signal: watchdog.combinedSignal, timeout: timeoutMs });
|
|
1221
1214
|
}
|
|
1222
1215
|
catch (err) {
|
|
1223
|
-
if (err instanceof
|
|
1216
|
+
if (err instanceof ProtocolError && err.code === ProtocolErrorCode.InvalidParams) {
|
|
1224
1217
|
if (pages > 0)
|
|
1225
1218
|
return { kind: "ok", resources, cursorInvalid: true };
|
|
1226
|
-
const detail = remoteErrorText(err, rs.declared
|
|
1219
|
+
const detail = remoteErrorText(err, rs.declared);
|
|
1227
1220
|
return { kind: classifyDirReadInvalidParams(detail), detail };
|
|
1228
1221
|
}
|
|
1229
|
-
if (err instanceof
|
|
1222
|
+
if (err instanceof ProtocolError && err.code === ProtocolErrorCode.MethodNotFound)
|
|
1230
1223
|
return { kind: "unsupported" };
|
|
1231
1224
|
if (pages > 0 && !signal?.aborted) {
|
|
1232
1225
|
return { kind: "ok", resources, incomplete: remoteErrorText(err, rs.declared) };
|
|
@@ -1316,7 +1309,7 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1316
1309
|
try {
|
|
1317
1310
|
const walk = await walkMcpListPages(async (cursor, remainingMs) => {
|
|
1318
1311
|
const page = await rs.client
|
|
1319
|
-
.
|
|
1312
|
+
.request(resourcesListRequest(cursor), { signal: watchdog.combinedSignal, timeout: remainingMs })
|
|
1320
1313
|
.catch((err) => {
|
|
1321
1314
|
throw watchdog.idleSignal.reason === IDLE_WATCHDOG_ABORT_REASON ? new Error(idleWatchdogTripText(idleMs)) : err;
|
|
1322
1315
|
});
|
|
@@ -1398,7 +1391,7 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1398
1391
|
let res;
|
|
1399
1392
|
try {
|
|
1400
1393
|
res = await rs.client
|
|
1401
|
-
.
|
|
1394
|
+
.request({ method: "resources/read", params: rs.readParams(uri) }, { signal: watchdog.combinedSignal, timeout: timeoutMs })
|
|
1402
1395
|
.catch((err) => rethrowHonestMcpError(err, { server, declared: rs.declared, what, timeoutMs, writeEffect: false, signal, attributeServer: true, site, idle: { signal: watchdog.idleSignal, idleMs }, liveness: rs.health }));
|
|
1403
1396
|
rs.health.observe?.("completed");
|
|
1404
1397
|
}
|
|
@@ -1487,7 +1480,7 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1487
1480
|
}
|
|
1488
1481
|
const walk = await walkMcpListPages(async (cursor, remainingMs) => {
|
|
1489
1482
|
const page = await rs.client
|
|
1490
|
-
.
|
|
1483
|
+
.request(resourcesListRequest(cursor), { signal: watchdog.combinedSignal, timeout: remainingMs })
|
|
1491
1484
|
.catch((err) => rethrowHonestMcpError(err, { server, declared: rs.declared, what, timeoutMs: remainingMs, writeEffect: false, signal, attributeServer: true, site, idle: { signal: watchdog.idleSignal, idleMs }, liveness: rs.health }));
|
|
1492
1485
|
rs.health.observe?.("completed");
|
|
1493
1486
|
return { items: page.resources, ...(page.nextCursor !== undefined ? { nextCursor: page.nextCursor } : {}) };
|
|
@@ -1507,60 +1500,62 @@ function buildResourceTools(resourceServers, isServerRevoked = () => false) {
|
|
|
1507
1500
|
withContentOrigin(t, "external");
|
|
1508
1501
|
return { tools, axes };
|
|
1509
1502
|
}
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1503
|
+
const OUTPUT_SCHEMA_VALIDATORS = new WeakMap();
|
|
1504
|
+
function outputSchemaValidatorOf(client) {
|
|
1505
|
+
const validator = OUTPUT_SCHEMA_VALIDATORS.get(client);
|
|
1506
|
+
if (validator === undefined)
|
|
1507
|
+
throw new Error("internal: an MCP client this module did not dial has no recorded schema validator");
|
|
1508
|
+
return validator;
|
|
1509
|
+
}
|
|
1510
|
+
function toolDefinitionOf(t, validator) {
|
|
1511
|
+
const tool = { ...t, inputSchema: t.inputSchema };
|
|
1512
|
+
if (!t.outputSchema)
|
|
1513
|
+
return { tool };
|
|
1514
1514
|
try {
|
|
1515
|
-
|
|
1515
|
+
validator.getValidator(t.outputSchema);
|
|
1516
|
+
return { tool };
|
|
1516
1517
|
}
|
|
1517
1518
|
catch {
|
|
1519
|
+
return { tool, outputSchemaUncompilable: true };
|
|
1518
1520
|
}
|
|
1519
1521
|
}
|
|
1520
|
-
const
|
|
1521
|
-
|
|
1522
|
-
if (typeof data !== "object" || data === null)
|
|
1523
|
-
return { success: false, error: new Error("tools/list result is not an object") };
|
|
1524
|
-
const rawTools = data.tools;
|
|
1525
|
-
if (!Array.isArray(rawTools))
|
|
1526
|
-
return { success: false, error: new Error("tools/list result.tools is not an array") };
|
|
1527
|
-
const tools = [];
|
|
1528
|
-
for (const raw of rawTools) {
|
|
1529
|
-
if (typeof raw !== "object" || raw === null || typeof raw.name !== "string") {
|
|
1530
|
-
return { success: false, error: new Error("a tools/list entry is missing a string name") };
|
|
1531
|
-
}
|
|
1532
|
-
const t = raw;
|
|
1533
|
-
tools.push({
|
|
1534
|
-
name: t.name,
|
|
1535
|
-
...(typeof t.description === "string" ? { description: t.description } : {}),
|
|
1536
|
-
inputSchema: t.inputSchema,
|
|
1537
|
-
...(t.annotations !== undefined ? { annotations: t.annotations } : {}),
|
|
1538
|
-
...(t._meta !== undefined ? { _meta: t._meta } : {}),
|
|
1539
|
-
...(t.outputSchema !== undefined ? { outputSchema: t.outputSchema } : {}),
|
|
1540
|
-
...(t.execution !== undefined ? { execution: t.execution } : {}),
|
|
1541
|
-
});
|
|
1542
|
-
}
|
|
1543
|
-
const nextCursor = data.nextCursor;
|
|
1544
|
-
const cursorInvalid = nextCursor !== undefined && nextCursor !== null && typeof nextCursor !== "string";
|
|
1545
|
-
return { success: true, data: { tools, ...(typeof nextCursor === "string" ? { nextCursor } : {}), ...(cursorInvalid ? { cursorInvalid: true } : {}) } };
|
|
1546
|
-
},
|
|
1522
|
+
const LENIENT_LIST_TOOLS_RESULT_SCHEMA = {
|
|
1523
|
+
"~standard": { version: 1, vendor: "sema-core", validate: parseLenientToolsPage },
|
|
1547
1524
|
};
|
|
1548
|
-
|
|
1549
|
-
if (typeof data !== "object" || data === null
|
|
1550
|
-
return
|
|
1525
|
+
function parseLenientToolsPage(data) {
|
|
1526
|
+
if (typeof data !== "object" || data === null)
|
|
1527
|
+
return { issues: [{ message: "tools/list result is not an object" }] };
|
|
1528
|
+
const rawTools = data.tools;
|
|
1529
|
+
if (!Array.isArray(rawTools))
|
|
1530
|
+
return { issues: [{ message: "tools/list result.tools is not an array" }] };
|
|
1531
|
+
const tools = [];
|
|
1532
|
+
for (const raw of rawTools) {
|
|
1533
|
+
if (typeof raw !== "object" || raw === null || typeof raw.name !== "string") {
|
|
1534
|
+
return { issues: [{ message: "a tools/list entry is missing a string name" }] };
|
|
1535
|
+
}
|
|
1536
|
+
const t = raw;
|
|
1537
|
+
tools.push({
|
|
1538
|
+
name: t.name,
|
|
1539
|
+
...(typeof t.description === "string" ? { description: t.description } : {}),
|
|
1540
|
+
inputSchema: t.inputSchema,
|
|
1541
|
+
...(t.annotations !== undefined ? { annotations: t.annotations } : {}),
|
|
1542
|
+
...(t._meta !== undefined ? { _meta: t._meta } : {}),
|
|
1543
|
+
...(t.outputSchema !== undefined ? { outputSchema: t.outputSchema } : {}),
|
|
1544
|
+
...(t.execution !== undefined ? { execution: t.execution } : {}),
|
|
1545
|
+
});
|
|
1551
1546
|
}
|
|
1552
|
-
const
|
|
1553
|
-
const
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1547
|
+
const nextCursor = data.nextCursor;
|
|
1548
|
+
const cursorInvalid = nextCursor !== undefined && nextCursor !== null && typeof nextCursor !== "string";
|
|
1549
|
+
return { value: { tools, ...(typeof nextCursor === "string" ? { nextCursor } : {}), ...(cursorInvalid ? { cursorInvalid: true } : {}) } };
|
|
1550
|
+
}
|
|
1551
|
+
function resourcesListRequest(cursor) {
|
|
1552
|
+
return cursor === undefined ? { method: "resources/list" } : { method: "resources/list", params: { cursor } };
|
|
1557
1553
|
}
|
|
1558
|
-
const LENIENT_CALL_TOOL_RESULT_SCHEMA = { safeParse: parseCallToolResultLenient };
|
|
1559
1554
|
async function listToolsLenient(client, options, declared) {
|
|
1560
1555
|
if (!client.getServerCapabilities()?.tools)
|
|
1561
1556
|
return { tools: [], toolsCapabilityAbsent: true };
|
|
1562
1557
|
const walk = await walkMcpListPages(async (cursor, remainingMs) => {
|
|
1563
|
-
const page = await client.request({ method: "tools/list", params: cursor === undefined ? {} : { cursor } },
|
|
1558
|
+
const page = await client.request({ method: "tools/list", params: cursor === undefined ? {} : { cursor } }, LENIENT_LIST_TOOLS_RESULT_SCHEMA, { ...options, timeout: remainingMs });
|
|
1564
1559
|
return {
|
|
1565
1560
|
items: page.tools,
|
|
1566
1561
|
...(page.nextCursor !== undefined ? { nextCursor: page.nextCursor } : {}),
|
|
@@ -1584,11 +1579,18 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1584
1579
|
const announce = {};
|
|
1585
1580
|
const startupMs = mcpStartupTimeoutMs(spec);
|
|
1586
1581
|
const startupOpts = startupMs !== undefined ? { timeout: startupMs } : undefined;
|
|
1582
|
+
const answersOneLeg = elicitOn || transportKind === "host";
|
|
1583
|
+
const poolKey = pool !== undefined && !answersOneLeg ? McpConnectionPool.keyOf(spec, principal, transportKind, startupMs) : undefined;
|
|
1587
1584
|
const dialClient = async (stop = dialOpts?.signal) => {
|
|
1588
1585
|
stop?.throwIfAborted();
|
|
1589
|
-
const
|
|
1586
|
+
const outputSchemaValidator = new AjvJsonSchemaValidator();
|
|
1587
|
+
const client = new Client({ name: `sema-core/${spec.name}`, version: "0.1.0" }, {
|
|
1588
|
+
capabilities: elicitOn ? { elicitation: { form: {} } } : {},
|
|
1589
|
+
jsonSchemaValidator: outputSchemaValidator,
|
|
1590
|
+
});
|
|
1591
|
+
OUTPUT_SCHEMA_VALIDATORS.set(client, outputSchemaValidator);
|
|
1590
1592
|
if (elicitOn) {
|
|
1591
|
-
client.setRequestHandler(
|
|
1593
|
+
client.setRequestHandler("elicitation/create", async (request, ctx) => {
|
|
1592
1594
|
health.pendingElicitations++;
|
|
1593
1595
|
try {
|
|
1594
1596
|
const p = request.params;
|
|
@@ -1598,7 +1600,7 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1598
1600
|
...(p.requestedSchema !== undefined ? { requestedSchema: p.requestedSchema } : {}),
|
|
1599
1601
|
...(principal !== undefined ? { principal } : {}),
|
|
1600
1602
|
};
|
|
1601
|
-
const answer = await onElicit(req,
|
|
1603
|
+
const answer = await onElicit(req, ctx.mcpReq.signal);
|
|
1602
1604
|
return answer.action === "accept" ? { action: "accept", content: answer.content ?? {} } : { action: answer.action };
|
|
1603
1605
|
}
|
|
1604
1606
|
finally {
|
|
@@ -1608,11 +1610,12 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1608
1610
|
});
|
|
1609
1611
|
}
|
|
1610
1612
|
const pieces = transportKind === "stdio" ? await dialOpts.carrier.next(stop) : undefined;
|
|
1611
|
-
const
|
|
1613
|
+
const pipe = transportKind === "host" ? await openHostPipe(dialOpts.hostSeat, spec.name, stop) : undefined;
|
|
1614
|
+
const transport = buildTransport(spec, principal, transportKind, dialOpts.carrier, pieces, pipe);
|
|
1612
1615
|
const hangUp = () => void client.close().catch(() => undefined);
|
|
1613
1616
|
stop?.addEventListener("abort", hangUp, { once: true });
|
|
1614
1617
|
try {
|
|
1615
|
-
await client.connect(transport, startupOpts);
|
|
1618
|
+
await settledBefore(client.connect(transport, startupOpts), pipe !== undefined ? stop : undefined);
|
|
1616
1619
|
}
|
|
1617
1620
|
catch (err) {
|
|
1618
1621
|
await client.close().catch(() => undefined);
|
|
@@ -1624,16 +1627,18 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1624
1627
|
stop?.removeEventListener("abort", hangUp);
|
|
1625
1628
|
}
|
|
1626
1629
|
recordCarrier(client, dialOpts.carrier);
|
|
1630
|
+
if (poolKey !== undefined)
|
|
1631
|
+
recordEngineDial(client, poolKey);
|
|
1627
1632
|
return client;
|
|
1628
1633
|
};
|
|
1629
|
-
const
|
|
1630
|
-
const
|
|
1631
|
-
const
|
|
1634
|
+
const mount = transportKind === "host" ? hostMount(startupMs, dialOpts.signal) : undefined;
|
|
1635
|
+
const mountStop = mount?.signal ?? dialOpts?.signal;
|
|
1636
|
+
const lease = pool !== undefined && poolKey !== undefined ? await pool.acquire(poolKey, dialClient, dialOpts) : undefined;
|
|
1637
|
+
const client = lease !== undefined ? lease.client : await dialClient(mountStop).catch((err) => {
|
|
1638
|
+
mount?.end();
|
|
1639
|
+
throw err;
|
|
1640
|
+
});
|
|
1632
1641
|
const close = () => (lease !== undefined ? lease.release() : client.close());
|
|
1633
|
-
const openListing = () => {
|
|
1634
|
-
const write = lease?.openListing();
|
|
1635
|
-
return (tools, retained) => (write !== undefined ? write(tools, (all) => cacheMcpToolMetadata(client, all), retained) : cacheMcpToolMetadata(client, tools));
|
|
1636
|
-
};
|
|
1637
1642
|
try {
|
|
1638
1643
|
const onClosed = () => {
|
|
1639
1644
|
health.dead = true;
|
|
@@ -1645,13 +1650,11 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1645
1650
|
client.onclose = onClosed;
|
|
1646
1651
|
const listing = lease?.listing ?? new ConnectionListing();
|
|
1647
1652
|
const at = listing.open();
|
|
1648
|
-
const cacheTools = openListing();
|
|
1649
1653
|
const declared = (carrierOf(client) ?? dialOpts.carrier).sent;
|
|
1650
1654
|
const echo = carrierEcho(carrierOf(client) ?? dialOpts.carrier, dialOpts.announceEcho);
|
|
1651
|
-
const listed = await underStartupBound(startupMs,
|
|
1655
|
+
const listed = await underStartupBound(startupMs, mountStop, (options) => listToolsLenient(client, options, declared)).finally(() => mount?.end());
|
|
1652
1656
|
const answered = listing.answer(at, listed.tools, listed.incomplete !== undefined, dialOpts.carried);
|
|
1653
|
-
const { serverTools, serverAxes, gates, dropped, advisories
|
|
1654
|
-
cacheTools(accepted, answered.kept);
|
|
1657
|
+
const { serverTools, serverAxes, gates, definitions, dropped, advisories } = intakeListedTools({ tools: [...answered.view], unproven: answered.unproven }, spec, dialOpts.link, declared, outputSchemaValidatorOf(client), imageProcessor, reminderDisclosure, isServerRevoked, transportKind, seat, echo);
|
|
1655
1658
|
const caps = client.getServerCapabilities();
|
|
1656
1659
|
const resourceInfo = caps?.resources
|
|
1657
1660
|
? {
|
|
@@ -1675,13 +1678,12 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1675
1678
|
status,
|
|
1676
1679
|
client,
|
|
1677
1680
|
close,
|
|
1678
|
-
openListing,
|
|
1679
1681
|
health,
|
|
1680
1682
|
announce,
|
|
1681
1683
|
tools: serverTools,
|
|
1682
1684
|
axes: serverAxes,
|
|
1683
1685
|
listing,
|
|
1684
|
-
|
|
1686
|
+
intakeAt: { at, gates, definitions },
|
|
1685
1687
|
dropped,
|
|
1686
1688
|
schemaAdvisories: advisories,
|
|
1687
1689
|
...(listed.toolsCapabilityAbsent === true ? { toolsCapabilityAbsent: true } : {}),
|
|
@@ -1698,13 +1700,13 @@ async function connectServer(spec, principal, onElicit, imageProcessor, reminder
|
|
|
1698
1700
|
throw err;
|
|
1699
1701
|
}
|
|
1700
1702
|
}
|
|
1701
|
-
function intakeListedTools(listed, spec, link, declared, imageProcessor, reminderDisclosure, isServerRevoked, transportKind, seat, echo = NO_CREDENTIAL_ECHO) {
|
|
1703
|
+
function intakeListedTools(listed, spec, link, declared, validator, imageProcessor, reminderDisclosure, isServerRevoked, transportKind, seat, echo = NO_CREDENTIAL_ECHO) {
|
|
1702
1704
|
const declaredContentOrigin = spec.contentOrigin;
|
|
1703
1705
|
const serverTools = [];
|
|
1704
1706
|
const serverAxes = [];
|
|
1705
1707
|
const gates = new Map();
|
|
1706
1708
|
const dropped = [];
|
|
1707
|
-
const
|
|
1709
|
+
const definitions = new Map();
|
|
1708
1710
|
const advisories = [];
|
|
1709
1711
|
const claimToolName = createToolNameClaims(MCP_NAMESPACE, spec.name);
|
|
1710
1712
|
for (const t of listed.tools) {
|
|
@@ -1802,11 +1804,13 @@ function intakeListedTools(listed, spec, link, declared, imageProcessor, reminde
|
|
|
1802
1804
|
const callMeta = mcpCallMeta(toolCallId, seat?.of(toolCallId), spec.sessionMetaKey, seat?.sessionId);
|
|
1803
1805
|
let answeredWith = declared;
|
|
1804
1806
|
const attempt = async (conn, resent, last) => {
|
|
1807
|
+
const definition = conn.definitions().get(namespacedName);
|
|
1805
1808
|
const site = requestSite(conn.client);
|
|
1806
1809
|
const watchdog = armMcpIdleWatchdog(conn.health, idleMs, signal);
|
|
1807
1810
|
try {
|
|
1808
1811
|
const res = await conn.client
|
|
1809
|
-
.callTool({ name: remoteName, arguments: (params ?? {}), ...(callMeta !== undefined ? { _meta: callMeta } : {}) },
|
|
1812
|
+
.callTool({ name: remoteName, arguments: (params ?? {}), ...(callMeta !== undefined ? { _meta: callMeta } : {}) }, {
|
|
1813
|
+
toolDefinition: definition.tool,
|
|
1810
1814
|
signal: watchdog.combinedSignal,
|
|
1811
1815
|
timeout: timeoutMs,
|
|
1812
1816
|
resetTimeoutOnProgress: true,
|
|
@@ -1913,9 +1917,9 @@ function intakeListedTools(listed, spec, link, declared, imageProcessor, reminde
|
|
|
1913
1917
|
},
|
|
1914
1918
|
};
|
|
1915
1919
|
serverTools.push(declaredContentOrigin !== undefined ? withContentOrigin(mounted, declaredContentOrigin) : mounted);
|
|
1916
|
-
|
|
1920
|
+
definitions.set(namespacedName, toolDefinitionOf(t, validator));
|
|
1917
1921
|
}
|
|
1918
|
-
return { serverTools, serverAxes, gates, dropped, advisories
|
|
1922
|
+
return { serverTools, serverAxes, gates, definitions, dropped, advisories };
|
|
1919
1923
|
}
|
|
1920
1924
|
function asServerWarning(spec, err, declared) {
|
|
1921
1925
|
const warning = new Error(`mcp: server "${spec.name}" failed to connect — skipped (${namedMcpFailureText(err, declared)})`, { cause: sanitizedCause(err, declared) });
|