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

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 (300) hide show
  1. package/README.md +28 -3
  2. package/dist/agent/{url-download.cjs → ai-sdk/url-download.cjs} +19 -76
  3. package/dist/agent/ai-sdk/url-download.cjs.map +1 -0
  4. package/dist/agent/{url-download.d.cts → ai-sdk/url-download.d.cts} +11 -8
  5. package/dist/agent/ai-sdk/url-download.d.cts.map +1 -0
  6. package/dist/agent/{url-download.d.mts → ai-sdk/url-download.d.mts} +11 -8
  7. package/dist/agent/ai-sdk/url-download.d.mts.map +1 -0
  8. package/dist/agent/{url-download.mjs → ai-sdk/url-download.mjs} +20 -74
  9. package/dist/agent/ai-sdk/url-download.mjs.map +1 -0
  10. package/dist/agent/ai-sdk.cjs +425 -0
  11. package/dist/agent/ai-sdk.cjs.map +1 -0
  12. package/dist/agent/ai-sdk.d.cts +119 -0
  13. package/dist/agent/ai-sdk.d.cts.map +1 -0
  14. package/dist/agent/ai-sdk.d.mts +119 -0
  15. package/dist/agent/ai-sdk.d.mts.map +1 -0
  16. package/dist/agent/ai-sdk.mjs +419 -0
  17. package/dist/agent/ai-sdk.mjs.map +1 -0
  18. package/dist/agent/classic-tools.cjs +185 -0
  19. package/dist/agent/classic-tools.cjs.map +1 -0
  20. package/dist/agent/classic-tools.mjs +183 -0
  21. package/dist/agent/classic-tools.mjs.map +1 -0
  22. package/dist/agent/converters/aisdk.cjs +16 -3
  23. package/dist/agent/converters/aisdk.cjs.map +1 -1
  24. package/dist/agent/converters/aisdk.d.cts.map +1 -1
  25. package/dist/agent/converters/aisdk.d.mts.map +1 -1
  26. package/dist/agent/converters/aisdk.mjs +18 -2
  27. package/dist/agent/converters/aisdk.mjs.map +1 -1
  28. package/dist/agent/converters/tanstack.cjs +201 -29
  29. package/dist/agent/converters/tanstack.cjs.map +1 -1
  30. package/dist/agent/converters/tanstack.d.cts +90 -6
  31. package/dist/agent/converters/tanstack.d.cts.map +1 -1
  32. package/dist/agent/converters/tanstack.d.mts +90 -6
  33. package/dist/agent/converters/tanstack.d.mts.map +1 -1
  34. package/dist/agent/converters/tanstack.mjs +201 -28
  35. package/dist/agent/converters/tanstack.mjs.map +1 -1
  36. package/dist/agent/learned-skills.cjs +15 -17
  37. package/dist/agent/learned-skills.cjs.map +1 -1
  38. package/dist/agent/learned-skills.d.cts +9 -3
  39. package/dist/agent/learned-skills.d.cts.map +1 -1
  40. package/dist/agent/learned-skills.d.mts +9 -3
  41. package/dist/agent/learned-skills.d.mts.map +1 -1
  42. package/dist/agent/learned-skills.mjs +15 -16
  43. package/dist/agent/learned-skills.mjs.map +1 -1
  44. package/dist/agent/model.cjs +42 -0
  45. package/dist/agent/model.cjs.map +1 -0
  46. package/dist/agent/model.d.cts +19 -0
  47. package/dist/agent/model.d.cts.map +1 -0
  48. package/dist/agent/model.d.mts +19 -0
  49. package/dist/agent/model.d.mts.map +1 -0
  50. package/dist/agent/model.mjs +41 -0
  51. package/dist/agent/model.mjs.map +1 -0
  52. package/dist/agent/state-delta.cjs +0 -1
  53. package/dist/agent/state-delta.cjs.map +1 -1
  54. package/dist/agent.cjs +558 -0
  55. package/dist/agent.cjs.map +1 -0
  56. package/dist/agent.d.cts +455 -0
  57. package/dist/agent.d.cts.map +1 -0
  58. package/dist/agent.d.mts +455 -0
  59. package/dist/agent.d.mts.map +1 -0
  60. package/dist/agent.mjs +551 -0
  61. package/dist/agent.mjs.map +1 -0
  62. package/dist/index.cjs +21 -27
  63. package/dist/index.d.cts +9 -11
  64. package/dist/index.d.mts +9 -11
  65. package/dist/index.mjs +5 -6
  66. package/dist/internal/learned-skills.d.cts +1 -1
  67. package/dist/internal/learned-skills.d.mts +1 -1
  68. package/dist/node.cjs +1 -2
  69. package/dist/node.d.cts +2 -2
  70. package/dist/node.d.mts +2 -2
  71. package/dist/node.mjs +2 -2
  72. package/dist/runtime/core/channel-manager.cjs +10 -2
  73. package/dist/runtime/core/channel-manager.cjs.map +1 -1
  74. package/dist/runtime/core/channel-manager.d.cts +1 -1
  75. package/dist/runtime/core/channel-manager.d.mts +1 -1
  76. package/dist/runtime/core/channel-manager.mjs +10 -1
  77. package/dist/runtime/core/channel-manager.mjs.map +1 -1
  78. package/dist/runtime/core/debug-event-bus.cjs +0 -1
  79. package/dist/runtime/core/debug-event-bus.cjs.map +1 -1
  80. package/dist/runtime/core/debug-event-bus.d.cts +1 -1
  81. package/dist/runtime/core/fetch-handler.cjs +7 -5
  82. package/dist/runtime/core/fetch-handler.cjs.map +1 -1
  83. package/dist/runtime/core/fetch-handler.d.cts +8 -0
  84. package/dist/runtime/core/fetch-handler.d.cts.map +1 -1
  85. package/dist/runtime/core/fetch-handler.d.mts +8 -0
  86. package/dist/runtime/core/fetch-handler.d.mts.map +1 -1
  87. package/dist/runtime/core/fetch-handler.mjs +4 -1
  88. package/dist/runtime/core/fetch-handler.mjs.map +1 -1
  89. package/dist/runtime/core/learning.d.cts +1 -1
  90. package/dist/runtime/core/logger.cjs +85 -13
  91. package/dist/runtime/core/logger.cjs.map +1 -1
  92. package/dist/runtime/core/logger.d.cts +21 -8
  93. package/dist/runtime/core/logger.d.cts.map +1 -1
  94. package/dist/runtime/core/logger.d.mts +21 -8
  95. package/dist/runtime/core/logger.d.mts.map +1 -1
  96. package/dist/runtime/core/logger.mjs +85 -10
  97. package/dist/runtime/core/logger.mjs.map +1 -1
  98. package/dist/runtime/core/middleware-sse-parser.cjs +0 -1
  99. package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -1
  100. package/dist/runtime/core/middleware.cjs +0 -1
  101. package/dist/runtime/core/middleware.cjs.map +1 -1
  102. package/dist/runtime/core/package-info.cjs +1 -1
  103. package/dist/runtime/core/package-info.mjs +1 -1
  104. package/dist/runtime/core/runtime.cjs +0 -1
  105. package/dist/runtime/core/runtime.cjs.map +1 -1
  106. package/dist/runtime/core/runtime.d.cts +3 -3
  107. package/dist/runtime/core/runtime.d.mts +3 -3
  108. package/dist/runtime/endpoints/auto-start-channels.cjs +0 -1
  109. package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -1
  110. package/dist/runtime/endpoints/node-fetch-handler.cjs +0 -4
  111. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -1
  112. package/dist/runtime/endpoints/node-fetch-handler.d.cts +1 -3
  113. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -1
  114. package/dist/runtime/endpoints/node-fetch-handler.d.mts +1 -3
  115. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -1
  116. package/dist/runtime/endpoints/node-fetch-handler.mjs +1 -3
  117. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -1
  118. package/dist/runtime/event-transforms/index.d.cts +4 -0
  119. package/dist/runtime/event-transforms/index.d.mts +4 -0
  120. package/dist/runtime/event-transforms/index.mjs +5 -0
  121. package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs +277 -0
  122. package/dist/runtime/event-transforms/open-generative-ui-middleware.cjs.map +1 -0
  123. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts +61 -0
  124. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.cts.map +1 -0
  125. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts +61 -0
  126. package/dist/runtime/event-transforms/open-generative-ui-middleware.d.mts.map +1 -0
  127. package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs +276 -0
  128. package/dist/runtime/event-transforms/open-generative-ui-middleware.mjs.map +1 -0
  129. package/dist/runtime/event-transforms/recorded-events.cjs +58 -0
  130. package/dist/runtime/event-transforms/recorded-events.cjs.map +1 -0
  131. package/dist/runtime/event-transforms/recorded-events.d.cts +23 -0
  132. package/dist/runtime/event-transforms/recorded-events.d.cts.map +1 -0
  133. package/dist/runtime/event-transforms/recorded-events.d.mts +23 -0
  134. package/dist/runtime/event-transforms/recorded-events.d.mts.map +1 -0
  135. package/dist/runtime/event-transforms/recorded-events.mjs +58 -0
  136. package/dist/runtime/event-transforms/recorded-events.mjs.map +1 -0
  137. package/dist/runtime/event-transforms/streaming-json-scanner.cjs +289 -0
  138. package/dist/runtime/event-transforms/streaming-json-scanner.cjs.map +1 -0
  139. package/dist/runtime/event-transforms/streaming-json-scanner.mjs +288 -0
  140. package/dist/runtime/event-transforms/streaming-json-scanner.mjs.map +1 -0
  141. package/dist/runtime/generative-ui/generative-ui-middleware.cjs +0 -1
  142. package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -1
  143. package/dist/runtime/generative-ui/surface-writer.cjs +4 -5
  144. package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -1
  145. package/dist/runtime/generative-ui/surface-writer.d.cts +1 -1
  146. package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -1
  147. package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -1
  148. package/dist/runtime/generative-ui/surface-writer.mjs +5 -5
  149. package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -1
  150. package/dist/runtime/handlers/handle-connect.cjs.map +1 -1
  151. package/dist/runtime/handlers/handle-connect.mjs.map +1 -1
  152. package/dist/runtime/handlers/handle-inspector-learning.cjs +2 -3
  153. package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -1
  154. package/dist/runtime/handlers/handle-inspector-metadata.cjs +2 -3
  155. package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -1
  156. package/dist/runtime/handlers/handle-run.cjs +8 -6
  157. package/dist/runtime/handlers/handle-run.cjs.map +1 -1
  158. package/dist/runtime/handlers/handle-run.mjs +5 -2
  159. package/dist/runtime/handlers/handle-run.mjs.map +1 -1
  160. package/dist/runtime/handlers/handle-stop.cjs +3 -4
  161. package/dist/runtime/handlers/handle-stop.cjs.map +1 -1
  162. package/dist/runtime/handlers/handle-suggest.cjs +4 -3
  163. package/dist/runtime/handlers/handle-suggest.cjs.map +1 -1
  164. package/dist/runtime/handlers/handle-suggest.mjs +4 -2
  165. package/dist/runtime/handlers/handle-suggest.mjs.map +1 -1
  166. package/dist/runtime/handlers/handle-transcribe.cjs +0 -1
  167. package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -1
  168. package/dist/runtime/handlers/intelligence/annotate.cjs +2 -3
  169. package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -1
  170. package/dist/runtime/handlers/intelligence/memories.cjs +7 -8
  171. package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -1
  172. package/dist/runtime/handlers/intelligence/run.cjs +24 -18
  173. package/dist/runtime/handlers/intelligence/run.cjs.map +1 -1
  174. package/dist/runtime/handlers/intelligence/run.mjs +24 -17
  175. package/dist/runtime/handlers/intelligence/run.mjs.map +1 -1
  176. package/dist/runtime/handlers/intelligence/thread-names.cjs +0 -1
  177. package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
  178. package/dist/runtime/handlers/intelligence/threads.cjs +6 -7
  179. package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -1
  180. package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -1
  181. package/dist/runtime/handlers/shared/agent-utils.cjs +9 -9
  182. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  183. package/dist/runtime/handlers/shared/agent-utils.mjs +2 -1
  184. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  185. package/dist/runtime/handlers/shared/cloud-telemetry.cjs +0 -1
  186. package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -1
  187. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +1 -1
  188. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
  189. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +1 -1
  190. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
  191. package/dist/runtime/handlers/shared/sse-response.cjs +72 -64
  192. package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -1
  193. package/dist/runtime/handlers/shared/sse-response.mjs +72 -63
  194. package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -1
  195. package/dist/runtime/handlers/sse/run.cjs.map +1 -1
  196. package/dist/runtime/handlers/sse/run.mjs.map +1 -1
  197. package/dist/runtime/index.d.cts +8 -15
  198. package/dist/runtime/index.d.mts +8 -15
  199. package/dist/runtime/intelligence-platform/analytics-context.cjs +84 -0
  200. package/dist/runtime/intelligence-platform/analytics-context.cjs.map +1 -0
  201. package/dist/runtime/intelligence-platform/analytics-context.mjs +83 -0
  202. package/dist/runtime/intelligence-platform/analytics-context.mjs.map +1 -0
  203. package/dist/runtime/intelligence-platform/client.cjs +27 -1
  204. package/dist/runtime/intelligence-platform/client.cjs.map +1 -1
  205. package/dist/runtime/intelligence-platform/client.d.cts +24 -1
  206. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -1
  207. package/dist/runtime/intelligence-platform/client.d.mts +24 -1
  208. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -1
  209. package/dist/runtime/intelligence-platform/client.mjs +27 -0
  210. package/dist/runtime/intelligence-platform/client.mjs.map +1 -1
  211. package/dist/runtime/intelligence-platform/learning-management.cjs +7 -8
  212. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -1
  213. package/dist/runtime/intelligence-platform/learning-management.mjs +7 -7
  214. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -1
  215. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +104 -110
  216. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -1
  217. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +8 -2
  218. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -1
  219. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +8 -2
  220. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -1
  221. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +104 -109
  222. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -1
  223. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +0 -1
  224. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -1
  225. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +1 -1
  226. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +1 -1
  227. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +22 -19
  228. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -1
  229. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -1
  230. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -1
  231. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +22 -19
  232. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -1
  233. package/dist/runtime/intelligence-platform/stop-run.cjs +50 -0
  234. package/dist/runtime/intelligence-platform/stop-run.cjs.map +1 -0
  235. package/dist/runtime/intelligence-platform/stop-run.mjs +50 -0
  236. package/dist/runtime/intelligence-platform/stop-run.mjs.map +1 -0
  237. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +0 -1
  238. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -1
  239. package/dist/runtime/intelligence-platform/trajectories.cjs +2 -3
  240. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -1
  241. package/dist/runtime/intelligence-platform/trajectories.mjs +2 -2
  242. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -1
  243. package/dist/runtime/node.d.cts +1 -1
  244. package/dist/runtime/node.d.mts +1 -1
  245. package/dist/runtime/runner/agent-runner.cjs +0 -1
  246. package/dist/runtime/runner/agent-runner.cjs.map +1 -1
  247. package/dist/runtime/runner/agent-runner.d.cts +9 -0
  248. package/dist/runtime/runner/agent-runner.d.cts.map +1 -1
  249. package/dist/runtime/runner/agent-runner.d.mts +9 -0
  250. package/dist/runtime/runner/agent-runner.d.mts.map +1 -1
  251. package/dist/runtime/runner/agent-runner.mjs.map +1 -1
  252. package/dist/runtime/runner/in-memory.cjs +0 -1
  253. package/dist/runtime/runner/in-memory.cjs.map +1 -1
  254. package/dist/runtime/runner/index.d.cts +1 -1
  255. package/dist/runtime/runner/index.d.mts +1 -1
  256. package/dist/runtime/runner/index.mjs +1 -1
  257. package/dist/runtime/runner/intelligence.cjs +50 -6
  258. package/dist/runtime/runner/intelligence.cjs.map +1 -1
  259. package/dist/runtime/runner/intelligence.d.cts +8 -1
  260. package/dist/runtime/runner/intelligence.d.cts.map +1 -1
  261. package/dist/runtime/runner/intelligence.d.mts +8 -1
  262. package/dist/runtime/runner/intelligence.d.mts.map +1 -1
  263. package/dist/runtime/runner/intelligence.mjs +50 -6
  264. package/dist/runtime/runner/intelligence.mjs.map +1 -1
  265. package/dist/runtime/telemetry/disclosure.cjs +0 -1
  266. package/dist/runtime/telemetry/disclosure.cjs.map +1 -1
  267. package/dist/runtime/telemetry/disclosure.mjs.map +1 -1
  268. package/dist/runtime/telemetry/events.d.cts +1 -1
  269. package/dist/runtime/telemetry/events.d.mts +1 -1
  270. package/dist/runtime/telemetry/instance-created.cjs +33 -12
  271. package/dist/runtime/telemetry/instance-created.cjs.map +1 -1
  272. package/dist/runtime/telemetry/instance-created.mjs +33 -12
  273. package/dist/runtime/telemetry/instance-created.mjs.map +1 -1
  274. package/dist/runtime/telemetry/telemetry-client.cjs +0 -5
  275. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -1
  276. package/dist/runtime/telemetry/telemetry-client.mjs +0 -4
  277. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -1
  278. package/dist/runtime/telemetry/telemetry-identity.cjs +0 -1
  279. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -1
  280. package/package.json +56 -27
  281. package/dist/_virtual/_rolldown/runtime.cjs +0 -29
  282. package/dist/agent/converters/index.d.mts +0 -2
  283. package/dist/agent/index.cjs +0 -1328
  284. package/dist/agent/index.cjs.map +0 -1
  285. package/dist/agent/index.d.cts +0 -467
  286. package/dist/agent/index.d.cts.map +0 -1
  287. package/dist/agent/index.d.mts +0 -468
  288. package/dist/agent/index.d.mts.map +0 -1
  289. package/dist/agent/index.mjs +0 -1318
  290. package/dist/agent/index.mjs.map +0 -1
  291. package/dist/agent/mcp-tool-names.cjs +0 -82
  292. package/dist/agent/mcp-tool-names.cjs.map +0 -1
  293. package/dist/agent/mcp-tool-names.mjs +0 -80
  294. package/dist/agent/mcp-tool-names.mjs.map +0 -1
  295. package/dist/agent/url-download.cjs.map +0 -1
  296. package/dist/agent/url-download.d.cts.map +0 -1
  297. package/dist/agent/url-download.d.mts.map +0 -1
  298. package/dist/agent/url-download.mjs.map +0 -1
  299. package/dist/runtime/index.d.cts.map +0 -1
  300. package/dist/runtime/index.d.mts.map +0 -1
