@conveno/cli 0.2.0-rc.5 → 0.2.0-rc.7

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 (33) hide show
  1. package/README.md +22 -30
  2. package/dist/acp-9pRRszwU.js +82 -0
  3. package/dist/agy-relay-C-nqvieJ.js +137 -0
  4. package/dist/args-C7Agak9f.js +321 -0
  5. package/dist/bin.js +2 -2
  6. package/dist/{ctx-CDLE-2f2.js → ctx-tYftvhz_.js} +2 -3
  7. package/dist/daemon.js +410 -1423
  8. package/dist/daemonError-DNAKEyRT.js +66 -0
  9. package/dist/{dist-TrWRppjR.js → dist-D2hMvcZu.js} +592 -1216
  10. package/dist/dist-D9Gu-mQm.js +547 -0
  11. package/dist/dist-DOGlDbRb.js +504 -0
  12. package/dist/{dist-BPPOKmbH.js → dist-DOKVrSIw.js} +39 -148
  13. package/dist/dist-Dd31Fg0h.js +671 -0
  14. package/dist/{dist-CEJ2-wxh.js → dist-ftx5RNCp.js} +4 -17
  15. package/dist/{dist-E3XvoT1Q.js → dist-iFaY42Bs.js} +1 -1
  16. package/dist/{doctor-CzIGTeNT.js → doctor-BYa-MApu.js} +109 -102
  17. package/dist/fmt-C2SsP5Y0.js +96 -0
  18. package/dist/{hook-CLB_muZS.js → hook-CQeSn-w4.js} +7 -5
  19. package/dist/hook-entry-BXmSN--S.js +2490 -0
  20. package/dist/hook-entry-CgiSN-Oj.js +1 -0
  21. package/dist/main-seh-HPZO.js +971 -0
  22. package/dist/pick-DoyocW55.js +9 -0
  23. package/dist/{run-CYH0CRbp.js → run-B-WfNtCX.js} +627 -1998
  24. package/dist/{runtime-B1Pb9Qqg.js → runtime-Bnjh9BQ8.js} +119 -210
  25. package/dist/{dist-C8JRuLiZ.js → toml-patch-DGzVRdd1.js} +20 -1890
  26. package/dist/watch-Dr2RdyGo.js +185 -0
  27. package/package.json +15 -15
  28. package/dist/acp-BD7Oaerg.js +0 -142
  29. package/dist/args-BRB8QEQM.js +0 -554
  30. package/dist/dist-DcmKjrmu.js +0 -271
  31. package/dist/hook-entry-BlvSoNMm.js +0 -1289
  32. package/dist/hook-entry-CRDh36pe.js +0 -1
  33. package/dist/main-CsCsyq2G.js +0 -1645
@@ -3,7 +3,7 @@ import { mkdir, open, readFile, rm, stat } from "node:fs/promises";
3
3
  import { createConnection } from "node:net";
4
4
  import { homedir } from "node:os";
5
5
  import { dirname, join } from "node:path";
6
- import { Cn as RpcResponse, E as clientProof, In as isSocketPathTooLong, Jn as socketPathTooLongMessage, M as dataDir, Mn as defaultSocketPath, N as dataPaths, Nn as encodeFrame, Pn as ipcMethods, Sn as RpcErrorCode, Tt as proofsMatch, bn as PROTOCOL_VERSION, j as daemonProof, jn as createLineDecoder, pn as EventPayload, r as ConvenoError, ut as newAuthNonce } from "./dist-TrWRppjR.js";
6
+ import { A as daemonProof, M as dataPaths, T as clientProof, Tn as socketPathTooLongMessage, an as PROTOCOL_VERSION, cn as RpcResponse, dn as defaultSocketPath, fn as encodeFrame, ht as proofsMatch, j as dataDir, mn as isSocketPathTooLong, pn as ipcMethods, r as ConvenoError, rt as newAuthNonce, sn as RpcErrorCode, tn as EventPayload, un as createLineDecoder } from "./dist-D2hMvcZu.js";
7
7
  // ../client/dist/index.js
