stitchkit 0.103.13 → 0.104.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.
Files changed (223) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/darwin-native.cjs +1 -3
  3. package/dist/agent-runtime/store-conformance-lifecycle.d.ts +10 -10
  4. package/dist/agent-runtime/store-conformance-support.d.ts +5 -5
  5. package/dist/application/directory-inbox-accept.d.ts +13 -0
  6. package/dist/application/directory-inbox-accept.d.ts.map +1 -0
  7. package/dist/application/directory-inbox-contract.d.ts +42 -5
  8. package/dist/application/directory-inbox-contract.d.ts.map +1 -1
  9. package/dist/application/directory-inbox-delivery.d.ts +14 -0
  10. package/dist/application/directory-inbox-delivery.d.ts.map +1 -0
  11. package/dist/application/directory-inbox-files.d.ts +28 -0
  12. package/dist/application/directory-inbox-files.d.ts.map +1 -0
  13. package/dist/application/directory-inbox-state.d.ts +14 -0
  14. package/dist/application/directory-inbox-state.d.ts.map +1 -0
  15. package/dist/application/directory-inbox.d.ts +2 -1
  16. package/dist/application/directory-inbox.d.ts.map +1 -1
  17. package/dist/application/file-state-store.d.ts +2 -8
  18. package/dist/application/file-state-store.d.ts.map +1 -1
  19. package/dist/application/state-store.d.ts +6 -1
  20. package/dist/application/state-store.d.ts.map +1 -1
  21. package/dist/browser/client-arguments.d.ts +4 -0
  22. package/dist/browser/client-arguments.d.ts.map +1 -0
  23. package/dist/browser/client-executors.d.ts.map +1 -1
  24. package/dist/browser/client.d.ts.map +1 -1
  25. package/dist/browser/contract-stream.d.ts.map +1 -1
  26. package/dist/browser/http.d.ts +2 -1
  27. package/dist/browser/http.d.ts.map +1 -1
  28. package/dist/browser/native-fetch.d.ts +8 -0
  29. package/dist/browser/native-fetch.d.ts.map +1 -0
  30. package/dist/contract/errors.d.ts +16 -12
  31. package/dist/contract/errors.d.ts.map +1 -1
  32. package/dist/contract/normalize.d.ts +5 -1
  33. package/dist/contract/normalize.d.ts.map +1 -1
  34. package/dist/contract/stream.d.ts +1 -0
  35. package/dist/contract/stream.d.ts.map +1 -1
  36. package/dist/entrypoints/agent-runtime/browser.js +3 -3
  37. package/dist/entrypoints/agent-runtime/coding-tools.js +6 -6
  38. package/dist/entrypoints/agent-runtime/harness-tools.js +8 -8
  39. package/dist/entrypoints/agent-runtime/harness.js +11 -11
  40. package/dist/entrypoints/agent-runtime/realtime.js +3 -3
  41. package/dist/entrypoints/agent-runtime/sandbox.js +6 -6
  42. package/dist/entrypoints/agent-runtime.js +13 -13
  43. package/dist/entrypoints/application/diagnostic-journal.js +1 -1
  44. package/dist/entrypoints/application/directory-inbox.js +424 -119
  45. package/dist/entrypoints/application/grammy.js +1 -1
  46. package/dist/entrypoints/application.d.ts +2 -2
  47. package/dist/entrypoints/application.d.ts.map +1 -1
  48. package/dist/entrypoints/application.js +7 -3
  49. package/dist/entrypoints/cli.d.ts +2 -0
  50. package/dist/entrypoints/cli.d.ts.map +1 -1
  51. package/dist/entrypoints/cli.js +757 -136
  52. package/dist/entrypoints/contract.js +3 -3
  53. package/dist/entrypoints/files/packaging.d.ts +3 -0
  54. package/dist/entrypoints/files/packaging.d.ts.map +1 -0
  55. package/dist/entrypoints/files/packaging.js +133 -0
  56. package/dist/entrypoints/files.js +10 -107
  57. package/dist/entrypoints/index.js +7 -7
  58. package/dist/entrypoints/node.js +8 -8
  59. package/dist/entrypoints/observability.js +2 -2
  60. package/dist/entrypoints/react.js +1 -1
  61. package/dist/entrypoints/remote.js +19 -6
  62. package/dist/entrypoints/server.d.ts +1 -1
  63. package/dist/entrypoints/server.d.ts.map +1 -1
  64. package/dist/entrypoints/server.js +23 -17
  65. package/dist/entrypoints/telegram.d.ts +1 -0
  66. package/dist/entrypoints/telegram.d.ts.map +1 -1
  67. package/dist/entrypoints/telegram.js +214 -98
  68. package/dist/entrypoints/testing.js +7 -7
  69. package/dist/entrypoints/tools/connections.d.ts +2 -2
  70. package/dist/entrypoints/tools/connections.d.ts.map +1 -1
  71. package/dist/entrypoints/tools/connections.js +427 -294
  72. package/dist/entrypoints/tools/invoker.js +6 -6
  73. package/dist/entrypoints/tools/mcp.d.ts +12 -0
  74. package/dist/entrypoints/tools/mcp.d.ts.map +1 -0
  75. package/dist/entrypoints/tools/mcp.js +45 -0
  76. package/dist/entrypoints/tools.d.ts +1 -0
  77. package/dist/entrypoints/tools.d.ts.map +1 -1
  78. package/dist/entrypoints/tools.js +82 -1147
  79. package/dist/entrypoints/tracking.js +1 -1
  80. package/dist/files/boundary.d.ts +2 -8
  81. package/dist/files/boundary.d.ts.map +1 -1
  82. package/dist/files/file-io.d.ts +0 -5
  83. package/dist/files/file-io.d.ts.map +1 -1
  84. package/dist/files/native-packaging-layout.d.ts +12 -0
  85. package/dist/files/native-packaging-layout.d.ts.map +1 -0
  86. package/dist/files/native-packaging.d.ts +72 -0
  87. package/dist/files/native-packaging.d.ts.map +1 -0
  88. package/dist/files/read.d.ts +2 -2
  89. package/dist/files/read.d.ts.map +1 -1
  90. package/dist/index-1a6jtnd9.js +88 -0
  91. package/dist/index-269zqj8m.js +77 -0
  92. package/dist/{index-r34mvse1.js → index-27a2pj09.js} +1 -1
  93. package/dist/{index-r956rndn.js → index-2hyavjjj.js} +3 -3
  94. package/dist/{index-m2xqkv55.js → index-2vnh05w4.js} +83 -14
  95. package/dist/{index-pw99k9h5.js → index-43p08g7t.js} +1 -1
  96. package/dist/{index-xwq9j1sf.js → index-4e0ah203.js} +9 -7
  97. package/dist/{index-qapzv4p5.js → index-5z6jn897.js} +1 -1
  98. package/dist/{index-ahvsksw5.js → index-6d9xaxw1.js} +1 -1
  99. package/dist/{index-8zfsgar0.js → index-6drst9sg.js} +11 -5
  100. package/dist/{index-x87j7csh.js → index-77nxk6ay.js} +2 -2
  101. package/dist/{index-dnn9z96q.js → index-a0zzh8ak.js} +3 -3
  102. package/dist/{index-kmpzj1cq.js → index-a3wma1hk.js} +1 -1
  103. package/dist/{index-j8aw2c0e.js → index-bakgedh8.js} +35 -7
  104. package/dist/index-bhb950qs.js +1145 -0
  105. package/dist/{index-tgzhq07n.js → index-cvda079a.js} +1 -1
  106. package/dist/{index-n2gre124.js → index-fa4wg312.js} +4 -4
  107. package/dist/{index-zp4jpkp0.js → index-fk18k56k.js} +2 -2
  108. package/dist/{index-afjvjyck.js → index-g2j7pnak.js} +2 -134
  109. package/dist/index-g95fk660.js +116 -0
  110. package/dist/{index-r5c4fedv.js → index-h2fhjqy7.js} +2 -1
  111. package/dist/{index-sybedc8b.js → index-hbd32c6a.js} +23 -94
  112. package/dist/{index-fyphpknh.js → index-hp9d77wk.js} +1 -1
  113. package/dist/index-jd470k6q.js +109 -0
  114. package/dist/{index-b2bz0kdm.js → index-kb8styz3.js} +4 -3
  115. package/dist/{index-0c419yx7.js → index-kemm0ej5.js} +12 -9
  116. package/dist/{index-db2spkv1.js → index-ptn0g0gj.js} +3 -3
  117. package/dist/{index-w575evhq.js → index-r4r70zmh.js} +1 -1
  118. package/dist/{index-12m2v2a9.js → index-s4evrmp5.js} +1 -1
  119. package/dist/{index-1khy8y7n.js → index-t1sr4aks.js} +3 -3
  120. package/dist/{index-45tdvqa3.js → index-wh0ecvyk.js} +1 -1
  121. package/dist/{index-n53mswt3.js → index-x928baz2.js} +8 -1
  122. package/dist/index-yk4g8805.js +133 -0
  123. package/dist/{index-ygkka6zn.js → index-ywppsaby.js} +28 -5
  124. package/dist/{index-9853ymwb.js → index-za6j7nwy.js} +18 -4
  125. package/dist/internal/bounded-file-read.d.ts +41 -0
  126. package/dist/internal/bounded-file-read.d.ts.map +1 -0
  127. package/dist/internal/exclusive-lock.d.ts +2 -0
  128. package/dist/internal/exclusive-lock.d.ts.map +1 -1
  129. package/dist/internal/with-exclusive-lock.d.ts +4 -2
  130. package/dist/internal/with-exclusive-lock.d.ts.map +1 -1
  131. package/dist/telegram/broadcast-delivery.d.ts +23 -0
  132. package/dist/telegram/broadcast-delivery.d.ts.map +1 -0
  133. package/dist/telegram/broadcast-failure.d.ts +22 -0
  134. package/dist/telegram/broadcast-failure.d.ts.map +1 -0
  135. package/dist/telegram/broadcast-state.d.ts +6 -3
  136. package/dist/telegram/broadcast-state.d.ts.map +1 -1
  137. package/dist/telegram/broadcast.d.ts +10 -5
  138. package/dist/telegram/broadcast.d.ts.map +1 -1
  139. package/dist/tools/cli/format.d.ts.map +1 -1
  140. package/dist/tools/cli/invoke.d.ts +2 -2
  141. package/dist/tools/cli/invoke.d.ts.map +1 -1
  142. package/dist/tools/cli/publication-assets.d.ts +10 -0
  143. package/dist/tools/cli/publication-assets.d.ts.map +1 -0
  144. package/dist/tools/cli/publication-contract.d.ts +75 -0
  145. package/dist/tools/cli/publication-contract.d.ts.map +1 -0
  146. package/dist/tools/cli/publication-control.d.ts +4 -0
  147. package/dist/tools/cli/publication-control.d.ts.map +1 -0
  148. package/dist/tools/cli/publication-storage.d.ts +32 -0
  149. package/dist/tools/cli/publication-storage.d.ts.map +1 -0
  150. package/dist/tools/cli/publication.d.ts +35 -0
  151. package/dist/tools/cli/publication.d.ts.map +1 -0
  152. package/dist/tools/cli/update.d.ts.map +1 -1
  153. package/dist/tools/connections/define.d.ts.map +1 -1
  154. package/dist/tools/connections/error-projection.d.ts +4 -0
  155. package/dist/tools/connections/error-projection.d.ts.map +1 -0
  156. package/dist/tools/connections/errors.d.ts +24 -8
  157. package/dist/tools/connections/errors.d.ts.map +1 -1
  158. package/dist/tools/connections/limits.d.ts +11 -31
  159. package/dist/tools/connections/limits.d.ts.map +1 -1
  160. package/dist/tools/connections/mcp-client.d.ts +6 -4
  161. package/dist/tools/connections/mcp-client.d.ts.map +1 -1
  162. package/dist/tools/connections/mcp.d.ts.map +1 -1
  163. package/dist/tools/connections/openapi.d.ts.map +1 -1
  164. package/dist/tools/connections/operation-limits.d.ts +25 -0
  165. package/dist/tools/connections/operation-limits.d.ts.map +1 -0
  166. package/dist/tools/connections/sse-frames.d.ts +11 -2
  167. package/dist/tools/connections/sse-frames.d.ts.map +1 -1
  168. package/dist/tools/connections/sse-session.d.ts +15 -2
  169. package/dist/tools/connections/sse-session.d.ts.map +1 -1
  170. package/dist/tools/connections/types.d.ts +19 -1
  171. package/dist/tools/connections/types.d.ts.map +1 -1
  172. package/dist/tools/execute-result.d.ts.map +1 -1
  173. package/dist/tools/execute.d.ts.map +1 -1
  174. package/dist/tools/internal/observe-hook.d.ts +3 -0
  175. package/dist/tools/internal/observe-hook.d.ts.map +1 -0
  176. package/dist/tools/internal/surface-projector.d.ts +2 -1
  177. package/dist/tools/internal/surface-projector.d.ts.map +1 -1
  178. package/dist/tools/mcp/mount.d.ts +2 -2
  179. package/dist/tools/mcp/mount.d.ts.map +1 -1
  180. package/dist/tools/mcp/prepare.d.ts +4 -5
  181. package/dist/tools/mcp/prepare.d.ts.map +1 -1
  182. package/dist/tools/mcp/register.d.ts +4 -1
  183. package/dist/tools/mcp/register.d.ts.map +1 -1
  184. package/dist/tools/mcp/runtime-tools.d.ts.map +1 -1
  185. package/dist/tools/remote.d.ts.map +1 -1
  186. package/dist/tools/runtime-tool-execution.d.ts +65 -0
  187. package/dist/tools/runtime-tool-execution.d.ts.map +1 -0
  188. package/dist/tools/runtime-tool-mcp.d.ts +27 -0
  189. package/dist/tools/runtime-tool-mcp.d.ts.map +1 -0
  190. package/dist/tools/runtime-tool.d.ts +9 -60
  191. package/dist/tools/runtime-tool.d.ts.map +1 -1
  192. package/dist/tools/surface.d.ts +12 -14
  193. package/dist/tools/surface.d.ts.map +1 -1
  194. package/llms/application.2.txt +221 -44
  195. package/llms/application.3.txt +3 -1
  196. package/llms/application.txt +1 -1
  197. package/llms/cli.2.txt +144 -1
  198. package/llms/cli.txt +123 -104
  199. package/llms/contract.txt +1 -1
  200. package/llms/files-packaging.txt +27 -0
  201. package/llms/process.txt +63 -1
  202. package/llms/server.4.txt +4 -1
  203. package/llms/server.5.txt +1 -0
  204. package/llms/stitchkit.2.txt +14 -0
  205. package/llms/stitchkit.txt +6 -4
  206. package/llms/telegram.txt +64 -2
  207. package/llms/tools-connections.txt +3 -0
  208. package/llms/tools-mcp.txt +29 -0
  209. package/llms/tools.2.txt +59 -0
  210. package/llms/tools.3.txt +1 -0
  211. package/llms/tools.txt +11 -52
  212. package/llms/upgrading-0.37.0-0.44.0.txt +444 -0
  213. package/llms/{upgrading-0.44.0-0.60.0.txt → upgrading-0.44.0-0.61.0.txt} +140 -271
  214. package/llms/{upgrading-0.61.0-0.74.0.txt → upgrading-0.62.0-0.80.0.txt} +217 -140
  215. package/llms/{upgrading-0.75.0-0.103.0.txt → upgrading-0.81.0-0.104.0.txt} +154 -217
  216. package/llms/upgrading.txt +4 -4
  217. package/llms-full.txt +745 -60
  218. package/llms.txt +14 -12
  219. package/native-assets.json +8 -0
  220. package/package.json +12 -3
  221. package/dist/index-wykebpn9.js +0 -221
  222. package/llms/upgrading-0.37.0.txt +0 -176
  223. package/dist/{index-69nvze1q.js → index-pptyv13k.js} +3 -3