@@ -1,20 +1,92 @@
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
+ const METHOD_LEVELS = {
5
+ debug: 20,
6
+ info: 30,
7
+ warn: 40,
8
+ error: 50
9
+ };
10
+ const THRESHOLDS = new Map([
11
+ ["trace", 10],
12
+ ...Object.entries(METHOD_LEVELS),
13
+ ["fatal", 60],
14
+ ["silent", Infinity]
15
+ ]);
16
+ function resolveThreshold(level) {
17
+ const name = (0, _copilotkit_shared.processEnv)().LOG_LEVEL || level || "error";
18
+ return THRESHOLDS.get(name) ?? METHOD_LEVELS.error;
19
+ }
20
+ function createReplacer() {
21
+ const ancestors = [];
22
+ return function replacer(_key, value) {
23
+ while (ancestors.length > 0 && ancestors.at(-1) !== this) ancestors.pop();
24
+ const written = value instanceof Error ? {
25
+ type: value.name,
26
+ message: value.message,
27
+ stack: value.stack
28
+ } : value;
29
+ if (typeof written !== "object" || written === null) return written;
30
+ if (ancestors.includes(written)) return "[Circular]";
31
+ ancestors.push(written);
32
+ return written;
33
+ };
34
+ }
35
+ function buildLogger(threshold, bindings) {
36
+ const createLogFn = (levelValue) => {
37
+ const log = (objOrMsg, msg) => {
38
+ if (levelValue < threshold) return;
39
+ const isMessageOnly = typeof objOrMsg === "string";
40
+ const message = isMessageOnly ? objOrMsg : msg;
41
+ const fields = isMessageOnly ? {} : objOrMsg;
42
+ const head = {
43
+ level: levelValue,
44
+ time: Date.now()
45
+ };
46
+ try {
47
+ const record = {
48
+ ...head,
49
+ ...bindings,
50
+ ...fields
51
+ };
52
+ if (message !== void 0) record.msg = message;
53
+ console.log(JSON.stringify(record, createReplacer()));
54
+ } catch {
55
+ console.log(JSON.stringify({
56
+ ...head,
57
+ msg: message
58
+ }));
59
+ }
60
+ };
61
+ return log;
62
+ };
63
+ return {
64
+ debug: createLogFn(METHOD_LEVELS.debug),
65
+ info: createLogFn(METHOD_LEVELS.info),
66
+ warn: createLogFn(METHOD_LEVELS.warn),
67
+ error: createLogFn(METHOD_LEVELS.error),
68
+ child: (childBindings) => buildLogger(threshold, {
69
+ ...bindings,
70
+ ...childBindings
71
+ })
72
+ };
73
+ }
74
+ /**
75
+ * Creates the runtime logger. Each call writes one JSON line with
76
+ * `console.log`, in pino's format:
77
+ * `{"level":20,"time":<ms>,"component":"...",...fields,"msg":"..."}`.
78
+ *
79
+ * @param options.level - The lowest level to write. The `LOG_LEVEL`
80
+ * environment variable wins over it. The default is `"error"`.
81
+ * @param options.component - Added as `component` to each line.
82
+ *
83
+ * @example
84
+ * const logger = createLogger({ level: "debug", component: "copilotkit-debug" });
85
+ * logger.debug({ eventCount: 2 }, "SSE stream completed");
86
+ */
9
87
  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;
