@copilotkit/runtime 1.62.3 → 1.63.1

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 (162) hide show
  1. package/dist/_virtual/_rolldown/runtime.mjs +15 -1
  2. package/dist/agent/converters/aisdk.d.cts +1 -1
  3. package/dist/agent/converters/tanstack.d.cts +1 -1
  4. package/dist/agent/index.d.cts +1 -1
  5. package/dist/channels/dist/index.d.cts +10 -0
  6. package/dist/channels/dist/index.d.cts.map +1 -0
  7. package/dist/channels/dist/index.d.mts +10 -0
  8. package/dist/channels/dist/index.d.mts.map +1 -0
  9. package/dist/graphql/inputs/action.input.d.cts +1 -1
  10. package/dist/graphql/inputs/agent-session.input.d.cts +1 -1
  11. package/dist/graphql/inputs/agent-state.input.d.cts +1 -1
  12. package/dist/graphql/inputs/extensions.input.d.cts +1 -1
  13. package/dist/graphql/inputs/forwarded-parameters.input.d.cts +1 -1
  14. package/dist/graphql/inputs/message.input.d.cts +1 -1
  15. package/dist/graphql/types/base/index.d.cts +1 -1
  16. package/dist/graphql/types/converted/index.d.cts +1 -1
  17. package/dist/graphql/types/copilot-response.type.d.cts +1 -1
  18. package/dist/graphql/types/enums.d.cts +1 -1
  19. package/dist/graphql/types/extensions-response.type.d.cts +1 -1
  20. package/dist/graphql/types/message-status.type.d.cts +1 -1
  21. package/dist/graphql/types/response-status.type.d.cts +1 -1
  22. package/dist/index.d.cts +1 -1
  23. package/dist/langgraph.d.cts +1 -1
  24. package/dist/lib/cloud/index.d.cts +1 -1
  25. package/dist/lib/index.d.cts +1 -1
  26. package/dist/lib/integrations/index.d.cts +1 -1
  27. package/dist/lib/integrations/nest/index.d.cts +1 -1
  28. package/dist/lib/integrations/nextjs/app-router.d.cts +1 -1
  29. package/dist/lib/integrations/nextjs/pages-router.d.cts +1 -1
  30. package/dist/lib/integrations/node-express/index.d.cts +1 -1
  31. package/dist/lib/integrations/node-http/index.d.cts +1 -1
  32. package/dist/lib/integrations/shared.d.cts +1 -1
  33. package/dist/lib/logger.d.cts +1 -1
  34. package/dist/lib/observability.d.cts +1 -1
  35. package/dist/lib/runtime/agent-integrations/langgraph/agent.d.cts +1 -1
  36. package/dist/lib/runtime/agent-integrations/langgraph/consts.d.cts +1 -1
  37. package/dist/lib/runtime/agent-integrations/langgraph/index.d.cts +1 -1
  38. package/dist/lib/runtime/copilot-runtime.d.cts +1 -1
  39. package/dist/lib/runtime/mcp-tools-utils.d.cts +1 -1
  40. package/dist/lib/runtime/telemetry-agent-runner.d.cts +1 -1
  41. package/dist/lib/runtime/types.d.cts +1 -1
  42. package/dist/lib/telemetry-client.mjs +1 -1
  43. package/dist/package.cjs +4 -1
  44. package/dist/{package.mjs → runtime/package.mjs} +5 -2
  45. package/dist/runtime/package.mjs.map +1 -0
  46. package/dist/service-adapters/anthropic/anthropic-adapter.d.cts +1 -1
  47. package/dist/service-adapters/bedrock/bedrock-adapter.d.cts +1 -1
  48. package/dist/service-adapters/empty/empty-adapter.d.cts +1 -1
  49. package/dist/service-adapters/events.d.cts +1 -1
  50. package/dist/service-adapters/experimental/ollama/ollama-adapter.d.cts +1 -1
  51. package/dist/service-adapters/google/google-genai-adapter.d.cts +1 -1
  52. package/dist/service-adapters/groq/groq-adapter.d.cts +1 -1
  53. package/dist/service-adapters/index.d.cts +1 -1
  54. package/dist/service-adapters/langchain/langchain-adapter.d.cts +1 -1
  55. package/dist/service-adapters/langchain/langserve.d.cts +1 -1
  56. package/dist/service-adapters/langchain/types.d.cts +1 -1
  57. package/dist/service-adapters/openai/openai-adapter.d.cts +1 -1
  58. package/dist/service-adapters/openai/openai-assistant-adapter.d.cts +1 -1
  59. package/dist/service-adapters/service-adapter.d.cts +1 -1
  60. package/dist/service-adapters/shared/error-utils.d.cts +1 -1
  61. package/dist/service-adapters/shared/sdk-client-utils.d.cts +1 -1
  62. package/dist/service-adapters/unify/unify-adapter.d.cts +1 -1
  63. package/dist/utils/failed-response-status-reasons.d.cts +1 -1
  64. package/dist/v2/express.d.cts +3 -3
  65. package/dist/v2/express.d.mts +2 -2
  66. package/dist/v2/hono.d.cts +3 -3
  67. package/dist/v2/hono.d.mts +2 -2
  68. package/dist/v2/index.d.cts +7 -6
  69. package/dist/v2/index.d.mts +6 -5
  70. package/dist/v2/node.d.cts +1 -1
  71. package/dist/v2/runtime/core/channel-activation-config.cjs +93 -0
  72. package/dist/v2/runtime/core/channel-activation-config.cjs.map +1 -0
  73. package/dist/v2/runtime/core/channel-activation-config.d.cts +34 -0
  74. package/dist/v2/runtime/core/channel-activation-config.d.cts.map +1 -0
  75. package/dist/v2/runtime/core/channel-activation-config.d.mts +34 -0
  76. package/dist/v2/runtime/core/channel-activation-config.d.mts.map +1 -0
  77. package/dist/v2/runtime/core/channel-activation-config.mjs +91 -0
  78. package/dist/v2/runtime/core/channel-activation-config.mjs.map +1 -0
  79. package/dist/v2/runtime/core/channel-manager.cjs +447 -0
  80. package/dist/v2/runtime/core/channel-manager.cjs.map +1 -0
  81. package/dist/v2/runtime/core/channel-manager.d.cts +90 -0
  82. package/dist/v2/runtime/core/channel-manager.d.cts.map +1 -0
  83. package/dist/v2/runtime/core/channel-manager.d.mts +90 -0
  84. package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -0
  85. package/dist/v2/runtime/core/channel-manager.mjs +446 -0
  86. package/dist/v2/runtime/core/channel-manager.mjs.map +1 -0
  87. package/dist/v2/runtime/core/debug-event-bus.d.cts +1 -1
  88. package/dist/v2/runtime/core/fetch-cors.d.cts +1 -1
  89. package/dist/v2/runtime/core/fetch-handler.cjs +47 -1
  90. package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
  91. package/dist/v2/runtime/core/fetch-handler.d.cts +60 -4
  92. package/dist/v2/runtime/core/fetch-handler.d.cts.map +1 -1
  93. package/dist/v2/runtime/core/fetch-handler.d.mts +59 -3
  94. package/dist/v2/runtime/core/fetch-handler.d.mts.map +1 -1
  95. package/dist/v2/runtime/core/fetch-handler.mjs +47 -1
  96. package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
  97. package/dist/v2/runtime/core/hooks.d.cts +1 -1
  98. package/dist/v2/runtime/core/middleware-sse-parser.d.cts +1 -1
  99. package/dist/v2/runtime/core/middleware.d.cts +1 -1
  100. package/dist/v2/runtime/core/runtime.cjs +24 -1
  101. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  102. package/dist/v2/runtime/core/runtime.d.cts +75 -27
  103. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  104. package/dist/v2/runtime/core/runtime.d.mts +74 -26
  105. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  106. package/dist/v2/runtime/core/runtime.mjs +25 -2
  107. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  108. package/dist/v2/runtime/endpoints/express-single.d.cts +1 -1
  109. package/dist/v2/runtime/endpoints/express.cjs +10 -5
  110. package/dist/v2/runtime/endpoints/express.cjs.map +1 -1
  111. package/dist/v2/runtime/endpoints/express.d.cts +30 -4
  112. package/dist/v2/runtime/endpoints/express.d.cts.map +1 -1
  113. package/dist/v2/runtime/endpoints/express.d.mts +29 -3
  114. package/dist/v2/runtime/endpoints/express.d.mts.map +1 -1
  115. package/dist/v2/runtime/endpoints/express.mjs +10 -5
  116. package/dist/v2/runtime/endpoints/express.mjs.map +1 -1
  117. package/dist/v2/runtime/endpoints/hono-single.d.cts +1 -1
  118. package/dist/v2/runtime/endpoints/hono.cjs +7 -3
  119. package/dist/v2/runtime/endpoints/hono.cjs.map +1 -1
  120. package/dist/v2/runtime/endpoints/hono.d.cts +30 -16
  121. package/dist/v2/runtime/endpoints/hono.d.cts.map +1 -1
  122. package/dist/v2/runtime/endpoints/hono.d.mts +29 -15
  123. package/dist/v2/runtime/endpoints/hono.d.mts.map +1 -1
  124. package/dist/v2/runtime/endpoints/hono.mjs +7 -3
  125. package/dist/v2/runtime/endpoints/hono.mjs.map +1 -1
  126. package/dist/v2/runtime/endpoints/index.d.cts +3 -3
  127. package/dist/v2/runtime/endpoints/index.d.mts +2 -2
  128. package/dist/v2/runtime/endpoints/node-fetch-handler.d.cts +1 -1
  129. package/dist/v2/runtime/endpoints/node.cjs +12 -1
  130. package/dist/v2/runtime/endpoints/node.cjs.map +1 -1
  131. package/dist/v2/runtime/endpoints/node.d.cts +22 -2
  132. package/dist/v2/runtime/endpoints/node.d.cts.map +1 -1
  133. package/dist/v2/runtime/endpoints/node.d.mts +21 -1
  134. package/dist/v2/runtime/endpoints/node.d.mts.map +1 -1
  135. package/dist/v2/runtime/endpoints/node.mjs +12 -1
  136. package/dist/v2/runtime/endpoints/node.mjs.map +1 -1
  137. package/dist/v2/runtime/express.d.cts +2 -2
  138. package/dist/v2/runtime/express.d.mts +1 -1
  139. package/dist/v2/runtime/handlers/header-utils.d.cts +1 -1
  140. package/dist/v2/runtime/hono.d.cts +2 -2
  141. package/dist/v2/runtime/hono.d.mts +1 -1
  142. package/dist/v2/runtime/index.d.cts +6 -5
  143. package/dist/v2/runtime/index.d.cts.map +1 -1
  144. package/dist/v2/runtime/index.d.mts +5 -4
  145. package/dist/v2/runtime/index.d.mts.map +1 -1
  146. package/dist/v2/runtime/intelligence-platform/client.d.cts +1 -1
  147. package/dist/v2/runtime/node.d.cts +1 -1
  148. package/dist/v2/runtime/runner/agent-runner.d.cts +1 -1
  149. package/dist/v2/runtime/runner/in-memory.cjs +35 -19
  150. package/dist/v2/runtime/runner/in-memory.cjs.map +1 -1
  151. package/dist/v2/runtime/runner/in-memory.d.cts +13 -1
  152. package/dist/v2/runtime/runner/in-memory.d.cts.map +1 -1
  153. package/dist/v2/runtime/runner/in-memory.d.mts +12 -0
  154. package/dist/v2/runtime/runner/in-memory.d.mts.map +1 -1
  155. package/dist/v2/runtime/runner/in-memory.mjs +35 -19
  156. package/dist/v2/runtime/runner/in-memory.mjs.map +1 -1
  157. package/dist/v2/runtime/runner/index.d.cts +1 -1
  158. package/dist/v2/runtime/runner/intelligence.d.cts +1 -1
  159. package/dist/v2/runtime/telemetry/telemetry-client.mjs +1 -1
  160. package/dist/v2/runtime/transcription-service/transcription-service.d.cts +1 -1
  161. package/package.json +5 -2
  162. package/dist/package.mjs.map +0 -1
