copilotkit 4.0.0 → 4.0.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 +284 -52
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -78,9 +78,9 @@ function getTelemetryEndpointUrl() {
|
|
|
78
78
|
}
|
|
79
79
|
function getBuildInfo() {
|
|
80
80
|
return {
|
|
81
|
-
version: true ? "4.0.
|
|
82
|
-
buildNumber: true ? "
|
|
83
|
-
commitSha: true ? "
|
|
81
|
+
version: true ? "4.0.1" : "dev",
|
|
82
|
+
buildNumber: true ? "27840207129" : "dev",
|
|
83
|
+
commitSha: true ? "e5f3dcfef0b6d5732bd9c436285eab0e650303f8" : "dev"
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
function getTemplateRef() {
|
|
@@ -1241,9 +1241,9 @@ var init_retryify_async = __esm({
|
|
|
1241
1241
|
throw error48;
|
|
1242
1242
|
if (Date.now() >= timestamp)
|
|
1243
1243
|
throw error48;
|
|
1244
|
-
const
|
|
1245
|
-
if (
|
|
1246
|
-
const delayPromise = new Promise((resolve2) => setTimeout(resolve2,
|
|
1244
|
+
const delay3 = Math.round(interval * Math.random());
|
|
1245
|
+
if (delay3 > 0) {
|
|
1246
|
+
const delayPromise = new Promise((resolve2) => setTimeout(resolve2, delay3));
|
|
1247
1247
|
return delayPromise.then(() => attempt.apply(void 0, args));
|
|
1248
1248
|
} else {
|
|
1249
1249
|
return attempt.apply(void 0, args);
|
|
@@ -91561,6 +91561,21 @@ function copyEnvExample(projectDir) {
|
|
|
91561
91561
|
}
|
|
91562
91562
|
return false;
|
|
91563
91563
|
}
|
|
91564
|
+
function removeTestHarnessArtifacts(projectDir) {
|
|
91565
|
+
const markerPath = path9.join(projectDir, "docker-compose.test.yml");
|
|
91566
|
+
if (!fs13.existsSync(markerPath)) {
|
|
91567
|
+
return [];
|
|
91568
|
+
}
|
|
91569
|
+
const removed = [];
|
|
91570
|
+
for (const artifact of TEST_HARNESS_ARTIFACTS) {
|
|
91571
|
+
const target = path9.join(projectDir, artifact);
|
|
91572
|
+
if (fs13.existsSync(target)) {
|
|
91573
|
+
fs13.rmSync(target, { recursive: true, force: true });
|
|
91574
|
+
removed.push(artifact);
|
|
91575
|
+
}
|
|
91576
|
+
}
|
|
91577
|
+
return removed;
|
|
91578
|
+
}
|
|
91564
91579
|
function writeEnvLicenseKey(projectDir, licenseKey) {
|
|
91565
91580
|
const envPath = path9.join(projectDir, ".env");
|
|
91566
91581
|
const envExamplePath = path9.join(projectDir, ".env.example");
|
|
@@ -91605,11 +91620,18 @@ async function commitInitial(projectDir) {
|
|
|
91605
91620
|
stdio: "pipe"
|
|
91606
91621
|
});
|
|
91607
91622
|
}
|
|
91608
|
-
var LICENSE_TOKEN_LINE_RE;
|
|
91623
|
+
var TEST_HARNESS_ARTIFACTS, LICENSE_TOKEN_LINE_RE;
|
|
91609
91624
|
var init_project_scaffold = __esm({
|
|
91610
91625
|
"apps/cli/src/services/project-scaffold.ts"() {
|
|
91611
91626
|
"use strict";
|
|
91612
91627
|
init_event_properties();
|
|
91628
|
+
TEST_HARNESS_ARTIFACTS = [
|
|
91629
|
+
"docker",
|
|
91630
|
+
".dockerignore",
|
|
91631
|
+
"docker-compose.test.yml",
|
|
91632
|
+
"Dockerfile",
|
|
91633
|
+
"docker-route-override.ts"
|
|
91634
|
+
];
|
|
91613
91635
|
LICENSE_TOKEN_LINE_RE = /^[ \t]*(?:export\s+)?COPILOTKIT_LICENSE_TOKEN=.*$/m;
|
|
91614
91636
|
}
|
|
91615
91637
|
});
|
|
@@ -92035,12 +92057,24 @@ function withFsErrorTag(operation) {
|
|
|
92035
92057
|
throw err;
|
|
92036
92058
|
}
|
|
92037
92059
|
}
|
|
92060
|
+
function buildIntelligenceEnvKeys(hosted) {
|
|
92061
|
+
const keys = [];
|
|
92062
|
+
if (hosted.apiUrl !== "") {
|
|
92063
|
+
keys.push({ key: "INTELLIGENCE_API_URL" });
|
|
92064
|
+
}
|
|
92065
|
+
if (hosted.gatewayWsUrl !== "") {
|
|
92066
|
+
keys.push({ key: "INTELLIGENCE_GATEWAY_WS_URL" });
|
|
92067
|
+
}
|
|
92068
|
+
keys.push({ key: "INTELLIGENCE_API_KEY" });
|
|
92069
|
+
return keys;
|
|
92070
|
+
}
|
|
92038
92071
|
function activateIntelligence({
|
|
92039
92072
|
projectDir,
|
|
92040
92073
|
vendorEnvKeys = [],
|
|
92041
92074
|
hosted
|
|
92042
92075
|
}) {
|
|
92043
|
-
|
|
92076
|
+
const intelligenceEnvKeys = hosted ? buildIntelligenceEnvKeys(hosted) : [];
|
|
92077
|
+
writeDevInfraScript(projectDir, vendorEnvKeys, intelligenceEnvKeys);
|
|
92044
92078
|
const devScriptPatched = chainDevInfraScript(projectDir);
|
|
92045
92079
|
if (hosted) {
|
|
92046
92080
|
writeHostedEnvBlock(projectDir, hosted);
|
|
@@ -92058,19 +92092,25 @@ function resolveHostedScaffoldConfig() {
|
|
|
92058
92092
|
slEnabled: getHostedSlEnabled()
|
|
92059
92093
|
};
|
|
92060
92094
|
}
|
|
92061
|
-
function buildDevInfraScriptContent(vendorEnvKeys) {
|
|
92095
|
+
function buildDevInfraScriptContent(vendorEnvKeys, intelligenceEnvKeys) {
|
|
92062
92096
|
const validEnvKeyName = /^[A-Za-z_][A-Za-z0-9_]*$/;
|
|
92063
|
-
for (const entry of vendorEnvKeys) {
|
|
92097
|
+
for (const entry of [...vendorEnvKeys, ...intelligenceEnvKeys]) {
|
|
92064
92098
|
if (!validEnvKeyName.test(entry.key)) {
|
|
92065
92099
|
throw new Error(
|
|
92066
|
-
`
|
|
92100
|
+
`Env key "${entry.key}" is not a valid environment variable name; refusing to template it into the dev preflight script.`
|
|
92067
92101
|
);
|
|
92068
92102
|
}
|
|
92069
92103
|
}
|
|
92070
92104
|
const requiredEnvKeysJson = JSON.stringify(vendorEnvKeys, null, 2);
|
|
92105
|
+
const requiredIntelligenceKeysJson = JSON.stringify(
|
|
92106
|
+
intelligenceEnvKeys,
|
|
92107
|
+
null,
|
|
92108
|
+
2
|
|
92109
|
+
);
|
|
92071
92110
|
return `#!/usr/bin/env node
|
|
92072
|
-
// Warns about missing LLM vendor API keys
|
|
92073
|
-
//
|
|
92111
|
+
// Warns about missing LLM vendor API keys and missing CopilotKit Intelligence
|
|
92112
|
+
// configuration before \`npm run dev\`, then lets the dev server start anyway
|
|
92113
|
+
// (chat/generations and Intelligence features fail until the values are set).
|
|
92074
92114
|
// Written by \`copilotkit init\`; safe to delete if you manage env validation
|
|
92075
92115
|
// yourself.
|
|
92076
92116
|
import { existsSync, readFileSync } from 'node:fs';
|
|
@@ -92078,6 +92118,13 @@ import { existsSync, readFileSync } from 'node:fs';
|
|
|
92078
92118
|
/** Vendor API keys this scaffold needs before chat and generations will work. */
|
|
92079
92119
|
const REQUIRED_ENV_KEYS = ${requiredEnvKeysJson};
|
|
92080
92120
|
|
|
92121
|
+
/**
|
|
92122
|
+
* Hosted CopilotKit Intelligence env var NAMES this scaffold was generated with
|
|
92123
|
+
* (no values \u2014 those live only in .env). Empty for a non-hosted build. A
|
|
92124
|
+
* missing/blank value means the generated .env was overwritten.
|
|
92125
|
+
*/
|
|
92126
|
+
const REQUIRED_INTELLIGENCE_KEYS = ${requiredIntelligenceKeysJson};
|
|
92127
|
+
|
|
92081
92128
|
const envFileExists = existsSync('.env');
|
|
92082
92129
|
const envFileContent = envFileExists ? readFileSync('.env', 'utf8') : '';
|
|
92083
92130
|
|
|
@@ -92116,17 +92163,45 @@ if (failedKeys.length > 0) {
|
|
|
92116
92163
|
);
|
|
92117
92164
|
}
|
|
92118
92165
|
|
|
92166
|
+
// Hosted Intelligence config check (ENT-949). Reuses the shared predicate above:
|
|
92167
|
+
// a key is unsatisfied when missing/blank in both process.env and .env \u2014 the
|
|
92168
|
+
// symptom of an overwritten generated .env. Names the missing keys only; the
|
|
92169
|
+
// values belong solely in .env, so the fix is to restore it or re-run init.
|
|
92170
|
+
const intelligenceFailures = findUnsatisfiedVendorKeys(
|
|
92171
|
+
process.env,
|
|
92172
|
+
envFileContent,
|
|
92173
|
+
REQUIRED_INTELLIGENCE_KEYS,
|
|
92174
|
+
).map(({ requirement }) => requirement);
|
|
92175
|
+
|
|
92176
|
+
if (intelligenceFailures.length > 0) {
|
|
92177
|
+
console.warn(
|
|
92178
|
+
'\u26A0 CopilotKit Intelligence is not configured \u2014 your .env may have been overwritten.',
|
|
92179
|
+
);
|
|
92180
|
+
for (const entry of intelligenceFailures) {
|
|
92181
|
+
console.warn(\` Missing: \${entry.key}\`);
|
|
92182
|
+
}
|
|
92183
|
+
console.warn(
|
|
92184
|
+
'Restore the value(s) in .env, or re-run \`copilotkit init\` to reconfigure.',
|
|
92185
|
+
);
|
|
92186
|
+
console.warn(
|
|
92187
|
+
'Starting the dev server anyway \u2014 Intelligence features will not work until these are set.',
|
|
92188
|
+
);
|
|
92189
|
+
}
|
|
92190
|
+
|
|
92119
92191
|
process.exit(0);
|
|
92120
92192
|
`;
|
|
92121
92193
|
}
|
|
92122
|
-
function writeDevInfraScript(projectDir, vendorEnvKeys) {
|
|
92194
|
+
function writeDevInfraScript(projectDir, vendorEnvKeys, intelligenceEnvKeys) {
|
|
92123
92195
|
const scriptPath = path12.join(projectDir, DEV_INFRA_SCRIPT_PATH);
|
|
92124
92196
|
if (fs15.existsSync(scriptPath)) {
|
|
92125
92197
|
return;
|
|
92126
92198
|
}
|
|
92127
92199
|
withFsErrorTag(() => {
|
|
92128
92200
|
fs15.mkdirSync(path12.dirname(scriptPath), { recursive: true });
|
|
92129
|
-
fs15.writeFileSync(
|
|
92201
|
+
fs15.writeFileSync(
|
|
92202
|
+
scriptPath,
|
|
92203
|
+
buildDevInfraScriptContent(vendorEnvKeys, intelligenceEnvKeys)
|
|
92204
|
+
);
|
|
92130
92205
|
});
|
|
92131
92206
|
}
|
|
92132
92207
|
function chainDevInfraScript(projectDir) {
|
|
@@ -92294,6 +92369,21 @@ var init_hosted_project2 = __esm({
|
|
|
92294
92369
|
}
|
|
92295
92370
|
});
|
|
92296
92371
|
|
|
92372
|
+
// apps/cli/src/ui/theme.ts
|
|
92373
|
+
var theme;
|
|
92374
|
+
var init_theme = __esm({
|
|
92375
|
+
"apps/cli/src/ui/theme.ts"() {
|
|
92376
|
+
"use strict";
|
|
92377
|
+
theme = {
|
|
92378
|
+
/**
|
|
92379
|
+
* Brand violet accent — used for the product name, selected picker rows, and
|
|
92380
|
+
* primary marks. A single source of truth so the shade is tuned in one place.
|
|
92381
|
+
*/
|
|
92382
|
+
accent: "#6B5CFF"
|
|
92383
|
+
};
|
|
92384
|
+
}
|
|
92385
|
+
});
|
|
92386
|
+
|
|
92297
92387
|
// apps/cli/src/ui/hosted-project-select.tsx
|
|
92298
92388
|
function defer() {
|
|
92299
92389
|
let resolve2;
|
|
@@ -92302,8 +92392,8 @@ function defer() {
|
|
|
92302
92392
|
});
|
|
92303
92393
|
return { promise: promise2, resolve: resolve2 };
|
|
92304
92394
|
}
|
|
92305
|
-
function ProjectExplainer() {
|
|
92306
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { children: "An Intelligence project is where this app's threads, messages, and analytics are stored." });
|
|
92395
|
+
function ProjectExplainer({ dim = false }) {
|
|
92396
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { dimColor: dim, children: "An Intelligence project is where this app's threads, messages, and analytics are stored." });
|
|
92307
92397
|
}
|
|
92308
92398
|
function HostedProjectSelect({
|
|
92309
92399
|
apiClient,
|
|
@@ -92491,16 +92581,24 @@ function HostedProjectSelect({
|
|
|
92491
92581
|
{ label: "Create a new project", value: "__create__" }
|
|
92492
92582
|
];
|
|
92493
92583
|
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
92494
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, {
|
|
92495
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ProjectExplainer, {}),
|
|
92584
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { children: "Connect this app to one of your existing projects, or create a new one." }),
|
|
92585
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(ProjectExplainer, { dim: true }),
|
|
92496
92586
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { children: " " }),
|
|
92497
92587
|
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Text, { children: "Select a project (\u2191/\u2193 to move, Enter to choose, Esc to cancel):" }),
|
|
92498
92588
|
items.map((item, index) => {
|
|
92499
92589
|
const selected = index === pickerIndex;
|
|
92500
|
-
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
92501
|
-
|
|
92502
|
-
|
|
92503
|
-
|
|
92590
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
92591
|
+
Text,
|
|
92592
|
+
{
|
|
92593
|
+
color: selected ? theme.accent : void 0,
|
|
92594
|
+
bold: selected,
|
|
92595
|
+
children: [
|
|
92596
|
+
selected ? "\u276F " : "- ",
|
|
92597
|
+
item.label
|
|
92598
|
+
]
|
|
92599
|
+
},
|
|
92600
|
+
item.value
|
|
92601
|
+
);
|
|
92504
92602
|
})
|
|
92505
92603
|
] });
|
|
92506
92604
|
}
|
|
@@ -92543,6 +92641,7 @@ var init_hosted_project_select = __esm({
|
|
|
92543
92641
|
import_react37 = __toESM(require_react(), 1);
|
|
92544
92642
|
await init_build2();
|
|
92545
92643
|
init_hosted_project2();
|
|
92644
|
+
init_theme();
|
|
92546
92645
|
import_jsx_runtime7 = __toESM(require_jsx_runtime(), 1);
|
|
92547
92646
|
}
|
|
92548
92647
|
});
|
|
@@ -92827,8 +92926,12 @@ Start by inspecting my repo, then walk me through the setup.`;
|
|
|
92827
92926
|
// apps/cli/src/ui/banner.tsx
|
|
92828
92927
|
function Banner() {
|
|
92829
92928
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Box_default, { flexDirection: "column", marginBottom: 1, children: [
|
|
92830
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { color:
|
|
92831
|
-
/* @__PURE__ */ (0, import_jsx_runtime9.
|
|
92929
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { color: theme.accent, children: KITE }),
|
|
92930
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(Text, { bold: true, children: [
|
|
92931
|
+
"~ Welcome to ",
|
|
92932
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Text, { color: theme.accent, children: "CopilotKit" }),
|
|
92933
|
+
"! ~"
|
|
92934
|
+
] })
|
|
92832
92935
|
] });
|
|
92833
92936
|
}
|
|
92834
92937
|
function IntelligenceFeatures() {
|
|
@@ -92845,6 +92948,7 @@ var init_banner = __esm({
|
|
|
92845
92948
|
async "apps/cli/src/ui/banner.tsx"() {
|
|
92846
92949
|
"use strict";
|
|
92847
92950
|
await init_build2();
|
|
92951
|
+
init_theme();
|
|
92848
92952
|
import_jsx_runtime9 = __toESM(require_jsx_runtime(), 1);
|
|
92849
92953
|
KITE = `\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
|
|
92850
92954
|
\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u281F\u2819\u28FF\u285B\u283B\u283F\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF
|
|
@@ -93202,38 +93306,99 @@ var init_docs = __esm({
|
|
|
93202
93306
|
// apps/cli/src/services/install-dependencies.ts
|
|
93203
93307
|
import { spawn as spawn3 } from "node:child_process";
|
|
93204
93308
|
import { StringDecoder } from "node:string_decoder";
|
|
93205
|
-
function
|
|
93206
|
-
|
|
93207
|
-
|
|
93208
|
-
})
|
|
93309
|
+
function delay2(ms) {
|
|
93310
|
+
return new Promise((resolve2) => {
|
|
93311
|
+
setTimeout(resolve2, ms);
|
|
93312
|
+
});
|
|
93313
|
+
}
|
|
93314
|
+
function runInstallOnce(cwd2, command) {
|
|
93209
93315
|
return new Promise((resolve2) => {
|
|
93210
|
-
const child = spawn3(command, { cwd: cwd2, shell: true, stdio: ["ignore", "
|
|
93211
|
-
const
|
|
93316
|
+
const child = spawn3(command, { cwd: cwd2, shell: true, stdio: ["ignore", "pipe", "pipe"] });
|
|
93317
|
+
const stdoutDecoder = new StringDecoder("utf8");
|
|
93318
|
+
const stderrDecoder = new StringDecoder("utf8");
|
|
93319
|
+
let stdout = "";
|
|
93212
93320
|
let stderr = "";
|
|
93321
|
+
child.stdout?.on("data", (chunk) => {
|
|
93322
|
+
stdout += stdoutDecoder.write(chunk);
|
|
93323
|
+
if (stdout.length > STDOUT_TAIL_LIMIT * 2) {
|
|
93324
|
+
stdout = stdout.slice(-STDOUT_TAIL_LIMIT);
|
|
93325
|
+
}
|
|
93326
|
+
});
|
|
93213
93327
|
child.stderr?.on("data", (chunk) => {
|
|
93214
|
-
stderr +=
|
|
93328
|
+
stderr += stderrDecoder.write(chunk);
|
|
93215
93329
|
if (stderr.length > STDERR_TAIL_LIMIT * 2) {
|
|
93216
93330
|
stderr = stderr.slice(-STDERR_TAIL_LIMIT);
|
|
93217
93331
|
}
|
|
93218
93332
|
});
|
|
93219
93333
|
child.once("error", (error48) => {
|
|
93220
|
-
resolve2({
|
|
93334
|
+
resolve2({
|
|
93335
|
+
ok: false,
|
|
93336
|
+
code: null,
|
|
93337
|
+
stdoutTail: "",
|
|
93338
|
+
stderrTail: "",
|
|
93339
|
+
spawnError: error48.message
|
|
93340
|
+
});
|
|
93221
93341
|
});
|
|
93222
93342
|
child.once("close", (code) => {
|
|
93223
|
-
|
|
93224
|
-
|
|
93225
|
-
|
|
93226
|
-
|
|
93227
|
-
|
|
93228
|
-
|
|
93343
|
+
stdout += stdoutDecoder.end();
|
|
93344
|
+
stderr += stderrDecoder.end();
|
|
93345
|
+
resolve2({
|
|
93346
|
+
ok: code === 0,
|
|
93347
|
+
code,
|
|
93348
|
+
stdoutTail: stdout.slice(-STDOUT_TAIL_LIMIT).trim(),
|
|
93349
|
+
stderrTail: stderr.slice(-STDERR_TAIL_LIMIT).trim()
|
|
93350
|
+
});
|
|
93229
93351
|
});
|
|
93230
93352
|
});
|
|
93231
93353
|
}
|
|
93232
|
-
|
|
93354
|
+
async function installDependencies({
|
|
93355
|
+
cwd: cwd2,
|
|
93356
|
+
command,
|
|
93357
|
+
log,
|
|
93358
|
+
retryDelayMs = DEFAULT_RETRY_DELAY_MS
|
|
93359
|
+
}) {
|
|
93360
|
+
let lastAttempt;
|
|
93361
|
+
for (let attempt = 1; attempt <= INSTALL_MAX_ATTEMPTS; attempt += 1) {
|
|
93362
|
+
if (attempt > 1 && retryDelayMs > 0) {
|
|
93363
|
+
await delay2(retryDelayMs);
|
|
93364
|
+
}
|
|
93365
|
+
lastAttempt = await runInstallOnce(cwd2, command);
|
|
93366
|
+
if (lastAttempt.ok) {
|
|
93367
|
+
if (attempt > 1) {
|
|
93368
|
+
log?.("info", {
|
|
93369
|
+
event: "install_succeeded_after_retry",
|
|
93370
|
+
command,
|
|
93371
|
+
cwd: cwd2,
|
|
93372
|
+
attempt
|
|
93373
|
+
});
|
|
93374
|
+
}
|
|
93375
|
+
return { ok: true };
|
|
93376
|
+
}
|
|
93377
|
+
log?.("error", {
|
|
93378
|
+
event: "install_failed",
|
|
93379
|
+
command,
|
|
93380
|
+
cwd: cwd2,
|
|
93381
|
+
attempt,
|
|
93382
|
+
maxAttempts: INSTALL_MAX_ATTEMPTS,
|
|
93383
|
+
exitCode: lastAttempt.code,
|
|
93384
|
+
...lastAttempt.spawnError ? { spawnError: lastAttempt.spawnError } : {},
|
|
93385
|
+
stdoutTail: lastAttempt.stdoutTail,
|
|
93386
|
+
stderrTail: lastAttempt.stderrTail
|
|
93387
|
+
});
|
|
93388
|
+
}
|
|
93389
|
+
return {
|
|
93390
|
+
ok: false,
|
|
93391
|
+
stderrTail: lastAttempt?.spawnError ?? lastAttempt?.stderrTail ?? "install failed"
|
|
93392
|
+
};
|
|
93393
|
+
}
|
|
93394
|
+
var STDERR_TAIL_LIMIT, STDOUT_TAIL_LIMIT, INSTALL_MAX_ATTEMPTS, DEFAULT_RETRY_DELAY_MS;
|
|
93233
93395
|
var init_install_dependencies = __esm({
|
|
93234
93396
|
"apps/cli/src/services/install-dependencies.ts"() {
|
|
93235
93397
|
"use strict";
|
|
93236
93398
|
STDERR_TAIL_LIMIT = 2e3;
|
|
93399
|
+
STDOUT_TAIL_LIMIT = 4e3;
|
|
93400
|
+
INSTALL_MAX_ATTEMPTS = 2;
|
|
93401
|
+
DEFAULT_RETRY_DELAY_MS = 1e3;
|
|
93237
93402
|
}
|
|
93238
93403
|
});
|
|
93239
93404
|
|
|
@@ -93273,6 +93438,15 @@ var init_vendor_env_keys = __esm({
|
|
|
93273
93438
|
});
|
|
93274
93439
|
|
|
93275
93440
|
// apps/cli/src/ui/init-flow.tsx
|
|
93441
|
+
function FrameworkIndicator({ isSelected = false }) {
|
|
93442
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Box_default, { marginRight: 1, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { color: isSelected ? theme.accent : void 0, children: isSelected ? "\u276F" : " " }) });
|
|
93443
|
+
}
|
|
93444
|
+
function FrameworkItem({
|
|
93445
|
+
isSelected = false,
|
|
93446
|
+
label
|
|
93447
|
+
}) {
|
|
93448
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { color: isSelected ? theme.accent : void 0, bold: isSelected, children: label });
|
|
93449
|
+
}
|
|
93276
93450
|
function validateName(name) {
|
|
93277
93451
|
if (name.length === 0)
|
|
93278
93452
|
return "App name is required.";
|
|
@@ -93284,6 +93458,32 @@ function validateName(name) {
|
|
|
93284
93458
|
return NAME_PATTERN_MESSAGE;
|
|
93285
93459
|
return null;
|
|
93286
93460
|
}
|
|
93461
|
+
function computeFrameworkPickerLimit(rows, itemCount) {
|
|
93462
|
+
if (!Number.isFinite(rows) || rows <= 0)
|
|
93463
|
+
return itemCount;
|
|
93464
|
+
const available = rows - FRAMEWORK_PICKER_RESERVED_ROWS;
|
|
93465
|
+
return Math.max(
|
|
93466
|
+
MIN_FRAMEWORK_PICKER_VISIBLE,
|
|
93467
|
+
Math.min(itemCount, available, MAX_FRAMEWORK_PICKER_VISIBLE)
|
|
93468
|
+
);
|
|
93469
|
+
}
|
|
93470
|
+
function useStdoutRows() {
|
|
93471
|
+
const { stdout } = use_stdout_default();
|
|
93472
|
+
const readRows = () => stdout && Number.isFinite(stdout.rows) && stdout.rows > 0 ? stdout.rows : 0;
|
|
93473
|
+
const [rows, setRows] = (0, import_react39.useState)(readRows);
|
|
93474
|
+
(0, import_react39.useEffect)(() => {
|
|
93475
|
+
if (!stdout)
|
|
93476
|
+
return;
|
|
93477
|
+
const update = () => {
|
|
93478
|
+
setRows(readRows());
|
|
93479
|
+
};
|
|
93480
|
+
stdout.on("resize", update);
|
|
93481
|
+
return () => {
|
|
93482
|
+
stdout.off("resize", update);
|
|
93483
|
+
};
|
|
93484
|
+
}, [stdout]);
|
|
93485
|
+
return rows;
|
|
93486
|
+
}
|
|
93287
93487
|
function InitFlow({
|
|
93288
93488
|
initialName,
|
|
93289
93489
|
initialIntelligence,
|
|
@@ -93302,6 +93502,7 @@ function InitFlow({
|
|
|
93302
93502
|
return "framework";
|
|
93303
93503
|
}
|
|
93304
93504
|
const [step, setStep] = (0, import_react39.useState)(firstStep);
|
|
93505
|
+
const stdoutRows = useStdoutRows();
|
|
93305
93506
|
(0, import_react39.useEffect)(() => {
|
|
93306
93507
|
if (initialFramework !== null) {
|
|
93307
93508
|
onFrameworkSelected?.({
|
|
@@ -93359,6 +93560,11 @@ function InitFlow({
|
|
|
93359
93560
|
const frameworkChoices = initialIntelligence === true ? FRAMEWORK_CHOICES.filter(
|
|
93360
93561
|
(choice) => THREADS_FRAMEWORKS.has(choice.value)
|
|
93361
93562
|
) : FRAMEWORK_CHOICES;
|
|
93563
|
+
const frameworkLimit = computeFrameworkPickerLimit(
|
|
93564
|
+
stdoutRows,
|
|
93565
|
+
frameworkChoices.length
|
|
93566
|
+
);
|
|
93567
|
+
const frameworkIsScrolling = frameworkLimit < frameworkChoices.length;
|
|
93362
93568
|
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
93363
93569
|
step === "name" && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Box_default, { flexDirection: "column", children: [
|
|
93364
93570
|
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Text, { bold: true, children: "App name" }),
|
|
@@ -93386,13 +93592,21 @@ function InitFlow({
|
|
|
93386
93592
|
SelectInput_default,
|
|
93387
93593
|
{
|
|
93388
93594
|
items: frameworkChoices,
|
|
93389
|
-
onSelect: handleFrameworkSelect
|
|
93595
|
+
onSelect: handleFrameworkSelect,
|
|
93596
|
+
indicatorComponent: FrameworkIndicator,
|
|
93597
|
+
itemComponent: FrameworkItem,
|
|
93598
|
+
limit: frameworkLimit
|
|
93390
93599
|
}
|
|
93391
|
-
)
|
|
93600
|
+
),
|
|
93601
|
+
frameworkIsScrolling && /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(Text, { dimColor: true, children: [
|
|
93602
|
+
"\u2191\u2193 to browse all ",
|
|
93603
|
+
frameworkChoices.length,
|
|
93604
|
+
" \xB7 \u21B5 select"
|
|
93605
|
+
] })
|
|
93392
93606
|
] })
|
|
93393
93607
|
] });
|
|
93394
93608
|
}
|
|
93395
|
-
var import_react39, import_jsx_runtime11, DISALLOWED_NAME_CHAR_RE, NAME_PATTERN_MESSAGE;
|
|
93609
|
+
var import_react39, import_jsx_runtime11, DISALLOWED_NAME_CHAR_RE, NAME_PATTERN_MESSAGE, FRAMEWORK_PICKER_RESERVED_ROWS, MIN_FRAMEWORK_PICKER_VISIBLE, MAX_FRAMEWORK_PICKER_VISIBLE;
|
|
93396
93610
|
var init_init_flow = __esm({
|
|
93397
93611
|
async "apps/cli/src/ui/init-flow.tsx"() {
|
|
93398
93612
|
"use strict";
|
|
@@ -93401,9 +93615,13 @@ var init_init_flow = __esm({
|
|
|
93401
93615
|
await init_build3();
|
|
93402
93616
|
await init_build4();
|
|
93403
93617
|
init_types();
|
|
93618
|
+
init_theme();
|
|
93404
93619
|
import_jsx_runtime11 = __toESM(require_jsx_runtime(), 1);
|
|
93405
93620
|
DISALLOWED_NAME_CHAR_RE = /[^a-z0-9-]/;
|
|
93406
93621
|
NAME_PATTERN_MESSAGE = "Use only lowercase letters, numbers, and hyphens, and do not start or end with a hyphen.";
|
|
93622
|
+
FRAMEWORK_PICKER_RESERVED_ROWS = 4;
|
|
93623
|
+
MIN_FRAMEWORK_PICKER_VISIBLE = 3;
|
|
93624
|
+
MAX_FRAMEWORK_PICKER_VISIBLE = 6;
|
|
93407
93625
|
}
|
|
93408
93626
|
});
|
|
93409
93627
|
|
|
@@ -93686,6 +93904,15 @@ async function scaffoldInitProject(options, dependencies = defaultInitScaffoldDe
|
|
|
93686
93904
|
...hostedConfig ? { hosted: hostedConfig } : {}
|
|
93687
93905
|
});
|
|
93688
93906
|
}
|
|
93907
|
+
try {
|
|
93908
|
+
dependencies.cleanupTestHarness(projectDir);
|
|
93909
|
+
} catch (cleanupError) {
|
|
93910
|
+
const detail = cleanupError instanceof Error ? cleanupError.message : String(cleanupError);
|
|
93911
|
+
process.stderr.write(
|
|
93912
|
+
`Warning: could not remove docker test-harness artifacts from the new app (${detail}); they remain in the scaffold.
|
|
93913
|
+
`
|
|
93914
|
+
);
|
|
93915
|
+
}
|
|
93689
93916
|
onPhaseChange?.("git");
|
|
93690
93917
|
try {
|
|
93691
93918
|
await dependencies.initGit(projectDir);
|
|
@@ -93973,7 +94200,8 @@ function ScaffoldProgress({
|
|
|
93973
94200
|
setPhase("installing");
|
|
93974
94201
|
scaffoldDependencies.installDependencies({
|
|
93975
94202
|
cwd: scaffoldResult.projectDir,
|
|
93976
|
-
command: templateDefinition.installCommand
|
|
94203
|
+
command: templateDefinition.installCommand,
|
|
94204
|
+
log: writeCliLog
|
|
93977
94205
|
}).then((r) => {
|
|
93978
94206
|
if (r.ok)
|
|
93979
94207
|
return true;
|
|
@@ -94005,14 +94233,17 @@ function ScaffoldProgress({
|
|
|
94005
94233
|
options.name,
|
|
94006
94234
|
'" created successfully!'
|
|
94007
94235
|
] }),
|
|
94008
|
-
installError ?
|
|
94009
|
-
|
|
94010
|
-
|
|
94011
|
-
|
|
94012
|
-
|
|
94013
|
-
|
|
94014
|
-
|
|
94015
|
-
|
|
94236
|
+
installError ? (
|
|
94237
|
+
// The error detail is not inlined here — it goes to the CLI log; the
|
|
94238
|
+
// second line points the user at the full captured output.
|
|
94239
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
94240
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Text, { color: "yellow", children: "Install didn't finish after a retry." }),
|
|
94241
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { color: "yellow", children: [
|
|
94242
|
+
"Full output: ",
|
|
94243
|
+
getCliLogPath()
|
|
94244
|
+
] })
|
|
94245
|
+
] })
|
|
94246
|
+
) : null,
|
|
94016
94247
|
scaffoldWarnings.map((warning, index) => /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(Text, { color: "yellow", children: [
|
|
94017
94248
|
"\u26A0 ",
|
|
94018
94249
|
warning
|
|
@@ -94218,6 +94449,7 @@ var init_init = __esm({
|
|
|
94218
94449
|
scaffoldProject,
|
|
94219
94450
|
initGit,
|
|
94220
94451
|
copyEnvExample,
|
|
94452
|
+
cleanupTestHarness: removeTestHarnessArtifacts,
|
|
94221
94453
|
writeLicenseKey,
|
|
94222
94454
|
commandExists,
|
|
94223
94455
|
resolveProjectDir: (projectName) => path14.resolve(process.cwd(), projectName),
|