@copilotkit/core 1.55.0-next.9 → 1.55.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 +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.umd.js
CHANGED
|
@@ -615,7 +615,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
615
615
|
constructor(config) {
|
|
616
616
|
var _config$transport, _ref, _config$agentId, _config$runtimeMode;
|
|
617
617
|
const normalizedRuntimeUrl = config.runtimeUrl ? config.runtimeUrl.replace(/\/$/, "") : void 0;
|
|
618
|
-
const transport = (_config$transport = config.transport) !== null && _config$transport !== void 0 ? _config$transport : "
|
|
618
|
+
const transport = (_config$transport = config.transport) !== null && _config$transport !== void 0 ? _config$transport : "auto";
|
|
619
619
|
const runUrl = transport === "single" ? (_ref = normalizedRuntimeUrl !== null && normalizedRuntimeUrl !== void 0 ? normalizedRuntimeUrl : config.runtimeUrl) !== null && _ref !== void 0 ? _ref : "" : `${normalizedRuntimeUrl !== null && normalizedRuntimeUrl !== void 0 ? normalizedRuntimeUrl : config.runtimeUrl}/agent/${encodeURIComponent((_config$agentId = config.agentId) !== null && _config$agentId !== void 0 ? _config$agentId : "")}/run`;
|
|
620
620
|
if (!runUrl) throw new Error("ProxiedCopilotRuntimeAgent requires a runtimeUrl when transport is set to 'single'.");
|
|
621
621
|
super({
|
|
@@ -773,6 +773,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
773
773
|
}
|
|
774
774
|
async fetchRuntimeInfo() {
|
|
775
775
|
const headers = { ...this.headers };
|
|
776
|
+
if (this.transport === "auto") return this.fetchRuntimeInfoAutoDetect(headers);
|
|
776
777
|
let init;
|
|
777
778
|
let url;
|
|
778
779
|
if (this.transport === "single") {
|
|
@@ -795,6 +796,30 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
795
796
|
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
796
797
|
return await response.json();
|
|
797
798
|
}
|
|
799
|
+
async fetchRuntimeInfoAutoDetect(headers) {
|
|
800
|
+
try {
|
|
801
|
+
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
802
|
+
headers: { ...headers },
|
|
803
|
+
...this.credentials ? { credentials: this.credentials } : {}
|
|
804
|
+
});
|
|
805
|
+
if (response.status >= 200 && response.status < 300) {
|
|
806
|
+
this.transport = "rest";
|
|
807
|
+
return await response.json();
|
|
808
|
+
}
|
|
809
|
+
} catch (_unused) {}
|
|
810
|
+
const singleHeaders = { ...headers };
|
|
811
|
+
if (!singleHeaders["Content-Type"]) singleHeaders["Content-Type"] = "application/json";
|
|
812
|
+
const response = await fetch(this.runtimeUrl, {
|
|
813
|
+
method: "POST",
|
|
814
|
+
headers: singleHeaders,
|
|
815
|
+
body: JSON.stringify({ method: "info" }),
|
|
816
|
+
...this.credentials ? { credentials: this.credentials } : {}
|
|
817
|
+
});
|
|
818
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
819
|
+
this.transport = "single";
|
|
820
|
+
this.singleEndpointUrl = this.runtimeUrl;
|
|
821
|
+
return await response.json();
|
|
822
|
+
}
|
|
798
823
|
createSingleRouteRequestInit(input, method, params) {
|
|
799
824
|
var _baseInit$headers, _headers$get;
|
|
800
825
|
if (!this.agentId) throw new Error("ProxiedCopilotRuntimeAgent requires agentId to make runtime requests");
|
|
@@ -878,11 +903,12 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
878
903
|
_defineProperty(this, "_runtimeUrl", void 0);
|
|
879
904
|
_defineProperty(this, "_runtimeVersion", void 0);
|
|
880
905
|
_defineProperty(this, "_runtimeConnectionStatus", CopilotKitCoreRuntimeConnectionStatus.Disconnected);
|
|
881
|
-
_defineProperty(this, "_runtimeTransport", "
|
|
906
|
+
_defineProperty(this, "_runtimeTransport", "auto");
|
|
882
907
|
_defineProperty(this, "_audioFileTranscriptionEnabled", false);
|
|
883
908
|
_defineProperty(this, "_runtimeMode", _copilotkit_shared.RUNTIME_MODE_SSE);
|
|
884
909
|
_defineProperty(this, "_intelligence", void 0);
|
|
885
910
|
_defineProperty(this, "_a2uiEnabled", false);
|
|
911
|
+
_defineProperty(this, "_openGenerativeUIEnabled", false);
|
|
886
912
|
_defineProperty(this, "_licenseStatus", void 0);
|
|
887
913
|
}
|
|
888
914
|
/**
|
|
@@ -915,6 +941,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
915
941
|
get a2uiEnabled() {
|
|
916
942
|
return this._a2uiEnabled;
|
|
917
943
|
}
|
|
944
|
+
get openGenerativeUIEnabled() {
|
|
945
|
+
return this._openGenerativeUIEnabled;
|
|
946
|
+
}
|
|
918
947
|
get licenseStatus() {
|
|
919
948
|
return this._licenseStatus;
|
|
920
949
|
}
|
|
@@ -1027,6 +1056,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1027
1056
|
this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
1028
1057
|
this._intelligence = void 0;
|
|
1029
1058
|
this._a2uiEnabled = false;
|
|
1059
|
+
this._openGenerativeUIEnabled = false;
|
|
1030
1060
|
this.remoteAgents = {};
|
|
1031
1061
|
this._agents = this.localAgents;
|
|
1032
1062
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Disconnected);
|
|
@@ -1036,7 +1066,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1036
1066
|
this._runtimeConnectionStatus = CopilotKitCoreRuntimeConnectionStatus.Connecting;
|
|
1037
1067
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Connecting);
|
|
1038
1068
|
try {
|
|
1039
|
-
var _runtimeInfoResponse$2, _runtimeInfoResponse$3, _runtimeInfoResponse$4;
|
|
1069
|
+
var _runtimeInfoResponse$2, _runtimeInfoResponse$3, _runtimeInfoResponse$4, _runtimeInfoResponse$5;
|
|
1040
1070
|
const runtimeInfoResponse = await this.fetchRuntimeInfo();
|
|
1041
1071
|
const { version, ...runtimeInfo } = runtimeInfoResponse;
|
|
1042
1072
|
const credentials = this.core.credentials;
|
|
@@ -1064,6 +1094,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1064
1094
|
this._runtimeMode = (_runtimeInfoResponse$3 = runtimeInfoResponse.mode) !== null && _runtimeInfoResponse$3 !== void 0 ? _runtimeInfoResponse$3 : _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
1065
1095
|
this._intelligence = runtimeInfoResponse.intelligence;
|
|
1066
1096
|
this._a2uiEnabled = (_runtimeInfoResponse$4 = runtimeInfoResponse.a2uiEnabled) !== null && _runtimeInfoResponse$4 !== void 0 ? _runtimeInfoResponse$4 : false;
|
|
1097
|
+
this._openGenerativeUIEnabled = (_runtimeInfoResponse$5 = runtimeInfoResponse.openGenerativeUIEnabled) !== null && _runtimeInfoResponse$5 !== void 0 ? _runtimeInfoResponse$5 : false;
|
|
1067
1098
|
this._licenseStatus = runtimeInfoResponse.licenseStatus;
|
|
1068
1099
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Connected);
|
|
1069
1100
|
await this.notifyAgentsChanged();
|
|
@@ -1074,6 +1105,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1074
1105
|
this._runtimeMode = _copilotkit_shared.RUNTIME_MODE_SSE;
|
|
1075
1106
|
this._intelligence = void 0;
|
|
1076
1107
|
this._a2uiEnabled = false;
|
|
1108
|
+
this._openGenerativeUIEnabled = false;
|
|
1077
1109
|
this.remoteAgents = {};
|
|
1078
1110
|
this._agents = this.localAgents;
|
|
1079
1111
|
await this.notifyRuntimeStatusChanged(CopilotKitCoreRuntimeConnectionStatus.Error);
|
|
@@ -1093,24 +1125,45 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1093
1125
|
const baseHeaders = this.core.headers;
|
|
1094
1126
|
const credentials = this.core.credentials;
|
|
1095
1127
|
const headers = { ...baseHeaders };
|
|
1096
|
-
if (this._runtimeTransport === "single")
|
|
1097
|
-
|
|
1098
|
-
const response = await fetch(this.runtimeUrl, {
|
|
1099
|
-
method: "POST",
|
|
1100
|
-
headers,
|
|
1101
|
-
body: JSON.stringify({ method: "info" }),
|
|
1102
|
-
...credentials ? { credentials } : {}
|
|
1103
|
-
});
|
|
1104
|
-
if ("ok" in response && !response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
1105
|
-
return await response.json();
|
|
1106
|
-
}
|
|
1128
|
+
if (this._runtimeTransport === "single") return this.fetchRuntimeInfoSingle(headers, credentials);
|
|
1129
|
+
if (this._runtimeTransport === "auto") return this.fetchRuntimeInfoAutoDetect(headers, credentials);
|
|
1107
1130
|
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
1108
1131
|
headers,
|
|
1109
1132
|
...credentials ? { credentials } : {}
|
|
1110
1133
|
});
|
|
1111
|
-
if (
|
|
1134
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
1112
1135
|
return await response.json();
|
|
1113
1136
|
}
|
|
1137
|
+
async fetchRuntimeInfoSingle(headers, credentials) {
|
|
1138
|
+
if (!headers["Content-Type"]) headers["Content-Type"] = "application/json";
|
|
1139
|
+
const response = await fetch(this.runtimeUrl, {
|
|
1140
|
+
method: "POST",
|
|
1141
|
+
headers,
|
|
1142
|
+
body: JSON.stringify({ method: "info" }),
|
|
1143
|
+
...credentials ? { credentials } : {}
|
|
1144
|
+
});
|
|
1145
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
1146
|
+
return await response.json();
|
|
1147
|
+
}
|
|
1148
|
+
/**
|
|
1149
|
+
* Auto-detect transport by trying REST first, then falling back to single-endpoint.
|
|
1150
|
+
* Updates `_runtimeTransport` to the detected value so subsequent requests use it directly.
|
|
1151
|
+
*/
|
|
1152
|
+
async fetchRuntimeInfoAutoDetect(headers, credentials) {
|
|
1153
|
+
try {
|
|
1154
|
+
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
1155
|
+
headers: { ...headers },
|
|
1156
|
+
...credentials ? { credentials } : {}
|
|
1157
|
+
});
|
|
1158
|
+
if (response.status >= 200 && response.status < 300) {
|
|
1159
|
+
this._runtimeTransport = "rest";
|
|
1160
|
+
return await response.json();
|
|
1161
|
+
}
|
|
1162
|
+
} catch (_unused) {}
|
|
1163
|
+
const result = await this.fetchRuntimeInfoSingle({ ...headers }, credentials);
|
|
1164
|
+
this._runtimeTransport = "single";
|
|
1165
|
+
return result;
|
|
1166
|
+
}
|
|
1114
1167
|
/**
|
|
1115
1168
|
* Assign agent IDs to a record of agents
|
|
1116
1169
|
*/
|
|
@@ -1625,13 +1678,15 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
1625
1678
|
});
|
|
1626
1679
|
} catch (error) {
|
|
1627
1680
|
const connectError = error instanceof Error ? error : new Error(String(error));
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1681
|
+
if (!(connectError.name === "AbortError" || connectError.message === "Fetch is aborted" || connectError.message === "signal is aborted without reason" || connectError.message === "component unmounted")) {
|
|
1682
|
+
const context = {};
|
|
1683
|
+
if (agent.agentId) context.agentId = agent.agentId;
|
|
1684
|
+
await this._internal.emitError({
|
|
1685
|
+
error: connectError,
|
|
1686
|
+
code: CopilotKitCoreErrorCode.AGENT_CONNECT_FAILED,
|
|
1687
|
+
context
|
|
1688
|
+
});
|
|
1689
|
+
}
|
|
1635
1690
|
return { newMessages: [] };
|
|
1636
1691
|
}
|
|
1637
1692
|
}
|
|
@@ -2389,10 +2444,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2389
2444
|
return CopilotKitCoreRuntimeConnectionStatus;
|
|
2390
2445
|
}({});
|
|
2391
2446
|
var CopilotKitCore = class {
|
|
2392
|
-
constructor({ runtimeUrl, runtimeTransport = "
|
|
2447
|
+
constructor({ runtimeUrl, runtimeTransport = "auto", headers = {}, credentials, properties = {}, agents__unsafe_dev_only = {}, tools = [], suggestionsConfig = [] }) {
|
|
2393
2448
|
_defineProperty(this, "_headers", void 0);
|
|
2394
2449
|
_defineProperty(this, "_credentials", void 0);
|
|
2395
2450
|
_defineProperty(this, "_properties", void 0);
|
|
2451
|
+
_defineProperty(this, "_defaultThrottleMs", void 0);
|
|
2396
2452
|
_defineProperty(this, "subscribers", /* @__PURE__ */ new Set());
|
|
2397
2453
|
_defineProperty(this, "agentRegistry", void 0);
|
|
2398
2454
|
_defineProperty(this, "contextStore", void 0);
|
|
@@ -2481,6 +2537,22 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2481
2537
|
get properties() {
|
|
2482
2538
|
return this._properties;
|
|
2483
2539
|
}
|
|
2540
|
+
/**
|
|
2541
|
+
* Default throttle interval (ms) applied by framework hooks (e.g.
|
|
2542
|
+
* `useAgent()`) when the hook/component does not specify an explicit
|
|
2543
|
+
* `throttleMs`. An explicit `0` passed as `throttleMs` to `useAgent()`
|
|
2544
|
+
* or `<CopilotChat>` overrides this default and disables throttling.
|
|
2545
|
+
*/
|
|
2546
|
+
get defaultThrottleMs() {
|
|
2547
|
+
return this._defaultThrottleMs;
|
|
2548
|
+
}
|
|
2549
|
+
setDefaultThrottleMs(value) {
|
|
2550
|
+
if (value !== void 0 && (!Number.isFinite(value) || value < 0)) {
|
|
2551
|
+
this._defaultThrottleMs = void 0;
|
|
2552
|
+
return;
|
|
2553
|
+
}
|
|
2554
|
+
this._defaultThrottleMs = value;
|
|
2555
|
+
}
|
|
2484
2556
|
get runtimeConnectionStatus() {
|
|
2485
2557
|
return this.agentRegistry.runtimeConnectionStatus;
|
|
2486
2558
|
}
|
|
@@ -2496,6 +2568,9 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
|
2496
2568
|
get a2uiEnabled() {
|
|
2497
2569
|
return this.agentRegistry.a2uiEnabled;
|
|
2498
2570
|
}
|
|
2571
|
+
get openGenerativeUIEnabled() {
|
|
2572
|
+
return this.agentRegistry.openGenerativeUIEnabled;
|
|
2573
|
+
}
|
|
2499
2574
|
get licenseStatus() {
|
|
2500
2575
|
return this.agentRegistry.licenseStatus;
|
|
2501
2576
|
}
|