@copilotkit/runtime 2.0.0-rc.6 → 2.0.0-rc.61

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 +23 -28
  63. package/dist/index.d.cts +14 -14
  64. package/dist/index.d.mts +14 -14
  65. package/dist/index.mjs +8 -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 +2 -3
  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 +17 -14
  93. package/dist/runtime/core/fetch-handler.cjs.map +1 -1
  94. package/dist/runtime/core/fetch-handler.d.cts +22 -14
  95. package/dist/runtime/core/fetch-handler.d.cts.map +1 -1
  96. package/dist/runtime/core/fetch-handler.d.mts +22 -14
  97. package/dist/runtime/core/fetch-handler.d.mts.map +1 -1
  98. package/dist/runtime/core/fetch-handler.mjs +9 -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 +44 -46
  139. package/dist/runtime/core/runtime.cjs.map +1 -1
  140. package/dist/runtime/core/runtime.d.cts +178 -91
  141. package/dist/runtime/core/runtime.d.cts.map +1 -1
  142. package/dist/runtime/core/runtime.d.mts +178 -91
  143. package/dist/runtime/core/runtime.d.mts.map +1 -1
  144. package/dist/runtime/core/runtime.mjs +42 -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 +4 -8
  151. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -1
  152. package/dist/runtime/endpoints/node-fetch-handler.d.cts +4 -5
  153. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -1
  154. package/dist/runtime/endpoints/node-fetch-handler.d.mts +4 -5
  155. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -1
  156. package/dist/runtime/endpoints/node-fetch-handler.mjs +3 -5
  157. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -1
  158. package/dist/runtime/endpoints/node.cjs +7 -5
  159. package/dist/runtime/endpoints/node.cjs.map +1 -1
  160. package/dist/runtime/endpoints/node.d.cts +16 -16
  161. package/dist/runtime/endpoints/node.d.cts.map +1 -1
  162. package/dist/runtime/endpoints/node.d.mts +16 -16
  163. package/dist/runtime/endpoints/node.d.mts.map +1 -1
  164. package/dist/runtime/endpoints/node.mjs +9 -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.d.cts +13 -18
  308. package/dist/runtime/index.d.mts +13 -18
  309. package/dist/runtime/intelligence-platform/analytics-context.cjs +84 -0
  310. package/dist/runtime/intelligence-platform/analytics-context.cjs.map +1 -0
  311. package/dist/runtime/intelligence-platform/analytics-context.mjs +83 -0
  312. package/dist/runtime/intelligence-platform/analytics-context.mjs.map +1 -0
  313. package/dist/runtime/intelligence-platform/client.cjs +30 -4
  314. package/dist/runtime/intelligence-platform/client.cjs.map +1 -1
  315. package/dist/runtime/intelligence-platform/client.d.cts +25 -2
  316. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -1
  317. package/dist/runtime/intelligence-platform/client.d.mts +25 -2
  318. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -1
  319. package/dist/runtime/intelligence-platform/client.mjs +30 -3
  320. package/dist/runtime/intelligence-platform/client.mjs.map +1 -1
  321. package/dist/runtime/intelligence-platform/learning-management.cjs +7 -8
  322. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -1
  323. package/dist/runtime/intelligence-platform/learning-management.mjs +7 -7
  324. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -1
  325. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +104 -110
  326. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -1
  327. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +8 -2
  328. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -1
  329. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +8 -2
  330. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -1
  331. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +104 -109
  332. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -1
  333. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +0 -1
  334. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -1
  335. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +1 -1
  336. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +1 -1
  337. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +22 -19
  338. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -1
  339. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -1
  340. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -1
  341. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +22 -19
  342. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -1
  343. package/dist/runtime/intelligence-platform/stop-run.cjs +50 -0
  344. package/dist/runtime/intelligence-platform/stop-run.cjs.map +1 -0
  345. package/dist/runtime/intelligence-platform/stop-run.mjs +50 -0
  346. package/dist/runtime/intelligence-platform/stop-run.mjs.map +1 -0
  347. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +3 -3
  348. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -1
  349. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +2 -1
  350. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -1
  351. package/dist/runtime/intelligence-platform/trajectories.cjs +2 -3
  352. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -1
  353. package/dist/runtime/intelligence-platform/trajectories.mjs +2 -2
  354. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -1
  355. package/dist/runtime/node.d.cts +2 -2
  356. package/dist/runtime/node.d.mts +2 -2
  357. package/dist/runtime/runner/agent-runner.cjs +0 -1
  358. package/dist/runtime/runner/agent-runner.cjs.map +1 -1
  359. package/dist/runtime/runner/agent-runner.d.cts +9 -0
  360. package/dist/runtime/runner/agent-runner.d.cts.map +1 -1
  361. package/dist/runtime/runner/agent-runner.d.mts +9 -0
  362. package/dist/runtime/runner/agent-runner.d.mts.map +1 -1
  363. package/dist/runtime/runner/agent-runner.mjs.map +1 -1
  364. package/dist/runtime/runner/in-memory.cjs +0 -1
  365. package/dist/runtime/runner/in-memory.cjs.map +1 -1
  366. package/dist/runtime/runner/index.d.cts +1 -1
  367. package/dist/runtime/runner/index.d.mts +1 -1
  368. package/dist/runtime/runner/index.mjs +1 -1
  369. package/dist/runtime/runner/intelligence.cjs +55 -9
  370. package/dist/runtime/runner/intelligence.cjs.map +1 -1
  371. package/dist/runtime/runner/intelligence.d.cts +12 -1
  372. package/dist/runtime/runner/intelligence.d.cts.map +1 -1
  373. package/dist/runtime/runner/intelligence.d.mts +12 -1
  374. package/dist/runtime/runner/intelligence.d.mts.map +1 -1
  375. package/dist/runtime/runner/intelligence.mjs +56 -10
  376. package/dist/runtime/runner/intelligence.mjs.map +1 -1
  377. package/dist/runtime/telemetry/disclosure.cjs +2 -3
  378. package/dist/runtime/telemetry/disclosure.cjs.map +1 -1
  379. package/dist/runtime/telemetry/disclosure.mjs +3 -3
  380. package/dist/runtime/telemetry/disclosure.mjs.map +1 -1
  381. package/dist/runtime/telemetry/events.d.cts +1 -1
  382. package/dist/runtime/telemetry/events.d.mts +1 -1
  383. package/dist/runtime/telemetry/instance-created.cjs +33 -12
  384. package/dist/runtime/telemetry/instance-created.cjs.map +1 -1
  385. package/dist/runtime/telemetry/instance-created.mjs +33 -12
  386. package/dist/runtime/telemetry/instance-created.mjs.map +1 -1
  387. package/dist/runtime/telemetry/telemetry-client.cjs +0 -5
  388. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -1
  389. package/dist/runtime/telemetry/telemetry-client.mjs +0 -4
  390. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -1
  391. package/dist/runtime/telemetry/telemetry-identity.cjs +0 -1
  392. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -1
  393. package/dist/v2/index.d.cts +242 -0
  394. package/dist/v2/index.d.mts +242 -0
  395. package/dist/v2/node.d.cts +18 -0
  396. package/dist/v2/node.d.mts +18 -0
  397. package/package.json +84 -29
  398. package/dist/_virtual/_rolldown/runtime.cjs +0 -29
  399. package/dist/agent/converters/index.d.mts +0 -2
  400. package/dist/agent/index.cjs +0 -1328
  401. package/dist/agent/index.cjs.map +0 -1
  402. package/dist/agent/index.d.cts +0 -467
  403. package/dist/agent/index.d.cts.map +0 -1
  404. package/dist/agent/index.d.mts +0 -468
  405. package/dist/agent/index.d.mts.map +0 -1
  406. package/dist/agent/index.mjs +0 -1318
  407. package/dist/agent/index.mjs.map +0 -1
  408. package/dist/agent/mcp-tool-names.cjs +0 -82
  409. package/dist/agent/mcp-tool-names.cjs.map +0 -1
  410. package/dist/agent/mcp-tool-names.mjs +0 -80
  411. package/dist/agent/mcp-tool-names.mjs.map +0 -1
  412. package/dist/agent/url-download.cjs.map +0 -1
  413. package/dist/agent/url-download.d.cts.map +0 -1
  414. package/dist/agent/url-download.d.mts.map +0 -1
  415. package/dist/agent/url-download.mjs.map +0 -1
  416. package/dist/runtime/index.d.cts.map +0 -1
  417. package/dist/runtime/index.d.mts.map +0 -1
@@ -1,22 +1,22 @@
1
1
  import "./runtime.cjs";
2
- import { MaybePromise } from "@copilotkit/shared";
3
2
  import { RunAgentInput } from "@ag-ui/client";
3
+ import { MaybePromise } from "@copilotkit/shared";
4
4
 
5
5
  //#region src/runtime/core/learning.d.ts
6
6
  /** Application user resolved by an Intelligence runtime. */
