@ghostlytools/cli 1.12.1 → 1.13.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.
- package/README.md +1 -1
- package/dist/assets/{api-jRUXnBdX.js → api-CVtg7MpI.js} +2 -2
- package/dist/assets/{api-BwEgbvvK.js → api-CjOaoG-v.js} +16 -16
- package/dist/assets/api-CjOaoG-v.js.map +1 -0
- package/dist/assets/{apiKit-BlsNk-Cx.js → apiKit-BAGvlQtm.js} +2 -2
- package/dist/assets/{apiKit-BlsNk-Cx.js.map → apiKit-BAGvlQtm.js.map} +1 -1
- package/dist/assets/{appFetch-CW9fJPHh.js → appFetch-BwJd-kNq.js} +2 -2
- package/dist/assets/{appFetch-CW9fJPHh.js.map → appFetch-BwJd-kNq.js.map} +1 -1
- package/dist/assets/{apps-CL8TXHhu.js → apps-Cuk45sz5.js} +5 -5
- package/dist/assets/{apps-CL8TXHhu.js.map → apps-Cuk45sz5.js.map} +1 -1
- package/dist/assets/{apps-BcG4u6SM.js → apps-DjY095Af.js} +1 -1
- package/dist/assets/{backup-xZfV-ytw.js → backup-B56sQqoQ.js} +1 -1
- package/dist/assets/{backup-BA41EDvh.js → backup-DekVCDWv.js} +3 -3
- package/dist/assets/{backup-BA41EDvh.js.map → backup-DekVCDWv.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-CcafsJla.js.map +1 -1
- package/dist/assets/{bitcoind-Dh7n9amb.js → bitcoind-B2bbVSzh.js} +2 -2
- package/dist/assets/{bitcoind-Dh7n9amb.js.map → bitcoind-B2bbVSzh.js.map} +1 -1
- package/dist/assets/bitcoindevkit_bg-BWQHx7vd.js.map +1 -1
- package/dist/assets/{buttons-SH1tNRh7.js → buttons-BGxzOtrq.js} +26 -5
- package/dist/assets/buttons-BGxzOtrq.js.map +1 -0
- package/dist/assets/buttons-CsN2WJOf.js +1 -0
- package/dist/assets/{client-DGS-atRu.js → client-DcQAfc3h.js} +2 -2
- package/dist/assets/{client-DGS-atRu.js.map → client-DcQAfc3h.js.map} +1 -1
- package/dist/assets/{fixedHosts-CPSsGOI2.js → fixedHosts-C3hBliM9.js} +2 -2
- package/dist/assets/{fixedHosts-CPSsGOI2.js.map → fixedHosts-C3hBliM9.js.map} +1 -1
- package/dist/assets/{groupMeta-DxuJzko_.js → groupMeta-goASqzOt.js} +94 -17
- package/dist/assets/{groupMeta-DxuJzko_.js.map → groupMeta-goASqzOt.js.map} +1 -1
- package/dist/assets/{host-BxM-HMr0.js → host-C2WRKj3g.js} +52 -32
- package/dist/assets/host-C2WRKj3g.js.map +1 -0
- package/dist/assets/{irohWeb-CbnGtUo6.js → irohWeb-NfthOL98.js} +6 -6
- package/dist/assets/{irohWeb-CbnGtUo6.js.map → irohWeb-NfthOL98.js.map} +1 -1
- package/dist/assets/{main-CwTaepxR.js → main-Dh7fePd8.js} +19 -19
- package/dist/assets/main-Dh7fePd8.js.map +1 -0
- package/dist/assets/{mainline-CVrd0C1n.js → mainline-DY95WbuK.js} +2 -2
- package/dist/assets/{mainline-CVrd0C1n.js.map → mainline-DY95WbuK.js.map} +1 -1
- package/dist/assets/{ownDid-DY3rYqDI.js → ownDid-BErplN7N.js} +2 -2
- package/dist/assets/{ownDid-DY3rYqDI.js.map → ownDid-BErplN7N.js.map} +1 -1
- package/dist/assets/{ownStatus-DtzIllg2.js → ownStatus-ClrFjd7h.js} +4 -3
- package/dist/assets/ownStatus-ClrFjd7h.js.map +1 -0
- package/dist/assets/{profiles-BOYGlmu2.js → profiles-B8xO8-oj.js} +2 -2
- package/dist/assets/{profiles-BOYGlmu2.js.map → profiles-B8xO8-oj.js.map} +1 -1
- package/dist/assets/{registry-4W1LGlCF.js → registry--Rg2YvOH.js} +1 -1
- package/dist/assets/{registry-Bep4umOM.js → registry-CU8PevhI.js} +3 -3
- package/dist/assets/{registry-Bep4umOM.js.map → registry-CU8PevhI.js.map} +1 -1
- package/dist/assets/{relay-Cjfmdec0.js → relay-CHWg5hpZ.js} +73 -11
- package/dist/assets/relay-CHWg5hpZ.js.map +1 -0
- package/dist/assets/{resolve-CIc3KZMV.js → resolve-B1upovPM.js} +2 -2
- package/dist/assets/{resolve-CIc3KZMV.js.map → resolve-B1upovPM.js.map} +1 -1
- package/dist/assets/{server-D4gf-LnD.js → server-Dgxx_DaN.js} +221 -22
- package/dist/assets/server-Dgxx_DaN.js.map +1 -0
- package/dist/assets/{waitNotice-DQvZgz2T.js → waitNotice-ylU3XwjO.js} +2 -2
- package/dist/assets/{waitNotice-DQvZgz2T.js.map → waitNotice-ylU3XwjO.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
- package/dist/assets/api-BwEgbvvK.js.map +0 -1
- package/dist/assets/buttons-CsGdQNnR.js +0 -1
- package/dist/assets/buttons-SH1tNRh7.js.map +0 -1
- package/dist/assets/host-BxM-HMr0.js.map +0 -1
- package/dist/assets/main-CwTaepxR.js.map +0 -1
- package/dist/assets/ownStatus-DtzIllg2.js.map +0 -1
- package/dist/assets/relay-Cjfmdec0.js.map +0 -1
- package/dist/assets/server-D4gf-LnD.js.map +0 -1
|
@@ -561,6 +561,13 @@ var READ_STARVED_MS = 6e4;
|
|
|
561
561
|
/** How long a read that let an older one go first waits before it asks again. */
|
|
562
562
|
var TURN_WAIT_MS = 1e3;
|
|
563
563
|
/**
|
|
564
|
+
* A background read the budget held back far down the turns asks again no later than this (`backgroundTurnIn`). The
|
|
565
|
+
* requests past the background share go to a read held back long (`READ_STARVED_MS`) that is there when one frees: asked
|
|
566
|
+
* only at its estimated turn, a web app with 200 chats away read each contact every 7 to 8 minutes, not every 6, and
|
|
567
|
+
* one with 100 left half the writes' share unused at 20 s.
|
|
568
|
+
*/
|
|
569
|
+
var BACKGROUND_TURN_MAX_MS = 15e3;
|
|
570
|
+
/**
|
|
564
571
|
* Once a group's read found a relay's minute full, the groups' reads there are spread over the minute for a minute
|
|
565
572
|
* (`GROUP_RATION_MS`): at most a sixth of it in any 10 s (5 on a relay of 30), the key read longest ago first. A sliding
|
|
566
573
|
* minute that demand keeps full hands out its requests in bursts: the minute is spent in 25 to 35 s as requests age
|
|
@@ -579,6 +586,12 @@ var SIGNALING_WINDOW_MS = 1e4;
|
|
|
579
586
|
/** A relay that missed a key's newest packet gets it (`catchUpLater`) no sooner than this, and tries again this often. */
|
|
580
587
|
var CATCH_UP_MIN_MS = 1e3;
|
|
581
588
|
var CATCH_UP_RETRY_MS = 5e3;
|
|
589
|
+
/**
|
|
590
|
+
* The longest another background write is told to wait behind the packets queued for a relay (`catchUpLater`): the
|
|
591
|
+
* link and the DHT floor try again within a minute anyway, and longer kept a chat's upkeep off a relay with a long queue
|
|
592
|
+
* for most of the presence window.
|
|
593
|
+
*/
|
|
594
|
+
var CATCH_UP_BEHIND_MAX_MS = 6e4;
|
|
582
595
|
/** A catch-up put waits behind every link's request: a background write. A group edge's offer or answer goes as its own (`putEverywhere`). */
|
|
583
596
|
var CATCH_UP_ASKER = {
|
|
584
597
|
background: true,
|
|
@@ -818,6 +831,8 @@ var RelayTransport = class {
|
|
|
818
831
|
lastPut = /* @__PURE__ */ new Map();
|
|
819
832
|
/** Per relay and key, the newest packet that relay held back for its budget while another relay took it (`catchUpLater`). */
|
|
820
833
|
catchUp = /* @__PURE__ */ new Map();
|
|
834
|
+
/** Per relay, how many packets wait in `catchUp` for it: background reads leave them their share (`heldFor`). */
|
|
835
|
+
catchUpWaiting = /* @__PURE__ */ new Map();
|
|
821
836
|
catchUpTimer = null;
|
|
822
837
|
/**
|
|
823
838
|
* Per key whose reads the budget held back since its last read went out: when a request frees for it
|
|
@@ -1194,7 +1209,6 @@ var RelayTransport = class {
|
|
|
1194
1209
|
putEverywhere(pubKeyZ32, payload, timestamp, options, conflict) {
|
|
1195
1210
|
this.readAt.delete(pubKeyZ32);
|
|
1196
1211
|
this.missing.delete(pubKeyZ32);
|
|
1197
|
-
for (const relay of this.relays) this.catchUp.delete(`${relay} ${pubKeyZ32}`);
|
|
1198
1212
|
const waitingBefore = new Map(this.writeWaiting);
|
|
1199
1213
|
const writer = firstWriter(asker(options, true));
|
|
1200
1214
|
const noWriteWaits = () => {
|
|
@@ -1226,8 +1240,10 @@ var RelayTransport = class {
|
|
|
1226
1240
|
} catch (error) {
|
|
1227
1241
|
if (!isDiscoveryBudgetError(error) && !(error instanceof RelayLeftAloneError)) failed.add(relay);
|
|
1228
1242
|
nowhere[i] = isDiscoveryBudgetError(error) || error instanceof RelayLeftAloneError || error instanceof RelayNoAnswerError && !error.sent;
|
|
1243
|
+
if (this.catchUp.has(slot) && isDiscoveryBudgetError(error)) this.catchUpLater(relay, pubKeyZ32, payload, timestamp, asker(options, true));
|
|
1229
1244
|
throw error;
|
|
1230
1245
|
}
|
|
1246
|
+
if (response.ok && (this.catchUp.get(slot)?.timestamp ?? 0n) <= timestamp) this.dropCatchUp(relay, pubKeyZ32);
|
|
1231
1247
|
nowhere[i] = response.status >= 400 && response.status < 500;
|
|
1232
1248
|
if (response.status >= 500 || response.status === 428) failed.add(relay);
|
|
1233
1249
|
if (response.status === 409) conflict?.(relay);
|
|
@@ -1419,6 +1435,7 @@ var RelayTransport = class {
|
|
|
1419
1435
|
}
|
|
1420
1436
|
const resting = this.relays.every((r) => this.isCoolingDown(r, "GET") || this.breaker.blockedFor(r) > 0 || this.heldFor(r, who, Date.now(), pubKeyZ32) > 0);
|
|
1421
1437
|
const known = down ? this.newest.get(pubKeyZ32) : newerPacket(this.newest.get(pubKeyZ32), this.written.get(pubKeyZ32));
|
|
1438
|
+
if (!down && budgetWait < Infinity) budgetWait = Math.max(budgetWait, this.backgroundTurnIn(pubKeyZ32, who, Date.now()));
|
|
1422
1439
|
if (resting && known) {
|
|
1423
1440
|
if (down && !keptOnFailure) throw new RelaysFailedError(known);
|
|
1424
1441
|
if (!down && budgetWait < Infinity) this.heldBackUntil(pubKeyZ32, Date.now() + budgetWait);
|
|
@@ -1554,7 +1571,8 @@ var RelayTransport = class {
|
|
|
1554
1571
|
/**
|
|
1555
1572
|
* A relay whose budget (this client's, or its own rate limit) held a packet back that another relay took: it gets
|
|
1556
1573
|
* that packet when it frees a request, as a background write (`who`: a group edge's offer or answer as its own, also
|
|
1557
|
-
* after that relay failed it). Only the newest per key and relay
|
|
1574
|
+
* after that relay failed it). Only the newest per key and relay, until that relay takes this packet or a newer one (one
|
|
1575
|
+
* the budget holds there takes its place). Without this,
|
|
1558
1576
|
* that relay kept the key's older packet for good, and an app that restarted and read it first found a contact's offer
|
|
1559
1577
|
* long answered, answered it again, and waited on it (bug hunt r7a).
|
|
1560
1578
|
*/
|
|
@@ -1563,7 +1581,7 @@ var RelayTransport = class {
|
|
|
1563
1581
|
if ((this.lastPut.get(slot) ?? 0n) > timestamp) return;
|
|
1564
1582
|
const pending = this.catchUp.get(slot);
|
|
1565
1583
|
if (pending && pending.timestamp >= timestamp) return;
|
|
1566
|
-
this.
|
|
1584
|
+
this.keepCatchUp(slot, {
|
|
1567
1585
|
relay,
|
|
1568
1586
|
key,
|
|
1569
1587
|
payload,
|
|
@@ -1572,6 +1590,16 @@ var RelayTransport = class {
|
|
|
1572
1590
|
});
|
|
1573
1591
|
this.scheduleCatchUp(CATCH_UP_MIN_MS);
|
|
1574
1592
|
}
|
|
1593
|
+
keepCatchUp(slot, item) {
|
|
1594
|
+
if (!this.catchUp.has(slot)) this.catchUpWaiting.set(item.relay, (this.catchUpWaiting.get(item.relay) ?? 0) + 1);
|
|
1595
|
+
this.catchUp.set(slot, item);
|
|
1596
|
+
}
|
|
1597
|
+
dropCatchUp(relay, key) {
|
|
1598
|
+
if (!this.catchUp.delete(`${relay} ${key}`)) return;
|
|
1599
|
+
const left = (this.catchUpWaiting.get(relay) ?? 1) - 1;
|
|
1600
|
+
if (left > 0) this.catchUpWaiting.set(relay, left);
|
|
1601
|
+
else this.catchUpWaiting.delete(relay);
|
|
1602
|
+
}
|
|
1575
1603
|
scheduleCatchUp(inMs) {
|
|
1576
1604
|
if (this.catchUpTimer || this.catchUp.size === 0) return;
|
|
1577
1605
|
this.catchUpTimer = setTimeout(() => {
|
|
@@ -1584,21 +1612,25 @@ var RelayTransport = class {
|
|
|
1584
1612
|
for (const [slot, item] of [...this.catchUp]) {
|
|
1585
1613
|
if (this.catchUp.get(slot) !== item) continue;
|
|
1586
1614
|
const coolingDown = (this.networkCooldown.get(`PUT ${item.relay}`) ?? 0) - Date.now();
|
|
1587
|
-
const
|
|
1615
|
+
const who = {
|
|
1616
|
+
...item.who,
|
|
1617
|
+
catchUp: true
|
|
1618
|
+
};
|
|
1619
|
+
const wait = Math.max(this.heldFor(item.relay, who), this.rateLimitedFor(item.relay), this.breaker.blockedFor(item.relay), coolingDown);
|
|
1588
1620
|
if (wait > 0) {
|
|
1589
1621
|
next = Math.min(next, wait);
|
|
1590
1622
|
continue;
|
|
1591
1623
|
}
|
|
1592
|
-
this.
|
|
1624
|
+
this.dropCatchUp(item.relay, item.key);
|
|
1593
1625
|
try {
|
|
1594
|
-
const response = await this.put(item.relay, item.key, item.payload, void 0,
|
|
1626
|
+
const response = await this.put(item.relay, item.key, item.payload, void 0, who);
|
|
1595
1627
|
if ((response.status === 428 || response.status === 429) && !this.catchUp.has(slot)) {
|
|
1596
|
-
this.
|
|
1628
|
+
this.keepCatchUp(slot, item);
|
|
1597
1629
|
next = Math.min(next, CATCH_UP_RETRY_MS);
|
|
1598
1630
|
}
|
|
1599
1631
|
} catch (error) {
|
|
1600
1632
|
if (isDiscoveryBudgetError(error) && !this.catchUp.has(slot)) {
|
|
1601
|
-
this.
|
|
1633
|
+
this.keepCatchUp(slot, item);
|
|
1602
1634
|
next = Math.min(next, error.retryInMs);
|
|
1603
1635
|
}
|
|
1604
1636
|
}
|
|
@@ -1754,10 +1786,17 @@ var RelayTransport = class {
|
|
|
1754
1786
|
const groupOver = within(this.spentGroupOver.get(relay) ?? [], now, GROUP_OVER_PACE_MS);
|
|
1755
1787
|
this.spentGroupOver.set(relay, groupOver);
|
|
1756
1788
|
if (isGroupSignal(who) && !who.write && recent.length >= limit && groupOver.length > 0) wait = Math.max(wait, groupOver[groupOver.length - 1] + GROUP_OVER_PACE_MS - now);
|
|
1789
|
+
const backgroundShare = Math.min(this.backgroundPerMinute, Math.ceil(limit * 2 / 3));
|
|
1790
|
+
const writesShare = Math.max(1, Math.floor(backgroundShare * BACKGROUND_WRITES_SHARE));
|
|
1791
|
+
const caughtUp = this.catchUpWaiting.get(relay) ?? 0;
|
|
1792
|
+
if (who.background && !who.write && caughtUp) {
|
|
1793
|
+
const writesLeft = writesShare - recentBackgroundWrites.length;
|
|
1794
|
+
if (writesLeft > 0) wait = Math.max(wait, over(recent, Math.max(1, limit - writesLeft)), over(recentBackground, Math.max(1, backgroundShare - writesLeft)));
|
|
1795
|
+
}
|
|
1796
|
+
if (who.background && who.write && !who.catchUp && caughtUp) wait = Math.max(wait, Math.min(CATCH_UP_BEHIND_MAX_MS, Math.ceil(caughtUp * 6e4 / writesShare)));
|
|
1757
1797
|
if (who.background && !starved) {
|
|
1758
|
-
const backgroundShare = Math.min(this.backgroundPerMinute, Math.ceil(limit * 2 / 3));
|
|
1759
1798
|
wait = Math.max(wait, over(recentBackground, backgroundShare));
|
|
1760
|
-
if (who.write) wait = Math.max(wait, over(recentBackgroundWrites,
|
|
1799
|
+
if (who.write) wait = Math.max(wait, over(recentBackgroundWrites, writesShare));
|
|
1761
1800
|
const signaling = this.urgentAt + SIGNALING_WINDOW_MS - now;
|
|
1762
1801
|
if (signaling > 0 && !who.door) wait = Math.max(wait, Math.min(signaling, over(recentBackground, Math.min(this.backgroundWhileSignaling, Math.ceil(limit / 6)))));
|
|
1763
1802
|
}
|
|
@@ -1921,6 +1960,29 @@ var RelayTransport = class {
|
|
|
1921
1960
|
}
|
|
1922
1961
|
return false;
|
|
1923
1962
|
}
|
|
1963
|
+
/**
|
|
1964
|
+
* How long until a background read of `key` the budget held back is likely to have its turn: the background reads of
|
|
1965
|
+
* keys ahead of it in turn (read longer ago, still asking; `turnAhead`), one after the other at the relays' background
|
|
1966
|
+
* share. Told only when the budget frees the next request, every held key asked again then, and lost it to the key
|
|
1967
|
+
* whose turn it was: a daemon whose 50 contacts were away asked about 600 times a minute for some 50 reads, and one
|
|
1968
|
+
* with 200 three times as often after four hours as after 15 minutes (bug hunts, 2026-11-06 and 2026-11-14).
|
|
1969
|
+
*/
|
|
1970
|
+
backgroundTurnIn(key, who, now) {
|
|
1971
|
+
if (!who.background || !isTurnRead(who)) return 0;
|
|
1972
|
+
const mine = this.keyTurns.get(key);
|
|
1973
|
+
if (!mine) return 0;
|
|
1974
|
+
const since = (k) => this.heldBack.get(k)?.since ?? now;
|
|
1975
|
+
const mineSince = since(key);
|
|
1976
|
+
let ahead = 0, read = 0;
|
|
1977
|
+
for (const [other, turn] of this.keyTurns) {
|
|
1978
|
+
if (other !== key && turn.who.background && now - turn.servedAt < 6e4) read++;
|
|
1979
|
+
if (other === key || !turn.waiting || !turn.who.background || staleTurn(turn, now)) continue;
|
|
1980
|
+
if (turn.servedAt < mine.servedAt || turn.servedAt === mine.servedAt && (since(other) < mineSince || since(other) === mineSince && other < key)) ahead++;
|
|
1981
|
+
}
|
|
1982
|
+
if (ahead === 0) return 0;
|
|
1983
|
+
const perMinute = this.relays.reduce((sum, relay) => sum + Math.min(this.backgroundPerMinute, Math.ceil(this.limitOf(relay) * 2 / 3)), 0);
|
|
1984
|
+
return Math.min(BACKGROUND_TURN_MAX_MS, Math.ceil(ahead * 6e4 / Math.max(1, perMinute, read)));
|
|
1985
|
+
}
|
|
1924
1986
|
/** A 1:1 chat's read of `key` the budget has held back for `READ_STARVED_MS` without a break. */
|
|
1925
1987
|
starved(key, who, now) {
|
|
1926
1988
|
const since = this.heldBack.get(key)?.since;
|
|
@@ -2216,4 +2278,4 @@ async function readRelayBody(response, signal, max = RELAY_PAYLOAD_MAX_BYTES) {
|
|
|
2216
2278
|
}
|
|
2217
2279
|
export { RelaysFailedError as a, normalizeRelayUrl as c, traceLink as d, DiscoveryBudgetError as f, withRequestOptions as g, publishedNowhere as h, RelayTransport as i, relayUrlProblem as l, isDiscoveryBudgetError as m, HEDGE_MISSING_MS as n, SLOW_MS as o, budgetRetryMs as p, HEDGE_MS as r, currentRelays as s, DEFAULT_RELAYS as t, setLinkTraceSink as u };
|
|
2218
2280
|
|
|
2219
|
-
//# sourceMappingURL=relay-
|
|
2281
|
+
//# sourceMappingURL=relay-CHWg5hpZ.js.map
|