@copilotkit/runtime 1.77.1 → 1.77.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/package.cjs +1 -1
- package/dist/package.mjs +1 -1
- package/dist/v2/runtime/core/package-info.cjs +1 -1
- package/dist/v2/runtime/core/package-info.mjs +1 -1
- package/dist/v2/runtime/handlers/handle-trajectory-connect.cjs +1 -1
- package/dist/v2/runtime/handlers/handle-trajectory-connect.cjs.map +1 -1
- package/dist/v2/runtime/handlers/handle-trajectory-connect.mjs +1 -1
- package/dist/v2/runtime/handlers/handle-trajectory-connect.mjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.cjs +36 -13
- package/dist/v2/runtime/intelligence-platform/client.cjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.cts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/client.mjs +36 -13
- package/dist/v2/runtime/intelligence-platform/client.mjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/trajectories.cjs +19 -3
- package/dist/v2/runtime/intelligence-platform/trajectories.cjs.map +1 -1
- package/dist/v2/runtime/intelligence-platform/trajectories.d.cts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/trajectories.d.mts.map +1 -1
- package/dist/v2/runtime/intelligence-platform/trajectories.mjs +19 -3
- package/dist/v2/runtime/intelligence-platform/trajectories.mjs.map +1 -1
- package/package.json +5 -5
package/dist/package.cjs
CHANGED
|
@@ -5,7 +5,7 @@ const require_runtime = require('./_virtual/_rolldown/runtime.cjs');
|
|
|
5
5
|
var require_package = /* @__PURE__ */ require_runtime.__commonJSMin(((exports, module) => {
|
|
6
6
|
module.exports = {
|
|
7
7
|
"name": "@copilotkit/runtime",
|
|
8
|
-
"version": "1.77.
|
|
8
|
+
"version": "1.77.2",
|
|
9
9
|
"private": false,
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ai",
|
package/dist/package.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { __commonJSMin } from "./_virtual/_rolldown/runtime.mjs";
|
|
|
5
5
|
var require_package = /* @__PURE__ */ __commonJSMin(((exports, module) => {
|
|
6
6
|
module.exports = {
|
|
7
7
|
"name": "@copilotkit/runtime",
|
|
8
|
-
"version": "1.77.
|
|
8
|
+
"version": "1.77.2",
|
|
9
9
|
"private": false,
|
|
10
10
|
"keywords": [
|
|
11
11
|
"ai",
|
|
@@ -2,7 +2,7 @@ require("reflect-metadata");
|
|
|
2
2
|
|
|
3
3
|
//#region src/v2/runtime/core/package-info.ts
|
|
4
4
|
const RUNTIME_PACKAGE_NAME = "@copilotkit/runtime";
|
|
5
|
-
const RUNTIME_PACKAGE_VERSION = "1.77.
|
|
5
|
+
const RUNTIME_PACKAGE_VERSION = "1.77.2";
|
|
6
6
|
|
|
7
7
|
//#endregion
|
|
8
8
|
exports.RUNTIME_PACKAGE_NAME = RUNTIME_PACKAGE_NAME;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
2
|
//#region src/v2/runtime/core/package-info.ts
|
|
3
3
|
const RUNTIME_PACKAGE_NAME = "@copilotkit/runtime";
|
|
4
|
-
const RUNTIME_PACKAGE_VERSION = "1.77.
|
|
4
|
+
const RUNTIME_PACKAGE_VERSION = "1.77.2";
|
|
5
5
|
|
|
6
6
|
//#endregion
|
|
7
7
|
export { RUNTIME_PACKAGE_NAME, RUNTIME_PACKAGE_VERSION };
|
|
@@ -15,7 +15,7 @@ function trajectoryErrorResponse(code, message, status) {
|
|
|
15
15
|
}
|
|
16
16
|
async function handleTrajectoryConnect({ runtime, request, trajectoryId }) {
|
|
17
17
|
if (!require_trajectories.isValidTrajectoryId(trajectoryId)) return trajectoryErrorResponse("INVALID_REQUEST", "A valid trajectoryId is required", 400);
|
|
18
|
-
if (!require_runtime.isIntelligenceRuntime(runtime)) return trajectoryErrorResponse("
|
|
18
|
+
if (!require_runtime.isIntelligenceRuntime(runtime)) return trajectoryErrorResponse("INTELLIGENCE_RUNTIME_REQUIRED", "Trajectory capture requires an Intelligence runtime", 503);
|
|
19
19
|
if (!runtime.identifyUser) return trajectoryErrorResponse("IDENTITY_REQUIRED", "Trajectory capture requires an identified user", 401);
|
|
20
20
|
const user = await require_resolve_intelligence_user.resolveIntelligenceUser({
|
|
21
21
|
runtime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-trajectory-connect.cjs","names":["isValidTrajectoryId","isIntelligenceRuntime","resolveIntelligenceUser","TrajectoryConnectionError"],"sources":["../../../../src/v2/runtime/handlers/handle-trajectory-connect.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport {\n isValidTrajectoryId,\n TrajectoryConnectionError,\n} from \"../intelligence-platform/trajectories\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\n\nexport function trajectoryErrorResponse(\n code: string,\n message: string,\n status: number,\n): Response {\n return Response.json(\n { code, message },\n { status, headers: { \"Cache-Control\": \"no-store\" } },\n );\n}\n\nexport async function handleTrajectoryConnect({\n runtime,\n request,\n trajectoryId,\n}: {\n runtime: CopilotRuntimeLike;\n request: Request;\n trajectoryId: string;\n}): Promise<Response> {\n if (!isValidTrajectoryId(trajectoryId)) {\n return trajectoryErrorResponse(\n \"INVALID_REQUEST\",\n \"A valid trajectoryId is required\",\n 400,\n );\n }\n if (!isIntelligenceRuntime(runtime)) {\n return trajectoryErrorResponse(\n \"
|
|
1
|
+
{"version":3,"file":"handle-trajectory-connect.cjs","names":["isValidTrajectoryId","isIntelligenceRuntime","resolveIntelligenceUser","TrajectoryConnectionError"],"sources":["../../../../src/v2/runtime/handlers/handle-trajectory-connect.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport {\n isValidTrajectoryId,\n TrajectoryConnectionError,\n} from \"../intelligence-platform/trajectories\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\n\nexport function trajectoryErrorResponse(\n code: string,\n message: string,\n status: number,\n): Response {\n return Response.json(\n { code, message },\n { status, headers: { \"Cache-Control\": \"no-store\" } },\n );\n}\n\nexport async function handleTrajectoryConnect({\n runtime,\n request,\n trajectoryId,\n}: {\n runtime: CopilotRuntimeLike;\n request: Request;\n trajectoryId: string;\n}): Promise<Response> {\n if (!isValidTrajectoryId(trajectoryId)) {\n return trajectoryErrorResponse(\n \"INVALID_REQUEST\",\n \"A valid trajectoryId is required\",\n 400,\n );\n }\n if (!isIntelligenceRuntime(runtime)) {\n return trajectoryErrorResponse(\n \"INTELLIGENCE_RUNTIME_REQUIRED\",\n \"Trajectory capture requires an Intelligence runtime\",\n 503,\n );\n }\n if (!runtime.identifyUser) {\n return trajectoryErrorResponse(\n \"IDENTITY_REQUIRED\",\n \"Trajectory capture requires an identified user\",\n 401,\n );\n }\n const user = await resolveIntelligenceUser({ runtime, request });\n if (user instanceof Response) {\n return trajectoryErrorResponse(\n \"IDENTITY_REQUIRED\",\n \"Trajectory capture requires an identified user\",\n 401,\n );\n }\n\n try {\n const grant = await runtime.intelligence.ɵconnectTrajectory({\n trajectoryId,\n user,\n signal: request.signal,\n });\n return Response.json(grant, {\n headers: { \"Cache-Control\": \"no-store\" },\n });\n } catch (error) {\n if (error instanceof TrajectoryConnectionError) {\n return trajectoryErrorResponse(error.code, error.message, error.status);\n }\n return trajectoryErrorResponse(\n \"CONNECTION_FAILED\",\n \"Could not connect to Intelligence\",\n 502,\n );\n }\n}\n"],"mappings":";;;;;;AAQA,SAAgB,wBACd,MACA,SACA,QACU;AACV,QAAO,SAAS,KACd;EAAE;EAAM;EAAS,EACjB;EAAE;EAAQ,SAAS,EAAE,iBAAiB,YAAY;EAAE,CACrD;;AAGH,eAAsB,wBAAwB,EAC5C,SACA,SACA,gBAKoB;AACpB,KAAI,CAACA,yCAAoB,aAAa,CACpC,QAAO,wBACL,mBACA,oCACA,IACD;AAEH,KAAI,CAACC,sCAAsB,QAAQ,CACjC,QAAO,wBACL,iCACA,uDACA,IACD;AAEH,KAAI,CAAC,QAAQ,aACX,QAAO,wBACL,qBACA,kDACA,IACD;CAEH,MAAM,OAAO,MAAMC,0DAAwB;EAAE;EAAS;EAAS,CAAC;AAChE,KAAI,gBAAgB,SAClB,QAAO,wBACL,qBACA,kDACA,IACD;AAGH,KAAI;EACF,MAAM,QAAQ,MAAM,QAAQ,aAAa,mBAAmB;GAC1D;GACA;GACA,QAAQ,QAAQ;GACjB,CAAC;AACF,SAAO,SAAS,KAAK,OAAO,EAC1B,SAAS,EAAE,iBAAiB,YAAY,EACzC,CAAC;UACK,OAAO;AACd,MAAI,iBAAiBC,+CACnB,QAAO,wBAAwB,MAAM,MAAM,MAAM,SAAS,MAAM,OAAO;AAEzE,SAAO,wBACL,qBACA,qCACA,IACD"}
|
|
@@ -15,7 +15,7 @@ function trajectoryErrorResponse(code, message, status) {
|
|
|
15
15
|
}
|
|
16
16
|
async function handleTrajectoryConnect({ runtime, request, trajectoryId }) {
|
|
17
17
|
if (!isValidTrajectoryId(trajectoryId)) return trajectoryErrorResponse("INVALID_REQUEST", "A valid trajectoryId is required", 400);
|
|
18
|
-
if (!isIntelligenceRuntime(runtime)) return trajectoryErrorResponse("
|
|
18
|
+
if (!isIntelligenceRuntime(runtime)) return trajectoryErrorResponse("INTELLIGENCE_RUNTIME_REQUIRED", "Trajectory capture requires an Intelligence runtime", 503);
|
|
19
19
|
if (!runtime.identifyUser) return trajectoryErrorResponse("IDENTITY_REQUIRED", "Trajectory capture requires an identified user", 401);
|
|
20
20
|
const user = await resolveIntelligenceUser({
|
|
21
21
|
runtime,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"handle-trajectory-connect.mjs","names":[],"sources":["../../../../src/v2/runtime/handlers/handle-trajectory-connect.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport {\n isValidTrajectoryId,\n TrajectoryConnectionError,\n} from \"../intelligence-platform/trajectories\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\n\nexport function trajectoryErrorResponse(\n code: string,\n message: string,\n status: number,\n): Response {\n return Response.json(\n { code, message },\n { status, headers: { \"Cache-Control\": \"no-store\" } },\n );\n}\n\nexport async function handleTrajectoryConnect({\n runtime,\n request,\n trajectoryId,\n}: {\n runtime: CopilotRuntimeLike;\n request: Request;\n trajectoryId: string;\n}): Promise<Response> {\n if (!isValidTrajectoryId(trajectoryId)) {\n return trajectoryErrorResponse(\n \"INVALID_REQUEST\",\n \"A valid trajectoryId is required\",\n 400,\n );\n }\n if (!isIntelligenceRuntime(runtime)) {\n return trajectoryErrorResponse(\n \"
|
|
1
|
+
{"version":3,"file":"handle-trajectory-connect.mjs","names":[],"sources":["../../../../src/v2/runtime/handlers/handle-trajectory-connect.ts"],"sourcesContent":["import type { CopilotRuntimeLike } from \"../core/runtime\";\nimport { isIntelligenceRuntime } from \"../core/runtime\";\nimport {\n isValidTrajectoryId,\n TrajectoryConnectionError,\n} from \"../intelligence-platform/trajectories\";\nimport { resolveIntelligenceUser } from \"./shared/resolve-intelligence-user\";\n\nexport function trajectoryErrorResponse(\n code: string,\n message: string,\n status: number,\n): Response {\n return Response.json(\n { code, message },\n { status, headers: { \"Cache-Control\": \"no-store\" } },\n );\n}\n\nexport async function handleTrajectoryConnect({\n runtime,\n request,\n trajectoryId,\n}: {\n runtime: CopilotRuntimeLike;\n request: Request;\n trajectoryId: string;\n}): Promise<Response> {\n if (!isValidTrajectoryId(trajectoryId)) {\n return trajectoryErrorResponse(\n \"INVALID_REQUEST\",\n \"A valid trajectoryId is required\",\n 400,\n );\n }\n if (!isIntelligenceRuntime(runtime)) {\n return trajectoryErrorResponse(\n \"INTELLIGENCE_RUNTIME_REQUIRED\",\n \"Trajectory capture requires an Intelligence runtime\",\n 503,\n );\n }\n if (!runtime.identifyUser) {\n return trajectoryErrorResponse(\n \"IDENTITY_REQUIRED\",\n \"Trajectory capture requires an identified user\",\n 401,\n );\n }\n const user = await resolveIntelligenceUser({ runtime, request });\n if (user instanceof Response) {\n return trajectoryErrorResponse(\n \"IDENTITY_REQUIRED\",\n \"Trajectory capture requires an identified user\",\n 401,\n );\n }\n\n try {\n const grant = await runtime.intelligence.ɵconnectTrajectory({\n trajectoryId,\n user,\n signal: request.signal,\n });\n return Response.json(grant, {\n headers: { \"Cache-Control\": \"no-store\" },\n });\n } catch (error) {\n if (error instanceof TrajectoryConnectionError) {\n return trajectoryErrorResponse(error.code, error.message, error.status);\n }\n return trajectoryErrorResponse(\n \"CONNECTION_FAILED\",\n \"Could not connect to Intelligence\",\n 502,\n );\n }\n}\n"],"mappings":";;;;;;AAQA,SAAgB,wBACd,MACA,SACA,QACU;AACV,QAAO,SAAS,KACd;EAAE;EAAM;EAAS,EACjB;EAAE;EAAQ,SAAS,EAAE,iBAAiB,YAAY;EAAE,CACrD;;AAGH,eAAsB,wBAAwB,EAC5C,SACA,SACA,gBAKoB;AACpB,KAAI,CAAC,oBAAoB,aAAa,CACpC,QAAO,wBACL,mBACA,oCACA,IACD;AAEH,KAAI,CAAC,sBAAsB,QAAQ,CACjC,QAAO,wBACL,iCACA,uDACA,IACD;AAEH,KAAI,CAAC,QAAQ,aACX,QAAO,wBACL,qBACA,kDACA,IACD;CAEH,MAAM,OAAO,MAAM,wBAAwB;EAAE;EAAS;EAAS,CAAC;AAChE,KAAI,gBAAgB,SAClB,QAAO,wBACL,qBACA,kDACA,IACD;AAGH,KAAI;EACF,MAAM,QAAQ,MAAM,QAAQ,aAAa,mBAAmB;GAC1D;GACA;GACA,QAAQ,QAAQ;GACjB,CAAC;AACF,SAAO,SAAS,KAAK,OAAO,EAC1B,SAAS,EAAE,iBAAiB,YAAY,EACzC,CAAC;UACK,OAAO;AACd,MAAI,iBAAiB,0BACnB,QAAO,wBAAwB,MAAM,MAAM,MAAM,SAAS,MAAM,OAAO;AAEzE,SAAO,wBACL,qBACA,qCACA,IACD"}
|
|
@@ -646,19 +646,29 @@ var CopilotKitIntelligence = class {
|
|
|
646
646
|
}
|
|
647
647
|
/** Mint a browser capture grant using only the Runtime's project and user. */
|
|
648
648
|
async ɵconnectTrajectory(params) {
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
649
|
+
let response;
|
|
650
|
+
try {
|
|
651
|
+
response = await fetch(`${this.#apiUrl}/api/trajectories/join`, {
|
|
652
|
+
method: "POST",
|
|
653
|
+
headers: {
|
|
654
|
+
Authorization: `Bearer ${this.#apiKey}`,
|
|
655
|
+
"Content-Type": "application/json"
|
|
656
|
+
},
|
|
657
|
+
body: JSON.stringify({
|
|
658
|
+
trajectoryId: params.trajectoryId,
|
|
659
|
+
appUserId: params.user.id
|
|
660
|
+
}),
|
|
661
|
+
signal: params.signal,
|
|
662
|
+
redirect: "error"
|
|
663
|
+
});
|
|
664
|
+
} catch (error) {
|
|
665
|
+
if (!params.signal?.aborted) _copilotkit_shared.logger.warn({
|
|
666
|
+
error: error instanceof Error ? error.name : typeof error,
|
|
667
|
+
causeCode: networkErrorCode(error instanceof Error ? error.cause : void 0),
|
|
668
|
+
host: urlHost(this.#apiUrl)
|
|
669
|
+
}, "Could not reach Intelligence to connect a Trajectory");
|
|
670
|
+
throw error;
|
|
671
|
+
}
|
|
662
672
|
const payload = await response.json().catch(() => void 0);
|
|
663
673
|
if (!response.ok) throw require_trajectories.trajectoryResponseError(payload, response.status, this.#apiKey);
|
|
664
674
|
return require_trajectories.parseTrajectoryConnectionGrant(payload, params.trajectoryId, this.ɵgetClientWsUrl());
|
|
@@ -1114,6 +1124,19 @@ function deriveRunnerWsUrl(wsUrl) {
|
|
|
1114
1124
|
if (wsUrl.endsWith("/channels")) return `${wsUrl.slice(0, -9)}/runner`;
|
|
1115
1125
|
return `${wsUrl}/runner`;
|
|
1116
1126
|
}
|
|
1127
|
+
/** A system error code such as ECONNREFUSED, or undefined for anything else. */
|
|
1128
|
+
function networkErrorCode(cause) {
|
|
1129
|
+
const code = typeof cause === "object" && cause !== null && "code" in cause ? cause.code : void 0;
|
|
1130
|
+
return typeof code === "string" && /^[A-Z][A-Z0-9_]{0,63}$/.test(code) ? code : void 0;
|
|
1131
|
+
}
|
|
1132
|
+
/** The host of a URL without its credentials, path or query. */
|
|
1133
|
+
function urlHost(url) {
|
|
1134
|
+
try {
|
|
1135
|
+
return new URL(url).host;
|
|
1136
|
+
} catch {
|
|
1137
|
+
return;
|
|
1138
|
+
}
|
|
1139
|
+
}
|
|
1117
1140
|
function deriveClientWsUrl(wsUrl) {
|
|
1118
1141
|
if (wsUrl.endsWith("/client")) return wsUrl;
|
|
1119
1142
|
if (wsUrl.endsWith("/runner")) return `${wsUrl.slice(0, -7)}/client`;
|