@copilotkit/runtime 1.64.2-canary.rc-1 → 1.64.3-canary.1785623356

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 (116) hide show
  1. package/README.md +35 -0
  2. package/dist/package.cjs +1 -1
  3. package/dist/runtime/package.mjs +1 -1
  4. package/dist/v2/index.d.cts +2 -2
  5. package/dist/v2/index.d.mts +2 -2
  6. package/dist/v2/runtime/core/channel-activation-config.cjs +9 -14
  7. package/dist/v2/runtime/core/channel-activation-config.cjs.map +1 -1
  8. package/dist/v2/runtime/core/channel-activation-config.d.cts +11 -6
  9. package/dist/v2/runtime/core/channel-activation-config.d.cts.map +1 -1
  10. package/dist/v2/runtime/core/channel-activation-config.d.mts +11 -6
  11. package/dist/v2/runtime/core/channel-activation-config.d.mts.map +1 -1
  12. package/dist/v2/runtime/core/channel-activation-config.mjs +9 -14
  13. package/dist/v2/runtime/core/channel-activation-config.mjs.map +1 -1
  14. package/dist/v2/runtime/core/channel-manager.cjs +319 -127
  15. package/dist/v2/runtime/core/channel-manager.cjs.map +1 -1
  16. package/dist/v2/runtime/core/channel-manager.d.cts +12 -19
  17. package/dist/v2/runtime/core/channel-manager.d.cts.map +1 -1
  18. package/dist/v2/runtime/core/channel-manager.d.mts +12 -19
  19. package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
  20. package/dist/v2/runtime/core/channel-manager.mjs +319 -127
  21. package/dist/v2/runtime/core/channel-manager.mjs.map +1 -1
  22. package/dist/v2/runtime/core/fetch-handler.cjs +5 -0
  23. package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
  24. package/dist/v2/runtime/core/fetch-handler.d.cts +5 -0
  25. package/dist/v2/runtime/core/fetch-handler.d.cts.map +1 -1
  26. package/dist/v2/runtime/core/fetch-handler.d.mts +5 -0
  27. package/dist/v2/runtime/core/fetch-handler.d.mts.map +1 -1
  28. package/dist/v2/runtime/core/fetch-handler.mjs +5 -0
  29. package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
  30. package/dist/v2/runtime/core/runtime.cjs +16 -4
  31. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  32. package/dist/v2/runtime/core/runtime.d.cts +43 -17
  33. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  34. package/dist/v2/runtime/core/runtime.d.mts +43 -17
  35. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  36. package/dist/v2/runtime/core/runtime.mjs +16 -4
  37. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  38. package/dist/v2/runtime/endpoints/auto-start-channels.cjs +47 -0
  39. package/dist/v2/runtime/endpoints/auto-start-channels.cjs.map +1 -0
  40. package/dist/v2/runtime/endpoints/auto-start-channels.mjs +46 -0
  41. package/dist/v2/runtime/endpoints/auto-start-channels.mjs.map +1 -0
  42. package/dist/v2/runtime/endpoints/express.cjs +2 -0
  43. package/dist/v2/runtime/endpoints/express.cjs.map +1 -1
  44. package/dist/v2/runtime/endpoints/express.d.cts +9 -8
  45. package/dist/v2/runtime/endpoints/express.d.cts.map +1 -1
  46. package/dist/v2/runtime/endpoints/express.d.mts +9 -8
  47. package/dist/v2/runtime/endpoints/express.d.mts.map +1 -1
  48. package/dist/v2/runtime/endpoints/express.mjs +2 -0
  49. package/dist/v2/runtime/endpoints/express.mjs.map +1 -1
  50. package/dist/v2/runtime/endpoints/hono.cjs.map +1 -1
  51. package/dist/v2/runtime/endpoints/hono.d.cts +14 -5
  52. package/dist/v2/runtime/endpoints/hono.d.cts.map +1 -1
  53. package/dist/v2/runtime/endpoints/hono.d.mts +14 -5
  54. package/dist/v2/runtime/endpoints/hono.d.mts.map +1 -1
  55. package/dist/v2/runtime/endpoints/hono.mjs.map +1 -1
  56. package/dist/v2/runtime/endpoints/node.cjs +2 -0
  57. package/dist/v2/runtime/endpoints/node.cjs.map +1 -1
  58. package/dist/v2/runtime/endpoints/node.d.cts +23 -13
  59. package/dist/v2/runtime/endpoints/node.d.cts.map +1 -1
  60. package/dist/v2/runtime/endpoints/node.d.mts +23 -13
  61. package/dist/v2/runtime/endpoints/node.d.mts.map +1 -1
  62. package/dist/v2/runtime/endpoints/node.mjs +2 -0
  63. package/dist/v2/runtime/endpoints/node.mjs.map +1 -1
  64. package/dist/v2/runtime/handlers/get-runtime-info.cjs +9 -8
  65. package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
  66. package/dist/v2/runtime/handlers/get-runtime-info.mjs +9 -8
  67. package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
  68. package/dist/v2/runtime/handlers/handle-run.cjs +2 -1
  69. package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
  70. package/dist/v2/runtime/handlers/handle-run.mjs +2 -1
  71. package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
  72. package/dist/v2/runtime/handlers/intelligence/memories.cjs +37 -38
  73. package/dist/v2/runtime/handlers/intelligence/memories.cjs.map +1 -1
  74. package/dist/v2/runtime/handlers/intelligence/memories.mjs +37 -38
  75. package/dist/v2/runtime/handlers/intelligence/memories.mjs.map +1 -1
  76. package/dist/v2/runtime/handlers/shared/agent-utils.cjs +11 -5
  77. package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  78. package/dist/v2/runtime/handlers/shared/agent-utils.mjs +11 -5
  79. package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  80. package/dist/v2/runtime/handlers/shared/memory-policy.cjs +41 -0
  81. package/dist/v2/runtime/handlers/shared/memory-policy.cjs.map +1 -0
  82. package/dist/v2/runtime/handlers/shared/memory-policy.mjs +41 -0
  83. package/dist/v2/runtime/handlers/shared/memory-policy.mjs.map +1 -0
  84. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs +8 -0
  85. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
  86. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs +8 -0
  87. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
  88. package/dist/v2/runtime/index.d.cts +1 -1
  89. package/dist/v2/runtime/index.d.mts +1 -1
  90. package/dist/v2/runtime/intelligence-platform/client.cjs +46 -8
  91. package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
  92. package/dist/v2/runtime/intelligence-platform/client.d.cts +46 -5
  93. package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
  94. package/dist/v2/runtime/intelligence-platform/client.d.mts +46 -5
  95. package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
  96. package/dist/v2/runtime/intelligence-platform/client.mjs +46 -9
  97. package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
  98. package/dist/v2/runtime/runner/agent-runner.cjs.map +1 -1
  99. package/dist/v2/runtime/runner/agent-runner.d.cts +4 -0
  100. package/dist/v2/runtime/runner/agent-runner.d.cts.map +1 -1
  101. package/dist/v2/runtime/runner/agent-runner.d.mts +4 -0
  102. package/dist/v2/runtime/runner/agent-runner.d.mts.map +1 -1
  103. package/dist/v2/runtime/runner/agent-runner.mjs.map +1 -1
  104. package/dist/v2/runtime/runner/in-memory.cjs +3 -5
  105. package/dist/v2/runtime/runner/in-memory.cjs.map +1 -1
  106. package/dist/v2/runtime/runner/in-memory.d.cts.map +1 -1
  107. package/dist/v2/runtime/runner/in-memory.d.mts.map +1 -1
  108. package/dist/v2/runtime/runner/in-memory.mjs +3 -5
  109. package/dist/v2/runtime/runner/in-memory.mjs.map +1 -1
  110. package/dist/v2/runtime/runner/intelligence.cjs +38 -31
  111. package/dist/v2/runtime/runner/intelligence.cjs.map +1 -1
  112. package/dist/v2/runtime/runner/intelligence.d.cts.map +1 -1
  113. package/dist/v2/runtime/runner/intelligence.d.mts.map +1 -1
  114. package/dist/v2/runtime/runner/intelligence.mjs +38 -31
  115. package/dist/v2/runtime/runner/intelligence.mjs.map +1 -1
  116. package/package.json +6 -6
