@copilotkit/runtime 2.0.0-rc.5 → 2.0.0-rc.51

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 (417) hide show
  1. package/README.md +29 -4
  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 +17 -4
  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 +202 -30
  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 +202 -29
  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 +27 -27
  63. package/dist/index.d.cts +15 -15
  64. package/dist/index.d.mts +15 -15
  65. package/dist/index.mjs +9 -8
  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 +3 -2
  69. package/dist/node.d.cts +3 -3
  70. package/dist/node.d.mts +3 -3
  71. package/dist/node.mjs +3 -3
  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-cors.cjs.map +1 -1
  87. package/dist/runtime/core/fetch-cors.d.cts +2 -2
  88. package/dist/runtime/core/fetch-cors.d.cts.map +1 -1
  89. package/dist/runtime/core/fetch-cors.d.mts +2 -2
  90. package/dist/runtime/core/fetch-cors.d.mts.map +1 -1
  91. package/dist/runtime/core/fetch-cors.mjs.map +1 -1
  92. package/dist/runtime/core/fetch-handler.cjs +24 -13
  93. package/dist/runtime/core/fetch-handler.cjs.map +1 -1
  94. package/dist/runtime/core/fetch-handler.d.cts +35 -14
  95. package/dist/runtime/core/fetch-handler.d.cts.map +1 -1
  96. package/dist/runtime/core/fetch-handler.d.mts +35 -14
  97. package/dist/runtime/core/fetch-handler.d.mts.map +1 -1
  98. package/dist/runtime/core/fetch-handler.mjs +16 -5
  99. package/dist/runtime/core/fetch-handler.mjs.map +1 -1
  100. package/dist/runtime/core/hooks.cjs.map +1 -1
  101. package/dist/runtime/core/hooks.d.cts +5 -5
  102. package/dist/runtime/core/hooks.d.cts.map +1 -1
  103. package/dist/runtime/core/hooks.d.mts +5 -5
  104. package/dist/runtime/core/hooks.d.mts.map +1 -1
  105. package/dist/runtime/core/hooks.mjs.map +1 -1
  106. package/dist/runtime/core/learning.cjs.map +1 -1
  107. package/dist/runtime/core/learning.d.cts +9 -9
  108. package/dist/runtime/core/learning.d.cts.map +1 -1
  109. package/dist/runtime/core/learning.d.mts +8 -8
  110. package/dist/runtime/core/learning.d.mts.map +1 -1
  111. package/dist/runtime/core/learning.mjs.map +1 -1
  112. package/dist/runtime/core/logger.cjs +105 -14
  113. package/dist/runtime/core/logger.cjs.map +1 -1
  114. package/dist/runtime/core/logger.d.cts +26 -9
  115. package/dist/runtime/core/logger.d.cts.map +1 -1
  116. package/dist/runtime/core/logger.d.mts +26 -9
  117. package/dist/runtime/core/logger.d.mts.map +1 -1
  118. package/dist/runtime/core/logger.mjs +105 -12
  119. package/dist/runtime/core/logger.mjs.map +1 -1
  120. package/dist/runtime/core/middleware-sse-parser.cjs +3 -4
  121. package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -1
  122. package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -1
  123. package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -1
  124. package/dist/runtime/core/middleware-sse-parser.mjs +2 -2
  125. package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -1
  126. package/dist/runtime/core/middleware.cjs +5 -5
  127. package/dist/runtime/core/middleware.cjs.map +1 -1
  128. package/dist/runtime/core/middleware.d.cts +3 -3
  129. package/dist/runtime/core/middleware.d.cts.map +1 -1
  130. package/dist/runtime/core/middleware.d.mts +3 -3
  131. package/dist/runtime/core/middleware.d.mts.map +1 -1
  132. package/dist/runtime/core/middleware.mjs +4 -3
  133. package/dist/runtime/core/middleware.mjs.map +1 -1
  134. package/dist/runtime/core/package-info.cjs +1 -1
  135. package/dist/runtime/core/package-info.mjs +1 -1
  136. package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -1
  137. package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -1
  138. package/dist/runtime/core/runtime.cjs +29 -46
  139. package/dist/runtime/core/runtime.cjs.map +1 -1
  140. package/dist/runtime/core/runtime.d.cts +157 -91
  141. package/dist/runtime/core/runtime.d.cts.map +1 -1
  142. package/dist/runtime/core/runtime.d.mts +157 -91
  143. package/dist/runtime/core/runtime.d.mts.map +1 -1
  144. package/dist/runtime/core/runtime.mjs +27 -42
  145. package/dist/runtime/core/runtime.mjs.map +1 -1
  146. package/dist/runtime/endpoints/auto-start-channels.cjs +3 -4
  147. package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -1
  148. package/dist/runtime/endpoints/auto-start-channels.mjs +2 -2
  149. package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -1
  150. package/dist/runtime/endpoints/node-fetch-handler.cjs +11 -7
  151. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -1
  152. package/dist/runtime/endpoints/node-fetch-handler.d.cts +9 -5
  153. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -1
  154. package/dist/runtime/endpoints/node-fetch-handler.d.mts +9 -5
  155. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -1
  156. package/dist/runtime/endpoints/node-fetch-handler.mjs +10 -5
  157. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -1
  158. package/dist/runtime/endpoints/node.cjs +14 -4
  159. package/dist/runtime/endpoints/node.cjs.map +1 -1
  160. package/dist/runtime/endpoints/node.d.cts +39 -16
  161. package/dist/runtime/endpoints/node.d.cts.map +1 -1
  162. package/dist/runtime/endpoints/node.d.mts +39 -16
  163. package/dist/runtime/endpoints/node.d.mts.map +1 -1
  164. package/dist/runtime/endpoints/node.mjs +16 -7
  165. package/dist/runtime/endpoints/node.mjs.map +1 -1
  166. package/dist/runtime/event-transforms/index.d.cts +4 -0
  167. package/dist/runtime/event-transforms/index.d.mts +4 -0
  168. package/dist/runtime/event-transforms/index.mjs +5 -0
  169. package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs +277 -0
  170. package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
  171. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts +61 -0
  172. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
  173. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts +61 -0
  174. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
  175. package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs +276 -0
  176. package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
  177. package/dist/runtime/event-transforms/recorded-events.cjs +68 -0
  178. package/dist/runtime/event-transforms/recorded-events.cjs.map +1 -0
  179. package/dist/runtime/event-transforms/recorded-events.d.cts +27 -0
  180. package/dist/runtime/event-transforms/recorded-events.d.cts.map +1 -0
  181. package/dist/runtime/event-transforms/recorded-events.d.mts +27 -0
  182. package/dist/runtime/event-transforms/recorded-events.d.mts.map +1 -0
  183. package/dist/runtime/event-transforms/recorded-events.mjs +68 -0
  184. package/dist/runtime/event-transforms/recorded-events.mjs.map +1 -0
  185. package/dist/runtime/event-transforms/streaming-json-scanner.cjs +289 -0
  186. package/dist/runtime/event-transforms/streaming-json-scanner.cjs.map +1 -0
  187. package/dist/runtime/event-transforms/streaming-json-scanner.mjs +288 -0
  188. package/dist/runtime/event-transforms/streaming-json-scanner.mjs.map +1 -0
  189. package/dist/runtime/generative-ui/a2ui-v09-actions.cjs +106 -0
  190. package/dist/runtime/generative-ui/a2ui-v09-actions.cjs.map +1 -0
  191. package/dist/runtime/generative-ui/a2ui-v09-actions.mjs +106 -0
  192. package/dist/runtime/generative-ui/a2ui-v09-actions.mjs.map +1 -0
  193. package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs +422 -0
  194. package/dist/runtime/generative-ui/a2ui-v09-catalog.cjs.map +1 -0
  195. package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs +422 -0
  196. package/dist/runtime/generative-ui/a2ui-v09-catalog.mjs.map +1 -0
  197. package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs +84 -0
  198. package/dist/runtime/generative-ui/a2ui-v09-middleware.cjs.map +1 -0
  199. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts +41 -0
  200. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.cts.map +1 -0
  201. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts +41 -0
  202. package/dist/runtime/generative-ui/a2ui-v09-middleware.d.mts.map +1 -0
  203. package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs +83 -0
  204. package/dist/runtime/generative-ui/a2ui-v09-middleware.mjs.map +1 -0
  205. package/dist/runtime/generative-ui/a2ui-v09-operations.cjs +694 -0
  206. package/dist/runtime/generative-ui/a2ui-v09-operations.cjs.map +1 -0
  207. package/dist/runtime/generative-ui/a2ui-v09-operations.mjs +694 -0
  208. package/dist/runtime/generative-ui/a2ui-v09-operations.mjs.map +1 -0
  209. package/dist/runtime/generative-ui/generative-ui-middleware.cjs +0 -1
  210. package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -1
  211. package/dist/runtime/generative-ui/index.d.cts +1 -0
  212. package/dist/runtime/generative-ui/index.d.mts +1 -0
  213. package/dist/runtime/generative-ui/surface-writer.cjs +4 -5
  214. package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -1
  215. package/dist/runtime/generative-ui/surface-writer.d.cts +1 -1
  216. package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -1
  217. package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -1
  218. package/dist/runtime/generative-ui/surface-writer.mjs +5 -5
  219. package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -1
  220. package/dist/runtime/handlers/get-runtime-info.cjs +24 -6
  221. package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -1
  222. package/dist/runtime/handlers/get-runtime-info.mjs +25 -7
  223. package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -1
  224. package/dist/runtime/handlers/handle-connect.cjs +3 -8
  225. package/dist/runtime/handlers/handle-connect.cjs.map +1 -1
  226. package/dist/runtime/handlers/handle-connect.mjs +3 -8
  227. package/dist/runtime/handlers/handle-connect.mjs.map +1 -1
  228. package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -1
  229. package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -1
  230. package/dist/runtime/handlers/handle-inspector-learning.cjs +2 -3
  231. package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -1
  232. package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -1
  233. package/dist/runtime/handlers/handle-inspector-metadata.cjs +2 -3
  234. package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -1
  235. package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -1
  236. package/dist/runtime/handlers/handle-run.cjs +11 -16
  237. package/dist/runtime/handlers/handle-run.cjs.map +1 -1
  238. package/dist/runtime/handlers/handle-run.mjs +8 -12
  239. package/dist/runtime/handlers/handle-run.mjs.map +1 -1
  240. package/dist/runtime/handlers/handle-stop.cjs +5 -5
  241. package/dist/runtime/handlers/handle-stop.cjs.map +1 -1
  242. package/dist/runtime/handlers/handle-stop.mjs +2 -1
  243. package/dist/runtime/handlers/handle-stop.mjs.map +1 -1
  244. package/dist/runtime/handlers/handle-suggest.cjs +6 -3
  245. package/dist/runtime/handlers/handle-suggest.cjs.map +1 -1
  246. package/dist/runtime/handlers/handle-suggest.mjs +6 -2
  247. package/dist/runtime/handlers/handle-suggest.mjs.map +1 -1
  248. package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -1
  249. package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -1
  250. package/dist/runtime/handlers/handle-transcribe.cjs +0 -1
  251. package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -1
  252. package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -1
  253. package/dist/runtime/handlers/intelligence/annotate.cjs +8 -8
  254. package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -1
  255. package/dist/runtime/handlers/intelligence/annotate.mjs +5 -4
  256. package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -1
  257. package/dist/runtime/handlers/intelligence/connect.cjs +6 -2
  258. package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -1
  259. package/dist/runtime/handlers/intelligence/connect.mjs +6 -2
  260. package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -1
  261. package/dist/runtime/handlers/intelligence/memories.cjs +28 -23
  262. package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -1
  263. package/dist/runtime/handlers/intelligence/memories.mjs +12 -6
  264. package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -1
  265. package/dist/runtime/handlers/intelligence/run.cjs +38 -30
  266. package/dist/runtime/handlers/intelligence/run.cjs.map +1 -1
  267. package/dist/runtime/handlers/intelligence/run.mjs +37 -28
  268. package/dist/runtime/handlers/intelligence/run.mjs.map +1 -1
  269. package/dist/runtime/handlers/intelligence/thread-names.cjs +6 -5
  270. package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
  271. package/dist/runtime/handlers/intelligence/thread-names.mjs +3 -1
  272. package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -1
  273. package/dist/runtime/handlers/intelligence/threads.cjs +40 -31
  274. package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -1
  275. package/dist/runtime/handlers/intelligence/threads.mjs +18 -8
  276. package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -1
  277. package/dist/runtime/handlers/shared/agent-utils.cjs +50 -46
  278. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  279. package/dist/runtime/handlers/shared/agent-utils.mjs +47 -42
  280. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  281. package/dist/runtime/handlers/shared/cloud-telemetry.cjs +0 -1
  282. package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -1
  283. package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -1
  284. package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -1
  285. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +4 -3
  286. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
  287. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +4 -3
  288. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
  289. package/dist/runtime/handlers/shared/sse-response.cjs +77 -78
  290. package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -1
  291. package/dist/runtime/handlers/shared/sse-response.mjs +77 -77
  292. package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -1
  293. package/dist/runtime/handlers/shared/thread-access.cjs +4 -3
  294. package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -1
  295. package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -1
  296. package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -1
  297. package/dist/runtime/handlers/shared/thread-access.mjs +4 -3
  298. package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -1
  299. package/dist/runtime/handlers/sse/connect.cjs +2 -0
  300. package/dist/runtime/handlers/sse/connect.cjs.map +1 -1
  301. package/dist/runtime/handlers/sse/connect.mjs +2 -0
  302. package/dist/runtime/handlers/sse/connect.mjs.map +1 -1
  303. package/dist/runtime/handlers/sse/run.cjs +5 -2
  304. package/dist/runtime/handlers/sse/run.cjs.map +1 -1
  305. package/dist/runtime/handlers/sse/run.mjs +5 -2
  306. package/dist/runtime/handlers/sse/run.mjs.map +1 -1
  307. package/dist/runtime/index.cjs +29 -0
  308. package/dist/runtime/index.cjs.map +1 -0
  309. package/dist/runtime/index.d.cts +61 -15
  310. package/dist/runtime/index.d.cts.map +1 -1
  311. package/dist/runtime/index.d.mts +61 -15
  312. package/dist/runtime/index.d.mts.map +1 -1
  313. package/dist/runtime/index.mjs +27 -0
  314. package/dist/runtime/index.mjs.map +1 -0
  315. package/dist/runtime/intelligence-platform/analytics-context.cjs +84 -0
  316. package/dist/runtime/intelligence-platform/analytics-context.cjs.map +1 -0
  317. package/dist/runtime/intelligence-platform/analytics-context.mjs +83 -0
  318. package/dist/runtime/intelligence-platform/analytics-context.mjs.map +1 -0
  319. package/dist/runtime/intelligence-platform/client.cjs +30 -4
  320. package/dist/runtime/intelligence-platform/client.cjs.map +1 -1
  321. package/dist/runtime/intelligence-platform/client.d.cts +25 -2
  322. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -1
  323. package/dist/runtime/intelligence-platform/client.d.mts +25 -2
  324. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -1
  325. package/dist/runtime/intelligence-platform/client.mjs +30 -3
  326. package/dist/runtime/intelligence-platform/client.mjs.map +1 -1
  327. package/dist/runtime/intelligence-platform/learning-management.cjs +7 -8
  328. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -1
  329. package/dist/runtime/intelligence-platform/learning-management.mjs +7 -7
  330. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -1
  331. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +104 -110
  332. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -1
  333. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +8 -2
  334. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -1
  335. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +8 -2
  336. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -1
  337. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +104 -109
  338. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -1
  339. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +0 -1
  340. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -1
  341. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +1 -1
  342. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +1 -1
  343. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +22 -19
  344. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -1
  345. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -1
  346. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -1
  347. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +22 -19
  348. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -1
  349. package/dist/runtime/intelligence-platform/stop-run.cjs +50 -0
  350. package/dist/runtime/intelligence-platform/stop-run.cjs.map +1 -0
  351. package/dist/runtime/intelligence-platform/stop-run.mjs +50 -0
  352. package/dist/runtime/intelligence-platform/stop-run.mjs.map +1 -0
  353. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +3 -3
  354. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -1
  355. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +2 -1
  356. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -1
  357. package/dist/runtime/intelligence-platform/trajectories.cjs +2 -3
  358. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -1
  359. package/dist/runtime/intelligence-platform/trajectories.mjs +2 -2
  360. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -1
  361. package/dist/runtime/node.d.cts +2 -2
  362. package/dist/runtime/node.d.mts +2 -2
  363. package/dist/runtime/runner/agent-runner.cjs +0 -1
  364. package/dist/runtime/runner/agent-runner.cjs.map +1 -1
  365. package/dist/runtime/runner/agent-runner.d.cts +9 -0
  366. package/dist/runtime/runner/agent-runner.d.cts.map +1 -1
  367. package/dist/runtime/runner/agent-runner.d.mts +9 -0
  368. package/dist/runtime/runner/agent-runner.d.mts.map +1 -1
  369. package/dist/runtime/runner/agent-runner.mjs.map +1 -1
  370. package/dist/runtime/runner/in-memory.cjs +0 -1
  371. package/dist/runtime/runner/in-memory.cjs.map +1 -1
  372. package/dist/runtime/runner/index.d.cts +1 -1
  373. package/dist/runtime/runner/index.d.mts +1 -1
  374. package/dist/runtime/runner/index.mjs +1 -1
  375. package/dist/runtime/runner/intelligence.cjs +55 -9
  376. package/dist/runtime/runner/intelligence.cjs.map +1 -1
  377. package/dist/runtime/runner/intelligence.d.cts +12 -1
  378. package/dist/runtime/runner/intelligence.d.cts.map +1 -1
  379. package/dist/runtime/runner/intelligence.d.mts +12 -1
  380. package/dist/runtime/runner/intelligence.d.mts.map +1 -1
  381. package/dist/runtime/runner/intelligence.mjs +56 -10
  382. package/dist/runtime/runner/intelligence.mjs.map +1 -1
  383. package/dist/runtime/telemetry/disclosure.cjs +2 -3
  384. package/dist/runtime/telemetry/disclosure.cjs.map +1 -1
  385. package/dist/runtime/telemetry/disclosure.mjs +3 -3
  386. package/dist/runtime/telemetry/disclosure.mjs.map +1 -1
  387. package/dist/runtime/telemetry/events.d.cts +1 -1
  388. package/dist/runtime/telemetry/events.d.mts +1 -1
  389. package/dist/runtime/telemetry/instance-created.cjs +33 -12
  390. package/dist/runtime/telemetry/instance-created.cjs.map +1 -1
  391. package/dist/runtime/telemetry/instance-created.mjs +33 -12
  392. package/dist/runtime/telemetry/instance-created.mjs.map +1 -1
  393. package/dist/runtime/telemetry/telemetry-client.cjs +0 -5
  394. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -1
  395. package/dist/runtime/telemetry/telemetry-client.mjs +0 -4
  396. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -1
  397. package/dist/runtime/telemetry/telemetry-identity.cjs +0 -1
  398. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -1
  399. package/package.json +54 -29
  400. package/dist/_virtual/_rolldown/runtime.cjs +0 -29
  401. package/dist/agent/converters/index.d.mts +0 -2
  402. package/dist/agent/index.cjs +0 -1328
  403. package/dist/agent/index.cjs.map +0 -1
  404. package/dist/agent/index.d.cts +0 -467
  405. package/dist/agent/index.d.cts.map +0 -1
  406. package/dist/agent/index.d.mts +0 -468
  407. package/dist/agent/index.d.mts.map +0 -1
  408. package/dist/agent/index.mjs +0 -1318
  409. package/dist/agent/index.mjs.map +0 -1
  410. package/dist/agent/mcp-tool-names.cjs +0 -82
  411. package/dist/agent/mcp-tool-names.cjs.map +0 -1
  412. package/dist/agent/mcp-tool-names.mjs +0 -80
  413. package/dist/agent/mcp-tool-names.mjs.map +0 -1
  414. package/dist/agent/url-download.cjs.map +0 -1
  415. package/dist/agent/url-download.d.cts.map +0 -1
  416. package/dist/agent/url-download.d.mts.map +0 -1
  417. package/dist/agent/url-download.mjs.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"middleware-sse-parser.cjs","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"sourcesContent":["import { logger } from \"@copilotkit/shared\";\n\nexport interface ParsedSSEResult {\n messages: Message[];\n threadId?: string;\n runId?: string;\n}\n\n/** Minimal message shape reconstructed from AG-UI events. */\nexport interface Message {\n id: string;\n role: string;\n content?: string;\n toolCalls?: ToolCall[];\n toolCallId?: string;\n}\n\ninterface ToolCall {\n id: string;\n name: string;\n args: string;\n}\n\n/**\n * Parse a cloned SSE Response body into structured messages.\n * Returns empty results for non-SSE responses.\n */\nexport async function parseSSEResponse(\n response: Response,\n): Promise<ParsedSSEResult> {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"text/event-stream\")) {\n return { messages: [] };\n }\n\n let text: string;\n try {\n text = await response.text();\n } catch {\n logger.warn(\"Failed to read SSE response body in afterRequestMiddleware\");\n return { messages: [] };\n }\n\n if (!text.trim()) {\n return { messages: [] };\n }\n\n let threadId: string | undefined;\n let runId: string | undefined;\n const messagesById = new Map<string, Message>();\n const toolCallsById = new Map<string, ToolCall>();\n const toolCallParent = new Map<string, string>(); // toolCallId → messageId\n let snapshotMessages: Message[] | undefined;\n\n // Link a tool call to its assistant message the way @ag-ui/client does. A\n // tool-only turn streams no TEXT_MESSAGE_START, so the parent may not exist\n // yet; create it, keyed by toolCallId when parentMessageId is missing or\n // names a non-assistant message.\n const linkToolCallParent = (toolCallId: string, parentMessageId?: string) => {\n const parent = parentMessageId\n ? messagesById.get(parentMessageId)\n : undefined;\n const parentId =\n parentMessageId && (!parent || parent.role === \"assistant\")\n ? parentMessageId\n : toolCallId;\n if (!messagesById.has(parentId)) {\n messagesById.set(parentId, { id: parentId, role: \"assistant\" });\n }\n toolCallParent.set(toolCallId, parentId);\n };\n\n for (const line of text.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"data:\")) continue;\n\n let event: Record<string, any>;\n try {\n event = JSON.parse(trimmed.slice(5).trim());\n } catch {\n continue;\n }\n\n switch (event.type) {\n case \"RUN_STARTED\":\n threadId = event.threadId;\n runId = event.runId;\n break;\n\n case \"MESSAGES_SNAPSHOT\":\n if (Array.isArray(event.messages)) {\n snapshotMessages = event.messages;\n }\n break;\n\n case \"TEXT_MESSAGE_START\":\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: \"\",\n });\n break;\n\n case \"TEXT_MESSAGE_CONTENT\": {\n const msg = messagesById.get(event.messageId);\n if (msg) {\n msg.content = (msg.content ?? \"\") + (event.delta ?? \"\");\n }\n break;\n }\n\n case \"TEXT_MESSAGE_CHUNK\": {\n // Chunk format: combined start+content. First chunk creates the\n // message, subsequent chunks append delta to content.\n if (event.messageId) {\n const existing = messagesById.get(event.messageId);\n if (existing) {\n existing.content = (existing.content ?? \"\") + (event.delta ?? \"\");\n } else {\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: event.delta ?? \"\",\n });\n }\n }\n break;\n }\n\n case \"TOOL_CALL_START\": {\n const tc: ToolCall = {\n id: event.toolCallId,\n name: event.toolCallName,\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n break;\n }\n\n case \"TOOL_CALL_ARGS\": {\n const tc = toolCallsById.get(event.toolCallId);\n if (tc) {\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_CHUNK\": {\n // Chunk format: combined start+args. First chunk for a given\n // toolCallId creates the tool call, subsequent chunks append delta.\n if (event.toolCallId) {\n let tc = toolCallsById.get(event.toolCallId);\n if (!tc) {\n tc = {\n id: event.toolCallId,\n name: event.toolCallName ?? \"\",\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n }\n if (event.toolCallName) {\n tc.name = event.toolCallName;\n }\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_END\": {\n const tc = toolCallsById.get(event.toolCallId);\n const parentId = toolCallParent.get(event.toolCallId);\n if (tc && parentId) {\n const parent = messagesById.get(parentId);\n if (parent) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n break;\n }\n\n case \"TOOL_CALL_RESULT\": {\n // langchain-mcp-adapters may send content as an array of\n // {type:\"text\", text:string} objects instead of a plain string.\n let resultContent = event.content;\n if (Array.isArray(resultContent)) {\n resultContent = resultContent\n .filter((part: any) => part && typeof part.text === \"string\")\n .map((part: any) => part.text)\n .join(\"\");\n }\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: \"tool\",\n content: resultContent,\n toolCallId: event.toolCallId,\n });\n break;\n }\n }\n }\n\n // Attach any tool calls not yet linked to their parent message.\n // This handles TOOL_CALL_CHUNK flows which don't emit TOOL_CALL_END.\n for (const [toolCallId, tc] of toolCallsById) {\n const parentId = toolCallParent.get(toolCallId);\n if (!parentId) continue;\n const parent = messagesById.get(parentId);\n if (!parent) continue;\n const alreadyAttached = parent.toolCalls?.some((t) => t.id === tc.id);\n if (!alreadyAttached) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n\n // Prefer MESSAGES_SNAPSHOT if present (contains full history).\n // Otherwise reconstruct from individual events.\n const messages = snapshotMessages ?? [...messagesById.values()];\n\n return { messages, threadId, runId };\n}\n"],"mappings":";;;;;;;;AA2BA,eAAsB,iBACpB,UAC0B;AAE1B,KAAI,EADgB,SAAS,QAAQ,IAAI,eAAe,IAAI,IAC3C,SAAS,oBAAoB,CAC5C,QAAO,EAAE,U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cAAc,CAC9B,iBAAgB,cACb,QAAQ,SAAc,QAAQ,OAAO,KAAK,SAAS,SAAS,CAC5D,KAAK,SAAc,KAAK,KAAK,CAC7B,KAAK,GAAG;AAEb,iBAAa,IAAI,MAAM,WAAW;KAChC,IAAI,MAAM;KACV,MAAM;KACN,SAAS;KACT,YAAY,MAAM;KACnB,CAAC;AACF;;;;AAON,MAAK,MAAM,CAAC,YAAY,OAAO,eAAe;EAC5C,MAAM,WAAW,eAAe,IAAI,WAAW;AAC/C,MAAI,CAAC,SAAU;EACf,MAAM,SAAS,aAAa,IAAI,SAAS;AACzC,MAAI,CAAC,OAAQ;AAEb,MAAI,CADoB,OAAO,WAAW,MAAM,MAAM,EAAE,OAAO,GAAG,GAAG,EAC/C;AACpB,UAAO,YAAY,OAAO,aAAa,EAAE;AACzC,UAAO,UAAU,KAAK,GAAG;;;AAQ7B,QAAO;EAAE,UAFQ,oBAAoB,CAAC,GAAG,aAAa,QAAQ,CAAC;EAE5C;EAAU;EAAO"}
