@copilotkit/runtime 1.66.2 → 1.66.3

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 (75) hide show
  1. package/dist/agent/converters/aisdk.cjs +17 -9
  2. package/dist/agent/converters/aisdk.cjs.map +1 -1
  3. package/dist/agent/converters/aisdk.d.cts +1 -1
  4. package/dist/agent/converters/aisdk.d.cts.map +1 -1
  5. package/dist/agent/converters/aisdk.d.mts +1 -1
  6. package/dist/agent/converters/aisdk.d.mts.map +1 -1
  7. package/dist/agent/converters/aisdk.mjs +17 -9
  8. package/dist/agent/converters/aisdk.mjs.map +1 -1
  9. package/dist/agent/converters/tanstack.cjs +17 -9
  10. package/dist/agent/converters/tanstack.cjs.map +1 -1
  11. package/dist/agent/converters/tanstack.d.cts +1 -1
  12. package/dist/agent/converters/tanstack.d.cts.map +1 -1
  13. package/dist/agent/converters/tanstack.d.mts +1 -1
  14. package/dist/agent/converters/tanstack.d.mts.map +1 -1
  15. package/dist/agent/converters/tanstack.mjs +17 -9
  16. package/dist/agent/converters/tanstack.mjs.map +1 -1
  17. package/dist/agent/index.cjs +6 -4
  18. package/dist/agent/index.cjs.map +1 -1
  19. package/dist/agent/index.d.cts.map +1 -1
  20. package/dist/agent/index.d.mts.map +1 -1
  21. package/dist/agent/index.mjs +6 -4
  22. package/dist/agent/index.mjs.map +1 -1
  23. package/dist/agent/state-delta.cjs +322 -0
  24. package/dist/agent/state-delta.cjs.map +1 -0
  25. package/dist/agent/state-delta.mjs +321 -0
  26. package/dist/agent/state-delta.mjs.map +1 -0
  27. package/dist/package.cjs +1 -1
  28. package/dist/runtime/package.mjs +1 -1
  29. package/dist/v2/index.cjs +6 -1
  30. package/dist/v2/index.d.cts +2 -2
  31. package/dist/v2/index.d.mts +2 -2
  32. package/dist/v2/index.mjs +2 -2
  33. package/dist/v2/runtime/core/channel-manager.cjs +110 -9
  34. package/dist/v2/runtime/core/channel-manager.cjs.map +1 -1
  35. package/dist/v2/runtime/core/channel-manager.d.cts +79 -8
  36. package/dist/v2/runtime/core/channel-manager.d.cts.map +1 -1
  37. package/dist/v2/runtime/core/channel-manager.d.mts +79 -8
  38. package/dist/v2/runtime/core/channel-manager.d.mts.map +1 -1
  39. package/dist/v2/runtime/core/channel-manager.mjs +110 -9
  40. package/dist/v2/runtime/core/channel-manager.mjs.map +1 -1
  41. package/dist/v2/runtime/core/runtime.cjs.map +1 -1
  42. package/dist/v2/runtime/core/runtime.d.cts +1 -0
  43. package/dist/v2/runtime/core/runtime.d.cts.map +1 -1
  44. package/dist/v2/runtime/core/runtime.d.mts +1 -0
  45. package/dist/v2/runtime/core/runtime.d.mts.map +1 -1
  46. package/dist/v2/runtime/core/runtime.mjs.map +1 -1
  47. package/dist/v2/runtime/handlers/shared/agent-utils.cjs +2 -5
  48. package/dist/v2/runtime/handlers/shared/agent-utils.cjs.map +1 -1
  49. package/dist/v2/runtime/handlers/shared/agent-utils.mjs +2 -5
  50. package/dist/v2/runtime/handlers/shared/agent-utils.mjs.map +1 -1
  51. package/dist/v2/runtime/handlers/shared/mcp-apps-servers.cjs +23 -0
  52. package/dist/v2/runtime/handlers/shared/mcp-apps-servers.cjs.map +1 -0
  53. package/dist/v2/runtime/handlers/shared/mcp-apps-servers.mjs +22 -0
  54. package/dist/v2/runtime/handlers/shared/mcp-apps-servers.mjs.map +1 -0
  55. package/dist/v2/runtime/index.d.cts +1 -1
  56. package/dist/v2/runtime/index.d.mts +1 -1
  57. package/dist/v2/runtime/open-generative-ui-middleware.cjs +1 -0
  58. package/dist/v2/runtime/open-generative-ui-middleware.cjs.map +1 -1
  59. package/dist/v2/runtime/open-generative-ui-middleware.mjs +1 -0
  60. package/dist/v2/runtime/open-generative-ui-middleware.mjs.map +1 -1
  61. package/dist/v2/runtime/runner/in-memory.cjs +335 -101
  62. package/dist/v2/runtime/runner/in-memory.cjs.map +1 -1
  63. package/dist/v2/runtime/runner/in-memory.d.cts +246 -6
  64. package/dist/v2/runtime/runner/in-memory.d.cts.map +1 -1
  65. package/dist/v2/runtime/runner/in-memory.d.mts +246 -6
  66. package/dist/v2/runtime/runner/in-memory.d.mts.map +1 -1
  67. package/dist/v2/runtime/runner/in-memory.mjs +331 -102
  68. package/dist/v2/runtime/runner/in-memory.mjs.map +1 -1
  69. package/dist/v2/runtime/runner/index.d.cts +1 -1
  70. package/dist/v2/runtime/runner/index.d.mts +1 -1
  71. package/dist/v2/runtime/runner/index.mjs +1 -1
  72. package/package.json +6 -6
  73. package/skills/runtime/references/agent-runners-in-memory.md +49 -34
  74. package/skills/runtime/references/agent-runners.md +47 -21
  75. package/skills/runtime/references/wiring-mcp-apps-middleware.md +5 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"state-delta.mjs","names":[],"sources":["../../src/agent/state-delta.ts"],"sourcesContent":["import type {\n BaseEvent,\n StateDeltaEvent,\n StateSnapshotEvent,\n} from \"@ag-ui/client\";\nimport { EventType } from \"@ag-ui/client\";\n\ntype StateDeltaOperation = {\n op?: string;\n path?: string;\n from?: string;\n value?: unknown;\n};\n\ntype PointerResult = {\n exists: boolean;\n value?: unknown;\n};\n\ntype OperationResult = {\n root: unknown;\n applied: boolean;\n};\n\nfunction parseJsonPointer(pointer: string): string[] | undefined {\n if (pointer === \"\") return [];\n if (!pointer.startsWith(\"/\")) return undefined;\n\n const segments = pointer.slice(1).split(\"/\");\n if (segments.some((segment) => /~(?![01])/.test(segment))) {\n return undefined;\n }\n\n return segments.map((segment) =>\n segment.replace(/~1/g, \"/\").replace(/~0/g, \"~\"),\n );\n}\n\nfunction encodeJsonPointer(segments: string[]): string {\n if (segments.length === 0) return \"\";\n return `/${segments\n .map((segment) => segment.replace(/~/g, \"~0\").replace(/\\//g, \"~1\"))\n .join(\"/\")}`;\n}\n\nfunction getArrayIndex(segment: string, length: number): number | undefined {\n if (segment !== \"0\" && !/^[1-9]\\d*$/.test(segment)) return undefined;\n const index = Number(segment);\n return Number.isSafeInteger(index) && index < length ? index : undefined;\n}\n\nfunction getJsonPointerValue(root: unknown, pointer: string): PointerResult {\n const segments = parseJsonPointer(pointer);\n if (segments === undefined) return { exists: false };\n\n let current = root;\n for (const segment of segments) {\n if (current === null || typeof current !== \"object\") {\n return { exists: false };\n }\n\n if (Array.isArray(current)) {\n const index = getArrayIndex(segment, current.length);\n if (index === undefined) return { exists: false };\n current = current[index];\n } else {\n if (!Object.prototype.hasOwnProperty.call(current, segment)) {\n return { exists: false };\n }\n current = (current as Record<string, unknown>)[segment];\n }\n }\n\n return { exists: true, value: current };\n}\n\nfunction getParent(root: unknown, segments: string[]): PointerResult {\n return getJsonPointerValue(root, encodeJsonPointer(segments.slice(0, -1)));\n}\n\nfunction cloneStateFallback(\n state: unknown,\n seen = new WeakMap<object, unknown>(),\n): unknown {\n if (state === null || typeof state !== \"object\") return state;\n\n const existing = seen.get(state);\n if (existing !== undefined) return existing;\n\n let clone: object;\n try {\n clone = Array.isArray(state)\n ? []\n : Object.create(Object.getPrototypeOf(state));\n } catch {\n clone = Array.isArray(state) ? [] : {};\n }\n seen.set(state, clone);\n\n let keys: (string | symbol)[] = [];\n try {\n keys = Reflect.ownKeys(state);\n } catch {\n return clone;\n }\n\n for (const key of keys) {\n try {\n const descriptor = Object.getOwnPropertyDescriptor(state, key);\n if (!descriptor) continue;\n if (\"value\" in descriptor) {\n descriptor.value = cloneStateFallback(descriptor.value, seen);\n }\n Object.defineProperty(clone, key, descriptor);\n } catch {\n // Keep the cloned container distinct when a property is inaccessible.\n }\n }\n\n return clone;\n}\n\nfunction cloneState(state: unknown): unknown {\n try {\n return structuredClone(state);\n } catch {\n return cloneStateFallback(state);\n }\n}\n\nfunction addValue(\n root: unknown,\n segments: string[],\n value: unknown,\n): OperationResult {\n if (segments.length === 0) {\n return { root: cloneState(value), applied: true };\n }\n\n const parent = getParent(root, segments);\n if (\n !parent.exists ||\n parent.value === null ||\n typeof parent.value !== \"object\"\n ) {\n return { root, applied: false };\n }\n\n const segment = segments[segments.length - 1];\n if (Array.isArray(parent.value)) {\n if (segment === \"-\") {\n parent.value.push(cloneState(value));\n return { root, applied: true };\n }\n\n const index =\n segment === \"0\"\n ? 0\n : /^[1-9]\\d*$/.test(segment)\n ? Number(segment)\n : undefined;\n if (\n index === undefined ||\n !Number.isSafeInteger(index) ||\n index > parent.value.length\n ) {\n return { root, applied: false };\n }\n parent.value.splice(index, 0, cloneState(value));\n return { root, applied: true };\n }\n\n (parent.value as Record<string, unknown>)[segment] = cloneState(value);\n return { root, applied: true };\n}\n\nfunction removeValue(root: unknown, segments: string[]): OperationResult {\n if (segments.length === 0) return { root: undefined, applied: true };\n\n const parent = getParent(root, segments);\n if (\n !parent.exists ||\n parent.value === null ||\n typeof parent.value !== \"object\"\n ) {\n return { root, applied: false };\n }\n\n const segment = segments[segments.length - 1];\n if (Array.isArray(parent.value)) {\n const index = getArrayIndex(segment, parent.value.length);\n if (index === undefined) return { root, applied: false };\n parent.value.splice(index, 1);\n return { root, applied: true };\n }\n\n if (!Object.prototype.hasOwnProperty.call(parent.value, segment)) {\n return { root, applied: false };\n }\n delete (parent.value as Record<string, unknown>)[segment];\n return { root, applied: true };\n}\n\nfunction replaceValue(\n root: unknown,\n segments: string[],\n value: unknown,\n): OperationResult {\n if (segments.length === 0) {\n return { root: cloneState(value), applied: true };\n }\n\n const parent = getParent(root, segments);\n if (\n !parent.exists ||\n parent.value === null ||\n typeof parent.value !== \"object\"\n ) {\n return { root, applied: false };\n }\n\n const segment = segments[segments.length - 1];\n if (Array.isArray(parent.value)) {\n const index = getArrayIndex(segment, parent.value.length);\n if (index === undefined) return { root, applied: false };\n parent.value[index] = cloneState(value);\n return { root, applied: true };\n }\n\n if (!Object.prototype.hasOwnProperty.call(parent.value, segment)) {\n return { root, applied: false };\n }\n (parent.value as Record<string, unknown>)[segment] = cloneState(value);\n return { root, applied: true };\n}\n\nfunction jsonValueEqual(left: unknown, right: unknown): boolean {\n if (Object.is(left, right)) return true;\n if (\n left === null ||\n right === null ||\n typeof left !== \"object\" ||\n typeof right !== \"object\"\n ) {\n return false;\n }\n if (Array.isArray(left) !== Array.isArray(right)) return false;\n\n const leftKeys = Object.keys(left as object);\n const rightKeys = Object.keys(right as object);\n if (leftKeys.length !== rightKeys.length) return false;\n\n return leftKeys.every(\n (key) =>\n Object.prototype.hasOwnProperty.call(right, key) &&\n jsonValueEqual(\n (left as Record<string, unknown>)[key],\n (right as Record<string, unknown>)[key],\n ),\n );\n}\n\nfunction applyStateDeltaOperation(\n root: unknown,\n operation: StateDeltaOperation,\n): OperationResult {\n if (typeof operation.path !== \"string\") return { root, applied: false };\n\n const path = parseJsonPointer(operation.path);\n if (path === undefined) return { root, applied: false };\n\n switch (operation.op) {\n case \"add\":\n return addValue(root, path, operation.value);\n case \"remove\":\n return removeValue(root, path);\n case \"replace\":\n return replaceValue(root, path, operation.value);\n case \"test\": {\n const actual = getJsonPointerValue(root, operation.path);\n return {\n root,\n applied: actual.exists && jsonValueEqual(actual.value, operation.value),\n };\n }\n case \"copy\": {\n if (typeof operation.from !== \"string\") return { root, applied: false };\n const source = getJsonPointerValue(root, operation.from);\n if (!source.exists) return { root, applied: false };\n return addValue(root, path, source.value);\n }\n case \"move\": {\n if (typeof operation.from !== \"string\") return { root, applied: false };\n const from = parseJsonPointer(operation.from);\n if (from === undefined) return { root, applied: false };\n const source = getJsonPointerValue(root, operation.from);\n if (!source.exists) return { root, applied: false };\n if (operation.from === operation.path) return { root, applied: true };\n\n const nextRoot = cloneState(root);\n const removed = removeValue(nextRoot, from);\n if (!removed.applied) return { root, applied: false };\n const added = addValue(removed.root, path, source.value);\n return added.applied ? added : { root, applied: false };\n }\n default:\n return { root, applied: false };\n }\n}\n\nfunction normalizeStateDelta(\n delta: unknown[],\n initialState: unknown,\n): { delta: unknown[]; state: unknown } {\n let state = cloneState(initialState);\n const normalized: unknown[] = [];\n\n for (const operation of delta) {\n const candidate =\n operation !== null && typeof operation === \"object\"\n ? (operation as StateDeltaOperation)\n : undefined;\n if (\n candidate?.op === \"add\" &&\n typeof candidate.path === \"string\" &&\n candidate.path.endsWith(\"/-\")\n ) {\n const arrayPath = candidate.path.slice(0, -2);\n const array = getJsonPointerValue(state, arrayPath);\n if (!array.exists) {\n const lastSlash = arrayPath.lastIndexOf(\"/\");\n const parentPath = lastSlash > 0 ? arrayPath.slice(0, lastSlash) : \"\";\n if (getJsonPointerValue(state, parentPath).exists) {\n const initializer: StateDeltaOperation = {\n op: \"add\",\n path: arrayPath,\n value: [],\n };\n const applied = applyStateDeltaOperation(state, initializer);\n if (applied.applied) {\n normalized.push(initializer);\n state = applied.root;\n }\n }\n }\n }\n\n normalized.push(operation);\n if (candidate) {\n const applied = applyStateDeltaOperation(state, candidate);\n if (applied.applied) state = applied.root;\n }\n }\n\n return { delta: normalized, state };\n}\n\nexport function createStateEventNormalizer(\n initialState: unknown,\n): (event: BaseEvent) => BaseEvent[] {\n let state = cloneState(initialState);\n let hasEmittedState = false;\n\n return (event) => {\n if (event.type === EventType.STATE_SNAPSHOT) {\n state = cloneState((event as StateSnapshotEvent).snapshot);\n hasEmittedState = true;\n return [event];\n }\n\n if (event.type !== EventType.STATE_DELTA) return [event];\n\n const stateDeltaEvent = event as StateDeltaEvent;\n const initialSnapshot: StateSnapshotEvent[] =\n !hasEmittedState && initialState !== undefined\n ? [\n {\n type: EventType.STATE_SNAPSHOT,\n snapshot: cloneState(state),\n },\n ]\n : [];\n const normalized = Array.isArray(stateDeltaEvent.delta)\n ? normalizeStateDelta(stateDeltaEvent.delta, state)\n : { delta: stateDeltaEvent.delta, state };\n state = normalized.state;\n hasEmittedState = true;\n\n return [\n ...initialSnapshot,\n {\n ...stateDeltaEvent,\n delta: normalized.delta as StateDeltaEvent[\"delta\"],\n },\n ];\n };\n}\n"],"mappings":";;;;AAwBA,SAAS,iBAAiB,SAAuC;AAC/D,KAAI,YAAY,GAAI,QAAO,EAAE;AAC7B,KAAI,CAAC,QAAQ,WAAW,IAAI,CAAE,QAAO;CAErC,MAAM,WAAW,QAAQ,M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ACnB,CACF"}
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.66.2",
8
+ "version": "1.66.3",
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.66.2",
8
+ "version": "1.66.3",
9
9
  "private": false,
