@conveno/cli 0.2.0-rc.14 → 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 +2 -2
- package/dist/{acp-OHqthTVC.js → acp-BtwJHwcr.js} +39 -7
- package/dist/{agy-relay-DLP2H1Rj.js → agy-relay-KS1DbLqD.js} +3 -2
- package/dist/{args-DmUsbNu9.js → args-CtyKPZuN.js} +17 -4
- package/dist/bin.js +2 -2
- package/dist/daemon.js +79 -9
- package/dist/{daemonError-CUE_dVn-.js → daemonError-DUP5zkiR.js} +1 -1
- package/dist/{dist-D-PhGsuL.js → dist-BqfYxlVP.js} +1 -1
- package/dist/{dist-BYkDv29h.js → dist-Ch3ohbIk.js} +2 -1
- package/dist/{dist-BRjg9CLd.js → dist-CkqMgCGl.js} +15 -4
- package/dist/{dist-BiV6HopA.js → dist-DVLAWfDg.js} +284 -40
- package/dist/{dist-1k5b8UGF.js → dist-DnWOZkAu.js} +221 -20
- package/dist/{dist-Cv5et1iE.js → dist-X1bpJWck.js} +1 -1
- package/dist/{dist-vefQHFb-.js → dist-XoKXwG-y.js} +1 -1
- package/dist/{dist-C4Ey9THP.js → dist-fwpPA9AY.js} +1 -1
- package/dist/{hook-mvifUk0K.js → hook-DHMu72Vf.js} +1 -1
- package/dist/{hook-entry-Cxh3yIdT.js → hook-entry-CLAuy_HJ.js} +6 -6
- package/dist/hook-entry-DY-CMxKE.js +1 -0
- package/dist/{main-BY7Kcf9S.js → main-DVIyOy85.js} +32 -16
- package/dist/{pick-ClIK4l8K.js → pick-UDFASnAn.js} +1 -1
- package/dist/{run-BYmOjvDF.js → run-B-UMVEQs.js} +4010 -1789
- package/dist/{runtime-PeEPWwix.js → runtime-CU-5JQvj.js} +36 -12
- package/dist/{uninstall-CQoGVhp3.js → uninstall-jwneyeJm.js} +7 -7
- package/dist/{watch-CaC2G2cT.js → watch-Cpp4Uwsd.js} +4 -4
- package/package.json +14 -13
- package/dist/hook-entry-De06GWme.js +0 -1
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
|
|
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 `
|
|
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 {
|
|
3
|
-
import {
|
|
4
|
-
import { a as parseFlags, n as COMMANDS } from "./args-
|
|
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
|
-
|
|
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
|
|
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-
|
|
3
|
-
import {
|
|
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
|
/**
|
|
@@ -64,6 +64,7 @@ async function runAgyRelay(ctx, argv, deps = {}) {
|
|
|
64
64
|
ctx.out(`[conveno] ${RELAY_SUBCOMMAND} ended: ${why}\n`);
|
|
65
65
|
return code;
|
|
66
66
|
};
|
|
67
|
+
if (ctx.env.CONVENO_ACP_WORKER === "1") return 0;
|
|
67
68
|
if (argv.length > 0) return end("it takes no arguments.", 2);
|
|
68
69
|
const conversationId = ctx.env.ANTIGRAVITY_CONVERSATION_ID;
|
|
69
70
|
const exe = ctx.env.ANTIGRAVITY_AGENTAPI_EXE;
|
|
@@ -45,7 +45,7 @@ const COMMANDS = [
|
|
|
45
45
|
"worker-access": {
|
|
46
46
|
type: "string",
|
|
47
47
|
value: "<read|edit|full>",
|
|
48
|
-
help: "What background workers may do: read, edit (the default)
|
|
48
|
+
help: "What background workers may do: read, edit or full (the default)"
|
|
49
49
|
}
|
|
50
50
|
},
|
|
51
51
|
notes: [
|
|
@@ -161,7 +161,17 @@ const COMMANDS = [
|
|
|
161
161
|
access: {
|
|
162
162
|
type: "string",
|
|
163
163
|
value: "<read|edit|full>",
|
|
164
|
-
help: "Background: what the worker may do without asking (default:
|
|
164
|
+
help: "Background: what the worker may do without asking (default: your setting, full unless changed)"
|
|
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)"
|
|
165
175
|
},
|
|
166
176
|
yes: {
|
|
167
177
|
type: "boolean",
|
|
@@ -170,12 +180,15 @@ 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
|
-
"change files and fetch pages
|
|
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",
|
|
176
188
|
"it becomes its next prompt: right away when it is idle, else when its turn ends.",
|
|
177
189
|
"--window opens the real CLI in a new terminal instead, so you can watch it and take over.",
|
|
178
|
-
"In the background, tool calls the preset does not cover are
|
|
190
|
+
"In the background, tool calls the preset does not cover are asked of the session that spawned the worker,",
|
|
191
|
+
"and denied if nobody answers in time or there is nobody to ask.",
|
|
179
192
|
"Conveno's own tools, such as send, are always allowed.",
|
|
180
193
|
"claude and codex need an ACP adapter installed. End a worker with conveno stop.",
|
|
181
194
|
"Waits until the session registers, then prints its name.",
|
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-
|
|
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-
|
|
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-
|
|
4
|
-
import { $
|
|
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-
|
|
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.
|
|
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. */
|
|
@@ -2046,6 +2059,10 @@ var Daemon = class {
|
|
|
2046
2059
|
idleSince;
|
|
2047
2060
|
startedMs;
|
|
2048
2061
|
/** Permission requests of workers that wait for their spawner, by request id. In memory only. */
|
|
2062
|
+
/** When each session last sent a message (since this daemon started). */
|
|
2063
|
+
lastSent = /* @__PURE__ */ new Map();
|
|
2064
|
+
/** The model label a worker host reported at registration. Memory only. */
|
|
2065
|
+
modelLabels = /* @__PURE__ */ new Map();
|
|
2049
2066
|
asks = /* @__PURE__ */ new Map();
|
|
2050
2067
|
/** When each session went offline, for the removal grace. In memory only. */
|
|
2051
2068
|
offlineSince = /* @__PURE__ */ new Map();
|
|
@@ -2137,6 +2154,10 @@ var Daemon = class {
|
|
|
2137
2154
|
this.send(conn, makeError(req.id, RpcErrorCode.Unauthorized, unauthorizedMessage));
|
|
2138
2155
|
return;
|
|
2139
2156
|
}
|
|
2157
|
+
if (req.method === "permission.ask") {
|
|
2158
|
+
(async () => this.dispatch(conn, req))().then((result) => this.send(conn, makeResult(req.id, result)), (e) => this.sendError(conn, req.id, req.method, e));
|
|
2159
|
+
return;
|
|
2160
|
+
}
|
|
2140
2161
|
try {
|
|
2141
2162
|
const result = await this.dispatch(conn, req);
|
|
2142
2163
|
const flushed = req.method === "daemon.shutdown" ? this.requestShutdown : void 0;
|
|
@@ -2158,7 +2179,11 @@ var Daemon = class {
|
|
|
2158
2179
|
case "hello": return this.hello(conn, req.params);
|
|
2159
2180
|
case "auth": return this.auth(conn, req.params);
|
|
2160
2181
|
case "session.register": return this.registerAsync(req.params);
|
|
2161
|
-
case "session.heartbeat":
|
|
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
|
+
}
|
|
2162
2187
|
case "session.unregister": return this.unregister(req.params.sessionId, req.params.pid);
|
|
2163
2188
|
case "session.remove": return this.remove(req.params.sessionId);
|
|
2164
2189
|
case "session.rename": return this.rename(req.params);
|
|
@@ -2179,6 +2204,7 @@ var Daemon = class {
|
|
|
2179
2204
|
case "permission.answer": return this.permissionAnswer(req.params);
|
|
2180
2205
|
case "message.send": return this.sendMessage(req.params);
|
|
2181
2206
|
case "owner.send": return this.ownerSend(conn, req.params);
|
|
2207
|
+
case "message.recent": return this.recent(conn, req.params);
|
|
2182
2208
|
case "message.inbox": return this.inbox(req.params);
|
|
2183
2209
|
case "message.deliver": return this.deliver(req.params);
|
|
2184
2210
|
case "message.ack": return this.ack(req.params);
|
|
@@ -2241,7 +2267,9 @@ var Daemon = class {
|
|
|
2241
2267
|
...row,
|
|
2242
2268
|
deliveryTier: tier
|
|
2243
2269
|
}, holder?.id === row.id, this.store.unreadCount(row.id) + this.stalledWoken(row.id)),
|
|
2244
|
-
wakeable: tier === "live" || tier === "acp"
|
|
2270
|
+
wakeable: tier === "live" || tier === "acp",
|
|
2271
|
+
...this.lastSent.has(row.id) ? { lastSentAt: this.lastSent.get(row.id) } : {},
|
|
2272
|
+
...this.modelLabels.has(row.id) ? { model: this.modelLabels.get(row.id) } : {}
|
|
2245
2273
|
};
|
|
2246
2274
|
}
|
|
2247
2275
|
/** The orchestrator as routing sees it: the holder, if it is online. */
|
|
@@ -2345,6 +2373,7 @@ var Daemon = class {
|
|
|
2345
2373
|
return r;
|
|
2346
2374
|
});
|
|
2347
2375
|
this.attachedOf(row);
|
|
2376
|
+
if (p.model !== void 0) this.setModelLabel(row.id, p.model);
|
|
2348
2377
|
this.emitSession(row.id, "registered");
|
|
2349
2378
|
this.claimPreferredLead(row);
|
|
2350
2379
|
return { session: this.view(this.store.getSession(row.id) ?? row) };
|
|
@@ -2384,6 +2413,12 @@ var Daemon = class {
|
|
|
2384
2413
|
this.emitSession(sessionId, "updated");
|
|
2385
2414
|
return { lastSeenAt: at };
|
|
2386
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
|
+
}
|
|
2387
2422
|
depart(sessionId, change) {
|
|
2388
2423
|
const before = this.store.holder();
|
|
2389
2424
|
const after = holderAfterDeparture(before, sessionId);
|
|
@@ -2452,6 +2487,8 @@ var Daemon = class {
|
|
|
2452
2487
|
this.offlineSince.delete(sessionId);
|
|
2453
2488
|
this.attached.delete(sessionId);
|
|
2454
2489
|
this.hookAt.delete(sessionId);
|
|
2490
|
+
this.lastSent.delete(sessionId);
|
|
2491
|
+
this.modelLabels.delete(sessionId);
|
|
2455
2492
|
this.settleAsksOf(sessionId);
|
|
2456
2493
|
this.emit({
|
|
2457
2494
|
event: "session.updated",
|
|
@@ -2723,6 +2760,8 @@ var Daemon = class {
|
|
|
2723
2760
|
this.attached.delete(from.id);
|
|
2724
2761
|
this.hookAt.delete(from.id);
|
|
2725
2762
|
this.offlineSince.delete(from.id);
|
|
2763
|
+
this.lastSent.delete(from.id);
|
|
2764
|
+
this.modelLabels.delete(from.id);
|
|
2726
2765
|
this.relay?.sessionsChanged();
|
|
2727
2766
|
if (lead) this.emit({
|
|
2728
2767
|
event: "orchestrator.changed",
|
|
@@ -2755,6 +2794,8 @@ var Daemon = class {
|
|
|
2755
2794
|
this.offlineSince.delete(r.id);
|
|
2756
2795
|
this.attached.delete(r.id);
|
|
2757
2796
|
this.hookAt.delete(r.id);
|
|
2797
|
+
this.lastSent.delete(r.id);
|
|
2798
|
+
this.modelLabels.delete(r.id);
|
|
2758
2799
|
}
|
|
2759
2800
|
}
|
|
2760
2801
|
leadName(id) {
|
|
@@ -2876,9 +2917,9 @@ var Daemon = class {
|
|
|
2876
2917
|
clearTimeout(ask.timer);
|
|
2877
2918
|
ask.resolve(result);
|
|
2878
2919
|
}
|
|
2879
|
-
/** The worker left: its waiting requests end as
|
|
2920
|
+
/** The worker left: its waiting requests end as `worker_offline`. */
|
|
2880
2921
|
settleAsksOf(worker) {
|
|
2881
|
-
for (const [id, a] of this.asks) if (a.worker === worker) this.settleAsk(id, { answer: "
|
|
2922
|
+
for (const [id, a] of this.asks) if (a.worker === worker) this.settleAsk(id, { answer: "worker_offline" });
|
|
2882
2923
|
}
|
|
2883
2924
|
clearLead(conn) {
|
|
2884
2925
|
this.requireCli(conn, "clear the lead");
|
|
@@ -2924,12 +2965,14 @@ var Daemon = class {
|
|
|
2924
2965
|
const sender = this.requireSession(p.sessionId);
|
|
2925
2966
|
if (sender.status === "offline") throw new ConvenoError(RpcErrorCode.NotFound, `Session "${sender.name}" is offline. Register the session again before sending.`);
|
|
2926
2967
|
if (p.kind === "system") throw new ConvenoError(RpcErrorCode.InvalidParams, "Messages of kind \"system\" are made by the Conveno daemon only. Send kind \"text\" instead.");
|
|
2927
|
-
|
|
2968
|
+
const sent = this.deliverFrom({
|
|
2928
2969
|
id: sender.id,
|
|
2929
2970
|
name: sender.name,
|
|
2930
2971
|
cli: sender.cli,
|
|
2931
2972
|
hops: sender.status === "busy" ? sender.turnHops : 0
|
|
2932
2973
|
}, p);
|
|
2974
|
+
this.lastSent.set(sender.id, this.iso());
|
|
2975
|
+
return sent;
|
|
2933
2976
|
}
|
|
2934
2977
|
/** The recipient names the owner: `you`, or the id of a message the owner sent. */
|
|
2935
2978
|
isOwnerRecipient(to) {
|
|
@@ -2981,6 +3024,29 @@ var Daemon = class {
|
|
|
2981
3024
|
requireCli(conn, what) {
|
|
2982
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.`);
|
|
2983
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
|
+
}
|
|
2984
3050
|
ownerSend(conn, p) {
|
|
2985
3051
|
this.requireCli(conn, "send as the owner");
|
|
2986
3052
|
return this.deliverFrom({
|
|
@@ -3527,6 +3593,10 @@ async function startDaemon(opts) {
|
|
|
3527
3593
|
throw e;
|
|
3528
3594
|
}
|
|
3529
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
|
+
}
|
|
3530
3600
|
// ../daemon/src/bin.ts
|
|
3531
3601
|
async function main() {
|
|
3532
3602
|
const handle = await startDaemon({
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile } from "node:fs/promises";
|
|
2
2
|
import { join } from "node:path";
|
|
3
|
-
import { At as
|
|
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 {
|
|
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,
|
|
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);
|