@ghostlytools/cli 1.10.1 → 1.10.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/README.md +10 -8
  2. package/SKILL.md +3 -2
  3. package/dist/assets/{api-BOWLZYXM.js → api-DcE4KylM.js} +2 -2
  4. package/dist/assets/{api-Bi6hCcwG.js → api-EUGHGnRz.js} +95 -43
  5. package/dist/assets/api-EUGHGnRz.js.map +1 -0
  6. package/dist/assets/{apiKit-DzXHZojD.js → apiKit-CJVp_crp.js} +68 -22
  7. package/dist/assets/apiKit-CJVp_crp.js.map +1 -0
  8. package/dist/assets/{apps-0Ks6KjqS.js → apps-C-KbyLCa.js} +1 -1
  9. package/dist/assets/{apps-DIQbzG08.js → apps-C54T_MOT.js} +5 -5
  10. package/dist/assets/{apps-DIQbzG08.js.map → apps-C54T_MOT.js.map} +1 -1
  11. package/dist/assets/{arkade-zozCldAE.js → arkade-BmxJTa65.js} +2 -2
  12. package/dist/assets/{arkade-zozCldAE.js.map → arkade-BmxJTa65.js.map} +1 -1
  13. package/dist/assets/{backup-BL49Kt-T.js → backup-BxSH5BZG.js} +7 -7
  14. package/dist/assets/{backup-BL49Kt-T.js.map → backup-BxSH5BZG.js.map} +1 -1
  15. package/dist/assets/{backup-BvIFcZM7.js → backup-C0Plp-DF.js} +1 -1
  16. package/dist/assets/{buttons-CAW5v5EE.js → buttons-B-ZJYdo0.js} +6 -6
  17. package/dist/assets/{buttons-CAW5v5EE.js.map → buttons-B-ZJYdo0.js.map} +1 -1
  18. package/dist/assets/buttons-DA3wZfG0.js +2 -0
  19. package/dist/assets/{client-CyApKBEw.js → client-CDa87uYD.js} +3 -3
  20. package/dist/assets/{client-CyApKBEw.js.map → client-CDa87uYD.js.map} +1 -1
  21. package/dist/assets/{codec-DqFxxB_q.js → codec-D45W1L8n.js} +2 -2
  22. package/dist/assets/{codec-DqFxxB_q.js.map → codec-D45W1L8n.js.map} +1 -1
  23. package/dist/assets/{envelope-CMUgz31I.js → envelope-C3yFCQa-.js} +2 -2
  24. package/dist/assets/{envelope-CMUgz31I.js.map → envelope-C3yFCQa-.js.map} +1 -1
  25. package/dist/assets/{errors-R4S2SAEM.js → errors-Dt-ZnyOX.js} +3 -1
  26. package/dist/assets/errors-Dt-ZnyOX.js.map +1 -0
  27. package/dist/assets/{fixedHosts-C2hdCfzK.js → fixedHosts-C6nCHjOa.js} +4 -4
  28. package/dist/assets/{fixedHosts-C2hdCfzK.js.map → fixedHosts-C6nCHjOa.js.map} +1 -1
  29. package/dist/assets/{groupFiles-BAQIt_bJ.js → groupFiles-DYopNE57.js} +156 -41
  30. package/dist/assets/groupFiles-DYopNE57.js.map +1 -0
  31. package/dist/assets/{host-CaRlDMTd.js → host-G5seUwaI.js} +108 -55
  32. package/dist/assets/host-G5seUwaI.js.map +1 -0
  33. package/dist/assets/{hyperdhtRelay-BxADl3SG.js → hyperdhtRelay-B_uHjg_r.js} +28 -20
  34. package/dist/assets/hyperdhtRelay-B_uHjg_r.js.map +1 -0
  35. package/dist/assets/{irohWeb-D2sh6EWp.js → irohWeb-C-2oslSU.js} +112 -34
  36. package/dist/assets/{irohWeb-D2sh6EWp.js.map → irohWeb-C-2oslSU.js.map} +1 -1
  37. package/dist/assets/{main-Bc4Ow56Z.js → main-Dk--nD7X.js} +69 -41
  38. package/dist/assets/main-Dk--nD7X.js.map +1 -0
  39. package/dist/assets/{mainline-DWh4Ccri.js → mainline-HPlVrl8R.js} +5 -5
  40. package/dist/assets/mainline-HPlVrl8R.js.map +1 -0
  41. package/dist/assets/{networkReason-DT_D_Wpc.js → networkReason-CfpO9ayz.js} +3 -3
  42. package/dist/assets/{networkReason-DT_D_Wpc.js.map → networkReason-CfpO9ayz.js.map} +1 -1
  43. package/dist/assets/{nwc-DoSEhUKb.js → nwc-BY7BPttn.js} +3 -3
  44. package/dist/assets/{nwc-DoSEhUKb.js.map → nwc-BY7BPttn.js.map} +1 -1
  45. package/dist/assets/{nwcProvider-CGWqUjpB.js → nwcProvider-CfpbNUf7.js} +2 -2
  46. package/dist/assets/{nwcProvider-CGWqUjpB.js.map → nwcProvider-CfpbNUf7.js.map} +1 -1
  47. package/dist/assets/{ownDid-CbGjRLBn.js → ownDid-DJFZM2cV.js} +2 -2
  48. package/dist/assets/{ownDid-CbGjRLBn.js.map → ownDid-DJFZM2cV.js.map} +1 -1
  49. package/dist/assets/{profiles-DgIfvBeN.js → profiles-DKmZGXp6.js} +13 -6
  50. package/dist/assets/profiles-DKmZGXp6.js.map +1 -0
  51. package/dist/assets/{registry-BSyxGjN6.js → registry-BUm4cAzV.js} +54 -15
  52. package/dist/assets/registry-BUm4cAzV.js.map +1 -0
  53. package/dist/assets/{registry-C5cn80Rw.js → registry-CAzrtV0_.js} +1 -1
  54. package/dist/assets/{resolve-D-9YRFhl.js → resolve-CDD4X68j.js} +5 -3
  55. package/dist/assets/resolve-CDD4X68j.js.map +1 -0
  56. package/dist/assets/{restoredRows-CRYwIx3g.js → restoredRows-YhlbokEE.js} +4 -2
  57. package/dist/assets/restoredRows-YhlbokEE.js.map +1 -0
  58. package/dist/assets/{secretGuard-CSVNxXVW.js → secretGuard-B7Hj0Kvz.js} +2 -2
  59. package/dist/assets/{secretGuard-CSVNxXVW.js.map → secretGuard-B7Hj0Kvz.js.map} +1 -1
  60. package/dist/assets/secretGuard-DUr6bgKc.js +2 -0
  61. package/dist/assets/{server-BufntkX8.js → server-DcOsgYDU.js} +821 -299
  62. package/dist/assets/server-DcOsgYDU.js.map +1 -0
  63. package/dist/assets/{src-CCt5s4DK.js → src-D31D1_oY.js} +417 -67
  64. package/dist/assets/src-D31D1_oY.js.map +1 -0
  65. package/dist/assets/{sshForges-D8CPaIbR.js → sshForges-DerRwMf3.js} +2 -2
  66. package/dist/assets/{sshForges-D8CPaIbR.js.map → sshForges-DerRwMf3.js.map} +1 -1
  67. package/dist/assets/{translate-Cb-6hMhD.js → translate-C-sj0VJe.js} +3 -3
  68. package/dist/assets/{translate-Cb-6hMhD.js.map → translate-C-sj0VJe.js.map} +1 -1
  69. package/dist/assets/{usdt-ds461mzA.js → usdt-DwHqp625.js} +3 -3
  70. package/dist/assets/{usdt-ds461mzA.js.map → usdt-DwHqp625.js.map} +1 -1
  71. package/dist/assets/{waitNotice-B8D8WhbE.js → waitNotice-D52RWbV4.js} +38 -4
  72. package/dist/assets/waitNotice-D52RWbV4.js.map +1 -0
  73. package/dist/assets/{words-B1ylON2h.js → words-Db9WgatT.js} +3 -3
  74. package/dist/assets/words-Db9WgatT.js.map +1 -0
  75. package/dist/ghostly.mjs +1 -1
  76. package/package.json +1 -1
  77. package/dist/assets/api-Bi6hCcwG.js.map +0 -1
  78. package/dist/assets/apiKit-DzXHZojD.js.map +0 -1
  79. package/dist/assets/buttons-oJI5mHSL.js +0 -2
  80. package/dist/assets/errors-R4S2SAEM.js.map +0 -1
  81. package/dist/assets/groupFiles-BAQIt_bJ.js.map +0 -1
  82. package/dist/assets/host-CaRlDMTd.js.map +0 -1
  83. package/dist/assets/hyperdhtRelay-BxADl3SG.js.map +0 -1
  84. package/dist/assets/main-Bc4Ow56Z.js.map +0 -1
  85. package/dist/assets/mainline-DWh4Ccri.js.map +0 -1
  86. package/dist/assets/profiles-DgIfvBeN.js.map +0 -1
  87. package/dist/assets/registry-BSyxGjN6.js.map +0 -1
  88. package/dist/assets/resolve-D-9YRFhl.js.map +0 -1
  89. package/dist/assets/restoredRows-CRYwIx3g.js.map +0 -1
  90. package/dist/assets/secretGuard-Q2BKq0q0.js +0 -2
  91. package/dist/assets/server-BufntkX8.js.map +0 -1
  92. package/dist/assets/src-CCt5s4DK.js.map +0 -1
  93. package/dist/assets/waitNotice-B8D8WhbE.js.map +0 -1
  94. package/dist/assets/words-B1ylON2h.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import { Eu as setLinkTraceSink, Ku as fromBase64Url, Wo as DAEMON_WATCH_PEER_IDLE_MS, as as CALL_SIGNAL_MAX_AGE_MS, cs as answersOffer, ds as callSignalHeardAt, hs as signalHasVideo, li as checkPushEndpoint, ls as buildSdpFromSignal, ms as parseCallSignal, ps as extractParamsFromSdp, sa as isPublicAddress, ss as RTC_CONFIG, us as callRtcConfig } from "./src-CCt5s4DK.js";