8
8
  const DEFAULT_REQUEST_TIMEOUT_MS = 5e3;
9
9
  const DEFAULT_START_TIMEOUT_MS = 1e4;
@@ -16,32 +16,21 @@ const CLIENT_METHODS = [
16
16
  "session.setStatus",
17
17
  "session.byHost",
18
18
  "session.hostOf",
19
- "session.forget",
20
- "session.setAuto",
19
+ "session.setNative",
21
20
  "turn.start",
22
21
  "turn.end",
23
22
  "turn.wake",
24
23
  "daemon.shutdown",
25
24
  "session.list",
26
25
  "orchestrator.claim",
26
+ "orchestrator.clear",
27
27
  "message.send",
28
28
  "message.inbox",
29
29
  "message.deliver",
30
30
  "message.ack",
31
- "owner.inbox",
32
- "owner.ack",
31
+ "message.requeue",
33
32
  "owner.send",
34
- "message.history",
35
- "session.setCliInfo",
36
- "session.setPeekable",
37
- "session.peek",
38
33
  "events.subscribe",
39
- "ticket.create",
40
- "ticket.answer",
41
- "ticket.list",
42
- "ticket.cancel",
43
- "permission.relay",
44
- "permission.request",
45
34
  "relay.status",
46
35
  "devices.list",
47
36
  "devices.pair",
@@ -63,8 +52,6 @@ const NOT_REPLAYABLE = /* @__PURE__ */ new Set([
63
52
  "daemon.shutdown",
64
53
  "turn.end",
65
54
  "turn.wake",
66
- "ticket.create",
67
- "permission.request",
68
55
  "devices.pair",
69
56
  "devices.pairConfirm",
70
57
  "devices.revoke",
@@ -2,7 +2,7 @@ import { randomBytes as randomBytes$1 } from "@noble/ciphers/utils.js";
2
2
  import { equalBytes } from "@noble/curves/utils.js";
3
3
  import { sha256 } from "@noble/hashes/sha2.js";
4
4
  import { bytesToHex, concatBytes, utf8ToBytes } from "@noble/hashes/utils.js";
5
- import { $n as literal, Qn as discriminatedUnion, Xn as array, Yn as _enum, er as number, nr as string, tr as object, un as DeviceId } from "./dist-TrWRppjR.js";
5
+ import { An as literal, Dn as array, En as _enum, Mn as object, Nn as string, Qt as DeviceId, jn as number, kn as discriminatedUnion } from "./dist-D2hMvcZu.js";
6
6
  import { ed25519, x25519 } from "@noble/curves/ed25519.js";
7
7
  import { chacha20poly1305 } from "@noble/ciphers/chacha.js";
8
8
  import { expand, extract } from "@noble/hashes/hkdf.js";
@@ -1,11 +1,12 @@
1
- import { D as compatStatus, Dt as readAccountTokens, G as fetchAccountStatus, K as findOnPath, Mt as readSettings, N as dataPaths, O as completeLogin, Rt as requestDeviceCode, St as pinnedAdapter, cn as CLI_KINDS, f as acpOverrideVar, g as adapterNpxCommand, h as adapterInstallCommand, l as SPAWN_TABLE, n as AccountError, on as writeSettings, st as logoutAccount, wt as pollDeviceCode, zt as resolveAcpProgram } from "./dist-TrWRppjR.js";
2
- import { t as ClientError } from "./dist-CEJ2-wxh.js";
3
- import { a as closest, c as errorBlock, d as plainError, f as plural, h as warnBlock, i as parseFlags, l as fail, m as tilde, o as cmd, p as seconds, s as columns, t as COMMANDS, u as localStamp } from "./args-BRB8QEQM.js";
4
- import { n as connectOpts, t as adapterEnv } from "./ctx-CDLE-2f2.js";
1
+ import { D as completeLogin, E as compatStatus, H as fetchAccountStatus, M as dataPaths, Tt as requestDeviceCode, U as findOnPath, Xt as CLI_KINDS, Yt as writeSettings, _t as readAccountTokens, d as SPAWN_TABLE, dt as pinnedAdapter, g as adapterNpxCommand, h as adapterInstallCommand, kt as resolveAcpProgram, m as acpOverrideVar, mt as pollDeviceCode, n as AccountError, tt as logoutAccount, xt as readSettings } from "./dist-D2hMvcZu.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-C7Agak9f.js";
4
+ import { n as connectOpts, t as adapterEnv } from "./ctx-tYftvhz_.js";
5
+ import { t as daemonProblem } from "./daemonError-DNAKEyRT.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: "The Conveno daemon cannot be reached",
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 daemon refused the request",
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> --acp)")}`,
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> --acp 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:
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,14 @@ async function applyChanges(ctx, items, opts = {}) {
941
879
  }
942
880
  if (!done) {
943
881
  await currentIfUnchanged(change);
944
- if (change.deleteFile) await io.rm(change.path);
945
- else await writeAtomic(change.path, change.after, io);
882
+ if (change.deleteFile) {
883
+ await io.rm(change.path);
884
+ let dir = dirname(change.path);
885
+ for (let n = change.pruneEmptyDir === true ? 1 : change.pruneEmptyDir ?? 0; n > 0; n--) {
886
+ if (!await rmdir(dir).then(() => true, () => false)) break;
887
+ dir = dirname(dir);
888
+ }
889
+ } else await writeAtomic(change.path, change.after, io);
946
890
  }
947
891
  how.push({
948
892
  cli,
@@ -1073,9 +1017,11 @@ async function detectAll(ctx, adapters = ctx.adapters) {
1073
1017
  }
1074
1018
  }));
1075
1019
  }