@@ -1,20 +1,21 @@
1
-
1
+ require("reflect-metadata");
2
2
  import { TranscribeFileOptions, TranscriptionService } from "./runtime/transcription-service/transcription-service.cjs";
3
3
  import { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, LocalThreadEndpointRecord, LocalThreadEndpointRunner, supportsLocalThreadEndpoints } from "./runtime/runner/agent-runner.cjs";
4
4
  import { CopilotKitIntelligence, CopilotKitIntelligenceConfig, CreateThreadRequest, ListThreadsResponse, SubscribeToThreadsRequest, SubscribeToThreadsResponse, ThreadSummary, UpdateThreadRequest } from "./runtime/intelligence-platform/client.cjs";
5
- import { AgentFactoryContext, AgentsConfig, AgentsFactory, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotRuntime, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, OpenGenerativeUIConfig, OpenGenerativeUIOptions, VERSION, isA2UIEnabled, isIntelligenceRuntime, resolveAgents } from "./runtime/core/runtime.cjs";
5
+ import { AgentFactoryContext, AgentsConfig, AgentsFactory, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, OpenGenerativeUIConfig, OpenGenerativeUIOptions, RuntimeWithDeclaredChannels, VERSION, isA2UIEnabled, isIntelligenceRuntime, resolveAgents } from "./runtime/core/runtime.cjs";
6
6
  import { CopilotCorsConfig } from "./runtime/core/fetch-cors.cjs";
7
7
  import { CopilotRuntimeHooks, ErrorHookContext, HandlerHookContext, HookContext, ResponseHookContext, RouteInfo } from "./runtime/core/hooks.cjs";
8
- import { CopilotEndpointCorsConfig, createCopilotEndpoint, createCopilotHonoHandler, toFetchCorsConfig } from "./runtime/endpoints/hono.cjs";
8
+ import { ChannelStatus, ChannelsControl } from "./runtime/core/channel-manager.cjs";
9
+ import { CopilotEndpointCorsConfig, CopilotHonoApp, createCopilotEndpoint, createCopilotHonoHandler, toFetchCorsConfig } from "./runtime/endpoints/hono.cjs";
9
10
  import { createCopilotEndpointSingleRoute } from "./runtime/endpoints/hono-single.cjs";
