@copilotkit/runtime 2.0.0-rc.6 → 2.0.0-rc.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/agent/index.cjs +0 -10
  2. package/dist/agent/index.cjs.map +1 -1
  3. package/dist/agent/index.d.cts +1 -9
  4. package/dist/agent/index.d.cts.map +1 -1
  5. package/dist/agent/index.d.mts +1 -9
  6. package/dist/agent/index.d.mts.map +1 -1
  7. package/dist/agent/index.mjs +1 -10
  8. package/dist/agent/index.mjs.map +1 -1
  9. package/dist/index.cjs +0 -1
  10. package/dist/index.d.cts +3 -3
  11. package/dist/index.d.mts +3 -3
  12. package/dist/index.mjs +2 -2
  13. package/dist/node.cjs +1 -2
  14. package/dist/node.d.cts +2 -2
  15. package/dist/node.d.mts +2 -2
  16. package/dist/node.mjs +2 -2
  17. package/dist/runtime/core/package-info.cjs +1 -1
  18. package/dist/runtime/core/package-info.mjs +1 -1
  19. package/dist/runtime/endpoints/node-fetch-handler.cjs +0 -3
  20. package/dist/runtime/endpoints/node-fetch-handler.cjs.map +1 -1
  21. package/dist/runtime/endpoints/node-fetch-handler.d.cts +1 -3
  22. package/dist/runtime/endpoints/node-fetch-handler.d.cts.map +1 -1
  23. package/dist/runtime/endpoints/node-fetch-handler.d.mts +1 -3
  24. package/dist/runtime/endpoints/node-fetch-handler.d.mts.map +1 -1
  25. package/dist/runtime/endpoints/node-fetch-handler.mjs +1 -3
  26. package/dist/runtime/endpoints/node-fetch-handler.mjs.map +1 -1
  27. package/dist/runtime/index.d.cts +1 -9
  28. package/dist/runtime/index.d.mts +1 -9
  29. package/dist/runtime/node.d.cts +1 -1
  30. package/dist/runtime/node.d.mts +1 -1
  31. package/dist/runtime/telemetry/telemetry-client.cjs +0 -4
  32. package/dist/runtime/telemetry/telemetry-client.cjs.map +1 -1
  33. package/dist/runtime/telemetry/telemetry-client.mjs +0 -4
  34. package/dist/runtime/telemetry/telemetry-client.mjs.map +1 -1
  35. package/package.json +4 -4
  36. package/dist/runtime/index.d.cts.map +0 -1
  37. package/dist/runtime/index.d.mts.map +0 -1
package/dist/index.cjs CHANGED
@@ -17,7 +17,6 @@ const require_index = require('./agent/index.cjs');
17
17
  let _copilotkit_shared = require("@copilotkit/shared");
18
18
 
19
19
  exports.AgentRunner = require_agent_runner.AgentRunner;
20
- exports.BasicAgent = require_index.BasicAgent;
21
20
  exports.BuiltInAgent = require_index.BuiltInAgent;
22
21
  exports.CopilotIntelligenceRuntime = require_runtime$1.CopilotIntelligenceRuntime;
23
22
  exports.CopilotKitIntelligence = require_client.CopilotKitIntelligence;
package/dist/index.d.cts CHANGED
@@ -15,10 +15,10 @@ import { ChannelStatus, ChannelsControl } from "./runtime/core/channel-manager.c
15
15
  import { CopilotRuntimeHooks, ErrorHookContext, HandlerHookContext, HookContext, ResponseHookContext, RouteInfo } from "./runtime/core/hooks.cjs";
16
16
  import { CopilotCorsConfig } from "./runtime/core/fetch-cors.cjs";
17
17
  import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.cjs";
18
- import { CopilotKitRequestHandler, MCPClient, MCPTransport } from "./runtime/index.cjs";
18
+ import { MCPClient, MCPTransport } from "./runtime/index.cjs";
19
19
  import { CreateSafeUrlDownloadOptions, SafeUrlDownloadOptions, createSafeUrlDownload } from "./agent/url-download.cjs";
20
20
  import { BuiltInAgentLearnedSkills, BuiltInAgentLearnedSkillsOptions } from "./agent/learned-skills.cjs";
21
21
  import { convertAISDKStream } from "./agent/converters/aisdk.cjs";
22
22
  import { TanStackChatMessage, TanStackInputResult, convertInputToTanStackAI, convertTanStackStream } from "./agent/converters/tanstack.cjs";
23
- import { BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, InterruptSignal, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MessageConversionOptions, ModelSpecifier, OverridableProperty, ToolDefinition, classifyModelSpec, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "./agent/index.cjs";
24
- export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentLearnedSkills, BuiltInAgentLearnedSkillsOptions, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, ChannelStatus, ChannelsControl, CopilotCorsConfig, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotKitRequestHandler, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeLike, CopilotRuntimeMemoryConfig, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateSafeUrlDownloadOptions, CreateThreadRequest, ErrorHookContext, FinalizeRunOptions, GenerativeUIMiddleware, GenerativeUISurfaceWriter, GetLearnedSkillsSnapshotRequest, GetLearnedSkillsSnapshotsRequest, GetLearningContainerId, GetTrajectoryLearningContainerIds, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryAgentRunnerOptions, InMemoryLimits, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, LearnedSkillsBatchResult, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult, LearningContainerSelectorInput, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, LocalThreadEndpointScope, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MemoryAccess, MemoryConsumer, MemoryGrant, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, PlatformRequestError, ResponseHookContext, RouteInfo, RunEventFinalizer, RunnerStartupBoundary, RuntimeWithDeclaredChannels, SafeUrlDownloadOptions, SubscribeToThreadsRequest, SubscribeToThreadsResponse, THREAD_ACCESS_DENIED_ERROR_CODE, TanStackChatMessage, TanStackInputResult, ThreadAccessDeniedError, ThreadAccessMode, ThreadAlreadyRunningError, ThreadOwnershipRunner, ThreadSummary, ThreadsConfig, ToolDefinition, TrajectoryLearningContainerSelectorInput, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, classifyModelSpec, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotRuntimeHandler, createRunEventFinalizer, createSafeUrlDownload, createSurfaceWriter, defineTool, enforcesThreadOwnership, experimental_d_exports as experimental, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, isThreadAccessDeniedError, resolveAgents, resolveModel, supportsLocalThreadEndpoints, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵOWNER_RETENTION_DEFAULTS, ɵOwnerRetention, ɵSERVER_THREAD_OWNER, ɵestimateBytes, ɵnormalizeLimits, ɵresolveThreadOwner };
23
+ import { BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, InterruptSignal, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MessageConversionOptions, ModelSpecifier, OverridableProperty, ToolDefinition, classifyModelSpec, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "./agent/index.cjs";
24
+ export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentLearnedSkills, BuiltInAgentLearnedSkillsOptions, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, ChannelStatus, ChannelsControl, CopilotCorsConfig, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeLike, CopilotRuntimeMemoryConfig, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateSafeUrlDownloadOptions, CreateThreadRequest, ErrorHookContext, FinalizeRunOptions, GenerativeUIMiddleware, GenerativeUISurfaceWriter, GetLearnedSkillsSnapshotRequest, GetLearnedSkillsSnapshotsRequest, GetLearningContainerId, GetTrajectoryLearningContainerIds, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryAgentRunnerOptions, InMemoryLimits, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, LearnedSkillsBatchResult, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult, LearningContainerSelectorInput, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, LocalThreadEndpointScope, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MemoryAccess, MemoryConsumer, MemoryGrant, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, PlatformRequestError, ResponseHookContext, RouteInfo, RunEventFinalizer, RunnerStartupBoundary, RuntimeWithDeclaredChannels, SafeUrlDownloadOptions, SubscribeToThreadsRequest, SubscribeToThreadsResponse, THREAD_ACCESS_DENIED_ERROR_CODE, TanStackChatMessage, TanStackInputResult, ThreadAccessDeniedError, ThreadAccessMode, ThreadAlreadyRunningError, ThreadOwnershipRunner, ThreadSummary, ThreadsConfig, ToolDefinition, TrajectoryLearningContainerSelectorInput, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, classifyModelSpec, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotRuntimeHandler, createRunEventFinalizer, createSafeUrlDownload, createSurfaceWriter, defineTool, enforcesThreadOwnership, experimental_d_exports as experimental, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, isThreadAccessDeniedError, resolveAgents, resolveModel, supportsLocalThreadEndpoints, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵOWNER_RETENTION_DEFAULTS, ɵOwnerRetention, ɵSERVER_THREAD_OWNER, ɵestimateBytes, ɵnormalizeLimits, ɵresolveThreadOwner };
package/dist/index.d.mts CHANGED
@@ -15,10 +15,10 @@ import { ChannelStatus, ChannelsControl } from "./runtime/core/channel-manager.m
15
15
  import { CopilotRuntimeHooks, ErrorHookContext, HandlerHookContext, HookContext, ResponseHookContext, RouteInfo } from "./runtime/core/hooks.mjs";
16
16
  import { CopilotCorsConfig } from "./runtime/core/fetch-cors.mjs";
17
17
  import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.mjs";
18
- import { CopilotKitRequestHandler, MCPClient, MCPTransport } from "./runtime/index.mjs";
18
+ import { MCPClient, MCPTransport } from "./runtime/index.mjs";
19
19
  import { CreateSafeUrlDownloadOptions, SafeUrlDownloadOptions, createSafeUrlDownload } from "./agent/url-download.mjs";
20
20
  import { BuiltInAgentLearnedSkills, BuiltInAgentLearnedSkillsOptions } from "./agent/learned-skills.mjs";
21
21
  import { convertAISDKStream } from "./agent/converters/aisdk.mjs";
22
22
  import { TanStackChatMessage, TanStackInputResult, convertInputToTanStackAI, convertTanStackStream } from "./agent/converters/tanstack.mjs";
