@copilotkit/runtime 1.55.0-next.8 → 1.55.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 (345) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/agent/index.cjs +101 -12
  3. package/dist/agent/index.cjs.map +1 -1
  4. package/dist/agent/index.d.cts.map +1 -1
  5. package/dist/agent/index.d.mts.map +1 -1
  6. package/dist/agent/index.mjs +102 -13
  7. package/dist/agent/index.mjs.map +1 -1
  8. package/dist/lib/runtime/agent-integrations/langgraph/agent.cjs.map +1 -1
  9. package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts +4 -841
  10. package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts.map +1 -1
  11. package/dist/lib/runtime/agent-integrations/langgraph/agent.d.mts +4 -841
  12. package/dist/lib/runtime/agent-integrations/langgraph/agent.d.mts.map +1 -1
  13. package/dist/lib/runtime/agent-integrations/langgraph/agent.mjs.map +1 -1
  14. package/dist/lib/runtime/copilot-runtime.cjs +3 -2
  15. package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
  16. package/dist/lib/runtime/copilot-runtime.d.cts +1 -1
  17. package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
  18. package/dist/lib/runtime/copilot-runtime.d.mts +3 -3
  19. package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
  20. package/dist/lib/runtime/copilot-runtime.mjs +3 -2
  21. package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
  22. package/dist/package.cjs +70 -47
  23. package/dist/package.mjs +70 -47
  24. package/dist/v2/express.cjs +8 -0
  25. package/dist/v2/express.d.cts +5 -0
  26. package/dist/v2/express.d.mts +5 -0
  27. package/dist/v2/express.mjs +5 -0
  28. package/dist/v2/hono.cjs +9 -0
  29. package/dist/v2/hono.d.cts +5 -0
  30. package/dist/v2/hono.d.mts +5 -0
  31. package/dist/v2/hono.mjs +5 -0
  32. package/dist/v2/index.cjs +8 -3
  33. package/dist/v2/index.d.cts +8 -5
  34. package/dist/v2/index.d.mts +8 -5
  35. package/dist/v2/index.mjs +5 -4
  36. package/dist/v2/node.cjs +8 -0
  37. package/dist/v2/node.d.cts +5 -0
  38. package/dist/v2/node.d.mts +5 -0
  39. package/dist/v2/node.mjs +5 -0
  40. package/dist/v2/runtime/core/fetch-cors.cjs +72 -0
  41. package/dist/v2/runtime/core/fetch-cors.cjs.map +1 -0
  42. package/dist/v2/runtime/core/fetch-cors.d.cts +20 -0
  43. package/dist/v2/runtime/core/fetch-cors.d.cts.map +1 -0
  44. package/dist/v2/runtime/core/fetch-cors.d.mts +20 -0
  45. package/dist/v2/runtime/core/fetch-cors.d.mts.map +1 -0
  46. package/dist/v2/runtime/core/fetch-cors.mjs +70 -0
  47. package/dist/v2/runtime/core/fetch-cors.mjs.map +1 -0
  48. package/dist/v2/runtime/core/fetch-handler.cjs +232 -0
  49. package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -0
  50. package/dist/v2/runtime/core/fetch-handler.d.cts +40 -0
  51. package/dist/v2/runtime/core/fetch-handler.d.cts.map +1 -0
  52. package/dist/v2/runtime/core/fetch-handler.d.mts +40 -0
  53. package/dist/v2/runtime/core/fetch-handler.d.mts.map +1 -0
  54. package/dist/v2/runtime/core/fetch-handler.mjs +231 -0
  55. package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -0
  56. package/dist/v2/runtime/core/fetch-router.cjs +68 -0
  57. package/dist/v2/runtime/core/fetch-router.cjs.map +1 -0
  58. package/dist/v2/runtime/core/fetch-router.mjs +67 -0
  59. package/dist/v2/runtime/core/fetch-router.mjs.map +1 -0
  60. package/dist/v2/runtime/core/hooks.cjs +29 -0
  61. package/dist/v2/runtime/core/hooks.cjs.map +1 -0
  62. package/dist/v2/runtime/core/hooks.d.cts +78 -0
  63. package/dist/v2/runtime/core/hooks.d.cts.map +1 -0
  64. package/dist/v2/runtime/core/hooks.d.mts +78 -0
  65. package/dist/v2/runtime/core/hooks.d.mts.map +1 -0
  66. package/dist/v2/runtime/core/hooks.mjs +25 -0
  67. package/dist/v2/runtime/core/hooks.mjs.map +1 -0
  68. package/dist/v2/runtime/{middleware-sse-parser.cjs → core/middleware-sse-parser.cjs} +2 -2
  69. package/dist/v2/runtime/core/middleware-sse-parser.cjs.map +1 -0
  70. package/dist/v2/runtime/{middleware-sse-parser.d.cts → core/middleware-sse-parser.d.cts} +1 -1
  71. package/dist/v2/runtime/core/middleware-sse-parser.d.cts.map +1 -0
  72. package/dist/v2/runtime/{middleware-sse-parser.d.mts → core/middleware-sse-parser.d.mts} +1 -1
  73. package/dist/v2/runtime/core/middleware-sse-parser.d.mts.map +1 -0
  74. package/dist/v2/runtime/{middleware-sse-parser.mjs → core/middleware-sse-parser.mjs} +1 -1
  75. package/dist/v2/runtime/core/middleware-sse-parser.mjs.map +1 -0
  76. package/dist/v2/runtime/{middleware.cjs → core/middleware.cjs} +2 -2
  77. package/dist/v2/runtime/core/middleware.cjs.map +1 -0
  78. package/dist/v2/runtime/{middleware.d.cts → core/middleware.d.cts} +1 -1
  79. package/dist/v2/runtime/core/middleware.d.cts.map +1 -0
  80. package/dist/v2/runtime/{middleware.d.mts → core/middleware.d.mts} +1 -1
  81. package/dist/v2/runtime/core/middleware.d.mts.map +1 -0
  82. package/dist/v2/runtime/{middleware.mjs → core/middleware.mjs} +1 -1
  83. package/dist/v2/runtime/core/middleware.mjs.map +1 -0
  84. package/dist/v2/runtime/{runtime.cjs → core/runtime.cjs} +35 -10
  85. package/dist/v2/runtime/core/runtime.cjs.map +1 -0
  86. package/dist/v2/runtime/{runtime.d.cts → core/runtime.d.cts} +41 -7
  87. package/dist/v2/runtime/core/runtime.d.cts.map +1 -0
  88. package/dist/v2/runtime/{runtime.d.mts → core/runtime.d.mts} +42 -8
  89. package/dist/v2/runtime/core/runtime.d.mts.map +1 -0
  90. package/dist/v2/runtime/{runtime.mjs → core/runtime.mjs} +36 -11
  91. package/dist/v2/runtime/core/runtime.mjs.map +1 -0
  92. package/dist/v2/runtime/endpoints/express-fetch-bridge.cjs +83 -0
  93. package/dist/v2/runtime/endpoints/express-fetch-bridge.cjs.map +1 -0
  94. package/dist/v2/runtime/endpoints/express-fetch-bridge.mjs +82 -0
  95. package/dist/v2/runtime/endpoints/express-fetch-bridge.mjs.map +1 -0
  96. package/dist/v2/runtime/endpoints/express-single.cjs +35 -181
  97. package/dist/v2/runtime/endpoints/express-single.cjs.map +1 -1
  98. package/dist/v2/runtime/endpoints/express-single.d.cts +35 -2
  99. package/dist/v2/runtime/endpoints/express-single.d.cts.map +1 -1
  100. package/dist/v2/runtime/endpoints/express-single.d.mts +35 -2
  101. package/dist/v2/runtime/endpoints/express-single.d.mts.map +1 -1
  102. package/dist/v2/runtime/endpoints/express-single.mjs +35 -178
  103. package/dist/v2/runtime/endpoints/express-single.mjs.map +1 -1
  104. package/dist/v2/runtime/endpoints/express.cjs +41 -195
  105. package/dist/v2/runtime/endpoints/express.cjs.map +1 -1
  106. package/dist/v2/runtime/endpoints/express.d.cts +26 -4
  107. package/dist/v2/runtime/endpoints/express.d.cts.map +1 -1
  108. package/dist/v2/runtime/endpoints/express.d.mts +26 -4
  109. package/dist/v2/runtime/endpoints/express.d.mts.map +1 -1
  110. package/dist/v2/runtime/endpoints/express.mjs +41 -195
  111. package/dist/v2/runtime/endpoints/express.mjs.map +1 -1
  112. package/dist/v2/runtime/endpoints/hono-single.cjs +11 -123
  113. package/dist/v2/runtime/endpoints/hono-single.cjs.map +1 -1
  114. package/dist/v2/runtime/endpoints/hono-single.d.cts +14 -11
  115. package/dist/v2/runtime/endpoints/hono-single.d.cts.map +1 -1
  116. package/dist/v2/runtime/endpoints/hono-single.d.mts +14 -11
  117. package/dist/v2/runtime/endpoints/hono-single.d.mts.map +1 -1
  118. package/dist/v2/runtime/endpoints/hono-single.mjs +11 -123
  119. package/dist/v2/runtime/endpoints/hono-single.mjs.map +1 -1
  120. package/dist/v2/runtime/endpoints/hono.cjs +23 -237
  121. package/dist/v2/runtime/endpoints/hono.cjs.map +1 -1
  122. package/dist/v2/runtime/endpoints/hono.d.cts +29 -120
  123. package/dist/v2/runtime/endpoints/hono.d.cts.map +1 -1
  124. package/dist/v2/runtime/endpoints/hono.d.mts +29 -120
  125. package/dist/v2/runtime/endpoints/hono.d.mts.map +1 -1
  126. package/dist/v2/runtime/endpoints/hono.mjs +22 -238
  127. package/dist/v2/runtime/endpoints/hono.mjs.map +1 -1
  128. package/dist/v2/runtime/endpoints/index.d.cts +2 -2
  129. package/dist/v2/runtime/endpoints/index.d.mts +2 -2
  130. package/dist/v2/runtime/endpoints/node-fetch-handler.cjs +26 -0
  131. package/dist/v2/runtime/endpoints/node-fetch-handler.cjs.map +1 -0
  132. package/dist/v2/runtime/endpoints/node-fetch-handler.d.cts +12 -0
  133. package/dist/v2/runtime/endpoints/node-fetch-handler.d.cts.map +1 -0
  134. package/dist/v2/runtime/endpoints/node-fetch-handler.d.mts +12 -0
  135. package/dist/v2/runtime/endpoints/node-fetch-handler.d.mts.map +1 -0
  136. package/dist/v2/runtime/endpoints/node-fetch-handler.mjs +24 -0
  137. package/dist/v2/runtime/endpoints/node-fetch-handler.mjs.map +1 -0
  138. package/dist/v2/runtime/endpoints/node.cjs +30 -0
  139. package/dist/v2/runtime/endpoints/node.cjs.map +1 -0
  140. package/dist/v2/runtime/endpoints/node.d.cts +27 -0
  141. package/dist/v2/runtime/endpoints/node.d.cts.map +1 -0
  142. package/dist/v2/runtime/endpoints/node.d.mts +27 -0
  143. package/dist/v2/runtime/endpoints/node.d.mts.map +1 -0
  144. package/dist/v2/runtime/endpoints/node.mjs +30 -0
  145. package/dist/v2/runtime/endpoints/node.mjs.map +1 -0
  146. package/dist/v2/runtime/express.d.cts +3 -0
  147. package/dist/v2/runtime/express.d.mts +3 -0
  148. package/dist/v2/runtime/handlers/get-runtime-info.cjs +2 -1
  149. package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
  150. package/dist/v2/runtime/handlers/get-runtime-info.mjs +2 -1
  151. package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
  152. package/dist/v2/runtime/handlers/handle-connect.cjs +6 -3
  153. package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -1
  154. package/dist/v2/runtime/handlers/handle-connect.mjs +6 -3
  155. package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -1
  156. package/dist/v2/runtime/handlers/handle-run.cjs +6 -3
  157. package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
  158. package/dist/v2/runtime/handlers/handle-run.mjs +6 -3
  159. package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
  160. package/dist/v2/runtime/handlers/handle-stop.cjs.map +1 -1
  161. package/dist/v2/runtime/handlers/handle-stop.mjs.map +1 -1
  162. package/dist/v2/runtime/handlers/handle-transcribe.cjs.map +1 -1
  163. package/dist/v2/runtime/handlers/handle-transcribe.mjs.map +1 -1
  164. package/dist/v2/runtime/handlers/intelligence/connect.cjs.map +1 -1
  165. package/dist/v2/runtime/handlers/intelligence/connect.mjs.map +1 -1
  166. package/dist/v2/runtime/handlers/intelligence/run.cjs +22 -1
  167. package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -1
  168. package/dist/v2/runtime/handlers/intelligence/run.mjs +22 -1
  169. package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -1
  170. package/dist/v2/runtime/handlers/intelligence/thread-names.cjs +1 -1
  171. package/dist/v2/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
  172. package/dist/v2/runtime/handlers/intelligence/thread-names.mjs +1 -1
  173. package/dist/v2/runtime/handlers/intelligence/thread-names.mjs.map +1 -1
  174. package/dist/v2/runtime/handlers/shared/agent-utils.cjs +21 -6
  175. package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  176. package/dist/v2/runtime/handlers/shared/agent-utils.mjs +21 -6
  177. package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  178. package/dist/v2/runtime/handlers/shared/json-response.cjs +4 -1
  179. package/dist/v2/runtime/handlers/shared/json-response.cjs.map +1 -1
  180. package/dist/v2/runtime/handlers/shared/json-response.mjs +4 -1
  181. package/dist/v2/runtime/handlers/shared/json-response.mjs.map +1 -1
  182. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
  183. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
  184. package/dist/v2/runtime/handlers/sse/connect.cjs.map +1 -1
  185. package/dist/v2/runtime/handlers/sse/connect.mjs.map +1 -1
  186. package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
  187. package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
  188. package/dist/v2/runtime/hono.d.cts +3 -0
  189. package/dist/v2/runtime/hono.d.mts +3 -0
  190. package/dist/v2/runtime/index.d.cts +16 -4
  191. package/dist/v2/runtime/index.d.cts.map +1 -0
  192. package/dist/v2/runtime/index.d.mts +16 -4
  193. package/dist/v2/runtime/index.d.mts.map +1 -0
  194. package/dist/v2/runtime/intelligence-platform/client.cjs +10 -1
  195. package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
  196. package/dist/v2/runtime/intelligence-platform/client.d.cts +22 -0
  197. package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
  198. package/dist/v2/runtime/intelligence-platform/client.d.mts +22 -0
  199. package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
  200. package/dist/v2/runtime/intelligence-platform/client.mjs +10 -1
  201. package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
  202. package/dist/v2/runtime/node.d.cts +3 -0
  203. package/dist/v2/runtime/node.d.mts +3 -0
  204. package/dist/v2/runtime/open-generative-ui-middleware.cjs +282 -0
  205. package/dist/v2/runtime/open-generative-ui-middleware.cjs.map +1 -0
  206. package/dist/v2/runtime/open-generative-ui-middleware.mjs +280 -0
  207. package/dist/v2/runtime/open-generative-ui-middleware.mjs.map +1 -0
  208. package/dist/v2/runtime/runner/intelligence.cjs +4 -4
  209. package/dist/v2/runtime/runner/intelligence.cjs.map +1 -1
  210. package/dist/v2/runtime/runner/intelligence.d.cts +6 -2
  211. package/dist/v2/runtime/runner/intelligence.d.cts.map +1 -1
  212. package/dist/v2/runtime/runner/intelligence.d.mts +6 -2
  213. package/dist/v2/runtime/runner/intelligence.d.mts.map +1 -1
  214. package/dist/v2/runtime/runner/intelligence.mjs +4 -4
  215. package/dist/v2/runtime/runner/intelligence.mjs.map +1 -1
  216. package/dist/v2/runtime/telemetry/telemetry-client.cjs +37 -0
  217. package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
  218. package/dist/v2/runtime/telemetry/telemetry-client.mjs +36 -0
  219. package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
  220. package/dist/v2/runtime/telemetry/utils.cjs +15 -0
  221. package/dist/v2/runtime/telemetry/utils.cjs.map +1 -0
  222. package/dist/v2/runtime/telemetry/utils.mjs +14 -0
  223. package/dist/v2/runtime/telemetry/utils.mjs.map +1 -0
  224. package/package.json +81 -48
  225. package/src/agent/__tests__/multimodal.test.ts +176 -0
  226. package/src/agent/index.ts +130 -19
  227. package/src/lib/runtime/agent-integrations/langgraph/agent.ts +3 -3
  228. package/src/lib/runtime/copilot-runtime.ts +1 -0
  229. package/src/v2/express.ts +1 -0
  230. package/src/v2/hono.ts +1 -0
  231. package/src/v2/node.ts +1 -0
  232. package/src/v2/runtime/__tests__/backward-compat.test.ts +261 -0
  233. package/src/v2/runtime/__tests__/code-review-fixes.test.ts +500 -0
  234. package/src/v2/runtime/__tests__/cors-credentials.test.ts +2 -2
  235. package/src/v2/runtime/__tests__/express-adapter.test.ts +188 -0
  236. package/src/v2/runtime/__tests__/express-body-order.test.ts +1 -1
  237. package/src/v2/runtime/__tests__/express-fetch-bridge.test.ts +344 -0
  238. package/src/v2/runtime/__tests__/express-single-sse.test.ts +1 -1
  239. package/src/v2/runtime/__tests__/fetch-cors.test.ts +205 -0
  240. package/src/v2/runtime/__tests__/fetch-handler-validation.test.ts +372 -0
  241. package/src/v2/runtime/__tests__/fetch-handler.test.ts +456 -0
  242. package/src/v2/runtime/__tests__/fetch-router.test.ts +132 -0
  243. package/src/v2/runtime/__tests__/get-runtime-info.test.ts +4 -1
  244. package/src/v2/runtime/__tests__/handle-connect.test.ts +15 -13
  245. package/src/v2/runtime/__tests__/handle-run.test.ts +21 -17
  246. package/src/v2/runtime/__tests__/handle-threads.test.ts +1 -1
  247. package/src/v2/runtime/__tests__/handle-transcribe.test.ts +1 -1
  248. package/src/v2/runtime/__tests__/hono-adapter.test.ts +150 -0
  249. package/src/v2/runtime/__tests__/hooks-edge-cases.test.ts +457 -0
  250. package/src/v2/runtime/__tests__/hooks.test.ts +557 -0
  251. package/src/v2/runtime/__tests__/integration/bun/bun-servers.integration.test.ts +27 -0
  252. package/src/v2/runtime/__tests__/integration/bun/elysia-multi.ts +32 -0
  253. package/src/v2/runtime/__tests__/integration/bun/elysia-single.ts +33 -0
  254. package/src/v2/runtime/__tests__/integration/bun/hono-bun-multi.ts +25 -0
  255. package/src/v2/runtime/__tests__/integration/bun/hono-bun-single.ts +32 -0
  256. package/src/v2/runtime/__tests__/integration/helpers/create-test-runtime.ts +15 -0
  257. package/src/v2/runtime/__tests__/integration/helpers/sse-reader.ts +45 -0
  258. package/src/v2/runtime/__tests__/integration/helpers/test-agent.ts +58 -0
  259. package/src/v2/runtime/__tests__/integration/node-servers.integration.test.ts +39 -0
  260. package/src/v2/runtime/__tests__/integration/servers/express-multi.ts +35 -0
  261. package/src/v2/runtime/__tests__/integration/servers/express-single.ts +36 -0
  262. package/src/v2/runtime/__tests__/integration/servers/fetch-direct.ts +39 -0
  263. package/src/v2/runtime/__tests__/integration/servers/hono-multi.ts +30 -0
  264. package/src/v2/runtime/__tests__/integration/servers/hono-single.ts +37 -0
  265. package/src/v2/runtime/__tests__/integration/servers/node-multi.ts +45 -0
  266. package/src/v2/runtime/__tests__/integration/servers/node-single.ts +46 -0
  267. package/src/v2/runtime/__tests__/integration/servers/types.ts +18 -0
  268. package/src/v2/runtime/__tests__/integration/suites/multi-endpoint.suite.ts +358 -0
  269. package/src/v2/runtime/__tests__/integration/suites/single-endpoint.suite.ts +363 -0
  270. package/src/v2/runtime/__tests__/middleware-express.test.ts +25 -23
  271. package/src/v2/runtime/__tests__/middleware-single-express.test.ts +25 -23
  272. package/src/v2/runtime/__tests__/middleware-single.test.ts +1 -1
  273. package/src/v2/runtime/__tests__/middleware-sse-parser.test.ts +1 -1
  274. package/src/v2/runtime/__tests__/middleware.test.ts +1 -2
  275. package/src/v2/runtime/__tests__/node-fetch-handler.test.ts +157 -0
  276. package/src/v2/runtime/__tests__/open-generative-ui-middleware.e2e.test.ts +728 -0
  277. package/src/v2/runtime/__tests__/router-edge-cases.test.ts +217 -0
  278. package/src/v2/runtime/__tests__/routing-express.test.ts +1 -1
  279. package/src/v2/runtime/__tests__/routing-single-express.test.ts +1 -1
  280. package/src/v2/runtime/__tests__/routing-single.test.ts +1 -1
  281. package/src/v2/runtime/__tests__/routing.test.ts +1 -1
  282. package/src/v2/runtime/__tests__/runtime.test.ts +110 -1
  283. package/src/v2/runtime/__tests__/telemetry.test.ts +62 -1
  284. package/src/v2/runtime/core/fetch-cors.ts +136 -0
  285. package/src/v2/runtime/core/fetch-handler.ts +415 -0
  286. package/src/v2/runtime/core/fetch-router.ts +112 -0
  287. package/src/v2/runtime/core/hooks.ts +151 -0
  288. package/src/v2/runtime/{runtime.ts → core/runtime.ts} +79 -10
  289. package/src/v2/runtime/endpoints/express-fetch-bridge.ts +137 -0
  290. package/src/v2/runtime/endpoints/express-single.ts +42 -219
  291. package/src/v2/runtime/endpoints/express.ts +128 -230
  292. package/src/v2/runtime/endpoints/hono-single.ts +19 -171
  293. package/src/v2/runtime/endpoints/hono.ts +45 -270
  294. package/src/v2/runtime/endpoints/node-fetch-handler.ts +48 -0
  295. package/src/v2/runtime/endpoints/node.ts +28 -0
  296. package/src/v2/runtime/handlers/get-runtime-info.ts +3 -2
  297. package/src/v2/runtime/handlers/handle-connect.ts +7 -4
  298. package/src/v2/runtime/handlers/handle-run.ts +7 -4
  299. package/src/v2/runtime/handlers/handle-stop.ts +1 -1
  300. package/src/v2/runtime/handlers/handle-transcribe.ts +1 -1
  301. package/src/v2/runtime/handlers/intelligence/connect.ts +1 -1
  302. package/src/v2/runtime/handlers/intelligence/run.ts +31 -1
  303. package/src/v2/runtime/handlers/intelligence/thread-names.ts +2 -2
  304. package/src/v2/runtime/handlers/intelligence/threads.ts +1 -1
  305. package/src/v2/runtime/handlers/shared/agent-utils.ts +29 -10
  306. package/src/v2/runtime/handlers/shared/json-response.ts +4 -1
  307. package/src/v2/runtime/handlers/shared/resolve-intelligence-user.ts +1 -1
  308. package/src/v2/runtime/handlers/sse/connect.ts +1 -1
  309. package/src/v2/runtime/handlers/sse/run.ts +1 -1
  310. package/src/v2/runtime/hono.ts +2 -0
  311. package/src/v2/runtime/index.ts +27 -1
  312. package/src/v2/runtime/intelligence-platform/client.ts +50 -1
  313. package/src/v2/runtime/node.ts +6 -0
  314. package/src/v2/runtime/open-generative-ui-middleware.ts +373 -0
  315. package/src/v2/runtime/runner/intelligence.ts +14 -4
  316. package/src/v2/runtime/telemetry/telemetry-client.ts +56 -0
  317. package/src/v2/runtime/telemetry/utils.ts +15 -0
  318. package/tsdown.config.ts +8 -1
  319. package/vitest.config.mjs +2 -5
  320. package/.eslintrc.js +0 -7
  321. package/dist/v2/runtime/endpoints/express-utils.cjs +0 -119
  322. package/dist/v2/runtime/endpoints/express-utils.cjs.map +0 -1
  323. package/dist/v2/runtime/endpoints/express-utils.mjs +0 -117
  324. package/dist/v2/runtime/endpoints/express-utils.mjs.map +0 -1
  325. package/dist/v2/runtime/handlers/intelligence/threads.cjs +0 -159
  326. package/dist/v2/runtime/handlers/intelligence/threads.cjs.map +0 -1
  327. package/dist/v2/runtime/handlers/intelligence/threads.mjs +0 -154
  328. package/dist/v2/runtime/handlers/intelligence/threads.mjs.map +0 -1
  329. package/dist/v2/runtime/middleware-sse-parser.cjs.map +0 -1
  330. package/dist/v2/runtime/middleware-sse-parser.d.cts.map +0 -1
  331. package/dist/v2/runtime/middleware-sse-parser.d.mts.map +0 -1
  332. package/dist/v2/runtime/middleware-sse-parser.mjs.map +0 -1
  333. package/dist/v2/runtime/middleware.cjs.map +0 -1
  334. package/dist/v2/runtime/middleware.d.cts.map +0 -1
  335. package/dist/v2/runtime/middleware.d.mts.map +0 -1
  336. package/dist/v2/runtime/middleware.mjs.map +0 -1
  337. package/dist/v2/runtime/runtime.cjs.map +0 -1
  338. package/dist/v2/runtime/runtime.d.cts.map +0 -1
  339. package/dist/v2/runtime/runtime.d.mts.map +0 -1
  340. package/dist/v2/runtime/runtime.mjs.map +0 -1
  341. package/src/v2/runtime/__tests__/express-abort-signal.test.ts +0 -25
  342. package/src/v2/runtime/endpoints/express-utils.ts +0 -182
  343. package/src/v2/runtime/handler.ts +0 -3
  344. /package/src/v2/runtime/{middleware-sse-parser.ts → core/middleware-sse-parser.ts} +0 -0
  345. /package/src/v2/runtime/{middleware.ts → core/middleware.ts} +0 -0
