@ghostlytools/cli 1.4.4 → 1.5.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 (88) hide show
  1. package/README.md +14 -7
  2. package/dist/assets/{api-Cr5NjA-g.js → api-C_IHKsrl.js} +2 -2
  3. package/dist/assets/{api-N5IiCxB7.js → api-ClHM_G5A.js} +87 -60
  4. package/dist/assets/api-ClHM_G5A.js.map +1 -0
  5. package/dist/assets/{apiKit-BDB40JPK.js → apiKit-gS-yfb25.js} +2 -2
  6. package/dist/assets/{apiKit-BDB40JPK.js.map → apiKit-gS-yfb25.js.map} +1 -1
  7. package/dist/assets/{apps-Cf_TQYPs.js → apps-DP8pElH-.js} +2 -2
  8. package/dist/assets/{apps-Cf_TQYPs.js.map → apps-DP8pElH-.js.map} +1 -1
  9. package/dist/assets/{apps-C3H4yttJ.js → apps-DyihkNO-.js} +1 -1
  10. package/dist/assets/{arkade-DCovElLt.js → arkade-GzJoov-w.js} +2 -2
  11. package/dist/assets/{arkade-DCovElLt.js.map → arkade-GzJoov-w.js.map} +1 -1
  12. package/dist/assets/{backup-lrj6hQ3t.js → backup-A_C4hYNO.js} +1 -1
  13. package/dist/assets/{backup-Dnh7GFXh.js → backup-DKDXkaS1.js} +6 -6
  14. package/dist/assets/{backup-Dnh7GFXh.js.map → backup-DKDXkaS1.js.map} +1 -1
  15. package/dist/assets/{blobFiles-B0rNnHlO.js → blobFiles-1wUBd8ZD.js} +3 -3
  16. package/dist/assets/{blobFiles-B0rNnHlO.js.map → blobFiles-1wUBd8ZD.js.map} +1 -1
  17. package/dist/assets/{buttons-BCzrFo-d.js → buttons-BDw8cqDq.js} +3 -3
  18. package/dist/assets/{buttons-BCzrFo-d.js.map → buttons-BDw8cqDq.js.map} +1 -1
  19. package/dist/assets/buttons-CNkxiN2c.js +2 -0
  20. package/dist/assets/daemonProof-CWTVNUmr.js +254 -0
  21. package/dist/assets/daemonProof-CWTVNUmr.js.map +1 -0
  22. package/dist/assets/{envelope-BKSHUJnt.js → envelope-DEvU5FA9.js} +2 -2
  23. package/dist/assets/{envelope-BKSHUJnt.js.map → envelope-DEvU5FA9.js.map} +1 -1
  24. package/dist/assets/{fileBytes-B-fqGdEd.js → fileBytes-B8eTZfAT.js} +3 -3
  25. package/dist/assets/{fileBytes-B-fqGdEd.js.map → fileBytes-B8eTZfAT.js.map} +1 -1
  26. package/dist/assets/{fileBytes-C2jycN_7.js → fileBytes-gTd_8l-P.js} +1 -1
  27. package/dist/assets/{fileBytes-D6fqFQEX.js → fileBytes-uRqLyxa0.js} +2 -2
  28. package/dist/assets/{fileBytes-D6fqFQEX.js.map → fileBytes-uRqLyxa0.js.map} +1 -1
  29. package/dist/assets/{fileBytesIdb-_HnxdacI.js → fileBytesIdb-BIFKtgln.js} +3 -3
  30. package/dist/assets/{fileBytesIdb-_HnxdacI.js.map → fileBytesIdb-BIFKtgln.js.map} +1 -1
  31. package/dist/assets/fileBytesIdb-BVVr_rWX.js +2 -0
  32. package/dist/assets/{fileBytesOpfs-p_CANncD.js → fileBytesOpfs-ChrHcCVV.js} +3 -3
  33. package/dist/assets/{fileBytesOpfs-p_CANncD.js.map → fileBytesOpfs-ChrHcCVV.js.map} +1 -1
  34. package/dist/assets/{groupFiles-Dw0BA5-Z.js → groupFiles-Cr4Gj9-R.js} +49 -16
  35. package/dist/assets/groupFiles-Cr4Gj9-R.js.map +1 -0
  36. package/dist/assets/{host-BjTfNkxj.js → host-D0MIWyOe.js} +47 -129
  37. package/dist/assets/host-D0MIWyOe.js.map +1 -0
  38. package/dist/assets/{hyperdhtRelay-CmqjYDch.js → hyperdhtRelay-SBo4aoMk.js} +2 -2
  39. package/dist/assets/{hyperdhtRelay-CmqjYDch.js.map → hyperdhtRelay-SBo4aoMk.js.map} +1 -1
  40. package/dist/assets/{idb-CMVgtn2k.js → idb-BJARz3Qi.js} +5 -3
  41. package/dist/assets/idb-BJARz3Qi.js.map +1 -0
  42. package/dist/assets/{irohWeb-4Q4EdaCa.js → irohWeb-D2WaYPdN.js} +2 -2
  43. package/dist/assets/{irohWeb-4Q4EdaCa.js.map → irohWeb-D2WaYPdN.js.map} +1 -1
  44. package/dist/assets/{main-Dd5INTcu.js → main-DUG0nGLw.js} +279 -67
  45. package/dist/assets/main-DUG0nGLw.js.map +1 -0
  46. package/dist/assets/{mainline-o7bmeZsk.js → mainline-B8NGRodL.js} +79 -15
  47. package/dist/assets/mainline-B8NGRodL.js.map +1 -0
  48. package/dist/assets/{networkReason-ve6jyxIs.js → networkReason-BAnNO1Ji.js} +3 -3
  49. package/dist/assets/{networkReason-ve6jyxIs.js.map → networkReason-BAnNO1Ji.js.map} +1 -1
  50. package/dist/assets/{nwc-CL27LJx-.js → nwc-DQT3rx-s.js} +3 -3
  51. package/dist/assets/{nwc-CL27LJx-.js.map → nwc-DQT3rx-s.js.map} +1 -1
  52. package/dist/assets/{nwcProvider-CIlvpLT5.js → nwcProvider-Dq647EAl.js} +2 -2
  53. package/dist/assets/{nwcProvider-CIlvpLT5.js.map → nwcProvider-Dq647EAl.js.map} +1 -1
  54. package/dist/assets/{profiles-DSxPYdlU.js → profiles-BehWURA9.js} +18 -4
  55. package/dist/assets/profiles-BehWURA9.js.map +1 -0
  56. package/dist/assets/{registry-dG_Wm7fC.js → registry-DFiOxH5q.js} +1 -1
  57. package/dist/assets/{registry-CWJRfG2e.js → registry-ieI8INKT.js} +3 -3
  58. package/dist/assets/registry-ieI8INKT.js.map +1 -0
  59. package/dist/assets/{resolve-BDoQLkJR.js → resolve-C39pc4Kf.js} +2 -2
  60. package/dist/assets/{resolve-BDoQLkJR.js.map → resolve-C39pc4Kf.js.map} +1 -1
  61. package/dist/assets/{restoredRows-DeBImGRd.js → restoredRows-DGuKtIBz.js} +2 -2
  62. package/dist/assets/{restoredRows-DeBImGRd.js.map → restoredRows-DGuKtIBz.js.map} +1 -1
  63. package/dist/assets/{server-CYCzKx-R.js → server-DIICuvgy.js} +1150 -192
  64. package/dist/assets/server-DIICuvgy.js.map +1 -0
  65. package/dist/assets/{src-D1X4uVPW.js → src-CwMTZ5Hj.js} +864 -82
  66. package/dist/assets/src-CwMTZ5Hj.js.map +1 -0
  67. package/dist/assets/{usdt-Byi5OFic.js → usdt-CxSyuXq4.js} +3 -3
  68. package/dist/assets/{usdt-Byi5OFic.js.map → usdt-CxSyuXq4.js.map} +1 -1
  69. package/dist/assets/{turnRefs-BJeWWYlJ.js → words-31VaDW5h.js} +61 -3
  70. package/dist/assets/words-31VaDW5h.js.map +1 -0
  71. package/dist/ghostly.mjs +1 -1
  72. package/package.json +1 -1
  73. package/skills/ghostly/scripts/status +3 -2
  74. package/dist/assets/api-N5IiCxB7.js.map +0 -1
  75. package/dist/assets/buttons-B5dhQKnU.js +0 -2
  76. package/dist/assets/daemonProof-B53VnZ1Z.js +0 -100
  77. package/dist/assets/daemonProof-B53VnZ1Z.js.map +0 -1
  78. package/dist/assets/fileBytesIdb-DOxm_BKt.js +0 -2
  79. package/dist/assets/groupFiles-Dw0BA5-Z.js.map +0 -1
  80. package/dist/assets/host-BjTfNkxj.js.map +0 -1
  81. package/dist/assets/idb-CMVgtn2k.js.map +0 -1
  82. package/dist/assets/main-Dd5INTcu.js.map +0 -1
  83. package/dist/assets/mainline-o7bmeZsk.js.map +0 -1
  84. package/dist/assets/profiles-DSxPYdlU.js.map +0 -1
  85. package/dist/assets/registry-CWJRfG2e.js.map +0 -1
  86. package/dist/assets/server-CYCzKx-R.js.map +0 -1
  87. package/dist/assets/src-D1X4uVPW.js.map +0 -1
  88. package/dist/assets/turnRefs-BJeWWYlJ.js.map +0 -1
