@ghostlytools/cli 1.10.0 → 1.10.1
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.
- package/README.md +9 -9
- package/SKILL.md +2 -2
- package/dist/assets/api-BOWLZYXM.js +3 -0
- package/dist/assets/{api-BF_KwecF.js → api-Bi6hCcwG.js} +27 -20
- package/dist/assets/api-Bi6hCcwG.js.map +1 -0
- package/dist/assets/{apiKit-Du1u2l4x.js → apiKit-DzXHZojD.js} +20 -3
- package/dist/assets/apiKit-DzXHZojD.js.map +1 -0
- package/dist/assets/{apps-Bti9fDoW.js → apps-0Ks6KjqS.js} +1 -1
- package/dist/assets/{apps-DwPfp54I.js → apps-DIQbzG08.js} +31 -10
- package/dist/assets/apps-DIQbzG08.js.map +1 -0
- package/dist/assets/{arkade-DOWpA2Kr.js → arkade-zozCldAE.js} +2 -2
- package/dist/assets/{arkade-DOWpA2Kr.js.map → arkade-zozCldAE.js.map} +1 -1
- package/dist/assets/{backup-DZ_Q1eSu.js → backup-BL49Kt-T.js} +6 -5
- package/dist/assets/{backup-DZ_Q1eSu.js.map → backup-BL49Kt-T.js.map} +1 -1
- package/dist/assets/{backup-CeRckyl2.js → backup-BvIFcZM7.js} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/{buttons-BxIThdg9.js → buttons-CAW5v5EE.js} +3 -3
- package/dist/assets/{buttons-BxIThdg9.js.map → buttons-CAW5v5EE.js.map} +1 -1
- package/dist/assets/buttons-oJI5mHSL.js +2 -0
- package/dist/assets/childEnv-BVOQK9EA.js +21 -0
- package/dist/assets/childEnv-BVOQK9EA.js.map +1 -0
- package/dist/assets/{client-D5E1RQYB.js → client-CyApKBEw.js} +2 -2
- package/dist/assets/{client-D5E1RQYB.js.map → client-CyApKBEw.js.map} +1 -1
- package/dist/assets/codec-DqFxxB_q.js +13 -0
- package/dist/assets/codec-DqFxxB_q.js.map +1 -0
- package/dist/assets/{envelope-CugS9qwQ.js → envelope-CMUgz31I.js} +3 -12
- package/dist/assets/envelope-CMUgz31I.js.map +1 -0
- package/dist/assets/{fixedHosts-B4E4VrYE.js → fixedHosts-C2hdCfzK.js} +4 -4
- package/dist/assets/{fixedHosts-B4E4VrYE.js.map → fixedHosts-C2hdCfzK.js.map} +1 -1
- package/dist/assets/{groupFiles-NonOYBKN.js → groupFiles-BAQIt_bJ.js} +68 -144
- package/dist/assets/groupFiles-BAQIt_bJ.js.map +1 -0
- package/dist/assets/{host-DvcVt5YI.js → host-CaRlDMTd.js} +143 -42
- package/dist/assets/host-CaRlDMTd.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-Ce42sR8x.js → hyperdhtRelay-BxADl3SG.js} +2 -2
- package/dist/assets/{hyperdhtRelay-Ce42sR8x.js.map → hyperdhtRelay-BxADl3SG.js.map} +1 -1
- package/dist/assets/{irohWeb-C9ChbD-c.js → irohWeb-D2sh6EWp.js} +10 -6
- package/dist/assets/irohWeb-D2sh6EWp.js.map +1 -0
- package/dist/assets/{main-4qE381KM.js → main-Bc4Ow56Z.js} +46 -30
- package/dist/assets/main-Bc4Ow56Z.js.map +1 -0
- package/dist/assets/{mainline-DOwZDHVy.js → mainline-DWh4Ccri.js} +2 -2
- package/dist/assets/{mainline-DOwZDHVy.js.map → mainline-DWh4Ccri.js.map} +1 -1
- package/dist/assets/networkReason-DT_D_Wpc.js +474 -0
- package/dist/assets/networkReason-DT_D_Wpc.js.map +1 -0
- package/dist/assets/{nwc-CHLWFV1R.js → nwc-DoSEhUKb.js} +3 -3
- package/dist/assets/{nwc-CHLWFV1R.js.map → nwc-DoSEhUKb.js.map} +1 -1
- package/dist/assets/{nwcProvider-BlkPOJen.js → nwcProvider-CGWqUjpB.js} +2 -2
- package/dist/assets/{nwcProvider-BlkPOJen.js.map → nwcProvider-CGWqUjpB.js.map} +1 -1
- package/dist/assets/{ownDid-yXtY_1B5.js → ownDid-CbGjRLBn.js} +2 -2
- package/dist/assets/{ownDid-yXtY_1B5.js.map → ownDid-CbGjRLBn.js.map} +1 -1
- package/dist/assets/{profiles-vbXHs0Mq.js → profiles-DgIfvBeN.js} +10 -4
- package/dist/assets/profiles-DgIfvBeN.js.map +1 -0
- package/dist/assets/{registry-chCD0KWS.js → registry-BSyxGjN6.js} +11 -9
- package/dist/assets/registry-BSyxGjN6.js.map +1 -0
- package/dist/assets/{registry-BN9r2pR4.js → registry-C5cn80Rw.js} +1 -1
- package/dist/assets/{resolve-Dtzogt2W.js → resolve-D-9YRFhl.js} +2 -2
- package/dist/assets/{resolve-Dtzogt2W.js.map → resolve-D-9YRFhl.js.map} +1 -1
- package/dist/assets/{server-BZnsm5X5.js → server-BufntkX8.js} +240 -289
- package/dist/assets/server-BufntkX8.js.map +1 -0
- package/dist/assets/{src-DZagapGt.js → src-CCt5s4DK.js} +3162 -2825
- package/dist/assets/src-CCt5s4DK.js.map +1 -0
- package/dist/assets/{sshForges-BkTgy5rx.js → sshForges-D8CPaIbR.js} +2 -2
- package/dist/assets/{sshForges-BkTgy5rx.js.map → sshForges-D8CPaIbR.js.map} +1 -1
- package/dist/assets/{translate-B9SMd6uf.js → translate-Cb-6hMhD.js} +11 -7
- package/dist/assets/{translate-B9SMd6uf.js.map → translate-Cb-6hMhD.js.map} +1 -1
- package/dist/assets/{usdt-BU4ezonh.js → usdt-ds461mzA.js} +3 -3
- package/dist/assets/{usdt-BU4ezonh.js.map → usdt-ds461mzA.js.map} +1 -1
- package/dist/assets/{words-jYy7lTcb.js → words-B1ylON2h.js} +2 -2
- package/dist/assets/{words-jYy7lTcb.js.map → words-B1ylON2h.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-BF_KwecF.js.map +0 -1
- package/dist/assets/api-DdrA86Ur.js +0 -3
- package/dist/assets/apiKit-Du1u2l4x.js.map +0 -1
- package/dist/assets/apps-DwPfp54I.js.map +0 -1
- package/dist/assets/buttons-D9QBHS9Y.js +0 -2
- package/dist/assets/envelope-CugS9qwQ.js.map +0 -1
- package/dist/assets/groupFiles-NonOYBKN.js.map +0 -1
- package/dist/assets/host-DvcVt5YI.js.map +0 -1
- package/dist/assets/irohWeb-C9ChbD-c.js.map +0 -1
- package/dist/assets/main-4qE381KM.js.map +0 -1
- package/dist/assets/networkReason-MInk1Y63.js +0 -154
- package/dist/assets/networkReason-MInk1Y63.js.map +0 -1
- package/dist/assets/profiles-vbXHs0Mq.js.map +0 -1
- package/dist/assets/registry-chCD0KWS.js.map +0 -1
- package/dist/assets/server-BZnsm5X5.js.map +0 -1
- package/dist/assets/src-DZagapGt.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as fedimintSdkOn, r as irohRelayProblem } from "./irohWeb-
|
|
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
3
|
import { r as asCliError, t as CliError } from "./errors-R4S2SAEM.js";
|
|
4
|
-
import { l as findOwnNamedChat, o as findChat } from "./apiKit-
|
|
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-
|
|
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-
|
|
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-
|
|
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";
|
|
8
8
|
import { createRequire } from "node:module";
|
|
9
|
-
import { appendFileSync, chmodSync, closeSync, existsSync, fstatSync, fsyncSync, ftruncateSync, lstatSync, mkdirSync, openSync, readFileSync, readSync, readdirSync, renameSync, rmSync, statSync, writeFileSync, writeSync } from "node:fs";
|
|
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";
|
|
11
11
|
import { dirname, join } from "node:path";
|
|
12
12
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
|
@@ -980,6 +980,10 @@ var CallManager = class {
|
|
|
980
980
|
clearing = /* @__PURE__ */ new Map();
|
|
981
981
|
/** Per chat: when this side's last call there ended before it was answered (`CALL_PACE_MS`). */
|
|
982
982
|
unansweredAt = /* @__PURE__ */ new Map();
|
|
983
|
+
/** Per chat: when the contact's last call there was missed after it barely rang, or held back (`QUICK_REDIAL_MS`). */
|
|
984
|
+
missedAt = /* @__PURE__ */ new Map();
|
|
985
|
+
/** Per chat: the contact's last call held back (`QUICK_REDIAL_MS`) until its hang-up, and when it came. */
|
|
986
|
+
held = /* @__PURE__ */ new Map();
|
|
983
987
|
/** The early answers being made, those of ended calls too (MAX_EARLY_ANSWERS). */
|
|
984
988
|
makings = /* @__PURE__ */ new Set();
|
|
985
989
|
auto;
|
|
@@ -1014,7 +1018,14 @@ var CallManager = class {
|
|
|
1014
1018
|
if (call?.state === "connected" && signal.t !== "h" && signal.t !== "v") return;
|
|
1015
1019
|
if (signal.t === "o" && !call) {
|
|
1016
1020
|
this.lastSignal.set(chat, signal.ts);
|
|
1017
|
-
this.
|
|
1021
|
+
if (this.quickRedial(chat)) {
|
|
1022
|
+
process.stderr.write(`ghostly: chat ${chat}: a call came right after a missed one that barely rang: kept as missed\n`);
|
|
1023
|
+
this.missedAt.set(chat, this.now);
|
|
1024
|
+
this.held.set(chat, {
|
|
1025
|
+
offer: signal,
|
|
1026
|
+
at: this.now
|
|
1027
|
+
});
|
|
1028
|
+
} else this.incoming(chat, signal);
|
|
1018
1029
|
} else if (signal.t === "a" && call?.direction === "out" && call.offering && answersOffer(signal, call.offerTs)) {
|
|
1019
1030
|
this.lastSignal.set(chat, signal.ts);
|
|
1020
1031
|
this.accepted(call, signal);
|
|
@@ -1024,10 +1035,12 @@ var CallManager = class {
|
|
|
1024
1035
|
if (!mine || signal.ts < mine || signal.ts === mine && (signal.f ?? "") < (call.media?.local.f ?? "")) this.yieldTo(call, signal);
|
|
1025
1036
|
} else if (signal.t === "o" && call?.direction === "in" && call.state === "connecting" && call.media && signal.ts > (call.offer?.ts ?? 0)) {
|
|
1026
1037
|
this.lastSignal.set(chat, signal.ts);
|
|
1027
|
-
this.reanswer(call, signal);
|
|
1038
|
+
if (call.reanswers < this.maxRedials) this.reanswer(call, signal);
|
|
1039
|
+
else process.stderr.write(`ghostly: call ${call.id}: the contact offered again past the last start-over: ignored\n`);
|
|
1028
1040
|
} else if (signal.t === "v") this.lastSignal.set(chat, signal.ts);
|
|
1029
1041
|
else if (signal.t === "h") {
|
|
1030
1042
|
this.lastSignal.set(chat, signal.ts);
|
|
1043
|
+
this.held.delete(chat);
|
|
1031
1044
|
if (call) {
|
|
1032
1045
|
const unreachable = signal.r === "u" && call.state !== "connected";
|
|
1033
1046
|
const failed = unreachable || call.state !== "connected" && (call.offering || call.direction === "out" && call.redials > 0);
|
|
@@ -1046,6 +1059,7 @@ var CallManager = class {
|
|
|
1046
1059
|
this.incoming(call.chat, offer);
|
|
1047
1060
|
}
|
|
1048
1061
|
incoming(chat, offer) {
|
|
1062
|
+
this.held.delete(chat);
|
|
1049
1063
|
const link = this.link(chat);
|
|
1050
1064
|
const call = this.add(chat, "in", this.auto.rate);
|
|
1051
1065
|
call.offer = offer;
|
|
@@ -1130,6 +1144,7 @@ var CallManager = class {
|
|
|
1130
1144
|
/** The contact's newer offer (its `redial`): answered on a new connection, on the call's socket. */
|
|
1131
1145
|
async reanswer(call, offer) {
|
|
1132
1146
|
process.stderr.write(`ghostly: call ${call.id}: the contact offered again: answering on a new connection\n`);
|
|
1147
|
+
call.reanswers++;
|
|
1133
1148
|
call.offer = offer;
|
|
1134
1149
|
call.video = signalHasVideo(offer);
|
|
1135
1150
|
this.arm(call, CONNECT_MS, "failed", true);
|
|
@@ -1214,6 +1229,11 @@ var CallManager = class {
|
|
|
1214
1229
|
async start(chat, options) {
|
|
1215
1230
|
const link = this.callable(chat);
|
|
1216
1231
|
if (this.byChat(link.id)) throw new CliError("busy", "A call is already on in this chat");
|
|
1232
|
+
const held = this.held.get(link.id);
|
|
1233
|
+
if (held && this.now - held.at < 6e4) {
|
|
1234
|
+
this.incoming(link.id, held.offer);
|
|
1235
|
+
throw new CliError("busy", "The contact is calling: their call rings here");
|
|
1236
|
+
}
|
|
1217
1237
|
this.paced(link.id);
|
|
1218
1238
|
const rate = rateOf(options.rate, this.auto.rate);
|
|
1219
1239
|
const stack = await this.stack();
|
|
@@ -1365,6 +1385,7 @@ var CallManager = class {
|
|
|
1365
1385
|
offerTs: 0,
|
|
1366
1386
|
offering: false,
|
|
1367
1387
|
redials: 0,
|
|
1388
|
+
reanswers: 0,
|
|
1368
1389
|
attempt: 0,
|
|
1369
1390
|
answered: 0,
|
|
1370
1391
|
answeredAt: 0,
|
|
@@ -1502,6 +1523,10 @@ var CallManager = class {
|
|
|
1502
1523
|
if (call.watcher) clearInterval(call.watcher);
|
|
1503
1524
|
this.calls.delete(call.id);
|
|
1504
1525
|
if (call.direction === "out" && call.connectedAt === null && call.state === "ringing" && (reason === "hangup" || reason === "unanswered")) this.unansweredAt.set(call.chat, this.now);
|
|
1526
|
+
if (call.direction === "in" && call.connectedAt === null && reason !== "hangup" && reason !== "stopped") {
|
|
1527
|
+
if (this.now - call.startedAt < 1e3) this.missedAt.set(call.chat, this.now);
|
|
1528
|
+
else this.missedAt.delete(call.chat);
|
|
1529
|
+
}
|
|
1505
1530
|
if (report) process.stderr.write(`ghostly: call ${call.id}: ended (${reason})${call.media ? `, ice ${call.media.ice.state}` : ""}\n`);
|
|
1506
1531
|
try {
|
|
1507
1532
|
call.media?.close();
|
|
@@ -1546,6 +1571,11 @@ var CallManager = class {
|
|
|
1546
1571
|
}
|
|
1547
1572
|
throw new CliError("busy", `Your last call in this chat ended unanswered a moment ago: call again in ${Math.ceil(left / 100) / 10} s`, { retryAfterMs: left });
|
|
1548
1573
|
}
|
|
1574
|
+
/** Whether the contact's call coming now in the chat is held back: its last one was missed after it barely rang, or held, a moment ago. */
|
|
1575
|
+
quickRedial(chat) {
|
|
1576
|
+
const quick = this.host.quickRedialMs ?? 2e3, last = this.missedAt.get(chat);
|
|
1577
|
+
return !!quick && last !== void 0 && this.now - last < quick;
|
|
1578
|
+
}
|
|
1549
1579
|
arm(call, ms, reason, tell) {
|
|
1550
1580
|
this.disarm(call);
|
|
1551
1581
|
call.timer = setTimeout(() => void this.end(call, reason, tell), ms);
|
|
@@ -1711,6 +1741,8 @@ var EventHub = class {
|
|
|
1711
1741
|
dropped = 0;
|
|
1712
1742
|
/** Whether `<journal>.dropped` is written: before `forget` first takes a journal's first events, it must be. */
|
|
1713
1743
|
marked = false;
|
|
1744
|
+
/** Whether `dropped` is ahead of `<journal>.dropped` (a full disk refused it): the next event's write tries it again. */
|
|
1745
|
+
markOwed = false;
|
|
1714
1746
|
journalLines = 0;
|
|
1715
1747
|
journalBytes = 0;
|
|
1716
1748
|
listeners = /* @__PURE__ */ new Set();
|
|
@@ -1752,13 +1784,29 @@ var EventHub = class {
|
|
|
1752
1784
|
try {
|
|
1753
1785
|
const dropped = readDropped(this.journalPath + ".dropped");
|
|
1754
1786
|
if (existsSync(this.journalPath)) {
|
|
1755
|
-
const { seq, first, lines, size } = journalEnd(this.journalPath);
|
|
1787
|
+
const { seq, first, lines, size, tail } = journalEnd(this.journalPath);
|
|
1756
1788
|
this.journalLines = lines;
|
|
1757
1789
|
this.journalBytes = size;
|
|
1758
1790
|
this.seq = seq;
|
|
1759
1791
|
this.dropped = dropped ?? (first === void 0 ? seq : first - 1);
|
|
1760
1792
|
this.marked = dropped !== void 0;
|
|
1761
|
-
|
|
1793
|
+
let ended = false;
|
|
1794
|
+
if (tail?.whole) try {
|
|
1795
|
+
appendFileSync(this.journalPath, "\n");
|
|
1796
|
+
this.journalBytes++;
|
|
1797
|
+
ended = true;
|
|
1798
|
+
} catch {}
|
|
1799
|
+
if (tail && !ended) {
|
|
1800
|
+
truncateSync(this.journalPath, tail.at);
|
|
1801
|
+
this.journalLines--;
|
|
1802
|
+
this.journalBytes = tail.at;
|
|
1803
|
+
const lost = tail.whole ? seq : tail.seq !== void 0 && tail.seq > seq ? tail.seq : void 0;
|
|
1804
|
+
if (lost !== void 0) {
|
|
1805
|
+
this.seq = lost;
|
|
1806
|
+
this.markDropped(Math.max(this.dropped, lost));
|
|
1807
|
+
}
|
|
1808
|
+
}
|
|
1809
|
+
if (this.journalBytes > 33554432 || this.journalLines > 2e4) this.trimJournal();
|
|
1762
1810
|
} else if (dropped !== void 0) rmSync(this.journalPath + ".dropped", { force: true });
|
|
1763
1811
|
} catch (error) {
|
|
1764
1812
|
process.stderr.write(`ghostly: the event journal could not be read, a new one begins: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
@@ -1889,24 +1937,37 @@ var EventHub = class {
|
|
|
1889
1937
|
return () => this.appListeners.delete(listener);
|
|
1890
1938
|
}
|
|
1891
1939
|
/**
|
|
1892
|
-
* Events after `since` still in the journal; a gap event
|
|
1893
|
-
* what the person removed (`forget`) are no gap: they are not here on
|
|
1940
|
+
* Events after `since` still in the journal; a gap event where ones up to `dropped` are missing (a trim, a full disk
|
|
1941
|
+
* that took none of them). The events of what the person removed (`forget`) after it are no gap: they are not here on
|
|
1942
|
+
* purpose.
|
|
1894
1943
|
*/
|
|
1895
1944
|
replay(since) {
|
|
1896
|
-
if (
|
|
1945
|
+
if (since >= this.seq) return [];
|
|
1897
1946
|
const out = [];
|
|
1898
|
-
|
|
1899
|
-
|
|
1900
|
-
if (
|
|
1901
|
-
|
|
1902
|
-
|
|
1903
|
-
|
|
1904
|
-
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
1908
|
-
|
|
1909
|
-
|
|
1947
|
+
let before = since;
|
|
1948
|
+
const gapTo = (next) => {
|
|
1949
|
+
if (next > before + 1 && before < this.dropped) out.push({
|
|
1950
|
+
seq: before,
|
|
1951
|
+
id: `events.gap:${before}:${next}`,
|
|
1952
|
+
type: "events.gap",
|
|
1953
|
+
at: this.now(),
|
|
1954
|
+
from: before + 1,
|
|
1955
|
+
to: Math.min(this.dropped, next - 1)
|
|
1956
|
+
});
|
|
1957
|
+
};
|
|
1958
|
+
if (existsSync(this.journalPath)) for (const line of journalTail(this.journalPath).lines) {
|
|
1959
|
+
let event;
|
|
1960
|
+
try {
|
|
1961
|
+
event = JSON.parse(line);
|
|
1962
|
+
} catch {
|
|
1963
|
+
continue;
|
|
1964
|
+
}
|
|
1965
|
+
if (event.seq <= before) continue;
|
|
1966
|
+
gapTo(event.seq);
|
|
1967
|
+
out.push(event);
|
|
1968
|
+
before = event.seq;
|
|
1969
|
+
}
|
|
1970
|
+
gapTo(Math.min(this.dropped, this.seq) + 1);
|
|
1910
1971
|
return out;
|
|
1911
1972
|
}
|
|
1912
1973
|
/**
|
|
@@ -1916,9 +1977,12 @@ var EventHub = class {
|
|
|
1916
1977
|
markDropped(seq) {
|
|
1917
1978
|
this.dropped = seq;
|
|
1918
1979
|
try {
|
|
1919
|
-
writeFileSync(this.journalPath + ".dropped", String(seq), { mode: 384 });
|
|
1980
|
+
writeFileSync(this.journalPath + ".dropped.tmp", String(seq), { mode: 384 });
|
|
1981
|
+
renameSync(this.journalPath + ".dropped.tmp", this.journalPath + ".dropped");
|
|
1920
1982
|
this.marked = true;
|
|
1983
|
+
this.markOwed = false;
|
|
1921
1984
|
} catch (error) {
|
|
1985
|
+
this.markOwed = true;
|
|
1922
1986
|
process.stderr.write(`ghostly: event journal error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
1923
1987
|
}
|
|
1924
1988
|
}
|
|
@@ -1934,13 +1998,17 @@ var EventHub = class {
|
|
|
1934
1998
|
at: this.now(),
|
|
1935
1999
|
...fields
|
|
1936
2000
|
};
|
|
2001
|
+
let written = false;
|
|
1937
2002
|
try {
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
this.
|
|
2003
|
+
if (this.markOwed) this.markDropped(this.dropped);
|
|
2004
|
+
const line = Buffer.from(JSON.stringify(event) + "\n");
|
|
2005
|
+
appendWhole(this.journalPath, line);
|
|
2006
|
+
written = true;
|
|
2007
|
+
this.journalBytes += line.length;
|
|
1941
2008
|
if (++this.journalLines > 2e4 || this.journalBytes > 33554432) this.trimJournal();
|
|
1942
2009
|
} catch (error) {
|
|
1943
2010
|
process.stderr.write(`ghostly: event journal error: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
2011
|
+
if (!written) this.markDropped(Math.max(this.dropped, event.seq));
|
|
1944
2012
|
}
|
|
1945
2013
|
this.tell(event);
|
|
1946
2014
|
return event;
|
|
@@ -2453,22 +2521,23 @@ var EventHub = class {
|
|
|
2453
2521
|
}
|
|
2454
2522
|
/**
|
|
2455
2523
|
* A press on a button of a message of mine (WISP 406 · Message Buttons), after the reply's own event: the question
|
|
2456
|
-
* (`messageId`), the button, its label, who pressed (`by`: the chat, or a group member's key), `name` (the
|
|
2457
|
-
*
|
|
2458
|
-
*
|
|
2459
|
-
*
|
|
2524
|
+
* (`messageId`), the button, its label, who pressed (`by`: the chat, or a group member's key), `name` (the label this
|
|
2525
|
+
* profile gave the chat, as `chat list` gives it; null without one, and in a group) and the reply (`replyId`).
|
|
2526
|
+
* `untrusted.name` is the name the person gave themselves, as an agent turn's: theirs to choose, so data, never
|
|
2527
|
+
* instructions, and under `untrusted` only. The engine marks a reply a press only while the buttons were open for
|
|
2528
|
+
* that person.
|
|
2460
2529
|
*/
|
|
2461
2530
|
pressed(chat, group, message, json) {
|
|
2462
2531
|
const press = message.press;
|
|
2463
2532
|
const link = group ? void 0 : this.state?.links.find((l) => l.id === chat);
|
|
2464
|
-
const name =
|
|
2533
|
+
const name = link ? chatJson(link).label : null;
|
|
2465
2534
|
this.emit("button.pressed", `button.pressed:${group ?? chat}:${message.id}`, {
|
|
2466
2535
|
...group ? { group } : { chat },
|
|
2467
2536
|
messageId: press.messageId,
|
|
2468
2537
|
button: press.button,
|
|
2469
2538
|
label: press.label,
|
|
2470
2539
|
by: group ? message.member ?? null : chat,
|
|
2471
|
-
name
|
|
2540
|
+
name,
|
|
2472
2541
|
replyId: message.id,
|
|
2473
2542
|
...press.inferred ? { inferred: true } : {},
|
|
2474
2543
|
untrusted: { name: json.nick ?? null }
|
|
@@ -2646,20 +2715,32 @@ function journalEnd(path) {
|
|
|
2646
2715
|
if (stop > from) first = firstSeq([bytes.toString("utf8", from, stop)]);
|
|
2647
2716
|
from = stop + 1;
|
|
2648
2717
|
}
|
|
2649
|
-
let seq = 0;
|
|
2718
|
+
let seq = 0, read = -1;
|
|
2650
2719
|
for (let stop = bytes.length; stop > start;) {
|
|
2651
2720
|
const from = Math.max(start, bytes.lastIndexOf(10, stop - 1) + 1);
|
|
2652
2721
|
if (from < stop) try {
|
|
2653
2722
|
seq = JSON.parse(bytes.toString("utf8", from, stop)).seq;
|
|
2723
|
+
read = from;
|
|
2654
2724
|
break;
|
|
2655
2725
|
} catch {}
|
|
2656
2726
|
stop = from - 1;
|
|
2657
2727
|
}
|
|
2728
|
+
let tail;
|
|
2729
|
+
if (bytes.length > start && bytes[bytes.length - 1] !== 10) {
|
|
2730
|
+
const from = Math.max(start, bytes.lastIndexOf(10) + 1);
|
|
2731
|
+
const named = /^\{"seq":(\d+)[,}]/.exec(bytes.toString("latin1", from, Math.min(bytes.length, from + 32)))?.[1];
|
|
2732
|
+
tail = {
|
|
2733
|
+
at: size - bytes.length + from,
|
|
2734
|
+
whole: read === from,
|
|
2735
|
+
seq: named === void 0 ? void 0 : Number(named)
|
|
2736
|
+
};
|
|
2737
|
+
}
|
|
2658
2738
|
return {
|
|
2659
2739
|
seq,
|
|
2660
2740
|
first,
|
|
2661
2741
|
lines,
|
|
2662
|
-
size
|
|
2742
|
+
size,
|
|
2743
|
+
tail
|
|
2663
2744
|
};
|
|
2664
2745
|
}
|
|
2665
2746
|
/** The seq of the first of these lines that can be read. */
|
|
@@ -2678,6 +2759,25 @@ function readDropped(path) {
|
|
|
2678
2759
|
return;
|
|
2679
2760
|
}
|
|
2680
2761
|
}
|
|
2762
|
+
/**
|
|
2763
|
+
* Appends a line whole or not at all: what a full disk took of it is cut back (as the store's journal does), so the
|
|
2764
|
+
* next line, once there is room, starts a line of its own instead of making one no reader can parse with it.
|
|
2765
|
+
*/
|
|
2766
|
+
function appendWhole(path, line) {
|
|
2767
|
+
const fd = openSync(path, "a", 384);
|
|
2768
|
+
let whole = -1;
|
|
2769
|
+
try {
|
|
2770
|
+
whole = fstatSync(fd).size;
|
|
2771
|
+
for (let at = 0; at < line.length;) at += writeSync(fd, line, at);
|
|
2772
|
+
} catch (error) {
|
|
2773
|
+
if (whole >= 0) try {
|
|
2774
|
+
ftruncateSync(fd, whole);
|
|
2775
|
+
} catch {}
|
|
2776
|
+
throw error;
|
|
2777
|
+
} finally {
|
|
2778
|
+
closeSync(fd);
|
|
2779
|
+
}
|
|
2780
|
+
}
|
|
2681
2781
|
/** The bytes of the journal's last `JOURNAL_MAX_BYTES`, `start` where its first whole line begins in them, and its size. */
|
|
2682
2782
|
function journalWindow(path) {
|
|
2683
2783
|
const fd = openSync(path, "r");
|
|
@@ -5016,12 +5116,12 @@ async function startRuntime(paths, options = {}) {
|
|
|
5016
5116
|
const [{ registerFileBytes }, { NodeFileBytes }] = await Promise.all([import("./fileBytes-DMzrIdCu.js"), import("./fileBytes-Douk1yOp.js")]);
|
|
5017
5117
|
registerFileBytes("native", async () => new NodeFileBytes(paths.files), true);
|
|
5018
5118
|
if (await (await import("./blobFiles-BnjN_Vrz.js")).moveBlobFiles()) await store.compact();
|
|
5019
|
-
const [{ EngineServer }, { createHyperEndpoint }] = await Promise.all([import("./server-
|
|
5020
|
-
const mainline = dht.off ? null : new (await (import("./mainline-
|
|
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({
|
|
5021
5121
|
bootstrap: dht.bootstrap,
|
|
5022
5122
|
host: dht.host
|
|
5023
5123
|
});
|
|
5024
|
-
const transport = mainline || pinned ? new (await (import("./mainline-
|
|
5124
|
+
const transport = mainline || pinned ? new (await (import("./mainline-DWh4Ccri.js"))).RelaysAndDht(mainline, pinned ? { relays: pinned } : {}, !!pinned) : null;
|
|
5025
5125
|
const apps = servedApps(paths.dir).length > 0;
|
|
5026
5126
|
const server = new EngineServer({
|
|
5027
5127
|
...transport ? { transport } : {},
|
|
@@ -5034,6 +5134,7 @@ async function startRuntime(paths, options = {}) {
|
|
|
5034
5134
|
servicesSupport: true,
|
|
5035
5135
|
apps: apps ? "wire" : false,
|
|
5036
5136
|
staysOnline: envSwitch("GHOSTLY_HUB", true),
|
|
5137
|
+
watchPeerIdleMs: DAEMON_WATCH_PEER_IDLE_MS,
|
|
5037
5138
|
localFetch: nodeLocalFetch,
|
|
5038
5139
|
pushSend: (request) => nodePushSend(request),
|
|
5039
5140
|
holdFetch: nodeHoldFetch(),
|
|
@@ -5380,4 +5481,4 @@ function connection(ctx, socket, secret) {
|
|
|
5380
5481
|
//#endregion
|
|
5381
5482
|
export { BASELINE_NEWEST, MAX_UNREAD, keepServing, openHost, serve };
|
|
5382
5483
|
|
|
5383
|
-
//# sourceMappingURL=host-
|
|
5484
|
+
//# sourceMappingURL=host-CaRlDMTd.js.map
|