@conveno/cli 0.2.0-rc.9 → 0.2.0

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.
Files changed (30) hide show
  1. package/README.md +3 -5
  2. package/dist/{acp-BVk6rmXR.js → acp-BUddItzP.js} +39 -7
  3. package/dist/{agy-relay-D8eZcLuc.js → agy-relay-BZ3d_-FS.js} +4 -2
  4. package/dist/{args-B3Cj2Ie4.js → args-CtyKPZuN.js} +29 -8
  5. package/dist/bin.js +16 -2
  6. package/dist/daemon.js +4 -3139
  7. package/dist/{daemonError-C05GqdhQ.js → daemonError-CDgEtvy7.js} +1 -1
  8. package/dist/dist-BNhTPp5p.js +4509 -0
  9. package/dist/{dist-BRjg9CLd.js → dist-BOwFdixw.js} +23 -50
  10. package/dist/{dist-DaIpdMke.js → dist-CFsDqevs.js} +51 -9
  11. package/dist/dist-CNdqmI3E.js +1065 -0
  12. package/dist/{dist-STNJjbNH.js → dist-CSSvrcKr.js} +1516 -599
  13. package/dist/{dist-BjdBeCHy.js → dist-D6Xoip5W.js} +63 -17
  14. package/dist/{dist-D_O_JLLq.js → dist-DAVtixeC.js} +19 -5
  15. package/dist/{dist-MK-cK1JY.js → dist-DTMnNySx.js} +39 -19
  16. package/dist/{hook-CDF1A8AY.js → hook-BA-tI6Oc.js} +101 -7
  17. package/dist/hook-entry-BwzBtAnd.js +1346 -0
  18. package/dist/hook-entry-Cgt5ZH1s.js +1 -0
  19. package/dist/{main-Kv31Qxro.js → main-kKnLA7Hj.js} +58 -21
  20. package/dist/{pick-DLp6w_-z.js → pick-BsMvXuDo.js} +1 -1
  21. package/dist/run-PQBzaHv1.js +8193 -0
  22. package/dist/{runtime-xjPzIGmp.js → runtime-0FMqklYn.js} +171 -119
  23. package/dist/{uninstall-8AHErPRN.js → uninstall-DcxkIDpk.js} +356 -56
  24. package/dist/{watch-D0KIPowJ.js → watch-BIepRTXJ.js} +29 -7
  25. package/package.json +14 -15
  26. package/dist/dist-CVdpCNJo.js +0 -793
  27. package/dist/dist-DzpERiRx.js +0 -624
  28. package/dist/hook-entry-BTJK7aO0.js +0 -2500
  29. package/dist/hook-entry-D6zup0QV.js +0 -1
  30. package/dist/run-BPtFUGtu.js +0 -5609
@@ -1,19 +1,21 @@
1
- import { A as completeLogin, F as dataPaths, G as fetchAccountStatus, K as findOnPath, Lt as resolveAcpProgram, Nt as requestDeviceCode, St as pollDeviceCode, Tt as readAccountTokens, an as CLI_KINDS, d as SPAWN_TABLE, g as adapterNpxCommand, h as adapterInstallCommand, in as writeSettings, k as compatStatus, kt as readSettings, m as acpOverrideVar, n as AccountError, st as logoutAccount, vt as pinnedAdapter } from "./dist-STNJjbNH.js";
1
+ import { B as compatStatus, Et as logoutAccount, Fn as workerUnansweredOf, Gt as planSpawn, Ht as pinnedAdapter, K as dataPaths, Kt as pollDeviceCode, Nn as workerAccessOf, Pn as workerAskTimeoutOf, Rn as writeSettings, S as adapterNpxCommand, Tt as loginAccountApi, V as completeLogin, Yt as readAccountTokens, _n as signedInAccountApi, b as acpOverrideVar, h as WORKER_ACCESS, it as findOnPath, ln as resolveAcpProgram, nt as fetchAccountStatus, on as requestDeviceCode, p as SPAWN_TABLE, t as AccountError, tn as readSettings, x as adapterInstallCommand, zn as CLI_KINDS } from "./dist-CSSvrcKr.js";
2
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 { a as parseFlags, n as COMMANDS } from "./args-B3Cj2Ie4.js";
3
+ import { a as parseFlags, n as COMMANDS } from "./args-CtyKPZuN.js";
4
4
  import { n as connectOpts, t as adapterEnv } from "./ctx-tYftvhz_.js";
5
- import { t as daemonProblem } from "./daemonError-C05GqdhQ.js";
6
- import { basename, dirname, join } from "node:path";
7
- import { spawn } from "node:child_process";
5
+ import { t as daemonProblem } from "./daemonError-CDgEtvy7.js";
6
+ import { basename, dirname, isAbsolute, join } from "node:path";
7
+ import { execFile, spawn } from "node:child_process";
8
8
  import { access, chmod, mkdir, open, readFile, readdir, realpath, rename as rename$1, rm, rmdir, stat, writeFile } from "node:fs/promises";
9
9
  import { createHash, randomBytes } from "node:crypto";
10
10
  // src/account.ts