@@ -1,10 +1,10 @@
1
- import { Ao as signalHasVideo, Co as RTC_CONFIG, Do as callSignalHeardAt, Eo as callRtcConfig, Oo as extractParamsFromSdp, So as CALL_SIGNAL_MAX_AGE_MS, To as buildSdpFromSignal, Xr as checkPushEndpoint, Zl as fromBase64Url, bi as isPublicAddress, jl as setLinkTraceSink, ko as parseCallSignal, wo as answersOffer } from "./src-D1X4uVPW.js";
2
- import { a as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-4Q4EdaCa.js";
1
+ import { Ao as RTC_CONFIG, Hl as setLinkTraceSink, Io as extractParamsFromSdp, Lo as parseCallSignal, Mo as buildSdpFromSignal, No as callRtcConfig, Po as callSignalHeardAt, Ro as signalHasVideo, Si as isPublicAddress, Xr as checkPushEndpoint, cu as fromBase64Url, jo as answersOffer, ko as CALL_SIGNAL_MAX_AGE_MS } from "./src-CwMTZ5Hj.js";
2
+ import { a as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-D2WaYPdN.js";
3
3
  import { r as asCliError, t as CliError } from "./errors-BLSPp0tK.js";
4
- import { a as findChat } from "./apiKit-BDB40JPK.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-N5IiCxB7.js";
6
- import { n as RESTORED_MARK, r as acquireLock } from "./profiles-DSxPYdlU.js";
7
- import { i as proof, l as privateFolder, n as newDaemonSecret, s as ownFolder } from "./daemonProof-B53VnZ1Z.js";
4
+ import { a as findChat } from "./apiKit-gS-yfb25.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-ClHM_G5A.js";
6
+ import { n as RESTORED_MARK, r as acquireLock } from "./profiles-BehWURA9.js";
7
+ import { _ as ownFolder, a as proof, d as DEFAULT_RATE, f as PlaybackQueue, g as isCallRate, h as frameSamples, l as removeDaemonSecret, m as frameBytes, n as greeting, p as bytesToMs, r as newDaemonSecret, y as privateFolder } from "./daemonProof-CWTVNUmr.js";
8
8
  import { createRequire } from "node:module";
9
9
  import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
10
10
  import { readFile } from "node:fs/promises";
@@ -44,115 +44,6 @@ function announceJoins(hub, node) {
44
44
  else if (event.type === "chat.joined") say(chat);
45
45
  });
46
46
  }
