@ghostlytools/cli 1.7.2 → 1.7.3

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 (66) hide show
  1. package/README.md +22 -14
  2. package/SKILL.md +5 -1
  3. package/dist/assets/{api-CcuCtc1H.js → api-B42F9ytB.js} +2 -2
  4. package/dist/assets/{api-tSZELCPQ.js → api-tf-wAAnB.js} +214 -87
  5. package/dist/assets/api-tf-wAAnB.js.map +1 -0
  6. package/dist/assets/{apiKit-BFk7GAk9.js → apiKit-DJb9hulp.js} +33 -4
  7. package/dist/assets/{apiKit-BFk7GAk9.js.map → apiKit-DJb9hulp.js.map} +1 -1
  8. package/dist/assets/{apps-D6THreq_.js → apps-BfoDISRg.js} +1 -1
  9. package/dist/assets/{apps-C5Mi6x9Q.js → apps-DIrWmLgL.js} +3 -3
  10. package/dist/assets/{apps-C5Mi6x9Q.js.map → apps-DIrWmLgL.js.map} +1 -1
  11. package/dist/assets/{arkade-Cz0B9bJ0.js → arkade-CJAhhgPQ.js} +2 -2
  12. package/dist/assets/{arkade-Cz0B9bJ0.js.map → arkade-CJAhhgPQ.js.map} +1 -1
  13. package/dist/assets/{backup-A0hIa9GE.js → backup-BkUeeduy.js} +1 -1
  14. package/dist/assets/{backup-Wb2sm2dd.js → backup-Bko-AAm0.js} +4 -4
  15. package/dist/assets/{backup-Wb2sm2dd.js.map → backup-Bko-AAm0.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/buttons-Be7u0V5g.js +2 -0
  19. package/dist/assets/{buttons-Cf70NVYq.js → buttons-DeA6Yddq.js} +34 -8
  20. package/dist/assets/buttons-DeA6Yddq.js.map +1 -0
  21. package/dist/assets/{envelope-kQ5kYjVE.js → envelope-Cz5fc7BM.js} +2 -2
  22. package/dist/assets/{envelope-kQ5kYjVE.js.map → envelope-Cz5fc7BM.js.map} +1 -1
  23. package/dist/assets/{groupFiles-D9Ttlm3M.js → groupFiles-BlZRBWpt.js} +558 -4
  24. package/dist/assets/groupFiles-BlZRBWpt.js.map +1 -0
  25. package/dist/assets/{host-DpypH-fR.js → host-BX0DmKW6.js} +38 -15
  26. package/dist/assets/host-BX0DmKW6.js.map +1 -0
  27. package/dist/assets/{hyperdhtRelay-D1rj84v2.js → hyperdhtRelay-DitYDnXx.js} +2 -2
  28. package/dist/assets/{hyperdhtRelay-D1rj84v2.js.map → hyperdhtRelay-DitYDnXx.js.map} +1 -1
  29. package/dist/assets/{irohWeb-BTSlWgEX.js → irohWeb-R3bcd34h.js} +2 -2
  30. package/dist/assets/{irohWeb-BTSlWgEX.js.map → irohWeb-R3bcd34h.js.map} +1 -1
  31. package/dist/assets/{main-BwgoQZVu.js → main-6QOSvQ8b.js} +247 -102
  32. package/dist/assets/main-6QOSvQ8b.js.map +1 -0
  33. package/dist/assets/{mainline-B1urhbEZ.js → mainline-BfwezHWi.js} +2 -2
  34. package/dist/assets/{mainline-B1urhbEZ.js.map → mainline-BfwezHWi.js.map} +1 -1
  35. package/dist/assets/{networkReason-D2Z0BdIj.js → networkReason-Ba9415nn.js} +2 -2
  36. package/dist/assets/{networkReason-D2Z0BdIj.js.map → networkReason-Ba9415nn.js.map} +1 -1
  37. package/dist/assets/{nwc-T2aUK6bi.js → nwc-ovXSN2M2.js} +3 -3
  38. package/dist/assets/{nwc-T2aUK6bi.js.map → nwc-ovXSN2M2.js.map} +1 -1
  39. package/dist/assets/{nwcProvider-Dz-ty_DE.js → nwcProvider-BzZbfFP3.js} +2 -2
  40. package/dist/assets/{nwcProvider-Dz-ty_DE.js.map → nwcProvider-BzZbfFP3.js.map} +1 -1
  41. package/dist/assets/{registry-Bazitl0a.js → registry-B0Uv9yL6.js} +3 -3
  42. package/dist/assets/{registry-Bazitl0a.js.map → registry-B0Uv9yL6.js.map} +1 -1
  43. package/dist/assets/{registry-BlSTJlbv.js → registry-CFtlhWCI.js} +1 -1
  44. package/dist/assets/{resolve-Bx1Eeg-w.js → resolve-BzFG4WDU.js} +2 -2
  45. package/dist/assets/{resolve-Bx1Eeg-w.js.map → resolve-BzFG4WDU.js.map} +1 -1
  46. package/dist/assets/{server-CnPj9wWh.js → server-BGCuHbmQ.js} +266 -594
  47. package/dist/assets/server-BGCuHbmQ.js.map +1 -0
  48. package/dist/assets/{src-BsznF3XG.js → src-DWw2hUE5.js} +106 -38
  49. package/dist/assets/src-DWw2hUE5.js.map +1 -0
  50. package/dist/assets/{translate-cDBotA-b.js → translate-DObb-1tq.js} +2 -2
  51. package/dist/assets/{translate-cDBotA-b.js.map → translate-DObb-1tq.js.map} +1 -1
  52. package/dist/assets/{usdt-DxxLdG60.js → usdt-Bkva90Vo.js} +3 -3
  53. package/dist/assets/{usdt-DxxLdG60.js.map → usdt-Bkva90Vo.js.map} +1 -1
  54. package/dist/assets/{words-qH8gGtmc.js → words-odSAoasK.js} +4 -2
  55. package/dist/assets/words-odSAoasK.js.map +1 -0
  56. package/dist/ghostly.mjs +1 -1
  57. package/package.json +1 -1
  58. package/dist/assets/api-tSZELCPQ.js.map +0 -1
  59. package/dist/assets/buttons-Bxxu3lSk.js +0 -2
  60. package/dist/assets/buttons-Cf70NVYq.js.map +0 -1
  61. package/dist/assets/groupFiles-D9Ttlm3M.js.map +0 -1
  62. package/dist/assets/host-DpypH-fR.js.map +0 -1
  63. package/dist/assets/main-BwgoQZVu.js.map +0 -1
  64. package/dist/assets/server-CnPj9wWh.js.map +0 -1
  65. package/dist/assets/src-BsznF3XG.js.map +0 -1
  66. package/dist/assets/words-qH8gGtmc.js.map +0 -1
@@ -1,8 +1,8 @@
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-BsznF3XG.js";
2
- import { a as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-BTSlWgEX.js";
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
3
  import { r as asCliError, t as CliError } from "./errors-mnjSQlbX.js";
4
- import { a as findChat, c as findOwnNamedChat } from "./apiKit-BFk7GAk9.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-tSZELCPQ.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
6
  import { g as ownFolder, n as RESTORED_MARK, r as acquireLock, v as privateFolder, y as runtimePath } from "./profiles-C6XWqre5.js";
7
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";
8
8
  import { createRequire } from "node:module";
@@ -1496,7 +1496,7 @@ var CallManager = class {
1496
1496
  }
1497
1497
  }
1498
1498
  async stack() {
1499
- if (this.host.answers === false) throw new CliError("unavailable", "Calls need the daemon (a call outlives this command): start it with `ghostly daemon --detach`");
1499
+ if (this.host.answers === false) throw new CliError("unavailable", CALLS_NEED_DAEMON);
1500
1500
  const stack = await (this.host.stack ?? loadCallStack)();
1501
1501
  if (typeof stack === "string") throw new CliError("unavailable", stack);
1502
1502
  return stack;
@@ -1559,6 +1559,7 @@ var CallManager = class {
1559
1559
  /** The chat, if a call can go in it now; else why not (the engine's reason). */
1560
1560
  callable(ref) {
1561
1561
  const link = this.link(this.chatId(ref));
1562
+ if (this.host.answers === false) throw new CliError("unavailable", CALLS_NEED_DAEMON);
1562
1563
  if (!link.profile) throw new CliError("unavailable", "Calls are in chats made since 0.4 (the chat session): this is a compatibility chat");
1563
1564
  if (link.callsUnavailable) throw new CliError("unavailable", link.callsUnavailable);
1564
1565
  return link;
@@ -1567,6 +1568,7 @@ var CallManager = class {
1567
1568
  return this.auto.on && (this.auto.from.length === 0 || this.auto.from.includes(chat));
1568
1569
  }
1569
1570
  };
1571
+ var CALLS_NEED_DAEMON = "Calls need the daemon (a call outlives this command): start it with `ghostly daemon --detach`";
1570
1572
  function nameOf(link) {
1571
1573
  return link.label?.trim() || link.peerNick?.trim() || null;
1572
1574
  }
@@ -3441,6 +3443,14 @@ var ON_DISK = /* @__PURE__ */ new Set(["messages", "fileState"]);
3441
3443
  var COMPACT_BYTES = 33554432;
3442
3444
  /** A journal up to this is kept at close and at start: replaying it costs less than writing the snapshot again. */
3443
3445
  var KEEP_BYTES = 1048576;
3446
+ /** The stores whose rows a delete means gone from the disk: the chats (their seed, their ratchet) and their messages. */
3447
+ var FORGOTTEN = /* @__PURE__ */ new Set(["links", "messages"]);
3448
+ /**
3449
+ * 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.
3452
+ */
3453
+ var DELETE_FOLD_MS = 36e5;
3444
3454
  /**
3445
3455
  * The database a journal's close mark names. No profile has it, so a replay skips the mark (an older version's too:
3446
3456
  * it skips an op whose store it does not find).
@@ -3491,9 +3501,12 @@ async function openPersistentIndexedDb(dir, options = {}) {
3491
3501
  let unsaved = false;
3492
3502
  /** Set while the journal holds relaxed entries no sync has covered yet. */
3493
3503
  let relaxed = null;
3504
+ /** The journal holds a delete of a chat or a message, and what came before it with it. */
3505
+ let holdsDelete = false;
3494
3506
  const pending = /* @__PURE__ */ new WeakMap();
3495
3507
  const snapshotPath = join(dir, SNAPSHOT);
3496
3508
  const journalPath = join(dir, JOURNAL);
3509
+ const deleteDue = () => holdsDelete && Date.now() - (statSync(snapshotPath, { throwIfNoEntry: false })?.mtimeMs ?? 0) >= DELETE_FOLD_MS;
3497
3510
  const snapshotFound = existsSync(snapshotPath), journalFound = existsSync(journalPath);
3498
3511
  const saved = snapshotFound ? deserialize(readFileSync(snapshotPath)) : null;
3499
3512
  const rows = sqlite && saved?.format === 2 && rowsFound ? openRowFile(sqlite, rowsPath) : null;
@@ -3533,7 +3546,8 @@ async function openPersistentIndexedDb(dir, options = {}) {
3533
3546
  }) : {
3534
3547
  end: 0,
3535
3548
  closed: !folded,
3536
- seq: 0
3549
+ seq: 0,
3550
+ deletes: false
3537
3551
  };
3538
3552
  seq = Math.max(seq, replayed.seq);
3539
3553
  if (trees) {
@@ -3550,7 +3564,8 @@ async function openPersistentIndexedDb(dir, options = {}) {
3550
3564
  restoring = false;
3551
3565
  /** Whether the journal on disk says the store is closed: nothing was written since its mark, or there is none. */
3552
3566
  let marked = replayed.closed;
3553
- const kept = !!journal && named !== void 0 && named === snapshotName && replayed.end === journal.length && journal.length <= KEEP_BYTES;
3567
+ holdsDelete = replayed.deletes;
3568
+ const kept = !!journal && named !== void 0 && named === snapshotName && replayed.end === journal.length && journal.length <= KEEP_BYTES && !deleteDue();
3554
3569
  const rewrite = journal && !kept || !snapshotFound || moved;
3555
3570
  if (rewrite) await writeSnapshot();
3556
3571
  rows?.close();
@@ -3660,6 +3675,7 @@ async function openPersistentIndexedDb(dir, options = {}) {
3660
3675
  * and the transaction is to be refused, not completed.
3661
3676
  */
3662
3677
  function append(ops, lazy, entry, owner) {
3678
+ holdsDelete ||= ops.some(deletes);
3663
3679
  if (trees) ops = [{
3664
3680
  db: SEQ,
3665
3681
  store: "",
@@ -3808,7 +3824,7 @@ async function openPersistentIndexedDb(dir, options = {}) {
3808
3824
  failed(error);
3809
3825
  }
3810
3826
  }, RELAXED_SYNC_MS).unref();
3811
- if (statSync(journalPath).size > COMPACT_BYTES) enqueue(writeSnapshot);
3827
+ if (statSync(journalPath).size > COMPACT_BYTES || deleteDue()) enqueue(writeSnapshot);
3812
3828
  return true;
3813
3829
  }
3814
3830
  function sync() {
@@ -3914,10 +3930,11 @@ async function openPersistentIndexedDb(dir, options = {}) {
3914
3930
  }
3915
3931
  rmSync(journalPath, { force: true });
3916
3932
  marked = true;
3933
+ holdsDelete = false;
3917
3934
  }
3918
3935
  /** What `close` leaves: a short journal with the mark at its end, synced (its relaxed entries too), or a fresh snapshot. */
3919
3936
  async function leave() {
3920
- if (schemaDirty || unsaved || journalBytes() > KEEP_BYTES) return writeSnapshot();
3937
+ if (schemaDirty || unsaved || journalBytes() > KEEP_BYTES || deleteDue()) return writeSnapshot();
3921
3938
  if (marked) return;
3922
3939
  writeEntry(serialize([{
3923
3940
  db: CLOSED,
@@ -4454,6 +4471,10 @@ function fill(store, sorted) {
4454
4471
  store.records._numNodes = sorted.length;
4455
4472
  store.records._numTombstones = 0;
4456
4473
  }
4474
+ /** Whether an op takes a chat or a message away: a delete, or a clear of their store. */
4475
+ function deletes(op) {
4476
+ return op.kind !== "put" && FORGOTTEN.has(op.store);
4477
+ }
4457
4478
  /**
4458
4479
  * Replays whole entries; a torn last entry (the process died mid-write) was never acknowledged and is dropped.
4459
4480
  *
@@ -4483,7 +4504,7 @@ function replay(databases, journal, cmp, trees) {
4483
4504
  }
4484
4505
  }
4485
4506
  function replayEntries(databases, journal, touched, trees) {
4486
- let offset = 0, closed = false, last = 0;
4507
+ let offset = 0, closed = false, last = 0, deleted = false;
4487
4508
  while (offset + 4 <= journal.length) {
4488
4509
  const length = journal.readUInt32BE(offset);
4489
4510
  if (offset + 4 + length > journal.length) break;
@@ -4498,6 +4519,7 @@ function replayEntries(databases, journal, touched, trees) {
4498
4519
  const marker = ops.find((op) => op.db === SEQ);
4499
4520
  const entry = marker?.kind === "clear" ? marker.seq : void 0;
4500
4521
  if (entry !== void 0) last = Math.max(last, entry);
4522
+ deleted ||= ops.some(deletes);
4501
4523
  for (const op of ops) {
4502
4524
  const store = databases.get(op.db)?.rawObjectStores.get(op.store);
4503
4525
  if (!store) continue;
@@ -4519,7 +4541,8 @@ function replayEntries(databases, journal, touched, trees) {
4519
4541
  return {
4520
4542
  end: offset,
4521
4543
  closed: closed && offset === journal.length,
4522
- seq: last
4544
+ seq: last,
4545
+ deletes: deleted
4523
4546
  };
4524
4547
  }
4525
4548
  /**
@@ -4825,12 +4848,12 @@ async function startRuntime(paths, options = {}) {
4825
4848
  const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-OolN5cSY.js"), import("./fileBytes-_fd-2JRY.js")]);
4826
4849
  registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
4827
4850
  if (await (await import("./blobFiles-Bckz9fjp.js")).moveBlobFiles()) await store.compact();
4828
- const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-CnPj9wWh.js"), import("./endpoint-BdaeBw2L.js")]);
4829
- const mainline = dht.off ? null : new (await (import("./mainline-B1urhbEZ.js"))).Mainline({
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({
4830
4853
  bootstrap: dht.bootstrap,
4831
4854
  host: dht.host
4832
4855
  });
4833
- const transport = mainline || pinned ? new (await (import("./mainline-B1urhbEZ.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
4856
+ const transport = mainline || pinned ? new (await (import("./mainline-BfwezHWi.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
4834
4857
  const apps = servedApps(paths.dir).length > 0;
4835
4858
  const server = new EngineServer({
4836
4859
  ...transport ? { transport } : {},
@@ -5172,4 +5195,4 @@ function connection(ctx, socket, secret) {
5172
5195
  //#endregion
5173
5196
  export { BASELINE_NEWEST, MAX_LINE, MAX_UNREAD, keepServing, openHost, serve };
5174
5197
 
5175
- //# sourceMappingURL=host-DpypH-fR.js.map
5198
+ //# sourceMappingURL=host-BX0DmKW6.js.map