10
10
  "keywords": [
11
11
  "ai",
package/dist/v2/index.cjs CHANGED
@@ -55,4 +55,9 @@ exports.isIntelligenceRuntime = require_runtime$1.isIntelligenceRuntime;
55
55
  exports.resolveAgents = require_runtime$1.resolveAgents;
56
56
  exports.resolveModel = require_index.resolveModel;
57
57
  exports.supportsLocalThreadEndpoints = require_agent_runner.supportsLocalThreadEndpoints;
58
- exports.toFetchCorsConfig = require_hono.toFetchCorsConfig;
58
+ exports.toFetchCorsConfig = require_hono.toFetchCorsConfig;
59
+ exports.ɵBoundedThreadStore = require_in_memory.ɵBoundedThreadStore;
60
+ exports.ɵGLOBAL_STORE = require_in_memory.ɵGLOBAL_STORE;
61
+ exports.ɵINMEMORY_DEFAULTS = require_in_memory.ɵINMEMORY_DEFAULTS;
62
+ exports.ɵestimateBytes = require_in_memory.ɵestimateBytes;
63
+ exports.ɵnormalizeLimits = require_in_memory.ɵnormalizeLimits;
@@ -10,7 +10,7 @@ import { CopilotEndpointCorsConfig, CopilotHonoApp, createCopilotEndpoint, creat
10
10
  import { createCopilotEndpointSingleRoute } from "./runtime/endpoints/hono-single.cjs";
11
11
  import { CopilotExpressEndpointParams, CopilotExpressRouter, createCopilotExpressHandler } from "./runtime/endpoints/express.cjs";
12
12
  import { createCopilotEndpointSingleRouteExpress } from "./runtime/endpoints/express-single.cjs";
13
- import { InMemoryAgentRunner, InMemoryThread } from "./runtime/runner/in-memory.cjs";
13
+ import { InMemoryAgentRunner, InMemoryAgentRunnerOptions, InMemoryLimits, InMemoryThread, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵestimateBytes, ɵnormalizeLimits } from "./runtime/runner/in-memory.cjs";
14
14
  import { IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, RunnerStartupBoundary } from "./runtime/runner/intelligence.cjs";
15
15
  import { finalizeRunEvents } from "./runtime/runner/index.cjs";
16
16
  import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.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, 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 };
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, InMemoryAgentRunnerOptions, InMemoryLimits, 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, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵestimateBytes, ɵnormalizeLimits };
@@ -10,7 +10,7 @@ import { CopilotEndpointCorsConfig, CopilotHonoApp, createCopilotEndpoint, creat
10
10
  import { createCopilotEndpointSingleRoute } from "./runtime/endpoints/hono-single.mjs";
11
11
  import { CopilotExpressEndpointParams, CopilotExpressRouter, createCopilotExpressHandler } from "./runtime/endpoints/express.mjs";
12
12
  import { createCopilotEndpointSingleRouteExpress } from "./runtime/endpoints/express-single.mjs";
13
- import { InMemoryAgentRunner, InMemoryThread } from "./runtime/runner/in-memory.mjs";
13
+ import { InMemoryAgentRunner, InMemoryAgentRunnerOptions, InMemoryLimits, InMemoryThread, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵestimateBytes, ɵnormalizeLimits } from "./runtime/runner/in-memory.mjs";
14
14
  import { IntelligenceAgentRunner, IntelligenceAgentRunnerOptions, RunnerStartupBoundary } from "./runtime/runner/intelligence.mjs";
15
15
  import { finalizeRunEvents } from "./runtime/runner/index.mjs";
16
16
  import { CopilotRuntimeFetchHandler, CopilotRuntimeFetchHandlerWithChannels, CopilotRuntimeHandlerOptions, createCopilotRuntimeHandler } from "./runtime/core/fetch-handler.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, 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 };
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, InMemoryAgentRunnerOptions, InMemoryLimits, 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, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵestimateBytes, ɵnormalizeLimits };
package/dist/v2/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import "reflect-metadata";
2
2
  import { AgentRunner, supportsLocalThreadEndpoints } from "./runtime/runner/agent-runner.mjs";
