@copilotkit/core 1.68.3-canary.1787220377 → 1.69.0
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 +101 -155
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -71
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +12 -71
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +102 -155
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +118 -165
- 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
|
/**
|
|
@@ -2777,6 +2802,7 @@ const isContinuation = (input) => input.resume !== void 0 || Object.prototype.ha
|
|
|
2777
2802
|
var StateManager = class {
|
|
2778
2803
|
stateByRun = /* @__PURE__ */ new Map();
|
|
2779
2804
|
messageToRun = /* @__PURE__ */ new Map();
|
|
2805
|
+
rawEventByMessage = /* @__PURE__ */ new Map();
|
|
2780
2806
|
activeRun = /* @__PURE__ */ new Map();
|
|
2781
2807
|
agentSubscriptions = /* @__PURE__ */ new Map();
|
|
2782
2808
|
pendingContinuations = /* @__PURE__ */ new WeakMap();
|
|
@@ -2828,12 +2854,13 @@ var StateManager = class {
|
|
|
2828
2854
|
runId: subRunId ?? input.runId
|
|
2829
2855
|
});
|
|
2830
2856
|
const { unsubscribe } = agent.subscribe({
|
|
2831
|
-
onRunStartedEvent: ({ input, state }) => {
|
|
2857
|
+
onRunStartedEvent: ({ event, input, state }) => {
|
|
2832
2858
|
if (revoked) return;
|
|
2833
2859
|
const internalContinuation = [...this.pendingContinuations.get(agent) ?? []].find((pending) => pending.expectedInput === input);
|
|
2834
2860
|
internalContinuation?.cancel();
|
|
2835
|
-
if (
|
|
2836
|
-
else subRunId
|
|
2861
|
+
if (internalContinuation) subRunId = internalContinuation.expectedRunId ?? event.runId ?? input.runId;
|
|
2862
|
+
else if (runFinished && input.runId === subRunId && !isContinuation(input) && (event.runId == null || event.runId === subRunId)) subRunId = randomUUID();
|
|
2863
|
+
else subRunId = event.runId || input.runId;
|
|
2837
2864
|
runFinished = false;
|
|
2838
2865
|
this.handleRunStarted(agent, effectiveInput(input), state);
|
|
2839
2866
|
},
|
|
@@ -2855,13 +2882,22 @@ var StateManager = class {
|
|
|
2855
2882
|
if (revoked) return;
|
|
2856
2883
|
this.handleStateDelta(agent, event, effectiveInput(input), state);
|
|
2857
2884
|
},
|
|
2885
|
+
onTextMessageStartEvent: ({ event, input }) => {
|
|
2886
|
+
if (revoked) return;
|
|
2887
|
+
this.handleTextMessageStart(agent, event, effectiveInput(input));
|
|
2888
|
+
},
|
|
2858
2889
|
onMessagesSnapshotEvent: ({ event, input, messages }) => {
|
|
2859
2890
|
if (revoked) return;
|
|
2860
2891
|
this.handleMessagesSnapshot(agent, event, effectiveInput(input), messages);
|
|
2892
|
+
this.pruneRawEvents(agent.agentId, input.threadId, event.messages, effectiveInput(input));
|
|
2861
2893
|
},
|
|
2862
2894
|
onNewMessage: ({ message, input }) => {
|
|
2863
2895
|
if (revoked) return;
|
|
2864
2896
|
this.handleNewMessage(agent, message, input ? effectiveInput(input) : void 0);
|
|
2897
|
+
},
|
|
2898
|
+
onMessagesChanged: ({ messages, input }) => {
|
|
2899
|
+
if (revoked) return;
|
|
2900
|
+
if (!input) this.pruneRawEvents(agent.agentId, agent.threadId, messages);
|
|
2865
2901
|
}
|
|
2866
2902
|
});
|
|
2867
2903
|
this.agentSubscriptions.set(agentId, () => {
|
|
@@ -2879,6 +2915,7 @@ var StateManager = class {
|
|
|
2879
2915
|
unsubscribe();
|
|
2880
2916
|
this.agentSubscriptions.delete(agentId);
|
|
2881
2917
|
}
|
|
2918
|
+
this.rawEventByMessage.delete(agentId);
|
|
2882
2919
|
}
|
|
2883
2920
|
/**
|
|
2884
2921
|
* Get state for a specific run
|
|
@@ -2896,6 +2933,13 @@ var StateManager = class {
|
|
|
2896
2933
|
return this.messageToRun.get(agentId)?.get(threadId)?.get(messageId);
|
|
2897
2934
|
}
|
|
2898
2935
|
/**
|
|
2936
|
+
* Get direct text-start metadata associated with a message.
|
|
2937
|
+
*/
|
|
2938
|
+
getRawEventForMessage(agentId, threadId, messageId) {
|
|
2939
|
+
const rawEvent = this.rawEventByMessage.get(agentId)?.get(threadId)?.get(messageId);
|
|
2940
|
+
return rawEvent === void 0 ? void 0 : structuredClone_(rawEvent);
|
|
2941
|
+
}
|
|
2942
|
+
/**
|
|
2899
2943
|
* Get all states for an agent's thread
|
|
2900
2944
|
*/
|
|
2901
2945
|
getStatesForThread(agentId, threadId) {
|
|
@@ -2947,12 +2991,30 @@ var StateManager = class {
|
|
|
2947
2991
|
this.saveState(agent.agentId, threadId, runId, state);
|
|
2948
2992
|
}
|
|
2949
2993
|
/**
|
|
2994
|
+
* Capture only defined metadata from a normalized direct text-start event.
|
|
2995
|
+
*/
|
|
2996
|
+
handleTextMessageStart(agent, event, input) {
|
|
2997
|
+
if (!agent.agentId) return;
|
|
2998
|
+
const { threadId } = input;
|
|
2999
|
+
if (event.rawEvent === void 0) {
|
|
3000
|
+
const threadEvents = this.rawEventByMessage.get(agent.agentId)?.get(threadId);
|
|
3001
|
+
threadEvents?.delete(event.messageId);
|
|
3002
|
+
if (threadEvents?.size === 0) this.rawEventByMessage.get(agent.agentId)?.delete(threadId);
|
|
3003
|
+
if (this.rawEventByMessage.get(agent.agentId)?.size === 0) this.rawEventByMessage.delete(agent.agentId);
|
|
3004
|
+
return;
|
|
3005
|
+
}
|
|
3006
|
+
if (!this.rawEventByMessage.has(agent.agentId)) this.rawEventByMessage.set(agent.agentId, /* @__PURE__ */ new Map());
|
|
3007
|
+
const agentEvents = this.rawEventByMessage.get(agent.agentId);
|
|
3008
|
+
if (!agentEvents.has(threadId)) agentEvents.set(threadId, /* @__PURE__ */ new Map());
|
|
3009
|
+
agentEvents.get(threadId).set(event.messageId, event.rawEvent);
|
|
3010
|
+
}
|
|
3011
|
+
/**
|
|
2950
3012
|
* Handle messages snapshot event
|
|
2951
3013
|
*/
|
|
2952
3014
|
handleMessagesSnapshot(agent, event, input, messages) {
|
|
2953
3015
|
if (!agent.agentId) return;
|
|
2954
3016
|
const { threadId, runId } = input;
|
|
2955
|
-
for (const message of event.messages) this.associateMessageWithRun(agent.agentId, threadId, message.id, runId);
|
|
3017
|
+
for (const message of event.messages) if (this.getRunIdForMessage(agent.agentId, threadId, message.id) === void 0) this.associateMessageWithRun(agent.agentId, threadId, message.id, runId);
|
|
2956
3018
|
}
|
|
2957
3019
|
/**
|
|
2958
3020
|
* Handle new message event
|
|
@@ -2986,12 +3048,23 @@ var StateManager = class {
|
|
|
2986
3048
|
if (!agentMessages.has(threadId)) agentMessages.set(threadId, /* @__PURE__ */ new Map());
|
|
2987
3049
|
agentMessages.get(threadId).set(messageId, runId);
|
|
2988
3050
|
}
|
|
3051
|
+
pruneRawEvents(agentId, fallbackThreadId, messages, input) {
|
|
3052
|
+
const threadId = input?.threadId ?? fallbackThreadId;
|
|
3053
|
+
if (!threadId) return;
|
|
3054
|
+
const threadEvents = this.rawEventByMessage.get(agentId)?.get(threadId);
|
|
3055
|
+
if (!threadEvents) return;
|
|
3056
|
+
const messageIds = new Set(messages.map((message) => message.id));
|
|
3057
|
+
for (const messageId of threadEvents.keys()) if (!messageIds.has(messageId)) threadEvents.delete(messageId);
|
|
3058
|
+
if (threadEvents.size === 0) this.rawEventByMessage.get(agentId)?.delete(threadId);
|
|
3059
|
+
if (this.rawEventByMessage.get(agentId)?.size === 0) this.rawEventByMessage.delete(agentId);
|
|
3060
|
+
}
|
|
2989
3061
|
/**
|
|
2990
3062
|
* Clear all state for an agent
|
|
2991
3063
|
*/
|
|
2992
3064
|
clearAgentState(agentId) {
|
|
2993
3065
|
this.stateByRun.delete(agentId);
|
|
2994
3066
|
this.messageToRun.delete(agentId);
|
|
3067
|
+
this.rawEventByMessage.delete(agentId);
|
|
2995
3068
|
}
|
|
2996
3069
|
/**
|
|
2997
3070
|
* Clear all state for a thread
|
|
@@ -2999,124 +3072,7 @@ var StateManager = class {
|
|
|
2999
3072
|
clearThreadState(agentId, threadId) {
|
|
3000
3073
|
this.stateByRun.get(agentId)?.delete(threadId);
|
|
3001
3074
|
this.messageToRun.get(agentId)?.delete(threadId);
|
|
3002
|
-
|
|
3003
|
-
};
|
|
3004
|
-
|
|
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:");
|
|
3075
|
+
this.rawEventByMessage.get(agentId)?.delete(threadId);
|
|
3120
3076
|
}
|
|
3121
3077
|
};
|
|
3122
3078
|
|
|
@@ -4308,7 +4264,6 @@ var CopilotKitCore = class {
|
|
|
4308
4264
|
suggestionEngine;
|
|
4309
4265
|
runHandler;
|
|
4310
4266
|
stateManager;
|
|
4311
|
-
subagentRegistry;
|
|
4312
4267
|
threadStoreRegistry;
|
|
4313
4268
|
/**
|
|
4314
4269
|
* The single core-owned memory store, created lazily on first
|
|
@@ -4334,7 +4289,6 @@ var CopilotKitCore = class {
|
|
|
4334
4289
|
this.suggestionEngine = new SuggestionEngine(this);
|
|
4335
4290
|
this.runHandler = new RunHandler(this);
|
|
4336
4291
|
this.stateManager = new StateManager(this);
|
|
4337
|
-
this.subagentRegistry = new SubagentRegistry(this);
|
|
4338
4292
|
this.threadStoreRegistry = new ThreadStoreRegistry(this);
|
|
4339
4293
|
this.agentRegistry.initialize(agents__unsafe_dev_only);
|
|
4340
4294
|
this.runHandler.initialize(tools);
|
|
@@ -4349,10 +4303,7 @@ var CopilotKitCore = class {
|
|
|
4349
4303
|
},
|
|
4350
4304
|
onAgentsChanged: ({ agents }) => {
|
|
4351
4305
|
Object.values(agents).forEach((agent) => {
|
|
4352
|
-
if (agent.agentId)
|
|
4353
|
-
this.stateManager.subscribeToAgent(agent);
|
|
4354
|
-
this.subagentRegistry.subscribeToAgent(agent);
|
|
4355
|
-
}
|
|
4306
|
+
if (agent.agentId) this.stateManager.subscribeToAgent(agent);
|
|
4356
4307
|
});
|
|
4357
4308
|
const currentAgentIds = new Set(Object.keys(agents));
|
|
4358
4309
|
for (const agentId of Object.keys(this.threadStoreRegistry.getAll())) if (this.previousAgentIds.has(agentId) && !currentAgentIds.has(agentId)) try {
|
|
@@ -4360,17 +4311,10 @@ var CopilotKitCore = class {
|
|
|
4360
4311
|
} catch (err) {
|
|
4361
4312
|
console.error(`CopilotKitCore.onAgentsChanged: threadStoreRegistry.unregister failed for "${agentId}":`, err);
|
|
4362
4313
|
}
|
|
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
|
-
}
|
|
4314
|
+
for (const agentId of this.previousAgentIds) if (!currentAgentIds.has(agentId)) try {
|
|
4315
|
+
this.stateManager.unsubscribeFromAgent(agentId);
|
|
4316
|
+
} catch (err) {
|
|
4317
|
+
console.error(`CopilotKitCore.onAgentsChanged: stateManager.unsubscribeFromAgent failed for "${agentId}":`, err);
|
|
4374
4318
|
}
|
|
4375
4319
|
this.previousAgentIds = currentAgentIds;
|
|
4376
4320
|
}
|
|
@@ -4740,16 +4684,6 @@ var CopilotKitCore = class {
|
|
|
4740
4684
|
return this.suggestionEngine.getSuggestions(agentId);
|
|
4741
4685
|
}
|
|
4742
4686
|
/**
|
|
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
4687
|
* Tool management (delegated to RunHandler)
|
|
4754
4688
|
*/
|
|
4755
4689
|
addTool(tool) {
|
|
@@ -4968,6 +4902,9 @@ var CopilotKitCore = class {
|
|
|
4968
4902
|
getRunIdForMessage(agentId, threadId, messageId) {
|
|
4969
4903
|
return this.stateManager.getRunIdForMessage(agentId, threadId, messageId);
|
|
4970
4904
|
}
|
|
4905
|
+
getRawEventForMessage(agentId, threadId, messageId) {
|
|
4906
|
+
return this.stateManager.getRawEventForMessage(agentId, threadId, messageId);
|
|
4907
|
+
}
|
|
4971
4908
|
getRunIdsForThread(agentId, threadId) {
|
|
4972
4909
|
return this.stateManager.getRunIdsForThread(agentId, threadId);
|
|
4973
4910
|
}
|
|
@@ -5252,6 +5189,16 @@ function optionalString(value) {
|
|
|
5252
5189
|
return typeof value === "string" && value.length > 0 ? value : void 0;
|
|
5253
5190
|
}
|
|
5254
5191
|
/**
|
|
5192
|
+
* REST `/threads` is agent-scoped. The Phoenix `user_meta` channel is not.
|
|
5193
|
+
* Drop live upserts that belong to a different agent, or one Inspector
|
|
5194
|
+
* `all-agents` flatten shows the same thread twice until a hard refresh.
|
|
5195
|
+
*/
|
|
5196
|
+
function threadMetadataTargetsAgent(payload, agentId) {
|
|
5197
|
+
if (!agentId || payload.operation === "deleted") return true;
|
|
5198
|
+
const threadAgentId = optionalString(payload.thread.agentId);
|
|
5199
|
+
return !threadAgentId || threadAgentId === agentId;
|
|
5200
|
+
}
|
|
5201
|
+
/**
|
|
5255
5202
|
* Converts gateway run-activity payloads into the internal TypeScript shape.
|
|
5256
5203
|
*/
|
|
5257
5204
|
function normalizeThreadRunActivityNotification(payload) {
|
|
@@ -5677,7 +5624,7 @@ function createThreadStore(environment) {
|
|
|
5677
5624
|
}))), ɵobservePhoenixJoinOutcome$(channel$).pipe(filter((outcome) => outcome.type !== "joined"), map((outcome) => outcome.type === "timeout" ? threadSocketEvents.joinTimedOut({ sessionId: action.sessionId }) : threadSocketEvents.joinFailed({ sessionId: action.sessionId })))).pipe(takeUntil(merge(shutdown$, fatalSocketShutdown$)));
|
|
5678
5625
|
});
|
|
5679
5626
|
}))),
|
|
5680
|
-
createEffect((actions$, state$) => actions$.pipe(ofType(threadSocketEvents.metadataReceived), withLatestFrom(state$), filter(([action, state]) => action.sessionId === state.sessionId), map(([action, state]) => {
|
|
5627
|
+
createEffect((actions$, state$) => actions$.pipe(ofType(threadSocketEvents.metadataReceived), withLatestFrom(state$), filter(([action, state]) => action.sessionId === state.sessionId && threadMetadataTargetsAgent(action.payload, state.context?.agentId)), map(([action, state]) => {
|
|
5681
5628
|
if (action.payload.operation === "deleted") return threadDomainEvents.threadDeleted({
|
|
5682
5629
|
sessionId: action.sessionId,
|
|
5683
5630
|
threadId: action.payload.deleted.id
|
|
@@ -6032,5 +5979,5 @@ var ɵInterruptState = class {
|
|
|
6032
5979
|
};
|
|
6033
5980
|
|
|
6034
5981
|
//#endregion
|
|
6035
|
-
export { AgentRegistry, AgentThreadLockedError, ContextStore, CopilotKitCore, CopilotKitCoreErrorCode, CopilotKitCoreRuntimeConnectionStatus, IntelligenceAgent, MEMORY_ERROR_REGISTRY, MemoryError, ProxiedCopilotRuntimeAgent, RunHandler, StateManager,
|
|
5982
|
+
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
5983
|
//# sourceMappingURL=index.mjs.map
|