@conveno/cli 0.2.0-rc.13 → 0.2.0-rc.14

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,10 +1,10 @@
1
1
  import { Box, Text, render, useApp, useInput, useStdin, useStdout } from "ink";
2
2
  import { n as connectOpts, t as adapterEnv } from "./ctx-tYftvhz_.js";
3
- import { D as stopDaemonIfRunning, N as showCode$1, S as PAIR_TIMEOUT_MS, T as replaceStaleDaemon, _ as saveChoice, a as applyOptions, b as unifiedDiff, c as collectPlans, d as refreshManifest, f as renewedApprovals, g as connectedTools, h as chosenTools, k as openInBrowser, l as detectAll, n as inspect, o as approvalWrites, r as partState, s as approvedBySetup, t as runUninstall, u as pendingOptions, v as StaleError, x as warmAcpAdapters, y as applyChanges } from "./uninstall-812XZDTG.js";
4
- import { t as daemonProblem } from "./daemonError-CjxG2yUl.js";
3
+ import { C as saveChoice, D as warmAcpAdapters, E as unifiedDiff, F as openInBrowser, N as stopDaemonIfRunning, O as PAIR_TIMEOUT_MS, S as connectedTools, T as applyChanges, _ as readWorkerAccess, a as applyOptions, c as collectPlans, d as refreshManifest, f as renewedApprovals, g as UNANSWERED_TEXT, h as ACCESS_TEXT, j as replaceStaleDaemon, l as detectAll, n as inspect, o as approvalWrites, r as partState, s as approvedBySetup, t as runUninstall, u as pendingOptions, v as saveWorkerAccess, w as StaleError, x as chosenTools, y as waitText, z as showCode$1 } from "./uninstall-CQoGVhp3.js";
4
+ import { t as daemonProblem } from "./daemonError-CUE_dVn-.js";
5
5
  import { a as fail, n as cmd, s as plainError, u as tilde } from "./fmt-C2SsP5Y0.js";
6
6
  import { createContext, useContext, useEffect, useImperativeHandle, useMemo, useReducer, useRef, useState, useSyncExternalStore } from "react";
7
- import { Ht as readSettings, Kt as requestDeviceCode, Lt as readAccountTokens, N as compatStatus, Nt as planSpawn, P as completeLogin, Pt as pollDeviceCode, Ut as readSpawnRecord, V as defaultProcessIo, Vt as readProcessList, Wt as realSpawnDeps, X as findOnPath, Y as fetchAccountStatus, gn as writeSettings, gt as logoutAccount, jn as SESSION_NAME_PATTERN, nn as spawnRecordPath, r as AccountError, rn as spawnSession, z as dataPaths } from "./dist-DnNuDzEA.js";
7
+ import { Bt as readAccountTokens, F as compatStatus, Gt as readSettings, I as completeLogin, It as planSpawn, Kt as readSpawnRecord, Ln as SESSION_NAME_PATTERN, Lt as pollDeviceCode, Q as findOnPath, Sn as writeSettings, U as defaultProcessIo, V as dataPaths, Wt as readProcessList, Yt as requestDeviceCode, Z as fetchAccountStatus, an as spawnRecordPath, h as WORKER_UNANSWERED, m as WORKER_ASK_TIMEOUT_CHOICES, n as AccountError, on as spawnSession, p as WORKER_ACCESS, qt as realSpawnDeps, yt as logoutAccount } from "./dist-1k5b8UGF.js";
8
8
  import { i as tokens, n as detectColorLevel, r as detectUnicode } from "./dist-BRjg9CLd.js";
9
9
  import { Fragment, jsx, jsxs } from "react/jsx-runtime";
10
10
  import { readFileSync, statSync, writeFileSync } from "node:fs";
@@ -12,7 +12,7 @@ import { Readable } from "node:stream";
12
12
  import { basename, posix, win32 } from "node:path";
13
13
  import { spawn } from "node:child_process";
14
14
  import { homedir } from "node:os";
15
- import { r as stopRequestPath, t as killProcessTree } from "./dist-BkhKEexU.js";
15
+ import { r as stopRequestPath, t as killProcessTree } from "./dist-BiV6HopA.js";
16
16
  // src/tui/home/deps.ts