47
- var CALL_RATES = [
48
- 8e3,
49
- 12e3,
50
- 16e3,
51
- 24e3,
52
- 48e3
53
- ];
54
- var DEFAULT_RATE = 48e3;
55
- var frameSamples = (rate) => rate * 20 / 1e3;
56
- var frameBytes = (rate) => frameSamples(rate) * 2;
57
- var bytesToMs = (rate, bytes) => Math.round(bytes / 2 / rate * 1e3);
58
- function isCallRate(value) {
59
- return CALL_RATES.includes(value);
60
- }
61
- /** The most a program may queue ahead of the call: five minutes of speech. What goes past it is dropped. */
62
- var MAX_QUEUE_MS = 3e5;
63
- /**
64
- * What the program wrote, waiting to be sent: taken one 20 ms frame per tick, silence when there is nothing, and
65
- * dropped whole by a flush (barge-in). The program may write any amount at any time, faster than real time too.
66
- */
67
- var PlaybackQueue = class {
68
- rate;
69
- now;
70
- chunks = [];
71
- head = 0;
72
- length = 0;
73
- lastPush = 0;
74
- frame;
75
- max;
76
- silence;
77
- /** Bytes dropped because the queue was full, since the start. */
78
- dropped = 0;
79
- constructor(rate, now = Date.now, maxMs = MAX_QUEUE_MS) {
80
- this.rate = rate;
81
- this.now = now;
82
- this.frame = frameBytes(rate);
83
- this.max = Math.floor(rate * maxMs / 1e3) * 2;
84
- this.silence = Buffer.alloc(this.frame);
85
- }
86
- /** Adds what the program wrote. Returns the bytes it could not keep (the queue was full). */
87
- push(chunk) {
88
- if (!chunk.length) return 0;
89
- this.lastPush = this.now();
90
- const room = this.max - this.length;
91
- const kept = chunk.length <= room ? chunk : chunk.subarray(0, Math.max(0, room));
92
- const lost = chunk.length - kept.length;
93
- this.dropped += lost;
94
- if (kept.length) {
95
- this.chunks.push(Buffer.from(kept));
96
- this.length += kept.length;
97
- }
98
- return lost;
99
- }
100
- /** Queued audio, in milliseconds (whole frames and a partial one). */
101
- get queuedMs() {
102
- return bytesToMs(this.rate, this.length - this.length % 2);
103
- }
104
- /** One frame to send now, and whether it is the program's audio or silence. */
105
- next() {
106
- if (this.length >= this.frame) return {
107
- frame: this.take(this.frame),
108
- silent: false
109
- };
110
- const whole = this.length - this.length % 2;
111
- if (whole > 0 && this.now() - this.lastPush >= 60) {
112
- const frame = Buffer.alloc(this.frame);
113
- this.take(whole).copy(frame);
114
- return {
115
- frame,
116
- silent: false
117
- };
118
- }
119
- return {
120
- frame: this.silence,
121
- silent: true
122
- };
123
- }
124
- /** Drops everything queued; returns how much, in milliseconds. */
125
- flush() {
126
- const ms = this.queuedMs;
127
- this.chunks = [];
128
- this.head = 0;
129
- this.length = 0;
130
- return ms;
131
- }
132
- /** Drops up to that much from the front, in whole frames (audio whose time went by); returns how much, in milliseconds. */
133
- skip(ms) {
134
- const frames = Math.min(Math.floor(ms / 20), Math.floor(this.length / this.frame));
135
- if (frames > 0) this.take(frames * this.frame);
136
- return Math.max(0, frames) * 20;
137
- }
138
- take(bytes) {
139
- const out = Buffer.allocUnsafe(bytes);
140
- let filled = 0;
141
- while (filled < bytes) {
142
- const chunk = this.chunks[0];
143
- const n = Math.min(bytes - filled, chunk.length - this.head);
144
- chunk.copy(out, filled, this.head, this.head + n);
145
- filled += n;
146
- this.head += n;
147
- if (this.head === chunk.length) {
148
- this.chunks.shift();
149
- this.head = 0;
150
- }
151
- }
152
- this.length -= bytes;
153
- return out;
154
- }
155
- };
156
47
  //#endregion
