@conveno/cli 0.1.1-rc.1 → 0.1.1-rc.3
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 +1 -0
- package/dist/bin.js +382 -149
- package/dist/daemon.js +56 -5
- package/dist/{dist-Do8KKOnN.js → dist-WPVVRVUh.js} +38 -1
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -34,6 +34,7 @@ Then open two CLI sessions, for example Claude Code and Codex. In one, ask it to
|
|
|
34
34
|
| `conveno init` | Add the Conveno MCP server and hooks to each detected CLI. |
|
|
35
35
|
| `conveno uninstall` | Undo every install that has not been undone. |
|
|
36
36
|
| `conveno status` | Online sessions grouped by repo, with the orchestrator marked. `--all` includes offline ones. |
|
|
37
|
+
| `conveno forget [<name\|pattern>...] [--offline] [--older-than <duration>] [--dry-run] [--yes]` | Remove offline sessions from the list, for example the leftovers of deleted test repos. A name is exact or a pattern where `*` matches any run of characters (quote it: `'conveno-real-*'`). `--offline` with no name means every offline session, and `--older-than 30m`, `24h` or `7d` keeps only those last seen that long ago. It lists what it will remove and asks; `--yes` skips the question, and without a terminal it exits 2 unless `--yes` is given. `--dry-run` lists and changes nothing. A running session that matches is listed as skipped and never removed. Forgetting deletes the queued messages of the session; messages it sent stay with the receivers. The daemon also forgets offline sessions whose folder has been missing for 5 minutes and that have no unread messages. |
|
|
37
38
|
| `conveno doctor` | Check each CLI and the daemon, and say how to fix what is wrong. |
|
|
38
39
|
| `conveno daemon start\|stop\|status` | Control the local daemon. It also starts when a CLI opens the Conveno MCP server, and exits when no session has been online for a while. |
|
|
39
40
|
|
package/dist/bin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import {
|
|
2
|
+
import { B as EventPayload, D as readAncestry, E as proofsMatch, F as validateRename, G as RpcResponse, H as MessageId, I as CLI_KINDS, J as createLineDecoder, K as SessionId, O as readCommandLine, Q as isSocketPathTooLong, S as parseCliVersion, T as planSpawn, U as PROTOCOL_VERSION, W as RpcErrorCode, X as encodeFrame, Y as defaultSocketPath, Z as ipcMethods, c as clientProof, d as dataPaths, f as detectRepo, h as formatInbox, j as resolveWindowsCommand, l as daemonProof, n as HEARTBEAT_INTERVAL_MS, o as baseName, q as SessionNamePattern, r as NOT_FROM_USER_NOTICE, st as socketPathTooLongMessage, t as ConvenoError, u as dataDir, w as pendingHookContext, x as newAuthNonce } from "./dist-WPVVRVUh.js";
|
|
3
3
|
import { parseArgs } from "node:util";
|
|
4
4
|
import { access, chmod, mkdir, open, readFile, readdir, realpath, rename, rm, stat, writeFile } from "node:fs/promises";
|
|
5
5
|
import { execFile, spawn } from "node:child_process";
|
|
@@ -153,6 +153,39 @@ const COMMANDS = [
|
|
|
153
153
|
help: "Also list offline sessions"
|
|
154
154
|
} }
|
|
155
155
|
},
|
|
156
|
+
{
|
|
157
|
+
name: "forget",
|
|
158
|
+
usage: "conveno forget [<name|pattern>...] [options]",
|
|
159
|
+
summary: "Remove offline sessions from the list",
|
|
160
|
+
flags: {
|
|
161
|
+
offline: {
|
|
162
|
+
type: "boolean",
|
|
163
|
+
help: "Every offline session, when no name is given"
|
|
164
|
+
},
|
|
165
|
+
"older-than": {
|
|
166
|
+
type: "string",
|
|
167
|
+
value: "<duration>",
|
|
168
|
+
help: "Only sessions last seen this long ago, such as 30m, 24h or 7d"
|
|
169
|
+
},
|
|
170
|
+
"dry-run": {
|
|
171
|
+
type: "boolean",
|
|
172
|
+
help: "List the sessions and change nothing"
|
|
173
|
+
},
|
|
174
|
+
yes: {
|
|
175
|
+
type: "boolean",
|
|
176
|
+
short: "y",
|
|
177
|
+
help: "Forget without asking"
|
|
178
|
+
}
|
|
179
|
+
},
|
|
180
|
+
notes: [
|
|
181
|
+
"A name is an exact session name or a pattern where * matches any run of characters.",
|
|
182
|
+
"Quote a pattern so the shell leaves it alone: conveno forget 'conveno-real-*'.",
|
|
183
|
+
"Only offline sessions are forgotten. A running session is listed as skipped.",
|
|
184
|
+
"Forgetting deletes the queued messages of the session. Messages it sent stay with the receivers.",
|
|
185
|
+
"Without a terminal it needs --yes, and exits 2 without it."
|
|
186
|
+
],
|
|
187
|
+
positionals: true
|
|
188
|
+
},
|
|
156
189
|
{
|
|
157
190
|
name: "doctor",
|
|
158
191
|
usage: "conveno doctor",
|
|
@@ -275,7 +308,7 @@ const connectOpts = (ctx, autoStart) => ({
|
|
|
275
308
|
});
|
|
276
309
|
// ../client/dist/index.js
|
|
277
310
|
const DEFAULT_REQUEST_TIMEOUT_MS = 5e3;
|
|
278
|
-
const DEFAULT_START_TIMEOUT_MS =
|
|
311
|
+
const DEFAULT_START_TIMEOUT_MS = 1e4;
|
|
279
312
|
const LOCK_STALE_MS = 1e4;
|
|
280
313
|
const CLIENT_METHODS = [
|
|
281
314
|
"session.register",
|
|
@@ -284,6 +317,7 @@ const CLIENT_METHODS = [
|
|
|
284
317
|
"session.rename",
|
|
285
318
|
"session.setStatus",
|
|
286
319
|
"session.byHost",
|
|
320
|
+
"session.forget",
|
|
287
321
|
"daemon.shutdown",
|
|
288
322
|
"session.list",
|
|
289
323
|
"orchestrator.claim",
|
|
@@ -507,14 +541,50 @@ function requireDaemonEntry(entry) {
|
|
|
507
541
|
if (entry) return entry;
|
|
508
542
|
throw new ClientError("Cannot find the Conveno daemon program. Pass daemonEntry to connect(), or run \"conveno daemon start\" yourself.", { kind: "daemon_missing" });
|
|
509
543
|
}
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
544
|
+
/**
|
|
545
|
+
* Start the daemon detached, with its stdout and stderr in `logPath`, truncated at each start. The
|
|
546
|
+
* daemon writes its own `daemon.log` once it runs; this file catches what it prints before that,
|
|
547
|
+
* such as a crash at startup, which would otherwise be lost.
|
|
548
|
+
*/
|
|
549
|
+
async function spawnDaemon(entry, logPath) {
|
|
550
|
+
await mkdir(dirname(logPath), { recursive: true });
|
|
551
|
+
const fh = await open(logPath, "w", 384);
|
|
552
|
+
try {
|
|
553
|
+
const child = spawn(process.execPath, [entry], {
|
|
554
|
+
detached: true,
|
|
555
|
+
stdio: [
|
|
556
|
+
"ignore",
|
|
557
|
+
fh.fd,
|
|
558
|
+
fh.fd
|
|
559
|
+
],
|
|
560
|
+
windowsHide: true
|
|
561
|
+
});
|
|
562
|
+
const spawned = { child };
|
|
563
|
+
child.on("error", (e) => {
|
|
564
|
+
spawned.spawnError = e;
|
|
565
|
+
});
|
|
566
|
+
child.on("exit", (code, signal) => {
|
|
567
|
+
spawned.exit = {
|
|
568
|
+
code,
|
|
569
|
+
signal
|
|
570
|
+
};
|
|
571
|
+
});
|
|
572
|
+
child.unref();
|
|
573
|
+
return spawned;
|
|
574
|
+
} finally {
|
|
575
|
+
await fh.close();
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
/** The last lines the daemon printed at startup, for an error message. */
|
|
579
|
+
async function startLogTail(logPath, lines = 12) {
|
|
580
|
+
try {
|
|
581
|
+
return (await readFile(logPath, "utf8")).trimEnd().split(/\r?\n/).slice(-lines).join("\n");
|
|
582
|
+
} catch {
|
|
583
|
+
return "";
|
|
584
|
+
}
|
|
585
|
+
}
|
|
586
|
+
function startFailureDetail(logPath, tail) {
|
|
587
|
+
return tail ? ` Its output, from ${logPath}:\n${tail}` : ` It printed nothing; its output would be in ${logPath}.`;
|
|
518
588
|
}
|
|
519
589
|
/** Take the start lock. Returns a release function, or null if another client holds it. */
|
|
520
590
|
async function acquireStartLock(path) {
|
|
@@ -533,27 +603,33 @@ async function acquireStartLock(path) {
|
|
|
533
603
|
}
|
|
534
604
|
async function startAndConnect(entry, dir, attempt, socketPath, startTimeout) {
|
|
535
605
|
await mkdir(dir, { recursive: true });
|
|
606
|
+
const logPath = dataPaths(process.platform, dir).daemonStartLog;
|
|
536
607
|
const release = await acquireStartLock(join(dir, "client-start.lock"));
|
|
537
|
-
if (release) spawnDaemon(entry);
|
|
538
608
|
const deadline = Date.now() + startTimeout;
|
|
539
609
|
let delay = 25;
|
|
540
610
|
let last;
|
|
541
611
|
try {
|
|
612
|
+
const spawned = release ? await spawnDaemon(entry, logPath) : void 0;
|
|
542
613
|
for (;;) {
|
|
543
614
|
await sleep$1(delay);
|
|
544
615
|
delay = Math.min(delay * 2, 250);
|
|
616
|
+
const ended = spawned?.exit ?? spawned?.spawnError;
|
|
545
617
|
try {
|
|
546
618
|
return await attempt();
|
|
547
619
|
} catch (e) {
|
|
548
620
|
if (!isMissingDaemon(e)) throw e;
|
|
549
621
|
last = e;
|
|
550
622
|
}
|
|
623
|
+
if (spawned && ended) throw new ClientError(`The Conveno daemon ${spawned.spawnError ? `could not be started (${spawned.spawnError.message})` : `exited with ${spawned.exit?.signal ? `signal ${spawned.exit.signal}` : `code ${spawned.exit?.code}`} before it listened on ${socketPath}`}.${startFailureDetail(logPath, await startLogTail(logPath))}`, {
|
|
624
|
+
cause: spawned.spawnError ?? last,
|
|
625
|
+
kind: "start_exited"
|
|
626
|
+
});
|
|
551
627
|
if (Date.now() >= deadline) break;
|
|
552
628
|
}
|
|
553
629
|
} finally {
|
|
554
630
|
await release?.();
|
|
555
631
|
}
|
|
556
|
-
throw new ClientError(`The Conveno daemon did not start within ${startTimeout} ms (socket ${socketPath})
|
|
632
|
+
throw new ClientError(`The Conveno daemon did not start within ${startTimeout} ms (socket ${socketPath}).${startFailureDetail(logPath, await startLogTail(logPath))}`, {
|
|
557
633
|
cause: last,
|
|
558
634
|
kind: "start_timeout"
|
|
559
635
|
});
|
|
@@ -713,6 +789,11 @@ function daemonProblem(t, e) {
|
|
|
713
789
|
fix: `Run ${status} to see whether it came up, or ${cmd(t, "conveno doctor")} to check the install.`,
|
|
714
790
|
notRunning: false
|
|
715
791
|
};
|
|
792
|
+
case "start_exited": return {
|
|
793
|
+
why,
|
|
794
|
+
fix: `Fix what its output above shows, then run ${start}. If it is unclear, report it with that output.`,
|
|
795
|
+
notRunning: false
|
|
796
|
+
};
|
|
716
797
|
case "connection": return {
|
|
717
798
|
why,
|
|
718
799
|
fix: `Run ${status}, then try again.`,
|
|
@@ -906,6 +987,12 @@ async function runDaemon(ctx, argv) {
|
|
|
906
987
|
});
|
|
907
988
|
}
|
|
908
989
|
// src/doctor.ts
|
|
990
|
+
/** What the plan says about one part: nothing to do, an addition, or an update to what is there. */
|
|
991
|
+
function partState(changes, component) {
|
|
992
|
+
const mine = changes.filter((c) => c.component === component);
|
|
993
|
+
if (mine.length === 0) return "ok";
|
|
994
|
+
return mine.some((c) => c.kind === "add") ? "missing" : "outdated";
|
|
995
|
+
}
|
|
909
996
|
/** Time allowed for the one process-table query. */
|
|
910
997
|
const ANCESTRY_TIMEOUT_MS = 5e3;
|
|
911
998
|
const tierWord = (t) => t === "next_turn" ? "next turn" : t;
|
|
@@ -929,21 +1016,18 @@ async function inspect(ctx, adapter) {
|
|
|
929
1016
|
const hasHooks = adapter.deliveryTier !== "inbox";
|
|
930
1017
|
try {
|
|
931
1018
|
const changes = await adapter.plan(env);
|
|
932
|
-
const text = changes.map((c) => c.description);
|
|
933
|
-
const hooksMissing = text.some((d) => /hook/i.test(d));
|
|
934
|
-
const mcpMissing = text.some((d) => /mcp/i.test(d)) || changes.length > 0 && !hooksMissing;
|
|
935
1019
|
return {
|
|
936
1020
|
adapter,
|
|
937
1021
|
detection,
|
|
938
|
-
mcp:
|
|
939
|
-
hooks: hasHooks ?
|
|
1022
|
+
mcp: partState(changes, "mcp"),
|
|
1023
|
+
hooks: hasHooks ? partState(changes, "hooks") : null
|
|
940
1024
|
};
|
|
941
1025
|
} catch (e) {
|
|
942
1026
|
return {
|
|
943
1027
|
adapter,
|
|
944
1028
|
detection,
|
|
945
|
-
mcp:
|
|
946
|
-
hooks: hasHooks ?
|
|
1029
|
+
mcp: "missing",
|
|
1030
|
+
hooks: hasHooks ? "missing" : null,
|
|
947
1031
|
planError: plainError$1(e)
|
|
948
1032
|
};
|
|
949
1033
|
}
|
|
@@ -1003,7 +1087,7 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1003
1087
|
q("TIER"),
|
|
1004
1088
|
q("NOTE")
|
|
1005
1089
|
]];
|
|
1006
|
-
const yesNo = (v) => v === null ? q("n/a") : v ? "yes" : t.paint("warn", "not configured");
|
|
1090
|
+
const yesNo = (v) => v === null ? q("n/a") : v === "ok" ? "yes" : t.paint("warn", v === "missing" ? "not configured" : "needs update");
|
|
1007
1091
|
for (const r of rows) {
|
|
1008
1092
|
const { adapter, detection } = r;
|
|
1009
1093
|
if (!detection.installed) {
|
|
@@ -1018,9 +1102,9 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1018
1102
|
]);
|
|
1019
1103
|
continue;
|
|
1020
1104
|
}
|
|
1021
|
-
const good = r.mcp ===
|
|
1105
|
+
const good = r.mcp === "ok" && (r.hooks === null || r.hooks === "ok") && !r.planError;
|
|
1022
1106
|
let note = adapter.deliveryTier === "next_turn" ? "delivered at the next prompt" : "read through the inbox tool";
|
|
1023
|
-
if (!good) note = r.planError ? "config could not be read" : "not fully configured";
|
|
1107
|
+
if (!good) note = r.planError ? "config could not be read" : r.mcp === "outdated" || r.hooks === "outdated" ? "needs an update" : "not fully configured";
|
|
1024
1108
|
table.push([
|
|
1025
1109
|
` ${good ? t.status("ok") : t.status("warn")} ${adapter.cli}`,
|
|
1026
1110
|
adapter.displayName,
|
|
@@ -1042,8 +1126,12 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1042
1126
|
} else if (good) ok++;
|
|
1043
1127
|
else {
|
|
1044
1128
|
warnings++;
|
|
1045
|
-
const
|
|
1046
|
-
|
|
1129
|
+
const named = [["the MCP server", r.mcp], ["the hooks", r.hooks]];
|
|
1130
|
+
const list = (state) => named.filter(([, s]) => s === state).map(([n]) => n).join(" and ");
|
|
1131
|
+
const missing = list("missing");
|
|
1132
|
+
const outdated = list("outdated");
|
|
1133
|
+
const fix = `Run ${cmd(t, "conveno init")}, then restart open ${adapter.displayName} sessions.`;
|
|
1134
|
+
notes.push(missing && outdated ? warnBlock(t, `${adapter.displayName} is missing ${missing} and needs an update to ${outdated}.`, fix) : missing ? warnBlock(t, `${adapter.displayName} is missing ${missing}.`, fix) : warnBlock(t, `${adapter.displayName} needs an update.`, fix, `Conveno's setup for ${outdated} is from an older version. ${cmd(t, "conveno init")} shows exactly which lines change.`));
|
|
1047
1135
|
}
|
|
1048
1136
|
}
|
|
1049
1137
|
ctx.out(`${columns(table).join("\n")}\n`);
|
|
@@ -1056,7 +1144,7 @@ async function runDoctor(ctx, argv = []) {
|
|
|
1056
1144
|
return problems > 0 ? 1 : 0;
|
|
1057
1145
|
}
|
|
1058
1146
|
// src/version.ts
|
|
1059
|
-
const VERSION = "0.1.1-rc.
|
|
1147
|
+
const VERSION = "0.1.1-rc.3";
|
|
1060
1148
|
// src/errorLog.ts
|
|
1061
1149
|
/** The message of an unexpected error, as it is. Not the softened text `plainError` gives. */
|
|
1062
1150
|
function rawMessage(e) {
|
|
@@ -1095,6 +1183,247 @@ async function writeErrorLog(ctx, argv, e) {
|
|
|
1095
1183
|
return;
|
|
1096
1184
|
}
|
|
1097
1185
|
}
|
|
1186
|
+
// src/status.ts
|
|
1187
|
+
const CLI_SHORT = {
|
|
1188
|
+
claude: "cl",
|
|
1189
|
+
codex: "cx",
|
|
1190
|
+
opencode: "oc",
|
|
1191
|
+
antigravity: "ag",
|
|
1192
|
+
cursor: "cu",
|
|
1193
|
+
copilot: "cp"
|
|
1194
|
+
};
|
|
1195
|
+
const pad2 = (n) => String(n).padStart(2, "0");
|
|
1196
|
+
/** Local `HH:MM:SS`, with the date in front when it is not today. */
|
|
1197
|
+
function stamp(iso, now) {
|
|
1198
|
+
const d = new Date(iso);
|
|
1199
|
+
const time = `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
|
|
1200
|
+
const day = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
1201
|
+
return day === `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}` ? time : `${day} ${time}`;
|
|
1202
|
+
}
|
|
1203
|
+
function tierText(theme, tier) {
|
|
1204
|
+
switch (tier) {
|
|
1205
|
+
case "live": return theme.paint("entry", "live");
|
|
1206
|
+
case "next_turn": return "next turn";
|
|
1207
|
+
case "acp": return "ACP";
|
|
1208
|
+
case "inbox": return theme.paint("quiet", "inbox");
|
|
1209
|
+
}
|
|
1210
|
+
}
|
|
1211
|
+
function stateCell(theme, s) {
|
|
1212
|
+
if (s.status === "offline") return {
|
|
1213
|
+
glyph: theme.status("offline"),
|
|
1214
|
+
word: "offline"
|
|
1215
|
+
};
|
|
1216
|
+
if (s.status === "waiting_on_question") return {
|
|
1217
|
+
glyph: theme.status("waiting"),
|
|
1218
|
+
word: "waiting"
|
|
1219
|
+
};
|
|
1220
|
+
if (s.isOrchestrator) return {
|
|
1221
|
+
glyph: theme.status("orchestrator"),
|
|
1222
|
+
word: s.status
|
|
1223
|
+
};
|
|
1224
|
+
if (s.status === "busy") return {
|
|
1225
|
+
glyph: theme.glyph("busy"),
|
|
1226
|
+
word: "busy"
|
|
1227
|
+
};
|
|
1228
|
+
return {
|
|
1229
|
+
glyph: theme.status("idle"),
|
|
1230
|
+
word: "idle"
|
|
1231
|
+
};
|
|
1232
|
+
}
|
|
1233
|
+
/** Sessions grouped by repository, the way brand/components/terminal.md lays them out. */
|
|
1234
|
+
function renderSessions(ctx, sessions) {
|
|
1235
|
+
const t = ctx.theme;
|
|
1236
|
+
const now = ctx.now();
|
|
1237
|
+
const groups = /* @__PURE__ */ new Map();
|
|
1238
|
+
for (const s of sessions) {
|
|
1239
|
+
const key = s.repo?.root ?? s.cwd;
|
|
1240
|
+
groups.set(key, [...groups.get(key) ?? [], s]);
|
|
1241
|
+
}
|
|
1242
|
+
const blocks = [];
|
|
1243
|
+
for (const key of [...groups.keys()].sort()) {
|
|
1244
|
+
const list = (groups.get(key) ?? []).sort((a, b) => a.name.localeCompare(b.name));
|
|
1245
|
+
const q = (w) => t.paint("quiet", w);
|
|
1246
|
+
const [headLine, ...rowLines] = columns([[
|
|
1247
|
+
` ${q("SESSION")}`,
|
|
1248
|
+
q("CLI"),
|
|
1249
|
+
q("TIER"),
|
|
1250
|
+
q("STATE"),
|
|
1251
|
+
q("LAST SEEN")
|
|
1252
|
+
], ...list.map((s) => {
|
|
1253
|
+
const st = stateCell(t, s);
|
|
1254
|
+
return [
|
|
1255
|
+
`${st.glyph} ${t.bold(s.name)}`,
|
|
1256
|
+
CLI_SHORT[s.cli] ?? s.cli,
|
|
1257
|
+
tierText(t, s.deliveryTier),
|
|
1258
|
+
st.word,
|
|
1259
|
+
t.paint("quiet", stamp(s.lastSeenAt, now)),
|
|
1260
|
+
...s.isOrchestrator ? [t.paint("entry", "orchestrator")] : []
|
|
1261
|
+
];
|
|
1262
|
+
})]);
|
|
1263
|
+
blocks.push([
|
|
1264
|
+
` ${t.bold(tilde(key, ctx.home))}`,
|
|
1265
|
+
` ${headLine}`,
|
|
1266
|
+
...rowLines.map((l) => ` ${l}`)
|
|
1267
|
+
].join("\n"));
|
|
1268
|
+
}
|
|
1269
|
+
return blocks.join("\n\n");
|
|
1270
|
+
}
|
|
1271
|
+
async function runStatus(ctx, argv = []) {
|
|
1272
|
+
const t = ctx.theme;
|
|
1273
|
+
const spec = COMMANDS.find((c) => c.name === "status");
|
|
1274
|
+
let all = false;
|
|
1275
|
+
if (spec) {
|
|
1276
|
+
const parsed = parseFlags(ctx, spec, argv);
|
|
1277
|
+
if (typeof parsed === "number") return parsed;
|
|
1278
|
+
all = parsed.values.all === true;
|
|
1279
|
+
}
|
|
1280
|
+
let client;
|
|
1281
|
+
try {
|
|
1282
|
+
client = await ctx.connect(connectOpts(ctx, false));
|
|
1283
|
+
} catch (e) {
|
|
1284
|
+
const problem = daemonProblem(t, e);
|
|
1285
|
+
ctx.err(problem.notRunning ? warnBlock(t, "The Conveno daemon is not running.", `Run ${cmd(t, "conveno daemon start")}, or open a supported CLI after ${cmd(t, "conveno init")}.`, "Sessions are listed by the daemon, and nothing is listening on its socket.") : warnBlock(t, "The Conveno daemon cannot be reached.", problem.fix, problem.why));
|
|
1286
|
+
return 0;
|
|
1287
|
+
}
|
|
1288
|
+
try {
|
|
1289
|
+
const everyone = (await client["session.list"]({ includeOffline: true })).sessions;
|
|
1290
|
+
const sessions = all ? everyone : everyone.filter((s) => s.status !== "offline");
|
|
1291
|
+
const hidden = everyone.length - sessions.length;
|
|
1292
|
+
const repos = new Set(sessions.map((s) => s.repo?.root ?? s.cwd)).size;
|
|
1293
|
+
const hint = hidden > 0 ? `${hidden} offline hidden, ${cmd(t, "conveno status --all")} shows them` : "";
|
|
1294
|
+
ctx.out(`daemon up ${t.status("bullet")} relay: off (local only) ${t.status("bullet")} ${plural(sessions.length, "session")}\n`);
|
|
1295
|
+
if (sessions.length === 0) {
|
|
1296
|
+
ctx.out(hidden > 0 ? `\nNo sessions online. ${hint}.\n` : `\nNo sessions yet. Open a supported CLI after ${cmd(t, "conveno init")} and it appears here.\n`);
|
|
1297
|
+
return 0;
|
|
1298
|
+
}
|
|
1299
|
+
ctx.out(`\n${renderSessions(ctx, sessions)}\n\n`);
|
|
1300
|
+
ctx.out(`${plural(sessions.length, "session")} in ${plural(repos, "repo")}${hint ? ` ${t.status("bullet")} ${hint}` : ""}\n`);
|
|
1301
|
+
return 0;
|
|
1302
|
+
} finally {
|
|
1303
|
+
await client.close().catch(() => void 0);
|
|
1304
|
+
}
|
|
1305
|
+
}
|
|
1306
|
+
// src/forget.ts
|
|
1307
|
+
const UNIT_MS = {
|
|
1308
|
+
m: 6e4,
|
|
1309
|
+
h: 36e5,
|
|
1310
|
+
d: 864e5
|
|
1311
|
+
};
|
|
1312
|
+
/** `30m`, `24h` or `7d` as milliseconds, or undefined when the text is anything else. */
|
|
1313
|
+
function parseDuration(text) {
|
|
1314
|
+
const m = /^(\d{1,6})([mhd])$/.exec(text);
|
|
1315
|
+
if (!m) return void 0;
|
|
1316
|
+
const ms = Number(m[1]) * UNIT_MS[m[2]];
|
|
1317
|
+
return ms > 0 ? ms : void 0;
|
|
1318
|
+
}
|
|
1319
|
+
/** Rebuild the command line the user typed, for the "run it again with --yes" hint. */
|
|
1320
|
+
function rerunLine(names, flags) {
|
|
1321
|
+
return [
|
|
1322
|
+
"conveno forget",
|
|
1323
|
+
...names.map((n) => n.includes("*") ? `'${n}'` : n),
|
|
1324
|
+
...flags.offline ? ["--offline"] : [],
|
|
1325
|
+
...flags.olderThan ? ["--older-than", flags.olderThan] : []
|
|
1326
|
+
].join(" ");
|
|
1327
|
+
}
|
|
1328
|
+
async function runForget(ctx, argv) {
|
|
1329
|
+
const t = ctx.theme;
|
|
1330
|
+
const spec = COMMANDS.find((c) => c.name === "forget");
|
|
1331
|
+
if (!spec) return 2;
|
|
1332
|
+
const parsed = parseFlags(ctx, spec, argv);
|
|
1333
|
+
if (typeof parsed === "number") return parsed;
|
|
1334
|
+
const names = parsed.positionals;
|
|
1335
|
+
const offline = parsed.values.offline === true;
|
|
1336
|
+
const olderThan = typeof parsed.values["older-than"] === "string" ? parsed.values["older-than"] : void 0;
|
|
1337
|
+
const dryRun = parsed.values["dry-run"] === true;
|
|
1338
|
+
const yes = parsed.values.yes === true;
|
|
1339
|
+
const help = `Run ${cmd(t, "conveno forget --help")} to see the options.`;
|
|
1340
|
+
for (const n of names) if (!SessionNamePattern.safeParse(n).success) return fail$1(ctx, {
|
|
1341
|
+
what: `"${n}" is not a session name or pattern`,
|
|
1342
|
+
detail: ["Names use lowercase letters, digits and \".\", \"_\", \"@\" or \"-\". A \"*\" matches any run of characters."],
|
|
1343
|
+
fix: `Run ${cmd(t, "conveno status --all")} to see the names.`,
|
|
1344
|
+
exit: 2,
|
|
1345
|
+
ref: "e_usage"
|
|
1346
|
+
});
|
|
1347
|
+
let olderThanMs;
|
|
1348
|
+
if (olderThan !== void 0) {
|
|
1349
|
+
olderThanMs = parseDuration(olderThan);
|
|
1350
|
+
if (olderThanMs === void 0) return fail$1(ctx, {
|
|
1351
|
+
what: `"${olderThan}" is not a duration`,
|
|
1352
|
+
detail: ["Use a whole number and a unit: 30m for minutes, 24h for hours, 7d for days."],
|
|
1353
|
+
fix: help,
|
|
1354
|
+
exit: 2,
|
|
1355
|
+
ref: "e_usage"
|
|
1356
|
+
});
|
|
1357
|
+
}
|
|
1358
|
+
if (names.length === 0 && !offline && olderThanMs === void 0) return fail$1(ctx, {
|
|
1359
|
+
what: "conveno forget needs to know which sessions to forget",
|
|
1360
|
+
detail: ["Name them, or pass --offline for every offline session."],
|
|
1361
|
+
fix: `For example ${cmd(t, "conveno forget 'conveno-real-*'")} or ${cmd(t, "conveno forget --offline --older-than 7d")}.`,
|
|
1362
|
+
exit: 2,
|
|
1363
|
+
ref: "e_usage"
|
|
1364
|
+
});
|
|
1365
|
+
let client;
|
|
1366
|
+
try {
|
|
1367
|
+
client = await ctx.connect(connectOpts(ctx, false));
|
|
1368
|
+
} catch (e) {
|
|
1369
|
+
const problem = daemonProblem(t, e);
|
|
1370
|
+
return fail$1(ctx, {
|
|
1371
|
+
what: problem.notRunning ? "The Conveno daemon is not running" : "The Conveno daemon cannot be reached",
|
|
1372
|
+
detail: [problem.notRunning ? "Sessions live in the daemon, so there is nothing to forget until it runs." : problem.why],
|
|
1373
|
+
fix: problem.notRunning ? `Run ${cmd(t, "conveno daemon start")}.` : problem.fix,
|
|
1374
|
+
exit: 1,
|
|
1375
|
+
ref: "e_daemon"
|
|
1376
|
+
});
|
|
1377
|
+
}
|
|
1378
|
+
try {
|
|
1379
|
+
const selector = {
|
|
1380
|
+
...names.length > 0 ? { names } : {},
|
|
1381
|
+
...names.length === 0 || olderThanMs !== void 0 ? { olderThanMs: olderThanMs ?? 0 } : {}
|
|
1382
|
+
};
|
|
1383
|
+
const preview = await client["session.forget"]({
|
|
1384
|
+
...selector,
|
|
1385
|
+
dryRun: true
|
|
1386
|
+
});
|
|
1387
|
+
const ids = new Set(preview.forgotten.map((s) => s.id));
|
|
1388
|
+
const picked = (await client["session.list"]({ includeOffline: true })).sessions.filter((s) => ids.has(s.id));
|
|
1389
|
+
if (preview.skippedOnline.length > 0) {
|
|
1390
|
+
ctx.out(`${t.status("warn")} ${t.bold(`Skipped ${plural(preview.skippedOnline.length, "online session")}`)}\n`);
|
|
1391
|
+
ctx.out(`${columns(preview.skippedOnline.map((s) => [` ${t.status("idle")} ${t.bold(s.name)}`, t.paint("quiet", "online, a running session is never forgotten")])).join("\n")}\n\n`);
|
|
1392
|
+
}
|
|
1393
|
+
if (picked.length === 0) {
|
|
1394
|
+
ctx.out(`${t.status("info")} Nothing to forget. ${t.paint("quiet", `${cmd(t, "conveno status --all")} lists the offline sessions.`)}\n`);
|
|
1395
|
+
return 0;
|
|
1396
|
+
}
|
|
1397
|
+
ctx.out(`${t.bold(dryRun ? `Would forget ${plural(picked.length, "session")}` : `Will forget ${plural(picked.length, "session")}`)}\n\n`);
|
|
1398
|
+
ctx.out(`${renderSessions(ctx, picked)}\n\n`);
|
|
1399
|
+
ctx.out(` ${t.paint("quiet", "Their queued messages are deleted too. Messages they sent stay with the receivers.")}\n\n`);
|
|
1400
|
+
if (dryRun) {
|
|
1401
|
+
ctx.out(`${t.status("info")} Dry run. Nothing was changed.\n`);
|
|
1402
|
+
return 0;
|
|
1403
|
+
}
|
|
1404
|
+
if (!yes) {
|
|
1405
|
+
if (!ctx.interactive) return fail$1(ctx, {
|
|
1406
|
+
what: "Needs a terminal to confirm",
|
|
1407
|
+
detail: ["No sessions were forgotten."],
|
|
1408
|
+
fix: `Run ${cmd(t, `${rerunLine(names, {
|
|
1409
|
+
offline,
|
|
1410
|
+
...olderThan ? { olderThan } : {}
|
|
1411
|
+
})} --yes`)} to forget the sessions listed above.`,
|
|
1412
|
+
exit: 2,
|
|
1413
|
+
ref: "e_no_tty"
|
|
1414
|
+
});
|
|
1415
|
+
if (!await ctx.confirm(`Forget ${plural(picked.length, "session")}?`, false)) {
|
|
1416
|
+
ctx.out(`${t.status("info")} Nothing was changed.\n`);
|
|
1417
|
+
return 0;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
const done = await client["session.forget"]({ ids: [...ids] });
|
|
1421
|
+
ctx.out(`${t.status("ok")} ${t.bold("Done.")} Forgot ${plural(done.forgotten.length, "session")}.\n`);
|
|
1422
|
+
return 0;
|
|
1423
|
+
} finally {
|
|
1424
|
+
await client.close().catch(() => void 0);
|
|
1425
|
+
}
|
|
1426
|
+
}
|
|
1098
1427
|
// src/hook.ts
|
|
1099
1428
|
/**
|
|
1100
1429
|
* Time allowed for the one process-table query behind the host pid. It runs beside reading
|
|
@@ -1745,126 +2074,6 @@ async function runInit(ctx, argv) {
|
|
|
1745
2074
|
ctx.out(` Next: ${cmd(t, "conveno status")} lists your sessions.\n`);
|
|
1746
2075
|
return 0;
|
|
1747
2076
|
}
|
|
1748
|
-
// src/status.ts
|
|
1749
|
-
const CLI_SHORT = {
|
|
1750
|
-
claude: "cl",
|
|
1751
|
-
codex: "cx",
|
|
1752
|
-
opencode: "oc",
|
|
1753
|
-
antigravity: "ag",
|
|
1754
|
-
cursor: "cu",
|
|
1755
|
-
copilot: "cp"
|
|
1756
|
-
};
|
|
1757
|
-
const pad2 = (n) => String(n).padStart(2, "0");
|
|
1758
|
-
/** Local `HH:MM:SS`, with the date in front when it is not today. */
|
|
1759
|
-
function stamp(iso, now) {
|
|
1760
|
-
const d = new Date(iso);
|
|
1761
|
-
const time = `${pad2(d.getHours())}:${pad2(d.getMinutes())}:${pad2(d.getSeconds())}`;
|
|
1762
|
-
const day = `${d.getFullYear()}-${pad2(d.getMonth() + 1)}-${pad2(d.getDate())}`;
|
|
1763
|
-
return day === `${now.getFullYear()}-${pad2(now.getMonth() + 1)}-${pad2(now.getDate())}` ? time : `${day} ${time}`;
|
|
1764
|
-
}
|
|
1765
|
-
function tierText(theme, tier) {
|
|
1766
|
-
switch (tier) {
|
|
1767
|
-
case "live": return theme.paint("entry", "live");
|
|
1768
|
-
case "next_turn": return "next turn";
|
|
1769
|
-
case "acp": return "ACP";
|
|
1770
|
-
case "inbox": return theme.paint("quiet", "inbox");
|
|
1771
|
-
}
|
|
1772
|
-
}
|
|
1773
|
-
function stateCell(theme, s) {
|
|
1774
|
-
if (s.status === "offline") return {
|
|
1775
|
-
glyph: theme.status("offline"),
|
|
1776
|
-
word: "offline"
|
|
1777
|
-
};
|
|
1778
|
-
if (s.status === "waiting_on_question") return {
|
|
1779
|
-
glyph: theme.status("waiting"),
|
|
1780
|
-
word: "waiting"
|
|
1781
|
-
};
|
|
1782
|
-
if (s.isOrchestrator) return {
|
|
1783
|
-
glyph: theme.status("orchestrator"),
|
|
1784
|
-
word: s.status
|
|
1785
|
-
};
|
|
1786
|
-
if (s.status === "busy") return {
|
|
1787
|
-
glyph: theme.glyph("busy"),
|
|
1788
|
-
word: "busy"
|
|
1789
|
-
};
|
|
1790
|
-
return {
|
|
1791
|
-
glyph: theme.status("idle"),
|
|
1792
|
-
word: "idle"
|
|
1793
|
-
};
|
|
1794
|
-
}
|
|
1795
|
-
/** Sessions grouped by repository, the way brand/components/terminal.md lays them out. */
|
|
1796
|
-
function renderSessions(ctx, sessions) {
|
|
1797
|
-
const t = ctx.theme;
|
|
1798
|
-
const now = ctx.now();
|
|
1799
|
-
const groups = /* @__PURE__ */ new Map();
|
|
1800
|
-
for (const s of sessions) {
|
|
1801
|
-
const key = s.repo?.root ?? s.cwd;
|
|
1802
|
-
groups.set(key, [...groups.get(key) ?? [], s]);
|
|
1803
|
-
}
|
|
1804
|
-
const blocks = [];
|
|
1805
|
-
for (const key of [...groups.keys()].sort()) {
|
|
1806
|
-
const list = (groups.get(key) ?? []).sort((a, b) => a.name.localeCompare(b.name));
|
|
1807
|
-
const q = (w) => t.paint("quiet", w);
|
|
1808
|
-
const [headLine, ...rowLines] = columns([[
|
|
1809
|
-
` ${q("SESSION")}`,
|
|
1810
|
-
q("CLI"),
|
|
1811
|
-
q("TIER"),
|
|
1812
|
-
q("STATE"),
|
|
1813
|
-
q("LAST SEEN")
|
|
1814
|
-
], ...list.map((s) => {
|
|
1815
|
-
const st = stateCell(t, s);
|
|
1816
|
-
return [
|
|
1817
|
-
`${st.glyph} ${t.bold(s.name)}`,
|
|
1818
|
-
CLI_SHORT[s.cli] ?? s.cli,
|
|
1819
|
-
tierText(t, s.deliveryTier),
|
|
1820
|
-
st.word,
|
|
1821
|
-
t.paint("quiet", stamp(s.lastSeenAt, now)),
|
|
1822
|
-
...s.isOrchestrator ? [t.paint("entry", "orchestrator")] : []
|
|
1823
|
-
];
|
|
1824
|
-
})]);
|
|
1825
|
-
blocks.push([
|
|
1826
|
-
` ${t.bold(tilde(key, ctx.home))}`,
|
|
1827
|
-
` ${headLine}`,
|
|
1828
|
-
...rowLines.map((l) => ` ${l}`)
|
|
1829
|
-
].join("\n"));
|
|
1830
|
-
}
|
|
1831
|
-
return blocks.join("\n\n");
|
|
1832
|
-
}
|
|
1833
|
-
async function runStatus(ctx, argv = []) {
|
|
1834
|
-
const t = ctx.theme;
|
|
1835
|
-
const spec = COMMANDS.find((c) => c.name === "status");
|
|
1836
|
-
let all = false;
|
|
1837
|
-
if (spec) {
|
|
1838
|
-
const parsed = parseFlags(ctx, spec, argv);
|
|
1839
|
-
if (typeof parsed === "number") return parsed;
|
|
1840
|
-
all = parsed.values.all === true;
|
|
1841
|
-
}
|
|
1842
|
-
let client;
|
|
1843
|
-
try {
|
|
1844
|
-
client = await ctx.connect(connectOpts(ctx, false));
|
|
1845
|
-
} catch (e) {
|
|
1846
|
-
const problem = daemonProblem(t, e);
|
|
1847
|
-
ctx.err(problem.notRunning ? warnBlock(t, "The Conveno daemon is not running.", `Run ${cmd(t, "conveno daemon start")}, or open a supported CLI after ${cmd(t, "conveno init")}.`, "Sessions are listed by the daemon, and nothing is listening on its socket.") : warnBlock(t, "The Conveno daemon cannot be reached.", problem.fix, problem.why));
|
|
1848
|
-
return 0;
|
|
1849
|
-
}
|
|
1850
|
-
try {
|
|
1851
|
-
const everyone = (await client["session.list"]({ includeOffline: true })).sessions;
|
|
1852
|
-
const sessions = all ? everyone : everyone.filter((s) => s.status !== "offline");
|
|
1853
|
-
const hidden = everyone.length - sessions.length;
|
|
1854
|
-
const repos = new Set(sessions.map((s) => s.repo?.root ?? s.cwd)).size;
|
|
1855
|
-
const hint = hidden > 0 ? `${hidden} offline hidden, ${cmd(t, "conveno status --all")} shows them` : "";
|
|
1856
|
-
ctx.out(`daemon up ${t.status("bullet")} relay: off (local only) ${t.status("bullet")} ${plural(sessions.length, "session")}\n`);
|
|
1857
|
-
if (sessions.length === 0) {
|
|
1858
|
-
ctx.out(hidden > 0 ? `\nNo sessions online. ${hint}.\n` : `\nNo sessions yet. Open a supported CLI after ${cmd(t, "conveno init")} and it appears here.\n`);
|
|
1859
|
-
return 0;
|
|
1860
|
-
}
|
|
1861
|
-
ctx.out(`\n${renderSessions(ctx, sessions)}\n\n`);
|
|
1862
|
-
ctx.out(`${plural(sessions.length, "session")} in ${plural(repos, "repo")}${hint ? ` ${t.status("bullet")} ${hint}` : ""}\n`);
|
|
1863
|
-
return 0;
|
|
1864
|
-
} finally {
|
|
1865
|
-
await client.close().catch(() => void 0);
|
|
1866
|
-
}
|
|
1867
|
-
}
|
|
1868
2077
|
// src/uninstall.ts
|
|
1869
2078
|
const NOTE = {
|
|
1870
2079
|
restore: "restored byte for byte",
|
|
@@ -2043,6 +2252,7 @@ async function dispatch(command, rest, ctx) {
|
|
|
2043
2252
|
case "init": return runInit(ctx, rest);
|
|
2044
2253
|
case "uninstall": return runUninstall(ctx, rest);
|
|
2045
2254
|
case "status": return runStatus(ctx, rest);
|
|
2255
|
+
case "forget": return runForget(ctx, rest);
|
|
2046
2256
|
case "doctor": return runDoctor(ctx, rest);
|
|
2047
2257
|
case "daemon": return runDaemon(ctx, rest);
|
|
2048
2258
|
case "mcp": return runMcp(ctx, rest);
|
|
@@ -2266,6 +2476,8 @@ async function plan$1(env) {
|
|
|
2266
2476
|
value: want
|
|
2267
2477
|
}]);
|
|
2268
2478
|
changes.push({
|
|
2479
|
+
component: "mcp",
|
|
2480
|
+
kind: servers["conveno"] === void 0 ? "add" : "update",
|
|
2269
2481
|
path: p.mcp,
|
|
2270
2482
|
before: mcpFile.raw,
|
|
2271
2483
|
after,
|
|
@@ -2292,7 +2504,10 @@ async function plan$1(env) {
|
|
|
2292
2504
|
command: hookCommand$1(env, e),
|
|
2293
2505
|
timeout: 5
|
|
2294
2506
|
}] }];
|
|
2507
|
+
const installed = HOOK_EVENTS$1.some((e) => groupsOf(hooks, e).some((g) => isObject(g) && Array.isArray(g.hooks) && g.hooks.some((h) => isObject(h) && isOurHookCommand(h.command))));
|
|
2295
2508
|
changes.push({
|
|
2509
|
+
component: "hooks",
|
|
2510
|
+
kind: installed ? "update" : "add",
|
|
2296
2511
|
path: p.settings,
|
|
2297
2512
|
before: setFile.raw,
|
|
2298
2513
|
after: editJson(setFile, missing.map((e) => ({
|
|
@@ -2309,6 +2524,8 @@ async function uninstallPlan$1(env) {
|
|
|
2309
2524
|
const changes = [];
|
|
2310
2525
|
const mcpFile = await loadJson(p.mcp);
|
|
2311
2526
|
if ("conveno" in mcpObject(mcpFile.value, p.mcp)) changes.push({
|
|
2527
|
+
component: "mcp",
|
|
2528
|
+
kind: "remove",
|
|
2312
2529
|
path: p.mcp,
|
|
2313
2530
|
before: mcpFile.raw,
|
|
2314
2531
|
after: editJson(mcpFile, [{
|
|
@@ -2346,6 +2563,8 @@ async function uninstallPlan$1(env) {
|
|
|
2346
2563
|
value: void 0
|
|
2347
2564
|
});
|
|
2348
2565
|
changes.push({
|
|
2566
|
+
component: "hooks",
|
|
2567
|
+
kind: "remove",
|
|
2349
2568
|
path: p.settings,
|
|
2350
2569
|
before: setFile.raw,
|
|
2351
2570
|
after: editJson(setFile, edits),
|
|
@@ -2553,6 +2772,8 @@ async function planHooks(env) {
|
|
|
2553
2772
|
}
|
|
2554
2773
|
if (!changed) return [];
|
|
2555
2774
|
return [{
|
|
2775
|
+
component: "hooks",
|
|
2776
|
+
kind: HOOK_EVENTS.some((event) => asArray(hooks[event]).some((g) => handlersOf(g).some((h) => isOurs(asObject(h).command, event)))) ? "update" : "add",
|
|
2556
2777
|
path,
|
|
2557
2778
|
before,
|
|
2558
2779
|
after: json({
|
|
@@ -2585,6 +2806,8 @@ async function uninstallHooks(env) {
|
|
|
2585
2806
|
hooks: next
|
|
2586
2807
|
} : rest;
|
|
2587
2808
|
return [{
|
|
2809
|
+
component: "hooks",
|
|
2810
|
+
kind: "remove",
|
|
2588
2811
|
path,
|
|
2589
2812
|
before,
|
|
2590
2813
|
after: json(after),
|
|
@@ -2613,6 +2836,8 @@ async function planMcp(env) {
|
|
|
2613
2836
|
const spec = serverSpec(env, existing);
|
|
2614
2837
|
if (matchesSpec(existing, spec)) return [];
|
|
2615
2838
|
return [{
|
|
2839
|
+
component: "mcp",
|
|
2840
|
+
kind: existing ? "update" : "add",
|
|
2616
2841
|
path,
|
|
2617
2842
|
before,
|
|
2618
2843
|
after: addServer(path, before ?? "", spec),
|
|
@@ -2624,6 +2849,8 @@ async function uninstallMcp(env) {
|
|
|
2624
2849
|
const before = await readIfExists(path);
|
|
2625
2850
|
if (before === null || !serverOf(parseToml(path, before))) return [];
|
|
2626
2851
|
return [{
|
|
2852
|
+
component: "mcp",
|
|
2853
|
+
kind: "remove",
|
|
2627
2854
|
path,
|
|
2628
2855
|
before,
|
|
2629
2856
|
after: removeServer(path, before),
|
|
@@ -2837,14 +3064,18 @@ async function plan(env) {
|
|
|
2837
3064
|
const config = parseConfig(file);
|
|
2838
3065
|
const shape = await chooseShape(env, config);
|
|
2839
3066
|
const want = serverEntry(env, shape);
|
|
2840
|
-
|
|
3067
|
+
const current = shape === "v1" ? v1Entry(config) : servers(config)?.[SERVER_NAME];
|
|
3068
|
+
if (sameEntry(current, want)) return [];
|
|
2841
3069
|
let text = file.text === null || file.text.trim() === "" ? "{}\n" : file.text;
|
|
2842
3070
|
const otherShape = shape === "v1" ? "v2" : "v1";
|
|
2843
|
-
|
|
3071
|
+
const other = otherShape === "v1" ? v1Entry(config) : servers(config)?.[SERVER_NAME];
|
|
3072
|
+
if (other !== void 0) text = applyEdits(text, modify(text, pathFor(otherShape), void 0, { formattingOptions: FORMAT }));
|
|
2844
3073
|
let after = applyEdits(text, modify(text, pathFor(shape), want, { formattingOptions: FORMAT }));
|
|
2845
3074
|
if (!after.endsWith("\n")) after += "\n";
|
|
2846
3075
|
const where = shape === "v1" ? `mcp.${SERVER_NAME}` : `mcp.servers.${SERVER_NAME}`;
|
|
2847
3076
|
return [{
|
|
3077
|
+
component: "mcp",
|
|
3078
|
+
kind: current !== void 0 || other !== void 0 ? "update" : "add",
|
|
2848
3079
|
path: file.path,
|
|
2849
3080
|
before: file.text,
|
|
2850
3081
|
after,
|
|
@@ -2867,6 +3098,8 @@ async function uninstallPlan(env) {
|
|
|
2867
3098
|
}
|
|
2868
3099
|
if (removed.length === 0) return [];
|
|
2869
3100
|
return [{
|
|
3101
|
+
component: "mcp",
|
|
3102
|
+
kind: "remove",
|
|
2870
3103
|
path: file.path,
|
|
2871
3104
|
before: file.text,
|
|
2872
3105
|
after: text,
|
|
@@ -3617,7 +3850,7 @@ function createTheme(opts = {}) {
|
|
|
3617
3850
|
spinner
|
|
3618
3851
|
};
|
|
3619
3852
|
}
|
|
3620
|
-
// ../daemon/dist/server-
|
|
3853
|
+
// ../daemon/dist/server-LGouDx5G.js
|
|
3621
3854
|
/** `kill(pid, 0)` liveness: EPERM means the process exists but belongs to someone else. */
|
|
3622
3855
|
function defaultIsAlive(pid) {
|
|
3623
3856
|
try {
|
|
@@ -3629,7 +3862,7 @@ function defaultIsAlive(pid) {
|
|
|
3629
3862
|
}
|
|
3630
3863
|
SessionId.parse("0".repeat(26));
|
|
3631
3864
|
// ../mcp/dist/index.js
|
|
3632
|
-
const SERVER_VERSION = "0.1.1-rc.
|
|
3865
|
+
const SERVER_VERSION = "0.1.1-rc.3";
|
|
3633
3866
|
const ok = (text) => ({ content: [{
|
|
3634
3867
|
type: "text",
|
|
3635
3868
|
text
|
package/dist/daemon.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { homedir } from "node:os";
|
|
3
|
-
import { $ as
|
|
3
|
+
import { $ as makeError, A as resolveRecipient, C as pendingForInjection, E as proofsMatch, F as validateRename, J as createLineDecoder, K as SessionId, L as DeviceId, M as statusAfterLiveness, N as takeWithinBytes, P as tooManyUnreadMessage, Q as isSocketPathTooLong, R as EVENT_NAMES, U as PROTOCOL_VERSION, V as Message, W as RpcErrorCode, X as encodeFrame, Y as defaultSocketPath, _ as holderAfterDeparture, a as ackEntries, at as parseIpcRequest, b as nameMatchesPattern, c as clientProof, d as dataPaths, et as makeEventNotification, f as detectRepo, g as generateSessionName, i as RESPONSE_BUDGET_BYTES, it as newSessionId, k as readInbox, l as daemonProof, m as evaluateLiveness, nt as newDeviceId, o as baseName, ot as sanitizeLine, p as effectiveHolder, rt as newMessageId, s as claimOrchestrator, st as socketPathTooLongMessage, t as ConvenoError, tt as makeResult, u as dataDir, v as isOnline, x as newAuthNonce, y as markDelivered } from "./dist-WPVVRVUh.js";
|
|
4
4
|
import { randomBytes } from "node:crypto";
|
|
5
5
|
import { appendFileSync, chmodSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync, unlinkSync, writeFileSync } from "node:fs";
|
|
6
6
|
import { connect, createServer } from "node:net";
|
|
@@ -419,7 +419,7 @@ var Store = class {
|
|
|
419
419
|
}
|
|
420
420
|
};
|
|
421
421
|
// ../daemon/src/server.ts
|
|
422
|
-
const DAEMON_VERSION = "0.1.1-rc.
|
|
422
|
+
const DAEMON_VERSION = "0.1.1-rc.3";
|
|
423
423
|
/** A connection that has not finished the handshake by then is closed. */
|
|
424
424
|
const AUTH_TIMEOUT_MS = 5e3;
|
|
425
425
|
/** Unread messages one session may hold. */
|
|
@@ -458,11 +458,12 @@ var Daemon = class {
|
|
|
458
458
|
requestShutdown;
|
|
459
459
|
log;
|
|
460
460
|
authTimeoutMs;
|
|
461
|
+
pathExists;
|
|
461
462
|
conns = /* @__PURE__ */ new Set();
|
|
462
463
|
deviceId;
|
|
463
464
|
idleSince;
|
|
464
465
|
startedMs;
|
|
465
|
-
constructor(store, token, now, isAlive, idleExitMs, requestIdleExit, requestShutdown, log, authTimeoutMs = AUTH_TIMEOUT_MS) {
|
|
466
|
+
constructor(store, token, now, isAlive, idleExitMs, requestIdleExit, requestShutdown, log, authTimeoutMs = AUTH_TIMEOUT_MS, pathExists = existsSync) {
|
|
466
467
|
this.store = store;
|
|
467
468
|
this.token = token;
|
|
468
469
|
this.now = now;
|
|
@@ -472,6 +473,7 @@ var Daemon = class {
|
|
|
472
473
|
this.requestShutdown = requestShutdown;
|
|
473
474
|
this.log = log;
|
|
474
475
|
this.authTimeoutMs = authTimeoutMs;
|
|
476
|
+
this.pathExists = pathExists;
|
|
475
477
|
this.deviceId = store.deviceId();
|
|
476
478
|
this.startedMs = now().getTime();
|
|
477
479
|
this.idleSince = this.startedMs;
|
|
@@ -557,6 +559,7 @@ var Daemon = class {
|
|
|
557
559
|
case "session.setStatus": return this.setStatus(req.params);
|
|
558
560
|
case "session.list": return this.list(req.params);
|
|
559
561
|
case "session.byHost": return this.byHost(req.params.pid);
|
|
562
|
+
case "session.forget": return this.forget(req.params);
|
|
560
563
|
case "daemon.shutdown": return { ok: true };
|
|
561
564
|
case "orchestrator.claim": return this.claim(req.params.sessionId);
|
|
562
565
|
case "message.send": return this.sendMessage(req.params);
|
|
@@ -744,6 +747,53 @@ var Daemon = class {
|
|
|
744
747
|
const only = holders.length === 1 ? holders[0] : void 0;
|
|
745
748
|
return { session: only ? this.view(only) : null };
|
|
746
749
|
}
|
|
750
|
+
/**
|
|
751
|
+
* Remove offline sessions on the owner's request. Selection: with `ids` or `names` the
|
|
752
|
+
* candidates are the sessions matching either; with neither, every session. `olderThanMs` then
|
|
753
|
+
* keeps only sessions last seen at least that long ago. Online candidates are never removed:
|
|
754
|
+
* those picked by `ids` or `names` come back in `skippedOnline`, and with `olderThanMs` alone
|
|
755
|
+
* they are ignored, since the caller asked for offline sessions. A removed session takes its
|
|
756
|
+
* mailbox with it, in one transaction.
|
|
757
|
+
*/
|
|
758
|
+
forget(p) {
|
|
759
|
+
const nowMs = this.now().getTime();
|
|
760
|
+
const explicit = p.ids !== void 0 || p.names !== void 0;
|
|
761
|
+
const ids = new Set(p.ids ?? []);
|
|
762
|
+
const names = p.names ?? [];
|
|
763
|
+
const matched = this.store.allSessions().filter((r) => {
|
|
764
|
+
if (explicit && !ids.has(r.id) && !names.some((n) => nameMatchesPattern(n, r.name))) return false;
|
|
765
|
+
return p.olderThanMs === void 0 || nowMs - Date.parse(r.lastSeenAt) >= p.olderThanMs;
|
|
766
|
+
});
|
|
767
|
+
const brief = (r) => ({
|
|
768
|
+
id: r.id,
|
|
769
|
+
name: r.name
|
|
770
|
+
});
|
|
771
|
+
const offline = matched.filter((r) => r.status === "offline");
|
|
772
|
+
const skippedOnline = explicit ? matched.filter((r) => r.status !== "offline") : [];
|
|
773
|
+
if (!p.dryRun) this.forgetRows(offline);
|
|
774
|
+
return {
|
|
775
|
+
forgotten: offline.map(brief),
|
|
776
|
+
skippedOnline: skippedOnline.map(brief)
|
|
777
|
+
};
|
|
778
|
+
}
|
|
779
|
+
forgetRows(rows) {
|
|
780
|
+
if (rows.length === 0) return;
|
|
781
|
+
this.store.tx(() => {
|
|
782
|
+
for (const r of rows) this.store.deleteSession(r.id);
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
/**
|
|
786
|
+
* An offline session whose working folder (or repository root) has been missing for
|
|
787
|
+
* PRUNE_MISSING_FOLDER_AFTER_MS is forgotten. One with unread messages is left to the unread
|
|
788
|
+
* rule, so queued mail is never dropped early. One whose host process still runs is kept,
|
|
789
|
+
* because it can come back with a heartbeat.
|
|
790
|
+
*/
|
|
791
|
+
workspaceGone(row, nowMs) {
|
|
792
|
+
if (nowMs - Date.parse(row.lastSeenAt) < 3e5) return false;
|
|
793
|
+
if (this.store.unreadCount(row.id) > 0) return false;
|
|
794
|
+
if (row.hostPid !== void 0 && this.isAlive(row.hostPid)) return false;
|
|
795
|
+
return !this.pathExists(row.cwd) || row.repoRoot !== void 0 && !this.pathExists(row.repoRoot);
|
|
796
|
+
}
|
|
747
797
|
claim(sessionId) {
|
|
748
798
|
this.requireSession(sessionId);
|
|
749
799
|
const rows = this.store.allSessions();
|
|
@@ -877,6 +927,7 @@ var Daemon = class {
|
|
|
877
927
|
* 2. Replaced by a newer live session with the same name, CLI and repo: delete after
|
|
878
928
|
* PRUNE_SUPERSEDED_AFTER_MS.
|
|
879
929
|
* 3. Otherwise delete after PRUNE_OFFLINE_AFTER_MS.
|
|
930
|
+
* Besides these rules, `workspaceGone` forgets an offline session whose folder has been gone a while.
|
|
880
931
|
*/
|
|
881
932
|
shouldPrune(row, all, nowMs) {
|
|
882
933
|
const offlineMs = nowMs - Date.parse(row.lastSeenAt);
|
|
@@ -890,7 +941,7 @@ var Daemon = class {
|
|
|
890
941
|
const rows = this.store.allSessions();
|
|
891
942
|
for (const row of rows) {
|
|
892
943
|
if (row.status === "offline") {
|
|
893
|
-
if (this.shouldPrune(row, rows, nowMs)
|
|
944
|
+
if (this.shouldPrune(row, rows, nowMs) || this.workspaceGone(row, nowMs)) this.forgetRows([row]);
|
|
894
945
|
continue;
|
|
895
946
|
}
|
|
896
947
|
const lastSeenMs = Math.max(Date.parse(row.lastSeenAt), this.startedMs);
|
|
@@ -929,7 +980,7 @@ async function startDaemon(opts) {
|
|
|
929
980
|
close().then(() => opts.onIdleExit?.());
|
|
930
981
|
}, () => {
|
|
931
982
|
close().then(() => opts.onShutdown?.());
|
|
932
|
-
}, createDaemonLog(paths.daemonLog, { now }), opts.authTimeoutMs ?? 5e3);
|
|
983
|
+
}, createDaemonLog(paths.daemonLog, { now }), opts.authTimeoutMs ?? 5e3, opts.pathExists ?? existsSync);
|
|
933
984
|
const srv = createServer((socket) => daemon.attach(socket));
|
|
934
985
|
server = srv;
|
|
935
986
|
await new Promise((resolve, reject) => {
|
|
@@ -164,6 +164,11 @@ const isReservedSessionName = (n) => RESERVED_SESSION_NAMES.includes(n);
|
|
|
164
164
|
*/
|
|
165
165
|
const SessionNameInput = z.string().regex(SESSION_NAME_PATTERN, "invalid session name");
|
|
166
166
|
/**
|
|
167
|
+
* A session name or a simple glob over names: the name characters plus `*`, which matches any run
|
|
168
|
+
* of characters (including none). Used by `session.forget`.
|
|
169
|
+
*/
|
|
170
|
+
const SessionNamePattern = z.string().regex(/^[a-z0-9._@*-]{1,64}$/, "invalid session name pattern");
|
|
171
|
+
/**
|
|
167
172
|
* Human-readable session name, unique per account. Reserved names are refused. ULIDs are
|
|
168
173
|
* uppercase, names are lowercase, so ids and names never collide.
|
|
169
174
|
*/
|
|
@@ -437,6 +442,20 @@ const ListParams = z.object({
|
|
|
437
442
|
cli: CliKind.optional(),
|
|
438
443
|
includeOffline: z.boolean().default(false)
|
|
439
444
|
});
|
|
445
|
+
const ForgetParams = z.object({
|
|
446
|
+
/** Sessions to forget, by id. */
|
|
447
|
+
ids: z.array(SessionId).min(1).max(100).optional(),
|
|
448
|
+
/** Exact names or `*` globs. A name or id selector is joined with `ids` by OR. */
|
|
449
|
+
names: z.array(SessionNamePattern).min(1).max(100).optional(),
|
|
450
|
+
/** Only sessions last seen at least this long ago. With no `ids` or `names`, every offline session this old. */
|
|
451
|
+
olderThanMs: z.number().int().min(0).optional(),
|
|
452
|
+
/** Report what would be forgotten and change nothing. */
|
|
453
|
+
dryRun: z.boolean().default(false)
|
|
454
|
+
}).refine((p) => p.ids !== void 0 || p.names !== void 0 || p.olderThanMs !== void 0, { message: "provide ids, names and/or olderThanMs" });
|
|
455
|
+
const ForgottenSession = z.object({
|
|
456
|
+
id: SessionId,
|
|
457
|
+
name: SessionName
|
|
458
|
+
});
|
|
440
459
|
const sendShape = {
|
|
441
460
|
...sid,
|
|
442
461
|
to: messageEnvelopeShape.to,
|
|
@@ -557,6 +576,13 @@ const ipcMethods = {
|
|
|
557
576
|
params: z.object({ pid: z.number().int().positive() }),
|
|
558
577
|
result: z.object({ session: Session.nullable() })
|
|
559
578
|
},
|
|
579
|
+
"session.forget": {
|
|
580
|
+
params: ForgetParams,
|
|
581
|
+
result: z.object({
|
|
582
|
+
forgotten: z.array(ForgottenSession),
|
|
583
|
+
skippedOnline: z.array(ForgottenSession)
|
|
584
|
+
})
|
|
585
|
+
},
|
|
560
586
|
"daemon.shutdown": {
|
|
561
587
|
params: z.object({}),
|
|
562
588
|
result: z.object({ ok: z.literal(true) })
|
|
@@ -1062,6 +1088,15 @@ function validateRename(sessionId, requested, sessions) {
|
|
|
1062
1088
|
if (sessions.find((s) => s.id !== sessionId && isOnline(s) && s.name === requested)) throw new ConvenoError(RpcErrorCode.Conflict, `The name "${requested}" is already used by an active session. Pick a different name.`);
|
|
1063
1089
|
return parsed.data;
|
|
1064
1090
|
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Does a session name match a pattern? A pattern is an exact name, or a simple glob where `*`
|
|
1093
|
+
* matches any run of characters, including none. Nothing else is special, and the dot is literal.
|
|
1094
|
+
*/
|
|
1095
|
+
function nameMatchesPattern(pattern, name) {
|
|
1096
|
+
if (!pattern.includes("*")) return pattern === name;
|
|
1097
|
+
const source = pattern.split("*").map((part) => part.replace(/[.*+?^${}()|[\]\\]/g, "\\$&")).join(".*");
|
|
1098
|
+
return new RegExp(`^${source}$`).test(name);
|
|
1099
|
+
}
|
|
1065
1100
|
/** The current holder, treating an offline or unknown holder as nobody. */
|
|
1066
1101
|
function effectiveHolder(holder, sessions) {
|
|
1067
1102
|
if (holder === null) return null;
|
|
@@ -1139,6 +1174,8 @@ function dataPaths(platform, dir) {
|
|
|
1139
1174
|
/** The CLI writes its error logs here, and the daemon writes `daemon.log`. */
|
|
1140
1175
|
logs: p.join(dir, "logs"),
|
|
1141
1176
|
daemonLog: p.join(dir, "logs", "daemon.log"),
|
|
1177
|
+
/** What the daemon printed to stdout and stderr, from the last time a client started it. */
|
|
1178
|
+
daemonStartLog: p.join(dir, "logs", "daemon-start.log"),
|
|
1142
1179
|
manifest: p.join(dir, "install-manifest.json")
|
|
1143
1180
|
};
|
|
1144
1181
|
}
|
|
@@ -1467,4 +1504,4 @@ async function detectRepo(cwd, fs) {
|
|
|
1467
1504
|
basename: baseName(cwd)
|
|
1468
1505
|
};
|
|
1469
1506
|
}
|
|
1470
|
-
export {
|
|
1507
|
+
export { makeError as $, resolveRecipient as A, EventPayload as B, pendingForInjection as C, readAncestry as D, proofsMatch as E, validateRename as F, RpcResponse as G, MessageId as H, CLI_KINDS as I, createLineDecoder as J, SessionId as K, DeviceId as L, statusAfterLiveness as M, takeWithinBytes as N, readCommandLine as O, tooManyUnreadMessage as P, isSocketPathTooLong as Q, EVENT_NAMES as R, parseCliVersion as S, planSpawn as T, PROTOCOL_VERSION as U, Message as V, RpcErrorCode as W, encodeFrame as X, defaultSocketPath as Y, ipcMethods as Z, holderAfterDeparture as _, ackEntries as a, parseIpcRequest as at, nameMatchesPattern as b, clientProof as c, dataPaths as d, makeEventNotification as et, detectRepo as f, generateSessionName as g, formatInbox as h, RESPONSE_BUDGET_BYTES as i, newSessionId as it, resolveWindowsCommand as j, readInbox as k, daemonProof as l, evaluateLiveness as m, HEARTBEAT_INTERVAL_MS as n, newDeviceId as nt, baseName as o, sanitizeLine as ot, effectiveHolder as p, SessionNamePattern as q, NOT_FROM_USER_NOTICE as r, newMessageId as rt, claimOrchestrator as s, socketPathTooLongMessage as st, ConvenoError as t, makeResult as tt, dataDir as u, isOnline as v, pendingHookContext as w, newAuthNonce as x, markDelivered as y, EVENT_NOTIFICATION_METHOD as z };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@conveno/cli",
|
|
3
|
-
"version": "0.1.1-rc.
|
|
3
|
+
"version": "0.1.1-rc.3",
|
|
4
4
|
"description": "Connect AI coding CLI sessions so they can message each other.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"repository": {
|
|
@@ -46,15 +46,15 @@
|
|
|
46
46
|
"zod": "4.6.7"
|
|
47
47
|
},
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@conveno/adapter-claude": "0.1.1-rc.
|
|
50
|
-
"@conveno/adapter-codex": "0.1.1-rc.
|
|
51
|
-
"@conveno/adapter-opencode": "0.1.1-rc.
|
|
52
|
-
"@conveno/brand": "0.1.1-rc.
|
|
53
|
-
"@conveno/client": "0.1.1-rc.
|
|
54
|
-
"@conveno/core": "0.1.1-rc.
|
|
55
|
-
"@conveno/daemon": "0.1.1-rc.
|
|
56
|
-
"@conveno/mcp": "0.1.1-rc.
|
|
57
|
-
"@conveno/protocol": "0.1.1-rc.
|
|
49
|
+
"@conveno/adapter-claude": "0.1.1-rc.3",
|
|
50
|
+
"@conveno/adapter-codex": "0.1.1-rc.3",
|
|
51
|
+
"@conveno/adapter-opencode": "0.1.1-rc.3",
|
|
52
|
+
"@conveno/brand": "0.1.1-rc.3",
|
|
53
|
+
"@conveno/client": "0.1.1-rc.3",
|
|
54
|
+
"@conveno/core": "0.1.1-rc.3",
|
|
55
|
+
"@conveno/daemon": "0.1.1-rc.3",
|
|
56
|
+
"@conveno/mcp": "0.1.1-rc.3",
|
|
57
|
+
"@conveno/protocol": "0.1.1-rc.3"
|
|
58
58
|
},
|
|
59
59
|
"scripts": {
|
|
60
60
|
"build": "tsdown",
|