7
- interface CopilotRuntimeUser {
7
+ interface CopilotKitRuntimeUser {
8
8
  readonly id: string;
9
9
  readonly name: string;
10
10
  }
11
11
  /** Context for choosing a Learning Container through the public Intelligence SDK. */
12
12
  type LearningContainerSelectorInput = {
13
13
  readonly surface: "web";
14
- readonly user: CopilotRuntimeUser;
14
+ readonly user: CopilotKitRuntimeUser;
15
15
  readonly agentId: string;
16
16
  readonly input: Readonly<RunAgentInput>;
17
17
  } | {
18
18
  readonly surface: "channel";
19
- readonly user: CopilotRuntimeUser | null;
19
+ readonly user: CopilotKitRuntimeUser | null;
20
20
  readonly agentId: string;
21
21
  readonly input: Readonly<RunAgentInput>;
22
22
  };
@@ -29,7 +29,7 @@ type GetLearningContainerId = (input: LearningContainerSelectorInput) => MaybePr
29
29
  */
30
30
  interface TrajectoryLearningContainerSelectorInput {
31
31
  readonly trajectoryId: string;
32
- readonly user: CopilotRuntimeUser;
32
+ readonly user: CopilotKitRuntimeUser;
33
33
  }
34
34
  /**
35
35
  * Selects existing Learning Spaces without requiring an agent run or Thread.
@@ -37,7 +37,7 @@ interface TrajectoryLearningContainerSelectorInput {
37
37
  */
38
38
  type GetTrajectoryLearningContainerIds = (input: TrajectoryLearningContainerSelectorInput, signal?: AbortSignal) => MaybePromise<readonly string[] | null | undefined>;
39
39
  /** Context for choosing one Learning Container for an Intelligence run. */
40
- type CopilotRuntimeLearningContext = {
40
+ type CopilotKitRuntimeLearningContext = {
41
41
  readonly surface: "web";
42
42
  readonly request: Request;
43
43
  readonly threadId: string;
@@ -53,9 +53,9 @@ type CopilotRuntimeLearningContext = {
53
53
  readonly deliveryId: string;
54
54
  };
55
55
  /** Assigns each Intelligence Thread to one developer-created Learning Container. */
56
- interface CopilotRuntimeLearningConfig {
57
- readonly containerId: string | ((input: CopilotRuntimeLearningContext) => MaybePromise<string | null | undefined>);
56
+ interface CopilotKitRuntimeLearningConfig {
57
+ readonly containerId: string | ((input: CopilotKitRuntimeLearningContext) => MaybePromise<string | null | undefined>);
58
58
  }
59
59
  //#endregion
60
- export { CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeUser, GetLearningContainerId, GetTrajectoryLearningContainerIds, LearningContainerSelectorInput, TrajectoryLearningContainerSelectorInput };
60
+ export { CopilotKitRuntimeLearningConfig, CopilotKitRuntimeLearningContext, CopilotKitRuntimeUser, GetLearningContainerId, GetTrajectoryLearningContainerIds, LearningContainerSelectorInput, TrajectoryLearningContainerSelectorInput };
61
61
  //# sourceMappingURL=learning.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"learning.d.cts","names":[],"sources":["../../../src/runtime/core/learning.ts"],"mappings":";;;;;AAeA;AAAA,UAAiB,kBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;AAAA;AAIX;AAAA,KAAY,8BAAA;EAAA,SAEG,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;EAAA,SAGhB,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;;KAInB,sBAAA,IACV,KAAA,EAAO,8BAAA,KACJ,YAAA;;;;;;UAOY,wCAAA;EAAA,SACN,YAAA;EAAA,SACA,IAAA,EAAM,kBAAA;AAAA;;;;;KAOL,iCAAA,IACV,KAAA,EAAO,wCAAA,EACP,MAAA,GAAS,WAAA,KACN,YAAA;;KAkDO,6BAAA;EAAA,SAEG,OAAA;EAAA,SACA,OAAA,EAAS,OAAA;EAAA,SACT,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;AAAA;;UAIE,4BAAA;EAAA,SACN,WAAA,aAGH,KAAA,EAAO,6BAAA,KACJ,YAAA;AAAA"}
1
+ {"version":3,"file":"learning.d.cts","names":[],"sources":["../../../src/runtime/core/learning.ts"],"mappings":";;;;;AAeA;AAAA,UAAiB,qBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;AAAA;AAIX;AAAA,KAAY,8BAAA;EAAA,SAEG,OAAA;EAAA,SACA,IAAA,EAAM,qBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;EAAA,SAGhB,OAAA;EAAA,SACA,IAAA,EAAM,qBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;;KAInB,sBAAA,IACV,KAAA,EAAO,8BAAA,KACJ,YAAA;;;;;;UAOY,wCAAA;EAAA,SACN,YAAA;EAAA,SACA,IAAA,EAAM,qBAAA;AAAA;;;;;KAOL,iCAAA,IACV,KAAA,EAAO,wCAAA,EACP,MAAA,GAAS,WAAA,KACN,YAAA;;KAkDO,gCAAA;EAAA,SAEG,OAAA;EAAA,SACA,OAAA,EAAS,OAAA;EAAA,SACT,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;AAAA;;UAIE,+BAAA;EAAA,SACN,WAAA,aAGH,KAAA,EAAO,gCAAA,KACJ,YAAA;AAAA"}
@@ -4,19 +4,19 @@ import { RunAgentInput } from "@ag-ui/client";
4
4
 
5
5
  //#region src/runtime/core/learning.d.ts
6
6
  /** Application user resolved by an Intelligence runtime. */
7
- interface CopilotRuntimeUser {
7
+ interface CopilotKitRuntimeUser {
8
8
  readonly id: string;
9
9
  readonly name: string;
10
10
  }
11
11
  /** Context for choosing a Learning Container through the public Intelligence SDK. */
12
12
  type LearningContainerSelectorInput = {
13
13
  readonly surface: "web";
14
- readonly user: CopilotRuntimeUser;
14
+ readonly user: CopilotKitRuntimeUser;
15
15
  readonly agentId: string;
16
16
  readonly input: Readonly<RunAgentInput>;
17
17
  } | {
18
18
  readonly surface: "channel";
19
- readonly user: CopilotRuntimeUser | null;
19
+ readonly user: CopilotKitRuntimeUser | null;
20
20
  readonly agentId: string;
21
21
  readonly input: Readonly<RunAgentInput>;
22
22
  };
@@ -29,7 +29,7 @@ type GetLearningContainerId = (input: LearningContainerSelectorInput) => MaybePr
29
29
  */
30
30
  interface TrajectoryLearningContainerSelectorInput {
31
31
  readonly trajectoryId: string;
32
- readonly user: CopilotRuntimeUser;
32
+ readonly user: CopilotKitRuntimeUser;
33
33
  }
34
34
  /**
35
35
  * Selects existing Learning Spaces without requiring an agent run or Thread.
@@ -37,7 +37,7 @@ interface TrajectoryLearningContainerSelectorInput {
37
37
  */
38
38
  type GetTrajectoryLearningContainerIds = (input: TrajectoryLearningContainerSelectorInput, signal?: AbortSignal) => MaybePromise<readonly string[] | null | undefined>;
39
39
  /** Context for choosing one Learning Container for an Intelligence run. */
40
- type CopilotRuntimeLearningContext = {
40
+ type CopilotKitRuntimeLearningContext = {
41
41
  readonly surface: "web";
42
42
  readonly request: Request;
43
43
  readonly threadId: string;
@@ -53,9 +53,9 @@ type CopilotRuntimeLearningContext = {
53
53
  readonly deliveryId: string;
54
54
  };
55
55
  /** Assigns each Intelligence Thread to one developer-created Learning Container. */
56
- interface CopilotRuntimeLearningConfig {
57
- readonly containerId: string | ((input: CopilotRuntimeLearningContext) => MaybePromise<string | null | undefined>);
56
+ interface CopilotKitRuntimeLearningConfig {
57
+ readonly containerId: string | ((input: CopilotKitRuntimeLearningContext) => MaybePromise<string | null | undefined>);
58
58
  }
59
59
  //#endregion
60
- export { CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeUser, GetLearningContainerId, GetTrajectoryLearningContainerIds, LearningContainerSelectorInput, TrajectoryLearningContainerSelectorInput };
60
+ export { CopilotKitRuntimeLearningConfig, CopilotKitRuntimeLearningContext, CopilotKitRuntimeUser, GetLearningContainerId, GetTrajectoryLearningContainerIds, LearningContainerSelectorInput, TrajectoryLearningContainerSelectorInput };
61
61
  //# sourceMappingURL=learning.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"learning.d.mts","names":[],"sources":["../../../src/runtime/core/learning.ts"],"mappings":";;;;;AAeA;AAAA,UAAiB,kBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;AAAA;AAIX;AAAA,KAAY,8BAAA;EAAA,SAEG,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;EAAA,SAGhB,OAAA;EAAA,SACA,IAAA,EAAM,kBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;;KAInB,sBAAA,IACV,KAAA,EAAO,8BAAA,KACJ,YAAA;;;;;;UAOY,wCAAA;EAAA,SACN,YAAA;EAAA,SACA,IAAA,EAAM,kBAAA;AAAA;;;;;KAOL,iCAAA,IACV,KAAA,EAAO,wCAAA,EACP,MAAA,GAAS,WAAA,KACN,YAAA;;KAkDO,6BAAA;EAAA,SAEG,OAAA;EAAA,SACA,OAAA,EAAS,OAAA;EAAA,SACT,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;AAAA;;UAIE,4BAAA;EAAA,SACN,WAAA,aAGH,KAAA,EAAO,6BAAA,KACJ,YAAA;AAAA"}
1
+ {"version":3,"file":"learning.d.mts","names":[],"sources":["../../../src/runtime/core/learning.ts"],"mappings":";;;;;AAeA;AAAA,UAAiB,qBAAA;EAAA,SACN,EAAA;EAAA,SACA,IAAA;AAAA;AAIX;AAAA,KAAY,8BAAA;EAAA,SAEG,OAAA;EAAA,SACA,IAAA,EAAM,qBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;EAAA,SAGhB,OAAA;EAAA,SACA,IAAA,EAAM,qBAAA;EAAA,SACN,OAAA;EAAA,SACA,KAAA,EAAO,QAAA,CAAS,aAAA;AAAA;;KAInB,sBAAA,IACV,KAAA,EAAO,8BAAA,KACJ,YAAA;;;;;;UAOY,wCAAA;EAAA,SACN,YAAA;EAAA,SACA,IAAA,EAAM,qBAAA;AAAA;;;;;KAOL,iCAAA,IACV,KAAA,EAAO,wCAAA,EACP,MAAA,GAAS,WAAA,KACN,YAAA;;KAkDO,gCAAA;EAAA,SAEG,OAAA;EAAA,SACA,OAAA,EAAS,OAAA;EAAA,SACT,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;AAAA;EAAA,SAGA,OAAA;EAAA,SACA,QAAA;EAAA,SACA,KAAA;EAAA,SACA,OAAA;EAAA,SACA,MAAA;EAAA,SACA,UAAA;AAAA;;UAIE,+BAAA;EAAA,SACN,WAAA,aAGH,KAAA,EAAO,gCAAA,KACJ,YAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"learning.mjs","names":[],"sources":["../../../src/runtime/core/learning.ts"],"sourcesContent":["import type { RunAgentInput } from \"@ag-ui/client\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport type { CopilotRuntimeLike } from \"./runtime\";\n\n/** Checks configuration without invoking a selector that requires a real run. */\nexport function hasLearningContainerConfiguration(\n runtime: CopilotRuntimeLike,\n): boolean {\n return (\n runtime.intelligence?.ɵgetLearningContainerId?.() !== undefined ||\n runtime.learning?.containerId !== undefined\n );\n}\n\n/** Application user resolved by an Intelligence runtime. */\nexport interface CopilotRuntimeUser {\n readonly id: string;\n readonly name: string;\n}\n\n/** Context for choosing a Learning Container through the public Intelligence SDK. */\nexport type LearningContainerSelectorInput =\n | {\n readonly surface: \"web\";\n readonly user: CopilotRuntimeUser;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n }\n | {\n readonly surface: \"channel\";\n readonly user: CopilotRuntimeUser | null;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n };\n\n/** Chooses one developer-created Learning Container for an Intelligence run. */\nexport type GetLearningContainerId = (\n input: LearningContainerSelectorInput,\n) => MaybePromise<string | null | undefined>;\n\n/**\n * Context for assigning browser activity to Learning Spaces. The Runtime\n * verifies `user`; the browser chooses `trajectoryId`, which is only checked\n * to be a UUID.\n */\nexport interface TrajectoryLearningContainerSelectorInput {\n readonly trajectoryId: string;\n readonly user: CopilotRuntimeUser;\n}\n\n/**\n * Selects existing Learning Spaces without requiring an agent run or Thread.\n * The optional signal cancels on request abort or the five-second deadline.\n */\nexport type GetTrajectoryLearningContainerIds = (\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n) => MaybePromise<readonly string[] | null | undefined>;\n\n/** Resolves bounded, validated Space IDs selected by application server code. */\nexport async function resolveTrajectoryLearningContainerIds(\n selector: GetTrajectoryLearningContainerIds | undefined,\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n): Promise<readonly string[] | undefined> {\n signal?.throwIfAborted();\n if (!selector) return undefined;\n const controller = new AbortController();\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n const timeout = setTimeout(\n () =>\n controller.abort(\n new Error(\"Trajectory Learning Container selection timed out\"),\n ),\n 5_000,\n );\n let onCancelled: (() => void) | undefined;\n try {\n const cancelled = new Promise<never>((_resolve, reject) => {\n onCancelled = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onCancelled, { once: true });\n });\n const selection = new Promise<readonly string[] | null | undefined>(\n (resolve) => {\n resolve(selector(input, controller.signal));\n },\n );\n const value = await Promise.race([selection, cancelled]);\n controller.signal.throwIfAborted();\n if (value == null) return undefined;\n if (!Array.isArray(value) || value.length > 100) {\n throw new Error(\n \"Trajectory Learning Container selection must be an array of at most 100 IDs\",\n );\n }\n // Array.from visits holes in sparse arrays, so they fail validation.\n return [...new Set(Array.from(value, assertStableLearningContainerId))];\n } finally {\n clearTimeout(timeout);\n signal?.removeEventListener(\"abort\", onAbort);\n if (onCancelled)\n controller.signal.removeEventListener(\"abort\", onCancelled);\n }\n}\n\n/** Context for choosing one Learning Container for an Intelligence run. */\nexport type CopilotRuntimeLearningContext =\n | {\n readonly surface: \"web\";\n readonly request: Request;\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n }\n | {\n readonly surface: \"channel\";\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n readonly deliveryId: string;\n };\n\n/** Assigns each Intelligence Thread to one developer-created Learning Container. */\nexport interface CopilotRuntimeLearningConfig {\n readonly containerId:\n | string\n | ((\n input: CopilotRuntimeLearningContext,\n ) => MaybePromise<string | null | undefined>);\n}\n\nconst STABLE_CONTAINER_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** Validates and returns a stable Learning Container ID. */\nexport function assertStableLearningContainerId(value: unknown): string {\n if (\n typeof value !== \"string\" ||\n value.length < 1 ||\n value.length > 64 ||\n !STABLE_CONTAINER_ID.test(value)\n ) {\n throw new Error(\n \"Learning Container must use a 1-64 character stable ID with lowercase letters, numbers, and single hyphens\",\n );\n }\n return value;\n}\n\n/** Resolves and validates a public Intelligence Learning Container selection. */\nexport async function resolveLearningContainerSelector(\n selector: GetLearningContainerId,\n input: LearningContainerSelectorInput,\n): Promise<string | undefined> {\n const value = await selector(input);\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n\n/** Resolves the configured Container once for one web or Channel run. */\nexport async function resolveLearningContainerId(\n config: CopilotRuntimeLearningConfig | undefined,\n input: CopilotRuntimeLearningContext,\n): Promise<string | undefined> {\n if (config === undefined) return undefined;\n const value =\n typeof config.containerId === \"function\"\n ? await config.containerId(input)\n : config.containerId;\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n"],"mappings":";;AAKA,SAAgB,kCACd,SACS;AACT,QACE,QAAQ,cAAc,2BAA2B,KAAK,UACtD,QAAQ,UAAU,gBAAgB;;;AAkDtC,eAAsB,sCACpB,UACA,OACA,QACwC;AACxC,SAAQ,gBAAgB;AACxB,KAAI,CAAC,SAAU,QAAO;CACtB,MAAM,aAAa,IAAI,iBAAiB;CACxC,MAAM,gBAAgB,WAAW,MAAM,QAAQ,OAAO;AACtD,SAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;CAC1D,MAAM,UAAU,iBAEZ,WAAW,sBACT,IAAI,MAAM,oDAAoD,CAC/D,EACH,IACD;CACD,IAAI;AACJ,KAAI;EACF,MAAM,YAAY,IAAI,SAAgB,UAAU,WAAW;AACzD,uBAAoB,OAAO,WAAW,OAAO,OAAO;AACpD,cAAW,OAAO,iBAAiB,SAAS,aAAa,EAAE,MAAM,MAAM,CAAC;IACxE;EACF,MAAM,YAAY,IAAI,SACnB,YAAY;AACX,WAAQ,SAAS,OAAO,WAAW,OAAO,CAAC;IAE9C;EACD,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC,WAAW,UAAU,CAAC;AACxD,aAAW,OAAO,gBAAgB;AAClC,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,IAC1C,OAAM,IAAI,MACR,8EACD;AAGH,SAAO,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,OAAO,gCAAgC,CAAC,CAAC;WAC/D;AACR,eAAa,QAAQ;AACrB,UAAQ,oBAAoB,SAAS,QAAQ;AAC7C,MAAI,YACF,YAAW,OAAO,oBAAoB,SAAS,YAAY;;;AAgCjE,MAAM,sBAAsB;;AAG5B,SAAgB,gCAAgC,OAAwB;AACtE,KACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,SAAS,MACf,CAAC,oBAAoB,KAAK,MAAM,CAEhC,OAAM,IAAI,MACR,6GACD;AAEH,QAAO;;;AAIT,eAAsB,iCACpB,UACA,OAC6B;CAC7B,MAAM,QAAQ,MAAM,SAAS,MAAM;AACnC,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM;;;AAI/C,eAAsB,2BACpB,QACA,OAC6B;AAC7B,KAAI,WAAW,OAAW,QAAO;CACjC,MAAM,QACJ,OAAO,OAAO,gBAAgB,aAC1B,MAAM,OAAO,YAAY,MAAM,GAC/B,OAAO;AACb,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM"}
1
+ {"version":3,"file":"learning.mjs","names":[],"sources":["../../../src/runtime/core/learning.ts"],"sourcesContent":["import type { RunAgentInput } from \"@ag-ui/client\";\nimport type { MaybePromise } from \"@copilotkit/shared\";\nimport type { CopilotKitRuntimeLike } from \"./runtime\";\n\n/** Checks configuration without invoking a selector that requires a real run. */\nexport function hasLearningContainerConfiguration(\n runtime: CopilotKitRuntimeLike,\n): boolean {\n return (\n runtime.intelligence?.ɵgetLearningContainerId?.() !== undefined ||\n runtime.learning?.containerId !== undefined\n );\n}\n\n/** Application user resolved by an Intelligence runtime. */\nexport interface CopilotKitRuntimeUser {\n readonly id: string;\n readonly name: string;\n}\n\n/** Context for choosing a Learning Container through the public Intelligence SDK. */\nexport type LearningContainerSelectorInput =\n | {\n readonly surface: \"web\";\n readonly user: CopilotKitRuntimeUser;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n }\n | {\n readonly surface: \"channel\";\n readonly user: CopilotKitRuntimeUser | null;\n readonly agentId: string;\n readonly input: Readonly<RunAgentInput>;\n };\n\n/** Chooses one developer-created Learning Container for an Intelligence run. */\nexport type GetLearningContainerId = (\n input: LearningContainerSelectorInput,\n) => MaybePromise<string | null | undefined>;\n\n/**\n * Context for assigning browser activity to Learning Spaces. The Runtime\n * verifies `user`; the browser chooses `trajectoryId`, which is only checked\n * to be a UUID.\n */\nexport interface TrajectoryLearningContainerSelectorInput {\n readonly trajectoryId: string;\n readonly user: CopilotKitRuntimeUser;\n}\n\n/**\n * Selects existing Learning Spaces without requiring an agent run or Thread.\n * The optional signal cancels on request abort or the five-second deadline.\n */\nexport type GetTrajectoryLearningContainerIds = (\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n) => MaybePromise<readonly string[] | null | undefined>;\n\n/** Resolves bounded, validated Space IDs selected by application server code. */\nexport async function resolveTrajectoryLearningContainerIds(\n selector: GetTrajectoryLearningContainerIds | undefined,\n input: TrajectoryLearningContainerSelectorInput,\n signal?: AbortSignal,\n): Promise<readonly string[] | undefined> {\n signal?.throwIfAborted();\n if (!selector) return undefined;\n const controller = new AbortController();\n const onAbort = () => controller.abort(signal?.reason);\n signal?.addEventListener(\"abort\", onAbort, { once: true });\n const timeout = setTimeout(\n () =>\n controller.abort(\n new Error(\"Trajectory Learning Container selection timed out\"),\n ),\n 5_000,\n );\n let onCancelled: (() => void) | undefined;\n try {\n const cancelled = new Promise<never>((_resolve, reject) => {\n onCancelled = () => reject(controller.signal.reason);\n controller.signal.addEventListener(\"abort\", onCancelled, { once: true });\n });\n const selection = new Promise<readonly string[] | null | undefined>(\n (resolve) => {\n resolve(selector(input, controller.signal));\n },\n );\n const value = await Promise.race([selection, cancelled]);\n controller.signal.throwIfAborted();\n if (value == null) return undefined;\n if (!Array.isArray(value) || value.length > 100) {\n throw new Error(\n \"Trajectory Learning Container selection must be an array of at most 100 IDs\",\n );\n }\n // Array.from visits holes in sparse arrays, so they fail validation.\n return [...new Set(Array.from(value, assertStableLearningContainerId))];\n } finally {\n clearTimeout(timeout);\n signal?.removeEventListener(\"abort\", onAbort);\n if (onCancelled)\n controller.signal.removeEventListener(\"abort\", onCancelled);\n }\n}\n\n/** Context for choosing one Learning Container for an Intelligence run. */\nexport type CopilotKitRuntimeLearningContext =\n | {\n readonly surface: \"web\";\n readonly request: Request;\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n }\n | {\n readonly surface: \"channel\";\n readonly threadId: string;\n readonly runId: string;\n readonly agentId: string;\n readonly userId: string;\n readonly deliveryId: string;\n };\n\n/** Assigns each Intelligence Thread to one developer-created Learning Container. */\nexport interface CopilotKitRuntimeLearningConfig {\n readonly containerId:\n | string\n | ((\n input: CopilotKitRuntimeLearningContext,\n ) => MaybePromise<string | null | undefined>);\n}\n\nconst STABLE_CONTAINER_ID = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;\n\n/** Validates and returns a stable Learning Container ID. */\nexport function assertStableLearningContainerId(value: unknown): string {\n if (\n typeof value !== \"string\" ||\n value.length < 1 ||\n value.length > 64 ||\n !STABLE_CONTAINER_ID.test(value)\n ) {\n throw new Error(\n \"Learning Container must use a 1-64 character stable ID with lowercase letters, numbers, and single hyphens\",\n );\n }\n return value;\n}\n\n/** Resolves and validates a public Intelligence Learning Container selection. */\nexport async function resolveLearningContainerSelector(\n selector: GetLearningContainerId,\n input: LearningContainerSelectorInput,\n): Promise<string | undefined> {\n const value = await selector(input);\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n\n/** Resolves the configured Container once for one web or Channel run. */\nexport async function resolveLearningContainerId(\n config: CopilotKitRuntimeLearningConfig | undefined,\n input: CopilotKitRuntimeLearningContext,\n): Promise<string | undefined> {\n if (config === undefined) return undefined;\n const value =\n typeof config.containerId === \"function\"\n ? await config.containerId(input)\n : config.containerId;\n if (value == null) return undefined;\n return assertStableLearningContainerId(value);\n}\n"],"mappings":";;AAKA,SAAgB,kCACd,SACS;AACT,QACE,QAAQ,cAAc,2BAA2B,KAAK,UACtD,QAAQ,UAAU,gBAAgB;;;AAkDtC,eAAsB,sCACpB,UACA,OACA,QACwC;AACxC,SAAQ,gBAAgB;AACxB,KAAI,CAAC,SAAU,QAAO;CACtB,MAAM,aAAa,IAAI,iBAAiB;CACxC,MAAM,gBAAgB,WAAW,MAAM,QAAQ,OAAO;AACtD,SAAQ,iBAAiB,SAAS,SAAS,EAAE,MAAM,MAAM,CAAC;CAC1D,MAAM,UAAU,iBAEZ,WAAW,sBACT,IAAI,MAAM,oDAAoD,CAC/D,EACH,IACD;CACD,IAAI;AACJ,KAAI;EACF,MAAM,YAAY,IAAI,SAAgB,UAAU,WAAW;AACzD,uBAAoB,OAAO,WAAW,OAAO,OAAO;AACpD,cAAW,OAAO,iBAAiB,SAAS,aAAa,EAAE,MAAM,MAAM,CAAC;IACxE;EACF,MAAM,YAAY,IAAI,SACnB,YAAY;AACX,WAAQ,SAAS,OAAO,WAAW,OAAO,CAAC;IAE9C;EACD,MAAM,QAAQ,MAAM,QAAQ,KAAK,CAAC,WAAW,UAAU,CAAC;AACxD,aAAW,OAAO,gBAAgB;AAClC,MAAI,SAAS,KAAM,QAAO;AAC1B,MAAI,CAAC,MAAM,QAAQ,MAAM,IAAI,MAAM,SAAS,IAC1C,OAAM,IAAI,MACR,8EACD;AAGH,SAAO,CAAC,GAAG,IAAI,IAAI,MAAM,KAAK,OAAO,gCAAgC,CAAC,CAAC;WAC/D;AACR,eAAa,QAAQ;AACrB,UAAQ,oBAAoB,SAAS,QAAQ;AAC7C,MAAI,YACF,YAAW,OAAO,oBAAoB,SAAS,YAAY;;;AAgCjE,MAAM,sBAAsB;;AAG5B,SAAgB,gCAAgC,OAAwB;AACtE,KACE,OAAO,UAAU,YACjB,MAAM,SAAS,KACf,MAAM,SAAS,MACf,CAAC,oBAAoB,KAAK,MAAM,CAEhC,OAAM,IAAI,MACR,6GACD;AAEH,QAAO;;;AAIT,eAAsB,iCACpB,UACA,OAC6B;CAC7B,MAAM,QAAQ,MAAM,SAAS,MAAM;AACnC,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM;;;AAI/C,eAAsB,2BACpB,QACA,OAC6B;AAC7B,KAAI,WAAW,OAAW,QAAO;CACjC,MAAM,QACJ,OAAO,OAAO,gBAAgB,aAC1B,MAAM,OAAO,YAAY,MAAM,GAC/B,OAAO;AACb,KAAI,SAAS,KAAM,QAAO;AAC1B,QAAO,gCAAgC,MAAM"}
@@ -1,22 +1,113 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
1
  let _copilotkit_shared = require("@copilotkit/shared");
3
- let pino = require("pino");
4
- pino = require_runtime.__toESM(pino);
5
- let pino_pretty = require("pino-pretty");
6
- pino_pretty = require_runtime.__toESM(pino_pretty);
7
2
 
8
3
  //#region src/runtime/core/logger.ts
4
+ /** The logger a runtime writes to. A runtime without one writes to the console. */
5
+ function getRuntimeLogger(runtime) {
6
+ if (runtime === void 0 || runtime.logger === void 0) return _copilotkit_shared.logger;
7
+ return runtime.logger;
8
+ }
9
+ const DEBUG_COMPONENT = "copilotkit-debug";
10
+ /**
11
+ * The logger for `debug` output. With an app logger, a child of it (or the
12
+ * logger itself when it has no `child`). Without one, JSON lines from
13
+ * `createLogger`.
14
+ */
15
+ function createDebugLogger(logger) {
16
+ if (logger === void 0) return createLogger({
17
+ level: "debug",
18
+ component: DEBUG_COMPONENT
19
+ });
20
+ return typeof logger.child === "function" ? logger.child({ component: DEBUG_COMPONENT }) : logger;
21
+ }
22
+ const METHOD_LEVELS = {
23
+ debug: 20,
24
+ info: 30,
25
+ warn: 40,
26
+ error: 50
27
+ };
28
+ const THRESHOLDS = new Map([
29
+ ["trace", 10],
30
+ ...Object.entries(METHOD_LEVELS),
31
+ ["fatal", 60],
32
+ ["silent", Infinity]
33
+ ]);
34
+ function resolveThreshold(level) {
35
+ const name = (0, _copilotkit_shared.processEnv)().LOG_LEVEL || level || "error";
36
+ return THRESHOLDS.get(name) ?? METHOD_LEVELS.error;
37
+ }
38
+ function createReplacer() {
39
+ const ancestors = [];
40
+ return function replacer(_key, value) {
41
+ while (ancestors.length > 0 && ancestors.at(-1) !== this) ancestors.pop();
42
+ const written = value instanceof Error ? {
43
+ type: value.name,
44
+ message: value.message,
45
+ stack: value.stack
46
+ } : value;
47
+ if (typeof written !== "object" || written === null) return written;
48
+ if (ancestors.includes(written)) return "[Circular]";
49
+ ancestors.push(written);
50
+ return written;
51
+ };
52
+ }
53
+ function buildLogger(threshold, bindings) {
54
+ const createLogFn = (levelValue) => {
55
+ const log = (objOrMsg, msg) => {
56
+ if (levelValue < threshold) return;
57
+ const isMessageOnly = typeof objOrMsg === "string";
58
+ const message = isMessageOnly ? objOrMsg : msg;
59
+ const fields = isMessageOnly ? {} : objOrMsg;
60
+ const head = {
61
+ level: levelValue,
62
+ time: Date.now()
63
+ };
64
+ try {
65
+ const record = {
66
+ ...head,
67
+ ...bindings,
68
+ ...fields
69
+ };
70
+ if (message !== void 0) record.msg = message;
71
+ console.log(JSON.stringify(record, createReplacer()));
72
+ } catch {
73
+ console.log(JSON.stringify({
74
+ ...head,
75
+ msg: message
76
+ }));
77
+ }
78
+ };
79
+ return log;
80
+ };
81
+ return {
82
+ debug: createLogFn(METHOD_LEVELS.debug),
83
+ info: createLogFn(METHOD_LEVELS.info),
84
+ warn: createLogFn(METHOD_LEVELS.warn),
85
+ error: createLogFn(METHOD_LEVELS.error),
86
+ child: (childBindings) => buildLogger(threshold, {
87
+ ...bindings,
88
+ ...childBindings
89
+ })
90
+ };
91
+ }
92
+ /**
93
+ * Creates the runtime logger. Each call writes one JSON line with
94
+ * `console.log`, in pino's format:
95
+ * `{"level":20,"time":<ms>,"component":"...",...fields,"msg":"..."}`.
96
+ *
97
+ * @param options.level - The lowest level to write. The `LOG_LEVEL`
98
+ * environment variable wins over it. The default is `"error"`.
99
+ * @param options.component - Added as `component` to each line.
100
+ *
101
+ * @example
102
+ * const logger = createLogger({ level: "debug", component: "copilotkit-debug" });
103
+ * logger.debug({ eventCount: 2 }, "SSE stream completed");
104
+ */
9
105
  function createLogger(options) {
10
- const { level, component } = options || {};
11
- const stream = (0, pino_pretty.default)({ colorize: true });
12
- const logger = (0, pino.default)({
13
- level: (0, _copilotkit_shared.processEnv)().LOG_LEVEL || level || "error",
14
- base: null
15
- }, stream);
16
- if (component) return logger.child({ component });
17
- else return logger;
106
+ const { level, component } = options ?? {};
107
+ return buildLogger(resolveThreshold(level), component ? { component } : {});
18
108
  }
19
109
 
20
110
  //#endregion
21
- exports.createLogger = createLogger;
111
+ exports.createDebugLogger = createDebugLogger;
112
+ exports.getRuntimeLogger = getRuntimeLogger;
22
113
  //# sourceMappingURL=logger.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.cjs","names":[],"sources":["../../../src/runtime/core/logger.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CopilotRuntimeLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — createLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LogLevel:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { processEnv } from \"@copilotkit/shared\";\nimport createPinoLogger from \"pino\";\nimport pretty from \"pino-pretty\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport type CopilotRuntimeLogger = ReturnType<typeof createLogger>;\n\nexport function createLogger(options?: {\n level?: LogLevel;\n component?: string;\n}) {\n const { level, component } = options || {};\n const stream = pretty({ colorize: true });\n\n const logger = createPinoLogger(\n {\n level: processEnv().LOG_LEVEL || level || \"error\",\n // Drop `pid` and `hostname` with pino's own `base` switch rather than\n // with `redact`. pino 9 validates every redact path by calling\n // `Function(...)`, and edge runtimes such as Cloudflare Workers forbid\n // code generation from strings. That throws while the logger is being\n // built, and the validator reports the first path in the array, so the\n // failure surfaces as the misleading \"redact paths array contains an\n // invalid path (pid)\". `base: null` produces identical output and needs\n // no code generation. See issue #2355.\n base: null,\n },\n stream,\n );\n\n if (component) {\n return logger.child({ component });\n } else {\n return logger;\n }\n}\n"],"mappings":";;;;;;;;AAsCA,SAAgB,aAAa,SAG1B;CACD,MAAM,EAAE,OAAO,cAAc,WAAW,EAAE;CAC1C,MAAM,kCAAgB,EAAE,UAAU,MAAM,CAAC;CAEzC,MAAM,2BACJ;EACE,2CAAmB,CAAC,aAAa,SAAS;EAS1C,MAAM;EACP,EACD,OACD;AAED,KAAI,UACF,QAAO,OAAO,MAAM,EAAE,WAAW,CAAC;KAElC,QAAO"}
1
+ {"version":3,"file":"logger.cjs","names":["consoleLogger"],"sources":["../../../src/runtime/core/logger.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CopilotKitRuntimeLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — createLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LogLevel:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { logger as consoleLogger, processEnv } from \"@copilotkit/shared\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\n/**\n * One log method. Give a message, or an object of fields and an optional\n * message. The fields go into the JSON line next to the message.\n */\ntype LogFn = {\n (msg: string): void;\n (obj: object, msg?: string): void;\n};\n\n/**\n * A logger the runtime can write to. The shape is pino's: each method takes a\n * message, or an object of fields and then a message. pino and `console` fit\n * it as they are. For a logger that takes the message first (for example\n * winston), pass a small adapter.\n */\nexport interface CopilotKitRuntimeLogger {\n debug: LogFn;\n info: LogFn;\n warn: LogFn;\n error: LogFn;\n /**\n * Returns a logger that adds `bindings` to each line it writes. Optional:\n * when it is missing, the runtime uses the logger itself.\n */\n child?(bindings: Record<string, unknown>): CopilotKitRuntimeLogger;\n}\n\n/** The logger a runtime writes to. A runtime without one writes to the console. */\nexport function getRuntimeLogger(runtime?: {\n logger?: CopilotKitRuntimeLogger;\n}): CopilotKitRuntimeLogger {\n if (runtime === undefined || runtime.logger === undefined) {\n return consoleLogger;\n }\n return runtime.logger;\n}\n\nconst DEBUG_COMPONENT = \"copilotkit-debug\";\n\n/**\n * The logger for `debug` output. With an app logger, a child of it (or the\n * logger itself when it has no `child`). Without one, JSON lines from\n * `createLogger`.\n */\nexport function createDebugLogger(\n logger?: CopilotKitRuntimeLogger,\n): CopilotKitRuntimeLogger {\n if (logger === undefined) {\n return createLogger({ level: \"debug\", component: DEBUG_COMPONENT });\n }\n // `child` is optional: `console`, for example, has none.\n return typeof logger.child === \"function\"\n ? logger.child({ component: DEBUG_COMPONENT })\n : logger;\n}\n\n// pino's number levels. A logger writes a line only when the level of the\n// call is at or above its threshold.\nconst METHOD_LEVELS: Record<LogLevel, number> = {\n debug: 20,\n info: 30,\n warn: 40,\n error: 50,\n};\n\n// `LOG_LEVEL` also accepts pino's other level names. They only set the\n// threshold. There are no `trace` or `fatal` methods.\nconst THRESHOLDS = new Map<string, number>([\n [\"trace\", 10],\n ...Object.entries(METHOD_LEVELS),\n [\"fatal\", 60],\n [\"silent\", Infinity],\n]);\n\nfunction resolveThreshold(level: LogLevel | undefined) {\n const name = processEnv().LOG_LEVEL || level || \"error\";\n // An unknown name falls back to \"error\". It must not stop the runtime.\n return THRESHOLDS.get(name) ?? METHOD_LEVELS.error;\n}\n\n// A JSON.stringify replacer. It writes an Error as `{ type, message, stack }`\n// (JSON.stringify writes an Error as `{}`), and it writes a reference back to\n// an ancestor as \"[Circular]\". It keeps a stack of the ancestors of the\n// current value, so an object that is used two times in different places is\n// written two times and is not marked as circular.\nfunction createReplacer() {\n const ancestors: unknown[] = [];\n return function replacer(this: unknown, _key: string, value: unknown) {\n // `this` is the object that holds `value`. Remove the ancestors that\n // JSON.stringify has finished.\n while (ancestors.length > 0 && ancestors.at(-1) !== this) {\n ancestors.pop();\n }\n const written =\n value instanceof Error\n ? { type: value.name, message: value.message, stack: value.stack }\n : value;\n if (typeof written !== \"object\" || written === null) {\n return written;\n }\n if (ancestors.includes(written)) {\n return \"[Circular]\";\n }\n ancestors.push(written);\n return written;\n };\n}\n\nfunction buildLogger(threshold: number, bindings: Record<string, unknown>) {\n const createLogFn = (levelValue: number) => {\n const log: LogFn = (objOrMsg: string | object, msg?: string) => {\n if (levelValue < threshold) {\n return;\n }\n const isMessageOnly = typeof objOrMsg === \"string\";\n const message = isMessageOnly ? objOrMsg : msg;\n const fields = isMessageOnly ? {} : objOrMsg;\n const head = { level: levelValue, time: Date.now() };\n try {\n const record: Record<string, unknown> = {\n ...head,\n ...bindings,\n ...fields,\n };\n if (message !== undefined) {\n record.msg = message;\n }\n console.log(JSON.stringify(record, createReplacer()));\n } catch {\n // A value that JSON cannot write (for example a BigInt or a getter\n // that throws). A log call must never throw, so write the message\n // only.\n console.log(JSON.stringify({ ...head, msg: message }));\n }\n };\n return log;\n };\n\n const logger: CopilotKitRuntimeLogger = {\n debug: createLogFn(METHOD_LEVELS.debug),\n info: createLogFn(METHOD_LEVELS.info),\n warn: createLogFn(METHOD_LEVELS.warn),\n error: createLogFn(METHOD_LEVELS.error),\n child: (childBindings) =>\n buildLogger(threshold, { ...bindings, ...childBindings }),\n };\n return logger;\n}\n\n/**\n * Creates the runtime logger. Each call writes one JSON line with\n * `console.log`, in pino's format:\n * `{\"level\":20,\"time\":<ms>,\"component\":\"...\",...fields,\"msg\":\"...\"}`.\n *\n * @param options.level - The lowest level to write. The `LOG_LEVEL`\n * environment variable wins over it. The default is `\"error\"`.\n * @param options.component - Added as `component` to each line.\n *\n * @example\n * const logger = createLogger({ level: \"debug\", component: \"copilotkit-debug\" });\n * logger.debug({ eventCount: 2 }, \"SSE stream completed\");\n */\nexport function createLogger(options?: {\n level?: LogLevel;\n component?: string;\n}) {\n const { level, component } = options ?? {};\n return buildLogger(resolveThreshold(level), component ? { component } : {});\n}\n"],"mappings":";;;;AA8DA,SAAgB,iBAAiB,SAEL;AAC1B,KAAI,YAAY,UAAa,QAAQ,WAAW,OAC9C,QAAOA;AAET,QAAO,QAAQ;;AAGjB,MAAM,kBAAkB;;;;;;AAOxB,SAAgB,kBACd,QACyB;AACzB,KAAI,WAAW,OACb,QAAO,aAAa;EAAE,OAAO;EAAS,WAAW;EAAiB,CAAC;AAGrE,QAAO,OAAO,OAAO,UAAU,aAC3B,OAAO,MAAM,EAAE,WAAW,iBAAiB,CAAC,GAC5C;;AAKN,MAAM,gBAA0C;CAC9C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACR;AAID,MAAM,aAAa,IAAI,IAAoB;CACzC,CAAC,SAAS,GAAG;CACb,GAAG,OAAO,QAAQ,cAAc;CAChC,CAAC,SAAS,GAAG;CACb,CAAC,UAAU,SAAS;CACrB,CAAC;AAEF,SAAS,iBAAiB,OAA6B;CACrD,MAAM,2CAAmB,CAAC,aAAa,SAAS;AAEhD,QAAO,WAAW,IAAI,KAAK,IAAI,cAAc;;AAQ/C,SAAS,iBAAiB;CACxB,MAAM,YAAuB,EAAE;AAC/B,QAAO,SAAS,SAAwB,MAAc,OAAgB;AAGpE,SAAO,UAAU,SAAS,KAAK,UAAU,GAAG,GAAG,KAAK,KAClD,WAAU,KAAK;EAEjB,MAAM,UACJ,iBAAiB,QACb;GAAE,MAAM,MAAM;GAAM,SAAS,MAAM;GAAS,OAAO,MAAM;GAAO,GAChE;AACN,MAAI,OAAO,YAAY,YAAY,YAAY,KAC7C,QAAO;AAET,MAAI,UAAU,SAAS,QAAQ,CAC7B,QAAO;AAET,YAAU,KAAK,QAAQ;AACvB,SAAO;;;AAIX,SAAS,YAAY,WAAmB,UAAmC;CACzE,MAAM,eAAe,eAAuB;EAC1C,MAAM,OAAc,UAA2B,QAAiB;AAC9D,OAAI,aAAa,UACf;GAEF,MAAM,gBAAgB,OAAO,aAAa;GAC1C,MAAM,UAAU,gBAAgB,WAAW;GAC3C,MAAM,SAAS,gBAAgB,EAAE,GAAG;GACpC,MAAM,OAAO;IAAE,OAAO;IAAY,MAAM,KAAK,KAAK;IAAE;AACpD,OAAI;IACF,MAAM,SAAkC;KACtC,GAAG;KACH,GAAG;KACH,GAAG;KACJ;AACD,QAAI,YAAY,OACd,QAAO,MAAM;AAEf,YAAQ,IAAI,KAAK,UAAU,QAAQ,gBAAgB,CAAC,CAAC;WAC/C;AAIN,YAAQ,IAAI,KAAK,UAAU;KAAE,GAAG;KAAM,KAAK;KAAS,CAAC,CAAC;;;AAG1D,SAAO;;AAWT,QARwC;EACtC,OAAO,YAAY,cAAc,MAAM;EACvC,MAAM,YAAY,cAAc,KAAK;EACrC,MAAM,YAAY,cAAc,KAAK;EACrC,OAAO,YAAY,cAAc,MAAM;EACvC,QAAQ,kBACN,YAAY,WAAW;GAAE,GAAG;GAAU,GAAG;GAAe,CAAC;EAC5D;;;;;;;;;;;;;;;AAiBH,SAAgB,aAAa,SAG1B;CACD,MAAM,EAAE,OAAO,cAAc,WAAW,EAAE;AAC1C,QAAO,YAAY,iBAAiB,MAAM,EAAE,YAAY,EAAE,WAAW,GAAG,EAAE,CAAC"}
@@ -1,12 +1,29 @@
1
- import createPinoLogger from "pino";
2
-
3
1
  //#region src/runtime/core/logger.d.ts
4
- type LogLevel = "debug" | "info" | "warn" | "error";
5
- type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
6
- declare function createLogger(options?: {
7
- level?: LogLevel;
8
- component?: string;
9
- }): createPinoLogger.Logger<never, boolean>;
2
+ /**
3
+ * One log method. Give a message, or an object of fields and an optional
4
+ * message. The fields go into the JSON line next to the message.
5
+ */
6
+ type LogFn = {
7
+ (msg: string): void;
8
+ (obj: object, msg?: string): void;
9
+ };
10
+ /**
11
+ * A logger the runtime can write to. The shape is pino's: each method takes a
12
+ * message, or an object of fields and then a message. pino and `console` fit
13
+ * it as they are. For a logger that takes the message first (for example
14
+ * winston), pass a small adapter.
15
+ */
16
+ interface CopilotKitRuntimeLogger {
17
+ debug: LogFn;
18
+ info: LogFn;
19
+ warn: LogFn;
20
+ error: LogFn;
21
+ /**
22
+ * Returns a logger that adds `bindings` to each line it writes. Optional:
23
+ * when it is missing, the runtime uses the logger itself.
24
+ */
25
+ child?(bindings: Record<string, unknown>): CopilotKitRuntimeLogger;
26
+ }
10
27
  //#endregion
11
- export { CopilotRuntimeLogger };
28
+ export { CopilotKitRuntimeLogger };
12
29
  //# sourceMappingURL=logger.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.cts","names":[],"sources":["../../../src/runtime/core/logger.ts"],"mappings":";;;KAkCY,QAAA;AAAA,KAEA,oBAAA,GAAuB,UAAA,QAAkB,YAAA;AAAA,iBAErC,YAAA,CAAa,OAAA;EAC3B,KAAA,GAAQ,QAAA;EACR,SAAA;AAAA,IACD,gBAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"logger.d.cts","names":[],"sources":["../../../src/runtime/core/logger.ts"],"mappings":";AAgC2D;;;;AAAA,KAMtD,KAAA;EAAA,CACF,GAAA;EAAA,CACA,GAAA,UAAa,GAAA;AAAA;;AAShB;;;;;UAAiB,uBAAA;EACf,KAAA,EAAO,KAAA;EACP,IAAA,EAAM,KAAA;EACN,IAAA,EAAM,KAAA;EACN,KAAA,EAAO,KAAA;EAK2D;;;;EAAlE,KAAA,EAAO,QAAA,EAAU,MAAA,oBAA0B,uBAAA;AAAA"}
@@ -1,12 +1,29 @@
1
- import createPinoLogger from "pino";
2
-
3
1
  //#region src/runtime/core/logger.d.ts
4
- type LogLevel = "debug" | "info" | "warn" | "error";
5
- type CopilotRuntimeLogger = ReturnType<typeof createLogger>;
6
- declare function createLogger(options?: {
7
- level?: LogLevel;
8
- component?: string;
9
- }): createPinoLogger.Logger<never, boolean>;
2
+ /**
3
+ * One log method. Give a message, or an object of fields and an optional
4
+ * message. The fields go into the JSON line next to the message.
5
+ */
6
+ type LogFn = {
7
+ (msg: string): void;
8
+ (obj: object, msg?: string): void;
9
+ };
10
+ /**
11
+ * A logger the runtime can write to. The shape is pino's: each method takes a
12
+ * message, or an object of fields and then a message. pino and `console` fit
13
+ * it as they are. For a logger that takes the message first (for example
14
+ * winston), pass a small adapter.
15
+ */
16
+ interface CopilotKitRuntimeLogger {
17
+ debug: LogFn;
18
+ info: LogFn;
19
+ warn: LogFn;
20
+ error: LogFn;
21
+ /**
22
+ * Returns a logger that adds `bindings` to each line it writes. Optional:
23
+ * when it is missing, the runtime uses the logger itself.
24
+ */
25
+ child?(bindings: Record<string, unknown>): CopilotKitRuntimeLogger;
26
+ }
10
27
  //#endregion
11
- export { CopilotRuntimeLogger };
28
+ export { CopilotKitRuntimeLogger };
12
29
  //# sourceMappingURL=logger.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.d.mts","names":[],"sources":["../../../src/runtime/core/logger.ts"],"mappings":";;;KAkCY,QAAA;AAAA,KAEA,oBAAA,GAAuB,UAAA,QAAkB,YAAA;AAAA,iBAErC,YAAA,CAAa,OAAA;EAC3B,KAAA,GAAQ,QAAA;EACR,SAAA;AAAA,IACD,gBAAA,CAAA,MAAA"}
1
+ {"version":3,"file":"logger.d.mts","names":[],"sources":["../../../src/runtime/core/logger.ts"],"mappings":";AAgC2D;;;;AAAA,KAMtD,KAAA;EAAA,CACF,GAAA;EAAA,CACA,GAAA,UAAa,GAAA;AAAA;;AAShB;;;;;UAAiB,uBAAA;EACf,KAAA,EAAO,KAAA;EACP,IAAA,EAAM,KAAA;EACN,IAAA,EAAM,KAAA;EACN,KAAA,EAAO,KAAA;EAK2D;;;;EAAlE,KAAA,EAAO,QAAA,EAAU,MAAA,oBAA0B,uBAAA;AAAA"}
@@ -1,19 +1,112 @@
1
- import { processEnv } from "@copilotkit/shared";
2
- import createPinoLogger from "pino";
3
- import pretty from "pino-pretty";
1
+ import { logger, processEnv } from "@copilotkit/shared";
4
2
 
5
3
  //#region src/runtime/core/logger.ts
4
+ /** The logger a runtime writes to. A runtime without one writes to the console. */
5
+ function getRuntimeLogger(runtime) {
6
+ if (runtime === void 0 || runtime.logger === void 0) return logger;
7
+ return runtime.logger;
8
+ }
9
+ const DEBUG_COMPONENT = "copilotkit-debug";
10
+ /**
11
+ * The logger for `debug` output. With an app logger, a child of it (or the
12
+ * logger itself when it has no `child`). Without one, JSON lines from
13
+ * `createLogger`.
14
+ */
15
+ function createDebugLogger(logger) {
16
+ if (logger === void 0) return createLogger({
17
+ level: "debug",
18
+ component: DEBUG_COMPONENT
19
+ });
20
+ return typeof logger.child === "function" ? logger.child({ component: DEBUG_COMPONENT }) : logger;
21
+ }
22
+ const METHOD_LEVELS = {
23
+ debug: 20,
24
+ info: 30,
25
+ warn: 40,
26
+ error: 50
27
+ };
28
+ const THRESHOLDS = new Map([
29
+ ["trace", 10],
30
+ ...Object.entries(METHOD_LEVELS),
31
+ ["fatal", 60],
32
+ ["silent", Infinity]
33
+ ]);
34
+ function resolveThreshold(level) {
35
+ const name = processEnv().LOG_LEVEL || level || "error";
36
+ return THRESHOLDS.get(name) ?? METHOD_LEVELS.error;
37
+ }
38
+ function createReplacer() {
39
+ const ancestors = [];
40
+ return function replacer(_key, value) {
41
+ while (ancestors.length > 0 && ancestors.at(-1) !== this) ancestors.pop();
42
+ const written = value instanceof Error ? {
43
+ type: value.name,
44
+ message: value.message,
45
+ stack: value.stack
46
+ } : value;
47
+ if (typeof written !== "object" || written === null) return written;
48
+ if (ancestors.includes(written)) return "[Circular]";
49
+ ancestors.push(written);
50
+ return written;
51
+ };
52
+ }
53
+ function buildLogger(threshold, bindings) {
54
+ const createLogFn = (levelValue) => {
55
+ const log = (objOrMsg, msg) => {
56
+ if (levelValue < threshold) return;
57
+ const isMessageOnly = typeof objOrMsg === "string";
58
+ const message = isMessageOnly ? objOrMsg : msg;
59
+ const fields = isMessageOnly ? {} : objOrMsg;
60
+ const head = {
61
+ level: levelValue,
62
+ time: Date.now()
63
+ };
64
+ try {
65
+ const record = {
66
+ ...head,
67
+ ...bindings,
68
+ ...fields
69
+ };
70
+ if (message !== void 0) record.msg = message;
71
+ console.log(JSON.stringify(record, createReplacer()));
72
+ } catch {
73
+ console.log(JSON.stringify({
74
+ ...head,
75
+ msg: message
76
+ }));
77
+ }
78
+ };
79
+ return log;
80
+ };
81
+ return {
82
+ debug: createLogFn(METHOD_LEVELS.debug),
83
+ info: createLogFn(METHOD_LEVELS.info),
84
+ warn: createLogFn(METHOD_LEVELS.warn),
85
+ error: createLogFn(METHOD_LEVELS.error),
86
+ child: (childBindings) => buildLogger(threshold, {
87
+ ...bindings,
88
+ ...childBindings
89
+ })
90
+ };
91
+ }
92
+ /**
93
+ * Creates the runtime logger. Each call writes one JSON line with
94
+ * `console.log`, in pino's format:
95
+ * `{"level":20,"time":<ms>,"component":"...",...fields,"msg":"..."}`.
96
+ *
97
+ * @param options.level - The lowest level to write. The `LOG_LEVEL`
98
+ * environment variable wins over it. The default is `"error"`.
99
+ * @param options.component - Added as `component` to each line.
100
+ *
101
+ * @example
102
+ * const logger = createLogger({ level: "debug", component: "copilotkit-debug" });
103
+ * logger.debug({ eventCount: 2 }, "SSE stream completed");
104
+ */
6
105
  function createLogger(options) {
7
- const { level, component } = options || {};
8
- const stream = pretty({ colorize: true });
9
- const logger = createPinoLogger({
10
- level: processEnv().LOG_LEVEL || level || "error",
11
- base: null
12
- }, stream);
13
- if (component) return logger.child({ component });
14
- else return logger;
106
+ const { level, component } = options ?? {};
107
+ return buildLogger(resolveThreshold(level), component ? { component } : {});
15
108
  }
16
109
 
17
110
  //#endregion
18
- export { createLogger };
111
+ export { createDebugLogger, getRuntimeLogger };
19
112
  //# sourceMappingURL=logger.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"logger.mjs","names":[],"sources":["../../../src/runtime/core/logger.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CopilotRuntimeLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — createLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LogLevel:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { processEnv } from \"@copilotkit/shared\";\nimport createPinoLogger from \"pino\";\nimport pretty from \"pino-pretty\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\nexport type CopilotRuntimeLogger = ReturnType<typeof createLogger>;\n\nexport function createLogger(options?: {\n level?: LogLevel;\n component?: string;\n}) {\n const { level, component } = options || {};\n const stream = pretty({ colorize: true });\n\n const logger = createPinoLogger(\n {\n level: processEnv().LOG_LEVEL || level || \"error\",\n // Drop `pid` and `hostname` with pino's own `base` switch rather than\n // with `redact`. pino 9 validates every redact path by calling\n // `Function(...)`, and edge runtimes such as Cloudflare Workers forbid\n // code generation from strings. That throws while the logger is being\n // built, and the validator reports the first path in the array, so the\n // failure surfaces as the misleading \"redact paths array contains an\n // invalid path (pid)\". `base: null` produces identical output and needs\n // no code generation. See issue #2355.\n base: null,\n },\n stream,\n );\n\n if (component) {\n return logger.child({ component });\n } else {\n return logger;\n }\n}\n"],"mappings":";;;;;AAsCA,SAAgB,aAAa,SAG1B;CACD,MAAM,EAAE,OAAO,cAAc,WAAW,EAAE;CAC1C,MAAM,SAAS,OAAO,EAAE,UAAU,MAAM,CAAC;CAEzC,MAAM,SAAS,iBACb;EACE,OAAO,YAAY,CAAC,aAAa,SAAS;EAS1C,MAAM;EACP,EACD,OACD;AAED,KAAI,UACF,QAAO,OAAO,MAAM,EAAE,WAAW,CAAC;KAElC,QAAO"}
1
+ {"version":3,"file":"logger.mjs","names":["consoleLogger"],"sources":["../../../src/runtime/core/logger.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — CopilotKitRuntimeLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — createLogger:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — LogLevel:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\nimport { logger as consoleLogger, processEnv } from \"@copilotkit/shared\";\n\nexport type LogLevel = \"debug\" | \"info\" | \"warn\" | \"error\";\n\n/**\n * One log method. Give a message, or an object of fields and an optional\n * message. The fields go into the JSON line next to the message.\n */\ntype LogFn = {\n (msg: string): void;\n (obj: object, msg?: string): void;\n};\n\n/**\n * A logger the runtime can write to. The shape is pino's: each method takes a\n * message, or an object of fields and then a message. pino and `console` fit\n * it as they are. For a logger that takes the message first (for example\n * winston), pass a small adapter.\n */\nexport interface CopilotKitRuntimeLogger {\n debug: LogFn;\n info: LogFn;\n warn: LogFn;\n error: LogFn;\n /**\n * Returns a logger that adds `bindings` to each line it writes. Optional:\n * when it is missing, the runtime uses the logger itself.\n */\n child?(bindings: Record<string, unknown>): CopilotKitRuntimeLogger;\n}\n\n/** The logger a runtime writes to. A runtime without one writes to the console. */\nexport function getRuntimeLogger(runtime?: {\n logger?: CopilotKitRuntimeLogger;\n}): CopilotKitRuntimeLogger {\n if (runtime === undefined || runtime.logger === undefined) {\n return consoleLogger;\n }\n return runtime.logger;\n}\n\nconst DEBUG_COMPONENT = \"copilotkit-debug\";\n\n/**\n * The logger for `debug` output. With an app logger, a child of it (or the\n * logger itself when it has no `child`). Without one, JSON lines from\n * `createLogger`.\n */\nexport function createDebugLogger(\n logger?: CopilotKitRuntimeLogger,\n): CopilotKitRuntimeLogger {\n if (logger === undefined) {\n return createLogger({ level: \"debug\", component: DEBUG_COMPONENT });\n }\n // `child` is optional: `console`, for example, has none.\n return typeof logger.child === \"function\"\n ? logger.child({ component: DEBUG_COMPONENT })\n : logger;\n}\n\n// pino's number levels. A logger writes a line only when the level of the\n// call is at or above its threshold.\nconst METHOD_LEVELS: Record<LogLevel, number> = {\n debug: 20,\n info: 30,\n warn: 40,\n error: 50,\n};\n\n// `LOG_LEVEL` also accepts pino's other level names. They only set the\n// threshold. There are no `trace` or `fatal` methods.\nconst THRESHOLDS = new Map<string, number>([\n [\"trace\", 10],\n ...Object.entries(METHOD_LEVELS),\n [\"fatal\", 60],\n [\"silent\", Infinity],\n]);\n\nfunction resolveThreshold(level: LogLevel | undefined) {\n const name = processEnv().LOG_LEVEL || level || \"error\";\n // An unknown name falls back to \"error\". It must not stop the runtime.\n return THRESHOLDS.get(name) ?? METHOD_LEVELS.error;\n}\n\n// A JSON.stringify replacer. It writes an Error as `{ type, message, stack }`\n// (JSON.stringify writes an Error as `{}`), and it writes a reference back to\n// an ancestor as \"[Circular]\". It keeps a stack of the ancestors of the\n// current value, so an object that is used two times in different places is\n// written two times and is not marked as circular.\nfunction createReplacer() {\n const ancestors: unknown[] = [];\n return function replacer(this: unknown, _key: string, value: unknown) {\n // `this` is the object that holds `value`. Remove the ancestors that\n // JSON.stringify has finished.\n while (ancestors.length > 0 && ancestors.at(-1) !== this) {\n ancestors.pop();\n }\n const written =\n value instanceof Error\n ? { type: value.name, message: value.message, stack: value.stack }\n : value;\n if (typeof written !== \"object\" || written === null) {\n return written;\n }\n if (ancestors.includes(written)) {\n return \"[Circular]\";\n }\n ancestors.push(written);\n return written;\n };\n}\n\nfunction buildLogger(threshold: number, bindings: Record<string, unknown>) {\n const createLogFn = (levelValue: number) => {\n const log: LogFn = (objOrMsg: string | object, msg?: string) => {\n if (levelValue < threshold) {\n return;\n }\n const isMessageOnly = typeof objOrMsg === \"string\";\n const message = isMessageOnly ? objOrMsg : msg;\n const fields = isMessageOnly ? {} : objOrMsg;\n const head = { level: levelValue, time: Date.now() };\n try {\n const record: Record<string, unknown> = {\n ...head,\n ...bindings,\n ...fields,\n };\n if (message !== undefined) {\n record.msg = message;\n }\n console.log(JSON.stringify(record, createReplacer()));\n } catch {\n // A value that JSON cannot write (for example a BigInt or a getter\n // that throws). A log call must never throw, so write the message\n // only.\n console.log(JSON.stringify({ ...head, msg: message }));\n }\n };\n return log;\n };\n\n const logger: CopilotKitRuntimeLogger = {\n debug: createLogFn(METHOD_LEVELS.debug),\n info: createLogFn(METHOD_LEVELS.info),\n warn: createLogFn(METHOD_LEVELS.warn),\n error: createLogFn(METHOD_LEVELS.error),\n child: (childBindings) =>\n buildLogger(threshold, { ...bindings, ...childBindings }),\n };\n return logger;\n}\n\n/**\n * Creates the runtime logger. Each call writes one JSON line with\n * `console.log`, in pino's format:\n * `{\"level\":20,\"time\":<ms>,\"component\":\"...\",...fields,\"msg\":\"...\"}`.\n *\n * @param options.level - The lowest level to write. The `LOG_LEVEL`\n * environment variable wins over it. The default is `\"error\"`.\n * @param options.component - Added as `component` to each line.\n *\n * @example\n * const logger = createLogger({ level: \"debug\", component: \"copilotkit-debug\" });\n * logger.debug({ eventCount: 2 }, \"SSE stream completed\");\n */\nexport function createLogger(options?: {\n level?: LogLevel;\n component?: string;\n}) {\n const { level, component } = options ?? {};\n return buildLogger(resolveThreshold(level), component ? { component } : {});\n}\n"],"mappings":";;;;AA8DA,SAAgB,iBAAiB,SAEL;AAC1B,KAAI,YAAY,UAAa,QAAQ,WAAW,OAC9C,QAAOA;AAET,QAAO,QAAQ;;AAGjB,MAAM,kBAAkB;;;;;;AAOxB,SAAgB,kBACd,QACyB;AACzB,KAAI,WAAW,OACb,QAAO,aAAa;EAAE,OAAO;EAAS,WAAW;EAAiB,CAAC;AAGrE,QAAO,OAAO,OAAO,UAAU,aAC3B,OAAO,MAAM,EAAE,WAAW,iBAAiB,CAAC,GAC5C;;AAKN,MAAM,gBAA0C;CAC9C,OAAO;CACP,MAAM;CACN,MAAM;CACN,OAAO;CACR;AAID,MAAM,aAAa,IAAI,IAAoB;CACzC,CAAC,SAAS,GAAG;CACb,GAAG,OAAO,QAAQ,cAAc;CAChC,CAAC,SAAS,GAAG;CACb,CAAC,UAAU,SAAS;CACrB,CAAC;AAEF,SAAS,iBAAiB,OAA6B;CACrD,MAAM,OAAO,YAAY,CAAC,aAAa,SAAS;AAEhD,QAAO,WAAW,IAAI,KAAK,IAAI,cAAc;;AAQ/C,SAAS,iBAAiB;CACxB,MAAM,YAAuB,EAAE;AAC/B,QAAO,SAAS,SAAwB,MAAc,OAAgB;AAGpE,SAAO,UAAU,SAAS,KAAK,UAAU,GAAG,GAAG,KAAK,KAClD,WAAU,KAAK;EAEjB,MAAM,UACJ,iBAAiB,QACb;GAAE,MAAM,MAAM;GAAM,SAAS,MAAM;GAAS,OAAO,MAAM;GAAO,GAChE;AACN,MAAI,OAAO,YAAY,YAAY,YAAY,KAC7C,QAAO;AAET,MAAI,UAAU,SAAS,QAAQ,CAC7B,QAAO;AAET,YAAU,KAAK,QAAQ;AACvB,SAAO;;;AAIX,SAAS,YAAY,WAAmB,UAAmC;CACzE,MAAM,eAAe,eAAuB;EAC1C,MAAM,OAAc,UAA2B,QAAiB;AAC9D,OAAI,aAAa,UACf;GAEF,MAAM,gBAAgB,OAAO,aAAa;GAC1C,MAAM,UAAU,gBAAgB,WAAW;GAC3C,MAAM,SAAS,gBAAgB,EAAE,GAAG;GACpC,MAAM,OAAO;IAAE,OAAO;IAAY,MAAM,KAAK,KAAK;IAAE;AACpD,OAAI;IACF,MAAM,SAAkC;KACtC,GAAG;KACH,GAAG;KACH,GAAG;KACJ;AACD,QAAI,YAAY,OACd,QAAO,MAAM;AAEf,YAAQ,IAAI,KAAK,UAAU,QAAQ,gBAAgB,CAAC,CAAC;WAC/C;AAIN,YAAQ,IAAI,KAAK,UAAU;KAAE,GAAG;KAAM,KAAK;KAAS,CAAC,CAAC;;;AAG1D,SAAO;;AAWT,QARwC;EACtC,OAAO,YAAY,cAAc,MAAM;EACvC,MAAM,YAAY,cAAc,KAAK;EACrC,MAAM,YAAY,cAAc,KAAK;EACrC,OAAO,YAAY,cAAc,MAAM;EACvC,QAAQ,kBACN,YAAY,WAAW;GAAE,GAAG;GAAU,GAAG;GAAe,CAAC;EAC5D;;;;;;;;;;;;;;;AAiBH,SAAgB,aAAa,SAG1B;CACD,MAAM,EAAE,OAAO,cAAc,WAAW,EAAE;AAC1C,QAAO,YAAY,iBAAiB,MAAM,EAAE,YAAY,EAAE,WAAW,GAAG,EAAE,CAAC"}
@@ -1,18 +1,17 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
- let _copilotkit_shared = require("@copilotkit/shared");
1
+ const require_logger = require('./logger.cjs');
3
2
 
4
3
  //#region src/runtime/core/middleware-sse-parser.ts
5
4
  /**
6
5
  * Parse a cloned SSE Response body into structured messages.
7
6
  * Returns empty results for non-SSE responses.
8
7
  */
9
- async function parseSSEResponse(response) {
8
+ async function parseSSEResponse(response, logger = require_logger.getRuntimeLogger()) {
10
9
  if (!(response.headers.get("content-type") ?? "").includes("text/event-stream")) return { messages: [] };
11
10
  let text;
12
11
  try {
13
12
  text = await response.text();
14
13
  } catch {
15
- _copilotkit_shared.logger.warn("Failed to read SSE response body in afterRequestMiddleware");
14
+ logger.warn("Failed to read SSE response body in afterRequestMiddleware");
16
15
  return { messages: [] };
17
16
  }
18
17
  if (!text.trim()) return { messages: [] };