@copilotkit/runtime 1.69.3 → 1.70.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (146) hide show
  1. package/dist/agent/index.cjs +1 -1
  2. package/dist/agent/index.d.mts +1 -1
  3. package/dist/agent/index.mjs +1 -1
  4. package/dist/graphql/resolvers/copilot.resolver.cjs +1 -2
  5. package/dist/graphql/resolvers/copilot.resolver.cjs.map +1 -1
  6. package/dist/graphql/resolvers/copilot.resolver.mjs +1 -2
  7. package/dist/graphql/resolvers/copilot.resolver.mjs.map +1 -1
  8. package/dist/lib/integrations/nest/index.cjs +1 -1
  9. package/dist/lib/integrations/nest/index.cjs.map +1 -1
  10. package/dist/lib/integrations/nest/index.mjs +1 -1
  11. package/dist/lib/integrations/nest/index.mjs.map +1 -1
  12. package/dist/lib/integrations/nextjs/app-router.cjs +1 -1
  13. package/dist/lib/integrations/nextjs/app-router.cjs.map +1 -1
  14. package/dist/lib/integrations/nextjs/app-router.d.cts.map +1 -1
  15. package/dist/lib/integrations/nextjs/app-router.d.mts.map +1 -1
  16. package/dist/lib/integrations/nextjs/app-router.mjs +1 -1
  17. package/dist/lib/integrations/nextjs/app-router.mjs.map +1 -1
  18. package/dist/lib/integrations/nextjs/pages-router.cjs +1 -1
  19. package/dist/lib/integrations/nextjs/pages-router.cjs.map +1 -1
  20. package/dist/lib/integrations/nextjs/pages-router.mjs +1 -1
  21. package/dist/lib/integrations/nextjs/pages-router.mjs.map +1 -1
  22. package/dist/lib/integrations/node-express/index.cjs +1 -1
  23. package/dist/lib/integrations/node-express/index.cjs.map +1 -1
  24. package/dist/lib/integrations/node-express/index.mjs +1 -1
  25. package/dist/lib/integrations/node-express/index.mjs.map +1 -1
  26. package/dist/lib/integrations/node-http/index.cjs +1 -1
  27. package/dist/lib/integrations/node-http/index.cjs.map +1 -1
  28. package/dist/lib/integrations/node-http/index.d.cts.map +1 -1
  29. package/dist/lib/integrations/node-http/index.d.mts.map +1 -1
  30. package/dist/lib/integrations/node-http/index.mjs +1 -1
  31. package/dist/lib/integrations/node-http/index.mjs.map +1 -1
  32. package/dist/lib/integrations/shared.cjs +1 -1
  33. package/dist/lib/integrations/shared.mjs +1 -1
  34. package/dist/lib/runtime/copilot-runtime.cjs +13 -5
  35. package/dist/lib/runtime/copilot-runtime.cjs.map +1 -1
  36. package/dist/lib/runtime/copilot-runtime.d.cts +5 -1
  37. package/dist/lib/runtime/copilot-runtime.d.cts.map +1 -1
  38. package/dist/lib/runtime/copilot-runtime.d.mts +5 -1
  39. package/dist/lib/runtime/copilot-runtime.d.mts.map +1 -1
  40. package/dist/lib/runtime/copilot-runtime.mjs +13 -5
  41. package/dist/lib/runtime/copilot-runtime.mjs.map +1 -1
  42. package/dist/lib/runtime/telemetry-agent-runner.cjs +4 -3
  43. package/dist/lib/runtime/telemetry-agent-runner.cjs.map +1 -1
  44. package/dist/lib/runtime/telemetry-agent-runner.d.cts +4 -0
  45. package/dist/lib/runtime/telemetry-agent-runner.d.cts.map +1 -1
  46. package/dist/lib/runtime/telemetry-agent-runner.d.mts +4 -0
  47. package/dist/lib/runtime/telemetry-agent-runner.d.mts.map +1 -1
  48. package/dist/lib/runtime/telemetry-agent-runner.mjs +4 -3
  49. package/dist/lib/runtime/telemetry-agent-runner.mjs.map +1 -1
  50. package/dist/lib/telemetry-disclosure.cjs +4 -4
  51. package/dist/lib/telemetry-disclosure.cjs.map +1 -1
  52. package/dist/lib/telemetry-disclosure.mjs +4 -4
  53. package/dist/lib/telemetry-disclosure.mjs.map +1 -1
  54. package/dist/package.cjs +4 -4
  55. package/dist/package.mjs +4 -4
  56. package/dist/v2/index.d.cts +3 -3
  57. package/dist/v2/index.d.mts +3 -3
  58. package/dist/v2/runtime/core/channel-manager.cjs +24 -8
  59. package/dist/v2/runtime/core/channel-manager.cjs.map +1 -1
  60. package/dist/v2/runtime/core/channel-manager.d.cts.map +1 -1
  61. package/dist/v2/runtime/core/channel-manager.d.mts +1 -1
  62. package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
  63. package/dist/v2/runtime/core/channel-manager.mjs +25 -9
  64. package/dist/v2/runtime/core/channel-manager.mjs.map +1 -1
  65. package/dist/v2/runtime/core/fetch-handler.cjs +1 -0
  66. package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
  67. package/dist/v2/runtime/core/fetch-handler.d.cts.map +1 -1
  68. package/dist/v2/runtime/core/fetch-handler.d.mts.map +1 -1
  69. package/dist/v2/runtime/core/fetch-handler.mjs +1 -0
  70. package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
  71. package/dist/v2/runtime/core/learning.cjs +7 -0
  72. package/dist/v2/runtime/core/learning.cjs.map +1 -1
  73. package/dist/v2/runtime/core/learning.d.cts +21 -1
  74. package/dist/v2/runtime/core/learning.d.cts.map +1 -1
  75. package/dist/v2/runtime/core/learning.d.mts +21 -1
  76. package/dist/v2/runtime/core/learning.d.mts.map +1 -1
  77. package/dist/v2/runtime/core/learning.mjs +7 -1
  78. package/dist/v2/runtime/core/learning.mjs.map +1 -1
  79. package/dist/v2/runtime/core/runtime.cjs +10 -4
  80. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  81. package/dist/v2/runtime/core/runtime.d.cts +17 -7
  82. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  83. package/dist/v2/runtime/core/runtime.d.mts +17 -7
  84. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  85. package/dist/v2/runtime/core/runtime.mjs +10 -4
  86. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  87. package/dist/v2/runtime/handlers/get-runtime-info.cjs +53 -2
  88. package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
  89. package/dist/v2/runtime/handlers/get-runtime-info.mjs +53 -2
  90. package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
  91. package/dist/v2/runtime/handlers/handle-connect.cjs +1 -1
  92. package/dist/v2/runtime/handlers/handle-connect.cjs.map +1 -1
  93. package/dist/v2/runtime/handlers/handle-connect.mjs +1 -1
  94. package/dist/v2/runtime/handlers/handle-connect.mjs.map +1 -1
  95. package/dist/v2/runtime/handlers/handle-run.cjs +1 -1
  96. package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
  97. package/dist/v2/runtime/handlers/handle-run.mjs +1 -1
  98. package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
  99. package/dist/v2/runtime/handlers/intelligence/run.cjs +11 -4
  100. package/dist/v2/runtime/handlers/intelligence/run.cjs.map +1 -1
  101. package/dist/v2/runtime/handlers/intelligence/run.mjs +12 -5
  102. package/dist/v2/runtime/handlers/intelligence/run.mjs.map +1 -1
  103. package/dist/v2/runtime/handlers/shared/sse-response.cjs +4 -4
  104. package/dist/v2/runtime/handlers/shared/sse-response.cjs.map +1 -1
  105. package/dist/v2/runtime/handlers/shared/sse-response.mjs +4 -4
  106. package/dist/v2/runtime/handlers/shared/sse-response.mjs.map +1 -1
  107. package/dist/v2/runtime/handlers/sse/connect.cjs +1 -0
  108. package/dist/v2/runtime/handlers/sse/connect.cjs.map +1 -1
  109. package/dist/v2/runtime/handlers/sse/connect.mjs +1 -0
  110. package/dist/v2/runtime/handlers/sse/connect.mjs.map +1 -1
  111. package/dist/v2/runtime/handlers/sse/run.cjs +1 -0
  112. package/dist/v2/runtime/handlers/sse/run.cjs.map +1 -1
  113. package/dist/v2/runtime/handlers/sse/run.mjs +1 -0
  114. package/dist/v2/runtime/handlers/sse/run.mjs.map +1 -1
  115. package/dist/v2/runtime/index.d.cts +2 -2
  116. package/dist/v2/runtime/index.d.mts +2 -2
  117. package/dist/v2/runtime/intelligence-platform/client.cjs +170 -3
  118. package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
  119. package/dist/v2/runtime/intelligence-platform/client.d.cts +22 -3
  120. package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
  121. package/dist/v2/runtime/intelligence-platform/client.d.mts +22 -3
  122. package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
  123. package/dist/v2/runtime/intelligence-platform/client.mjs +170 -3
  124. package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
  125. package/dist/v2/runtime/telemetry/events.d.cts +55 -0
  126. package/dist/v2/runtime/telemetry/events.d.cts.map +1 -0
  127. package/dist/v2/runtime/telemetry/events.d.mts +55 -0
  128. package/dist/v2/runtime/telemetry/events.d.mts.map +1 -0
  129. package/dist/v2/runtime/telemetry/instance-created.cjs +4 -2
  130. package/dist/v2/runtime/telemetry/instance-created.cjs.map +1 -1
  131. package/dist/v2/runtime/telemetry/instance-created.mjs +4 -2
  132. package/dist/v2/runtime/telemetry/instance-created.mjs.map +1 -1
  133. package/dist/v2/runtime/telemetry/telemetry-client.cjs +48 -6
  134. package/dist/v2/runtime/telemetry/telemetry-client.cjs.map +1 -1
  135. package/dist/v2/runtime/telemetry/telemetry-client.d.cts +11 -0
  136. package/dist/v2/runtime/telemetry/telemetry-client.d.cts.map +1 -0
  137. package/dist/v2/runtime/telemetry/telemetry-client.d.mts +11 -0
  138. package/dist/v2/runtime/telemetry/telemetry-client.d.mts.map +1 -0
  139. package/dist/v2/runtime/telemetry/telemetry-client.mjs +50 -7
  140. package/dist/v2/runtime/telemetry/telemetry-client.mjs.map +1 -1
  141. package/dist/v2/runtime/telemetry/telemetry-identity.cjs +13 -0
  142. package/dist/v2/runtime/telemetry/telemetry-identity.cjs.map +1 -0
  143. package/dist/v2/runtime/telemetry/telemetry-identity.mjs +12 -0
  144. package/dist/v2/runtime/telemetry/telemetry-identity.mjs.map +1 -0
  145. package/package.json +7 -7
  146. package/skills/runtime/SKILL.md +1 -1
@@ -2,6 +2,7 @@ import "reflect-metadata";
2
2
  import { aguiToGQL } from "../../graphql/message-conversion/agui-to-gql.mjs";
3
3
  import { logRuntimeTelemetryDisclosure } from "../telemetry-disclosure.mjs";
4
4
  import { InMemoryAgentRunner } from "../../v2/runtime/runner/in-memory.mjs";
5
+ import { firstNonBlankLicenseToken, firstNonBlankTelemetryId } from "../../v2/runtime/telemetry/telemetry-identity.mjs";
5
6
  import { createRuntimeErrorReporter, runtimeErrorReporterOption } from "../../v2/runtime/core/runtime-error-reporter.mjs";
6
7
  import { CopilotRuntime as CopilotRuntime$1 } from "../../v2/runtime/core/runtime.mjs";
7
8
  import { TelemetryAgentRunner } from "./telemetry-agent-runner.mjs";
@@ -54,13 +55,20 @@ var CopilotRuntime = class {
54
55
  ...endpointAgents,
55
56
  ...resolved
56
57
  }));
58
+ const resolvedLicenseToken = firstNonBlankLicenseToken(params?.licenseToken, process.env.COPILOTKIT_LICENSE_TOKEN);
59
+ const resolvedTelemetryId = firstNonBlankTelemetryId(params?.telemetryId, process.env.CPK_TELEMETRY_ID);
60
+ const resolvedTelemetryIdentity = resolvedTelemetryId !== void 0 ? { telemetryId: resolvedTelemetryId } : resolvedLicenseToken !== void 0 ? { licenseToken: resolvedLicenseToken } : {};
61
+ this.telemetry = telemetryClient.createScope(resolvedTelemetryIdentity);
57
62
  const baseRunner = params?.runner ?? new InMemoryAgentRunner();