3
- import { InMemoryAgentRunner } from "./runtime/runner/in-memory.mjs";
3
+ import { InMemoryAgentRunner, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵestimateBytes, ɵnormalizeLimits } from "./runtime/runner/in-memory.mjs";
4
4
  import { IntelligenceAgentRunner } from "./runtime/runner/intelligence.mjs";
5
5
  import { CopilotIntelligenceRuntime, CopilotRuntime, CopilotSseRuntime, VERSION, isA2UIEnabled, isIntelligenceRuntime, resolveAgents } from "./runtime/core/runtime.mjs";
6
6
  import { CopilotKitIntelligence } from "./runtime/intelligence-platform/client.mjs";
@@ -15,4 +15,4 @@ import { convertAISDKStream } from "../agent/converters/aisdk.mjs";
15
15
  import { convertInputToTanStackAI, convertTanStackStream } from "../agent/converters/tanstack.mjs";
16
16
  import { BasicAgent, BuiltInAgent, InterruptSignal, convertJsonSchemaToZodSchema, convertMessagesToVercelAISDKMessages, convertToolDefinitionsToVercelAITools, convertToolsToVercelAITools, defineTool, resolveModel } from "../agent/index.mjs";
17
17
 
18
- export { AgentRunner, BasicAgent, BuiltInAgent, CopilotIntelligenceRuntime, CopilotKitIntelligence, CopilotRuntime, CopilotSseRuntime, InMemoryAgentRunner, IntelligenceAgentRunner, InterruptSignal, TranscriptionService, 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 };
18
+ export { AgentRunner, BasicAgent, BuiltInAgent, CopilotIntelligenceRuntime, CopilotKitIntelligence, CopilotRuntime, CopilotSseRuntime, InMemoryAgentRunner, IntelligenceAgentRunner, InterruptSignal, TranscriptionService, 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, ɵBoundedThreadStore, ɵGLOBAL_STORE, ɵINMEMORY_DEFAULTS, ɵestimateBytes, ɵnormalizeLimits };
@@ -9,6 +9,60 @@ let _ag_ui_mcp_middleware = require("@ag-ui/mcp-middleware");
9
9
 
