@copilotkit/core 1.55.0-next.9 → 1.55.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 +97 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +22 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +97 -22
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +98 -23
- package/dist/index.umd.js.map +1 -1
- package/package.json +13 -16
- package/vitest.config.mjs +1 -1
- package/eslint.config.mjs +0 -3
package/dist/index.cjs
CHANGED
|
@@ -520,7 +520,7 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
|
|
|
520
520
|
runtimeInfoPromise;
|
|
521
521
|
constructor(config) {
|
|
522
522
|
const normalizedRuntimeUrl = config.runtimeUrl ? config.runtimeUrl.replace(/\/$/, "") : void 0;
|
|
523
|
-
const transport = config.transport ?? "
|
|
523
|
+
const transport = config.transport ?? "auto";
|
|
524
524
|
const runUrl = transport === "single" ? normalizedRuntimeUrl ?? config.runtimeUrl ?? "" : `${normalizedRuntimeUrl ?? config.runtimeUrl}/agent/${encodeURIComponent(config.agentId ?? "")}/run`;
|
|
525
525
|
if (!runUrl) throw new Error("ProxiedCopilotRuntimeAgent requires a runtimeUrl when transport is set to 'single'.");
|
|
526
526
|
super({
|
|
@@ -689,6 +689,7 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
|
|
|
689
689
|
}
|
|
690
690
|
async fetchRuntimeInfo() {
|
|
691
691
|
const headers = { ...this.headers };
|
|
692
|
+
if (this.transport === "auto") return this.fetchRuntimeInfoAutoDetect(headers);
|
|
692
693
|
let init;
|
|
693
694
|
let url;
|
|
694
695
|
if (this.transport === "single") {
|
|
@@ -711,6 +712,30 @@ var ProxiedCopilotRuntimeAgent = class ProxiedCopilotRuntimeAgent extends _ag_ui
|
|
|
711
712
|
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
712
713
|
return await response.json();
|
|
713
714
|
}
|
|
715
|
+
async fetchRuntimeInfoAutoDetect(headers) {
|
|
716
|
+
try {
|
|
717
|
+
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
718
|
+
headers: { ...headers },
|
|
719
|
+
...this.credentials ? { credentials: this.credentials } : {}
|
|
720
|
+
});
|
|
721
|
+
if (response.status >= 200 && response.status < 300) {
|
|
722
|
+
this.transport = "rest";
|
|
723
|
+
return await response.json();
|
|
724
|
+
}
|
|
725
|
+
} catch {}
|
|
726
|
+
const singleHeaders = { ...headers };
|
|
727
|
+
if (!singleHeaders["Content-Type"]) singleHeaders["Content-Type"] = "application/json";
|
|
728
|
+
const response = await fetch(this.runtimeUrl, {
|
|
729
|
+
method: "POST",
|
|
730
|
+
headers: singleHeaders,
|
|
731
|
+
body: JSON.stringify({ method: "info" }),
|
|
732
|
+
...this.credentials ? { credentials: this.credentials } : {}
|
|
733
|
+
});
|
|
734
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
735
|
+
this.transport = "single";
|
|
736
|
+
this.singleEndpointUrl = this.runtimeUrl;
|
|
737
|
+
return await response.json();
|
|
738
|
+
}
|
|
714
739
|
createSingleRouteRequestInit(input, method, params) {
|
|
715
740
|
if (!this.agentId) throw new Error("ProxiedCopilotRuntimeAgent requires agentId to make runtime requests");
|
|
716
741
|
const baseInit = super.requestInit(input);
|
|
@@ -767,11 +792,12 @@ var AgentRegistry = class {
|
|
|
767
792
|
_runtimeUrl;
|
|
768
793
|
_runtimeVersion;
|
|
769
794
|
_runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Disconnected;
|
|
770
|
-
_runtimeTransport = "
|
|
795
|
+
_runtimeTransport = "auto";
|
|
771
796
|
_audioFileTranscriptionEnabled = false;
|
|
772
797
|
_runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
773
798
|
_intelligence;
|
|
774
799
|
_a2uiEnabled = false;
|
|
800
|
+
_openGenerativeUIEnabled = false;
|
|
775
801
|
_licenseStatus;
|
|
776
802
|
constructor(core) {
|
|
777
803
|
this.core = core;
|
|
@@ -806,6 +832,9 @@ var AgentRegistry = class {
|
|
|
806
832
|
get a2uiEnabled() {
|
|
807
833
|
return this._a2uiEnabled;
|
|
808
834
|
}
|
|
835
|
+
get openGenerativeUIEnabled() {
|
|
836
|
+
return this._openGenerativeUIEnabled;
|
|
837
|
+
}
|
|
809
838
|
get licenseStatus() {
|
|
810
839
|
return this._licenseStatus;
|
|
811
840
|
}
|
|
@@ -918,6 +947,7 @@ var AgentRegistry = class {
|
|
|
918
947
|
this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
919
948
|
this._intelligence = void 0;
|
|
920
949
|
this._a2uiEnabled = false;
|
|
950
|
+
this._openGenerativeUIEnabled = false;
|
|
921
951
|
this.remoteAgents = {};
|
|
922
952
|
this._agents = this.localAgents;
|
|
923
953
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Disconnected);
|
|
@@ -953,6 +983,7 @@ var AgentRegistry = class {
|
|
|
953
983
|
this._runtimeMode = runtimeInfoResponse.mode ?? _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
954
984
|
this._intelligence = runtimeInfoResponse.intelligence;
|
|
955
985
|
this._a2uiEnabled = runtimeInfoResponse.a2uiEnabled ?? false;
|
|
986
|
+
this._openGenerativeUIEnabled = runtimeInfoResponse.openGenerativeUIEnabled ?? false;
|
|
956
987
|
this._licenseStatus = runtimeInfoResponse.licenseStatus;
|
|
957
988
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Connected);
|
|
958
989
|
await this.notifyAgentsChanged();
|
|
@@ -963,6 +994,7 @@ var AgentRegistry = class {
|
|
|
963
994
|
this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
964
995
|
this._intelligence = void 0;
|
|
965
996
|
this._a2uiEnabled = false;
|
|
997
|
+
this._openGenerativeUIEnabled = false;
|
|
966
998
|
this.remoteAgents = {};
|
|
967
999
|
this._agents = this.localAgents;
|
|
968
1000
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Error);
|
|
@@ -982,24 +1014,45 @@ var AgentRegistry = class {
|
|
|
982
1014
|
const baseHeaders = this.core.headers;
|
|
983
1015
|
const credentials = this.core.credentials;
|
|
984
1016
|
const headers = { ...baseHeaders };
|
|
985
|
-
if (this._runtimeTransport === "single")
|
|
986
|
-
|
|
987
|
-
const response = await fetch(this.runtimeUrl, {
|
|
988
|
-
method: "POST",
|
|
989
|
-
headers,
|
|
990
|
-
body: JSON.stringify({ method: "info" }),
|
|
991
|
-
...credentials ? { credentials } : {}
|
|
992
|
-
});
|
|
993
|
-
if ("ok" in response && !response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
994
|
-
return await response.json();
|
|
995
|
-
}
|
|
1017
|
+
if (this._runtimeTransport === "single") return this.fetchRuntimeInfoSingle(headers, credentials);
|
|
1018
|
+
if (this._runtimeTransport === "auto") return this.fetchRuntimeInfoAutoDetect(headers, credentials);
|
|
996
1019
|
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
997
1020
|
headers,
|
|
998
1021
|
...credentials ? { credentials } : {}
|
|
999
1022
|
});
|
|
1000
|
-
if (
|
|
1023
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
1001
1024
|
return await response.json();
|
|
1002
1025
|
}
|
|
1026
|
+
async fetchRuntimeInfoSingle(headers, credentials) {
|
|
1027
|
+
if (!headers["Content-Type"]) headers["Content-Type"] = "application/json";
|
|
1028
|
+
const response = await fetch(this.runtimeUrl, {
|
|
1029
|
+
method: "POST",
|
|
1030
|
+
headers,
|
|
1031
|
+
body: JSON.stringify({ method: "info" }),
|
|
1032
|
+
...credentials ? { credentials } : {}
|
|
1033
|
+
});
|
|
1034
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
1035
|
+
return await response.json();
|
|
1036
|
+
}
|
|
1037
|
+
/**
|
|
1038
|
+
* Auto-detect transport by trying REST first, then falling back to single-endpoint.
|
|
1039
|
+
* Updates `_runtimeTransport` to the detected value so subsequent requests use it directly.
|
|
1040
|
+
*/
|
|
1041
|
+
async fetchRuntimeInfoAutoDetect(headers, credentials) {
|
|
1042
|
+
try {
|
|
1043
|
+
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
1044
|
+
headers: { ...headers },
|
|
1045
|
+
...credentials ? { credentials } : {}
|
|
1046
|
+
});
|
|
1047
|
+
if (response.status >= 200 && response.status < 300) {
|
|
1048
|
+
this._runtimeTransport = "rest";
|
|
1049
|
+
return await response.json();
|
|
1050
|
+
}
|
|
1051
|
+
} catch {}
|
|
1052
|
+
const result = await this.fetchRuntimeInfoSingle({ ...headers }, credentials);
|
|
1053
|
+
this._runtimeTransport = "single";
|
|
1054
|
+
return result;
|
|
1055
|
+
}
|
|
1003
1056
|
/**
|
|
1004
1057
|
* Assign agent IDs to a record of agents
|
|
1005
1058
|
*/
|
|
@@ -1494,13 +1547,15 @@ var RunHandler = class {
|
|
|
1494
1547
|
});
|
|
1495
1548
|
} catch (error) {
|
|
1496
1549
|
const connectError = error instanceof Error ? error : new Error(String(error));
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1550
|
+
if (!(connectError.name === "AbortError" || connectError.message === "Fetch is aborted" || connectError.message === "signal is aborted without reason" || connectError.message === "component unmounted")) {
|
|
1551
|
+
const context = {};
|
|
1552
|
+
if (agent.agentId) context.agentId = agent.agentId;
|
|
1553
|
+
await this._internal.emitError({
|
|
1554
|
+
error: connectError,
|
|
1555
|
+
code: CopilotKitCoreErrorCode.AGENT_CONNECT_FAILED,
|
|
1556
|
+
context
|
|
1557
|
+
});
|
|
1558
|
+
}
|
|
1504
1559
|
return { newMessages: [] };
|
|
1505
1560
|
}
|
|
1506
1561
|
}
|
|
@@ -2234,13 +2289,14 @@ var CopilotKitCore = class {
|
|
|
2234
2289
|
_headers;
|
|
2235
2290
|
_credentials;
|
|
2236
2291
|
_properties;
|
|
2292
|
+
_defaultThrottleMs;
|
|
2237
2293
|
subscribers = /* @__PURE__ */ new Set();
|
|
2238
2294
|
agentRegistry;
|
|
2239
2295
|
contextStore;
|
|
2240
2296
|
suggestionEngine;
|
|
2241
2297
|
runHandler;
|
|
2242
2298
|
stateManager;
|
|
2243
|
-
constructor({ runtimeUrl, runtimeTransport = "
|
|
2299
|
+
constructor({ runtimeUrl, runtimeTransport = "auto", headers = {}, credentials, properties = {}, agents__unsafe_dev_only = {}, tools = [], suggestionsConfig = [] }) {
|
|
2244
2300
|
this._headers = headers;
|
|
2245
2301
|
this._credentials = credentials;
|
|
2246
2302
|
this._properties = properties;
|
|
@@ -2320,6 +2376,22 @@ var CopilotKitCore = class {
|
|
|
2320
2376
|
get properties() {
|
|
2321
2377
|
return this._properties;
|
|
2322
2378
|
}
|
|
2379
|
+
/**
|
|
2380
|
+
* Default throttle interval (ms) applied by framework hooks (e.g.
|
|
2381
|
+
* `useAgent()`) when the hook/component does not specify an explicit
|
|
2382
|
+
* `throttleMs`. An explicit `0` passed as `throttleMs` to `useAgent()`
|
|
2383
|
+
* or `<CopilotChat>` overrides this default and disables throttling.
|
|
2384
|
+
*/
|
|
2385
|
+
get defaultThrottleMs() {
|
|
2386
|
+
return this._defaultThrottleMs;
|
|
2387
|
+
}
|
|
2388
|
+
setDefaultThrottleMs(value) {
|
|
2389
|
+
if (value !== void 0 && (!Number.isFinite(value) || value < 0)) {
|
|
2390
|
+
this._defaultThrottleMs = void 0;
|
|
2391
|
+
return;
|
|
2392
|
+
}
|
|
2393
|
+
this._defaultThrottleMs = value;
|
|
2394
|
+
}
|
|
2323
2395
|
get runtimeConnectionStatus() {
|
|
2324
2396
|
return this.agentRegistry.runtimeConnectionStatus;
|
|
2325
2397
|
}
|
|
@@ -2335,6 +2407,9 @@ var CopilotKitCore = class {
|
|
|
2335
2407
|
get a2uiEnabled() {
|
|
2336
2408
|
return this.agentRegistry.a2uiEnabled;
|
|
2337
2409
|
}
|
|
2410
|
+
get openGenerativeUIEnabled() {
|
|
2411
|
+
return this.agentRegistry.openGenerativeUIEnabled;
|
|
2412
|
+
}
|
|
2338
2413
|
get licenseStatus() {
|
|
2339
2414
|
return this.agentRegistry.licenseStatus;
|
|
2340
2415
|
}
|