@copilotkit/core 1.59.3 → 1.59.5-canary.1781104893
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 +26 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +38 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +38 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +26 -7
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +30 -6
- package/dist/index.umd.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -137,12 +137,27 @@ var AgentThreadLockedError = class extends Error {
|
|
|
137
137
|
this.name = "AgentThreadLockedError";
|
|
138
138
|
}
|
|
139
139
|
};
|
|
140
|
+
/**
|
|
141
|
+
* Type guard for {@link RunCompletionAware}. Returns true when `agent` exposes
|
|
142
|
+
* an `activeRunCompletionPromise` property, so callers can await an in-flight
|
|
143
|
+
* run without an `as unknown as` cast. Returns false for agents that don't
|
|
144
|
+
* implement the contract, letting the caller skip the await and degrade safely.
|
|
145
|
+
*/
|
|
146
|
+
function isRunCompletionAware(agent) {
|
|
147
|
+
return typeof agent === "object" && agent !== null && "activeRunCompletionPromise" in agent;
|
|
148
|
+
}
|
|
140
149
|
var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAgent {
|
|
141
150
|
config;
|
|
142
151
|
socket = null;
|
|
143
152
|
activeChannel = null;
|
|
144
153
|
canonicalRunId = null;
|
|
145
154
|
sharedState;
|
|
155
|
+
/**
|
|
156
|
+
* Resolves when the active run's pipeline finalizes; `undefined` between runs.
|
|
157
|
+
* Set/cleared inside {@link connectAgent}'s observable lifecycle. Declared
|
|
158
|
+
* here so {@link RunCompletionAware} consumers can read it without a cast.
|
|
159
|
+
*/
|
|
160
|
+
activeRunCompletionPromise;
|
|
146
161
|
constructor(config, sharedState = { lastSeenEventIds: /* @__PURE__ */ new Map() }) {
|
|
147
162
|
super();
|
|
148
163
|
this.config = config;
|
|
@@ -196,7 +211,7 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
196
211
|
await this.onInitialize(input, subscribers);
|
|
197
212
|
self.activeRunDetach$ = new rxjs.Subject();
|
|
198
213
|
let resolveCompletion;
|
|
199
|
-
|
|
214
|
+
this.activeRunCompletionPromise = new Promise((resolve) => {
|
|
200
215
|
resolveCompletion = resolve;
|
|
201
216
|
});
|
|
202
217
|
const source$ = (0, rxjs.defer)(() => this.connect(input)).pipe((0, _ag_ui_client.transformChunks)(this.debug), (0, rxjs_operators.takeUntil)(self.activeRunDetach$));
|
|
@@ -209,7 +224,7 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
209
224
|
this.onFinalize(input, subscribers);
|
|
210
225
|
resolveCompletion?.();
|
|
211
226
|
resolveCompletion = void 0;
|
|
212
|
-
|
|
227
|
+
this.activeRunCompletionPromise = void 0;
|
|
213
228
|
self.activeRunDetach$ = void 0;
|
|
214
229
|
})), { defaultValue: void 0 });
|
|
215
230
|
const newMessages = (0, _ag_ui_client.structuredClone_)(this.messages).filter((m) => !previousMessageIds.has(m.id));
|
|
@@ -676,9 +691,11 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
|
|
|
676
691
|
if (this.transport === "single") {
|
|
677
692
|
if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
|
|
678
693
|
const requestInit = this.createSingleRouteRequestInit(input, "agent/connect", { agentId: routedId });
|
|
679
|
-
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
|
|
694
|
+
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
|
|
680
695
|
}
|
|
681
|
-
|
|
696
|
+
const connectUrl = `${this.runtimeUrl}/agent/${routedId}/connect`;
|
|
697
|
+
const connectRequestInit = this.requestInit(input);
|
|
698
|
+
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(connectUrl, connectRequestInit))));
|
|
682
699
|
}
|
|
683
700
|
#runViaDelegate(input) {
|
|
684
701
|
return (0, rxjs.defer)(() => (0, rxjs.from)(this.resolveDelegate())).pipe((0, rxjs_operators.switchMap)((delegate) => withAbortErrorHandling(delegate.run(input))));
|
|
@@ -687,7 +704,7 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
|
|
|
687
704
|
if (this.transport === "single") {
|
|
688
705
|
if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
|
|
689
706
|
const requestInit = this.createSingleRouteRequestInit(input, "agent/run", { agentId: this.routedAgentId() });
|
|
690
|
-
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
|
|
707
|
+
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
|
|
691
708
|
}
|
|
692
709
|
return withAbortErrorHandling(super.run(input));
|
|
693
710
|
}
|
|
@@ -855,6 +872,7 @@ var AgentRegistry = class {
|
|
|
855
872
|
_runtimeVersion;
|
|
856
873
|
_runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Disconnected;
|
|
857
874
|
_runtimeTransport = "auto";
|
|
875
|
+
_requestedTransport = "auto";
|
|
858
876
|
_audioFileTranscriptionEnabled = false;
|
|
859
877
|
_runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
860
878
|
_intelligence;
|
|
@@ -923,7 +941,8 @@ var AgentRegistry = class {
|
|
|
923
941
|
this.updateRuntimeConnection();
|
|
924
942
|
}
|
|
925
943
|
setRuntimeTransport(runtimeTransport) {
|
|
926
|
-
if (this.
|
|
944
|
+
if (this._requestedTransport === runtimeTransport) return;
|
|
945
|
+
this._requestedTransport = runtimeTransport;
|
|
927
946
|
this._runtimeTransport = runtimeTransport;
|
|
928
947
|
this.updateRuntimeConnection();
|
|
929
948
|
}
|
|
@@ -3901,6 +3920,7 @@ exports.createSelector = createSelector;
|
|
|
3901
3920
|
exports.createStore = createStore;
|
|
3902
3921
|
exports.empty = empty;
|
|
3903
3922
|
exports.ensureObjectArgs = ensureObjectArgs;
|
|
3923
|
+
exports.isRunCompletionAware = isRunCompletionAware;
|
|
3904
3924
|
exports.ofType = ofType;
|
|
3905
3925
|
exports.on = on;
|
|
3906
3926
|
exports.parseToolArguments = parseToolArguments;
|