@copilotkit/runtime 2.0.0-rc.4 → 2.0.0-rc.41

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 (357) hide show
  1. package/README.md +28 -3
  2. package/dist/agent/{url-download.cjs → ai-sdk/url-download.cjs} +19 -76
  3. package/dist/agent/ai-sdk/url-download.cjs.map +1 -0
  4. package/dist/agent/{url-download.d.cts → ai-sdk/url-download.d.cts} +11 -8
  5. package/dist/agent/ai-sdk/url-download.d.cts.map +1 -0
  6. package/dist/agent/{url-download.d.mts → ai-sdk/url-download.d.mts} +11 -8
  7. package/dist/agent/ai-sdk/url-download.d.mts.map +1 -0
  8. package/dist/agent/{url-download.mjs → ai-sdk/url-download.mjs} +20 -74
  9. package/dist/agent/ai-sdk/url-download.mjs.map +1 -0
  10. package/dist/agent/ai-sdk.cjs +425 -0
  11. package/dist/agent/ai-sdk.cjs.map +1 -0
  12. package/dist/agent/ai-sdk.d.cts +119 -0
  13. package/dist/agent/ai-sdk.d.cts.map +1 -0
  14. package/dist/agent/ai-sdk.d.mts +119 -0
  15. package/dist/agent/ai-sdk.d.mts.map +1 -0
  16. package/dist/agent/ai-sdk.mjs +419 -0
  17. package/dist/agent/ai-sdk.mjs.map +1 -0
  18. package/dist/agent/classic-tools.cjs +185 -0
  19. package/dist/agent/classic-tools.cjs.map +1 -0
  20. package/dist/agent/classic-tools.mjs +183 -0
  21. package/dist/agent/classic-tools.mjs.map +1 -0
  22. package/dist/agent/converters/aisdk.cjs +16 -3
  23. package/dist/agent/converters/aisdk.cjs.map +1 -1
  24. package/dist/agent/converters/aisdk.d.cts.map +1 -1
  25. package/dist/agent/converters/aisdk.d.mts.map +1 -1
  26. package/dist/agent/converters/aisdk.mjs +18 -2
  27. package/dist/agent/converters/aisdk.mjs.map +1 -1
  28. package/dist/agent/converters/tanstack.cjs +201 -29
  29. package/dist/agent/converters/tanstack.cjs.map +1 -1
  30. package/dist/agent/converters/tanstack.d.cts +90 -6
  31. package/dist/agent/converters/tanstack.d.cts.map +1 -1
  32. package/dist/agent/converters/tanstack.d.mts +90 -6
  33. package/dist/agent/converters/tanstack.d.mts.map +1 -1
  34. package/dist/agent/converters/tanstack.mjs +201 -28
  35. package/dist/agent/converters/tanstack.mjs.map +1 -1
  36. package/dist/agent/learned-skills.cjs +15 -17
  37. package/dist/agent/learned-skills.cjs.map +1 -1
  38. package/dist/agent/learned-skills.d.cts +9 -3
  39. package/dist/agent/learned-skills.d.cts.map +1 -1
  40. package/dist/agent/learned-skills.d.mts +9 -3
  41. package/dist/agent/learned-skills.d.mts.map +1 -1
  42. package/dist/agent/learned-skills.mjs +15 -16
  43. package/dist/agent/learned-skills.mjs.map +1 -1
  44. package/dist/agent/model.cjs +42 -0
  45. package/dist/agent/model.cjs.map +1 -0
  46. package/dist/agent/model.d.cts +19 -0
  47. package/dist/agent/model.d.cts.map +1 -0
  48. package/dist/agent/model.d.mts +19 -0
  49. package/dist/agent/model.d.mts.map +1 -0
  50. package/dist/agent/model.mjs +41 -0
  51. package/dist/agent/model.mjs.map +1 -0
  52. package/dist/agent/state-delta.cjs +0 -1
  53. package/dist/agent/state-delta.cjs.map +1 -1
  54. package/dist/agent.cjs +558 -0
  55. package/dist/agent.cjs.map +1 -0
  56. package/dist/agent.d.cts +455 -0
  57. package/dist/agent.d.cts.map +1 -0
  58. package/dist/agent.d.mts +455 -0
  59. package/dist/agent.d.mts.map +1 -0
  60. package/dist/agent.mjs +551 -0
  61. package/dist/agent.mjs.map +1 -0
  62. package/dist/index.cjs +21 -27
  63. package/dist/index.d.cts +10 -11
  64. package/dist/index.d.mts +10 -11
  65. package/dist/index.mjs +5 -6
  66. package/dist/internal/learned-skills.d.cts +1 -1
  67. package/dist/internal/learned-skills.d.mts +1 -1
  68. package/dist/node.cjs +1 -2
  69. package/dist/node.d.cts +2 -2
  70. package/dist/node.d.mts +2 -2
  71. package/dist/node.mjs +2 -2
  72. package/dist/runtime/core/channel-manager.cjs +10 -2
  73. package/dist/runtime/core/channel-manager.cjs.map +1 -1
  74. package/dist/runtime/core/channel-manager.d.cts +1 -1
  75. package/dist/runtime/core/channel-manager.d.mts +1 -1
  76. package/dist/runtime/core/channel-manager.mjs +10 -1
  77. package/dist/runtime/core/channel-manager.mjs.map +1 -1
  78. package/dist/runtime/core/debug-event-bus.cjs +4 -3
  79. package/dist/runtime/core/debug-event-bus.cjs.map +1 -1
  80. package/dist/runtime/core/debug-event-bus.d.cts +5 -1
  81. package/dist/runtime/core/debug-event-bus.d.cts.map +1 -1
  82. package/dist/runtime/core/debug-event-bus.d.mts +4 -0
  83. package/dist/runtime/core/debug-event-bus.d.mts.map +1 -1
  84. package/dist/runtime/core/debug-event-bus.mjs +5 -3
  85. package/dist/runtime/core/debug-event-bus.mjs.map +1 -1
  86. package/dist/runtime/core/fetch-handler.cjs +15 -12
  87. package/dist/runtime/core/fetch-handler.cjs.map +1 -1
  88. package/dist/runtime/core/fetch-handler.d.cts +8 -0
  89. package/dist/runtime/core/fetch-handler.d.cts.map +1 -1
  90. package/dist/runtime/core/fetch-handler.d.mts +8 -0
  91. package/dist/runtime/core/fetch-handler.d.mts.map +1 -1
  92. package/dist/runtime/core/fetch-handler.mjs +7 -3
  93. package/dist/runtime/core/fetch-handler.mjs.map +1 -1
  94. package/dist/runtime/core/learning.d.cts +1 -1
  95. package/dist/runtime/core/logger.cjs +105 -14
  96. package/dist/runtime/core/logger.cjs.map +1 -1
  97. package/dist/runtime/core/logger.d.cts +25 -8
  98. package/dist/runtime/core/logger.d.cts.map +1 -1
  99. package/dist/runtime/core/logger.d.mts +25 -8
  100. package/dist/runtime/core/logger.d.mts.map +1 -1
  101. package/dist/runtime/core/logger.mjs +105 -12
  102. package/dist/runtime/core/logger.mjs.map +1 -1
  103. package/dist/runtime/core/middleware-sse-parser.cjs +3 -4
  104. package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -1
  105. package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -1
  106. package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -1
  107. package/dist/runtime/core/middleware-sse-parser.mjs +2 -2
  108. package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -1
  109. package/dist/runtime/core/middleware.cjs +5 -5
  110. package/dist/runtime/core/middleware.cjs.map +1 -1
  111. package/dist/runtime/core/middleware.mjs +4 -3
  112. package/dist/runtime/core/middleware.mjs.map +1 -1
  113. package/dist/runtime/core/package-info.cjs +1 -1
  114. package/dist/runtime/core/package-info.mjs +1 -1
  115. package/dist/runtime/core/runtime.cjs +11 -10
  116. package/dist/runtime/core/runtime.cjs.map +1 -1
  117. package/dist/runtime/core/runtime.d.cts +22 -4
  118. package/dist/runtime/core/runtime.d.cts.map +1 -1
  119. package/dist/runtime/core/runtime.d.mts +22 -4
  120. package/dist/runtime/core/runtime.d.mts.map +1 -1
  121. package/dist/runtime/core/runtime.mjs +11 -9
  122. package/dist/runtime/core/runtime.mjs.map +1 -1
  123. package/dist/runtime/endpoints/auto-start-channels.cjs +3 -4
  124. package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -1
  125. package/dist/runtime/endpoints/auto-start-channels.mjs +2 -2
  126. package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -1
  127. package/dist/runtime/endpoints/node-fetch-handler.cjs +3 -7
  128. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -1
  129. package/dist/runtime/endpoints/node-fetch-handler.d.cts +3 -4
  130. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -1
  131. package/dist/runtime/endpoints/node-fetch-handler.d.mts +3 -4
  132. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -1
  133. package/dist/runtime/endpoints/node-fetch-handler.mjs +3 -5
  134. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -1
  135. package/dist/runtime/endpoints/node.cjs +4 -2
  136. package/dist/runtime/endpoints/node.cjs.map +1 -1
  137. package/dist/runtime/endpoints/node.d.cts.map +1 -1
  138. package/dist/runtime/endpoints/node.d.mts.map +1 -1
  139. package/dist/runtime/endpoints/node.mjs +4 -2
  140. package/dist/runtime/endpoints/node.mjs.map +1 -1
  141. package/dist/runtime/event-transforms/index.d.cts +4 -0
  142. package/dist/runtime/event-transforms/index.d.mts +4 -0
  143. package/dist/runtime/event-transforms/index.mjs +5 -0
  144. package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs +277 -0
  145. package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
  146. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts +61 -0
  147. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
  148. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts +61 -0
  149. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
  150. package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs +276 -0
  151. package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
  152. package/dist/runtime/event-transforms/recorded-events.cjs +58 -0
  153. package/dist/runtime/event-transforms/recorded-events.cjs.map +1 -0
  154. package/dist/runtime/event-transforms/recorded-events.d.cts +23 -0
  155. package/dist/runtime/event-transforms/recorded-events.d.cts.map +1 -0
  156. package/dist/runtime/event-transforms/recorded-events.d.mts +23 -0
  157. package/dist/runtime/event-transforms/recorded-events.d.mts.map +1 -0
  158. package/dist/runtime/event-transforms/recorded-events.mjs +58 -0
  159. package/dist/runtime/event-transforms/recorded-events.mjs.map +1 -0
  160. package/dist/runtime/event-transforms/streaming-json-scanner.cjs +289 -0
  161. package/dist/runtime/event-transforms/streaming-json-scanner.cjs.map +1 -0
  162. package/dist/runtime/event-transforms/streaming-json-scanner.mjs +288 -0
  163. package/dist/runtime/event-transforms/streaming-json-scanner.mjs.map +1 -0
  164. package/dist/runtime/generative-ui/generative-ui-middleware.cjs +0 -1
  165. package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -1
  166. package/dist/runtime/generative-ui/surface-writer.cjs +4 -5
  167. package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -1
  168. package/dist/runtime/generative-ui/surface-writer.d.cts +1 -1
  169. package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -1
  170. package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -1
  171. package/dist/runtime/generative-ui/surface-writer.mjs +5 -5
  172. package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -1
  173. package/dist/runtime/handlers/get-runtime-info.cjs +5 -1
  174. package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -1
  175. package/dist/runtime/handlers/get-runtime-info.mjs +5 -1
  176. package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -1
  177. package/dist/runtime/handlers/handle-connect.cjs +3 -8
  178. package/dist/runtime/handlers/handle-connect.cjs.map +1 -1
  179. package/dist/runtime/handlers/handle-connect.mjs +3 -8
  180. package/dist/runtime/handlers/handle-connect.mjs.map +1 -1
  181. package/dist/runtime/handlers/handle-inspector-learning.cjs +2 -3
  182. package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -1
  183. package/dist/runtime/handlers/handle-inspector-metadata.cjs +2 -3
  184. package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -1
  185. package/dist/runtime/handlers/handle-run.cjs +11 -14
  186. package/dist/runtime/handlers/handle-run.cjs.map +1 -1
  187. package/dist/runtime/handlers/handle-run.mjs +8 -10
  188. package/dist/runtime/handlers/handle-run.mjs.map +1 -1
  189. package/dist/runtime/handlers/handle-stop.cjs +5 -5
  190. package/dist/runtime/handlers/handle-stop.cjs.map +1 -1
  191. package/dist/runtime/handlers/handle-stop.mjs +2 -1
  192. package/dist/runtime/handlers/handle-stop.mjs.map +1 -1
  193. package/dist/runtime/handlers/handle-suggest.cjs +6 -3
  194. package/dist/runtime/handlers/handle-suggest.cjs.map +1 -1
  195. package/dist/runtime/handlers/handle-suggest.mjs +6 -2
  196. package/dist/runtime/handlers/handle-suggest.mjs.map +1 -1
  197. package/dist/runtime/handlers/handle-transcribe.cjs +0 -1
  198. package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -1
  199. package/dist/runtime/handlers/intelligence/annotate.cjs +8 -8
  200. package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -1
  201. package/dist/runtime/handlers/intelligence/annotate.mjs +4 -3
  202. package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -1
  203. package/dist/runtime/handlers/intelligence/connect.cjs +6 -2
  204. package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -1
  205. package/dist/runtime/handlers/intelligence/connect.mjs +6 -2
  206. package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -1
  207. package/dist/runtime/handlers/intelligence/memories.cjs +27 -22
  208. package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -1
  209. package/dist/runtime/handlers/intelligence/memories.mjs +11 -5
  210. package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -1
  211. package/dist/runtime/handlers/intelligence/run.cjs +38 -30
  212. package/dist/runtime/handlers/intelligence/run.cjs.map +1 -1
  213. package/dist/runtime/handlers/intelligence/run.mjs +37 -28
  214. package/dist/runtime/handlers/intelligence/run.mjs.map +1 -1
  215. package/dist/runtime/handlers/intelligence/thread-names.cjs +6 -5
  216. package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
  217. package/dist/runtime/handlers/intelligence/thread-names.mjs +3 -1
  218. package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -1
  219. package/dist/runtime/handlers/intelligence/threads.cjs +36 -27
  220. package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -1
  221. package/dist/runtime/handlers/intelligence/threads.mjs +13 -3
  222. package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -1
  223. package/dist/runtime/handlers/shared/agent-utils.cjs +35 -34
  224. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  225. package/dist/runtime/handlers/shared/agent-utils.mjs +29 -27
  226. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  227. package/dist/runtime/handlers/shared/cloud-telemetry.cjs +0 -1
  228. package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -1
  229. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +4 -3
  230. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
  231. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +4 -3
  232. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
  233. package/dist/runtime/handlers/shared/sse-response.cjs +77 -78
  234. package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -1
  235. package/dist/runtime/handlers/shared/sse-response.mjs +77 -77
  236. package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -1
  237. package/dist/runtime/handlers/shared/thread-access.cjs +3 -2
  238. package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -1
  239. package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -1
  240. package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -1
  241. package/dist/runtime/handlers/shared/thread-access.mjs +3 -2
  242. package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -1
  243. package/dist/runtime/handlers/sse/connect.cjs +2 -0
  244. package/dist/runtime/handlers/sse/connect.cjs.map +1 -1
  245. package/dist/runtime/handlers/sse/connect.mjs +2 -0
  246. package/dist/runtime/handlers/sse/connect.mjs.map +1 -1
  247. package/dist/runtime/handlers/sse/run.cjs +5 -2
  248. package/dist/runtime/handlers/sse/run.cjs.map +1 -1
  249. package/dist/runtime/handlers/sse/run.mjs +5 -2
  250. package/dist/runtime/handlers/sse/run.mjs.map +1 -1
  251. package/dist/runtime/index.d.cts +9 -15
  252. package/dist/runtime/index.d.mts +9 -15
  253. package/dist/runtime/intelligence-platform/analytics-context.cjs +84 -0
  254. package/dist/runtime/intelligence-platform/analytics-context.cjs.map +1 -0
  255. package/dist/runtime/intelligence-platform/analytics-context.mjs +83 -0
  256. package/dist/runtime/intelligence-platform/analytics-context.mjs.map +1 -0
  257. package/dist/runtime/intelligence-platform/client.cjs +27 -1
  258. package/dist/runtime/intelligence-platform/client.cjs.map +1 -1
  259. package/dist/runtime/intelligence-platform/client.d.cts +24 -1
  260. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -1
  261. package/dist/runtime/intelligence-platform/client.d.mts +24 -1
  262. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -1
  263. package/dist/runtime/intelligence-platform/client.mjs +27 -0
  264. package/dist/runtime/intelligence-platform/client.mjs.map +1 -1
  265. package/dist/runtime/intelligence-platform/learning-management.cjs +7 -8
  266. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -1
  267. package/dist/runtime/intelligence-platform/learning-management.mjs +7 -7
  268. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -1
  269. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +104 -110
  270. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -1
  271. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +8 -2
  272. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -1
  273. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +8 -2
  274. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -1
  275. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +104 -109
  276. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -1
  277. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +0 -1
  278. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -1
  279. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +1 -1
  280. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +1 -1
  281. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +22 -19
  282. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -1
  283. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -1
  284. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -1
  285. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +22 -19
  286. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -1
  287. package/dist/runtime/intelligence-platform/stop-run.cjs +50 -0
  288. package/dist/runtime/intelligence-platform/stop-run.cjs.map +1 -0
  289. package/dist/runtime/intelligence-platform/stop-run.mjs +50 -0
  290. package/dist/runtime/intelligence-platform/stop-run.mjs.map +1 -0
  291. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +3 -3
  292. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -1
  293. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +2 -1
  294. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -1
  295. package/dist/runtime/intelligence-platform/trajectories.cjs +2 -3
  296. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -1
  297. package/dist/runtime/intelligence-platform/trajectories.mjs +2 -2
  298. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -1
  299. package/dist/runtime/node.d.cts +1 -1
  300. package/dist/runtime/node.d.mts +1 -1
  301. package/dist/runtime/runner/agent-runner.cjs +0 -1
  302. package/dist/runtime/runner/agent-runner.cjs.map +1 -1
  303. package/dist/runtime/runner/agent-runner.d.cts +9 -0
  304. package/dist/runtime/runner/agent-runner.d.cts.map +1 -1
  305. package/dist/runtime/runner/agent-runner.d.mts +9 -0
  306. package/dist/runtime/runner/agent-runner.d.mts.map +1 -1
  307. package/dist/runtime/runner/agent-runner.mjs.map +1 -1
  308. package/dist/runtime/runner/in-memory.cjs +0 -1
  309. package/dist/runtime/runner/in-memory.cjs.map +1 -1
  310. package/dist/runtime/runner/index.d.cts +1 -1
  311. package/dist/runtime/runner/index.d.mts +1 -1
  312. package/dist/runtime/runner/index.mjs +1 -1
  313. package/dist/runtime/runner/intelligence.cjs +55 -9
  314. package/dist/runtime/runner/intelligence.cjs.map +1 -1
  315. package/dist/runtime/runner/intelligence.d.cts +12 -1
  316. package/dist/runtime/runner/intelligence.d.cts.map +1 -1
  317. package/dist/runtime/runner/intelligence.d.mts +12 -1
  318. package/dist/runtime/runner/intelligence.d.mts.map +1 -1
  319. package/dist/runtime/runner/intelligence.mjs +56 -10
  320. package/dist/runtime/runner/intelligence.mjs.map +1 -1
  321. package/dist/runtime/telemetry/disclosure.cjs +2 -3
  322. package/dist/runtime/telemetry/disclosure.cjs.map +1 -1
  323. package/dist/runtime/telemetry/disclosure.mjs +3 -3
  324. package/dist/runtime/telemetry/disclosure.mjs.map +1 -1
  325. package/dist/runtime/telemetry/events.d.cts +1 -1
  326. package/dist/runtime/telemetry/events.d.mts +1 -1
  327. package/dist/runtime/telemetry/instance-created.cjs +33 -12
  328. package/dist/runtime/telemetry/instance-created.cjs.map +1 -1
  329. package/dist/runtime/telemetry/instance-created.mjs +33 -12
  330. package/dist/runtime/telemetry/instance-created.mjs.map +1 -1
  331. package/dist/runtime/telemetry/telemetry-client.cjs +0 -5
  332. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -1
  333. package/dist/runtime/telemetry/telemetry-client.mjs +0 -4
  334. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -1
  335. package/dist/runtime/telemetry/telemetry-identity.cjs +0 -1
  336. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -1
  337. package/package.json +55 -30
  338. package/dist/_virtual/_rolldown/runtime.cjs +0 -29
  339. package/dist/agent/converters/index.d.mts +0 -2
  340. package/dist/agent/index.cjs +0 -1328
  341. package/dist/agent/index.cjs.map +0 -1
  342. package/dist/agent/index.d.cts +0 -467
  343. package/dist/agent/index.d.cts.map +0 -1
  344. package/dist/agent/index.d.mts +0 -468
  345. package/dist/agent/index.d.mts.map +0 -1
  346. package/dist/agent/index.mjs +0 -1318
  347. package/dist/agent/index.mjs.map +0 -1
  348. package/dist/agent/mcp-tool-names.cjs +0 -82
  349. package/dist/agent/mcp-tool-names.cjs.map +0 -1
  350. package/dist/agent/mcp-tool-names.mjs +0 -80
  351. package/dist/agent/mcp-tool-names.mjs.map +0 -1
  352. package/dist/agent/url-download.cjs.map +0 -1
  353. package/dist/agent/url-download.d.cts.map +0 -1
  354. package/dist/agent/url-download.d.mts.map +0 -1
  355. package/dist/agent/url-download.mjs.map +0 -1
  356. package/dist/runtime/index.d.cts.map +0 -1
  357. package/dist/runtime/index.d.mts.map +0 -1
