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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (623) 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 +18 -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/index.cjs +75 -0
  63. package/dist/index.d.cts +24 -0
  64. package/dist/index.d.mts +24 -0
  65. package/dist/index.mjs +17 -5598
  66. package/dist/internal/learned-skills.cjs +21 -0
  67. package/dist/internal/learned-skills.d.cts +9 -0
  68. package/dist/internal/learned-skills.d.mts +9 -0
  69. package/dist/internal/learned-skills.mjs +9 -0
  70. package/dist/node.cjs +7 -0
  71. package/dist/node.d.cts +4 -0
  72. package/dist/node.d.mts +4 -0
  73. package/dist/node.mjs +4 -0
  74. package/dist/runtime/core/channel-activation-config.cjs +87 -0
  75. package/dist/runtime/core/channel-activation-config.cjs.map +1 -0
  76. package/dist/runtime/core/channel-activation-config.d.cts +39 -0
  77. package/dist/runtime/core/channel-activation-config.d.cts.map +1 -0
  78. package/dist/runtime/core/channel-activation-config.d.mts +39 -0
  79. package/dist/runtime/core/channel-activation-config.d.mts.map +1 -0
  80. package/dist/runtime/core/channel-activation-config.mjs +85 -0
  81. package/dist/runtime/core/channel-activation-config.mjs.map +1 -0
  82. package/dist/runtime/core/channel-manager.cjs +973 -0
  83. package/dist/runtime/core/channel-manager.cjs.map +1 -0
  84. package/dist/runtime/core/channel-manager.d.cts +166 -0
  85. package/dist/runtime/core/channel-manager.d.cts.map +1 -0
  86. package/dist/runtime/core/channel-manager.d.mts +167 -0
  87. package/dist/runtime/core/channel-manager.d.mts.map +1 -0
  88. package/dist/runtime/core/channel-manager.mjs +972 -0
  89. package/dist/runtime/core/channel-manager.mjs.map +1 -0
  90. package/dist/runtime/core/debug-event-bus.cjs +57 -0
  91. package/dist/runtime/core/debug-event-bus.cjs.map +1 -0
  92. package/dist/runtime/core/debug-event-bus.d.cts +18 -0
  93. package/dist/runtime/core/debug-event-bus.d.cts.map +1 -0
  94. package/dist/runtime/core/debug-event-bus.d.mts +18 -0
  95. package/dist/runtime/core/debug-event-bus.d.mts.map +1 -0
  96. package/dist/runtime/core/debug-event-bus.mjs +55 -0
  97. package/dist/runtime/core/debug-event-bus.mjs.map +1 -0
  98. package/dist/runtime/core/fetch-cors.cjs +71 -0
  99. package/dist/runtime/core/fetch-cors.cjs.map +1 -0
  100. package/dist/runtime/core/fetch-cors.d.cts +19 -0
  101. package/dist/runtime/core/fetch-cors.d.cts.map +1 -0
  102. package/dist/runtime/core/fetch-cors.d.mts +19 -0
  103. package/dist/runtime/core/fetch-cors.d.mts.map +1 -0
  104. package/dist/runtime/core/fetch-cors.mjs +69 -0
  105. package/dist/runtime/core/fetch-cors.mjs.map +1 -0
  106. package/dist/runtime/core/fetch-handler.cjs +539 -0
  107. package/dist/runtime/core/fetch-handler.cjs.map +1 -0
  108. package/dist/runtime/core/fetch-handler.d.cts +99 -0
  109. package/dist/runtime/core/fetch-handler.d.cts.map +1 -0
  110. package/dist/runtime/core/fetch-handler.d.mts +99 -0
  111. package/dist/runtime/core/fetch-handler.d.mts.map +1 -0
  112. package/dist/runtime/core/fetch-handler.mjs +538 -0
  113. package/dist/runtime/core/fetch-handler.mjs.map +1 -0
  114. package/dist/runtime/core/fetch-router.cjs +141 -0
  115. package/dist/runtime/core/fetch-router.cjs.map +1 -0
  116. package/dist/runtime/core/fetch-router.mjs +140 -0
  117. package/dist/runtime/core/fetch-router.mjs.map +1 -0
  118. package/dist/runtime/core/hooks.cjs +28 -0
  119. package/dist/runtime/core/hooks.cjs.map +1 -0
  120. package/dist/runtime/core/hooks.d.cts +121 -0
  121. package/dist/runtime/core/hooks.d.cts.map +1 -0
  122. package/dist/runtime/core/hooks.d.mts +121 -0
  123. package/dist/runtime/core/hooks.d.mts.map +1 -0
  124. package/dist/runtime/core/hooks.mjs +24 -0
  125. package/dist/runtime/core/hooks.mjs.map +1 -0
  126. package/dist/runtime/core/learning.cjs +61 -0
  127. package/dist/runtime/core/learning.cjs.map +1 -0
  128. package/dist/runtime/core/learning.d.cts +61 -0
  129. package/dist/runtime/core/learning.d.cts.map +1 -0
  130. package/dist/runtime/core/learning.d.mts +61 -0
  131. package/dist/runtime/core/learning.d.mts.map +1 -0
  132. package/dist/runtime/core/learning.mjs +56 -0
  133. package/dist/runtime/core/learning.mjs.map +1 -0
  134. package/dist/runtime/core/logger.cjs +21 -0
  135. package/dist/runtime/core/logger.cjs.map +1 -0
  136. package/dist/runtime/core/logger.d.cts +12 -0
  137. package/dist/runtime/core/logger.d.cts.map +1 -0
  138. package/dist/runtime/core/logger.d.mts +12 -0
  139. package/dist/runtime/core/logger.d.mts.map +1 -0
  140. package/dist/runtime/core/logger.mjs +18 -0
  141. package/dist/runtime/core/logger.mjs.map +1 -0
  142. package/dist/runtime/core/middleware-sse-parser.cjs +149 -0
  143. package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -0
  144. package/dist/runtime/core/middleware-sse-parser.d.cts +21 -0
  145. package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -0
  146. package/dist/runtime/core/middleware-sse-parser.d.mts +21 -0
  147. package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -0
  148. package/dist/runtime/core/middleware-sse-parser.mjs +148 -0
  149. package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -0
  150. package/dist/runtime/core/middleware.cjs +34 -0
  151. package/dist/runtime/core/middleware.cjs.map +1 -0
  152. package/dist/runtime/core/middleware.d.cts +31 -0
  153. package/dist/runtime/core/middleware.d.cts.map +1 -0
  154. package/dist/runtime/core/middleware.d.mts +31 -0
  155. package/dist/runtime/core/middleware.d.mts.map +1 -0
  156. package/dist/runtime/core/middleware.mjs +32 -0
  157. package/dist/runtime/core/middleware.mjs.map +1 -0
  158. package/dist/runtime/core/package-info.cjs +9 -0
  159. package/dist/runtime/core/package-info.cjs.map +1 -0
  160. package/dist/runtime/core/package-info.mjs +7 -0
  161. package/dist/runtime/core/package-info.mjs.map +1 -0
  162. package/dist/runtime/core/runtime-error-reporter.cjs +21 -0
  163. package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -0
  164. package/dist/runtime/core/runtime-error-reporter.mjs +18 -0
  165. package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -0
  166. package/dist/runtime/core/runtime.cjs +256 -0
  167. package/dist/runtime/core/runtime.cjs.map +1 -0
  168. package/dist/runtime/core/runtime.d.cts +481 -0
  169. package/dist/runtime/core/runtime.d.cts.map +1 -0
  170. package/dist/runtime/core/runtime.d.mts +481 -0
  171. package/dist/runtime/core/runtime.d.mts.map +1 -0
  172. package/dist/runtime/core/runtime.mjs +249 -0
  173. package/dist/runtime/core/runtime.mjs.map +1 -0
  174. package/dist/runtime/endpoints/auto-start-channels.cjs +46 -0
  175. package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -0
  176. package/dist/runtime/endpoints/auto-start-channels.mjs +45 -0
  177. package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -0
  178. package/dist/runtime/endpoints/node-fetch-handler.cjs +75 -0
  179. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -0
  180. package/dist/runtime/endpoints/node-fetch-handler.d.cts +11 -0
  181. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -0
  182. package/dist/runtime/endpoints/node-fetch-handler.d.mts +11 -0
  183. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -0
  184. package/dist/runtime/endpoints/node-fetch-handler.mjs +73 -0
  185. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -0
  186. package/dist/runtime/endpoints/node.cjs +16 -0
  187. package/dist/runtime/endpoints/node.cjs.map +1 -0
  188. package/dist/runtime/endpoints/node.d.cts +104 -0
  189. package/dist/runtime/endpoints/node.d.cts.map +1 -0
  190. package/dist/runtime/endpoints/node.d.mts +104 -0
  191. package/dist/runtime/endpoints/node.d.mts.map +1 -0
  192. package/dist/runtime/endpoints/node.mjs +16 -0
  193. package/dist/runtime/endpoints/node.mjs.map +1 -0
  194. package/dist/runtime/endpoints/single-route-helpers.cjs +130 -0
  195. package/dist/runtime/endpoints/single-route-helpers.cjs.map +1 -0
  196. package/dist/runtime/endpoints/single-route-helpers.mjs +125 -0
  197. package/dist/runtime/endpoints/single-route-helpers.mjs.map +1 -0
  198. package/dist/runtime/generative-ui/generative-ui-middleware.cjs +393 -0
  199. package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -0
  200. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts +20 -0
  201. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts.map +1 -0
  202. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts +20 -0
  203. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts.map +1 -0
  204. package/dist/runtime/generative-ui/generative-ui-middleware.mjs +392 -0
  205. package/dist/runtime/generative-ui/generative-ui-middleware.mjs.map +1 -0
  206. package/dist/runtime/generative-ui/index.d.cts +2 -0
  207. package/dist/runtime/generative-ui/index.d.mts +2 -0
  208. package/dist/runtime/generative-ui/surface-writer.cjs +85 -0
  209. package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -0
  210. package/dist/runtime/generative-ui/surface-writer.d.cts +32 -0
  211. package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -0
  212. package/dist/runtime/generative-ui/surface-writer.d.mts +32 -0
  213. package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -0
  214. package/dist/runtime/generative-ui/surface-writer.mjs +84 -0
  215. package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -0
  216. package/dist/runtime/handlers/get-runtime-info.cjs +140 -0
  217. package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -0
  218. package/dist/runtime/handlers/get-runtime-info.mjs +140 -0
  219. package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -0
  220. package/dist/runtime/handlers/handle-connect.cjs +62 -0
  221. package/dist/runtime/handlers/handle-connect.cjs.map +1 -0
  222. package/dist/runtime/handlers/handle-connect.mjs +62 -0
  223. package/dist/runtime/handlers/handle-connect.mjs.map +1 -0
  224. package/dist/runtime/handlers/handle-debug-events.cjs +33 -0
  225. package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -0
  226. package/dist/runtime/handlers/handle-debug-events.mjs +33 -0
  227. package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -0
  228. package/dist/runtime/handlers/handle-inspector-learning.cjs +56 -0
  229. package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -0
  230. package/dist/runtime/handlers/handle-inspector-learning.mjs +55 -0
  231. package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -0
  232. package/dist/runtime/handlers/handle-inspector-metadata.cjs +36 -0
  233. package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -0
  234. package/dist/runtime/handlers/handle-inspector-metadata.mjs +35 -0
  235. package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -0
  236. package/dist/runtime/handlers/handle-run.cjs +111 -0
  237. package/dist/runtime/handlers/handle-run.cjs.map +1 -0
  238. package/dist/runtime/handlers/handle-run.mjs +110 -0
  239. package/dist/runtime/handlers/handle-run.mjs.map +1 -0
  240. package/dist/runtime/handlers/handle-stop.cjs +102 -0
  241. package/dist/runtime/handlers/handle-stop.cjs.map +1 -0
  242. package/dist/runtime/handlers/handle-stop.mjs +101 -0
  243. package/dist/runtime/handlers/handle-stop.mjs.map +1 -0
  244. package/dist/runtime/handlers/handle-suggest.cjs +83 -0
  245. package/dist/runtime/handlers/handle-suggest.cjs.map +1 -0
  246. package/dist/runtime/handlers/handle-suggest.mjs +82 -0
  247. package/dist/runtime/handlers/handle-suggest.mjs.map +1 -0
  248. package/dist/runtime/handlers/handle-trajectory-connect.cjs +40 -0
  249. package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -0
  250. package/dist/runtime/handlers/handle-trajectory-connect.mjs +39 -0
  251. package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -0
  252. package/dist/runtime/handlers/handle-transcribe.cjs +112 -0
  253. package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -0
  254. package/dist/runtime/handlers/handle-transcribe.mjs +111 -0
  255. package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -0
  256. package/dist/runtime/handlers/header-utils.cjs +185 -0
  257. package/dist/runtime/handlers/header-utils.cjs.map +1 -0
  258. package/dist/runtime/handlers/header-utils.d.cts +53 -0
  259. package/dist/runtime/handlers/header-utils.d.cts.map +1 -0
  260. package/dist/runtime/handlers/header-utils.d.mts +53 -0
  261. package/dist/runtime/handlers/header-utils.d.mts.map +1 -0
  262. package/dist/runtime/handlers/header-utils.mjs +183 -0
  263. package/dist/runtime/handlers/header-utils.mjs.map +1 -0
  264. package/dist/runtime/handlers/intelligence/annotate.cjs +83 -0
  265. package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -0
  266. package/dist/runtime/handlers/intelligence/annotate.mjs +82 -0
  267. package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -0
  268. package/dist/runtime/handlers/intelligence/connect.cjs +68 -0
  269. package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -0
  270. package/dist/runtime/handlers/intelligence/connect.mjs +68 -0
  271. package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -0
  272. package/dist/runtime/handlers/intelligence/memories.cjs +260 -0
  273. package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -0
  274. package/dist/runtime/handlers/intelligence/memories.mjs +254 -0
  275. package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -0
  276. package/dist/runtime/handlers/intelligence/run.cjs +283 -0
  277. package/dist/runtime/handlers/intelligence/run.cjs.map +1 -0
  278. package/dist/runtime/handlers/intelligence/run.mjs +282 -0
  279. package/dist/runtime/handlers/intelligence/run.mjs.map +1 -0
  280. package/dist/runtime/handlers/intelligence/thread-names.cjs +172 -0
  281. package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -0
  282. package/dist/runtime/handlers/intelligence/thread-names.mjs +171 -0
  283. package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -0
  284. package/dist/runtime/handlers/intelligence/threads.cjs +399 -0
  285. package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -0
  286. package/dist/runtime/handlers/intelligence/threads.mjs +390 -0
  287. package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -0
  288. package/dist/runtime/handlers/shared/agent-utils.cjs +267 -0
  289. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -0
  290. package/dist/runtime/handlers/shared/agent-utils.mjs +262 -0
  291. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -0
  292. package/dist/runtime/handlers/shared/cloud-telemetry.cjs +30 -0
  293. package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -0
  294. package/dist/runtime/handlers/shared/cloud-telemetry.mjs +29 -0
  295. package/dist/runtime/handlers/shared/cloud-telemetry.mjs.map +1 -0
  296. package/dist/runtime/handlers/shared/describe-endpoint.cjs +25 -0
  297. package/dist/runtime/handlers/shared/describe-endpoint.cjs.map +1 -0
  298. package/dist/runtime/handlers/shared/describe-endpoint.mjs +24 -0
  299. package/dist/runtime/handlers/shared/describe-endpoint.mjs.map +1 -0
  300. package/dist/runtime/handlers/shared/intelligence-utils.cjs +24 -0
  301. package/dist/runtime/handlers/shared/intelligence-utils.cjs.map +1 -0
  302. package/dist/runtime/handlers/shared/intelligence-utils.mjs +23 -0
  303. package/dist/runtime/handlers/shared/intelligence-utils.mjs.map +1 -0
  304. package/dist/runtime/handlers/shared/json-response.cjs +14 -0
  305. package/dist/runtime/handlers/shared/json-response.cjs.map +1 -0
  306. package/dist/runtime/handlers/shared/json-response.mjs +12 -0
  307. package/dist/runtime/handlers/shared/json-response.mjs.map +1 -0
  308. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs +22 -0
  309. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs.map +1 -0
  310. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs +22 -0
  311. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs.map +1 -0
  312. package/dist/runtime/handlers/shared/memory-policy.cjs +78 -0
  313. package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -0
  314. package/dist/runtime/handlers/shared/memory-policy.mjs +77 -0
  315. package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -0
  316. package/dist/runtime/handlers/shared/platform-error.cjs +39 -0
  317. package/dist/runtime/handlers/shared/platform-error.cjs.map +1 -0
  318. package/dist/runtime/handlers/shared/platform-error.mjs +39 -0
  319. package/dist/runtime/handlers/shared/platform-error.mjs.map +1 -0
  320. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +50 -0
  321. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -0
  322. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +49 -0
  323. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -0
  324. package/dist/runtime/handlers/shared/sse-keep-alive.cjs +68 -0
  325. package/dist/runtime/handlers/shared/sse-keep-alive.cjs.map +1 -0
  326. package/dist/runtime/handlers/shared/sse-keep-alive.mjs +66 -0
  327. package/dist/runtime/handlers/shared/sse-keep-alive.mjs.map +1 -0
  328. package/dist/runtime/handlers/shared/sse-response.cjs +237 -0
  329. package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -0
  330. package/dist/runtime/handlers/shared/sse-response.mjs +236 -0
  331. package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -0
  332. package/dist/runtime/handlers/shared/thread-access.cjs +137 -0
  333. package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -0
  334. package/dist/runtime/handlers/shared/thread-access.d.cts +28 -0
  335. package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -0
  336. package/dist/runtime/handlers/shared/thread-access.d.mts +28 -0
  337. package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -0
  338. package/dist/runtime/handlers/shared/thread-access.mjs +132 -0
  339. package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -0
  340. package/dist/runtime/handlers/sse/connect.cjs +23 -0
  341. package/dist/runtime/handlers/sse/connect.cjs.map +1 -0
  342. package/dist/runtime/handlers/sse/connect.mjs +23 -0
  343. package/dist/runtime/handlers/sse/connect.mjs.map +1 -0
  344. package/dist/runtime/handlers/sse/run.cjs +44 -0
  345. package/dist/runtime/handlers/sse/run.cjs.map +1 -0
  346. package/dist/runtime/handlers/sse/run.mjs +44 -0
  347. package/dist/runtime/handlers/sse/run.mjs.map +1 -0
  348. package/dist/runtime/index.d.cts +29 -0
  349. package/dist/runtime/index.d.cts.map +1 -0
  350. package/dist/runtime/index.d.mts +29 -0
  351. package/dist/runtime/index.d.mts.map +1 -0
  352. package/dist/runtime/intelligence-platform/client.cjs +1338 -0
  353. package/dist/runtime/intelligence-platform/client.cjs.map +1 -0
  354. package/dist/runtime/intelligence-platform/client.d.cts +824 -0
  355. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -0
  356. package/dist/runtime/intelligence-platform/client.d.mts +824 -0
  357. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -0
  358. package/dist/runtime/intelligence-platform/client.mjs +1334 -0
  359. package/dist/runtime/intelligence-platform/client.mjs.map +1 -0
  360. package/dist/runtime/intelligence-platform/experimental.d.cts +26 -0
  361. package/dist/runtime/intelligence-platform/experimental.d.cts.map +1 -0
  362. package/dist/runtime/intelligence-platform/experimental.d.mts +26 -0
  363. package/dist/runtime/intelligence-platform/experimental.d.mts.map +1 -0
  364. package/dist/runtime/intelligence-platform/index.d.cts +3 -0
  365. package/dist/runtime/intelligence-platform/index.d.mts +3 -0
  366. package/dist/runtime/intelligence-platform/learned-skills.cjs +95 -0
  367. package/dist/runtime/intelligence-platform/learned-skills.cjs.map +1 -0
  368. package/dist/runtime/intelligence-platform/learned-skills.d.cts +43 -0
  369. package/dist/runtime/intelligence-platform/learned-skills.d.cts.map +1 -0
  370. package/dist/runtime/intelligence-platform/learned-skills.d.mts +43 -0
  371. package/dist/runtime/intelligence-platform/learned-skills.d.mts.map +1 -0
  372. package/dist/runtime/intelligence-platform/learned-skills.mjs +92 -0
  373. package/dist/runtime/intelligence-platform/learned-skills.mjs.map +1 -0
  374. package/dist/runtime/intelligence-platform/learning-management.cjs +203 -0
  375. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -0
  376. package/dist/runtime/intelligence-platform/learning-management.d.cts +111 -0
  377. package/dist/runtime/intelligence-platform/learning-management.d.cts.map +1 -0
  378. package/dist/runtime/intelligence-platform/learning-management.d.mts +111 -0
  379. package/dist/runtime/intelligence-platform/learning-management.d.mts.map +1 -0
  380. package/dist/runtime/intelligence-platform/learning-management.mjs +193 -0
  381. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -0
  382. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +131 -0
  383. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -0
  384. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +10 -0
  385. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -0
  386. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +10 -0
  387. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -0
  388. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +127 -0
  389. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -0
  390. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +65 -0
  391. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -0
  392. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts +47 -0
  393. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts.map +1 -0
  394. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts +47 -0
  395. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts.map +1 -0
  396. package/dist/runtime/intelligence-platform/skill-registry/config.mjs +65 -0
  397. package/dist/runtime/intelligence-platform/skill-registry/config.mjs.map +1 -0
  398. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs +10 -0
  399. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs.map +1 -0
  400. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts +7 -0
  401. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts.map +1 -0
  402. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts +7 -0
  403. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts.map +1 -0
  404. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs +10 -0
  405. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs.map +1 -0
  406. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +7 -0
  407. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +7 -0
  408. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +247 -0
  409. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -0
  410. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts +36 -0
  411. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -0
  412. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts +36 -0
  413. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -0
  414. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +246 -0
  415. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -0
  416. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs +41 -0
  417. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs.map +1 -0
  418. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts +12 -0
  419. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts.map +1 -0
  420. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts +12 -0
  421. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts.map +1 -0
  422. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs +38 -0
  423. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs.map +1 -0
  424. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs +92 -0
  425. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs.map +1 -0
  426. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts +27 -0
  427. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts.map +1 -0
  428. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts +27 -0
  429. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts.map +1 -0
  430. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs +91 -0
  431. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs.map +1 -0
  432. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +142 -0
  433. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -0
  434. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +141 -0
  435. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -0
  436. package/dist/runtime/intelligence-platform/trajectories.cjs +95 -0
  437. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -0
  438. package/dist/runtime/intelligence-platform/trajectories.d.cts +11 -0
  439. package/dist/runtime/intelligence-platform/trajectories.d.cts.map +1 -0
  440. package/dist/runtime/intelligence-platform/trajectories.d.mts +11 -0
  441. package/dist/runtime/intelligence-platform/trajectories.d.mts.map +1 -0
  442. package/dist/runtime/intelligence-platform/trajectories.mjs +91 -0
  443. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -0
  444. package/dist/runtime/node.d.cts +2 -0
  445. package/dist/runtime/node.d.mts +2 -0
  446. package/dist/runtime/runner/agent-runner.cjs +82 -0
  447. package/dist/runtime/runner/agent-runner.cjs.map +1 -0
  448. package/dist/runtime/runner/agent-runner.d.cts +151 -0
  449. package/dist/runtime/runner/agent-runner.d.cts.map +1 -0
  450. package/dist/runtime/runner/agent-runner.d.mts +151 -0
  451. package/dist/runtime/runner/agent-runner.d.mts.map +1 -0
  452. package/dist/runtime/runner/agent-runner.mjs +73 -0
  453. package/dist/runtime/runner/agent-runner.mjs.map +1 -0
  454. package/dist/runtime/runner/in-memory.cjs +741 -0
  455. package/dist/runtime/runner/in-memory.cjs.map +1 -0
  456. package/dist/runtime/runner/in-memory.d.cts +427 -0
  457. package/dist/runtime/runner/in-memory.d.cts.map +1 -0
  458. package/dist/runtime/runner/in-memory.d.mts +427 -0
  459. package/dist/runtime/runner/in-memory.d.mts.map +1 -0
  460. package/dist/runtime/runner/in-memory.mjs +734 -0
  461. package/dist/runtime/runner/in-memory.mjs.map +1 -0
  462. package/dist/runtime/runner/index.d.cts +5 -0
  463. package/dist/runtime/runner/index.d.mts +5 -0
  464. package/dist/runtime/runner/index.mjs +6 -0
  465. package/dist/runtime/runner/intelligence.cjs +617 -0
  466. package/dist/runtime/runner/intelligence.cjs.map +1 -0
  467. package/dist/runtime/runner/intelligence.d.cts +104 -0
  468. package/dist/runtime/runner/intelligence.d.cts.map +1 -0
  469. package/dist/runtime/runner/intelligence.d.mts +104 -0
  470. package/dist/runtime/runner/intelligence.d.mts.map +1 -0
  471. package/dist/runtime/runner/intelligence.mjs +616 -0
  472. package/dist/runtime/runner/intelligence.mjs.map +1 -0
  473. package/dist/runtime/telemetry/disclosure.cjs +25 -0
  474. package/dist/runtime/telemetry/disclosure.cjs.map +1 -0
  475. package/dist/runtime/telemetry/disclosure.mjs +24 -0
  476. package/dist/runtime/telemetry/disclosure.mjs.map +1 -0
  477. package/dist/runtime/telemetry/events.d.cts +66 -0
  478. package/dist/runtime/telemetry/events.d.cts.map +1 -0
  479. package/dist/runtime/telemetry/events.d.mts +66 -0
  480. package/dist/runtime/telemetry/events.d.mts.map +1 -0
  481. package/dist/runtime/telemetry/instance-created.cjs +34 -0
  482. package/dist/runtime/telemetry/instance-created.cjs.map +1 -0
  483. package/dist/runtime/telemetry/instance-created.mjs +34 -0
  484. package/dist/runtime/telemetry/instance-created.mjs.map +1 -0
  485. package/dist/runtime/telemetry/telemetry-client.cjs +108 -0
  486. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -0
  487. package/dist/runtime/telemetry/telemetry-client.d.cts +10 -0
  488. package/dist/runtime/telemetry/telemetry-client.d.cts.map +1 -0
  489. package/dist/runtime/telemetry/telemetry-client.d.mts +10 -0
  490. package/dist/runtime/telemetry/telemetry-client.d.mts.map +1 -0
  491. package/dist/runtime/telemetry/telemetry-client.mjs +107 -0
  492. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -0
  493. package/dist/runtime/telemetry/telemetry-identity.cjs +12 -0
  494. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -0
  495. package/dist/runtime/telemetry/telemetry-identity.mjs +11 -0
  496. package/dist/runtime/telemetry/telemetry-identity.mjs.map +1 -0
  497. package/dist/runtime/transcription-service/transcription-service.cjs +7 -0
  498. package/dist/runtime/transcription-service/transcription-service.cjs.map +1 -0
  499. package/dist/runtime/transcription-service/transcription-service.d.cts +14 -0
  500. package/dist/runtime/transcription-service/transcription-service.d.cts.map +1 -0
  501. package/dist/runtime/transcription-service/transcription-service.d.mts +14 -0
  502. package/dist/runtime/transcription-service/transcription-service.d.mts.map +1 -0
  503. package/dist/runtime/transcription-service/transcription-service.mjs +6 -0
  504. package/dist/runtime/transcription-service/transcription-service.mjs.map +1 -0
  505. package/package.json +104 -105
  506. package/.eslintrc.js +0 -7
  507. package/CHANGELOG.md +0 -2920
  508. package/__snapshots__/schema/schema.graphql +0 -371
  509. package/dist/index.d.ts +0 -1494
  510. package/dist/index.js +0 -5641
  511. package/dist/index.js.map +0 -1
  512. package/dist/index.mjs.map +0 -1
  513. package/dist/langgraph.d.ts +0 -284
  514. package/dist/langgraph.js +0 -211
  515. package/dist/langgraph.js.map +0 -1
  516. package/dist/langgraph.mjs +0 -206
  517. package/dist/langgraph.mjs.map +0 -1
  518. package/dist/v2/index.d.ts +0 -2
  519. package/dist/v2/index.js +0 -22
  520. package/dist/v2/index.js.map +0 -1
  521. package/dist/v2/index.mjs +0 -5
  522. package/dist/v2/index.mjs.map +0 -1
  523. package/jest.config.js +0 -10
  524. package/scripts/generate-gql-schema.ts +0 -13
  525. package/src/agents/langgraph/event-source.ts +0 -329
  526. package/src/agents/langgraph/events.ts +0 -377
  527. package/src/graphql/inputs/action.input.ts +0 -16
  528. package/src/graphql/inputs/agent-session.input.ts +0 -13
  529. package/src/graphql/inputs/agent-state.input.ts +0 -13
  530. package/src/graphql/inputs/cloud-guardrails.input.ts +0 -16
  531. package/src/graphql/inputs/cloud.input.ts +0 -8
  532. package/src/graphql/inputs/context-property.input.ts +0 -10
  533. package/src/graphql/inputs/copilot-context.input.ts +0 -10
  534. package/src/graphql/inputs/custom-property.input.ts +0 -15
  535. package/src/graphql/inputs/extensions.input.ts +0 -21
  536. package/src/graphql/inputs/forwarded-parameters.input.ts +0 -22
  537. package/src/graphql/inputs/frontend.input.ts +0 -14
  538. package/src/graphql/inputs/generate-copilot-response.input.ts +0 -59
  539. package/src/graphql/inputs/load-agent-state.input.ts +0 -10
  540. package/src/graphql/inputs/message.input.ts +0 -110
  541. package/src/graphql/inputs/meta-event.input.ts +0 -18
  542. package/src/graphql/message-conversion/agui-to-gql.test.ts +0 -1263
  543. package/src/graphql/message-conversion/agui-to-gql.ts +0 -333
  544. package/src/graphql/message-conversion/gql-to-agui.test.ts +0 -1580
  545. package/src/graphql/message-conversion/gql-to-agui.ts +0 -278
  546. package/src/graphql/message-conversion/index.ts +0 -2
  547. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +0 -526
  548. package/src/graphql/resolvers/copilot.resolver.ts +0 -708
  549. package/src/graphql/resolvers/state.resolver.ts +0 -27
  550. package/src/graphql/types/agents-response.type.ts +0 -19
  551. package/src/graphql/types/base/index.ts +0 -10
  552. package/src/graphql/types/converted/index.ts +0 -176
  553. package/src/graphql/types/copilot-response.type.ts +0 -138
  554. package/src/graphql/types/enums.ts +0 -38
  555. package/src/graphql/types/extensions-response.type.ts +0 -23
  556. package/src/graphql/types/guardrails-result.type.ts +0 -20
  557. package/src/graphql/types/load-agent-state-response.type.ts +0 -17
  558. package/src/graphql/types/message-status.type.ts +0 -42
  559. package/src/graphql/types/meta-events.type.ts +0 -71
  560. package/src/graphql/types/response-status.type.ts +0 -66
  561. package/src/index.ts +0 -4
  562. package/src/langgraph.ts +0 -1
  563. package/src/lib/cloud/index.ts +0 -4
  564. package/src/lib/error-messages.ts +0 -200
  565. package/src/lib/index.ts +0 -52
  566. package/src/lib/integrations/index.ts +0 -6
  567. package/src/lib/integrations/nest/index.ts +0 -14
  568. package/src/lib/integrations/nextjs/app-router.ts +0 -38
  569. package/src/lib/integrations/nextjs/pages-router.ts +0 -39
  570. package/src/lib/integrations/node-express/index.ts +0 -14
  571. package/src/lib/integrations/node-http/index.ts +0 -143
  572. package/src/lib/integrations/node-http/request-handler.ts +0 -111
  573. package/src/lib/integrations/shared.ts +0 -161
  574. package/src/lib/logger.ts +0 -28
  575. package/src/lib/observability.ts +0 -160
  576. package/src/lib/runtime/__tests__/copilot-runtime-error.test.ts +0 -169
  577. package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +0 -464
  578. package/src/lib/runtime/agent-integrations/langgraph/agent.ts +0 -209
  579. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +0 -34
  580. package/src/lib/runtime/agent-integrations/langgraph/index.ts +0 -2
  581. package/src/lib/runtime/copilot-runtime.ts +0 -710
  582. package/src/lib/runtime/mcp-tools-utils.ts +0 -254
  583. package/src/lib/runtime/retry-utils.ts +0 -96
  584. package/src/lib/runtime/telemetry-agent-runner.ts +0 -139
  585. package/src/lib/runtime/types.ts +0 -49
  586. package/src/lib/runtime/utils.ts +0 -87
  587. package/src/lib/streaming.ts +0 -202
  588. package/src/lib/telemetry-client.ts +0 -64
  589. package/src/service-adapters/anthropic/anthropic-adapter.ts +0 -452
  590. package/src/service-adapters/anthropic/utils.ts +0 -152
  591. package/src/service-adapters/bedrock/bedrock-adapter.ts +0 -73
  592. package/src/service-adapters/conversion.ts +0 -67
  593. package/src/service-adapters/empty/empty-adapter.ts +0 -38
  594. package/src/service-adapters/events.ts +0 -294
  595. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +0 -84
  596. package/src/service-adapters/google/google-genai-adapter.test.ts +0 -104
  597. package/src/service-adapters/google/google-genai-adapter.ts +0 -88
  598. package/src/service-adapters/groq/groq-adapter.ts +0 -203
  599. package/src/service-adapters/index.ts +0 -18
  600. package/src/service-adapters/langchain/langchain-adapter.ts +0 -111
  601. package/src/service-adapters/langchain/langserve.ts +0 -88
  602. package/src/service-adapters/langchain/types.ts +0 -14
  603. package/src/service-adapters/langchain/utils.ts +0 -313
  604. package/src/service-adapters/openai/openai-adapter.ts +0 -283
  605. package/src/service-adapters/openai/openai-assistant-adapter.ts +0 -344
  606. package/src/service-adapters/openai/utils.ts +0 -199
  607. package/src/service-adapters/service-adapter.ts +0 -41
  608. package/src/service-adapters/shared/error-utils.ts +0 -61
  609. package/src/service-adapters/shared/index.ts +0 -1
  610. package/src/service-adapters/unify/unify-adapter.ts +0 -151
  611. package/src/utils/failed-response-status-reasons.ts +0 -70
  612. package/src/utils/index.ts +0 -1
  613. package/src/v2/index.ts +0 -3
  614. package/tests/global.d.ts +0 -13
  615. package/tests/service-adapters/anthropic/allowlist-approach.test.ts +0 -226
  616. package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +0 -389
  617. package/tests/service-adapters/openai/allowlist-approach.test.ts +0 -238
  618. package/tests/service-adapters/openai/openai-adapter.test.ts +0 -301
  619. package/tests/setup.jest.ts +0 -21
  620. package/tests/tsconfig.json +0 -10
  621. package/tsconfig.json +0 -13
  622. package/tsup.config.ts +0 -20
  623. package/typedoc.json +0 -4
