stitchkit 0.93.0 → 0.94.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +198 -0
- package/README.md +5 -2
- package/dist/agent-runtime/children-control.d.ts +6 -0
- package/dist/agent-runtime/children-control.d.ts.map +1 -0
- package/dist/agent-runtime/children-spawn.d.ts +6 -0
- package/dist/agent-runtime/children-spawn.d.ts.map +1 -0
- package/dist/agent-runtime/children-state.d.ts +46 -0
- package/dist/agent-runtime/children-state.d.ts.map +1 -0
- package/dist/agent-runtime/children-usage.d.ts +8 -0
- package/dist/agent-runtime/children-usage.d.ts.map +1 -0
- package/dist/agent-runtime/children.d.ts +11 -14
- package/dist/agent-runtime/children.d.ts.map +1 -1
- package/dist/agent-runtime/coding-shell-process.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +2 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/contained-darwin.d.ts +38 -0
- package/dist/agent-runtime/contained-darwin.d.ts.map +1 -0
- package/dist/agent-runtime/contained-files.d.ts +11 -26
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/contained-scan.d.ts +21 -0
- package/dist/agent-runtime/contained-scan.d.ts.map +1 -0
- package/dist/agent-runtime/contained-write.d.ts +9 -0
- package/dist/agent-runtime/contained-write.d.ts.map +1 -0
- package/dist/agent-runtime/deferred-tool-types.d.ts +4 -3
- package/dist/agent-runtime/deferred-tool-types.d.ts.map +1 -1
- package/dist/agent-runtime/events.d.ts +1 -1
- package/dist/agent-runtime/events.d.ts.map +1 -1
- package/dist/agent-runtime/harness-control.d.ts +0 -1
- package/dist/agent-runtime/harness-control.d.ts.map +1 -1
- package/dist/agent-runtime/harness.d.ts +0 -5
- package/dist/agent-runtime/harness.d.ts.map +1 -1
- package/dist/agent-runtime/managed-tools.d.ts +3 -2
- package/dist/agent-runtime/managed-tools.d.ts.map +1 -1
- package/dist/agent-runtime/observability.d.ts +1 -1
- package/dist/agent-runtime/observability.d.ts.map +1 -1
- package/dist/agent-runtime/openrouter.d.ts +29 -0
- package/dist/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/agent-runtime/projections.d.ts +1 -1
- package/dist/agent-runtime/projections.d.ts.map +1 -1
- package/dist/agent-runtime/run-acquisition.d.ts +17 -0
- package/dist/agent-runtime/run-acquisition.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution-state.d.ts +133 -0
- package/dist/agent-runtime/run-execution-state.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution.d.ts +17 -33
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/run-failure.d.ts +18 -0
- package/dist/agent-runtime/run-failure.d.ts.map +1 -0
- package/dist/agent-runtime/run-model-attempts.d.ts +6 -0
- package/dist/agent-runtime/run-model-attempts.d.ts.map +1 -0
- package/dist/agent-runtime/run-prompt-history.d.ts +58 -0
- package/dist/agent-runtime/run-prompt-history.d.ts.map +1 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts +26 -0
- package/dist/agent-runtime/run-provider-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/run-stream-parts.d.ts +17 -0
- package/dist/agent-runtime/run-stream-parts.d.ts.map +1 -0
- package/dist/agent-runtime/run-terminal.d.ts +11 -0
- package/dist/agent-runtime/run-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts +22 -0
- package/dist/agent-runtime/run-turn-preparation.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts +29 -0
- package/dist/agent-runtime/runtime-admission-gate.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-control.d.ts +9 -0
- package/dist/agent-runtime/runtime-control.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-recovery.d.ts +10 -0
- package/dist/agent-runtime/runtime-recovery.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-state.d.ts +36 -0
- package/dist/agent-runtime/runtime-state.d.ts.map +1 -0
- package/dist/agent-runtime/runtime-submit.d.ts +5 -0
- package/dist/agent-runtime/runtime-submit.d.ts.map +1 -0
- package/dist/agent-runtime/runtime.d.ts +10 -5
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schedule-records.d.ts +34 -0
- package/dist/agent-runtime/schedule-records.d.ts.map +1 -0
- package/dist/agent-runtime/schedules.d.ts +34 -0
- package/dist/agent-runtime/schedules.d.ts.map +1 -1
- package/dist/agent-runtime/sqlite-bun.d.ts +12 -0
- package/dist/agent-runtime/sqlite-bun.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-events.d.ts +5 -0
- package/dist/agent-runtime/sqlite-events.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-history.d.ts +7 -0
- package/dist/agent-runtime/sqlite-history.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts +7 -0
- package/dist/agent-runtime/sqlite-ledger.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-node.d.ts +12 -0
- package/dist/agent-runtime/sqlite-node.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-reads.d.ts +14 -0
- package/dist/agent-runtime/sqlite-reads.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-rows.d.ts +178 -0
- package/dist/agent-runtime/sqlite-rows.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-schema.d.ts +7 -0
- package/dist/agent-runtime/sqlite-schema.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts +25 -0
- package/dist/agent-runtime/sqlite-transactions.d.ts.map +1 -0
- package/dist/agent-runtime/sqlite.d.ts +10 -6
- package/dist/agent-runtime/sqlite.d.ts.map +1 -1
- package/dist/agent-runtime/store-archive.d.ts +16 -0
- package/dist/agent-runtime/store-archive.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts +434 -0
- package/dist/agent-runtime/store-conformance-lifecycle.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts +18 -0
- package/dist/agent-runtime/store-conformance-ordering.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-support.d.ts +130 -0
- package/dist/agent-runtime/store-conformance-support.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts +12 -0
- package/dist/agent-runtime/store-conformance-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-conformance.d.ts +40 -0
- package/dist/agent-runtime/store-conformance.d.ts.map +1 -0
- package/dist/agent-runtime/store-create.d.ts +11 -0
- package/dist/agent-runtime/store-create.d.ts.map +1 -0
- package/dist/agent-runtime/store-driver-contract.d.ts +814 -0
- package/dist/agent-runtime/store-driver-contract.d.ts.map +1 -0
- package/dist/agent-runtime/store-events.d.ts +7 -89
- package/dist/agent-runtime/store-events.d.ts.map +1 -1
- package/dist/agent-runtime/store-memory.d.ts +4 -0
- package/dist/agent-runtime/store-memory.d.ts.map +1 -0
- package/dist/agent-runtime/store-mutate.d.ts +13 -0
- package/dist/agent-runtime/store-mutate.d.ts.map +1 -0
- package/dist/agent-runtime/store-purge.d.ts +1 -1
- package/dist/agent-runtime/store-purge.d.ts.map +1 -1
- package/dist/agent-runtime/store-reads.d.ts +29 -0
- package/dist/agent-runtime/store-reads.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-history.d.ts +10 -0
- package/dist/agent-runtime/store-reduce-history.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-run.d.ts +14 -0
- package/dist/agent-runtime/store-reduce-run.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts +76 -0
- package/dist/agent-runtime/store-reduce-shared.d.ts.map +1 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts +6 -0
- package/dist/agent-runtime/store-reduce-terminal.d.ts.map +1 -0
- package/dist/agent-runtime/store-reducer.d.ts +24 -0
- package/dist/agent-runtime/store-reducer.d.ts.map +1 -0
- package/dist/agent-runtime/store-snapshot.d.ts +19 -0
- package/dist/agent-runtime/store-snapshot.d.ts.map +1 -0
- package/dist/agent-runtime/store.d.ts +1 -1
- package/dist/agent-runtime/store.d.ts.map +1 -1
- package/dist/application/admission-rate.d.ts +21 -0
- package/dist/application/admission-rate.d.ts.map +1 -0
- package/dist/application/admission-run.d.ts +8 -0
- package/dist/application/admission-run.d.ts.map +1 -0
- package/dist/application/admission.d.ts +1 -1
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +9 -34
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/events.d.ts +1 -1
- package/dist/application/events.d.ts.map +1 -1
- package/dist/application/file-state-store.d.ts +23 -0
- package/dist/application/file-state-store.d.ts.map +1 -0
- package/dist/application/health.d.ts +1 -1
- package/dist/application/health.d.ts.map +1 -1
- package/dist/application/kernel-admission.d.ts +8 -0
- package/dist/application/kernel-admission.d.ts.map +1 -0
- package/dist/application/kernel-contract.d.ts +142 -0
- package/dist/application/kernel-contract.d.ts.map +1 -0
- package/dist/application/kernel-resource-context.d.ts +24 -0
- package/dist/application/kernel-resource-context.d.ts.map +1 -0
- package/dist/application/kernel-restart.d.ts +5 -0
- package/dist/application/kernel-restart.d.ts.map +1 -0
- package/dist/application/kernel-rollback.d.ts +4 -0
- package/dist/application/kernel-rollback.d.ts.map +1 -0
- package/dist/application/kernel-shutdown.d.ts +6 -0
- package/dist/application/kernel-shutdown.d.ts.map +1 -0
- package/dist/application/kernel-start.d.ts +20 -0
- package/dist/application/kernel-start.d.ts.map +1 -0
- package/dist/application/kernel-state.d.ts +116 -0
- package/dist/application/kernel-state.d.ts.map +1 -0
- package/dist/application/kernel.d.ts +9 -140
- package/dist/application/kernel.d.ts.map +1 -1
- package/dist/application/latest-sink.d.ts +1 -1
- package/dist/application/latest-sink.d.ts.map +1 -1
- package/dist/application/notification-outbox.d.ts.map +1 -1
- package/dist/application/opentelemetry.d.ts +1 -1
- package/dist/application/opentelemetry.d.ts.map +1 -1
- package/dist/application/schedule.d.ts +0 -1
- package/dist/application/schedule.d.ts.map +1 -1
- package/dist/application/watch-hub-core.d.ts +122 -0
- package/dist/application/watch-hub-core.d.ts.map +1 -0
- package/dist/application/watch-hub.d.ts +3 -3
- package/dist/application/watch-hub.d.ts.map +1 -1
- package/dist/browser/client-executors.d.ts +14 -0
- package/dist/browser/client-executors.d.ts.map +1 -0
- package/dist/browser/client-multipart.d.ts +1 -1
- package/dist/browser/client-multipart.d.ts.map +1 -1
- package/dist/browser/client-url.d.ts +1 -1
- package/dist/browser/client-url.d.ts.map +1 -1
- package/dist/browser/client.d.ts +3 -2
- package/dist/browser/client.d.ts.map +1 -1
- package/dist/browser/contract-stream.d.ts +1 -1
- package/dist/browser/contract-stream.d.ts.map +1 -1
- package/dist/browser/http-fetch.d.ts +22 -0
- package/dist/browser/http-fetch.d.ts.map +1 -0
- package/dist/browser/http.d.ts +2 -4
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/browser/live-state-core.d.ts +63 -0
- package/dist/browser/live-state-core.d.ts.map +1 -0
- package/dist/browser/live-state.d.ts.map +1 -1
- package/dist/browser/realtime-client.d.ts +26 -0
- package/dist/browser/realtime-client.d.ts.map +1 -0
- package/dist/browser/resumable.d.ts +1 -28
- package/dist/browser/resumable.d.ts.map +1 -1
- package/dist/browser/retained.d.ts.map +1 -0
- package/dist/browser/socket-io-connection.d.ts +82 -0
- package/dist/browser/socket-io-connection.d.ts.map +1 -0
- package/dist/browser/socket-io-peer.d.ts +20 -0
- package/dist/browser/socket-io-peer.d.ts.map +1 -0
- package/dist/browser/socket-io-trace.d.ts +31 -0
- package/dist/browser/socket-io-trace.d.ts.map +1 -0
- package/dist/browser/socket-io.d.ts +24 -18
- package/dist/browser/socket-io.d.ts.map +1 -1
- package/dist/browser/stream.d.ts +14 -2
- package/dist/browser/stream.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +134 -0
- package/dist/contract/client-types.d.ts.map +1 -0
- package/dist/contract/define-validation.d.ts +30 -0
- package/dist/contract/define-validation.d.ts.map +1 -0
- package/dist/contract/define.d.ts +47 -394
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/normalize.d.ts +56 -0
- package/dist/contract/normalize.d.ts.map +1 -0
- package/dist/contract/runtime-context.d.ts +131 -0
- package/dist/contract/runtime-context.d.ts.map +1 -0
- package/dist/contract/tool-options.d.ts +105 -0
- package/dist/contract/tool-options.d.ts.map +1 -0
- package/dist/contract/tool-view.d.ts +148 -0
- package/dist/contract/tool-view.d.ts.map +1 -0
- package/dist/declaration/declaration.d.ts.map +1 -0
- package/dist/durability/contract.d.ts +259 -0
- package/dist/durability/contract.d.ts.map +1 -0
- package/dist/durability/effect.d.ts +24 -0
- package/dist/durability/effect.d.ts.map +1 -0
- package/dist/durability/engine.d.ts +14 -0
- package/dist/durability/engine.d.ts.map +1 -0
- package/dist/durability/events.d.ts +103 -0
- package/dist/durability/events.d.ts.map +1 -0
- package/dist/durability/json.d.ts +3 -0
- package/dist/durability/json.d.ts.map +1 -0
- package/dist/durability/ledger.d.ts +27 -0
- package/dist/durability/ledger.d.ts.map +1 -0
- package/dist/durability/parks.d.ts +22 -0
- package/dist/durability/parks.d.ts.map +1 -0
- package/dist/durability/scheduler.d.ts +30 -0
- package/dist/durability/scheduler.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts +5 -0
- package/dist/entrypoints/agent-runtime/browser.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/browser.js +124 -0
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/coding-tools.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/coding-tools.js +22 -0
- package/dist/entrypoints/agent-runtime/harness.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/harness.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/harness.js +739 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/openrouter.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/openrouter.js +270 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts +5 -0
- package/dist/entrypoints/agent-runtime/sandbox.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sandbox.js +797 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +44 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts +2 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/sqlite/node.js +46 -0
- package/dist/entrypoints/agent-runtime/testing.d.ts +4 -0
- package/dist/entrypoints/agent-runtime/testing.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/testing.js +1116 -0
- package/dist/entrypoints/agent-runtime.d.ts +42 -0
- package/dist/entrypoints/agent-runtime.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime.js +2670 -0
- package/dist/entrypoints/application/diagnostic-journal.d.ts +21 -0
- package/dist/entrypoints/application/diagnostic-journal.d.ts.map +1 -0
- package/dist/entrypoints/application/diagnostic-journal.js +492 -0
- package/dist/entrypoints/application/grammy.d.ts +2 -0
- package/dist/entrypoints/application/grammy.d.ts.map +1 -0
- package/dist/entrypoints/application/grammy.js +169 -0
- package/dist/entrypoints/application/opentelemetry.d.ts +2 -0
- package/dist/entrypoints/application/opentelemetry.d.ts.map +1 -0
- package/dist/entrypoints/application/opentelemetry.js +250 -0
- package/dist/entrypoints/application/schemas.d.ts +15 -0
- package/dist/entrypoints/application/schemas.d.ts.map +1 -0
- package/dist/entrypoints/application/schemas.js +27 -0
- package/dist/entrypoints/application.d.ts +23 -0
- package/dist/entrypoints/application.d.ts.map +1 -0
- package/dist/entrypoints/application.js +2016 -0
- package/dist/entrypoints/bin/upgrade-cli.d.ts.map +1 -0
- package/dist/entrypoints/bin/upgrade-cli.js +177 -0
- package/dist/entrypoints/cli.d.ts +44 -0
- package/dist/entrypoints/cli.d.ts.map +1 -0
- package/dist/entrypoints/cli.js +773 -0
- package/dist/entrypoints/contract.d.ts +12 -0
- package/dist/entrypoints/contract.d.ts.map +1 -0
- package/dist/entrypoints/contract.js +64 -0
- package/dist/entrypoints/declaration.d.ts +2 -0
- package/dist/entrypoints/declaration.d.ts.map +1 -0
- package/dist/entrypoints/declaration.js +183 -0
- package/dist/entrypoints/files.d.ts +5 -0
- package/dist/entrypoints/files.d.ts.map +1 -0
- package/dist/entrypoints/files.js +111 -0
- package/dist/entrypoints/geo.d.ts +3 -0
- package/dist/entrypoints/geo.d.ts.map +1 -0
- package/dist/entrypoints/geo.js +245 -0
- package/dist/entrypoints/google.d.ts +2 -0
- package/dist/entrypoints/google.d.ts.map +1 -0
- package/dist/entrypoints/google.js +175 -0
- package/dist/entrypoints/index.d.ts +17 -0
- package/dist/entrypoints/index.d.ts.map +1 -0
- package/dist/entrypoints/index.js +764 -0
- package/dist/entrypoints/live.d.ts +19 -0
- package/dist/entrypoints/live.d.ts.map +1 -0
- package/dist/entrypoints/live.js +302 -0
- package/dist/entrypoints/node.d.ts +19 -0
- package/dist/entrypoints/node.d.ts.map +1 -0
- package/dist/entrypoints/node.js +308 -0
- package/dist/entrypoints/oauth.d.ts +2 -0
- package/dist/entrypoints/oauth.d.ts.map +1 -0
- package/dist/entrypoints/oauth.js +170 -0
- package/dist/entrypoints/observability.d.ts +19 -0
- package/dist/entrypoints/observability.d.ts.map +1 -0
- package/dist/entrypoints/observability.js +567 -0
- package/dist/entrypoints/primitives.d.ts +3 -0
- package/dist/entrypoints/primitives.d.ts.map +1 -0
- package/dist/entrypoints/primitives.js +749 -0
- package/dist/entrypoints/react.d.ts +5 -0
- package/dist/entrypoints/react.d.ts.map +1 -0
- package/dist/entrypoints/react.js +403 -0
- package/dist/entrypoints/release.d.ts +15 -0
- package/dist/entrypoints/release.d.ts.map +1 -0
- package/dist/entrypoints/release.js +196 -0
- package/dist/entrypoints/remote.d.ts +9 -0
- package/dist/entrypoints/remote.d.ts.map +1 -0
- package/dist/entrypoints/remote.js +66 -0
- package/dist/entrypoints/server.d.ts +39 -0
- package/dist/entrypoints/server.d.ts.map +1 -0
- package/dist/entrypoints/server.js +2009 -0
- package/dist/entrypoints/telegram.d.ts +3 -0
- package/dist/entrypoints/telegram.d.ts.map +1 -0
- package/dist/entrypoints/telegram.js +224 -0
- package/dist/entrypoints/testing.d.ts +10 -0
- package/dist/entrypoints/testing.d.ts.map +1 -0
- package/dist/entrypoints/testing.js +1377 -0
- package/dist/entrypoints/tools/connections.d.ts +19 -0
- package/dist/entrypoints/tools/connections.d.ts.map +1 -0
- package/dist/entrypoints/tools/connections.js +1110 -0
- package/dist/entrypoints/tools/contract.d.ts +29 -0
- package/dist/entrypoints/tools/contract.d.ts.map +1 -0
- package/dist/entrypoints/tools/contract.js +24 -0
- package/dist/entrypoints/tools/invoker.d.ts +9 -0
- package/dist/entrypoints/tools/invoker.d.ts.map +1 -0
- package/dist/entrypoints/tools/invoker.js +20 -0
- package/dist/entrypoints/tools.d.ts +54 -0
- package/dist/entrypoints/tools.d.ts.map +1 -0
- package/dist/entrypoints/tools.js +3009 -0
- package/dist/entrypoints/tracking/server.d.ts +15 -0
- package/dist/entrypoints/tracking/server.d.ts.map +1 -0
- package/dist/entrypoints/tracking.d.ts +24 -0
- package/dist/entrypoints/tracking.d.ts.map +1 -0
- package/dist/entrypoints/tracking.js +1140 -0
- package/dist/files/boundary.d.ts.map +1 -1
- package/dist/files/file-io.d.ts +14 -0
- package/dist/files/file-io.d.ts.map +1 -0
- package/dist/google/google.d.ts.map +1 -0
- package/dist/index-0b1ess5e.js +38 -0
- package/dist/index-1j8pm5t0.js +412 -0
- package/dist/index-1zbbzgfh.js +89 -0
- package/dist/index-2bxbyab0.js +47 -0
- package/dist/index-2gxzjvyr.js +266 -0
- package/dist/index-35mh5bhj.js +177 -0
- package/dist/index-48ffdxgk.js +6 -0
- package/dist/index-4gcnakhx.js +82 -0
- package/dist/index-55hkhm67.js +343 -0
- package/dist/index-79z7m7dt.js +675 -0
- package/dist/index-7f68ghdn.js +3618 -0
- package/dist/index-7p1f0vp2.js +154 -0
- package/dist/index-83bdg97s.js +16 -0
- package/dist/index-863ea9jb.js +154 -0
- package/dist/index-8p52kd5p.js +242 -0
- package/dist/index-d9pk3td4.js +326 -0
- package/dist/index-dce5wxcq.js +63 -0
- package/dist/index-e01r054k.js +105 -0
- package/dist/index-ensd0r74.js +595 -0
- package/dist/index-eqqvgdb3.js +46 -0
- package/dist/index-gxrt5h6v.js +341 -0
- package/dist/index-h6eeys1v.js +211 -0
- package/dist/index-ham5sz8m.js +734 -0
- package/dist/index-het2he5g.js +1387 -0
- package/dist/index-hffjpmq9.js +30 -0
- package/dist/index-hmp4800j.js +51 -0
- package/dist/index-k30h66yd.js +317 -0
- package/dist/index-k5hsfc3j.js +31 -0
- package/dist/index-khtgb21r.js +92 -0
- package/dist/index-m9zn6cpq.js +51 -0
- package/dist/index-ndddxtyx.js +324 -0
- package/dist/index-ngfhvfpd.js +30 -0
- package/dist/index-np4m8hd3.js +1205 -0
- package/dist/index-p3vsv1fb.js +3493 -0
- package/dist/index-p5r7qpdd.js +85 -0
- package/dist/index-p9e0w8hs.js +1084 -0
- package/dist/index-p9sh0xx4.js +64 -0
- package/dist/index-paz6sgdp.js +371 -0
- package/dist/index-px2gm2jp.js +448 -0
- package/dist/index-qwhynv6x.js +103 -0
- package/dist/index-s812ycat.js +65 -0
- package/dist/index-sp1tzwnb.js +281 -0
- package/dist/index-t9rhjr9f.js +2306 -0
- package/dist/index-v260df89.js +342 -0
- package/dist/index-w906953s.js +946 -0
- package/dist/index-wdkt63w3.js +214 -0
- package/dist/index-wqgjfstn.js +18 -0
- package/dist/index-wsm5w4ee.js +1023 -0
- package/dist/index-xw3s75nj.js +100 -0
- package/dist/index-yw4fzmdz.js +268 -0
- package/dist/index-zfrhfn82.js +85 -0
- package/dist/index-znfs20ss.js +98 -0
- package/dist/internal/atomic-file.d.ts +23 -2
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/backoff.d.ts +29 -0
- package/dist/internal/backoff.d.ts.map +1 -0
- package/dist/internal/canonical-json.d.ts +21 -11
- package/dist/internal/canonical-json.d.ts.map +1 -1
- package/dist/internal/channel.d.ts.map +1 -0
- package/dist/internal/exclusive-lock.d.ts +51 -0
- package/dist/internal/exclusive-lock.d.ts.map +1 -0
- package/dist/internal/logger.d.ts.map +1 -0
- package/dist/internal/process-identity.d.ts +47 -0
- package/dist/internal/process-identity.d.ts.map +1 -0
- package/dist/internal/request.d.ts.map +1 -0
- package/dist/internal/stable-digest.d.ts +0 -43
- package/dist/internal/stable-digest.d.ts.map +1 -1
- package/dist/internal/typed.d.ts +0 -8
- package/dist/internal/typed.d.ts.map +1 -1
- package/dist/internal/with-exclusive-lock.d.ts +67 -0
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
- package/dist/internal/zod-issues.d.ts +38 -0
- package/dist/internal/zod-issues.d.ts.map +1 -0
- package/dist/json-schema/dialect.d.ts +17 -0
- package/dist/json-schema/dialect.d.ts.map +1 -0
- package/dist/json-schema/json-schema.d.ts.map +1 -0
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/live/watch-delta.d.ts.map +1 -1
- package/dist/oauth/authorization-code.d.ts +57 -0
- package/dist/oauth/authorization-code.d.ts.map +1 -0
- package/dist/observability/audit.d.ts +3 -3
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/bounded-logger.d.ts +1 -1
- package/dist/observability/bounded-logger.d.ts.map +1 -1
- package/dist/observability/bounded-sink.d.ts +81 -0
- package/dist/observability/bounded-sink.d.ts.map +1 -0
- package/dist/observability/context.d.ts +1 -1
- package/dist/observability/context.d.ts.map +1 -1
- package/dist/observability/event.d.ts +2 -1
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/observability/work.d.ts +1 -1
- package/dist/observability/work.d.ts.map +1 -1
- package/dist/primitives/audit.d.ts +1 -1
- package/dist/primitives/audit.d.ts.map +1 -1
- package/dist/primitives/export-operation.d.ts +4 -2
- package/dist/primitives/export-operation.d.ts.map +1 -1
- package/dist/realtime/registry.d.ts +0 -5
- package/dist/realtime/registry.d.ts.map +1 -1
- package/dist/realtime/socket.d.ts +1 -1
- package/dist/realtime/socket.d.ts.map +1 -1
- package/dist/server/bun.d.ts +0 -1
- package/dist/server/bun.d.ts.map +1 -1
- package/dist/server/context-contribution.d.ts +1 -1
- package/dist/server/context-contribution.d.ts.map +1 -1
- package/dist/server/context.d.ts +2 -2
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts +15 -0
- package/dist/server/contract-method.d.ts.map +1 -0
- package/dist/server/contract-stream.d.ts +1 -1
- package/dist/server/contract-stream.d.ts.map +1 -1
- package/dist/server/create.d.ts +8 -0
- package/dist/server/create.d.ts.map +1 -1
- package/dist/server/endpoint-dispatch.d.ts +10 -0
- package/dist/server/endpoint-dispatch.d.ts.map +1 -0
- package/dist/server/endpoint-response.d.ts +19 -0
- package/dist/server/endpoint-response.d.ts.map +1 -0
- package/dist/server/error-dispatch.d.ts +17 -1
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +2 -2
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +44 -0
- package/dist/server/handler-state.d.ts.map +1 -0
- package/dist/server/implement-registry.d.ts +54 -0
- package/dist/server/implement-registry.d.ts.map +1 -0
- package/dist/server/implement.d.ts +9 -55
- package/dist/server/implement.d.ts.map +1 -1
- package/dist/server/middleware/auth.d.ts +1 -31
- package/dist/server/middleware/auth.d.ts.map +1 -1
- package/dist/server/middleware/cors.d.ts +17 -0
- package/dist/server/middleware/cors.d.ts.map +1 -1
- package/dist/server/middleware/jwt.d.ts +31 -0
- package/dist/server/middleware/jwt.d.ts.map +1 -0
- package/dist/server/middleware/trust-fence.d.ts +1 -1
- package/dist/server/middleware/trust-fence.d.ts.map +1 -1
- package/dist/server/multipart-reader.d.ts +22 -0
- package/dist/server/multipart-reader.d.ts.map +1 -0
- package/dist/server/multipart.d.ts +1 -1
- package/dist/server/multipart.d.ts.map +1 -1
- package/dist/server/oauth/cimd.d.ts +88 -0
- package/dist/server/oauth/cimd.d.ts.map +1 -0
- package/dist/server/oauth/endpoints.d.ts +39 -0
- package/dist/server/oauth/endpoints.d.ts.map +1 -0
- package/dist/server/oauth/metadata.d.ts +28 -0
- package/dist/server/oauth/metadata.d.ts.map +1 -0
- package/dist/server/oauth/provider.d.ts +117 -0
- package/dist/server/oauth/provider.d.ts.map +1 -0
- package/dist/server/realtime.d.ts +1 -1
- package/dist/server/realtime.d.ts.map +1 -1
- package/dist/server/request-completion.d.ts +16 -0
- package/dist/server/request-completion.d.ts.map +1 -0
- package/dist/server/response-metadata.d.ts +1 -1
- package/dist/server/response-metadata.d.ts.map +1 -1
- package/dist/server/route-table.d.ts +9 -0
- package/dist/server/route-table.d.ts.map +1 -0
- package/dist/server/stream.d.ts +0 -13
- package/dist/server/stream.d.ts.map +1 -1
- package/dist/server/streaming-pump.d.ts +66 -0
- package/dist/server/streaming-pump.d.ts.map +1 -0
- package/dist/server/streaming-route.d.ts +12 -5
- package/dist/server/streaming-route.d.ts.map +1 -1
- package/dist/server/types.d.ts +10 -4
- package/dist/server/types.d.ts.map +1 -1
- package/dist/server/unix-client-bun.d.ts.map +1 -1
- package/dist/server/unix-client-http1.d.ts +76 -0
- package/dist/server/unix-client-http1.d.ts.map +1 -0
- package/dist/server/unix-client.d.ts.map +1 -1
- package/dist/testing/handler-clients.d.ts +32 -0
- package/dist/testing/handler-clients.d.ts.map +1 -0
- package/dist/testing/managed-resource-conformance-scenarios.d.ts.map +1 -1
- package/dist/testing/realtime-probe.d.ts +33 -0
- package/dist/testing/realtime-probe.d.ts.map +1 -0
- package/dist/testing/surface-conformance.d.ts +2 -32
- package/dist/testing/surface-conformance.d.ts.map +1 -1
- package/dist/testing/surface-manifest-digest.d.ts +44 -0
- package/dist/testing/surface-manifest-digest.d.ts.map +1 -0
- package/dist/testing/surface-manifest.d.ts +30 -4
- package/dist/testing/surface-manifest.d.ts.map +1 -1
- package/dist/tools/agent.d.ts +1 -1
- package/dist/tools/agent.d.ts.map +1 -1
- package/dist/tools/cli/args-fields.d.ts +31 -0
- package/dist/tools/cli/args-fields.d.ts.map +1 -0
- package/dist/tools/cli/args-route.d.ts +42 -0
- package/dist/tools/cli/args-route.d.ts.map +1 -0
- package/dist/tools/cli/args-view.d.ts +32 -0
- package/dist/tools/cli/args-view.d.ts.map +1 -0
- package/dist/tools/cli/args.d.ts +80 -0
- package/dist/tools/cli/args.d.ts.map +1 -0
- package/dist/tools/cli/argument-error.d.ts +5 -0
- package/dist/tools/cli/argument-error.d.ts.map +1 -0
- package/dist/tools/cli/checkpoint.d.ts +24 -0
- package/dist/tools/cli/checkpoint.d.ts.map +1 -0
- package/dist/tools/cli/command.d.ts +70 -0
- package/dist/tools/cli/command.d.ts.map +1 -0
- package/dist/tools/cli/config.d.ts +90 -0
- package/dist/tools/cli/config.d.ts.map +1 -0
- package/dist/tools/cli/create-cli.d.ts +36 -0
- package/dist/tools/cli/create-cli.d.ts.map +1 -0
- package/dist/tools/cli/download.d.ts +8 -0
- package/dist/tools/cli/download.d.ts.map +1 -0
- package/dist/tools/cli/format.d.ts +50 -0
- package/dist/tools/cli/format.d.ts.map +1 -0
- package/dist/tools/cli/help.d.ts +24 -0
- package/dist/tools/cli/help.d.ts.map +1 -0
- package/dist/tools/cli/installer.d.ts +34 -0
- package/dist/tools/cli/installer.d.ts.map +1 -0
- package/dist/tools/cli/invoke.d.ts +144 -0
- package/dist/tools/cli/invoke.d.ts.map +1 -0
- package/dist/tools/cli/io.d.ts +10 -0
- package/dist/tools/cli/io.d.ts.map +1 -0
- package/dist/tools/cli/managed-surface.d.ts +30 -0
- package/dist/tools/cli/managed-surface.d.ts.map +1 -0
- package/dist/tools/cli/manifest.d.ts +80 -0
- package/dist/tools/cli/manifest.d.ts.map +1 -0
- package/dist/tools/cli/policy.d.ts +27 -0
- package/dist/tools/cli/policy.d.ts.map +1 -0
- package/dist/tools/cli/prepare.d.ts +14 -0
- package/dist/tools/cli/prepare.d.ts.map +1 -0
- package/dist/tools/cli/profile.d.ts +40 -0
- package/dist/tools/cli/profile.d.ts.map +1 -0
- package/dist/tools/cli/run-managed.d.ts +5 -0
- package/dist/tools/cli/run-managed.d.ts.map +1 -0
- package/dist/tools/cli/run-native.d.ts +9 -0
- package/dist/tools/cli/run-native.d.ts.map +1 -0
- package/dist/tools/cli/session.d.ts +40 -0
- package/dist/tools/cli/session.d.ts.map +1 -0
- package/dist/tools/cli/signature.d.ts +81 -0
- package/dist/tools/cli/signature.d.ts.map +1 -0
- package/dist/tools/cli/stream.d.ts +93 -0
- package/dist/tools/cli/stream.d.ts.map +1 -0
- package/dist/tools/cli/update.d.ts +145 -0
- package/dist/tools/cli/update.d.ts.map +1 -0
- package/dist/tools/cli/view.d.ts +12 -0
- package/dist/tools/cli/view.d.ts.map +1 -0
- package/dist/tools/cli/wait.d.ts +54 -0
- package/dist/tools/cli/wait.d.ts.map +1 -0
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.d.ts.map +1 -1
- package/dist/tools/connections/types.d.ts +3 -3
- package/dist/tools/connections/types.d.ts.map +1 -1
- package/dist/tools/durability-context.d.ts +1 -1
- package/dist/tools/durability-context.d.ts.map +1 -1
- package/dist/tools/execute-args.d.ts +23 -0
- package/dist/tools/execute-args.d.ts.map +1 -0
- package/dist/tools/execute-hooks.d.ts +146 -0
- package/dist/tools/execute-hooks.d.ts.map +1 -0
- package/dist/tools/execute-result.d.ts +40 -0
- package/dist/tools/execute-result.d.ts.map +1 -0
- package/dist/tools/execute.d.ts +31 -193
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +9 -6
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/internal/tool-view.d.ts +41 -0
- package/dist/tools/internal/tool-view.d.ts.map +1 -0
- package/dist/tools/invoker.d.ts +13 -4
- package/dist/tools/invoker.d.ts.map +1 -1
- package/dist/tools/lifecycle.d.ts +1 -1
- package/dist/tools/lifecycle.d.ts.map +1 -1
- package/dist/tools/list-names.d.ts +3 -3
- package/dist/tools/list-names.d.ts.map +1 -1
- package/dist/tools/manifest.d.ts +2 -2
- package/dist/tools/manifest.d.ts.map +1 -1
- package/dist/tools/mcp/app.d.ts +62 -0
- package/dist/tools/mcp/app.d.ts.map +1 -0
- package/dist/tools/mcp/catalog.d.ts +68 -0
- package/dist/tools/mcp/catalog.d.ts.map +1 -0
- package/dist/tools/mcp/handler.d.ts +46 -0
- package/dist/tools/mcp/handler.d.ts.map +1 -0
- package/dist/tools/mcp/mount.d.ts +152 -0
- package/dist/tools/mcp/mount.d.ts.map +1 -0
- package/dist/tools/mcp/prepare.d.ts +76 -0
- package/dist/tools/mcp/prepare.d.ts.map +1 -0
- package/dist/tools/mcp/progress.d.ts +46 -0
- package/dist/tools/mcp/progress.d.ts.map +1 -0
- package/dist/tools/mcp/register.d.ts +36 -0
- package/dist/tools/mcp/register.d.ts.map +1 -0
- package/dist/tools/mcp/round-context.d.ts +38 -0
- package/dist/tools/mcp/round-context.d.ts.map +1 -0
- package/dist/tools/mcp/round-policy.d.ts +33 -0
- package/dist/tools/mcp/round-policy.d.ts.map +1 -0
- package/dist/tools/mcp/round.d.ts +53 -0
- package/dist/tools/mcp/round.d.ts.map +1 -0
- package/dist/tools/mcp/runtime-tools.d.ts +25 -0
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -0
- package/dist/tools/mcp/stdio-signals.d.ts +33 -0
- package/dist/tools/mcp/stdio-signals.d.ts.map +1 -0
- package/dist/tools/mcp/stdio.d.ts +20 -0
- package/dist/tools/mcp/stdio.d.ts.map +1 -0
- package/dist/tools/mcp/trace.d.ts +12 -0
- package/dist/tools/mcp/trace.d.ts.map +1 -0
- package/dist/tools/mount.d.ts +14 -7
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +4 -3
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-binding-types.d.ts +127 -0
- package/dist/tools/operations/async-operation-binding-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-binding.d.ts +28 -0
- package/dist/tools/operations/async-operation-binding.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts +110 -0
- package/dist/tools/operations/async-operation-canonical-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-canonical.d.ts +7 -0
- package/dist/tools/operations/async-operation-canonical.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-contract.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-id.d.ts +23 -0
- package/dist/tools/operations/async-operation-id.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +41 -0
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts +69 -0
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -0
- package/dist/tools/operations/async-operation-runtime.d.ts +5 -0
- package/dist/tools/operations/async-operation-runtime.d.ts.map +1 -0
- package/dist/tools/operations/define-wait-tool.d.ts +22 -0
- package/dist/tools/operations/define-wait-tool.d.ts.map +1 -0
- package/dist/tools/operations/mount-wait.d.ts.map +1 -0
- package/dist/tools/operations/wait-core.d.ts.map +1 -0
- package/dist/tools/remote.d.ts +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +13 -4
- package/dist/tools/runtime-tool.d.ts.map +1 -1
- package/dist/tools/schema/coerce.d.ts.map +1 -0
- package/dist/tools/schema/flatten-join.d.ts.map +1 -0
- package/dist/tools/schema/flatten.d.ts.map +1 -0
- package/dist/tools/schema/portable-formats.d.ts.map +1 -0
- package/dist/tools/schema/presentation.d.ts +24 -0
- package/dist/tools/schema/presentation.d.ts.map +1 -0
- package/dist/tools/schema/schema.d.ts.map +1 -0
- package/dist/tools/schema/untyped-properties.d.ts.map +1 -0
- package/dist/tools/surface.d.ts +2 -3
- package/dist/tools/surface.d.ts.map +1 -1
- package/dist/tools/tool-logger.d.ts +1 -1
- package/dist/tools/tool-logger.d.ts.map +1 -1
- package/dist/tools/toolkit.d.ts +4 -4
- package/dist/tools/toolkit.d.ts.map +1 -1
- package/dist/tools/transfer/define-download-tool.d.ts +18 -0
- package/dist/tools/transfer/define-download-tool.d.ts.map +1 -0
- package/dist/tools/transfer/define-upload-tool.d.ts +16 -0
- package/dist/tools/transfer/define-upload-tool.d.ts.map +1 -0
- package/dist/tools/transfer/define-view-file-tool.d.ts +10 -0
- package/dist/tools/transfer/define-view-file-tool.d.ts.map +1 -0
- package/dist/tools/transfer/download-core.d.ts +20 -0
- package/dist/tools/transfer/download-core.d.ts.map +1 -0
- package/dist/tools/transfer/managed-file-error.d.ts +6 -0
- package/dist/tools/transfer/managed-file-error.d.ts.map +1 -0
- package/dist/tools/transfer/mount-download.d.ts +41 -0
- package/dist/tools/transfer/mount-download.d.ts.map +1 -0
- package/dist/tools/transfer/mount-upload.d.ts +21 -0
- package/dist/tools/transfer/mount-upload.d.ts.map +1 -0
- package/dist/tools/transfer/native-result.d.ts.map +1 -0
- package/dist/tools/transfer/upload-core.d.ts +4 -0
- package/dist/tools/transfer/upload-core.d.ts.map +1 -0
- package/dist/tools/transfer/view-file-contract.d.ts.map +1 -0
- package/dist/tools/transfer/view-file.d.ts +62 -0
- package/dist/tools/transfer/view-file.d.ts.map +1 -0
- package/dist/tools/transports.d.ts +1 -1
- package/dist/tools/transports.d.ts.map +1 -1
- package/dist/tracking/client-listeners.d.ts +30 -0
- package/dist/tracking/client-listeners.d.ts.map +1 -0
- package/dist/tracking/client-visit.d.ts +61 -0
- package/dist/tracking/client-visit.d.ts.map +1 -0
- package/dist/tracking/client.d.ts +3 -2
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/contract.d.ts +1 -1
- package/dist/tracking/contract.d.ts.map +1 -1
- package/llms/agent-runtime-browser.txt +33 -0
- package/llms/agent-runtime-coding-tools.txt +58 -0
- package/llms/agent-runtime-harness.txt +45 -0
- package/llms/agent-runtime-openrouter.txt +22 -0
- package/llms/agent-runtime-sandbox.txt +159 -0
- package/llms/agent-runtime-sqlite-bun.txt +29 -0
- package/llms/agent-runtime-sqlite-node.txt +26 -0
- package/llms/agent-runtime-testing.txt +30 -0
- package/llms/agent-runtime.2.txt +550 -0
- package/llms/agent-runtime.3.txt +311 -0
- package/llms/agent-runtime.txt +893 -0
- package/llms/application-diagnostic-journal.txt +30 -0
- package/llms/application-grammy.txt +27 -0
- package/llms/application-opentelemetry.txt +27 -0
- package/llms/application-schemas.txt +42 -0
- package/llms/application.2.txt +487 -0
- package/llms/application.txt +886 -0
- package/llms/cli.2.txt +80 -0
- package/llms/cli.txt +948 -0
- package/llms/contract.txt +606 -0
- package/llms/declaration.txt +286 -0
- package/llms/files.txt +33 -0
- package/llms/geo.txt +114 -0
- package/llms/google.txt +27 -0
- package/llms/live.txt +471 -0
- package/llms/node.txt +43 -0
- package/llms/oauth.txt +136 -0
- package/llms/observability.txt +893 -0
- package/llms/primitives.txt +158 -0
- package/llms/react.txt +184 -0
- package/llms/release.txt +176 -0
- package/llms/remote.txt +25 -0
- package/llms/server.2.txt +361 -0
- package/llms/server.3.txt +1031 -0
- package/llms/server.4.txt +905 -0
- package/llms/server.5.txt +250 -0
- package/llms/server.txt +996 -0
- package/llms/stitchkit.2.txt +836 -0
- package/llms/stitchkit.3.txt +147 -0
- package/llms/stitchkit.txt +260 -0
- package/llms/telegram.txt +30 -0
- package/llms/testing.txt +676 -0
- package/llms/tools-connections.txt +45 -0
- package/llms/tools-contract.txt +9 -0
- package/llms/tools-invoker.txt +9 -0
- package/llms/tools.2.txt +647 -0
- package/llms/tools.3.txt +288 -0
- package/llms/tools.txt +966 -0
- package/llms/tracking-server.txt +32 -0
- package/llms/tracking.txt +263 -0
- package/llms/upgrading-0.37.0-0.50.0.txt +947 -0
- package/llms/upgrading-0.53.0-0.67.0.txt +1174 -0
- package/llms/upgrading-0.68.0-0.94.0.txt +1159 -0
- package/llms/upgrading.txt +215 -0
- package/llms-full.txt +312 -77
- package/llms.txt +54 -5
- package/package.json +84 -83
- package/dist/agent-runtime/durability-contract.d.ts +0 -176
- package/dist/agent-runtime/durability-contract.d.ts.map +0 -1
- package/dist/agent-runtime/durability-json.d.ts +0 -3
- package/dist/agent-runtime/durability-json.d.ts.map +0 -1
- package/dist/agent-runtime/durability-ledger.d.ts +0 -16
- package/dist/agent-runtime/durability-ledger.d.ts.map +0 -1
- package/dist/agent-runtime/durability-scheduler.d.ts +0 -29
- package/dist/agent-runtime/durability-scheduler.d.ts.map +0 -1
- package/dist/agent-runtime/durability.d.ts +0 -14
- package/dist/agent-runtime/durability.d.ts.map +0 -1
- package/dist/agent-runtime/store-driver.d.ts +0 -814
- package/dist/agent-runtime/store-driver.d.ts.map +0 -1
- package/dist/agent-runtime-browser.d.ts +0 -5
- package/dist/agent-runtime-browser.d.ts.map +0 -1
- package/dist/agent-runtime-browser.js +0 -124
- package/dist/agent-runtime-coding-tools.d.ts +0 -2
- package/dist/agent-runtime-coding-tools.d.ts.map +0 -1
- package/dist/agent-runtime-coding-tools.js +0 -23
- package/dist/agent-runtime-harness.d.ts +0 -2
- package/dist/agent-runtime-harness.d.ts.map +0 -1
- package/dist/agent-runtime-harness.js +0 -729
- package/dist/agent-runtime-openrouter.d.ts +0 -29
- package/dist/agent-runtime-openrouter.d.ts.map +0 -1
- package/dist/agent-runtime-openrouter.js +0 -270
- package/dist/agent-runtime-sandbox.d.ts +0 -5
- package/dist/agent-runtime-sandbox.d.ts.map +0 -1
- package/dist/agent-runtime-sandbox.js +0 -798
- package/dist/agent-runtime-sqlite-bun.d.ts +0 -11
- package/dist/agent-runtime-sqlite-bun.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-bun.js +0 -42
- package/dist/agent-runtime-sqlite-node.d.ts +0 -11
- package/dist/agent-runtime-sqlite-node.d.ts.map +0 -1
- package/dist/agent-runtime-sqlite-node.js +0 -44
- package/dist/agent-runtime-testing.d.ts +0 -3
- package/dist/agent-runtime-testing.d.ts.map +0 -1
- package/dist/agent-runtime-testing.js +0 -156
- package/dist/agent-runtime.d.ts +0 -38
- package/dist/agent-runtime.d.ts.map +0 -1
- package/dist/agent-runtime.js +0 -2607
- package/dist/application/channel.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.d.ts +0 -21
- package/dist/application-diagnostic-journal.d.ts.map +0 -1
- package/dist/application-diagnostic-journal.js +0 -632
- package/dist/application-grammy.d.ts +0 -2
- package/dist/application-grammy.d.ts.map +0 -1
- package/dist/application-grammy.js +0 -169
- package/dist/application-opentelemetry.d.ts +0 -2
- package/dist/application-opentelemetry.d.ts.map +0 -1
- package/dist/application-opentelemetry.js +0 -250
- package/dist/application-schemas.d.ts +0 -15
- package/dist/application-schemas.d.ts.map +0 -1
- package/dist/application-schemas.js +0 -27
- package/dist/application.d.ts +0 -22
- package/dist/application.d.ts.map +0 -1
- package/dist/application.js +0 -1977
- package/dist/cli.d.ts +0 -41
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -753
- package/dist/contract/index.d.ts +0 -8
- package/dist/contract/index.d.ts.map +0 -1
- package/dist/contract/index.js +0 -55
- package/dist/declaration.d.ts.map +0 -1
- package/dist/declaration.js +0 -183
- package/dist/files.d.ts +0 -3
- package/dist/files.d.ts.map +0 -1
- package/dist/files.js +0 -15
- package/dist/geo.d.ts +0 -3
- package/dist/geo.d.ts.map +0 -1
- package/dist/geo.js +0 -245
- package/dist/google.d.ts.map +0 -1
- package/dist/google.js +0 -175
- package/dist/index-0a349c33.js +0 -470
- package/dist/index-0j3vcp5m.js +0 -28
- package/dist/index-2c2bjw3s.js +0 -51
- package/dist/index-2na0qrfn.js +0 -214
- package/dist/index-2qzskm8h.js +0 -63
- package/dist/index-3bmnp41g.js +0 -2169
- package/dist/index-3xwxfj4z.js +0 -334
- package/dist/index-4fpa9dy2.js +0 -51
- package/dist/index-6kyksz9y.js +0 -268
- package/dist/index-77fekveh.js +0 -44
- package/dist/index-7gnkny4z.js +0 -326
- package/dist/index-7zbps32p.js +0 -89
- package/dist/index-9f8ztey6.js +0 -588
- package/dist/index-a11g2kry.js +0 -866
- package/dist/index-a916km3r.js +0 -45
- package/dist/index-actkayzn.js +0 -367
- package/dist/index-bn2cjajt.js +0 -524
- package/dist/index-bx75zwt7.js +0 -63
- package/dist/index-cby4ar3v.js +0 -46
- package/dist/index-cnyk6te3.js +0 -77
- package/dist/index-cxqhvq21.js +0 -413
- package/dist/index-e0znv5gn.js +0 -176
- package/dist/index-e42wzzz5.js +0 -154
- package/dist/index-f477k430.js +0 -324
- package/dist/index-f9mb610r.js +0 -177
- package/dist/index-fadnxwna.js +0 -1046
- package/dist/index-fq77yfzc.js +0 -1303
- package/dist/index-h9etkkyk.js +0 -1126
- package/dist/index-hrbajay7.js +0 -1196
- package/dist/index-kw9t5ayn.js +0 -507
- package/dist/index-mzvgxp0n.js +0 -80
- package/dist/index-n0f51dfn.js +0 -3170
- package/dist/index-p13mwz16.js +0 -16
- package/dist/index-s8cnx02s.js +0 -90
- package/dist/index-sr93cwf9.js +0 -325
- package/dist/index-tmwcrptx.js +0 -85
- package/dist/index-v5573g1k.js +0 -142
- package/dist/index-vjpvjqpn.js +0 -86
- package/dist/index-vk3kq9sb.js +0 -3344
- package/dist/index-wc4x00bn.js +0 -103
- package/dist/index-wnfk50r0.js +0 -211
- package/dist/index-yewwh1w4.js +0 -647
- package/dist/index-yn8remb1.js +0 -290
- package/dist/index-ywd0y6m1.js +0 -394
- package/dist/index-zwkgfq1s.js +0 -345
- package/dist/index.d.ts +0 -14
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -632
- package/dist/internal/errors.d.ts +0 -92
- package/dist/internal/errors.d.ts.map +0 -1
- package/dist/internal/observability-sink.d.ts +0 -81
- package/dist/internal/observability-sink.d.ts.map +0 -1
- package/dist/live.d.ts +0 -19
- package/dist/live.d.ts.map +0 -1
- package/dist/live.js +0 -282
- package/dist/logger.d.ts.map +0 -1
- package/dist/node.d.ts +0 -18
- package/dist/node.d.ts.map +0 -1
- package/dist/node.js +0 -303
- package/dist/oauth.d.ts +0 -57
- package/dist/oauth.d.ts.map +0 -1
- package/dist/oauth.js +0 -170
- package/dist/observability/index.d.ts +0 -19
- package/dist/observability/index.d.ts.map +0 -1
- package/dist/observability/index.js +0 -569
- package/dist/primitives.d.ts +0 -3
- package/dist/primitives.d.ts.map +0 -1
- package/dist/primitives.js +0 -754
- package/dist/react.d.ts +0 -5
- package/dist/react.d.ts.map +0 -1
- package/dist/react.js +0 -403
- package/dist/release.d.ts +0 -15
- package/dist/release.d.ts.map +0 -1
- package/dist/release.js +0 -196
- package/dist/remote.d.ts +0 -9
- package/dist/remote.d.ts.map +0 -1
- package/dist/remote.js +0 -88
- package/dist/retained.d.ts.map +0 -1
- package/dist/server/file-state-store.d.ts +0 -23
- package/dist/server/file-state-store.d.ts.map +0 -1
- package/dist/server/index.d.ts +0 -36
- package/dist/server/index.d.ts.map +0 -1
- package/dist/server/index.js +0 -1745
- package/dist/server/request.d.ts.map +0 -1
- package/dist/telegram.d.ts +0 -3
- package/dist/telegram.d.ts.map +0 -1
- package/dist/telegram.js +0 -224
- package/dist/testing/agent-store-conformance.d.ts +0 -40
- package/dist/testing/agent-store-conformance.d.ts.map +0 -1
- package/dist/testing.d.ts +0 -39
- package/dist/testing.d.ts.map +0 -1
- package/dist/testing.js +0 -2209
- package/dist/tool-invoker.d.ts +0 -9
- package/dist/tool-invoker.d.ts.map +0 -1
- package/dist/tool-invoker.js +0 -21
- package/dist/tools/async-operation-contract.d.ts.map +0 -1
- package/dist/tools/async-operation.d.ts +0 -332
- package/dist/tools/async-operation.d.ts.map +0 -1
- package/dist/tools/cli-args.d.ts +0 -143
- package/dist/tools/cli-args.d.ts.map +0 -1
- package/dist/tools/cli-checkpoint.d.ts +0 -24
- package/dist/tools/cli-checkpoint.d.ts.map +0 -1
- package/dist/tools/cli-command.d.ts +0 -70
- package/dist/tools/cli-command.d.ts.map +0 -1
- package/dist/tools/cli-format.d.ts +0 -49
- package/dist/tools/cli-format.d.ts.map +0 -1
- package/dist/tools/cli-installer.d.ts +0 -34
- package/dist/tools/cli-installer.d.ts.map +0 -1
- package/dist/tools/cli-invoke.d.ts +0 -143
- package/dist/tools/cli-invoke.d.ts.map +0 -1
- package/dist/tools/cli-manifest.d.ts +0 -80
- package/dist/tools/cli-manifest.d.ts.map +0 -1
- package/dist/tools/cli-policy.d.ts +0 -27
- package/dist/tools/cli-policy.d.ts.map +0 -1
- package/dist/tools/cli-profile.d.ts +0 -40
- package/dist/tools/cli-profile.d.ts.map +0 -1
- package/dist/tools/cli-signature.d.ts +0 -81
- package/dist/tools/cli-signature.d.ts.map +0 -1
- package/dist/tools/cli-stream.d.ts +0 -93
- package/dist/tools/cli-stream.d.ts.map +0 -1
- package/dist/tools/cli-update.d.ts +0 -126
- package/dist/tools/cli-update.d.ts.map +0 -1
- package/dist/tools/cli-view.d.ts +0 -12
- package/dist/tools/cli-view.d.ts.map +0 -1
- package/dist/tools/cli-wait.d.ts +0 -54
- package/dist/tools/cli-wait.d.ts.map +0 -1
- package/dist/tools/cli.d.ts +0 -94
- package/dist/tools/cli.d.ts.map +0 -1
- package/dist/tools/coerce.d.ts.map +0 -1
- package/dist/tools/connections/index.d.ts +0 -20
- package/dist/tools/connections/index.d.ts.map +0 -1
- package/dist/tools/connections/index.js +0 -1107
- package/dist/tools/define-download-tool.d.ts +0 -18
- package/dist/tools/define-download-tool.d.ts.map +0 -1
- package/dist/tools/define-upload-tool.d.ts +0 -16
- package/dist/tools/define-upload-tool.d.ts.map +0 -1
- package/dist/tools/define-view-file-tool.d.ts +0 -10
- package/dist/tools/define-view-file-tool.d.ts.map +0 -1
- package/dist/tools/define-wait-tool.d.ts +0 -22
- package/dist/tools/define-wait-tool.d.ts.map +0 -1
- package/dist/tools/download-core.d.ts +0 -20
- package/dist/tools/download-core.d.ts.map +0 -1
- package/dist/tools/flatten-join.d.ts.map +0 -1
- package/dist/tools/flatten.d.ts.map +0 -1
- package/dist/tools/json-schema-dialect.d.ts +0 -17
- package/dist/tools/json-schema-dialect.d.ts.map +0 -1
- package/dist/tools/json-schema.d.ts.map +0 -1
- package/dist/tools/managed-file-error.d.ts +0 -6
- package/dist/tools/managed-file-error.d.ts.map +0 -1
- package/dist/tools/mcp-app.d.ts +0 -62
- package/dist/tools/mcp-app.d.ts.map +0 -1
- package/dist/tools/mcp-catalog.d.ts +0 -68
- package/dist/tools/mcp-catalog.d.ts.map +0 -1
- package/dist/tools/mcp-handler.d.ts +0 -46
- package/dist/tools/mcp-handler.d.ts.map +0 -1
- package/dist/tools/mcp-prepare.d.ts +0 -75
- package/dist/tools/mcp-prepare.d.ts.map +0 -1
- package/dist/tools/mcp-progress.d.ts +0 -46
- package/dist/tools/mcp-progress.d.ts.map +0 -1
- package/dist/tools/mcp-round-policy.d.ts +0 -33
- package/dist/tools/mcp-round-policy.d.ts.map +0 -1
- package/dist/tools/mcp-round.d.ts +0 -61
- package/dist/tools/mcp-round.d.ts.map +0 -1
- package/dist/tools/mcp-stdio-signals.d.ts +0 -33
- package/dist/tools/mcp-stdio-signals.d.ts.map +0 -1
- package/dist/tools/mcp-stdio.d.ts +0 -20
- package/dist/tools/mcp-stdio.d.ts.map +0 -1
- package/dist/tools/mcp-trace.d.ts +0 -12
- package/dist/tools/mcp-trace.d.ts.map +0 -1
- package/dist/tools/mcp.d.ts +0 -152
- package/dist/tools/mcp.d.ts.map +0 -1
- package/dist/tools/mount-download.d.ts +0 -41
- package/dist/tools/mount-download.d.ts.map +0 -1
- package/dist/tools/mount-upload.d.ts +0 -21
- package/dist/tools/mount-upload.d.ts.map +0 -1
- package/dist/tools/mount-wait.d.ts.map +0 -1
- package/dist/tools/native-mcp.d.ts +0 -20
- package/dist/tools/native-mcp.d.ts.map +0 -1
- package/dist/tools/native-result.d.ts.map +0 -1
- package/dist/tools/oauth-metadata.d.ts +0 -28
- package/dist/tools/oauth-metadata.d.ts.map +0 -1
- package/dist/tools/oauth-provider.d.ts +0 -184
- package/dist/tools/oauth-provider.d.ts.map +0 -1
- package/dist/tools/portable-formats.d.ts.map +0 -1
- package/dist/tools/presentation.d.ts +0 -22
- package/dist/tools/presentation.d.ts.map +0 -1
- package/dist/tools/schema.d.ts.map +0 -1
- package/dist/tools/untyped-properties.d.ts.map +0 -1
- package/dist/tools/upload-core.d.ts +0 -4
- package/dist/tools/upload-core.d.ts.map +0 -1
- package/dist/tools/view-file-contract.d.ts.map +0 -1
- package/dist/tools/view-file.d.ts +0 -62
- package/dist/tools/view-file.d.ts.map +0 -1
- package/dist/tools/wait-core.d.ts.map +0 -1
- package/dist/tools-contract.d.ts +0 -29
- package/dist/tools-contract.d.ts.map +0 -1
- package/dist/tools-contract.js +0 -24
- package/dist/tools.d.ts +0 -50
- package/dist/tools.d.ts.map +0 -1
- package/dist/tools.js +0 -2930
- package/dist/tracking-server.d.ts +0 -15
- package/dist/tracking-server.d.ts.map +0 -1
- package/dist/tracking.d.ts +0 -24
- package/dist/tracking.d.ts.map +0 -1
- package/dist/tracking.js +0 -1092
- package/dist/upgrade-cli.d.ts.map +0 -1
- package/dist/upgrade-cli.js +0 -177
- /package/dist/{retained.d.ts → browser/retained.d.ts} +0 -0
- /package/dist/{declaration.d.ts → declaration/declaration.d.ts} +0 -0
- /package/dist/{upgrade-cli.d.ts → entrypoints/bin/upgrade-cli.d.ts} +0 -0
- /package/dist/{tracking-server.js → entrypoints/tracking/server.js} +0 -0
- /package/dist/{google.d.ts → google/google.d.ts} +0 -0
- /package/dist/{index-pq95qkbf.js → index-5jm36zv1.js} +0 -0
- /package/dist/{application → internal}/channel.d.ts +0 -0
- /package/dist/{logger.d.ts → internal/logger.d.ts} +0 -0
- /package/dist/{server → internal}/request.d.ts +0 -0
- /package/dist/{tools → json-schema}/json-schema.d.ts +0 -0
- /package/dist/tools/{async-operation-contract.d.ts → operations/async-operation-contract.d.ts} +0 -0
- /package/dist/tools/{mount-wait.d.ts → operations/mount-wait.d.ts} +0 -0
- /package/dist/tools/{wait-core.d.ts → operations/wait-core.d.ts} +0 -0
- /package/dist/tools/{coerce.d.ts → schema/coerce.d.ts} +0 -0
- /package/dist/tools/{flatten-join.d.ts → schema/flatten-join.d.ts} +0 -0
- /package/dist/tools/{flatten.d.ts → schema/flatten.d.ts} +0 -0
- /package/dist/tools/{portable-formats.d.ts → schema/portable-formats.d.ts} +0 -0
- /package/dist/tools/{schema.d.ts → schema/schema.d.ts} +0 -0
- /package/dist/tools/{untyped-properties.d.ts → schema/untyped-properties.d.ts} +0 -0
- /package/dist/tools/{native-result.d.ts → transfer/native-result.d.ts} +0 -0
- /package/dist/tools/{view-file-contract.d.ts → transfer/view-file-contract.d.ts} +0 -0
|
@@ -1,1107 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
defineRuntimeTool
|
|
3
|
-
} from "../../index-vjpvjqpn.js";
|
|
4
|
-
import {
|
|
5
|
-
declaresDraft07,
|
|
6
|
-
withDefsDialect
|
|
7
|
-
} from "../../index-h9etkkyk.js";
|
|
8
|
-
import"../../index-cby4ar3v.js";
|
|
9
|
-
import {
|
|
10
|
-
AppError
|
|
11
|
-
} from "../../index-2vtcmrj9.js";
|
|
12
|
-
import {
|
|
13
|
-
safeJsonParse
|
|
14
|
-
} from "../../index-kzfs85xp.js";
|
|
15
|
-
import {
|
|
16
|
-
isRecord
|
|
17
|
-
} from "../../index-77fekveh.js";
|
|
18
|
-
|
|
19
|
-
// src/tools/connections/errors.ts
|
|
20
|
-
class ConnectionAuthorizationRequiredError extends Error {
|
|
21
|
-
connectionName;
|
|
22
|
-
instanceId;
|
|
23
|
-
constructor(connectionName, instanceId) {
|
|
24
|
-
super(`Connection "${connectionName}" requires authorization`);
|
|
25
|
-
this.name = "ConnectionAuthorizationRequiredError";
|
|
26
|
-
this.connectionName = connectionName;
|
|
27
|
-
this.instanceId = instanceId;
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
class ConnectionRequestError extends Error {
|
|
32
|
-
connectionName;
|
|
33
|
-
status;
|
|
34
|
-
body;
|
|
35
|
-
constructor(connectionName, status, body) {
|
|
36
|
-
super(`Connection "${connectionName}" request failed with status ${status}`);
|
|
37
|
-
this.name = "ConnectionRequestError";
|
|
38
|
-
this.connectionName = connectionName;
|
|
39
|
-
this.status = status;
|
|
40
|
-
this.body = body;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
class ConnectionUrlError extends Error {
|
|
45
|
-
url;
|
|
46
|
-
constructor(message, url) {
|
|
47
|
-
super(message);
|
|
48
|
-
this.name = "ConnectionUrlError";
|
|
49
|
-
this.url = url;
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
class ConnectionBudgetExceededError extends Error {
|
|
54
|
-
limit;
|
|
55
|
-
actual;
|
|
56
|
-
constructor(limit, actual, unit = "tools") {
|
|
57
|
-
super(`Connection surface exposes ${actual} ${unit}, above the budget of ${limit}`);
|
|
58
|
-
this.name = "ConnectionBudgetExceededError";
|
|
59
|
-
this.limit = limit;
|
|
60
|
-
this.actual = actual;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
class ConnectionTimeoutError extends Error {
|
|
65
|
-
connectionName;
|
|
66
|
-
timeoutMs;
|
|
67
|
-
constructor(connectionName, timeoutMs) {
|
|
68
|
-
super(`Connection "${connectionName}" timed out after ${timeoutMs} ms`);
|
|
69
|
-
this.name = "ConnectionTimeoutError";
|
|
70
|
-
this.connectionName = connectionName;
|
|
71
|
-
this.timeoutMs = timeoutMs;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
class ConnectionResponseTooLargeError extends Error {
|
|
76
|
-
connectionName;
|
|
77
|
-
maxBytes;
|
|
78
|
-
constructor(connectionName, maxBytes) {
|
|
79
|
-
super(`Connection "${connectionName}" response exceeded the ${maxBytes} byte limit`);
|
|
80
|
-
this.name = "ConnectionResponseTooLargeError";
|
|
81
|
-
this.connectionName = connectionName;
|
|
82
|
-
this.maxBytes = maxBytes;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// src/tools/connections/ssrf.ts
|
|
87
|
-
function assertConnectionUrl(rawUrl, connectionName) {
|
|
88
|
-
let url;
|
|
89
|
-
try {
|
|
90
|
-
url = new URL(rawUrl);
|
|
91
|
-
} catch {
|
|
92
|
-
throw new ConnectionUrlError(`Connection "${connectionName}" has an unparseable URL: ${rawUrl}`, rawUrl);
|
|
93
|
-
}
|
|
94
|
-
if (url.protocol !== "http:" && url.protocol !== "https:") {
|
|
95
|
-
throw new ConnectionUrlError(`Connection "${connectionName}" must use http(s), got "${url.protocol}"`, rawUrl);
|
|
96
|
-
}
|
|
97
|
-
return url;
|
|
98
|
-
}
|
|
99
|
-
function connectionAllowedHosts(connectionUrl, extra) {
|
|
100
|
-
const hosts = new Set([connectionUrl.host.toLowerCase()]);
|
|
101
|
-
for (const host of extra ?? [])
|
|
102
|
-
hosts.add(host.toLowerCase());
|
|
103
|
-
return hosts;
|
|
104
|
-
}
|
|
105
|
-
function assertAllowedHost(url, allowedHosts, connectionName) {
|
|
106
|
-
if (!allowedHosts.has(url.host.toLowerCase())) {
|
|
107
|
-
throw new ConnectionUrlError(`Connection "${connectionName}" refused request to host "${url.host}": not the connection host or an allowed host`, url.toString());
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
// src/tools/connections/define.ts
|
|
112
|
-
function defineMcpClientConnection(config) {
|
|
113
|
-
if (!config.name.trim())
|
|
114
|
-
throw new Error("MCP connection requires a name");
|
|
115
|
-
assertConnectionUrl(config.transport.url, config.name);
|
|
116
|
-
return { ...config, kind: "mcp" };
|
|
117
|
-
}
|
|
118
|
-
function defineOpenApiConnection(config) {
|
|
119
|
-
if (!config.name.trim())
|
|
120
|
-
throw new Error("OpenAPI connection requires a name");
|
|
121
|
-
if (config.baseUrl)
|
|
122
|
-
assertConnectionUrl(config.baseUrl, config.name);
|
|
123
|
-
return { ...config, kind: "openapi" };
|
|
124
|
-
}
|
|
125
|
-
// src/tools/connections/instance.ts
|
|
126
|
-
import { createHash } from "node:crypto";
|
|
127
|
-
function connectionInstanceId(name, url, instanceKey) {
|
|
128
|
-
return createHash("sha256").update(`${name}\x00${url}\x00${instanceKey ?? ""}`).digest("hex").slice(0, 32);
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
// src/tools/connections/mcp.ts
|
|
132
|
-
import { z as z2 } from "zod";
|
|
133
|
-
|
|
134
|
-
// src/tools/connections/limits.ts
|
|
135
|
-
var DEFAULT_CONNECTION_TIMEOUT_MS = 30000;
|
|
136
|
-
var DEFAULT_MAX_RESPONSE_BYTES = 1024 * 1024;
|
|
137
|
-
function connectionTimeoutMs(value) {
|
|
138
|
-
return value !== undefined && value > 0 ? value : DEFAULT_CONNECTION_TIMEOUT_MS;
|
|
139
|
-
}
|
|
140
|
-
function connectionMaxResponseBytes(value) {
|
|
141
|
-
return value !== undefined && value > 0 ? value : DEFAULT_MAX_RESPONSE_BYTES;
|
|
142
|
-
}
|
|
143
|
-
async function withConnectionDeadline(connectionName, timeoutMs, callerSignal, body) {
|
|
144
|
-
const controller = new AbortController;
|
|
145
|
-
const timer = setTimeout(() => controller.abort(new ConnectionTimeoutError(connectionName, timeoutMs)), timeoutMs);
|
|
146
|
-
const onAbort = () => controller.abort(callerSignal?.reason);
|
|
147
|
-
if (callerSignal) {
|
|
148
|
-
if (callerSignal.aborted)
|
|
149
|
-
controller.abort(callerSignal.reason);
|
|
150
|
-
else
|
|
151
|
-
callerSignal.addEventListener("abort", onAbort, { once: true });
|
|
152
|
-
}
|
|
153
|
-
try {
|
|
154
|
-
return await body(controller.signal);
|
|
155
|
-
} finally {
|
|
156
|
-
clearTimeout(timer);
|
|
157
|
-
callerSignal?.removeEventListener("abort", onAbort);
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
async function readBoundedText(response, maxBytes, connectionName) {
|
|
161
|
-
const stream = response.body;
|
|
162
|
-
if (!stream)
|
|
163
|
-
return "";
|
|
164
|
-
const reader = stream.getReader();
|
|
165
|
-
const decoder = new TextDecoder;
|
|
166
|
-
let total = 0;
|
|
167
|
-
let text = "";
|
|
168
|
-
try {
|
|
169
|
-
for (;; ) {
|
|
170
|
-
const { done, value } = await reader.read();
|
|
171
|
-
if (done)
|
|
172
|
-
break;
|
|
173
|
-
total += value.byteLength;
|
|
174
|
-
if (total > maxBytes) {
|
|
175
|
-
await reader.cancel().catch(() => {
|
|
176
|
-
return;
|
|
177
|
-
});
|
|
178
|
-
throw new ConnectionResponseTooLargeError(connectionName, maxBytes);
|
|
179
|
-
}
|
|
180
|
-
text += decoder.decode(value, { stream: true });
|
|
181
|
-
}
|
|
182
|
-
text += decoder.decode();
|
|
183
|
-
return text;
|
|
184
|
-
} finally {
|
|
185
|
-
reader.releaseLock();
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
async function readBoundedJson(response, maxBytes, connectionName) {
|
|
189
|
-
const text = await readBoundedText(response, maxBytes, connectionName);
|
|
190
|
-
return JSON.parse(text);
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
// src/tools/connections/http.ts
|
|
194
|
-
async function fetchConnection(target, init, allowedHosts, connectionName) {
|
|
195
|
-
const url = assertConnectionUrl(target.toString(), connectionName);
|
|
196
|
-
assertAllowedHost(url, allowedHosts, connectionName);
|
|
197
|
-
const response = await fetch(url, { ...init, redirect: "manual" });
|
|
198
|
-
if (response.status >= 300 && response.status < 400) {
|
|
199
|
-
await response.body?.cancel();
|
|
200
|
-
throw new ConnectionUrlError(`Connection "${connectionName}" refused a redirect`, url.toString());
|
|
201
|
-
}
|
|
202
|
-
return response;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
// src/tools/connections/json-rpc.ts
|
|
206
|
-
function unwrap(payload, id, connectionName) {
|
|
207
|
-
if (!isRecord(payload) || payload.id !== id)
|
|
208
|
-
throw new Error(`MCP response id mismatch from "${connectionName}"`);
|
|
209
|
-
if (isRecord(payload.error))
|
|
210
|
-
throw new Error(`MCP error from "${connectionName}": ${typeof payload.error.message === "string" ? payload.error.message : "unknown"}`);
|
|
211
|
-
return payload.result;
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
// src/tools/connections/sse-frames.ts
|
|
215
|
-
async function* readSseFrames(response, maxBytes, connectionName, totalLimit = false) {
|
|
216
|
-
if (!response.body)
|
|
217
|
-
throw new Error("MCP stream ended with no body");
|
|
218
|
-
const reader = response.body.getReader();
|
|
219
|
-
const decoder = new TextDecoder;
|
|
220
|
-
let buffer = "";
|
|
221
|
-
let bytes = 0;
|
|
222
|
-
try {
|
|
223
|
-
for (;; ) {
|
|
224
|
-
const { done, value } = await reader.read();
|
|
225
|
-
if (done)
|
|
226
|
-
break;
|
|
227
|
-
if (totalLimit) {
|
|
228
|
-
bytes += value.byteLength;
|
|
229
|
-
if (bytes > maxBytes)
|
|
230
|
-
throw new ConnectionResponseTooLargeError(connectionName, maxBytes);
|
|
231
|
-
}
|
|
232
|
-
for (let offset = 0;offset < value.byteLength; offset += 1024) {
|
|
233
|
-
buffer += decoder.decode(value.subarray(offset, offset + 1024), { stream: true });
|
|
234
|
-
let match = /\r?\n\r?\n/.exec(buffer);
|
|
235
|
-
while (match) {
|
|
236
|
-
const frame = buffer.slice(0, match.index);
|
|
237
|
-
if (new TextEncoder().encode(frame).byteLength > maxBytes)
|
|
238
|
-
throw new ConnectionResponseTooLargeError(connectionName, maxBytes);
|
|
239
|
-
buffer = buffer.slice(match.index + match[0].length);
|
|
240
|
-
let event = "message";
|
|
241
|
-
const data = [];
|
|
242
|
-
for (const line of frame.split(/\r?\n/)) {
|
|
243
|
-
if (line.startsWith("event:"))
|
|
244
|
-
event = line.slice(6).trim();
|
|
245
|
-
if (line.startsWith("data:"))
|
|
246
|
-
data.push(line.slice(5).replace(/^ /, ""));
|
|
247
|
-
}
|
|
248
|
-
yield { event, data: data.join(`
|
|
249
|
-
`) };
|
|
250
|
-
match = /\r?\n\r?\n/.exec(buffer);
|
|
251
|
-
}
|
|
252
|
-
if (new TextEncoder().encode(buffer).byteLength > maxBytes)
|
|
253
|
-
throw new ConnectionResponseTooLargeError(connectionName, maxBytes);
|
|
254
|
-
}
|
|
255
|
-
}
|
|
256
|
-
} finally {
|
|
257
|
-
await reader.cancel().catch(() => {
|
|
258
|
-
return;
|
|
259
|
-
});
|
|
260
|
-
reader.releaseLock();
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
// src/tools/connections/sse-session.ts
|
|
265
|
-
class SseSession {
|
|
266
|
-
connectionName;
|
|
267
|
-
instanceId;
|
|
268
|
-
options;
|
|
269
|
-
controller = new AbortController;
|
|
270
|
-
pending = new Map;
|
|
271
|
-
endpoint = Promise.withResolvers();
|
|
272
|
-
failure;
|
|
273
|
-
constructor(connectionName, instanceId, options) {
|
|
274
|
-
this.connectionName = connectionName;
|
|
275
|
-
this.instanceId = instanceId;
|
|
276
|
-
this.options = options;
|
|
277
|
-
this.endpoint.promise.catch(() => {
|
|
278
|
-
return;
|
|
279
|
-
});
|
|
280
|
-
this.open();
|
|
281
|
-
}
|
|
282
|
-
async ready(signal) {
|
|
283
|
-
return withConnectionDeadline(this.connectionName, this.options.timeoutMs, signal, async (deadline) => {
|
|
284
|
-
const onAbort = () => this.close(deadline.reason);
|
|
285
|
-
deadline.addEventListener("abort", onAbort, { once: true });
|
|
286
|
-
try {
|
|
287
|
-
deadline.throwIfAborted();
|
|
288
|
-
return await this.endpoint.promise;
|
|
289
|
-
} finally {
|
|
290
|
-
deadline.removeEventListener("abort", onAbort);
|
|
291
|
-
}
|
|
292
|
-
});
|
|
293
|
-
}
|
|
294
|
-
close(reason = new Error("MCP SSE session closed")) {
|
|
295
|
-
this.failure = reason;
|
|
296
|
-
this.controller.abort(reason);
|
|
297
|
-
this.endpoint.reject(reason);
|
|
298
|
-
for (const pending of this.pending.values())
|
|
299
|
-
pending.reject(reason);
|
|
300
|
-
this.pending.clear();
|
|
301
|
-
}
|
|
302
|
-
async request(message, token, signal) {
|
|
303
|
-
return withConnectionDeadline(this.connectionName, this.options.timeoutMs, signal, async (deadline) => {
|
|
304
|
-
const abort = () => this.close(deadline.reason);
|
|
305
|
-
deadline.addEventListener("abort", abort, { once: true });
|
|
306
|
-
try {
|
|
307
|
-
deadline.throwIfAborted();
|
|
308
|
-
if (this.controller.signal.aborted)
|
|
309
|
-
throw this.failure;
|
|
310
|
-
const endpoint = await this.endpoint.promise;
|
|
311
|
-
const response = Promise.withResolvers();
|
|
312
|
-
response.promise.catch(() => {
|
|
313
|
-
return;
|
|
314
|
-
});
|
|
315
|
-
if (message.id !== undefined)
|
|
316
|
-
this.pending.set(message.id, response);
|
|
317
|
-
const post = await fetchConnection(endpoint, {
|
|
318
|
-
method: "POST",
|
|
319
|
-
headers: {
|
|
320
|
-
...this.options.headers,
|
|
321
|
-
"content-type": "application/json",
|
|
322
|
-
...token ? { authorization: `Bearer ${token}` } : {}
|
|
323
|
-
},
|
|
324
|
-
body: JSON.stringify(message),
|
|
325
|
-
signal: deadline
|
|
326
|
-
}, this.options.allowedHosts, this.connectionName);
|
|
327
|
-
this.assertStatus(post);
|
|
328
|
-
await post.body?.cancel();
|
|
329
|
-
return message.id === undefined ? undefined : await response.promise;
|
|
330
|
-
} finally {
|
|
331
|
-
if (message.id !== undefined)
|
|
332
|
-
this.pending.delete(message.id);
|
|
333
|
-
deadline.removeEventListener("abort", abort);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
assertStatus(response) {
|
|
338
|
-
if (response.status === 401)
|
|
339
|
-
throw new ConnectionAuthorizationRequiredError(this.connectionName, this.instanceId);
|
|
340
|
-
if (!response.ok)
|
|
341
|
-
throw new ConnectionRequestError(this.connectionName, response.status, "");
|
|
342
|
-
}
|
|
343
|
-
async open() {
|
|
344
|
-
try {
|
|
345
|
-
const response = await fetchConnection(this.options.baseUrl, {
|
|
346
|
-
method: "GET",
|
|
347
|
-
headers: { ...this.options.headers, accept: "text/event-stream" },
|
|
348
|
-
signal: this.controller.signal
|
|
349
|
-
}, this.options.allowedHosts, this.connectionName);
|
|
350
|
-
this.assertStatus(response);
|
|
351
|
-
for await (const frame of readSseFrames(response, this.options.maxResponseBytes, this.connectionName)) {
|
|
352
|
-
if (frame.event === "endpoint") {
|
|
353
|
-
const url = assertConnectionUrl(new URL(frame.data, this.options.baseUrl).toString(), this.connectionName);
|
|
354
|
-
assertAllowedHost(url, this.options.allowedHosts, this.connectionName);
|
|
355
|
-
this.endpoint.resolve(url.toString());
|
|
356
|
-
} else if (frame.event === "message" && frame.data) {
|
|
357
|
-
const message = JSON.parse(frame.data);
|
|
358
|
-
if (!isRecord(message) || typeof message.id !== "number")
|
|
359
|
-
continue;
|
|
360
|
-
const pending = this.pending.get(message.id);
|
|
361
|
-
if (!pending)
|
|
362
|
-
continue;
|
|
363
|
-
try {
|
|
364
|
-
pending.resolve(unwrap(message, message.id, this.connectionName));
|
|
365
|
-
} catch (error) {
|
|
366
|
-
pending.reject(error);
|
|
367
|
-
}
|
|
368
|
-
this.pending.delete(message.id);
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
this.close(new Error("MCP SSE stream ended"));
|
|
372
|
-
} catch (error) {
|
|
373
|
-
this.close(error);
|
|
374
|
-
}
|
|
375
|
-
}
|
|
376
|
-
}
|
|
377
|
-
|
|
378
|
-
// src/tools/connections/mcp-client.ts
|
|
379
|
-
var FALLBACK_STATUSES = new Set([400, 404, 405]);
|
|
380
|
-
var PROTOCOL_VERSION = "2024-11-05";
|
|
381
|
-
|
|
382
|
-
class McpHttpClient {
|
|
383
|
-
connectionName;
|
|
384
|
-
instanceId;
|
|
385
|
-
options;
|
|
386
|
-
mode = "streamable";
|
|
387
|
-
sessionId;
|
|
388
|
-
protocolVersion;
|
|
389
|
-
nextId = 1;
|
|
390
|
-
initialized = false;
|
|
391
|
-
sse;
|
|
392
|
-
constructor(connectionName, instanceId, options) {
|
|
393
|
-
this.connectionName = connectionName;
|
|
394
|
-
this.instanceId = instanceId;
|
|
395
|
-
this.options = options;
|
|
396
|
-
}
|
|
397
|
-
teardown() {
|
|
398
|
-
this.initialized = false;
|
|
399
|
-
this.sessionId = undefined;
|
|
400
|
-
this.sse?.close();
|
|
401
|
-
this.sse = undefined;
|
|
402
|
-
this.mode = "streamable";
|
|
403
|
-
}
|
|
404
|
-
async initialize(token, signal) {
|
|
405
|
-
if (this.initialized)
|
|
406
|
-
return;
|
|
407
|
-
const result = await this.request("initialize", {
|
|
408
|
-
protocolVersion: PROTOCOL_VERSION,
|
|
409
|
-
capabilities: {},
|
|
410
|
-
clientInfo: { name: "stitchkit", version: "0.0.0" }
|
|
411
|
-
}, token, signal);
|
|
412
|
-
if (isRecord(result) && typeof result.protocolVersion === "string") {
|
|
413
|
-
this.protocolVersion = result.protocolVersion;
|
|
414
|
-
}
|
|
415
|
-
this.initialized = true;
|
|
416
|
-
try {
|
|
417
|
-
await this.dispatch({ jsonrpc: "2.0", method: "notifications/initialized" }, token, signal);
|
|
418
|
-
} catch {}
|
|
419
|
-
}
|
|
420
|
-
request(method, params, token, signal) {
|
|
421
|
-
return this.dispatch({ jsonrpc: "2.0", id: this.nextId++, method, params }, token, signal);
|
|
422
|
-
}
|
|
423
|
-
async dispatch(message, token, signal) {
|
|
424
|
-
if (this.mode === "sse")
|
|
425
|
-
return this.sseRequest(message, token, signal);
|
|
426
|
-
try {
|
|
427
|
-
return await this.streamableRequest(message, token, signal);
|
|
428
|
-
} catch (error) {
|
|
429
|
-
if (error instanceof ConnectionRequestError && FALLBACK_STATUSES.has(error.status)) {
|
|
430
|
-
await this.openSse(token, signal);
|
|
431
|
-
this.mode = "sse";
|
|
432
|
-
return this.sseRequest(message, token, signal);
|
|
433
|
-
}
|
|
434
|
-
throw error;
|
|
435
|
-
}
|
|
436
|
-
}
|
|
437
|
-
streamableRequest(message, token, signal) {
|
|
438
|
-
const target = new URL(this.options.transport.url);
|
|
439
|
-
assertAllowedHost(target, this.options.allowedHosts, this.connectionName);
|
|
440
|
-
return withConnectionDeadline(this.connectionName, this.options.timeoutMs, signal, async (deadline) => {
|
|
441
|
-
const response = await fetchConnection(target, {
|
|
442
|
-
method: "POST",
|
|
443
|
-
headers: this.headers(token),
|
|
444
|
-
body: JSON.stringify(message),
|
|
445
|
-
signal: deadline
|
|
446
|
-
}, this.options.allowedHosts, this.connectionName);
|
|
447
|
-
if (response.status === 401) {
|
|
448
|
-
throw new ConnectionAuthorizationRequiredError(this.connectionName, this.instanceId);
|
|
449
|
-
}
|
|
450
|
-
if (!response.ok) {
|
|
451
|
-
throw new ConnectionRequestError(this.connectionName, response.status, await this.safeText(response));
|
|
452
|
-
}
|
|
453
|
-
const session = response.headers.get("mcp-session-id");
|
|
454
|
-
if (session)
|
|
455
|
-
this.sessionId = session;
|
|
456
|
-
if (message.id === undefined) {
|
|
457
|
-
await response.body?.cancel();
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
461
|
-
if (contentType.includes("text/event-stream")) {
|
|
462
|
-
for await (const frame of readSseFrames(response, this.options.maxResponseBytes, this.connectionName, true)) {
|
|
463
|
-
if (!frame.data)
|
|
464
|
-
continue;
|
|
465
|
-
const payload2 = JSON.parse(frame.data);
|
|
466
|
-
if (isRecord(payload2) && payload2.id === message.id)
|
|
467
|
-
return unwrap(payload2, message.id, this.connectionName);
|
|
468
|
-
}
|
|
469
|
-
throw new Error("MCP stream ended without a response");
|
|
470
|
-
}
|
|
471
|
-
const text = await readBoundedText(response, this.options.maxResponseBytes, this.connectionName);
|
|
472
|
-
let payload;
|
|
473
|
-
try {
|
|
474
|
-
payload = JSON.parse(text);
|
|
475
|
-
} catch {
|
|
476
|
-
throw new Error(`MCP response from "${this.connectionName}" was not JSON`);
|
|
477
|
-
}
|
|
478
|
-
return unwrap(payload, message.id, this.connectionName);
|
|
479
|
-
});
|
|
480
|
-
}
|
|
481
|
-
headers(token) {
|
|
482
|
-
const headers = {
|
|
483
|
-
"content-type": "application/json",
|
|
484
|
-
accept: "application/json, text/event-stream",
|
|
485
|
-
...this.options.transport.headers
|
|
486
|
-
};
|
|
487
|
-
if (token)
|
|
488
|
-
headers.authorization = `Bearer ${token}`;
|
|
489
|
-
if (this.sessionId)
|
|
490
|
-
headers["mcp-session-id"] = this.sessionId;
|
|
491
|
-
if (this.protocolVersion)
|
|
492
|
-
headers["mcp-protocol-version"] = this.protocolVersion;
|
|
493
|
-
return headers;
|
|
494
|
-
}
|
|
495
|
-
async openSse(token, signal) {
|
|
496
|
-
this.sse?.close();
|
|
497
|
-
this.sse = new SseSession(this.connectionName, this.instanceId, {
|
|
498
|
-
baseUrl: this.options.transport.url,
|
|
499
|
-
allowedHosts: this.options.allowedHosts,
|
|
500
|
-
headers: this.headers(token),
|
|
501
|
-
timeoutMs: this.options.timeoutMs,
|
|
502
|
-
maxResponseBytes: this.options.maxResponseBytes
|
|
503
|
-
});
|
|
504
|
-
await this.sse.ready(signal);
|
|
505
|
-
}
|
|
506
|
-
async sseRequest(message, token, signal) {
|
|
507
|
-
if (!this.sse)
|
|
508
|
-
await this.openSse(token, signal);
|
|
509
|
-
const session = this.sse;
|
|
510
|
-
if (!session)
|
|
511
|
-
throw new Error("MCP SSE session failed to open");
|
|
512
|
-
return session.request(message, token, signal);
|
|
513
|
-
}
|
|
514
|
-
async safeText(response) {
|
|
515
|
-
try {
|
|
516
|
-
return (await readBoundedText(response, this.options.maxResponseBytes, this.connectionName)).slice(0, 512);
|
|
517
|
-
} catch {
|
|
518
|
-
return "";
|
|
519
|
-
}
|
|
520
|
-
}
|
|
521
|
-
}
|
|
522
|
-
|
|
523
|
-
// src/tools/connections/mcp-envelope.ts
|
|
524
|
-
function unwrapMcpResult(result) {
|
|
525
|
-
if (!isRecord(result))
|
|
526
|
-
return result;
|
|
527
|
-
if (result.structuredContent !== undefined)
|
|
528
|
-
return result.structuredContent;
|
|
529
|
-
if (!Array.isArray(result.content))
|
|
530
|
-
return result;
|
|
531
|
-
const only = result.content.length === 1 ? result.content[0] : undefined;
|
|
532
|
-
if (!isRecord(only) || only.type !== "text" || typeof only.text !== "string")
|
|
533
|
-
return result;
|
|
534
|
-
try {
|
|
535
|
-
return safeJsonParse(only.text);
|
|
536
|
-
} catch {
|
|
537
|
-
return only.text;
|
|
538
|
-
}
|
|
539
|
-
}
|
|
540
|
-
var UPSTREAM_TOOL_ERROR = "UPSTREAM_TOOL_ERROR";
|
|
541
|
-
function mcpToolFailure(toolName, result) {
|
|
542
|
-
const payload = unwrapMcpResult(result);
|
|
543
|
-
if (isRecord(payload) && typeof payload.error === "string") {
|
|
544
|
-
const details = isRecord(payload.details) ? payload.details : undefined;
|
|
545
|
-
const message = typeof details?.message === "string" ? details.message : payload.error;
|
|
546
|
-
return new AppError(payload.error, message, 502, details, typeof payload._hint === "string" ? payload._hint : undefined, undefined, typeof payload.retryable === "boolean" ? payload.retryable : undefined);
|
|
547
|
-
}
|
|
548
|
-
return new AppError(UPSTREAM_TOOL_ERROR, `External MCP tool "${toolName}" returned an error`, 502, payload === undefined ? undefined : { upstream: payload });
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
// src/tools/connections/runtime.ts
|
|
552
|
-
import { z } from "zod";
|
|
553
|
-
async function withConnectionToken(params, body) {
|
|
554
|
-
const token = await params.provider?.(params.context);
|
|
555
|
-
try {
|
|
556
|
-
return await body(token);
|
|
557
|
-
} catch (error) {
|
|
558
|
-
if (error instanceof ConnectionAuthorizationRequiredError) {
|
|
559
|
-
params.client?.teardown();
|
|
560
|
-
}
|
|
561
|
-
throw error;
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
function zodObjectFromJsonSchema(schema) {
|
|
565
|
-
if (!schema || Object.keys(schema).length === 0)
|
|
566
|
-
return z.looseObject({});
|
|
567
|
-
const parsed = z.fromJSONSchema(reconcileDefinitionKeyword(schema));
|
|
568
|
-
if (parsed instanceof z.ZodObject)
|
|
569
|
-
return parsed;
|
|
570
|
-
return z.looseObject({});
|
|
571
|
-
}
|
|
572
|
-
function reconcileDefinitionKeyword(schema) {
|
|
573
|
-
return declaresDraft07(schema.$schema) ? schema : withDefsDialect(schema);
|
|
574
|
-
}
|
|
575
|
-
function sanitizeToolName(value) {
|
|
576
|
-
return value.replace(/[^a-zA-Z0-9_-]+/g, "_").replace(/^_+|_+$/g, "") || "operation";
|
|
577
|
-
}
|
|
578
|
-
function reportSkippedConnectionTool(skipped) {
|
|
579
|
-
console.warn(`[stitchkit] connection "${skipped.connection}": tool "${skipped.tool}" not mounted — ${skipped.reason}`);
|
|
580
|
-
}
|
|
581
|
-
function mountToolsTolerantly(entries, connection, nameOf, build, onSkipped) {
|
|
582
|
-
const mounted = [];
|
|
583
|
-
for (const entry of entries) {
|
|
584
|
-
try {
|
|
585
|
-
mounted.push(build(entry));
|
|
586
|
-
} catch (error) {
|
|
587
|
-
onSkipped({
|
|
588
|
-
connection,
|
|
589
|
-
tool: nameOf(entry),
|
|
590
|
-
reason: error instanceof Error ? error.message : String(error)
|
|
591
|
-
});
|
|
592
|
-
}
|
|
593
|
-
}
|
|
594
|
-
return mounted;
|
|
595
|
-
}
|
|
596
|
-
|
|
597
|
-
// src/tools/connections/schema-budget.ts
|
|
598
|
-
var schemaBytes = new WeakMap;
|
|
599
|
-
function recordForeignSchemaBytes(tool, size) {
|
|
600
|
-
schemaBytes.set(tool, size);
|
|
601
|
-
}
|
|
602
|
-
function foreignSchemaBytes(tool) {
|
|
603
|
-
return schemaBytes.get(tool) ?? 0;
|
|
604
|
-
}
|
|
605
|
-
function jsonSchemaBytes(schema) {
|
|
606
|
-
if (!schema || Object.keys(schema).length === 0)
|
|
607
|
-
return 0;
|
|
608
|
-
return new TextEncoder().encode(JSON.stringify(schema)).byteLength;
|
|
609
|
-
}
|
|
610
|
-
|
|
611
|
-
// src/tools/connections/mcp.ts
|
|
612
|
-
async function mountMcpConnection(connection, instanceId, onSkipped) {
|
|
613
|
-
const url = assertConnectionUrl(connection.transport.url, connection.name);
|
|
614
|
-
const allowedHosts = connectionAllowedHosts(url, connection.allowHosts);
|
|
615
|
-
assertAllowedHost(url, allowedHosts, connection.name);
|
|
616
|
-
const createClient = () => new McpHttpClient(connection.name, instanceId, {
|
|
617
|
-
transport: connection.transport,
|
|
618
|
-
allowedHosts,
|
|
619
|
-
timeoutMs: connectionTimeoutMs(connection.timeoutMs),
|
|
620
|
-
maxResponseBytes: connectionMaxResponseBytes(connection.maxResponseBytes)
|
|
621
|
-
});
|
|
622
|
-
const discovery = createClient();
|
|
623
|
-
const listed = await withConnectionToken({ instanceId, provider: connection.token, client: discovery }, async (token) => {
|
|
624
|
-
await discovery.initialize(token);
|
|
625
|
-
return discovery.request("tools/list", {}, token);
|
|
626
|
-
}).finally(() => discovery.teardown());
|
|
627
|
-
const discovered = readDiscoveredTools(listed, connection.name);
|
|
628
|
-
const filtered = filterMcpTools(discovered, connection.tools);
|
|
629
|
-
return mountToolsTolerantly(filtered, connection.name, (tool) => tool.name, (tool) => {
|
|
630
|
-
const name = tool.name;
|
|
631
|
-
const description = tool.description ?? `External MCP tool "${name}"`;
|
|
632
|
-
const input = zodObjectFromJsonSchema(tool.inputSchema);
|
|
633
|
-
const definition = defineRuntimeTool({
|
|
634
|
-
name,
|
|
635
|
-
description,
|
|
636
|
-
identity: { serviceName: connection.name, action: name, method: "POST" },
|
|
637
|
-
...connection.transports && { transports: connection.transports },
|
|
638
|
-
input,
|
|
639
|
-
output: z2.unknown(),
|
|
640
|
-
handler: (context) => {
|
|
641
|
-
const client = createClient();
|
|
642
|
-
return withConnectionToken({ instanceId, provider: connection.token, client, context }, async (token) => {
|
|
643
|
-
await client.initialize(token, context.signal);
|
|
644
|
-
const result = await client.request("tools/call", { name, arguments: context.input }, token, context.signal);
|
|
645
|
-
if (isRecord(result) && result.isError === true)
|
|
646
|
-
throw mcpToolFailure(name, result);
|
|
647
|
-
return context.source === "cli" ? unwrapMcpResult(result) : result;
|
|
648
|
-
}).finally(() => client.teardown());
|
|
649
|
-
}
|
|
650
|
-
});
|
|
651
|
-
recordForeignSchemaBytes(definition, jsonSchemaBytes(tool.inputSchema));
|
|
652
|
-
return definition;
|
|
653
|
-
}, onSkipped);
|
|
654
|
-
}
|
|
655
|
-
function readDiscoveredTools(listed, connectionName) {
|
|
656
|
-
if (!isRecord(listed) || !Array.isArray(listed.tools)) {
|
|
657
|
-
throw new Error(`MCP connection "${connectionName}" returned no tools list`);
|
|
658
|
-
}
|
|
659
|
-
const tools = [];
|
|
660
|
-
for (const raw of listed.tools) {
|
|
661
|
-
if (!isRecord(raw) || typeof raw.name !== "string")
|
|
662
|
-
continue;
|
|
663
|
-
tools.push({
|
|
664
|
-
name: raw.name,
|
|
665
|
-
...typeof raw.description === "string" && { description: raw.description },
|
|
666
|
-
...isRecord(raw.inputSchema) && { inputSchema: raw.inputSchema }
|
|
667
|
-
});
|
|
668
|
-
}
|
|
669
|
-
return tools;
|
|
670
|
-
}
|
|
671
|
-
function filterMcpTools(tools, filter) {
|
|
672
|
-
const allow = filter?.allow ? new Set(filter.allow) : undefined;
|
|
673
|
-
const block = new Set(filter?.block ?? []);
|
|
674
|
-
return tools.filter((tool) => (allow === undefined || allow.has(tool.name)) && !block.has(tool.name));
|
|
675
|
-
}
|
|
676
|
-
|
|
677
|
-
// src/tools/connections/openapi.ts
|
|
678
|
-
import { z as z3 } from "zod";
|
|
679
|
-
|
|
680
|
-
// src/tools/connections/openapi-document.ts
|
|
681
|
-
function resolveOpenApiDocument(document) {
|
|
682
|
-
let nodes = 0;
|
|
683
|
-
const visit = (value, refs, depth) => {
|
|
684
|
-
if (++nodes > 1e5 || depth > 64)
|
|
685
|
-
throw new TypeError("OpenAPI document expansion exceeds its limit");
|
|
686
|
-
if (Array.isArray(value))
|
|
687
|
-
return value.map((item) => visit(item, refs, depth + 1));
|
|
688
|
-
if (!isRecord(value))
|
|
689
|
-
return value;
|
|
690
|
-
if (typeof value.$ref === "string") {
|
|
691
|
-
const ref = value.$ref;
|
|
692
|
-
if (!ref.startsWith("#/"))
|
|
693
|
-
throw new TypeError("OpenAPI external references are unsupported");
|
|
694
|
-
if (refs.includes(ref))
|
|
695
|
-
throw new TypeError("OpenAPI recursive references are unsupported");
|
|
696
|
-
let target = document;
|
|
697
|
-
for (const part of ref.slice(2).split("/").map((part2) => part2.replace(/~1/g, "/").replace(/~0/g, "~"))) {
|
|
698
|
-
if (!isRecord(target) || !Object.hasOwn(target, part))
|
|
699
|
-
throw new TypeError("OpenAPI reference does not resolve");
|
|
700
|
-
target = target[part];
|
|
701
|
-
}
|
|
702
|
-
if (!isRecord(target))
|
|
703
|
-
throw new TypeError("OpenAPI reference must resolve to an object");
|
|
704
|
-
const { $ref: _, ...siblings } = value;
|
|
705
|
-
return visit({ ...target, ...siblings }, [...refs, ref], depth + 1);
|
|
706
|
-
}
|
|
707
|
-
return Object.fromEntries(Object.entries(value).map(([key, item]) => [key, visit(item, refs, depth + 1)]));
|
|
708
|
-
};
|
|
709
|
-
const result = visit(document, [], 0);
|
|
710
|
-
if (!isRecord(result))
|
|
711
|
-
throw new TypeError("OpenAPI document must be an object");
|
|
712
|
-
return result;
|
|
713
|
-
}
|
|
714
|
-
function assertOpenApiOperation(document, operation, pathItem) {
|
|
715
|
-
for (const servers of [document.servers, pathItem.servers, operation.servers]) {
|
|
716
|
-
if (Array.isArray(servers) && servers.some((server) => isRecord(server) && typeof server.url === "string" && /[{}]/.test(server.url)))
|
|
717
|
-
throw new TypeError("OpenAPI server variables are unsupported");
|
|
718
|
-
}
|
|
719
|
-
const security = operation.security ?? document.security;
|
|
720
|
-
if (Array.isArray(security) && security.some((item) => isRecord(item) && Object.keys(item).length > 1))
|
|
721
|
-
throw new TypeError("OpenAPI combined security schemes require a custom tool");
|
|
722
|
-
const body = operation.requestBody;
|
|
723
|
-
if (isRecord(body) && (!isRecord(body.content) || !isRecord(body.content["application/json"])))
|
|
724
|
-
throw new TypeError("OpenAPI request bodies must declare application/json");
|
|
725
|
-
const names = new Map;
|
|
726
|
-
for (const source of [pathItem.parameters, operation.parameters]) {
|
|
727
|
-
if (!Array.isArray(source))
|
|
728
|
-
continue;
|
|
729
|
-
for (const parameter of source) {
|
|
730
|
-
if (!isRecord(parameter) || typeof parameter.name !== "string" || typeof parameter.in !== "string")
|
|
731
|
-
throw new TypeError("Invalid OpenAPI parameter");
|
|
732
|
-
const previous = names.get(parameter.name);
|
|
733
|
-
if (previous && previous !== parameter.in)
|
|
734
|
-
throw new TypeError("OpenAPI parameter names must be unique across locations");
|
|
735
|
-
names.set(parameter.name, parameter.in);
|
|
736
|
-
if (isRecord(parameter.schema) && (parameter.schema.type === "array" || parameter.schema.type === "object"))
|
|
737
|
-
throw new TypeError("OpenAPI structured parameter serialization is unsupported");
|
|
738
|
-
if (parameter.content)
|
|
739
|
-
throw new TypeError("OpenAPI parameter content serialization is unsupported");
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
}
|
|
743
|
-
|
|
744
|
-
// src/tools/connections/openapi.ts
|
|
745
|
-
async function mountOpenApiConnection(connection, instanceId, onSkipped) {
|
|
746
|
-
const timeoutMs = connectionTimeoutMs(connection.timeoutMs);
|
|
747
|
-
const maxResponseBytes = connectionMaxResponseBytes(connection.maxResponseBytes);
|
|
748
|
-
const loaded = await loadOpenApiDocument(connection, timeoutMs, maxResponseBytes);
|
|
749
|
-
const document = resolveOpenApiDocument(loaded.document);
|
|
750
|
-
const baseUrl = resolveBaseUrl(connection, document, loaded.url);
|
|
751
|
-
const baseHost = assertConnectionUrl(baseUrl, connection.name);
|
|
752
|
-
const allowedHosts = connectionAllowedHosts(loaded.url && !connection.baseUrl ? new URL(loaded.url) : baseHost, loaded.url ? [...connection.allowHosts ?? [], new URL(loaded.url).host] : connection.allowHosts);
|
|
753
|
-
assertAllowedHost(new URL(baseUrl), allowedHosts, connection.name);
|
|
754
|
-
const operations = collectOperations(document);
|
|
755
|
-
const names = new Set;
|
|
756
|
-
return mountToolsTolerantly(operations, connection.name, operationKey, (entry) => {
|
|
757
|
-
assertOpenApiOperation(document, entry.operation, entry.pathItem);
|
|
758
|
-
const rawName = operationKey(entry);
|
|
759
|
-
const name = uniqueToolName(connection.name, rawName, names);
|
|
760
|
-
const description = typeof entry.operation.description === "string" ? entry.operation.description : `${entry.method} ${entry.path}`;
|
|
761
|
-
const schema = operationInputSchema(document, entry);
|
|
762
|
-
const input = zodObjectFromJsonSchema(schema);
|
|
763
|
-
const auth = resolveAuth(document, entry.operation);
|
|
764
|
-
const definition = defineRuntimeTool({
|
|
765
|
-
name,
|
|
766
|
-
description,
|
|
767
|
-
identity: {
|
|
768
|
-
serviceName: connection.name,
|
|
769
|
-
action: rawName,
|
|
770
|
-
method: entry.method
|
|
771
|
-
},
|
|
772
|
-
...connection.transports && { transports: connection.transports },
|
|
773
|
-
input,
|
|
774
|
-
output: z3.unknown(),
|
|
775
|
-
handler: (context) => withConnectionToken({ instanceId, provider: connection.token, context }, async (token) => {
|
|
776
|
-
const args = isRecord(context.input) ? context.input : {};
|
|
777
|
-
const url = buildOperationUrl(baseUrl, entry, args);
|
|
778
|
-
assertAllowedHost(url, allowedHosts, connection.name);
|
|
779
|
-
const headers = { accept: "application/json" };
|
|
780
|
-
for (const parameter of operationParameters(document, entry)) {
|
|
781
|
-
const value = args[parameter.name];
|
|
782
|
-
if (value === undefined)
|
|
783
|
-
continue;
|
|
784
|
-
if (parameter.in === "query")
|
|
785
|
-
url.searchParams.set(parameter.name, String(value));
|
|
786
|
-
else if (parameter.in === "header")
|
|
787
|
-
headers[parameter.name] = String(value);
|
|
788
|
-
else if (parameter.in === "cookie") {
|
|
789
|
-
const cookie = `${parameter.name}=${encodeURIComponent(String(value))}`;
|
|
790
|
-
headers.cookie = headers.cookie ? `${headers.cookie}; ${cookie}` : cookie;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
const body = requestBody(entry.operation);
|
|
794
|
-
applyAuth(auth, token, url, headers);
|
|
795
|
-
return withConnectionDeadline(connection.name, timeoutMs, context.signal, async (signal) => {
|
|
796
|
-
const requestInit = { method: entry.method, headers, signal };
|
|
797
|
-
if (body && args.body !== undefined) {
|
|
798
|
-
headers["content-type"] = "application/json";
|
|
799
|
-
requestInit.body = JSON.stringify(args.body);
|
|
800
|
-
}
|
|
801
|
-
const response = await fetchConnection(url, requestInit, allowedHosts, connection.name);
|
|
802
|
-
if (response.status === 401) {
|
|
803
|
-
await response.body?.cancel();
|
|
804
|
-
throw new ConnectionAuthorizationRequiredError(connection.name, instanceId);
|
|
805
|
-
}
|
|
806
|
-
if (!response.ok) {
|
|
807
|
-
throw new ConnectionRequestError(connection.name, response.status, (await safeText(response, maxResponseBytes)).slice(0, 512));
|
|
808
|
-
}
|
|
809
|
-
return readResponse(response, maxResponseBytes, connection.name);
|
|
810
|
-
});
|
|
811
|
-
})
|
|
812
|
-
});
|
|
813
|
-
recordForeignSchemaBytes(definition, jsonSchemaBytes(schema));
|
|
814
|
-
return definition;
|
|
815
|
-
}, onSkipped);
|
|
816
|
-
}
|
|
817
|
-
async function loadOpenApiDocument(connection, timeoutMs, maxResponseBytes) {
|
|
818
|
-
if (typeof connection.spec === "object" && connection.spec !== null) {
|
|
819
|
-
if (!isRecord(connection.spec)) {
|
|
820
|
-
throw new Error(`OpenAPI spec of "${connection.name}" is not an object`);
|
|
821
|
-
}
|
|
822
|
-
return { document: connection.spec };
|
|
823
|
-
}
|
|
824
|
-
const text = connection.spec.trim();
|
|
825
|
-
if (text.startsWith("{")) {
|
|
826
|
-
const parsed2 = JSON.parse(text);
|
|
827
|
-
if (!isRecord(parsed2))
|
|
828
|
-
throw new Error(`OpenAPI spec of "${connection.name}" is not an object`);
|
|
829
|
-
return { document: parsed2 };
|
|
830
|
-
}
|
|
831
|
-
const url = assertConnectionUrl(text, connection.name);
|
|
832
|
-
const parsed = await withConnectionDeadline(connection.name, timeoutMs, undefined, async (signal) => {
|
|
833
|
-
const response = await fetchConnection(url, { signal }, connectionAllowedHosts(url, connection.allowHosts), connection.name);
|
|
834
|
-
if (!response.ok) {
|
|
835
|
-
throw new ConnectionRequestError(connection.name, response.status, "");
|
|
836
|
-
}
|
|
837
|
-
return readBoundedJson(response, maxResponseBytes, connection.name);
|
|
838
|
-
});
|
|
839
|
-
if (!isRecord(parsed))
|
|
840
|
-
throw new Error(`OpenAPI spec at ${url} is not an object`);
|
|
841
|
-
return { document: parsed, url: url.toString() };
|
|
842
|
-
}
|
|
843
|
-
function resolveBaseUrl(connection, document, specUrl) {
|
|
844
|
-
if (connection.baseUrl)
|
|
845
|
-
return connection.baseUrl;
|
|
846
|
-
const servers = document.servers;
|
|
847
|
-
if (Array.isArray(servers)) {
|
|
848
|
-
for (const server of servers) {
|
|
849
|
-
if (isRecord(server) && typeof server.url === "string" && server.url)
|
|
850
|
-
return server.url;
|
|
851
|
-
}
|
|
852
|
-
}
|
|
853
|
-
if (specUrl)
|
|
854
|
-
return specUrl;
|
|
855
|
-
throw new Error(`OpenAPI connection "${connection.name}" declares no baseUrl or server`);
|
|
856
|
-
}
|
|
857
|
-
function collectOperations(document) {
|
|
858
|
-
const paths = asRecord(document.paths);
|
|
859
|
-
if (!paths)
|
|
860
|
-
return [];
|
|
861
|
-
const operations = [];
|
|
862
|
-
for (const [path, rawItem] of Object.entries(paths)) {
|
|
863
|
-
const pathItem = asRecord(rawItem);
|
|
864
|
-
if (!pathItem)
|
|
865
|
-
continue;
|
|
866
|
-
for (const [rawMethod, method] of Object.entries(HTTP_METHODS)) {
|
|
867
|
-
const operation = asRecord(pathItem[rawMethod]);
|
|
868
|
-
if (!operation)
|
|
869
|
-
continue;
|
|
870
|
-
operations.push({ method, path, operation, pathItem });
|
|
871
|
-
}
|
|
872
|
-
}
|
|
873
|
-
return operations;
|
|
874
|
-
}
|
|
875
|
-
var HTTP_METHODS = {
|
|
876
|
-
get: "GET",
|
|
877
|
-
head: "HEAD",
|
|
878
|
-
post: "POST",
|
|
879
|
-
put: "PUT",
|
|
880
|
-
patch: "PATCH",
|
|
881
|
-
delete: "DELETE"
|
|
882
|
-
};
|
|
883
|
-
function operationKey(entry) {
|
|
884
|
-
const id = entry.operation.operationId;
|
|
885
|
-
if (typeof id === "string" && id.trim())
|
|
886
|
-
return id;
|
|
887
|
-
return `${entry.method}_${entry.path}`;
|
|
888
|
-
}
|
|
889
|
-
function uniqueToolName(connectionName, rawName, used) {
|
|
890
|
-
const base = `${sanitizeToolName(connectionName)}__${sanitizeToolName(rawName)}`;
|
|
891
|
-
if (!used.has(base)) {
|
|
892
|
-
used.add(base);
|
|
893
|
-
return base;
|
|
894
|
-
}
|
|
895
|
-
let suffix = 2;
|
|
896
|
-
while (used.has(`${base}_${suffix}`))
|
|
897
|
-
suffix += 1;
|
|
898
|
-
const name = `${base}_${suffix}`;
|
|
899
|
-
used.add(name);
|
|
900
|
-
return name;
|
|
901
|
-
}
|
|
902
|
-
function operationParameters(document, entry) {
|
|
903
|
-
const merged = new Map;
|
|
904
|
-
for (const source of [entry.pathItem.parameters, entry.operation.parameters]) {
|
|
905
|
-
if (!Array.isArray(source))
|
|
906
|
-
continue;
|
|
907
|
-
for (const raw of source) {
|
|
908
|
-
const parameter = asRecord(raw);
|
|
909
|
-
if (!parameter || typeof parameter.name !== "string")
|
|
910
|
-
continue;
|
|
911
|
-
const location = parameter.in;
|
|
912
|
-
if (location !== "path" && location !== "query" && location !== "header" && location !== "cookie") {
|
|
913
|
-
continue;
|
|
914
|
-
}
|
|
915
|
-
const resolved = resolveRef(document, asRecord(parameter.schema));
|
|
916
|
-
merged.set(`${location}:${parameter.name}`, {
|
|
917
|
-
name: parameter.name,
|
|
918
|
-
in: location,
|
|
919
|
-
required: parameter.required === true || location === "path",
|
|
920
|
-
...resolved && { schema: resolved }
|
|
921
|
-
});
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
return [...merged.values()];
|
|
925
|
-
}
|
|
926
|
-
function requestBody(operation) {
|
|
927
|
-
const body = asRecord(operation.requestBody);
|
|
928
|
-
if (!body)
|
|
929
|
-
return false;
|
|
930
|
-
const content = asRecord(body.content);
|
|
931
|
-
return Boolean(content && isRecord(content["application/json"]));
|
|
932
|
-
}
|
|
933
|
-
function operationInputSchema(document, entry) {
|
|
934
|
-
const properties = {};
|
|
935
|
-
const required = [];
|
|
936
|
-
for (const parameter of operationParameters(document, entry)) {
|
|
937
|
-
properties[parameter.name] = parameter.schema ?? { type: "string" };
|
|
938
|
-
if (parameter.required)
|
|
939
|
-
required.push(parameter.name);
|
|
940
|
-
}
|
|
941
|
-
const body = asRecord(entry.operation.requestBody);
|
|
942
|
-
const content = body ? asRecord(body.content) : undefined;
|
|
943
|
-
const json = content ? asRecord(content["application/json"]) : undefined;
|
|
944
|
-
if (body && json) {
|
|
945
|
-
properties.body = resolveRef(document, asRecord(json.schema)) ?? {};
|
|
946
|
-
if (body.required === true)
|
|
947
|
-
required.push("body");
|
|
948
|
-
}
|
|
949
|
-
return {
|
|
950
|
-
type: "object",
|
|
951
|
-
properties,
|
|
952
|
-
...required.length > 0 && { required }
|
|
953
|
-
};
|
|
954
|
-
}
|
|
955
|
-
function resolveRef(document, node) {
|
|
956
|
-
if (!node)
|
|
957
|
-
return;
|
|
958
|
-
const ref = node.$ref;
|
|
959
|
-
if (typeof ref !== "string" || !ref.startsWith("#/"))
|
|
960
|
-
return node;
|
|
961
|
-
const segments = ref.slice(2).split("/").map((segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~"));
|
|
962
|
-
let current = document;
|
|
963
|
-
for (const segment of segments) {
|
|
964
|
-
if (!isRecord(current))
|
|
965
|
-
return;
|
|
966
|
-
current = current[segment];
|
|
967
|
-
}
|
|
968
|
-
return asRecord(current);
|
|
969
|
-
}
|
|
970
|
-
function resolveAuth(document, operation) {
|
|
971
|
-
const security = operation.security ?? document.security;
|
|
972
|
-
if (!Array.isArray(security))
|
|
973
|
-
return;
|
|
974
|
-
for (const requirement of security) {
|
|
975
|
-
const record = asRecord(requirement);
|
|
976
|
-
if (!record)
|
|
977
|
-
continue;
|
|
978
|
-
const schemeName = Object.keys(record)[0];
|
|
979
|
-
if (!schemeName)
|
|
980
|
-
return;
|
|
981
|
-
const scheme = asRecord(asRecord(asRecord(document.components)?.securitySchemes)?.[schemeName]);
|
|
982
|
-
if (!scheme)
|
|
983
|
-
continue;
|
|
984
|
-
const type = scheme.type;
|
|
985
|
-
if (type === "apiKey") {
|
|
986
|
-
const placement = scheme.in;
|
|
987
|
-
const headerName = scheme.name;
|
|
988
|
-
if (typeof headerName === "string" && (placement === "header" || placement === "query" || placement === "cookie")) {
|
|
989
|
-
return { placement, name: headerName, scheme: "apikey" };
|
|
990
|
-
}
|
|
991
|
-
continue;
|
|
992
|
-
}
|
|
993
|
-
if (type === "http") {
|
|
994
|
-
const httpScheme = typeof scheme.scheme === "string" ? scheme.scheme.toLowerCase() : "";
|
|
995
|
-
if (httpScheme === "basic")
|
|
996
|
-
return { placement: "header", name: "authorization", scheme: "basic" };
|
|
997
|
-
if (httpScheme === "bearer")
|
|
998
|
-
return { placement: "header", name: "authorization", scheme: "bearer" };
|
|
999
|
-
continue;
|
|
1000
|
-
}
|
|
1001
|
-
if (type === "oauth2" || type === "openIdConnect") {
|
|
1002
|
-
return { placement: "header", name: "authorization", scheme: "bearer" };
|
|
1003
|
-
}
|
|
1004
|
-
}
|
|
1005
|
-
if (security.length > 0)
|
|
1006
|
-
throw new TypeError("OpenAPI security has no supported alternative");
|
|
1007
|
-
return;
|
|
1008
|
-
}
|
|
1009
|
-
function applyAuth(auth, token, url, headers) {
|
|
1010
|
-
if (!auth || token === undefined)
|
|
1011
|
-
return;
|
|
1012
|
-
const value = auth.scheme === "basic" ? `Basic ${btoa(token)}` : auth.scheme === "bearer" ? `Bearer ${token}` : token;
|
|
1013
|
-
if (auth.placement === "query")
|
|
1014
|
-
url.searchParams.set(auth.name, value);
|
|
1015
|
-
else if (auth.placement === "cookie") {
|
|
1016
|
-
headers.cookie = headers.cookie ? `${headers.cookie}; ${auth.name}=${value}` : `${auth.name}=${value}`;
|
|
1017
|
-
} else
|
|
1018
|
-
headers[auth.name] = value;
|
|
1019
|
-
}
|
|
1020
|
-
function operationServerUrl(entry) {
|
|
1021
|
-
for (const source of [entry.operation.servers, entry.pathItem.servers]) {
|
|
1022
|
-
if (!Array.isArray(source))
|
|
1023
|
-
continue;
|
|
1024
|
-
for (const server of source) {
|
|
1025
|
-
if (isRecord(server) && typeof server.url === "string" && server.url)
|
|
1026
|
-
return server.url;
|
|
1027
|
-
}
|
|
1028
|
-
}
|
|
1029
|
-
return;
|
|
1030
|
-
}
|
|
1031
|
-
function buildOperationUrl(baseUrl, entry, args) {
|
|
1032
|
-
let path = entry.path;
|
|
1033
|
-
for (const parameter of operationParameters({}, entry)) {
|
|
1034
|
-
if (parameter.in !== "path")
|
|
1035
|
-
continue;
|
|
1036
|
-
const value = args[parameter.name];
|
|
1037
|
-
if (value === undefined)
|
|
1038
|
-
continue;
|
|
1039
|
-
path = path.replace(`{${parameter.name}}`, encodeURIComponent(String(value)));
|
|
1040
|
-
}
|
|
1041
|
-
const origin = operationServerUrl(entry) ?? baseUrl;
|
|
1042
|
-
const resolved = `${origin.replace(/\/+$/, "")}/${path.replace(/^\/+/, "")}`;
|
|
1043
|
-
return new URL(resolved);
|
|
1044
|
-
}
|
|
1045
|
-
async function readResponse(response, maxBytes, connectionName) {
|
|
1046
|
-
if (response.status === 204)
|
|
1047
|
-
return null;
|
|
1048
|
-
const contentType = response.headers.get("content-type") ?? "";
|
|
1049
|
-
if (contentType.includes("json"))
|
|
1050
|
-
return readBoundedJson(response, maxBytes, connectionName);
|
|
1051
|
-
return readBoundedText(response, maxBytes, connectionName);
|
|
1052
|
-
}
|
|
1053
|
-
async function safeText(response, maxBytes) {
|
|
1054
|
-
try {
|
|
1055
|
-
return await readBoundedText(response, maxBytes, "response");
|
|
1056
|
-
} catch {
|
|
1057
|
-
return "";
|
|
1058
|
-
}
|
|
1059
|
-
}
|
|
1060
|
-
function asRecord(value) {
|
|
1061
|
-
return isRecord(value) ? value : undefined;
|
|
1062
|
-
}
|
|
1063
|
-
|
|
1064
|
-
// src/tools/connections/mount.ts
|
|
1065
|
-
async function mountConnections(connections, options = {}) {
|
|
1066
|
-
const tools = [];
|
|
1067
|
-
const onSkipped = options.onSkippedTool ?? reportSkippedConnectionTool;
|
|
1068
|
-
for (const connection of connections) {
|
|
1069
|
-
const instanceId = instanceIdOf(connection);
|
|
1070
|
-
const mounted = connection.kind === "mcp" ? await mountMcpConnection(connection, instanceId, onSkipped) : await mountOpenApiConnection(connection, instanceId, onSkipped);
|
|
1071
|
-
tools.push(...mounted);
|
|
1072
|
-
}
|
|
1073
|
-
const limit = options.budget?.maxTools;
|
|
1074
|
-
if (limit !== undefined && tools.length > limit) {
|
|
1075
|
-
throw new ConnectionBudgetExceededError(limit, tools.length);
|
|
1076
|
-
}
|
|
1077
|
-
const schemaLimit = options.budget?.maxSchemaBytes;
|
|
1078
|
-
if (schemaLimit !== undefined) {
|
|
1079
|
-
const schemaBytes2 = tools.reduce((total, tool) => total + foreignSchemaBytes(tool), 0);
|
|
1080
|
-
if (schemaBytes2 > schemaLimit) {
|
|
1081
|
-
throw new ConnectionBudgetExceededError(schemaLimit, schemaBytes2, "schema bytes");
|
|
1082
|
-
}
|
|
1083
|
-
}
|
|
1084
|
-
return tools;
|
|
1085
|
-
}
|
|
1086
|
-
function instanceIdOf(connection) {
|
|
1087
|
-
let url;
|
|
1088
|
-
if (connection.kind === "mcp") {
|
|
1089
|
-
url = connection.transport.url;
|
|
1090
|
-
} else if (connection.baseUrl) {
|
|
1091
|
-
url = connection.baseUrl;
|
|
1092
|
-
} else if (typeof connection.spec === "string") {
|
|
1093
|
-
url = connection.spec;
|
|
1094
|
-
} else {
|
|
1095
|
-
url = JSON.stringify(connection.spec);
|
|
1096
|
-
}
|
|
1097
|
-
return connectionInstanceId(connection.name, url, connection.instanceKey);
|
|
1098
|
-
}
|
|
1099
|
-
export {
|
|
1100
|
-
mountConnections,
|
|
1101
|
-
defineOpenApiConnection,
|
|
1102
|
-
defineMcpClientConnection,
|
|
1103
|
-
ConnectionUrlError,
|
|
1104
|
-
ConnectionRequestError,
|
|
1105
|
-
ConnectionBudgetExceededError,
|
|
1106
|
-
ConnectionAuthorizationRequiredError
|
|
1107
|
-
};
|