23
- import { BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, InterruptSignal, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MessageConversionOptions, ModelSpecifier, OverridableProperty, ToolDefinition, classifyModelSpec, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "./agent/index.mjs";
24
- export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentLearnedSkills, BuiltInAgentLearnedSkillsOptions, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, ChannelStatus, ChannelsControl, CopilotCorsConfig, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotKitRequestHandler, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeLike, CopilotRuntimeMemoryConfig, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateSafeUrlDownloadOptions, CreateThreadRequest, ErrorHookContext, FinalizeRunOptions, GenerativeUIMiddleware, GenerativeUISurfaceWriter, GetLearnedSkillsSnapshotRequest, GetLearnedSkillsSnapshotsRequest, GetLearningContainerId, GetTrajectoryLearningContainerIds, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryAgentRunnerOptions, InMemoryLimits, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, LearnedSkillsBatchResult, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult, LearningContainerSelectorInput, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, LocalThreadEndpointScope, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MemoryAccess, MemoryConsumer, MemoryGrant, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, PlatformRequestError, ResponseHookContext, RouteInfo, RunEventFinalizer, RunnerStartupBoundary, RuntimeWithDeclaredChannels, SafeUrlDownloadOptions, SubscribeToThreadsRequest, SubscribeToThreadsResponse, THREAD_ACCESS_DENIED_ERROR_CODE, TanStackChatMessage, TanStackInputResult, ThreadAccessDeniedError, ThreadAccessMode, ThreadAlreadyRunningError, ThreadOwnershipRunner, ThreadSummary, ThreadsConfig, ToolDefinition, TrajectoryLearningContainerSelectorInput, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, classifyModelSpec, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotRuntimeHandler, createRunEventFinalizer, createSafeUrlDownload, createSurfaceWriter, defineTool, enforcesThreadOwnership, experimental_d_exports as experimental, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, isThreadAccessDeniedError, resolveAgents, resolveModel, supportsLocalThreadEndpoints, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵOWNER_RETENTION_DEFAULTS, ɵOwnerRetention, ɵSERVER_THREAD_OWNER, ɵestimateBytes, ɵnormalizeLimits, ɵresolveThreadOwner };
23
+ import { BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, InterruptSignal, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MessageConversionOptions, ModelSpecifier, OverridableProperty, ToolDefinition, classifyModelSpec, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "./agent/index.mjs";
24
+ export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentFactoryContext, BuiltInAgentLearnedSkills, BuiltInAgentLearnedSkillsOptions, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, ChannelStatus, ChannelsControl, CopilotCorsConfig, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLearningConfig, CopilotRuntimeLearningContext, CopilotRuntimeLike, CopilotRuntimeMemoryConfig, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateSafeUrlDownloadOptions, CreateThreadRequest, ErrorHookContext, FinalizeRunOptions, GenerativeUIMiddleware, GenerativeUISurfaceWriter, GetLearnedSkillsSnapshotRequest, GetLearnedSkillsSnapshotsRequest, GetLearningContainerId, GetTrajectoryLearningContainerIds, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryAgentRunnerOptions, InMemoryLimits, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, LearnedSkillsBatchResult, LearnedSkillsError, LearnedSkillsErrorCode, LearnedSkillsSnapshotResult, LearningContainerSelectorInput, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, LocalThreadEndpointScope, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MemoryAccess, MemoryConsumer, MemoryGrant, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, PlatformRequestError, ResponseHookContext, RouteInfo, RunEventFinalizer, RunnerStartupBoundary, RuntimeWithDeclaredChannels, SafeUrlDownloadOptions, SubscribeToThreadsRequest, SubscribeToThreadsResponse, THREAD_ACCESS_DENIED_ERROR_CODE, TanStackChatMessage, TanStackInputResult, ThreadAccessDeniedError, ThreadAccessMode, ThreadAlreadyRunningError, ThreadOwnershipRunner, ThreadSummary, ThreadsConfig, ToolDefinition, TrajectoryLearningContainerSelectorInput, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, classifyModelSpec, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotRuntimeHandler, createRunEventFinalizer, createSafeUrlDownload, createSurfaceWriter, defineTool, enforcesThreadOwnership, experimental_d_exports as experimental, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, isThreadAccessDeniedError, resolveAgents, resolveModel, supportsLocalThreadEndpoints, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵOWNER_RETENTION_DEFAULTS, ɵOwnerRetention, ɵSERVER_THREAD_OWNER, ɵestimateBytes, ɵnormalizeLimits, ɵresolveThreadOwner };
package/dist/index.mjs CHANGED
@@ -12,6 +12,6 @@ import { createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.mjs";
12
12
  import { createSafeUrlDownload } from "./agent/url-download.mjs";
13
13
  import { convertAISDKStream } from "./agent/converters/aisdk.mjs";
14
14
  import { convertInputToTanStackAI, convertTanStackStream } from "./agent/converters/tanstack.mjs";
15
- import { BasicAgent, BuiltInAgent, InterruptSignal, classifyModelSpec, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "./agent/index.mjs";
15
+ import { BuiltInAgent, InterruptSignal, classifyModelSpec, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "./agent/index.mjs";
16
16
 
17
- export { AgentRunner, BasicAgent, BuiltInAgent, CopilotIntelligenceRuntime, CopilotKitIntelligence, CopilotRuntime, CopilotSseRuntime, GenerativeUIMiddleware, InMemoryAgentRunner, IntelligenceAgentRunner, InterruptSignal, LearnedSkillsError, PlatformRequestError, THREAD_ACCESS_DENIED_ERROR_CODE, ThreadAccessDeniedError, ThreadAlreadyRunningError, TranscriptionService, VERSION, classifyModelSpec, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotRuntimeHandler, createRunEventFinalizer, createSafeUrlDownload, createSurfaceWriter, defineTool, enforcesThreadOwnership, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, isThreadAccessDeniedError, resolveAgents, resolveModel, supportsLocalThreadEndpoints, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵOWNER_RETENTION_DEFAULTS, ɵSERVER_THREAD_OWNER, ɵestimateBytes, ɵnormalizeLimits, ɵresolveThreadOwner };
17
+ export { AgentRunner, BuiltInAgent, CopilotIntelligenceRuntime, CopilotKitIntelligence, CopilotRuntime, CopilotSseRuntime, GenerativeUIMiddleware, InMemoryAgentRunner, IntelligenceAgentRunner, InterruptSignal, LearnedSkillsError, PlatformRequestError, THREAD_ACCESS_DENIED_ERROR_CODE, ThreadAccessDeniedError, ThreadAlreadyRunningError, TranscriptionService, VERSION, classifyModelSpec, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotRuntimeHandler, createRunEventFinalizer, createSafeUrlDownload, createSurfaceWriter, defineTool, enforcesThreadOwnership, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, isThreadAccessDeniedError, resolveAgents, resolveModel, supportsLocalThreadEndpoints, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵOWNER_RETENTION_DEFAULTS, ɵSERVER_THREAD_OWNER, ɵestimateBytes, ɵnormalizeLimits, ɵresolveThreadOwner };
package/dist/node.cjs CHANGED
@@ -3,5 +3,4 @@ const require_node_fetch_handler = require('./runtime/endpoints/node-fetch-handl
3
3
  const require_node = require('./runtime/endpoints/node.cjs');
4
4
 
5
5
  exports.createCopilotNodeHandler = require_node_fetch_handler.createCopilotNodeHandler;
6
- exports.createCopilotNodeListener = require_node.createCopilotNodeListener;
7
- exports.createNodeFetchHandler = require_node_fetch_handler.createNodeFetchHandler;
6
+ exports.createCopilotNodeListener = require_node.createCopilotNodeListener;
package/dist/node.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- import { NodeFetchHandler, createCopilotNodeHandler, createNodeFetchHandler } from "./runtime/endpoints/node-fetch-handler.cjs";
1
+ import { NodeFetchHandler, createCopilotNodeHandler } from "./runtime/endpoints/node-fetch-handler.cjs";
2
2
  import { NodeCopilotListener, NodeCopilotListenerWithChannels, createCopilotNodeListener } from "./runtime/endpoints/node.cjs";
3
3
  import "./runtime/node.cjs";
4
- export { NodeCopilotListener, NodeCopilotListenerWithChannels, NodeFetchHandler, createCopilotNodeHandler, createCopilotNodeListener, createNodeFetchHandler };
4
+ export { NodeCopilotListener, NodeCopilotListenerWithChannels, NodeFetchHandler, createCopilotNodeHandler, createCopilotNodeListener };
package/dist/node.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import { NodeFetchHandler, createCopilotNodeHandler, createNodeFetchHandler } from "./runtime/endpoints/node-fetch-handler.mjs";
1
+ import { NodeFetchHandler, createCopilotNodeHandler } from "./runtime/endpoints/node-fetch-handler.mjs";
2
2
  import { NodeCopilotListener, NodeCopilotListenerWithChannels, createCopilotNodeListener } from "./runtime/endpoints/node.mjs";
3
3
  import "./runtime/node.mjs";
4
- export { NodeCopilotListener, NodeCopilotListenerWithChannels, NodeFetchHandler, createCopilotNodeHandler, createCopilotNodeListener, createNodeFetchHandler };
4
+ export { NodeCopilotListener, NodeCopilotListenerWithChannels, NodeFetchHandler, createCopilotNodeHandler, createCopilotNodeListener };
package/dist/node.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { createCopilotNodeHandler, createNodeFetchHandler } from "./runtime/endpoints/node-fetch-handler.mjs";
1
+ import { createCopilotNodeHandler } from "./runtime/endpoints/node-fetch-handler.mjs";
2
2
  import { createCopilotNodeListener } from "./runtime/endpoints/node.mjs";
3
3
 
4
- export { createCopilotNodeHandler, createCopilotNodeListener, createNodeFetchHandler };
4
+ export { createCopilotNodeHandler, createCopilotNodeListener };
@@ -1,7 +1,7 @@
1
1
 
2
2
  //#region src/runtime/core/package-info.ts
3
3
  const RUNTIME_PACKAGE_NAME = "@copilotkit/runtime";
4
- const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.6";
4
+ const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.7";
5
5
 
6
6
  //#endregion
7
7
  exports.RUNTIME_PACKAGE_NAME = RUNTIME_PACKAGE_NAME;
@@ -1,6 +1,6 @@
1
1
  //#region src/runtime/core/package-info.ts
2
2
  const RUNTIME_PACKAGE_NAME = "@copilotkit/runtime";
3
- const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.6";
3
+ const RUNTIME_PACKAGE_VERSION = "2.0.0-rc.7";
4
4
 
5
5
  //#endregion
6
6
  export { RUNTIME_PACKAGE_NAME, RUNTIME_PACKAGE_VERSION };
@@ -22,8 +22,6 @@ function createCopilotNodeHandler(handler) {
22
22
  }
23
23
  };
24
24
  }
25
- /** @deprecated Use `createCopilotNodeHandler` instead. */
26
- const createNodeFetchHandler = createCopilotNodeHandler;
27
25
  /**
28
26
  * Build a Fetch Request from a Node IncomingMessage whose body stream has
29
27
  * already been consumed by a body parser.
@@ -71,5 +69,4 @@ function synthesizeBody(body) {
71
69
 
72
70
  //#endregion
73
71
  exports.createCopilotNodeHandler = createCopilotNodeHandler;
74
- exports.createNodeFetchHandler = createNodeFetchHandler;
75
72
  //# sourceMappingURL=node-fetch-handler.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-fetch-handler.cjs","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"sourcesContent":["/**\n * Generic Node ↔ Fetch bridge for CopilotKit runtime.\n *\n * Wraps a `CopilotRuntimeFetchHandler` as a Node HTTP handler using\n * `@remix-run/node-fetch-server` for reliable streaming and conversion.\n *\n * When body-parsing middleware (Express `express.json()`, NestJS's default\n * parser, …) runs first, the Node request stream is already consumed and\n * `req.body` holds the parsed content. Reading the exhausted stream would hang,\n * so that case re-serialises `req.body` into the Fetch `Request` instead.\n *\n * @example\n * ```typescript\n * import { createServer } from \"node:http\";\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime\";\n * import { createCopilotNodeHandler } from \"@copilotkit/runtime/node\";\n *\n * const handler = createCopilotRuntimeHandler({ runtime, basePath: \"/api/copilotkit\", cors: true });\n * const nodeHandler = createCopilotNodeHandler(handler);\n * createServer(nodeHandler).listen(3000);\n * ```\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport {\n createHeaders,\n createRequest,\n sendResponse,\n} from \"@remix-run/node-fetch-server\";\nimport type { CopilotRuntimeFetchHandler } from \"../core/fetch-handler\";\nimport { logger } from \"@copilotkit/shared\";\n\nconst METHODS_WITHOUT_BODY = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\nexport type NodeFetchHandler = (\n req: IncomingMessage,\n res: ServerResponse,\n) => Promise<void>;\n\nexport function createCopilotNodeHandler(\n handler: CopilotRuntimeFetchHandler,\n): NodeFetchHandler {\n return async (req: IncomingMessage, res: ServerResponse) => {\n try {\n const method = (req.method ?? \"GET\").toUpperCase();\n const fetchReq =\n !METHODS_WITHOUT_BODY.has(method) && hasPreParsedBody(req)\n ? buildPreParsedRequest(req, res)\n : createRequest(req, res);\n const fetchRes = await handler(fetchReq);\n await sendResponse(res, fetchRes);\n } catch (err: unknown) {\n logger.error({ err }, \"Error in Node fetch handler\");\n if (!res.headersSent) {\n res.statusCode = 500;\n res.end(\"Internal Server Error\");\n }\n }\n };\n}\n\n/** @deprecated Use `createCopilotNodeHandler` instead. */\nexport const createNodeFetchHandler = createCopilotNodeHandler;\n\n/**\n * Build a Fetch Request from a Node IncomingMessage whose body stream has\n * already been consumed by a body parser.\n *\n * The URL, headers and abort wiring match `createRequest` (the streaming path),\n * so a request routes the same way whether or not a parser ran first. In\n * particular the URL comes from `req.url`, which is what a mounting router\n * matched against; `originalUrl` still carries the mount prefix and would miss\n * the handler's `basePath`.\n */\nfunction buildPreParsedRequest(\n req: IncomingMessage & { body?: unknown },\n res: ServerResponse,\n): Request {\n const method = (req.method ?? \"GET\").toUpperCase();\n const headers = createHeaders(req);\n const protocol =\n \"encrypted\" in req.socket && req.socket.encrypted ? \"https:\" : \"http:\";\n const host = headers.get(\"host\") ?? \"localhost\";\n const url = new URL(req.url ?? \"/\", `${protocol}//${host}`);\n\n // Wire an AbortSignal so client disconnects propagate to the fetch handler\n const controller = new AbortController();\n res.on(\"close\", () => {\n if (!res.writableFinished) controller.abort();\n });\n\n const init: RequestInit = {\n method,\n headers,\n signal: controller.signal,\n };\n\n const { body, contentType } = synthesizeBody(req.body);\n if (contentType) {\n headers.set(\"content-type\", contentType);\n }\n headers.delete(\"content-length\");\n if (body !== undefined) {\n init.body = body;\n }\n\n return new Request(url, init);\n}\n\nfunction hasPreParsedBody(req: IncomingMessage & { body?: unknown }): boolean {\n if (req.body === undefined || req.body === null) return false;\n\n // Only `readableEnded` means \"a parser drained this stream to its end\".\n // `req.complete` and the private `_readableState.ended` are set by the HTTP\n // parser once the socket has all the bytes, whether or not anything read them.\n //\n // That distinction matters because `req.body` being set does not prove a parser\n // ran: body-parser 1.x (Express 4) assigns `req.body = req.body || {}` before\n // its own content-type checks, so a request it declines to parse — multipart\n // upload, text/plain — reaches us with `req.body === {}` and a full, unread\n // stream. Treating that as pre-parsed rebuilt the request from `{}` and\n // dropped the real payload.\n return Boolean(req.readableEnded);\n}\n\nfunction synthesizeBody(body: unknown): {\n body?: BodyInit;\n contentType?: string;\n} {\n if (Buffer.isBuffer(body) || body instanceof Uint8Array) {\n // Buffer/Uint8Array<ArrayBufferLike> are valid fetch bodies at runtime,\n // but the DOM lib's BodyInit only admits ArrayBuffer-backed views.\n return { body: body as BodyInit };\n }\n if (typeof body === \"string\") {\n return { body };\n }\n if (typeof body === \"object\" && body !== null) {\n return { body: JSON.stringify(body), contentType: \"application/json\" };\n }\n return {};\n}\n"],"mappings":";;;;;AAgCA,MAAM,uBAAuB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAU,CAAC;AAOhE,SAAgB,yBACd,SACkB;AAClB,QAAO,OAAO,KAAsB,QAAwB;AAC1D,MAAI;GACF,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;AAMlD,wDAAmB,KADF,MAAM,QAHrB,CAAC,qBAAqB,IAAI,OAAO,IAAI,iBAAiB,IAAI,GACtD,sBAAsB,KAAK,IAAI,mDACjB,KAAK,IAAI,CACW,CACP;WAC1B,KAAc;AACrB,6BAAO,MAAM,EAAE,KAAK,EAAE,8BAA8B;AACpD,OAAI,CAAC,IAAI,aAAa;AACpB,QAAI,aAAa;AACjB,QAAI,IAAI,wBAAwB;;;;;;AAOxC,MAAa,yBAAyB;;;;;;;;;;;AAYtC,SAAS,sBACP,KACA,KACS;CACT,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;CAClD,MAAM,0DAAwB,IAAI;CAClC,MAAM,WACJ,eAAe,IAAI,UAAU,IAAI,OAAO,YAAY,WAAW;CACjE,MAAM,OAAO,QAAQ,IAAI,OAAO,IAAI;CACpC,MAAM,MAAM,IAAI,IAAI,IAAI,OAAO,KAAK,GAAG,SAAS,IAAI,OAAO;CAG3D,MAAM,aAAa,IAAI,iBAAiB;AACxC,KAAI,GAAG,eAAe;AACpB,MAAI,CAAC,IAAI,iBAAkB,YAAW,OAAO;GAC7C;CAEF,MAAM,OAAoB;EACxB;EACA;EACA,QAAQ,WAAW;EACpB;CAED,MAAM,EAAE,MAAM,gBAAgB,eAAe,IAAI,KAAK;AACtD,KAAI,YACF,SAAQ,IAAI,gBAAgB,YAAY;AAE1C,SAAQ,OAAO,iBAAiB;AAChC,KAAI,SAAS,OACX,MAAK,OAAO;AAGd,QAAO,IAAI,QAAQ,KAAK,KAAK;;AAG/B,SAAS,iBAAiB,KAAoD;AAC5E,KAAI,IAAI,SAAS,UAAa,IAAI,SAAS,KAAM,QAAO;AAYxD,QAAO,QAAQ,IAAI,cAAc;;AAGnC,SAAS,eAAe,MAGtB;AACA,KAAI,OAAO,SAAS,KAAK,IAAI,gBAAgB,WAG3C,QAAO,EAAQ,MAAkB;AAEnC,KAAI,OAAO,SAAS,SAClB,QAAO,EAAE,MAAM;AAEjB,KAAI,OAAO,SAAS,YAAY,SAAS,KACvC,QAAO;EAAE,MAAM,KAAK,UAAU,KAAK;EAAE,aAAa;EAAoB;AAExE,QAAO,EAAE"}
1
+ {"version":3,"file":"node-fetch-handler.cjs","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"sourcesContent":["/**\n * Generic Node ↔ Fetch bridge for CopilotKit runtime.\n *\n * Wraps a `CopilotRuntimeFetchHandler` as a Node HTTP handler using\n * `@remix-run/node-fetch-server` for reliable streaming and conversion.\n *\n * When body-parsing middleware (Express `express.json()`, NestJS's default\n * parser, …) runs first, the Node request stream is already consumed and\n * `req.body` holds the parsed content. Reading the exhausted stream would hang,\n * so that case re-serialises `req.body` into the Fetch `Request` instead.\n *\n * @example\n * ```typescript\n * import { createServer } from \"node:http\";\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime\";\n * import { createCopilotNodeHandler } from \"@copilotkit/runtime/node\";\n *\n * const handler = createCopilotRuntimeHandler({ runtime, basePath: \"/api/copilotkit\", cors: true });\n * const nodeHandler = createCopilotNodeHandler(handler);\n * createServer(nodeHandler).listen(3000);\n * ```\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport {\n createHeaders,\n createRequest,\n sendResponse,\n} from \"@remix-run/node-fetch-server\";\nimport type { CopilotRuntimeFetchHandler } from \"../core/fetch-handler\";\nimport { logger } from \"@copilotkit/shared\";\n\nconst METHODS_WITHOUT_BODY = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\nexport type NodeFetchHandler = (\n req: IncomingMessage,\n res: ServerResponse,\n) => Promise<void>;\n\nexport function createCopilotNodeHandler(\n handler: CopilotRuntimeFetchHandler,\n): NodeFetchHandler {\n return async (req: IncomingMessage, res: ServerResponse) => {\n try {\n const method = (req.method ?? \"GET\").toUpperCase();\n const fetchReq =\n !METHODS_WITHOUT_BODY.has(method) && hasPreParsedBody(req)\n ? buildPreParsedRequest(req, res)\n : createRequest(req, res);\n const fetchRes = await handler(fetchReq);\n await sendResponse(res, fetchRes);\n } catch (err: unknown) {\n logger.error({ err }, \"Error in Node fetch handler\");\n if (!res.headersSent) {\n res.statusCode = 500;\n res.end(\"Internal Server Error\");\n }\n }\n };\n}\n\n/**\n * Build a Fetch Request from a Node IncomingMessage whose body stream has\n * already been consumed by a body parser.\n *\n * The URL, headers and abort wiring match `createRequest` (the streaming path),\n * so a request routes the same way whether or not a parser ran first. In\n * particular the URL comes from `req.url`, which is what a mounting router\n * matched against; `originalUrl` still carries the mount prefix and would miss\n * the handler's `basePath`.\n */\nfunction buildPreParsedRequest(\n req: IncomingMessage & { body?: unknown },\n res: ServerResponse,\n): Request {\n const method = (req.method ?? \"GET\").toUpperCase();\n const headers = createHeaders(req);\n const protocol =\n \"encrypted\" in req.socket && req.socket.encrypted ? \"https:\" : \"http:\";\n const host = headers.get(\"host\") ?? \"localhost\";\n const url = new URL(req.url ?? \"/\", `${protocol}//${host}`);\n\n // Wire an AbortSignal so client disconnects propagate to the fetch handler\n const controller = new AbortController();\n res.on(\"close\", () => {\n if (!res.writableFinished) controller.abort();\n });\n\n const init: RequestInit = {\n method,\n headers,\n signal: controller.signal,\n };\n\n const { body, contentType } = synthesizeBody(req.body);\n if (contentType) {\n headers.set(\"content-type\", contentType);\n }\n headers.delete(\"content-length\");\n if (body !== undefined) {\n init.body = body;\n }\n\n return new Request(url, init);\n}\n\nfunction hasPreParsedBody(req: IncomingMessage & { body?: unknown }): boolean {\n if (req.body === undefined || req.body === null) return false;\n\n // Only `readableEnded` means \"a parser drained this stream to its end\".\n // `req.complete` and the private `_readableState.ended` are set by the HTTP\n // parser once the socket has all the bytes, whether or not anything read them.\n //\n // That distinction matters because `req.body` being set does not prove a parser\n // ran: body-parser 1.x (Express 4) assigns `req.body = req.body || {}` before\n // its own content-type checks, so a request it declines to parse — multipart\n // upload, text/plain — reaches us with `req.body === {}` and a full, unread\n // stream. Treating that as pre-parsed rebuilt the request from `{}` and\n // dropped the real payload.\n return Boolean(req.readableEnded);\n}\n\nfunction synthesizeBody(body: unknown): {\n body?: BodyInit;\n contentType?: string;\n} {\n if (Buffer.isBuffer(body) || body instanceof Uint8Array) {\n // Buffer/Uint8Array<ArrayBufferLike> are valid fetch bodies at runtime,\n // but the DOM lib's BodyInit only admits ArrayBuffer-backed views.\n return { body: body as BodyInit };\n }\n if (typeof body === \"string\") {\n return { body };\n }\n if (typeof body === \"object\" && body !== null) {\n return { body: JSON.stringify(body), contentType: \"application/json\" };\n }\n return {};\n}\n"],"mappings":";;;;;AAgCA,MAAM,uBAAuB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAU,CAAC;AAOhE,SAAgB,yBACd,SACkB;AAClB,QAAO,OAAO,KAAsB,QAAwB;AAC1D,MAAI;GACF,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;AAMlD,wDAAmB,KADF,MAAM,QAHrB,CAAC,qBAAqB,IAAI,OAAO,IAAI,iBAAiB,IAAI,GACtD,sBAAsB,KAAK,IAAI,mDACjB,KAAK,IAAI,CACW,CACP;WAC1B,KAAc;AACrB,6BAAO,MAAM,EAAE,KAAK,EAAE,8BAA8B;AACpD,OAAI,CAAC,IAAI,aAAa;AACpB,QAAI,aAAa;AACjB,QAAI,IAAI,wBAAwB;;;;;;;;;;;;;;;AAgBxC,SAAS,sBACP,KACA,KACS;CACT,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;CAClD,MAAM,0DAAwB,IAAI;CAClC,MAAM,WACJ,eAAe,IAAI,UAAU,IAAI,OAAO,YAAY,WAAW;CACjE,MAAM,OAAO,QAAQ,IAAI,OAAO,IAAI;CACpC,MAAM,MAAM,IAAI,IAAI,IAAI,OAAO,KAAK,GAAG,SAAS,IAAI,OAAO;CAG3D,MAAM,aAAa,IAAI,iBAAiB;AACxC,KAAI,GAAG,eAAe;AACpB,MAAI,CAAC,IAAI,iBAAkB,YAAW,OAAO;GAC7C;CAEF,MAAM,OAAoB;EACxB;EACA;EACA,QAAQ,WAAW;EACpB;CAED,MAAM,EAAE,MAAM,gBAAgB,eAAe,IAAI,KAAK;AACtD,KAAI,YACF,SAAQ,IAAI,gBAAgB,YAAY;AAE1C,SAAQ,OAAO,iBAAiB;AAChC,KAAI,SAAS,OACX,MAAK,OAAO;AAGd,QAAO,IAAI,QAAQ,KAAK,KAAK;;AAG/B,SAAS,iBAAiB,KAAoD;AAC5E,KAAI,IAAI,SAAS,UAAa,IAAI,SAAS,KAAM,QAAO;AAYxD,QAAO,QAAQ,IAAI,cAAc;;AAGnC,SAAS,eAAe,MAGtB;AACA,KAAI,OAAO,SAAS,KAAK,IAAI,gBAAgB,WAG3C,QAAO,EAAQ,MAAkB;AAEnC,KAAI,OAAO,SAAS,SAClB,QAAO,EAAE,MAAM;AAEjB,KAAI,OAAO,SAAS,YAAY,SAAS,KACvC,QAAO;EAAE,MAAM,KAAK,UAAU,KAAK;EAAE,aAAa;EAAoB;AAExE,QAAO,EAAE"}
@@ -4,8 +4,6 @@ import { IncomingMessage, ServerResponse } from "node:http";
4
4
  //#region src/runtime/endpoints/node-fetch-handler.d.ts
5
5
  type NodeFetchHandler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
6
6
  declare function createCopilotNodeHandler(handler: CopilotRuntimeFetchHandler): NodeFetchHandler;
7
- /** @deprecated Use `createCopilotNodeHandler` instead. */
8
- declare const createNodeFetchHandler: typeof createCopilotNodeHandler;
9
7
  //#endregion
10
- export { NodeFetchHandler, createCopilotNodeHandler, createNodeFetchHandler };
8
+ export { NodeFetchHandler, createCopilotNodeHandler };
11
9
  //# sourceMappingURL=node-fetch-handler.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-fetch-handler.d.cts","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"mappings":";;;;KAkCY,gBAAA,IACV,GAAA,EAAK,eAAA,EACL,GAAA,EAAK,cAAA,KACF,OAAA;AAAA,iBAEW,wBAAA,CACd,OAAA,EAAS,0BAAA,GACR,gBAAA;;cAqBU,sBAAA,SAAsB,wBAAA"}
1
+ {"version":3,"file":"node-fetch-handler.d.cts","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"mappings":";;;;KAkCY,gBAAA,IACV,GAAA,EAAK,eAAA,EACL,GAAA,EAAK,cAAA,KACF,OAAA;AAAA,iBAEW,wBAAA,CACd,OAAA,EAAS,0BAAA,GACR,gBAAA"}
@@ -4,8 +4,6 @@ import { IncomingMessage, ServerResponse } from "node:http";
4
4
  //#region src/runtime/endpoints/node-fetch-handler.d.ts
5
5
  type NodeFetchHandler = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
6
6
  declare function createCopilotNodeHandler(handler: CopilotRuntimeFetchHandler): NodeFetchHandler;
7
- /** @deprecated Use `createCopilotNodeHandler` instead. */
8
- declare const createNodeFetchHandler: typeof createCopilotNodeHandler;
9
7
  //#endregion
10
- export { NodeFetchHandler, createCopilotNodeHandler, createNodeFetchHandler };
8
+ export { NodeFetchHandler, createCopilotNodeHandler };
11
9
  //# sourceMappingURL=node-fetch-handler.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-fetch-handler.d.mts","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"mappings":";;;;KAkCY,gBAAA,IACV,GAAA,EAAK,eAAA,EACL,GAAA,EAAK,cAAA,KACF,OAAA;AAAA,iBAEW,wBAAA,CACd,OAAA,EAAS,0BAAA,GACR,gBAAA;;cAqBU,sBAAA,SAAsB,wBAAA"}
1
+ {"version":3,"file":"node-fetch-handler.d.mts","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"mappings":";;;;KAkCY,gBAAA,IACV,GAAA,EAAK,eAAA,EACL,GAAA,EAAK,cAAA,KACF,OAAA;AAAA,iBAEW,wBAAA,CACd,OAAA,EAAS,0BAAA,GACR,gBAAA"}
@@ -21,8 +21,6 @@ function createCopilotNodeHandler(handler) {
21
21
  }
22
22
  };
23
23
  }
24
- /** @deprecated Use `createCopilotNodeHandler` instead. */
25
- const createNodeFetchHandler = createCopilotNodeHandler;
26
24
  /**
27
25
  * Build a Fetch Request from a Node IncomingMessage whose body stream has
28
26
  * already been consumed by a body parser.
@@ -69,5 +67,5 @@ function synthesizeBody(body) {
69
67
  }
70
68
 
71
69
  //#endregion
72
- export { createCopilotNodeHandler, createNodeFetchHandler };
70
+ export { createCopilotNodeHandler };
73
71
  //# sourceMappingURL=node-fetch-handler.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"node-fetch-handler.mjs","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"sourcesContent":["/**\n * Generic Node ↔ Fetch bridge for CopilotKit runtime.\n *\n * Wraps a `CopilotRuntimeFetchHandler` as a Node HTTP handler using\n * `@remix-run/node-fetch-server` for reliable streaming and conversion.\n *\n * When body-parsing middleware (Express `express.json()`, NestJS's default\n * parser, …) runs first, the Node request stream is already consumed and\n * `req.body` holds the parsed content. Reading the exhausted stream would hang,\n * so that case re-serialises `req.body` into the Fetch `Request` instead.\n *\n * @example\n * ```typescript\n * import { createServer } from \"node:http\";\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime\";\n * import { createCopilotNodeHandler } from \"@copilotkit/runtime/node\";\n *\n * const handler = createCopilotRuntimeHandler({ runtime, basePath: \"/api/copilotkit\", cors: true });\n * const nodeHandler = createCopilotNodeHandler(handler);\n * createServer(nodeHandler).listen(3000);\n * ```\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport {\n createHeaders,\n createRequest,\n sendResponse,\n} from \"@remix-run/node-fetch-server\";\nimport type { CopilotRuntimeFetchHandler } from \"../core/fetch-handler\";\nimport { logger } from \"@copilotkit/shared\";\n\nconst METHODS_WITHOUT_BODY = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\nexport type NodeFetchHandler = (\n req: IncomingMessage,\n res: ServerResponse,\n) => Promise<void>;\n\nexport function createCopilotNodeHandler(\n handler: CopilotRuntimeFetchHandler,\n): NodeFetchHandler {\n return async (req: IncomingMessage, res: ServerResponse) => {\n try {\n const method = (req.method ?? \"GET\").toUpperCase();\n const fetchReq =\n !METHODS_WITHOUT_BODY.has(method) && hasPreParsedBody(req)\n ? buildPreParsedRequest(req, res)\n : createRequest(req, res);\n const fetchRes = await handler(fetchReq);\n await sendResponse(res, fetchRes);\n } catch (err: unknown) {\n logger.error({ err }, \"Error in Node fetch handler\");\n if (!res.headersSent) {\n res.statusCode = 500;\n res.end(\"Internal Server Error\");\n }\n }\n };\n}\n\n/** @deprecated Use `createCopilotNodeHandler` instead. */\nexport const createNodeFetchHandler = createCopilotNodeHandler;\n\n/**\n * Build a Fetch Request from a Node IncomingMessage whose body stream has\n * already been consumed by a body parser.\n *\n * The URL, headers and abort wiring match `createRequest` (the streaming path),\n * so a request routes the same way whether or not a parser ran first. In\n * particular the URL comes from `req.url`, which is what a mounting router\n * matched against; `originalUrl` still carries the mount prefix and would miss\n * the handler's `basePath`.\n */\nfunction buildPreParsedRequest(\n req: IncomingMessage & { body?: unknown },\n res: ServerResponse,\n): Request {\n const method = (req.method ?? \"GET\").toUpperCase();\n const headers = createHeaders(req);\n const protocol =\n \"encrypted\" in req.socket && req.socket.encrypted ? \"https:\" : \"http:\";\n const host = headers.get(\"host\") ?? \"localhost\";\n const url = new URL(req.url ?? \"/\", `${protocol}//${host}`);\n\n // Wire an AbortSignal so client disconnects propagate to the fetch handler\n const controller = new AbortController();\n res.on(\"close\", () => {\n if (!res.writableFinished) controller.abort();\n });\n\n const init: RequestInit = {\n method,\n headers,\n signal: controller.signal,\n };\n\n const { body, contentType } = synthesizeBody(req.body);\n if (contentType) {\n headers.set(\"content-type\", contentType);\n }\n headers.delete(\"content-length\");\n if (body !== undefined) {\n init.body = body;\n }\n\n return new Request(url, init);\n}\n\nfunction hasPreParsedBody(req: IncomingMessage & { body?: unknown }): boolean {\n if (req.body === undefined || req.body === null) return false;\n\n // Only `readableEnded` means \"a parser drained this stream to its end\".\n // `req.complete` and the private `_readableState.ended` are set by the HTTP\n // parser once the socket has all the bytes, whether or not anything read them.\n //\n // That distinction matters because `req.body` being set does not prove a parser\n // ran: body-parser 1.x (Express 4) assigns `req.body = req.body || {}` before\n // its own content-type checks, so a request it declines to parse — multipart\n // upload, text/plain — reaches us with `req.body === {}` and a full, unread\n // stream. Treating that as pre-parsed rebuilt the request from `{}` and\n // dropped the real payload.\n return Boolean(req.readableEnded);\n}\n\nfunction synthesizeBody(body: unknown): {\n body?: BodyInit;\n contentType?: string;\n} {\n if (Buffer.isBuffer(body) || body instanceof Uint8Array) {\n // Buffer/Uint8Array<ArrayBufferLike> are valid fetch bodies at runtime,\n // but the DOM lib's BodyInit only admits ArrayBuffer-backed views.\n return { body: body as BodyInit };\n }\n if (typeof body === \"string\") {\n return { body };\n }\n if (typeof body === \"object\" && body !== null) {\n return { body: JSON.stringify(body), contentType: \"application/json\" };\n }\n return {};\n}\n"],"mappings":";;;;AAgCA,MAAM,uBAAuB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAU,CAAC;AAOhE,SAAgB,yBACd,SACkB;AAClB,QAAO,OAAO,KAAsB,QAAwB;AAC1D,MAAI;GACF,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;AAMlD,SAAM,aAAa,KADF,MAAM,QAHrB,CAAC,qBAAqB,IAAI,OAAO,IAAI,iBAAiB,IAAI,GACtD,sBAAsB,KAAK,IAAI,GAC/B,cAAc,KAAK,IAAI,CACW,CACP;WAC1B,KAAc;AACrB,UAAO,MAAM,EAAE,KAAK,EAAE,8BAA8B;AACpD,OAAI,CAAC,IAAI,aAAa;AACpB,QAAI,aAAa;AACjB,QAAI,IAAI,wBAAwB;;;;;;AAOxC,MAAa,yBAAyB;;;;;;;;;;;AAYtC,SAAS,sBACP,KACA,KACS;CACT,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;CAClD,MAAM,UAAU,cAAc,IAAI;CAClC,MAAM,WACJ,eAAe,IAAI,UAAU,IAAI,OAAO,YAAY,WAAW;CACjE,MAAM,OAAO,QAAQ,IAAI,OAAO,IAAI;CACpC,MAAM,MAAM,IAAI,IAAI,IAAI,OAAO,KAAK,GAAG,SAAS,IAAI,OAAO;CAG3D,MAAM,aAAa,IAAI,iBAAiB;AACxC,KAAI,GAAG,eAAe;AACpB,MAAI,CAAC,IAAI,iBAAkB,YAAW,OAAO;GAC7C;CAEF,MAAM,OAAoB;EACxB;EACA;EACA,QAAQ,WAAW;EACpB;CAED,MAAM,EAAE,MAAM,gBAAgB,eAAe,IAAI,KAAK;AACtD,KAAI,YACF,SAAQ,IAAI,gBAAgB,YAAY;AAE1C,SAAQ,OAAO,iBAAiB;AAChC,KAAI,SAAS,OACX,MAAK,OAAO;AAGd,QAAO,IAAI,QAAQ,KAAK,KAAK;;AAG/B,SAAS,iBAAiB,KAAoD;AAC5E,KAAI,IAAI,SAAS,UAAa,IAAI,SAAS,KAAM,QAAO;AAYxD,QAAO,QAAQ,IAAI,cAAc;;AAGnC,SAAS,eAAe,MAGtB;AACA,KAAI,OAAO,SAAS,KAAK,IAAI,gBAAgB,WAG3C,QAAO,EAAQ,MAAkB;AAEnC,KAAI,OAAO,SAAS,SAClB,QAAO,EAAE,MAAM;AAEjB,KAAI,OAAO,SAAS,YAAY,SAAS,KACvC,QAAO;EAAE,MAAM,KAAK,UAAU,KAAK;EAAE,aAAa;EAAoB;AAExE,QAAO,EAAE"}
1
+ {"version":3,"file":"node-fetch-handler.mjs","names":[],"sources":["../../../src/runtime/endpoints/node-fetch-handler.ts"],"sourcesContent":["/**\n * Generic Node ↔ Fetch bridge for CopilotKit runtime.\n *\n * Wraps a `CopilotRuntimeFetchHandler` as a Node HTTP handler using\n * `@remix-run/node-fetch-server` for reliable streaming and conversion.\n *\n * When body-parsing middleware (Express `express.json()`, NestJS's default\n * parser, …) runs first, the Node request stream is already consumed and\n * `req.body` holds the parsed content. Reading the exhausted stream would hang,\n * so that case re-serialises `req.body` into the Fetch `Request` instead.\n *\n * @example\n * ```typescript\n * import { createServer } from \"node:http\";\n * import { createCopilotRuntimeHandler } from \"@copilotkit/runtime\";\n * import { createCopilotNodeHandler } from \"@copilotkit/runtime/node\";\n *\n * const handler = createCopilotRuntimeHandler({ runtime, basePath: \"/api/copilotkit\", cors: true });\n * const nodeHandler = createCopilotNodeHandler(handler);\n * createServer(nodeHandler).listen(3000);\n * ```\n */\n\nimport type { IncomingMessage, ServerResponse } from \"node:http\";\nimport {\n createHeaders,\n createRequest,\n sendResponse,\n} from \"@remix-run/node-fetch-server\";\nimport type { CopilotRuntimeFetchHandler } from \"../core/fetch-handler\";\nimport { logger } from \"@copilotkit/shared\";\n\nconst METHODS_WITHOUT_BODY = new Set([\"GET\", \"HEAD\", \"OPTIONS\"]);\n\nexport type NodeFetchHandler = (\n req: IncomingMessage,\n res: ServerResponse,\n) => Promise<void>;\n\nexport function createCopilotNodeHandler(\n handler: CopilotRuntimeFetchHandler,\n): NodeFetchHandler {\n return async (req: IncomingMessage, res: ServerResponse) => {\n try {\n const method = (req.method ?? \"GET\").toUpperCase();\n const fetchReq =\n !METHODS_WITHOUT_BODY.has(method) && hasPreParsedBody(req)\n ? buildPreParsedRequest(req, res)\n : createRequest(req, res);\n const fetchRes = await handler(fetchReq);\n await sendResponse(res, fetchRes);\n } catch (err: unknown) {\n logger.error({ err }, \"Error in Node fetch handler\");\n if (!res.headersSent) {\n res.statusCode = 500;\n res.end(\"Internal Server Error\");\n }\n }\n };\n}\n\n/**\n * Build a Fetch Request from a Node IncomingMessage whose body stream has\n * already been consumed by a body parser.\n *\n * The URL, headers and abort wiring match `createRequest` (the streaming path),\n * so a request routes the same way whether or not a parser ran first. In\n * particular the URL comes from `req.url`, which is what a mounting router\n * matched against; `originalUrl` still carries the mount prefix and would miss\n * the handler's `basePath`.\n */\nfunction buildPreParsedRequest(\n req: IncomingMessage & { body?: unknown },\n res: ServerResponse,\n): Request {\n const method = (req.method ?? \"GET\").toUpperCase();\n const headers = createHeaders(req);\n const protocol =\n \"encrypted\" in req.socket && req.socket.encrypted ? \"https:\" : \"http:\";\n const host = headers.get(\"host\") ?? \"localhost\";\n const url = new URL(req.url ?? \"/\", `${protocol}//${host}`);\n\n // Wire an AbortSignal so client disconnects propagate to the fetch handler\n const controller = new AbortController();\n res.on(\"close\", () => {\n if (!res.writableFinished) controller.abort();\n });\n\n const init: RequestInit = {\n method,\n headers,\n signal: controller.signal,\n };\n\n const { body, contentType } = synthesizeBody(req.body);\n if (contentType) {\n headers.set(\"content-type\", contentType);\n }\n headers.delete(\"content-length\");\n if (body !== undefined) {\n init.body = body;\n }\n\n return new Request(url, init);\n}\n\nfunction hasPreParsedBody(req: IncomingMessage & { body?: unknown }): boolean {\n if (req.body === undefined || req.body === null) return false;\n\n // Only `readableEnded` means \"a parser drained this stream to its end\".\n // `req.complete` and the private `_readableState.ended` are set by the HTTP\n // parser once the socket has all the bytes, whether or not anything read them.\n //\n // That distinction matters because `req.body` being set does not prove a parser\n // ran: body-parser 1.x (Express 4) assigns `req.body = req.body || {}` before\n // its own content-type checks, so a request it declines to parse — multipart\n // upload, text/plain — reaches us with `req.body === {}` and a full, unread\n // stream. Treating that as pre-parsed rebuilt the request from `{}` and\n // dropped the real payload.\n return Boolean(req.readableEnded);\n}\n\nfunction synthesizeBody(body: unknown): {\n body?: BodyInit;\n contentType?: string;\n} {\n if (Buffer.isBuffer(body) || body instanceof Uint8Array) {\n // Buffer/Uint8Array<ArrayBufferLike> are valid fetch bodies at runtime,\n // but the DOM lib's BodyInit only admits ArrayBuffer-backed views.\n return { body: body as BodyInit };\n }\n if (typeof body === \"string\") {\n return { body };\n }\n if (typeof body === \"object\" && body !== null) {\n return { body: JSON.stringify(body), contentType: \"application/json\" };\n }\n return {};\n}\n"],"mappings":";;;;AAgCA,MAAM,uBAAuB,IAAI,IAAI;CAAC;CAAO;CAAQ;CAAU,CAAC;AAOhE,SAAgB,yBACd,SACkB;AAClB,QAAO,OAAO,KAAsB,QAAwB;AAC1D,MAAI;GACF,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;AAMlD,SAAM,aAAa,KADF,MAAM,QAHrB,CAAC,qBAAqB,IAAI,OAAO,IAAI,iBAAiB,IAAI,GACtD,sBAAsB,KAAK,IAAI,GAC/B,cAAc,KAAK,IAAI,CACW,CACP;WAC1B,KAAc;AACrB,UAAO,MAAM,EAAE,KAAK,EAAE,8BAA8B;AACpD,OAAI,CAAC,IAAI,aAAa;AACpB,QAAI,aAAa;AACjB,QAAI,IAAI,wBAAwB;;;;;;;;;;;;;;;AAgBxC,SAAS,sBACP,KACA,KACS;CACT,MAAM,UAAU,IAAI,UAAU,OAAO,aAAa;CAClD,MAAM,UAAU,cAAc,IAAI;CAClC,MAAM,WACJ,eAAe,IAAI,UAAU,IAAI,OAAO,YAAY,WAAW;CACjE,MAAM,OAAO,QAAQ,IAAI,OAAO,IAAI;CACpC,MAAM,MAAM,IAAI,IAAI,IAAI,OAAO,KAAK,GAAG,SAAS,IAAI,OAAO;CAG3D,MAAM,aAAa,IAAI,iBAAiB;AACxC,KAAI,GAAG,eAAe;AACpB,MAAI,CAAC,IAAI,iBAAkB,YAAW,OAAO;GAC7C;CAEF,MAAM,OAAoB;EACxB;EACA;EACA,QAAQ,WAAW;EACpB;CAED,MAAM,EAAE,MAAM,gBAAgB,eAAe,IAAI,KAAK;AACtD,KAAI,YACF,SAAQ,IAAI,gBAAgB,YAAY;AAE1C,SAAQ,OAAO,iBAAiB;AAChC,KAAI,SAAS,OACX,MAAK,OAAO;AAGd,QAAO,IAAI,QAAQ,KAAK,KAAK;;AAG/B,SAAS,iBAAiB,KAAoD;AAC5E,KAAI,IAAI,SAAS,UAAa,IAAI,SAAS,KAAM,QAAO;AAYxD,QAAO,QAAQ,IAAI,cAAc;;AAGnC,SAAS,eAAe,MAGtB;AACA,KAAI,OAAO,SAAS,KAAK,IAAI,gBAAgB,WAG3C,QAAO,EAAQ,MAAkB;AAEnC,KAAI,OAAO,SAAS,SAClB,QAAO,EAAE,MAAM;AAEjB,KAAI,OAAO,SAAS,YAAY,SAAS,KACvC,QAAO;EAAE,MAAM,KAAK,UAAU,KAAK;EAAE,aAAa;EAAoB;AAExE,QAAO,EAAE"}
@@ -18,12 +18,4 @@ import { CopilotRuntimeHooks, ErrorHookContext, HandlerHookContext, HookContext,
18
18
  import { CopilotCorsConfig } from "./core/fetch-cors.cjs";
19
19
  import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./core/fetch-handler.cjs";
20
20
  import { MCPClient, MCPTransport } from "@ai-sdk/mcp";
21
-
22
- //#region src/runtime/index.d.ts
23
- /** @deprecated Use `CopilotRuntimeFetchHandler` instead. Note: the new type takes `Request` directly, not `{ request: Request }`. */
24
- type CopilotKitRequestHandler = (params: {
25
- request: Request;
26
- }) => Promise<Response>;
27
- //#endregion
28
- export { CopilotKitRequestHandler, type MCPClient, type MCPTransport };
29
- //# sourceMappingURL=index.d.cts.map
21
+ export { type MCPClient, type MCPTransport };
@@ -18,12 +18,4 @@ import { CopilotRuntimeHooks, ErrorHookContext, HandlerHookContext, HookContext,
18
18
  import { CopilotCorsConfig } from "./core/fetch-cors.mjs";
19
19
  import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./core/fetch-handler.mjs";
20
20
  import { MCPClient, MCPTransport } from "@ai-sdk/mcp";
21
-
22
- //#region src/runtime/index.d.ts
23
- /** @deprecated Use `CopilotRuntimeFetchHandler` instead. Note: the new type takes `Request` directly, not `{ request: Request }`. */
24
- type CopilotKitRequestHandler = (params: {
25
- request: Request;
26
- }) => Promise<Response>;
27
- //#endregion
28
- export { CopilotKitRequestHandler, type MCPClient, type MCPTransport };
29
- //# sourceMappingURL=index.d.mts.map
21
+ export { type MCPClient, type MCPTransport };
@@ -1,2 +1,2 @@
1
- import { NodeFetchHandler, createCopilotNodeHandler, createNodeFetchHandler } from "./endpoints/node-fetch-handler.cjs";
1
+ import { NodeFetchHandler, createCopilotNodeHandler } from "./endpoints/node-fetch-handler.cjs";
2
2
  import { NodeCopilotListener, NodeCopilotListenerWithChannels, createCopilotNodeListener } from "./endpoints/node.cjs";
@@ -1,2 +1,2 @@
1
- import { NodeFetchHandler, createCopilotNodeHandler, createNodeFetchHandler } from "./endpoints/node-fetch-handler.mjs";
1
+ import { NodeFetchHandler, createCopilotNodeHandler } from "./endpoints/node-fetch-handler.mjs";
2
2
  import { NodeCopilotListener, NodeCopilotListenerWithChannels, createCopilotNodeListener } from "./endpoints/node.mjs";
@@ -41,10 +41,6 @@ var TelemetryClient = class {
41
41
  this.licenseToken = resolvedIdentity.licenseToken;
42
42
  this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;
43
43
  }
44
- /** @deprecated Prefer {@link setTelemetryIdentity}. */
45
- setLicenseToken(licenseToken) {
46
- this.setTelemetryIdentity({ licenseToken });
47
- }
48
44
  /** Create an immutable capture scope for one Runtime instance. */
49
45
  createScope(identity) {
50
46
  const resolvedIdentity = this.resolveTelemetryIdentity(identity);
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-client.cjs","names":["lambdaClient","TELEMETRY_EMITTER_V2","TELEMETRY_SURFACE_V2","RUNTIME_PACKAGE_NAME","RUNTIME_PACKAGE_VERSION"],"sources":["../../../src/runtime/telemetry/telemetry-client.ts"],"sourcesContent":["import type { AnalyticsEvents } from \"./events\";\nimport {\n lambdaClient,\n parseAndWarnTelemetryId,\n computeSamplingMeta,\n TELEMETRY_EMITTER_V2,\n TELEMETRY_SURFACE_V2,\n processEnv,\n} from \"@copilotkit/shared\";\nimport {\n RUNTIME_PACKAGE_NAME,\n RUNTIME_PACKAGE_VERSION,\n} from \"../core/package-info\";\nimport { firstNonBlankTelemetryId } from \"./telemetry-identity\";\n\n/** Transport identity and sampling authority resolved for one runtime. */\nexport interface TelemetryIdentity {\n telemetryId?: string;\n licenseToken?: string;\n}\n\n/** Capture-only telemetry client bound to one runtime identity. */\nexport interface TelemetryCapture {\n capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void>;\n}\n\ninterface ResolvedTelemetryIdentity {\n telemetryId: string | null;\n licenseToken: string | null;\n licenseTelemetryId: string | null;\n}\n\nexport function isTelemetryDisabled(): boolean {\n return (\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n processEnv().DO_NOT_TRACK === \"true\" ||\n processEnv().DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n private telemetryDisabled: boolean = false;\n // Opt-down for anonymous events, defaulting to 1: the sink is ours, so a\n // real count beats one extrapolated from a fraction of the population.\n // It stays configurable because it is the cross-SDK lever for reducing or\n // stopping anonymous volume — the Go, Python, Ruby, and .NET runtimes all\n // expose it, and the cross-language conformance suite drives it to 0 to\n // assert silence. Identified callers bypass it.\n private sampleRate: number = 1;\n // EIP / Intelligence license token (Ed25519-signed JWT). Kept separate\n // from standalone identity so the transport receives only the selected\n // identity source.\n private licenseToken: string | null = null;\n // Standalone identity sent as a transport claim. It does not make an\n // event identified.\n private telemetryId: string | null = null;\n // License-derived identity. This client sends every event either way;\n // the id is what sets telemetry_identified on the sampling block, which\n // is how the two populations stay separable downstream.\n private licenseTelemetryId: string | null = null;\n // Properties merged into every event this client sends.\n //\n // For facts about the caller that are true for the whole process rather than\n // for one event: which product is embedding the runtime, for instance. A\n // distribution built on top of this can then be told apart in the existing\n // events instead of sending its own, which is the difference between one\n // extra field and a second pipeline nobody asked for.\n //\n // Sent as `global_properties`, a field of its own, so these stay separable\n // from an event's own properties all the way to the sink.\n //\n // Do not reuse a key an event already sets: the fanout spreads this bag last\n // for `oss.runtime.*`, so a collision resolves in favour of the global and\n // does so silently. Names here should describe the caller, not the call.\n private globalProperties: Record<string, unknown> = {};\n\n constructor({\n telemetryDisabled,\n sampleRate,\n }: {\n telemetryDisabled?: boolean;\n sampleRate?: number;\n } = {}) {\n this.telemetryDisabled = telemetryDisabled || isTelemetryDisabled();\n this.setSampleRate(sampleRate);\n }\n\n private shouldSendEvent() {\n if (this.sampleRate >= 1) return true;\n return Math.random() < this.sampleRate;\n }\n\n /**\n * Add properties carried by every subsequent event.\n *\n * Merged rather than replaced, so two callers setting different fields do not\n * erase each other. Set once at runtime construction in practice; nothing\n * here is per-request.\n */\n setGlobalProperties(properties: Record<string, unknown>) {\n this.globalProperties = { ...this.globalProperties, ...properties };\n }\n\n /** Atomically replace the process-wide telemetry identity. */\n setTelemetryIdentity(identity: TelemetryIdentity): void {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n this.telemetryId = resolvedIdentity.telemetryId;\n this.licenseToken = resolvedIdentity.licenseToken;\n this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;\n }\n\n /** @deprecated Prefer {@link setTelemetryIdentity}. */\n setLicenseToken(licenseToken: string): void {\n this.setTelemetryIdentity({ licenseToken });\n }\n\n /** Create an immutable capture scope for one Runtime instance. */\n createScope(identity: TelemetryIdentity): TelemetryCapture {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n return {\n capture: <K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ) => this.captureWithIdentity(event, properties, resolvedIdentity),\n };\n }\n\n async capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void> {\n return this.captureWithIdentity(event, properties, {\n telemetryId: this.telemetryId,\n licenseToken: this.licenseToken,\n licenseTelemetryId: this.licenseTelemetryId,\n });\n }\n\n private async captureWithIdentity<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n identity: ResolvedTelemetryIdentity,\n ): Promise<void> {\n // Re-read the environment: an opt-out set after import (for example a\n // dotenv call below the imports) must still stop events.\n if (this.telemetryDisabled || isTelemetryDisabled()) return;\n // Nothing is gated at the default rate of 1. A caller who dialled it\n // down means it, and identified callers are exempt either way.\n if (!identity.licenseTelemetryId && !this.shouldSendEvent()) return;\n\n await lambdaClient.send({\n event,\n properties: properties as Record<string, unknown>,\n // Its own field on the wire rather than folded into `properties`, which\n // is what the sink expects: for `oss.runtime.*` the fanout treats\n // `global_properties` as the SDK's pass-through bag and spreads it into\n // the analytics event, and v1's client sends package name and version the\n // same way. Folding it in would work and would put a process-level fact\n // in the per-event slot, where nothing downstream expects to find one.\n // Sampling metadata rides in the same slot, as it does in v1. It\n // reads 1/1 unless a caller dialled the rate down, and is stamped\n // either way: a consumer summing sampleWeight across emitters must\n // not find the field missing on a quarter of the rows, which is the\n // state that made ~24% of runtime volume unweightable (OSS-1017).\n globalProperties: {\n ...this.globalProperties,\n ...computeSamplingMeta({\n telemetryId: identity.licenseTelemetryId,\n sampleRate: this.sampleRate,\n }),\n telemetry_emitter: TELEMETRY_EMITTER_V2,\n // Constant here: a v1 request never reaches this client. The v1\n // entrypoint hands its own capture scope to the V2 runtime it\n // builds, so v1 traffic is emitted by the v1 client and stamped\n // v1 there — which is also what keeps it on the Segment wire.\n telemetry_surface: TELEMETRY_SURFACE_V2,\n // This client has one transport, so the marker is constant here. It\n // is stamped anyway so the property means the same thing on every\n // event whichever client produced it (OSS-1019).\n telemetry_transport: \"lambda\",\n },\n packageName: RUNTIME_PACKAGE_NAME,\n packageVersion: RUNTIME_PACKAGE_VERSION,\n telemetryId: identity.telemetryId ?? undefined,\n licenseToken: identity.licenseToken ?? undefined,\n });\n }\n\n private resolveTelemetryIdentity(\n identity: TelemetryIdentity,\n ): ResolvedTelemetryIdentity {\n const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);\n if (telemetryId !== undefined) {\n return {\n telemetryId,\n licenseToken: null,\n licenseTelemetryId: null,\n };\n }\n\n return {\n telemetryId: null,\n licenseToken: identity.licenseToken ?? null,\n licenseTelemetryId: identity.licenseToken\n ? parseAndWarnTelemetryId(identity.licenseToken)\n : null,\n };\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 1;\n\n if (processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n _sampleRate = parseFloat(processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n // Number.isNaN guards against parseFloat(\"nonsense\") slipping past the\n // range check (all NaN comparisons are false), which would silently\n // drop every anonymous event with no signal.\n if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n }\n}\n\nconst telemetry = new TelemetryClient();\nexport default telemetry;\n"],"mappings":";;;;;AAmCA,SAAgB,sBAA+B;AAC7C,4CACc,CAAC,kCAAkC,8CACnC,CAAC,kCAAkC,2CACnC,CAAC,iBAAiB,8CAClB,CAAC,iBAAiB;;AAIlC,IAAa,kBAAb,MAA6B;CAoC3B,YAAY,EACV,mBACA,eAIE,EAAE,EAAE;2BAzC6B;oBAOR;sBAIS;qBAGD;4BAIO;0BAeQ,EAAE;AASpD,OAAK,oBAAoB,qBAAqB,qBAAqB;AACnE,OAAK,cAAc,WAAW;;CAGhC,AAAQ,kBAAkB;AACxB,MAAI,KAAK,cAAc,EAAG,QAAO;AACjC,SAAO,KAAK,QAAQ,GAAG,KAAK;;;;;;;;;CAU9B,oBAAoB,YAAqC;AACvD,OAAK,mBAAmB;GAAE,GAAG,KAAK;GAAkB,GAAG;GAAY;;;CAIrE,qBAAqB,UAAmC;EACtD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,OAAK,cAAc,iBAAiB;AACpC,OAAK,eAAe,iBAAiB;AACrC,OAAK,qBAAqB,iBAAiB;;;CAI7C,gBAAgB,cAA4B;AAC1C,OAAK,qBAAqB,EAAE,cAAc,CAAC;;;CAI7C,YAAY,UAA+C;EACzD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,SAAO,EACL,UACE,OACA,eACG,KAAK,oBAAoB,OAAO,YAAY,iBAAiB,EACnE;;CAGH,MAAM,QACJ,OACA,YACe;AACf,SAAO,KAAK,oBAAoB,OAAO,YAAY;GACjD,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB,oBAAoB,KAAK;GAC1B,CAAC;;CAGJ,MAAc,oBACZ,OACA,YACA,UACe;AAGf,MAAI,KAAK,qBAAqB,qBAAqB,CAAE;AAGrD,MAAI,CAAC,SAAS,sBAAsB,CAAC,KAAK,iBAAiB,CAAE;AAE7D,QAAMA,gCAAa,KAAK;GACtB;GACY;GAYZ,kBAAkB;IAChB,GAAG,KAAK;IACR,+CAAuB;KACrB,aAAa,SAAS;KACtB,YAAY,KAAK;KAClB,CAAC;IACF,mBAAmBC;IAKnB,mBAAmBC;IAInB,qBAAqB;IACtB;GACD,aAAaC;GACb,gBAAgBC;GAChB,aAAa,SAAS,eAAe;GACrC,cAAc,SAAS,gBAAgB;GACxC,CAAC;;CAGJ,AAAQ,yBACN,UAC2B;EAC3B,MAAM,+DAAuC,SAAS,YAAY;AAClE,MAAI,gBAAgB,OAClB,QAAO;GACL;GACA,cAAc;GACd,oBAAoB;GACrB;AAGH,SAAO;GACL,aAAa;GACb,cAAc,SAAS,gBAAgB;GACvC,oBAAoB,SAAS,+DACD,SAAS,aAAa,GAC9C;GACL;;CAGH,AAAQ,cAAc,YAAgC;EACpD,IAAI;AAEJ,gBAAc,cAAc;AAE5B,0CAAgB,CAAC,iCACf,eAAc,+CAAuB,CAAC,iCAAiC;AAMzE,MAAI,OAAO,MAAM,YAAY,IAAI,cAAc,KAAK,cAAc,EAChE,OAAM,IAAI,MAAM,sCAAsC;AAGxD,OAAK,aAAa;;;AAItB,MAAM,YAAY,IAAI,iBAAiB"}
1
+ {"version":3,"file":"telemetry-client.cjs","names":["lambdaClient","TELEMETRY_EMITTER_V2","TELEMETRY_SURFACE_V2","RUNTIME_PACKAGE_NAME","RUNTIME_PACKAGE_VERSION"],"sources":["../../../src/runtime/telemetry/telemetry-client.ts"],"sourcesContent":["import type { AnalyticsEvents } from \"./events\";\nimport {\n lambdaClient,\n parseAndWarnTelemetryId,\n computeSamplingMeta,\n TELEMETRY_EMITTER_V2,\n TELEMETRY_SURFACE_V2,\n processEnv,\n} from \"@copilotkit/shared\";\nimport {\n RUNTIME_PACKAGE_NAME,\n RUNTIME_PACKAGE_VERSION,\n} from \"../core/package-info\";\nimport { firstNonBlankTelemetryId } from \"./telemetry-identity\";\n\n/** Transport identity and sampling authority resolved for one runtime. */\nexport interface TelemetryIdentity {\n telemetryId?: string;\n licenseToken?: string;\n}\n\n/** Capture-only telemetry client bound to one runtime identity. */\nexport interface TelemetryCapture {\n capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void>;\n}\n\ninterface ResolvedTelemetryIdentity {\n telemetryId: string | null;\n licenseToken: string | null;\n licenseTelemetryId: string | null;\n}\n\nexport function isTelemetryDisabled(): boolean {\n return (\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n processEnv().DO_NOT_TRACK === \"true\" ||\n processEnv().DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n private telemetryDisabled: boolean = false;\n // Opt-down for anonymous events, defaulting to 1: the sink is ours, so a\n // real count beats one extrapolated from a fraction of the population.\n // It stays configurable because it is the cross-SDK lever for reducing or\n // stopping anonymous volume — the Go, Python, Ruby, and .NET runtimes all\n // expose it, and the cross-language conformance suite drives it to 0 to\n // assert silence. Identified callers bypass it.\n private sampleRate: number = 1;\n // EIP / Intelligence license token (Ed25519-signed JWT). Kept separate\n // from standalone identity so the transport receives only the selected\n // identity source.\n private licenseToken: string | null = null;\n // Standalone identity sent as a transport claim. It does not make an\n // event identified.\n private telemetryId: string | null = null;\n // License-derived identity. This client sends every event either way;\n // the id is what sets telemetry_identified on the sampling block, which\n // is how the two populations stay separable downstream.\n private licenseTelemetryId: string | null = null;\n // Properties merged into every event this client sends.\n //\n // For facts about the caller that are true for the whole process rather than\n // for one event: which product is embedding the runtime, for instance. A\n // distribution built on top of this can then be told apart in the existing\n // events instead of sending its own, which is the difference between one\n // extra field and a second pipeline nobody asked for.\n //\n // Sent as `global_properties`, a field of its own, so these stay separable\n // from an event's own properties all the way to the sink.\n //\n // Do not reuse a key an event already sets: the fanout spreads this bag last\n // for `oss.runtime.*`, so a collision resolves in favour of the global and\n // does so silently. Names here should describe the caller, not the call.\n private globalProperties: Record<string, unknown> = {};\n\n constructor({\n telemetryDisabled,\n sampleRate,\n }: {\n telemetryDisabled?: boolean;\n sampleRate?: number;\n } = {}) {\n this.telemetryDisabled = telemetryDisabled || isTelemetryDisabled();\n this.setSampleRate(sampleRate);\n }\n\n private shouldSendEvent() {\n if (this.sampleRate >= 1) return true;\n return Math.random() < this.sampleRate;\n }\n\n /**\n * Add properties carried by every subsequent event.\n *\n * Merged rather than replaced, so two callers setting different fields do not\n * erase each other. Set once at runtime construction in practice; nothing\n * here is per-request.\n */\n setGlobalProperties(properties: Record<string, unknown>) {\n this.globalProperties = { ...this.globalProperties, ...properties };\n }\n\n /** Atomically replace the process-wide telemetry identity. */\n setTelemetryIdentity(identity: TelemetryIdentity): void {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n this.telemetryId = resolvedIdentity.telemetryId;\n this.licenseToken = resolvedIdentity.licenseToken;\n this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;\n }\n\n /** Create an immutable capture scope for one Runtime instance. */\n createScope(identity: TelemetryIdentity): TelemetryCapture {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n return {\n capture: <K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ) => this.captureWithIdentity(event, properties, resolvedIdentity),\n };\n }\n\n async capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void> {\n return this.captureWithIdentity(event, properties, {\n telemetryId: this.telemetryId,\n licenseToken: this.licenseToken,\n licenseTelemetryId: this.licenseTelemetryId,\n });\n }\n\n private async captureWithIdentity<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n identity: ResolvedTelemetryIdentity,\n ): Promise<void> {\n // Re-read the environment: an opt-out set after import (for example a\n // dotenv call below the imports) must still stop events.\n if (this.telemetryDisabled || isTelemetryDisabled()) return;\n // Nothing is gated at the default rate of 1. A caller who dialled it\n // down means it, and identified callers are exempt either way.\n if (!identity.licenseTelemetryId && !this.shouldSendEvent()) return;\n\n await lambdaClient.send({\n event,\n properties: properties as Record<string, unknown>,\n // Its own field on the wire rather than folded into `properties`, which\n // is what the sink expects: for `oss.runtime.*` the fanout treats\n // `global_properties` as the SDK's pass-through bag and spreads it into\n // the analytics event, and v1's client sends package name and version the\n // same way. Folding it in would work and would put a process-level fact\n // in the per-event slot, where nothing downstream expects to find one.\n // Sampling metadata rides in the same slot, as it does in v1. It\n // reads 1/1 unless a caller dialled the rate down, and is stamped\n // either way: a consumer summing sampleWeight across emitters must\n // not find the field missing on a quarter of the rows, which is the\n // state that made ~24% of runtime volume unweightable (OSS-1017).\n globalProperties: {\n ...this.globalProperties,\n ...computeSamplingMeta({\n telemetryId: identity.licenseTelemetryId,\n sampleRate: this.sampleRate,\n }),\n telemetry_emitter: TELEMETRY_EMITTER_V2,\n // Constant here: a v1 request never reaches this client. The v1\n // entrypoint hands its own capture scope to the V2 runtime it\n // builds, so v1 traffic is emitted by the v1 client and stamped\n // v1 there — which is also what keeps it on the Segment wire.\n telemetry_surface: TELEMETRY_SURFACE_V2,\n // This client has one transport, so the marker is constant here. It\n // is stamped anyway so the property means the same thing on every\n // event whichever client produced it (OSS-1019).\n telemetry_transport: \"lambda\",\n },\n packageName: RUNTIME_PACKAGE_NAME,\n packageVersion: RUNTIME_PACKAGE_VERSION,\n telemetryId: identity.telemetryId ?? undefined,\n licenseToken: identity.licenseToken ?? undefined,\n });\n }\n\n private resolveTelemetryIdentity(\n identity: TelemetryIdentity,\n ): ResolvedTelemetryIdentity {\n const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);\n if (telemetryId !== undefined) {\n return {\n telemetryId,\n licenseToken: null,\n licenseTelemetryId: null,\n };\n }\n\n return {\n telemetryId: null,\n licenseToken: identity.licenseToken ?? null,\n licenseTelemetryId: identity.licenseToken\n ? parseAndWarnTelemetryId(identity.licenseToken)\n : null,\n };\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 1;\n\n if (processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n _sampleRate = parseFloat(processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n // Number.isNaN guards against parseFloat(\"nonsense\") slipping past the\n // range check (all NaN comparisons are false), which would silently\n // drop every anonymous event with no signal.\n if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n }\n}\n\nconst telemetry = new TelemetryClient();\nexport default telemetry;\n"],"mappings":";;;;;AAmCA,SAAgB,sBAA+B;AAC7C,4CACc,CAAC,kCAAkC,8CACnC,CAAC,kCAAkC,2CACnC,CAAC,iBAAiB,8CAClB,CAAC,iBAAiB;;AAIlC,IAAa,kBAAb,MAA6B;CAoC3B,YAAY,EACV,mBACA,eAIE,EAAE,EAAE;2BAzC6B;oBAOR;sBAIS;qBAGD;4BAIO;0BAeQ,EAAE;AASpD,OAAK,oBAAoB,qBAAqB,qBAAqB;AACnE,OAAK,cAAc,WAAW;;CAGhC,AAAQ,kBAAkB;AACxB,MAAI,KAAK,cAAc,EAAG,QAAO;AACjC,SAAO,KAAK,QAAQ,GAAG,KAAK;;;;;;;;;CAU9B,oBAAoB,YAAqC;AACvD,OAAK,mBAAmB;GAAE,GAAG,KAAK;GAAkB,GAAG;GAAY;;;CAIrE,qBAAqB,UAAmC;EACtD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,OAAK,cAAc,iBAAiB;AACpC,OAAK,eAAe,iBAAiB;AACrC,OAAK,qBAAqB,iBAAiB;;;CAI7C,YAAY,UAA+C;EACzD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,SAAO,EACL,UACE,OACA,eACG,KAAK,oBAAoB,OAAO,YAAY,iBAAiB,EACnE;;CAGH,MAAM,QACJ,OACA,YACe;AACf,SAAO,KAAK,oBAAoB,OAAO,YAAY;GACjD,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB,oBAAoB,KAAK;GAC1B,CAAC;;CAGJ,MAAc,oBACZ,OACA,YACA,UACe;AAGf,MAAI,KAAK,qBAAqB,qBAAqB,CAAE;AAGrD,MAAI,CAAC,SAAS,sBAAsB,CAAC,KAAK,iBAAiB,CAAE;AAE7D,QAAMA,gCAAa,KAAK;GACtB;GACY;GAYZ,kBAAkB;IAChB,GAAG,KAAK;IACR,+CAAuB;KACrB,aAAa,SAAS;KACtB,YAAY,KAAK;KAClB,CAAC;IACF,mBAAmBC;IAKnB,mBAAmBC;IAInB,qBAAqB;IACtB;GACD,aAAaC;GACb,gBAAgBC;GAChB,aAAa,SAAS,eAAe;GACrC,cAAc,SAAS,gBAAgB;GACxC,CAAC;;CAGJ,AAAQ,yBACN,UAC2B;EAC3B,MAAM,+DAAuC,SAAS,YAAY;AAClE,MAAI,gBAAgB,OAClB,QAAO;GACL;GACA,cAAc;GACd,oBAAoB;GACrB;AAGH,SAAO;GACL,aAAa;GACb,cAAc,SAAS,gBAAgB;GACvC,oBAAoB,SAAS,+DACD,SAAS,aAAa,GAC9C;GACL;;CAGH,AAAQ,cAAc,YAAgC;EACpD,IAAI;AAEJ,gBAAc,cAAc;AAE5B,0CAAgB,CAAC,iCACf,eAAc,+CAAuB,CAAC,iCAAiC;AAMzE,MAAI,OAAO,MAAM,YAAY,IAAI,cAAc,KAAK,cAAc,EAChE,OAAM,IAAI,MAAM,sCAAsC;AAGxD,OAAK,aAAa;;;AAItB,MAAM,YAAY,IAAI,iBAAiB"}
@@ -41,10 +41,6 @@ var TelemetryClient = class {
41
41
  this.licenseToken = resolvedIdentity.licenseToken;
42
42
  this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;
43
43
  }
44
- /** @deprecated Prefer {@link setTelemetryIdentity}. */
45
- setLicenseToken(licenseToken) {
46
- this.setTelemetryIdentity({ licenseToken });
47
- }
48
44
  /** Create an immutable capture scope for one Runtime instance. */
49
45
  createScope(identity) {
50
46
  const resolvedIdentity = this.resolveTelemetryIdentity(identity);
@@ -1 +1 @@
1
- {"version":3,"file":"telemetry-client.mjs","names":[],"sources":["../../../src/runtime/telemetry/telemetry-client.ts"],"sourcesContent":["import type { AnalyticsEvents } from \"./events\";\nimport {\n lambdaClient,\n parseAndWarnTelemetryId,\n computeSamplingMeta,\n TELEMETRY_EMITTER_V2,\n TELEMETRY_SURFACE_V2,\n processEnv,\n} from \"@copilotkit/shared\";\nimport {\n RUNTIME_PACKAGE_NAME,\n RUNTIME_PACKAGE_VERSION,\n} from \"../core/package-info\";\nimport { firstNonBlankTelemetryId } from \"./telemetry-identity\";\n\n/** Transport identity and sampling authority resolved for one runtime. */\nexport interface TelemetryIdentity {\n telemetryId?: string;\n licenseToken?: string;\n}\n\n/** Capture-only telemetry client bound to one runtime identity. */\nexport interface TelemetryCapture {\n capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void>;\n}\n\ninterface ResolvedTelemetryIdentity {\n telemetryId: string | null;\n licenseToken: string | null;\n licenseTelemetryId: string | null;\n}\n\nexport function isTelemetryDisabled(): boolean {\n return (\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n processEnv().DO_NOT_TRACK === \"true\" ||\n processEnv().DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n private telemetryDisabled: boolean = false;\n // Opt-down for anonymous events, defaulting to 1: the sink is ours, so a\n // real count beats one extrapolated from a fraction of the population.\n // It stays configurable because it is the cross-SDK lever for reducing or\n // stopping anonymous volume — the Go, Python, Ruby, and .NET runtimes all\n // expose it, and the cross-language conformance suite drives it to 0 to\n // assert silence. Identified callers bypass it.\n private sampleRate: number = 1;\n // EIP / Intelligence license token (Ed25519-signed JWT). Kept separate\n // from standalone identity so the transport receives only the selected\n // identity source.\n private licenseToken: string | null = null;\n // Standalone identity sent as a transport claim. It does not make an\n // event identified.\n private telemetryId: string | null = null;\n // License-derived identity. This client sends every event either way;\n // the id is what sets telemetry_identified on the sampling block, which\n // is how the two populations stay separable downstream.\n private licenseTelemetryId: string | null = null;\n // Properties merged into every event this client sends.\n //\n // For facts about the caller that are true for the whole process rather than\n // for one event: which product is embedding the runtime, for instance. A\n // distribution built on top of this can then be told apart in the existing\n // events instead of sending its own, which is the difference between one\n // extra field and a second pipeline nobody asked for.\n //\n // Sent as `global_properties`, a field of its own, so these stay separable\n // from an event's own properties all the way to the sink.\n //\n // Do not reuse a key an event already sets: the fanout spreads this bag last\n // for `oss.runtime.*`, so a collision resolves in favour of the global and\n // does so silently. Names here should describe the caller, not the call.\n private globalProperties: Record<string, unknown> = {};\n\n constructor({\n telemetryDisabled,\n sampleRate,\n }: {\n telemetryDisabled?: boolean;\n sampleRate?: number;\n } = {}) {\n this.telemetryDisabled = telemetryDisabled || isTelemetryDisabled();\n this.setSampleRate(sampleRate);\n }\n\n private shouldSendEvent() {\n if (this.sampleRate >= 1) return true;\n return Math.random() < this.sampleRate;\n }\n\n /**\n * Add properties carried by every subsequent event.\n *\n * Merged rather than replaced, so two callers setting different fields do not\n * erase each other. Set once at runtime construction in practice; nothing\n * here is per-request.\n */\n setGlobalProperties(properties: Record<string, unknown>) {\n this.globalProperties = { ...this.globalProperties, ...properties };\n }\n\n /** Atomically replace the process-wide telemetry identity. */\n setTelemetryIdentity(identity: TelemetryIdentity): void {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n this.telemetryId = resolvedIdentity.telemetryId;\n this.licenseToken = resolvedIdentity.licenseToken;\n this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;\n }\n\n /** @deprecated Prefer {@link setTelemetryIdentity}. */\n setLicenseToken(licenseToken: string): void {\n this.setTelemetryIdentity({ licenseToken });\n }\n\n /** Create an immutable capture scope for one Runtime instance. */\n createScope(identity: TelemetryIdentity): TelemetryCapture {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n return {\n capture: <K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ) => this.captureWithIdentity(event, properties, resolvedIdentity),\n };\n }\n\n async capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void> {\n return this.captureWithIdentity(event, properties, {\n telemetryId: this.telemetryId,\n licenseToken: this.licenseToken,\n licenseTelemetryId: this.licenseTelemetryId,\n });\n }\n\n private async captureWithIdentity<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n identity: ResolvedTelemetryIdentity,\n ): Promise<void> {\n // Re-read the environment: an opt-out set after import (for example a\n // dotenv call below the imports) must still stop events.\n if (this.telemetryDisabled || isTelemetryDisabled()) return;\n // Nothing is gated at the default rate of 1. A caller who dialled it\n // down means it, and identified callers are exempt either way.\n if (!identity.licenseTelemetryId && !this.shouldSendEvent()) return;\n\n await lambdaClient.send({\n event,\n properties: properties as Record<string, unknown>,\n // Its own field on the wire rather than folded into `properties`, which\n // is what the sink expects: for `oss.runtime.*` the fanout treats\n // `global_properties` as the SDK's pass-through bag and spreads it into\n // the analytics event, and v1's client sends package name and version the\n // same way. Folding it in would work and would put a process-level fact\n // in the per-event slot, where nothing downstream expects to find one.\n // Sampling metadata rides in the same slot, as it does in v1. It\n // reads 1/1 unless a caller dialled the rate down, and is stamped\n // either way: a consumer summing sampleWeight across emitters must\n // not find the field missing on a quarter of the rows, which is the\n // state that made ~24% of runtime volume unweightable (OSS-1017).\n globalProperties: {\n ...this.globalProperties,\n ...computeSamplingMeta({\n telemetryId: identity.licenseTelemetryId,\n sampleRate: this.sampleRate,\n }),\n telemetry_emitter: TELEMETRY_EMITTER_V2,\n // Constant here: a v1 request never reaches this client. The v1\n // entrypoint hands its own capture scope to the V2 runtime it\n // builds, so v1 traffic is emitted by the v1 client and stamped\n // v1 there — which is also what keeps it on the Segment wire.\n telemetry_surface: TELEMETRY_SURFACE_V2,\n // This client has one transport, so the marker is constant here. It\n // is stamped anyway so the property means the same thing on every\n // event whichever client produced it (OSS-1019).\n telemetry_transport: \"lambda\",\n },\n packageName: RUNTIME_PACKAGE_NAME,\n packageVersion: RUNTIME_PACKAGE_VERSION,\n telemetryId: identity.telemetryId ?? undefined,\n licenseToken: identity.licenseToken ?? undefined,\n });\n }\n\n private resolveTelemetryIdentity(\n identity: TelemetryIdentity,\n ): ResolvedTelemetryIdentity {\n const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);\n if (telemetryId !== undefined) {\n return {\n telemetryId,\n licenseToken: null,\n licenseTelemetryId: null,\n };\n }\n\n return {\n telemetryId: null,\n licenseToken: identity.licenseToken ?? null,\n licenseTelemetryId: identity.licenseToken\n ? parseAndWarnTelemetryId(identity.licenseToken)\n : null,\n };\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 1;\n\n if (processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n _sampleRate = parseFloat(processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n // Number.isNaN guards against parseFloat(\"nonsense\") slipping past the\n // range check (all NaN comparisons are false), which would silently\n // drop every anonymous event with no signal.\n if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n }\n}\n\nconst telemetry = new TelemetryClient();\nexport default telemetry;\n"],"mappings":";;;;;AAmCA,SAAgB,sBAA+B;AAC7C,QACE,YAAY,CAAC,kCAAkC,UAC/C,YAAY,CAAC,kCAAkC,OAC/C,YAAY,CAAC,iBAAiB,UAC9B,YAAY,CAAC,iBAAiB;;AAIlC,IAAa,kBAAb,MAA6B;CAoC3B,YAAY,EACV,mBACA,eAIE,EAAE,EAAE;2BAzC6B;oBAOR;sBAIS;qBAGD;4BAIO;0BAeQ,EAAE;AASpD,OAAK,oBAAoB,qBAAqB,qBAAqB;AACnE,OAAK,cAAc,WAAW;;CAGhC,AAAQ,kBAAkB;AACxB,MAAI,KAAK,cAAc,EAAG,QAAO;AACjC,SAAO,KAAK,QAAQ,GAAG,KAAK;;;;;;;;;CAU9B,oBAAoB,YAAqC;AACvD,OAAK,mBAAmB;GAAE,GAAG,KAAK;GAAkB,GAAG;GAAY;;;CAIrE,qBAAqB,UAAmC;EACtD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,OAAK,cAAc,iBAAiB;AACpC,OAAK,eAAe,iBAAiB;AACrC,OAAK,qBAAqB,iBAAiB;;;CAI7C,gBAAgB,cAA4B;AAC1C,OAAK,qBAAqB,EAAE,cAAc,CAAC;;;CAI7C,YAAY,UAA+C;EACzD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,SAAO,EACL,UACE,OACA,eACG,KAAK,oBAAoB,OAAO,YAAY,iBAAiB,EACnE;;CAGH,MAAM,QACJ,OACA,YACe;AACf,SAAO,KAAK,oBAAoB,OAAO,YAAY;GACjD,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB,oBAAoB,KAAK;GAC1B,CAAC;;CAGJ,MAAc,oBACZ,OACA,YACA,UACe;AAGf,MAAI,KAAK,qBAAqB,qBAAqB,CAAE;AAGrD,MAAI,CAAC,SAAS,sBAAsB,CAAC,KAAK,iBAAiB,CAAE;AAE7D,QAAM,aAAa,KAAK;GACtB;GACY;GAYZ,kBAAkB;IAChB,GAAG,KAAK;IACR,GAAG,oBAAoB;KACrB,aAAa,SAAS;KACtB,YAAY,KAAK;KAClB,CAAC;IACF,mBAAmB;IAKnB,mBAAmB;IAInB,qBAAqB;IACtB;GACD,aAAa;GACb,gBAAgB;GAChB,aAAa,SAAS,eAAe;GACrC,cAAc,SAAS,gBAAgB;GACxC,CAAC;;CAGJ,AAAQ,yBACN,UAC2B;EAC3B,MAAM,cAAc,yBAAyB,SAAS,YAAY;AAClE,MAAI,gBAAgB,OAClB,QAAO;GACL;GACA,cAAc;GACd,oBAAoB;GACrB;AAGH,SAAO;GACL,aAAa;GACb,cAAc,SAAS,gBAAgB;GACvC,oBAAoB,SAAS,eACzB,wBAAwB,SAAS,aAAa,GAC9C;GACL;;CAGH,AAAQ,cAAc,YAAgC;EACpD,IAAI;AAEJ,gBAAc,cAAc;AAE5B,MAAI,YAAY,CAAC,iCACf,eAAc,WAAW,YAAY,CAAC,iCAAiC;AAMzE,MAAI,OAAO,MAAM,YAAY,IAAI,cAAc,KAAK,cAAc,EAChE,OAAM,IAAI,MAAM,sCAAsC;AAGxD,OAAK,aAAa;;;AAItB,MAAM,YAAY,IAAI,iBAAiB"}
1
+ {"version":3,"file":"telemetry-client.mjs","names":[],"sources":["../../../src/runtime/telemetry/telemetry-client.ts"],"sourcesContent":["import type { AnalyticsEvents } from \"./events\";\nimport {\n lambdaClient,\n parseAndWarnTelemetryId,\n computeSamplingMeta,\n TELEMETRY_EMITTER_V2,\n TELEMETRY_SURFACE_V2,\n processEnv,\n} from \"@copilotkit/shared\";\nimport {\n RUNTIME_PACKAGE_NAME,\n RUNTIME_PACKAGE_VERSION,\n} from \"../core/package-info\";\nimport { firstNonBlankTelemetryId } from \"./telemetry-identity\";\n\n/** Transport identity and sampling authority resolved for one runtime. */\nexport interface TelemetryIdentity {\n telemetryId?: string;\n licenseToken?: string;\n}\n\n/** Capture-only telemetry client bound to one runtime identity. */\nexport interface TelemetryCapture {\n capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void>;\n}\n\ninterface ResolvedTelemetryIdentity {\n telemetryId: string | null;\n licenseToken: string | null;\n licenseTelemetryId: string | null;\n}\n\nexport function isTelemetryDisabled(): boolean {\n return (\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"true\" ||\n processEnv().COPILOTKIT_TELEMETRY_DISABLED === \"1\" ||\n processEnv().DO_NOT_TRACK === \"true\" ||\n processEnv().DO_NOT_TRACK === \"1\"\n );\n}\n\nexport class TelemetryClient {\n private telemetryDisabled: boolean = false;\n // Opt-down for anonymous events, defaulting to 1: the sink is ours, so a\n // real count beats one extrapolated from a fraction of the population.\n // It stays configurable because it is the cross-SDK lever for reducing or\n // stopping anonymous volume — the Go, Python, Ruby, and .NET runtimes all\n // expose it, and the cross-language conformance suite drives it to 0 to\n // assert silence. Identified callers bypass it.\n private sampleRate: number = 1;\n // EIP / Intelligence license token (Ed25519-signed JWT). Kept separate\n // from standalone identity so the transport receives only the selected\n // identity source.\n private licenseToken: string | null = null;\n // Standalone identity sent as a transport claim. It does not make an\n // event identified.\n private telemetryId: string | null = null;\n // License-derived identity. This client sends every event either way;\n // the id is what sets telemetry_identified on the sampling block, which\n // is how the two populations stay separable downstream.\n private licenseTelemetryId: string | null = null;\n // Properties merged into every event this client sends.\n //\n // For facts about the caller that are true for the whole process rather than\n // for one event: which product is embedding the runtime, for instance. A\n // distribution built on top of this can then be told apart in the existing\n // events instead of sending its own, which is the difference between one\n // extra field and a second pipeline nobody asked for.\n //\n // Sent as `global_properties`, a field of its own, so these stay separable\n // from an event's own properties all the way to the sink.\n //\n // Do not reuse a key an event already sets: the fanout spreads this bag last\n // for `oss.runtime.*`, so a collision resolves in favour of the global and\n // does so silently. Names here should describe the caller, not the call.\n private globalProperties: Record<string, unknown> = {};\n\n constructor({\n telemetryDisabled,\n sampleRate,\n }: {\n telemetryDisabled?: boolean;\n sampleRate?: number;\n } = {}) {\n this.telemetryDisabled = telemetryDisabled || isTelemetryDisabled();\n this.setSampleRate(sampleRate);\n }\n\n private shouldSendEvent() {\n if (this.sampleRate >= 1) return true;\n return Math.random() < this.sampleRate;\n }\n\n /**\n * Add properties carried by every subsequent event.\n *\n * Merged rather than replaced, so two callers setting different fields do not\n * erase each other. Set once at runtime construction in practice; nothing\n * here is per-request.\n */\n setGlobalProperties(properties: Record<string, unknown>) {\n this.globalProperties = { ...this.globalProperties, ...properties };\n }\n\n /** Atomically replace the process-wide telemetry identity. */\n setTelemetryIdentity(identity: TelemetryIdentity): void {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n this.telemetryId = resolvedIdentity.telemetryId;\n this.licenseToken = resolvedIdentity.licenseToken;\n this.licenseTelemetryId = resolvedIdentity.licenseTelemetryId;\n }\n\n /** Create an immutable capture scope for one Runtime instance. */\n createScope(identity: TelemetryIdentity): TelemetryCapture {\n const resolvedIdentity = this.resolveTelemetryIdentity(identity);\n return {\n capture: <K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ) => this.captureWithIdentity(event, properties, resolvedIdentity),\n };\n }\n\n async capture<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n ): Promise<void> {\n return this.captureWithIdentity(event, properties, {\n telemetryId: this.telemetryId,\n licenseToken: this.licenseToken,\n licenseTelemetryId: this.licenseTelemetryId,\n });\n }\n\n private async captureWithIdentity<K extends keyof AnalyticsEvents>(\n event: K,\n properties: AnalyticsEvents[K],\n identity: ResolvedTelemetryIdentity,\n ): Promise<void> {\n // Re-read the environment: an opt-out set after import (for example a\n // dotenv call below the imports) must still stop events.\n if (this.telemetryDisabled || isTelemetryDisabled()) return;\n // Nothing is gated at the default rate of 1. A caller who dialled it\n // down means it, and identified callers are exempt either way.\n if (!identity.licenseTelemetryId && !this.shouldSendEvent()) return;\n\n await lambdaClient.send({\n event,\n properties: properties as Record<string, unknown>,\n // Its own field on the wire rather than folded into `properties`, which\n // is what the sink expects: for `oss.runtime.*` the fanout treats\n // `global_properties` as the SDK's pass-through bag and spreads it into\n // the analytics event, and v1's client sends package name and version the\n // same way. Folding it in would work and would put a process-level fact\n // in the per-event slot, where nothing downstream expects to find one.\n // Sampling metadata rides in the same slot, as it does in v1. It\n // reads 1/1 unless a caller dialled the rate down, and is stamped\n // either way: a consumer summing sampleWeight across emitters must\n // not find the field missing on a quarter of the rows, which is the\n // state that made ~24% of runtime volume unweightable (OSS-1017).\n globalProperties: {\n ...this.globalProperties,\n ...computeSamplingMeta({\n telemetryId: identity.licenseTelemetryId,\n sampleRate: this.sampleRate,\n }),\n telemetry_emitter: TELEMETRY_EMITTER_V2,\n // Constant here: a v1 request never reaches this client. The v1\n // entrypoint hands its own capture scope to the V2 runtime it\n // builds, so v1 traffic is emitted by the v1 client and stamped\n // v1 there — which is also what keeps it on the Segment wire.\n telemetry_surface: TELEMETRY_SURFACE_V2,\n // This client has one transport, so the marker is constant here. It\n // is stamped anyway so the property means the same thing on every\n // event whichever client produced it (OSS-1019).\n telemetry_transport: \"lambda\",\n },\n packageName: RUNTIME_PACKAGE_NAME,\n packageVersion: RUNTIME_PACKAGE_VERSION,\n telemetryId: identity.telemetryId ?? undefined,\n licenseToken: identity.licenseToken ?? undefined,\n });\n }\n\n private resolveTelemetryIdentity(\n identity: TelemetryIdentity,\n ): ResolvedTelemetryIdentity {\n const telemetryId = firstNonBlankTelemetryId(identity.telemetryId);\n if (telemetryId !== undefined) {\n return {\n telemetryId,\n licenseToken: null,\n licenseTelemetryId: null,\n };\n }\n\n return {\n telemetryId: null,\n licenseToken: identity.licenseToken ?? null,\n licenseTelemetryId: identity.licenseToken\n ? parseAndWarnTelemetryId(identity.licenseToken)\n : null,\n };\n }\n\n private setSampleRate(sampleRate: number | undefined) {\n let _sampleRate: number;\n\n _sampleRate = sampleRate ?? 1;\n\n if (processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE) {\n _sampleRate = parseFloat(processEnv().COPILOTKIT_TELEMETRY_SAMPLE_RATE);\n }\n\n // Number.isNaN guards against parseFloat(\"nonsense\") slipping past the\n // range check (all NaN comparisons are false), which would silently\n // drop every anonymous event with no signal.\n if (Number.isNaN(_sampleRate) || _sampleRate < 0 || _sampleRate > 1) {\n throw new Error(\"Sample rate must be between 0 and 1\");\n }\n\n this.sampleRate = _sampleRate;\n }\n}\n\nconst telemetry = new TelemetryClient();\nexport default telemetry;\n"],"mappings":";;;;;AAmCA,SAAgB,sBAA+B;AAC7C,QACE,YAAY,CAAC,kCAAkC,UAC/C,YAAY,CAAC,kCAAkC,OAC/C,YAAY,CAAC,iBAAiB,UAC9B,YAAY,CAAC,iBAAiB;;AAIlC,IAAa,kBAAb,MAA6B;CAoC3B,YAAY,EACV,mBACA,eAIE,EAAE,EAAE;2BAzC6B;oBAOR;sBAIS;qBAGD;4BAIO;0BAeQ,EAAE;AASpD,OAAK,oBAAoB,qBAAqB,qBAAqB;AACnE,OAAK,cAAc,WAAW;;CAGhC,AAAQ,kBAAkB;AACxB,MAAI,KAAK,cAAc,EAAG,QAAO;AACjC,SAAO,KAAK,QAAQ,GAAG,KAAK;;;;;;;;;CAU9B,oBAAoB,YAAqC;AACvD,OAAK,mBAAmB;GAAE,GAAG,KAAK;GAAkB,GAAG;GAAY;;;CAIrE,qBAAqB,UAAmC;EACtD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,OAAK,cAAc,iBAAiB;AACpC,OAAK,eAAe,iBAAiB;AACrC,OAAK,qBAAqB,iBAAiB;;;CAI7C,YAAY,UAA+C;EACzD,MAAM,mBAAmB,KAAK,yBAAyB,SAAS;AAChE,SAAO,EACL,UACE,OACA,eACG,KAAK,oBAAoB,OAAO,YAAY,iBAAiB,EACnE;;CAGH,MAAM,QACJ,OACA,YACe;AACf,SAAO,KAAK,oBAAoB,OAAO,YAAY;GACjD,aAAa,KAAK;GAClB,cAAc,KAAK;GACnB,oBAAoB,KAAK;GAC1B,CAAC;;CAGJ,MAAc,oBACZ,OACA,YACA,UACe;AAGf,MAAI,KAAK,qBAAqB,qBAAqB,CAAE;AAGrD,MAAI,CAAC,SAAS,sBAAsB,CAAC,KAAK,iBAAiB,CAAE;AAE7D,QAAM,aAAa,KAAK;GACtB;GACY;GAYZ,kBAAkB;IAChB,GAAG,KAAK;IACR,GAAG,oBAAoB;KACrB,aAAa,SAAS;KACtB,YAAY,KAAK;KAClB,CAAC;IACF,mBAAmB;IAKnB,mBAAmB;IAInB,qBAAqB;IACtB;GACD,aAAa;GACb,gBAAgB;GAChB,aAAa,SAAS,eAAe;GACrC,cAAc,SAAS,gBAAgB;GACxC,CAAC;;CAGJ,AAAQ,yBACN,UAC2B;EAC3B,MAAM,cAAc,yBAAyB,SAAS,YAAY;AAClE,MAAI,gBAAgB,OAClB,QAAO;GACL;GACA,cAAc;GACd,oBAAoB;GACrB;AAGH,SAAO;GACL,aAAa;GACb,cAAc,SAAS,gBAAgB;GACvC,oBAAoB,SAAS,eACzB,wBAAwB,SAAS,aAAa,GAC9C;GACL;;CAGH,AAAQ,cAAc,YAAgC;EACpD,IAAI;AAEJ,gBAAc,cAAc;AAE5B,MAAI,YAAY,CAAC,iCACf,eAAc,WAAW,YAAY,CAAC,iCAAiC;AAMzE,MAAI,OAAO,MAAM,YAAY,IAAI,cAAc,KAAK,cAAc,EAChE,OAAM,IAAI,MAAM,sCAAsC;AAGxD,OAAK,aAAa;;;AAItB,MAAM,YAAY,IAAI,iBAAiB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@copilotkit/runtime",
3
- "version": "2.0.0-rc.6",
3
+ "version": "2.0.0-rc.7",
4
4
  "private": false,
5
5
  "keywords": [
6
6
  "ai",
@@ -65,7 +65,7 @@
65
65
  "@ai-sdk/openai": "^3.0.36",
66
66
  "@cfworker/json-schema": "^4.1.1",
67
67
  "@copilotkit/license-verifier": "~0.5.0",
68
- "@copilotkit/shared": "2.0.0-rc.6",
68
+ "@copilotkit/shared": "2.0.0-rc.7",
69
69
  "@modelcontextprotocol/sdk": "^1.18.2",
70
70
  "@remix-run/node-fetch-server": "^0.13.0",
71
71
  "@scarf/scarf": "^1.3.0",
@@ -76,8 +76,8 @@
76
76
  "rxjs": "7.8.1",
77
77
  "zod": "^3.25.18",
78
78
  "yauzl": "2.10.0",
79
- "@copilotkit/channels-core": "^0.12.0",
80
- "@copilotkit/channels-intelligence": "^0.12.0"
79
+ "@copilotkit/channels-intelligence": "^0.12.0",
80
+ "@copilotkit/channels-core": "^0.12.0"
81
81
  },
82
82
  "devDependencies": {
83
83
  "@copilotkit/aimock": "latest",
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.cts","names":[],"sources":["../../src/runtime/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KA+DY,wBAAA,IAA4B,MAAA;EACtC,OAAA,EAAS,OAAA;AAAA,MACL,OAAA,CAAQ,QAAA"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../src/runtime/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;KA+DY,wBAAA,IAA4B,MAAA;EACtC,OAAA,EAAS,OAAA;AAAA,MACL,OAAA,CAAQ,QAAA"}