88
+ const { level, component } = options ?? {};
89
+ return buildLogger(resolveThreshold(level), component ? { component } : {});
18
90
  }
19
91
 
20
92
  //#endregion
@@ -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":[],"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\";\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 * The logger that `createLogger` returns and `runtime.debugLogger` holds.\n * Each call writes one JSON line in pino's format, so `npx pino-pretty` can\n * format the output.\n */\nexport interface CopilotRuntimeLogger {\n debug: LogFn;\n info: LogFn;\n warn: LogFn;\n error: LogFn;\n /** Returns a logger that adds `bindings` to each line it writes. */\n child(bindings: Record<string, unknown>): CopilotRuntimeLogger;\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: CopilotRuntimeLogger = {\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":";;;AA2DA,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,C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W;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,25 @@
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
+ * The logger that `createLogger` returns and `runtime.debugLogger` holds.
12
+ * Each call writes one JSON line in pino's format, so `npx pino-pretty` can
13
+ * format the output.
14
+ */
15
+ interface CopilotRuntimeLogger {
16
+ debug: LogFn;
17
+ info: LogFn;
18
+ warn: LogFn;
19
+ error: LogFn;
20
+ /** Returns a logger that adds `bindings` to each line it writes. */
21
+ child(bindings: Record<string, unknown>): CopilotRuntimeLogger;
22
+ }
10
23
  //#endregion