10
- import { CopilotExpressEndpointParams, createCopilotExpressHandler } from "./runtime/endpoints/express.cjs";
11
+ import { CopilotExpressEndpointParams, CopilotExpressRouter, createCopilotExpressHandler } from "./runtime/endpoints/express.cjs";
11
12
  import { createCopilotEndpointSingleRouteExpress } from "./runtime/endpoints/express-single.cjs";
12
13
  import { InMemoryAgentRunner, InMemoryThread } from "./runtime/runner/in-memory.cjs";
13
14
  import { IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, RunnerStartupBoundary } from "./runtime/runner/intelligence.cjs";
14
15
  import { finalizeRunEvents } from "./runtime/runner/index.cjs";
15
- import { CopilotRuntimeFetchHandler, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.cjs";
16
+ import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.cjs";
16
17
  import { CopilotKitRequestHandler, MCPClient, MCPTransport } from "./runtime/index.cjs";
17
18
  import { convertAISDKStream } from "../agent/converters/aisdk.cjs";
18
19
  import { TanStackChatMessage, TanStackInputResult, convertInputToTanStackAI, convertTanStackStream } from "../agent/converters/tanstack.cjs";
19
20
  import { BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, InterruptSignal, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MessageConversionOptions, ModelSpecifier, OverridableProperty, ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "../agent/index.cjs";
20
- export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, CopilotCorsConfig, CopilotEndpointCorsConfig, CopilotExpressEndpointParams, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotKitRequestHandler, CopilotRuntime, CopilotRuntimeFetchHandler, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateThreadRequest, ErrorHookContext, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, ResponseHookContext, RouteInfo, RunnerStartupBoundary, SubscribeToThreadsRequest, SubscribeToThreadsResponse, TanStackChatMessage, TanStackInputResult, ThreadSummary, ToolDefinition, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotEndpoint, createCopilotExpressHandler as createCopilotEndpointExpress, createCopilotExpressHandler, createCopilotEndpointSingleRoute, createCopilotEndpointSingleRouteExpress, createCopilotHonoHandler, createCopilotRuntimeHandler, defineTool, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, resolveAgents, resolveModel, supportsLocalThreadEndpoints, toFetchCorsConfig };
21
+ export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, ChannelStatus, ChannelsControl, CopilotCorsConfig, CopilotEndpointCorsConfig, CopilotExpressEndpointParams, CopilotExpressRouter, CopilotHonoApp, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotKitRequestHandler, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateThreadRequest, ErrorHookContext, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, ResponseHookContext, RouteInfo, RunnerStartupBoundary, RuntimeWithDeclaredChannels, SubscribeToThreadsRequest, SubscribeToThreadsResponse, TanStackChatMessage, TanStackInputResult, ThreadSummary, ToolDefinition, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotEndpoint, createCopilotExpressHandler as createCopilotEndpointExpress, createCopilotExpressHandler, createCopilotEndpointSingleRoute, createCopilotEndpointSingleRouteExpress, createCopilotHonoHandler, createCopilotRuntimeHandler, defineTool, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, resolveAgents, resolveModel, supportsLocalThreadEndpoints, toFetchCorsConfig };
@@ -2,19 +2,20 @@ import "reflect-metadata";
2
2
  import { TranscribeFileOptions, TranscriptionService } from "./runtime/transcription-service/transcription-service.mjs";
3
3
  import { AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, LocalThreadEndpointRecord, LocalThreadEndpointRunner, supportsLocalThreadEndpoints } from "./runtime/runner/agent-runner.mjs";
4
4
  import { CopilotKitIntelligence, CopilotKitIntelligenceConfig, CreateThreadRequest, ListThreadsResponse, SubscribeToThreadsRequest, SubscribeToThreadsResponse, ThreadSummary, UpdateThreadRequest } from "./runtime/intelligence-platform/client.mjs";
5
- import { AgentFactoryContext, AgentsConfig, AgentsFactory, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotRuntime, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, OpenGenerativeUIConfig, OpenGenerativeUIOptions, VERSION, isA2UIEnabled, isIntelligenceRuntime, resolveAgents } from "./runtime/core/runtime.mjs";
5
+ import { AgentFactoryContext, AgentsConfig, AgentsFactory, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, OpenGenerativeUIConfig, OpenGenerativeUIOptions, RuntimeWithDeclaredChannels, VERSION, isA2UIEnabled, isIntelligenceRuntime, resolveAgents } from "./runtime/core/runtime.mjs";
6
6
  import { CopilotCorsConfig } from "./runtime/core/fetch-cors.mjs";
7
7
  import { CopilotRuntimeHooks, ErrorHookContext, HandlerHookContext, HookContext, ResponseHookContext, RouteInfo } from "./runtime/core/hooks.mjs";
8
- import { CopilotEndpointCorsConfig, createCopilotEndpoint, createCopilotHonoHandler, toFetchCorsConfig } from "./runtime/endpoints/hono.mjs";
8
+ import { ChannelStatus, ChannelsControl } from "./runtime/core/channel-manager.mjs";
9
+ import { CopilotEndpointCorsConfig, CopilotHonoApp, createCopilotEndpoint, createCopilotHonoHandler, toFetchCorsConfig } from "./runtime/endpoints/hono.mjs";
9
10
  import { createCopilotEndpointSingleRoute } from "./runtime/endpoints/hono-single.mjs";
10
- import { CopilotExpressEndpointParams, createCopilotExpressHandler } from "./runtime/endpoints/express.mjs";
11
+ import { CopilotExpressEndpointParams, CopilotExpressRouter, createCopilotExpressHandler } from "./runtime/endpoints/express.mjs";
11
12
  import { createCopilotEndpointSingleRouteExpress } from "./runtime/endpoints/express-single.mjs";
12
13
  import { InMemoryAgentRunner, InMemoryThread } from "./runtime/runner/in-memory.mjs";
13
14
  import { IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, RunnerStartupBoundary } from "./runtime/runner/intelligence.mjs";
14
15
  import { finalizeRunEvents } from "./runtime/runner/index.mjs";
