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

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 (623) 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 +18 -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/index.cjs +75 -0
  63. package/dist/index.d.cts +24 -0
  64. package/dist/index.d.mts +24 -0
  65. package/dist/index.mjs +17 -5598
  66. package/dist/internal/learned-skills.cjs +21 -0
  67. package/dist/internal/learned-skills.d.cts +9 -0
  68. package/dist/internal/learned-skills.d.mts +9 -0
  69. package/dist/internal/learned-skills.mjs +9 -0
  70. package/dist/node.cjs +7 -0
  71. package/dist/node.d.cts +4 -0
  72. package/dist/node.d.mts +4 -0
  73. package/dist/node.mjs +4 -0
  74. package/dist/runtime/core/channel-activation-config.cjs +87 -0
  75. package/dist/runtime/core/channel-activation-config.cjs.map +1 -0
  76. package/dist/runtime/core/channel-activation-config.d.cts +39 -0
  77. package/dist/runtime/core/channel-activation-config.d.cts.map +1 -0
  78. package/dist/runtime/core/channel-activation-config.d.mts +39 -0
  79. package/dist/runtime/core/channel-activation-config.d.mts.map +1 -0
  80. package/dist/runtime/core/channel-activation-config.mjs +85 -0
  81. package/dist/runtime/core/channel-activation-config.mjs.map +1 -0
  82. package/dist/runtime/core/channel-manager.cjs +973 -0
  83. package/dist/runtime/core/channel-manager.cjs.map +1 -0
  84. package/dist/runtime/core/channel-manager.d.cts +166 -0
  85. package/dist/runtime/core/channel-manager.d.cts.map +1 -0
  86. package/dist/runtime/core/channel-manager.d.mts +167 -0
  87. package/dist/runtime/core/channel-manager.d.mts.map +1 -0
  88. package/dist/runtime/core/channel-manager.mjs +972 -0
  89. package/dist/runtime/core/channel-manager.mjs.map +1 -0
  90. package/dist/runtime/core/debug-event-bus.cjs +57 -0
  91. package/dist/runtime/core/debug-event-bus.cjs.map +1 -0
  92. package/dist/runtime/core/debug-event-bus.d.cts +18 -0
  93. package/dist/runtime/core/debug-event-bus.d.cts.map +1 -0
  94. package/dist/runtime/core/debug-event-bus.d.mts +18 -0
  95. package/dist/runtime/core/debug-event-bus.d.mts.map +1 -0
  96. package/dist/runtime/core/debug-event-bus.mjs +55 -0
  97. package/dist/runtime/core/debug-event-bus.mjs.map +1 -0
  98. package/dist/runtime/core/fetch-cors.cjs +71 -0
  99. package/dist/runtime/core/fetch-cors.cjs.map +1 -0
  100. package/dist/runtime/core/fetch-cors.d.cts +19 -0
  101. package/dist/runtime/core/fetch-cors.d.cts.map +1 -0
  102. package/dist/runtime/core/fetch-cors.d.mts +19 -0
  103. package/dist/runtime/core/fetch-cors.d.mts.map +1 -0
  104. package/dist/runtime/core/fetch-cors.mjs +69 -0
  105. package/dist/runtime/core/fetch-cors.mjs.map +1 -0
  106. package/dist/runtime/core/fetch-handler.cjs +539 -0
  107. package/dist/runtime/core/fetch-handler.cjs.map +1 -0
  108. package/dist/runtime/core/fetch-handler.d.cts +99 -0
  109. package/dist/runtime/core/fetch-handler.d.cts.map +1 -0
  110. package/dist/runtime/core/fetch-handler.d.mts +99 -0
  111. package/dist/runtime/core/fetch-handler.d.mts.map +1 -0
  112. package/dist/runtime/core/fetch-handler.mjs +538 -0
  113. package/dist/runtime/core/fetch-handler.mjs.map +1 -0
  114. package/dist/runtime/core/fetch-router.cjs +141 -0
  115. package/dist/runtime/core/fetch-router.cjs.map +1 -0
  116. package/dist/runtime/core/fetch-router.mjs +140 -0
  117. package/dist/runtime/core/fetch-router.mjs.map +1 -0
  118. package/dist/runtime/core/hooks.cjs +28 -0
  119. package/dist/runtime/core/hooks.cjs.map +1 -0
  120. package/dist/runtime/core/hooks.d.cts +121 -0
  121. package/dist/runtime/core/hooks.d.cts.map +1 -0
  122. package/dist/runtime/core/hooks.d.mts +121 -0
  123. package/dist/runtime/core/hooks.d.mts.map +1 -0
  124. package/dist/runtime/core/hooks.mjs +24 -0
  125. package/dist/runtime/core/hooks.mjs.map +1 -0
  126. package/dist/runtime/core/learning.cjs +61 -0
  127. package/dist/runtime/core/learning.cjs.map +1 -0
  128. package/dist/runtime/core/learning.d.cts +61 -0
  129. package/dist/runtime/core/learning.d.cts.map +1 -0
  130. package/dist/runtime/core/learning.d.mts +61 -0
  131. package/dist/runtime/core/learning.d.mts.map +1 -0
  132. package/dist/runtime/core/learning.mjs +56 -0
  133. package/dist/runtime/core/learning.mjs.map +1 -0
  134. package/dist/runtime/core/logger.cjs +21 -0
  135. package/dist/runtime/core/logger.cjs.map +1 -0
  136. package/dist/runtime/core/logger.d.cts +12 -0
  137. package/dist/runtime/core/logger.d.cts.map +1 -0
  138. package/dist/runtime/core/logger.d.mts +12 -0
  139. package/dist/runtime/core/logger.d.mts.map +1 -0
  140. package/dist/runtime/core/logger.mjs +18 -0
  141. package/dist/runtime/core/logger.mjs.map +1 -0
  142. package/dist/runtime/core/middleware-sse-parser.cjs +149 -0
  143. package/dist/runtime/core/middleware-sse-parser.cjs.map +1 -0
  144. package/dist/runtime/core/middleware-sse-parser.d.cts +21 -0
  145. package/dist/runtime/core/middleware-sse-parser.d.cts.map +1 -0
  146. package/dist/runtime/core/middleware-sse-parser.d.mts +21 -0
  147. package/dist/runtime/core/middleware-sse-parser.d.mts.map +1 -0
  148. package/dist/runtime/core/middleware-sse-parser.mjs +148 -0
  149. package/dist/runtime/core/middleware-sse-parser.mjs.map +1 -0
  150. package/dist/runtime/core/middleware.cjs +34 -0
  151. package/dist/runtime/core/middleware.cjs.map +1 -0
  152. package/dist/runtime/core/middleware.d.cts +31 -0
  153. package/dist/runtime/core/middleware.d.cts.map +1 -0
  154. package/dist/runtime/core/middleware.d.mts +31 -0
  155. package/dist/runtime/core/middleware.d.mts.map +1 -0
  156. package/dist/runtime/core/middleware.mjs +32 -0
  157. package/dist/runtime/core/middleware.mjs.map +1 -0
  158. package/dist/runtime/core/package-info.cjs +9 -0
  159. package/dist/runtime/core/package-info.cjs.map +1 -0
  160. package/dist/runtime/core/package-info.mjs +7 -0
  161. package/dist/runtime/core/package-info.mjs.map +1 -0
  162. package/dist/runtime/core/runtime-error-reporter.cjs +21 -0
  163. package/dist/runtime/core/runtime-error-reporter.cjs.map +1 -0
  164. package/dist/runtime/core/runtime-error-reporter.mjs +18 -0
  165. package/dist/runtime/core/runtime-error-reporter.mjs.map +1 -0
  166. package/dist/runtime/core/runtime.cjs +256 -0
  167. package/dist/runtime/core/runtime.cjs.map +1 -0
  168. package/dist/runtime/core/runtime.d.cts +481 -0
  169. package/dist/runtime/core/runtime.d.cts.map +1 -0
  170. package/dist/runtime/core/runtime.d.mts +481 -0
  171. package/dist/runtime/core/runtime.d.mts.map +1 -0
  172. package/dist/runtime/core/runtime.mjs +249 -0
  173. package/dist/runtime/core/runtime.mjs.map +1 -0
  174. package/dist/runtime/endpoints/auto-start-channels.cjs +46 -0
  175. package/dist/runtime/endpoints/auto-start-channels.cjs.map +1 -0
  176. package/dist/runtime/endpoints/auto-start-channels.mjs +45 -0
  177. package/dist/runtime/endpoints/auto-start-channels.mjs.map +1 -0
  178. package/dist/runtime/endpoints/node-fetch-handler.cjs +75 -0
  179. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -0
  180. package/dist/runtime/endpoints/node-fetch-handler.d.cts +11 -0
  181. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -0
  182. package/dist/runtime/endpoints/node-fetch-handler.d.mts +11 -0
  183. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -0
  184. package/dist/runtime/endpoints/node-fetch-handler.mjs +73 -0
  185. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -0
  186. package/dist/runtime/endpoints/node.cjs +16 -0
  187. package/dist/runtime/endpoints/node.cjs.map +1 -0
  188. package/dist/runtime/endpoints/node.d.cts +104 -0
  189. package/dist/runtime/endpoints/node.d.cts.map +1 -0
  190. package/dist/runtime/endpoints/node.d.mts +104 -0
  191. package/dist/runtime/endpoints/node.d.mts.map +1 -0
  192. package/dist/runtime/endpoints/node.mjs +16 -0
  193. package/dist/runtime/endpoints/node.mjs.map +1 -0
  194. package/dist/runtime/endpoints/single-route-helpers.cjs +130 -0
  195. package/dist/runtime/endpoints/single-route-helpers.cjs.map +1 -0
  196. package/dist/runtime/endpoints/single-route-helpers.mjs +125 -0
  197. package/dist/runtime/endpoints/single-route-helpers.mjs.map +1 -0
  198. package/dist/runtime/generative-ui/generative-ui-middleware.cjs +393 -0
  199. package/dist/runtime/generative-ui/generative-ui-middleware.cjs.map +1 -0
  200. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts +20 -0
  201. package/dist/runtime/generative-ui/generative-ui-middleware.d.cts.map +1 -0
  202. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts +20 -0
  203. package/dist/runtime/generative-ui/generative-ui-middleware.d.mts.map +1 -0
  204. package/dist/runtime/generative-ui/generative-ui-middleware.mjs +392 -0
  205. package/dist/runtime/generative-ui/generative-ui-middleware.mjs.map +1 -0
  206. package/dist/runtime/generative-ui/index.d.cts +2 -0
  207. package/dist/runtime/generative-ui/index.d.mts +2 -0
  208. package/dist/runtime/generative-ui/surface-writer.cjs +85 -0
  209. package/dist/runtime/generative-ui/surface-writer.cjs.map +1 -0
  210. package/dist/runtime/generative-ui/surface-writer.d.cts +32 -0
  211. package/dist/runtime/generative-ui/surface-writer.d.cts.map +1 -0
  212. package/dist/runtime/generative-ui/surface-writer.d.mts +32 -0
  213. package/dist/runtime/generative-ui/surface-writer.d.mts.map +1 -0
  214. package/dist/runtime/generative-ui/surface-writer.mjs +84 -0
  215. package/dist/runtime/generative-ui/surface-writer.mjs.map +1 -0
  216. package/dist/runtime/handlers/get-runtime-info.cjs +140 -0
  217. package/dist/runtime/handlers/get-runtime-info.cjs.map +1 -0
  218. package/dist/runtime/handlers/get-runtime-info.mjs +140 -0
  219. package/dist/runtime/handlers/get-runtime-info.mjs.map +1 -0
  220. package/dist/runtime/handlers/handle-connect.cjs +62 -0
  221. package/dist/runtime/handlers/handle-connect.cjs.map +1 -0
  222. package/dist/runtime/handlers/handle-connect.mjs +62 -0
  223. package/dist/runtime/handlers/handle-connect.mjs.map +1 -0
  224. package/dist/runtime/handlers/handle-debug-events.cjs +33 -0
  225. package/dist/runtime/handlers/handle-debug-events.cjs.map +1 -0
  226. package/dist/runtime/handlers/handle-debug-events.mjs +33 -0
  227. package/dist/runtime/handlers/handle-debug-events.mjs.map +1 -0
  228. package/dist/runtime/handlers/handle-inspector-learning.cjs +56 -0
  229. package/dist/runtime/handlers/handle-inspector-learning.cjs.map +1 -0
  230. package/dist/runtime/handlers/handle-inspector-learning.mjs +55 -0
  231. package/dist/runtime/handlers/handle-inspector-learning.mjs.map +1 -0
  232. package/dist/runtime/handlers/handle-inspector-metadata.cjs +36 -0
  233. package/dist/runtime/handlers/handle-inspector-metadata.cjs.map +1 -0
  234. package/dist/runtime/handlers/handle-inspector-metadata.mjs +35 -0
  235. package/dist/runtime/handlers/handle-inspector-metadata.mjs.map +1 -0
  236. package/dist/runtime/handlers/handle-run.cjs +111 -0
  237. package/dist/runtime/handlers/handle-run.cjs.map +1 -0
  238. package/dist/runtime/handlers/handle-run.mjs +110 -0
  239. package/dist/runtime/handlers/handle-run.mjs.map +1 -0
  240. package/dist/runtime/handlers/handle-stop.cjs +102 -0
  241. package/dist/runtime/handlers/handle-stop.cjs.map +1 -0
  242. package/dist/runtime/handlers/handle-stop.mjs +101 -0
  243. package/dist/runtime/handlers/handle-stop.mjs.map +1 -0
  244. package/dist/runtime/handlers/handle-suggest.cjs +83 -0
  245. package/dist/runtime/handlers/handle-suggest.cjs.map +1 -0
  246. package/dist/runtime/handlers/handle-suggest.mjs +82 -0
  247. package/dist/runtime/handlers/handle-suggest.mjs.map +1 -0
  248. package/dist/runtime/handlers/handle-trajectory-connect.cjs +40 -0
  249. package/dist/runtime/handlers/handle-trajectory-connect.cjs.map +1 -0
  250. package/dist/runtime/handlers/handle-trajectory-connect.mjs +39 -0
  251. package/dist/runtime/handlers/handle-trajectory-connect.mjs.map +1 -0
  252. package/dist/runtime/handlers/handle-transcribe.cjs +112 -0
  253. package/dist/runtime/handlers/handle-transcribe.cjs.map +1 -0
  254. package/dist/runtime/handlers/handle-transcribe.mjs +111 -0
  255. package/dist/runtime/handlers/handle-transcribe.mjs.map +1 -0
  256. package/dist/runtime/handlers/header-utils.cjs +185 -0
  257. package/dist/runtime/handlers/header-utils.cjs.map +1 -0
  258. package/dist/runtime/handlers/header-utils.d.cts +53 -0
  259. package/dist/runtime/handlers/header-utils.d.cts.map +1 -0
  260. package/dist/runtime/handlers/header-utils.d.mts +53 -0
  261. package/dist/runtime/handlers/header-utils.d.mts.map +1 -0
  262. package/dist/runtime/handlers/header-utils.mjs +183 -0
  263. package/dist/runtime/handlers/header-utils.mjs.map +1 -0
  264. package/dist/runtime/handlers/intelligence/annotate.cjs +83 -0
  265. package/dist/runtime/handlers/intelligence/annotate.cjs.map +1 -0
  266. package/dist/runtime/handlers/intelligence/annotate.mjs +82 -0
  267. package/dist/runtime/handlers/intelligence/annotate.mjs.map +1 -0
  268. package/dist/runtime/handlers/intelligence/connect.cjs +68 -0
  269. package/dist/runtime/handlers/intelligence/connect.cjs.map +1 -0
  270. package/dist/runtime/handlers/intelligence/connect.mjs +68 -0
  271. package/dist/runtime/handlers/intelligence/connect.mjs.map +1 -0
  272. package/dist/runtime/handlers/intelligence/memories.cjs +260 -0
  273. package/dist/runtime/handlers/intelligence/memories.cjs.map +1 -0
  274. package/dist/runtime/handlers/intelligence/memories.mjs +254 -0
  275. package/dist/runtime/handlers/intelligence/memories.mjs.map +1 -0
  276. package/dist/runtime/handlers/intelligence/run.cjs +283 -0
  277. package/dist/runtime/handlers/intelligence/run.cjs.map +1 -0
  278. package/dist/runtime/handlers/intelligence/run.mjs +282 -0
  279. package/dist/runtime/handlers/intelligence/run.mjs.map +1 -0
  280. package/dist/runtime/handlers/intelligence/thread-names.cjs +172 -0
  281. package/dist/runtime/handlers/intelligence/thread-names.cjs.map +1 -0
  282. package/dist/runtime/handlers/intelligence/thread-names.mjs +171 -0
  283. package/dist/runtime/handlers/intelligence/thread-names.mjs.map +1 -0
  284. package/dist/runtime/handlers/intelligence/threads.cjs +399 -0
  285. package/dist/runtime/handlers/intelligence/threads.cjs.map +1 -0
  286. package/dist/runtime/handlers/intelligence/threads.mjs +390 -0
  287. package/dist/runtime/handlers/intelligence/threads.mjs.map +1 -0
  288. package/dist/runtime/handlers/shared/agent-utils.cjs +267 -0
  289. package/dist/runtime/handlers/shared/agent-utils.cjs.map +1 -0
  290. package/dist/runtime/handlers/shared/agent-utils.mjs +262 -0
  291. package/dist/runtime/handlers/shared/agent-utils.mjs.map +1 -0
  292. package/dist/runtime/handlers/shared/cloud-telemetry.cjs +30 -0
  293. package/dist/runtime/handlers/shared/cloud-telemetry.cjs.map +1 -0
  294. package/dist/runtime/handlers/shared/cloud-telemetry.mjs +29 -0
  295. package/dist/runtime/handlers/shared/cloud-telemetry.mjs.map +1 -0
  296. package/dist/runtime/handlers/shared/describe-endpoint.cjs +25 -0
  297. package/dist/runtime/handlers/shared/describe-endpoint.cjs.map +1 -0
  298. package/dist/runtime/handlers/shared/describe-endpoint.mjs +24 -0
  299. package/dist/runtime/handlers/shared/describe-endpoint.mjs.map +1 -0
  300. package/dist/runtime/handlers/shared/intelligence-utils.cjs +24 -0
  301. package/dist/runtime/handlers/shared/intelligence-utils.cjs.map +1 -0
  302. package/dist/runtime/handlers/shared/intelligence-utils.mjs +23 -0
  303. package/dist/runtime/handlers/shared/intelligence-utils.mjs.map +1 -0
  304. package/dist/runtime/handlers/shared/json-response.cjs +14 -0
  305. package/dist/runtime/handlers/shared/json-response.cjs.map +1 -0
  306. package/dist/runtime/handlers/shared/json-response.mjs +12 -0
  307. package/dist/runtime/handlers/shared/json-response.mjs.map +1 -0
  308. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs +22 -0
  309. package/dist/runtime/handlers/shared/mcp-apps-servers.cjs.map +1 -0
  310. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs +22 -0
  311. package/dist/runtime/handlers/shared/mcp-apps-servers.mjs.map +1 -0
  312. package/dist/runtime/handlers/shared/memory-policy.cjs +78 -0
  313. package/dist/runtime/handlers/shared/memory-policy.cjs.map +1 -0
  314. package/dist/runtime/handlers/shared/memory-policy.mjs +77 -0
  315. package/dist/runtime/handlers/shared/memory-policy.mjs.map +1 -0
  316. package/dist/runtime/handlers/shared/platform-error.cjs +39 -0
  317. package/dist/runtime/handlers/shared/platform-error.cjs.map +1 -0
  318. package/dist/runtime/handlers/shared/platform-error.mjs +39 -0
  319. package/dist/runtime/handlers/shared/platform-error.mjs.map +1 -0
  320. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs +50 -0
  321. package/dist/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -0
  322. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs +49 -0
  323. package/dist/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -0
  324. package/dist/runtime/handlers/shared/sse-keep-alive.cjs +68 -0
  325. package/dist/runtime/handlers/shared/sse-keep-alive.cjs.map +1 -0
  326. package/dist/runtime/handlers/shared/sse-keep-alive.mjs +66 -0
  327. package/dist/runtime/handlers/shared/sse-keep-alive.mjs.map +1 -0
  328. package/dist/runtime/handlers/shared/sse-response.cjs +237 -0
  329. package/dist/runtime/handlers/shared/sse-response.cjs.map +1 -0
  330. package/dist/runtime/handlers/shared/sse-response.mjs +236 -0
  331. package/dist/runtime/handlers/shared/sse-response.mjs.map +1 -0
  332. package/dist/runtime/handlers/shared/thread-access.cjs +137 -0
  333. package/dist/runtime/handlers/shared/thread-access.cjs.map +1 -0
  334. package/dist/runtime/handlers/shared/thread-access.d.cts +28 -0
  335. package/dist/runtime/handlers/shared/thread-access.d.cts.map +1 -0
  336. package/dist/runtime/handlers/shared/thread-access.d.mts +28 -0
  337. package/dist/runtime/handlers/shared/thread-access.d.mts.map +1 -0
  338. package/dist/runtime/handlers/shared/thread-access.mjs +132 -0
  339. package/dist/runtime/handlers/shared/thread-access.mjs.map +1 -0
  340. package/dist/runtime/handlers/sse/connect.cjs +23 -0
  341. package/dist/runtime/handlers/sse/connect.cjs.map +1 -0
  342. package/dist/runtime/handlers/sse/connect.mjs +23 -0
  343. package/dist/runtime/handlers/sse/connect.mjs.map +1 -0
  344. package/dist/runtime/handlers/sse/run.cjs +44 -0
  345. package/dist/runtime/handlers/sse/run.cjs.map +1 -0
  346. package/dist/runtime/handlers/sse/run.mjs +44 -0
  347. package/dist/runtime/handlers/sse/run.mjs.map +1 -0
  348. package/dist/runtime/index.d.cts +29 -0
  349. package/dist/runtime/index.d.cts.map +1 -0
  350. package/dist/runtime/index.d.mts +29 -0
  351. package/dist/runtime/index.d.mts.map +1 -0
  352. package/dist/runtime/intelligence-platform/client.cjs +1338 -0
  353. package/dist/runtime/intelligence-platform/client.cjs.map +1 -0
  354. package/dist/runtime/intelligence-platform/client.d.cts +824 -0
  355. package/dist/runtime/intelligence-platform/client.d.cts.map +1 -0
  356. package/dist/runtime/intelligence-platform/client.d.mts +824 -0
  357. package/dist/runtime/intelligence-platform/client.d.mts.map +1 -0
  358. package/dist/runtime/intelligence-platform/client.mjs +1334 -0
  359. package/dist/runtime/intelligence-platform/client.mjs.map +1 -0
  360. package/dist/runtime/intelligence-platform/experimental.d.cts +26 -0
  361. package/dist/runtime/intelligence-platform/experimental.d.cts.map +1 -0
  362. package/dist/runtime/intelligence-platform/experimental.d.mts +26 -0
  363. package/dist/runtime/intelligence-platform/experimental.d.mts.map +1 -0
  364. package/dist/runtime/intelligence-platform/index.d.cts +3 -0
  365. package/dist/runtime/intelligence-platform/index.d.mts +3 -0
  366. package/dist/runtime/intelligence-platform/learned-skills.cjs +95 -0
  367. package/dist/runtime/intelligence-platform/learned-skills.cjs.map +1 -0
  368. package/dist/runtime/intelligence-platform/learned-skills.d.cts +43 -0
  369. package/dist/runtime/intelligence-platform/learned-skills.d.cts.map +1 -0
  370. package/dist/runtime/intelligence-platform/learned-skills.d.mts +43 -0
  371. package/dist/runtime/intelligence-platform/learned-skills.d.mts.map +1 -0
  372. package/dist/runtime/intelligence-platform/learned-skills.mjs +92 -0
  373. package/dist/runtime/intelligence-platform/learned-skills.mjs.map +1 -0
  374. package/dist/runtime/intelligence-platform/learning-management.cjs +203 -0
  375. package/dist/runtime/intelligence-platform/learning-management.cjs.map +1 -0
  376. package/dist/runtime/intelligence-platform/learning-management.d.cts +111 -0
  377. package/dist/runtime/intelligence-platform/learning-management.d.cts.map +1 -0
  378. package/dist/runtime/intelligence-platform/learning-management.d.mts +111 -0
  379. package/dist/runtime/intelligence-platform/learning-management.d.mts.map +1 -0
  380. package/dist/runtime/intelligence-platform/learning-management.mjs +193 -0
  381. package/dist/runtime/intelligence-platform/learning-management.mjs.map +1 -0
  382. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs +131 -0
  383. package/dist/runtime/intelligence-platform/skill-registry/archive.cjs.map +1 -0
  384. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts +10 -0
  385. package/dist/runtime/intelligence-platform/skill-registry/archive.d.cts.map +1 -0
  386. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts +10 -0
  387. package/dist/runtime/intelligence-platform/skill-registry/archive.d.mts.map +1 -0
  388. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs +127 -0
  389. package/dist/runtime/intelligence-platform/skill-registry/archive.mjs.map +1 -0
  390. package/dist/runtime/intelligence-platform/skill-registry/config.cjs +65 -0
  391. package/dist/runtime/intelligence-platform/skill-registry/config.cjs.map +1 -0
  392. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts +47 -0
  393. package/dist/runtime/intelligence-platform/skill-registry/config.d.cts.map +1 -0
  394. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts +47 -0
  395. package/dist/runtime/intelligence-platform/skill-registry/config.d.mts.map +1 -0
  396. package/dist/runtime/intelligence-platform/skill-registry/config.mjs +65 -0
  397. package/dist/runtime/intelligence-platform/skill-registry/config.mjs.map +1 -0
  398. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs +10 -0
  399. package/dist/runtime/intelligence-platform/skill-registry/errors.cjs.map +1 -0
  400. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts +7 -0
  401. package/dist/runtime/intelligence-platform/skill-registry/errors.d.cts.map +1 -0
  402. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts +7 -0
  403. package/dist/runtime/intelligence-platform/skill-registry/errors.d.mts.map +1 -0
  404. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs +10 -0
  405. package/dist/runtime/intelligence-platform/skill-registry/errors.mjs.map +1 -0
  406. package/dist/runtime/intelligence-platform/skill-registry/index.d.cts +7 -0
  407. package/dist/runtime/intelligence-platform/skill-registry/index.d.mts +7 -0
  408. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs +247 -0
  409. package/dist/runtime/intelligence-platform/skill-registry/registry.cjs.map +1 -0
  410. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts +36 -0
  411. package/dist/runtime/intelligence-platform/skill-registry/registry.d.cts.map +1 -0
  412. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts +36 -0
  413. package/dist/runtime/intelligence-platform/skill-registry/registry.d.mts.map +1 -0
  414. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs +246 -0
  415. package/dist/runtime/intelligence-platform/skill-registry/registry.mjs.map +1 -0
  416. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs +41 -0
  417. package/dist/runtime/intelligence-platform/skill-registry/skill-content.cjs.map +1 -0
  418. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts +12 -0
  419. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.cts.map +1 -0
  420. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts +12 -0
  421. package/dist/runtime/intelligence-platform/skill-registry/skill-content.d.mts.map +1 -0
  422. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs +38 -0
  423. package/dist/runtime/intelligence-platform/skill-registry/skill-content.mjs.map +1 -0
  424. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs +92 -0
  425. package/dist/runtime/intelligence-platform/skill-registry/snapshot.cjs.map +1 -0
  426. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts +27 -0
  427. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.cts.map +1 -0
  428. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts +27 -0
  429. package/dist/runtime/intelligence-platform/skill-registry/snapshot.d.mts.map +1 -0
  430. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs +91 -0
  431. package/dist/runtime/intelligence-platform/skill-registry/snapshot.mjs.map +1 -0
  432. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs +142 -0
  433. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.cjs.map +1 -0
  434. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs +141 -0
  435. package/dist/runtime/intelligence-platform/thread-lock-heartbeat.mjs.map +1 -0
  436. package/dist/runtime/intelligence-platform/trajectories.cjs +95 -0
  437. package/dist/runtime/intelligence-platform/trajectories.cjs.map +1 -0
  438. package/dist/runtime/intelligence-platform/trajectories.d.cts +11 -0
  439. package/dist/runtime/intelligence-platform/trajectories.d.cts.map +1 -0
  440. package/dist/runtime/intelligence-platform/trajectories.d.mts +11 -0
  441. package/dist/runtime/intelligence-platform/trajectories.d.mts.map +1 -0
  442. package/dist/runtime/intelligence-platform/trajectories.mjs +91 -0
  443. package/dist/runtime/intelligence-platform/trajectories.mjs.map +1 -0
  444. package/dist/runtime/node.d.cts +2 -0
  445. package/dist/runtime/node.d.mts +2 -0
  446. package/dist/runtime/runner/agent-runner.cjs +82 -0
  447. package/dist/runtime/runner/agent-runner.cjs.map +1 -0
  448. package/dist/runtime/runner/agent-runner.d.cts +151 -0
  449. package/dist/runtime/runner/agent-runner.d.cts.map +1 -0
  450. package/dist/runtime/runner/agent-runner.d.mts +151 -0
  451. package/dist/runtime/runner/agent-runner.d.mts.map +1 -0
  452. package/dist/runtime/runner/agent-runner.mjs +73 -0
  453. package/dist/runtime/runner/agent-runner.mjs.map +1 -0
  454. package/dist/runtime/runner/in-memory.cjs +741 -0
  455. package/dist/runtime/runner/in-memory.cjs.map +1 -0
  456. package/dist/runtime/runner/in-memory.d.cts +427 -0
  457. package/dist/runtime/runner/in-memory.d.cts.map +1 -0
  458. package/dist/runtime/runner/in-memory.d.mts +427 -0
  459. package/dist/runtime/runner/in-memory.d.mts.map +1 -0
  460. package/dist/runtime/runner/in-memory.mjs +734 -0
  461. package/dist/runtime/runner/in-memory.mjs.map +1 -0
  462. package/dist/runtime/runner/index.d.cts +5 -0
  463. package/dist/runtime/runner/index.d.mts +5 -0
  464. package/dist/runtime/runner/index.mjs +6 -0
  465. package/dist/runtime/runner/intelligence.cjs +617 -0
  466. package/dist/runtime/runner/intelligence.cjs.map +1 -0
  467. package/dist/runtime/runner/intelligence.d.cts +104 -0
  468. package/dist/runtime/runner/intelligence.d.cts.map +1 -0
  469. package/dist/runtime/runner/intelligence.d.mts +104 -0
  470. package/dist/runtime/runner/intelligence.d.mts.map +1 -0
  471. package/dist/runtime/runner/intelligence.mjs +616 -0
  472. package/dist/runtime/runner/intelligence.mjs.map +1 -0
  473. package/dist/runtime/telemetry/disclosure.cjs +25 -0
  474. package/dist/runtime/telemetry/disclosure.cjs.map +1 -0
  475. package/dist/runtime/telemetry/disclosure.mjs +24 -0
  476. package/dist/runtime/telemetry/disclosure.mjs.map +1 -0
  477. package/dist/runtime/telemetry/events.d.cts +66 -0
  478. package/dist/runtime/telemetry/events.d.cts.map +1 -0
  479. package/dist/runtime/telemetry/events.d.mts +66 -0
  480. package/dist/runtime/telemetry/events.d.mts.map +1 -0
  481. package/dist/runtime/telemetry/instance-created.cjs +34 -0
  482. package/dist/runtime/telemetry/instance-created.cjs.map +1 -0
  483. package/dist/runtime/telemetry/instance-created.mjs +34 -0
  484. package/dist/runtime/telemetry/instance-created.mjs.map +1 -0
  485. package/dist/runtime/telemetry/telemetry-client.cjs +108 -0
  486. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -0
  487. package/dist/runtime/telemetry/telemetry-client.d.cts +10 -0
  488. package/dist/runtime/telemetry/telemetry-client.d.cts.map +1 -0
  489. package/dist/runtime/telemetry/telemetry-client.d.mts +10 -0
  490. package/dist/runtime/telemetry/telemetry-client.d.mts.map +1 -0
  491. package/dist/runtime/telemetry/telemetry-client.mjs +107 -0
  492. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -0
  493. package/dist/runtime/telemetry/telemetry-identity.cjs +12 -0
  494. package/dist/runtime/telemetry/telemetry-identity.cjs.map +1 -0
  495. package/dist/runtime/telemetry/telemetry-identity.mjs +11 -0
  496. package/dist/runtime/telemetry/telemetry-identity.mjs.map +1 -0
  497. package/dist/runtime/transcription-service/transcription-service.cjs +7 -0
  498. package/dist/runtime/transcription-service/transcription-service.cjs.map +1 -0
  499. package/dist/runtime/transcription-service/transcription-service.d.cts +14 -0
  500. package/dist/runtime/transcription-service/transcription-service.d.cts.map +1 -0
  501. package/dist/runtime/transcription-service/transcription-service.d.mts +14 -0
  502. package/dist/runtime/transcription-service/transcription-service.d.mts.map +1 -0
  503. package/dist/runtime/transcription-service/transcription-service.mjs +6 -0
  504. package/dist/runtime/transcription-service/transcription-service.mjs.map +1 -0
  505. package/package.json +104 -105
  506. package/.eslintrc.js +0 -7
  507. package/CHANGELOG.md +0 -2920
  508. package/__snapshots__/schema/schema.graphql +0 -371
  509. package/dist/index.d.ts +0 -1494
  510. package/dist/index.js +0 -5641
  511. package/dist/index.js.map +0 -1
  512. package/dist/index.mjs.map +0 -1
  513. package/dist/langgraph.d.ts +0 -284
  514. package/dist/langgraph.js +0 -211
  515. package/dist/langgraph.js.map +0 -1
  516. package/dist/langgraph.mjs +0 -206
  517. package/dist/langgraph.mjs.map +0 -1
  518. package/dist/v2/index.d.ts +0 -2
  519. package/dist/v2/index.js +0 -22
  520. package/dist/v2/index.js.map +0 -1
  521. package/dist/v2/index.mjs +0 -5
  522. package/dist/v2/index.mjs.map +0 -1
  523. package/jest.config.js +0 -10
  524. package/scripts/generate-gql-schema.ts +0 -13
  525. package/src/agents/langgraph/event-source.ts +0 -329
  526. package/src/agents/langgraph/events.ts +0 -377
  527. package/src/graphql/inputs/action.input.ts +0 -16
  528. package/src/graphql/inputs/agent-session.input.ts +0 -13
  529. package/src/graphql/inputs/agent-state.input.ts +0 -13
  530. package/src/graphql/inputs/cloud-guardrails.input.ts +0 -16
  531. package/src/graphql/inputs/cloud.input.ts +0 -8
  532. package/src/graphql/inputs/context-property.input.ts +0 -10
  533. package/src/graphql/inputs/copilot-context.input.ts +0 -10
  534. package/src/graphql/inputs/custom-property.input.ts +0 -15
  535. package/src/graphql/inputs/extensions.input.ts +0 -21
  536. package/src/graphql/inputs/forwarded-parameters.input.ts +0 -22
  537. package/src/graphql/inputs/frontend.input.ts +0 -14
  538. package/src/graphql/inputs/generate-copilot-response.input.ts +0 -59
  539. package/src/graphql/inputs/load-agent-state.input.ts +0 -10
  540. package/src/graphql/inputs/message.input.ts +0 -110
  541. package/src/graphql/inputs/meta-event.input.ts +0 -18
  542. package/src/graphql/message-conversion/agui-to-gql.test.ts +0 -1263
  543. package/src/graphql/message-conversion/agui-to-gql.ts +0 -333
  544. package/src/graphql/message-conversion/gql-to-agui.test.ts +0 -1580
  545. package/src/graphql/message-conversion/gql-to-agui.ts +0 -278
  546. package/src/graphql/message-conversion/index.ts +0 -2
  547. package/src/graphql/message-conversion/roundtrip-conversion.test.ts +0 -526
  548. package/src/graphql/resolvers/copilot.resolver.ts +0 -708
  549. package/src/graphql/resolvers/state.resolver.ts +0 -27
  550. package/src/graphql/types/agents-response.type.ts +0 -19
  551. package/src/graphql/types/base/index.ts +0 -10
  552. package/src/graphql/types/converted/index.ts +0 -176
  553. package/src/graphql/types/copilot-response.type.ts +0 -138
  554. package/src/graphql/types/enums.ts +0 -38
  555. package/src/graphql/types/extensions-response.type.ts +0 -23
  556. package/src/graphql/types/guardrails-result.type.ts +0 -20
  557. package/src/graphql/types/load-agent-state-response.type.ts +0 -17
  558. package/src/graphql/types/message-status.type.ts +0 -42
  559. package/src/graphql/types/meta-events.type.ts +0 -71
  560. package/src/graphql/types/response-status.type.ts +0 -66
  561. package/src/index.ts +0 -4
  562. package/src/langgraph.ts +0 -1
  563. package/src/lib/cloud/index.ts +0 -4
  564. package/src/lib/error-messages.ts +0 -200
  565. package/src/lib/index.ts +0 -52
  566. package/src/lib/integrations/index.ts +0 -6
  567. package/src/lib/integrations/nest/index.ts +0 -14
  568. package/src/lib/integrations/nextjs/app-router.ts +0 -38
  569. package/src/lib/integrations/nextjs/pages-router.ts +0 -39
  570. package/src/lib/integrations/node-express/index.ts +0 -14
  571. package/src/lib/integrations/node-http/index.ts +0 -143
  572. package/src/lib/integrations/node-http/request-handler.ts +0 -111
  573. package/src/lib/integrations/shared.ts +0 -161
  574. package/src/lib/logger.ts +0 -28
  575. package/src/lib/observability.ts +0 -160
  576. package/src/lib/runtime/__tests__/copilot-runtime-error.test.ts +0 -169
  577. package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +0 -464
  578. package/src/lib/runtime/agent-integrations/langgraph/agent.ts +0 -209
  579. package/src/lib/runtime/agent-integrations/langgraph/consts.ts +0 -34
  580. package/src/lib/runtime/agent-integrations/langgraph/index.ts +0 -2
  581. package/src/lib/runtime/copilot-runtime.ts +0 -710
  582. package/src/lib/runtime/mcp-tools-utils.ts +0 -254
  583. package/src/lib/runtime/retry-utils.ts +0 -96
  584. package/src/lib/runtime/telemetry-agent-runner.ts +0 -139
  585. package/src/lib/runtime/types.ts +0 -49
  586. package/src/lib/runtime/utils.ts +0 -87
  587. package/src/lib/streaming.ts +0 -202
  588. package/src/lib/telemetry-client.ts +0 -64
  589. package/src/service-adapters/anthropic/anthropic-adapter.ts +0 -452
  590. package/src/service-adapters/anthropic/utils.ts +0 -152
  591. package/src/service-adapters/bedrock/bedrock-adapter.ts +0 -73
  592. package/src/service-adapters/conversion.ts +0 -67
  593. package/src/service-adapters/empty/empty-adapter.ts +0 -38
  594. package/src/service-adapters/events.ts +0 -294
  595. package/src/service-adapters/experimental/ollama/ollama-adapter.ts +0 -84
  596. package/src/service-adapters/google/google-genai-adapter.test.ts +0 -104
  597. package/src/service-adapters/google/google-genai-adapter.ts +0 -88
  598. package/src/service-adapters/groq/groq-adapter.ts +0 -203
  599. package/src/service-adapters/index.ts +0 -18
  600. package/src/service-adapters/langchain/langchain-adapter.ts +0 -111
  601. package/src/service-adapters/langchain/langserve.ts +0 -88
  602. package/src/service-adapters/langchain/types.ts +0 -14
  603. package/src/service-adapters/langchain/utils.ts +0 -313
  604. package/src/service-adapters/openai/openai-adapter.ts +0 -283
  605. package/src/service-adapters/openai/openai-assistant-adapter.ts +0 -344
  606. package/src/service-adapters/openai/utils.ts +0 -199
  607. package/src/service-adapters/service-adapter.ts +0 -41
  608. package/src/service-adapters/shared/error-utils.ts +0 -61
  609. package/src/service-adapters/shared/index.ts +0 -1
  610. package/src/service-adapters/unify/unify-adapter.ts +0 -151
  611. package/src/utils/failed-response-status-reasons.ts +0 -70
  612. package/src/utils/index.ts +0 -1
  613. package/src/v2/index.ts +0 -3
  614. package/tests/global.d.ts +0 -13
  615. package/tests/service-adapters/anthropic/allowlist-approach.test.ts +0 -226
  616. package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +0 -389
  617. package/tests/service-adapters/openai/allowlist-approach.test.ts +0 -238
  618. package/tests/service-adapters/openai/openai-adapter.test.ts +0 -301
  619. package/tests/setup.jest.ts +0 -21
  620. package/tests/tsconfig.json +0 -10
  621. package/tsconfig.json +0 -13
  622. package/tsup.config.ts +0 -20
  623. package/typedoc.json +0 -4
