@copilotkit/runtime 1.54.1-next.6 → 1.55.0-next.7
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/.eslintrc.js +4 -4
- package/CHANGELOG.md +117 -106
- package/dist/_virtual/_rolldown/runtime.mjs +25 -1
- package/dist/agent/index.cjs +643 -0
- package/dist/agent/index.cjs.map +1 -0
- package/dist/agent/index.d.cts +263 -0
- package/dist/agent/index.d.cts.map +1 -0
- package/dist/agent/index.d.mts +263 -0
- package/dist/agent/index.d.mts.map +1 -0
- package/dist/agent/index.mjs +635 -0
- package/dist/agent/index.mjs.map +1 -0
- package/dist/graphql/message-conversion/agui-to-gql.cjs.map +1 -1
- package/dist/graphql/message-conversion/agui-to-gql.mjs.map +1 -1
- package/dist/lib/integrations/nextjs/app-router.cjs +2 -2
- package/dist/lib/integrations/nextjs/app-router.cjs.map +1 -1
- package/dist/lib/integrations/nextjs/app-router.mjs +1 -1
- package/dist/lib/integrations/nextjs/app-router.mjs.map +1 -1
- package/dist/lib/integrations/node-http/index.cjs +2 -3
- package/dist/lib/integrations/node-http/index.cjs.map +1 -1
- package/dist/lib/integrations/node-http/index.mjs +1 -1
- package/dist/lib/integrations/node-http/index.mjs.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.cjs +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts +2 -2
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.mts +3 -3
- package/dist/lib/runtime/agent-integrations/langgraph/agent.d.mts.map +1 -1
- package/dist/lib/runtime/agent-integrations/langgraph/agent.mjs +1 -1
- package/dist/lib/runtime/copilot-runtime.cjs +7 -5
- package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.cts +10 -8
- package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.mts +10 -8
- package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.mjs +7 -5
- package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.cjs +2 -2
- package/dist/lib/runtime/telemetry-agent-runner.cjs.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.cts +2 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.cts.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.mts +2 -1
- package/dist/lib/runtime/telemetry-agent-runner.d.mts.map +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.mjs +1 -1
- package/dist/lib/runtime/telemetry-agent-runner.mjs.map +1 -1
- package/dist/lib/telemetry-client.cjs +1 -1
- package/dist/lib/telemetry-client.mjs +1 -1
- package/dist/package.cjs +21 -4
- package/dist/package.mjs +21 -4
- package/dist/service-adapters/anthropic/anthropic-adapter.d.mts +1 -1
- package/dist/v2/index.cjs +41 -15
- package/dist/v2/index.d.cts +14 -2
- package/dist/v2/index.d.mts +14 -2
- package/dist/v2/index.mjs +13 -4
- package/dist/v2/runtime/endpoints/express-single.cjs +190 -0
- package/dist/v2/runtime/endpoints/express-single.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/express-single.d.cts +16 -0
- package/dist/v2/runtime/endpoints/express-single.d.cts.map +1 -0
- package/dist/v2/runtime/endpoints/express-single.d.mts +16 -0
- package/dist/v2/runtime/endpoints/express-single.d.mts.map +1 -0
- package/dist/v2/runtime/endpoints/express-single.mjs +187 -0
- package/dist/v2/runtime/endpoints/express-single.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/express-utils.cjs +119 -0
- package/dist/v2/runtime/endpoints/express-utils.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/express-utils.mjs +117 -0
- package/dist/v2/runtime/endpoints/express-utils.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/express.cjs +217 -0
- package/dist/v2/runtime/endpoints/express.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/express.d.cts +16 -0
- package/dist/v2/runtime/endpoints/express.d.cts.map +1 -0
- package/dist/v2/runtime/endpoints/express.d.mts +16 -0
- package/dist/v2/runtime/endpoints/express.d.mts.map +1 -0
- package/dist/v2/runtime/endpoints/express.mjs +214 -0
- package/dist/v2/runtime/endpoints/express.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/hono-single.cjs +141 -0
- package/dist/v2/runtime/endpoints/hono-single.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/hono-single.d.cts +41 -0
- package/dist/v2/runtime/endpoints/hono-single.d.cts.map +1 -0
- package/dist/v2/runtime/endpoints/hono-single.d.mts +41 -0
- package/dist/v2/runtime/endpoints/hono-single.d.mts.map +1 -0
- package/dist/v2/runtime/endpoints/hono-single.mjs +140 -0
- package/dist/v2/runtime/endpoints/hono-single.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/hono.cjs +248 -0
- package/dist/v2/runtime/endpoints/hono.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/hono.d.cts +164 -0
- package/dist/v2/runtime/endpoints/hono.d.cts.map +1 -0
- package/dist/v2/runtime/endpoints/hono.d.mts +164 -0
- package/dist/v2/runtime/endpoints/hono.d.mts.map +1 -0
- package/dist/v2/runtime/endpoints/hono.mjs +247 -0
- package/dist/v2/runtime/endpoints/hono.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/index.d.cts +5 -0
- package/dist/v2/runtime/endpoints/index.d.mts +5 -0
- package/dist/v2/runtime/endpoints/single-route-helpers.cjs +68 -0
- package/dist/v2/runtime/endpoints/single-route-helpers.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/single-route-helpers.mjs +65 -0
- package/dist/v2/runtime/endpoints/single-route-helpers.mjs.map +1 -0
- package/dist/v2/runtime/handlers/get-runtime-info.cjs +51 -0
- package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -0
- package/dist/v2/runtime/handlers/get-runtime-info.mjs +51 -0
- package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-connect.cjs +49 -0
- package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-connect.mjs +49 -0
- package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-run.cjs +61 -0
- package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-run.mjs +61 -0
- package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-stop.cjs +47 -0
- package/dist/v2/runtime/handlers/handle-stop.cjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-stop.mjs +46 -0
- package/dist/v2/runtime/handlers/handle-stop.mjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-transcribe.cjs +112 -0
- package/dist/v2/runtime/handlers/handle-transcribe.cjs.map +1 -0
- package/dist/v2/runtime/handlers/handle-transcribe.mjs +111 -0
- package/dist/v2/runtime/handlers/handle-transcribe.mjs.map +1 -0
- package/dist/v2/runtime/handlers/header-utils.cjs +26 -0
- package/dist/v2/runtime/handlers/header-utils.cjs.map +1 -0
- package/dist/v2/runtime/handlers/header-utils.mjs +25 -0
- package/dist/v2/runtime/handlers/header-utils.mjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/connect.cjs +37 -0
- package/dist/v2/runtime/handlers/intelligence/connect.cjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/connect.mjs +37 -0
- package/dist/v2/runtime/handlers/intelligence/connect.mjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/run.cjs +89 -0
- package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/run.mjs +88 -0
- package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/thread-names.cjs +146 -0
- package/dist/v2/runtime/handlers/intelligence/thread-names.cjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/thread-names.mjs +145 -0
- package/dist/v2/runtime/handlers/intelligence/thread-names.mjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/threads.cjs +159 -0
- package/dist/v2/runtime/handlers/intelligence/threads.cjs.map +1 -0
- package/dist/v2/runtime/handlers/intelligence/threads.mjs +154 -0
- package/dist/v2/runtime/handlers/intelligence/threads.mjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs +74 -0
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs +70 -0
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/intelligence-utils.cjs +21 -0
- package/dist/v2/runtime/handlers/shared/intelligence-utils.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/intelligence-utils.mjs +20 -0
- package/dist/v2/runtime/handlers/shared/intelligence-utils.mjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/json-response.cjs +12 -0
- package/dist/v2/runtime/handlers/shared/json-response.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/json-response.mjs +10 -0
- package/dist/v2/runtime/handlers/shared/json-response.mjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs +20 -0
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs +20 -0
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/sse-response.cjs +69 -0
- package/dist/v2/runtime/handlers/shared/sse-response.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/sse-response.mjs +68 -0
- package/dist/v2/runtime/handlers/shared/sse-response.mjs.map +1 -0
- package/dist/v2/runtime/handlers/sse/connect.cjs +18 -0
- package/dist/v2/runtime/handlers/sse/connect.cjs.map +1 -0
- package/dist/v2/runtime/handlers/sse/connect.mjs +18 -0
- package/dist/v2/runtime/handlers/sse/connect.mjs.map +1 -0
- package/dist/v2/runtime/handlers/sse/run.cjs +18 -0
- package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -0
- package/dist/v2/runtime/handlers/sse/run.mjs +18 -0
- package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -0
- package/dist/v2/runtime/index.d.cts +13 -0
- package/dist/v2/runtime/index.d.mts +14 -0
- package/dist/v2/runtime/intelligence-platform/client.cjs +333 -0
- package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/client.d.cts +336 -0
- package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/client.d.mts +336 -0
- package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -0
- package/dist/v2/runtime/intelligence-platform/client.mjs +331 -0
- package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -0
- package/dist/v2/runtime/intelligence-platform/index.d.mts +2 -0
- package/dist/v2/runtime/middleware-sse-parser.cjs +138 -0
- package/dist/v2/runtime/middleware-sse-parser.cjs.map +1 -0
- package/dist/v2/runtime/middleware-sse-parser.d.cts +22 -0
- package/dist/v2/runtime/middleware-sse-parser.d.cts.map +1 -0
- package/dist/v2/runtime/middleware-sse-parser.d.mts +22 -0
- package/dist/v2/runtime/middleware-sse-parser.d.mts.map +1 -0
- package/dist/v2/runtime/middleware-sse-parser.mjs +137 -0
- package/dist/v2/runtime/middleware-sse-parser.mjs.map +1 -0
- package/dist/v2/runtime/middleware.cjs +35 -0
- package/dist/v2/runtime/middleware.cjs.map +1 -0
- package/dist/v2/runtime/middleware.d.cts +32 -0
- package/dist/v2/runtime/middleware.d.cts.map +1 -0
- package/dist/v2/runtime/middleware.d.mts +32 -0
- package/dist/v2/runtime/middleware.d.mts.map +1 -0
- package/dist/v2/runtime/middleware.mjs +33 -0
- package/dist/v2/runtime/middleware.mjs.map +1 -0
- package/dist/v2/runtime/runner/agent-runner.cjs +8 -0
- package/dist/v2/runtime/runner/agent-runner.cjs.map +1 -0
- package/dist/v2/runtime/runner/agent-runner.d.cts +32 -0
- package/dist/v2/runtime/runner/agent-runner.d.cts.map +1 -0
- package/dist/v2/runtime/runner/agent-runner.d.mts +32 -0
- package/dist/v2/runtime/runner/agent-runner.d.mts.map +1 -0
- package/dist/v2/runtime/runner/agent-runner.mjs +7 -0
- package/dist/v2/runtime/runner/agent-runner.mjs.map +1 -0
- package/dist/v2/runtime/runner/in-memory.cjs +223 -0
- package/dist/v2/runtime/runner/in-memory.cjs.map +1 -0
- package/dist/v2/runtime/runner/in-memory.d.cts +15 -0
- package/dist/v2/runtime/runner/in-memory.d.cts.map +1 -0
- package/dist/v2/runtime/runner/in-memory.d.mts +15 -0
- package/dist/v2/runtime/runner/in-memory.d.mts.map +1 -0
- package/dist/v2/runtime/runner/in-memory.mjs +222 -0
- package/dist/v2/runtime/runner/in-memory.mjs.map +1 -0
- package/dist/v2/runtime/runner/index.d.cts +6 -0
- package/dist/v2/runtime/runner/index.d.mts +6 -0
- package/dist/v2/runtime/runner/index.mjs +7 -0
- package/dist/v2/runtime/runner/intelligence.cjs +246 -0
- package/dist/v2/runtime/runner/intelligence.cjs.map +1 -0
- package/dist/v2/runtime/runner/intelligence.d.cts +57 -0
- package/dist/v2/runtime/runner/intelligence.d.cts.map +1 -0
- package/dist/v2/runtime/runner/intelligence.d.mts +57 -0
- package/dist/v2/runtime/runner/intelligence.d.mts.map +1 -0
- package/dist/v2/runtime/runner/intelligence.mjs +245 -0
- package/dist/v2/runtime/runner/intelligence.mjs.map +1 -0
- package/dist/v2/runtime/runtime.cjs +101 -0
- package/dist/v2/runtime/runtime.cjs.map +1 -0
- package/dist/v2/runtime/runtime.d.cts +132 -0
- package/dist/v2/runtime/runtime.d.cts.map +1 -0
- package/dist/v2/runtime/runtime.d.mts +133 -0
- package/dist/v2/runtime/runtime.d.mts.map +1 -0
- package/dist/v2/runtime/runtime.mjs +97 -0
- package/dist/v2/runtime/runtime.mjs.map +1 -0
- package/dist/v2/runtime/telemetry/scarf-client.cjs +32 -0
- package/dist/v2/runtime/telemetry/scarf-client.cjs.map +1 -0
- package/dist/v2/runtime/telemetry/scarf-client.mjs +32 -0
- package/dist/v2/runtime/telemetry/scarf-client.mjs.map +1 -0
- package/dist/v2/runtime/telemetry/telemetry-client.cjs +35 -0
- package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -0
- package/dist/v2/runtime/telemetry/telemetry-client.mjs +35 -0
- package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -0
- package/dist/v2/runtime/transcription-service/transcription-service.cjs +8 -0
- package/dist/v2/runtime/transcription-service/transcription-service.cjs.map +1 -0
- package/dist/v2/runtime/transcription-service/transcription-service.d.cts +15 -0
- package/dist/v2/runtime/transcription-service/transcription-service.d.cts.map +1 -0
- package/dist/v2/runtime/transcription-service/transcription-service.d.mts +15 -0
- package/dist/v2/runtime/transcription-service/transcription-service.d.mts.map +1 -0
- package/dist/v2/runtime/transcription-service/transcription-service.mjs +7 -0
- package/dist/v2/runtime/transcription-service/transcription-service.mjs.map +1 -0
- package/package.json +22 -5
- package/src/agent/__tests__/ai-sdk-v6-compat.test.ts +116 -0
- package/src/agent/__tests__/basic-agent.test.ts +1248 -0
- package/src/agent/__tests__/config-tools-execution.test.ts +516 -0
- package/src/agent/__tests__/mcp-clients.test.ts +260 -0
- package/src/agent/__tests__/property-overrides.test.ts +598 -0
- package/src/agent/__tests__/standard-schema-tools.test.ts +313 -0
- package/src/agent/__tests__/standard-schema-types.test.ts +158 -0
- package/src/agent/__tests__/state-tools.test.ts +436 -0
- package/src/agent/__tests__/test-helpers.ts +178 -0
- package/src/agent/__tests__/utils.test.ts +536 -0
- package/src/agent/__tests__/zod-regression.test.ts +350 -0
- package/src/agent/index.ts +1305 -0
- package/src/graphql/message-conversion/agui-to-gql.test.ts +1 -1
- package/src/graphql/message-conversion/agui-to-gql.ts +1 -1
- package/src/graphql/message-conversion/gql-to-agui.ts +1 -1
- package/src/graphql/message-conversion/roundtrip-conversion.test.ts +1 -1
- package/src/lib/integrations/nextjs/app-router.ts +2 -2
- package/src/lib/integrations/node-http/index.ts +2 -2
- package/src/lib/runtime/copilot-runtime.ts +3 -5
- package/src/lib/runtime/telemetry-agent-runner.ts +1 -1
- package/src/service-adapters/conversion.test.ts +1 -1
- package/src/service-adapters/conversion.ts +1 -28
- package/src/v2/index.ts +5 -2
- package/src/v2/runtime/__tests__/cors-credentials.test.ts +320 -0
- package/src/v2/runtime/__tests__/express-abort-signal.test.ts +25 -0
- package/src/v2/runtime/__tests__/express-body-order.test.ts +76 -0
- package/src/v2/runtime/__tests__/express-single-sse.test.ts +122 -0
- package/src/v2/runtime/__tests__/get-runtime-info.test.ts +141 -0
- package/src/v2/runtime/__tests__/handle-connect.test.ts +423 -0
- package/src/v2/runtime/__tests__/handle-run.test.ts +910 -0
- package/src/v2/runtime/__tests__/handle-threads.test.ts +388 -0
- package/src/v2/runtime/__tests__/handle-transcribe.test.ts +301 -0
- package/src/v2/runtime/__tests__/header-utils.test.ts +88 -0
- package/src/v2/runtime/__tests__/in-process-agent-runner-messages.test.ts +230 -0
- package/src/v2/runtime/__tests__/in-process-agent-runner.test.ts +1030 -0
- package/src/v2/runtime/__tests__/middleware-express.test.ts +206 -0
- package/src/v2/runtime/__tests__/middleware-single-express.test.ts +211 -0
- package/src/v2/runtime/__tests__/middleware-single.test.ts +225 -0
- package/src/v2/runtime/__tests__/middleware-sse-parser.test.ts +187 -0
- package/src/v2/runtime/__tests__/middleware.test.ts +251 -0
- package/src/v2/runtime/__tests__/routing-express.test.ts +174 -0
- package/src/v2/runtime/__tests__/routing-single-express.test.ts +168 -0
- package/src/v2/runtime/__tests__/routing-single.test.ts +193 -0
- package/src/v2/runtime/__tests__/routing.test.ts +257 -0
- package/src/v2/runtime/__tests__/runtime.test.ts +123 -0
- package/src/v2/runtime/__tests__/telemetry.test.ts +167 -0
- package/src/v2/runtime/__tests__/thread-names.test.ts +188 -0
- package/src/v2/runtime/endpoints/express-single.ts +231 -0
- package/src/v2/runtime/endpoints/express-utils.ts +182 -0
- package/src/v2/runtime/endpoints/express.ts +275 -0
- package/src/v2/runtime/endpoints/hono-single.ts +212 -0
- package/src/v2/runtime/endpoints/hono.ts +314 -0
- package/src/v2/runtime/endpoints/index.ts +4 -0
- package/src/v2/runtime/endpoints/single-route-helpers.ts +125 -0
- package/src/v2/runtime/express.ts +2 -0
- package/src/v2/runtime/handler.ts +3 -0
- package/src/v2/runtime/handlers/get-runtime-info.ts +79 -0
- package/src/v2/runtime/handlers/handle-connect.ts +76 -0
- package/src/v2/runtime/handlers/handle-run.ts +89 -0
- package/src/v2/runtime/handlers/handle-stop.ts +76 -0
- package/src/v2/runtime/handlers/handle-threads.ts +7 -0
- package/src/v2/runtime/handlers/handle-transcribe.ts +256 -0
- package/src/v2/runtime/handlers/header-utils.ts +24 -0
- package/src/v2/runtime/handlers/intelligence/connect.ts +65 -0
- package/src/v2/runtime/handlers/intelligence/run.ts +152 -0
- package/src/v2/runtime/handlers/intelligence/thread-names.ts +246 -0
- package/src/v2/runtime/handlers/intelligence/threads.ts +233 -0
- package/src/v2/runtime/handlers/shared/agent-utils.ts +136 -0
- package/src/v2/runtime/handlers/shared/intelligence-utils.ts +21 -0
- package/src/v2/runtime/handlers/shared/json-response.ts +6 -0
- package/src/v2/runtime/handlers/shared/resolve-intelligence-user.ts +25 -0
- package/src/v2/runtime/handlers/shared/sse-response.ts +100 -0
- package/src/v2/runtime/handlers/sse/connect.ts +24 -0
- package/src/v2/runtime/handlers/sse/run.ts +27 -0
- package/src/v2/runtime/index.ts +20 -0
- package/src/v2/runtime/intelligence-platform/__tests__/client.test.ts +605 -0
- package/src/v2/runtime/intelligence-platform/client.ts +659 -0
- package/src/v2/runtime/intelligence-platform/index.ts +10 -0
- package/src/v2/runtime/middleware-sse-parser.ts +200 -0
- package/src/v2/runtime/middleware.ts +115 -0
- package/src/v2/runtime/runner/__tests__/finalize-events.test.ts +109 -0
- package/src/v2/runtime/runner/__tests__/in-memory-runner.e2e.test.ts +775 -0
- package/src/v2/runtime/runner/__tests__/in-memory-runner.test.ts +363 -0
- package/src/v2/runtime/runner/__tests__/intelligence-runner.test.ts +981 -0
- package/src/v2/runtime/runner/agent-runner.ts +36 -0
- package/src/v2/runtime/runner/in-memory.ts +381 -0
- package/src/v2/runtime/runner/index.ts +4 -0
- package/src/v2/runtime/runner/intelligence.ts +429 -0
- package/src/v2/runtime/runtime.ts +260 -0
- package/src/v2/runtime/telemetry/events.ts +35 -0
- package/src/v2/runtime/telemetry/index.ts +7 -0
- package/src/v2/runtime/telemetry/scarf-client.ts +39 -0
- package/src/v2/runtime/telemetry/telemetry-client.ts +70 -0
- package/src/v2/runtime/transcription-service/transcription-service.ts +11 -0
- package/tsconfig.json +9 -2
- package/tsdown.config.ts +1 -0
|
@@ -0,0 +1,350 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Regression tests proving that the agent package's defineTool and
|
|
3
|
+
* convertToolDefinitionsToVercelAITools still work identically with
|
|
4
|
+
* Zod schemas after the Standard Schema migration.
|
|
5
|
+
*
|
|
6
|
+
* Covers:
|
|
7
|
+
* 1. defineTool with complex Zod schemas
|
|
8
|
+
* 2. convertToolDefinitionsToVercelAITools passes Zod schemas directly
|
|
9
|
+
* (not through JSON Schema conversion — critical behavioral regression)
|
|
10
|
+
* 3. BuiltInAgent with Zod tools still works end-to-end
|
|
11
|
+
* 4. execute callback receives correctly shaped args
|
|
12
|
+
*/
|
|
13
|
+
import { describe, it, expect, vi, beforeEach, afterEach } from "vitest";
|
|
14
|
+
import { z } from "zod";
|
|
15
|
+
import {
|
|
16
|
+
defineTool,
|
|
17
|
+
convertToolDefinitionsToVercelAITools,
|
|
18
|
+
BuiltInAgent,
|
|
19
|
+
} from "../index";
|
|
20
|
+
import type { RunAgentInput } from "@ag-ui/client";
|
|
21
|
+
import { streamText } from "ai";
|
|
22
|
+
import { mockStreamTextResponse, finish, collectEvents } from "./test-helpers";
|
|
23
|
+
|
|
24
|
+
vi.mock("ai", async () => {
|
|
25
|
+
const actual = await vi.importActual("ai");
|
|
26
|
+
return {
|
|
27
|
+
...actual,
|
|
28
|
+
streamText: vi.fn(),
|
|
29
|
+
tool: vi.fn((config) => config),
|
|
30
|
+
stepCountIs: vi.fn((count: number) => ({ type: "stepCount", count })),
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
vi.mock("@ai-sdk/openai", () => ({
|
|
35
|
+
createOpenAI: vi.fn(() => (modelId: string) => ({
|
|
36
|
+
modelId,
|
|
37
|
+
provider: "openai",
|
|
38
|
+
})),
|
|
39
|
+
}));
|
|
40
|
+
|
|
41
|
+
describe("defineTool Zod regression", () => {
|
|
42
|
+
it("complex Zod schema with nested objects, arrays, unions", () => {
|
|
43
|
+
const tool = defineTool({
|
|
44
|
+
name: "complexTool",
|
|
45
|
+
description: "A complex tool",
|
|
46
|
+
parameters: z.object({
|
|
47
|
+
query: z.string().describe("Search query"),
|
|
48
|
+
filters: z
|
|
49
|
+
.object({
|
|
50
|
+
category: z.enum(["books", "movies", "music"]).optional(),
|
|
51
|
+
minRating: z.number().min(0).max(5).optional(),
|
|
52
|
+
tags: z.array(z.string()).optional(),
|
|
53
|
+
})
|
|
54
|
+
.optional(),
|
|
55
|
+
pagination: z
|
|
56
|
+
.object({
|
|
57
|
+
page: z.number().int().positive().default(1),
|
|
58
|
+
perPage: z.number().int().positive().default(20),
|
|
59
|
+
})
|
|
60
|
+
.optional(),
|
|
61
|
+
}),
|
|
62
|
+
execute: async (args) => {
|
|
63
|
+
return { query: args.query };
|
|
64
|
+
},
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
expect(tool.name).toBe("complexTool");
|
|
68
|
+
expect(tool.parameters["~standard"].vendor).toBe("zod");
|
|
69
|
+
expect(tool.parameters["~standard"].version).toBe(1);
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
it("Zod schema with discriminated union", () => {
|
|
73
|
+
const tool = defineTool({
|
|
74
|
+
name: "actionTool",
|
|
75
|
+
description: "An action tool",
|
|
76
|
+
parameters: z.object({
|
|
77
|
+
action: z.discriminatedUnion("type", [
|
|
78
|
+
z.object({ type: z.literal("search"), query: z.string() }),
|
|
79
|
+
z.object({ type: z.literal("navigate"), url: z.string().url() }),
|
|
80
|
+
z.object({
|
|
81
|
+
type: z.literal("execute"),
|
|
82
|
+
code: z.string(),
|
|
83
|
+
language: z.enum(["javascript", "python"]),
|
|
84
|
+
}),
|
|
85
|
+
]),
|
|
86
|
+
}),
|
|
87
|
+
execute: async (args) => {
|
|
88
|
+
return { action: args.action.type };
|
|
89
|
+
},
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
expect(tool.name).toBe("actionTool");
|
|
93
|
+
expect(tool.parameters["~standard"].vendor).toBe("zod");
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it("Zod schema with nullable and record fields", () => {
|
|
97
|
+
const tool = defineTool({
|
|
98
|
+
name: "flexTool",
|
|
99
|
+
description: "Flexible tool",
|
|
100
|
+
parameters: z.object({
|
|
101
|
+
title: z.string(),
|
|
102
|
+
description: z.string().nullable(),
|
|
103
|
+
metadata: z.record(z.string(), z.unknown()).optional(),
|
|
104
|
+
}),
|
|
105
|
+
execute: async (args) => {
|
|
106
|
+
return { title: args.title };
|
|
107
|
+
},
|
|
108
|
+
});
|
|
109
|
+
|
|
110
|
+
expect(tool.name).toBe("flexTool");
|
|
111
|
+
expect(tool.parameters["~standard"].vendor).toBe("zod");
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
it("execute callback receives correctly typed args", async () => {
|
|
115
|
+
const receivedArgs: unknown[] = [];
|
|
116
|
+
|
|
117
|
+
const tool = defineTool({
|
|
118
|
+
name: "argCapture",
|
|
119
|
+
description: "Captures args",
|
|
120
|
+
parameters: z.object({
|
|
121
|
+
city: z.string(),
|
|
122
|
+
units: z.enum(["celsius", "fahrenheit"]),
|
|
123
|
+
}),
|
|
124
|
+
execute: async (args) => {
|
|
125
|
+
receivedArgs.push(args);
|
|
126
|
+
return { temp: 22 };
|
|
127
|
+
},
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
await tool.execute({ city: "Berlin", units: "celsius" });
|
|
131
|
+
|
|
132
|
+
expect(receivedArgs).toHaveLength(1);
|
|
133
|
+
expect(receivedArgs[0]).toEqual({ city: "Berlin", units: "celsius" });
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
describe("convertToolDefinitionsToVercelAITools Zod regression", () => {
|
|
138
|
+
it("Zod schemas are passed directly to AI SDK (not converted via JSON Schema)", () => {
|
|
139
|
+
const zodSchema = z.object({
|
|
140
|
+
city: z.string(),
|
|
141
|
+
units: z.enum(["celsius", "fahrenheit"]).optional(),
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
const tools = [
|
|
145
|
+
defineTool({
|
|
146
|
+
name: "weather",
|
|
147
|
+
description: "Get weather",
|
|
148
|
+
parameters: zodSchema,
|
|
149
|
+
execute: async () => ({ temp: 22 }),
|
|
150
|
+
}),
|
|
151
|
+
];
|
|
152
|
+
|
|
153
|
+
const aiTools = convertToolDefinitionsToVercelAITools(tools);
|
|
154
|
+
|
|
155
|
+
expect(aiTools).toHaveProperty("weather");
|
|
156
|
+
// The inputSchema should be the original Zod schema (passed directly),
|
|
157
|
+
// NOT a jsonSchema() wrapper. We verify by checking the Zod-specific
|
|
158
|
+
// ~standard.vendor property is preserved on the schema.
|
|
159
|
+
const inputSchema = aiTools.weather.inputSchema;
|
|
160
|
+
expect(inputSchema).toBeDefined();
|
|
161
|
+
// For Zod schemas, the AI SDK receives the raw Zod object (which has ~standard.vendor === "zod")
|
|
162
|
+
// If it went through jsonSchema(), it would lose the ~standard property
|
|
163
|
+
expect(inputSchema["~standard"]?.vendor).toBe("zod");
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it("multiple Zod tools all get direct pass-through", () => {
|
|
167
|
+
const tools = [
|
|
168
|
+
defineTool({
|
|
169
|
+
name: "tool1",
|
|
170
|
+
description: "Tool 1",
|
|
171
|
+
parameters: z.object({ a: z.string() }),
|
|
172
|
+
execute: async () => ({}),
|
|
173
|
+
}),
|
|
174
|
+
defineTool({
|
|
175
|
+
name: "tool2",
|
|
176
|
+
description: "Tool 2",
|
|
177
|
+
parameters: z.object({ b: z.number(), c: z.boolean().optional() }),
|
|
178
|
+
execute: async () => ({}),
|
|
179
|
+
}),
|
|
180
|
+
defineTool({
|
|
181
|
+
name: "tool3",
|
|
182
|
+
description: "Tool 3",
|
|
183
|
+
parameters: z.object({
|
|
184
|
+
nested: z.object({ x: z.number(), y: z.number() }),
|
|
185
|
+
}),
|
|
186
|
+
execute: async () => ({}),
|
|
187
|
+
}),
|
|
188
|
+
];
|
|
189
|
+
|
|
190
|
+
const aiTools = convertToolDefinitionsToVercelAITools(tools);
|
|
191
|
+
|
|
192
|
+
for (const name of ["tool1", "tool2", "tool3"]) {
|
|
193
|
+
expect(aiTools).toHaveProperty(name);
|
|
194
|
+
expect(aiTools[name].inputSchema["~standard"]?.vendor).toBe("zod");
|
|
195
|
+
expect(typeof aiTools[name].execute).toBe("function");
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
|
|
199
|
+
it("preserves tool description and execute function", () => {
|
|
200
|
+
const executeFn = vi.fn().mockResolvedValue({ result: "ok" });
|
|
201
|
+
|
|
202
|
+
const tools = [
|
|
203
|
+
defineTool({
|
|
204
|
+
name: "myTool",
|
|
205
|
+
description: "My custom tool description",
|
|
206
|
+
parameters: z.object({ input: z.string() }),
|
|
207
|
+
execute: executeFn,
|
|
208
|
+
}),
|
|
209
|
+
];
|
|
210
|
+
|
|
211
|
+
const aiTools = convertToolDefinitionsToVercelAITools(tools);
|
|
212
|
+
|
|
213
|
+
expect(aiTools.myTool.description).toBe("My custom tool description");
|
|
214
|
+
expect(aiTools.myTool.execute).toBeDefined();
|
|
215
|
+
});
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
describe("BuiltInAgent Zod regression", () => {
|
|
219
|
+
const originalEnv = process.env;
|
|
220
|
+
|
|
221
|
+
beforeEach(() => {
|
|
222
|
+
vi.clearAllMocks();
|
|
223
|
+
process.env = { ...originalEnv };
|
|
224
|
+
process.env.OPENAI_API_KEY = "test-key";
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
afterEach(() => {
|
|
228
|
+
process.env = originalEnv;
|
|
229
|
+
});
|
|
230
|
+
|
|
231
|
+
it("Zod tools are included in streamText call", async () => {
|
|
232
|
+
const agent = new BuiltInAgent({
|
|
233
|
+
model: "openai/gpt-4o",
|
|
234
|
+
tools: [
|
|
235
|
+
defineTool({
|
|
236
|
+
name: "weather",
|
|
237
|
+
description: "Get weather",
|
|
238
|
+
parameters: z.object({
|
|
239
|
+
city: z.string(),
|
|
240
|
+
units: z.enum(["celsius", "fahrenheit"]).optional(),
|
|
241
|
+
}),
|
|
242
|
+
execute: async () => ({ temp: 22 }),
|
|
243
|
+
}),
|
|
244
|
+
],
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
vi.mocked(streamText).mockReturnValue(
|
|
248
|
+
mockStreamTextResponse([finish()]) as any,
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
const input: RunAgentInput = {
|
|
252
|
+
threadId: "thread1",
|
|
253
|
+
runId: "run1",
|
|
254
|
+
messages: [],
|
|
255
|
+
tools: [],
|
|
256
|
+
context: [],
|
|
257
|
+
state: {},
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
await collectEvents(agent["run"](input));
|
|
261
|
+
|
|
262
|
+
const callArgs = vi.mocked(streamText).mock.calls[0][0];
|
|
263
|
+
expect(callArgs.tools).toHaveProperty("weather");
|
|
264
|
+
expect(typeof callArgs.tools?.weather.execute).toBe("function");
|
|
265
|
+
});
|
|
266
|
+
|
|
267
|
+
it("multiple Zod tools coexist with built-in state tools", async () => {
|
|
268
|
+
const agent = new BuiltInAgent({
|
|
269
|
+
model: "openai/gpt-4o",
|
|
270
|
+
tools: [
|
|
271
|
+
defineTool({
|
|
272
|
+
name: "search",
|
|
273
|
+
description: "Search",
|
|
274
|
+
parameters: z.object({ query: z.string() }),
|
|
275
|
+
execute: async () => ({}),
|
|
276
|
+
}),
|
|
277
|
+
defineTool({
|
|
278
|
+
name: "calculate",
|
|
279
|
+
description: "Calculate",
|
|
280
|
+
parameters: z.object({
|
|
281
|
+
expression: z.string(),
|
|
282
|
+
precision: z.number().int().optional(),
|
|
283
|
+
}),
|
|
284
|
+
execute: async () => ({}),
|
|
285
|
+
}),
|
|
286
|
+
],
|
|
287
|
+
});
|
|
288
|
+
|
|
289
|
+
vi.mocked(streamText).mockReturnValue(
|
|
290
|
+
mockStreamTextResponse([finish()]) as any,
|
|
291
|
+
);
|
|
292
|
+
|
|
293
|
+
const input: RunAgentInput = {
|
|
294
|
+
threadId: "thread1",
|
|
295
|
+
runId: "run1",
|
|
296
|
+
messages: [],
|
|
297
|
+
tools: [],
|
|
298
|
+
context: [],
|
|
299
|
+
state: {},
|
|
300
|
+
};
|
|
301
|
+
|
|
302
|
+
await collectEvents(agent["run"](input));
|
|
303
|
+
|
|
304
|
+
const callArgs = vi.mocked(streamText).mock.calls[0][0];
|
|
305
|
+
// User-defined Zod tools
|
|
306
|
+
expect(callArgs.tools).toHaveProperty("search");
|
|
307
|
+
expect(callArgs.tools).toHaveProperty("calculate");
|
|
308
|
+
// Built-in state tools
|
|
309
|
+
expect(callArgs.tools).toHaveProperty("AGUISendStateSnapshot");
|
|
310
|
+
expect(callArgs.tools).toHaveProperty("AGUISendStateDelta");
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
it("Zod tool execute is invocable after conversion", async () => {
|
|
314
|
+
const executeFn = vi.fn().mockResolvedValue({ temp: 22 });
|
|
315
|
+
|
|
316
|
+
const agent = new BuiltInAgent({
|
|
317
|
+
model: "openai/gpt-4o",
|
|
318
|
+
tools: [
|
|
319
|
+
defineTool({
|
|
320
|
+
name: "weather",
|
|
321
|
+
description: "Get weather",
|
|
322
|
+
parameters: z.object({ city: z.string() }),
|
|
323
|
+
execute: executeFn,
|
|
324
|
+
}),
|
|
325
|
+
],
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
vi.mocked(streamText).mockReturnValue(
|
|
329
|
+
mockStreamTextResponse([finish()]) as any,
|
|
330
|
+
);
|
|
331
|
+
|
|
332
|
+
const input: RunAgentInput = {
|
|
333
|
+
threadId: "thread1",
|
|
334
|
+
runId: "run1",
|
|
335
|
+
messages: [],
|
|
336
|
+
tools: [],
|
|
337
|
+
context: [],
|
|
338
|
+
state: {},
|
|
339
|
+
};
|
|
340
|
+
|
|
341
|
+
await collectEvents(agent["run"](input));
|
|
342
|
+
|
|
343
|
+
const callArgs = vi.mocked(streamText).mock.calls[0][0];
|
|
344
|
+
const weatherTool = callArgs.tools?.weather;
|
|
345
|
+
|
|
346
|
+
// Invoke the execute function to verify it's wired correctly
|
|
347
|
+
await weatherTool.execute({ city: "Berlin" });
|
|
348
|
+
expect(executeFn).toHaveBeenCalledWith({ city: "Berlin" });
|
|
349
|
+
});
|
|
350
|
+
});
|