@copilotkit/runtime 1.64.2 → 1.64.3-canary.1785633429

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 (68) 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 +6 -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 +0 -8
  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 +0 -8
  11. package/dist/v2/runtime/core/channel-activation-config.d.mts.map +1 -1
  12. package/dist/v2/runtime/core/channel-activation-config.mjs +6 -14
  13. package/dist/v2/runtime/core/channel-activation-config.mjs.map +1 -1
  14. package/dist/v2/runtime/core/channel-manager.cjs +62 -107
  15. package/dist/v2/runtime/core/channel-manager.cjs.map +1 -1
  16. package/dist/v2/runtime/core/channel-manager.d.cts +4 -15
  17. package/dist/v2/runtime/core/channel-manager.d.cts.map +1 -1
  18. package/dist/v2/runtime/core/channel-manager.d.mts +4 -15
  19. package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
  20. package/dist/v2/runtime/core/channel-manager.mjs +62 -107
  21. package/dist/v2/runtime/core/channel-manager.mjs.map +1 -1
  22. package/dist/v2/runtime/core/fetch-handler.cjs +1 -0
  23. package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
  24. package/dist/v2/runtime/core/fetch-handler.mjs +1 -0
  25. package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
  26. package/dist/v2/runtime/core/runtime.cjs +16 -4
  27. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  28. package/dist/v2/runtime/core/runtime.d.cts +43 -17
  29. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  30. package/dist/v2/runtime/core/runtime.d.mts +43 -17
  31. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  32. package/dist/v2/runtime/core/runtime.mjs +16 -4
  33. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  34. package/dist/v2/runtime/handlers/get-runtime-info.cjs +9 -8
  35. package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
  36. package/dist/v2/runtime/handlers/get-runtime-info.mjs +9 -8
  37. package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
  38. package/dist/v2/runtime/handlers/handle-run.cjs +2 -1
  39. package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
  40. package/dist/v2/runtime/handlers/handle-run.mjs +2 -1
  41. package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
  42. package/dist/v2/runtime/handlers/intelligence/memories.cjs +37 -38
  43. package/dist/v2/runtime/handlers/intelligence/memories.cjs.map +1 -1
  44. package/dist/v2/runtime/handlers/intelligence/memories.mjs +37 -38
  45. package/dist/v2/runtime/handlers/intelligence/memories.mjs.map +1 -1
  46. package/dist/v2/runtime/handlers/shared/agent-utils.cjs +11 -5
  47. package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  48. package/dist/v2/runtime/handlers/shared/agent-utils.mjs +11 -5
  49. package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  50. package/dist/v2/runtime/handlers/shared/memory-policy.cjs +41 -0
  51. package/dist/v2/runtime/handlers/shared/memory-policy.cjs.map +1 -0
  52. package/dist/v2/runtime/handlers/shared/memory-policy.mjs +41 -0
  53. package/dist/v2/runtime/handlers/shared/memory-policy.mjs.map +1 -0
  54. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs +8 -0
  55. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
  56. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs +8 -0
  57. package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
  58. package/dist/v2/runtime/index.d.cts +1 -1
  59. package/dist/v2/runtime/index.d.mts +1 -1
  60. package/dist/v2/runtime/intelligence-platform/client.cjs +13 -6
  61. package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
  62. package/dist/v2/runtime/intelligence-platform/client.d.cts +32 -2
  63. package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
  64. package/dist/v2/runtime/intelligence-platform/client.d.mts +32 -2
  65. package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
  66. package/dist/v2/runtime/intelligence-platform/client.mjs +13 -7
  67. package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
  68. package/package.json +7 -7
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",
8
+ "version": "1.64.3-canary.1785633429",
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",
8
+ "version": "1.64.3-canary.1785633429",
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,8 +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,
45
- * and `showToolStatus` optionally overrides managed tool-call visibility.
44
+ * `showToolStatus` optionally overrides managed tool-call visibility.
46
45
  * @param args.runtimeInstanceId - Identifier for the activating runtime
47
46
  * instance, passed through unchanged.
48
47
  * @returns The resolved {@link ChannelActivationConfig}.