15
- import { CopilotRuntimeFetchHandler, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.mjs";
16
+ import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.mjs";
16
17
  import { CopilotKitRequestHandler, MCPClient, MCPTransport } from "./runtime/index.mjs";
17
18
  import { convertAISDKStream } from "../agent/converters/aisdk.mjs";
18
19
  import { TanStackChatMessage, TanStackInputResult, convertInputToTanStackAI, convertTanStackStream } from "../agent/converters/tanstack.mjs";
19
20
  import { BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, InterruptSignal, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MessageConversionOptions, ModelSpecifier, OverridableProperty, ToolDefinition, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "../agent/index.mjs";
20
- export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, CopilotCorsConfig, CopilotEndpointCorsConfig, CopilotExpressEndpointParams, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotKitRequestHandler, CopilotRuntime, CopilotRuntimeFetchHandler, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateThreadRequest, ErrorHookContext, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, ResponseHookContext, RouteInfo, RunnerStartupBoundary, SubscribeToThreadsRequest, SubscribeToThreadsResponse, TanStackChatMessage, TanStackInputResult, ThreadSummary, ToolDefinition, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotEndpoint, createCopilotExpressHandler as createCopilotEndpointExpress, createCopilotExpressHandler, createCopilotEndpointSingleRoute, createCopilotEndpointSingleRouteExpress, createCopilotHonoHandler, createCopilotRuntimeHandler, defineTool, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, resolveAgents, resolveModel, supportsLocalThreadEndpoints, toFetchCorsConfig };
21
+ export { type AgentFactoryContext, AgentRunner, AgentRunnerConnectRequest, AgentRunnerIsRunningRequest, AgentRunnerRunRequest, AgentRunnerStopRequest, AgentsConfig, AgentsFactory, BasicAgent, BasicAgentConfiguration, BuiltInAgent, BuiltInAgentAISDKFactoryConfig, BuiltInAgentClassicConfig, BuiltInAgentConfiguration, BuiltInAgentCustomFactoryConfig, BuiltInAgentFactoryConfig, BuiltInAgentModel, BuiltInAgentTanStackFactoryConfig, ChannelStatus, ChannelsControl, CopilotCorsConfig, CopilotEndpointCorsConfig, CopilotExpressEndpointParams, CopilotExpressRouter, CopilotHonoApp, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotKitIntelligence, CopilotKitIntelligenceConfig, CopilotKitRequestHandler, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, CopilotRuntimeHooks, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, CreateThreadRequest, ErrorHookContext, HandlerHookContext, HookContext, IdentifyUserCallback, InMemoryAgentRunner, InMemoryThread, IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, InterruptSignal, ListThreadsResponse, LocalThreadEndpointRecord, LocalThreadEndpointRunner, MCPClient, MCPClientConfig, MCPClientConfigHTTP, MCPClientConfigSSE, MCPClientProvider, MCPTransport, McpAppsConfig, McpAppsServerConfig, MessageConversionOptions, ModelSpecifier, OpenGenerativeUIConfig, OpenGenerativeUIOptions, OverridableProperty, ResponseHookContext, RouteInfo, RunnerStartupBoundary, RuntimeWithDeclaredChannels, SubscribeToThreadsRequest, SubscribeToThreadsResponse, TanStackChatMessage, TanStackInputResult, ThreadSummary, ToolDefinition, TranscribeFileOptions, TranscriptionService, UpdateThreadRequest, VERSION, convertAISDKStream, convertInputToTanStackAI, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertTanStackStream, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, createCopilotEndpoint, createCopilotExpressHandler as createCopilotEndpointExpress, createCopilotExpressHandler, createCopilotEndpointSingleRoute, createCopilotEndpointSingleRouteExpress, createCopilotHonoHandler, createCopilotRuntimeHandler, defineTool, finalizeRunEvents, isA2UIEnabled, isIntelligenceRuntime, resolveAgents, resolveModel, supportsLocalThreadEndpoints, toFetchCorsConfig };
@@ -1,4 +1,4 @@
1
-
1
+ require("reflect-metadata");
2
2
  import { NodeFetchHandler, createCopilotNodeHandler, createNodeFetchHandler } from "./runtime/endpoints/node-fetch-handler.cjs";
3
3
  import { createCopilotNodeListener } from "./runtime/endpoints/node.cjs";
4
4
  import "./runtime/node.cjs";
@@ -0,0 +1,93 @@
1
+ require("reflect-metadata");
2
+
3
+ //#region src/v2/runtime/core/channel-activation-config.ts
4
+ /**
5
+ * Error thrown when a Channel activation config cannot be derived — either the
6
+ * Intelligence API key does not carry a project id in the expected
7
+ * `cpk-{projectId}_...` format, or the {@link Channel} is missing a `name`.
8
+ */
9
+ var ChannelConfigError = class extends Error {
10
+ constructor(message) {
11
+ super(message);
12
+ this.name = "ChannelConfigError";
13
+ }
14
+ };
15
+ /** Matches the `cpk-{projectId}_...` Intelligence API key format. */
16
+ const API_KEY_PROJECT_ID_PATTERN = /^cpk-(\d+)_/;
17
+ /**
18
+ * Parse the project id embedded in an Intelligence API key.
19
+ *
20
+ * Intelligence API keys are formatted `cpk-{projectId}_{rest}` — this
21
+ * extracts and numerically parses the `{projectId}` segment.
22
+ *
23
+ * @param apiKey - The Intelligence API key to parse.
24
+ * @returns The parsed, strictly-positive, safe-integer project id.
25
+ * @throws {ChannelConfigError} If `apiKey` does not match the expected
26
+ * `cpk-{projectId}_...` format — a wrong/missing prefix or an absent project
27
+ * id segment all fail the same match — or if the parsed project id is not a
28
+ * strictly-positive safe integer.
29
+ */
30
+ function parseProjectIdFromApiKey(apiKey) {
31
+ const match = API_KEY_PROJECT_ID_PATTERN.exec(apiKey);
32
+ if (!match) throw new ChannelConfigError("Could not parse a project id from the Intelligence API key — expected the \"cpk-{projectId}_...\" format (the key value is omitted here to avoid leaking secret material).");
33
+ const projectId = Number(match[1]);
34
+ if (!Number.isSafeInteger(projectId) || projectId <= 0) throw new ChannelConfigError(`Parsed an invalid project id (${projectId}) from the Intelligence API key — the project id in "cpk-{projectId}_..." must be a positive safe integer (the key value is omitted here to avoid leaking secret material).`);
35
+ return projectId;
36
+ }
37
+ /**
38
+ * Derive the {@link ChannelActivationConfig} needed to activate `channel`
39
+ * against the given Intelligence runtime configuration.
40
+ *
41
+ * @param args.intelligence - The Intelligence runtime client to pull the
42
+ * runner websocket URL and auth token from.
43
+ * @param args.channel - The Channel being activated. Must have a `name`; its
44
+ * per-Channel `provider` selects the managed adapter declared to the gateway.
45
+ * @param args.runtimeInstanceId - Identifier for the activating runtime
46
+ * instance, passed through unchanged.
47
+ * @returns The resolved {@link ChannelActivationConfig}.
48
+ * @throws {ChannelConfigError} If the Intelligence API key does not carry a
49
+ * parseable, strictly-positive project id, or if `channel.name` is
50
+ * missing/empty.
51
+ *
52
+ * The managed provider is a PER-CHANNEL choice read from `channel.provider`, so
53
+ * one runtime can activate a Slack-backed Channel and a Teams-backed Channel
54
+ * side by side. When `channel.provider` is unset the config adapter defaults to
55
+ * `"slack"` — an explicit, documented default, not a silent global. The SDK
56
+ * only DECLARES this provider to the Intelligence gateway on join; the gateway
57
+ * resolves the actual connection and is the authority on which providers it
58
+ * accepts (it accepts only `"slack"` today — Teams gateway support is tracked
59
+ * in OSS-450).
60
+ *
61
+ * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the
62
+ * reserved-name rule are NOT re-checked here. Their single source of truth is
63
+ * the `@copilotkit/channels-intelligence` launcher
64
+ * (`assertValidChannelRealtimeScope` + `assertValidChannelNames`), which
65
+ * validates them at activation; a malformed name surfaces as a logged `error`
66
+ * status via {@link ChannelManager.ready} rather than an up-front throw. An
67
+ * empty/missing name is still rejected here because that is this config's own
68
+ * precondition (it has no name to forward at all), not a downstream replica.
69
+ */
70
+ function deriveChannelActivationConfig(args) {
71
+ const { intelligence, channel, runtimeInstanceId } = args;
72
+ if (!channel.name) throw new ChannelConfigError("Channel is missing a `name` — pass createChannel({ name }) to activate it.");
73
+ const channelName = channel.name;
74
+ const wsUrl = intelligence.ɵgetRunnerWsUrl();
75
+ const apiUrl = intelligence.ɵgetApiUrl();
76
+ const apiKey = intelligence.ɵgetRunnerAuthToken();
77
+ const projectId = parseProjectIdFromApiKey(apiKey);
78
+ const trimmedProvider = channel.provider?.trim();
79
+ return {
80
+ wsUrl,
81
+ apiUrl,
82
+ apiKey,
83
+ projectId,
84
+ channelName,
85
+ adapter: trimmedProvider ? trimmedProvider : "slack",
86
+ runtimeInstanceId
87
+ };
88
+ }
89
+
90
+ //#endregion
91
+ exports.ChannelConfigError = ChannelConfigError;
92
+ exports.deriveChannelActivationConfig = deriveChannelActivationConfig;
93
+ //# sourceMappingURL=channel-activation-config.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-activation-config.cjs","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"sourcesContent":["import type { CopilotKitIntelligence } from \"../intelligence-platform\";\n// Type-only: @copilotkit/channels is pure-ESM, so a value import would break this\n// package's CJS output (see `runtime.ts` for the same constraint).\nimport type { Channel } from \"@copilotkit/channels\";\n\n/**\n * Error thrown when a Channel activation config cannot be derived — either the\n * Intelligence API key does not carry a project id in the expected\n * `cpk-{projectId}_...` format, or the {@link Channel} is missing a `name`.\n */\nexport class ChannelConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChannelConfigError\";\n }\n}\n\n/**\n * Resolved configuration needed to activate a single Channel against a\n * running Intelligence runtime instance.\n */\nexport interface ChannelActivationConfig {\n /** Intelligence runner websocket URL the Channel connects to. */\n wsUrl: string;\n /** Intelligence API key used to authenticate the runner connection. */\n apiKey: string;\n /** Intelligence app-api HTTP base URL (`intelligence.ɵgetApiUrl()`), forwarded\n * to the transport so the managed realtime path enables file/history parity\n * (those are HTTP-only). Without it, Channels started by the normal runtime\n * handler run with no history and no file support (OSS-476). */\n apiUrl: string;\n /** Project id parsed from {@link apiKey}. */\n projectId: number;\n /** The Channel's declared name (`createChannel({ name })`). */\n channelName: string;\n /**\n * The managed provider this Channel declares to the Intelligence gateway on\n * join, resolved from the Channel's per-Channel `provider` (e.g. `\"slack\"` or\n * `\"teams\"`), defaulting to `\"slack\"`. Named `adapter` because that is the\n * field the gateway's join payload expects; the gateway resolves the actual\n * connection for the declared provider.\n */\n adapter: string;\n /** Identifier for the runtime instance activating this Channel. */\n runtimeInstanceId: string;\n}\n\n/** Matches the `cpk-{projectId}_...` Intelligence API key format. */\nconst API_KEY_PROJECT_ID_PATTERN = /^cpk-(\\d+)_/;\n\n/**\n * Parse the project id embedded in an Intelligence API key.\n *\n * Intelligence API keys are formatted `cpk-{projectId}_{rest}` — this\n * extracts and numerically parses the `{projectId}` segment.\n *\n * @param apiKey - The Intelligence API key to parse.\n * @returns The parsed, strictly-positive, safe-integer project id.\n * @throws {ChannelConfigError} If `apiKey` does not match the expected\n * `cpk-{projectId}_...` format — a wrong/missing prefix or an absent project\n * id segment all fail the same match — or if the parsed project id is not a\n * strictly-positive safe integer.\n */\nexport function parseProjectIdFromApiKey(apiKey: string): number {\n const match = API_KEY_PROJECT_ID_PATTERN.exec(apiKey);\n if (!match) {\n // The whole API key is a `cpk-…` secret — everything after the fixed `cpk-`\n // namespace is sensitive, so a fixed-width slice (e.g. `apiKey.slice(0, 8)`)\n // would echo secret bytes for a `cpk-_short_long`-shaped key. This message is\n // logged and surfaced through `ready()`'s AggregateError, so echo NONE of the\n // key value; name only the expected format to aid diagnosis.\n throw new ChannelConfigError(\n `Could not parse a project id from the Intelligence API key — expected the ` +\n `\"cpk-{projectId}_...\" format (the key value is omitted here to avoid ` +\n `leaking secret material).`,\n );\n }\n const projectId = Number(match[1]);\n // Validate the parser's OWN output: `cpk-0_...` matches the pattern but a\n // non-positive project id would otherwise fail deep inside the launcher's\n // `assertValidChannelRealtimeScope` (which requires a positive projectId).\n // A very long digit run also matches `\\d+` but loses precision (or overflows\n // to Infinity) once coerced to `Number`, so it must be rejected too even\n // though it is `> 0` — `Number.isSafeInteger` catches both. This is the\n // parser guarding its own contract, not a channel-name replica, so it\n // belongs here. Reuse the same redaction: never echo the key value.\n if (!Number.isSafeInteger(projectId) || projectId <= 0) {\n throw new ChannelConfigError(\n `Parsed an invalid project id (${projectId}) from the Intelligence API ` +\n `key — the project id in \"cpk-{projectId}_...\" must be a positive safe ` +\n `integer (the key value is omitted here to avoid leaking secret material).`,\n );\n }\n return projectId;\n}\n\n/**\n * Derive the {@link ChannelActivationConfig} needed to activate `channel`\n * against the given Intelligence runtime configuration.\n *\n * @param args.intelligence - The Intelligence runtime client to pull the\n * runner websocket URL and auth token from.\n * @param args.channel - The Channel being activated. Must have a `name`; its\n * per-Channel `provider` selects the managed adapter declared to the gateway.\n * @param args.runtimeInstanceId - Identifier for the activating runtime\n * instance, passed through unchanged.\n * @returns The resolved {@link ChannelActivationConfig}.\n * @throws {ChannelConfigError} If the Intelligence API key does not carry a\n * parseable, strictly-positive project id, or if `channel.name` is\n * missing/empty.\n *\n * The managed provider is a PER-CHANNEL choice read from `channel.provider`, so\n * one runtime can activate a Slack-backed Channel and a Teams-backed Channel\n * side by side. When `channel.provider` is unset the config adapter defaults to\n * `\"slack\"` — an explicit, documented default, not a silent global. The SDK\n * only DECLARES this provider to the Intelligence gateway on join; the gateway\n * resolves the actual connection and is the authority on which providers it\n * accepts (it accepts only `\"slack\"` today — Teams gateway support is tracked\n * in OSS-450).\n *\n * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the\n * reserved-name rule are NOT re-checked here. Their single source of truth is\n * the `@copilotkit/channels-intelligence` launcher\n * (`assertValidChannelRealtimeScope` + `assertValidChannelNames`), which\n * validates them at activation; a malformed name surfaces as a logged `error`\n * status via {@link ChannelManager.ready} rather than an up-front throw. An\n * empty/missing name is still rejected here because that is this config's own\n * precondition (it has no name to forward at all), not a downstream replica.\n */\nexport function deriveChannelActivationConfig(args: {\n intelligence: CopilotKitIntelligence;\n channel: Channel;\n runtimeInstanceId: string;\n}): ChannelActivationConfig {\n const { intelligence, channel, runtimeInstanceId } = args;\n\n if (!channel.name) {\n throw new ChannelConfigError(\n \"Channel is missing a `name` — pass createChannel({ name }) to activate it.\",\n );\n }\n\n const channelName = channel.name;\n\n const wsUrl = intelligence.ɵgetRunnerWsUrl();\n const apiUrl = intelligence.ɵgetApiUrl();\n const apiKey = intelligence.ɵgetRunnerAuthToken();\n const projectId = parseProjectIdFromApiKey(apiKey);\n\n // Resolve the managed adapter declared to the gateway from the Channel's OWN\n // `provider` — a per-Channel choice, not a manager-wide default. When\n // `provider` is unset the adapter is the documented default `\"slack\"`; set\n // `createChannel({ provider: \"teams\" })` to declare Teams instead. The value\n // is trimmed so a padded runtime value (one that bypassed the typed union)\n // resolves to its bare provider rather than being forwarded with whitespace,\n // and a blank/whitespace-only provider falls back to `\"slack\"` (`??` alone\n // would keep `\"\"`).\n const trimmedProvider = channel.provider?.trim();\n\n return {\n wsUrl,\n apiUrl,\n apiKey,\n projectId,\n channelName,\n adapter: trimmedProvider ? trimmedProvider : \"slack\",\n runtimeInstanceId,\n };\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;;AAmChB,MAAM,6BAA6B;;;;;;;;;;;;;;AAenC,SAAgB,yBAAyB,QAAwB;CAC/D,MAAM,QAAQ,2BAA2B,KAAK,OAAO;AACrD,KAAI,CAAC,MAMH,OAAM,IAAI,mBACR,6KAGD;CAEH,MAAM,YAAY,OAAO,MAAM,GAAG;AASlC,KAAI,CAAC,OAAO,cAAc,UAAU,IAAI,aAAa,EACnD,OAAM,IAAI,mBACR,iCAAiC,UAAU,6KAG5C;AAEH,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCT,SAAgB,8BAA8B,MAIlB;CAC1B,MAAM,EAAE,cAAc,SAAS,sBAAsB;AAErD,KAAI,CAAC,QAAQ,KACX,OAAM,IAAI,mBACR,6EACD;CAGH,MAAM,cAAc,QAAQ;CAE5B,MAAM,QAAQ,aAAa,iBAAiB;CAC5C,MAAM,SAAS,aAAa,YAAY;CACxC,MAAM,SAAS,aAAa,qBAAqB;CACjD,MAAM,YAAY,yBAAyB,OAAO;CAUlD,MAAM,kBAAkB,QAAQ,UAAU,MAAM;AAEhD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,SAAS,kBAAkB,kBAAkB;EAC7C;EACD"}
@@ -0,0 +1,34 @@
1
+ require("reflect-metadata");
2
+ //#region src/v2/runtime/core/channel-activation-config.d.ts
3
+ /**
4
+ * Resolved configuration needed to activate a single Channel against a
5
+ * running Intelligence runtime instance.
6
+ */
7
+ interface ChannelActivationConfig {
8
+ /** Intelligence runner websocket URL the Channel connects to. */
9
+ wsUrl: string;
10
+ /** Intelligence API key used to authenticate the runner connection. */
11
+ apiKey: string;
12
+ /** Intelligence app-api HTTP base URL (`intelligence.ɵgetApiUrl()`), forwarded
13
+ * to the transport so the managed realtime path enables file/history parity
14
+ * (those are HTTP-only). Without it, Channels started by the normal runtime
15
+ * handler run with no history and no file support (OSS-476). */
16
+ apiUrl: string;
17
+ /** Project id parsed from {@link apiKey}. */
18
+ projectId: number;
19
+ /** The Channel's declared name (`createChannel({ name })`). */
20
+ channelName: string;
21
+ /**
22
+ * The managed provider this Channel declares to the Intelligence gateway on
23
+ * join, resolved from the Channel's per-Channel `provider` (e.g. `"slack"` or
24
+ * `"teams"`), defaulting to `"slack"`. Named `adapter` because that is the
25
+ * field the gateway's join payload expects; the gateway resolves the actual
26
+ * connection for the declared provider.
27
+ */
28
+ adapter: string;
29
+ /** Identifier for the runtime instance activating this Channel. */
30
+ runtimeInstanceId: string;
31
+ }
32
+ //#endregion
33
+ export { ChannelActivationConfig };
34
+ //# sourceMappingURL=channel-activation-config.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-activation-config.d.cts","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"mappings":";;;;;;UAqBiB,uBAAA;;EAEf,KAAA;;EAEA,MAAA;;;;;EAKA,MAAA;;EAEA,SAAA;;EAEA,WAAA;;;;;;;;EAQA,OAAA;;EAEA,iBAAA;AAAA"}
@@ -0,0 +1,34 @@
1
+ import "reflect-metadata";
2
+ //#region src/v2/runtime/core/channel-activation-config.d.ts
3
+ /**
4
+ * Resolved configuration needed to activate a single Channel against a
5
+ * running Intelligence runtime instance.
6
+ */
7
+ interface ChannelActivationConfig {
8
+ /** Intelligence runner websocket URL the Channel connects to. */
9
+ wsUrl: string;
10
+ /** Intelligence API key used to authenticate the runner connection. */
11
+ apiKey: string;
12
+ /** Intelligence app-api HTTP base URL (`intelligence.ɵgetApiUrl()`), forwarded
13
+ * to the transport so the managed realtime path enables file/history parity
14
+ * (those are HTTP-only). Without it, Channels started by the normal runtime
15
+ * handler run with no history and no file support (OSS-476). */
16
+ apiUrl: string;
17
+ /** Project id parsed from {@link apiKey}. */
18
+ projectId: number;
19
+ /** The Channel's declared name (`createChannel({ name })`). */
20
+ channelName: string;
21
+ /**
22
+ * The managed provider this Channel declares to the Intelligence gateway on
23
+ * join, resolved from the Channel's per-Channel `provider` (e.g. `"slack"` or
24
+ * `"teams"`), defaulting to `"slack"`. Named `adapter` because that is the
25
+ * field the gateway's join payload expects; the gateway resolves the actual
26
+ * connection for the declared provider.
27
+ */
28
+ adapter: string;
29
+ /** Identifier for the runtime instance activating this Channel. */
30
+ runtimeInstanceId: string;
31
+ }
32
+ //#endregion
33
+ export { ChannelActivationConfig };
34
+ //# sourceMappingURL=channel-activation-config.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-activation-config.d.mts","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"mappings":";;;;;;UAqBiB,uBAAA;;EAEf,KAAA;;EAEA,MAAA;;;;;EAKA,MAAA;;EAEA,SAAA;;EAEA,WAAA;;;;;;;;EAQA,OAAA;;EAEA,iBAAA;AAAA"}
@@ -0,0 +1,91 @@
1
+ import "reflect-metadata";
2
+ //#region src/v2/runtime/core/channel-activation-config.ts
3
+ /**
4
+ * Error thrown when a Channel activation config cannot be derived — either the
5
+ * Intelligence API key does not carry a project id in the expected
6
+ * `cpk-{projectId}_...` format, or the {@link Channel} is missing a `name`.
7
+ */
8
+ var ChannelConfigError = class extends Error {
9
+ constructor(message) {
10
+ super(message);
11
+ this.name = "ChannelConfigError";
12
+ }
13
+ };
14
+ /** Matches the `cpk-{projectId}_...` Intelligence API key format. */
15
+ const API_KEY_PROJECT_ID_PATTERN = /^cpk-(\d+)_/;
16
+ /**
17
+ * Parse the project id embedded in an Intelligence API key.
18
+ *
19
+ * Intelligence API keys are formatted `cpk-{projectId}_{rest}` — this
20
+ * extracts and numerically parses the `{projectId}` segment.
21
+ *
22
+ * @param apiKey - The Intelligence API key to parse.
23
+ * @returns The parsed, strictly-positive, safe-integer project id.
24
+ * @throws {ChannelConfigError} If `apiKey` does not match the expected
25
+ * `cpk-{projectId}_...` format — a wrong/missing prefix or an absent project
26
+ * id segment all fail the same match — or if the parsed project id is not a
27
+ * strictly-positive safe integer.
28
+ */
29
+ function parseProjectIdFromApiKey(apiKey) {
30
+ const match = API_KEY_PROJECT_ID_PATTERN.exec(apiKey);
31
+ if (!match) throw new ChannelConfigError("Could not parse a project id from the Intelligence API key — expected the \"cpk-{projectId}_...\" format (the key value is omitted here to avoid leaking secret material).");
32
+ const projectId = Number(match[1]);
33
+ if (!Number.isSafeInteger(projectId) || projectId <= 0) throw new ChannelConfigError(`Parsed an invalid project id (${projectId}) from the Intelligence API key — the project id in "cpk-{projectId}_..." must be a positive safe integer (the key value is omitted here to avoid leaking secret material).`);
34
+ return projectId;
35
+ }
36
+ /**
37
+ * Derive the {@link ChannelActivationConfig} needed to activate `channel`
38
+ * against the given Intelligence runtime configuration.
39
+ *
40
+ * @param args.intelligence - The Intelligence runtime client to pull the
41
+ * runner websocket URL and auth token from.
42
+ * @param args.channel - The Channel being activated. Must have a `name`; its
43
+ * per-Channel `provider` selects the managed adapter declared to the gateway.
44
+ * @param args.runtimeInstanceId - Identifier for the activating runtime
45
+ * instance, passed through unchanged.
46
+ * @returns The resolved {@link ChannelActivationConfig}.
47
+ * @throws {ChannelConfigError} If the Intelligence API key does not carry a
48
+ * parseable, strictly-positive project id, or if `channel.name` is
49
+ * missing/empty.
50
+ *
51
+ * The managed provider is a PER-CHANNEL choice read from `channel.provider`, so
52
+ * one runtime can activate a Slack-backed Channel and a Teams-backed Channel
53
+ * side by side. When `channel.provider` is unset the config adapter defaults to
54
+ * `"slack"` — an explicit, documented default, not a silent global. The SDK
55
+ * only DECLARES this provider to the Intelligence gateway on join; the gateway
56
+ * resolves the actual connection and is the authority on which providers it
57
+ * accepts (it accepts only `"slack"` today — Teams gateway support is tracked
58
+ * in OSS-450).
59
+ *
60
+ * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the
61
+ * reserved-name rule are NOT re-checked here. Their single source of truth is
62
+ * the `@copilotkit/channels-intelligence` launcher
63
+ * (`assertValidChannelRealtimeScope` + `assertValidChannelNames`), which
64
+ * validates them at activation; a malformed name surfaces as a logged `error`
65
+ * status via {@link ChannelManager.ready} rather than an up-front throw. An
66
+ * empty/missing name is still rejected here because that is this config's own
67
+ * precondition (it has no name to forward at all), not a downstream replica.
68
+ */
69
+ function deriveChannelActivationConfig(args) {
70
+ const { intelligence, channel, runtimeInstanceId } = args;
71
+ if (!channel.name) throw new ChannelConfigError("Channel is missing a `name` — pass createChannel({ name }) to activate it.");
72
+ const channelName = channel.name;
73
+ const wsUrl = intelligence.ɵgetRunnerWsUrl();
74
+ const apiUrl = intelligence.ɵgetApiUrl();
75
+ const apiKey = intelligence.ɵgetRunnerAuthToken();
76
+ const projectId = parseProjectIdFromApiKey(apiKey);
77
+ const trimmedProvider = channel.provider?.trim();
78
+ return {
79
+ wsUrl,
80
+ apiUrl,
81
+ apiKey,
82
+ projectId,
83
+ channelName,
84
+ adapter: trimmedProvider ? trimmedProvider : "slack",
85
+ runtimeInstanceId
86
+ };
87
+ }
88
+
89
+ //#endregion
90
+ export { ChannelConfigError, deriveChannelActivationConfig };
91
+ //# sourceMappingURL=channel-activation-config.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"channel-activation-config.mjs","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"sourcesContent":["import type { CopilotKitIntelligence } from \"../intelligence-platform\";\n// Type-only: @copilotkit/channels is pure-ESM, so a value import would break this\n// package's CJS output (see `runtime.ts` for the same constraint).\nimport type { Channel } from \"@copilotkit/channels\";\n\n/**\n * Error thrown when a Channel activation config cannot be derived — either the\n * Intelligence API key does not carry a project id in the expected\n * `cpk-{projectId}_...` format, or the {@link Channel} is missing a `name`.\n */\nexport class ChannelConfigError extends Error {\n constructor(message: string) {\n super(message);\n this.name = \"ChannelConfigError\";\n }\n}\n\n/**\n * Resolved configuration needed to activate a single Channel against a\n * running Intelligence runtime instance.\n */\nexport interface ChannelActivationConfig {\n /** Intelligence runner websocket URL the Channel connects to. */\n wsUrl: string;\n /** Intelligence API key used to authenticate the runner connection. */\n apiKey: string;\n /** Intelligence app-api HTTP base URL (`intelligence.ɵgetApiUrl()`), forwarded\n * to the transport so the managed realtime path enables file/history parity\n * (those are HTTP-only). Without it, Channels started by the normal runtime\n * handler run with no history and no file support (OSS-476). */\n apiUrl: string;\n /** Project id parsed from {@link apiKey}. */\n projectId: number;\n /** The Channel's declared name (`createChannel({ name })`). */\n channelName: string;\n /**\n * The managed provider this Channel declares to the Intelligence gateway on\n * join, resolved from the Channel's per-Channel `provider` (e.g. `\"slack\"` or\n * `\"teams\"`), defaulting to `\"slack\"`. Named `adapter` because that is the\n * field the gateway's join payload expects; the gateway resolves the actual\n * connection for the declared provider.\n */\n adapter: string;\n /** Identifier for the runtime instance activating this Channel. */\n runtimeInstanceId: string;\n}\n\n/** Matches the `cpk-{projectId}_...` Intelligence API key format. */\nconst API_KEY_PROJECT_ID_PATTERN = /^cpk-(\\d+)_/;\n\n/**\n * Parse the project id embedded in an Intelligence API key.\n *\n * Intelligence API keys are formatted `cpk-{projectId}_{rest}` — this\n * extracts and numerically parses the `{projectId}` segment.\n *\n * @param apiKey - The Intelligence API key to parse.\n * @returns The parsed, strictly-positive, safe-integer project id.\n * @throws {ChannelConfigError} If `apiKey` does not match the expected\n * `cpk-{projectId}_...` format — a wrong/missing prefix or an absent project\n * id segment all fail the same match — or if the parsed project id is not a\n * strictly-positive safe integer.\n */\nexport function parseProjectIdFromApiKey(apiKey: string): number {\n const match = API_KEY_PROJECT_ID_PATTERN.exec(apiKey);\n if (!match) {\n // The whole API key is a `cpk-…` secret — everything after the fixed `cpk-`\n // namespace is sensitive, so a fixed-width slice (e.g. `apiKey.slice(0, 8)`)\n // would echo secret bytes for a `cpk-_short_long`-shaped key. This message is\n // logged and surfaced through `ready()`'s AggregateError, so echo NONE of the\n // key value; name only the expected format to aid diagnosis.\n throw new ChannelConfigError(\n `Could not parse a project id from the Intelligence API key — expected the ` +\n `\"cpk-{projectId}_...\" format (the key value is omitted here to avoid ` +\n `leaking secret material).`,\n );\n }\n const projectId = Number(match[1]);\n // Validate the parser's OWN output: `cpk-0_...` matches the pattern but a\n // non-positive project id would otherwise fail deep inside the launcher's\n // `assertValidChannelRealtimeScope` (which requires a positive projectId).\n // A very long digit run also matches `\\d+` but loses precision (or overflows\n // to Infinity) once coerced to `Number`, so it must be rejected too even\n // though it is `> 0` — `Number.isSafeInteger` catches both. This is the\n // parser guarding its own contract, not a channel-name replica, so it\n // belongs here. Reuse the same redaction: never echo the key value.\n if (!Number.isSafeInteger(projectId) || projectId <= 0) {\n throw new ChannelConfigError(\n `Parsed an invalid project id (${projectId}) from the Intelligence API ` +\n `key — the project id in \"cpk-{projectId}_...\" must be a positive safe ` +\n `integer (the key value is omitted here to avoid leaking secret material).`,\n );\n }\n return projectId;\n}\n\n/**\n * Derive the {@link ChannelActivationConfig} needed to activate `channel`\n * against the given Intelligence runtime configuration.\n *\n * @param args.intelligence - The Intelligence runtime client to pull the\n * runner websocket URL and auth token from.\n * @param args.channel - The Channel being activated. Must have a `name`; its\n * per-Channel `provider` selects the managed adapter declared to the gateway.\n * @param args.runtimeInstanceId - Identifier for the activating runtime\n * instance, passed through unchanged.\n * @returns The resolved {@link ChannelActivationConfig}.\n * @throws {ChannelConfigError} If the Intelligence API key does not carry a\n * parseable, strictly-positive project id, or if `channel.name` is\n * missing/empty.\n *\n * The managed provider is a PER-CHANNEL choice read from `channel.provider`, so\n * one runtime can activate a Slack-backed Channel and a Teams-backed Channel\n * side by side. When `channel.provider` is unset the config adapter defaults to\n * `\"slack\"` — an explicit, documented default, not a silent global. The SDK\n * only DECLARES this provider to the Intelligence gateway on join; the gateway\n * resolves the actual connection and is the authority on which providers it\n * accepts (it accepts only `\"slack\"` today — Teams gateway support is tracked\n * in OSS-450).\n *\n * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the\n * reserved-name rule are NOT re-checked here. Their single source of truth is\n * the `@copilotkit/channels-intelligence` launcher\n * (`assertValidChannelRealtimeScope` + `assertValidChannelNames`), which\n * validates them at activation; a malformed name surfaces as a logged `error`\n * status via {@link ChannelManager.ready} rather than an up-front throw. An\n * empty/missing name is still rejected here because that is this config's own\n * precondition (it has no name to forward at all), not a downstream replica.\n */\nexport function deriveChannelActivationConfig(args: {\n intelligence: CopilotKitIntelligence;\n channel: Channel;\n runtimeInstanceId: string;\n}): ChannelActivationConfig {\n const { intelligence, channel, runtimeInstanceId } = args;\n\n if (!channel.name) {\n throw new ChannelConfigError(\n \"Channel is missing a `name` — pass createChannel({ name }) to activate it.\",\n );\n }\n\n const channelName = channel.name;\n\n const wsUrl = intelligence.ɵgetRunnerWsUrl();\n const apiUrl = intelligence.ɵgetApiUrl();\n const apiKey = intelligence.ɵgetRunnerAuthToken();\n const projectId = parseProjectIdFromApiKey(apiKey);\n\n // Resolve the managed adapter declared to the gateway from the Channel's OWN\n // `provider` — a per-Channel choice, not a manager-wide default. When\n // `provider` is unset the adapter is the documented default `\"slack\"`; set\n // `createChannel({ provider: \"teams\" })` to declare Teams instead. The value\n // is trimmed so a padded runtime value (one that bypassed the typed union)\n // resolves to its bare provider rather than being forwarded with whitespace,\n // and a blank/whitespace-only provider falls back to `\"slack\"` (`??` alone\n // would keep `\"\"`).\n const trimmedProvider = channel.provider?.trim();\n\n return {\n wsUrl,\n apiUrl,\n apiKey,\n projectId,\n channelName,\n adapter: trimmedProvider ? trimmedProvider : \"slack\",\n runtimeInstanceId,\n };\n}\n"],"mappings":";;;;;;;AAUA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;;AAmChB,MAAM,6BAA6B;;;;;;;;;;;;;;AAenC,SAAgB,yBAAyB,QAAwB;CAC/D,MAAM,QAAQ,2BAA2B,KAAK,OAAO;AACrD,KAAI,CAAC,MAMH,OAAM,IAAI,mBACR,6KAGD;CAEH,MAAM,YAAY,OAAO,MAAM,GAAG;AASlC,KAAI,CAAC,OAAO,cAAc,UAAU,IAAI,aAAa,EACnD,OAAM,IAAI,mBACR,iCAAiC,UAAU,6KAG5C;AAEH,QAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAoCT,SAAgB,8BAA8B,MAIlB;CAC1B,MAAM,EAAE,cAAc,SAAS,sBAAsB;AAErD,KAAI,CAAC,QAAQ,KACX,OAAM,IAAI,mBACR,6EACD;CAGH,MAAM,cAAc,QAAQ;CAE5B,MAAM,QAAQ,aAAa,iBAAiB;CAC5C,MAAM,SAAS,aAAa,YAAY;CACxC,MAAM,SAAS,aAAa,qBAAqB;CACjD,MAAM,YAAY,yBAAyB,OAAO;CAUlD,MAAM,kBAAkB,QAAQ,UAAU,MAAM;AAEhD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,SAAS,kBAAkB,kBAAkB;EAC7C;EACD"}