@ghostlytools/cli 1.5.2 → 1.5.4
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 +18 -13
- package/dist/assets/{api-CHD8_kcJ.js → api-ButrHieZ.js} +2 -2
- package/dist/assets/{api-CMohP9Pw.js → api-DDmune9b.js} +352 -120
- package/dist/assets/api-DDmune9b.js.map +1 -0
- package/dist/assets/{apiKit-CfwVtBcw.js → apiKit-DfFlJhXO.js} +4 -4
- package/dist/assets/apiKit-DfFlJhXO.js.map +1 -0
- package/dist/assets/{apps-733nXRBy.js → apps-BVnNpB2f.js} +1 -1
- package/dist/assets/{apps-LG-QOIxs.js → apps-CpQVuYqT.js} +17 -16
- package/dist/assets/apps-CpQVuYqT.js.map +1 -0
- package/dist/assets/{arkade-C8x3Efyj.js → arkade-C9Ne-zJb.js} +12 -5
- package/dist/assets/arkade-C9Ne-zJb.js.map +1 -0
- package/dist/assets/{backup-nCbNWJ7-.js → backup-DavZrUf6.js} +1 -1
- package/dist/assets/{backup-CfJenOQo.js → backup-MN2sZQeW.js} +11 -8
- package/dist/assets/backup-MN2sZQeW.js.map +1 -0
- 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/{blobFiles-1wUBd8ZD.js → blobFiles-B6nf0gCG.js} +3 -3
- package/dist/assets/{blobFiles-1wUBd8ZD.js.map → blobFiles-B6nf0gCG.js.map} +1 -1
- package/dist/assets/buttons-DC20Q2no.js +2 -0
- package/dist/assets/{buttons-BC0stvPg.js → buttons-DIWDW2n5.js} +23 -6
- package/dist/assets/buttons-DIWDW2n5.js.map +1 -0
- package/dist/assets/{daemonProof-CWTVNUmr.js → daemonProof-ui8jtIw0.js} +19 -37
- package/dist/assets/daemonProof-ui8jtIw0.js.map +1 -0
- package/dist/assets/{endpoint-Cl3cgAYl.js → endpoint-BdaeBw2L.js} +3 -3
- package/dist/assets/endpoint-BdaeBw2L.js.map +1 -0
- package/dist/assets/{envelope-BbvUBjc5.js → envelope-ByeUit1N.js} +2 -2
- package/dist/assets/{envelope-BbvUBjc5.js.map → envelope-ByeUit1N.js.map} +1 -1
- package/dist/assets/{errors-BLSPp0tK.js → errors-CzXgR8Cc.js} +39 -4
- package/dist/assets/errors-CzXgR8Cc.js.map +1 -0
- package/dist/assets/{fileBytes-B8eTZfAT.js → fileBytes-BMEBas7S.js} +3 -3
- package/dist/assets/{fileBytes-B8eTZfAT.js.map → fileBytes-BMEBas7S.js.map} +1 -1
- package/dist/assets/{fileBytes-uRqLyxa0.js → fileBytes-CFNrRfcl.js} +2 -2
- package/dist/assets/{fileBytes-uRqLyxa0.js.map → fileBytes-CFNrRfcl.js.map} +1 -1
- package/dist/assets/{fileBytes-gTd_8l-P.js → fileBytes-CtwagJ8h.js} +1 -1
- package/dist/assets/{fileBytesIdb-BIFKtgln.js → fileBytesIdb-BXAN7i-N.js} +7 -7
- package/dist/assets/fileBytesIdb-BXAN7i-N.js.map +1 -0
- package/dist/assets/fileBytesIdb-C20oXDdr.js +2 -0
- package/dist/assets/{fileBytesOpfs-ChrHcCVV.js → fileBytesOpfs-Do1Vpkis.js} +3 -3
- package/dist/assets/{fileBytesOpfs-ChrHcCVV.js.map → fileBytesOpfs-Do1Vpkis.js.map} +1 -1
- package/dist/assets/{ghostly_iroh_web-BsAEFIjl.js → ghostly_iroh_web-BXCsSxxo.js} +29 -29
- package/dist/assets/{ghostly_iroh_web-BsAEFIjl.js.map → ghostly_iroh_web-BXCsSxxo.js.map} +1 -1
- package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
- package/dist/assets/{groupFiles-Bmo-SkVQ.js → groupFiles-DVxX0O1g.js} +61 -17
- package/dist/assets/groupFiles-DVxX0O1g.js.map +1 -0
- package/dist/assets/{host-DxDRCRKD.js → host-AB2Cr46b.js} +127 -48
- package/dist/assets/host-AB2Cr46b.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-CZfsPfT9.js → hyperdhtRelay-BcrwJRtb.js} +2 -2
- package/dist/assets/{hyperdhtRelay-CZfsPfT9.js.map → hyperdhtRelay-BcrwJRtb.js.map} +1 -1
- package/dist/assets/{idb-BJARz3Qi.js → idb-BlH8-O3R.js} +35 -5
- package/dist/assets/idb-BlH8-O3R.js.map +1 -0
- package/dist/assets/{irohWeb-BUvaADop.js → irohWeb-B5j2rgWj.js} +3 -3
- package/dist/assets/{irohWeb-BUvaADop.js.map → irohWeb-B5j2rgWj.js.map} +1 -1
- package/dist/assets/{main-BIXIs84L.js → main-AHz1dbsm.js} +227 -62
- package/dist/assets/main-AHz1dbsm.js.map +1 -0
- package/dist/assets/{mainline-HQVJ5ukA.js → mainline-afyQ77bv.js} +46 -16
- package/dist/assets/mainline-afyQ77bv.js.map +1 -0
- package/dist/assets/{networkReason-CKBiFTwt.js → networkReason-DWzsMN8E.js} +3 -3
- package/dist/assets/{networkReason-CKBiFTwt.js.map → networkReason-DWzsMN8E.js.map} +1 -1
- package/dist/assets/{nwc-Dm4RSvvF.js → nwc-DYXTp8UX.js} +3 -3
- package/dist/assets/{nwc-Dm4RSvvF.js.map → nwc-DYXTp8UX.js.map} +1 -1
- package/dist/assets/{nwcProvider-yQdL-DfC.js → nwcProvider-B4k6mYJl.js} +2 -2
- package/dist/assets/{nwcProvider-yQdL-DfC.js.map → nwcProvider-B4k6mYJl.js.map} +1 -1
- package/dist/assets/{profiles-BehWURA9.js → profiles-CEnZfN78.js} +74 -13
- package/dist/assets/profiles-CEnZfN78.js.map +1 -0
- package/dist/assets/{registry-CHVZ0Jzl.js → registry-Ccru6KBP.js} +1 -1
- package/dist/assets/{registry-C9f2Ogff.js → registry-wSZHgbsv.js} +3 -3
- package/dist/assets/{registry-C9f2Ogff.js.map → registry-wSZHgbsv.js.map} +1 -1
- package/dist/assets/{resolve-Cqj1jjK2.js → resolve-BPJnMtLC.js} +2 -2
- package/dist/assets/{resolve-Cqj1jjK2.js.map → resolve-BPJnMtLC.js.map} +1 -1
- package/dist/assets/{restoredRows-DGuKtIBz.js → restoredRows-Fv-MuY45.js} +2 -2
- package/dist/assets/{restoredRows-DGuKtIBz.js.map → restoredRows-Fv-MuY45.js.map} +1 -1
- package/dist/assets/{server-CcAs54Yb.js → server-DPzt5V2x.js} +993 -283
- package/dist/assets/server-DPzt5V2x.js.map +1 -0
- package/dist/assets/{src-BLHey3Q1.js → src-CFeRBeHz.js} +518 -134
- package/dist/assets/src-CFeRBeHz.js.map +1 -0
- package/dist/assets/{usdt-DMKpMhdM.js → usdt-CBh78JVF.js} +3 -3
- package/dist/assets/{usdt-DMKpMhdM.js.map → usdt-CBh78JVF.js.map} +1 -1
- package/dist/assets/{words-DUlvkoUT.js → words-DC8BQvPO.js} +4 -4
- package/dist/assets/words-DC8BQvPO.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/examples/payment-bot.mjs +5 -2
- package/package.json +1 -1
- package/dist/assets/api-CMohP9Pw.js.map +0 -1
- package/dist/assets/apiKit-CfwVtBcw.js.map +0 -1
- package/dist/assets/apps-LG-QOIxs.js.map +0 -1
- package/dist/assets/arkade-C8x3Efyj.js.map +0 -1
- package/dist/assets/backup-CfJenOQo.js.map +0 -1
- package/dist/assets/buttons-BC0stvPg.js.map +0 -1
- package/dist/assets/buttons-BDKeKyKw.js +0 -2
- package/dist/assets/daemonProof-CWTVNUmr.js.map +0 -1
- package/dist/assets/endpoint-Cl3cgAYl.js.map +0 -1
- package/dist/assets/errors-BLSPp0tK.js.map +0 -1
- package/dist/assets/fileBytesIdb-BIFKtgln.js.map +0 -1
- package/dist/assets/fileBytesIdb-BVVr_rWX.js +0 -2
- package/dist/assets/groupFiles-Bmo-SkVQ.js.map +0 -1
- package/dist/assets/host-DxDRCRKD.js.map +0 -1
- package/dist/assets/idb-BJARz3Qi.js.map +0 -1
- package/dist/assets/main-BIXIs84L.js.map +0 -1
- package/dist/assets/mainline-HQVJ5ukA.js.map +0 -1
- package/dist/assets/profiles-BehWURA9.js.map +0 -1
- package/dist/assets/server-CcAs54Yb.js.map +0 -1
- package/dist/assets/src-BLHey3Q1.js.map +0 -1
- package/dist/assets/words-DUlvkoUT.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-
|
|
3
|
-
import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-
|
|
4
|
-
import { t as CONTACT_KEY } from "./apiKit-
|
|
5
|
-
import { a as checkShownName, c as ghostlyHome, f as profileExists, h as userPath, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner } from "./profiles-
|
|
6
|
-
import {
|
|
7
|
-
import { accessSync, constants, existsSync, openSync, readFileSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
1
|
+
import { Ga as ITEM_STATES, Ja as ROUTINE_STATES, Ka as PR_CHECKS, Wa as CRON_LINE, Wn as GROUP_FILE_LIMITS, Xa as STATUS_CARD_LIMITS, Ya as RUN_RESULTS, Za as TASK_STATUSES, da as VOICE_LIMITS, eo as cardLine, qa as PR_STATES, to as cardUrl } from "./src-CFeRBeHz.js";
|
|
2
|
+
import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, r as PAY_METHODS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-DC8BQvPO.js";
|
|
3
|
+
import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-CzXgR8Cc.js";
|
|
4
|
+
import { t as CONTACT_KEY } from "./apiKit-DfFlJhXO.js";
|
|
5
|
+
import { _ as ownSocket, a as checkShownName, c as ghostlyHome, f as profileExists, h as userPath, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner } from "./profiles-CEnZfN78.js";
|
|
6
|
+
import { _ as isCallRate, a as newNonce, c as provesGreeting, d as CALL_RATES, l as readDaemonSecret, n as daemonOfThisRelease, s as provesDaemon, t as HELLO } from "./daemonProof-ui8jtIw0.js";
|
|
7
|
+
import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
8
8
|
import { dirname, resolve } from "node:path";
|
|
9
9
|
import { spawn } from "node:child_process";
|
|
10
10
|
import { connect } from "node:net";
|
|
@@ -12,7 +12,7 @@ import { createInterface } from "node:readline";
|
|
|
12
12
|
import { format } from "node:util";
|
|
13
13
|
var package_default = {
|
|
14
14
|
name: "@ghostlytools/cli",
|
|
15
|
-
version: "1.5.
|
|
15
|
+
version: "1.5.4",
|
|
16
16
|
type: "module",
|
|
17
17
|
description: "Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.",
|
|
18
18
|
license: "MIT",
|
|
@@ -239,10 +239,13 @@ function liftGlobals(argv) {
|
|
|
239
239
|
/** The id of the hello on every connection: a string, so it is never one of the calls' numbers. */
|
|
240
240
|
var HELLO_ID = "hello";
|
|
241
241
|
/**
|
|
242
|
-
* How long a client waits for the daemon's greeting before it
|
|
243
|
-
* connection, and one of an older release (before the greeting) never does.
|
|
242
|
+
* How long a client waits for the daemon's greeting before it asks who holds the profile: a daemon greets as it
|
|
243
|
+
* accepts the connection, and one of an older release (before the greeting) never does. A daemon of this release
|
|
244
|
+
* holding the profile (`daemonOfThisRelease`) is busy and is waited for, under each call's own deadline; anything
|
|
245
|
+
* else is refused then. It used to refuse every late greeting, after 10 s: a daemon busy that long on one task (an
|
|
246
|
+
* outbox backlog, 14 to 29 s) had every command and `listen` refused as an older release's, to be restarted.
|
|
244
247
|
*/
|
|
245
|
-
var GREETING_MS =
|
|
248
|
+
var GREETING_MS = 2e3;
|
|
246
249
|
/** The refusal of a listener that did not prove it is the profile's daemon (`isNotTheDaemon` tells it apart). */
|
|
247
250
|
function notTheDaemon(socket) {
|
|
248
251
|
return new CliError("refused", `What answers on ${socket} did not prove it is this profile's daemon, so nothing was sent to it. A daemon of an older release cannot: \`ghostly daemon restart\` starts this one's`, { reason: "not-the-daemon" });
|
|
@@ -287,7 +290,7 @@ var DaemonClient = class {
|
|
|
287
290
|
this.ready.catch(() => {});
|
|
288
291
|
const nonce = newNonce();
|
|
289
292
|
const waitedTooLong = setTimeout(() => {
|
|
290
|
-
if (!this.greeted && !this.refusal) this.refuse();
|
|
293
|
+
if (!this.greeted && !this.refusal && !daemonOfThisRelease(this.address.dir)) this.refuse();
|
|
291
294
|
}, greetingMs);
|
|
292
295
|
waitedTooLong.unref?.();
|
|
293
296
|
const lines = createInterface({
|
|
@@ -300,6 +303,7 @@ var DaemonClient = class {
|
|
|
300
303
|
try {
|
|
301
304
|
message = JSON.parse(line);
|
|
302
305
|
} catch {
|
|
306
|
+
if (!this.greeted && !this.refusal) this.refuse();
|
|
303
307
|
return;
|
|
304
308
|
}
|
|
305
309
|
if (this.refusal) return;
|
|
@@ -1092,7 +1096,7 @@ var commands$8 = {
|
|
|
1092
1096
|
description: "Replace the three files when they are there"
|
|
1093
1097
|
}
|
|
1094
1098
|
},
|
|
1095
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1099
|
+
run: async ({ options }, a) => (await import("./apps-BVnNpB2f.js")).initApp(a.dir, {
|
|
1096
1100
|
name: options.name,
|
|
1097
1101
|
title: options.title,
|
|
1098
1102
|
force: options.force === true
|
|
@@ -1132,7 +1136,7 @@ var commands$8 = {
|
|
|
1132
1136
|
description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
|
|
1133
1137
|
}
|
|
1134
1138
|
},
|
|
1135
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1139
|
+
run: async ({ options }, a) => (await import("./apps-BVnNpB2f.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
|
|
1136
1140
|
},
|
|
1137
1141
|
"app revoke": {
|
|
1138
1142
|
method: "app.revoke",
|
|
@@ -1165,7 +1169,7 @@ var commands$8 = {
|
|
|
1165
1169
|
description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
|
|
1166
1170
|
}
|
|
1167
1171
|
},
|
|
1168
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1172
|
+
run: async ({ options }, a) => (await import("./apps-BVnNpB2f.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>]"), {
|
|
1169
1173
|
digests: options.digest,
|
|
1170
1174
|
upTo: options["up-to"],
|
|
1171
1175
|
reason: options.reason,
|
|
@@ -1226,7 +1230,7 @@ var commands$8 = {
|
|
|
1226
1230
|
usage: "app verify <bundle|url>",
|
|
1227
1231
|
summary: "Check a .ghostlyapp as a client would, from a file or an https URL: its manifest and digest, or refused (exit 1) with the reason, revoked when the ghostly-revoke.json beside it revokes this version",
|
|
1228
1232
|
args: ["bundle"],
|
|
1229
|
-
run: async (_, a) => (await import("./apps-
|
|
1233
|
+
run: async (_, a) => (await import("./apps-BVnNpB2f.js")).verifyApp(a.bundle)
|
|
1230
1234
|
},
|
|
1231
1235
|
"store sign": {
|
|
1232
1236
|
method: "store.sign",
|
|
@@ -1243,7 +1247,7 @@ var commands$8 = {
|
|
|
1243
1247
|
description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
|
|
1244
1248
|
}
|
|
1245
1249
|
},
|
|
1246
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1250
|
+
run: async ({ options }, a) => (await import("./apps-BVnNpB2f.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
|
|
1247
1251
|
}
|
|
1248
1252
|
};
|
|
1249
1253
|
//#endregion
|
|
@@ -1278,7 +1282,7 @@ var commands$7 = {
|
|
|
1278
1282
|
options: {
|
|
1279
1283
|
from: {
|
|
1280
1284
|
type: "list",
|
|
1281
|
-
description: "Only calls from this chat (again for more)"
|
|
1285
|
+
description: "Only calls from this chat: its id, its contact's key or a label given here with chat rename (again for more)"
|
|
1282
1286
|
},
|
|
1283
1287
|
rate
|
|
1284
1288
|
},
|
|
@@ -1863,6 +1867,26 @@ var commands$6 = {
|
|
|
1863
1867
|
};
|
|
1864
1868
|
//#endregion
|
|
1865
1869
|
//#region src/commands/files.ts
|
|
1870
|
+
/**
|
|
1871
|
+
* `--voice [ms]` and `--peaks`: a length and a waveform a voice note takes, or a usage error (exit 2) that names the flag
|
|
1872
|
+
* before the profile opens. Before, the API answered them once it had opened ("voice must be a number from 1 to
|
|
1873
|
+
* 9007199254740991", or one sentence for every case), and `--peaks` without `--voice` was dropped without a word.
|
|
1874
|
+
*/
|
|
1875
|
+
function voiceOf(options) {
|
|
1876
|
+
const { voice, peaks } = options;
|
|
1877
|
+
if (typeof voice === "number" && !(Number.isInteger(voice) && voice >= 1 && voice <= VOICE_LIMITS.maxDurationMs)) throw new CliError("usage", `--voice takes a length in milliseconds from 1 to ${VOICE_LIMITS.maxDurationMs} (${VOICE_LIMITS.maxDurationMs / 6e4} minutes), not ${voice}`);
|
|
1878
|
+
if (typeof peaks !== "string") return {
|
|
1879
|
+
voice,
|
|
1880
|
+
peaks: void 0
|
|
1881
|
+
};
|
|
1882
|
+
if (voice === void 0) throw new CliError("usage", "--peaks is a voice note's waveform: not without --voice");
|
|
1883
|
+
const bars = peaks.split(",");
|
|
1884
|
+
if (bars.length > VOICE_LIMITS.maxBars || !bars.every((bar) => /^\d{1,3}$/.test(bar.trim()) && Number(bar) <= 255)) throw new CliError("usage", `--peaks takes up to ${VOICE_LIMITS.maxBars} numbers from 0 to 255, comma-separated, not ${JSON.stringify(peaks)}`);
|
|
1885
|
+
return {
|
|
1886
|
+
voice,
|
|
1887
|
+
peaks: bars
|
|
1888
|
+
};
|
|
1889
|
+
}
|
|
1866
1890
|
/** Files: one entry per command, in alphabetical order (test/commands.test.ts checks). */
|
|
1867
1891
|
var commands$5 = {
|
|
1868
1892
|
"file accept": {
|
|
@@ -2022,8 +2046,7 @@ var commands$5 = {
|
|
|
2022
2046
|
path: here(a.path),
|
|
2023
2047
|
name: options.name,
|
|
2024
2048
|
mime: options.mime,
|
|
2025
|
-
|
|
2026
|
-
peaks: typeof options.peaks === "string" ? options.peaks.split(",") : void 0,
|
|
2049
|
+
...voiceOf(options),
|
|
2027
2050
|
reply: options.reply
|
|
2028
2051
|
})
|
|
2029
2052
|
},
|
|
@@ -2590,6 +2613,7 @@ var commands$1 = {
|
|
|
2590
2613
|
memo,
|
|
2591
2614
|
method: {
|
|
2592
2615
|
type: "string",
|
|
2616
|
+
choices: PAY_METHODS,
|
|
2593
2617
|
description: "cashu, arkade, usdt, bitcoin, spark, …"
|
|
2594
2618
|
},
|
|
2595
2619
|
rail: {
|
|
@@ -2637,7 +2661,7 @@ var commands$1 = {
|
|
|
2637
2661
|
},
|
|
2638
2662
|
"pay": {
|
|
2639
2663
|
method: "pay",
|
|
2640
|
-
usage: "pay <invoice|lightning-address|lnurl> [--amount sats] [--network n] [--max-fee sats] [--card <id>] [--comment t] [--confirm-real]",
|
|
2664
|
+
usage: "pay <invoice|lightning-address|lnurl> [--amount sats] [--network n] [--max-fee sats] [--card <id>] [--comment t] [--confirm-real] [--force]",
|
|
2641
2665
|
summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real",
|
|
2642
2666
|
args: ["target"],
|
|
2643
2667
|
options: {
|
|
@@ -2655,7 +2679,8 @@ var commands$1 = {
|
|
|
2655
2679
|
type: "string",
|
|
2656
2680
|
description: "For the address's owner"
|
|
2657
2681
|
},
|
|
2658
|
-
"confirm-real": confirmReal
|
|
2682
|
+
"confirm-real": confirmReal,
|
|
2683
|
+
force
|
|
2659
2684
|
},
|
|
2660
2685
|
params: ({ options }, { target }) => ({
|
|
2661
2686
|
target,
|
|
@@ -2664,7 +2689,8 @@ var commands$1 = {
|
|
|
2664
2689
|
maxFee: options["max-fee"],
|
|
2665
2690
|
card: options.card,
|
|
2666
2691
|
comment: options.comment,
|
|
2667
|
-
confirmReal: options["confirm-real"] === true
|
|
2692
|
+
confirmReal: options["confirm-real"] === true,
|
|
2693
|
+
force: options.force === true
|
|
2668
2694
|
})
|
|
2669
2695
|
},
|
|
2670
2696
|
"payment check": {
|
|
@@ -3135,6 +3161,14 @@ function noMoreThan(count, values, usage) {
|
|
|
3135
3161
|
}
|
|
3136
3162
|
//#endregion
|
|
3137
3163
|
//#region src/listen.ts
|
|
3164
|
+
/** The cursor's own write failed, not the event's handling. */
|
|
3165
|
+
var CursorError = class extends Error {
|
|
3166
|
+
error;
|
|
3167
|
+
constructor(error) {
|
|
3168
|
+
super(error instanceof Error ? error.message : String(error));
|
|
3169
|
+
this.error = error;
|
|
3170
|
+
}
|
|
3171
|
+
};
|
|
3138
3172
|
/**
|
|
3139
3173
|
* Who `listen` passes on, checked before any hook or output: chats by id (a contact key is matched to its chat as
|
|
3140
3174
|
* events come, so a chat made after the start counts too), groups by id. An event of a chat or group not on it is
|
|
@@ -3241,6 +3275,7 @@ function checkWebhook(url) {
|
|
|
3241
3275
|
"localhost",
|
|
3242
3276
|
"[::1]"
|
|
3243
3277
|
].includes(parsed.hostname)) throw new CliError("usage", "The webhook must be on this machine (127.0.0.1, localhost or [::1])");
|
|
3278
|
+
if (parsed.username || parsed.password) throw new CliError("usage", "The webhook URL takes no user or password: put the bridge's token in its path or query");
|
|
3244
3279
|
return parsed;
|
|
3245
3280
|
}
|
|
3246
3281
|
function readCursor(path) {
|
|
@@ -3446,13 +3481,22 @@ function eventHandler(options) {
|
|
|
3446
3481
|
const webhook = options.webhook ? checkWebhook(options.webhook) : null;
|
|
3447
3482
|
let chain = Promise.resolve();
|
|
3448
3483
|
let behind = 0;
|
|
3484
|
+
let stopped = false;
|
|
3485
|
+
const keep = (seq) => {
|
|
3486
|
+
if (!options.cursor) return;
|
|
3487
|
+
try {
|
|
3488
|
+
writeCursor(options.cursor, seq);
|
|
3489
|
+
} catch (error) {
|
|
3490
|
+
throw new CursorError(error);
|
|
3491
|
+
}
|
|
3492
|
+
};
|
|
3449
3493
|
const handle = (event) => {
|
|
3450
3494
|
const seq = event.seq, type = event.type;
|
|
3495
|
+
if (stopped) return;
|
|
3451
3496
|
behind++;
|
|
3452
3497
|
chain = chain.then(async () => {
|
|
3453
|
-
|
|
3454
|
-
|
|
3455
|
-
};
|
|
3498
|
+
if (stopped) return;
|
|
3499
|
+
const skip = () => keep(event.seq);
|
|
3456
3500
|
if (!matches(event, options.types)) return skip();
|
|
3457
3501
|
if (options.allow && !await options.allow.allows(event)) return skip();
|
|
3458
3502
|
if (options.turns) {
|
|
@@ -3468,12 +3512,18 @@ function eventHandler(options) {
|
|
|
3468
3512
|
const answered = webhook ? await post(webhook, event, options.retryMs ?? 500) : true;
|
|
3469
3513
|
if (webhook && answered !== true) process.stderr.write(`ghostly: the webhook at ${webhook.href} answered ${answered}: event ${event.seq} (${event.type}) passed, not taken (a 4xx or a redirect is not tried again)\n`);
|
|
3470
3514
|
if (full) await options.drained?.();
|
|
3471
|
-
|
|
3515
|
+
keep(event.seq);
|
|
3472
3516
|
}).catch((error) => {
|
|
3473
3517
|
try {
|
|
3474
|
-
|
|
3475
|
-
|
|
3476
|
-
|
|
3518
|
+
if (!(error instanceof CursorError)) {
|
|
3519
|
+
process.stderr.write(`ghostly: event ${seq} (${type}) failed: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
3520
|
+
keep(seq);
|
|
3521
|
+
} else throw error;
|
|
3522
|
+
} catch (failed) {
|
|
3523
|
+
if (!(failed instanceof CursorError) || !options.cursorFailed) return;
|
|
3524
|
+
stopped = true;
|
|
3525
|
+
options.cursorFailed(failed.error);
|
|
3526
|
+
}
|
|
3477
3527
|
}).finally(() => {
|
|
3478
3528
|
behind--;
|
|
3479
3529
|
});
|
|
@@ -3530,9 +3580,11 @@ var PAUSE_HOLD_MS = 6e4;
|
|
|
3530
3580
|
* does, so the daemon does not keep a replay and what came live for it while it hangs; resume opens it again after the
|
|
3531
3581
|
* last event taken.
|
|
3532
3582
|
* `subscribed`: the first subscription's answer (a journal that cannot be replayed rejects it).
|
|
3583
|
+
* `profile`: a daemon gone longer than a restart takes (`daemon stop`) is said once on stderr, and so is the one that
|
|
3584
|
+
* answers again: the listen waits for it, it does not go silent.
|
|
3533
3585
|
*/
|
|
3534
|
-
function followDaemon(address, client, handle, since, holdMs = PAUSE_HOLD_MS) {
|
|
3535
|
-
let current = client;
|
|
3586
|
+
function followDaemon(address, client, handle, since, holdMs = PAUSE_HOLD_MS, profile) {
|
|
3587
|
+
let current = client, missedSince = 0, missing = false;
|
|
3536
3588
|
let holding;
|
|
3537
3589
|
const reconnect = (wait) => void (async () => {
|
|
3538
3590
|
while (!current && !feed.paused) {
|
|
@@ -3541,10 +3593,20 @@ function followDaemon(address, client, handle, since, holdMs = PAUSE_HOLD_MS) {
|
|
|
3541
3593
|
if (current || feed.paused) return;
|
|
3542
3594
|
const next = await connectDaemon(address, 1e3);
|
|
3543
3595
|
if (next) {
|
|
3596
|
+
missedSince = 0;
|
|
3597
|
+
if (missing) {
|
|
3598
|
+
missing = false;
|
|
3599
|
+
process.stderr.write(`ghostly: the daemon of profile ${profile} answers again\n`);
|
|
3600
|
+
}
|
|
3544
3601
|
current = next;
|
|
3545
3602
|
await follow(next).catch(() => {
|
|
3546
3603
|
if (current === next) current = null;
|
|
3547
3604
|
});
|
|
3605
|
+
} else if (profile === void 0) continue;
|
|
3606
|
+
else if (!missedSince) missedSince = Date.now();
|
|
3607
|
+
else if (!missing && Date.now() - missedSince >= 3e3) {
|
|
3608
|
+
missing = true;
|
|
3609
|
+
process.stderr.write(`ghostly: the daemon of profile ${profile} stopped; waiting for it to start again (ghostly daemon --detach)\n`);
|
|
3548
3610
|
}
|
|
3549
3611
|
}
|
|
3550
3612
|
})();
|
|
@@ -3703,8 +3765,8 @@ var VERSION = package_default.version;
|
|
|
3703
3765
|
* command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
|
|
3704
3766
|
* cost every command ~100 ms before its socket was opened.
|
|
3705
3767
|
*/
|
|
3706
|
-
var engineApi = () => import("./api-
|
|
3707
|
-
var engineHost = () => import("./host-
|
|
3768
|
+
var engineApi = () => import("./api-ButrHieZ.js");
|
|
3769
|
+
var engineHost = () => import("./host-AB2Cr46b.js");
|
|
3708
3770
|
var pretty = false;
|
|
3709
3771
|
function print(value) {
|
|
3710
3772
|
process.stdout.write(JSON.stringify(value, null, pretty ? 2 : void 0) + "\n");
|
|
@@ -3752,11 +3814,24 @@ function versionWarning(daemon, cli) {
|
|
|
3752
3814
|
* Never fails, and has no deadline of its own: a daemon that does not answer is the command's own call to find out,
|
|
3753
3815
|
* at the command's deadline, which closes the connection and ends this check with it. A deadline here ended every
|
|
3754
3816
|
* command on a wedged daemon at 15 s with `unavailable` ("The daemon went away"), whatever its own `--timeout` said.
|
|
3817
|
+
* A command with no deadline of its own waits for this check instead (15 s, session()), before it is sent.
|
|
3755
3818
|
*/
|
|
3756
3819
|
async function warnVersion(client) {
|
|
3757
3820
|
const warning = versionWarning((await client.call("status").catch(() => null))?.version, VERSION);
|
|
3758
3821
|
if (warning) process.stderr.write(warning + "\n");
|
|
3759
3822
|
}
|
|
3823
|
+
/** Whether `promise` settles within `ms` (the timer keeps no process alive). */
|
|
3824
|
+
function settlesWithin(promise, ms) {
|
|
3825
|
+
return new Promise((resolve) => {
|
|
3826
|
+
const timer = setTimeout(() => resolve(false), ms);
|
|
3827
|
+
timer.unref?.();
|
|
3828
|
+
const settled = () => {
|
|
3829
|
+
clearTimeout(timer);
|
|
3830
|
+
resolve(true);
|
|
3831
|
+
};
|
|
3832
|
+
promise.then(settled, settled);
|
|
3833
|
+
});
|
|
3834
|
+
}
|
|
3760
3835
|
/**
|
|
3761
3836
|
* A command about one 1:1 chat: a one-shot for it leaves the groups' sessions unstarted. A fresh process starts an edge
|
|
3762
3837
|
* per group member, and their first polls spent the relays' 30 requests a minute in seconds: the chat's message then
|
|
@@ -3836,7 +3911,7 @@ function offlineCall(method, params) {
|
|
|
3836
3911
|
}
|
|
3837
3912
|
/** How long a daemon gets to answer before a command gives up: a read is in memory (15 s); a call that waits for the
|
|
3838
3913
|
* contact carries its own `--timeout` (or the daemon's default for it), plus a margin; anything else may take as long
|
|
3839
|
-
* as it takes. */
|
|
3914
|
+
* as it takes, once the daemon has answered the version check sent ahead of it (session()). */
|
|
3840
3915
|
var ANSWER_MS = 15e3;
|
|
3841
3916
|
function answerWithin(method, params) {
|
|
3842
3917
|
const waits = typeof params.timeout === "number" ? Math.min(Math.max(params.timeout, 1), 86400) : waitsFor(method, params);
|
|
@@ -3858,9 +3933,17 @@ async function session(g, options) {
|
|
|
3858
3933
|
const client = await connectDaemon(g.paths);
|
|
3859
3934
|
if (client) {
|
|
3860
3935
|
const warned = warnVersion(client);
|
|
3936
|
+
const call = async (m, p) => {
|
|
3937
|
+
const timeoutMs = answerWithin(m, p ?? {});
|
|
3938
|
+
if (timeoutMs === void 0 && !await settlesWithin(warned, ANSWER_MS)) {
|
|
3939
|
+
client.destroy();
|
|
3940
|
+
throw new CliError("timeout", `The daemon did not answer in ${ANSWER_MS / 1e3} s; nothing was done: \`ghostly daemon restart\` starts a fresh one`, { method: m });
|
|
3941
|
+
}
|
|
3942
|
+
return client.call(m, p, { timeoutMs });
|
|
3943
|
+
};
|
|
3861
3944
|
return {
|
|
3862
3945
|
mode: "daemon",
|
|
3863
|
-
call
|
|
3946
|
+
call,
|
|
3864
3947
|
close: async () => {
|
|
3865
3948
|
await warned;
|
|
3866
3949
|
client.close();
|
|
@@ -4044,14 +4127,30 @@ var SPECIAL = [
|
|
|
4044
4127
|
],
|
|
4045
4128
|
["version", "This CLI's version (also ghostly --version)"]
|
|
4046
4129
|
];
|
|
4130
|
+
/** A command's words before its arguments: "group send", "send", "engine". */
|
|
4131
|
+
var wordsOf = (usage) => usage.split(" ").filter((w) => /^[a-z][\w-]*$/.test(w)).slice(0, 2);
|
|
4132
|
+
/**
|
|
4133
|
+
* `rows`, then each of `more` beside the rows of its first word: after the last of them (`group send` with the group
|
|
4134
|
+
* commands, `identity add` with the identity ones), or at the end when none has that word. They were all appended after
|
|
4135
|
+
* the table: `group send` 106 lines below the group block, `identity add` 60 below its own (agents#1606).
|
|
4136
|
+
*/
|
|
4137
|
+
function beside(rows, more) {
|
|
4138
|
+
const out = [...rows];
|
|
4139
|
+
for (const row of more) {
|
|
4140
|
+
const [first, second] = wordsOf(row[0]);
|
|
4141
|
+
let at = -1;
|
|
4142
|
+
if (second !== void 0) {
|
|
4143
|
+
for (let i = out.length - 1; i >= 0; i--) if (wordsOf(out[i][0])[0] === first && wordsOf(out[i][0]).length > 1) {
|
|
4144
|
+
at = i;
|
|
4145
|
+
break;
|
|
4146
|
+
}
|
|
4147
|
+
}
|
|
4148
|
+
out.splice(at < 0 ? out.length : at + 1, 0, row);
|
|
4149
|
+
}
|
|
4150
|
+
return out;
|
|
4151
|
+
}
|
|
4047
4152
|
function help() {
|
|
4048
|
-
const rows = [
|
|
4049
|
-
...SPECIAL.slice(0, 7).map(([usage, summary]) => [usage, summary]),
|
|
4050
|
-
...Object.values(COMMANDS).filter((c) => c.method !== "events.replay").map((c) => [c.usage, c.summary]),
|
|
4051
|
-
...Object.values(TEXT_COMMANDS).map((c) => [c.usage, c.summary]),
|
|
4052
|
-
...SPECIAL.slice(7).map(([usage, summary]) => [usage, summary]),
|
|
4053
|
-
[COMMANDS.events.usage, COMMANDS.events.summary]
|
|
4054
|
-
];
|
|
4153
|
+
const rows = [...beside([...SPECIAL.slice(0, 7).map(([usage, summary]) => [usage, summary]), ...Object.values(COMMANDS).filter((c) => c.method !== "events.replay").map((c) => [c.usage, c.summary])], [...Object.values(TEXT_COMMANDS).map((c) => [c.usage, c.summary]), ...SPECIAL.slice(7).map(([usage, summary]) => [usage, summary])]), [COMMANDS.events.usage, COMMANDS.events.summary]];
|
|
4055
4154
|
const width = 58;
|
|
4056
4155
|
return [
|
|
4057
4156
|
`ghostly ${VERSION}: Ghostly for bots and terminals, the app's own engine without a screen.`,
|
|
@@ -4282,7 +4381,7 @@ async function profileCommand(sub, argv) {
|
|
|
4282
4381
|
if (!given || !name) throw new CliError("usage", "ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4283
4382
|
noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4284
4383
|
const file = here(given);
|
|
4285
|
-
const { backupFileProtection, restoreProfile } = await import("./backup-
|
|
4384
|
+
const { backupFileProtection, restoreProfile } = await import("./backup-DavZrUf6.js");
|
|
4286
4385
|
const protection = await backupFileProtection(file);
|
|
4287
4386
|
const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
|
|
4288
4387
|
if (parsed.options.use) selectProfile(g.home, name);
|
|
@@ -4374,11 +4473,6 @@ async function runDaemon(g) {
|
|
|
4374
4473
|
lastSeq: host.ctx.hub.lastSeq
|
|
4375
4474
|
});
|
|
4376
4475
|
}
|
|
4377
|
-
/**
|
|
4378
|
-
* `daemon stop` and `restart` wait this long for the daemon's greeting: a daemon of an older release never greets, and
|
|
4379
|
-
* what does not prove itself is stopped as the process that holds the profile (`stopDaemon`), as the stop asked.
|
|
4380
|
-
*/
|
|
4381
|
-
var STOP_GREETING_MS = 2e3;
|
|
4382
4476
|
async function daemonCommand(argv) {
|
|
4383
4477
|
const sub = argv[0] && !argv[0].startsWith("-") ? argv[0] : void 0;
|
|
4384
4478
|
const parsed = parseArgs(sub ? argv.slice(1) : argv, {
|
|
@@ -4423,7 +4517,7 @@ async function daemonCommand(argv) {
|
|
|
4423
4517
|
if (sub === "stop") {
|
|
4424
4518
|
knownProfile(g);
|
|
4425
4519
|
const stopFor = seconds(parsed, 20);
|
|
4426
|
-
const client = await connectDaemon(g.paths
|
|
4520
|
+
const client = await connectDaemon(g.paths);
|
|
4427
4521
|
if (!client) throw new CliError("not_found", `No daemon runs profile ${g.profile}`);
|
|
4428
4522
|
print({
|
|
4429
4523
|
stopped: true,
|
|
@@ -4433,14 +4527,26 @@ async function daemonCommand(argv) {
|
|
|
4433
4527
|
}
|
|
4434
4528
|
if (sub === "restart") {
|
|
4435
4529
|
const stopFor = seconds(parsed, 20), startFor = seconds(parsed, 60);
|
|
4436
|
-
const client = await connectDaemon(g.paths
|
|
4530
|
+
const client = await connectDaemon(g.paths);
|
|
4437
4531
|
const probe = client ? client.call("status").catch(() => null) : null;
|
|
4532
|
+
const stopped = client ? await stopDaemon(g, client, stopFor) : null;
|
|
4533
|
+
const before = (await probe)?.version ?? null;
|
|
4534
|
+
let started;
|
|
4535
|
+
try {
|
|
4536
|
+
started = await startDetached(g, startFor);
|
|
4537
|
+
} catch (error) {
|
|
4538
|
+
if (stopped === null || !(error instanceof CliError) || error.code === "timeout") throw error;
|
|
4539
|
+
throw new CliError(error.code, `${error.message}. The daemon (process ${stopped}) was stopped: start it again with ghostly daemon --detach`, {
|
|
4540
|
+
...error.details,
|
|
4541
|
+
stopped
|
|
4542
|
+
});
|
|
4543
|
+
}
|
|
4438
4544
|
print({
|
|
4439
4545
|
restarted: true,
|
|
4440
|
-
stopped
|
|
4441
|
-
before
|
|
4546
|
+
stopped,
|
|
4547
|
+
before,
|
|
4442
4548
|
version: VERSION,
|
|
4443
|
-
...
|
|
4549
|
+
...started
|
|
4444
4550
|
});
|
|
4445
4551
|
return;
|
|
4446
4552
|
}
|
|
@@ -4518,12 +4624,31 @@ function processAlive(pid) {
|
|
|
4518
4624
|
return error.code === "EPERM";
|
|
4519
4625
|
}
|
|
4520
4626
|
}
|
|
4521
|
-
/**
|
|
4627
|
+
/**
|
|
4628
|
+
* A daemon in the background, running this command's code, once its socket answers. A one-shot command (or a listen)
|
|
4629
|
+
* that opened the profile in process holds it: the child would only log that. One that ends in a moment (a bot's
|
|
4630
|
+
* `send` every 200 ms, which takes the profile in the gap of a restart) is waited for, and so is one that took it
|
|
4631
|
+
* between the look and the child's start; one that still holds it at `seconds` is the answer, busy with its pid.
|
|
4632
|
+
*/
|
|
4522
4633
|
async function startDetached(g, seconds) {
|
|
4523
4634
|
requireProfile(g);
|
|
4524
|
-
|
|
4525
|
-
|
|
4526
|
-
|
|
4635
|
+
const until = Date.now() + seconds * 1e3;
|
|
4636
|
+
for (;;) {
|
|
4637
|
+
if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
|
|
4638
|
+
if (lockOwner(g.paths) === null) {
|
|
4639
|
+
const started = await spawnDaemon(g, until);
|
|
4640
|
+
if (started) return started;
|
|
4641
|
+
}
|
|
4642
|
+
if (Date.now() >= until) {
|
|
4643
|
+
heldBy(g);
|
|
4644
|
+
throw new CliError("engine", `The daemon did not start; see ${g.paths.log}`);
|
|
4645
|
+
}
|
|
4646
|
+
await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, until - Date.now()))));
|
|
4647
|
+
}
|
|
4648
|
+
}
|
|
4649
|
+
/** `startDetached`'s child, or null when another process took the profile ahead of it and there is time to try again. */
|
|
4650
|
+
async function spawnDaemon(g, until) {
|
|
4651
|
+
const log = openSync(g.paths.log, "a", 384), logFrom = fstatSync(log).size;
|
|
4527
4652
|
const child = spawn(process.execPath, [
|
|
4528
4653
|
...process.execArgv,
|
|
4529
4654
|
process.argv[1],
|
|
@@ -4540,12 +4665,12 @@ async function startDetached(g, seconds) {
|
|
|
4540
4665
|
log
|
|
4541
4666
|
]
|
|
4542
4667
|
});
|
|
4668
|
+
closeSync(log);
|
|
4543
4669
|
child.unref();
|
|
4544
4670
|
const spawned = { error: null };
|
|
4545
4671
|
child.once("error", (error) => {
|
|
4546
4672
|
spawned.error = error;
|
|
4547
4673
|
});
|
|
4548
|
-
const until = Date.now() + seconds * 1e3;
|
|
4549
4674
|
let client = null;
|
|
4550
4675
|
while (child.exitCode === null && child.signalCode === null && !spawned.error) {
|
|
4551
4676
|
const left = until - Date.now();
|
|
@@ -4555,6 +4680,7 @@ async function startDetached(g, seconds) {
|
|
|
4555
4680
|
await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(200, until - Date.now()))));
|
|
4556
4681
|
}
|
|
4557
4682
|
if (!client) {
|
|
4683
|
+
if (!spawned.error && (![null, child.pid].includes(lockOwner(g.paths)) || lostTheProfile(g.paths.log, logFrom)) && Date.now() < until) return null;
|
|
4558
4684
|
heldBy(g, child.pid);
|
|
4559
4685
|
if (child.exitCode === null && child.signalCode === null && child.pid !== void 0 && processAlive(child.pid)) throw new CliError("timeout", `The daemon (process ${child.pid}) is still starting; ghostly daemon status shows when it is up`, {
|
|
4560
4686
|
pid: child.pid,
|
|
@@ -4571,6 +4697,27 @@ async function startDetached(g, seconds) {
|
|
|
4571
4697
|
log: g.paths.log
|
|
4572
4698
|
};
|
|
4573
4699
|
}
|
|
4700
|
+
/** Whether a daemon's answer written to the log from byte `from` on is `busy`: it found the profile taken. */
|
|
4701
|
+
function lostTheProfile(log, from) {
|
|
4702
|
+
let fd;
|
|
4703
|
+
try {
|
|
4704
|
+
fd = openSync(log, "r");
|
|
4705
|
+
} catch {
|
|
4706
|
+
return false;
|
|
4707
|
+
}
|
|
4708
|
+
try {
|
|
4709
|
+
const buffer = Buffer.alloc(65536);
|
|
4710
|
+
return buffer.subarray(0, readSync(fd, buffer, 0, buffer.length, from)).toString("utf8").split("\n").some((line) => {
|
|
4711
|
+
try {
|
|
4712
|
+
return JSON.parse(line).error?.code === "busy";
|
|
4713
|
+
} catch {
|
|
4714
|
+
return false;
|
|
4715
|
+
}
|
|
4716
|
+
});
|
|
4717
|
+
} finally {
|
|
4718
|
+
closeSync(fd);
|
|
4719
|
+
}
|
|
4720
|
+
}
|
|
4574
4721
|
/**
|
|
4575
4722
|
* Nobody reads `listen`'s output any more (`listen | head -n 1`, a `grep -m1` that found its line): it stops as on
|
|
4576
4723
|
* SIGTERM, exit 0. Through a daemon it died on an 'error' nobody handled; on its own profile it served on with nobody
|
|
@@ -4642,6 +4789,15 @@ async function listenCommand(argv) {
|
|
|
4642
4789
|
const cursor = here(parsed.options.cursor);
|
|
4643
4790
|
checkCursor(cursor);
|
|
4644
4791
|
const since = parsed.options.since ?? readCursor(cursor);
|
|
4792
|
+
let quit = (code) => {
|
|
4793
|
+
process.exit(code);
|
|
4794
|
+
};
|
|
4795
|
+
const cursorFailed = (error) => {
|
|
4796
|
+
const failure = localFileError(error, cursor) ?? asCliError(error);
|
|
4797
|
+
process.stderr.write(`ghostly: could not write the cursor ${cursor}: ${failure.message}. Stopped, so that no event is handed twice\n`);
|
|
4798
|
+
print({ error: failure.toJSON() });
|
|
4799
|
+
quit(EXIT[failure.code]);
|
|
4800
|
+
};
|
|
4645
4801
|
const start = async (call, peerOf) => {
|
|
4646
4802
|
return eventHandler({
|
|
4647
4803
|
types,
|
|
@@ -4649,6 +4805,7 @@ async function listenCommand(argv) {
|
|
|
4649
4805
|
exec: parsed.options.exec,
|
|
4650
4806
|
webhook: parsed.options.webhook,
|
|
4651
4807
|
cursor,
|
|
4808
|
+
cursorFailed,
|
|
4652
4809
|
print: parsed.options.print === true || !parsed.options.exec && !parsed.options.webhook,
|
|
4653
4810
|
write: (line) => process.stdout.write(line + "\n"),
|
|
4654
4811
|
drained: () => new Promise((resolve) => {
|
|
@@ -4679,11 +4836,15 @@ async function listenCommand(argv) {
|
|
|
4679
4836
|
client.close();
|
|
4680
4837
|
throw error;
|
|
4681
4838
|
});
|
|
4682
|
-
const following = followDaemon(g.paths, client, handle, since);
|
|
4839
|
+
const following = followDaemon(g.paths, client, handle, since, PAUSE_HOLD_MS, g.profile);
|
|
4683
4840
|
const stop = () => {
|
|
4684
4841
|
following.close();
|
|
4685
4842
|
process.exit(0);
|
|
4686
4843
|
};
|
|
4844
|
+
quit = (code) => {
|
|
4845
|
+
following.close();
|
|
4846
|
+
process.exit(code);
|
|
4847
|
+
};
|
|
4687
4848
|
onReaderGone(stop);
|
|
4688
4849
|
await following.subscribed;
|
|
4689
4850
|
process.on("SIGINT", stop);
|
|
@@ -4706,6 +4867,10 @@ async function listenCommand(argv) {
|
|
|
4706
4867
|
await served.close();
|
|
4707
4868
|
await host.close();
|
|
4708
4869
|
});
|
|
4870
|
+
quit = (code) => {
|
|
4871
|
+
setTimeout(() => process.exit(code), 2e4).unref();
|
|
4872
|
+
served.close().then(() => host.close()).finally(() => process.exit(code));
|
|
4873
|
+
};
|
|
4709
4874
|
host.ctx.stop = stop;
|
|
4710
4875
|
onStopSignals(stop);
|
|
4711
4876
|
onReaderGone(stop);
|
|
@@ -4855,7 +5020,7 @@ async function textCommand(name, argv) {
|
|
|
4855
5020
|
};
|
|
4856
5021
|
if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
|
|
4857
5022
|
if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
|
|
4858
|
-
if (!spec.message) Object.assign(params, (await import("./buttons-
|
|
5023
|
+
if (!spec.message) Object.assign(params, (await import("./buttons-DC20Q2no.js")).buttonsOf(parsed.options));
|
|
4859
5024
|
print(await withSession(g, (s) => {
|
|
4860
5025
|
if (spec.target === "chat") {
|
|
4861
5026
|
params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
|
|
@@ -5163,4 +5328,4 @@ async function run(argv) {
|
|
|
5163
5328
|
//#endregion
|
|
5164
5329
|
export { run };
|
|
5165
5330
|
|
|
5166
|
-
//# sourceMappingURL=main-
|
|
5331
|
+
//# sourceMappingURL=main-AHz1dbsm.js.map
|