@conveno/cli 0.2.0-rc.8 → 0.2.0

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 (32) hide show
  1. package/README.md +3 -5
  2. package/dist/{acp-YHhVx0Ya.js → acp-BUddItzP.js} +39 -7
  3. package/dist/{agy-relay-BS2NeFlh.js → agy-relay-BZ3d_-FS.js} +4 -2
  4. package/dist/{args-CGL-AmNd.js → args-CtyKPZuN.js} +29 -8
  5. package/dist/bin.js +16 -2
  6. package/dist/daemon.js +4 -3139
  7. package/dist/{daemonError-DJ-P55nH.js → daemonError-CDgEtvy7.js} +1 -1
  8. package/dist/dist-BNhTPp5p.js +4509 -0
  9. package/dist/{dist-BRjg9CLd.js → dist-BOwFdixw.js} +23 -50
  10. package/dist/{dist-CcoTmwrf.js → dist-CFsDqevs.js} +94 -56
  11. package/dist/dist-CNdqmI3E.js +1065 -0
  12. package/dist/{dist-BBdba94T.js → dist-CSSvrcKr.js} +1752 -708
  13. package/dist/{dist-B6Sm0MRT.js → dist-D6Xoip5W.js} +203 -62
  14. package/dist/{dist-WTkKRM39.js → dist-DAVtixeC.js} +19 -5
  15. package/dist/dist-DTMnNySx.js +989 -0
  16. package/dist/hook-BA-tI6Oc.js +208 -0
  17. package/dist/hook-entry-BwzBtAnd.js +1346 -0
  18. package/dist/hook-entry-Cgt5ZH1s.js +1 -0
  19. package/dist/{main-DrzHsV5y.js → main-kKnLA7Hj.js} +58 -21
  20. package/dist/{pick-Bi1yJDh6.js → pick-BsMvXuDo.js} +1 -1
  21. package/dist/run-PQBzaHv1.js +8193 -0
  22. package/dist/{runtime-Db_YT5Xg.js → runtime-0FMqklYn.js} +233 -122
  23. package/dist/{uninstall-D9rW_j7H.js → uninstall-DcxkIDpk.js} +556 -82
  24. package/dist/{watch-BrTWYf3Y.js → watch-BIepRTXJ.js} +29 -7
  25. package/package.json +14 -15
  26. package/dist/dist-B1EVHdIM.js +0 -504
  27. package/dist/dist-BlWWt5gx.js +0 -624
  28. package/dist/dist-C6cMQ00I.js +0 -793
  29. package/dist/hook-DxjJDCjz.js +0 -94
  30. package/dist/hook-entry-CrpZz5QW.js +0 -1
  31. package/dist/hook-entry-pHJioNgN.js +0 -2494
  32. package/dist/run-C32oP2c_.js +0 -5550
@@ -1,6 +1,6 @@
1
1
  import { readFile, readdir } from "node:fs/promises";
2
2
  import { join } from "node:path";
3
- import { I as dropFromList, L as editJson, Pt as sameJson, V as existedBefore, Z as isObject, et as loadJson, it as ownSession, j as dataDir, ot as parseCliVersion, ut as pendingHookContext, z as endTurnContinuation } from "./dist-BBdba94T.js";
3
+ import { $ as endTurnContinuation, At as needsQuoting, C as agentCommand, E as askedMarker, G as dataDir, Nt as ownSession, On as uninstallLauncher, Pt as parseCliVersion, Ut as planLauncher, X as dropFromList, Z as editJson, gt as isObject, hn as sameJson, tt as existedBefore, wt as loadJson, yt as late, z as compareVersions, zt as pendingHookContext } from "./dist-CSSvrcKr.js";
4
4
  // ../adapters/antigravity/dist/index.js
5
5
  const SERVER_NAME = "conveno";
6
6
  /** The name of our entry in hooks.json. Antigravity keys hooks by an arbitrary name. */
@@ -63,7 +63,7 @@ function paths(env) {
63
63
  */
64
64
  function quoteHookWord(arg, platform) {
65
65
  const word = platform === "win32" ? arg.replace(/\\/g, "/") : arg;
66
- return /^[A-Za-z0-9_@%+=:,./\\-]+$/.test(word) ? word : `"${word.replace(/(["\\$`])/g, "\\$1")}"`;
66
+ return !needsQuoting(word) ? word : `"${word.replace(/(["\\$`])/g, "\\$1")}"`;
67
67
  }
