@copilotkit/runtime 2.0.0-next.1 → 2.0.0-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (673) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -1
  3. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/_virtual/_rolldown/runtime.mjs +20 -0
  5. package/dist/agent/converters/aisdk.cjs +355 -0
  6. package/dist/agent/converters/aisdk.cjs.map +1 -0
  7. package/dist/agent/converters/aisdk.d.cts +22 -0
  8. package/dist/agent/converters/aisdk.d.cts.map +1 -0
  9. package/dist/agent/converters/aisdk.d.mts +22 -0
  10. package/dist/agent/converters/aisdk.d.mts.map +1 -0
  11. package/dist/agent/converters/aisdk.mjs +351 -0
  12. package/dist/agent/converters/aisdk.mjs.map +1 -0
  13. package/dist/agent/converters/index.d.mts +2 -0
  14. package/dist/agent/converters/tanstack.cjs +374 -0
  15. package/dist/agent/converters/tanstack.cjs.map +1 -0
  16. package/dist/agent/converters/tanstack.d.cts +83 -0
  17. package/dist/agent/converters/tanstack.d.cts.map +1 -0
  18. package/dist/agent/converters/tanstack.d.mts +83 -0
  19. package/dist/agent/converters/tanstack.d.mts.map +1 -0
  20. package/dist/agent/converters/tanstack.mjs +372 -0
  21. package/dist/agent/converters/tanstack.mjs.map +1 -0
  22. package/dist/agent/converters/usage.cjs +68 -0
  23. package/dist/agent/converters/usage.cjs.map +1 -0
  24. package/dist/agent/converters/usage.d.cts +19 -0
  25. package/dist/agent/converters/usage.d.cts.map +1 -0
  26. package/dist/agent/converters/usage.d.mts +19 -0
  27. package/dist/agent/converters/usage.d.mts.map +1 -0
  28. package/dist/agent/converters/usage.mjs +62 -0
  29. package/dist/agent/converters/usage.mjs.map +1 -0
  30. package/dist/agent/index.cjs +1328 -0
  31. package/dist/agent/index.cjs.map +1 -0
  32. package/dist/agent/index.d.cts +467 -0
  33. package/dist/agent/index.d.cts.map +1 -0
  34. package/dist/agent/index.d.mts +468 -0
  35. package/dist/agent/index.d.mts.map +1 -0
  36. package/dist/agent/index.mjs +1318 -0
  37. package/dist/agent/index.mjs.map +1 -0
  38. package/dist/agent/learned-skills.cjs +76 -0
  39. package/dist/agent/learned-skills.cjs.map +1 -0
  40. package/dist/agent/learned-skills.d.cts +15 -0
  41. package/dist/agent/learned-skills.d.cts.map +1 -0
  42. package/dist/agent/learned-skills.d.mts +15 -0
  43. package/dist/agent/learned-skills.d.mts.map +1 -0
  44. package/dist/agent/learned-skills.mjs +74 -0
  45. package/dist/agent/learned-skills.mjs.map +1 -0
  46. package/dist/agent/mcp-tool-names.cjs +82 -0
  47. package/dist/agent/mcp-tool-names.cjs.map +1 -0
  48. package/dist/agent/mcp-tool-names.mjs +80 -0
  49. package/dist/agent/mcp-tool-names.mjs.map +1 -0
  50. package/dist/agent/state-delta.cjs +321 -0
  51. package/dist/agent/state-delta.cjs.map +1 -0
  52. package/dist/agent/state-delta.mjs +320 -0
  53. package/dist/agent/state-delta.mjs.map +1 -0
  54. package/dist/agent/url-download.cjs +503 -0
  55. package/dist/agent/url-download.cjs.map +1 -0
  56. package/dist/agent/url-download.d.cts +79 -0
  57. package/dist/agent/url-download.d.cts.map +1 -0
  58. package/dist/agent/url-download.d.mts +79 -0
  59. package/dist/agent/url-download.d.mts.map +1 -0
  60. package/dist/agent/url-download.mjs +500 -0
  61. package/dist/agent/url-download.mjs.map +1 -0
  62. package/dist/express.cjs +7 -0
  63. package/dist/express.d.cts +4 -0
  64. package/dist/express.d.mts +4 -0
  65. package/dist/express.mjs +4 -0
  66. package/dist/hono.cjs +8 -0
  67. package/dist/hono.d.cts +4 -0
  68. package/dist/hono.d.mts +4 -0
  69. package/dist/hono.mjs +4 -0
  70. package/dist/index.cjs +86 -0
  71. package/dist/index.d.cts +28 -0
  72. package/dist/index.d.mts +28 -0
  73. package/dist/index.mjs +21 -5598
  74. package/dist/internal/learned-skills.cjs +21 -0
  75. package/dist/internal/learned-skills.d.cts +9 -0
  76. package/dist/internal/learned-skills.d.mts +9 -0
  77. package/dist/internal/learned-skills.mjs +9 -0
  78. package/dist/node.cjs +7 -0
  79. package/dist/node.d.cts +4 -0
  80. package/dist/node.d.mts +4 -0
  81. package/dist/node.mjs +4 -0
  82. package/dist/runtime/core/channel-activation-config.cjs +87 -0
  83. package/dist/runtime/core/channel-activation-config.cjs.map +1 -0
  84. package/dist/runtime/core/channel-activation-config.d.cts +39 -0
  85. package/dist/runtime/core/channel-activation-config.d.cts.map +1 -0
  86. package/dist/runtime/core/channel-activation-config.d.mts +39 -0
  87. package/dist/runtime/core/channel-activation-config.d.mts.map +1 -0
  88. package/dist/runtime/core/channel-activation-config.mjs +85 -0
  89. package/dist/runtime/core/channel-activation-config.mjs.map +1 -0
  90. package/dist/runtime/core/channel-manager.cjs +973 -0
  91. package/dist/runtime/core/channel-manager.cjs.map +1 -0
  92. package/dist/runtime/core/channel-manager.d.cts +166 -0
  93. package/dist/runtime/core/channel-manager.d.cts.map +1 -0
  94. package/dist/runtime/core/channel-manager.d.mts +167 -0
  95. package/dist/runtime/core/channel-manager.d.mts.map +1 -0
  96. package/dist/runtime/core/channel-manager.mjs +972 -0
  97. package/dist/runtime/core/channel-manager.mjs.map +1 -0
  98. package/dist/runtime/core/debug-event-bus.cjs +57 -0
  99. package/dist/runtime/core/debug-event-bus.cjs.map +1 -0
  100. package/dist/runtime/core/debug-event-bus.d.cts +18 -0
  101. package/dist/runtime/core/debug-event-bus.d.cts.map +1 -0
  102. package/dist/runtime/core/debug-event-bus.d.mts +18 -0
  103. package/dist/runtime/core/debug-event-bus.d.mts.map +1 -0
  104. package/dist/runtime/core/debug-event-bus.mjs +55 -0
  105. package/dist/runtime/core/debug-event-bus.mjs.map +1 -0
  106. package/dist/runtime/core/fetch-cors.cjs +71 -0
  107. package/dist/runtime/core/fetch-cors.cjs.map +1 -0
  108. package/dist/runtime/core/fetch-cors.d.cts +19 -0
  109. package/dist/runtime/core/fetch-cors.d.cts.map +1 -0
  110. package/dist/runtime/core/fetch-cors.d.mts +19 -0
  111. package/dist/runtime/core/fetch-cors.d.mts.map +1 -0
  112. package/dist/runtime/core/fetch-cors.mjs +69 -0
  113. package/dist/runtime/core/fetch-cors.mjs.map +1 -0
  114. package/dist/runtime/core/fetch-handler.cjs +539 -0
  115. package/dist/runtime/core/fetch-handler.cjs.map +1 -0
  116. package/dist/runtime/core/fetch-handler.d.cts +100 -0
  117. package/dist/runtime/core/fetch-handler.d.cts.map +1 -0
  118. package/dist/runtime/core/fetch-handler.d.mts +100 -0
  119. package/dist/runtime/core/fetch-handler.d.mts.map +1 -0
  120. package/dist/runtime/core/fetch-handler.mjs +538 -0
  121. package/dist/runtime/core/fetch-handler.mjs.map +1 -0
  122. package/dist/runtime/core/fetch-router.cjs +141 -0
  123. package/dist/runtime/core/fetch-router.cjs.map +1 -0
  124. package/dist/runtime/core/fetch-router.mjs +140 -0
  125. package/dist/runtime/core/fetch-router.mjs.map +1 -0
  126. package/dist/runtime/core/hooks.cjs +28 -0
  127. package/dist/runtime/core/hooks.cjs.map +1 -0
  128. package/dist/runtime/core/hooks.d.cts +121 -0
  129. package/dist/runtime/core/hooks.d.cts.map +1 -0
  130. package/dist/runtime/core/hooks.d.mts +121 -0
  131. package/dist/runtime/core/hooks.d.mts.map +1 -0
  132. package/dist/runtime/core/hooks.mjs +24 -0
  133. package/dist/runtime/core/hooks.mjs.map +1 -0
  134. package/dist/runtime/core/learning.cjs +61 -0
  135. package/dist/runtime/core/learning.cjs.map +1 -0
  136. package/dist/runtime/core/learning.d.cts +61 -0
  137. package/dist/runtime/core/learning.d.cts.map +1 -0
  138. package/dist/runtime/core/learning.d.mts +61 -0
  139. package/dist/runtime/core/learning.d.mts.map +1 -0
  140. package/dist/runtime/core/learning.mjs +56 -0
  141. package/dist/runtime/core/learning.mjs.map +1 -0
  142. package/dist/runtime/core/logger.cjs +21 -0
  143. package/dist/runtime/core/logger.cjs.map +1 -0
  144. package/dist/runtime/core/logger.d.cts +12 -0
  145. package/dist/runtime/core/logger.d.cts.map +1 -0
  146. package/dist/runtime/core/logger.d.mts +12 -0
  147. package/dist/runtime/core/logger.d.mts.map +1 -0
  148. package/dist/runtime/core/logger.mjs +18 -0
  149. package/dist/runtime/core/logger.mjs.map +1 -0
  150. package/dist/runtime/core/middleware-sse-parser.cjs +149 -0
  151. package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -0
  152. package/dist/runtime/core/middleware-sse-parser.d.cts +21 -0
  153. package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -0
  154. package/dist/runtime/core/middleware-sse-parser.d.mts +21 -0
  155. package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -0
  156. package/dist/runtime/core/middleware-sse-parser.mjs +148 -0
  157. package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -0
  158. package/dist/runtime/core/middleware.cjs +34 -0
  159. package/dist/runtime/core/middleware.cjs.map +1 -0
  160. package/dist/runtime/core/middleware.d.cts +31 -0
  161. package/dist/runtime/core/middleware.d.cts.map +1 -0
  162. package/dist/runtime/core/middleware.d.mts +31 -0
  163. package/dist/runtime/core/middleware.d.mts.map +1 -0
  164. package/dist/runtime/core/middleware.mjs +32 -0
  165. package/dist/runtime/core/middleware.mjs.map +1 -0
  166. package/dist/runtime/core/package-info.cjs +9 -0
  167. package/dist/runtime/core/package-info.cjs.map +1 -0
  168. package/dist/runtime/core/package-info.mjs +7 -0
  169. package/dist/runtime/core/package-info.mjs.map +1 -0
  170. package/dist/runtime/core/runtime-error-reporter.cjs +21 -0
  171. package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -0
  172. package/dist/runtime/core/runtime-error-reporter.mjs +18 -0
  173. package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -0
  174. package/dist/runtime/core/runtime.cjs +256 -0
  175. package/dist/runtime/core/runtime.cjs.map +1 -0
  176. package/dist/runtime/core/runtime.d.cts +481 -0
  177. package/dist/runtime/core/runtime.d.cts.map +1 -0
  178. package/dist/runtime/core/runtime.d.mts +481 -0
  179. package/dist/runtime/core/runtime.d.mts.map +1 -0
  180. package/dist/runtime/core/runtime.mjs +249 -0
  181. package/dist/runtime/core/runtime.mjs.map +1 -0
  182. package/dist/runtime/endpoints/auto-start-channels.cjs +46 -0
  183. package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -0
  184. package/dist/runtime/endpoints/auto-start-channels.mjs +45 -0
  185. package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -0
  186. package/dist/runtime/endpoints/express-single.cjs +43 -0
  187. package/dist/runtime/endpoints/express-single.cjs.map +1 -0
  188. package/dist/runtime/endpoints/express-single.d.cts +48 -0
  189. package/dist/runtime/endpoints/express-single.d.cts.map +1 -0
  190. package/dist/runtime/endpoints/express-single.d.mts +48 -0
  191. package/dist/runtime/endpoints/express-single.d.mts.map +1 -0
  192. package/dist/runtime/endpoints/express-single.mjs +43 -0
  193. package/dist/runtime/endpoints/express-single.mjs.map +1 -0
  194. package/dist/runtime/endpoints/express.cjs +68 -0
  195. package/dist/runtime/endpoints/express.cjs.map +1 -0
  196. package/dist/runtime/endpoints/express.d.cts +84 -0
  197. package/dist/runtime/endpoints/express.d.cts.map +1 -0
  198. package/dist/runtime/endpoints/express.d.mts +84 -0
  199. package/dist/runtime/endpoints/express.d.mts.map +1 -0
  200. package/dist/runtime/endpoints/express.mjs +66 -0
  201. package/dist/runtime/endpoints/express.mjs.map +1 -0
  202. package/dist/runtime/endpoints/hono-single.cjs +28 -0
  203. package/dist/runtime/endpoints/hono-single.cjs.map +1 -0
  204. package/dist/runtime/endpoints/hono-single.d.cts +43 -0
  205. package/dist/runtime/endpoints/hono-single.d.cts.map +1 -0
  206. package/dist/runtime/endpoints/hono-single.d.mts +43 -0
  207. package/dist/runtime/endpoints/hono-single.d.mts.map +1 -0
  208. package/dist/runtime/endpoints/hono-single.mjs +27 -0
  209. package/dist/runtime/endpoints/hono-single.mjs.map +1 -0
  210. package/dist/runtime/endpoints/hono.cjs +37 -0
  211. package/dist/runtime/endpoints/hono.cjs.map +1 -0
  212. package/dist/runtime/endpoints/hono.d.cts +96 -0
  213. package/dist/runtime/endpoints/hono.d.cts.map +1 -0
  214. package/dist/runtime/endpoints/hono.d.mts +96 -0
  215. package/dist/runtime/endpoints/hono.d.mts.map +1 -0
  216. package/dist/runtime/endpoints/hono.mjs +34 -0
  217. package/dist/runtime/endpoints/hono.mjs.map +1 -0
  218. package/dist/runtime/endpoints/index.d.cts +4 -0
  219. package/dist/runtime/endpoints/index.d.mts +4 -0
  220. package/dist/runtime/endpoints/load-express.cjs +35 -0
  221. package/dist/runtime/endpoints/load-express.cjs.map +1 -0
  222. package/dist/runtime/endpoints/load-express.mjs +34 -0
  223. package/dist/runtime/endpoints/load-express.mjs.map +1 -0
  224. package/dist/runtime/endpoints/node-fetch-handler.cjs +75 -0
  225. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -0
  226. package/dist/runtime/endpoints/node-fetch-handler.d.cts +11 -0
  227. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -0
  228. package/dist/runtime/endpoints/node-fetch-handler.d.mts +11 -0
  229. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -0
  230. package/dist/runtime/endpoints/node-fetch-handler.mjs +73 -0
  231. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -0
  232. package/dist/runtime/endpoints/node.cjs +16 -0
  233. package/dist/runtime/endpoints/node.cjs.map +1 -0
  234. package/dist/runtime/endpoints/node.d.cts +104 -0
  235. package/dist/runtime/endpoints/node.d.cts.map +1 -0
  236. package/dist/runtime/endpoints/node.d.mts +104 -0
  237. package/dist/runtime/endpoints/node.d.mts.map +1 -0
  238. package/dist/runtime/endpoints/node.mjs +16 -0
  239. package/dist/runtime/endpoints/node.mjs.map +1 -0
  240. package/dist/runtime/endpoints/single-route-helpers.cjs +130 -0
  241. package/dist/runtime/endpoints/single-route-helpers.cjs.map +1 -0
  242. package/dist/runtime/endpoints/single-route-helpers.mjs +125 -0
  243. package/dist/runtime/endpoints/single-route-helpers.mjs.map +1 -0
  244. package/dist/runtime/express.d.cts +2 -0
  245. package/dist/runtime/express.d.mts +2 -0
  246. package/dist/runtime/generative-ui/generative-ui-middleware.cjs +393 -0
  247. package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -0
  248. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts +20 -0
  249. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts.map +1 -0
  250. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts +20 -0
  251. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts.map +1 -0
  252. package/dist/runtime/generative-ui/generative-ui-middleware.mjs +392 -0
  253. package/dist/runtime/generative-ui/generative-ui-middleware.mjs.map +1 -0
  254. package/dist/runtime/generative-ui/index.d.cts +2 -0
  255. package/dist/runtime/generative-ui/index.d.mts +2 -0
  256. package/dist/runtime/generative-ui/surface-writer.cjs +85 -0
  257. package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -0
  258. package/dist/runtime/generative-ui/surface-writer.d.cts +32 -0
  259. package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -0
  260. package/dist/runtime/generative-ui/surface-writer.d.mts +32 -0
  261. package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -0
  262. package/dist/runtime/generative-ui/surface-writer.mjs +84 -0
  263. package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -0
  264. package/dist/runtime/handlers/get-runtime-info.cjs +140 -0
  265. package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -0
  266. package/dist/runtime/handlers/get-runtime-info.mjs +140 -0
  267. package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -0
  268. package/dist/runtime/handlers/handle-connect.cjs +62 -0
  269. package/dist/runtime/handlers/handle-connect.cjs.map +1 -0
  270. package/dist/runtime/handlers/handle-connect.mjs +62 -0
  271. package/dist/runtime/handlers/handle-connect.mjs.map +1 -0
  272. package/dist/runtime/handlers/handle-debug-events.cjs +33 -0
  273. package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -0
  274. package/dist/runtime/handlers/handle-debug-events.mjs +33 -0
  275. package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -0
  276. package/dist/runtime/handlers/handle-inspector-learning.cjs +56 -0
  277. package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -0
  278. package/dist/runtime/handlers/handle-inspector-learning.mjs +55 -0
  279. package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -0
  280. package/dist/runtime/handlers/handle-inspector-metadata.cjs +36 -0
  281. package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -0
  282. package/dist/runtime/handlers/handle-inspector-metadata.mjs +35 -0
  283. package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -0
  284. package/dist/runtime/handlers/handle-run.cjs +111 -0
  285. package/dist/runtime/handlers/handle-run.cjs.map +1 -0
  286. package/dist/runtime/handlers/handle-run.mjs +110 -0
  287. package/dist/runtime/handlers/handle-run.mjs.map +1 -0
  288. package/dist/runtime/handlers/handle-stop.cjs +102 -0
  289. package/dist/runtime/handlers/handle-stop.cjs.map +1 -0
  290. package/dist/runtime/handlers/handle-stop.mjs +101 -0
  291. package/dist/runtime/handlers/handle-stop.mjs.map +1 -0
  292. package/dist/runtime/handlers/handle-suggest.cjs +83 -0
  293. package/dist/runtime/handlers/handle-suggest.cjs.map +1 -0
  294. package/dist/runtime/handlers/handle-suggest.mjs +82 -0
  295. package/dist/runtime/handlers/handle-suggest.mjs.map +1 -0
  296. package/dist/runtime/handlers/handle-trajectory-connect.cjs +40 -0
  297. package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -0
  298. package/dist/runtime/handlers/handle-trajectory-connect.mjs +39 -0
  299. package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -0
  300. package/dist/runtime/handlers/handle-transcribe.cjs +112 -0
  301. package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -0
  302. package/dist/runtime/handlers/handle-transcribe.mjs +111 -0
  303. package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -0
  304. package/dist/runtime/handlers/header-utils.cjs +185 -0
  305. package/dist/runtime/handlers/header-utils.cjs.map +1 -0
  306. package/dist/runtime/handlers/header-utils.d.cts +53 -0
  307. package/dist/runtime/handlers/header-utils.d.cts.map +1 -0
  308. package/dist/runtime/handlers/header-utils.d.mts +53 -0
  309. package/dist/runtime/handlers/header-utils.d.mts.map +1 -0
  310. package/dist/runtime/handlers/header-utils.mjs +183 -0
  311. package/dist/runtime/handlers/header-utils.mjs.map +1 -0
  312. package/dist/runtime/handlers/intelligence/annotate.cjs +83 -0
  313. package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -0
  314. package/dist/runtime/handlers/intelligence/annotate.mjs +82 -0
  315. package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -0
  316. package/dist/runtime/handlers/intelligence/connect.cjs +68 -0
  317. package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -0
  318. package/dist/runtime/handlers/intelligence/connect.mjs +68 -0
  319. package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -0
  320. package/dist/runtime/handlers/intelligence/memories.cjs +260 -0
  321. package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -0
  322. package/dist/runtime/handlers/intelligence/memories.mjs +254 -0
  323. package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -0
  324. package/dist/runtime/handlers/intelligence/run.cjs +283 -0
  325. package/dist/runtime/handlers/intelligence/run.cjs.map +1 -0
  326. package/dist/runtime/handlers/intelligence/run.mjs +282 -0
  327. package/dist/runtime/handlers/intelligence/run.mjs.map +1 -0
  328. package/dist/runtime/handlers/intelligence/thread-names.cjs +172 -0
  329. package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -0
  330. package/dist/runtime/handlers/intelligence/thread-names.mjs +171 -0
  331. package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -0
  332. package/dist/runtime/handlers/intelligence/threads.cjs +399 -0
  333. package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -0
  334. package/dist/runtime/handlers/intelligence/threads.mjs +390 -0
  335. package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -0
  336. package/dist/runtime/handlers/shared/agent-utils.cjs +267 -0
  337. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -0
  338. package/dist/runtime/handlers/shared/agent-utils.mjs +262 -0
  339. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -0
  340. package/dist/runtime/handlers/shared/cloud-telemetry.cjs +30 -0
  341. package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -0
  342. package/dist/runtime/handlers/shared/cloud-telemetry.mjs +29 -0
  343. package/dist/runtime/handlers/shared/cloud-telemetry.mjs.map +1 -0
  344. package/dist/runtime/handlers/shared/describe-endpoint.cjs +25 -0
  345. package/dist/runtime/handlers/shared/describe-endpoint.cjs.map +1 -0
  346. package/dist/runtime/handlers/shared/describe-endpoint.mjs +24 -0
  347. package/dist/runtime/handlers/shared/describe-endpoint.mjs.map +1 -0
  348. package/dist/runtime/handlers/shared/intelligence-utils.cjs +24 -0
  349. package/dist/runtime/handlers/shared/intelligence-utils.cjs.map +1 -0
  350. package/dist/runtime/handlers/shared/intelligence-utils.mjs +23 -0
  351. package/dist/runtime/handlers/shared/intelligence-utils.mjs.map +1 -0
  352. package/dist/runtime/handlers/shared/json-response.cjs +14 -0
  353. package/dist/runtime/handlers/shared/json-response.cjs.map +1 -0
  354. package/dist/runtime/handlers/shared/json-response.mjs +12 -0
  355. package/dist/runtime/handlers/shared/json-response.mjs.map +1 -0
  356. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs +22 -0
  357. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs.map +1 -0
  358. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs +22 -0
  359. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs.map +1 -0
  360. package/dist/runtime/handlers/shared/memory-policy.cjs +78 -0
  361. package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -0
  362. package/dist/runtime/handlers/shared/memory-policy.mjs +77 -0
  363. package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -0
  364. package/dist/runtime/handlers/shared/platform-error.cjs +39 -0
  365. package/dist/runtime/handlers/shared/platform-error.cjs.map +1 -0
  366. package/dist/runtime/handlers/shared/platform-error.mjs +39 -0
  367. package/dist/runtime/handlers/shared/platform-error.mjs.map +1 -0
  368. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +50 -0
  369. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -0
  370. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +49 -0
  371. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -0
  372. package/dist/runtime/handlers/shared/sse-keep-alive.cjs +68 -0
  373. package/dist/runtime/handlers/shared/sse-keep-alive.cjs.map +1 -0
  374. package/dist/runtime/handlers/shared/sse-keep-alive.mjs +66 -0
  375. package/dist/runtime/handlers/shared/sse-keep-alive.mjs.map +1 -0
  376. package/dist/runtime/handlers/shared/sse-response.cjs +237 -0
  377. package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -0
  378. package/dist/runtime/handlers/shared/sse-response.mjs +236 -0
  379. package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -0
  380. package/dist/runtime/handlers/shared/thread-access.cjs +137 -0
  381. package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -0
  382. package/dist/runtime/handlers/shared/thread-access.d.cts +28 -0
  383. package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -0
  384. package/dist/runtime/handlers/shared/thread-access.d.mts +28 -0
  385. package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -0
  386. package/dist/runtime/handlers/shared/thread-access.mjs +132 -0
  387. package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -0
  388. package/dist/runtime/handlers/sse/connect.cjs +23 -0
  389. package/dist/runtime/handlers/sse/connect.cjs.map +1 -0
  390. package/dist/runtime/handlers/sse/connect.mjs +23 -0
  391. package/dist/runtime/handlers/sse/connect.mjs.map +1 -0
  392. package/dist/runtime/handlers/sse/run.cjs +44 -0
  393. package/dist/runtime/handlers/sse/run.cjs.map +1 -0
  394. package/dist/runtime/handlers/sse/run.mjs +44 -0
  395. package/dist/runtime/handlers/sse/run.mjs.map +1 -0
  396. package/dist/runtime/hono.d.cts +2 -0
  397. package/dist/runtime/hono.d.mts +2 -0
  398. package/dist/runtime/index.d.cts +34 -0
  399. package/dist/runtime/index.d.cts.map +1 -0
  400. package/dist/runtime/index.d.mts +34 -0
  401. package/dist/runtime/index.d.mts.map +1 -0
  402. package/dist/runtime/intelligence-platform/client.cjs +1338 -0
  403. package/dist/runtime/intelligence-platform/client.cjs.map +1 -0
  404. package/dist/runtime/intelligence-platform/client.d.cts +824 -0
  405. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -0
  406. package/dist/runtime/intelligence-platform/client.d.mts +824 -0
  407. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -0
  408. package/dist/runtime/intelligence-platform/client.mjs +1334 -0
  409. package/dist/runtime/intelligence-platform/client.mjs.map +1 -0
  410. package/dist/runtime/intelligence-platform/experimental.d.cts +26 -0
  411. package/dist/runtime/intelligence-platform/experimental.d.cts.map +1 -0
  412. package/dist/runtime/intelligence-platform/experimental.d.mts +26 -0
  413. package/dist/runtime/intelligence-platform/experimental.d.mts.map +1 -0
  414. package/dist/runtime/intelligence-platform/index.d.cts +3 -0
  415. package/dist/runtime/intelligence-platform/index.d.mts +3 -0
  416. package/dist/runtime/intelligence-platform/learned-skills.cjs +95 -0
  417. package/dist/runtime/intelligence-platform/learned-skills.cjs.map +1 -0
  418. package/dist/runtime/intelligence-platform/learned-skills.d.cts +43 -0
  419. package/dist/runtime/intelligence-platform/learned-skills.d.cts.map +1 -0
  420. package/dist/runtime/intelligence-platform/learned-skills.d.mts +43 -0
  421. package/dist/runtime/intelligence-platform/learned-skills.d.mts.map +1 -0
  422. package/dist/runtime/intelligence-platform/learned-skills.mjs +92 -0
  423. package/dist/runtime/intelligence-platform/learned-skills.mjs.map +1 -0
  424. package/dist/runtime/intelligence-platform/learning-management.cjs +203 -0
  425. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -0
  426. package/dist/runtime/intelligence-platform/learning-management.d.cts +111 -0
  427. package/dist/runtime/intelligence-platform/learning-management.d.cts.map +1 -0
  428. package/dist/runtime/intelligence-platform/learning-management.d.mts +111 -0
  429. package/dist/runtime/intelligence-platform/learning-management.d.mts.map +1 -0
  430. package/dist/runtime/intelligence-platform/learning-management.mjs +193 -0
  431. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -0
  432. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +131 -0
  433. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -0
  434. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +10 -0
  435. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -0
  436. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +10 -0
  437. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -0
  438. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +127 -0
  439. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -0
  440. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +65 -0
  441. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -0
  442. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts +47 -0
  443. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts.map +1 -0
  444. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts +47 -0
  445. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts.map +1 -0
  446. package/dist/runtime/intelligence-platform/skill-registry/config.mjs +65 -0
  447. package/dist/runtime/intelligence-platform/skill-registry/config.mjs.map +1 -0
  448. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs +10 -0
  449. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs.map +1 -0
  450. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts +7 -0
  451. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts.map +1 -0
  452. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts +7 -0
  453. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts.map +1 -0
  454. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs +10 -0
  455. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs.map +1 -0
  456. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +7 -0
  457. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +7 -0
  458. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +247 -0
  459. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -0
  460. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts +36 -0
  461. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -0
  462. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts +36 -0
  463. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -0
  464. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +246 -0
  465. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -0
  466. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs +41 -0
  467. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs.map +1 -0
  468. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts +12 -0
  469. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts.map +1 -0
  470. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts +12 -0
  471. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts.map +1 -0
  472. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs +38 -0
  473. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs.map +1 -0
  474. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs +92 -0
  475. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs.map +1 -0
  476. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts +27 -0
  477. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts.map +1 -0
  478. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts +27 -0
  479. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts.map +1 -0
  480. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs +91 -0
  481. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs.map +1 -0
  482. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +142 -0
  483. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -0
  484. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +141 -0
  485. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -0
  486. package/dist/runtime/intelligence-platform/trajectories.cjs +95 -0
  487. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -0
  488. package/dist/runtime/intelligence-platform/trajectories.d.cts +11 -0
  489. package/dist/runtime/intelligence-platform/trajectories.d.cts.map +1 -0
  490. package/dist/runtime/intelligence-platform/trajectories.d.mts +11 -0
  491. package/dist/runtime/intelligence-platform/trajectories.d.mts.map +1 -0
  492. package/dist/runtime/intelligence-platform/trajectories.mjs +91 -0
  493. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -0
  494. package/dist/runtime/node.d.cts +2 -0
  495. package/dist/runtime/node.d.mts +2 -0
  496. package/dist/runtime/runner/agent-runner.cjs +82 -0
  497. package/dist/runtime/runner/agent-runner.cjs.map +1 -0
  498. package/dist/runtime/runner/agent-runner.d.cts +151 -0
  499. package/dist/runtime/runner/agent-runner.d.cts.map +1 -0
  500. package/dist/runtime/runner/agent-runner.d.mts +151 -0
  501. package/dist/runtime/runner/agent-runner.d.mts.map +1 -0
  502. package/dist/runtime/runner/agent-runner.mjs +73 -0
  503. package/dist/runtime/runner/agent-runner.mjs.map +1 -0
  504. package/dist/runtime/runner/in-memory.cjs +741 -0
  505. package/dist/runtime/runner/in-memory.cjs.map +1 -0
  506. package/dist/runtime/runner/in-memory.d.cts +427 -0
  507. package/dist/runtime/runner/in-memory.d.cts.map +1 -0
  508. package/dist/runtime/runner/in-memory.d.mts +427 -0
  509. package/dist/runtime/runner/in-memory.d.mts.map +1 -0
  510. package/dist/runtime/runner/in-memory.mjs +734 -0
  511. package/dist/runtime/runner/in-memory.mjs.map +1 -0
  512. package/dist/runtime/runner/index.d.cts +5 -0
  513. package/dist/runtime/runner/index.d.mts +5 -0
  514. package/dist/runtime/runner/index.mjs +6 -0
  515. package/dist/runtime/runner/intelligence.cjs +617 -0
  516. package/dist/runtime/runner/intelligence.cjs.map +1 -0
  517. package/dist/runtime/runner/intelligence.d.cts +104 -0
  518. package/dist/runtime/runner/intelligence.d.cts.map +1 -0
  519. package/dist/runtime/runner/intelligence.d.mts +104 -0
  520. package/dist/runtime/runner/intelligence.d.mts.map +1 -0
  521. package/dist/runtime/runner/intelligence.mjs +616 -0
  522. package/dist/runtime/runner/intelligence.mjs.map +1 -0
  523. package/dist/runtime/telemetry/disclosure.cjs +25 -0
  524. package/dist/runtime/telemetry/disclosure.cjs.map +1 -0
  525. package/dist/runtime/telemetry/disclosure.mjs +24 -0
  526. package/dist/runtime/telemetry/disclosure.mjs.map +1 -0
  527. package/dist/runtime/telemetry/events.d.cts +66 -0
  528. package/dist/runtime/telemetry/events.d.cts.map +1 -0
  529. package/dist/runtime/telemetry/events.d.mts +66 -0
  530. package/dist/runtime/telemetry/events.d.mts.map +1 -0
  531. package/dist/runtime/telemetry/instance-created.cjs +34 -0
  532. package/dist/runtime/telemetry/instance-created.cjs.map +1 -0
  533. package/dist/runtime/telemetry/instance-created.mjs +34 -0
  534. package/dist/runtime/telemetry/instance-created.mjs.map +1 -0
  535. package/dist/runtime/telemetry/telemetry-client.cjs +108 -0
  536. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -0
  537. package/dist/runtime/telemetry/telemetry-client.d.cts +10 -0
  538. package/dist/runtime/telemetry/telemetry-client.d.cts.map +1 -0
  539. package/dist/runtime/telemetry/telemetry-client.d.mts +10 -0
  540. package/dist/runtime/telemetry/telemetry-client.d.mts.map +1 -0
  541. package/dist/runtime/telemetry/telemetry-client.mjs +107 -0
  542. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -0
  543. package/dist/runtime/telemetry/telemetry-identity.cjs +12 -0
  544. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -0
  545. package/dist/runtime/telemetry/telemetry-identity.mjs +11 -0
  546. package/dist/runtime/telemetry/telemetry-identity.mjs.map +1 -0
  547. package/dist/runtime/transcription-service/transcription-service.cjs +7 -0
  548. package/dist/runtime/transcription-service/transcription-service.cjs.map +1 -0
  549. package/dist/runtime/transcription-service/transcription-service.d.cts +14 -0
  550. package/dist/runtime/transcription-service/transcription-service.d.cts.map +1 -0
  551. package/dist/runtime/transcription-service/transcription-service.d.mts +14 -0
  552. package/dist/runtime/transcription-service/transcription-service.d.mts.map +1 -0
  553. package/dist/runtime/transcription-service/transcription-service.mjs +6 -0
  554. package/dist/runtime/transcription-service/transcription-service.mjs.map +1 -0
  555. package/package.json +119 -104
  556. package/.eslintrc.js +0 -7
  557. package/CHANGELOG.md +0 -2920
  558. package/__snapshots__/schema/schema.graphql +0 -371
  559. package/dist/index.d.ts +0 -1494
  560. package/dist/index.js +0 -5641
  561. package/dist/index.js.map +0 -1
  562. package/dist/index.mjs.map +0 -1
  563. package/dist/langgraph.d.ts +0 -284
  564. package/dist/langgraph.js +0 -211
  565. package/dist/langgraph.js.map +0 -1
  566. package/dist/langgraph.mjs +0 -206
  567. package/dist/langgraph.mjs.map +0 -1
  568. package/dist/v2/index.d.ts +0 -2
  569. package/dist/v2/index.js +0 -22
  570. package/dist/v2/index.js.map +0 -1
  571. package/dist/v2/index.mjs +0 -5
  572. package/dist/v2/index.mjs.map +0 -1
  573. package/jest.config.js +0 -10
  574. package/scripts/generate-gql-schema.ts +0 -13
  575. package/src/agents/langgraph/event-source.ts +0 -329
  576. package/src/agents/langgraph/events.ts +0 -377
  577. package/src/graphql/inputs/action.input.ts +0 -16
  578. package/src/graphql/inputs/agent-session.input.ts +0 -13
  579. package/src/graphql/inputs/agent-state.input.ts +0 -13
  580. package/src/graphql/inputs/cloud-guardrails.input.ts +0 -16
  581. package/src/graphql/inputs/cloud.input.ts +0 -8
  582. package/src/graphql/inputs/context-property.input.ts +0 -10
  583. package/src/graphql/inputs/copilot-context.input.ts +0 -10
  584. package/src/graphql/inputs/custom-property.input.ts +0 -15
  585. package/src/graphql/inputs/extensions.input.ts +0 -21
  586. package/src/graphql/inputs/forwarded-parameters.input.ts +0 -22
  587. package/src/graphql/inputs/frontend.input.ts +0 -14
  588. package/src/graphql/inputs/generate-copilot-response.input.ts +0 -59
  589. package/src/graphql/inputs/load-agent-state.input.ts +0 -10
  590. package/src/graphql/inputs/message.input.ts +0 -110
  591. package/src/graphql/inputs/meta-event.input.ts +0 -18
  592. package/src/graphql/message-conversion/agui-to-gql.test.ts +0 -1263
  593. package/src/graphql/message-conversion/agui-to-gql.ts +0 -333
  594. package/src/graphql/message-conversion/gql-to-agui.test.ts +0 -1580
  595. package/src/graphql/message-conversion/gql-to-agui.ts +0 -278
  596. package/src/graphql/message-conversion/index.ts +0 -2
  597. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +0 -526
  598. package/src/graphql/resolvers/copilot.resolver.ts +0 -708
  599. package/src/graphql/resolvers/state.resolver.ts +0 -27
  600. package/src/graphql/types/agents-response.type.ts +0 -19
  601. package/src/graphql/types/base/index.ts +0 -10
  602. package/src/graphql/types/converted/index.ts +0 -176
  603. package/src/graphql/types/copilot-response.type.ts +0 -138
  604. package/src/graphql/types/enums.ts +0 -38
  605. package/src/graphql/types/extensions-response.type.ts +0 -23
  606. package/src/graphql/types/guardrails-result.type.ts +0 -20
  607. package/src/graphql/types/load-agent-state-response.type.ts +0 -17
  608. package/src/graphql/types/message-status.type.ts +0 -42
  609. package/src/graphql/types/meta-events.type.ts +0 -71
  610. package/src/graphql/types/response-status.type.ts +0 -66
  611. package/src/index.ts +0 -4
  612. package/src/langgraph.ts +0 -1
  613. package/src/lib/cloud/index.ts +0 -4
  614. package/src/lib/error-messages.ts +0 -200
  615. package/src/lib/index.ts +0 -52
  616. package/src/lib/integrations/index.ts +0 -6
  617. package/src/lib/integrations/nest/index.ts +0 -14
  618. package/src/lib/integrations/nextjs/app-router.ts +0 -38
  619. package/src/lib/integrations/nextjs/pages-router.ts +0 -39
  620. package/src/lib/integrations/node-express/index.ts +0 -14
  621. package/src/lib/integrations/node-http/index.ts +0 -143
  622. package/src/lib/integrations/node-http/request-handler.ts +0 -111
  623. package/src/lib/integrations/shared.ts +0 -161
  624. package/src/lib/logger.ts +0 -28
  625. package/src/lib/observability.ts +0 -160
  626. package/src/lib/runtime/__tests__/copilot-runtime-error.test.ts +0 -169
  627. package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +0 -464
  628. package/src/lib/runtime/agent-integrations/langgraph/agent.ts +0 -209
  629. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +0 -34
  630. package/src/lib/runtime/agent-integrations/langgraph/index.ts +0 -2
  631. package/src/lib/runtime/copilot-runtime.ts +0 -710
  632. package/src/lib/runtime/mcp-tools-utils.ts +0 -254
  633. package/src/lib/runtime/retry-utils.ts +0 -96
  634. package/src/lib/runtime/telemetry-agent-runner.ts +0 -139
  635. package/src/lib/runtime/types.ts +0 -49
  636. package/src/lib/runtime/utils.ts +0 -87
  637. package/src/lib/streaming.ts +0 -202
  638. package/src/lib/telemetry-client.ts +0 -64
  639. package/src/service-adapters/anthropic/anthropic-adapter.ts +0 -452
  640. package/src/service-adapters/anthropic/utils.ts +0 -152
  641. package/src/service-adapters/bedrock/bedrock-adapter.ts +0 -73
  642. package/src/service-adapters/conversion.ts +0 -67
  643. package/src/service-adapters/empty/empty-adapter.ts +0 -38
  644. package/src/service-adapters/events.ts +0 -294
  645. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +0 -84
  646. package/src/service-adapters/google/google-genai-adapter.test.ts +0 -104
  647. package/src/service-adapters/google/google-genai-adapter.ts +0 -88
  648. package/src/service-adapters/groq/groq-adapter.ts +0 -203
  649. package/src/service-adapters/index.ts +0 -18
  650. package/src/service-adapters/langchain/langchain-adapter.ts +0 -111
  651. package/src/service-adapters/langchain/langserve.ts +0 -88
  652. package/src/service-adapters/langchain/types.ts +0 -14
  653. package/src/service-adapters/langchain/utils.ts +0 -313
  654. package/src/service-adapters/openai/openai-adapter.ts +0 -283
  655. package/src/service-adapters/openai/openai-assistant-adapter.ts +0 -344
  656. package/src/service-adapters/openai/utils.ts +0 -199
  657. package/src/service-adapters/service-adapter.ts +0 -41
  658. package/src/service-adapters/shared/error-utils.ts +0 -61
  659. package/src/service-adapters/shared/index.ts +0 -1
  660. package/src/service-adapters/unify/unify-adapter.ts +0 -151
  661. package/src/utils/failed-response-status-reasons.ts +0 -70
  662. package/src/utils/index.ts +0 -1
  663. package/src/v2/index.ts +0 -3
  664. package/tests/global.d.ts +0 -13
  665. package/tests/service-adapters/anthropic/allowlist-approach.test.ts +0 -226
  666. package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +0 -389
  667. package/tests/service-adapters/openai/allowlist-approach.test.ts +0 -238
  668. package/tests/service-adapters/openai/openai-adapter.test.ts +0 -301
  669. package/tests/setup.jest.ts +0 -21
  670. package/tests/tsconfig.json +0 -10
  671. package/tsconfig.json +0 -13
  672. package/tsup.config.ts +0 -20
  673. package/typedoc.json +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent-utils.mjs","names":[],"sources":["../../../../src/runtime/handlers/shared/agent-utils.ts"],"sourcesContent":["import type { AbstractAgent, RunAgentInput } from \"@ag-ui/client\";\nimport { RunAgentInputSchema } from \"@ag-ui/core/schemas\";\nimport type { CopilotKitUIEnvelope } from \"@copilotkit/shared\";\nimport {\n A2UIMiddleware,\n OpenGenerativeUIMiddleware,\n} from \"@copilotkit/shared/event-transforms\";\nimport { MCPAppsMiddleware } from \"@ag-ui/mcp-apps-middleware\";\nimport { MCPMiddleware } from \"@ag-ui/mcp-middleware\";\nimport { GenerativeUIMiddleware } from \"../../generative-ui\";\nimport type { CopilotRuntimeLike } from \"../../core/runtime\";\nimport {\n isA2UIEnabled,\n isIntelligenceRuntime,\n resolveAgents,\n} from \"../../core/runtime\";\nimport {\n INTELLIGENCE_MEMORY_GRANT_HEADER,\n INTELLIGENCE_USER_ID_HEADER,\n} from \"../../intelligence-platform/client\";\nimport {\n mergeForwardableHeaders,\n resolveForwardHeadersPolicy,\n} from \"../header-utils\";\nimport { resolveMcpAppsServers } from \"./mcp-apps-servers\";\nimport { resolveIntelligenceUser } from \"./resolve-intelligence-user\";\nimport { grantAllowsMemory, resolveWebMemory } from \"./memory-policy\";\nimport { errorResponse } from \"./json-response\";\nimport { logger } from \"@copilotkit/shared\";\n\ntype MiddlewareCapableAgent = AbstractAgent & {\n use?: (middleware: unknown) => void;\n headers?: Record<string, string>;\n};\n\nexport interface RunAgentParameters {\n request: Request;\n runtime: CopilotRuntimeLike;\n agentId: string;\n}\n\nexport interface ConnectRequestBody extends RunAgentInput {\n lastSeenEventId?: string | null;\n}\n\n/**\n * Resolve `agentId` against the runtime's agents and return a per-request\n * clone of the matching agent.\n *\n * Dual return contract — both callers (`handle-run.ts`, `handle-connect.ts`)\n * depend on it:\n * - Returns a cloned `AbstractAgent` when the agent exists.\n * - Returns a 404 `Response` (`{ error: \"Agent not found\", ... }`) when the\n * agent is unknown. Callers MUST `instanceof Response`-check the result and\n * return it directly; this doubles as the connect/run path's agent-existence\n * guard, so skipping the check would let unknown agent ids slip through.\n *\n * The clone is what subsequent per-request mutation (middleware attach,\n * `agent.headers` merge) operates on, leaving the shared agent registration\n * untouched.\n */\nexport async function cloneAgentForRequest(\n runtime: CopilotRuntimeLike,\n agentId: string,\n request?: Request,\n): Promise<AbstractAgent | Response> {\n const agents = await resolveAgents(runtime.agents, request);\n\n if (!agents[agentId]) {\n return new Response(\n JSON.stringify({\n error: \"Agent not found\",\n message: `Agent '${agentId}' does not exist`,\n }),\n {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n return (agents[agentId] as AbstractAgent).clone() as AbstractAgent;\n}\n\nexport function configureAgentForRequest(params: {\n runtime: CopilotRuntimeLike;\n request: Request;\n agentId: string;\n agent: AbstractAgent;\n /**\n * True when the React provider was given an A2UI catalog\n * (`<CopilotKit a2ui={{ catalog }}>`), forwarded per-run. A catalog alone is\n * enough to enable A2UI and inject the render tool — the developer no longer\n * has to also set `a2ui.injectA2UITool` on the runtime.\n */\n providerA2UIHasCatalog?: boolean;\n /**\n * The transport of the generative UI envelope that the client sent on this\n * run (`forwardedProps.copilotkit.ui`). Not set when the run has no envelope.\n */\n providerGenerativeUITransport?: CopilotKitUIEnvelope[\"metadata\"][\"extensions\"][\"copilotkit_transport\"];\n /** Retain proxy rejection even when no server is available to this agent. */\n isMcpProxyRequest?: boolean;\n}): void {\n const {\n runtime,\n request,\n agentId,\n providerA2UIHasCatalog,\n isMcpProxyRequest,\n } = params;\n const agent = params.agent as MiddlewareCapableAgent;\n\n // A2UI is on when the runtime explicitly enables it, OR when the provider\n // forwarded a catalog — but an explicit `enabled: false` always wins (we\n // provide a quick default, never override a deeper opt-out).\n const a2uiEnabledByCatalog =\n !!providerA2UIHasCatalog && runtime.a2ui?.enabled !== false;\n\n if (isA2UIEnabled(runtime.a2ui) || a2uiEnabledByCatalog) {\n // `enabled` is a CopilotKit-level switch, not an A2UIMiddleware option —\n // drop it (alongside the agent filter) before forwarding to the middleware.\n const {\n agents: targetAgents,\n enabled: _enabled,\n injectA2UITool,\n ...a2uiOptions\n } = runtime.a2ui ?? {};\n const shouldApply = !targetAgents || targetAgents.includes(agentId);\n if (shouldApply && typeof agent.use === \"function\") {\n agent.use(\n new A2UIMiddleware({\n ...a2uiOptions,\n // Default render-tool injection on when a catalog is present and the\n // developer hasn't set it explicitly. `??` means an explicit value\n // (including `false`) is always respected.\n injectA2UITool:\n injectA2UITool ?? (providerA2UIHasCatalog ? true : undefined),\n }),\n );\n }\n }\n\n if (isIntelligenceRuntime(runtime) && typeof agent.use === \"function\") {\n // Ordinary runs need no middleware without selected servers. Proxy requests\n // still need the upstream guard so they cannot fall through to the model.\n const mcpServers = resolveMcpAppsServers(\n runtime.mcpApps?.servers ?? [],\n agentId,\n );\n if (mcpServers.length > 0 || isMcpProxyRequest) {\n agent.use(\n new MCPAppsMiddleware({ mcpServers, discoveryFailureMode: \"throw\" }),\n );\n }\n } else if (runtime.mcpApps?.servers?.length) {\n const mcpServers = resolveMcpAppsServers(runtime.mcpApps.servers, agentId);\n\n if (mcpServers.length > 0 && typeof agent.use === \"function\") {\n agent.use(new MCPAppsMiddleware({ mcpServers }));\n }\n }\n\n if (runtime.openGenerativeUI) {\n const config = runtime.openGenerativeUI;\n const targetAgents = typeof config === \"object\" ? config.agents : undefined;\n const shouldApply = !targetAgents || targetAgents.includes(agentId);\n if (shouldApply && typeof agent.use === \"function\") {\n agent.use(new OpenGenerativeUIMiddleware());\n }\n }\n\n // A \"markdown\" envelope means the model writes ```a2ui fences, so the run\n // gets no render tool, even when the runtime turns generative UI on.\n const generativeUI = runtime.generativeUI;\n const transport = params.providerGenerativeUITransport;\n const isGenerativeUIRun =\n transport === \"tool\" || (transport !== \"markdown\" && !!generativeUI);\n if (\n isGenerativeUIRun &&\n generativeUI !== false &&\n typeof agent.use === \"function\"\n ) {\n const targetAgents =\n typeof generativeUI === \"object\" ? generativeUI.agents : undefined;\n if (!targetAgents || targetAgents.includes(agentId)) {\n agent.use(new GenerativeUIMiddleware());\n }\n }\n\n // Forward eligible inbound headers onto the outgoing agent call under the\n // runtime's resolved forwarding policy (`authorization` / custom `x-*`, with\n // known infra/proxy/platform headers stripped by the default denylist —\n // #5712), but let headers the server explicitly configured on the agent WIN\n // on collision (case-insensitively): a server-set service-to-service token\n // (e.g. an IAM bearer) must never be silently overridden by a\n // browser/edge/platform-injected inbound header. See `mergeForwardableHeaders`\n // for the casing/duplicate-key rationale and `shouldForwardHeader` for breadth.\n agent.headers = mergeForwardableHeaders(\n agent.headers,\n request,\n // `forwardHeadersPolicy` is optional on the published `CopilotRuntimeLike`\n // interface (non-breaking minor release). Concrete runtimes always set it;\n // a policy-less external implementor falls back to the default resolved\n // policy (default-on denylist) so behavior stays identical and never derefs\n // undefined.\n runtime.forwardHeadersPolicy ?? resolveForwardHeadersPolicy(undefined),\n );\n}\n\n/**\n * Shared by the two places a run meets a middleware-less agent: before Memory\n * is resolved (nothing left to resolve) and after (Memory resolved to nothing).\n */\nconst NO_MIDDLEWARE_WARNING =\n \"CopilotKitIntelligence.enableEnterpriseLearning is enabled, but the agent \" +\n \"does not support middleware (no `.use()` method); Intelligence tools were \" +\n \"not attached for this run.\";\n\n/**\n * Attach CopilotKit Intelligence's MCP tools to the agent run when\n * `CopilotKitIntelligence` was constructed with\n * `enableEnterpriseLearning: true`. Uses `@ag-ui/mcp-middleware`, so the\n * tools are available uniformly across agent frameworks (not just\n * `BuiltInAgent`).\n *\n * The middleware sits on a per-request agent clone, so the per-request\n * auth (Bearer apiKey + resolved user-id) is baked into the transport\n * headers at attach time. If user resolution fails, attachment is\n * skipped silently — the intelligence run handler will reject the\n * request with the same error. Note this means `identifyUser` is\n * resolved twice per learning-enabled run (here and in the run handler);\n * the callback is expected to be idempotent and side-effect-free.\n *\n * Intentionally split out from `configureAgentForRequest`: this is only\n * relevant to actual agent runs, not auxiliary flows like thread-name\n * generation (which has no need for MCP tools and shouldn't pay the\n * `listTools` round-trip).\n */\nexport async function attachIntelligenceEnterpriseLearning(params: {\n runtime: CopilotRuntimeLike;\n request: Request;\n agent: AbstractAgent;\n}): Promise<void | Response> {\n const { runtime, request } = params;\n const agent = params.agent as MiddlewareCapableAgent;\n\n if (!isIntelligenceRuntime(runtime)) return;\n\n const learningEnabled =\n runtime.intelligence?.ɵisEnterpriseLearningEnabled?.() === true;\n if (runtime.memory === undefined && !learningEnabled) return;\n\n // Nothing here is resolvable for an agent whose framework can't take\n // middleware and whose runtime configures no Memory — bail before paying for\n // `identifyUser`, so an enterprise-learning-only run keeps warning rather\n // than acquiring a new way to fail.\n if (runtime.memory === undefined && typeof agent.use !== \"function\") {\n logger.warn(NO_MIDDLEWARE_WARNING);\n return;\n }\n\n const userResult = await resolveIntelligenceUser({ runtime, request });\n if (userResult instanceof Response) return userResult;\n const access = await resolveWebMemory(runtime, request, userResult, \"agent\");\n if (access instanceof Response) return access;\n\n const memoryGranted =\n runtime.memory !== undefined && grantAllowsMemory(access.grant);\n\n // A policy that grants no scope means this run gets no Memory — it does NOT\n // mean the run is refused. Attach nothing and let the conversation proceed,\n // exactly as a Channel does when its grant asks for nothing\n // (`hasMemoryAccess` in @copilotkit/channels-core). Returning a 403 here\n // instead fails the whole run, so switching Memory off for one tenant would\n // leave that tenant with no assistant, and the only signal is a run error the\n // chat surface has no reason to render.\n //\n // Enterprise learning rides the SAME MCP server, so \"no Memory\" must not cost\n // an operator the learning tools too. When it is on, attach anyway and let\n // Intelligence filter: it registers one Memory tool per granted scope and\n // none at all for an all-none grant, leaving the learning tools untouched.\n if (!memoryGranted && !learningEnabled) return;\n\n // Whatever is left to attach needs middleware. Failing the run is right only\n // when Memory was actually granted and cannot be delivered; a run that merely\n // wanted learning tools warns and proceeds, as it always has.\n if (typeof agent.use !== \"function\") {\n if (memoryGranted) {\n return errorResponse(\n \"Memory is configured, but this agent does not support middleware\",\n 500,\n );\n }\n logger.warn(NO_MIDDLEWARE_WARNING);\n return;\n }\n\n agent.use(\n new MCPMiddleware([\n {\n type: \"http\",\n url: `${runtime.intelligence.ɵgetApiUrl()}/mcp`,\n serverId: \"intelligence\",\n headers: {\n Authorization: `Bearer ${runtime.intelligence.ɵgetApiKey()}`,\n [INTELLIGENCE_USER_ID_HEADER]: userResult.id,\n ...(runtime.memory\n ? {\n [INTELLIGENCE_MEMORY_GRANT_HEADER]: JSON.stringify(\n access.grant,\n ),\n }\n : {}),\n },\n },\n ]),\n );\n}\n\n// Intentional local exception: HTTP request parsing runs before AG-UI's event\n// compatibility boundary. Mirror its historically accepted optional-null rules\n// and its legacy binary-part upgrade here, without depending on a new public\n// AG-UI helper (AG-UI does not export one). Keep these aligned\n// with client/src/middleware/compatibility-boundary.ts and AG-UI's migration guide.\n// Required nulls and nulls within application data must remain untouched.\nfunction warnCompatibility(what: string, replacement: string) {\n if (\n typeof process !== \"undefined\" &&\n typeof process.env !== \"undefined\" &&\n process.env.SUPPRESS_TRANSFORMATION_WARNINGS\n )\n return;\n console.warn(\n `[ag-ui][compat] Converting deprecated ${what} to ${replacement}. The old shape leaves the protocol after its shim window — see the repo-root DEPRECATIONS.md. Set SUPPRESS_TRANSFORMATION_WARNINGS=true to silence.`,\n );\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\nfunction omitLegacyNull(\n value: unknown,\n field: string,\n context: string,\n): unknown {\n if (!isRecord(value) || value[field] !== null) return value;\n warnCompatibility(`${context}.${field}: null`, \"an absent field\");\n const { [field]: _null, ...rest } = value;\n return rest;\n}\n\nfunction mapProtocolArray(\n value: unknown,\n field: string,\n normalize: (entry: unknown) => unknown,\n): unknown {\n if (!isRecord(value) || !Array.isArray(value[field])) return value;\n const original = value[field];\n const entries = original.map(normalize);\n return entries.some((entry, index) => entry !== original[index])\n ? { ...value, [field]: entries }\n : value;\n}\n\nfunction mediaTypeFor(\n mimeType: string,\n): \"image\" | \"audio\" | \"video\" | \"document\" {\n if (mimeType.startsWith(\"image/\")) return \"image\";\n if (mimeType.startsWith(\"audio/\")) return \"audio\";\n if (mimeType.startsWith(\"video/\")) return \"video\";\n return \"document\";\n}\n\nfunction sameSource(part: unknown, converted: Record<string, unknown>) {\n if (!isRecord(part) || part.type !== converted.type) return false;\n const a = part.source;\n const b = converted.source as Record<string, unknown>;\n return (\n isRecord(a) &&\n a.type === b.type &&\n a.value === b.value &&\n a.mimeType === b.mimeType\n );\n}\n\n/**\n * The 0.x `{ type: \"binary\" }` part, which 1.0 retired and main accepted.\n * Mirrors AG-UI's outgoing upgrade (client/src/middleware/legacy-content.ts):\n * data or url becomes the media part its mime type names, and a binary part\n * that only mirrors a modern part already in the message is dropped. A part\n * with only an `id` has no 1.0 form; it is dropped with a warning instead of\n * failing the whole request, which is what BuiltInAgent already did with it.\n */\nfunction upgradeLegacyBinaryParts(content: unknown[]): unknown[] {\n return content.flatMap((part) => {\n if (\n !isRecord(part) ||\n part.type !== \"binary\" ||\n typeof part.mimeType !== \"string\"\n )\n return [part];\n const kind =\n typeof part.data === \"string\"\n ? \"data\"\n : typeof part.url === \"string\"\n ? \"url\"\n : null;\n if (kind === null) {\n console.warn(\n \"[CopilotKit] Dropping a legacy binary content part that has no data or url; AG-UI 1.0 has no equivalent for it.\",\n );\n return [];\n }\n warnCompatibility(\"binary input content\", \"the modern media content part\");\n const converted: Record<string, unknown> = {\n type: mediaTypeFor(part.mimeType),\n source: {\n type: kind,\n value: kind === \"data\" ? part.data : part.url,\n mimeType: part.mimeType,\n },\n ...(typeof part.filename === \"string\"\n ? { metadata: { filename: part.filename } }\n : {}),\n };\n return content.some((other) => sameSource(other, converted))\n ? []\n : [converted];\n });\n}\n\nfunction normalizeLegacyMessageContent(message: unknown): unknown {\n const upgraded =\n isRecord(message) &&\n Array.isArray(message.content) &&\n message.content.some((part) => isRecord(part) && part.type === \"binary\")\n ? {\n ...message,\n content: upgradeLegacyBinaryParts(message.content),\n }\n : message;\n return mapProtocolArray(upgraded, \"content\", (part) => {\n if (!isRecord(part)) return part;\n switch (part.type) {\n case \"image\":\n case \"audio\":\n case \"video\":\n case \"document\":\n return omitLegacyNull(part, \"metadata\", `${part.type} input content`);\n default:\n return part;\n }\n });\n}\n\nfunction normalizeLegacyRunAgentInput(input: unknown): unknown {\n let normalized = omitLegacyNull(input, \"forwardedProps\", \"RunAgentInput\");\n normalized = mapProtocolArray(normalized, \"tools\", (tool) =>\n omitLegacyNull(tool, \"parameters\", \"Tool\"),\n );\n normalized = mapProtocolArray(normalized, \"resume\", (entry) =>\n omitLegacyNull(entry, \"payload\", \"ResumeEntry\"),\n );\n return mapProtocolArray(\n normalized,\n \"messages\",\n normalizeLegacyMessageContent,\n );\n}\n\nfunction parseRunAgentInput(value: unknown): RunAgentInput {\n // With strictNullChecks disabled, Zod infers some required nested fields\n // (such as image.source) as optional. The schema still validates them.\n return RunAgentInputSchema.parse(\n normalizeLegacyRunAgentInput(value),\n ) as RunAgentInput;\n}\n\nexport async function parseRunRequest(\n request: Request,\n): Promise<RunAgentInput | Response> {\n try {\n const requestBody = await request.json();\n return parseRunAgentInput(requestBody);\n } catch (error) {\n logger.error(\"Invalid run request body:\", error);\n return new Response(\n JSON.stringify({\n error: \"Invalid request body\",\n details: error instanceof Error ? error.message : String(error),\n }),\n {\n status: 400,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n}\n\nexport async function parseConnectRequest(request: Request): Promise<\n | Response\n | {\n input: RunAgentInput;\n lastSeenEventId: string | null;\n }\n> {\n try {\n const requestBody = await request.json();\n const input = parseRunAgentInput(requestBody);\n let lastSeenEventId: string | null = null;\n\n if (\n \"lastSeenEventId\" in (requestBody as Record<string, unknown>) &&\n (typeof (requestBody as Record<string, unknown>).lastSeenEventId ===\n \"string\" ||\n (requestBody as Record<string, unknown>).lastSeenEventId === null)\n ) {\n lastSeenEventId =\n (requestBody as ConnectRequestBody).lastSeenEventId ?? null;\n }\n\n return { input, lastSeenEventId };\n } catch (error) {\n logger.error(\"Invalid connect request body:\", error);\n return new Response(\n JSON.stringify({\n error: \"Invalid request body\",\n details: error instanceof Error ? error.message : String(error),\n }),\n {\n status: 400,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n}\n"],"mappings":"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"}
