@conveno/cli 0.2.0-rc.10 → 0.2.0-rc.12

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.
@@ -4,18 +4,18 @@ import { homedir } from "node:os";
4
4
  import { delimiter, join, win32 } from "node:path";
5
5
  import { createInterface } from "node:readline";
6
6
  import { fileURLToPath } from "node:url";
7
- import { n as antigravityAdapter } from "./dist-VOS92iqO.js";
8
- import { a as opencodeAdapter, c as claudeAdapter, o as cursorAdapter, r as readAllStdin, s as copilotAdapter } from "./hook-entry-CQQU-e_t.js";
9
- import { t as codexAdapter } from "./dist-MK-cK1JY.js";
10
- import { t as grokAdapter } from "./dist-DaIpdMke.js";
7
+ import { n as antigravityAdapter } from "./dist-Du1hwaux.js";
8
+ import { a as opencodeAdapter, o as claudeAdapter, r as readAllStdin } from "./hook-entry-DWa1oppt.js";
9
+ import { t as codexAdapter } from "./dist-BjATai4T.js";
10
+ import { t as grokAdapter } from "./dist-DF0nL8wE.js";
11
11
  import { t as createTheme } from "./dist-BRjg9CLd.js";
12
- import { n as connect$1 } from "./dist-D_O_JLLq.js";
13
- import { Dt as readCommandLine, Et as readAncestry, Gt as spawnSession, In as _enum, Ln as array, P as dataDir, R as detectRepo, Rn as boolean, S as baseName, T as claimSpawnRecord, Un as string, Vn as number, Y as formatInbox, an as CLI_KINDS, at as launcherText, f as SpawnError, fn as MessageId, gn as RpcErrorCode, ht as parsePs1ShimTarget, it as launcherPath, jt as realSpawnDeps, lt as needsQuoting, mt as parseCmdShimTarget, o as HEARTBEAT_INTERVAL_MS, pn as OWNER_SESSION_ID, r as ConvenoError, s as NOT_FROM_USER_NOTICE, tn as validateRename, u as SPAWN_CLIS, xt as planSpawn, y as attachAcpSession, yn as SessionId, zt as resolveWindowsCommand } from "./dist-STNJjbNH.js";
14
- import "./dist-CVdpCNJo.js";
12
+ import { n as connect$1 } from "./dist-B3YYLzKS.js";
13
+ import { Gt as resolveWindowsCommand, Hn as _enum, L as dataDir, Nt as readAncestry, O as claimSpawnRecord, Ot as planSpawn, Pt as readCommandLine, Q as formatInbox, Rt as realSpawnDeps, S as attachAcpSession, Sn as RpcErrorCode, T as baseName, Tn as SessionId, Un as array, V as detectRepo, Wn as boolean, Yn as string, Zt as spawnSession, bt as parseCmdShimTarget, c as NOT_FROM_USER_NOTICE, d as SPAWN_CLIS, dn as CLI_KINDS, i as ConvenoError, lt as launcherPath, mt as needsQuoting, p as SpawnError, qn as number, s as HEARTBEAT_INTERVAL_MS, sn as validateRename, ut as launcherText, vn as MessageId, wt as pendingTurn, xt as parsePs1ShimTarget, yn as OWNER_SESSION_ID } from "./dist-CRj_cuHc.js";
14
+ import "./dist-DeN0jR3I.js";
15
15
  import { access } from "node:fs/promises";
16
16
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
17
17
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
18
- // ../daemon/dist/server-C7A-D-0O.js
18
+ // ../daemon/dist/server-p7RFPs-_.js
19
19
  /** `kill(pid, 0)` liveness: EPERM means the process exists but belongs to someone else. */