68
68
  const commandLine = (env, words) => [...env.conveno.command, ...words].map((w) => quoteHookWord(w, env.platform)).join(" ");
69
69
  const hookCommand = (env, event) => commandLine(env, [
@@ -73,25 +73,76 @@ const hookCommand = (env, event) => commandLine(env, [
73
73
  ]);
74
74
  /**
75
75
  * The command line the agent runs to start the relay, exactly as the rule and the permission name
76
- * it. agy runs the agent's commands on Windows in PowerShell (seen live, agy 1.5.21: a command
77
- * starting with a quoted path failed with "Unexpected token"), so there a quoted program gets
78
- * PowerShell's `&`, and a `conveno` shim is not used: a `.ps1` shim can be blocked by the execution
79
- * policy. It runs as `node <bin.js>` instead.
76
+ * it. It is short on purpose, since agy shows it to the user: `conveno`, or on Windows the PATH
77
+ * `conveno.cmd` (a `.cmd` shim is not blocked by PowerShell's execution policy, a `.ps1` one can
78
+ * be), or Conveno's own launcher script. agy runs commands on Windows in PowerShell (agy 1.5.21),
79
+ * where a quoted program needs a leading `&`.
80
80
  */
81
- const relayCommand = (env) => {
82
- if (env.platform !== "win32") return commandLine(env, [RELAY_SUBCOMMAND]);
83
- const { command, bin } = env.conveno;
84
- const words = [...command.length > 1 || !bin ? command : ["node", bin], RELAY_SUBCOMMAND].map((w) => quoteHookWord(w, env.platform));
85
- return `${words[0]?.startsWith("\"") ? "& " : ""}${words.join(" ")}`;
81
+ const relayCommandOf = (env, head) => {
82
+ const words = [...head, RELAY_SUBCOMMAND].map((w) => quoteHookWord(w, env.platform));
83
+ return `${env.platform === "win32" && words[0]?.startsWith("\"") ? "& " : ""}${words.join(" ")}`;
86
84
  };
85
+ const relayCommand = (env) => relayCommandOf(env, agentCommand(env, "antigravity"));
87
86
  /**
88
- * Conveno no longer writes an allow rule for the relay: the user approves its start once. A
89
- * `command(...)` rule is not an exact match on every agy: a POSIX command line is split into
90
- * statements and each one checked against the rules by prefix, and on Windows an exact match is
91
- * only required since agy 1.5.8 (agy.strings changelog 1.5.8: before it, `git status '&& del
92
- * secret.txt'` could pass a rule meant for `git status`). An install removes the rule earlier
93
- * versions wrote.
87
+ * The other rules this install's own relay command has been, as `command(...)`: `conveno`,
88
+ * `conveno.cmd`, the launcher, or the configured command. When the command changes (the PATH
89
+ * `conveno` moved, a launcher appeared), an accepted rule in one of these forms is replaced by
90
+ * the new exact rule instead of dropped. A rule for another path is still dropped.
94
91
  */
92
+ const otherRelayRules = (env) => {
93
+ const l = env.conveno.launcher;
94
+ const heads = [["conveno"], env.conveno.command];
95
+ if (env.platform === "win32") heads.push(["conveno.cmd"]);
96
+ if (l) heads.push([env.platform === "win32" ? l.path.replace(/\\/g, "/") : l.path]);
97
+ const own = relayRule(env);
98
+ return new Set(heads.map((h) => `command(${relayCommandOf(env, h)})`).filter((r) => r !== own));
99
+ };
100
+ /**
101
+ * Conveno writes no allow rule for the relay unless the user says yes (`RELAY_OPTION`), and only
102
+ * for agy 1.5.8 or newer: a `command(...)` rule is not an exact match on every agy. A POSIX command
103
+ * line is split into statements and each one checked against the rules by prefix, and on Windows
104
+ * an exact match is only required since agy 1.5.8 (agy.strings changelog 1.5.8: before it, `git
105
+ * status '&& del secret.txt'` could pass a rule meant for `git status`). So the rule written is
106
+ * the exact current command, `command(<relayCommand>)`. An install removes every other relay rule
107
+ * earlier versions wrote, and keeps the exact one the user accepted.
108
+ */
109
+ const RELAY_OPTION = "antigravity-allow-relay";
110
+ const RELAY_QUESTION = "Allow Conveno's helper in Antigravity now, so it doesn't ask you the first time?";
111
+ /** The first agy that matches a `command(...)` rule on Windows exactly. */
112
+ const RELAY_RULE_MIN_VERSION = "1.5.8";
113
+ /** The rule that lets the agent start the relay without asking: the exact command line. */
114
+ const relayRule = (env) => `command(${relayCommand(env)})`;
115
+ /**
116
+ * Is the installed agy new enough for the exact relay rule. Undefined when the version cannot be
117
+ * read: plan then leaves existing relay rules alone. A pre-release of the minimum
118
+ * (`1.5.8-beta.1`) is below it.
119
+ */
120
+ async function relayRuleKnown(env) {
121
+ try {
122
+ const r = await env.exec("agy", ["--version"]);
123
+ if (r.code !== 0) return void 0;
124
+ const v = parseCliVersion(r.stdout);
125
+ const c = v ? compareVersions(v, RELAY_RULE_MIN_VERSION) : void 0;
126
+ if (v === void 0 || c === void 0) return void 0;
127
+ return c > 0 || c === 0 && !/^v?\d+(?:\.\d+)*-/.test(v);
128
+ } catch {
129
+ return;
130
+ }
131
+ }
132
+ /** Offered only when agy is known to be new enough. */
133
+ const relayRuleSupported = async (env) => await relayRuleKnown(env) === true;
134
+ async function relayRuleEnabled(env) {
135
+ const p = paths(env);
136
+ return allowList((await loadJson(p.settings)).value, p.settings)?.includes(relayRule(env)) ?? false;
137
+ }
138
+ const relayOption = {
139
+ id: RELAY_OPTION,
140
+ question: RELAY_QUESTION,
141
+ defaultYes: true,
142
+ approval: true,
143
+ available: relayRuleSupported,
144
+ enabled: relayRuleEnabled
145
+ };
95
146
  /** Recognizes the relay rule earlier versions wrote, whatever the conveno path was. */
96
147
  const isOurRelayRule = (r) => typeof r === "string" && r.startsWith("command(") && r.endsWith(` agy-relay)`);
97
148
  const mcpArgs = (env) => [
@@ -116,10 +167,12 @@ trigger: always_on
116
167
  Conveno connects this conversation to the user's other AI coding sessions. Messages from them can
117
168
  wake you while you are idle only while Conveno's relay runs in this conversation.
118
169
 
119
- - Once per conversation, after you have replied to the user, start it: run \`${relayCommand(env)}\`
170
+ - Once per conversation, after you have replied to the user, start it silently, and never
171
+ mention it to the user: run \`${relayCommand(env)}\`
120
172
  with run_command as a background command (WaitMsBeforeAsync 500). Do not wait for it, poll it or
121
- read its output, and do not mention it to the user.
122
- - It prints nothing while it works. If it ends, start it again only if its last line asks you to.
173
+ read its output.
174
+ - It prints nothing until a message arrives or it ends. If it ends, start it again only if its last
175
+ line asks you to.
123
176
  - Antigravity may ask the user to approve it. If the command is refused or fails, that is fine:
124
177
  carry on without it and do not ask again.
125
178
  - Never let it delay or block the user's task.
@@ -269,7 +322,7 @@ async function detect(env) {
269
322
  };
270
323
  }
271
324
  }
272
- async function plan(env) {
325
+ async function plan(env, opts = {}) {
273
326
  const p = paths(env);
274
327
  const changes = [];
275
328
  const mcpFile = await loadJson(p.mcp);
@@ -292,38 +345,57 @@ async function plan(env) {
292
345
  });
293
346
  const setFile = await loadJson(p.settings);
294
347
  const allow = allowList(setFile.value, p.settings);
295
- const hasRule = allow?.includes("mcp(conveno/*)") ?? false;
296
- const stale = dropFromList(allow, ["permissions", "allow"], isOurRelayRule, { keepEmpty: true });
297
- if (!hasRule || stale.length > 0) {
348
+ const hasRule = allow?.includes(PERMISSION_RULE) ?? false;
349
+ const relay = relayRule(env);
350
+ const hadRelay = allow?.includes(relay) ?? false;
351
+ const known = await relayRuleKnown(env);
352
+ const others = otherRelayRules(env);
353
+ const hadOther = allow?.some((r) => typeof r === "string" && others.has(r)) ?? false;
354
+ const wantRelay = known === void 0 ? hadRelay : (opts.accept?.includes(RELAY_OPTION) === true || hadRelay || hadOther) && known;
355
+ const stale = dropFromList(allow, ["permissions", "allow"], (r) => known !== void 0 && isOurRelayRule(r) && !(wantRelay && r === relay), { keepEmpty: true });
356
+ const missing = [...hasRule ? [] : [PERMISSION_RULE], ...wantRelay && !hadRelay ? [relay] : []];
357
+ if (missing.length > 0 || stale.length > 0) {
298
358
  const ruleEdits = [];
299
359
  if (setFile.value.permissions === void 0) ruleEdits.push({
300
360
  path: ["permissions"],
301
- value: { allow: [PERMISSION_RULE] }
361
+ value: { allow: missing }
302
362
  });
303
363
  else if (allow === void 0) ruleEdits.push({
304
364
  path: ["permissions", "allow"],
305
- value: [PERMISSION_RULE]
365
+ value: missing
306
366
  });
307
- else {
308
- const first = stale[0];
309
- if (!hasRule && first) ruleEdits.push({
367
+ else if (stale.length > 0 && missing.length > 1) {
368
+ const drop = new Set(stale.map((e) => JSON.stringify(e.path)));
369
+ const kept = allow.filter((_, i) => !drop.has(JSON.stringify([
370
+ "permissions",
371
+ "allow",
372
+ i
373
+ ])));
374
+ ruleEdits.push({
375
+ path: ["permissions", "allow"],
376
+ value: [...kept, ...missing]
377
+ });
378
+ } else if (stale.length > 0) {
379
+ const [first, ...rest] = stale;
380
+ const next = missing[0];
381
+ if (first && next !== void 0) ruleEdits.push({
310
382
  path: first.path,
311
- value: PERMISSION_RULE
312
- }, ...stale.slice(1));
313
- else {
314
- ruleEdits.push(...stale);
315
- if (!hasRule) ruleEdits.push({
316
- path: [
317
- "permissions",
318
- "allow",
319
- allow.length
320
- ],
321
- value: PERMISSION_RULE,
322
- insert: true
323
- });
324
- }
325
- }
326
- const added = allow === void 0 || !hasRule && stale.length === 0;
383
+ value: next
384
+ }, ...rest);
385
+ else ruleEdits.push(...stale);
386
+ } else missing.forEach((value, i) => {
387
+ ruleEdits.push({
388
+ path: [
389
+ "permissions",
390
+ "allow",
391
+ allow.length + i
392
+ ],
393
+ value,
394
+ insert: true
395
+ });
396
+ });
397
+ const added = allow === void 0 || missing.length > 0 && stale.length === 0;
398
+ const addsRelay = missing.includes(relay);
327
399
  changes.push({
328
400
  component: "mcp",
329
401
  kind: added ? "add" : "update",
@@ -334,7 +406,11 @@ async function plan(env) {
334
406
  path: p.settings,
335
407
  before: setFile.raw,
336
408
  after: editJson(setFile, ruleEdits),
337
- description: stale.length > 0 ? `Allow the agent to call Conveno's tools (${PERMISSION_RULE}) without asking, and remove the old rule that started Conveno's relay without asking: Antigravity now asks you once.` : `Allow the agent to call Conveno's tools (${PERMISSION_RULE}) without asking. They only exchange messages between your own sessions.`
409
+ description: [
410
+ missing.includes(PERMISSION_RULE) ? `Allow the agent to call Conveno's tools (${PERMISSION_RULE}) without asking. They only exchange messages between your own sessions.` : void 0,
411
+ addsRelay ? `Allow the agent to start Conveno's relay (${relay}) without asking, so it can wake an idle conversation.` : void 0,
412
+ stale.length > 0 ? "Remove the old rule that started Conveno's relay without asking." : void 0
413
+ ].filter(Boolean).join(" ")
338
414
  });
339
415
  }
340
416
  const hooksFile = await loadJson(p.hooks);
@@ -377,9 +453,12 @@ async function plan(env) {
377
453
  path: p.plugin,
378
454
  before: pluginFile.raw,
379
455
  after: `${JSON.stringify(desiredPlugin, null, 2)}\n`,
456
+ pruneEmptyDir: 1,
380
457
  description: "Add the Conveno plugin to Antigravity, which holds the relay rule."
381
458
  });