@@ -0,0 +1,30 @@
1
+ const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
2
+ let _copilotkit_shared = require("@copilotkit/shared");
3
+
4
+ //#region src/runtime/handlers/shared/cloud-telemetry.ts
5
+ /**
6
+ * Whether the caller forwarded CopilotCloud guardrails configuration.
7
+ *
8
+ * Guardrails reach a runtime as `forwardedProps.cloud.guardrails`. An earlier
9
+ * version read the body only when the CopilotCloud key header was present,
10
+ * because in principle only a CopilotCloud client sends guardrails and that
11
+ * client always sends its key. Production does not hold to that: of 112
12
+ * guardrails-enabled requests over 90 days, 2 carried no key, and they
13
+ * undercounted as `false`. The signal is rare enough — 13 people across 9
14
+ * Cloud keys in a year — that losing 2% of it to save a body clone is a bad
15
+ * trade, so the body is now always read.
16
+ *
17
+ * `readBody` clones rather than consuming, so the handler can still parse the
18
+ * request afterwards.
19
+ */
20
+ async function readGuardrailsEnabled(request) {
21
+ try {
22
+ return ((await (0, _copilotkit_shared.readBody)(request))?.forwardedProps)?.cloud?.guardrails !== void 0;
23
+ } catch {
24
+ return false;
25
+ }
26
+ }
27
+
28
+ //#endregion
29
+ exports.readGuardrailsEnabled = readGuardrailsEnabled;
30
+ //# sourceMappingURL=cloud-telemetry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-telemetry.cjs","names":[],"sources":["../../../../src/runtime/handlers/shared/cloud-telemetry.ts"],"sourcesContent":["// The CopilotCloud guardrails flag on `oss.runtime.copilot_request_created`.\n//\n// It lives here because the v1 entrypoint used to compute it in its own\n// middleware and emit a second copy of the event. That copy is gone; this is\n// what it carried and the v2 handlers did not.\n//\n// The v1 copy also carried `cloud.base_url`, which is deliberately not\n// ported. The cross-language conformance suite pins this event to exactly\n// requestType, cloud.guardrails.enabled and cloud.api_key_provided\n// (`tools/runtime-conformance/telemetry-cases.mjs`), and the four native\n// runtimes send nothing else. A near-constant read off an env var is not\n// worth diverging the canonical event shape for.\n\nimport { readBody } from \"@copilotkit/shared\";\nimport type { RunAgentInput } from \"@ag-ui/client\";\n\n/**\n * Whether the caller forwarded CopilotCloud guardrails configuration.\n *\n * Guardrails reach a runtime as `forwardedProps.cloud.guardrails`. An earlier\n * version read the body only when the CopilotCloud key header was present,\n * because in principle only a CopilotCloud client sends guardrails and that\n * client always sends its key. Production does not hold to that: of 112\n * guardrails-enabled requests over 90 days, 2 carried no key, and they\n * undercounted as `false`. The signal is rare enough — 13 people across 9\n * Cloud keys in a year — that losing 2% of it to save a body clone is a bad\n * trade, so the body is now always read.\n *\n * `readBody` clones rather than consuming, so the handler can still parse the\n * request afterwards.\n */\nexport async function readGuardrailsEnabled(\n request: Request,\n): Promise<boolean> {\n try {\n const body = (await readBody(request)) as RunAgentInput | undefined;\n const forwardedProps = body?.forwardedProps as\n | { cloud?: { guardrails?: unknown } }\n | undefined;\n return forwardedProps?.cloud?.guardrails !== undefined;\n } catch {\n // Telemetry must never decide whether a request is served.\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA+BA,eAAsB,sBACpB,SACkB;AAClB,KAAI;AAKF,WAJc,uCAAe,QAAQ,GACR,iBAGN,OAAO,eAAe;SACvC;AAEN,SAAO"}
@@ -0,0 +1,29 @@
1
+ import { readBody } from "@copilotkit/shared";
2
+
3
+ //#region src/runtime/handlers/shared/cloud-telemetry.ts
4
+ /**
5
+ * Whether the caller forwarded CopilotCloud guardrails configuration.
6
+ *
7
+ * Guardrails reach a runtime as `forwardedProps.cloud.guardrails`. An earlier
8
+ * version read the body only when the CopilotCloud key header was present,
9
+ * because in principle only a CopilotCloud client sends guardrails and that
10
+ * client always sends its key. Production does not hold to that: of 112
11
+ * guardrails-enabled requests over 90 days, 2 carried no key, and they
12
+ * undercounted as `false`. The signal is rare enough — 13 people across 9
13
+ * Cloud keys in a year — that losing 2% of it to save a body clone is a bad
14
+ * trade, so the body is now always read.
15
+ *
16
+ * `readBody` clones rather than consuming, so the handler can still parse the
17
+ * request afterwards.
18
+ */
19
+ async function readGuardrailsEnabled(request) {
20
+ try {
21
+ return ((await readBody(request))?.forwardedProps)?.cloud?.guardrails !== void 0;
22
+ } catch {
23
+ return false;
24
+ }
25
+ }
26
+
27
+ //#endregion
28
+ export { readGuardrailsEnabled };
29
+ //# sourceMappingURL=cloud-telemetry.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"cloud-telemetry.mjs","names":[],"sources":["../../../../src/runtime/handlers/shared/cloud-telemetry.ts"],"sourcesContent":["// The CopilotCloud guardrails flag on `oss.runtime.copilot_request_created`.\n//\n// It lives here because the v1 entrypoint used to compute it in its own\n// middleware and emit a second copy of the event. That copy is gone; this is\n// what it carried and the v2 handlers did not.\n//\n// The v1 copy also carried `cloud.base_url`, which is deliberately not\n// ported. The cross-language conformance suite pins this event to exactly\n// requestType, cloud.guardrails.enabled and cloud.api_key_provided\n// (`tools/runtime-conformance/telemetry-cases.mjs`), and the four native\n// runtimes send nothing else. A near-constant read off an env var is not\n// worth diverging the canonical event shape for.\n\nimport { readBody } from \"@copilotkit/shared\";\nimport type { RunAgentInput } from \"@ag-ui/client\";\n\n/**\n * Whether the caller forwarded CopilotCloud guardrails configuration.\n *\n * Guardrails reach a runtime as `forwardedProps.cloud.guardrails`. An earlier\n * version read the body only when the CopilotCloud key header was present,\n * because in principle only a CopilotCloud client sends guardrails and that\n * client always sends its key. Production does not hold to that: of 112\n * guardrails-enabled requests over 90 days, 2 carried no key, and they\n * undercounted as `false`. The signal is rare enough — 13 people across 9\n * Cloud keys in a year — that losing 2% of it to save a body clone is a bad\n * trade, so the body is now always read.\n *\n * `readBody` clones rather than consuming, so the handler can still parse the\n * request afterwards.\n */\nexport async function readGuardrailsEnabled(\n request: Request,\n): Promise<boolean> {\n try {\n const body = (await readBody(request)) as RunAgentInput | undefined;\n const forwardedProps = body?.forwardedProps as\n | { cloud?: { guardrails?: unknown } }\n | undefined;\n return forwardedProps?.cloud?.guardrails !== undefined;\n } catch {\n // Telemetry must never decide whether a request is served.\n return false;\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AA+BA,eAAsB,sBACpB,SACkB;AAClB,KAAI;AAKF,WAJc,MAAM,SAAS,QAAQ,GACR,iBAGN,OAAO,eAAe;SACvC;AAEN,SAAO"}
@@ -0,0 +1,25 @@
1
+
2
+ //#region src/runtime/handlers/shared/describe-endpoint.ts
3
+ /**
4
+ * A form of the endpoint that is safe to write to application logs.
5
+ *
6
+ * Both halves of an endpoint URL can carry a secret: userinfo, and the query
7
+ * string — the #2407 reporter's own workaround appended `?uid=<hash of the
8
+ * API key>`. Only the origin and path survive.
9
+ *
10
+ * Used for anything that leaves this process with an endpoint in it: log
11
+ * lines, and the tool descriptions that go to the model provider.
12
+ */
13
+ function describeEndpoint(endpoint) {
14
+ if (!endpoint) return "an MCP endpoint";
15
+ try {
16
+ const url = new URL(endpoint);
17
+ return `${url.protocol}//${url.host}${url.pathname}`;
18
+ } catch {
19
+ return "an MCP endpoint";
20
+ }
21
+ }
22
+
23
+ //#endregion
24
+ exports.describeEndpoint = describeEndpoint;
25
+ //# sourceMappingURL=describe-endpoint.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-endpoint.cjs","names":[],"sources":["../../../../src/runtime/handlers/shared/describe-endpoint.ts"],"sourcesContent":["/**\n * A form of the endpoint that is safe to write to application logs.\n *\n * Both halves of an endpoint URL can carry a secret: userinfo, and the query\n * string — the #2407 reporter's own workaround appended `?uid=<hash of the\n * API key>`. Only the origin and path survive.\n *\n * Used for anything that leaves this process with an endpoint in it: log\n * lines, and the tool descriptions that go to the model provider.\n */\nexport function describeEndpoint(endpoint: string | undefined): string {\n if (!endpoint) return \"an MCP endpoint\";\n try {\n const url = new URL(endpoint);\n // Not `url.origin`: for any scheme other than http(s) that is the opaque\n // origin, the literal string \"null\", and `pathname` is empty — so a\n // `stdio://` endpoint would render as \"null\" in a log and in a prompt.\n // Rebuilding from protocol and host keeps every scheme legible while\n // still dropping userinfo, query, and fragment.\n return `${url.protocol}//${url.host}${url.pathname}`;\n } catch {\n return \"an MCP endpoint\";\n }\n}\n"],"mappings":";;;;;;;;;;;;AAUA,SAAgB,iBAAiB,UAAsC;AACrE,KAAI,CAAC,SAAU,QAAO;AACtB,KAAI;EACF,MAAM,MAAM,IAAI,IAAI,SAAS;AAM7B,SAAO,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,IAAI;SACpC;AACN,SAAO"}
@@ -0,0 +1,24 @@
1
+ //#region src/runtime/handlers/shared/describe-endpoint.ts
2
+ /**
3
+ * A form of the endpoint that is safe to write to application logs.
4
+ *
5
+ * Both halves of an endpoint URL can carry a secret: userinfo, and the query
6
+ * string — the #2407 reporter's own workaround appended `?uid=<hash of the
7
+ * API key>`. Only the origin and path survive.
8
+ *
9
+ * Used for anything that leaves this process with an endpoint in it: log
10
+ * lines, and the tool descriptions that go to the model provider.
11
+ */
12
+ function describeEndpoint(endpoint) {
13
+ if (!endpoint) return "an MCP endpoint";
14
+ try {
15
+ const url = new URL(endpoint);
16
+ return `${url.protocol}//${url.host}${url.pathname}`;
17
+ } catch {
18
+ return "an MCP endpoint";
19
+ }
20
+ }
21
+
22
+ //#endregion
23
+ export { describeEndpoint };
24
+ //# sourceMappingURL=describe-endpoint.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"describe-endpoint.mjs","names":[],"sources":["../../../../src/runtime/handlers/shared/describe-endpoint.ts"],"sourcesContent":["/**\n * A form of the endpoint that is safe to write to application logs.\n *\n * Both halves of an endpoint URL can carry a secret: userinfo, and the query\n * string — the #2407 reporter's own workaround appended `?uid=<hash of the\n * API key>`. Only the origin and path survive.\n *\n * Used for anything that leaves this process with an endpoint in it: log\n * lines, and the tool descriptions that go to the model provider.\n */\nexport function describeEndpoint(endpoint: string | undefined): string {\n if (!endpoint) return \"an MCP endpoint\";\n try {\n const url = new URL(endpoint);\n // Not `url.origin`: for any scheme other than http(s) that is the opaque\n // origin, the literal string \"null\", and `pathname` is empty — so a\n // `stdio://` endpoint would render as \"null\" in a log and in a prompt.\n // Rebuilding from protocol and host keeps every scheme legible while\n // still dropping userinfo, query, and fragment.\n return `${url.protocol}//${url.host}${url.pathname}`;\n } catch {\n return \"an MCP endpoint\";\n }\n}\n"],"mappings":";;;;;;;;;;;AAUA,SAAgB,iBAAiB,UAAsC;AACrE,KAAI,CAAC,SAAU,QAAO;AACtB,KAAI;EACF,MAAM,MAAM,IAAI,IAAI,SAAS;AAM7B,SAAO,GAAG,IAAI,SAAS,IAAI,IAAI,OAAO,IAAI;SACpC;AACN,SAAO"}
@@ -0,0 +1,24 @@
1
+ const require_client = require('../../intelligence-platform/client.cjs');
2
+
3
+ //#region src/runtime/handlers/shared/intelligence-utils.ts
4
+ /**
5
+ * Returns the HTTP status carried by platform request errors.
6
+ */
7
+ function getPlatformErrorStatus(error) {
8
+ if (error instanceof require_client.PlatformRequestError) return error.status;
9
+ if (error !== null && typeof error === "object" && "status" in error && typeof error.status === "number") return error.status;
10
+ }
11
+ const MAX_ID_LENGTH = 128;
12
+ const SAFE_ID_PATTERN = /^[\w.@:=-]+$/;
13
+ /**
14
+ * Validates that a string identifier (userId, agentId) is safe to pass through.
15
+ * Returns `true` if valid, `false` otherwise.
16
+ */
17
+ function isValidIdentifier(value) {
18
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_ID_LENGTH && SAFE_ID_PATTERN.test(value);
19
+ }
20
+
21
+ //#endregion
22
+ exports.getPlatformErrorStatus = getPlatformErrorStatus;
23
+ exports.isValidIdentifier = isValidIdentifier;
24
+ //# sourceMappingURL=intelligence-utils.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligence-utils.cjs","names":["PlatformRequestError"],"sources":["../../../../src/runtime/handlers/shared/intelligence-utils.ts"],"sourcesContent":["import { PlatformRequestError } from \"../../intelligence-platform/client\";\n\n/**\n * Returns the HTTP status carried by platform request errors.\n */\nexport function getPlatformErrorStatus(error: unknown): number | undefined {\n if (error instanceof PlatformRequestError) {\n return error.status;\n }\n\n if (\n error !== null &&\n typeof error === \"object\" &&\n \"status\" in error &&\n typeof error.status === \"number\"\n ) {\n return error.status;\n }\n\n return undefined;\n}\n\nexport function isPlatformNotFoundError(error: unknown): boolean {\n return getPlatformErrorStatus(error) === 404;\n}\n\nconst MAX_ID_LENGTH = 128;\nconst SAFE_ID_PATTERN = /^[\\w.@:=-]+$/;\n\n/**\n * Validates that a string identifier (userId, agentId) is safe to pass through.\n * Returns `true` if valid, `false` otherwise.\n */\nexport function isValidIdentifier(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.length > 0 &&\n value.length <= MAX_ID_LENGTH &&\n SAFE_ID_PATTERN.test(value)\n );\n}\n"],"mappings":";;;;;;AAKA,SAAgB,uBAAuB,OAAoC;AACzE,KAAI,iBAAiBA,oCACnB,QAAO,MAAM;AAGf,KACE,UAAU,QACV,OAAO,UAAU,YACjB,YAAY,SACZ,OAAO,MAAM,WAAW,SAExB,QAAO,MAAM;;AAUjB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;;;;;AAMxB,SAAgB,kBAAkB,OAAiC;AACjE,QACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,UAAU,iBAChB,gBAAgB,KAAK,MAAM"}
@@ -0,0 +1,23 @@
1
+ import { PlatformRequestError } from "../../intelligence-platform/client.mjs";
2
+
3
+ //#region src/runtime/handlers/shared/intelligence-utils.ts
4
+ /**
5
+ * Returns the HTTP status carried by platform request errors.
6
+ */
7
+ function getPlatformErrorStatus(error) {
8
+ if (error instanceof PlatformRequestError) return error.status;
9
+ if (error !== null && typeof error === "object" && "status" in error && typeof error.status === "number") return error.status;
10
+ }
11
+ const MAX_ID_LENGTH = 128;
12
+ const SAFE_ID_PATTERN = /^[\w.@:=-]+$/;
13
+ /**
14
+ * Validates that a string identifier (userId, agentId) is safe to pass through.
15
+ * Returns `true` if valid, `false` otherwise.
16
+ */
17
+ function isValidIdentifier(value) {
18
+ return typeof value === "string" && value.length > 0 && value.length <= MAX_ID_LENGTH && SAFE_ID_PATTERN.test(value);
19
+ }
20
+
21
+ //#endregion
22
+ export { getPlatformErrorStatus, isValidIdentifier };
23
+ //# sourceMappingURL=intelligence-utils.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intelligence-utils.mjs","names":[],"sources":["../../../../src/runtime/handlers/shared/intelligence-utils.ts"],"sourcesContent":["import { PlatformRequestError } from \"../../intelligence-platform/client\";\n\n/**\n * Returns the HTTP status carried by platform request errors.\n */\nexport function getPlatformErrorStatus(error: unknown): number | undefined {\n if (error instanceof PlatformRequestError) {\n return error.status;\n }\n\n if (\n error !== null &&\n typeof error === \"object\" &&\n \"status\" in error &&\n typeof error.status === \"number\"\n ) {\n return error.status;\n }\n\n return undefined;\n}\n\nexport function isPlatformNotFoundError(error: unknown): boolean {\n return getPlatformErrorStatus(error) === 404;\n}\n\nconst MAX_ID_LENGTH = 128;\nconst SAFE_ID_PATTERN = /^[\\w.@:=-]+$/;\n\n/**\n * Validates that a string identifier (userId, agentId) is safe to pass through.\n * Returns `true` if valid, `false` otherwise.\n */\nexport function isValidIdentifier(value: unknown): value is string {\n return (\n typeof value === \"string\" &&\n value.length > 0 &&\n value.length <= MAX_ID_LENGTH &&\n SAFE_ID_PATTERN.test(value)\n );\n}\n"],"mappings":";;;;;;AAKA,SAAgB,uBAAuB,OAAoC;AACzE,KAAI,iBAAiB,qBACnB,QAAO,MAAM;AAGf,KACE,UAAU,QACV,OAAO,UAAU,YACjB,YAAY,SACZ,OAAO,MAAM,WAAW,SAExB,QAAO,MAAM;;AAUjB,MAAM,gBAAgB;AACtB,MAAM,kBAAkB;;;;;AAMxB,SAAgB,kBAAkB,OAAiC;AACjE,QACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,UAAU,iBAChB,gBAAgB,KAAK,MAAM"}
@@ -0,0 +1,14 @@
1
+
2
+ //#region src/runtime/handlers/shared/json-response.ts
3
+ const errorResponse = (message, status) => new Response(JSON.stringify({ error: message }), {
4
+ status,
5
+ headers: { "Content-Type": "application/json" }
6
+ });
7
+ function isHandlerResponse(value) {
8
+ return value instanceof Response;
9
+ }
10
+
11
+ //#endregion
12
+ exports.errorResponse = errorResponse;
13
+ exports.isHandlerResponse = isHandlerResponse;
14
+ //# sourceMappingURL=json-response.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-response.cjs","names":[],"sources":["../../../../src/runtime/handlers/shared/json-response.ts"],"sourcesContent":["export const errorResponse = (message: string, status: number) =>\n new Response(JSON.stringify({ error: message }), {\n status,\n headers: { \"Content-Type\": \"application/json\" },\n });\n\nexport function isHandlerResponse(value: unknown): value is Response {\n return value instanceof Response;\n}\n"],"mappings":";;AAAA,MAAa,iBAAiB,SAAiB,WAC7C,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,SAAS,CAAC,EAAE;CAC/C;CACA,SAAS,EAAE,gBAAgB,oBAAoB;CAChD,CAAC;AAEJ,SAAgB,kBAAkB,OAAmC;AACnE,QAAO,iBAAiB"}
@@ -0,0 +1,12 @@
1
+ //#region src/runtime/handlers/shared/json-response.ts
2
+ const errorResponse = (message, status) => new Response(JSON.stringify({ error: message }), {
3
+ status,
4
+ headers: { "Content-Type": "application/json" }
5
+ });
6
+ function isHandlerResponse(value) {
7
+ return value instanceof Response;
8
+ }
9
+
10
+ //#endregion
11
+ export { errorResponse, isHandlerResponse };
12
+ //# sourceMappingURL=json-response.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-response.mjs","names":[],"sources":["../../../../src/runtime/handlers/shared/json-response.ts"],"sourcesContent":["export const errorResponse = (message: string, status: number) =>\n new Response(JSON.stringify({ error: message }), {\n status,\n headers: { \"Content-Type\": \"application/json\" },\n });\n\nexport function isHandlerResponse(value: unknown): value is Response {\n return value instanceof Response;\n}\n"],"mappings":";AAAA,MAAa,iBAAiB,SAAiB,WAC7C,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,SAAS,CAAC,EAAE;CAC/C;CACA,SAAS,EAAE,gBAAgB,oBAAoB;CAChD,CAAC;AAEJ,SAAgB,kBAAkB,OAAmC;AACnE,QAAO,iBAAiB"}
@@ -0,0 +1,22 @@
1
+ const require_describe_endpoint = require('./describe-endpoint.cjs');
2
+
3
+ //#region src/runtime/handlers/shared/mcp-apps-servers.ts
4
+ const UNSUPPORTED_POLICY_KEYS = ["includeTools", "excludeTools"];
5
+ const MCP_APPS_POLICY_ISSUE = "https://github.com/CopilotKit/CopilotKit/issues/5930";
6
+ /**
7
+ * Select the servers for an agent and validate the policy boundary owned by
8
+ * the installed MCP Apps middleware.
9
+ */
10
+ function resolveMcpAppsServers(servers, agentId) {
11
+ const violations = [];
12
+ for (const [index, server] of servers.entries()) {
13
+ const config = server;
14
+ for (const key of UNSUPPORTED_POLICY_KEYS) if (Object.prototype.hasOwnProperty.call(config, key) && config[key] !== void 0) violations.push(`${key} at server[${index}] (${server.serverId ?? require_describe_endpoint.describeEndpoint(server.url)})`);
15
+ }
16
+ if (violations.length > 0) throw new Error(`Unsupported MCP Apps tool policy: ${violations.join(", ")}. @ag-ui/mcp-apps-middleware owns per-server tool policy, and the release the runtime depends on does not support these keys; see ${MCP_APPS_POLICY_ISSUE}.`);
17
+ return servers.filter((server) => !server.agentId || server.agentId === agentId).map(({ agentId: _agentId, ...server }) => server);
18
+ }
19
+
20
+ //#endregion
21
+ exports.resolveMcpAppsServers = resolveMcpAppsServers;
22
+ //# sourceMappingURL=mcp-apps-servers.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-apps-servers.cjs","names":["describeEndpoint"],"sources":["../../../../src/runtime/handlers/shared/mcp-apps-servers.ts"],"sourcesContent":["import type { MCPClientConfig } from \"@ag-ui/mcp-apps-middleware\";\nimport type { McpAppsServerConfig } from \"../../core/runtime\";\nimport { describeEndpoint } from \"./describe-endpoint\";\n\nconst UNSUPPORTED_POLICY_KEYS = [\"includeTools\", \"excludeTools\"] as const;\nconst MCP_APPS_POLICY_ISSUE =\n \"https://github.com/CopilotKit/CopilotKit/issues/5930\";\n\n/**\n * Select the servers for an agent and validate the policy boundary owned by\n * the installed MCP Apps middleware.\n */\nexport function resolveMcpAppsServers(\n servers: readonly McpAppsServerConfig[],\n agentId: string,\n): MCPClientConfig[] {\n const violations: string[] = [];\n\n for (const [index, server] of servers.entries()) {\n const config = server as unknown as Record<string, unknown>;\n for (const key of UNSUPPORTED_POLICY_KEYS) {\n if (\n Object.prototype.hasOwnProperty.call(config, key) &&\n config[key] !== undefined\n ) {\n violations.push(\n `${key} at server[${index}] (${server.serverId ?? describeEndpoint(server.url)})`,\n );\n }\n }\n }\n\n if (violations.length > 0) {\n throw new Error(\n `Unsupported MCP Apps tool policy: ${violations.join(\", \")}. ` +\n `@ag-ui/mcp-apps-middleware owns per-server tool policy, and the ` +\n `release the runtime depends on does not support these keys; see ` +\n `${MCP_APPS_POLICY_ISSUE}.`,\n );\n }\n\n return servers\n .filter((server) => !server.agentId || server.agentId === agentId)\n .map(({ agentId: _agentId, ...server }) => server as MCPClientConfig);\n}\n"],"mappings":";;;AAIA,MAAM,0BAA0B,CAAC,gBAAgB,eAAe;AAChE,MAAM,wBACJ;;;;;AAMF,SAAgB,sBACd,SACA,SACmB;CACnB,MAAM,aAAuB,EAAE;AAE/B,MAAK,MAAM,CAAC,OAAO,WAAW,QAAQ,SAAS,EAAE;EAC/C,MAAM,SAAS;AACf,OAAK,MAAM,OAAO,wBAChB,KACE,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI,IACjD,OAAO,SAAS,OAEhB,YAAW,KACT,GAAG,IAAI,aAAa,MAAM,KAAK,OAAO,YAAYA,2CAAiB,OAAO,IAAI,CAAC,GAChF;;AAKP,KAAI,WAAW,SAAS,EACtB,OAAM,IAAI,MACR,qCAAqC,WAAW,KAAK,KAAK,CAAC,oIAGtD,sBAAsB,GAC5B;AAGH,QAAO,QACJ,QAAQ,WAAW,CAAC,OAAO,WAAW,OAAO,YAAY,QAAQ,CACjE,KAAK,EAAE,SAAS,UAAU,GAAG,aAAa,OAA0B"}
@@ -0,0 +1,22 @@
1
+ import { describeEndpoint } from "./describe-endpoint.mjs";
2
+
3
+ //#region src/runtime/handlers/shared/mcp-apps-servers.ts
4
+ const UNSUPPORTED_POLICY_KEYS = ["includeTools", "excludeTools"];
5
+ const MCP_APPS_POLICY_ISSUE = "https://github.com/CopilotKit/CopilotKit/issues/5930";
6
+ /**
7
+ * Select the servers for an agent and validate the policy boundary owned by
8
+ * the installed MCP Apps middleware.
9
+ */
10
+ function resolveMcpAppsServers(servers, agentId) {
11
+ const violations = [];
12
+ for (const [index, server] of servers.entries()) {
13
+ const config = server;
14
+ for (const key of UNSUPPORTED_POLICY_KEYS) if (Object.prototype.hasOwnProperty.call(config, key) && config[key] !== void 0) violations.push(`${key} at server[${index}] (${server.serverId ?? describeEndpoint(server.url)})`);
15
+ }
16
+ if (violations.length > 0) throw new Error(`Unsupported MCP Apps tool policy: ${violations.join(", ")}. @ag-ui/mcp-apps-middleware owns per-server tool policy, and the release the runtime depends on does not support these keys; see ${MCP_APPS_POLICY_ISSUE}.`);
17
+ return servers.filter((server) => !server.agentId || server.agentId === agentId).map(({ agentId: _agentId, ...server }) => server);
18
+ }
19
+
20
+ //#endregion
21
+ export { resolveMcpAppsServers };
22
+ //# sourceMappingURL=mcp-apps-servers.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mcp-apps-servers.mjs","names":[],"sources":["../../../../src/runtime/handlers/shared/mcp-apps-servers.ts"],"sourcesContent":["import type { MCPClientConfig } from \"@ag-ui/mcp-apps-middleware\";\nimport type { McpAppsServerConfig } from \"../../core/runtime\";\nimport { describeEndpoint } from \"./describe-endpoint\";\n\nconst UNSUPPORTED_POLICY_KEYS = [\"includeTools\", \"excludeTools\"] as const;\nconst MCP_APPS_POLICY_ISSUE =\n \"https://github.com/CopilotKit/CopilotKit/issues/5930\";\n\n/**\n * Select the servers for an agent and validate the policy boundary owned by\n * the installed MCP Apps middleware.\n */\nexport function resolveMcpAppsServers(\n servers: readonly McpAppsServerConfig[],\n agentId: string,\n): MCPClientConfig[] {\n const violations: string[] = [];\n\n for (const [index, server] of servers.entries()) {\n const config = server as unknown as Record<string, unknown>;\n for (const key of UNSUPPORTED_POLICY_KEYS) {\n if (\n Object.prototype.hasOwnProperty.call(config, key) &&\n config[key] !== undefined\n ) {\n violations.push(\n `${key} at server[${index}] (${server.serverId ?? describeEndpoint(server.url)})`,\n );\n }\n }\n }\n\n if (violations.length > 0) {\n throw new Error(\n `Unsupported MCP Apps tool policy: ${violations.join(\", \")}. ` +\n `@ag-ui/mcp-apps-middleware owns per-server tool policy, and the ` +\n `release the runtime depends on does not support these keys; see ` +\n `${MCP_APPS_POLICY_ISSUE}.`,\n );\n }\n\n return servers\n .filter((server) => !server.agentId || server.agentId === agentId)\n .map(({ agentId: _agentId, ...server }) => server as MCPClientConfig);\n}\n"],"mappings":";;;AAIA,MAAM,0BAA0B,CAAC,gBAAgB,eAAe;AAChE,MAAM,wBACJ;;;;;AAMF,SAAgB,sBACd,SACA,SACmB;CACnB,MAAM,aAAuB,EAAE;AAE/B,MAAK,MAAM,CAAC,OAAO,WAAW,QAAQ,SAAS,EAAE;EAC/C,MAAM,SAAS;AACf,OAAK,MAAM,OAAO,wBAChB,KACE,OAAO,UAAU,eAAe,KAAK,QAAQ,IAAI,IACjD,OAAO,SAAS,OAEhB,YAAW,KACT,GAAG,IAAI,aAAa,MAAM,KAAK,OAAO,YAAY,iBAAiB,OAAO,IAAI,CAAC,GAChF;;AAKP,KAAI,WAAW,SAAS,EACtB,OAAM,IAAI,MACR,qCAAqC,WAAW,KAAK,KAAK,CAAC,oIAGtD,sBAAsB,GAC5B;AAGH,QAAO,QACJ,QAAQ,WAAW,CAAC,OAAO,WAAW,OAAO,YAAY,QAAQ,CACjE,KAAK,EAAE,SAAS,UAAU,GAAG,aAAa,OAA0B"}
@@ -0,0 +1,78 @@
1
+ const require_json_response = require('./json-response.cjs');
2
+
3
+ //#region src/runtime/handlers/shared/memory-policy.ts
4
+ const ACCESS = new Set([
5
+ "none",
6
+ "read",
7
+ "read-write"
8
+ ]);
9
+ /** What a policy that declines Memory entirely resolves to. */
10
+ const NO_MEMORY = Object.freeze({
11
+ user: "none",
12
+ project: "none"
13
+ });
14
+ /**
15
+ * True when a grant asks for any Memory operation at all.
16
+ *
17
+ * The web counterpart of `hasMemoryAccess` in `@copilotkit/channels-core`, and
18
+ * deliberately the same predicate: a grant with every scope at `"none"` means
19
+ * "this request gets no Memory", NOT "refuse this request". Channels has always
20
+ * read it that way — there both scopes are optional and default to `"none"`, so
21
+ * all-none is the grant you get by writing nothing, which could not coherently
22
+ * mean refusal.
23
+ */
24
+ function grantAllowsMemory(grant) {
25
+ return grant.user !== "none" || grant.project !== "none";
26
+ }
27
+ /**
28
+ * Evaluates and validates one configured web Memory policy.
29
+ *
30
+ * Resolving is separate from ACTING on the result, because the two callers want
31
+ * opposite things from a policy that grants nothing:
32
+ *
33
+ * - An agent run wants to proceed WITHOUT Memory tools. `memory.access` is a
34
+ * Memory policy, not an authorization gate on the conversation; a runtime
35
+ * that wants to reject the request outright has `beforeRequestMiddleware`
36
+ * for exactly that. Failing the run here means a deployment that switches
37
+ * Memory off for one tenant gets no assistant at all, and the failure
38
+ * surfaces as a bare run error rather than as anything a user can read.
39
+ * - The browser Memory routes want a 403. There the caller asked for memories
40
+ * specifically, so "you may not have them" is the honest answer, and an
41
+ * empty list would imply none exist.
42
+ *
43
+ * So this returns the grant (or a Response for a genuinely broken policy), and
44
+ * each call site applies `grantAllowsMemory` to its own case.
45
+ */
46
+ async function resolveWebMemory(runtime, request, user, consumer) {
47
+ if (!runtime.memory) return {
48
+ user,
49
+ grant: {
50
+ user: "read-write",
51
+ project: "read-write"
52
+ }
53
+ };
54
+ try {
55
+ const grant = await runtime.memory.access({
56
+ request,
57
+ user,
58
+ consumer
59
+ });
60
+ if (grant === void 0) return require_json_response.errorResponse("Memory policy returned an invalid grant", 500);
61
+ const resolved = grant ?? NO_MEMORY;
62
+ if (!ACCESS.has(resolved.user) || !ACCESS.has(resolved.project)) return require_json_response.errorResponse("Memory policy returned an invalid grant", 500);
63
+ return {
64
+ user,
65
+ grant: {
66
+ user: resolved.user,
67
+ project: resolved.project
68
+ }
69
+ };
70
+ } catch {
71
+ return require_json_response.errorResponse("Memory policy failed", 500);
72
+ }
73
+ }
74
+
75
+ //#endregion
76
+ exports.grantAllowsMemory = grantAllowsMemory;
77
+ exports.resolveWebMemory = resolveWebMemory;
78
+ //# sourceMappingURL=memory-policy.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-policy.cjs","names":["errorResponse"],"sources":["../../../../src/runtime/handlers/shared/memory-policy.ts"],"sourcesContent":["import type {\n CopilotIntelligenceRuntimeLike,\n CopilotRuntimeUser,\n MemoryConsumer,\n MemoryGrant,\n} from \"../../core/runtime\";\nimport { errorResponse } from \"./json-response\";\n\nconst ACCESS = new Set([\"none\", \"read\", \"read-write\"]);\n\n/** What a policy that declines Memory entirely resolves to. */\nconst NO_MEMORY: MemoryGrant = Object.freeze({\n user: \"none\",\n project: \"none\",\n});\n\nexport interface ResolvedWebMemory {\n readonly user: CopilotRuntimeUser;\n readonly grant: MemoryGrant;\n}\n\n/**\n * True when a grant asks for any Memory operation at all.\n *\n * The web counterpart of `hasMemoryAccess` in `@copilotkit/channels-core`, and\n * deliberately the same predicate: a grant with every scope at `\"none\"` means\n * \"this request gets no Memory\", NOT \"refuse this request\". Channels has always\n * read it that way — there both scopes are optional and default to `\"none\"`, so\n * all-none is the grant you get by writing nothing, which could not coherently\n * mean refusal.\n */\nexport function grantAllowsMemory(grant: MemoryGrant): boolean {\n return grant.user !== \"none\" || grant.project !== \"none\";\n}\n\n/**\n * Evaluates and validates one configured web Memory policy.\n *\n * Resolving is separate from ACTING on the result, because the two callers want\n * opposite things from a policy that grants nothing:\n *\n * - An agent run wants to proceed WITHOUT Memory tools. `memory.access` is a\n * Memory policy, not an authorization gate on the conversation; a runtime\n * that wants to reject the request outright has `beforeRequestMiddleware`\n * for exactly that. Failing the run here means a deployment that switches\n * Memory off for one tenant gets no assistant at all, and the failure\n * surfaces as a bare run error rather than as anything a user can read.\n * - The browser Memory routes want a 403. There the caller asked for memories\n * specifically, so \"you may not have them\" is the honest answer, and an\n * empty list would imply none exist.\n *\n * So this returns the grant (or a Response for a genuinely broken policy), and\n * each call site applies `grantAllowsMemory` to its own case.\n */\nexport async function resolveWebMemory(\n runtime: CopilotIntelligenceRuntimeLike,\n request: Request,\n user: CopilotRuntimeUser,\n consumer: MemoryConsumer,\n): Promise<ResolvedWebMemory | Response> {\n if (!runtime.memory) {\n return {\n user,\n grant: { user: \"read-write\", project: \"read-write\" },\n };\n }\n\n try {\n const grant = await runtime.memory.access({ request, user, consumer });\n // `null` is the policy declining to grant anything, which is the same\n // outcome as an explicit all-none grant — not a distinct third state.\n //\n // `undefined` is NOT that. The contract is `MemoryGrant | null`, so a\n // missing return is a policy that is broken rather than restrictive — a\n // JavaScript caller who forgot one, or a branch that falls off the end.\n // Reading it as \"grant nothing\" would switch Memory off silently for the\n // exact deployments least able to notice; it fails loudly instead.\n if (grant === undefined) {\n return errorResponse(\"Memory policy returned an invalid grant\", 500);\n }\n const resolved = grant ?? NO_MEMORY;\n if (!ACCESS.has(resolved.user) || !ACCESS.has(resolved.project)) {\n return errorResponse(\"Memory policy returned an invalid grant\", 500);\n }\n return { user, grant: { user: resolved.user, project: resolved.project } };\n } catch {\n return errorResponse(\"Memory policy failed\", 500);\n }\n}\n"],"mappings":";;;AAQA,MAAM,SAAS,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAa,CAAC;;AAGtD,MAAM,YAAyB,OAAO,OAAO;CAC3C,MAAM;CACN,SAAS;CACV,CAAC;;;;;;;;;;;AAiBF,SAAgB,kBAAkB,OAA6B;AAC7D,QAAO,MAAM,SAAS,UAAU,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;AAsBpD,eAAsB,iBACpB,SACA,SACA,MACA,UACuC;AACvC,KAAI,CAAC,QAAQ,OACX,QAAO;EACL;EACA,OAAO;GAAE,MAAM;GAAc,SAAS;GAAc;EACrD;AAGH,KAAI;EACF,MAAM,QAAQ,MAAM,QAAQ,OAAO,OAAO;GAAE;GAAS;GAAM;GAAU,CAAC;AAStE,MAAI,UAAU,OACZ,QAAOA,oCAAc,2CAA2C,IAAI;EAEtE,MAAM,WAAW,SAAS;AAC1B,MAAI,CAAC,OAAO,IAAI,SAAS,KAAK,IAAI,CAAC,OAAO,IAAI,SAAS,QAAQ,CAC7D,QAAOA,oCAAc,2CAA2C,IAAI;AAEtE,SAAO;GAAE;GAAM,OAAO;IAAE,MAAM,SAAS;IAAM,SAAS,SAAS;IAAS;GAAE;SACpE;AACN,SAAOA,oCAAc,wBAAwB,IAAI"}
@@ -0,0 +1,77 @@
1
+ import { errorResponse } from "./json-response.mjs";
2
+
3
+ //#region src/runtime/handlers/shared/memory-policy.ts
4
+ const ACCESS = new Set([
5
+ "none",
6
+ "read",
7
+ "read-write"
8
+ ]);
9
+ /** What a policy that declines Memory entirely resolves to. */
10
+ const NO_MEMORY = Object.freeze({
11
+ user: "none",
12
+ project: "none"
13
+ });
14
+ /**
15
+ * True when a grant asks for any Memory operation at all.
16
+ *
17
+ * The web counterpart of `hasMemoryAccess` in `@copilotkit/channels-core`, and
18
+ * deliberately the same predicate: a grant with every scope at `"none"` means
19
+ * "this request gets no Memory", NOT "refuse this request". Channels has always
20
+ * read it that way — there both scopes are optional and default to `"none"`, so
21
+ * all-none is the grant you get by writing nothing, which could not coherently
22
+ * mean refusal.
23
+ */
24
+ function grantAllowsMemory(grant) {
25
+ return grant.user !== "none" || grant.project !== "none";
26
+ }
27
+ /**
28
+ * Evaluates and validates one configured web Memory policy.
29
+ *
30
+ * Resolving is separate from ACTING on the result, because the two callers want
31
+ * opposite things from a policy that grants nothing:
32
+ *
33
+ * - An agent run wants to proceed WITHOUT Memory tools. `memory.access` is a
34
+ * Memory policy, not an authorization gate on the conversation; a runtime
35
+ * that wants to reject the request outright has `beforeRequestMiddleware`
36
+ * for exactly that. Failing the run here means a deployment that switches
37
+ * Memory off for one tenant gets no assistant at all, and the failure
38
+ * surfaces as a bare run error rather than as anything a user can read.
39
+ * - The browser Memory routes want a 403. There the caller asked for memories
40
+ * specifically, so "you may not have them" is the honest answer, and an
41
+ * empty list would imply none exist.
42
+ *
43
+ * So this returns the grant (or a Response for a genuinely broken policy), and
44
+ * each call site applies `grantAllowsMemory` to its own case.
45
+ */
46
+ async function resolveWebMemory(runtime, request, user, consumer) {
47
+ if (!runtime.memory) return {
48
+ user,
49
+ grant: {
50
+ user: "read-write",
51
+ project: "read-write"
52
+ }
53
+ };
54
+ try {
55
+ const grant = await runtime.memory.access({
56
+ request,
57
+ user,
58
+ consumer
59
+ });
60
+ if (grant === void 0) return errorResponse("Memory policy returned an invalid grant", 500);
61
+ const resolved = grant ?? NO_MEMORY;
62
+ if (!ACCESS.has(resolved.user) || !ACCESS.has(resolved.project)) return errorResponse("Memory policy returned an invalid grant", 500);
63
+ return {
64
+ user,
65
+ grant: {
66
+ user: resolved.user,
67
+ project: resolved.project
68
+ }
69
+ };
70
+ } catch {
71
+ return errorResponse("Memory policy failed", 500);
72
+ }
73
+ }
74
+
75
+ //#endregion
76
+ export { grantAllowsMemory, resolveWebMemory };
77
+ //# sourceMappingURL=memory-policy.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory-policy.mjs","names":[],"sources":["../../../../src/runtime/handlers/shared/memory-policy.ts"],"sourcesContent":["import type {\n CopilotIntelligenceRuntimeLike,\n CopilotRuntimeUser,\n MemoryConsumer,\n MemoryGrant,\n} from \"../../core/runtime\";\nimport { errorResponse } from \"./json-response\";\n\nconst ACCESS = new Set([\"none\", \"read\", \"read-write\"]);\n\n/** What a policy that declines Memory entirely resolves to. */\nconst NO_MEMORY: MemoryGrant = Object.freeze({\n user: \"none\",\n project: \"none\",\n});\n\nexport interface ResolvedWebMemory {\n readonly user: CopilotRuntimeUser;\n readonly grant: MemoryGrant;\n}\n\n/**\n * True when a grant asks for any Memory operation at all.\n *\n * The web counterpart of `hasMemoryAccess` in `@copilotkit/channels-core`, and\n * deliberately the same predicate: a grant with every scope at `\"none\"` means\n * \"this request gets no Memory\", NOT \"refuse this request\". Channels has always\n * read it that way — there both scopes are optional and default to `\"none\"`, so\n * all-none is the grant you get by writing nothing, which could not coherently\n * mean refusal.\n */\nexport function grantAllowsMemory(grant: MemoryGrant): boolean {\n return grant.user !== \"none\" || grant.project !== \"none\";\n}\n\n/**\n * Evaluates and validates one configured web Memory policy.\n *\n * Resolving is separate from ACTING on the result, because the two callers want\n * opposite things from a policy that grants nothing:\n *\n * - An agent run wants to proceed WITHOUT Memory tools. `memory.access` is a\n * Memory policy, not an authorization gate on the conversation; a runtime\n * that wants to reject the request outright has `beforeRequestMiddleware`\n * for exactly that. Failing the run here means a deployment that switches\n * Memory off for one tenant gets no assistant at all, and the failure\n * surfaces as a bare run error rather than as anything a user can read.\n * - The browser Memory routes want a 403. There the caller asked for memories\n * specifically, so \"you may not have them\" is the honest answer, and an\n * empty list would imply none exist.\n *\n * So this returns the grant (or a Response for a genuinely broken policy), and\n * each call site applies `grantAllowsMemory` to its own case.\n */\nexport async function resolveWebMemory(\n runtime: CopilotIntelligenceRuntimeLike,\n request: Request,\n user: CopilotRuntimeUser,\n consumer: MemoryConsumer,\n): Promise<ResolvedWebMemory | Response> {\n if (!runtime.memory) {\n return {\n user,\n grant: { user: \"read-write\", project: \"read-write\" },\n };\n }\n\n try {\n const grant = await runtime.memory.access({ request, user, consumer });\n // `null` is the policy declining to grant anything, which is the same\n // outcome as an explicit all-none grant — not a distinct third state.\n //\n // `undefined` is NOT that. The contract is `MemoryGrant | null`, so a\n // missing return is a policy that is broken rather than restrictive — a\n // JavaScript caller who forgot one, or a branch that falls off the end.\n // Reading it as \"grant nothing\" would switch Memory off silently for the\n // exact deployments least able to notice; it fails loudly instead.\n if (grant === undefined) {\n return errorResponse(\"Memory policy returned an invalid grant\", 500);\n }\n const resolved = grant ?? NO_MEMORY;\n if (!ACCESS.has(resolved.user) || !ACCESS.has(resolved.project)) {\n return errorResponse(\"Memory policy returned an invalid grant\", 500);\n }\n return { user, grant: { user: resolved.user, project: resolved.project } };\n } catch {\n return errorResponse(\"Memory policy failed\", 500);\n }\n}\n"],"mappings":";;;AAQA,MAAM,SAAS,IAAI,IAAI;CAAC;CAAQ;CAAQ;CAAa,CAAC;;AAGtD,MAAM,YAAyB,OAAO,OAAO;CAC3C,MAAM;CACN,SAAS;CACV,CAAC;;;;;;;;;;;AAiBF,SAAgB,kBAAkB,OAA6B;AAC7D,QAAO,MAAM,SAAS,UAAU,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;AAsBpD,eAAsB,iBACpB,SACA,SACA,MACA,UACuC;AACvC,KAAI,CAAC,QAAQ,OACX,QAAO;EACL;EACA,OAAO;GAAE,MAAM;GAAc,SAAS;GAAc;EACrD;AAGH,KAAI;EACF,MAAM,QAAQ,MAAM,QAAQ,OAAO,OAAO;GAAE;GAAS;GAAM;GAAU,CAAC;AAStE,MAAI,UAAU,OACZ,QAAO,cAAc,2CAA2C,IAAI;EAEtE,MAAM,WAAW,SAAS;AAC1B,MAAI,CAAC,OAAO,IAAI,SAAS,KAAK,IAAI,CAAC,OAAO,IAAI,SAAS,QAAQ,CAC7D,QAAO,cAAc,2CAA2C,IAAI;AAEtE,SAAO;GAAE;GAAM,OAAO;IAAE,MAAM,SAAS;IAAM,SAAS,SAAS;IAAS;GAAE;SACpE;AACN,SAAO,cAAc,wBAAwB,IAAI"}
@@ -0,0 +1,39 @@
1
+ const require_json_response = require('./json-response.cjs');
2
+ const require_client = require('../../intelligence-platform/client.cjs');
3
+
4
+ //#region src/runtime/handlers/shared/platform-error.ts
5
+ /**
6
+ * Map a thrown error from a platform call onto a `Response`.
7
+ *
8
+ * Extracted from the memory handlers, which had it first and alone; the thread
9
+ * handlers flattened every failure to 500, so a "this does not exist yet" was
10
+ * indistinguishable from "the platform is down". One copy, because two would
11
+ * drift the moment either grew a case.
12
+ *
13
+ * Forward only client-actionable **4xx** statuses verbatim (404 missing or
14
+ * wrong-scope, 409 conflict, 422 unprocessable) so a consumer can branch on
15
+ * them — a flat 500 erases that distinction. A platform **5xx**, or any non-4xx
16
+ * or malformed status, means this runtime is healthy but its dependency failed,
17
+ * so it surfaces as `502 Bad Gateway` rather than echoing the upstream status as
18
+ * if the runtime itself broke. That also avoids a `RangeError` from
19
+ * `new Response(..., { status })` on an out-of-range status. Anything that is
20
+ * not a platform error at all stays 500.
21
+ *
22
+ * A platform **401** is also 502: it rejects the runtime's own credentials
23
+ * (e.g. a rotated API key), not the end user, so forwarding it would tell the
24
+ * browser the user is unauthenticated for a fault only the server can fix. A
25
+ * **403** is different: the platform uses it to deny this user an action (e.g.
26
+ * a write to read-only memory), so it is forwarded like any other 4xx.
27
+ */
28
+ function platformErrorResponse(error, message) {
29
+ if (error instanceof require_client.PlatformRequestError) {
30
+ const { status } = error;
31
+ if (Number.isInteger(status) && status >= 400 && status <= 499 && status !== 401) return require_json_response.errorResponse(message, status);
32
+ return require_json_response.errorResponse(message, 502);
33
+ }
34
+ return require_json_response.errorResponse(message, 500);
35
+ }
36
+
37
+ //#endregion
38
+ exports.platformErrorResponse = platformErrorResponse;
39
+ //# sourceMappingURL=platform-error.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"platform-error.cjs","names":["PlatformRequestError","errorResponse"],"sources":["../../../../src/runtime/handlers/shared/platform-error.ts"],"sourcesContent":["import { PlatformRequestError } from \"../../intelligence-platform/client\";\nimport { errorResponse } from \"./json-response\";\n\n/**\n * Map a thrown error from a platform call onto a `Response`.\n *\n * Extracted from the memory handlers, which had it first and alone; the thread\n * handlers flattened every failure to 500, so a \"this does not exist yet\" was\n * indistinguishable from \"the platform is down\". One copy, because two would\n * drift the moment either grew a case.\n *\n * Forward only client-actionable **4xx** statuses verbatim (404 missing or\n * wrong-scope, 409 conflict, 422 unprocessable) so a consumer can branch on\n * them — a flat 500 erases that distinction. A platform **5xx**, or any non-4xx\n * or malformed status, means this runtime is healthy but its dependency failed,\n * so it surfaces as `502 Bad Gateway` rather than echoing the upstream status as\n * if the runtime itself broke. That also avoids a `RangeError` from\n * `new Response(..., { status })` on an out-of-range status. Anything that is\n * not a platform error at all stays 500.\n *\n * A platform **401** is also 502: it rejects the runtime's own credentials\n * (e.g. a rotated API key), not the end user, so forwarding it would tell the\n * browser the user is unauthenticated for a fault only the server can fix. A\n * **403** is different: the platform uses it to deny this user an action (e.g.\n * a write to read-only memory), so it is forwarded like any other 4xx.\n */\nexport function platformErrorResponse(\n error: unknown,\n message: string,\n): Response {\n if (error instanceof PlatformRequestError) {\n const { status } = error;\n if (\n Number.isInteger(status) &&\n status >= 400 &&\n status <= 499 &&\n status !== 401\n ) {\n return errorResponse(message, status);\n }\n return errorResponse(message, 502);\n }\n return errorResponse(message, 500);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAgB,sBACd,OACA,SACU;AACV,KAAI,iBAAiBA,qCAAsB;EACzC,MAAM,EAAE,WAAW;AACnB,MACE,OAAO,UAAU,OAAO,IACxB,UAAU,OACV,UAAU,OACV,WAAW,IAEX,QAAOC,oCAAc,SAAS,OAAO;AAEvC,SAAOA,oCAAc,SAAS,IAAI;;AAEpC,QAAOA,oCAAc,SAAS,IAAI"}