@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
package/src/lib/runtime/utils.ts
DELETED
|
@@ -1,93 +0,0 @@
|
|
|
1
|
-
import { GraphQLContext } from "../integrations";
|
|
2
|
-
import { Logger } from "pino";
|
|
3
|
-
import { CopilotKitEndpoint, RemoteActionInfoResponse } from "./types";
|
|
4
|
-
import {
|
|
5
|
-
Action,
|
|
6
|
-
CopilotKitError,
|
|
7
|
-
CopilotKitLowLevelError,
|
|
8
|
-
ResolvedCopilotKitError,
|
|
9
|
-
} from "@copilotkit/shared";
|
|
10
|
-
|
|
11
|
-
async function fetchRemoteInfo({
|
|
12
|
-
url,
|
|
13
|
-
onBeforeRequest,
|
|
14
|
-
graphqlContext,
|
|
15
|
-
logger,
|
|
16
|
-
frontendUrl,
|
|
17
|
-
}: {
|
|
18
|
-
url: string;
|
|
19
|
-
onBeforeRequest?: CopilotKitEndpoint["onBeforeRequest"];
|
|
20
|
-
graphqlContext: GraphQLContext;
|
|
21
|
-
logger: Logger;
|
|
22
|
-
frontendUrl?: string;
|
|
23
|
-
}): Promise<RemoteActionInfoResponse> {
|
|
24
|
-
logger.debug({ url }, "Fetching actions from url");
|
|
25
|
-
const headers = createHeaders(onBeforeRequest, graphqlContext);
|
|
26
|
-
|
|
27
|
-
const fetchUrl = `${url}/info`;
|
|
28
|
-
try {
|
|
29
|
-
const response = await fetch(fetchUrl, {
|
|
30
|
-
method: "POST",
|
|
31
|
-
headers,
|
|
32
|
-
body: JSON.stringify({
|
|
33
|
-
properties: graphqlContext.properties,
|
|
34
|
-
frontendUrl,
|
|
35
|
-
}),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
if (!response.ok) {
|
|
39
|
-
logger.error(
|
|
40
|
-
{ url, status: response.status, body: await response.text() },
|
|
41
|
-
"Failed to fetch actions from url",
|
|
42
|
-
);
|
|
43
|
-
throw new ResolvedCopilotKitError({
|
|
44
|
-
status: response.status,
|
|
45
|
-
url: fetchUrl,
|
|
46
|
-
isRemoteEndpoint: true,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
const json = await response.json();
|
|
51
|
-
logger.debug({ json }, "Fetched actions from url");
|
|
52
|
-
return json;
|
|
53
|
-
} catch (error) {
|
|
54
|
-
if (error instanceof CopilotKitError) {
|
|
55
|
-
throw error;
|
|
56
|
-
}
|
|
57
|
-
throw new CopilotKitLowLevelError({ error, url: fetchUrl });
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// Utility to determine if an error is a user configuration issue vs system error
|
|
62
|
-
export function isUserConfigurationError(error: any): boolean {
|
|
63
|
-
return (
|
|
64
|
-
(error instanceof CopilotKitError ||
|
|
65
|
-
error instanceof CopilotKitLowLevelError) &&
|
|
66
|
-
(error.code === "NETWORK_ERROR" ||
|
|
67
|
-
error.code === "AUTHENTICATION_ERROR" ||
|
|
68
|
-
error.statusCode === 401 ||
|
|
69
|
-
error.statusCode === 403 ||
|
|
70
|
-
error.message?.toLowerCase().includes("authentication") ||
|
|
71
|
-
error.message?.toLowerCase().includes("api key"))
|
|
72
|
-
);
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
export function createHeaders(
|
|
76
|
-
onBeforeRequest: CopilotKitEndpoint["onBeforeRequest"],
|
|
77
|
-
graphqlContext: GraphQLContext,
|
|
78
|
-
) {
|
|
79
|
-
const headers = {
|
|
80
|
-
"Content-Type": "application/json",
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
if (onBeforeRequest) {
|
|
84
|
-
const { headers: additionalHeaders } = onBeforeRequest({
|
|
85
|
-
ctx: graphqlContext,
|
|
86
|
-
});
|
|
87
|
-
if (additionalHeaders) {
|
|
88
|
-
Object.assign(headers, additionalHeaders);
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
return headers;
|
|
93
|
-
}
|
package/src/lib/streaming.ts
DELETED
|
@@ -1,220 +0,0 @@
|
|
|
1
|
-
import { ReplaySubject } from "rxjs";
|
|
2
|
-
import {
|
|
3
|
-
CopilotKitLowLevelError,
|
|
4
|
-
CopilotKitError,
|
|
5
|
-
CopilotKitErrorCode,
|
|
6
|
-
ensureStructuredError,
|
|
7
|
-
} from "@copilotkit/shared";
|
|
8
|
-
import { errorConfig, getFallbackMessage } from "./error-messages";
|
|
9
|
-
|
|
10
|
-
export async function writeJsonLineResponseToEventStream<T>(
|
|
11
|
-
response: ReadableStream<Uint8Array>,
|
|
12
|
-
eventStream$: ReplaySubject<T>,
|
|
13
|
-
) {
|
|
14
|
-
const reader = response.getReader();
|
|
15
|
-
const decoder = new TextDecoder();
|
|
16
|
-
let buffer = [];
|
|
17
|
-
|
|
18
|
-
function flushBuffer() {
|
|
19
|
-
const currentBuffer = buffer.join("");
|
|
20
|
-
if (currentBuffer.trim().length === 0) {
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const parts = currentBuffer.split("\n");
|
|
24
|
-
if (parts.length === 0) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const lastPartIsComplete = currentBuffer.endsWith("\n");
|
|
29
|
-
|
|
30
|
-
// truncate buffer
|
|
31
|
-
buffer = [];
|
|
32
|
-
|
|
33
|
-
if (!lastPartIsComplete) {
|
|
34
|
-
// put back the last part
|
|
35
|
-
buffer.push(parts.pop());
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
parts
|
|
39
|
-
.map((part) => part.trim())
|
|
40
|
-
.filter((part) => part != "")
|
|
41
|
-
.forEach((part) => {
|
|
42
|
-
eventStream$.next(JSON.parse(part));
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
try {
|
|
47
|
-
while (true) {
|
|
48
|
-
const { done, value } = await reader.read();
|
|
49
|
-
|
|
50
|
-
if (!done) {
|
|
51
|
-
buffer.push(decoder.decode(value, { stream: true }));
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
flushBuffer();
|
|
55
|
-
|
|
56
|
-
if (done) {
|
|
57
|
-
break;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
} catch (error) {
|
|
61
|
-
// Preserve already structured CopilotKit errors, only convert unstructured errors
|
|
62
|
-
const structuredError = ensureStructuredError(
|
|
63
|
-
error,
|
|
64
|
-
convertStreamingErrorToStructured,
|
|
65
|
-
);
|
|
66
|
-
eventStream$.error(structuredError);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
eventStream$.complete();
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function convertStreamingErrorToStructured(error: any): CopilotKitError {
|
|
73
|
-
// Determine a more helpful error message based on context
|
|
74
|
-
let helpfulMessage = generateHelpfulErrorMessage(error);
|
|
75
|
-
|
|
76
|
-
// For network-related errors, use CopilotKitLowLevelError to preserve the original error
|
|
77
|
-
if (
|
|
78
|
-
error?.message?.includes("fetch failed") ||
|
|
79
|
-
error?.message?.includes("ECONNREFUSED") ||
|
|
80
|
-
error?.message?.includes("ENOTFOUND") ||
|
|
81
|
-
error?.message?.includes("ETIMEDOUT") ||
|
|
82
|
-
error?.message?.includes("terminated") ||
|
|
83
|
-
error?.cause?.code === "UND_ERR_SOCKET" ||
|
|
84
|
-
error?.message?.includes("other side closed") ||
|
|
85
|
-
error?.code === "UND_ERR_SOCKET"
|
|
86
|
-
) {
|
|
87
|
-
console.log("error", error);
|
|
88
|
-
return new CopilotKitLowLevelError({
|
|
89
|
-
error: error instanceof Error ? error : new Error(String(error)),
|
|
90
|
-
url: "streaming connection",
|
|
91
|
-
message: helpfulMessage,
|
|
92
|
-
});
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
// For all other errors, preserve the raw error in a basic CopilotKitError
|
|
96
|
-
return new CopilotKitError({
|
|
97
|
-
message: helpfulMessage,
|
|
98
|
-
code: CopilotKitErrorCode.UNKNOWN,
|
|
99
|
-
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
/**
|
|
103
|
-
* Generates a helpful error message based on error patterns and context
|
|
104
|
-
*/
|
|
105
|
-
export function generateHelpfulErrorMessage(
|
|
106
|
-
error: any,
|
|
107
|
-
context: string = "connection",
|
|
108
|
-
): string {
|
|
109
|
-
const baseMessage = error?.message || String(error);
|
|
110
|
-
|
|
111
|
-
// Check for preserved error information from Python agent
|
|
112
|
-
const originalErrorType =
|
|
113
|
-
error?.originalErrorType || error?.extensions?.originalErrorType;
|
|
114
|
-
const statusCode = error?.statusCode || error?.extensions?.statusCode;
|
|
115
|
-
const responseData = error?.responseData || error?.extensions?.responseData;
|
|
116
|
-
|
|
117
|
-
// First, try to match by original error type if available (more specific)
|
|
118
|
-
if (originalErrorType) {
|
|
119
|
-
const typeConfig = errorConfig.errorPatterns[originalErrorType];
|
|
120
|
-
if (typeConfig) {
|
|
121
|
-
return typeConfig.message.replace("{context}", context);
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
// Check for specific error patterns from configuration
|
|
126
|
-
for (const [pattern, config] of Object.entries(errorConfig.errorPatterns)) {
|
|
127
|
-
const shouldMatch =
|
|
128
|
-
baseMessage?.includes(pattern) ||
|
|
129
|
-
error?.cause?.code === pattern ||
|
|
130
|
-
error?.code === pattern ||
|
|
131
|
-
statusCode === parseInt(pattern) ||
|
|
132
|
-
(pattern === "other_side_closed" &&
|
|
133
|
-
baseMessage?.includes("other side closed")) ||
|
|
134
|
-
(pattern === "fetch_failed" && baseMessage?.includes("fetch failed")) ||
|
|
135
|
-
(responseData && JSON.stringify(responseData).includes(pattern));
|
|
136
|
-
|
|
137
|
-
if (shouldMatch) {
|
|
138
|
-
// Replace {context} placeholder with actual context
|
|
139
|
-
return config.message.replace("{context}", context);
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// Try to match by category for fallback messages
|
|
144
|
-
if (isNetworkError(error)) {
|
|
145
|
-
return getFallbackMessage("network");
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
if (isConnectionError(error)) {
|
|
149
|
-
return getFallbackMessage("connection");
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
if (isAuthenticationError(error)) {
|
|
153
|
-
return getFallbackMessage("authentication");
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Default fallback
|
|
157
|
-
return getFallbackMessage("default");
|
|
158
|
-
}
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* Determines if an error is network-related
|
|
162
|
-
*/
|
|
163
|
-
function isNetworkError(error: any): boolean {
|
|
164
|
-
const networkPatterns = [
|
|
165
|
-
"ECONNREFUSED",
|
|
166
|
-
"ENOTFOUND",
|
|
167
|
-
"ETIMEDOUT",
|
|
168
|
-
"fetch_failed",
|
|
169
|
-
];
|
|
170
|
-
return networkPatterns.some(
|
|
171
|
-
(pattern) =>
|
|
172
|
-
error?.message?.includes(pattern) ||
|
|
173
|
-
error?.cause?.code === pattern ||
|
|
174
|
-
error?.code === pattern,
|
|
175
|
-
);
|
|
176
|
-
}
|
|
177
|
-
|
|
178
|
-
/**
|
|
179
|
-
* Determines if an error is connection-related
|
|
180
|
-
*/
|
|
181
|
-
function isConnectionError(error: any): boolean {
|
|
182
|
-
const connectionPatterns = [
|
|
183
|
-
"terminated",
|
|
184
|
-
"UND_ERR_SOCKET",
|
|
185
|
-
"other side closed",
|
|
186
|
-
];
|
|
187
|
-
return connectionPatterns.some(
|
|
188
|
-
(pattern) =>
|
|
189
|
-
error?.message?.includes(pattern) ||
|
|
190
|
-
error?.cause?.code === pattern ||
|
|
191
|
-
error?.code === pattern,
|
|
192
|
-
);
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
/**
|
|
196
|
-
* Determines if an error is authentication-related
|
|
197
|
-
*/
|
|
198
|
-
function isAuthenticationError(error: any): boolean {
|
|
199
|
-
const authPatterns = [
|
|
200
|
-
"401",
|
|
201
|
-
"api key",
|
|
202
|
-
"unauthorized",
|
|
203
|
-
"authentication",
|
|
204
|
-
"AuthenticationError",
|
|
205
|
-
"PermissionDeniedError",
|
|
206
|
-
];
|
|
207
|
-
const baseMessage = error?.message || String(error);
|
|
208
|
-
const originalErrorType =
|
|
209
|
-
error?.originalErrorType || error?.extensions?.originalErrorType;
|
|
210
|
-
const statusCode = error?.statusCode || error?.extensions?.statusCode;
|
|
211
|
-
|
|
212
|
-
return authPatterns.some(
|
|
213
|
-
(pattern) =>
|
|
214
|
-
baseMessage?.toLowerCase().includes(pattern.toLowerCase()) ||
|
|
215
|
-
originalErrorType === pattern ||
|
|
216
|
-
statusCode === 401 ||
|
|
217
|
-
error?.status === 401 ||
|
|
218
|
-
error?.statusCode === 401,
|
|
219
|
-
);
|
|
220
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { TelemetryClient } from "@copilotkit/shared";
|
|
2
|
-
import { createHash } from "node:crypto";
|
|
3
|
-
import { CopilotRuntime, resolveEndpointType } from "./runtime/copilot-runtime";
|
|
4
|
-
import { RuntimeInstanceCreatedInfo } from "@copilotkit/shared/src/telemetry/events";
|
|
5
|
-
import { CreateCopilotRuntimeServerOptions } from "./integrations/shared";
|
|
6
|
-
import { EndpointType, LangGraphPlatformEndpoint } from "./runtime/types";
|
|
7
|
-
const packageJson = require("../../package.json");
|
|
8
|
-
|
|
9
|
-
const telemetryClient = new TelemetryClient({
|
|
10
|
-
packageName: packageJson.name,
|
|
11
|
-
packageVersion: packageJson.version,
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
export function getRuntimeInstanceTelemetryInfo(
|
|
15
|
-
options: CreateCopilotRuntimeServerOptions,
|
|
16
|
-
): RuntimeInstanceCreatedInfo {
|
|
17
|
-
const runtime = options.runtime;
|
|
18
|
-
const remoteEndpoints = runtime.params?.remoteEndpoints ?? [];
|
|
19
|
-
const endpointsInfo = remoteEndpoints.reduce(
|
|
20
|
-
(acc, endpoint) => {
|
|
21
|
-
let info = { ...acc };
|
|
22
|
-
|
|
23
|
-
const endpointType = resolveEndpointType(endpoint);
|
|
24
|
-
if (!info.endpointTypes.includes(endpointType)) {
|
|
25
|
-
info = {
|
|
26
|
-
...info,
|
|
27
|
-
endpointTypes: [...info.endpointTypes, endpointType],
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
if (endpointType === EndpointType.LangGraphPlatform) {
|
|
32
|
-
// When type is resolved, recreating a const with casting of type
|
|
33
|
-
const ep = endpoint as LangGraphPlatformEndpoint;
|
|
34
|
-
info = {
|
|
35
|
-
...info,
|
|
36
|
-
agentsAmount: ep.agents.length,
|
|
37
|
-
hashedKey: ep.langsmithApiKey
|
|
38
|
-
? createHash("sha256").update(ep.langsmithApiKey).digest("hex")
|
|
39
|
-
: null,
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
return info;
|
|
44
|
-
},
|
|
45
|
-
{ endpointTypes: [], agentsAmount: null, hashedKey: null },
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
// Get public API key from options.cloud.publicApiKey
|
|
49
|
-
const publicApiKey = options.cloud?.publicApiKey;
|
|
50
|
-
const apiKeyProvided = !!publicApiKey && publicApiKey.trim().length > 0;
|
|
51
|
-
|
|
52
|
-
return {
|
|
53
|
-
actionsAmount: runtime.params?.actions?.length ?? 0,
|
|
54
|
-
endpointsAmount: remoteEndpoints.length,
|
|
55
|
-
endpointTypes: endpointsInfo.endpointTypes,
|
|
56
|
-
agentsAmount: Object.keys(runtime.instance.agents).length,
|
|
57
|
-
hashedLgcKey: endpointsInfo.hashedKey,
|
|
58
|
-
"cloud.api_key_provided": apiKeyProvided,
|
|
59
|
-
...(apiKeyProvided ? { "cloud.public_api_key": publicApiKey } : {}),
|
|
60
|
-
...(options.cloud?.baseUrl
|
|
61
|
-
? { "cloud.base_url": options.cloud.baseUrl }
|
|
62
|
-
: {}),
|
|
63
|
-
} as RuntimeInstanceCreatedInfo;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
export default telemetryClient;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// Runtime-side anonymous telemetry disclosure log.
|
|
2
|
-
//
|
|
3
|
-
// The runtime has shipped anonymous telemetry for some time (see
|
|
4
|
-
// `packages/shared/src/telemetry/telemetry-client.ts`). This file just
|
|
5
|
-
// surfaces a one-line pointer to the opt-out docs on first
|
|
6
|
-
// instantiation so operators don't have to dig through the docs site
|
|
7
|
-
// to discover the existing behavior. Pairs with the inspector's
|
|
8
|
-
// first-run console disclosure for a consistent operator-facing
|
|
9
|
-
// surface.
|
|
10
|
-
//
|
|
11
|
-
// Fires at most once per process — runtime instances may be constructed
|
|
12
|
-
// multiple times (tests, hot-reload), but the disclosure is informational
|
|
13
|
-
// and a single line is enough.
|
|
14
|
-
|
|
15
|
-
// Canonical telemetry docs page on main.
|
|
16
|
-
// Mirror constant: packages/web-inspector/src/lib/telemetry.ts
|
|
17
|
-
const TELEMETRY_DOCS_URL = "https://docs.copilotkit.ai/telemetry";
|
|
18
|
-
|
|
19
|
-
function isTelemetryDisabled(): boolean {
|
|
20
|
-
const env = process.env as Record<string, string | undefined>;
|
|
21
|
-
return (
|
|
22
|
-
env.COPILOTKIT_TELEMETRY_DISABLED === "true" ||
|
|
23
|
-
env.COPILOTKIT_TELEMETRY_DISABLED === "1" ||
|
|
24
|
-
env.DO_NOT_TRACK === "true" ||
|
|
25
|
-
env.DO_NOT_TRACK === "1"
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
let disclosureLogged = false;
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Logs a one-line console.info about anonymous telemetry on runtime
|
|
33
|
-
* startup. No-op when telemetry is disabled via `COPILOTKIT_TELEMETRY_DISABLED`
|
|
34
|
-
* or `DO_NOT_TRACK`, or when already logged once in this process.
|
|
35
|
-
*
|
|
36
|
-
* Idempotent — safe to call from multiple constructor paths.
|
|
37
|
-
*/
|
|
38
|
-
export function logRuntimeTelemetryDisclosure(): void {
|
|
39
|
-
if (disclosureLogged) return;
|
|
40
|
-
if (isTelemetryDisabled()) return;
|
|
41
|
-
disclosureLogged = true;
|
|
42
|
-
// eslint-disable-next-line no-console
|
|
43
|
-
console.info(
|
|
44
|
-
`[CopilotKit Runtime] anonymous telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`,
|
|
45
|
-
);
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
// Test-only reset hook so the once-per-process guard doesn't leak between
|
|
49
|
-
// test cases. Not part of the public package surface — used by the runtime
|
|
50
|
-
// disclosure tests.
|
|
51
|
-
export function _resetRuntimeTelemetryDisclosureForTesting(): void {
|
|
52
|
-
disclosureLogged = false;
|
|
53
|
-
}
|