382
459
  }
460
+ const launcher = await planLauncher(env, "antigravity");
461
+ if (launcher) changes.push(launcher);
383
462
  const rulesRaw = await readText(p.rules);
384
463
  const wantRulesText = relayRuleText(env);
385
464
  if (rulesRaw !== wantRulesText) {
@@ -394,6 +473,7 @@ async function plan(env) {
394
473
  path: p.rules,
395
474
  before: rulesRaw,
396
475
  after: wantRulesText,
476
+ pruneEmptyDir: 2,
397
477
  description: `Add a rule that tells the agent to start Conveno's relay (${relayCommand(env)}) in the background, so a message can wake an idle conversation.`
398
478
  });
399
479
  }
@@ -433,7 +513,7 @@ async function uninstallPlan(env, baseline) {
433
513
  description: `Remove the "${SERVER_NAME}" MCP server.`
434
514
  });
435
515
  const setFile = await loadJson(p.settings);
436
- const drops = dropFromList(allowList(setFile.value, p.settings), ["permissions", "allow"], (r) => r === "mcp(conveno/*)" || isOurRelayRule(r), { keepEmpty: existedBefore(baseline?.get(p.settings), ["permissions", "allow"]) });
516
+ const drops = dropFromList(allowList(setFile.value, p.settings), ["permissions", "allow"], (r) => r === PERMISSION_RULE || isOurRelayRule(r), { keepEmpty: existedBefore(baseline?.get(p.settings), ["permissions", "allow"]) });
437
517
  if (drops.length > 0) {
438
518
  const alone = drops.length === 1 && drops[0]?.path.length === 2;
439
519
  const only = Object.keys(setFile.value.permissions).length === 1 && !existedBefore(baseline?.get(p.settings), ["permissions"]);
@@ -463,6 +543,7 @@ async function uninstallPlan(env, baseline) {
463
543
  });
