@copilotkit/runtime 1.57.3 → 1.58.0-canary.thread-id-propagation
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/dist/lib/observability.d.cts +1 -1
- package/dist/lib/observability.d.cts.map +1 -1
- package/dist/lib/observability.d.mts +1 -1
- package/dist/lib/observability.d.mts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.cjs +2 -0
- package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
- package/dist/lib/runtime/copilot-runtime.mjs +2 -0
- package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
- package/dist/package.cjs +5 -8
- package/dist/package.mjs +5 -8
- package/dist/v2/runtime/core/runtime.cjs +4 -1
- package/dist/v2/runtime/core/runtime.cjs.map +1 -1
- package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
- package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
- package/dist/v2/runtime/core/runtime.mjs +4 -1
- package/dist/v2/runtime/core/runtime.mjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.cjs +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.mjs +1 -1
- package/dist/v2/runtime/handlers/handle-connect.cjs +1 -1
- package/dist/v2/runtime/handlers/handle-connect.mjs +1 -1
- package/dist/v2/runtime/handlers/handle-run.cjs +1 -1
- package/dist/v2/runtime/handlers/handle-run.mjs +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.cjs +22 -6
- package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
- package/dist/v2/runtime/telemetry/telemetry-client.mjs +27 -11
- package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
- package/package.json +9 -19
- package/skills/runtime/SKILL.md +98 -0
- package/skills/runtime/references/agent-runners-custom.md +161 -0
- package/skills/runtime/references/agent-runners-in-memory.md +64 -0
- package/skills/runtime/references/agent-runners-sqlite.md +90 -0
- package/skills/runtime/references/agent-runners.md +304 -0
- package/skills/runtime/references/built-in-agent-factory-modes.md +232 -0
- package/skills/runtime/references/built-in-agent-helper-utilities.md +123 -0
- package/skills/runtime/references/built-in-agent-model-identifiers.md +59 -0
- package/skills/runtime/references/built-in-agent.md +523 -0
- package/skills/runtime/references/intelligence-mode.md +336 -0
- package/skills/runtime/references/middleware.md +376 -0
- package/skills/runtime/references/server-side-tools.md +414 -0
- package/skills/runtime/references/setup-endpoint.md +503 -0
- package/skills/runtime/references/transcription.md +287 -0
- package/skills/runtime/references/wiring-a2a.md +40 -0
- package/skills/runtime/references/wiring-adk.md +45 -0
- package/skills/runtime/references/wiring-ag2.md +41 -0
- package/skills/runtime/references/wiring-agno.md +39 -0
- package/skills/runtime/references/wiring-aws-strands.md +59 -0
- package/skills/runtime/references/wiring-crewai-crews.md +51 -0
- package/skills/runtime/references/wiring-crewai-flows.md +45 -0
- package/skills/runtime/references/wiring-external-agents.md +348 -0
- package/skills/runtime/references/wiring-langgraph.md +50 -0
- package/skills/runtime/references/wiring-llamaindex.md +39 -0
- package/skills/runtime/references/wiring-mastra.md +70 -0
- package/skills/runtime/references/wiring-mcp-apps-middleware.md +68 -0
- package/skills/runtime/references/wiring-ms-agent-framework.md +41 -0
- package/skills/runtime/references/wiring-pydantic-ai.md +45 -0
- package/CHANGELOG.md +0 -3624
- package/__snapshots__/schema/schema.graphql +0 -371
- package/dist/v2/runtime/telemetry/scarf-client.cjs +0 -32
- package/dist/v2/runtime/telemetry/scarf-client.cjs.map +0 -1
- package/dist/v2/runtime/telemetry/scarf-client.mjs +0 -32
- package/dist/v2/runtime/telemetry/scarf-client.mjs.map +0 -1
- package/scripts/generate-gql-schema.ts +0 -16
- package/src/agent/__tests__/agent-test-helpers.ts +0 -476
- package/src/agent/__tests__/agent.test.ts +0 -593
- package/src/agent/__tests__/ai-sdk-v6-compat.test.ts +0 -116
- package/src/agent/__tests__/basic-agent.test.ts +0 -1698
- package/src/agent/__tests__/capabilities.test.ts +0 -81
- package/src/agent/__tests__/config-tools-execution.test.ts +0 -516
- package/src/agent/__tests__/converter-aisdk.test.ts +0 -692
- package/src/agent/__tests__/converter-custom.test.ts +0 -319
- package/src/agent/__tests__/converter-tanstack-input.test.ts +0 -211
- package/src/agent/__tests__/converter-tanstack.test.ts +0 -594
- package/src/agent/__tests__/mcp-clients.test.ts +0 -246
- package/src/agent/__tests__/mcp-servers-integration.test.ts +0 -373
- package/src/agent/__tests__/multimodal-tanstack.test.ts +0 -284
- package/src/agent/__tests__/multimodal.test.ts +0 -176
- package/src/agent/__tests__/property-overrides.test.ts +0 -598
- package/src/agent/__tests__/provider-id-collision.test.ts +0 -195
- package/src/agent/__tests__/standard-schema-tools.test.ts +0 -313
- package/src/agent/__tests__/standard-schema-types.test.ts +0 -158
- package/src/agent/__tests__/state-tools.test.ts +0 -436
- package/src/agent/__tests__/test-helpers.ts +0 -197
- package/src/agent/__tests__/utils.test.ts +0 -536
- package/src/agent/__tests__/zod-regression.test.ts +0 -350
- package/src/agent/converters/aisdk.ts +0 -326
- package/src/agent/converters/index.ts +0 -7
- package/src/agent/converters/tanstack.ts +0 -451
- package/src/agent/index.ts +0 -1743
- package/src/agents/langgraph/__tests__/event-source.test.ts +0 -256
- package/src/agents/langgraph/event-source.ts +0 -365
- package/src/agents/langgraph/events.ts +0 -394
- package/src/graphql/inputs/action.input.ts +0 -16
- package/src/graphql/inputs/agent-session.input.ts +0 -13
- package/src/graphql/inputs/agent-state.input.ts +0 -13
- package/src/graphql/inputs/cloud-guardrails.input.ts +0 -16
- package/src/graphql/inputs/cloud.input.ts +0 -8
- package/src/graphql/inputs/context-property.input.ts +0 -10
- package/src/graphql/inputs/copilot-context.input.ts +0 -10
- package/src/graphql/inputs/custom-property.input.ts +0 -15
- package/src/graphql/inputs/extensions.input.ts +0 -21
- package/src/graphql/inputs/forwarded-parameters.input.ts +0 -22
- package/src/graphql/inputs/frontend.input.ts +0 -14
- package/src/graphql/inputs/generate-copilot-response.input.ts +0 -59
- package/src/graphql/inputs/load-agent-state.input.ts +0 -10
- package/src/graphql/inputs/message.input.ts +0 -110
- package/src/graphql/inputs/meta-event.input.ts +0 -18
- package/src/graphql/message-conversion/agui-to-gql.test.ts +0 -1384
- package/src/graphql/message-conversion/agui-to-gql.ts +0 -384
- package/src/graphql/message-conversion/gql-to-agui.test.ts +0 -1653
- package/src/graphql/message-conversion/gql-to-agui.ts +0 -297
- package/src/graphql/message-conversion/index.ts +0 -2
- package/src/graphql/message-conversion/roundtrip-conversion.test.ts +0 -561
- package/src/graphql/resolvers/__tests__/resolve-message-id.test.ts +0 -25
- package/src/graphql/resolvers/copilot.resolver.ts +0 -785
- package/src/graphql/resolvers/resolve-message-id.ts +0 -14
- package/src/graphql/resolvers/state.resolver.ts +0 -30
- package/src/graphql/types/agents-response.type.ts +0 -19
- package/src/graphql/types/base/index.ts +0 -10
- package/src/graphql/types/converted/index.ts +0 -183
- package/src/graphql/types/copilot-response.type.ts +0 -141
- package/src/graphql/types/enums.ts +0 -38
- package/src/graphql/types/extensions-response.type.ts +0 -23
- package/src/graphql/types/guardrails-result.type.ts +0 -20
- package/src/graphql/types/load-agent-state-response.type.ts +0 -17
- package/src/graphql/types/message-status.type.ts +0 -48
- package/src/graphql/types/meta-events.type.ts +0 -78
- package/src/graphql/types/response-status.type.ts +0 -77
- package/src/index.ts +0 -3
- package/src/langgraph.ts +0 -1
- package/src/lib/__tests__/telemetry-disclosure.test.ts +0 -55
- package/src/lib/cloud/index.ts +0 -4
- package/src/lib/error-messages.ts +0 -211
- package/src/lib/index.ts +0 -52
- package/src/lib/integrations/index.ts +0 -6
- package/src/lib/integrations/nest/index.ts +0 -21
- package/src/lib/integrations/nextjs/app-router.ts +0 -47
- package/src/lib/integrations/nextjs/pages-router.ts +0 -45
- package/src/lib/integrations/node-express/index.ts +0 -21
- package/src/lib/integrations/node-http/__tests__/request-duck-type.test.ts +0 -66
- package/src/lib/integrations/node-http/index.ts +0 -187
- package/src/lib/integrations/node-http/request-handler.ts +0 -128
- package/src/lib/integrations/shared.ts +0 -112
- package/src/lib/logger.ts +0 -31
- package/src/lib/observability.ts +0 -167
- package/src/lib/runtime/__tests__/copilot-runtime-error.test.ts +0 -183
- package/src/lib/runtime/__tests__/handle-service-adapter.test.ts +0 -108
- package/src/lib/runtime/__tests__/mcp-tools-utils.test.ts +0 -499
- package/src/lib/runtime/__tests__/on-after-request.test.ts +0 -122
- package/src/lib/runtime/__tests__/retry-utils.test.ts +0 -137
- package/src/lib/runtime/__tests__/v1-agent-factory.test.ts +0 -109
- package/src/lib/runtime/agent-integrations/langgraph/__tests__/dispatch-event-filtering.test.ts +0 -345
- package/src/lib/runtime/agent-integrations/langgraph/__tests__/run-message-filtering.test.ts +0 -156
- package/src/lib/runtime/agent-integrations/langgraph/agent.ts +0 -263
- package/src/lib/runtime/agent-integrations/langgraph/consts.ts +0 -37
- package/src/lib/runtime/agent-integrations/langgraph/index.ts +0 -2
- package/src/lib/runtime/copilot-runtime.ts +0 -863
- package/src/lib/runtime/mcp-tools-utils.ts +0 -313
- package/src/lib/runtime/retry-utils.ts +0 -141
- package/src/lib/runtime/telemetry-agent-runner.ts +0 -151
- package/src/lib/runtime/types.ts +0 -48
- package/src/lib/runtime/utils.ts +0 -93
- package/src/lib/streaming.ts +0 -220
- package/src/lib/telemetry-client.ts +0 -66
- package/src/lib/telemetry-disclosure.ts +0 -53
- package/src/service-adapters/anthropic/anthropic-adapter.ts +0 -532
- package/src/service-adapters/anthropic/utils.ts +0 -219
- package/src/service-adapters/bedrock/bedrock-adapter.ts +0 -73
- package/src/service-adapters/conversion.test.ts +0 -56
- package/src/service-adapters/conversion.ts +0 -69
- package/src/service-adapters/empty/empty-adapter.ts +0 -38
- package/src/service-adapters/events.ts +0 -337
- package/src/service-adapters/experimental/ollama/ollama-adapter.ts +0 -84
- package/src/service-adapters/google/google-genai-adapter.test.ts +0 -151
- package/src/service-adapters/google/google-genai-adapter.ts +0 -95
- package/src/service-adapters/groq/groq-adapter.ts +0 -229
- package/src/service-adapters/index.ts +0 -18
- package/src/service-adapters/langchain/langchain-adapter.ts +0 -113
- package/src/service-adapters/langchain/langserve.ts +0 -88
- package/src/service-adapters/langchain/types.ts +0 -20
- package/src/service-adapters/langchain/utils.ts +0 -330
- package/src/service-adapters/openai/__tests__/openai-v5-compat.test.ts +0 -177
- package/src/service-adapters/openai/openai-adapter.ts +0 -324
- package/src/service-adapters/openai/openai-assistant-adapter.ts +0 -385
- package/src/service-adapters/openai/utils.ts +0 -305
- package/src/service-adapters/service-adapter.ts +0 -50
- package/src/service-adapters/shared/error-utils.ts +0 -64
- package/src/service-adapters/shared/index.ts +0 -2
- package/src/service-adapters/shared/sdk-client-utils.ts +0 -19
- package/src/service-adapters/unify/unify-adapter.ts +0 -165
- package/src/utils/failed-response-status-reasons.ts +0 -70
- package/src/utils/index.ts +0 -1
- package/src/v2/express.ts +0 -1
- package/src/v2/hono.ts +0 -1
- package/src/v2/index.ts +0 -5
- package/src/v2/node.ts +0 -1
- package/src/v2/runtime/__tests__/agents-factory.test.ts +0 -136
- package/src/v2/runtime/__tests__/backward-compat.test.ts +0 -261
- package/src/v2/runtime/__tests__/code-review-fixes.test.ts +0 -500
- package/src/v2/runtime/__tests__/cors-credentials.test.ts +0 -320
- package/src/v2/runtime/__tests__/debug-sse-response.test.ts +0 -302
- package/src/v2/runtime/__tests__/express-adapter.test.ts +0 -188
- package/src/v2/runtime/__tests__/express-body-order.test.ts +0 -76
- package/src/v2/runtime/__tests__/express-fetch-bridge.test.ts +0 -344
- package/src/v2/runtime/__tests__/express-single-sse.test.ts +0 -122
- package/src/v2/runtime/__tests__/express-single-telemetry.integration.test.ts +0 -65
- package/src/v2/runtime/__tests__/express-telemetry.integration.test.ts +0 -101
- package/src/v2/runtime/__tests__/fetch-cors.test.ts +0 -205
- package/src/v2/runtime/__tests__/fetch-handler-validation.test.ts +0 -440
- package/src/v2/runtime/__tests__/fetch-handler.test.ts +0 -456
- package/src/v2/runtime/__tests__/fetch-router.test.ts +0 -276
- package/src/v2/runtime/__tests__/get-runtime-info.test.ts +0 -335
- package/src/v2/runtime/__tests__/handle-connect.test.ts +0 -585
- package/src/v2/runtime/__tests__/handle-run.test.ts +0 -1388
- package/src/v2/runtime/__tests__/handle-threads.test.ts +0 -930
- package/src/v2/runtime/__tests__/handle-transcribe.test.ts +0 -301
- package/src/v2/runtime/__tests__/header-utils.test.ts +0 -88
- package/src/v2/runtime/__tests__/hono-adapter.test.ts +0 -150
- package/src/v2/runtime/__tests__/hono-single-telemetry.integration.test.ts +0 -46
- package/src/v2/runtime/__tests__/hono-telemetry.integration.test.ts +0 -99
- package/src/v2/runtime/__tests__/hooks-edge-cases.test.ts +0 -457
- package/src/v2/runtime/__tests__/hooks.test.ts +0 -557
- package/src/v2/runtime/__tests__/in-process-agent-runner-messages.test.ts +0 -230
- package/src/v2/runtime/__tests__/in-process-agent-runner.test.ts +0 -1030
- package/src/v2/runtime/__tests__/integration/bun/bun-servers.integration.test.ts +0 -27
- package/src/v2/runtime/__tests__/integration/bun/elysia-multi.ts +0 -32
- package/src/v2/runtime/__tests__/integration/bun/elysia-single.ts +0 -33
- package/src/v2/runtime/__tests__/integration/bun/hono-bun-multi.ts +0 -25
- package/src/v2/runtime/__tests__/integration/bun/hono-bun-single.ts +0 -32
- package/src/v2/runtime/__tests__/integration/helpers/create-test-runtime.ts +0 -15
- package/src/v2/runtime/__tests__/integration/helpers/sse-reader.ts +0 -45
- package/src/v2/runtime/__tests__/integration/helpers/test-agent.ts +0 -58
- package/src/v2/runtime/__tests__/integration/node-servers.integration.test.ts +0 -58
- package/src/v2/runtime/__tests__/integration/servers/express-multi.ts +0 -35
- package/src/v2/runtime/__tests__/integration/servers/express-single.ts +0 -36
- package/src/v2/runtime/__tests__/integration/servers/fetch-direct.ts +0 -39
- package/src/v2/runtime/__tests__/integration/servers/hono-multi.ts +0 -30
- package/src/v2/runtime/__tests__/integration/servers/hono-single.ts +0 -37
- package/src/v2/runtime/__tests__/integration/servers/node-multi.ts +0 -45
- package/src/v2/runtime/__tests__/integration/servers/node-single.ts +0 -46
- package/src/v2/runtime/__tests__/integration/servers/types.ts +0 -18
- package/src/v2/runtime/__tests__/integration/suites/debug-events.suite.ts +0 -253
- package/src/v2/runtime/__tests__/integration/suites/multi-endpoint.suite.ts +0 -358
- package/src/v2/runtime/__tests__/integration/suites/single-endpoint.suite.ts +0 -363
- package/src/v2/runtime/__tests__/intelligence-run-telemetry.test.ts +0 -194
- package/src/v2/runtime/__tests__/mcp-apps-middleware-integration.test.ts +0 -275
- package/src/v2/runtime/__tests__/middleware-express.test.ts +0 -208
- package/src/v2/runtime/__tests__/middleware-single-express.test.ts +0 -213
- package/src/v2/runtime/__tests__/middleware-single.test.ts +0 -225
- package/src/v2/runtime/__tests__/middleware-sse-parser.test.ts +0 -237
- package/src/v2/runtime/__tests__/middleware.test.ts +0 -250
- package/src/v2/runtime/__tests__/node-fetch-handler.test.ts +0 -157
- package/src/v2/runtime/__tests__/open-generative-ui-middleware.e2e.test.ts +0 -728
- package/src/v2/runtime/__tests__/router-edge-cases.test.ts +0 -217
- package/src/v2/runtime/__tests__/routing-express.test.ts +0 -174
- package/src/v2/runtime/__tests__/routing-single-express.test.ts +0 -168
- package/src/v2/runtime/__tests__/routing-single.test.ts +0 -193
- package/src/v2/runtime/__tests__/routing.test.ts +0 -257
- package/src/v2/runtime/__tests__/runtime.test.ts +0 -234
- package/src/v2/runtime/__tests__/sse-response-telemetry.test.ts +0 -108
- package/src/v2/runtime/__tests__/telemetry.test.ts +0 -167
- package/src/v2/runtime/__tests__/thread-names.test.ts +0 -188
- package/src/v2/runtime/core/__tests__/debug-event-bus.test.ts +0 -156
- package/src/v2/runtime/core/debug-event-bus.ts +0 -45
- package/src/v2/runtime/core/fetch-cors.ts +0 -136
- package/src/v2/runtime/core/fetch-handler.ts +0 -492
- package/src/v2/runtime/core/fetch-router.ts +0 -203
- package/src/v2/runtime/core/hooks.ts +0 -160
- package/src/v2/runtime/core/middleware-sse-parser.ts +0 -210
- package/src/v2/runtime/core/middleware.ts +0 -115
- package/src/v2/runtime/core/runtime.ts +0 -432
- package/src/v2/runtime/endpoints/express-fetch-bridge.ts +0 -137
- package/src/v2/runtime/endpoints/express-single.ts +0 -54
- package/src/v2/runtime/endpoints/express.ts +0 -179
- package/src/v2/runtime/endpoints/hono-single.ts +0 -60
- package/src/v2/runtime/endpoints/hono.ts +0 -89
- package/src/v2/runtime/endpoints/index.ts +0 -4
- package/src/v2/runtime/endpoints/node-fetch-handler.ts +0 -48
- package/src/v2/runtime/endpoints/node.ts +0 -28
- package/src/v2/runtime/endpoints/single-route-helpers.ts +0 -125
- package/src/v2/runtime/express.ts +0 -2
- package/src/v2/runtime/handlers/__tests__/handle-debug-events.test.ts +0 -176
- package/src/v2/runtime/handlers/get-runtime-info.ts +0 -101
- package/src/v2/runtime/handlers/handle-connect.ts +0 -80
- package/src/v2/runtime/handlers/handle-debug-events.ts +0 -52
- package/src/v2/runtime/handlers/handle-run.ts +0 -111
- package/src/v2/runtime/handlers/handle-stop.ts +0 -77
- package/src/v2/runtime/handlers/handle-threads.ts +0 -11
- package/src/v2/runtime/handlers/handle-transcribe.ts +0 -269
- package/src/v2/runtime/handlers/header-utils.ts +0 -24
- package/src/v2/runtime/handlers/intelligence/connect.ts +0 -102
- package/src/v2/runtime/handlers/intelligence/run.ts +0 -351
- package/src/v2/runtime/handlers/intelligence/thread-names.ts +0 -246
- package/src/v2/runtime/handlers/intelligence/threads.ts +0 -420
- package/src/v2/runtime/handlers/shared/agent-utils.ts +0 -154
- package/src/v2/runtime/handlers/shared/intelligence-utils.ts +0 -41
- package/src/v2/runtime/handlers/shared/json-response.ts +0 -9
- package/src/v2/runtime/handlers/shared/resolve-intelligence-user.ts +0 -28
- package/src/v2/runtime/handlers/shared/sse-response.ts +0 -215
- package/src/v2/runtime/handlers/sse/__tests__/sse-connect-agent-id.test.ts +0 -71
- package/src/v2/runtime/handlers/sse/connect.ts +0 -30
- package/src/v2/runtime/handlers/sse/run.ts +0 -40
- package/src/v2/runtime/hono.ts +0 -2
- package/src/v2/runtime/index.ts +0 -51
- package/src/v2/runtime/intelligence-platform/__tests__/client.test.ts +0 -601
- package/src/v2/runtime/intelligence-platform/__tests__/intelligence-mcp-helper.test.ts +0 -246
- package/src/v2/runtime/intelligence-platform/client.ts +0 -818
- package/src/v2/runtime/intelligence-platform/index.ts +0 -10
- package/src/v2/runtime/node.ts +0 -6
- package/src/v2/runtime/open-generative-ui-middleware.ts +0 -373
- package/src/v2/runtime/runner/__tests__/finalize-events.test.ts +0 -109
- package/src/v2/runtime/runner/__tests__/in-memory-runner.e2e.test.ts +0 -775
- package/src/v2/runtime/runner/__tests__/in-memory-runner.test.ts +0 -777
- package/src/v2/runtime/runner/__tests__/intelligence-runner.test.ts +0 -1039
- package/src/v2/runtime/runner/agent-runner.ts +0 -35
- package/src/v2/runtime/runner/in-memory.ts +0 -467
- package/src/v2/runtime/runner/index.ts +0 -4
- package/src/v2/runtime/runner/intelligence.ts +0 -498
- package/src/v2/runtime/telemetry/__tests__/instance-created.test.ts +0 -96
- package/src/v2/runtime/telemetry/events.ts +0 -35
- package/src/v2/runtime/telemetry/index.ts +0 -7
- package/src/v2/runtime/telemetry/instance-created.ts +0 -44
- package/src/v2/runtime/telemetry/scarf-client.ts +0 -39
- package/src/v2/runtime/telemetry/telemetry-client.ts +0 -70
- package/src/v2/runtime/transcription-service/transcription-service.ts +0 -11
- package/tests/global.d.ts +0 -1
- package/tests/service-adapters/anthropic/allowlist-approach.test.ts +0 -259
- package/tests/service-adapters/anthropic/anthropic-adapter-language-model.test.ts +0 -101
- package/tests/service-adapters/anthropic/anthropic-adapter.test.ts +0 -645
- package/tests/service-adapters/anthropic/utils-token-trimming.test.ts +0 -301
- package/tests/service-adapters/groq/groq-adapter-language-model.test.ts +0 -102
- package/tests/service-adapters/openai/allowlist-approach.test.ts +0 -294
- package/tests/service-adapters/openai/openai-adapter-language-model.test.ts +0 -122
- package/tests/service-adapters/openai/openai-adapter.test.ts +0 -291
- package/tests/service-adapters/shared/sdk-client-utils.test.ts +0 -36
- package/tests/setup.vitest.ts +0 -8
- package/tests/tsconfig.json +0 -10
- package/tsconfig.json +0 -20
- package/tsdown.config.ts +0 -45
- package/typedoc.json +0 -4
- package/vitest.config.mjs +0 -13
|
@@ -1,330 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ActionExecutionMessage,
|
|
3
|
-
Message,
|
|
4
|
-
ResultMessage,
|
|
5
|
-
TextMessage,
|
|
6
|
-
} from "../../graphql/types/converted";
|
|
7
|
-
import {
|
|
8
|
-
AIMessage,
|
|
9
|
-
AIMessageChunk,
|
|
10
|
-
BaseMessage,
|
|
11
|
-
BaseMessageChunk,
|
|
12
|
-
HumanMessage,
|
|
13
|
-
SystemMessage,
|
|
14
|
-
ToolMessage,
|
|
15
|
-
} from "@langchain/core/messages";
|
|
16
|
-
import { DynamicStructuredTool } from "@langchain/core/tools";
|
|
17
|
-
import { z } from "zod";
|
|
18
|
-
import { ActionInput } from "../../graphql/inputs/action.input";
|
|
19
|
-
import { LangChainReturnType } from "./types";
|
|
20
|
-
import { RuntimeEventSubject } from "../events";
|
|
21
|
-
import { randomId, convertJsonSchemaToZodSchema } from "@copilotkit/shared";
|
|
22
|
-
|
|
23
|
-
export function convertMessageToLangChainMessage(
|
|
24
|
-
message: Message,
|
|
25
|
-
): BaseMessage {
|
|
26
|
-
if (message.isTextMessage()) {
|
|
27
|
-
if (message.role == "user") {
|
|
28
|
-
return new HumanMessage(message.content);
|
|
29
|
-
} else if (message.role == "assistant") {
|
|
30
|
-
return new AIMessage(message.content);
|
|
31
|
-
} else if (message.role === "system") {
|
|
32
|
-
return new SystemMessage(message.content);
|
|
33
|
-
}
|
|
34
|
-
} else if (message.isActionExecutionMessage()) {
|
|
35
|
-
return new AIMessage({
|
|
36
|
-
content: "",
|
|
37
|
-
tool_calls: [
|
|
38
|
-
{
|
|
39
|
-
id: message.id,
|
|
40
|
-
args: message.arguments,
|
|
41
|
-
name: message.name,
|
|
42
|
-
},
|
|
43
|
-
],
|
|
44
|
-
});
|
|
45
|
-
} else if (message.isResultMessage()) {
|
|
46
|
-
return new ToolMessage({
|
|
47
|
-
content: message.result,
|
|
48
|
-
tool_call_id: message.actionExecutionId,
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export function convertActionInputToLangChainTool(
|
|
54
|
-
actionInput: ActionInput,
|
|
55
|
-
): any {
|
|
56
|
-
return new DynamicStructuredTool({
|
|
57
|
-
...actionInput,
|
|
58
|
-
name: actionInput.name,
|
|
59
|
-
description: actionInput.description,
|
|
60
|
-
schema: convertJsonSchemaToZodSchema(
|
|
61
|
-
JSON.parse(actionInput.jsonSchema),
|
|
62
|
-
true,
|
|
63
|
-
) as z.ZodObject<any>,
|
|
64
|
-
func: async () => {
|
|
65
|
-
return "";
|
|
66
|
-
},
|
|
67
|
-
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
interface StreamLangChainResponseParams {
|
|
71
|
-
result: LangChainReturnType;
|
|
72
|
-
eventStream$: RuntimeEventSubject;
|
|
73
|
-
actionExecution?: {
|
|
74
|
-
id: string;
|
|
75
|
-
name: string;
|
|
76
|
-
returnDirect?: boolean;
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
function getConstructorName(object: any): string {
|
|
81
|
-
if (
|
|
82
|
-
object &&
|
|
83
|
-
typeof object === "object" &&
|
|
84
|
-
object.constructor &&
|
|
85
|
-
object.constructor.name
|
|
86
|
-
) {
|
|
87
|
-
return object.constructor.name;
|
|
88
|
-
}
|
|
89
|
-
return "";
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
function isAIMessage(message: any): message is AIMessage {
|
|
93
|
-
return Object.prototype.toString.call(message) === "[object AIMessage]";
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
function isAIMessageChunk(message: any): message is AIMessageChunk {
|
|
97
|
-
return Object.prototype.toString.call(message) === "[object AIMessageChunk]";
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
function isBaseMessageChunk(message: any): message is BaseMessageChunk {
|
|
101
|
-
return (
|
|
102
|
-
Object.prototype.toString.call(message) === "[object BaseMessageChunk]"
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
function maybeSendActionExecutionResultIsMessage(
|
|
107
|
-
eventStream$: RuntimeEventSubject,
|
|
108
|
-
actionExecution?: { id: string; name: string },
|
|
109
|
-
) {
|
|
110
|
-
// language models need a result after the function call
|
|
111
|
-
// we simply let them know that we are sending a message
|
|
112
|
-
if (actionExecution) {
|
|
113
|
-
eventStream$.sendActionExecutionResult({
|
|
114
|
-
actionExecutionId: actionExecution.id,
|
|
115
|
-
actionName: actionExecution.name,
|
|
116
|
-
result: "Sending a message",
|
|
117
|
-
});
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
export async function streamLangChainResponse({
|
|
122
|
-
result,
|
|
123
|
-
eventStream$,
|
|
124
|
-
actionExecution,
|
|
125
|
-
}: StreamLangChainResponseParams) {
|
|
126
|
-
// We support several types of return values from LangChain functions:
|
|
127
|
-
|
|
128
|
-
// 1. string
|
|
129
|
-
|
|
130
|
-
if (typeof result === "string") {
|
|
131
|
-
if (!actionExecution || actionExecution?.returnDirect) {
|
|
132
|
-
// Just send one chunk with the string as the content.
|
|
133
|
-
eventStream$.sendActionExecutionResult({
|
|
134
|
-
actionExecutionId: actionExecution.id,
|
|
135
|
-
actionName: actionExecution.name,
|
|
136
|
-
result: result,
|
|
137
|
-
});
|
|
138
|
-
eventStream$.sendTextMessage(randomId(), result);
|
|
139
|
-
} else {
|
|
140
|
-
// Send as a result
|
|
141
|
-
eventStream$.sendActionExecutionResult({
|
|
142
|
-
actionExecutionId: actionExecution.id,
|
|
143
|
-
actionName: actionExecution.name,
|
|
144
|
-
result: result,
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// 2. AIMessage
|
|
150
|
-
// Send the content and function call of the AIMessage as the content of the chunk.
|
|
151
|
-
else if (isAIMessage(result)) {
|
|
152
|
-
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
153
|
-
|
|
154
|
-
if (result.content) {
|
|
155
|
-
eventStream$.sendTextMessage(randomId(), result.content as string);
|
|
156
|
-
}
|
|
157
|
-
for (const toolCall of result.tool_calls) {
|
|
158
|
-
eventStream$.sendActionExecution({
|
|
159
|
-
actionExecutionId: toolCall.id || randomId(),
|
|
160
|
-
actionName: toolCall.name,
|
|
161
|
-
args: JSON.stringify(toolCall.args),
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
// 3. BaseMessageChunk
|
|
167
|
-
// Send the content and function call of the AIMessage as the content of the chunk.
|
|
168
|
-
else if (isBaseMessageChunk(result)) {
|
|
169
|
-
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
170
|
-
|
|
171
|
-
if (result.lc_kwargs?.content) {
|
|
172
|
-
eventStream$.sendTextMessage(randomId(), result.content as string);
|
|
173
|
-
}
|
|
174
|
-
if (result.lc_kwargs?.tool_calls) {
|
|
175
|
-
for (const toolCall of result.lc_kwargs?.tool_calls) {
|
|
176
|
-
eventStream$.sendActionExecution({
|
|
177
|
-
actionExecutionId: toolCall.id || randomId(),
|
|
178
|
-
actionName: toolCall.name,
|
|
179
|
-
args: JSON.stringify(toolCall.args),
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
// 4. IterableReadableStream
|
|
186
|
-
// Stream the result of the LangChain function.
|
|
187
|
-
else if (result && "getReader" in result) {
|
|
188
|
-
maybeSendActionExecutionResultIsMessage(eventStream$, actionExecution);
|
|
189
|
-
|
|
190
|
-
let reader = result.getReader();
|
|
191
|
-
|
|
192
|
-
let mode: "function" | "message" | null = null;
|
|
193
|
-
let currentMessageId: string;
|
|
194
|
-
|
|
195
|
-
const toolCallDetails = {
|
|
196
|
-
name: null,
|
|
197
|
-
id: null,
|
|
198
|
-
index: null,
|
|
199
|
-
prevIndex: null,
|
|
200
|
-
};
|
|
201
|
-
|
|
202
|
-
while (true) {
|
|
203
|
-
try {
|
|
204
|
-
const { done, value } = await reader.read();
|
|
205
|
-
|
|
206
|
-
let toolCallName: string | undefined = undefined;
|
|
207
|
-
let toolCallId: string | undefined = undefined;
|
|
208
|
-
let toolCallArgs: string | undefined = undefined;
|
|
209
|
-
let hasToolCall: boolean = false;
|
|
210
|
-
let content = "";
|
|
211
|
-
if (value && value.content) {
|
|
212
|
-
content = Array.isArray(value.content)
|
|
213
|
-
? (((value.content[0] as any)?.text ?? "") as string)
|
|
214
|
-
: value.content;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
if (isAIMessageChunk(value)) {
|
|
218
|
-
let chunk = value.tool_call_chunks?.[0];
|
|
219
|
-
toolCallArgs = chunk?.args;
|
|
220
|
-
hasToolCall = chunk != undefined;
|
|
221
|
-
if (chunk?.name) toolCallDetails.name = chunk.name;
|
|
222
|
-
// track different index on the same tool cool
|
|
223
|
-
if (chunk?.index != null) {
|
|
224
|
-
toolCallDetails.index = chunk.index; // 1
|
|
225
|
-
if (toolCallDetails.prevIndex == null)
|
|
226
|
-
toolCallDetails.prevIndex = chunk.index;
|
|
227
|
-
}
|
|
228
|
-
// Differentiate when calling the same tool but with different index
|
|
229
|
-
if (chunk?.id)
|
|
230
|
-
toolCallDetails.id =
|
|
231
|
-
chunk.index != null ? `${chunk.id}-idx-${chunk.index}` : chunk.id;
|
|
232
|
-
|
|
233
|
-
// Assign to internal variables that the entire script here knows how to work with
|
|
234
|
-
toolCallName = toolCallDetails.name;
|
|
235
|
-
toolCallId = toolCallDetails.id;
|
|
236
|
-
} else if (isBaseMessageChunk(value)) {
|
|
237
|
-
let chunk = value.additional_kwargs?.tool_calls?.[0];
|
|
238
|
-
toolCallName = chunk?.function?.name;
|
|
239
|
-
toolCallId = chunk?.id;
|
|
240
|
-
toolCallArgs = chunk?.function?.arguments;
|
|
241
|
-
hasToolCall = chunk?.function != undefined;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// When switching from message to function or vice versa,
|
|
245
|
-
// send the respective end event.
|
|
246
|
-
// If toolCallName is defined, it means a new tool call starts.
|
|
247
|
-
if (mode === "message" && (toolCallId || done)) {
|
|
248
|
-
mode = null;
|
|
249
|
-
eventStream$.sendTextMessageEnd({ messageId: currentMessageId });
|
|
250
|
-
} else if (mode === "function" && (!hasToolCall || done)) {
|
|
251
|
-
mode = null;
|
|
252
|
-
eventStream$.sendActionExecutionEnd({
|
|
253
|
-
actionExecutionId: toolCallId,
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
if (done) {
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
// If we send a new message type, send the appropriate start event.
|
|
262
|
-
if (mode === null) {
|
|
263
|
-
if (hasToolCall && toolCallId && toolCallName) {
|
|
264
|
-
mode = "function";
|
|
265
|
-
eventStream$.sendActionExecutionStart({
|
|
266
|
-
actionExecutionId: toolCallId,
|
|
267
|
-
actionName: toolCallName,
|
|
268
|
-
parentMessageId: value.lc_kwargs?.id,
|
|
269
|
-
});
|
|
270
|
-
} else if (content) {
|
|
271
|
-
mode = "message";
|
|
272
|
-
currentMessageId = randomId();
|
|
273
|
-
eventStream$.sendTextMessageStart({ messageId: currentMessageId });
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
|
|
277
|
-
// send the content events
|
|
278
|
-
if (mode === "message" && content) {
|
|
279
|
-
eventStream$.sendTextMessageContent({
|
|
280
|
-
messageId: currentMessageId,
|
|
281
|
-
content,
|
|
282
|
-
});
|
|
283
|
-
} else if (mode === "function" && toolCallArgs) {
|
|
284
|
-
// For calls of the same tool with different index, we seal last tool call and register a new one
|
|
285
|
-
if (toolCallDetails.index !== toolCallDetails.prevIndex) {
|
|
286
|
-
eventStream$.sendActionExecutionEnd({
|
|
287
|
-
actionExecutionId: toolCallId,
|
|
288
|
-
});
|
|
289
|
-
eventStream$.sendActionExecutionStart({
|
|
290
|
-
actionExecutionId: toolCallId,
|
|
291
|
-
actionName: toolCallName,
|
|
292
|
-
parentMessageId: value.lc_kwargs?.id,
|
|
293
|
-
});
|
|
294
|
-
toolCallDetails.prevIndex = toolCallDetails.index;
|
|
295
|
-
}
|
|
296
|
-
eventStream$.sendActionExecutionArgs({
|
|
297
|
-
actionExecutionId: toolCallId,
|
|
298
|
-
args: toolCallArgs,
|
|
299
|
-
});
|
|
300
|
-
}
|
|
301
|
-
} catch (error) {
|
|
302
|
-
console.error("Error reading from stream", error);
|
|
303
|
-
break;
|
|
304
|
-
}
|
|
305
|
-
}
|
|
306
|
-
} else if (actionExecution) {
|
|
307
|
-
eventStream$.sendActionExecutionResult({
|
|
308
|
-
actionExecutionId: actionExecution.id,
|
|
309
|
-
actionName: actionExecution.name,
|
|
310
|
-
result: encodeResult(result),
|
|
311
|
-
});
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
// unsupported type
|
|
315
|
-
else {
|
|
316
|
-
throw new Error("Invalid return type from LangChain function.");
|
|
317
|
-
}
|
|
318
|
-
|
|
319
|
-
eventStream$.complete();
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
function encodeResult(result: any): string {
|
|
323
|
-
if (result === undefined) {
|
|
324
|
-
return "";
|
|
325
|
-
} else if (typeof result === "string") {
|
|
326
|
-
return result;
|
|
327
|
-
} else {
|
|
328
|
-
return JSON.stringify(result);
|
|
329
|
-
}
|
|
330
|
-
}
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from "vitest";
|
|
2
|
-
import {
|
|
3
|
-
isOpenAIV5,
|
|
4
|
-
getChatCompletionsForStreaming,
|
|
5
|
-
retrieveThreadRun,
|
|
6
|
-
submitToolOutputsStream,
|
|
7
|
-
} from "../utils";
|
|
8
|
-
import type OpenAI from "openai";
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Tests for OpenAI SDK v4/v5 compatibility layer.
|
|
12
|
-
*
|
|
13
|
-
* In v5, the `beta.chat` namespace was removed and promoted to `chat`.
|
|
14
|
-
* In v5, methods with multiple path params switched to named params
|
|
15
|
-
* (e.g. runs.retrieve(runId, { thread_id }) instead of runs.retrieve(threadId, runId)).
|
|
16
|
-
*/
|
|
17
|
-
|
|
18
|
-
function createMockV4Client() {
|
|
19
|
-
const streamFn = vi.fn();
|
|
20
|
-
return {
|
|
21
|
-
client: {
|
|
22
|
-
beta: {
|
|
23
|
-
chat: {
|
|
24
|
-
completions: { stream: streamFn },
|
|
25
|
-
},
|
|
26
|
-
threads: {
|
|
27
|
-
create: vi.fn(),
|
|
28
|
-
runs: {
|
|
29
|
-
retrieve: vi.fn().mockResolvedValue({ id: "run_xyz" }),
|
|
30
|
-
stream: vi.fn(),
|
|
31
|
-
submitToolOutputsStream: vi.fn(),
|
|
32
|
-
},
|
|
33
|
-
messages: {
|
|
34
|
-
create: vi.fn(),
|
|
35
|
-
},
|
|
36
|
-
},
|
|
37
|
-
},
|
|
38
|
-
chat: {
|
|
39
|
-
completions: {
|
|
40
|
-
stream: vi.fn(), // exists but should NOT be used for streaming in v4
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
} as unknown as OpenAI,
|
|
44
|
-
streamFn,
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function createMockV5Client() {
|
|
49
|
-
const streamFn = vi.fn();
|
|
50
|
-
return {
|
|
51
|
-
client: {
|
|
52
|
-
// v5: beta.chat is gone, only beta.threads remains
|
|
53
|
-
beta: {
|
|
54
|
-
threads: {
|
|
55
|
-
create: vi.fn(),
|
|
56
|
-
runs: {
|
|
57
|
-
retrieve: vi.fn().mockResolvedValue({ id: "run_xyz" }),
|
|
58
|
-
stream: vi.fn(),
|
|
59
|
-
submitToolOutputsStream: vi.fn(),
|
|
60
|
-
},
|
|
61
|
-
messages: {
|
|
62
|
-
create: vi.fn(),
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
},
|
|
66
|
-
chat: {
|
|
67
|
-
completions: {
|
|
68
|
-
stream: streamFn,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
} as unknown as OpenAI,
|
|
72
|
-
streamFn,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
describe("isOpenAIV5", () => {
|
|
77
|
-
it("returns false for a v4 client (beta.chat exists)", () => {
|
|
78
|
-
const { client } = createMockV4Client();
|
|
79
|
-
expect(isOpenAIV5(client)).toBe(false);
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
it("returns true for a v5 client (beta.chat does not exist)", () => {
|
|
83
|
-
const { client } = createMockV5Client();
|
|
84
|
-
expect(isOpenAIV5(client)).toBe(true);
|
|
85
|
-
});
|
|
86
|
-
|
|
87
|
-
it("returns true when beta is entirely missing", () => {
|
|
88
|
-
const client = { chat: { completions: {} } } as unknown as OpenAI;
|
|
89
|
-
expect(isOpenAIV5(client)).toBe(true);
|
|
90
|
-
});
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
describe("getChatCompletionsForStreaming", () => {
|
|
94
|
-
it("returns beta.chat.completions for a v4 client", () => {
|
|
95
|
-
const { client } = createMockV4Client();
|
|
96
|
-
const completions = getChatCompletionsForStreaming(client);
|
|
97
|
-
// Should be the beta version, not the top-level one
|
|
98
|
-
expect(completions).not.toBe(client.chat.completions);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it("returns chat.completions for a v5 client", () => {
|
|
102
|
-
const { client } = createMockV5Client();
|
|
103
|
-
const completions = getChatCompletionsForStreaming(client);
|
|
104
|
-
expect(completions).toBe(client.chat.completions);
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
it("stream() on v4 calls beta.chat.completions.stream", () => {
|
|
108
|
-
const { client, streamFn } = createMockV4Client();
|
|
109
|
-
const completions = getChatCompletionsForStreaming(client);
|
|
110
|
-
completions.stream({ model: "gpt-4o", messages: [] });
|
|
111
|
-
expect(streamFn).toHaveBeenCalledWith({ model: "gpt-4o", messages: [] });
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it("stream() on v5 calls chat.completions.stream", () => {
|
|
115
|
-
const { client, streamFn } = createMockV5Client();
|
|
116
|
-
const completions = getChatCompletionsForStreaming(client);
|
|
117
|
-
completions.stream({ model: "gpt-4o", messages: [] });
|
|
118
|
-
expect(streamFn).toHaveBeenCalledWith({ model: "gpt-4o", messages: [] });
|
|
119
|
-
});
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
describe("retrieveThreadRun", () => {
|
|
123
|
-
it("v4: calls retrieve with positional args (threadId, runId)", async () => {
|
|
124
|
-
const { client } = createMockV4Client();
|
|
125
|
-
const retrieveFn = client.beta.threads.runs.retrieve as ReturnType<
|
|
126
|
-
typeof vi.fn
|
|
127
|
-
>;
|
|
128
|
-
|
|
129
|
-
await retrieveThreadRun(client, "thread_abc", "run_xyz");
|
|
130
|
-
|
|
131
|
-
expect(retrieveFn).toHaveBeenCalledWith("thread_abc", "run_xyz");
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
it("v5: calls retrieve with named path params (runId, { thread_id })", async () => {
|
|
135
|
-
const { client } = createMockV5Client();
|
|
136
|
-
const retrieveFn = client.beta.threads.runs.retrieve as ReturnType<
|
|
137
|
-
typeof vi.fn
|
|
138
|
-
>;
|
|
139
|
-
|
|
140
|
-
await retrieveThreadRun(client, "thread_abc", "run_xyz");
|
|
141
|
-
|
|
142
|
-
expect(retrieveFn).toHaveBeenCalledWith("run_xyz", {
|
|
143
|
-
thread_id: "thread_abc",
|
|
144
|
-
});
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
|
|
148
|
-
describe("submitToolOutputsStream", () => {
|
|
149
|
-
it("v4: calls with positional args (threadId, runId, body)", () => {
|
|
150
|
-
const { client } = createMockV4Client();
|
|
151
|
-
const submitFn = client.beta.threads.runs
|
|
152
|
-
.submitToolOutputsStream as ReturnType<typeof vi.fn>;
|
|
153
|
-
const body = {
|
|
154
|
-
tool_outputs: [{ tool_call_id: "tc_1", output: "result" }],
|
|
155
|
-
};
|
|
156
|
-
|
|
157
|
-
submitToolOutputsStream(client, "thread_abc", "run_xyz", body);
|
|
158
|
-
|
|
159
|
-
expect(submitFn).toHaveBeenCalledWith("thread_abc", "run_xyz", body);
|
|
160
|
-
});
|
|
161
|
-
|
|
162
|
-
it("v5: calls with named path params (runId, { thread_id, ...body })", () => {
|
|
163
|
-
const { client } = createMockV5Client();
|
|
164
|
-
const submitFn = client.beta.threads.runs
|
|
165
|
-
.submitToolOutputsStream as ReturnType<typeof vi.fn>;
|
|
166
|
-
const body = {
|
|
167
|
-
tool_outputs: [{ tool_call_id: "tc_1", output: "result" }],
|
|
168
|
-
};
|
|
169
|
-
|
|
170
|
-
submitToolOutputsStream(client, "thread_abc", "run_xyz", body);
|
|
171
|
-
|
|
172
|
-
expect(submitFn).toHaveBeenCalledWith("run_xyz", {
|
|
173
|
-
thread_id: "thread_abc",
|
|
174
|
-
...body,
|
|
175
|
-
});
|
|
176
|
-
});
|
|
177
|
-
});
|