@@ -0,0 +1,33 @@
1
+ import { isDebugEventFeedEnabled } from "../core/debug-event-bus.mjs";
2
+
3
+ //#region src/runtime/handlers/handle-debug-events.ts
4
+ function handleDebugEvents({ runtime, request }) {
5
+ if (!isDebugEventFeedEnabled(runtime.debug)) return new Response("Not Found", { status: 404 });
6
+ if (!runtime.debugEventBus) return new Response("Debug event bus not available", { status: 503 });
7
+ const bus = runtime.debugEventBus;
8
+ const encoder = new TextEncoder();
9
+ const stream = new TransformStream();
10
+ const writer = stream.writable.getWriter();
11
+ writer.write(encoder.encode(": connected\n\n")).catch(() => {});
12
+ const unsubscribe = bus.subscribe((envelope) => {
13
+ if (request.signal.aborted) return;
14
+ const line = `data: ${JSON.stringify(envelope)}\n\n`;
15
+ writer.write(encoder.encode(line)).catch(() => {});
16
+ });
17
+ request.signal.addEventListener("abort", () => {
18
+ unsubscribe();
19
+ writer.close().catch(() => {});
20
+ });
21
+ return new Response(stream.readable, {
22
+ status: 200,
23
+ headers: {
24
+ "Content-Type": "text/event-stream",
25
+ "Cache-Control": "no-cache",
26
+ Connection: "keep-alive"
27
+ }
28
+ });
29
+ }
30
+
31
+ //#endregion
32
+ export { handleDebugEvents };
33
+ //# sourceMappingURL=handle-debug-events.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-debug-events.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-debug-events.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isDebugEventFeedEnabled } from \"../core/debug-event-bus\";\nimport type { DebugEventEnvelope } from \"@copilotkit/shared\";\n\ninterface HandleDebugEventsParams {\n runtime: CopilotRuntimeLike;\n request: Request;\n}\n\nexport function handleDebugEvents({\n runtime,\n request,\n}: HandleDebugEventsParams): Response {\n if (!isDebugEventFeedEnabled(runtime.debug)) {\n return new Response(\"Not Found\", { status: 404 });\n }\n\n if (!runtime.debugEventBus) {\n return new Response(\"Debug event bus not available\", { status: 503 });\n }\n\n const bus = runtime.debugEventBus;\n const encoder = new TextEncoder();\n const stream = new TransformStream();\n const writer = stream.writable.getWriter();\n\n // Send an SSE comment immediately to flush response headers to the client.\n // Without this, some frameworks buffer the response until actual data is written,\n // leaving the client stuck in \"connecting\" state.\n writer.write(encoder.encode(\": connected\\n\\n\")).catch(() => {});\n\n const unsubscribe = bus.subscribe((envelope: DebugEventEnvelope) => {\n if (request.signal.aborted) return;\n const line = `data: ${JSON.stringify(envelope)}\\n\\n`;\n writer.write(encoder.encode(line)).catch(() => {\n // Client disconnected, will be cleaned up by abort handler.\n });\n });\n\n request.signal.addEventListener(\"abort\", () => {\n unsubscribe();\n writer.close().catch(() => {});\n });\n\n return new Response(stream.readable, {\n status: 200,\n headers: {\n \"Content-Type\": \"text/event-stream\",\n \"Cache-Control\": \"no-cache\",\n Connection: \"keep-alive\",\n },\n });\n}\n"],"mappings":";;;AASA,SAAgB,kBAAkB,EAChC,SACA,WACoC;AACpC,KAAI,CAAC,wBAAwB,QAAQ,MAAM,CACzC,QAAO,IAAI,SAAS,aAAa,EAAE,QAAQ,KAAK,CAAC;AAGnD,KAAI,CAAC,QAAQ,cACX,QAAO,IAAI,SAAS,iCAAiC,EAAE,QAAQ,KAAK,CAAC;CAGvE,MAAM,MAAM,QAAQ;CACpB,MAAM,UAAU,IAAI,aAAa;CACjC,MAAM,SAAS,IAAI,iBAAiB;CACpC,MAAM,SAAS,OAAO,SAAS,WAAW;AAK1C,QAAO,MAAM,QAAQ,OAAO,kBAAkB,CAAC,CAAC,YAAY,GAAG;CAE/D,MAAM,cAAc,IAAI,WAAW,aAAiC;AAClE,MAAI,QAAQ,OAAO,QAAS;EAC5B,MAAM,OAAO,SAAS,KAAK,UAAU,SAAS,CAAC;AAC/C,SAAO,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,YAAY,GAE7C;GACF;AAEF,SAAQ,OAAO,iBAAiB,eAAe;AAC7C,eAAa;AACb,SAAO,OAAO,CAAC,YAAY,GAAG;GAC9B;AAEF,QAAO,IAAI,SAAS,OAAO,UAAU;EACnC,QAAQ;EACR,SAAS;GACP,gBAAgB;GAChB,iBAAiB;GACjB,YAAY;GACb;EACF,CAAC"}
@@ -0,0 +1,56 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_learning = require('../core/learning.cjs');
3
+ const require_client = require('../intelligence-platform/client.cjs');
4
+ const require_resolve_intelligence_user = require('./shared/resolve-intelligence-user.cjs');
5
+ const require_runtime$1 = require('../core/runtime.cjs');
6
+ let _copilotkit_shared = require("@copilotkit/shared");
7
+
8
+ //#region src/runtime/handlers/handle-inspector-learning.ts
9
+ const headers = {
10
+ "Cache-Control": "no-store, private",
11
+ "Content-Type": "application/json"
12
+ };
13
+ const errorResponse = (status, message) => new Response(JSON.stringify({ error: message }), {
14
+ status,
15
+ headers
16
+ });
17
+ const queryPage = (value) => value === null ? void 0 : Number(value);
18
+ /** Proxies a bounded Learning read through the runtime's server-held credential. */
19
+ async function handleInspectorLearning({ runtime, request }) {
20
+ if (!require_runtime$1.isIntelligenceRuntime(runtime) || !require_learning.hasLearningContainerConfiguration(runtime)) return errorResponse(404, "Not found");
21
+ const user = await require_resolve_intelligence_user.resolveIntelligenceUser({
22
+ runtime,
23
+ request
24
+ });
25
+ if (user instanceof Response) return user;
26
+ const url = new URL(request.url);
27
+ if ([...url.searchParams.keys()].some((key) => ![
28
+ "agentId",
29
+ "skillsPage",
30
+ "insightsPage"
31
+ ].includes(key))) return errorResponse(400, "Invalid Inspector Learning request");
32
+ const parsedRequest = (0, _copilotkit_shared.parseInspectorLearningRequestV1)({
33
+ agentId: url.searchParams.get("agentId") ?? void 0,
34
+ skillsPage: queryPage(url.searchParams.get("skillsPage")),
35
+ insightsPage: queryPage(url.searchParams.get("insightsPage"))
36
+ });
37
+ if (!parsedRequest) return errorResponse(400, "Invalid Inspector Learning request");
38
+ try {
39
+ const snapshot = (0, _copilotkit_shared.parseInspectorLearningSnapshotV1)(await runtime.intelligence.getInspectorLearning({
40
+ ...parsedRequest,
41
+ ...typeof runtime.learning?.containerId === "string" ? { runtimeContainerId: runtime.learning.containerId } : {}
42
+ }));
43
+ if (!snapshot) return errorResponse(502, "Invalid Inspector Learning response");
44
+ return new Response(JSON.stringify(snapshot), {
45
+ status: 200,
46
+ headers
47
+ });
48
+ } catch (error) {
49
+ if (error instanceof require_client.PlatformRequestError && error.status === 404) return errorResponse(404, "Not found");
50
+ return errorResponse(503, "Inspector Learning is temporarily unavailable");
51
+ }
52
+ }
53
+
54
+ //#endregion
55
+ exports.handleInspectorLearning = handleInspectorLearning;
56
+ //# sourceMappingURL=handle-inspector-learning.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-inspector-learning.cjs","names":["isIntelligenceRuntime","hasLearningContainerConfiguration","resolveIntelligenceUser","PlatformRequestError"],"sources":["../../../src/runtime/handlers/handle-inspector-learning.ts"],"sourcesContent":["import {\n parseInspectorLearningRequestV1,\n parseInspectorLearningSnapshotV1,\n} from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { hasLearningContainerConfiguration } from \"../core/learning\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport { PlatformRequestError } from \"../intelligence-platform/client\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\n\nconst headers = {\n \"Cache-Control\": \"no-store, private\",\n \"Content-Type\": \"application/json\",\n} as const;\n\nconst errorResponse = (status: number, message: string) =>\n new Response(JSON.stringify({ error: message }), { status, headers });\n\nconst queryPage = (value: string | null): number | undefined =>\n value === null ? undefined : Number(value);\n\n/** Proxies a bounded Learning read through the runtime's server-held credential. */\nexport async function handleInspectorLearning({\n runtime,\n request,\n}: {\n readonly runtime: CopilotRuntimeLike;\n readonly request: Request;\n}): Promise<Response> {\n if (\n !isIntelligenceRuntime(runtime) ||\n !hasLearningContainerConfiguration(runtime)\n ) {\n return errorResponse(404, \"Not found\");\n }\n const user = await resolveIntelligenceUser({ runtime, request });\n if (user instanceof Response) return user;\n const url = new URL(request.url);\n if (\n [...url.searchParams.keys()].some(\n (key) => ![\"agentId\", \"skillsPage\", \"insightsPage\"].includes(key),\n )\n ) {\n return errorResponse(400, \"Invalid Inspector Learning request\");\n }\n const parsedRequest = parseInspectorLearningRequestV1({\n agentId: url.searchParams.get(\"agentId\") ?? undefined,\n skillsPage: queryPage(url.searchParams.get(\"skillsPage\")),\n insightsPage: queryPage(url.searchParams.get(\"insightsPage\")),\n });\n if (!parsedRequest)\n return errorResponse(400, \"Invalid Inspector Learning request\");\n\n try {\n const snapshot = parseInspectorLearningSnapshotV1(\n await runtime.intelligence.getInspectorLearning({\n ...parsedRequest,\n ...(typeof runtime.learning?.containerId === \"string\"\n ? { runtimeContainerId: runtime.learning.containerId }\n : {}),\n }),\n );\n if (!snapshot)\n return errorResponse(502, \"Invalid Inspector Learning response\");\n return new Response(JSON.stringify(snapshot), { status: 200, headers });\n } catch (error) {\n if (error instanceof PlatformRequestError && error.status === 404) {\n return errorResponse(404, \"Not found\");\n }\n return errorResponse(503, \"Inspector Learning is temporarily unavailable\");\n }\n}\n"],"mappings":";;;;;;;;AAUA,MAAM,UAAU;CACd,iBAAiB;CACjB,gBAAgB;CACjB;AAED,MAAM,iBAAiB,QAAgB,YACrC,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,SAAS,CAAC,EAAE;CAAE;CAAQ;CAAS,CAAC;AAEvE,MAAM,aAAa,UACjB,UAAU,OAAO,SAAY,OAAO,MAAM;;AAG5C,eAAsB,wBAAwB,EAC5C,SACA,WAIoB;AACpB,KACE,CAACA,wCAAsB,QAAQ,IAC/B,CAACC,mDAAkC,QAAQ,CAE3C,QAAO,cAAc,KAAK,YAAY;CAExC,MAAM,OAAO,MAAMC,0DAAwB;EAAE;EAAS;EAAS,CAAC;AAChE,KAAI,gBAAgB,SAAU,QAAO;CACrC,MAAM,MAAM,IAAI,IAAI,QAAQ,IAAI;AAChC,KACE,CAAC,GAAG,IAAI,aAAa,MAAM,CAAC,CAAC,MAC1B,QAAQ,CAAC;EAAC;EAAW;EAAc;EAAe,CAAC,SAAS,IAAI,CAClE,CAED,QAAO,cAAc,KAAK,qCAAqC;CAEjE,MAAM,wEAAgD;EACpD,SAAS,IAAI,aAAa,IAAI,UAAU,IAAI;EAC5C,YAAY,UAAU,IAAI,aAAa,IAAI,aAAa,CAAC;EACzD,cAAc,UAAU,IAAI,aAAa,IAAI,eAAe,CAAC;EAC9D,CAAC;AACF,KAAI,CAAC,cACH,QAAO,cAAc,KAAK,qCAAqC;AAEjE,KAAI;EACF,MAAM,oEACJ,MAAM,QAAQ,aAAa,qBAAqB;GAC9C,GAAG;GACH,GAAI,OAAO,QAAQ,UAAU,gBAAgB,WACzC,EAAE,oBAAoB,QAAQ,SAAS,aAAa,GACpD,EAAE;GACP,CAAC,CACH;AACD,MAAI,CAAC,SACH,QAAO,cAAc,KAAK,sCAAsC;AAClE,SAAO,IAAI,SAAS,KAAK,UAAU,SAAS,EAAE;GAAE,QAAQ;GAAK;GAAS,CAAC;UAChE,OAAO;AACd,MAAI,iBAAiBC,uCAAwB,MAAM,WAAW,IAC5D,QAAO,cAAc,KAAK,YAAY;AAExC,SAAO,cAAc,KAAK,gDAAgD"}
@@ -0,0 +1,55 @@
1
+ import { hasLearningContainerConfiguration } from "../core/learning.mjs";
2
+ import { PlatformRequestError } from "../intelligence-platform/client.mjs";
3
+ import { resolveIntelligenceUser } from "./shared/resolve-intelligence-user.mjs";
4
+ import { isIntelligenceRuntime } from "../core/runtime.mjs";
5
+ import { parseInspectorLearningRequestV1, parseInspectorLearningSnapshotV1 } from "@copilotkit/shared";
6
+
7
+ //#region src/runtime/handlers/handle-inspector-learning.ts
8
+ const headers = {
9
+ "Cache-Control": "no-store, private",
10
+ "Content-Type": "application/json"
11
+ };
12
+ const errorResponse = (status, message) => new Response(JSON.stringify({ error: message }), {
13
+ status,
14
+ headers
15
+ });
16
+ const queryPage = (value) => value === null ? void 0 : Number(value);
17
+ /** Proxies a bounded Learning read through the runtime's server-held credential. */
18
+ async function handleInspectorLearning({ runtime, request }) {
19
+ if (!isIntelligenceRuntime(runtime) || !hasLearningContainerConfiguration(runtime)) return errorResponse(404, "Not found");
20
+ const user = await resolveIntelligenceUser({
21
+ runtime,
22
+ request
23
+ });
24
+ if (user instanceof Response) return user;
25
+ const url = new URL(request.url);
26
+ if ([...url.searchParams.keys()].some((key) => ![
27
+ "agentId",
28
+ "skillsPage",
29
+ "insightsPage"
30
+ ].includes(key))) return errorResponse(400, "Invalid Inspector Learning request");
31
+ const parsedRequest = parseInspectorLearningRequestV1({
32
+ agentId: url.searchParams.get("agentId") ?? void 0,
33
+ skillsPage: queryPage(url.searchParams.get("skillsPage")),
34
+ insightsPage: queryPage(url.searchParams.get("insightsPage"))
35
+ });
36
+ if (!parsedRequest) return errorResponse(400, "Invalid Inspector Learning request");
37
+ try {
38
+ const snapshot = parseInspectorLearningSnapshotV1(await runtime.intelligence.getInspectorLearning({
39
+ ...parsedRequest,
40
+ ...typeof runtime.learning?.containerId === "string" ? { runtimeContainerId: runtime.learning.containerId } : {}
41
+ }));
42
+ if (!snapshot) return errorResponse(502, "Invalid Inspector Learning response");
43
+ return new Response(JSON.stringify(snapshot), {
44
+ status: 200,
45
+ headers
46
+ });
47
+ } catch (error) {
48
+ if (error instanceof PlatformRequestError && error.status === 404) return errorResponse(404, "Not found");
49
+ return errorResponse(503, "Inspector Learning is temporarily unavailable");
50
+ }
51
+ }
52
+
53
+ //#endregion
54
+ export { handleInspectorLearning };
55
+ //# sourceMappingURL=handle-inspector-learning.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-inspector-learning.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-inspector-learning.ts"],"sourcesContent":["import {\n parseInspectorLearningRequestV1,\n parseInspectorLearningSnapshotV1,\n} from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { hasLearningContainerConfiguration } from \"../core/learning\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport { PlatformRequestError } from \"../intelligence-platform/client\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\n\nconst headers = {\n \"Cache-Control\": \"no-store, private\",\n \"Content-Type\": \"application/json\",\n} as const;\n\nconst errorResponse = (status: number, message: string) =>\n new Response(JSON.stringify({ error: message }), { status, headers });\n\nconst queryPage = (value: string | null): number | undefined =>\n value === null ? undefined : Number(value);\n\n/** Proxies a bounded Learning read through the runtime's server-held credential. */\nexport async function handleInspectorLearning({\n runtime,\n request,\n}: {\n readonly runtime: CopilotRuntimeLike;\n readonly request: Request;\n}): Promise<Response> {\n if (\n !isIntelligenceRuntime(runtime) ||\n !hasLearningContainerConfiguration(runtime)\n ) {\n return errorResponse(404, \"Not found\");\n }\n const user = await resolveIntelligenceUser({ runtime, request });\n if (user instanceof Response) return user;\n const url = new URL(request.url);\n if (\n [...url.searchParams.keys()].some(\n (key) => ![\"agentId\", \"skillsPage\", \"insightsPage\"].includes(key),\n )\n ) {\n return errorResponse(400, \"Invalid Inspector Learning request\");\n }\n const parsedRequest = parseInspectorLearningRequestV1({\n agentId: url.searchParams.get(\"agentId\") ?? undefined,\n skillsPage: queryPage(url.searchParams.get(\"skillsPage\")),\n insightsPage: queryPage(url.searchParams.get(\"insightsPage\")),\n });\n if (!parsedRequest)\n return errorResponse(400, \"Invalid Inspector Learning request\");\n\n try {\n const snapshot = parseInspectorLearningSnapshotV1(\n await runtime.intelligence.getInspectorLearning({\n ...parsedRequest,\n ...(typeof runtime.learning?.containerId === \"string\"\n ? { runtimeContainerId: runtime.learning.containerId }\n : {}),\n }),\n );\n if (!snapshot)\n return errorResponse(502, \"Invalid Inspector Learning response\");\n return new Response(JSON.stringify(snapshot), { status: 200, headers });\n } catch (error) {\n if (error instanceof PlatformRequestError && error.status === 404) {\n return errorResponse(404, \"Not found\");\n }\n return errorResponse(503, \"Inspector Learning is temporarily unavailable\");\n }\n}\n"],"mappings":";;;;;;;AAUA,MAAM,UAAU;CACd,iBAAiB;CACjB,gBAAgB;CACjB;AAED,MAAM,iBAAiB,QAAgB,YACrC,IAAI,SAAS,KAAK,UAAU,EAAE,OAAO,SAAS,CAAC,EAAE;CAAE;CAAQ;CAAS,CAAC;AAEvE,MAAM,aAAa,UACjB,UAAU,OAAO,SAAY,OAAO,MAAM;;AAG5C,eAAsB,wBAAwB,EAC5C,SACA,WAIoB;AACpB,KACE,CAAC,sBAAsB,QAAQ,IAC/B,CAAC,kCAAkC,QAAQ,CAE3C,QAAO,cAAc,KAAK,YAAY;CAExC,MAAM,OAAO,MAAM,wBAAwB;EAAE;EAAS;EAAS,CAAC;AAChE,KAAI,gBAAgB,SAAU,QAAO;CACrC,MAAM,MAAM,IAAI,IAAI,QAAQ,IAAI;AAChC,KACE,CAAC,GAAG,IAAI,aAAa,MAAM,CAAC,CAAC,MAC1B,QAAQ,CAAC;EAAC;EAAW;EAAc;EAAe,CAAC,SAAS,IAAI,CAClE,CAED,QAAO,cAAc,KAAK,qCAAqC;CAEjE,MAAM,gBAAgB,gCAAgC;EACpD,SAAS,IAAI,aAAa,IAAI,UAAU,IAAI;EAC5C,YAAY,UAAU,IAAI,aAAa,IAAI,aAAa,CAAC;EACzD,cAAc,UAAU,IAAI,aAAa,IAAI,eAAe,CAAC;EAC9D,CAAC;AACF,KAAI,CAAC,cACH,QAAO,cAAc,KAAK,qCAAqC;AAEjE,KAAI;EACF,MAAM,WAAW,iCACf,MAAM,QAAQ,aAAa,qBAAqB;GAC9C,GAAG;GACH,GAAI,OAAO,QAAQ,UAAU,gBAAgB,WACzC,EAAE,oBAAoB,QAAQ,SAAS,aAAa,GACpD,EAAE;GACP,CAAC,CACH;AACD,MAAI,CAAC,SACH,QAAO,cAAc,KAAK,sCAAsC;AAClE,SAAO,IAAI,SAAS,KAAK,UAAU,SAAS,EAAE;GAAE,QAAQ;GAAK;GAAS,CAAC;UAChE,OAAO;AACd,MAAI,iBAAiB,wBAAwB,MAAM,WAAW,IAC5D,QAAO,cAAc,KAAK,YAAY;AAExC,SAAO,cAAc,KAAK,gDAAgD"}
@@ -0,0 +1,36 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_runtime$1 = require('../core/runtime.cjs');
3
+ let _copilotkit_shared = require("@copilotkit/shared");
4
+
5
+ //#region src/runtime/handlers/handle-inspector-metadata.ts
6
+ const PRIVATE_NO_STORE_HEADERS = { "Cache-Control": "no-store, private" };
7
+ function emptyInspectorMetadataResponse() {
8
+ return new Response(null, {
9
+ status: 204,
10
+ headers: PRIVATE_NO_STORE_HEADERS
11
+ });
12
+ }
13
+ /**
14
+ * Returns trusted, sanitized Inspector metadata without exposing provider
15
+ * failures or forwarding any browser request credentials to Intelligence.
16
+ */
17
+ async function handleInspectorMetadata({ runtime }) {
18
+ if (!require_runtime$1.isIntelligenceRuntime(runtime)) return emptyInspectorMetadataResponse();
19
+ try {
20
+ const metadata = (0, _copilotkit_shared.parseInspectorMetadataV1)(await runtime.intelligence.getInspectorMetadata());
21
+ if (metadata === void 0) return emptyInspectorMetadataResponse();
22
+ return new Response(JSON.stringify(metadata), {
23
+ status: 200,
24
+ headers: {
25
+ ...PRIVATE_NO_STORE_HEADERS,
26
+ "Content-Type": "application/json"
27
+ }
28
+ });
29
+ } catch {
30
+ return emptyInspectorMetadataResponse();
31
+ }
32
+ }
33
+
34
+ //#endregion
35
+ exports.handleInspectorMetadata = handleInspectorMetadata;
36
+ //# sourceMappingURL=handle-inspector-metadata.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-inspector-metadata.cjs","names":["isIntelligenceRuntime"],"sources":["../../../src/runtime/handlers/handle-inspector-metadata.ts"],"sourcesContent":["import { parseInspectorMetadataV1 } from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\n\nconst PRIVATE_NO_STORE_HEADERS = {\n \"Cache-Control\": \"no-store, private\",\n} as const;\n\ninterface HandleInspectorMetadataParameters {\n runtime: CopilotRuntimeLike;\n request: Request;\n}\n\nfunction emptyInspectorMetadataResponse(): Response {\n return new Response(null, {\n status: 204,\n headers: PRIVATE_NO_STORE_HEADERS,\n });\n}\n\n/**\n * Returns trusted, sanitized Inspector metadata without exposing provider\n * failures or forwarding any browser request credentials to Intelligence.\n */\nexport async function handleInspectorMetadata({\n runtime,\n}: HandleInspectorMetadataParameters): Promise<Response> {\n if (!isIntelligenceRuntime(runtime)) {\n return emptyInspectorMetadataResponse();\n }\n\n try {\n const metadata = parseInspectorMetadataV1(\n await runtime.intelligence.getInspectorMetadata(),\n );\n if (metadata === undefined) {\n return emptyInspectorMetadataResponse();\n }\n\n return new Response(JSON.stringify(metadata), {\n status: 200,\n headers: {\n ...PRIVATE_NO_STORE_HEADERS,\n \"Content-Type\": \"application/json\",\n },\n });\n } catch {\n return emptyInspectorMetadataResponse();\n }\n}\n"],"mappings":";;;;;AAIA,MAAM,2BAA2B,EAC/B,iBAAiB,qBAClB;AAOD,SAAS,iCAA2C;AAClD,QAAO,IAAI,SAAS,MAAM;EACxB,QAAQ;EACR,SAAS;EACV,CAAC;;;;;;AAOJ,eAAsB,wBAAwB,EAC5C,WACuD;AACvD,KAAI,CAACA,wCAAsB,QAAQ,CACjC,QAAO,gCAAgC;AAGzC,KAAI;EACF,MAAM,4DACJ,MAAM,QAAQ,aAAa,sBAAsB,CAClD;AACD,MAAI,aAAa,OACf,QAAO,gCAAgC;AAGzC,SAAO,IAAI,SAAS,KAAK,UAAU,SAAS,EAAE;GAC5C,QAAQ;GACR,SAAS;IACP,GAAG;IACH,gBAAgB;IACjB;GACF,CAAC;SACI;AACN,SAAO,gCAAgC"}
@@ -0,0 +1,35 @@
1
+ import { isIntelligenceRuntime } from "../core/runtime.mjs";
2
+ import { parseInspectorMetadataV1 } from "@copilotkit/shared";
3
+
4
+ //#region src/runtime/handlers/handle-inspector-metadata.ts
5
+ const PRIVATE_NO_STORE_HEADERS = { "Cache-Control": "no-store, private" };
6
+ function emptyInspectorMetadataResponse() {
7
+ return new Response(null, {
8
+ status: 204,
9
+ headers: PRIVATE_NO_STORE_HEADERS
10
+ });
11
+ }
12
+ /**
13
+ * Returns trusted, sanitized Inspector metadata without exposing provider
14
+ * failures or forwarding any browser request credentials to Intelligence.
15
+ */
16
+ async function handleInspectorMetadata({ runtime }) {
17
+ if (!isIntelligenceRuntime(runtime)) return emptyInspectorMetadataResponse();
18
+ try {
19
+ const metadata = parseInspectorMetadataV1(await runtime.intelligence.getInspectorMetadata());
20
+ if (metadata === void 0) return emptyInspectorMetadataResponse();
21
+ return new Response(JSON.stringify(metadata), {
22
+ status: 200,
23
+ headers: {
24
+ ...PRIVATE_NO_STORE_HEADERS,
25
+ "Content-Type": "application/json"
26
+ }
27
+ });
28
+ } catch {
29
+ return emptyInspectorMetadataResponse();
30
+ }
31
+ }
32
+
33
+ //#endregion
34
+ export { handleInspectorMetadata };
35
+ //# sourceMappingURL=handle-inspector-metadata.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-inspector-metadata.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-inspector-metadata.ts"],"sourcesContent":["import { parseInspectorMetadataV1 } from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\n\nconst PRIVATE_NO_STORE_HEADERS = {\n \"Cache-Control\": \"no-store, private\",\n} as const;\n\ninterface HandleInspectorMetadataParameters {\n runtime: CopilotRuntimeLike;\n request: Request;\n}\n\nfunction emptyInspectorMetadataResponse(): Response {\n return new Response(null, {\n status: 204,\n headers: PRIVATE_NO_STORE_HEADERS,\n });\n}\n\n/**\n * Returns trusted, sanitized Inspector metadata without exposing provider\n * failures or forwarding any browser request credentials to Intelligence.\n */\nexport async function handleInspectorMetadata({\n runtime,\n}: HandleInspectorMetadataParameters): Promise<Response> {\n if (!isIntelligenceRuntime(runtime)) {\n return emptyInspectorMetadataResponse();\n }\n\n try {\n const metadata = parseInspectorMetadataV1(\n await runtime.intelligence.getInspectorMetadata(),\n );\n if (metadata === undefined) {\n return emptyInspectorMetadataResponse();\n }\n\n return new Response(JSON.stringify(metadata), {\n status: 200,\n headers: {\n ...PRIVATE_NO_STORE_HEADERS,\n \"Content-Type\": \"application/json\",\n },\n });\n } catch {\n return emptyInspectorMetadataResponse();\n }\n}\n"],"mappings":";;;;AAIA,MAAM,2BAA2B,EAC/B,iBAAiB,qBAClB;AAOD,SAAS,iCAA2C;AAClD,QAAO,IAAI,SAAS,MAAM;EACxB,QAAQ;EACR,SAAS;EACV,CAAC;;;;;;AAOJ,eAAsB,wBAAwB,EAC5C,WACuD;AACvD,KAAI,CAAC,sBAAsB,QAAQ,CACjC,QAAO,gCAAgC;AAGzC,KAAI;EACF,MAAM,WAAW,yBACf,MAAM,QAAQ,aAAa,sBAAsB,CAClD;AACD,MAAI,aAAa,OACf,QAAO,gCAAgC;AAGzC,SAAO,IAAI,SAAS,KAAK,UAAU,SAAS,EAAE;GAC5C,QAAQ;GACR,SAAS;IACP,GAAG;IACH,gBAAgB;IACjB;GACF,CAAC;SACI;AACN,SAAO,gCAAgC"}
@@ -0,0 +1,111 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_agent_runner = require('../runner/agent-runner.cjs');
3
+ const require_thread_access = require('./shared/thread-access.cjs');
4
+ const require_telemetry_client = require('../telemetry/telemetry-client.cjs');
5
+ const require_runtime_error_reporter = require('../core/runtime-error-reporter.cjs');
6
+ const require_runtime$1 = require('../core/runtime.cjs');
7
+ const require_cloud_telemetry = require('./shared/cloud-telemetry.cjs');
8
+ const require_agent_utils = require('./shared/agent-utils.cjs');
9
+ const require_run = require('./intelligence/run.cjs');
10
+ const require_run$1 = require('./sse/run.cjs');
11
+ let _copilotkit_shared = require("@copilotkit/shared");
12
+
13
+ //#region src/runtime/handlers/handle-run.ts
14
+ async function handleRunAgent({ runtime, request, agentId }) {
15
+ const startTime = Date.now();
16
+ const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
17
+ (runtime.telemetry ?? require_telemetry_client.default).capture("oss.runtime.copilot_request_created", {
18
+ "cloud.guardrails.enabled": await require_cloud_telemetry.readGuardrailsEnabled(request),
19
+ requestType: "run",
20
+ "cloud.api_key_provided": !!publicApiKey,
21
+ ...publicApiKey ? { "cloud.public_api_key": publicApiKey } : {}
22
+ });
23
+ try {
24
+ const agent = await require_agent_utils.cloneAgentForRequest(runtime, agentId, request);
25
+ if (agent instanceof Response) return agent;
26
+ agent.agentId = agentId;
27
+ const input = await require_agent_utils.parseRunRequest(request.clone());
28
+ if (input instanceof Response) return input;
29
+ let ownerId;
30
+ if (!require_runtime$1.isIntelligenceRuntime(runtime)) {
31
+ const owner = await require_thread_access.resolveLocalThreadOwner({
32
+ runtime,
33
+ request,
34
+ operation: "run"
35
+ });
36
+ if (owner instanceof Response) return owner;
37
+ if (require_agent_runner.enforcesThreadOwnership(runtime.runner) && !await runtime.runner.isThreadAccessible(input.threadId, { ownerId: owner })) return require_thread_access.threadAccessDeniedResponse();
38
+ ownerId = owner;
39
+ }
40
+ const providerA2UIHasCatalog = input.forwardedProps?.a2uiCatalogAvailable === true;
41
+ const providerGenerativeUITransport = (0, _copilotkit_shared.readCopilotKitUIEnvelope)(input.forwardedProps)?.metadata.extensions.copilotkit_transport;
42
+ require_agent_utils.configureAgentForRequest({
43
+ runtime,
44
+ request,
45
+ agentId,
46
+ agent,
47
+ providerA2UIHasCatalog,
48
+ providerGenerativeUITransport,
49
+ isMcpProxyRequest: Object.prototype.hasOwnProperty.call(input.forwardedProps ?? {}, "__proxiedMCPRequest")
50
+ });
51
+ const memoryResponse = await require_agent_utils.attachIntelligenceEnterpriseLearning({
52
+ runtime,
53
+ request,
54
+ agent
55
+ });
56
+ if (memoryResponse instanceof Response) return memoryResponse;
57
+ agent.setMessages(input.messages);
58
+ agent.setState(input.state);
59
+ agent.threadId = input.threadId;
60
+ if (runtime.debug?.lifecycle && runtime.debugLogger) runtime.debugLogger.debug({
61
+ agentName: agentId,
62
+ threadId: input.threadId
63
+ }, "Agent run started");
64
+ if (require_runtime$1.isIntelligenceRuntime(runtime)) return require_run.handleIntelligenceRun({
65
+ runtime,
66
+ request,
67
+ agentId,
68
+ agent,
69
+ input,
70
+ startTime
71
+ });
72
+ return require_run$1.handleSseRun({
73
+ runtime,
74
+ request,
75
+ agent,
76
+ input,
77
+ agentId,
78
+ debug: runtime.debug,
79
+ logger: runtime.debugLogger,
80
+ startTime,
81
+ ownerId
82
+ });
83
+ } catch (error) {
84
+ require_runtime_error_reporter.getRuntimeErrorReporter(runtime)?.report({
85
+ request,
86
+ error,
87
+ operation: "agent.run",
88
+ agentId,
89
+ phase: "common",
90
+ startTime
91
+ });
92
+ console.error("Error running agent:", error);
93
+ console.error("Error stack:", error instanceof Error ? error.stack : "No stack trace");
94
+ console.error("Error details:", {
95
+ name: error instanceof Error ? error.name : "Unknown",
96
+ message: error instanceof Error ? error.message : String(error),
97
+ cause: error instanceof Error ? error.cause : void 0
98
+ });
99
+ return new Response(JSON.stringify({
100
+ error: "Failed to run agent",
101
+ message: error instanceof Error ? error.message : "Unknown error"
102
+ }), {
103
+ status: 500,
104
+ headers: { "Content-Type": "application/json" }
105
+ });
106
+ }
107
+ }
108
+
109
+ //#endregion
110
+ exports.handleRunAgent = handleRunAgent;
111
+ //# sourceMappingURL=handle-run.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-run.cjs","names":["telemetry","readGuardrailsEnabled","cloneAgentForRequest","parseRunRequest","isIntelligenceRuntime","resolveLocalThreadOwner","enforcesThreadOwnership","threadAccessDeniedResponse","attachIntelligenceEnterpriseLearning","handleIntelligenceRun","handleSseRun"],"sources":["../../../src/runtime/handlers/handle-run.ts"],"sourcesContent":["import { readCopilotKitUIEnvelope } from \"@copilotkit/shared\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport { telemetry } from \"../telemetry\";\nimport { readGuardrailsEnabled } from \"./shared/cloud-telemetry\";\nimport type { RunAgentParameters } from \"./shared/agent-utils\";\nimport {\n attachIntelligenceEnterpriseLearning,\n cloneAgentForRequest,\n configureAgentForRequest,\n parseRunRequest,\n} from \"./shared/agent-utils\";\nimport { handleIntelligenceRun } from \"./intelligence/run\";\nimport { handleSseRun } from \"./sse/run\";\nimport { getRuntimeErrorReporter } from \"../core/runtime-error-reporter\";\nimport { enforcesThreadOwnership } from \"../runner/agent-runner\";\nimport {\n resolveLocalThreadOwner,\n threadAccessDeniedResponse,\n} from \"./shared/thread-access\";\n\nexport async function handleRunAgent({\n runtime,\n request,\n agentId,\n}: RunAgentParameters) {\n const startTime = Date.now();\n const publicApiKey = request.headers.get(\"x-copilotcloud-public-api-key\");\n (runtime.telemetry ?? telemetry).capture(\n \"oss.runtime.copilot_request_created\",\n {\n \"cloud.guardrails.enabled\": await readGuardrailsEnabled(request),\n requestType: \"run\",\n \"cloud.api_key_provided\": !!publicApiKey,\n ...(publicApiKey ? { \"cloud.public_api_key\": publicApiKey } : {}),\n },\n );\n\n try {\n const agent = await cloneAgentForRequest(runtime, agentId, request);\n if (agent instanceof Response) {\n return agent;\n }\n\n // Ensure the clone carries the registry key so InMemoryAgentRunner can\n // tag historic runs with the correct agentId for filtering.\n agent.agentId = agentId;\n\n // Parse the body before configuring middleware: middleware configuration\n // needs the A2UI catalog signal the React provider forwards (see\n // `a2uiCatalogAvailable` below). Middleware is applied to the agent here;\n // the run itself is kicked off later, so this is safe. The body is read\n // from a clone, so `identifyUser` can still read the original request.\n const input = await parseRunRequest(request.clone());\n if (input instanceof Response) {\n return input;\n }\n\n // A thread belongs to the identity of its first run. Running needs no\n // configured identity (anonymous runs keep working), but nobody may add to\n // a thread that another identity owns.\n let ownerId: string | undefined;\n if (!isIntelligenceRuntime(runtime)) {\n const owner = await resolveLocalThreadOwner({\n runtime,\n request,\n operation: \"run\",\n });\n if (owner instanceof Response) return owner;\n if (\n enforcesThreadOwnership(runtime.runner) &&\n !(await runtime.runner.isThreadAccessible(input.threadId, {\n ownerId: owner,\n }))\n ) {\n return threadAccessDeniedResponse();\n }\n ownerId = owner;\n }\n\n // `<CopilotKit a2ui={{ catalog }}>` forwards this flag on every run. Its\n // presence alone is enough to turn A2UI on end-to-end — no runtime-side\n // `a2ui` config required.\n const providerA2UIHasCatalog =\n (input.forwardedProps as Record<string, unknown> | undefined)\n ?.a2uiCatalogAvailable === true;\n // The generative UI envelope (`forwardedProps.copilotkit.ui`) picks the\n // transport of this run.\n const providerGenerativeUITransport = readCopilotKitUIEnvelope(\n input.forwardedProps,\n )?.metadata.extensions.copilotkit_transport;\n\n configureAgentForRequest({\n runtime,\n request,\n agentId,\n agent,\n providerA2UIHasCatalog,\n providerGenerativeUITransport,\n isMcpProxyRequest: Object.prototype.hasOwnProperty.call(\n input.forwardedProps ?? {},\n \"__proxiedMCPRequest\",\n ),\n });\n const memoryResponse = await attachIntelligenceEnterpriseLearning({\n runtime,\n request,\n agent,\n });\n if (memoryResponse instanceof Response) return memoryResponse;\n\n agent.setMessages(input.messages);\n agent.setState(input.state);\n agent.threadId = input.threadId;\n\n if (runtime.debug?.lifecycle && runtime.debugLogger) {\n runtime.debugLogger.debug(\n { agentName: agentId, threadId: input.threadId },\n \"Agent run started\",\n );\n }\n\n if (isIntelligenceRuntime(runtime)) {\n return handleIntelligenceRun({\n runtime,\n request,\n agentId,\n agent,\n input,\n startTime,\n });\n }\n\n return handleSseRun({\n runtime,\n request,\n agent,\n input,\n agentId,\n debug: runtime.debug,\n logger: runtime.debugLogger,\n startTime,\n ownerId,\n });\n } catch (error) {\n getRuntimeErrorReporter(runtime)?.report({\n request,\n error,\n operation: \"agent.run\",\n agentId,\n phase: \"common\",\n startTime,\n });\n console.error(\"Error running agent:\", error);\n console.error(\n \"Error stack:\",\n error instanceof Error ? error.stack : \"No stack trace\",\n );\n console.error(\"Error details:\", {\n name: error instanceof Error ? error.name : \"Unknown\",\n message: error instanceof Error ? error.message : String(error),\n cause: error instanceof Error ? error.cause : undefined,\n });\n\n return new Response(\n JSON.stringify({\n error: \"Failed to run agent\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n }),\n {\n status: 500,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;;AAoBA,eAAsB,eAAe,EACnC,SACA,SACA,WACqB;CACrB,MAAM,YAAY,KAAK,KAAK;CAC5B,MAAM,eAAe,QAAQ,QAAQ,IAAI,gCAAgC;AACzE,EAAC,QAAQ,aAAaA,kCAAW,QAC/B,uCACA;EACE,4BAA4B,MAAMC,8CAAsB,QAAQ;EAChE,aAAa;EACb,0BAA0B,CAAC,CAAC;EAC5B,GAAI,eAAe,EAAE,wBAAwB,cAAc,GAAG,EAAE;EACjE,CACF;AAED,KAAI;EACF,MAAM,QAAQ,MAAMC,yCAAqB,SAAS,SAAS,QAAQ;AACnE,MAAI,iBAAiB,SACnB,QAAO;AAKT,QAAM,UAAU;EAOhB,MAAM,QAAQ,MAAMC,oCAAgB,QAAQ,OAAO,CAAC;AACpD,MAAI,iBAAiB,SACnB,QAAO;EAMT,IAAI;AACJ,MAAI,CAACC,wCAAsB,QAAQ,EAAE;GACnC,MAAM,QAAQ,MAAMC,8CAAwB;IAC1C;IACA;IACA,WAAW;IACZ,CAAC;AACF,OAAI,iBAAiB,SAAU,QAAO;AACtC,OACEC,6CAAwB,QAAQ,OAAO,IACvC,CAAE,MAAM,QAAQ,OAAO,mBAAmB,MAAM,UAAU,EACxD,SAAS,OACV,CAAC,CAEF,QAAOC,kDAA4B;AAErC,aAAU;;EAMZ,MAAM,yBACH,MAAM,gBACH,yBAAyB;EAG/B,MAAM,iFACJ,MAAM,eACP,EAAE,SAAS,WAAW;AAEvB,+CAAyB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA,mBAAmB,OAAO,UAAU,eAAe,KACjD,MAAM,kBAAkB,EAAE,EAC1B,sBACD;GACF,CAAC;EACF,MAAM,iBAAiB,MAAMC,yDAAqC;GAChE;GACA;GACA;GACD,CAAC;AACF,MAAI,0BAA0B,SAAU,QAAO;AAE/C,QAAM,YAAY,MAAM,SAAS;AACjC,QAAM,SAAS,MAAM,MAAM;AAC3B,QAAM,WAAW,MAAM;AAEvB,MAAI,QAAQ,OAAO,aAAa,QAAQ,YACtC,SAAQ,YAAY,MAClB;GAAE,WAAW;GAAS,UAAU,MAAM;GAAU,EAChD,oBACD;AAGH,MAAIJ,wCAAsB,QAAQ,CAChC,QAAOK,kCAAsB;GAC3B;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;AAGJ,SAAOC,2BAAa;GAClB;GACA;GACA;GACA;GACA;GACA,OAAO,QAAQ;GACf,QAAQ,QAAQ;GAChB;GACA;GACD,CAAC;UACK,OAAO;AACd,yDAAwB,QAAQ,EAAE,OAAO;GACvC;GACA;GACA,WAAW;GACX;GACA,OAAO;GACP;GACD,CAAC;AACF,UAAQ,MAAM,wBAAwB,MAAM;AAC5C,UAAQ,MACN,gBACA,iBAAiB,QAAQ,MAAM,QAAQ,iBACxC;AACD,UAAQ,MAAM,kBAAkB;GAC9B,MAAM,iBAAiB,QAAQ,MAAM,OAAO;GAC5C,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GAC/D,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;GAC/C,CAAC;AAEF,SAAO,IAAI,SACT,KAAK,UAAU;GACb,OAAO;GACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU;GACnD,CAAC,EACF;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CACF"}
@@ -0,0 +1,110 @@
1
+ import { enforcesThreadOwnership } from "../runner/agent-runner.mjs";
2
+ import { resolveLocalThreadOwner, threadAccessDeniedResponse } from "./shared/thread-access.mjs";
3
+ import telemetry from "../telemetry/telemetry-client.mjs";
4
+ import { getRuntimeErrorReporter } from "../core/runtime-error-reporter.mjs";
5
+ import { isIntelligenceRuntime } from "../core/runtime.mjs";
6
+ import { readGuardrailsEnabled } from "./shared/cloud-telemetry.mjs";
7
+ import { attachIntelligenceEnterpriseLearning, cloneAgentForRequest, configureAgentForRequest, parseRunRequest } from "./shared/agent-utils.mjs";
8
+ import { handleIntelligenceRun } from "./intelligence/run.mjs";
9
+ import { handleSseRun } from "./sse/run.mjs";
10
+ import { readCopilotKitUIEnvelope } from "@copilotkit/shared";
11
+
12
+ //#region src/runtime/handlers/handle-run.ts
13
+ async function handleRunAgent({ runtime, request, agentId }) {
14
+ const startTime = Date.now();
15
+ const publicApiKey = request.headers.get("x-copilotcloud-public-api-key");
16
+ (runtime.telemetry ?? telemetry).capture("oss.runtime.copilot_request_created", {
17
+ "cloud.guardrails.enabled": await readGuardrailsEnabled(request),
18
+ requestType: "run",
19
+ "cloud.api_key_provided": !!publicApiKey,
20
+ ...publicApiKey ? { "cloud.public_api_key": publicApiKey } : {}
21
+ });
22
+ try {
23
+ const agent = await cloneAgentForRequest(runtime, agentId, request);
24
+ if (agent instanceof Response) return agent;
25
+ agent.agentId = agentId;
26
+ const input = await parseRunRequest(request.clone());
27
+ if (input instanceof Response) return input;
28
+ let ownerId;
29
+ if (!isIntelligenceRuntime(runtime)) {
30
+ const owner = await resolveLocalThreadOwner({
31
+ runtime,
32
+ request,
33
+ operation: "run"
34
+ });
35
+ if (owner instanceof Response) return owner;
36
+ if (enforcesThreadOwnership(runtime.runner) && !await runtime.runner.isThreadAccessible(input.threadId, { ownerId: owner })) return threadAccessDeniedResponse();
37
+ ownerId = owner;
38
+ }
39
+ const providerA2UIHasCatalog = input.forwardedProps?.a2uiCatalogAvailable === true;
40
+ const providerGenerativeUITransport = readCopilotKitUIEnvelope(input.forwardedProps)?.metadata.extensions.copilotkit_transport;
41
+ configureAgentForRequest({
42
+ runtime,
43
+ request,
44
+ agentId,
45
+ agent,
46
+ providerA2UIHasCatalog,
47
+ providerGenerativeUITransport,
48
+ isMcpProxyRequest: Object.prototype.hasOwnProperty.call(input.forwardedProps ?? {}, "__proxiedMCPRequest")
49
+ });
50
+ const memoryResponse = await attachIntelligenceEnterpriseLearning({
51
+ runtime,
52
+ request,
53
+ agent
54
+ });
55
+ if (memoryResponse instanceof Response) return memoryResponse;
56
+ agent.setMessages(input.messages);
57
+ agent.setState(input.state);
58
+ agent.threadId = input.threadId;
59
+ if (runtime.debug?.lifecycle && runtime.debugLogger) runtime.debugLogger.debug({
60
+ agentName: agentId,
61
+ threadId: input.threadId
62
+ }, "Agent run started");
63
+ if (isIntelligenceRuntime(runtime)) return handleIntelligenceRun({
64
+ runtime,
65
+ request,
66
+ agentId,
67
+ agent,
68
+ input,
69
+ startTime
70
+ });
71
+ return handleSseRun({
72
+ runtime,
73
+ request,
74
+ agent,
75
+ input,
76
+ agentId,
77
+ debug: runtime.debug,
78
+ logger: runtime.debugLogger,
79
+ startTime,
80
+ ownerId
81
+ });
82
+ } catch (error) {
83
+ getRuntimeErrorReporter(runtime)?.report({
84
+ request,
85
+ error,
86
+ operation: "agent.run",
87
+ agentId,
88
+ phase: "common",
89
+ startTime
90
+ });
91
+ console.error("Error running agent:", error);
92
+ console.error("Error stack:", error instanceof Error ? error.stack : "No stack trace");
93
+ console.error("Error details:", {
94
+ name: error instanceof Error ? error.name : "Unknown",
95
+ message: error instanceof Error ? error.message : String(error),
96
+ cause: error instanceof Error ? error.cause : void 0
97
+ });
98
+ return new Response(JSON.stringify({
99
+ error: "Failed to run agent",
100
+ message: error instanceof Error ? error.message : "Unknown error"
101
+ }), {
102
+ status: 500,
103
+ headers: { "Content-Type": "application/json" }
104
+ });
105
+ }
106
+ }
107
+
108
+ //#endregion
109
+ export { handleRunAgent };
110
+ //# sourceMappingURL=handle-run.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"handle-run.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-run.ts"],"sourcesContent":["import { readCopilotKitUIEnvelope } from \"@copilotkit/shared\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport { telemetry } from \"../telemetry\";\nimport { readGuardrailsEnabled } from \"./shared/cloud-telemetry\";\nimport type { RunAgentParameters } from \"./shared/agent-utils\";\nimport {\n attachIntelligenceEnterpriseLearning,\n cloneAgentForRequest,\n configureAgentForRequest,\n parseRunRequest,\n} from \"./shared/agent-utils\";\nimport { handleIntelligenceRun } from \"./intelligence/run\";\nimport { handleSseRun } from \"./sse/run\";\nimport { getRuntimeErrorReporter } from \"../core/runtime-error-reporter\";\nimport { enforcesThreadOwnership } from \"../runner/agent-runner\";\nimport {\n resolveLocalThreadOwner,\n threadAccessDeniedResponse,\n} from \"./shared/thread-access\";\n\nexport async function handleRunAgent({\n runtime,\n request,\n agentId,\n}: RunAgentParameters) {\n const startTime = Date.now();\n const publicApiKey = request.headers.get(\"x-copilotcloud-public-api-key\");\n (runtime.telemetry ?? telemetry).capture(\n \"oss.runtime.copilot_request_created\",\n {\n \"cloud.guardrails.enabled\": await readGuardrailsEnabled(request),\n requestType: \"run\",\n \"cloud.api_key_provided\": !!publicApiKey,\n ...(publicApiKey ? { \"cloud.public_api_key\": publicApiKey } : {}),\n },\n );\n\n try {\n const agent = await cloneAgentForRequest(runtime, agentId, request);\n if (agent instanceof Response) {\n return agent;\n }\n\n // Ensure the clone carries the registry key so InMemoryAgentRunner can\n // tag historic runs with the correct agentId for filtering.\n agent.agentId = agentId;\n\n // Parse the body before configuring middleware: middleware configuration\n // needs the A2UI catalog signal the React provider forwards (see\n // `a2uiCatalogAvailable` below). Middleware is applied to the agent here;\n // the run itself is kicked off later, so this is safe. The body is read\n // from a clone, so `identifyUser` can still read the original request.\n const input = await parseRunRequest(request.clone());\n if (input instanceof Response) {\n return input;\n }\n\n // A thread belongs to the identity of its first run. Running needs no\n // configured identity (anonymous runs keep working), but nobody may add to\n // a thread that another identity owns.\n let ownerId: string | undefined;\n if (!isIntelligenceRuntime(runtime)) {\n const owner = await resolveLocalThreadOwner({\n runtime,\n request,\n operation: \"run\",\n });\n if (owner instanceof Response) return owner;\n if (\n enforcesThreadOwnership(runtime.runner) &&\n !(await runtime.runner.isThreadAccessible(input.threadId, {\n ownerId: owner,\n }))\n ) {\n return threadAccessDeniedResponse();\n }\n ownerId = owner;\n }\n\n // `<CopilotKit a2ui={{ catalog }}>` forwards this flag on every run. Its\n // presence alone is enough to turn A2UI on end-to-end — no runtime-side\n // `a2ui` config required.\n const providerA2UIHasCatalog =\n (input.forwardedProps as Record<string, unknown> | undefined)\n ?.a2uiCatalogAvailable === true;\n // The generative UI envelope (`forwardedProps.copilotkit.ui`) picks the\n // transport of this run.\n const providerGenerativeUITransport = readCopilotKitUIEnvelope(\n input.forwardedProps,\n )?.metadata.extensions.copilotkit_transport;\n\n configureAgentForRequest({\n runtime,\n request,\n agentId,\n agent,\n providerA2UIHasCatalog,\n providerGenerativeUITransport,\n isMcpProxyRequest: Object.prototype.hasOwnProperty.call(\n input.forwardedProps ?? {},\n \"__proxiedMCPRequest\",\n ),\n });\n const memoryResponse = await attachIntelligenceEnterpriseLearning({\n runtime,\n request,\n agent,\n });\n if (memoryResponse instanceof Response) return memoryResponse;\n\n agent.setMessages(input.messages);\n agent.setState(input.state);\n agent.threadId = input.threadId;\n\n if (runtime.debug?.lifecycle && runtime.debugLogger) {\n runtime.debugLogger.debug(\n { agentName: agentId, threadId: input.threadId },\n \"Agent run started\",\n );\n }\n\n if (isIntelligenceRuntime(runtime)) {\n return handleIntelligenceRun({\n runtime,\n request,\n agentId,\n agent,\n input,\n startTime,\n });\n }\n\n return handleSseRun({\n runtime,\n request,\n agent,\n input,\n agentId,\n debug: runtime.debug,\n logger: runtime.debugLogger,\n startTime,\n ownerId,\n });\n } catch (error) {\n getRuntimeErrorReporter(runtime)?.report({\n request,\n error,\n operation: \"agent.run\",\n agentId,\n phase: \"common\",\n startTime,\n });\n console.error(\"Error running agent:\", error);\n console.error(\n \"Error stack:\",\n error instanceof Error ? error.stack : \"No stack trace\",\n );\n console.error(\"Error details:\", {\n name: error instanceof Error ? error.name : \"Unknown\",\n message: error instanceof Error ? error.message : String(error),\n cause: error instanceof Error ? error.cause : undefined,\n });\n\n return new Response(\n JSON.stringify({\n error: \"Failed to run agent\",\n message: error instanceof Error ? error.message : \"Unknown error\",\n }),\n {\n status: 500,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n}\n"],"mappings":";;;;;;;;;;;;AAoBA,eAAsB,eAAe,EACnC,SACA,SACA,WACqB;CACrB,MAAM,YAAY,KAAK,KAAK;CAC5B,MAAM,eAAe,QAAQ,QAAQ,IAAI,gCAAgC;AACzE,EAAC,QAAQ,aAAa,WAAW,QAC/B,uCACA;EACE,4BAA4B,MAAM,sBAAsB,QAAQ;EAChE,aAAa;EACb,0BAA0B,CAAC,CAAC;EAC5B,GAAI,eAAe,EAAE,wBAAwB,cAAc,GAAG,EAAE;EACjE,CACF;AAED,KAAI;EACF,MAAM,QAAQ,MAAM,qBAAqB,SAAS,SAAS,QAAQ;AACnE,MAAI,iBAAiB,SACnB,QAAO;AAKT,QAAM,UAAU;EAOhB,MAAM,QAAQ,MAAM,gBAAgB,QAAQ,OAAO,CAAC;AACpD,MAAI,iBAAiB,SACnB,QAAO;EAMT,IAAI;AACJ,MAAI,CAAC,sBAAsB,QAAQ,EAAE;GACnC,MAAM,QAAQ,MAAM,wBAAwB;IAC1C;IACA;IACA,WAAW;IACZ,CAAC;AACF,OAAI,iBAAiB,SAAU,QAAO;AACtC,OACE,wBAAwB,QAAQ,OAAO,IACvC,CAAE,MAAM,QAAQ,OAAO,mBAAmB,MAAM,UAAU,EACxD,SAAS,OACV,CAAC,CAEF,QAAO,4BAA4B;AAErC,aAAU;;EAMZ,MAAM,yBACH,MAAM,gBACH,yBAAyB;EAG/B,MAAM,gCAAgC,yBACpC,MAAM,eACP,EAAE,SAAS,WAAW;AAEvB,2BAAyB;GACvB;GACA;GACA;GACA;GACA;GACA;GACA,mBAAmB,OAAO,UAAU,eAAe,KACjD,MAAM,kBAAkB,EAAE,EAC1B,sBACD;GACF,CAAC;EACF,MAAM,iBAAiB,MAAM,qCAAqC;GAChE;GACA;GACA;GACD,CAAC;AACF,MAAI,0BAA0B,SAAU,QAAO;AAE/C,QAAM,YAAY,MAAM,SAAS;AACjC,QAAM,SAAS,MAAM,MAAM;AAC3B,QAAM,WAAW,MAAM;AAEvB,MAAI,QAAQ,OAAO,aAAa,QAAQ,YACtC,SAAQ,YAAY,MAClB;GAAE,WAAW;GAAS,UAAU,MAAM;GAAU,EAChD,oBACD;AAGH,MAAI,sBAAsB,QAAQ,CAChC,QAAO,sBAAsB;GAC3B;GACA;GACA;GACA;GACA;GACA;GACD,CAAC;AAGJ,SAAO,aAAa;GAClB;GACA;GACA;GACA;GACA;GACA,OAAO,QAAQ;GACf,QAAQ,QAAQ;GAChB;GACA;GACD,CAAC;UACK,OAAO;AACd,0BAAwB,QAAQ,EAAE,OAAO;GACvC;GACA;GACA,WAAW;GACX;GACA,OAAO;GACP;GACD,CAAC;AACF,UAAQ,MAAM,wBAAwB,MAAM;AAC5C,UAAQ,MACN,gBACA,iBAAiB,QAAQ,MAAM,QAAQ,iBACxC;AACD,UAAQ,MAAM,kBAAkB;GAC9B,MAAM,iBAAiB,QAAQ,MAAM,OAAO;GAC5C,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;GAC/D,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;GAC/C,CAAC;AAEF,SAAO,IAAI,SACT,KAAK,UAAU;GACb,OAAO;GACP,SAAS,iBAAiB,QAAQ,MAAM,UAAU;GACnD,CAAC,EACF;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CACF"}
@@ -0,0 +1,102 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ const require_json_response = require('./shared/json-response.cjs');
3
+ const require_intelligence_utils = require('./shared/intelligence-utils.cjs');
4
+ const require_resolve_intelligence_user = require('./shared/resolve-intelligence-user.cjs');
5
+ const require_thread_access = require('./shared/thread-access.cjs');
6
+ const require_runtime$1 = require('../core/runtime.cjs');
7
+ let _ag_ui_client = require("@ag-ui/client");
8
+
9
+ //#region src/runtime/handlers/handle-stop.ts
10
+ /** Read `{ runId? }` from a stop request body; a 400 Response when the body is not a valid scope. */
11
+ async function parseStopScope(request) {
12
+ try {
13
+ const raw = await request.text();
14
+ const body = raw.trim() ? JSON.parse(raw) : {};
15
+ if (typeof body !== "object" || body === null || Array.isArray(body)) return Response.json({ error: "Invalid stop request" }, { status: 400 });
16
+ if (Object.keys(body).some((key) => key !== "runId")) return Response.json({ error: "Invalid stop request" }, { status: 400 });
17
+ if (!("runId" in body)) return {};
18
+ if (typeof body.runId !== "string" || !body.runId.trim()) return Response.json({ error: "Invalid runId" }, { status: 400 });
19
+ return { runId: body.runId };
20
+ } catch {
21
+ return Response.json({ error: "Invalid stop request" }, { status: 400 });
22
+ }
23
+ }
24
+ /** Stop an active run after applying the runtime's application identity policy. */
25
+ async function handleStopAgent({ runtime, request, agentId, threadId }) {
26
+ try {
27
+ const scope = await parseStopScope(request.clone());
28
+ if (require_json_response.isHandlerResponse(scope)) return scope;
29
+ const { runId } = scope;
30
+ let stopThreadId = threadId;
31
+ let ownerId;
32
+ if (!require_runtime$1.isIntelligenceRuntime(runtime)) {
33
+ const owner = await require_thread_access.resolveLocalThreadOwner({
34
+ runtime,
35
+ request,
36
+ operation: "stop"
37
+ });
38
+ if (require_json_response.isHandlerResponse(owner)) return owner;
39
+ ownerId = owner;
40
+ } else {
41
+ const user = await require_resolve_intelligence_user.resolveIntelligenceUser({
42
+ runtime,
43
+ request
44
+ });
45
+ if (require_json_response.isHandlerResponse(user)) return user;
46
+ try {
47
+ const thread = await runtime.intelligence.getThread({
48
+ threadId,
49
+ userId: user.id
50
+ });
51
+ if (!thread || typeof thread.id !== "string" || !thread.id.trim()) return Response.json({ error: "Invalid thread response" }, { status: 502 });
52
+ if (thread.agentId !== void 0 && thread.agentId !== agentId) return Response.json({ error: "Thread access denied" }, { status: 403 });
53
+ stopThreadId = thread.id;
54
+ } catch (error) {
55
+ const status = require_intelligence_utils.getPlatformErrorStatus(error);
56
+ return Response.json({ error: "Thread access denied" }, { status: status && status >= 400 && status < 500 ? status : 502 });
57
+ }
58
+ }
59
+ if (!(await require_runtime$1.resolveAgents(runtime.agents, request))[agentId]) return new Response(JSON.stringify({
60
+ error: "Agent not found",
61
+ message: `Agent '${agentId}' does not exist`
62
+ }), {
63
+ status: 404,
64
+ headers: { "Content-Type": "application/json" }
65
+ });
66
+ if (!await runtime.runner.stop({
67
+ threadId: stopThreadId,
68
+ ...runId === void 0 ? {} : { runId },
69
+ ...ownerId === void 0 ? {} : { ownerId }
70
+ })) return new Response(JSON.stringify({
71
+ stopped: false,
72
+ message: runId === void 0 ? `No active run for thread '${threadId}'.` : `Run '${runId}' is not the active run for thread '${threadId}'.`
73
+ }), {
74
+ status: 200,
75
+ headers: { "Content-Type": "application/json" }
76
+ });
77
+ return new Response(JSON.stringify({
78
+ stopped: true,
79
+ interrupt: {
80
+ type: _ag_ui_client.EventType.RUN_ERROR,
81
+ message: "Run stopped by user",
82
+ code: "STOPPED"
83
+ }
84
+ }), {
85
+ status: 200,
86
+ headers: { "Content-Type": "application/json" }
87
+ });
88
+ } catch (error) {
89
+ console.error("Error stopping agent run:", error);
90
+ return new Response(JSON.stringify({
91
+ error: "Failed to stop agent",
92
+ message: error instanceof Error ? error.message : "Unknown error"
93
+ }), {
94
+ status: 500,
95
+ headers: { "Content-Type": "application/json" }
96
+ });
97
+ }
98
+ }
99
+
100
+ //#endregion
101
+ exports.handleStopAgent = handleStopAgent;
102
+ //# sourceMappingURL=handle-stop.cjs.map