11
24
  export { CopilotRuntimeLogger };
12
25
  //# 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;;AAQhB;;;;UAAiB,oBAAA;EACf,KAAA,EAAO,KAAA;EACP,IAAA,EAAM,KAAA;EACN,IAAA,EAAM,KAAA;EACN,KAAA,EAAO,KAAA;EAEuD;EAA9D,KAAA,CAAM,QAAA,EAAU,MAAA,oBAA0B,oBAAA;AAAA"}
@@ -1,12 +1,25 @@
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
+ * The logger that `createLogger` returns and `runtime.debugLogger` holds.
12
+ * Each call writes one JSON line in pino's format, so `npx pino-pretty` can
13
+ * format the output.
14
+ */
15
+ interface CopilotRuntimeLogger {
16
+ debug: LogFn;
17
+ info: LogFn;
18
+ warn: LogFn;
19
+ error: LogFn;
20
+ /** Returns a logger that adds `bindings` to each line it writes. */
21
+ child(bindings: Record<string, unknown>): CopilotRuntimeLogger;
22
+ }
10
23
  //#endregion
11
24
  export { CopilotRuntimeLogger };
12
25
  //# 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;;AAQhB;;;;UAAiB,oBAAA;EACf,KAAA,EAAO,KAAA;EACP,IAAA,EAAM,KAAA;EACN,IAAA,EAAM,KAAA;EACN,KAAA,EAAO,KAAA;EAEuD;EAA9D,KAAA,CAAM,QAAA,EAAU,MAAA,oBAA0B,oBAAA;AAAA"}
