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

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 (673) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +135 -1
  3. package/dist/_virtual/_rolldown/runtime.cjs +29 -0
  4. package/dist/_virtual/_rolldown/runtime.mjs +20 -0
  5. package/dist/agent/converters/aisdk.cjs +355 -0
  6. package/dist/agent/converters/aisdk.cjs.map +1 -0
  7. package/dist/agent/converters/aisdk.d.cts +22 -0
  8. package/dist/agent/converters/aisdk.d.cts.map +1 -0
  9. package/dist/agent/converters/aisdk.d.mts +22 -0
  10. package/dist/agent/converters/aisdk.d.mts.map +1 -0
  11. package/dist/agent/converters/aisdk.mjs +351 -0
  12. package/dist/agent/converters/aisdk.mjs.map +1 -0
  13. package/dist/agent/converters/index.d.mts +2 -0
  14. package/dist/agent/converters/tanstack.cjs +374 -0
  15. package/dist/agent/converters/tanstack.cjs.map +1 -0
  16. package/dist/agent/converters/tanstack.d.cts +83 -0
  17. package/dist/agent/converters/tanstack.d.cts.map +1 -0
  18. package/dist/agent/converters/tanstack.d.mts +83 -0
  19. package/dist/agent/converters/tanstack.d.mts.map +1 -0
  20. package/dist/agent/converters/tanstack.mjs +372 -0
  21. package/dist/agent/converters/tanstack.mjs.map +1 -0
  22. package/dist/agent/converters/usage.cjs +68 -0
  23. package/dist/agent/converters/usage.cjs.map +1 -0
  24. package/dist/agent/converters/usage.d.cts +19 -0
  25. package/dist/agent/converters/usage.d.cts.map +1 -0
  26. package/dist/agent/converters/usage.d.mts +19 -0
  27. package/dist/agent/converters/usage.d.mts.map +1 -0
  28. package/dist/agent/converters/usage.mjs +62 -0
  29. package/dist/agent/converters/usage.mjs.map +1 -0
  30. package/dist/agent/index.cjs +1328 -0
  31. package/dist/agent/index.cjs.map +1 -0
  32. package/dist/agent/index.d.cts +467 -0
  33. package/dist/agent/index.d.cts.map +1 -0
  34. package/dist/agent/index.d.mts +468 -0
  35. package/dist/agent/index.d.mts.map +1 -0
  36. package/dist/agent/index.mjs +1318 -0
  37. package/dist/agent/index.mjs.map +1 -0
  38. package/dist/agent/learned-skills.cjs +76 -0
  39. package/dist/agent/learned-skills.cjs.map +1 -0
  40. package/dist/agent/learned-skills.d.cts +15 -0
  41. package/dist/agent/learned-skills.d.cts.map +1 -0
  42. package/dist/agent/learned-skills.d.mts +15 -0
  43. package/dist/agent/learned-skills.d.mts.map +1 -0
  44. package/dist/agent/learned-skills.mjs +74 -0
  45. package/dist/agent/learned-skills.mjs.map +1 -0
  46. package/dist/agent/mcp-tool-names.cjs +82 -0
  47. package/dist/agent/mcp-tool-names.cjs.map +1 -0
  48. package/dist/agent/mcp-tool-names.mjs +80 -0
  49. package/dist/agent/mcp-tool-names.mjs.map +1 -0
  50. package/dist/agent/state-delta.cjs +321 -0
  51. package/dist/agent/state-delta.cjs.map +1 -0
  52. package/dist/agent/state-delta.mjs +320 -0
  53. package/dist/agent/state-delta.mjs.map +1 -0
  54. package/dist/agent/url-download.cjs +503 -0
  55. package/dist/agent/url-download.cjs.map +1 -0
  56. package/dist/agent/url-download.d.cts +79 -0
  57. package/dist/agent/url-download.d.cts.map +1 -0
  58. package/dist/agent/url-download.d.mts +79 -0
  59. package/dist/agent/url-download.d.mts.map +1 -0
  60. package/dist/agent/url-download.mjs +500 -0
  61. package/dist/agent/url-download.mjs.map +1 -0
  62. package/dist/express.cjs +7 -0
  63. package/dist/express.d.cts +4 -0
  64. package/dist/express.d.mts +4 -0
  65. package/dist/express.mjs +4 -0
  66. package/dist/hono.cjs +8 -0
  67. package/dist/hono.d.cts +4 -0
  68. package/dist/hono.d.mts +4 -0
  69. package/dist/hono.mjs +4 -0
  70. package/dist/index.cjs +86 -0
  71. package/dist/index.d.cts +28 -0
  72. package/dist/index.d.mts +28 -0
  73. package/dist/index.mjs +21 -5598
  74. package/dist/internal/learned-skills.cjs +21 -0
  75. package/dist/internal/learned-skills.d.cts +9 -0
  76. package/dist/internal/learned-skills.d.mts +9 -0
  77. package/dist/internal/learned-skills.mjs +9 -0
  78. package/dist/node.cjs +7 -0
  79. package/dist/node.d.cts +4 -0
  80. package/dist/node.d.mts +4 -0
  81. package/dist/node.mjs +4 -0
  82. package/dist/runtime/core/channel-activation-config.cjs +87 -0
  83. package/dist/runtime/core/channel-activation-config.cjs.map +1 -0
  84. package/dist/runtime/core/channel-activation-config.d.cts +39 -0
  85. package/dist/runtime/core/channel-activation-config.d.cts.map +1 -0
  86. package/dist/runtime/core/channel-activation-config.d.mts +39 -0
  87. package/dist/runtime/core/channel-activation-config.d.mts.map +1 -0
  88. package/dist/runtime/core/channel-activation-config.mjs +85 -0
  89. package/dist/runtime/core/channel-activation-config.mjs.map +1 -0
  90. package/dist/runtime/core/channel-manager.cjs +973 -0
  91. package/dist/runtime/core/channel-manager.cjs.map +1 -0
  92. package/dist/runtime/core/channel-manager.d.cts +166 -0
  93. package/dist/runtime/core/channel-manager.d.cts.map +1 -0
  94. package/dist/runtime/core/channel-manager.d.mts +167 -0
  95. package/dist/runtime/core/channel-manager.d.mts.map +1 -0
  96. package/dist/runtime/core/channel-manager.mjs +972 -0
  97. package/dist/runtime/core/channel-manager.mjs.map +1 -0
  98. package/dist/runtime/core/debug-event-bus.cjs +57 -0
  99. package/dist/runtime/core/debug-event-bus.cjs.map +1 -0
  100. package/dist/runtime/core/debug-event-bus.d.cts +18 -0
  101. package/dist/runtime/core/debug-event-bus.d.cts.map +1 -0
  102. package/dist/runtime/core/debug-event-bus.d.mts +18 -0
  103. package/dist/runtime/core/debug-event-bus.d.mts.map +1 -0
  104. package/dist/runtime/core/debug-event-bus.mjs +55 -0
  105. package/dist/runtime/core/debug-event-bus.mjs.map +1 -0
  106. package/dist/runtime/core/fetch-cors.cjs +71 -0
  107. package/dist/runtime/core/fetch-cors.cjs.map +1 -0
  108. package/dist/runtime/core/fetch-cors.d.cts +19 -0
  109. package/dist/runtime/core/fetch-cors.d.cts.map +1 -0
  110. package/dist/runtime/core/fetch-cors.d.mts +19 -0
  111. package/dist/runtime/core/fetch-cors.d.mts.map +1 -0
  112. package/dist/runtime/core/fetch-cors.mjs +69 -0
  113. package/dist/runtime/core/fetch-cors.mjs.map +1 -0
  114. package/dist/runtime/core/fetch-handler.cjs +539 -0
  115. package/dist/runtime/core/fetch-handler.cjs.map +1 -0
  116. package/dist/runtime/core/fetch-handler.d.cts +100 -0
  117. package/dist/runtime/core/fetch-handler.d.cts.map +1 -0
  118. package/dist/runtime/core/fetch-handler.d.mts +100 -0
  119. package/dist/runtime/core/fetch-handler.d.mts.map +1 -0
  120. package/dist/runtime/core/fetch-handler.mjs +538 -0
  121. package/dist/runtime/core/fetch-handler.mjs.map +1 -0
  122. package/dist/runtime/core/fetch-router.cjs +141 -0
  123. package/dist/runtime/core/fetch-router.cjs.map +1 -0
  124. package/dist/runtime/core/fetch-router.mjs +140 -0
  125. package/dist/runtime/core/fetch-router.mjs.map +1 -0
  126. package/dist/runtime/core/hooks.cjs +28 -0
  127. package/dist/runtime/core/hooks.cjs.map +1 -0
  128. package/dist/runtime/core/hooks.d.cts +121 -0
  129. package/dist/runtime/core/hooks.d.cts.map +1 -0
  130. package/dist/runtime/core/hooks.d.mts +121 -0
  131. package/dist/runtime/core/hooks.d.mts.map +1 -0
  132. package/dist/runtime/core/hooks.mjs +24 -0
  133. package/dist/runtime/core/hooks.mjs.map +1 -0
  134. package/dist/runtime/core/learning.cjs +61 -0
  135. package/dist/runtime/core/learning.cjs.map +1 -0
  136. package/dist/runtime/core/learning.d.cts +61 -0
  137. package/dist/runtime/core/learning.d.cts.map +1 -0
  138. package/dist/runtime/core/learning.d.mts +61 -0
  139. package/dist/runtime/core/learning.d.mts.map +1 -0
  140. package/dist/runtime/core/learning.mjs +56 -0
  141. package/dist/runtime/core/learning.mjs.map +1 -0
  142. package/dist/runtime/core/logger.cjs +21 -0
  143. package/dist/runtime/core/logger.cjs.map +1 -0
  144. package/dist/runtime/core/logger.d.cts +12 -0
  145. package/dist/runtime/core/logger.d.cts.map +1 -0
  146. package/dist/runtime/core/logger.d.mts +12 -0
  147. package/dist/runtime/core/logger.d.mts.map +1 -0
  148. package/dist/runtime/core/logger.mjs +18 -0
  149. package/dist/runtime/core/logger.mjs.map +1 -0
  150. package/dist/runtime/core/middleware-sse-parser.cjs +149 -0
  151. package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -0
  152. package/dist/runtime/core/middleware-sse-parser.d.cts +21 -0
  153. package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -0
  154. package/dist/runtime/core/middleware-sse-parser.d.mts +21 -0
  155. package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -0
  156. package/dist/runtime/core/middleware-sse-parser.mjs +148 -0
  157. package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -0
  158. package/dist/runtime/core/middleware.cjs +34 -0
  159. package/dist/runtime/core/middleware.cjs.map +1 -0
  160. package/dist/runtime/core/middleware.d.cts +31 -0
  161. package/dist/runtime/core/middleware.d.cts.map +1 -0
  162. package/dist/runtime/core/middleware.d.mts +31 -0
  163. package/dist/runtime/core/middleware.d.mts.map +1 -0
  164. package/dist/runtime/core/middleware.mjs +32 -0
  165. package/dist/runtime/core/middleware.mjs.map +1 -0
  166. package/dist/runtime/core/package-info.cjs +9 -0
  167. package/dist/runtime/core/package-info.cjs.map +1 -0
  168. package/dist/runtime/core/package-info.mjs +7 -0
  169. package/dist/runtime/core/package-info.mjs.map +1 -0
  170. package/dist/runtime/core/runtime-error-reporter.cjs +21 -0
  171. package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -0
  172. package/dist/runtime/core/runtime-error-reporter.mjs +18 -0
  173. package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -0
  174. package/dist/runtime/core/runtime.cjs +256 -0
  175. package/dist/runtime/core/runtime.cjs.map +1 -0
  176. package/dist/runtime/core/runtime.d.cts +481 -0
  177. package/dist/runtime/core/runtime.d.cts.map +1 -0
  178. package/dist/runtime/core/runtime.d.mts +481 -0
  179. package/dist/runtime/core/runtime.d.mts.map +1 -0
  180. package/dist/runtime/core/runtime.mjs +249 -0
  181. package/dist/runtime/core/runtime.mjs.map +1 -0
  182. package/dist/runtime/endpoints/auto-start-channels.cjs +46 -0
  183. package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -0
  184. package/dist/runtime/endpoints/auto-start-channels.mjs +45 -0
  185. package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -0
  186. package/dist/runtime/endpoints/express-single.cjs +43 -0
  187. package/dist/runtime/endpoints/express-single.cjs.map +1 -0
  188. package/dist/runtime/endpoints/express-single.d.cts +48 -0
  189. package/dist/runtime/endpoints/express-single.d.cts.map +1 -0
  190. package/dist/runtime/endpoints/express-single.d.mts +48 -0
  191. package/dist/runtime/endpoints/express-single.d.mts.map +1 -0
  192. package/dist/runtime/endpoints/express-single.mjs +43 -0
  193. package/dist/runtime/endpoints/express-single.mjs.map +1 -0
  194. package/dist/runtime/endpoints/express.cjs +68 -0
  195. package/dist/runtime/endpoints/express.cjs.map +1 -0
  196. package/dist/runtime/endpoints/express.d.cts +84 -0
  197. package/dist/runtime/endpoints/express.d.cts.map +1 -0
  198. package/dist/runtime/endpoints/express.d.mts +84 -0
  199. package/dist/runtime/endpoints/express.d.mts.map +1 -0
  200. package/dist/runtime/endpoints/express.mjs +66 -0
  201. package/dist/runtime/endpoints/express.mjs.map +1 -0
  202. package/dist/runtime/endpoints/hono-single.cjs +28 -0
  203. package/dist/runtime/endpoints/hono-single.cjs.map +1 -0
  204. package/dist/runtime/endpoints/hono-single.d.cts +43 -0
  205. package/dist/runtime/endpoints/hono-single.d.cts.map +1 -0
  206. package/dist/runtime/endpoints/hono-single.d.mts +43 -0
  207. package/dist/runtime/endpoints/hono-single.d.mts.map +1 -0
  208. package/dist/runtime/endpoints/hono-single.mjs +27 -0
  209. package/dist/runtime/endpoints/hono-single.mjs.map +1 -0
  210. package/dist/runtime/endpoints/hono.cjs +37 -0
  211. package/dist/runtime/endpoints/hono.cjs.map +1 -0
  212. package/dist/runtime/endpoints/hono.d.cts +96 -0
  213. package/dist/runtime/endpoints/hono.d.cts.map +1 -0
  214. package/dist/runtime/endpoints/hono.d.mts +96 -0
  215. package/dist/runtime/endpoints/hono.d.mts.map +1 -0
  216. package/dist/runtime/endpoints/hono.mjs +34 -0
  217. package/dist/runtime/endpoints/hono.mjs.map +1 -0
  218. package/dist/runtime/endpoints/index.d.cts +4 -0
  219. package/dist/runtime/endpoints/index.d.mts +4 -0
  220. package/dist/runtime/endpoints/load-express.cjs +35 -0
  221. package/dist/runtime/endpoints/load-express.cjs.map +1 -0
  222. package/dist/runtime/endpoints/load-express.mjs +34 -0
  223. package/dist/runtime/endpoints/load-express.mjs.map +1 -0
  224. package/dist/runtime/endpoints/node-fetch-handler.cjs +75 -0
  225. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -0
  226. package/dist/runtime/endpoints/node-fetch-handler.d.cts +11 -0
  227. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -0
  228. package/dist/runtime/endpoints/node-fetch-handler.d.mts +11 -0
  229. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -0
  230. package/dist/runtime/endpoints/node-fetch-handler.mjs +73 -0
  231. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -0
  232. package/dist/runtime/endpoints/node.cjs +16 -0
  233. package/dist/runtime/endpoints/node.cjs.map +1 -0
  234. package/dist/runtime/endpoints/node.d.cts +104 -0
  235. package/dist/runtime/endpoints/node.d.cts.map +1 -0
  236. package/dist/runtime/endpoints/node.d.mts +104 -0
  237. package/dist/runtime/endpoints/node.d.mts.map +1 -0
  238. package/dist/runtime/endpoints/node.mjs +16 -0
  239. package/dist/runtime/endpoints/node.mjs.map +1 -0
  240. package/dist/runtime/endpoints/single-route-helpers.cjs +130 -0
  241. package/dist/runtime/endpoints/single-route-helpers.cjs.map +1 -0
  242. package/dist/runtime/endpoints/single-route-helpers.mjs +125 -0
  243. package/dist/runtime/endpoints/single-route-helpers.mjs.map +1 -0
  244. package/dist/runtime/express.d.cts +2 -0
  245. package/dist/runtime/express.d.mts +2 -0
  246. package/dist/runtime/generative-ui/generative-ui-middleware.cjs +393 -0
  247. package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -0
  248. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts +20 -0
  249. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts.map +1 -0
  250. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts +20 -0
  251. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts.map +1 -0
  252. package/dist/runtime/generative-ui/generative-ui-middleware.mjs +392 -0
  253. package/dist/runtime/generative-ui/generative-ui-middleware.mjs.map +1 -0
  254. package/dist/runtime/generative-ui/index.d.cts +2 -0
  255. package/dist/runtime/generative-ui/index.d.mts +2 -0
  256. package/dist/runtime/generative-ui/surface-writer.cjs +85 -0
  257. package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -0
  258. package/dist/runtime/generative-ui/surface-writer.d.cts +32 -0
  259. package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -0
  260. package/dist/runtime/generative-ui/surface-writer.d.mts +32 -0
  261. package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -0
  262. package/dist/runtime/generative-ui/surface-writer.mjs +84 -0
  263. package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -0
  264. package/dist/runtime/handlers/get-runtime-info.cjs +140 -0
  265. package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -0
  266. package/dist/runtime/handlers/get-runtime-info.mjs +140 -0
  267. package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -0
  268. package/dist/runtime/handlers/handle-connect.cjs +62 -0
  269. package/dist/runtime/handlers/handle-connect.cjs.map +1 -0
  270. package/dist/runtime/handlers/handle-connect.mjs +62 -0
  271. package/dist/runtime/handlers/handle-connect.mjs.map +1 -0
  272. package/dist/runtime/handlers/handle-debug-events.cjs +33 -0
  273. package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -0
  274. package/dist/runtime/handlers/handle-debug-events.mjs +33 -0
  275. package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -0
  276. package/dist/runtime/handlers/handle-inspector-learning.cjs +56 -0
  277. package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -0
  278. package/dist/runtime/handlers/handle-inspector-learning.mjs +55 -0
  279. package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -0
  280. package/dist/runtime/handlers/handle-inspector-metadata.cjs +36 -0
  281. package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -0
  282. package/dist/runtime/handlers/handle-inspector-metadata.mjs +35 -0
  283. package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -0
  284. package/dist/runtime/handlers/handle-run.cjs +111 -0
  285. package/dist/runtime/handlers/handle-run.cjs.map +1 -0
  286. package/dist/runtime/handlers/handle-run.mjs +110 -0
  287. package/dist/runtime/handlers/handle-run.mjs.map +1 -0
  288. package/dist/runtime/handlers/handle-stop.cjs +102 -0
  289. package/dist/runtime/handlers/handle-stop.cjs.map +1 -0
  290. package/dist/runtime/handlers/handle-stop.mjs +101 -0
  291. package/dist/runtime/handlers/handle-stop.mjs.map +1 -0
  292. package/dist/runtime/handlers/handle-suggest.cjs +83 -0
  293. package/dist/runtime/handlers/handle-suggest.cjs.map +1 -0
  294. package/dist/runtime/handlers/handle-suggest.mjs +82 -0
  295. package/dist/runtime/handlers/handle-suggest.mjs.map +1 -0
  296. package/dist/runtime/handlers/handle-trajectory-connect.cjs +40 -0
  297. package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -0
  298. package/dist/runtime/handlers/handle-trajectory-connect.mjs +39 -0
  299. package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -0
  300. package/dist/runtime/handlers/handle-transcribe.cjs +112 -0
  301. package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -0
  302. package/dist/runtime/handlers/handle-transcribe.mjs +111 -0
  303. package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -0
  304. package/dist/runtime/handlers/header-utils.cjs +185 -0
  305. package/dist/runtime/handlers/header-utils.cjs.map +1 -0
  306. package/dist/runtime/handlers/header-utils.d.cts +53 -0
  307. package/dist/runtime/handlers/header-utils.d.cts.map +1 -0
  308. package/dist/runtime/handlers/header-utils.d.mts +53 -0
  309. package/dist/runtime/handlers/header-utils.d.mts.map +1 -0
  310. package/dist/runtime/handlers/header-utils.mjs +183 -0
  311. package/dist/runtime/handlers/header-utils.mjs.map +1 -0
  312. package/dist/runtime/handlers/intelligence/annotate.cjs +83 -0
  313. package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -0
  314. package/dist/runtime/handlers/intelligence/annotate.mjs +82 -0
  315. package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -0
  316. package/dist/runtime/handlers/intelligence/connect.cjs +68 -0
  317. package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -0
  318. package/dist/runtime/handlers/intelligence/connect.mjs +68 -0
  319. package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -0
  320. package/dist/runtime/handlers/intelligence/memories.cjs +260 -0
  321. package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -0
  322. package/dist/runtime/handlers/intelligence/memories.mjs +254 -0
  323. package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -0
  324. package/dist/runtime/handlers/intelligence/run.cjs +283 -0
  325. package/dist/runtime/handlers/intelligence/run.cjs.map +1 -0
  326. package/dist/runtime/handlers/intelligence/run.mjs +282 -0
  327. package/dist/runtime/handlers/intelligence/run.mjs.map +1 -0
  328. package/dist/runtime/handlers/intelligence/thread-names.cjs +172 -0
  329. package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -0
  330. package/dist/runtime/handlers/intelligence/thread-names.mjs +171 -0
  331. package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -0
  332. package/dist/runtime/handlers/intelligence/threads.cjs +399 -0
  333. package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -0
  334. package/dist/runtime/handlers/intelligence/threads.mjs +390 -0
  335. package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -0
  336. package/dist/runtime/handlers/shared/agent-utils.cjs +267 -0
  337. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -0
  338. package/dist/runtime/handlers/shared/agent-utils.mjs +262 -0
  339. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -0
  340. package/dist/runtime/handlers/shared/cloud-telemetry.cjs +30 -0
  341. package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -0
  342. package/dist/runtime/handlers/shared/cloud-telemetry.mjs +29 -0
  343. package/dist/runtime/handlers/shared/cloud-telemetry.mjs.map +1 -0
  344. package/dist/runtime/handlers/shared/describe-endpoint.cjs +25 -0
  345. package/dist/runtime/handlers/shared/describe-endpoint.cjs.map +1 -0
  346. package/dist/runtime/handlers/shared/describe-endpoint.mjs +24 -0
  347. package/dist/runtime/handlers/shared/describe-endpoint.mjs.map +1 -0
  348. package/dist/runtime/handlers/shared/intelligence-utils.cjs +24 -0
  349. package/dist/runtime/handlers/shared/intelligence-utils.cjs.map +1 -0
  350. package/dist/runtime/handlers/shared/intelligence-utils.mjs +23 -0
  351. package/dist/runtime/handlers/shared/intelligence-utils.mjs.map +1 -0
  352. package/dist/runtime/handlers/shared/json-response.cjs +14 -0
  353. package/dist/runtime/handlers/shared/json-response.cjs.map +1 -0
  354. package/dist/runtime/handlers/shared/json-response.mjs +12 -0
  355. package/dist/runtime/handlers/shared/json-response.mjs.map +1 -0
  356. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs +22 -0
  357. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs.map +1 -0
  358. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs +22 -0
  359. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs.map +1 -0
  360. package/dist/runtime/handlers/shared/memory-policy.cjs +78 -0
  361. package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -0
  362. package/dist/runtime/handlers/shared/memory-policy.mjs +77 -0
  363. package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -0
  364. package/dist/runtime/handlers/shared/platform-error.cjs +39 -0
  365. package/dist/runtime/handlers/shared/platform-error.cjs.map +1 -0
  366. package/dist/runtime/handlers/shared/platform-error.mjs +39 -0
  367. package/dist/runtime/handlers/shared/platform-error.mjs.map +1 -0
  368. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +50 -0
  369. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -0
  370. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +49 -0
  371. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -0
  372. package/dist/runtime/handlers/shared/sse-keep-alive.cjs +68 -0
  373. package/dist/runtime/handlers/shared/sse-keep-alive.cjs.map +1 -0
  374. package/dist/runtime/handlers/shared/sse-keep-alive.mjs +66 -0
  375. package/dist/runtime/handlers/shared/sse-keep-alive.mjs.map +1 -0
  376. package/dist/runtime/handlers/shared/sse-response.cjs +237 -0
  377. package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -0
  378. package/dist/runtime/handlers/shared/sse-response.mjs +236 -0
  379. package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -0
  380. package/dist/runtime/handlers/shared/thread-access.cjs +137 -0
  381. package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -0
  382. package/dist/runtime/handlers/shared/thread-access.d.cts +28 -0
  383. package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -0
  384. package/dist/runtime/handlers/shared/thread-access.d.mts +28 -0
  385. package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -0
  386. package/dist/runtime/handlers/shared/thread-access.mjs +132 -0
  387. package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -0
  388. package/dist/runtime/handlers/sse/connect.cjs +23 -0
  389. package/dist/runtime/handlers/sse/connect.cjs.map +1 -0
  390. package/dist/runtime/handlers/sse/connect.mjs +23 -0
  391. package/dist/runtime/handlers/sse/connect.mjs.map +1 -0
  392. package/dist/runtime/handlers/sse/run.cjs +44 -0
  393. package/dist/runtime/handlers/sse/run.cjs.map +1 -0
  394. package/dist/runtime/handlers/sse/run.mjs +44 -0
  395. package/dist/runtime/handlers/sse/run.mjs.map +1 -0
  396. package/dist/runtime/hono.d.cts +2 -0
  397. package/dist/runtime/hono.d.mts +2 -0
  398. package/dist/runtime/index.d.cts +34 -0
  399. package/dist/runtime/index.d.cts.map +1 -0
  400. package/dist/runtime/index.d.mts +34 -0
  401. package/dist/runtime/index.d.mts.map +1 -0
  402. package/dist/runtime/intelligence-platform/client.cjs +1338 -0
  403. package/dist/runtime/intelligence-platform/client.cjs.map +1 -0
  404. package/dist/runtime/intelligence-platform/client.d.cts +824 -0
  405. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -0
  406. package/dist/runtime/intelligence-platform/client.d.mts +824 -0
  407. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -0
  408. package/dist/runtime/intelligence-platform/client.mjs +1334 -0
  409. package/dist/runtime/intelligence-platform/client.mjs.map +1 -0
  410. package/dist/runtime/intelligence-platform/experimental.d.cts +26 -0
  411. package/dist/runtime/intelligence-platform/experimental.d.cts.map +1 -0
  412. package/dist/runtime/intelligence-platform/experimental.d.mts +26 -0
  413. package/dist/runtime/intelligence-platform/experimental.d.mts.map +1 -0
  414. package/dist/runtime/intelligence-platform/index.d.cts +3 -0
  415. package/dist/runtime/intelligence-platform/index.d.mts +3 -0
  416. package/dist/runtime/intelligence-platform/learned-skills.cjs +95 -0
  417. package/dist/runtime/intelligence-platform/learned-skills.cjs.map +1 -0
  418. package/dist/runtime/intelligence-platform/learned-skills.d.cts +43 -0
  419. package/dist/runtime/intelligence-platform/learned-skills.d.cts.map +1 -0
  420. package/dist/runtime/intelligence-platform/learned-skills.d.mts +43 -0
  421. package/dist/runtime/intelligence-platform/learned-skills.d.mts.map +1 -0
  422. package/dist/runtime/intelligence-platform/learned-skills.mjs +92 -0
  423. package/dist/runtime/intelligence-platform/learned-skills.mjs.map +1 -0
  424. package/dist/runtime/intelligence-platform/learning-management.cjs +203 -0
  425. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -0
  426. package/dist/runtime/intelligence-platform/learning-management.d.cts +111 -0
  427. package/dist/runtime/intelligence-platform/learning-management.d.cts.map +1 -0
  428. package/dist/runtime/intelligence-platform/learning-management.d.mts +111 -0
  429. package/dist/runtime/intelligence-platform/learning-management.d.mts.map +1 -0
  430. package/dist/runtime/intelligence-platform/learning-management.mjs +193 -0
  431. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -0
  432. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +131 -0
  433. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -0
  434. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +10 -0
  435. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -0
  436. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +10 -0
  437. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -0
  438. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +127 -0
  439. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -0
  440. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +65 -0
  441. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -0
  442. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts +47 -0
  443. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts.map +1 -0
  444. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts +47 -0
  445. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts.map +1 -0
  446. package/dist/runtime/intelligence-platform/skill-registry/config.mjs +65 -0
  447. package/dist/runtime/intelligence-platform/skill-registry/config.mjs.map +1 -0
  448. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs +10 -0
  449. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs.map +1 -0
  450. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts +7 -0
  451. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts.map +1 -0
  452. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts +7 -0
  453. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts.map +1 -0
  454. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs +10 -0
  455. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs.map +1 -0
  456. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +7 -0
  457. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +7 -0
  458. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +247 -0
  459. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -0
  460. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts +36 -0
  461. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -0
  462. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts +36 -0
  463. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -0
  464. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +246 -0
  465. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -0
  466. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs +41 -0
  467. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs.map +1 -0
  468. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts +12 -0
  469. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts.map +1 -0
  470. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts +12 -0
  471. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts.map +1 -0
  472. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs +38 -0
  473. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs.map +1 -0
  474. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs +92 -0
  475. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs.map +1 -0
  476. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts +27 -0
  477. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts.map +1 -0
  478. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts +27 -0
  479. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts.map +1 -0
  480. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs +91 -0
  481. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs.map +1 -0
  482. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +142 -0
  483. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -0
  484. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +141 -0
  485. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -0
  486. package/dist/runtime/intelligence-platform/trajectories.cjs +95 -0
  487. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -0
  488. package/dist/runtime/intelligence-platform/trajectories.d.cts +11 -0
  489. package/dist/runtime/intelligence-platform/trajectories.d.cts.map +1 -0
  490. package/dist/runtime/intelligence-platform/trajectories.d.mts +11 -0
  491. package/dist/runtime/intelligence-platform/trajectories.d.mts.map +1 -0
  492. package/dist/runtime/intelligence-platform/trajectories.mjs +91 -0
  493. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -0
  494. package/dist/runtime/node.d.cts +2 -0
  495. package/dist/runtime/node.d.mts +2 -0
  496. package/dist/runtime/runner/agent-runner.cjs +82 -0
  497. package/dist/runtime/runner/agent-runner.cjs.map +1 -0
  498. package/dist/runtime/runner/agent-runner.d.cts +151 -0
  499. package/dist/runtime/runner/agent-runner.d.cts.map +1 -0
  500. package/dist/runtime/runner/agent-runner.d.mts +151 -0
  501. package/dist/runtime/runner/agent-runner.d.mts.map +1 -0
  502. package/dist/runtime/runner/agent-runner.mjs +73 -0
  503. package/dist/runtime/runner/agent-runner.mjs.map +1 -0
  504. package/dist/runtime/runner/in-memory.cjs +741 -0
  505. package/dist/runtime/runner/in-memory.cjs.map +1 -0
  506. package/dist/runtime/runner/in-memory.d.cts +427 -0
  507. package/dist/runtime/runner/in-memory.d.cts.map +1 -0
  508. package/dist/runtime/runner/in-memory.d.mts +427 -0
  509. package/dist/runtime/runner/in-memory.d.mts.map +1 -0
  510. package/dist/runtime/runner/in-memory.mjs +734 -0
  511. package/dist/runtime/runner/in-memory.mjs.map +1 -0
  512. package/dist/runtime/runner/index.d.cts +5 -0
  513. package/dist/runtime/runner/index.d.mts +5 -0
  514. package/dist/runtime/runner/index.mjs +6 -0
  515. package/dist/runtime/runner/intelligence.cjs +617 -0
  516. package/dist/runtime/runner/intelligence.cjs.map +1 -0
  517. package/dist/runtime/runner/intelligence.d.cts +104 -0
  518. package/dist/runtime/runner/intelligence.d.cts.map +1 -0
  519. package/dist/runtime/runner/intelligence.d.mts +104 -0
  520. package/dist/runtime/runner/intelligence.d.mts.map +1 -0
  521. package/dist/runtime/runner/intelligence.mjs +616 -0
  522. package/dist/runtime/runner/intelligence.mjs.map +1 -0
  523. package/dist/runtime/telemetry/disclosure.cjs +25 -0
  524. package/dist/runtime/telemetry/disclosure.cjs.map +1 -0
  525. package/dist/runtime/telemetry/disclosure.mjs +24 -0
  526. package/dist/runtime/telemetry/disclosure.mjs.map +1 -0
  527. package/dist/runtime/telemetry/events.d.cts +66 -0
  528. package/dist/runtime/telemetry/events.d.cts.map +1 -0
  529. package/dist/runtime/telemetry/events.d.mts +66 -0
  530. package/dist/runtime/telemetry/events.d.mts.map +1 -0
  531. package/dist/runtime/telemetry/instance-created.cjs +34 -0
  532. package/dist/runtime/telemetry/instance-created.cjs.map +1 -0
  533. package/dist/runtime/telemetry/instance-created.mjs +34 -0
  534. package/dist/runtime/telemetry/instance-created.mjs.map +1 -0
  535. package/dist/runtime/telemetry/telemetry-client.cjs +108 -0
  536. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -0
  537. package/dist/runtime/telemetry/telemetry-client.d.cts +10 -0
  538. package/dist/runtime/telemetry/telemetry-client.d.cts.map +1 -0
  539. package/dist/runtime/telemetry/telemetry-client.d.mts +10 -0
  540. package/dist/runtime/telemetry/telemetry-client.d.mts.map +1 -0
  541. package/dist/runtime/telemetry/telemetry-client.mjs +107 -0
  542. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -0
  543. package/dist/runtime/telemetry/telemetry-identity.cjs +12 -0
  544. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -0
  545. package/dist/runtime/telemetry/telemetry-identity.mjs +11 -0
  546. package/dist/runtime/telemetry/telemetry-identity.mjs.map +1 -0
  547. package/dist/runtime/transcription-service/transcription-service.cjs +7 -0
  548. package/dist/runtime/transcription-service/transcription-service.cjs.map +1 -0
  549. package/dist/runtime/transcription-service/transcription-service.d.cts +14 -0
  550. package/dist/runtime/transcription-service/transcription-service.d.cts.map +1 -0
  551. package/dist/runtime/transcription-service/transcription-service.d.mts +14 -0
  552. package/dist/runtime/transcription-service/transcription-service.d.mts.map +1 -0
  553. package/dist/runtime/transcription-service/transcription-service.mjs +6 -0
  554. package/dist/runtime/transcription-service/transcription-service.mjs.map +1 -0
  555. package/package.json +119 -104
  556. package/.eslintrc.js +0 -7
  557. package/CHANGELOG.md +0 -2920
  558. package/__snapshots__/schema/schema.graphql +0 -371
  559. package/dist/index.d.ts +0 -1494
  560. package/dist/index.js +0 -5641
  561. package/dist/index.js.map +0 -1
  562. package/dist/index.mjs.map +0 -1
  563. package/dist/langgraph.d.ts +0 -284
  564. package/dist/langgraph.js +0 -211
  565. package/dist/langgraph.js.map +0 -1
  566. package/dist/langgraph.mjs +0 -206
  567. package/dist/langgraph.mjs.map +0 -1
  568. package/dist/v2/index.d.ts +0 -2
  569. package/dist/v2/index.js +0 -22
  570. package/dist/v2/index.js.map +0 -1
  571. package/dist/v2/index.mjs +0 -5
  572. package/dist/v2/index.mjs.map +0 -1
  573. package/jest.config.js +0 -10
  574. package/scripts/generate-gql-schema.ts +0 -13
  575. package/src/agents/langgraph/event-source.ts +0 -329
  576. package/src/agents/langgraph/events.ts +0 -377
  577. package/src/graphql/inputs/action.input.ts +0 -16
  578. package/src/graphql/inputs/agent-session.input.ts +0 -13
  579. package/src/graphql/inputs/agent-state.input.ts +0 -13
  580. package/src/graphql/inputs/cloud-guardrails.input.ts +0 -16
  581. package/src/graphql/inputs/cloud.input.ts +0 -8
  582. package/src/graphql/inputs/context-property.input.ts +0 -10
  583. package/src/graphql/inputs/copilot-context.input.ts +0 -10
  584. package/src/graphql/inputs/custom-property.input.ts +0 -15
  585. package/src/graphql/inputs/extensions.input.ts +0 -21
  586. package/src/graphql/inputs/forwarded-parameters.input.ts +0 -22
  587. package/src/graphql/inputs/frontend.input.ts +0 -14
  588. package/src/graphql/inputs/generate-copilot-response.input.ts +0 -59
  589. package/src/graphql/inputs/load-agent-state.input.ts +0 -10
  590. package/src/graphql/inputs/message.input.ts +0 -110
  591. package/src/graphql/inputs/meta-event.input.ts +0 -18
  592. package/src/graphql/message-conversion/agui-to-gql.test.ts +0 -1263
  593. package/src/graphql/message-conversion/agui-to-gql.ts +0 -333
  594. package/src/graphql/message-conversion/gql-to-agui.test.ts +0 -1580
  595. package/src/graphql/message-conversion/gql-to-agui.ts +0 -278
  596. package/src/graphql/message-conversion/index.ts +0 -2
  597. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +0 -526
  598. package/src/graphql/resolvers/copilot.resolver.ts +0 -708
  599. package/src/graphql/resolvers/state.resolver.ts +0 -27
  600. package/src/graphql/types/agents-response.type.ts +0 -19
  601. package/src/graphql/types/base/index.ts +0 -10
  602. package/src/graphql/types/converted/index.ts +0 -176
  603. package/src/graphql/types/copilot-response.type.ts +0 -138
  604. package/src/graphql/types/enums.ts +0 -38
  605. package/src/graphql/types/extensions-response.type.ts +0 -23
  606. package/src/graphql/types/guardrails-result.type.ts +0 -20
  607. package/src/graphql/types/load-agent-state-response.type.ts +0 -17
  608. package/src/graphql/types/message-status.type.ts +0 -42
  609. package/src/graphql/types/meta-events.type.ts +0 -71
  610. package/src/graphql/types/response-status.type.ts +0 -66
  611. package/src/index.ts +0 -4
  612. package/src/langgraph.ts +0 -1
  613. package/src/lib/cloud/index.ts +0 -4
  614. package/src/lib/error-messages.ts +0 -200
  615. package/src/lib/index.ts +0 -52
  616. package/src/lib/integrations/index.ts +0 -6
  617. package/src/lib/integrations/nest/index.ts +0 -14
  618. package/src/lib/integrations/nextjs/app-router.ts +0 -38
  619. package/src/lib/integrations/nextjs/pages-router.ts +0 -39
  620. package/src/lib/integrations/node-express/index.ts +0 -14
  621. package/src/lib/integrations/node-http/index.ts +0 -143
  622. package/src/lib/integrations/node-http/request-handler.ts +0 -111
  623. package/src/lib/integrations/shared.ts +0 -161
  624. package/src/lib/logger.ts +0 -28
  625. package/src/lib/observability.ts +0 -160
  626. package/src/lib/runtime/__tests__/copilot-runtime-error.test.ts +0 -169
  627. package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +0 -464
  628. package/src/lib/runtime/agent-integrations/langgraph/agent.ts +0 -209
  629. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +0 -34
  630. package/src/lib/runtime/agent-integrations/langgraph/index.ts +0 -2
  631. package/src/lib/runtime/copilot-runtime.ts +0 -710
  632. package/src/lib/runtime/mcp-tools-utils.ts +0 -254
  633. package/src/lib/runtime/retry-utils.ts +0 -96
  634. package/src/lib/runtime/telemetry-agent-runner.ts +0 -139
  635. package/src/lib/runtime/types.ts +0 -49
  636. package/src/lib/runtime/utils.ts +0 -87
  637. package/src/lib/streaming.ts +0 -202
  638. package/src/lib/telemetry-client.ts +0 -64
  639. package/src/service-adapters/anthropic/anthropic-adapter.ts +0 -452
  640. package/src/service-adapters/anthropic/utils.ts +0 -152
  641. package/src/service-adapters/bedrock/bedrock-adapter.ts +0 -73
  642. package/src/service-adapters/conversion.ts +0 -67
  643. package/src/service-adapters/empty/empty-adapter.ts +0 -38
  644. package/src/service-adapters/events.ts +0 -294
  645. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +0 -84
  646. package/src/service-adapters/google/google-genai-adapter.test.ts +0 -104
  647. package/src/service-adapters/google/google-genai-adapter.ts +0 -88
  648. package/src/service-adapters/groq/groq-adapter.ts +0 -203
  649. package/src/service-adapters/index.ts +0 -18
  650. package/src/service-adapters/langchain/langchain-adapter.ts +0 -111
  651. package/src/service-adapters/langchain/langserve.ts +0 -88
  652. package/src/service-adapters/langchain/types.ts +0 -14
  653. package/src/service-adapters/langchain/utils.ts +0 -313
  654. package/src/service-adapters/openai/openai-adapter.ts +0 -283
  655. package/src/service-adapters/openai/openai-assistant-adapter.ts +0 -344
  656. package/src/service-adapters/openai/utils.ts +0 -199
  657. package/src/service-adapters/service-adapter.ts +0 -41
  658. package/src/service-adapters/shared/error-utils.ts +0 -61
  659. package/src/service-adapters/shared/index.ts +0 -1
  660. package/src/service-adapters/unify/unify-adapter.ts +0 -151
  661. package/src/utils/failed-response-status-reasons.ts +0 -70
  662. package/src/utils/index.ts +0 -1
  663. package/src/v2/index.ts +0 -3
  664. package/tests/global.d.ts +0 -13
  665. package/tests/service-adapters/anthropic/allowlist-approach.test.ts +0 -226
  666. package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +0 -389
  667. package/tests/service-adapters/openai/allowlist-approach.test.ts +0 -238
  668. package/tests/service-adapters/openai/openai-adapter.test.ts +0 -301
  669. package/tests/setup.jest.ts +0 -21
  670. package/tests/tsconfig.json +0 -10
  671. package/tsconfig.json +0 -13
  672. package/tsup.config.ts +0 -20
  673. package/typedoc.json +0 -4
