@copilotkitnext/core 1.53.0-next.6 → 1.53.1-next.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 +48 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +49 -23
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +48 -22
- package/dist/index.umd.js.map +1 -1
- package/package.json +4 -4
package/dist/index.cjs
CHANGED
|
@@ -1727,26 +1727,18 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
1727
1727
|
return new IntelligenceAgent(this.config);
|
|
1728
1728
|
}
|
|
1729
1729
|
abortRun() {
|
|
1730
|
-
if (
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
"Content-Type": "application/json",
|
|
1743
|
-
...headers
|
|
1744
|
-
},
|
|
1745
|
-
...credentials ? { credentials } : {}
|
|
1746
|
-
}).catch((error) => {
|
|
1747
|
-
console.error("IntelligenceAgent: stop request failed", error);
|
|
1748
|
-
});
|
|
1749
|
-
this.cleanup();
|
|
1730
|
+
if (this.activeChannel && this.threadId) {
|
|
1731
|
+
const fallback = setTimeout(() => this.cleanup(), 5e3);
|
|
1732
|
+
const clear = () => {
|
|
1733
|
+
clearTimeout(fallback);
|
|
1734
|
+
this.cleanup();
|
|
1735
|
+
};
|
|
1736
|
+
this.activeChannel.push(_copilotkitnext_shared.AG_UI_CHANNEL_EVENT, {
|
|
1737
|
+
type: _ag_ui_client.EventType.CUSTOM,
|
|
1738
|
+
name: "stop",
|
|
1739
|
+
value: { threadId: this.threadId }
|
|
1740
|
+
}).receive("ok", clear).receive("error", clear).receive("timeout", clear);
|
|
1741
|
+
} else this.cleanup();
|
|
1750
1742
|
}
|
|
1751
1743
|
/**
|
|
1752
1744
|
* Connect to a Phoenix channel scoped to the thread, trigger the run via
|
|
@@ -1760,7 +1752,11 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
1760
1752
|
run(input) {
|
|
1761
1753
|
return new rxjs.Observable((observer) => {
|
|
1762
1754
|
this.threadId = input.threadId;
|
|
1763
|
-
const socket = new phoenix.Socket(this.config.url, {
|
|
1755
|
+
const socket = new phoenix.Socket(this.config.url, {
|
|
1756
|
+
params: this.config.socketParams ?? {},
|
|
1757
|
+
reconnectAfterMs: (0, _copilotkitnext_shared.phoenixExponentialBackoff)(100, 1e4),
|
|
1758
|
+
rejoinAfterMs: (0, _copilotkitnext_shared.phoenixExponentialBackoff)(1e3, 3e4)
|
|
1759
|
+
});
|
|
1764
1760
|
this.socket = socket;
|
|
1765
1761
|
socket.connect();
|
|
1766
1762
|
const channel = socket.channel(`agent:${input.threadId}`, { runId: input.runId });
|
|
@@ -1775,6 +1771,19 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
1775
1771
|
this.cleanup();
|
|
1776
1772
|
}
|
|
1777
1773
|
});
|
|
1774
|
+
const MAX_CONSECUTIVE_ERRORS = 5;
|
|
1775
|
+
let consecutiveErrors = 0;
|
|
1776
|
+
socket.onError(() => {
|
|
1777
|
+
consecutiveErrors++;
|
|
1778
|
+
if (consecutiveErrors >= MAX_CONSECUTIVE_ERRORS) {
|
|
1779
|
+
observer.error(/* @__PURE__ */ new Error(`WebSocket connection failed after ${MAX_CONSECUTIVE_ERRORS} consecutive errors`));
|
|
1780
|
+
this.cleanup();
|
|
1781
|
+
}
|
|
1782
|
+
});
|
|
1783
|
+
socket.onOpen(() => {
|
|
1784
|
+
consecutiveErrors = 0;
|
|
1785
|
+
});
|
|
1786
|
+
channel.onError(() => {});
|
|
1778
1787
|
channel.join().receive("ok", () => {
|
|
1779
1788
|
const { runtimeUrl, agentId, headers, credentials } = this.config;
|
|
1780
1789
|
const runPath = `${runtimeUrl}/agent/${encodeURIComponent(agentId)}/run`;
|
|
@@ -1819,7 +1828,11 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
1819
1828
|
connect(input) {
|
|
1820
1829
|
return new rxjs.Observable((observer) => {
|
|
1821
1830
|
this.threadId = input.threadId;
|
|
1822
|
-
const socket = new phoenix.Socket(this.config.url, {
|
|
1831
|
+
const socket = new phoenix.Socket(this.config.url, {
|
|
1832
|
+
params: this.config.socketParams ?? {},
|
|
1833
|
+
reconnectAfterMs: (0, _copilotkitnext_shared.phoenixExponentialBackoff)(100, 1e4),
|
|
1834
|
+
rejoinAfterMs: (0, _copilotkitnext_shared.phoenixExponentialBackoff)(1e3, 3e4)
|
|
1835
|
+
});
|
|
1823
1836
|
this.socket = socket;
|
|
1824
1837
|
socket.connect();
|
|
1825
1838
|
const channel = socket.channel(`agent:${input.threadId}`, { mode: "connect" });
|
|
@@ -1831,6 +1844,19 @@ var IntelligenceAgent = class IntelligenceAgent extends _ag_ui_client.AbstractAg
|
|
|
1831
1844
|
this.cleanup();
|
|
1832
1845
|
}
|
|
1833
1846
|
});
|
|
1847
|
+
const MAX_CONSECUTIVE_ERRORS = 5;
|
|
1848
|
+
let consecutiveErrors = 0;
|
|
1849
|
+
socket.onError(() => {
|
|
1850
|
+
consecutiveErrors++;
|
|
1851
|
+
if (consecutiveErrors >= MAX_CONSECUTIVE_ERRORS) {
|
|
1852
|
+
observer.error(/* @__PURE__ */ new Error(`WebSocket connection failed after ${MAX_CONSECUTIVE_ERRORS} consecutive errors`));
|
|
1853
|
+
this.cleanup();
|
|
1854
|
+
}
|
|
1855
|
+
});
|
|
1856
|
+
socket.onOpen(() => {
|
|
1857
|
+
consecutiveErrors = 0;
|
|
1858
|
+
});
|
|
1859
|
+
channel.onError(() => {});
|
|
1834
1860
|
channel.join().receive("ok", () => {
|
|
1835
1861
|
channel.push(_ag_ui_client.EventType.CUSTOM, {
|
|
1836
1862
|
type: _ag_ui_client.EventType.CUSTOM,
|