157
48
  //#region src/calls/audioSocket.ts
158
49
  /**
@@ -1729,14 +1620,11 @@ var EventHub = class {
1729
1620
  async open() {
1730
1621
  try {
1731
1622
  if (existsSync(this.journalPath)) {
1732
- const { lines, size } = journalTail(this.journalPath);
1733
- this.journalLines = lines.length;
1623
+ const { seq, lines, size } = journalEnd(this.journalPath);
1624
+ this.journalLines = lines;
1734
1625
  this.journalBytes = size;
1735
- for (let i = lines.length - 1; i >= 0; i--) try {
1736
- this.seq = JSON.parse(lines[i]).seq;
1737
- break;
1738
- } catch {}
1739
- if (size > 33554432 || lines.length > 2e4) this.trimJournal();
1626
+ this.seq = seq;
1627
+ if (size > 33554432 || lines > 2e4) this.trimJournal();
1740
1628
  }
1741
1629
  } catch (error) {
1742
1630
  process.stderr.write(`ghostly: the event journal could not be read, a new one begins: ${error instanceof Error ? error.message : String(error)}\n`);
@@ -2582,6 +2470,34 @@ function journalTail(path) {
2582
2470
  size
2583
2471
  };
2584
2472
  }
2473
+ /**
2474
+ * What opening needs of the journal: its last seq, its number of lines (as `journalTail` counts them) and its size. The
2475
+ * lines are counted by their bytes and only the last whole one is made into text.
2476
+ */
2477
+ function journalEnd(path) {
2478
+ const { bytes, start, size } = journalWindow(path);
2479
+ let lines = 0;
2480
+ for (let from = start; from < bytes.length;) {
2481
+ const end = bytes.indexOf(10, from);
2482
+ const stop = end === -1 ? bytes.length : end;
2483
+ if (stop > from) lines++;
2484
+ from = stop + 1;
2485
+ }
2486
+ let seq = 0;
2487
+ for (let stop = bytes.length; stop > start;) {
2488
+ const from = Math.max(start, bytes.lastIndexOf(10, stop - 1) + 1);
2489
+ if (from < stop) try {
2490
+ seq = JSON.parse(bytes.toString("utf8", from, stop)).seq;
2491
+ break;
2492
+ } catch {}
2493
+ stop = from - 1;
2494
+ }
2495
+ return {
2496
+ seq,
2497
+ lines,
2498
+ size
2499
+ };
2500
+ }
2585
2501
  /** The bytes of the journal's last `JOURNAL_MAX_BYTES`, `start` where its first whole line begins in them, and its size. */
