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

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.
@@ -5839,13 +5839,18 @@ const SessionStatus = _enum([
5839
5839
  const SESSION_NAME_PATTERN = /^[a-z0-9][a-z0-9._@-]{0,63}$/;
5840
5840
  /** Literal recipient meaning "whoever currently holds the orchestrator role". */
5841
5841
  const ORCHESTRATOR_ALIAS = "orchestrator";
5842
+ /** Literal recipient, the same as `orchestrator`: whoever currently holds the lead role. */
5843
+ const LEAD_ALIAS = "lead";
5844
+ /** True for either name of the lead role. */
5845
+ const isLeadAlias = (to) => to === "lead" || to === "orchestrator";
5842
5846
  /**
5843
- * Names no session may take. `orchestrator` and `you` are recipient aliases; the others are the
5847
+ * Names no session may take. `orchestrator`, `lead` and `you` are recipient aliases; the others are the
5844
5848
  * senders the daemon uses for its own messages, so a session must not pose as them.
5845
5849
  */
5846
5850
  const RESERVED_SESSION_NAMES = [
5847
5851
  "conveno",
5848
5852
  ORCHESTRATOR_ALIAS,
5853
+ LEAD_ALIAS,
5849
5854
  "you",
5850
5855
  "system",
5851
5856
  "user"
@@ -5875,9 +5880,10 @@ const Sha256Hex = string().regex(/^[0-9a-f]{64}$/, "expected lowercase hex sha-2
5875
5880
  const Base64 = string().regex(/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/, "invalid base64");
5876
5881
  const TEXT_MAX_BYTES = 65536;
5877
5882
  const boundedText = (maxBytes) => string().refine((s) => utf8ByteLength(s) <= maxBytes, { message: `exceeds ${maxBytes} bytes` });
5878
- /** A message recipient: a session id, a session name, `orchestrator`, or `you` (the owner). */
5883
+ /** A message recipient: a session id, a session name, `lead` (or `orchestrator`), or `you` (the owner). */
5879
5884
  const Recipient = union([
5880
5885
  literal(ORCHESTRATOR_ALIAS),
5886
+ literal(LEAD_ALIAS),
5881
5887
  literal("you"),
5882
5888
  SessionId,
5883
5889
  SessionName,
@@ -6698,6 +6704,17 @@ const ipcMethods = {
6698
6704
  }),
6699
6705
  result: SendResult
6700
6706
  },
6707
+ "message.history": {
6708
+ params: object({
6709
+ session: SessionId,
6710
+ limit: number().int().min(1).max(200).default(50),
6711
+ before: MessageId.optional()
6712
+ }),
6713
+ result: object({
6714
+ messages: array(Message),
6715
+ more: boolean()
6716
+ })
6717
+ },
6701
6718
  "ticket.create": {
6702
6719
  params: object({
6703
6720
  ...sid,
@@ -9223,12 +9240,12 @@ function createWmiWalker(opts) {
9223
9240
  };
9224
9241
  }
9225
9242
  /**
9226
- * Resolve a recipient (`orchestrator`, session id or session name) to a session.
9243
+ * Resolve a recipient (`lead`, `orchestrator`, session id or session name) to a session.
9227
9244
  * Names resolve among non-offline sessions only; an id may also name an offline session
9228
9245
  * so a sender gets a clear error rather than "unknown".
9229
9246
  */
9230
9247
  function resolveRecipient(to, sessions, holder) {
9231
- if (to === "orchestrator") {
9248
+ if (isLeadAlias(to)) {
9232
9249
  const h = effectiveHolder(holder, sessions);
9233
9250
  if (!h) throw new ConvenoError(RpcErrorCode.NotFound, NO_ORCHESTRATOR_MESSAGE);
9234
9251
  return h;
@@ -9269,13 +9286,26 @@ async function detectRepo(cwd, fs) {
9269
9286
  basename: baseName(cwd)
9270
9287
  };
9271
9288
  }
9289
+ /** `CONVENO_NOTIFY=0` (or `off`, `false`, `no`) switches desktop notifications off whatever was saved. */
9290
+ function notifyForcedOff(env) {
9291
+ const v = env.CONVENO_NOTIFY?.trim().toLowerCase();
9292
+ return v === "0" || v === "off" || v === "false" || v === "no";
9293
+ }
9294
+ /** Whether desktop notifications are wanted: on unless forced off or saved as off. */
9295
+ function notifyDesktopWanted(path, env) {
9296
+ if (notifyForcedOff(env)) return false;
9297
+ return readSettings(path).notifyDesktop !== false;
9298
+ }
9272
9299
  /** Read the settings. A missing, unreadable or malformed file gives no settings. */
9273
9300
  function readSettings(path) {
9274
9301
  try {
9275
9302
  const v = JSON.parse(readFileSync(path, "utf8"));
9276
9303
  if (typeof v !== "object" || v === null) return {};
9277
9304
  const o = v;
9278
- return typeof o.acpAdapterNpx === "boolean" ? { acpAdapterNpx: o.acpAdapterNpx } : {};
9305
+ return {
9306
+ ...typeof o.acpAdapterNpx === "boolean" ? { acpAdapterNpx: o.acpAdapterNpx } : {},
9307
+ ...typeof o.notifyDesktop === "boolean" ? { notifyDesktop: o.notifyDesktop } : {}
9308
+ };
9279
9309
  } catch {
9280
9310
  return {};
9281
9311
  }
@@ -10545,4 +10575,4 @@ async function waitForRegistration(deps, w) {
10545
10575
  await deps.sleep(250);
10546
10576
  }
10547
10577
  }
10548
- export { isAllowed as $, string as $n, turnHops as $t, currentAccessToken as A, defaultSocketPath as An, readSettings as At, effectiveHolder as B, newTicketId as Bn, runLaunchFile as Bt, claimOrchestrator as C, SessionName as Cn, proofsMatch as Ct, compatStatus as D, Ticket as Dn, readCommandLine as Dt, clientProof as E, TICKET_STATUSES as En, readAncestry as Et, defaultProcessIo as F, makeEventNotification as Fn, relayPermission as Ft, fetchAccountStatus as G, socketPathTooLongMessage as Gn, startTurnContext as Gt, entriesNewestFirst as H, parseRelayFrame as Hn, samePath as Ht, describeToolCall as I, makeResult as In, requestDeviceCode as It, formatInbox as J, boolean as Jn, tailJsonl as Jt, findOnPath as K, _enum as Kn, statusAfterLiveness as Kt, detectRepo as L, newDeviceId as Ln, resolveAcpProgram as Lt, dataDir as M, ipcMethods as Mn, readTailLines as Mt, dataPaths as N, isSocketPathTooLong as Nn, realSpawnDeps as Nt, completeLogin as O, TicketId as On, readHeadLine as Ot, decideAutoContinue as P, makeError as Pn, recordCliInfo as Pt, holderAfterDeparture as Q, object as Qn, tooManyUnreadMessage as Qt, dropFromList as R, newMessageId as Rn, resolveRecipient as Rt, bindAccountDevice as S, SessionId as Sn, pollDeviceCode as St, classifyPermission as T, SessionNamePattern as Tn, readAccountTokens as Tt, evaluateLiveness as U, safeParse as Un, spawnRecordPath as Ut, endTurnContinuation as V, parseIpcRequest as Vn, sameJson as Vt, existedBefore as W, sanitizeLine as Wn, spawnSession as Wt, formatPermissionDecision as X, literal as Xn, takeWithinBytes as Xt, formatPeek as Y, discriminatedUnion as Yn, takeAcpLaunchFile as Yt, generateSessionName as Z, number as Zn, toIso as Zt, asString as _, PERMISSION_ANSWERS as _n, pendingForInjection as _t, NOT_FROM_USER_NOTICE as a, AUTO_LIMIT_MAX as an, jwtClaim as at, autoLimitsFromEnv as b, RpcErrorCode as bn, pinnedAdapter as bt, SPAWN_CLIS as c, DeviceId as cn, markDelivered as ct, ackEntries as d, EventPayload as dn, notFound as dt, unsupportedTranscript as en, isObject as et, acpOverrideVar as f, HUMAN_ANSWERER as fn, parseAllowPatterns as ft, adapterNpxCommand as g, OWNER_SESSION_ID as gn, pauseLabel as gt, adapterInstallCommand as h, ORCHESTRATOR_ALIAS as hn, parsePs1ShimTarget as ht, HEARTBEAT_INTERVAL_MS as i, writeSettings as in, isTranscriptPath as it, daemonProof as j, encodeFrame as jn, readSpawnRecord as jt, createWmiWalker as k, createLineDecoder as kn, readInbox as kt, SPAWN_TABLE as l, EVENT_NAMES as ln, nameMatchesPattern as lt, acpTurnsPath as m, MessageId as mn, parseCmdShimTarget as mt, AccountError as n, validateRename as nn, isPermissionHook as nt, PERMISSION_HOOK_BUDGET_MS as o, CLI_KINDS as on, loadJson as ot, acpTranscript as p, Message as pn, parseCliVersion as pt, formatContinuation as q, array as qn, subdirsNewestFirst as qt, ConvenoError as r, waitForWork as rn, isRecord as rt, RESPONSE_BUDGET_BYTES as s, CliKind as sn, logoutAccount as st, ACCOUNT_API as t, updateSpawnRecord as tn, isOnline as tt, SpawnError as u, EVENT_NOTIFICATION_METHOD as un, newAuthNonce as ut, attachAcpSession as v, PROTOCOL_VERSION as vn, pendingHookContext as vt, claimSpawnRecord as w, SessionNameInput as wn, putInList as wt, baseName as x, RpcResponse as xn, planSpawn as xt, autoCandidates as y, RelayPayload as yn, pickNewestSince as yt, editJson as z, newSessionId as zn, resolveWindowsCommand as zt };
10578
+ export { isAllowed as $, literal as $n, toIso as $t, currentAccessToken as A, TicketId as An, readHeadLine as At, effectiveHolder as B, newDeviceId as Bn, resolveRecipient as Bt, claimOrchestrator as C, RpcResponse as Cn, planSpawn as Ct, compatStatus as D, SessionNamePattern as Dn, readAccountTokens as Dt, clientProof as E, SessionNameInput as En, putInList as Et, defaultProcessIo as F, isLeadAlias as Fn, realSpawnDeps as Ft, fetchAccountStatus as G, parseRelayFrame as Gn, spawnRecordPath as Gt, entriesNewestFirst as H, newSessionId as Hn, runLaunchFile as Ht, describeToolCall as I, isSocketPathTooLong as In, recordCliInfo as It, formatInbox as J, socketPathTooLongMessage as Jn, statusAfterLiveness as Jt, findOnPath as K, safeParse as Kn, spawnSession as Kt, detectRepo as L, makeError as Ln, relayPermission as Lt, dataDir as M, defaultSocketPath as Mn, readSettings as Mt, dataPaths as N, encodeFrame as Nn, readSpawnRecord as Nt, completeLogin as O, TICKET_STATUSES as On, readAncestry as Ot, decideAutoContinue as P, ipcMethods as Pn, readTailLines as Pt, holderAfterDeparture as Q, discriminatedUnion as Qn, takeWithinBytes as Qt, dropFromList as R, makeEventNotification as Rn, requestDeviceCode as Rt, bindAccountDevice as S, RpcErrorCode as Sn, pinnedAdapter as St, classifyPermission as T, SessionName as Tn, proofsMatch as Tt, evaluateLiveness as U, newTicketId as Un, sameJson as Ut, endTurnContinuation as V, newMessageId as Vn, resolveWindowsCommand as Vt, existedBefore as W, parseIpcRequest as Wn, samePath as Wt, formatPermissionDecision as X, array as Xn, tailJsonl as Xt, formatPeek as Y, _enum as Yn, subdirsNewestFirst as Yt, generateSessionName as Z, boolean as Zn, takeAcpLaunchFile as Zt, asString as _, ORCHESTRATOR_ALIAS as _n, parsePs1ShimTarget as _t, NOT_FROM_USER_NOTICE as a, waitForWork as an, jwtClaim as at, autoLimitsFromEnv as b, PROTOCOL_VERSION as bn, pendingHookContext as bt, SPAWN_CLIS as c, CLI_KINDS as cn, markDelivered as ct, ackEntries as d, EVENT_NAMES as dn, notFound as dt, tooManyUnreadMessage as en, number as er, isObject as et, acpOverrideVar as f, EVENT_NOTIFICATION_METHOD as fn, notifyDesktopWanted as ft, adapterNpxCommand as g, MessageId as gn, parseCmdShimTarget as gt, adapterInstallCommand as h, Message as hn, parseCliVersion as ht, HEARTBEAT_INTERVAL_MS as i, validateRename as in, isTranscriptPath as it, daemonProof as j, createLineDecoder as jn, readInbox as jt, createWmiWalker as k, Ticket as kn, readCommandLine as kt, SPAWN_TABLE as l, CliKind as ln, nameMatchesPattern as lt, acpTurnsPath as m, HUMAN_ANSWERER as mn, parseAllowPatterns as mt, AccountError as n, unsupportedTranscript as nn, string as nr, isPermissionHook as nt, PERMISSION_HOOK_BUDGET_MS as o, writeSettings as on, loadJson as ot, acpTranscript as p, EventPayload as pn, notifyForcedOff as pt, formatContinuation as q, sanitizeLine as qn, startTurnContext as qt, ConvenoError as r, updateSpawnRecord as rn, isRecord as rt, RESPONSE_BUDGET_BYTES as s, AUTO_LIMIT_MAX as sn, logoutAccount as st, ACCOUNT_API as t, turnHops as tn, object as tr, isOnline as tt, SpawnError as u, DeviceId as un, newAuthNonce as ut, attachAcpSession as v, OWNER_SESSION_ID as vn, pauseLabel as vt, claimSpawnRecord as w, SessionId as wn, pollDeviceCode as wt, baseName as x, RelayPayload as xn, pickNewestSince as xt, autoCandidates as y, PERMISSION_ANSWERS as yn, pendingForInjection as yt, editJson as z, makeResult as zn, resolveAcpProgram as zt };
@@ -1,6 +1,6 @@
1
- import { At as readSettings, D as compatStatus, G as fetchAccountStatus, It as requestDeviceCode, K as findOnPath, Lt as resolveAcpProgram, N as dataPaths, O as completeLogin, St as pollDeviceCode, Tt as readAccountTokens, bt as pinnedAdapter, f as acpOverrideVar, g as adapterNpxCommand, h as adapterInstallCommand, in as writeSettings, l as SPAWN_TABLE, n as AccountError, on as CLI_KINDS, st as logoutAccount } from "./dist-M9Gs7e_K.js";
2
- import { t as ClientError } from "./dist-B3mH66Y1.js";
3
- import { a as closest, c as errorBlock, d as plainError, f as plural, h as warnBlock, i as parseFlags, l as fail, m as tilde, o as cmd, p as seconds, s as columns, t as COMMANDS, u as localStamp } from "./args-DEYV4Ran.js";
1
+ import { D as compatStatus, Dt as readAccountTokens, G as fetchAccountStatus, K as findOnPath, Mt as readSettings, N as dataPaths, O as completeLogin, Rt as requestDeviceCode, St as pinnedAdapter, cn as CLI_KINDS, f as acpOverrideVar, g as adapterNpxCommand, h as adapterInstallCommand, l as SPAWN_TABLE, n as AccountError, on as writeSettings, st as logoutAccount, wt as pollDeviceCode, zt as resolveAcpProgram } from "./dist-TrWRppjR.js";
2
+ import { t as ClientError } from "./dist-CEJ2-wxh.js";
3
+ import { a as closest, c as errorBlock, d as plainError, f as plural, h as warnBlock, i as parseFlags, l as fail, m as tilde, o as cmd, p as seconds, s as columns, t as COMMANDS, u as localStamp } from "./args-BRB8QEQM.js";
4
4
  import { n as connectOpts, t as adapterEnv } from "./ctx-CDLE-2f2.js";
5
5
  import { basename, dirname, join } from "node:path";
6
6
  import { chmod, mkdir, open, readFile, readdir, realpath, rename as rename$1, rm, stat, writeFile } from "node:fs/promises";
@@ -1,4 +1,4 @@
1
- import { nt as isPermissionHook } from "./dist-M9Gs7e_K.js";
1
+ import { nt as isPermissionHook } from "./dist-TrWRppjR.js";
2
2
  import { n as connectOpts } from "./ctx-CDLE-2f2.js";
3
3
  // src/hook.ts
4
4
  /**
@@ -1,10 +1,10 @@
1
1
  import { homedir } from "node:os";
2
2
  import { join } from "node:path";
3
- import { Et as readAncestry, Gt as startTurnContext, M as dataDir, R as dropFromList, V as endTurnContinuation, Vt as sameJson, W as existedBefore, et as isObject, ot as loadJson, pt as parseCliVersion, vt as pendingHookContext, wt as putInList, z as editJson } from "./dist-M9Gs7e_K.js";
4
- import { a as Za, n as opencodeAdapter, o as cs, r as codexAdapter, s as claudeAdapter } from "./dist-B7znzc5U.js";
3
+ import { Et as putInList, M as dataDir, Ot as readAncestry, R as dropFromList, Ut as sameJson, V as endTurnContinuation, W as existedBefore, bt as pendingHookContext, et as isObject, ht as parseCliVersion, ot as loadJson, qt as startTurnContext, z as editJson } from "./dist-TrWRppjR.js";
4
+ import { a as Za, n as opencodeAdapter, o as cs, r as codexAdapter, s as claudeAdapter } from "./dist-C8JRuLiZ.js";
5
5
  import { readFile } from "node:fs/promises";
6
- import { n as connect } from "./dist-B3mH66Y1.js";
7
- import { t as runHook } from "./hook-W7tV131z.js";
6
+ import { n as connect } from "./dist-CEJ2-wxh.js";
7
+ import { t as runHook } from "./hook-CLB_muZS.js";
8
8
  // ../adapters/antigravity/dist/index.js
9
9
  const SERVER_NAME$3 = "conveno";
10
10
  /** The name of our entry in hooks.json. Antigravity keys hooks by an arbitrary name. */
@@ -0,0 +1 @@
1
+ export { i as runHookEntry } from "./hook-entry-BlvSoNMm.js";
@@ -1,10 +1,10 @@
1
- import { Bt as runLaunchFile, Cn as SessionName, N as dataPaths, Nt as realSpawnDeps, On as TicketId, Sn as SessionId, Tn as SessionNamePattern, Wn as sanitizeLine, Wt as spawnSession, an as AUTO_LIMIT_MAX, bn as RpcErrorCode, c as SPAWN_CLIS, gt as pauseLabel, l as SPAWN_TABLE, on as CLI_KINDS, r as ConvenoError, u as SpawnError, wn as SessionNameInput } from "./dist-M9Gs7e_K.js";
2
- import { C as runLogout, S as runLogin, _ as runDevices, a as detectAll, c as staleFailure, d as listManifests, f as markRestored, i as confirmAndApply, l as StaleError, m as restoreEntry, n as runDoctor, o as reportFailures, p as previewRestore, r as collectPlans, s as runInit, u as applyChanges, v as runRelay, x as runAccount, y as daemonProblem } from "./doctor-D1sP9gCl.js";
3
- import { a as closest, d as plainError, f as plural, h as warnBlock, i as parseFlags, l as fail, m as tilde, n as COMMAND_NAMES, o as cmd, p as seconds, r as commandHelp, s as columns, t as COMMANDS, u as localStamp } from "./args-DEYV4Ran.js";
1
+ import { An as TicketId, Dn as SessionNamePattern, En as SessionNameInput, Ft as realSpawnDeps, Ht as runLaunchFile, Kt as spawnSession, N as dataPaths, Sn as RpcErrorCode, Tn as SessionName, c as SPAWN_CLIS, cn as CLI_KINDS, l as SPAWN_TABLE, qn as sanitizeLine, r as ConvenoError, sn as AUTO_LIMIT_MAX, u as SpawnError, vt as pauseLabel, wn as SessionId } from "./dist-TrWRppjR.js";
2
+ import { C as runLogout, S as runLogin, _ as runDevices, a as detectAll, c as staleFailure, d as listManifests, f as markRestored, i as confirmAndApply, l as StaleError, m as restoreEntry, n as runDoctor, o as reportFailures, p as previewRestore, r as collectPlans, s as runInit, u as applyChanges, v as runRelay, x as runAccount, y as daemonProblem } from "./doctor-CzIGTeNT.js";
3
+ import { a as closest, d as plainError, f as plural, h as warnBlock, i as parseFlags, l as fail, m as tilde, n as COMMAND_NAMES, o as cmd, p as seconds, r as commandHelp, s as columns, t as COMMANDS, u as localStamp } from "./args-BRB8QEQM.js";
4
4
  import { n as connectOpts, t as adapterEnv } from "./ctx-CDLE-2f2.js";
5
5
  import { access, chmod, mkdir, readFile, rm, writeFile } from "node:fs/promises";
6
6
  import { join, resolve } from "node:path";
7
- import { t as runHook } from "./hook-W7tV131z.js";
7
+ import { t as runHook } from "./hook-CLB_muZS.js";
8
8
  import { readFileSync } from "node:fs";
9
9
  // src/status.ts
10
10
  const CLI_SHORT = {
@@ -453,7 +453,7 @@ async function runDaemon(ctx, argv) {
453
453
  });
454
454
  }
455
455
  // src/version.ts
456
- const VERSION = "0.2.0-rc.3";
456
+ const VERSION = "0.2.0-rc.5";
457
457
  // src/errorLog.ts
458
458
  /** The message of an unexpected error, as it is. Not the softened text `plainError` gives. */
459
459
  function rawMessage(e) {
@@ -613,6 +613,75 @@ async function runForget(ctx, argv) {
613
613
  await client.close().catch(() => void 0);
614
614
  }
615
615
  }
616
+ // src/pick.ts
617
+ /**
618
+ * The session a name or id means. A name means the online session that has it; with none online
619
+ * it falls back to the newest offline one. Returns undefined when nothing matches.
620
+ */
621
+ async function findSession(client, text) {
622
+ const { sessions } = await client["session.list"]({ includeOffline: true });
623
+ if (SessionId.safeParse(text).success) return sessions.find((s) => s.id === text);
624
+ const named = sessions.filter((s) => s.name === text);
625
+ return named.find((s) => s.status !== "offline") ?? named[0];
626
+ }
627
+ // src/lead.ts
628
+ /** `conveno lead <session>`: make that session the lead. */
629
+ async function runLead(ctx, argv) {
630
+ const t = ctx.theme;
631
+ const spec = COMMANDS.find((c) => c.name === "lead");
632
+ if (!spec) return 2;
633
+ const parsed = parseFlags(ctx, spec, argv);
634
+ if (typeof parsed === "number") return parsed;
635
+ const [session, ...extra] = parsed.positionals;
636
+ if (!session || extra.length > 0) return fail(ctx, {
637
+ what: "conveno lead needs one session",
638
+ fix: `For example ${cmd(t, "conveno lead planner")}. ${cmd(t, "conveno status")} lists the names.`,
639
+ exit: 2,
640
+ ref: "e_usage"
641
+ });
642
+ let client;
643
+ try {
644
+ client = await ctx.connect(connectOpts(ctx, false));
645
+ } catch (e) {
646
+ const problem = daemonProblem(t, e);
647
+ return fail(ctx, {
648
+ what: problem.notRunning ? "The Conveno daemon is not running" : "The Conveno daemon cannot be reached",
649
+ detail: [problem.notRunning ? "There are no sessions to pick from." : problem.why],
650
+ fix: problem.notRunning ? `Run ${cmd(t, "conveno daemon start")}.` : problem.fix,
651
+ exit: 1,
652
+ ref: "e_daemon"
653
+ });
654
+ }
655
+ try {
656
+ const found = await findSession(client, session);
657
+ if (!found) return fail(ctx, {
658
+ what: `No session "${session}"`,
659
+ fix: `Run ${cmd(t, "conveno status")} to see the names.`,
660
+ exit: 1,
661
+ ref: "e_session"
662
+ });
663
+ if (found.status === "offline") return fail(ctx, {
664
+ what: `${found.name} is offline`,
665
+ detail: ["Only a session that is online can be the lead."],
666
+ fix: `Run ${cmd(t, "conveno status")} to see who is online.`,
667
+ exit: 1,
668
+ ref: "e_session"
669
+ });
670
+ await client["orchestrator.claim"]({ sessionId: found.id });
671
+ ctx.out(`${t.status("ok")} ${t.bold(found.name)} is the lead now.\n`);
672
+ return 0;
673
+ } catch (e) {
674
+ return fail(ctx, {
675
+ what: "The lead was not changed",
676
+ detail: [plainError(e)],
677
+ fix: `Run ${cmd(t, "conveno status")} to see the sessions.`,
678
+ exit: 1,
679
+ ref: "e_lead"
680
+ });
681
+ } finally {
682
+ await client.close().catch(() => void 0);
683
+ }
684
+ }
616
685
  // src/peek.ts
617
686
  async function connectOrFail(ctx) {
618
687
  const t = ctx.theme;
@@ -761,12 +830,12 @@ const oneLine = (text, max) => {
761
830
  const headline = (t) => oneLine(t.question.split("\n")[0] ?? "", 70);
762
831
  async function runTickets(ctx, argv) {
763
832
  const t = ctx.theme;
764
- const spec = COMMANDS.find((c) => c.name === "tickets");
833
+ const spec = COMMANDS.find((c) => c.name === "questions");
765
834
  if (!spec) return 2;
766
835
  const parsed = parseFlags(ctx, spec, argv);
767
836
  if (typeof parsed === "number") return parsed;
768
837
  const openOnly = parsed.values.open === true;
769
- const client = await connectRunning(ctx, "Tickets live in the daemon, so there are none to list.");
838
+ const client = await connectRunning(ctx, "Questions live in the daemon, so there are none to list.");
770
839
  if ("exit" in client) return client.exit;
771
840
  try {
772
841
  const res = await client["ticket.list"]({
@@ -776,7 +845,7 @@ async function runTickets(ctx, argv) {
776
845
  const names = new Map((await client["session.list"]({ includeOffline: true })).sessions.map((s) => [s.id, s.name]));
777
846
  const who = (id) => names.get(id) ?? id.slice(-6);
778
847
  if (res.tickets.length === 0) {
779
- ctx.out(`${t.status("info")} ${openOnly ? "No open tickets." : "No tickets yet."} ${t.paint("quiet", "Workers raise them with the ask tool.")}\n`);
848
+ ctx.out(`${t.status("info")} ${openOnly ? "No open questions." : "No questions yet."} ${t.paint("quiet", "Workers ask with the ask tool.")}\n`);
780
849
  return 0;
781
850
  }
782
851
  const q = (w) => t.paint("quiet", w);
@@ -797,7 +866,7 @@ async function runTickets(ctx, argv) {
797
866
  ])];
798
867
  ctx.out(`${columns(rows).join("\n")}\n\n`);
799
868
  const hint = res.openCount > 0 ? ` Answer with ${cmd(t, "conveno answer <ticket> <text>")}.` : "";
800
- ctx.out(`${plural(res.openCount, "open ticket")}.${hint}\n`);
869
+ ctx.out(`${plural(res.openCount, "open question")}.${hint}\n`);
801
870
  return 0;
802
871
  } finally {
803
872
  await client.close().catch(() => void 0);
@@ -822,7 +891,7 @@ async function runAnswer(ctx, argv) {
822
891
  const response = words.join(" ").trim();
823
892
  if (!id || response === "") return fail(ctx, {
824
893
  what: "conveno answer needs a ticket and an answer",
825
- fix: `For example ${cmd(t, "conveno answer 01J8ABCD \"Use sqlite\"")}. ${cmd(t, "conveno tickets --open")} lists the open tickets.`,
894
+ fix: `For example ${cmd(t, "conveno answer 01J8ABCD \"Use sqlite\"")}. ${cmd(t, "conveno questions --open")} lists the open questions.`,
826
895
  exit: 2,
827
896
  ref: "e_usage"
828
897
  });
@@ -833,7 +902,7 @@ async function runAnswer(ctx, argv) {
833
902
  const picked = pickTicket(tickets, id);
834
903
  if (typeof picked === "string") return fail(ctx, {
835
904
  what: picked,
836
- fix: `Run ${cmd(t, "conveno tickets --open")} to see the open tickets.`,
905
+ fix: `Run ${cmd(t, "conveno questions --open")} to see the open questions.`,
837
906
  exit: 1,
838
907
  ref: "e_ticket"
839
908
  });
@@ -848,7 +917,7 @@ async function runAnswer(ctx, argv) {
848
917
  return fail(ctx, {
849
918
  what: "The ticket could not be answered",
850
919
  detail: [e instanceof Error ? e.message : String(e)],
851
- fix: `Run ${cmd(t, "conveno tickets")} to see its state.`,
920
+ fix: `Run ${cmd(t, "conveno questions")} to see its state.`,
852
921
  exit: 1,
853
922
  ref: "e_ticket"
854
923
  });
@@ -997,6 +1066,117 @@ async function runPermissions(ctx, argv) {
997
1066
  await client.close().catch(() => void 0);
998
1067
  }
999
1068
  }
1069
+ // src/rename.ts
1070
+ /** `conveno rename <session> <new-name>`. */
1071
+ async function runRename(ctx, argv) {
1072
+ const t = ctx.theme;
1073
+ const spec = COMMANDS.find((c) => c.name === "rename");
1074
+ if (!spec) return 2;
1075
+ const parsed = parseFlags(ctx, spec, argv);
1076
+ if (typeof parsed === "number") return parsed;
1077
+ const [session, name, ...extra] = parsed.positionals;
1078
+ if (!session || !name || extra.length > 0) return fail(ctx, {
1079
+ what: "conveno rename needs a session and a new name",
1080
+ fix: `For example ${cmd(t, "conveno rename claude@app-1 planner")}.`,
1081
+ exit: 2,
1082
+ ref: "e_usage"
1083
+ });
1084
+ let client;
1085
+ try {
1086
+ client = await ctx.connect(connectOpts(ctx, false));
1087
+ } catch (e) {
1088
+ const problem = daemonProblem(t, e);
1089
+ return fail(ctx, {
1090
+ what: problem.notRunning ? "The Conveno daemon is not running" : "The Conveno daemon cannot be reached",
1091
+ detail: [problem.notRunning ? "There are no sessions to rename." : problem.why],
1092
+ fix: problem.notRunning ? `Run ${cmd(t, "conveno daemon start")}.` : problem.fix,
1093
+ exit: 1,
1094
+ ref: "e_daemon"
1095
+ });
1096
+ }
1097
+ try {
1098
+ const found = await findSession(client, session);
1099
+ if (!found) return fail(ctx, {
1100
+ what: `No session "${session}"`,
1101
+ fix: `Run ${cmd(t, "conveno status")} to see the names.`,
1102
+ exit: 1,
1103
+ ref: "e_session"
1104
+ });
1105
+ if (found.status === "offline") return fail(ctx, {
1106
+ what: `${found.name} is offline`,
1107
+ detail: ["Only a session that is online can be renamed."],
1108
+ fix: `Run ${cmd(t, "conveno status")} to see who is online.`,
1109
+ exit: 1,
1110
+ ref: "e_session"
1111
+ });
1112
+ const res = await client["session.rename"]({
1113
+ sessionId: found.id,
1114
+ name
1115
+ });
1116
+ ctx.out(`${t.status("ok")} ${t.bold(found.name)} is now ${t.bold(res.session.name)}.\n`);
1117
+ return 0;
1118
+ } catch (e) {
1119
+ return fail(ctx, {
1120
+ what: "The session was not renamed",
1121
+ detail: [plainError(e)],
1122
+ fix: `Pick another name, or run ${cmd(t, "conveno status")} to see the names in use.`,
1123
+ exit: 1,
1124
+ ref: "e_rename"
1125
+ });
1126
+ } finally {
1127
+ await client.close().catch(() => void 0);
1128
+ }
1129
+ }
1130
+ // src/send.ts
1131
+ /** `conveno send <to> <text...>`: send a message as you, the owner. */
1132
+ async function runSend(ctx, argv) {
1133
+ const t = ctx.theme;
1134
+ const spec = COMMANDS.find((c) => c.name === "send");
1135
+ if (!spec) return 2;
1136
+ const parsed = parseFlags(ctx, spec, argv);
1137
+ if (typeof parsed === "number") return parsed;
1138
+ const [to, ...words] = parsed.positionals;
1139
+ let text = words.join(" ");
1140
+ if (words.length === 1 && words[0] === "-") text = (await ctx.readStdin()).replace(/\s+$/, "");
1141
+ if (!to || text.trim() === "") return fail(ctx, {
1142
+ what: "conveno send needs a recipient and a text",
1143
+ fix: `For example ${cmd(t, "conveno send lead \"Please start with the tests\"")}, or ${cmd(t, "conveno send worker -")} to read the text from standard input.`,
1144
+ exit: 2,
1145
+ ref: "e_usage"
1146
+ });
1147
+ let client;
1148
+ try {
1149
+ client = await ctx.connect(connectOpts(ctx, false));
1150
+ } catch (e) {
1151
+ const problem = daemonProblem(t, e);
1152
+ return fail(ctx, {
1153
+ what: problem.notRunning ? "The Conveno daemon is not running" : "The Conveno daemon cannot be reached",
1154
+ detail: [problem.notRunning ? "Nobody can get the message." : problem.why],
1155
+ fix: problem.notRunning ? `Run ${cmd(t, "conveno daemon start")}.` : problem.fix,
1156
+ exit: 1,
1157
+ ref: "e_daemon"
1158
+ });
1159
+ }
1160
+ try {
1161
+ const res = await client["owner.send"]({
1162
+ to,
1163
+ text,
1164
+ urgent: parsed.values.urgent === true
1165
+ });
1166
+ ctx.out(`${t.status("ok")} Sent to ${t.bold(res.deliveredTo.name)}.\n`);
1167
+ return 0;
1168
+ } catch (e) {
1169
+ return fail(ctx, {
1170
+ what: "The message was not sent",
1171
+ detail: [plainError(e)],
1172
+ fix: `Run ${cmd(t, "conveno status")} to see the session names.`,
1173
+ exit: 1,
1174
+ ref: "e_send"
1175
+ });
1176
+ } finally {
1177
+ await client.close().catch(() => void 0);
1178
+ }
1179
+ }
1000
1180
  // src/spawn.ts
1001
1181
  /** Read the task from `--task-file`. Returns the text or the failure's exit code. */
1002
1182
  function readTaskFile(ctx, path) {
@@ -1053,15 +1233,27 @@ async function runSpawn(ctx, argv) {
1053
1233
  if (typeof text === "number") return text;
1054
1234
  task = text;
1055
1235
  }
1056
- const acpFlag = parsed.values.acp === true;
1057
- const oneShot = parsed.values["one-shot"] === true;
1236
+ const mode = str("mode");
1237
+ if (mode !== void 0 && ![
1238
+ "window",
1239
+ "background",
1240
+ "once"
1241
+ ].includes(mode)) return fail(ctx, {
1242
+ what: `"${mode}" is not a spawn mode`,
1243
+ detail: ["Modes: window (a terminal you can watch), background, once (one task, then it ends)."],
1244
+ fix: help,
1245
+ exit: 2,
1246
+ ref: "e_usage"
1247
+ });
1248
+ const acpFlag = mode === void 0 ? parsed.values.acp === true : mode === "background";
1249
+ const oneShot = mode === void 0 ? parsed.values["one-shot"] === true : mode === "once";
1058
1250
  if (acpFlag && oneShot) return fail(ctx, {
1059
1251
  what: "Use --acp or --one-shot, not both",
1060
1252
  fix: help,
1061
1253
  exit: 2,
1062
1254
  ref: "e_usage"
1063
1255
  });
1064
- const headless = parsed.values.headless === true || acpFlag || oneShot;
1256
+ const headless = mode === void 0 ? parsed.values.headless === true || acpFlag || oneShot : mode !== "window";
1065
1257
  const acp = acpFlag ? "require" : headless && !oneShot ? "prefer" : void 0;
1066
1258
  const allowFlag = str("allow");
1067
1259
  const allow = allowFlag === void 0 ? void 0 : [allowFlag];
@@ -1354,7 +1546,9 @@ async function runMcp(ctx, argv) {
1354
1546
  });
1355
1547
  }
1356
1548
  }
1357
- async function dispatch(command, rest, ctx) {
1549
+ async function dispatch(name, rest, ctx) {
1550
+ let command = name;
1551
+ if (command === "tickets") command = "questions";
1358
1552
  const spec = COMMANDS.find((c) => c.name === command);
1359
1553
  if (spec && (rest.includes("--help") || rest.includes("-h")) && command !== "hook") {
1360
1554
  ctx.out(commandHelp(ctx, spec));
@@ -1364,14 +1558,17 @@ async function dispatch(command, rest, ctx) {
1364
1558
  case "init": return runInit(ctx, rest);
1365
1559
  case "uninstall": return runUninstall(ctx, rest);
1366
1560
  case "status": return runStatus(ctx, rest);
1367
- case "tickets": return runTickets(ctx, rest);
1561
+ case "questions": return runTickets(ctx, rest);
1562
+ case "send": return runSend(ctx, rest);
1563
+ case "rename": return runRename(ctx, rest);
1564
+ case "lead": return runLead(ctx, rest);
1368
1565
  case "answer": return runAnswer(ctx, rest);
1369
1566
  case "permissions": return runPermissions(ctx, rest);
1370
1567
  case "forget": return runForget(ctx, rest);
1371
1568
  case "spawn": return runSpawn(ctx, rest);
1372
- case "acp-host": return (await import("./acp-BD19nka6.js")).runAcpHostCmd(ctx, rest);
1373
- case "stop": return (await import("./acp-BD19nka6.js")).runStop(ctx, rest);
1374
- case "attach": return (await import("./acp-BD19nka6.js")).runAttach(ctx, rest);
1569
+ case "acp-host": return (await import("./acp-BD7Oaerg.js")).runAcpHostCmd(ctx, rest);
1570
+ case "stop": return (await import("./acp-BD7Oaerg.js")).runStop(ctx, rest);
1571
+ case "attach": return (await import("./acp-BD7Oaerg.js")).runAttach(ctx, rest);
1375
1572
  case "spawn-run": return runSpawnRun(ctx, rest);
1376
1573
  case "auto": return runAuto(ctx, rest);
1377
1574
  case "peek": return runPeek(ctx, rest);
@@ -1413,7 +1610,7 @@ function opensApp(env, tty = {
1413
1610
  async function main(argv, ctx) {
1414
1611
  const [command, ...rest] = argv;
1415
1612
  if (command === void 0 && opensApp(ctx.env)) try {
1416
- return await (await import("./run-BlRhoflZ.js")).runTui(ctx);
1613
+ return await (await import("./run-CYH0CRbp.js")).runTui(ctx);
1417
1614
  } catch (e) {
1418
1615
  ctx.err(`The app could not start (${rawMessage(e)}). Showing the help instead.\n`);
1419
1616
  ctx.out(helpText(ctx));