20
20
  function defaultIsAlive(pid) {
21
21
  try {
@@ -28,7 +28,7 @@ function defaultIsAlive(pid) {
28
28
  `${OWNER_SESSION_ID}`;
29
29
  SessionId.parse("0".repeat(26));
30
30
  // ../mcp/dist/index.js
31
- const SERVER_VERSION = "0.2.0-rc.10";
31
+ const SERVER_VERSION = "0.2.0-rc.12";
32
32
  const ok = (text) => ({ content: [{
33
33
  type: "text",
34
34
  text
@@ -140,25 +140,20 @@ function createServer(opts) {
140
140
  /** This server acts as a session an ACP host registered, and leaves its lifecycle to the host. */
141
141
  let attached = false;
142
142
  /**
143
- * OpenCode 2.x serves several sessions from one MCP process. Each OpenCode session that calls a
144
- * tool gets its own Conveno session; the first one takes over the session this process
145
- * registered at start, the others register fresh and heartbeat on their own.
143
+ * The id Conveno acts as. It starts as the session this process registered, and changes to the
144
+ * surviving session when `session.bind` merges this process's session into the one that already
145
+ * holds its conversation (Codex runs one MCP server per thread, so a thread the window already
146
+ * has may be registered a second time). Heartbeats, tool calls and unregister all use it.
146
147
  */
147
- const byOpencode = /* @__PURE__ */ new Map();
148
- const extraBeats = /* @__PURE__ */ new Map();
149
- let baseOwner;
150
- /** Stop an extra session's heartbeat and forget it, so a closed OpenCode session goes offline. */
151
- const release = (ocId, id) => {
152
- const beat = extraBeats.get(id);
153
- if (beat) clearInterval(beat);
154
- extraBeats.delete(id);
155
- byOpencode.delete(ocId);
156
- };
157
- const register = async (extra = false, ocId) => {
148
+ let actingId;
149
+ /** The conversation this process last bound, so a tool call binds only when it changes. */
150
+ let boundConversation;
151
+ let binding = Promise.resolve();
152
+ const register = async () => {
158
153
  const repo = await detectRepo(cwd, { exists: pathExists });
159
154
  const cliVersion = process.env.CONVENO_CLI_VERSION?.trim().slice(0, 64);
160
155
  const { hostPid, hostPids } = await host;
161
- const record = extra ? void 0 : claimSpawnRecord(spawnDataDir, cli, hostPids);
156
+ const record = claimSpawnRecord(spawnDataDir, cli, hostPids);
162
157
  if (record?.acp) {
163
158
  attached = true;
164
159
  return attachAcpSession(client, spawnDataDir, record);
@@ -175,31 +170,53 @@ function createServer(opts) {
175
170
  ...spawnedBy.success ? { spawnedBy: spawnedBy.data } : {},
176
171
  ...record ? { spawned: true } : {}
177
172
  };
178
- const res = await (record ? client["session.register"]({
173
+ let session = (await (record ? client["session.register"]({
179
174
  ...params,
180
175
  name: record.name
181
176
  }).catch((err) => {
182
177
  if (err instanceof ConvenoError && err.code === RpcErrorCode.Conflict) return client["session.register"](params);
183
178
  throw err;
184
- }) : client["session.register"](params));
185
- const id = res.session.id;
179
+ }) : client["session.register"](params))).session;
180
+ actingId = session.id;
181
+ boundConversation = session.nativeId;
186
182
  const claudeId = cli === "claude" ? process.env.CLAUDE_CODE_SESSION_ID?.trim() : void 0;
187
- if (!extra && claudeId) await client["session.setNative"]({
188
- sessionId: id,
189
- nativeId: claudeId
190
- }).catch(() => {});
183
+ if (claudeId && session.nativeId === void 0) {
184
+ const bound = await bindTo(claudeId, session);
185
+ if (bound) session = bound;
186
+ if (await pendingTurn(spawnDataDir, "claude-pending-turn").take(claudeId)) await client["turn.start"]({ sessionId: session.id }).catch(() => {});
187
+ }
191
188
  const beat = setInterval(() => {
192
- client["session.heartbeat"]({ sessionId: id }).catch((err) => {
193
- if (extra && ocId !== void 0 && isSessionGone(err)) release(ocId, id);
194
- });
189
+ if (actingId) client["session.heartbeat"]({
190
+ sessionId: actingId,
191
+ pid: process.pid
192
+ }).catch(() => {});
195
193
  }, HEARTBEAT_INTERVAL_MS);
196
194
  beat.unref();
197
- if (extra) extraBeats.set(id, beat);
198
- else {
199
- if (timer) clearInterval(timer);
200
- timer = beat;
195
+ if (timer) clearInterval(timer);
196
+ timer = beat;
197
+ return session;
198
+ };
199
+ /**
200
+ * Bind this process's session to a conversation. The daemon may answer with another session, the
201
+ * one that already holds it; this process acts as that one from then on. Best effort: without
202
+ * the answer the session stays as it is.
203
+ */
204
+ const bindTo = async (conversation, me) => {
205
+ try {
206
+ const { session } = await client["session.bind"]({
207
+ cli,
208
+ nativeId: conversation,
209
+ sessionId: me.id,
210
+ pid: process.pid,
211
+ turnStart: true
212
+ });
213
+ if (!session) return void 0;
214
+ boundConversation = conversation;
215
+ actingId = session.id;
216
+ return session;
217
+ } catch {
218
+ return;
201
219
  }
202
- return res.session;
203
220
  };
204
221
  const ensure = () => {
205
222
  if (!registering) {
@@ -211,20 +228,15 @@ function createServer(opts) {
211
228
  }
212
229
  return registering;
213
230
  };
214
- /** Forget a dead session so the next ensure() registers again. Only drops `dead`, not a newer one. */
215
- const forget = (dead) => {
216
- if (registering === dead) registering = void 0;
217
- };
218
231
  const shutdown = () => {
219
232
  shutting ??= (async () => {
220
233
  if (timer) clearInterval(timer);
221
234
  timer = void 0;
222
235
  const s = await registering?.catch(() => void 0);
223
- if (s && !attached) await client["session.unregister"]({ sessionId: s.id }).catch(() => void 0);
224
- for (const beat of extraBeats.values()) clearInterval(beat);
225
- extraBeats.clear();
226
- const others = await Promise.all([...byOpencode.values()].map((p) => p.catch(() => void 0)));
227
- for (const o of others) if (o && o.id !== s?.id) await client["session.unregister"]({ sessionId: o.id }).catch(() => void 0);
236
+ if (s && !attached) await client["session.unregister"]({
237
+ sessionId: actingId ?? s.id,
238
+ pid: process.pid
239
+ }).catch(() => void 0);
228
240
  })();
229
241
  return shutting;
230
242
  };
@@ -239,44 +251,38 @@ function createServer(opts) {
239
251
  await closeTransport();
240
252
  await shutdown();
241
253
  };
242
- /** The Conveno session for an OpenCode session id; without one, this process's own session. */
243
- const sessionFor = (ocId) => {
244
- if (!ocId) return ensure();
245
- let p = byOpencode.get(ocId);
246
- if (!p) {
247
- const takeBase = baseOwner === void 0;
248
- if (takeBase) baseOwner = ocId;
249
- const made = (takeBase ? ensure() : register(true, ocId)).then(async (s) => {
250
- await client["session.setNative"]({
251
- sessionId: s.id,
252
- nativeId: ocId
253
- });
254
- return s;
255
- });
256
- p = made;
257
- byOpencode.set(ocId, made);
258
- made.catch(() => {
259
- if (byOpencode.get(ocId) === made) byOpencode.delete(ocId);
260
- if (takeBase && baseOwner === ocId) baseOwner = void 0;
261
- });
262
- }
263
- return p;
254
+ /**
255
+ * The session a tool call acts as. A call that names its conversation (`_meta`) is a turn start
256
+ * in it: when it differs from the one this process last bound, the window's session moves to it
257
+ * (and a session of another process that already holds it takes this one over).
258
+ */
259
+ const sessionFor = async (conversation) => {
260
+ const me = await ensure();
261
+ if (!conversation || attached || conversation === boundConversation) return me;
262
+ const turn = binding.then(async () => {
263
+ const current = await ensure();
264
+ if (conversation === boundConversation) return current;
265
+ const bound = await bindTo(conversation, current);
266
+ if (bound) registering = Promise.resolve(bound);
267
+ return bound ?? current;
268
+ });
269
+ binding = turn.catch(() => void 0);
270
+ return turn;
264
271
  };
265
272
  /** Drop a dead session so the next call registers again. */
266
- const forgetFor = (ocId, dead) => {
267
- if (!ocId) {
268
- forget(dead);
269
- return;
270
- }
271
- if (byOpencode.get(ocId) === dead) byOpencode.delete(ocId);
272
- if (baseOwner === ocId) {
273
- baseOwner = void 0;
274
- registering = void 0;
275
- }
273
+ const forgetSession = () => {
274
+ registering = void 0;
275
+ boundConversation = void 0;
276
+ actingId = void 0;
276
277
  };
277
- /** OpenCode puts the calling session's id in the request's `_meta`. */
278
- const opencodeId = (extra) => {
279
- const v = extra?._meta?.["ai.opencode/sessionID"];
278
+ /**
279
+ * The conversation a tool call comes from, in the request's `_meta`: Codex `threadId`, OpenCode
280
+ * `ai.opencode/sessionID`, Antigravity `antigravity.google/root_conversation_id`.
281
+ */
282
+ const conversationOf = (extra) => {
283
+ const meta = extra?._meta;
284
+ const key = cli === "codex" ? "threadId" : cli === "opencode" ? "ai.opencode/sessionID" : cli === "antigravity" ? "antigravity.google/root_conversation_id" : void 0;
285
+ const v = key === void 0 ? void 0 : meta?.[key];
280
286
  return typeof v === "string" && v.length > 0 && v.length <= 256 ? v : void 0;
281
287
  };
282
288
  /**
@@ -287,16 +293,15 @@ function createServer(opts) {
287
293
  const tool = (body) => async (...given) => {
288
294
  const extra = given.length > 1 ? given[given.length - 1] : void 0;
289
295
  const args = given.length > 1 ? given[0] : {};
290
- const oc = opencodeId(extra ?? given[0]);
291
- const first = sessionFor(oc);
296
+ const conversation = conversationOf(extra ?? given[0]);
292
297
  try {
293
- return ok(await body(await first, args));
298
+ return ok(await body(await sessionFor(conversation), args));
294
299
  } catch (err) {
295
300
  if (!isSessionGone(err)) return fail(err);
296
- forgetFor(oc, first);
301
+ forgetSession();
297
302
  }
298
303
  try {
299
- return ok(await body(await sessionFor(oc), args));
304
+ return ok(await body(await sessionFor(conversation), args));
300
305
  } catch (err) {
301
306
  return isSessionGone(err) ? fail(/* @__PURE__ */ new Error(SESSION_LOST_TEXT)) : fail(err);
302
307
  }
@@ -741,8 +746,6 @@ function createRuntimeCtx() {
741
746
  claudeAdapter,
742
747
  codexAdapter,
743
748
  opencodeAdapter,
744
- cursorAdapter,
745
- copilotAdapter,
746
749
  antigravityAdapter,
747
750
  grokAdapter
748
751
  ],
@@ -1,9 +1,9 @@
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 { Bt as requestDeviceCode, It as readSettings, J as fetchAccountStatus, M as compatStatus, Mt as readAccountTokens, N as completeLogin, R as dataPaths, Tt as pinnedAdapter, Ut as resolveAcpProgram, Y as findOnPath, _ as adapterNpxCommand, dn as CLI_KINDS, f as SPAWN_TABLE, ft as logoutAccount, g as adapterInstallCommand, h as acpOverrideVar, kt as pollDeviceCode, n as AccountError, un as writeSettings } from "./dist-CRj_cuHc.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-C1eX8Ixk.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";
5
+ import { t as daemonProblem } from "./daemonError-0KnkgIRo.js";
6
+ import { basename, dirname, isAbsolute, join } from "node:path";
7
7
  import { 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";
@@ -1188,9 +1188,56 @@ async function markRestored(ctx, found) {
1188
1188
  };
1189
1189
  await writeFile(join(found.dir, MANIFEST_NAME), `${JSON.stringify(done, null, 2)}\n`, { mode: 384 });
1190
1190
  }
1191
+ // src/tools.ts
1192
+ /**
1193
+ * The settings file, or undefined when its path is not a real path on this machine. A test that
1194
+ * fakes another platform builds paths with that platform's separators; writing there would land
1195
+ * in the working directory, so nothing is read or written.
1196
+ */
1197
+ function settingsFile(ctx) {
1198
+ const path = dataPaths(ctx.platform, ctx.dataDir).settings;
1199
+ return isAbsolute(path) ? path : void 0;
1200
+ }
1201
+ /** The tools that already have Conveno's setup, whether or not their program is on PATH now. */
1202
+ async function connectedTools(ctx) {
1203
+ const env = adapterEnv(ctx);
1204
+ const out = [];
1205
+ for (const adapter of ctx.adapters) try {
1206
+ if (!(await adapter.plan(env)).some((c) => c.component === "mcp" && c.kind === "add")) out.push(adapter.cli);
1207
+ } catch {}
1208
+ return out;
1209
+ }
1210
+ /**
1211
+ * The saved choice. Installs from before the choice was saved have none: it is then taken, once,
1212
+ * from the tools that already have Conveno's setup and saved. Nothing saved and nothing set up
1213
+ * gives an empty list (the first setup has not happened).
1214
+ */
1215
+ async function chosenTools(ctx) {
1216
+ const path = settingsFile(ctx);
1217
+ const known = new Set(ctx.adapters.map((a) => a.cli));
1218
+ const saved = path ? readSettings(path).tools : void 0;
1219
+ if (saved) return saved.filter((c) => known.has(c));
1220
+ const derived = await connectedTools(ctx);
1221
+ if (path && derived.length > 0) try {
1222
+ writeSettings(path, { tools: derived });
1223
+ } catch {}
1224
+ return derived;
1225
+ }
1226
+ /**
1227
+ * Save the choice, after the setup worked. The lead must be one of the chosen tools: a new one is
1228
+ * kept, the earlier one stays while it is still chosen, and a lead that was dropped is cleared.
1229
+ */
1230
+ function saveChoice(ctx, tools, lead) {
1231
+ const path = settingsFile(ctx);
1232
+ if (!path) return;
1233
+ const next = lead ?? readSettings(path).leadCli;
1234
+ writeSettings(path, {
1235
+ tools: [...new Set(tools)],
1236
+ leadCli: next && tools.includes(next) ? next : null
1237
+ });
1238
+ }
1191
1239
  // src/init.ts
1192
1240
  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
1241
  /** Detect every adapter. A detection that throws counts as not installed. */
1195
1242
  async function detectAll(ctx, adapters = ctx.adapters) {
1196
1243
  const env = adapterEnv(ctx);
@@ -1231,6 +1278,24 @@ function parseCliList(raw, ctx) {
1231
1278
  }
1232
1279
  return out;
1233
1280
  }
1281
+ /**
1282
+ * The tools to set up: `--cli` when given (it becomes the saved choice), else the saved choice.
1283
+ * With neither there is nothing to go on, so the caller must ask for `--cli`.
1284
+ */
1285
+ async function toolsToSet(ctx, raw) {
1286
+ if (raw !== void 0) {
1287
+ const list = parseCliList(raw, ctx);
1288
+ return Array.isArray(list) ? {
1289
+ adapters: list,
1290
+ explicit: true
1291
+ } : list;
1292
+ }
1293
+ const saved = await chosenTools(ctx);
1294
+ return {
1295
+ adapters: ctx.adapters.filter((a) => saved.includes(a.cli)),
1296
+ explicit: false
1297
+ };
1298
+ }
1234
1299
  function printDetections(ctx, found) {
1235
1300
  const t = ctx.theme;
1236
1301
  ctx.out(`${t.bold("Looking for AI tools on this machine")}\n`);
@@ -1482,6 +1547,17 @@ async function runInit(ctx, argv, name = "init") {
1482
1547
  ref: "e_usage"
1483
1548
  });
1484
1549
  }
1550
+ if (typeof lead === "string") {
1551
+ const rawCli = early?.values.cli;
1552
+ const picked = await toolsToSet(ctx, typeof rawCli === "string" ? rawCli : void 0);
1553
+ if ("adapters" in picked && !picked.adapters.some((a) => a.cli === lead)) return fail(ctx, {
1554
+ what: `${lead} is not one of the chosen AI tools, so it can't lead`,
1555
+ detail: [`Chosen: ${picked.adapters.map((a) => a.cli).join(", ") || "none"}.`],
1556
+ fix: `Pass ${cmd(ctx.theme, `--cli ${lead}`)} too, or pick a lead from the list above.`,
1557
+ exit: 2,
1558
+ ref: "e_usage"
1559
+ });
1560
+ }
1485
1561
  const outcome = {};
1486
1562
  const code = await initSetup(ctx, argv, outcome, name);
1487
1563
  if (code !== 0) return code;
@@ -1515,11 +1591,19 @@ async function initSetup(ctx, argv, outcome, name) {
1515
1591
  exit: 2,
1516
1592
  ref: "e_usage"
1517
1593
  });
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,
1594
+ const picked = await toolsToSet(ctx, typeof values.cli === "string" ? values.cli : void 0);
1595
+ if (!("adapters" in picked)) return fail(ctx, {
1596
+ what: picked.message,
1521
1597
  fix: `Pass ${cmd(t, cliListExample(ctx))} or leave it out.`,
1522
- ...chosen.suggestion ? { didYouMean: chosen.suggestion } : {},
1598
+ ...picked.suggestion ? { didYouMean: picked.suggestion } : {},
1599
+ exit: 2,
1600
+ ref: "e_usage"
1601
+ });
1602
+ const chosen = picked.adapters;
1603
+ if (chosen.length === 0) return fail(ctx, {
1604
+ what: "No AI tools are chosen yet",
1605
+ detail: [`Choices: ${ctx.adapters.map((a) => a.cli).join(", ")}.`],
1606
+ fix: `Pass ${cmd(t, cliListExample(ctx))}, or run ${cmd(t, "conveno setup")} in a terminal to pick.`,
1523
1607
  exit: 2,
1524
1608
  ref: "e_usage"
1525
1609
  });
@@ -1576,7 +1660,10 @@ async function initSetup(ctx, argv, outcome, name) {
1576
1660
  }
1577
1661
  if (items.length === 0 && extras.length === 0) {
1578
1662
  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());
1663
+ if (!dryRun) {
1664
+ await approveTools(ctx, installed, accepted, /* @__PURE__ */ new Set());
1665
+ if (picked.explicit) saveChoice(ctx, installed.map((f) => f.adapter.cli));
1666
+ }
1580
1667
  outcome.offer = installed.map((f) => f.adapter);
1581
1668
  return 0;
1582
1669
  }
@@ -1611,7 +1698,7 @@ async function initSetup(ctx, argv, outcome, name) {
1611
1698
  ctx.out(" Restart open sessions so they pick up Conveno.\n");
1612
1699
  const approved = await approveTools(ctx, installed, applying, new Set(byCli.keys()), result.applied.backupDir);
1613
1700
  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`);
1701
+ if (picked.explicit) saveChoice(ctx, installed.map((f) => f.adapter.cli));
1615
1702
  ctx.out(` Next: ${cmd(t, "conveno status")} lists your sessions.\n`);
1616
1703
  outcome.offer = installed.map((f) => f.adapter);
1617
1704
  return 0;
@@ -1651,7 +1738,7 @@ async function runSetup(ctx, argv) {
1651
1738
  const parsed = parseFlags(ctx, spec, argv);
1652
1739
  if (typeof parsed === "number") return parsed;
1653
1740
  const v = parsed.values;
1654
- if (ctx.interactive && v.yes !== true && v["dry-run"] !== true) return (await import("./run-eCXO1SyO.js")).runTui(ctx, { start: "setup" });
1741
+ if (ctx.interactive && v.yes !== true && v["dry-run"] !== true) return (await import("./run-Df6vFm9n.js")).runTui(ctx, { start: "setup" });
1655
1742
  return runInit(ctx, argv, "setup");
1656
1743
  }
1657
1744
  // src/doctor.ts
@@ -1732,44 +1819,35 @@ async function inspect(ctx, adapter) {
1732
1819
  }
1733
1820
  }
1734
1821
  /**
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.
1822
+ * A warning for a CLI older than a known-broken floor: a version that lacks something Conveno
1823
+ * needs. Nothing else is flagged: a newer or untested version gets no warning, and doctor never
1824
+ * exits 1 for a version.
1738
1825
  */
1739
1826
  function versionBlock(t, adapter, version, status) {
1827
+ if (status.kind !== "older") return void 0;
1740
1828
  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
- };
1829
+ 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
1830
  }
1756
1831
  async function runDoctor(ctx, argv = []) {
1757
1832
  const t = ctx.theme;
1758
1833
  const spec = COMMANDS.find((c) => c.name === "doctor");
1759
1834
  let adapters = ctx.adapters;
1835
+ let chosen;
1760
1836
  if (spec) {
1761
1837
  const parsed = parseFlags(ctx, spec, argv);
1762
1838
  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,
1839
+ const picked = parseCliList(typeof parsed.values.cli === "string" ? parsed.values.cli : void 0, ctx);
1840
+ if (!Array.isArray(picked)) return fail(ctx, {
1841
+ what: picked.message,
1766
1842
  fix: `Pass ${cmd(t, cliListExample(ctx))} or leave it out.`,
1767
- ...chosen.suggestion ? { didYouMean: chosen.suggestion } : {},
1843
+ ...picked.suggestion ? { didYouMean: picked.suggestion } : {},
1768
1844
  exit: 2,
1769
1845
  ref: "e_usage"
1770
1846
  });
1771
- adapters = chosen;
1847
+ adapters = picked;
1848
+ if (typeof parsed.values.cli === "string") chosen = new Set(picked.map((a) => a.cli));
1772
1849
  }
1850
+ chosen ??= new Set(await chosenTools(ctx));
1773
1851
  let ok = 0;
1774
1852
  let warnings = 0;
1775
1853
  let problems = 0;
@@ -1833,14 +1911,25 @@ async function runDoctor(ctx, argv = []) {
1833
1911
  ]);
1834
1912
  continue;
1835
1913
  }
1914
+ if (!chosen.has(adapter.cli) && !(r.mcp === "ok" && (r.hooks === null || r.hooks === "ok"))) {
1915
+ table.push([
1916
+ ` ${t.glyph("offline")} ${adapter.cli}`,
1917
+ adapter.displayName,
1918
+ detection.version ?? "",
1919
+ "",
1920
+ "",
1921
+ "",
1922
+ q("not set up (not chosen)")
1923
+ ]);
1924
+ continue;
1925
+ }
1836
1926
  const good = r.mcp === "ok" && (r.hooks === null || r.hooks === "ok") && !r.planError;
1837
1927
  const compat = compatStatus(adapter.cli, detection.version, ctx.compat);
1838
1928
  const tiers = activeTiers(r);
1839
1929
  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
1930
  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");
1931
+ if (compat.kind === "older") note = `older than ${compat.minimum}, which Conveno needs`;
1932
+ const glyph = good && compat.kind !== "older" ? t.status("ok") : t.status("warn");
1844
1933
  table.push([
1845
1934
  ` ${glyph} ${adapter.cli}`,
1846
1935
  adapter.displayName,
@@ -1861,7 +1950,7 @@ async function runDoctor(ctx, argv = []) {
1861
1950
  ref: "e_config"
1862
1951
  }));
1863
1952
  } else if (good) {
1864
- if (compat.kind !== "older" && !(compat.kind === "newer" && compat.minor)) ok++;
1953
+ if (compat.kind !== "older") ok++;
1865
1954
  } else {
1866
1955
  warnings++;
1867
1956
  const named = [["the MCP server", r.mcp], ["the hooks", r.hooks]];
@@ -1873,9 +1962,8 @@ async function runDoctor(ctx, argv = []) {
1873
1962
  }
1874
1963
  const versionNote = versionBlock(t, adapter, detection.version, compat);
1875
1964
  if (versionNote) {
1876
- notes.push(versionNote.text);
1877
- if (versionNote.problem) problems++;
1878
- else warnings++;
1965
+ notes.push(versionNote);
1966
+ warnings++;
1879
1967
  }
1880
1968
  }
1881
1969
  ctx.out(`${columns(table).join("\n")}\n`);
@@ -2014,6 +2102,8 @@ async function runUninstall(ctx, argv) {
2014
2102
  return 1;
2015
2103
  }
2016
2104
  if (items.length === 0) {
2105
+ const stopped = await stopDaemonIfRunning(ctx);
2106
+ if (stopped !== 0) return stopped;
2017
2107
  ctx.out(`${t.status("ok")} Nothing to remove. No Conveno entries were found in any supported CLI.\n`);
2018
2108
  return 0;
2019
2109
  }
@@ -2031,4 +2121,4 @@ async function runUninstall(ctx, argv) {
2031
2121
  ctx.out(" Removed the Conveno entries. Restart open sessions to drop Conveno.\n");
2032
2122
  return 0;
2033
2123
  }
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 };
2124
+ export { showCode as A, runRelay as C, runAccount as D, openInBrowser as E, runLogin as O, runDevices as S, stopDaemonIfRunning as T, saveChoice as _, applyOptions as a, unifiedDiff as b, collectPlans as c, refreshManifest as d, renewedApprovals as f, connectedTools as g, chosenTools as h, runDoctor as i, runLogout 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, StaleError as v, runDaemon as w, PAIR_TIMEOUT_MS as x, applyChanges as y };
@@ -1,8 +1,8 @@
1
- import { n as isOneShotGrok } from "./dist-DaIpdMke.js";
2
- import { $ as isFromOwner, Mt as renderBody, Ut as senderOf, Vt as runWaker } from "./dist-STNJjbNH.js";
1
+ import { n as isOneShotGrok } from "./dist-DF0nL8wE.js";
2
+ import { Yt as senderOf, it as isFromOwner, qt as runWaker, zt as renderBody } from "./dist-CRj_cuHc.js";
3
3
  import { n as connectOpts } from "./ctx-tYftvhz_.js";
4
- import { t as daemonProblem } from "./daemonError-C05GqdhQ.js";
5
- import { t as findSession } from "./pick-DLp6w_-z.js";
4
+ import { t as daemonProblem } from "./daemonError-0KnkgIRo.js";
5
+ import { t as findSession } from "./pick-BmZuv9yQ.js";
6
6
  // src/watch.ts
7
7
  const CONNECT_MAX_RETRY_MS = 3e4;
8
8
  const CONNECT_GIVE_UP_MS = 3e5;
@@ -80,7 +80,27 @@ function watchLines(messages, orchestrator) {
80
80
  }
81
81
  /** The one line a watcher prints in a one-shot run. The rules file tells the agent not to restart it. */
82
82
  const ONE_SHOT_TEXT = "[conveno] watch ended: this Grok run is one-shot (grok -p), so nothing wakes it. Do not start the watcher again.";
83
- const USAGE = "[conveno] watch needs a session name. The conveno whoami tool gives it.";
83
+ const USAGE = "[conveno] watch needs a session name, and may take --conversation <id>. The conveno whoami tool gives the name.";
84
+ /** The conversation id the agent was asked to pass: plain characters, short. */
85
+ const CONVERSATION = /^[A-Za-z0-9_.:-]{1,128}$/;
86
+ /**
87
+ * `<session name> [--conversation <id>]`. The id is the Grok conversation the watcher serves: once
88
+ * the window's session moves to another conversation the daemon calls the watcher superseded.
89
+ * Null for anything else.
90
+ */
91
+ function parseWatchArgs(argv) {
92
+ const [name, ...rest] = argv;
93
+ if (!name || name.startsWith("--")) return null;
94
+ if (rest.length === 0) return { name };
95
+ const [flag, value] = rest;
96
+ let id;
97
+ if (flag?.startsWith("--conversation=") && rest.length === 1) id = flag.slice(15);
98
+ else if (flag === "--conversation" && rest.length === 2) id = value;
99
+ return id !== void 0 && CONVERSATION.test(id) ? {
100
+ name,
101
+ conversation: id
102
+ } : null;
103
+ }
84
104
  /** Reasons the waker stops that are not a failure of the watcher. */
85
105
  const CLEAN_STOPS = /* @__PURE__ */ new Set([
86
106
  "aborted",
@@ -101,11 +121,12 @@ const STOP_TEXT = {
101
121
  * nothing but `[conveno]` lines, on stdout, because Grok reads the monitor's stdout.
102
122
  */
103
123
  async function runWatch(ctx, argv, deps = {}) {
104
- const [name, ...extra] = argv;
105
- if (!name || extra.length > 0) {
124
+ const args = parseWatchArgs(argv);
125
+ if (!args) {
106
126
  ctx.out(`${USAGE}\n`);
107
127
  return 2;
108
128
  }
129
+ const { name, conversation } = args;
109
130
  const ancestry = await ctx.ancestry(2e3).catch(() => void 0);
110
131
  const host = ancestry?.entries.find((e) => e.pid === ancestry.hostPid);
111
132
  if (isOneShotGrok(host?.command)) {
@@ -135,6 +156,7 @@ async function runWatch(ctx, argv, deps = {}) {
135
156
  client,
136
157
  sessionId: session.id,
137
158
  signal: controller.signal,
159
+ ...conversation === void 0 ? {} : { nativeId: conversation },
138
160
  inject: async (_text, messages, batch) => {
139
161
  const lines = watchLines(messages, batch?.orchestrator ?? null);
140
162
  if (lines.length === 0) return false;