@@ -1,1263 +0,0 @@
1
- import { describe, test, expect } from "@jest/globals";
2
- import * as gql from "../types/converted/index";
3
- import agui from "@copilotkit/shared";
4
- import {
5
- aguiToGQL,
6
- aguiTextMessageToGQLMessage,
7
- aguiToolCallToGQLActionExecution,
8
- aguiToolMessageToGQLResultMessage,
9
- aguiMessageWithRenderToGQL,
10
- aguiMessageWithImageToGQLMessage,
11
- } from "./agui-to-gql";
12
-
13
- describe("agui-to-gql", () => {
14
- describe("aguiTextMessageToGQLMessage", () => {
15
- test("should convert developer message", () => {
16
- const aguiMessage: agui.Message = {
17
- id: "dev-message-id",
18
- role: "developer",
19
- content: "Hello from developer",
20
- };
21
-
22
- const result = aguiTextMessageToGQLMessage(aguiMessage);
23
-
24
- expect(result).toBeInstanceOf(gql.TextMessage);
25
- expect(result.id).toBe("dev-message-id");
26
- expect(result.content).toBe("Hello from developer");
27
- expect(result.role).toBe(gql.Role.developer);
28
- });
29
-
30
- test("should convert system message", () => {
31
- const aguiMessage: agui.Message = {
32
- id: "system-message-id",
33
- role: "system",
34
- content: "System instruction",
35
- };
36
-
37
- const result = aguiTextMessageToGQLMessage(aguiMessage);
38
-
39
- expect(result).toBeInstanceOf(gql.TextMessage);
40
- expect(result.id).toBe("system-message-id");
41
- expect(result.content).toBe("System instruction");
42
- expect(result.role).toBe(gql.Role.system);
43
- });
44
-
45
- test("should convert assistant message", () => {
46
- const aguiMessage: agui.Message = {
47
- id: "assistant-message-id",
48
- role: "assistant",
49
- content: "Assistant response",
50
- };
51
-
52
- const result = aguiTextMessageToGQLMessage(aguiMessage);
53
-
54
- expect(result).toBeInstanceOf(gql.TextMessage);
55
- expect(result.id).toBe("assistant-message-id");
56
- expect(result.content).toBe("Assistant response");
57
- expect(result.role).toBe(gql.Role.assistant);
58
- });
59
-
60
- test("should convert user message", () => {
61
- const aguiMessage: agui.Message = {
62
- id: "user-message-id",
63
- role: "user",
64
- content: "User input",
65
- };
66
-
67
- const result = aguiTextMessageToGQLMessage(aguiMessage);
68
-
69
- expect(result).toBeInstanceOf(gql.TextMessage);
70
- expect(result.id).toBe("user-message-id");
71
- expect(result.content).toBe("User input");
72
- expect(result.role).toBe(gql.Role.user);
73
- });
74
-
75
- test("should throw error for unsupported role", () => {
76
- const aguiMessage: agui.Message = {
77
- id: "tool-message-id",
78
- role: "tool",
79
- content: "Tool response",
80
- toolCallId: "tool-call-id",
81
- };
82
-
83
- expect(() => aguiTextMessageToGQLMessage(aguiMessage)).toThrow(
84
- "Cannot convert message with role tool to TextMessage",
85
- );
86
- });
87
-
88
- test("should handle undefined content", () => {
89
- const aguiMessage: agui.Message = {
90
- id: "assistant-message-id",
91
- role: "assistant",
92
- content: undefined,
93
- } as any;
94
-
95
- const result = aguiTextMessageToGQLMessage(aguiMessage);
96
-
97
- expect(result.content).toBe("");
98
- });
99
- });
100
-
101
- describe("aguiToolCallToGQLActionExecution", () => {
102
- test("should convert function tool call to action execution message", () => {
103
- const toolCall: agui.ToolCall = {
104
- id: "tool-call-id",
105
- type: "function",
106
- function: {
107
- name: "testFunction",
108
- arguments: JSON.stringify({ param: "value" }),
109
- },
110
- };
111
-
112
- const result = aguiToolCallToGQLActionExecution(toolCall, "parent-message-id");
113
-
114
- expect(result).toBeInstanceOf(gql.ActionExecutionMessage);
115
- expect(result.id).toBe("tool-call-id");
116
- expect(result.name).toBe("testFunction");
117
- expect(result.arguments).toEqual({ param: "value" });
118
- expect(result.parentMessageId).toBe("parent-message-id");
119
- });
120
-
121
- test("should throw error for unsupported tool call type", () => {
122
- const toolCall = {
123
- id: "tool-call-id",
124
- type: "unsupported-type",
125
- function: {
126
- name: "testFunction",
127
- arguments: "{}",
128
- },
129
- } as any;
130
-
131
- expect(() => aguiToolCallToGQLActionExecution(toolCall, "parent-id")).toThrow(
132
- "Unsupported tool call type",
133
- );
134
- });
135
- });
136
-
137
- describe("aguiToolMessageToGQLResultMessage", () => {
138
- test("should convert tool message to result message", () => {
139
- const aguiMessage: agui.Message = {
140
- id: "tool-message-id",
141
- role: "tool",
142
- content: "Tool execution result",
143
- toolCallId: "tool-call-id",
144
- };
145
-
146
- const toolCallNames = { "tool-call-id": "testFunction" };
147
- const result = aguiToolMessageToGQLResultMessage(aguiMessage, toolCallNames);
148
-
149
- expect(result).toBeInstanceOf(gql.ResultMessage);
150
- expect(result.id).toBe("tool-message-id");
151
- expect(result.result).toBe("Tool execution result");
152
- expect(result.actionExecutionId).toBe("tool-call-id");
153
- expect(result.actionName).toBe("testFunction");
154
- });
155
-
156
- test("should throw error for non-tool message", () => {
157
- const aguiMessage: agui.Message = {
158
- id: "assistant-message-id",
159
- role: "assistant",
160
- content: "Assistant response",
161
- };
162
-
163
- expect(() => aguiToolMessageToGQLResultMessage(aguiMessage, {})).toThrow(
164
- "Cannot convert message with role assistant to ResultMessage",
165
- );
166
- });
167
-
168
- test("should throw error for tool message without toolCallId", () => {
169
- const aguiMessage = {
170
- id: "tool-message-id",
171
- role: "tool",
172
- content: "Tool execution result",
173
- } as any;
174
-
175
- expect(() => aguiToolMessageToGQLResultMessage(aguiMessage, {})).toThrow(
176
- "Tool message must have a toolCallId",
177
- );
178
- });
179
-
180
- test("should handle undefined content", () => {
181
- const aguiMessage: agui.Message = {
182
- id: "tool-message-id",
183
- role: "tool",
184
- content: undefined,
185
- toolCallId: "tool-call-id",
186
- } as any;
187
-
188
- const toolCallNames = { "tool-call-id": "testFunction" };
189
- const result = aguiToolMessageToGQLResultMessage(aguiMessage, toolCallNames);
190
-
191
- expect(result.result).toBe("");
192
- expect(result.actionName).toBe("testFunction");
193
- });
194
- });
195
-
196
- describe("aguiToGQL", () => {
197
- test("should convert an array of text messages", () => {
198
- const aguiMessages: agui.Message[] = [
199
- {
200
- id: "dev-1",
201
- role: "developer",
202
- content: "Hello",
203
- },
204
- {
205
- id: "assistant-1",
206
- role: "assistant",
207
- content: "Hi there",
208
- },
209
- ];
210
-
211
- const result = aguiToGQL(aguiMessages);
212
-
213
- expect(result).toHaveLength(2);
214
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
215
- expect(result[0].id).toBe("dev-1");
216
- expect((result[0] as gql.TextMessage).content).toBe("Hello");
217
- expect((result[0] as gql.TextMessage).role).toBe(gql.Role.developer);
218
-
219
- expect(result[1]).toBeInstanceOf(gql.TextMessage);
220
- expect(result[1].id).toBe("assistant-1");
221
- expect((result[1] as gql.TextMessage).content).toBe("Hi there");
222
- expect((result[1] as gql.TextMessage).role).toBe(gql.Role.assistant);
223
- });
224
-
225
- test("should convert an array of text messages including user messages", () => {
226
- const aguiMessages: agui.Message[] = [
227
- {
228
- id: "user-1",
229
- role: "user",
230
- content: "Hello from user",
231
- },
232
- {
233
- id: "assistant-1",
234
- role: "assistant",
235
- content: "Hi there",
236
- },
237
- {
238
- id: "user-2",
239
- role: "user",
240
- content: "Another user message",
241
- },
242
- ];
243
-
244
- const result = aguiToGQL(aguiMessages);
245
-
246
- expect(result).toHaveLength(3);
247
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
248
- expect(result[0].id).toBe("user-1");
249
- expect((result[0] as gql.TextMessage).content).toBe("Hello from user");
250
- expect((result[0] as gql.TextMessage).role).toBe(gql.Role.user);
251
-
252
- expect(result[1]).toBeInstanceOf(gql.TextMessage);
253
- expect(result[1].id).toBe("assistant-1");
254
- expect((result[1] as gql.TextMessage).content).toBe("Hi there");
255
- expect((result[1] as gql.TextMessage).role).toBe(gql.Role.assistant);
256
-
257
- expect(result[2]).toBeInstanceOf(gql.TextMessage);
258
- expect(result[2].id).toBe("user-2");
259
- expect((result[2] as gql.TextMessage).content).toBe("Another user message");
260
- expect((result[2] as gql.TextMessage).role).toBe(gql.Role.user);
261
- });
262
-
263
- test("should handle assistant messages with tool calls", () => {
264
- const aguiMessages: agui.Message[] = [
265
- {
266
- id: "assistant-1",
267
- role: "assistant",
268
- content: "I'll execute a function",
269
- toolCalls: [
270
- {
271
- id: "tool-call-1",
272
- type: "function",
273
- function: {
274
- name: "testFunction",
275
- arguments: JSON.stringify({ param: "value" }),
276
- },
277
- },
278
- ],
279
- },
280
- ];
281
-
282
- const result = aguiToGQL(aguiMessages);
283
-
284
- expect(result).toHaveLength(2);
285
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
286
- expect(result[0].id).toBe("assistant-1");
287
-
288
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
289
- expect(result[1].id).toBe("tool-call-1");
290
- expect((result[1] as gql.ActionExecutionMessage).name).toBe("testFunction");
291
- expect((result[1] as gql.ActionExecutionMessage).arguments).toEqual({ param: "value" });
292
- expect((result[1] as gql.ActionExecutionMessage).parentMessageId).toBe("assistant-1");
293
- });
294
-
295
- test("should handle multiple tool calls in assistant message", () => {
296
- const aguiMessages: agui.Message[] = [
297
- {
298
- id: "assistant-1",
299
- role: "assistant",
300
- content: "I'll execute multiple functions",
301
- toolCalls: [
302
- {
303
- id: "tool-call-1",
304
- type: "function",
305
- function: {
306
- name: "firstFunction",
307
- arguments: JSON.stringify({ param: "value1" }),
308
- },
309
- },
310
- {
311
- id: "tool-call-2",
312
- type: "function",
313
- function: {
314
- name: "secondFunction",
315
- arguments: JSON.stringify({ param: "value2" }),
316
- },
317
- },
318
- ],
319
- },
320
- ];
321
-
322
- const result = aguiToGQL(aguiMessages);
323
-
324
- expect(result).toHaveLength(3);
325
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
326
-
327
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
328
- expect(result[1].id).toBe("tool-call-1");
329
- expect((result[1] as gql.ActionExecutionMessage).name).toBe("firstFunction");
330
-
331
- expect(result[2]).toBeInstanceOf(gql.ActionExecutionMessage);
332
- expect(result[2].id).toBe("tool-call-2");
333
- expect((result[2] as gql.ActionExecutionMessage).name).toBe("secondFunction");
334
- });
335
-
336
- test("should convert tool messages to result messages", () => {
337
- const aguiMessages: agui.Message[] = [
338
- {
339
- id: "tool-1",
340
- role: "tool",
341
- content: "Tool result",
342
- toolCallId: "tool-call-1",
343
- },
344
- ];
345
-
346
- const result = aguiToGQL(aguiMessages);
347
-
348
- expect(result).toHaveLength(1);
349
- expect(result[0]).toBeInstanceOf(gql.ResultMessage);
350
- expect(result[0].id).toBe("tool-1");
351
- expect((result[0] as gql.ResultMessage).result).toBe("Tool result");
352
- expect((result[0] as gql.ResultMessage).actionExecutionId).toBe("tool-call-1");
353
- });
354
-
355
- test("should handle a mix of message types", () => {
356
- const aguiMessages: agui.Message[] = [
357
- {
358
- id: "dev-1",
359
- role: "developer",
360
- content: "Can you run a function?",
361
- },
362
- {
363
- id: "assistant-1",
364
- role: "assistant",
365
- content: "Yes, I'll run it",
366
- toolCalls: [
367
- {
368
- id: "tool-call-1",
369
- type: "function",
370
- function: {
371
- name: "testFunction",
372
- arguments: JSON.stringify({ param: "value" }),
373
- },
374
- },
375
- ],
376
- },
377
- {
378
- id: "tool-1",
379
- role: "tool",
380
- content: "Function result",
381
- toolCallId: "tool-call-1",
382
- },
383
- ];
384
-
385
- const result = aguiToGQL(aguiMessages);
386
-
387
- expect(result).toHaveLength(4);
388
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
389
- expect(result[0].id).toBe("dev-1");
390
-
391
- expect(result[1]).toBeInstanceOf(gql.TextMessage);
392
- expect(result[1].id).toBe("assistant-1");
393
-
394
- expect(result[2]).toBeInstanceOf(gql.ActionExecutionMessage);
395
- expect(result[2].id).toBe("tool-call-1");
396
-
397
- expect(result[3]).toBeInstanceOf(gql.ResultMessage);
398
- expect(result[3].id).toBe("tool-1");
399
- });
400
-
401
- test("should handle a mix of message types including user messages", () => {
402
- const aguiMessages: agui.Message[] = [
403
- {
404
- id: "user-1",
405
- role: "user",
406
- content: "Can you help me?",
407
- },
408
- {
409
- id: "assistant-1",
410
- role: "assistant",
411
- content: "Yes, I'll help you",
412
- toolCalls: [
413
- {
414
- id: "tool-call-1",
415
- type: "function",
416
- function: {
417
- name: "helpFunction",
418
- arguments: JSON.stringify({ query: "help" }),
419
- },
420
- },
421
- ],
422
- },
423
- {
424
- id: "tool-1",
425
- role: "tool",
426
- content: "Help result",
427
- toolCallId: "tool-call-1",
428
- },
429
- {
430
- id: "user-2",
431
- role: "user",
432
- content: "Thank you!",
433
- },
434
- ];
435
-
436
- const result = aguiToGQL(aguiMessages);
437
-
438
- expect(result).toHaveLength(5);
439
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
440
- expect(result[0].id).toBe("user-1");
441
- expect((result[0] as gql.TextMessage).role).toBe(gql.Role.user);
442
-
443
- expect(result[1]).toBeInstanceOf(gql.TextMessage);
444
- expect(result[1].id).toBe("assistant-1");
445
- expect((result[1] as gql.TextMessage).role).toBe(gql.Role.assistant);
446
-
447
- expect(result[2]).toBeInstanceOf(gql.ActionExecutionMessage);
448
- expect(result[2].id).toBe("tool-call-1");
449
-
450
- expect(result[3]).toBeInstanceOf(gql.ResultMessage);
451
- expect(result[3].id).toBe("tool-1");
452
-
453
- expect(result[4]).toBeInstanceOf(gql.TextMessage);
454
- expect(result[4].id).toBe("user-2");
455
- expect((result[4] as gql.TextMessage).role).toBe(gql.Role.user);
456
- });
457
- });
458
-
459
- describe("aguiMessageWithRenderToGQL", () => {
460
- test("should handle assistant message with tool calls and render function", () => {
461
- const mockRender = () => "Test Render";
462
- const aguiMessage: agui.Message = {
463
- id: "assistant-1",
464
- role: "assistant",
465
- content: "I'll execute a function",
466
- toolCalls: [
467
- {
468
- id: "tool-call-1",
469
- type: "function",
470
- function: {
471
- name: "testFunction",
472
- arguments: JSON.stringify({ param: "value" }),
473
- },
474
- },
475
- ],
476
- generativeUI: mockRender,
477
- };
478
-
479
- const actions: Record<string, any> = {
480
- testFunction: {
481
- name: "testFunction",
482
- },
483
- };
484
-
485
- const result = aguiMessageWithRenderToGQL(aguiMessage, actions);
486
-
487
- expect(result).toHaveLength(2);
488
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
489
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
490
-
491
- // Check that the render function was preserved in actions
492
- expect(actions.testFunction.render).toBe(mockRender);
493
- });
494
-
495
- test("should handle assistant message with render function but no tool calls", () => {
496
- const mockRender = () => "Agent State Render";
497
- const aguiMessage: agui.Message = {
498
- id: "agent-state-1",
499
- role: "assistant",
500
- generativeUI: mockRender,
501
- };
502
-
503
- const coAgentStateRenders: Record<string, any> = {};
504
-
505
- const result = aguiMessageWithRenderToGQL(aguiMessage, undefined, coAgentStateRenders);
506
-
507
- expect(result).toHaveLength(1);
508
- expect(result[0]).toBeInstanceOf(gql.AgentStateMessage);
509
- expect((result[0] as gql.AgentStateMessage).agentName).toBe("unknown");
510
-
511
- // Check that the render function was preserved in coAgentStateRenders
512
- expect(coAgentStateRenders.unknown.render).toBe(mockRender);
513
- });
514
-
515
- test("should handle regular assistant message without render function", () => {
516
- const aguiMessage: agui.Message = {
517
- id: "assistant-1",
518
- role: "assistant",
519
- content: "Regular assistant message",
520
- };
521
-
522
- const result = aguiMessageWithRenderToGQL(aguiMessage);
523
-
524
- expect(result).toHaveLength(1);
525
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
526
- expect((result[0] as gql.TextMessage).content).toBe("Regular assistant message");
527
- });
528
-
529
- test("should handle non-assistant messages normally", () => {
530
- const aguiMessage: agui.Message = {
531
- id: "user-1",
532
- role: "user",
533
- content: "User message",
534
- };
535
-
536
- const result = aguiMessageWithRenderToGQL(aguiMessage);
537
-
538
- expect(result).toHaveLength(1);
539
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
540
- expect((result[0] as gql.TextMessage).role).toBe(gql.Role.user);
541
- });
542
-
543
- test("should handle multiple tool calls with render functions", () => {
544
- const mockRender1 = () => "Render 1";
545
- const mockRender2 = () => "Render 2";
546
- const aguiMessage: agui.Message = {
547
- id: "assistant-1",
548
- role: "assistant",
549
- content: "I'll execute multiple functions",
550
- toolCalls: [
551
- {
552
- id: "tool-call-1",
553
- type: "function",
554
- function: {
555
- name: "firstFunction",
556
- arguments: JSON.stringify({ param: "value1" }),
557
- },
558
- },
559
- {
560
- id: "tool-call-2",
561
- type: "function",
562
- function: {
563
- name: "secondFunction",
564
- arguments: JSON.stringify({ param: "value2" }),
565
- },
566
- },
567
- ],
568
- generativeUI: mockRender1,
569
- };
570
-
571
- const actions: Record<string, any> = {
572
- firstFunction: { name: "firstFunction" },
573
- secondFunction: { name: "secondFunction" },
574
- };
575
-
576
- const result = aguiMessageWithRenderToGQL(aguiMessage, actions);
577
-
578
- expect(result).toHaveLength(3);
579
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
580
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
581
- expect(result[2]).toBeInstanceOf(gql.ActionExecutionMessage);
582
-
583
- // Assert that all actions receive the render function
584
- Object.values(actions).forEach((action) => {
585
- expect(action.render).toBe(mockRender1);
586
- });
587
- });
588
-
589
- test("should verify render function receives correct props including name", () => {
590
- const mockRender = jest.fn(
591
- (props) => `Rendered: ${props.name} with args: ${JSON.stringify(props.args)}`,
592
- );
593
- const aguiMessage: agui.Message = {
594
- id: "assistant-render-props",
595
- role: "assistant",
596
- content: "I'll execute a function",
597
- toolCalls: [
598
- {
599
- id: "tool-call-render-props",
600
- type: "function",
601
- function: {
602
- name: "testFunction",
603
- arguments: JSON.stringify({ param: "value" }),
604
- },
605
- },
606
- ],
607
- generativeUI: mockRender,
608
- };
609
-
610
- const actions: Record<string, any> = {
611
- testFunction: { name: "testFunction" },
612
- };
613
-
614
- const result = aguiMessageWithRenderToGQL(aguiMessage, actions);
615
-
616
- expect(result).toHaveLength(2);
617
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
618
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
619
-
620
- // Check that the render function was preserved in actions
621
- expect(actions.testFunction.render).toBe(mockRender);
622
-
623
- // Now test that when the render function is called, it receives the correct props
624
- // This simulates what happens when the render function is actually used
625
- if (actions.testFunction.render) {
626
- actions.testFunction.render({
627
- status: "inProgress",
628
- args: { param: "value" },
629
- result: undefined,
630
- respond: () => {},
631
- messageId: "tool-call-render-props",
632
- name: "testFunction",
633
- });
634
-
635
- expect(mockRender).toHaveBeenCalledWith({
636
- status: "inProgress",
637
- args: { param: "value" },
638
- result: undefined,
639
- respond: expect.any(Function),
640
- messageId: "tool-call-render-props",
641
- name: "testFunction",
642
- });
643
- }
644
- });
645
- });
646
-
647
- describe("aguiImageMessageToGQLMessage", () => {
648
- test("should throw error for missing format or bytes in image message", () => {
649
- const aguiMessage: agui.Message = {
650
- id: "image-1",
651
- role: "assistant",
652
- content: "Image message",
653
- } as any;
654
-
655
- expect(() => aguiMessageWithImageToGQLMessage(aguiMessage)).toThrow(
656
- "Cannot convert message to ImageMessage: missing format or bytes",
657
- );
658
- });
659
-
660
- test("should convert valid assistant image message", () => {
661
- const aguiMessage: agui.Message = {
662
- id: "image-2",
663
- role: "assistant",
664
- image: {
665
- format: "jpeg",
666
- bytes: "base64stringdata",
667
- },
668
- };
669
-
670
- const result = aguiMessageWithImageToGQLMessage(aguiMessage);
671
- expect(result).toBeInstanceOf(gql.ImageMessage);
672
- expect(result.id).toBe("image-2");
673
- expect(result.format).toBe("jpeg");
674
- expect(result.bytes).toBe("base64stringdata");
675
- expect(result.role).toBe(gql.Role.assistant);
676
- });
677
-
678
- test("should convert valid user image message", () => {
679
- const aguiMessage: agui.Message = {
680
- id: "image-3",
681
- role: "user",
682
- content: "",
683
- image: {
684
- format: "png",
685
- bytes: "anotherbase64string",
686
- },
687
- };
688
-
689
- const result = aguiMessageWithImageToGQLMessage(aguiMessage);
690
- expect(result).toBeInstanceOf(gql.ImageMessage);
691
- expect(result.id).toBe("image-3");
692
- expect(result.format).toBe("png");
693
- expect(result.bytes).toBe("anotherbase64string");
694
- expect(result.role).toBe(gql.Role.user);
695
- });
696
- });
697
-
698
- describe("Wild Card Actions", () => {
699
- test("should preserve render function for specific action", () => {
700
- const mockRender = () => "Specific Action Render";
701
- const aguiMessage: agui.Message = {
702
- id: "assistant-1",
703
- role: "assistant",
704
- content: "I'll execute a function",
705
- toolCalls: [
706
- {
707
- id: "tool-call-1",
708
- type: "function",
709
- function: {
710
- name: "specificAction",
711
- arguments: JSON.stringify({ param: "value" }),
712
- },
713
- },
714
- ],
715
- generativeUI: mockRender,
716
- };
717
-
718
- const actions: Record<string, any> = {
719
- specificAction: { name: "specificAction" },
720
- };
721
-
722
- const result = aguiToGQL(aguiMessage, actions);
723
-
724
- expect(result).toHaveLength(2);
725
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
726
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
727
- expect(actions.specificAction.render).toBe(mockRender);
728
- });
729
-
730
- test("should preserve render function for wild card action", () => {
731
- const mockRender = () => "Wild Card Action Render";
732
- const aguiMessage: agui.Message = {
733
- id: "assistant-2",
734
- role: "assistant",
735
- content: "I'll execute an unknown function",
736
- toolCalls: [
737
- {
738
- id: "tool-call-2",
739
- type: "function",
740
- function: {
741
- name: "unknownAction",
742
- arguments: JSON.stringify({ param: "value" }),
743
- },
744
- },
745
- ],
746
- generativeUI: mockRender,
747
- };
748
-
749
- const actions: Record<string, any> = {
750
- "*": { name: "*" },
751
- };
752
-
753
- const result = aguiToGQL(aguiMessage, actions);
754
-
755
- expect(result).toHaveLength(2);
756
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
757
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
758
- expect(actions["*"].render).toBe(mockRender);
759
- });
760
-
761
- test("should prioritize specific action over wild card action", () => {
762
- const mockRender = () => "Prioritized Render";
763
- const aguiMessage: agui.Message = {
764
- id: "assistant-3",
765
- role: "assistant",
766
- content: "I'll execute a function",
767
- toolCalls: [
768
- {
769
- id: "tool-call-3",
770
- type: "function",
771
- function: {
772
- name: "specificAction",
773
- arguments: JSON.stringify({ param: "value" }),
774
- },
775
- },
776
- ],
777
- generativeUI: mockRender,
778
- };
779
-
780
- const actions: Record<string, any> = {
781
- specificAction: { name: "specificAction" },
782
- "*": { name: "*" },
783
- };
784
-
785
- const result = aguiToGQL(aguiMessage, actions);
786
-
787
- expect(result).toHaveLength(2);
788
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
789
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
790
- expect(actions.specificAction.render).toBe(mockRender);
791
- expect(actions["*"].render).toBeUndefined();
792
- });
793
-
794
- test("should not preserve render function when no matching action", () => {
795
- const mockRender = () => "Unmatched Render";
796
- const aguiMessage: agui.Message = {
797
- id: "assistant-4",
798
- role: "assistant",
799
- content: "I'll execute an unmatched function",
800
- toolCalls: [
801
- {
802
- id: "tool-call-4",
803
- type: "function",
804
- function: {
805
- name: "unmatchedAction",
806
- arguments: JSON.stringify({ param: "value" }),
807
- },
808
- },
809
- ],
810
- generativeUI: mockRender,
811
- };
812
-
813
- const actions: Record<string, any> = {
814
- otherAction: { name: "otherAction" },
815
- };
816
-
817
- const result = aguiToGQL(aguiMessage, actions);
818
-
819
- expect(result).toHaveLength(2);
820
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
821
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
822
- expect(actions.otherAction.render).toBeUndefined();
823
- });
824
-
825
- test("should handle multiple tool calls with wild card action", () => {
826
- const mockRender = () => "Wild Card Render";
827
- const aguiMessage: agui.Message = {
828
- id: "assistant-5",
829
- role: "assistant",
830
- content: "I'll execute multiple functions",
831
- toolCalls: [
832
- {
833
- id: "tool-call-5",
834
- type: "function",
835
- function: {
836
- name: "firstFunction",
837
- arguments: JSON.stringify({ param: "value1" }),
838
- },
839
- },
840
- {
841
- id: "tool-call-6",
842
- type: "function",
843
- function: {
844
- name: "secondFunction",
845
- arguments: JSON.stringify({ param: "value2" }),
846
- },
847
- },
848
- ],
849
- generativeUI: mockRender,
850
- };
851
-
852
- const actions: Record<string, any> = {
853
- "*": { name: "*" },
854
- };
855
-
856
- const result = aguiToGQL(aguiMessage, actions);
857
-
858
- expect(result).toHaveLength(3);
859
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
860
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
861
- expect(result[2]).toBeInstanceOf(gql.ActionExecutionMessage);
862
- expect(actions["*"].render).toBe(mockRender);
863
- });
864
-
865
- test("should handle mixed specific and wild card actions", () => {
866
- const mockRender = () => "Mixed Render";
867
- const aguiMessage: agui.Message = {
868
- id: "assistant-6",
869
- role: "assistant",
870
- content: "I'll execute mixed functions",
871
- toolCalls: [
872
- {
873
- id: "tool-call-7",
874
- type: "function",
875
- function: {
876
- name: "specificAction",
877
- arguments: JSON.stringify({ param: "value1" }),
878
- },
879
- },
880
- {
881
- id: "tool-call-8",
882
- type: "function",
883
- function: {
884
- name: "unknownAction",
885
- arguments: JSON.stringify({ param: "value2" }),
886
- },
887
- },
888
- ],
889
- generativeUI: mockRender,
890
- };
891
-
892
- const actions: Record<string, any> = {
893
- specificAction: { name: "specificAction" },
894
- "*": { name: "*" },
895
- };
896
-
897
- const result = aguiToGQL(aguiMessage, actions);
898
-
899
- expect(result).toHaveLength(3);
900
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
901
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
902
- expect(result[2]).toBeInstanceOf(gql.ActionExecutionMessage);
903
- expect(actions.specificAction.render).toBe(mockRender);
904
- // The wild card action should get the render function for the second tool call
905
- expect(actions["*"].render).toBe(mockRender);
906
- });
907
-
908
- test("should handle no actions provided", () => {
909
- const mockRender = () => "No Actions Render";
910
- const aguiMessage: agui.Message = {
911
- id: "assistant-7",
912
- role: "assistant",
913
- content: "I'll execute a function",
914
- toolCalls: [
915
- {
916
- id: "tool-call-9",
917
- type: "function",
918
- function: {
919
- name: "anyAction",
920
- arguments: JSON.stringify({ param: "value" }),
921
- },
922
- },
923
- ],
924
- generativeUI: mockRender,
925
- };
926
-
927
- const result = aguiToGQL(aguiMessage);
928
-
929
- expect(result).toHaveLength(2);
930
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
931
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
932
- });
933
-
934
- test("should handle empty actions object", () => {
935
- const mockRender = () => "Empty Actions Render";
936
- const aguiMessage: agui.Message = {
937
- id: "assistant-8",
938
- role: "assistant",
939
- content: "I'll execute a function",
940
- toolCalls: [
941
- {
942
- id: "tool-call-10",
943
- type: "function",
944
- function: {
945
- name: "anyAction",
946
- arguments: JSON.stringify({ param: "value" }),
947
- },
948
- },
949
- ],
950
- generativeUI: mockRender,
951
- };
952
-
953
- const actions: Record<string, any> = {};
954
-
955
- const result = aguiToGQL(aguiMessage, actions);
956
-
957
- expect(result).toHaveLength(2);
958
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
959
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
960
- });
961
-
962
- test("should handle actions with null render functions", () => {
963
- const mockRender = () => "Null Render Test";
964
- const aguiMessage: agui.Message = {
965
- id: "assistant-9",
966
- role: "assistant",
967
- content: "I'll execute a function",
968
- toolCalls: [
969
- {
970
- id: "tool-call-11",
971
- type: "function",
972
- function: {
973
- name: "specificAction",
974
- arguments: JSON.stringify({ param: "value" }),
975
- },
976
- },
977
- ],
978
- generativeUI: mockRender,
979
- };
980
-
981
- const actions: Record<string, any> = {
982
- specificAction: { name: "specificAction", render: null },
983
- "*": { name: "*", render: null },
984
- };
985
-
986
- const result = aguiToGQL(aguiMessage, actions);
987
-
988
- expect(result).toHaveLength(2);
989
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
990
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
991
- // The render function should still be assigned even if the action had null render
992
- expect(actions.specificAction.render).toBe(mockRender);
993
- });
994
-
995
- test("should handle actions with undefined render functions", () => {
996
- const mockRender = () => "Undefined Render Test";
997
- const aguiMessage: agui.Message = {
998
- id: "assistant-10",
999
- role: "assistant",
1000
- content: "I'll execute a function",
1001
- toolCalls: [
1002
- {
1003
- id: "tool-call-12",
1004
- type: "function",
1005
- function: {
1006
- name: "wildcardAction",
1007
- arguments: JSON.stringify({ param: "value" }),
1008
- },
1009
- },
1010
- ],
1011
- generativeUI: mockRender,
1012
- };
1013
-
1014
- const actions: Record<string, any> = {
1015
- "*": { name: "*", render: undefined },
1016
- };
1017
-
1018
- const result = aguiToGQL(aguiMessage, actions);
1019
-
1020
- expect(result).toHaveLength(2);
1021
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
1022
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
1023
- // The render function should still be assigned even if the action had undefined render
1024
- expect(actions["*"].render).toBe(mockRender);
1025
- });
1026
-
1027
- test("should handle tool calls with malformed arguments", () => {
1028
- const mockRender = () => "Malformed Args Test";
1029
- const aguiMessage: agui.Message = {
1030
- id: "assistant-11",
1031
- role: "assistant",
1032
- content: "I'll execute a function",
1033
- toolCalls: [
1034
- {
1035
- id: "tool-call-13",
1036
- type: "function",
1037
- function: {
1038
- name: "wildcardAction",
1039
- arguments: "invalid json {", // Malformed JSON
1040
- },
1041
- },
1042
- ],
1043
- generativeUI: mockRender,
1044
- };
1045
-
1046
- const actions: Record<string, any> = {
1047
- "*": { name: "*" },
1048
- };
1049
-
1050
- const result = aguiToGQL(aguiMessage, actions);
1051
-
1052
- expect(result).toHaveLength(2);
1053
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
1054
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
1055
- expect(actions["*"].render).toBe(mockRender);
1056
- });
1057
-
1058
- test("should handle tool calls with empty arguments string", () => {
1059
- const mockRender = () => "Empty Args Test";
1060
- const aguiMessage: agui.Message = {
1061
- id: "assistant-12",
1062
- role: "assistant",
1063
- content: "I'll execute a function",
1064
- toolCalls: [
1065
- {
1066
- id: "tool-call-14",
1067
- type: "function",
1068
- function: {
1069
- name: "wildcardAction",
1070
- arguments: "",
1071
- },
1072
- },
1073
- ],
1074
- generativeUI: mockRender,
1075
- };
1076
-
1077
- const actions: Record<string, any> = {
1078
- "*": { name: "*" },
1079
- };
1080
-
1081
- const result = aguiToGQL(aguiMessage, actions);
1082
-
1083
- expect(result).toHaveLength(2);
1084
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
1085
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
1086
- expect(actions["*"].render).toBe(mockRender);
1087
- });
1088
-
1089
- test("should handle multiple wild card actions in same object", () => {
1090
- const mockRender = () => "Multiple Wildcards Test";
1091
- const aguiMessage: agui.Message = {
1092
- id: "assistant-13",
1093
- role: "assistant",
1094
- content: "I'll execute a function",
1095
- toolCalls: [
1096
- {
1097
- id: "tool-call-15",
1098
- type: "function",
1099
- function: {
1100
- name: "unknownAction",
1101
- arguments: JSON.stringify({ param: "value" }),
1102
- },
1103
- },
1104
- ],
1105
- generativeUI: mockRender,
1106
- };
1107
-
1108
- const actions: Record<string, any> = {
1109
- wildcard1: { name: "*" },
1110
- wildcard2: { name: "*" },
1111
- };
1112
-
1113
- const result = aguiToGQL(aguiMessage, actions);
1114
-
1115
- expect(result).toHaveLength(2);
1116
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
1117
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
1118
- // Should assign to the first wild card action found
1119
- expect(actions.wildcard1.render).toBe(mockRender);
1120
- expect(actions.wildcard2.render).toBeUndefined();
1121
- });
1122
-
1123
- test("should handle tool calls with object arguments (backward compatibility)", () => {
1124
- const mockRender = () => "Object Args Test";
1125
- const aguiMessage: agui.Message = {
1126
- id: "assistant-14",
1127
- role: "assistant",
1128
- content: "I'll execute a function",
1129
- toolCalls: [
1130
- {
1131
- id: "tool-call-16",
1132
- type: "function",
1133
- function: {
1134
- name: "objectArgsAction",
1135
- arguments: { param: "value" } as any, // Object instead of string
1136
- },
1137
- },
1138
- ],
1139
- generativeUI: mockRender,
1140
- };
1141
-
1142
- const actions: Record<string, any> = {
1143
- "*": { name: "*" },
1144
- };
1145
-
1146
- const result = aguiToGQL(aguiMessage, actions);
1147
-
1148
- expect(result).toHaveLength(2);
1149
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
1150
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
1151
- expect((result[1] as any).arguments).toEqual({ param: "value" });
1152
- expect(actions["*"].render).toBe(mockRender);
1153
- });
1154
-
1155
- test("should handle tool calls with null/undefined arguments", () => {
1156
- const mockRender = () => "Null Args Test";
1157
- const aguiMessage: agui.Message = {
1158
- id: "assistant-15",
1159
- role: "assistant",
1160
- content: "I'll execute a function",
1161
- toolCalls: [
1162
- {
1163
- id: "tool-call-17",
1164
- type: "function",
1165
- function: {
1166
- name: "nullArgsAction",
1167
- arguments: null as any,
1168
- },
1169
- },
1170
- ],
1171
- generativeUI: mockRender,
1172
- };
1173
-
1174
- const actions: Record<string, any> = {
1175
- "*": { name: "*" },
1176
- };
1177
-
1178
- const result = aguiToGQL(aguiMessage, actions);
1179
-
1180
- expect(result).toHaveLength(2);
1181
- expect(result[0]).toBeInstanceOf(gql.TextMessage);
1182
- expect(result[1]).toBeInstanceOf(gql.ActionExecutionMessage);
1183
- expect((result[1] as any).arguments).toEqual({});
1184
- expect(actions["*"].render).toBe(mockRender);
1185
- });
1186
-
1187
- test("should handle tool result messages with object content", () => {
1188
- const aguiMessage: agui.Message = {
1189
- id: "tool-result-1",
1190
- role: "tool",
1191
- content: { status: "success", data: { value: 42 } } as any,
1192
- toolCallId: "tool-call-1",
1193
- toolName: "testAction",
1194
- };
1195
-
1196
- const toolCallNames = { "tool-call-1": "testAction" };
1197
- const result = aguiToGQL(aguiMessage);
1198
-
1199
- expect(result).toHaveLength(1);
1200
- expect(result[0]).toBeInstanceOf(gql.ResultMessage);
1201
- expect((result[0] as any).result).toBe('{"status":"success","data":{"value":42}}');
1202
- expect((result[0] as any).actionExecutionId).toBe("tool-call-1");
1203
- expect((result[0] as any).actionName).toBe("testAction");
1204
- });
1205
-
1206
- test("should handle tool result messages with non-string content types", () => {
1207
- const aguiMessage: agui.Message = {
1208
- id: "tool-result-2",
1209
- role: "tool",
1210
- content: 42 as any,
1211
- toolCallId: "tool-call-2",
1212
- toolName: "numberAction",
1213
- };
1214
-
1215
- const result = aguiToGQL(aguiMessage);
1216
-
1217
- expect(result).toHaveLength(1);
1218
- expect(result[0]).toBeInstanceOf(gql.ResultMessage);
1219
- expect((result[0] as any).result).toBe("42");
1220
- expect((result[0] as any).actionExecutionId).toBe("tool-call-2");
1221
- expect((result[0] as any).actionName).toBe("numberAction");
1222
- });
1223
-
1224
- test("should handle tool result messages with circular reference content", () => {
1225
- const circularObj: any = { status: "success" };
1226
- circularObj.self = circularObj;
1227
-
1228
- const aguiMessage: agui.Message = {
1229
- id: "tool-result-3",
1230
- role: "tool",
1231
- content: circularObj as any,
1232
- toolCallId: "tool-call-3",
1233
- toolName: "circularAction",
1234
- };
1235
-
1236
- const result = aguiToGQL(aguiMessage);
1237
-
1238
- expect(result).toHaveLength(1);
1239
- expect(result[0]).toBeInstanceOf(gql.ResultMessage);
1240
- expect((result[0] as any).result).toBe("[object Object]"); // Should fallback to String conversion
1241
- expect((result[0] as any).actionExecutionId).toBe("tool-call-3");
1242
- expect((result[0] as any).actionName).toBe("circularAction");
1243
- });
1244
-
1245
- test("should handle tool result messages with boolean content", () => {
1246
- const aguiMessage: agui.Message = {
1247
- id: "tool-result-4",
1248
- role: "tool",
1249
- content: true as any,
1250
- toolCallId: "tool-call-4",
1251
- toolName: "booleanAction",
1252
- };
1253
-
1254
- const result = aguiToGQL(aguiMessage);
1255
-
1256
- expect(result).toHaveLength(1);
1257
- expect(result[0]).toBeInstanceOf(gql.ResultMessage);
1258
- expect((result[0] as any).result).toBe("true");
1259
- expect((result[0] as any).actionExecutionId).toBe("tool-call-4");
1260
- expect((result[0] as any).actionName).toBe("booleanAction");
1261
- });
1262
- });
1263
- });