bazilion 0.15.0 → 0.16.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 (94) hide show
  1. package/dist/cli.js +816 -681
  2. package/dist/cli.js.map +1 -1
  3. package/dist/daemon.js +6605 -4313
  4. package/dist/daemon.js.map +1 -1
  5. package/dist/migrations/0001_init.sql +47 -0
  6. package/dist/web/client/assets/ChatPane-CQZzxOir.js +76 -0
  7. package/dist/web/client/assets/{ConfirmDialog-CGZzom9E.js → ConfirmDialog-MicTTwdy.js} +1 -1
  8. package/dist/web/client/assets/{FieldRow-DYNU9gWb.js → FieldRow-DJ2Gx4Du.js} +1 -1
  9. package/dist/web/client/assets/{ProductionTeamPolicyEditor-DT5Sl8jd.js → ProductionTeamPolicyEditor-DqUnN_ce.js} +1 -1
  10. package/dist/web/client/assets/{ProfileCommunicationEditor-TyCU5vXX.js → ProfileCommunicationEditor-DArXub0b.js} +1 -1
  11. package/dist/web/client/assets/{ResultSourceConversation-CGhKTSTD.js → ResultSourceConversation-CtzJ8QA-.js} +1 -1
  12. package/dist/web/client/assets/{TeamTabs-BZHyRnbd.js → TeamTabs-DbIk5vvT.js} +1 -1
  13. package/dist/web/client/assets/{TemplatesTabs-BHzkPMRC.js → TemplatesTabs-CatJIjGi.js} +1 -1
  14. package/dist/web/client/assets/{UnsavedChangesGuard-CFQcKsrf.js → UnsavedChangesGuard-BCsLw-mU.js} +1 -1
  15. package/dist/web/client/assets/_id-B5Ov7cdO.js +1 -0
  16. package/dist/web/client/assets/{_id-D_eKokkd.js → _id-BEDmIXVf.js} +1 -1
  17. package/dist/web/client/assets/{_id-9nCIhbVd.js → _id-BFM_tn_s.js} +1 -1
  18. package/dist/web/client/assets/{_id-CGd21j3k.js → _id-CrnEVcw8.js} +1 -1
  19. package/dist/web/client/assets/{_id-BSu3AqKA.js → _id-DxopIW-y.js} +1 -1
  20. package/dist/web/client/assets/{activity-Cn2-9PpZ.js → activity-CrG8Bg60.js} +1 -1
  21. package/dist/web/client/assets/{agents-NY3VrZgB.js → agents-CMPOFcs-.js} +1 -1
  22. package/dist/web/client/assets/{agents-CCmiZek6.js → agents-O4soKZND.js} +1 -1
  23. package/dist/web/client/assets/{approvals-CPDAPgrM.js → approvals-CwDu_lrA.js} +1 -1
  24. package/dist/web/client/assets/{attention-Qra_9_OI.js → attention-BY8MMuM_.js} +1 -1
  25. package/dist/web/client/assets/chevron-right-Cf6vKeLq.js +1 -0
  26. package/dist/web/client/assets/{config-D8EO0LPB.js → config-Cn4iBJFz.js} +1 -1
  27. package/dist/web/client/assets/{inbox-C5W-sm1q.js → inbox-CWXql0K3.js} +1 -1
  28. package/dist/web/client/assets/{index-BUhhk_u9.js → index-Bq2zrG2_.js} +2 -2
  29. package/dist/web/client/assets/{learning-Dr-7_7J4.js → learning-DAm4dyyc.js} +1 -1
  30. package/dist/web/client/assets/{login-Bu5UxbJh.js → login-BsABI8Ux.js} +1 -1
  31. package/dist/web/client/assets/{mcp-BueuwQiv.js → mcp-loLB0wuh.js} +1 -1
  32. package/dist/web/client/assets/{members-ZikuYNcy.js → members-BJ0ikkTl.js} +1 -1
  33. package/dist/web/client/assets/{memory-1JUJlPrn.js → memory-Drn9Gv53.js} +1 -1
  34. package/dist/web/client/assets/{policy-DbkhsFNA.js → policy-pQadZyk0.js} +1 -1
  35. package/dist/web/client/assets/{results-mMr8Ar2u.js → results-9exU6f7m.js} +1 -1
  36. package/dist/web/client/assets/{routes-DJYB-MS9.js → routes-jw1PuqiR.js} +1 -1
  37. package/dist/web/client/assets/{services-kfQA9cpJ.js → services-BLso1BhA.js} +1 -1
  38. package/dist/web/client/assets/{skills-C6pcgxaC.js → skills-BodqX3OI.js} +1 -1
  39. package/dist/web/client/assets/styles-d1yjBpud.css +2 -0
  40. package/dist/web/client/assets/{teams-LB0KBXY9.js → teams-ByQedXZi.js} +1 -1
  41. package/dist/web/client/assets/{teams-C6_Noz5X.js → teams-SYsF1bOR.js} +1 -1
  42. package/dist/web/client/assets/{telegram-A2jaI1QM.js → telegram-DC9PLFbB.js} +1 -1
  43. package/dist/web/client/assets/{tokens-BGlUpJcL.js → tokens-DGy8Ijpo.js} +1 -1
  44. package/dist/web/client/assets/{triggers-C54_feGg.js → triggers-BXpVmHDG.js} +1 -1
  45. package/dist/web/client/assets/{welcome-DyUIswRi.js → welcome-BKsnsCxJ.js} +1 -1
  46. package/dist/web/client/assets/{x-BY2MPLr9.js → x-BK4xNCzS.js} +1 -1
  47. package/dist/web/server/assets/{ChatPane-DJ30FdFG.js → ChatPane-CS5oI7ef.js} +235 -13
  48. package/dist/web/server/assets/{ResultSourceConversation-zYogeOWp.js → ResultSourceConversation-BpVWBRYq.js} +1 -1
  49. package/dist/web/server/assets/{_id-1LwoHhJg.js → _id-5pgKoid8.js} +1 -1
  50. package/dist/web/server/assets/{_id-BvSWsPI5.js → _id-BG2nkGxa.js} +1 -1
  51. package/dist/web/server/assets/{_id-1hTvnKLN2.js → _id-BnqodC1c2.js} +3 -3
  52. package/dist/web/server/assets/{_id-DDNVQx3y.js → _id-CeyHEsCZ.js} +1 -1
  53. package/dist/web/server/assets/{_id-T_8btpbB.js → _id-DOnInzLb.js} +1 -1
  54. package/dist/web/server/assets/{_id-DxFLSIio.js → _id-DrB9uR1b.js} +1 -1
  55. package/dist/web/server/assets/{_id-B2EEyStS.js → _id-DtIYuJJX.js} +1 -1
  56. package/dist/web/server/assets/_id-DwZXhLlL.js +779 -0
  57. package/dist/web/server/assets/{_tanstack-start-manifest_v-DP4ZUBw3.js → _tanstack-start-manifest_v-D7gKv6m6.js} +85 -85
  58. package/dist/web/server/assets/{activity-D73w4mkZ.js → activity-0VUkStOu.js} +1 -1
  59. package/dist/web/server/assets/{agents-DB5hCSAI.js → agents-C86K6HvS.js} +1 -1
  60. package/dist/web/server/assets/{agents-DRSo7lRX.js → agents-CSXLaM2W.js} +1 -1
  61. package/dist/web/server/assets/{approvals-4y9bZF4r.js → approvals-C3MysI6l.js} +1 -1
  62. package/dist/web/server/assets/{attention-BFx8ZkmH.js → attention-DLeLCKah.js} +1 -1
  63. package/dist/web/server/assets/{auth-_eaCwhyq.js → auth-CDZp9aEk.js} +1 -1
  64. package/dist/web/server/assets/{config-B7JIfv_7.js → config-BVTHvljR.js} +1 -1
  65. package/dist/web/server/assets/{daemon-client-B06W1Qa2.js → daemon-client-xWyYKAcx.js} +5 -0
  66. package/dist/web/server/assets/{inbox-YRpDQcvp.js → inbox-PQTrjtOw.js} +1 -1
  67. package/dist/web/server/assets/{learning-UBZb6h6M.js → learning-K0cmDsZR.js} +1 -1
  68. package/dist/web/server/assets/{mcp-Dv6RXMaS.js → mcp-Rtraochg.js} +1 -1
  69. package/dist/web/server/assets/{members-BFTKSlOe.js → members-grAKFWgv.js} +1 -1
  70. package/dist/web/server/assets/{memory-D0PQgZAn.js → memory-egFpBD1g.js} +1 -1
  71. package/dist/web/server/assets/{policy-C-p8HIhA.js → policy-ooSBgiDS.js} +1 -1
  72. package/dist/web/server/assets/{results-Cj-Dlw3C.js → results-CfNsFncJ.js} +2 -2
  73. package/dist/web/server/assets/{results-Cfev4KNt.js → results-DXdYtHaq.js} +1 -1
  74. package/dist/web/server/assets/{results-CwEQ5EUL.js → results-N-kP4iFT.js} +1 -1
  75. package/dist/web/server/assets/{router-d3sTMpMX.js → router-B6g_s7W3.js} +6 -6
  76. package/dist/web/server/assets/{routes-cW4MWU18.js → routes-BqSaZvlu.js} +1 -1
  77. package/dist/web/server/assets/{routes-MIZz6uMr.js → routes-Dsh8F_7i.js} +2 -2
  78. package/dist/web/server/assets/{routes-B765DVhj.js → routes-pcRy_Sf8.js} +1 -1
  79. package/dist/web/server/assets/{services-BCbdn3R9.js → services-DlZA8fRL.js} +1 -1
  80. package/dist/web/server/assets/{skills-Bpoa8MIp.js → skills-i2duvgW-.js} +1 -1
  81. package/dist/web/server/assets/{teams-CXzwqzcE.js → teams-6RYIj1Xm.js} +1 -1
  82. package/dist/web/server/assets/{teams-hWGjbpUA.js → teams-B1AI3NfN.js} +1 -1
  83. package/dist/web/server/assets/{telegram-DhpvtGUc.js → telegram-C4q0YTVn.js} +1 -1
  84. package/dist/web/server/assets/{tokens-Bjp19Vkn.js → tokens-RFquA2Bx.js} +1 -1
  85. package/dist/web/server/assets/{triggers-DJlcvXzn.js → triggers-DVD-iE-N.js} +1 -1
  86. package/dist/web/server/server.js +28 -28
  87. package/dist/worker.js +1553 -688
  88. package/dist/worker.js.map +1 -1
  89. package/package.json +3 -3
  90. package/dist/web/client/assets/ChatPane-55j13bBj.js +0 -74
  91. package/dist/web/client/assets/_id-SRMFlIgP.js +0 -1
  92. package/dist/web/client/assets/chevron-right-DXE4CWf2.js +0 -1
  93. package/dist/web/client/assets/styles-CcNf8jT_.css +0 -2
  94. package/dist/web/server/assets/_id-CDBtO_jL.js +0 -381
package/dist/cli.js CHANGED
@@ -1,12 +1,12 @@
1
1
  #!/usr/bin/env node
2
2
 
3
3
  // src/index.ts
4
- import { defineCommand as defineCommand33, runCommand, showUsage } from "citty";
4
+ import { defineCommand as defineCommand34, runCommand, showUsage } from "citty";
5
5
 
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "bazilion",
9
- version: "0.15.0",
9
+ version: "0.16.0",
10
10
  description: "Multi-agent runtime CLI \u2014 spawn LLM agents, manage profiles/teams/skills, and run the local daemon.",
11
11
  license: "MIT",
