@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.
- package/CHANGELOG.md +28 -0
- package/dist/agent/index.cjs +101 -12
- package/dist/agent/index.cjs.map +1 -1
- package/dist/agent/index.d.cts.map +1 -1
- package/dist/agent/index.d.mts.map +1 -1
- package/dist/agent/index.mjs +102 -13
- package/dist/agent/index.mjs.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.cjs.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts +4 -841
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.mts +4 -841
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.mts.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.mjs.map +1 -1
- package/dist/lib/runtime/copilot-runtime.cjs +3 -2
- package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.cts +1 -1
- package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.mts +3 -3
- package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.mjs +3 -2
- package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
- package/dist/package.cjs +70 -47
- package/dist/package.mjs +70 -47
- package/dist/v2/express.cjs +8 -0
- package/dist/v2/express.d.cts +5 -0
- package/dist/v2/express.d.mts +5 -0
- package/dist/v2/express.mjs +5 -0
- package/dist/v2/hono.cjs +9 -0
- package/dist/v2/hono.d.cts +5 -0
- package/dist/v2/hono.d.mts +5 -0
- package/dist/v2/hono.mjs +5 -0
- package/dist/v2/index.cjs +8 -3
- package/dist/v2/index.d.cts +8 -5
- package/dist/v2/index.d.mts +8 -5
- package/dist/v2/index.mjs +5 -4
- package/dist/v2/node.cjs +8 -0
- package/dist/v2/node.d.cts +5 -0
- package/dist/v2/node.d.mts +5 -0
- package/dist/v2/node.mjs +5 -0
- package/dist/v2/runtime/core/fetch-cors.cjs +72 -0
- package/dist/v2/runtime/core/fetch-cors.cjs.map +1 -0
- package/dist/v2/runtime/core/fetch-cors.d.cts +20 -0
- package/dist/v2/runtime/core/fetch-cors.d.cts.map +1 -0
- package/dist/v2/runtime/core/fetch-cors.d.mts +20 -0
- package/dist/v2/runtime/core/fetch-cors.d.mts.map +1 -0
- package/dist/v2/runtime/core/fetch-cors.mjs +70 -0
- package/dist/v2/runtime/core/fetch-cors.mjs.map +1 -0
- package/dist/v2/runtime/core/fetch-handler.cjs +232 -0
- package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -0
- package/dist/v2/runtime/core/fetch-handler.d.cts +40 -0
- package/dist/v2/runtime/core/fetch-handler.d.cts.map +1 -0
- package/dist/v2/runtime/core/fetch-handler.d.mts +40 -0
- package/dist/v2/runtime/core/fetch-handler.d.mts.map +1 -0
- package/dist/v2/runtime/core/fetch-handler.mjs +231 -0
- package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -0
- package/dist/v2/runtime/core/fetch-router.cjs +68 -0
- package/dist/v2/runtime/core/fetch-router.cjs.map +1 -0
- package/dist/v2/runtime/core/fetch-router.mjs +67 -0
- package/dist/v2/runtime/core/fetch-router.mjs.map +1 -0
- package/dist/v2/runtime/core/hooks.cjs +29 -0
- package/dist/v2/runtime/core/hooks.cjs.map +1 -0
- package/dist/v2/runtime/core/hooks.d.cts +78 -0
- package/dist/v2/runtime/core/hooks.d.cts.map +1 -0
- package/dist/v2/runtime/core/hooks.d.mts +78 -0
- package/dist/v2/runtime/core/hooks.d.mts.map +1 -0
- package/dist/v2/runtime/core/hooks.mjs +25 -0
- package/dist/v2/runtime/core/hooks.mjs.map +1 -0
- package/dist/v2/runtime/{middleware-sse-parser.cjs → core/middleware-sse-parser.cjs} +2 -2
- package/dist/v2/runtime/core/middleware-sse-parser.cjs.map +1 -0
- package/dist/v2/runtime/{middleware-sse-parser.d.cts → core/middleware-sse-parser.d.cts} +1 -1
- package/dist/v2/runtime/core/middleware-sse-parser.d.cts.map +1 -0
- package/dist/v2/runtime/{middleware-sse-parser.d.mts → core/middleware-sse-parser.d.mts} +1 -1
- package/dist/v2/runtime/core/middleware-sse-parser.d.mts.map +1 -0
- package/dist/v2/runtime/{middleware-sse-parser.mjs → core/middleware-sse-parser.mjs} +1 -1
- package/dist/v2/runtime/core/middleware-sse-parser.mjs.map +1 -0
- package/dist/v2/runtime/{middleware.cjs → core/middleware.cjs} +2 -2
- package/dist/v2/runtime/core/middleware.cjs.map +1 -0
- package/dist/v2/runtime/{middleware.d.cts → core/middleware.d.cts} +1 -1
- package/dist/v2/runtime/core/middleware.d.cts.map +1 -0
- package/dist/v2/runtime/{middleware.d.mts → core/middleware.d.mts} +1 -1
- package/dist/v2/runtime/core/middleware.d.mts.map +1 -0
- package/dist/v2/runtime/{middleware.mjs → core/middleware.mjs} +1 -1
- package/dist/v2/runtime/core/middleware.mjs.map +1 -0
- package/dist/v2/runtime/{runtime.cjs → core/runtime.cjs} +35 -10
- package/dist/v2/runtime/core/runtime.cjs.map +1 -0
- package/dist/v2/runtime/{runtime.d.cts → core/runtime.d.cts} +41 -7
- package/dist/v2/runtime/core/runtime.d.cts.map +1 -0
- package/dist/v2/runtime/{runtime.d.mts → core/runtime.d.mts} +42 -8
- package/dist/v2/runtime/core/runtime.d.mts.map +1 -0
- package/dist/v2/runtime/{runtime.mjs → core/runtime.mjs} +36 -11
- package/dist/v2/runtime/core/runtime.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/express-fetch-bridge.cjs +83 -0
- package/dist/v2/runtime/endpoints/express-fetch-bridge.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/express-fetch-bridge.mjs +82 -0
- package/dist/v2/runtime/endpoints/express-fetch-bridge.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/express-single.cjs +35 -181
- package/dist/v2/runtime/endpoints/express-single.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/express-single.d.cts +35 -2
- package/dist/v2/runtime/endpoints/express-single.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/express-single.d.mts +35 -2
- package/dist/v2/runtime/endpoints/express-single.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/express-single.mjs +35 -178
- package/dist/v2/runtime/endpoints/express-single.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/express.cjs +41 -195
- package/dist/v2/runtime/endpoints/express.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/express.d.cts +26 -4
- package/dist/v2/runtime/endpoints/express.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/express.d.mts +26 -4
- package/dist/v2/runtime/endpoints/express.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/express.mjs +41 -195
- package/dist/v2/runtime/endpoints/express.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/hono-single.cjs +11 -123
- package/dist/v2/runtime/endpoints/hono-single.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/hono-single.d.cts +14 -11
- package/dist/v2/runtime/endpoints/hono-single.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/hono-single.d.mts +14 -11
- package/dist/v2/runtime/endpoints/hono-single.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/hono-single.mjs +11 -123
- package/dist/v2/runtime/endpoints/hono-single.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/hono.cjs +23 -237
- package/dist/v2/runtime/endpoints/hono.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/hono.d.cts +29 -120
- package/dist/v2/runtime/endpoints/hono.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/hono.d.mts +29 -120
- package/dist/v2/runtime/endpoints/hono.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/hono.mjs +22 -238
- package/dist/v2/runtime/endpoints/hono.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/index.d.cts +2 -2
- package/dist/v2/runtime/endpoints/index.d.mts +2 -2
- package/dist/v2/runtime/endpoints/node-fetch-handler.cjs +26 -0
- package/dist/v2/runtime/endpoints/node-fetch-handler.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/node-fetch-handler.d.cts +12 -0
- package/dist/v2/runtime/endpoints/node-fetch-handler.d.cts.map +1 -0
- package/dist/v2/runtime/endpoints/node-fetch-handler.d.mts +12 -0
- package/dist/v2/runtime/endpoints/node-fetch-handler.d.mts.map +1 -0
- package/dist/v2/runtime/endpoints/node-fetch-handler.mjs +24 -0
- package/dist/v2/runtime/endpoints/node-fetch-handler.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/node.cjs +30 -0
- package/dist/v2/runtime/endpoints/node.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/node.d.cts +27 -0
- package/dist/v2/runtime/endpoints/node.d.cts.map +1 -0
- package/dist/v2/runtime/endpoints/node.d.mts +27 -0
- package/dist/v2/runtime/endpoints/node.d.mts.map +1 -0
- package/dist/v2/runtime/endpoints/node.mjs +30 -0
- package/dist/v2/runtime/endpoints/node.mjs.map +1 -0
- package/dist/v2/runtime/express.d.cts +3 -0
- package/dist/v2/runtime/express.d.mts +3 -0
- package/dist/v2/runtime/handlers/get-runtime-info.cjs +2 -1
- package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.mjs +2 -1
- package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-connect.cjs +6 -3
- package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-connect.mjs +6 -3
- package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-run.cjs +6 -3
- package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-run.mjs +6 -3
- package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-stop.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-stop.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-transcribe.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-transcribe.mjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.cjs +22 -1
- package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/run.mjs +22 -1
- package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/thread-names.cjs +1 -1
- package/dist/v2/runtime/handlers/intelligence/thread-names.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/thread-names.mjs +1 -1
- package/dist/v2/runtime/handlers/intelligence/thread-names.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs +21 -6
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs +21 -6
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/json-response.cjs +4 -1
- package/dist/v2/runtime/handlers/shared/json-response.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/json-response.mjs +4 -1
- package/dist/v2/runtime/handlers/shared/json-response.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/connect.mjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
- package/dist/v2/runtime/hono.d.cts +3 -0
- package/dist/v2/runtime/hono.d.mts +3 -0
- package/dist/v2/runtime/index.d.cts +16 -4
- package/dist/v2/runtime/index.d.cts.map +1 -0
- package/dist/v2/runtime/index.d.mts +16 -4
- package/dist/v2/runtime/index.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/client.cjs +10 -1
- package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.cts +22 -0
- package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.mts +22 -0
- package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs +10 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
- package/dist/v2/runtime/node.d.cts +3 -0
- package/dist/v2/runtime/node.d.mts +3 -0
- package/dist/v2/runtime/open-generative-ui-middleware.cjs +282 -0
- package/dist/v2/runtime/open-generative-ui-middleware.cjs.map +1 -0
- package/dist/v2/runtime/open-generative-ui-middleware.mjs +280 -0
- package/dist/v2/runtime/open-generative-ui-middleware.mjs.map +1 -0
- package/dist/v2/runtime/runner/intelligence.cjs +4 -4
- package/dist/v2/runtime/runner/intelligence.cjs.map +1 -1
- package/dist/v2/runtime/runner/intelligence.d.cts +6 -2
- package/dist/v2/runtime/runner/intelligence.d.cts.map +1 -1
- package/dist/v2/runtime/runner/intelligence.d.mts +6 -2
- package/dist/v2/runtime/runner/intelligence.d.mts.map +1 -1
- package/dist/v2/runtime/runner/intelligence.mjs +4 -4
- package/dist/v2/runtime/runner/intelligence.mjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.cjs +37 -0
- package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.mjs +36 -0
- package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
- package/dist/v2/runtime/telemetry/utils.cjs +15 -0
- package/dist/v2/runtime/telemetry/utils.cjs.map +1 -0
- package/dist/v2/runtime/telemetry/utils.mjs +14 -0
- package/dist/v2/runtime/telemetry/utils.mjs.map +1 -0
- package/package.json +81 -48
- package/src/agent/__tests__/multimodal.test.ts +176 -0
- package/src/agent/index.ts +130 -19
- package/src/lib/runtime/agent-integrations/langgraph/agent.ts +3 -3
- package/src/lib/runtime/copilot-runtime.ts +1 -0
- package/src/v2/express.ts +1 -0
- package/src/v2/hono.ts +1 -0
- package/src/v2/node.ts +1 -0
- package/src/v2/runtime/__tests__/backward-compat.test.ts +261 -0
- package/src/v2/runtime/__tests__/code-review-fixes.test.ts +500 -0
- package/src/v2/runtime/__tests__/cors-credentials.test.ts +2 -2
- package/src/v2/runtime/__tests__/express-adapter.test.ts +188 -0
- package/src/v2/runtime/__tests__/express-body-order.test.ts +1 -1
- package/src/v2/runtime/__tests__/express-fetch-bridge.test.ts +344 -0
- package/src/v2/runtime/__tests__/express-single-sse.test.ts +1 -1
- package/src/v2/runtime/__tests__/fetch-cors.test.ts +205 -0
- package/src/v2/runtime/__tests__/fetch-handler-validation.test.ts +372 -0
- package/src/v2/runtime/__tests__/fetch-handler.test.ts +456 -0
- package/src/v2/runtime/__tests__/fetch-router.test.ts +132 -0
- package/src/v2/runtime/__tests__/get-runtime-info.test.ts +4 -1
- package/src/v2/runtime/__tests__/handle-connect.test.ts +15 -13
- package/src/v2/runtime/__tests__/handle-run.test.ts +21 -17
- package/src/v2/runtime/__tests__/handle-threads.test.ts +1 -1
- package/src/v2/runtime/__tests__/handle-transcribe.test.ts +1 -1
- package/src/v2/runtime/__tests__/hono-adapter.test.ts +150 -0
- package/src/v2/runtime/__tests__/hooks-edge-cases.test.ts +457 -0
- package/src/v2/runtime/__tests__/hooks.test.ts +557 -0
- package/src/v2/runtime/__tests__/integration/bun/bun-servers.integration.test.ts +27 -0
- package/src/v2/runtime/__tests__/integration/bun/elysia-multi.ts +32 -0
- package/src/v2/runtime/__tests__/integration/bun/elysia-single.ts +33 -0
- package/src/v2/runtime/__tests__/integration/bun/hono-bun-multi.ts +25 -0
- package/src/v2/runtime/__tests__/integration/bun/hono-bun-single.ts +32 -0
- package/src/v2/runtime/__tests__/integration/helpers/create-test-runtime.ts +15 -0
- package/src/v2/runtime/__tests__/integration/helpers/sse-reader.ts +45 -0
- package/src/v2/runtime/__tests__/integration/helpers/test-agent.ts +58 -0
- package/src/v2/runtime/__tests__/integration/node-servers.integration.test.ts +39 -0
- package/src/v2/runtime/__tests__/integration/servers/express-multi.ts +35 -0
- package/src/v2/runtime/__tests__/integration/servers/express-single.ts +36 -0
- package/src/v2/runtime/__tests__/integration/servers/fetch-direct.ts +39 -0
- package/src/v2/runtime/__tests__/integration/servers/hono-multi.ts +30 -0
- package/src/v2/runtime/__tests__/integration/servers/hono-single.ts +37 -0
- package/src/v2/runtime/__tests__/integration/servers/node-multi.ts +45 -0
- package/src/v2/runtime/__tests__/integration/servers/node-single.ts +46 -0
- package/src/v2/runtime/__tests__/integration/servers/types.ts +18 -0
- package/src/v2/runtime/__tests__/integration/suites/multi-endpoint.suite.ts +358 -0
- package/src/v2/runtime/__tests__/integration/suites/single-endpoint.suite.ts +363 -0
- package/src/v2/runtime/__tests__/middleware-express.test.ts +25 -23
- package/src/v2/runtime/__tests__/middleware-single-express.test.ts +25 -23
- package/src/v2/runtime/__tests__/middleware-single.test.ts +1 -1
- package/src/v2/runtime/__tests__/middleware-sse-parser.test.ts +1 -1
- package/src/v2/runtime/__tests__/middleware.test.ts +1 -2
- package/src/v2/runtime/__tests__/node-fetch-handler.test.ts +157 -0
- package/src/v2/runtime/__tests__/open-generative-ui-middleware.e2e.test.ts +728 -0
- package/src/v2/runtime/__tests__/router-edge-cases.test.ts +217 -0
- package/src/v2/runtime/__tests__/routing-express.test.ts +1 -1
- package/src/v2/runtime/__tests__/routing-single-express.test.ts +1 -1
- package/src/v2/runtime/__tests__/routing-single.test.ts +1 -1
- package/src/v2/runtime/__tests__/routing.test.ts +1 -1
- package/src/v2/runtime/__tests__/runtime.test.ts +110 -1
- package/src/v2/runtime/__tests__/telemetry.test.ts +62 -1
- package/src/v2/runtime/core/fetch-cors.ts +136 -0
- package/src/v2/runtime/core/fetch-handler.ts +415 -0
- package/src/v2/runtime/core/fetch-router.ts +112 -0
- package/src/v2/runtime/core/hooks.ts +151 -0
- package/src/v2/runtime/{runtime.ts → core/runtime.ts} +79 -10
- package/src/v2/runtime/endpoints/express-fetch-bridge.ts +137 -0
- package/src/v2/runtime/endpoints/express-single.ts +42 -219
- package/src/v2/runtime/endpoints/express.ts +128 -230
- package/src/v2/runtime/endpoints/hono-single.ts +19 -171
- package/src/v2/runtime/endpoints/hono.ts +45 -270
- package/src/v2/runtime/endpoints/node-fetch-handler.ts +48 -0
- package/src/v2/runtime/endpoints/node.ts +28 -0
- package/src/v2/runtime/handlers/get-runtime-info.ts +3 -2
- package/src/v2/runtime/handlers/handle-connect.ts +7 -4
- package/src/v2/runtime/handlers/handle-run.ts +7 -4
- package/src/v2/runtime/handlers/handle-stop.ts +1 -1
- package/src/v2/runtime/handlers/handle-transcribe.ts +1 -1
- package/src/v2/runtime/handlers/intelligence/connect.ts +1 -1
- package/src/v2/runtime/handlers/intelligence/run.ts +31 -1
- package/src/v2/runtime/handlers/intelligence/thread-names.ts +2 -2
- package/src/v2/runtime/handlers/intelligence/threads.ts +1 -1
- package/src/v2/runtime/handlers/shared/agent-utils.ts +29 -10
- package/src/v2/runtime/handlers/shared/json-response.ts +4 -1
- package/src/v2/runtime/handlers/shared/resolve-intelligence-user.ts +1 -1
- package/src/v2/runtime/handlers/sse/connect.ts +1 -1
- package/src/v2/runtime/handlers/sse/run.ts +1 -1
- package/src/v2/runtime/hono.ts +2 -0
- package/src/v2/runtime/index.ts +27 -1
- package/src/v2/runtime/intelligence-platform/client.ts +50 -1
- package/src/v2/runtime/node.ts +6 -0
- package/src/v2/runtime/open-generative-ui-middleware.ts +373 -0
- package/src/v2/runtime/runner/intelligence.ts +14 -4
- package/src/v2/runtime/telemetry/telemetry-client.ts +56 -0
- package/src/v2/runtime/telemetry/utils.ts +15 -0
- package/tsdown.config.ts +8 -1
- package/vitest.config.mjs +2 -5
- package/.eslintrc.js +0 -7
- package/dist/v2/runtime/endpoints/express-utils.cjs +0 -119
- package/dist/v2/runtime/endpoints/express-utils.cjs.map +0 -1
- package/dist/v2/runtime/endpoints/express-utils.mjs +0 -117
- package/dist/v2/runtime/endpoints/express-utils.mjs.map +0 -1
- package/dist/v2/runtime/handlers/intelligence/threads.cjs +0 -159
- package/dist/v2/runtime/handlers/intelligence/threads.cjs.map +0 -1
- package/dist/v2/runtime/handlers/intelligence/threads.mjs +0 -154
- package/dist/v2/runtime/handlers/intelligence/threads.mjs.map +0 -1
- package/dist/v2/runtime/middleware-sse-parser.cjs.map +0 -1
- package/dist/v2/runtime/middleware-sse-parser.d.cts.map +0 -1
- package/dist/v2/runtime/middleware-sse-parser.d.mts.map +0 -1
- package/dist/v2/runtime/middleware-sse-parser.mjs.map +0 -1
- package/dist/v2/runtime/middleware.cjs.map +0 -1
- package/dist/v2/runtime/middleware.d.cts.map +0 -1
- package/dist/v2/runtime/middleware.d.mts.map +0 -1
- package/dist/v2/runtime/middleware.mjs.map +0 -1
- package/dist/v2/runtime/runtime.cjs.map +0 -1
- package/dist/v2/runtime/runtime.d.cts.map +0 -1
- package/dist/v2/runtime/runtime.d.mts.map +0 -1
- package/dist/v2/runtime/runtime.mjs.map +0 -1
- package/src/v2/runtime/__tests__/express-abort-signal.test.ts +0 -25
- package/src/v2/runtime/endpoints/express-utils.ts +0 -182
- package/src/v2/runtime/handler.ts +0 -3
- /package/src/v2/runtime/{middleware-sse-parser.ts → core/middleware-sse-parser.ts} +0 -0
- /package/src/v2/runtime/{middleware.ts → core/middleware.ts} +0 -0
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
|
2
|
+
import type { ServerHandle } from "../servers/types";
|
|
3
|
+
import { readSSEStream, extractEventTypes } from "../helpers/sse-reader";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Shared single-endpoint test suite.
|
|
7
|
+
*
|
|
8
|
+
* In single-route mode, all operations go through a single POST endpoint
|
|
9
|
+
* with a JSON envelope: { method, params?, body? }
|
|
10
|
+
*/
|
|
11
|
+
export function singleEndpointSuite(
|
|
12
|
+
name: string,
|
|
13
|
+
factory: (opts?: {
|
|
14
|
+
capturedHeaders?: Record<string, string>[];
|
|
15
|
+
}) => Promise<ServerHandle & { handler?: (r: Request) => Promise<Response> }>,
|
|
16
|
+
requestFn?: (
|
|
17
|
+
input: RequestInfo | URL,
|
|
18
|
+
init?: RequestInit,
|
|
19
|
+
) => Promise<Response>,
|
|
20
|
+
) {
|
|
21
|
+
describe(`[${name}] Single-Endpoint`, () => {
|
|
22
|
+
let handle: ServerHandle & { handler?: (r: Request) => Promise<Response> };
|
|
23
|
+
let doFetch: (
|
|
24
|
+
input: RequestInfo | URL,
|
|
25
|
+
init?: RequestInit,
|
|
26
|
+
) => Promise<Response>;
|
|
27
|
+
|
|
28
|
+
beforeAll(async () => {
|
|
29
|
+
handle = await factory();
|
|
30
|
+
doFetch =
|
|
31
|
+
requestFn ??
|
|
32
|
+
(handle.handler
|
|
33
|
+
? (input, init) =>
|
|
34
|
+
handle.handler!(
|
|
35
|
+
new Request(
|
|
36
|
+
typeof input === "string" || input instanceof URL
|
|
37
|
+
? input
|
|
38
|
+
: input,
|
|
39
|
+
init,
|
|
40
|
+
),
|
|
41
|
+
)
|
|
42
|
+
: fetch);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
afterAll(async () => {
|
|
46
|
+
await handle?.close();
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
const endpoint = () => `${handle.baseUrl}${handle.basePath}`;
|
|
50
|
+
|
|
51
|
+
function postEnvelope(
|
|
52
|
+
envelope: Record<string, unknown>,
|
|
53
|
+
extraHeaders?: Record<string, string>,
|
|
54
|
+
) {
|
|
55
|
+
return doFetch(endpoint(), {
|
|
56
|
+
method: "POST",
|
|
57
|
+
headers: {
|
|
58
|
+
"Content-Type": "application/json",
|
|
59
|
+
...extraHeaders,
|
|
60
|
+
},
|
|
61
|
+
body: JSON.stringify(envelope),
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// ─── Info ────────────────────────────────────────────────────────
|
|
66
|
+
|
|
67
|
+
describe("Info", () => {
|
|
68
|
+
it("method: info returns 200 with runtime info", async () => {
|
|
69
|
+
const res = await postEnvelope({ method: "info" });
|
|
70
|
+
expect(res.status).toBe(200);
|
|
71
|
+
const body = await res.json();
|
|
72
|
+
expect(body).toHaveProperty("version");
|
|
73
|
+
expect(body).toHaveProperty("agents");
|
|
74
|
+
expect(body.agents).toHaveProperty("default");
|
|
75
|
+
expect(body).toHaveProperty("audioFileTranscriptionEnabled", false);
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
// ─── Agent Run ───────────────────────────────────────────────────
|
|
80
|
+
|
|
81
|
+
describe("Agent Run", () => {
|
|
82
|
+
it("method: agent/run returns SSE stream", async () => {
|
|
83
|
+
const res = await postEnvelope({
|
|
84
|
+
method: "agent/run",
|
|
85
|
+
params: { agentId: "default" },
|
|
86
|
+
body: {
|
|
87
|
+
threadId: "t-srun-1",
|
|
88
|
+
runId: "r-srun-1",
|
|
89
|
+
messages: [],
|
|
90
|
+
state: {},
|
|
91
|
+
tools: [],
|
|
92
|
+
context: [],
|
|
93
|
+
forwardedProps: {},
|
|
94
|
+
},
|
|
95
|
+
});
|
|
96
|
+
expect(res.status).toBe(200);
|
|
97
|
+
expect(res.headers.get("content-type")).toContain("text/event-stream");
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
it("SSE stream contains correct event sequence", async () => {
|
|
101
|
+
const res = await postEnvelope({
|
|
102
|
+
method: "agent/run",
|
|
103
|
+
params: { agentId: "default" },
|
|
104
|
+
body: {
|
|
105
|
+
threadId: "t-srun-2",
|
|
106
|
+
runId: "r-srun-2",
|
|
107
|
+
messages: [],
|
|
108
|
+
state: {},
|
|
109
|
+
tools: [],
|
|
110
|
+
context: [],
|
|
111
|
+
forwardedProps: {},
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
const payload = await readSSEStream(res.body!);
|
|
115
|
+
const types = extractEventTypes(payload);
|
|
116
|
+
|
|
117
|
+
expect(types).toContain("RUN_STARTED");
|
|
118
|
+
expect(types).toContain("TEXT_MESSAGE_CONTENT");
|
|
119
|
+
expect(types).toContain("RUN_FINISHED");
|
|
120
|
+
});
|
|
121
|
+
|
|
122
|
+
it("SSE stream contains expected delta text", async () => {
|
|
123
|
+
const res = await postEnvelope({
|
|
124
|
+
method: "agent/run",
|
|
125
|
+
params: { agentId: "default" },
|
|
126
|
+
body: {
|
|
127
|
+
threadId: "t-srun-3",
|
|
128
|
+
runId: "r-srun-3",
|
|
129
|
+
messages: [],
|
|
130
|
+
state: {},
|
|
131
|
+
tools: [],
|
|
132
|
+
context: [],
|
|
133
|
+
forwardedProps: {},
|
|
134
|
+
},
|
|
135
|
+
});
|
|
136
|
+
const payload = await readSSEStream(res.body!);
|
|
137
|
+
expect(payload).toContain("Hello from test");
|
|
138
|
+
});
|
|
139
|
+
|
|
140
|
+
it("returns 404 for unknown agent", async () => {
|
|
141
|
+
const res = await postEnvelope({
|
|
142
|
+
method: "agent/run",
|
|
143
|
+
params: { agentId: "nonexistent" },
|
|
144
|
+
body: {
|
|
145
|
+
threadId: "t-s404",
|
|
146
|
+
runId: "r-s404",
|
|
147
|
+
messages: [],
|
|
148
|
+
state: {},
|
|
149
|
+
tools: [],
|
|
150
|
+
context: [],
|
|
151
|
+
forwardedProps: {},
|
|
152
|
+
},
|
|
153
|
+
});
|
|
154
|
+
expect(res.status).toBe(404);
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
|
|
158
|
+
// ─── Agent Connect ───────────────────────────────────────────────
|
|
159
|
+
|
|
160
|
+
describe("Agent Connect", () => {
|
|
161
|
+
it("method: agent/connect returns SSE stream", async () => {
|
|
162
|
+
const res = await postEnvelope({
|
|
163
|
+
method: "agent/connect",
|
|
164
|
+
params: { agentId: "default" },
|
|
165
|
+
body: {
|
|
166
|
+
threadId: "t-sconn-1",
|
|
167
|
+
runId: "r-sconn-1",
|
|
168
|
+
messages: [],
|
|
169
|
+
state: {},
|
|
170
|
+
tools: [],
|
|
171
|
+
context: [],
|
|
172
|
+
forwardedProps: {},
|
|
173
|
+
},
|
|
174
|
+
});
|
|
175
|
+
expect(res.status).toBe(200);
|
|
176
|
+
expect(res.headers.get("content-type")).toContain("text/event-stream");
|
|
177
|
+
});
|
|
178
|
+
|
|
179
|
+
it("returns 404 for unknown agent", async () => {
|
|
180
|
+
const res = await postEnvelope({
|
|
181
|
+
method: "agent/connect",
|
|
182
|
+
params: { agentId: "nonexistent" },
|
|
183
|
+
body: {
|
|
184
|
+
threadId: "t-sconn-404",
|
|
185
|
+
runId: "r-sconn-404",
|
|
186
|
+
messages: [],
|
|
187
|
+
state: {},
|
|
188
|
+
tools: [],
|
|
189
|
+
context: [],
|
|
190
|
+
forwardedProps: {},
|
|
191
|
+
},
|
|
192
|
+
});
|
|
193
|
+
expect(res.status).toBe(404);
|
|
194
|
+
});
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
// ─── Agent Stop ──────────────────────────────────────────────────
|
|
198
|
+
|
|
199
|
+
describe("Agent Stop", () => {
|
|
200
|
+
it("method: agent/stop returns stop result", async () => {
|
|
201
|
+
const res = await postEnvelope({
|
|
202
|
+
method: "agent/stop",
|
|
203
|
+
params: { agentId: "default", threadId: "t-sstop-1" },
|
|
204
|
+
});
|
|
205
|
+
expect(res.status).toBe(200);
|
|
206
|
+
const body = await res.json();
|
|
207
|
+
expect(body).toHaveProperty("stopped");
|
|
208
|
+
expect(typeof body.stopped).toBe("boolean");
|
|
209
|
+
});
|
|
210
|
+
|
|
211
|
+
it("returns 404 for unknown agent", async () => {
|
|
212
|
+
const res = await postEnvelope({
|
|
213
|
+
method: "agent/stop",
|
|
214
|
+
params: { agentId: "nonexistent", threadId: "t-sstop-404" },
|
|
215
|
+
});
|
|
216
|
+
expect(res.status).toBe(404);
|
|
217
|
+
});
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
// ─── Transcribe ──────────────────────────────────────────────────
|
|
221
|
+
|
|
222
|
+
describe("Transcribe", () => {
|
|
223
|
+
it("method: transcribe returns 503 without transcription service", async () => {
|
|
224
|
+
const res = await postEnvelope({
|
|
225
|
+
method: "transcribe",
|
|
226
|
+
body: {},
|
|
227
|
+
});
|
|
228
|
+
expect(res.status).toBe(503);
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
// ─── CORS ────────────────────────────────────────────────────────
|
|
233
|
+
|
|
234
|
+
describe("CORS", () => {
|
|
235
|
+
it("OPTIONS preflight returns CORS headers", async () => {
|
|
236
|
+
const res = await doFetch(endpoint(), {
|
|
237
|
+
method: "OPTIONS",
|
|
238
|
+
headers: {
|
|
239
|
+
Origin: "https://example.com",
|
|
240
|
+
"Access-Control-Request-Method": "POST",
|
|
241
|
+
},
|
|
242
|
+
});
|
|
243
|
+
expect(res.headers.get("access-control-allow-origin")).toBe("*");
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
it("POST response includes CORS headers", async () => {
|
|
247
|
+
const res = await postEnvelope({ method: "info" });
|
|
248
|
+
expect(res.headers.get("access-control-allow-origin")).toBe("*");
|
|
249
|
+
});
|
|
250
|
+
});
|
|
251
|
+
|
|
252
|
+
// ─── Error Handling ──────────────────────────────────────────────
|
|
253
|
+
|
|
254
|
+
describe("Error Handling", () => {
|
|
255
|
+
it("GET returns 405 or 404 (only POST allowed)", async () => {
|
|
256
|
+
const res = await doFetch(endpoint());
|
|
257
|
+
// Express single-route only mounts POST/OPTIONS, so GET may 404 at the
|
|
258
|
+
// framework layer before the fetch handler can return 405.
|
|
259
|
+
expect([404, 405]).toContain(res.status);
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
it("unknown method returns 400", async () => {
|
|
263
|
+
const res = await postEnvelope({ method: "unknown/method" });
|
|
264
|
+
expect(res.status).toBe(400);
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("missing agentId for agent/run returns 400", async () => {
|
|
268
|
+
const res = await postEnvelope({
|
|
269
|
+
method: "agent/run",
|
|
270
|
+
body: {
|
|
271
|
+
threadId: "t-err-1",
|
|
272
|
+
runId: "r-err-1",
|
|
273
|
+
messages: [],
|
|
274
|
+
state: {},
|
|
275
|
+
},
|
|
276
|
+
});
|
|
277
|
+
expect(res.status).toBe(400);
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
// ─── Header Forwarding ───────────────────────────────────────────
|
|
282
|
+
|
|
283
|
+
describe("Header Forwarding", () => {
|
|
284
|
+
it("forwards Authorization header to agent", async () => {
|
|
285
|
+
const captured: Record<string, string>[] = [];
|
|
286
|
+
const h = await factory({ capturedHeaders: captured });
|
|
287
|
+
const localFetch =
|
|
288
|
+
requestFn ??
|
|
289
|
+
((h as any).handler
|
|
290
|
+
? (input: any, init: any) =>
|
|
291
|
+
(h as any).handler(new Request(input, init))
|
|
292
|
+
: fetch);
|
|
293
|
+
|
|
294
|
+
try {
|
|
295
|
+
const res = await localFetch(`${h.baseUrl}${h.basePath}`, {
|
|
296
|
+
method: "POST",
|
|
297
|
+
headers: {
|
|
298
|
+
"Content-Type": "application/json",
|
|
299
|
+
Authorization: "Bearer test-token",
|
|
300
|
+
},
|
|
301
|
+
body: JSON.stringify({
|
|
302
|
+
method: "agent/run",
|
|
303
|
+
params: { agentId: "default" },
|
|
304
|
+
body: {
|
|
305
|
+
threadId: "t-shdr-1",
|
|
306
|
+
runId: "r-shdr-1",
|
|
307
|
+
messages: [],
|
|
308
|
+
state: {},
|
|
309
|
+
tools: [],
|
|
310
|
+
context: [],
|
|
311
|
+
forwardedProps: {},
|
|
312
|
+
},
|
|
313
|
+
}),
|
|
314
|
+
});
|
|
315
|
+
if (res.body) await readSSEStream(res.body);
|
|
316
|
+
expect(captured.length).toBeGreaterThan(0);
|
|
317
|
+
expect(captured[0]!.authorization).toBe("Bearer test-token");
|
|
318
|
+
} finally {
|
|
319
|
+
await h.close();
|
|
320
|
+
}
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
it("forwards x-custom headers to agent", async () => {
|
|
324
|
+
const captured: Record<string, string>[] = [];
|
|
325
|
+
const h = await factory({ capturedHeaders: captured });
|
|
326
|
+
const localFetch =
|
|
327
|
+
requestFn ??
|
|
328
|
+
((h as any).handler
|
|
329
|
+
? (input: any, init: any) =>
|
|
330
|
+
(h as any).handler(new Request(input, init))
|
|
331
|
+
: fetch);
|
|
332
|
+
|
|
333
|
+
try {
|
|
334
|
+
const res = await localFetch(`${h.baseUrl}${h.basePath}`, {
|
|
335
|
+
method: "POST",
|
|
336
|
+
headers: {
|
|
337
|
+
"Content-Type": "application/json",
|
|
338
|
+
"X-Custom-Value": "my-value",
|
|
339
|
+
},
|
|
340
|
+
body: JSON.stringify({
|
|
341
|
+
method: "agent/run",
|
|
342
|
+
params: { agentId: "default" },
|
|
343
|
+
body: {
|
|
344
|
+
threadId: "t-shdr-2",
|
|
345
|
+
runId: "r-shdr-2",
|
|
346
|
+
messages: [],
|
|
347
|
+
state: {},
|
|
348
|
+
tools: [],
|
|
349
|
+
context: [],
|
|
350
|
+
forwardedProps: {},
|
|
351
|
+
},
|
|
352
|
+
}),
|
|
353
|
+
});
|
|
354
|
+
if (res.body) await readSSEStream(res.body);
|
|
355
|
+
expect(captured.length).toBeGreaterThan(0);
|
|
356
|
+
expect(captured[0]!["x-custom-value"]).toBe("my-value");
|
|
357
|
+
} finally {
|
|
358
|
+
await h.close();
|
|
359
|
+
}
|
|
360
|
+
});
|
|
361
|
+
});
|
|
362
|
+
});
|
|
363
|
+
}
|
|
@@ -4,7 +4,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
4
4
|
import type { AbstractAgent } from "@ag-ui/client";
|
|
5
5
|
|
|
6
6
|
import { createCopilotEndpointExpress } from "../express";
|
|
7
|
-
import { CopilotRuntime } from "../runtime";
|
|
7
|
+
import { CopilotRuntime } from "../core/runtime";
|
|
8
8
|
import { logger } from "@copilotkit/shared";
|
|
9
9
|
|
|
10
10
|
const dummyRuntime = (opts: Partial<CopilotRuntime> = {}) => {
|
|
@@ -48,15 +48,15 @@ describe("CopilotEndpointExpress middleware", () => {
|
|
|
48
48
|
path: "/info",
|
|
49
49
|
});
|
|
50
50
|
|
|
51
|
-
await
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
);
|
|
51
|
+
await vi.waitFor(() => {
|
|
52
|
+
expect(after).toHaveBeenCalledWith(
|
|
53
|
+
expect.objectContaining({
|
|
54
|
+
runtime,
|
|
55
|
+
response: expect.any(Response),
|
|
56
|
+
path: "/info",
|
|
57
|
+
}),
|
|
58
|
+
);
|
|
59
|
+
});
|
|
60
60
|
|
|
61
61
|
expect(response.status).toBe(200);
|
|
62
62
|
expect(response.body).toHaveProperty("version");
|
|
@@ -142,8 +142,9 @@ describe("CopilotEndpointExpress middleware", () => {
|
|
|
142
142
|
|
|
143
143
|
expect(response.status).toBe(500);
|
|
144
144
|
expect(logSpy).toHaveBeenCalled();
|
|
145
|
-
await
|
|
146
|
-
|
|
145
|
+
await vi.waitFor(() => {
|
|
146
|
+
expect(after).toHaveBeenCalled();
|
|
147
|
+
});
|
|
147
148
|
});
|
|
148
149
|
|
|
149
150
|
it("passes parsed messages to afterRequestMiddleware", async () => {
|
|
@@ -159,10 +160,11 @@ describe("CopilotEndpointExpress middleware", () => {
|
|
|
159
160
|
const app = buildApp(runtime);
|
|
160
161
|
const response = await request(app).get("/info");
|
|
161
162
|
|
|
162
|
-
await
|
|
163
|
+
await vi.waitFor(() => {
|
|
164
|
+
expect(after).toHaveBeenCalled();
|
|
165
|
+
});
|
|
163
166
|
|
|
164
167
|
expect(response.status).toBe(200);
|
|
165
|
-
expect(after).toHaveBeenCalled();
|
|
166
168
|
expect(receivedParams).toHaveProperty("messages");
|
|
167
169
|
expect(receivedParams.messages).toEqual([]);
|
|
168
170
|
});
|
|
@@ -184,15 +186,15 @@ describe("CopilotEndpointExpress middleware", () => {
|
|
|
184
186
|
|
|
185
187
|
expect(response.status).toBe(200);
|
|
186
188
|
|
|
187
|
-
await
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
);
|
|
189
|
+
await vi.waitFor(() => {
|
|
190
|
+
expect(after).toHaveBeenCalledWith(
|
|
191
|
+
expect.objectContaining({
|
|
192
|
+
runtime,
|
|
193
|
+
response: expect.any(Response),
|
|
194
|
+
path: "/info",
|
|
195
|
+
}),
|
|
196
|
+
);
|
|
197
|
+
});
|
|
196
198
|
|
|
197
199
|
expect(logSpy).toHaveBeenCalledWith(
|
|
198
200
|
expect.objectContaining({
|
|
@@ -4,7 +4,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
4
4
|
import type { AbstractAgent } from "@ag-ui/client";
|
|
5
5
|
|
|
6
6
|
import { createCopilotEndpointSingleRouteExpress } from "../express";
|
|
7
|
-
import { CopilotRuntime } from "../runtime";
|
|
7
|
+
import { CopilotRuntime } from "../core/runtime";
|
|
8
8
|
import { logger } from "@copilotkit/shared";
|
|
9
9
|
|
|
10
10
|
const dummyRuntime = (opts: Partial<CopilotRuntime> = {}) => {
|
|
@@ -52,15 +52,15 @@ describe("CopilotEndpointSingleRouteExpress middleware", () => {
|
|
|
52
52
|
path: "/rpc",
|
|
53
53
|
});
|
|
54
54
|
|
|
55
|
-
await
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
);
|
|
55
|
+
await vi.waitFor(() => {
|
|
56
|
+
expect(after).toHaveBeenCalledWith(
|
|
57
|
+
expect.objectContaining({
|
|
58
|
+
runtime,
|
|
59
|
+
response: expect.any(Response),
|
|
60
|
+
path: "/rpc",
|
|
61
|
+
}),
|
|
62
|
+
);
|
|
63
|
+
});
|
|
64
64
|
|
|
65
65
|
expect(response.status).toBe(200);
|
|
66
66
|
expect(response.body).toHaveProperty("version");
|
|
@@ -147,8 +147,9 @@ describe("CopilotEndpointSingleRouteExpress middleware", () => {
|
|
|
147
147
|
|
|
148
148
|
expect(response.status).toBe(500);
|
|
149
149
|
expect(logSpy).toHaveBeenCalled();
|
|
150
|
-
await
|
|
151
|
-
|
|
150
|
+
await vi.waitFor(() => {
|
|
151
|
+
expect(after).toHaveBeenCalled();
|
|
152
|
+
});
|
|
152
153
|
});
|
|
153
154
|
|
|
154
155
|
it("passes parsed messages to afterRequestMiddleware", async () => {
|
|
@@ -164,10 +165,11 @@ describe("CopilotEndpointSingleRouteExpress middleware", () => {
|
|
|
164
165
|
const app = buildApp(runtime);
|
|
165
166
|
const response = await rpcRequest(app, { method: "info" });
|
|
166
167
|
|
|
167
|
-
await
|
|
168
|
+
await vi.waitFor(() => {
|
|
169
|
+
expect(after).toHaveBeenCalled();
|
|
170
|
+
});
|
|
168
171
|
|
|
169
172
|
expect(response.status).toBe(200);
|
|
170
|
-
expect(after).toHaveBeenCalled();
|
|
171
173
|
expect(receivedParams).toHaveProperty("messages");
|
|
172
174
|
expect(receivedParams.messages).toEqual([]);
|
|
173
175
|
});
|
|
@@ -189,15 +191,15 @@ describe("CopilotEndpointSingleRouteExpress middleware", () => {
|
|
|
189
191
|
|
|
190
192
|
expect(response.status).toBe(200);
|
|
191
193
|
|
|
192
|
-
await
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
);
|
|
194
|
+
await vi.waitFor(() => {
|
|
195
|
+
expect(after).toHaveBeenCalledWith(
|
|
196
|
+
expect.objectContaining({
|
|
197
|
+
runtime,
|
|
198
|
+
response: expect.any(Response),
|
|
199
|
+
path: "/rpc",
|
|
200
|
+
}),
|
|
201
|
+
);
|
|
202
|
+
});
|
|
201
203
|
|
|
202
204
|
expect(logSpy).toHaveBeenCalledWith(
|
|
203
205
|
expect.objectContaining({
|
|
@@ -2,7 +2,7 @@ import { afterEach, describe, expect, it, vi } from "vitest";
|
|
|
2
2
|
import type { AbstractAgent } from "@ag-ui/client";
|
|
3
3
|
|
|
4
4
|
import { createCopilotEndpointSingleRoute } from "../endpoints";
|
|
5
|
-
import { CopilotRuntime } from "../runtime";
|
|
5
|
+
import { CopilotRuntime } from "../core/runtime";
|
|
6
6
|
import { logger } from "@copilotkit/shared";
|
|
7
7
|
|
|
8
8
|
const dummyRuntime = (opts: Partial<CopilotRuntime> = {}) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
|
-
import { parseSSEResponse } from "../middleware-sse-parser";
|
|
2
|
+
import { parseSSEResponse } from "../core/middleware-sse-parser";
|
|
3
3
|
|
|
4
4
|
function buildSSEResponse(events: Record<string, unknown>[]): Response {
|
|
5
5
|
const body = events.map((e) => `data: ${JSON.stringify(e)}\n\n`).join("");
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { vi, type MockedFunction } from "vitest";
|
|
2
2
|
import { createCopilotEndpoint } from "../endpoints";
|
|
3
|
-
import { CopilotRuntime } from "../runtime";
|
|
3
|
+
import { CopilotRuntime } from "../core/runtime";
|
|
4
4
|
import { logger } from "@copilotkit/shared";
|
|
5
5
|
import type { AbstractAgent } from "@ag-ui/client";
|
|
6
|
-
import { WebhookStage } from "../middleware";
|
|
7
6
|
import { afterEach, describe, expect, it } from "vitest";
|
|
8
7
|
|
|
9
8
|
const dummyRuntime = (opts: Partial<CopilotRuntime> = {}) => {
|