@@ -0,0 +1 @@
1
+ {"version":3,"file":"single-route-helpers.mjs","names":[],"sources":["../../../src/runtime/endpoints/single-route-helpers.ts"],"sourcesContent":["const METHOD_NAMES = [\n \"agent/run\",\n \"agent/suggest\",\n \"agent/connect\",\n \"trajectory/connect\",\n \"agent/stop\",\n \"info\",\n \"inspector/metadata\",\n \"inspector/learning\",\n \"transcribe\",\n \"resource/request\",\n] as const;\n\nexport type EndpointMethod = (typeof METHOD_NAMES)[number];\n\ninterface JsonEnvelope {\n method?: string;\n params?: Record<string, unknown>;\n body?: unknown;\n}\n\nexport interface MethodCall {\n method: EndpointMethod;\n params?: Record<string, unknown>;\n body?: unknown;\n}\n\n/**\n * Detect a single-route JSON envelope on a request the multi-route router\n * could not match.\n *\n * A single-endpoint client (`useSingleEndpoint` on the frontend provider)\n * POSTs `{ method, params, body }` at the base path. A multi-route runtime\n * matches no route for that path and would otherwise answer a bare 404, giving\n * the developer nothing to go on. Recognising the envelope here lets the\n * handler name the actual cause instead.\n *\n * Deliberately conservative: it reports a method only for a POST carrying a\n * JSON body whose `method` is one the single-route endpoint actually accepts.\n * Anything else is a genuine 404 and must stay one.\n *\n * @returns The envelope's method name, or `null` if this is not an envelope.\n */\nexport async function detectSingleRouteEnvelope(\n request: Request,\n): Promise<EndpointMethod | null> {\n if (request.method !== \"POST\") return null;\n\n const contentType = request.headers.get(\"content-type\") || \"\";\n if (!contentType.includes(\"application/json\")) return null;\n\n let envelope: unknown;\n try {\n envelope = await request.clone().json();\n } catch {\n return null;\n }\n\n if (typeof envelope !== \"object\" || envelope === null) return null;\n\n const method = (envelope as JsonEnvelope).method;\n if (typeof method !== \"string\") return null;\n if (!(METHOD_NAMES as readonly string[]).includes(method)) return null;\n\n return method as EndpointMethod;\n}\n\nexport async function parseMethodCall(request: Request): Promise<MethodCall> {\n const contentType = request.headers.get(\"content-type\") || \"\";\n\n if (!contentType.includes(\"application/json\")) {\n throw createResponseError(\n \"Single-route endpoint expects JSON payloads\",\n 415,\n );\n }\n\n let jsonEnvelope: JsonEnvelope;\n try {\n jsonEnvelope = (await request.clone().json()) as JsonEnvelope;\n } catch {\n throw createResponseError(\"Invalid JSON payload\", 400);\n }\n\n const method = validateMethod(jsonEnvelope.method);\n\n return {\n method,\n params: jsonEnvelope.params,\n body: jsonEnvelope.body,\n };\n}\n\nexport function expectString(\n params: Record<string, unknown> | undefined,\n key: string,\n): string {\n const value = params?.[key];\n if (typeof value === \"string\" && value.trim().length > 0) {\n return value;\n }\n\n throw createResponseError(`Missing or invalid parameter '${key}'`, 400);\n}\n\nexport function createJsonRequest(base: Request, body: unknown): Request {\n if (body === undefined || body === null) {\n throw createResponseError(\"Missing request body for JSON handler\", 400);\n }\n\n const headers = new Headers(base.headers);\n headers.set(\"content-type\", \"application/json\");\n headers.delete(\"content-length\");\n\n const serializedBody = serializeJsonBody(body);\n\n return new Request(base.url, {\n method: \"POST\",\n headers,\n body: serializedBody,\n signal: base.signal,\n });\n}\n\n/**\n * Rebuild a resource request carried inside the single-route JSON envelope.\n *\n * The resource path must stay relative to the mounted Runtime. This prevents\n * the envelope from becoming an open HTTP proxy while preserving the method,\n * query string, headers, and cancellation signal used by the REST handler.\n */\nexport function createResourceRequest(\n base: Request,\n path: string,\n httpMethod: string,\n body: unknown,\n): Request {\n if (!path.startsWith(\"/\") || path.startsWith(\"//\")) {\n throw createResponseError(\"Resource path must be Runtime-relative\", 400);\n }\n\n const resourceUrl = new URL(path, \"http://copilotkit.resource\");\n if (resourceUrl.origin !== \"http://copilotkit.resource\") {\n throw createResponseError(\"Resource path must be Runtime-relative\", 400);\n }\n\n const targetUrl = new URL(base.url);\n targetUrl.pathname = `${targetUrl.pathname.replace(/\\/$/, \"\")}${resourceUrl.pathname}`;\n targetUrl.search = resourceUrl.search;\n\n const method = httpMethod.toUpperCase();\n const headers = new Headers(base.headers);\n headers.delete(\"content-length\");\n const hasBody = method !== \"GET\" && method !== \"HEAD\" && body != null;\n\n return new Request(targetUrl, {\n method,\n headers,\n ...(hasBody ? { body: serializeJsonBody(body) } : {}),\n signal: base.signal,\n });\n}\n\nexport function createResponseError(message: string, status: number): Response {\n return new Response(\n JSON.stringify({\n error: \"invalid_request\",\n message,\n }),\n {\n status,\n headers: {\n \"Content-Type\": \"application/json\",\n },\n },\n );\n}\n\nfunction validateMethod(method: string | undefined): EndpointMethod {\n if (!method) {\n throw createResponseError(\"Missing method field\", 400);\n }\n\n if ((METHOD_NAMES as readonly string[]).includes(method)) {\n return method as EndpointMethod;\n }\n\n throw createResponseError(`Unsupported method '${method}'`, 400);\n}\n\nfunction serializeJsonBody(body: unknown): BodyInit {\n if (typeof body === \"string\") {\n return body;\n }\n\n if (\n body instanceof Blob ||\n body instanceof ArrayBuffer ||\n body instanceof Uint8Array\n ) {\n // Uint8Array<ArrayBufferLike> is a valid fetch body at runtime, but the\n // DOM lib's BodyInit only admits ArrayBuffer-backed views.\n return body as BodyInit;\n }\n\n if (body instanceof FormData || body instanceof URLSearchParams) {\n return body;\n }\n\n return JSON.stringify(body);\n}\n"],"mappings":";AAAA,MAAM,eAAe;CACnB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD;;;;;;;;;;;;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"}
@@ -0,0 +1,393 @@
1
+ const require_runtime = require('../../_virtual/_rolldown/runtime.cjs');
2
+ let _copilotkit_shared = require("@copilotkit/shared");
3
+ let rxjs = require("rxjs");
4
+ let _ag_ui_client = require("@ag-ui/client");
5
+
6
+ //#region src/runtime/generative-ui/generative-ui-middleware.ts
7
+ function isRecord(value) {
8
+ return typeof value === "object" && value !== null && !Array.isArray(value);
9
+ }
10
+ /**
11
+ * Builds the manifest from the generative UI envelope
12
+ * (`forwardedProps.copilotkit.ui`). The client sends the envelope, so it is
13
+ * not trusted: `readCopilotKitUIEnvelope` checks every field, and
14
+ * `envelopeToManifest` turns it into the manifest. Returns
15
+ * `undefined` (the run passes through) when:
16
+ * - there is no valid envelope;
17
+ * - the transport is "markdown" (the model writes fences, not render_ui);
18
+ * - the catalog has no components (the server cannot validate operations).
19
+ */
20
+ function readManifest(forwardedProps) {
21
+ const envelope = (0, _copilotkit_shared.readCopilotKitUIEnvelope)(forwardedProps);
22
+ if (!envelope) return void 0;
23
+ const manifest = (0, _copilotkit_shared.envelopeToManifest)(envelope);
24
+ return manifest.transport === "tool" && manifest.hasComponents ? manifest : void 0;
25
+ }
26
+ function prepareInput(input, manifest) {
27
+ const tools = (input.tools ?? []).filter((t) => t.name !== _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL);
28
+ tools.push({
29
+ name: _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL,
30
+ description: "Render or update generative UI surfaces, or call app functions, with A2UI v1.0 operations. Follow the generative UI guide in context.",
31
+ parameters: {
32
+ type: "object",
33
+ properties: {
34
+ target: {
35
+ type: "string",
36
+ enum: manifest.targets.map((t) => t.id),
37
+ description: "Where the surface is shown: \"chat\" or a named inline target."
38
+ },
39
+ operations: {
40
+ type: "array",
41
+ description: "A2UI v1.0 operations, applied in order.",
42
+ items: { type: "object" }
43
+ }
44
+ },
45
+ required: ["target", "operations"]
46
+ }
47
+ });
48
+ const context = (input.context ?? []).filter((c) => c.description !== _copilotkit_shared.GENERATIVE_UI_CONTEXT_DESCRIPTION);
49
+ context.push({
50
+ description: _copilotkit_shared.GENERATIVE_UI_CONTEXT_DESCRIPTION,
51
+ value: (0, _copilotkit_shared.buildGenerativeUIPrompt)(manifest)
52
+ });
53
+ return {
54
+ ...input,
55
+ tools,
56
+ context
57
+ };
58
+ }
59
+ /**
60
+ * Experimental. Lets an agent render CopilotKit generative UI surfaces via the
61
+ * `render_ui` tool. It applies only to runs whose generative UI envelope uses
62
+ * the "tool" transport. Each complete operation in the streamed arguments is
63
+ * validated against the catalog in the envelope and committed immediately:
64
+ * - `ACTIVITY_SNAPSHOT` for a new surface, `ACTIVITY_DELTA` for every further
65
+ * operation on it.
66
+ * - One `ACTIVITY_SNAPSHOT` of type `generative-ui-function-call` for each
67
+ * `callRendererFunction`. The client runs the function.
68
+ */
69
+ var GenerativeUIMiddleware = class extends _ag_ui_client.Middleware {
70
+ run(input, next) {
71
+ const manifest = readManifest(input.forwardedProps);
72
+ if (!manifest) return this.runNext(input, next);
73
+ return processStream(this.runNextWithState(prepareInput(input, manifest), next), manifest);
74
+ }
75
+ };
76
+ /**
77
+ * The first time a render_ui call touches an existing surface, mark it
78
+ * streaming and clear its rejection list: earlier calls' rejections were
79
+ * already reported to the model in their own tool results, and a repaired
80
+ * surface must not keep showing them. A surface created by this call starts
81
+ * with an empty list in its snapshot.
82
+ */
83
+ function beginSurfaceUpdate(state, surfaceId) {
84
+ if (state.touched.has(surfaceId)) return [];
85
+ state.touched.add(surfaceId);
86
+ return [{
87
+ op: "replace",
88
+ path: "/status",
89
+ value: "streaming"
90
+ }, {
91
+ op: "replace",
92
+ path: "/rejected",
93
+ value: []
94
+ }];
95
+ }
96
+ function processStream(source, manifest) {
97
+ return new rxjs.Observable((subscriber) => {
98
+ const entries = Object.entries(manifest.surfaces);
99
+ const surfaces = new Map(entries.filter(([, s]) => !s.status).map(([id, s]) => [id, s.target]));
100
+ const createdSurfaces = new Set(entries.filter(([, s]) => s.status !== "failed").map(([id]) => id));
101
+ const targetComponents = new Map(manifest.targets.filter((t) => t.components !== void 0).map((t) => [t.id, new Set(t.components)]));
102
+ const functionCallIds = /* @__PURE__ */ new Set();
103
+ const calls = /* @__PURE__ */ new Map();
104
+ let heldFinish = null;
105
+ const emit = (event) => subscriber.next(event);
106
+ const patch = (surfaceId, ops) => emit({
107
+ type: _ag_ui_client.EventType.ACTIVITY_DELTA,
108
+ messageId: (0, _copilotkit_shared.generativeUISurfaceMessageId)(surfaceId),
109
+ activityType: _copilotkit_shared.GENERATIVE_UI_ACTIVITY_TYPE,
110
+ patch: ops
111
+ });
112
+ const processOperation = (state, op) => {
113
+ const index = state.nextIndex++;
114
+ const reject = (reason, surfaceId) => {
115
+ const entry = {
116
+ index,
117
+ reason
118
+ };
119
+ state.rejected.push(entry);
120
+ if (surfaceId && surfaces.has(surfaceId)) patch(surfaceId, [...beginSurfaceUpdate(state, surfaceId), {
121
+ op: "add",
122
+ path: "/rejected/-",
123
+ value: entry
124
+ }]);
125
+ };
126
+ if (op === null) return reject("operation is not valid JSON");
127
+ let surfaceId;
128
+ try {
129
+ surfaceId = (0, _copilotkit_shared.getOperationSurfaceId)(op);
130
+ applyOperation(state, withCatalogId(op), surfaceId, reject);
131
+ } catch (error) {
132
+ reject(`operation could not be processed: ${error instanceof Error ? error.message : String(error)}`, surfaceId);
133
+ }
134
+ };
135
+ /**
136
+ * The model does not have to name the catalog. A createSurface keeps a
137
+ * catalogId that the envelope lists, and gets the catalog id of the run
138
+ * for any other value. The whole operation, with its inline components
139
+ * and data model, stays in the snapshot.
140
+ */
141
+ const catalogIds = manifest.catalogIds ?? [manifest.catalogId];
142
+ const withCatalogId = (op) => {
143
+ const create = op.createSurface;
144
+ if (!isRecord(create)) return op;
145
+ const catalogId = catalogIds.includes(create.catalogId) ? create.catalogId : manifest.catalogId;
146
+ return {
147
+ ...op,
148
+ createSurface: {
149
+ ...create,
150
+ catalogId
151
+ }
152
+ };
153
+ };
154
+ /**
155
+ * The components that the target of the surface takes. A createSurface
156
+ * goes to the target of the render_ui call. Every other operation goes to
157
+ * the target that the surface was created on.
158
+ */
159
+ const allowedComponentsFor = (state, op, surfaceId) => {
160
+ const target = (0, _copilotkit_shared.getOperationKind)(op) === "createSurface" ? state.target : surfaces.get(surfaceId);
161
+ const names = targetComponents.get(target);
162
+ return names && {
163
+ target,
164
+ names
165
+ };
166
+ };
167
+ const applyOperation = (state, op, surfaceId, reject) => {
168
+ const validation = (0, _copilotkit_shared.validateOperation)(op, {
169
+ manifest,
170
+ knownSurfaces: new Set(surfaces.keys()),
171
+ createdSurfaces,
172
+ functions: manifest.functions,
173
+ allowedComponents: allowedComponentsFor(state, op, surfaceId)
174
+ });
175
+ if (validation.ok === false) return reject(validation.reason, surfaceId);
176
+ const accepted = op;
177
+ if ("callRendererFunction" in accepted) return callRendererFunction(state, accepted.callRendererFunction, reject);
178
+ if ("createSurface" in accepted) return createSurface(state, surfaceId, accepted, reject);
179
+ patch(surfaceId, [...beginSurfaceUpdate(state, surfaceId), {
180
+ op: "add",
181
+ path: "/operations/-",
182
+ value: accepted
183
+ }]);
184
+ if ("deleteSurface" in accepted) surfaces.delete(surfaceId);
185
+ state.applied++;
186
+ };
187
+ const createSurface = (state, surfaceId, op, reject) => {
188
+ const { target } = state;
189
+ if (target === void 0) return reject("render_ui was called without a target");
190
+ if (!manifest.targets.some((t) => t.id === target)) return reject(`target "${target}" is not mounted`);
191
+ surfaces.set(surfaceId, target);
192
+ createdSurfaces.add(surfaceId);
193
+ const content = {
194
+ surfaceId,
195
+ target,
196
+ catalogId: "createSurface" in op && op.createSurface.catalogId || manifest.catalogId,
197
+ operations: [op],
198
+ status: "streaming",
199
+ rejected: []
200
+ };
201
+ emit({
202
+ type: _ag_ui_client.EventType.ACTIVITY_SNAPSHOT,
203
+ messageId: (0, _copilotkit_shared.generativeUISurfaceMessageId)(surfaceId),
204
+ activityType: _copilotkit_shared.GENERATIVE_UI_ACTIVITY_TYPE,
205
+ content,
206
+ replace: true
207
+ });
208
+ state.touched.add(surfaceId);
209
+ state.applied++;
210
+ };
211
+ /**
212
+ * Sends one function call to the client, which runs it. A function call
213
+ * needs no target and no surface. Each `functionCallId` runs once.
214
+ */
215
+ const callRendererFunction = (state, content, reject) => {
216
+ const { functionCallId } = content;
217
+ if (functionCallIds.has(functionCallId)) return reject(`functionCallId "${functionCallId}" was used before; use a new functionCallId`);
218
+ functionCallIds.add(functionCallId);
219
+ emit({
220
+ type: _ag_ui_client.EventType.ACTIVITY_SNAPSHOT,
221
+ messageId: (0, _copilotkit_shared.generativeUIFunctionCallMessageId)(functionCallId),
222
+ activityType: _copilotkit_shared.GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE,
223
+ content: {
224
+ functionCallId,
225
+ callFunction: content.callFunction
226
+ },
227
+ replace: true
228
+ });
229
+ state.calls++;
230
+ };
231
+ /** Same buffering rule as streamed ops: hold them until the target is known. */
232
+ const acceptOperation = (state, op) => {
233
+ if (state.target === void 0) state.buffered.push(op);
234
+ else processOperation(state, op);
235
+ };
236
+ /**
237
+ * The streaming parser found no operations at all. Models sometimes send
238
+ * `operations` as a JSON-encoded string; recover those from the complete
239
+ * arguments. Anything still unusable leaves the call with zero operations,
240
+ * which the tool result reports as an error.
241
+ */
242
+ const recoverOperations = (state) => {
243
+ let args;
244
+ try {
245
+ args = JSON.parse(state.stream.text);
246
+ } catch {
247
+ return;
248
+ }
249
+ if (!isRecord(args)) return;
250
+ if (state.target === void 0 && typeof args.target === "string") state.target = args.target;
251
+ let operations = args.operations;
252
+ if (typeof operations === "string") try {
253
+ operations = JSON.parse(operations);
254
+ } catch {
255
+ return;
256
+ }
257
+ if (!Array.isArray(operations)) return;
258
+ for (const op of operations) acceptOperation(state, isRecord(op) ? op : null);
259
+ };
260
+ const finishCall = (state) => {
261
+ if (state.finished) return;
262
+ state.finished = true;
263
+ if (state.nextIndex === 0 && state.buffered.length === 0) recoverOperations(state);
264
+ if (state.target === void 0) {
265
+ const buffered = state.buffered;
266
+ state.buffered = [];
267
+ for (const op of buffered) {
268
+ if ((0, _copilotkit_shared.getOperationKind)(op) === "callRendererFunction") {
269
+ processOperation(state, op);
270
+ continue;
271
+ }
272
+ state.rejected.push({
273
+ index: state.nextIndex++,
274
+ reason: "render_ui was called without a target"
275
+ });
276
+ }
277
+ }
278
+ if (state.stream.hasIncompleteOperation) state.rejected.push({
279
+ index: state.nextIndex++,
280
+ reason: "operation was truncated"
281
+ });
282
+ for (const id of state.touched) patch(id, [{
283
+ op: "replace",
284
+ path: "/status",
285
+ value: "ready"
286
+ }]);
287
+ };
288
+ const flushFinish = () => {
289
+ if (heldFinish) {
290
+ emit(heldFinish.event);
291
+ heldFinish = null;
292
+ }
293
+ };
294
+ const handleEvent = ({ event, messages }) => {
295
+ flushFinish();
296
+ if (event.type === _ag_ui_client.EventType.RUN_FINISHED) {
297
+ heldFinish = {
298
+ event,
299
+ messages
300
+ };
301
+ return;
302
+ }
303
+ emit(event);
304
+ if (event.type === _ag_ui_client.EventType.TOOL_CALL_START) {
305
+ const start = event;
306
+ if (start.toolCallName === _copilotkit_shared.GENERATIVE_UI_RENDER_TOOL) calls.set(start.toolCallId, {
307
+ stream: new _copilotkit_shared.RenderUIArgsStream(),
308
+ buffered: [],
309
+ nextIndex: 0,
310
+ applied: 0,
311
+ calls: 0,
312
+ rejected: [],
313
+ touched: /* @__PURE__ */ new Set(),
314
+ finished: false
315
+ });
316
+ } else if (event.type === _ag_ui_client.EventType.TOOL_CALL_ARGS) {
317
+ const args = event;
318
+ const state = calls.get(args.toolCallId);
319
+ if (!state || state.finished) return;
320
+ const { target, newOperations } = state.stream.push(args.delta);
321
+ if (target !== void 0 && state.target === void 0) {
322
+ state.target = target;
323
+ const buffered = state.buffered;
324
+ state.buffered = [];
325
+ for (const op of buffered) processOperation(state, op);
326
+ }
327
+ for (const op of newOperations) acceptOperation(state, op);
328
+ } else if (event.type === _ag_ui_client.EventType.TOOL_CALL_END) {
329
+ const state = calls.get(event.toolCallId);
330
+ if (state) finishCall(state);
331
+ }
332
+ };
333
+ const completeRun = () => {
334
+ for (const state of calls.values()) finishCall(state);
335
+ if (heldFinish) {
336
+ const answered = new Set(heldFinish.messages.filter((m) => m.role === "tool").map((m) => m.toolCallId));
337
+ for (const [toolCallId, state] of calls) {
338
+ if (answered.has(toolCallId)) continue;
339
+ const nothingParsed = state.applied === 0 && state.calls === 0 && state.rejected.length === 0;
340
+ emit({
341
+ type: _ag_ui_client.EventType.TOOL_CALL_RESULT,
342
+ messageId: (0, _copilotkit_shared.randomUUID)(),
343
+ toolCallId,
344
+ content: JSON.stringify(nothingParsed ? {
345
+ status: "error",
346
+ applied: 0,
347
+ calls: 0,
348
+ rejected: [],
349
+ reason: "operations must be a JSON array of A2UI operation objects; nothing was rendered"
350
+ } : {
351
+ status: "rendered",
352
+ applied: state.applied,
353
+ calls: state.calls,
354
+ rejected: state.rejected
355
+ })
356
+ });
357
+ }
358
+ flushFinish();
359
+ }
360
+ subscriber.complete();
361
+ };
362
+ let failed = false;
363
+ const subscription = source.subscribe({
364
+ next: (item) => {
365
+ if (failed) return;
366
+ try {
367
+ handleEvent(item);
368
+ } catch (error) {
369
+ failed = true;
370
+ subscriber.error(error);
371
+ }
372
+ },
373
+ error: (error) => {
374
+ flushFinish();
375
+ subscriber.error(error);
376
+ },
377
+ complete: () => {
378
+ if (failed) return;
379
+ try {
380
+ completeRun();
381
+ } catch (error) {
382
+ failed = true;
383
+ subscriber.error(error);
384
+ }
385
+ }
386
+ });
387
+ return () => subscription.unsubscribe();
388
+ });
389
+ }
390
+
391
+ //#endregion
392
+ exports.GenerativeUIMiddleware = GenerativeUIMiddleware;
393
+ //# sourceMappingURL=generative-ui-middleware.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generative-ui-middleware.cjs","names":["GENERATIVE_UI_RENDER_TOOL","GENERATIVE_UI_CONTEXT_DESCRIPTION","Middleware","Observable","EventType","GENERATIVE_UI_ACTIVITY_TYPE","GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE","RenderUIArgsStream"],"sources":["../../../src/runtime/generative-ui/generative-ui-middleware.ts"],"sourcesContent":["import { EventType, Middleware } from \"@ag-ui/client\";\nimport type {\n AbstractAgent,\n BaseEvent,\n Message,\n RunAgentInput,\n ToolCallArgsEvent,\n ToolCallEndEvent,\n ToolCallStartEvent,\n} from \"@ag-ui/client\";\nimport { Observable } from \"rxjs\";\nimport {\n GENERATIVE_UI_ACTIVITY_TYPE,\n GENERATIVE_UI_CONTEXT_DESCRIPTION,\n GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE,\n GENERATIVE_UI_RENDER_TOOL,\n RenderUIArgsStream,\n buildGenerativeUIPrompt,\n envelopeToManifest,\n generativeUIFunctionCallMessageId,\n generativeUISurfaceMessageId,\n getOperationKind,\n getOperationSurfaceId,\n randomUUID,\n readCopilotKitUIEnvelope,\n validateOperation,\n} from \"@copilotkit/shared\";\nimport type {\n A2UIOperation,\n GenerativeUIFunctionCallContent,\n GenerativeUIManifest,\n GenerativeUIRejectedOperation,\n GenerativeUISurfaceContent,\n} from \"@copilotkit/shared\";\n\ntype EventWithState = { event: BaseEvent; messages: Message[] };\ntype JsonPatchOperation = {\n op: \"add\" | \"replace\";\n path: string;\n value: unknown;\n};\n\ninterface RenderCallState {\n stream: RenderUIArgsStream;\n target?: string;\n buffered: Array<Record<string, unknown> | null>;\n nextIndex: number;\n /** Accepted surface operations. */\n applied: number;\n /** Accepted `callRendererFunction` operations. */\n calls: number;\n rejected: GenerativeUIRejectedOperation[];\n touched: Set<string>;\n finished: boolean;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === \"object\" && value !== null && !Array.isArray(value);\n}\n\n/**\n * Builds the manifest from the generative UI envelope\n * (`forwardedProps.copilotkit.ui`). The client sends the envelope, so it is\n * not trusted: `readCopilotKitUIEnvelope` checks every field, and\n * `envelopeToManifest` turns it into the manifest. Returns\n * `undefined` (the run passes through) when:\n * - there is no valid envelope;\n * - the transport is \"markdown\" (the model writes fences, not render_ui);\n * - the catalog has no components (the server cannot validate operations).\n */\nfunction readManifest(forwardedProps: unknown) {\n const envelope = readCopilotKitUIEnvelope(forwardedProps);\n if (!envelope) return undefined;\n const manifest = envelopeToManifest(envelope);\n const isToolRun = manifest.transport === \"tool\" && manifest.hasComponents;\n return isToolRun ? manifest : undefined;\n}\n\nfunction prepareInput(input: RunAgentInput, manifest: GenerativeUIManifest) {\n const tools = (input.tools ?? []).filter(\n (t) => t.name !== GENERATIVE_UI_RENDER_TOOL,\n );\n tools.push({\n name: GENERATIVE_UI_RENDER_TOOL,\n description:\n \"Render or update generative UI surfaces, or call app functions, with A2UI v1.0 operations. Follow the generative UI guide in context.\",\n parameters: {\n type: \"object\",\n properties: {\n target: {\n type: \"string\",\n enum: manifest.targets.map((t) => t.id),\n description:\n 'Where the surface is shown: \"chat\" or a named inline target.',\n },\n operations: {\n type: \"array\",\n description: \"A2UI v1.0 operations, applied in order.\",\n items: { type: \"object\" },\n },\n },\n required: [\"target\", \"operations\"],\n },\n });\n const context = (input.context ?? []).filter(\n (c) => c.description !== GENERATIVE_UI_CONTEXT_DESCRIPTION,\n );\n context.push({\n description: GENERATIVE_UI_CONTEXT_DESCRIPTION,\n value: buildGenerativeUIPrompt(manifest),\n });\n return { ...input, tools, context };\n}\n\n/**\n * Experimental. Lets an agent render CopilotKit generative UI surfaces via the\n * `render_ui` tool. It applies only to runs whose generative UI envelope uses\n * the \"tool\" transport. Each complete operation in the streamed arguments is\n * validated against the catalog in the envelope and committed immediately:\n * - `ACTIVITY_SNAPSHOT` for a new surface, `ACTIVITY_DELTA` for every further\n * operation on it.\n * - One `ACTIVITY_SNAPSHOT` of type `generative-ui-function-call` for each\n * `callRendererFunction`. The client runs the function.\n */\nexport class GenerativeUIMiddleware extends Middleware {\n run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent> {\n const manifest = readManifest(input.forwardedProps);\n if (!manifest) return this.runNext(input, next);\n return processStream(\n this.runNextWithState(\n prepareInput(input, manifest),\n next,\n ) as Observable<EventWithState>,\n manifest,\n );\n }\n}\n\n/**\n * The first time a render_ui call touches an existing surface, mark it\n * streaming and clear its rejection list: earlier calls' rejections were\n * already reported to the model in their own tool results, and a repaired\n * surface must not keep showing them. A surface created by this call starts\n * with an empty list in its snapshot.\n */\nfunction beginSurfaceUpdate(\n state: RenderCallState,\n surfaceId: string,\n): JsonPatchOperation[] {\n if (state.touched.has(surfaceId)) return [];\n state.touched.add(surfaceId);\n return [\n { op: \"replace\", path: \"/status\", value: \"streaming\" },\n { op: \"replace\", path: \"/rejected\", value: [] },\n ];\n}\n\nfunction processStream(\n source: Observable<EventWithState>,\n manifest: GenerativeUIManifest,\n) {\n return new Observable<BaseEvent>((subscriber) => {\n const entries = Object.entries(manifest.surfaces);\n // Only live surfaces take updates. A surface that the client deleted, or\n // that was never created, has a `status`.\n const surfaces = new Map<string, string>(\n entries.filter(([, s]) => !s.status).map(([id, s]) => [id, s.target]),\n );\n // A surface id is unique for the life of the page. Keep the ids that were\n // created, also after deleteSurface (in this run or an earlier one), so a\n // second createSurface is rejected. A failed create can be sent again.\n const createdSurfaces = new Set(\n entries.filter(([, s]) => s.status !== \"failed\").map(([id]) => id),\n );\n // The targets that limit their components, by target id.\n const targetComponents = new Map(\n manifest.targets\n .filter((t) => t.components !== undefined)\n .map((t) => [t.id, new Set(t.components)]),\n );\n const functionCallIds = new Set<string>();\n const calls = new Map<string, RenderCallState>();\n let heldFinish: EventWithState | null = null;\n\n const emit = (event: BaseEvent) => subscriber.next(event);\n const patch = (surfaceId: string, ops: JsonPatchOperation[]) =>\n emit({\n type: EventType.ACTIVITY_DELTA,\n messageId: generativeUISurfaceMessageId(surfaceId),\n activityType: GENERATIVE_UI_ACTIVITY_TYPE,\n patch: ops,\n });\n\n const processOperation = (\n state: RenderCallState,\n op: Record<string, unknown> | null,\n ) => {\n const index = state.nextIndex++;\n const reject = (reason: string, surfaceId?: string) => {\n const entry = { index, reason };\n state.rejected.push(entry);\n if (surfaceId && surfaces.has(surfaceId)) {\n patch(surfaceId, [\n ...beginSurfaceUpdate(state, surfaceId),\n { op: \"add\", path: \"/rejected/-\", value: entry },\n ]);\n }\n };\n if (op === null) return reject(\"operation is not valid JSON\");\n let surfaceId: string | undefined;\n try {\n surfaceId = getOperationSurfaceId(op);\n applyOperation(state, withCatalogId(op), surfaceId, reject);\n } catch (error) {\n // Never let one bad operation take down the run: report it to the\n // model through the tool result instead.\n reject(\n `operation could not be processed: ${error instanceof Error ? error.message : String(error)}`,\n surfaceId,\n );\n }\n };\n\n /**\n * The model does not have to name the catalog. A createSurface keeps a\n * catalogId that the envelope lists, and gets the catalog id of the run\n * for any other value. The whole operation, with its inline components\n * and data model, stays in the snapshot.\n */\n const catalogIds = manifest.catalogIds ?? [manifest.catalogId];\n const withCatalogId = (op: Record<string, unknown>) => {\n const create = op.createSurface;\n if (!isRecord(create)) return op;\n const catalogId = catalogIds.includes(create.catalogId as string)\n ? create.catalogId\n : manifest.catalogId;\n return { ...op, createSurface: { ...create, catalogId } };\n };\n\n /**\n * The components that the target of the surface takes. A createSurface\n * goes to the target of the render_ui call. Every other operation goes to\n * the target that the surface was created on.\n */\n const allowedComponentsFor = (\n state: RenderCallState,\n op: Record<string, unknown>,\n surfaceId: string | undefined,\n ) => {\n const target =\n getOperationKind(op) === \"createSurface\"\n ? state.target\n : surfaces.get(surfaceId);\n const names = targetComponents.get(target);\n return names && { target, names };\n };\n\n const applyOperation = (\n state: RenderCallState,\n op: Record<string, unknown>,\n surfaceId: string | undefined,\n reject: (reason: string, surfaceId?: string) => void,\n ) => {\n const validation = validateOperation(op, {\n manifest,\n knownSurfaces: new Set(surfaces.keys()),\n createdSurfaces,\n functions: manifest.functions,\n allowedComponents: allowedComponentsFor(state, op, surfaceId),\n });\n // `=== false` (not `!ok`): runtime is compiled non-strict, where `!ok`\n // does not narrow the discriminated union.\n if (validation.ok === false) return reject(validation.reason, surfaceId);\n // validateOperation checked the shape of the operation.\n const accepted = op as A2UIOperation;\n if (\"callRendererFunction\" in accepted) {\n return callRendererFunction(\n state,\n accepted.callRendererFunction,\n reject,\n );\n }\n if (\"createSurface\" in accepted) {\n return createSurface(state, surfaceId, accepted, reject);\n }\n patch(surfaceId, [\n ...beginSurfaceUpdate(state, surfaceId),\n { op: \"add\", path: \"/operations/-\", value: accepted },\n ]);\n if (\"deleteSurface\" in accepted) surfaces.delete(surfaceId);\n state.applied++;\n };\n\n const createSurface = (\n state: RenderCallState,\n surfaceId: string,\n op: A2UIOperation,\n reject: (reason: string) => void,\n ) => {\n const { target } = state;\n if (target === undefined) {\n return reject(\"render_ui was called without a target\");\n }\n if (!manifest.targets.some((t) => t.id === target)) {\n return reject(`target \"${target}\" is not mounted`);\n }\n surfaces.set(surfaceId, target);\n createdSurfaces.add(surfaceId);\n const content: GenerativeUISurfaceContent = {\n surfaceId,\n target,\n catalogId:\n (\"createSurface\" in op && op.createSurface.catalogId) ||\n manifest.catalogId,\n operations: [op],\n status: \"streaming\",\n rejected: [],\n };\n emit({\n type: EventType.ACTIVITY_SNAPSHOT,\n messageId: generativeUISurfaceMessageId(surfaceId),\n activityType: GENERATIVE_UI_ACTIVITY_TYPE,\n content,\n replace: true,\n });\n state.touched.add(surfaceId);\n state.applied++;\n };\n\n /**\n * Sends one function call to the client, which runs it. A function call\n * needs no target and no surface. Each `functionCallId` runs once.\n */\n const callRendererFunction = (\n state: RenderCallState,\n content: GenerativeUIFunctionCallContent,\n reject: (reason: string) => void,\n ) => {\n const { functionCallId } = content;\n if (functionCallIds.has(functionCallId)) {\n return reject(\n `functionCallId \"${functionCallId}\" was used before; use a new functionCallId`,\n );\n }\n functionCallIds.add(functionCallId);\n emit({\n type: EventType.ACTIVITY_SNAPSHOT,\n messageId: generativeUIFunctionCallMessageId(functionCallId),\n activityType: GENERATIVE_UI_FUNCTION_CALL_ACTIVITY_TYPE,\n content: {\n functionCallId,\n callFunction: content.callFunction,\n } satisfies GenerativeUIFunctionCallContent,\n replace: true,\n });\n state.calls++;\n };\n\n /** Same buffering rule as streamed ops: hold them until the target is known. */\n const acceptOperation = (\n state: RenderCallState,\n op: Record<string, unknown> | null,\n ) => {\n if (state.target === undefined) state.buffered.push(op);\n else processOperation(state, op);\n };\n\n /**\n * The streaming parser found no operations at all. Models sometimes send\n * `operations` as a JSON-encoded string; recover those from the complete\n * arguments. Anything still unusable leaves the call with zero operations,\n * which the tool result reports as an error.\n */\n const recoverOperations = (state: RenderCallState) => {\n let args: unknown;\n try {\n args = JSON.parse(state.stream.text);\n } catch {\n return;\n }\n if (!isRecord(args)) return;\n if (state.target === undefined && typeof args.target === \"string\") {\n state.target = args.target;\n }\n let operations = args.operations;\n if (typeof operations === \"string\") {\n try {\n operations = JSON.parse(operations);\n } catch {\n return;\n }\n }\n if (!Array.isArray(operations)) return;\n for (const op of operations)\n acceptOperation(state, isRecord(op) ? op : null);\n };\n\n const finishCall = (state: RenderCallState) => {\n if (state.finished) return;\n state.finished = true;\n if (state.nextIndex === 0 && state.buffered.length === 0)\n recoverOperations(state);\n if (state.target === undefined) {\n // A function call needs no target, so it still runs. Every other\n // operation is rejected.\n const buffered = state.buffered;\n state.buffered = [];\n for (const op of buffered) {\n if (getOperationKind(op) === \"callRendererFunction\") {\n processOperation(state, op);\n continue;\n }\n state.rejected.push({\n index: state.nextIndex++,\n reason: \"render_ui was called without a target\",\n });\n }\n }\n if (state.stream.hasIncompleteOperation) {\n // The arguments ended inside an element (for example the model hit its\n // output limit): report it instead of silently dropping it.\n state.rejected.push({\n index: state.nextIndex++,\n reason: \"operation was truncated\",\n });\n }\n for (const id of state.touched) {\n patch(id, [{ op: \"replace\", path: \"/status\", value: \"ready\" }]);\n }\n };\n\n const flushFinish = () => {\n if (heldFinish) {\n emit(heldFinish.event);\n heldFinish = null;\n }\n };\n\n const handleEvent = ({ event, messages }: EventWithState) => {\n flushFinish();\n if (event.type === EventType.RUN_FINISHED) {\n heldFinish = { event, messages };\n return;\n }\n emit(event);\n if (event.type === EventType.TOOL_CALL_START) {\n const start = event as ToolCallStartEvent;\n if (start.toolCallName === GENERATIVE_UI_RENDER_TOOL) {\n calls.set(start.toolCallId, {\n stream: new RenderUIArgsStream(),\n buffered: [],\n nextIndex: 0,\n applied: 0,\n calls: 0,\n rejected: [],\n touched: new Set(),\n finished: false,\n });\n }\n } else if (event.type === EventType.TOOL_CALL_ARGS) {\n const args = event as ToolCallArgsEvent;\n const state = calls.get(args.toolCallId);\n if (!state || state.finished) return;\n const { target, newOperations } = state.stream.push(args.delta);\n if (target !== undefined && state.target === undefined) {\n state.target = target;\n const buffered = state.buffered;\n state.buffered = [];\n for (const op of buffered) processOperation(state, op);\n }\n for (const op of newOperations) acceptOperation(state, op);\n } else if (event.type === EventType.TOOL_CALL_END) {\n const state = calls.get((event as ToolCallEndEvent).toolCallId);\n if (state) finishCall(state);\n }\n };\n\n const completeRun = () => {\n for (const state of calls.values()) finishCall(state);\n if (heldFinish) {\n const answered = new Set(\n heldFinish.messages\n .filter((m) => m.role === \"tool\")\n .map((m) => (m as { toolCallId: string }).toolCallId),\n );\n for (const [toolCallId, state] of calls) {\n if (answered.has(toolCallId)) continue;\n const nothingParsed =\n state.applied === 0 &&\n state.calls === 0 &&\n state.rejected.length === 0;\n // `applied` counts the surface operations, `calls` the function calls.\n emit({\n type: EventType.TOOL_CALL_RESULT,\n messageId: randomUUID(),\n toolCallId,\n content: JSON.stringify(\n nothingParsed\n ? {\n status: \"error\",\n applied: 0,\n calls: 0,\n rejected: [],\n reason:\n \"operations must be a JSON array of A2UI operation objects; nothing was rendered\",\n }\n : {\n status: \"rendered\",\n applied: state.applied,\n calls: state.calls,\n rejected: state.rejected,\n },\n ),\n });\n }\n flushFinish();\n }\n subscriber.complete();\n };\n\n let failed = false;\n const subscription = source.subscribe({\n next: (item) => {\n if (failed) return;\n try {\n handleEvent(item);\n } catch (error) {\n // Anything unexpected must reach the consumer as an error instead of\n // escaping this callback, where RxJS would rethrow it asynchronously\n // as an uncaught exception.\n failed = true;\n subscriber.error(error);\n }\n },\n error: (error) => {\n flushFinish();\n subscriber.error(error);\n },\n complete: () => {\n if (failed) return;\n try {\n completeRun();\n } catch (error) {\n failed = true;\n subscriber.error(error);\n }\n },\n });\n return () => subscription.unsubscribe();\n });\n}\n"],"mappings":";;;;;;AAwDA,SAAS,SAAS,OAAkD;AAClE,QAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,CAAC,MAAM,QAAQ,MAAM;;;;;;;;;;;;AAa7E,SAAS,aAAa,gBAAyB;CAC7C,MAAM,4DAAoC,eAAe;AACzD,KAAI,CAAC,SAAU,QAAO;CACtB,MAAM,sDAA8B,SAAS;AAE7C,QADkB,SAAS,cAAc,UAAU,SAAS,gBACzC,WAAW;;AAGhC,SAAS,aAAa,OAAsB,UAAgC;CAC1E,MAAM,SAAS,MAAM,SAAS,EAAE,EAAE,QAC/B,MAAM,EAAE,SAASA,6CACnB;AACD,OAAM,KAAK;EACT,MAAMA;EACN,aACE;EACF,YAAY;GACV,MAAM;GACN,YAAY;IACV,QAAQ;KACN,MAAM;KACN,MAAM,SAAS,QAAQ,KAAK,MAAM,EAAE,GAAG;KACvC,aACE;KACH;IACD,YAAY;KACV,MAAM;KACN,aAAa;KACb,OAAO,EAAE,MAAM,UAAU;KAC1B;IACF;GACD,UAAU,CAAC,UAAU,aAAa;GACnC;EACF,CAAC;CACF,MAAM,WAAW,MAAM,WAAW,EAAE,EAAE,QACnC,MAAM,EAAE,gBAAgBC,qDAC1B;AACD,SAAQ,KAAK;EACX,aAAaA;EACb,uDAA+B,SAAS;EACzC,CAAC;AACF,QAAO;EAAE,GAAG;EAAO;EAAO;EAAS;;;;;;;;;;;;AAarC,IAAa,yBAAb,cAA4CC,yBAAW;CACrD,IAAI,OAAsB,MAA4C;EACpE,MAAM,WAAW,aAAa,MAAM,eAAe;AACnD,MAAI,CAAC,SAAU,QAAO,KAAK,QAAQ,OAAO,KAAK;AAC/C,SAAO,cACL,KAAK,iBACH,aAAa,OAAO,SAAS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,CAAC;;AAEJ,iBAAa;;AAEf,cAAW,UAAU;;EAGvB,IAAI,SAAS;EACb,MAAM,eAAe,OAAO,UAAU;GACpC,OAAO,SAAS;AACd,QAAI,OAAQ;AACZ,QAAI;AACF,iBAAY,KAAK;aACV,OAAO;AAId,cAAS;AACT,gBAAW,MAAM,MAAM;;;GAG3B,QAAQ,UAAU;AAChB,iBAAa;AACb,eAAW,MAAM,MAAM;;GAEzB,gBAAgB;AACd,QAAI,OAAQ;AACZ,QAAI;AACF,kBAAa;aACN,OAAO;AACd,cAAS;AACT,gBAAW,MAAM,MAAM;;;GAG5B,CAAC;AACF,eAAa,aAAa,aAAa;GACvC"}
@@ -0,0 +1,20 @@
1
+ import { AbstractAgent, BaseEvent, Middleware, RunAgentInput } from "@ag-ui/client";
2
+ import { Observable } from "rxjs";
3
+
4
+ //#region src/runtime/generative-ui/generative-ui-middleware.d.ts
5
+ /**
6
+ * Experimental. Lets an agent render CopilotKit generative UI surfaces via the
7
+ * `render_ui` tool. It applies only to runs whose generative UI envelope uses
8
+ * the "tool" transport. Each complete operation in the streamed arguments is
9
+ * validated against the catalog in the envelope and committed immediately:
10
+ * - `ACTIVITY_SNAPSHOT` for a new surface, `ACTIVITY_DELTA` for every further
11
+ * operation on it.
12
+ * - One `ACTIVITY_SNAPSHOT` of type `generative-ui-function-call` for each
13
+ * `callRendererFunction`. The client runs the function.
14
+ */
15
+ declare class GenerativeUIMiddleware extends Middleware {
16
+ run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
17
+ }
18
+ //#endregion
19
+ export { GenerativeUIMiddleware };
20
+ //# sourceMappingURL=generative-ui-middleware.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generative-ui-middleware.d.cts","names":[],"sources":["../../../src/runtime/generative-ui/generative-ui-middleware.ts"],"mappings":";;;;;AA4HA;;;;;;;;;cAAa,sBAAA,SAA+B,UAAA;EAC1C,GAAA,CAAI,KAAA,EAAO,aAAA,EAAe,IAAA,EAAM,aAAA,GAAgB,UAAA,CAAW,SAAA;AAAA"}
@@ -0,0 +1,20 @@
1
+ import { Observable } from "rxjs";
2
+ import { AbstractAgent, BaseEvent, Middleware, RunAgentInput } from "@ag-ui/client";
3
+
4
+ //#region src/runtime/generative-ui/generative-ui-middleware.d.ts
5
+ /**
6
+ * Experimental. Lets an agent render CopilotKit generative UI surfaces via the
7
+ * `render_ui` tool. It applies only to runs whose generative UI envelope uses
8
+ * the "tool" transport. Each complete operation in the streamed arguments is
9
+ * validated against the catalog in the envelope and committed immediately:
10
+ * - `ACTIVITY_SNAPSHOT` for a new surface, `ACTIVITY_DELTA` for every further
11
+ * operation on it.
12
+ * - One `ACTIVITY_SNAPSHOT` of type `generative-ui-function-call` for each
13
+ * `callRendererFunction`. The client runs the function.
14
+ */
15
+ declare class GenerativeUIMiddleware extends Middleware {
16
+ run(input: RunAgentInput, next: AbstractAgent): Observable<BaseEvent>;
17
+ }
18
+ //#endregion
19
+ export { GenerativeUIMiddleware };
20
+ //# sourceMappingURL=generative-ui-middleware.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generative-ui-middleware.d.mts","names":[],"sources":["../../../src/runtime/generative-ui/generative-ui-middleware.ts"],"mappings":";;;;;AA4HA;;;;;;;;;cAAa,sBAAA,SAA+B,UAAA;EAC1C,GAAA,CAAI,KAAA,EAAO,aAAA,EAAe,IAAA,EAAM,aAAA,GAAgB,UAAA,CAAW,SAAA;AAAA"}