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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (33) hide show
  1. package/README.md +22 -30
  2. package/dist/acp-9pRRszwU.js +82 -0
  3. package/dist/agy-relay-C-nqvieJ.js +137 -0
  4. package/dist/args-C7Agak9f.js +321 -0
  5. package/dist/bin.js +2 -2
  6. package/dist/{ctx-CDLE-2f2.js → ctx-tYftvhz_.js} +2 -3
  7. package/dist/daemon.js +410 -1423
  8. package/dist/daemonError-DNAKEyRT.js +66 -0
  9. package/dist/{dist-TrWRppjR.js → dist-D2hMvcZu.js} +592 -1216
  10. package/dist/dist-D9Gu-mQm.js +547 -0
  11. package/dist/dist-DOGlDbRb.js +504 -0
  12. package/dist/{dist-BPPOKmbH.js → dist-DOKVrSIw.js} +39 -148
  13. package/dist/dist-Dd31Fg0h.js +671 -0
  14. package/dist/{dist-CEJ2-wxh.js → dist-ftx5RNCp.js} +4 -17
  15. package/dist/{dist-E3XvoT1Q.js → dist-iFaY42Bs.js} +1 -1
  16. package/dist/{doctor-CzIGTeNT.js → doctor-BYa-MApu.js} +109 -102
  17. package/dist/fmt-C2SsP5Y0.js +96 -0
  18. package/dist/{hook-CLB_muZS.js → hook-CQeSn-w4.js} +7 -5
  19. package/dist/hook-entry-BXmSN--S.js +2490 -0
  20. package/dist/hook-entry-CgiSN-Oj.js +1 -0
  21. package/dist/main-seh-HPZO.js +971 -0
  22. package/dist/pick-DoyocW55.js +9 -0
  23. package/dist/{run-CYH0CRbp.js → run-B-WfNtCX.js} +627 -1998
  24. package/dist/{runtime-B1Pb9Qqg.js → runtime-Bnjh9BQ8.js} +119 -210
  25. package/dist/{dist-C8JRuLiZ.js → toml-patch-DGzVRdd1.js} +20 -1890
  26. package/dist/watch-Dr2RdyGo.js +185 -0
  27. package/package.json +15 -15
  28. package/dist/acp-BD7Oaerg.js +0 -142
  29. package/dist/args-BRB8QEQM.js +0 -554
  30. package/dist/dist-DcmKjrmu.js +0 -271
  31. package/dist/hook-entry-BlvSoNMm.js +0 -1289
  32. package/dist/hook-entry-CRDh36pe.js +0 -1
  33. package/dist/main-CsCsyq2G.js +0 -1645
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # @conveno/cli
2
2
 
3
- Conveno is a connector. It lets the AI coding CLI sessions you already use find each other, send messages and route work to the one session you pick as the lead (the code and older docs call it the orchestrator). You keep using each CLI the way you do today. This package is the `conveno` command and everything it needs, including the local daemon.
3
+ Conveno connects your AI coding CLI sessions. Open your CLIs, make one the lead, and it hands out work. The other sessions wake up and start working. With Pro it works across your computers and servers. You keep using each CLI the way you do today. This package is the `conveno` command and everything it needs, including the local daemon.
4
4
 
5
5
  - Website: https://conveno.dev
6
6
  - Source and issues: https://github.com/0xPixelNinja/conveno
7
- - Status: pre-alpha. The local mesh works, with spawn, peek, questions and handoff. Pro, the end-to-end encrypted relay between your machines, is in preview.
7
+ - Status: pre-alpha. The local mesh works, with spawn and handoff. Pro, the end-to-end encrypted relay between your machines, is in preview.
8
8
 
9
9
  ## Install
10
10
 
@@ -23,9 +23,9 @@ conveno init
23
23
 
24
24
  `conveno init` finds the supported CLIs on your machine and shows a diff of every config file it would change. It asks before it writes, and it backs each file up first. Add `--dry-run` to print the plan and write nothing.
25
25
 
