@conveno/cli 0.2.0-rc.6 → 0.2.0-rc.8

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.
@@ -1,7 +1,7 @@
1
1
  import { writeFileSync } from "node:fs";
2
- import { n as runAcpHostFromFile, r as stopRequestPath, t as killProcessTree } from "./dist-BAlMjYqQ.js";
3
- import { Pt as spawnRecordPath, xt as readSpawnRecord } from "./dist-BTLBO1Rp.js";
4
- import { i as parseFlags, t as COMMANDS } from "./args-D9T-6TDw.js";
2
+ import { n as runAcpHostFromFile, r as stopRequestPath, t as killProcessTree } from "./dist-BlWWt5gx.js";
3
+ import { It as spawnRecordPath, St as readSpawnRecord } from "./dist-BBdba94T.js";
4
+ import { a as parseFlags, n as COMMANDS } from "./args-CGL-AmNd.js";
5
5
  import { a as fail, n as cmd } from "./fmt-C2SsP5Y0.js";
6
6
  // src/acp.ts
7
7
  /** How long `conveno stop` waits for a worker to end by itself before it ends the process tree. */
@@ -0,0 +1,137 @@
1
+ import { execFile } from "node:child_process";
2
+ import { t as RELAY_SUBCOMMAND } from "./dist-B6Sm0MRT.js";
3
+ import { Nt as runWaker } from "./dist-BBdba94T.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 };
@@ -1,61 +1,93 @@
1
1
  import { parseArgs } from "node:util";
2
2
  import { a as fail, n as cmd, t as closest } from "./fmt-C2SsP5Y0.js";
3
+ // src/args.ts
4
+ const SETUP_FLAGS = {
5
+ yes: {
6
+ type: "boolean",
7
+ short: "y",
8
+ help: "Apply without asking"
9
+ },
10
+ "dry-run": {
11
+ type: "boolean",
12
+ help: "Show the changes and write nothing"
13
+ },
14
+ cli: {
15
+ type: "string",
16
+ value: "<list>",
17
+ help: "Only these AI tools, separated by commas or spaces, such as claude,codex"
18
+ },
19
+ accept: {
20
+ type: "string",
21
+ value: "<ids>",
22
+ help: "Say yes to these extras without asking, such as copilot-idle-wake"
23
+ },
24
+ "acp-adapters": {
25
+ type: "boolean",
26
+ help: "Let ACP workers fetch the Codex and Claude adapters with npx, without asking"
27
+ },
28
+ "no-acp-adapters": {
29
+ type: "boolean",
30
+ help: "Do not let ACP workers fetch adapters; print how to install them"
31
+ }
32
+ };
3
33
  const COMMANDS = [
4
34
  {
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",
35
+ name: "setup",
36
+ usage: "conveno setup [--yes] [--dry-run] [--cli <list>] [--lead <cli>]",
37
+ summary: "Connect Conveno to your AI tools",
8
38
  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: {
39
+ ...SETUP_FLAGS,
40
+ lead: {
19
41
  type: "string",
20
- value: "<list>",
21
- help: "Only these CLIs, comma separated, such as claude,codex"
22
- },
23
- "acp-adapters": {
24
- type: "boolean",
25
- help: "Let ACP workers fetch the Codex and Claude adapters with npx, without asking"
26
- },
27
- "no-acp-adapters": {
28
- type: "boolean",
29
- help: "Do not let ACP workers fetch adapters; print how to install them"
42
+ value: "<cli>",
43
+ help: "The AI tool that should lead when it starts, such as claude"
30
44
  }
31
45
  },
32
46
  notes: [
33
- "init shows every file it will change, with a diff, and asks first.",
47
+ "In a terminal, setup walks you through it. With --yes, or without a terminal, it applies the changes without a walk-through.",
48
+ "Setup shows every file it will change and asks first. Without a terminal it needs --yes, and exits 2 without it.",
49
+ "Extras, 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.",
50
+ "Undo any time with conveno uninstall."
51
+ ]
52
+ },
53
+ {
54
+ name: "init",
55
+ usage: "conveno init [--yes] [--dry-run] [--cli <list>] [--acp-adapters | --no-acp-adapters]",
56
+ summary: "Set up every supported AI tool that is installed",
57
+ flags: SETUP_FLAGS,
58
+ notes: [
59
+ "init is the older name for setup. It shows every file it will change, with a diff, and asks first.",
34
60
  "Without a terminal it needs --yes, and exits 2 without it.",
61
+ "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.",
35
62
  "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."
36
- ]
63
+ ],
64
+ hidden: true
37
65
  },
38
66
  {
39
67
  name: "uninstall",
40
68
  usage: "conveno uninstall [--yes]",
41
- summary: "Undo what init changed",
69
+ summary: "Remove Conveno from your AI tools",
42
70
  flags: { yes: {
43
71
  type: "boolean",
44
72
  short: "y",
45
- help: "Restore without asking"
73
+ help: "Go ahead without asking"
46
74
  } },
47
- 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."]
75
+ notes: [
76
+ "Stops Conveno's background service first, then puts your AI tools back the way they were.",
77
+ "Files that are still as setup left them are restored exactly.",
78
+ "Files you or the AI tool changed since lose only Conveno's own entries."
79
+ ]
48
80
  },
49
81
  {
50
82
  name: "status",
51
83
  usage: "conveno status",
52
- summary: "List online sessions by repo",
84
+ summary: "See which AI sessions are running",
53
85
  flags: {}
54
86
  },