2
- import { o as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-D2sh6EWp.js";
3
- import { r as asCliError, t as CliError } from "./errors-R4S2SAEM.js";
4
- import { l as findOwnNamedChat, o as findChat } from "./apiKit-DzXHZojD.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-Bi6hCcwG.js";
6
- import { S as runtimePath, g as startingPath, n as RESTORED_MARK, r as acquireLock, v as ownFolder, x as privateFolder, y as ownProfile } from "./profiles-DgIfvBeN.js";
7
- import { c as proof, d as DEFAULT_RATE, f as PlaybackQueue, g as isCallRate, h as frameSamples, l as removeDaemonSecret, m as frameBytes, o as greeting, p as bytesToMs, s as newDaemonSecret } from "./client-CyApKBEw.js";
1
+ import { Au as setLinkTraceSink, Qu as fromBase64Url, _s as parseCallSignal, cs as CALL_SIGNAL_MAX_AGE_MS, ds as answersOffer, fi as checkPushEndpoint, fs as buildSdpFromSignal, gs as extractParamsFromSdp, ms as callSignalHeardAt, ps as callRtcConfig, qo as DAEMON_WATCH_PEER_IDLE_MS, ua as isPublicAddress, us as RTC_CONFIG, vs as signalHasVideo } from "./src-D31D1_oY.js";
2
+ import { o as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-C-2oslSU.js";
3
+ import { r as asCliError, t as CliError } from "./errors-Dt-ZnyOX.js";
4
+ import { s as findChat, u as findOwnNamedChat } from "./apiKit-CJVp_crp.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-EUGHGnRz.js";
6
+ import { S as runtimePath, g as startingPath, n as RESTORED_MARK, r as acquireLock, v as ownFolder, x as privateFolder, y as ownProfile } from "./profiles-DKmZGXp6.js";
7
+ import { c as proof, d as DEFAULT_RATE, f as PlaybackQueue, g as isCallRate, h as frameSamples, l as removeDaemonSecret, m as frameBytes, o as greeting, p as bytesToMs, s as newDaemonSecret } from "./client-CDa87uYD.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, truncateSync, writeFileSync, writeSync } from "node:fs";
10
10
  import { readFile } from "node:fs/promises";
@@ -1329,7 +1329,8 @@ var CallManager = class {
1329
1329
  };
1330
1330
  }
1331
1331
  setAuto(next) {
1332
- const from = (next.from ?? []).map((ref) => findOwnNamedChat(this.host.engine.getState().links, ref).id);
1332
+ const { links, groups } = this.host.engine.getState();
1333
+ const from = (next.from ?? []).map((ref) => findOwnNamedChat(links, ref, groups).id);
1333
1334
  this.auto = {
1334
1335
  on: next.on,
1335
1336
  from: next.on ? from : [],
@@ -1656,9 +1657,10 @@ var CallManager = class {
1656
1657
  link(chat) {
1657
1658
  return this.host.engine.getState().links.find((l) => l.id === chat);
1658
1659
  }
1659
- /** A chat by id, contact key, prefix or name (the API's rules, `findChat`). */
1660
+ /** A chat by id, contact key, prefix or name (the API's rules, `findChat`); a group's says it is one. */
1660
1661
  chatId(ref) {
1661
- return findChat(this.host.engine.getState().links, ref).id;
1662
+ const { links, groups } = this.host.engine.getState();
1663
+ return findChat(links, ref, groups).id;
1662
1664
  }
1663
1665
  /** The chat, if a call can go in it now; else why not (the engine's reason). */
1664
1666
  callable(ref) {
@@ -1743,6 +1745,8 @@ var EventHub = class {
1743
1745
  marked = false;
1744
1746
  /** Whether `dropped` is ahead of `<journal>.dropped` (a full disk refused it): the next event's write tries it again. */
1745
1747
  markOwed = false;
1748
+ /** Typing changes told this run: a change's id carries it, as it takes no seq of its own (`emitLive`). */
1749
+ typingChanges = 0;
1746
1750
  journalLines = 0;
1747
1751
  journalBytes = 0;
1748
1752
  listeners = /* @__PURE__ */ new Set();
@@ -2015,7 +2019,7 @@ var EventHub = class {
2015
2019
  }
2016
2020
  /**
2017
2021
  * An event for the listeners only, never the journal: a contact's app frames, live only (WISP 1200), which at the
2018
- * receiver's rate would push every other chat's events out of it in seconds. It takes no seq of its own but the last
2022
+ * receiver's rate would push every other chat's events out of it in seconds, and typing, which lasts seconds. It takes no seq of its own but the last
2019
2023
  * event's (as an `agent.turn` takes its source's): a cursor that handled it resumes after that event, a replay never
2020
2024
  * gives it, and a restart never numbers an event again.
2021
2025
  */
@@ -2049,54 +2053,78 @@ var EventHub = class {
2049
2053
  this.journalBytes = bytes;
2050
2054
  }
2051
2055
  /**
2052
- * What was removed here leaves the journal too: the journal is written again without the events that name it (a
2053
- * line that names it and cannot be read goes as well), and a journal set aside as unreadable, which cannot be sorted,
2054
- * is deleted. `ids`: what was removed (a message's id, a chat's or a group's); `gone`: whether an event is of it;
2055
- * `unquote`: an event that stays, written again without what it quotes of the removed (a reply's event), else none.
2056
+ * What was removed here leaves the journal too: the events that name it are blanked, or the journal is written again
2057
+ * without them (a line that names it and cannot be read goes as well), and a journal set aside as unreadable, which
2058
+ * cannot be sorted, is deleted. `ids`: what was removed (a message's id, a chat's or a group's); `gone`: whether an
2059
+ * event is of it; `unquote`: an event that stays, written again without what it quotes of the removed (a reply's
2060
+ * event), else none.
2056
2061
  */
2057
2062
  forget(ids, gone, unquote = () => void 0) {
2058
2063
  if (!ids.length) return;
2059
2064
  try {
2060
2065
  rmSync(this.journalPath + ".unreadable", { force: true });
2061
2066
  if (!existsSync(this.journalPath)) return;
2062
- const { bytes, start } = journalWindow(this.journalPath);
2067
+ const { bytes, start, at } = journalWindow(this.journalPath);
2063
2068
  const needles = ids.map((id) => JSON.stringify(id)), few = ids.length <= FORGET_SEARCHED_IDS;
2064
2069
  const names = (line) => needles.some((needle) => line.includes(needle));
2065
- let from = few ? bytes.length : start;
2066
- if (few) for (const needle of needles) {
2067
- const at = bytes.indexOf(needle, start);
2068
- if (at !== -1 && at < from) from = at;
2069
- }
2070
- if (from === bytes.length) return;
2071
- from = Math.max(start, bytes.lastIndexOf(10, from) + 1);
2072
- const lines = bytes.toString("utf8", from).split("\n").filter(Boolean);
2073
- let changed = false;
2074
- const kept = lines.flatMap((line) => {
2075
- if (few && !names(line)) return [line];
2070
+ const edits = [];
2071
+ for (const [from, to] of few ? linesNaming(bytes, start, needles) : linesOf(bytes, start)) {
2072
+ const line = bytes.toString("utf8", from, to);
2076
2073
  let event;
2077
2074
  try {
2078
2075
  event = JSON.parse(line);
2079
2076
  } catch {
2080
- if (!few && !names(line)) return [line];
2081
- changed = true;
2082
- return [];
2077
+ if (few || names(line)) edits.push({
2078
+ from,
2079
+ to,
2080
+ line: null
2081
+ });
2082
+ continue;
2083
2083
  }
2084
2084
  if (gone(event)) {
2085
- changed = true;
2086
- return [];
2085
+ edits.push({
2086
+ from,
2087
+ to,
2088
+ line: null
2089
+ });
2090
+ continue;
2087
2091
  }
2088
2092
  const written = unquote(event);
2089
- if (!written) return [line];
2090
- changed = true;
2091
- return [JSON.stringify(written)];
2092
- });
2093
- if (!changed) return;
2093
+ if (written) edits.push({
2094
+ from,
2095
+ to,
2096
+ line: JSON.stringify(written)
2097
+ });
2098
+ }
2099
+ if (!edits.length) return;
2094
2100
  if (!this.marked) this.markDropped(this.dropped);
2095
- const tail = kept.length ? kept.join("\n") + "\n" : "";
2096
- writeFileSync(this.journalPath + ".tmp", Buffer.concat([bytes.subarray(start, from), Buffer.from(tail)]), { mode: 384 });
2101
+ if (few && edits.every(({ from, to, line }) => line === null || Buffer.byteLength(line) <= to - from)) {
2102
+ const fd = openSync(this.journalPath, "r+");
2103
+ try {
2104
+ for (const { from, to, line } of edits) {
2105
+ const over = Buffer.alloc(to - from, " ");
2106
+ if (line !== null) over.write(line);
2107
+ for (let done = 0; done < over.length;) done += writeSync(fd, over, done, over.length - done, at + from + done);
2108
+ }
2109
+ } finally {
2110
+ closeSync(fd);
2111
+ }
2112
+ return;
2113
+ }
2114
+ const parts = [];
2115
+ let from = start, removed = 0;
2116
+ for (const edit of edits) {
2117
+ parts.push(bytes.subarray(from, edit.from));
2118
+ if (edit.line === null) removed++;
2119
+ else parts.push(Buffer.from(edit.line));
2120
+ from = edit.line === null ? edit.to + 1 : edit.to;
2121
+ }
2122
+ parts.push(bytes.subarray(from));
2123
+ const written = Buffer.concat(parts);
2124
+ writeFileSync(this.journalPath + ".tmp", written, { mode: 384 });
2097
2125
  renameSync(this.journalPath + ".tmp", this.journalPath);
2098
- this.journalLines -= lines.length - kept.length;
2099
- this.journalBytes = from - start + Buffer.byteLength(tail);
2126
+ this.journalLines -= removed;
2127
+ this.journalBytes = written.length;
2100
2128
  } catch (error) {
2101
2129
  process.stderr.write(`ghostly: event journal error: ${error instanceof Error ? error.message : String(error)}\n`);
2102
2130
  }
@@ -2167,11 +2195,11 @@ var EventHub = class {
2167
2195
  name: shape.name
2168
2196
  });
2169
2197
  this.pinned("chat", id, before.pin, shape.pin);
2170
- if (shape.typing !== before.typing) this.emit(shape.typing ? "typing.started" : "typing.stopped", `typing.${shape.typing ? "started" : "stopped"}:${id}:${this.now()}`, {
2198
+ if (shape.typing !== before.typing) this.emitLive(shape.typing ? "typing.started" : "typing.stopped", `typing.${shape.typing ? "started" : "stopped"}:${id}:${this.now()}`, {
2171
2199
  chat: id,
2172
2200
  ...shape.typing ? typingFields(shape) : {}
2173
2201
  });
2174
- else if (shape.typing && (shape.typingKind !== before.typingKind || shape.typingStatus !== before.typingStatus)) this.emit("typing.started", `typing.started:${id}:${this.now()}:${this.seq + 1}`, {
2202
+ else if (shape.typing && (shape.typingKind !== before.typingKind || shape.typingStatus !== before.typingStatus)) this.emitLive("typing.started", `typing.started:${id}:${this.now()}:${++this.typingChanges}`, {
2175
2203
  chat: id,
2176
2204
  ...typingFields(shape)
2177
2205
  });
@@ -2210,13 +2238,13 @@ var EventHub = class {
2210
2238
  for (const [member, word] of Object.entries(shape.typing)) {
2211
2239
  const was = before.typing[member];
2212
2240
  if (was && was.kind === word.kind && was.status === word.status) continue;
2213
- this.emit("group.typing.started", `group.typing.started:${id}:${member}:${this.now()}${was ? `:${this.seq + 1}` : ""}`, {
2241
+ this.emitLive("group.typing.started", `group.typing.started:${id}:${member}:${this.now()}${was ? `:${++this.typingChanges}` : ""}`, {
2214
2242
  group: id,
2215
2243
  member,
2216
2244
  ...word
2217
2245
  });
2218
2246
  }
2219
- for (const member of Object.keys(before.typing)) if (!shape.typing[member]) this.emit("group.typing.stopped", `group.typing.stopped:${id}:${member}:${this.now()}`, {
2247
+ for (const member of Object.keys(before.typing)) if (!shape.typing[member]) this.emitLive("group.typing.stopped", `group.typing.stopped:${id}:${member}:${this.now()}`, {
2220
2248
  group: id,
2221
2249
  member
2222
2250
  });
@@ -2686,12 +2714,13 @@ function groupShape(group) {
2686
2714
  }
2687
2715
  /**
2688
2716
  * The journal's whole lines within its last `JOURNAL_MAX_BYTES`, and its size: never the whole file as one string, so
2689
- * a journal grown past what a string can hold (or a trim's bound) is still read, and in bounded time.
2717
+ * a journal grown past what a string can hold (or a trim's bound) is still read, and in bounded time. Lines `forget`
2718
+ * blanked are left out.
2690
2719
  */
2691
2720
  function journalTail(path) {
2692
2721
  const { bytes, start, size } = journalWindow(path);
2693
2722
  return {
2694
- lines: bytes.toString("utf8", start).split("\n").filter(Boolean),
2723
+ lines: bytes.toString("utf8", start).split("\n").filter((line) => line.trimStart()),
2695
2724
  size
2696
2725
  };
2697
2726
  }
@@ -2778,7 +2807,30 @@ function appendWhole(path, line) {
2778
2807
  closeSync(fd);
2779
2808
  }
2780
2809
  }
2781
- /** The bytes of the journal's last `JOURNAL_MAX_BYTES`, `start` where its first whole line begins in them, and its size. */
2810
+ /** The bounds in `bytes` of each line from `start` on, its newline left out. */
2811
+ function linesOf(bytes, start) {
2812
+ const lines = [];
2813
+ for (let from = start; from < bytes.length;) {
2814
+ const end = bytes.indexOf(10, from), to = end === -1 ? bytes.length : end;
2815
+ if (to > from) lines.push([from, to]);
2816
+ from = to + 1;
2817
+ }
2818
+ return lines;
2819
+ }
2820
+ /** The bounds in `bytes` of each line from `start` on that holds one of the needles, in their order, found in the bytes. */
2821
+ function linesNaming(bytes, start, needles) {
2822
+ const lines = /* @__PURE__ */ new Map();
2823
+ for (const needle of needles) for (let at = bytes.indexOf(needle, start); at !== -1;) {
2824
+ const from = Math.max(start, bytes.lastIndexOf(10, at) + 1), end = bytes.indexOf(10, at), to = end === -1 ? bytes.length : end;
2825
+ lines.set(from, to);
2826
+ at = end === -1 ? -1 : bytes.indexOf(needle, end + 1);
2827
+ }
2828
+ return [...lines].sort(([a], [b]) => a - b);
2829
+ }
2830
+ /**
2831
+ * The bytes of the journal's last `JOURNAL_MAX_BYTES`, `start` where its first whole line begins in them, `at` where
2832
+ * they begin in the file, and its size.
2833
+ */
2782
2834
  function journalWindow(path) {
2783
2835
  const fd = openSync(path, "r");
2784
2836
  try {
@@ -2795,6 +2847,7 @@ function journalWindow(path) {
2795
2847
  return {
2796
2848
  bytes,
2797
2849
  start: from > 0 ? bytes.indexOf(10) + 1 || bytes.length : 0,
2850
+ at: from,
2798
2851
  size
2799
2852
  };
2800
2853
  } finally {
@@ -4985,8 +5038,8 @@ function mainlineNetwork(env = process.env) {
4985
5038
  }
4986
5039
  /**
4987
5040
  * WebRTC for the engine (WISP 101): libdatachannel through node-datachannel's W3C polyfill. Chats go live over it with
4988
- * browsers directly, and groups need it (their links use WebRTC alone). A native module: without it, or with
4989
- * `GHOSTLY_WEBRTC=0`, the CLI runs without WebRTC and says so.
5041
+ * browsers directly, and calls need it. A native module: without it, or with `GHOSTLY_WEBRTC=0`, the CLI runs without
5042
+ * WebRTC and says so; its groups' links go over Iroh or HyperDHT (WISP 902 § Transports).
4990
5043
  */
4991
5044
  async function installWebRtc() {
4992
5045
  if (!envSwitch("GHOSTLY_WEBRTC", true)) return false;
@@ -5093,7 +5146,7 @@ async function startRuntime(paths, options = {}) {
5093
5146
  const restored = join(paths.dir, RESTORED_MARK);
5094
5147
  if (existsSync(restored)) {
5095
5148
  try {
5096
- const rows = await import("./restoredRows-CRYwIx3g.js");
5149
+ const rows = await import("./restoredRows-YhlbokEE.js");
5097
5150
  await rows.markRestoredWallet();
5098
5151
  await rows.markLeftOutFiles(leftOutIn(restored));
5099
5152
  await rows.forgetRatchets();
@@ -5116,12 +5169,12 @@ async function startRuntime(paths, options = {}) {
5116
5169
  const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-DMzrIdCu.js"), import("./fileBytes-Douk1yOp.js")]);
5117
5170
  registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
5118
5171
  if (await (await import("./blobFiles-BnjN_Vrz.js")).moveBlobFiles()) await store.compact();
5119
- const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-BufntkX8.js"), import("./endpoint-DWHkXWVM.js")]);
5120
- const mainline = dht.off ? null : new (await (import("./mainline-DWh4Ccri.js"))).Mainline({
5172
+ const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-DcOsgYDU.js"), import("./endpoint-DWHkXWVM.js")]);
5173
+ const mainline = dht.off ? null : new (await (import("./mainline-HPlVrl8R.js"))).Mainline({
5121
5174
  bootstrap: dht.bootstrap,
5122
5175
  host: dht.host
5123
5176
  });
5124
- const transport = mainline || pinned ? new (await (import("./mainline-DWh4Ccri.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
5177
+ const transport = mainline || pinned ? new (await (import("./mainline-HPlVrl8R.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
5125
5178
  const apps = servedApps(paths.dir).length > 0;
5126
5179
  const server = new EngineServer({
5127
5180
  ...transport ? { transport } : {},
@@ -5481,4 +5534,4 @@ function connection(ctx, socket, secret) {
5481
5534
  //#endregion
5482
5535
  export { BASELINE_NEWEST, MAX_UNREAD, keepServing, openHost, serve };
5483
5536
 
5484
- //# sourceMappingURL=host-CaRlDMTd.js.map
5537
+ //# sourceMappingURL=host-G5seUwaI.js.map