2586
2502
  function journalWindow(path) {
2587
2503
  const fd = openSync(path, "r");
@@ -4755,7 +4671,7 @@ async function startRuntime(paths, options = {}) {
4755
4671
  const restored = join(paths.dir, RESTORED_MARK);
4756
4672
  if (existsSync(restored)) {
4757
4673
  try {
4758
- const rows = await import("./restoredRows-DeBImGRd.js");
4674
+ const rows = await import("./restoredRows-DGuKtIBz.js");
4759
4675
  await rows.markRestoredWallet();
4760
4676
  await rows.markLeftOutFiles(leftOutIn(restored));
4761
4677
  await store.compact();
@@ -4774,17 +4690,17 @@ async function startRuntime(paths, options = {}) {
4774
4690
  await installEventSource();
4775
4691
  await preloadWalletModules();
4776
4692
  (await import("./ghostly_iroh_web-BsAEFIjl.js")).initSync({ module: irohWasmBytes() });
4777
- const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-C2jycN_7.js"), import("./fileBytes-D6fqFQEX.js")]);
4693
+ const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-gTd_8l-P.js"), import("./fileBytes-uRqLyxa0.js")]);
4778
4694
  registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
4779
- if (await (await import("./blobFiles-B0rNnHlO.js")).moveBlobFiles()) await store.compact();
4780
- const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-CYCzKx-R.js"), import("./endpoint-Cl3cgAYl.js")]);
4695
+ if (await (await import("./blobFiles-1wUBd8ZD.js")).moveBlobFiles()) await store.compact();
4696
+ const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-DIICuvgy.js"), import("./endpoint-Cl3cgAYl.js")]);
4781
4697
  const network = hyperdhtNetwork();
4782
4698
  const dht = mainlineNetwork();
4783
- const mainline = dht.off ? null : new (await (import("./mainline-o7bmeZsk.js"))).Mainline({
4699
+ const mainline = dht.off ? null : new (await (import("./mainline-B8NGRodL.js"))).Mainline({
4784
4700
  bootstrap: dht.bootstrap,
4785
4701
  host: dht.host
4786
4702
  });
4787
- const transport = mainline || pinned ? new (await (import("./mainline-o7bmeZsk.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
4703
+ const transport = mainline || pinned ? new (await (import("./mainline-B8NGRodL.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
4788
4704
  const apps = servedApps(paths.dir).length > 0;
4789
4705
  const server = new EngineServer({
4790
4706
  ...transport ? { transport } : {},
@@ -4954,6 +4870,7 @@ async function serve(host) {
4954
4870
  return {
4955
4871
  server,
4956
4872
  close: () => closing ??= new Promise((resolve) => {
4873
+ removeDaemonSecret(ctx.runtime.paths.dir);
4957
4874
  server.close(() => resolve());
4958
4875
  for (const socket of sockets) socket.end();
4959
4876
  setTimeout(() => {
@@ -5021,6 +4938,7 @@ function connection(ctx, socket, secret) {
5021
4938
  });
5022
4939
  socket.on("close", unsubscribe);
5023
4940
  socket.on("error", () => {});
4941
+ write(greeting(secret));
5024
4942
  const lines = createInterface({
5025
4943
  input: socket,
5026
4944
  crlfDelay: Infinity
@@ -5122,4 +5040,4 @@ function connection(ctx, socket, secret) {
5122
5040
  //#endregion
5123
5041
  export { BASELINE_NEWEST, MAX_LINE, MAX_UNREAD, keepServing, openHost, serve };
5124
5042
 
5125
- //# sourceMappingURL=host-BjTfNkxj.js.map
5043
+ //# sourceMappingURL=host-D0MIWyOe.js.map