10
10
  //#region src/v2/runtime/core/channel-manager.ts
11
11
  /**
12
+ * Recognised provider states, used to validate what crosses the seam.
13
+ *
14
+ * Deliberately duplicates `PROVIDER_STATES` in
15
+ * `@copilotkit/channels-intelligence`'s `realtime-gateway.ts` rather than
16
+ * importing it: this package must not take a static dependency on
17
+ * channels-intelligence (it is reached only through a dynamic import), so the
18
+ * `providerStates` seam is duck-typed as `Record<string, string>`.
19
+ *
20
+ * A state added there needs adding here too, plus a `case` in
21
+ * {@link foldChannelLegs}. Until both land it fails OPEN — an unrecognised state
22
+ * becomes `unknown` and the Channel keeps its transport-derived status, rather
23
+ * than being wrongly certified or condemned.
24
+ */
25
+ const PROVIDER_LEGS = new Set([
26
+ "attached",
27
+ "unhealthy",
28
+ "not_attached",
29
+ "disabled",
30
+ "channel_not_declared"
31
+ ]);
32
+ /**
33
+ * Fold a Channel's transport and provider legs into its single status.
34
+ *
35
+ * The transport leg dominates whenever it is not `online`: while the control
36
+ * socket is connecting, retrying, stopped, or failed, whatever the gateway last
37
+ * said about the provider is stale or irrelevant — the Channel cannot serve a
38
+ * turn either way, and reporting `setup_required` for a Channel that is actually
39
+ * mid-reconnect would hide the outage.
40
+ *
41
+ * Once the transport is `online` the provider leg decides, which is the whole
42
+ * point of the split: a joined socket with no provider bound is
43
+ * `setup_required`, not `online`.
44
+ *
45
+ * `unknown` keeps the transport-derived answer. That is what makes an older
46
+ * gateway (or a gateway whose lookup failed) behave exactly as it did before
47
+ * provider states existed, instead of turning every Channel into
48
+ * `setup_required`.
49
+ *
50
+ * @param transport - Control-socket status for the Channel.
51
+ * @param provider - Reported provider attachment state.
52
+ * @returns The folded Channel status.
53
+ */
54
+ function foldChannelLegs(transport, provider) {
55
+ if (transport !== "online") return transport;
56
+ switch (provider) {
57
+ case "attached":
58
+ case "unknown": return "online";
59
+ case "unhealthy": return "error";
60
+ case "not_attached":
61
+ case "disabled":
62
+ case "channel_not_declared": return "setup_required";
63
+ }
64
+ }
65
+ /**
12
66
  * Signals that a declared Channel cannot be activated because no managed
13
67
  * provider exists for it yet. The engine throws this (or any error whose
14
68
  * `code === "SETUP_REQUIRED"`) to move a Channel to `setup_required` rather
@@ -616,31 +670,78 @@ var ChannelManager = class {
616
670
  * Snapshot status. Every declared Channel appears keyed by name in
617
671
  * `channels` after its combined adapter lifecycle starts.
618
672
  *
673
+ * Each Channel's entry is the fold of its transport and provider legs (see
674
+ * {@link foldChannelLegs}), and `detail` reports those legs separately so a
675
+ * caller can assert the one it cares about.
676
+ *
619
677
  * `overall` is folded over ALL declared Channels (see {@link computeOverall}),
620
678
  * by precedence `error` > `reconnecting` > `setup_required` > `connecting` >
621
- * `online`. `online` means every Channel can currently send. `reconnecting`
622
- * outranks `setup_required` because a dropped-but-retrying Channel is an active
623
- * outage, louder than a steadily-degraded unprovisioned one. With no declared
624
- * Channels at all, `overall` is `online` (nothing
625
- * is degraded); once every Channel has been stopped, `overall` is `stopped`.
679
+ * `online`. `online` means every Channel can currently send AND none was
680
+ * reported as missing its managed provider. `reconnecting` outranks
681
+ * `setup_required` because a dropped-but-retrying Channel is an active outage,
682
+ * louder than a steadily-degraded unprovisioned one. With no declared Channels
683
+ * at all, `overall` is `online` (nothing is degraded); once every Channel has
684
+ * been stopped, `overall` is `stopped`.
685
+ *
686
+ * `overall === "online"` is only end-to-end proof when every Channel's
687
+ * `provider` leg is `attached`. A gateway that reports no provider state leaves
688
+ * the legs `unknown` and `overall` transport-derived, exactly as before this
689
+ * contract existed — so a caller that must be certain checks `detail`.
626
690
  */
