@copilotkit/core 1.68.3-canary.1787220377 → 1.68.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.
- package/dist/index.cjs +34 -150
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -71
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +1 -71
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +35 -150
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +35 -155
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -571,6 +571,31 @@ var IntelligenceAgent = class IntelligenceAgent extends AbstractAgent {
|
|
|
571
571
|
}
|
|
572
572
|
};
|
|
573
573
|
|
|
574
|
+
//#endregion
|
|
575
|
+
//#region src/utils/runtime-info-error.ts
|
|
576
|
+
/**
|
|
577
|
+
* Build the error for a failed runtime `/info` response, folding in whatever
|
|
578
|
+
* explanation the runtime sent back.
|
|
579
|
+
*
|
|
580
|
+
* The status alone cannot distinguish a wrong `runtimeUrl` from a transport
|
|
581
|
+
* mismatch, so the runtime answers the latter with a body naming the cause
|
|
582
|
+
* (see the handler's `single_route_envelope_against_multi_route_runtime`
|
|
583
|
+
* diagnostic). Discarding that body — as every `/info` caller used to — left
|
|
584
|
+
* the developer with a bare 404 and nothing to act on (OSS-882).
|
|
585
|
+
*
|
|
586
|
+
* A body that isn't JSON, or carries no string `message`, contributes nothing:
|
|
587
|
+
* the status is then the whole error.
|
|
588
|
+
*/
|
|
589
|
+
async function runtimeInfoError(response) {
|
|
590
|
+
const base = `Runtime info request failed with status ${response.status}`;
|
|
591
|
+
let detail;
|
|
592
|
+
try {
|
|
593
|
+
const message = (await response.clone().json())?.message;
|
|
594
|
+
if (typeof message === "string" && message.trim().length > 0) detail = message.trim();
|
|
595
|
+
} catch {}
|
|
596
|
+
return new Error(detail ? `${base}: ${detail}` : base);
|
|
597
|
+
}
|
|
598
|
+
|
|
574
599
|
//#endregion
|
|
575
600
|
//#region src/agent.ts
|
|
576
601
|
function hasHeaders(agent) {
|
|
@@ -860,7 +885,7 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends HttpAg
|
|
|
860
885
|
headers,
|
|
861
886
|
...this.credentials ? { credentials: this.credentials } : {}
|
|
862
887
|
});
|
|
863
|
-
if (!response.ok) throw
|
|
888
|
+
if (!response.ok) throw await runtimeInfoError(response);
|
|
864
889
|
return await response.json();
|
|
865
890
|
}
|
|
866
891
|
async fetchRuntimeInfoAutoDetect(headers) {
|
|
@@ -882,7 +907,7 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends HttpAg
|
|
|
882
907
|
body: JSON.stringify({ method: "info" }),
|
|
883
908
|
...this.credentials ? { credentials: this.credentials } : {}
|
|
884
909
|
});
|
|
885
|
-
if (!response.ok) throw
|
|
910
|
+
if (!response.ok) throw await runtimeInfoError(response);
|
|
886
911
|
this.transport = "single";
|
|
887
912
|
this.singleEndpointUrl = this.runtimeUrl;
|
|
888
913
|
return await response.json();
|
|
@@ -1491,7 +1516,7 @@ var AgentRegistry = class {
|
|
|
1491
1516
|
headers,
|
|
1492
1517
|
...credentials ? { credentials } : {}
|
|
1493
1518
|
});
|
|
1494
|
-
if (!response.ok) throw
|
|
1519
|
+
if (!response.ok) throw await runtimeInfoError(response);
|
|
1495
1520
|
return {
|
|
1496
1521
|
runtimeInfo: await response.json(),
|
|
1497
1522
|
resolvedTransport: "rest"
|
|
@@ -1504,7 +1529,7 @@ var AgentRegistry = class {
|
|
|
1504
1529
|
body: JSON.stringify({ method: "info" }),
|
|
1505
1530
|
...credentials ? { credentials } : {}
|
|
1506
1531
|
});
|
|
1507
|
-
if (!response.ok) throw
|
|
1532
|
+
if (!response.ok) throw await runtimeInfoError(response);
|
|
1508
1533
|
return await response.json();
|
|
1509
1534
|
}
|
|
1510
1535
|
/**
|
|
@@ -3002,124 +3027,6 @@ var StateManager = class {
|
|
|
3002
3027
|
}
|
|
3003
3028
|
};
|
|
3004
3029
|
|
|
3005
|
-
//#endregion
|
|
3006
|
-
//#region src/core/subagent-registry.ts
|
|
3007
|
-
/**
|
|
3008
|
-
* Tracks subagent lifecycle events (SUBAGENT_STARTED / FINISHED / ERROR) per
|
|
3009
|
-
* owning agent so consumers can resolve a message's `subagentRunId` to a name,
|
|
3010
|
-
* description, and running status.
|
|
3011
|
-
*
|
|
3012
|
-
* Modeled on {@link SuggestionEngine}: an in-memory `Record` keyed by (owning)
|
|
3013
|
-
* agentId, mutated from streamed AG-UI events, made reactive by calling
|
|
3014
|
-
* `notifySubscribers(onSubagentsChanged)` after every change. It owns its own
|
|
3015
|
-
* per-agent `agent.subscribe` (like {@link StateManager}) so it is fully
|
|
3016
|
-
* self-contained and adds no coupling to the state/message tracking path.
|
|
3017
|
-
*
|
|
3018
|
-
* No-op for runs without subagents (a normal LangGraph run never emits
|
|
3019
|
-
* SUBAGENT_* events), so the registry simply stays empty.
|
|
3020
|
-
*/
|
|
3021
|
-
var SubagentRegistry = class {
|
|
3022
|
-
_subagents = {};
|
|
3023
|
-
agentSubscriptions = /* @__PURE__ */ new Map();
|
|
3024
|
-
constructor(core) {
|
|
3025
|
-
this.core = core;
|
|
3026
|
-
}
|
|
3027
|
-
/**
|
|
3028
|
-
* Subscribe to an agent's subagent lifecycle events. Idempotent per agentId:
|
|
3029
|
-
* an existing subscription for the same agent is revoked and replaced.
|
|
3030
|
-
*/
|
|
3031
|
-
subscribeToAgent(agent) {
|
|
3032
|
-
if (!agent.agentId) return;
|
|
3033
|
-
const agentId = agent.agentId;
|
|
3034
|
-
const existingUnsubscribe = this.agentSubscriptions.get(agentId);
|
|
3035
|
-
if (existingUnsubscribe) {
|
|
3036
|
-
existingUnsubscribe();
|
|
3037
|
-
this.agentSubscriptions.delete(agentId);
|
|
3038
|
-
}
|
|
3039
|
-
let revoked = false;
|
|
3040
|
-
const { unsubscribe } = agent.subscribe({
|
|
3041
|
-
onSubagentStartedEvent: ({ event }) => {
|
|
3042
|
-
if (revoked) return;
|
|
3043
|
-
this.handleStarted(agentId, event);
|
|
3044
|
-
},
|
|
3045
|
-
onSubagentFinishedEvent: ({ event }) => {
|
|
3046
|
-
if (revoked) return;
|
|
3047
|
-
this.handleFinished(agentId, event);
|
|
3048
|
-
},
|
|
3049
|
-
onSubagentErrorEvent: ({ event }) => {
|
|
3050
|
-
if (revoked) return;
|
|
3051
|
-
this.handleError(agentId, event);
|
|
3052
|
-
}
|
|
3053
|
-
});
|
|
3054
|
-
this.agentSubscriptions.set(agentId, () => {
|
|
3055
|
-
revoked = true;
|
|
3056
|
-
unsubscribe();
|
|
3057
|
-
});
|
|
3058
|
-
}
|
|
3059
|
-
/**
|
|
3060
|
-
* Unsubscribe an agent's subscription (symmetric with StateManager cleanup).
|
|
3061
|
-
*/
|
|
3062
|
-
unsubscribeFromAgent(agentId) {
|
|
3063
|
-
const unsubscribe = this.agentSubscriptions.get(agentId);
|
|
3064
|
-
if (unsubscribe) {
|
|
3065
|
-
unsubscribe();
|
|
3066
|
-
this.agentSubscriptions.delete(agentId);
|
|
3067
|
-
}
|
|
3068
|
-
}
|
|
3069
|
-
/**
|
|
3070
|
-
* Get the subagents observed for an owning agent, keyed by subagentRunId.
|
|
3071
|
-
* Returns a fresh shallow copy each call so consumers (and React state) see
|
|
3072
|
-
* a new reference when anything changed.
|
|
3073
|
-
*/
|
|
3074
|
-
getSubagents(agentId) {
|
|
3075
|
-
return { ...this._subagents[agentId] };
|
|
3076
|
-
}
|
|
3077
|
-
handleStarted(agentId, event) {
|
|
3078
|
-
const bucket = this._subagents[agentId] ??= {};
|
|
3079
|
-
bucket[event.subagentRunId] = {
|
|
3080
|
-
subagentRunId: event.subagentRunId,
|
|
3081
|
-
name: event.name,
|
|
3082
|
-
description: event.description,
|
|
3083
|
-
parentSubagentRunId: event.parentSubagentRunId,
|
|
3084
|
-
status: "running"
|
|
3085
|
-
};
|
|
3086
|
-
this.notifySubagentsChanged(agentId);
|
|
3087
|
-
}
|
|
3088
|
-
handleFinished(agentId, event) {
|
|
3089
|
-
const bucket = this._subagents[agentId];
|
|
3090
|
-
const existing = bucket?.[event.subagentRunId];
|
|
3091
|
-
if (!bucket || !existing) return;
|
|
3092
|
-
bucket[event.subagentRunId] = {
|
|
3093
|
-
...existing,
|
|
3094
|
-
status: "finished"
|
|
3095
|
-
};
|
|
3096
|
-
this.notifySubagentsChanged(agentId);
|
|
3097
|
-
}
|
|
3098
|
-
handleError(agentId, event) {
|
|
3099
|
-
const bucket = this._subagents[agentId] ??= {};
|
|
3100
|
-
const existing = bucket[event.subagentRunId];
|
|
3101
|
-
bucket[event.subagentRunId] = existing ? {
|
|
3102
|
-
...existing,
|
|
3103
|
-
status: "error",
|
|
3104
|
-
error: event.message
|
|
3105
|
-
} : {
|
|
3106
|
-
subagentRunId: event.subagentRunId,
|
|
3107
|
-
name: event.subagentRunId,
|
|
3108
|
-
status: "error",
|
|
3109
|
-
error: event.message
|
|
3110
|
-
};
|
|
3111
|
-
this.notifySubagentsChanged(agentId);
|
|
3112
|
-
}
|
|
3113
|
-
async notifySubagentsChanged(agentId) {
|
|
3114
|
-
const subagents = this.getSubagents(agentId);
|
|
3115
|
-
await this.core.notifySubscribers((subscriber) => subscriber.onSubagentsChanged?.({
|
|
3116
|
-
copilotkit: this.core,
|
|
3117
|
-
agentId,
|
|
3118
|
-
subagents
|
|
3119
|
-
}), "Subscriber onSubagentsChanged error:");
|
|
3120
|
-
}
|
|
3121
|
-
};
|
|
3122
|
-
|
|
3123
3030
|
//#endregion
|
|
3124
3031
|
//#region src/core/thread-store-registry.ts
|
|
3125
3032
|
var ThreadStoreRegistry = class {
|
|
@@ -4308,7 +4215,6 @@ var CopilotKitCore = class {
|
|
|
4308
4215
|
suggestionEngine;
|
|
4309
4216
|
runHandler;
|
|
4310
4217
|
stateManager;
|
|
4311
|
-
subagentRegistry;
|
|
4312
4218
|
threadStoreRegistry;
|
|
4313
4219
|
/**
|
|
4314
4220
|
* The single core-owned memory store, created lazily on first
|
|
@@ -4334,7 +4240,6 @@ var CopilotKitCore = class {
|
|
|
4334
4240
|
this.suggestionEngine = new SuggestionEngine(this);
|
|
4335
4241
|
this.runHandler = new RunHandler(this);
|
|
4336
4242
|
this.stateManager = new StateManager(this);
|
|
4337
|
-
this.subagentRegistry = new SubagentRegistry(this);
|
|
4338
4243
|
this.threadStoreRegistry = new ThreadStoreRegistry(this);
|
|
4339
4244
|
this.agentRegistry.initialize(agents__unsafe_dev_only);
|
|
4340
4245
|
this.runHandler.initialize(tools);
|
|
@@ -4349,10 +4254,7 @@ var CopilotKitCore = class {
|
|
|
4349
4254
|
},
|
|
4350
4255
|
onAgentsChanged: ({ agents }) => {
|
|
4351
4256
|
Object.values(agents).forEach((agent) => {
|
|
4352
|
-
if (agent.agentId)
|
|
4353
|
-
this.stateManager.subscribeToAgent(agent);
|
|
4354
|
-
this.subagentRegistry.subscribeToAgent(agent);
|
|
4355
|
-
}
|
|
4257
|
+
if (agent.agentId) this.stateManager.subscribeToAgent(agent);
|
|
4356
4258
|
});
|
|
4357
4259
|
const currentAgentIds = new Set(Object.keys(agents));
|
|
4358
4260
|
for (const agentId of Object.keys(this.threadStoreRegistry.getAll())) if (this.previousAgentIds.has(agentId) && !currentAgentIds.has(agentId)) try {
|
|
@@ -4360,17 +4262,10 @@ var CopilotKitCore = class {
|
|
|
4360
4262
|
} catch (err) {
|
|
4361
4263
|
console.error(`CopilotKitCore.onAgentsChanged: threadStoreRegistry.unregister failed for "${agentId}":`, err);
|
|
4362
4264
|
}
|
|
4363
|
-
for (const agentId of this.previousAgentIds) if (!currentAgentIds.has(agentId)) {
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
}
|
|
4367
|
-
console.error(`CopilotKitCore.onAgentsChanged: stateManager.unsubscribeFromAgent failed for "${agentId}":`, err);
|
|
4368
|
-
}
|
|
4369
|
-
try {
|
|
4370
|
-
this.subagentRegistry.unsubscribeFromAgent(agentId);
|
|
4371
|
-
} catch (err) {
|
|
4372
|
-
console.error(`CopilotKitCore.onAgentsChanged: subagentRegistry.unsubscribeFromAgent failed for "${agentId}":`, err);
|
|
4373
|
-
}
|
|
4265
|
+
for (const agentId of this.previousAgentIds) if (!currentAgentIds.has(agentId)) try {
|
|
4266
|
+
this.stateManager.unsubscribeFromAgent(agentId);
|
|
4267
|
+
} catch (err) {
|
|
4268
|
+
console.error(`CopilotKitCore.onAgentsChanged: stateManager.unsubscribeFromAgent failed for "${agentId}":`, err);
|
|
4374
4269
|
}
|
|
4375
4270
|
this.previousAgentIds = currentAgentIds;
|
|
4376
4271
|
}
|
|
@@ -4740,16 +4635,6 @@ var CopilotKitCore = class {
|
|
|
4740
4635
|
return this.suggestionEngine.getSuggestions(agentId);
|
|
4741
4636
|
}
|
|
4742
4637
|
/**
|
|
4743
|
-
* Subagent registry (delegated to SubagentRegistry).
|
|
4744
|
-
*
|
|
4745
|
-
* Returns the subagents observed for an owning agent during its run(s),
|
|
4746
|
-
* keyed by `subagentRunId`, each carrying `name` / `description` / `status`.
|
|
4747
|
-
* Empty for runs that never emit SUBAGENT_* events.
|
|
4748
|
-
*/
|
|
4749
|
-
getSubagents(agentId) {
|
|
4750
|
-
return this.subagentRegistry.getSubagents(agentId);
|
|
4751
|
-
}
|
|
4752
|
-
/**
|
|
4753
4638
|
* Tool management (delegated to RunHandler)
|
|
4754
4639
|
*/
|
|
4755
4640
|
addTool(tool) {
|
|
@@ -6032,5 +5917,5 @@ var ɵInterruptState = class {
|
|
|
6032
5917
|
};
|
|
6033
5918
|
|
|
6034
5919
|
//#endregion
|
|
6035
|
-
export { AgentRegistry, AgentThreadLockedError, ContextStore, CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, IntelligenceAgent, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, RunHandler, StateManager,
|
|
5920
|
+
export { AgentRegistry, AgentThreadLockedError, ContextStore, CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, IntelligenceAgent, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, RunHandler, StateManager, SuggestionEngine, ToolCallStatus, completePartialMarkdown, createActionGroup, createEffect, createReducer, createSelector, createStore, empty, ensureObjectArgs, isAbortError, isRunCompletionAware, ofType, on, parseToolArguments, props, select, ɵCOPILOTKIT_FEATURES, ɵInterruptState, ɵMAX_SOCKET_RETRIES, createMemoryStore as ɵcreateMemoryStore, ɵcreateThreadSelectors, createThreadStore as ɵcreateThreadStore, ɵisCopilotKitFeature, isRetryableStatus as ɵisRetryableMemoryStatus, ɵjoinPhoenixChannel$, ɵmapMemoryMetadataEvent, ɵmemoryAdapterEvents, ɵmemoryDomainEvents, ɵmemoryReducer, ɵmemoryRestEvents, ɵobservePhoenixEvent$, ɵobservePhoenixJoinOutcome$, ɵobservePhoenixSocketHealth$, ɵobservePhoenixSocketSignals$, ɵphoenixChannel$, ɵphoenixSocket$, ɵselectFetchMoreError, ɵselectHasNextPage, ɵselectIsFetchingNextPage, ɵselectIsMutating, ɵselectMemories, ɵselectMemoriesAvailable, ɵselectMemoriesError, ɵselectMemoriesIsLoading, ɵselectMemoriesIsMutating, ɵselectMemoriesRealtimeStatus, ɵselectThreads, ɵselectThreadsError, ɵselectThreadsIsLoading, ɵthreadAdapterEvents };
|
|
6036
5921
|
//# sourceMappingURL=index.mjs.map
|