11
- const accountIo = (ctx, io) => ({
12
- apiBase: ctx.env.CONVENO_API_URL || "https://api.conveno.dev",
11
+ const tokenFile = (ctx) => dataPaths(ctx.platform, ctx.dataDir).account;
12
+ /** The account server of the saved login, the one its tokens may be sent to. */
13
+ const accountServer = (ctx) => signedInAccountApi(tokenFile(ctx), ctx.env);
14
+ const accountIo = (ctx, io, apiBase = accountServer(ctx)) => ({
15
+ apiBase,
13
16
  now: () => ctx.now().getTime(),
14
17
  ...io.fetch ? { fetch: io.fetch } : {}
15
18
  });
16
- const tokenFile = (ctx) => dataPaths(ctx.platform, ctx.dataDir).account;
17
19
  /** Show the code as ABCD-1234, the way the page asks for it. */
18
20
  const showCode = (code) => /^[A-Za-z0-9]{8}$/.test(code) ? `${code.slice(0, 4)}-${code.slice(4)}` : code;
19
21
  /** Open a page with the system's own opener. No shell is involved, so the URL is one argument. */
@@ -65,7 +67,7 @@ async function runLogin(ctx, argv, io = {}) {
65
67
  const parsed = parseFlags(ctx, spec, argv);
66
68
  if (typeof parsed === "number") return parsed;
67
69
  const t = ctx.theme;
68
- const aio = accountIo(ctx, io);
70
+ const aio = accountIo(ctx, io, loginAccountApi(ctx.env));
69
71
  try {
70
72
  const code = await requestDeviceCode(aio);
71
73
  ctx.err([
@@ -98,13 +100,14 @@ async function runLogout(ctx, argv, io = {}) {
98
100
  if (!spec) return 2;
99
101
  const parsed = parseFlags(ctx, spec, argv);
100
102
  if (typeof parsed === "number") return parsed;
101
- const r = await logoutAccount(tokenFile(ctx), accountIo(ctx, io));
103
+ const server = accountServer(ctx);
104
+ const r = await logoutAccount(tokenFile(ctx), accountIo(ctx, io, server));
102
105
  if (!r.hadLogin) {
103
106
  ctx.out("You were not signed in.\n");
104
107
  return 0;
105
108
  }
106
109
  ctx.out(`${ctx.theme.status("ok")} Signed out.\n`);
107
- if (!r.revoked) ctx.err(`${ctx.theme.status("warn")} The account server could not be reached, so the login was only removed from this machine. Sign out everywhere at https://api.conveno.dev/account.\n`);
110
+ if (!r.revoked) ctx.err(`${ctx.theme.status("warn")} The account server could not be reached, so the login was only removed from this machine. Sign out everywhere at ${server}/account.\n`);
108
111
  return 0;
109
112
  }
110
113
  /** `conveno account`: plan and trial. */
@@ -123,7 +126,8 @@ async function runAccount(ctx, argv, io = {}) {
123
126
  ref: "e_account_not_logged_in"
124
127
  });
125
128
  try {
126
- const s = await fetchAccountStatus(tokens.refreshToken, accountIo(ctx, io));
129
+ const server = accountServer(ctx);
130
+ const s = await fetchAccountStatus(tokens.refreshToken, accountIo(ctx, io, server));
127
131
  const rows = [["Account", s.user.name], ["Plan", planLine(ctx, s)]];
128
132
  if (s.status === "trialing" && s.trialEnd !== null) {
129
133
  const left = s.trialDaysLeft ?? 0;
@@ -132,14 +136,16 @@ async function runAccount(ctx, argv, io = {}) {
132
136
  if (s.paymentFailed) rows.push(["Billing", t.paint("warn", "last payment failed")]);
133
137
  const width = Math.max(...rows.map(([k]) => k.length)) + 2;
134
138
  const lines = rows.map(([k, v]) => `${t.paint("quiet", k.padEnd(width))}${v}`);
135
- if (s.plan === "free") lines.push("", `Upgrade or start the 14-day trial at ${t.bold("https://api.conveno.dev/account")}.`);
136
- else if (s.status === "trialing") lines.push("", "No card is on file. Add one at https://api.conveno.dev/account to keep Pro.");
139
+ if (s.plan === "free") lines.push("", `Upgrade or start the 14-day trial at ${t.bold(`${server}/account`)}.`);
140
+ else if (s.status === "trialing") lines.push("", `No card is on file. Add one at ${server}/account to keep Pro.`);
137
141
  ctx.out(`${lines.join("\n")}\n`);
138
142
  return 0;
139
143
  } catch (e) {
140
144
  return accountFailure(ctx, e, "Could not read your account");
141
145
  }
142
146
  }
147
+ // src/version.ts
148
+ const VERSION = "0.2.0";
143
149
  // src/daemon.ts
144
150
  async function lockPid(ctx) {
145
151
  try {
@@ -276,6 +282,29 @@ async function stopDaemonIfRunning(ctx) {
276
282
  }
277
283
  return stopDaemon(ctx, true);
278
284
  }
285
+ /**
286
+ * For the commands a person runs (`conveno`, `conveno setup`): when a daemon is running from a
287
+ * different version than this CLI (an upgrade left the old one up), stop it so the next connect
288
+ * starts this version's. Says nothing itself; the returned line is for the setup details. Never
289
+ * starts a daemon, and never throws. MCP servers and hooks must not call this: an old MCP would
290
+ * take the daemon back to its own version.
291
+ */
292
+ async function replaceStaleDaemon(ctx) {
293
+ let running;
294
+ try {
295
+ const c = await ctx.connect(connectOpts(ctx, false));
296
+ running = c.daemonVersion;
297
+ await c.close().catch(() => void 0);
298
+ } catch {
299
+ return null;
300
+ }
301
+ if (running === void 0 || running === VERSION) return null;
302
+ return await stopDaemon({
303
+ ...ctx,
304
+ out: () => void 0,
305
+ err: () => void 0
306
+ }, true).catch(() => 1) === 0 ? `Restarted the background service: it was ${running}, now ${VERSION}.` : `The background service is still ${running} (this is ${VERSION}). Run conveno daemon stop.`;
307
+ }
279
308
  const SUBCOMMANDS = [
280
309
  "start",
281
310
  "stop",
@@ -370,6 +399,7 @@ function listLine(ctx, list) {
370
399
  function conflictBlock(ctx, c) {
371
400
  if (!c) return "";
372
401
  const t = ctx.theme;
402
+ const account = signedInAccountApi(dataPaths(ctx.platform, ctx.dataDir).account, ctx.env);
373
403
  const head = (l) => l ? `${l.head.slice(0, 16)} ${t.paint("quiet", `(${plural(l.length, "entry", "entries")})`)}` : "none";
374
404
  const why = c.kind === "split_view" ? [` ${c.peer?.name ?? "Another device"} signed a message with a device list this device does not hold.`, " The relay may be showing your devices different lists, for example to hide a revocation."] : [" The relay holds a device list that this device's list is not part of.", " Someone changed the list in a way this device cannot follow, or the relay is lying."];
375
405
  return `${[
@@ -386,7 +416,7 @@ function conflictBlock(ctx, c) {
386
416
  " If it lists only devices you recognize, type the head it shows (the full 64 characters) here:",
387
417
  ` ${cmd(t, "conveno devices accept <head>")}. Then revoke any device you do not recognize.`,
388
418
  " If no device you trust is left, or you did not reset the devices yourself, reset them at",
389
- ` https://api.conveno.dev/account. After a reset, run ${cmd(t, "conveno devices reset")} here and pair again.`,
419
+ ` ${account}/account. After a reset, run ${cmd(t, "conveno devices reset")} here and pair again.`,
390
420
  ""
391
421
  ].join("\n")}\n`;
392
422
  }
@@ -613,7 +643,8 @@ const STATE_TEXT = {
613
643
  connecting: "connecting",
614
644
  connected: "connected",
615
645
  disconnected: "disconnected, retrying",
616
- revoked: "off, this device was revoked"
646
+ revoked: "off, this device was revoked",
647
+ upgrade_required: "off, Conveno needs an update"
617
648
  };
618
649
  async function runRelay(ctx, argv) {
619
650
  const t = ctx.theme;
@@ -762,6 +793,93 @@ ${missing.map((m) => ` ${pinnedAdapter(m.pkg) ?? m.pkg}\n`).join("")}`);
762
793
  printManual(ctx, missing);
763
794
  }
764
795
  }
796
+ // src/acp-warm.ts
797
+ /** Longest a download may take. */
798
+ const WARM_TIMEOUT_MS = 3e5;
799
+ function realWarmRunner(ctx) {
800
+ return { run: (file, args, timeoutMs) => {
801
+ const plan = planSpawn(file, args);
802
+ return new Promise((resolve) => {
803
+ execFile(plan.file, plan.args, {
804
+ timeout: timeoutMs,
805
+ windowsHide: true,
806
+ env: {
807
+ ...ctx.env,
808
+ npm_config_update_notifier: "false"
809
+ },
810
+ maxBuffer: 16777216,
811
+ ...plan.windowsVerbatimArguments ? { windowsVerbatimArguments: true } : {}
812
+ }, (err) => {
813
+ if (!err) return resolve(0);
814
+ const code = err.code;
815
+ resolve(typeof code === "number" ? code : null);
816
+ });
817
+ });
818
+ } };
819
+ }
820
+ /**
821
+ * The pinned `<pkg>@<version>` of every adapter these tools need that is not on PATH (nor
822
+ * overridden), when the person allowed on-demand adapters. Empty otherwise.
823
+ */
824
+ function adaptersToWarm(ctx, clis) {
825
+ if (!(readSettings(dataPaths(ctx.platform, ctx.dataDir).settings).acpAdapterNpx === true)) return [];
826
+ const out = [];
827
+ for (const cli of clis) {
828
+ const acp = SPAWN_TABLE[cli]?.acp;
829
+ if (!acp?.adapterPackage) continue;
830
+ const found = resolveAcpProgram(cli, acp, {
831
+ env: ctx.env,
832
+ which: (n) => findOnPath(n, ctx.env, ctx.platform),
833
+ npxConsent: false
834
+ });
835
+ const pinned = pinnedAdapter(acp.adapterPackage);
836
+ if (!found.ok && pinned && !out.includes(pinned)) out.push(pinned);
837
+ }
838
+ return out;
839
+ }
840
+ /**
841
+ * Download the adapters now. `onStart` is called once, before the first download, and only when
842
+ * there is something to download. Never throws.
843
+ */
844
+ async function warmAcpAdapters(ctx, clis, opts = {}) {
845
+ const packages = adaptersToWarm(ctx, clis);
846
+ if (packages.length === 0) return { status: "none" };
847
+ opts.onStart?.();
848
+ const runner = opts.runner ?? ctx.warmRunner ?? realWarmRunner(ctx);
849
+ const failed = [];
850
+ for (const pkg of packages) {
851
+ const args = [
852
+ "exec",
853
+ "--yes",
854
+ `--package=${pkg}`,
855
+ "--",
856
+ "node",
857
+ "-e",
858
+ "0"
859
+ ];
860
+ opts.onLine?.(`$ npm ${args.join(" ")}`);
861
+ let code = null;
862
+ try {
863
+ code = await runner.run("npm", args, opts.timeoutMs ?? WARM_TIMEOUT_MS);
864
+ } catch {
865
+ code = null;
866
+ }
867
+ if (code !== 0) {
868
+ failed.push(pkg);
869
+ opts.onLine?.(`Could not fetch ${pkg} now (${code === null ? "no answer" : `exit ${code}`}).`);
870
+ } else opts.onLine?.(`${pkg} is ready.`);
871
+ }
872
+ if (failed.length === 0) return {
873
+ status: "ready",
874
+ packages
875
+ };
876
+ return {
877
+ status: "failed",
878
+ packages,
879
+ failed,
880
+ reason: "It will download the first time a worker starts."
881
+ };
882
+ }
765
883
  // src/diff.ts
766
884
  const splitLines = (s) => {
767
885
  if (s === "") return [];
@@ -1188,9 +1306,111 @@ async function markRestored(ctx, found) {
1188
1306
  };
1189
1307
  await writeFile(join(found.dir, MANIFEST_NAME), `${JSON.stringify(done, null, 2)}\n`, { mode: 384 });
1190
1308
  }
1309
+ // src/tools.ts
1310
+ /**
1311
+ * The settings file, or undefined when its path is not a real path on this machine. A test that
1312
+ * fakes another platform builds paths with that platform's separators; writing there would land
1313
+ * in the working directory, so nothing is read or written.
1314
+ */
1315
+ function settingsFile(ctx) {
1316
+ const path = dataPaths(ctx.platform, ctx.dataDir).settings;
1317
+ return isAbsolute(path) ? path : void 0;
1318
+ }
1319
+ /** The tools that already have Conveno's setup, whether or not their program is on PATH now. */
1320
+ async function connectedTools(ctx) {
1321
+ const env = adapterEnv(ctx);
1322
+ const out = [];
1323
+ for (const adapter of ctx.adapters) try {
1324
+ if (!(await adapter.plan(env)).some((c) => c.component === "mcp" && c.kind === "add")) out.push(adapter.cli);
1325
+ } catch {}
1326
+ return out;
1327
+ }
1328
+ /**
1329
+ * The saved choice. Installs from before the choice was saved have none: it is then taken, once,
1330
+ * from the tools that already have Conveno's setup and saved. Nothing saved and nothing set up
1331
+ * gives an empty list (the first setup has not happened).
1332
+ */
1333
+ async function chosenTools(ctx) {
1334
+ const path = settingsFile(ctx);
1335
+ const known = new Set(ctx.adapters.map((a) => a.cli));
1336
+ const saved = path ? readSettings(path).tools : void 0;
1337
+ if (saved) return saved.filter((c) => known.has(c));
1338
+ const derived = await connectedTools(ctx);
1339
+ if (path && derived.length > 0) try {
1340
+ writeSettings(path, { tools: derived });
1341
+ } catch {}
1342
+ return derived;
1343
+ }
1344
+ /**
1345
+ * Save the choice, after the setup worked. The lead must be one of the chosen tools: a new one is
1346
+ * kept, the earlier one stays while it is still chosen, and a lead that was dropped is cleared.
1347
+ */
1348
+ function saveChoice(ctx, tools, lead) {
1349
+ const path = settingsFile(ctx);
1350
+ if (!path) return;
1351
+ const next = lead ?? readSettings(path).leadCli;
1352
+ writeSettings(path, {
1353
+ tools: [...new Set(tools)],
1354
+ leadCli: next && tools.includes(next) ? next : null
1355
+ });
1356
+ }
1357
+ // src/worker-access.ts
1358
+ /** "1 min", "2 min", "5 min". */
1359
+ const waitText = (sec) => `${Math.round(sec / 60)} min`;
1360
+ /** Plain words for each level. */
1361
+ const ACCESS_TEXT = {
1362
+ read: {
1363
+ label: "Read only",
1364
+ hint: "read and search files, list folders"
1365
+ },
1366
+ edit: {
1367
+ label: "Read and edit",
1368
+ hint: "also edit files; commands are asked"
1369
+ },
1370
+ full: {
1371
+ label: "Everything",
1372
+ hint: "anything, no questions"
1373
+ }
1374
+ };
1375
+ const UNANSWERED_TEXT = {
1376
+ deny: {
1377
+ label: "Deny it",
1378
+ hint: "the worker is told no"
1379
+ },
1380
+ allow: {
1381
+ label: "Allow it",
1382
+ hint: "the worker goes ahead"
1383
+ }
1384
+ };
1385
+ const isWorkerAccess = (v) => WORKER_ACCESS.includes(v);
1386
+ /** The saved choices, or the defaults. */
1387
+ function readWorkerAccess(ctx) {
1388
+ const path = settingsFile(ctx);
1389
+ const s = path ? readSettings(path) : {};
1390
+ return {
1391
+ access: workerAccessOf(s),
1392
+ unanswered: workerUnansweredOf(s),
1393
+ waitSec: workerAskTimeoutOf(s)
1394
+ };
1395
+ }
1396
+ /** Save some or all. Does nothing when the settings path is not a real path (faked platform). */
1397
+ function saveWorkerAccess(ctx, patch) {
1398
+ const path = settingsFile(ctx);
1399
+ if (!path) return;
1400
+ writeSettings(path, {
1401
+ ...patch.access ? { workerAccess: patch.access } : {},
1402
+ ...patch.unanswered ? { workerUnanswered: patch.unanswered } : {},
1403
+ ...patch.waitSec ? { workerAskTimeoutSec: patch.waitSec } : {}
1404
+ });
1405
+ }
1406
+ /** One quiet line for `conveno status` and `conveno doctor`. */
1407
+ function workerAccessLine(ctx) {
1408
+ const { access, unanswered, waitSec } = readWorkerAccess(ctx);
1409
+ if (access === "full") return "Workers: full · no questions";
1410
+ return `Workers: ${access} · asks wait ${waitText(waitSec)}, then ${unanswered}`;
1411
+ }
1191
1412
  // src/init.ts
1192
1413
  const CODEX_NOTE = "Codex asks you to approve Conveno once: run /hooks inside Codex.";
1193
- const CURSOR_NOTE = "Cursor can ask you to approve Conveno when you start it in your home folder. Approve it once there with: cursor-agent mcp enable conveno";
1194
1414
  /** Detect every adapter. A detection that throws counts as not installed. */
1195
1415
  async function detectAll(ctx, adapters = ctx.adapters) {
1196
1416
  const env = adapterEnv(ctx);
@@ -1231,6 +1451,24 @@ function parseCliList(raw, ctx) {
1231
1451
  }
1232
1452
  return out;
1233
1453
  }
1454
+ /**
1455
+ * The tools to set up: `--cli` when given (it becomes the saved choice), else the saved choice.
1456
+ * With neither there is nothing to go on, so the caller must ask for `--cli`.
1457
+ */
1458
+ async function toolsToSet(ctx, raw) {
1459
+ if (raw !== void 0) {
1460
+ const list = parseCliList(raw, ctx);
1461
+ return Array.isArray(list) ? {
1462
+ adapters: list,
1463
+ explicit: true
1464
+ } : list;
1465
+ }
1466
+ const saved = await chosenTools(ctx);
1467
+ return {
1468
+ adapters: ctx.adapters.filter((a) => saved.includes(a.cli)),
1469
+ explicit: false
1470
+ };
1471
+ }
1234
1472
  function printDetections(ctx, found) {
1235
1473
  const t = ctx.theme;
1236
1474
  ctx.out(`${t.bold("Looking for AI tools on this machine")}\n`);
@@ -1482,9 +1720,29 @@ async function runInit(ctx, argv, name = "init") {
1482
1720
  ref: "e_usage"
1483
1721
  });
1484
1722
  }
1723
+ if (typeof lead === "string") {
1724
+ const rawCli = early?.values.cli;
1725
+ const picked = await toolsToSet(ctx, typeof rawCli === "string" ? rawCli : void 0);
1726
+ if ("adapters" in picked && !picked.adapters.some((a) => a.cli === lead)) return fail(ctx, {
1727
+ what: `${lead} is not one of the chosen AI tools, so it can't lead`,
1728
+ detail: [`Chosen: ${picked.adapters.map((a) => a.cli).join(", ") || "none"}.`],
1729
+ fix: `Pass ${cmd(ctx.theme, `--cli ${lead}`)} too, or pick a lead from the list above.`,
1730
+ exit: 2,
1731
+ ref: "e_usage"
1732
+ });
1733
+ }
1734
+ if (early?.values["dry-run"] !== true) {
1735
+ const restarted = await replaceStaleDaemon(ctx);
1736
+ if (restarted) ctx.out(`${ctx.theme.status("info")} ${restarted}\n`);
1737
+ }
1485
1738
  const outcome = {};
1486
1739
  const code = await initSetup(ctx, argv, outcome, name);
1487
1740
  if (code !== 0) return code;
1741
+ const access = early?.values["worker-access"];
1742
+ if (isWorkerAccess(access) && early?.values["dry-run"] !== true) {
1743
+ saveWorkerAccess(ctx, { access });
1744
+ ctx.out(`${ctx.theme.status("ok")} Workers get ${access} access.\n`);
1745
+ }
1488
1746
  if (typeof lead === "string" && early?.values["dry-run"] !== true) {
1489
1747
  writeSettings(dataPaths(ctx.platform, ctx.dataDir).settings, { leadCli: lead });
1490
1748
  const shown = ctx.adapters.find((a) => a.cli === lead)?.displayName ?? lead;
@@ -1499,6 +1757,10 @@ async function runInit(ctx, argv, name = "init") {
1499
1757
  flag: values["acp-adapters"] === true ? true : values["no-acp-adapters"] === true ? false : void 0,
1500
1758
  yes: values.yes === true
1501
1759
  });
1760
+ const t = ctx.theme;
1761
+ const warmed = await warmAcpAdapters(ctx, outcome.offer.map((a) => a.cli), { onStart: () => ctx.out(`${t.status("info")} Getting workers ready (the first download can take a minute).\n`) }).catch(() => void 0);
1762
+ if (warmed?.status === "ready") ctx.out(`${t.status("ok")} Workers are ready.\n`);
1763
+ else if (warmed?.status === "failed") ctx.out(`${t.status("info")} Couldn't get workers ready now. They download the first time one starts.\n`);
1502
1764
  return 0;
1503
1765
  }
1504
1766
  async function initSetup(ctx, argv, outcome, name) {
@@ -1515,11 +1777,19 @@ async function initSetup(ctx, argv, outcome, name) {
1515
1777
  exit: 2,
1516
1778
  ref: "e_usage"
1517
1779
  });
1518
- const chosen = parseCliList(typeof values.cli === "string" ? values.cli : void 0, ctx);
1519
- if (!Array.isArray(chosen)) return fail(ctx, {
1520
- what: chosen.message,
1780
+ const picked = await toolsToSet(ctx, typeof values.cli === "string" ? values.cli : void 0);
1781
+ if (!("adapters" in picked)) return fail(ctx, {
1782
+ what: picked.message,
1521
1783
  fix: `Pass ${cmd(t, cliListExample(ctx))} or leave it out.`,
1522
- ...chosen.suggestion ? { didYouMean: chosen.suggestion } : {},
1784
+ ...picked.suggestion ? { didYouMean: picked.suggestion } : {},
1785
+ exit: 2,
1786
+ ref: "e_usage"
1787
+ });
1788
+ const chosen = picked.adapters;
1789
+ if (chosen.length === 0) return fail(ctx, {
1790
+ what: "No AI tools are chosen yet",
1791
+ detail: [`Choices: ${ctx.adapters.map((a) => a.cli).join(", ")}.`],
1792
+ fix: `Pass ${cmd(t, cliListExample(ctx))}, or run ${cmd(t, "conveno setup")} in a terminal to pick.`,
1523
1793
  exit: 2,
1524
1794
  ref: "e_usage"
1525
1795
  });
@@ -1576,7 +1846,10 @@ async function initSetup(ctx, argv, outcome, name) {
1576
1846
  }
1577
1847
  if (items.length === 0 && extras.length === 0) {
1578
1848
  ctx.out(`${t.status("ok")} Conveno is already set up for ${installed.map((f) => f.adapter.cli).join(", ")}. Nothing to change.\n`);
1579
- if (!dryRun) await approveTools(ctx, installed, accepted, /* @__PURE__ */ new Set());
1849
+ if (!dryRun) {
1850
+ await approveTools(ctx, installed, accepted, /* @__PURE__ */ new Set());
1851
+ if (picked.explicit) saveChoice(ctx, installed.map((f) => f.adapter.cli));
1852
+ }
1580
1853
  outcome.offer = installed.map((f) => f.adapter);
1581
1854
  return 0;
1582
1855
  }
@@ -1611,7 +1884,7 @@ async function initSetup(ctx, argv, outcome, name) {
1611
1884
  ctx.out(" Restart open sessions so they pick up Conveno.\n");
1612
1885
  const approved = await approveTools(ctx, installed, applying, new Set(byCli.keys()), result.applied.backupDir);
1613
1886
  if (byCli.has("codex") && !approved.has("codex")) ctx.out(`${t.status("info")} ${CODEX_NOTE}\n`);
1614
- if (byCli.has("cursor")) ctx.out(`${t.status("info")} ${CURSOR_NOTE}\n`);
1887
+ if (picked.explicit) saveChoice(ctx, installed.map((f) => f.adapter.cli));
1615
1888
  ctx.out(` Next: ${cmd(t, "conveno status")} lists your sessions.\n`);
1616
1889
  outcome.offer = installed.map((f) => f.adapter);
1617
1890
  return 0;
@@ -1651,7 +1924,18 @@ async function runSetup(ctx, argv) {
1651
1924
  const parsed = parseFlags(ctx, spec, argv);
1652
1925
  if (typeof parsed === "number") return parsed;
1653
1926
  const v = parsed.values;
1654
- if (ctx.interactive && v.yes !== true && v["dry-run"] !== true) return (await import("./run-BPtFUGtu.js")).runTui(ctx, { start: "setup" });
1927
+ const access = v["worker-access"];
1928
+ if (access !== void 0 && !isWorkerAccess(access)) return fail(ctx, {
1929
+ what: `Unknown worker access "${String(access)}"`,
1930
+ detail: ["Choose read, edit or full."],
1931
+ fix: `Pass ${cmd(ctx.theme, "--worker-access edit")} or leave it out.`,
1932
+ exit: 2,
1933
+ ref: "e_usage"
1934
+ });
1935
+ if (ctx.interactive && v.yes !== true && v["dry-run"] !== true) {
1936
+ if (isWorkerAccess(access)) saveWorkerAccess(ctx, { access });
1937
+ return (await import("./run-PQBzaHv1.js")).runTui(ctx, { start: "setup" });
1938
+ }
1655
1939
  return runInit(ctx, argv, "setup");
1656
1940
  }
1657
1941
  // src/doctor.ts
@@ -1732,44 +2016,35 @@ async function inspect(ctx, adapter) {
1732
2016
  }
1733
2017
  }
1734
2018
  /**
1735
- * A note for a CLI outside the tested range. Older than the minimum is a problem. Past the tested
1736
- * major or minor version is a warning. A patch release ahead gets only the short table note: CLIs
1737
- * like Claude Code ship patches almost daily, and they rarely change config or hook formats.
2019
+ * A warning for a CLI older than a known-broken floor: a version that lacks something Conveno
2020
+ * needs. Nothing else is flagged: a newer or untested version gets no warning, and doctor never
2021
+ * exits 1 for a version.
1738
2022
  */
1739
2023
  function versionBlock(t, adapter, version, status) {
2024
+ if (status.kind !== "older") return void 0;
1740
2025
  const name = adapter.displayName;
1741
- if (status.kind === "older") return {
1742
- problem: true,
1743
- text: errorBlock(t, {
1744
- what: `${name} ${version} is older than Conveno supports`,
1745
- detail: [`Conveno needs ${name} ${status.minimum} or newer.`],
1746
- fix: `Upgrade ${name}, then run ${cmd(t, "conveno doctor")} again.`,
1747
- exit: 1,
1748
- ref: "e_cli_old"
1749
- })
1750
- };
1751
- if (status.kind === "newer" && status.minor) return {
1752
- problem: false,
1753
- text: warnBlock(t, `${name} ${version} is newer than the ${status.verified} Conveno was tested with.`, "Nothing to do unless messages stop arriving. Please report it at https://github.com/0xPixelNinja/conveno/issues if something breaks.", "CLI vendors change config and hook formats often. A nightly check tests the newest releases and raises the tested version when they pass.")
1754
- };
2026
+ return warnBlock(t, `${name} ${version} is older than ${status.minimum}, which Conveno needs.`, `Upgrade ${name}, then run ${cmd(t, "conveno doctor")} again.`, `Some features need ${name} ${status.minimum} or newer. Conveno still works with what this version supports.`);
1755
2027
  }
1756
2028
  async function runDoctor(ctx, argv = []) {
1757
2029
  const t = ctx.theme;
1758
2030
  const spec = COMMANDS.find((c) => c.name === "doctor");
1759
2031
  let adapters = ctx.adapters;
2032
+ let chosen;
1760
2033
  if (spec) {
1761
2034
  const parsed = parseFlags(ctx, spec, argv);
1762
2035
  if (typeof parsed === "number") return parsed;
1763
- const chosen = parseCliList(typeof parsed.values.cli === "string" ? parsed.values.cli : void 0, ctx);
1764
- if (!Array.isArray(chosen)) return fail(ctx, {
1765
- what: chosen.message,
2036
+ const picked = parseCliList(typeof parsed.values.cli === "string" ? parsed.values.cli : void 0, ctx);
2037
+ if (!Array.isArray(picked)) return fail(ctx, {
2038
+ what: picked.message,
1766
2039
  fix: `Pass ${cmd(t, cliListExample(ctx))} or leave it out.`,
1767
- ...chosen.suggestion ? { didYouMean: chosen.suggestion } : {},
2040
+ ...picked.suggestion ? { didYouMean: picked.suggestion } : {},
1768
2041
  exit: 2,
1769
2042
  ref: "e_usage"
1770
2043
  });
1771
- adapters = chosen;
2044
+ adapters = picked;
2045
+ if (typeof parsed.values.cli === "string") chosen = new Set(picked.map((a) => a.cli));
1772
2046
  }
2047
+ chosen ??= new Set(await chosenTools(ctx));
1773
2048
  let ok = 0;
1774
2049
  let warnings = 0;
1775
2050
  let problems = 0;
@@ -1779,8 +2054,20 @@ async function runDoctor(ctx, argv = []) {
1779
2054
  const client = await ctx.connect(connectOpts(ctx, false));
1780
2055
  try {
1781
2056
  const { sessions } = await client["session.list"]({});
1782
- daemonLine = [` ${t.status("ok")} daemon`, `running, ${plural(sessions.length, "session")}`];
1783
- ok++;
2057
+ const relay = await (async () => client["relay.status"]({}))().catch(() => void 0);
2058
+ if (relay?.state === "upgrade_required") {
2059
+ warnings++;
2060
+ notes.push(warnBlock(t, "The relay no longer accepts this version of Conveno.", relay.detail ?? "Update Conveno to keep using your other computers.", "Your other computers cannot be reached until Conveno is updated."));
2061
+ }
2062
+ const running = client.daemonVersion;
2063
+ if (running !== void 0 && running !== VERSION) {
2064
+ daemonLine = [` ${t.status("warn")} daemon`, `running ${running}, this is ${VERSION}`];
2065
+ warnings++;
2066
+ notes.push(warnBlock(t, "Conveno's background service is from an older version.", `Run ${cmd(t, "conveno")} to restart it, or ${cmd(t, "conveno daemon stop")} and open your AI tools again.`, `The service running now is ${running}; this install is ${VERSION}. ${cmd(t, "conveno")} and ${cmd(t, "conveno setup")} restart it for you.`));
2067
+ } else {
2068
+ daemonLine = [` ${t.status("ok")} daemon`, `running, ${plural(sessions.length, "session")}`];
2069
+ ok++;
2070
+ }
1784
2071
  } finally {
1785
2072
  await client.close().catch(() => void 0);
1786
2073
  }
@@ -1833,14 +2120,25 @@ async function runDoctor(ctx, argv = []) {
1833
2120
  ]);
1834
2121
  continue;
1835
2122
  }
2123
+ if (!chosen.has(adapter.cli) && !(r.mcp === "ok" && (r.hooks === null || r.hooks === "ok"))) {
2124
+ table.push([
2125
+ ` ${t.glyph("offline")} ${adapter.cli}`,
2126
+ adapter.displayName,
2127
+ detection.version ?? "",
2128
+ "",
2129
+ "",
2130
+ "",
2131
+ q("not set up (not chosen)")
2132
+ ]);
2133
+ continue;
2134
+ }
1836
2135
  const good = r.mcp === "ok" && (r.hooks === null || r.hooks === "ok") && !r.planError;
1837
2136
  const compat = compatStatus(adapter.cli, detection.version, ctx.compat);
1838
2137
  const tiers = activeTiers(r);
1839
2138
  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";
1840
2139
  if (!good) note = r.planError ? "config could not be read" : r.mcp === "outdated" || r.hooks === "outdated" ? "needs an update" : "not fully configured";
1841
- if (compat.kind === "older") note = `older than the minimum ${compat.minimum}`;
1842
- else if (compat.kind === "newer" && good) note = `newer than tested (${compat.verified})`;
1843
- const glyph = compat.kind === "older" ? t.status("error") : good && !(compat.kind === "newer" && compat.minor) ? t.status("ok") : t.status("warn");
2140
+ if (compat.kind === "older") note = `older than ${compat.minimum}, which Conveno needs`;
2141
+ const glyph = good && compat.kind !== "older" ? t.status("ok") : t.status("warn");
1844
2142
  table.push([
1845
2143
  ` ${glyph} ${adapter.cli}`,
1846
2144
  adapter.displayName,
@@ -1861,7 +2159,7 @@ async function runDoctor(ctx, argv = []) {
1861
2159
  ref: "e_config"
1862
2160
  }));
1863
2161
  } else if (good) {
1864
- if (compat.kind !== "older" && !(compat.kind === "newer" && compat.minor)) ok++;
2162
+ if (compat.kind !== "older") ok++;
1865
2163
  } else {
1866
2164
  warnings++;
1867
2165
  const named = [["the MCP server", r.mcp], ["the hooks", r.hooks]];
@@ -1873,14 +2171,14 @@ async function runDoctor(ctx, argv = []) {
1873
2171
  }
1874
2172
  const versionNote = versionBlock(t, adapter, detection.version, compat);
1875
2173
  if (versionNote) {
1876
- notes.push(versionNote.text);
1877
- if (versionNote.problem) problems++;
1878
- else warnings++;
2174
+ notes.push(versionNote);
2175
+ warnings++;
1879
2176
  }
1880
2177
  }
1881
2178
  ctx.out(`${columns(table).join("\n")}\n`);
1882
2179
  const acpLines = acpDoctorLines(ctx, rows.filter((r) => r.detection.installed).map((r) => r.adapter.cli));
1883
2180
  if (acpLines.length > 0) ctx.out(`${acpLines.join("\n")}\n`);
2181
+ ctx.out(`${t.paint("quiet", workerAccessLine(ctx))}\n`);
1884
2182
  if (!rows.some((r) => r.detection.installed)) {
1885
2183
  notes.push(warnBlock(t, "No supported AI coding CLI was found on PATH.", "Install Claude Code, Codex CLI or OpenCode, then run conveno init."));
1886
2184
  warnings++;
@@ -2014,6 +2312,8 @@ async function runUninstall(ctx, argv) {
2014
2312
  return 1;
2015
2313
  }
2016
2314
  if (items.length === 0) {
2315
+ const stopped = await stopDaemonIfRunning(ctx);
2316
+ if (stopped !== 0) return stopped;
2017
2317
  ctx.out(`${t.status("ok")} Nothing to remove. No Conveno entries were found in any supported CLI.\n`);
2018
2318
  return 0;
2019
2319
  }
@@ -2031,4 +2331,4 @@ async function runUninstall(ctx, argv) {
2031
2331
  ctx.out(" Removed the Conveno entries. Restart open sessions to drop Conveno.\n");
2032
2332
  return 0;
2033
2333
  }
2034
- export { openInBrowser as C, showCode as D, runLogout as E, stopDaemonIfRunning as S, runLogin as T, unifiedDiff as _, applyOptions as a, runRelay as b, collectPlans as c, refreshManifest as d, renewedApprovals as f, applyChanges as g, StaleError as h, runDoctor as i, detectAll as l, runSetup as m, inspect as n, approvalWrites as o, runInit as p, partState as r, approvedBySetup as s, runUninstall as t, pendingOptions as u, PAIR_TIMEOUT_MS as v, runAccount as w, runDaemon as x, runDevices as y };
2334
+ export { runRelay as A, saveChoice as C, warmAcpAdapters as D, unifiedDiff as E, openInBrowser as F, runAccount as I, runLogin as L, runDaemon as M, stopDaemonIfRunning as N, PAIR_TIMEOUT_MS as O, VERSION as P, runLogout as R, connectedTools as S, applyChanges as T, readWorkerAccess as _, applyOptions as a, workerAccessLine as b, collectPlans as c, refreshManifest as d, renewedApprovals as f, UNANSWERED_TEXT as g, ACCESS_TEXT as h, runDoctor as i, replaceStaleDaemon as j, runDevices as k, detectAll as l, runSetup as m, inspect as n, approvalWrites as o, runInit as p, partState as r, approvedBySetup as s, runUninstall as t, pendingOptions as u, saveWorkerAccess as v, StaleError as w, chosenTools as x, waitText as y, showCode as z };