17
17
  /**
18
18
  * What home does outside the store: sign in and out, and take Conveno away. Real in the app, fake
@@ -1173,6 +1173,134 @@ function sessionLabel(s, all) {
1173
1173
  const tool = sessionTool(s);
1174
1174
  return all.some((o) => o.id !== s.id && o.cli === s.cli) ? `${tool} (${shortName(s.name)})` : tool;
1175
1175
  }
1176
+ // src/tui/home/access.tsx
1177
+ /** "Worker access": what background workers may do, how long a question waits, and what then. */
1178
+ /** One question: a list that starts on `current`, tracks its own focus, and answers on enter. */
1179
+ function Pick({ items, current, onPick }) {
1180
+ const [value, setValue] = useState(current);
1181
+ const [focus, setFocus] = useState(Math.max(0, items.findIndex((i) => i.id === current)));
1182
+ const known = (v) => items.find((i) => i.id === v)?.id ?? value;
1183
+ return /* @__PURE__ */ jsx(Choices, {
1184
+ items,
1185
+ value: [value],
1186
+ onChange: (v) => setValue(known(v[0])),
1187
+ onSubmit: (v) => onPick(known(v[0])),
1188
+ focusIndex: focus,
1189
+ onFocusChange: setFocus
1190
+ });
1191
+ }
1192
+ const KEYS = [
1193
+ {
1194
+ k: "↑↓",
1195
+ label: "move"
1196
+ },
1197
+ {
1198
+ k: "enter",
1199
+ label: "choose"
1200
+ },
1201
+ {
1202
+ k: "esc",
1203
+ label: "back"
1204
+ }
1205
+ ];
1206
+ function WorkerAccessScreen({ actions, onBack, onSaved, onFailed }) {
1207
+ const k = useKit();
1208
+ const [phase, setPhase] = useState("access");
1209
+ const [access, setAccess] = useState("edit");
1210
+ const [waitSec, setWaitSec] = useState(120);
1211
+ const [unanswered, setUnanswered] = useState("deny");
1212
+ const [loaded, setLoaded] = useState(false);
1213
+ useEffect(() => {
1214
+ let live = true;
1215
+ actions.getWorkerAccess().then((c) => {
1216
+ if (!live) return;
1217
+ setAccess(c.access);
1218
+ setWaitSec(c.waitSec);
1219
+ setUnanswered(c.unanswered);
1220
+ }).catch(() => void 0).finally(() => {
1221
+ if (live) setLoaded(true);
1222
+ });
1223
+ return () => {
1224
+ live = false;
1225
+ };
1226
+ }, [actions]);
1227
+ useInput((_input, key) => {
1228
+ if (!key.escape) return;
1229
+ if (phase === "unanswered") setPhase("wait");
1230
+ else if (phase === "wait") setPhase("access");
1231
+ else onBack();
1232
+ });
1233
+ const save = (choice) => {
1234
+ actions.setWorkerAccess(choice).then(() => onSaved(choice), onFailed);
1235
+ };
1236
+ if (!loaded) return /* @__PURE__ */ jsx(Frame, {
1237
+ keys: [{
1238
+ k: "esc",
1239
+ label: "back"
1240
+ }],
1241
+ children: /* @__PURE__ */ jsx(Text, {
1242
+ ...k.quiet,
1243
+ children: "Reading your choice…"
1244
+ })
1245
+ });
1246
+ if (phase === "access") return /* @__PURE__ */ jsx(Frame, {
1247
+ title: "What may background workers do?",
1248
+ keys: KEYS,
1249
+ children: /* @__PURE__ */ jsx(Pick, {
1250
+ items: WORKER_ACCESS.map((id) => ({
1251
+ id,
1252
+ label: ACCESS_TEXT[id].label,
1253
+ hint: ACCESS_TEXT[id].hint
1254
+ })),
1255
+ current: access,
1256
+ onPick: (next) => {
1257
+ setAccess(next);
1258
+ if (next === "full") save({
1259
+ access: next,
1260
+ unanswered,
1261
+ waitSec
1262
+ });
1263
+ else setPhase("wait");
1264
+ }
1265
+ }, "access")
1266
+ });
1267
+ if (phase === "wait") return /* @__PURE__ */ jsx(Frame, {
1268
+ title: "Wait for an answer",
1269
+ subtitle: "Asked requests go to the session that started the worker.",
1270
+ keys: KEYS,
1271
+ children: /* @__PURE__ */ jsx(Pick, {
1272
+ items: WORKER_ASK_TIMEOUT_CHOICES.map((sec) => ({
1273
+ id: String(sec),
1274
+ label: waitText(sec)
1275
+ })),
1276
+ current: String(waitSec),
1277
+ onPick: (id) => {
1278
+ setWaitSec(WORKER_ASK_TIMEOUT_CHOICES.find((s) => String(s) === id) ?? waitSec);
1279
+ setPhase("unanswered");
1280
+ }
1281
+ }, "wait")
1282
+ });
1283
+ return /* @__PURE__ */ jsx(Frame, {
1284
+ title: `If nobody answers in ${waitText(waitSec)}`,
1285
+ keys: KEYS,
1286
+ children: /* @__PURE__ */ jsx(Pick, {
1287
+ items: WORKER_UNANSWERED.map((id) => ({
1288
+ id,
1289
+ label: UNANSWERED_TEXT[id].label,
1290
+ hint: UNANSWERED_TEXT[id].hint
1291
+ })),
1292
+ current: unanswered,
1293
+ onPick: (next) => {
1294
+ setUnanswered(next);
1295
+ save({
1296
+ access,
1297
+ unanswered: next,
1298
+ waitSec
1299
+ });
1300
+ }
1301
+ }, "unanswered")
1302
+ });
1303
+ }
1176
1304
  // src/tui/home/hooks.ts