1
+ {"version":3,"file":"middleware-sse-parser.cjs","names":["getRuntimeLogger"],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"sourcesContent":["import { getRuntimeLogger } from \"./logger\";\nimport type { CopilotKitRuntimeLogger } from \"./logger\";\n\nexport interface ParsedSSEResult {\n messages: Message[];\n threadId?: string;\n runId?: string;\n}\n\n/** Minimal message shape reconstructed from AG-UI events. */\nexport interface Message {\n id: string;\n role: string;\n content?: string;\n toolCalls?: ToolCall[];\n toolCallId?: string;\n}\n\ninterface ToolCall {\n id: string;\n name: string;\n args: string;\n}\n\n/**\n * Parse a cloned SSE Response body into structured messages.\n * Returns empty results for non-SSE responses.\n */\nexport async function parseSSEResponse(\n response: Response,\n logger: CopilotKitRuntimeLogger = getRuntimeLogger(),\n): Promise<ParsedSSEResult> {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"text/event-stream\")) {\n return { messages: [] };\n }\n\n let text: string;\n try {\n text = await response.text();\n } catch {\n logger.warn(\"Failed to read SSE response body in afterRequestMiddleware\");\n return { messages: [] };\n }\n\n if (!text.trim()) {\n return { messages: [] };\n }\n\n let threadId: string | undefined;\n let runId: string | undefined;\n const messagesById = new Map<string, Message>();\n const toolCallsById = new Map<string, ToolCall>();\n const toolCallParent = new Map<string, string>(); // toolCallId → messageId\n let snapshotMessages: Message[] | undefined;\n\n // Link a tool call to its assistant message the way @ag-ui/client does. A\n // tool-only turn streams no TEXT_MESSAGE_START, so the parent may not exist\n // yet; create it, keyed by toolCallId when parentMessageId is missing or\n // names a non-assistant message.\n const linkToolCallParent = (toolCallId: string, parentMessageId?: string) => {\n const parent = parentMessageId\n ? messagesById.get(parentMessageId)\n : undefined;\n const parentId =\n parentMessageId && (!parent || parent.role === \"assistant\")\n ? parentMessageId\n : toolCallId;\n if (!messagesById.has(parentId)) {\n messagesById.set(parentId, { id: parentId, role: \"assistant\" });\n }\n toolCallParent.set(toolCallId, parentId);\n };\n\n for (const line of text.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"data:\")) continue;\n\n let event: Record<string, any>;\n try {\n event = JSON.parse(trimmed.slice(5).trim());\n } catch {\n continue;\n }\n\n switch (event.type) {\n case \"RUN_STARTED\":\n threadId = event.threadId;\n runId = event.runId;\n break;\n\n case \"MESSAGES_SNAPSHOT\":\n if (Array.isArray(event.messages)) {\n snapshotMessages = event.messages;\n }\n break;\n\n case \"TEXT_MESSAGE_START\":\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: \"\",\n });\n break;\n\n case \"TEXT_MESSAGE_CONTENT\": {\n const msg = messagesById.get(event.messageId);\n if (msg) {\n msg.content = (msg.content ?? \"\") + (event.delta ?? \"\");\n }\n break;\n }\n\n case \"TEXT_MESSAGE_CHUNK\": {\n // Chunk format: combined start+content. First chunk creates the\n // message, subsequent chunks append delta to content.\n if (event.messageId) {\n const existing = messagesById.get(event.messageId);\n if (existing) {\n existing.content = (existing.content ?? \"\") + (event.delta ?? \"\");\n } else {\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: event.delta ?? \"\",\n });\n }\n }\n break;\n }\n\n case \"TOOL_CALL_START\": {\n const tc: ToolCall = {\n id: event.toolCallId,\n name: event.toolCallName,\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n break;\n }\n\n case \"TOOL_CALL_ARGS\": {\n const tc = toolCallsById.get(event.toolCallId);\n if (tc) {\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_CHUNK\": {\n // Chunk format: combined start+args. First chunk for a given\n // toolCallId creates the tool call, subsequent chunks append delta.\n if (event.toolCallId) {\n let tc = toolCallsById.get(event.toolCallId);\n if (!tc) {\n tc = {\n id: event.toolCallId,\n name: event.toolCallName ?? \"\",\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n }\n if (event.toolCallName) {\n tc.name = event.toolCallName;\n }\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_END\": {\n const tc = toolCallsById.get(event.toolCallId);\n const parentId = toolCallParent.get(event.toolCallId);\n if (tc && parentId) {\n const parent = messagesById.get(parentId);\n if (parent) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n break;\n }\n\n case \"TOOL_CALL_RESULT\": {\n // langchain-mcp-adapters may send content as an array of\n // {type:\"text\", text:string} objects instead of a plain string.\n let resultContent = event.content;\n if (Array.isArray(resultContent)) {\n resultContent = resultContent\n .filter((part: any) => part && typeof part.text === \"string\")\n .map((part: any) => part.text)\n .join(\"\");\n }\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: \"tool\",\n content: resultContent,\n toolCallId: event.toolCallId,\n });\n break;\n }\n }\n }\n\n // Attach any tool calls not yet linked to their parent message.\n // This handles TOOL_CALL_CHUNK flows which don't emit TOOL_CALL_END.\n for (const [toolCallId, tc] of toolCallsById) {\n const parentId = toolCallParent.get(toolCallId);\n if (!parentId) continue;\n const parent = messagesById.get(parentId);\n if (!parent) continue;\n const alreadyAttached = parent.toolCalls?.some((t) => t.id === tc.id);\n if (!alreadyAttached) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n\n // Prefer MESSAGES_SNAPSHOT if present (contains full history).\n // Otherwise reconstruct from individual events.\n const messages = snapshotMessages ?? [...messagesById.values()];\n\n return { messages, threadId, runId };\n}\n"],"mappings":";;;;;;;AA4BA,eAAsB,iBACpB,UACA,SAAkCA,iCAAkB,EAC1B;AAE1B,KAAI,EADgB,SAAS,QAAQ,IAAI,eAAe,IAAI,IAC3C,SAAS,oBAAoB,CAC5C,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;AACJ,KAAI;AACF,SAAO,MAAM,SAAS,MAAM;SACtB;AACN,SAAO,KAAK,6DAA6D;AACzE,SAAO,EAAE,UAAU,EAAE,EAAE;;AAGzB,KAAI,CAAC,KAAK,MAAM,CACd,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;CACJ,IAAI;CACJ,MAAM,+BAAe,IAAI,KAAsB;CAC/C,MAAM,gCAAgB,IAAI,KAAuB;CACjD,MAAM,iCAAiB,IAAI,KAAqB;CAChD,IAAI;CAMJ,MAAM,sBAAsB,YAAoB,oBAA6B;EAC3E,MAAM,SAAS,kBACX,aAAa,IAAI,gBAAgB,GACjC;EACJ,MAAM,WACJ,oBAAoB,CAAC,UAAU,OAAO,SAAS,eAC3C,kBACA;AACN,MAAI,CAAC,aAAa,IAAI,SAAS,CAC7B,cAAa,IAAI,UAAU;GAAE,IAAI;GAAU,MAAM;GAAa,CAAC;AAEjE,iBAAe,IAAI,YAAY,SAAS;;AAG1C,MAAK,MAAM,QAAQ,KAAK,MAAM,KAAK,EAAE;EACnC,MAAM,UAAU,KAAK,MAAM;AAC3B,MAAI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;UASiB,OAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA,GAAY,QAAA;EACZ,UAAA;AAAA;AAAA,UAGQ,QAAA;EACR,EAAA;EACA,IAAA;EACA,IAAA;AAAA"}
1
+ {"version":3,"file":"middleware-sse-parser.d.cts","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"mappings":";;UAUiB,OAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA,GAAY,QAAA;EACZ,UAAA;AAAA;AAAA,UAGQ,QAAA;EACR,EAAA;EACA,IAAA;EACA,IAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"middleware-sse-parser.d.mts","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"mappings":";;UASiB,OAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA,GAAY,QAAA;EACZ,UAAA;AAAA;AAAA,UAGQ,QAAA;EACR,EAAA;EACA,IAAA;EACA,IAAA;AAAA"}
1
+ {"version":3,"file":"middleware-sse-parser.d.mts","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"mappings":";;UAUiB,OAAA;EACf,EAAA;EACA,IAAA;EACA,OAAA;EACA,SAAA,GAAY,QAAA;EACZ,UAAA;AAAA;AAAA,UAGQ,QAAA;EACR,EAAA;EACA,IAAA;EACA,IAAA;AAAA"}
@@ -1,11 +1,11 @@
1
- import { logger } from "@copilotkit/shared";
1
+ import { getRuntimeLogger } from "./logger.mjs";
2
2
 
3
3
  //#region src/runtime/core/middleware-sse-parser.ts
4
4
  /**
5
5
  * Parse a cloned SSE Response body into structured messages.
6
6
  * Returns empty results for non-SSE responses.
7
7
  */
8
- async function parseSSEResponse(response) {
8
+ async function parseSSEResponse(response, logger = getRuntimeLogger()) {
9
9
  if (!(response.headers.get("content-type") ?? "").includes("text/event-stream")) return { messages: [] };
10
10
  let text;
11
11
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"middleware-sse-parser.mjs","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"sourcesContent":["import { logger } from \"@copilotkit/shared\";\n\nexport interface ParsedSSEResult {\n messages: Message[];\n threadId?: string;\n runId?: string;\n}\n\n/** Minimal message shape reconstructed from AG-UI events. */\nexport interface Message {\n id: string;\n role: string;\n content?: string;\n toolCalls?: ToolCall[];\n toolCallId?: string;\n}\n\ninterface ToolCall {\n id: string;\n name: string;\n args: string;\n}\n\n/**\n * Parse a cloned SSE Response body into structured messages.\n * Returns empty results for non-SSE responses.\n */\nexport async function parseSSEResponse(\n response: Response,\n): Promise<ParsedSSEResult> {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"text/event-stream\")) {\n return { messages: [] };\n }\n\n let text: string;\n try {\n text = await response.text();\n } catch {\n logger.warn(\"Failed to read SSE response body in afterRequestMiddleware\");\n return { messages: [] };\n }\n\n if (!text.trim()) {\n return { messages: [] };\n }\n\n let threadId: string | undefined;\n let runId: string | undefined;\n const messagesById = new Map<string, Message>();\n const toolCallsById = new Map<string, ToolCall>();\n const toolCallParent = new Map<string, string>(); // toolCallId → messageId\n let snapshotMessages: Message[] | undefined;\n\n // Link a tool call to its assistant message the way @ag-ui/client does. A\n // tool-only turn streams no TEXT_MESSAGE_START, so the parent may not exist\n // yet; create it, keyed by toolCallId when parentMessageId is missing or\n // names a non-assistant message.\n const linkToolCallParent = (toolCallId: string, parentMessageId?: string) => {\n const parent = parentMessageId\n ? messagesById.get(parentMessageId)\n : undefined;\n const parentId =\n parentMessageId && (!parent || parent.role === \"assistant\")\n ? parentMessageId\n : toolCallId;\n if (!messagesById.has(parentId)) {\n messagesById.set(parentId, { id: parentId, role: \"assistant\" });\n }\n toolCallParent.set(toolCallId, parentId);\n };\n\n for (const line of text.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"data:\")) continue;\n\n let event: Record<string, any>;\n try {\n event = JSON.parse(trimmed.slice(5).trim());\n } catch {\n continue;\n }\n\n switch (event.type) {\n case \"RUN_STARTED\":\n threadId = event.threadId;\n runId = event.runId;\n break;\n\n case \"MESSAGES_SNAPSHOT\":\n if (Array.isArray(event.messages)) {\n snapshotMessages = event.messages;\n }\n break;\n\n case \"TEXT_MESSAGE_START\":\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: \"\",\n });\n break;\n\n case \"TEXT_MESSAGE_CONTENT\": {\n const msg = messagesById.get(event.messageId);\n if (msg) {\n msg.content = (msg.content ?? \"\") + (event.delta ?? \"\");\n }\n break;\n }\n\n case \"TEXT_MESSAGE_CHUNK\": {\n // Chunk format: combined start+content. First chunk creates the\n // message, subsequent chunks append delta to content.\n if (event.messageId) {\n const existing = messagesById.get(event.messageId);\n if (existing) {\n existing.content = (existing.content ?? \"\") + (event.delta ?? \"\");\n } else {\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: event.delta ?? \"\",\n });\n }\n }\n break;\n }\n\n case \"TOOL_CALL_START\": {\n const tc: ToolCall = {\n id: event.toolCallId,\n name: event.toolCallName,\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n break;\n }\n\n case \"TOOL_CALL_ARGS\": {\n const tc = toolCallsById.get(event.toolCallId);\n if (tc) {\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_CHUNK\": {\n // Chunk format: combined start+args. First chunk for a given\n // toolCallId creates the tool call, subsequent chunks append delta.\n if (event.toolCallId) {\n let tc = toolCallsById.get(event.toolCallId);\n if (!tc) {\n tc = {\n id: event.toolCallId,\n name: event.toolCallName ?? \"\",\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n }\n if (event.toolCallName) {\n tc.name = event.toolCallName;\n }\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_END\": {\n const tc = toolCallsById.get(event.toolCallId);\n const parentId = toolCallParent.get(event.toolCallId);\n if (tc && parentId) {\n const parent = messagesById.get(parentId);\n if (parent) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n break;\n }\n\n case \"TOOL_CALL_RESULT\": {\n // langchain-mcp-adapters may send content as an array of\n // {type:\"text\", text:string} objects instead of a plain string.\n let resultContent = event.content;\n if (Array.isArray(resultContent)) {\n resultContent = resultContent\n .filter((part: any) => part && typeof part.text === \"string\")\n .map((part: any) => part.text)\n .join(\"\");\n }\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: \"tool\",\n content: resultContent,\n toolCallId: event.toolCallId,\n });\n break;\n }\n }\n }\n\n // Attach any tool calls not yet linked to their parent message.\n // This handles TOOL_CALL_CHUNK flows which don't emit TOOL_CALL_END.\n for (const [toolCallId, tc] of toolCallsById) {\n const parentId = toolCallParent.get(toolCallId);\n if (!parentId) continue;\n const parent = messagesById.get(parentId);\n if (!parent) continue;\n const alreadyAttached = parent.toolCalls?.some((t) => t.id === tc.id);\n if (!alreadyAttached) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n\n // Prefer MESSAGES_SNAPSHOT if present (contains full history).\n // Otherwise reconstruct from individual events.\n const messages = snapshotMessages ?? [...messagesById.values()];\n\n return { messages, threadId, runId };\n}\n"],"mappings":";;;;;;;AA2BA,eAAsB,iBACpB,UAC0B;AAE1B,KAAI,EADgB,SAAS,QAAQ,IAAI,eAAe,IAAI,IAC3C,SAAS,oBAAoB,CAC5C,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;AACJ,KAAI;AACF,SAAO,MAAM,SAAS,MAAM;SACtB;AACN,SAAO,KAAK,6DAA6D;AACzE,SAAO,EAAE,UAAU,EAAE,EAAE;;AAGzB,KAAI,CAAC,KAAK,MAAM,CACd,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;CACJ,IAAI;CACJ,MAAM,+BAAe,IAAI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Y,OAAO,eAAe;EAC5C,MAAM,WAAW,eAAe,IAAI,WAAW;AAC/C,MAAI,CAAC,SAAU;EACf,MAAM,SAAS,aAAa,IAAI,SAAS;AACzC,MAAI,CAAC,OAAQ;AAEb,MAAI,CADoB,OAAO,WAAW,MAAM,MAAM,EAAE,OAAO,GAAG,GAAG,EAC/C;AACpB,UAAO,YAAY,OAAO,aAAa,EAAE;AACzC,UAAO,UAAU,KAAK,GAAG;;;AAQ7B,QAAO;EAAE,UAFQ,oBAAoB,CAAC,GAAG,aAAa,QAAQ,CAAC;EAE5C;EAAU;EAAO"}
1
+ {"version":3,"file":"middleware-sse-parser.mjs","names":[],"sources":["../../../src/runtime/core/middleware-sse-parser.ts"],"sourcesContent":["import { getRuntimeLogger } from \"./logger\";\nimport type { CopilotKitRuntimeLogger } from \"./logger\";\n\nexport interface ParsedSSEResult {\n messages: Message[];\n threadId?: string;\n runId?: string;\n}\n\n/** Minimal message shape reconstructed from AG-UI events. */\nexport interface Message {\n id: string;\n role: string;\n content?: string;\n toolCalls?: ToolCall[];\n toolCallId?: string;\n}\n\ninterface ToolCall {\n id: string;\n name: string;\n args: string;\n}\n\n/**\n * Parse a cloned SSE Response body into structured messages.\n * Returns empty results for non-SSE responses.\n */\nexport async function parseSSEResponse(\n response: Response,\n logger: CopilotKitRuntimeLogger = getRuntimeLogger(),\n): Promise<ParsedSSEResult> {\n const contentType = response.headers.get(\"content-type\") ?? \"\";\n if (!contentType.includes(\"text/event-stream\")) {\n return { messages: [] };\n }\n\n let text: string;\n try {\n text = await response.text();\n } catch {\n logger.warn(\"Failed to read SSE response body in afterRequestMiddleware\");\n return { messages: [] };\n }\n\n if (!text.trim()) {\n return { messages: [] };\n }\n\n let threadId: string | undefined;\n let runId: string | undefined;\n const messagesById = new Map<string, Message>();\n const toolCallsById = new Map<string, ToolCall>();\n const toolCallParent = new Map<string, string>(); // toolCallId → messageId\n let snapshotMessages: Message[] | undefined;\n\n // Link a tool call to its assistant message the way @ag-ui/client does. A\n // tool-only turn streams no TEXT_MESSAGE_START, so the parent may not exist\n // yet; create it, keyed by toolCallId when parentMessageId is missing or\n // names a non-assistant message.\n const linkToolCallParent = (toolCallId: string, parentMessageId?: string) => {\n const parent = parentMessageId\n ? messagesById.get(parentMessageId)\n : undefined;\n const parentId =\n parentMessageId && (!parent || parent.role === \"assistant\")\n ? parentMessageId\n : toolCallId;\n if (!messagesById.has(parentId)) {\n messagesById.set(parentId, { id: parentId, role: \"assistant\" });\n }\n toolCallParent.set(toolCallId, parentId);\n };\n\n for (const line of text.split(\"\\n\")) {\n const trimmed = line.trim();\n if (!trimmed.startsWith(\"data:\")) continue;\n\n let event: Record<string, any>;\n try {\n event = JSON.parse(trimmed.slice(5).trim());\n } catch {\n continue;\n }\n\n switch (event.type) {\n case \"RUN_STARTED\":\n threadId = event.threadId;\n runId = event.runId;\n break;\n\n case \"MESSAGES_SNAPSHOT\":\n if (Array.isArray(event.messages)) {\n snapshotMessages = event.messages;\n }\n break;\n\n case \"TEXT_MESSAGE_START\":\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: \"\",\n });\n break;\n\n case \"TEXT_MESSAGE_CONTENT\": {\n const msg = messagesById.get(event.messageId);\n if (msg) {\n msg.content = (msg.content ?? \"\") + (event.delta ?? \"\");\n }\n break;\n }\n\n case \"TEXT_MESSAGE_CHUNK\": {\n // Chunk format: combined start+content. First chunk creates the\n // message, subsequent chunks append delta to content.\n if (event.messageId) {\n const existing = messagesById.get(event.messageId);\n if (existing) {\n existing.content = (existing.content ?? \"\") + (event.delta ?? \"\");\n } else {\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: event.role ?? \"assistant\",\n content: event.delta ?? \"\",\n });\n }\n }\n break;\n }\n\n case \"TOOL_CALL_START\": {\n const tc: ToolCall = {\n id: event.toolCallId,\n name: event.toolCallName,\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n break;\n }\n\n case \"TOOL_CALL_ARGS\": {\n const tc = toolCallsById.get(event.toolCallId);\n if (tc) {\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_CHUNK\": {\n // Chunk format: combined start+args. First chunk for a given\n // toolCallId creates the tool call, subsequent chunks append delta.\n if (event.toolCallId) {\n let tc = toolCallsById.get(event.toolCallId);\n if (!tc) {\n tc = {\n id: event.toolCallId,\n name: event.toolCallName ?? \"\",\n args: \"\",\n };\n toolCallsById.set(event.toolCallId, tc);\n linkToolCallParent(event.toolCallId, event.parentMessageId);\n }\n if (event.toolCallName) {\n tc.name = event.toolCallName;\n }\n tc.args += event.delta ?? \"\";\n }\n break;\n }\n\n case \"TOOL_CALL_END\": {\n const tc = toolCallsById.get(event.toolCallId);\n const parentId = toolCallParent.get(event.toolCallId);\n if (tc && parentId) {\n const parent = messagesById.get(parentId);\n if (parent) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n break;\n }\n\n case \"TOOL_CALL_RESULT\": {\n // langchain-mcp-adapters may send content as an array of\n // {type:\"text\", text:string} objects instead of a plain string.\n let resultContent = event.content;\n if (Array.isArray(resultContent)) {\n resultContent = resultContent\n .filter((part: any) => part && typeof part.text === \"string\")\n .map((part: any) => part.text)\n .join(\"\");\n }\n messagesById.set(event.messageId, {\n id: event.messageId,\n role: \"tool\",\n content: resultContent,\n toolCallId: event.toolCallId,\n });\n break;\n }\n }\n }\n\n // Attach any tool calls not yet linked to their parent message.\n // This handles TOOL_CALL_CHUNK flows which don't emit TOOL_CALL_END.\n for (const [toolCallId, tc] of toolCallsById) {\n const parentId = toolCallParent.get(toolCallId);\n if (!parentId) continue;\n const parent = messagesById.get(parentId);\n if (!parent) continue;\n const alreadyAttached = parent.toolCalls?.some((t) => t.id === tc.id);\n if (!alreadyAttached) {\n parent.toolCalls = parent.toolCalls ?? [];\n parent.toolCalls.push(tc);\n }\n }\n\n // Prefer MESSAGES_SNAPSHOT if present (contains full history).\n // Otherwise reconstruct from individual events.\n const messages = snapshotMessages ?? [...messagesById.values()];\n\n return { messages, threadId, runId };\n}\n"],"mappings":";;;;;;;AA4BA,eAAsB,iBACpB,UACA,SAAkC,kBAAkB,EAC1B;AAE1B,KAAI,EADgB,SAAS,QAAQ,IAAI,eAAe,IAAI,IAC3C,SAAS,oBAAoB,CAC5C,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;AACJ,KAAI;AACF,SAAO,MAAM,SAAS,MAAM;SACtB;AACN,SAAO,KAAK,6DAA6D;AACzE,SAAO,EAAE,UAAU,EAAE,EAAE;;AAGzB,KAAI,CAAC,KAAK,MAAM,CACd,QAAO,EAAE,UAAU,EAAE,EAAE;CAGzB,IAAI;CACJ,IAAI;CACJ,MAAM,+BAAe,IAAI,KAAsB;CAC/C,MAAM,gCAAgB,IAAI,KAAuB;CACjD,MAAM,iCAAiB,IAAI,KAAqB;CAChD,IAAI;CAMJ,MAAM,sBAAsB,YAAoB,oBAA6B;EAC3E,MAAM,SAAS,kBACX,aAAa,IAAI,gBAAgB,GACjC;EACJ,MAAM,WACJ,oBAAoB,CAAC,UAAU,OAAO,SAAS,eAC3C,kBACA;AACN,MAAI,CAAC,aAAa,IAAI,SAAS,CAC7B,cAAa,IAAI,UAAU;GAAE,IAAI;GAAU,MAAM;GAAa,CAAC;AAEjE,iBAAe,IAAI,YAAY,SAAS;;AAG1C,MAAK,MAAM,QAAQ,KAAK,MAAM,KAAK,EAAE;EACnC,MAAM,UAAU,KAAK,MAAM;AAC3B,MAAI,CAAC,QAAQ,WAAW,QAAQ,CAAE;EAElC,IAAI;AACJ,MAAI;AACF,WAAQ,KAAK,MAAM,QAAQ,MAAM,EAAE,CAAC,MAAM,CAAC;UACrC;AACN;;AAGF,UAAQ,MAAM,MAAd;GACE,KAAK;AACH,eAAW,MAAM;AACjB,YAAQ,MAAM;AACd;GAEF,KAAK;AACH,QAAI,MAAM,QAAQ,MAAM,SAAS,CAC/B,oBAAm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MAAM,WAAW;AACrD,QAAI,MAAM,UAAU;KAClB,MAAM,SAAS,aAAa,IAAI,SAAS;AACzC,SAAI,QAAQ;AACV,aAAO,YAAY,OAAO,aAAa,EAAE;AACzC,aAAO,UAAU,KAAK,GAAG;;;AAG7B;;GAGF,KAAK,oBAAoB;IAGvB,IAAI,gBAAgB,MAAM;AAC1B,QAAI,MAAM,QAAQ,cAAc,CAC9B,iBAAgB,cACb,QAAQ,SAAc,QAAQ,OAAO,KAAK,SAAS,SAAS,CAC5D,KAAK,SAAc,KAAK,KAAK,CAC7B,KAAK,GAAG;AAEb,iBAAa,IAAI,MAAM,WAAW;KAChC,IAAI,MAAM;KACV,MAAM;KACN,SAAS;KACT,YAAY,MAAM;KACnB,CAAC;AACF;;;;AAON,MAAK,MAAM,CAAC,YAAY,OAAO,eAAe;EAC5C,MAAM,WAAW,eAAe,IAAI,WAAW;AAC/C,MAAI,CAAC,SAAU;EACf,MAAM,SAAS,aAAa,IAAI,SAAS;AACzC,MAAI,CAAC,OAAQ;AAEb,MAAI,CADoB,OAAO,WAAW,MAAM,MAAM,EAAE,OAAO,GAAG,GAAG,EAC/C;AACpB,UAAO,YAAY,OAAO,aAAa,EAAE;AACzC,UAAO,UAAU,KAAK,GAAG;;;AAQ7B,QAAO;EAAE,UAFQ,oBAAoB,CAAC,GAAG,aAAa,QAAQ,CAAC;EAE5C;EAAU;EAAO"}
@@ -1,6 +1,5 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
1
+ const require_logger = require('./logger.cjs');
2
2
  const require_middleware_sse_parser = require('./middleware-sse-parser.cjs');
3
- let _copilotkit_shared = require("@copilotkit/shared");
4
3
 
5
4
  //#region src/runtime/core/middleware.ts
6
5
  async function callBeforeRequestMiddleware({ runtime, request, path }) {
@@ -11,12 +10,13 @@ async function callBeforeRequestMiddleware({ runtime, request, path }) {
11
10
  request,
12
11
  path
13
12
  });
14
- _copilotkit_shared.logger.warn({ mw }, "Unsupported beforeRequestMiddleware value – skipped");
13
+ require_logger.getRuntimeLogger(runtime).warn({ mw }, "Unsupported beforeRequestMiddleware value – skipped");
15
14
  }
16
15
  async function callAfterRequestMiddleware({ runtime, response, path }) {
17
16
  const mw = runtime.afterRequestMiddleware;
18
17
  if (!mw) return;
19
- const { messages, threadId, runId } = await require_middleware_sse_parser.parseSSEResponse(response);
18
+ const logger = require_logger.getRuntimeLogger(runtime);
19
+ const { messages, threadId, runId } = await require_middleware_sse_parser.parseSSEResponse(response, logger);
20
20
  if (typeof mw === "function") return mw({
21
21
  runtime,
22
22
  response,
@@ -25,7 +25,7 @@ async function callAfterRequestMiddleware({ runtime, response, path }) {
25
25
  threadId,
26
26
  runId
27
27
  });
28
- _copilotkit_shared.logger.warn({ mw }, "Unsupported afterRequestMiddleware value – skipped");
28
+ logger.warn({ mw }, "Unsupported afterRequestMiddleware value – skipped");
29
29
  }
30
30
 
31
31
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.cjs","names":["parseSSEResponse"],"sources":["../../../src/runtime/core/middleware.ts"],"sourcesContent":["/**\n * Middleware support for CopilotKit Runtime.\n *\n * A middleware hook can be provided as either:\n * 1. A **callback function** executed in-process.\n * 2. A **webhook URL** (http/https). The runtime will `POST` a JSON payload\n * to the URL and, for *before* hooks, accept an optional modified\n * `Request` object in the response body.\n *\n * Two lifecycle hooks are available:\n * • `BEFORE_REQUEST` – runs *before* the request handler.\n * • `AFTER_REQUEST` – runs *after* the handler returns a `Response`.\n */\n\nimport type { CopilotRuntimeLike } from \"./runtime\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport { logger } from \"@copilotkit/shared\";\nimport { parseSSEResponse } from \"./middleware-sse-parser\";\nimport type { Message } from \"./middleware-sse-parser\";\n\n/* ------------------------------------------------------------------------------------------------\n * Public types\n * --------------------------------------------------------------------------------------------- */\n\nexport interface BeforeRequestMiddlewareParameters {\n runtime: CopilotRuntimeLike;\n request: Request;\n path: string;\n}\nexport interface AfterRequestMiddlewareParameters {\n runtime: CopilotRuntimeLike;\n response: Response;\n path: string;\n /** Reconstructed messages from the SSE stream (empty for non-SSE responses). */\n messages?: Message[];\n /** Thread ID extracted from the RUN_STARTED event. */\n threadId?: string;\n /** Run ID extracted from the RUN_STARTED event. */\n runId?: string;\n}\n\nexport type BeforeRequestMiddlewareFn = (\n params: BeforeRequestMiddlewareParameters,\n) => MaybePromise<Request | void>;\nexport type AfterRequestMiddlewareFn = (\n params: AfterRequestMiddlewareParameters,\n) => MaybePromise<void>;\n\n/**\n * A middleware value can be either a callback function or a webhook URL.\n */\nexport type BeforeRequestMiddleware = BeforeRequestMiddlewareFn;\nexport type AfterRequestMiddleware = AfterRequestMiddlewareFn;\n\n/** Lifecycle events emitted to webhook middleware. */\nexport enum CopilotKitMiddlewareEvent {\n BeforeRequest = \"BEFORE_REQUEST\",\n AfterRequest = \"AFTER_REQUEST\",\n}\n\n/** Stages used by the Middleware Webhook Protocol */\n/** Stages used by the CopilotKit webhook protocol */\nexport enum WebhookStage {\n BeforeRequest = \"before_request\",\n AfterRequest = \"after_request\",\n}\n\n/* ------------------------------------------------------------------------------------------------\n * Internal helpers – (de)serialisation\n * --------------------------------------------------------------------------------------------- */\n\nexport async function callBeforeRequestMiddleware({\n runtime,\n request,\n path,\n}: BeforeRequestMiddlewareParameters): Promise<Request | void> {\n const mw = runtime.beforeRequestMiddleware;\n if (!mw) return;\n\n // Function-based middleware (in-process)\n if (typeof mw === \"function\") {\n return (mw as BeforeRequestMiddlewareFn)({ runtime, request, path });\n }\n\n logger.warn({ mw }, \"Unsupported beforeRequestMiddleware value – skipped\");\n return;\n}\n\nexport async function callAfterRequestMiddleware({\n runtime,\n response,\n path,\n}: {\n runtime: CopilotRuntimeLike;\n response: Response;\n path: string;\n}): Promise<void> {\n const mw = runtime.afterRequestMiddleware;\n if (!mw) return;\n\n const { messages, threadId, runId } = await parseSSEResponse(response);\n\n if (typeof mw === \"function\") {\n return (mw as AfterRequestMiddlewareFn)({\n runtime,\n response,\n path,\n messages,\n threadId,\n runId,\n });\n }\n\n logger.warn({ mw }, \"Unsupported afterRequestMiddleware value – skipped\");\n}\n"],"mappings":";;;;;AAuEA,eAAsB,4BAA4B,EAChD,SACA,SACA,QAC6D;CAC7D,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;AAGT,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAiC;EAAE;EAAS;EAAS;EAAM,CAAC;AAGtE,2BAAO,KAAK,EAAE,IAAI,EAAE,sDAAsD;;AAI5E,eAAsB,2BAA2B,EAC/C,SACA,UACA,QAKgB;CAChB,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;CAET,MAAM,EAAE,UAAU,UAAU,UAAU,MAAMA,+CAAiB,SAAS;AAEtE,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAgC;EACtC;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAGJ,2BAAO,KAAK,EAAE,IAAI,EAAE,qDAAqD"}
1
+ {"version":3,"file":"middleware.cjs","names":["getRuntimeLogger","parseSSEResponse"],"sources":["../../../src/runtime/core/middleware.ts"],"sourcesContent":["/**\n * Middleware support for CopilotKit Runtime.\n *\n * A middleware hook can be provided as either:\n * 1. A **callback function** executed in-process.\n * 2. A **webhook URL** (http/https). The runtime will `POST` a JSON payload\n * to the URL and, for *before* hooks, accept an optional modified\n * `Request` object in the response body.\n *\n * Two lifecycle hooks are available:\n * • `BEFORE_REQUEST` – runs *before* the request handler.\n * • `AFTER_REQUEST` – runs *after* the handler returns a `Response`.\n */\n\nimport type { CopilotKitRuntimeLike } from \"./runtime\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport { getRuntimeLogger } from \"./logger\";\nimport { parseSSEResponse } from \"./middleware-sse-parser\";\nimport type { Message } from \"./middleware-sse-parser\";\n\n/* ------------------------------------------------------------------------------------------------\n * Public types\n * --------------------------------------------------------------------------------------------- */\n\nexport interface BeforeRequestMiddlewareParameters {\n runtime: CopilotKitRuntimeLike;\n request: Request;\n path: string;\n}\nexport interface AfterRequestMiddlewareParameters {\n runtime: CopilotKitRuntimeLike;\n response: Response;\n path: string;\n /** Reconstructed messages from the SSE stream (empty for non-SSE responses). */\n messages?: Message[];\n /** Thread ID extracted from the RUN_STARTED event. */\n threadId?: string;\n /** Run ID extracted from the RUN_STARTED event. */\n runId?: string;\n}\n\nexport type BeforeRequestMiddlewareFn = (\n params: BeforeRequestMiddlewareParameters,\n) => MaybePromise<Request | void>;\nexport type AfterRequestMiddlewareFn = (\n params: AfterRequestMiddlewareParameters,\n) => MaybePromise<void>;\n\n/**\n * A middleware value can be either a callback function or a webhook URL.\n */\nexport type BeforeRequestMiddleware = BeforeRequestMiddlewareFn;\nexport type AfterRequestMiddleware = AfterRequestMiddlewareFn;\n\n/** Lifecycle events emitted to webhook middleware. */\nexport enum CopilotKitMiddlewareEvent {\n BeforeRequest = \"BEFORE_REQUEST\",\n AfterRequest = \"AFTER_REQUEST\",\n}\n\n/** Stages used by the Middleware Webhook Protocol */\n/** Stages used by the CopilotKit webhook protocol */\nexport enum WebhookStage {\n BeforeRequest = \"before_request\",\n AfterRequest = \"after_request\",\n}\n\n/* ------------------------------------------------------------------------------------------------\n * Internal helpers – (de)serialisation\n * --------------------------------------------------------------------------------------------- */\n\nexport async function callBeforeRequestMiddleware({\n runtime,\n request,\n path,\n}: BeforeRequestMiddlewareParameters): Promise<Request | void> {\n const mw = runtime.beforeRequestMiddleware;\n if (!mw) return;\n\n // Function-based middleware (in-process)\n if (typeof mw === \"function\") {\n return (mw as BeforeRequestMiddlewareFn)({ runtime, request, path });\n }\n\n getRuntimeLogger(runtime).warn(\n { mw },\n \"Unsupported beforeRequestMiddleware value – skipped\",\n );\n return;\n}\n\nexport async function callAfterRequestMiddleware({\n runtime,\n response,\n path,\n}: {\n runtime: CopilotKitRuntimeLike;\n response: Response;\n path: string;\n}): Promise<void> {\n const mw = runtime.afterRequestMiddleware;\n if (!mw) return;\n\n const logger = getRuntimeLogger(runtime);\n const { messages, threadId, runId } = await parseSSEResponse(\n response,\n logger,\n );\n\n if (typeof mw === \"function\") {\n return (mw as AfterRequestMiddlewareFn)({\n runtime,\n response,\n path,\n messages,\n threadId,\n runId,\n });\n }\n\n logger.warn({ mw }, \"Unsupported afterRequestMiddleware value – skipped\");\n}\n"],"mappings":";;;;AAuEA,eAAsB,4BAA4B,EAChD,SACA,SACA,QAC6D;CAC7D,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;AAGT,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAiC;EAAE;EAAS;EAAS;EAAM,CAAC;AAGtE,iCAAiB,QAAQ,CAAC,KACxB,EAAE,IAAI,EACN,sDACD;;AAIH,eAAsB,2BAA2B,EAC/C,SACA,UACA,QAKgB;CAChB,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;CAET,MAAM,SAASA,gCAAiB,QAAQ;CACxC,MAAM,EAAE,UAAU,UAAU,UAAU,MAAMC,+CAC1C,UACA,OACD;AAED,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAgC;EACtC;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAGJ,QAAO,KAAK,EAAE,IAAI,EAAE,qDAAqD"}
@@ -1,15 +1,15 @@
1
1
  import { Message } from "./middleware-sse-parser.cjs";
