@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.umd.js
CHANGED
|
@@ -176,6 +176,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
176
176
|
this.name = "AgentThreadLockedError";
|
|
177
177
|
}
|
|
178
178
|
};
|
|
179
|
+
/**
|
|
180
|
+
* Type guard for {@link RunCompletionAware}. Returns true when `agent` exposes
|
|
181
|
+
* an `activeRunCompletionPromise` property, so callers can await an in-flight
|
|
182
|
+
* run without an `as unknown as` cast. Returns false for agents that don't
|
|
183
|
+
* implement the contract, letting the caller skip the await and degrade safely.
|
|
184
|
+
*/
|
|
185
|
+
function isRunCompletionAware(agent) {
|
|
186
|
+
return typeof agent === "object" && agent !== null && "activeRunCompletionPromise" in agent;
|
|
187
|
+
}
|
|
179
188
|
var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAgent {
|
|
180
189
|
constructor(config, sharedState = { lastSeenEventIds: /* @__PURE__ */ new Map() }) {
|
|
181
190
|
super();
|
|
@@ -184,6 +193,16 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
184
193
|
_defineProperty(this, "activeChannel", null);
|
|
185
194
|
_defineProperty(this, "canonicalRunId", null);
|
|
186
195
|
_defineProperty(this, "sharedState", void 0);
|
|
196
|
+
_defineProperty(
|
|
197
|
+
this,
|
|
198
|
+
/**
|
|
199
|
+
* Resolves when the active run's pipeline finalizes; `undefined` between runs.
|
|
200
|
+
* Set/cleared inside {@link connectAgent}'s observable lifecycle. Declared
|
|
201
|
+
* here so {@link RunCompletionAware} consumers can read it without a cast.
|
|
202
|
+
*/
|
|
203
|
+
"activeRunCompletionPromise",
|
|
204
|
+
void 0
|
|
205
|
+
);
|
|
187
206
|
this.config = config;
|
|
188
207
|
this.sharedState = sharedState;
|
|
189
208
|
}
|
|
@@ -236,7 +255,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
236
255
|
await this.onInitialize(input, subscribers);
|
|
237
256
|
self.activeRunDetach$ = new rxjs.Subject();
|
|
238
257
|
let resolveCompletion;
|
|
239
|
-
|
|
258
|
+
this.activeRunCompletionPromise = new Promise((resolve) => {
|
|
240
259
|
resolveCompletion = resolve;
|
|
241
260
|
});
|
|
242
261
|
const source$ = (0, rxjs.defer)(() => this.connect(input)).pipe((0, _ag_ui_client.transformChunks)(this.debug), (0, rxjs_operators.takeUntil)(self.activeRunDetach$));
|
|
@@ -249,7 +268,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
249
268
|
this.onFinalize(input, subscribers);
|
|
250
269
|
resolveCompletion === null || resolveCompletion === void 0 || resolveCompletion();
|
|
251
270
|
resolveCompletion = void 0;
|
|
252
|
-
|
|
271
|
+
this.activeRunCompletionPromise = void 0;
|
|
253
272
|
self.activeRunDetach$ = void 0;
|
|
254
273
|
})), { defaultValue: void 0 });
|
|
255
274
|
const newMessages = (0, _ag_ui_client.structuredClone_)(this.messages).filter((m) => !previousMessageIds.has(m.id));
|
|
@@ -937,9 +956,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
937
956
|
if (this.transport === "single") {
|
|
938
957
|
if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
|
|
939
958
|
const requestInit = this.createSingleRouteRequestInit(input, "agent/connect", { agentId: routedId });
|
|
940
|
-
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
|
|
959
|
+
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
|
|
941
960
|
}
|
|
942
|
-
|
|
961
|
+
const connectUrl = `${this.runtimeUrl}/agent/${routedId}/connect`;
|
|
962
|
+
const connectRequestInit = this.requestInit(input);
|
|
963
|
+
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(connectUrl, connectRequestInit))));
|
|
943
964
|
}
|
|
944
965
|
function _runViaDelegate(input) {
|
|
945
966
|
return (0, rxjs.defer)(() => (0, rxjs.from)(this.resolveDelegate())).pipe((0, rxjs_operators.switchMap)((delegate) => withAbortErrorHandling(delegate.run(input))));
|
|
@@ -948,7 +969,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
948
969
|
if (this.transport === "single") {
|
|
949
970
|
if (!this.singleEndpointUrl) throw new Error("Single endpoint transport requires a runtimeUrl");
|
|
950
971
|
const requestInit = this.createSingleRouteRequestInit(input, "agent/run", { agentId: this.routedAgentId() });
|
|
951
|
-
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(this.singleEndpointUrl, requestInit)));
|
|
972
|
+
return withAbortErrorHandling((0, _ag_ui_client.transformHttpEventStream)((0, _ag_ui_client.runHttpRequest)(() => this.fetch(this.singleEndpointUrl, requestInit))));
|
|
952
973
|
}
|
|
953
974
|
return withAbortErrorHandling(_superPropGet(_ProxiedCopilotRuntimeAgent.prototype, "run", this, 2)([input]));
|
|
954
975
|
}
|
|
@@ -969,6 +990,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
969
990
|
_defineProperty(this, "_runtimeVersion", void 0);
|
|
970
991
|
_defineProperty(this, "_runtimeConnectionStatus", CopilotKitCoreRuntimeConnectionStatus.Disconnected);
|
|
971
992
|
_defineProperty(this, "_runtimeTransport", "auto");
|
|
993
|
+
_defineProperty(this, "_requestedTransport", "auto");
|
|
972
994
|
_defineProperty(this, "_audioFileTranscriptionEnabled", false);
|
|
973
995
|
_defineProperty(this, "_runtimeMode", _copilotkit_shared.RUNTIME_MODE_SSE);
|
|
974
996
|
_defineProperty(this, "_intelligence", void 0);
|
|
@@ -1035,7 +1057,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1035
1057
|
this.updateRuntimeConnection();
|
|
1036
1058
|
}
|
|
1037
1059
|
setRuntimeTransport(runtimeTransport) {
|
|
1038
|
-
if (this.
|
|
1060
|
+
if (this._requestedTransport === runtimeTransport) return;
|
|
1061
|
+
this._requestedTransport = runtimeTransport;
|
|
1039
1062
|
this._runtimeTransport = runtimeTransport;
|
|
1040
1063
|
this.updateRuntimeConnection();
|
|
1041
1064
|
}
|
|
@@ -4069,6 +4092,7 @@ exports.createSelector = createSelector;
|
|
|
4069
4092
|
exports.createStore = createStore;
|
|
4070
4093
|
exports.empty = empty;
|
|
4071
4094
|
exports.ensureObjectArgs = ensureObjectArgs;
|
|
4095
|
+
exports.isRunCompletionAware = isRunCompletionAware;
|
|
4072
4096
|
exports.ofType = ofType;
|
|
4073
4097
|
exports.on = on;
|
|
4074
4098
|
exports.parseToolArguments = parseToolArguments;
|