@@ -0,0 +1,456 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { createCopilotRuntimeHandler } from "../core/fetch-handler";
3
+ import { CopilotRuntime } from "../core/runtime";
4
+ import type { AbstractAgent } from "@ag-ui/client";
5
+
6
+ /* ------------------------------------------------------------------------------------------------
7
+ * Helpers
8
+ * --------------------------------------------------------------------------------------------- */
9
+
10
+ const createMockAgent = () => {
11
+ const agent: unknown = {
12
+ execute: vi.fn().mockResolvedValue({ events: [] }),
13
+ };
14
+ (agent as { clone: () => unknown }).clone = () => createMockAgent();
15
+ return agent as AbstractAgent;
16
+ };
17
+
18
+ const createRuntime = (
19
+ agents: Record<string, AbstractAgent> = { default: createMockAgent() },
20
+ ) => new CopilotRuntime({ agents });
21
+
22
+ const post = (url: string, body?: unknown) =>
23
+ new Request(url, {
24
+ method: "POST",
25
+ headers: { "Content-Type": "application/json" },
26
+ body: body ? JSON.stringify(body) : undefined,
27
+ });
28
+
29
+ const get = (url: string) => new Request(url, { method: "GET" });
30
+
31
+ /* ------------------------------------------------------------------------------------------------
32
+ * Multi-route with basePath
33
+ * --------------------------------------------------------------------------------------------- */
34
+
35
+ describe("createCopilotRuntimeHandler — multi-route with basePath", () => {
36
+ const runtime = createRuntime();
37
+ const handler = createCopilotRuntimeHandler({
38
+ runtime,
39
+ basePath: "/api/copilotkit",
40
+ mode: "multi-route",
41
+ });
42
+
43
+ it("routes GET /info to handleGetRuntimeInfo", async () => {
44
+ const response = await handler(get("http://localhost/api/copilotkit/info"));
45
+ expect(response.status).toBe(200);
46
+ const body = await response.json();
47
+ expect(body).toHaveProperty("version");
48
+ expect(body).toHaveProperty("agents");
49
+ });
50
+
51
+ it("returns 404 for paths not starting with basePath", async () => {
52
+ const response = await handler(get("http://localhost/other/info"));
53
+ expect(response.status).toBe(404);
54
+ });
55
+
56
+ it("returns 404 for unmatched subpaths", async () => {
57
+ const response = await handler(
58
+ get("http://localhost/api/copilotkit/unknown"),
59
+ );
60
+ expect(response.status).toBe(404);
61
+ });
62
+
63
+ it("returns 405 for wrong HTTP method on /info (POST instead of GET)", async () => {
64
+ const response = await handler(
65
+ post("http://localhost/api/copilotkit/info"),
66
+ );
67
+ expect(response.status).toBe(405);
68
+ });
69
+
70
+ it("returns 405 for GET on a POST-only route", async () => {
71
+ const response = await handler(
72
+ get("http://localhost/api/copilotkit/agent/myAgent/run"),
73
+ );
74
+ expect(response.status).toBe(405);
75
+ });
76
+
77
+ it("routes POST /agent/:agentId/run", async () => {
78
+ const response = await handler(
79
+ post("http://localhost/api/copilotkit/agent/default/run", {
80
+ threadId: "t1",
81
+ runId: "r1",
82
+ }),
83
+ );
84
+ // Handler runs — may return error for invalid input but at least matches the route
85
+ expect(response.status).not.toBe(404);
86
+ expect(response.status).not.toBe(405);
87
+ });
88
+
89
+ it("routes POST /agent/:agentId/connect", async () => {
90
+ const response = await handler(
91
+ post("http://localhost/api/copilotkit/agent/default/connect", {
92
+ threadId: "t1",
93
+ runId: "r1",
94
+ }),
95
+ );
96
+ expect(response.status).not.toBe(404);
97
+ expect(response.status).not.toBe(405);
98
+ });
99
+
100
+ it("routes POST /agent/:agentId/stop/:threadId", async () => {
101
+ const response = await handler(
102
+ post("http://localhost/api/copilotkit/agent/default/stop/t1"),
103
+ );
104
+ expect(response.status).not.toBe(404);
105
+ expect(response.status).not.toBe(405);
106
+ });
107
+
108
+ it("routes POST /transcribe", async () => {
109
+ const response = await handler(
110
+ post("http://localhost/api/copilotkit/transcribe"),
111
+ );
112
+ // Transcribe may fail (no service configured) but should match the route
113
+ expect(response.status).not.toBe(404);
114
+ expect(response.status).not.toBe(405);
115
+ });
116
+
117
+ it("basePath with trailing slash still works", async () => {
118
+ const trailingSlashHandler = createCopilotRuntimeHandler({
119
+ runtime: createRuntime(),
120
+ basePath: "/api/copilotkit/",
121
+ mode: "multi-route",
122
+ });
123
+ const response = await trailingSlashHandler(
124
+ get("http://localhost/api/copilotkit/info"),
125
+ );
126
+ expect(response.status).toBe(200);
127
+ const body = await response.json();
128
+ expect(body).toHaveProperty("version");
129
+ expect(body).toHaveProperty("agents");
130
+ });
131
+
132
+ it("URL-encoded agentId is handled correctly", async () => {
133
+ const encodedHandler = createCopilotRuntimeHandler({
134
+ runtime: createRuntime({ "my agent": createMockAgent() }),
135
+ basePath: "/api/copilotkit",
136
+ mode: "multi-route",
137
+ });
138
+ const response = await encodedHandler(
139
+ post("http://localhost/api/copilotkit/agent/my%20agent/run", {
140
+ threadId: "t1",
141
+ runId: "r1",
142
+ }),
143
+ );
144
+ expect(response.status).not.toBe(404);
145
+ expect(response.status).not.toBe(405);
146
+ });
147
+ });
148
+
149
+ /* ------------------------------------------------------------------------------------------------
150
+ * Multi-route without basePath (suffix matching)
151
+ * --------------------------------------------------------------------------------------------- */
152
+
153
+ describe("createCopilotRuntimeHandler — multi-route without basePath", () => {
154
+ const runtime = createRuntime();
155
+ const handler = createCopilotRuntimeHandler({
156
+ runtime,
157
+ mode: "multi-route",
158
+ });
159
+
160
+ it("matches /info suffix", async () => {
161
+ const response = await handler(get("http://localhost/some/prefix/info"));
162
+ expect(response.status).toBe(200);
163
+ const body = await response.json();
164
+ expect(body).toHaveProperty("version");
165
+ });
166
+
167
+ it("matches /agent/:id/run suffix", async () => {
168
+ const response = await handler(
169
+ post("http://localhost/some/prefix/agent/default/run", {
170
+ threadId: "t1",
171
+ runId: "r1",
172
+ }),
173
+ );
174
+ expect(response.status).not.toBe(404);
175
+ });
176
+
177
+ it("returns 404 for no known suffix", async () => {
178
+ const response = await handler(get("http://localhost/some/prefix/unknown"));
179
+ expect(response.status).toBe(404);
180
+ });
181
+
182
+ it("matches /agent/:id/connect suffix", async () => {
183
+ const response = await handler(
184
+ post("http://localhost/some/prefix/agent/default/connect", {
185
+ threadId: "t1",
186
+ runId: "r1",
187
+ }),
188
+ );
189
+ expect(response.status).not.toBe(404);
190
+ expect(response.status).not.toBe(405);
191
+ });
192
+
193
+ it("matches /agent/:id/stop/:threadId suffix", async () => {
194
+ const response = await handler(
195
+ post("http://localhost/some/prefix/agent/default/stop/t1"),
196
+ );
197
+ expect(response.status).not.toBe(404);
198
+ expect(response.status).not.toBe(405);
199
+ });
200
+
201
+ it("matches /transcribe suffix", async () => {
202
+ const response = await handler(
203
+ post("http://localhost/some/prefix/transcribe"),
204
+ );
205
+ expect(response.status).not.toBe(404);
206
+ expect(response.status).not.toBe(405);
207
+ });
208
+ });
209
+
210
+ /* ------------------------------------------------------------------------------------------------
211
+ * Single-route mode
212
+ * --------------------------------------------------------------------------------------------- */
213
+
214
+ describe("createCopilotRuntimeHandler — single-route mode", () => {
215
+ const runtime = createRuntime();
216
+ const handler = createCopilotRuntimeHandler({
217
+ runtime,
218
+ basePath: "/api/copilotkit",
219
+ mode: "single-route",
220
+ });
221
+
222
+ it("dispatches info method", async () => {
223
+ const response = await handler(
224
+ post("http://localhost/api/copilotkit", { method: "info" }),
225
+ );
226
+ expect(response.status).toBe(200);
227
+ const body = await response.json();
228
+ expect(body).toHaveProperty("version");
229
+ });
230
+
231
+ it("returns 400 for missing method", async () => {
232
+ const response = await handler(post("http://localhost/api/copilotkit", {}));
233
+ expect(response.status).toBe(400);
234
+ });
235
+
236
+ it("returns 400 for invalid method", async () => {
237
+ const response = await handler(
238
+ post("http://localhost/api/copilotkit", { method: "nonexistent" }),
239
+ );
240
+ expect(response.status).toBe(400);
241
+ });
242
+
243
+ it("returns 415 for non-JSON content-type", async () => {
244
+ const request = new Request("http://localhost/api/copilotkit", {
245
+ method: "POST",
246
+ headers: { "Content-Type": "text/plain" },
247
+ body: "hello",
248
+ });
249
+ const response = await handler(request);
250
+ expect(response.status).toBe(415);
251
+ });
252
+
253
+ it("returns 405 for GET in single-route mode", async () => {
254
+ const response = await handler(get("http://localhost/api/copilotkit"));
255
+ expect(response.status).toBe(405);
256
+ });
257
+
258
+ it("dispatches agent/run with params (routes correctly)", async () => {
259
+ const response = await handler(
260
+ post("http://localhost/api/copilotkit", {
261
+ method: "agent/run",
262
+ params: { agentId: "default" },
263
+ body: { threadId: "t1", runId: "r1" },
264
+ }),
265
+ );
266
+ // Route matched — not a 404/405 routing error. May return 400 due to
267
+ // incomplete RunAgentInput schema fields, which is handler-level validation.
268
+ expect(response.status).not.toBe(404);
269
+ expect(response.status).not.toBe(405);
270
+ });
271
+
272
+ it("returns 404 when basePath doesn't match in single-route", async () => {
273
+ const response = await handler(
274
+ post("http://localhost/other/path", { method: "info" }),
275
+ );
276
+ expect(response.status).toBe(404);
277
+ });
278
+
279
+ it("dispatches agent/connect method", async () => {
280
+ const response = await handler(
281
+ post("http://localhost/api/copilotkit", {
282
+ method: "agent/connect",
283
+ params: { agentId: "default" },
284
+ body: { threadId: "t1", runId: "r1" },
285
+ }),
286
+ );
287
+ expect(response.status).not.toBe(404);
288
+ expect(response.status).not.toBe(405);
289
+ });
290
+
291
+ it("dispatches agent/stop method with agentId and threadId params", async () => {
292
+ const response = await handler(
293
+ post("http://localhost/api/copilotkit", {
294
+ method: "agent/stop",
295
+ params: { agentId: "default", threadId: "t1" },
296
+ }),
297
+ );
298
+ expect(response.status).not.toBe(404);
299
+ expect(response.status).not.toBe(405);
300
+ });
301
+
302
+ it("dispatches transcribe method", async () => {
303
+ const response = await handler(
304
+ post("http://localhost/api/copilotkit", {
305
+ method: "transcribe",
306
+ }),
307
+ );
308
+ expect(response.status).not.toBe(404);
309
+ expect(response.status).not.toBe(405);
310
+ });
311
+
312
+ it("single-route without basePath dispatches any POST", async () => {
313
+ const noBasePathHandler = createCopilotRuntimeHandler({
314
+ runtime: createRuntime(),
315
+ mode: "single-route",
316
+ });
317
+ const response = await noBasePathHandler(
318
+ post("http://localhost/any/path/here", { method: "info" }),
319
+ );
320
+ expect(response.status).toBe(200);
321
+ const body = await response.json();
322
+ expect(body).toHaveProperty("version");
323
+ });
324
+ });
325
+
326
+ /* ------------------------------------------------------------------------------------------------
327
+ * CORS integration
328
+ * --------------------------------------------------------------------------------------------- */
329
+
330
+ describe("createCopilotRuntimeHandler — CORS", () => {
331
+ const runtime = createRuntime();
332
+
333
+ it("handles OPTIONS preflight when cors: true", async () => {
334
+ const handler = createCopilotRuntimeHandler({
335
+ runtime,
336
+ basePath: "/api",
337
+ cors: true,
338
+ });
339
+ const request = new Request("http://localhost/api/info", {
340
+ method: "OPTIONS",
341
+ headers: { Origin: "https://myapp.com" },
342
+ });
343
+ const response = await handler(request);
344
+ expect(response.status).toBe(204);
345
+ expect(response.headers.get("Access-Control-Allow-Origin")).toBe("*");
346
+ });
347
+
348
+ it("adds CORS headers to normal responses when cors: true", async () => {
349
+ const handler = createCopilotRuntimeHandler({
350
+ runtime,
351
+ basePath: "/api",
352
+ cors: true,
353
+ });
354
+ const response = await handler(get("http://localhost/api/info"));
355
+ expect(response.status).toBe(200);
356
+ expect(response.headers.get("Access-Control-Allow-Origin")).toBe("*");
357
+ });
358
+
359
+ it("does not add CORS headers when cors is omitted", async () => {
360
+ const handler = createCopilotRuntimeHandler({
361
+ runtime,
362
+ basePath: "/api",
363
+ });
364
+ const response = await handler(get("http://localhost/api/info"));
365
+ expect(response.status).toBe(200);
366
+ expect(response.headers.get("Access-Control-Allow-Origin")).toBeNull();
367
+ });
368
+
369
+ it("does not add CORS headers when cors: false", async () => {
370
+ const handler = createCopilotRuntimeHandler({
371
+ runtime,
372
+ basePath: "/api",
373
+ cors: false,
374
+ });
375
+ const response = await handler(get("http://localhost/api/info"));
376
+ expect(response.headers.get("Access-Control-Allow-Origin")).toBeNull();
377
+ });
378
+
379
+ it("uses custom CORS config", async () => {
380
+ const handler = createCopilotRuntimeHandler({
381
+ runtime,
382
+ basePath: "/api",
383
+ cors: {
384
+ origin: "https://specific.com",
385
+ credentials: true,
386
+ },
387
+ });
388
+ const response = await handler(
389
+ new Request("http://localhost/api/info", {
390
+ method: "GET",
391
+ headers: { Origin: "https://specific.com" },
392
+ }),
393
+ );
394
+ expect(response.headers.get("Access-Control-Allow-Origin")).toBe(
395
+ "https://specific.com",
396
+ );
397
+ expect(response.headers.get("Access-Control-Allow-Credentials")).toBe(
398
+ "true",
399
+ );
400
+ });
401
+
402
+ it("adds CORS headers to error responses", async () => {
403
+ const handler = createCopilotRuntimeHandler({
404
+ runtime,
405
+ basePath: "/api",
406
+ cors: true,
407
+ });
408
+ const response = await handler(get("http://localhost/api/unknown"));
409
+ expect(response.status).toBe(404);
410
+ expect(response.headers.get("Access-Control-Allow-Origin")).toBe("*");
411
+ });
412
+ });
413
+
414
+ /* ------------------------------------------------------------------------------------------------
415
+ * Error handling
416
+ * --------------------------------------------------------------------------------------------- */
417
+
418
+ describe("createCopilotRuntimeHandler — error handling", () => {
419
+ it("returns 500 JSON error for unhandled errors", async () => {
420
+ const agent: unknown = {
421
+ execute: vi.fn().mockRejectedValue(new Error("boom")),
422
+ clone: () => agent,
423
+ };
424
+ const runtime = createRuntime({
425
+ default: agent as AbstractAgent,
426
+ });
427
+ const handler = createCopilotRuntimeHandler({
428
+ runtime,
429
+ basePath: "/api",
430
+ });
431
+
432
+ const response = await handler(
433
+ post("http://localhost/api/agent/default/run", {
434
+ threadId: "t1",
435
+ runId: "r1",
436
+ }),
437
+ );
438
+ // The handler catches errors and produces some response
439
+ expect(response).toBeInstanceOf(Response);
440
+ });
441
+
442
+ it("returns thrown Response directly", async () => {
443
+ const handler = createCopilotRuntimeHandler({
444
+ runtime: createRuntime(),
445
+ basePath: "/api",
446
+ hooks: {
447
+ onRequest: () => {
448
+ throw new Response("Forbidden", { status: 403 });
449
+ },
450
+ },
451
+ });
452
+
453
+ const response = await handler(get("http://localhost/api/info"));
454
+ expect(response.status).toBe(403);
455
+ });
456
+ });
@@ -0,0 +1,132 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { matchRoute } from "../core/fetch-router";
3
+
4
+ describe("fetch-router", () => {
5
+ describe("with basePath (strict prefix stripping)", () => {
6
+ const basePath = "/api/copilotkit";
7
+
8
+ it("matches GET /info", () => {
9
+ const result = matchRoute("/api/copilotkit/info", basePath);
10
+ expect(result).toEqual({ method: "info" });
11
+ });
12
+
13
+ it("matches POST /transcribe", () => {
14
+ const result = matchRoute("/api/copilotkit/transcribe", basePath);
15
+ expect(result).toEqual({ method: "transcribe" });
16
+ });
17
+
18
+ it("matches POST /agent/:agentId/run", () => {
19
+ const result = matchRoute("/api/copilotkit/agent/myAgent/run", basePath);
20
+ expect(result).toEqual({ method: "agent/run", agentId: "myAgent" });
21
+ });
22
+
23
+ it("matches POST /agent/:agentId/connect", () => {
24
+ const result = matchRoute(
25
+ "/api/copilotkit/agent/myAgent/connect",
26
+ basePath,
27
+ );
28
+ expect(result).toEqual({ method: "agent/connect", agentId: "myAgent" });
29
+ });
30
+
31
+ it("matches POST /agent/:agentId/stop/:threadId", () => {
32
+ const result = matchRoute(
33
+ "/api/copilotkit/agent/myAgent/stop/thread-123",
34
+ basePath,
35
+ );
36
+ expect(result).toEqual({
37
+ method: "agent/stop",
38
+ agentId: "myAgent",
39
+ threadId: "thread-123",
40
+ });
41
+ });
42
+
43
+ it("returns null for paths not starting with basePath", () => {
44
+ const result = matchRoute("/other/info", basePath);
45
+ expect(result).toBeNull();
46
+ });
47
+
48
+ it("returns null for unmatched subpaths after basePath", () => {
49
+ const result = matchRoute("/api/copilotkit/unknown", basePath);
50
+ expect(result).toBeNull();
51
+ });
52
+
53
+ it("returns null when basePath is a prefix but not a segment boundary", () => {
54
+ const result = matchRoute("/api/copilotkitextra/info", basePath);
55
+ expect(result).toBeNull();
56
+ });
57
+
58
+ it("handles basePath with trailing slash", () => {
59
+ const result = matchRoute("/api/copilotkit/info", "/api/copilotkit/");
60
+ expect(result).toEqual({ method: "info" });
61
+ });
62
+
63
+ it("handles URL-encoded agentId", () => {
64
+ const result = matchRoute(
65
+ "/api/copilotkit/agent/my%20agent/run",
66
+ basePath,
67
+ );
68
+ expect(result).toEqual({ method: "agent/run", agentId: "my agent" });
69
+ });
70
+
71
+ it("handles URL-encoded threadId", () => {
72
+ const result = matchRoute(
73
+ "/api/copilotkit/agent/ag/stop/thread%2F123",
74
+ basePath,
75
+ );
76
+ expect(result).toEqual({
77
+ method: "agent/stop",
78
+ agentId: "ag",
79
+ threadId: "thread/123",
80
+ });
81
+ });
82
+
83
+ it("matches basePath with just root /", () => {
84
+ const result = matchRoute("/info", "/");
85
+ expect(result).toEqual({ method: "info" });
86
+ });
87
+ });
88
+
89
+ describe("without basePath (suffix matching)", () => {
90
+ it("matches /info suffix", () => {
91
+ const result = matchRoute("/anything/info");
92
+ expect(result).toEqual({ method: "info" });
93
+ });
94
+
95
+ it("matches /transcribe suffix", () => {
96
+ const result = matchRoute("/anything/transcribe");
97
+ expect(result).toEqual({ method: "transcribe" });
98
+ });
99
+
100
+ it("matches /agent/:agentId/run suffix", () => {
101
+ const result = matchRoute("/anything/agent/myAgent/run");
102
+ expect(result).toEqual({ method: "agent/run", agentId: "myAgent" });
103
+ });
104
+
105
+ it("matches /agent/:agentId/connect suffix", () => {
106
+ const result = matchRoute("/anything/agent/myAgent/connect");
107
+ expect(result).toEqual({
108
+ method: "agent/connect",
109
+ agentId: "myAgent",
110
+ });
111
+ });
112
+
113
+ it("matches /agent/:agentId/stop/:threadId suffix", () => {
114
+ const result = matchRoute("/anything/agent/ag/stop/t1");
115
+ expect(result).toEqual({
116
+ method: "agent/stop",
117
+ agentId: "ag",
118
+ threadId: "t1",
119
+ });
120
+ });
121
+
122
+ it("returns null when no known suffix matches", () => {
123
+ const result = matchRoute("/anything/unknown");
124
+ expect(result).toBeNull();
125
+ });
126
+
127
+ it("works with deeply nested mount prefix", () => {
128
+ const result = matchRoute("/api/v2/copilotkit/agent/a1/run");
129
+ expect(result).toEqual({ method: "agent/run", agentId: "a1" });
130
+ });
131
+ });
132
+ });
@@ -1,5 +1,5 @@
1
1
  import { handleGetRuntimeInfo } from "../handlers/get-runtime-info";
