@ghostlytools/cli 1.5.3 → 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 +2 -2
- package/dist/assets/{api-BIg0Msax.js → api-ButrHieZ.js} +2 -2
- package/dist/assets/{api-d2aXkbM5.js → api-DDmune9b.js} +24 -19
- package/dist/assets/api-DDmune9b.js.map +1 -0
- package/dist/assets/{apiKit-Ba_t7MZO.js → apiKit-DfFlJhXO.js} +3 -3
- package/dist/assets/{apiKit-Ba_t7MZO.js.map → apiKit-DfFlJhXO.js.map} +1 -1
- package/dist/assets/{apps-B_F3gEI4.js → apps-BVnNpB2f.js} +1 -1
- package/dist/assets/{apps-CJo1MmSY.js → apps-CpQVuYqT.js} +4 -4
- package/dist/assets/{apps-CJo1MmSY.js.map → apps-CpQVuYqT.js.map} +1 -1
- package/dist/assets/{arkade-DTne0O3Q.js → arkade-C9Ne-zJb.js} +2 -2
- package/dist/assets/{arkade-DTne0O3Q.js.map → arkade-C9Ne-zJb.js.map} +1 -1
- package/dist/assets/{backup-CqpDAZZG.js → backup-DavZrUf6.js} +1 -1
- package/dist/assets/{backup-BY88aZr5.js → backup-MN2sZQeW.js} +7 -7
- package/dist/assets/{backup-BY88aZr5.js.map → backup-MN2sZQeW.js.map} +1 -1
- package/dist/assets/{blobFiles-B1lX6iGy.js → blobFiles-B6nf0gCG.js} +3 -3
- package/dist/assets/{blobFiles-B1lX6iGy.js.map → blobFiles-B6nf0gCG.js.map} +1 -1
- package/dist/assets/buttons-DC20Q2no.js +2 -0
- package/dist/assets/{buttons-B5EnA2nh.js → buttons-DIWDW2n5.js} +4 -4
- package/dist/assets/{buttons-B5EnA2nh.js.map → buttons-DIWDW2n5.js.map} +1 -1
- package/dist/assets/{daemonProof-Dx3N_DLC.js → daemonProof-ui8jtIw0.js} +2 -2
- package/dist/assets/{daemonProof-Dx3N_DLC.js.map → daemonProof-ui8jtIw0.js.map} +1 -1
- package/dist/assets/{envelope-BU-BB1wR.js → envelope-ByeUit1N.js} +2 -2
- package/dist/assets/{envelope-BU-BB1wR.js.map → envelope-ByeUit1N.js.map} +1 -1
- package/dist/assets/{errors-DI6Z3jTH.js → errors-CzXgR8Cc.js} +14 -4
- package/dist/assets/errors-CzXgR8Cc.js.map +1 -0
- package/dist/assets/{fileBytes-D85lBh-Q.js → fileBytes-BMEBas7S.js} +3 -3
- package/dist/assets/{fileBytes-D85lBh-Q.js.map → fileBytes-BMEBas7S.js.map} +1 -1
- package/dist/assets/{fileBytes-D0CYuRwZ.js → fileBytes-CFNrRfcl.js} +2 -2
- package/dist/assets/{fileBytes-D0CYuRwZ.js.map → fileBytes-CFNrRfcl.js.map} +1 -1
- package/dist/assets/{fileBytes-BMlLVdfg.js → fileBytes-CtwagJ8h.js} +1 -1
- package/dist/assets/{fileBytesIdb-LAhH7kY2.js → fileBytesIdb-BXAN7i-N.js} +3 -3
- package/dist/assets/{fileBytesIdb-LAhH7kY2.js.map → fileBytesIdb-BXAN7i-N.js.map} +1 -1
- package/dist/assets/fileBytesIdb-C20oXDdr.js +2 -0
- package/dist/assets/{fileBytesOpfs-DjBBghvq.js → fileBytesOpfs-Do1Vpkis.js} +3 -3
- package/dist/assets/{fileBytesOpfs-DjBBghvq.js.map → fileBytesOpfs-Do1Vpkis.js.map} +1 -1
- package/dist/assets/{groupFiles-D9k6fyhf.js → groupFiles-DVxX0O1g.js} +5 -5
- package/dist/assets/groupFiles-DVxX0O1g.js.map +1 -0
- package/dist/assets/{host-DrL7FPG4.js → host-AB2Cr46b.js} +16 -15
- package/dist/assets/host-AB2Cr46b.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-C-BsT6_V.js → hyperdhtRelay-BcrwJRtb.js} +2 -2
- package/dist/assets/{hyperdhtRelay-C-BsT6_V.js.map → hyperdhtRelay-BcrwJRtb.js.map} +1 -1
- package/dist/assets/{idb-CWvq4HKc.js → idb-BlH8-O3R.js} +11 -3
- package/dist/assets/{idb-CWvq4HKc.js.map → idb-BlH8-O3R.js.map} +1 -1
- package/dist/assets/{irohWeb-DdHXEwgj.js → irohWeb-B5j2rgWj.js} +2 -2
- package/dist/assets/{irohWeb-DdHXEwgj.js.map → irohWeb-B5j2rgWj.js.map} +1 -1
- package/dist/assets/{main-xeoX7yLM.js → main-AHz1dbsm.js} +84 -29
- package/dist/assets/main-AHz1dbsm.js.map +1 -0
- package/dist/assets/{mainline-CEqGvRYJ.js → mainline-afyQ77bv.js} +2 -2
- package/dist/assets/{mainline-CEqGvRYJ.js.map → mainline-afyQ77bv.js.map} +1 -1
- package/dist/assets/{networkReason-RGRU5xoa.js → networkReason-DWzsMN8E.js} +3 -3
- package/dist/assets/{networkReason-RGRU5xoa.js.map → networkReason-DWzsMN8E.js.map} +1 -1
- package/dist/assets/{nwc-s5xHLqNf.js → nwc-DYXTp8UX.js} +3 -3
- package/dist/assets/{nwc-s5xHLqNf.js.map → nwc-DYXTp8UX.js.map} +1 -1
- package/dist/assets/{nwcProvider-CfAFO5Fr.js → nwcProvider-B4k6mYJl.js} +2 -2
- package/dist/assets/{nwcProvider-CfAFO5Fr.js.map → nwcProvider-B4k6mYJl.js.map} +1 -1
- package/dist/assets/{profiles-gZdQPyaz.js → profiles-CEnZfN78.js} +2 -2
- package/dist/assets/{profiles-gZdQPyaz.js.map → profiles-CEnZfN78.js.map} +1 -1
- package/dist/assets/{registry-BUhSjM-J.js → registry-Ccru6KBP.js} +1 -1
- package/dist/assets/{registry-CVUdD4bJ.js → registry-wSZHgbsv.js} +3 -3
- package/dist/assets/{registry-CVUdD4bJ.js.map → registry-wSZHgbsv.js.map} +1 -1
- package/dist/assets/{resolve-uZECJ3f7.js → resolve-BPJnMtLC.js} +2 -2
- package/dist/assets/{resolve-uZECJ3f7.js.map → resolve-BPJnMtLC.js.map} +1 -1
- package/dist/assets/{restoredRows-D6WZUA2U.js → restoredRows-Fv-MuY45.js} +2 -2
- package/dist/assets/{restoredRows-D6WZUA2U.js.map → restoredRows-Fv-MuY45.js.map} +1 -1
- package/dist/assets/{server-DOtUKoYR.js → server-DPzt5V2x.js} +236 -54
- package/dist/assets/server-DPzt5V2x.js.map +1 -0
- package/dist/assets/{src-Dd_7Ew1X.js → src-CFeRBeHz.js} +60 -6
- package/dist/assets/{src-Dd_7Ew1X.js.map → src-CFeRBeHz.js.map} +1 -1
- package/dist/assets/{usdt-C2Anx8p7.js → usdt-CBh78JVF.js} +3 -3
- package/dist/assets/{usdt-C2Anx8p7.js.map → usdt-CBh78JVF.js.map} +1 -1
- package/dist/assets/{words-DoLU6p8H.js → words-DC8BQvPO.js} +2 -2
- package/dist/assets/{words-DoLU6p8H.js.map → words-DC8BQvPO.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/examples/payment-bot.mjs +5 -2
- package/package.json +1 -1
- package/dist/assets/api-d2aXkbM5.js.map +0 -1
- package/dist/assets/buttons-azvbN6xn.js +0 -2
- package/dist/assets/errors-DI6Z3jTH.js.map +0 -1
- package/dist/assets/fileBytesIdb-Dn9levD1.js +0 -2
- package/dist/assets/groupFiles-D9k6fyhf.js.map +0 -1
- package/dist/assets/host-DrL7FPG4.js.map +0 -1
- package/dist/assets/main-xeoX7yLM.js.map +0 -1
- package/dist/assets/server-DOtUKoYR.js.map +0 -1
|
@@ -1,10 +1,10 @@
|
|
|
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-
|
|
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-
|
|
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 { _ 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-
|
|
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-
|
|
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",
|
|
@@ -1096,7 +1096,7 @@ var commands$8 = {
|
|
|
1096
1096
|
description: "Replace the three files when they are there"
|
|
1097
1097
|
}
|
|
1098
1098
|
},
|
|
1099
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1099
|
+
run: async ({ options }, a) => (await import("./apps-BVnNpB2f.js")).initApp(a.dir, {
|
|
1100
1100
|
name: options.name,
|
|
1101
1101
|
title: options.title,
|
|
1102
1102
|
force: options.force === true
|
|
@@ -1136,7 +1136,7 @@ var commands$8 = {
|
|
|
1136
1136
|
description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
|
|
1137
1137
|
}
|
|
1138
1138
|
},
|
|
1139
|
-
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)
|
|
1140
1140
|
},
|
|
1141
1141
|
"app revoke": {
|
|
1142
1142
|
method: "app.revoke",
|
|
@@ -1169,7 +1169,7 @@ var commands$8 = {
|
|
|
1169
1169
|
description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
|
|
1170
1170
|
}
|
|
1171
1171
|
},
|
|
1172
|
-
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>]"), {
|
|
1173
1173
|
digests: options.digest,
|
|
1174
1174
|
upTo: options["up-to"],
|
|
1175
1175
|
reason: options.reason,
|
|
@@ -1230,7 +1230,7 @@ var commands$8 = {
|
|
|
1230
1230
|
usage: "app verify <bundle|url>",
|
|
1231
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",
|
|
1232
1232
|
args: ["bundle"],
|
|
1233
|
-
run: async (_, a) => (await import("./apps-
|
|
1233
|
+
run: async (_, a) => (await import("./apps-BVnNpB2f.js")).verifyApp(a.bundle)
|
|
1234
1234
|
},
|
|
1235
1235
|
"store sign": {
|
|
1236
1236
|
method: "store.sign",
|
|
@@ -1247,7 +1247,7 @@ var commands$8 = {
|
|
|
1247
1247
|
description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
|
|
1248
1248
|
}
|
|
1249
1249
|
},
|
|
1250
|
-
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))
|
|
1251
1251
|
}
|
|
1252
1252
|
};
|
|
1253
1253
|
//#endregion
|
|
@@ -2661,7 +2661,7 @@ var commands$1 = {
|
|
|
2661
2661
|
},
|
|
2662
2662
|
"pay": {
|
|
2663
2663
|
method: "pay",
|
|
2664
|
-
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]",
|
|
2665
2665
|
summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real",
|
|
2666
2666
|
args: ["target"],
|
|
2667
2667
|
options: {
|
|
@@ -2679,7 +2679,8 @@ var commands$1 = {
|
|
|
2679
2679
|
type: "string",
|
|
2680
2680
|
description: "For the address's owner"
|
|
2681
2681
|
},
|
|
2682
|
-
"confirm-real": confirmReal
|
|
2682
|
+
"confirm-real": confirmReal,
|
|
2683
|
+
force
|
|
2683
2684
|
},
|
|
2684
2685
|
params: ({ options }, { target }) => ({
|
|
2685
2686
|
target,
|
|
@@ -2688,7 +2689,8 @@ var commands$1 = {
|
|
|
2688
2689
|
maxFee: options["max-fee"],
|
|
2689
2690
|
card: options.card,
|
|
2690
2691
|
comment: options.comment,
|
|
2691
|
-
confirmReal: options["confirm-real"] === true
|
|
2692
|
+
confirmReal: options["confirm-real"] === true,
|
|
2693
|
+
force: options.force === true
|
|
2692
2694
|
})
|
|
2693
2695
|
},
|
|
2694
2696
|
"payment check": {
|
|
@@ -3763,8 +3765,8 @@ var VERSION = package_default.version;
|
|
|
3763
3765
|
* command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
|
|
3764
3766
|
* cost every command ~100 ms before its socket was opened.
|
|
3765
3767
|
*/
|
|
3766
|
-
var engineApi = () => import("./api-
|
|
3767
|
-
var engineHost = () => import("./host-
|
|
3768
|
+
var engineApi = () => import("./api-ButrHieZ.js");
|
|
3769
|
+
var engineHost = () => import("./host-AB2Cr46b.js");
|
|
3768
3770
|
var pretty = false;
|
|
3769
3771
|
function print(value) {
|
|
3770
3772
|
process.stdout.write(JSON.stringify(value, null, pretty ? 2 : void 0) + "\n");
|
|
@@ -4379,7 +4381,7 @@ async function profileCommand(sub, argv) {
|
|
|
4379
4381
|
if (!given || !name) throw new CliError("usage", "ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4380
4382
|
noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4381
4383
|
const file = here(given);
|
|
4382
|
-
const { backupFileProtection, restoreProfile } = await import("./backup-
|
|
4384
|
+
const { backupFileProtection, restoreProfile } = await import("./backup-DavZrUf6.js");
|
|
4383
4385
|
const protection = await backupFileProtection(file);
|
|
4384
4386
|
const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
|
|
4385
4387
|
if (parsed.options.use) selectProfile(g.home, name);
|
|
@@ -4527,12 +4529,24 @@ async function daemonCommand(argv) {
|
|
|
4527
4529
|
const stopFor = seconds(parsed, 20), startFor = seconds(parsed, 60);
|
|
4528
4530
|
const client = await connectDaemon(g.paths);
|
|
4529
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
|
+
}
|
|
4530
4544
|
print({
|
|
4531
4545
|
restarted: true,
|
|
4532
|
-
stopped
|
|
4533
|
-
before
|
|
4546
|
+
stopped,
|
|
4547
|
+
before,
|
|
4534
4548
|
version: VERSION,
|
|
4535
|
-
...
|
|
4549
|
+
...started
|
|
4536
4550
|
});
|
|
4537
4551
|
return;
|
|
4538
4552
|
}
|
|
@@ -4610,12 +4624,31 @@ function processAlive(pid) {
|
|
|
4610
4624
|
return error.code === "EPERM";
|
|
4611
4625
|
}
|
|
4612
4626
|
}
|
|
4613
|
-
/**
|
|
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
|
+
*/
|
|
4614
4633
|
async function startDetached(g, seconds) {
|
|
4615
4634
|
requireProfile(g);
|
|
4616
|
-
|
|
4617
|
-
|
|
4618
|
-
|
|
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;
|
|
4619
4652
|
const child = spawn(process.execPath, [
|
|
4620
4653
|
...process.execArgv,
|
|
4621
4654
|
process.argv[1],
|
|
@@ -4632,12 +4665,12 @@ async function startDetached(g, seconds) {
|
|
|
4632
4665
|
log
|
|
4633
4666
|
]
|
|
4634
4667
|
});
|
|
4668
|
+
closeSync(log);
|
|
4635
4669
|
child.unref();
|
|
4636
4670
|
const spawned = { error: null };
|
|
4637
4671
|
child.once("error", (error) => {
|
|
4638
4672
|
spawned.error = error;
|
|
4639
4673
|
});
|
|
4640
|
-
const until = Date.now() + seconds * 1e3;
|
|
4641
4674
|
let client = null;
|
|
4642
4675
|
while (child.exitCode === null && child.signalCode === null && !spawned.error) {
|
|
4643
4676
|
const left = until - Date.now();
|
|
@@ -4647,6 +4680,7 @@ async function startDetached(g, seconds) {
|
|
|
4647
4680
|
await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(200, until - Date.now()))));
|
|
4648
4681
|
}
|
|
4649
4682
|
if (!client) {
|
|
4683
|
+
if (!spawned.error && (![null, child.pid].includes(lockOwner(g.paths)) || lostTheProfile(g.paths.log, logFrom)) && Date.now() < until) return null;
|
|
4650
4684
|
heldBy(g, child.pid);
|
|
4651
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`, {
|
|
4652
4686
|
pid: child.pid,
|
|
@@ -4663,6 +4697,27 @@ async function startDetached(g, seconds) {
|
|
|
4663
4697
|
log: g.paths.log
|
|
4664
4698
|
};
|
|
4665
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
|
+
}
|
|
4666
4721
|
/**
|
|
4667
4722
|
* Nobody reads `listen`'s output any more (`listen | head -n 1`, a `grep -m1` that found its line): it stops as on
|
|
4668
4723
|
* SIGTERM, exit 0. Through a daemon it died on an 'error' nobody handled; on its own profile it served on with nobody
|
|
@@ -4965,7 +5020,7 @@ async function textCommand(name, argv) {
|
|
|
4965
5020
|
};
|
|
4966
5021
|
if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
|
|
4967
5022
|
if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
|
|
4968
|
-
if (!spec.message) Object.assign(params, (await import("./buttons-
|
|
5023
|
+
if (!spec.message) Object.assign(params, (await import("./buttons-DC20Q2no.js")).buttonsOf(parsed.options));
|
|
4969
5024
|
print(await withSession(g, (s) => {
|
|
4970
5025
|
if (spec.target === "chat") {
|
|
4971
5026
|
params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
|
|
@@ -5273,4 +5328,4 @@ async function run(argv) {
|
|
|
5273
5328
|
//#endregion
|
|
5274
5329
|
export { run };
|
|
5275
5330
|
|
|
5276
|
-
//# sourceMappingURL=main-
|
|
5331
|
+
//# sourceMappingURL=main-AHz1dbsm.js.map
|