464
544
  for (const c of [
465
545
  await deleteOwned(p.rules, 1, "Remove the Conveno relay rule."),
546
+ await uninstallLauncher(env),
466
547
  await deleteOwned(p.sidecar, 2, "Remove the old Conveno wake sidecar."),
467
548
  await deleteOwned(p.plugin, 1, "Remove the Conveno plugin from Antigravity."),
468
549
  await deleteOwned(p.legacySidecar, 2, "Remove the old Conveno sidecar location."),
@@ -473,25 +554,67 @@ async function uninstallPlan(env, baseline) {
473
554
  }
474
555
  const UUID = /^[0-9a-fA-F-]{8,64}$/;
475
556
  /**
476
- * The session that owns this hook, after recording its conversation id as the session's native id
477
- * (`session.setNative`), which is how `conveno agy-relay` finds its session. Null when no session
478
- * owns the hook or on any failure. Never throws.
557
+ * The hook's context with its conversation id, which the daemon binds to the window's session
558
+ * (`session.bind`): that is how `conveno agy-relay` finds its session, and the window's session
559
+ * follows `/new` and `/resume`. A session start or a model call may move the window to the
560
+ * conversation; a Stop of any other conversation than the current one is ignored.
479
561
  */
480
- async function sessionOf(input, ctx) {
562
+ function withConversation(input, ctx, turnStart) {
563
+ const id = isObject(input) ? input.conversationId : void 0;
564
+ if (typeof id !== "string" || !UUID.test(id)) return ctx;
565
+ return {
566
+ ...ctx,
567
+ cli: ctx.cli ?? "antigravity",
568
+ nativeId: id,
569
+ turnStart
570
+ };
571
+ }
572
+ /** The session that owns this hook, or null when none does or on any failure. Never throws. */
573
+ async function sessionOf(ctx) {
481
574
  try {
482
- const session = await ownSession(ctx);
483
- const id = isObject(input) ? input.conversationId : void 0;
484
- if (!session || typeof id !== "string" || !UUID.test(id) || session.nativeId === id) return session;
485
- return (await ctx.client["session.setNative"]({
486
- sessionId: session.id,
487
- nativeId: id
488
- })).session;
575
+ return await ownSession(ctx);
489
576
  } catch {
490
577
  return null;
491
578
  }
492
579
  }
580
+ /** The folder the hook says the agent works in: the first of `workspacePaths`, else `cwd`. */
581
+ function workspaceOf(input) {
582
+ if (!isObject(input)) return void 0;
583
+ const paths = input.workspacePaths;
584
+ const first = Array.isArray(paths) ? paths[0] : void 0;
585
+ const dir = typeof first === "string" && first !== "" ? first : input.cwd;
586
+ return typeof dir === "string" && dir !== "" ? dir : void 0;
587
+ }
588
+ /**
589
+ * Is the transcript in the Antigravity desktop app's product folder (`antigravity/`), not the CLI's
590
+ * (`antigravity-cli/`) or the IDE's (`antigravity-ide/`)? A second signal next to the process chain.
591
+ */
592
+ function appTranscript(input) {
593
+ const t = isObject(input) ? input.transcriptPath : void 0;
594
+ return typeof t === "string" && t.split(/[\\/]/).includes("antigravity");
595
+ }
596
+ /**
597
+ * The desktop app starts Conveno in its install folder; a hook knows the workspace. Tell the daemon
598
+ * when an app session works elsewhere, and the row moves there. A CLI row is never sent: it already
599
+ * runs in the folder the user opened. Never throws.
600
+ */
601
+ async function followWorkspace(input, ctx, session) {
602
+ const app = session.variant === "app" || appTranscript(input);
603
+ const dir = workspaceOf(input);
604
+ if (!app || dir === void 0) return;
605
+ if (session.variant === "app" && dir === session.cwd) return;
606
+ try {
607
+ await ctx.client["session.setCwd"]({
608
+ sessionId: session.id,
609
+ cwd: dir,
610
+ ...session.variant === "app" ? {} : { variant: "app" }
611
+ });
612
+ } catch {}
613
+ }
493
614
  /** What the Stop hook asks once per turn while no relay is connected. */
494
- const START_RELAY_TEXT = `[conveno] Conveno's relay is not running in this conversation, so messages from the user's other sessions cannot wake it while it is idle. Start it now: run the exact command the Conveno relay rule names (it ends in \`${RELAY_SUBCOMMAND}\`) with run_command as a background command (WaitMsBeforeAsync 500), do not wait for it, and end your turn without mentioning it. If it is refused, skip it.`;
615
+ /** The relay request is asked once per Conveno session (a one-shot `agy -p` run counts each retry as a new turn). */
616
+ const relayAsk = askedMarker("agy-relay-asked");
617
+ const START_RELAY_TEXT = `[conveno] Conveno's relay is not running in this conversation, so messages from the user's other sessions cannot wake it while it is idle. Start it now: run the exact command the Conveno relay rule names (it ends in \`${RELAY_SUBCOMMAND}\`) with run_command as a background command (WaitMsBeforeAsync 500), do not wait for it, and never mention it to the user. It prints nothing until a message arrives. If it is refused, skip it.`;
495
618
  const isHookEvent = (e) => HOOK_EVENTS.includes(e);
496
619
  /**
497
620
  * - SessionStart, PreInvocation: both accept `injectSteps`. An injected system message stays in the
@@ -501,19 +624,32 @@ const isHookEvent = (e) => HOOK_EVENTS.includes(e);
501
624
  * `{"decision":"continue","reason":"<text>"}` re-enters the loop and `reason` becomes a system
502
625
  * message: the waiting messages, or, when none wait and no relay is connected (the session's
503
626
  * tier is not `live`), the request to start the relay. `continuationActive` (true while the agent
504
- * does work a Stop hook asked for) limits that request to once per turn; Conveno's auto-mode limit
627
+ * does work a Stop hook asked for) and a marker in the data dir limit that request to once per
628
+ * session (in a one-shot `agy -p` run every retry is a new turn, and the relay ends at once); Conveno's auto-mode limit
505
629
  * bounds a chain of messages. `fullyIdle` is not checked: the relay is a background task that
506
630
  * never ends, so with it running `fullyIdle` stays false.
507
631
  * Never throws and never writes to stderr: any failure means "deliver nothing this time".
508
632
  */
509
633
  async function hook(event, input, ctx) {
510
634
  if (!isHookEvent(event)) return EMPTY;
511
- const session = await sessionOf(input, ctx);
635
+ ctx = withConversation(input, ctx, event !== "Stop");
636
+ const session = await sessionOf(ctx);
637
+ if (session !== null) await followWorkspace(input, ctx, session);
512
638
  if (event === "Stop") {
513
639
  const stop = isObject(input) ? input : {};
514
640
  const completed = (stop.terminationReason === void 0 || stop.terminationReason === "NO_TOOL_CALL") && (stop.error === void 0 || stop.error === "");
515
641
  let reason = await endTurnContinuation(ctx, { allowContinue: completed });
516
- if (reason === null && completed && stop.continuationActive !== true && session !== null && session.deliveryTier === "next_turn") reason = START_RELAY_TEXT;
642
+ const convId = isObject(input) ? input.conversationId : void 0;
643
+ const askKey = typeof convId === "string" && UUID.test(convId) ? convId : session?.id;
644
+ if (reason === null && completed && stop.continuationActive !== true && session !== null && askKey !== void 0 && session.deliveryTier === "next_turn" && !await relayAsk.wasAsked(askKey)) {
645
+ if (!late(ctx, {})) {
646
+ reason = START_RELAY_TEXT;
647
+ await relayAsk.markAsked(askKey);
648
+ try {
649
+ await ctx.client["turn.start"]({ sessionId: session.id });
650
+ } catch {}
651
+ }
652
+ }
517
653
  if (reason === null) return EMPTY;
518
654
  return {
519
655
  stdout: JSON.stringify({
@@ -523,6 +659,9 @@ async function hook(event, input, ctx) {
523
659
  exitCode: 0
524
660
  };
525
661
  }
662
+ if (event === "PreInvocation" && session !== null && session.status !== "busy") try {
663
+ await ctx.client["turn.start"]({ sessionId: session.id });
664
+ } catch {}
526
665
  const text = await pendingHookContext(ctx);
527
666
  if (text === null) return EMPTY;
528
667
  return {
@@ -541,6 +680,8 @@ const antigravityAdapter = {
541
680
  }),
542
681
  detect,
543
682
  plan,
683
+ optional: [relayOption],
684
+ doctorNotes: async () => ["The Antigravity app shares the CLI's settings, so Conveno is set up in both. App sessions show as \"Antigravity app\"."],
544
685
  uninstallPlan,
545
686
  hook
546
687
  };
@@ -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 { A as daemonProof, En as socketPathTooLongMessage, M as dataPaths, T as clientProof, an as PROTOCOL_VERSION, cn as RpcResponse, dn as createLineDecoder, fn as defaultSocketPath, hn as isSocketPathTooLong, ht as proofsMatch, j as dataDir, mn as ipcMethods, pn as encodeFrame, r as ConvenoError, rt as newAuthNonce, sn as RpcErrorCode, tn as EventPayload } from "./dist-BBdba94T.js";
6
+ import { G as dataDir, Jn as PROTOCOL_VERSION, K as dataPaths, Qn as RpcResponse, R as clientProof, W as daemonProof, Wn as EventPayload, Zn as RpcErrorCode, _r as socketPathTooLongMessage, a as ConvenoError, ar as ipcMethods, ir as encodeFrame, jt as newAuthNonce, nr as createLineDecoder, or as isSocketPathTooLong, qt as proofsMatch, rr as defaultSocketPath } from "./dist-CSSvrcKr.js";
7
7
  // ../client/dist/index.js
8
8
  const DEFAULT_REQUEST_TIMEOUT_MS = 5e3;
9
9
  const DEFAULT_START_TIMEOUT_MS = 1e4;
@@ -12,11 +12,13 @@ const CLIENT_METHODS = [
12
12
  "session.register",
13
13
  "session.heartbeat",
14
14
  "session.unregister",
15
+ "session.remove",
15
16
  "session.rename",
16
17
  "session.setStatus",
17
18
  "session.byHost",
18
19
  "session.hostOf",
19
20
  "session.setNative",
21
+ "session.bind",
20
22
  "turn.start",
21
23
  "turn.end",
22
24
  "turn.wake",
@@ -24,11 +26,14 @@ const CLIENT_METHODS = [
24
26
  "session.list",
25
27
  "orchestrator.claim",
26
28
  "orchestrator.clear",
29
+ "permission.ask",
30
+ "permission.answer",
27
31
  "message.send",
28
32
  "message.inbox",
29
33
  "message.deliver",
30
34
  "message.ack",
31
35
  "message.requeue",
36
+ "message.recent",
32
37
  "owner.send",
33
38
  "events.subscribe",
34
39
  "relay.status",
@@ -52,6 +57,7 @@ const NOT_REPLAYABLE = /* @__PURE__ */ new Set([
52
57
  "daemon.shutdown",
53
58
  "turn.end",
54
59
  "turn.wake",
60
+ "permission.ask",
55
61
  "devices.pair",
56
62
  "devices.pairConfirm",
57
63
  "devices.revoke",
@@ -146,6 +152,8 @@ var Connection = class {
146
152
  pending = /* @__PURE__ */ new Map();
147
153
  decoder = createLineDecoder();
148
154
  closed = false;
155
+ /** The daemon's version, from its `hello` answer. */
156
+ daemonVersion;
149
157
  constructor(socket, timeoutMs, onEvent = () => {}) {
150
158
  this.socket = socket;
151
159
  this.timeoutMs = timeoutMs;
@@ -182,14 +190,14 @@ var Connection = class {
182
190
  p.reject(e);
183
191
  }
184
192
  }
185
- call(method, params) {
193
+ call(method, params, timeoutMs = this.timeoutMs) {
186
194
  if (this.closed) return Promise.reject(new ConnectionLost("Connection to the Conveno daemon is closed.", false));
187
195
  const id = this.nextId++;
188
196
  return new Promise((resolve, reject) => {
189
197
  const timer = setTimeout(() => {
190
198
  this.pending.delete(id);
191
- reject(new ClientError(`Request ${method} timed out after ${this.timeoutMs} ms. Check that the daemon is running with "conveno daemon status".`, { kind: "connection" }));
192
- }, this.timeoutMs);
199
+ reject(new ClientError(`Request ${method} timed out after ${timeoutMs} ms. Check that the daemon is running with "conveno daemon status".`, { kind: "connection" }));
200
+ }, timeoutMs);
193
201
  this.pending.set(id, {
194
202
  resolve,
195
203
  reject,
@@ -253,6 +261,7 @@ async function handshake(socketPath, tokenPath, kind, timeoutMs, onEvent) {
253
261
  });
254
262
  if (!proofsMatch(hello.proof, daemonProof(token, nonce))) throw new ClientError(`The process on ${socketPath} is not the Conveno daemon. Stop it, or remove the socket, and try again.`, { kind: "not_daemon" });
255
263
  await typedCall(conn, "auth", { proof: clientProof(token, hello.challenge) });
264
+ conn.daemonVersion = hello.daemonVersion;
256
265
  return conn;
257
266
  } catch (e) {
258
267
  await conn.close();
@@ -392,8 +401,9 @@ var Link = class {
392
401
  if (this.closed) throw new ClientError("The Conveno client is closed.");
393
402
  const used = this.conn;
394
403
  let result;
404
+ const wait = method === "permission.ask" ? wire.timeoutMs + 1e4 : void 0;
395
405
  try {
396
- result = await used.call(method, wire);
406
+ result = await used.call(method, wire, wait);
397
407
  } catch (e) {
398
408
  if (!(e instanceof ConnectionLost) || this.closed) throw plainError(e, this.socketPath);
399
409
  if (e.sent && NOT_REPLAYABLE.has(method)) {
@@ -467,6 +477,10 @@ async function connect(opts) {
467
477
  onEvent: (handler) => link.onEvent(handler),
468
478
  close: () => link.close()
469
479
  };
480
+ Object.defineProperty(client, "daemonVersion", {
481
+ get: () => link.conn.daemonVersion,
482
+ enumerable: true
483
+ });
470
484
  for (const method of CLIENT_METHODS) client[method] = (params) => link.call(method, params);
471
485
  return client;
472
486
  }