2
- import { CopilotRuntimeLike } from "./runtime.cjs";
2
+ import { CopilotKitRuntimeLike } from "./runtime.cjs";
3
3
  import { MaybePromise } from "@copilotkit/shared";
4
4
 
5
5
  //#region src/runtime/core/middleware.d.ts
6
6
  interface BeforeRequestMiddlewareParameters {
7
- runtime: CopilotRuntimeLike;
7
+ runtime: CopilotKitRuntimeLike;
8
8
  request: Request;
9
9
  path: string;
10
10
  }
11
11
  interface AfterRequestMiddlewareParameters {
12
- runtime: CopilotRuntimeLike;
12
+ runtime: CopilotKitRuntimeLike;
13
13
  response: Response;
14
14
  path: string;
15
15
  /** Reconstructed messages from the SSE stream (empty for non-SSE responses). */
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.cts","names":[],"sources":["../../../src/runtime/core/middleware.ts"],"mappings":";;;;;UAwBiB,iCAAA;EACf,OAAA,EAAS,kBAAA;EACT,OAAA,EAAS,OAAA;EACT,IAAA;AAAA;AAAA,UAEe,gCAAA;EACf,OAAA,EAAS,kBAAA;EACT,QAAA,EAAU,QAAA;EACV,IAAA;EAFS;EAIT,QAAA,GAAW,OAAA;EAHD;EAKV,QAAA;EAFA;EAIA,KAAA;AAAA;AAAA,KAGU,yBAAA,IACV,MAAA,EAAQ,iCAAA,KACL,YAAA,CAAa,OAAA;AAAA,KACN,wBAAA,IACV,MAAA,EAAQ,gCAAA,KACL,YAAA;;AALL;;KAUY,uBAAA,GAA0B,yBAAA;AAAA,KAC1B,sBAAA,GAAyB,wBAAA"}
1
+ {"version":3,"file":"middleware.d.cts","names":[],"sources":["../../../src/runtime/core/middleware.ts"],"mappings":";;;;;UAwBiB,iCAAA;EACf,OAAA,EAAS,qBAAA;EACT,OAAA,EAAS,OAAA;EACT,IAAA;AAAA;AAAA,UAEe,gCAAA;EACf,OAAA,EAAS,qBAAA;EACT,QAAA,EAAU,QAAA;EACV,IAAA;EAFS;EAIT,QAAA,GAAW,OAAA;EAHD;EAKV,QAAA;EAFA;EAIA,KAAA;AAAA;AAAA,KAGU,yBAAA,IACV,MAAA,EAAQ,iCAAA,KACL,YAAA,CAAa,OAAA;AAAA,KACN,wBAAA,IACV,MAAA,EAAQ,gCAAA,KACL,YAAA;;AALL;;KAUY,uBAAA,GAA0B,yBAAA;AAAA,KAC1B,sBAAA,GAAyB,wBAAA"}
@@ -1,15 +1,15 @@
1
1
  import { Message } from "./middleware-sse-parser.mjs";
2
- import { CopilotRuntimeLike } from "./runtime.mjs";
2
+ import { CopilotKitRuntimeLike } from "./runtime.mjs";
3
3
  import { MaybePromise } from "@copilotkit/shared";
4
4
 
5
5
  //#region src/runtime/core/middleware.d.ts
6
6
  interface BeforeRequestMiddlewareParameters {
7
- runtime: CopilotRuntimeLike;
7
+ runtime: CopilotKitRuntimeLike;
8
8
  request: Request;
9
9
  path: string;
10
10
  }
11
11
  interface AfterRequestMiddlewareParameters {
12
- runtime: CopilotRuntimeLike;
12
+ runtime: CopilotKitRuntimeLike;
13
13
  response: Response;
14
14
  path: string;
15
15
  /** Reconstructed messages from the SSE stream (empty for non-SSE responses). */
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.d.mts","names":[],"sources":["../../../src/runtime/core/middleware.ts"],"mappings":";;;;;UAwBiB,iCAAA;EACf,OAAA,EAAS,kBAAA;EACT,OAAA,EAAS,OAAA;EACT,IAAA;AAAA;AAAA,UAEe,gCAAA;EACf,OAAA,EAAS,kBAAA;EACT,QAAA,EAAU,QAAA;EACV,IAAA;EAFS;EAIT,QAAA,GAAW,OAAA;EAHD;EAKV,QAAA;EAFA;EAIA,KAAA;AAAA;AAAA,KAGU,yBAAA,IACV,MAAA,EAAQ,iCAAA,KACL,YAAA,CAAa,OAAA;AAAA,KACN,wBAAA,IACV,MAAA,EAAQ,gCAAA,KACL,YAAA;;AALL;;KAUY,uBAAA,GAA0B,yBAAA;AAAA,KAC1B,sBAAA,GAAyB,wBAAA"}
1
+ {"version":3,"file":"middleware.d.mts","names":[],"sources":["../../../src/runtime/core/middleware.ts"],"mappings":";;;;;UAwBiB,iCAAA;EACf,OAAA,EAAS,qBAAA;EACT,OAAA,EAAS,OAAA;EACT,IAAA;AAAA;AAAA,UAEe,gCAAA;EACf,OAAA,EAAS,qBAAA;EACT,QAAA,EAAU,QAAA;EACV,IAAA;EAFS;EAIT,QAAA,GAAW,OAAA;EAHD;EAKV,QAAA;EAFA;EAIA,KAAA;AAAA;AAAA,KAGU,yBAAA,IACV,MAAA,EAAQ,iCAAA,KACL,YAAA,CAAa,OAAA;AAAA,KACN,wBAAA,IACV,MAAA,EAAQ,gCAAA,KACL,YAAA;;AALL;;KAUY,uBAAA,GAA0B,yBAAA;AAAA,KAC1B,sBAAA,GAAyB,wBAAA"}
@@ -1,5 +1,5 @@
1
+ import { getRuntimeLogger } from "./logger.mjs";
1
2
  import { parseSSEResponse } from "./middleware-sse-parser.mjs";
2
- import { logger } from "@copilotkit/shared";
3
3
 
4
4
  //#region src/runtime/core/middleware.ts
5
5
  async function callBeforeRequestMiddleware({ runtime, request, path }) {
@@ -10,12 +10,13 @@ async function callBeforeRequestMiddleware({ runtime, request, path }) {
10
10
  request,
11
11
  path
12
12
  });
13
- logger.warn({ mw }, "Unsupported beforeRequestMiddleware value – skipped");
13
+ getRuntimeLogger(runtime).warn({ mw }, "Unsupported beforeRequestMiddleware value – skipped");
14
14
  }
15
15
  async function callAfterRequestMiddleware({ runtime, response, path }) {
16
16
  const mw = runtime.afterRequestMiddleware;
17
17
  if (!mw) return;
18
- const { messages, threadId, runId } = await parseSSEResponse(response);
18
+ const logger = getRuntimeLogger(runtime);
19
+ const { messages, threadId, runId } = await parseSSEResponse(response, logger);
19
20
  if (typeof mw === "function") return mw({
20
21
  runtime,
21
22
  response,
@@ -1 +1 @@
1
- {"version":3,"file":"middleware.mjs","names":[],"sources":["../../../src/runtime/core/middleware.ts"],"sourcesContent":["/**\n * Middleware support for CopilotKit Runtime.\n *\n * A middleware hook can be provided as either:\n * 1. A **callback function** executed in-process.\n * 2. A **webhook URL** (http/https). The runtime will `POST` a JSON payload\n * to the URL and, for *before* hooks, accept an optional modified\n * `Request` object in the response body.\n *\n * Two lifecycle hooks are available:\n * • `BEFORE_REQUEST` – runs *before* the request handler.\n * • `AFTER_REQUEST` – runs *after* the handler returns a `Response`.\n */\n\nimport type { CopilotRuntimeLike } from \"./runtime\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport { logger } from \"@copilotkit/shared\";\nimport { parseSSEResponse } from \"./middleware-sse-parser\";\nimport type { Message } from \"./middleware-sse-parser\";\n\n/* ------------------------------------------------------------------------------------------------\n * Public types\n * --------------------------------------------------------------------------------------------- */\n\nexport interface BeforeRequestMiddlewareParameters {\n runtime: CopilotRuntimeLike;\n request: Request;\n path: string;\n}\nexport interface AfterRequestMiddlewareParameters {\n runtime: CopilotRuntimeLike;\n response: Response;\n path: string;\n /** Reconstructed messages from the SSE stream (empty for non-SSE responses). */\n messages?: Message[];\n /** Thread ID extracted from the RUN_STARTED event. */\n threadId?: string;\n /** Run ID extracted from the RUN_STARTED event. */\n runId?: string;\n}\n\nexport type BeforeRequestMiddlewareFn = (\n params: BeforeRequestMiddlewareParameters,\n) => MaybePromise<Request | void>;\nexport type AfterRequestMiddlewareFn = (\n params: AfterRequestMiddlewareParameters,\n) => MaybePromise<void>;\n\n/**\n * A middleware value can be either a callback function or a webhook URL.\n */\nexport type BeforeRequestMiddleware = BeforeRequestMiddlewareFn;\nexport type AfterRequestMiddleware = AfterRequestMiddlewareFn;\n\n/** Lifecycle events emitted to webhook middleware. */\nexport enum CopilotKitMiddlewareEvent {\n BeforeRequest = \"BEFORE_REQUEST\",\n AfterRequest = \"AFTER_REQUEST\",\n}\n\n/** Stages used by the Middleware Webhook Protocol */\n/** Stages used by the CopilotKit webhook protocol */\nexport enum WebhookStage {\n BeforeRequest = \"before_request\",\n AfterRequest = \"after_request\",\n}\n\n/* ------------------------------------------------------------------------------------------------\n * Internal helpers – (de)serialisation\n * --------------------------------------------------------------------------------------------- */\n\nexport async function callBeforeRequestMiddleware({\n runtime,\n request,\n path,\n}: BeforeRequestMiddlewareParameters): Promise<Request | void> {\n const mw = runtime.beforeRequestMiddleware;\n if (!mw) return;\n\n // Function-based middleware (in-process)\n if (typeof mw === \"function\") {\n return (mw as BeforeRequestMiddlewareFn)({ runtime, request, path });\n }\n\n logger.warn({ mw }, \"Unsupported beforeRequestMiddleware value – skipped\");\n return;\n}\n\nexport async function callAfterRequestMiddleware({\n runtime,\n response,\n path,\n}: {\n runtime: CopilotRuntimeLike;\n response: Response;\n path: string;\n}): Promise<void> {\n const mw = runtime.afterRequestMiddleware;\n if (!mw) return;\n\n const { messages, threadId, runId } = await parseSSEResponse(response);\n\n if (typeof mw === \"function\") {\n return (mw as AfterRequestMiddlewareFn)({\n runtime,\n response,\n path,\n messages,\n threadId,\n runId,\n });\n }\n\n logger.warn({ mw }, \"Unsupported afterRequestMiddleware value – skipped\");\n}\n"],"mappings":";;;;AAuEA,eAAsB,4BAA4B,EAChD,SACA,SACA,QAC6D;CAC7D,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;AAGT,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAiC;EAAE;EAAS;EAAS;EAAM,CAAC;AAGtE,QAAO,KAAK,EAAE,IAAI,EAAE,sDAAsD;;AAI5E,eAAsB,2BAA2B,EAC/C,SACA,UACA,QAKgB;CAChB,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;CAET,MAAM,EAAE,UAAU,UAAU,UAAU,MAAM,iBAAiB,SAAS;AAEtE,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAgC;EACtC;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAGJ,QAAO,KAAK,EAAE,IAAI,EAAE,qDAAqD"}
1
+ {"version":3,"file":"middleware.mjs","names":[],"sources":["../../../src/runtime/core/middleware.ts"],"sourcesContent":["/**\n * Middleware support for CopilotKit Runtime.\n *\n * A middleware hook can be provided as either:\n * 1. A **callback function** executed in-process.\n * 2. A **webhook URL** (http/https). The runtime will `POST` a JSON payload\n * to the URL and, for *before* hooks, accept an optional modified\n * `Request` object in the response body.\n *\n * Two lifecycle hooks are available:\n * • `BEFORE_REQUEST` – runs *before* the request handler.\n * • `AFTER_REQUEST` – runs *after* the handler returns a `Response`.\n */\n\nimport type { CopilotKitRuntimeLike } from \"./runtime\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport { getRuntimeLogger } from \"./logger\";\nimport { parseSSEResponse } from \"./middleware-sse-parser\";\nimport type { Message } from \"./middleware-sse-parser\";\n\n/* ------------------------------------------------------------------------------------------------\n * Public types\n * --------------------------------------------------------------------------------------------- */\n\nexport interface BeforeRequestMiddlewareParameters {\n runtime: CopilotKitRuntimeLike;\n request: Request;\n path: string;\n}\nexport interface AfterRequestMiddlewareParameters {\n runtime: CopilotKitRuntimeLike;\n response: Response;\n path: string;\n /** Reconstructed messages from the SSE stream (empty for non-SSE responses). */\n messages?: Message[];\n /** Thread ID extracted from the RUN_STARTED event. */\n threadId?: string;\n /** Run ID extracted from the RUN_STARTED event. */\n runId?: string;\n}\n\nexport type BeforeRequestMiddlewareFn = (\n params: BeforeRequestMiddlewareParameters,\n) => MaybePromise<Request | void>;\nexport type AfterRequestMiddlewareFn = (\n params: AfterRequestMiddlewareParameters,\n) => MaybePromise<void>;\n\n/**\n * A middleware value can be either a callback function or a webhook URL.\n */\nexport type BeforeRequestMiddleware = BeforeRequestMiddlewareFn;\nexport type AfterRequestMiddleware = AfterRequestMiddlewareFn;\n\n/** Lifecycle events emitted to webhook middleware. */\nexport enum CopilotKitMiddlewareEvent {\n BeforeRequest = \"BEFORE_REQUEST\",\n AfterRequest = \"AFTER_REQUEST\",\n}\n\n/** Stages used by the Middleware Webhook Protocol */\n/** Stages used by the CopilotKit webhook protocol */\nexport enum WebhookStage {\n BeforeRequest = \"before_request\",\n AfterRequest = \"after_request\",\n}\n\n/* ------------------------------------------------------------------------------------------------\n * Internal helpers – (de)serialisation\n * --------------------------------------------------------------------------------------------- */\n\nexport async function callBeforeRequestMiddleware({\n runtime,\n request,\n path,\n}: BeforeRequestMiddlewareParameters): Promise<Request | void> {\n const mw = runtime.beforeRequestMiddleware;\n if (!mw) return;\n\n // Function-based middleware (in-process)\n if (typeof mw === \"function\") {\n return (mw as BeforeRequestMiddlewareFn)({ runtime, request, path });\n }\n\n getRuntimeLogger(runtime).warn(\n { mw },\n \"Unsupported beforeRequestMiddleware value – skipped\",\n );\n return;\n}\n\nexport async function callAfterRequestMiddleware({\n runtime,\n response,\n path,\n}: {\n runtime: CopilotKitRuntimeLike;\n response: Response;\n path: string;\n}): Promise<void> {\n const mw = runtime.afterRequestMiddleware;\n if (!mw) return;\n\n const logger = getRuntimeLogger(runtime);\n const { messages, threadId, runId } = await parseSSEResponse(\n response,\n logger,\n );\n\n if (typeof mw === \"function\") {\n return (mw as AfterRequestMiddlewareFn)({\n runtime,\n response,\n path,\n messages,\n threadId,\n runId,\n });\n }\n\n logger.warn({ mw }, \"Unsupported afterRequestMiddleware value – skipped\");\n}\n"],"mappings":";;;;AAuEA,eAAsB,4BAA4B,EAChD,SACA,SACA,QAC6D;CAC7D,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;AAGT,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAiC;EAAE;EAAS;EAAS;EAAM,CAAC;AAGtE,kBAAiB,QAAQ,CAAC,KACxB,EAAE,IAAI,EACN,sDACD;;AAIH,eAAsB,2BAA2B,EAC/C,SACA,UACA,QAKgB;CAChB,MAAM,KAAK,QAAQ;AACnB,KAAI,CAAC,GAAI;CAET,MAAM,SAAS,iBAAiB,QAAQ;CACxC,MAAM,EAAE,UAAU,UAAU,UAAU,MAAM,iBAC1C,UACA,OACD;AAED,KAAI,OAAO,OAAO,WAChB,QAAQ,GAAgC;EACtC;EACA;EACA;EACA;EACA;EACA;EACD,CAAC;AAGJ,QAAO,KAAK,EAAE,IAAI,EAAE,qDAAqD"}
@@ -1,7 +1,7 @@
1
1
 
2
2
  //#region src/runtime/core/package-info.ts
3
3
  const RUNTIME_PACKAGE_NAME = "@copilotkit/runtime";
4
- const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.5";
4
+ const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.51";
5
5
 
6
6
  //#endregion
7
7
  exports.RUNTIME_PACKAGE_NAME = RUNTIME_PACKAGE_NAME;
@@ -1,6 +1,6 @@
1
1
  //#region src/runtime/core/package-info.ts
2
2
  const RUNTIME_PACKAGE_NAME = "@copilotkit/runtime";
3
- const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.5";
3
+ const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.51";
4
4
 
5
5
  //#endregion
6
6
  export { RUNTIME_PACKAGE_NAME, RUNTIME_PACKAGE_VERSION };
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-error-reporter.cjs","names":[],"sources":["../../../src/runtime/core/runtime-error-reporter.ts"],"sourcesContent":["import type {\n CopilotErrorEvent,\n CopilotErrorHandler,\n} from \"@copilotkit/shared\";\n\nimport type { CopilotRuntimeLike } from \"./runtime\";\n\nexport const runtimeErrorReporterOption = Symbol(\n \"copilotkit.runtimeErrorReporter\",\n);\n\nexport type RuntimeErrorPhase =\n | \"common\"\n | \"sse.factory\"\n | \"sse.subscription\"\n | \"intelligence.startup\"\n | \"intelligence.subscription\";\n\nexport interface RuntimeErrorReportParams {\n request: Request;\n error: unknown;\n operation: string;\n agentId?: string;\n threadId?: string;\n runId?: string;\n phase?: RuntimeErrorPhase;\n startTime?: number;\n}\n\nexport interface RuntimeErrorReporter {\n report(params: RuntimeErrorReportParams): void;\n}\n\nexport interface RuntimeErrorReporterOptions {\n [runtimeErrorReporterOption]?: RuntimeErrorReporter;\n}\n\nconst SENSITIVE_REQUEST_HEADERS = new Set([\n \"authorization\",\n \"proxy-authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"api-key\",\n \"x-copilotcloud-public-api-key\",\n]);\n\nfunction sanitizeRequestHeaders(headers: Headers): Record<string, string> {\n const sanitized: Record<string, string> = {};\n headers.forEach((value, key) => {\n if (!SENSITIVE_REQUEST_HEADERS.has(key.toLowerCase())) {\n sanitized[key] = value;\n }\n });\n return sanitized;\n}\n\nexport function createRuntimeErrorReporter(\n handler?: CopilotErrorHandler,\n): RuntimeErrorReporter {\n return {\n report({\n request,\n error,\n operation,\n agentId,\n threadId,\n runId,\n phase,\n startTime,\n }) {\n if (!handler) return;\n\n try {\n const event: CopilotErrorEvent = {\n type: \"error\",\n timestamp: Date.now(),\n context: {\n source: \"runtime\",\n ...(threadId ? { threadId } : {}),\n ...(runId ? { runId } : {}),\n request: {\n operation,\n method: request.method,\n url: request.url,\n path: new URL(request.url).pathname,\n headers: sanitizeRequestHeaders(request.headers),\n startTime: startTime ?? Date.now(),\n },\n ...(agentId ? { agent: { name: agentId } } : {}),\n ...(phase ? { metadata: { phase } } : {}),\n },\n error,\n };\n\n const result = handler(event);\n if (result && typeof (result as Promise<void>).catch === \"function\") {\n void (result as Promise<void>).catch((handlerError) => {\n console.error(\n \"CopilotRuntime onError reporting failed:\",\n handlerError,\n );\n });\n }\n } catch (handlerError) {\n console.error(\"CopilotRuntime onError reporting failed:\", handlerError);\n }\n },\n };\n}\n\nexport function getRuntimeErrorReporterFromOptions(\n options: object,\n): RuntimeErrorReporter | undefined {\n return (options as RuntimeErrorReporterOptions)[runtimeErrorReporterOption];\n}\n\nexport function attachRuntimeErrorReporter(\n runtime: object,\n reporter: RuntimeErrorReporter,\n): void {\n Object.defineProperty(runtime, runtimeErrorReporterOption, {\n configurable: true,\n value: reporter,\n });\n}\n\nexport function getRuntimeErrorReporter(\n runtime: CopilotRuntimeLike,\n): RuntimeErrorReporter | undefined {\n return (runtime as CopilotRuntimeLike & RuntimeErrorReporterOptions)[\n runtimeErrorReporterOption\n ];\n}\n"],"mappings":";;AAOA,MAAa,6BAA6B,OACxC,kCACD;AAsGD,SAAgB,mCACd,SACkC;AAClC,QAAQ,QAAwC;;AAGlD,SAAgB,2BACd,SACA,UACM;AACN,QAAO,eAAe,SAAS,4BAA4B;EACzD,cAAc;EACd,OAAO;EACR,CAAC;;AAGJ,SAAgB,wBACd,SACkC;AAClC,QAAQ,QACN"}
1
+ {"version":3,"file":"runtime-error-reporter.cjs","names":[],"sources":["../../../src/runtime/core/runtime-error-reporter.ts"],"sourcesContent":["import type {\n CopilotErrorEvent,\n CopilotErrorHandler,\n} from \"@copilotkit/shared\";\n\nimport type { CopilotKitRuntimeLike } from \"./runtime\";\n\nexport const runtimeErrorReporterOption = Symbol(\n \"copilotkit.runtimeErrorReporter\",\n);\n\nexport type RuntimeErrorPhase =\n | \"common\"\n | \"sse.factory\"\n | \"sse.subscription\"\n | \"intelligence.startup\"\n | \"intelligence.subscription\";\n\nexport interface RuntimeErrorReportParams {\n request: Request;\n error: unknown;\n operation: string;\n agentId?: string;\n threadId?: string;\n runId?: string;\n phase?: RuntimeErrorPhase;\n startTime?: number;\n}\n\nexport interface RuntimeErrorReporter {\n report(params: RuntimeErrorReportParams): void;\n}\n\nexport interface RuntimeErrorReporterOptions {\n [runtimeErrorReporterOption]?: RuntimeErrorReporter;\n}\n\nconst SENSITIVE_REQUEST_HEADERS = new Set([\n \"authorization\",\n \"proxy-authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"api-key\",\n \"x-copilotcloud-public-api-key\",\n]);\n\nfunction sanitizeRequestHeaders(headers: Headers): Record<string, string> {\n const sanitized: Record<string, string> = {};\n headers.forEach((value, key) => {\n if (!SENSITIVE_REQUEST_HEADERS.has(key.toLowerCase())) {\n sanitized[key] = value;\n }\n });\n return sanitized;\n}\n\nexport function createRuntimeErrorReporter(\n handler?: CopilotErrorHandler,\n): RuntimeErrorReporter {\n return {\n report({\n request,\n error,\n operation,\n agentId,\n threadId,\n runId,\n phase,\n startTime,\n }) {\n if (!handler) return;\n\n try {\n const event: CopilotErrorEvent = {\n type: \"error\",\n timestamp: Date.now(),\n context: {\n source: \"runtime\",\n ...(threadId ? { threadId } : {}),\n ...(runId ? { runId } : {}),\n request: {\n operation,\n method: request.method,\n url: request.url,\n path: new URL(request.url).pathname,\n headers: sanitizeRequestHeaders(request.headers),\n startTime: startTime ?? Date.now(),\n },\n ...(agentId ? { agent: { name: agentId } } : {}),\n ...(phase ? { metadata: { phase } } : {}),\n },\n error,\n };\n\n const result = handler(event);\n if (result && typeof (result as Promise<void>).catch === \"function\") {\n void (result as Promise<void>).catch((handlerError) => {\n console.error(\n \"CopilotKitRuntime onError reporting failed:\",\n handlerError,\n );\n });\n }\n } catch (handlerError) {\n console.error(\n \"CopilotKitRuntime onError reporting failed:\",\n handlerError,\n );\n }\n },\n };\n}\n\nexport function getRuntimeErrorReporterFromOptions(\n options: object,\n): RuntimeErrorReporter | undefined {\n return (options as RuntimeErrorReporterOptions)[runtimeErrorReporterOption];\n}\n\nexport function attachRuntimeErrorReporter(\n runtime: object,\n reporter: RuntimeErrorReporter,\n): void {\n Object.defineProperty(runtime, runtimeErrorReporterOption, {\n configurable: true,\n value: reporter,\n });\n}\n\nexport function getRuntimeErrorReporter(\n runtime: CopilotKitRuntimeLike,\n): RuntimeErrorReporter | undefined {\n return (runtime as CopilotKitRuntimeLike & RuntimeErrorReporterOptions)[\n runtimeErrorReporterOption\n ];\n}\n"],"mappings":";;AAOA,MAAa,6BAA6B,OACxC,kCACD;AAyGD,SAAgB,mCACd,SACkC;AAClC,QAAQ,QAAwC;;AAGlD,SAAgB,2BACd,SACA,UACM;AACN,QAAO,eAAe,SAAS,4BAA4B;EACzD,cAAc;EACd,OAAO;EACR,CAAC;;AAGJ,SAAgB,wBACd,SACkC;AAClC,QAAQ,QACN"}
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-error-reporter.mjs","names":[],"sources":["../../../src/runtime/core/runtime-error-reporter.ts"],"sourcesContent":["import type {\n CopilotErrorEvent,\n CopilotErrorHandler,\n} from \"@copilotkit/shared\";\n\nimport type { CopilotRuntimeLike } from \"./runtime\";\n\nexport const runtimeErrorReporterOption = Symbol(\n \"copilotkit.runtimeErrorReporter\",\n);\n\nexport type RuntimeErrorPhase =\n | \"common\"\n | \"sse.factory\"\n | \"sse.subscription\"\n | \"intelligence.startup\"\n | \"intelligence.subscription\";\n\nexport interface RuntimeErrorReportParams {\n request: Request;\n error: unknown;\n operation: string;\n agentId?: string;\n threadId?: string;\n runId?: string;\n phase?: RuntimeErrorPhase;\n startTime?: number;\n}\n\nexport interface RuntimeErrorReporter {\n report(params: RuntimeErrorReportParams): void;\n}\n\nexport interface RuntimeErrorReporterOptions {\n [runtimeErrorReporterOption]?: RuntimeErrorReporter;\n}\n\nconst SENSITIVE_REQUEST_HEADERS = new Set([\n \"authorization\",\n \"proxy-authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"api-key\",\n \"x-copilotcloud-public-api-key\",\n]);\n\nfunction sanitizeRequestHeaders(headers: Headers): Record<string, string> {\n const sanitized: Record<string, string> = {};\n headers.forEach((value, key) => {\n if (!SENSITIVE_REQUEST_HEADERS.has(key.toLowerCase())) {\n sanitized[key] = value;\n }\n });\n return sanitized;\n}\n\nexport function createRuntimeErrorReporter(\n handler?: CopilotErrorHandler,\n): RuntimeErrorReporter {\n return {\n report({\n request,\n error,\n operation,\n agentId,\n threadId,\n runId,\n phase,\n startTime,\n }) {\n if (!handler) return;\n\n try {\n const event: CopilotErrorEvent = {\n type: \"error\",\n timestamp: Date.now(),\n context: {\n source: \"runtime\",\n ...(threadId ? { threadId } : {}),\n ...(runId ? { runId } : {}),\n request: {\n operation,\n method: request.method,\n url: request.url,\n path: new URL(request.url).pathname,\n headers: sanitizeRequestHeaders(request.headers),\n startTime: startTime ?? Date.now(),\n },\n ...(agentId ? { agent: { name: agentId } } : {}),\n ...(phase ? { metadata: { phase } } : {}),\n },\n error,\n };\n\n const result = handler(event);\n if (result && typeof (result as Promise<void>).catch === \"function\") {\n void (result as Promise<void>).catch((handlerError) => {\n console.error(\n \"CopilotRuntime onError reporting failed:\",\n handlerError,\n );\n });\n }\n } catch (handlerError) {\n console.error(\"CopilotRuntime onError reporting failed:\", handlerError);\n }\n },\n };\n}\n\nexport function getRuntimeErrorReporterFromOptions(\n options: object,\n): RuntimeErrorReporter | undefined {\n return (options as RuntimeErrorReporterOptions)[runtimeErrorReporterOption];\n}\n\nexport function attachRuntimeErrorReporter(\n runtime: object,\n reporter: RuntimeErrorReporter,\n): void {\n Object.defineProperty(runtime, runtimeErrorReporterOption, {\n configurable: true,\n value: reporter,\n });\n}\n\nexport function getRuntimeErrorReporter(\n runtime: CopilotRuntimeLike,\n): RuntimeErrorReporter | undefined {\n return (runtime as CopilotRuntimeLike & RuntimeErrorReporterOptions)[\n runtimeErrorReporterOption\n ];\n}\n"],"mappings":";AAOA,MAAa,6BAA6B,OACxC,kCACD;AAsGD,SAAgB,mCACd,SACkC;AAClC,QAAQ,QAAwC;;AAGlD,SAAgB,2BACd,SACA,UACM;AACN,QAAO,eAAe,SAAS,4BAA4B;EACzD,cAAc;EACd,OAAO;EACR,CAAC;;AAGJ,SAAgB,wBACd,SACkC;AAClC,QAAQ,QACN"}
1
+ {"version":3,"file":"runtime-error-reporter.mjs","names":[],"sources":["../../../src/runtime/core/runtime-error-reporter.ts"],"sourcesContent":["import type {\n CopilotErrorEvent,\n CopilotErrorHandler,\n} from \"@copilotkit/shared\";\n\nimport type { CopilotKitRuntimeLike } from \"./runtime\";\n\nexport const runtimeErrorReporterOption = Symbol(\n \"copilotkit.runtimeErrorReporter\",\n);\n\nexport type RuntimeErrorPhase =\n | \"common\"\n | \"sse.factory\"\n | \"sse.subscription\"\n | \"intelligence.startup\"\n | \"intelligence.subscription\";\n\nexport interface RuntimeErrorReportParams {\n request: Request;\n error: unknown;\n operation: string;\n agentId?: string;\n threadId?: string;\n runId?: string;\n phase?: RuntimeErrorPhase;\n startTime?: number;\n}\n\nexport interface RuntimeErrorReporter {\n report(params: RuntimeErrorReportParams): void;\n}\n\nexport interface RuntimeErrorReporterOptions {\n [runtimeErrorReporterOption]?: RuntimeErrorReporter;\n}\n\nconst SENSITIVE_REQUEST_HEADERS = new Set([\n \"authorization\",\n \"proxy-authorization\",\n \"cookie\",\n \"set-cookie\",\n \"x-api-key\",\n \"api-key\",\n \"x-copilotcloud-public-api-key\",\n]);\n\nfunction sanitizeRequestHeaders(headers: Headers): Record<string, string> {\n const sanitized: Record<string, string> = {};\n headers.forEach((value, key) => {\n if (!SENSITIVE_REQUEST_HEADERS.has(key.toLowerCase())) {\n sanitized[key] = value;\n }\n });\n return sanitized;\n}\n\nexport function createRuntimeErrorReporter(\n handler?: CopilotErrorHandler,\n): RuntimeErrorReporter {\n return {\n report({\n request,\n error,\n operation,\n agentId,\n threadId,\n runId,\n phase,\n startTime,\n }) {\n if (!handler) return;\n\n try {\n const event: CopilotErrorEvent = {\n type: \"error\",\n timestamp: Date.now(),\n context: {\n source: \"runtime\",\n ...(threadId ? { threadId } : {}),\n ...(runId ? { runId } : {}),\n request: {\n operation,\n method: request.method,\n url: request.url,\n path: new URL(request.url).pathname,\n headers: sanitizeRequestHeaders(request.headers),\n startTime: startTime ?? Date.now(),\n },\n ...(agentId ? { agent: { name: agentId } } : {}),\n ...(phase ? { metadata: { phase } } : {}),\n },\n error,\n };\n\n const result = handler(event);\n if (result && typeof (result as Promise<void>).catch === \"function\") {\n void (result as Promise<void>).catch((handlerError) => {\n console.error(\n \"CopilotKitRuntime onError reporting failed:\",\n handlerError,\n );\n });\n }\n } catch (handlerError) {\n console.error(\n \"CopilotKitRuntime onError reporting failed:\",\n handlerError,\n );\n }\n },\n };\n}\n\nexport function getRuntimeErrorReporterFromOptions(\n options: object,\n): RuntimeErrorReporter | undefined {\n return (options as RuntimeErrorReporterOptions)[runtimeErrorReporterOption];\n}\n\nexport function attachRuntimeErrorReporter(\n runtime: object,\n reporter: RuntimeErrorReporter,\n): void {\n Object.defineProperty(runtime, runtimeErrorReporterOption, {\n configurable: true,\n value: reporter,\n });\n}\n\nexport function getRuntimeErrorReporter(\n runtime: CopilotKitRuntimeLike,\n): RuntimeErrorReporter | undefined {\n return (runtime as CopilotKitRuntimeLike & RuntimeErrorReporterOptions)[\n runtimeErrorReporterOption\n ];\n}\n"],"mappings":";AAOA,MAAa,6BAA6B,OACxC,kCACD;AAyGD,SAAgB,mCACd,SACkC;AAClC,QAAQ,QAAwC;;AAGlD,SAAgB,2BACd,SACA,UACM;AACN,QAAO,eAAe,SAAS,4BAA4B;EACzD,cAAc;EACd,OAAO;EACR,CAAC;;AAGJ,SAAgB,wBACd,SACkC;AAClC,QAAQ,QACN"}
@@ -1,10 +1,9 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
1
  const require_header_utils = require('../handlers/header-utils.cjs');