12
12
  repository: {
@@ -177,6 +177,21 @@ function createClient(cfg) {
177
177
  return new Uint8Array(await res.arrayBuffer());
178
178
  }
179
179
  return {
180
+ codingEnvironment: {
181
+ show: (teamId) => request(
182
+ "GET",
183
+ `/api/teams/${encodeURIComponent(teamId)}/coding-environment`
184
+ ),
185
+ configure: (teamId, input) => request(
186
+ "PUT",
187
+ `/api/teams/${encodeURIComponent(teamId)}/coding-environment`,
188
+ input
189
+ )
190
+ },
191
+ repositoryContext: (teamId, options = {}) => request(
192
+ "GET",
193
+ `/api/teams/${encodeURIComponent(teamId)}/repository-context${options.target !== void 0 ? `?target=${encodeURIComponent(options.target)}` : ""}`
194
+ ),
180
195
  notifications: {
181
196
  settings: () => request("GET", "/api/notifications"),
182
197
  configure: (input) => request("PUT", "/api/notifications", input),
@@ -318,12 +333,12 @@ var list = defineCommand({
318
333
  offset: { type: "string", default: "0" },
319
334
  json: { type: "boolean" }
320
335
  },
321
- async run({ args }) {
322
- const query = new URLSearchParams({ limit: args.limit, offset: args.offset });
336
+ async run({ args: args2 }) {
337
+ const query = new URLSearchParams({ limit: args2.limit, offset: args2.offset });
323
338
  const body = await createClient2().get(
324
- `${pathFor(args.agent)}?${query}`
339
+ `${pathFor(args2.agent)}?${query}`
325
340
  );
326
- if (args.json) return console.log(JSON.stringify(body, null, 2));
341
+ if (args2.json) return console.log(JSON.stringify(body, null, 2));
327
342
  if (!body.total) return console.log("(no conversations)");
328
343
  for (const line of columnize([
329
344
  ["id", "title", "active"],
@@ -340,9 +355,9 @@ var list = defineCommand({
340
355
  var show = defineCommand({
341
356
  meta: { name: "show", description: "Read retained history without selecting it" },
342
357
  args: { agent: positional, id: positional, json: { type: "boolean" } },
343
- async run({ args }) {
344
- const body = await createClient2().get(`${pathFor(args.agent)}/${encodeURIComponent(args.id)}`);
345
- if (args.json) return console.log(JSON.stringify(body, null, 2));
358
+ async run({ args: args2 }) {
359
+ const body = await createClient2().get(`${pathFor(args2.agent)}/${encodeURIComponent(args2.id)}`);
360
+ if (args2.json) return console.log(JSON.stringify(body, null, 2));
346
361
  console.log(body.conversation.title);
347
362
  for (const message of body.messages) console.log(`[${message.role}] ${message.content}`);
348
363
  }
@@ -366,32 +381,32 @@ var newConversation = defineCommand({
366
381
  },
367
382
  json: { type: "boolean" }
368
383
  },
369
- async run({ args }) {
384
+ async run({ args: args2 }) {
370
385
  const client = createClient2();
371
- const state = await client.get(`${pathFor(args.agent)}?limit=1`);
372
- const requestId = args["request-id"] ?? randomUUID();
373
- const revision = args["expected-revision"] === void 0 ? state.selection.revision : Number(args["expected-revision"]);
386
+ const state = await client.get(`${pathFor(args2.agent)}?limit=1`);
387
+ const requestId = args2["request-id"] ?? randomUUID();
388
+ const revision = args2["expected-revision"] === void 0 ? state.selection.revision : Number(args2["expected-revision"]);
374
389
  if (!Number.isSafeInteger(revision) || revision < 0)
375
390
  throw new Error("Invalid expected revision");
376
- if (args["request-id"] && (args["expected-revision"] === void 0 || args["expected-conversation"] === void 0)) {
391
+ if (args2["request-id"] && (args2["expected-revision"] === void 0 || args2["expected-conversation"] === void 0)) {
377
392
  throw new Error(
378
393
  "--request-id requires --expected-revision and --expected-conversation for an exact retry"
379
394
  );
380
395
  }
381
396
  const expectedSelection = {
382
397
  revision,
383
- conversationId: args["expected-conversation"] === void 0 ? state.selection.conversationId : args["expected-conversation"] === "none" ? null : args["expected-conversation"]
398
+ conversationId: args2["expected-conversation"] === void 0 ? state.selection.conversationId : args2["expected-conversation"] === "none" ? null : args2["expected-conversation"]
384
399
  };
385
400
  console.error(
386
401
  `Create request: ${requestId}; retry with --request-id ${requestId} --expected-revision ${revision} --expected-conversation ${expectedSelection.conversationId ?? "none"} and the same title.`
387
402
  );
388
- const body = await client.post(pathFor(args.agent), {
403
+ const body = await client.post(pathFor(args2.agent), {
389
404
  requestId,
390
405
  expectedSelection,
391
- ...args.title ? { title: args.title } : {}
406
+ ...args2.title ? { title: args2.title } : {}
392
407
  });
393
408
  console.log(
394
- args.json ? JSON.stringify(body, null, 2) : `Conversation ${body.conversation.id}: ${body.conversation.title} (active: ${body.selection.conversationId})`
409
+ args2.json ? JSON.stringify(body, null, 2) : `Conversation ${body.conversation.id}: ${body.conversation.title} (active: ${body.selection.conversationId})`
395
410
  );
396
411
  }
397
412
  });
@@ -401,15 +416,15 @@ var rename = defineCommand({
401
416
  description: "Rename a conversation without changing its selection or history"
402
417
  },
403
418
  args: { agent: positional, id: positional, title: positional, json: { type: "boolean" } },
404
- async run({ args }) {
419
+ async run({ args: args2 }) {
405
420
  const client = createClient2();
406
- const path = `${pathFor(args.agent)}/${encodeURIComponent(args.id)}`;
421
+ const path = `${pathFor(args2.agent)}/${encodeURIComponent(args2.id)}`;
407
422
  const current = await client.get(path);
408
423
  const body = await client.patch(path, {
409
- title: args.title,
424
+ title: args2.title,
410
425
  expectedTitleRevision: current.conversation.titleRevision
411
426
  });
412
- console.log(args.json ? JSON.stringify(body, null, 2) : body.conversation.title);
427
+ console.log(args2.json ? JSON.stringify(body, null, 2) : body.conversation.title);
413
428
  }
414
429
  });
415
430
  var conversationCommand = defineCommand({
@@ -439,9 +454,9 @@ var notificationCommand = defineCommand2({
439
454
  description: "Comma-separated Attention kinds; defaults to current selection"
440
455
  }
441
456
  },
442
- async run({ args }) {
457
+ async run({ args: args2 }) {
443
458
  const api = createClient2().notifications;
444
- const kinds = args.kinds ? args.kinds.split(",") : (await api.settings()).settings.kinds;
459
+ const kinds = args2.kinds ? args2.kinds.split(",") : (await api.settings()).settings.kinds;
445
460
  output(await api.preview(kinds));
446
461
  }
447
462
  }),
@@ -464,44 +479,44 @@ var notificationCommand = defineCommand2({
464
479
  },
465
480
  "expected-revision": { type: "string" }
466
481
  },
467
- async run({ args }) {
468
- if (args.enable && args.disable) throw new Error("Choose --enable or --disable");
469
- if (args.enable && !args["destination-id"])
482
+ async run({ args: args2 }) {
483
+ if (args2.enable && args2.disable) throw new Error("Choose --enable or --disable");
484
+ if (args2.enable && !args2["destination-id"])
470
485
  throw new Error("--enable requires --destination-id from notification settings");
471
- if (Boolean(args["quiet-start"]) !== Boolean(args["quiet-end"]))
486
+ if (Boolean(args2["quiet-start"]) !== Boolean(args2["quiet-end"]))
472
487
  throw new Error("Provide both --quiet-start and --quiet-end");
473
- if (args["clear-quiet-hours"] && args["quiet-start"])
488
+ if (args2["clear-quiet-hours"] && args2["quiet-start"])
474
489
  throw new Error("Choose a quiet window or --clear-quiet-hours");
475
490
  const api = createClient2().notifications;
476
491
  const { settings } = await api.settings();
477
492
  output(
478
493
  await api.configure({
479
- expectedRevision: args["expected-revision"] === void 0 ? settings.revision : Number(args["expected-revision"]),
480
- enabled: args.enable ? true : args.disable ? false : settings.enabled,
481
- destinationId: args["destination-id"] ?? settings.destination?.id,
482
- kinds: args.kinds ? args.kinds.split(",") : settings.kinds,
483
- timezone: args.timezone ?? settings.timezone,
484
- quietHours: args["clear-quiet-hours"] ? null : args["quiet-start"] && args["quiet-end"] ? { start: args["quiet-start"], end: args["quiet-end"] } : settings.quietHours,
485
- includeOpenPreview: args["include-open-preview"]
494
+ expectedRevision: args2["expected-revision"] === void 0 ? settings.revision : Number(args2["expected-revision"]),
495
+ enabled: args2.enable ? true : args2.disable ? false : settings.enabled,
496
+ destinationId: args2["destination-id"] ?? settings.destination?.id,
497
+ kinds: args2.kinds ? args2.kinds.split(",") : settings.kinds,
498
+ timezone: args2.timezone ?? settings.timezone,
499
+ quietHours: args2["clear-quiet-hours"] ? null : args2["quiet-start"] && args2["quiet-end"] ? { start: args2["quiet-start"], end: args2["quiet-end"] } : settings.quietHours,
500
+ includeOpenPreview: args2["include-open-preview"]
486
501
  })
487
502
  );
488
503
  }
489
504
  }),
490
505
  list: defineCommand2({
491
506
  args: { cursor: { type: "string" }, limit: { type: "string" } },
492
- async run({ args }) {
507
+ async run({ args: args2 }) {
493
508
  output(
494
509
  await createClient2().notifications.list({
495
- cursor: args.cursor,
496
- limit: args.limit === void 0 ? void 0 : Number(args.limit)
510
+ cursor: args2.cursor,
511
+ limit: args2.limit === void 0 ? void 0 : Number(args2.limit)
497
512
  })
498
513
  );
499
514
  }
500
515
  }),
501
516
  show: defineCommand2({
502
517
  args: { id: positional2 },
503
- async run({ args }) {
504
- output(await createClient2().notifications.get(args.id));
518
+ async run({ args: args2 }) {
519
+ output(await createClient2().notifications.get(args2.id));
505
520
  }
506
521
  }),
507
522
  retry: defineCommand2({
@@ -512,13 +527,13 @@ var notificationCommand = defineCommand2({
512
527
  description: "Telegram may already have received this notice"
513
528
  }
514
529
  },
515
- async run({ args }) {
516
- if (!args["acknowledge-possible-duplicate"])
530
+ async run({ args: args2 }) {
531
+ if (!args2["acknowledge-possible-duplicate"])
517
532
  throw new Error("Explicit retry requires --acknowledge-possible-duplicate");
518
533
  const api = createClient2().notifications;
519
- const receipt = await api.get(args.id);
534
+ const receipt = await api.get(args2.id);
520
535
  output(
521
- await api.retry(args.id, {
536
+ await api.retry(args2.id, {
522
537
  expectedUpdatedAt: receipt.updatedAt,
523
538
  acknowledgePossibleDuplicate: true
524
539
  })
@@ -533,17 +548,17 @@ import { randomUUID as randomUUID2 } from "crypto";
533
548
  import { defineCommand as defineCommand3 } from "citty";
534
549
  var positional3 = { type: "positional", required: true };
535
550
  var output2 = (value) => console.log(JSON.stringify(value, null, 2));
536
- function questionAnswer(args) {
537
- const count = Number(args.choice !== void 0) + Number(args.text !== void 0) + Number(args.skip === true);
551
+ function questionAnswer(args2) {
552
+ const count = Number(args2.choice !== void 0) + Number(args2.text !== void 0) + Number(args2.skip === true);
538
553
  if (count !== 1) throw new Error("Specify exactly one of --choice, --text, or --skip");
539
- if (args.skip) return { kind: "skip" };
540
- if (args.text !== void 0) {
541
- if (!args.text.trim() || Buffer.byteLength(args.text, "utf8") > 4096)
554
+ if (args2.skip) return { kind: "skip" };
555
+ if (args2.text !== void 0) {
556
+ if (!args2.text.trim() || Buffer.byteLength(args2.text, "utf8") > 4096)
542
557
  throw new Error("Answer text must contain 1\u20134096 UTF-8 bytes");
543
- return { kind: "text", text: args.text };
558
+ return { kind: "text", text: args2.text };
544
559
  }
545
- if (!/^[1-4]$/.test(args.choice ?? "")) throw new Error("--choice must be a number from 1 to 4");
546
- return { kind: "choice", index: Number(args.choice) - 1 };
560
+ if (!/^[1-4]$/.test(args2.choice ?? "")) throw new Error("--choice must be a number from 1 to 4");
561
+ return { kind: "choice", index: Number(args2.choice) - 1 };
547
562
  }
548
563
  var questionCommand = defineCommand3({
549
564
  meta: {
@@ -553,14 +568,14 @@ var questionCommand = defineCommand3({
553
568
  subCommands: {
554
569
  list: defineCommand3({
555
570
  args: { agent: positional3, conversation: { type: "string" } },
556
- async run({ args }) {
557
- output2(await createClient2().questions(args.agent).list(args.conversation));
571
+ async run({ args: args2 }) {
572
+ output2(await createClient2().questions(args2.agent).list(args2.conversation));
558
573
  }
559
574
  }),
560
575
  show: defineCommand3({
561
576
  args: { agent: positional3, id: positional3 },
562
- async run({ args }) {
563
- output2(await createClient2().questions(args.agent).get(args.id));
577
+ async run({ args: args2 }) {
578
+ output2(await createClient2().questions(args2.agent).get(args2.id));
564
579
  }
565
580
  }),
566
581
  answer: defineCommand3({
@@ -576,22 +591,22 @@ var questionCommand = defineCommand3({
576
591
  description: "Original conversation ID; required for retries"
577
592
  }
578
593
  },
579
- async run({ args }) {
580
- const answer = questionAnswer(args);
581
- if (args["request-id"] && !args.conversation)
594
+ async run({ args: args2 }) {
595
+ const answer = questionAnswer(args2);
596
+ if (args2["request-id"] && !args2.conversation)
582
597
  throw new Error("Retry requires the original --conversation and identical answer");
583
- const client = createClient2().questions(args.agent);
584
- const observed = await client.get(args.id);
585
- const conversationId = args.conversation ?? observed.conversationId;
598
+ const client = createClient2().questions(args2.agent);
599
+ const observed = await client.get(args2.id);
600
+ const conversationId = args2.conversation ?? observed.conversationId;
586
601
  if (conversationId !== observed.conversationId)
587
602
  throw new Error("Question conversation differs");
588
603
  if (answer.kind === "choice" && answer.index >= observed.question.choices.length)
589
604
  throw new Error("That choice does not exist for this question");
590
- const requestId = args["request-id"] ?? randomUUID2();
605
+ const requestId = args2["request-id"] ?? randomUUID2();
591
606
  console.error(
592
607
  `Question request: ${requestId}; exact retry uses --request-id ${requestId} --conversation ${conversationId} and the same answer. Acceptance does not prove consumption or task completion.`
593
608
  );
594
- output2(await client.answer(args.id, { requestId, conversationId, answer }));
609
+ output2(await client.answer(args2.id, { requestId, conversationId, answer }));
595
610
  }
596
611
  })
597
612
  }
@@ -613,14 +628,14 @@ var expected = {
613
628
  };
614
629
  var list2 = defineCommand4({
615
630
  args: { ...common, all: { type: "boolean" }, offset: { type: "string", default: "0" } },
616
- async run({ args }) {
617
- output3(await createClient2().queue(args.agent).list(args.all, Number(args.offset)));
631
+ async run({ args: args2 }) {
632
+ output3(await createClient2().queue(args2.agent).list(args2.all, Number(args2.offset)));
618
633
  }
619
634
  });
620
635
  var show2 = defineCommand4({
621
636
  args: entry,
622
- async run({ args }) {
623
- output3(await createClient2().queue(args.agent).get(args.id));
637
+ async run({ args: args2 }) {
638
+ output3(await createClient2().queue(args2.agent).get(args2.id));
624
639
  }
625
640
  });
626
641
  var enqueueArgs = {
@@ -640,27 +655,27 @@ var enqueueArgs = {
640
655
  description: "Original selection revision; required for retries"
641
656
  }
642
657
  };
643
- async function submit(args, replacement) {
658
+ async function submit(args2, replacement) {
644
659
  const client = createClient2();
645
- const agentId = String(args.agent);
646
- if (args["request-id"] && (args["expected-conversation"] === void 0 || args["expected-selection-revision"] === void 0))
660
+ const agentId = String(args2.agent);
661
+ if (args2["request-id"] && (args2["expected-conversation"] === void 0 || args2["expected-selection-revision"] === void 0))
647
662
  throw new Error(
648
663
  "Exact retry requires --expected-conversation and --expected-selection-revision"
649
664
  );
650
665
  const observed = await client.get(
651
666
  `/api/agents/${encodeURIComponent(agentId)}/conversations?limit=1`
652
667
  );
653
- const requestId = typeof args["request-id"] === "string" ? args["request-id"] : randomUUID3();
668
+ const requestId = typeof args2["request-id"] === "string" ? args2["request-id"] : randomUUID3();
654
669
  const expectedSelection = {
655
- conversationId: args["expected-conversation"] === void 0 ? observed.selection.conversationId : args["expected-conversation"] === "none" ? null : String(args["expected-conversation"]),
656
- revision: args["expected-selection-revision"] === void 0 ? observed.selection.revision : Number(args["expected-selection-revision"])
670
+ conversationId: args2["expected-conversation"] === void 0 ? observed.selection.conversationId : args2["expected-conversation"] === "none" ? null : String(args2["expected-conversation"]),
671
+ revision: args2["expected-selection-revision"] === void 0 ? observed.selection.revision : Number(args2["expected-selection-revision"])
657
672
  };
658
- const paths = args.files ? JSON.parse(String(args.files)) : [];
673
+ const paths = args2.files ? JSON.parse(String(args2.files)) : [];
659
674
  if (!Array.isArray(paths) || paths.length > 16 || paths.some((p) => typeof p !== "string"))
660
675
  throw new Error("--files must be a JSON array of at most 16 paths");
661
676
  let bytes = 0;
662
- const original = replacement && (args.files === void 0 || args.message === void 0) ? await client.queue(agentId).input(replacement.id) : void 0;
663
- const attachments = args.files === void 0 && original ? original.attachments : paths.map((path) => {
677
+ const original = replacement && (args2.files === void 0 || args2.message === void 0) ? await client.queue(agentId).input(replacement.id) : void 0;
678
+ const attachments = args2.files === void 0 && original ? original.attachments : paths.map((path) => {
664
679
  const stat = statSync(path);
665
680
  bytes += stat.size;
666
681
  if (!stat.isFile() || bytes > 25 * 1024 * 1024)
@@ -686,7 +701,7 @@ async function submit(args, replacement) {
686
701
  const input = {
687
702
  requestId,
688
703
  expectedSelection,
689
- message: String(args.message ?? original?.message ?? ""),
704
+ message: String(args2.message ?? original?.message ?? ""),
690
705
  attachments
691
706
  };
692
707
  output3(
@@ -695,36 +710,36 @@ async function submit(args, replacement) {
695
710
  }
696
711
  var add = defineCommand4({
697
712
  args: enqueueArgs,
698
- async run({ args }) {
699
- await submit(args);
713
+ async run({ args: args2 }) {
714
+ await submit(args2);
700
715
  }
701
716
  });
702
717
  var edit = defineCommand4({
703
718
  args: { ...enqueueArgs, id: positional4, "expected-revision": expected },
704
- async run({ args }) {
705
- await submit(args, { id: args.id, expectedRevision: Number(args["expected-revision"]) });
719
+ async run({ args: args2 }) {
720
+ await submit(args2, { id: args2.id, expectedRevision: Number(args2["expected-revision"]) });
706
721
  }
707
722
  });
708
723
  var remove = defineCommand4({
709
724
  args: { ...entry, "expected-revision": expected },
710
- async run({ args }) {
725
+ async run({ args: args2 }) {
711
726
  output3(
712
- await createClient2().queue(args.agent).remove(args.id, Number(args["expected-revision"]))
727
+ await createClient2().queue(args2.agent).remove(args2.id, Number(args2["expected-revision"]))
713
728
  );
714
729
  }
715
730
  });
716
731
  var control = (paused) => defineCommand4({
717
732
  args: { ...common, "expected-revision": expected },
718
- async run({ args }) {
733
+ async run({ args: args2 }) {
719
734
  output3(
720
- await createClient2().queue(args.agent).pause(paused, Number(args["expected-revision"]))
735
+ await createClient2().queue(args2.agent).pause(paused, Number(args2["expected-revision"]))
721
736
  );
722
737
  }
723
738
  });
724
739
  var stop = defineCommand4({
725
740
  args: { ...common, "expected-revision": expected },
726
- async run({ args }) {
727
- output3(await createClient2().queue(args.agent).stop(Number(args["expected-revision"])));
741
+ async run({ args: args2 }) {
742
+ output3(await createClient2().queue(args2.agent).stop(Number(args2["expected-revision"])));
728
743
  }
729
744
  });
730
745
  var reconcile = defineCommand4({
@@ -736,11 +751,11 @@ var reconcile = defineCommand4({
736
751
  description: "Acknowledge this input may already have acted; close without replay"
737
752
  }
738
753
  },
739
- async run({ args }) {
740
- if (!args.acknowledge)
754
+ async run({ args: args2 }) {
755
+ if (!args2.acknowledge)
741
756
  throw new Error("--acknowledge is required; this input may already have acted");
742
757
  output3(
743
- await createClient2().queue(args.agent).reconcile(args.id, Number(args["expected-revision"]))
758
+ await createClient2().queue(args2.agent).reconcile(args2.id, Number(args2["expected-revision"]))
744
759
  );
745
760
  }
746
761
  });
@@ -870,17 +885,17 @@ var spawnCmd = defineCommand5({
870
885
  description: "Reasoning level: off|minimal|low|medium|high|xhigh (default: medium)"
871
886
  }
872
887
  },
873
- async run({ args }) {
888
+ async run({ args: args2 }) {
874
889
  const client = createClient2();
875
- const teamId = args.team ?? "default";
890
+ const teamId = args2.team ?? "default";
876
891
  const policy = await client.get(
877
892
  `/api/teams/${encodeURIComponent(teamId)}/policy`
878
893
  );
879
894
  const body = {
880
- profileId: args.profile,
881
- name: args.name,
882
- model: args.model,
883
- reasoningLevel: args.reasoning,
895
+ profileId: args2.profile,
896
+ name: args2.name,
897
+ model: args2.model,
898
+ reasoningLevel: args2.reasoning,
884
899
  teamId,
885
900
  teamExpectedRevision: policy.teamPolicy.revision,
886
901
  placement: "profile_defaults"
@@ -913,8 +928,8 @@ var editCmd = defineCommand5({
913
928
  description: 'Telegram topic emoji (e.g. \u{1F4DA}). Use --topic-icon "" to clear.'
914
929
  }
915
930
  },
916
- async run({ args }) {
917
- if (args.name === void 0 && args.model === void 0 && args.reasoning === void 0 && args.mirror === void 0 && args["topic-icon"] === void 0) {
931
+ async run({ args: args2 }) {
932
+ if (args2.name === void 0 && args2.model === void 0 && args2.reasoning === void 0 && args2.mirror === void 0 && args2["topic-icon"] === void 0) {
918
933
  console.error(
919
934
  "agent edit: specify at least one of --name, --model, --reasoning, --mirror, --topic-icon"
920
935
  );
@@ -922,22 +937,22 @@ var editCmd = defineCommand5({
922
937
  }
923
938
  const client = createClient2();
924
939
  const body = {};
925
- if (args.name !== void 0) body.name = args.name;
926
- if (args.model !== void 0) {
927
- body.modelOverride = args.model === "" ? null : args.model;
940
+ if (args2.name !== void 0) body.name = args2.name;
941
+ if (args2.model !== void 0) {
942
+ body.modelOverride = args2.model === "" ? null : args2.model;
928
943
  }
929
- if (args.reasoning !== void 0) body.reasoningLevel = args.reasoning;
930
- if (args.mirror !== void 0) {
931
- if (args.mirror !== "minimal" && args.mirror !== "verbose") {
944
+ if (args2.reasoning !== void 0) body.reasoningLevel = args2.reasoning;
945
+ if (args2.mirror !== void 0) {
946
+ if (args2.mirror !== "minimal" && args2.mirror !== "verbose") {
932
947
  console.error(`agent edit: --mirror must be 'minimal' or 'verbose'`);
933
948
  process.exit(2);
934
949
  }
935
- body.telegramMirrorMode = args.mirror;
950
+ body.telegramMirrorMode = args2.mirror;
936
951
  }
937
- if (args["topic-icon"] !== void 0) {
938
- body.telegramIconEmoji = args["topic-icon"] === "" ? null : args["topic-icon"];
952
+ if (args2["topic-icon"] !== void 0) {
953
+ body.telegramIconEmoji = args2["topic-icon"] === "" ? null : args2["topic-icon"];
939
954
  }
940
- const agent = await client.patch(`/api/agents/${args.id}`, body);
955
+ const agent = await client.patch(`/api/agents/${args2.id}`, body);
941
956
  console.log(`updated agent ${agent.id} (${agent.name})`);
942
957
  }
943
958
  });
@@ -947,16 +962,16 @@ var listCmd = defineCommand5({
947
962
  all: { type: "boolean", description: "Include archived agents" },
948
963
  long: { type: "boolean", alias: "l", description: "Show profile + full UUID columns" }
949
964
  },
950
- async run({ args }) {
965
+ async run({ args: args2 }) {
951
966
  const client = createClient2();
952
- const q = args.all ? "?includeArchived=true" : "";
967
+ const q = args2.all ? "?includeArchived=true" : "";
953
968
  const list8 = await client.get(`/api/agents${q}`);
954
969
  if (list8.length === 0) {
955
970
  console.log("(no agents)");
956
971
  return;
957
972
  }
958
973
  const rows = list8.map(
959
- (a) => args.long ? [a.id, a.status, a.name, a.profileId] : (
974
+ (a) => args2.long ? [a.id, a.status, a.name, a.profileId] : (
960
975
  // Short UUID prefix — all CLI commands accept 4+ char prefixes now.
961
976
  [a.id.slice(0, 8), a.status, a.name]
962
977
  )
@@ -969,9 +984,9 @@ var showCmd = defineCommand5({
969
984
  args: {
970
985
  id: { type: "positional", required: true }
971
986
  },
972
- async run({ args }) {
987
+ async run({ args: args2 }) {
973
988
  const client = createClient2();
974
- const r = await client.get(`/api/agents/${args.id}`);
989
+ const r = await client.get(`/api/agents/${args2.id}`);
975
990
  console.log(`# ${r.agent.id}`);
976
991
  console.log(`name: ${r.agent.name}`);
977
992
  console.log(`status: ${r.agent.status}`);
@@ -992,10 +1007,10 @@ var archiveCmd = defineCommand5({
992
1007
  args: {
993
1008
  id: { type: "positional", required: true }
994
1009
  },
995
- async run({ args }) {
1010
+ async run({ args: args2 }) {
996
1011
  const client = createClient2();
997
- await client.post(`/api/agents/${args.id}/archive`);
998
- console.log(`archived agent ${args.id}`);
1012
+ await client.post(`/api/agents/${args2.id}/archive`);
1013
+ console.log(`archived agent ${args2.id}`);
999
1014
  }
1000
1015
  });
1001
1016
  var unarchiveCmd = defineCommand5({
@@ -1003,10 +1018,10 @@ var unarchiveCmd = defineCommand5({
1003
1018
  args: {
1004
1019
  id: { type: "positional", required: true }
1005
1020
  },
1006
- async run({ args }) {
1021
+ async run({ args: args2 }) {
1007
1022
  const client = createClient2();
1008
- await client.post(`/api/agents/${args.id}/unarchive`);
1009
- console.log(`unarchived agent ${args.id}`);
1023
+ await client.post(`/api/agents/${args2.id}/unarchive`);
1024
+ console.log(`unarchived agent ${args2.id}`);
1010
1025
  }
1011
1026
  });
1012
1027
  var deleteCmd = defineCommand5({
@@ -1014,16 +1029,16 @@ var deleteCmd = defineCommand5({
1014
1029
  args: {
1015
1030
  id: { type: "positional", required: true }
1016
1031
  },
1017
- async run({ args }) {
1032
+ async run({ args: args2 }) {
1018
1033
  const client = createClient2();
1019
- const agent = await client.get(`/api/agents/${encodeURIComponent(args.id)}`);
1034
+ const agent = await client.get(`/api/agents/${encodeURIComponent(args2.id)}`);
1020
1035
  const policy = await client.get(
1021
1036
  `/api/teams/${encodeURIComponent(agent.team.id)}/policy`
1022
1037
  );
1023
1038
  await client.del(
1024
- `/api/agents/${encodeURIComponent(args.id)}?expectedTeamRevision=${policy.teamPolicy.revision}`
1039
+ `/api/agents/${encodeURIComponent(args2.id)}?expectedTeamRevision=${policy.teamPolicy.revision}`
1025
1040
  );
1026
- console.log(`deleted agent ${args.id}`);
1041
+ console.log(`deleted agent ${args2.id}`);
1027
1042
  }
1028
1043
  });
1029
1044
  function bashApprovalModeForTty(inputIsTty, outputIsTty) {
@@ -1216,18 +1231,18 @@ var chatCmd = defineCommand5({
1216
1231
  description: "Attach any file \u2014 the agent gets a path reference (repeatable). One-shot mode."
1217
1232
  }
1218
1233
  },
1219
- async run({ args }) {
1234
+ async run({ args: args2 }) {
1220
1235
  const client = createClient2();
1221
- const resolved = await client.get(`/api/agents/${args.id}`);
1236
+ const resolved = await client.get(`/api/agents/${args2.id}`);
1222
1237
  const bashApprovalMode = bashApprovalModeForTty(stdin.isTTY, stdout.isTTY);
1223
1238
  const attachments = [
1224
- ...loadImages(asPaths(args.image)),
1225
- ...loadFiles(asPaths(args.file))
1239
+ ...loadImages(asPaths(args2.image)),
1240
+ ...loadFiles(asPaths(args2.file))
1226
1241
  ];
1227
- if (args.message || attachments.length > 0) {
1242
+ if (args2.message || attachments.length > 0) {
1228
1243
  const rl2 = bashApprovalMode === "interactive" ? createInterface({ input: stdin, output: stdout }) : null;
1229
1244
  try {
1230
- await streamTurn(client, resolved.agent.id, args.message ?? "", attachments, {
1245
+ await streamTurn(client, resolved.agent.id, args2.message ?? "", attachments, {
1231
1246
  bashApprovalMode,
1232
1247
  ...rl2 ? {
1233
1248
  approvalPrompt: {
@@ -1323,16 +1338,16 @@ var chatTrimCmd = defineCommand5({
1323
1338
  id: { type: "positional", required: true },
1324
1339
  keep: { type: "string", required: true, description: "Number of leading messages to keep" }
1325
1340
  },
1326
- async run({ args }) {
1327
- const n = Number(args.keep);
1341
+ async run({ args: args2 }) {
1342
+ const n = Number(args2.keep);
1328
1343
  if (!Number.isFinite(n) || n < 0 || !Number.isInteger(n)) {
1329
1344
  throw new Error("--keep must be a non-negative integer");
1330
1345
  }
1331
1346
  const client = createClient2();
1332
- const head = await client.get(`/api/agents/${args.id}/sessions/head`);
1347
+ const head = await client.get(`/api/agents/${args2.id}/sessions/head`);
1333
1348
  const body = { keepCount: n, expectedSelection: head.selection };
1334
1349
  const res = await client.post(
1335
- `/api/agents/${args.id}/chat/truncate`,
1350
+ `/api/agents/${args2.id}/chat/truncate`,
1336
1351
  body
1337
1352
  );
1338
1353
  console.log(
@@ -1358,11 +1373,11 @@ var chatContextCmd = defineCommand5({
1358
1373
  },
1359
1374
  json: { type: "boolean", description: "Emit raw JSON instead of a human report" }
1360
1375
  },
1361
- async run({ args }) {
1376
+ async run({ args: args2 }) {
1362
1377
  const client = createClient2();
1363
- const query = args.detail || args.json ? "?detail=1" : "";
1364
- const ctx = await client.get(`/api/agents/${args.id}/chat/context${query}`);
1365
- if (args.json) {
1378
+ const query = args2.detail || args2.json ? "?detail=1" : "";
1379
+ const ctx = await client.get(`/api/agents/${args2.id}/chat/context${query}`);
1380
+ if (args2.json) {
1366
1381
  console.log(JSON.stringify(ctx, null, 2));
1367
1382
  return;
1368
1383
  }
@@ -1446,20 +1461,20 @@ var chatCompactCmd = defineCommand5({
1446
1461
  },
1447
1462
  force: { type: "boolean", description: "Skip the y/N prompt" }
1448
1463
  },
1449
- async run({ args }) {
1450
- if (!args.force) {
1464
+ async run({ args: args2 }) {
1465
+ if (!args2.force) {
1451
1466
  process.stdout.write(
1452
- `compact chat history for ${args.id}? head turns become a summary; tail is preserved. [y/N] `
1467
+ `compact chat history for ${args2.id}? head turns become a summary; tail is preserved. [y/N] `
1453
1468
  );
1454
- const answer = await new Promise((resolve5) => {
1455
- process.stdin.once("data", (d) => resolve5(String(d).trim().toLowerCase()));
1469
+ const answer = await new Promise((resolve6) => {
1470
+ process.stdin.once("data", (d) => resolve6(String(d).trim().toLowerCase()));
1456
1471
  });
1457
1472
  if (answer !== "y" && answer !== "yes") {
1458
1473
  console.log("aborted");
1459
1474
  return;
1460
1475
  }
1461
1476
  }
1462
- const keepTailNum = args["keep-tail"] ? Number(args["keep-tail"]) : void 0;
1477
+ const keepTailNum = args2["keep-tail"] ? Number(args2["keep-tail"]) : void 0;
1463
1478
  if (keepTailNum !== void 0 && (!Number.isFinite(keepTailNum) || keepTailNum < 0)) {
1464
1479
  console.error("--keep-tail must be a non-negative integer");
1465
1480
  process.exitCode = 1;
@@ -1467,11 +1482,11 @@ var chatCompactCmd = defineCommand5({
1467
1482
  }
1468
1483
  const body = {};
1469
1484
  if (keepTailNum !== void 0) body.keepTail = Math.floor(keepTailNum);
1470
- if (args.instructions) body.customInstructions = args.instructions;
1485
+ if (args2.instructions) body.customInstructions = args2.instructions;
1471
1486
  const client = createClient2();
1472
- const head = await client.get(`/api/agents/${args.id}/sessions/head`);
1487
+ const head = await client.get(`/api/agents/${args2.id}/sessions/head`);
1473
1488
  body.expectedSelection = head.selection;
1474
- const res = await client.post(`/api/agents/${args.id}/chat/compact`, body);
1489
+ const res = await client.post(`/api/agents/${args2.id}/chat/compact`, body);
1475
1490
  console.log(
1476
1491
  `compacted: ${res.before} \u2192 ${res.after} entries (${res.summarized} summarized, ${res.keptTail} tail kept verbatim)`
1477
1492
  );
@@ -1493,11 +1508,11 @@ var skillAddCmd = defineCommand5({
1493
1508
  description: "Attach even when the static skill scan reports findings"
1494
1509
  }
1495
1510
  },
1496
- async run({ args }) {
1511
+ async run({ args: args2 }) {
1497
1512
  const client = createClient2();
1498
- const body = { skill: args.skill, allowFindings: args["allow-warnings"] };
1513
+ const body = { skill: args2.skill, allowFindings: args2["allow-warnings"] };
1499
1514
  try {
1500
- await client.post(`/api/agents/${args.agent}/skills`, body);
1515
+ await client.post(`/api/agents/${args2.agent}/skills`, body);
1501
1516
  } catch (err) {
1502
1517
  if (err instanceof ApiClientError && err.body.code === "skill_scan_blocked") {
1503
1518
  console.error(`error: ${err.body.error}`);
@@ -1508,7 +1523,7 @@ var skillAddCmd = defineCommand5({
1508
1523
  }
1509
1524
  throw err;
1510
1525
  }
1511
- console.log(`attached skill ${args.skill} to ${args.agent}`);
1526
+ console.log(`attached skill ${args2.skill} to ${args2.agent}`);
1512
1527
  }
1513
1528
  });
1514
1529
  function printSkillFindings(findings) {
@@ -1525,10 +1540,10 @@ var skillRmCmd = defineCommand5({
1525
1540
  agent: { type: "positional", required: true },
1526
1541
  skill: { type: "positional", required: true }
1527
1542
  },
1528
- async run({ args }) {
1543
+ async run({ args: args2 }) {
1529
1544
  const client = createClient2();
1530
- await client.del(`/api/agents/${args.agent}/skills/${encodeURIComponent(args.skill)}`);
1531
- console.log(`detached skill ${args.skill} from ${args.agent}`);
1545
+ await client.del(`/api/agents/${args2.agent}/skills/${encodeURIComponent(args2.skill)}`);
1546
+ console.log(`detached skill ${args2.skill} from ${args2.agent}`);
1532
1547
  }
1533
1548
  });
1534
1549
  var skillCmd = defineCommand5({
@@ -1544,23 +1559,23 @@ var moveCmd = defineCommand5({
1544
1559
  agent: { type: "positional", required: true },
1545
1560
  team: { type: "positional", required: true }
1546
1561
  },
1547
- async run({ args }) {
1562
+ async run({ args: args2 }) {
1548
1563
  const client = createClient2();
1549
1564
  const [agent, destination] = await Promise.all([
1550
- client.get(`/api/agents/${encodeURIComponent(args.agent)}`),
1551
- client.get(`/api/teams/${encodeURIComponent(args.team)}/policy`)
1565
+ client.get(`/api/agents/${encodeURIComponent(args2.agent)}`),
1566
+ client.get(`/api/teams/${encodeURIComponent(args2.team)}/policy`)
1552
1567
  ]);
1553
1568
  const source = await client.get(
1554
1569
  `/api/teams/${encodeURIComponent(agent.team.id)}/policy`
1555
1570
  );
1556
1571
  const body = {
1557
- teamId: args.team,
1572
+ teamId: args2.team,
1558
1573
  sourceExpectedRevision: source.teamPolicy.revision,
1559
1574
  destinationExpectedRevision: destination.teamPolicy.revision,
1560
1575
  placement: "profile_defaults"
1561
1576
  };
1562
- await client.patch(`/api/agents/${args.agent}/team`, body);
1563
- console.log(`moved ${args.agent} to team ${args.team}`);
1577
+ await client.patch(`/api/agents/${args2.agent}/team`, body);
1578
+ console.log(`moved ${args2.agent} to team ${args2.team}`);
1564
1579
  }
1565
1580
  });
1566
1581
  var sessionHeadCmd = defineCommand5({
@@ -1572,10 +1587,10 @@ var sessionHeadCmd = defineCommand5({
1572
1587
  id: { type: "positional", required: true },
1573
1588
  json: { type: "boolean", description: "Emit raw JSON instead of a human line" }
1574
1589
  },
1575
- async run({ args }) {
1590
+ async run({ args: args2 }) {
1576
1591
  const client = createClient2();
1577
- const head = await client.get(`/api/agents/${args.id}/sessions/head`);
1578
- if (args.json) {
1592
+ const head = await client.get(`/api/agents/${args2.id}/sessions/head`);
1593
+ if (args2.json) {
1579
1594
  console.log(JSON.stringify(head));
1580
1595
  return;
1581
1596
  }
@@ -1587,10 +1602,10 @@ var cancelCmd = defineCommand5({
1587
1602
  args: {
1588
1603
  id: { type: "positional", required: true }
1589
1604
  },
1590
- async run({ args }) {
1605
+ async run({ args: args2 }) {
1591
1606
  const client = createClient2();
1592
- await client.post(`/api/agents/${args.id}/cancel`);
1593
- console.log(`cancelled active turn for ${args.id}`);
1607
+ await client.post(`/api/agents/${args2.id}/cancel`);
1608
+ console.log(`cancelled active turn for ${args2.id}`);
1594
1609
  }
1595
1610
  });
1596
1611
  var reviewConfigCmd = defineCommand5({
@@ -1603,24 +1618,24 @@ var reviewConfigCmd = defineCommand5({
1603
1618
  model: { type: "string", description: "Review model, or 'agent' to use the Agent model" },
1604
1619
  reasoning: { type: "string", description: "Review reasoning level" }
1605
1620
  },
1606
- async run({ args }) {
1607
- if (args.enable && args.disable) throw new Error("choose either --enable or --disable");
1621
+ async run({ args: args2 }) {
1622
+ if (args2.enable && args2.disable) throw new Error("choose either --enable or --disable");
1608
1623
  const client = createClient2();
1609
1624
  const body = {};
1610
- if (args.enable || args.disable) body.enabled = Boolean(args.enable);
1611
- if (args.every !== void 0) {
1612
- const value = Number(args.every);
1625
+ if (args2.enable || args2.disable) body.enabled = Boolean(args2.enable);
1626
+ if (args2.every !== void 0) {
1627
+ const value = Number(args2.every);
1613
1628
  if (!Number.isInteger(value) || value < 1 || value > 100) {
1614
1629
  throw new Error("--every must be an integer from 1 to 100");
1615
1630
  }
1616
1631
  body.everyNTurns = value;
1617
1632
  }
1618
- if (args.model !== void 0) body.model = args.model === "agent" ? null : args.model;
1619
- if (args.reasoning !== void 0) {
1620
- body.reasoningLevel = args.reasoning;
1633
+ if (args2.model !== void 0) body.model = args2.model === "agent" ? null : args2.model;
1634
+ if (args2.reasoning !== void 0) {
1635
+ body.reasoningLevel = args2.reasoning;
1621
1636
  }
1622
1637
  const hasChanges = Object.keys(body).length > 0;
1623
- const config = hasChanges ? await client.patch(`/api/agents/${args.id}/review-config`, body) : await client.get(`/api/agents/${args.id}/review-config`);
1638
+ const config = hasChanges ? await client.patch(`/api/agents/${args2.id}/review-config`, body) : await client.get(`/api/agents/${args2.id}/review-config`);
1624
1639
  console.log(`review: ${config.enabled ? "enabled" : "disabled"}`);
1625
1640
  console.log(`cadence: every ${config.everyNTurns} successful user turns`);
1626
1641
  console.log(`model: ${config.model ?? "agent model"}`);
@@ -1631,9 +1646,9 @@ var reviewConfigCmd = defineCommand5({
1631
1646
  var reviewCmd = defineCommand5({
1632
1647
  meta: { name: "review", description: "Enqueue a reviewed-learning pass" },
1633
1648
  args: { id: { type: "positional", required: true, description: "Agent id or prefix" } },
1634
- async run({ args }) {
1649
+ async run({ args: args2 }) {
1635
1650
  const response = await createClient2().post(
1636
- `/api/agents/${args.id}/reviews`
1651
+ `/api/agents/${args2.id}/reviews`
1637
1652
  );
1638
1653
  console.log(`review ${response.review.id} ${response.review.status}`);
1639
1654
  }
@@ -1644,11 +1659,11 @@ var reviewsCmd = defineCommand5({
1644
1659
  id: { type: "positional", required: true, description: "Agent id or prefix" },
1645
1660
  status: { type: "string", description: "pending|running|retrying|completed|failed|cancelled" }
1646
1661
  },
1647
- async run({ args }) {
1662
+ async run({ args: args2 }) {
1648
1663
  const response = await createClient2().get(
1649
- `/api/agents/${args.id}/reviews`
1664
+ `/api/agents/${args2.id}/reviews`
1650
1665
  );
1651
- const reviews = args.status ? response.reviews.filter((review) => review.status === args.status) : response.reviews;
1666
+ const reviews = args2.status ? response.reviews.filter((review) => review.status === args2.status) : response.reviews;
1652
1667
  if (reviews.length === 0) return console.log("(no reviews)");
1653
1668
  for (const line of columnize(
1654
1669
  reviews.map((review) => [
@@ -1669,11 +1684,11 @@ var lessonsCmd = defineCommand5({
1669
1684
  id: { type: "positional", required: true, description: "Agent id or prefix" },
1670
1685
  status: { type: "string", description: "pending|approved|rejected|revoked" }
1671
1686
  },
1672
- async run({ args }) {
1673
- const status = args.status;
1687
+ async run({ args: args2 }) {
1688
+ const status = args2.status;
1674
1689
  const query = status ? `?status=${encodeURIComponent(status)}` : "";
1675
1690
  const response = await createClient2().get(
1676
- `/api/agents/${args.id}/lesson-proposals${query}`
1691
+ `/api/agents/${args2.id}/lesson-proposals${query}`
1677
1692
  );
1678
1693
  if (response.proposals.length === 0) return console.log("(no lesson proposals)");
1679
1694
  for (const line of columnize(
@@ -1707,9 +1722,9 @@ function lessonDecisionCmd(decision2) {
1707
1722
  id: { type: "positional", required: true, description: "Proposal id or prefix" },
1708
1723
  yes: { type: "boolean", description: `Confirm ${decision2}` }
1709
1724
  },
1710
- async run({ args }) {
1711
- if (!args.yes) throw new Error(`${decision2} requires --yes`);
1712
- const { agent, proposal } = await locateProposal(args.id);
1725
+ async run({ args: args2 }) {
1726
+ if (!args2.yes) throw new Error(`${decision2} requires --yes`);
1727
+ const { agent, proposal } = await locateProposal(args2.id);
1713
1728
  const response = await createClient2().post(
1714
1729
  `/api/agents/${agent.id}/lesson-proposals/${proposal.id}/${decision2}`,
1715
1730
  { version: proposal.version }
@@ -1725,14 +1740,14 @@ var lessonEditCmd = defineCommand5({
1725
1740
  text: { type: "string", description: "Replacement lesson text" },
1726
1741
  scope: { type: "string", description: "private|shared" }
1727
1742
  },
1728
- async run({ args }) {
1729
- if (args.text === void 0 && args.scope === void 0) {
1743
+ async run({ args: args2 }) {
1744
+ if (args2.text === void 0 && args2.scope === void 0) {
1730
1745
  throw new Error("lesson edit requires --text or --scope");
1731
1746
  }
1732
- const { agent, proposal } = await locateProposal(args.id);
1747
+ const { agent, proposal } = await locateProposal(args2.id);
1733
1748
  const response = await createClient2().patch(
1734
1749
  `/api/agents/${agent.id}/lesson-proposals/${proposal.id}`,
1735
- { version: proposal.version, text: args.text, scope: args.scope }
1750
+ { version: proposal.version, text: args2.text, scope: args2.scope }
1736
1751
  );
1737
1752
  console.log(`updated ${response.proposal.id} v${response.proposal.version}`);
1738
1753
  }
@@ -1781,13 +1796,13 @@ var list3 = defineCommand6({
1781
1796
  team: { type: "string" },
1782
1797
  json: { type: "boolean" }
1783
1798
  },
1784
- async run({ args }) {
1785
- const query = new URLSearchParams({ status: args.status, limit: "100" });
1786
- if (args.team) query.set("teamId", args.team);
1799
+ async run({ args: args2 }) {
1800
+ const query = new URLSearchParams({ status: args2.status, limit: "100" });
1801
+ if (args2.team) query.set("teamId", args2.team);
1787
1802
  const body = await createClient2().get(
1788
1803
  `/api/approvals?${query}`
1789
1804
  );
1790
- if (args.json) return console.log(JSON.stringify(body, null, 2));
1805
+ if (args2.json) return console.log(JSON.stringify(body, null, 2));
1791
1806
  if (!body.approvals.length) return console.log("(no approvals)");
1792
1807
  for (const line of columnize([
1793
1808
  ["id", "status", "path", "origin", "expires"],
@@ -1805,11 +1820,11 @@ var list3 = defineCommand6({
1805
1820
  var show3 = defineCommand6({
1806
1821
  meta: { name: "show", description: "Show one approval including payload and audit events" },
1807
1822
  args: { id: { type: "positional", required: true }, json: { type: "boolean" } },
1808
- async run({ args }) {
1823
+ async run({ args: args2 }) {
1809
1824
  const item = await createClient2().get(
1810
- `/api/approvals/${encodeURIComponent(args.id)}`
1825
+ `/api/approvals/${encodeURIComponent(args2.id)}`
1811
1826
  );
1812
- if (args.json) return console.log(JSON.stringify(item, null, 2));
1827
+ if (args2.json) return console.log(JSON.stringify(item, null, 2));
1813
1828
  console.log(`# ${item.id}`);
1814
1829
  console.log(`status: ${item.status}`);
1815
1830
  console.log(`attempt: ${item.attemptKind}:${item.attemptId}`);
@@ -1834,13 +1849,13 @@ function decision(name) {
1834
1849
  yes: { type: "boolean", description: "Required explicit non-interactive confirmation" },
1835
1850
  json: { type: "boolean" }
1836
1851
  },
1837
- async run({ args }) {
1838
- if (!args.yes) throw new Error(`refusing ${name}: review with approval show, then pass --yes`);
1852
+ async run({ args: args2 }) {
1853
+ if (!args2.yes) throw new Error(`refusing ${name}: review with approval show, then pass --yes`);
1839
1854
  const item = await createClient2().post(
1840
- `/api/approvals/${encodeURIComponent(args.id)}/${name}`,
1841
- args.reason ? { reason: args.reason } : {}
1855
+ `/api/approvals/${encodeURIComponent(args2.id)}/${name}`,
1856
+ args2.reason ? { reason: args2.reason } : {}
1842
1857
  );
1843
- if (args.json) console.log(JSON.stringify(item, null, 2));
1858
+ if (args2.json) console.log(JSON.stringify(item, null, 2));
1844
1859
  else console.log(`${item.id}: ${item.status}`);
1845
1860
  }
1846
1861
  });
@@ -1868,11 +1883,11 @@ var list4 = defineCommand7({
1868
1883
  kind: { type: "string" },
1869
1884
  json: { type: "boolean" }
1870
1885
  },
1871
- async run({ args }) {
1872
- const query = new URLSearchParams({ state: args.state, limit: "200" });
1873
- if (args.kind) query.set("kind", args.kind);
1886
+ async run({ args: args2 }) {
1887
+ const query = new URLSearchParams({ state: args2.state, limit: "200" });
1888
+ if (args2.kind) query.set("kind", args2.kind);
1874
1889
  const body = await createClient2().get(`/api/attention?${query}`);
1875
- if (args.json) return console.log(JSON.stringify(body, null, 2));
1890
+ if (args2.json) return console.log(JSON.stringify(body, null, 2));
1876
1891
  if (!body.items.length) console.log("(nothing needs attention)");
1877
1892
  else
1878
1893
  for (const line of columnize([
@@ -1893,9 +1908,9 @@ var list4 = defineCommand7({
1893
1908
  var summary = defineCommand7({
1894
1909
  meta: { name: "summary", description: "Summarize open attention items" },
1895
1910
  args: { json: { type: "boolean" } },
1896
- async run({ args }) {
1911
+ async run({ args: args2 }) {
1897
1912
  const body = await createClient2().get("/api/attention/summary");
1898
- if (args.json) console.log(JSON.stringify(body, null, 2));
1913
+ if (args2.json) console.log(JSON.stringify(body, null, 2));
1899
1914
  else
1900
1915
  console.log(
1901
1916
  `${body.openTotal} open \xB7 ${body.bySeverity.action_required} action required \xB7 ${body.bySeverity.error} errors \xB7 ${body.bySeverity.warning} warnings`
@@ -1910,11 +1925,11 @@ function mutation(name) {
1910
1925
  yes: { type: "boolean", description: "Required confirmation" },
1911
1926
  json: { type: "boolean" }
1912
1927
  },
1913
- async run({ args }) {
1914
- if (!args.yes) throw new Error(`refusing mutation: pass --yes to ${name}`);
1915
- const path = `/api/attention/${encodeURIComponent(args.key)}/${name === "acknowledge" ? "acknowledge" : "acknowledgement"}`;
1928
+ async run({ args: args2 }) {
1929
+ if (!args2.yes) throw new Error(`refusing mutation: pass --yes to ${name}`);
1930
+ const path = `/api/attention/${encodeURIComponent(args2.key)}/${name === "acknowledge" ? "acknowledge" : "acknowledgement"}`;
1916
1931
  const body = name === "acknowledge" ? await createClient2().post(path) : await createClient2().del(path);
1917
- if (args.json) console.log(JSON.stringify(body, null, 2));
1932
+ if (args2.json) console.log(JSON.stringify(body, null, 2));
1918
1933
  else console.log(`${body.item.key}: ${body.item.acknowledgedAt ? "acknowledged" : "open"}`);
1919
1934
  }
1920
1935
  });
@@ -1922,12 +1937,12 @@ function mutation(name) {
1922
1937
  var acknowledgeAll = defineCommand7({
1923
1938
  meta: { name: "acknowledge-all", description: "Acknowledge all open informational items" },
1924
1939
  args: { yes: { type: "boolean" }, json: { type: "boolean" } },
1925
- async run({ args }) {
1926
- if (!args.yes) throw new Error("refusing mutation: pass --yes to acknowledge-all");
1940
+ async run({ args: args2 }) {
1941
+ if (!args2.yes) throw new Error("refusing mutation: pass --yes to acknowledge-all");
1927
1942
  const body = await createClient2().post(
1928
1943
  "/api/attention/acknowledge-all"
1929
1944
  );
1930
- if (args.json) console.log(JSON.stringify(body, null, 2));
1945
+ if (args2.json) console.log(JSON.stringify(body, null, 2));
1931
1946
  else console.log(`acknowledged ${body.acknowledged} informational item(s)`);
1932
1947
  }
1933
1948
  });
@@ -1979,7 +1994,7 @@ function answerCliOpenAIPrompt(prompt, input = process.stdin, output4 = process.
1979
1994
  );
1980
1995
  }
1981
1996
  output4.write(`${prompt.message}: `);
1982
- return new Promise((resolve5, reject) => {
1997
+ return new Promise((resolve6, reject) => {
1983
1998
  let settled = false;
1984
1999
  const signal = prompt.signal;
1985
2000
  let readingInput = true;
@@ -2000,7 +2015,7 @@ function answerCliOpenAIPrompt(prompt, input = process.stdin, output4 = process.
2000
2015
  if (settled) return;
2001
2016
  settled = true;
2002
2017
  cleanup();
2003
- resolve5(String(data).trim());
2018
+ resolve6(String(data).trim());
2004
2019
  };
2005
2020
  const onAbort = () => {
2006
2021
  if (settled || !signal) return;
@@ -2049,9 +2064,9 @@ var openaiLoginCmd = defineCommand8({
2049
2064
  description: "Use headless device-code login instead of the localhost browser callback"
2050
2065
  }
2051
2066
  },
2052
- async run({ args }) {
2067
+ async run({ args: args2 }) {
2053
2068
  const client = createClient2();
2054
- const loginMethod = args["device-code"] ? "device_code" : "browser";
2069
+ const loginMethod = args2["device-code"] ? "device_code" : "browser";
2055
2070
  if (loginMethod === "device_code") {
2056
2071
  console.log("starting OpenAI device-code sign-in...");
2057
2072
  } else {
@@ -2172,7 +2187,7 @@ import {
2172
2187
  createWriteStream,
2173
2188
  existsSync as existsSync2,
2174
2189
  fsyncSync as fsyncSync2,
2175
- lstatSync as lstatSync2,
2190
+ lstatSync as lstatSync3,
2176
2191
  mkdirSync as mkdirSync2,
2177
2192
  mkdtempSync,
2178
2193
  openSync as openSync2,
@@ -2184,7 +2199,7 @@ import {
2184
2199
  writeFileSync as writeFileSync2
2185
2200
  } from "fs";
2186
2201
  import { tmpdir } from "os";
2187
- import { basename as basename4, dirname as dirname2, isAbsolute, parse, posix, relative, resolve as resolve2 } from "path";
2202
+ import { basename as basename4, dirname as dirname2, isAbsolute, parse, posix, relative, resolve as resolve3 } from "path";
2188
2203
  import { DatabaseSync as DatabaseSync2, backup as sqliteBackup } from "node:sqlite";
2189
2204
  import { Readable } from "stream";
2190
2205
  import { pipeline } from "stream/promises";
@@ -2192,6 +2207,34 @@ import { Decrypter, Encrypter } from "age-encryption";
2192
2207
  import { defineCommand as defineCommand9 } from "citty";
2193
2208
  import { extract, list as list5 } from "tar";
2194
2209
 
2210
+ // src/backup-coding-recovery.ts
2211
+ import { lstatSync } from "fs";
2212
+ import { resolve } from "path";
2213
+ function invalidateRestoredCodingEvidence(db, payload, targetHome) {
2214
+ const rows = db.prepare("SELECT id, receipt_json FROM coding_commands").all();
2215
+ for (const row2 of rows) {
2216
+ const receipt = JSON.parse(row2.receipt_json);
2217
+ receipt.environment.inputFingerprint = null;
2218
+ if (!receipt.finishedAt) {
2219
+ receipt.state = "interrupted";
2220
+ receipt.reason = "backup_restored";
2221
+ receipt.finishedAt = Date.now();
2222
+ }
2223
+ db.prepare("UPDATE coding_commands SET state = ?, receipt_json = ? WHERE id = ?").run(
2224
+ receipt.state,
2225
+ JSON.stringify(receipt),
2226
+ row2.id
2227
+ );
2228
+ }
2229
+ db.prepare("UPDATE workspace_writers SET state = 'recovery', recovery_mode = 'restored'").run();
2230
+ const teams = db.prepare("SELECT id FROM teams").all();
2231
+ const rebase = db.prepare("UPDATE workspace_writers SET root_path = ? WHERE team_id = ?");
2232
+ for (const team of teams) {
2233
+ if (lstatSync(resolve(payload, "teams", team.id)).isDirectory())
2234
+ rebase.run(resolve(targetHome, "teams", team.id), team.id);
2235
+ }
2236
+ }
2237
+
2195
2238
  // src/backup-queue-recovery.ts
2196
2239
  import { randomUUID as randomUUID5 } from "crypto";
2197
2240
  import { DatabaseSync } from "node:sqlite";
@@ -2264,8 +2307,13 @@ function pauseRestoredUserQueue(database) {
2264
2307
  // src/backup-schema.ts
2265
2308
  import { createHash } from "crypto";
2266
2309
  var CANONICAL_MIGRATION = "0001_init";
2267
- var CANONICAL_SCHEMA_HASH = "278a7649d6017011b97405306760af3fdd337f068693e24b18cab43421a0c723";
2310
+ var CANONICAL_SCHEMA_HASH = "50e8e9fcbf9bc995ec343f4b1a81000e05f5a62e514dc20fca91d275ef0e3cf1";
2268
2311
  var CANONICAL_OBJECTS = [
2312
+ ["table", "team_coding_environments"],
2313
+ ["table", "workspace_writers"],
2314
+ ["table", "workspace_resources"],
2315
+ ["table", "coding_commands"],
2316
+ ["index", "coding_command_history"],
2269
2317
  ["table", "notification_settings"],
2270
2318
  ["table", "notification_receipts"],
2271
2319
  ["index", "notification_receipts_state"],
@@ -2408,7 +2456,7 @@ import {
2408
2456
  fsyncSync,
2409
2457
  ftruncateSync,
2410
2458
  futimesSync,
2411
- lstatSync,
2459
+ lstatSync as lstatSync2,
2412
2460
  mkdirSync,
2413
2461
  openSync,
2414
2462
  readFileSync as readFileSync4,
@@ -2417,12 +2465,12 @@ import {
2417
2465
  rmSync,
2418
2466
  writeSync
2419
2467
  } from "fs";
2420
- import { basename as basename3, dirname, join as join2, resolve } from "path";
2468
+ import { basename as basename3, dirname, join as join2, resolve as resolve2 } from "path";
2421
2469
  var DAEMON_LIVENESS_FILENAME = "daemon-runtime.json";
2422
2470
  var STALE_AFTER_MS = 6e4;
2423
2471
  var PROBE_TIMEOUT_MS = 750;
2424
2472
  function canonicalHomeIdentity(home) {
2425
- const absolute = resolve(home);
2473
+ const absolute = resolve2(home);
2426
2474
  try {
2427
2475
  return realpathSync.native(absolute);
2428
2476
  } catch (error) {
@@ -2472,7 +2520,7 @@ function parseRecord(raw) {
2472
2520
  }
2473
2521
  function readRecord(path) {
2474
2522
  try {
2475
- const stat = lstatSync(path);
2523
+ const stat = lstatSync2(path);
2476
2524
  const raw = stat.isFile() ? readFileSync4(path, "utf8") : "";
2477
2525
  return { raw, stat, record: stat.isFile() ? parseRecord(raw) : null };
2478
2526
  } catch (error) {
@@ -2560,7 +2608,7 @@ function reclaimRecord(path, existing) {
2560
2608
  }
2561
2609
  }
2562
2610
  async function acquireHomeRestoreLock(home, operation = "restoring") {
2563
- const targetHome = resolve(home);
2611
+ const targetHome = resolve2(home);
2564
2612
  mkdirSync(dirname(targetHome), { recursive: true });
2565
2613
  const path = daemonLivenessPath(targetHome);
2566
2614
  mkdirSync(dirname(path), { recursive: true });
@@ -2652,7 +2700,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
2652
2700
  closeSync(fd);
2653
2701
  fd = null;
2654
2702
  try {
2655
- if (sameFile(lstatSync(path), ownedStat)) rmSync(path, { force: true });
2703
+ if (sameFile(lstatSync2(path), ownedStat)) rmSync(path, { force: true });
2656
2704
  } catch {
2657
2705
  }
2658
2706
  throw error;
@@ -2661,7 +2709,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
2661
2709
  let uninstallComplete = false;
2662
2710
  const stillOwnsPath = () => {
2663
2711
  try {
2664
- return sameFile(lstatSync(path), ownedStat);
2712
+ return sameFile(lstatSync2(path), ownedStat);
2665
2713
  } catch {
2666
2714
  return false;
2667
2715
  }
@@ -2689,7 +2737,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
2689
2737
  markSwapping(recoveryPath, hadPrevious) {
2690
2738
  if (released || !stillOwnsPath()) throw new Error("restore ownership was lost");
2691
2739
  record.state = "swapping";
2692
- record.recoveryPath = resolve(recoveryPath);
2740
+ record.recoveryPath = resolve2(recoveryPath);
2693
2741
  record.hadPrevious = hadPrevious;
2694
2742
  writeRecord(fd, record);
2695
2743
  fsyncParentDirectory(path);
@@ -2704,7 +2752,7 @@ async function acquireHomeRestoreLock(home, operation = "restoring") {
2704
2752
  markRecoveryRequired(recoveryPath, hadPrevious) {
2705
2753
  if (released || !stillOwnsPath()) throw new Error("restore ownership was lost");
2706
2754
  record.state = "recovery-required";
2707
- record.recoveryPath = resolve(recoveryPath);
2755
+ record.recoveryPath = resolve2(recoveryPath);
2708
2756
  record.hadPrevious = hadPrevious;
2709
2757
  writeRecord(fd, record);
2710
2758
  },
@@ -2746,29 +2794,29 @@ var createCmd = defineCommand9({
2746
2794
  description: "Explicitly permit a sensitive unencrypted .tar.gz backup"
2747
2795
  }
2748
2796
  },
2749
- async run({ args }) {
2750
- if (args.recipient && args.plaintext) {
2797
+ async run({ args: args2 }) {
2798
+ if (args2.recipient && args2.plaintext) {
2751
2799
  throw new Error("--recipient and --plaintext are mutually exclusive");
2752
2800
  }
2753
- if (!args.recipient && !args.plaintext) {
2801
+ if (!args2.recipient && !args2.plaintext) {
2754
2802
  throw new Error("choose --recipient <age1\u2026> for encryption or explicitly pass --plaintext");
2755
2803
  }
2756
2804
  const cfg = loadClientConfig();
2757
2805
  const date = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
2758
- const defaultSuffix = args.recipient ? ".tar.gz.age" : ".tar.gz";
2759
- const outAbs = resolve2(args.output ?? `bazilion-backup-${date}${defaultSuffix}`);
2806
+ const defaultSuffix = args2.recipient ? ".tar.gz.age" : ".tar.gz";
2807
+ const outAbs = resolve3(args2.output ?? `bazilion-backup-${date}${defaultSuffix}`);
2760
2808
  if (existsSync2(outAbs)) throw new Error(`refusing to overwrite existing backup: ${outAbs}`);
2761
- const configuredHome = resolve2(resolveCliPaths().home);
2809
+ const configuredHome = resolve3(resolveCliPaths().home);
2762
2810
  const outputFromHome = relative(configuredHome, outAbs);
2763
2811
  if (!outputFromHome || !outputFromHome.startsWith("..") && !isAbsolute(outputFromHome)) {
2764
2812
  throw new Error(
2765
2813
  `backup output must be outside BAZILION_HOME (${configuredHome}) to avoid nesting backups`
2766
2814
  );
2767
2815
  }
2768
- if (!args.recipient) {
2816
+ if (!args2.recipient) {
2769
2817
  console.warn("warning: creating a plaintext backup containing all Bazilion credentials");
2770
2818
  }
2771
- console.log(`${args.recipient ? "encrypting" : "downloading"} backup \u2192 ${outAbs}`);
2819
+ console.log(`${args2.recipient ? "encrypting" : "downloading"} backup \u2192 ${outAbs}`);
2772
2820
  const res = await fetch(`${cfg.serverUrl}/api/backup`, {
2773
2821
  headers: { authorization: `Bearer ${cfg.token}`, origin: cfg.serverUrl }
2774
2822
  });
@@ -2781,13 +2829,13 @@ var createCmd = defineCommand9({
2781
2829
  }
2782
2830
  throw new Error(`backup failed: ${err}`);
2783
2831
  }
2784
- const downloadDir = mkdtempSync(resolve2(tmpdir(), "bazilion-download-"));
2785
- const partial = resolve2(downloadDir, "backup.tar.gz");
2832
+ const downloadDir = mkdtempSync(resolve3(tmpdir(), "bazilion-download-"));
2833
+ const partial = resolve3(downloadDir, "backup.tar.gz");
2786
2834
  try {
2787
- if (args.recipient) {
2835
+ if (args2.recipient) {
2788
2836
  const [encryptSource, validateSource] = res.body.tee();
2789
2837
  const encrypter = new Encrypter();
2790
- encrypter.addRecipient(args.recipient);
2838
+ encrypter.addRecipient(args2.recipient);
2791
2839
  const encrypted = await encrypter.encrypt(encryptSource);
2792
2840
  await Promise.all([
2793
2841
  pipeline(
@@ -2802,12 +2850,12 @@ var createCmd = defineCommand9({
2802
2850
  createWriteStream(partial, { flags: "wx", mode: 384 })
2803
2851
  );
2804
2852
  }
2805
- if (!args.recipient) await validateArchive(partial);
2853
+ if (!args2.recipient) await validateArchive(partial);
2806
2854
  try {
2807
2855
  renameSync2(partial, outAbs);
2808
2856
  } catch (error) {
2809
2857
  if (!(error instanceof Error) || !("code" in error) || error.code !== "EXDEV") throw error;
2810
- const installPartial = resolve2(
2858
+ const installPartial = resolve3(
2811
2859
  dirname2(outAbs),
2812
2860
  `.${basename4(outAbs)}.${randomUUID7()}.installing`
2813
2861
  );
@@ -3047,7 +3095,7 @@ function validateEntityId(id, pattern, entity) {
3047
3095
  return id;
3048
3096
  }
3049
3097
  function containedChildDirectory(root, id, rowLabel) {
3050
- const child = resolve2(root, id);
3098
+ const child = resolve3(root, id);
3051
3099
  const fromRoot = relative(root, child);
3052
3100
  if (!fromRoot || fromRoot.startsWith("..") || isAbsolute(fromRoot)) {
3053
3101
  throw new Error(`${rowLabel} directory escapes its canonical root: ${JSON.stringify(id)}`);
@@ -3056,14 +3104,14 @@ function containedChildDirectory(root, id, rowLabel) {
3056
3104
  }
3057
3105
  function requireExtractedDirectory(path, rowLabel) {
3058
3106
  try {
3059
- if (lstatSync2(path).isDirectory()) return;
3107
+ if (lstatSync3(path).isDirectory()) return;
3060
3108
  } catch {
3061
3109
  }
3062
3110
  throw new Error(`${rowLabel} is missing its canonical directory in the backup`);
3063
3111
  }
3064
3112
  function requireExtractedTeamSlot(path, rowLabel) {
3065
3113
  try {
3066
- const entry3 = lstatSync2(path);
3114
+ const entry3 = lstatSync3(path);
3067
3115
  if (entry3.isDirectory() || entry3.isSymbolicLink()) return;
3068
3116
  } catch {
3069
3117
  }
@@ -3083,8 +3131,8 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
3083
3131
  ["agents", agents, AGENT_ID]
3084
3132
  ]) {
3085
3133
  const collection = table;
3086
- const stagedRoot = resolve2(payload, collection);
3087
- const targetRoot = resolve2(targetHome, collection);
3134
+ const stagedRoot = resolve3(payload, collection);
3135
+ const targetRoot = resolve3(targetHome, collection);
3088
3136
  for (const row2 of rows) {
3089
3137
  const id = validateEntityId(row2.id, idPattern, `${table} row`);
3090
3138
  const rowLabel = `${table} row ${JSON.stringify(id)}`;
@@ -3097,7 +3145,7 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
3097
3145
  });
3098
3146
  }
3099
3147
  }
3100
- const stagedTeamsRoot = resolve2(payload, "teams");
3148
+ const stagedTeamsRoot = resolve3(payload, "teams");
3101
3149
  for (const row2 of teams) {
3102
3150
  const id = validateEntityId(row2.id, SLUG_ID, "teams row");
3103
3151
  const rowLabel = `teams row ${JSON.stringify(id)}`;
@@ -3127,6 +3175,7 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
3127
3175
  );
3128
3176
  }
3129
3177
  }
3178
+ invalidateRestoredCodingEvidence(db, payload, targetHome);
3130
3179
  db.exec("COMMIT");
3131
3180
  transactionOpen = false;
3132
3181
  } catch (error) {
@@ -3146,15 +3195,15 @@ function rebaseRestoredHomeDirectories(database, payload, targetHome) {
3146
3195
  }
3147
3196
  }
3148
3197
  function removeRebuildableQmdIndexes(payload) {
3149
- const teamsDir = resolve2(payload, "teams");
3150
- if (!existsSync2(teamsDir) || !lstatSync2(teamsDir).isDirectory()) return;
3198
+ const teamsDir = resolve3(payload, "teams");
3199
+ if (!existsSync2(teamsDir) || !lstatSync3(teamsDir).isDirectory()) return;
3151
3200
  for (const team of readdirSync(teamsDir, { withFileTypes: true })) {
3152
3201
  if (!team.isDirectory() || team.isSymbolicLink()) continue;
3153
- const memoryDir = resolve2(teamsDir, team.name, "memory");
3154
- if (!existsSync2(memoryDir) || !lstatSync2(memoryDir).isDirectory()) continue;
3202
+ const memoryDir = resolve3(teamsDir, team.name, "memory");
3203
+ if (!existsSync2(memoryDir) || !lstatSync3(memoryDir).isDirectory()) continue;
3155
3204
  for (const entry3 of readdirSync(memoryDir, { withFileTypes: true })) {
3156
3205
  if (entry3.isFile() && entry3.name.startsWith(".qmd-index.sqlite")) {
3157
- rmSync2(resolve2(memoryDir, entry3.name), { force: true });
3206
+ rmSync2(resolve3(memoryDir, entry3.name), { force: true });
3158
3207
  }
3159
3208
  }
3160
3209
  }
@@ -3168,7 +3217,7 @@ function revokeRestoredBrowserSessions(database) {
3168
3217
  }
3169
3218
  }
3170
3219
  function installValidatedPayload(payload, targetHome, staging, lifecycle, operations = { rename: renameSync2 }) {
3171
- const previous = resolve2(staging, "previous-home");
3220
+ const previous = resolve3(staging, "previous-home");
3172
3221
  const hadPrevious = existsSync2(targetHome);
3173
3222
  const targetParent = dirname2(targetHome);
3174
3223
  const syncDirectory = operations.fsyncDirectory ?? fsyncDirectory;
@@ -3299,8 +3348,8 @@ function isAgeEncrypted(path) {
3299
3348
  }
3300
3349
  }
3301
3350
  function readAgeIdentity(rawPath) {
3302
- const path = resolve2(rawPath);
3303
- const entry3 = lstatSync2(path);
3351
+ const path = resolve3(rawPath);
3352
+ const entry3 = lstatSync3(path);
3304
3353
  if (!entry3.isFile()) throw new Error(`age identity is not a regular file: ${path}`);
3305
3354
  if (process.platform !== "win32" && (entry3.mode & 63) !== 0) {
3306
3355
  throw new Error(`age identity must be owner-only (chmod 600): ${path}`);
@@ -3332,11 +3381,11 @@ var restoreCmd = defineCommand9({
3332
3381
  description: "Path to an age identity file required for encrypted backups"
3333
3382
  }
3334
3383
  },
3335
- async run({ args }) {
3336
- const file = resolve2(args.file);
3384
+ async run({ args: args2 }) {
3385
+ const file = resolve3(args2.file);
3337
3386
  if (!existsSync2(file)) throw new Error(`backup file not found: ${file}`);
3338
- const paths = resolveCliPaths(args.home);
3339
- const targetHome = resolve2(paths.home);
3387
+ const paths = resolveCliPaths(args2.home);
3388
+ const targetHome = resolve3(paths.home);
3340
3389
  if (targetHome === parse(targetHome).root) {
3341
3390
  throw new Error(`refusing to restore over filesystem root: ${targetHome}`);
3342
3391
  }
@@ -3344,7 +3393,7 @@ var restoreCmd = defineCommand9({
3344
3393
  mkdirSync2(targetParent, { recursive: true });
3345
3394
  const restoreLock = await acquireHomeRestoreLock(targetHome);
3346
3395
  try {
3347
- const targetsConfiguredHome = targetHome === resolve2(resolveCliPaths().home);
3396
+ const targetsConfiguredHome = targetHome === resolve3(resolveCliPaths().home);
3348
3397
  if (targetsConfiguredHome) {
3349
3398
  for (const serverUrl of configuredLoopbackUrls()) {
3350
3399
  if (await probeServerRunning(serverUrl)) {
@@ -3355,26 +3404,26 @@ var restoreCmd = defineCommand9({
3355
3404
  }
3356
3405
  }
3357
3406
  if (existsSync2(targetHome)) {
3358
- if (!lstatSync2(targetHome).isDirectory()) {
3407
+ if (!lstatSync3(targetHome).isDirectory()) {
3359
3408
  throw new Error(`${targetHome} exists and is not a directory`);
3360
3409
  }
3361
3410
  const entries = readdirSync(targetHome);
3362
- if (entries.length > 0 && !args.force) {
3411
+ if (entries.length > 0 && !args2.force) {
3363
3412
  throw new Error(
3364
3413
  `${targetHome} is not empty. Pass --force to overwrite (destroys existing data).`
3365
3414
  );
3366
3415
  }
3367
3416
  }
3368
- const staging = mkdtempSync(resolve2(targetParent, ".bazilion-restore-"));
3369
- const stagedArchive = resolve2(staging, "backup.tar.gz");
3370
- const payload = resolve2(staging, "payload");
3417
+ const staging = mkdtempSync(resolve3(targetParent, ".bazilion-restore-"));
3418
+ const stagedArchive = resolve3(staging, "backup.tar.gz");
3419
+ const payload = resolve3(staging, "payload");
3371
3420
  let preserveStaging = false;
3372
3421
  try {
3373
3422
  if (isAgeEncrypted(file)) {
3374
- if (!args.identity) {
3423
+ if (!args2.identity) {
3375
3424
  throw new Error("encrypted backup requires --identity <owner-only age identity file>");
3376
3425
  }
3377
- const identity = readAgeIdentity(args.identity);
3426
+ const identity = readAgeIdentity(args2.identity);
3378
3427
  const decrypter = new Decrypter();
3379
3428
  decrypter.addIdentity(identity);
3380
3429
  let decrypted;
@@ -3394,7 +3443,7 @@ var restoreCmd = defineCommand9({
3394
3443
  throw new Error("backup decryption failed: ciphertext is truncated or modified");
3395
3444
  }
3396
3445
  } else {
3397
- if (args.identity) {
3446
+ if (args2.identity) {
3398
3447
  throw new Error("encrypted-only restore requested, but the backup is plaintext");
3399
3448
  }
3400
3449
  copyFileSync(file, stagedArchive);
@@ -3413,9 +3462,9 @@ var restoreCmd = defineCommand9({
3413
3462
  // payload-relative path by npm-tar.
3414
3463
  preservePaths: true
3415
3464
  });
3416
- const database = resolve2(payload, "bazilion.db");
3417
- const authFile = resolve2(payload, "auth.json");
3418
- if (!lstatSync2(database).isFile() || !lstatSync2(authFile).isFile()) {
3465
+ const database = resolve3(payload, "bazilion.db");
3466
+ const authFile = resolve3(payload, "auth.json");
3467
+ if (!lstatSync3(database).isFile() || !lstatSync3(authFile).isFile()) {
3419
3468
  throw new Error("backup required files did not extract as regular files");
3420
3469
  }
3421
3470
  const authToken = validateAuthFile(authFile);
@@ -3477,8 +3526,8 @@ function encryptSecretEnvelope(value, password) {
3477
3526
  });
3478
3527
  }
3479
3528
  function credentialInventory(home) {
3480
- const authFile = resolve2(home, "auth.json");
3481
- const database = resolve2(home, "bazilion.db");
3529
+ const authFile = resolve3(home, "auth.json");
3530
+ const database = resolve3(home, "bazilion.db");
3482
3531
  const token = validateAuthFile(authFile);
3483
3532
  validateDatabase(database, token);
3484
3533
  const db = new DatabaseSync2(database, { readOnly: true });
@@ -3495,8 +3544,8 @@ function credentialInventory(home) {
3495
3544
  var inventoryCmd = defineCommand9({
3496
3545
  meta: { name: "inventory", description: "List credential classes captured by a backup/home" },
3497
3546
  args: { home: { type: "string", description: "Override BAZILION_HOME" } },
3498
- run({ args }) {
3499
- const home = resolve2(resolveCliPaths(args.home).home);
3547
+ run({ args: args2 }) {
3548
+ const home = resolve3(resolveCliPaths(args2.home).home);
3500
3549
  const inventory = credentialInventory(home);
3501
3550
  console.log("credential classes present (values are never shown):");
3502
3551
  console.log(` bootstrap token: ${inventory.bootstrap ? "present" : "missing"}`);
@@ -3532,17 +3581,17 @@ var rotateBootstrapCmd = defineCommand9({
3532
3581
  home: { type: "string", description: "Override BAZILION_HOME" },
3533
3582
  yes: { type: "boolean", required: true, description: "Confirm token revocation and home swap" }
3534
3583
  },
3535
- async run({ args }) {
3536
- if (!args.yes) throw new Error("--yes is required");
3537
- const paths = resolveCliPaths(args.home);
3538
- const targetHome = resolve2(paths.home);
3584
+ async run({ args: args2 }) {
3585
+ if (!args2.yes) throw new Error("--yes is required");
3586
+ const paths = resolveCliPaths(args2.home);
3587
+ const targetHome = resolve3(paths.home);
3539
3588
  if (targetHome === parse(targetHome).root) {
3540
3589
  throw new Error(`refusing to rotate filesystem root: ${targetHome}`);
3541
3590
  }
3542
3591
  const lock = await acquireHomeRestoreLock(targetHome);
3543
3592
  const parent = dirname2(targetHome);
3544
- const staging = mkdtempSync(resolve2(parent, ".bazilion-rotate-"));
3545
- const payload = resolve2(staging, "payload");
3593
+ const staging = mkdtempSync(resolve3(parent, ".bazilion-rotate-"));
3594
+ const payload = resolve3(staging, "payload");
3546
3595
  let preserveStaging = false;
3547
3596
  try {
3548
3597
  for (const serverUrl of configuredLoopbackUrls()) {
@@ -3554,16 +3603,16 @@ var rotateBootstrapCmd = defineCommand9({
3554
3603
  if (typeof oldAuth.token !== "string" || !oldAuth.token) {
3555
3604
  throw new Error("auth.json is missing the bootstrap token");
3556
3605
  }
3557
- validateDatabase(resolve2(targetHome, "bazilion.db"), oldAuth.token);
3606
+ validateDatabase(resolve3(targetHome, "bazilion.db"), oldAuth.token);
3558
3607
  cpSync(targetHome, payload, {
3559
3608
  recursive: true,
3560
3609
  dereference: false,
3561
3610
  verbatimSymlinks: true,
3562
3611
  preserveTimestamps: true
3563
3612
  });
3564
- const stagedDb = resolve2(payload, "bazilion.db");
3613
+ const stagedDb = resolve3(payload, "bazilion.db");
3565
3614
  rmSync2(stagedDb, { force: true });
3566
- const sourceDb = new DatabaseSync2(resolve2(targetHome, "bazilion.db"), { readOnly: true });
3615
+ const sourceDb = new DatabaseSync2(resolve3(targetHome, "bazilion.db"), { readOnly: true });
3567
3616
  try {
3568
3617
  await sqliteBackup(sourceDb, stagedDb);
3569
3618
  } finally {
@@ -3610,8 +3659,8 @@ var rotateBootstrapCmd = defineCommand9({
3610
3659
  } finally {
3611
3660
  db.close();
3612
3661
  }
3613
- const stagedAuth = resolve2(payload, "auth.json");
3614
- const authPartial = resolve2(payload, `.auth.json.${randomUUID7()}.installing`);
3662
+ const stagedAuth = resolve3(payload, "auth.json");
3663
+ const authPartial = resolve3(payload, `.auth.json.${randomUUID7()}.installing`);
3615
3664
  writeFileSync2(authPartial, `${JSON.stringify({ ...oldAuth, token: newToken }, null, 2)}
3616
3665
  `, {
3617
3666
  mode: 384,
@@ -3668,9 +3717,9 @@ async function walk(cmd, path, out) {
3668
3717
  await walk(sub, [...path, name], out);
3669
3718
  }
3670
3719
  }
3671
- function flagsOf(args) {
3720
+ function flagsOf(args2) {
3672
3721
  const out = [];
3673
- for (const [name, def] of Object.entries(args)) {
3722
+ for (const [name, def] of Object.entries(args2)) {
3674
3723
  if (def.type === "positional") continue;
3675
3724
  out.push(`--${name}`);
3676
3725
  const aliases = Array.isArray(def.alias) ? def.alias : def.alias ? [def.alias] : [];
@@ -3773,14 +3822,14 @@ function completionCommand(main2) {
3773
3822
  description: "bash | zsh | fish"
3774
3823
  }
3775
3824
  },
3776
- async run({ args }) {
3825
+ async run({ args: args2 }) {
3777
3826
  const flat = [];
3778
3827
  await walk(main2, [], flat);
3779
- const shell = String(args.shell).toLowerCase();
3828
+ const shell = String(args2.shell).toLowerCase();
3780
3829
  if (shell === "bash") console.log(bashScript(flat));
3781
3830
  else if (shell === "zsh") console.log(zshScript(flat));
3782
3831
  else if (shell === "fish") console.log(fishScript(flat));
3783
- else throw new Error(`unsupported shell: ${args.shell} (want bash | zsh | fish)`);
3832
+ else throw new Error(`unsupported shell: ${args2.shell} (want bash | zsh | fish)`);
3784
3833
  }
3785
3834
  });
3786
3835
  }
@@ -3832,11 +3881,11 @@ var setCmd = defineCommand11({
3832
3881
  description: "New value (empty string clears the field)"
3833
3882
  }
3834
3883
  },
3835
- async run({ args }) {
3884
+ async run({ args: args2 }) {
3836
3885
  const client = createClient2();
3837
- const body = { value: args.value };
3886
+ const body = { value: args2.value };
3838
3887
  const state = await client.put(
3839
- `/api/config/fields/${encodeURIComponent(args.envVar)}`,
3888
+ `/api/config/fields/${encodeURIComponent(args2.envVar)}`,
3840
3889
  body
3841
3890
  );
3842
3891
  console.log(`${state.envVar} (${state.kind}): ${displayValue(state)}`);
@@ -3847,10 +3896,10 @@ var rmCmd = defineCommand11({
3847
3896
  args: {
3848
3897
  envVar: { type: "positional", required: true, description: "Env var name to clear" }
3849
3898
  },
3850
- async run({ args }) {
3899
+ async run({ args: args2 }) {
3851
3900
  const client = createClient2();
3852
- await client.del(`/api/config/fields/${encodeURIComponent(args.envVar)}`);
3853
- console.log(`removed ${args.envVar}`);
3901
+ await client.del(`/api/config/fields/${encodeURIComponent(args2.envVar)}`);
3902
+ console.log(`removed ${args2.envVar}`);
3854
3903
  }
3855
3904
  });
3856
3905
  var configCommand = defineCommand11({
@@ -3897,12 +3946,12 @@ function probeHost(host) {
3897
3946
  return host;
3898
3947
  }
3899
3948
  function isTcpPortOpen(host, port) {
3900
- return new Promise((resolve5) => {
3949
+ return new Promise((resolve6) => {
3901
3950
  const socket = connect({ host: probeHost(host), port: Number(port) });
3902
3951
  const done = (open) => {
3903
3952
  socket.removeAllListeners();
3904
3953
  socket.destroy();
3905
- resolve5(open);
3954
+ resolve6(open);
3906
3955
  };
3907
3956
  socket.setTimeout(600);
3908
3957
  socket.once("connect", () => done(true));
@@ -3951,8 +4000,8 @@ async function waitFor(url, label, timeoutMs = 2e4) {
3951
4000
  function openBrowser(url) {
3952
4001
  const platform = process.platform;
3953
4002
  const cmd = platform === "darwin" ? "open" : platform === "win32" ? "cmd" : process.env.BROWSER || "xdg-open";
3954
- const args = platform === "win32" ? ["/c", "start", "", url] : [url];
3955
- const proc = spawn(cmd, args, { detached: true, stdio: "ignore" });
4003
+ const args2 = platform === "win32" ? ["/c", "start", "", url] : [url];
4004
+ const proc = spawn(cmd, args2, { detached: true, stdio: "ignore" });
3956
4005
  proc.unref();
3957
4006
  }
3958
4007
  function spawnProcess(label, entry3, env) {
@@ -3986,11 +4035,11 @@ var dashboardCommand = defineCommand12({
3986
4035
  default: true
3987
4036
  }
3988
4037
  },
3989
- async run({ args }) {
3990
- const webHost = args.host ?? "127.0.0.1";
3991
- const webPort = args.port ?? "4322";
3992
- const daemonHost = args["daemon-host"] ?? "127.0.0.1";
3993
- const daemonPort = args["daemon-port"] ?? "4321";
4038
+ async run({ args: args2 }) {
4039
+ const webHost = args2.host ?? "127.0.0.1";
4040
+ const webPort = args2.port ?? "4322";
4041
+ const daemonHost = args2["daemon-host"] ?? "127.0.0.1";
4042
+ const daemonPort = args2["daemon-port"] ?? "4321";
3994
4043
  const daemonUrl = `http://${daemonHost}:${daemonPort}`;
3995
4044
  const webUrl = `http://${webHost}:${webPort}`;
3996
4045
  const authFile = resolveCliPaths().authFile;
@@ -4060,7 +4109,7 @@ var dashboardCommand = defineCommand12({
4060
4109
  console.log("");
4061
4110
  console.log(`dashboard: ${webUrl}`);
4062
4111
  console.log(`token: ${authFile}`);
4063
- if (args.open) openBrowser(webUrl);
4112
+ if (args2.open) openBrowser(webUrl);
4064
4113
  } catch (err) {
4065
4114
  terminateChildren();
4066
4115
  throw err;
@@ -4068,13 +4117,13 @@ var dashboardCommand = defineCommand12({
4068
4117
  if (children.length === 0) return;
4069
4118
  process.on("SIGINT", terminateChildren);
4070
4119
  process.on("SIGTERM", terminateChildren);
4071
- await new Promise((resolve5) => {
4120
+ await new Promise((resolve6) => {
4072
4121
  let remaining = children.length;
4073
4122
  for (const child of children) {
4074
4123
  child.on("close", (code) => {
4075
4124
  remaining--;
4076
4125
  if (!signalled && code && code !== 0) process.exitCode = code;
4077
- if (remaining === 0) resolve5();
4126
+ if (remaining === 0) resolve6();
4078
4127
  });
4079
4128
  }
4080
4129
  });
@@ -4363,14 +4412,14 @@ var listCmd3 = defineCommand15({
4363
4412
  agent: { type: "positional", required: true, description: "Recipient agent id" },
4364
4413
  unread: { type: "boolean", description: "Only show unread messages" }
4365
4414
  },
4366
- async run({ args }) {
4415
+ async run({ args: args2 }) {
4367
4416
  const client = createClient2();
4368
- const qs = args.unread ? "?unread=1" : "";
4417
+ const qs = args2.unread ? "?unread=1" : "";
4369
4418
  const { messages } = await client.get(
4370
- `/api/agents/${args.agent}/messages${qs}`
4419
+ `/api/agents/${args2.agent}/messages${qs}`
4371
4420
  );
4372
4421
  if (messages.length === 0) {
4373
- console.log(args.unread ? "(no unread messages)" : "(inbox empty)");
4422
+ console.log(args2.unread ? "(no unread messages)" : "(inbox empty)");
4374
4423
  return;
4375
4424
  }
4376
4425
  for (const line of columnize(messages.map(messageRow))) console.log(line);
@@ -4381,9 +4430,9 @@ var showCmd2 = defineCommand15({
4381
4430
  args: {
4382
4431
  id: { type: "positional", required: true, description: "Message id" }
4383
4432
  },
4384
- async run({ args }) {
4433
+ async run({ args: args2 }) {
4385
4434
  const client = createClient2();
4386
- const m = await client.get(`/api/messages/${args.id}`);
4435
+ const m = await client.get(`/api/messages/${args2.id}`);
4387
4436
  const when = new Date(m.createdAt).toISOString();
4388
4437
  const read = m.readAt ? new Date(m.readAt).toISOString() : "(unread)";
4389
4438
  console.log(`id: ${m.id}`);
@@ -4401,10 +4450,10 @@ var readCmd = defineCommand15({
4401
4450
  args: {
4402
4451
  id: { type: "positional", required: true, description: "Message id" }
4403
4452
  },
4404
- async run({ args }) {
4453
+ async run({ args: args2 }) {
4405
4454
  const client = createClient2();
4406
- await client.patch(`/api/messages/${args.id}`, { read: true });
4407
- console.log(`marked read: ${args.id}`);
4455
+ await client.patch(`/api/messages/${args2.id}`, { read: true });
4456
+ console.log(`marked read: ${args2.id}`);
4408
4457
  }
4409
4458
  });
4410
4459
  var loopBreaksCmd = defineCommand15({
@@ -4413,11 +4462,11 @@ var loopBreaksCmd = defineCommand15({
4413
4462
  agent: { type: "positional", required: true, description: "Agent id" },
4414
4463
  limit: { type: "string", description: "Maximum events to show (default 25)" }
4415
4464
  },
4416
- async run({ args }) {
4465
+ async run({ args: args2 }) {
4417
4466
  const client = createClient2();
4418
- const limit = args.limit ? `?limit=${encodeURIComponent(args.limit)}` : "";
4467
+ const limit = args2.limit ? `?limit=${encodeURIComponent(args2.limit)}` : "";
4419
4468
  const { events } = await client.get(
4420
- `/api/agents/${args.agent}/loop-breaks${limit}`
4469
+ `/api/agents/${args2.agent}/loop-breaks${limit}`
4421
4470
  );
4422
4471
  if (events.length === 0) {
4423
4472
  console.log("(no agent-message chains stopped)");
@@ -4482,7 +4531,7 @@ var loginCommand = defineCommand16({
4482
4531
  skipVerify: { type: "boolean", description: "Don't verify /api/auth/whoami before saving" },
4483
4532
  clear: { type: "boolean", description: "Remove the stored remote instead of setting one" }
4484
4533
  },
4485
- async run({ args }) {
4534
+ async run({ args: args2 }) {
4486
4535
  const paths = resolveCliPaths();
4487
4536
  if (!existsSync4(paths.authFile)) {
4488
4537
  throw new Error(
@@ -4490,7 +4539,7 @@ var loginCommand = defineCommand16({
4490
4539
  );
4491
4540
  }
4492
4541
  const auth = JSON.parse(readFileSync6(paths.authFile, "utf8"));
4493
- if (args.clear) {
4542
+ if (args2.clear) {
4494
4543
  if (!auth.remote) {
4495
4544
  console.log("no remote stored \u2014 nothing to clear");
4496
4545
  return;
@@ -4501,16 +4550,16 @@ var loginCommand = defineCommand16({
4501
4550
  console.log("cleared stored remote; CLI will fall back to the local daemon");
4502
4551
  return;
4503
4552
  }
4504
- if (!args.server || !args.token) {
4553
+ if (!args2.server || !args2.token) {
4505
4554
  throw new Error(
4506
4555
  "--server and --token are required (or pass --clear to remove the stored remote)"
4507
4556
  );
4508
4557
  }
4509
- const server = normalizeServer(args.server);
4510
- if (!args.skipVerify) {
4511
- await verifyToken(server, args.token);
4558
+ const server = normalizeServer(args2.server);
4559
+ if (!args2.skipVerify) {
4560
+ await verifyToken(server, args2.token);
4512
4561
  }
4513
- auth.remote = { server, token: args.token };
4562
+ auth.remote = { server, token: args2.token };
4514
4563
  writeFileSync3(paths.authFile, `${JSON.stringify(auth, null, 2)}
4515
4564
  `, { mode: 384 });
4516
4565
  console.log(`saved remote: ${server}`);
@@ -4542,16 +4591,16 @@ var addCmd = defineCommand17({
4542
4591
  token: { type: "string", description: "http/sse: bearer token (stored encrypted)" },
4543
4592
  disabled: { type: "boolean", description: "Create disabled" }
4544
4593
  },
4545
- async run({ args }) {
4546
- const transport = args.transport ?? "stdio";
4594
+ async run({ args: args2 }) {
4595
+ const transport = args2.transport ?? "stdio";
4547
4596
  const body = {
4548
- name: args.name,
4597
+ name: args2.name,
4549
4598
  transport,
4550
- command: args.command ?? null,
4551
- args: args.args ? args.args.split(" ").filter(Boolean) : [],
4552
- url: args.url ?? null,
4553
- authToken: args.token ?? void 0,
4554
- enabled: !args.disabled
4599
+ command: args2.command ?? null,
4600
+ args: args2.args ? args2.args.split(" ").filter(Boolean) : [],
4601
+ url: args2.url ?? null,
4602
+ authToken: args2.token ?? void 0,
4603
+ enabled: !args2.disabled
4555
4604
  };
4556
4605
  const client = createClient2();
4557
4606
  const { server } = await client.post("/api/mcp-servers", body);
@@ -4573,46 +4622,46 @@ var listCmd4 = defineCommand17({
4573
4622
  var showCmd3 = defineCommand17({
4574
4623
  meta: { name: "show", description: "Show one MCP server" },
4575
4624
  args: { id: { type: "positional", required: true } },
4576
- async run({ args }) {
4625
+ async run({ args: args2 }) {
4577
4626
  const client = createClient2();
4578
- const { server } = await client.get(`/api/mcp-servers/${args.id}`);
4627
+ const { server } = await client.get(`/api/mcp-servers/${args2.id}`);
4579
4628
  console.log(JSON.stringify(server, null, 2));
4580
4629
  }
4581
4630
  });
4582
4631
  var rmCmd2 = defineCommand17({
4583
4632
  meta: { name: "rm", description: "Delete an MCP server" },
4584
4633
  args: { id: { type: "positional", required: true } },
4585
- async run({ args }) {
4634
+ async run({ args: args2 }) {
4586
4635
  const client = createClient2();
4587
- await client.del(`/api/mcp-servers/${args.id}`);
4588
- console.log(`removed MCP server ${args.id}`);
4636
+ await client.del(`/api/mcp-servers/${args2.id}`);
4637
+ console.log(`removed MCP server ${args2.id}`);
4589
4638
  }
4590
4639
  });
4591
4640
  var enableCmd = defineCommand17({
4592
4641
  meta: { name: "enable", description: "Enable an MCP server" },
4593
4642
  args: { id: { type: "positional", required: true } },
4594
- async run({ args }) {
4643
+ async run({ args: args2 }) {
4595
4644
  const client = createClient2();
4596
- await client.patch(`/api/mcp-servers/${args.id}`, { enabled: true });
4597
- console.log(`enabled MCP server ${args.id}`);
4645
+ await client.patch(`/api/mcp-servers/${args2.id}`, { enabled: true });
4646
+ console.log(`enabled MCP server ${args2.id}`);
4598
4647
  }
4599
4648
  });
4600
4649
  var disableCmd = defineCommand17({
4601
4650
  meta: { name: "disable", description: "Disable an MCP server" },
4602
4651
  args: { id: { type: "positional", required: true } },
4603
- async run({ args }) {
4652
+ async run({ args: args2 }) {
4604
4653
  const client = createClient2();
4605
- await client.patch(`/api/mcp-servers/${args.id}`, { enabled: false });
4606
- console.log(`disabled MCP server ${args.id}`);
4654
+ await client.patch(`/api/mcp-servers/${args2.id}`, { enabled: false });
4655
+ console.log(`disabled MCP server ${args2.id}`);
4607
4656
  }
4608
4657
  });
4609
4658
  var testCmd = defineCommand17({
4610
4659
  meta: { name: "test", description: "Connect to a server and list its tools" },
4611
4660
  args: { id: { type: "positional", required: true } },
4612
- async run({ args }) {
4661
+ async run({ args: args2 }) {
4613
4662
  const client = createClient2();
4614
4663
  const res = await client.post(
4615
- `/api/mcp-servers/${args.id}/test`
4664
+ `/api/mcp-servers/${args2.id}/test`
4616
4665
  );
4617
4666
  if (!res.ok) {
4618
4667
  console.error(`connection failed: ${res.error}`);
@@ -4649,11 +4698,11 @@ var writeCmd = defineCommand18({
4649
4698
  key: { type: "positional", required: true, description: "Memory key (path under memory/)" },
4650
4699
  content: { type: "positional", required: true, description: "Content to write" }
4651
4700
  },
4652
- async run({ args }) {
4701
+ async run({ args: args2 }) {
4653
4702
  const client = createClient2();
4654
4703
  const entry3 = await client.put(
4655
- `/api/teams/${args.team}/memory/${encodeKey(args.key)}`,
4656
- { content: args.content }
4704
+ `/api/teams/${args2.team}/memory/${encodeKey(args2.key)}`,
4705
+ { content: args2.content }
4657
4706
  );
4658
4707
  console.log(`wrote ${entry3.key} (${entry3.content.length} bytes)`);
4659
4708
  }
@@ -4664,10 +4713,10 @@ var readCmd2 = defineCommand18({
4664
4713
  team: { type: "positional", required: true, description: "Team slug" },
4665
4714
  key: { type: "positional", required: true }
4666
4715
  },
4667
- async run({ args }) {
4716
+ async run({ args: args2 }) {
4668
4717
  const client = createClient2();
4669
4718
  const entry3 = await client.get(
4670
- `/api/teams/${args.team}/memory/${encodeKey(args.key)}`
4719
+ `/api/teams/${args2.team}/memory/${encodeKey(args2.key)}`
4671
4720
  );
4672
4721
  console.log(entry3.content);
4673
4722
  }
@@ -4679,11 +4728,11 @@ var searchCmd = defineCommand18({
4679
4728
  query: { type: "positional", required: true },
4680
4729
  limit: { type: "string", description: "Max results (default 10)" }
4681
4730
  },
4682
- async run({ args }) {
4731
+ async run({ args: args2 }) {
4683
4732
  const client = createClient2();
4684
- const limit = args.limit ? Number.parseInt(args.limit, 10) : 10;
4685
- const params = new URLSearchParams({ q: args.query, limit: String(limit) });
4686
- const hits = await client.get(`/api/teams/${args.team}/memory/search?${params}`);
4733
+ const limit = args2.limit ? Number.parseInt(args2.limit, 10) : 10;
4734
+ const params = new URLSearchParams({ q: args2.query, limit: String(limit) });
4735
+ const hits = await client.get(`/api/teams/${args2.team}/memory/search?${params}`);
4687
4736
  if (hits.length === 0) {
4688
4737
  console.log("(no matches)");
4689
4738
  return;
@@ -4698,9 +4747,9 @@ var listCmd5 = defineCommand18({
4698
4747
  args: {
4699
4748
  team: { type: "positional", required: true, description: "Team slug" }
4700
4749
  },
4701
- async run({ args }) {
4750
+ async run({ args: args2 }) {
4702
4751
  const client = createClient2();
4703
- const all = await client.get(`/api/teams/${args.team}/memory`);
4752
+ const all = await client.get(`/api/teams/${args2.team}/memory`);
4704
4753
  if (all.length === 0) {
4705
4754
  console.log("(no memory entries)");
4706
4755
  return;
@@ -4716,10 +4765,10 @@ var rmCmd3 = defineCommand18({
4716
4765
  team: { type: "positional", required: true, description: "Team slug" },
4717
4766
  key: { type: "positional", required: true }
4718
4767
  },
4719
- async run({ args }) {
4768
+ async run({ args: args2 }) {
4720
4769
  const client = createClient2();
4721
- await client.del(`/api/teams/${args.team}/memory/${encodeKey(args.key)}`);
4722
- console.log(`removed ${args.key}`);
4770
+ await client.del(`/api/teams/${args2.team}/memory/${encodeKey(args2.key)}`);
4771
+ console.log(`removed ${args2.key}`);
4723
4772
  }
4724
4773
  });
4725
4774
  var memoryCommand = defineCommand18({
@@ -4808,20 +4857,20 @@ var createCmd2 = defineCommand19({
4808
4857
  description: "Path to TOOLS.md content (optional; omit to skip)"
4809
4858
  }
4810
4859
  },
4811
- async run({ args }) {
4812
- const skillsMode = parseSkillsMode(args["skills-mode"]);
4860
+ async run({ args: args2 }) {
4861
+ const skillsMode = parseSkillsMode(args2["skills-mode"]);
4813
4862
  const readTemplate = (path) => path ? readFileSync7(path, "utf8") : void 0;
4814
4863
  const body = {
4815
- id: args.id,
4816
- name: args.name,
4817
- defaultModel: args.model,
4864
+ id: args2.id,
4865
+ name: args2.name,
4866
+ defaultModel: args2.model,
4818
4867
  skillsMode,
4819
- defaultSkills: splitCsv(args.skills),
4820
- soul: readTemplate(args["soul-file"]),
4821
- identity: readTemplate(args["identity-file"]),
4822
- bootstrap: args["skip-bootstrap"] ? null : readTemplate(args["bootstrap-file"]) ?? void 0,
4823
- agents: readTemplate(args["agents-file"]),
4824
- tools: readTemplate(args["tools-file"])
4868
+ defaultSkills: splitCsv(args2.skills),
4869
+ soul: readTemplate(args2["soul-file"]),
4870
+ identity: readTemplate(args2["identity-file"]),
4871
+ bootstrap: args2["skip-bootstrap"] ? null : readTemplate(args2["bootstrap-file"]) ?? void 0,
4872
+ agents: readTemplate(args2["agents-file"]),
4873
+ tools: readTemplate(args2["tools-file"])
4825
4874
  };
4826
4875
  const client = createClient2();
4827
4876
  const profile = await client.post("/api/profiles", body);
@@ -4846,9 +4895,9 @@ var showCmd4 = defineCommand19({
4846
4895
  args: {
4847
4896
  id: { type: "positional", required: true }
4848
4897
  },
4849
- async run({ args }) {
4898
+ async run({ args: args2 }) {
4850
4899
  const client = createClient2();
4851
- const loaded = await client.get(`/api/profiles/${args.id}`);
4900
+ const loaded = await client.get(`/api/profiles/${args2.id}`);
4852
4901
  console.log(`# ${loaded.profile.id}`);
4853
4902
  console.log(`name: ${loaded.profile.name}`);
4854
4903
  console.log(`dir: ${loaded.profile.dir}`);
@@ -4876,23 +4925,23 @@ var editCmd2 = defineCommand19({
4876
4925
  description: `File: ${PROFILE_FILES.join(", ")}`
4877
4926
  }
4878
4927
  },
4879
- async run({ args }) {
4880
- if (!PROFILE_FILES.includes(args.file)) {
4881
- throw new Error(`unsupported file: ${args.file}. Allowed: ${PROFILE_FILES.join(", ")}`);
4928
+ async run({ args: args2 }) {
4929
+ if (!PROFILE_FILES.includes(args2.file)) {
4930
+ throw new Error(`unsupported file: ${args2.file}. Allowed: ${PROFILE_FILES.join(", ")}`);
4882
4931
  }
4883
- const file = args.file;
4932
+ const file = args2.file;
4884
4933
  const client = createClient2();
4885
4934
  const { content } = await client.get(
4886
- `/api/profiles/${args.id}/files/${file}`
4935
+ `/api/profiles/${args2.id}/files/${file}`
4887
4936
  );
4888
- const tmpPath = join4(tmpdir2(), `bazilion-${args.id}-${file}-${randomBytes2(4).toString("hex")}`);
4937
+ const tmpPath = join4(tmpdir2(), `bazilion-${args2.id}-${file}-${randomBytes2(4).toString("hex")}`);
4889
4938
  writeFileSync4(tmpPath, content);
4890
4939
  try {
4891
4940
  const editor = process.env.EDITOR ?? process.env.VISUAL ?? "vi";
4892
- const code = await new Promise((resolve5, reject) => {
4941
+ const code = await new Promise((resolve6, reject) => {
4893
4942
  const child = spawn2(editor, [tmpPath], { stdio: "inherit" });
4894
4943
  child.on("error", reject);
4895
- child.on("close", (c) => resolve5(c ?? 0));
4944
+ child.on("close", (c) => resolve6(c ?? 0));
4896
4945
  });
4897
4946
  if (code !== 0) throw new Error(`editor exited with code ${code}`);
4898
4947
  const updated = readFileSync7(tmpPath, "utf8");
@@ -4901,7 +4950,7 @@ var editCmd2 = defineCommand19({
4901
4950
  return;
4902
4951
  }
4903
4952
  const body = { content: updated };
4904
- await client.put(`/api/profiles/${args.id}/files/${file}`, body);
4953
+ await client.put(`/api/profiles/${args2.id}/files/${file}`, body);
4905
4954
  console.log(`saved ${file}`);
4906
4955
  } finally {
4907
4956
  try {
@@ -4926,14 +4975,14 @@ var updateCmd = defineCommand19({
4926
4975
  },
4927
4976
  skills: { type: "string", description: "Replacement default skills, comma-separated" }
4928
4977
  },
4929
- async run({ args }) {
4978
+ async run({ args: args2 }) {
4930
4979
  const body = {};
4931
- if (args.name !== void 0) body.name = args.name;
4932
- if (args.model !== void 0) body.defaultModel = args.model;
4933
- const mode = parseSkillsMode(args["skills-mode"]);
4980
+ if (args2.name !== void 0) body.name = args2.name;
4981
+ if (args2.model !== void 0) body.defaultModel = args2.model;
4982
+ const mode = parseSkillsMode(args2["skills-mode"]);
4934
4983
  if (mode !== void 0) body.skillsMode = mode;
4935
- if (args.skills !== void 0) {
4936
- body.defaultSkills = args.skills.split(",").map((s) => s.trim()).filter(Boolean);
4984
+ if (args2.skills !== void 0) {
4985
+ body.defaultSkills = args2.skills.split(",").map((s) => s.trim()).filter(Boolean);
4937
4986
  }
4938
4987
  if (Object.keys(body).length === 0) {
4939
4988
  throw new Error(
@@ -4941,7 +4990,7 @@ var updateCmd = defineCommand19({
4941
4990
  );
4942
4991
  }
4943
4992
  const client = createClient2();
4944
- const profile = await client.patch(`/api/profiles/${args.id}`, body);
4993
+ const profile = await client.patch(`/api/profiles/${args2.id}`, body);
4945
4994
  console.log(`updated profile ${profile.id}`);
4946
4995
  }
4947
4996
  });
@@ -4950,10 +4999,10 @@ var deleteCmd2 = defineCommand19({
4950
4999
  args: {
4951
5000
  id: { type: "positional", required: true }
4952
5001
  },
4953
- async run({ args }) {
5002
+ async run({ args: args2 }) {
4954
5003
  const client = createClient2();
4955
- await client.del(`/api/profiles/${args.id}`);
4956
- console.log(`deleted profile ${args.id}`);
5004
+ await client.del(`/api/profiles/${args2.id}`);
5005
+ console.log(`deleted profile ${args2.id}`);
4957
5006
  }
4958
5007
  });
4959
5008
  var profileCommand = defineCommand19({
@@ -4978,10 +5027,10 @@ var listCmd7 = defineCommand20({
4978
5027
  args: {
4979
5028
  enabled: { type: "boolean", description: "Show only enabled providers" }
4980
5029
  },
4981
- async run({ args }) {
5030
+ async run({ args: args2 }) {
4982
5031
  const client = createClient2();
4983
5032
  const { providers } = await client.get("/api/config/providers");
4984
- const filtered = args.enabled ? providers.filter((p) => p.enabled) : providers;
5033
+ const filtered = args2.enabled ? providers.filter((p) => p.enabled) : providers;
4985
5034
  if (filtered.length === 0) {
4986
5035
  console.log("(no providers to show)");
4987
5036
  return;
@@ -5004,12 +5053,12 @@ var modelsCmd = defineCommand20({
5004
5053
  args: {
5005
5054
  name: { type: "positional", required: true, description: "Provider name" }
5006
5055
  },
5007
- async run({ args }) {
5056
+ async run({ args: args2 }) {
5008
5057
  const client = createClient2();
5009
5058
  const { providers } = await client.get("/api/config/providers");
5010
- const p = providers.find((x) => x.id === args.name);
5059
+ const p = providers.find((x) => x.id === args2.name);
5011
5060
  if (!p) {
5012
- console.error(`unknown provider: ${args.name}`);
5061
+ console.error(`unknown provider: ${args2.name}`);
5013
5062
  process.exit(1);
5014
5063
  }
5015
5064
  console.log(`# ${p.id} (${p.enabled ? "enabled" : "disabled"})`);
@@ -5041,15 +5090,15 @@ var modelsSetCmd = defineCommand20({
5041
5090
  description: "Comma-separated model list (empty string clears the list)"
5042
5091
  }
5043
5092
  },
5044
- async run({ args }) {
5093
+ async run({ args: args2 }) {
5045
5094
  const client = createClient2();
5046
- const models = args.models.split(",").map((s) => s.trim()).filter(Boolean);
5095
+ const models = args2.models.split(",").map((s) => s.trim()).filter(Boolean);
5047
5096
  const body = { models };
5048
5097
  const saved = await client.put(
5049
- `/api/config/providers/${encodeURIComponent(args.name)}/models`,
5098
+ `/api/config/providers/${encodeURIComponent(args2.name)}/models`,
5050
5099
  body
5051
5100
  );
5052
- console.log(`saved ${saved.models.length} curated model(s) for ${args.name}`);
5101
+ console.log(`saved ${saved.models.length} curated model(s) for ${args2.name}`);
5053
5102
  for (const m of saved.models) console.log(` ${m}`);
5054
5103
  }
5055
5104
  });
@@ -5058,10 +5107,10 @@ var enableCmd2 = defineCommand20({
5058
5107
  args: {
5059
5108
  name: { type: "positional", required: true, description: "Provider id (e.g. anthropic)" }
5060
5109
  },
5061
- async run({ args }) {
5110
+ async run({ args: args2 }) {
5062
5111
  const client = createClient2();
5063
5112
  const res = await client.put(
5064
- `/api/config/providers/${encodeURIComponent(args.name)}/enabled`,
5113
+ `/api/config/providers/${encodeURIComponent(args2.name)}/enabled`,
5065
5114
  { enabled: true }
5066
5115
  );
5067
5116
  console.log(`${res.name}: enabled`);
@@ -5075,10 +5124,10 @@ var disableCmd2 = defineCommand20({
5075
5124
  args: {
5076
5125
  name: { type: "positional", required: true, description: "Provider id" }
5077
5126
  },
5078
- async run({ args }) {
5127
+ async run({ args: args2 }) {
5079
5128
  const client = createClient2();
5080
5129
  const res = await client.put(
5081
- `/api/config/providers/${encodeURIComponent(args.name)}/enabled`,
5130
+ `/api/config/providers/${encodeURIComponent(args2.name)}/enabled`,
5082
5131
  { enabled: false }
5083
5132
  );
5084
5133
  console.log(`${res.name}: disabled`);
@@ -5094,10 +5143,10 @@ var testCmd2 = defineCommand20({
5094
5143
  },
5095
5144
  message: { type: "string", description: 'Message text (default "say hi briefly")' }
5096
5145
  },
5097
- async run({ args }) {
5146
+ async run({ args: args2 }) {
5098
5147
  const client = createClient2();
5099
- const body = { model: args.model, message: args.message };
5100
- console.log(`-> ${args.model}: ${args.message ?? "say hi briefly"}`);
5148
+ const body = { model: args2.model, message: args2.message };
5149
+ console.log(`-> ${args2.model}: ${args2.message ?? "say hi briefly"}`);
5101
5150
  const res = await client.post("/api/providers/test", body);
5102
5151
  console.log(`<- ${res.content}`);
5103
5152
  if (res.usage) {
@@ -5130,12 +5179,12 @@ var list6 = defineCommand21({
5130
5179
  offset: { type: "string", default: "0" },
5131
5180
  json: { type: "boolean" }
5132
5181
  },
5133
- async run({ args }) {
5134
- const query = new URLSearchParams({ limit: args.limit, offset: args.offset });
5135
- if (args.team) query.set("teamId", args.team);
5136
- if (args.agent) query.set("agentId", args.agent);
5182
+ async run({ args: args2 }) {
5183
+ const query = new URLSearchParams({ limit: args2.limit, offset: args2.offset });
5184
+ if (args2.team) query.set("teamId", args2.team);
5185
+ if (args2.agent) query.set("agentId", args2.agent);
5137
5186
  const body = await createClient2().get(`/api/results?${query}`);
5138
- if (args.json) return console.log(JSON.stringify(body, null, 2));
5187
+ if (args2.json) return console.log(JSON.stringify(body, null, 2));
5139
5188
  if (!body.results.length) return console.log("(no saved results)");
5140
5189
  for (const line of columnize([
5141
5190
  ["id", "filename", "bytes", "team", "agent", "created"],
@@ -5155,9 +5204,9 @@ var list6 = defineCommand21({
5155
5204
  var show4 = defineCommand21({
5156
5205
  meta: { name: "show", description: "Inspect a saved result and its provenance" },
5157
5206
  args: { id: idArg, json: { type: "boolean" } },
5158
- async run({ args }) {
5207
+ async run({ args: args2 }) {
5159
5208
  const { result } = await createClient2().get(
5160
- `/api/results/${encodeURIComponent(args.id)}`
5209
+ `/api/results/${encodeURIComponent(args2.id)}`
5161
5210
  );
5162
5211
  console.log(JSON.stringify(result, null, 2));
5163
5212
  }
@@ -5172,21 +5221,21 @@ var download = defineCommand21({
5172
5221
  description: "Destination path; existing files are never overwritten"
5173
5222
  }
5174
5223
  },
5175
- async run({ args }) {
5224
+ async run({ args: args2 }) {
5176
5225
  const bytes = await createClient2().binary(
5177
- `/api/results/${encodeURIComponent(args.id)}/download`
5226
+ `/api/results/${encodeURIComponent(args2.id)}/download`
5178
5227
  );
5179
- const fd = openSync3(args.output, "wx", 384);
5228
+ const fd = openSync3(args2.output, "wx", 384);
5180
5229
  try {
5181
5230
  writeFileSync5(fd, bytes);
5182
5231
  fsyncSync3(fd);
5183
5232
  } catch (error) {
5184
5233
  closeSync3(fd);
5185
- unlinkSync(args.output);
5234
+ unlinkSync(args2.output);
5186
5235
  throw error;
5187
5236
  }
5188
5237
  closeSync3(fd);
5189
- console.log(`Saved ${bytes.byteLength} bytes to ${args.output}`);
5238
+ console.log(`Saved ${bytes.byteLength} bytes to ${args2.output}`);
5190
5239
  }
5191
5240
  });
5192
5241
  var rm = defineCommand21({
@@ -5195,9 +5244,9 @@ var rm = defineCommand21({
5195
5244
  description: "Delete saved bytes; retained history will report the result as deleted"
5196
5245
  },
5197
5246
  args: { id: idArg, yes: { type: "boolean" } },
5198
- async run({ args }) {
5199
- if (!args.yes) throw new Error("Pass --yes to permanently delete the saved file bytes");
5200
- await createClient2().del(`/api/results/${encodeURIComponent(args.id)}`);
5247
+ async run({ args: args2 }) {
5248
+ if (!args2.yes) throw new Error("Pass --yes to permanently delete the saved file bytes");
5249
+ await createClient2().del(`/api/results/${encodeURIComponent(args2.id)}`);
5201
5250
  console.log("Saved file deleted; historical references retain a deletion receipt.");
5202
5251
  }
5203
5252
  });
@@ -5218,14 +5267,14 @@ var sendCommand = defineCommand22({
5218
5267
  to: { type: "positional", required: true, description: "Recipient agent id" },
5219
5268
  message: { type: "positional", required: true, description: "Message text" }
5220
5269
  },
5221
- async run({ args }) {
5270
+ async run({ args: args2 }) {
5222
5271
  const client = createClient2();
5223
5272
  const body = {
5224
- from: args.from,
5225
- payload: { text: args.message }
5273
+ from: args2.from,
5274
+ payload: { text: args2.message }
5226
5275
  };
5227
5276
  const result = await client.post(
5228
- `/api/agents/${args.to}/messages`,
5277
+ `/api/agents/${args2.to}/messages`,
5229
5278
  body
5230
5279
  );
5231
5280
  if ("approvalId" in result) {
@@ -5258,17 +5307,17 @@ var serveCommand = defineCommand23({
5258
5307
  description: "Host (default 127.0.0.1). Put a TLS proxy in front before binding 0.0.0.0"
5259
5308
  }
5260
5309
  },
5261
- async run({ args }) {
5310
+ async run({ args: args2 }) {
5262
5311
  if (!existsSync5(daemonEntry2)) {
5263
5312
  throw new Error(
5264
5313
  `bazilion daemon not found at ${daemonEntry2}. Are you running from a development checkout?`
5265
5314
  );
5266
5315
  }
5267
5316
  const env = { ...process.env };
5268
- if (args.port) env.PORT = args.port;
5269
- if (args.host) env.HOST = args.host;
5270
- const host = args.host ?? "127.0.0.1";
5271
- const port = args.port ?? "4321";
5317
+ if (args2.port) env.PORT = args2.port;
5318
+ if (args2.host) env.HOST = args2.host;
5319
+ const host = args2.host ?? "127.0.0.1";
5320
+ const port = args2.port ?? "4321";
5272
5321
  if (host !== "127.0.0.1" && host !== "localhost" && host !== "::1") {
5273
5322
  console.error("");
5274
5323
  console.error(`\u26A0 binding to ${host} \u2014 the daemon is now reachable beyond loopback.`);
@@ -5295,17 +5344,17 @@ var serveCommand = defineCommand23({
5295
5344
  signalled = true;
5296
5345
  });
5297
5346
  process.on("SIGTERM", onSigterm);
5298
- await new Promise((resolve5, reject) => {
5347
+ await new Promise((resolve6, reject) => {
5299
5348
  proc.on("error", (err) => reject(err));
5300
5349
  proc.on("close", (code) => {
5301
5350
  if (signalled) {
5302
5351
  process.exitCode = 0;
5303
- resolve5();
5352
+ resolve6();
5304
5353
  } else if (code === 0 || code === null) {
5305
- resolve5();
5354
+ resolve6();
5306
5355
  } else {
5307
5356
  process.exitCode = code;
5308
- resolve5();
5357
+ resolve6();
5309
5358
  }
5310
5359
  });
5311
5360
  });
@@ -5339,9 +5388,9 @@ var listCmd8 = defineCommand24({
5339
5388
  var revokeCmd = defineCommand24({
5340
5389
  meta: { name: "revoke", description: "Revoke one browser session" },
5341
5390
  args: { id: { type: "positional", required: true } },
5342
- async run({ args }) {
5343
- await createClient2().del(`/api/sessions/${encodeURIComponent(args.id)}`);
5344
- console.log(`revoked browser session ${args.id}`);
5391
+ async run({ args: args2 }) {
5392
+ await createClient2().del(`/api/sessions/${encodeURIComponent(args2.id)}`);
5393
+ console.log(`revoked browser session ${args2.id}`);
5345
5394
  }
5346
5395
  });
5347
5396
  var sessionCommand = defineCommand24({
@@ -5351,7 +5400,7 @@ var sessionCommand = defineCommand24({
5351
5400
 
5352
5401
  // src/commands/skill.ts
5353
5402
  import { existsSync as existsSync6, readFileSync as readFileSync8, statSync as statSync2 } from "fs";
5354
- import { basename as basename5, resolve as resolve3 } from "path";
5403
+ import { basename as basename5, resolve as resolve4 } from "path";
5355
5404
  import { defineCommand as defineCommand25 } from "citty";
5356
5405
  function printFindings(findings, prefix = " ") {
5357
5406
  for (const f of findings) {
@@ -5364,10 +5413,10 @@ var listCmd9 = defineCommand25({
5364
5413
  args: {
5365
5414
  agent: { type: "string", description: "Filter to skills attached to this agent" }
5366
5415
  },
5367
- async run({ args }) {
5416
+ async run({ args: args2 }) {
5368
5417
  const client = createClient2();
5369
- if (args.agent) {
5370
- const set = await client.get(`/api/agents/${args.agent}/skills`);
5418
+ if (args2.agent) {
5419
+ const set = await client.get(`/api/agents/${args2.agent}/skills`);
5371
5420
  if (set.resolved.length === 0 && set.missing.length === 0) {
5372
5421
  console.log("(no skills attached to this agent)");
5373
5422
  return;
@@ -5413,10 +5462,10 @@ var importCmd = defineCommand25({
5413
5462
  },
5414
5463
  force: { type: "boolean", description: "Overwrite existing skills" }
5415
5464
  },
5416
- async run({ args }) {
5465
+ async run({ args: args2 }) {
5417
5466
  const client = createClient2();
5418
- const absFrom = resolve3(args.from);
5419
- const isLocalZip = args.from.toLowerCase().endsWith(".zip") && existsSync6(absFrom) && statSync2(absFrom).isFile();
5467
+ const absFrom = resolve4(args2.from);
5468
+ const isLocalZip = args2.from.toLowerCase().endsWith(".zip") && existsSync6(absFrom) && statSync2(absFrom).isFile();
5420
5469
  let result;
5421
5470
  try {
5422
5471
  if (isLocalZip) {
@@ -5424,12 +5473,12 @@ var importCmd = defineCommand25({
5424
5473
  const file = new File([bytes], basename5(absFrom), { type: "application/zip" });
5425
5474
  const fd = new FormData();
5426
5475
  fd.set("file", file);
5427
- if (args.force) fd.set("force", "true");
5476
+ if (args2.force) fd.set("force", "true");
5428
5477
  result = await client.postMultipart("/api/skills/import", fd);
5429
5478
  } else {
5430
5479
  const body = {
5431
- source: args.from,
5432
- force: args.force
5480
+ source: args2.from,
5481
+ force: args2.force
5433
5482
  };
5434
5483
  result = await client.post("/api/skills/import", body);
5435
5484
  }
@@ -5474,10 +5523,10 @@ var rmCmd4 = defineCommand25({
5474
5523
  args: {
5475
5524
  name: { type: "positional", required: true }
5476
5525
  },
5477
- async run({ args }) {
5526
+ async run({ args: args2 }) {
5478
5527
  const client = createClient2();
5479
- await client.del(`/api/skills/${encodeURIComponent(args.name)}`);
5480
- console.log(`removed skill ${args.name}`);
5528
+ await client.del(`/api/skills/${encodeURIComponent(args2.name)}`);
5529
+ console.log(`removed skill ${args2.name}`);
5481
5530
  }
5482
5531
  });
5483
5532
  var skillCommand = defineCommand25({
@@ -5490,13 +5539,50 @@ var skillCommand = defineCommand25({
5490
5539
  });
5491
5540
 
5492
5541
  // src/commands/team.ts
5493
- import { readFileSync as readFileSync10 } from "fs";
5542
+ import { readFileSync as readFileSync11 } from "fs";
5494
5543
  import { stdin as stdin2 } from "process";
5495
- import { defineCommand as defineCommand27 } from "citty";
5544
+ import { defineCommand as defineCommand28 } from "citty";
5496
5545
 
5497
- // src/commands/team-policy.ts
5546
+ // src/commands/team-environment.ts
5498
5547
  import { readFileSync as readFileSync9 } from "fs";
5499
5548
  import { defineCommand as defineCommand26 } from "citty";
5549
+ var args = { id: { type: "positional", required: true, description: "Team slug" } };
5550
+ var teamEnvironmentCommand = defineCommand26({
5551
+ meta: {
5552
+ name: "environment",
5553
+ description: "Optional Team runtime defaults; Agents discover and run commands during tasks"
5554
+ },
5555
+ subCommands: {
5556
+ show: defineCommand26({
5557
+ args,
5558
+ async run({ args: args2 }) {
5559
+ console.log(JSON.stringify(await createClient2().codingEnvironment.show(args2.id), null, 2));
5560
+ }
5561
+ }),
5562
+ configure: defineCommand26({
5563
+ args: {
5564
+ ...args,
5565
+ file: {
5566
+ type: "string",
5567
+ required: true,
5568
+ description: "JSON {expectedRevision,config:{image,cwd,env}}"
5569
+ }
5570
+ },
5571
+ async run({ args: args2 }) {
5572
+ const input = JSON.parse(
5573
+ readFileSync9(args2.file, "utf8")
5574
+ );
5575
+ console.log(
5576
+ JSON.stringify(await createClient2().codingEnvironment.configure(args2.id, input), null, 2)
5577
+ );
5578
+ }
5579
+ })
5580
+ }
5581
+ });
5582
+
5583
+ // src/commands/team-policy.ts
5584
+ import { readFileSync as readFileSync10 } from "fs";
5585
+ import { defineCommand as defineCommand27 } from "citty";
5500
5586
 
5501
5587
  // src/team-interchange.ts
5502
5588
  var TEAM_POLICY_INTERCHANGE_VERSION = 1;
@@ -5712,7 +5798,7 @@ function edgeDiff(before, after) {
5712
5798
  // src/commands/team-policy.ts
5713
5799
  function readJson(path) {
5714
5800
  try {
5715
- return JSON.parse(readFileSync9(path, "utf8"));
5801
+ return JSON.parse(readFileSync10(path, "utf8"));
5716
5802
  } catch (error) {
5717
5803
  throw new Error(`invalid JSON: ${error.message}`);
5718
5804
  }
@@ -5744,30 +5830,30 @@ function printPolicy(detail) {
5744
5830
  console.log(line);
5745
5831
  }
5746
5832
  }
5747
- var show5 = defineCommand26({
5833
+ var show5 = defineCommand27({
5748
5834
  meta: { name: "show", description: "Show the one effective live policy for a Team" },
5749
5835
  args: {
5750
5836
  team: { type: "positional", required: true },
5751
5837
  json: { type: "boolean", description: "Emit the canonical aggregate as JSON" }
5752
5838
  },
5753
- async run({ args }) {
5839
+ async run({ args: args2 }) {
5754
5840
  const detail = await createClient2().get(
5755
- `/api/teams/${encodeURIComponent(args.team)}/policy`
5841
+ `/api/teams/${encodeURIComponent(args2.team)}/policy`
5756
5842
  );
5757
- if (args.json) console.log(JSON.stringify(detail, null, 2));
5843
+ if (args2.json) console.log(JSON.stringify(detail, null, 2));
5758
5844
  else printPolicy(detail);
5759
5845
  }
5760
5846
  });
5761
- var exportCommand = defineCommand26({
5847
+ var exportCommand = defineCommand27({
5762
5848
  meta: { name: "export", description: "Export a revisioned Team policy document" },
5763
5849
  args: { team: { type: "positional", required: true } },
5764
- async run({ args }) {
5850
+ async run({ args: args2 }) {
5765
5851
  const detail = await createClient2().get(
5766
- `/api/teams/${encodeURIComponent(args.team)}/policy`
5852
+ `/api/teams/${encodeURIComponent(args2.team)}/policy`
5767
5853
  );
5768
5854
  console.log(
5769
5855
  JSON.stringify(
5770
- exportTeamPolicy(args.team, detail.teamPolicy.revision, detail.edges),
5856
+ exportTeamPolicy(args2.team, detail.teamPolicy.revision, detail.edges),
5771
5857
  null,
5772
5858
  2
5773
5859
  )
@@ -5782,7 +5868,7 @@ function printEdgeDiff(current, edges) {
5782
5868
  for (const value of diff2.added) console.log(` + ${value}`);
5783
5869
  for (const value of diff2.removed) console.log(` - ${value}`);
5784
5870
  }
5785
- var importCommand = defineCommand26({
5871
+ var importCommand = defineCommand27({
5786
5872
  meta: {
5787
5873
  name: "import",
5788
5874
  description: "Validate, diff, and explicitly replace a Team policy"
@@ -5805,22 +5891,22 @@ var importCommand = defineCommand26({
5805
5891
  description: "Second force confirmation: the freshly displayed current revision"
5806
5892
  }
5807
5893
  },
5808
- async run({ args }) {
5809
- if (args.force && !args.apply)
5894
+ async run({ args: args2 }) {
5895
+ if (args2.force && !args2.apply)
5810
5896
  throw new Error("--force requires --apply (interactive force is intentionally unsupported)");
5811
- const document = parseTeamPolicyDocument(readJson(args.file));
5812
- if (document.teamId !== args.team)
5813
- throw new Error(`document belongs to Team ${document.teamId}, not ${args.team}`);
5897
+ const document = parseTeamPolicyDocument(readJson(args2.file));
5898
+ if (document.teamId !== args2.team)
5899
+ throw new Error(`document belongs to Team ${document.teamId}, not ${args2.team}`);
5814
5900
  const client = createClient2();
5815
5901
  const current = await client.get(
5816
- `/api/teams/${encodeURIComponent(args.team)}/policy`
5902
+ `/api/teams/${encodeURIComponent(args2.team)}/policy`
5817
5903
  );
5818
5904
  printEdgeDiff(current, document.edges);
5819
- if (args["dry-run"]) return console.log("valid: no changes applied");
5820
- if (!args.apply) throw new Error("refusing mutation: review the diff, then pass --apply");
5821
- const supplied = args["expected-revision"] ? Number.parseInt(args["expected-revision"], 10) : document.expectedRevision;
5822
- const expectedRevision = args.force ? current.teamPolicy.revision : supplied;
5823
- if (args.force && Number.parseInt(args["confirm-current-revision"] ?? "", 10) !== current.teamPolicy.revision)
5905
+ if (args2["dry-run"]) return console.log("valid: no changes applied");
5906
+ if (!args2.apply) throw new Error("refusing mutation: review the diff, then pass --apply");
5907
+ const supplied = args2["expected-revision"] ? Number.parseInt(args2["expected-revision"], 10) : document.expectedRevision;
5908
+ const expectedRevision = args2.force ? current.teamPolicy.revision : supplied;
5909
+ if (args2.force && Number.parseInt(args2["confirm-current-revision"] ?? "", 10) !== current.teamPolicy.revision)
5824
5910
  throw new Error(
5825
5911
  `--force requires --confirm-current-revision ${current.teamPolicy.revision} after reviewing the fresh diff`
5826
5912
  );
@@ -5831,24 +5917,24 @@ var importCommand = defineCommand26({
5831
5917
  edges: document.edges
5832
5918
  };
5833
5919
  const updated = await client.put(
5834
- `/api/teams/${encodeURIComponent(args.team)}/policy`,
5920
+ `/api/teams/${encodeURIComponent(args2.team)}/policy`,
5835
5921
  body
5836
5922
  );
5837
- console.log(`updated Team ${args.team} policy to revision ${updated.teamPolicy.revision}`);
5923
+ console.log(`updated Team ${args2.team} policy to revision ${updated.teamPolicy.revision}`);
5838
5924
  }
5839
5925
  });
5840
- var diff = defineCommand26({
5926
+ var diff = defineCommand27({
5841
5927
  meta: { name: "diff", description: "Compare live policy with its retained baseline source" },
5842
5928
  args: {
5843
5929
  team: { type: "positional", required: true },
5844
5930
  json: { type: "boolean", description: "Emit canonical diff JSON" }
5845
5931
  },
5846
- async run({ args }) {
5932
+ async run({ args: args2 }) {
5847
5933
  const result = await createClient2().get(
5848
- `/api/teams/${encodeURIComponent(args.team)}/policy/diff`
5934
+ `/api/teams/${encodeURIComponent(args2.team)}/policy/diff`
5849
5935
  );
5850
- if (args.json) return console.log(JSON.stringify(result, null, 2));
5851
- console.log(`# Team ${args.team} source diff`);
5936
+ if (args2.json) return console.log(JSON.stringify(result, null, 2));
5937
+ console.log(`# Team ${args2.team} source diff`);
5852
5938
  console.log(
5853
5939
  `status: ${result.baseline ? result.sourceDiverged ? "source diverged" : "source current" : "no baseline"}`
5854
5940
  );
@@ -5861,7 +5947,7 @@ var diff = defineCommand26({
5861
5947
  );
5862
5948
  }
5863
5949
  });
5864
- var evaluate = defineCommand26({
5950
+ var evaluate = defineCommand27({
5865
5951
  meta: {
5866
5952
  name: "evaluate",
5867
5953
  description: "Evaluate a communication path without sending or recording a block"
@@ -5873,18 +5959,18 @@ var evaluate = defineCommand26({
5873
5959
  origin: { type: "string", default: "cli-diagnostic" },
5874
5960
  json: { type: "boolean", description: "Emit decision JSON" }
5875
5961
  },
5876
- async run({ args }) {
5962
+ async run({ args: args2 }) {
5877
5963
  const result = await createClient2().post(
5878
5964
  "/api/communication/evaluate",
5879
5965
  {
5880
- source: endpoint2(args.source, args.team),
5881
- target: endpoint2(args.target, args.team),
5882
- origin: args.origin,
5966
+ source: endpoint2(args2.source, args2.team),
5967
+ target: endpoint2(args2.target, args2.team),
5968
+ origin: args2.origin,
5883
5969
  attemptKind: "cli_evaluate",
5884
- attemptId: `diagnostic:${args.team}`
5970
+ attemptId: `diagnostic:${args2.team}`
5885
5971
  }
5886
5972
  );
5887
- if (args.json) return console.log(JSON.stringify(result, null, 2));
5973
+ if (args2.json) return console.log(JSON.stringify(result, null, 2));
5888
5974
  console.log(`${result.decision.toUpperCase()} ${result.channel}: ${result.reasonCode}`);
5889
5975
  console.log(result.reason);
5890
5976
  console.log(
@@ -5892,7 +5978,7 @@ var evaluate = defineCommand26({
5892
5978
  );
5893
5979
  }
5894
5980
  });
5895
- var blocks = defineCommand26({
5981
+ var blocks = defineCommand27({
5896
5982
  meta: { name: "blocks", description: "List paginated durable communication denials" },
5897
5983
  args: {
5898
5984
  team: { type: "positional", required: true },
@@ -5907,23 +5993,23 @@ var blocks = defineCommand26({
5907
5993
  to: { type: "string", description: "Epoch milliseconds or ISO timestamp" },
5908
5994
  json: { type: "boolean", description: "Emit page JSON including nextCursor" }
5909
5995
  },
5910
- async run({ args }) {
5911
- const query = new URLSearchParams({ limit: args.limit });
5996
+ async run({ args: args2 }) {
5997
+ const query = new URLSearchParams({ limit: args2.limit });
5912
5998
  for (const [key, value] of [
5913
- ["cursor", args.cursor],
5914
- ["source", args.source],
5915
- ["target", args.target],
5916
- ["channel", args.channel],
5917
- ["origin", args.origin],
5918
- ["reasonCode", args.reason],
5919
- ["from", args.from],
5920
- ["to", args.to]
5999
+ ["cursor", args2.cursor],
6000
+ ["source", args2.source],
6001
+ ["target", args2.target],
6002
+ ["channel", args2.channel],
6003
+ ["origin", args2.origin],
6004
+ ["reasonCode", args2.reason],
6005
+ ["from", args2.from],
6006
+ ["to", args2.to]
5921
6007
  ])
5922
6008
  if (value) query.set(key, value);
5923
6009
  const page = await createClient2().get(
5924
- `/api/teams/${encodeURIComponent(args.team)}/policy/blocks?${query}`
6010
+ `/api/teams/${encodeURIComponent(args2.team)}/policy/blocks?${query}`
5925
6011
  );
5926
- if (args.json) return console.log(JSON.stringify(page, null, 2));
6012
+ if (args2.json) return console.log(JSON.stringify(page, null, 2));
5927
6013
  if (!page.blocks.length) console.log("(no blocks)");
5928
6014
  else
5929
6015
  for (const line of columnize([
@@ -5941,7 +6027,7 @@ var blocks = defineCommand26({
5941
6027
  if (page.nextCursor) console.log(`next cursor: ${page.nextCursor}`);
5942
6028
  }
5943
6029
  });
5944
- var teamPolicyCommand = defineCommand26({
6030
+ var teamPolicyCommand = defineCommand27({
5945
6031
  meta: { name: "policy", description: "Inspect and manage the Team-owned live policy" },
5946
6032
  subCommands: {
5947
6033
  show: show5,
@@ -5954,7 +6040,7 @@ var teamPolicyCommand = defineCommand26({
5954
6040
  });
5955
6041
 
5956
6042
  // src/commands/team.ts
5957
- var addCmd2 = defineCommand27({
6043
+ var addCmd2 = defineCommand28({
5958
6044
  meta: {
5959
6045
  name: "add",
5960
6046
  description: "Register a team at ~/.bazilion/teams/<slug>/ (use --link to point at an existing tree)"
@@ -5967,18 +6053,18 @@ var addCmd2 = defineCommand27({
5967
6053
  description: "Absolute path of an existing directory; the team slot becomes a symlink to it"
5968
6054
  }
5969
6055
  },
5970
- async run({ args }) {
6056
+ async run({ args: args2 }) {
5971
6057
  const client = createClient2();
5972
6058
  const body = {
5973
- id: args.id,
5974
- ...args.name ? { name: args.name } : {},
5975
- ...args.link ? { link: args.link } : {}
6059
+ id: args2.id,
6060
+ ...args2.name ? { name: args2.name } : {},
6061
+ ...args2.link ? { link: args2.link } : {}
5976
6062
  };
5977
6063
  const g = await client.post("/api/teams", body);
5978
6064
  console.log(`registered team ${g.id} at ${g.path}`);
5979
6065
  }
5980
6066
  });
5981
- var listCmd10 = defineCommand27({
6067
+ var listCmd10 = defineCommand28({
5982
6068
  meta: { name: "list", description: "List teams" },
5983
6069
  async run() {
5984
6070
  const client = createClient2();
@@ -5991,20 +6077,20 @@ var listCmd10 = defineCommand27({
5991
6077
  for (const line of columnize(rows)) console.log(line);
5992
6078
  }
5993
6079
  });
5994
- var rmCmd5 = defineCommand27({
6080
+ var rmCmd5 = defineCommand28({
5995
6081
  meta: { name: "rm", description: "Remove a team registration" },
5996
6082
  args: {
5997
6083
  id: { type: "positional", required: true }
5998
6084
  },
5999
- async run({ args }) {
6085
+ async run({ args: args2 }) {
6000
6086
  const client = createClient2();
6001
6087
  const policy = await client.get(
6002
- `/api/teams/${encodeURIComponent(args.id)}/policy`
6088
+ `/api/teams/${encodeURIComponent(args2.id)}/policy`
6003
6089
  );
6004
6090
  await client.del(
6005
- `/api/teams/${encodeURIComponent(args.id)}?expectedTeamPolicyRevision=${policy.teamPolicy.revision}`
6091
+ `/api/teams/${encodeURIComponent(args2.id)}?expectedTeamPolicyRevision=${policy.teamPolicy.revision}`
6006
6092
  );
6007
- console.log(`removed team ${args.id}`);
6093
+ console.log(`removed team ${args2.id}`);
6008
6094
  }
6009
6095
  });
6010
6096
  async function readStdin() {
@@ -6012,17 +6098,17 @@ async function readStdin() {
6012
6098
  for await (const chunk of stdin2) chunks.push(chunk);
6013
6099
  return Buffer.concat(chunks).toString("utf8");
6014
6100
  }
6015
- var userMdShowCmd = defineCommand27({
6101
+ var userMdShowCmd = defineCommand28({
6016
6102
  meta: { name: "show", description: "Print the team's USER.md" },
6017
6103
  args: { id: { type: "positional", required: true } },
6018
- async run({ args }) {
6104
+ async run({ args: args2 }) {
6019
6105
  const client = createClient2();
6020
- const g = await client.get(`/api/teams/${args.id}`);
6106
+ const g = await client.get(`/api/teams/${args2.id}`);
6021
6107
  process.stdout.write(g.userMd);
6022
6108
  if (g.userMd && !g.userMd.endsWith("\n")) process.stdout.write("\n");
6023
6109
  }
6024
6110
  });
6025
- var userMdSetCmd = defineCommand27({
6111
+ var userMdSetCmd = defineCommand28({
6026
6112
  meta: {
6027
6113
  name: "set",
6028
6114
  description: "Replace the team's USER.md (from --file, --from-stdin, or inline text)"
@@ -6033,32 +6119,32 @@ var userMdSetCmd = defineCommand27({
6033
6119
  "from-stdin": { type: "boolean", description: "Read content from stdin" },
6034
6120
  text: { type: "string", description: "Inline content" }
6035
6121
  },
6036
- async run({ args }) {
6122
+ async run({ args: args2 }) {
6037
6123
  let content;
6038
- if (args["from-stdin"]) content = await readStdin();
6039
- else if (args.file) content = readFileSync10(args.file, "utf8");
6040
- else if (args.text !== void 0) content = args.text;
6124
+ if (args2["from-stdin"]) content = await readStdin();
6125
+ else if (args2.file) content = readFileSync11(args2.file, "utf8");
6126
+ else if (args2.text !== void 0) content = args2.text;
6041
6127
  else {
6042
6128
  console.error("team user-md set: provide --file, --from-stdin, or --text");
6043
6129
  process.exit(2);
6044
6130
  }
6045
6131
  const client = createClient2();
6046
6132
  const body = { userMd: content };
6047
- await client.put(`/api/teams/${args.id}/user-md`, body);
6048
- console.log(`updated USER.md for team ${args.id} (${content.length} bytes)`);
6133
+ await client.put(`/api/teams/${args2.id}/user-md`, body);
6134
+ console.log(`updated USER.md for team ${args2.id} (${content.length} bytes)`);
6049
6135
  }
6050
6136
  });
6051
- var userMdClearCmd = defineCommand27({
6137
+ var userMdClearCmd = defineCommand28({
6052
6138
  meta: { name: "clear", description: "Clear the team's USER.md to empty" },
6053
6139
  args: { id: { type: "positional", required: true } },
6054
- async run({ args }) {
6140
+ async run({ args: args2 }) {
6055
6141
  const client = createClient2();
6056
6142
  const body = { userMd: "" };
6057
- await client.put(`/api/teams/${args.id}/user-md`, body);
6058
- console.log(`cleared USER.md for team ${args.id}`);
6143
+ await client.put(`/api/teams/${args2.id}/user-md`, body);
6144
+ console.log(`cleared USER.md for team ${args2.id}`);
6059
6145
  }
6060
6146
  });
6061
- var userMdCmd = defineCommand27({
6147
+ var userMdCmd = defineCommand28({
6062
6148
  meta: { name: "user-md", description: "View or edit a team's USER.md" },
6063
6149
  subCommands: {
6064
6150
  show: userMdShowCmd,
@@ -6066,16 +6152,16 @@ var userMdCmd = defineCommand27({
6066
6152
  clear: userMdClearCmd
6067
6153
  }
6068
6154
  });
6069
- var topicFormatShowCmd = defineCommand27({
6155
+ var topicFormatShowCmd = defineCommand28({
6070
6156
  meta: { name: "show", description: "Print the team's Telegram topic-name template" },
6071
6157
  args: { id: { type: "positional", required: true } },
6072
- async run({ args }) {
6158
+ async run({ args: args2 }) {
6073
6159
  const client = createClient2();
6074
- const g = await client.get(`/api/teams/${args.id}`);
6160
+ const g = await client.get(`/api/teams/${args2.id}`);
6075
6161
  console.log(g.telegramTopicNameFormat ?? "(default naming)");
6076
6162
  }
6077
6163
  });
6078
- var topicFormatSetCmd = defineCommand27({
6164
+ var topicFormatSetCmd = defineCommand28({
6079
6165
  meta: {
6080
6166
  name: "set",
6081
6167
  description: "Set the topic-name template. Tokens: {agent.name} {team.name} {team.slug} (must include {agent.name})"
@@ -6088,24 +6174,24 @@ var topicFormatSetCmd = defineCommand27({
6088
6174
  description: 'e.g. "{team.name} / {agent.name}"'
6089
6175
  }
6090
6176
  },
6091
- async run({ args }) {
6177
+ async run({ args: args2 }) {
6092
6178
  const client = createClient2();
6093
- const body = { format: args.format };
6094
- const g = await client.put(`/api/teams/${args.id}/topic-format`, body);
6095
- console.log(`set topic-name template for team ${args.id}: ${g.telegramTopicNameFormat}`);
6179
+ const body = { format: args2.format };
6180
+ const g = await client.put(`/api/teams/${args2.id}/topic-format`, body);
6181
+ console.log(`set topic-name template for team ${args2.id}: ${g.telegramTopicNameFormat}`);
6096
6182
  }
6097
6183
  });
6098
- var topicFormatClearCmd = defineCommand27({
6184
+ var topicFormatClearCmd = defineCommand28({
6099
6185
  meta: { name: "clear", description: "Clear the template (revert to built-in naming)" },
6100
6186
  args: { id: { type: "positional", required: true } },
6101
- async run({ args }) {
6187
+ async run({ args: args2 }) {
6102
6188
  const client = createClient2();
6103
6189
  const body = { format: null };
6104
- await client.put(`/api/teams/${args.id}/topic-format`, body);
6105
- console.log(`cleared topic-name template for team ${args.id}`);
6190
+ await client.put(`/api/teams/${args2.id}/topic-format`, body);
6191
+ console.log(`cleared topic-name template for team ${args2.id}`);
6106
6192
  }
6107
6193
  });
6108
- var topicFormatCmd = defineCommand27({
6194
+ var topicFormatCmd = defineCommand28({
6109
6195
  meta: {
6110
6196
  name: "topic-format",
6111
6197
  description: "View or edit a team's Telegram forum-topic name template"
@@ -6116,9 +6202,58 @@ var topicFormatCmd = defineCommand27({
6116
6202
  clear: topicFormatClearCmd
6117
6203
  }
6118
6204
  });
6119
- var teamCommand = defineCommand27({
6205
+ var contextCmd = defineCommand28({
6206
+ meta: {
6207
+ name: "context",
6208
+ description: "Inspect repository instructions, Git state and command suggestions"
6209
+ },
6210
+ args: {
6211
+ id: { type: "positional", required: true, description: "Team slug" },
6212
+ target: { type: "string", description: "Contained relative file or directory" },
6213
+ json: { type: "boolean", description: "Print the complete captured report as JSON" }
6214
+ },
6215
+ async run({ args: args2 }) {
6216
+ const report = await createClient2().repositoryContext(args2.id, { target: args2.target });
6217
+ if (args2.json) {
6218
+ console.log(JSON.stringify(report, null, 2));
6219
+ return;
6220
+ }
6221
+ const safe2 = (value) => [...value].map(
6222
+ (char) => char.charCodeAt(0) < 32 || char.charCodeAt(0) === 127 ? JSON.stringify(char).slice(1, -1) : char
6223
+ ).join("");
6224
+ console.log(
6225
+ `Team ${safe2(report.teamId)} \xB7 target ${safe2(report.target)} \xB7 captured ${new Date(report.capturedAt).toISOString()}`
6226
+ );
6227
+ console.log(`Repository instructions: ${report.instructions.state}`);
6228
+ for (const file of report.instructions.files)
6229
+ console.log(
6230
+ ` ${safe2(file.path)} (scope ${safe2(file.scope)}, precedence ${file.precedence}, SHA-256 ${file.sha256})`
6231
+ );
6232
+ console.log(
6233
+ `Git: ${report.git.state}${report.git.headState ? ` \xB7 ${report.git.headState} ${safe2(report.git.branch ?? report.git.head ?? "")}` : ""}`
6234
+ );
6235
+ if (report.git.state === "available")
6236
+ console.log(
6237
+ ` staged ${report.git.staged}, unstaged ${report.git.unstaged}, untracked ${report.git.untracked}, conflicted ${report.git.conflicted}`
6238
+ );
6239
+ console.log(`Command suggestions: ${report.commands.state} (not executed)`);
6240
+ for (const candidate of report.commands.candidates)
6241
+ console.log(
6242
+ ` ${safe2(candidate.command)} \u2014 ${safe2(candidate.source)} ${safe2(candidate.location)}, cwd ${safe2(candidate.cwd)}`
6243
+ );
6244
+ for (const issue of [
6245
+ ...report.instructions.issues,
6246
+ ...report.commands.issues,
6247
+ ...report.git.issues
6248
+ ])
6249
+ console.log(` ${issue.code}${issue.path ? `: ${safe2(issue.path)}` : ""} \u2014 ${issue.message}`);
6250
+ }
6251
+ });
6252
+ var teamCommand = defineCommand28({
6120
6253
  meta: { name: "team", description: "Manage teams (collaboration contexts)" },
6121
6254
  subCommands: {
6255
+ environment: teamEnvironmentCommand,
6256
+ context: contextCmd,
6122
6257
  add: addCmd2,
6123
6258
  list: listCmd10,
6124
6259
  rm: rmCmd5,
@@ -6129,11 +6264,11 @@ var teamCommand = defineCommand27({
6129
6264
  });
6130
6265
 
6131
6266
  // src/commands/team-template.ts
6132
- import { readFileSync as readFileSync11 } from "fs";
6133
- import { defineCommand as defineCommand28 } from "citty";
6267
+ import { readFileSync as readFileSync12 } from "fs";
6268
+ import { defineCommand as defineCommand29 } from "citty";
6134
6269
  function jsonFile(path) {
6135
6270
  try {
6136
- return JSON.parse(readFileSync11(path, "utf8"));
6271
+ return JSON.parse(readFileSync12(path, "utf8"));
6137
6272
  } catch (error) {
6138
6273
  throw new Error(`invalid JSON: ${error.message}`);
6139
6274
  }
@@ -6158,12 +6293,12 @@ function printTeam(detail) {
6158
6293
  console.log(line);
6159
6294
  }
6160
6295
  }
6161
- var list7 = defineCommand28({
6296
+ var list7 = defineCommand29({
6162
6297
  meta: { name: "list", description: "List canonical Team templates" },
6163
6298
  args: { json: { type: "boolean", description: "Emit stable JSON" } },
6164
- async run({ args }) {
6299
+ async run({ args: args2 }) {
6165
6300
  const rows = await createClient2().get("/api/team-templates");
6166
- if (args.json) return console.log(JSON.stringify(rows, null, 2));
6301
+ if (args2.json) return console.log(JSON.stringify(rows, null, 2));
6167
6302
  if (!rows.length) return console.log("(no Team templates)");
6168
6303
  for (const line of columnize([
6169
6304
  ["id", "revision", "slots", "name"],
@@ -6172,29 +6307,29 @@ var list7 = defineCommand28({
6172
6307
  console.log(line);
6173
6308
  }
6174
6309
  });
6175
- var show6 = defineCommand28({
6310
+ var show6 = defineCommand29({
6176
6311
  meta: { name: "show", description: "Show a canonical Team template" },
6177
6312
  args: {
6178
6313
  id: { type: "positional", required: true },
6179
6314
  json: { type: "boolean", description: "Emit the canonical API aggregate" }
6180
6315
  },
6181
- async run({ args }) {
6316
+ async run({ args: args2 }) {
6182
6317
  const detail = await createClient2().get(
6183
- `/api/team-templates/${encodeURIComponent(args.id)}`
6318
+ `/api/team-templates/${encodeURIComponent(args2.id)}`
6184
6319
  );
6185
- if (args.json) console.log(JSON.stringify(detail, null, 2));
6320
+ if (args2.json) console.log(JSON.stringify(detail, null, 2));
6186
6321
  else printTeam(detail);
6187
6322
  }
6188
6323
  });
6189
- var exportCommand2 = defineCommand28({
6324
+ var exportCommand2 = defineCommand29({
6190
6325
  meta: {
6191
6326
  name: "export",
6192
6327
  description: "Export a portable versioned Team-template document to stdout"
6193
6328
  },
6194
6329
  args: { id: { type: "positional", required: true } },
6195
- async run({ args }) {
6330
+ async run({ args: args2 }) {
6196
6331
  const detail = await createClient2().get(
6197
- `/api/team-templates/${encodeURIComponent(args.id)}`
6332
+ `/api/team-templates/${encodeURIComponent(args2.id)}`
6198
6333
  );
6199
6334
  console.log(JSON.stringify(exportTeamDocument(detail), null, 2));
6200
6335
  }
@@ -6226,7 +6361,7 @@ function printImportDiff(current, document) {
6226
6361
  for (const value of diff2.added) console.log(` + ${value}`);
6227
6362
  for (const value of diff2.removed) console.log(` - ${value}`);
6228
6363
  }
6229
- var importCommand2 = defineCommand28({
6364
+ var importCommand2 = defineCommand29({
6230
6365
  meta: {
6231
6366
  name: "import",
6232
6367
  description: "Validate, diff, and explicitly apply a portable Team-template document"
@@ -6248,10 +6383,10 @@ var importCommand2 = defineCommand28({
6248
6383
  description: "Second force confirmation: the freshly displayed current revision"
6249
6384
  }
6250
6385
  },
6251
- async run({ args }) {
6252
- if (args.force && !args.apply)
6386
+ async run({ args: args2 }) {
6387
+ if (args2.force && !args2.apply)
6253
6388
  throw new Error("--force requires --apply (interactive force is intentionally unsupported)");
6254
- const document = parseTeamDocument(jsonFile(args.file));
6389
+ const document = parseTeamDocument(jsonFile(args2.file));
6255
6390
  const client = createClient2();
6256
6391
  let current = null;
6257
6392
  try {
@@ -6262,11 +6397,11 @@ var importCommand2 = defineCommand28({
6262
6397
  if (!(error instanceof ApiClientError) || error.status !== 404) throw error;
6263
6398
  }
6264
6399
  printImportDiff(current, document);
6265
- if (args["dry-run"]) {
6400
+ if (args2["dry-run"]) {
6266
6401
  console.log("valid: no changes applied");
6267
6402
  return;
6268
6403
  }
6269
- if (!args.apply) throw new Error("refusing mutation: review the diff, then pass --apply");
6404
+ if (!args2.apply) throw new Error("refusing mutation: review the diff, then pass --apply");
6270
6405
  if (!current) {
6271
6406
  const body2 = teamImportBody(document);
6272
6407
  const created = await client.post("/api/team-templates/import", {
@@ -6288,9 +6423,9 @@ var importCommand2 = defineCommand28({
6288
6423
  throw new Error(
6289
6424
  "replacement document metadata differs; update Team name/USER.md separately before import"
6290
6425
  );
6291
- const supplied = Number.parseInt(args["expected-revision"] ?? "", 10);
6292
- const expectedRevision = args.force ? current.template.currentRevision : supplied;
6293
- if (args.force && Number.parseInt(args["confirm-current-revision"] ?? "", 10) !== current.template.currentRevision)
6426
+ const supplied = Number.parseInt(args2["expected-revision"] ?? "", 10);
6427
+ const expectedRevision = args2.force ? current.template.currentRevision : supplied;
6428
+ if (args2.force && Number.parseInt(args2["confirm-current-revision"] ?? "", 10) !== current.template.currentRevision)
6294
6429
  throw new Error(
6295
6430
  `--force requires --confirm-current-revision ${current.template.currentRevision} after reviewing the fresh diff`
6296
6431
  );
@@ -6307,7 +6442,7 @@ var importCommand2 = defineCommand28({
6307
6442
  );
6308
6443
  }
6309
6444
  });
6310
- var teamTemplateCommand = defineCommand28({
6445
+ var teamTemplateCommand = defineCommand29({
6311
6446
  meta: {
6312
6447
  name: "team-template",
6313
6448
  description: "Inspect and exchange canonical Team templates"
@@ -6316,8 +6451,8 @@ var teamTemplateCommand = defineCommand28({
6316
6451
  });
6317
6452
 
6318
6453
  // src/commands/telegram.ts
6319
- import { defineCommand as defineCommand29 } from "citty";
6320
- var setCmd2 = defineCommand29({
6454
+ import { defineCommand as defineCommand30 } from "citty";
6455
+ var setCmd2 = defineCommand30({
6321
6456
  meta: {
6322
6457
  name: "set",
6323
6458
  description: "Save bot token + supergroup chat ID (paired write)"
@@ -6326,16 +6461,16 @@ var setCmd2 = defineCommand29({
6326
6461
  token: { type: "string", required: true, description: "Bot token from @BotFather" },
6327
6462
  chat: { type: "string", required: true, description: "Numeric supergroup chat ID" }
6328
6463
  },
6329
- async run({ args }) {
6464
+ async run({ args: args2 }) {
6330
6465
  const client = createClient2();
6331
6466
  const state = await client.put("/api/config/telegram", {
6332
- botToken: args.token,
6333
- chatId: args.chat
6467
+ botToken: args2.token,
6468
+ chatId: args2.chat
6334
6469
  });
6335
6470
  console.log(`saved \xB7 token ${state.botTokenPreview} \xB7 chat ${state.chatId}`);
6336
6471
  }
6337
6472
  });
6338
- var clearCmd = defineCommand29({
6473
+ var clearCmd = defineCommand30({
6339
6474
  meta: {
6340
6475
  name: "clear",
6341
6476
  description: "Remove stored bot token + chat ID"
@@ -6346,7 +6481,7 @@ var clearCmd = defineCommand29({
6346
6481
  console.log("cleared");
6347
6482
  }
6348
6483
  });
6349
- var showCmd5 = defineCommand29({
6484
+ var showCmd5 = defineCommand30({
6350
6485
  meta: {
6351
6486
  name: "show",
6352
6487
  description: "Show what credentials are stored (token is masked)"
@@ -6367,7 +6502,7 @@ var showCmd5 = defineCommand29({
6367
6502
  }
6368
6503
  }
6369
6504
  });
6370
- var reconnectCmd = defineCommand29({
6505
+ var reconnectCmd = defineCommand30({
6371
6506
  meta: {
6372
6507
  name: "reconnect",
6373
6508
  description: "Apply a pending supergroup chat-id migration + re-activate the bot"
@@ -6378,7 +6513,7 @@ var reconnectCmd = defineCommand29({
6378
6513
  console.log(`reconnected \xB7 chat ${state.chatId}`);
6379
6514
  }
6380
6515
  });
6381
- var configCmd = defineCommand29({
6516
+ var configCmd = defineCommand30({
6382
6517
  meta: {
6383
6518
  name: "config",
6384
6519
  description: "Manage Telegram credentials (bot token + chat ID)"
@@ -6389,7 +6524,7 @@ var configCmd = defineCommand29({
6389
6524
  show: showCmd5
6390
6525
  }
6391
6526
  });
6392
- var healthCmd = defineCommand29({
6527
+ var healthCmd = defineCommand30({
6393
6528
  meta: {
6394
6529
  name: "health",
6395
6530
  description: "Run the four-step preflight against the Telegram Bot API"
@@ -6428,7 +6563,7 @@ var healthCmd = defineCommand29({
6428
6563
  if (!allOk) process.exitCode = 1;
6429
6564
  }
6430
6565
  });
6431
- var botStatusCmd = defineCommand29({
6566
+ var botStatusCmd = defineCommand30({
6432
6567
  meta: {
6433
6568
  name: "status",
6434
6569
  description: "Show polling state of the live bot"
@@ -6453,7 +6588,7 @@ var botStatusCmd = defineCommand29({
6453
6588
  if (!p.running) process.exitCode = 1;
6454
6589
  }
6455
6590
  });
6456
- var botRestartCmd = defineCommand29({
6591
+ var botRestartCmd = defineCommand30({
6457
6592
  meta: {
6458
6593
  name: "restart",
6459
6594
  description: "Force-restart the bot (tears down + brings up from current creds)"
@@ -6464,7 +6599,7 @@ var botRestartCmd = defineCommand29({
6464
6599
  console.log("restart requested");
6465
6600
  }
6466
6601
  });
6467
- var botCmd = defineCommand29({
6602
+ var botCmd = defineCommand30({
6468
6603
  meta: {
6469
6604
  name: "bot",
6470
6605
  description: "Inspect / control the live polling bot"
@@ -6474,7 +6609,7 @@ var botCmd = defineCommand29({
6474
6609
  restart: botRestartCmd
6475
6610
  }
6476
6611
  });
6477
- var bindCmd = defineCommand29({
6612
+ var bindCmd = defineCommand30({
6478
6613
  meta: {
6479
6614
  name: "bind",
6480
6615
  description: "Create a Telegram topic for an agent (manual fallback for /talk)"
@@ -6482,17 +6617,17 @@ var bindCmd = defineCommand29({
6482
6617
  args: {
6483
6618
  agent: { type: "positional", required: true, description: "Agent id or prefix" }
6484
6619
  },
6485
- async run({ args }) {
6620
+ async run({ args: args2 }) {
6486
6621
  const client = createClient2();
6487
6622
  const result = await client.post(
6488
- `/api/agents/${args.agent}/telegram/bind`
6623
+ `/api/agents/${args2.agent}/telegram/bind`
6489
6624
  );
6490
6625
  const verb = result.created ? "created topic" : "already bound to";
6491
6626
  console.log(`${verb} #${result.topicId} for agent ${result.agent.name} (${result.agent.id})`);
6492
6627
  console.log(` ${result.deepLink}`);
6493
6628
  }
6494
6629
  });
6495
- var unbindCmd = defineCommand29({
6630
+ var unbindCmd = defineCommand30({
6496
6631
  meta: {
6497
6632
  name: "unbind",
6498
6633
  description: "Clear an agent's Telegram topic binding (topic stays in Telegram as orphan)"
@@ -6500,13 +6635,13 @@ var unbindCmd = defineCommand29({
6500
6635
  args: {
6501
6636
  agent: { type: "positional", required: true, description: "Agent id or prefix" }
6502
6637
  },
6503
- async run({ args }) {
6638
+ async run({ args: args2 }) {
6504
6639
  const client = createClient2();
6505
- await client.del(`/api/agents/${args.agent}/telegram/binding`);
6506
- console.log(`unbound agent ${args.agent}`);
6640
+ await client.del(`/api/agents/${args2.agent}/telegram/binding`);
6641
+ console.log(`unbound agent ${args2.agent}`);
6507
6642
  }
6508
6643
  });
6509
- var listBindingsCmd = defineCommand29({
6644
+ var listBindingsCmd = defineCommand30({
6510
6645
  meta: {
6511
6646
  name: "list",
6512
6647
  description: "List agents and their Telegram topic bindings"
@@ -6534,32 +6669,32 @@ var listBindingsCmd = defineCommand29({
6534
6669
  }
6535
6670
  }
6536
6671
  });
6537
- var allowCmd = defineCommand29({
6672
+ var allowCmd = defineCommand30({
6538
6673
  meta: { name: "allow", description: "Add a Telegram user id to the allowlist" },
6539
6674
  args: {
6540
6675
  userId: { type: "positional", required: true, description: "Numeric Telegram user id" },
6541
6676
  label: { type: "string", description: "Optional human label" }
6542
6677
  },
6543
- async run({ args }) {
6678
+ async run({ args: args2 }) {
6544
6679
  const client = createClient2();
6545
6680
  const u = await client.post("/api/config/telegram/acl", {
6546
- userId: Number(args.userId),
6547
- label: args.label ?? null,
6681
+ userId: Number(args2.userId),
6682
+ label: args2.label ?? null,
6548
6683
  role: "member"
6549
6684
  });
6550
6685
  console.log(`allowed ${u.userId} (${u.role})`);
6551
6686
  }
6552
6687
  });
6553
- var denyCmd = defineCommand29({
6688
+ var denyCmd = defineCommand30({
6554
6689
  meta: { name: "deny", description: "Remove a Telegram user id from the allowlist" },
6555
6690
  args: { userId: { type: "positional", required: true } },
6556
- async run({ args }) {
6691
+ async run({ args: args2 }) {
6557
6692
  const client = createClient2();
6558
- await client.del(`/api/config/telegram/acl/${Number(args.userId)}`);
6559
- console.log(`removed ${args.userId}`);
6693
+ await client.del(`/api/config/telegram/acl/${Number(args2.userId)}`);
6694
+ console.log(`removed ${args2.userId}`);
6560
6695
  }
6561
6696
  });
6562
- var allowedCmd = defineCommand29({
6697
+ var allowedCmd = defineCommand30({
6563
6698
  meta: { name: "allowed", description: "List allowlisted Telegram users" },
6564
6699
  async run() {
6565
6700
  const client = createClient2();
@@ -6574,7 +6709,7 @@ var allowedCmd = defineCommand29({
6574
6709
  }
6575
6710
  }
6576
6711
  });
6577
- var pairingCreateCmd = defineCommand29({
6712
+ var pairingCreateCmd = defineCommand30({
6578
6713
  meta: { name: "create", description: "Generate a one-time Telegram owner pairing code" },
6579
6714
  async run() {
6580
6715
  const result = await createClient2().post(
@@ -6585,7 +6720,7 @@ var pairingCreateCmd = defineCommand29({
6585
6720
  console.log("send `/pair <code>` in the configured \u2699 bazilion service topic");
6586
6721
  }
6587
6722
  });
6588
- var pairingStatusCmd = defineCommand29({
6723
+ var pairingStatusCmd = defineCommand30({
6589
6724
  meta: { name: "status", description: "Show Telegram owner pairing status" },
6590
6725
  async run() {
6591
6726
  const result = await createClient2().get("/api/config/telegram/pairing");
@@ -6596,25 +6731,25 @@ var pairingStatusCmd = defineCommand29({
6596
6731
  console.log(`expires: ${new Date(result.challengeExpiresAt).toISOString()}`);
6597
6732
  }
6598
6733
  });
6599
- var pairingCancelCmd = defineCommand29({
6734
+ var pairingCancelCmd = defineCommand30({
6600
6735
  meta: { name: "cancel", description: "Cancel the active Telegram pairing code" },
6601
6736
  async run() {
6602
6737
  await createClient2().del("/api/config/telegram/pairing/challenge");
6603
6738
  console.log("pairing challenge cancelled");
6604
6739
  }
6605
6740
  });
6606
- var pairingResetCmd = defineCommand29({
6741
+ var pairingResetCmd = defineCommand30({
6607
6742
  meta: { name: "reset", description: "Revoke the Telegram owner and require re-pairing" },
6608
6743
  args: {
6609
6744
  yes: { type: "boolean", description: "Confirm destructive owner reset", required: true }
6610
6745
  },
6611
- async run({ args }) {
6612
- if (!args.yes) throw new Error("--yes is required");
6746
+ async run({ args: args2 }) {
6747
+ if (!args2.yes) throw new Error("--yes is required");
6613
6748
  await createClient2().post("/api/config/telegram/pairing/reset", { confirm: true });
6614
6749
  console.log("Telegram owner reset; ingress is closed until re-paired");
6615
6750
  }
6616
6751
  });
6617
- var pairingCmd = defineCommand29({
6752
+ var pairingCmd = defineCommand30({
6618
6753
  meta: { name: "pairing", description: "Manage single-owner Telegram pairing" },
6619
6754
  subCommands: {
6620
6755
  create: pairingCreateCmd,
@@ -6623,7 +6758,7 @@ var pairingCmd = defineCommand29({
6623
6758
  reset: pairingResetCmd
6624
6759
  }
6625
6760
  });
6626
- var telegramCommand = defineCommand29({
6761
+ var telegramCommand = defineCommand30({
6627
6762
  meta: {
6628
6763
  name: "telegram",
6629
6764
  description: "Telegram integration: credentials, health, bot lifecycle, bindings, access"
@@ -6644,7 +6779,7 @@ var telegramCommand = defineCommand29({
6644
6779
  });
6645
6780
 
6646
6781
  // src/commands/token.ts
6647
- import { defineCommand as defineCommand30 } from "citty";
6782
+ import { defineCommand as defineCommand31 } from "citty";
6648
6783
  import qrcode from "qrcode-terminal";
6649
6784
  function tokenRow(t) {
6650
6785
  const last = t.lastUsedAt ? new Date(t.lastUsedAt).toISOString() : "(never)";
@@ -6673,7 +6808,7 @@ function resolveQrServer(override) {
6673
6808
  }
6674
6809
  return url.origin;
6675
6810
  }
6676
- var createCmd3 = defineCommand30({
6811
+ var createCmd3 = defineCommand31({
6677
6812
  meta: { name: "create", description: "Mint a new web token (shown once)" },
6678
6813
  args: {
6679
6814
  label: { type: "positional", required: true, description: "Human-readable label" },
@@ -6690,13 +6825,13 @@ var createCmd3 = defineCommand30({
6690
6825
  description: "Device lifetime in days (default 90, maximum 365)"
6691
6826
  }
6692
6827
  },
6693
- async run({ args }) {
6828
+ async run({ args: args2 }) {
6694
6829
  const client = createClient2();
6695
- const expiresInDays = args.expiresDays === void 0 ? void 0 : Number(args.expiresDays);
6830
+ const expiresInDays = args2.expiresDays === void 0 ? void 0 : Number(args2.expiresDays);
6696
6831
  if (expiresInDays !== void 0 && !Number.isInteger(expiresInDays)) {
6697
6832
  throw new Error("--expires-days must be an integer");
6698
6833
  }
6699
- const body = { label: args.label, expiresInDays };
6834
+ const body = { label: args2.label, expiresInDays };
6700
6835
  const res = await client.post("/api/tokens", body);
6701
6836
  console.log(`id: ${res.meta.id}`);
6702
6837
  console.log(`label: ${res.meta.label}`);
@@ -6707,8 +6842,8 @@ var createCmd3 = defineCommand30({
6707
6842
  console.log(`token: ${res.token}`);
6708
6843
  console.log("");
6709
6844
  console.log("store the token now \u2014 it is not recoverable later.");
6710
- if (!args.qr) return;
6711
- const serverUrl = resolveQrServer(args.server);
6845
+ if (!args2.qr) return;
6846
+ const serverUrl = resolveQrServer(args2.server);
6712
6847
  const pairUrl = `bazilion://pair?server=${encodeURIComponent(serverUrl)}&token=${encodeURIComponent(res.token)}`;
6713
6848
  console.log("");
6714
6849
  console.log(`pairing URL: ${pairUrl}`);
@@ -6716,14 +6851,14 @@ var createCmd3 = defineCommand30({
6716
6851
  qrcode.generate(pairUrl, { small: true }, (qr) => console.log(qr));
6717
6852
  }
6718
6853
  });
6719
- var listCmd11 = defineCommand30({
6854
+ var listCmd11 = defineCommand31({
6720
6855
  meta: { name: "list", description: "List web tokens" },
6721
6856
  args: {
6722
6857
  all: { type: "boolean", description: "Include revoked tokens" }
6723
6858
  },
6724
- async run({ args }) {
6859
+ async run({ args: args2 }) {
6725
6860
  const client = createClient2();
6726
- const qs = args.all ? "?includeRevoked=1" : "";
6861
+ const qs = args2.all ? "?includeRevoked=1" : "";
6727
6862
  const { tokens } = await client.get(`/api/tokens${qs}`);
6728
6863
  if (tokens.length === 0) {
6729
6864
  console.log("(no tokens)");
@@ -6732,7 +6867,7 @@ var listCmd11 = defineCommand30({
6732
6867
  for (const line of columnize(tokens.map(tokenRow))) console.log(line);
6733
6868
  }
6734
6869
  });
6735
- var showLocalCmd = defineCommand30({
6870
+ var showLocalCmd = defineCommand31({
6736
6871
  meta: {
6737
6872
  name: "show-local",
6738
6873
  description: "Print the bootstrap web token stored in ~/.bazilion/auth.json"
@@ -6742,18 +6877,18 @@ var showLocalCmd = defineCommand30({
6742
6877
  console.log(readAuthFile(paths.authFile).token);
6743
6878
  }
6744
6879
  });
6745
- var revokeCmd2 = defineCommand30({
6880
+ var revokeCmd2 = defineCommand31({
6746
6881
  meta: { name: "revoke", description: "Revoke a web token" },
6747
6882
  args: {
6748
6883
  id: { type: "positional", required: true }
6749
6884
  },
6750
- async run({ args }) {
6885
+ async run({ args: args2 }) {
6751
6886
  const client = createClient2();
6752
- await client.del(`/api/tokens/${args.id}`);
6753
- console.log(`revoked token ${args.id}`);
6887
+ await client.del(`/api/tokens/${args2.id}`);
6888
+ console.log(`revoked token ${args2.id}`);
6754
6889
  }
6755
6890
  });
6756
- var tokenCommand = defineCommand30({
6891
+ var tokenCommand = defineCommand31({
6757
6892
  meta: { name: "token", description: "Manage web tokens for API/CLI clients" },
6758
6893
  subCommands: {
6759
6894
  create: createCmd3,
@@ -6764,8 +6899,8 @@ var tokenCommand = defineCommand30({
6764
6899
  });
6765
6900
 
6766
6901
  // src/commands/trigger.ts
6767
- import { defineCommand as defineCommand31 } from "citty";
6768
- var addCmd3 = defineCommand31({
6902
+ import { defineCommand as defineCommand32 } from "citty";
6903
+ var addCmd3 = defineCommand32({
6769
6904
  meta: { name: "add", description: "Add an interval / cron trigger to an agent" },
6770
6905
  args: {
6771
6906
  agent: { type: "positional", required: true },
@@ -6784,23 +6919,23 @@ var addCmd3 = defineCommand31({
6784
6919
  },
6785
6920
  disabled: { type: "boolean", description: "Create in disabled state" }
6786
6921
  },
6787
- async run({ args }) {
6788
- if (!args.every === !args.cron) {
6922
+ async run({ args: args2 }) {
6923
+ if (!args2.every === !args2.cron) {
6789
6924
  throw new Error('specify exactly one of --every <seconds> or --cron "<expr>"');
6790
6925
  }
6791
6926
  const client = createClient2();
6792
- const body = args.every ? {
6927
+ const body = args2.every ? {
6793
6928
  kind: "interval",
6794
- intervalSec: Number(args.every),
6795
- message: args.message,
6796
- enabled: !args.disabled
6929
+ intervalSec: Number(args2.every),
6930
+ message: args2.message,
6931
+ enabled: !args2.disabled
6797
6932
  } : {
6798
6933
  kind: "cron",
6799
- cronExpr: args.cron,
6800
- message: args.message,
6801
- enabled: !args.disabled
6934
+ cronExpr: args2.cron,
6935
+ message: args2.message,
6936
+ enabled: !args2.disabled
6802
6937
  };
6803
- const res = await client.post(`/api/agents/${args.agent}/triggers`, body);
6938
+ const res = await client.post(`/api/agents/${args2.agent}/triggers`, body);
6804
6939
  const t = res.trigger;
6805
6940
  const spec = t.kind === "interval" ? `every ${t.intervalSec}s` : `cron "${t.cronExpr}"`;
6806
6941
  console.log(`${t.id} ${spec} ${t.enabled ? "enabled" : "disabled"}`);
@@ -6813,15 +6948,15 @@ function triggerRow(t) {
6813
6948
  const msgPreview = t.message.length > 60 ? `${t.message.slice(0, 60)}\u2026` : t.message;
6814
6949
  return [t.id, state, spec, `last: ${last}`, `"${msgPreview}"`];
6815
6950
  }
6816
- var listCmd12 = defineCommand31({
6951
+ var listCmd12 = defineCommand32({
6817
6952
  meta: { name: "list", description: "List triggers for an agent" },
6818
6953
  args: {
6819
6954
  agent: { type: "positional", required: true }
6820
6955
  },
6821
- async run({ args }) {
6956
+ async run({ args: args2 }) {
6822
6957
  const client = createClient2();
6823
6958
  const { triggers } = await client.get(
6824
- `/api/agents/${args.agent}/triggers`
6959
+ `/api/agents/${args2.agent}/triggers`
6825
6960
  );
6826
6961
  if (triggers.length === 0) {
6827
6962
  console.log("(no triggers)");
@@ -6830,55 +6965,55 @@ var listCmd12 = defineCommand31({
6830
6965
  for (const line of columnize(triggers.map(triggerRow))) console.log(line);
6831
6966
  }
6832
6967
  });
6833
- var rmCmd6 = defineCommand31({
6968
+ var rmCmd6 = defineCommand32({
6834
6969
  meta: { name: "rm", description: "Delete a trigger" },
6835
6970
  args: {
6836
6971
  id: { type: "positional", required: true }
6837
6972
  },
6838
- async run({ args }) {
6973
+ async run({ args: args2 }) {
6839
6974
  const client = createClient2();
6840
- await client.del(`/api/triggers/${args.id}`);
6841
- console.log(`removed trigger ${args.id}`);
6975
+ await client.del(`/api/triggers/${args2.id}`);
6976
+ console.log(`removed trigger ${args2.id}`);
6842
6977
  }
6843
6978
  });
6844
- var enableCmd3 = defineCommand31({
6979
+ var enableCmd3 = defineCommand32({
6845
6980
  meta: { name: "enable", description: "Enable a trigger" },
6846
6981
  args: {
6847
6982
  id: { type: "positional", required: true }
6848
6983
  },
6849
- async run({ args }) {
6984
+ async run({ args: args2 }) {
6850
6985
  const client = createClient2();
6851
6986
  const body = { enabled: true };
6852
- await client.patch(`/api/triggers/${args.id}`, body);
6853
- console.log(`enabled trigger ${args.id}`);
6987
+ await client.patch(`/api/triggers/${args2.id}`, body);
6988
+ console.log(`enabled trigger ${args2.id}`);
6854
6989
  }
6855
6990
  });
6856
- var disableCmd3 = defineCommand31({
6991
+ var disableCmd3 = defineCommand32({
6857
6992
  meta: { name: "disable", description: "Disable a trigger" },
6858
6993
  args: {
6859
6994
  id: { type: "positional", required: true }
6860
6995
  },
6861
- async run({ args }) {
6996
+ async run({ args: args2 }) {
6862
6997
  const client = createClient2();
6863
6998
  const body = { enabled: false };
6864
- await client.patch(`/api/triggers/${args.id}`, body);
6865
- console.log(`disabled trigger ${args.id}`);
6999
+ await client.patch(`/api/triggers/${args2.id}`, body);
7000
+ console.log(`disabled trigger ${args2.id}`);
6866
7001
  }
6867
7002
  });
6868
- var historyCmd = defineCommand31({
7003
+ var historyCmd = defineCommand32({
6869
7004
  meta: { name: "history", description: "Show recent dispatches for a trigger" },
6870
7005
  args: {
6871
7006
  id: { type: "positional", required: true },
6872
7007
  limit: { type: "string", description: "Maximum rows (default 20)" }
6873
7008
  },
6874
- async run({ args }) {
6875
- const limit = args.limit ? Number(args.limit) : 20;
7009
+ async run({ args: args2 }) {
7010
+ const limit = args2.limit ? Number(args2.limit) : 20;
6876
7011
  if (!Number.isInteger(limit) || limit < 1 || limit > 100) {
6877
7012
  throw new Error("--limit must be an integer from 1 to 100");
6878
7013
  }
6879
7014
  const client = createClient2();
6880
7015
  const { dispatches } = await client.get(
6881
- `/api/triggers/${args.id}/dispatches?limit=${limit}`
7016
+ `/api/triggers/${args2.id}/dispatches?limit=${limit}`
6882
7017
  );
6883
7018
  if (dispatches.length === 0) {
6884
7019
  console.log("(no dispatches)");
@@ -6893,7 +7028,7 @@ var historyCmd = defineCommand31({
6893
7028
  for (const line of columnize(rows)) console.log(line);
6894
7029
  }
6895
7030
  });
6896
- var triggerCommand = defineCommand31({
7031
+ var triggerCommand = defineCommand32({
6897
7032
  meta: { name: "trigger", description: "Manage scheduled agent triggers" },
6898
7033
  subCommands: {
6899
7034
  add: addCmd3,
@@ -6906,10 +7041,10 @@ var triggerCommand = defineCommand31({
6906
7041
  });
6907
7042
 
6908
7043
  // src/commands/uninstall.ts
6909
- import { existsSync as existsSync7, lstatSync as lstatSync3, readdirSync as readdirSync2, realpathSync as realpathSync2, rmSync as rmSync4 } from "fs";
7044
+ import { existsSync as existsSync7, lstatSync as lstatSync4, readdirSync as readdirSync2, realpathSync as realpathSync2, rmSync as rmSync4 } from "fs";
6910
7045
  import { homedir as homedir2 } from "os";
6911
- import { isAbsolute as isAbsolute2, join as join6, parse as parse2, relative as relative2, resolve as resolve4, sep } from "path";
6912
- import { defineCommand as defineCommand32 } from "citty";
7046
+ import { isAbsolute as isAbsolute2, join as join6, parse as parse2, relative as relative2, resolve as resolve5, sep } from "path";
7047
+ import { defineCommand as defineCommand33 } from "citty";
6913
7048
  function makeLineReader() {
6914
7049
  let buffer = "";
6915
7050
  let ended = false;
@@ -6919,8 +7054,8 @@ function makeLineReader() {
6919
7054
  const nlIdx = buffer.indexOf("\n");
6920
7055
  if (nlIdx === -1) {
6921
7056
  if (ended) {
6922
- const resolve5 = queue.shift();
6923
- resolve5?.(buffer);
7057
+ const resolve6 = queue.shift();
7058
+ resolve6?.(buffer);
6924
7059
  buffer = "";
6925
7060
  } else {
6926
7061
  return;
@@ -6928,8 +7063,8 @@ function makeLineReader() {
6928
7063
  } else {
6929
7064
  const line = buffer.slice(0, nlIdx);
6930
7065
  buffer = buffer.slice(nlIdx + 1);
6931
- const resolve5 = queue.shift();
6932
- resolve5?.(line);
7066
+ const resolve6 = queue.shift();
7067
+ resolve6?.(line);
6933
7068
  }
6934
7069
  }
6935
7070
  };
@@ -6942,8 +7077,8 @@ function makeLineReader() {
6942
7077
  ended = true;
6943
7078
  tryDeliver();
6944
7079
  });
6945
- return () => new Promise((resolve5) => {
6946
- queue.push(resolve5);
7080
+ return () => new Promise((resolve6) => {
7081
+ queue.push(resolve6);
6947
7082
  tryDeliver();
6948
7083
  });
6949
7084
  }
@@ -6954,7 +7089,7 @@ async function askYes(readLine, prompt) {
6954
7089
  }
6955
7090
  function removePath(p) {
6956
7091
  try {
6957
- lstatSync3(p);
7092
+ lstatSync4(p);
6958
7093
  } catch (error) {
6959
7094
  if (error instanceof Error && "code" in error && error.code === "ENOENT") return false;
6960
7095
  throw error;
@@ -6967,7 +7102,7 @@ function canonicalExistingPath(path) {
6967
7102
  return realpathSync2.native(path);
6968
7103
  } catch (error) {
6969
7104
  if (!(error instanceof Error && "code" in error && error.code === "ENOENT")) throw error;
6970
- return resolve4(path);
7105
+ return resolve5(path);
6971
7106
  }
6972
7107
  }
6973
7108
  function containsPath(container, candidate) {
@@ -6975,7 +7110,7 @@ function containsPath(container, candidate) {
6975
7110
  return nested === "" || nested !== ".." && !nested.startsWith(`..${sep}`) && !isAbsolute2(nested);
6976
7111
  }
6977
7112
  function assertSafeUninstallHome(home) {
6978
- const target = resolve4(home);
7113
+ const target = resolve5(home);
6979
7114
  const canonical = canonicalExistingPath(target);
6980
7115
  const userHome = canonicalExistingPath(homedir2());
6981
7116
  const workingDirectory = canonicalExistingPath(process.cwd());
@@ -6996,7 +7131,7 @@ function assertSafeUninstallHome(home) {
6996
7131
  }
6997
7132
  return target;
6998
7133
  }
6999
- var uninstallCommand = defineCommand32({
7134
+ var uninstallCommand = defineCommand33({
7000
7135
  meta: {
7001
7136
  name: "uninstall",
7002
7137
  description: "Wipe bazilion state from ~/.bazilion (or BAZILION_HOME)"
@@ -7012,8 +7147,8 @@ var uninstallCommand = defineCommand32({
7012
7147
  description: "Also remove logs and skills (full wipe)"
7013
7148
  }
7014
7149
  },
7015
- async run({ args }) {
7016
- const paths = resolveCliPaths(args.home);
7150
+ async run({ args: args2 }) {
7151
+ const paths = resolveCliPaths(args2.home);
7017
7152
  const targetHome = assertSafeUninstallHome(paths.home);
7018
7153
  const dbFile = join6(targetHome, "bazilion.db");
7019
7154
  const profilesDir = join6(targetHome, "profiles");
@@ -7034,7 +7169,7 @@ var uninstallCommand = defineCommand32({
7034
7169
  }
7035
7170
  return;
7036
7171
  }
7037
- const homeIsSymlink = lstatSync3(targetHome).isSymbolicLink();
7172
+ const homeIsSymlink = lstatSync4(targetHome).isSymbolicLink();
7038
7173
  console.log(`about to uninstall bazilion at ${targetHome}`);
7039
7174
  console.log("");
7040
7175
  const resetTargets = [
@@ -7050,9 +7185,9 @@ var uninstallCommand = defineCommand32({
7050
7185
  teamsDir,
7051
7186
  legacyGroupsDir
7052
7187
  ];
7053
- const needsPrompt = !args.yes;
7188
+ const needsPrompt = !args2.yes;
7054
7189
  const readLine = needsPrompt ? makeLineReader() : null;
7055
- const wipeData = args.yes || await askYes(
7190
+ const wipeData = args2.yes || await askYes(
7056
7191
  readLine,
7057
7192
  "remove DB + auth/config + agent / profile / team data?"
7058
7193
  );
@@ -7061,7 +7196,7 @@ var uninstallCommand = defineCommand32({
7061
7196
  process.stdin.pause();
7062
7197
  return;
7063
7198
  }
7064
- const wipeAll = args.all || (args.yes ? false : await askYes(
7199
+ const wipeAll = args2.all || (args2.yes ? false : await askYes(
7065
7200
  readLine,
7066
7201
  `also remove logs and skills? (full wipe of ${targetHome})`
7067
7202
  ));
@@ -7100,7 +7235,7 @@ var uninstallCommand = defineCommand32({
7100
7235
 
7101
7236
  // src/index.ts
7102
7237
  var VERSION = package_default.version;
7103
- var main = defineCommand33({
7238
+ var main = defineCommand34({
7104
7239
  meta: {
7105
7240
  name: "bazilion",
7106
7241
  version: VERSION,