@halcyonlabs/app 0.47.0-halcyon.425 → 0.47.0-halcyon.427

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 (48) hide show
  1. package/dist/bb-app.js +93 -16
  2. package/dist/index.d.ts +13 -13
  3. package/dist/index.js +13 -0
  4. package/host-daemon/dist/bb +2 -2
  5. package/host-daemon/dist/bb-chunks/{browser-WHQ7FOYB.js → browser-ZEFFGB26.js} +1 -1
  6. package/host-daemon/dist/bb-chunks/{chunk-NBD63LSE.js → chunk-2VBVXHCO.js} +1 -1
  7. package/host-daemon/dist/bb-chunks/{chunk-KOHZHKV3.js → chunk-4DB32TQ2.js} +1 -1
  8. package/host-daemon/dist/bb-chunks/{chunk-ASVZVMB7.js → chunk-6W522XWW.js} +1 -1
  9. package/host-daemon/dist/bb-chunks/{chunk-CO7MWB5S.js → chunk-CQQULLUB.js} +1 -1
  10. package/host-daemon/dist/bb-chunks/{chunk-7XQFWLHC.js → chunk-EGI3PDJP.js} +2 -2
  11. package/host-daemon/dist/bb-chunks/{chunk-XSWDT4Z7.js → chunk-G7UKUDRZ.js} +1 -1
  12. package/host-daemon/dist/bb-chunks/chunk-G7YL5DVK.js +2 -0
  13. package/host-daemon/dist/bb-chunks/{chunk-JV4DTKAM.js → chunk-GRWMDTBD.js} +1 -1
  14. package/host-daemon/dist/bb-chunks/{chunk-4MDJTHVY.js → chunk-HIWLZ4JX.js} +6 -2
  15. package/host-daemon/dist/bb-chunks/{chunk-QQHP55AW.js → chunk-NKXENHEU.js} +1 -1
  16. package/host-daemon/dist/bb-chunks/{chunk-4RFVFB3F.js → chunk-OD73XZBZ.js} +1 -1
  17. package/host-daemon/dist/bb-chunks/{client-UV5XAEUU.js → client-ARSXLZ7U.js} +1 -1
  18. package/host-daemon/dist/bb-chunks/{commander-errors-2ZA2II5B.js → commander-errors-LG2MJ6KV.js} +1 -1
  19. package/host-daemon/dist/bb-chunks/{context-env-AK3SQXHK.js → context-env-5PHP22B2.js} +1 -1
  20. package/host-daemon/dist/bb-chunks/{context-hints-W52LG6SC.js → context-hints-V6LBX4TV.js} +1 -1
  21. package/host-daemon/dist/bb-chunks/{diagnostics-47OCBACR.js → diagnostics-XYZ2XT6S.js} +1 -1
  22. package/host-daemon/dist/bb-chunks/{environment-YQBGGDAF.js → environment-FS7NEMOY.js} +1 -1
  23. package/host-daemon/dist/bb-chunks/{file-R4Z7DRXC.js → file-YGLCC6R4.js} +1 -1
  24. package/host-daemon/dist/bb-chunks/{guide-X7BLBOHV.js → guide-MV7X42MR.js} +1 -1
  25. package/host-daemon/dist/bb-chunks/{machine-NATUHEOT.js → machine-IY6LFZJ7.js} +1 -1
  26. package/host-daemon/dist/bb-chunks/{marketplace-C2ADGBOS.js → marketplace-T52ANUUC.js} +1 -1
  27. package/host-daemon/dist/bb-chunks/{permissions-JNQZO4MB.js → permissions-GZMED7X7.js} +1 -1
  28. package/host-daemon/dist/bb-chunks/{plugin-6365EP4W.js → plugin-VA4UGRYQ.js} +1 -1
  29. package/host-daemon/dist/bb-chunks/{plugin-cli-proxy-WS4TNUQO.js → plugin-cli-proxy-GCWTZ7AA.js} +1 -1
  30. package/host-daemon/dist/bb-chunks/{project-MP2KPUP5.js → project-BB5DNBCN.js} +1 -1
  31. package/host-daemon/dist/bb-chunks/{prompt-history-A45GQCAH.js → prompt-history-QTZ2B3LB.js} +1 -1
  32. package/host-daemon/dist/bb-chunks/{provider-PAU7BND7.js → provider-L3CLTJKX.js} +1 -1
  33. package/host-daemon/dist/bb-chunks/{schedule-DEYAHYDB.js → schedule-AEDFLDHP.js} +1 -1
  34. package/host-daemon/dist/bb-chunks/{server-WKX3EXD5.js → server-GUBCT4WZ.js} +1 -1
  35. package/host-daemon/dist/bb-chunks/{settings-EVFPBWJ3.js → settings-JUGX3QON.js} +1 -1
  36. package/host-daemon/dist/bb-chunks/{skill-IG7H76CR.js → skill-I5D53CJV.js} +1 -1
  37. package/host-daemon/dist/bb-chunks/{status-MIGTL764.js → status-SSJMYM4S.js} +1 -1
  38. package/host-daemon/dist/bb-chunks/{terminal-PPYCAE62.js → terminal-VMCCEQDY.js} +1 -1
  39. package/host-daemon/dist/bb-chunks/{theme-HSOUFGMX.js → theme-U637PPQA.js} +1 -1
  40. package/host-daemon/dist/bb-chunks/{thread-FXA7B7RK.js → thread-DOGLLRXR.js} +1 -1
  41. package/host-daemon/dist/bb-chunks/{updates-B3MHHKGZ.js → updates-DYICOEFL.js} +1 -1
  42. package/host-daemon/dist/bb-chunks/{voice-LNAFNPHW.js → voice-DE4QKGCQ.js} +1 -1
  43. package/host-daemon/dist/daemon-bundle.mjs +86 -86
  44. package/package.json +2 -2
  45. package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/fixed-runner/linux-x64/manifest.json +4 -4
  46. package/server/dist/builtin-plugins/orbit/dist/assets/moonlet/revision +1 -1
  47. package/server/dist/start-server.js +84067 -83667
  48. package/host-daemon/dist/bb-chunks/chunk-DUXDOOOQ.js +0 -2
package/dist/bb-app.js CHANGED
@@ -14898,7 +14898,7 @@ function relayDesktopAppUpdates(child) {
14898
14898
  }
14899
14899
 
14900
14900
  // src/launcher.ts
14901
- import { existsSync as existsSync2, readdirSync, readFileSync as readFileSync2 } from "node:fs";
14901
+ import { existsSync as existsSync3, readdirSync, readFileSync as readFileSync2 } from "node:fs";
14902
14902
 
14903
14903
  // src/logged-process.ts
14904
14904
  import { spawn } from "node:child_process";
@@ -16415,6 +16415,10 @@ import { delimiter as delimiter2 } from "node:path";
16415
16415
  import { randomUUID } from "node:crypto";
16416
16416
  import { mkdir as mkdir4, open as open3, readFile as readFile3, rename as rename2, unlink as unlink2 } from "node:fs/promises";
16417
16417
  import { join as join8 } from "node:path";
16418
+ var APP_UPDATE_CONTINUATION_PLUGIN_ID = "bb-app-update";
16419
+ var APP_UPDATE_CONTINUATION_SEND_AT = 864e13;
16420
+ var APP_UPDATE_CONTINUATION_PROTOCOL_ENV_NAME = "BB_APP_UPDATE_CONTINUATION_PROTOCOL";
16421
+ var APP_UPDATE_CONTINUATION_PROTOCOL_VERSION = "1";
16418
16422
  var APP_UPDATE_RECOVERY_PROTOCOL_ENV_NAME = "BB_APP_UPDATE_RECOVERY_PROTOCOL";
16419
16423
  var APP_UPDATE_SHIM_PROTOCOL_ENV_NAME = "BB_APP_UPDATE_SHIM_PROTOCOL";
16420
16424
  var APP_UPDATE_SHIM_PROTOCOL_VERSION = 1;
@@ -17541,11 +17545,40 @@ async function writeCliLauncher(args) {
17541
17545
  return "written";
17542
17546
  }
17543
17547
 
17548
+ // src/app-update/continuations.ts
17549
+ import { existsSync } from "node:fs";
17550
+ import { createRequire as createRequire2 } from "node:module";
17551
+ function releaseAppUpdateContinuations(dataDir, attemptId) {
17552
+ const path2 = resolveDataDirDatabasePath({ dataDir });
17553
+ if (!existsSync(path2)) return;
17554
+ const Database = createRequire2(import.meta.url)("better-sqlite3");
17555
+ const db = new Database(path2, { fileMustExist: true });
17556
+ try {
17557
+ db.pragma("busy_timeout = 5000");
17558
+ db.prepare(
17559
+ `UPDATE queued_thread_messages
17560
+ SET send_at = NULL, waiting_on = NULL, wait_holder = NULL,
17561
+ state = 'queued', updated_at = ?
17562
+ WHERE send_at = ? AND state = 'scheduled' AND claim_token IS NULL
17563
+ AND json_extract(system_notice, '$.kind') = 'plugin-notice'
17564
+ AND json_extract(system_notice, '$.subject.pluginId') = ?
17565
+ AND json_extract(system_notice, '$.subject.label') = ?`
17566
+ ).run(
17567
+ Date.now(),
17568
+ APP_UPDATE_CONTINUATION_SEND_AT,
17569
+ APP_UPDATE_CONTINUATION_PLUGIN_ID,
17570
+ attemptId
17571
+ );
17572
+ } finally {
17573
+ db.close();
17574
+ }
17575
+ }
17576
+
17544
17577
  // src/app-update/launcher-controller.ts
17545
17578
  import { randomUUID as randomUUID2 } from "node:crypto";
17546
17579
 
17547
17580
  // src/app-update/npm-revision.ts
17548
- import { existsSync, readFileSync } from "node:fs";
17581
+ import { existsSync as existsSync2, readFileSync } from "node:fs";
17549
17582
 
17550
17583
  // ../config/src/app-package.ts
17551
17584
  var BB_APP_NPM_PACKAGE_NAME = "@halcyonlabs/app";