3
2
  const require_sse_keep_alive = require('../handlers/shared/sse-keep-alive.cjs');
3
+ const require_logger = require('./logger.cjs');
4
4
  const require_learning = require('./learning.cjs');
5
5
  const require_thread_access = require('../handlers/shared/thread-access.cjs');
6
6
  const require_package_info = require('./package-info.cjs');
7
- const require_logger = require('./logger.cjs');
8
7
  const require_disclosure = require('../telemetry/disclosure.cjs');
9
8
  const require_debug_event_bus = require('./debug-event-bus.cjs');
10
9
  const require_in_memory = require('../runner/in-memory.cjs');
@@ -35,13 +34,13 @@ var BaseCopilotRuntime = class {
35
34
  return Promise.resolve(void 0);
36
35
  }
37
36
  constructor(options, runner) {
38
- require_disclosure.logRuntimeTelemetryDisclosure();
39
- const { agents, transcriptionService, beforeRequestMiddleware, afterRequestMiddleware, a2ui, mcpApps, openGenerativeUI, generativeUI } = options;
37
+ this.logger = require_logger.getRuntimeLogger(options);
38
+ require_disclosure.logRuntimeTelemetryDisclosure(this.logger);
39
+ const { agents, transcriptionService, beforeRequestMiddleware, afterRequestMiddleware, mcpApps, openGenerativeUI, generativeUI } = options;
40
40
  this.agents = agents;
41
41
  this.transcriptionService = transcriptionService;
42
42
  this.beforeRequestMiddleware = beforeRequestMiddleware;
43
43
  this.afterRequestMiddleware = afterRequestMiddleware;
44
- this.a2ui = a2ui || void 0;
45
44
  this.mcpApps = mcpApps;
46
45
  this.openGenerativeUI = openGenerativeUI;
47
46
  this.generativeUI = generativeUI;
@@ -51,11 +50,8 @@ var BaseCopilotRuntime = class {
51
50
  this.telemetry = options.ɵtelemetry ?? require_telemetry_client.default.createScope(resolvedTelemetryId !== void 0 ? { telemetryId: resolvedTelemetryId } : this.resolvedLicenseToken !== void 0 ? { licenseToken: this.resolvedLicenseToken } : {});
52
51
  if (options.telemetryProperties) require_telemetry_client.default.setGlobalProperties(options.telemetryProperties);
53
52
  this.debug = (0, _copilotkit_shared.resolveDebugConfig)(options.debug);
54
- if (this.debug.enabled) this.debugLogger = require_logger.createLogger({
55
- level: "debug",
56
- component: "copilotkit-debug"
57
- });
58
- if (require_debug_event_bus.isDebugEventFeedEnabled(this.debug)) this.debugEventBus = new require_debug_event_bus.DebugEventBus();
53
+ if (this.debug.enabled) this.debugLogger = require_logger.createDebugLogger(options.logger);
54
+ if (require_debug_event_bus.isDebugEventFeedEnabled(this.debug)) this.debugEventBus = new require_debug_event_bus.DebugEventBus(this.logger);
59
55
  this.forwardHeadersPolicy = require_header_utils.resolveForwardHeadersPolicy(options.forwardHeaders);
60
56
  this.sseKeepAliveIntervalSeconds = require_sse_keep_alive.resolveSseKeepAliveIntervalSeconds(options.sseKeepAliveIntervalSeconds);
61
57
  this.memory = options.memory;
@@ -63,7 +59,7 @@ var BaseCopilotRuntime = class {
63
59
  this.threadAccess = require_thread_access.resolveThreadAccessMode(options.threads);
64
60
  }
65
61
  };
66
- var CopilotSseRuntime = class extends BaseCopilotRuntime {
62
+ var CopilotKitSseRuntime = class extends BaseCopilotRuntime {
67
63
  constructor(options) {
68
64
  const channels = options.channels;
69
65
  if (Array.isArray(channels) && channels.length > 0) throw new Error("`channels` requires the Intelligence runtime (pass `intelligence`); Intelligence Channels are not available in SSE mode.");
@@ -77,7 +73,7 @@ var CopilotSseRuntime = class extends BaseCopilotRuntime {
77
73
  require_thread_access.warnIfThreadListRefused(this);
78
74
  }
79
75
  };
80
- var CopilotIntelligenceRuntime = class CopilotIntelligenceRuntime extends BaseCopilotRuntime {
76
+ var CopilotKitIntelligenceRuntime = class CopilotKitIntelligenceRuntime extends BaseCopilotRuntime {
81
77
  static {
82
78
  this.MAX_LOCK_TTL_SECONDS = 3600;
83
79
  }
@@ -88,7 +84,7 @@ var CopilotIntelligenceRuntime = class CopilotIntelligenceRuntime extends BaseCo
88
84
  const rawOptions = options;
89
85
  if (rawOptions.runner !== void 0) throw new Error("Intelligence Runtime auto-wires its own `runner`; passing `runner` alongside `intelligence` is not supported. Durability is managed by the Intelligence service, so `InMemoryAgentRunner` / a SQLite runner is unnecessary here — drop `runner`, or drop `intelligence` to run in SSE mode with a runner you control.");
90
86
  if (rawOptions.identifyUser !== void 0 && typeof rawOptions.identifyUser !== "function") throw new Error("Intelligence Runtime `identifyUser` must be a callback");
91
- if (rawOptions.threads !== void 0) console.warn("[CopilotKit] `threads` has no effect on an Intelligence runtime: the platform scopes threads per user. Remove the option.");
87
+ if (rawOptions.threads !== void 0) require_logger.getRuntimeLogger(options).warn("[CopilotKit] `threads` has no effect on an Intelligence runtime: the platform scopes threads per user. Remove the option.");
92
88
  if (rawOptions.channels !== void 0 && !Array.isArray(rawOptions.channels)) throw new Error("Intelligence Runtime `channels` must be an array");
93
89
  const hasWebIdentity = typeof rawOptions.identifyUser === "function";
94
90
  const hasChannels = Array.isArray(rawOptions.channels) && rawOptions.channels.length > 0;
@@ -96,23 +92,24 @@ var CopilotIntelligenceRuntime = class CopilotIntelligenceRuntime extends BaseCo
96
92
  if (rawOptions.memory !== void 0 && (typeof rawOptions.memory !== "object" || rawOptions.memory === null || typeof rawOptions.memory.access !== "function")) throw new Error("Intelligence Runtime `memory.access` must be a callback");
97
93
  if (rawOptions.memory !== void 0 && !hasWebIdentity) throw new Error("Intelligence Runtime web `memory` requires `identifyUser`");
98
94
  if (rawOptions.ɵlearning !== void 0 && (typeof rawOptions.ɵlearning !== "object" || rawOptions.ɵlearning === null || !(typeof rawOptions.ɵlearning.containerId === "string" || typeof rawOptions.ɵlearning.containerId === "function"))) throw new Error("Intelligence Runtime `ɵlearning.containerId` must be a stable ID or callback");
99
- if (rawOptions.ɵlearning !== void 0 && options.intelligence.ɵgetLearningContainerId?.() !== void 0) throw new Error("Configure Learning Containers with `getLearningContainerId` on `CopilotKitIntelligence`; do not also pass deprecated `ɵlearning` to `CopilotRuntime`");
95
+ if (rawOptions.ɵlearning !== void 0 && options.intelligence.ɵgetLearningContainerId?.() !== void 0) throw new Error("Configure Learning Containers with `getLearningContainerId` on `CopilotKitIntelligence`; do not also pass deprecated `ɵlearning` to `CopilotKitRuntime`");
100
96
  if (typeof rawOptions.ɵlearning?.containerId === "string") require_learning.assertStableLearningContainerId(rawOptions.ɵlearning.containerId);
101
97
  super(options, new require_intelligence.IntelligenceAgentRunner({
102
98
  url: options.intelligence.ɵgetRunnerWsUrl(),
103
99
  authToken: options.intelligence.ɵgetRunnerAuthToken(),
104
100
  maxReconnectMs: options.maxReconnectMs,
105
101
  maxRejoinMs: options.maxRejoinMs,
106
- heartbeatIntervalMs: options.heartbeatIntervalMs
102
+ heartbeatIntervalMs: options.heartbeatIntervalMs,
103
+ logger: require_logger.getRuntimeLogger(options)
107
104
  }));
108
105
  this.mode = _copilotkit_shared.RUNTIME_MODE_INTELLIGENCE;
109
106
  this.intelligence = options.intelligence;
110
107
  this.learning = options.ɵlearning;
111
108
  this.identifyUser = hasWebIdentity ? rawOptions.identifyUser : void 0;
112
109
  this.generateThreadNames = options.generateThreadNames ?? true;
113
- this.lockTtlSeconds = Math.min(options.lockTtlSeconds ?? 20, CopilotIntelligenceRuntime.MAX_LOCK_TTL_SECONDS);
110
+ this.lockTtlSeconds = Math.min(options.lockTtlSeconds ?? 20, CopilotKitIntelligenceRuntime.MAX_LOCK_TTL_SECONDS);
114
111
  this.lockKeyPrefix = options.lockKeyPrefix;
115
- this.lockHeartbeatIntervalSeconds = Math.min(options.lockHeartbeatIntervalSeconds ?? 15, CopilotIntelligenceRuntime.MAX_HEARTBEAT_INTERVAL_SECONDS);
112
+ this.lockHeartbeatIntervalSeconds = Math.min(options.lockHeartbeatIntervalSeconds ?? 15, CopilotKitIntelligenceRuntime.MAX_HEARTBEAT_INTERVAL_SECONDS);
116
113
  this.channels = [...rawOptions.channels ?? []];
117
114
  for (const c of this.channels) if (!c || typeof c !== "object" || !c.name) throw new Error("Intelligence Channel is missing a `name` — pass createChannel({ name }) for each Channel in `channels`");
118
115
  }
@@ -135,29 +132,16 @@ function isIntelligenceRuntime(runtime) {
135
132
  return runtime.mode === _copilotkit_shared.RUNTIME_MODE_INTELLIGENCE && !!runtime.intelligence;
136
133
  }
137
134
  /**
138
- * Single source of truth for "is A2UI on for this runtime?". Both the run path
139
- * (which applies `A2UIMiddleware`) and the `/info` response (which tells the
140
- * client whether to mount the A2UI renderer + catalog context) MUST go through
141
- * this, so they can never disagree — the divergence between them was the root
142
- * of CopilotKit/CopilotKit#5369.
143
- *
144
- * Backwards compatible: any config object is enabled (matching the historical
145
- * `!!runtime.a2ui`); only an explicit `enabled: false` turns it off.
146
- */
147
- function isA2UIEnabled(a2ui) {
148
- return !!a2ui && a2ui.enabled !== false;
149
- }
150
- /**
151
- * Compatibility shim that preserves the legacy `CopilotRuntime` entrypoint.
152
- * New code should prefer `CopilotSseRuntime` or `CopilotIntelligenceRuntime`.
135
+ * Compatibility shim that preserves the legacy `CopilotKitRuntime` entrypoint.
136
+ * New code should prefer `CopilotKitSseRuntime` or `CopilotKitIntelligenceRuntime`.
153
137
  *
154
- * Exported to consumers as the {@link CopilotRuntime} value (typed as
155
- * {@link CopilotRuntimeConstructor}) rather than as a class, so that the
138
+ * Exported to consumers as the {@link CopilotKitRuntime} value (typed as
139
+ * {@link CopilotKitRuntimeConstructor}) rather than as a class, so that the
156
140
  * channel-presence brand can flow from construction into the handler type.
157
141
  */
158
142
  var CopilotRuntimeShim = class {
159
143
  constructor(options) {
160
- this.delegate = hasIntelligenceOptions(options) ? new CopilotIntelligenceRuntime(options) : new CopilotSseRuntime(options);
144
+ this.delegate = hasIntelligenceOptions(options) ? new CopilotKitIntelligenceRuntime(options) : new CopilotKitSseRuntime(options);
161
145
  const reporter = require_runtime_error_reporter.getRuntimeErrorReporterFromOptions(options);
162
146
  if (reporter) require_runtime_error_reporter.attachRuntimeErrorReporter(this, reporter);
163
147
  }
@@ -176,9 +160,6 @@ var CopilotRuntimeShim = class {
176
160
  get runner() {
177
161
  return this.delegate.runner;
178
162
  }
179
- get a2ui() {
180
- return this.delegate.a2ui;
181
- }
182
163
  get mcpApps() {
183
164
  return this.delegate.mcpApps;
184
165
  }
@@ -230,6 +211,9 @@ var CopilotRuntimeShim = class {
230
211
  get debugLogger() {
231
212
  return this.delegate.debugLogger;
232
213
  }
214
+ get logger() {
215
+ return this.delegate.logger;
216
+ }
233
217
  get telemetry() {
234
218
  return this.delegate.telemetry;
235
219
  }
@@ -247,24 +231,23 @@ var CopilotRuntimeShim = class {
247
231
  }
248
232
  };
249
233
  /**
250
- * The public `CopilotRuntime` constructor. Backed by {@link CopilotRuntimeShim}
251
- * but typed as {@link CopilotRuntimeConstructor} so that constructing with a
234
+ * The public `CopilotKitRuntime` constructor. Backed by {@link CopilotRuntimeShim}
235
+ * but typed as {@link CopilotKitRuntimeConstructor} so that constructing with a
252
236
  * non-empty `channels` array yields a {@link RuntimeWithDeclaredChannels}-branded
253
237
  * runtime type.
254
238
  *
255
239
  * The `as unknown as` cast is required (not dishonest widening): the brand is a
256
240
  * phantom, compile-time-only marker with no runtime representation, so the shim
257
241
  * instances legitimately do not carry the brand property. Behavior is identical
258
- * to the former `class CopilotRuntime` — this only refines the static type.
242
+ * to the former `class CopilotKitRuntime` — this only refines the static type.
259
243
  */
260
- const CopilotRuntime = CopilotRuntimeShim;
244
+ const CopilotKitRuntime = CopilotRuntimeShim;
261
245
 
262
246
  //#endregion
263
- exports.CopilotIntelligenceRuntime = CopilotIntelligenceRuntime;
264
- exports.CopilotRuntime = CopilotRuntime;
265
- exports.CopilotSseRuntime = CopilotSseRuntime;
247
+ exports.CopilotKitIntelligenceRuntime = CopilotKitIntelligenceRuntime;
248
+ exports.CopilotKitRuntime = CopilotKitRuntime;
249
+ exports.CopilotKitSseRuntime = CopilotKitSseRuntime;
266
250
  exports.VERSION = VERSION;
267
- exports.isA2UIEnabled = isA2UIEnabled;
268
251
  exports.isIntelligenceRuntime = isIntelligenceRuntime;
269
252
  exports.resolveAgents = resolveAgents;
270
253
  //# sourceMappingURL=runtime.cjs.map