@ghostlytools/cli 1.11.2 → 1.11.3
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 +11 -10
- package/dist/assets/{api-BM3PsXbB.js → api-DBlaoz8i.js} +129 -37
- package/dist/assets/api-DBlaoz8i.js.map +1 -0
- package/dist/assets/{api-CtXgscmK.js → api-DgU4MZPD.js} +2 -2
- package/dist/assets/{apiKit-lCTQ0EBG.js → apiKit-DesObIDf.js} +4 -4
- package/dist/assets/{apiKit-lCTQ0EBG.js.map → apiKit-DesObIDf.js.map} +1 -1
- package/dist/assets/{appFetch-BKHy5H8J.js → appFetch-C8yZIq1e.js} +3 -3
- package/dist/assets/{appFetch-BKHy5H8J.js.map → appFetch-C8yZIq1e.js.map} +1 -1
- package/dist/assets/{apps-Do26w3c7.js → apps-DkMjDHML.js} +104 -33
- package/dist/assets/apps-DkMjDHML.js.map +1 -0
- package/dist/assets/{apps-DO_gAZgm.js → apps-rzxsjfBV.js} +1 -1
- package/dist/assets/{arkade-CZrLbz-M.js → arkade-CarKONmH.js} +2 -2
- package/dist/assets/{arkade-CZrLbz-M.js.map → arkade-CarKONmH.js.map} +1 -1
- package/dist/assets/{backup-j47AzDvG.js → backup-C0OJCJlM.js} +17 -25
- package/dist/assets/backup-C0OJCJlM.js.map +1 -0
- package/dist/assets/{backup-D21x1f5P.js → backup-CgWU7x0T.js} +1 -1
- package/dist/assets/buttons-Cco0Agfa.js +2 -0
- package/dist/assets/{buttons-CiGlBVBT.js → buttons-fZTEa_2i.js} +34 -5
- package/dist/assets/buttons-fZTEa_2i.js.map +1 -0
- package/dist/assets/{client-raIncVtF.js → client-Ibk3-e60.js} +2 -2
- package/dist/assets/{client-raIncVtF.js.map → client-Ibk3-e60.js.map} +1 -1
- package/dist/assets/{codec-DcG2AeyE.js → codec-DMpQqVSt.js} +2 -2
- package/dist/assets/{codec-DcG2AeyE.js.map → codec-DMpQqVSt.js.map} +1 -1
- package/dist/assets/{envelope-Dud6lntA.js → envelope-CvQVCGdf.js} +2 -2
- package/dist/assets/{envelope-Dud6lntA.js.map → envelope-CvQVCGdf.js.map} +1 -1
- package/dist/assets/{fedimintSdk-DRKRSw14.js → fedimintSdk-zV_5Qdqz.js} +2 -2
- package/dist/assets/{fedimintSdk-DRKRSw14.js.map → fedimintSdk-zV_5Qdqz.js.map} +1 -1
- package/dist/assets/{fixedHosts-CNX7QiUD.js → fixedHosts-6gKn8dp2.js} +3 -3
- package/dist/assets/{fixedHosts-CNX7QiUD.js.map → fixedHosts-6gKn8dp2.js.map} +1 -1
- package/dist/assets/{host-8RskzQgB.js → host-CYlIiY3r.js} +161 -32
- package/dist/assets/host-CYlIiY3r.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-uAThbFub.js → hyperdhtRelay-CdsLcAhY.js} +2 -2
- package/dist/assets/{hyperdhtRelay-uAThbFub.js.map → hyperdhtRelay-CdsLcAhY.js.map} +1 -1
- package/dist/assets/{irohWeb-DGelfgDJ.js → irohWeb-D2IuloLL.js} +19 -12
- package/dist/assets/irohWeb-D2IuloLL.js.map +1 -0
- package/dist/assets/{main-BC33ooYg.js → main-C0PfjKTe.js} +109 -42
- package/dist/assets/main-C0PfjKTe.js.map +1 -0
- package/dist/assets/{mainline-DYrjsS1t.js → mainline-Cu61qcPS.js} +35 -18
- package/dist/assets/mainline-Cu61qcPS.js.map +1 -0
- package/dist/assets/{networkReason-n2oBs4by.js → networkReason-Dt7Yx_n4.js} +3 -3
- package/dist/assets/{networkReason-n2oBs4by.js.map → networkReason-Dt7Yx_n4.js.map} +1 -1
- package/dist/assets/{nwc-Do3VSlIS.js → nwc-CtZypDcv.js} +3 -3
- package/dist/assets/{nwc-Do3VSlIS.js.map → nwc-CtZypDcv.js.map} +1 -1
- package/dist/assets/{nwcProvider-Du5aWNIn.js → nwcProvider-DYHkd0iu.js} +2 -2
- package/dist/assets/{nwcProvider-Du5aWNIn.js.map → nwcProvider-DYHkd0iu.js.map} +1 -1
- package/dist/assets/{ownDid-CwwYu8s2.js → ownDid-CJ0ta8CL.js} +2 -2
- package/dist/assets/{ownDid-CwwYu8s2.js.map → ownDid-CJ0ta8CL.js.map} +1 -1
- package/dist/assets/{ownStatus-D7dB4zJB.js → ownStatus-D4HC6tNR.js} +11 -6
- package/dist/assets/{ownStatus-D7dB4zJB.js.map → ownStatus-D4HC6tNR.js.map} +1 -1
- package/dist/assets/{profiles-NyF5FnYF.js → profiles-Ccdq6Xf6.js} +3 -3
- package/dist/assets/{profiles-NyF5FnYF.js.map → profiles-Ccdq6Xf6.js.map} +1 -1
- package/dist/assets/{registry-C734VrO9.js → registry-CE0PpQAE.js} +1 -1
- package/dist/assets/{registry-DKDInr0A.js → registry-LvxsLJ5S.js} +18 -7
- package/dist/assets/registry-LvxsLJ5S.js.map +1 -0
- package/dist/assets/{resolve-3Tqh9AWQ.js → resolve-6kVu2DE5.js} +2 -2
- package/dist/assets/{resolve-3Tqh9AWQ.js.map → resolve-6kVu2DE5.js.map} +1 -1
- package/dist/assets/{server-B6PQ6iae.js → server-Q3VcNqGt.js} +245 -97
- package/dist/assets/server-Q3VcNqGt.js.map +1 -0
- package/dist/assets/{src-ChJijTlM.js → src-DjVj2ynY.js} +188 -42
- package/dist/assets/src-DjVj2ynY.js.map +1 -0
- package/dist/assets/{sshForges-Brf0fslM.js → sshForges-DeZ9cN9Q.js} +4 -3
- package/dist/assets/sshForges-DeZ9cN9Q.js.map +1 -0
- package/dist/assets/{translate-xLme9Rdh.js → translate-iQZq4TnY.js} +35 -14
- package/dist/assets/translate-iQZq4TnY.js.map +1 -0
- package/dist/assets/{usdt-CSU5KzTV.js → usdt-DnyTGdTX.js} +3 -3
- package/dist/assets/{usdt-CSU5KzTV.js.map → usdt-DnyTGdTX.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-BM3PsXbB.js.map +0 -1
- package/dist/assets/apps-Do26w3c7.js.map +0 -1
- package/dist/assets/backup-j47AzDvG.js.map +0 -1
- package/dist/assets/buttons-CiGlBVBT.js.map +0 -1
- package/dist/assets/buttons-D2l2bVCG.js +0 -2
- package/dist/assets/host-8RskzQgB.js.map +0 -1
- package/dist/assets/irohWeb-DGelfgDJ.js.map +0 -1
- package/dist/assets/main-BC33ooYg.js.map +0 -1
- package/dist/assets/mainline-DYrjsS1t.js.map +0 -1
- package/dist/assets/registry-DKDInr0A.js.map +0 -1
- package/dist/assets/server-B6PQ6iae.js.map +0 -1
- package/dist/assets/src-ChJijTlM.js.map +0 -1
- package/dist/assets/sshForges-Brf0fslM.js.map +0 -1
- package/dist/assets/translate-xLme9Rdh.js.map +0 -1
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { Ao as
|
|
1
|
+
import { Ao as ROUTINE_STATES, Do as ITEM_STATES, Eo as CRON_LINE, Lo as cardLine, Mo as STATUS_CARD_LIMITS, No as TASK_STATUSES, Oo as PR_CHECKS, Qr as STATUS_AVAILABILITIES, Ro as cardUrl, Ua as VOICE_LIMITS, Vo as statusCardBytes, jo as RUN_RESULTS, ko as PR_STATES, sr as GROUP_FILE_LIMITS } from "./src-DjVj2ynY.js";
|
|
2
2
|
import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-Dt-ZnyOX.js";
|
|
3
|
-
import { a as PAY_METHODS, c as turnRef, d as ENGINE_METHODS, f as ENGINE_PARAMS, h as SECRET_RESULTS, i as CHAT_METHODS, m as READ_PARAMS, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus } from "./ownStatus-
|
|
4
|
-
import { a as contactKeyOf, v as nameKey, y as namedByThem } from "./apiKit-
|
|
3
|
+
import { a as PAY_METHODS, c as turnRef, d as ENGINE_METHODS, f as ENGINE_PARAMS, h as SECRET_RESULTS, i as CHAT_METHODS, m as READ_PARAMS, o as TRANSPORT_NAMES, p as ENGINE_READS, r as ADDRESS_TYPES, s as WALLET_TYPES, t as checkOwnStatus } from "./ownStatus-D4HC6tNR.js";
|
|
4
|
+
import { a as contactKeyOf, v as nameKey, y as namedByThem } from "./apiKit-DesObIDf.js";
|
|
5
5
|
import { n as dropSecretEnv, t as childEnv } from "./childEnv-K_IzUqQx.js";
|
|
6
6
|
import { i as waitsFor, r as waitNotice } from "./waitNotice-Cn0WJ-He.js";
|
|
7
|
-
import { C as ownProfile, _ as profilePaths, c as createProfile, d as ghostlyHome, f as listProfiles, g as profileExists, h as noProfile, i as checkProfileName, l as currentProfile, o as checkShownNameOption, p as lockOwner, s as claimForDaemon, u as daemonClaim, v as selectProfile, x as userPath, y as startingDaemon } from "./profiles-
|
|
7
|
+
import { C as ownProfile, _ as profilePaths, c as createProfile, d as ghostlyHome, f as listProfiles, g as profileExists, h as noProfile, i as checkProfileName, l as currentProfile, o as checkShownNameOption, p as lockOwner, s as claimForDaemon, u as daemonClaim, v as selectProfile, x as userPath, y as startingDaemon } from "./profiles-Ccdq6Xf6.js";
|
|
8
8
|
import { t as jsonOut } from "./jsonOut-POtMBS_V.js";
|
|
9
|
-
import { a as endedUnsent, f as CALL_RATES, i as endedUnanswered, o as isNotTheDaemon, r as connectDaemon, t as DaemonClient, v as isCallRate } from "./client-
|
|
9
|
+
import { a as endedUnsent, f as CALL_RATES, i as endedUnanswered, o as isNotTheDaemon, r as connectDaemon, t as DaemonClient, v as isCallRate } from "./client-Ibk3-e60.js";
|
|
10
10
|
import { spawn } from "node:child_process";
|
|
11
11
|
import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
12
12
|
import { dirname, resolve, sep } from "node:path";
|
|
@@ -14,7 +14,7 @@ import { connect } from "node:net";
|
|
|
14
14
|
import { format } from "node:util";
|
|
15
15
|
var package_default = {
|
|
16
16
|
name: "@ghostlytools/cli",
|
|
17
|
-
version: "1.11.
|
|
17
|
+
version: "1.11.3",
|
|
18
18
|
type: "module",
|
|
19
19
|
description: "Ghostly for bots and terminals: the app's own engine, headless on Node, behind a daemon and a `ghostly` command with JSON output.",
|
|
20
20
|
license: "MIT",
|
|
@@ -1114,7 +1114,7 @@ var commands$8 = {
|
|
|
1114
1114
|
description: "Replace the three files when they are there"
|
|
1115
1115
|
}
|
|
1116
1116
|
},
|
|
1117
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1117
|
+
run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).initApp(a.dir, {
|
|
1118
1118
|
name: options.name,
|
|
1119
1119
|
title: options.title,
|
|
1120
1120
|
force: options.force === true
|
|
@@ -1154,7 +1154,7 @@ var commands$8 = {
|
|
|
1154
1154
|
description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
|
|
1155
1155
|
}
|
|
1156
1156
|
},
|
|
1157
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1157
|
+
run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
|
|
1158
1158
|
},
|
|
1159
1159
|
"app revoke": {
|
|
1160
1160
|
method: "app.revoke",
|
|
@@ -1187,7 +1187,7 @@ var commands$8 = {
|
|
|
1187
1187
|
description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere), and a --reason that looks like a seed, a key or ecash"
|
|
1188
1188
|
}
|
|
1189
1189
|
},
|
|
1190
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1190
|
+
run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
|
|
1191
1191
|
digests: options.digest,
|
|
1192
1192
|
upTo: options["up-to"],
|
|
1193
1193
|
reason: options.reason,
|
|
@@ -1248,7 +1248,7 @@ var commands$8 = {
|
|
|
1248
1248
|
usage: "app verify <bundle|url>",
|
|
1249
1249
|
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 (for a URL, or beside one of its sources) revokes this version",
|
|
1250
1250
|
args: ["bundle"],
|
|
1251
|
-
run: async (_, a) => (await import("./apps-
|
|
1251
|
+
run: async (_, a) => (await import("./apps-rzxsjfBV.js")).verifyApp(a.bundle)
|
|
1252
1252
|
},
|
|
1253
1253
|
"store sign": {
|
|
1254
1254
|
method: "store.sign",
|
|
@@ -1265,7 +1265,7 @@ var commands$8 = {
|
|
|
1265
1265
|
description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
|
|
1266
1266
|
}
|
|
1267
1267
|
},
|
|
1268
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1268
|
+
run: async ({ options }, a) => (await import("./apps-rzxsjfBV.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
|
|
1269
1269
|
}
|
|
1270
1270
|
};
|
|
1271
1271
|
//#endregion
|
|
@@ -1532,16 +1532,23 @@ var commands$6 = {
|
|
|
1532
1532
|
},
|
|
1533
1533
|
"chat remove": {
|
|
1534
1534
|
method: "chat.remove",
|
|
1535
|
-
usage: "chat remove <chat> --yes",
|
|
1536
|
-
summary: "Delete a chat, its keys and history on this device",
|
|
1535
|
+
usage: "chat remove <chat> --yes [--force]",
|
|
1536
|
+
summary: "Delete a chat, its keys and history on this device; refused while a message you deleted for everyone has not reached the contact, unless --force",
|
|
1537
1537
|
args: ["chat"],
|
|
1538
|
-
options: {
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1538
|
+
options: {
|
|
1539
|
+
yes: {
|
|
1540
|
+
type: "boolean",
|
|
1541
|
+
description: "Confirm"
|
|
1542
|
+
},
|
|
1543
|
+
force: {
|
|
1544
|
+
type: "boolean",
|
|
1545
|
+
description: "Remove it even if a message you deleted for everyone has not reached the contact yet"
|
|
1546
|
+
}
|
|
1547
|
+
},
|
|
1542
1548
|
params: ({ options }, { chat }) => ({
|
|
1543
1549
|
chat,
|
|
1544
|
-
yes: options.yes === true
|
|
1550
|
+
yes: options.yes === true,
|
|
1551
|
+
force: options.force === true
|
|
1545
1552
|
})
|
|
1546
1553
|
},
|
|
1547
1554
|
"chat rename": {
|
|
@@ -2742,6 +2749,17 @@ var commands$2 = {
|
|
|
2742
2749
|
};
|
|
2743
2750
|
//#endregion
|
|
2744
2751
|
//#region src/commands/payments.ts
|
|
2752
|
+
/**
|
|
2753
|
+
* `chat accept`'s --networks: mainnet and/or testnet, comma-separated; any other word, or none (an unset variable), is a
|
|
2754
|
+
* usage error before the profile opens, as a word --network does not take is. Before, the API refused it after a
|
|
2755
|
+
* one-shot had opened the profile: bad_request, exit 1.
|
|
2756
|
+
*/
|
|
2757
|
+
function networkList(value) {
|
|
2758
|
+
const networks = value.split(",").map((n) => n.trim()).filter(Boolean);
|
|
2759
|
+
if (!networks.length) throw new CliError("usage", `--networks takes mainnet, testnet or mainnet,testnet (to stop taking it: --off), not ${JSON.stringify(value)}`);
|
|
2760
|
+
if (!networks.every((n) => n === "mainnet" || n === "testnet")) throw new CliError("usage", `--networks takes mainnet, testnet or mainnet,testnet, not ${JSON.stringify(value)}`);
|
|
2761
|
+
return networks;
|
|
2762
|
+
}
|
|
2745
2763
|
/** Wallets and payments: one entry per command, in alphabetical order (test/commands.test.ts checks). */
|
|
2746
2764
|
var commands$1 = {
|
|
2747
2765
|
"chat accept": {
|
|
@@ -2767,7 +2785,7 @@ var commands$1 = {
|
|
|
2767
2785
|
chat: a.chat,
|
|
2768
2786
|
method: a.method,
|
|
2769
2787
|
on: options.off !== true,
|
|
2770
|
-
networks: typeof options.networks === "string" ? options.networks
|
|
2788
|
+
networks: typeof options.networks === "string" ? networkList(options.networks) : void 0
|
|
2771
2789
|
};
|
|
2772
2790
|
}
|
|
2773
2791
|
},
|
|
@@ -3690,6 +3708,13 @@ function checkTypes(types, warn) {
|
|
|
3690
3708
|
if (type === "*") continue;
|
|
3691
3709
|
const family = type.split(/[.*]/)[0];
|
|
3692
3710
|
if (!EVENT_FAMILIES.includes(family)) throw new CliError("usage", `No event is of type ${type}: --type takes a type, or a family (${EVENT_FAMILIES.join(", ")})`);
|
|
3711
|
+
const known = EVENT_TYPES.filter((each) => matches({
|
|
3712
|
+
seq: 0,
|
|
3713
|
+
id: "",
|
|
3714
|
+
type: each,
|
|
3715
|
+
at: 0
|
|
3716
|
+
}, [type]));
|
|
3717
|
+
if (known.length === 1 && known[0] === "agent.turn") throw new CliError("usage", `No event is of type ${type} without --turns: ghostly listen --turns gives agent.turn events, in the place of --type`);
|
|
3693
3718
|
if (!EVENT_TYPES.some((known) => matches({
|
|
3694
3719
|
seq: 0,
|
|
3695
3720
|
id: "",
|
|
@@ -3858,12 +3883,9 @@ function eventHandler(options) {
|
|
|
3858
3883
|
if (stopped) return;
|
|
3859
3884
|
const skip = () => keep(event.seq);
|
|
3860
3885
|
if (options.allow && !await options.allow.allows(event)) return skip();
|
|
3886
|
+
if (options.turns && !gap && !toTurn(event)) return skip();
|
|
3861
3887
|
if (options.translate) event = await options.translate(event);
|
|
3862
|
-
if (options.turns && !gap)
|
|
3863
|
-
const next = toTurn(event);
|
|
3864
|
-
if (!next) return skip();
|
|
3865
|
-
event = next;
|
|
3866
|
-
}
|
|
3888
|
+
if (options.turns && !gap) event = toTurn(event);
|
|
3867
3889
|
const full = options.print && options.write(jsonOut(event)) === false;
|
|
3868
3890
|
if (options.exec) {
|
|
3869
3891
|
const hook = running = runExec(options.exec, event, options.print);
|
|
@@ -4240,15 +4262,15 @@ var VERSION = package_default.version;
|
|
|
4240
4262
|
* command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
|
|
4241
4263
|
* cost every command ~100 ms before its socket was opened.
|
|
4242
4264
|
*/
|
|
4243
|
-
var engineApi = () => import("./api-
|
|
4244
|
-
var engineHost = () => import("./host-
|
|
4265
|
+
var engineApi = () => import("./api-DgU4MZPD.js");
|
|
4266
|
+
var engineHost = () => import("./host-CYlIiY3r.js");
|
|
4245
4267
|
/**
|
|
4246
4268
|
* `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
|
|
4247
4269
|
* asked: the app's message parser it reads costs every other command nothing.
|
|
4248
4270
|
*/
|
|
4249
4271
|
async function translatorFor(value, home) {
|
|
4250
4272
|
if (value === void 0) return null;
|
|
4251
|
-
const { loadDetector, openTranslator, translateTarget } = await import("./translate-
|
|
4273
|
+
const { loadDetector, openTranslator, translateTarget } = await import("./translate-iQZq4TnY.js");
|
|
4252
4274
|
return openTranslator({
|
|
4253
4275
|
home,
|
|
4254
4276
|
to: translateTarget(value),
|
|
@@ -4388,6 +4410,38 @@ function newChatOnly(method) {
|
|
|
4388
4410
|
function oneChatOnly(method, params) {
|
|
4389
4411
|
return newChatOnly(method) || (chatOnly(method, params) || chatOrGroup(method, params)) && typeof params.chat === "string";
|
|
4390
4412
|
}
|
|
4413
|
+
/** What a member says in one group, over that group's own edges: no 1:1 chat carries any of it. */
|
|
4414
|
+
var GROUP_EDGES_ONLY = /* @__PURE__ */ new Set([
|
|
4415
|
+
"group.send",
|
|
4416
|
+
"group.edit",
|
|
4417
|
+
"group.react",
|
|
4418
|
+
"group.typing"
|
|
4419
|
+
]);
|
|
4420
|
+
/**
|
|
4421
|
+
* A command about one group that goes over its edges only (`GROUP_EDGES_ONLY`): a one-shot for it leaves the saved 1:1
|
|
4422
|
+
* chats unstarted (`deferChats`); the groups start, and their edges are never deferred. Started, each saved chat put its
|
|
4423
|
+
* records and its leave packet on the relays: with 12 invites saved, one `group send` asked the relay 32 times (3 with
|
|
4424
|
+
* none), its whole minute, and a text to an away contact, or the next one-shot, waited behind them.
|
|
4425
|
+
*/
|
|
4426
|
+
function oneGroupOnly(method) {
|
|
4427
|
+
return GROUP_EDGES_ONLY.has(method);
|
|
4428
|
+
}
|
|
4429
|
+
/**
|
|
4430
|
+
* Reads that need nothing of a chat's history: a one-shot for one leaves every saved chat unstarted too (`deferChats`),
|
|
4431
|
+
* so its start reads each chat's newest row (its place in `chat list`) and no history. It read every 1:1 chat whole:
|
|
4432
|
+
* `profile show` took 0.8 s and 243 MB instead of 0.45 s and 162 MB with 53,800 messages in the profile.
|
|
4433
|
+
*/
|
|
4434
|
+
var NO_HISTORY_READS = /* @__PURE__ */ new Set([
|
|
4435
|
+
"status",
|
|
4436
|
+
"profile.get",
|
|
4437
|
+
"settings.get",
|
|
4438
|
+
"status.get",
|
|
4439
|
+
"chat.list"
|
|
4440
|
+
]);
|
|
4441
|
+
/** Whether a one-shot for this call leaves every saved chat unstarted, its history unread (`NO_HISTORY_READS`). */
|
|
4442
|
+
function readsNoHistory(method) {
|
|
4443
|
+
return NO_HISTORY_READS.has(method);
|
|
4444
|
+
}
|
|
4391
4445
|
/**
|
|
4392
4446
|
* Calls that only read what the profile stores: a one-shot for one opens it offline (`RuntimeOptions.offline`).
|
|
4393
4447
|
* Opened online, `status` or `chat list` started every chat, put the profile's records on the relays again and waited
|
|
@@ -4490,8 +4544,8 @@ async function session(g, options, again = true) {
|
|
|
4490
4544
|
const [, { callApi, startNamedChats }] = await Promise.all([engineHost(), engineApi()]);
|
|
4491
4545
|
const host = await openOneShot(g, options);
|
|
4492
4546
|
if (host instanceof DaemonClient) return throughDaemon(host, anew);
|
|
4493
|
-
const call = (m, p) => {
|
|
4494
|
-
if (options.deferChats && p && typeof p === "object") startNamedChats(host.ctx, p);
|
|
4547
|
+
const call = async (m, p) => {
|
|
4548
|
+
if (options.deferChats && p && typeof p === "object") await startNamedChats(host.ctx, p);
|
|
4495
4549
|
return callApi(host.ctx, m, p ?? {});
|
|
4496
4550
|
};
|
|
4497
4551
|
return {
|
|
@@ -4591,12 +4645,13 @@ var TURNS_WAIT_MS = 6e4;
|
|
|
4591
4645
|
* failed busy, told to start the daemon that was running. A daemon that marked its start is waited for up to
|
|
4592
4646
|
* STARTING_WAIT_MS, and named as the holder. So is a profile a `daemon restart` or `daemon --detach` keeps for the daemon
|
|
4593
4647
|
* it starts (`daemonClaim`): the commands that took the profile in turn in the gap kept that daemon from ever starting.
|
|
4594
|
-
* A `listen` with no daemon opens it the same way, as the daemon (`mode`).
|
|
4648
|
+
* A `listen` with no daemon opens it the same way, as the daemon (`mode`). A wait that goes on past WAIT_NOTICE_MS says
|
|
4649
|
+
* on a terminal what it waits for, once per kind of holder: it said nothing for up to 30 s (60 s behind commands in turn).
|
|
4595
4650
|
*/
|
|
4596
4651
|
async function openOneShot(g, options = {}, mode = "one-shot") {
|
|
4597
4652
|
const { openHost } = await engineHost();
|
|
4598
4653
|
const from = performance.now();
|
|
4599
|
-
let holder, since = from;
|
|
4654
|
+
let holder, since = from, told;
|
|
4600
4655
|
for (;;) try {
|
|
4601
4656
|
return await openHost(g.paths, mode, VERSION, options);
|
|
4602
4657
|
} catch (error) {
|
|
@@ -4617,6 +4672,12 @@ async function openOneShot(g, options = {}, mode = "one-shot") {
|
|
|
4617
4672
|
const held = now - since >= HOLDER_WAIT_MS ? `was not free after ${HOLDER_WAIT_MS / 1e3} s` : `was taken by one process after another for ${TURNS_WAIT_MS / 1e3} s`;
|
|
4618
4673
|
throw new CliError("busy", `Profile ${g.profile} is in use by ${pid ? `process ${pid}, another ghostly command,` : "another ghostly command"} and ${held}: run the commands one after another, or start \`ghostly daemon --detach\` so they can run at once`, error.details);
|
|
4619
4674
|
}
|
|
4675
|
+
const kind = claimed !== null ? "claimed" : starting !== null ? "starting" : "command";
|
|
4676
|
+
if (process.stderr.isTTY && now - from >= 1e3 && told !== kind) {
|
|
4677
|
+
told = kind;
|
|
4678
|
+
const line = claimed !== null ? `profile ${g.profile} is kept for the daemon that process ${claimed} (ghostly daemon) starts: waiting for it (up to ${STARTING_WAIT_MS / 1e3} s` : starting !== null ? `profile ${g.profile}'s daemon (process ${starting}) is starting: waiting for it (up to ${STARTING_WAIT_MS / 1e3} s` : `profile ${g.profile} is in use by ${pid ? `process ${pid}, another ghostly command` : "another ghostly command"}: waiting for it to let go (up to ${HOLDER_WAIT_MS / 1e3} s`;
|
|
4679
|
+
process.stderr.write(`ghostly: ${line}; Ctrl-C stops waiting)\n`);
|
|
4680
|
+
}
|
|
4620
4681
|
await new Promise((resolve) => setTimeout(resolve, Math.min(50 + Math.random() * 50, left)));
|
|
4621
4682
|
}
|
|
4622
4683
|
}
|
|
@@ -4851,7 +4912,7 @@ var SPECIAL = [
|
|
|
4851
4912
|
"confirm-real": o("boolean", "Confirm a Mainnet (real money) spend"),
|
|
4852
4913
|
"show-secret": o("boolean", "Print a call's secrets"),
|
|
4853
4914
|
yes: o("boolean", "Confirm a call that deletes chats or groups"),
|
|
4854
|
-
force: o("boolean", "Send a text that looks like a secret")
|
|
4915
|
+
force: o("boolean", "Send a text that looks like a secret, or remove a chat (or clear the profile) while a delete for everyone has not reached the contact")
|
|
4855
4916
|
}
|
|
4856
4917
|
],
|
|
4857
4918
|
[
|
|
@@ -5172,7 +5233,10 @@ async function profileCommand(sub, argv) {
|
|
|
5172
5233
|
}
|
|
5173
5234
|
case "show":
|
|
5174
5235
|
noMoreThan(0, parsed.positionals, "profile show");
|
|
5175
|
-
print(await withSession(g, (s) => s.call("profile.get"), {
|
|
5236
|
+
print(await withSession(g, (s) => s.call("profile.get"), {
|
|
5237
|
+
offline: true,
|
|
5238
|
+
deferChats: readsNoHistory("profile.get")
|
|
5239
|
+
}));
|
|
5176
5240
|
return;
|
|
5177
5241
|
case "set": {
|
|
5178
5242
|
noMoreThan(0, parsed.positionals, "profile set [--name <name>] [--share-profile | --no-share-profile] [--force]");
|
|
@@ -5195,7 +5259,7 @@ async function profileCommand(sub, argv) {
|
|
|
5195
5259
|
if (parsed.options.passphrase === true) throw new CliError("usage", "The passphrase comes from --passphrase-file or GHOSTLY_BACKUP_PASSPHRASE, never the command line");
|
|
5196
5260
|
if (unsealed && (parsed.options["passphrase-file"] !== void 0 || process.env.GHOSTLY_BACKUP_PASSPHRASE)) throw new CliError("usage", "A passphrase is set (--passphrase-file or GHOSTLY_BACKUP_PASSPHRASE) and --no-passphrase was given: choose one");
|
|
5197
5261
|
const light = parsed.options.light === true ? { light: true } : {};
|
|
5198
|
-
const
|
|
5262
|
+
const resolved = here(out), path = (out.endsWith("/") || out.endsWith(sep)) && !resolved.endsWith(sep) ? `${resolved}${sep}` : resolved;
|
|
5199
5263
|
const params = unsealed ? {
|
|
5200
5264
|
path,
|
|
5201
5265
|
noPassphrase: true,
|
|
@@ -5215,7 +5279,7 @@ async function profileCommand(sub, argv) {
|
|
|
5215
5279
|
if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
|
|
5216
5280
|
noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
5217
5281
|
const file = here(given);
|
|
5218
|
-
const { backupFileProtection, restoreProfile } = await import("./backup-
|
|
5282
|
+
const { backupFileProtection, restoreProfile } = await import("./backup-CgWU7x0T.js");
|
|
5219
5283
|
const protection = await backupFileProtection(file);
|
|
5220
5284
|
const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
|
|
5221
5285
|
if (parsed.options.use) selectProfile(g.home, name);
|
|
@@ -5951,7 +6015,10 @@ async function settingsCommand(sub, argv) {
|
|
|
5951
6015
|
pretty = g.pretty;
|
|
5952
6016
|
if (sub === "get") {
|
|
5953
6017
|
noMoreThan(0, parsed.positionals, "settings get [--show-secret]");
|
|
5954
|
-
print(await withSession(g, (s) => s.call("settings.get", { showSecret: parsed.options["show-secret"] === true }), {
|
|
6018
|
+
print(await withSession(g, (s) => s.call("settings.get", { showSecret: parsed.options["show-secret"] === true }), {
|
|
6019
|
+
offline: true,
|
|
6020
|
+
deferChats: readsNoHistory("settings.get")
|
|
6021
|
+
}));
|
|
5955
6022
|
return;
|
|
5956
6023
|
}
|
|
5957
6024
|
if (sub === "set") {
|
|
@@ -6005,14 +6072,14 @@ async function textCommand(name, argv) {
|
|
|
6005
6072
|
};
|
|
6006
6073
|
if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
|
|
6007
6074
|
if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
|
|
6008
|
-
if (!spec.message) Object.assign(params, (await import("./buttons-
|
|
6075
|
+
if (!spec.message) Object.assign(params, (await import("./buttons-Cco0Agfa.js")).buttonsOf(parsed.options));
|
|
6009
6076
|
print(await withSession(g, (s) => {
|
|
6010
6077
|
if (parsed.options.wait !== void 0) params.wait = parsed.options.wait;
|
|
6011
6078
|
if (parsed.options.timeout !== void 0) params.timeout = parsed.options.timeout;
|
|
6012
6079
|
return s.call(spec.method, params);
|
|
6013
6080
|
}, {
|
|
6014
6081
|
deferGroups: spec.target === "chat",
|
|
6015
|
-
deferChats: spec.target === "chat"
|
|
6082
|
+
deferChats: spec.target === "chat" || oneGroupOnly(spec.method)
|
|
6016
6083
|
}));
|
|
6017
6084
|
}
|
|
6018
6085
|
/**
|
|
@@ -6049,7 +6116,7 @@ async function identityAddCommand(argv) {
|
|
|
6049
6116
|
if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
|
|
6050
6117
|
inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
|
|
6051
6118
|
const items = parsed.options.field ?? [];
|
|
6052
|
-
const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-
|
|
6119
|
+
const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-CE0PpQAE.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
|
|
6053
6120
|
if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
|
|
6054
6121
|
const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
|
|
6055
6122
|
if (warning) process.stderr.write(`ghostly: ${warning}\n`);
|
|
@@ -6155,12 +6222,12 @@ async function tableCommand(name, argv) {
|
|
|
6155
6222
|
return result;
|
|
6156
6223
|
}, {
|
|
6157
6224
|
deferGroups: chatOnly(command.method, params) || newChatOnly(command.method),
|
|
6158
|
-
deferChats: oneChatOnly(command.method, params),
|
|
6225
|
+
deferChats: oneChatOnly(command.method, params) || oneGroupOnly(command.method) || readsNoHistory(command.method),
|
|
6159
6226
|
offline: offlineCall(command.method, params)
|
|
6160
6227
|
});
|
|
6161
6228
|
if (translator) {
|
|
6162
6229
|
try {
|
|
6163
|
-
printAnswer(await (await import("./translate-
|
|
6230
|
+
printAnswer(await (await import("./translate-iQZq4TnY.js")).translateAnswer(result, translator));
|
|
6164
6231
|
} finally {
|
|
6165
6232
|
translator.close();
|
|
6166
6233
|
}
|
|
@@ -6387,4 +6454,4 @@ async function run(argv) {
|
|
|
6387
6454
|
//#endregion
|
|
6388
6455
|
export { run };
|
|
6389
6456
|
|
|
6390
|
-
//# sourceMappingURL=main-
|
|
6457
|
+
//# sourceMappingURL=main-C0PfjKTe.js.map
|