58
- const runner = isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({ runner: baseRunner });
59
- const resolvedLicenseToken = params?.licenseToken ?? process.env.COPILOTKIT_LICENSE_TOKEN;
60
- if (resolvedLicenseToken) telemetryClient.setLicenseToken(resolvedLicenseToken);
63
+ const runner = isTelemetryDisabled() ? baseRunner : new TelemetryAgentRunner({
64
+ runner: baseRunner,
65
+ telemetry: this.telemetry
66
+ });
61
67
  const sharedRuntimeArgs = {
62
68
  agents: mergedAgents,
63
- licenseToken: params?.licenseToken,
69
+ telemetryId: resolvedTelemetryId,
70
+ licenseToken: resolvedLicenseToken,
71
+ telemetryProperties: params?.telemetryProperties,
64
72
  debug: params?.debug,
65
73
  beforeRequestMiddleware: this.createOnBeforeRequestHandler(params).bind(this),
66
74
  ...params?.afterRequestMiddleware || params?.middleware?.onAfterRequest ? { afterRequestMiddleware: this.createOnAfterRequestHandler(params).bind(this) } : {},
@@ -160,7 +168,7 @@ var CopilotRuntime = class {
160
168
  const body = await readBody(request);
161
169
  const forwardedProps = body?.forwardedProps;
162
170
  const cloudBaseUrl = process.env.COPILOT_CLOUD_BASE_URL || "https://api.cloud.copilotkit.ai";
163
- telemetryClient.capture("oss.runtime.copilot_request_created", {
171
+ this.telemetry.capture("oss.runtime.copilot_request_created", {
164
172
  "cloud.guardrails.enabled": forwardedProps?.cloud?.guardrails !== void 0,
165
173
  requestType: forwardedProps?.metadata?.requestType ?? "unknown",
166
174
  "cloud.api_key_provided": !!publicApiKey,
@@ -1 +1 @@
1
- {"version":3,"file":"copilot-runtime.mjs","names":["CopilotRuntimeVNext"],"sources":["../../../../src/v1-deprecated/lib/runtime/copilot-runtime.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotKitEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — CopilotRuntime:\n * V2 import and usage:\n * import { CopilotRuntime } from \"@copilotkit/runtime/v2\";\n *\n * const runtime = new CopilotRuntime({ agents: {} });\n * V2 replacement source: packages/runtime/src/v2/runtime/core/runtime.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n * Migration note: V2 uses AG-UI runtime handlers instead of the v1 GraphQL adapter setup.\n *\n * @copilotkit/runtime — CopilotRuntimeConstructorParams_BASE:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — langGraphPlatformEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — resolveEndpointType:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * <Callout type=\"info\">\n * This is the reference for the `CopilotRuntime` class. For more information and example code snippets, please see [Concept: Copilot Runtime](/backend/copilot-runtime).\n * </Callout>\n *\n * ## Usage\n *\n * ```tsx\n * import { CopilotRuntime } from \"@copilotkit/runtime\";\n *\n * const copilotKit = new CopilotRuntime();\n * ```\n */\n\nimport {\n CopilotKitMisuseError,\n readBody,\n getZodParameters,\n isTelemetryDisabled,\n} from \"@copilotkit/shared\";\nimport type {\n Action,\n CopilotErrorHandler,\n MaybePromise,\n NonEmptyRecord,\n Parameter,\n PartialBy,\n DebugConfig,\n} from \"@copilotkit/shared\";\nimport type { RunAgentInput } from \"@ag-ui/core\";\nimport { aguiToGQL } from \"../../graphql/message-conversion/agui-to-gql\";\nimport type {\n CopilotServiceAdapter,\n RemoteChainParameters,\n} from \"../../service-adapters\";\nimport {\n CopilotRuntime as CopilotRuntimeVNext,\n InMemoryAgentRunner,\n} from \"../../../v2/runtime\";\nimport {\n createRuntimeErrorReporter,\n runtimeErrorReporterOption,\n} from \"../../../v2/runtime/core/runtime-error-reporter\";\nimport type { RuntimeErrorReporterOptions } from \"../../../v2/runtime/core/runtime-error-reporter\";\nimport type {\n CopilotIntelligenceRuntimeOptions,\n CopilotRuntimeOptions,\n CopilotRuntimeOptions as CopilotRuntimeOptionsVNext,\n AgentRunner,\n AgentsConfig,\n AgentsFactory,\n AgentFactoryContext,\n} from \"../../../v2/runtime\";\n\nexport type { AgentsConfig, AgentsFactory, AgentFactoryContext };\nimport { TelemetryAgentRunner } from \"./telemetry-agent-runner\";\nimport telemetry from \"../telemetry-client\";\nimport { logRuntimeTelemetryDisclosure } from \"../telemetry-disclosure\";\n\nimport type { MessageInput } from \"../../graphql/inputs/message.input\";\nimport type { Message } from \"../../graphql/types/converted\";\n\nimport { EndpointType } from \"./types\";\nimport type {\n EndpointDefinition,\n CopilotKitEndpoint,\n LangGraphPlatformEndpoint,\n} from \"./types\";\n\nimport type {\n CopilotObservabilityConfig,\n LLMRequestData,\n LLMResponseData,\n} from \"../observability\";\nimport type { AbstractAgent } from \"@ag-ui/client\";\n\n// +++ MCP Imports +++\nimport { extractParametersFromSchema } from \"./mcp-tools-utils\";\nimport type { MCPClient, MCPEndpointConfig, MCPTool } from \"./mcp-tools-utils\";\nimport { BuiltInAgent } from \"../../../agent\";\nimport type { BuiltInAgentClassicConfig } from \"../../../agent\";\n// Define the function type alias here or import if defined elsewhere\ntype CreateMCPClientFunction = (\n config: MCPEndpointConfig,\n) => Promise<MCPClient>;\n\ntype ActionsConfiguration<T extends Parameter[] | [] = []> =\n | Action<T>[]\n | ((ctx: { properties: any; url?: string }) => Action<T>[]);\n\ninterface OnBeforeRequestOptions {\n threadId?: string;\n runId?: string;\n inputMessages: Message[];\n properties: any;\n url?: string;\n}\n\ntype OnBeforeRequestHandler = (\n options: OnBeforeRequestOptions,\n) => void | Promise<void>;\n\ninterface OnAfterRequestOptions {\n threadId: string;\n runId?: string;\n inputMessages: Message[];\n outputMessages: Message[];\n properties: any;\n url?: string;\n}\n\ntype OnAfterRequestHandler = (\n options: OnAfterRequestOptions,\n) => void | Promise<void>;\n\ninterface OnStopGenerationOptions {\n threadId: string;\n runId?: string;\n url?: string;\n agentName?: string;\n lastMessage: MessageInput;\n}\ntype OnStopGenerationHandler = (\n options: OnStopGenerationOptions,\n) => void | Promise<void>;\n\ninterface Middleware {\n /**\n * A function that is called before the request is processed.\n */\n /**\n * @deprecated This middleware hook is deprecated and will be removed in a future version.\n * Use updated middleware integration methods in CopilotRuntimeVNext instead.\n */\n onBeforeRequest?: OnBeforeRequestHandler;\n\n /**\n * A function that is called after the request is processed.\n */\n /**\n * @deprecated This middleware hook is deprecated and will be removed in a future version.\n * Use updated middleware integration methods in CopilotRuntimeVNext instead.\n */\n onAfterRequest?: OnAfterRequestHandler;\n}\n\nexport interface CopilotRuntimeConstructorParams_BASE<\n T extends Parameter[] | [] = [],\n> {\n /**\n * Middleware to be used by the runtime.\n *\n * ```ts\n * onBeforeRequest: (options: {\n * threadId?: string;\n * runId?: string;\n * inputMessages: Message[];\n * properties: any;\n * }) => void | Promise<void>;\n * ```\n *\n * ```ts\n * onAfterRequest: (options: {\n * threadId?: string;\n * runId?: string;\n * inputMessages: Message[];\n * outputMessages: Message[];\n * properties: any;\n * }) => void | Promise<void>;\n * ```\n */\n /**\n * @deprecated This middleware hook is deprecated and will be removed in a future version.\n * Use updated middleware integration methods in CopilotRuntimeVNext instead.\n */\n middleware?: Middleware;\n\n /*\n * A list of server side actions that can be executed. Will be ignored when remoteActions are set\n */\n actions?: ActionsConfiguration<T>;\n\n /*\n * Deprecated: Use `remoteEndpoints`.\n */\n remoteActions?: CopilotKitEndpoint[];\n\n /*\n * A list of remote actions that can be executed.\n */\n remoteEndpoints?: EndpointDefinition[];\n\n /*\n * An array of LangServer URLs.\n */\n langserve?: RemoteChainParameters[];\n\n /**\n * Optional agent runner to use for SSE runtime.\n */\n runner?: AgentRunner;\n\n /*\n * A map of agent names to AGUI agents.\n * Example agent config:\n * ```ts\n * import { AbstractAgent } from \"@ag-ui/client\";\n * // ...\n * agents: {\n * \"support\": new CustomerSupportAgent(),\n * \"technical\": new TechnicalAgent()\n * }\n * ```\n */\n agents?: Record<string, AbstractAgent>;\n\n /*\n * Delegates agent state processing to the service adapter.\n *\n * When enabled, individual agent state requests will not be processed by the agent itself.\n * Instead, all processing will be handled by the service adapter.\n */\n delegateAgentProcessingToServiceAdapter?: boolean;\n\n /**\n * Configuration for LLM request/response logging.\n *\n * Example logging config:\n * ```ts\n * logging: {\n * enabled: true, // Enable or disable logging\n * progressive: true, // Set to false for buffered logging\n * logger: {\n * logRequest: (data) => langfuse.trace({ name: \"LLM Request\", input: data }),\n * logResponse: (data) => langfuse.trace({ name: \"LLM Response\", output: data }),\n * logError: (errorData) => langfuse.trace({ name: \"LLM Error\", metadata: errorData }),\n * },\n * }\n * ```\n */\n observability_c?: CopilotObservabilityConfig;\n\n /**\n * Configuration for connecting to Model Context Protocol (MCP) servers.\n * Allows fetching and using tools defined on external MCP-compliant servers.\n * Requires providing the `createMCPClient` function during instantiation.\n * @experimental\n */\n mcpServers?: MCPEndpointConfig[];\n\n /**\n * A function that creates an MCP client instance for a given endpoint configuration.\n * This function is responsible for using the appropriate MCP client library\n * (e.g., `@copilotkit/runtime`, `ai`) to establish a connection.\n * Required if `mcpServers` is provided.\n *\n * ```typescript\n * import { experimental_createMCPClient } from \"ai\"; // Import from vercel ai library\n * // ...\n * const runtime = new CopilotRuntime({\n * mcpServers: [{ endpoint: \"...\" }],\n * async createMCPClient(config) {\n * return await experimental_createMCPClient({\n * transport: {\n * type: \"sse\",\n * url: config.endpoint,\n * headers: config.apiKey\n * ? { Authorization: `Bearer ${config.apiKey}` }\n * : undefined,\n * },\n * });\n * }\n * });\n * ```\n */\n createMCPClient?: CreateMCPClientFunction;\n\n /**\n * Optional error handler for comprehensive debugging and observability.\n *\n * @param errorEvent - Structured error event with rich debugging context\n *\n * @example\n * ```typescript\n * const runtime = new CopilotRuntime({\n * onError: (errorEvent) => {\n * debugDashboard.capture(errorEvent);\n * }\n * });\n * ```\n */\n onError?: CopilotErrorHandler;\n\n onStopGeneration?: OnStopGenerationHandler;\n\n /**\n * Enable debug logging for the runtime event pipeline.\n * Pass `true` for full output, or an object for granular control:\n *\n * ```ts\n * const runtime = new CopilotRuntime({\n * debug: true,\n * // or: debug: { events: true, lifecycle: true, verbose: false }\n * });\n * ```\n */\n debug?: DebugConfig;\n\n // /** Optional transcription service for audio processing. */\n // transcriptionService?: CopilotRuntimeOptionsVNext[\"transcriptionService\"];\n // /** Optional *before* middleware – callback function or webhook URL. */\n // beforeRequestMiddleware?: CopilotRuntimeOptionsVNext[\"beforeRequestMiddleware\"];\n // /** Optional *after* middleware – callback function or webhook URL. */\n // afterRequestMiddleware?: CopilotRuntimeOptionsVNext[\"afterRequestMiddleware\"];\n}\n\ntype BeforeRequestMiddleware =\n CopilotRuntimeOptionsVNext[\"beforeRequestMiddleware\"];\ntype AfterRequestMiddleware =\n CopilotRuntimeOptionsVNext[\"afterRequestMiddleware\"];\ntype BeforeRequestMiddlewareFn = Exclude<BeforeRequestMiddleware, string>;\ntype BeforeRequestMiddlewareFnParameters =\n Parameters<BeforeRequestMiddlewareFn>;\ntype BeforeRequestMiddlewareFnResult = ReturnType<BeforeRequestMiddlewareFn>;\ntype AfterRequestMiddlewareFn = Exclude<AfterRequestMiddleware, string>;\ntype AfterRequestMiddlewareFnParameters = Parameters<AfterRequestMiddlewareFn>;\n\ninterface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []>\n extends\n Omit<CopilotRuntimeConstructorParams_BASE<T>, \"agents\">,\n Omit<CopilotRuntimeOptionsVNext, \"agents\" | \"transcriptionService\"> {\n /**\n * TODO: un-omit `transcriptionService` above once it's supported\n *\n * This satisfies...\n * – the optional constraint in `CopilotRuntimeConstructorParams_BASE`\n * – the `MaybePromise<NonEmptyRecord<T>>` constraint in `CopilotRuntimeOptionsVNext`\n * – the `Record<string, AbstractAgent>` constraint in `both\n */\n agents?: AgentsConfig;\n\n intelligence?: CopilotIntelligenceRuntimeOptions[\"intelligence\"];\n identifyUser?: CopilotIntelligenceRuntimeOptions[\"identifyUser\"];\n memory?: CopilotIntelligenceRuntimeOptions[\"memory\"];\n channels?: CopilotIntelligenceRuntimeOptions[\"channels\"];\n ɵlearning?: CopilotIntelligenceRuntimeOptions[\"ɵlearning\"];\n generateThreadNames?: CopilotIntelligenceRuntimeOptions[\"generateThreadNames\"];\n maxReconnectMs?: CopilotIntelligenceRuntimeOptions[\"maxReconnectMs\"];\n maxRejoinMs?: CopilotIntelligenceRuntimeOptions[\"maxRejoinMs\"];\n lockTtlSeconds?: CopilotIntelligenceRuntimeOptions[\"lockTtlSeconds\"];\n lockKeyPrefix?: CopilotIntelligenceRuntimeOptions[\"lockKeyPrefix\"];\n lockHeartbeatIntervalSeconds?: CopilotIntelligenceRuntimeOptions[\"lockHeartbeatIntervalSeconds\"];\n}\n\n/**\n * Central runtime object passed to all request handlers.\n * @deprecated The v1 SDK is deprecated. Use v2 instead. Use `CopilotRuntime` from `@copilotkit/runtime/v2` instead.\n *\n * ```tsx\n * import { CopilotRuntime } from \"@copilotkit/runtime/v2\";\n *\n * const runtime = new CopilotRuntime({ agents: {} });\n * ```\n * See https://docs.copilotkit.ai/runtime-server-adapter\n */\nexport class CopilotRuntime<const T extends Parameter[] | [] = []> {\n params?: CopilotRuntimeConstructorParams<T>;\n private observability?: CopilotObservabilityConfig;\n // Cache MCP tools per endpoint to avoid re-fetching repeatedly\n private mcpToolsCache: Map<string, BuiltInAgentClassicConfig[\"tools\"]> =\n new Map();\n private runtimeArgs: CopilotRuntimeOptions & RuntimeErrorReporterOptions;\n private _instance: CopilotRuntimeVNext;\n\n constructor(params?: CopilotRuntimeConstructorParams<T>) {\n logRuntimeTelemetryDisclosure();\n\n const agents = params?.agents ?? {};\n const endpointAgents = this.assignEndpointsToAgents(\n params?.remoteEndpoints ?? [],\n );\n\n // Merge endpoint agents with user-provided agents.\n // When agents is a factory function, wrap it so endpoint agents are merged\n // at resolution time (spreading a function produces {} — silent data loss).\n let mergedAgents: AgentsConfig;\n if (typeof agents === \"function\") {\n mergedAgents = async (ctx) => {\n const resolved = await agents(ctx);\n return { ...endpointAgents, ...resolved };\n };\n } else {\n mergedAgents = Promise.resolve(agents).then((resolved) => ({\n ...endpointAgents,\n ...resolved,\n }));\n }\n\n // Determine the base runner (user-provided or default)\n const baseRunner = params?.runner ?? new InMemoryAgentRunner();\n\n // Wrap with TelemetryAgentRunner unless telemetry is disabled\n // This ensures we always capture agent execution telemetry when enabled,\n // even if the user provides their own custom runner\n const runner = isTelemetryDisabled()\n ? baseRunner\n : new TelemetryAgentRunner({ runner: baseRunner });\n\n // Match license-verifier's env fallback so telemetry attribution\n // resolves the same way as feature gating — otherwise customers who\n // set only COPILOTKIT_LICENSE_TOKEN would get a working license but\n // anonymous telemetry. Only used here for the telemetry setter; the\n // v2 runtime applies the same fallback to runtimeArgs.licenseToken\n // on its own.\n const resolvedLicenseToken =\n params?.licenseToken ?? process.env.COPILOTKIT_LICENSE_TOKEN;\n if (resolvedLicenseToken) {\n telemetry.setLicenseToken(resolvedLicenseToken);\n }\n\n const sharedRuntimeArgs = {\n agents: mergedAgents,\n licenseToken: params?.licenseToken,\n debug: params?.debug,\n // TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready\n // transcriptionService: params?.transcriptionService,\n\n beforeRequestMiddleware:\n this.createOnBeforeRequestHandler(params).bind(this),\n ...(params?.afterRequestMiddleware || params?.middleware?.onAfterRequest\n ? {\n afterRequestMiddleware:\n this.createOnAfterRequestHandler(params).bind(this),\n }\n : {}),\n a2ui: params?.a2ui,\n mcpApps: params?.mcpApps,\n openGenerativeUI: params?.openGenerativeUI,\n [runtimeErrorReporterOption]: createRuntimeErrorReporter(params?.onError),\n forwardHeaders: params?.forwardHeaders,\n exposeMemoryRoutes: params?.exposeMemoryRoutes,\n };\n if (params?.intelligence !== undefined) {\n // The compatibility constructor keeps Intelligence identity optional at\n // compile time, while the v2 runtime checks that callers supply web\n // identity, Channels, or both. Preserve that runtime validation here.\n this.runtimeArgs = {\n ...sharedRuntimeArgs,\n intelligence: params.intelligence,\n identifyUser: params.identifyUser,\n memory: params.memory,\n channels: params.channels,\n ɵlearning: params.ɵlearning,\n generateThreadNames: params.generateThreadNames,\n maxReconnectMs: params.maxReconnectMs,\n maxRejoinMs: params.maxRejoinMs,\n lockTtlSeconds: params.lockTtlSeconds,\n lockKeyPrefix: params.lockKeyPrefix,\n lockHeartbeatIntervalSeconds: params.lockHeartbeatIntervalSeconds,\n } as CopilotRuntimeOptions;\n } else {\n this.runtimeArgs = {\n ...sharedRuntimeArgs,\n runner,\n };\n }\n this.params = params;\n this.observability = params?.observability_c;\n }\n\n get instance() {\n if (!this._instance) {\n this._instance = new CopilotRuntimeVNext(this.runtimeArgs);\n }\n\n return this._instance;\n }\n\n private assignEndpointsToAgents(\n endpoints: CopilotRuntimeConstructorParams<T>[\"remoteEndpoints\"],\n ): Record<string, AbstractAgent> {\n let result: Record<string, AbstractAgent> = {};\n\n if (\n endpoints.some(\n (endpoint) =>\n resolveEndpointType(endpoint) == EndpointType.LangGraphPlatform,\n )\n ) {\n throw new CopilotKitMisuseError({\n message:\n \"LangGraphPlatformEndpoint in remoteEndpoints is deprecated. \" +\n 'Please use the \"agents\" option instead with LangGraphAgent from \"@copilotkit/runtime/langgraph\". ' +\n 'Example: agents: { myAgent: new LangGraphAgent({ deploymentUrl: \"...\", graphId: \"...\" }) }',\n });\n }\n\n return result;\n }\n\n handleServiceAdapter(serviceAdapter: CopilotServiceAdapter) {\n this.runtimeArgs.agents = Promise.resolve(\n this.runtimeArgs.agents ?? {},\n ).then(async (agents) => {\n // An AgentsFactory function has no enumerable keys, so it flows through\n // this path the same way an empty record does.\n let agentsList = agents as Record<string, AbstractAgent>;\n const isAgentsListEmpty = !Object.keys(agents).length;\n const hasServiceAdapter = Boolean(serviceAdapter);\n const illegalServiceAdapterNames = [\"EmptyAdapter\"];\n const serviceAdapterCanBeUsedForAgent =\n !illegalServiceAdapterNames.includes(serviceAdapter.name);\n\n if (\n isAgentsListEmpty &&\n (!hasServiceAdapter || !serviceAdapterCanBeUsedForAgent)\n ) {\n throw new CopilotKitMisuseError({\n message:\n \"No default agent provided. Please provide a default agent in the runtime config.\",\n });\n }\n\n if (isAgentsListEmpty) {\n const languageModel = serviceAdapter.getLanguageModel?.();\n if (languageModel) {\n // Adapter exposes a pre-configured LanguageModel (e.g. OpenAI/Anthropic adapters)\n agentsList.default = new BuiltInAgent({ model: languageModel });\n } else if (serviceAdapter.provider && serviceAdapter.model) {\n // Adapter exposes provider/model strings\n agentsList.default = new BuiltInAgent({\n model: `${serviceAdapter.provider}/${serviceAdapter.model}`,\n });\n } else {\n throw new CopilotKitMisuseError({\n message:\n `Service adapter \"${serviceAdapter.name ?? \"unknown\"}\" does not provide model information. ` +\n `When using adapters like LangChainAdapter without an explicit agents list, ` +\n `please provide a default agent in the runtime config. Example:\\n` +\n ` new CopilotRuntime({\\n` +\n ` agents: { default: new BuiltInAgent({ model: \"openai/gpt-4o\" }) }\\n` +\n ` })`,\n });\n }\n }\n\n const actions = this.params?.actions;\n if (actions) {\n const mcpTools = await this.getToolsFromMCP();\n agentsList = this.assignToolsToAgents(agentsList, [\n ...this.getToolsFromActions(actions),\n ...mcpTools,\n ]);\n }\n\n return agentsList;\n });\n }\n\n // Receive this.params.action and turn it into the AbstractAgent tools\n private getToolsFromActions(\n actions: ActionsConfiguration<any>,\n ): BuiltInAgentClassicConfig[\"tools\"] {\n // Resolve actions to an array (handle function case)\n const actionsArray =\n typeof actions === \"function\"\n ? actions({ properties: {}, url: undefined })\n : actions;\n\n // Convert each Action to a ToolDefinition\n return actionsArray.map((action) => {\n // Convert JSON schema to Zod schema\n const zodSchema = getZodParameters(action.parameters || []);\n\n return {\n name: action.name,\n description: action.description || \"\",\n parameters: zodSchema,\n execute: () => Promise.resolve(),\n };\n });\n }\n\n private assignToolsToAgents(\n agents: Record<string, AbstractAgent>,\n tools: BuiltInAgentClassicConfig[\"tools\"],\n ): Record<string, AbstractAgent> {\n if (!tools?.length) {\n return agents;\n }\n\n const enrichedAgents: Record<string, AbstractAgent> = { ...agents };\n\n for (const [agentId, agent] of Object.entries(enrichedAgents)) {\n const existingConfig = (Reflect.get(agent, \"config\") ?? {}) as Record<\n string,\n unknown\n >;\n\n // Skip factory-mode agents — they don't have a tools property\n if (\"factory\" in existingConfig) {\n continue;\n }\n\n const classicConfig =\n existingConfig as unknown as BuiltInAgentClassicConfig;\n const existingTools = classicConfig.tools ?? [];\n\n const updatedConfig: BuiltInAgentClassicConfig = {\n ...classicConfig,\n tools: [...existingTools, ...tools],\n };\n\n Reflect.set(agent, \"config\", updatedConfig);\n enrichedAgents[agentId] = agent;\n }\n\n return enrichedAgents;\n }\n\n private createOnBeforeRequestHandler(\n params?: CopilotRuntimeConstructorParams<T> &\n PartialBy<CopilotRuntimeOptions, \"agents\">,\n ) {\n return async (hookParams: BeforeRequestMiddlewareFnParameters[0]) => {\n const { request } = hookParams;\n\n // Capture telemetry for copilot request creation\n const publicApiKey = request.headers.get(\"x-copilotcloud-public-api-key\");\n const body = (await readBody(request)) as RunAgentInput;\n\n const forwardedProps = body?.forwardedProps as\n | {\n cloud?: { guardrails?: unknown };\n metadata?: { requestType?: string };\n }\n | undefined;\n\n // Get cloud base URL from environment or default\n const cloudBaseUrl =\n process.env.COPILOT_CLOUD_BASE_URL || \"https://api.cloud.copilotkit.ai\";\n\n telemetry.capture(\"oss.runtime.copilot_request_created\", {\n \"cloud.guardrails.enabled\":\n forwardedProps?.cloud?.guardrails !== undefined,\n requestType: forwardedProps?.metadata?.requestType ?? \"unknown\",\n \"cloud.api_key_provided\": !!publicApiKey,\n ...(publicApiKey ? { \"cloud.public_api_key\": publicApiKey } : {}),\n \"cloud.base_url\": cloudBaseUrl,\n });\n\n // We do not process middleware for the internal GET requests\n if (request.method === \"GET\" || !body) return;\n\n // TODO: get public api key and run with expected data\n // if (this.observability?.enabled && this.params.publicApiKey) {\n // this.logObservabilityBeforeRequest()\n // }\n\n // TODO: replace hooksParams top argument type with BeforeRequestMiddlewareParameters when exported\n const middlewareResult =\n await params?.beforeRequestMiddleware?.(hookParams);\n\n if (params?.middleware?.onBeforeRequest) {\n const { request, runtime, path } = hookParams;\n const gqlMessages = (aguiToGQL(body.messages) as Message[]).reduce(\n (acc, msg) => {\n if (\"role\" in msg && msg.role === \"user\") {\n acc.inputMessages.push(msg);\n } else {\n acc.outputMessages.push(msg);\n }\n return acc;\n },\n { inputMessages: [] as Message[], outputMessages: [] as Message[] },\n );\n const { inputMessages, outputMessages } = gqlMessages;\n params.middleware.onBeforeRequest({\n threadId: body.threadId,\n runId: body.runId,\n inputMessages,\n properties: body.forwardedProps,\n url: request.url,\n } satisfies OnBeforeRequestOptions);\n }\n\n return middlewareResult;\n };\n }\n\n private createOnAfterRequestHandler(\n params?: CopilotRuntimeConstructorParams<T> &\n PartialBy<CopilotRuntimeOptions, \"agents\">,\n ) {\n return async (hookParams: AfterRequestMiddlewareFnParameters[0]) => {\n // TODO: get public api key and run with expected data\n // if (this.observability?.enabled && publicApiKey) {\n // this.logObservabilityAfterRequest()\n // }\n\n // TODO: replace hooksParams top argument type with AfterRequestMiddlewareParameters when exported\n params?.afterRequestMiddleware?.(hookParams);\n\n if (params?.middleware?.onAfterRequest) {\n const messages = hookParams.messages ?? [];\n params.middleware.onAfterRequest({\n threadId: hookParams.threadId ?? \"\",\n runId: hookParams.runId,\n inputMessages: messages.filter(\n (m): m is typeof m & { role: string } =>\n \"role\" in m && m.role === \"user\",\n ) as unknown as Message[],\n outputMessages: messages.filter(\n (m): m is typeof m & { role: string } =>\n \"role\" in m && m.role !== \"user\",\n ) as unknown as Message[],\n // TODO: forward actual properties once the after-request hook has access to the request body\n properties: {},\n url: hookParams.path,\n } satisfies OnAfterRequestOptions);\n }\n };\n }\n\n // Observability Methods\n\n /**\n * Log LLM request if observability is enabled\n */\n private async logObservabilityBeforeRequest(\n requestData: LLMRequestData,\n ): Promise<void> {\n try {\n await this.observability.hooks.handleRequest(requestData);\n } catch (error) {\n console.error(\"Error logging LLM request:\", error);\n }\n }\n\n /**\n * Log final LLM response after request completes\n */\n private logObservabilityAfterRequest(\n outputMessagesPromise: Promise<Message[]>,\n baseData: {\n threadId: string;\n runId?: string;\n model?: string;\n provider?: string;\n agentName?: string;\n nodeName?: string;\n },\n streamedChunks: any[],\n requestStartTime: number,\n publicApiKey?: string,\n ): void {\n try {\n outputMessagesPromise\n .then((outputMessages) => {\n const responseData: LLMResponseData = {\n threadId: baseData.threadId,\n runId: baseData.runId,\n model: baseData.model,\n // Use collected chunks for progressive mode or outputMessages for regular mode\n output: this.observability.progressive\n ? streamedChunks\n : outputMessages,\n latency: Date.now() - requestStartTime,\n timestamp: Date.now(),\n provider: baseData.provider,\n isFinalResponse: true,\n agentName: baseData.agentName,\n nodeName: baseData.nodeName,\n };\n\n try {\n this.observability.hooks.handleResponse(responseData);\n } catch (logError) {\n console.error(\"Error logging LLM response:\", logError);\n }\n })\n .catch((error) => {\n console.error(\"Failed to get output messages for logging:\", error);\n });\n } catch (error) {\n console.error(\"Error setting up logging for LLM response:\", error);\n }\n }\n\n // Resolve MCP tools to BuiltInAgent tool definitions\n // Optionally accepts request-scoped properties to merge request-provided mcpServers\n private async getToolsFromMCP(options?: {\n properties?: Record<string, unknown>;\n }): Promise<BuiltInAgentClassicConfig[\"tools\"]> {\n const runtimeMcpServers = (this.params?.mcpServers ??\n []) as MCPEndpointConfig[];\n const createMCPClient = this.params?.createMCPClient as\n | CreateMCPClientFunction\n | undefined;\n\n // If no runtime config and no request overrides, nothing to do\n const requestMcpServers = ((\n options?.properties as { mcpServers?: MCPEndpointConfig[] } | undefined\n )?.mcpServers ??\n (\n options?.properties as\n | { mcpEndpoints?: MCPEndpointConfig[] }\n | undefined\n )?.mcpEndpoints ??\n []) as MCPEndpointConfig[];\n\n const hasAnyServers =\n (runtimeMcpServers?.length ?? 0) > 0 ||\n (requestMcpServers?.length ?? 0) > 0;\n if (!hasAnyServers) {\n return [];\n }\n\n if (!createMCPClient) {\n // Mirror legacy behavior: when servers are provided without a factory, treat as misconfiguration\n throw new CopilotKitMisuseError({\n message:\n \"MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`.\",\n });\n }\n\n // Merge and dedupe endpoints by URL; request-level overrides take precedence\n const effectiveEndpoints = (() => {\n const byUrl = new Map<string, MCPEndpointConfig>();\n for (const ep of runtimeMcpServers) {\n if (ep?.endpoint) byUrl.set(ep.endpoint, ep);\n }\n for (const ep of requestMcpServers) {\n if (ep?.endpoint) byUrl.set(ep.endpoint, ep);\n }\n return Array.from(byUrl.values());\n })();\n\n const allTools: BuiltInAgentClassicConfig[\"tools\"] = [];\n\n for (const config of effectiveEndpoints) {\n const endpointUrl = config.endpoint;\n // Return cached tool definitions when available\n const cached = this.mcpToolsCache.get(endpointUrl);\n if (cached) {\n allTools.push(...cached);\n continue;\n }\n\n try {\n const client = await createMCPClient(config);\n const toolsMap = await client.tools();\n\n const toolDefs: BuiltInAgentClassicConfig[\"tools\"] = Object.entries(\n toolsMap,\n ).map(([toolName, tool]: [string, MCPTool]) => {\n const params: Parameter[] = extractParametersFromSchema(tool);\n const zodSchema = getZodParameters(params);\n return {\n name: toolName,\n description:\n tool.description || `MCP tool: ${toolName} (from ${endpointUrl})`,\n parameters: zodSchema,\n execute: () => Promise.resolve(),\n };\n });\n\n // Cache per endpoint and add to aggregate\n this.mcpToolsCache.set(endpointUrl, toolDefs);\n allTools.push(...toolDefs);\n } catch (error) {\n console.error(\n `MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`,\n error,\n );\n // Cache empty to prevent repeated attempts within lifecycle\n this.mcpToolsCache.set(endpointUrl, []);\n }\n }\n\n // Dedupe tools by name while preserving last-in wins (request overrides)\n const dedupedByName = new Map<string, (typeof allTools)[number]>();\n for (const tool of allTools) {\n dedupedByName.set(tool.name, tool);\n }\n\n return Array.from(dedupedByName.values());\n }\n}\n\n// The two functions below are \"factory functions\", meant to create the action objects that adhere to the expected interfaces\nexport function copilotKitEndpoint(\n config: Omit<CopilotKitEndpoint, \"type\">,\n): CopilotKitEndpoint {\n return {\n ...config,\n type: EndpointType.CopilotKit,\n };\n}\n\nexport function langGraphPlatformEndpoint(\n config: Omit<LangGraphPlatformEndpoint, \"type\">,\n): LangGraphPlatformEndpoint {\n return {\n ...config,\n type: EndpointType.LangGraphPlatform,\n };\n}\n\nexport function resolveEndpointType(endpoint: EndpointDefinition) {\n if (!endpoint.type) {\n if (\"deploymentUrl\" in endpoint && \"agents\" in endpoint) {\n return EndpointType.LangGraphPlatform;\n } else {\n return EndpointType.CopilotKit;\n }\n }\n\n return endpoint.type;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8ZA,IAAa,iBAAb,MAAmE;CASjE,YAAY,QAA6C;uCAJvD,IAAI,KAAK;AAKT,iCAA+B;EAE/B,MAAM,SAAS,QAAQ,UAAU,EAAE;EACnC,MAAM,iBAAiB,KAAK,wBAC1B,QAAQ,mBAAmB,EAAE,CAC9B;EAKD,IAAI;AACJ,MAAI,OAAO,WAAW,WACpB,gBAAe,OAAO,QAAQ;GAC5B,MAAM,WAAW,MAAM,OAAO,IAAI;AAClC,UAAO;IAAE,GAAG;IAAgB,GAAG;IAAU;;MAG3C,gBAAe,QAAQ,QAAQ,OAAO,CAAC,MAAM,cAAc;GACzD,GAAG;GACH,GAAG;GACJ,EAAE;EAIL,MAAM,aAAa,QAAQ,UAAU,IAAI,qBAAqB;EAK9D,MAAM,SAAS,qBAAqB,GAChC,aACA,IAAI,qBAAqB,EAAE,QAAQ,YAAY,CAAC;EAQpD,MAAM,uBACJ,QAAQ,gBAAgB,QAAQ,IAAI;AACtC,MAAI,qBACF,iBAAU,gBAAgB,qBAAqB;EAGjD,MAAM,oBAAoB;GACxB,QAAQ;GACR,cAAc,QAAQ;GACtB,OAAO,QAAQ;GAIf,yBACE,KAAK,6BAA6B,OAAO,CAAC,KAAK,KAAK;GACtD,GAAI,QA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AO,aAAa;KAEpB,QAAO,aAAa;AAIxB,QAAO,SAAS"}
1
+ {"version":3,"file":"copilot-runtime.mjs","names":["telemetry","CopilotRuntimeVNext"],"sources":["../../../../src/v1-deprecated/lib/runtime/copilot-runtime.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — copilotKitEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — CopilotRuntime:\n * V2 import and usage:\n * import { CopilotRuntime } from \"@copilotkit/runtime/v2\";\n *\n * const runtime = new CopilotRuntime({ agents: {} });\n * V2 replacement source: packages/runtime/src/v2/runtime/core/runtime.ts\n * V2 docs: https://docs.copilotkit.ai/runtime-server-adapter\n * Migration note: V2 uses AG-UI runtime handlers instead of the v1 GraphQL adapter setup.\n *\n * @copilotkit/runtime — CopilotRuntimeConstructorParams_BASE:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — langGraphPlatformEndpoint:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (LangGraph agents): https://docs.copilotkit.ai/agent-spec/langgraph\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — resolveEndpointType:\n * No 1:1 v2 replacement is available.\n * Related v2 docs (Runtime server adapter): https://docs.copilotkit.ai/runtime-server-adapter\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * <Callout type=\"info\">\n * This is the reference for the `CopilotRuntime` class. For more information and example code snippets, please see [Concept: Copilot Runtime](/backend/copilot-runtime).\n * </Callout>\n *\n * ## Usage\n *\n * ```tsx\n * import { CopilotRuntime } from \"@copilotkit/runtime\";\n *\n * const copilotKit = new CopilotRuntime();\n * ```\n */\n\nimport {\n CopilotKitMisuseError,\n readBody,\n getZodParameters,\n isTelemetryDisabled,\n} from \"@copilotkit/shared\";\nimport type {\n Action,\n CopilotErrorHandler,\n MaybePromise,\n NonEmptyRecord,\n Parameter,\n PartialBy,\n DebugConfig,\n TelemetryCapture,\n} from \"@copilotkit/shared\";\nimport type { RunAgentInput } from \"@ag-ui/core\";\nimport { aguiToGQL } from \"../../graphql/message-conversion/agui-to-gql\";\nimport type {\n CopilotServiceAdapter,\n RemoteChainParameters,\n} from \"../../service-adapters\";\nimport {\n CopilotRuntime as CopilotRuntimeVNext,\n InMemoryAgentRunner,\n} from \"../../../v2/runtime\";\nimport {\n createRuntimeErrorReporter,\n runtimeErrorReporterOption,\n} from \"../../../v2/runtime/core/runtime-error-reporter\";\nimport type { RuntimeErrorReporterOptions } from \"../../../v2/runtime/core/runtime-error-reporter\";\nimport type {\n CopilotIntelligenceRuntimeOptions,\n CopilotRuntimeOptions,\n CopilotRuntimeOptions as CopilotRuntimeOptionsVNext,\n AgentRunner,\n AgentsConfig,\n AgentsFactory,\n AgentFactoryContext,\n} from \"../../../v2/runtime\";\n\nexport type { AgentsConfig, AgentsFactory, AgentFactoryContext };\nimport { TelemetryAgentRunner } from \"./telemetry-agent-runner\";\nimport telemetry from \"../telemetry-client\";\nimport { logRuntimeTelemetryDisclosure } from \"../telemetry-disclosure\";\n\nimport type { MessageInput } from \"../../graphql/inputs/message.input\";\nimport type { Message } from \"../../graphql/types/converted\";\n\nimport { EndpointType } from \"./types\";\nimport type {\n EndpointDefinition,\n CopilotKitEndpoint,\n LangGraphPlatformEndpoint,\n} from \"./types\";\n\nimport type {\n CopilotObservabilityConfig,\n LLMRequestData,\n LLMResponseData,\n} from \"../observability\";\nimport type { AbstractAgent } from \"@ag-ui/client\";\nimport {\n firstNonBlankLicenseToken,\n firstNonBlankTelemetryId,\n} from \"../../../v2/runtime/telemetry/telemetry-identity\";\n\n// +++ MCP Imports +++\nimport { extractParametersFromSchema } from \"./mcp-tools-utils\";\nimport type { MCPClient, MCPEndpointConfig, MCPTool } from \"./mcp-tools-utils\";\nimport { BuiltInAgent } from \"../../../agent\";\nimport type { BuiltInAgentClassicConfig } from \"../../../agent\";\n// Define the function type alias here or import if defined elsewhere\ntype CreateMCPClientFunction = (\n config: MCPEndpointConfig,\n) => Promise<MCPClient>;\n\ntype ActionsConfiguration<T extends Parameter[] | [] = []> =\n | Action<T>[]\n | ((ctx: { properties: any; url?: string }) => Action<T>[]);\n\ninterface OnBeforeRequestOptions {\n threadId?: string;\n runId?: string;\n inputMessages: Message[];\n properties: any;\n url?: string;\n}\n\ntype OnBeforeRequestHandler = (\n options: OnBeforeRequestOptions,\n) => void | Promise<void>;\n\ninterface OnAfterRequestOptions {\n threadId: string;\n runId?: string;\n inputMessages: Message[];\n outputMessages: Message[];\n properties: any;\n url?: string;\n}\n\ntype OnAfterRequestHandler = (\n options: OnAfterRequestOptions,\n) => void | Promise<void>;\n\ninterface OnStopGenerationOptions {\n threadId: string;\n runId?: string;\n url?: string;\n agentName?: string;\n lastMessage: MessageInput;\n}\ntype OnStopGenerationHandler = (\n options: OnStopGenerationOptions,\n) => void | Promise<void>;\n\ninterface Middleware {\n /**\n * A function that is called before the request is processed.\n */\n /**\n * @deprecated This middleware hook is deprecated and will be removed in a future version.\n * Use updated middleware integration methods in CopilotRuntimeVNext instead.\n */\n onBeforeRequest?: OnBeforeRequestHandler;\n\n /**\n * A function that is called after the request is processed.\n */\n /**\n * @deprecated This middleware hook is deprecated and will be removed in a future version.\n * Use updated middleware integration methods in CopilotRuntimeVNext instead.\n */\n onAfterRequest?: OnAfterRequestHandler;\n}\n\nexport interface CopilotRuntimeConstructorParams_BASE<\n T extends Parameter[] | [] = [],\n> {\n /** Standalone telemetry identity. Falls back to CPK_TELEMETRY_ID before legacy license identity. */\n telemetryId?: string;\n /**\n * Middleware to be used by the runtime.\n *\n * ```ts\n * onBeforeRequest: (options: {\n * threadId?: string;\n * runId?: string;\n * inputMessages: Message[];\n * properties: any;\n * }) => void | Promise<void>;\n * ```\n *\n * ```ts\n * onAfterRequest: (options: {\n * threadId?: string;\n * runId?: string;\n * inputMessages: Message[];\n * outputMessages: Message[];\n * properties: any;\n * }) => void | Promise<void>;\n * ```\n */\n /**\n * @deprecated This middleware hook is deprecated and will be removed in a future version.\n * Use updated middleware integration methods in CopilotRuntimeVNext instead.\n */\n middleware?: Middleware;\n\n /*\n * A list of server side actions that can be executed. Will be ignored when remoteActions are set\n */\n actions?: ActionsConfiguration<T>;\n\n /*\n * Deprecated: Use `remoteEndpoints`.\n */\n remoteActions?: CopilotKitEndpoint[];\n\n /*\n * A list of remote actions that can be executed.\n */\n remoteEndpoints?: EndpointDefinition[];\n\n /*\n * An array of LangServer URLs.\n */\n langserve?: RemoteChainParameters[];\n\n /**\n * Optional agent runner to use for SSE runtime.\n */\n runner?: AgentRunner;\n\n /*\n * A map of agent names to AGUI agents.\n * Example agent config:\n * ```ts\n * import { AbstractAgent } from \"@ag-ui/client\";\n * // ...\n * agents: {\n * \"support\": new CustomerSupportAgent(),\n * \"technical\": new TechnicalAgent()\n * }\n * ```\n */\n agents?: Record<string, AbstractAgent>;\n\n /*\n * Delegates agent state processing to the service adapter.\n *\n * When enabled, individual agent state requests will not be processed by the agent itself.\n * Instead, all processing will be handled by the service adapter.\n */\n delegateAgentProcessingToServiceAdapter?: boolean;\n\n /**\n * Configuration for LLM request/response logging.\n *\n * Example logging config:\n * ```ts\n * logging: {\n * enabled: true, // Enable or disable logging\n * progressive: true, // Set to false for buffered logging\n * logger: {\n * logRequest: (data) => langfuse.trace({ name: \"LLM Request\", input: data }),\n * logResponse: (data) => langfuse.trace({ name: \"LLM Response\", output: data }),\n * logError: (errorData) => langfuse.trace({ name: \"LLM Error\", metadata: errorData }),\n * },\n * }\n * ```\n */\n observability_c?: CopilotObservabilityConfig;\n\n /**\n * Configuration for connecting to Model Context Protocol (MCP) servers.\n * Allows fetching and using tools defined on external MCP-compliant servers.\n * Requires providing the `createMCPClient` function during instantiation.\n * @experimental\n */\n mcpServers?: MCPEndpointConfig[];\n\n /**\n * A function that creates an MCP client instance for a given endpoint configuration.\n * This function is responsible for using the appropriate MCP client library\n * (e.g., `@copilotkit/runtime`, `ai`) to establish a connection.\n * Required if `mcpServers` is provided.\n *\n * ```typescript\n * import { experimental_createMCPClient } from \"ai\"; // Import from vercel ai library\n * // ...\n * const runtime = new CopilotRuntime({\n * mcpServers: [{ endpoint: \"...\" }],\n * async createMCPClient(config) {\n * return await experimental_createMCPClient({\n * transport: {\n * type: \"sse\",\n * url: config.endpoint,\n * headers: config.apiKey\n * ? { Authorization: `Bearer ${config.apiKey}` }\n * : undefined,\n * },\n * });\n * }\n * });\n * ```\n */\n createMCPClient?: CreateMCPClientFunction;\n\n /**\n * Optional error handler for comprehensive debugging and observability.\n *\n * @param errorEvent - Structured error event with rich debugging context\n *\n * @example\n * ```typescript\n * const runtime = new CopilotRuntime({\n * onError: (errorEvent) => {\n * debugDashboard.capture(errorEvent);\n * }\n * });\n * ```\n */\n onError?: CopilotErrorHandler;\n\n onStopGeneration?: OnStopGenerationHandler;\n\n /**\n * Enable debug logging for the runtime event pipeline.\n * Pass `true` for full output, or an object for granular control:\n *\n * ```ts\n * const runtime = new CopilotRuntime({\n * debug: true,\n * // or: debug: { events: true, lifecycle: true, verbose: false }\n * });\n * ```\n */\n debug?: DebugConfig;\n\n // /** Optional transcription service for audio processing. */\n // transcriptionService?: CopilotRuntimeOptionsVNext[\"transcriptionService\"];\n // /** Optional *before* middleware – callback function or webhook URL. */\n // beforeRequestMiddleware?: CopilotRuntimeOptionsVNext[\"beforeRequestMiddleware\"];\n // /** Optional *after* middleware – callback function or webhook URL. */\n // afterRequestMiddleware?: CopilotRuntimeOptionsVNext[\"afterRequestMiddleware\"];\n}\n\ntype BeforeRequestMiddleware =\n CopilotRuntimeOptionsVNext[\"beforeRequestMiddleware\"];\ntype AfterRequestMiddleware =\n CopilotRuntimeOptionsVNext[\"afterRequestMiddleware\"];\ntype BeforeRequestMiddlewareFn = Exclude<BeforeRequestMiddleware, string>;\ntype BeforeRequestMiddlewareFnParameters =\n Parameters<BeforeRequestMiddlewareFn>;\ntype BeforeRequestMiddlewareFnResult = ReturnType<BeforeRequestMiddlewareFn>;\ntype AfterRequestMiddlewareFn = Exclude<AfterRequestMiddleware, string>;\ntype AfterRequestMiddlewareFnParameters = Parameters<AfterRequestMiddlewareFn>;\n\ninterface CopilotRuntimeConstructorParams<T extends Parameter[] | [] = []>\n extends\n Omit<CopilotRuntimeConstructorParams_BASE<T>, \"agents\">,\n Omit<CopilotRuntimeOptionsVNext, \"agents\" | \"transcriptionService\"> {\n /**\n * TODO: un-omit `transcriptionService` above once it's supported\n *\n * This satisfies...\n * – the optional constraint in `CopilotRuntimeConstructorParams_BASE`\n * – the `MaybePromise<NonEmptyRecord<T>>` constraint in `CopilotRuntimeOptionsVNext`\n * – the `Record<string, AbstractAgent>` constraint in `both\n */\n agents?: AgentsConfig;\n\n intelligence?: CopilotIntelligenceRuntimeOptions[\"intelligence\"];\n identifyUser?: CopilotIntelligenceRuntimeOptions[\"identifyUser\"];\n memory?: CopilotIntelligenceRuntimeOptions[\"memory\"];\n channels?: CopilotIntelligenceRuntimeOptions[\"channels\"];\n ɵlearning?: CopilotIntelligenceRuntimeOptions[\"ɵlearning\"];\n generateThreadNames?: CopilotIntelligenceRuntimeOptions[\"generateThreadNames\"];\n maxReconnectMs?: CopilotIntelligenceRuntimeOptions[\"maxReconnectMs\"];\n maxRejoinMs?: CopilotIntelligenceRuntimeOptions[\"maxRejoinMs\"];\n lockTtlSeconds?: CopilotIntelligenceRuntimeOptions[\"lockTtlSeconds\"];\n lockKeyPrefix?: CopilotIntelligenceRuntimeOptions[\"lockKeyPrefix\"];\n lockHeartbeatIntervalSeconds?: CopilotIntelligenceRuntimeOptions[\"lockHeartbeatIntervalSeconds\"];\n}\n\n/**\n * Central runtime object passed to all request handlers.\n * @deprecated The v1 SDK is deprecated. Use v2 instead. Use `CopilotRuntime` from `@copilotkit/runtime/v2` instead.\n *\n * ```tsx\n * import { CopilotRuntime } from \"@copilotkit/runtime/v2\";\n *\n * const runtime = new CopilotRuntime({ agents: {} });\n * ```\n * See https://docs.copilotkit.ai/runtime-server-adapter\n */\nexport class CopilotRuntime<const T extends Parameter[] | [] = []> {\n params?: CopilotRuntimeConstructorParams<T>;\n private observability?: CopilotObservabilityConfig;\n // Cache MCP tools per endpoint to avoid re-fetching repeatedly\n private mcpToolsCache: Map<string, BuiltInAgentClassicConfig[\"tools\"]> =\n new Map();\n private runtimeArgs: CopilotRuntimeOptions & RuntimeErrorReporterOptions;\n private _instance: CopilotRuntimeVNext;\n /** Runtime-bound telemetry identity and sampling authority. */\n public readonly telemetry: TelemetryCapture;\n\n constructor(params?: CopilotRuntimeConstructorParams<T>) {\n logRuntimeTelemetryDisclosure();\n\n const agents = params?.agents ?? {};\n const endpointAgents = this.assignEndpointsToAgents(\n params?.remoteEndpoints ?? [],\n );\n\n // Merge endpoint agents with user-provided agents.\n // When agents is a factory function, wrap it so endpoint agents are merged\n // at resolution time (spreading a function produces {} — silent data loss).\n let mergedAgents: AgentsConfig;\n if (typeof agents === \"function\") {\n mergedAgents = async (ctx) => {\n const resolved = await agents(ctx);\n return { ...endpointAgents, ...resolved };\n };\n } else {\n mergedAgents = Promise.resolve(agents).then((resolved) => ({\n ...endpointAgents,\n ...resolved,\n }));\n }\n\n // Resolve identity once and bind it to this compatibility Runtime. The\n // capture scope shares process-level sinks and settings without exposing\n // mutable identity to other live runtimes.\n const resolvedLicenseToken = firstNonBlankLicenseToken(\n params?.licenseToken,\n process.env.COPILOTKIT_LICENSE_TOKEN,\n );\n const resolvedTelemetryId = firstNonBlankTelemetryId(\n params?.telemetryId,\n process.env.CPK_TELEMETRY_ID,\n );\n const resolvedTelemetryIdentity =\n resolvedTelemetryId !== undefined\n ? { telemetryId: resolvedTelemetryId }\n : resolvedLicenseToken !== undefined\n ? { licenseToken: resolvedLicenseToken }\n : {};\n this.telemetry = telemetry.createScope(resolvedTelemetryIdentity);\n\n // Determine the base runner (user-provided or default)\n const baseRunner = params?.runner ?? new InMemoryAgentRunner();\n\n // Wrap with TelemetryAgentRunner unless telemetry is disabled\n // This ensures we always capture agent execution telemetry when enabled,\n // even if the user provides their own custom runner.\n const runner = isTelemetryDisabled()\n ? baseRunner\n : new TelemetryAgentRunner({\n runner: baseRunner,\n telemetry: this.telemetry,\n });\n\n const sharedRuntimeArgs = {\n agents: mergedAgents,\n telemetryId: resolvedTelemetryId,\n licenseToken: resolvedLicenseToken,\n telemetryProperties: params?.telemetryProperties,\n debug: params?.debug,\n // TODO: add support for transcriptionService from CopilotRuntimeOptionsVNext once it is ready\n // transcriptionService: params?.transcriptionService,\n\n beforeRequestMiddleware:\n this.createOnBeforeRequestHandler(params).bind(this),\n ...(params?.afterRequestMiddleware || params?.middleware?.onAfterRequest\n ? {\n afterRequestMiddleware:\n this.createOnAfterRequestHandler(params).bind(this),\n }\n : {}),\n a2ui: params?.a2ui,\n mcpApps: params?.mcpApps,\n openGenerativeUI: params?.openGenerativeUI,\n [runtimeErrorReporterOption]: createRuntimeErrorReporter(params?.onError),\n forwardHeaders: params?.forwardHeaders,\n exposeMemoryRoutes: params?.exposeMemoryRoutes,\n };\n if (params?.intelligence !== undefined) {\n // The compatibility constructor keeps Intelligence identity optional at\n // compile time, while the v2 runtime checks that callers supply web\n // identity, Channels, or both. Preserve that runtime validation here.\n this.runtimeArgs = {\n ...sharedRuntimeArgs,\n intelligence: params.intelligence,\n identifyUser: params.identifyUser,\n memory: params.memory,\n channels: params.channels,\n ɵlearning: params.ɵlearning,\n generateThreadNames: params.generateThreadNames,\n maxReconnectMs: params.maxReconnectMs,\n maxRejoinMs: params.maxRejoinMs,\n lockTtlSeconds: params.lockTtlSeconds,\n lockKeyPrefix: params.lockKeyPrefix,\n lockHeartbeatIntervalSeconds: params.lockHeartbeatIntervalSeconds,\n } as CopilotRuntimeOptions;\n } else {\n this.runtimeArgs = {\n ...sharedRuntimeArgs,\n runner,\n };\n }\n this.params = params;\n this.observability = params?.observability_c;\n }\n\n get instance() {\n if (!this._instance) {\n this._instance = new CopilotRuntimeVNext(this.runtimeArgs);\n }\n\n return this._instance;\n }\n\n private assignEndpointsToAgents(\n endpoints: CopilotRuntimeConstructorParams<T>[\"remoteEndpoints\"],\n ): Record<string, AbstractAgent> {\n let result: Record<string, AbstractAgent> = {};\n\n if (\n endpoints.some(\n (endpoint) =>\n resolveEndpointType(endpoint) == EndpointType.LangGraphPlatform,\n )\n ) {\n throw new CopilotKitMisuseError({\n message:\n \"LangGraphPlatformEndpoint in remoteEndpoints is deprecated. \" +\n 'Please use the \"agents\" option instead with LangGraphAgent from \"@copilotkit/runtime/langgraph\". ' +\n 'Example: agents: { myAgent: new LangGraphAgent({ deploymentUrl: \"...\", graphId: \"...\" }) }',\n });\n }\n\n return result;\n }\n\n handleServiceAdapter(serviceAdapter: CopilotServiceAdapter) {\n this.runtimeArgs.agents = Promise.resolve(\n this.runtimeArgs.agents ?? {},\n ).then(async (agents) => {\n // An AgentsFactory function has no enumerable keys, so it flows through\n // this path the same way an empty record does.\n let agentsList = agents as Record<string, AbstractAgent>;\n const isAgentsListEmpty = !Object.keys(agents).length;\n const hasServiceAdapter = Boolean(serviceAdapter);\n const illegalServiceAdapterNames = [\"EmptyAdapter\"];\n const serviceAdapterCanBeUsedForAgent =\n !illegalServiceAdapterNames.includes(serviceAdapter.name);\n\n if (\n isAgentsListEmpty &&\n (!hasServiceAdapter || !serviceAdapterCanBeUsedForAgent)\n ) {\n throw new CopilotKitMisuseError({\n message:\n \"No default agent provided. Please provide a default agent in the runtime config.\",\n });\n }\n\n if (isAgentsListEmpty) {\n const languageModel = serviceAdapter.getLanguageModel?.();\n if (languageModel) {\n // Adapter exposes a pre-configured LanguageModel (e.g. OpenAI/Anthropic adapters)\n agentsList.default = new BuiltInAgent({ model: languageModel });\n } else if (serviceAdapter.provider && serviceAdapter.model) {\n // Adapter exposes provider/model strings\n agentsList.default = new BuiltInAgent({\n model: `${serviceAdapter.provider}/${serviceAdapter.model}`,\n });\n } else {\n throw new CopilotKitMisuseError({\n message:\n `Service adapter \"${serviceAdapter.name ?? \"unknown\"}\" does not provide model information. ` +\n `When using adapters like LangChainAdapter without an explicit agents list, ` +\n `please provide a default agent in the runtime config. Example:\\n` +\n ` new CopilotRuntime({\\n` +\n ` agents: { default: new BuiltInAgent({ model: \"openai/gpt-4o\" }) }\\n` +\n ` })`,\n });\n }\n }\n\n const actions = this.params?.actions;\n if (actions) {\n const mcpTools = await this.getToolsFromMCP();\n agentsList = this.assignToolsToAgents(agentsList, [\n ...this.getToolsFromActions(actions),\n ...mcpTools,\n ]);\n }\n\n return agentsList;\n });\n }\n\n // Receive this.params.action and turn it into the AbstractAgent tools\n private getToolsFromActions(\n actions: ActionsConfiguration<any>,\n ): BuiltInAgentClassicConfig[\"tools\"] {\n // Resolve actions to an array (handle function case)\n const actionsArray =\n typeof actions === \"function\"\n ? actions({ properties: {}, url: undefined })\n : actions;\n\n // Convert each Action to a ToolDefinition\n return actionsArray.map((action) => {\n // Convert JSON schema to Zod schema\n const zodSchema = getZodParameters(action.parameters || []);\n\n return {\n name: action.name,\n description: action.description || \"\",\n parameters: zodSchema,\n execute: () => Promise.resolve(),\n };\n });\n }\n\n private assignToolsToAgents(\n agents: Record<string, AbstractAgent>,\n tools: BuiltInAgentClassicConfig[\"tools\"],\n ): Record<string, AbstractAgent> {\n if (!tools?.length) {\n return agents;\n }\n\n const enrichedAgents: Record<string, AbstractAgent> = { ...agents };\n\n for (const [agentId, agent] of Object.entries(enrichedAgents)) {\n const existingConfig = (Reflect.get(agent, \"config\") ?? {}) as Record<\n string,\n unknown\n >;\n\n // Skip factory-mode agents — they don't have a tools property\n if (\"factory\" in existingConfig) {\n continue;\n }\n\n const classicConfig =\n existingConfig as unknown as BuiltInAgentClassicConfig;\n const existingTools = classicConfig.tools ?? [];\n\n const updatedConfig: BuiltInAgentClassicConfig = {\n ...classicConfig,\n tools: [...existingTools, ...tools],\n };\n\n Reflect.set(agent, \"config\", updatedConfig);\n enrichedAgents[agentId] = agent;\n }\n\n return enrichedAgents;\n }\n\n private createOnBeforeRequestHandler(\n params?: CopilotRuntimeConstructorParams<T> &\n PartialBy<CopilotRuntimeOptions, \"agents\">,\n ) {\n return async (hookParams: BeforeRequestMiddlewareFnParameters[0]) => {\n const { request } = hookParams;\n\n // Capture telemetry for copilot request creation\n const publicApiKey = request.headers.get(\"x-copilotcloud-public-api-key\");\n const body = (await readBody(request)) as RunAgentInput;\n\n const forwardedProps = body?.forwardedProps as\n | {\n cloud?: { guardrails?: unknown };\n metadata?: { requestType?: string };\n }\n | undefined;\n\n // Get cloud base URL from environment or default\n const cloudBaseUrl =\n process.env.COPILOT_CLOUD_BASE_URL || \"https://api.cloud.copilotkit.ai\";\n\n this.telemetry.capture(\"oss.runtime.copilot_request_created\", {\n \"cloud.guardrails.enabled\":\n forwardedProps?.cloud?.guardrails !== undefined,\n requestType: forwardedProps?.metadata?.requestType ?? \"unknown\",\n \"cloud.api_key_provided\": !!publicApiKey,\n ...(publicApiKey ? { \"cloud.public_api_key\": publicApiKey } : {}),\n \"cloud.base_url\": cloudBaseUrl,\n });\n\n // We do not process middleware for the internal GET requests\n if (request.method === \"GET\" || !body) return;\n\n // TODO: get public api key and run with expected data\n // if (this.observability?.enabled && this.params.publicApiKey) {\n // this.logObservabilityBeforeRequest()\n // }\n\n // TODO: replace hooksParams top argument type with BeforeRequestMiddlewareParameters when exported\n const middlewareResult =\n await params?.beforeRequestMiddleware?.(hookParams);\n\n if (params?.middleware?.onBeforeRequest) {\n const { request, runtime, path } = hookParams;\n const gqlMessages = (aguiToGQL(body.messages) as Message[]).reduce(\n (acc, msg) => {\n if (\"role\" in msg && msg.role === \"user\") {\n acc.inputMessages.push(msg);\n } else {\n acc.outputMessages.push(msg);\n }\n return acc;\n },\n { inputMessages: [] as Message[], outputMessages: [] as Message[] },\n );\n const { inputMessages, outputMessages } = gqlMessages;\n params.middleware.onBeforeRequest({\n threadId: body.threadId,\n runId: body.runId,\n inputMessages,\n properties: body.forwardedProps,\n url: request.url,\n } satisfies OnBeforeRequestOptions);\n }\n\n return middlewareResult;\n };\n }\n\n private createOnAfterRequestHandler(\n params?: CopilotRuntimeConstructorParams<T> &\n PartialBy<CopilotRuntimeOptions, \"agents\">,\n ) {\n return async (hookParams: AfterRequestMiddlewareFnParameters[0]) => {\n // TODO: get public api key and run with expected data\n // if (this.observability?.enabled && publicApiKey) {\n // this.logObservabilityAfterRequest()\n // }\n\n // TODO: replace hooksParams top argument type with AfterRequestMiddlewareParameters when exported\n params?.afterRequestMiddleware?.(hookParams);\n\n if (params?.middleware?.onAfterRequest) {\n const messages = hookParams.messages ?? [];\n params.middleware.onAfterRequest({\n threadId: hookParams.threadId ?? \"\",\n runId: hookParams.runId,\n inputMessages: messages.filter(\n (m): m is typeof m & { role: string } =>\n \"role\" in m && m.role === \"user\",\n ) as unknown as Message[],\n outputMessages: messages.filter(\n (m): m is typeof m & { role: string } =>\n \"role\" in m && m.role !== \"user\",\n ) as unknown as Message[],\n // TODO: forward actual properties once the after-request hook has access to the request body\n properties: {},\n url: hookParams.path,\n } satisfies OnAfterRequestOptions);\n }\n };\n }\n\n // Observability Methods\n\n /**\n * Log LLM request if observability is enabled\n */\n private async logObservabilityBeforeRequest(\n requestData: LLMRequestData,\n ): Promise<void> {\n try {\n await this.observability.hooks.handleRequest(requestData);\n } catch (error) {\n console.error(\"Error logging LLM request:\", error);\n }\n }\n\n /**\n * Log final LLM response after request completes\n */\n private logObservabilityAfterRequest(\n outputMessagesPromise: Promise<Message[]>,\n baseData: {\n threadId: string;\n runId?: string;\n model?: string;\n provider?: string;\n agentName?: string;\n nodeName?: string;\n },\n streamedChunks: any[],\n requestStartTime: number,\n publicApiKey?: string,\n ): void {\n try {\n outputMessagesPromise\n .then((outputMessages) => {\n const responseData: LLMResponseData = {\n threadId: baseData.threadId,\n runId: baseData.runId,\n model: baseData.model,\n // Use collected chunks for progressive mode or outputMessages for regular mode\n output: this.observability.progressive\n ? streamedChunks\n : outputMessages,\n latency: Date.now() - requestStartTime,\n timestamp: Date.now(),\n provider: baseData.provider,\n isFinalResponse: true,\n agentName: baseData.agentName,\n nodeName: baseData.nodeName,\n };\n\n try {\n this.observability.hooks.handleResponse(responseData);\n } catch (logError) {\n console.error(\"Error logging LLM response:\", logError);\n }\n })\n .catch((error) => {\n console.error(\"Failed to get output messages for logging:\", error);\n });\n } catch (error) {\n console.error(\"Error setting up logging for LLM response:\", error);\n }\n }\n\n // Resolve MCP tools to BuiltInAgent tool definitions\n // Optionally accepts request-scoped properties to merge request-provided mcpServers\n private async getToolsFromMCP(options?: {\n properties?: Record<string, unknown>;\n }): Promise<BuiltInAgentClassicConfig[\"tools\"]> {\n const runtimeMcpServers = (this.params?.mcpServers ??\n []) as MCPEndpointConfig[];\n const createMCPClient = this.params?.createMCPClient as\n | CreateMCPClientFunction\n | undefined;\n\n // If no runtime config and no request overrides, nothing to do\n const requestMcpServers = ((\n options?.properties as { mcpServers?: MCPEndpointConfig[] } | undefined\n )?.mcpServers ??\n (\n options?.properties as\n | { mcpEndpoints?: MCPEndpointConfig[] }\n | undefined\n )?.mcpEndpoints ??\n []) as MCPEndpointConfig[];\n\n const hasAnyServers =\n (runtimeMcpServers?.length ?? 0) > 0 ||\n (requestMcpServers?.length ?? 0) > 0;\n if (!hasAnyServers) {\n return [];\n }\n\n if (!createMCPClient) {\n // Mirror legacy behavior: when servers are provided without a factory, treat as misconfiguration\n throw new CopilotKitMisuseError({\n message:\n \"MCP Integration Error: `mcpServers` were provided, but the `createMCPClient` function was not passed to the CopilotRuntime constructor. Please provide an implementation for `createMCPClient`.\",\n });\n }\n\n // Merge and dedupe endpoints by URL; request-level overrides take precedence\n const effectiveEndpoints = (() => {\n const byUrl = new Map<string, MCPEndpointConfig>();\n for (const ep of runtimeMcpServers) {\n if (ep?.endpoint) byUrl.set(ep.endpoint, ep);\n }\n for (const ep of requestMcpServers) {\n if (ep?.endpoint) byUrl.set(ep.endpoint, ep);\n }\n return Array.from(byUrl.values());\n })();\n\n const allTools: BuiltInAgentClassicConfig[\"tools\"] = [];\n\n for (const config of effectiveEndpoints) {\n const endpointUrl = config.endpoint;\n // Return cached tool definitions when available\n const cached = this.mcpToolsCache.get(endpointUrl);\n if (cached) {\n allTools.push(...cached);\n continue;\n }\n\n try {\n const client = await createMCPClient(config);\n const toolsMap = await client.tools();\n\n const toolDefs: BuiltInAgentClassicConfig[\"tools\"] = Object.entries(\n toolsMap,\n ).map(([toolName, tool]: [string, MCPTool]) => {\n const params: Parameter[] = extractParametersFromSchema(tool);\n const zodSchema = getZodParameters(params);\n return {\n name: toolName,\n description:\n tool.description || `MCP tool: ${toolName} (from ${endpointUrl})`,\n parameters: zodSchema,\n execute: () => Promise.resolve(),\n };\n });\n\n // Cache per endpoint and add to aggregate\n this.mcpToolsCache.set(endpointUrl, toolDefs);\n allTools.push(...toolDefs);\n } catch (error) {\n console.error(\n `MCP: Failed to fetch tools from endpoint ${endpointUrl}. Skipping. Error:`,\n error,\n );\n // Cache empty to prevent repeated attempts within lifecycle\n this.mcpToolsCache.set(endpointUrl, []);\n }\n }\n\n // Dedupe tools by name while preserving last-in wins (request overrides)\n const dedupedByName = new Map<string, (typeof allTools)[number]>();\n for (const tool of allTools) {\n dedupedByName.set(tool.name, tool);\n }\n\n return Array.from(dedupedByName.values());\n }\n}\n\n// The two functions below are \"factory functions\", meant to create the action objects that adhere to the expected interfaces\nexport function copilotKitEndpoint(\n config: Omit<CopilotKitEndpoint, \"type\">,\n): CopilotKitEndpoint {\n return {\n ...config,\n type: EndpointType.CopilotKit,\n };\n}\n\nexport function langGraphPlatformEndpoint(\n config: Omit<LangGraphPlatformEndpoint, \"type\">,\n): LangGraphPlatformEndpoint {\n return {\n ...config,\n type: EndpointType.LangGraphPlatform,\n };\n}\n\nexport function resolveEndpointType(endpoint: EndpointDefinition) {\n if (!endpoint.type) {\n if (\"deploymentUrl\" in endpoint && \"agents\" in endpoint) {\n return EndpointType.LangGraphPlatform;\n } else {\n return EndpointType.CopilotKit;\n }\n }\n\n return endpoint.type;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqaA,IAAa,iBAAb,MAAmE;CAWjE,YAAY,QAA6C;uCANvD,IAAI,KAAK;AAOT,iCAA+B;EAE/B,MAAM,SAAS,QAAQ,UAAU,EAAE;EACnC,MAAM,iBAAiB,KAAK,wBAC1B,QAAQ,mBAAmB,EAAE,CAC9B;EAKD,IAAI;AACJ,MAAI,OAAO,WAAW,WACpB,gBAAe,OAAO,QAAQ;GAC5B,MAAM,WAAW,MAAM,OAAO,IAAI;AAClC,UAAO;IAAE,GAAG;IAAgB,GAAG;IAAU;;MAG3C,gBAAe,QAAQ,QAAQ,OAAO,CAAC,MAAM,cAAc;GACzD,GAAG;GACH,GAAG;GACJ,EAAE;EAML,MAAM,uBAAuB,0BAC3B,QAAQ,cACR,QAAQ,IAAI,yBACb;EACD,MAAM,sBAAsB,yBAC1B,QAAQ,aACR,QAAQ,IAAI,iBACb;EACD,MAAM,4BACJ,wBAAwB,SACpB,EAAE,aAAa,qBAAqB,GACpC,yBAAyB,SACvB,EAAE,cAAc,sBAAsB,GACtC,EAAE;AACV,OAAK,YAAYA,gBAAU,YAAY,0BAA0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AI,KAAK,MAAM,KAAK;AAGpC,SAAO,MAAM,KAAK,cAAc,QAAQ,CAAC;;;AAK7C,SAAgB,mBACd,QACoB;AACpB,QAAO;EACL,GAAG;EACH,MAAM,aAAa;EACpB;;AAGH,SAAgB,0BACd,QAC2B;AAC3B,QAAO;EACL,GAAG;EACH,MAAM,aAAa;EACpB;;AAGH,SAAgB,oBAAoB,UAA8B;AAChE,KAAI,CAAC,SAAS,KACZ,KAAI,mBAAmB,YAAY,YAAY,SAC7C,QAAO,aAAa;KAEpB,QAAO,aAAa;AAIxB,QAAO,SAAS"}
@@ -30,6 +30,7 @@ let node_crypto = require("node:crypto");
30
30
  var TelemetryAgentRunner = class {
31
31
  constructor(config) {
32
32
  this._runner = config?.runner ?? new require_in_memory.InMemoryAgentRunner();
33
+ this.telemetry = config?.telemetry ?? require_telemetry_client.default;
33
34
  this.hashedLgcKey = config?.langsmithApiKey ? (0, node_crypto.createHash)("sha256").update(config.langsmithApiKey).digest("hex") : void 0;
34
35
  }
35
36
  /**
@@ -39,7 +40,7 @@ var TelemetryAgentRunner = class {
39
40
  run(...args) {
40
41
  const streamInfo = { hashedLgcKey: this.hashedLgcKey };
41
42
  let streamErrored = false;
42
- require_telemetry_client.default.capture("oss.runtime.agent_execution_stream_started", { hashedLgcKey: this.hashedLgcKey });
43
+ this.telemetry.capture("oss.runtime.agent_execution_stream_started", { hashedLgcKey: this.hashedLgcKey });
43
44
  return this._runner.run(...args).pipe((0, rxjs.tap)((event) => {
44
45
  const rawEvent = event.rawEvent;
45
46
  if (rawEvent?.data) {
@@ -56,13 +57,13 @@ var TelemetryAgentRunner = class {
56
57
  }
57
58
  }), (0, rxjs.catchError)((error) => {
58
59
  streamErrored = true;
59
- require_telemetry_client.default.capture("oss.runtime.agent_execution_stream_errored", {
60
+ this.telemetry.capture("oss.runtime.agent_execution_stream_errored", {
60
61
  ...streamInfo,
61
62
  error: error instanceof Error ? error.message : String(error)
62
63
  });
63
64
  throw error;
64
65
  }), (0, rxjs.finalize)(() => {
65
- if (!streamErrored) require_telemetry_client.default.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
66
+ if (!streamErrored) this.telemetry.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
66
67
  }));
67
68
  }
68
69
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-agent-runner.cjs","names":["InMemoryAgentRunner"],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { type AgentRunner, InMemoryAgentRunner } from \"../../../v2/runtime\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAa,uBAAb,MAAyD;CAIvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAIA,uCAAqB;AAC1D,OAAK,eAAe,QAAQ,8CACb,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,mCAAU,QAAQ,8CAA8C,EAC9D,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,oBAE1B,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,wBACU,UAAU;AAEpB,mBAAgB;AAChB,oCAAU,QAAQ,8CAA8C;IAC9D,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,2BACa;AAEb,OAAI,CAAC,cACH,kCAAU,QACR,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
1
+ {"version":3,"file":"telemetry-agent-runner.cjs","names":["InMemoryAgentRunner","telemetry"],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { InMemoryAgentRunner } from \"../../../v2/runtime\";\nimport type { AgentRunner } from \"../../../v2/runtime\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\nimport type { TelemetryCapture } from \"@copilotkit/shared\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n\n /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */\n telemetry?: TelemetryCapture;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n private readonly telemetry: TelemetryCapture;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.telemetry = config?.telemetry ?? telemetry;\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n this.telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,uBAAb,MAAyD;CAKvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAIA,uCAAqB;AAC1D,OAAK,YAAY,QAAQ,aAAaC;AACtC,OAAK,eAAe,QAAQ,8CACb,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,OAAK,UAAU,QAAQ,8CAA8C,EACnE,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,oBAE1B,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,wBACU,UAAU;AAEpB,mBAAgB;AAChB,QAAK,UAAU,QAAQ,8CAA8C;IACnE,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,2BACa;AAEb,OAAI,CAAC,cACH,MAAK,UAAU,QACb,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
@@ -1,6 +1,7 @@
1
1
 
2
2
  import { AgentRunner } from "../../v2/runtime/runner/agent-runner.cjs";
3
3
  import "../../v2/runtime/index.cjs";
4
+ import { TelemetryCapture } from "@copilotkit/shared";
4
5
 
5
6
  //#region src/v1-deprecated/lib/runtime/telemetry-agent-runner.d.ts
6
7
  /**
@@ -16,6 +17,8 @@ interface TelemetryAgentRunnerConfig {
16
17
  * Optional LangSmith API key (will be hashed for telemetry)
17
18
  */
18
19
  langsmithApiKey?: string;
20
+ /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */
21
+ telemetry?: TelemetryCapture;
19
22
  }
20
23
  /**
21
24
  * An AgentRunner wrapper that adds telemetry tracking for agent executions.
@@ -32,6 +35,7 @@ interface TelemetryAgentRunnerConfig {
32
35
  declare class TelemetryAgentRunner implements AgentRunner {
33
36
  private readonly _runner;
34
37
  private readonly hashedLgcKey;
38
+ private readonly telemetry;
35
39
  constructor(config?: TelemetryAgentRunnerConfig);
36
40
  /**
37
41
  * Runs an agent with telemetry tracking.
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-agent-runner.d.cts","names":[],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"mappings":";;;;;;;;UA2CiB,0BAAA;EAyBiB;;;;EApBhC,MAAA,GAAS,WAAA;EAmCgD;;;EA9BzD,eAAA;AAAA;;;;;;;;;;;;;cAeW,oBAAA,YAAgC,WAAA;EAAA,iBAC1B,OAAA;EAAA,iBACA,YAAA;cAEL,MAAA,GAAS,0BAAA;EAAA;;;;EAWrB,GAAA,CAAA,GAAO,IAAA,EAAM,UAAA,CAAW,WAAA,WAAsB,UAAA,CAAW,WAAA;EAAjC;;;EAoExB,OAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,eACnB,UAAA,CAAW,WAAA;EADT;;;EAQL,SAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,iBACnB,UAAA,CAAW,WAAA;EATA;;;EAgBd,IAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,YACnB,UAAA,CAAW,WAAA;AAAA"}
1
+ {"version":3,"file":"telemetry-agent-runner.d.cts","names":[],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"mappings":";;;;;;;;;UA6CiB,0BAAA;EAA0B;;;;EAKzC,MAAA,GAAS,WAAA;EAKT;;;EAAA,eAAA;EAG4B;EAA5B,SAAA,GAAY,gBAAA;AAAA;;;;;;;;;;;;;cAeD,oBAAA,YAAgC,WAAA;EAAA,iBAC1B,OAAA;EAAA,iBACA,YAAA;EAAA,iBACA,SAAA;cAEL,MAAA,GAAS,0BAAA;EAoGlB;;;;EAxFH,GAAA,CAAA,GAAO,IAAA,EAAM,UAAA,CAAW,WAAA,WAAsB,UAAA,CAAW,WAAA;EAhBxC;;;EAoFjB,OAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,eACnB,UAAA,CAAW,WAAA;EAlFO;;;EAyFrB,SAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,iBACnB,UAAA,CAAW,WAAA;EA/ED;;;EAsFb,IAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,YACnB,UAAA,CAAW,WAAA;AAAA"}
@@ -1,6 +1,7 @@
1
1
 
2
2
  import { AgentRunner } from "../../v2/runtime/runner/agent-runner.mjs";
3
3
  import "../../v2/runtime/index.mjs";
4
+ import { TelemetryCapture } from "@copilotkit/shared";
4
5
 
5
6
  //#region src/v1-deprecated/lib/runtime/telemetry-agent-runner.d.ts
6
7
  /**
@@ -16,6 +17,8 @@ interface TelemetryAgentRunnerConfig {
16
17
  * Optional LangSmith API key (will be hashed for telemetry)
17
18
  */
18
19
  langsmithApiKey?: string;
20
+ /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */
21
+ telemetry?: TelemetryCapture;
19
22
  }
20
23
  /**
21
24
  * An AgentRunner wrapper that adds telemetry tracking for agent executions.
@@ -32,6 +35,7 @@ interface TelemetryAgentRunnerConfig {
32
35
  declare class TelemetryAgentRunner implements AgentRunner {
33
36
  private readonly _runner;
34
37
  private readonly hashedLgcKey;
38
+ private readonly telemetry;
35
39
  constructor(config?: TelemetryAgentRunnerConfig);
36
40
  /**
37
41
  * Runs an agent with telemetry tracking.
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-agent-runner.d.mts","names":[],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"mappings":";;;;;;;;UA2CiB,0BAAA;EAyBiB;;;;EApBhC,MAAA,GAAS,WAAA;EAmCgD;;;EA9BzD,eAAA;AAAA;;;;;;;;;;;;;cAeW,oBAAA,YAAgC,WAAA;EAAA,iBAC1B,OAAA;EAAA,iBACA,YAAA;cAEL,MAAA,GAAS,0BAAA;EAAA;;;;EAWrB,GAAA,CAAA,GAAO,IAAA,EAAM,UAAA,CAAW,WAAA,WAAsB,UAAA,CAAW,WAAA;EAAjC;;;EAoExB,OAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,eACnB,UAAA,CAAW,WAAA;EADT;;;EAQL,SAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,iBACnB,UAAA,CAAW,WAAA;EATA;;;EAgBd,IAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,YACnB,UAAA,CAAW,WAAA;AAAA"}
1
+ {"version":3,"file":"telemetry-agent-runner.d.mts","names":[],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"mappings":";;;;;;;;;UA6CiB,0BAAA;EAA0B;;;;EAKzC,MAAA,GAAS,WAAA;EAKT;;;EAAA,eAAA;EAG4B;EAA5B,SAAA,GAAY,gBAAA;AAAA;;;;;;;;;;;;;cAeD,oBAAA,YAAgC,WAAA;EAAA,iBAC1B,OAAA;EAAA,iBACA,YAAA;EAAA,iBACA,SAAA;cAEL,MAAA,GAAS,0BAAA;EAoGlB;;;;EAxFH,GAAA,CAAA,GAAO,IAAA,EAAM,UAAA,CAAW,WAAA,WAAsB,UAAA,CAAW,WAAA;EAhBxC;;;EAoFjB,OAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,eACnB,UAAA,CAAW,WAAA;EAlFO;;;EAyFrB,SAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,iBACnB,UAAA,CAAW,WAAA;EA/ED;;;EAsFb,IAAA,CAAA,GACK,IAAA,EAAM,UAAA,CAAW,WAAA,YACnB,UAAA,CAAW,WAAA;AAAA"}
@@ -29,6 +29,7 @@ import { createHash } from "node:crypto";
29
29
  var TelemetryAgentRunner = class {
30
30
  constructor(config) {
31
31
  this._runner = config?.runner ?? new InMemoryAgentRunner();
32
+ this.telemetry = config?.telemetry ?? telemetryClient;
32
33
  this.hashedLgcKey = config?.langsmithApiKey ? createHash("sha256").update(config.langsmithApiKey).digest("hex") : void 0;
33
34
  }
34
35
  /**
@@ -38,7 +39,7 @@ var TelemetryAgentRunner = class {
38
39
  run(...args) {
39
40
  const streamInfo = { hashedLgcKey: this.hashedLgcKey };
40
41
  let streamErrored = false;
41
- telemetryClient.capture("oss.runtime.agent_execution_stream_started", { hashedLgcKey: this.hashedLgcKey });
42
+ this.telemetry.capture("oss.runtime.agent_execution_stream_started", { hashedLgcKey: this.hashedLgcKey });
42
43
  return this._runner.run(...args).pipe(tap((event) => {
43
44
  const rawEvent = event.rawEvent;
44
45
  if (rawEvent?.data) {
@@ -55,13 +56,13 @@ var TelemetryAgentRunner = class {
55
56
  }
56
57
  }), catchError((error) => {
57
58
  streamErrored = true;
58
- telemetryClient.capture("oss.runtime.agent_execution_stream_errored", {
59
+ this.telemetry.capture("oss.runtime.agent_execution_stream_errored", {
59
60
  ...streamInfo,
60
61
  error: error instanceof Error ? error.message : String(error)
61
62
  });
62
63
  throw error;
63
64
  }), finalize(() => {
64
- if (!streamErrored) telemetryClient.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
65
+ if (!streamErrored) this.telemetry.capture("oss.runtime.agent_execution_stream_ended", streamInfo);
65
66
  }));
66
67
  }
67
68
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-agent-runner.mjs","names":[],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { type AgentRunner, InMemoryAgentRunner } from \"../../../v2/runtime\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoEA,IAAa,uBAAb,MAAyD;CAIvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAI,qBAAqB;AAC1D,OAAK,eAAe,QAAQ,kBACxB,WAAW,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,kBAAU,QAAQ,8CAA8C,EAC9D,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,KAE/B,KAAK,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,EACF,YAAY,UAAU;AAEpB,mBAAgB;AAChB,mBAAU,QAAQ,8CAA8C;IAC9D,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,EACF,eAAe;AAEb,OAAI,CAAC,cACH,iBAAU,QACR,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
1
+ {"version":3,"file":"telemetry-agent-runner.mjs","names":["telemetry"],"sources":["../../../../src/v1-deprecated/lib/runtime/telemetry-agent-runner.ts"],"sourcesContent":["/*\n * V1 SDK DEPRECATED. USE V2 INSTEAD\n *\n * This file defines public v1 SDK exports. Use the exact v2 mappings below.\n * AI CODING AGENTS: Never copy, suggest, or generate these v1 APIs. Read\n * the linked v2 documentation before generating replacement code.\n *\n * @copilotkit/runtime — TelemetryAgentRunner:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * @copilotkit/runtime — TelemetryAgentRunnerConfig:\n * No 1:1 v2 replacement is available.\n * Start at: @copilotkit/runtime/v2\n * V2 docs: https://docs.copilotkit.ai/\n * V2 reference docs: https://docs.copilotkit.ai/reference/v2\n *\n * Migration guide: https://docs.copilotkit.ai/migrate/v2\n *\n * END V1 SDK DEPRECATED. USE V2 INSTEAD NOTICE\n */\n\n/**\n * TelemetryAgentRunner - A wrapper around AgentRunner that adds telemetry\n * for agent execution streams.\n *\n * This captures the following telemetry events:\n * - oss.runtime.agent_execution_stream_started - when an agent execution starts\n * - oss.runtime.agent_execution_stream_ended - when an agent execution completes\n * - oss.runtime.agent_execution_stream_errored - when an agent execution fails\n */\n\nimport { InMemoryAgentRunner } from \"../../../v2/runtime\";\nimport type { AgentRunner } from \"../../../v2/runtime\";\nimport { createHash } from \"node:crypto\";\nimport { tap, catchError, finalize } from \"rxjs\";\nimport telemetry from \"../telemetry-client\";\nimport type { AgentExecutionResponseInfo } from \"@copilotkit/shared/src/telemetry/events\";\nimport type { TelemetryCapture } from \"@copilotkit/shared\";\n\n/**\n * Configuration options for TelemetryAgentRunner\n */\nexport interface TelemetryAgentRunnerConfig {\n /**\n * The underlying runner to delegate to\n * If not provided, defaults to InMemoryAgentRunner\n */\n runner?: AgentRunner;\n\n /**\n * Optional LangSmith API key (will be hashed for telemetry)\n */\n langsmithApiKey?: string;\n\n /** Runtime-bound telemetry capture. Defaults to the legacy singleton. */\n telemetry?: TelemetryCapture;\n}\n\n/**\n * An AgentRunner wrapper that adds telemetry tracking for agent executions.\n *\n * Usage:\n * ```ts\n * const runtime = new CopilotRuntime({\n * runner: new TelemetryAgentRunner(),\n * // or with custom runner:\n * runner: new TelemetryAgentRunner({ runner: customRunner }),\n * });\n * ```\n */\nexport class TelemetryAgentRunner implements AgentRunner {\n private readonly _runner: AgentRunner;\n private readonly hashedLgcKey: string | undefined;\n private readonly telemetry: TelemetryCapture;\n\n constructor(config?: TelemetryAgentRunnerConfig) {\n this._runner = config?.runner ?? new InMemoryAgentRunner();\n this.telemetry = config?.telemetry ?? telemetry;\n this.hashedLgcKey = config?.langsmithApiKey\n ? createHash(\"sha256\").update(config.langsmithApiKey).digest(\"hex\")\n : undefined;\n }\n\n /**\n * Runs an agent with telemetry tracking.\n * Wraps the underlying runner's Observable stream with telemetry events.\n */\n run(...args: Parameters<AgentRunner[\"run\"]>): ReturnType<AgentRunner[\"run\"]> {\n const streamInfo: AgentExecutionResponseInfo = {\n hashedLgcKey: this.hashedLgcKey,\n };\n let streamErrored = false;\n\n // Capture stream started event\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_started\", {\n hashedLgcKey: this.hashedLgcKey,\n });\n\n // Delegate to the underlying runner and wrap with telemetry\n return this._runner.run(...args).pipe(\n // Extract metadata from events if available\n tap((event) => {\n // Try to extract provider/model info from raw events\n const rawEvent = (\n event as {\n rawEvent?: {\n metadata?: Record<string, unknown>;\n data?: Record<string, unknown>;\n };\n }\n ).rawEvent;\n if (rawEvent?.data) {\n const data = rawEvent.data as { output?: { model?: string } };\n if (data?.output?.model) {\n streamInfo.model = data.output.model;\n streamInfo.provider = data.output.model;\n }\n }\n if (rawEvent?.metadata) {\n const metadata = rawEvent.metadata as {\n langgraph_host?: string;\n langgraph_version?: string;\n };\n if (metadata?.langgraph_host) {\n streamInfo.langGraphHost = metadata.langgraph_host;\n }\n if (metadata?.langgraph_version) {\n streamInfo.langGraphVersion = metadata.langgraph_version;\n }\n }\n }),\n catchError((error) => {\n // Capture stream error event\n streamErrored = true;\n this.telemetry.capture(\"oss.runtime.agent_execution_stream_errored\", {\n ...streamInfo,\n error: error instanceof Error ? error.message : String(error),\n });\n throw error;\n }),\n finalize(() => {\n // Capture stream ended event (only if not errored)\n if (!streamErrored) {\n this.telemetry.capture(\n \"oss.runtime.agent_execution_stream_ended\",\n streamInfo,\n );\n }\n }),\n );\n }\n\n /**\n * Delegates to the underlying runner's connect method\n */\n connect(\n ...args: Parameters<AgentRunner[\"connect\"]>\n ): ReturnType<AgentRunner[\"connect\"]> {\n return this._runner.connect(...args);\n }\n\n /**\n * Delegates to the underlying runner's isRunning method\n */\n isRunning(\n ...args: Parameters<AgentRunner[\"isRunning\"]>\n ): ReturnType<AgentRunner[\"isRunning\"]> {\n return this._runner.isRunning(...args);\n }\n\n /**\n * Delegates to the underlying runner's stop method\n */\n stop(\n ...args: Parameters<AgentRunner[\"stop\"]>\n ): ReturnType<AgentRunner[\"stop\"]> {\n return this._runner.stop(...args);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyEA,IAAa,uBAAb,MAAyD;CAKvD,YAAY,QAAqC;AAC/C,OAAK,UAAU,QAAQ,UAAU,IAAI,qBAAqB;AAC1D,OAAK,YAAY,QAAQ,aAAaA;AACtC,OAAK,eAAe,QAAQ,kBACxB,WAAW,SAAS,CAAC,OAAO,OAAO,gBAAgB,CAAC,OAAO,MAAM,GACjE;;;;;;CAON,IAAI,GAAG,MAAsE;EAC3E,MAAM,aAAyC,EAC7C,cAAc,KAAK,cACpB;EACD,IAAI,gBAAgB;AAGpB,OAAK,UAAU,QAAQ,8CAA8C,EACnE,cAAc,KAAK,cACpB,CAAC;AAGF,SAAO,KAAK,QAAQ,IAAI,GAAG,KAAK,CAAC,KAE/B,KAAK,UAAU;GAEb,MAAM,WACJ,MAMA;AACF,OAAI,UAAU,MAAM;IAClB,MAAM,OAAO,SAAS;AACtB,QAAI,MAAM,QAAQ,OAAO;AACvB,gBAAW,QAAQ,KAAK,OAAO;AAC/B,gBAAW,WAAW,KAAK,OAAO;;;AAGtC,OAAI,UAAU,UAAU;IACtB,MAAM,WAAW,SAAS;AAI1B,QAAI,UAAU,eACZ,YAAW,gBAAgB,SAAS;AAEtC,QAAI,UAAU,kBACZ,YAAW,mBAAmB,SAAS;;IAG3C,EACF,YAAY,UAAU;AAEpB,mBAAgB;AAChB,QAAK,UAAU,QAAQ,8CAA8C;IACnE,GAAG;IACH,OAAO,iBAAiB,QAAQ,MAAM,UAAU,OAAO,MAAM;IAC9D,CAAC;AACF,SAAM;IACN,EACF,eAAe;AAEb,OAAI,CAAC,cACH,MAAK,UAAU,QACb,4CACA,WACD;IAEH,CACH;;;;;CAMH,QACE,GAAG,MACiC;AACpC,SAAO,KAAK,QAAQ,QAAQ,GAAG,KAAK;;;;;CAMtC,UACE,GAAG,MACmC;AACtC,SAAO,KAAK,QAAQ,UAAU,GAAG,KAAK;;;;;CAMxC,KACE,GAAG,MAC8B;AACjC,SAAO,KAAK,QAAQ,KAAK,GAAG,KAAK"}
@@ -8,9 +8,9 @@ function isTelemetryDisabled() {
8
8
  }
9
9
  let disclosureLogged = false;
10
10
  /**
11
- * Logs a one-line console.info about anonymous telemetry on runtime
12
- * startup. No-op when telemetry is disabled via `COPILOTKIT_TELEMETRY_DISABLED`
13
- * or `DO_NOT_TRACK`, or when already logged once in this process.
11
+ * Logs a one-line telemetry notice on Runtime startup. No-op when telemetry is
12
+ * disabled via `COPILOTKIT_TELEMETRY_DISABLED` or `DO_NOT_TRACK`, or when
13
+ * already logged once in this process.
14
14
  *
15
15
  * Idempotent — safe to call from multiple constructor paths.
16
16
  */
@@ -18,7 +18,7 @@ function logRuntimeTelemetryDisclosure() {
18
18
  if (disclosureLogged) return;
19
19
  if (isTelemetryDisabled()) return;
20
20
  disclosureLogged = true;
21
- console.info(`[CopilotKit Runtime] anonymous telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`);
21
+ console.info(`[CopilotKit Runtime] telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`);
22
22
  }
23
23
 
24
24
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-disclosure.cjs","names":[],"sources":["../../../src/v1-deprecated/lib/telemetry-disclosure.ts"],"sourcesContent":["// Runtime-side anonymous telemetry disclosure log.\n//\n// The runtime has shipped anonymous telemetry for some time (see\n// `packages/shared/src/telemetry/telemetry-client.ts`). This file just\n// surfaces a one-line pointer to the opt-out docs on first\n// instantiation so operators don't have to dig through the docs site\n// to discover the existing behavior. Pairs with the inspector's\n// first-run console disclosure for a consistent operator-facing\n// surface.\n//\n// Fires at most once per process — runtime instances may be constructed\n// multiple times (tests, hot-reload), but the disclosure is informational\n// and a single line is enough.\n\n// Canonical telemetry docs page on main.\n// Mirror constant: packages/web-inspector/src/lib/telemetry.ts\nconst TELEMETRY_DOCS_URL = \"https://docs.copilotkit.ai/telemetry\";\n\nfunction isTelemetryDisabled(): boolean {\n const env = process.env as Record<string, string | undefined>;\n return (\n env.COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n env.COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n env.DO_NOT_TRACK === \"true\" ||\n env.DO_NOT_TRACK === \"1\"\n );\n}\n\nlet disclosureLogged = false;\n\n/**\n * Logs a one-line console.info about anonymous telemetry on runtime\n * startup. No-op when telemetry is disabled via `COPILOTKIT_TELEMETRY_DISABLED`\n * or `DO_NOT_TRACK`, or when already logged once in this process.\n *\n * Idempotent — safe to call from multiple constructor paths.\n */\nexport function logRuntimeTelemetryDisclosure(): void {\n if (disclosureLogged) return;\n if (isTelemetryDisabled()) return;\n disclosureLogged = true;\n // eslint-disable-next-line no-console\n console.info(\n `[CopilotKit Runtime] anonymous telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`,\n );\n}\n\n// Test-only reset hook so the once-per-process guard doesn't leak between\n// test cases. Not part of the public package surface — used by the runtime\n// disclosure tests.\nexport function _resetRuntimeTelemetryDisclosureForTesting(): void {\n disclosureLogged = false;\n}\n"],"mappings":";;;AAgBA,MAAM,qBAAqB;AAE3B,SAAS,sBAA+B;CACtC,MAAM,MAAM,QAAQ;AACpB,QACE,IAAI,kCAAkC,UACtC,IAAI,kCAAkC,OACtC,IAAI,iBAAiB,UACrB,IAAI,iBAAiB;;AAIzB,IAAI,mBAAmB;;;;;;;;AASvB,SAAgB,gCAAsC;AACpD,KAAI,iBAAkB;AACtB,KAAI,qBAAqB,CAAE;AAC3B,oBAAmB;AAEnB,SAAQ,KACN,0DAA0D,mBAAmB,uDAC9E"}
1
+ {"version":3,"file":"telemetry-disclosure.cjs","names":[],"sources":["../../../src/v1-deprecated/lib/telemetry-disclosure.ts"],"sourcesContent":["// Runtime-side telemetry disclosure log.\n//\n// The runtime has shipped telemetry for some time (see\n// `packages/shared/src/telemetry/telemetry-client.ts`). Sends are anonymous by\n// default but can carry a configured standalone or legacy identity. This file\n// surfaces a neutral one-line pointer to the opt-out docs on first\n// instantiation so the disclosure stays true for every identity mode. It pairs\n// with the inspector's first-run console disclosure.\n//\n// Fires at most once per process — runtime instances may be constructed\n// multiple times (tests, hot-reload), but the disclosure is informational\n// and a single line is enough.\n\n// Canonical telemetry docs page on main.\n// Mirror constant: packages/web-inspector/src/lib/telemetry.ts\nconst TELEMETRY_DOCS_URL = \"https://docs.copilotkit.ai/telemetry\";\n\nfunction isTelemetryDisabled(): boolean {\n const env = process.env as Record<string, string | undefined>;\n return (\n env.COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n env.COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n env.DO_NOT_TRACK === \"true\" ||\n env.DO_NOT_TRACK === \"1\"\n );\n}\n\nlet disclosureLogged = false;\n\n/**\n * Logs a one-line telemetry notice on Runtime startup. No-op when telemetry is\n * disabled via `COPILOTKIT_TELEMETRY_DISABLED` or `DO_NOT_TRACK`, or when\n * already logged once in this process.\n *\n * Idempotent — safe to call from multiple constructor paths.\n */\nexport function logRuntimeTelemetryDisclosure(): void {\n if (disclosureLogged) return;\n if (isTelemetryDisabled()) return;\n disclosureLogged = true;\n // eslint-disable-next-line no-console\n console.info(\n `[CopilotKit Runtime] telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`,\n );\n}\n\n// Test-only reset hook so the once-per-process guard doesn't leak between\n// test cases. Not part of the public package surface — used by the runtime\n// disclosure tests.\nexport function _resetRuntimeTelemetryDisclosureForTesting(): void {\n disclosureLogged = false;\n}\n"],"mappings":";;;AAeA,MAAM,qBAAqB;AAE3B,SAAS,sBAA+B;CACtC,MAAM,MAAM,QAAQ;AACpB,QACE,IAAI,kCAAkC,UACtC,IAAI,kCAAkC,OACtC,IAAI,iBAAiB,UACrB,IAAI,iBAAiB;;AAIzB,IAAI,mBAAmB;;;;;;;;AASvB,SAAgB,gCAAsC;AACpD,KAAI,iBAAkB;AACtB,KAAI,qBAAqB,CAAE;AAC3B,oBAAmB;AAEnB,SAAQ,KACN,gDAAgD,mBAAmB,uDACpE"}
@@ -7,9 +7,9 @@ function isTelemetryDisabled() {
7
7
  }
8
8
  let disclosureLogged = false;
9
9
  /**
10
- * Logs a one-line console.info about anonymous telemetry on runtime
11
- * startup. No-op when telemetry is disabled via `COPILOTKIT_TELEMETRY_DISABLED`
12
- * or `DO_NOT_TRACK`, or when already logged once in this process.
10
+ * Logs a one-line telemetry notice on Runtime startup. No-op when telemetry is
11
+ * disabled via `COPILOTKIT_TELEMETRY_DISABLED` or `DO_NOT_TRACK`, or when
12
+ * already logged once in this process.
13
13
  *
14
14
  * Idempotent — safe to call from multiple constructor paths.
15
15
  */
@@ -17,7 +17,7 @@ function logRuntimeTelemetryDisclosure() {
17
17
  if (disclosureLogged) return;
18
18
  if (isTelemetryDisabled()) return;
19
19
  disclosureLogged = true;
20
- console.info(`[CopilotKit Runtime] anonymous telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`);
20
+ console.info(`[CopilotKit Runtime] telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`);
21
21
  }
22
22
 
23
23
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-disclosure.mjs","names":[],"sources":["../../../src/v1-deprecated/lib/telemetry-disclosure.ts"],"sourcesContent":["// Runtime-side anonymous telemetry disclosure log.\n//\n// The runtime has shipped anonymous telemetry for some time (see\n// `packages/shared/src/telemetry/telemetry-client.ts`). This file just\n// surfaces a one-line pointer to the opt-out docs on first\n// instantiation so operators don't have to dig through the docs site\n// to discover the existing behavior. Pairs with the inspector's\n// first-run console disclosure for a consistent operator-facing\n// surface.\n//\n// Fires at most once per process — runtime instances may be constructed\n// multiple times (tests, hot-reload), but the disclosure is informational\n// and a single line is enough.\n\n// Canonical telemetry docs page on main.\n// Mirror constant: packages/web-inspector/src/lib/telemetry.ts\nconst TELEMETRY_DOCS_URL = \"https://docs.copilotkit.ai/telemetry\";\n\nfunction isTelemetryDisabled(): boolean {\n const env = process.env as Record<string, string | undefined>;\n return (\n env.COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n env.COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n env.DO_NOT_TRACK === \"true\" ||\n env.DO_NOT_TRACK === \"1\"\n );\n}\n\nlet disclosureLogged = false;\n\n/**\n * Logs a one-line console.info about anonymous telemetry on runtime\n * startup. No-op when telemetry is disabled via `COPILOTKIT_TELEMETRY_DISABLED`\n * or `DO_NOT_TRACK`, or when already logged once in this process.\n *\n * Idempotent — safe to call from multiple constructor paths.\n */\nexport function logRuntimeTelemetryDisclosure(): void {\n if (disclosureLogged) return;\n if (isTelemetryDisabled()) return;\n disclosureLogged = true;\n // eslint-disable-next-line no-console\n console.info(\n `[CopilotKit Runtime] anonymous telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`,\n );\n}\n\n// Test-only reset hook so the once-per-process guard doesn't leak between\n// test cases. Not part of the public package surface — used by the runtime\n// disclosure tests.\nexport function _resetRuntimeTelemetryDisclosureForTesting(): void {\n disclosureLogged = false;\n}\n"],"mappings":";;AAgBA,MAAM,qBAAqB;AAE3B,SAAS,sBAA+B;CACtC,MAAM,MAAM,QAAQ;AACpB,QACE,IAAI,kCAAkC,UACtC,IAAI,kCAAkC,OACtC,IAAI,iBAAiB,UACrB,IAAI,iBAAiB;;AAIzB,IAAI,mBAAmB;;;;;;;;AASvB,SAAgB,gCAAsC;AACpD,KAAI,iBAAkB;AACtB,KAAI,qBAAqB,CAAE;AAC3B,oBAAmB;AAEnB,SAAQ,KACN,0DAA0D,mBAAmB,uDAC9E"}
1
+ {"version":3,"file":"telemetry-disclosure.mjs","names":[],"sources":["../../../src/v1-deprecated/lib/telemetry-disclosure.ts"],"sourcesContent":["// Runtime-side telemetry disclosure log.\n//\n// The runtime has shipped telemetry for some time (see\n// `packages/shared/src/telemetry/telemetry-client.ts`). Sends are anonymous by\n// default but can carry a configured standalone or legacy identity. This file\n// surfaces a neutral one-line pointer to the opt-out docs on first\n// instantiation so the disclosure stays true for every identity mode. It pairs\n// with the inspector's first-run console disclosure.\n//\n// Fires at most once per process — runtime instances may be constructed\n// multiple times (tests, hot-reload), but the disclosure is informational\n// and a single line is enough.\n\n// Canonical telemetry docs page on main.\n// Mirror constant: packages/web-inspector/src/lib/telemetry.ts\nconst TELEMETRY_DOCS_URL = \"https://docs.copilotkit.ai/telemetry\";\n\nfunction isTelemetryDisabled(): boolean {\n const env = process.env as Record<string, string | undefined>;\n return (\n env.COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n env.COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n env.DO_NOT_TRACK === \"true\" ||\n env.DO_NOT_TRACK === \"1\"\n );\n}\n\nlet disclosureLogged = false;\n\n/**\n * Logs a one-line telemetry notice on Runtime startup. No-op when telemetry is\n * disabled via `COPILOTKIT_TELEMETRY_DISABLED` or `DO_NOT_TRACK`, or when\n * already logged once in this process.\n *\n * Idempotent — safe to call from multiple constructor paths.\n */\nexport function logRuntimeTelemetryDisclosure(): void {\n if (disclosureLogged) return;\n if (isTelemetryDisabled()) return;\n disclosureLogged = true;\n // eslint-disable-next-line no-console\n console.info(\n `[CopilotKit Runtime] telemetry enabled — see ${TELEMETRY_DOCS_URL} to opt out (set COPILOTKIT_TELEMETRY_DISABLED=true).`,\n );\n}\n\n// Test-only reset hook so the once-per-process guard doesn't leak between\n// test cases. Not part of the public package surface — used by the runtime\n// disclosure tests.\nexport function _resetRuntimeTelemetryDisclosureForTesting(): void {\n disclosureLogged = false;\n}\n"],"mappings":";;AAeA,MAAM,qBAAqB;AAE3B,SAAS,sBAA+B;CACtC,MAAM,MAAM,QAAQ;AACpB,QACE,IAAI,kCAAkC,UACtC,IAAI,kCAAkC,OACtC,IAAI,iBAAiB,UACrB,IAAI,iBAAiB;;AAIzB,IAAI,mBAAmB;;;;;;;;AASvB,SAAgB,gCAAsC;AACpD,KAAI,iBAAkB;AACtB,KAAI,qBAAqB,CAAE;AAC3B,oBAAmB;AAEnB,SAAQ,KACN,gDAAgD,mBAAmB,uDACpE"}
package/dist/package.cjs CHANGED
@@ -5,7 +5,7 @@ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
5
5
  var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
6
6
  module.exports = {
7
7
  "name": "@copilotkit/runtime",
8
- "version": "1.69.3",
8
+ "version": "1.70.0",
9
9
  "private": false,
10
10
  "keywords": [
11
11
  "ai",
@@ -79,9 +79,9 @@ var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, m
79
79
  },
80
80
  "dependencies": {
81
81
  "@ag-ui/a2ui-middleware": "0.0.10",
82
- "@ag-ui/client": "0.0.57",
83
- "@ag-ui/core": "0.0.57",
84
- "@ag-ui/encoder": "0.0.57",
82
+ "@ag-ui/client": "0.0.59",
83
+ "@ag-ui/core": "0.0.59",
84
+ "@ag-ui/encoder": "0.0.59",
85
85
  "@ag-ui/langgraph": "0.0.42",
86
86
  "@ag-ui/mcp-apps-middleware": "0.0.3",
87
87
  "@ag-ui/mcp-middleware": "0.0.1",
package/dist/package.mjs CHANGED
@@ -5,7 +5,7 @@ import { __commonJSMin } from "./_virtual/_rolldown/runtime.mjs";
5
5
  var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6
6
  module.exports = {
7
7
  "name": "@copilotkit/runtime",
8
- "version": "1.69.3",
8
+ "version": "1.70.0",
9
9
  "private": false,
10
10
  "keywords": [
11
11
  "ai",
@@ -79,9 +79,9 @@ var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
79
79
  },
80
80
  "dependencies": {
81
81
  "@ag-ui/a2ui-middleware": "0.0.10",
82
- "@ag-ui/client": "0.0.57",
83
- "@ag-ui/core": "0.0.57",
84
- "@ag-ui/encoder": "0.0.57",
82
+ "@ag-ui/client": "0.0.59",
83
+ "@ag-ui/core": "0.0.59",
84
+ "@ag-ui/encoder": "0.0.59",
85
85
  "@ag-ui/langgraph": "0.0.42",
86
86
  "@ag-ui/mcp-apps-middleware": "0.0.3",
87
87
  "@ag-ui/mcp-middleware": "0.0.1",