@conveno/cli 0.2.0-rc.15 → 0.2.0-rc.16

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,7 @@ conveno init
25
25
 
26
26
  Then open two CLI sessions, for example Claude Code and Codex. Make one the lead (in the app, with `conveno lead <session>`, or by asking it to coordinate) and ask it to hand out work. The other session wakes up and starts. `conveno status` lists the sessions.
27
27
 
28
- Or run `conveno` with no arguments. It opens a full-screen app (Sessions, New, Devices, Setup) for the keyboard and mouse: `/` searches, `?` shows the keys. Turn the mouse off in Setup or with `CONVENO_MOUSE=0`.
28
+ Or run `conveno` with no arguments. It opens a full-screen app for the keyboard and mouse: a table of your sessions with an Activity box and a detail pane, and a menu (`/` or ctrl+p) whose screens open as dialogs. `?` shows the keys. Turn the mouse off in Setup or with `CONVENO_MOUSE=0`.
29
29
 
30
30
  `conveno uninstall` reverts what `init` did. A file that has not changed since `init` is restored byte for byte. If a CLI has rewritten it since, only Conveno's entries are removed.
31
31
 
@@ -39,7 +39,7 @@ Or run `conveno` with no arguments. It opens a full-screen app (Sessions, New, D
39
39
  | `conveno send <to> <text...> [--urgent]` | Send a message as you to a session name or id, `lead`, or `device:name`. `-` reads the text from standard input. |
40
40
  | `conveno rename <session> <new-name>` | Rename an online session. |
41
41
  | `conveno lead <session>` | Make a session the lead. `conveno lead --clear` leaves no lead. |
42
- | `conveno spawn <cli> [--cwd <dir>] [--name <name>] [--task <text> \| --task-file <path>] [--window] [--access <read\|edit\|full>] [--yes]` | Start a worker session of `claude`, `codex`, `opencode`, `antigravity` or `grok`, and print its name once it registers. The CLI must be installed. By default the worker runs in the background through the CLI's Agent Client Protocol server, with `conveno acp-host` driving it. It keeps running: each message sent to it becomes its next prompt at once when it is idle, or when its current turn ends. `--window` opens the real CLI in a new terminal instead, so you can watch it and take over: Windows Terminal (`wt -w 0 new-tab`, else a new console window) on Windows, Terminal.app (iTerm2 when it is your terminal) on macOS, and on Linux a new tmux window when you are inside tmux, else the first of `x-terminal-emulator`, `gnome-terminal`, `konsole`, `kitty`, `wezterm`, `alacritty` and `xterm`. The ACP commands are `claude-agent-acp` (install `@agentclientprotocol/claude-agent-acp`), `codex-acp` (install `@agentclientprotocol/codex-acp`), `opencode acp`, `agy acp` and `grok agent stdio`; a missing one is an error that says what to install. For Claude Code and Codex, `conveno init` can allow running the adapter with `npx -y <package>@<pinned version>`, and `CONVENO_ACP_CODEX_CMD` / `CONVENO_ACP_CLAUDE_CMD` replace the command. In the background a tool call the `--access` preset (`read`, `edit` or `full`; default `full`) does not cover is asked of the session that spawned the worker. The first task is optional. `--name` sets the session name (a taken or reserved one is refused); otherwise the usual `<cli>@<repo>-<n>` name is used. `--cwd` defaults to the current folder, which must be inside your home folder; an explicit `--cwd` can be anywhere. It asks first and `--yes` skips the question; without a terminal it exits 2 unless `--yes` is given. At most 8 spawned sessions run at once (`CONVENO_SPAWN_MAX` changes that), and a spawned session cannot spawn more than 3 levels deep. A task is at most 16000 characters. See `packages/protocol/PROTOCOL.md`. |
42
+ | `conveno spawn <cli> [--cwd <dir>] [--name <name>] [--task <text> \| --task-file <path>] [--window] [--access <read\|edit\|full>] [--model <name>] [--effort <name>] [--yes]` | Start a worker session of `claude`, `codex`, `opencode`, `antigravity` or `grok`, and print its name once it registers. The CLI must be installed. By default the worker runs in the background through the CLI's Agent Client Protocol server, with `conveno acp-host` driving it. It keeps running: each message sent to it becomes its next prompt at once when it is idle, or when its current turn ends. `--window` opens the real CLI in a new terminal instead, so you can watch it and take over: Windows Terminal (`wt -w 0 new-tab`, else a new console window) on Windows, Terminal.app (iTerm2 when it is your terminal) on macOS, and on Linux a new tmux window when you are inside tmux, else the first of `x-terminal-emulator`, `gnome-terminal`, `konsole`, `kitty`, `wezterm`, `alacritty` and `xterm`. The ACP commands are `claude-agent-acp` (install `@agentclientprotocol/claude-agent-acp`), `codex-acp` (install `@agentclientprotocol/codex-acp`), `opencode acp`, `agy acp` and `grok agent stdio`; a missing one is an error that says what to install. For Claude Code and Codex, `conveno init` can allow running the adapter with `npx -y <package>@<pinned version>`, and `CONVENO_ACP_CODEX_CMD` / `CONVENO_ACP_CLAUDE_CMD` replace the command. In the background a tool call the `--access` preset (`read`, `edit` or `full`; default `full`) does not cover is asked of the session that spawned the worker. The first task is optional. `--name` sets the session name (a taken or reserved one is refused); otherwise the usual `<cli>@<repo>-<n>` name is used. `--cwd` defaults to the current folder, which must be inside your home folder; an explicit `--cwd` can be anywhere. It asks first and `--yes` skips the question; without a terminal it exits 2 unless `--yes` is given. At most 8 spawned sessions run at once (`CONVENO_SPAWN_MAX` changes that), and a spawned session cannot spawn more than 3 levels deep. `--model` and `--effort` pick the CLI's own model and effort names; without them your setting for that CLI applies, else the CLI's default. A task is at most 16000 characters. See `packages/protocol/PROTOCOL.md`. |
43
43
  | `conveno stop <worker>` | Stop a background worker. It cancels a running turn, ends its CLI and the processes it started, tells the spawning session why, and goes offline. A worker in a window is yours to close. |
44
44
  | `conveno doctor [--cli <list>]` | Check each CLI and the daemon, and say how to fix what is wrong. `--cli claude,codex` checks only those CLIs, so problems in the others do not count. |
45
45
  | `conveno devices [pair\|join\|revoke\|rename\|accept\|reset]` | Pro. List your devices, or pair a new machine: `pair` on one device and `join` on the new one at the same time, then type the 8-digit code each screen shows. `revoke` removes a device for good. Needs a Pro login on both. |
@@ -1,8 +1,10 @@
1
1
  import { writeFileSync } from "node:fs";
2
- import { n as runAcpHostFromFile, r as stopRequestPath, t as killProcessTree } from "./dist-fI_XSoCQ.js";
3
- import { Kt as readSpawnRecord, an as spawnRecordPath } from "./dist-ZL7d4_97.js";
4
- import { a as parseFlags, n as COMMANDS } from "./args-CpAvszNY.js";
2
+ import { i as stopRequestPath, r as runAcpHostFromFile, t as killProcessTree } from "./dist-DVLAWfDg.js";
3
+ import { Qt as readSpawnRecord, dn as spawnRecordOfSession, fn as spawnRecordPath } from "./dist-DnWOZkAu.js";
4
+ import { a as parseFlags, n as COMMANDS } from "./args-CtyKPZuN.js";
5
+ import { n as connectOpts } from "./ctx-tYftvhz_.js";
5
6
  import { a as fail, n as cmd } from "./fmt-C2SsP5Y0.js";
7
+ import { t as findSession } from "./pick-UDFASnAn.js";
6
8
  // src/acp.ts
7
9
  /** How long `conveno stop` waits for a worker to end by itself before it ends the process tree. */
8
10
  const STOP_WAIT_MS = 1e4;
@@ -32,14 +34,26 @@ async function runAcpHostCmd(ctx, argv) {
32
34
  });