2
- import { CopilotRuntime } from "../runtime";
2
+ import { CopilotRuntime } from "../core/runtime";
3
3
  import { TranscriptionService } from "../transcription-service/transcription-service";
4
4
  import { describe, it, expect } from "vitest";
5
5
  import type { AbstractAgent } from "@ag-ui/client";
@@ -34,6 +34,7 @@ describe("handleGetRuntimeInfo", () => {
34
34
  audioFileTranscriptionEnabled: false,
35
35
  mode: "sse",
36
36
  a2uiEnabled: false,
37
+ openGenerativeUIEnabled: false,
37
38
  });
38
39
  });
39
40
 
@@ -58,6 +59,7 @@ describe("handleGetRuntimeInfo", () => {
58
59
  audioFileTranscriptionEnabled: true,
59
60
  mode: "sse",
60
61
  a2uiEnabled: false,
62
+ openGenerativeUIEnabled: false,
61
63
  });
62
64
  });
63
65
 
@@ -94,6 +96,7 @@ describe("handleGetRuntimeInfo", () => {
94
96
  audioFileTranscriptionEnabled: true,
95
97
  mode: "sse",
96
98
  a2uiEnabled: false,
99
+ openGenerativeUIEnabled: false,
97
100
  });
98
101
  });
99
102