@ghostlytools/cli 1.7.3 → 1.8.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 (106) hide show
  1. package/README.md +30 -19
  2. package/SKILL.md +6 -4
  3. package/dist/assets/{api-B42F9ytB.js → api-Dj1yn0px.js} +2 -2
  4. package/dist/assets/{api-tf-wAAnB.js → api-I_KbuXHa.js} +192 -88
  5. package/dist/assets/api-I_KbuXHa.js.map +1 -0
  6. package/dist/assets/{apiKit-DJb9hulp.js → apiKit-C-_PWZvy.js} +44 -9
  7. package/dist/assets/apiKit-C-_PWZvy.js.map +1 -0
  8. package/dist/assets/{apps-DIrWmLgL.js → apps-DKIe8VjF.js} +11 -8
  9. package/dist/assets/apps-DKIe8VjF.js.map +1 -0
  10. package/dist/assets/{apps-BfoDISRg.js → apps-DbEfL_3b.js} +1 -1
  11. package/dist/assets/{arkade-CJAhhgPQ.js → arkade-k1bdSm70.js} +2 -2
  12. package/dist/assets/{arkade-CJAhhgPQ.js.map → arkade-k1bdSm70.js.map} +1 -1
  13. package/dist/assets/{backup-BkUeeduy.js → backup-Cdd6-HNu.js} +1 -1
  14. package/dist/assets/{backup-Bko-AAm0.js → backup-beKfbfNk.js} +7 -7
  15. package/dist/assets/{backup-Bko-AAm0.js.map → backup-beKfbfNk.js.map} +1 -1
  16. package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
  17. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  18. package/dist/assets/{blobFiles-Bckz9fjp.js → blobFiles-DOQDRdDI.js} +3 -3
  19. package/dist/assets/{blobFiles-Bckz9fjp.js.map → blobFiles-DOQDRdDI.js.map} +1 -1
  20. package/dist/assets/buttons-BO1_7V4L.js +2 -0
  21. package/dist/assets/{buttons-DeA6Yddq.js → buttons-ClI13rdv.js} +7 -6
  22. package/dist/assets/buttons-ClI13rdv.js.map +1 -0
  23. package/dist/assets/{daemonProof-Bp9lJDxf.js → daemonProof-DtrL5lE5.js} +2 -2
  24. package/dist/assets/{daemonProof-Bp9lJDxf.js.map → daemonProof-DtrL5lE5.js.map} +1 -1
  25. package/dist/assets/{envelope-Cz5fc7BM.js → envelope-B88yiCQj.js} +2 -2
  26. package/dist/assets/{envelope-Cz5fc7BM.js.map → envelope-B88yiCQj.js.map} +1 -1
  27. package/dist/assets/{errors-mnjSQlbX.js → errors-R4S2SAEM.js} +8 -3
  28. package/dist/assets/errors-R4S2SAEM.js.map +1 -0
  29. package/dist/assets/{fileBytes-OolN5cSY.js → fileBytes-BPDKufla.js} +1 -1
  30. package/dist/assets/{fileBytes-BD0v3rRG.js → fileBytes-DNgrRL0R.js} +3 -3
  31. package/dist/assets/{fileBytes-BD0v3rRG.js.map → fileBytes-DNgrRL0R.js.map} +1 -1
  32. package/dist/assets/{fileBytes-_fd-2JRY.js → fileBytes-Q3ehcEr8.js} +2 -2
  33. package/dist/assets/{fileBytes-_fd-2JRY.js.map → fileBytes-Q3ehcEr8.js.map} +1 -1
  34. package/dist/assets/fileBytesIdb-DZcESfTt.js +2 -0
  35. package/dist/assets/{fileBytesIdb-NtA8r9EM.js → fileBytesIdb-Dm1EyEbT.js} +3 -3
  36. package/dist/assets/{fileBytesIdb-NtA8r9EM.js.map → fileBytesIdb-Dm1EyEbT.js.map} +1 -1
  37. package/dist/assets/{fileBytesOpfs-B8fJwkwM.js → fileBytesOpfs-ZGD21c4Q.js} +3 -3
  38. package/dist/assets/{fileBytesOpfs-B8fJwkwM.js.map → fileBytesOpfs-ZGD21c4Q.js.map} +1 -1
  39. package/dist/assets/{groupFiles-BlZRBWpt.js → groupFiles-DjQc5XXv.js} +151 -28
  40. package/dist/assets/groupFiles-DjQc5XXv.js.map +1 -0
  41. package/dist/assets/{host-BX0DmKW6.js → host-CNWGB3-j.js} +86 -24
  42. package/dist/assets/host-CNWGB3-j.js.map +1 -0
  43. package/dist/assets/{hyperdhtRelay-DitYDnXx.js → hyperdhtRelay-g7eXzf5h.js} +2 -2
  44. package/dist/assets/{hyperdhtRelay-DitYDnXx.js.map → hyperdhtRelay-g7eXzf5h.js.map} +1 -1
  45. package/dist/assets/{idb-BlH8-O3R.js → idb-BkOJES5_.js} +5 -3
  46. package/dist/assets/idb-BkOJES5_.js.map +1 -0
  47. package/dist/assets/{irohWeb-R3bcd34h.js → irohWeb-Bx8dI4be.js} +2 -2
  48. package/dist/assets/{irohWeb-R3bcd34h.js.map → irohWeb-Bx8dI4be.js.map} +1 -1
  49. package/dist/assets/{main-6QOSvQ8b.js → main-BRxhBctJ.js} +462 -126
  50. package/dist/assets/main-BRxhBctJ.js.map +1 -0
  51. package/dist/assets/{mainline-BfwezHWi.js → mainline-CwuS6ngj.js} +39 -12
  52. package/dist/assets/mainline-CwuS6ngj.js.map +1 -0
  53. package/dist/assets/mints-BaOmx517.js +2 -0
  54. package/dist/assets/{mints-BrlY773j.js → mints-j5XAOk4f.js} +15 -3
  55. package/dist/assets/mints-j5XAOk4f.js.map +1 -0
  56. package/dist/assets/{networkReason-Ba9415nn.js → networkReason-CIAMieQm.js} +3 -3
  57. package/dist/assets/{networkReason-Ba9415nn.js.map → networkReason-CIAMieQm.js.map} +1 -1
  58. package/dist/assets/{nwc-ovXSN2M2.js → nwc-C9JLJJkL.js} +3 -3
  59. package/dist/assets/{nwc-ovXSN2M2.js.map → nwc-C9JLJJkL.js.map} +1 -1
  60. package/dist/assets/{nwcProvider-BzZbfFP3.js → nwcProvider-pFMrsUJh.js} +2 -2
  61. package/dist/assets/{nwcProvider-BzZbfFP3.js.map → nwcProvider-pFMrsUJh.js.map} +1 -1
  62. package/dist/assets/{profiles-C6XWqre5.js → profiles-MFtCmJwK.js} +104 -10
  63. package/dist/assets/profiles-MFtCmJwK.js.map +1 -0
  64. package/dist/assets/{registry-B0Uv9yL6.js → registry-Cks7FA_o.js} +45 -14
  65. package/dist/assets/registry-Cks7FA_o.js.map +1 -0
  66. package/dist/assets/{registry-CFtlhWCI.js → registry-DY2ixQfU.js} +1 -1
  67. package/dist/assets/{resolve-BzFG4WDU.js → resolve-C4Y2HPqQ.js} +79 -30
  68. package/dist/assets/resolve-C4Y2HPqQ.js.map +1 -0
  69. package/dist/assets/{restoredRows-Fv-MuY45.js → restoredRows-BCRCjhdF.js} +27 -3
  70. package/dist/assets/{restoredRows-Fv-MuY45.js.map → restoredRows-BCRCjhdF.js.map} +1 -1
  71. package/dist/assets/{server-BGCuHbmQ.js → server-D9RAmGdm.js} +1398 -358
  72. package/dist/assets/server-D9RAmGdm.js.map +1 -0
  73. package/dist/assets/{src-DWw2hUE5.js → src-1RU4TilT.js} +1416 -234
  74. package/dist/assets/src-1RU4TilT.js.map +1 -0
  75. package/dist/assets/{translate-DObb-1tq.js → translate-od5GbpvR.js} +19 -13
  76. package/dist/assets/translate-od5GbpvR.js.map +1 -0
  77. package/dist/assets/{usdt-Bkva90Vo.js → usdt-DldXV0MR.js} +3 -3
  78. package/dist/assets/{usdt-Bkva90Vo.js.map → usdt-DldXV0MR.js.map} +1 -1
  79. package/dist/assets/waitNotice-Ck3el3_Z.js +45 -0
  80. package/dist/assets/waitNotice-Ck3el3_Z.js.map +1 -0
  81. package/dist/assets/{words-odSAoasK.js → words-BS2qq_vV.js} +7 -4
  82. package/dist/assets/words-BS2qq_vV.js.map +1 -0
  83. package/dist/ghostly.mjs +1 -1
  84. package/examples/claude-code-agent.sh +1 -1
  85. package/package.json +1 -1
  86. package/dist/assets/api-tf-wAAnB.js.map +0 -1
  87. package/dist/assets/apiKit-DJb9hulp.js.map +0 -1
  88. package/dist/assets/apps-DIrWmLgL.js.map +0 -1
  89. package/dist/assets/buttons-Be7u0V5g.js +0 -2
  90. package/dist/assets/buttons-DeA6Yddq.js.map +0 -1
  91. package/dist/assets/errors-mnjSQlbX.js.map +0 -1
  92. package/dist/assets/fileBytesIdb-CsSQcSxD.js +0 -2
  93. package/dist/assets/groupFiles-BlZRBWpt.js.map +0 -1
  94. package/dist/assets/host-BX0DmKW6.js.map +0 -1
  95. package/dist/assets/idb-BlH8-O3R.js.map +0 -1
  96. package/dist/assets/main-6QOSvQ8b.js.map +0 -1
  97. package/dist/assets/mainline-BfwezHWi.js.map +0 -1
  98. package/dist/assets/mints-BrlY773j.js.map +0 -1
  99. package/dist/assets/mints-CqTdA4Gk.js +0 -2
  100. package/dist/assets/profiles-C6XWqre5.js.map +0 -1
  101. package/dist/assets/registry-B0Uv9yL6.js.map +0 -1
  102. package/dist/assets/resolve-BzFG4WDU.js.map +0 -1
  103. package/dist/assets/server-BGCuHbmQ.js.map +0 -1
  104. package/dist/assets/src-DWw2hUE5.js.map +0 -1
  105. package/dist/assets/translate-DObb-1tq.js.map +0 -1
  106. package/dist/assets/words-odSAoasK.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import { Bo as callRtcConfig, Go as signalHasVideo, Io as CALL_SIGNAL_MAX_AGE_MS, Lo as RTC_CONFIG, Ql as setLinkTraceSink, Qr as checkPushEndpoint, Ro as answersOffer, Uo as extractParamsFromSdp, Vo as callSignalHeardAt, Wo as parseCallSignal, vu as fromBase64Url, wi as isPublicAddress, zo as buildSdpFromSignal } from "./src-DWw2hUE5.js";