@@ -1,17 +1,92 @@
1
1
  import { processEnv } from "@copilotkit/shared";
2
- import createPinoLogger from "pino";
3
- import pretty from "pino-pretty";
4
2
 
5
3
  //#region src/runtime/core/logger.ts
4
+ const METHOD_LEVELS = {
5
+ debug: 20,
6
+ info: 30,
7
+ warn: 40,
8
+ error: 50
9
+ };
10
+ const THRESHOLDS = new Map([
11
+ ["trace", 10],
12
+ ...Object.entries(METHOD_LEVELS),
13
+ ["fatal", 60],
14
+ ["silent", Infinity]
15
+ ]);
16
+ function resolveThreshold(level) {
17
+ const name = processEnv().LOG_LEVEL || level || "error";
18
+ return THRESHOLDS.get(name) ?? METHOD_LEVELS.error;
19
+ }
20
+ function createReplacer() {
21
+ const ancestors = [];
22
+ return function replacer(_key, value) {
23
+ while (ancestors.length > 0 && ancestors.at(-1) !== this) ancestors.pop();
24
+ const written = value instanceof Error ? {
25
+ type: value.name,
26
+ message: value.message,
27
+ stack: value.stack
28
+ } : value;
29
+ if (typeof written !== "object" || written === null) return written;
30
+ if (ancestors.includes(written)) return "[Circular]";
31
+ ancestors.push(written);
32
+ return written;
33
+ };
34
+ }
35
+ function buildLogger(threshold, bindings) {
36
+ const createLogFn = (levelValue) => {
37
+ const log = (objOrMsg, msg) => {
38
+ if (levelValue < threshold) return;
39
+ const isMessageOnly = typeof objOrMsg === "string";
40
+ const message = isMessageOnly ? objOrMsg : msg;
41
+ const fields = isMessageOnly ? {} : objOrMsg;
42
+ const head = {
43
+ level: levelValue,
44
+ time: Date.now()
45
+ };
46
+ try {
47
+ const record = {
48
+ ...head,
49
+ ...bindings,
50
+ ...fields
51
+ };
52
+ if (message !== void 0) record.msg = message;
53
+ console.log(JSON.stringify(record, createReplacer()));
54
+ } catch {
55
+ console.log(JSON.stringify({
56
+ ...head,
57
+ msg: message
58
+ }));
59
+ }
60
+ };
61
+ return log;
62
+ };
63
+ return {
64
+ debug: createLogFn(METHOD_LEVELS.debug),
65
+ info: createLogFn(METHOD_LEVELS.info),
66
+ warn: createLogFn(METHOD_LEVELS.warn),
67
+ error: createLogFn(METHOD_LEVELS.error),
68
+ child: (childBindings) => buildLogger(threshold, {
69
+ ...bindings,
70
+ ...childBindings
71
+ })
72
+ };
73
+ }
74
+ /**
75
+ * Creates the runtime logger. Each call writes one JSON line with
76
+ * `console.log`, in pino's format:
77
+ * `{"level":20,"time":<ms>,"component":"...",...fields,"msg":"..."}`.
78
+ *
79
+ * @param options.level - The lowest level to write. The `LOG_LEVEL`
80
+ * environment variable wins over it. The default is `"error"`.
81
+ * @param options.component - Added as `component` to each line.
82
+ *
83
+ * @example
84
+ * const logger = createLogger({ level: "debug", component: "copilotkit-debug" });
85
+ * logger.debug({ eventCount: 2 }, "SSE stream completed");
86
+ */
6
87
  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;
