copilotkit 4.2.0 → 4.2.1
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/index.js +80 -28
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -86,9 +86,9 @@ function getTelemetryEndpointUrl() {
|
|
|
86
86
|
}
|
|
87
87
|
function getBuildInfo() {
|
|
88
88
|
return {
|
|
89
|
-
version: true ? "4.2.
|
|
90
|
-
buildNumber: true ? "
|
|
91
|
-
commitSha: true ? "
|
|
89
|
+
version: true ? "4.2.1" : "dev",
|
|
90
|
+
buildNumber: true ? "28617162924" : "dev",
|
|
91
|
+
commitSha: true ? "662c87d2fca9d23f5b58adc49e244b326c094823" : "dev"
|
|
92
92
|
};
|
|
93
93
|
}
|
|
94
94
|
function getTemplateRef() {
|
|
@@ -29099,7 +29099,7 @@ var require_atomic_sleep = __commonJS({
|
|
|
29099
29099
|
"node_modules/.pnpm/atomic-sleep@1.0.0/node_modules/atomic-sleep/index.js"(exports, module) {
|
|
29100
29100
|
"use strict";
|
|
29101
29101
|
if (typeof SharedArrayBuffer !== "undefined" && typeof Atomics !== "undefined") {
|
|
29102
|
-
let
|
|
29102
|
+
let sleep2 = function(ms) {
|
|
29103
29103
|
const valid = ms > 0 && ms < Infinity;
|
|
29104
29104
|
if (valid === false) {
|
|
29105
29105
|
if (typeof ms !== "number" && typeof ms !== "bigint") {
|
|
@@ -29110,9 +29110,9 @@ var require_atomic_sleep = __commonJS({
|
|
|
29110
29110
|
Atomics.wait(nil, 0, 0, Number(ms));
|
|
29111
29111
|
};
|
|
29112
29112
|
const nil = new Int32Array(new SharedArrayBuffer(4));
|
|
29113
|
-
module.exports =
|
|
29113
|
+
module.exports = sleep2;
|
|
29114
29114
|
} else {
|
|
29115
|
-
let
|
|
29115
|
+
let sleep2 = function(ms) {
|
|
29116
29116
|
const valid = ms > 0 && ms < Infinity;
|
|
29117
29117
|
if (valid === false) {
|
|
29118
29118
|
if (typeof ms !== "number" && typeof ms !== "bigint") {
|
|
@@ -29124,7 +29124,7 @@ var require_atomic_sleep = __commonJS({
|
|
|
29124
29124
|
while (target > Date.now()) {
|
|
29125
29125
|
}
|
|
29126
29126
|
};
|
|
29127
|
-
module.exports =
|
|
29127
|
+
module.exports = sleep2;
|
|
29128
29128
|
}
|
|
29129
29129
|
}
|
|
29130
29130
|
});
|
|
@@ -29137,7 +29137,7 @@ var require_sonic_boom = __commonJS({
|
|
|
29137
29137
|
var EventEmitter3 = __require("events");
|
|
29138
29138
|
var inherits = __require("util").inherits;
|
|
29139
29139
|
var path21 = __require("path");
|
|
29140
|
-
var
|
|
29140
|
+
var sleep2 = require_atomic_sleep();
|
|
29141
29141
|
var assert3 = __require("assert");
|
|
29142
29142
|
var BUSY_WRITE_TIMEOUT = 100;
|
|
29143
29143
|
var kEmptyBuffer = Buffer.allocUnsafe(0);
|
|
@@ -29285,7 +29285,7 @@ var require_sonic_boom = __commonJS({
|
|
|
29285
29285
|
if ((err.code === "EAGAIN" || err.code === "EBUSY") && this.retryEAGAIN(err, this._writingBuf.length, this._len - this._writingBuf.length)) {
|
|
29286
29286
|
if (this.sync) {
|
|
29287
29287
|
try {
|
|
29288
|
-
|
|
29288
|
+
sleep2(BUSY_WRITE_TIMEOUT);
|
|
29289
29289
|
this.release(void 0, 0);
|
|
29290
29290
|
} catch (err2) {
|
|
29291
29291
|
this.release(err2);
|
|
@@ -29599,7 +29599,7 @@ var require_sonic_boom = __commonJS({
|
|
|
29599
29599
|
if (shouldRetry && !this.retryEAGAIN(err, buf.length, this._len - buf.length)) {
|
|
29600
29600
|
throw err;
|
|
29601
29601
|
}
|
|
29602
|
-
|
|
29602
|
+
sleep2(BUSY_WRITE_TIMEOUT);
|
|
29603
29603
|
}
|
|
29604
29604
|
}
|
|
29605
29605
|
try {
|
|
@@ -29636,7 +29636,7 @@ var require_sonic_boom = __commonJS({
|
|
|
29636
29636
|
if (shouldRetry && !this.retryEAGAIN(err, buf.length, this._len - buf.length)) {
|
|
29637
29637
|
throw err;
|
|
29638
29638
|
}
|
|
29639
|
-
|
|
29639
|
+
sleep2(BUSY_WRITE_TIMEOUT);
|
|
29640
29640
|
}
|
|
29641
29641
|
}
|
|
29642
29642
|
}
|
|
@@ -30373,7 +30373,7 @@ var require_transport = __commonJS({
|
|
|
30373
30373
|
var getCallers = require_caller();
|
|
30374
30374
|
var { join: join13, isAbsolute, sep } = __require("node:path");
|
|
30375
30375
|
var { fileURLToPath: fileURLToPath3 } = __require("node:url");
|
|
30376
|
-
var
|
|
30376
|
+
var sleep2 = require_atomic_sleep();
|
|
30377
30377
|
var onExit = require_on_exit_leak_free();
|
|
30378
30378
|
var ThreadStream = require_thread_stream();
|
|
30379
30379
|
function setupOnExit(stream) {
|
|
@@ -30496,7 +30496,7 @@ var require_transport = __commonJS({
|
|
|
30496
30496
|
return;
|
|
30497
30497
|
}
|
|
30498
30498
|
stream.flushSync();
|
|
30499
|
-
|
|
30499
|
+
sleep2(100);
|
|
30500
30500
|
stream.end();
|
|
30501
30501
|
}
|
|
30502
30502
|
return stream;
|
|
@@ -90781,16 +90781,58 @@ async function fetchWithTimeout(url2, init) {
|
|
|
90781
90781
|
"CLI_REQUEST_TIMEOUT"
|
|
90782
90782
|
);
|
|
90783
90783
|
}
|
|
90784
|
-
const detail = error48 instanceof Error ? error48.message : String(error48);
|
|
90785
90784
|
throw new ApiClientError(
|
|
90786
90785
|
0,
|
|
90787
|
-
`Could not reach CopilotKit at ${url2}: ${
|
|
90786
|
+
`Could not reach CopilotKit at ${url2}: ${describeTransportError(error48)}. Check your network connection and try again.`,
|
|
90788
90787
|
"CLI_REQUEST_FAILED"
|
|
90789
90788
|
);
|
|
90790
90789
|
} finally {
|
|
90791
90790
|
clearTimeout(timer);
|
|
90792
90791
|
}
|
|
90793
90792
|
}
|
|
90793
|
+
function describeTransportError(error48) {
|
|
90794
|
+
if (!(error48 instanceof Error)) {
|
|
90795
|
+
return String(error48);
|
|
90796
|
+
}
|
|
90797
|
+
const cause = error48.cause;
|
|
90798
|
+
if (cause instanceof Error) {
|
|
90799
|
+
const code = cause.code;
|
|
90800
|
+
const causeDetail = typeof code === "string" && code.length > 0 ? code : cause.message;
|
|
90801
|
+
if (causeDetail) {
|
|
90802
|
+
return `${error48.message} (${causeDetail})`;
|
|
90803
|
+
}
|
|
90804
|
+
}
|
|
90805
|
+
return error48.message;
|
|
90806
|
+
}
|
|
90807
|
+
function isRetryableTransportError(error48) {
|
|
90808
|
+
if (!(error48 instanceof ApiClientError)) {
|
|
90809
|
+
return false;
|
|
90810
|
+
}
|
|
90811
|
+
if (error48.code === "CLI_REQUEST_FAILED") {
|
|
90812
|
+
return true;
|
|
90813
|
+
}
|
|
90814
|
+
return error48.status >= 500;
|
|
90815
|
+
}
|
|
90816
|
+
function sleep(ms) {
|
|
90817
|
+
return new Promise((resolve3) => {
|
|
90818
|
+
setTimeout(resolve3, ms);
|
|
90819
|
+
});
|
|
90820
|
+
}
|
|
90821
|
+
async function retryTransient(operation, attempts = DEFAULT_TRANSIENT_RETRY_ATTEMPTS) {
|
|
90822
|
+
let lastError;
|
|
90823
|
+
for (let attempt = 1; attempt <= attempts; attempt += 1) {
|
|
90824
|
+
try {
|
|
90825
|
+
return await operation();
|
|
90826
|
+
} catch (error48) {
|
|
90827
|
+
lastError = error48;
|
|
90828
|
+
if (attempt >= attempts || !isRetryableTransportError(error48)) {
|
|
90829
|
+
throw error48;
|
|
90830
|
+
}
|
|
90831
|
+
await sleep(TRANSIENT_RETRY_BASE_DELAY_MS * attempt);
|
|
90832
|
+
}
|
|
90833
|
+
}
|
|
90834
|
+
throw lastError;
|
|
90835
|
+
}
|
|
90794
90836
|
function verifySessionResponseError(status, error48) {
|
|
90795
90837
|
const organizationInvalid = error48.issues.some(
|
|
90796
90838
|
(issue2) => issue2.path[0] === "organization"
|
|
@@ -90879,13 +90921,16 @@ function createApiClient(baseUrl, token, options = {}) {
|
|
|
90879
90921
|
return res.json();
|
|
90880
90922
|
},
|
|
90881
90923
|
async verifySession() {
|
|
90882
|
-
const res = await
|
|
90883
|
-
|
|
90884
|
-
|
|
90924
|
+
const res = await retryTransient(async () => {
|
|
90925
|
+
const r = await fetchWithTimeout(`${baseUrl}/api/cli/auth/verify`, {
|
|
90926
|
+
method: "GET",
|
|
90927
|
+
headers: { Authorization: `Bearer ${token}` }
|
|
90928
|
+
});
|
|
90929
|
+
if (!r.ok) {
|
|
90930
|
+
throw await readApiError(r);
|
|
90931
|
+
}
|
|
90932
|
+
return r;
|
|
90885
90933
|
});
|
|
90886
|
-
if (!res.ok) {
|
|
90887
|
-
throw await readApiError(res);
|
|
90888
|
-
}
|
|
90889
90934
|
const parsed = verifySessionResponseSchema.safeParse(await res.json());
|
|
90890
90935
|
if (!parsed.success) {
|
|
90891
90936
|
throw verifySessionResponseError(res.status, parsed.error);
|
|
@@ -90934,12 +90979,15 @@ function createApiClient(baseUrl, token, options = {}) {
|
|
|
90934
90979
|
async listHostedProjects() {
|
|
90935
90980
|
const productBaseUrl = requireProductBaseUrl(options);
|
|
90936
90981
|
const organizationId = requireProductOrganizationId(options);
|
|
90937
|
-
const res = await
|
|
90938
|
-
|
|
90982
|
+
const res = await retryTransient(async () => {
|
|
90983
|
+
const r = await fetchProduct(`${productBaseUrl}/api/projects`, {
|
|
90984
|
+
method: "GET"
|
|
90985
|
+
});
|
|
90986
|
+
if (!r.ok) {
|
|
90987
|
+
throw await readApiError(r);
|
|
90988
|
+
}
|
|
90989
|
+
return r;
|
|
90939
90990
|
});
|
|
90940
|
-
if (!res.ok) {
|
|
90941
|
-
throw await readApiError(res);
|
|
90942
|
-
}
|
|
90943
90991
|
return parseAppApiProjectListResponse(await res.json(), organizationId);
|
|
90944
90992
|
},
|
|
90945
90993
|
async createHostedProject(name) {
|
|
@@ -90977,7 +91025,7 @@ function createApiClient(baseUrl, token, options = {}) {
|
|
|
90977
91025
|
}
|
|
90978
91026
|
};
|
|
90979
91027
|
}
|
|
90980
|
-
var opsContractsRuntime2, opsContracts2, cliProductCredentialExchangeResponseSchema2, ApiClientError, verifySessionResponseSchema, appApiProjectSchema, appApiProjectListResponseSchema, appApiCreateKeyResponseSchema, DEFAULT_REQUEST_TIMEOUT_MS, NO_ORGANIZATION_MESSAGE;
|
|
91028
|
+
var opsContractsRuntime2, opsContracts2, cliProductCredentialExchangeResponseSchema2, ApiClientError, verifySessionResponseSchema, appApiProjectSchema, appApiProjectListResponseSchema, appApiCreateKeyResponseSchema, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_TRANSIENT_RETRY_ATTEMPTS, TRANSIENT_RETRY_BASE_DELAY_MS, NO_ORGANIZATION_MESSAGE;
|
|
90981
91029
|
var init_api_client = __esm({
|
|
90982
91030
|
"apps/cli/src/services/api-client.ts"() {
|
|
90983
91031
|
"use strict";
|
|
@@ -91032,6 +91080,8 @@ var init_api_client = __esm({
|
|
|
91032
91080
|
}).strict()
|
|
91033
91081
|
}).strict();
|
|
91034
91082
|
DEFAULT_REQUEST_TIMEOUT_MS = 15e3;
|
|
91083
|
+
DEFAULT_TRANSIENT_RETRY_ATTEMPTS = 3;
|
|
91084
|
+
TRANSIENT_RETRY_BASE_DELAY_MS = 500;
|
|
91035
91085
|
NO_ORGANIZATION_MESSAGE = "No active organization for this session. Please log in again with `copilotkit login`.";
|
|
91036
91086
|
}
|
|
91037
91087
|
});
|
|
@@ -96110,12 +96160,14 @@ async function scaffoldInitProject(options, dependencies = defaultInitScaffoldDe
|
|
|
96110
96160
|
dependencies.writeHostedApiKey(projectDir, apiKey.token);
|
|
96111
96161
|
} catch (provisionError) {
|
|
96112
96162
|
const detail = provisionError instanceof Error ? provisionError.message : String(provisionError);
|
|
96163
|
+
const code = provisionError instanceof ApiClientError ? provisionError.code : void 0;
|
|
96113
96164
|
warnings.push(
|
|
96114
96165
|
`Could not provision a project-scoped API key (${detail}); no INTELLIGENCE_API_KEY was written. Re-run \`copilotkit project select\` in the project, or set INTELLIGENCE_API_KEY manually, before running the app.`
|
|
96115
96166
|
);
|
|
96116
96167
|
writeCliLog("error", {
|
|
96117
96168
|
event: "init.provision_api_key_failed",
|
|
96118
|
-
detail
|
|
96169
|
+
detail,
|
|
96170
|
+
code
|
|
96119
96171
|
});
|
|
96120
96172
|
}
|
|
96121
96173
|
}
|