55
87
  {
56
88
  name: "send",
57
89
  usage: "conveno send <to> <text...> [--urgent]",
58
- summary: "Send a message to a session as you",
90
+ summary: "Send a message to a running session",
59
91
  flags: { urgent: {
60
92
  type: "boolean",
61
93
  help: "Mark the message urgent"
@@ -73,7 +105,8 @@ const COMMANDS = [
73
105
  summary: "Give an online session a new name",
74
106
  flags: {},
75
107
  notes: ["<session> is a name or id. Names use lowercase letters, digits and . _ @ -."],
76
- positionals: true
108
+ positionals: true,
109
+ hidden: true
77
110
  },
78
111
  {
79
112
  name: "lead",
@@ -88,7 +121,8 @@ const COMMANDS = [
88
121
  "<session> is a name or id. The old lead is told.",
89
122
  "--clear leaves no lead."
90
123
  ],
91
- positionals: true
124
+ positionals: true,
125
+ hidden: true
92
126
  },
93
127
  {
94
128
  name: "spawn",
@@ -140,7 +174,8 @@ const COMMANDS = [
140
174
  "Without a terminal of your own it needs --yes, and exits 2 without it.",
141
175
  "At most 8 spawned sessions run at once; CONVENO_SPAWN_MAX changes that."
142
176
  ],
143
- positionals: true
177
+ positionals: true,
178
+ hidden: true
144
179
  },
145
180
  {
146
181
  name: "stop",
@@ -148,7 +183,8 @@ const COMMANDS = [
148
183
  summary: "Stop a background worker",
149
184
  flags: {},
150
185
  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."],
151
- positionals: true
186
+ positionals: true,
187
+ hidden: true
152
188
  },
153
189
  {
154
190
  name: "devices",
@@ -168,14 +204,16 @@ const COMMANDS = [
168
204
  "reset forgets this device's list after you reset your devices on the account page.",
169
205
  "Needs a Conveno Pro login on both devices."
170
206
  ],
171
- positionals: true
207
+ positionals: true,
208
+ hidden: true
172
209
  },
173
210
  {
174
211
  name: "relay",
175
212
  usage: "conveno relay status",
176
213
  summary: "Show the relay connection",
177
214
  flags: {},
178
- positionals: true
215
+ positionals: true,
216
+ hidden: true
179
217
  },
180
218
  {
181
219
  name: "doctor",
@@ -184,8 +222,9 @@ const COMMANDS = [
184
222
  flags: { cli: {
185
223
  type: "string",
186
224
  value: "<list>",
187
- help: "Only these CLIs, comma separated, such as claude,codex"
188
- } }
225
+ help: "Only these AI tools, separated by commas or spaces, such as claude,codex"
226
+ } },
227
+ hidden: true
189
228
  },
190
229
  {
191
230
  name: "login",
@@ -199,19 +238,22 @@ const COMMANDS = [
199
238
  "login shows a code and a link. Approve the code in your browser and the terminal signs in.",
200
239
  "The account is only for Conveno Pro. Everything on this machine works without one.",
201
240
  "The tokens are kept in the data dir, in account.json, readable by you only."
202
- ]
241
+ ],
242
+ hidden: true
203
243
  },
204
244
  {
205
245
  name: "logout",
206
246
  usage: "conveno logout",
207
247
  summary: "Sign out and delete the saved tokens",
208
- flags: {}
248
+ flags: {},
249
+ hidden: true
209
250
  },
210
251
  {
211
252
  name: "account",
212
253
  usage: "conveno account",
213
254
  summary: "Show your plan and trial",
214
- flags: {}
255
+ flags: {},
256
+ hidden: true
215
257
  },
216
258
  {
217
259
  name: "daemon",
@@ -228,18 +270,22 @@ const COMMANDS = [
228
270
  flags: { cli: {
229
271
  type: "string",
230
272
  value: "<cli>",
231
- help: "claude, codex or opencode"
232
- } }
273
+ help: "The CLI that starts it, such as claude"
274
+ } },
275
+ hidden: true
233
276
  },
234
277
  {
235
278
  name: "hook",
236
279
  usage: "conveno hook <cli> <event>",
237
280
  summary: "Hook entry (CLIs launch this)",
238
281
  flags: {},
239
- positionals: true
282
+ positionals: true,
283
+ hidden: true
240
284
  }
241
285
  ];
242
286
  const COMMAND_NAMES = COMMANDS.filter((c) => !c.hidden).map((c) => c.name);
287
+ /** Every command that works, shown in help or not. Used for "Did you mean". */
288
+ const ALL_COMMAND_NAMES = COMMANDS.map((c) => c.name);
243
289
  /** `conveno <command> --help`. */
244
290
  function commandHelp(ctx, spec) {
245
291
  const t = ctx.theme;
@@ -312,4 +358,4 @@ function parseFlags(ctx, spec, argv) {
312
358
  });
313
359
  }
314
360
  }
315
- export { parseFlags as i, COMMAND_NAMES as n, commandHelp as r, COMMANDS as t };
361
+ export { parseFlags as a, commandHelp as i, COMMANDS as n, COMMAND_NAMES as r, ALL_COMMAND_NAMES 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-rDISaMgP.js")).runHookEntry(argv.slice(1));
29
+ if (isHook) code = await (await import("./hook-entry-CrpZz5QW.js")).runHookEntry(argv.slice(1));
30
30
  else {
31
- const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-CRw-fISR.js"), import("./runtime-DyknkzAS.js")]);
31
+ const [{ main }, { createRuntimeCtx }] = await Promise.all([import("./main-DrzHsV5y.js"), import("./runtime-Db_YT5Xg.js")]);
32
32
  code = await main(argv, createRuntimeCtx());
33
33
  }
34
34
  if (isHook) process.exit(code);