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