@@ -1 +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"}
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,sCAAsB,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"}
@@ -1,5 +1,4 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
- const require_runtime$1 = require('../core/runtime.cjs');
1
+ const require_runtime = require('../core/runtime.cjs');
3
2
  let _copilotkit_shared = require("@copilotkit/shared");
4
3
 
5
4
  //#region src/runtime/handlers/handle-inspector-metadata.ts
@@ -15,7 +14,7 @@ function emptyInspectorMetadataResponse() {
15
14
  * failures or forwarding any browser request credentials to Intelligence.
16
15
  */
17
16
  async function handleInspectorMetadata({ runtime }) {
18
- if (!require_runtime$1.isIntelligenceRuntime(runtime)) return emptyInspectorMetadataResponse();
17
+ if (!require_runtime.isIntelligenceRuntime(runtime)) return emptyInspectorMetadataResponse();
19
18
  try {
20
19
  const metadata = (0, _copilotkit_shared.parseInspectorMetadataV1)(await runtime.intelligence.getInspectorMetadata());
21
20
  if (metadata === void 0) return emptyInspectorMetadataResponse();
@@ -1 +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"}
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,sCAAsB,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"}
@@ -1,9 +1,10 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
1
+ const require_logger = require('../core/logger.cjs');
2
2
  const require_agent_runner = require('../runner/agent-runner.cjs');
3
+ const require_analytics_context = require('../intelligence-platform/analytics-context.cjs');
3
4
  const require_thread_access = require('./shared/thread-access.cjs');
4
5
  const require_telemetry_client = require('../telemetry/telemetry-client.cjs');
5
6
  const require_runtime_error_reporter = require('../core/runtime-error-reporter.cjs');
6
- const require_runtime$1 = require('../core/runtime.cjs');
7
+ const require_runtime = require('../core/runtime.cjs');
7
8
  const require_cloud_telemetry = require('./shared/cloud-telemetry.cjs');
8
9
  const require_agent_utils = require('./shared/agent-utils.cjs');
9
10
  const require_run = require('./intelligence/run.cjs');
@@ -24,10 +25,11 @@ async function handleRunAgent({ runtime, request, agentId }) {
24
25
  const agent = await require_agent_utils.cloneAgentForRequest(runtime, agentId, request);
25
26
  if (agent instanceof Response) return agent;
26
27
  agent.agentId = agentId;
27
- const input = await require_agent_utils.parseRunRequest(request.clone());
28
- if (input instanceof Response) return input;
28
+ const parsed = await require_agent_utils.parseRunRequest(request.clone(), require_logger.getRuntimeLogger(runtime));
29
+ if (parsed instanceof Response) return parsed;
30
+ const { input, analyticsContext } = require_analytics_context.takeAnalyticsContext(parsed);
29
31
  let ownerId;
30
- if (!require_runtime$1.isIntelligenceRuntime(runtime)) {
32
+ if (!require_runtime.isIntelligenceRuntime(runtime)) {
31
33
  const owner = await require_thread_access.resolveLocalThreadOwner({
32
34
  runtime,
33
35
  request,
@@ -61,12 +63,13 @@ async function handleRunAgent({ runtime, request, agentId }) {
61
63
  agentName: agentId,
62
64
  threadId: input.threadId
63
65
  }, "Agent run started");
64
- if (require_runtime$1.isIntelligenceRuntime(runtime)) return require_run.handleIntelligenceRun({
66
+ if (require_runtime.isIntelligenceRuntime(runtime)) return require_run.handleIntelligenceRun({
65
67
  runtime,
66
68
  request,
67
69
  agentId,
68
70
  agent,
69
71
  input,
72
+ analyticsContext,
70
73
  startTime
71
74
  });
72
75
  return require_run$1.handleSseRun({
@@ -76,7 +79,7 @@ async function handleRunAgent({ runtime, request, agentId }) {
76
79
  input,
77
80
  agentId,
78
81
  debug: runtime.debug,
79
- logger: runtime.debugLogger,
82
+ debugLogger: runtime.debugLogger,
80
83
  startTime,
81
84
  ownerId
82
85
  });
@@ -89,13 +92,7 @@ async function handleRunAgent({ runtime, request, agentId }) {
89
92
  phase: "common",
90
93
  startTime
91
94
  });
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
- });
95
+ require_logger.getRuntimeLogger(runtime).error({ err: error }, "Error running agent");
99
96
  return new Response(JSON.stringify({
100
97
  error: "Failed to run agent",
101
98
  message: error instanceof Error ? error.message : "Unknown error"
@@ -1 +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"}
1
+ {"version":3,"file":"handle-run.cjs","names":["telemetry","readGuardrailsEnabled","cloneAgentForRequest","parseRunRequest","getRuntimeLogger","takeAnalyticsContext","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 { getRuntimeLogger } from \"../core/logger\";\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 { takeAnalyticsContext } from \"../intelligence-platform/analytics-context\";\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 void (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 parsed = await parseRunRequest(\n request.clone(),\n getRuntimeLogger(runtime),\n );\n if (parsed instanceof Response) {\n return parsed;\n }\n // An app's analytics context is for Intelligence's lock request alone, so\n // it is taken off the input before anything hands that input to an agent.\n const { input, analyticsContext } = takeAnalyticsContext(parsed);\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 analyticsContext,\n startTime,\n });\n }\n\n return handleSseRun({\n runtime,\n request,\n agent,\n input,\n agentId,\n debug: runtime.debug,\n debugLogger: 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 getRuntimeLogger(runtime).error({ err: error }, \"Error running agent\");\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":";;;;;;;;;;;;;;AAsBA,eAAsB,eAAe,EACnC,SACA,SACA,WACqB;CACrB,MAAM,YAAY,KAAK,KAAK;CAC5B,MAAM,eAAe,QAAQ,QAAQ,IAAI,gCAAgC;AACzE,EAAM,QAAQ,aAAaA,kCAAW,QACpC,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,SAAS,MAAMC,oCACnB,QAAQ,OAAO,EACfC,gCAAiB,QAAQ,CAC1B;AACD,MAAI,kBAAkB,SACpB,QAAO;EAIT,MAAM,EAAE,OAAO,qBAAqBC,+CAAqB,OAAO;EAKhE,IAAI;AACJ,MAAI,CAACC,sCAAsB,QAAQ,EAAE;GACnC,MAAM,QAAQ,MAAMC,8CAAwB;IAC1C;IACA;IACA,WAAW;IACZ,CAAC;AACF,OAAI,iBAAiB,SAA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ger.mjs";
1
2
  import { enforcesThreadOwnership } from "../runner/agent-runner.mjs";
3
+ import { takeAnalyticsContext } from "../intelligence-platform/analytics-context.mjs";
2
4
  import { resolveLocalThreadOwner, threadAccessDeniedResponse } from "./shared/thread-access.mjs";
3
5
  import telemetry from "../telemetry/telemetry-client.mjs";
4
6
  import { getRuntimeErrorReporter } from "../core/runtime-error-reporter.mjs";
@@ -23,8 +25,9 @@ async function handleRunAgent({ runtime, request, agentId }) {
23
25
  const agent = await cloneAgentForRequest(runtime, agentId, request);
24
26
  if (agent instanceof Response) return agent;
25
27
  agent.agentId = agentId;
26
- const input = await parseRunRequest(request.clone());
27
- if (input instanceof Response) return input;
28
+ const parsed = await parseRunRequest(request.clone(), getRuntimeLogger(runtime));
29
+ if (parsed instanceof Response) return parsed;
30
+ const { input, analyticsContext } = takeAnalyticsContext(parsed);
28
31
  let ownerId;
29
32
  if (!isIntelligenceRuntime(runtime)) {
30
33
  const owner = await resolveLocalThreadOwner({
@@ -66,6 +69,7 @@ async function handleRunAgent({ runtime, request, agentId }) {
66
69
  agentId,
67
70
  agent,
68
71
  input,
72
+ analyticsContext,
69
73
  startTime
70
74
  });
71
75
  return handleSseRun({
@@ -75,7 +79,7 @@ async function handleRunAgent({ runtime, request, agentId }) {
75
79
  input,
76
80
  agentId,
77
81
  debug: runtime.debug,
78
- logger: runtime.debugLogger,
82
+ debugLogger: runtime.debugLogger,
79
83
  startTime,
80
84
  ownerId
81
85
  });
@@ -88,13 +92,7 @@ async function handleRunAgent({ runtime, request, agentId }) {
88
92
  phase: "common",
89
93
  startTime
90
94
  });
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
- });
95
+ getRuntimeLogger(runtime).error({ err: error }, "Error running agent");
98
96
  return new Response(JSON.stringify({
99
97
  error: "Failed to run agent",
100
98
  message: error instanceof Error ? error.message : "Unknown error"
@@ -1 +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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":"handle-run.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-run.ts"],"sourcesContent":["import { readCopilotKitUIEnvelope } from \"@copilotkit/shared\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport { getRuntimeLogger } from \"../core/logger\";\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 { takeAnalyticsContext } from \"../intelligence-platform/analytics-context\";\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 void (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 parsed = await parseRunRequest(\n request.clone(),\n getRuntimeLogger(runtime),\n );\n if (parsed instanceof Response) {\n return parsed;\n }\n // An app's analytics context is for Intelligence's lock request alone, so\n // it is taken off the input before anything hands that input to an agent.\n const { input, analyticsContext } = takeAnalyticsContext(parsed);\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 analyticsContext,\n startTime,\n });\n }\n\n return handleSseRun({\n runtime,\n request,\n agent,\n input,\n agentId,\n debug: runtime.debug,\n debugLogger: 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 getRuntimeLogger(runtime).error({ err: error }, \"Error running agent\");\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":";;;;;;;;;;;;;;AAsBA,eAAsB,eAAe,EACnC,SACA,SACA,WACqB;CACrB,MAAM,YAAY,KAAK,KAAK;CAC5B,MAAM,eAAe,QAAQ,QAAQ,IAAI,gCAAgC;AACzE,EAAM,QAAQ,aAAa,WAAW,QACpC,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,SAAS,MAAM,gBACnB,QAAQ,OAAO,EACf,iBAAiB,QAAQ,CAC1B;AACD,MAAI,kBAAkB,SACpB,QAAO;EAIT,MAAM,EAAE,OAAO,qBAAqB,qBAAqB,OAAO;EAKhE,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;GACA;GACD,CAAC;AAGJ,SAAO,aAAa;GAClB;GACA;GACA;GACA;GACA;GACA,OAAO,QAAQ;GACf,aAAa,QAAQ;GACrB;GACA;GACD,CAAC;UACK,OAAO;AACd,0BAAwB,QAAQ,EAAE,OAAO;GACvC;GACA;GACA,WAAW;GACX;GACA,OAAO;GACP;GACD,CAAC;AACF,mBAAiB,QAAQ,CAAC,MAAM,EAAE,KAAK,OAAO,EAAE,sBAAsB;AAEtE,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"}
@@ -1,9 +1,9 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
1
+ const require_logger = require('../core/logger.cjs');
2
2
  const require_json_response = require('./shared/json-response.cjs');
3
3
  const require_intelligence_utils = require('./shared/intelligence-utils.cjs');
4
4
  const require_resolve_intelligence_user = require('./shared/resolve-intelligence-user.cjs');
5
5
  const require_thread_access = require('./shared/thread-access.cjs');
6
- const require_runtime$1 = require('../core/runtime.cjs');
6
+ const require_runtime = require('../core/runtime.cjs');
7
7
  let _ag_ui_client = require("@ag-ui/client");
8
8
 
9
9
  //#region src/runtime/handlers/handle-stop.ts
@@ -29,7 +29,7 @@ async function handleStopAgent({ runtime, request, agentId, threadId }) {
29
29
  const { runId } = scope;
30
30
  let stopThreadId = threadId;
31
31
  let ownerId;
32
- if (!require_runtime$1.isIntelligenceRuntime(runtime)) {
32
+ if (!require_runtime.isIntelligenceRuntime(runtime)) {
33
33
  const owner = await require_thread_access.resolveLocalThreadOwner({
34
34
  runtime,
35
35
  request,
@@ -56,7 +56,7 @@ async function handleStopAgent({ runtime, request, agentId, threadId }) {
56
56
  return Response.json({ error: "Thread access denied" }, { status: status && status >= 400 && status < 500 ? status : 502 });
57
57
  }
58
58
  }
59
- if (!(await require_runtime$1.resolveAgents(runtime.agents, request))[agentId]) return new Response(JSON.stringify({
59
+ if (!(await require_runtime.resolveAgents(runtime.agents, request))[agentId]) return new Response(JSON.stringify({
60
60
  error: "Agent not found",
61
61
  message: `Agent '${agentId}' does not exist`
62
62
  }), {
@@ -86,7 +86,7 @@ async function handleStopAgent({ runtime, request, agentId, threadId }) {
86
86
  headers: { "Content-Type": "application/json" }
87
87
  });
88
88
  } catch (error) {
89
- console.error("Error stopping agent run:", error);
89
+ require_logger.getRuntimeLogger(runtime).error({ err: error }, "Error stopping agent run");
90
90
  return new Response(JSON.stringify({
91
91
  error: "Failed to stop agent",
92
92
  message: error instanceof Error ? error.message : "Unknown error"
@@ -1 +1 @@
1
- {"version":3,"file":"handle-stop.cjs","names":["isHandlerResponse","isIntelligenceRuntime","resolveLocalThreadOwner","resolveIntelligenceUser","getPlatformErrorStatus","resolveAgents","EventType"],"sources":["../../../src/runtime/handlers/handle-stop.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime, resolveAgents } from \"../core/runtime\";\nimport { EventType } from \"@ag-ui/client\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\nimport { isHandlerResponse } from \"./shared/json-response\";\nimport { getPlatformErrorStatus } from \"./shared/intelligence-utils\";\nimport { resolveLocalThreadOwner } from \"./shared/thread-access\";\n\ninterface StopAgentParameters {\n request: Request;\n runtime: CopilotRuntimeLike;\n agentId: string;\n threadId: string;\n}\n\n/** Read `{ runId? }` from a stop request body; a 400 Response when the body is not a valid scope. */\nasync function parseStopScope(\n request: Request,\n): Promise<{ runId?: string } | Response> {\n try {\n const raw = await request.text();\n const body: unknown = raw.trim() ? JSON.parse(raw) : {};\n if (typeof body !== \"object\" || body === null || Array.isArray(body)) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n // Only `runId` is allowed. A misspelt key must not fall through to a\n // thread-wide stop, because a stop cannot be undone.\n if (Object.keys(body).some((key) => key !== \"runId\")) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n if (!(\"runId\" in body)) return {};\n if (typeof body.runId !== \"string\" || !body.runId.trim()) {\n return Response.json({ error: \"Invalid runId\" }, { status: 400 });\n }\n return { runId: body.runId };\n } catch {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n}\n\n/** Stop an active run after applying the runtime's application identity policy. */\nexport async function handleStopAgent({\n runtime,\n request,\n agentId,\n threadId,\n}: StopAgentParameters): Promise<Response> {\n try {\n // Parse the optional run scope for every runtime kind, from a clone so an\n // identity callback can still read the original body. No body or `{}`\n // keeps the thread-wide stop existing clients rely on.\n const scope = await parseStopScope(request.clone());\n if (isHandlerResponse(scope)) return scope;\n const { runId } = scope;\n let stopThreadId = threadId;\n let ownerId: string | undefined;\n if (!isIntelligenceRuntime(runtime)) {\n // A run on another identity's thread reports \"no active run\".\n const owner = await resolveLocalThreadOwner({\n runtime,\n request,\n operation: \"stop\",\n });\n if (isHandlerResponse(owner)) return owner;\n ownerId = owner;\n } else {\n const user = await resolveIntelligenceUser({ runtime, request });\n if (isHandlerResponse(user)) return user;\n try {\n const thread = await runtime.intelligence.getThread({\n threadId,\n userId: user.id,\n });\n if (!thread || typeof thread.id !== \"string\" || !thread.id.trim()) {\n return Response.json(\n { error: \"Invalid thread response\" },\n { status: 502 },\n );\n }\n if (thread.agentId !== undefined && thread.agentId !== agentId) {\n return Response.json(\n { error: \"Thread access denied\" },\n { status: 403 },\n );\n }\n stopThreadId = thread.id;\n } catch (error) {\n const status = getPlatformErrorStatus(error);\n return Response.json(\n { error: \"Thread access denied\" },\n { status: status && status >= 400 && status < 500 ? status : 502 },\n );\n }\n }\n const agents = await resolveAgents(runtime.agents, request);\n\n if (!agents[agentId]) {\n return new Response(\n JSON.stringify({\n error: \"Agent not found\",\n message: `Agent '${agentId}' does not exist`,\n }),\n {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n const stopped = await runtime.runner.stop({\n threadId: stopThreadId,\n ...(runId === undefined ? {} : { runId }),\n ...(ownerId === undefined ? {} : { ownerId }),\n });\n\n if (!stopped) {\n return new Response(\n JSON.stringify({\n stopped: false,\n message:\n runId === undefined\n ? `No active run for thread '${threadId}'.`\n : `Run '${runId}' is not the active run for thread '${threadId}'.`,\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n return new Response(\n JSON.stringify({\n stopped: true,\n interrupt: {\n type: EventType.RUN_ERROR,\n message: \"Run stopped by user\",\n code: \"STOPPED\",\n },\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n } catch (error) {\n console.error(\"Error stopping agent run:\", error);\n\n return new Response(\n JSON.stringify({\n error: \"Failed to stop 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":";;;;;;;;;;AAgBA,eAAe,e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6B,MAAM;AAEjD,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"}
1
+ {"version":3,"file":"handle-stop.cjs","names":["isHandlerResponse","isIntelligenceRuntime","resolveLocalThreadOwner","resolveIntelligenceUser","getPlatformErrorStatus","resolveAgents","EventType"],"sources":["../../../src/runtime/handlers/handle-stop.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime, resolveAgents } from \"../core/runtime\";\nimport { getRuntimeLogger } from \"../core/logger\";\nimport { EventType } from \"@ag-ui/client\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\nimport { isHandlerResponse } from \"./shared/json-response\";\nimport { getPlatformErrorStatus } from \"./shared/intelligence-utils\";\nimport { resolveLocalThreadOwner } from \"./shared/thread-access\";\n\ninterface StopAgentParameters {\n request: Request;\n runtime: CopilotRuntimeLike;\n agentId: string;\n threadId: string;\n}\n\n/** Read `{ runId? }` from a stop request body; a 400 Response when the body is not a valid scope. */\nasync function parseStopScope(\n request: Request,\n): Promise<{ runId?: string } | Response> {\n try {\n const raw = await request.text();\n const body: unknown = raw.trim() ? JSON.parse(raw) : {};\n if (typeof body !== \"object\" || body === null || Array.isArray(body)) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n // Only `runId` is allowed. A misspelt key must not fall through to a\n // thread-wide stop, because a stop cannot be undone.\n if (Object.keys(body).some((key) => key !== \"runId\")) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n if (!(\"runId\" in body)) return {};\n if (typeof body.runId !== \"string\" || !body.runId.trim()) {\n return Response.json({ error: \"Invalid runId\" }, { status: 400 });\n }\n return { runId: body.runId };\n } catch {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n}\n\n/** Stop an active run after applying the runtime's application identity policy. */\nexport async function handleStopAgent({\n runtime,\n request,\n agentId,\n threadId,\n}: StopAgentParameters): Promise<Response> {\n try {\n // Parse the optional run scope for every runtime kind, from a clone so an\n // identity callback can still read the original body. No body or `{}`\n // keeps the thread-wide stop existing clients rely on.\n const scope = await parseStopScope(request.clone());\n if (isHandlerResponse(scope)) return scope;\n const { runId } = scope;\n let stopThreadId = threadId;\n let ownerId: string | undefined;\n if (!isIntelligenceRuntime(runtime)) {\n // A run on another identity's thread reports \"no active run\".\n const owner = await resolveLocalThreadOwner({\n runtime,\n request,\n operation: \"stop\",\n });\n if (isHandlerResponse(owner)) return owner;\n ownerId = owner;\n } else {\n const user = await resolveIntelligenceUser({ runtime, request });\n if (isHandlerResponse(user)) return user;\n try {\n const thread = await runtime.intelligence.getThread({\n threadId,\n userId: user.id,\n });\n if (!thread || typeof thread.id !== \"string\" || !thread.id.trim()) {\n return Response.json(\n { error: \"Invalid thread response\" },\n { status: 502 },\n );\n }\n if (thread.agentId !== undefined && thread.agentId !== agentId) {\n return Response.json(\n { error: \"Thread access denied\" },\n { status: 403 },\n );\n }\n stopThreadId = thread.id;\n } catch (error) {\n const status = getPlatformErrorStatus(error);\n return Response.json(\n { error: \"Thread access denied\" },\n { status: status && status >= 400 && status < 500 ? status : 502 },\n );\n }\n }\n const agents = await resolveAgents(runtime.agents, request);\n\n if (!agents[agentId]) {\n return new Response(\n JSON.stringify({\n error: \"Agent not found\",\n message: `Agent '${agentId}' does not exist`,\n }),\n {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n const stopped = await runtime.runner.stop({\n threadId: stopThreadId,\n ...(runId === undefined ? {} : { runId }),\n ...(ownerId === undefined ? {} : { ownerId }),\n });\n\n if (!stopped) {\n return new Response(\n JSON.stringify({\n stopped: false,\n message:\n runId === undefined\n ? `No active run for thread '${threadId}'.`\n : `Run '${runId}' is not the active run for thread '${threadId}'.`,\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n return new Response(\n JSON.stringify({\n stopped: true,\n interrupt: {\n type: EventType.RUN_ERROR,\n message: \"Run stopped by user\",\n code: \"STOPPED\",\n },\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n } catch (error) {\n getRuntimeLogger(runtime).error({ err: error }, \"Error stopping agent run\");\n\n return new Response(\n JSON.stringify({\n error: \"Failed to stop 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":";;;;;;;;;;AAiBA,eAAe,eACb,SACwC;AACxC,KAAI;EACF,MAAM,MAAM,MAAM,QAAQ,MAAM;EAChC,MAAM,OAAgB,IAAI,MAAM,GAAG,KAAK,MAAM,IAAI,GAAG,EAAE;AACvD,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,KAAK,CAClE,QAAO,SAAS,KAAK,EAAE,OAAO,wBAAwB,EAAE,EAAE,QAAQ,KAAK,CAAC;AAI1E,MAAI,OAAO,KAAK,KAAK,CAAC,MAAM,QAAQ,QAAQ,QAAQ,CAClD,QAAO,SAAS,KAAK,EAAE,OAAO,wBAAwB,EAAE,EAAE,QAAQ,KAAK,CAAC;AAE1E,MAAI,EAAE,WAAW,MAAO,QAAO,EAAE;AACjC,MAAI,OAAO,KAAK,UAAU,YAAY,CAAC,KAAK,MAAM,MAAM,CACtD,QAAO,SAAS,KAAK,EAAE,OAAO,iBAAiB,EAAE,EAAE,QAAQ,KAAK,CAAC;AAEnE,SAAO,EAAE,OAAO,KAAK,OAAO;SACtB;AACN,SAAO,SAAS,KAAK,EAAE,OAAO,wBAAwB,EAAE,EAAE,QAAQ,KAAK,CAAC;;;;AAK5E,eAAsB,gBAAgB,EACpC,SACA,SACA,SACA,YACyC;AACzC,KAAI;EAIF,MAAM,QAAQ,MAAM,eAAe,QAAQ,OAAO,CAAC;AACnD,MAAIA,wCAAkB,MA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QAAO,IAAI,SACT,KAAK,UAAU;GACb,SAAS;GACT,SACE,UAAU,SACN,6BAA6B,SAAS,MACtC,QAAQ,MAAM,sCAAsC,SAAS;GACpE,CAAC,EACF;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CACF;AAGH,SAAO,IAAI,SACT,KAAK,UAAU;GACb,SAAS;GACT,WAAW;IACT,MAAMC,wBAAU;IAChB,SAAS;IACT,MAAM;IACP;GACF,CAAC,EACF;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CACF;UACM,OAAO;AACd,kCAAiB,QAAQ,CAAC,MAAM,EAAE,KAAK,OAAO,EAAE,2BAA2B;AAE3E,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"}
@@ -1,3 +1,4 @@
1
+ import { getRuntimeLogger } from "../core/logger.mjs";
1
2
  import { isHandlerResponse } from "./shared/json-response.mjs";
2
3
  import { getPlatformErrorStatus } from "./shared/intelligence-utils.mjs";
3
4
  import { resolveIntelligenceUser } from "./shared/resolve-intelligence-user.mjs";
@@ -85,7 +86,7 @@ async function handleStopAgent({ runtime, request, agentId, threadId }) {
85
86
  headers: { "Content-Type": "application/json" }
86
87
  });
87
88
  } catch (error) {
88
- console.error("Error stopping agent run:", error);
89
+ getRuntimeLogger(runtime).error({ err: error }, "Error stopping agent run");
89
90
  return new Response(JSON.stringify({
90
91
  error: "Failed to stop agent",
91
92
  message: error instanceof Error ? error.message : "Unknown error"
@@ -1 +1 @@
1
- {"version":3,"file":"handle-stop.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-stop.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime, resolveAgents } from \"../core/runtime\";\nimport { EventType } from \"@ag-ui/client\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\nimport { isHandlerResponse } from \"./shared/json-response\";\nimport { getPlatformErrorStatus } from \"./shared/intelligence-utils\";\nimport { resolveLocalThreadOwner } from \"./shared/thread-access\";\n\ninterface StopAgentParameters {\n request: Request;\n runtime: CopilotRuntimeLike;\n agentId: string;\n threadId: string;\n}\n\n/** Read `{ runId? }` from a stop request body; a 400 Response when the body is not a valid scope. */\nasync function parseStopScope(\n request: Request,\n): Promise<{ runId?: string } | Response> {\n try {\n const raw = await request.text();\n const body: unknown = raw.trim() ? JSON.parse(raw) : {};\n if (typeof body !== \"object\" || body === null || Array.isArray(body)) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n // Only `runId` is allowed. A misspelt key must not fall through to a\n // thread-wide stop, because a stop cannot be undone.\n if (Object.keys(body).some((key) => key !== \"runId\")) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n if (!(\"runId\" in body)) return {};\n if (typeof body.runId !== \"string\" || !body.runId.trim()) {\n return Response.json({ error: \"Invalid runId\" }, { status: 400 });\n }\n return { runId: body.runId };\n } catch {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n}\n\n/** Stop an active run after applying the runtime's application identity policy. */\nexport async function handleStopAgent({\n runtime,\n request,\n agentId,\n threadId,\n}: StopAgentParameters): Promise<Response> {\n try {\n // Parse the optional run scope for every runtime kind, from a clone so an\n // identity callback can still read the original body. No body or `{}`\n // keeps the thread-wide stop existing clients rely on.\n const scope = await parseStopScope(request.clone());\n if (isHandlerResponse(scope)) return scope;\n const { runId } = scope;\n let stopThreadId = threadId;\n let ownerId: string | undefined;\n if (!isIntelligenceRuntime(runtime)) {\n // A run on another identity's thread reports \"no active run\".\n const owner = await resolveLocalThreadOwner({\n runtime,\n request,\n operation: \"stop\",\n });\n if (isHandlerResponse(owner)) return owner;\n ownerId = owner;\n } else {\n const user = await resolveIntelligenceUser({ runtime, request });\n if (isHandlerResponse(user)) return user;\n try {\n const thread = await runtime.intelligence.getThread({\n threadId,\n userId: user.id,\n });\n if (!thread || typeof thread.id !== \"string\" || !thread.id.trim()) {\n return Response.json(\n { error: \"Invalid thread response\" },\n { status: 502 },\n );\n }\n if (thread.agentId !== undefined && thread.agentId !== agentId) {\n return Response.json(\n { error: \"Thread access denied\" },\n { status: 403 },\n );\n }\n stopThreadId = thread.id;\n } catch (error) {\n const status = getPlatformErrorStatus(error);\n return Response.json(\n { error: \"Thread access denied\" },\n { status: status && status >= 400 && status < 500 ? status : 502 },\n );\n }\n }\n const agents = await resolveAgents(runtime.agents, request);\n\n if (!agents[agentId]) {\n return new Response(\n JSON.stringify({\n error: \"Agent not found\",\n message: `Agent '${agentId}' does not exist`,\n }),\n {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n const stopped = await runtime.runner.stop({\n threadId: stopThreadId,\n ...(runId === undefined ? {} : { runId }),\n ...(ownerId === undefined ? {} : { ownerId }),\n });\n\n if (!stopped) {\n return new Response(\n JSON.stringify({\n stopped: false,\n message:\n runId === undefined\n ? `No active run for thread '${threadId}'.`\n : `Run '${runId}' is not the active run for thread '${threadId}'.`,\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n return new Response(\n JSON.stringify({\n stopped: true,\n interrupt: {\n type: EventType.RUN_ERROR,\n message: \"Run stopped by user\",\n code: \"STOPPED\",\n },\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n } catch (error) {\n console.error(\"Error stopping agent run:\", error);\n\n return new Response(\n JSON.stringify({\n error: \"Failed to stop 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":";;;;;;;;;AAgBA,eAAe,eACb,SACwC;AACxC,KAAI;EACF,MAAM,MAAM,MAAM,QAAQ,MAAM;EAChC,MAAM,OAAgB,IAAI,MAAM,GAAG,KAA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F;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CACF"}
1
+ {"version":3,"file":"handle-stop.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-stop.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime, resolveAgents } from \"../core/runtime\";\nimport { getRuntimeLogger } from \"../core/logger\";\nimport { EventType } from \"@ag-ui/client\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\nimport { isHandlerResponse } from \"./shared/json-response\";\nimport { getPlatformErrorStatus } from \"./shared/intelligence-utils\";\nimport { resolveLocalThreadOwner } from \"./shared/thread-access\";\n\ninterface StopAgentParameters {\n request: Request;\n runtime: CopilotRuntimeLike;\n agentId: string;\n threadId: string;\n}\n\n/** Read `{ runId? }` from a stop request body; a 400 Response when the body is not a valid scope. */\nasync function parseStopScope(\n request: Request,\n): Promise<{ runId?: string } | Response> {\n try {\n const raw = await request.text();\n const body: unknown = raw.trim() ? JSON.parse(raw) : {};\n if (typeof body !== \"object\" || body === null || Array.isArray(body)) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n // Only `runId` is allowed. A misspelt key must not fall through to a\n // thread-wide stop, because a stop cannot be undone.\n if (Object.keys(body).some((key) => key !== \"runId\")) {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n if (!(\"runId\" in body)) return {};\n if (typeof body.runId !== \"string\" || !body.runId.trim()) {\n return Response.json({ error: \"Invalid runId\" }, { status: 400 });\n }\n return { runId: body.runId };\n } catch {\n return Response.json({ error: \"Invalid stop request\" }, { status: 400 });\n }\n}\n\n/** Stop an active run after applying the runtime's application identity policy. */\nexport async function handleStopAgent({\n runtime,\n request,\n agentId,\n threadId,\n}: StopAgentParameters): Promise<Response> {\n try {\n // Parse the optional run scope for every runtime kind, from a clone so an\n // identity callback can still read the original body. No body or `{}`\n // keeps the thread-wide stop existing clients rely on.\n const scope = await parseStopScope(request.clone());\n if (isHandlerResponse(scope)) return scope;\n const { runId } = scope;\n let stopThreadId = threadId;\n let ownerId: string | undefined;\n if (!isIntelligenceRuntime(runtime)) {\n // A run on another identity's thread reports \"no active run\".\n const owner = await resolveLocalThreadOwner({\n runtime,\n request,\n operation: \"stop\",\n });\n if (isHandlerResponse(owner)) return owner;\n ownerId = owner;\n } else {\n const user = await resolveIntelligenceUser({ runtime, request });\n if (isHandlerResponse(user)) return user;\n try {\n const thread = await runtime.intelligence.getThread({\n threadId,\n userId: user.id,\n });\n if (!thread || typeof thread.id !== \"string\" || !thread.id.trim()) {\n return Response.json(\n { error: \"Invalid thread response\" },\n { status: 502 },\n );\n }\n if (thread.agentId !== undefined && thread.agentId !== agentId) {\n return Response.json(\n { error: \"Thread access denied\" },\n { status: 403 },\n );\n }\n stopThreadId = thread.id;\n } catch (error) {\n const status = getPlatformErrorStatus(error);\n return Response.json(\n { error: \"Thread access denied\" },\n { status: status && status >= 400 && status < 500 ? status : 502 },\n );\n }\n }\n const agents = await resolveAgents(runtime.agents, request);\n\n if (!agents[agentId]) {\n return new Response(\n JSON.stringify({\n error: \"Agent not found\",\n message: `Agent '${agentId}' does not exist`,\n }),\n {\n status: 404,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n const stopped = await runtime.runner.stop({\n threadId: stopThreadId,\n ...(runId === undefined ? {} : { runId }),\n ...(ownerId === undefined ? {} : { ownerId }),\n });\n\n if (!stopped) {\n return new Response(\n JSON.stringify({\n stopped: false,\n message:\n runId === undefined\n ? `No active run for thread '${threadId}'.`\n : `Run '${runId}' is not the active run for thread '${threadId}'.`,\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n }\n\n return new Response(\n JSON.stringify({\n stopped: true,\n interrupt: {\n type: EventType.RUN_ERROR,\n message: \"Run stopped by user\",\n code: \"STOPPED\",\n },\n }),\n {\n status: 200,\n headers: { \"Content-Type\": \"application/json\" },\n },\n );\n } catch (error) {\n getRuntimeLogger(runtime).error({ err: error }, \"Error stopping agent run\");\n\n return new Response(\n JSON.stringify({\n error: \"Failed to stop 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":";;;;;;;;;;AAiBA,eAAe,eACb,SACwC;AACxC,KAAI;EACF,MAAM,MAAM,MAAM,QAAQ,MAAM;EAChC,MAAM,OAAgB,IAAI,MAAM,GAAG,KAAK,MAAM,IAAI,GAAG,EAAE;AACvD,MAAI,OAAO,SAAS,YAAY,SAAS,QAAQ,MAAM,QAAQ,KAAK,CAClE,QAAO,SAAS,KAAK,EAAE,OAAO,wBAAwB,EAAE,EAAE,QAAQ,KAAK,CAAC;AAI1E,MAAI,OAAO,KAAK,KAAK,CAAC,MAAM,QAAQ,QAAQ,QAAQ,CAClD,QAAO,SAAS,KAAK,EAAE,OAAO,wBAAwB,EAAE,EAAE,QAAQ,KAAK,CAAC;AAE1E,MAAI,EAAE,WAAW,MAAO,QAAO,EAAE;AACjC,MAAI,OAAO,KAAK,UAAU,YAAY,CAAC,KAAK,MAAM,MAAM,CACtD,QAAO,SAAS,KAAK,EAAE,OAAO,iBAAiB,EAAE,EAAE,QAAQ,KAAK,CAAC;AAEnE,SAAO,EAAE,OAAO,KAAK,OAAO;SACtB;AACN,SAAO,SAAS,KAAK,EAAE,OAAO,wBAAwB,EAAE,EAAE,QAAQ,KAAK,CAAC;;;;AAK5E,eAAsB,gBAAgB,EACpC,SACA,SACA,SACA,YACyC;AACzC,KAAI;EAIF,MAAM,QAAQ,MAAM,eAAe,QAAQ,OAAO,CAAC;AACnD,MAAI,kBAAkB,MAAM,CAAE,QAAO;EACrC,MAAM,EAAE,UAAU;EAClB,IAAI,eAAe;EACnB,IAAI;AACJ,MAAI,CAAC,sBAAsB,QAAQ,EAAE;GAEnC,MAAM,QAAQ,MAAM,wBAAwB;IAC1C;IACA;IACA,WAAW;IACZ,CAAC;AACF,OAAI,kBA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ACT,KAAK,UAAU;GACb,SAAS;GACT,WAAW;IACT,MAAM,UAAU;IAChB,SAAS;IACT,MAAM;IACP;GACF,CAAC,EACF;GACE,QAAQ;GACR,SAAS,EAAE,gBAAgB,oBAAoB;GAChD,CACF;UACM,OAAO;AACd,mBAAiB,QAAQ,CAAC,MAAM,EAAE,KAAK,OAAO,EAAE,2BAA2B;AAE3E,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"}
@@ -1,5 +1,6 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
1
  const require_header_utils = require('./header-utils.cjs');
2
+ const require_logger = require('../core/logger.cjs');
3
+ const require_analytics_context = require('../intelligence-platform/analytics-context.cjs');
3
4
  const require_agent_utils = require('./shared/agent-utils.cjs');
4
5
  const require_sse_response = require('./shared/sse-response.cjs');
5
6
  let _copilotkit_shared = require("@copilotkit/shared");
@@ -43,8 +44,9 @@ async function handleSuggestAgent({ runtime, request, agentId }) {
43
44
  const agent = await require_agent_utils.cloneAgentForRequest(runtime, agentId, request);
44
45
  if (agent instanceof Response) return agent;
45
46
  agent.agentId = agentId;
46
- const input = await require_agent_utils.parseRunRequest(request);
47
- if (input instanceof Response) return input;
47
+ const parsed = await require_agent_utils.parseRunRequest(request, require_logger.getRuntimeLogger(runtime));
48
+ if (parsed instanceof Response) return parsed;
49
+ const { input } = require_analytics_context.takeAnalyticsContext(parsed);
48
50
  const headerCarryingAgent = agent;
49
51
  headerCarryingAgent.headers = require_header_utils.mergeForwardableHeaders(headerCarryingAgent.headers, request, runtime.forwardHeadersPolicy ?? require_header_utils.resolveForwardHeadersPolicy(void 0));
50
52
  agent.setMessages(input.messages);
@@ -54,6 +56,7 @@ async function handleSuggestAgent({ runtime, request, agentId }) {
54
56
  request,
55
57
  agentId,
56
58
  captureTelemetry: false,
59
+ logger: require_logger.getRuntimeLogger(runtime),
57
60
  keepAliveIntervalSeconds: runtime.sseKeepAliveIntervalSeconds,
58
61
  observableFactory: () => new rxjs.Observable((subscriber) => {
59
62
  const finalizer = (0, _copilotkit_shared.createRunEventFinalizer)();
@@ -1 +1 @@
1
- {"version":3,"file":"handle-suggest.cjs","names":["cloneAgentForRequest","parseRunRequest","mergeForwardableHeaders","resolveForwardHeadersPolicy","createSseEventResponse","Observable"],"sources":["../../../src/runtime/handlers/handle-suggest.ts"],"sourcesContent":["import type { AbstractAgent, BaseEvent } from \"@ag-ui/client\";\nimport { createRunEventFinalizer } from \"@copilotkit/shared\";\nimport { Observable } from \"rxjs\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport {\n mergeForwardableHeaders,\n resolveForwardHeadersPolicy,\n} from \"./header-utils\";\nimport { cloneAgentForRequest, parseRunRequest } from \"./shared/agent-utils\";\nimport { createSseEventResponse } from \"./shared/sse-response\";\n\n/**\n * Parameters for {@link handleSuggestAgent}.\n */\ninterface SuggestAgentParameters {\n /** The runtime whose registry the agent is resolved from. */\n runtime: CopilotRuntimeLike;\n /** The incoming `POST /agent/:agentId/suggest` request. */\n request: Request;\n /** The route-resolved agent id to run. */\n agentId: string;\n}\n\n/**\n * Stateless suggestion run.\n *\n * Executes the provider agent **directly** and streams its AG-UI events back as\n * SSE — the same wire format as `/agent/:id/run`, so the client consumes it with\n * the stock `HttpAgent` transport and chips fill in as the provider emits them.\n * It deliberately does not go through `runtime.runner`: the runner's\n * `run()` writes to a module-level store keyed by threadId (backing the SSE\n * runtime's local thread endpoints), which would leak the throwaway suggestion\n * thread. This handler runs the agent's event pipeline **without** that\n * persistence — no thread, lock, gateway, name-gen, or run telemetry — so\n * dynamic suggestions are side-effect-free in every runtime mode.\n *\n * The only per-request configuration it applies is forwarding the request's\n * allowlisted headers (`authorization` + `x-*`) onto the agent clone. It does\n * **not** attach any request middleware — no A2UI, no MCPApps, no\n * OpenGenerativeUI, no Intelligence enterprise-learning tools. The **client**\n * (the core suggestion engine) forces `toolChoice: copilotkitSuggest` in the\n * request body; this handler does not set tool choice itself and relies on it\n * being present in the incoming `input`. Given that forced tool choice, any\n * middleware-injected tools are dead weight, and MCPApps setup can incur a\n * `listTools` network round-trip per suggestion under `available: \"always\"` — a\n * side effect this path must never pay.\n *\n * When the client aborts the HTTP request (via its `AbortController`), the\n * server-side run is cancelled best-effort so an aborted suggestion does not\n * keep running a provider call to completion.\n *\n * @param params - The runtime, request, and resolved agent id.\n * @returns A `text/event-stream` `Response` of the provider agent's AG-UI events\n * on success, or the resolution `Response` (e.g. 404/400) when agent/body\n * resolution fails before streaming begins.\n */\nexport async function handleSuggestAgent({\n runtime,\n request,\n agentId,\n}: SuggestAgentParameters): Promise<Response> {\n const agent = await cloneAgentForRequest(runtime, agentId, request);\n if (agent instanceof Response) {\n return agent;\n }\n\n // Carry the registry key onto the clone so any framework relying on it during\n // the run sees the correct agentId.\n agent.agentId = agentId;\n\n const input = await parseRunRequest(request);\n if (input instanceof Response) {\n return input;\n }\n\n // Forward eligible inbound headers onto the clone under the runtime's resolved\n // forwarding policy (same helper the run handler uses: `authorization` /\n // custom `x-*`, infra/proxy/platform headers denylisted, server-set headers\n // winning on collision — #5712). Unlike a full agent run, the suggest path\n // intentionally attaches no middleware (see the handler docblock): the forced\n // `copilotkitSuggest` tool choice makes any middleware-injected tools dead\n // weight, and MCPApps setup can trigger a `listTools` network round-trip we\n // must never incur per suggestion.\n //\n // `AbstractAgent` doesn't declare `headers` on its base type (concrete\n // framework agents add it), so narrow to the header-carrying shape rather\n // than casting to `any`.\n const headerCarryingAgent = agent as AbstractAgent & {\n headers?: Record<string, string>;\n };\n headerCarryingAgent.headers = mergeForwardableHeaders(\n headerCarryingAgent.headers,\n request,\n runtime.forwardHeadersPolicy ?? resolveForwardHeadersPolicy(undefined),\n );\n\n agent.setMessages(input.messages);\n agent.setState(input.state);\n agent.threadId = input.threadId;\n\n // Stream the provider agent's events over SSE without persistence. This is\n // the runner's event pipeline (`agent.runAgent({ onEvent })` + terminal-event\n // finalization) minus the `GLOBAL_STORE` writes that would leak a thread.\n // `captureTelemetry: false` keeps suggestions out of run telemetry; omitting\n // `debugEventBus` keeps them out of the inspector's run trace.\n return createSseEventResponse({\n request,\n agentId,\n captureTelemetry: false,\n keepAliveIntervalSeconds: runtime.sseKeepAliveIntervalSeconds,\n observableFactory: () =>\n new Observable<BaseEvent>((subscriber) => {\n // Tracks open message/tool lifecycles so the missing terminal events\n // (an unclosed message/tool call, or a `RUN_FINISHED`) can be appended\n // — the same closure the runner applies — so the client sees a\n // well-formed AG-UI sequence. Nothing is persisted here, so only the\n // open ids are kept, never the streamed events themselves.\n const finalizer = createRunEventFinalizer();\n let settled = false;\n\n void agent\n .runAgent(input, {\n onEvent: ({ event }) => {\n finalizer.observe(event);\n subscriber.next(event);\n },\n })\n .then(() => {\n for (const event of finalizer.finalize({ stopRequested: false })) {\n subscriber.next(event);\n }\n settled = true;\n subscriber.complete();\n })\n .catch((error: unknown) => {\n settled = true;\n subscriber.error(error);\n });\n\n // Teardown fires when the response stream is torn down (client abort /\n // disconnect). Cancel the still-running provider call best-effort.\n return () => {\n if (!settled && typeof agent.abortRun === \"function\") {\n try {\n agent.abortRun();\n } catch {\n // best-effort — nothing actionable if aborting the run fails.\n }\n }\n };\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,eAAsB,mBAAmB,EACvC,SACA,SACA,WAC4C;CAC5C,MAAM,QAAQ,MAAMA,yCAAqB,SAAS,SAAS,QAAQ;AACnE,KAAI,iBAAiB,SACnB,QAAO;AAKT,OAAM,UAAU;CAEhB,MAAM,QAAQ,MAAMC,oCAAgB,QAAQ;AAC5C,KAAI,iBAAiB,SACnB,QAAO;CAeT,MAAM,sBAAsB;AAG5B,qBAAoB,UAAUC,6CAC5B,oBAAoB,SACpB,SACA,QAAQ,wBAAwBC,iDAA4B,OAAU,CACvE;AAED,OAAM,YAAY,MAAM,SAAS;AACjC,OAAM,SAAS,MAAM,MAAM;AAC3B,OAAM,WAAW,MAAM;AAOvB,QAAOC,4CAAuB;EAC5B;EACA;EACA,kBAAkB;EAClB,0BAA0B,QAAQ;EAClC,yBACE,IAAIC,iBAAuB,eAAe;GAMxC,MAAM,6DAAqC;GAC3C,IAAI,UAAU;AAEd,GAAK,MACF,SAAS,OAAO,EACf,UAAU,EAAE,YAAY;AACtB,cAAU,QAAQ,MAAM;AACxB,eAAW,KAAK,MAAM;MAEzB,CAAC,CACD,WAAW;AACV,SAAK,MAAM,SAAS,UAAU,SAAS,EAAE,eAAe,OAAO,CAAC,CAC9D,YAAW,KAAK,MAAM;AAExB,cAAU;AACV,eAAW,UAAU;KACrB,CACD,OAAO,UAAmB;AACzB,cAAU;AACV,eAAW,MAAM,MAAM;KACvB;AAIJ,gBAAa;AACX,QAAI,CAAC,WAAW,OAAO,MAAM,aAAa,WACxC,KAAI;AACF,WAAM,UAAU;YACV;;IAKZ;EACL,CAAC"}
1
+ {"version":3,"file":"handle-suggest.cjs","names":["cloneAgentForRequest","parseRunRequest","getRuntimeLogger","takeAnalyticsContext","mergeForwardableHeaders","resolveForwardHeadersPolicy","createSseEventResponse","Observable"],"sources":["../../../src/runtime/handlers/handle-suggest.ts"],"sourcesContent":["import type { AbstractAgent, BaseEvent } from \"@ag-ui/client\";\nimport { createRunEventFinalizer } from \"@copilotkit/shared\";\nimport { Observable } from \"rxjs\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { getRuntimeLogger } from \"../core/logger\";\nimport {\n mergeForwardableHeaders,\n resolveForwardHeadersPolicy,\n} from \"./header-utils\";\nimport { cloneAgentForRequest, parseRunRequest } from \"./shared/agent-utils\";\nimport { createSseEventResponse } from \"./shared/sse-response\";\nimport { takeAnalyticsContext } from \"../intelligence-platform/analytics-context\";\n\n/**\n * Parameters for {@link handleSuggestAgent}.\n */\ninterface SuggestAgentParameters {\n /** The runtime whose registry the agent is resolved from. */\n runtime: CopilotRuntimeLike;\n /** The incoming `POST /agent/:agentId/suggest` request. */\n request: Request;\n /** The route-resolved agent id to run. */\n agentId: string;\n}\n\n/**\n * Stateless suggestion run.\n *\n * Executes the provider agent **directly** and streams its AG-UI events back as\n * SSE — the same wire format as `/agent/:id/run`, so the client consumes it with\n * the stock `HttpAgent` transport and chips fill in as the provider emits them.\n * It deliberately does not go through `runtime.runner`: the runner's\n * `run()` writes to a module-level store keyed by threadId (backing the SSE\n * runtime's local thread endpoints), which would leak the throwaway suggestion\n * thread. This handler runs the agent's event pipeline **without** that\n * persistence — no thread, lock, gateway, name-gen, or run telemetry — so\n * dynamic suggestions are side-effect-free in every runtime mode.\n *\n * The only per-request configuration it applies is forwarding the request's\n * allowlisted headers (`authorization` + `x-*`) onto the agent clone. It does\n * **not** attach any request middleware — no A2UI, no MCPApps, no\n * OpenGenerativeUI, no Intelligence enterprise-learning tools. The **client**\n * (the core suggestion engine) forces `toolChoice: copilotkitSuggest` in the\n * request body; this handler does not set tool choice itself and relies on it\n * being present in the incoming `input`. Given that forced tool choice, any\n * middleware-injected tools are dead weight, and MCPApps setup can incur a\n * `listTools` network round-trip per suggestion under `available: \"always\"` — a\n * side effect this path must never pay.\n *\n * When the client aborts the HTTP request (via its `AbortController`), the\n * server-side run is cancelled best-effort so an aborted suggestion does not\n * keep running a provider call to completion.\n *\n * @param params - The runtime, request, and resolved agent id.\n * @returns A `text/event-stream` `Response` of the provider agent's AG-UI events\n * on success, or the resolution `Response` (e.g. 404/400) when agent/body\n * resolution fails before streaming begins.\n */\nexport async function handleSuggestAgent({\n runtime,\n request,\n agentId,\n}: SuggestAgentParameters): Promise<Response> {\n const agent = await cloneAgentForRequest(runtime, agentId, request);\n if (agent instanceof Response) {\n return agent;\n }\n\n // Carry the registry key onto the clone so any framework relying on it during\n // the run sees the correct agentId.\n agent.agentId = agentId;\n\n const parsed = await parseRunRequest(request, getRuntimeLogger(runtime));\n if (parsed instanceof Response) {\n return parsed;\n }\n // Suggestions are not Intelligence runs, so an app's analytics context goes\n // nowhere from here; it is only kept away from the agent.\n const { input } = takeAnalyticsContext(parsed);\n\n // Forward eligible inbound headers onto the clone under the runtime's resolved\n // forwarding policy (same helper the run handler uses: `authorization` /\n // custom `x-*`, infra/proxy/platform headers denylisted, server-set headers\n // winning on collision — #5712). Unlike a full agent run, the suggest path\n // intentionally attaches no middleware (see the handler docblock): the forced\n // `copilotkitSuggest` tool choice makes any middleware-injected tools dead\n // weight, and MCPApps setup can trigger a `listTools` network round-trip we\n // must never incur per suggestion.\n //\n // `AbstractAgent` doesn't declare `headers` on its base type (concrete\n // framework agents add it), so narrow to the header-carrying shape rather\n // than casting to `any`.\n const headerCarryingAgent = agent as AbstractAgent & {\n headers?: Record<string, string>;\n };\n headerCarryingAgent.headers = mergeForwardableHeaders(\n headerCarryingAgent.headers,\n request,\n runtime.forwardHeadersPolicy ?? resolveForwardHeadersPolicy(undefined),\n );\n\n agent.setMessages(input.messages);\n agent.setState(input.state);\n agent.threadId = input.threadId;\n\n // Stream the provider agent's events over SSE without persistence. This is\n // the runner's event pipeline (`agent.runAgent({ onEvent })` + terminal-event\n // finalization) minus the `GLOBAL_STORE` writes that would leak a thread.\n // `captureTelemetry: false` keeps suggestions out of run telemetry; omitting\n // `debugEventBus` keeps them out of the inspector's run trace.\n return createSseEventResponse({\n request,\n agentId,\n captureTelemetry: false,\n logger: getRuntimeLogger(runtime),\n keepAliveIntervalSeconds: runtime.sseKeepAliveIntervalSeconds,\n observableFactory: () =>\n new Observable<BaseEvent>((subscriber) => {\n // Tracks open message/tool lifecycles so the missing terminal events\n // (an unclosed message/tool call, or a `RUN_FINISHED`) can be appended\n // — the same closure the runner applies — so the client sees a\n // well-formed AG-UI sequence. Nothing is persisted here, so only the\n // open ids are kept, never the streamed events themselves.\n const finalizer = createRunEventFinalizer();\n let settled = false;\n\n void agent\n .runAgent(input, {\n onEvent: ({ event }) => {\n finalizer.observe(event);\n subscriber.next(event);\n },\n })\n .then(() => {\n for (const event of finalizer.finalize({ stopRequested: false })) {\n subscriber.next(event);\n }\n settled = true;\n subscriber.complete();\n })\n .catch((error: unknown) => {\n settled = true;\n subscriber.error(error);\n });\n\n // Teardown fires when the response stream is torn down (client abort /\n // disconnect). Cancel the still-running provider call best-effort.\n return () => {\n if (!settled && typeof agent.abortRun === \"function\") {\n try {\n agent.abortRun();\n } catch {\n // best-effort — nothing actionable if aborting the run fails.\n }\n }\n };\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,eAAsB,mBAAmB,EACvC,SACA,SACA,WAC4C;CAC5C,MAAM,QAAQ,MAAMA,yCAAqB,SAAS,SAAS,QAAQ;AACnE,KAAI,iBAAiB,SACnB,QAAO;AAKT,OAAM,UAAU;CAEhB,MAAM,SAAS,MAAMC,oCAAgB,SAASC,gCAAiB,QAAQ,CAAC;AACxE,KAAI,kBAAkB,SACpB,QAAO;CAIT,MAAM,EAAE,UAAUC,+CAAqB,OAAO;CAc9C,MAAM,sBAAsB;AAG5B,qBAAoB,UAAUC,6CAC5B,oBAAoB,SACpB,SACA,QAAQ,wBAAwBC,iDAA4B,OAAU,CACvE;AAED,OAAM,YAAY,MAAM,SAAS;AACjC,OAAM,SAAS,MAAM,MAAM;AAC3B,OAAM,WAAW,MAAM;AAOvB,QAAOC,4CAAuB;EAC5B;EACA;EACA,kBAAkB;EAClB,QAAQJ,gCAAiB,QAAQ;EACjC,0BAA0B,QAAQ;EAClC,yBACE,IAAIK,iBAAuB,eAAe;GAMxC,MAAM,6DAAqC;GAC3C,IAAI,UAAU;AAEd,GAAK,MACF,SAAS,OAAO,EACf,UAAU,EAAE,YAAY;AACtB,cAAU,QAAQ,MAAM;AACxB,eAAW,KAAK,MAAM;MAEzB,CAAC,CACD,WAAW;AACV,SAAK,MAAM,SAAS,UAAU,SAAS,EAAE,eAAe,OAAO,CAAC,CAC9D,YAAW,KAAK,MAAM;AAExB,cAAU;AACV,eAAW,UAAU;KACrB,CACD,OAAO,UAAmB;AACzB,cAAU;AACV,eAAW,MAAM,MAAM;KACvB;AAIJ,gBAAa;AACX,QAAI,CAAC,WAAW,OAAO,MAAM,aAAa,WACxC,KAAI;AACF,WAAM,UAAU;YACV;;IAKZ;EACL,CAAC"}
@@ -1,4 +1,6 @@
1
1
  import { mergeForwardableHeaders, resolveForwardHeadersPolicy } from "./header-utils.mjs";
2
+ import { getRuntimeLogger } from "../core/logger.mjs";
3
+ import { takeAnalyticsContext } from "../intelligence-platform/analytics-context.mjs";
2
4
  import { cloneAgentForRequest, parseRunRequest } from "./shared/agent-utils.mjs";
3
5
  import { createSseEventResponse } from "./shared/sse-response.mjs";
4
6
  import { createRunEventFinalizer } from "@copilotkit/shared";
@@ -42,8 +44,9 @@ async function handleSuggestAgent({ runtime, request, agentId }) {
42
44
  const agent = await cloneAgentForRequest(runtime, agentId, request);
43
45
  if (agent instanceof Response) return agent;
44
46
  agent.agentId = agentId;
45
- const input = await parseRunRequest(request);
46
- if (input instanceof Response) return input;
47
+ const parsed = await parseRunRequest(request, getRuntimeLogger(runtime));
48
+ if (parsed instanceof Response) return parsed;
49
+ const { input } = takeAnalyticsContext(parsed);
47
50
  const headerCarryingAgent = agent;
48
51
  headerCarryingAgent.headers = mergeForwardableHeaders(headerCarryingAgent.headers, request, runtime.forwardHeadersPolicy ?? resolveForwardHeadersPolicy(void 0));
49
52
  agent.setMessages(input.messages);
@@ -53,6 +56,7 @@ async function handleSuggestAgent({ runtime, request, agentId }) {
53
56
  request,
54
57
  agentId,
55
58
  captureTelemetry: false,
59
+ logger: getRuntimeLogger(runtime),
56
60
  keepAliveIntervalSeconds: runtime.sseKeepAliveIntervalSeconds,
57
61
  observableFactory: () => new Observable((subscriber) => {
58
62
  const finalizer = createRunEventFinalizer();
@@ -1 +1 @@
1
- {"version":3,"file":"handle-suggest.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-suggest.ts"],"sourcesContent":["import type { AbstractAgent, BaseEvent } from \"@ag-ui/client\";\nimport { createRunEventFinalizer } from \"@copilotkit/shared\";\nimport { Observable } from \"rxjs\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport {\n mergeForwardableHeaders,\n resolveForwardHeadersPolicy,\n} from \"./header-utils\";\nimport { cloneAgentForRequest, parseRunRequest } from \"./shared/agent-utils\";\nimport { createSseEventResponse } from \"./shared/sse-response\";\n\n/**\n * Parameters for {@link handleSuggestAgent}.\n */\ninterface SuggestAgentParameters {\n /** The runtime whose registry the agent is resolved from. */\n runtime: CopilotRuntimeLike;\n /** The incoming `POST /agent/:agentId/suggest` request. */\n request: Request;\n /** The route-resolved agent id to run. */\n agentId: string;\n}\n\n/**\n * Stateless suggestion run.\n *\n * Executes the provider agent **directly** and streams its AG-UI events back as\n * SSE — the same wire format as `/agent/:id/run`, so the client consumes it with\n * the stock `HttpAgent` transport and chips fill in as the provider emits them.\n * It deliberately does not go through `runtime.runner`: the runner's\n * `run()` writes to a module-level store keyed by threadId (backing the SSE\n * runtime's local thread endpoints), which would leak the throwaway suggestion\n * thread. This handler runs the agent's event pipeline **without** that\n * persistence — no thread, lock, gateway, name-gen, or run telemetry — so\n * dynamic suggestions are side-effect-free in every runtime mode.\n *\n * The only per-request configuration it applies is forwarding the request's\n * allowlisted headers (`authorization` + `x-*`) onto the agent clone. It does\n * **not** attach any request middleware — no A2UI, no MCPApps, no\n * OpenGenerativeUI, no Intelligence enterprise-learning tools. The **client**\n * (the core suggestion engine) forces `toolChoice: copilotkitSuggest` in the\n * request body; this handler does not set tool choice itself and relies on it\n * being present in the incoming `input`. Given that forced tool choice, any\n * middleware-injected tools are dead weight, and MCPApps setup can incur a\n * `listTools` network round-trip per suggestion under `available: \"always\"` — a\n * side effect this path must never pay.\n *\n * When the client aborts the HTTP request (via its `AbortController`), the\n * server-side run is cancelled best-effort so an aborted suggestion does not\n * keep running a provider call to completion.\n *\n * @param params - The runtime, request, and resolved agent id.\n * @returns A `text/event-stream` `Response` of the provider agent's AG-UI events\n * on success, or the resolution `Response` (e.g. 404/400) when agent/body\n * resolution fails before streaming begins.\n */\nexport async function handleSuggestAgent({\n runtime,\n request,\n agentId,\n}: SuggestAgentParameters): Promise<Response> {\n const agent = await cloneAgentForRequest(runtime, agentId, request);\n if (agent instanceof Response) {\n return agent;\n }\n\n // Carry the registry key onto the clone so any framework relying on it during\n // the run sees the correct agentId.\n agent.agentId = agentId;\n\n const input = await parseRunRequest(request);\n if (input instanceof Response) {\n return input;\n }\n\n // Forward eligible inbound headers onto the clone under the runtime's resolved\n // forwarding policy (same helper the run handler uses: `authorization` /\n // custom `x-*`, infra/proxy/platform headers denylisted, server-set headers\n // winning on collision — #5712). Unlike a full agent run, the suggest path\n // intentionally attaches no middleware (see the handler docblock): the forced\n // `copilotkitSuggest` tool choice makes any middleware-injected tools dead\n // weight, and MCPApps setup can trigger a `listTools` network round-trip we\n // must never incur per suggestion.\n //\n // `AbstractAgent` doesn't declare `headers` on its base type (concrete\n // framework agents add it), so narrow to the header-carrying shape rather\n // than casting to `any`.\n const headerCarryingAgent = agent as AbstractAgent & {\n headers?: Record<string, string>;\n };\n headerCarryingAgent.headers = mergeForwardableHeaders(\n headerCarryingAgent.headers,\n request,\n runtime.forwardHeadersPolicy ?? resolveForwardHeadersPolicy(undefined),\n );\n\n agent.setMessages(input.messages);\n agent.setState(input.state);\n agent.threadId = input.threadId;\n\n // Stream the provider agent's events over SSE without persistence. This is\n // the runner's event pipeline (`agent.runAgent({ onEvent })` + terminal-event\n // finalization) minus the `GLOBAL_STORE` writes that would leak a thread.\n // `captureTelemetry: false` keeps suggestions out of run telemetry; omitting\n // `debugEventBus` keeps them out of the inspector's run trace.\n return createSseEventResponse({\n request,\n agentId,\n captureTelemetry: false,\n keepAliveIntervalSeconds: runtime.sseKeepAliveIntervalSeconds,\n observableFactory: () =>\n new Observable<BaseEvent>((subscriber) => {\n // Tracks open message/tool lifecycles so the missing terminal events\n // (an unclosed message/tool call, or a `RUN_FINISHED`) can be appended\n // — the same closure the runner applies — so the client sees a\n // well-formed AG-UI sequence. Nothing is persisted here, so only the\n // open ids are kept, never the streamed events themselves.\n const finalizer = createRunEventFinalizer();\n let settled = false;\n\n void agent\n .runAgent(input, {\n onEvent: ({ event }) => {\n finalizer.observe(event);\n subscriber.next(event);\n },\n })\n .then(() => {\n for (const event of finalizer.finalize({ stopRequested: false })) {\n subscriber.next(event);\n }\n settled = true;\n subscriber.complete();\n })\n .catch((error: unknown) => {\n settled = true;\n subscriber.error(error);\n });\n\n // Teardown fires when the response stream is torn down (client abort /\n // disconnect). Cancel the still-running provider call best-effort.\n return () => {\n if (!settled && typeof agent.abortRun === \"function\") {\n try {\n agent.abortRun();\n } catch {\n // best-effort — nothing actionable if aborting the run fails.\n }\n }\n };\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAwDA,eAAsB,mBAAmB,EACvC,SACA,SACA,WAC4C;CAC5C,MAAM,QAAQ,MAAM,qBAAqB,SAAS,SAAS,QAAQ;AACnE,KAAI,iBAAiB,SACnB,QAAO;AAKT,OAAM,UAAU;CAEhB,MAAM,QAAQ,MAAM,gBAAgB,QAAQ;AAC5C,KAAI,iBAAiB,SACnB,QAAO;CAeT,MAAM,sBAAsB;AAG5B,qBAAoB,UAAU,wBAC5B,oBAAoB,SACpB,SACA,QAAQ,wBAAwB,4BAA4B,OAAU,CACvE;AAED,OAAM,YAAY,MAAM,SAAS;AACjC,OAAM,SAAS,MAAM,MAAM;AAC3B,OAAM,WAAW,MAAM;AAOvB,QAAO,uBAAuB;EAC5B;EACA;EACA,kBAAkB;EAClB,0BAA0B,QAAQ;EAClC,yBACE,IAAI,YAAuB,eAAe;GAMxC,MAAM,YAAY,yBAAyB;GAC3C,IAAI,UAAU;AAEd,GAAK,MACF,SAAS,OAAO,EACf,UAAU,EAAE,YAAY;AACtB,cAAU,QAAQ,MAAM;AACxB,eAAW,KAAK,MAAM;MAEzB,CAAC,CACD,WAAW;AACV,SAAK,MAAM,SAAS,UAAU,SAAS,EAAE,eAAe,OAAO,CAAC,CAC9D,YAAW,KAAK,MAAM;AAExB,cAAU;AACV,eAAW,UAAU;KACrB,CACD,OAAO,UAAmB;AACzB,cAAU;AACV,eAAW,MAAM,MAAM;KACvB;AAIJ,gBAAa;AACX,QAAI,CAAC,WAAW,OAAO,MAAM,aAAa,WACxC,KAAI;AACF,WAAM,UAAU;YACV;;IAKZ;EACL,CAAC"}
1
+ {"version":3,"file":"handle-suggest.mjs","names":[],"sources":["../../../src/runtime/handlers/handle-suggest.ts"],"sourcesContent":["import type { AbstractAgent, BaseEvent } from \"@ag-ui/client\";\nimport { createRunEventFinalizer } from \"@copilotkit/shared\";\nimport { Observable } from \"rxjs\";\nimport type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { getRuntimeLogger } from \"../core/logger\";\nimport {\n mergeForwardableHeaders,\n resolveForwardHeadersPolicy,\n} from \"./header-utils\";\nimport { cloneAgentForRequest, parseRunRequest } from \"./shared/agent-utils\";\nimport { createSseEventResponse } from \"./shared/sse-response\";\nimport { takeAnalyticsContext } from \"../intelligence-platform/analytics-context\";\n\n/**\n * Parameters for {@link handleSuggestAgent}.\n */\ninterface SuggestAgentParameters {\n /** The runtime whose registry the agent is resolved from. */\n runtime: CopilotRuntimeLike;\n /** The incoming `POST /agent/:agentId/suggest` request. */\n request: Request;\n /** The route-resolved agent id to run. */\n agentId: string;\n}\n\n/**\n * Stateless suggestion run.\n *\n * Executes the provider agent **directly** and streams its AG-UI events back as\n * SSE — the same wire format as `/agent/:id/run`, so the client consumes it with\n * the stock `HttpAgent` transport and chips fill in as the provider emits them.\n * It deliberately does not go through `runtime.runner`: the runner's\n * `run()` writes to a module-level store keyed by threadId (backing the SSE\n * runtime's local thread endpoints), which would leak the throwaway suggestion\n * thread. This handler runs the agent's event pipeline **without** that\n * persistence — no thread, lock, gateway, name-gen, or run telemetry — so\n * dynamic suggestions are side-effect-free in every runtime mode.\n *\n * The only per-request configuration it applies is forwarding the request's\n * allowlisted headers (`authorization` + `x-*`) onto the agent clone. It does\n * **not** attach any request middleware — no A2UI, no MCPApps, no\n * OpenGenerativeUI, no Intelligence enterprise-learning tools. The **client**\n * (the core suggestion engine) forces `toolChoice: copilotkitSuggest` in the\n * request body; this handler does not set tool choice itself and relies on it\n * being present in the incoming `input`. Given that forced tool choice, any\n * middleware-injected tools are dead weight, and MCPApps setup can incur a\n * `listTools` network round-trip per suggestion under `available: \"always\"` — a\n * side effect this path must never pay.\n *\n * When the client aborts the HTTP request (via its `AbortController`), the\n * server-side run is cancelled best-effort so an aborted suggestion does not\n * keep running a provider call to completion.\n *\n * @param params - The runtime, request, and resolved agent id.\n * @returns A `text/event-stream` `Response` of the provider agent's AG-UI events\n * on success, or the resolution `Response` (e.g. 404/400) when agent/body\n * resolution fails before streaming begins.\n */\nexport async function handleSuggestAgent({\n runtime,\n request,\n agentId,\n}: SuggestAgentParameters): Promise<Response> {\n const agent = await cloneAgentForRequest(runtime, agentId, request);\n if (agent instanceof Response) {\n return agent;\n }\n\n // Carry the registry key onto the clone so any framework relying on it during\n // the run sees the correct agentId.\n agent.agentId = agentId;\n\n const parsed = await parseRunRequest(request, getRuntimeLogger(runtime));\n if (parsed instanceof Response) {\n return parsed;\n }\n // Suggestions are not Intelligence runs, so an app's analytics context goes\n // nowhere from here; it is only kept away from the agent.\n const { input } = takeAnalyticsContext(parsed);\n\n // Forward eligible inbound headers onto the clone under the runtime's resolved\n // forwarding policy (same helper the run handler uses: `authorization` /\n // custom `x-*`, infra/proxy/platform headers denylisted, server-set headers\n // winning on collision — #5712). Unlike a full agent run, the suggest path\n // intentionally attaches no middleware (see the handler docblock): the forced\n // `copilotkitSuggest` tool choice makes any middleware-injected tools dead\n // weight, and MCPApps setup can trigger a `listTools` network round-trip we\n // must never incur per suggestion.\n //\n // `AbstractAgent` doesn't declare `headers` on its base type (concrete\n // framework agents add it), so narrow to the header-carrying shape rather\n // than casting to `any`.\n const headerCarryingAgent = agent as AbstractAgent & {\n headers?: Record<string, string>;\n };\n headerCarryingAgent.headers = mergeForwardableHeaders(\n headerCarryingAgent.headers,\n request,\n runtime.forwardHeadersPolicy ?? resolveForwardHeadersPolicy(undefined),\n );\n\n agent.setMessages(input.messages);\n agent.setState(input.state);\n agent.threadId = input.threadId;\n\n // Stream the provider agent's events over SSE without persistence. This is\n // the runner's event pipeline (`agent.runAgent({ onEvent })` + terminal-event\n // finalization) minus the `GLOBAL_STORE` writes that would leak a thread.\n // `captureTelemetry: false` keeps suggestions out of run telemetry; omitting\n // `debugEventBus` keeps them out of the inspector's run trace.\n return createSseEventResponse({\n request,\n agentId,\n captureTelemetry: false,\n logger: getRuntimeLogger(runtime),\n keepAliveIntervalSeconds: runtime.sseKeepAliveIntervalSeconds,\n observableFactory: () =>\n new Observable<BaseEvent>((subscriber) => {\n // Tracks open message/tool lifecycles so the missing terminal events\n // (an unclosed message/tool call, or a `RUN_FINISHED`) can be appended\n // — the same closure the runner applies — so the client sees a\n // well-formed AG-UI sequence. Nothing is persisted here, so only the\n // open ids are kept, never the streamed events themselves.\n const finalizer = createRunEventFinalizer();\n let settled = false;\n\n void agent\n .runAgent(input, {\n onEvent: ({ event }) => {\n finalizer.observe(event);\n subscriber.next(event);\n },\n })\n .then(() => {\n for (const event of finalizer.finalize({ stopRequested: false })) {\n subscriber.next(event);\n }\n settled = true;\n subscriber.complete();\n })\n .catch((error: unknown) => {\n settled = true;\n subscriber.error(error);\n });\n\n // Teardown fires when the response stream is torn down (client abort /\n // disconnect). Cancel the still-running provider call best-effort.\n return () => {\n if (!settled && typeof agent.abortRun === \"function\") {\n try {\n agent.abortRun();\n } catch {\n // best-effort — nothing actionable if aborting the run fails.\n }\n }\n };\n }),\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0DA,eAAsB,mBAAmB,EACvC,SACA,SACA,WAC4C;CAC5C,MAAM,QAAQ,MAAM,qBAAqB,SAAS,SAAS,QAAQ;AACnE,KAAI,iBAAiB,SACnB,QAAO;AAKT,OAAM,UAAU;CAEhB,MAAM,SAAS,MAAM,gBAAgB,SAAS,iBAAiB,QAAQ,CAAC;AACxE,KAAI,kBAAkB,SACpB,QAAO;CAIT,MAAM,EAAE,UAAU,qBAAqB,OAAO;CAc9C,MAAM,sBAAsB;AAG5B,qBAAoB,UAAU,wBAC5B,oBAAoB,SACpB,SACA,QAAQ,wBAAwB,4BAA4B,OAAU,CACvE;AAED,OAAM,YAAY,MAAM,SAAS;AACjC,OAAM,SAAS,MAAM,MAAM;AAC3B,OAAM,WAAW,MAAM;AAOvB,QAAO,uBAAuB;EAC5B;EACA;EACA,kBAAkB;EAClB,QAAQ,iBAAiB,QAAQ;EACjC,0BAA0B,QAAQ;EAClC,yBACE,IAAI,YAAuB,eAAe;GAMxC,MAAM,YAAY,yBAAyB;GAC3C,IAAI,UAAU;AAEd,GAAK,MACF,SAAS,OAAO,EACf,UAAU,EAAE,YAAY;AACtB,cAAU,QAAQ,MAAM;AACxB,eAAW,KAAK,MAAM;MAEzB,CAAC,CACD,WAAW;AACV,SAAK,MAAM,SAAS,UAAU,SAAS,EAAE,eAAe,OAAO,CAAC,CAC9D,YAAW,KAAK,MAAM;AAExB,cAAU;AACV,eAAW,UAAU;KACrB,CACD,OAAO,UAAmB;AACzB,cAAU;AACV,eAAW,MAAM,MAAM;KACvB;AAIJ,gBAAa;AACX,QAAI,CAAC,WAAW,OAAO,MAAM,aAAa,WACxC,KAAI;AACF,WAAM,UAAU;YACV;;IAKZ;EACL,CAAC"}
@@ -1,4 +1,3 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
1
  let _copilotkit_shared = require("@copilotkit/shared");
3
2
 
4
3
  //#region src/runtime/handlers/handle-transcribe.ts