2
- import { a as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-R3bcd34h.js";
3
- import { r as asCliError, t as CliError } from "./errors-mnjSQlbX.js";
4
- import { l as findOwnNamedChat, o as findChat } from "./apiKit-DJb9hulp.js";
5
- import { _ as flushCardUpdates, c as paymentJson, d as nodeLocalFetch, f as chatJson, g as resumeHolds, h as groupMessageJson, l as reportAppFrames, m as groupJson, p as chatMessageJson, r as callApi, u as servedApps } from "./api-tf-wAAnB.js";
6
- import { g as ownFolder, n as RESTORED_MARK, r as acquireLock, v as privateFolder, y as runtimePath } from "./profiles-C6XWqre5.js";
7
- import { _ as isCallRate, f as DEFAULT_RATE, g as frameSamples, h as frameBytes, i as newDaemonSecret, m as bytesToMs, o as proof, p as PlaybackQueue, r as greeting, u as removeDaemonSecret } from "./daemonProof-Bp9lJDxf.js";
1
+ import { $o as parseCallSignal, Du as fromBase64Url, Ei as isPublicAddress, Go as CALL_SIGNAL_MAX_AGE_MS, Jo as buildSdpFromSignal, Ko as RTC_CONFIG, Qo as extractParamsFromSdp, Xo as callSignalHeardAt, Yo as callRtcConfig, ei as checkPushEndpoint, es as signalHasVideo, qo as answersOffer, su as setLinkTraceSink } from "./src-1RU4TilT.js";
2
+ import { a as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-Bx8dI4be.js";
3
+ import { r as asCliError, t as CliError } from "./errors-R4S2SAEM.js";
4
+ import { l as findOwnNamedChat, o as findChat } from "./apiKit-C-_PWZvy.js";
5
+ import { _ as flushCardUpdates, c as paymentJson, d as nodeLocalFetch, f as chatJson, g as resumeHolds, h as groupMessageJson, l as reportAppFrames, m as groupJson, p as chatMessageJson, r as callApi, u as servedApps } from "./api-I_KbuXHa.js";
6
+ import { b as privateFolder, g as startingPath, n as RESTORED_MARK, r as acquireLock, v as ownFolder, x as runtimePath } from "./profiles-MFtCmJwK.js";
7
+ import { _ as isCallRate, f as DEFAULT_RATE, g as frameSamples, h as frameBytes, i as newDaemonSecret, m as bytesToMs, o as proof, p as PlaybackQueue, r as greeting, u as removeDaemonSecret } from "./daemonProof-DtrL5lE5.js";
8
8
  import { createRequire } from "node:module";
9
9
  import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
10
10
  import { readFile } from "node:fs/promises";
@@ -1262,10 +1262,30 @@ var CallManager = class {
1262
1262
  from: next.on ? from : [],
1263
1263
  rate: rateOf(next.rate, next.on ? this.auto.rate : DEFAULT_RATE)
1264
1264
  };
1265
+ this.saveAuto();
1266
+ return this.getAuto();
1267
+ }
1268
+ /**
1269
+ * A chat removed from this device leaves the chats auto-answer answers. The last one gone turns auto-answer off:
1270
+ * an empty list is "answer everyone", never what was asked for.
1271
+ */
1272
+ forgetChat(chat) {
1273
+ if (!this.auto.from.includes(chat)) return;
1274
+ const from = this.auto.from.filter((c) => c !== chat);
1275
+ this.auto = from.length > 0 ? {
1276
+ ...this.auto,
1277
+ from
1278
+ } : {
1279
+ on: false,
1280
+ from: [],
1281
+ rate: DEFAULT_RATE
1282
+ };
1283
+ this.saveAuto();
1284
+ }
1285
+ saveAuto() {
1265
1286
  const tmp = `${this.configPath}.tmp`;
1266
1287
  writeFileSync(tmp, JSON.stringify({ autoAnswer: this.auto }, null, 2) + "\n", { mode: 384 });
1267
1288
  renameSync(tmp, this.configPath);
1268
- return this.getAuto();
1269
1289
  }
1270
1290
  /** Before the engine stops: every call is hung up (the contact's app is told), its program gets EOF. */
1271
1291
  async stopAll() {
@@ -2071,14 +2091,16 @@ var EventHub = class {
2071
2091
  const key = `${link.id}:${identity.id}`, shape = identity.status, before = this.received.get(key);
2072
2092
  this.received.set(key, shape);
2073
2093
  if (quiet || before === shape) continue;
2074
- this.emit(before === void 0 ? "identity.received" : "identity.status", `identity.${before === void 0 ? "received" : "status"}:${key}:${shape}`, {
2094
+ const id = before === void 0 ? `identity.received:${key}:${shape}` : `identity.status:${key}:${shape}:${this.now()}:${this.seq + 1}`;
2095
+ this.emit(before === void 0 ? "identity.received" : "identity.status", id, {
2075
2096
  chat: link.id,
2076
2097
  identity: {
2077
2098
  id: identity.id,
2078
2099
  provider: identity.provider,
2079
2100
  subject: identity.subject,
2080
2101
  status: identity.status,
2081
- verified: identity.verified
2102
+ verified: identity.verified,
2103
+ error: identity.error ?? null
2082
2104
  }
2083
2105
  });
2084
2106
  }
@@ -3443,12 +3465,19 @@ var ON_DISK = /* @__PURE__ */ new Set(["messages", "fileState"]);
3443
3465
  var COMPACT_BYTES = 33554432;
3444
3466
  /** A journal up to this is kept at close and at start: replaying it costs less than writing the snapshot again. */
3445
3467
  var KEEP_BYTES = 1048576;
3468
+ /** The chat row's field that holds its ratchet, as a journal's bytes spell it. Another row that says the word only folds early. */
3469
+ var RATCHET = "ratchetState";
3470
+ /**
3471
+ * How long a used ratchet state may stay on the disk while the store is in use, so a profile folder copied later opens
3472
+ * nothing older. The time a fold blocks does not set this (tens of milliseconds at 100,000 messages, which are not in
3473
+ * the snapshot); its disk writes do: 4 MB on that profile, so about 100 MB a day at this hour and 600 MB at 10 minutes.
3474
+ */
3475
+ var RATCHET_FOLD_MS = 36e5;
3446
3476
  /** The stores whose rows a delete means gone from the disk: the chats (their seed, their ratchet) and their messages. */
3447
3477
  var FORGOTTEN = /* @__PURE__ */ new Set(["links", "messages"]);
3448
3478
  /**
3449
3479
  * How long what a delete of a chat or a message took may stay in the journal while the store is in use, so a profile
3450
- * folder copied later holds nothing older. Not at every close: writing the whole snapshot again costs a large profile a
3451
- * second or more.
3480
+ * folder copied later holds nothing older. The hour is the ratchet's, for the same reason.
3452
3481
  */
3453
3482
  var DELETE_FOLD_MS = 36e5;
3454
3483
  /**
@@ -3501,11 +3530,14 @@ async function openPersistentIndexedDb(dir, options = {}) {
3501
3530
  let unsaved = false;
3502
3531
  /** Set while the journal holds relaxed entries no sync has covered yet. */
3503
3532
  let relaxed = null;
3533
+ /** The journal holds a chat's ratchet state, and with the next one it holds a key already used. */
3534
+ let holdsRatchet = false;
3504
3535
  /** The journal holds a delete of a chat or a message, and what came before it with it. */
3505
3536
  let holdsDelete = false;
3506
3537
  const pending = /* @__PURE__ */ new WeakMap();
3507
3538
  const snapshotPath = join(dir, SNAPSHOT);
3508
3539
  const journalPath = join(dir, JOURNAL);
3540
+ const ratchetDue = () => holdsRatchet && Date.now() - (statSync(snapshotPath, { throwIfNoEntry: false })?.mtimeMs ?? 0) >= RATCHET_FOLD_MS;
3509
3541
  const deleteDue = () => holdsDelete && Date.now() - (statSync(snapshotPath, { throwIfNoEntry: false })?.mtimeMs ?? 0) >= DELETE_FOLD_MS;
3510
3542
  const snapshotFound = existsSync(snapshotPath), journalFound = existsSync(journalPath);
3511
3543
  const saved = snapshotFound ? deserialize(readFileSync(snapshotPath)) : null;
@@ -3564,8 +3596,9 @@ async function openPersistentIndexedDb(dir, options = {}) {
3564
3596
  restoring = false;
3565
3597
  /** Whether the journal on disk says the store is closed: nothing was written since its mark, or there is none. */
3566
3598
  let marked = replayed.closed;
3599
+ holdsRatchet = !!journal?.includes(RATCHET);
3567
3600
  holdsDelete = replayed.deletes;
3568
- const kept = !!journal && named !== void 0 && named === snapshotName && replayed.end === journal.length && journal.length <= KEEP_BYTES && !deleteDue();
3601
+ const kept = !!journal && named !== void 0 && named === snapshotName && replayed.end === journal.length && journal.length <= KEEP_BYTES && !ratchetDue() && !deleteDue();
3569
3602
  const rewrite = journal && !kept || !snapshotFound || moved;
3570
3603
  if (rewrite) await writeSnapshot();
3571
3604
  rows?.close();
@@ -3824,7 +3857,8 @@ async function openPersistentIndexedDb(dir, options = {}) {
3824
3857
  failed(error);
3825
3858
  }
3826
3859
  }, RELAXED_SYNC_MS).unref();
3827
- if (statSync(journalPath).size > COMPACT_BYTES || deleteDue()) enqueue(writeSnapshot);
3860
+ holdsRatchet ||= entry.includes(RATCHET);
3861
+ if (statSync(journalPath).size > COMPACT_BYTES || ratchetDue() || deleteDue()) enqueue(writeSnapshot);
3828
3862
  return true;
3829
3863
  }
3830
3864
  function sync() {
@@ -3930,11 +3964,12 @@ async function openPersistentIndexedDb(dir, options = {}) {
3930
3964
  }
3931
3965
  rmSync(journalPath, { force: true });
3932
3966
  marked = true;
3967
+ holdsRatchet = false;
3933
3968
  holdsDelete = false;
3934
3969
  }
3935
3970
  /** What `close` leaves: a short journal with the mark at its end, synced (its relaxed entries too), or a fresh snapshot. */
3936
3971
  async function leave() {
3937
- if (schemaDirty || unsaved || journalBytes() > KEEP_BYTES || deleteDue()) return writeSnapshot();
3972
+ if (schemaDirty || unsaved || journalBytes() > KEEP_BYTES || ratchetDue() || deleteDue()) return writeSnapshot();
3938
3973
  if (marked) return;
3939
3974
  writeEntry(serialize([{
3940
3975
  db: CLOSED,
@@ -3994,6 +4029,14 @@ async function openPersistentIndexedDb(dir, options = {}) {
3994
4029
  async exportSnapshot(path) {
3995
4030
  await settled();
3996
4031
  const snapshot = await capture(void 0, true);
4032
+ for (const db of snapshot.databases) for (const store of db.stores) {
4033
+ if (store.name !== "links") continue;
4034
+ store.records = store.records.map(([key, value]) => {
4035
+ if (!value || typeof value !== "object" || !("ratchetState" in value)) return [key, value];
4036
+ const { ratchetState: _ratchet, ...link } = value;
4037
+ return [key, link];
4038
+ });
4039
+ }
3997
4040
  const fd = openSync(path, "w", 384);
3998
4041
  try {
3999
4042
  writeAll(fd, serialize(snapshot));
@@ -4826,9 +4869,10 @@ async function startRuntime(paths, options = {}) {
4826
4869
  const restored = join(paths.dir, RESTORED_MARK);
4827
4870
  if (existsSync(restored)) {
4828
4871
  try {
4829
- const rows = await import("./restoredRows-Fv-MuY45.js");
4872
+ const rows = await import("./restoredRows-BCRCjhdF.js");
4830
4873
  await rows.markRestoredWallet();
4831
4874
  await rows.markLeftOutFiles(leftOutIn(restored));
4875
+ await rows.forgetRatchets();
4832
4876
  await store.compact();
4833
4877
  } catch (error) {
4834
4878
  await store.close().catch(() => {});
@@ -4841,19 +4885,19 @@ async function startRuntime(paths, options = {}) {
4841
4885
  const callsUnavailable = typeof stack === "string" ? stack : null;
4842
4886
  installFileFetch();
4843
4887
  const testMints = process.env.GHOSTLY_TEST_MINTS;
4844
- if (testMints) (await import("./mints-CqTdA4Gk.js")).declareTestMints(testMints.split(","));
4888
+ if (testMints) (await import("./mints-BaOmx517.js")).declareTestMints(testMints.split(","));
4845
4889
  await installEventSource();
4846
4890
  await preloadWalletModules();
4847
4891
  (await import("./ghostly_iroh_web-CO0onry8.js")).initSync({ module: irohWasmBytes() });
4848
- const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-OolN5cSY.js"), import("./fileBytes-_fd-2JRY.js")]);
4892
+ const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-BPDKufla.js"), import("./fileBytes-Q3ehcEr8.js")]);
4849
4893
  registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
4850
- if (await (await import("./blobFiles-Bckz9fjp.js")).moveBlobFiles()) await store.compact();
4851
- const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-BGCuHbmQ.js"), import("./endpoint-BdaeBw2L.js")]);
4852
- const mainline = dht.off ? null : new (await (import("./mainline-BfwezHWi.js"))).Mainline({
4894
+ if (await (await import("./blobFiles-DOQDRdDI.js")).moveBlobFiles()) await store.compact();
4895
+ const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-D9RAmGdm.js"), import("./endpoint-BdaeBw2L.js")]);
4896
+ const mainline = dht.off ? null : new (await (import("./mainline-CwuS6ngj.js"))).Mainline({
4853
4897
  bootstrap: dht.bootstrap,
4854
4898
  host: dht.host
4855
4899
  });
4856
- const transport = mainline || pinned ? new (await (import("./mainline-BfwezHWi.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
4900
+ const transport = mainline || pinned ? new (await (import("./mainline-CwuS6ngj.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
4857
4901
  const apps = servedApps(paths.dir).length > 0;
4858
4902
  const server = new EngineServer({
4859
4903
  ...transport ? { transport } : {},
@@ -4921,7 +4965,12 @@ var BASELINE_NEWEST = 100;
4921
4965
  * `deferGroups`: the groups' sessions would spend the relays' budget its message needs.
4922
4966
  */
4923
4967
  async function openHost(paths, mode, version, options = {}) {
4924
- const release = acquireLock(paths);
4968
+ const locked = acquireLock(paths);
4969
+ const unmark = mode === "daemon" ? markStarting(paths) : () => {};
4970
+ const release = () => {
4971
+ unmark();
4972
+ locked();
4973
+ };
4925
4974
  let runtime;
4926
4975
  try {
4927
4976
  runtime = await startRuntime(paths, mode === "daemon" ? {
@@ -5021,6 +5070,7 @@ async function serve(host) {
5021
5070
  }
5022
5071
  });
5023
5072
  if (process.platform !== "win32") chmodSync(path, 384);
5073
+ unmarkStarting(ctx.runtime.paths);
5024
5074
  let closing = null;
5025
5075
  return {
5026
5076
  server,
@@ -5034,6 +5084,18 @@ async function serve(host) {
5034
5084
  })
5035
5085
  };
5036
5086
  }
5087
+ /** Writes the daemon's start mark (`startingDaemon`); the function it returns removes it. A mark it cannot write is none. */
5088
+ function markStarting(paths) {
5089
+ try {
5090
+ writeFileSync(startingPath(paths.dir), String(process.pid), { mode: 384 });
5091
+ } catch {}
5092
+ return () => unmarkStarting(paths);
5093
+ }
5094
+ function unmarkStarting(paths) {
5095
+ try {
5096
+ rmSync(startingPath(paths.dir), { force: true });
5097
+ } catch {}
5098
+ }
5037
5099
  var guarded = false;
5038
5100
  /**
5039
5101
  * A daemon says an error nobody caught (with its stack, on stderr: the daemon's log when detached) and keeps serving:
@@ -5195,4 +5257,4 @@ function connection(ctx, socket, secret) {
5195
5257
  //#endregion
5196
5258
  export { BASELINE_NEWEST, MAX_LINE, MAX_UNREAD, keepServing, openHost, serve };
5197
5259
 
5198
- //# sourceMappingURL=host-BX0DmKW6.js.map
5260
+ //# sourceMappingURL=host-CNWGB3-j.js.map