@bendyline/gezel-cli 1.2.12 → 1.2.13
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/README.md +4 -2
- package/dist/app-author-command.js +5 -3
- package/dist/app-command.js +2 -0
- package/dist/bin/gezel-main.js +127 -37
- package/dist/knowledge-command.js +2 -0
- package/dist/tui/index.js +39 -2
- package/package.json +6 -6
package/README.md
CHANGED
|
@@ -14,8 +14,10 @@ installs a current one.
|
|
|
14
14
|
npm install -g @bendyline/gezel-cli
|
|
15
15
|
```
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
The unscoped [`gezel-cli`](https://www.npmjs.com/package/gezel-cli) package is the
|
|
18
|
+
short name for this one: `npx gezel-cli` runs it without installing, and
|
|
19
|
+
`npm install -g gezel-cli` installs the same program. Install one of the two
|
|
20
|
+
globally, not both: they both provide the `gezel` command.
|
|
19
21
|
|
|
20
22
|
Then choose where the AI runs.
|
|
21
23
|
|
|
@@ -471,6 +471,7 @@ import { createHash, randomUUID } from "crypto";
|
|
|
471
471
|
import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
|
|
472
472
|
import { homedir } from "os";
|
|
473
473
|
import { basename, dirname, join, resolve } from "path";
|
|
474
|
+
import { fileURLToPath } from "url";
|
|
474
475
|
import {
|
|
475
476
|
evaluateApiCompat,
|
|
476
477
|
getLogLevel,
|
|
@@ -488,6 +489,7 @@ import {
|
|
|
488
489
|
authorizeLocalOwner
|
|
489
490
|
} from "@bendyline/gezel-app-sdk";
|
|
490
491
|
import {
|
|
492
|
+
DaemonInAnotherNamespaceError,
|
|
491
493
|
GezelApiError,
|
|
492
494
|
GezelClient,
|
|
493
495
|
LiveDaemonUnhealthyError,
|
|
@@ -517,7 +519,7 @@ import { createHash as createHash2 } from "crypto";
|
|
|
517
519
|
import { readFileSync as readFileSync2 } from "fs";
|
|
518
520
|
import { mkdir as mkdir2, writeFile as writeFile2 } from "fs/promises";
|
|
519
521
|
import { dirname as dirname2, join as join3, relative } from "path";
|
|
520
|
-
import { fileURLToPath } from "url";
|
|
522
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
521
523
|
import { injectPageDemo, pageDemoBootstrapSource } from "@bendyline/gezel";
|
|
522
524
|
|
|
523
525
|
// ../../scripts/project-page-typography.mjs
|
|
@@ -539,8 +541,8 @@ function buildProjectPageTypography(uiRoot) {
|
|
|
539
541
|
// src/page-demo-export.ts
|
|
540
542
|
function pageDemoAssets() {
|
|
541
543
|
const sourceMode = import.meta.url.endsWith(".ts");
|
|
542
|
-
const fonts =
|
|
543
|
-
const css = sourceMode ? buildProjectPageTypography(
|
|
544
|
+
const fonts = fileURLToPath2(new URL("../../ui/src/assets/fonts/", import.meta.url));
|
|
545
|
+
const css = sourceMode ? buildProjectPageTypography(fileURLToPath2(new URL("../../ui", import.meta.url))) : readFileSync2(new URL("./page-typography.css", import.meta.url), "utf8");
|
|
544
546
|
const versioned = (stem, extension, source) => ({
|
|
545
547
|
path: `${stem}-${createHash2("sha256").update(source).digest("hex").slice(0, 16)}.${extension}`,
|
|
546
548
|
bytes: Buffer.from(source)
|
package/dist/app-command.js
CHANGED
|
@@ -10,6 +10,7 @@ import { createHash, randomUUID } from "crypto";
|
|
|
10
10
|
import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
|
|
11
11
|
import { homedir } from "os";
|
|
12
12
|
import { basename, dirname, join, resolve } from "path";
|
|
13
|
+
import { fileURLToPath } from "url";
|
|
13
14
|
import {
|
|
14
15
|
evaluateApiCompat,
|
|
15
16
|
getLogLevel,
|
|
@@ -27,6 +28,7 @@ import {
|
|
|
27
28
|
authorizeLocalOwner
|
|
28
29
|
} from "@bendyline/gezel-app-sdk";
|
|
29
30
|
import {
|
|
31
|
+
DaemonInAnotherNamespaceError,
|
|
30
32
|
GezelApiError,
|
|
31
33
|
GezelClient,
|
|
32
34
|
LiveDaemonUnhealthyError,
|
package/dist/bin/gezel-main.js
CHANGED
|
@@ -41,6 +41,7 @@ import { createHash, randomUUID } from "crypto";
|
|
|
41
41
|
import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
|
|
42
42
|
import { homedir } from "os";
|
|
43
43
|
import { basename, dirname, join, resolve } from "path";
|
|
44
|
+
import { fileURLToPath } from "url";
|
|
44
45
|
import {
|
|
45
46
|
evaluateApiCompat,
|
|
46
47
|
getLogLevel,
|
|
@@ -58,6 +59,7 @@ import {
|
|
|
58
59
|
authorizeLocalOwner
|
|
59
60
|
} from "@bendyline/gezel-app-sdk";
|
|
60
61
|
import {
|
|
62
|
+
DaemonInAnotherNamespaceError,
|
|
61
63
|
GezelApiError,
|
|
62
64
|
GezelClient,
|
|
63
65
|
LiveDaemonUnhealthyError,
|
|
@@ -172,7 +174,7 @@ async function connectOwned(globals, options = {}) {
|
|
|
172
174
|
...process.env.GEZEL_HOME ? { home: process.env.GEZEL_HOME } : {}
|
|
173
175
|
}
|
|
174
176
|
}).catch((error) => {
|
|
175
|
-
throw isIncompatibleDaemonError(error) ? incompatibleDaemonCliError(error) : error;
|
|
177
|
+
throw isIncompatibleDaemonError(error) ? incompatibleDaemonCliError(error) : localDaemonCliError(error) ?? error;
|
|
176
178
|
});
|
|
177
179
|
if (authorized.daemon.mode === "spawned" && options.announceSpawn !== false) {
|
|
178
180
|
process.stderr.write(spawnedDaemonNotice(authorized.daemon.pid));
|
|
@@ -273,9 +275,8 @@ async function authorizeLocalOwnedDaemon(deps = {}) {
|
|
|
273
275
|
});
|
|
274
276
|
return await (deps.connect ?? defaultConnectAsOwner)(authorized);
|
|
275
277
|
} catch (error) {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
}
|
|
278
|
+
const local = localDaemonCliError(error);
|
|
279
|
+
if (local) throw local;
|
|
279
280
|
if (!(error instanceof GezelSdkError) || error.code !== "daemon_not_running") {
|
|
280
281
|
throw cliGrantError(error, "the local Gezel daemon");
|
|
281
282
|
}
|
|
@@ -289,6 +290,13 @@ async function authorizeLocalOwnedDaemon(deps = {}) {
|
|
|
289
290
|
function defaultConnectAsOwner(authorized) {
|
|
290
291
|
return connectionFromAuthorization(authorized, "The local Gezel owner authorization");
|
|
291
292
|
}
|
|
293
|
+
function localDaemonCliError(error) {
|
|
294
|
+
if (error instanceof LiveDaemonUnhealthyError) {
|
|
295
|
+
return unhealthyLocalDaemonError(error.pid, error.baseUrl);
|
|
296
|
+
}
|
|
297
|
+
if (error instanceof DaemonInAnotherNamespaceError) return new CliError(error.message);
|
|
298
|
+
return null;
|
|
299
|
+
}
|
|
292
300
|
function unhealthyLocalDaemonError(pid, baseUrl) {
|
|
293
301
|
return new CliError(
|
|
294
302
|
`The local Gezel daemon (pid ${pid}) is running but did not answer at ${baseUrl}. Stop or repair it before retrying.`
|
|
@@ -566,12 +574,18 @@ var CLI_CLIENT_LABEL = "this gezel CLI";
|
|
|
566
574
|
function isIncompatibleDaemonError(error) {
|
|
567
575
|
return error instanceof GezelSdkError && error.code === "daemon_incompatible";
|
|
568
576
|
}
|
|
577
|
+
function cliUpdateCommand(moduleUrl = import.meta.url) {
|
|
578
|
+
const path = fileURLToPath(moduleUrl).replaceAll("\\", "/");
|
|
579
|
+
if (path.includes("/_npx/")) return "npx gezel-cli@latest";
|
|
580
|
+
const shortName = path.includes("/node_modules/gezel-cli/node_modules/@bendyline/gezel-cli/");
|
|
581
|
+
return `npm install -g ${shortName ? "gezel-cli" : "@bendyline/gezel-cli"}`;
|
|
582
|
+
}
|
|
569
583
|
function incompatibleDaemonCliError(source) {
|
|
570
584
|
const verdict = source instanceof GezelSdkError ? { ...source.cause, systemService: false } : source;
|
|
571
585
|
const service = `the Gezel service${verdict.version ? ` (${verdict.version})` : ""}`;
|
|
572
586
|
if (verdict.code === "client-too-old") {
|
|
573
587
|
return new CliError(
|
|
574
|
-
`This gezel CLI is older than ${service} supports. Update it with
|
|
588
|
+
`This gezel CLI is older than ${service} supports. Update it with \`${cliUpdateCommand()}\`, then try again.`
|
|
575
589
|
);
|
|
576
590
|
}
|
|
577
591
|
if (verdict.code === "machine-engine-role") {
|
|
@@ -1323,6 +1337,12 @@ function describeSubmission(shard) {
|
|
|
1323
1337
|
return { title, body };
|
|
1324
1338
|
}
|
|
1325
1339
|
var execFileAsync = promisify(execFile);
|
|
1340
|
+
var BENCH_RESULT_LABEL = "bench-result";
|
|
1341
|
+
function labelMissing(error) {
|
|
1342
|
+
const { stderr, message } = error ?? {};
|
|
1343
|
+
const text = typeof stderr === "string" && stderr ? stderr : String(message ?? error);
|
|
1344
|
+
return /could not add label/i.test(text) || text.includes(`'${BENCH_RESULT_LABEL}' not found`);
|
|
1345
|
+
}
|
|
1326
1346
|
async function submitBench(file, io, deps = {}) {
|
|
1327
1347
|
const text = await (deps.readFile ?? ((p) => readFile2(p, "utf8")))(file);
|
|
1328
1348
|
let shard;
|
|
@@ -1337,22 +1357,28 @@ async function submitBench(file, io, deps = {}) {
|
|
|
1337
1357
|
throw new CliError(`${file} holds ${shard.runs.length} runs; submit one run per issue.`);
|
|
1338
1358
|
}
|
|
1339
1359
|
const { title, body } = describeSubmission(shard);
|
|
1340
|
-
const params = new URLSearchParams({ title, labels:
|
|
1360
|
+
const params = new URLSearchParams({ title, labels: BENCH_RESULT_LABEL });
|
|
1341
1361
|
const url = `https://github.com/${BENCH_SUBMIT_REPO}/issues/new?${params.toString()}`;
|
|
1342
1362
|
const gh = deps.gh ?? (async (args) => (await execFileAsync("gh", args, { encoding: "utf8" })).stdout);
|
|
1363
|
+
const createIssue = (labeled) => gh([
|
|
1364
|
+
"issue",
|
|
1365
|
+
"create",
|
|
1366
|
+
"--repo",
|
|
1367
|
+
BENCH_SUBMIT_REPO,
|
|
1368
|
+
"--title",
|
|
1369
|
+
title,
|
|
1370
|
+
...labeled ? ["--label", BENCH_RESULT_LABEL] : [],
|
|
1371
|
+
"--body",
|
|
1372
|
+
body
|
|
1373
|
+
]);
|
|
1343
1374
|
try {
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
"--label",
|
|
1352
|
-
"bench-result",
|
|
1353
|
-
"--body",
|
|
1354
|
-
body
|
|
1355
|
-
]);
|
|
1375
|
+
let stdout;
|
|
1376
|
+
try {
|
|
1377
|
+
stdout = await createIssue(true);
|
|
1378
|
+
} catch (error) {
|
|
1379
|
+
if (!labelMissing(error)) throw error;
|
|
1380
|
+
stdout = await createIssue(false);
|
|
1381
|
+
}
|
|
1356
1382
|
const issueUrl = stdout.trim().split("\n").pop() ?? "";
|
|
1357
1383
|
io.out(`Opened ${issueUrl}`);
|
|
1358
1384
|
return { title, body, url, issueUrl };
|
|
@@ -3364,6 +3390,10 @@ async function checkRunReadiness(client, gezelId, env2 = process.env) {
|
|
|
3364
3390
|
})
|
|
3365
3391
|
};
|
|
3366
3392
|
}
|
|
3393
|
+
function canOfferRunSetup(io = process, env2 = process.env) {
|
|
3394
|
+
if (env2.CI) return false;
|
|
3395
|
+
return io.stdin.isTTY === true && io.stderr.isTTY === true;
|
|
3396
|
+
}
|
|
3367
3397
|
function formatRunSetupMessage(input) {
|
|
3368
3398
|
const { provider, engineMissing, pinned, installedIds } = input;
|
|
3369
3399
|
const flag = providerFlag(
|
|
@@ -3634,6 +3664,50 @@ function registerSecretCommands(program2, connect, output = console.log) {
|
|
|
3634
3664
|
});
|
|
3635
3665
|
}
|
|
3636
3666
|
|
|
3667
|
+
// src/start-reuse.ts
|
|
3668
|
+
var SIGN_IN_STATE_TIMEOUT_MS = 3e3;
|
|
3669
|
+
async function startShortfall(runtime, want, deps) {
|
|
3670
|
+
if (want.port !== void 0 && runtime.port !== want.port) return "port";
|
|
3671
|
+
if (!want.web) return null;
|
|
3672
|
+
if (new URL(runtime.baseUrl).protocol !== "http:") return "web";
|
|
3673
|
+
if ((await deps.readWebUiToken()).trim().length === 0) return "web";
|
|
3674
|
+
if (want.accounts && !await requiresAccounts(runtime.baseUrl, deps.fetch ?? fetch)) {
|
|
3675
|
+
return "accounts";
|
|
3676
|
+
}
|
|
3677
|
+
return null;
|
|
3678
|
+
}
|
|
3679
|
+
async function requiresAccounts(baseUrl, fetchImpl) {
|
|
3680
|
+
const controller = new AbortController();
|
|
3681
|
+
const timer = setTimeout(() => controller.abort(), SIGN_IN_STATE_TIMEOUT_MS);
|
|
3682
|
+
timer.unref?.();
|
|
3683
|
+
try {
|
|
3684
|
+
const res = await fetchImpl(`${new URL(baseUrl).origin}/v1/apps/signin/state`, {
|
|
3685
|
+
signal: controller.signal
|
|
3686
|
+
});
|
|
3687
|
+
if (!res.ok) return false;
|
|
3688
|
+
const state = await res.json();
|
|
3689
|
+
return state.accountsRequired === true;
|
|
3690
|
+
} catch {
|
|
3691
|
+
return false;
|
|
3692
|
+
} finally {
|
|
3693
|
+
clearTimeout(timer);
|
|
3694
|
+
}
|
|
3695
|
+
}
|
|
3696
|
+
function startShortfallMessage(shortfall, running, want) {
|
|
3697
|
+
const has = shortfall === "port" ? `on port ${running.port}` : shortfall === "web" ? "without the web UI" : "with the web UI but without accounts";
|
|
3698
|
+
const retry = ["gezel start"];
|
|
3699
|
+
if (want.port !== void 0) retry.push(`--port ${want.port}`);
|
|
3700
|
+
if (want.web) retry.push("--web");
|
|
3701
|
+
if (want.accounts) retry.push("--accounts");
|
|
3702
|
+
retry.push("--restart");
|
|
3703
|
+
return `gezeld is already running for this home ${has} (pid ${running.pid}).
|
|
3704
|
+
Restart it ${startRestartWanted(want)} with \`${retry.join(" ")}\`, or stop it first with \`gezel stop\`.`;
|
|
3705
|
+
}
|
|
3706
|
+
function startRestartWanted(want) {
|
|
3707
|
+
if (want.accounts) return "with the web UI and accounts";
|
|
3708
|
+
return want.web ? "with the web UI" : `on port ${want.port}`;
|
|
3709
|
+
}
|
|
3710
|
+
|
|
3637
3711
|
// src/storage-format.ts
|
|
3638
3712
|
function formatBytes2(bytes) {
|
|
3639
3713
|
if (bytes >= 1024 ** 3) return `${(bytes / 1024 ** 3).toFixed(1)} GB`;
|
|
@@ -4135,18 +4209,18 @@ program.command("start").description("Start the Gezel daemon (no-op if already r
|
|
|
4135
4209
|
if (port !== void 0 || opts.web) {
|
|
4136
4210
|
const runtime = await readRuntime2();
|
|
4137
4211
|
const running = runtime && isProcessAlive2(runtime.pid) ? runtime : null;
|
|
4138
|
-
const
|
|
4139
|
-
|
|
4140
|
-
|
|
4212
|
+
const want = {
|
|
4213
|
+
port,
|
|
4214
|
+
web: opts.web === true,
|
|
4215
|
+
accounts: opts.web === true && opts.accounts === true
|
|
4216
|
+
};
|
|
4217
|
+
const shortfall = running ? await startShortfall(running, want, { readWebUiToken }) : null;
|
|
4218
|
+
const reuse = running !== null && shortfall === null;
|
|
4219
|
+
if (running && shortfall) {
|
|
4141
4220
|
if (!opts.restart) {
|
|
4142
|
-
|
|
4143
|
-
if (opts.web) retry.push("--web");
|
|
4144
|
-
throw new CliError(
|
|
4145
|
-
`gezeld is already running for this home ${opts.web ? "without the web UI" : `on port ${running.port}`} (pid ${running.pid}).
|
|
4146
|
-
Restart it ${wanted} with \`${[...retry, "--restart"].join(" ")}\`, or stop it first with \`gezel stop\`.`
|
|
4147
|
-
);
|
|
4221
|
+
throw new CliError(startShortfallMessage(shortfall, running, want));
|
|
4148
4222
|
}
|
|
4149
|
-
console.error(`Restarting gezeld (pid ${running.pid}) ${
|
|
4223
|
+
console.error(`Restarting gezeld (pid ${running.pid}) ${startRestartWanted(want)}\u2026`);
|
|
4150
4224
|
if (!await stopDaemonPid(running.pid)) {
|
|
4151
4225
|
throw new CliError(`failed to confirm gezeld pid=${running.pid} stopped`);
|
|
4152
4226
|
}
|
|
@@ -4156,7 +4230,7 @@ Restart it ${wanted} with \`${[...retry, "--restart"].join(" ")}\`, or stop it f
|
|
|
4156
4230
|
daemonEntry: entry,
|
|
4157
4231
|
detached: true,
|
|
4158
4232
|
env: spawnEnv,
|
|
4159
|
-
// Never adopt a daemon that lacks the requested port or
|
|
4233
|
+
// Never adopt a daemon that lacks the requested port, transport or accounts.
|
|
4160
4234
|
// A forced spawn accepts only its own process, so losing a race
|
|
4161
4235
|
// fails here instead of reporting someone else's daemon.
|
|
4162
4236
|
forceSpawn: !reuse,
|
|
@@ -4183,14 +4257,10 @@ Restart it ${wanted} with \`${[...retry, "--restart"].join(" ")}\`, or stop it f
|
|
|
4183
4257
|
console.log(`gezeld running (version ${health.version})`);
|
|
4184
4258
|
}
|
|
4185
4259
|
);
|
|
4186
|
-
async function
|
|
4187
|
-
if (want.port !== void 0 && runtime.port !== want.port) return false;
|
|
4188
|
-
if (!want.web) return true;
|
|
4189
|
-
if (new URL(runtime.baseUrl).protocol !== "http:") return false;
|
|
4260
|
+
async function readWebUiToken() {
|
|
4190
4261
|
const { readFile: readFile5 } = await import("fs/promises");
|
|
4191
4262
|
const { gezelPaths: gezelPaths2 } = await import("@bendyline/gezel/paths");
|
|
4192
|
-
|
|
4193
|
-
return token.trim().length > 0;
|
|
4263
|
+
return readFile5(gezelPaths2().runtime.webUiToken, "utf8").catch(() => "");
|
|
4194
4264
|
}
|
|
4195
4265
|
async function printAccountsWebUrl(client, baseUrl, open) {
|
|
4196
4266
|
const origin = new URL(baseUrl).origin;
|
|
@@ -4522,7 +4592,9 @@ Examples:
|
|
|
4522
4592
|
gezel run - < prompt.txt
|
|
4523
4593
|
|
|
4524
4594
|
A sole - reads UTF-8 stdin to EOF. Empty input is rejected.
|
|
4525
|
-
Replies go to stdout; diagnostics go to stderr
|
|
4595
|
+
Replies go to stdout; diagnostics go to stderr.
|
|
4596
|
+
With no model set up yet, a run in a terminal first offers to download one,
|
|
4597
|
+
then runs the prompt.`
|
|
4526
4598
|
).action(async (promptParts, opts) => {
|
|
4527
4599
|
const prompt = await resolveRunPrompt(promptParts);
|
|
4528
4600
|
const previousLogOutput = getLogOutput2();
|
|
@@ -4543,7 +4615,25 @@ Replies go to stdout; diagnostics go to stderr.`
|
|
|
4543
4615
|
const { client } = conn;
|
|
4544
4616
|
const projectId = await resolveRunProject(client, cliGlobals());
|
|
4545
4617
|
const gezelId = opts.gezel ? await resolveRunGezel(client, opts.gezel) : await ensureCliProjectLead(client, projectId);
|
|
4546
|
-
|
|
4618
|
+
let readiness = await checkRunReadiness(client, gezelId);
|
|
4619
|
+
if (!readiness.ready && canOfferRunSetup()) {
|
|
4620
|
+
const tuiModule = "../tui/index.js";
|
|
4621
|
+
const { launchRunSetup } = await import(tuiModule);
|
|
4622
|
+
const runLogLevel = getLogLevel2();
|
|
4623
|
+
if (!process.env.GEZEL_LOG_LEVEL) setLogLevel2("error");
|
|
4624
|
+
let finished;
|
|
4625
|
+
try {
|
|
4626
|
+
finished = await launchRunSetup({ client });
|
|
4627
|
+
} finally {
|
|
4628
|
+
setLogLevel2(runLogLevel);
|
|
4629
|
+
}
|
|
4630
|
+
if (!finished) {
|
|
4631
|
+
console.error("Setup stopped. Your request was not run.");
|
|
4632
|
+
process.exitCode = 130;
|
|
4633
|
+
return;
|
|
4634
|
+
}
|
|
4635
|
+
readiness = await checkRunReadiness(client, gezelId);
|
|
4636
|
+
}
|
|
4547
4637
|
if (!readiness.ready) {
|
|
4548
4638
|
console.error(readiness.message);
|
|
4549
4639
|
process.exitCode = 1;
|
|
@@ -34,6 +34,7 @@ import { createHash, randomUUID } from "crypto";
|
|
|
34
34
|
import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
|
|
35
35
|
import { homedir } from "os";
|
|
36
36
|
import { basename, dirname, join, resolve } from "path";
|
|
37
|
+
import { fileURLToPath } from "url";
|
|
37
38
|
import {
|
|
38
39
|
evaluateApiCompat,
|
|
39
40
|
getLogLevel,
|
|
@@ -51,6 +52,7 @@ import {
|
|
|
51
52
|
authorizeLocalOwner
|
|
52
53
|
} from "@bendyline/gezel-app-sdk";
|
|
53
54
|
import {
|
|
55
|
+
DaemonInAnotherNamespaceError,
|
|
54
56
|
GezelApiError,
|
|
55
57
|
GezelClient,
|
|
56
58
|
LiveDaemonUnhealthyError,
|
package/dist/tui/index.js
CHANGED
|
@@ -17,6 +17,7 @@ import { createHash, randomUUID } from "crypto";
|
|
|
17
17
|
import { chmod, mkdir, readFile, realpath, rm, writeFile } from "fs/promises";
|
|
18
18
|
import { homedir } from "os";
|
|
19
19
|
import { basename, dirname, join, resolve } from "path";
|
|
20
|
+
import { fileURLToPath } from "url";
|
|
20
21
|
import {
|
|
21
22
|
evaluateApiCompat,
|
|
22
23
|
getLogLevel,
|
|
@@ -34,6 +35,7 @@ import {
|
|
|
34
35
|
authorizeLocalOwner
|
|
35
36
|
} from "@bendyline/gezel-app-sdk";
|
|
36
37
|
import {
|
|
38
|
+
DaemonInAnotherNamespaceError,
|
|
37
39
|
GezelApiError,
|
|
38
40
|
GezelClient,
|
|
39
41
|
LiveDaemonUnhealthyError,
|
|
@@ -4759,8 +4761,17 @@ async function settledFirstRunConfig(client, options = {}) {
|
|
|
4759
4761
|
// src/tui/components/BootstrapGate.tsx
|
|
4760
4762
|
import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
4761
4763
|
var MAX_ALTERNATIVE_MODELS = 6;
|
|
4764
|
+
var SKIP_HINTS = {
|
|
4765
|
+
tui: "open the TUI without a local model",
|
|
4766
|
+
run: "stop without running your request"
|
|
4767
|
+
};
|
|
4768
|
+
var CONTINUE_OPTIONS = {
|
|
4769
|
+
tui: { label: "Continue to Gezel", hint: "configure this later" },
|
|
4770
|
+
run: { label: "Stop here", hint: "set this up later" }
|
|
4771
|
+
};
|
|
4762
4772
|
function BootstrapGate(props) {
|
|
4763
4773
|
const { client, children } = props;
|
|
4774
|
+
const nextStep = props.nextStep ?? "tui";
|
|
4764
4775
|
const { exit } = useApp2();
|
|
4765
4776
|
const [screen, setScreen] = useState6({
|
|
4766
4777
|
kind: "loading",
|
|
@@ -5113,7 +5124,7 @@ function BootstrapGate(props) {
|
|
|
5113
5124
|
hint: `${formatDownloadSize(model.approxSizeBytes)} \xB7 ${fitLabel(model.fit)}`,
|
|
5114
5125
|
value: `chat:${model.id}`
|
|
5115
5126
|
})),
|
|
5116
|
-
{ label: "Not now", hint:
|
|
5127
|
+
{ label: "Not now", hint: SKIP_HINTS[nextStep], value: "skip" }
|
|
5117
5128
|
];
|
|
5118
5129
|
return /* @__PURE__ */ jsxs7(
|
|
5119
5130
|
BootstrapFrame,
|
|
@@ -5154,7 +5165,7 @@ function BootstrapGate(props) {
|
|
|
5154
5165
|
{
|
|
5155
5166
|
options: [
|
|
5156
5167
|
...screen.retry ? [{ label: "Try again", hint: "resume setup", value: "retry" }] : [],
|
|
5157
|
-
{
|
|
5168
|
+
{ ...CONTINUE_OPTIONS[nextStep], value: "continue" }
|
|
5158
5169
|
],
|
|
5159
5170
|
onSelect: (value) => {
|
|
5160
5171
|
if (value === "retry") screen.retry?.();
|
|
@@ -5164,6 +5175,15 @@ function BootstrapGate(props) {
|
|
|
5164
5175
|
)
|
|
5165
5176
|
] });
|
|
5166
5177
|
}
|
|
5178
|
+
function ExitWhenReady(props) {
|
|
5179
|
+
const { onReady } = props;
|
|
5180
|
+
const { exit } = useApp2();
|
|
5181
|
+
useEffect5(() => {
|
|
5182
|
+
onReady();
|
|
5183
|
+
exit();
|
|
5184
|
+
}, [exit, onReady]);
|
|
5185
|
+
return null;
|
|
5186
|
+
}
|
|
5167
5187
|
function BootstrapFrame(props) {
|
|
5168
5188
|
return /* @__PURE__ */ jsxs7(Box7, { flexDirection: "column", paddingX: 1, paddingY: 1, children: [
|
|
5169
5189
|
/* @__PURE__ */ jsx6(Text7, { bold: true, color: "cyan", children: "gezel \xB7 first-time setup" }),
|
|
@@ -5539,6 +5559,23 @@ async function launchTui(opts) {
|
|
|
5539
5559
|
await diagnostics.stop();
|
|
5540
5560
|
}
|
|
5541
5561
|
}
|
|
5562
|
+
async function launchRunSetup(opts) {
|
|
5563
|
+
let finished = false;
|
|
5564
|
+
const instance = render(
|
|
5565
|
+
/* @__PURE__ */ jsx7(BootstrapGate, { client: opts.client, nextStep: "run", children: /* @__PURE__ */ jsx7(
|
|
5566
|
+
ExitWhenReady,
|
|
5567
|
+
{
|
|
5568
|
+
onReady: () => {
|
|
5569
|
+
finished = true;
|
|
5570
|
+
}
|
|
5571
|
+
}
|
|
5572
|
+
) }),
|
|
5573
|
+
{ stdout: process.stderr, exitOnCtrlC: false }
|
|
5574
|
+
);
|
|
5575
|
+
await instance.waitUntilExit();
|
|
5576
|
+
return finished;
|
|
5577
|
+
}
|
|
5542
5578
|
export {
|
|
5579
|
+
launchRunSetup,
|
|
5543
5580
|
launchTui
|
|
5544
5581
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bendyline/gezel-cli",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.13",
|
|
4
4
|
"description": "The gezel command-line tool: chat with your gezels, run craftbooks, and manage local models from the terminal.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"keywords": [
|
|
@@ -44,12 +44,12 @@
|
|
|
44
44
|
"!dist/**/*.map"
|
|
45
45
|
],
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@bendyline/gezel": "1.2.
|
|
48
|
-
"@bendyline/gezel-app-sdk": "1.1.
|
|
49
|
-
"@bendyline/gezel-catalog": "1.2.
|
|
50
|
-
"@bendyline/gezel-client": "1.2.
|
|
47
|
+
"@bendyline/gezel": "1.2.13",
|
|
48
|
+
"@bendyline/gezel-app-sdk": "1.1.13",
|
|
49
|
+
"@bendyline/gezel-catalog": "1.2.13",
|
|
50
|
+
"@bendyline/gezel-client": "1.2.13",
|
|
51
51
|
"@bendyline/gezel-knowledge": "1.2.10",
|
|
52
|
-
"@bendyline/gezel-service": "1.2.
|
|
52
|
+
"@bendyline/gezel-service": "1.2.13",
|
|
53
53
|
"@bendyline/squisq": "2.13.10",
|
|
54
54
|
"@bendyline/squisq-formats": "2.8.12",
|
|
55
55
|
"@bendyline/squisq-react": "2.12.22",
|