@copilotkit/core 1.57.1 → 1.57.2
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 +71 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +55 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +55 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +71 -3
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +59 -4
- package/dist/index.umd.js.map +1 -1
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -255,10 +255,22 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
255
255
|
* Reconnect to an existing thread by fetching websocket credentials and
|
|
256
256
|
* joining the realtime thread channel.
|
|
257
257
|
*/
|
|
258
|
+
/**
|
|
259
|
+
* Reconnect to an existing thread by fetching websocket credentials
|
|
260
|
+
* and joining the realtime thread channel.
|
|
261
|
+
*
|
|
262
|
+
* Note: this method does NOT clear the replay cursor. Whether to
|
|
263
|
+
* request a full historical replay vs. resume from
|
|
264
|
+
* `lastSeenEventId` is a decision the caller (typically
|
|
265
|
+
* `RunHandler.connectAgent`) makes by calling
|
|
266
|
+
* {@link clearReconnectCursor} ahead of time on a fresh thread
|
|
267
|
+
* restore. Same-thread churn re-connects preserve the cursor so the
|
|
268
|
+
* gateway only streams events past it instead of replaying the
|
|
269
|
+
* entire history every time the chat re-opens a socket.
|
|
270
|
+
*/
|
|
258
271
|
connect(input) {
|
|
259
272
|
this.threadId = input.threadId;
|
|
260
273
|
this.canonicalRunId = null;
|
|
261
|
-
this.clearReconnectCursor(input.threadId);
|
|
262
274
|
return (0, rxjs.defer)(() => this.requestJoinCredentials$("connect", input)).pipe((0, rxjs.switchMap)((credentials) => {
|
|
263
275
|
if (credentials === null) return rxjs.EMPTY;
|
|
264
276
|
const canonicalInput = this.applyCanonicalRunIdentity(input, credentials, { fallbackToInputRunId: false });
|
|
@@ -440,6 +452,14 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
440
452
|
getReconnectCursor(input) {
|
|
441
453
|
return this.getLastSeenEventId(input.threadId);
|
|
442
454
|
}
|
|
455
|
+
/**
|
|
456
|
+
* Drop the cached `lastSeenEventId` cursor for `threadId` so the
|
|
457
|
+
* next connect to that topic asks the gateway for a full historical
|
|
458
|
+
* replay (rather than resuming). Public because
|
|
459
|
+
* `RunHandler.connectAgent` calls it on a detected thread switch
|
|
460
|
+
* to rebuild local state from scratch, and skips it on same-thread
|
|
461
|
+
* churn so the gateway can resume.
|
|
462
|
+
*/
|
|
443
463
|
clearReconnectCursor(threadId) {
|
|
444
464
|
this.sharedState.lastSeenEventIds.delete(threadId);
|
|
445
465
|
}
|
|
@@ -694,6 +714,22 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
|
|
|
694
714
|
}
|
|
695
715
|
return cloned;
|
|
696
716
|
}
|
|
717
|
+
/**
|
|
718
|
+
* Drop the delegate's cached `lastSeenEventId` for this thread so
|
|
719
|
+
* the next connect requests a full historical replay from the
|
|
720
|
+
* gateway. Used by `RunHandler.connectAgent` on a detected thread
|
|
721
|
+
* switch (the chat moved between threads, so its local
|
|
722
|
+
* messages/state are about to be cleared and need rebuilding from
|
|
723
|
+
* the gateway). Skipped on same-thread churn re-connects so the
|
|
724
|
+
* gateway can resume from the cursor instead.
|
|
725
|
+
*
|
|
726
|
+
* No-op for non-Intelligence runtime modes — the HTTP transport
|
|
727
|
+
* doesn't replay.
|
|
728
|
+
*/
|
|
729
|
+
clearReplayCursor(threadId) {
|
|
730
|
+
if (this.runtimeMode !== _copilotkit_shared.RUNTIME_MODE_INTELLIGENCE) return;
|
|
731
|
+
this.delegate?.clearReconnectCursor?.(threadId);
|
|
732
|
+
}
|
|
697
733
|
async resolveDelegate() {
|
|
698
734
|
await this.ensureRuntimeMode();
|
|
699
735
|
if (!this.delegate) {
|
|
@@ -825,6 +861,7 @@ var AgentRegistry = class {
|
|
|
825
861
|
_a2uiEnabled = false;
|
|
826
862
|
_openGenerativeUIEnabled = false;
|
|
827
863
|
_licenseStatus;
|
|
864
|
+
_telemetryDisabled = false;
|
|
828
865
|
constructor(core) {
|
|
829
866
|
this.core = core;
|
|
830
867
|
}
|
|
@@ -864,6 +901,9 @@ var AgentRegistry = class {
|
|
|
864
901
|
get licenseStatus() {
|
|
865
902
|
return this._licenseStatus;
|
|
866
903
|
}
|
|
904
|
+
get telemetryDisabled() {
|
|
905
|
+
return this._telemetryDisabled;
|
|
906
|
+
}
|
|
867
907
|
/**
|
|
868
908
|
* Initialize agents from configuration
|
|
869
909
|
*/
|
|
@@ -1063,6 +1103,7 @@ var AgentRegistry = class {
|
|
|
1063
1103
|
this._a2uiEnabled = runtimeInfoResponse.a2uiEnabled ?? false;
|
|
1064
1104
|
this._openGenerativeUIEnabled = runtimeInfoResponse.openGenerativeUIEnabled ?? false;
|
|
1065
1105
|
this._licenseStatus = runtimeInfoResponse.licenseStatus;
|
|
1106
|
+
this._telemetryDisabled = runtimeInfoResponse.telemetryDisabled ?? false;
|
|
1066
1107
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Connected);
|
|
1067
1108
|
await this.notifyAgentsChanged();
|
|
1068
1109
|
} catch (error) {
|
|
@@ -1531,6 +1572,23 @@ var RunHandler = class {
|
|
|
1531
1572
|
* `processAgentResult`.
|
|
1532
1573
|
*/
|
|
1533
1574
|
_runDepth = 0;
|
|
1575
|
+
/**
|
|
1576
|
+
* Tracks the threadId of the most recent `connectAgent` call so we
|
|
1577
|
+
* can distinguish a fresh thread restore (different threadId than
|
|
1578
|
+
* last time — chat is rebuilding state from scratch, must clear
|
|
1579
|
+
* messages/state and ask the gateway for a full replay) from a
|
|
1580
|
+
* same-thread churn re-connect (effect-dep churn or transient
|
|
1581
|
+
* disconnect — local messages/state are still meaningful, must
|
|
1582
|
+
* preserve them and let the gateway resume from
|
|
1583
|
+
* `lastSeenEventId`).
|
|
1584
|
+
*
|
|
1585
|
+
* Tyler's bug fired because every `connectAgent` was treated as a
|
|
1586
|
+
* fresh restore, which forced the gateway to replay the full
|
|
1587
|
+
* thread history on every churn re-connect and amplified the
|
|
1588
|
+
* downstream churn into duplicate `cpki_event_id` rows in the
|
|
1589
|
+
* inspector and intermittent "Message not found" toasts.
|
|
1590
|
+
*/
|
|
1591
|
+
_lastConnectedThreadId = null;
|
|
1534
1592
|
constructor(core) {
|
|
1535
1593
|
this.core = core;
|
|
1536
1594
|
}
|
|
@@ -1604,9 +1662,16 @@ var RunHandler = class {
|
|
|
1604
1662
|
*/
|
|
1605
1663
|
async connectAgent({ agent }) {
|
|
1606
1664
|
try {
|
|
1665
|
+
const incomingThreadId = agent.threadId ?? null;
|
|
1666
|
+
const isFreshRestore = incomingThreadId !== this._lastConnectedThreadId;
|
|
1667
|
+
this._lastConnectedThreadId = incomingThreadId;
|
|
1607
1668
|
await agent.detachActiveRun();
|
|
1608
|
-
|
|
1609
|
-
|
|
1669
|
+
if (isFreshRestore) {
|
|
1670
|
+
agent.setMessages([]);
|
|
1671
|
+
agent.setState({});
|
|
1672
|
+
const proxied = agent;
|
|
1673
|
+
if (incomingThreadId && typeof proxied.clearReplayCursor === "function") proxied.clearReplayCursor(incomingThreadId);
|
|
1674
|
+
}
|
|
1610
1675
|
if (agent instanceof _ag_ui_client.HttpAgent) agent.headers = { ...this._internal.headers };
|
|
1611
1676
|
const runAgentResult = await agent.connectAgent({
|
|
1612
1677
|
forwardedProps: this._internal.properties,
|
|
@@ -2600,6 +2665,9 @@ var CopilotKitCore = class {
|
|
|
2600
2665
|
get licenseStatus() {
|
|
2601
2666
|
return this.agentRegistry.licenseStatus;
|
|
2602
2667
|
}
|
|
2668
|
+
get telemetryDisabled() {
|
|
2669
|
+
return this.agentRegistry.telemetryDisabled;
|
|
2670
|
+
}
|
|
2603
2671
|
/**
|
|
2604
2672
|
* Configuration updates
|
|
2605
2673
|
*/
|