@@ -1,55 +1,41 @@
1
1
  import {
2
2
  EffectUnresolvedError2,
3
3
  createLocalStepDurability2
4
- } from "../index-69nvze1q.js";
4
+ } from "../index-pptyv13k.js";
5
5
  import {
6
6
  AppError2,
7
7
  STITCH_ERROR_STATUS2
8
- } from "../index-n53mswt3.js";
8
+ } from "../index-x928baz2.js";
9
9
  import {
10
10
  AgentToolError2,
11
11
  isAgentToolError2
12
12
  } from "../index-nggfa2yn.js";
13
13
  import {
14
14
  normalizeError2
15
- } from "../index-b2bz0kdm.js";
16
- import {
17
- resolvePropagationContext2
18
- } from "../index-yex7eg1v.js";
15
+ } from "../index-kb8styz3.js";
16
+ import"../index-yex7eg1v.js";
19
17
  import {
20
18
  coerceJsonArgs2
21
19
  } from "../index-9pw0a51a.js";
20
+ import"../index-ct75c3at.js";
22
21
  import {
23
- toJsonSchema
24
- } from "../index-ct75c3at.js";
25
- import {
26
- toolSurfaceOutputSchema,
27
- staticInputRounds,
28
- validateMcpRoundPolicy,
29
- validateResolvedInputRounds,
30
22
  assertToolName,
31
23
  assertUniqueToolName,
32
24
  PORTABLE_JSON_SCHEMA_FORMATS2,
33
25
  findNonPortableFormats2,
34
26
  flattenToolJsonSchema2,
35
- presentationMetadata,
36
- findUntypedProperties2,
37
- prepareProjectedMcpTools
38
- } from "../index-x87j7csh.js";
27
+ findUntypedProperties2
28
+ } from "../index-77nxk6ay.js";
39
29
  import {
40
- parseToolCallArguments,
41
- toolResultFromError,
42
30
  ToolExecutionControlError2,
43
31
  isToolExecutionControlError2
44
- } from "../index-m2xqkv55.js";
32
+ } from "../index-2vnh05w4.js";
45
33
  import {
46
- collectTools2,
47
- createToolRunner,
48
- formatToolError
49
- } from "../index-r956rndn.js";
34
+ collectTools2
35
+ } from "../index-2hyavjjj.js";
50
36
  import {
51
37
  mountAgent2
52
- } from "../index-1khy8y7n.js";
38
+ } from "../index-t1sr4aks.js";
53
39
  import"../index-m38ej7e5.js";
54
40
  import {
55
41
  ALL_TRANSPORTS2,
@@ -57,10 +43,29 @@ import {
57
43
  defineContract2
58
44
  } from "../index-ck71tbcf.js";
59
45
  import"../index-1bx1xv1k.js";
60
- import"../index-sznqf8fx.js";
61
46
  import {
62
- redact2
63
- } from "../index-e6c2spsd.js";
47
+ PROTECTED_RESOURCE_PATH2,
48
+ protectedResourceMetadataUrl2,
49
+ wwwAuthenticateHeader2,
50
+ oauthProtectedResourceRoute2,
51
+ RESOURCE_MIME_TYPE2,
52
+ EXT_APPS_BUNDLE_PLACEHOLDER2,
53
+ inlineMcpAppBundle2,
54
+ MCP_CATALOG_META_KEY2,
55
+ mcpCatalogMeta2,
56
+ readMcpCatalogStamp2,
57
+ createMcpProgressReporter,
58
+ validateMcpSchemas2,
59
+ mountMcp2,
60
+ buildMcpServer2,
61
+ mountMcpResource2,
62
+ createMcpHandler2,
63
+ createMcpHttpRoute2,
64
+ createStdioMcpServer2,
65
+ bindStdioProcessSignals2
66
+ } from "../index-bhb950qs.js";
67
+ import"../index-sznqf8fx.js";
68
+ import"../index-e6c2spsd.js";
64
69
  import {
65
70
  AsyncOperationCancelResultSchema2,
66
71
  createAsyncOperationSnapshotSchema2,
@@ -77,56 +82,45 @@ import {
77
82
  WaitTimeoutError,
78
83
  runWaitOperation,
79
84
  createCli2
80
- } from "../index-8zfsgar0.js";
85
+ } from "../index-6drst9sg.js";
81
86
  import {
82
87
  ManagedFilePathSchema2,
83
88
  ManagedFileRefSchema2
84
89
  } from "../index-xqhede6x.js";