@@ -50,14 +49,10 @@ function parseProjectIdFromApiKey(apiKey) {
50
49
  * parseable, strictly-positive project id, or if `channel.name` is
51
50
  * missing/empty.
52
51
  *
53
- * The managed provider is a PER-CHANNEL choice read from `channel.provider`, so
54
- * one runtime can activate a Slack-backed Channel and a Teams-backed Channel
55
- * side by side. When `channel.provider` is unset the config adapter defaults to
56
- * `"slack"` — an explicit, documented default, not a silent global. The SDK
57
- * only DECLARES this provider to the Intelligence gateway on join; the gateway
58
- * resolves the actual connection and is the authority on which providers it
59
- * accepts (it accepts only `"slack"` today — Teams gateway support is tracked
60
- * 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.
61
56
  *
62
57
  * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the
63
58
  * reserved-name rule are NOT re-checked here. Their single source of truth is
@@ -75,15 +70,12 @@ function deriveChannelActivationConfig(args) {
75
70
  const wsUrl = intelligence.ɵgetChannelsWsUrl();
76
71
  const apiUrl = intelligence.ɵgetApiUrl();
77
72
  const apiKey = intelligence.ɵgetRunnerAuthToken();
78
- const projectId = parseProjectIdFromApiKey(apiKey);
79
- const trimmedProvider = channel.provider?.trim();
80
73
  return {
81
74
  wsUrl,
82
75
  apiUrl,
83
76
  apiKey,
84
- projectId,
77
+ projectId: parseProjectIdFromApiKey(apiKey),
85
78
  channelName,
86
- adapter: trimmedProvider ? trimmedProvider : "slack",
87
79
  ...channel.showToolStatus !== void 0 ? { showToolStatus: channel.showToolStatus } : {},
88
80
  ...channel.replyContinuation !== void 0 ? { replyContinuation: channel.replyContinuation } : {},
89
81
  runtimeInstanceId
@@ -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, 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 * 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 /**\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 * per-Channel `provider` selects the managed adapter declared to the gateway,\n * and `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 * 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.ɵgetChannelsWsUrl();\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 ...(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;;;;AA8ChB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCT,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;CACjD,MAAM,YAAY,yBAAyB,OAAO;CAUlD,MAAM,kBAAkB,QAAQ,UAAU,MAAM;AAEhD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,SAAS,kBAAkB,kBAAkB;EAC7C,GAAI,QAAQ,mBAAmB,SAC3B,EAAE,gBAAgB,QAAQ,gBAAgB,GAC1C,EAAE;EACN,GAAI,QAAQ,sBAAsB,SAC9B,EAAE,mBAAmB,QAAQ,mBAAmB,GAChD,EAAE;EACN;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"}
@@ -20,14 +20,6 @@ interface ChannelActivationConfig {
20
20
  projectId: number;
21
21
  /** The Channel's declared name (`createChannel({ name })`). */
22
22
  channelName: string;
23
- /**
24
- * The managed provider this Channel declares to the Intelligence gateway on
25
- * join, resolved from the Channel's per-Channel `provider` (e.g. `"slack"` or
26
- * `"teams"`), defaulting to `"slack"`. Named `adapter` because that is the
27
- * field the gateway's join payload expects; the gateway resolves the actual
28
- * connection for the declared provider.
29
- */
30
- adapter: string;
31
23
  /**
32
24
  * Optional per-Channel override for visible managed tool-call progress.
33
25
  * Unset Slack routes default to hidden; other providers retain their existing
@@ -1 +1 @@
1
- {"version":3,"file":"channel-activation-config.d.cts","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"mappings":";;;;;;;;UAqBiB,uBAAA;EAgCK;EA9BpB,KAAA;EAgCiB;EA9BjB,MAAA;;;;;EAKA,MAAA;;EAEA,SAAA;;EAEA,WAAA;;;;;;;;EAQA,OAAA;;;;;;EAMA,cAAA;;;;;EAKA,iBAAA,GAAoB,eAAA,CAAA,wBAAA;;EAEpB,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"}
@@ -20,14 +20,6 @@ interface ChannelActivationConfig {
20
20
  projectId: number;
21
21
  /** The Channel's declared name (`createChannel({ name })`). */
22
22
  channelName: string;
23
- /**
24
- * The managed provider this Channel declares to the Intelligence gateway on
25
- * join, resolved from the Channel's per-Channel `provider` (e.g. `"slack"` or
26
- * `"teams"`), defaulting to `"slack"`. Named `adapter` because that is the
27
- * field the gateway's join payload expects; the gateway resolves the actual
28
- * connection for the declared provider.
29
- */
30
- adapter: string;
31
23
  /**
32
24
  * Optional per-Channel override for visible managed tool-call progress.
33
25
  * Unset Slack routes default to hidden; other providers retain their existing
@@ -1 +1 @@
1
- {"version":3,"file":"channel-activation-config.d.mts","names":[],"sources":["../../../../src/v2/runtime/core/channel-activation-config.ts"],"mappings":";;;;;;;;UAqBiB,uBAAA;EAgCK;EA9BpB,KAAA;EAgCiB;EA9BjB,MAAA;;;;;EAKA,MAAA;;EAEA,SAAA;;EAEA,WAAA;;;;;;;;EAQA,OAAA;;;;;;EAMA,cAAA;;;;;EAKA,iBAAA,GAAoB,eAAA,CAAA,wBAAA;;EAEpB,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,8 +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,
44
- * and `showToolStatus` optionally overrides managed tool-call visibility.
43
+ * `showToolStatus` optionally overrides managed tool-call visibility.
45
44
  * @param args.runtimeInstanceId - Identifier for the activating runtime
46
45
  * instance, passed through unchanged.
47
46
  * @returns The resolved {@link ChannelActivationConfig}.
@@ -49,14 +48,10 @@ function parseProjectIdFromApiKey(apiKey) {
49
48
  * parseable, strictly-positive project id, or if `channel.name` is
50
49
  * missing/empty.
51
50
  *
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).
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.
60
55
  *
61
56
  * The Channel-name FORMAT rules (lowercase kebab-case, 3–64 chars) and the
62
57
  * reserved-name rule are NOT re-checked here. Their single source of truth is
@@ -74,15 +69,12 @@ function deriveChannelActivationConfig(args) {
74
69
  const wsUrl = intelligence.ɵgetChannelsWsUrl();
75
70
  const apiUrl = intelligence.ɵgetApiUrl();
76
71
  const apiKey = intelligence.ɵgetRunnerAuthToken();
77
- const projectId = parseProjectIdFromApiKey(apiKey);
78
- const trimmedProvider = channel.provider?.trim();
79
72
  return {
80
73
  wsUrl,
81
74
  apiUrl,
82
75
  apiKey,
83
- projectId,
76
+ projectId: parseProjectIdFromApiKey(apiKey),
84
77
  channelName,
85
- adapter: trimmedProvider ? trimmedProvider : "slack",
86
78
  ...channel.showToolStatus !== void 0 ? { showToolStatus: channel.showToolStatus } : {},
87
79
  ...channel.replyContinuation !== void 0 ? { replyContinuation: channel.replyContinuation } : {},
88
80
  runtimeInstanceId
@@ -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, 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 * 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 /**\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 * per-Channel `provider` selects the managed adapter declared to the gateway,\n * and `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 * 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.ɵgetChannelsWsUrl();\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 ...(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;;;;AA8ChB,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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAqCT,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;CACjD,MAAM,YAAY,yBAAyB,OAAO;CAUlD,MAAM,kBAAkB,QAAQ,UAAU,MAAM;AAEhD,QAAO;EACL;EACA;EACA;EACA;EACA;EACA,SAAS,kBAAkB,kBAAkB;EAC7C,GAAI,QAAQ,mBAAmB,SAC3B,EAAE,gBAAgB,QAAQ,gBAAgB,GAC1C,EAAE;EACN,GAAI,QAAQ,sBAAsB,SAC9B,EAAE,mBAAmB,QAAQ,mBAAmB,GAChD,EAAE;EACN;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"}
@@ -1,9 +1,11 @@
1
1
  require("reflect-metadata");
2
2
  const require_runtime = require('../../../_virtual/_rolldown/runtime.cjs');
3
3
  const require_channel_activation_config = require('./channel-activation-config.cjs');
4
+ const require_client = require('../intelligence-platform/client.cjs');
4
5
  let rxjs = require("rxjs");
5
6
  let node_crypto = require("node:crypto");
6
7
  let _ag_ui_client = require("@ag-ui/client");
8
+ let _ag_ui_mcp_middleware = require("@ag-ui/mcp-middleware");
7
9
 
8
10
  //#region src/v2/runtime/core/channel-manager.ts
9
11
  /**
@@ -65,7 +67,6 @@ async function defaultActivateChannel(config, channel, importChannelsIntelligenc
65
67
  channelName: config.channelName
66
68
  },
67
69
  runtimeInstanceId: config.runtimeInstanceId,
68
- adapter: config.adapter,
69
70
  ...config.showToolStatus !== void 0 ? { showToolStatus: config.showToolStatus } : {},
70
71
  ...config.replyContinuation !== void 0 ? { replyContinuation: config.replyContinuation } : {},
71
72
  appApiBaseUrl: config.apiUrl,
@@ -81,6 +82,27 @@ async function defaultActivateChannel(config, channel, importChannelsIntelligenc
81
82
  }
82
83
  });
83
84
  }
85
+ /** Attach grant-scoped Intelligence Memory tools to one isolated Channel agent. */
86
+ function attachChannelMemory(agent, intelligence, memory) {
87
+ if (!memory) return;
88
+ const middlewareAgent = agent;
89
+ if (typeof middlewareAgent.use !== "function") {
90
+ const error = /* @__PURE__ */ new Error("Channel Memory requires an agent with middleware support");
91
+ error.name = "ChannelMemoryAgentUnsupportedError";
92
+ error.code = "channel_memory_agent_unsupported";
93
+ throw error;
94
+ }
95
+ middlewareAgent.use(new _ag_ui_mcp_middleware.MCPMiddleware([{
96
+ type: "http",
97
+ url: `${intelligence.ɵgetApiUrl()}/mcp`,
98
+ serverId: "intelligence",
99
+ headers: {
100
+ Authorization: `Bearer ${intelligence.ɵgetApiKey()}`,
101
+ [require_client.INTELLIGENCE_MEMORY_GRANT_HEADER]: JSON.stringify(memory.grant),
102
+ ...memory.user ? { [require_client.INTELLIGENCE_USER_ID_HEADER]: memory.user.id } : {}
103
+ }
104
+ }]));
105
+ }
84
106
  /** One outer agent that lets the standard runner own the whole local tool loop. */
85
107
  var ChannelOuterAgent = class extends _ag_ui_client.AbstractAgent {
86
108
  constructor(inner, canonicalThreadId, executeLoop) {
@@ -128,6 +150,7 @@ async function runCanonicalChannelAgent(runner, intelligence, lockTtlSeconds, lo
128
150
  iterations: 0,
129
151
  interrupted: false
130
152
  };
153
+ attachChannelMemory(args.agent, intelligence, args.memory);
131
154
  const outer = new ChannelOuterAgent(args.agent, canonicalThreadId, async (subscriber, canonicalRun) => {
132
155
  result = await args.execute(subscriber, canonicalRun);
133
156
  return result;
@@ -304,15 +327,10 @@ function withTimeout(inner, timeoutMs, timeoutMessage) {
304
327
  }
305
328
  /**
306
329
  * Drives Channel activation for an Intelligence runtime: lazily activates each
307
- * declared Channel, tracks per-Channel lifecycle status, exposes readiness, and
308
- * tears everything down. A MANAGED Channel (empty `adapters`) is activated
309
- * through the injected engine over the Intelligence gateway; a DIRECT Channel
310
- * (developer-supplied adapter) is started through its own transport seam
311
- * (`channel.ɵruntime.start()`) — driven by the manager, but running only its own
312
- * adapter transport, not the gateway path (direct Channels stay below the
313
- * canonical/reliability layer by design — see {@link ChannelStatus} and OSS-599).
314
- * Its very existence means Intelligence is configured, so there is no
315
- * standalone/self-started path.
330
+ * declared Channel through the managed engine, tracks per-Channel lifecycle
331
+ * status, exposes readiness, and tears everything down. Existing direct
332
+ * adapters remain on the Channel; the launcher attaches the one managed
333
+ * adapter before starting the combined adapter array.
316
334
  *
317
335
  * Activation is lazy and idempotent — constructing the manager does nothing;
318
336
  * {@link activate} starts it and a second call is a no-op. Activation throws
@@ -371,10 +389,7 @@ var ChannelManager = class {
371
389
  this.assertUniqueChannelNames();
372
390
  this.activated = true;
373
391
  for (const channel of this.channels) {
374
- if (channel.adapters.some((a) => !a.__intelligenceChannel)) {
375
- this.startDirectChannel(channel);
376
- continue;
377
- }
392
+ channel.ɵruntime.enableIntelligenceMemory();
378
393
  const name = channel.name;
379
394
  const runtimeInstanceId = this.mintRuntimeInstanceId();
380
395
  let resolveSettled;
@@ -419,6 +434,28 @@ var ChannelManager = class {
419
434
  return;
420
435
  }
421
436
  if (isSetupRequired(err)) {
437
+ if (channel.adapters.some((adapter) => !adapter.__intelligenceChannel)) try {
438
+ await channel.ɵruntime.start();
439
+ entry.handle = {
440
+ metadata: {},
441
+ stop: () => channel.ɵruntime.stop()
442
+ };
443
+ if (this.stopped) {
444
+ await this.stopEntry(entry);
445
+ resolveSettled();
446
+ return;
447
+ }
448
+ } catch (directError) {
449
+ if (this.stopped) {
450
+ await this.stopEntry(entry);
451
+ resolveSettled();
452
+ return;
453
+ }
454
+ entry.status = "error";
455
+ this.log?.(`channel "${name}" failed to start its direct adapters while managed setup is incomplete`, directError);
456
+ rejectSettled(directError);
457
+ return;
458
+ }
422
459
  entry.status = "setup_required";
423
460
  this.log?.(`channel "${name}" requires setup`, err);
424
461
  resolveSettled();
@@ -432,76 +469,6 @@ var ChannelManager = class {
432
469
  }
433
470
  }
434
471
  /**
435
- * Start a DIRECT-adapter Channel through its own transport seam
436
- * ({@link Channel.ɵruntime}`.start()`), recording a live entry so
437
- * {@link ready}/{@link status}/{@link stop} all cover it. A direct Channel is
438
- * driven by the manager — but only because the Intelligence runtime constructed
439
- * this manager at all — and runs its OWN adapter transport, NOT the Intelligence
440
- * gateway path. It is deliberately NOT wired into the gateway/canonical/
441
- * reliability layer — that boundary is permanent, not a deferral (OSS-599).
442
- *
443
- * Mirrors the managed path's settle machinery so teardown resilience is shared:
444
- * the entry's `handle` is a synthetic {@link ChannelsHandle} whose `stop()`
445
- * calls `channel.ɵruntime.stop()`, so the SAME idempotent, bounded, resilient
446
- * {@link stopEntry} that tears down a managed handle tears down a direct Channel
447
- * too. The handle is assigned only AFTER `start()` resolves (exactly as the
448
- * managed path assigns its handle only on resolve), so a `stop()` during a
449
- * still-starting direct Channel returns promptly with nothing to stop and the
450
- * post-settle guard tears down the late transport. A direct Channel exposes no
451
- * managed-session drop signal, so no connection observer is wired and it never
452
- * reaches `reconnecting`.
453
- *
454
- * @param channel - The direct-adapter Channel to start.
455
- */
456
- startDirectChannel(channel) {
457
- const name = channel.name;
458
- this.log?.(`channel "${name}" carries a direct adapter — starting its own transport via channel.ɵruntime.start() (the Intelligence runtime drives its lifecycle; it runs its own adapter transport, NOT the managed gateway path — direct Channels stay below the canonical/reliability layer by design (OSS-599); managed+direct coexistence deferred (OSS-484))`);
459
- let resolveSettled;
460
- let rejectSettled;
461
- const settled = new Promise((resolve, reject) => {
462
- resolveSettled = resolve;
463
- rejectSettled = reject;
464
- });
465
- settled.catch(() => {});
466
- const directHandle = {
467
- metadata: {},
468
- stop: () => channel.ɵruntime.stop()
469
- };
470
- let activation;
471
- try {
472
- activation = channel.ɵruntime.start();
473
- } catch (err) {
474
- activation = Promise.reject(err);
475
- }
476
- const entry = {
477
- status: "connecting",
478
- handle: void 0,
479
- handleStopped: false,
480
- settled
481
- };
482
- activation.then(async () => {
483
- entry.handle = directHandle;
484
- if (this.stopped) {
485
- await this.stopEntry(entry);
486
- resolveSettled();
487
- return;
488
- }
489
- entry.status = "online";
490
- resolveSettled();
491
- }, async (err) => {
492
- if (this.stopped) {
493
- entry.handle = directHandle;
494
- await this.stopEntry(entry);
495
- resolveSettled();
496
- return;
497
- }
498
- entry.status = "error";
499
- this.log?.(`channel "${name}" failed to start its direct transport`, err);
500
- rejectSettled(err);
501
- }).catch(() => {});
502
- this.entries.set(name, entry);
503
- }
504
- /**
505
472
  * Throw if two declared Channels share a `name`. `entries` is keyed by name,
506
473
  * so a duplicate would overwrite the first Channel's entry and leak its live
507
474
  * session. Called at the very start of {@link activate}, before any engine
@@ -520,12 +487,8 @@ var ChannelManager = class {
520
487
  }
521
488
  }
522
489
  /**
523
- * Resolve when every declared Channel — managed OR direct — has settled to
524
- * `online`/`setup_required`.
525
- *
526
- * A direct-adapter Channel is awaited too: its `settled` resolves once its own
527
- * transport is up (`channel.ɵruntime.start()` settling) and rejects if that
528
- * start fails, exactly as a managed Channel's `settled` tracks its activation.
490
+ * Resolve when every declared Channel has settled to
491
+ * `online`/`setup_required` through its managed activation.
529
492
  *
530
493
  * Activates lazily if not already started — so a first call rejects with the
531
494
  * same {@link ChannelConfigError} as the synchronous throw from
@@ -559,17 +522,15 @@ var ChannelManager = class {
559
522
  if (errors.length > 0) throw new AggregateError(errors, `ChannelManager.ready: ${errors.length} channel(s) failed to activate or settle in time`);
560
523
  }
561
524
  /**
562
- * Snapshot status. Every declared Channel managed OR direct — appears keyed
563
- * by name in `channels`; a direct-adapter Channel reads `online` once its own
564
- * transport is up, exactly like a managed one.
525
+ * Snapshot status. Every declared Channel appears keyed by name in
526
+ * `channels` after its combined adapter lifecycle starts.
565
527
  *
566
528
  * `overall` is folded over ALL declared Channels (see {@link computeOverall}),
567
529
  * by precedence `error` > `reconnecting` > `setup_required` > `connecting` >
568
530
  * `online`. `online` means every Channel can currently send. `reconnecting`
569
531
  * outranks `setup_required` because a dropped-but-retrying Channel is an active
570
- * outage, louder than a steadily-degraded unprovisioned one (only managed
571
- * Channels ever reach `reconnecting`; a direct Channel has no managed-session
572
- * drop signal). With no declared Channels at all, `overall` is `online` (nothing
532
+ * outage, louder than a steadily-degraded unprovisioned one. With no declared
533
+ * Channels at all, `overall` is `online` (nothing
573
534
  * is degraded); once every Channel has been stopped, `overall` is `stopped`.
574
535
  */
575
536
  status() {
@@ -591,12 +552,9 @@ var ChannelManager = class {
591
552
  /**
592
553
  * Fold per-Channel statuses into a single overall status (see {@link status}).
593
554
  *
594
- * Every declared Channel — managed OR direct — participates: a started direct
595
- * Channel reads `online` and counts toward health exactly like a managed one,
596
- * and its `error` is a real outage that must dominate. Statuses are ranked
555
+ * Every declared Channel participates. Statuses are ranked
597
556
  * `error` > `reconnecting` > `setup_required` > `connecting` > `online`, so a
598
- * genuine failure still dominates a healthy sibling. (Only managed Channels ever
599
- * reach `reconnecting`; a direct Channel has no managed-session drop signal.)
557
+ * genuine failure still dominates a healthy sibling.
600
558
  * The empty-input case (no declared Channels at all) stays `online` (nothing is
601
559
  * degraded).
602
560
  */
@@ -684,14 +642,11 @@ var ChannelManager = class {
684
642
  * not-yet-stopped handle (gated by {@link ChannelEntry.handleStopped}).
685
643
  *
686
644
  * This is the ONE guarded teardown path shared by both `stop()` and the
687
- * post-settle guard in {@link activate}/{@link startDirectChannel}. Because the
645
+ * post-settle guard in {@link activate}. Because the
688
646
  * guard is per-entry and idempotent, a handle assigned in the same tick as
689
647
  * `stop()` is stopped exactly once even when both callers reach the entry, and a
690
- * late settle can never resurrect a `stopped` entry. It is transport-agnostic: a
691
- * managed entry's `handle.stop()` releases the gateway session, and a direct
692
- * entry's synthetic handle (assigned in {@link startDirectChannel}) routes the
693
- * same `handle.stop()` to `channel.ɵruntime.stop()` — so direct and managed
694
- * Channels share one bounded, resilient teardown.
648
+ * late settle can never resurrect a `stopped` entry. The activation handle
649
+ * releases the gateway session and stops the Channel's combined adapter array.
695
650
  *
696
651
  * `handle.stop()` failures are logged (via {@link ChannelManager.log}) but NOT
697
652
  * rethrown: the real launcher's `stop()` rethrows after `session.disconnect()`,