@ghostlytools/cli 1.7.0 → 1.7.2
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 +22 -12
- package/dist/assets/{api-BnCmJLiQ.js → api-CcuCtc1H.js} +2 -2
- package/dist/assets/{api-BIqr8SpM.js → api-tSZELCPQ.js} +133 -40
- package/dist/assets/api-tSZELCPQ.js.map +1 -0
- package/dist/assets/{apiKit-CWalYh1t.js → apiKit-BFk7GAk9.js} +9 -5
- package/dist/assets/{apiKit-CWalYh1t.js.map → apiKit-BFk7GAk9.js.map} +1 -1
- package/dist/assets/{apps-Bx3tXbJ9.js → apps-C5Mi6x9Q.js} +36 -13
- package/dist/assets/apps-C5Mi6x9Q.js.map +1 -0
- package/dist/assets/{apps-_hVUaHIT.js → apps-D6THreq_.js} +1 -1
- package/dist/assets/{arkade-AxrcyS1C.js → arkade-Cz0B9bJ0.js} +2 -2
- package/dist/assets/{arkade-AxrcyS1C.js.map → arkade-Cz0B9bJ0.js.map} +1 -1
- package/dist/assets/{backup-d_XvXpEK.js → backup-A0hIa9GE.js} +1 -1
- package/dist/assets/{backup-Y1V1Yxqr.js → backup-Wb2sm2dd.js} +6 -6
- package/dist/assets/{backup-Y1V1Yxqr.js.map → backup-Wb2sm2dd.js.map} +1 -1
- package/dist/assets/{blobFiles-B6nf0gCG.js → blobFiles-Bckz9fjp.js} +2 -2
- package/dist/assets/{blobFiles-B6nf0gCG.js.map → blobFiles-Bckz9fjp.js.map} +1 -1
- package/dist/assets/buttons-Bxxu3lSk.js +2 -0
- package/dist/assets/{buttons-BiQyQBb0.js → buttons-Cf70NVYq.js} +12 -7
- package/dist/assets/buttons-Cf70NVYq.js.map +1 -0
- package/dist/assets/{daemonProof-ui8jtIw0.js → daemonProof-Bp9lJDxf.js} +2 -2
- package/dist/assets/{daemonProof-ui8jtIw0.js.map → daemonProof-Bp9lJDxf.js.map} +1 -1
- package/dist/assets/{envelope-D3oeVhv8.js → envelope-kQ5kYjVE.js} +2 -2
- package/dist/assets/{envelope-D3oeVhv8.js.map → envelope-kQ5kYjVE.js.map} +1 -1
- package/dist/assets/{errors-CzXgR8Cc.js → errors-mnjSQlbX.js} +2 -1
- package/dist/assets/errors-mnjSQlbX.js.map +1 -0
- package/dist/assets/{fileBytes-BMEBas7S.js → fileBytes-BD0v3rRG.js} +10 -2
- package/dist/assets/{fileBytes-BMEBas7S.js.map → fileBytes-BD0v3rRG.js.map} +1 -1
- package/dist/assets/{fileBytes-CtwagJ8h.js → fileBytes-OolN5cSY.js} +1 -1
- package/dist/assets/{fileBytes-CFNrRfcl.js → fileBytes-_fd-2JRY.js} +2 -2
- package/dist/assets/{fileBytes-CFNrRfcl.js.map → fileBytes-_fd-2JRY.js.map} +1 -1
- package/dist/assets/fileBytesIdb-CsSQcSxD.js +2 -0
- package/dist/assets/{fileBytesIdb-BXAN7i-N.js → fileBytesIdb-NtA8r9EM.js} +2 -2
- package/dist/assets/{fileBytesIdb-BXAN7i-N.js.map → fileBytesIdb-NtA8r9EM.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-Do1Vpkis.js → fileBytesOpfs-B8fJwkwM.js} +3 -3
- package/dist/assets/{fileBytesOpfs-Do1Vpkis.js.map → fileBytesOpfs-B8fJwkwM.js.map} +1 -1
- package/dist/assets/{ghostly_iroh_web-BXCsSxxo.js → ghostly_iroh_web-CO0onry8.js} +33 -27
- package/dist/assets/ghostly_iroh_web-CO0onry8.js.map +1 -0
- package/dist/assets/ghostly_iroh_web_bg.wasm +0 -0
- package/dist/assets/{groupFiles-DU1wMGI9.js → groupFiles-D9Ttlm3M.js} +41 -25
- package/dist/assets/groupFiles-D9Ttlm3M.js.map +1 -0
- package/dist/assets/{host-DDMQfR7B.js → host-DpypH-fR.js} +44 -21
- package/dist/assets/host-DpypH-fR.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-B2v8eqRd.js → hyperdhtRelay-D1rj84v2.js} +2 -2
- package/dist/assets/{hyperdhtRelay-B2v8eqRd.js.map → hyperdhtRelay-D1rj84v2.js.map} +1 -1
- package/dist/assets/{irohWeb-9RVIbF_l.js → irohWeb-BTSlWgEX.js} +3 -3
- package/dist/assets/{irohWeb-9RVIbF_l.js.map → irohWeb-BTSlWgEX.js.map} +1 -1
- package/dist/assets/{main-BNwNEPEy.js → main-BwgoQZVu.js} +270 -97
- package/dist/assets/main-BwgoQZVu.js.map +1 -0
- package/dist/assets/{mainline-RXv5_Fby.js → mainline-B1urhbEZ.js} +27 -8
- package/dist/assets/mainline-B1urhbEZ.js.map +1 -0
- package/dist/assets/{networkReason-CIn4yN9h.js → networkReason-D2Z0BdIj.js} +2 -2
- package/dist/assets/{networkReason-CIn4yN9h.js.map → networkReason-D2Z0BdIj.js.map} +1 -1
- package/dist/assets/{nwc-BNPzuT-6.js → nwc-T2aUK6bi.js} +3 -3
- package/dist/assets/{nwc-BNPzuT-6.js.map → nwc-T2aUK6bi.js.map} +1 -1
- package/dist/assets/{nwcProvider-C9Y6PUNC.js → nwcProvider-Dz-ty_DE.js} +2 -2
- package/dist/assets/{nwcProvider-C9Y6PUNC.js.map → nwcProvider-Dz-ty_DE.js.map} +1 -1
- package/dist/assets/{profiles-CEnZfN78.js → profiles-C6XWqre5.js} +92 -20
- package/dist/assets/profiles-C6XWqre5.js.map +1 -0
- package/dist/assets/{registry-B9aYHNNf.js → registry-Bazitl0a.js} +3 -3
- package/dist/assets/{registry-B9aYHNNf.js.map → registry-Bazitl0a.js.map} +1 -1
- package/dist/assets/{registry-DOkDhUAu.js → registry-BlSTJlbv.js} +1 -1
- package/dist/assets/{resolve-imkCgogd.js → resolve-Bx1Eeg-w.js} +2 -2
- package/dist/assets/{resolve-imkCgogd.js.map → resolve-Bx1Eeg-w.js.map} +1 -1
- package/dist/assets/{server-CB9_JuWZ.js → server-CnPj9wWh.js} +661 -229
- package/dist/assets/server-CnPj9wWh.js.map +1 -0
- package/dist/assets/{src-BBG_NwMc.js → src-BsznF3XG.js} +305 -83
- package/dist/assets/src-BsznF3XG.js.map +1 -0
- package/dist/assets/{translate-BcP139SV.js → translate-cDBotA-b.js} +11 -11
- package/dist/assets/{translate-BcP139SV.js.map → translate-cDBotA-b.js.map} +1 -1
- package/dist/assets/types-C4_KafL_.js.map +1 -1
- package/dist/assets/{usdt-C5Gf9-IC.js → usdt-DxxLdG60.js} +3 -3
- package/dist/assets/{usdt-C5Gf9-IC.js.map → usdt-DxxLdG60.js.map} +1 -1
- package/dist/assets/{words-ZUiQo4yo.js → words-qH8gGtmc.js} +2 -2
- package/dist/assets/{words-ZUiQo4yo.js.map → words-qH8gGtmc.js.map} +1 -1
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-BIqr8SpM.js.map +0 -1
- package/dist/assets/apps-Bx3tXbJ9.js.map +0 -1
- package/dist/assets/buttons-BiQyQBb0.js.map +0 -1
- package/dist/assets/buttons-LO3Ql1Hd.js +0 -2
- package/dist/assets/errors-CzXgR8Cc.js.map +0 -1
- package/dist/assets/fileBytesIdb-C20oXDdr.js +0 -2
- package/dist/assets/ghostly_iroh_web-BXCsSxxo.js.map +0 -1
- package/dist/assets/groupFiles-DU1wMGI9.js.map +0 -1
- package/dist/assets/host-DDMQfR7B.js.map +0 -1
- package/dist/assets/main-BNwNEPEy.js.map +0 -1
- package/dist/assets/mainline-RXv5_Fby.js.map +0 -1
- package/dist/assets/profiles-CEnZfN78.js.map +0 -1
- package/dist/assets/server-CB9_JuWZ.js.map +0 -1
- package/dist/assets/src-BBG_NwMc.js.map +0 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Ga as
|
|
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-
|
|
1
|
+
import { Ga as CRON_LINE, Ja as PR_STATES, Ka as ITEM_STATES, Qa as TASK_STATUSES, Wn as GROUP_FILE_LIMITS, Xa as RUN_RESULTS, Ya as ROUTINE_STATES, Za as STATUS_CARD_LIMITS, ao as statusCardBytes, da as VOICE_LIMITS, no as cardUrl, qa as PR_CHECKS, to as cardLine } from "./src-BsznF3XG.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-qH8gGtmc.js";
|
|
3
|
+
import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-mnjSQlbX.js";
|
|
4
|
+
import { p as namedByThem, t as CONTACT_KEY } from "./apiKit-BFk7GAk9.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-C6XWqre5.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-Bp9lJDxf.js";
|
|
7
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";
|
|
@@ -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.7.
|
|
15
|
+
version: "1.7.2",
|
|
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",
|
|
@@ -492,7 +492,7 @@ var groupWait = {
|
|
|
492
492
|
/** `listen`, `events` and `chat history`: received messages with `translation: { from, text }` (translate.ts). */
|
|
493
493
|
var translate = {
|
|
494
494
|
type: "string",
|
|
495
|
-
description: "
|
|
495
|
+
description: "Not in this build yet (no language detector): messages print untranslated. Meant to add a translation into this language (en, pt...) to received messages, made on this machine"
|
|
496
496
|
};
|
|
497
497
|
var net = {
|
|
498
498
|
type: "string",
|
|
@@ -587,6 +587,19 @@ var showInvite = { "show-secret": {
|
|
|
587
587
|
} };
|
|
588
588
|
var secret = (options) => options["show-secret"] === true ? { showSecret: true } : {};
|
|
589
589
|
/**
|
|
590
|
+
* `--kind` of the typing commands: another word is a usage error (exit 2) before the profile opens, not the API's
|
|
591
|
+
* "kind must be one of" (exit 1). The words are core's TYPING_KINDS, written out: the package is not loaded here.
|
|
592
|
+
*/
|
|
593
|
+
var typingKind = {
|
|
594
|
+
type: "string",
|
|
595
|
+
choices: [
|
|
596
|
+
"typing",
|
|
597
|
+
"recording",
|
|
598
|
+
"thinking"
|
|
599
|
+
],
|
|
600
|
+
description: "typing (default), recording (a voice note) or thinking"
|
|
601
|
+
};
|
|
602
|
+
/**
|
|
590
603
|
* `--for` of the typing commands: the seconds it is kept on, 1 to 600, and never with `--stop`. A usage error (exit 2)
|
|
591
604
|
* that names the flag: before, the API's own check answered ("for must be a number from 1 to 600", exit 1).
|
|
592
605
|
*/
|
|
@@ -597,6 +610,32 @@ function typingFor(options) {
|
|
|
597
610
|
if (options.stop === true) throw new CliError("usage", "--for keeps it on: not with --stop");
|
|
598
611
|
return seconds;
|
|
599
612
|
}
|
|
613
|
+
/** The ranges the API takes (api.ts, files.ts): the most minutes of a `--hold` (a week, HOLD_MAX_MINUTES), seconds. */
|
|
614
|
+
var HOLD_MINUTES = 10080;
|
|
615
|
+
var WAIT_SECONDS = 3600;
|
|
616
|
+
var LONG_WAIT_SECONDS = 86400;
|
|
617
|
+
var HISTORY_LIMIT = 1e4;
|
|
618
|
+
/**
|
|
619
|
+
* A number flag out of the range the API takes: a usage error (exit 2) that names the flag, before the profile opens.
|
|
620
|
+
* Before, the API's own check answered once it had opened (a one-shot went online first), in its parameter's words
|
|
621
|
+
* ("hold must be a number from 0 to 10080", exit 1). The API keeps its check for socket callers.
|
|
622
|
+
*/
|
|
623
|
+
function inRange(options, flag, what, min, max, whole = false) {
|
|
624
|
+
const value = options[flag];
|
|
625
|
+
if (value === void 0) return void 0;
|
|
626
|
+
if (typeof value !== "number" || !(value >= min && value <= max) || whole && !Number.isInteger(value)) throw new CliError("usage", `--${flag} takes ${what} from ${min} to ${max}, not ${JSON.stringify(value)}`);
|
|
627
|
+
return value;
|
|
628
|
+
}
|
|
629
|
+
/** `--timeout` of a command that waits: seconds, up to an hour (a send, a card, a button) or a day (`chat wait`, a file). */
|
|
630
|
+
var timeout = (options, max = WAIT_SECONDS) => inRange(options, "timeout", "a number of seconds", 1, max);
|
|
631
|
+
/** `--limit` of a history: messages per page. */
|
|
632
|
+
var pageLimit = (options) => inRange(options, "limit", "a whole number", 1, HISTORY_LIMIT, true);
|
|
633
|
+
/** `--since` of `events` and `listen`: a seq, a whole number from 0 (a negative one replayed a made-up gap first). */
|
|
634
|
+
function since(options) {
|
|
635
|
+
const value = options.since;
|
|
636
|
+
if (value !== void 0 && !(Number.isSafeInteger(value) && value >= 0)) throw new CliError("usage", `--since takes a seq from 0 up, not ${JSON.stringify(value)}`);
|
|
637
|
+
return value;
|
|
638
|
+
}
|
|
600
639
|
/**
|
|
601
640
|
* A time given as digits: milliseconds. Unix seconds (from 1e9, 2001, up to 1e11, which as milliseconds would be 1970
|
|
602
641
|
* to 1973) are refused with the milliseconds they mean: before, they were read as January 1970 without a word.
|
|
@@ -717,6 +756,16 @@ function itemOf(value) {
|
|
|
717
756
|
text
|
|
718
757
|
};
|
|
719
758
|
}
|
|
759
|
+
/**
|
|
760
|
+
* A card's fields past the bytes a card takes in all (`STATUS_CARD_LIMITS.bytes`, its JSON as UTF-8): a usage error
|
|
761
|
+
* (exit 2) with its size and what to cut. Every flag can be within its own bound and the card not: 20 items of 200
|
|
762
|
+
* characters past Latin (3 bytes each) take 12 KiB. Before, it failed as `bad_request` (exit 1), the whole card in it.
|
|
763
|
+
*/
|
|
764
|
+
function cardBytes(fields, flags) {
|
|
765
|
+
const bytes = statusCardBytes(fields);
|
|
766
|
+
if (bytes > STATUS_CARD_LIMITS.bytes) throw new CliError("usage", `The card takes ${bytes} bytes, and holds at most ${STATUS_CARD_LIMITS.bytes} in all (a character past Latin takes 2 to 4): give shorter or fewer ${flags}`);
|
|
767
|
+
return fields;
|
|
768
|
+
}
|
|
720
769
|
/** `--progress`, `--left`: a percent, or a usage error that names the flag. */
|
|
721
770
|
function percent(options, flag) {
|
|
722
771
|
const value = options[flag];
|
|
@@ -788,7 +837,7 @@ function taskFields(options) {
|
|
|
788
837
|
set("parent", options.parent);
|
|
789
838
|
const links = cardLinks(options.link);
|
|
790
839
|
if (links) fields.links = links;
|
|
791
|
-
return fields;
|
|
840
|
+
return cardBytes(fields, "--item, --step, --link or --json");
|
|
792
841
|
}
|
|
793
842
|
/**
|
|
794
843
|
* The fields a new card cannot go without, given as a flag or in `--json`: a usage error (exit 2) that names the
|
|
@@ -860,7 +909,7 @@ function routineFields(options) {
|
|
|
860
909
|
if (next !== void 0) fields.nextRunAt = next;
|
|
861
910
|
const links = cardLinks(options.link);
|
|
862
911
|
if (links) fields.links = links;
|
|
863
|
-
return fields;
|
|
912
|
+
return cardBytes(fields, "--name, --schedule, --link or --json");
|
|
864
913
|
}
|
|
865
914
|
/** Options a routine command takes, beside `cardOptions`. */
|
|
866
915
|
var routineOptions = {
|
|
@@ -914,7 +963,7 @@ var taskOptions = {
|
|
|
914
963
|
},
|
|
915
964
|
item: {
|
|
916
965
|
type: "list",
|
|
917
|
-
description: "A step or log line, state:text with state pending, running, done, failed or skipped (text alone: pending). A lowercase word before the first colon must be one of them; pending:fix: x keeps the colon. The list replaces the card's (up to 20)"
|
|
966
|
+
description: "A step or log line, state:text with state pending, running, done, failed or skipped (text alone: pending). A lowercase word before the first colon must be one of them; pending:fix: x keeps the colon. The list replaces the card's (up to 20; the card holds at most 8 KiB in all, and a character past Latin takes 2 to 4 bytes)"
|
|
918
967
|
},
|
|
919
968
|
branch: {
|
|
920
969
|
type: "string",
|
|
@@ -997,7 +1046,7 @@ function usageFields(options) {
|
|
|
997
1046
|
const resets = cardTime(options.resets, "resets");
|
|
998
1047
|
if (resets !== void 0) fields.resetsAt = resets;
|
|
999
1048
|
if (Array.isArray(options.also) && options.also.length) fields.windows = options.also.map(usageWindowOf);
|
|
1000
|
-
return fields;
|
|
1049
|
+
return cardBytes(fields, "--json");
|
|
1001
1050
|
}
|
|
1002
1051
|
/** Options `usage send` takes. */
|
|
1003
1052
|
var usageOptions = {
|
|
@@ -1101,7 +1150,7 @@ var commands$8 = {
|
|
|
1101
1150
|
description: "Replace the three files when they are there"
|
|
1102
1151
|
}
|
|
1103
1152
|
},
|
|
1104
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1153
|
+
run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).initApp(a.dir, {
|
|
1105
1154
|
name: options.name,
|
|
1106
1155
|
title: options.title,
|
|
1107
1156
|
force: options.force === true
|
|
@@ -1124,7 +1173,7 @@ var commands$8 = {
|
|
|
1124
1173
|
},
|
|
1125
1174
|
"app publish": {
|
|
1126
1175
|
method: "app.publish",
|
|
1127
|
-
usage: "app publish <dir> --key <file> [--out <file>]",
|
|
1176
|
+
usage: "app publish <dir> --key <file> [--out <file>] [--sequence n]",
|
|
1128
1177
|
summary: "Bundle and sign an app (WISP 1200): <dir>/ghostly-app.json and every other file in <dir> become one .ghostlyapp, its sequence one more than the bundle at --out (default <dir>/app.ghostlyapp)",
|
|
1129
1178
|
args: ["dir"],
|
|
1130
1179
|
options: {
|
|
@@ -1141,7 +1190,7 @@ var commands$8 = {
|
|
|
1141
1190
|
description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
|
|
1142
1191
|
}
|
|
1143
1192
|
},
|
|
1144
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1193
|
+
run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
|
|
1145
1194
|
},
|
|
1146
1195
|
"app revoke": {
|
|
1147
1196
|
method: "app.revoke",
|
|
@@ -1174,7 +1223,7 @@ var commands$8 = {
|
|
|
1174
1223
|
description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
|
|
1175
1224
|
}
|
|
1176
1225
|
},
|
|
1177
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1226
|
+
run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>]"), {
|
|
1178
1227
|
digests: options.digest,
|
|
1179
1228
|
upTo: options["up-to"],
|
|
1180
1229
|
reason: options.reason,
|
|
@@ -1235,7 +1284,7 @@ var commands$8 = {
|
|
|
1235
1284
|
usage: "app verify <bundle|url>",
|
|
1236
1285
|
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",
|
|
1237
1286
|
args: ["bundle"],
|
|
1238
|
-
run: async (_, a) => (await import("./apps-
|
|
1287
|
+
run: async (_, a) => (await import("./apps-D6THreq_.js")).verifyApp(a.bundle)
|
|
1239
1288
|
},
|
|
1240
1289
|
"store sign": {
|
|
1241
1290
|
method: "store.sign",
|
|
@@ -1252,7 +1301,7 @@ var commands$8 = {
|
|
|
1252
1301
|
description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
|
|
1253
1302
|
}
|
|
1254
1303
|
},
|
|
1255
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1304
|
+
run: async ({ options }, a) => (await import("./apps-D6THreq_.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
|
|
1256
1305
|
}
|
|
1257
1306
|
};
|
|
1258
1307
|
//#endregion
|
|
@@ -1365,7 +1414,7 @@ var commands$6 = {
|
|
|
1365
1414
|
message: a.message,
|
|
1366
1415
|
button: a.button,
|
|
1367
1416
|
wait: options.wait,
|
|
1368
|
-
timeout: options
|
|
1417
|
+
timeout: timeout(options)
|
|
1369
1418
|
})
|
|
1370
1419
|
},
|
|
1371
1420
|
"button update": {
|
|
@@ -1408,7 +1457,7 @@ var commands$6 = {
|
|
|
1408
1457
|
text: options.text,
|
|
1409
1458
|
force: options.force === true,
|
|
1410
1459
|
wait: options.wait,
|
|
1411
|
-
timeout: options
|
|
1460
|
+
timeout: timeout(options)
|
|
1412
1461
|
};
|
|
1413
1462
|
}
|
|
1414
1463
|
},
|
|
@@ -1430,7 +1479,7 @@ var commands$6 = {
|
|
|
1430
1479
|
} },
|
|
1431
1480
|
params: ({ options }, { chat }) => ({
|
|
1432
1481
|
chat,
|
|
1433
|
-
hold: options
|
|
1482
|
+
hold: inRange(options, "hold", "a number of minutes", 0, HOLD_MINUTES)
|
|
1434
1483
|
})
|
|
1435
1484
|
},
|
|
1436
1485
|
"chat history": {
|
|
@@ -1455,7 +1504,7 @@ var commands$6 = {
|
|
|
1455
1504
|
},
|
|
1456
1505
|
params: ({ options }, { chat }) => ({
|
|
1457
1506
|
chat,
|
|
1458
|
-
limit: options
|
|
1507
|
+
limit: pageLimit(options),
|
|
1459
1508
|
before: cursor(options.before, "before"),
|
|
1460
1509
|
after: cursor(options.after, "after")
|
|
1461
1510
|
})
|
|
@@ -1553,7 +1602,7 @@ var commands$6 = {
|
|
|
1553
1602
|
params: ({ options }, { chat }) => ({
|
|
1554
1603
|
chat,
|
|
1555
1604
|
until: options.until,
|
|
1556
|
-
timeout: options
|
|
1605
|
+
timeout: timeout(options, LONG_WAIT_SECONDS)
|
|
1557
1606
|
})
|
|
1558
1607
|
},
|
|
1559
1608
|
"forward": {
|
|
@@ -1586,7 +1635,7 @@ var commands$6 = {
|
|
|
1586
1635
|
to: options.to,
|
|
1587
1636
|
force: options.force === true,
|
|
1588
1637
|
wait: options.wait,
|
|
1589
|
-
timeout: options
|
|
1638
|
+
timeout: timeout(options)
|
|
1590
1639
|
};
|
|
1591
1640
|
}
|
|
1592
1641
|
},
|
|
@@ -1690,7 +1739,7 @@ var commands$6 = {
|
|
|
1690
1739
|
},
|
|
1691
1740
|
"routine send": {
|
|
1692
1741
|
method: "routine.send",
|
|
1693
|
-
usage: "routine send <chat|group> --name <name> --schedule \"every day 01:00\" [--cron \"0 1 * * *\"] [--state active|paused] [--next <time>] [--run ok|failed|skipped[:summary]] [--link url]... [--id id] [--json json|-|file] [--force] [--wait none|sent|delivered] [--timeout s]",
|
|
1742
|
+
usage: "routine send <chat|group> --name <name> --schedule \"every day 01:00\" [--cron \"0 1 * * *\"] [--state active|paused] [--next <time>] [--run ok|failed|skipped[:summary]] [--link url]... [--id id] [--text <text>] [--json json|-|file] [--force] [--wait none|sent|delivered] [--timeout s]",
|
|
1694
1743
|
summary: "Send a routine card (something a bot runs on a schedule: its last run and the next) to a chat or group",
|
|
1695
1744
|
args: ["chat"],
|
|
1696
1745
|
options: {
|
|
@@ -1709,12 +1758,12 @@ var commands$6 = {
|
|
|
1709
1758
|
text: options.text,
|
|
1710
1759
|
force: options.force === true,
|
|
1711
1760
|
wait: options.wait,
|
|
1712
|
-
timeout: options
|
|
1761
|
+
timeout: timeout(options)
|
|
1713
1762
|
})
|
|
1714
1763
|
},
|
|
1715
1764
|
"routine update": {
|
|
1716
1765
|
method: "routine.update",
|
|
1717
|
-
usage: "routine update <chat|group> <routine> [--run ok|failed|skipped[:summary]] [--next <time>] [--state active|paused] [--schedule ...] [--json json|-|file] [--force] [--wait none|confirmed|sent] [--timeout s]",
|
|
1766
|
+
usage: "routine update <chat|group> <routine> [--run ok|failed|skipped[:summary]] [--next <time>] [--state active|paused] [--name <name>] [--schedule ...] [--cron ...] [--link url]... [--text <text>] [--json json|-|file] [--force] [--wait none|confirmed|sent] [--timeout s]",
|
|
1718
1767
|
summary: "Update a routine card you sent: record a run, the next one, a pause (at most one update per 2.5 s; sooner ones merge)",
|
|
1719
1768
|
args: ["chat", "routine"],
|
|
1720
1769
|
options: {
|
|
@@ -1738,7 +1787,7 @@ var commands$6 = {
|
|
|
1738
1787
|
text: options.text,
|
|
1739
1788
|
force: options.force === true,
|
|
1740
1789
|
wait: options.wait,
|
|
1741
|
-
timeout: options
|
|
1790
|
+
timeout: timeout(options)
|
|
1742
1791
|
})
|
|
1743
1792
|
},
|
|
1744
1793
|
"saved add": {
|
|
@@ -1768,7 +1817,7 @@ var commands$6 = {
|
|
|
1768
1817
|
},
|
|
1769
1818
|
"task send": {
|
|
1770
1819
|
method: "task.send",
|
|
1771
|
-
usage: "task send <chat|group> --title <title> [--status s] [--progress n | --steps a/b] [--step \"...\"] [--item state:text]... [--pr-url url --pr-number n --additions n --deletions n --files n --pr-state s --pr-checks c] [--branch b] [--tag label]... [--parent task] [--link url]... [--id id] [--json json|-|file] [--force] [--wait none|sent|delivered] [--timeout s]",
|
|
1820
|
+
usage: "task send <chat|group> --title <title> [--status s] [--progress n | --steps a/b] [--step \"...\"] [--item state:text]... [--pr-url url --pr-number n --additions n --deletions n --files n --pr-state s --pr-checks c] [--branch b] [--tag label]... [--parent task] [--link url]... [--id id] [--text <text>] [--json json|-|file] [--force] [--wait none|sent|delivered] [--timeout s]",
|
|
1772
1821
|
summary: "Send a task card (a bot's work: status, progress, its PR) to a chat or group; prints its id and message",
|
|
1773
1822
|
args: ["chat"],
|
|
1774
1823
|
options: {
|
|
@@ -1786,12 +1835,12 @@ var commands$6 = {
|
|
|
1786
1835
|
text: options.text,
|
|
1787
1836
|
force: options.force === true,
|
|
1788
1837
|
wait: options.wait,
|
|
1789
|
-
timeout: options
|
|
1838
|
+
timeout: timeout(options)
|
|
1790
1839
|
})
|
|
1791
1840
|
},
|
|
1792
1841
|
"task update": {
|
|
1793
1842
|
method: "task.update",
|
|
1794
|
-
usage: "task update <chat|group> <task> [--status s] [--progress n | --steps a/b] [--step \"...\"] [--item state:text]... [--pr-url
|
|
1843
|
+
usage: "task update <chat|group> <task> [--title <title>] [--status s] [--progress n | --steps a/b] [--step \"...\"] [--item state:text]... [--pr-url url] [--pr-number n] [--additions n] [--deletions n] [--files n] [--pr-state s] [--pr-checks c] [--branch b] [--tag label]... [--parent task] [--link url]... [--text <text>] [--json json|-|file] [--force] [--wait none|confirmed|sent] [--timeout s]",
|
|
1795
1844
|
summary: "Update a task card you sent: the fields given, merged over it (at most one update per 2.5 s; sooner ones merge)",
|
|
1796
1845
|
args: ["chat", "task"],
|
|
1797
1846
|
options: {
|
|
@@ -1814,7 +1863,7 @@ var commands$6 = {
|
|
|
1814
1863
|
text: options.text,
|
|
1815
1864
|
force: options.force === true,
|
|
1816
1865
|
wait: options.wait,
|
|
1817
|
-
timeout: options
|
|
1866
|
+
timeout: timeout(options)
|
|
1818
1867
|
})
|
|
1819
1868
|
},
|
|
1820
1869
|
"typing": {
|
|
@@ -1827,10 +1876,7 @@ var commands$6 = {
|
|
|
1827
1876
|
type: "boolean",
|
|
1828
1877
|
description: "Say you stopped"
|
|
1829
1878
|
},
|
|
1830
|
-
kind:
|
|
1831
|
-
type: "string",
|
|
1832
|
-
description: "typing (default), recording (a voice note) or thinking"
|
|
1833
|
-
},
|
|
1879
|
+
kind: typingKind,
|
|
1834
1880
|
status: {
|
|
1835
1881
|
type: "string",
|
|
1836
1882
|
description: "A short line shown instead, e.g. \"Transcribing your audio…\" (40 characters, no links)"
|
|
@@ -1850,7 +1896,7 @@ var commands$6 = {
|
|
|
1850
1896
|
},
|
|
1851
1897
|
"usage send": {
|
|
1852
1898
|
method: "usage.send",
|
|
1853
|
-
usage: "usage send [<chat|group>] [--all] --left <percent> [--window \"5 h\"] [--resets <time>] [--label Claude] [--account <name>] [--also week=80@<time>]... [--used n --limit n] [--id id] [--json json|-|file] [--force] [--wait none|sent] [--timeout s]",
|
|
1899
|
+
usage: "usage send [<chat|group>] [--all] --left <percent> [--window \"5 h\"] [--resets <time>] [--label Claude] [--account <name>] [--also week=80@<time>]... [--used n --limit n] [--id id] [--text <text>] [--json json|-|file] [--force] [--wait none|sent] [--timeout s]",
|
|
1854
1900
|
summary: "Say how much of your quota is left (a bot's usage card, one per chat, updated in place); --all for every 1:1 chat",
|
|
1855
1901
|
args: ["chat?"],
|
|
1856
1902
|
options: {
|
|
@@ -1866,7 +1912,7 @@ var commands$6 = {
|
|
|
1866
1912
|
text: options.text,
|
|
1867
1913
|
force: options.force === true,
|
|
1868
1914
|
wait: options.wait,
|
|
1869
|
-
timeout: options
|
|
1915
|
+
timeout: timeout(options)
|
|
1870
1916
|
};
|
|
1871
1917
|
}
|
|
1872
1918
|
}
|
|
@@ -1987,7 +2033,7 @@ var commands$5 = {
|
|
|
1987
2033
|
options: {
|
|
1988
2034
|
dir: {
|
|
1989
2035
|
type: "string",
|
|
1990
|
-
description: "Into this folder, under its own name"
|
|
2036
|
+
description: "Into this folder, under its own name (a voice message: the name Ghostly makes for it, \"(2)\" when taken)"
|
|
1991
2037
|
},
|
|
1992
2038
|
path: {
|
|
1993
2039
|
type: "string",
|
|
@@ -2018,7 +2064,7 @@ var commands$5 = {
|
|
|
2018
2064
|
path: here(options.path),
|
|
2019
2065
|
force: options.force === true,
|
|
2020
2066
|
wait: options.wait === true ? true : void 0,
|
|
2021
|
-
timeout: options
|
|
2067
|
+
timeout: timeout(options, LONG_WAIT_SECONDS)
|
|
2022
2068
|
};
|
|
2023
2069
|
}
|
|
2024
2070
|
},
|
|
@@ -2068,7 +2114,7 @@ var commands$5 = {
|
|
|
2068
2114
|
params: ({ options }, a) => ({
|
|
2069
2115
|
chat: a.chat,
|
|
2070
2116
|
file: a.file,
|
|
2071
|
-
timeout: options
|
|
2117
|
+
timeout: timeout(options, LONG_WAIT_SECONDS)
|
|
2072
2118
|
})
|
|
2073
2119
|
}
|
|
2074
2120
|
};
|
|
@@ -2087,7 +2133,7 @@ var commands$4 = {
|
|
|
2087
2133
|
},
|
|
2088
2134
|
translate
|
|
2089
2135
|
},
|
|
2090
|
-
params: ({ options }) => ({ since: options
|
|
2136
|
+
params: ({ options }) => ({ since: since(options) ?? 0 })
|
|
2091
2137
|
},
|
|
2092
2138
|
"profile picture": {
|
|
2093
2139
|
method: "profile.picture",
|
|
@@ -2192,7 +2238,7 @@ var commands$3 = {
|
|
|
2192
2238
|
},
|
|
2193
2239
|
params: ({ options }, { group }) => ({
|
|
2194
2240
|
group,
|
|
2195
|
-
limit: options
|
|
2241
|
+
limit: pageLimit(options),
|
|
2196
2242
|
before: cursor(options.before, "before"),
|
|
2197
2243
|
after: cursor(options.after, "after")
|
|
2198
2244
|
})
|
|
@@ -2391,10 +2437,7 @@ var commands$3 = {
|
|
|
2391
2437
|
type: "boolean",
|
|
2392
2438
|
description: "Say you stopped"
|
|
2393
2439
|
},
|
|
2394
|
-
kind:
|
|
2395
|
-
type: "string",
|
|
2396
|
-
description: "typing (default), recording (a voice note) or thinking"
|
|
2397
|
-
},
|
|
2440
|
+
kind: typingKind,
|
|
2398
2441
|
status: {
|
|
2399
2442
|
type: "string",
|
|
2400
2443
|
description: "A short line shown instead, e.g. \"Reading the thread…\" (40 characters, no links)"
|
|
@@ -2545,9 +2588,9 @@ var commands$2 = {
|
|
|
2545
2588
|
var commands$1 = {
|
|
2546
2589
|
"chat accept": {
|
|
2547
2590
|
method: "chat.accept",
|
|
2548
|
-
usage: "chat accept <chat> <method> [--off] [--networks mainnet,testnet]",
|
|
2549
|
-
summary: "Which ways of paying a chat takes",
|
|
2550
|
-
args: ["chat", "method"],
|
|
2591
|
+
usage: "chat accept <chat> [<method> [--off] [--networks mainnet,testnet]]",
|
|
2592
|
+
summary: "Which ways of paying a chat takes (no method: the ones it takes now)",
|
|
2593
|
+
args: ["chat", "method?"],
|
|
2551
2594
|
words: { method: CHAT_METHODS },
|
|
2552
2595
|
options: {
|
|
2553
2596
|
off: {
|
|
@@ -2559,12 +2602,16 @@ var commands$1 = {
|
|
|
2559
2602
|
description: "Comma-separated networks it is taken on"
|
|
2560
2603
|
}
|
|
2561
2604
|
},
|
|
2562
|
-
params: ({ options }, a) =>
|
|
2563
|
-
|
|
2564
|
-
method: a.
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2605
|
+
params: ({ options }, a) => {
|
|
2606
|
+
if (a.method === void 0 && (options.off !== void 0 || options.networks !== void 0)) throw new CliError("usage", "--off and --networks change one method: ghostly chat accept <chat> <method> [--off] [--networks mainnet,testnet]");
|
|
2607
|
+
if (a.method === void 0) return { chat: a.chat };
|
|
2608
|
+
return {
|
|
2609
|
+
chat: a.chat,
|
|
2610
|
+
method: a.method,
|
|
2611
|
+
on: options.off !== true,
|
|
2612
|
+
networks: typeof options.networks === "string" ? options.networks.split(",").map((n) => n.trim()).filter(Boolean) : void 0
|
|
2613
|
+
};
|
|
2614
|
+
}
|
|
2568
2615
|
},
|
|
2569
2616
|
"chat pay": {
|
|
2570
2617
|
method: "chat.pay",
|
|
@@ -2820,7 +2867,7 @@ var commands$1 = {
|
|
|
2820
2867
|
},
|
|
2821
2868
|
params: ({ options }) => ({
|
|
2822
2869
|
network: options.network,
|
|
2823
|
-
limit: options
|
|
2870
|
+
limit: pageLimit(options)
|
|
2824
2871
|
})
|
|
2825
2872
|
},
|
|
2826
2873
|
"wallet list": {
|
|
@@ -2847,7 +2894,7 @@ var commands$1 = {
|
|
|
2847
2894
|
},
|
|
2848
2895
|
"wallet redeem": {
|
|
2849
2896
|
method: "wallet.redeem",
|
|
2850
|
-
usage: "wallet redeem [<cashu-token>]",
|
|
2897
|
+
usage: "wallet redeem [<cashu-token> | -]",
|
|
2851
2898
|
summary: "Take the ecash of a Cashu token (its mint must be one of yours); the token on stdin keeps it out of ps",
|
|
2852
2899
|
args: ["token?"],
|
|
2853
2900
|
params: (_, { token }) => ({ token })
|
|
@@ -2929,7 +2976,7 @@ var commands = {
|
|
|
2929
2976
|
params: ({ options }, a) => ({
|
|
2930
2977
|
chat: a.chat,
|
|
2931
2978
|
service: a.service,
|
|
2932
|
-
port: options
|
|
2979
|
+
port: inRange(options, "port", "a whole number", 0, 65535, true)
|
|
2933
2980
|
})
|
|
2934
2981
|
},
|
|
2935
2982
|
"service peer": {
|
|
@@ -2986,7 +3033,7 @@ var TEXT_COMMANDS = {
|
|
|
2986
3033
|
method: "chat.send",
|
|
2987
3034
|
target: "chat",
|
|
2988
3035
|
args: ["chat", "text...?"],
|
|
2989
|
-
usage: "send <chat> [text...] [--reply <message>] [--button id:Label]... [--style id=primary|neutral|danger]... [--once] [--id id] [--stdin] [--force] [--wait none|sent|delivered]",
|
|
3036
|
+
usage: "send <chat> [text...] [--reply <message>] [--button id:Label]... [--style id=primary|neutral|danger]... [--once] [--id id] [--stdin] [--force] [--wait none|sent|delivered] [--timeout s]",
|
|
2990
3037
|
summary: "Send a message (text from arguments or stdin); --button puts buttons under it, each label its own (case aside)",
|
|
2991
3038
|
options: {
|
|
2992
3039
|
stdin: {
|
|
@@ -3008,7 +3055,7 @@ var TEXT_COMMANDS = {
|
|
|
3008
3055
|
"message",
|
|
3009
3056
|
"text...?"
|
|
3010
3057
|
],
|
|
3011
|
-
usage: "edit <chat> <message> [text... | --text <text> | --stdin] [--force] [--wait none|confirmed]",
|
|
3058
|
+
usage: "edit <chat> <message> [text... | --text <text> | --stdin] [--force] [--wait none|confirmed] [--timeout s]",
|
|
3012
3059
|
summary: "Replace the text of a message you sent (the id send gave; in a group, group edit)",
|
|
3013
3060
|
options: {
|
|
3014
3061
|
stdin: {
|
|
@@ -3097,15 +3144,18 @@ var ID_ARGS = /* @__PURE__ */ new Set([
|
|
|
3097
3144
|
"service",
|
|
3098
3145
|
"call"
|
|
3099
3146
|
]);
|
|
3100
|
-
/**
|
|
3101
|
-
|
|
3147
|
+
/**
|
|
3148
|
+
* The positionals that may be left out ahead of a required one (`chat?` in `[<chat>] <file>`): left out, they shift the
|
|
3149
|
+
* others. One with no required one after it (`<chat> [<method>]`, `text...?`) is simply missing at the end: it shifts nothing.
|
|
3150
|
+
*/
|
|
3151
|
+
var leadingOptionals = (names) => names.filter((name, i) => name.endsWith("?") && !name.endsWith("...?") && names.slice(i + 1).some((after) => !after.endsWith("?")));
|
|
3102
3152
|
/**
|
|
3103
3153
|
* Which of a command's positionals take an id, by index (a trailing `...` one covers the rest). An optional `name?`
|
|
3104
3154
|
* shifts the others, so it counts only where it and what may come in its place are all ids.
|
|
3105
3155
|
*/
|
|
3106
3156
|
function idSlot(command) {
|
|
3107
3157
|
const names = (command.args ?? []).map((name) => name.replace(/\?$/, ""));
|
|
3108
|
-
const shift = (command.args ?? []).
|
|
3158
|
+
const shift = leadingOptionals(command.args ?? []).length;
|
|
3109
3159
|
const rest = names.findIndex((name) => name.endsWith("..."));
|
|
3110
3160
|
const at = (index) => {
|
|
3111
3161
|
const name = rest !== -1 && index >= rest ? names[rest].slice(0, -3) : names[index];
|
|
@@ -3136,11 +3186,11 @@ function usageNames(usage) {
|
|
|
3136
3186
|
*/
|
|
3137
3187
|
function positionals(command, values) {
|
|
3138
3188
|
let names = command.args ?? [];
|
|
3139
|
-
const optional = names
|
|
3189
|
+
const optional = leadingOptionals(names);
|
|
3140
3190
|
let skip = 0;
|
|
3141
3191
|
if (optional.length) {
|
|
3142
3192
|
skip = Math.max(0, optional.length - Math.max(0, values.length - (names.length - optional.length)));
|
|
3143
|
-
names = [...optional.slice(skip).map((name) => name.slice(0, -1)), ...names.filter((name) => !
|
|
3193
|
+
names = [...optional.slice(skip).map((name) => name.slice(0, -1)), ...names.filter((name) => !optional.includes(name))];
|
|
3144
3194
|
}
|
|
3145
3195
|
const shown = usageNames(command.usage);
|
|
3146
3196
|
const missing = (i, name) => new CliError("usage", `Missing <${shown[i + skip] ?? name}>: ghostly ${command.usage}`);
|
|
@@ -3153,6 +3203,7 @@ function positionals(command, values) {
|
|
|
3153
3203
|
out[name.slice(0, -3)] = rest.length ? rest.join(" ") : void 0;
|
|
3154
3204
|
return out;
|
|
3155
3205
|
}
|
|
3206
|
+
if (values[i] === void 0 && names[i].endsWith("?")) continue;
|
|
3156
3207
|
if (values[i] === void 0 || values[i] === "") throw missing(i, name);
|
|
3157
3208
|
const words = command.words?.[name];
|
|
3158
3209
|
if (words && !words.includes(values[i])) {
|
|
@@ -3169,6 +3220,19 @@ function noMoreThan(count, values, usage) {
|
|
|
3169
3220
|
if (values.length > count) throw new CliError("usage", `Too many arguments: ghostly ${usage}`);
|
|
3170
3221
|
}
|
|
3171
3222
|
//#endregion
|
|
3223
|
+
//#region src/jsonOut.ts
|
|
3224
|
+
/**
|
|
3225
|
+
* What `JSON.stringify` leaves raw and a terminal may act on: DEL and the C1 controls (CSI, OSC, ST, NEL... in UTF-8),
|
|
3226
|
+
* the line and paragraph separators, and the bidi marks, embeddings, overrides and isolates that reorder a line. Only
|
|
3227
|
+
* a string holds them, and a peer writes some of those strings (a message's text), so the CLI's output writes them as
|
|
3228
|
+
* `\uXXXX`: the same JSON value for every reader, nothing a terminal acts on. What is stored stays whole.
|
|
3229
|
+
*/
|
|
3230
|
+
var RAW = /[\u007f-\u009f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g;
|
|
3231
|
+
/** `value` as the JSON the CLI prints: `JSON.stringify`, with `RAW` escaped. */
|
|
3232
|
+
function jsonOut(value, space) {
|
|
3233
|
+
return JSON.stringify(value, null, space)?.replace(RAW, (char) => "\\u" + char.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
3234
|
+
}
|
|
3235
|
+
//#endregion
|
|
3172
3236
|
//#region src/listen.ts
|
|
3173
3237
|
/** The cursor's own write failed, not the event's handling. */
|
|
3174
3238
|
var CursorError = class extends Error {
|
|
@@ -3214,13 +3278,25 @@ var Allowlist = class {
|
|
|
3214
3278
|
};
|
|
3215
3279
|
/**
|
|
3216
3280
|
* `--from` and `--group` as ids, resolved once at start: a contact key as that key (whatever any chat is named), else a
|
|
3217
|
-
* chat by id
|
|
3218
|
-
*
|
|
3281
|
+
* chat by its id or a label this side gave it, as `call auto on --from` (`findOwnNamedChat`): a prefix of its id or the
|
|
3282
|
+
* name its contact gave itself is refused, since another contact could call itself that; a group by id, prefix or name.
|
|
3283
|
+
* A name that later changes (or a contact who renames themselves) moves nothing.
|
|
3219
3284
|
*/
|
|
3220
3285
|
async function allowlist(from, groups, call, peerOf) {
|
|
3221
3286
|
const chats = /* @__PURE__ */ new Set(), keys = /* @__PURE__ */ new Set(), groupIds = /* @__PURE__ */ new Set();
|
|
3222
|
-
for (const ref of from)
|
|
3223
|
-
|
|
3287
|
+
for (const ref of from) {
|
|
3288
|
+
if (CONTACT_KEY.test(ref)) {
|
|
3289
|
+
keys.add(ref);
|
|
3290
|
+
continue;
|
|
3291
|
+
}
|
|
3292
|
+
const chat = await call("chat.get", { chat: ref });
|
|
3293
|
+
if (chat.id !== ref && chat.label?.toLowerCase() !== ref.toLowerCase()) throw namedByThem(ref, {
|
|
3294
|
+
chat: chat.id,
|
|
3295
|
+
name: chat.peerName ?? null,
|
|
3296
|
+
contact: chat.peer
|
|
3297
|
+
});
|
|
3298
|
+
chats.add(chat.id);
|
|
3299
|
+
}
|
|
3224
3300
|
for (const ref of groups) groupIds.add((await call("group.get", { group: ref })).id);
|
|
3225
3301
|
return new Allowlist(chats, keys, groupIds, peerOf);
|
|
3226
3302
|
}
|
|
@@ -3471,7 +3547,7 @@ async function post(url, event, retryMs) {
|
|
|
3471
3547
|
});
|
|
3472
3548
|
response.body?.cancel().catch(() => {});
|
|
3473
3549
|
if (response.ok) {
|
|
3474
|
-
if (holding) process.stderr.write(`ghostly: the webhook at ${url.
|
|
3550
|
+
if (holding) process.stderr.write(`ghostly: the webhook at ${url.origin} answers again: event ${event.seq} taken\n`);
|
|
3475
3551
|
return true;
|
|
3476
3552
|
}
|
|
3477
3553
|
status = response.status;
|
|
@@ -3480,7 +3556,7 @@ async function post(url, event, retryMs) {
|
|
|
3480
3556
|
if (!down && attempt >= 2) return status;
|
|
3481
3557
|
if (down && attempt >= 2 && !holding) {
|
|
3482
3558
|
holding = true;
|
|
3483
|
-
process.stderr.write(`ghostly: the webhook at ${url.
|
|
3559
|
+
process.stderr.write(`ghostly: the webhook at ${url.origin} is not answering: holding event ${event.seq} (${event.type}) until it does\n`);
|
|
3484
3560
|
}
|
|
3485
3561
|
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
3486
3562
|
wait = Math.min(wait * 2, RETRY_MAX_MS);
|
|
@@ -3495,6 +3571,8 @@ function eventHandler(options) {
|
|
|
3495
3571
|
let chain = Promise.resolve();
|
|
3496
3572
|
let behind = 0;
|
|
3497
3573
|
let stopped = false;
|
|
3574
|
+
/** The last event the cursor says, and the last one `--type` dropped while others were still being handled. */
|
|
3575
|
+
let kept = -1, dropped = -1;
|
|
3498
3576
|
const keep = (seq) => {
|
|
3499
3577
|
if (!options.cursor) return;
|
|
3500
3578
|
try {
|
|
@@ -3502,10 +3580,27 @@ function eventHandler(options) {
|
|
|
3502
3580
|
} catch (error) {
|
|
3503
3581
|
throw new CursorError(error);
|
|
3504
3582
|
}
|
|
3583
|
+
kept = Math.max(kept, seq);
|
|
3584
|
+
};
|
|
3585
|
+
/** The cursor past events dropped meanwhile, once nothing before them is left to handle. */
|
|
3586
|
+
const keepDropped = () => {
|
|
3587
|
+
if (behind > 0 || dropped <= kept) return;
|
|
3588
|
+
try {
|
|
3589
|
+
keep(dropped);
|
|
3590
|
+
} catch (failed) {
|
|
3591
|
+
if (!(failed instanceof CursorError) || !options.cursorFailed) return;
|
|
3592
|
+
stopped = true;
|
|
3593
|
+
options.cursorFailed(failed.error);
|
|
3594
|
+
}
|
|
3505
3595
|
};
|
|
3506
3596
|
const handle = (event) => {
|
|
3507
3597
|
const seq = event.seq, type = event.type;
|
|
3508
3598
|
if (stopped) return;
|
|
3599
|
+
if (!matches(event, options.types)) {
|
|
3600
|
+
dropped = Math.max(dropped, seq);
|
|
3601
|
+
keepDropped();
|
|
3602
|
+
return;
|
|
3603
|
+
}
|
|
3509
3604
|
behind++;
|
|
3510
3605
|
chain = chain.then(async () => {
|
|
3511
3606
|
if (stopped) return;
|
|
@@ -3518,13 +3613,13 @@ function eventHandler(options) {
|
|
|
3518
3613
|
if (!next) return skip();
|
|
3519
3614
|
event = next;
|
|
3520
3615
|
}
|
|
3521
|
-
const full = options.print && options.write(
|
|
3616
|
+
const full = options.print && options.write(jsonOut(event)) === false;
|
|
3522
3617
|
if (options.exec) {
|
|
3523
3618
|
const code = await runExec(options.exec, event);
|
|
3524
3619
|
if (code !== 0) process.stderr.write(`ghostly: --exec exited ${code} on event ${event.seq} (${event.type})\n`);
|
|
3525
3620
|
}
|
|
3526
3621
|
const answered = webhook ? await post(webhook, event, options.retryMs ?? 500) : true;
|
|
3527
|
-
if (webhook && answered !== true) process.stderr.write(`ghostly: the webhook at ${webhook.
|
|
3622
|
+
if (webhook && answered !== true) process.stderr.write(`ghostly: the webhook at ${webhook.origin} answered ${answered}: event ${event.seq} (${event.type}) passed, not taken (a 4xx or a redirect is not tried again)\n`);
|
|
3528
3623
|
if (full) await options.drained?.();
|
|
3529
3624
|
keep(event.seq);
|
|
3530
3625
|
}).catch((error) => {
|
|
@@ -3540,6 +3635,7 @@ function eventHandler(options) {
|
|
|
3540
3635
|
}
|
|
3541
3636
|
}).finally(() => {
|
|
3542
3637
|
behind--;
|
|
3638
|
+
keepDropped();
|
|
3543
3639
|
});
|
|
3544
3640
|
};
|
|
3545
3641
|
return Object.assign(handle, {
|
|
@@ -3685,10 +3781,10 @@ var STDIN_GIVE_UP_MS = 6e4;
|
|
|
3685
3781
|
async function secretsFromStdin(method, params, read, tty = false, note = () => {}) {
|
|
3686
3782
|
const warning = (what) => `${what} on the command line shows in ps and the shell's history: give it on stdin instead`;
|
|
3687
3783
|
if (method === "wallet.redeem") {
|
|
3688
|
-
if (params.token !== void 0) return warning("A token");
|
|
3784
|
+
if (params.token !== void 0 && params.token !== "-") return warning("A token");
|
|
3689
3785
|
const missing = () => new CliError("usage", "Missing <cashu-token>: give it as an argument or on stdin (… | ghostly wallet redeem)");
|
|
3690
3786
|
if (tty) throw missing();
|
|
3691
|
-
const token = (await readUnasked(read, note, {
|
|
3787
|
+
const token = (params.token === "-" ? await read() : await readUnasked(read, note, {
|
|
3692
3788
|
what: "a Cashu token",
|
|
3693
3789
|
missing: "Missing <cashu-token>",
|
|
3694
3790
|
command: "wallet redeem",
|
|
@@ -3779,15 +3875,15 @@ var VERSION = package_default.version;
|
|
|
3779
3875
|
* command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
|
|
3780
3876
|
* cost every command ~100 ms before its socket was opened.
|
|
3781
3877
|
*/
|
|
3782
|
-
var engineApi = () => import("./api-
|
|
3783
|
-
var engineHost = () => import("./host-
|
|
3878
|
+
var engineApi = () => import("./api-CcuCtc1H.js");
|
|
3879
|
+
var engineHost = () => import("./host-DpypH-fR.js");
|
|
3784
3880
|
/**
|
|
3785
3881
|
* `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
|
|
3786
3882
|
* asked: the app's message parser it reads costs every other command nothing.
|
|
3787
3883
|
*/
|
|
3788
3884
|
async function translatorFor(value, home) {
|
|
3789
3885
|
if (value === void 0) return null;
|
|
3790
|
-
const { loadDetector, openTranslator, translateTarget } = await import("./translate-
|
|
3886
|
+
const { loadDetector, openTranslator, translateTarget } = await import("./translate-cDBotA-b.js");
|
|
3791
3887
|
return openTranslator({
|
|
3792
3888
|
home,
|
|
3793
3889
|
to: translateTarget(value),
|
|
@@ -3797,7 +3893,7 @@ async function translatorFor(value, home) {
|
|
|
3797
3893
|
}
|
|
3798
3894
|
var pretty = false;
|
|
3799
3895
|
function print(value) {
|
|
3800
|
-
process.stdout.write(
|
|
3896
|
+
process.stdout.write(jsonOut(value, pretty ? 2 : void 0) + "\n");
|
|
3801
3897
|
}
|
|
3802
3898
|
/** Done, with something to know (a voice note sent without its waveform): said on stderr, the JSON stays the answer. */
|
|
3803
3899
|
function printAnswer(result) {
|
|
@@ -3833,10 +3929,45 @@ function noProfile(g) {
|
|
|
3833
3929
|
function knownProfile(g) {
|
|
3834
3930
|
if (g.profile !== "default" && !profileExists(g.home, g.profile)) throw noProfile(g);
|
|
3835
3931
|
}
|
|
3836
|
-
/**
|
|
3932
|
+
/** `1.2.3`, with an optional `v`, an optional `-beta.1` prerelease and an optional `+build` that never orders. */
|
|
3933
|
+
var RELEASE = /^v?(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
3934
|
+
/** Semver order: negative when `a` is the older release, positive when it is the newer, 0 the same; null when either is not one. */
|
|
3935
|
+
function compareReleases(a, b) {
|
|
3936
|
+
const left = RELEASE.exec(a.trim()), right = RELEASE.exec(b.trim());
|
|
3937
|
+
if (!left || !right) return null;
|
|
3938
|
+
for (let i = 1; i <= 3; i++) {
|
|
3939
|
+
const order = Number(left[i]) - Number(right[i]);
|
|
3940
|
+
if (order !== 0) return order;
|
|
3941
|
+
}
|
|
3942
|
+
if (left[4] === void 0 || right[4] === void 0) return (left[4] === void 0 ? 1 : 0) - (right[4] === void 0 ? 1 : 0);
|
|
3943
|
+
const l = left[4].split("."), r = right[4].split(".");
|
|
3944
|
+
for (let i = 0; i < Math.min(l.length, r.length); i++) {
|
|
3945
|
+
if (l[i] === r[i]) continue;
|
|
3946
|
+
const ln = /^\d+$/.test(l[i]), rn = /^\d+$/.test(r[i]);
|
|
3947
|
+
if (ln && rn) return Number(l[i]) - Number(r[i]);
|
|
3948
|
+
if (ln !== rn) return ln ? -1 : 1;
|
|
3949
|
+
return l[i] < r[i] ? -1 : 1;
|
|
3950
|
+
}
|
|
3951
|
+
return l.length - r.length;
|
|
3952
|
+
}
|
|
3953
|
+
/**
|
|
3954
|
+
* Said on stderr when the daemon runs another release than this command. An older daemon started before an upgrade:
|
|
3955
|
+
* `daemon restart` runs this release. A newer one means this command is the old one (a second install, a project's
|
|
3956
|
+
* pinned copy): a restart from it would start the older release, so it is told to upgrade instead.
|
|
3957
|
+
*/
|
|
3837
3958
|
function versionWarning(daemon, cli) {
|
|
3838
3959
|
if (typeof daemon !== "string" || daemon === cli) return null;
|
|
3839
|
-
|
|
3960
|
+
const order = compareReleases(daemon, cli);
|
|
3961
|
+
if (order === 0) return null;
|
|
3962
|
+
const both = `ghostly: the daemon runs ${daemon} and this command is ${cli}`;
|
|
3963
|
+
if (order === null) return `${both}: \`ghostly daemon restart\` runs this command's release`;
|
|
3964
|
+
if (order > 0) return `${both}, older than the daemon: upgrade the CLI (\`npm install -g @ghostlytools/cli\`)`;
|
|
3965
|
+
return `${both}: \`ghostly daemon restart\` runs the new code`;
|
|
3966
|
+
}
|
|
3967
|
+
/** Said on stderr when `daemon restart` stopped a newer release than the one it started (an older CLI ran it). */
|
|
3968
|
+
function restartWarning(before, version) {
|
|
3969
|
+
if (typeof before !== "string" || !((compareReleases(before, version) ?? 0) > 0)) return null;
|
|
3970
|
+
return `ghostly: the daemon ran ${before} and this restart started ${version}, an older release: upgrade the CLI (\`npm install -g @ghostlytools/cli\`) and run \`ghostly daemon restart\` again to go back`;
|
|
3840
3971
|
}
|
|
3841
3972
|
/**
|
|
3842
3973
|
* Never fails, and has no deadline of its own: a daemon that does not answer is the command's own call to find out,
|
|
@@ -3871,6 +4002,15 @@ function chatOnly(method, params) {
|
|
|
3871
4002
|
return method.startsWith("chat.") || params.chat !== void 0 && params.group === void 0 && !method.startsWith("group.");
|
|
3872
4003
|
}
|
|
3873
4004
|
/**
|
|
4005
|
+
* A command that makes a new chat and needs no other: a one-shot for it leaves the saved chats and the groups unstarted.
|
|
4006
|
+
* Started, each saved chat put its records and its leave packet on the relays: from about ten that was the relays' 30
|
|
4007
|
+
* requests a minute, and the new chat's waited behind them. A new invite took 21 s instead of under one, unpublished;
|
|
4008
|
+
* a join waited its whole 60 s and left unpaired. A join of a saved chat starts that chat (the engine's `joinLink`).
|
|
4009
|
+
*/
|
|
4010
|
+
function newChatOnly(method) {
|
|
4011
|
+
return method === "invite.create" || method === "invite.join";
|
|
4012
|
+
}
|
|
4013
|
+
/**
|
|
3874
4014
|
* Calls that only read what the profile stores: a one-shot for one opens it offline (`RuntimeOptions.offline`).
|
|
3875
4015
|
* Opened online, `status` or `chat list` started every chat, put the profile's records on the relays again and waited
|
|
3876
4016
|
* for its leave packet to be taken: 0.25 s became 3.3 s with a relay that takes 1.5 s, and 10 s with one that does not
|
|
@@ -3906,6 +4046,7 @@ var READS = /* @__PURE__ */ new Set([
|
|
|
3906
4046
|
function readOnly(method, params) {
|
|
3907
4047
|
if (method === "engine.call") return typeof params.method === "string" && ENGINE_READS.includes(params.method);
|
|
3908
4048
|
if (method === "call.auto") return params.on === void 0;
|
|
4049
|
+
if (method === "chat.accept") return params.method === void 0;
|
|
3909
4050
|
return READS.has(method);
|
|
3910
4051
|
}
|
|
3911
4052
|
/**
|
|
@@ -3978,17 +4119,40 @@ async function session(g, options) {
|
|
|
3978
4119
|
}
|
|
3979
4120
|
};
|
|
3980
4121
|
}
|
|
3981
|
-
const [
|
|
3982
|
-
const host = await
|
|
4122
|
+
const [, { callApi }] = await Promise.all([engineHost(), engineApi()]);
|
|
4123
|
+
const host = await openOneShot(g, options);
|
|
3983
4124
|
return {
|
|
3984
4125
|
mode: "one-shot",
|
|
3985
4126
|
call: (m, p) => callApi(host.ctx, m, p ?? {}),
|
|
3986
4127
|
close: () => host.close()
|
|
3987
4128
|
};
|
|
3988
4129
|
}
|
|
4130
|
+
/** How long a one-shot waits for another process to let go of the profile: a one-shot leaves in well under a second. */
|
|
4131
|
+
var HOLDER_WAIT_MS = 5e3;
|
|
4132
|
+
/**
|
|
4133
|
+
* Opens the profile in this process for a one-shot command. Another one that holds it (a script's `&`, a second
|
|
4134
|
+
* terminal) is waited for: both used to fail at once, and a backgrounded send was lost unless the script checked its
|
|
4135
|
+
* exit code. One still holding it after HOLDER_WAIT_MS is answered with the next step.
|
|
4136
|
+
*/
|
|
4137
|
+
async function openOneShot(g, options = {}) {
|
|
4138
|
+
const { openHost } = await engineHost();
|
|
4139
|
+
const until = Date.now() + HOLDER_WAIT_MS;
|
|
4140
|
+
for (;;) try {
|
|
4141
|
+
return await openHost(g.paths, "one-shot", VERSION, options);
|
|
4142
|
+
} catch (error) {
|
|
4143
|
+
if (!(error instanceof CliError) || error.code !== "busy") throw error;
|
|
4144
|
+
const left = until - Date.now();
|
|
4145
|
+
if (left <= 0) {
|
|
4146
|
+
const pid = error.details?.pid;
|
|
4147
|
+
throw new CliError("busy", `Profile ${g.profile} is in use by ${pid ? `process ${pid}, another ghostly command,` : "another ghostly command"} and was not free after ${HOLDER_WAIT_MS / 1e3} s: run the commands one after another, or start \`ghostly daemon --detach\` so they can run at once`, error.details);
|
|
4148
|
+
}
|
|
4149
|
+
await new Promise((resolve) => setTimeout(resolve, Math.min(50 + Math.random() * 50, left)));
|
|
4150
|
+
}
|
|
4151
|
+
}
|
|
3989
4152
|
/**
|
|
3990
4153
|
* How a one-shot opens the profile: `deferGroups` when the command is about one 1:1 chat (`chatOnly`) and needs
|
|
3991
|
-
* nothing of the groups, `
|
|
4154
|
+
* nothing of the groups, `deferChats` too when it makes a new chat (`newChatOnly`), `offline` when it only reads or
|
|
4155
|
+
* changes only this device (`offlineCall`).
|
|
3992
4156
|
*/
|
|
3993
4157
|
async function withSession(g, work, options = {}) {
|
|
3994
4158
|
const s = await session(g, options);
|
|
@@ -4127,7 +4291,7 @@ var SPECIAL = [
|
|
|
4127
4291
|
"The profile's settings",
|
|
4128
4292
|
{ "show-secret": o("boolean", "Show credentials too") }
|
|
4129
4293
|
],
|
|
4130
|
-
["settings set <key> <json-value>", "Change one: relays, irohRelays, hyperdhtRelay,
|
|
4294
|
+
["settings set <key> <json-value>", "Change one: relays, irohRelays, hyperdhtRelay, iceServers, publicProfiles, online, shareProfile, sendTyping, autoDownloads, serveFiles, nick"],
|
|
4131
4295
|
[
|
|
4132
4296
|
"engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]",
|
|
4133
4297
|
"Any call of the app's engine, with its own parameters (engine --list --verbose names them)",
|
|
@@ -4410,7 +4574,7 @@ async function profileCommand(sub, argv) {
|
|
|
4410
4574
|
if (!given || !name) throw new CliError("usage", "ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4411
4575
|
noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4412
4576
|
const file = here(given);
|
|
4413
|
-
const { backupFileProtection, restoreProfile } = await import("./backup-
|
|
4577
|
+
const { backupFileProtection, restoreProfile } = await import("./backup-A0hIa9GE.js");
|
|
4414
4578
|
const protection = await backupFileProtection(file);
|
|
4415
4579
|
const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
|
|
4416
4580
|
if (parsed.options.use) selectProfile(g.home, name);
|
|
@@ -4570,6 +4734,8 @@ async function daemonCommand(argv) {
|
|
|
4570
4734
|
stopped
|
|
4571
4735
|
});
|
|
4572
4736
|
}
|
|
4737
|
+
const older = restartWarning(before, VERSION);
|
|
4738
|
+
if (older) process.stderr.write(older + "\n");
|
|
4573
4739
|
print({
|
|
4574
4740
|
restarted: true,
|
|
4575
4741
|
stopped,
|
|
@@ -4821,8 +4987,8 @@ async function listenCommand(argv) {
|
|
|
4821
4987
|
const from = parsed.options.from ?? [], groups = parsed.options.group ?? [];
|
|
4822
4988
|
const cursor = here(parsed.options.cursor);
|
|
4823
4989
|
checkCursor(cursor);
|
|
4990
|
+
const since$1 = since(parsed.options) ?? readCursor(cursor);
|
|
4824
4991
|
const translator = await translatorFor(parsed.options.translate, g.home);
|
|
4825
|
-
const since = parsed.options.since ?? readCursor(cursor);
|
|
4826
4992
|
let quit = (code) => {
|
|
4827
4993
|
process.exit(code);
|
|
4828
4994
|
};
|
|
@@ -4871,7 +5037,7 @@ async function listenCommand(argv) {
|
|
|
4871
5037
|
client.close();
|
|
4872
5038
|
throw error;
|
|
4873
5039
|
});
|
|
4874
|
-
const following = followDaemon(g.paths, client, handle, since, PAUSE_HOLD_MS, g.profile);
|
|
5040
|
+
const following = followDaemon(g.paths, client, handle, since$1, PAUSE_HOLD_MS, g.profile);
|
|
4875
5041
|
const stop = () => {
|
|
4876
5042
|
following.close();
|
|
4877
5043
|
process.exit(0);
|
|
@@ -4926,11 +5092,11 @@ async function listenCommand(argv) {
|
|
|
4926
5092
|
}
|
|
4927
5093
|
off = host.ctx.hub.onEvent(feed.take);
|
|
4928
5094
|
};
|
|
4929
|
-
const feed = new Feed(handle, since, () => {
|
|
5095
|
+
const feed = new Feed(handle, since$1, () => {
|
|
4930
5096
|
off?.();
|
|
4931
5097
|
off = null;
|
|
4932
5098
|
}, open);
|
|
4933
|
-
open(since);
|
|
5099
|
+
open(since$1);
|
|
4934
5100
|
host.ctx.hub.emit("daemon.started", `daemon.started:${process.pid}:${Date.now()}`, {
|
|
4935
5101
|
pid: process.pid,
|
|
4936
5102
|
version: VERSION,
|
|
@@ -5038,6 +5204,7 @@ async function textCommand(name, argv) {
|
|
|
5038
5204
|
const [target, ...rest] = parsed.positionals;
|
|
5039
5205
|
const [message, ...words] = spec.message ? rest : [void 0, ...rest];
|
|
5040
5206
|
if (!target || spec.message && !message) throw new CliError("usage", `ghostly ${spec.usage}`);
|
|
5207
|
+
timeout(parsed.options);
|
|
5041
5208
|
let text = words.join(" ");
|
|
5042
5209
|
if (parsed.options.text !== void 0) {
|
|
5043
5210
|
if (text || parsed.options.stdin) throw new CliError("usage", "Give the text once: as arguments, --text or stdin");
|
|
@@ -5055,7 +5222,7 @@ async function textCommand(name, argv) {
|
|
|
5055
5222
|
};
|
|
5056
5223
|
if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
|
|
5057
5224
|
if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
|
|
5058
|
-
if (!spec.message) Object.assign(params, (await import("./buttons-
|
|
5225
|
+
if (!spec.message) Object.assign(params, (await import("./buttons-Bxxu3lSk.js")).buttonsOf(parsed.options));
|
|
5059
5226
|
print(await withSession(g, (s) => {
|
|
5060
5227
|
if (spec.target === "chat") {
|
|
5061
5228
|
params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
|
|
@@ -5101,6 +5268,11 @@ async function identityAddCommand(argv) {
|
|
|
5101
5268
|
if (eq < 1) throw new CliError("usage", `--field takes name=value, not ${JSON.stringify(item)}`);
|
|
5102
5269
|
fields[item.slice(0, eq)] = item.slice(eq + 1);
|
|
5103
5270
|
}
|
|
5271
|
+
inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
|
|
5272
|
+
if (parsed.options.days !== void 0) {
|
|
5273
|
+
const known = (await import("./registry-BlSTJlbv.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider);
|
|
5274
|
+
if (known) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
|
|
5275
|
+
}
|
|
5104
5276
|
const params = {
|
|
5105
5277
|
provider,
|
|
5106
5278
|
subject: subject.join(" ") || void 0,
|
|
@@ -5126,8 +5298,8 @@ async function identityAddCommand(argv) {
|
|
|
5126
5298
|
}
|
|
5127
5299
|
return;
|
|
5128
5300
|
}
|
|
5129
|
-
const [
|
|
5130
|
-
const host = await
|
|
5301
|
+
const [, { callApi }] = await Promise.all([engineHost(), engineApi()]);
|
|
5302
|
+
const host = await openOneShot(g);
|
|
5131
5303
|
const off = host.ctx.hub.onEvent(tell);
|
|
5132
5304
|
try {
|
|
5133
5305
|
const result = await callApi(host.ctx, "identity.add", params);
|
|
@@ -5189,12 +5361,13 @@ async function tableCommand(name, argv) {
|
|
|
5189
5361
|
}
|
|
5190
5362
|
return result;
|
|
5191
5363
|
}, {
|
|
5192
|
-
deferGroups: chatOnly(command.method, params),
|
|
5364
|
+
deferGroups: chatOnly(command.method, params) || newChatOnly(command.method),
|
|
5365
|
+
deferChats: newChatOnly(command.method),
|
|
5193
5366
|
offline: offlineCall(command.method, params)
|
|
5194
5367
|
});
|
|
5195
5368
|
if (translator) {
|
|
5196
5369
|
try {
|
|
5197
|
-
printAnswer(await (await import("./translate-
|
|
5370
|
+
printAnswer(await (await import("./translate-cDBotA-b.js")).translateAnswer(result, translator));
|
|
5198
5371
|
} finally {
|
|
5199
5372
|
translator.close();
|
|
5200
5373
|
}
|
|
@@ -5373,4 +5546,4 @@ async function run(argv) {
|
|
|
5373
5546
|
//#endregion
|
|
5374
5547
|
export { run };
|
|
5375
5548
|
|
|
5376
|
-
//# sourceMappingURL=main-
|
|
5549
|
+
//# sourceMappingURL=main-BwgoQZVu.js.map
|