26
- Then open two CLI sessions, for example Claude Code and Codex. In one, ask it to run `list_sessions`, then to `send` a message to the other. `conveno status` lists the sessions.
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
- Then run `conveno` with no arguments. It opens a full-screen app (Sessions, You, New, Devices, Setup) for the keyboard and mouse: `/` searches, `?` shows the keys. Sessions can message you or ask you questions there. It raises a desktop notification when something needs you; turn that off in Setup or with `CONVENO_NOTIFY=0`, and the mouse with `CONVENO_MOUSE=0`.
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`.
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
 
@@ -33,44 +33,36 @@ Then run `conveno` with no arguments. It opens a full-screen app (Sessions, You,
33
33
 
34
34
  | Command | What it does |
35
35
  |---|---|
36
- | `conveno init [--with-permission-relay]` | Add the Conveno MCP server and hooks to each detected CLI. `--with-permission-relay` also adds the hook for the experimental permission relay. |
36
+ | `conveno init` | Add the Conveno MCP server and hooks to each detected CLI. |
37
37
  | `conveno uninstall` | Undo every install that has not been undone. |
38
- | `conveno status` | Online sessions grouped by repo, with the lead marked. `--all` includes offline ones. |
39
- | `conveno questions [--open]` | Questions workers asked the lead (`conveno tickets` still works): id, state, who asked whom, when, and the first line. `--open` shows only those still waiting. `conveno status` ends with the open count when it is not zero. |
38
+ | `conveno status` | Online sessions grouped by repo, with the lead marked. |
40
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. |
41
40
  | `conveno rename <session> <new-name>` | Rename an online session. |
42
- | `conveno lead <session>` | Make a session the lead. |
43
- | `conveno answer <ticket> <text>` | Answer a ticket as yourself, no agent needed. The ticket is a full id or the start or end of one (6 characters or more). The worker gets the text as an `Answer (ticket ...)` message. For a permission request answer `allow` or `deny`. |
44
- | `conveno permissions [relay on\|off [session]]` | **Experimental, off by default.** `relay on <session>` lets the lead allow or deny that worker's tool permission prompts (Claude Code and Codex); `relay off [session]` ends it (without a name, for every session); no arguments lists the sessions with it on. It only works for a session started with `conveno spawn` or `spawn_session`, so a session you drive yourself is refused. The command prints a warning when it turns the relay on. The first `relay on` shows a diff and adds the CLI's `PermissionRequest` hook (Claude Code, Codex) with init's backup and manifest, so `conveno uninstall` removes it; `conveno init --with-permission-relay` adds it up front. The hook does nothing until the relay is on for a session. A call outside the worker's repo, network use, credential files, elevated rights and anything Conveno cannot read with certainty always stays with the CLI's own prompt, and so does any call the lead does not answer within about 80 seconds. SECURITY.md has the threat model. |
45
- | `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. |
46
- | `conveno spawn <cli> [--cwd <dir>] [--name <name>] [--task <text> \| --task-file <path>] [--headless] [--yes]` | Start a worker session of `claude`, `codex`, `opencode`, `cursor`, `copilot`, `antigravity` or `grok`, and print its name once it registers. The CLI must be installed. `--mode window\|background\|once` picks how it runs (window is the default; background is `--acp`; once is `--headless --one-shot`) and wins over those flags. By default the real CLI opens in a new terminal 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`. With none of those it exits 1 and suggests `--headless`. `--headless` runs the CLI's documented one-shot mode (`claude -p`, `codex exec`, `opencode run`, `agy -p` and so on) detached, with its output in `<data dir>/logs/spawn/<name>.log` (readable by you only); it needs a task, runs it and exits, and the session still registers and shows in `conveno status`. The first task is the CLI's initial prompt argument; for a CLI with none (Antigravity) it is sent as a Conveno message once the session registers, which needs the command to run inside an agent session. `--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. Run from inside an agent session (its shell tool, say), the new session's `spawnedBy` is that session. A task is at most 16000 characters; `--task-file` reads one from a file. |
47
- | `conveno spawn <cli> --acp [--allow <kinds>] [--task <text>]` | Run the worker through the CLI's Agent Client Protocol server, in the background, with `conveno acp-host` driving it. The ACP commands: `claude-agent-acp` (install `@agentclientprotocol/claude-agent-acp`), `codex-acp` (install `@agentclientprotocol/codex-acp`), `opencode acp`, `agent acp` (Cursor), `copilot --acp --stdio`, `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. The task is the first prompt and is optional. The worker keeps running: each message sent to it becomes its next prompt at once when it is idle, or when its current turn ends, under the auto-mode limit. A tool call that needs approval is denied unless `--allow` covers it: comma-separated ACP tool kinds (`read`, `edit`, `delete`, `move`, `search`, `execute`, `think`, `fetch`, `switch_mode`, `other`, or `*`), each optionally with `:` and a title glob (`execute:npm test*`). Allowed calls are answered "allow once", never "always". Denials are reported to the spawning session after the turn. `--headless` picks ACP when the CLI's ACP server is installed; `--one-shot` keeps the one-shot mode. The host's log is `<data dir>/logs/spawn/<name>.log`. See `packages/protocol/PROTOCOL.md`, section 6.8. |
48
- | `conveno attach <worker> [--lines <n>] [--no-follow]` | Print an ACP worker's recent prompts, answers, tool calls and permission answers, and follow new ones until it stops or you press Ctrl+C. Read-only. |
49
- | `conveno stop <worker>` | Stop a background worker. An ACP worker sends `session/cancel` for a running turn, ends its CLI and the processes it started, tells the spawning session why, and goes offline. A one-shot `--headless` run is ended. A worker in a terminal is yours to close. |
50
- | `conveno auto [on\|off\|resume] [<session>]`, `conveno auto limit <n\|default> [<session>]` | Auto mode for a session: waiting messages become its next prompt when its turn ends, and an idle Claude Code or OpenCode session is woken. Without a name it changes the session it is typed in; without arguments it lists the sessions. `resume` lifts a pause by the limit: 20 automatic turns per rolling hour, and a chain of sessions answering each other stops after 20 automatic turns with no person in between (`limit` changes both for one session). The lead may resume a session once per hour; the owner any time. See `packages/protocol/PROTOCOL.md`, section 6.7. |
51
- | `conveno peek <session> [-n 10] [--raw-json]` | Read the last turns (prompts, replies, tool calls) of another session on this machine, with secrets redacted on a best-effort basis. `-n` is 1 to 50. Works for Claude Code, Codex, OpenCode, Copilot and Grok, and for any worker started with `--acp`; Cursor and Antigravity sessions otherwise answer that peek is not supported yet. `--raw-json` prints the daemon's answer. |
52
- | `conveno peek on\|off [session]` | Allow or stop other sessions reading yours. With no session it covers every session online now. The daemon log records each peek (who, whom, how many turns), never the text. |
53
- | `conveno doctor [--cli <list>]` | Check each CLI and the daemon, and say which delivery works for each: next turn, end of turn, idle wake, or inbox only. `--cli claude,codex` checks only those CLIs, so problems in the others do not count. |
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] [--allow <kinds>] [--yes]` | Start a worker session of `claude`, `codex`, `opencode`, `cursor`, `copilot`, `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`, `agent acp` (Cursor), `copilot --acp --stdio`, `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 that needs approval is denied unless `--allow` covers it: comma-separated ACP tool kinds (`read`, `edit`, `delete`, `move`, `search`, `execute`, `think`, `fetch`, `switch_mode`, `other`, or `*`), each optionally with `:` and a title glob (`execute:npm test*`). Allowed calls are answered "allow once", never "always". 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`. |
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
+ | `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. |
54
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. |
55
46
  | `conveno relay status` | Show the relay connection. |