88
+ const { level, component } = options ?? {};
89
+ return buildLogger(resolveThreshold(level), component ? { component } : {});
15
90
  }
16
91
 
17
92
  //#endregion
@@ -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":[],"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\";\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 * The logger that `createLogger` returns and `runtime.debugLogger` holds.\n * Each call writes one JSON line in pino's format, so `npx pino-pretty` can\n * format the output.\n */\nexport interface CopilotRuntimeLogger {\n debug: LogFn;\n info: LogFn;\n warn: LogFn;\n error: LogFn;\n /** Returns a logger that adds `bindings` to each line it writes. */\n child(bindings: Record<string, unknown>): CopilotRuntimeLogger;\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: CopilotRuntimeLogger = {\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":";;;AA2DA,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,GAA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
2
1
  let _copilotkit_shared = require("@copilotkit/shared");
3
2
 
4
3
  //#region src/runtime/core/middleware-sse-parser.ts
@@ -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,UAAU,EAAE,EAAE;CAGzB,IAAI;AACJ,KAAI;AACF,SAAO,MAAM,SAAS,MAAM;SACtB;AACN,4BAAO,KAAK,6DAA6D;AACzE,SAAO,EAAE,UAAU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,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":[],"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,4BAAO,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,M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WAAW;IAC9C,MAAM,WAAW,eAAe,IAAI,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,4 +1,3 @@
1
- const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
1
  const require_middleware_sse_parser = require('./middleware-sse-parser.cjs');
3
2
  let _copilotkit_shared = require("@copilotkit/shared");
4
3
 
@@ -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":["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,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.4";
4
+ const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.40";
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.4";
3
+ const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.40";
4
4
 
5
5
  //#endregion
6
6
  export { RUNTIME_PACKAGE_NAME, RUNTIME_PACKAGE_VERSION };
@@ -1,4 +1,3 @@
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');
4
3
  const require_learning = require('./learning.cjs');