85
90
  import {
86
91
  ManagedFileError2
87
- } from "../index-sybedc8b.js";
92
+ } from "../index-hbd32c6a.js";
88
93
  import {
89
94
  composeToolLifecycle2
90
95
  } from "../index-ze1eph1k.js";
91
96
  import {
92
97
  signJwt2,
93
98
  verifyPkce2
94
- } from "../index-45tdvqa3.js";
99
+ } from "../index-wh0ecvyk.js";
95
100
  import {
96
- DEFAULT_CORS_ALLOW_HEADERS2,
97
101
  contractOnlyService,
98
- DEFAULT_PROCESS_SIGNALS,
99
- defaultSignalSource,
100
- reportSignalError,
101
- guardSignalCallback,
102
102
  mediaTypeEssence
103
- } from "../index-afjvjyck.js";
103
+ } from "../index-g2j7pnak.js";
104
104
  import {
105
105
  describeToolCatalog2,
106
106
  buildToolManifest2
107
- } from "../index-kmpzj1cq.js";
107
+ } from "../index-a3wma1hk.js";
108
+ import {
109
+ DEFAULT_CORS_ALLOW_HEADERS2
110
+ } from "../index-yk4g8805.js";
108
111
  import {
109
112
  collectToolSurface
110
- } from "../index-dnn9z96q.js";
113
+ } from "../index-a0zzh8ak.js";
111
114
  import {
112
- argumentsDigest
113
- } from "../index-r7a7r7ha.js";
115
+ defineRuntimeTool2,
116
+ createRuntimeToolFactory2
117
+ } from "../index-cvda079a.js";
114
118
  import {
115
119
  createToolInvoker2
116
- } from "../index-n2gre124.js";
120
+ } from "../index-fa4wg312.js";
117
121
  import {
118
- runWithRequestContext2,
119
- getRequestContext2,
120
122
  getTraceId2
121
123
  } from "../index-7n68nmc6.js";
122
- import {
123
- defineRuntimeTool2,
124
- createRuntimeToolFactory2
125
- } from "../index-tgzhq07n.js";
126
- import {
127
- compareCodeUnits,
128
- serializeCanonicalJson
129
- } from "../index-zsvzhjtk.js";
130
124
  import {
131
125
  isRecord
132
126
  } from "../index-9jfdm5tg.js";
@@ -441,48 +435,9 @@ function isLoopbackRedirectUri(value) {
441
435
  return false;
442
436
  }
443
437
  }
444
- // src/server/oauth/metadata.ts
445
- var PROTECTED_RESOURCE_PATH = "/.well-known/oauth-protected-resource";
446
- function metadataPath(resource) {
447
- const { pathname } = new URL(resource);
448
- return pathname === "/" ? PROTECTED_RESOURCE_PATH : `${PROTECTED_RESOURCE_PATH}${pathname}`;
449
- }
450
- function protectedResourceMetadataUrl(resource) {
451
- return `${new URL(resource).origin}${metadataPath(resource)}`;
452
- }
453
- function wwwAuthenticateHeader(resource) {
454
- return `Bearer resource_metadata="${protectedResourceMetadataUrl(resource)}"`;
455
- }
456
- var PUBLIC_CORS = {
457
- "Access-Control-Allow-Origin": "*",
458
- "Access-Control-Allow-Methods": "GET, OPTIONS",
459
- "Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS2
460
- };
461
- function oauthProtectedResourceRoute(config) {
462
- const body = JSON.stringify({
463
- resource: config.resource,
464
- authorization_servers: config.authorizationServers,
465
- ...config.scopesSupported && { scopes_supported: config.scopesSupported },
466
- bearer_methods_supported: ["header"]
467
- });
468
- return {
469
- method: "ALL",
470
- path: metadataPath(config.resource),
471
- handler: (req) => {
472
- if (req.method === "OPTIONS")
473
- return new Response(null, { status: 204, headers: PUBLIC_CORS });
474
- if (req.method !== "GET")
475
- return new Response("Method Not Allowed", { status: 405 });
476
- return new Response(body, {
477
- status: 200,
478
- headers: { "Content-Type": "application/json", ...PUBLIC_CORS }
479
- });
480
- }
481
- };
482
- }
483
438
  // src/server/oauth/endpoints.ts
484
439
  import { randomUUID } from "node:crypto";