@@ -17557,7 +17590,7 @@ function bbAppInstallSpec(versionOrTag) {
17557
17590
  // src/app-update/npm-revision.ts
17558
17591
  var import_semver = __toESM(require_semver2(), 1);
17559
17592
  import { mkdir as mkdir8, readdir as readdir2, rename as rename5, rm as rm5, writeFile as writeFile6 } from "node:fs/promises";
17560
- import { createRequire as createRequire2 } from "node:module";
17593
+ import { createRequire as createRequire3 } from "node:module";
17561
17594
  import { delimiter as delimiter3, dirname as dirname4, join as join11 } from "node:path";
17562
17595
 
17563
17596
  // src/app-update/run-command.ts
@@ -17672,11 +17705,15 @@ var shimLockFileSchema = external_exports.object({
17672
17705
  function hasErrorCode3(error2, code2) {
17673
17706
  return error2 instanceof Error && "code" in error2 && error2.code === code2;
17674
17707
  }
17708
+ function hasAppUpdateContinuationSupervisor(env) {
17709
+ return env[APP_UPDATE_RECOVERY_PROTOCOL_ENV_NAME] === "1" && env[APP_UPDATE_CONTINUATION_PROTOCOL_ENV_NAME] === APP_UPDATE_CONTINUATION_PROTOCOL_VERSION;
17710
+ }
17675
17711
  function createLauncherEnv(mode) {
17676
17712
  return {
17677
17713
  ...process.env,
17678
17714
  [APP_UPDATE_MODE_ENV_NAME]: mode,
17679
17715
  [APP_UPDATE_RECOVERY_PROTOCOL_ENV_NAME]: "1",
17716
+ [APP_UPDATE_CONTINUATION_PROTOCOL_ENV_NAME]: APP_UPDATE_CONTINUATION_PROTOCOL_VERSION,
17680
17717
  [APP_UPDATE_SHIM_PROTOCOL_ENV_NAME]: String(
17681
17718
  APP_UPDATE_SHIM_PROTOCOL_VERSION
17682
17719
  )
@@ -17861,7 +17898,7 @@ function isOwnNpmRevision(revision) {
17861
17898
  }
17862
17899
  function isUsableNpmRevision(revision) {
17863
17900
  return readPackageVersion(revision.packageRoot) === revision.version && NPM_REVISION_REQUIRED_FILES.every(
17864
- (file2) => existsSync(join11(revision.packageRoot, file2))
17901
+ (file2) => existsSync2(join11(revision.packageRoot, file2))
17865
17902
  );
17866
17903
  }
17867
17904
  function formatNpmRevisionInstallDir(dataDir, version2) {
@@ -17876,7 +17913,7 @@ function formatNpmRevisionPackageRoot(dataDir, version2) {
17876
17913
  }
17877
17914
  function resolveNpmCliPath() {
17878
17915
  try {
17879
- const require2 = createRequire2(import.meta.url);
17916
+ const require2 = createRequire3(import.meta.url);
17880
17917
  return join11(
17881
17918
  dirname4(require2.resolve("npm/package.json")),
17882
17919
  "bin",
@@ -18216,7 +18253,7 @@ function createLauncherAppUpdateController(args) {
18216
18253
  const timer = setTimeout(
18217
18254
  () => finish({
18218
18255
  kind: "cancel",
18219
- message: automatic ? "The automatic restart was not confirmed; work can continue and the updater can retry." : "The server did not confirm the restart. Update again to retry."
18256
+ message: automatic ? "The automatic restart was not confirmed. Any remaining pause in background work ends when you interact with the app or turn off automatic updates." : "The server did not confirm the restart. Update again to retry."
18220
18257
  }),
18221
18258
  READY_DECISION_TIMEOUT_MS
18222
18259
  );
@@ -18474,7 +18511,7 @@ function createLauncherAppUpdateController(args) {
18474
18511
  if (request.type === "restart" && activity.decisionId !== void 0 && (request.deadlineMonotonicMs === void 0 || monotonicNowMs() >= request.deadlineMonotonicMs)) {
18475
18512
  decide({
18476
18513
  kind: "cancel",
18477
- message: "The automatic update deadline expired before restart; work can continue."
18514
+ message: "The automatic update deadline expired before restart. Any remaining pause in background work ends when you interact with the app or turn off automatic updates."
18478
18515
  });
18479
18516
  return null;
18480
18517
  }
@@ -18606,6 +18643,12 @@ function createLauncherAppUpdateController(args) {
18606
18643
  args.dataDir,
18607
18644
  (state) => state.pending?.id !== pending.id ? state : { ...state, lastResult: result, pending: null }
18608
18645
  );
18646
+ if (args.mode === "source" && (updated || restored)) {
18647
+ (args.releaseContinuations ?? releaseAppUpdateContinuations)(
18648
+ args.dataDir,
18649
+ pending.id
18650
+ );
18651
+ }
18609
18652
  if (updated && pending.to.kind === "npm") {
18610
18653
  await pruneNpmRevisions({
18611
18654
  dataDir: args.dataDir,
@@ -18800,6 +18843,15 @@ async function runNpmShim(args) {
18800
18843
  ...state.lastResult?.id === attempt.id ? { lastResult: result } : {}
18801
18844
  }));
18802
18845
  };
18846
+ const releasedContinuations = /* @__PURE__ */ new Set();
18847
+ const releaseContinuations = (attemptId) => {
18848
+ if (releasedContinuations.has(attemptId)) return;
18849
+ (args.releaseContinuations ?? releaseAppUpdateContinuations)(
18850
+ args.dataDir,
18851
+ attemptId
18852
+ );
18853
+ releasedContinuations.add(attemptId);
18854
+ };
18803
18855
  const verifyReadinessReceipt = async (attempt, revision, recovering) => {
18804
18856
  const receipt = await readAppUpdateReceipt(
18805
18857
  args.dataDir,
@@ -18816,6 +18868,24 @@ async function runNpmShim(args) {
18816
18868
  for (; ; ) {
18817
18869
  const before = await readAppUpdateStateFile(args.dataDir);
18818
18870
  const pending = before?.pending ?? null;
18871
+ if (pending === null) {
18872
+ const result = before?.lastResult;
18873
+ const revision = result?.outcome === "updated" ? result.to : result?.restored;
18874
+ if (result !== null && result !== void 0 && revision?.kind === "npm" && isSameRevision(revision, launch)) {
18875
+ try {
18876
+ await verifyReadinessReceipt(
18877
+ result,
18878
+ launch,
18879
+ result.outcome === "failed"
18880
+ );
18881
+ releaseContinuations(result.id);
18882
+ } catch (error2) {
18883
+ args.output.warn(
18884
+ `Saved work remains held because its readiness receipt could not be verified: ${String(error2)}`
18885
+ );
18886
+ }
18887
+ }
18888
+ }
18819
18889
  if (pending !== null && pending.rollbackReason === void 0 && pending.from.kind === "npm") {
18820
18890
  const failed = await readAppUpdateReceipt(
18821
18891
  args.dataDir,
@@ -18885,8 +18955,12 @@ async function runNpmShim(args) {
18885
18955
  const result = state2?.lastResult;
18886
18956
  const ready = state2?.pending?.id !== attempt.id && result?.id === attempt.id && (recovering ? result.restored !== void 0 && isSameRevision(result.restored, launch) || result.outcome === "updated" && isSameRevision(result.to, launch) : result.outcome === "updated" && isSameRevision(result.to, launch));
18887
18957
  if (ready) {
18888
- if (recovering) await recordRestored(attempt, launch);
18958
+ if (recovering && result?.outcome === "updated")
18959
+ await recordRestored(attempt, launch);
18889
18960
  await verifyReadinessReceipt(attempt, launch, recovering);
18961
+ if (recovering && result?.outcome !== "updated")
18962
+ await recordRestored(attempt, launch);
18963
+ releaseContinuations(attempt.id);
18890
18964
  startupVerified = true;
18891
18965
  clearInterval(poll);
18892
18966
  } else if (result?.id === attempt.id && result.outcome === "failed" && state2?.pending === null) {
@@ -18931,8 +19005,12 @@ async function runNpmShim(args) {
18931
19005
  let verified = startupVerified;
18932
19006
  if (!verified && stateVerified) {
18933
19007
  try {
18934
- if (recovering) await recordRestored(attempt, launch);
19008
+ if (recovering && result?.outcome === "updated")
19009
+ await recordRestored(attempt, launch);
18935
19010
  await verifyReadinessReceipt(attempt, launch, recovering);
19011
+ if (recovering && result?.outcome !== "updated")
19012
+ await recordRestored(attempt, launch);
19013
+ releaseContinuations(attempt.id);
18936
19014
  verified = true;
18937
19015
  } catch (error2) {
18938
19016
  failure2 = `Could not verify the startup receipt: ${String(error2)}`;
@@ -18967,8 +19045,6 @@ async function runNpmShim(args) {
18967
19045
  continue;
18968
19046
  }
18969
19047
  }
18970
- if (attempt !== null && recovering && !startupVerified)
18971
- await recordRestored(attempt, launch);
18972
19048
  if (exit.code !== APP_UPDATE_RESTART_EXIT_CODE) {
18973
19049
  return toShimExitCode(exit);
18974
19050
  }
@@ -20238,7 +20314,7 @@ function requiredFullStackArtifactPaths(context) {
20238
20314
  function artifactPresent(artifact) {
20239
20315
  switch (artifact.kind) {
20240
20316
  case "file":
20241
- return existsSync2(artifact.path);
20317
+ return existsSync3(artifact.path);
20242
20318
  case "chunk-dir":
20243
20319
  try {
20244
20320
  return readdirSync(artifact.path).some((name2) => name2.endsWith(".js"));
@@ -20598,7 +20674,7 @@ async function resolveMovedDaemonLaunch(args) {
20598
20674
  function resolveEnrollmentRequirements(args) {
20599
20675
  const enrollKey = toOptionalString(args.env.BB_HOST_ENROLL_KEY);
20600
20676
  return {
20601
- enrolled: existsSync2(join14(args.context.dataDir, HOST_AUTH_FILE_NAME)),
20677
+ enrolled: existsSync3(join14(args.context.dataDir, HOST_AUTH_FILE_NAME)),
20602
20678
  ...enrollKey !== void 0 ? { enrollKey } : {}
20603
20679
  };
20604
20680
  }
@@ -20694,7 +20770,7 @@ async function runHostDaemonOnly(args) {
20694
20770
  ${bold("Moonlet host-daemon")}
20695
20771
 
20696
20772
  `);
20697
- if (existsSync2(args.context.daemonLockDir)) {
20773
+ if (existsSync3(args.context.daemonLockDir)) {
20698
20774
  warnExistingDaemonLock(args.context.daemonLockDir);
20699
20775
  }
20700
20776
  if (!enrollment.enrolled && enrollment.enrollKey === void 0) {
@@ -21561,8 +21637,9 @@ var shimOutput = {
21561
21637
  async function runBbApp(cliArgs = process.argv.slice(2), options = { worktreePolicy: null }) {
21562
21638
  const parsedArgs = parseLauncherArgs(cliArgs);
21563
21639
  const underAppUpdateShim = isRunningUnderAppUpdateShim(process.env);
21564
- const needsRecoverySupervisor = underAppUpdateShim && process.env[APP_UPDATE_RECOVERY_PROTOCOL_ENV_NAME] !== "1";
21640
+ const needsRecoverySupervisor = underAppUpdateShim && !hasAppUpdateContinuationSupervisor(process.env);
21565
21641
  delete process.env[APP_UPDATE_RECOVERY_PROTOCOL_ENV_NAME];
21642
+ delete process.env[APP_UPDATE_CONTINUATION_PROTOCOL_ENV_NAME];
21566
21643
  const appUpdateMode = takeAppUpdateModeFromEnv(process.env);
21567
21644
  if (parsedArgs.options.help) {
21568
21645
  printBbAppHelp();
@@ -21711,7 +21788,7 @@ async function runBbApp(cliArgs = process.argv.slice(2), options = { worktreePol
21711
21788
  ${bold("Moonlet")}
21712
21789
 
21713
21790
  `);
21714
- if (existsSync2(runtime.context.daemonLockDir)) {
21791
+ if (existsSync3(runtime.context.daemonLockDir)) {
21715
21792
  warnExistingDaemonLock(runtime.context.daemonLockDir);
21716
21793
  }
21717
21794
  const runtimeRecordOwned = await claimBbAppRuntimeFile({
package/dist/index.d.ts CHANGED
@@ -83,8 +83,8 @@ declare const appSettingsSchema: z$1.ZodObject<{
83
83
  providerOrder: z$1.ZodArray<z$1.ZodString>;
84
84
  defaultProviderId: z$1.ZodNullable<z$1.ZodString>;
85
85
  providerCompletedTurnDisplay: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
86
- collapse: "collapse";
87
86
  flat: "flat";
87
+ collapse: "collapse";
88
88
  }>>;
89
89
  streamerMode: z$1.ZodBoolean;
90
90
  allowFastServiceTier: z$1.ZodBoolean;
@@ -105,8 +105,8 @@ declare const appSettingsUpdateSchema: z$1.ZodUnion<readonly [z$1.ZodObject<{
105
105
  providerOrder: z$1.ZodArray<z$1.ZodString>;
106
106
  defaultProviderId: z$1.ZodNullable<z$1.ZodString>;
107
107
  providerCompletedTurnDisplay: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
108
- collapse: "collapse";
109
108
  flat: "flat";
109
+ collapse: "collapse";
110
110
  }>>;
111
111
  streamerMode: z$1.ZodBoolean;
112
112
  managedBranchPrefix: z$1.ZodString;
@@ -143,8 +143,8 @@ declare const appSettingsUpdateSchema: z$1.ZodUnion<readonly [z$1.ZodObject<{
143
143
  providerOrder: z$1.ZodArray<z$1.ZodString>;
144
144
  defaultProviderId: z$1.ZodNullable<z$1.ZodString>;
145
145
  providerCompletedTurnDisplay: z$1.ZodRecord<z$1.ZodString, z$1.ZodEnum<{
146
- collapse: "collapse";
147
146
  flat: "flat";
147
+ collapse: "collapse";
148
148
  }>>;
149
149
  streamerMode: z$1.ZodBoolean;
150
150
  machineServerUrl: z$1.ZodNullable<z$1.ZodString>;
@@ -4240,8 +4240,8 @@ declare const providerInfoSchema: z$1.ZodObject<{
4240
4240
  }, z$1.core.$strip>;
4241
4241
  }, z$1.core.$strip>], "kind">>;
4242
4242
  completedTurnDisplay: z$1.ZodEnum<{
4243
- collapse: "collapse";
4244
4243
  flat: "flat";
4244
+ collapse: "collapse";
4245
4245
  }>;
4246
4246
  available: z$1.ZodBoolean;
4247
4247
  strings: z$1.ZodOptional<z$1.ZodObject<{
@@ -7867,9 +7867,9 @@ declare const hostDaemonCommandRegistry: {
7867
7867
  base64: "base64";
7868
7868
  utf8: "utf8";
7869
7869
  }>;
7870
+ sha256: z$1.ZodString;
7870
7871
  sizeBytes: z$1.ZodNumber;
7871
7872
  mimeType: z$1.ZodOptional<z$1.ZodString>;
7872
- sha256: z$1.ZodString;
7873
7873
  modifiedAtMs: z$1.ZodOptional<z$1.ZodNumber>;
7874
7874
  notModified: z$1.ZodLiteral<true>;
7875
7875
  }, z$1.core.$strip>]>, "onlineRpc", true>;
@@ -8633,8 +8633,8 @@ declare const hostDaemonCommandRegistry: {
8633
8633
  message: z$1.ZodNullable<z$1.ZodString>;
8634
8634
  state: z$1.ZodNullable<z$1.ZodEnum<{
8635
8635
  pending: "pending";
8636
- ready: "ready";
8637
8636
  activating: "activating";
8637
+ ready: "ready";
8638
8638
  }>>;
8639
8639
  }, z$1.core.$strict>, "onlineRpc", true>;
8640
8640
  "server_move.prepare": HostDaemonCommandDescriptor<"server_move.prepare", z$1.ZodObject<{
@@ -16553,17 +16553,17 @@ declare const threadTimelineResponseSchema: z$1.ZodObject<{
16553
16553
  timeUsedSeconds: z$1.ZodNumber;
16554
16554
  }, z$1.core.$strip>>;
16555
16555
  providerCommands: z$1.ZodNullable<z$1.ZodArray<z$1.ZodObject<{
16556
+ source: z$1.ZodEnum<{
16557
+ command: "command";
16558
+ skill: "skill";
16559
+ }>;
16560
+ name: z$1.ZodString;
16556
16561
  origin: z$1.ZodEnum<{
16557
16562
  project: "project";
16558
16563
  builtin: "builtin";
16559
16564
  user: "user";
16560
16565
  }>;
16561
16566
  description: z$1.ZodNullable<z$1.ZodString>;
16562
- source: z$1.ZodEnum<{
16563
- command: "command";
16564
- skill: "skill";
16565
- }>;
16566
- name: z$1.ZodString;
16567
16567
  argumentHint: z$1.ZodNullable<z$1.ZodString>;
16568
16568
  }, z$1.core.$strip>>>;
16569
16569
  sessionOptions: z$1.ZodNullable<z$1.ZodArray<z$1.ZodDiscriminatedUnion<[z$1.ZodObject<{
@@ -24041,10 +24041,10 @@ declare function createApiClient(baseUrl: string, options?: PublicApiClientOptio
24041
24041
  timeUsedSeconds: number;
24042
24042
  } | null;
24043
24043
  providerCommands: {
24044
- origin: "project" | "builtin" | "user";
24045
- description: string | null;
24046
24044
  source: "command" | "skill";
24047
24045
  name: string;
24046
+ origin: "project" | "builtin" | "user";
24047
+ description: string | null;
24048
24048
  argumentHint: string | null;
24049
24049
  }[] | null;
24050
24050
  sessionOptions: ({
package/dist/index.js CHANGED
@@ -23362,6 +23362,19 @@ var templateDefinitions = [
23362
23362
  "invokedCommands": "Comma-separated slash commands or skills the prompt invokes, when it invokes any."
23363
23363
  }
23364
23364
  },
23365
+ {
23366
+ "id": "systemMessageAppUpdateCheckpoint",
23367
+ "body": "[bb system]\n\nAn automatic app update to {{version}} is waiting. Save your progress and remaining work, then end this turn at the next safe boundary. A continuation is saved and will resume after the update or verified rollback. The cooperative deadline is {{deadline}}; work still running then will be interrupted and may repeat its last unfinished step. Preserve unpublished work and do not wait for a quiet window.",
23368
+ "variables": {
23369
+ "version": "Published target version.",
23370
+ "deadline": "Cooperative deadline in UTC."
23371
+ }
23372
+ },
23373
+ {
23374
+ "id": "systemMessageAppUpdateContinue",
23375
+ "body": "[bb system]\n\nApp maintenance has finished or was cancelled. Continue the task from your saved progress. Check the outcome of any interrupted operation before repeating it, and preserve accepted input and unpublished work.",
23376
+ "variables": {}
23377
+ },
23365
23378
  {
23366
23379
  "id": "systemMessageChildThreadNeedsAttention",
23367
23380
  "body": "[bb system]\n\n{{threadMention}} needs help.\n{{blockerSummary}}\n\nReview the blocker. If you can resolve it from existing context, reply to the thread with guidance. Otherwise, ask the user for the missing decision.",
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env node
2
2
  import { createRequire as __createRequire } from "node:module";import { dirname as __pathDirname } from "node:path";import { fileURLToPath as __fileURLToPath } from "node:url";const require = __createRequire(import.meta.url);const __filename = __fileURLToPath(import.meta.url);const __dirname = __pathDirname(__filename);
3
- import{a as g,b as v,c as C}from"./bb-chunks/chunk-DUXDOOOQ.js";import{a as d,b as p,d as u}from"./bb-chunks/chunk-NCQMSH7M.js";import"./bb-chunks/chunk-5PWLIQO6.js";import{spawnSync as _}from"node:child_process";import{realpathSync as R}from"node:fs";import{resolve as S,win32 as B}from"node:path";var f="BB_CLI_REEXEC";function I(e){return e.platform==="win32"&&B.extname(e.target)===""?{command:e.nodePath,args:[e.target,...e.argv]}:{command:e.target,args:e.argv}}function x(e){try{return R(S(e))}catch{return null}}function b(e={}){let n=e.env??process.env;if(n[f]==="1")return;let r=n.BB_CLI?.trim();if(!r)return;let t=e.currentExecutablePath??process.argv[1];if(!t)return;let o=x(r),a=x(t);if(o===null||a===null||o===a)return;let i=e.argv??process.argv.slice(2),c={...n,[f]:"1"};if(e.reexec){e.reexec({target:o,argv:i,env:c});return}let l=I({argv:i,nodePath:process.execPath,platform:process.platform,target:o}),s=_(l.command,l.args,{env:c,stdio:"inherit"});if(s.error){process.stderr.write(`Moonlet: failed to re-exec BB_CLI=${o}: ${s.error.message}
4
- `),process.exitCode=1;return}process.exit(s.status===null?1:s.status)}process.env.FORCE_COLOR!==void 0&&delete process.env.NO_COLOR;b();var m=new p;m.name("bb").description("Moonlet CLI - manage your AI coding agents").enablePositionalOptions().exitOverride().showSuggestionAfterError(!1).version(u());var O=new Set([...g.map(e=>e.name),"help"]);function A(e){let n,r=()=>n??=e.createCliRuntimeContext();return{getUrl:()=>e.resolveServerUrl(r()),getContext:()=>e.resolveContextSnapshot(r())}}async function L(e,n,r){let t=await import("./bb-chunks/plugin-cli-proxy-WS4TNUQO.js"),o=await t.fetchPluginCliContributions(n());if(o.outcome==="unreachable"){if(r)return;let s=t.describeUnreachableServer(n(),o.cause,o.lastTimeoutMs,o.attempts);console.error(s);let{isJsonInvocation:E,writeCliErrorEnvelope:y}=await import("./bb-chunks/cli-error-output-KERMGTKZ.js");y({code:"server_unreachable",hint:null,message:s},E(process.argv)),process.exit(1)}if(o.outcome==="invalid")return;let a=t.findPluginCliCommand(o.contributions,e);if(a===void 0){let s=await t.findDisabledPluginForCommand(n(),e);s!==null&&(console.error(`bb ${e} is provided by the "${s}" plugin, which is disabled \u2014 run \`bb plugin enable ${s}\` or enable it in Plugins.`),process.exit(1));return}let i=process.argv.slice(3),c=a.commands.find(s=>s.name===i[0]);c!==void 0&&a.rendersHelp!==!0&&i.slice(1).some(s=>s==="--help"||s==="-h")&&(console.log(c.usage),process.exit(0));let l=await t.runPluginCliCommand(n(),a.pluginId,i);l!==0&&await w({code:"plugin_command_failed",command:t.pluginCommandLabel(a,i),exitCode:l,token:null}),process.exit(l)}async function w(e){let[{appendCliErrorLogEntry:n},{commandPathLabel:r}]=await Promise.all([import("./bb-chunks/cli-error-log-PHJFENHA.js"),import("./bb-chunks/commander-errors-2ZA2II5B.js")]);n({at:new Date().toISOString(),cliVersion:u(),code:e.code,command:e.command??r(m,process.argv),exitCode:e.exitCode,threadId:process.env.BB_THREAD_ID??null,token:e.token})}async function P(e,n){e.exitCode===0&&process.exit(0);let[r,t]=await Promise.all([import("./bb-chunks/commander-errors-2ZA2II5B.js"),import("./bb-chunks/context-hints-W52LG6SC.js")]),o=await r.summarizeCommanderError({argv:process.argv,error:e,program:m,resolveHostId:n===null?async()=>null:t.createContextHostIdResolver(n)});r.writeCommanderErrorSummary(o,process.argv),await w({code:o.code,command:null,exitCode:e.exitCode,token:o.logToken}),process.exit(e.exitCode)}async function h(e){try{await m.parseAsync(process.argv)}catch(n){throw n instanceof d&&await P(n,e),n}}async function M(e){let n=await import("./bb-chunks/command-resolution-U7GVB5KQ.js");if(!n.hasHelpFlag(process.argv))return;let r=n.resolveInvocation(m,process.argv);if(r.unknownSubcommand===null)return;let t=`error: unknown command '${r.unknownSubcommand}'`;console.error(t),await P(new d(1,"commander.unknownCommand",t),e)}async function k(){let[{JSON_SHAPE_BY_COMMAND_PATH:e,jsonShapeHelp:n},r]=await Promise.all([import("./bb-chunks/json-shapes-TGDCNQZQ.js"),import("./bb-chunks/command-resolution-U7GVB5KQ.js")]);for(let t of Object.keys(e)){let o=r.resolveInvocation(m,["node","bb",...t.split(" ")]),a=n(t);a===null||o.path.join(" ")!==t||o.command.addHelpText("after",a)}}async function D(){let e=process.argv[2],n=v(e);if(n.length===0){await h(null);return}let[r,...t]=await Promise.all([import("./bb-chunks/context-env-AK3SQXHK.js"),...n.map(i=>i.load())]),o=A(r);m.addHelpText("after",()=>{let i=o.getContext(),c=i.projectId??"<unset>",l=i.threadId??"<unset>";return`
3
+ import{a as g,b as v,c as C}from"./bb-chunks/chunk-G7YL5DVK.js";import{a as d,b as p,d as u}from"./bb-chunks/chunk-NCQMSH7M.js";import"./bb-chunks/chunk-5PWLIQO6.js";import{spawnSync as _}from"node:child_process";import{realpathSync as R}from"node:fs";import{resolve as S,win32 as B}from"node:path";var f="BB_CLI_REEXEC";function I(e){return e.platform==="win32"&&B.extname(e.target)===""?{command:e.nodePath,args:[e.target,...e.argv]}:{command:e.target,args:e.argv}}function x(e){try{return R(S(e))}catch{return null}}function b(e={}){let n=e.env??process.env;if(n[f]==="1")return;let r=n.BB_CLI?.trim();if(!r)return;let t=e.currentExecutablePath??process.argv[1];if(!t)return;let o=x(r),a=x(t);if(o===null||a===null||o===a)return;let i=e.argv??process.argv.slice(2),c={...n,[f]:"1"};if(e.reexec){e.reexec({target:o,argv:i,env:c});return}let l=I({argv:i,nodePath:process.execPath,platform:process.platform,target:o}),s=_(l.command,l.args,{env:c,stdio:"inherit"});if(s.error){process.stderr.write(`Moonlet: failed to re-exec BB_CLI=${o}: ${s.error.message}
4
+ `),process.exitCode=1;return}process.exit(s.status===null?1:s.status)}process.env.FORCE_COLOR!==void 0&&delete process.env.NO_COLOR;b();var m=new p;m.name("bb").description("Moonlet CLI - manage your AI coding agents").enablePositionalOptions().exitOverride().showSuggestionAfterError(!1).version(u());var O=new Set([...g.map(e=>e.name),"help"]);function A(e){let n,r=()=>n??=e.createCliRuntimeContext();return{getUrl:()=>e.resolveServerUrl(r()),getContext:()=>e.resolveContextSnapshot(r())}}async function L(e,n,r){let t=await import("./bb-chunks/plugin-cli-proxy-GCWTZ7AA.js"),o=await t.fetchPluginCliContributions(n());if(o.outcome==="unreachable"){if(r)return;let s=t.describeUnreachableServer(n(),o.cause,o.lastTimeoutMs,o.attempts);console.error(s);let{isJsonInvocation:E,writeCliErrorEnvelope:y}=await import("./bb-chunks/cli-error-output-KERMGTKZ.js");y({code:"server_unreachable",hint:null,message:s},E(process.argv)),process.exit(1)}if(o.outcome==="invalid")return;let a=t.findPluginCliCommand(o.contributions,e);if(a===void 0){let s=await t.findDisabledPluginForCommand(n(),e);s!==null&&(console.error(`bb ${e} is provided by the "${s}" plugin, which is disabled \u2014 run \`bb plugin enable ${s}\` or enable it in Plugins.`),process.exit(1));return}let i=process.argv.slice(3),c=a.commands.find(s=>s.name===i[0]);c!==void 0&&a.rendersHelp!==!0&&i.slice(1).some(s=>s==="--help"||s==="-h")&&(console.log(c.usage),process.exit(0));let l=await t.runPluginCliCommand(n(),a.pluginId,i);l!==0&&await w({code:"plugin_command_failed",command:t.pluginCommandLabel(a,i),exitCode:l,token:null}),process.exit(l)}async function w(e){let[{appendCliErrorLogEntry:n},{commandPathLabel:r}]=await Promise.all([import("./bb-chunks/cli-error-log-PHJFENHA.js"),import("./bb-chunks/commander-errors-LG2MJ6KV.js")]);n({at:new Date().toISOString(),cliVersion:u(),code:e.code,command:e.command??r(m,process.argv),exitCode:e.exitCode,threadId:process.env.BB_THREAD_ID??null,token:e.token})}async function P(e,n){e.exitCode===0&&process.exit(0);let[r,t]=await Promise.all([import("./bb-chunks/commander-errors-LG2MJ6KV.js"),import("./bb-chunks/context-hints-V6LBX4TV.js")]),o=await r.summarizeCommanderError({argv:process.argv,error:e,program:m,resolveHostId:n===null?async()=>null:t.createContextHostIdResolver(n)});r.writeCommanderErrorSummary(o,process.argv),await w({code:o.code,command:null,exitCode:e.exitCode,token:o.logToken}),process.exit(e.exitCode)}async function h(e){try{await m.parseAsync(process.argv)}catch(n){throw n instanceof d&&await P(n,e),n}}async function M(e){let n=await import("./bb-chunks/command-resolution-U7GVB5KQ.js");if(!n.hasHelpFlag(process.argv))return;let r=n.resolveInvocation(m,process.argv);if(r.unknownSubcommand===null)return;let t=`error: unknown command '${r.unknownSubcommand}'`;console.error(t),await P(new d(1,"commander.unknownCommand",t),e)}async function k(){let[{JSON_SHAPE_BY_COMMAND_PATH:e,jsonShapeHelp:n},r]=await Promise.all([import("./bb-chunks/json-shapes-TGDCNQZQ.js"),import("./bb-chunks/command-resolution-U7GVB5KQ.js")]);for(let t of Object.keys(e)){let o=r.resolveInvocation(m,["node","bb",...t.split(" ")]),a=n(t);a===null||o.path.join(" ")!==t||o.command.addHelpText("after",a)}}async function D(){let e=process.argv[2],n=v(e);if(n.length===0){await h(null);return}let[r,...t]=await Promise.all([import("./bb-chunks/context-env-5PHP22B2.js"),...n.map(i=>i.load())]),o=A(r);m.addHelpText("after",()=>{let i=o.getContext(),c=i.projectId??"<unset>",l=i.threadId??"<unset>";return`
5
5
 
6
6
  Current context:
7
7
  BB_PROJECT_ID: ${c}
@@ -1,5 +1,5 @@
1
1
  import { createRequire as __createRequire } from "node:module";import { dirname as __pathDirname } from "node:path";import { fileURLToPath as __fileURLToPath } from "node:url";const require = __createRequire(import.meta.url);const __filename = __fileURLToPath(import.meta.url);const __dirname = __pathDirname(__filename);
2
- import{j as a}from"./chunk-CO7MWB5S.js";import"./chunk-NCQMSH7M.js";import"./chunk-WWZ7D6EQ.js";import{b as I}from"./chunk-JV4DTKAM.js";import"./chunk-4MDJTHVY.js";import"./chunk-VLWNZSJS.js";import"./chunk-NBD63LSE.js";import"./chunk-7XQFWLHC.js";import"./chunk-ASVZVMB7.js";import"./chunk-E7J2DJY7.js";import{a as r}from"./chunk-BNG7SSF7.js";import"./chunk-5PWLIQO6.js";import{writeFile as y}from"node:fs/promises";var x=["chrome","chromium","helium","edge","brave","vivaldi","opera","arc","dia","firefox","zen","safari"],h=r.union([r.enum(x),r.string().regex(/^storage-[a-f0-9]{64}$/)]),k=r.enum(["notInstalled","needsKeychainApproval","keychainItemMissing","needsFullDiskAccess","browserRunning","unsupportedPlatform"]),B=r.enum([...k.options,"keychainUnavailable","unknownSource","unknownSourceProfile","readFailed"]),g=r.string().min(1).max(4096),v=r.object({directory:g,name:r.string().min(1).max(256),cookieCount:r.number().int().nonnegative().optional()}).strict(),T=r.object({id:h,name:r.string().min(1).max(64),profiles:r.array(v).max(100),unavailable:k.optional(),icon:r.string().max(256*1024).regex(/^data:image\/[a-z+]+;base64,/u).optional()}).strict(),E=r.object({sourceId:h,sourceProfileDirectory:g}),D=r.object({imported:r.number().int().nonnegative(),skipped:r.number().int().nonnegative(),skippedDomains:r.array(r.string().max(1024)).max(20)}).strict(),j=r.discriminatedUnion("ok",[D.extend({ok:r.literal(!0)}).strict(),r.object({ok:r.literal(!1),reason:B}).strict()]),R={notInstalled:"Not installed on this machine.",needsKeychainApproval:"Needs Keychain access to read its cookie encryption key. Approve the prompt and try again.",keychainItemMissing:"No matching encryption key was found in your Keychain. Open and sign in to the source browser, then try again. Browsers with custom key names may need additional support.",needsFullDiskAccess:"Give BB Full Disk Access in System Settings \u2192 Privacy & Security, then try again.",browserRunning:"Quit the browser first so its cookie database can be read.",unsupportedPlatform:"Importing from this browser isn't possible on this platform."},S={...R,keychainUnavailable:"The system keyring could not be reached. Make sure it is running and unlocked, then try again.",unknownSource:"That browser is no longer available to import from.",unknownSourceProfile:"That browser profile no longer exists.",readFailed:"The browser's cookie database could not be read."};function p(n){return{hostId:n.host,instanceId:n.instance,generation:n.generation,threadId:n.thread}}function O(n){return n.requiredOption("--host <id>","Browser host ID").requiredOption("--instance <id>","Desktop window instance ID").requiredOption("--generation <id>","Desktop connection generation").option("--json","Print machine-readable JSON output")}function $(n){return n.sources.map(s=>{let i=s.unavailable??"ready",o=s.profiles.map(e=>`${e.directory}${e.name===e.directory?"":` "${e.name}"`}${e.cookieCount===void 0?"":` (${e.cookieCount})`}`).join(", ");return`${s.id} ${i} ${o}`.trimEnd()}).join(`
2
+ import{j as a}from"./chunk-CQQULLUB.js";import"./chunk-NCQMSH7M.js";import"./chunk-WWZ7D6EQ.js";import{b as I}from"./chunk-GRWMDTBD.js";import"./chunk-HIWLZ4JX.js";import"./chunk-VLWNZSJS.js";import"./chunk-2VBVXHCO.js";import"./chunk-EGI3PDJP.js";import"./chunk-6W522XWW.js";import"./chunk-E7J2DJY7.js";import{a as r}from"./chunk-BNG7SSF7.js";import"./chunk-5PWLIQO6.js";import{writeFile as y}from"node:fs/promises";var x=["chrome","chromium","helium","edge","brave","vivaldi","opera","arc","dia","firefox","zen","safari"],h=r.union([r.enum(x),r.string().regex(/^storage-[a-f0-9]{64}$/)]),k=r.enum(["notInstalled","needsKeychainApproval","keychainItemMissing","needsFullDiskAccess","browserRunning","unsupportedPlatform"]),B=r.enum([...k.options,"keychainUnavailable","unknownSource","unknownSourceProfile","readFailed"]),g=r.string().min(1).max(4096),v=r.object({directory:g,name:r.string().min(1).max(256),cookieCount:r.number().int().nonnegative().optional()}).strict(),T=r.object({id:h,name:r.string().min(1).max(64),profiles:r.array(v).max(100),unavailable:k.optional(),icon:r.string().max(256*1024).regex(/^data:image\/[a-z+]+;base64,/u).optional()}).strict(),E=r.object({sourceId:h,sourceProfileDirectory:g}),D=r.object({imported:r.number().int().nonnegative(),skipped:r.number().int().nonnegative(),skippedDomains:r.array(r.string().max(1024)).max(20)}).strict(),j=r.discriminatedUnion("ok",[D.extend({ok:r.literal(!0)}).strict(),r.object({ok:r.literal(!1),reason:B}).strict()]),R={notInstalled:"Not installed on this machine.",needsKeychainApproval:"Needs Keychain access to read its cookie encryption key. Approve the prompt and try again.",keychainItemMissing:"No matching encryption key was found in your Keychain. Open and sign in to the source browser, then try again. Browsers with custom key names may need additional support.",needsFullDiskAccess:"Give BB Full Disk Access in System Settings \u2192 Privacy & Security, then try again.",browserRunning:"Quit the browser first so its cookie database can be read.",unsupportedPlatform:"Importing from this browser isn't possible on this platform."},S={...R,keychainUnavailable:"The system keyring could not be reached. Make sure it is running and unlocked, then try again.",unknownSource:"That browser is no longer available to import from.",unknownSourceProfile:"That browser profile no longer exists.",readFailed:"The browser's cookie database could not be read."};function p(n){return{hostId:n.host,instanceId:n.instance,generation:n.generation,threadId:n.thread}}function O(n){return n.requiredOption("--host <id>","Browser host ID").requiredOption("--instance <id>","Desktop window instance ID").requiredOption("--generation <id>","Desktop connection generation").option("--json","Print machine-readable JSON output")}function $(n){return n.sources.map(s=>{let i=s.unavailable??"ready",o=s.profiles.map(e=>`${e.directory}${e.name===e.directory?"":` "${e.name}"`}${e.cookieCount===void 0?"":` (${e.cookieCount})`}`).join(", ");return`${s.id} ${i} ${o}`.trimEnd()}).join(`
3
3
  `)||"No importable browsers found"}function P(n){if(!n.ok)return`Import failed: ${S[n.reason]}`;let l=n.skipped>0?`, skipped ${n.skipped}${n.skippedDomains.length>0?` (${n.skippedDomains.join(", ")})`:""}`:"";return`Imported ${n.imported} cookies${l}`}function d(n){return n.requiredOption("--host <id>","Browser host ID").requiredOption("--instance <id>","Desktop window instance ID").requiredOption("--generation <id>","Desktop connection generation").requiredOption("--thread <id>","Owning thread ID").option("--json","Print machine-readable JSON output")}function c(n,l,s){console.log(l.json?JSON.stringify(n):s)}function _(n,l){let s=n.command("browser").description("Experimental built-in desktop browser control"),i=()=>I(l()).experimental_desktopBrowsers;s.command("instances").description("List connected desktop windows on a host").requiredOption("--host <id>","Browser host ID").option("--json","Print machine-readable JSON output").action(a(async o=>{let e=await i().listInstances({hostId:o.host});c(e,o,e.instances.map(t=>`${t.instanceId} ${t.generation} ${t.label}`).join(`
4
4
  `)||"No connected desktop windows")})),d(s.command("tabs").description("List a thread's native browser tabs")).action(a(async o=>{let e=await i().listTabs(p(o));c(e,o,e.tabs.map(t=>`${t.tabId} ${t.title||t.url} ${t.control?.controllerLabel??"Available"}`).join(`
5
5
  `)||"No browser tabs in this thread")})),d(s.command("create").description("Create a tab in the Moonlet browser profile")).option("--url <url>","Initial HTTP(S) URL; defaults to about:blank").option("--reveal","Show the new native tab").action(a(async o=>{let e=await i().createTab({...p(o),...o.url===void 0?{}:{url:o.url},...o.reveal?{presentation:"reveal"}:{}});c(e,o,`Created tab ${e.tab.tabId}`)})),d(s.command("acquire <tabIds...>").description("Acquire exclusive, expiring control of selected tabs")).requiredOption("--controller <label>","Visible controller name").option("--ttl-ms <ms>","Lease duration; defaults to five minutes, maximum thirty").action(a(async(o,e)=>{let t=await i().acquireControl({...p(e),tabIds:o,controllerLabel:e.controller,...e.ttlMs===void 0?{}:{ttlMs:Number(e.ttlMs)}});c(t,e,`Control lease ${t.leaseId} expires ${new Date(t.expiresAt).toISOString()}`)})),d(s.command("connection <leaseId>").description("Write private CDP connection JSON to a new local file")).requiredOption("--output <file>","New credential file (mode 0600); endpoint works only on browser host").action(a(async(o,e)=>{let t=await i().openConnection({...p(e),leaseId:o});await y(e.output,JSON.stringify(t),{mode:384,flag:"wx"}),c({path:e.output,hostId:t.hostId,expiresAt:t.expiresAt},e,`Wrote private connection to ${e.output}`)})),d(s.command("release <leaseId>").description("Stop automation and keep tabs open")).action(a(async(o,e)=>{c(await i().releaseControl({...p(e),leaseId:o}),e,"Released browser control")}));for(let o of["reveal","close"])d(s.command(`${o} <tabId>`).description(o==="close"?"Close a native tab":"Reveal a native tab in its desktop window")).action(a(async(e,t)=>{let m={...p(t),tabId:e};c(await(o==="close"?i().closeTab(m):i().revealTab(m)),t,`${o==="close"?"Closed":"Revealed"} tab ${e}`)}));d(s.command("capture <tabId>").description("Save a native tab screenshot without focusing it")).requiredOption("--output <file>","New local JPEG file").action(a(async(o,e)=>{let t=await i().captureTab({...p(e),tabId:o});await y(e.output,Buffer.from(t.base64,"base64"),{flag:"wx",mode:384}),c({path:e.output,mimeType:t.mimeType},e,`Saved screenshot to ${e.output}`)})),O(s.command("import-sources").description("List browsers on the desktop host whose cookies can be imported")).action(a(async o=>{let e=await i().listImportSources({hostId:o.host,instanceId:o.instance,generation:o.generation});c(e,o,$(e))})),O(s.command("import-cookies").description("Copy signed-in cookies from an installed browser into the Moonlet browser")).requiredOption("--from <source>","Source browser ID from `bb browser import-sources`").requiredOption("--profile <directory>","Source profile directory as printed by `bb browser import-sources`").action(a(async o=>{let e=await i().importCookies({hostId:o.host,instanceId:o.instance,generation:o.generation,sourceId:h.parse(o.from),sourceProfileDirectory:o.profile});c(e,o,P(e)),e.ok||(process.exitCode=1)})),d(s.command("watch").description("Print changed tab snapshots every two seconds until interrupted")).action(a(async o=>{await new Promise((e,t)=>{let m=i().subscribe({...p(o),onChange:b=>c(b,o,b.tabs.map(w=>`${w.tabId} ${w.title||w.url} ${w.control?.controllerLabel??"Available"}`).join(`
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __createRequire } from "node:module";import { dirname as __pathDirname } from "node:path";import { fileURLToPath as __fileURLToPath } from "node:url";const require = __createRequire(import.meta.url);const __filename = __fileURLToPath(import.meta.url);const __dirname = __pathDirname(__filename);
2
- import{c as t,d as s}from"./chunk-7XQFWLHC.js";import{i as d}from"./chunk-ASVZVMB7.js";var n=class extends Error{code;hint;constructor(r){super(r.message),this.name="CliUsageError",this.code=r.code,this.hint=r.hint}};var l=/^[a-zA-Z0-9_-]+$/;function f(e={}){return{cliConfig:e.cliConfig??s()}}function i(e,r){if(!l.test(e))throw new Error(`Invalid ID from ${r}: "${e}". IDs must contain only letters, digits, hyphens, and underscores.`);return e}function p(e){return e.cliConfig.BB_SERVER_URL}function g(){let e=t(process.env.BB_PROJECT_ID);if(e)return i(e,"BB_PROJECT_ID")}function a(){let e=t(process.env.BB_THREAD_ID);if(e)return i(e,"BB_THREAD_ID")}function u(e){let r=t(e.value);if(r)return i(r,e.flagName)}function x(e){let r=u({flagName:"<threadId> argument",value:e});if(r)return r;throw new Error("Missing thread ID. Pass <threadId>.")}function E(e,r){if(r.self&&e)throw new Error("Cannot combine a thread ID argument with --self.");if(r.self){let o=a();if(!o)throw new Error("--self requires BB_THREAD_ID to be set.");return o}if(e)return i(e,"<threadId> argument");throw new n({code:"missing_required",hint:d(),message:"Missing thread ID. Pass <threadId> or use --self."})}function R(e=f()){return{projectId:g(),threadId:a(),serverUrl:e.cliConfig.BB_SERVER_URL}}export{n as a,f as b,p as c,g as d,a as e,u as f,x as g,E as h,R as i};
2
+ import{c as t,d as s}from"./chunk-EGI3PDJP.js";import{i as d}from"./chunk-6W522XWW.js";var n=class extends Error{code;hint;constructor(r){super(r.message),this.name="CliUsageError",this.code=r.code,this.hint=r.hint}};var l=/^[a-zA-Z0-9_-]+$/;function f(e={}){return{cliConfig:e.cliConfig??s()}}function i(e,r){if(!l.test(e))throw new Error(`Invalid ID from ${r}: "${e}". IDs must contain only letters, digits, hyphens, and underscores.`);return e}function p(e){return e.cliConfig.BB_SERVER_URL}function g(){let e=t(process.env.BB_PROJECT_ID);if(e)return i(e,"BB_PROJECT_ID")}function a(){let e=t(process.env.BB_THREAD_ID);if(e)return i(e,"BB_THREAD_ID")}function u(e){let r=t(e.value);if(r)return i(r,e.flagName)}function x(e){let r=u({flagName:"<threadId> argument",value:e});if(r)return r;throw new Error("Missing thread ID. Pass <threadId>.")}function E(e,r){if(r.self&&e)throw new Error("Cannot combine a thread ID argument with --self.");if(r.self){let o=a();if(!o)throw new Error("--self requires BB_THREAD_ID to be set.");return o}if(e)return i(e,"<threadId> argument");throw new n({code:"missing_required",hint:d(),message:"Missing thread ID. Pass <threadId> or use --self."})}function R(e=f()){return{projectId:g(),threadId:a(),serverUrl:e.cliConfig.BB_SERVER_URL}}export{n as a,f as b,p as c,g as d,a as e,u as f,x as g,E as h,R as i};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __createRequire } from "node:module";import { dirname as __pathDirname } from "node:path";import { fileURLToPath as __fileURLToPath } from "node:url";const require = __createRequire(import.meta.url);const __filename = __fileURLToPath(import.meta.url);const __dirname = __pathDirname(__filename);
2
- import{ja as n}from"./chunk-4MDJTHVY.js";var o;async function e(){if(o===void 0&&(o=await n()),!o)throw new Error("Cannot reach local host daemon. Is it running?");return o}export{e as a};
2
+ import{ja as n}from"./chunk-HIWLZ4JX.js";var o;async function e(){if(o===void 0&&(o=await n()),!o)throw new Error("Cannot reach local host daemon. Is it running?");return o}export{e as a};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __createRequire } from "node:module";import { dirname as __pathDirname } from "node:path";import { fileURLToPath as __fileURLToPath } from "node:url";const require = __createRequire(import.meta.url);const __filename = __fileURLToPath(import.meta.url);const __dirname = __pathDirname(__filename);
2
- var a=/^[a-zA-Z0-9_-]+$/;function i(t){let n=process.env[t]?.trim();return n===void 0||n.length===0?null:a.test(n)?n:null}function l(){return i("BB_PROJECT_ID")}function o(){return i("BB_THREAD_ID")}function s(){return i("BB_ENVIRONMENT_ID")}function h(t){return async()=>{let n=s();if(n===null)return null;try{let{createCliBbSdk:e}=await import("./client-UV5XAEUU.js"),d=e(t()).environments.get({environmentId:n}).then(r=>r.hostId),u=new Promise(r=>{setTimeout(()=>r(null),2500).unref()});return await Promise.race([d,u])}catch{return null}}}function m(){let t=l();return t===null?"List project IDs with `bb project list`.":`This thread's project is ${t}; add --project ${t}.`}function I(){let t=o();return t===null?"List thread IDs with `bb thread list`.":`The current thread is ${t}; add --thread ${t}.`}function g(){let t=s();return t===null?"List environment IDs with `bb environment list`.":`The current environment is ${t}; add --environment ${t}.`}async function p(t,n){let e=await n();return e===null?"List machine IDs with `bb machine list`.":`This thread runs on ${e}; add ${t} ${e}.`}function T(){let t=o();return t===null?"Pass a thread ID; --self is unavailable because BB_THREAD_ID is not set.":`Add --self to target the current thread (${t}), or pass a thread ID.`}function x(){let t=o();return t===null?"Add one of --thread <id>, --environment <id>, or --machine <id-or-name>.":`For this thread's terminals add --thread ${t}.`}export{l as a,o as b,s as c,h as d,m as e,I as f,g,p as h,T as i,x as j};
2
+ var a=/^[a-zA-Z0-9_-]+$/;function i(t){let n=process.env[t]?.trim();return n===void 0||n.length===0?null:a.test(n)?n:null}function l(){return i("BB_PROJECT_ID")}function o(){return i("BB_THREAD_ID")}function s(){return i("BB_ENVIRONMENT_ID")}function h(t){return async()=>{let n=s();if(n===null)return null;try{let{createCliBbSdk:e}=await import("./client-ARSXLZ7U.js"),d=e(t()).environments.get({environmentId:n}).then(r=>r.hostId),u=new Promise(r=>{setTimeout(()=>r(null),2500).unref()});return await Promise.race([d,u])}catch{return null}}}function m(){let t=l();return t===null?"List project IDs with `bb project list`.":`This thread's project is ${t}; add --project ${t}.`}function I(){let t=o();return t===null?"List thread IDs with `bb thread list`.":`The current thread is ${t}; add --thread ${t}.`}function g(){let t=s();return t===null?"List environment IDs with `bb environment list`.":`The current environment is ${t}; add --environment ${t}.`}async function p(t,n){let e=await n();return e===null?"List machine IDs with `bb machine list`.":`This thread runs on ${e}; add ${t} ${e}.`}function T(){let t=o();return t===null?"Pass a thread ID; --self is unavailable because BB_THREAD_ID is not set.":`Add --self to target the current thread (${t}), or pass a thread ID.`}function x(){let t=o();return t===null?"Add one of --thread <id>, --environment <id>, or --machine <id-or-name>.":`For this thread's terminals add --thread ${t}.`}export{l as a,o as b,s as c,h as d,m as e,I as f,g,p as h,T as i,x as j};
@@ -1,2 +1,2 @@
1
1
  import { createRequire as __createRequire } from "node:module";import { dirname as __pathDirname } from "node:path";import { fileURLToPath as __fileURLToPath } from "node:url";const require = __createRequire(import.meta.url);const __filename = __fileURLToPath(import.meta.url);const __dirname = __pathDirname(__filename);
2
- import{b as l,d as x}from"./chunk-NCQMSH7M.js";import{a as p,c as g,d as h,e as E}from"./chunk-WWZ7D6EQ.js";import{ha as f}from"./chunk-4MDJTHVY.js";import{d,e as m}from"./chunk-VLWNZSJS.js";import{a as c}from"./chunk-NBD63LSE.js";import{createInterface as w}from"node:readline/promises";var A=d;function $(n,o){return n.json?(console.log(JSON.stringify(o,null,2)),h(),!0):!1}function D(n,o){return[...o,n]}function J(n){n.source==="env"&&console.error(`Thread ${n.id} (from BB_THREAD_ID)`)}async function P(n){if(!process.stdin.isTTY||!process.stdout.isTTY)throw new Error("Refusing destructive action without an interactive terminal. Re-run with --yes to confirm.");let o=w({input:process.stdin,output:process.stdout});try{let e=(await o.question(`${n} [y/N] `)).trim().toLowerCase();return e==="y"||e==="yes"}finally{o.close()}}function u(n){if(!(n instanceof Error))return String(n);let o=new Set,r=[],e=[n];for(;e.length>0;){let t=e.pop();if(t===void 0||o.has(t))continue;o.add(t),t.message.length>0&&r.push(t.message);let i=[];t.cause instanceof Error&&i.push(t.cause),t instanceof AggregateError&&i.push(...t.errors.filter(s=>s instanceof Error));for(let s=i.length-1;s>=0;s-=1)e.push(i[s])}return r.join(": ")}function B(n){if(n===void 0)return;let o=m.safeParse(n);if(o.success)return o.data;throw new Error(`Invalid reasoning level '${n}'. Expected a level id the model lists, such as ${y(A)}.`)}function _(n,o){return new Error(`${n}: ${u(o)}`)}function y(n){return n.map(o=>`'${o}'`).join(" or ")}var a=class extends Error{code;exitCode;hint;constructor(o,r,e={code:"error",hint:null}){super(o),this.name="CliExitError",this.code=e.code,this.exitCode=r,this.hint=e.hint}};function z(n){return async(...o)=>{g();try{await n(...o)}catch(r){if(R(r))throw r;let e=r instanceof a?r.exitCode:1,t=r instanceof a?r.message:u(r),i=r instanceof c||r instanceof a?r.hint:null,s=v(r);console.error(`Error: ${t}`),i!==null&&console.error(i),E({code:s,hint:i,message:t},T(o)),await I({code:s,command:b(o),exitCode:e}),process.exit(e)}}}function v(n){return n instanceof c||n instanceof a?n.code:n instanceof f?n.code??`http_${n.status}`:"error"}function C(n){let o=n[n.length-1];return o instanceof l?o:null}function T(n){let o=C(n);if(o===null)return p();let r=o.opts();return r.json===!0||r.format==="json"}function b(n){let o=C(n);if(o===null)return"";let r=[];for(let e=o;e!==null&&e.parent!==null;e=e.parent)r.unshift(e.name());return r.join(" ")}async function I(n){try{let{appendCliErrorLogEntry:o}=await import("./cli-error-log-PHJFENHA.js");o({at:new Date().toISOString(),cliVersion:x(),code:n.code,command:n.command,exitCode:n.exitCode,threadId:process.env.BB_THREAD_ID??null,token:null})}catch{}}function R(n){return n instanceof Error&&n.message.startsWith("process.exit:")}export{$ as a,D as b,J as c,P as d,u as e,B as f,_ as g,y as h,a as i,z as j};
2
+ import{b as l,d as x}from"./chunk-NCQMSH7M.js";import{a as p,c as g,d as h,e as E}from"./chunk-WWZ7D6EQ.js";import{ha as f}from"./chunk-HIWLZ4JX.js";import{d,e as m}from"./chunk-VLWNZSJS.js";import{a as c}from"./chunk-2VBVXHCO.js";import{createInterface as w}from"node:readline/promises";var A=d;function $(n,o){return n.json?(console.log(JSON.stringify(o,null,2)),h(),!0):!1}function D(n,o){return[...o,n]}function J(n){n.source==="env"&&console.error(`Thread ${n.id} (from BB_THREAD_ID)`)}async function P(n){if(!process.stdin.isTTY||!process.stdout.isTTY)throw new Error("Refusing destructive action without an interactive terminal. Re-run with --yes to confirm.");let o=w({input:process.stdin,output:process.stdout});try{let e=(await o.question(`${n} [y/N] `)).trim().toLowerCase();return e==="y"||e==="yes"}finally{o.close()}}function u(n){if(!(n instanceof Error))return String(n);let o=new Set,r=[],e=[n];for(;e.length>0;){let t=e.pop();if(t===void 0||o.has(t))continue;o.add(t),t.message.length>0&&r.push(t.message);let i=[];t.cause instanceof Error&&i.push(t.cause),t instanceof AggregateError&&i.push(...t.errors.filter(s=>s instanceof Error));for(let s=i.length-1;s>=0;s-=1)e.push(i[s])}return r.join(": ")}function B(n){if(n===void 0)return;let o=m.safeParse(n);if(o.success)return o.data;throw new Error(`Invalid reasoning level '${n}'. Expected a level id the model lists, such as ${y(A)}.`)}function _(n,o){return new Error(`${n}: ${u(o)}`)}function y(n){return n.map(o=>`'${o}'`).join(" or ")}var a=class extends Error{code;exitCode;hint;constructor(o,r,e={code:"error",hint:null}){super(o),this.name="CliExitError",this.code=e.code,this.exitCode=r,this.hint=e.hint}};function z(n){return async(...o)=>{g();try{await n(...o)}catch(r){if(R(r))throw r;let e=r instanceof a?r.exitCode:1,t=r instanceof a?r.message:u(r),i=r instanceof c||r instanceof a?r.hint:null,s=v(r);console.error(`Error: ${t}`),i!==null&&console.error(i),E({code:s,hint:i,message:t},T(o)),await I({code:s,command:b(o),exitCode:e}),process.exit(e)}}}function v(n){return n instanceof c||n instanceof a?n.code:n instanceof f?n.code??`http_${n.status}`:"error"}function C(n){let o=n[n.length-1];return o instanceof l?o:null}function T(n){let o=C(n);if(o===null)return p();let r=o.opts();return r.json===!0||r.format==="json"}function b(n){let o=C(n);if(o===null)return"";let r=[];for(let e=o;e!==null&&e.parent!==null;e=e.parent)r.unshift(e.name());return r.join(" ")}async function I(n){try{let{appendCliErrorLogEntry:o}=await import("./cli-error-log-PHJFENHA.js");o({at:new Date().toISOString(),cliVersion:x(),code:n.code,command:n.command,exitCode:n.exitCode,threadId:process.env.BB_THREAD_ID??null,token:null})}catch{}}function R(n){return n instanceof Error&&n.message.startsWith("process.exit:")}export{$ as a,D as b,J as c,P as d,u as e,B as f,_ as g,y as h,a as i,z as j};
@@ -1,3 +1,3 @@
1
1
  import { createRequire as __createRequire } from "node:module";import { dirname as __pathDirname } from "node:path";import { fileURLToPath as __fileURLToPath } from "node:url";const require = __createRequire(import.meta.url);const __filename = __fileURLToPath(import.meta.url);const __dirname = __pathDirname(__filename);
2
- import{a as R,b as d,c as P,d as L,g as m,h as S}from"./chunk-E7J2DJY7.js";import{a as t}from"./chunk-BNG7SSF7.js";function y(e){if(e==null)return;let r=e.trim();return r.length>0?r:void 0}import{homedir as oe}from"node:os";function a(e={}){let r=e.env??process.env;return{context:{homeDir:e.homeDir??oe()},env:r,mode:e.mode??L(r.NODE_ENV)}}function O(e){let r=e.env[e.definition.name];if(r===void 0)throw new Error(`${e.definition.name} is required`);return e.definition.parse({context:e.context,name:e.definition.name,value:r})}function f(e){let r=e.env[e.definition.name];if(r!==void 0)return e.definition.parse({context:e.context,name:e.definition.name,value:r})}import{delimiter as Ne}from"node:path";var We=t.object({placeholder:t.boolean(),initiatorTelemetry:t.boolean().default(!0),timelineWindowEventBudget:t.number().int().positive()}),_={placeholder:!1,initiatorTelemetry:!0,timelineWindowEventBudget:1500};var D={appVersion:"0.0.0-dev",logLevel:{prod:"info",dev:"debug"},secretToken:{dev:"dev-secret"}};import{mkdir as de,rename as me,unlink as I,writeFile as fe}from"node:fs/promises";import{basename as k,dirname as _e,join as C}from"node:path";import{mkdir as ie,open as ae}from"node:fs/promises";import{createRequire as se}from"node:module";import{dirname as pe}from"node:path";import{setTimeout as ce}from"node:timers/promises";var ue=25,E;function le(){if(E!==void 0)return E;let e=se(import.meta.url)("fs-native-extensions");if(e===null||typeof e!="object"||!("tryLock"in e)||typeof e.tryLock!="function"||!("unlock"in e)||typeof e.unlock!="function")throw new Error("Invalid fs-native-extensions module");let r=e.tryLock,n=e.unlock;return E={tryLock:o=>{let i=Reflect.apply(r,e,[o]);if(typeof i!="boolean")throw new Error("Invalid fs-native-extensions lock result");return i},unlock:o=>{Reflect.apply(n,e,[o])}},E}var c=class extends Error{constructor(n){super(`Timed out waiting for file lock: ${n}`);this.path=n}path};async function w(e){let r=le();await ie(pe(e.path),{recursive:!0});let n=await ae(e.path,"a+",384),o=!1;try{let i=performance.now()+e.timeoutMs;for(;;){if(r.tryLock(n.fd)){o=!0;break}if(performance.now()>=i)throw new c(e.path);await ce(ue)}return await e.work()}finally{try{o&&r.unlock(n.fd)}finally{await n.close()}}}var Ee=5e3;function Ae(e,r){return e instanceof Error&&"code"in e&&e.code===r}async function he(e){let r=_e(e.path);await de(r,{recursive:!0});let n=C(r,`.${k(e.path)}.lock`);try{return await w({path:n,timeoutMs:Ee,work:async()=>{let o=C(r,`.${k(e.path)}.tmp`);try{await I(o)}catch(i){if(!Ae(i,"ENOENT"))throw i}try{let i=e.mutate(await e.read());return await fe(o,`${JSON.stringify(i,null,2)}
3
- `,{encoding:"utf8",flag:"wx",mode:384}),await me(o,e.path),i}finally{await I(o).catch(()=>{})}}})}catch(o){throw o instanceof c?new Error(`Timed out waiting to update ${e.path}; another bb command is updating it. Retry the command.`):o}}var M="BB_APP_UPDATE_MODE";var ve=1;var h=t.enum(["npm","source"]),B=t.string().regex(/^[0-9a-f]{40}$/u),F=t.object({kind:t.literal("npm"),packageRoot:t.string().min(1),version:t.string().min(1)}).passthrough(),H=t.object({commit:B,kind:t.literal("source"),version:t.string().min(1)}).passthrough(),s=t.discriminatedUnion("kind",[F,H]),ge=t.enum(["prepare","install","startup"]),Re=t.object({from:s,id:t.string().min(1),requestedAt:t.string().min(1),rollbackReason:t.string().min(1).optional(),failedTarget:s.optional(),to:s}).passthrough(),Pe=t.enum(["updated","failed"]),b=t.object({acknowledged:t.boolean(),finishedAt:t.string().min(1),from:s,id:t.string().min(1),logTail:t.array(t.string()),message:t.string().nullable(),outcome:Pe,restored:s.optional(),retryable:t.boolean().optional(),phase:ge.nullable(),to:s}).passthrough(),Se=t.object({id:t.string().min(1),from:t.object({version:t.string().min(1),commit:t.string().nullable()}),to:t.object({version:t.string().min(1),commit:t.string().nullable()}),startedAt:t.string().min(1),holdStartedAt:t.string().nullable(),deadlineAt:t.string().nullable(),blocker:t.string().nullable(),state:t.enum(["waiting","holding","preparing","cancelled","abandoned","failed","updated"]),reason:t.string().nullable(),result:b.nullable()}),Be=F.extend({nodeAbi:t.string().min(1)}).passthrough(),ct=t.object({current:Be.nullable(),lastResult:b.nullable(),automaticAttempt:Se.nullable().optional().catch(null),pending:Re.nullable(),schemaVersion:t.literal(ve)}).passthrough();var A=t.discriminatedUnion("kind",[t.object({kind:t.literal("npm"),version:t.string().min(1)}),t.object({commit:B,kind:t.literal("source")})]),be=t.enum(["detached-head","not-on-main","uncommitted-changes","diverged","fetch-failed"]),ut=t.object({blocked:t.object({message:t.string(),reason:be}).nullable(),current:H,incoming:t.object({commit:B,commitCount:t.number().int().nonnegative(),subjects:t.array(t.string()),version:t.string().min(1)}).nullable()}),Te=t.discriminatedUnion("phase",[t.object({phase:t.literal("idle")}),t.object({output:t.array(t.string()),phase:t.literal("preparing"),startedAt:t.string().min(1),step:t.string().min(1),target:A,targetVersion:t.string().min(1)}),t.object({phase:t.literal("ready"),decisionId:t.string().optional(),finalCheck:t.boolean().optional(),startedAt:t.string().min(1),target:A,targetVersion:t.string().min(1)}),t.object({phase:t.literal("restarting"),startedAt:t.string().min(1),target:A,targetVersion:t.string().min(1)})]),Ve=t.object({activity:Te,current:s,lastResult:b.nullable(),mode:h}),xe=t.discriminatedUnion("type",[t.object({type:t.literal("check-source")}),t.object({target:A,targetVersion:t.string().min(1),type:t.literal("apply"),attemptId:t.string().regex(/^[a-zA-Z0-9_-]+$/u).optional()}),t.object({id:t.string().min(1),type:t.literal("acknowledge-result")}),t.object({type:t.literal("restart"),decisionId:t.string().min(1).optional(),deadlineMonotonicMs:t.number().finite().optional()}),t.object({message:t.string().min(1),type:t.literal("cancel"),decisionId:t.string().min(1).optional()})]),lt=t.discriminatedUnion("channel",[t.object({channel:t.literal("bb-app-update/request"),request:xe,requestId:t.string().min(1)}),t.object({channel:t.literal("bb-app-update/hello")})]),dt=t.discriminatedUnion("channel",[t.object({channel:t.literal("bb-app-update/response"),error:t.string().nullable(),requestId:t.string().min(1),result:t.unknown()}),t.object({channel:t.literal("bb-app-update/status"),status:Ve})]);var j="BB_APP_INSTALL_KIND",$="BB_APP_SOURCE_ORIGIN",K="BB_APP_SOURCE_COMMIT",T=t.enum(["desktop","npm","source"]),V=t.enum(["official","fork","none"]);var z="BB_CLI_LAUNCHER";var q="BB_APP_SURFACE",x=["desktop","web"],At=[...x,"api","mobile"];function G(e){if(e==null)return;let r=e.trim();return x.find(n=>n===r)}function Y(){return x.join(", ")}var W=["trace","debug","info","warn","error","fatal"];function J(e){if(W.includes(e))return e;throw new Error(`BB_LOG_LEVEL must be one of ${W.join(", ")}, received "${e}"`)}function X(e,r){let n=r.trim();return n.length===0?"":u(e,n)}function u(e,r){let n=r.trim();if(n.length===0)throw new Error(`${e} must not be empty`);try{return new URL(n),n}catch{throw new Error(`${e} must be a valid URL, received "${r}"`)}}function p(e){let r=e.value.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes"||r==="y")return!0;if(r==="false"||r==="0"||r==="no"||r==="n")return!1;throw new Error(`${e.name} must be a boolean`)}function Ue(e){let r=G(e.value);if(r!==void 0)return r;throw new Error(`${e.name} must be one of ${Y()}`)}function Le(e){let r=h.safeParse(e.value);if(r.success)return r.data;throw new Error(`${e.name} must be one of ${h.options.join(", ")}`)}function ye(e){let r=T.safeParse(e.value);if(r.success)return r.data;throw new Error(`${e.name} must be one of ${T.options.join(", ")}`)}function Oe(e){let r=V.safeParse(e.value);if(r.success)return r.data;throw new Error(`${e.name} must be one of ${V.options.join(", ")}`)}function De(e){if(e.value!=="0")return S({name:e.name,rawPort:e.value})}function l(e){return y(e.value)}function Z(e){return e.value}function we(e){return e.value.split(Ne).map(r=>r.trim()).filter(r=>r.length>0)}function v(e){if(e.value.length===0)throw new Error(`${e.name} must not be empty`);return e.value}function Q(e){return S({name:e.name,rawPort:e.value})}function Ie(e){let r=e.trim();if(r==="127.0.0.1"||r==="0.0.0.0")return r;throw new Error('BB_SERVER_BIND_HOST must be "127.0.0.1" or "0.0.0.0"')}function ke(e){return Ie(e.value)}function Ce(e){let r=Number(e.value);if(!Number.isInteger(r)||r<=0)throw new Error(`${e.name} must be a positive integer`);return r}function ee(e){return u(e.name,e.value)}function N(e){return X(e.name,e.value)}function Me(e){return J(e.value)}var It={description:"Log level: trace, debug, info, warn, error, fatal",name:"BB_LOG_LEVEL",parse:Me},Fe={description:"HTTP port for the server",name:"BB_SERVER_PORT",parse:Q},kt={description:"HTTP bind host for the server",name:"BB_SERVER_BIND_HOST",parse:ke},te={description:"Port the host daemon listens on for local API requests",name:"BB_HOST_DAEMON_PORT",parse:Q},g={description:"URL of the Moonlet server",name:"BB_SERVER_URL",parse:ee},Ct={description:"Version of the running bb-app package. The bb-app launcher sets this from packages/bb-app/package.json; defaults to a sentinel for dev/source runs.",name:"BB_APP_VERSION",parse:v},Mt={description:"Internal per-spawn identity the bb-app launcher hands its server child. The server echoes it on /health so the launcher can tell its own child apart from another Moonlet server that already owns the port.",name:"BB_SERVER_LAUNCH_ID",parse:v},Ft={description:"Internal marker the bb-app launcher hands its server child when it runs under the in-app update shim: npm for package installs, source for pnpm start checkouts. The server offers in-app updates only when it is set.",name:M,parse:Le},Ht={description:"Internal path the bb-app launcher hands its server child: the bb command launcher it wrote in the data directory for this install. The server offers to put the bb command on PATH only when it is set.",name:z,parse:v},jt={description:"Internal marker the bb-app launcher hands its server child for telemetry attribution: desktop for the desktop app, npm for package installs, source for pnpm start checkouts. Absent when the server runs without the launcher.",name:j,parse:ye},$t={description:"Internal marker the bb-app launcher hands its server child for source checkouts: official when the origin remote is github.com/get-bb/bb or github.com/ymichael/bb, fork for any other origin, none without one.",name:$,parse:Oe},Kt={description:"Internal marker the bb-app launcher hands its server child with the HEAD commit of an official source checkout. Never set for forks.",name:K,parse:v},zt={description:"Internal launcher marker for telemetry attribution. Set by bb-app and desktop launchers.",name:q,parse:Ue},qt={description:"Human-facing app/server base URL used for generated links, allowed browser origins, and the allowed DNS hostname for incoming requests. Does not control which host or port the server binds to.",name:"BB_APP_URL",parse:N},Gt={description:"Internet-facing HTTPS base URL used for generated public links. Does not control which host or port the server binds to.",name:"BB_EXTERNAL_URL",parse:N},Yt={description:"Manifest URL of the reserved bb-community plugin marketplace, which lists as BB Community. Point it at a local file server to test catalog refreshes.",name:"BB_MARKETPLACE_URL",parse:N},Wt={description:"URL of the Moonlet Connect next gate public key set the server's tunnel ingress verifies gate assertions with. Point it at a local file server to test the ingress.",name:"BB_CONNECT_GATE_KEYS_URL",parse:ee},Jt={description:"PostHog project API key for anonymous usage telemetry. Telemetry is disabled when empty.",name:"BB_POSTHOG_API_KEY",parse:Z},Xt={description:"Permit server performance diagnostics when the performanceDiagnostics experiment is on. Requires restart.",name:"BB_PERF_DIAGNOSTICS",parse:p},Zt={description:"Mark first-run setup as completed at server startup so the setup screen is skipped. Settings can still replay it.",name:"BB_SKIP_ONBOARDING",parse:p},Qt={description:"Anonymous usage telemetry (app starts, thread creation counts, user message counts, and plugin installs, tagged with app version, install kind, and OS and Node versions). Off by default; sending also needs BB_POSTHOG_API_KEY.",name:"BB_TELEMETRY",parse:p},er={description:"Permanent placeholder feature flag. Non-functional keep-alive so the flag system has at least one entry; do not gate behavior on it.",name:"BB_FF_PLACEHOLDER",parse:p},tr={description:"Adds a fixed initiator value (user, agent, automation, plugin or system) to anonymous thread_created and user_message_sent telemetry. On by default; set false to omit it.",name:"BB_FF_INITIATOR_TELEMETRY",parse:p},rr={description:"Max events one thread-timeline window may span. Raise far above the default to restore unbounded windows.",name:"BB_FF_TIMELINE_WINDOW_EVENT_BUDGET",parse:Ce},nr={description:"Development-only Vite bind host override for apps/app. Defaults to 127.0.0.1 when unset.",name:"BB_DEV_APP_HOST",parse:Z},or={description:"Development-only Vite port for apps/app.",name:"BB_DEV_APP_PORT",parse:De},ir={description:"Directory containing the Moonlet CLI executable to inject into runtime shells",name:"BB_CLI_DIR",parse:l},ar={description:"Development-only path list of lower-priority inherited Moonlet skill roots",name:"BB_INHERITED_SKILLS_ROOTS",parse:we},sr={description:"Directory containing provider bridge bundles for the host daemon runtime",name:"BB_BRIDGE_DIR",parse:l},pr={description:"Private JSON headers attached to machine server requests",name:"BB_SERVER_HEADERS",parse:({value:e})=>{try{return t.record(t.string(),t.string()).parse(JSON.parse(e))}catch{throw new Error("BB_SERVER_HEADERS must be a JSON object with string values")}}},cr={description:"Daemon-managed Moonlet Connect credential for traversing the public machine gate",name:"BB_CONNECT_MACHINE_CREDENTIAL",parse:l},ur={description:"One-time enrollment token used to bootstrap a host daemon with the Moonlet server",name:"BB_HOST_ENROLL_KEY",parse:l},lr={description:"Allow a remote host daemon to install the exact bb-app package served by its server on a newer protocol mismatch",name:"BB_HOST_DAEMON_AUTO_UPDATE",parse:p},dr={description:"Set by bb-app host-daemon --supervise so a daemon that relaunches itself after a server move keeps its launcher restarting it",name:"BB_HOST_DAEMON_SUPERVISED",parse:p},mr={description:"Preferred host ID to persist for the daemon instead of generating one locally",name:"BB_HOST_ID",parse:l},fr=D.appVersion;var _r=_.placeholder,Er=_.initiatorTelemetry,Ar=_.timelineWindowEventBudget;function He(e){if(e.repoRoot!==void 0)return m({homeDir:e.homeDir,repoRoot:e.repoRoot}).ports.hostDaemonPort}function je(e){let r=a(e),n=f({context:r.context,definition:e.definition,env:r.env});if(n!==void 0)return n;if(r.mode==="prod")return e.prodDefault;if(e.devDefault!==void 0)return e.devDefault;throw new Error(`${e.definition.name} is required unless repoRoot is provided for development`)}function re(e={}){let r=a(e);return je({...e,definition:te,devDefault:He({homeDir:r.context.homeDir,repoRoot:e.repoRoot}),env:r.env,homeDir:r.context.homeDir,mode:r.mode,prodDefault:d})}function U(e={}){if(e.serverUrl!==void 0)return u(g.name,e.serverUrl);let r=a(e),n=f({context:r.context,definition:g,env:r.env});return n!==void 0?n:r.mode==="dev"&&e.repoRoot!==void 0?m({homeDir:r.context.homeDir,repoRoot:e.repoRoot}).serverUrl:O({context:r.context,definition:g,env:r.env})}var $e=`http://${P}:${R}`;function ne(e,r){return e[r]!==void 0}function yr(e={}){let r=a(e),n=r.mode==="dev"&&e.repoRoot!==void 0,o=ne(r.env,"BB_SERVER_URL")||n?U({...e,env:r.env,homeDir:r.context.homeDir,mode:r.mode}):U({...e,env:r.env,homeDir:r.context.homeDir,mode:r.mode,serverUrl:$e});return{BB_HOST_DAEMON_PORT:ne(r.env,"BB_HOST_DAEMON_PORT")||n?re({...e,env:r.env,homeDir:r.context.homeDir,mode:r.mode}):d,BB_SERVER_URL:o}}export{We as a,he as b,y as c,yr as d};
2
+ import{a as R,b as d,c as P,d as U,g as m,h as S}from"./chunk-E7J2DJY7.js";import{a as t}from"./chunk-BNG7SSF7.js";function L(e){if(e==null)return;let r=e.trim();return r.length>0?r:void 0}import{homedir as oe}from"node:os";function a(e={}){let r=e.env??process.env;return{context:{homeDir:e.homeDir??oe()},env:r,mode:e.mode??U(r.NODE_ENV)}}function y(e){let r=e.env[e.definition.name];if(r===void 0)throw new Error(`${e.definition.name} is required`);return e.definition.parse({context:e.context,name:e.definition.name,value:r})}function f(e){let r=e.env[e.definition.name];if(r!==void 0)return e.definition.parse({context:e.context,name:e.definition.name,value:r})}import{delimiter as Ne}from"node:path";var We=t.object({placeholder:t.boolean(),initiatorTelemetry:t.boolean().default(!0),timelineWindowEventBudget:t.number().int().positive()}),_={placeholder:!1,initiatorTelemetry:!0,timelineWindowEventBudget:1500};var D={appVersion:"0.0.0-dev",logLevel:{prod:"info",dev:"debug"},secretToken:{dev:"dev-secret"}};import{mkdir as de,rename as me,unlink as I,writeFile as fe}from"node:fs/promises";import{basename as C,dirname as _e,join as k}from"node:path";import{mkdir as ie,open as ae}from"node:fs/promises";import{createRequire as se}from"node:module";import{dirname as pe}from"node:path";import{setTimeout as ce}from"node:timers/promises";var ue=25,E;function le(){if(E!==void 0)return E;let e=se(import.meta.url)("fs-native-extensions");if(e===null||typeof e!="object"||!("tryLock"in e)||typeof e.tryLock!="function"||!("unlock"in e)||typeof e.unlock!="function")throw new Error("Invalid fs-native-extensions module");let r=e.tryLock,n=e.unlock;return E={tryLock:o=>{let i=Reflect.apply(r,e,[o]);if(typeof i!="boolean")throw new Error("Invalid fs-native-extensions lock result");return i},unlock:o=>{Reflect.apply(n,e,[o])}},E}var c=class extends Error{constructor(n){super(`Timed out waiting for file lock: ${n}`);this.path=n}path};async function w(e){let r=le();await ie(pe(e.path),{recursive:!0});let n=await ae(e.path,"a+",384),o=!1;try{let i=performance.now()+e.timeoutMs;for(;;){if(r.tryLock(n.fd)){o=!0;break}if(performance.now()>=i)throw new c(e.path);await ce(ue)}return await e.work()}finally{try{o&&r.unlock(n.fd)}finally{await n.close()}}}var Ee=5e3;function Ae(e,r){return e instanceof Error&&"code"in e&&e.code===r}async function he(e){let r=_e(e.path);await de(r,{recursive:!0});let n=k(r,`.${C(e.path)}.lock`);try{return await w({path:n,timeoutMs:Ee,work:async()=>{let o=k(r,`.${C(e.path)}.tmp`);try{await I(o)}catch(i){if(!Ae(i,"ENOENT"))throw i}try{let i=e.mutate(await e.read());return await fe(o,`${JSON.stringify(i,null,2)}
3
+ `,{encoding:"utf8",flag:"wx",mode:384}),await me(o,e.path),i}finally{await I(o).catch(()=>{})}}})}catch(o){throw o instanceof c?new Error(`Timed out waiting to update ${e.path}; another bb command is updating it. Retry the command.`):o}}var M="BB_APP_UPDATE_MODE";var ve=1;var h=t.enum(["npm","source"]),B=t.string().regex(/^[0-9a-f]{40}$/u),F=t.object({kind:t.literal("npm"),packageRoot:t.string().min(1),version:t.string().min(1)}).passthrough(),H=t.object({commit:B,kind:t.literal("source"),version:t.string().min(1)}).passthrough(),s=t.discriminatedUnion("kind",[F,H]),ge=t.enum(["prepare","install","startup"]),Re=t.object({from:s,id:t.string().min(1),requestedAt:t.string().min(1),rollbackReason:t.string().min(1).optional(),failedTarget:s.optional(),to:s}).passthrough(),Pe=t.enum(["updated","failed"]),T=t.object({acknowledged:t.boolean(),finishedAt:t.string().min(1),from:s,id:t.string().min(1),logTail:t.array(t.string()),message:t.string().nullable(),outcome:Pe,restored:s.optional(),retryable:t.boolean().optional(),phase:ge.nullable(),to:s}).passthrough(),Se=t.object({id:t.string().min(1),from:t.object({version:t.string().min(1),commit:t.string().nullable()}),to:t.object({version:t.string().min(1),commit:t.string().nullable()}),startedAt:t.string().min(1),holdStartedAt:t.string().nullable(),deadlineAt:t.string().nullable(),blocker:t.string().nullable(),state:t.enum(["waiting","holding","preparing","cancelled","abandoned","failed","updated"]),reason:t.string().nullable(),result:T.nullable()}),Be=F.extend({nodeAbi:t.string().min(1)}).passthrough(),ct=t.object({current:Be.nullable(),lastResult:T.nullable(),automaticAttempt:Se.nullable().optional().catch(null),pending:Re.nullable(),schemaVersion:t.literal(ve)}).passthrough();var A=t.discriminatedUnion("kind",[t.object({kind:t.literal("npm"),version:t.string().min(1)}),t.object({commit:B,kind:t.literal("source")})]),Te=t.enum(["detached-head","not-on-main","uncommitted-changes","diverged","fetch-failed"]),ut=t.object({blocked:t.object({message:t.string(),reason:Te}).nullable(),current:H,incoming:t.object({commit:B,commitCount:t.number().int().nonnegative(),subjects:t.array(t.string()),version:t.string().min(1)}).nullable()}),be=t.discriminatedUnion("phase",[t.object({phase:t.literal("idle")}),t.object({output:t.array(t.string()),phase:t.literal("preparing"),startedAt:t.string().min(1),step:t.string().min(1),target:A,targetVersion:t.string().min(1)}),t.object({phase:t.literal("ready"),decisionId:t.string().optional(),finalCheck:t.boolean().optional(),startedAt:t.string().min(1),target:A,targetVersion:t.string().min(1)}),t.object({phase:t.literal("restarting"),startedAt:t.string().min(1),target:A,targetVersion:t.string().min(1)})]),Ve=t.object({activity:be,current:s,lastResult:T.nullable(),mode:h}),xe=t.discriminatedUnion("type",[t.object({type:t.literal("check-source")}),t.object({target:A,targetVersion:t.string().min(1),type:t.literal("apply"),attemptId:t.string().regex(/^[a-zA-Z0-9_-]+$/u).optional()}),t.object({id:t.string().min(1),type:t.literal("acknowledge-result")}),t.object({type:t.literal("restart"),decisionId:t.string().min(1).optional(),deadlineMonotonicMs:t.number().finite().optional()}),t.object({message:t.string().min(1),type:t.literal("cancel"),decisionId:t.string().min(1).optional()})]),lt=t.discriminatedUnion("channel",[t.object({channel:t.literal("bb-app-update/request"),request:xe,requestId:t.string().min(1)}),t.object({channel:t.literal("bb-app-update/hello")})]),dt=t.discriminatedUnion("channel",[t.object({channel:t.literal("bb-app-update/response"),error:t.string().nullable(),requestId:t.string().min(1),result:t.unknown()}),t.object({channel:t.literal("bb-app-update/status"),status:Ve})]);var j="BB_APP_INSTALL_KIND",$="BB_APP_SOURCE_ORIGIN",K="BB_APP_SOURCE_COMMIT",b=t.enum(["desktop","npm","source"]),V=t.enum(["official","fork","none"]);var z="BB_CLI_LAUNCHER";var q="BB_APP_SURFACE",x=["desktop","web"],At=[...x,"api","mobile"];function G(e){if(e==null)return;let r=e.trim();return x.find(n=>n===r)}function Y(){return x.join(", ")}var W=["trace","debug","info","warn","error","fatal"];function J(e){if(W.includes(e))return e;throw new Error(`BB_LOG_LEVEL must be one of ${W.join(", ")}, received "${e}"`)}function X(e,r){let n=r.trim();return n.length===0?"":u(e,n)}function u(e,r){let n=r.trim();if(n.length===0)throw new Error(`${e} must not be empty`);try{return new URL(n),n}catch{throw new Error(`${e} must be a valid URL, received "${r}"`)}}function p(e){let r=e.value.trim().toLowerCase();if(r==="true"||r==="1"||r==="yes"||r==="y")return!0;if(r==="false"||r==="0"||r==="no"||r==="n")return!1;throw new Error(`${e.name} must be a boolean`)}function Oe(e){let r=G(e.value);if(r!==void 0)return r;throw new Error(`${e.name} must be one of ${Y()}`)}function Ue(e){let r=h.safeParse(e.value);if(r.success)return r.data;throw new Error(`${e.name} must be one of ${h.options.join(", ")}`)}function Le(e){let r=b.safeParse(e.value);if(r.success)return r.data;throw new Error(`${e.name} must be one of ${b.options.join(", ")}`)}function ye(e){let r=V.safeParse(e.value);if(r.success)return r.data;throw new Error(`${e.name} must be one of ${V.options.join(", ")}`)}function De(e){if(e.value!=="0")return S({name:e.name,rawPort:e.value})}function l(e){return L(e.value)}function Z(e){return e.value}function we(e){return e.value.split(Ne).map(r=>r.trim()).filter(r=>r.length>0)}function v(e){if(e.value.length===0)throw new Error(`${e.name} must not be empty`);return e.value}function Q(e){return S({name:e.name,rawPort:e.value})}function Ie(e){let r=e.trim();if(r==="127.0.0.1"||r==="0.0.0.0")return r;throw new Error('BB_SERVER_BIND_HOST must be "127.0.0.1" or "0.0.0.0"')}function Ce(e){return Ie(e.value)}function ke(e){let r=Number(e.value);if(!Number.isInteger(r)||r<=0)throw new Error(`${e.name} must be a positive integer`);return r}function ee(e){return u(e.name,e.value)}function N(e){return X(e.name,e.value)}function Me(e){return J(e.value)}var It={description:"Log level: trace, debug, info, warn, error, fatal",name:"BB_LOG_LEVEL",parse:Me},Fe={description:"HTTP port for the server",name:"BB_SERVER_PORT",parse:Q},Ct={description:"HTTP bind host for the server",name:"BB_SERVER_BIND_HOST",parse:Ce},te={description:"Port the host daemon listens on for local API requests",name:"BB_HOST_DAEMON_PORT",parse:Q},g={description:"URL of the Moonlet server",name:"BB_SERVER_URL",parse:ee},kt={description:"Version of the running bb-app package. The bb-app launcher sets this from packages/bb-app/package.json; defaults to a sentinel for dev/source runs.",name:"BB_APP_VERSION",parse:v},Mt={description:"Internal per-spawn identity the bb-app launcher hands its server child. The server echoes it on /health so the launcher can tell its own child apart from another Moonlet server that already owns the port.",name:"BB_SERVER_LAUNCH_ID",parse:v},Ft={description:"Internal marker the bb-app launcher hands its server child when it runs under the in-app update shim: npm for package installs, source for pnpm start checkouts. The server offers in-app updates only when it is set.",name:M,parse:Ue},Ht={description:"Internal path the bb-app launcher hands its server child: the bb command launcher it wrote in the data directory for this install. The server offers to put the bb command on PATH only when it is set.",name:z,parse:v},jt={description:"Internal marker the bb-app launcher hands its server child for telemetry attribution: desktop for the desktop app, npm for package installs, source for pnpm start checkouts. Absent when the server runs without the launcher.",name:j,parse:Le},$t={description:"Internal marker the bb-app launcher hands its server child for source checkouts: official when the origin remote is github.com/get-bb/bb or github.com/ymichael/bb, fork for any other origin, none without one.",name:$,parse:ye},Kt={description:"Internal marker the bb-app launcher hands its server child with the HEAD commit of an official source checkout. Never set for forks.",name:K,parse:v},zt={description:"Internal launcher marker for telemetry attribution. Set by bb-app and desktop launchers.",name:q,parse:Oe},qt={description:"Human-facing app/server base URL used for generated links, allowed browser origins, and the allowed DNS hostname for incoming requests. Does not control which host or port the server binds to.",name:"BB_APP_URL",parse:N},Gt={description:"Internet-facing HTTPS base URL used for generated public links. Does not control which host or port the server binds to.",name:"BB_EXTERNAL_URL",parse:N},Yt={description:"Manifest URL of the reserved bb-community plugin marketplace, which lists as BB Community. Point it at a local file server to test catalog refreshes.",name:"BB_MARKETPLACE_URL",parse:N},Wt={description:"URL of the Moonlet Connect next gate public key set the server's tunnel ingress verifies gate assertions with. Point it at a local file server to test the ingress.",name:"BB_CONNECT_GATE_KEYS_URL",parse:ee},Jt={description:"PostHog project API key for anonymous usage telemetry. Telemetry is disabled when empty.",name:"BB_POSTHOG_API_KEY",parse:Z},Xt={description:"Permit server performance diagnostics when the performanceDiagnostics experiment is on. Requires restart.",name:"BB_PERF_DIAGNOSTICS",parse:p},Zt={description:"Mark first-run setup as completed at server startup so the setup screen is skipped. Settings can still replay it.",name:"BB_SKIP_ONBOARDING",parse:p},Qt={description:"Anonymous usage telemetry (app starts, thread creation counts, user message counts, and plugin installs, tagged with app version, install kind, and OS and Node versions). Off by default; sending also needs BB_POSTHOG_API_KEY.",name:"BB_TELEMETRY",parse:p},er={description:"Permanent placeholder feature flag. Non-functional keep-alive so the flag system has at least one entry; do not gate behavior on it.",name:"BB_FF_PLACEHOLDER",parse:p},tr={description:"Adds a fixed initiator value (user, agent, automation, plugin or system) to anonymous thread_created and user_message_sent telemetry. On by default; set false to omit it.",name:"BB_FF_INITIATOR_TELEMETRY",parse:p},rr={description:"Max events one thread-timeline window may span. Raise far above the default to restore unbounded windows.",name:"BB_FF_TIMELINE_WINDOW_EVENT_BUDGET",parse:ke},nr={description:"Development-only Vite bind host override for apps/app. Defaults to 127.0.0.1 when unset.",name:"BB_DEV_APP_HOST",parse:Z},or={description:"Development-only Vite port for apps/app.",name:"BB_DEV_APP_PORT",parse:De},ir={description:"Directory containing the Moonlet CLI executable to inject into runtime shells",name:"BB_CLI_DIR",parse:l},ar={description:"Development-only path list of lower-priority inherited Moonlet skill roots",name:"BB_INHERITED_SKILLS_ROOTS",parse:we},sr={description:"Directory containing provider bridge bundles for the host daemon runtime",name:"BB_BRIDGE_DIR",parse:l},pr={description:"Private JSON headers attached to machine server requests",name:"BB_SERVER_HEADERS",parse:({value:e})=>{try{return t.record(t.string(),t.string()).parse(JSON.parse(e))}catch{throw new Error("BB_SERVER_HEADERS must be a JSON object with string values")}}},cr={description:"Daemon-managed Moonlet Connect credential for traversing the public machine gate",name:"BB_CONNECT_MACHINE_CREDENTIAL",parse:l},ur={description:"One-time enrollment token used to bootstrap a host daemon with the Moonlet server",name:"BB_HOST_ENROLL_KEY",parse:l},lr={description:"Allow a remote host daemon to install the exact bb-app package served by its server on a newer protocol mismatch",name:"BB_HOST_DAEMON_AUTO_UPDATE",parse:p},dr={description:"Set by bb-app host-daemon --supervise so a daemon that relaunches itself after a server move keeps its launcher restarting it",name:"BB_HOST_DAEMON_SUPERVISED",parse:p},mr={description:"Preferred host ID to persist for the daemon instead of generating one locally",name:"BB_HOST_ID",parse:l},fr=D.appVersion;var _r=_.placeholder,Er=_.initiatorTelemetry,Ar=_.timelineWindowEventBudget;function He(e){if(e.repoRoot!==void 0)return m({homeDir:e.homeDir,repoRoot:e.repoRoot}).ports.hostDaemonPort}function je(e){let r=a(e),n=f({context:r.context,definition:e.definition,env:r.env});if(n!==void 0)return n;if(r.mode==="prod")return e.prodDefault;if(e.devDefault!==void 0)return e.devDefault;throw new Error(`${e.definition.name} is required unless repoRoot is provided for development`)}function re(e={}){let r=a(e);return je({...e,definition:te,devDefault:He({homeDir:r.context.homeDir,repoRoot:e.repoRoot}),env:r.env,homeDir:r.context.homeDir,mode:r.mode,prodDefault:d})}function O(e={}){if(e.serverUrl!==void 0)return u(g.name,e.serverUrl);let r=a(e),n=f({context:r.context,definition:g,env:r.env});return n!==void 0?n:r.mode==="dev"&&e.repoRoot!==void 0?m({homeDir:r.context.homeDir,repoRoot:e.repoRoot}).serverUrl:y({context:r.context,definition:g,env:r.env})}var $e=`http://${P}:${R}`;function ne(e,r){return e[r]!==void 0}function Lr(e={}){let r=a(e),n=r.mode==="dev"&&e.repoRoot!==void 0,o=ne(r.env,"BB_SERVER_URL")||n?O({...e,env:r.env,homeDir:r.context.homeDir,mode:r.mode}):O({...e,env:r.env,homeDir:r.context.homeDir,mode:r.mode,serverUrl:$e});return{BB_HOST_DAEMON_PORT:ne(r.env,"BB_HOST_DAEMON_PORT")||n?re({...e,env:r.env,homeDir:r.context.homeDir,mode:r.mode}):d,BB_SERVER_URL:o}}export{We as a,he as b,L as c,Lr as d};