1020
+ /** The `--cli` example in error fixes: every CLI this version supports. */
1021
+ const cliListExample = (ctx) => `--cli ${ctx.adapters.map((a) => a.cli).join(",")}`;
1076
1022
  function parseCliList(raw, ctx) {
1077
1023
  if (raw === void 0) return ctx.adapters;
1078
- const names = raw.split(",").map((s) => s.trim()).filter(Boolean);
1024
+ const names = raw.split(/[\s,]+/).filter(Boolean);
1079
1025
  const out = [];
1080
1026
  for (const n of names) {
1081
1027
  if (!CLI_KINDS.includes(n)) {
@@ -1103,12 +1049,12 @@ function printDetections(ctx, found) {
1103
1049
  ctx.out(`${columns(rows).join("\n")}\n\n`);
1104
1050
  }
1105
1051
  /** Collect plans from installed adapters. Returns failures instead of throwing. */
1106
- async function collectPlans(ctx, found, which, baseline, opts = {}) {
1107
- const env = adapterEnv(ctx, opts);
1052
+ async function collectPlans(ctx, found, which, baseline, accept = []) {
1053
+ const env = adapterEnv(ctx);
1108
1054
  const items = [];
1109
1055
  const failures = [];
1110
1056
  for (const { adapter, detection } of found) try {
1111
- for (const change of await (which === "plan" ? adapter.plan(env) : adapter.uninstallPlan(env, baseline))) items.push({
1057
+ for (const change of await (which === "plan" ? adapter.plan(env, { accept }) : adapter.uninstallPlan(env, baseline))) items.push({
1112
1058
  cli: adapter.cli,
1113
1059
  installed: detection.installed,
1114
1060
  change
@@ -1182,6 +1128,25 @@ async function confirmAndApply(ctx, items, opts) {
1182
1128
  }) };
1183
1129
  }
1184
1130
  }
1131
+ /** Every optional question for these CLIs that is not yet turned on. `enabled` throwing counts as on: nothing to offer. */
1132
+ async function pendingOptions(ctx, adapters) {
1133
+ const env = adapterEnv(ctx);
1134
+ const out = [];
1135
+ for (const a of adapters) for (const o of a.optional ?? []) {
1136
+ if (await o.enabled(env).catch(() => true)) continue;
1137
+ out.push({
1138
+ cli: a.cli,
1139
+ id: o.id,
1140
+ question: o.question
1141
+ });
1142
+ }
1143
+ return out;
1144
+ }
1145
+ /** The changes `with` has that `base` does not: a different file, or the same file with other text. */
1146
+ function extraChanges(base, withOpt) {
1147
+ const had = new Set(base.map((i) => `${i.change.path}\0${i.change.after}\0${i.change.kind}`));
1148
+ return withOpt.filter((i) => !had.has(`${i.change.path}\0${i.change.after}\0${i.change.kind}`));
1149
+ }
1185
1150
  async function runInit(ctx, argv) {
1186
1151
  const outcome = {};
1187
1152
  const code = await initSetup(ctx, argv, outcome);
@@ -1213,7 +1178,7 @@ async function initSetup(ctx, argv, outcome) {
1213
1178
  const chosen = parseCliList(typeof values.cli === "string" ? values.cli : void 0, ctx);
1214
1179
  if (!Array.isArray(chosen)) return fail(ctx, {
1215
1180
  what: chosen.message,
1216
- fix: `Pass ${cmd(t, "--cli claude,codex,opencode")} or leave it out.`,
1181
+ fix: `Pass ${cmd(t, cliListExample(ctx))} or leave it out.`,
1217
1182
  ...chosen.suggestion ? { didYouMean: chosen.suggestion } : {},
1218
1183
  exit: 2,
1219
1184
  ref: "e_usage"
@@ -1228,28 +1193,62 @@ async function initSetup(ctx, argv, outcome) {
1228
1193
  exit: 1,
1229
1194
  ref: "e_no_cli"
1230
1195
  });
1231
- const withRelay = values["with-permission-relay"] === true;
1232
- const { items, failures } = await collectPlans(ctx, installed, "plan", void 0, { permissionRelay: withRelay });
1196
+ const accepted = /* @__PURE__ */ new Set();
1197
+ const acceptRaw = typeof values.accept === "string" ? values.accept : void 0;
1198
+ if (acceptRaw !== void 0) {
1199
+ const known = new Set(ctx.adapters.flatMap((a) => (a.optional ?? []).map((o) => o.id)));
1200
+ for (const id of acceptRaw.split(/[\s,]+/).filter(Boolean)) {
1201
+ if (!known.has(id)) return fail(ctx, {
1202
+ what: `Unknown option "${id}" for --accept`,
1203
+ detail: [known.size > 0 ? `Known: ${[...known].join(", ")}.` : "There are none."],
1204
+ fix: `Run ${cmd(t, "conveno init --help")} to see the options.`,
1205
+ exit: 2,
1206
+ ref: "e_usage"
1207
+ });
1208
+ accepted.add(id);
1209
+ }
1210
+ }
1211
+ const pending = await pendingOptions(ctx, installed.map((f) => f.adapter));
1212
+ const dryRun = Boolean(values["dry-run"]);
1213
+ for (const o of pending) {
1214
+ if (accepted.has(o.id)) continue;
1215
+ if (dryRun || values.yes === true || !ctx.interactive) continue;
1216
+ if (await ctx.confirm(o.question, false)) accepted.add(o.id);
1217
+ }
1218
+ const { items, failures } = await collectPlans(ctx, installed, "plan", void 0, [...accepted]);
1233
1219
  if (failures.length > 0) {
1234
1220
  reportFailures(ctx, failures, "conveno init --cli <others>");
1235
1221
  return 1;
1236
1222
  }
1237
- if (items.length === 0) {
1223
+ const extras = [];
1224
+ if (dryRun) for (const o of pending) {
1225
+ if (accepted.has(o.id)) continue;
1226
+ const more = extraChanges(items, (await collectPlans(ctx, installed, "plan", void 0, [...accepted, o.id])).items);
1227
+ if (more.length > 0) extras.push({
1228
+ option: o,
1229
+ items: more
1230
+ });
1231
+ }
1232
+ if (items.length === 0 && extras.length === 0) {
1238
1233
  ctx.out(`${t.status("ok")} Conveno is already set up for ${installed.map((f) => f.adapter.cli).join(", ")}. Nothing to change.\n`);
1239
1234
  outcome.offer = installed.map((f) => f.adapter);
1240
1235
  return 0;
1241
1236
  }
1242
- if (values["dry-run"]) {
1237
+ if (dryRun) {
1243
1238
  const files = new Set(items.map((i) => i.change.path)).size;
1244
1239
  ctx.out(`${t.bold(`Conveno would change ${plural(files, "file")}.`)} Nothing else is touched.\n\n`);
1245
1240
  presentChanges(ctx, items);
1241
+ for (const x of extras) {
1242
+ ctx.out(`${t.bold(x.option.question)}\n ${t.paint("quiet", `Not turned on. With --accept ${x.option.id} Conveno would also change:`)}\n\n`);
1243
+ presentChanges(ctx, x.items);
1244
+ }
1246
1245
  ctx.out(`${t.status("info")} Dry run: nothing was written. Run ${cmd(t, "conveno init")} to apply.\n`);
1247
1246
  return 0;
1248
1247
  }
1249
1248
  const result = await confirmAndApply(ctx, items, {
1250
1249
  yes: values.yes === true,
1251
1250
  verb: "Apply",
1252
- rerun: withRelay ? "conveno init --with-permission-relay" : "conveno init"
1251
+ rerun: "conveno init"
1253
1252
  });
1254
1253
  if ("exit" in result) return result.exit;
1255
1254
  const byCli = /* @__PURE__ */ new Map();
@@ -1281,7 +1280,11 @@ const hasAny = (c) => c !== void 0 && (c.nextTurn || c.endOfTurn || c.idleWake);
1281
1280
  * once its hooks (or plugin) are in place. Without them only the inbox tool is left.
1282
1281
  */
1283
1282
  function activeTiers(row) {
1284
- const caps = row.adapter.delivery?.(row.detection);
1283
+ const base = row.adapter.delivery?.(row.detection);
1284
+ const caps = base && row.idleWake !== void 0 ? {
1285
+ ...base,
1286
+ idleWake: base.idleWake && row.idleWake
1287
+ } : base;
1285
1288
  if (!caps) return row.adapter.deliveryTier === "inbox" || row.hooks === "ok" ? [tierWord(row.adapter.deliveryTier)] : ["inbox"];
1286
1289
  if (!hasAny(caps) || row.hooks !== "ok") return ["inbox"];
1287
1290
  return [
@@ -1308,13 +1311,22 @@ async function inspect(ctx, adapter) {
1308
1311
  hooks: null
1309
1312
  };
1310
1313
  const hasHooks = adapter.deliveryTier !== "inbox" || hasAny(adapter.delivery?.(detection));
1314
+ let idleWake;
1315
+ if (adapter.optional && adapter.optional.length > 0) {
1316
+ idleWake = true;
1317
+ for (const o of adapter.optional) if (!await o.enabled(env).catch(() => false)) idleWake = false;
1318
+ }
1319
+ const adapterNotes = await adapter.doctorNotes?.(env).catch(() => []);
1311
1320
  try {
1312
1321
  const changes = await adapter.plan(env);
1313
1322
  return {
1314
1323
  adapter,
1315
1324
  detection,
1316
1325
  mcp: partState(changes, "mcp"),
1317
- hooks: hasHooks ? partState(changes, "hooks") : null
1326
+ hooks: hasHooks ? partState(changes, "hooks") : null,
1327
+ changes,
1328
+ ...idleWake === void 0 ? {} : { idleWake },
1329
+ ...adapterNotes?.length ? { adapterNotes } : {}
1318
1330
  };
1319
1331
  } catch (e) {
1320
1332
  return {
@@ -1322,7 +1334,9 @@ async function inspect(ctx, adapter) {
1322
1334
  detection,
1323
1335
  mcp: "missing",
1324
1336
  hooks: hasHooks ? "missing" : null,
1325
- planError: plainError(e)
1337
+ planError: plainError(e),
1338
+ ...idleWake === void 0 ? {} : { idleWake },
1339
+ ...adapterNotes?.length ? { adapterNotes } : {}
1326
1340
  };
1327
1341
  }
1328
1342
  }
@@ -1358,7 +1372,7 @@ async function runDoctor(ctx, argv = []) {
1358
1372
  const chosen = parseCliList(typeof parsed.values.cli === "string" ? parsed.values.cli : void 0, ctx);
1359
1373
  if (!Array.isArray(chosen)) return fail(ctx, {
1360
1374
  what: chosen.message,
1361
- fix: `Pass ${cmd(t, "--cli claude,codex,opencode")} or leave it out.`,
1375
+ fix: `Pass ${cmd(t, cliListExample(ctx))} or leave it out.`,
1362
1376
  ...chosen.suggestion ? { didYouMean: chosen.suggestion } : {},
1363
1377
  exit: 2,
1364
1378
  ref: "e_usage"
@@ -1373,7 +1387,7 @@ async function runDoctor(ctx, argv = []) {
1373
1387
  try {
1374
1388
  const client = await ctx.connect(connectOpts(ctx, false));
1375
1389
  try {
1376
- const { sessions } = await client["session.list"]({ includeOffline: true });
1390
+ const { sessions } = await client["session.list"]({});
1377
1391
  daemonLine = [` ${t.status("ok")} daemon`, `running, ${plural(sessions.length, "session")}`];
1378
1392
  ok++;
1379
1393
  } finally {
@@ -1384,12 +1398,12 @@ async function runDoctor(ctx, argv = []) {
1384
1398
  if (problem.notRunning) {
1385
1399
  daemonLine = [` ${t.status("warn")} daemon`, "not running"];
1386
1400
  warnings++;
1387
- notes.push(warnBlock(t, "The Conveno daemon is not running.", problem.fix, problem.why));
1401
+ notes.push(warnBlock(t, "Conveno's background service is not running.", problem.fix, problem.why));
1388
1402
  } else {
1389
1403
  daemonLine = [` ${t.status("error")} daemon`, "cannot be reached"];
1390
1404
  problems++;
1391
1405
  notes.push(errorBlock(t, {
1392
- what: "The Conveno daemon cannot be reached",
1406
+ what: "Conveno's background service cannot be reached",
1393
1407
  detail: [problem.why],
1394
1408
  fix: problem.fix,
1395
1409
  exit: 1,
@@ -1431,7 +1445,7 @@ async function runDoctor(ctx, argv = []) {
1431
1445
  const good = r.mcp === "ok" && (r.hooks === null || r.hooks === "ok") && !r.planError;
1432
1446
  const compat = compatStatus(adapter.cli, detection.version, ctx.compat);
1433
1447
  const tiers = activeTiers(r);
1434
- let note = tiers.includes("idle wake") ? "auto mode wakes idle sessions" : tiers.includes("end of turn") ? "auto mode: at the end of a turn, no idle wake" : tiers.includes("next turn") ? "delivered at the next prompt" : "read through the inbox tool";
1448
+ 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
1449
  if (!good) note = r.planError ? "config could not be read" : r.mcp === "outdated" || r.hooks === "outdated" ? "needs an update" : "not fully configured";
1436
1450
  if (compat.kind === "older") note = `older than the minimum ${compat.minimum}`;
1437
1451
  else if (compat.kind === "newer" && good) note = `newer than tested (${compat.verified})`;
@@ -1445,6 +1459,7 @@ async function runDoctor(ctx, argv = []) {
1445
1459
  tiers.join(", "),
1446
1460
  q(note)
1447
1461
  ]);
1462
+ for (const line of r.adapterNotes ?? []) notes.push(`${q(`${adapter.displayName}:`)} ${line}`);
1448
1463
  if (r.planError) {
1449
1464
  problems++;
1450
1465
  notes.push(errorBlock(t, {
@@ -1473,16 +1488,8 @@ async function runDoctor(ctx, argv = []) {
1473
1488
  }
1474
1489
  }
1475
1490
  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
1491
  const acpLines = acpDoctorLines(ctx, rows.filter((r) => r.detection.installed).map((r) => r.adapter.cli));
1478
1492
  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
1493
  if (!rows.some((r) => r.detection.installed)) {
1487
1494
  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
1495
  warnings++;
@@ -1491,4 +1498,4 @@ async function runDoctor(ctx, argv = []) {
1491
1498
  ctx.out(`\n${ok} ok, ${plural(warnings, "warning")}, ${plural(problems, "problem")}\n`);
1492
1499
  return problems > 0 ? 1 : 0;
1493
1500
  }
1494
- export { runLogout as C, runLogin as S, runDevices as _, detectAll as a, openInBrowser 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, runAccount as x, daemonProblem as y };
1501
+ export { runLogout as C, runLogin as S, PAIR_TIMEOUT_MS as _, detectAll as a, openInBrowser as b, runInit as c, applyChanges as d, listManifests as f, unifiedDiff as g, restoreEntry as h, confirmAndApply as i, staleFailure as l, previewRestore as m, runDoctor as n, pendingOptions as o, markRestored as p, collectPlans as r, reportFailures as s, inspect as t, StaleError as u, runDevices as v, runAccount as x, runRelay 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 { nt as isPermissionHook } from "./dist-TrWRppjR.js";
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
@@ -41,11 +40,14 @@ async function findHostPid(ctx, client, cli, local) {
41
40
  * the message on stderr (Claude Code's `asyncRewake`). They stop on their own when the host CLI
42
41
  * exits, the session goes offline, or a newer listener replaces them.
43
42
  */
43
+ /** How long before the hook's timeout its messages count as too late to print. */
44
+ const DEADLINE_MARGIN_MS = 300;
44
45
  async function runHook(ctx, argv) {
45
46
  const [cli, event] = argv;
46
47
  const adapter = ctx.adapters.find((a) => a.cli === cli);
47
48
  if (!adapter || !event) return 0;
48
49
  const listener = adapter.listenEvents?.includes(event) === true;
50
+ const deadline = listener ? void 0 : Date.now() + ctx.hookTimeoutMs - DEADLINE_MARGIN_MS;
49
51
  let client;
50
52
  let timer;
51
53
  const early = ctx.hostLookup ? void 0 : ctx.ancestry(HOOK_ANCESTRY_TIMEOUT_MS);
@@ -66,12 +68,12 @@ async function runHook(ctx, argv) {
66
68
  client,
67
69
  hostPid,
68
70
  cli: adapter.cli,
69
- isAlive: ctx.isAlive
71
+ isAlive: ctx.isAlive,
72
+ ...deadline === void 0 ? {} : { deadline }
70
73
  });
71
74
  })();
72
- const budget = isPermissionHook(cli, event) ? ctx.permissionHookTimeoutMs ?? 9e4 : ctx.hookTimeoutMs;
73
75
  const timeout = listener ? new Promise(() => void 0) : new Promise((resolve) => {
74
- timer = setTimeout(() => resolve(NOTHING), budget);
76
+ timer = setTimeout(() => resolve(NOTHING), ctx.hookTimeoutMs);
75
77
  });
76
78
  let code = 0;
77
79
  try {