@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.
- package/README.md +35 -0
- package/dist/package.cjs +1 -1
- package/dist/runtime/package.mjs +1 -1
- package/dist/v2/index.d.cts +2 -2
- package/dist/v2/index.d.mts +2 -2
- package/dist/v2/runtime/core/channel-activation-config.cjs +9 -14
- package/dist/v2/runtime/core/channel-activation-config.cjs.map +1 -1
- package/dist/v2/runtime/core/channel-activation-config.d.cts +11 -6
- package/dist/v2/runtime/core/channel-activation-config.d.cts.map +1 -1
- package/dist/v2/runtime/core/channel-activation-config.d.mts +11 -6
- package/dist/v2/runtime/core/channel-activation-config.d.mts.map +1 -1
- package/dist/v2/runtime/core/channel-activation-config.mjs +9 -14
- package/dist/v2/runtime/core/channel-activation-config.mjs.map +1 -1
- package/dist/v2/runtime/core/channel-manager.cjs +319 -127
- package/dist/v2/runtime/core/channel-manager.cjs.map +1 -1
- package/dist/v2/runtime/core/channel-manager.d.cts +12 -19
- package/dist/v2/runtime/core/channel-manager.d.cts.map +1 -1
- package/dist/v2/runtime/core/channel-manager.d.mts +12 -19
- package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
- package/dist/v2/runtime/core/channel-manager.mjs +319 -127
- package/dist/v2/runtime/core/channel-manager.mjs.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.cjs +5 -0
- package/dist/v2/runtime/core/fetch-handler.cjs.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.d.cts +5 -0
- package/dist/v2/runtime/core/fetch-handler.d.cts.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.d.mts +5 -0
- package/dist/v2/runtime/core/fetch-handler.d.mts.map +1 -1
- package/dist/v2/runtime/core/fetch-handler.mjs +5 -0
- package/dist/v2/runtime/core/fetch-handler.mjs.map +1 -1
- package/dist/v2/runtime/core/runtime.cjs +16 -4
- package/dist/v2/runtime/core/runtime.cjs.map +1 -1
- package/dist/v2/runtime/core/runtime.d.cts +43 -17
- package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
- package/dist/v2/runtime/core/runtime.d.mts +43 -17
- package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
- package/dist/v2/runtime/core/runtime.mjs +16 -4
- package/dist/v2/runtime/core/runtime.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/auto-start-channels.cjs +47 -0
- package/dist/v2/runtime/endpoints/auto-start-channels.cjs.map +1 -0
- package/dist/v2/runtime/endpoints/auto-start-channels.mjs +46 -0
- package/dist/v2/runtime/endpoints/auto-start-channels.mjs.map +1 -0
- package/dist/v2/runtime/endpoints/express.cjs +2 -0
- package/dist/v2/runtime/endpoints/express.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/express.d.cts +9 -8
- package/dist/v2/runtime/endpoints/express.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/express.d.mts +9 -8
- package/dist/v2/runtime/endpoints/express.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/express.mjs +2 -0
- package/dist/v2/runtime/endpoints/express.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/hono.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/hono.d.cts +14 -5
- package/dist/v2/runtime/endpoints/hono.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/hono.d.mts +14 -5
- package/dist/v2/runtime/endpoints/hono.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/hono.mjs.map +1 -1
- package/dist/v2/runtime/endpoints/node.cjs +2 -0
- package/dist/v2/runtime/endpoints/node.cjs.map +1 -1
- package/dist/v2/runtime/endpoints/node.d.cts +23 -13
- package/dist/v2/runtime/endpoints/node.d.cts.map +1 -1
- package/dist/v2/runtime/endpoints/node.d.mts +23 -13
- package/dist/v2/runtime/endpoints/node.d.mts.map +1 -1
- package/dist/v2/runtime/endpoints/node.mjs +2 -0
- package/dist/v2/runtime/endpoints/node.mjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.cjs +9 -8
- package/dist/v2/runtime/handlers/get-runtime-info.cjs.map +1 -1
- package/dist/v2/runtime/handlers/get-runtime-info.mjs +9 -8
- package/dist/v2/runtime/handlers/get-runtime-info.mjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-run.cjs +2 -1
- package/dist/v2/runtime/handlers/handle-run.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-run.mjs +2 -1
- package/dist/v2/runtime/handlers/handle-run.mjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/memories.cjs +37 -38
- package/dist/v2/runtime/handlers/intelligence/memories.cjs.map +1 -1
- package/dist/v2/runtime/handlers/intelligence/memories.mjs +37 -38
- package/dist/v2/runtime/handlers/intelligence/memories.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs +11 -5
- package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs +11 -5
- package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/memory-policy.cjs +41 -0
- package/dist/v2/runtime/handlers/shared/memory-policy.cjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/memory-policy.mjs +41 -0
- package/dist/v2/runtime/handlers/shared/memory-policy.mjs.map +1 -0
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs +8 -0
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.cjs.map +1 -1
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs +8 -0
- package/dist/v2/runtime/handlers/shared/resolve-intelligence-user.mjs.map +1 -1
- package/dist/v2/runtime/index.d.cts +1 -1
- package/dist/v2/runtime/index.d.mts +1 -1
- package/dist/v2/runtime/intelligence-platform/client.cjs +46 -8
- package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.cts +46 -5
- package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.mts +46 -5
- package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs +46 -9
- package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.cjs.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.d.cts +4 -0
- package/dist/v2/runtime/runner/agent-runner.d.cts.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.d.mts +4 -0
- package/dist/v2/runtime/runner/agent-runner.d.mts.map +1 -1
- package/dist/v2/runtime/runner/agent-runner.mjs.map +1 -1
- package/dist/v2/runtime/runner/in-memory.cjs +3 -5
- package/dist/v2/runtime/runner/in-memory.cjs.map +1 -1
- package/dist/v2/runtime/runner/in-memory.d.cts.map +1 -1
- package/dist/v2/runtime/runner/in-memory.d.mts.map +1 -1
- package/dist/v2/runtime/runner/in-memory.mjs +3 -5
- package/dist/v2/runtime/runner/in-memory.mjs.map +1 -1
- package/dist/v2/runtime/runner/intelligence.cjs +38 -31
- package/dist/v2/runtime/runner/intelligence.cjs.map +1 -1
- package/dist/v2/runtime/runner/intelligence.d.cts.map +1 -1
- package/dist/v2/runtime/runner/intelligence.d.mts.map +1 -1
- package/dist/v2/runtime/runner/intelligence.mjs +38 -31
- package/dist/v2/runtime/runner/intelligence.mjs.map +1 -1
- 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.
|
|
8
|
+
"version": "1.64.3-canary.1785623356",
|
|
9
9
|
"private": false,
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ai",
|
package/dist/runtime/package.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { __commonJSMin } from "../_virtual/_rolldown/runtime.mjs";
|
|
|
5
5
|
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
6
|
module.exports = {
|
|
7
7
|
"name": "@copilotkit/runtime",
|
|
8
|
-
"version": "1.64.
|
|
8
|
+
"version": "1.64.3-canary.1785623356",
|
|
9
9
|
"private": false,
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ai",
|
package/dist/v2/index.d.cts
CHANGED
|
@@ -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 };
|
package/dist/v2/index.d.mts
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
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.ɵ
|
|
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
|
-
|
|
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 *
|
|
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
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
-
|
|
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":"
|
|
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
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
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
|
-
|
|
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":"
|
|
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
|
-
*
|
|
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
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
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.ɵ
|
|
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
|
-
|
|
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 *
|
|
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"}
|