33
35
  }
34
36
  }
35
- function findWorker(ctx, name, command) {
37
+ /**
38
+ * The worker `name` means: a session's name now, which a rename may have changed, or, when no
39
+ * online session has that name, the name it was spawned with (its record's file name).
40
+ */
41
+ async function findWorker(ctx, name, command) {
36
42
  if (!name) return fail(ctx, {
37
43
  what: `conveno ${command} needs a worker name`,
38
44
  fix: `Run ${cmd(ctx.theme, "conveno status")} to see the names.`,
39
45
  exit: 2,
40
46
  ref: "e_usage"
41
47
  });
42
- const rec = /^[a-z0-9][a-z0-9._@-]{0,63}$/.test(name) ? readSpawnRecord(spawnRecordPath(ctx.dataDir, name)) : void 0;
48
+ const live = await byCurrentName(ctx, name);
49
+ if (live === null) return fail(ctx, {
50
+ what: `${name} is not a worker started here`,
51
+ detail: ["Only sessions started by conveno spawn or spawn_session on this machine are workers."],
52
+ fix: `Run ${cmd(ctx.theme, "conveno status")} to see the names.`,
53
+ exit: 1,
54
+ ref: "e_not_found"
55
+ });
56
+ const rec = live ?? (/^[a-z0-9][a-z0-9._@-]{0,63}$/.test(name) ? readSpawnRecord(spawnRecordPath(ctx.dataDir, name)) : void 0);
43
57
  if (!rec) return fail(ctx, {
44
58
  what: `No running worker named "${name}"`,
45
59
  detail: ["Only sessions started by conveno spawn or spawn_session on this machine are workers."],
@@ -50,6 +64,24 @@ function findWorker(ctx, name, command) {
50
64
  return rec;
51
65
  }
52
66
  /**
67
+ * The record of the online session named `name`, through the daemon; null when that session has
68
+ * no record (it is not a worker started here). Undefined when no online session has that name, or
69
+ * the daemon is not running.
70
+ */
71
+ async function byCurrentName(ctx, name) {
72
+ const client = await ctx.connect(connectOpts(ctx, false)).catch(() => void 0);
73
+ if (!client) return void 0;
74
+ try {
75
+ const session = await findSession(client, name);
76
+ if (!session) return void 0;
77
+ return spawnRecordOfSession(ctx.dataDir, session.id) ?? null;
78
+ } catch {
79
+ return;
80
+ } finally {
81
+ await client.close().catch(() => void 0);
82
+ }
83
+ }
84
+ /**
53
85
  * `conveno stop <worker>`. An ACP worker gets a stop request: its host sends `session/cancel` for
54
86
  * a running turn, ends the agent, reports to the spawner and takes the session offline. A worker in a
55
87
  * terminal window is the user's to close.
@@ -60,7 +92,7 @@ async function runStop(ctx, argv) {
60
92
  const parsed = parseFlags(ctx, spec, argv);
61
93
  if (typeof parsed === "number") return parsed;
62
94
  const [name] = parsed.positionals;
63
- const rec = findWorker(ctx, name, "stop");
95
+ const rec = await findWorker(ctx, name, "stop");
64
96
  if (typeof rec === "number") return rec;
65
97
  const t = ctx.theme;
66
98
  if (!rec.acp) return fail(ctx, {
@@ -76,7 +108,7 @@ async function runStop(ctx, argv) {
76
108
  while (alive() && Date.now() < end) await new Promise((r) => setTimeout(r, 100));
77
109
  if (alive() && rec.pid !== void 0) killProcessTree(rec.pid, ctx.platform);
78
110
  if (rec.agentPid !== void 0 && ctx.isAlive(rec.agentPid)) killProcessTree(rec.agentPid, ctx.platform);
79
- ctx.out(`${t.status("ok")} ${t.bold(`Stopped ${rec.name}`)}\n`);
111
+ ctx.out(`${t.status("ok")} ${t.bold(`Stopped ${name ?? rec.name}`)}\n`);
80
112
  return 0;
81
113
  }
82
114
  export { runAcpHostCmd, runStop };
@@ -1,6 +1,6 @@
1
1
  import { execFile } from "node:child_process";
2
- import { t as RELAY_SUBCOMMAND } from "./dist-Bv1bmmme.js";
3
- import { nn as runWaker } from "./dist-ZL7d4_97.js";
2
+ import { t as RELAY_SUBCOMMAND } from "./dist-XoKXwG-y.js";
3
+ import { cn as runWaker } from "./dist-DnWOZkAu.js";
4
4
  import { n as connectOpts } from "./ctx-tYftvhz_.js";
5
5
  // src/agy-relay.ts
6
6
  /**
@@ -163,6 +163,16 @@ const COMMANDS = [
163
163
  value: "<read|edit|full>",
164
164
  help: "Background: what the worker may do without asking (default: your setting, full unless changed)"
165
165
  },
166
+ model: {
167
+ type: "string",
168
+ value: "<name>",
169
+ help: "The CLI's own model name (default: your setting for that CLI, else the CLI's default)"
170
+ },
171
+ effort: {
172
+ type: "string",
173
+ value: "<name>",
174
+ help: "The CLI's own effort name (default: your setting for that CLI, else the CLI's default)"
175
+ },
166
176
  yes: {
167
177
  type: "boolean",
168
178
  short: "y",
@@ -170,6 +180,8 @@ const COMMANDS = [
170
180
  }
171
181
  },
172
182
  notes: [
183
+ "--model and --effort pick the model and effort by the CLI's own names. A name the CLI does not offer",
184
+ "leaves its default. In a window they become the CLI's launch flags; OpenCode has no effort flag.",
173
185
  "--access sets what a background worker may do without asking: read (look only), edit (also",
174
186
  "change files and fetch pages) or full (everything). Without it, your setting applies; full unless changed.",
175
187
  "By default the worker runs in the background over ACP and stays alive. Each message sent to",
package/dist/bin.js CHANGED
@@ -40,9 +40,9 @@ for (const stream of [process.stdout, process.stderr]) stream.on("error", (err)
40
40
  });
41
41
  try {
42
42
  let code;
43
- if (isHook) code = await (await import("./hook-entry-CmuvppGf.js")).runHookEntry(argv.slice(1));
43
+ if (isHook) code = await (await import("./hook-entry-DY-CMxKE.js")).runHookEntry(argv.slice(1));
44
44
  else {
45
- const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-1QSm5UjR.js"), import("./runtime-CeFKWoIL.js")]);
45
+ const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-DVIyOy85.js"), import("./runtime-CU-5JQvj.js")]);
46
46
  code = await main(argv, createRuntimeCtx());
47
47
  }
48
48
  if (isHook) process.exit(code);
package/dist/daemon.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
  import { homedir, hostname, userInfo } from "node:os";
3
- import { t as codexAdapter } from "./dist-DDzIkwf9.js";
4
- import { $ as formatContinuation, $n as sanitizeLine, $t as resolveRecipient, A as claimOrchestrator, B as dataDir, Bn as defaultSocketPath, Bt as readAccountTokens, Ct as oneWindowPerHost, D as autoLimitsFromEnv, E as autoCandidates, En as EVENT_NAMES, Gn as makeEventNotification, Gt as readSettings, H as decideAutoContinue, In as SESSION_ENDED_TEXT, It as planSpawn, Jn as newMessageId, Kn as makeResult, L as createWmiWalker, M as clearOrchestrator, Mn as PROTOCOL_VERSION, N as clientProof, Nn as RelayPayload, O as baseName, Pn as RpcErrorCode, Qn as safeParse, R as currentAccessToken, Rn as SessionId, Rt as proofsMatch, S as appendHookLog, St as newAuthNonce, Tn as DeviceId, U as defaultProcessIo, Un as isSocketPathTooLong, Ut as readInbox, V as dataPaths, Vn as encodeFrame, Vt as readAncestry, W as detectRepo, Wn as makeError, Xn as parseIpcRequest, Xt as requeueEntries, Y as evaluateLiveness, Yn as newSessionId, Zn as parseRelayFrame, _ as ackEntries, _t as leadLogPath, bt as markDelivered, cn as statusAfterLiveness, dn as takeWithinChars, dt as isOnline, er as socketPathTooLongMessage, et as formatHookContext, fn as tooManyUnreadMessage, ft as jwtClaim, gn as validateRename, gt as leadLogLine, i as ConvenoError, jn as OWNER_SESSION_ID, k as bindAccountDevice, kn as Message, kt as pendingForInjection, l as RESPONSE_BUDGET_BYTES, n as AccountError, nt as generateSessionName, pn as turnHops, q as effectiveHolder, qn as newDeviceId, rt as holderAfterDeparture, un as takeWithinBytes, z as daemonProof, zn as createLineDecoder } from "./dist-ZL7d4_97.js";
3
+ import { t as codexAdapter } from "./dist-X1bpJWck.js";
4
+ import { $n as makeEventNotification, A as bindAccountDevice, B as currentAccessToken, Bn as PROTOCOL_VERSION, C as appendHookLog, Cn as validateRename, Ct as markDelivered, D as autoCandidates, Dt as newAuthNonce, F as clientProof, G as defaultProcessIo, Gt as readAccountTokens, H as dataDir, Hn as RpcErrorCode, Jn as defaultSocketPath, Jt as readInbox, K as detectRepo, Kn as SessionId, Kt as readAncestry, Ln as Message, Nn as DeviceId, O as autoLimitsFromEnv, Ot as oneWindowPerHost, P as clearOrchestrator, Pn as EVENT_NAMES, Pt as pendingForInjection, Qn as makeError, U as dataPaths, Ut as proofsMatch, V as daemonProof, Vn as RelayPayload, Vt as planSpawn, W as decideAutoContinue, Wn as SESSION_ENDED_TEXT, Y as effectiveHolder, Yn as encodeFrame, Z as evaluateLiveness, Zn as isSocketPathTooLong, Zt as readSettings, _n as takeWithinBytes, an as resolveRecipient, ar as parseRelayFrame, at as generateSessionName, bn as turnHops, bt as leadLogPath, cr as socketPathTooLongMessage, er as makeResult, hn as statusAfterLiveness, ht as jwtClaim, i as ConvenoError, ir as parseIpcRequest, j as claimOrchestrator, k as baseName, mt as isOnline, n as AccountError, nn as requeueEntries, nr as newMessageId, nt as formatContinuation, or as safeParse, ot as holderAfterDeparture, qn as createLineDecoder, rr as newSessionId, rt as formatHookContext, sr as sanitizeLine, tr as newDeviceId, u as RESPONSE_BUDGET_BYTES, v as ackEntries, vn as takeWithinChars, yn as tooManyUnreadMessage, yt as leadLogLine, z as createWmiWalker, zn as OWNER_SESSION_ID } from "./dist-DnWOZkAu.js";
5
5
  import { randomBytes } from "node:crypto";
6
6
  import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
7
7
  import { connect, createServer } from "node:net";
8
8
  import { dirname, join, posix, win32 } from "node:path";
9
- import { _ as sasMatches, a as JoinerPairing, b as signRelayHello, c as decodePairMessage, d as forkPoint, f as generateIdentity, g as publicRecord, h as parseIdentity, i as InviterPairing, l as deviceFingerprint, m as openEnvelope, n as ENVELOPE_MAX_AGE_MS, o as appendRevoke, p as headMatches, r as ENVELOPE_MAX_FUTURE_MS, s as chainHead, t as CryptoError, u as encodePairMessage, v as sealEnvelope, x as verifyChain, y as serializeIdentity } from "./dist-Bx22a5AV.js";
9
+ import { _ as sasMatches, a as JoinerPairing, b as signRelayHello, c as decodePairMessage, d as forkPoint, f as generateIdentity, g as publicRecord, h as parseIdentity, i as InviterPairing, l as deviceFingerprint, m as openEnvelope, n as ENVELOPE_MAX_AGE_MS, o as appendRevoke, p as headMatches, r as ENVELOPE_MAX_FUTURE_MS, s as chainHead, t as CryptoError, u as encodePairMessage, v as sealEnvelope, x as verifyChain, y as serializeIdentity } from "./dist-fwpPA9AY.js";
10
10
  import { execFileSync } from "node:child_process";
11
11
  import { DatabaseSync } from "node:sqlite";
12
12
  // ../daemon/src/lifecycle.ts
@@ -1949,6 +1949,19 @@ var Store = class {
1949
1949
  this.run("DELETE FROM messages WHERE id NOT IN (SELECT message_id FROM mailbox)");
1950
1950
  this.run("DELETE FROM sessions WHERE id = ?", id);
1951
1951
  }
1952
+ /**
1953
+ * The newest `limit` messages from one session to another, newest first, with who got each.
1954
+ * Never system messages, nor ones to or from the owner.
1955
+ */
1956
+ recentMessages(limit) {
1957
+ return this.all(`SELECT m.json, b.session_id FROM mailbox b JOIN messages m ON m.id = b.message_id
1958
+ WHERE b.session_id != ? AND json_extract(m.json, '$.kind') != 'system'
1959
+ AND json_extract(m.json, '$.from') != ?
1960
+ ORDER BY b.queued_at DESC, b.rowid DESC LIMIT ?`, OWNER_SESSION_ID, OWNER_SESSION_ID, limit).map((r) => ({
1961
+ message: Message.parse(JSON.parse(r.json)),
1962
+ recipient: r.session_id
1963
+ }));
1964
+ }
1952
1965
  /** Mailbox entries of one session, optionally limited to the given states or message ids. */
1953
1966
  entries(sessionId, filter = {}) {
1954
1967
  let sql = `SELECT m.json, b.state, b.queued_at, b.delivered_at, b.read_at, b.acked_at, b.hops
@@ -1970,7 +1983,7 @@ var Store = class {
1970
1983
  }
1971
1984
  };
1972
1985
  // ../daemon/src/server.ts
1973
- const DAEMON_VERSION = "0.2.0-rc.15";
1986
+ const DAEMON_VERSION = "0.2.0-rc.16";
1974
1987
  /** A connection that has not finished the handshake by then is closed. */
1975
1988
  const AUTH_TIMEOUT_MS = 5e3;
1976
1989
  /** Unread messages one session may hold. */
@@ -2048,6 +2061,8 @@ var Daemon = class {
2048
2061
  /** Permission requests of workers that wait for their spawner, by request id. In memory only. */
2049
2062
  /** When each session last sent a message (since this daemon started). */
2050
2063
  lastSent = /* @__PURE__ */ new Map();
2064
+ /** The model label a worker host reported at registration. Memory only. */
2065
+ modelLabels = /* @__PURE__ */ new Map();
2051
2066
  asks = /* @__PURE__ */ new Map();
2052
2067
  /** When each session went offline, for the removal grace. In memory only. */
2053
2068
  offlineSince = /* @__PURE__ */ new Map();
@@ -2164,7 +2179,11 @@ var Daemon = class {
2164
2179
  case "hello": return this.hello(conn, req.params);
2165
2180
  case "auth": return this.auth(conn, req.params);
2166
2181
  case "session.register": return this.registerAsync(req.params);
2167
- case "session.heartbeat": return this.heartbeat(req.params.sessionId, req.params.pid);
2182
+ case "session.heartbeat": {
2183
+ const beat = this.heartbeat(req.params.sessionId, req.params.pid);
2184
+ if (req.params.model !== void 0) this.setModelLabel(req.params.sessionId, req.params.model);
2185
+ return beat;
2186
+ }
2168
2187
  case "session.unregister": return this.unregister(req.params.sessionId, req.params.pid);
2169
2188
  case "session.remove": return this.remove(req.params.sessionId);
2170
2189
  case "session.rename": return this.rename(req.params);
@@ -2185,6 +2204,7 @@ var Daemon = class {
2185
2204
  case "permission.answer": return this.permissionAnswer(req.params);
2186
2205
  case "message.send": return this.sendMessage(req.params);
2187
2206
  case "owner.send": return this.ownerSend(conn, req.params);
2207
+ case "message.recent": return this.recent(conn, req.params);
2188
2208
  case "message.inbox": return this.inbox(req.params);
2189
2209
  case "message.deliver": return this.deliver(req.params);
2190
2210
  case "message.ack": return this.ack(req.params);
@@ -2248,7 +2268,8 @@ var Daemon = class {
2248
2268
  deliveryTier: tier
2249
2269
  }, holder?.id === row.id, this.store.unreadCount(row.id) + this.stalledWoken(row.id)),
2250
2270
  wakeable: tier === "live" || tier === "acp",
2251
- ...this.lastSent.has(row.id) ? { lastSentAt: this.lastSent.get(row.id) } : {}
2271
+ ...this.lastSent.has(row.id) ? { lastSentAt: this.lastSent.get(row.id) } : {},
2272
+ ...this.modelLabels.has(row.id) ? { model: this.modelLabels.get(row.id) } : {}
2252
2273
  };
2253
2274
  }
2254
2275
  /** The orchestrator as routing sees it: the holder, if it is online. */
@@ -2352,6 +2373,7 @@ var Daemon = class {
2352
2373
  return r;
2353
2374
  });
2354
2375
  this.attachedOf(row);
2376
+ if (p.model !== void 0) this.setModelLabel(row.id, p.model);
2355
2377
  this.emitSession(row.id, "registered");
2356
2378
  this.claimPreferredLead(row);
2357
2379
  return { session: this.view(this.store.getSession(row.id) ?? row) };
@@ -2391,6 +2413,12 @@ var Daemon = class {
2391
2413
  this.emitSession(sessionId, "updated");
2392
2414
  return { lastSeenAt: at };
2393
2415
  }
2416
+ /** The model label a session reports, as one line of plain text (it is shown in a terminal). */
2417
+ setModelLabel(sessionId, model) {
2418
+ const clean = sanitizeLine(model);
2419
+ if (clean === "") this.modelLabels.delete(sessionId);
2420
+ else this.modelLabels.set(sessionId, clean);
2421
+ }
2394
2422
  depart(sessionId, change) {
2395
2423
  const before = this.store.holder();
2396
2424
  const after = holderAfterDeparture(before, sessionId);
@@ -2459,6 +2487,8 @@ var Daemon = class {
2459
2487
  this.offlineSince.delete(sessionId);
2460
2488
  this.attached.delete(sessionId);
2461
2489
  this.hookAt.delete(sessionId);
2490
+ this.lastSent.delete(sessionId);
2491
+ this.modelLabels.delete(sessionId);
2462
2492
  this.settleAsksOf(sessionId);
2463
2493
  this.emit({
2464
2494
  event: "session.updated",
@@ -2730,6 +2760,8 @@ var Daemon = class {
2730
2760
  this.attached.delete(from.id);
2731
2761
  this.hookAt.delete(from.id);
2732
2762
  this.offlineSince.delete(from.id);
2763
+ this.lastSent.delete(from.id);
2764
+ this.modelLabels.delete(from.id);
2733
2765
  this.relay?.sessionsChanged();
2734
2766
  if (lead) this.emit({
2735
2767
  event: "orchestrator.changed",
@@ -2762,6 +2794,8 @@ var Daemon = class {
2762
2794
  this.offlineSince.delete(r.id);
2763
2795
  this.attached.delete(r.id);
2764
2796
  this.hookAt.delete(r.id);
2797
+ this.lastSent.delete(r.id);
2798
+ this.modelLabels.delete(r.id);
2765
2799
  }
2766
2800
  }
2767
2801
  leadName(id) {
@@ -2990,6 +3024,29 @@ var Daemon = class {
2990
3024
  requireCli(conn, what) {
2991
3025
  if (conn.client !== "cli") throw new ConvenoError(RpcErrorCode.Unauthorized, `Only the conveno command and app can ${what}. A session cannot act as the owner.`);
2992
3026
  }
3027
+ /** The last messages between sessions, oldest first, for the app's activity list. */
3028
+ recent(conn, p) {
3029
+ this.requireCli(conn, "list recent messages");
3030
+ return { messages: this.store.recentMessages(p.limit).flatMap(({ message: m, recipient }) => {
3031
+ if (m.kind === "system") return [];
3032
+ const to = this.store.getSession(recipient);
3033
+ if (!to) return [];
3034
+ const said = sanitizeLine(m.kind === "text" ? firstLineOf(m.body.text) : m.body.goal);
3035
+ const chars = [...said];
3036
+ const text = chars.length > 200 ? `${chars.slice(0, 199).join("")}…` : said;
3037
+ return [{
3038
+ id: m.id,
3039
+ from: m.from,
3040
+ ...m.fromName !== void 0 ? { fromName: m.fromName } : {},
3041
+ ...m.fromCli !== void 0 ? { fromCli: m.fromCli } : {},
3042
+ to: to.id,
3043
+ toName: to.name,
3044
+ toCli: to.cli,
3045
+ text,
3046
+ createdAt: m.createdAt
3047
+ }];
3048
+ }).reverse() };
3049
+ }
2993
3050
  ownerSend(conn, p) {
2994
3051
  this.requireCli(conn, "send as the owner");
2995
3052
  return this.deliverFrom({
@@ -3536,6 +3593,10 @@ async function startDaemon(opts) {
3536
3593
  throw e;
3537
3594
  }
3538
3595
  }
3596
+ /** The first line of a text that has something on it. */
3597
+ function firstLineOf(text) {
3598
+ return text.split(/\r?\n/).find((l) => l.trim() !== "") ?? "";
3599
+ }
3539
3600
  // ../daemon/src/bin.ts
3540
3601
  async function main() {
3541
3602
  const handle = await startDaemon({
@@ -1,4 +1,4 @@
1
- import { t as ClientError } from "./dist-C59LTq60.js";
1
+ import { t as ClientError } from "./dist-Ch3ohbIk.js";
2
2
  import { n as cmd, s as plainError } from "./fmt-C2SsP5Y0.js";
3
3
  // src/daemonError.ts
4
4
  /**
@@ -1,6 +1,6 @@
1
1
  import { readFile } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { At as pendingHookContext, C as askedKey, G as dropFromList, Ht as readCommandLine, J as endTurnContinuation, K as editJson, Pt as planLauncher, Tt as parseCliVersion, U as defaultProcessIo, X as existedBefore, a as FROM_USER_NOTICE, c as ORCHESTRATOR_TASK_NOTICE, mn as uninstallLauncher, pt as late, rn as sameJson, s as NOT_FROM_USER_NOTICE, st as hostPidOf, ut as isObject, vt as loadJson, w as askedMarker, wt as ownSession, x as agentCommand, xt as needsQuoting, zt as putInList } from "./dist-ZL7d4_97.js";
3
+ import { At as parseCliVersion, Et as needsQuoting, Ft as pendingHookContext, G as defaultProcessIo, J as editJson, Q as existedBefore, S as agentCommand, T as askedMarker, Wt as putInList, X as endTurnContinuation, a as FROM_USER_NOTICE, gt as late, kt as ownSession, l as ORCHESTRATOR_TASK_NOTICE, ln as sameJson, pt as isObject, q as dropFromList, qt as readCommandLine, s as NOT_FROM_USER_NOTICE, ut as hostPidOf, w as askedKey, xn as uninstallLauncher, xt as loadJson, zt as planLauncher } from "./dist-DnWOZkAu.js";
4
4
  import { n as cs, t as Za } from "./toml-patch-DGzVRdd1.js";
5
5
  // ../adapters/grok/dist/index.js
6
6
  const SERVER_NAME = "conveno";
@@ -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 { B as dataDir, Bn as defaultSocketPath, Fn as RpcResponse, Hn as ipcMethods, Mn as PROTOCOL_VERSION, N as clientProof, On as EventPayload, Pn as RpcErrorCode, Rt as proofsMatch, St as newAuthNonce, Un as isSocketPathTooLong, V as dataPaths, Vn as encodeFrame, er as socketPathTooLongMessage, i as ConvenoError, z as daemonProof, zn as createLineDecoder } from "./dist-ZL7d4_97.js";
6
+ import { Bn as PROTOCOL_VERSION, Dt as newAuthNonce, F as clientProof, H as dataDir, Hn as RpcErrorCode, In as EventPayload, Jn as defaultSocketPath, U as dataPaths, Un as RpcResponse, Ut as proofsMatch, V as daemonProof, Xn as ipcMethods, Yn as encodeFrame, Zn as isSocketPathTooLong, cr as socketPathTooLongMessage, i as ConvenoError, qn as createLineDecoder } from "./dist-DnWOZkAu.js";
7
7
  // ../client/dist/index.js
8
8
  const DEFAULT_REQUEST_TIMEOUT_MS = 5e3;
9
9
  const DEFAULT_START_TIMEOUT_MS = 1e4;
@@ -33,6 +33,7 @@ const CLIENT_METHODS = [
33
33
  "message.deliver",
34
34
  "message.ack",
35
35
  "message.requeue",
36
+ "message.recent",
36
37
  "owner.send",
37
38
  "events.subscribe",
38
39
  "relay.status",
@@ -1,4 +1,5 @@
1
1
  import "node:url";
2
+ import { release } from "node:os";
2
3
  // ../brand/dist/index.js
3
4
  const tokens = {
4
5
  "name": "Conveno",
@@ -597,11 +598,19 @@ const ESC = "\x1B[";
597
598
  const RESET = `${ESC}0m`;
598
599
  const set = (v) => v !== void 0 && v !== "";
599
600
  const falsy = (v) => v === void 0 || v === "" || v === "0" || v.toLowerCase() === "false";
601
+ /** Windows 10 build 18362 (1903) or later: conhost has VT, 256 colours and Unicode box drawing. */
602
+ function modernWindows(osRelease) {
603
+ const m = /^(\d+)\.(\d+)\.(\d+)/.exec(osRelease ?? "");
604
+ if (!m) return false;
605
+ const major = Number(m[1]);
606
+ return major > 10 || major === 10 && Number(m[3]) >= 18362;
607
+ }
600
608
  function currentContext() {
601
609
  return {
602
610
  env: process.env,
603
611
  isTTY: Boolean(process.stdout.isTTY),
604
- platform: process.platform
612
+ platform: process.platform,
613
+ osRelease: release()
605
614
  };
606
615
  }
607
616
  /** Precedence from brand/components/terminal-theme.json: NO_COLOR, FORCE_COLOR, flag, TTY, COLORTERM, TERM. */
@@ -626,6 +635,7 @@ function detectColorLevel(ctx = currentContext(), flag = "auto") {
626
635
  if (colorterm === "truecolor" || colorterm === "24bit") detected = 3;
627
636
  else if (ctx.platform === "win32" && (set(env.WT_SESSION) || env.ConEmuANSI === "ON")) detected = 3;
628
637
  else if (term === "dumb") detected = 0;
638
+ else if (ctx.platform === "win32" && modernWindows(ctx.osRelease) && !/256color/.test(term)) detected = 2;
629
639
  else if (term === "" && ctx.platform !== "win32") detected = 0;
630
640
  else if (/256color/.test(term)) detected = 2;
631
641
  else detected = 1;
@@ -640,11 +650,11 @@ function detectBackground(env = process.env) {
640
650
  }
641
651
  return "dark";
642
652
  }
643
- /** False for CONVENO_ASCII=1, the legacy Windows console and non-UTF-8 locales. */
653
+ /** False for CONVENO_ASCII=1, Windows older than 10 build 18362 and non-UTF-8 locales. */
644
654
  function detectUnicode(ctx = currentContext()) {
645
655
  const { env } = ctx;
646
656
  if (!falsy(env.CONVENO_ASCII)) return false;
647
- if (ctx.platform === "win32") return set(env.WT_SESSION) || set(env.TERM_PROGRAM) || env.ConEmuANSI === "ON" || env.TERM === "xterm-256color" || env.TERM === "alacritty";
657
+ if (ctx.platform === "win32") return set(env.WT_SESSION) || set(env.TERM_PROGRAM) || env.ConEmuANSI === "ON" || env.TERM === "xterm-256color" || env.TERM === "alacritty" || modernWindows(ctx.osRelease);
648
658
  if (env.TERM === "linux") return false;
649
659
  const locale = env.LC_ALL || env.LC_CTYPE || env.LANG;
650
660
  if (set(locale)) return /utf-?8/i.test(locale);
@@ -674,7 +684,8 @@ function createTheme(opts = {}) {
674
684
  const ctx = {
675
685
  env: opts.env ?? now.env,
676
686
  isTTY: opts.isTTY ?? now.isTTY,
677
- platform: opts.platform ?? now.platform
687
+ platform: opts.platform ?? now.platform,
688
+ ...(opts.osRelease ?? now.osRelease) !== void 0 ? { osRelease: opts.osRelease ?? now.osRelease } : {}
678
689
  };
679
690
  const colorLevel = detectColorLevel(ctx, opts.color);
680
691
  const background = opts.background ?? detectBackground(ctx.env);