56
47
  | `conveno login [--no-browser]` | Sign in to your Conveno account for Pro. Shows a code and a link, opens the browser, and waits for you to approve the code. The tokens go to `account.json` in the data dir, readable by you only. The local mesh does not need an account. |
57
48
  | `conveno logout` | Sign out on the server and delete the saved tokens. |
58
49
  | `conveno account` | Show your plan and trial. |
59
- | `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. |
60
50
 
61
- `conveno --help` lists the rest, and `conveno <command> --help` shows the options of one. The `mcp`, `hook`, `spawn-run` and `acp-host` commands are what the CLIs, spawned terminals and `conveno spawn --acp` call; you do not run them yourself.
51
+ `conveno --help` lists the rest, and `conveno <command> --help` shows the options of one. The `daemon`, `mcp`, `hook`, `spawn-run` and `acp-host` commands are hidden or are what the CLIs and spawned workers call; you do not run them yourself.
62
52
 
63
53
  ## Supported CLIs
64
54
 
65
- | CLI | Delivery |
66
- |---|---|
67
- | Claude Code | At the start of the next turn (hook), or with the `inbox` tool |
68
- | Codex | At the start of the next turn (hook), or with the `inbox` tool |
69
- | OpenCode | With the `inbox` tool |
70
- | Cursor CLI | After the next tool call (hook), or with the `inbox` tool |
71
- | GitHub Copilot CLI | At the start of the next turn (hook), or with the `inbox` tool |
72
- | Antigravity | Before each model call (hook); in auto mode also at the end of a turn; or with the `inbox` tool |
73
- | Grok | With the `inbox` tool; in auto mode also at the end of a turn (hook) |
55
+ | CLI | Messages arrive | Wakes when idle |
56
+ |---|---|---|
57
+ | Claude Code | Next turn (hook), or `inbox` | Yes |
58
+ | OpenCode | `inbox`, plus the plugin at the end of a turn | Yes (plugin) |
59
+ | Codex | Next turn (hook), or `inbox` | Coming in the next release |
60
+ | Cursor CLI | After the next tool call (hook), or `inbox` | Coming in the next release |
61
+ | GitHub Copilot CLI | Next turn (hook), or `inbox` | Coming in the next release |
62
+ | Antigravity | Before each model call (hook), or `inbox` | Coming in the next release |
63
+ | Grok | `inbox`, plus a hook at the end of a turn | Coming in the next release |
64
+
65
+ A worker started with `conveno spawn` wakes on every message, whatever the CLI.
74
66
 
75
67
  ## Compatibility
76
68
 
@@ -0,0 +1,82 @@
1
+ import { writeFileSync } from "node:fs";
2
+ import { n as runAcpHostFromFile, r as stopRequestPath, t as killProcessTree } from "./dist-DOKVrSIw.js";
3
+ import { It as spawnRecordPath, St as readSpawnRecord } from "./dist-D2hMvcZu.js";
4
+ import { i as parseFlags, t as COMMANDS } from "./args-C7Agak9f.js";
5
+ import { a as fail, n as cmd } from "./fmt-C2SsP5Y0.js";
6
+ // src/acp.ts
7
+ /** How long `conveno stop` waits for a worker to end by itself before it ends the process tree. */
8
+ const STOP_WAIT_MS = 1e4;
9
+ /** `conveno acp-host <launch file>`: what `conveno spawn` runs in the background. Not for people. */
10
+ async function runAcpHostCmd(ctx, argv) {
11
+ const [file] = argv;
12
+ if (!file) return fail(ctx, {
13
+ what: "conveno acp-host needs a launch file",
14
+ detail: ["It is started by conveno spawn."],
15
+ fix: `Run ${cmd(ctx.theme, "conveno spawn <cli>")} instead.`,
16
+ exit: 2,
17
+ ref: "e_usage"
18
+ });
19
+ try {
20
+ return await runAcpHostFromFile(file, {
21
+ dataDir: ctx.dataDir,
22
+ ...ctx.socketPath ? { socketPath: ctx.socketPath } : {},
23
+ ...ctx.daemonEntry ? { daemonEntry: ctx.daemonEntry } : {}
24
+ });
25
+ } catch (e) {
26
+ return fail(ctx, {
27
+ what: "The ACP host could not start",
28
+ detail: [e instanceof Error ? e.message : String(e)],
29
+ fix: `Run ${cmd(ctx.theme, "conveno spawn <cli>")} again.`,
30
+ exit: 1,
31
+ ref: "e_spawn"
32
+ });
33
+ }
34
+ }
35
+ function findWorker(ctx, name, command) {
36
+ if (!name) return fail(ctx, {
37
+ what: `conveno ${command} needs a worker name`,
38
+ fix: `Run ${cmd(ctx.theme, "conveno status")} to see the names.`,
39
+ exit: 2,
40
+ ref: "e_usage"
41
+ });
42
+ const rec = /^[a-z0-9][a-z0-9._@-]{0,63}$/.test(name) ? readSpawnRecord(spawnRecordPath(ctx.dataDir, name)) : void 0;
43
+ if (!rec) return fail(ctx, {
44
+ what: `No running worker named "${name}"`,
45
+ detail: ["Only sessions started by conveno spawn or spawn_session on this machine are workers."],
46
+ fix: `Run ${cmd(ctx.theme, "conveno status")} to see the names.`,
47
+ exit: 1,
48
+ ref: "e_not_found"
49
+ });
50
+ return rec;
51
+ }
52
+ /**
53
+ * `conveno stop <worker>`. An ACP worker gets a stop request: its host sends `session/cancel` for
54
+ * a running turn, ends the agent, reports to the spawner and takes the session offline. A worker in a
55
+ * terminal window is the user's to close.
56
+ */
57
+ async function runStop(ctx, argv) {
58
+ const spec = COMMANDS.find((c) => c.name === "stop");
59
+ if (!spec) return 2;
60
+ const parsed = parseFlags(ctx, spec, argv);
61
+ if (typeof parsed === "number") return parsed;
62
+ const [name] = parsed.positionals;
63
+ const rec = findWorker(ctx, name, "stop");
64
+ if (typeof rec === "number") return rec;
65
+ const t = ctx.theme;
66
+ if (!rec.acp) return fail(ctx, {
67
+ what: `${rec.name} runs in a terminal`,
68
+ detail: ["Conveno does not close a terminal you can see."],
69
+ fix: "Exit the CLI in that terminal.",
70
+ exit: 1,
71
+ ref: "e_spawn"
72
+ });
73
+ const alive = () => rec.pid !== void 0 && ctx.isAlive(rec.pid);
74
+ writeFileSync(stopRequestPath(spawnRecordPath(ctx.dataDir, rec.name)), "", { mode: 384 });
75
+ const end = Date.now() + STOP_WAIT_MS;
76
+ while (alive() && Date.now() < end) await new Promise((r) => setTimeout(r, 100));
77
+ if (alive() && rec.pid !== void 0) killProcessTree(rec.pid, ctx.platform);
78
+ 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`);
80
+ return 0;
81
+ }
82
+ export { runAcpHostCmd, runStop };
@@ -0,0 +1,137 @@
1
+ import { execFile } from "node:child_process";
2
+ import { t as RELAY_SUBCOMMAND } from "./dist-D9Gu-mQm.js";
3
+ import { Nt as runWaker } from "./dist-D2hMvcZu.js";
4
+ import { n as connectOpts } from "./ctx-tYftvhz_.js";
5
+ // src/agy-relay.ts
6
+ /**
7
+ * Time limit of one `agentapi send-message`. It normally answers within about a second; the limit
8
+ * only stops a hung run. It is long so a slow send that succeeds is not taken for a failure.
9
+ */
10
+ const SEND_TIMEOUT_MS = 12e4;
11
+ /** Runs the file directly, never through a shell, so every argument stays one argument. */
12
+ const runSend = (file, args, timeoutMs) => new Promise((resolve) => {
13
+ execFile(file, args, {
14
+ timeout: timeoutMs,
15
+ windowsHide: true,
16
+ encoding: "utf8"
17
+ }, (err) => {
18
+ if (!err) return resolve("sent");
19
+ resolve(err.killed ? "unknown" : "failed");
20
+ });
21
+ });
22
+ const UUID = /^[0-9a-fA-F-]{8,64}$/;
23
+ function relayText(text, count) {
24
+ if (text.length <= 16e3) return text;
25
+ return `[conveno] ${count} message${count === 1 ? "" : "s"} arrived through Conveno, too long to show here. Conveno started this turn; the user did not type it. Read them with the inbox tool (unread_only false).`;
26
+ }
27
+ /**
28
+ * Run `<agy> agentapi send-message <conversation> <text>`. The executable is run directly, never
29
+ * through a shell, so the text stays one argument; on Windows only a real `.exe` is run, because a
30
+ * `.cmd` or `.bat` shim would have cmd.exe parse the text. False only when no turn started: a send
31
+ * killed at the time limit counts as sent, so the waker does not requeue messages agy may already
32
+ * have taken and send them twice (they stay readable with the inbox tool).
33
+ */
34
+ async function sendToConversation(io, exe, conversationId, text) {
35
+ if (io.platform === "win32" && !/\.exe$/i.test(exe)) return false;
36
+ try {
37
+ return await (io.run ?? runSend)(exe, [
38
+ "agentapi",
39
+ "send-message",
40
+ conversationId,
41
+ text
42
+ ], SEND_TIMEOUT_MS) !== "failed";
43
+ } catch {
44
+ return false;
45
+ }
46
+ }
47
+ const END = {
48
+ superseded: "another relay for this conversation took over. Do not start it again.",
49
+ no_session: "no Conveno session belongs to this conversation (is the conveno MCP server on?). Do not start it again.",
50
+ one_shot: "this agy run is one-shot (agy -p), so nothing can wake it. Do not start it again."
51
+ };
52
+ /** agy's one-shot flags: `-p` and its aliases `--print` and `--prompt` (agy docs cli/headless). */
53
+ const ONE_SHOT = /^(?:-p|--print|--prompt)(?:=|$)/;
54
+ /** True when an ancestor of this process is a one-shot `agy -p` run. */
55
+ async function underOneShotAgy(ctx) {
56
+ return ((await ctx.ancestry(2e3).catch(() => void 0))?.entries ?? []).some((e) => {
57
+ const words = Array.from((e.command ?? "").matchAll(/"([^"]*)"|(\S+)/g)).map((m) => m[1] ?? m[2] ?? "");
58
+ const exe = (words[0] ?? "").split(/[\\/]/).pop()?.toLowerCase();
59
+ return (exe === "agy" || exe === "agy.exe") && words.slice(1).some((w) => ONE_SHOT.test(w));
60
+ });
61
+ }
62
+ async function runAgyRelay(ctx, argv, deps = {}) {
63
+ const end = (why, code = 0) => {
64
+ ctx.out(`[conveno] ${RELAY_SUBCOMMAND} ended: ${why}\n`);
65
+ return code;
66
+ };
67
+ if (argv.length > 0) return end("it takes no arguments.", 2);
68
+ const conversationId = ctx.env.ANTIGRAVITY_CONVERSATION_ID;
69
+ const exe = ctx.env.ANTIGRAVITY_AGENTAPI_EXE;
70
+ if (!conversationId || !UUID.test(conversationId) || !exe) return end("it only runs inside an Antigravity agent's command. Nothing to do.");
71
+ if (ctx.platform === "win32" && !/\.exe$/i.test(exe)) return end("ANTIGRAVITY_AGENTAPI_EXE is not an .exe. Do not start it again.");
72
+ if (await underOneShotAgy(ctx)) return end(END.one_shot);
73
+ const controller = new AbortController();
74
+ const signal = controller.signal;
75
+ const stop = () => controller.abort();
76
+ deps.signal?.addEventListener("abort", stop, { once: true });
77
+ if (deps.signal?.aborted) stop();
78
+ const signals = deps.signal ? [] : ["SIGINT", "SIGTERM"];
79
+ for (const s of signals) process.once(s, stop);
80
+ const runWaker$1 = deps.runWaker ?? runWaker;
81
+ const pollMs = deps.pollMs ?? 3e3;
82
+ const findMs = deps.findMs ?? 6e5;
83
+ const retryBase = deps.retryMs ?? 2e3;
84
+ const sleep = (ms) => new Promise((resolve) => {
85
+ const t = setTimeout(resolve, ms);
86
+ signal.addEventListener("abort", () => {
87
+ clearTimeout(t);
88
+ resolve();
89
+ }, { once: true });
90
+ });
91
+ let client;
92
+ let retry = retryBase;
93
+ let looking = Date.now();
94
+ try {
95
+ while (!signal.aborted) {
96
+ let session;
97
+ let c;
98
+ try {
99
+ c = client ??= await ctx.connect(connectOpts(ctx, false));
100
+ const { sessions } = await c["session.list"]({ cli: "antigravity" });
101
+ session = sessions.find((s) => s.nativeId === conversationId && s.status !== "offline");
102
+ retry = retryBase;
103
+ } catch {
104
+ await client?.close().catch(() => void 0);
105
+ client = void 0;
106
+ await sleep(retry);
107
+ retry = Math.min(retry * 2, 6e4);
108
+ continue;
109
+ }
110
+ if (!session) {
111
+ if (Date.now() - looking > findMs) return end(END.no_session);
112
+ await sleep(pollMs);
113
+ continue;
114
+ }
115
+ const hostPid = session.hostPid;
116
+ const reason = await runWaker$1({
117
+ client: c,
118
+ sessionId: session.id,
119
+ signal,
120
+ ...hostPid ? { isHostAlive: () => ctx.isAlive(hostPid) } : {},
121
+ inject: (text, messages) => sendToConversation({
122
+ platform: ctx.platform,
123
+ ...deps.run ? { run: deps.run } : {}
124
+ }, exe, conversationId, relayText(text, messages.length))
125
+ });
126
+ if (reason === "aborted" || reason === "host_exited") return 0;
127
+ if (reason === "superseded") return end(END.superseded);
128
+ looking = Date.now();
129
+ }
130
+ return 0;
131
+ } finally {
132
+ deps.signal?.removeEventListener("abort", stop);
133
+ for (const s of signals) process.off(s, stop);
134
+ await client?.close().catch(() => void 0);
135
+ }
136
+ }
137
+ export { runAgyRelay };
@@ -0,0 +1,321 @@
1
+ import { parseArgs } from "node:util";
2
+ import { a as fail, n as cmd, t as closest } from "./fmt-C2SsP5Y0.js";
3
+ const COMMANDS = [
4
+ {
5
+ name: "init",
6
+ usage: "conveno init [--yes] [--dry-run] [--cli <list>] [--acp-adapters | --no-acp-adapters]",
7
+ summary: "Set up every supported CLI that is installed",
8
+ flags: {
9
+ yes: {
10
+ type: "boolean",
11
+ short: "y",
12
+ help: "Apply without asking"
13
+ },
14
+ "dry-run": {
15
+ type: "boolean",
16
+ help: "Show the changes and write nothing"
17
+ },
18
+ cli: {
19
+ type: "string",
20
+ value: "<list>",
21
+ help: "Only these CLIs, separated by commas or spaces, such as claude,codex"
22
+ },
23
+ accept: {
24
+ type: "string",
25
+ value: "<ids>",
26
+ help: "Say yes to these optional setups without asking, such as copilot-idle-wake"
27
+ },
28
+ "acp-adapters": {
29
+ type: "boolean",
30
+ help: "Let ACP workers fetch the Codex and Claude adapters with npx, without asking"
31
+ },
32
+ "no-acp-adapters": {
33
+ type: "boolean",
34
+ help: "Do not let ACP workers fetch adapters; print how to install them"
35
+ }
36
+ },
37
+ notes: [
38
+ "init shows every file it will change, with a diff, and asks first.",
39
+ "Without a terminal it needs --yes, and exits 2 without it.",
40
+ "Optional setups, such as Copilot idle wake (it turns on Copilot's experimental mode), are asked as yes/no, default no. --yes answers no; pass --accept <id> to say yes.",
41
+ "When Codex or Claude Code is installed without its ACP adapter, init asks once whether npx may fetch it (third-party npm packages, pinned versions). The answer is kept; the two adapter flags change it."
42
+ ]
43
+ },
44
+ {
45
+ name: "uninstall",
46
+ usage: "conveno uninstall [--yes]",
47
+ summary: "Undo what init changed",
48
+ flags: { yes: {
49
+ type: "boolean",
50
+ short: "y",
51
+ help: "Restore without asking"
52
+ } },
53
+ notes: ["Files that still match what init wrote are restored byte for byte.", "Files you or the CLI edited since lose only Conveno's own entries."]
54
+ },
55
+ {
56
+ name: "status",
57
+ usage: "conveno status",
58
+ summary: "List online sessions by repo",
59
+ flags: {}
60
+ },
61
+ {
62
+ name: "send",
63
+ usage: "conveno send <to> <text...> [--urgent]",
64
+ summary: "Send a message to a session as you",
65
+ flags: { urgent: {
66
+ type: "boolean",
67
+ help: "Mark the message urgent"
68
+ } },
69
+ notes: [
70
+ "<to> is a session name or id, lead, or device:name for a session on another device.",
71
+ "Give - as the text to read it from standard input.",
72
+ "The session sees the message as coming from you."
73
+ ],
74
+ positionals: true
75
+ },
76
+ {
77
+ name: "rename",
78
+ usage: "conveno rename <session> <new-name>",
79
+ summary: "Give an online session a new name",
80
+ flags: {},
81
+ notes: ["<session> is a name or id. Names use lowercase letters, digits and . _ @ -."],
82
+ positionals: true
83
+ },
84
+ {
85
+ name: "lead",
86
+ usage: "conveno lead <session> | conveno lead --clear",
87
+ summary: "Make a session the lead, or clear the lead",
88
+ flags: { clear: {
89
+ type: "boolean",
90
+ help: "Make no session the lead"
91
+ } },
92
+ notes: [
93
+ "The lead gets the messages sent to lead.",
94
+ "<session> is a name or id. The old lead is told.",
95
+ "--clear leaves no lead."
96
+ ],
97
+ positionals: true
98
+ },
99
+ {
100
+ name: "spawn",
101
+ usage: "conveno spawn <cli> [options]",
102
+ summary: "Start a worker session of any CLI",
103
+ flags: {
104
+ cwd: {
105
+ type: "string",
106
+ value: "<dir>",
107
+ help: "Folder to work in (default: the current one)"
108
+ },
109
+ name: {
110
+ type: "string",
111
+ value: "<name>",
112
+ help: "Session name (default: the usual one)"
113
+ },
114
+ task: {
115
+ type: "string",
116
+ value: "<text>",
117
+ help: "The first task"
118
+ },
119
+ "task-file": {
120
+ type: "string",
121
+ value: "<path>",
122
+ help: "Read the first task from a file"
123
+ },
124
+ window: {
125
+ type: "boolean",
126
+ help: "Open the CLI in a terminal window you can watch, instead of the background"
127
+ },
128
+ allow: {
129
+ type: "string",
130
+ value: "<kinds>",
131
+ help: "Background: tool calls to approve, such as read,search or execute:npm test*"
132
+ },
133
+ yes: {
134
+ type: "boolean",
135
+ short: "y",
136
+ help: "Start without asking"
137
+ }
138
+ },
139
+ notes: [
140
+ "By default the worker runs in the background over ACP and stays alive. Each message sent to",
141
+ "it becomes its next prompt: right away when it is idle, else when its turn ends.",
142
+ "--window opens the real CLI in a new terminal instead, so you can watch it and take over.",
143
+ "In the background, tool calls that need approval are denied unless --allow covers them.",
144
+ "claude and codex need an ACP adapter installed. End a worker with conveno stop.",
145
+ "Waits until the session registers, then prints its name.",
146
+ "Without a terminal of your own it needs --yes, and exits 2 without it.",
147
+ "At most 8 spawned sessions run at once; CONVENO_SPAWN_MAX changes that."
148
+ ],
149
+ positionals: true
150
+ },
151
+ {
152
+ name: "stop",
153
+ usage: "conveno stop <worker>",
154
+ summary: "Stop a background worker",
155
+ flags: {},
156
+ notes: ["A background worker cancels its current turn, stops its CLI and tells the session that spawned it.", "A worker in a terminal window is yours to close."],
157
+ positionals: true
158
+ },
159
+ {
160
+ name: "devices",
161
+ usage: "conveno devices [pair|join|revoke|rename|accept|reset]",
162
+ summary: "Pair your machines over the relay (Pro)",
163
+ flags: { yes: {
164
+ type: "boolean",
165
+ short: "y",
166
+ help: "Revoke, accept or reset without asking"
167
+ } },
168
+ notes: [
169
+ "conveno devices lists your devices. revoke takes a device name or id, rename a new name.",
170
+ "pair runs on a device you already use, join on the new one, at the same time.",
171
+ "Each device shows an 8-digit code. Type the code from the other screen on each device.",
172
+ "revoke removes a device for good: it can no longer read or send for your sessions.",
173
+ "accept <head> ends a device list conflict by taking the relay's list with that head.",
174
+ "reset forgets this device's list after you reset your devices on the account page.",
175
+ "Needs a Conveno Pro login on both devices."
176
+ ],
177
+ positionals: true
178
+ },
179
+ {
180
+ name: "relay",
181
+ usage: "conveno relay status",
182
+ summary: "Show the relay connection",
183
+ flags: {},
184
+ positionals: true
185
+ },
186
+ {
187
+ name: "doctor",
188
+ usage: "conveno doctor [--cli <list>]",
189
+ summary: "Check each CLI and the daemon",
190
+ flags: { cli: {
191
+ type: "string",
192
+ value: "<list>",
193
+ help: "Only these CLIs, separated by commas or spaces, such as claude,codex"
194
+ } }
195
+ },
196
+ {
197
+ name: "login",
198
+ usage: "conveno login [--no-browser]",
199
+ summary: "Sign in to your Conveno account",
200
+ flags: { "no-browser": {
201
+ type: "boolean",
202
+ help: "Print the sign-in link, do not open it"
203
+ } },
204
+ notes: [
205
+ "login shows a code and a link. Approve the code in your browser and the terminal signs in.",
206
+ "The account is only for Conveno Pro. Everything on this machine works without one.",
207
+ "The tokens are kept in the data dir, in account.json, readable by you only."
208
+ ]
209
+ },
210
+ {
211
+ name: "logout",
212
+ usage: "conveno logout",
213
+ summary: "Sign out and delete the saved tokens",
214
+ flags: {}
215
+ },
216
+ {
217
+ name: "account",
218
+ usage: "conveno account",
219
+ summary: "Show your plan and trial",
220
+ flags: {}
221
+ },
222
+ {
223
+ name: "daemon",
224
+ usage: "conveno daemon start|stop|status",
225
+ summary: "Manage the background daemon",
226
+ flags: {},
227
+ positionals: true,
228
+ hidden: true
229
+ },
230
+ {
231
+ name: "mcp",
232
+ usage: "conveno mcp --cli <cli>",
233
+ summary: "MCP server on stdio (CLIs launch this)",
234
+ flags: { cli: {
235
+ type: "string",
236
+ value: "<cli>",
237
+ help: "The CLI that starts it, such as claude"
238
+ } }
239
+ },
240
+ {
241
+ name: "hook",
242
+ usage: "conveno hook <cli> <event>",
243
+ summary: "Hook entry (CLIs launch this)",
244
+ flags: {},
245
+ positionals: true
246
+ }
247
+ ];
248
+ const COMMAND_NAMES = COMMANDS.filter((c) => !c.hidden).map((c) => c.name);
249
+ /** `conveno <command> --help`. */
250
+ function commandHelp(ctx, spec) {
251
+ const t = ctx.theme;
252
+ const lines = [
253
+ spec.summary,
254
+ "",
255
+ `Usage: ${spec.usage}`
256
+ ];
257
+ const flags = Object.entries(spec.flags);
258
+ if (flags.length > 0) {
259
+ lines.push("", "Options:");
260
+ const rows = flags.map(([name, f]) => {
261
+ return [`${f.short ? `-${f.short}, ` : ""}--${name}${f.value ? ` ${f.value}` : ""}`, f.help];
262
+ });
263
+ const width = Math.max(...rows.map(([l]) => l.length)) + 2;
264
+ for (const [l, h] of rows) lines.push(` ${t.bold(l.padEnd(width))}${h}`);
265
+ }
266
+ if (spec.notes?.length) lines.push("", ...spec.notes);
267
+ return `${lines.join("\n")}\n`;
268
+ }
269
+ /**
270
+ * Parse a command's arguments. Unknown flags and stray words are usage errors (exit 2) with a
271
+ * "Did you mean" when a known flag is within two edits. Returns the exit code on failure.
272
+ */
273
+ function parseFlags(ctx, spec, argv) {
274
+ const options = {};
275
+ for (const [name, f] of Object.entries(spec.flags)) options[name] = {
276
+ type: f.type,
277
+ ...f.short ? { short: f.short } : {}
278
+ };
279
+ try {
280
+ const r = parseArgs({
281
+ args: argv,
282
+ options,
283
+ allowPositionals: spec.positionals === true,
284
+ strict: true
285
+ });
286
+ return {
287
+ values: r.values,
288
+ positionals: r.positionals
289
+ };
290
+ } catch (e) {
291
+ const t = ctx.theme;
292
+ const code = e.code;
293
+ const message = e instanceof Error ? e.message : "";
294
+ const unknown = /Unknown option '(-{1,2}[^']+)'/.exec(message)?.[1];
295
+ if (code === "ERR_PARSE_ARGS_UNKNOWN_OPTION" && unknown) {
296
+ const suggestion = closest(unknown.replace(/^-+/, ""), Object.keys(spec.flags));
297
+ return fail(ctx, {
298
+ what: `Unknown option ${unknown} for conveno ${spec.name}`,
299
+ fix: `Run ${cmd(t, `conveno ${spec.name} --help`)} to see the options.`,
300
+ ...suggestion ? { didYouMean: `Did you mean --${suggestion}?` } : {},
301
+ exit: 2,
302
+ ref: "e_usage"
303
+ });
304
+ }
305
+ if (code === "ERR_PARSE_ARGS_INVALID_OPTION_VALUE") return fail(ctx, {
306
+ what: `A conveno ${spec.name} option is missing its value`,
307
+ detail: [message.split("\n")[0] ?? message],
308
+ fix: `Run ${cmd(t, `conveno ${spec.name} --help`)} to see the options.`,
309
+ exit: 2,
310
+ ref: "e_usage"
311
+ });
312
+ const stray = /argument '([^']+)'/.exec(message)?.[1];
313
+ return fail(ctx, {
314
+ what: stray ? `Unexpected argument "${stray}" for conveno ${spec.name}` : `Could not read the arguments for conveno ${spec.name}`,
315
+ fix: `Run ${cmd(t, `conveno ${spec.name} --help`)} to see the options.`,
316
+ exit: 2,
317
+ ref: "e_usage"
318
+ });
319
+ }
320
+ }
321
+ export { parseFlags as i, COMMAND_NAMES as n, commandHelp as r, COMMANDS as t };
package/dist/bin.js CHANGED
@@ -26,9 +26,9 @@ for (const stream of [process.stdout, process.stderr]) stream.on("error", (err)
26
26
  });
27
27
  try {
28
28
  let code;
29
- if (isHook) code = await (await import("./hook-entry-CRDh36pe.js")).runHookEntry(argv.slice(1));
29
+ if (isHook) code = await (await import("./hook-entry-CgiSN-Oj.js")).runHookEntry(argv.slice(1));
30
30
  else {
31
- const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-CsCsyq2G.js"), import("./runtime-B1Pb9Qqg.js")]);
31
+ const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-seh-HPZO.js"), import("./runtime-Bnjh9BQ8.js")]);
32
32
  code = await main(argv, createRuntimeCtx());
33
33
  }
34
34
  if (isHook) process.exit(code);