1177
1305
  /** The store's state, re-read whenever it changes. */
1178
1306
  function useStoreState(store) {
@@ -2130,6 +2258,10 @@ const MENU_ITEMS = [
2130
2258
  id: "setup",
2131
2259
  label: "Set up tools"
2132
2260
  },
2261
+ {
2262
+ id: "workers",
2263
+ label: "Worker access"
2264
+ },
2133
2265
  {
2134
2266
  id: "computers",
2135
2267
  label: "Other computers"
@@ -2459,12 +2591,25 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2459
2591
  say(reasonOf(e, "That did not send."), "error");
2460
2592
  }
2461
2593
  };
2462
- const makeLead = async () => {
2594
+ const startLead = () => {
2463
2595
  const who = target();
2464
2596
  if (!who) return;
2465
2597
  const label = sessionLabel(who, state.sessions);
2466
- if (who.isOrchestrator) return say(`${label} is already in charge.`, "info");
2467
- if (who.remote) return say("That one's on another computer. Pick one here.", "warn");
2598
+ if (who.isOrchestrator) {
2599
+ say(`${label} is already in charge.`, "info");
2600
+ return;
2601
+ }
2602
+ if (who.remote) {
2603
+ say("That one's on another computer. Pick one here.", "warn");
2604
+ return;
2605
+ }
2606
+ setMode("lead");
2607
+ };
2608
+ const makeLead = async () => {
2609
+ const who = sel;
2610
+ setMode("board");
2611
+ if (!who) return;
2612
+ const label = sessionLabel(who, state.sessions);
2468
2613
  try {
2469
2614
  await actions.setLead(who.id);
2470
2615
  say(`${label} is in charge now.`);
@@ -2529,11 +2674,11 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2529
2674
  const pick = (id) => {
2530
2675
  setMode("board");
2531
2676
  if (id === "send") startMessage();
2532
- else if (id === "lead") makeLead();
2677
+ else if (id === "lead") startLead();
2533
2678
  else if (id === "rename") startRename();
2534
2679
  else if (id === "remove") startRemove();
2535
2680
  else if (id === "setup") onSetup();
2536
- else if (id === "computers" || id === "account" || id === "uninstall") setMode(id);
2681
+ else if (id === "computers" || id === "account" || id === "uninstall" || id === "workers") setMode(id);
2537
2682
  else if (id === "quit") onQuit();
2538
2683
  };
2539
2684
  const move = (to) => {
@@ -2557,7 +2702,7 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2557
2702
  return lead && first ? setSelId(first.id) : void 0;
2558
2703
  }
2559
2704
  if (key.return || input === "m") return startMessage();
2560
- if (input === "l") return void makeLead();
2705
+ if (input === "l") return startLead();
2561
2706
  if (input === "r") return startRename();
2562
2707
  if (input === "x") return startRemove();
2563
2708
  if (input === "f") return startFix();
@@ -2569,6 +2714,10 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2569
2714
  if (input === "y" || input === "Y") remove();
2570
2715
  else if (input === "n" || input === "N" || key.escape || key.return) setMode("board");
2571
2716
  }, { isActive: mode === "remove" });
2717
+ useInput((input, key) => {
2718
+ if (input === "y" || input === "Y") makeLead();
2719
+ else if (input === "n" || input === "N" || key.escape || key.return) setMode("board");
2720
+ }, { isActive: mode === "lead" });
2572
2721
  useWheel(boardRef, (d) => move(selIdx + d), { isActive: mode === "board" });
2573
2722
  const back = () => setMode("board");
2574
2723
  if (mode === "menu") return /* @__PURE__ */ jsx(Menu, {
@@ -2586,6 +2735,18 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2586
2735
  deps,
2587
2736
  onBack: back
2588
2737
  });
2738
+ if (mode === "workers") return /* @__PURE__ */ jsx(WorkerAccessScreen, {
2739
+ actions,
2740
+ onBack: back,
2741
+ onSaved: (c) => {
2742
+ back();
2743
+ say(`Workers now get ${c.access} access.`);
2744
+ },
2745
+ onFailed: (e) => {
2746
+ back();
2747
+ say(reasonOf(e, "That did not save."), "error");
2748
+ }
2749
+ });
2589
2750
  if (mode === "fix") return /* @__PURE__ */ jsx(FixScreen, {
2590
2751
  problems: fixing,
2591
2752
  actions,
@@ -2611,7 +2772,7 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2611
2772
  const hint = !lead && !empty;
2612
2773
  const entries = state.activity;
2613
2774
  let act = Math.min(ACTIVITY_LINES, Math.max(1, entries.length));
2614
- const asking = mode === "remove";
2775
+ const asking = mode === "remove" || mode === "lead";
2615
2776
  const fixed = 2 + (problems.length > 0 ? 2 : 0) + 1 + (typing || asking ? 1 : 0) + 1 + 1 + (hint ? 1 : 0);
2616
2777
  const need = lead && modeFor(columns) === "compact" ? 11 : 5;
2617
2778
  while (act > 1 && rows - fixed - act < need) act -= 1;
@@ -2671,6 +2832,10 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2671
2832
  k: "r",
2672
2833
  label: "rename"
2673
2834
  },
2835
+ {
2836
+ k: "x",
2837
+ label: "remove"
2838
+ },
2674
2839
  ...problems.length > 0 ? [{
2675
2840
  k: "f",
2676
2841
  label: "fix"
@@ -2762,6 +2927,11 @@ function Home({ store, deps, size, onSetup, onQuit }) {
2762
2927
  ...tint(k.c.warn),
2763
2928
  children: cut(`Remove ${sel.name} from the list? Its unread messages go too. y/n`, width, k.ascii)
2764
2929
  }) : null,
2930
+ mode === "lead" && sel ? /* @__PURE__ */ jsx(Text, {
2931
+ wrap: "truncate",
2932
+ ...tint(k.c.warn),
2933
+ children: cut(`Make ${sessionLabel(sel, state.sessions)} the lead? y/n`, width, k.ascii)
2934
+ }) : null,
2765
2935
  typing && sel ? /* @__PURE__ */ jsxs(Box, { children: [
2766
2936
  /* @__PURE__ */ jsx(Text, {
2767
2937
  wrap: "truncate",
@@ -4009,6 +4179,10 @@ function createOnboardingDeps(ctx) {
4009
4179
  saveChoice: async (tools, lead) => {
4010
4180
  saveChoice(ctx, tools, lead);
4011
4181
  },
4182
+ workerAccess: async () => readWorkerAccess(ctx).access,
4183
+ saveWorkerAccess: async (access) => {
4184
+ saveWorkerAccess(ctx, { access });
4185
+ },
4012
4186
  signedIn: async () => await readAccountTokens(tokenFile(ctx)).catch(() => null) !== null,
4013
4187
  signIn: async ({ signal, onCode }) => {
4014
4188
  const io = accountIo(ctx);
@@ -4058,6 +4232,7 @@ const initialState = (start) => ({
4058
4232
  tools: null,
4059
4233
  signedIn: false,
4060
4234
  picked: [],
4235
+ access: "edit",
4061
4236
  dropped: [],
4062
4237
  questions: [],
4063
4238
  qIndex: 0,
@@ -4161,8 +4336,21 @@ function buildRows(s) {
4161
4336
  });
4162
4337
  return rows;
4163
4338
  }
4164
- /** Leave the questions: set up the rows, or send the person back when nothing is left to do. */
4339
+ /** Leave the questions: ask what workers may do, or send the person back when nothing is left. */
4165
4340
  function startWorking(s) {
4341
+ if (buildRows(s).length === 0) return {
4342
+ ...s,
4343
+ step: "tools",
4344
+ notice: "Pick a tool to go on."
4345
+ };
4346
+ const { notice: _n, ...rest } = s;
4347
+ return {
4348
+ ...rest,
4349
+ step: "access"
4350
+ };
4351
+ }
4352
+ /** Set up the rows. */
4353
+ function runRows(s) {
4166
4354
  const active = activeTools(s);
4167
4355
  const lead = s.lead && active.some((t) => t.cli === s.lead) ? s.lead : s.lead && active[0]?.cli;
4168
4356
  const next = {
@@ -4228,9 +4416,14 @@ function reduce(s, a) {
4228
4416
  ...s,
4229
4417
  tools: a.tools,
4230
4418
  signedIn: a.signedIn,
4231
- picked: a.chosen.filter((c) => known.has(c))
4419
+ picked: a.chosen.filter((c) => known.has(c)),
4420
+ ...a.access ? { access: a.access } : {}
4232
4421
  };
4233
4422
  }
4423
+ case "chooseAccess": return s.step === "access" ? runRows({
4424
+ ...s,
4425
+ access: a.access
4426
+ }) : s;
4234
4427
  case "begin": return s.step === "welcome" && s.tools ? {
4235
4428
  ...s,
4236
4429
  step: "tools"
@@ -4319,6 +4512,15 @@ function reduce(s, a) {
4319
4512
  ...rest,
4320
4513
  step: "tools"
4321
4514
  };
4515
+ case "access":
4516
+ if (s.questions.length > 0) return toQuestionsAt(rest, s.questions.length - 1);
4517
+ return activeTools(rest).length >= 2 ? {
4518
+ ...rest,
4519
+ step: "lead"
4520
+ } : {
4521
+ ...rest,
4522
+ step: "tools"
4523
+ };
4322
4524
  default: return s;
4323
4525
  }
4324
4526
  }
@@ -4677,6 +4879,45 @@ function LeadStep({ s, dispatch }) {
4677
4879
  })
4678
4880
  });
4679
4881
  }
4882
+ function AccessStep({ s, dispatch }) {
4883
+ const [pick, setPick] = useState([s.access]);
4884
+ const [focus, setFocus] = useState(WORKER_ACCESS.indexOf(s.access));
4885
+ return /* @__PURE__ */ jsx(Frame, {
4886
+ title: "What may background workers do?",
4887
+ subtitle: "Workers are sessions Conveno starts for you. You can change this later.",
4888
+ keys: [
4889
+ {
4890
+ k: "↑↓",
4891
+ label: "move"
4892
+ },
4893
+ {
4894
+ k: "enter",
4895
+ label: "choose"
4896
+ },
4897
+ {
4898
+ k: "esc",
4899
+ label: "back"
4900
+ }
4901
+ ],
4902
+ children: /* @__PURE__ */ jsx(Choices, {
4903
+ items: WORKER_ACCESS.map((id) => ({
4904
+ id,
4905
+ label: ACCESS_TEXT[id].label,
4906
+ hint: ACCESS_TEXT[id].hint
4907
+ })),
4908
+ value: pick,
4909
+ onChange: setPick,
4910
+ onSubmit: (ids) => {
4911
+ dispatch({
4912
+ type: "chooseAccess",
4913
+ access: WORKER_ACCESS.find((a) => a === (ids[0] ?? s.access)) ?? s.access
4914
+ });
4915
+ },
4916
+ focusIndex: focus,
4917
+ onFocusChange: setFocus
4918
+ })
4919
+ });
4920
+ }
4680
4921
  function QuestionStep({ s, dispatch }) {
4681
4922
  const q = s.questions[s.qIndex];
4682
4923
  const [choice, setChoice] = useState(q?.defaultYes ? "yes" : "no");
@@ -4918,13 +5159,15 @@ function Onboarding({ deps, start, onDone }) {
4918
5159
  Promise.all([
4919
5160
  d.detect(),
4920
5161
  d.signedIn().catch(() => false),
4921
- d.chosen().catch(() => [])
4922
- ]).then(([tools, signedIn, chosen]) => {
5162
+ d.chosen().catch(() => []),
5163
+ d.workerAccess().catch(() => void 0)
5164
+ ]).then(([tools, signedIn, chosen, access]) => {
4923
5165
  if (live.current) dispatch({
4924
5166
  type: "loaded",
4925
5167
  tools,
4926
5168
  signedIn,
4927
- chosen
5169
+ chosen,
5170
+ ...access ? { access } : {}
4928
5171
  });
4929
5172
  });
4930
5173
  }, []);
@@ -4932,6 +5175,7 @@ function Onboarding({ deps, start, onDone }) {
4932
5175
  if (s.step !== "account" && s.step !== "finish") return;
4933
5176
  if (led.current) return;
4934
5177
  led.current = true;
5178
+ depsRef.current.saveWorkerAccess(s.access).catch(() => {});
4935
5179
  const tools = connectedRows(s).map((r) => r.cli);
4936
5180
  if (tools.length === 0) return;
4937
5181
  const lead = s.lead && tools.includes(s.lead) ? s.lead : void 0;
@@ -5073,7 +5317,8 @@ function Onboarding({ deps, start, onDone }) {
5073
5317
  "tools",
5074
5318
  "remove",
5075
5319
  "lead",
5076
- "question"
5320
+ "question",
5321
+ "access"
5077
5322
  ].includes(s.step)) dispatch({ type: "back" });
5078
5323
  return;
5079
5324
  }
@@ -5119,6 +5364,10 @@ function OnboardingView({ s, dispatch, signIn }) {
5119
5364
  s,
5120
5365
  dispatch
5121
5366
  });
5367
+ case "access": return /* @__PURE__ */ jsx(AccessStep, {
5368
+ s,
5369
+ dispatch
5370
+ });
5122
5371
  case "working": return /* @__PURE__ */ jsx(WorkingStep, { s });
5123
5372
  case "account": return /* @__PURE__ */ jsx(AccountStep, {
5124
5373
  s,
@@ -5521,7 +5770,10 @@ async function createStore(ctx, opts = {}) {
5521
5770
  });
5522
5771
  },
5523
5772
  async setLead(sessionId) {
5524
- await live()["orchestrator.claim"]({ sessionId });
5773
+ await live()["orchestrator.claim"]({
5774
+ sessionId,
5775
+ via: "home"
5776
+ });
5525
5777
  set({ sessions: state.sessions.map((s) => ({
5526
5778
  ...s,
5527
5779
  isOrchestrator: s.id === sessionId
@@ -5615,6 +5867,12 @@ async function createStore(ctx, opts = {}) {
5615
5867
  await live()["devices.revoke"]({ device: deviceId });
5616
5868
  await pollRelay(live());
5617
5869
  },
5870
+ async getWorkerAccess() {
5871
+ return readWorkerAccess(ctx);
5872
+ },
5873
+ async setWorkerAccess(choice) {
5874
+ saveWorkerAccess(ctx, choice);
5875
+ },
5618
5876
  async openAccountPage() {
5619
5877
  const base = ctx.env.CONVENO_API_URL || "https://api.conveno.dev";
5620
5878
  openInBrowser(ctx.platform, `${base}/account`);
@@ -4,18 +4,18 @@ import { homedir } from "node:os";
4
4
  import { delimiter, join, win32 } from "node:path";
5
5
  import { createInterface } from "node:readline";
6
6
  import { fileURLToPath } from "node:url";
7
- import { n as antigravityAdapter } from "./dist-D4sb5RQD.js";
8
- import { a as opencodeAdapter, o as claudeAdapter, r as readAllStdin } from "./hook-entry-WlJSM5aD.js";
9
- import { t as codexAdapter } from "./dist-C9Z1EMlM.js";
10
- import { t as grokAdapter } from "./dist-B14ldKRS.js";
7
+ import { n as antigravityAdapter } from "./dist-vefQHFb-.js";
8
+ import { a as opencodeAdapter, o as claudeAdapter, r as readAllStdin } from "./hook-entry-Cxh3yIdT.js";
9
+ import { t as codexAdapter } from "./dist-Cv5et1iE.js";
10
+ import { t as grokAdapter } from "./dist-D-PhGsuL.js";
11
11
  import { t as createTheme } from "./dist-BRjg9CLd.js";
12
- import { n as connect$1 } from "./dist-Ca3P7aN-.js";
13
- import { $ as formatInbox, C as attachAcpSession, E as baseName, H as detectRepo, Mn as SessionId, Nt as planSpawn, On as RpcErrorCode, Ot as pendingTurn, R as dataDir, Rt as readAncestry, Tn as OWNER_SESSION_ID, Tt as parsePs1ShimTarget, Wt as realSpawnDeps, Xn as array, Yn as _enum, Zn as boolean, Zt as resolveWindowsCommand, _n as CLI_KINDS, a as ConvenoError, c as HEARTBEAT_INTERVAL_MS, er as number, f as SPAWN_CLIS, k as claimSpawnRecord, kt as pidAlive, l as NOT_FROM_USER_NOTICE, m as SpawnError, mt as launcherText, nr as string, pn as validateRename, pt as launcherPath, rn as spawnSession, st as isAntigravityApp, vt as needsQuoting, wn as MessageId, wt as parseCmdShimTarget, zt as readCommandLine } from "./dist-DnNuDzEA.js";
14
- import "./dist-CoRBNycn.js";
12
+ import { n as connect$1 } from "./dist-BYkDv29h.js";
13
+ import { An as MessageId, B as dataDir, Cn as CLI_KINDS, Dt as parsePs1ShimTarget, Et as parseCmdShimTarget, Ht as readCommandLine, It as planSpawn, Mt as pidAlive, O as baseName, Pn as RpcErrorCode, Rn as SessionId, T as attachAcpSession, Vt as readAncestry, W as detectRepo, cr as string, ct as isAntigravityApp, en as resolveWindowsCommand, f as SpawnError, gn as validateRename, ht as launcherText, i as ConvenoError, j as claimSpawnRecord, jn as OWNER_SESSION_ID, jt as pendingTurn, mt as launcherPath, nr as array, o as HEARTBEAT_INTERVAL_MS, on as spawnSession, or as number, qt as realSpawnDeps, rr as boolean, s as NOT_FROM_USER_NOTICE, tr as _enum, tt as formatInbox, u as SPAWN_CLIS, xt as needsQuoting } from "./dist-1k5b8UGF.js";
14
+ import "./dist-C4Ey9THP.js";
15
15
  import { access } from "node:fs/promises";
16
16
  import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
17
17
  import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
18
- // ../daemon/dist/server-D8Ib1txr.js
18
+ // ../daemon/dist/server-BoGpufaz.js
19
19
  /** `kill(pid, 0)` liveness: EPERM means the process exists but belongs to someone else. */
20
20
  function defaultIsAlive(pid) {
21
21
  try {
@@ -28,7 +28,7 @@ function defaultIsAlive(pid) {
28
28
  `${OWNER_SESSION_ID}`;
29
29
  SessionId.parse("0".repeat(26));
30
30
  // ../mcp/dist/index.js
31
- const SERVER_VERSION = "0.2.0-rc.13";
31
+ const SERVER_VERSION = "0.2.0-rc.14";
32
32
  const ok = (text) => ({ content: [{
33
33
  type: "text",
34
34
  text
@@ -391,6 +391,24 @@ function createServer(opts) {
391
391
  const plural = (n, one, many) => n === 1 ? one : many;
392
392
  return [`Acknowledged ${res.acked} ${plural(res.acked, "message", "messages")}.`, unknown > 0 ? `${unknown} ${plural(unknown, "id was", "ids were")} not found.` : ""].filter(Boolean).join(" ");
393
393
  }));
394
+ mcp.registerTool("answer_permission", {
395
+ description: "Answer a worker's permission request (sent to you as a 'wants to run' notice).",
396
+ inputSchema: {
397
+ request: string().min(1).max(64).describe("The request id from the notice."),
398
+ answer: _enum([
399
+ "allow",
400
+ "always",
401
+ "deny"
402
+ ]).describe("allow: this once. always: also for the same call later. deny.")
403
+ }
404
+ }, tool(async (me, a) => {
405
+ await client["permission.answer"]({
406
+ sessionId: me.id,
407
+ requestId: a.request,
408
+ answer: a.answer === "allow" ? "allow_once" : a.answer === "always" ? "allow_always" : "deny"
409
+ });
410
+ return `Answered request ${a.request}: ${a.answer}.`;
411
+ }));
394
412
  mcp.registerTool("rename", {
395
413
  description: "Change this session's name. Use it when the user wants a name others can remember, such as `api-worker`.",
396
414
  inputSchema: { name: string().min(1).describe("New name: 1 to 64 characters of lowercase letters, digits, '.', '_', '@' or '-'.") }
@@ -417,7 +435,10 @@ function createServer(opts) {
417
435
  return a.text === "" ? "Status cleared." : "Status set.";
418
436
  }));
419
437
  const becomeLead = tool(async (me) => {
420
- const res = await client["orchestrator.claim"]({ sessionId: me.id });
438
+ const res = await client["orchestrator.claim"]({
439
+ sessionId: me.id,
440
+ via: "tool"
441
+ });
421
442
  if (!res.previous) return "You are now the lead. There was no previous holder.";
422
443
  const { sessions } = await client["session.list"]({ includeOffline: true });
423
444
  return `You are now the lead. Previous holder: ${sessions.find((s) => s.id === res.previous)?.name ?? res.previous}.`;
@@ -458,7 +479,11 @@ function createServer(opts) {
458
479
  name: string().min(1).optional().describe("Session name: lowercase letters, digits, '.', '_', '@' or '-'."),
459
480
  task: string().min(1).optional().describe("The first task for the new session."),
460
481
  window: boolean().optional().describe("Open it in a visible terminal window instead of the background."),
461
- allow: array(string().min(1)).max(32).optional().describe("Optional. By default the worker has full access in its folder; limit it to these tool kinds, such as read, search, or execute:npm test*. Not for window workers.")
482
+ access: _enum([
483
+ "read",
484
+ "edit",
485
+ "full"
486
+ ]).optional().describe("Optional. What the worker may do without asking: read (look only), edit (also change files; the default) or full (everything). Not for window workers.")
462
487
  }
463
488
  }, tool(async (me, a) => {
464
489
  const deps = opts.spawnDeps ?? realSpawnDeps({
@@ -477,7 +502,7 @@ function createServer(opts) {
477
502
  name: a.name,
478
503
  task: a.task,
479
504
  window: a.window ?? false,
480
- allow: a.allow,
505
+ access: a.access,
481
506
  requester: me,
482
507
  confineToHome: true,
483
508
  timeoutMs: 45e3