package/README.md CHANGED
@@ -55,6 +55,41 @@
55
55
 
56
56
  To get started with CopilotKit, please check out the [documentation](https://docs.copilotkit.ai).
57
57
 
58
+ ## Intelligence identity and Memory
59
+
60
+ An Intelligence Runtime supports web only, Channels only, or both. Web routes
61
+ need `identifyUser(request)`. Each Channel has its own `identifyUser` policy in
62
+ `createChannel`. A Channels-only Runtime omits the web callback and exposes no
63
+ functional web routes.
64
+
65
+ ```ts
66
+ const runtime = new CopilotRuntime({
67
+ agents,
68
+ intelligence,
69
+ identifyUser: authenticateApplicationUser,
70
+ channels: [supportChannel],
71
+ memory: {
72
+ access: async ({ request, user, consumer }) => {
73
+ const role = await roleFor(request, user);
74
+ if (role === "blocked") return null;
75
+ return consumer === "client"
76
+ ? { user: "read", project: "none" }
77
+ : { user: "read-write", project: "read" };
78
+ },
79
+ },
80
+ });
81
+ ```
82
+
83
+ The callback runs once per web request. Its user owns ordinary web Threads and
84
+ is reused for agent and browser Memory policy. Adding `memory` exposes the
85
+ browser Memory routes and agent tools under the same policy. A denial returns
86
+ 403; a policy error fails the request. Omitting `memory` hides the browser
87
+ routes and does not attach Memory tools.
88
+
89
+ `exposeMemoryRoutes` and
90
+ `CopilotKitIntelligence({ enableEnterpriseLearning: true })` remain for one
91
+ compatibility window. New code should use `memory.access`.
92
+
58
93
  ## Analytics & Privacy
59
94
 
60
95
  CopilotKit uses [Scarf](https://scarf.sh) for anonymous usage analytics to help improve the product. Scarf handles all privacy compliance and does not store raw IP addresses. This helps us understand how CopilotKit is being used and prioritize improvements.
package/dist/package.cjs CHANGED
@@ -5,7 +5,7 @@ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
5
5
  var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
6
6
  module.exports = {
7
7
  "name": "@copilotkit/runtime",
8
- "version": "1.64.2-canary.rc-1",
8
+ "version": "1.64.3-canary.1785623356",
9
9
  "private": false,
10
10
  "keywords": [
11
11
  "ai",
@@ -5,7 +5,7 @@ import { __commonJSMin } from "../_virtual/_rolldown/runtime.mjs";
5
5
  var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
6
6
  module.exports = {
7
7
  "name": "@copilotkit/runtime",
8
- "version": "1.64.2-canary.rc-1",
8
+ "version": "1.64.3-canary.1785623356",
9
9
  "private": false,
10
10
  "keywords": [
11
11
  "ai",
@@ -2,7 +2,7 @@ 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, CopilotRuntimeConstructor, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, OpenGenerativeUIConfig, OpenGenerativeUIOptions, RuntimeWithDeclaredChannels, VERSION, isA2UIEnabled, isIntelligenceRuntime, resolveAgents } from "./runtime/core/runtime.cjs";
5
+ import { AgentFactoryContext, AgentsConfig, AgentsFactory, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeLike, CopilotRuntimeMemoryConfig, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, MemoryAccess, MemoryConsumer, MemoryGrant, 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
8
  import { ChannelStatus, ChannelsControl } from "./runtime/core/channel-manager.cjs";
@@ -18,4 +18,4 @@ import { CopilotKitRequestHandler, MCPClient, MCPTransport } from "./runtime/ind
18
18
  import { convertAISDKStream } from "../agent/converters/aisdk.cjs";
19
19
  import { TanStackChatMessage, TanStackInputResult, convertInputToTanStackAI, convertTanStackStream } from "../agent/converters/tanstack.cjs";
20
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";
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 };
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, CopilotRuntimeMemoryConfig, 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, MemoryAccess, MemoryConsumer, MemoryGrant, 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,7 +2,7 @@ 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, CopilotRuntimeConstructor, CopilotRuntimeLike, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, OpenGenerativeUIConfig, OpenGenerativeUIOptions, RuntimeWithDeclaredChannels, VERSION, isA2UIEnabled, isIntelligenceRuntime, resolveAgents } from "./runtime/core/runtime.mjs";
5
+ import { AgentFactoryContext, AgentsConfig, AgentsFactory, CopilotIntelligenceRuntime, CopilotIntelligenceRuntimeLike, CopilotIntelligenceRuntimeOptions, CopilotRuntime, CopilotRuntimeConstructor, CopilotRuntimeLike, CopilotRuntimeMemoryConfig, CopilotRuntimeOptions, CopilotRuntimeUser, CopilotSseRuntime, CopilotSseRuntimeLike, CopilotSseRuntimeOptions, IdentifyUserCallback, McpAppsConfig, McpAppsServerConfig, MemoryAccess, MemoryConsumer, MemoryGrant, 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
8
  import { ChannelStatus, ChannelsControl } from "./runtime/core/channel-manager.mjs";
@@ -18,4 +18,4 @@ import { CopilotKitRequestHandler, MCPClient, MCPTransport } from "./runtime/ind
18
18
  import { convertAISDKStream } from "../agent/converters/aisdk.mjs";
19
19
  import { TanStackChatMessage, TanStackInputResult, convertInputToTanStackAI, convertTanStackStream } from "../agent/converters/tanstack.mjs";
20
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";
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 };
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, CopilotRuntimeMemoryConfig, 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, MemoryAccess, MemoryConsumer, MemoryGrant, 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 };
@@ -41,7 +41,7 @@ function parseProjectIdFromApiKey(apiKey) {
41
41
  * @param args.intelligence - The Intelligence runtime client to pull the
42
42
  * runner websocket URL and auth token from.
43
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.
44
+ * `showToolStatus` optionally overrides managed tool-call visibility.
45
45
  * @param args.runtimeInstanceId - Identifier for the activating runtime
46
46
  * instance, passed through unchanged.
47
47
  * @returns The resolved {@link ChannelActivationConfig}.
@@ -49,14 +49,10 @@ function parseProjectIdFromApiKey(apiKey) {
49
49
  * parseable, strictly-positive project id, or if `channel.name` is
50
50
  * missing/empty.
51
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).
52
+ * Provider declarations do not belong in this per-Channel config. One managed
53
+ * activation declares every supported managed provider over its single control
54
+ * connection; the Intelligence gateway selects the provider from each trusted
55
+ * prepared delivery.
60
56
  *
61
57
  * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the
62
58
  * reserved-name rule are NOT re-checked here. Their single source of truth is
@@ -71,18 +67,17 @@ function deriveChannelActivationConfig(args) {
71
67
  const { intelligence, channel, runtimeInstanceId } = args;
72
68
  if (!channel.name) throw new ChannelConfigError("Channel is missing a `name` — pass createChannel({ name }) to activate it.");
73
69
  const channelName = channel.name;
74
- const wsUrl = intelligence.ɵgetRunnerWsUrl();
70
+ const wsUrl = intelligence.ɵgetChannelsWsUrl();
75
71
  const apiUrl = intelligence.ɵgetApiUrl();
76
72
  const apiKey = intelligence.ɵgetRunnerAuthToken();
77
- const projectId = parseProjectIdFromApiKey(apiKey);
78
- const trimmedProvider = channel.provider?.trim();
79
73
  return {
80
74
  wsUrl,
81
75
  apiUrl,
82
76
  apiKey,
83
- projectId,
77
+ projectId: parseProjectIdFromApiKey(apiKey),
84
78
  channelName,
85
- adapter: trimmedProvider ? trimmedProvider : "slack",
79
+ ...channel.showToolStatus !== void 0 ? { showToolStatus: channel.showToolStatus } : {},
80
+ ...channel.replyContinuation !== void 0 ? { replyContinuation: channel.replyContinuation } : {},
86
81
  runtimeInstanceId
87
82
  };
88
83
  }
@@ -1 +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"}
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, ReplyContinuationOptions } 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 * Optional per-Channel override for visible managed tool-call progress.\n * Unset Slack routes default to hidden; other providers retain their existing\n * default.\n */\n showToolStatus?: boolean;\n /**\n * Optional per-Channel tuning for splitting a long reply across continuation\n * messages. Unset leaves the provider renderer's defaults in place.\n */\n replyContinuation?: ReplyContinuationOptions;\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 * `showToolStatus` optionally overrides managed tool-call visibility.\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 * Provider declarations do not belong in this per-Channel config. One managed\n * activation declares every supported managed provider over its single control\n * connection; the Intelligence gateway selects the provider from each trusted\n * prepared delivery.\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.ɵgetChannelsWsUrl();\n const apiUrl = intelligence.ɵgetApiUrl();\n const apiKey = intelligence.ɵgetRunnerAuthToken();\n const projectId = parseProjectIdFromApiKey(apiKey);\n\n return {\n wsUrl,\n apiUrl,\n apiKey,\n projectId,\n channelName,\n ...(channel.showToolStatus !== undefined\n ? { showToolStatus: channel.showToolStatus }\n : {}),\n ...(channel.replyContinuation !== undefined\n ? { replyContinuation: channel.replyContinuation }\n : {}),\n runtimeInstanceId,\n };\n}\n"],"mappings":";;;;;;;;AAUA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;;AAsChB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCT,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,mBAAmB;CAC9C,MAAM,SAAS,aAAa,YAAY;CACxC,MAAM,SAAS,aAAa,qBAAqB;AAGjD,QAAO;EACL;EACA;EACA;EACA,WANgB,yBAAyB,OAAO;EAOhD;EACA,GAAI,QAAQ,mBAAmB,SAC3B,EAAE,gBAAgB,QAAQ,gBAAgB,GAC1C,EAAE;EACN,GAAI,QAAQ,sBAAsB,SAC9B,EAAE,mBAAmB,QAAQ,mBAAmB,GAChD,EAAE;EACN;EACD"}
@@ -1,4 +1,6 @@
1
1
  require("reflect-metadata");
2
+ import { index_d_exports } from "../../../channels/dist/index.cjs";
3
+
2
4
  //#region src/v2/runtime/core/channel-activation-config.d.ts
3
5
  /**
4
6
  * Resolved configuration needed to activate a single Channel against a
@@ -19,13 +21,16 @@ interface ChannelActivationConfig {
19
21
  /** The Channel's declared name (`createChannel({ name })`). */
20
22
  channelName: string;
21
23
  /**
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.
24
+ * Optional per-Channel override for visible managed tool-call progress.
25
+ * Unset Slack routes default to hidden; other providers retain their existing
26
+ * default.
27
27
  */
28
- adapter: string;
28
+ showToolStatus?: boolean;
29
+ /**
30
+ * Optional per-Channel tuning for splitting a long reply across continuation
31
+ * messages. Unset leaves the provider renderer's defaults in place.
32
+ */
33
+ replyContinuation?: index_d_exports.ReplyContinuationOptions;
29
34
  /** Identifier for the runtime instance activating this Channel. */
30
35
  runtimeInstanceId: string;
31
36
  }
@@ -1 +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"}
1
+ {"version":3,"file":"channel-activation-config.d.cts","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"mappings":";;;;;;;;UAqBiB,uBAAA;EA0Bf;EAxBA,KAAA;EAwBiB;EAtBjB,MAAA;;;;;EAKA,MAAA;;EAEA,SAAA;;EAEA,WAAA;;;;;;EAMA,cAAA;;;;;EAKA,iBAAA,GAAoB,eAAA,CAAA,wBAAA;;EAEpB,iBAAA;AAAA"}
@@ -1,4 +1,6 @@
1
1
  import "reflect-metadata";
2
+ import { index_d_exports } from "../../../channels/dist/index.mjs";
3
+
2
4
  //#region src/v2/runtime/core/channel-activation-config.d.ts
3
5
  /**
4
6
  * Resolved configuration needed to activate a single Channel against a
@@ -19,13 +21,16 @@ interface ChannelActivationConfig {
19
21
  /** The Channel's declared name (`createChannel({ name })`). */
20
22
  channelName: string;
21
23
  /**
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.
24
+ * Optional per-Channel override for visible managed tool-call progress.
25
+ * Unset Slack routes default to hidden; other providers retain their existing
26
+ * default.
27
27
  */
28
- adapter: string;
28
+ showToolStatus?: boolean;
29
+ /**
30
+ * Optional per-Channel tuning for splitting a long reply across continuation
31
+ * messages. Unset leaves the provider renderer's defaults in place.
32
+ */
33
+ replyContinuation?: index_d_exports.ReplyContinuationOptions;
29
34
  /** Identifier for the runtime instance activating this Channel. */
30
35
  runtimeInstanceId: string;
31
36
  }
@@ -1 +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"}
1
+ {"version":3,"file":"channel-activation-config.d.mts","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"mappings":";;;;;;;;UAqBiB,uBAAA;EA0Bf;EAxBA,KAAA;EAwBiB;EAtBjB,MAAA;;;;;EAKA,MAAA;;EAEA,SAAA;;EAEA,WAAA;;;;;;EAMA,cAAA;;;;;EAKA,iBAAA,GAAoB,eAAA,CAAA,wBAAA;;EAEpB,iBAAA;AAAA"}
@@ -40,7 +40,7 @@ function parseProjectIdFromApiKey(apiKey) {
40
40
  * @param args.intelligence - The Intelligence runtime client to pull the
41
41
  * runner websocket URL and auth token from.
42
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.
43
+ * `showToolStatus` optionally overrides managed tool-call visibility.
44
44
  * @param args.runtimeInstanceId - Identifier for the activating runtime
45
45
  * instance, passed through unchanged.
46
46
  * @returns The resolved {@link ChannelActivationConfig}.
@@ -48,14 +48,10 @@ function parseProjectIdFromApiKey(apiKey) {
48
48
  * parseable, strictly-positive project id, or if `channel.name` is
49
49
  * missing/empty.
50
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).
51
+ * Provider declarations do not belong in this per-Channel config. One managed
52
+ * activation declares every supported managed provider over its single control
53
+ * connection; the Intelligence gateway selects the provider from each trusted
54
+ * prepared delivery.
59
55
  *
60
56
  * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the
61
57
  * reserved-name rule are NOT re-checked here. Their single source of truth is
@@ -70,18 +66,17 @@ function deriveChannelActivationConfig(args) {
70
66
  const { intelligence, channel, runtimeInstanceId } = args;
71
67
  if (!channel.name) throw new ChannelConfigError("Channel is missing a `name` — pass createChannel({ name }) to activate it.");
72
68
  const channelName = channel.name;
73
- const wsUrl = intelligence.ɵgetRunnerWsUrl();
69
+ const wsUrl = intelligence.ɵgetChannelsWsUrl();
74
70
  const apiUrl = intelligence.ɵgetApiUrl();
75
71
  const apiKey = intelligence.ɵgetRunnerAuthToken();
76
- const projectId = parseProjectIdFromApiKey(apiKey);
77
- const trimmedProvider = channel.provider?.trim();
78
72
  return {
79
73
  wsUrl,
80
74
  apiUrl,
81
75
  apiKey,
82
- projectId,
76
+ projectId: parseProjectIdFromApiKey(apiKey),
83
77
  channelName,
84
- adapter: trimmedProvider ? trimmedProvider : "slack",
78
+ ...channel.showToolStatus !== void 0 ? { showToolStatus: channel.showToolStatus } : {},
79
+ ...channel.replyContinuation !== void 0 ? { replyContinuation: channel.replyContinuation } : {},
85
80
  runtimeInstanceId
86
81
  };
87
82
  }
@@ -1 +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"}
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, ReplyContinuationOptions } 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 * Optional per-Channel override for visible managed tool-call progress.\n * Unset Slack routes default to hidden; other providers retain their existing\n * default.\n */\n showToolStatus?: boolean;\n /**\n * Optional per-Channel tuning for splitting a long reply across continuation\n * messages. Unset leaves the provider renderer's defaults in place.\n */\n replyContinuation?: ReplyContinuationOptions;\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 * `showToolStatus` optionally overrides managed tool-call visibility.\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 * Provider declarations do not belong in this per-Channel config. One managed\n * activation declares every supported managed provider over its single control\n * connection; the Intelligence gateway selects the provider from each trusted\n * prepared delivery.\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.ɵgetChannelsWsUrl();\n const apiUrl = intelligence.ɵgetApiUrl();\n const apiKey = intelligence.ɵgetRunnerAuthToken();\n const projectId = parseProjectIdFromApiKey(apiKey);\n\n return {\n wsUrl,\n apiUrl,\n apiKey,\n projectId,\n channelName,\n ...(channel.showToolStatus !== undefined\n ? { showToolStatus: channel.showToolStatus }\n : {}),\n ...(channel.replyContinuation !== undefined\n ? { replyContinuation: channel.replyContinuation }\n : {}),\n runtimeInstanceId,\n };\n}\n"],"mappings":";;;;;;;AAUA,IAAa,qBAAb,cAAwC,MAAM;CAC5C,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;;AAsChB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgCT,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,mBAAmB;CAC9C,MAAM,SAAS,aAAa,YAAY;CACxC,MAAM,SAAS,aAAa,qBAAqB;AAGjD,QAAO;EACL;EACA;EACA;EACA,WANgB,yBAAyB,OAAO;EAOhD;EACA,GAAI,QAAQ,mBAAmB,SAC3B,EAAE,gBAAgB,QAAQ,gBAAgB,GAC1C,EAAE;EACN,GAAI,QAAQ,sBAAsB,SAC9B,EAAE,mBAAmB,QAAQ,mBAAmB,GAChD,EAAE;EACN;EACD"}