stitchkit 0.94.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 +64 -0
- package/dist/agent-runtime/coding-shell-process.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 +3 -2
- package/dist/agent-runtime/deferred-tool-types.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/runtime.d.ts +1 -1
- 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/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.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.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/kernel-resource-context.d.ts.map +1 -1
- package/dist/application/notification-outbox.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 +2 -2
- 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.d.ts +3 -2
- package/dist/browser/client.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 +1 -3
- 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/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 +2 -18
- package/dist/browser/socket-io.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 +3 -357
- package/dist/contract/define.d.ts.map +1 -1
- 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 +15 -2
- package/dist/contract/tool-view.d.ts.map +1 -1
- package/dist/durability/contract.d.ts +83 -0
- package/dist/durability/contract.d.ts.map +1 -1
- package/dist/durability/effect.d.ts +24 -0
- package/dist/durability/effect.d.ts.map +1 -0
- package/dist/durability/engine.d.ts +2 -2
- package/dist/durability/engine.d.ts.map +1 -1
- package/dist/durability/events.d.ts +2 -0
- package/dist/durability/events.d.ts.map +1 -1
- package/dist/durability/ledger.d.ts +11 -0
- package/dist/durability/ledger.d.ts.map +1 -1
- package/dist/durability/parks.d.ts +22 -0
- package/dist/durability/parks.d.ts.map +1 -0
- package/dist/durability/scheduler.d.ts +1 -0
- package/dist/durability/scheduler.d.ts.map +1 -1
- package/dist/entrypoints/agent-runtime/coding-tools.js +4 -4
- package/dist/entrypoints/agent-runtime/harness.js +127 -116
- package/dist/entrypoints/agent-runtime/sandbox.js +4 -4
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +3 -3
- package/dist/entrypoints/agent-runtime/sqlite/node.js +3 -3
- package/dist/entrypoints/agent-runtime/testing.js +246 -214
- package/dist/entrypoints/agent-runtime.js +224 -203
- package/dist/entrypoints/application/diagnostic-journal.js +63 -203
- package/dist/entrypoints/application/opentelemetry.js +1 -1
- package/dist/entrypoints/application.js +361 -324
- package/dist/entrypoints/cli.d.ts +4 -1
- package/dist/entrypoints/cli.d.ts.map +1 -1
- package/dist/entrypoints/cli.js +57 -35
- package/dist/entrypoints/contract.d.ts +5 -2
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +3 -2
- package/dist/entrypoints/files.d.ts +2 -0
- package/dist/entrypoints/files.d.ts.map +1 -1
- package/dist/entrypoints/files.js +98 -2
- package/dist/entrypoints/index.d.ts +4 -2
- package/dist/entrypoints/index.d.ts.map +1 -1
- package/dist/entrypoints/index.js +348 -282
- package/dist/entrypoints/live.js +89 -71
- package/dist/entrypoints/node.d.ts +2 -1
- package/dist/entrypoints/node.d.ts.map +1 -1
- package/dist/entrypoints/node.js +13 -12
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +4 -4
- package/dist/entrypoints/server.d.ts +4 -2
- package/dist/entrypoints/server.d.ts.map +1 -1
- package/dist/entrypoints/server.js +293 -79
- package/dist/entrypoints/testing.d.ts +2 -1
- package/dist/entrypoints/testing.d.ts.map +1 -1
- package/dist/entrypoints/testing.js +288 -281
- package/dist/entrypoints/tools/connections.js +2 -2
- package/dist/entrypoints/tools/invoker.js +4 -4
- package/dist/entrypoints/tools.d.ts +6 -3
- package/dist/entrypoints/tools.d.ts.map +1 -1
- package/dist/entrypoints/tools.js +245 -202
- package/dist/entrypoints/tracking.js +325 -274
- 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/index-1j8pm5t0.js +412 -0
- package/dist/{index-kvj7f4hq.js → index-2bxbyab0.js} +10 -2
- package/dist/{index-xnj9bgxe.js → index-2gxzjvyr.js} +2 -162
- package/dist/index-4gcnakhx.js +82 -0
- package/dist/{index-j05z5gn4.js → index-55hkhm67.js} +136 -119
- package/dist/{index-cq4qfycf.js → index-79z7m7dt.js} +227 -59
- package/dist/{index-97ac4gph.js → index-7f68ghdn.js} +3 -3
- package/dist/{index-r7nmqpsg.js → index-7p1f0vp2.js} +1 -1
- package/dist/{index-dcpdvjsc.js → index-863ea9jb.js} +4 -4
- package/dist/index-8p52kd5p.js +242 -0
- package/dist/{index-2qzskm8h.js → index-dce5wxcq.js} +1 -1
- package/dist/index-e01r054k.js +105 -0
- package/dist/{index-sees8yf8.js → index-ensd0r74.js} +118 -111
- package/dist/{index-1nd48tm9.js → index-gxrt5h6v.js} +2 -1
- package/dist/{index-e87kakm4.js → index-ham5sz8m.js} +112 -110
- package/dist/{index-kj2wbeta.js → index-het2he5g.js} +280 -196
- package/dist/{index-vcvkq30w.js → index-hmp4800j.js} +3 -3
- package/dist/{index-gyr48nzg.js → index-k30h66yd.js} +71 -151
- package/dist/{index-2cr1cqhn.js → index-khtgb21r.js} +2 -2
- package/dist/{index-x4799c19.js → index-ndddxtyx.js} +11 -11
- package/dist/{index-dydjcp8z.js → index-np4m8hd3.js} +38 -36
- package/dist/{index-p81267c2.js → index-p3vsv1fb.js} +621 -357
- package/dist/{index-mp5sn43f.js → index-p9e0w8hs.js} +2 -2
- package/dist/{index-rewkc2hj.js → index-p9sh0xx4.js} +3 -3
- package/dist/{index-70yj2ebz.js → index-paz6sgdp.js} +107 -103
- package/dist/{index-bn2cjajt.js → index-px2gm2jp.js} +26 -102
- package/dist/index-s812ycat.js +65 -0
- package/dist/{index-xsqjkha9.js → index-sp1tzwnb.js} +2 -2
- package/dist/{index-n6hxg8as.js → index-t9rhjr9f.js} +615 -566
- package/dist/{index-zeemqhqx.js → index-v260df89.js} +88 -80
- package/dist/{index-fdp6hdxn.js → index-w906953s.js} +5 -1
- package/dist/{index-mdzh02yc.js → index-wdkt63w3.js} +1 -1
- package/dist/{index-58k4fp34.js → index-wsm5w4ee.js} +1 -1
- package/dist/{index-v38qyerb.js → index-xw3s75nj.js} +1 -1
- package/dist/internal/atomic-file.d.ts +23 -2
- package/dist/internal/atomic-file.d.ts.map +1 -1
- package/dist/internal/exclusive-lock.d.ts +51 -0
- package/dist/internal/exclusive-lock.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/with-exclusive-lock.d.ts +67 -0
- package/dist/internal/with-exclusive-lock.d.ts.map +1 -0
- package/dist/live/watch-client.d.ts.map +1 -1
- package/dist/observability/audit.d.ts +2 -2
- package/dist/observability/audit.d.ts.map +1 -1
- package/dist/observability/event.d.ts +2 -1
- package/dist/observability/event.d.ts.map +1 -1
- package/dist/primitives/export-operation.d.ts +1 -1
- 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/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 +1 -1
- package/dist/server/context.d.ts.map +1 -1
- package/dist/server/endpoint-response.d.ts +2 -1
- package/dist/server/endpoint-response.d.ts.map +1 -1
- package/dist/server/error-dispatch.d.ts +1 -1
- package/dist/server/error-dispatch.d.ts.map +1 -1
- package/dist/server/error-hook.d.ts +1 -1
- package/dist/server/error-hook.d.ts.map +1 -1
- package/dist/server/handler-state.d.ts +1 -1
- package/dist/server/handler-state.d.ts.map +1 -1
- 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/jwt.d.ts +31 -0
- package/dist/server/middleware/jwt.d.ts.map +1 -0
- 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/provider.d.ts +1 -68
- package/dist/server/oauth/provider.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 +4 -1
- 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 +2 -1
- package/dist/testing/handler-clients.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 +0 -31
- 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.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 +2 -65
- package/dist/tools/cli/args.d.ts.map +1 -1
- 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.map +1 -1
- package/dist/tools/cli/command.d.ts +1 -1
- package/dist/tools/cli/command.d.ts.map +1 -1
- package/dist/tools/cli/config.d.ts +1 -1
- package/dist/tools/cli/config.d.ts.map +1 -1
- package/dist/tools/cli/format.d.ts +2 -1
- package/dist/tools/cli/format.d.ts.map +1 -1
- package/dist/tools/cli/invoke.d.ts +2 -1
- package/dist/tools/cli/invoke.d.ts.map +1 -1
- package/dist/tools/cli/managed-surface.d.ts +1 -1
- package/dist/tools/cli/managed-surface.d.ts.map +1 -1
- package/dist/tools/cli/policy.d.ts +1 -1
- package/dist/tools/cli/policy.d.ts.map +1 -1
- package/dist/tools/cli/prepare.d.ts.map +1 -1
- package/dist/tools/cli/run-managed.d.ts.map +1 -1
- package/dist/tools/cli/session.d.ts +1 -1
- package/dist/tools/cli/session.d.ts.map +1 -1
- package/dist/tools/cli/update.d.ts +19 -0
- package/dist/tools/cli/update.d.ts.map +1 -1
- package/dist/tools/cli/view.d.ts +1 -1
- package/dist/tools/cli/view.d.ts.map +1 -1
- package/dist/tools/cli/wait.d.ts +1 -1
- package/dist/tools/cli/wait.d.ts.map +1 -1
- package/dist/tools/connections/runtime.d.ts +1 -1
- package/dist/tools/connections/runtime.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 +4 -193
- package/dist/tools/execute.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts +2 -1
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/invoker.d.ts +2 -1
- 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/mcp/mount.d.ts +1 -1
- package/dist/tools/mcp/mount.d.ts.map +1 -1
- package/dist/tools/mcp/prepare.d.ts +2 -1
- package/dist/tools/mcp/prepare.d.ts.map +1 -1
- package/dist/tools/mcp/progress.d.ts +1 -1
- package/dist/tools/mcp/progress.d.ts.map +1 -1
- package/dist/tools/mcp/register.d.ts +3 -2
- package/dist/tools/mcp/register.d.ts.map +1 -1
- 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 +1 -1
- package/dist/tools/mcp/round-policy.d.ts.map +1 -1
- package/dist/tools/mcp/round.d.ts +3 -11
- package/dist/tools/mcp/round.d.ts.map +1 -1
- package/dist/tools/mcp/runtime-tools.d.ts +2 -1
- package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
- package/dist/tools/mount.d.ts +3 -1
- package/dist/tools/mount.d.ts.map +1 -1
- package/dist/tools/native-definition.d.ts +2 -1
- package/dist/tools/native-definition.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts +2 -1
- package/dist/tools/operations/async-operation-runtime-tools.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts +2 -1
- package/dist/tools/operations/async-operation-runtime-types.d.ts.map +1 -1
- package/dist/tools/remote.d.ts.map +1 -1
- package/dist/tools/runtime-tool.d.ts +3 -1
- package/dist/tools/runtime-tool.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/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/llms/application.2.txt +266 -2
- package/llms/application.txt +8 -266
- package/llms/cli.2.txt +80 -0
- package/llms/cli.txt +45 -74
- package/llms/contract.txt +3 -3
- package/llms/files.txt +3 -0
- package/llms/tools.2.txt +88 -279
- package/llms/tools.3.txt +288 -0
- package/llms/tools.txt +27 -65
- package/llms-full.txt +108 -12
- package/llms.txt +5 -5
- package/package.json +1 -1
- package/dist/index-e2z3ahw9.js +0 -325
- package/dist/index-mkm15s49.js +0 -394
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ManagedFileError
|
|
3
|
-
} from "../index-
|
|
3
|
+
} from "../index-paz6sgdp.js";
|
|
4
4
|
import {
|
|
5
5
|
signJwt,
|
|
6
6
|
verifyPkce
|
|
7
|
-
} from "../index-
|
|
7
|
+
} from "../index-e01r054k.js";
|
|
8
8
|
import"../index-hr4tzbwq.js";
|
|
9
9
|
import {
|
|
10
10
|
DEFAULT_CORS_ALLOW_HEADERS,
|
|
@@ -14,8 +14,8 @@ import {
|
|
|
14
14
|
guardSignalCallback,
|
|
15
15
|
mediaTypeEssence,
|
|
16
16
|
reportSignalError
|
|
17
|
-
} from "../index-
|
|
18
|
-
import"../index-
|
|
17
|
+
} from "../index-2gxzjvyr.js";
|
|
18
|
+
import"../index-2bxbyab0.js";
|
|
19
19
|
import {
|
|
20
20
|
redact
|
|
21
21
|
} from "../index-yw4fzmdz.js";
|
|
@@ -23,18 +23,20 @@ import {
|
|
|
23
23
|
buildToolManifest,
|
|
24
24
|
describeToolCatalog,
|
|
25
25
|
mountAgent
|
|
26
|
-
} from "../index-
|
|
26
|
+
} from "../index-863ea9jb.js";
|
|
27
27
|
import {
|
|
28
28
|
AgentToolError,
|
|
29
|
+
EffectUnresolvedError,
|
|
29
30
|
createLocalStepDurability,
|
|
30
31
|
isAgentToolError
|
|
31
|
-
} from "../index-
|
|
32
|
+
} from "../index-79z7m7dt.js";
|
|
32
33
|
import"../index-rxfy4cq7.js";
|
|
33
34
|
import {
|
|
34
35
|
ALL_TRANSPORTS,
|
|
35
36
|
TOOL_TRANSPORTS,
|
|
36
37
|
defineContract
|
|
37
|
-
} from "../index-
|
|
38
|
+
} from "../index-k30h66yd.js";
|
|
39
|
+
import"../index-4gcnakhx.js";
|
|
38
40
|
import {
|
|
39
41
|
ManagedFilePathSchema,
|
|
40
42
|
ManagedFileRefSchema
|
|
@@ -50,7 +52,7 @@ import {
|
|
|
50
52
|
} from "../index-m9zn6cpq.js";
|
|
51
53
|
import {
|
|
52
54
|
createToolInvoker
|
|
53
|
-
} from "../index-
|
|
55
|
+
} from "../index-p9sh0xx4.js";
|
|
54
56
|
import {
|
|
55
57
|
WaitTimeoutError,
|
|
56
58
|
createCli,
|
|
@@ -58,11 +60,11 @@ import {
|
|
|
58
60
|
fetchPinnedDocument,
|
|
59
61
|
readCapped,
|
|
60
62
|
runWaitOperation
|
|
61
|
-
} from "../index-
|
|
63
|
+
} from "../index-t9rhjr9f.js";
|
|
62
64
|
import"../index-sbdmyz75.js";
|
|
63
65
|
import {
|
|
64
66
|
collectToolSurface
|
|
65
|
-
} from "../index-
|
|
67
|
+
} from "../index-hmp4800j.js";
|
|
66
68
|
import {
|
|
67
69
|
argumentsDigest
|
|
68
70
|
} from "../index-0b1ess5e.js";
|
|
@@ -70,13 +72,13 @@ import {
|
|
|
70
72
|
collectTools,
|
|
71
73
|
createToolRunner,
|
|
72
74
|
formatToolError
|
|
73
|
-
} from "../index-
|
|
75
|
+
} from "../index-khtgb21r.js";
|
|
74
76
|
import {
|
|
75
77
|
ToolExecutionControlError,
|
|
76
78
|
isToolExecutionControlError,
|
|
77
79
|
parseToolCallArguments,
|
|
78
80
|
toolResultFromError
|
|
79
|
-
} from "../index-
|
|
81
|
+
} from "../index-55hkhm67.js";
|
|
80
82
|
import {
|
|
81
83
|
getRequestContext,
|
|
82
84
|
getTraceId,
|
|
@@ -92,7 +94,7 @@ import {
|
|
|
92
94
|
import {
|
|
93
95
|
createRuntimeToolFactory,
|
|
94
96
|
defineRuntimeTool
|
|
95
|
-
} from "../index-
|
|
97
|
+
} from "../index-xw3s75nj.js";
|
|
96
98
|
import {
|
|
97
99
|
PORTABLE_JSON_SCHEMA_FORMATS,
|
|
98
100
|
assertToolName,
|
|
@@ -106,7 +108,7 @@ import {
|
|
|
106
108
|
toolSurfaceOutputSchema,
|
|
107
109
|
validateMcpRoundPolicy,
|
|
108
110
|
validateResolvedInputRounds
|
|
109
|
-
} from "../index-
|
|
111
|
+
} from "../index-np4m8hd3.js";
|
|
110
112
|
import {
|
|
111
113
|
toJsonSchema
|
|
112
114
|
} from "../index-eqqvgdb3.js";
|
|
@@ -126,47 +128,7 @@ import"../index-kzfs85xp.js";
|
|
|
126
128
|
import {
|
|
127
129
|
isRecord
|
|
128
130
|
} from "../index-hffjpmq9.js";
|
|
129
|
-
// src/server/oauth/
|
|
130
|
-
var PROTECTED_RESOURCE_PATH = "/.well-known/oauth-protected-resource";
|
|
131
|
-
function metadataPath(resource) {
|
|
132
|
-
const { pathname } = new URL(resource);
|
|
133
|
-
return pathname === "/" ? PROTECTED_RESOURCE_PATH : `${PROTECTED_RESOURCE_PATH}${pathname}`;
|
|
134
|
-
}
|
|
135
|
-
function protectedResourceMetadataUrl(resource) {
|
|
136
|
-
return `${new URL(resource).origin}${metadataPath(resource)}`;
|
|
137
|
-
}
|
|
138
|
-
function wwwAuthenticateHeader(resource) {
|
|
139
|
-
return `Bearer resource_metadata="${protectedResourceMetadataUrl(resource)}"`;
|
|
140
|
-
}
|
|
141
|
-
var PUBLIC_CORS = {
|
|
142
|
-
"Access-Control-Allow-Origin": "*",
|
|
143
|
-
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
144
|
-
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS
|
|
145
|
-
};
|
|
146
|
-
function oauthProtectedResourceRoute(config) {
|
|
147
|
-
const body = JSON.stringify({
|
|
148
|
-
resource: config.resource,
|
|
149
|
-
authorization_servers: config.authorizationServers,
|
|
150
|
-
...config.scopesSupported && { scopes_supported: config.scopesSupported },
|
|
151
|
-
bearer_methods_supported: ["header"]
|
|
152
|
-
});
|
|
153
|
-
return {
|
|
154
|
-
method: "ALL",
|
|
155
|
-
path: metadataPath(config.resource),
|
|
156
|
-
handler: (req) => {
|
|
157
|
-
if (req.method === "OPTIONS")
|
|
158
|
-
return new Response(null, { status: 204, headers: PUBLIC_CORS });
|
|
159
|
-
if (req.method !== "GET")
|
|
160
|
-
return new Response("Method Not Allowed", { status: 405 });
|
|
161
|
-
return new Response(body, {
|
|
162
|
-
status: 200,
|
|
163
|
-
headers: { "Content-Type": "application/json", ...PUBLIC_CORS }
|
|
164
|
-
});
|
|
165
|
-
}
|
|
166
|
-
};
|
|
167
|
-
}
|
|
168
|
-
// src/server/oauth/provider.ts
|
|
169
|
-
import { randomUUID } from "node:crypto";
|
|
131
|
+
// src/server/oauth/cimd.ts
|
|
170
132
|
import { z } from "zod";
|
|
171
133
|
function isPlainDisplayCharacter(character) {
|
|
172
134
|
const codePoint = character.codePointAt(0);
|
|
@@ -195,13 +157,6 @@ function createSecureClientMetadataFetcher(policy = {}) {
|
|
|
195
157
|
})
|
|
196
158
|
};
|
|
197
159
|
}
|
|
198
|
-
var PUBLIC_CORS2 = {
|
|
199
|
-
"Access-Control-Allow-Origin": "*",
|
|
200
|
-
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
201
|
-
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS
|
|
202
|
-
};
|
|
203
|
-
var AS_METADATA_PATH = "/.well-known/oauth-authorization-server";
|
|
204
|
-
var AUTH_CODE_TTL_MS = 60000;
|
|
205
160
|
var DEFAULT_CIMD_MAX_BYTES = 64 * 1024;
|
|
206
161
|
var DEFAULT_CIMD_TIMEOUT_MS = 5000;
|
|
207
162
|
function assertPositiveInteger(name, value) {
|
|
@@ -280,17 +235,6 @@ function responseFreshness(headers, policy, now) {
|
|
|
280
235
|
}
|
|
281
236
|
return { freshnessMs: Math.min(maxTtl, policy.defaultTtlMs ?? 300000), store: true };
|
|
282
237
|
}
|
|
283
|
-
function safeClientName(value) {
|
|
284
|
-
if (value === undefined)
|
|
285
|
-
return;
|
|
286
|
-
const safe = Array.from(value).filter(isPlainDisplayCharacter).join("").trim().slice(0, 200);
|
|
287
|
-
return safe || undefined;
|
|
288
|
-
}
|
|
289
|
-
function parseScopes(value) {
|
|
290
|
-
if (!value)
|
|
291
|
-
return [];
|
|
292
|
-
return [...new Set(value.split(/\s+/u).filter(Boolean))];
|
|
293
|
-
}
|
|
294
238
|
function toRegisteredClient(metadata) {
|
|
295
239
|
return {
|
|
296
240
|
clientId: metadata.client_id,
|
|
@@ -467,15 +411,6 @@ function createCimdResolver(options) {
|
|
|
467
411
|
return created;
|
|
468
412
|
};
|
|
469
413
|
}
|
|
470
|
-
function json(body, status = 200, extraHeaders) {
|
|
471
|
-
return new Response(JSON.stringify(body), {
|
|
472
|
-
status,
|
|
473
|
-
headers: { "Content-Type": "application/json", ...PUBLIC_CORS2, ...extraHeaders }
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
function oauthError(error, description, status = 400) {
|
|
477
|
-
return json({ error, error_description: description }, status);
|
|
478
|
-
}
|
|
479
414
|
function isRegistrableRedirectUri(value, applicationType) {
|
|
480
415
|
try {
|
|
481
416
|
const url = new URL(value);
|
|
@@ -504,6 +439,74 @@ function isLoopbackRedirectUri(value) {
|
|
|
504
439
|
return false;
|
|
505
440
|
}
|
|
506
441
|
}
|
|
442
|
+
// src/server/oauth/metadata.ts
|
|
443
|
+
var PROTECTED_RESOURCE_PATH = "/.well-known/oauth-protected-resource";
|
|
444
|
+
function metadataPath(resource) {
|
|
445
|
+
const { pathname } = new URL(resource);
|
|
446
|
+
return pathname === "/" ? PROTECTED_RESOURCE_PATH : `${PROTECTED_RESOURCE_PATH}${pathname}`;
|
|
447
|
+
}
|
|
448
|
+
function protectedResourceMetadataUrl(resource) {
|
|
449
|
+
return `${new URL(resource).origin}${metadataPath(resource)}`;
|
|
450
|
+
}
|
|
451
|
+
function wwwAuthenticateHeader(resource) {
|
|
452
|
+
return `Bearer resource_metadata="${protectedResourceMetadataUrl(resource)}"`;
|
|
453
|
+
}
|
|
454
|
+
var PUBLIC_CORS = {
|
|
455
|
+
"Access-Control-Allow-Origin": "*",
|
|
456
|
+
"Access-Control-Allow-Methods": "GET, OPTIONS",
|
|
457
|
+
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS
|
|
458
|
+
};
|
|
459
|
+
function oauthProtectedResourceRoute(config) {
|
|
460
|
+
const body = JSON.stringify({
|
|
461
|
+
resource: config.resource,
|
|
462
|
+
authorization_servers: config.authorizationServers,
|
|
463
|
+
...config.scopesSupported && { scopes_supported: config.scopesSupported },
|
|
464
|
+
bearer_methods_supported: ["header"]
|
|
465
|
+
});
|
|
466
|
+
return {
|
|
467
|
+
method: "ALL",
|
|
468
|
+
path: metadataPath(config.resource),
|
|
469
|
+
handler: (req) => {
|
|
470
|
+
if (req.method === "OPTIONS")
|
|
471
|
+
return new Response(null, { status: 204, headers: PUBLIC_CORS });
|
|
472
|
+
if (req.method !== "GET")
|
|
473
|
+
return new Response("Method Not Allowed", { status: 405 });
|
|
474
|
+
return new Response(body, {
|
|
475
|
+
status: 200,
|
|
476
|
+
headers: { "Content-Type": "application/json", ...PUBLIC_CORS }
|
|
477
|
+
});
|
|
478
|
+
}
|
|
479
|
+
};
|
|
480
|
+
}
|
|
481
|
+
// src/server/oauth/endpoints.ts
|
|
482
|
+
import { randomUUID } from "node:crypto";
|
|
483
|
+
var PUBLIC_CORS2 = {
|
|
484
|
+
"Access-Control-Allow-Origin": "*",
|
|
485
|
+
"Access-Control-Allow-Methods": "GET, POST, OPTIONS",
|
|
486
|
+
"Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS
|
|
487
|
+
};
|
|
488
|
+
var AS_METADATA_PATH = "/.well-known/oauth-authorization-server";
|
|
489
|
+
var AUTH_CODE_TTL_MS = 60000;
|
|
490
|
+
function safeClientName(value) {
|
|
491
|
+
if (value === undefined)
|
|
492
|
+
return;
|
|
493
|
+
const safe = Array.from(value).filter(isPlainDisplayCharacter).join("").trim().slice(0, 200);
|
|
494
|
+
return safe || undefined;
|
|
495
|
+
}
|
|
496
|
+
function parseScopes(value) {
|
|
497
|
+
if (!value)
|
|
498
|
+
return [];
|
|
499
|
+
return [...new Set(value.split(/\s+/u).filter(Boolean))];
|
|
500
|
+
}
|
|
501
|
+
function json(body, status = 200, extraHeaders) {
|
|
502
|
+
return new Response(JSON.stringify(body), {
|
|
503
|
+
status,
|
|
504
|
+
headers: { "Content-Type": "application/json", ...PUBLIC_CORS2, ...extraHeaders }
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
function oauthError(error, description, status = 400) {
|
|
508
|
+
return json({ error, error_description: description }, status);
|
|
509
|
+
}
|
|
507
510
|
function redirectWith(uri, params) {
|
|
508
511
|
const url = new URL(uri);
|
|
509
512
|
for (const [key, value] of Object.entries(params))
|
|
@@ -525,41 +528,9 @@ async function readForm(req) {
|
|
|
525
528
|
}
|
|
526
529
|
return new URLSearchParams(await req.text());
|
|
527
530
|
}
|
|
528
|
-
function
|
|
529
|
-
const
|
|
530
|
-
|
|
531
|
-
const registerPath = `${base}/register`;
|
|
532
|
-
const authorizePath = `${base}/authorize`;
|
|
533
|
-
const tokenPath = `${base}/token`;
|
|
534
|
-
const clientRegistration = config.clientRegistration ?? {};
|
|
535
|
-
const dcrRegistry = clientRegistration.dcr || undefined;
|
|
536
|
-
const dcrEnabled = dcrRegistry !== undefined;
|
|
537
|
-
const cimdConfig = clientRegistration.cimd === false ? undefined : clientRegistration.cimd ?? {};
|
|
538
|
-
const cimdEnabled = cimdConfig !== undefined;
|
|
539
|
-
const resolveCimd = cimdEnabled ? createCimdResolver({
|
|
540
|
-
cache: cimdConfig.cache,
|
|
541
|
-
fetcher: cimdConfig.fetcher ?? createSecureClientMetadataFetcher(),
|
|
542
|
-
onCacheEvent: cimdConfig.onCacheEvent
|
|
543
|
-
}) : undefined;
|
|
544
|
-
const resolveClient = async (clientId) => {
|
|
545
|
-
const preRegistered = await clientRegistration.preRegistered?.get(clientId);
|
|
546
|
-
if (preRegistered)
|
|
547
|
-
return preRegistered.clientId === clientId ? preRegistered : null;
|
|
548
|
-
const clientUrl = absoluteClientUrl(clientId);
|
|
549
|
-
if (clientUrl) {
|
|
550
|
-
if (!resolveCimd || clientUrl.protocol !== "https:")
|
|
551
|
-
return null;
|
|
552
|
-
try {
|
|
553
|
-
return await resolveCimd(clientId);
|
|
554
|
-
} catch {
|
|
555
|
-
return null;
|
|
556
|
-
}
|
|
557
|
-
}
|
|
558
|
-
const dcrClient = await dcrRegistry?.get(clientId);
|
|
559
|
-
return dcrClient?.clientId === clientId ? dcrClient : null;
|
|
560
|
-
};
|
|
561
|
-
const redirectToClient = (uri, params) => redirectWith(uri, { ...params, iss: config.issuer });
|
|
562
|
-
const metadataRoute = {
|
|
531
|
+
function metadataRoute(ctx) {
|
|
532
|
+
const { config } = ctx;
|
|
533
|
+
return {
|
|
563
534
|
method: "ALL",
|
|
564
535
|
path: AS_METADATA_PATH,
|
|
565
536
|
handler: (req) => {
|
|
@@ -567,22 +538,27 @@ function mountOAuthProvider(config) {
|
|
|
567
538
|
return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
|
|
568
539
|
return json({
|
|
569
540
|
issuer: config.issuer,
|
|
570
|
-
authorization_endpoint: `${config.issuer}${
|
|
571
|
-
token_endpoint: `${config.issuer}${
|
|
572
|
-
...
|
|
541
|
+
authorization_endpoint: `${config.issuer}${ctx.paths.authorize}`,
|
|
542
|
+
token_endpoint: `${config.issuer}${ctx.paths.token}`,
|
|
543
|
+
...ctx.dcrRegistry !== undefined && {
|
|
544
|
+
registration_endpoint: `${config.issuer}${ctx.paths.register}`
|
|
545
|
+
},
|
|
573
546
|
response_types_supported: ["code"],
|
|
574
547
|
grant_types_supported: config.refreshTokens ? ["authorization_code", "refresh_token"] : ["authorization_code"],
|
|
575
548
|
code_challenge_methods_supported: ["S256"],
|
|
576
549
|
token_endpoint_auth_methods_supported: ["none"],
|
|
577
|
-
...cimdEnabled && { client_id_metadata_document_supported: true },
|
|
550
|
+
...ctx.cimdEnabled && { client_id_metadata_document_supported: true },
|
|
578
551
|
authorization_response_iss_parameter_supported: true,
|
|
579
552
|
...config.scopesSupported && { scopes_supported: config.scopesSupported }
|
|
580
553
|
});
|
|
581
554
|
}
|
|
582
555
|
};
|
|
583
|
-
|
|
556
|
+
}
|
|
557
|
+
function registerRoute(ctx) {
|
|
558
|
+
const { config } = ctx;
|
|
559
|
+
return {
|
|
584
560
|
method: "ALL",
|
|
585
|
-
path:
|
|
561
|
+
path: ctx.paths.register,
|
|
586
562
|
handler: async (req) => {
|
|
587
563
|
if (req.method === "OPTIONS")
|
|
588
564
|
return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
|
|
@@ -605,9 +581,9 @@ function mountOAuthProvider(config) {
|
|
|
605
581
|
if (!Array.isArray(redirectUris) || redirectUris.length === 0 || !redirectUris.every((u) => typeof u === "string" && isRegistrableRedirectUri(u, applicationType))) {
|
|
606
582
|
return oauthError("invalid_redirect_uri", applicationType === "web" ? "redirect_uris must be a non-empty array of absolute https URLs (a web client cannot register an http loopback URI)" : "redirect_uris must be a non-empty array of absolute https URLs (http is allowed only on a loopback host)");
|
|
607
583
|
}
|
|
608
|
-
if (!dcrRegistry)
|
|
584
|
+
if (!ctx.dcrRegistry)
|
|
609
585
|
throw new Error("DCR route mounted without a DCR registry");
|
|
610
|
-
const client = await dcrRegistry.register({
|
|
586
|
+
const client = await ctx.dcrRegistry.register({
|
|
611
587
|
redirectUris,
|
|
612
588
|
clientName: typeof meta.client_name === "string" ? meta.client_name : undefined,
|
|
613
589
|
tokenEndpointAuthMethod,
|
|
@@ -624,9 +600,12 @@ function mountOAuthProvider(config) {
|
|
|
624
600
|
}, 201);
|
|
625
601
|
}
|
|
626
602
|
};
|
|
627
|
-
|
|
603
|
+
}
|
|
604
|
+
function authorizeRoute(ctx) {
|
|
605
|
+
const { config } = ctx;
|
|
606
|
+
return {
|
|
628
607
|
method: "ALL",
|
|
629
|
-
path:
|
|
608
|
+
path: ctx.paths.authorize,
|
|
630
609
|
handler: async (req) => {
|
|
631
610
|
if (req.method === "OPTIONS")
|
|
632
611
|
return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
|
|
@@ -643,34 +622,34 @@ function mountOAuthProvider(config) {
|
|
|
643
622
|
if (!clientId || !redirectUri) {
|
|
644
623
|
return oauthError("invalid_request", "client_id and redirect_uri are required");
|
|
645
624
|
}
|
|
646
|
-
const client = await resolveClient(clientId);
|
|
625
|
+
const client = await ctx.resolveClient(clientId);
|
|
647
626
|
if (!client)
|
|
648
627
|
return oauthError("invalid_client", "Unknown client_id", 401);
|
|
649
628
|
if (!client.redirectUris.includes(redirectUri)) {
|
|
650
629
|
return oauthError("invalid_request", "redirect_uri does not match a registered URI");
|
|
651
630
|
}
|
|
652
631
|
if (responseType !== "code") {
|
|
653
|
-
return redirectToClient(redirectUri, {
|
|
632
|
+
return ctx.redirectToClient(redirectUri, {
|
|
654
633
|
error: "unsupported_response_type",
|
|
655
634
|
...state && { state }
|
|
656
635
|
});
|
|
657
636
|
}
|
|
658
637
|
if (!codeChallenge || codeChallengeMethod !== "S256") {
|
|
659
|
-
return redirectToClient(redirectUri, {
|
|
638
|
+
return ctx.redirectToClient(redirectUri, {
|
|
660
639
|
error: "invalid_request",
|
|
661
640
|
error_description: "PKCE S256 code_challenge is required",
|
|
662
641
|
...state && { state }
|
|
663
642
|
});
|
|
664
643
|
}
|
|
665
644
|
if (!resource) {
|
|
666
|
-
return redirectToClient(redirectUri, {
|
|
645
|
+
return ctx.redirectToClient(redirectUri, {
|
|
667
646
|
error: "invalid_target",
|
|
668
647
|
error_description: "resource parameter is required",
|
|
669
648
|
...state && { state }
|
|
670
649
|
});
|
|
671
650
|
}
|
|
672
651
|
if (resource !== config.resource) {
|
|
673
|
-
return redirectToClient(redirectUri, {
|
|
652
|
+
return ctx.redirectToClient(redirectUri, {
|
|
674
653
|
error: "invalid_target",
|
|
675
654
|
error_description: "resource is not served by this authorization server",
|
|
676
655
|
...state && { state }
|
|
@@ -679,7 +658,7 @@ function mountOAuthProvider(config) {
|
|
|
679
658
|
const requestedScopes = parseScopes(scope);
|
|
680
659
|
const supportedScopes = new Set(config.scopesSupported ?? []);
|
|
681
660
|
if (config.scopesSupported && requestedScopes.some((requestedScope2) => !supportedScopes.has(requestedScope2))) {
|
|
682
|
-
return redirectToClient(redirectUri, {
|
|
661
|
+
return ctx.redirectToClient(redirectUri, {
|
|
683
662
|
error: "invalid_scope",
|
|
684
663
|
error_description: "One or more requested scopes are not supported",
|
|
685
664
|
...state && { state }
|
|
@@ -725,18 +704,15 @@ function mountOAuthProvider(config) {
|
|
|
725
704
|
userId: result.userId,
|
|
726
705
|
expiresAt: Date.now() + AUTH_CODE_TTL_MS
|
|
727
706
|
});
|
|
728
|
-
return redirectToClient(redirectUri, { code, ...state && { state } });
|
|
707
|
+
return ctx.redirectToClient(redirectUri, { code, ...state && { state } });
|
|
729
708
|
}
|
|
730
709
|
};
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
expiresInSec: ttl
|
|
736
|
-
});
|
|
737
|
-
const tokenRoute = {
|
|
710
|
+
}
|
|
711
|
+
function tokenRoute(ctx) {
|
|
712
|
+
const { config } = ctx;
|
|
713
|
+
return {
|
|
738
714
|
method: "ALL",
|
|
739
|
-
path:
|
|
715
|
+
path: ctx.paths.token,
|
|
740
716
|
handler: async (req) => {
|
|
741
717
|
if (req.method === "OPTIONS")
|
|
742
718
|
return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
|
|
@@ -764,7 +740,7 @@ function mountOAuthProvider(config) {
|
|
|
764
740
|
if (!await verifyPkce(verifier, data.codeChallenge)) {
|
|
765
741
|
return oauthError("invalid_grant", "PKCE verification failed");
|
|
766
742
|
}
|
|
767
|
-
const accessToken = await issueAccessToken(data.userId, data.resource, data.clientId, data.scope);
|
|
743
|
+
const accessToken = await ctx.issueAccessToken(data.userId, data.resource, data.clientId, data.scope);
|
|
768
744
|
let refreshToken;
|
|
769
745
|
if (config.refreshTokens) {
|
|
770
746
|
refreshToken = randomUUID();
|
|
@@ -778,7 +754,7 @@ function mountOAuthProvider(config) {
|
|
|
778
754
|
return json({
|
|
779
755
|
access_token: accessToken,
|
|
780
756
|
token_type: "Bearer",
|
|
781
|
-
expires_in: ttl,
|
|
757
|
+
expires_in: ctx.ttl,
|
|
782
758
|
...data.scope && { scope: data.scope },
|
|
783
759
|
...refreshToken && { refresh_token: refreshToken }
|
|
784
760
|
});
|
|
@@ -796,13 +772,13 @@ function mountOAuthProvider(config) {
|
|
|
796
772
|
return oauthError("invalid_grant", "Unknown or used refresh token");
|
|
797
773
|
if (data.clientId !== clientId)
|
|
798
774
|
return oauthError("invalid_grant", "client_id mismatch");
|
|
799
|
-
const accessToken = await issueAccessToken(data.userId, data.resource, data.clientId, data.scope);
|
|
775
|
+
const accessToken = await ctx.issueAccessToken(data.userId, data.resource, data.clientId, data.scope);
|
|
800
776
|
const newRefresh = randomUUID();
|
|
801
777
|
await config.refreshTokens.save(newRefresh, data);
|
|
802
778
|
return json({
|
|
803
779
|
access_token: accessToken,
|
|
804
780
|
token_type: "Bearer",
|
|
805
|
-
expires_in: ttl,
|
|
781
|
+
expires_in: ctx.ttl,
|
|
806
782
|
...data.scope && { scope: data.scope },
|
|
807
783
|
refresh_token: newRefresh
|
|
808
784
|
});
|
|
@@ -810,7 +786,60 @@ function mountOAuthProvider(config) {
|
|
|
810
786
|
return oauthError("unsupported_grant_type", `Unsupported grant_type: ${grantType ?? "none"}`);
|
|
811
787
|
}
|
|
812
788
|
};
|
|
813
|
-
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
// src/server/oauth/provider.ts
|
|
792
|
+
function mountOAuthProvider(config) {
|
|
793
|
+
const base = config.basePath ?? "/oauth";
|
|
794
|
+
const ttl = config.accessTokenTtlSec ?? 3600;
|
|
795
|
+
const registerPath = `${base}/register`;
|
|
796
|
+
const authorizePath = `${base}/authorize`;
|
|
797
|
+
const tokenPath = `${base}/token`;
|
|
798
|
+
const clientRegistration = config.clientRegistration ?? {};
|
|
799
|
+
const dcrRegistry = clientRegistration.dcr || undefined;
|
|
800
|
+
const dcrEnabled = dcrRegistry !== undefined;
|
|
801
|
+
const cimdConfig = clientRegistration.cimd === false ? undefined : clientRegistration.cimd ?? {};
|
|
802
|
+
const cimdEnabled = cimdConfig !== undefined;
|
|
803
|
+
const resolveCimd = cimdEnabled ? createCimdResolver({
|
|
804
|
+
cache: cimdConfig.cache,
|
|
805
|
+
fetcher: cimdConfig.fetcher ?? createSecureClientMetadataFetcher(),
|
|
806
|
+
onCacheEvent: cimdConfig.onCacheEvent
|
|
807
|
+
}) : undefined;
|
|
808
|
+
const resolveClient = async (clientId) => {
|
|
809
|
+
const preRegistered = await clientRegistration.preRegistered?.get(clientId);
|
|
810
|
+
if (preRegistered)
|
|
811
|
+
return preRegistered.clientId === clientId ? preRegistered : null;
|
|
812
|
+
const clientUrl = absoluteClientUrl(clientId);
|
|
813
|
+
if (clientUrl) {
|
|
814
|
+
if (!resolveCimd || clientUrl.protocol !== "https:")
|
|
815
|
+
return null;
|
|
816
|
+
try {
|
|
817
|
+
return await resolveCimd(clientId);
|
|
818
|
+
} catch {
|
|
819
|
+
return null;
|
|
820
|
+
}
|
|
821
|
+
}
|
|
822
|
+
const dcrClient = await dcrRegistry?.get(clientId);
|
|
823
|
+
return dcrClient?.clientId === clientId ? dcrClient : null;
|
|
824
|
+
};
|
|
825
|
+
const redirectToClient = (uri, params) => redirectWith(uri, { ...params, iss: config.issuer });
|
|
826
|
+
const issueAccessToken = (userId, audience, clientId, scope) => signJwt({ scope, client_id: clientId }, config.signingSecret, {
|
|
827
|
+
issuer: config.issuer,
|
|
828
|
+
audience,
|
|
829
|
+
subject: userId,
|
|
830
|
+
expiresInSec: ttl
|
|
831
|
+
});
|
|
832
|
+
const ctx = {
|
|
833
|
+
config,
|
|
834
|
+
ttl,
|
|
835
|
+
paths: { register: registerPath, authorize: authorizePath, token: tokenPath },
|
|
836
|
+
dcrRegistry,
|
|
837
|
+
cimdEnabled,
|
|
838
|
+
resolveClient,
|
|
839
|
+
redirectToClient,
|
|
840
|
+
issueAccessToken
|
|
841
|
+
};
|
|
842
|
+
return dcrEnabled ? [metadataRoute(ctx), registerRoute(ctx), authorizeRoute(ctx), tokenRoute(ctx)] : [metadataRoute(ctx), authorizeRoute(ctx), tokenRoute(ctx)];
|
|
814
843
|
}
|
|
815
844
|
// src/tools/lifecycle.ts
|
|
816
845
|
function composeToolLifecycle(...hooks) {
|
|
@@ -1053,13 +1082,17 @@ import { z as z3 } from "zod";
|
|
|
1053
1082
|
// src/tools/mcp/round.ts
|
|
1054
1083
|
import {
|
|
1055
1084
|
acceptedContent,
|
|
1056
|
-
CLIENT_INFO_META_KEY,
|
|
1057
1085
|
inputRequired,
|
|
1058
|
-
inputResponse
|
|
1059
|
-
PROTOCOL_VERSION_META_KEY
|
|
1086
|
+
inputResponse
|
|
1060
1087
|
} from "@modelcontextprotocol/server";
|
|
1061
1088
|
import { z as z2 } from "zod";
|
|
1062
1089
|
|
|
1090
|
+
// src/tools/mcp/round-context.ts
|
|
1091
|
+
import {
|
|
1092
|
+
CLIENT_INFO_META_KEY,
|
|
1093
|
+
PROTOCOL_VERSION_META_KEY
|
|
1094
|
+
} from "@modelcontextprotocol/server";
|
|
1095
|
+
|
|
1063
1096
|
// src/tools/mcp/progress.ts
|
|
1064
1097
|
function mcpProgressToken(context) {
|
|
1065
1098
|
const token = context.mcpReq._meta?.progressToken;
|
|
@@ -1091,7 +1124,7 @@ function createMcpProgressReporter(context) {
|
|
|
1091
1124
|
};
|
|
1092
1125
|
}
|
|
1093
1126
|
|
|
1094
|
-
// src/tools/mcp/round.ts
|
|
1127
|
+
// src/tools/mcp/round-context.ts
|
|
1095
1128
|
function transportContext(context, toolName, outcome, round) {
|
|
1096
1129
|
const protocolVersionValue = isRecord(context.mcpReq.envelope) ? Reflect.get(context.mcpReq.envelope, PROTOCOL_VERSION_META_KEY) : undefined;
|
|
1097
1130
|
const protocolVersion = typeof protocolVersionValue === "string" ? protocolVersionValue : undefined;
|
|
@@ -1153,6 +1186,8 @@ async function failedResolution(options) {
|
|
|
1153
1186
|
const result = await runRoundFailure(options.tool, options.rawArgs, options.runTool, options.context, options.code, options.message);
|
|
1154
1187
|
return { kind: "response", response: options.formatFailure(result) };
|
|
1155
1188
|
}
|
|
1189
|
+
|
|
1190
|
+
// src/tools/mcp/round.ts
|
|
1156
1191
|
function roundPlanDigest(requests) {
|
|
1157
1192
|
return argumentsDigest({
|
|
1158
1193
|
plan: requests.map((request) => ({
|
|
@@ -1178,6 +1213,54 @@ async function resolveRequests(options, policy) {
|
|
|
1178
1213
|
validateResolvedInputRounds(options.tool, resolved, options.runtime?.maxRounds ?? 1);
|
|
1179
1214
|
return { requests: resolved, guarded: false };
|
|
1180
1215
|
}
|
|
1216
|
+
async function askRound(runtime, context, request, state) {
|
|
1217
|
+
const requestState = await runtime.codec.mint(state, context);
|
|
1218
|
+
return {
|
|
1219
|
+
kind: "response",
|
|
1220
|
+
response: inputRequired({
|
|
1221
|
+
inputRequests: {
|
|
1222
|
+
[request.key]: inputRequired.elicit({
|
|
1223
|
+
message: request.message,
|
|
1224
|
+
requestedSchema: request.schema
|
|
1225
|
+
})
|
|
1226
|
+
},
|
|
1227
|
+
requestState
|
|
1228
|
+
})
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
function readRoundAnswer(context, request) {
|
|
1232
|
+
const view = inputResponse(context.mcpReq.inputResponses, request.key);
|
|
1233
|
+
if (view.kind !== "elicit") {
|
|
1234
|
+
return {
|
|
1235
|
+
refusal: {
|
|
1236
|
+
outcome: "invalid",
|
|
1237
|
+
code: "INVALID_INPUT_RESPONSE",
|
|
1238
|
+
message: "Expected an elicitation response for the current round"
|
|
1239
|
+
}
|
|
1240
|
+
};
|
|
1241
|
+
}
|
|
1242
|
+
if (view.action !== "accept") {
|
|
1243
|
+
const declined = view.action === "decline";
|
|
1244
|
+
return {
|
|
1245
|
+
refusal: {
|
|
1246
|
+
outcome: declined ? "declined" : "cancelled",
|
|
1247
|
+
code: declined ? "INPUT_DECLINED" : "INPUT_CANCELLED",
|
|
1248
|
+
message: declined ? "Required input was declined" : "Required input was cancelled"
|
|
1249
|
+
}
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
const content = acceptedContent(context.mcpReq.inputResponses, request.key, request.schema);
|
|
1253
|
+
if (!content) {
|
|
1254
|
+
return {
|
|
1255
|
+
refusal: {
|
|
1256
|
+
outcome: "invalid",
|
|
1257
|
+
code: "INVALID_INPUT_RESPONSE",
|
|
1258
|
+
message: "Accepted input failed its declared schema"
|
|
1259
|
+
}
|
|
1260
|
+
};
|
|
1261
|
+
}
|
|
1262
|
+
return { content };
|
|
1263
|
+
}
|
|
1181
1264
|
async function resolveMcpRound(options) {
|
|
1182
1265
|
const { policy } = options;
|
|
1183
1266
|
if (!policy) {
|
|
@@ -1242,25 +1325,13 @@ async function resolveMcpRound(options) {
|
|
|
1242
1325
|
const request2 = requests[0];
|
|
1243
1326
|
if (!request2)
|
|
1244
1327
|
throw new Error("[stitchkit] validated MRTR policy has no first round");
|
|
1245
|
-
|
|
1328
|
+
return askRound(options.runtime, options.context, request2, {
|
|
1246
1329
|
identity: operationIdentity(options.tool),
|
|
1247
1330
|
argumentsDigest: digest,
|
|
1248
1331
|
round: 0,
|
|
1249
1332
|
accepted: {},
|
|
1250
1333
|
planDigest
|
|
1251
|
-
}
|
|
1252
|
-
return {
|
|
1253
|
-
kind: "response",
|
|
1254
|
-
response: inputRequired({
|
|
1255
|
-
inputRequests: {
|
|
1256
|
-
[request2.key]: inputRequired.elicit({
|
|
1257
|
-
message: request2.message,
|
|
1258
|
-
requestedSchema: request2.schema
|
|
1259
|
-
})
|
|
1260
|
-
},
|
|
1261
|
-
requestState
|
|
1262
|
-
})
|
|
1263
|
-
};
|
|
1334
|
+
});
|
|
1264
1335
|
}
|
|
1265
1336
|
if (state.planDigest !== planDigest || state.round >= requests.length) {
|
|
1266
1337
|
return failedResolution({
|
|
@@ -1273,33 +1344,16 @@ async function resolveMcpRound(options) {
|
|
|
1273
1344
|
const request = requests[state.round];
|
|
1274
1345
|
if (!request)
|
|
1275
1346
|
throw new Error("[stitchkit] validated MRTR state points outside its policy");
|
|
1276
|
-
const
|
|
1277
|
-
if (
|
|
1347
|
+
const answer = readRoundAnswer(options.context, request);
|
|
1348
|
+
if ("refusal" in answer) {
|
|
1278
1349
|
return failedResolution({
|
|
1279
1350
|
...options,
|
|
1280
|
-
context: transportContext(options.context, options.tool.name,
|
|
1281
|
-
code:
|
|
1282
|
-
message:
|
|
1283
|
-
});
|
|
1284
|
-
}
|
|
1285
|
-
if (view.action !== "accept") {
|
|
1286
|
-
const outcome = view.action === "decline" ? "declined" : "cancelled";
|
|
1287
|
-
return failedResolution({
|
|
1288
|
-
...options,
|
|
1289
|
-
context: transportContext(options.context, options.tool.name, outcome, state.round),
|
|
1290
|
-
code: view.action === "decline" ? "INPUT_DECLINED" : "INPUT_CANCELLED",
|
|
1291
|
-
message: view.action === "decline" ? "Required input was declined" : "Required input was cancelled"
|
|
1292
|
-
});
|
|
1293
|
-
}
|
|
1294
|
-
const content = acceptedContent(options.context.mcpReq.inputResponses, request.key, request.schema);
|
|
1295
|
-
if (!content) {
|
|
1296
|
-
return failedResolution({
|
|
1297
|
-
...options,
|
|
1298
|
-
context: transportContext(options.context, options.tool.name, "invalid", state.round),
|
|
1299
|
-
code: "INVALID_INPUT_RESPONSE",
|
|
1300
|
-
message: "Accepted input failed its declared schema"
|
|
1351
|
+
context: transportContext(options.context, options.tool.name, answer.refusal.outcome, state.round),
|
|
1352
|
+
code: answer.refusal.code,
|
|
1353
|
+
message: answer.refusal.message
|
|
1301
1354
|
});
|
|
1302
1355
|
}
|
|
1356
|
+
const { content } = answer;
|
|
1303
1357
|
const accepted = { ...state.accepted, [request.key]: content };
|
|
1304
1358
|
const nextRound = state.round + 1;
|
|
1305
1359
|
const nextRequest = requests[nextRound];
|
|
@@ -1310,25 +1364,13 @@ async function resolveMcpRound(options) {
|
|
|
1310
1364
|
return { kind: "response", response: options.formatFailure(guarded) };
|
|
1311
1365
|
}
|
|
1312
1366
|
}
|
|
1313
|
-
|
|
1367
|
+
return askRound(options.runtime, options.context, nextRequest, {
|
|
1314
1368
|
identity: state.identity,
|
|
1315
1369
|
argumentsDigest: state.argumentsDigest,
|
|
1316
1370
|
round: nextRound,
|
|
1317
1371
|
accepted,
|
|
1318
1372
|
planDigest
|
|
1319
|
-
}
|
|
1320
|
-
return {
|
|
1321
|
-
kind: "response",
|
|
1322
|
-
response: inputRequired({
|
|
1323
|
-
inputRequests: {
|
|
1324
|
-
[nextRequest.key]: inputRequired.elicit({
|
|
1325
|
-
message: nextRequest.message,
|
|
1326
|
-
requestedSchema: nextRequest.schema
|
|
1327
|
-
})
|
|
1328
|
-
},
|
|
1329
|
-
requestState
|
|
1330
|
-
})
|
|
1331
|
-
};
|
|
1373
|
+
});
|
|
1332
1374
|
}
|
|
1333
1375
|
return {
|
|
1334
1376
|
kind: "continue",
|
|
@@ -2960,6 +3002,7 @@ export {
|
|
|
2960
3002
|
McpMediaContentSchema,
|
|
2961
3003
|
McpAnnotationsSchema,
|
|
2962
3004
|
MCP_CATALOG_META_KEY,
|
|
3005
|
+
EffectUnresolvedError,
|
|
2963
3006
|
EXT_APPS_BUNDLE_PLACEHOLDER,
|
|
2964
3007
|
AsyncOperationCancelResultSchema,
|
|
2965
3008
|
AgentToolError
|