@copilotkit/core 0.0.0-main-20260403195251 → 0.0.0-main-20260407163127
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 +61 -15
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +8 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +61 -15
- package/dist/index.mjs.map +1 -1
- package/dist/index.umd.js +61 -15
- package/dist/index.umd.js.map +1 -1
- package/package.json +5 -5
- package/dist/index.d.ts +0 -1401
- package/dist/index.d.ts.map +0 -1
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,7 +792,7 @@ 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;
|
|
@@ -982,25 +1007,46 @@ var AgentRegistry = class {
|
|
|
982
1007
|
const baseHeaders = this.core.headers;
|
|
983
1008
|
const credentials = this.core.credentials;
|
|
984
1009
|
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
|
-
}
|
|
1010
|
+
if (this._runtimeTransport === "single") return this.fetchRuntimeInfoSingle(headers, credentials);
|
|
1011
|
+
if (this._runtimeTransport === "auto") return this.fetchRuntimeInfoAutoDetect(headers, credentials);
|
|
996
1012
|
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
997
1013
|
headers,
|
|
998
1014
|
...credentials ? { credentials } : {}
|
|
999
1015
|
});
|
|
1000
|
-
if (
|
|
1016
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
1017
|
+
return await response.json();
|
|
1018
|
+
}
|
|
1019
|
+
async fetchRuntimeInfoSingle(headers, credentials) {
|
|
1020
|
+
if (!headers["Content-Type"]) headers["Content-Type"] = "application/json";
|
|
1021
|
+
const response = await fetch(this.runtimeUrl, {
|
|
1022
|
+
method: "POST",
|
|
1023
|
+
headers,
|
|
1024
|
+
body: JSON.stringify({ method: "info" }),
|
|
1025
|
+
...credentials ? { credentials } : {}
|
|
1026
|
+
});
|
|
1027
|
+
if (!response.ok) throw new Error(`Runtime info request failed with status ${response.status}`);
|
|
1001
1028
|
return await response.json();
|
|
1002
1029
|
}
|
|
1003
1030
|
/**
|
|
1031
|
+
* Auto-detect transport by trying REST first, then falling back to single-endpoint.
|
|
1032
|
+
* Updates `_runtimeTransport` to the detected value so subsequent requests use it directly.
|
|
1033
|
+
*/
|
|
1034
|
+
async fetchRuntimeInfoAutoDetect(headers, credentials) {
|
|
1035
|
+
try {
|
|
1036
|
+
const response = await fetch(`${this.runtimeUrl}/info`, {
|
|
1037
|
+
headers: { ...headers },
|
|
1038
|
+
...credentials ? { credentials } : {}
|
|
1039
|
+
});
|
|
1040
|
+
if (response.status >= 200 && response.status < 300) {
|
|
1041
|
+
this._runtimeTransport = "rest";
|
|
1042
|
+
return await response.json();
|
|
1043
|
+
}
|
|
1044
|
+
} catch {}
|
|
1045
|
+
const result = await this.fetchRuntimeInfoSingle({ ...headers }, credentials);
|
|
1046
|
+
this._runtimeTransport = "single";
|
|
1047
|
+
return result;
|
|
1048
|
+
}
|
|
1049
|
+
/**
|
|
1004
1050
|
* Assign agent IDs to a record of agents
|
|
1005
1051
|
*/
|
|
1006
1052
|
assignAgentIds(agents) {
|
|
@@ -2240,7 +2286,7 @@ var CopilotKitCore = class {
|
|
|
2240
2286
|
suggestionEngine;
|
|
2241
2287
|
runHandler;
|
|
2242
2288
|
stateManager;
|
|
2243
|
-
constructor({ runtimeUrl, runtimeTransport = "
|
|
2289
|
+
constructor({ runtimeUrl, runtimeTransport = "auto", headers = {}, credentials, properties = {}, agents__unsafe_dev_only = {}, tools = [], suggestionsConfig = [] }) {
|
|
2244
2290
|
this._headers = headers;
|
|
2245
2291
|
this._credentials = credentials;
|
|
2246
2292
|
this._properties = properties;
|