485
- var PUBLIC_CORS2 = {
440
+ var PUBLIC_CORS = {
486
441
  "Access-Control-Allow-Origin": "*",
487
442
  "Access-Control-Allow-Methods": "GET, POST, OPTIONS",
488
443
  "Access-Control-Allow-Headers": DEFAULT_CORS_ALLOW_HEADERS2
@@ -503,7 +458,7 @@ function parseScopes(value) {
503
458
  function json(body, status = 200, extraHeaders) {
504
459
  return new Response(JSON.stringify(body), {
505
460
  status,
506
- headers: { "Content-Type": "application/json", ...PUBLIC_CORS2, ...extraHeaders }
461
+ headers: { "Content-Type": "application/json", ...PUBLIC_CORS, ...extraHeaders }
507
462
  });
508
463
  }
509
464
  function oauthError(error, description, status = 400) {
@@ -537,7 +492,7 @@ function metadataRoute(ctx) {
537
492
  path: AS_METADATA_PATH,
538
493
  handler: (req) => {
539
494
  if (req.method === "OPTIONS")
540
- return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
495
+ return new Response(null, { status: 204, headers: PUBLIC_CORS });
541
496
  return json({
542
497
  issuer: config.issuer,
543
498
  authorization_endpoint: `${config.issuer}${ctx.paths.authorize}`,
@@ -563,7 +518,7 @@ function registerRoute(ctx) {
563
518
  path: ctx.paths.register,
564
519
  handler: async (req) => {
565
520
  if (req.method === "OPTIONS")
566
- return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
521
+ return new Response(null, { status: 204, headers: PUBLIC_CORS });
567
522
  if (req.method !== "POST")
568
523
  return oauthError("invalid_request", "POST required", 405);
569
524
  const meta = await req.json().catch(() => null);
@@ -610,7 +565,7 @@ function authorizeRoute(ctx) {
610
565
  path: ctx.paths.authorize,
611
566
  handler: async (req) => {
612
567
  if (req.method === "OPTIONS")
613
- return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
568
+ return new Response(null, { status: 204, headers: PUBLIC_CORS });
614
569
  const url = new URL(req.url);
615
570
  const p = url.searchParams;
616
571
  const clientId = p.get("client_id");
@@ -717,7 +672,7 @@ function tokenRoute(ctx) {
717
672
  path: ctx.paths.token,
718
673
  handler: async (req) => {
719
674
  if (req.method === "OPTIONS")
720
- return new Response(null, { status: 204, headers: PUBLIC_CORS2 });
675
+ return new Response(null, { status: 204, headers: PUBLIC_CORS });
721
676
  if (req.method !== "POST")
722
677
  return oauthError("invalid_request", "POST required", 405);
723
678
  const form = await readForm(req);
@@ -873,1028 +828,8 @@ function listToolNames(surface) {
873
828
  function listContractToolNames(contracts) {
874
829
  return listToolNames({ services: contracts.map(contractOnlyService) });
875
830
  }
876
- // src/tools/mcp/app.ts
877
- import { readFileSync } from "node:fs";
878
- import { fileURLToPath } from "node:url";
879
- var RESOURCE_MIME_TYPE = "text/html;profile=mcp-app";
880
- var EXT_APPS_BUNDLE_PLACEHOLDER = "/*__EXT_APPS_BUNDLE__*/";
881
- function inlineMcpAppBundle(html) {
882
- if (!html.includes(EXT_APPS_BUNDLE_PLACEHOLDER))
883
- return html;
884
- let bundlePath;
885
- try {
886
- bundlePath = fileURLToPath(import.meta.resolve("@modelcontextprotocol/ext-apps/app-with-deps"));
887
- } catch {
888
- throw new Error("[stitchkit] inlineMcpAppBundle: '@modelcontextprotocol/ext-apps' is not installed. " + "Add it as a dependency to serve MCP App widgets.");
889
- }
890
- const bundle = readFileSync(bundlePath, "utf8").replace(/export\{([^}]+)\};?\s*$/, (_match, body) => `globalThis.ExtApps={${body.split(",").map((pair) => {
891
- const [local, exported] = pair.split(" as ").map((s) => s.trim());
892
- return `${exported ?? local}:${local}`;
893
- }).join(",")}};`);
894
- return html.replace(EXT_APPS_BUNDLE_PLACEHOLDER, () => bundle);
895
- }
896
- // src/tools/mcp/catalog.ts
897
- import { createHash } from "node:crypto";
898
- var MCP_CATALOG_META_KEY = "stitchkit/catalog";
899
- var stampCache = new WeakMap;
900
- function toolFingerprint(descriptor) {
901
- const { mountable } = descriptor;
902
- return {
903
- name: mountable.name,
904
- description: mountable.method.desc,
905
- input: descriptor.inputSchema,
906
- output: descriptor.outputSchema ? toJsonSchema(descriptor.outputSchema, "output", "any") : null,
907
- annotations: mountable.method.annotations ?? null
908
- };
909
- }
910
- function mcpCatalogStamp(surface) {
911
- const cached = stampCache.get(surface);
912
- if (cached)
913
- return cached;
914
- const descriptors = [
915
- ...surface.contractTools,
916
- ...surface.runtimeTools.map((entry) => entry.descriptor)
917
- ].sort((left, right) => compareCodeUnits(left.mountable.name, right.mountable.name));
918
- const bytes = serializeCanonicalJson(descriptors.map(toolFingerprint));
919
- const stamp = {
920
- digest: createHash("sha256").update(bytes).digest("hex").slice(0, 16),
921
- tools: descriptors.length
922
- };
923
- stampCache.set(surface, stamp);
924
- return stamp;
925
- }
926
- function mcpCatalogMeta(stamp) {
927
- return { [MCP_CATALOG_META_KEY]: { ...stamp } };
928
- }
929
- function readMcpCatalogStamp(meta) {
930
- if (!isRecord(meta))
931
- return null;
932
- const value = meta[MCP_CATALOG_META_KEY];
933
- if (!isRecord(value))
934
- return null;
935
- const { digest, tools } = value;
936
- if (typeof digest !== "string" || digest.length === 0)
937
- return null;
938
- if (typeof tools !== "number" || !Number.isInteger(tools) || tools < 0)
939
- return null;
940
- return { digest, tools };
941
- }
942
- function stampToolRegistration(config, stamp) {
943
- if (!stamp)
944
- return config;
945
- return { ...config, _meta: { ...config._meta, ...mcpCatalogMeta(stamp) } };
946
- }
947
- function stampToolResult(result, stamp) {
948
- if (!stamp)
949
- return result;
950
- return { ...result, _meta: { ...result._meta, ...mcpCatalogMeta(stamp) } };
951
- }
952
- // src/tools/mcp/handler.ts
953
- import {
954
- createMcpHandler as createSdkMcpHandler,
955
- hostHeaderValidationResponse,
956
- localhostAllowedHostnames,
957
- localhostAllowedOrigins,
958
- originValidationResponse
959
- } from "@modelcontextprotocol/server";
960
-
961
- // src/tools/mcp/mount.ts
962
- import {
963
- createRequestStateCodec,
964
- McpServer
965
- } from "@modelcontextprotocol/server";
966
-
967
- // src/tools/mcp/prepare.ts
968
- function textBlock(text) {
969
- return [{ type: "text", text }];
970
- }
971
- function formatMcpResult(result, mode, toolName, errorHint) {
972
- if (result.ok) {
973
- if (mode === "none")
974
- return { content: [] };
975
- let serialized;
976
- try {
977
- serialized = JSON.stringify(result.data, null, 2);
978
- } catch {
979
- serialized = undefined;
980
- }
981
- if (serialized === undefined) {
982
- const safe = redact2(result.data, { sensitiveKeys: /(?!)/ });
983
- return { content: textBlock(JSON.stringify(safe, null, 2)), structuredContent: safe };
984
- }
985
- return { content: textBlock(serialized), structuredContent: result.data };
986
- }
987
- return {
988
- content: textBlock(JSON.stringify(formatToolError(result, toolName, errorHint), null, 2)),
989
- isError: true
990
- };
991
- }
992
- function prepareMcpSurface(services, config = {}) {
993
- const serviceList = Array.isArray(services) ? services : [services];
994
- const tools = serviceList.flatMap((service) => collectTools2(service, "MCP", config));
995
- return prepareMcpTools(tools, config);
996
- }
997
- function prepareMcpTools(tools, config = {}) {
998
- const prepared = prepareProjectedMcpTools(tools.map((mountable) => {
999
- const outputSchema = toolSurfaceOutputSchema(mountable.method);
1000
- return {
1001
- tool: mountable,
1002
- name: mountable.name,
1003
- ...mountable.method.paramsSchema !== undefined && {
1004
- paramsSchema: mountable.method.paramsSchema
1005
- },
1006
- ...mountable.method.inputSchema !== undefined && {
1007
- inputSchema: mountable.method.inputSchema
1008
- },
1009
- ...mountable.method.toolView?.defaults !== undefined && {
1010
- inputDefaults: mountable.method.toolView.defaults
1011
- },
1012
- ...outputSchema !== undefined && { outputSchema },
1013
- shouldExtend: mountable.shouldExtend,
1014
- ...mountable.method.mcp !== undefined && { mcp: mountable.method.mcp }
1015
- };
1016
- }), config).map((entry) => {
1017
- Object.freeze(entry.tool);
1018
- return Object.freeze({
1019
- mountable: entry.tool,
1020
- inputSchema: entry.inputSchema,
1021
- ...entry.outputSchema !== undefined && { outputSchema: entry.outputSchema },
1022
- outputMode: entry.outputSchema === undefined ? "none" : "direct"
1023
- });
1024
- });
1025
- return Object.freeze(prepared);
1026
- }
1027
- function prepareMcpServerSurface(surface, config = {}) {
1028
- const contractMountables = [];
1029
- const definitions = [];
1030
- const runtimeMountables = [];
1031
- for (const entry of collectToolSurface({
1032
- surface,
1033
- transport: "MCP",
1034
- extend: config.extend,
1035
- flattenUnionInput: config.flattenUnionInput
1036
- })) {
1037
- if (entry.kind === "contract") {
1038
- contractMountables.push(entry.mountable);
1039
- } else {
1040
- definitions.push(entry.definition);
1041
- runtimeMountables.push(entry.mountable);
1042
- }
1043
- }
1044
- const contractTools = prepareMcpTools(contractMountables, config);
1045
- const runtimeDescriptors = prepareMcpTools(runtimeMountables, {
1046
- schemaValidation: config.schemaValidation,
1047
- logger: config.logger,
1048
- multiRound: config.multiRound
1049
- });
1050
- const descriptorsByName = new Map(runtimeDescriptors.map((descriptor) => [descriptor.mountable.name, descriptor]));
1051
- const runtimeTools = [];
1052
- for (const definition of definitions) {
1053
- const descriptor = descriptorsByName.get(definition.name);
1054
- if (descriptor)
1055
- runtimeTools.push(Object.freeze({ definition, descriptor }));
1056
- }
1057
- return Object.freeze({ contractTools, runtimeTools: Object.freeze(runtimeTools) });
1058
- }
1059
-
1060
- // src/tools/mcp/register.ts
1061
- import {
1062
- isCallToolResult
1063
- } from "@modelcontextprotocol/server";
1064
- import { z as z3 } from "zod";
1065
-
1066
- // src/tools/mcp/round.ts
1067
- import {
1068
- acceptedContent,
1069
- inputRequired,
1070
- inputResponse
1071
- } from "@modelcontextprotocol/server";
1072
- import { z as z2 } from "zod";
1073
-
1074
- // src/tools/mcp/round-context.ts
1075
- import {
1076
- CLIENT_INFO_META_KEY,
1077
- PROTOCOL_VERSION_META_KEY
1078
- } from "@modelcontextprotocol/server";
1079
-
1080
- // src/tools/mcp/progress.ts
1081
- function mcpProgressToken(context) {
1082
- const token = context.mcpReq._meta?.progressToken;
1083
- return typeof token === "string" || typeof token === "number" ? token : undefined;
1084
- }
1085
- function createMcpProgressReporter(context) {
1086
- const token = mcpProgressToken(context);
1087
- if (token === undefined)
1088
- return async () => {
1089
- return;
1090
- };
1091
- let sent = 0;
1092
- let highWater = 0;
1093
- return async (update) => {
1094
- sent += 1;
1095
- const value = update.progress ?? Math.max(sent, highWater + 1);
1096
- highWater = Math.max(highWater, value);
1097
- try {
1098
- await context.mcpReq.notify({
1099
- method: "notifications/progress",
1100
- params: {
1101
- progressToken: token,
1102
- progress: value,
1103
- ...update.total !== undefined && { total: update.total },
1104
- ...update.message !== undefined && { message: update.message }
1105
- }
1106
- });
1107
- } catch {}
1108
- };
1109
- }
1110
-
1111
- // src/tools/mcp/round-context.ts
1112
- function transportContext(context, toolName, outcome, round) {
1113
- const protocolVersionValue = isRecord(context.mcpReq.envelope) ? Reflect.get(context.mcpReq.envelope, PROTOCOL_VERSION_META_KEY) : undefined;
1114
- const protocolVersion = typeof protocolVersionValue === "string" ? protocolVersionValue : undefined;
1115
- const clientInfoValue = isRecord(context.mcpReq.envelope) ? Reflect.get(context.mcpReq.envelope, CLIENT_INFO_META_KEY) : undefined;
1116
- const clientInfo = isRecord(clientInfoValue) && typeof clientInfoValue.name === "string" && typeof clientInfoValue.version === "string" ? { name: clientInfoValue.name, version: clientInfoValue.version } : undefined;
1117
- const token = mcpProgressToken(context);
1118
- return {
1119
- signal: context.mcpReq.signal,
1120
- mcp: {
1121
- era: context.mcpReq.envelope ? "modern" : "legacy",
1122
- method: context.mcpReq.method,
1123
- toolName,
1124
- ...protocolVersion !== undefined && { protocolVersion },
1125
- ...clientInfo !== undefined && { clientInfo },
1126
- ...outcome !== undefined && { outcome },
1127
- ...round !== undefined && { round },
1128
- ...token !== undefined && { progressToken: token }
1129
- },
1130
- reportProgress: createMcpProgressReporter(context)
1131
- };
1132
- }
1133
- function operationIdentity(tool) {
1134
- return {
1135
- toolName: tool.name,
1136
- serviceName: tool.method.serviceName,
1137
- action: tool.method.key,
1138
- method: tool.method.method,
1139
- ...tool.method.scope !== undefined && { scope: tool.method.scope }
1140
- };
1141
- }
1142
- function sameIdentity(left, right) {
1143
- return left.toolName === right.toolName && left.serviceName === right.serviceName && left.action === right.action && left.method === right.method && left.scope === right.scope;
1144
- }
1145
- async function runRoundSuccess(tool, rawArgs, runTool, context) {
1146
- return runTool({
1147
- ...tool,
1148
- method: {
1149
- ...tool.method,
1150
- outputSchema: undefined,
1151
- handler: () => {
1152
- return;
1153
- }
1154
- }
1155
- }, rawArgs, context);
1156
- }
1157
- async function runRoundFailure(tool, rawArgs, runTool, context, code, message) {
1158
- return runTool({
1159
- ...tool,
1160
- method: {
1161
- ...tool.method,
1162
- outputSchema: undefined,
1163
- handler: () => {
1164
- throw new AppError2(code, message, 400);
1165
- }
1166
- }
1167
- }, rawArgs, context);
1168
- }
1169
- async function failedResolution(options) {
1170
- const result = await runRoundFailure(options.tool, options.rawArgs, options.runTool, options.context, options.code, options.message);
1171
- return { kind: "response", response: options.formatFailure(result) };
1172
- }
1173
-
1174
- // src/tools/mcp/round.ts
1175
- function roundPlanDigest(requests) {
1176
- return argumentsDigest({
1177
- plan: requests.map((request) => ({
1178
- key: request.key,
1179
- message: request.message,
1180
- schema: z2.toJSONSchema(request.schema, { io: "input", unrepresentable: "any" })
1181
- }))
1182
- });
1183
- }
1184
- async function resolveRequests(options, policy) {
1185
- const declared = staticInputRounds(policy);
1186
- if (declared)
1187
- return { requests: declared, guarded: false };
1188
- const parsed = parseToolCallArguments(options.tool.method, options.rawArgs, {
1189
- coerceJson: options.coerceJsonArgs ?? true,
1190
- toolSurface: true
1191
- });
1192
- if (!parsed.ok) {
1193
- return { requests: [], guarded: false };
1194
- }
1195
- const resolver = policy.inputRequired;
1196
- const resolved = await resolver({ params: parsed.params, input: parsed.input });
1197
- validateResolvedInputRounds(options.tool, resolved, options.runtime?.maxRounds ?? 1);
1198
- return { requests: resolved, guarded: false };
1199
- }
1200
- async function askRound(runtime, context, request, state) {
1201
- const requestState = await runtime.codec.mint(state, context);
1202
- return {
1203
- kind: "response",
1204
- response: inputRequired({
1205
- inputRequests: {
1206
- [request.key]: inputRequired.elicit({
1207
- message: request.message,
1208
- requestedSchema: request.schema
1209
- })
1210
- },
1211
- requestState
1212
- })
1213
- };
1214
- }
1215
- function readRoundAnswer(context, request) {
1216
- const view = inputResponse(context.mcpReq.inputResponses, request.key);
1217
- if (view.kind !== "elicit") {
1218
- return {
1219
- refusal: {
1220
- outcome: "invalid",
1221
- code: "INVALID_INPUT_RESPONSE",
1222
- message: "Expected an elicitation response for the current round"
1223
- }
1224
- };
1225
- }
1226
- if (view.action !== "accept") {
1227
- const declined = view.action === "decline";
1228
- return {
1229
- refusal: {
1230
- outcome: declined ? "declined" : "cancelled",
1231
- code: declined ? "INPUT_DECLINED" : "INPUT_CANCELLED",
1232
- message: declined ? "Required input was declined" : "Required input was cancelled"
1233
- }
1234
- };
1235
- }
1236
- const content = acceptedContent(context.mcpReq.inputResponses, request.key, request.schema);
1237
- if (!content) {
1238
- return {
1239
- refusal: {
1240
- outcome: "invalid",
1241
- code: "INVALID_INPUT_RESPONSE",
1242
- message: "Accepted input failed its declared schema"
1243
- }
1244
- };
1245
- }
1246
- return { content };
1247
- }
1248
- async function resolveMcpRound(options) {
1249
- const { policy } = options;
1250
- if (!policy) {
1251
- return {
1252
- kind: "continue",
1253
- context: transportContext(options.context, options.tool.name)
1254
- };
1255
- }
1256
- if (!options.runtime) {
1257
- throw new Error(`[stitchkit] MCP tool "${options.tool.name}" declares inputRequired but no multiRound.state key is configured`);
1258
- }
1259
- validateMcpRoundPolicy(options.tool, policy, {
1260
- stateConfigured: true,
1261
- maxRounds: options.runtime.maxRounds
1262
- });
1263
- const state = options.context.mcpReq.requestState();
1264
- const digest = argumentsDigest(options.rawArgs);
1265
- if (state) {
1266
- const mismatched = !sameIdentity(state.identity, operationIdentity(options.tool)) || state.argumentsDigest !== digest || !Number.isInteger(state.round) || state.round < 0 || state.round >= options.runtime.maxRounds || !isRecord(state.accepted);
1267
- if (mismatched) {
1268
- return failedResolution({
1269
- ...options,
1270
- context: transportContext(options.context, options.tool.name, "invalid", Number.isInteger(state.round) ? state.round : 0),
1271
- code: "INVALID_REQUEST_STATE",
1272
- message: "Continuation state does not match this operation, arguments or round"
1273
- });
1274
- }
1275
- }
1276
- const dynamic = staticInputRounds(policy) === undefined;
1277
- if (dynamic) {
1278
- const guarded = await runRoundSuccess(options.tool, options.rawArgs, options.runTool, transportContext(options.context, options.tool.name, "input_required", state?.round ?? 0));
1279
- if (!guarded.ok)
1280
- return { kind: "response", response: options.formatFailure(guarded) };
1281
- }
1282
- const resolution = await resolveRequests(options, policy);
1283
- if ("failure" in resolution)
1284
- return resolution.failure;
1285
- const requests = resolution.requests;
1286
- const alreadyGuarded = dynamic;
1287
- const planDigest = roundPlanDigest(requests);
1288
- if (requests.length === 0 && !state) {
1289
- return {
1290
- kind: "continue",
1291
- context: transportContext(options.context, options.tool.name)
1292
- };
1293
- }
1294
- if (!state) {
1295
- if (isRecord(options.context.mcpReq.inputResponses)) {
1296
- return failedResolution({
1297
- ...options,
1298
- context: transportContext(options.context, options.tool.name, "invalid", 0),
1299
- code: "INVALID_REQUEST_STATE",
1300
- message: "Input responses require a valid continuation state"
1301
- });
1302
- }
1303
- if (!alreadyGuarded) {
1304
- const guarded = await runRoundSuccess(options.tool, options.rawArgs, options.runTool, transportContext(options.context, options.tool.name, "input_required", 0));
1305
- if (!guarded.ok) {
1306
- return { kind: "response", response: options.formatFailure(guarded) };
1307
- }
1308
- }
1309
- const request = requests[0];
1310
- if (!request)
1311
- throw new Error("[stitchkit] validated MRTR policy has no first round");
1312
- return askRound(options.runtime, options.context, request, {
1313
- identity: operationIdentity(options.tool),
1314
- argumentsDigest: digest,
1315
- round: 0,
1316
- accepted: {},
1317
- planDigest
1318
- });
1319
- }
1320
- if (state.planDigest !== planDigest || state.round >= requests.length) {
1321
- return failedResolution({
1322
- ...options,
1323
- context: transportContext(options.context, options.tool.name, "invalid", state.round),
1324
- code: "INVALID_REQUEST_STATE",
1325
- message: state.round >= requests.length ? "Continuation state does not match this operation, arguments or round" : "The questions for this call changed between rounds"
1326
- });
1327
- }
1328
- const request = requests[state.round];
1329
- if (!request)
1330
- throw new Error("[stitchkit] validated MRTR state points outside its policy");
1331
- const answer = readRoundAnswer(options.context, request);
1332
- if ("refusal" in answer) {
1333
- return failedResolution({
1334
- ...options,
1335
- context: transportContext(options.context, options.tool.name, answer.refusal.outcome, state.round),
1336
- code: answer.refusal.code,
1337
- message: answer.refusal.message
1338
- });
1339
- }
1340
- const { content } = answer;
1341
- const accepted = { ...state.accepted, [request.key]: content };
1342
- const nextRound = state.round + 1;
1343
- const nextRequest = requests[nextRound];
1344
- if (nextRequest) {
1345
- if (!alreadyGuarded) {
1346
- const guarded = await runRoundSuccess(options.tool, options.rawArgs, options.runTool, transportContext(options.context, options.tool.name, "input_required", nextRound));
1347
- if (!guarded.ok) {
1348
- return { kind: "response", response: options.formatFailure(guarded) };
1349
- }
1350
- }
1351
- return askRound(options.runtime, options.context, nextRequest, {
1352
- identity: state.identity,
1353
- argumentsDigest: state.argumentsDigest,
1354
- round: nextRound,
1355
- accepted,
1356
- planDigest
1357
- });
1358
- }
1359
- return {
1360
- kind: "continue",
1361
- context: {
1362
- ...transportContext(options.context, options.tool.name, "complete", state.round),
1363
- mcpInput: accepted
1364
- }
1365
- };
1366
- }
1367
-
1368
- // src/tools/mcp/trace.ts
1369
- import {
1370
- BAGGAGE_META_KEY,
1371
- TRACEPARENT_META_KEY,
1372
- TRACESTATE_META_KEY
1373
- } from "@modelcontextprotocol/server";
1374
- function runInMcpRequestContext(context, toolName, body) {
1375
- const ambient = getRequestContext2();
1376
- const metadata = context.mcpReq._meta;
1377
- const propagation = metadata ? {
1378
- traceparent: metadata[TRACEPARENT_META_KEY],
1379
- tracestate: metadata[TRACESTATE_META_KEY],
1380
- baggage: metadata[BAGGAGE_META_KEY]
1381
- } : undefined;
1382
- const request = {
1383
- ...ambient ?? {
1384
- source: "mcp",
1385
- method: "MCP",
1386
- path: `/mcp/${toolName}`,
1387
- startedAt: process.hrtime.bigint()
1388
- },
1389
- trace: resolvePropagationContext2(propagation, ambient?.trace),
1390
- source: "mcp",
1391
- method: "MCP",
1392
- path: `/mcp/${toolName}`,
1393
- startedAt: process.hrtime.bigint(),
1394
- dimensions: ambient?.dimensions ? { ...ambient.dimensions } : undefined,
1395
- error: undefined
1396
- };
1397
- return runWithRequestContext2(request, body);
1398
- }
1399
-
1400
- // src/tools/mcp/register.ts
1401
- function registerMcpTool(server, presentation, descriptor, config) {
1402
- const { mountable } = descriptor;
1403
- const toolConfig = {
1404
- description: presentation.description,
1405
- inputSchema: z3.looseObject({}).meta(presentationMetadata(descriptor.inputSchema))
1406
- };
1407
- if (descriptor.outputSchema)
1408
- toolConfig.outputSchema = descriptor.outputSchema;
1409
- if (presentation.annotations)
1410
- toolConfig.annotations = presentation.annotations;
1411
- if (presentation.ui) {
1412
- toolConfig._meta = {
1413
- ui: presentation.ui,
1414
- "ui/resourceUri": presentation.ui.resourceUri
1415
- };
1416
- }
1417
- const { name } = presentation;
1418
- const format = config.formatResult;
1419
- server.registerTool(name, stampToolRegistration(toolConfig, config.catalog), async (rawArgs, mcpContext) => stampToolResult(await runInMcpRequestContext(mcpContext, name, async () => {
1420
- const args = isRecord(rawArgs) ? rawArgs : {};
1421
- try {
1422
- const round = await resolveMcpRound({
1423
- tool: mountable,
1424
- rawArgs: args,
1425
- context: mcpContext,
1426
- policy: mountable.method.mcp,
1427
- runtime: config.multiRoundRuntime,
1428
- runTool: config.runTool,
1429
- formatFailure: (result) => format(result, "none", name)
1430
- });
1431
- if (round.kind === "response")
1432
- return round.response;
1433
- const { present } = presentation;
1434
- if (!present) {
1435
- const result = await config.runTool(mountable, args, round.context);
1436
- return format(result, descriptor.outputMode, name);
1437
- }
1438
- const result = await config.runTool(mountable, args, round.context, {
1439
- finalizeOutput: async (data) => {
1440
- const presented = await present(data);
1441
- if (!isRecord(presented)) {
1442
- throw new AppError2("INTERNAL_SERVER_ERROR", "Runtime MCP presenter did not return a result", 500);
1443
- }
1444
- if ("structuredContent" in presented || "isError" in presented) {
1445
- throw new AppError2("INTERNAL_SERVER_ERROR", "Runtime MCP presenter cannot set framework-owned structuredContent or isError", 500);
1446
- }
1447
- const structured = format({ ok: true, data }, descriptor.outputMode, name).structuredContent;
1448
- const response = structured === undefined ? presented : { ...presented, structuredContent: structured };
1449
- if (!isCallToolResult(response)) {
1450
- throw new AppError2("INTERNAL_SERVER_ERROR", "Runtime MCP presenter returned an invalid CallToolResult", 500);
1451
- }
1452
- return response;
1453
- }
1454
- });
1455
- if (!result.ok)
1456
- return format(result, "none", name);
1457
- if (!isCallToolResult(result.data)) {
1458
- throw new Error("[stitchkit] Runtime MCP presenter invariant failed");
1459
- }
1460
- return result.data;
1461
- } catch (err) {
1462
- return format(toolResultFromError(err), "none", name);
1463
- }
1464
- }), config.catalog));
1465
- }
1466
-
1467
- // src/tools/mcp/runtime-tools.ts
1468
- function mountPreparedRuntimeMcp(server, tools, config) {
1469
- const runTool = createToolRunner({
1470
- source: "mcp",
1471
- toolSurface: true,
1472
- context: config.context,
1473
- hooks: config.hooks,
1474
- lifecycle: config.lifecycle,
1475
- coerceJsonArgs: config.coerceJsonArgs,
1476
- onOutputStrip: config.onOutputStrip
1477
- });
1478
- for (const { definition, descriptor } of tools) {
1479
- const present = definition.present?.mcp;
1480
- registerMcpTool(server, {
1481
- name: definition.name,
1482
- description: definition.description,
1483
- annotations: definition.annotations,
1484
- ui: definition.ui,
1485
- ...present && { present: (data) => present(data) }
1486
- }, descriptor, {
1487
- runTool,
1488
- formatResult: config.formatResult,
1489
- catalog: config.catalog,
1490
- multiRoundRuntime: config.multiRoundRuntime
1491
- });
1492
- }
1493
- }
1494
-
1495
- // src/tools/mcp/mount.ts
1496
- function validateMcpSchemas(config) {
1497
- prepareMcpSurface(config.services, {
1498
- extend: config.extend,
1499
- flattenUnionInput: config.flattenUnionInput,
1500
- schemaValidation: config,
1501
- logger: config.logger
1502
- });
1503
- }
1504
- function mountMcp(mcpServer, services, config = {}) {
1505
- const prepared = prepareMcpSurface(services, {
1506
- extend: config.extend,
1507
- flattenUnionInput: config.flattenUnionInput,
1508
- schemaValidation: config.schemaValidation,
1509
- logger: config.logger
1510
- });
1511
- mountPreparedMcp(mcpServer, prepared, {
1512
- ...config,
1513
- catalog: mcpCatalogStamp({ contractTools: prepared, runtimeTools: [] })
1514
- });
1515
- }
1516
- function mountPreparedMcp(mcpServer, prepared, config = {}) {
1517
- const runTool = createToolRunner({
1518
- source: "mcp",
1519
- toolSurface: true,
1520
- extend: config.extend,
1521
- context: config.context,
1522
- hooks: config.hooks,
1523
- lifecycle: config.lifecycle,
1524
- coerceJsonArgs: config.coerceJsonArgs,
1525
- onOutputStrip: config.onOutputStrip
1526
- });
1527
- for (const descriptor of prepared) {
1528
- const { method, name } = descriptor.mountable;
1529
- registerMcpTool(mcpServer, {
1530
- name,
1531
- description: method.desc,
1532
- annotations: method.annotations,
1533
- ui: method.ui
1534
- }, descriptor, {
1535
- runTool,
1536
- formatResult: (result, mode, toolName) => formatMcpResult(result, mode, toolName, config.errorHint),
1537
- catalog: config.catalog,
1538
- multiRoundRuntime: config.multiRoundRuntime
1539
- });
1540
- }
1541
- }
1542
- function buildMcpServer(config, auth) {
1543
- if (!isMcpServerBuildConfig(config)) {
1544
- throw new TypeError("[stitchkit] buildMcpServer requires a valid config object");
1545
- }
1546
- let surface;
1547
- if (config.surfaces) {
1548
- const key = config.selectSurface(auth);
1549
- if (!Object.hasOwn(config.surfaces, key)) {
1550
- throw new Error(`[stitchkit] Unknown MCP surface "${key}"`);
1551
- }
1552
- const selected = config.surfaces[key];
1553
- if (!selected)
1554
- throw new Error(`[stitchkit] Unknown MCP surface "${key}"`);
1555
- surface = selected;
1556
- } else {
1557
- const services = typeof config.services === "function" ? config.services(auth) : config.services;
1558
- const runtimeTools = typeof config.runtimeTools === "function" ? config.runtimeTools(auth) : config.runtimeTools;
1559
- surface = { services, runtimeTools };
1560
- }
1561
- const prepared = prepareMcpServerSurface(surface, {
1562
- extend: config.extend,
1563
- flattenUnionInput: config.flattenUnionInput,
1564
- schemaValidation: config.schemaValidation,
1565
- logger: config.logger,
1566
- multiRound: {
1567
- stateConfigured: config.multiRound !== undefined,
1568
- maxRounds: config.multiRound?.serving?.maxRounds ?? 10
1569
- }
1570
- });
1571
- return buildMcpServerFromPrepared(config, auth, prepared);
1572
- }
1573
- function isMcpServerBuildConfig(value) {
1574
- return isRecord(value) && isRecord(value.serverInfo);
1575
- }
1576
- function buildMcpServerFromPrepared(config, auth, prepared) {
1577
- let roundCodec;
1578
- if (config.multiRound) {
1579
- const principal = config.multiRound.state.principal(auth);
1580
- roundCodec = createRequestStateCodec({
1581
- key: config.multiRound.state.key,
1582
- ttlSeconds: config.multiRound.state.ttlSeconds,
1583
- bind: (mcpContext) => `${mcpContext.mcpReq.method}\x00${principal}`
1584
- });
1585
- }
1586
- const dynamicSurface = !config.surfaces && (typeof config.services === "function" || typeof config.runtimeTools === "function");
1587
- const serverOptions = {
1588
- ...config.instructions !== undefined && { instructions: config.instructions },
1589
- ...!dynamicSurface && config.cache?.operations !== undefined && {
1590
- cacheHints: config.cache.operations
1591
- },
1592
- ...config.multiRound?.serving !== undefined && {
1593
- inputRequired: config.multiRound.serving
1594
- },
1595
- ...roundCodec !== undefined && {
1596
- requestState: { verify: roundCodec.verify }
1597
- }
1598
- };
1599
- const server = new McpServer(config.serverInfo, serverOptions);
1600
- const context = config.context?.(auth);
1601
- const catalog = mcpCatalogStamp(prepared);
1602
- mountPreparedMcp(server, prepared.contractTools, {
1603
- catalog,
1604
- context,
1605
- hooks: config.hooks,
1606
- lifecycle: config.lifecycle,
1607
- extend: config.extend,
1608
- schemaValidation: config.schemaValidation,
1609
- logger: config.logger,
1610
- coerceJsonArgs: config.coerceJsonArgs,
1611
- flattenUnionInput: config.flattenUnionInput,
1612
- errorHint: config.errorHint,
1613
- onOutputStrip: config.onOutputStrip,
1614
- ...roundCodec !== undefined && {
1615
- multiRoundRuntime: {
1616
- codec: roundCodec,
1617
- maxRounds: config.multiRound?.serving?.maxRounds ?? 10
1618
- }
1619
- }
1620
- });
1621
- mountPreparedRuntimeMcp(server, prepared.runtimeTools, {
1622
- catalog,
1623
- context,
1624
- hooks: config.hooks,
1625
- lifecycle: config.lifecycle,
1626
- coerceJsonArgs: config.coerceJsonArgs,
1627
- onOutputStrip: config.onOutputStrip,
1628
- formatResult: (result, mode, toolName) => formatMcpResult(result, mode, toolName, config.errorHint),
1629
- ...roundCodec !== undefined && {
1630
- multiRoundRuntime: {
1631
- codec: roundCodec,
1632
- maxRounds: config.multiRound?.serving?.maxRounds ?? 10
1633
- }
1634
- }
1635
- });
1636
- config.rawTools?.(server, auth);
1637
- for (const resource of config.resources ?? []) {
1638
- mountMcpResource(server, resource);
1639
- }
1640
- return server;
1641
- }
1642
- function mountMcpResource(server, resource) {
1643
- server.registerResource(resource.name, resource.uri, {
1644
- mimeType: resource.mimeType ?? RESOURCE_MIME_TYPE,
1645
- ...resource.cacheHint !== undefined && { cacheHint: resource.cacheHint }
1646
- }, async () => ({
1647
- contents: [
1648
- {
1649
- uri: resource.uri,
1650
- mimeType: resource.mimeType ?? RESOURCE_MIME_TYPE,
1651
- text: await resource.read(),
1652
- ...resource.ui && { _meta: { ui: resource.ui } }
1653
- }
1654
- ]
1655
- }));
1656
- }
1657
-
1658
- // src/tools/mcp/handler.ts
1659
- function jsonRpcError(code, message, status, headers) {
1660
- return Response.json({ jsonrpc: "2.0", error: { code, message }, id: null }, { status, headers });
1661
- }
1662
- function hostValidationResponse(request, allowedHosts) {
1663
- if (request.headers.has("host")) {
1664
- return hostHeaderValidationResponse(request, [...allowedHosts]);
1665
- }
1666
- const hostname = new URL(request.url).hostname;
1667
- if (allowedHosts.includes(hostname))
1668
- return;
1669
- return jsonRpcError(-32000, "Invalid Host header", 403);
1670
- }
1671
- function prepareStaticSurface(config) {
1672
- const preparation = {
1673
- logger: config.logger,
1674
- extend: config.extend,
1675
- flattenUnionInput: config.flattenUnionInput,
1676
- schemaValidation: config.schemaValidation,
1677
- multiRound: {
1678
- stateConfigured: config.multiRound !== undefined,
1679
- maxRounds: config.multiRound?.serving?.maxRounds ?? 10
1680
- }
1681
- };
1682
- if (config.surfaces && config.selectSurface) {
1683
- const preparedByKey = new Map;
1684
- const preparedBySurface = new WeakMap;
1685
- for (const key in config.surfaces) {
1686
- if (!Object.hasOwn(config.surfaces, key))
1687
- continue;
1688
- const surface = config.surfaces[key];
1689
- if (!surface)
1690
- continue;
1691
- const existing = preparedBySurface.get(surface);
1692
- const prepared = existing ?? prepareMcpServerSurface(surface, preparation);
1693
- if (!existing)
1694
- preparedBySurface.set(surface, prepared);
1695
- preparedByKey.set(key, prepared);
1696
- }
1697
- return (auth) => {
1698
- const key = config.selectSurface(auth);
1699
- const prepared = preparedByKey.get(key);
1700
- if (!prepared)
1701
- throw new Error(`[stitchkit] Unknown MCP surface "${key}"`);
1702
- return buildMcpServerFromPrepared(config, auth, prepared);
1703
- };
1704
- }
1705
- if (config.services && typeof config.services !== "function" && typeof config.runtimeTools !== "function") {
1706
- const prepared = prepareMcpServerSurface({ services: config.services, runtimeTools: config.runtimeTools }, preparation);
1707
- return (auth) => buildMcpServerFromPrepared(config, auth, prepared);
1708
- }
1709
- return null;
1710
- }
1711
- function createMcpHandler(config) {
1712
- const buildPrepared = prepareStaticSurface(config);
1713
- const authByCarrier = new WeakMap;
1714
- let closed = false;
1715
- let resolveClosed;
1716
- const closedSignal = new Promise((resolve) => {
1717
- resolveClosed = resolve;
1718
- });
1719
- const sdkHandler = createSdkMcpHandler(({ authInfo }) => {
1720
- const resolved = authInfo ? authByCarrier.get(authInfo) : undefined;
1721
- if (!resolved) {
1722
- throw new Error("[stitchkit] MCP request reached the SDK without resolved auth");
1723
- }
1724
- const auth = resolved.value;
1725
- return buildPrepared ? buildPrepared(auth) : buildMcpServer(config, auth);
1726
- }, {
1727
- legacy: config.legacy === "reject" ? "reject" : "stateless",
1728
- maxSubscriptions: 0
1729
- });
1730
- const unauthorized = () => {
1731
- const headers = config.protectedResource ? { "WWW-Authenticate": wwwAuthenticateHeader(config.protectedResource.resource) } : undefined;
1732
- return jsonRpcError(-32001, "Authorization required", 401, headers);
1733
- };
1734
- const observeRejection = (request, response) => {
1735
- if (response.status < 400 || !config.onTransportRejected)
1736
- return response;
1737
- Promise.resolve(config.onTransportRejected({ request, response: response.clone() })).catch(() => {
1738
- return;
1739
- });
1740
- return response;
1741
- };
1742
- return {
1743
- fetch: async (request) => {
1744
- if (closed) {
1745
- return observeRejection(request, jsonRpcError(-32000, "MCP handler is closed", 503));
1746
- }
1747
- const allowedHosts = config.security?.allowedHosts ?? localhostAllowedHostnames();
1748
- const hostRejection = hostValidationResponse(request, allowedHosts);
1749
- if (hostRejection)
1750
- return observeRejection(request, hostRejection);
1751
- const allowedOrigins = config.security?.allowedOrigins ?? localhostAllowedOrigins();
1752
- const originRejection = originValidationResponse(request, [...allowedOrigins]);
1753
- if (originRejection)
1754
- return observeRejection(request, originRejection);
1755
- const auth = await Promise.race([
1756
- Promise.resolve(config.auth(request)),
1757
- closedSignal.then(() => null)
1758
- ]);
1759
- if (closed) {
1760
- return observeRejection(request, jsonRpcError(-32000, "MCP handler is closed", 503));
1761
- }
1762
- if (auth == null)
1763
- return observeRejection(request, unauthorized());
1764
- const authCarrier = {
1765
- token: "",
1766
- clientId: config.multiRound?.state.principal(auth) ?? "stitchkit",
1767
- scopes: []
1768
- };
1769
- authByCarrier.set(authCarrier, { value: auth });
1770
- try {
1771
- return observeRejection(request, await sdkHandler.fetch(request, { authInfo: authCarrier }));
1772
- } finally {
1773
- authByCarrier.delete(authCarrier);
1774
- }
1775
- },
1776
- close: async () => {
1777
- if (closed)
1778
- return;
1779
- closed = true;
1780
- resolveClosed?.();
1781
- await sdkHandler.close();
1782
- }
1783
- };
1784
- }
1785
- function createMcpHttpRoute(config) {
1786
- return {
1787
- method: "ALL",
1788
- path: config.path,
1789
- handler: (request) => config.handler.fetch(request)
1790
- };
1791
- }
1792
- // src/tools/mcp/stdio.ts
1793
- import { serveStdio } from "@modelcontextprotocol/server/stdio";
1794
- async function createStdioMcpServer(config) {
1795
- const auth = await config.auth;
1796
- return serveStdio(() => buildMcpServer(config, auth), {
1797
- legacy: config.legacy ?? "serve",
1798
- maxSubscriptions: 0
1799
- });
1800
- }
1801
- // src/tools/mcp/stdio-signals.ts
1802
- var bound = new WeakSet;
1803
- function bindStdioProcessSignals(handle, options = {}) {
1804
- if (bound.has(handle)) {
1805
- throw new Error("[stitchkit] bindStdioProcessSignals: this stdio handle is already bound; close the first binding before creating another");
1806
- }
1807
- bound.add(handle);
1808
- const signals = [...new Set(options.signals ?? DEFAULT_PROCESS_SIGNALS)];
1809
- const source = options.signalSource ?? defaultSignalSource;
1810
- const handlers = [];
1811
- let started = false;
1812
- let sameTurnAsStart = false;
1813
- let closed = false;
1814
- let resolveChain = () => {
1815
- return;
1816
- };
1817
- let rejectChain = () => {
1818
- return;
1819
- };
1820
- const promise = new Promise((resolve, reject) => {
1821
- resolveChain = resolve;
1822
- rejectChain = reject;
1823
- });
1824
- promise.catch(() => {
1825
- return;
1826
- });
1827
- const removeListeners = () => {
1828
- if (closed)
1829
- return;
1830
- closed = true;
1831
- for (const [signal, handler] of handlers)
1832
- source.off(signal, handler);
1833
- if (!started)
1834
- bound.delete(handle);
1835
- };
1836
- const close = () => {
1837
- const hadStarted = started;
1838
- removeListeners();
1839
- if (!hadStarted)
1840
- resolveChain();
1841
- };
1842
- const run = async (signal) => {
1843
- try {
1844
- await options.onClose?.(signal);
1845
- } catch (error) {
1846
- reportSignalError("prepare", error, options.onError);
1847
- }
1848
- try {
1849
- await handle.close();
1850
- } catch (error) {
1851
- rejectChain(error);
1852
- reportSignalError("close", error, options.onError);
1853
- removeListeners();
1854
- return;
1855
- }
1856
- resolveChain();
1857
- try {
1858
- await options.onComplete?.();
1859
- } catch (error) {
1860
- reportSignalError("complete", error, options.onError);
1861
- } finally {
1862
- removeListeners();
1863
- }
1864
- };
1865
- const onSignal = (signal) => {
1866
- if (!started) {
1867
- started = true;
1868
- sameTurnAsStart = true;
1869
- queueMicrotask(() => {
1870
- sameTurnAsStart = false;
1871
- });
1872
- run(signal).catch((error) => reportSignalError("close", error, options.onError));
1873
- return;
1874
- }
1875
- if (sameTurnAsStart)
1876
- return;
1877
- removeListeners();
1878
- guardSignalCallback(() => options.onRepeatedSignal?.(signal), "close", options.onError);
1879
- let restored = false;
1880
- try {
1881
- restored = source.raiseDefault(signal);
1882
- } catch (error) {
1883
- reportSignalError("close", error, options.onError);
1884
- }
1885
- if (!restored) {
1886
- guardSignalCallback(() => options.onEscalationBlocked?.(signal), "close", options.onError);
1887
- }
1888
- };
1889
- for (const signal of signals) {
1890
- const handler = () => onSignal(signal);
1891
- handlers.push([signal, handler]);
1892
- source.on(signal, handler);
1893
- }
1894
- return { promise, close };
1895
- }
1896
831
  // src/tools/operations/async-operation-id.ts
1897
- import { z as z4 } from "zod";
832
+ import { z as z2 } from "zod";
1898
833
  function adapterResult(capability, target, schema, value) {
1899
834
  const parsed = schema.safeParse(value);
1900
835
  if (!parsed.success) {
@@ -1923,7 +858,7 @@ function assertWireStableIdSchema(schema, boundary) {
1923
858
  if (typeof value !== "object" || value === null || visited.has(value))
1924
859
  continue;
1925
860
  visited.add(value);
1926
- if (value instanceof z4.ZodType) {
861
+ if (value instanceof z2.ZodType) {
1927
862
  const definition = value._zod.def;
1928
863
  if (NON_WIRE_STABLE_ZOD_TYPES.has(definition.type) || "coerce" in definition && definition.coerce === true || "checks" in definition && Array.isArray(definition.checks) && definition.checks.some(hasOverwriteCheck)) {
1929
864
  throw new Error(`${boundary} must use a wire-stable ID schema without transforms, coercion, defaults or overwrites; use binding: "adapted" with explicit ID adapters`);
@@ -2303,7 +1238,7 @@ function defineAsyncOperation(config) {
2303
1238
  };
2304
1239
  }
2305
1240
  // src/tools/operations/mount-wait.ts
2306
- import { z as z5 } from "zod";
1241
+ import { z as z3 } from "zod";
2307
1242
 
2308
1243
  // src/tools/transfer/native-result.ts
2309
1244
  function textResult(text, isError = false) {
@@ -2315,7 +1250,7 @@ function textResult(text, isError = false) {
2315
1250
  function mountWait(server, config) {
2316
1251
  const name = config.name ?? "wait";
2317
1252
  assertToolName(name, "<native>", "wait");
2318
- server.registerTool(name, { description: config.description, inputSchema: z5.object(config.inputSchema) }, async (rawArgs, mcpContext) => {
1253
+ server.registerTool(name, { description: config.description, inputSchema: z3.object(config.inputSchema) }, async (rawArgs, mcpContext) => {
2319
1254
  const args = isRecord(rawArgs) ? rawArgs : {};
2320
1255
  const report = createMcpProgressReporter(mcpContext);
2321
1256
  let last;
@@ -2426,11 +1361,11 @@ function createToolLogger(config = {}) {
2426
1361
  // src/tools/toolkit.ts
2427
1362
  function createToolkit() {
2428
1363
  return {
2429
- mountMcp: (server, services, config) => mountMcp(server, services, config),
1364
+ mountMcp: (server, services, config) => mountMcp2(server, services, config),
2430
1365
  mountAgent: (services, config) => mountAgent2(services, config),
2431
- buildMcpServer: (config, auth) => buildMcpServer(config, auth),
2432
- createMcpHandler: (config) => createMcpHandler(config),
2433
- createStdioMcpServer: (config) => createStdioMcpServer(config),
1366
+ buildMcpServer: (config, auth) => buildMcpServer2(config, auth),
1367
+ createMcpHandler: (config) => createMcpHandler2(config),
1368
+ createStdioMcpServer: (config) => createStdioMcpServer2(config),
2434
1369
  createCli: (config) => createCli2(config)
2435
1370
  };
2436
1371
  }
@@ -2578,7 +1513,7 @@ function defineDownloadTool(config) {
2578
1513
  });
2579
1514
  }
2580
1515
  // src/tools/transfer/define-upload-tool.ts
2581
- import { z as z6 } from "zod";
1516
+ import { z as z4 } from "zod";
2582
1517
 
2583
1518
  // src/tools/transfer/upload-core.ts
2584
1519
  function runUploadOperation(files, path, upload, signal) {
@@ -2587,7 +1522,7 @@ function runUploadOperation(files, path, upload, signal) {
2587
1522
  }
2588
1523
 
2589
1524
  // src/tools/transfer/define-upload-tool.ts
2590
- var UploadToolInputSchema = z6.object({
1525
+ var UploadToolInputSchema = z4.object({
2591
1526
  path: ManagedFilePathSchema2.describe("Path relative to the configured file boundary")
2592
1527
  });
2593
1528
  function defineUploadTool(config) {
@@ -2818,11 +1753,11 @@ function defineViewFileTool(config) {
2818
1753
  });
2819
1754
  }
2820
1755
  // src/tools/transfer/mount-download.ts
2821
- import { z as z7 } from "zod";
1756
+ import { z as z5 } from "zod";
2822
1757
  function mountDownload(server, config) {
2823
1758
  const name = config.name ?? "download";
2824
1759
  assertToolName(name, "<native>", "download");
2825
- server.registerTool(name, { description: config.description, inputSchema: z7.object(config.inputSchema) }, async (rawArgs) => {
1760
+ server.registerTool(name, { description: config.description, inputSchema: z5.object(config.inputSchema) }, async (rawArgs) => {
2826
1761
  const args = isRecord(rawArgs) ? rawArgs : {};
2827
1762
  try {
2828
1763
  const url = await config.resolveUrl(args);
@@ -2937,33 +1872,33 @@ function summarizeTransports(surface) {
2937
1872
  export {
2938
1873
  AgentToolError2 as AgentToolError,
2939
1874
  AsyncOperationCancelResultSchema2 as AsyncOperationCancelResultSchema,
2940
- EXT_APPS_BUNDLE_PLACEHOLDER,
1875
+ EXT_APPS_BUNDLE_PLACEHOLDER2 as EXT_APPS_BUNDLE_PLACEHOLDER,
2941
1876
  EffectUnresolvedError2 as EffectUnresolvedError,
2942
- MCP_CATALOG_META_KEY,
1877
+ MCP_CATALOG_META_KEY2 as MCP_CATALOG_META_KEY,
2943
1878
  McpAnnotationsSchema2 as McpAnnotationsSchema,
2944
1879
  McpMediaContentSchema2 as McpMediaContentSchema,
2945
1880
  PORTABLE_JSON_SCHEMA_FORMATS2 as PORTABLE_JSON_SCHEMA_FORMATS,
2946
- PROTECTED_RESOURCE_PATH,
2947
- RESOURCE_MIME_TYPE,
1881
+ PROTECTED_RESOURCE_PATH2 as PROTECTED_RESOURCE_PATH,
1882
+ RESOURCE_MIME_TYPE2 as RESOURCE_MIME_TYPE,
2948
1883
  ToolExecutionControlError2 as ToolExecutionControlError,
2949
1884
  UploadToolInputSchema,
2950
1885
  ViewFileErrorSchema2 as ViewFileErrorSchema,
2951
1886
  ViewFileInputSchema2 as ViewFileInputSchema,
2952
1887
  ViewFileOutputSchema2 as ViewFileOutputSchema,
2953
1888
  bindContractAsyncOperation,
2954
- bindStdioProcessSignals,
2955
- buildMcpServer,
1889
+ bindStdioProcessSignals2 as bindStdioProcessSignals,
1890
+ buildMcpServer2 as buildMcpServer,
2956
1891
  buildToolManifest2 as buildToolManifest,
2957
1892
  coerceJsonArgs2 as coerceJsonArgs,
2958
1893
  collectTools2 as collectTools,
2959
1894
  composeToolLifecycle2 as composeToolLifecycle,
2960
1895
  createAsyncOperationSnapshotSchema2 as createAsyncOperationSnapshotSchema,
2961
1896
  createLocalStepDurability2 as createLocalStepDurability,
2962
- createMcpHandler,
2963
- createMcpHttpRoute,
1897
+ createMcpHandler2 as createMcpHandler,
1898
+ createMcpHttpRoute2 as createMcpHttpRoute,
2964
1899
  createRuntimeToolFactory2 as createRuntimeToolFactory,
2965
1900
  createSecureClientMetadataFetcher,
2966
- createStdioMcpServer,
1901
+ createStdioMcpServer2 as createStdioMcpServer,
2967
1902
  createToolInvoker2 as createToolInvoker,
2968
1903
  createToolLogger,
2969
1904
  createToolkit,
@@ -2979,25 +1914,25 @@ export {
2979
1914
  findNonPortableFormats2 as findNonPortableFormats,
2980
1915
  findUntypedProperties2 as findUntypedProperties,
2981
1916
  flattenToolJsonSchema2 as flattenToolJsonSchema,
2982
- inlineMcpAppBundle,
1917
+ inlineMcpAppBundle2 as inlineMcpAppBundle,
2983
1918
  isAgentToolError2 as isAgentToolError,
2984
1919
  isToolExecutionControlError2 as isToolExecutionControlError,
2985
1920
  listContractToolNames,
2986
1921
  listToolNames,
2987
- mcpCatalogMeta,
1922
+ mcpCatalogMeta2 as mcpCatalogMeta,
2988
1923
  mountAgent2 as mountAgent,
2989
1924
  mountDownload,
2990
- mountMcp,
2991
- mountMcpResource,
1925
+ mountMcp2 as mountMcp,
1926
+ mountMcpResource2 as mountMcpResource,
2992
1927
  mountOAuthProvider,
2993
1928
  mountUpload,
2994
1929
  mountViewFile,
2995
1930
  mountWait,
2996
- oauthProtectedResourceRoute,
2997
- protectedResourceMetadataUrl,
2998
- readMcpCatalogStamp,
1931
+ oauthProtectedResourceRoute2 as oauthProtectedResourceRoute,
1932
+ protectedResourceMetadataUrl2 as protectedResourceMetadataUrl,
1933
+ readMcpCatalogStamp2 as readMcpCatalogStamp,
2999
1934
  resolveMedia,
3000
1935
  summarizeTransports,
3001
- validateMcpSchemas,
3002
- wwwAuthenticateHeader
1936
+ validateMcpSchemas2 as validateMcpSchemas,
1937
+ wwwAuthenticateHeader2 as wwwAuthenticateHeader
3003
1938
  };