627
691
  status() {
628
692
  const channels = {};
629
- for (const [name, entry] of this.entries) channels[name] = entry.status;
693
+ const detail = {};
694
+ for (const [name, entry] of this.entries) {
695
+ const transport = entry.status;
696
+ const provider = this.providerLeg(name, entry);
697
+ const status = foldChannelLegs(transport, provider);
698
+ channels[name] = status;
699
+ detail[name] = {
700
+ status,
701
+ transport,
702
+ provider
703
+ };
704
+ }
630
705
  if (this.stopped) return {
631
706
  overall: "stopped",
632
- channels
707
+ channels,
708
+ detail
633
709
  };
634
710
  if (!this.activated && this.channels.length > 0) return {
635
711
  overall: "connecting",
636
- channels
712
+ channels,
713
+ detail
637
714
  };
638
715
  return {
639
716
  overall: this.computeOverall(Object.values(channels)),
640
- channels
717
+ channels,
718
+ detail
641
719
  };
642
720
  }
643
721
  /**
722
+ * Read one Channel's provider leg from its handle.
723
+ *
724
+ * Defensive on every axis, because a wrong answer here silently changes what
725
+ * `status()` certifies: a handle without the seam, a gateway that reported
726
+ * nothing, a name the gateway did not mention, an unrecognised value, or a
727
+ * throwing getter all yield `unknown` — which {@link foldChannelLegs} treats as
728
+ * "keep the transport-derived status", i.e. pre-provider-state behaviour.
729
+ *
730
+ * @param name - The Channel name (map key).
731
+ * @param entry - The Channel's activation entry.
732
+ * @returns The provider leg, or `"unknown"` when it cannot be established.
733
+ */
734
+ providerLeg(name, entry) {
735
+ let states;
736
+ try {
737
+ states = entry.handle?.providerStates?.();
738
+ } catch {
739
+ return "unknown";
740
+ }
741
+ const reported = states?.[name];
742
+ return reported !== void 0 && PROVIDER_LEGS.has(reported) ? reported : "unknown";
743
+ }
744
+ /**
644
745
  * Fold per-Channel statuses into a single overall status (see {@link status}).
645
746
  *
646
747
  * Every declared Channel participates. Statuses are ranked