@conveno/cli 0.2.0-rc.4 → 0.2.0-rc.6
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 +28 -29
- package/dist/acp-3xehqLdo.js +82 -0
- package/dist/args-D9T-6TDw.js +315 -0
- package/dist/bin.js +2 -2
- package/dist/{ctx-CDLE-2f2.js → ctx-tYftvhz_.js} +2 -3
- package/dist/daemon.js +361 -1203
- package/dist/daemonError-CdLataBW.js +66 -0
- package/dist/{dist-CuStS_nO.js → dist-BAlMjYqQ.js} +39 -148
- package/dist/{dist-DUqXHTRg.js → dist-BTLBO1Rp.js} +373 -1130
- package/dist/{dist-CiE50AoI.js → dist-BYVibI3a.js} +4 -17
- package/dist/{dist-CfwMkSGH.js → dist-CNyzLyZh.js} +161 -1554
- package/dist/{dist-BmpWfYuM.js → dist-DIAtMDWW.js} +1 -1
- package/dist/dist-LkcRvVjE.js +449 -0
- package/dist/{doctor-Bckon1ju.js → doctor-DjwXJvKw.js} +26 -94
- package/dist/fmt-C2SsP5Y0.js +96 -0
- package/dist/{hook-DUMp43Xn.js → hook-BGJc4PHG.js} +2 -4
- package/dist/hook-entry-BWWJS7n3.js +2622 -0
- package/dist/hook-entry-rDISaMgP.js +1 -0
- package/dist/main-CRw-fISR.js +971 -0
- package/dist/pick-B-18E4Mx.js +9 -0
- package/dist/{run-BEhIahUS.js → run-Yi48fiJN.js} +286 -1667
- package/dist/{runtime-BS-SUGVR.js → runtime-DyknkzAS.js} +136 -209
- package/dist/sidecar-CTKxOMie.js +98 -0
- package/dist/watch-CfYanJvt.js +109 -0
- package/package.json +15 -15
- package/dist/acp-Bs2yS0Qg.js +0 -142
- package/dist/args-DEYV4Ran.js +0 -517
- package/dist/dist-DcmKjrmu.js +0 -271
- package/dist/hook-entry-C-HTnddc.js +0 -1289
- package/dist/hook-entry-DP6eq6qr.js +0 -1
- package/dist/main-ByyF0srt.js +0 -1448
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { t as
|
|
3
|
-
import {
|
|
4
|
-
import { n as connectOpts, t as adapterEnv } from "./ctx-
|
|
1
|
+
import { D as completeLogin, Dt as resolveAcpProgram, E as compatStatus, H as fetchAccountStatus, Kt as writeSettings, M as dataPaths, U as findOnPath, bt as readSettings, d as SPAWN_TABLE, et as logoutAccount, g as adapterNpxCommand, gt as readAccountTokens, h as adapterInstallCommand, m as acpOverrideVar, n as AccountError, pt as pollDeviceCode, qt as CLI_KINDS, ut as pinnedAdapter, wt as requestDeviceCode } from "./dist-BTLBO1Rp.js";
|
|
2
|
+
import { a as fail, c as plural, d as warnBlock, i as errorBlock, l as seconds, n as cmd, o as localStamp, r as columns, s as plainError, t as closest, u as tilde } from "./fmt-C2SsP5Y0.js";
|
|
3
|
+
import { i as parseFlags, t as COMMANDS } from "./args-D9T-6TDw.js";
|
|
4
|
+
import { n as connectOpts, t as adapterEnv } from "./ctx-tYftvhz_.js";
|
|
5
|
+
import { t as daemonProblem } from "./daemonError-CdLataBW.js";
|
|
5
6
|
import { basename, dirname, join } from "node:path";
|
|
6
|
-
import { chmod, mkdir, open, readFile, readdir, realpath, rename as rename$1, rm, stat, writeFile } from "node:fs/promises";
|
|
7
|
-
import { createHash, randomBytes } from "node:crypto";
|
|
8
7
|
import { spawn } from "node:child_process";
|
|
8
|
+
import { chmod, mkdir, open, readFile, readdir, realpath, rename as rename$1, rm, rmdir, stat, writeFile } from "node:fs/promises";
|
|
9
|
+
import { createHash, randomBytes } from "node:crypto";
|
|
9
10
|
// src/account.ts
|
|
10
11
|
const accountIo = (ctx, io) => ({
|
|
11
12
|
apiBase: ctx.env.CONVENO_API_URL || "https://api.conveno.dev",
|
|
@@ -139,69 +140,6 @@ async function runAccount(ctx, argv, io = {}) {
|
|
|
139
140
|
return accountFailure(ctx, e, "Could not read your account");
|
|
140
141
|
}
|
|
141
142
|
}
|
|
142
|
-
// src/daemonError.ts
|
|
143
|
-
/**
|
|
144
|
-
* Explain a failed connection to the daemon, with a fix that fits the cause. `start` is the command
|
|
145
|
-
* that fixes a daemon that is merely not running.
|
|
146
|
-
*/
|
|
147
|
-
function daemonProblem(t, e) {
|
|
148
|
-
const why = plainError(e);
|
|
149
|
-
const kind = e instanceof ClientError ? e.kind : void 0;
|
|
150
|
-
const start = cmd(t, "conveno daemon start");
|
|
151
|
-
const status = cmd(t, "conveno daemon status");
|
|
152
|
-
switch (kind) {
|
|
153
|
-
case "socket_path_too_long": return {
|
|
154
|
-
why,
|
|
155
|
-
fix: `Set ${cmd(t, "XDG_RUNTIME_DIR")} to a shorter directory, then run ${start}. Use the same value everywhere you run Conveno and your AI CLIs.`,
|
|
156
|
-
notRunning: false
|
|
157
|
-
};
|
|
158
|
-
case "permission": return {
|
|
159
|
-
why,
|
|
160
|
-
fix: `Check who owns the socket named above. If it is not yours, remove it, then run ${start}.`,
|
|
161
|
-
notRunning: false
|
|
162
|
-
};
|
|
163
|
-
case "not_daemon": return {
|
|
164
|
-
why,
|
|
165
|
-
fix: `Stop the process that owns the socket, or remove the socket, then run ${start}.`,
|
|
166
|
-
notRunning: false
|
|
167
|
-
};
|
|
168
|
-
case "token_empty": return {
|
|
169
|
-
why,
|
|
170
|
-
fix: `Run ${cmd(t, "conveno daemon stop")}, then ${start}.`,
|
|
171
|
-
notRunning: false
|
|
172
|
-
};
|
|
173
|
-
case "daemon_missing": return {
|
|
174
|
-
why,
|
|
175
|
-
fix: `Reinstall Conveno (${cmd(t, "npm install -g @conveno/cli")}), then run ${start}.`,
|
|
176
|
-
notRunning: false
|
|
177
|
-
};
|
|
178
|
-
case "start_timeout": return {
|
|
179
|
-
why,
|
|
180
|
-
fix: `Run ${status} to see whether it came up, or ${cmd(t, "conveno doctor")} to check the install.`,
|
|
181
|
-
notRunning: false
|
|
182
|
-
};
|
|
183
|
-
case "start_exited": return {
|
|
184
|
-
why,
|
|
185
|
-
fix: `Fix what its output above shows, then run ${start}. If it is unclear, report it with that output.`,
|
|
186
|
-
notRunning: false
|
|
187
|
-
};
|
|
188
|
-
case "connection": return {
|
|
189
|
-
why,
|
|
190
|
-
fix: `Run ${status}, then try again.`,
|
|
191
|
-
notRunning: false
|
|
192
|
-
};
|
|
193
|
-
case "no_daemon": return {
|
|
194
|
-
why,
|
|
195
|
-
fix: `Run ${start}. It also starts when a CLI opens the Conveno MCP server.`,
|
|
196
|
-
notRunning: true
|
|
197
|
-
};
|
|
198
|
-
default: return {
|
|
199
|
-
why,
|
|
200
|
-
fix: `Run ${cmd(t, "conveno doctor")} to check the install, then try again.`,
|
|
201
|
-
notRunning: false
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
143
|
const PAIR_TIMEOUT_MS = 3e5;
|
|
206
144
|
/**
|
|
207
145
|
* Run `run` with a daemon client. Commands that change something start the daemon when needed;
|
|
@@ -215,7 +153,7 @@ async function withClient(ctx, autoStart, run) {
|
|
|
215
153
|
} catch (e) {
|
|
216
154
|
const problem = daemonProblem(t, e);
|
|
217
155
|
return fail(ctx, {
|
|
218
|
-
what: "
|
|
156
|
+
what: "Conveno's background service cannot be reached",
|
|
219
157
|
detail: [problem.why],
|
|
220
158
|
fix: problem.fix,
|
|
221
159
|
exit: 1,
|
|
@@ -226,7 +164,7 @@ async function withClient(ctx, autoStart, run) {
|
|
|
226
164
|
return await run(client);
|
|
227
165
|
} catch (e) {
|
|
228
166
|
return fail(ctx, {
|
|
229
|
-
what: "The
|
|
167
|
+
what: "The background service refused the request",
|
|
230
168
|
detail: [plainError(e)],
|
|
231
169
|
fix: `Run ${cmd(t, "conveno relay status")} to see the relay and login state.`,
|
|
232
170
|
exit: 1,
|
|
@@ -567,7 +505,7 @@ function acpDoctorLines(ctx, clis) {
|
|
|
567
505
|
const table = rows.map((r) => [` ${r.command ? t.status("ok") : t.glyph("offline")} ${r.cli}`, r.command ? r.onDemand ? `ready: ${r.command} (on demand; the first start downloads the package, which can take minutes)` : r.adapter?.startsWith("override:") ? `ready: ${r.command} (${acpOverrideVar(r.cli)})` : `ready: ${r.command}` : r.noNpx ? `npx was not found on PATH. Install Node.js, or install the ACP adapter: ${r.install}` : r.install ? `to enable, install the ACP adapter: ${r.install} (or run conveno init to fetch it with npx)` : q("its ACP server was not found on PATH")]);
|
|
568
506
|
return [
|
|
569
507
|
"",
|
|
570
|
-
`ACP workers ${q("(conveno spawn <cli>
|
|
508
|
+
`ACP workers ${q("(conveno spawn <cli>)")}`,
|
|
571
509
|
...columns(table),
|
|
572
510
|
...rows.some((r) => r.install || r.onDemand) ? [q("Adapters are third-party npm packages, fetched by npx on first use. They use the CLI's own sign-in.")] : []
|
|
573
511
|
];
|
|
@@ -621,7 +559,7 @@ async function offerAcpAdapters(ctx, opts) {
|
|
|
621
559
|
if (missing.length === 0) return;
|
|
622
560
|
if (readSettings(path).acpAdapterNpx !== void 0) return;
|
|
623
561
|
const who = missing.map((m) => m.cli).join(" and ");
|
|
624
|
-
ctx.out(`\n${t.bold("ACP workers")} let conveno spawn <cli>
|
|
562
|
+
ctx.out(`\n${t.bold("ACP workers")} let conveno spawn <cli> drive a worker over the Agent Client Protocol.\n ${who} ${missing.length > 1 ? "need" : "needs"} a separate adapter for that. Adapters are third-party npm packages\n (Apache-2.0). Conveno does not bundle them; npx would download these on first use:
|
|
625
563
|
${missing.map((m) => ` ${pinnedAdapter(m.pkg) ?? m.pkg}\n`).join("")}`);
|
|
626
564
|
if (!ctx.interactive || opts.yes) {
|
|
627
565
|
ctx.out(`${t.status("info")} Not asked. Run ${cmd(t, "conveno init --acp-adapters")} to allow npx, or install by hand:\n`);
|
|
@@ -941,8 +879,10 @@ async function applyChanges(ctx, items, opts = {}) {
|
|
|
941
879
|
}
|
|
942
880
|
if (!done) {
|
|
943
881
|
await currentIfUnchanged(change);
|
|
944
|
-
if (change.deleteFile)
|
|
945
|
-
|
|
882
|
+
if (change.deleteFile) {
|
|
883
|
+
await io.rm(change.path);
|
|
884
|
+
if (change.pruneEmptyDir) await rmdir(dirname(change.path)).catch(() => void 0);
|
|
885
|
+
} else await writeAtomic(change.path, change.after, io);
|
|
946
886
|
}
|
|
947
887
|
how.push({
|
|
948
888
|
cli,
|
|
@@ -1103,8 +1043,8 @@ function printDetections(ctx, found) {
|
|
|
1103
1043
|
ctx.out(`${columns(rows).join("\n")}\n\n`);
|
|
1104
1044
|
}
|
|
1105
1045
|
/** Collect plans from installed adapters. Returns failures instead of throwing. */
|
|
1106
|
-
async function collectPlans(ctx, found, which, baseline
|
|
1107
|
-
const env = adapterEnv(ctx
|
|
1046
|
+
async function collectPlans(ctx, found, which, baseline) {
|
|
1047
|
+
const env = adapterEnv(ctx);
|
|
1108
1048
|
const items = [];
|
|
1109
1049
|
const failures = [];
|
|
1110
1050
|
for (const { adapter, detection } of found) try {
|
|
@@ -1228,8 +1168,7 @@ async function initSetup(ctx, argv, outcome) {
|
|
|
1228
1168
|
exit: 1,
|
|
1229
1169
|
ref: "e_no_cli"
|
|
1230
1170
|
});
|
|
1231
|
-
const
|
|
1232
|
-
const { items, failures } = await collectPlans(ctx, installed, "plan", void 0, { permissionRelay: withRelay });
|
|
1171
|
+
const { items, failures } = await collectPlans(ctx, installed, "plan");
|
|
1233
1172
|
if (failures.length > 0) {
|
|
1234
1173
|
reportFailures(ctx, failures, "conveno init --cli <others>");
|
|
1235
1174
|
return 1;
|
|
@@ -1249,7 +1188,7 @@ async function initSetup(ctx, argv, outcome) {
|
|
|
1249
1188
|
const result = await confirmAndApply(ctx, items, {
|
|
1250
1189
|
yes: values.yes === true,
|
|
1251
1190
|
verb: "Apply",
|
|
1252
|
-
rerun:
|
|
1191
|
+
rerun: "conveno init"
|
|
1253
1192
|
});
|
|
1254
1193
|
if ("exit" in result) return result.exit;
|
|
1255
1194
|
const byCli = /* @__PURE__ */ new Map();
|
|
@@ -1314,7 +1253,8 @@ async function inspect(ctx, adapter) {
|
|
|
1314
1253
|
adapter,
|
|
1315
1254
|
detection,
|
|
1316
1255
|
mcp: partState(changes, "mcp"),
|
|
1317
|
-
hooks: hasHooks ? partState(changes, "hooks") : null
|
|
1256
|
+
hooks: hasHooks ? partState(changes, "hooks") : null,
|
|
1257
|
+
changes
|
|
1318
1258
|
};
|
|
1319
1259
|
} catch (e) {
|
|
1320
1260
|
return {
|
|
@@ -1373,7 +1313,7 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1373
1313
|
try {
|
|
1374
1314
|
const client = await ctx.connect(connectOpts(ctx, false));
|
|
1375
1315
|
try {
|
|
1376
|
-
const { sessions } = await client["session.list"]({
|
|
1316
|
+
const { sessions } = await client["session.list"]({});
|
|
1377
1317
|
daemonLine = [` ${t.status("ok")} daemon`, `running, ${plural(sessions.length, "session")}`];
|
|
1378
1318
|
ok++;
|
|
1379
1319
|
} finally {
|
|
@@ -1384,12 +1324,12 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1384
1324
|
if (problem.notRunning) {
|
|
1385
1325
|
daemonLine = [` ${t.status("warn")} daemon`, "not running"];
|
|
1386
1326
|
warnings++;
|
|
1387
|
-
notes.push(warnBlock(t, "
|
|
1327
|
+
notes.push(warnBlock(t, "Conveno's background service is not running.", problem.fix, problem.why));
|
|
1388
1328
|
} else {
|
|
1389
1329
|
daemonLine = [` ${t.status("error")} daemon`, "cannot be reached"];
|
|
1390
1330
|
problems++;
|
|
1391
1331
|
notes.push(errorBlock(t, {
|
|
1392
|
-
what: "
|
|
1332
|
+
what: "Conveno's background service cannot be reached",
|
|
1393
1333
|
detail: [problem.why],
|
|
1394
1334
|
fix: problem.fix,
|
|
1395
1335
|
exit: 1,
|
|
@@ -1431,7 +1371,7 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1431
1371
|
const good = r.mcp === "ok" && (r.hooks === null || r.hooks === "ok") && !r.planError;
|
|
1432
1372
|
const compat = compatStatus(adapter.cli, detection.version, ctx.compat);
|
|
1433
1373
|
const tiers = activeTiers(r);
|
|
1434
|
-
let note = tiers.includes("idle wake") ? "
|
|
1374
|
+
let note = tiers.includes("idle wake") ? "wakes idle sessions" : tiers.includes("end of turn") ? "wakes at the end of a turn, no idle wake" : tiers.includes("next turn") ? "delivered at the next prompt" : "read through the inbox tool";
|
|
1435
1375
|
if (!good) note = r.planError ? "config could not be read" : r.mcp === "outdated" || r.hooks === "outdated" ? "needs an update" : "not fully configured";
|
|
1436
1376
|
if (compat.kind === "older") note = `older than the minimum ${compat.minimum}`;
|
|
1437
1377
|
else if (compat.kind === "newer" && good) note = `newer than tested (${compat.verified})`;
|
|
@@ -1473,16 +1413,8 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1473
1413
|
}
|
|
1474
1414
|
}
|
|
1475
1415
|
ctx.out(`${columns(table).join("\n")}\n`);
|
|
1476
|
-
if (rows.some((r) => r.detection.installed && activeTiers(r).some((t) => t !== "next turn" && t !== "inbox"))) ctx.out(`${q("End of turn and idle wake apply to sessions in auto mode; see conveno auto.")}\n`);
|
|
1477
1416
|
const acpLines = acpDoctorLines(ctx, rows.filter((r) => r.detection.installed).map((r) => r.adapter.cli));
|
|
1478
1417
|
if (acpLines.length > 0) ctx.out(`${acpLines.join("\n")}\n`);
|
|
1479
|
-
const relayRows = [];
|
|
1480
|
-
for (const r of rows) {
|
|
1481
|
-
if (!r.detection.installed || !r.adapter.permissionHookInstalled || r.planError) continue;
|
|
1482
|
-
const installed = await r.adapter.permissionHookInstalled(adapterEnv(ctx)).catch(() => false);
|
|
1483
|
-
relayRows.push([` ${r.adapter.cli}`, q(installed ? "permission relay: hook installed (off until turned on per session)" : "permission relay: not installed (optional)")]);
|
|
1484
|
-
}
|
|
1485
|
-
if (relayRows.length > 0) ctx.out(`\n${columns(relayRows).join("\n")}\n`);
|
|
1486
1418
|
if (!rows.some((r) => r.detection.installed)) {
|
|
1487
1419
|
notes.push(warnBlock(t, "No supported AI coding CLI was found on PATH.", "Install Claude Code, Codex CLI or OpenCode, then run conveno init."));
|
|
1488
1420
|
warnings++;
|
|
@@ -1491,4 +1423,4 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1491
1423
|
ctx.out(`\n${ok} ok, ${plural(warnings, "warning")}, ${plural(problems, "problem")}\n`);
|
|
1492
1424
|
return problems > 0 ? 1 : 0;
|
|
1493
1425
|
}
|
|
1494
|
-
export { runLogout as
|
|
1426
|
+
export { runLogout as S, runDevices as _, detectAll as a, runAccount as b, staleFailure as c, listManifests as d, markRestored as f, PAIR_TIMEOUT_MS as g, unifiedDiff as h, confirmAndApply as i, StaleError as l, restoreEntry as m, runDoctor as n, reportFailures as o, previewRestore as p, collectPlans as r, runInit as s, inspect as t, applyChanges as u, runRelay as v, runLogin as x, openInBrowser as y };
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// src/fmt.ts
|
|
2
|
+
/** Shorten the home directory to `~`. */
|
|
3
|
+
function tilde(path, home) {
|
|
4
|
+
if (path === home) return "~";
|
|
5
|
+
for (const sep of ["/", "\\"]) if (path.startsWith(home + sep)) return `~${sep}${path.slice(home.length + 1)}`;
|
|
6
|
+
return path;
|
|
7
|
+
}
|
|
8
|
+
/** Length of a string without ANSI escapes. */
|
|
9
|
+
const visibleLength = (s) => s.replace(/\u001b\[[0-9;]*m/g, "").length;
|
|
10
|
+
const padEnd = (s, width) => s + " ".repeat(Math.max(0, width - visibleLength(s)));
|
|
11
|
+
/** Pad every column to its widest cell. The last column is left unpadded. */
|
|
12
|
+
function columns(rows, gap = 2) {
|
|
13
|
+
const widths = [];
|
|
14
|
+
for (const row of rows) row.forEach((cell, i) => {
|
|
15
|
+
widths[i] = Math.max(widths[i] ?? 0, visibleLength(cell));
|
|
16
|
+
});
|
|
17
|
+
return rows.map((row) => row.map((cell, i) => i === row.length - 1 ? cell : padEnd(cell, (widths[i] ?? 0) + gap)).join("").trimEnd());
|
|
18
|
+
}
|
|
19
|
+
const plural = (n, one, many = `${one}s`) => `${n} ${n === 1 ? one : many}`;
|
|
20
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
21
|
+
/** `2026-11-27 14:02:11` in the machine's local time. */
|
|
22
|
+
function localStamp(iso) {
|
|
23
|
+
const d = new Date(iso);
|
|
24
|
+
if (Number.isNaN(d.getTime())) return iso;
|
|
25
|
+
return `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())} ${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
|
|
26
|
+
}
|
|
27
|
+
/** `1.2s` between two times. */
|
|
28
|
+
const seconds = (from, to) => `${(Math.max(0, to.getTime() - from.getTime()) / 1e3).toFixed(1)}s`;
|
|
29
|
+
function levenshtein(a, b) {
|
|
30
|
+
let prev = Array.from({ length: b.length + 1 }, (_, i) => i);
|
|
31
|
+
for (let i = 1; i <= a.length; i++) {
|
|
32
|
+
const row = [i];
|
|
33
|
+
for (let j = 1; j <= b.length; j++) row[j] = Math.min(row[j - 1] + 1, prev[j] + 1, prev[j - 1] + (a[i - 1] === b[j - 1] ? 0 : 1));
|
|
34
|
+
prev = row;
|
|
35
|
+
}
|
|
36
|
+
return prev[b.length];
|
|
37
|
+
}
|
|
38
|
+
/** The closest candidate within two edits, or undefined. */
|
|
39
|
+
function closest(word, candidates) {
|
|
40
|
+
let best;
|
|
41
|
+
let bestDistance = 3;
|
|
42
|
+
for (const c of candidates) {
|
|
43
|
+
const d = levenshtein(word.toLowerCase(), c.toLowerCase());
|
|
44
|
+
if (d < bestDistance) {
|
|
45
|
+
best = c;
|
|
46
|
+
bestDistance = d;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
return best;
|
|
50
|
+
}
|
|
51
|
+
/** Error block: what happened, detail, fix, then `exit N · ref e_code`. Goes to stderr. */
|
|
52
|
+
function errorBlock(theme, f) {
|
|
53
|
+
const lines = [`${theme.status("error")} ${f.what}`];
|
|
54
|
+
for (const d of f.detail ?? []) lines.push(` ${d}`);
|
|
55
|
+
if (f.fix) lines.push(` ${theme.paint("quiet", "fix")} ${f.fix}`);
|
|
56
|
+
if (f.didYouMean) lines.push(` ${f.didYouMean}`);
|
|
57
|
+
lines.push("", theme.paint("quiet", `exit ${f.exit} ${theme.glyph("bullet")} ref ${f.ref}`));
|
|
58
|
+
return `${lines.join("\n")}\n`;
|
|
59
|
+
}
|
|
60
|
+
/** Print an error block on stderr and return its exit code. */
|
|
61
|
+
function fail(ctx, f) {
|
|
62
|
+
ctx.err(errorBlock(ctx.theme, f));
|
|
63
|
+
return f.exit;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A message safe to show a user. Errors raised by Node get a plain sentence; errors we wrote
|
|
67
|
+
* pass through. Never a stack trace or a bare `EACCES: ...`.
|
|
68
|
+
*/
|
|
69
|
+
function plainError(e) {
|
|
70
|
+
if (!(e instanceof Error)) return "Something unexpected stopped the command.";
|
|
71
|
+
const code = e.code;
|
|
72
|
+
const path = e.path;
|
|
73
|
+
const named = path ?? "a file it needs";
|
|
74
|
+
switch (code) {
|
|
75
|
+
case "EACCES":
|
|
76
|
+
case "EPERM": return `Conveno has no permission to use ${named}.`;
|
|
77
|
+
case "ENOENT": return `${path ?? "A file or folder"} does not exist.`;
|
|
78
|
+
case "ENOSPC": return "The disk is full.";
|
|
79
|
+
case "EROFS": return `${path ?? "The location"} is read-only.`;
|
|
80
|
+
case "EISDIR":
|
|
81
|
+
case "ENOTDIR": return `${path ?? "A path"} is not the kind of entry Conveno expected.`;
|
|
82
|
+
case "EMFILE": return "Too many files are open.";
|
|
83
|
+
}
|
|
84
|
+
if (typeof code === "string" && /^E[A-Z0-9]+$/.test(code)) return `The system refused an operation (${code}).`;
|
|
85
|
+
if (e instanceof TypeError || e instanceof RangeError || e instanceof ReferenceError) return "Conveno hit an internal error.";
|
|
86
|
+
return e.message.replace(/,? or enable autoStart\.?/i, ".").replace(/No session holds the orchestrator role/, "No session is the lead yet").replace(/Run orchestrate in the session you want to use/, "Run conveno lead <session>").replace(/ Run list_sessions to see who is available\./, "").replace(/^No Conveno daemon is listening at /, "Conveno's background service is not listening at ").replace(/\.\.$/, ".");
|
|
87
|
+
}
|
|
88
|
+
function warnBlock(theme, what, fix, why) {
|
|
89
|
+
const lines = [`${theme.status("warn")} ${what}`];
|
|
90
|
+
if (why) lines.push(` ${theme.paint("quiet", "why")} ${why}`);
|
|
91
|
+
lines.push(` ${theme.paint("quiet", "fix")} ${fix}`);
|
|
92
|
+
return `${lines.join("\n")}\n`;
|
|
93
|
+
}
|
|
94
|
+
/** A command to run, in bold ink. */
|
|
95
|
+
const cmd = (theme, text) => theme.bold(text);
|
|
96
|
+
export { fail as a, plural as c, warnBlock as d, errorBlock as i, seconds as l, cmd as n, localStamp as o, columns as r, plainError as s, closest as t, tilde as u };
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { n as connectOpts } from "./ctx-CDLE-2f2.js";
|
|
1
|
+
import { n as connectOpts } from "./ctx-tYftvhz_.js";
|
|
3
2
|
// src/hook.ts
|
|
4
3
|
/**
|
|
5
4
|
* Time allowed for the hook's own process-table query. Only the fallback runs it: the usual way to
|
|
@@ -69,9 +68,8 @@ async function runHook(ctx, argv) {
|
|
|
69
68
|
isAlive: ctx.isAlive
|
|
70
69
|
});
|
|
71
70
|
})();
|
|
72
|
-
const budget = isPermissionHook(cli, event) ? ctx.permissionHookTimeoutMs ?? 9e4 : ctx.hookTimeoutMs;
|
|
73
71
|
const timeout = listener ? new Promise(() => void 0) : new Promise((resolve) => {
|
|
74
|
-
timer = setTimeout(() => resolve(NOTHING),
|
|
72
|
+
timer = setTimeout(() => resolve(NOTHING), ctx.hookTimeoutMs);
|
|
75
73
|
});
|
|
76
74
|
let code = 0;
|
|
77
75
|
try {
|