@copilotkit/core 1.59.3 → 1.59.5

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.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
- self.activeRunCompletionPromise = new Promise((resolve) => {
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
- self.activeRunCompletionPromise = void 0;
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));
@@ -969,6 +988,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
969
988
  _defineProperty(this, "_runtimeVersion", void 0);
970
989
  _defineProperty(this, "_runtimeConnectionStatus", CopilotKitCoreRuntimeConnectionStatus.Disconnected);
971
990
  _defineProperty(this, "_runtimeTransport", "auto");
991
+ _defineProperty(this, "_requestedTransport", "auto");
972
992
  _defineProperty(this, "_audioFileTranscriptionEnabled", false);
973
993
  _defineProperty(this, "_runtimeMode", _copilotkit_shared.RUNTIME_MODE_SSE);
974
994
  _defineProperty(this, "_intelligence", void 0);
@@ -1035,7 +1055,8 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
1035
1055
  this.updateRuntimeConnection();
1036
1056
  }
1037
1057
  setRuntimeTransport(runtimeTransport) {
1038
- if (this._runtimeTransport === runtimeTransport) return;
1058
+ if (this._requestedTransport === runtimeTransport) return;
1059
+ this._requestedTransport = runtimeTransport;
1039
1060
  this._runtimeTransport = runtimeTransport;
1040
1061
  this.updateRuntimeConnection();
1041
1062
  }
@@ -4069,6 +4090,7 @@ exports.createSelector = createSelector;
4069
4090
  exports.createStore = createStore;
4070
4091
  exports.empty = empty;
4071
4092
  exports.ensureObjectArgs = ensureObjectArgs;
4093
+ exports.isRunCompletionAware = isRunCompletionAware;
4072
4094
  exports.ofType = ofType;
4073
4095
  exports.on = on;
4074
4096
  exports.parseToolArguments = parseToolArguments;