@ghostlytools/cli 1.7.1 → 1.7.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 +27 -16
- package/SKILL.md +5 -1
- package/dist/assets/{api-CJM3R93b.js → api-B42F9ytB.js} +2 -2
- package/dist/assets/{api-CD9JbPuA.js → api-tf-wAAnB.js} +249 -100
- package/dist/assets/api-tf-wAAnB.js.map +1 -0
- package/dist/assets/{apiKit-BmnROpCN.js → apiKit-DJb9hulp.js} +34 -5
- package/dist/assets/{apiKit-BmnROpCN.js.map → apiKit-DJb9hulp.js.map} +1 -1
- package/dist/assets/{apps-CJ2dvKSz.js → apps-BfoDISRg.js} +1 -1
- package/dist/assets/{apps-DVA60Tg6.js → apps-DIrWmLgL.js} +6 -6
- package/dist/assets/{apps-DVA60Tg6.js.map → apps-DIrWmLgL.js.map} +1 -1
- package/dist/assets/{arkade-CHqwEHFd.js → arkade-CJAhhgPQ.js} +2 -2
- package/dist/assets/{arkade-CHqwEHFd.js.map → arkade-CJAhhgPQ.js.map} +1 -1
- package/dist/assets/{backup-C4CbTEcj.js → backup-BkUeeduy.js} +1 -1
- package/dist/assets/{backup-B4dSNvzb.js → backup-Bko-AAm0.js} +6 -6
- package/dist/assets/{backup-B4dSNvzb.js.map → backup-Bko-AAm0.js.map} +1 -1
- package/dist/assets/bark_ffi_wasm_bg-EY2uc0Bx.js.map +1 -1
- package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
- package/dist/assets/buttons-Be7u0V5g.js +2 -0
- package/dist/assets/{buttons-C13rK2mH.js → buttons-DeA6Yddq.js} +43 -12
- package/dist/assets/buttons-DeA6Yddq.js.map +1 -0
- package/dist/assets/{daemonProof-B41oSfon.js → daemonProof-Bp9lJDxf.js} +2 -2
- package/dist/assets/{daemonProof-B41oSfon.js.map → daemonProof-Bp9lJDxf.js.map} +1 -1
- package/dist/assets/{envelope-4TXDx3vD.js → envelope-Cz5fc7BM.js} +2 -2
- package/dist/assets/{envelope-4TXDx3vD.js.map → envelope-Cz5fc7BM.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/{groupFiles-ajZgZ6P8.js → groupFiles-BlZRBWpt.js} +558 -4
- package/dist/assets/groupFiles-BlZRBWpt.js.map +1 -0
- package/dist/assets/{host-CVeNtA2_.js → host-BX0DmKW6.js} +41 -18
- package/dist/assets/host-BX0DmKW6.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-CI2ISE-g.js → hyperdhtRelay-DitYDnXx.js} +2 -2
- package/dist/assets/{hyperdhtRelay-CI2ISE-g.js.map → hyperdhtRelay-DitYDnXx.js.map} +1 -1
- package/dist/assets/{irohWeb-DcRJdhce.js → irohWeb-R3bcd34h.js} +2 -2
- package/dist/assets/{irohWeb-DcRJdhce.js.map → irohWeb-R3bcd34h.js.map} +1 -1
- package/dist/assets/{main-CjO0KGiF.js → main-6QOSvQ8b.js} +297 -127
- package/dist/assets/main-6QOSvQ8b.js.map +1 -0
- package/dist/assets/{mainline-WM-WItCV.js → mainline-BfwezHWi.js} +2 -2
- package/dist/assets/{mainline-WM-WItCV.js.map → mainline-BfwezHWi.js.map} +1 -1
- package/dist/assets/{networkReason-380j5yMs.js → networkReason-Ba9415nn.js} +2 -2
- package/dist/assets/{networkReason-380j5yMs.js.map → networkReason-Ba9415nn.js.map} +1 -1
- package/dist/assets/{nwc-D5dkC1xg.js → nwc-ovXSN2M2.js} +3 -3
- package/dist/assets/{nwc-D5dkC1xg.js.map → nwc-ovXSN2M2.js.map} +1 -1
- package/dist/assets/{nwcProvider-p_rMwtDv.js → nwcProvider-BzZbfFP3.js} +2 -2
- package/dist/assets/{nwcProvider-p_rMwtDv.js.map → nwcProvider-BzZbfFP3.js.map} +1 -1
- package/dist/assets/{profiles-BFd0tpCZ.js → profiles-C6XWqre5.js} +2 -2
- package/dist/assets/{profiles-BFd0tpCZ.js.map → profiles-C6XWqre5.js.map} +1 -1
- package/dist/assets/{registry-BfNcA6kF.js → registry-B0Uv9yL6.js} +3 -3
- package/dist/assets/{registry-BfNcA6kF.js.map → registry-B0Uv9yL6.js.map} +1 -1
- package/dist/assets/{registry-BKffx4ZU.js → registry-CFtlhWCI.js} +1 -1
- package/dist/assets/{resolve-hUsgRkmm.js → resolve-BzFG4WDU.js} +2 -2
- package/dist/assets/{resolve-hUsgRkmm.js.map → resolve-BzFG4WDU.js.map} +1 -1
- package/dist/assets/{server-C3tJZFnv.js → server-BGCuHbmQ.js} +504 -673
- package/dist/assets/server-BGCuHbmQ.js.map +1 -0
- package/dist/assets/{src-BMHgbkli.js → src-DWw2hUE5.js} +193 -60
- package/dist/assets/src-DWw2hUE5.js.map +1 -0
- package/dist/assets/{translate-DJUutSis.js → translate-DObb-1tq.js} +11 -11
- package/dist/assets/{translate-DJUutSis.js.map → translate-DObb-1tq.js.map} +1 -1
- package/dist/assets/{usdt-glkUxsDe.js → usdt-Bkva90Vo.js} +3 -3
- package/dist/assets/{usdt-glkUxsDe.js.map → usdt-Bkva90Vo.js.map} +1 -1
- package/dist/assets/{words-DyW9b27T.js → words-odSAoasK.js} +4 -2
- package/dist/assets/words-odSAoasK.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/package.json +1 -1
- package/dist/assets/api-CD9JbPuA.js.map +0 -1
- package/dist/assets/buttons-BMVGYXpR.js +0 -2
- package/dist/assets/buttons-C13rK2mH.js.map +0 -1
- package/dist/assets/errors-CzXgR8Cc.js.map +0 -1
- package/dist/assets/groupFiles-ajZgZ6P8.js.map +0 -1
- package/dist/assets/host-CVeNtA2_.js.map +0 -1
- package/dist/assets/main-CjO0KGiF.js.map +0 -1
- package/dist/assets/server-C3tJZFnv.js.map +0 -1
- package/dist/assets/src-BMHgbkli.js.map +0 -1
- package/dist/assets/words-DyW9b27T.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 {
|
|
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-DWw2hUE5.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-odSAoasK.js";
|
|
3
|
+
import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-mnjSQlbX.js";
|
|
4
|
+
import { m as namedByThem, t as CONTACT_KEY } from "./apiKit-DJb9hulp.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.3",
|
|
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",
|
|
@@ -131,6 +131,10 @@ function parseArgs(argv, spec, idSlot = () => false) {
|
|
|
131
131
|
};
|
|
132
132
|
const positionals = [];
|
|
133
133
|
const options = {};
|
|
134
|
+
const setBoolean = (name, value) => {
|
|
135
|
+
if (all[name].eitherWay && options[name] !== void 0 && options[name] !== value) throw new CliError("usage", `--${name} or --no-${name}, not both`);
|
|
136
|
+
options[name] = value;
|
|
137
|
+
};
|
|
134
138
|
for (let i = 0; i < argv.length; i++) {
|
|
135
139
|
const arg = argv[i];
|
|
136
140
|
if (arg === "--") {
|
|
@@ -153,14 +157,14 @@ function parseArgs(argv, spec, idSlot = () => false) {
|
|
|
153
157
|
name = long;
|
|
154
158
|
}
|
|
155
159
|
if (name.startsWith("no-") && all[name.slice(3)]?.type === "boolean" && inline === void 0) {
|
|
156
|
-
|
|
160
|
+
setBoolean(name.slice(3), false);
|
|
157
161
|
continue;
|
|
158
162
|
}
|
|
159
163
|
const option = all[name];
|
|
160
164
|
if (!option) throw new CliError("usage", `Unknown option --${name}`);
|
|
161
165
|
if (option.type === "boolean") {
|
|
162
166
|
if (inline !== void 0 && !["true", "false"].includes(inline)) throw new CliError("usage", `--${name} takes no value`);
|
|
163
|
-
|
|
167
|
+
setBoolean(name, inline === void 0 || inline === "true");
|
|
164
168
|
continue;
|
|
165
169
|
}
|
|
166
170
|
let value = inline;
|
|
@@ -492,7 +496,7 @@ var groupWait = {
|
|
|
492
496
|
/** `listen`, `events` and `chat history`: received messages with `translation: { from, text }` (translate.ts). */
|
|
493
497
|
var translate = {
|
|
494
498
|
type: "string",
|
|
495
|
-
description: "
|
|
499
|
+
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
500
|
};
|
|
497
501
|
var net = {
|
|
498
502
|
type: "string",
|
|
@@ -587,6 +591,19 @@ var showInvite = { "show-secret": {
|
|
|
587
591
|
} };
|
|
588
592
|
var secret = (options) => options["show-secret"] === true ? { showSecret: true } : {};
|
|
589
593
|
/**
|
|
594
|
+
* `--kind` of the typing commands: another word is a usage error (exit 2) before the profile opens, not the API's
|
|
595
|
+
* "kind must be one of" (exit 1). The words are core's TYPING_KINDS, written out: the package is not loaded here.
|
|
596
|
+
*/
|
|
597
|
+
var typingKind = {
|
|
598
|
+
type: "string",
|
|
599
|
+
choices: [
|
|
600
|
+
"typing",
|
|
601
|
+
"recording",
|
|
602
|
+
"thinking"
|
|
603
|
+
],
|
|
604
|
+
description: "typing (default), recording (a voice note) or thinking"
|
|
605
|
+
};
|
|
606
|
+
/**
|
|
590
607
|
* `--for` of the typing commands: the seconds it is kept on, 1 to 600, and never with `--stop`. A usage error (exit 2)
|
|
591
608
|
* that names the flag: before, the API's own check answered ("for must be a number from 1 to 600", exit 1).
|
|
592
609
|
*/
|
|
@@ -597,7 +614,10 @@ function typingFor(options) {
|
|
|
597
614
|
if (options.stop === true) throw new CliError("usage", "--for keeps it on: not with --stop");
|
|
598
615
|
return seconds;
|
|
599
616
|
}
|
|
600
|
-
/**
|
|
617
|
+
/**
|
|
618
|
+
* The ranges the API takes (api.ts, files.ts): the most minutes of a `--hold` (a week, HOLD_MAX_MINUTES), seconds;
|
|
619
|
+
* `chat connect`'s, the chat link's own wait for a contact (CONNECT_MAX_SECONDS).
|
|
620
|
+
*/
|
|
601
621
|
var HOLD_MINUTES = 10080;
|
|
602
622
|
var WAIT_SECONDS = 3600;
|
|
603
623
|
var LONG_WAIT_SECONDS = 86400;
|
|
@@ -1137,7 +1157,7 @@ var commands$8 = {
|
|
|
1137
1157
|
description: "Replace the three files when they are there"
|
|
1138
1158
|
}
|
|
1139
1159
|
},
|
|
1140
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1160
|
+
run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).initApp(a.dir, {
|
|
1141
1161
|
name: options.name,
|
|
1142
1162
|
title: options.title,
|
|
1143
1163
|
force: options.force === true
|
|
@@ -1160,7 +1180,7 @@ var commands$8 = {
|
|
|
1160
1180
|
},
|
|
1161
1181
|
"app publish": {
|
|
1162
1182
|
method: "app.publish",
|
|
1163
|
-
usage: "app publish <dir> --key <file> [--out <file>]",
|
|
1183
|
+
usage: "app publish <dir> --key <file> [--out <file>] [--sequence n]",
|
|
1164
1184
|
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)",
|
|
1165
1185
|
args: ["dir"],
|
|
1166
1186
|
options: {
|
|
@@ -1177,7 +1197,7 @@ var commands$8 = {
|
|
|
1177
1197
|
description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
|
|
1178
1198
|
}
|
|
1179
1199
|
},
|
|
1180
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1200
|
+
run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
|
|
1181
1201
|
},
|
|
1182
1202
|
"app revoke": {
|
|
1183
1203
|
method: "app.revoke",
|
|
@@ -1210,7 +1230,7 @@ var commands$8 = {
|
|
|
1210
1230
|
description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
|
|
1211
1231
|
}
|
|
1212
1232
|
},
|
|
1213
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1233
|
+
run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
|
|
1214
1234
|
digests: options.digest,
|
|
1215
1235
|
upTo: options["up-to"],
|
|
1216
1236
|
reason: options.reason,
|
|
@@ -1271,7 +1291,7 @@ var commands$8 = {
|
|
|
1271
1291
|
usage: "app verify <bundle|url>",
|
|
1272
1292
|
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",
|
|
1273
1293
|
args: ["bundle"],
|
|
1274
|
-
run: async (_, a) => (await import("./apps-
|
|
1294
|
+
run: async (_, a) => (await import("./apps-BfoDISRg.js")).verifyApp(a.bundle)
|
|
1275
1295
|
},
|
|
1276
1296
|
"store sign": {
|
|
1277
1297
|
method: "store.sign",
|
|
@@ -1288,7 +1308,7 @@ var commands$8 = {
|
|
|
1288
1308
|
description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
|
|
1289
1309
|
}
|
|
1290
1310
|
},
|
|
1291
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1311
|
+
run: async ({ options }, a) => (await import("./apps-BfoDISRg.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
|
|
1292
1312
|
}
|
|
1293
1313
|
};
|
|
1294
1314
|
//#endregion
|
|
@@ -1328,7 +1348,7 @@ var commands$7 = {
|
|
|
1328
1348
|
rate
|
|
1329
1349
|
},
|
|
1330
1350
|
params: ({ options }, a) => {
|
|
1331
|
-
if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage",
|
|
1351
|
+
if (a.mode !== void 0 && a.mode !== "on" && a.mode !== "off") throw new CliError("usage", `call auto takes on or off, not ${JSON.stringify(a.mode)}: ghostly call auto [on|off] [--from <chat>]... [--rate 48000]`);
|
|
1332
1352
|
if (a.mode !== "on" && (options.from !== void 0 || options.rate !== void 0)) throw new CliError("usage", "--from and --rate go with on: ghostly call auto on --from <chat>");
|
|
1333
1353
|
refs(options.from, "from", "chat");
|
|
1334
1354
|
if (a.mode === void 0) return {};
|
|
@@ -1372,6 +1392,49 @@ var commands$7 = {
|
|
|
1372
1392
|
};
|
|
1373
1393
|
//#endregion
|
|
1374
1394
|
//#region src/commands/chats.ts
|
|
1395
|
+
/** `react` and `pin` in a 1:1 chat: until the contact confirmed it, by default without a daemon (the process leaves). */
|
|
1396
|
+
var confirmWait = {
|
|
1397
|
+
wait: {
|
|
1398
|
+
type: "string",
|
|
1399
|
+
choices: ["none", "confirmed"],
|
|
1400
|
+
description: "none or confirmed: until the contact confirmed it, in a 1:1 chat (default: none with a daemon, confirmed without)"
|
|
1401
|
+
},
|
|
1402
|
+
timeout: groupWait.timeout
|
|
1403
|
+
};
|
|
1404
|
+
/** The card commands: in a chat a one-shot stays until the card went out, as `send` (a group has no receipts). */
|
|
1405
|
+
var ONE_SHOT_DEFAULT = (word) => `(default: none with a daemon; without one, ${word} in a chat and none in a group)`;
|
|
1406
|
+
var cardWait = {
|
|
1407
|
+
wait: {
|
|
1408
|
+
type: "string",
|
|
1409
|
+
choices: [
|
|
1410
|
+
"none",
|
|
1411
|
+
"sent",
|
|
1412
|
+
"delivered"
|
|
1413
|
+
],
|
|
1414
|
+
description: `none, sent or delivered; in a group none or sent: until an edge took it ${ONE_SHOT_DEFAULT("sent")}`
|
|
1415
|
+
},
|
|
1416
|
+
timeout: groupWait.timeout
|
|
1417
|
+
};
|
|
1418
|
+
var cardUpdateWait = {
|
|
1419
|
+
wait: {
|
|
1420
|
+
type: "string",
|
|
1421
|
+
choices: [
|
|
1422
|
+
"none",
|
|
1423
|
+
"confirmed",
|
|
1424
|
+
"sent"
|
|
1425
|
+
],
|
|
1426
|
+
description: `none, confirmed (a chat's contact took it) or sent (a group's edge took it) ${ONE_SHOT_DEFAULT("confirmed")}`
|
|
1427
|
+
},
|
|
1428
|
+
timeout: groupWait.timeout
|
|
1429
|
+
};
|
|
1430
|
+
var usageWait = {
|
|
1431
|
+
wait: {
|
|
1432
|
+
type: "string",
|
|
1433
|
+
choices: ["none", "sent"],
|
|
1434
|
+
description: `none or sent: until the contact has it in a chat, an edge took it in a group ${ONE_SHOT_DEFAULT("sent")}`
|
|
1435
|
+
},
|
|
1436
|
+
timeout: groupWait.timeout
|
|
1437
|
+
};
|
|
1375
1438
|
var BUTTON_UPDATE = "button update <chat|group> <message> [--chosen <button>] [--close] [--text <text>] [--force] [--wait none|confirmed|sent] [--timeout s]";
|
|
1376
1439
|
/** Invites, chats and messages: one entry per command, in alphabetical order (test/commands.test.ts checks). */
|
|
1377
1440
|
var commands$6 = {
|
|
@@ -1450,10 +1513,17 @@ var commands$6 = {
|
|
|
1450
1513
|
},
|
|
1451
1514
|
"chat connect": {
|
|
1452
1515
|
method: "chat.connect",
|
|
1453
|
-
usage: "chat connect <chat>",
|
|
1516
|
+
usage: "chat connect <chat> [--timeout s]",
|
|
1454
1517
|
summary: "Reconnect a chat now (ends a --hold)",
|
|
1455
1518
|
args: ["chat"],
|
|
1456
|
-
|
|
1519
|
+
options: { timeout: {
|
|
1520
|
+
type: "number",
|
|
1521
|
+
description: `Seconds to wait for the contact (default and at most 90)`
|
|
1522
|
+
} },
|
|
1523
|
+
params: ({ options }, { chat }) => ({
|
|
1524
|
+
chat,
|
|
1525
|
+
timeout: timeout(options, 90)
|
|
1526
|
+
})
|
|
1457
1527
|
},
|
|
1458
1528
|
"chat disconnect": {
|
|
1459
1529
|
method: "chat.disconnect",
|
|
@@ -1652,22 +1722,35 @@ var commands$6 = {
|
|
|
1652
1722
|
},
|
|
1653
1723
|
"message delete": {
|
|
1654
1724
|
method: "chat.delete",
|
|
1655
|
-
usage: "message delete <chat|group> <message> [--everyone]",
|
|
1725
|
+
usage: "message delete <chat|group> <message> [--everyone [--wait none|confirmed] [--timeout s]]",
|
|
1656
1726
|
summary: "Forget a message on this device (the contact keeps theirs); --everyone deletes one of yours, in a chat or a group, from every member's device",
|
|
1657
1727
|
args: ["chat", "message"],
|
|
1658
|
-
options: {
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1728
|
+
options: {
|
|
1729
|
+
everyone: {
|
|
1730
|
+
type: "boolean",
|
|
1731
|
+
description: "Delete a message of yours for everyone (a chat or a group)"
|
|
1732
|
+
},
|
|
1733
|
+
wait: {
|
|
1734
|
+
type: "string",
|
|
1735
|
+
choices: ["none", "confirmed"],
|
|
1736
|
+
description: "With --everyone in a chat: none or confirmed, until the contact has it (default: none with a daemon, confirmed without)"
|
|
1737
|
+
},
|
|
1738
|
+
timeout: wait.timeout
|
|
1739
|
+
},
|
|
1740
|
+
params: ({ options }, a) => {
|
|
1741
|
+
for (const flag of ["wait", "timeout"]) if (options[flag] !== void 0 && options.everyone !== true) throw new CliError("usage", `--${flag} goes with --everyone`);
|
|
1742
|
+
return {
|
|
1743
|
+
chat: a.chat,
|
|
1744
|
+
message: a.message,
|
|
1745
|
+
everyone: options.everyone === true,
|
|
1746
|
+
wait: options.wait,
|
|
1747
|
+
timeout: timeout(options)
|
|
1748
|
+
};
|
|
1749
|
+
}
|
|
1667
1750
|
},
|
|
1668
1751
|
"message details": {
|
|
1669
1752
|
method: "chat.details",
|
|
1670
|
-
usage: "message details <chat> <message>",
|
|
1753
|
+
usage: "message details <chat|group> <message>",
|
|
1671
1754
|
summary: "How a message travelled",
|
|
1672
1755
|
args: ["chat", "message"],
|
|
1673
1756
|
params: (_, a) => ({
|
|
@@ -1687,46 +1770,56 @@ var commands$6 = {
|
|
|
1687
1770
|
},
|
|
1688
1771
|
"pin": {
|
|
1689
1772
|
method: "chat.pin",
|
|
1690
|
-
usage: "pin <chat|group> <message> | --remove",
|
|
1773
|
+
usage: "pin <chat|group> <message> | --remove [--wait none|confirmed] [--timeout s]",
|
|
1691
1774
|
summary: "Pin a message at the top of a chat or group (one per chat: it replaces the pinned one); --remove unpins",
|
|
1692
1775
|
args: ["chat", "message...?"],
|
|
1693
|
-
options: {
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1776
|
+
options: {
|
|
1777
|
+
remove: {
|
|
1778
|
+
type: "boolean",
|
|
1779
|
+
description: "Unpin the chat's pinned message (it names no message)"
|
|
1780
|
+
},
|
|
1781
|
+
...confirmWait
|
|
1782
|
+
},
|
|
1697
1783
|
params: ({ options }, a) => {
|
|
1698
1784
|
if (a.message === void 0 && options.remove !== true) throw new CliError("usage", "Missing <message>: ghostly pin <chat|group> <message> | --remove");
|
|
1699
1785
|
if (a.message?.includes(" ")) throw new CliError("usage", "Too many arguments: ghostly pin <chat|group> <message> | --remove");
|
|
1700
1786
|
return {
|
|
1701
1787
|
chat: a.chat,
|
|
1702
1788
|
message: a.message,
|
|
1703
|
-
remove: options.remove === true
|
|
1789
|
+
remove: options.remove === true,
|
|
1790
|
+
wait: options.wait,
|
|
1791
|
+
timeout: timeout(options)
|
|
1704
1792
|
};
|
|
1705
1793
|
}
|
|
1706
1794
|
},
|
|
1707
1795
|
"react": {
|
|
1708
1796
|
method: "chat.react",
|
|
1709
|
-
usage: "react <chat> <message> <emoji> [--remove]",
|
|
1797
|
+
usage: "react <chat> <message> <emoji> [--remove] [--wait none|confirmed] [--timeout s]",
|
|
1710
1798
|
summary: "React to a message with one emoji (it replaces yours); --remove takes yours back",
|
|
1711
1799
|
args: [
|
|
1712
1800
|
"chat",
|
|
1713
1801
|
"message",
|
|
1714
1802
|
"emoji...?"
|
|
1715
1803
|
],
|
|
1716
|
-
options: {
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1804
|
+
options: {
|
|
1805
|
+
remove: {
|
|
1806
|
+
type: "boolean",
|
|
1807
|
+
description: "Take your reaction back"
|
|
1808
|
+
},
|
|
1809
|
+
...confirmWait
|
|
1810
|
+
},
|
|
1720
1811
|
params: ({ options }, a) => ({
|
|
1721
1812
|
chat: a.chat,
|
|
1722
1813
|
message: a.message,
|
|
1723
1814
|
emoji: a.emoji,
|
|
1724
|
-
remove: options.remove === true
|
|
1815
|
+
remove: options.remove === true,
|
|
1816
|
+
wait: options.wait,
|
|
1817
|
+
timeout: timeout(options)
|
|
1725
1818
|
})
|
|
1726
1819
|
},
|
|
1727
1820
|
"routine send": {
|
|
1728
1821
|
method: "routine.send",
|
|
1729
|
-
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]",
|
|
1822
|
+
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]",
|
|
1730
1823
|
summary: "Send a routine card (something a bot runs on a schedule: its last run and the next) to a chat or group",
|
|
1731
1824
|
args: ["chat"],
|
|
1732
1825
|
options: {
|
|
@@ -1735,8 +1828,7 @@ var commands$6 = {
|
|
|
1735
1828
|
description: "The routine's id, kept across updates (default: made up)"
|
|
1736
1829
|
},
|
|
1737
1830
|
...routineOptions,
|
|
1738
|
-
...
|
|
1739
|
-
wait: wait.wait
|
|
1831
|
+
...cardWait
|
|
1740
1832
|
},
|
|
1741
1833
|
params: ({ options }, { chat }) => ({
|
|
1742
1834
|
chat,
|
|
@@ -1750,21 +1842,12 @@ var commands$6 = {
|
|
|
1750
1842
|
},
|
|
1751
1843
|
"routine update": {
|
|
1752
1844
|
method: "routine.update",
|
|
1753
|
-
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]",
|
|
1845
|
+
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]",
|
|
1754
1846
|
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)",
|
|
1755
1847
|
args: ["chat", "routine"],
|
|
1756
1848
|
options: {
|
|
1757
1849
|
...routineOptions,
|
|
1758
|
-
|
|
1759
|
-
type: "string",
|
|
1760
|
-
choices: [
|
|
1761
|
-
"none",
|
|
1762
|
-
"confirmed",
|
|
1763
|
-
"sent"
|
|
1764
|
-
],
|
|
1765
|
-
description: "none (default), confirmed (a chat's contact took it) or sent (a group's edge took it)"
|
|
1766
|
-
},
|
|
1767
|
-
timeout: groupWait.timeout
|
|
1850
|
+
...cardUpdateWait
|
|
1768
1851
|
},
|
|
1769
1852
|
params: ({ options }, a) => ({
|
|
1770
1853
|
chat: a.chat,
|
|
@@ -1804,7 +1887,7 @@ var commands$6 = {
|
|
|
1804
1887
|
},
|
|
1805
1888
|
"task send": {
|
|
1806
1889
|
method: "task.send",
|
|
1807
|
-
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]",
|
|
1890
|
+
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]",
|
|
1808
1891
|
summary: "Send a task card (a bot's work: status, progress, its PR) to a chat or group; prints its id and message",
|
|
1809
1892
|
args: ["chat"],
|
|
1810
1893
|
options: {
|
|
@@ -1813,8 +1896,7 @@ var commands$6 = {
|
|
|
1813
1896
|
description: "The task's id, kept across updates (default: made up)"
|
|
1814
1897
|
},
|
|
1815
1898
|
...taskOptions,
|
|
1816
|
-
...
|
|
1817
|
-
wait: wait.wait
|
|
1899
|
+
...cardWait
|
|
1818
1900
|
},
|
|
1819
1901
|
params: ({ options }, { chat }) => ({
|
|
1820
1902
|
chat,
|
|
@@ -1827,21 +1909,12 @@ var commands$6 = {
|
|
|
1827
1909
|
},
|
|
1828
1910
|
"task update": {
|
|
1829
1911
|
method: "task.update",
|
|
1830
|
-
usage: "task update <chat|group> <task> [--status s] [--progress n | --steps a/b] [--step \"...\"] [--item state:text]... [--pr-url
|
|
1912
|
+
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]",
|
|
1831
1913
|
summary: "Update a task card you sent: the fields given, merged over it (at most one update per 2.5 s; sooner ones merge)",
|
|
1832
1914
|
args: ["chat", "task"],
|
|
1833
1915
|
options: {
|
|
1834
1916
|
...taskOptions,
|
|
1835
|
-
|
|
1836
|
-
type: "string",
|
|
1837
|
-
choices: [
|
|
1838
|
-
"none",
|
|
1839
|
-
"confirmed",
|
|
1840
|
-
"sent"
|
|
1841
|
-
],
|
|
1842
|
-
description: "none (default), confirmed (a chat's contact took it) or sent (a group's edge took it)"
|
|
1843
|
-
},
|
|
1844
|
-
timeout: groupWait.timeout
|
|
1917
|
+
...cardUpdateWait
|
|
1845
1918
|
},
|
|
1846
1919
|
params: ({ options }, a) => ({
|
|
1847
1920
|
chat: a.chat,
|
|
@@ -1863,10 +1936,7 @@ var commands$6 = {
|
|
|
1863
1936
|
type: "boolean",
|
|
1864
1937
|
description: "Say you stopped"
|
|
1865
1938
|
},
|
|
1866
|
-
kind:
|
|
1867
|
-
type: "string",
|
|
1868
|
-
description: "typing (default), recording (a voice note) or thinking"
|
|
1869
|
-
},
|
|
1939
|
+
kind: typingKind,
|
|
1870
1940
|
status: {
|
|
1871
1941
|
type: "string",
|
|
1872
1942
|
description: "A short line shown instead, e.g. \"Transcribing your audio…\" (40 characters, no links)"
|
|
@@ -1886,15 +1956,16 @@ var commands$6 = {
|
|
|
1886
1956
|
},
|
|
1887
1957
|
"usage send": {
|
|
1888
1958
|
method: "usage.send",
|
|
1889
|
-
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]",
|
|
1959
|
+
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]",
|
|
1890
1960
|
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",
|
|
1891
1961
|
args: ["chat?"],
|
|
1892
1962
|
options: {
|
|
1893
1963
|
...usageOptions,
|
|
1894
|
-
...
|
|
1964
|
+
...usageWait
|
|
1895
1965
|
},
|
|
1896
1966
|
params: ({ options }, { chat }) => {
|
|
1897
1967
|
if (!chat && options.all !== true) throw new CliError("usage", "Name a chat or group, or give --all: ghostly usage send <chat|--all> --left <percent>");
|
|
1968
|
+
if (chat && options.all === true) throw new CliError("usage", "Name a chat or group or give --all, not both: ghostly usage send <chat|--all> --left <percent>");
|
|
1898
1969
|
return {
|
|
1899
1970
|
chat,
|
|
1900
1971
|
all: options.all === true,
|
|
@@ -2427,10 +2498,7 @@ var commands$3 = {
|
|
|
2427
2498
|
type: "boolean",
|
|
2428
2499
|
description: "Say you stopped"
|
|
2429
2500
|
},
|
|
2430
|
-
kind:
|
|
2431
|
-
type: "string",
|
|
2432
|
-
description: "typing (default), recording (a voice note) or thinking"
|
|
2433
|
-
},
|
|
2501
|
+
kind: typingKind,
|
|
2434
2502
|
status: {
|
|
2435
2503
|
type: "string",
|
|
2436
2504
|
description: "A short line shown instead, e.g. \"Reading the thread…\" (40 characters, no links)"
|
|
@@ -2472,7 +2540,7 @@ var commands$2 = {
|
|
|
2472
2540
|
},
|
|
2473
2541
|
stdin: {
|
|
2474
2542
|
type: "boolean",
|
|
2475
|
-
description: "The tool's output, from stdin"
|
|
2543
|
+
description: "The tool's output, from stdin (piped to it without the flag is read too)"
|
|
2476
2544
|
}
|
|
2477
2545
|
},
|
|
2478
2546
|
params: ({ options }, a) => {
|
|
@@ -2887,7 +2955,7 @@ var commands$1 = {
|
|
|
2887
2955
|
},
|
|
2888
2956
|
"wallet redeem": {
|
|
2889
2957
|
method: "wallet.redeem",
|
|
2890
|
-
usage: "wallet redeem [<cashu-token>]",
|
|
2958
|
+
usage: "wallet redeem [<cashu-token> | -]",
|
|
2891
2959
|
summary: "Take the ecash of a Cashu token (its mint must be one of yours); the token on stdin keeps it out of ps",
|
|
2892
2960
|
args: ["token?"],
|
|
2893
2961
|
params: (_, { token }) => ({ token })
|
|
@@ -2969,7 +3037,7 @@ var commands = {
|
|
|
2969
3037
|
params: ({ options }, a) => ({
|
|
2970
3038
|
chat: a.chat,
|
|
2971
3039
|
service: a.service,
|
|
2972
|
-
port: options
|
|
3040
|
+
port: inRange(options, "port", "a whole number", 0, 65535, true)
|
|
2973
3041
|
})
|
|
2974
3042
|
},
|
|
2975
3043
|
"service peer": {
|
|
@@ -3026,7 +3094,7 @@ var TEXT_COMMANDS = {
|
|
|
3026
3094
|
method: "chat.send",
|
|
3027
3095
|
target: "chat",
|
|
3028
3096
|
args: ["chat", "text...?"],
|
|
3029
|
-
usage: "send <chat> [text...] [--reply <message>] [--button id:Label]... [--style id=primary|neutral|danger]... [--once] [--id id] [--stdin] [--force] [--wait none|sent|delivered]",
|
|
3097
|
+
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]",
|
|
3030
3098
|
summary: "Send a message (text from arguments or stdin); --button puts buttons under it, each label its own (case aside)",
|
|
3031
3099
|
options: {
|
|
3032
3100
|
stdin: {
|
|
@@ -3048,7 +3116,7 @@ var TEXT_COMMANDS = {
|
|
|
3048
3116
|
"message",
|
|
3049
3117
|
"text...?"
|
|
3050
3118
|
],
|
|
3051
|
-
usage: "edit <chat> <message> [text... | --text <text> | --stdin] [--force] [--wait none|confirmed]",
|
|
3119
|
+
usage: "edit <chat> <message> [text... | --text <text> | --stdin] [--force] [--wait none|confirmed] [--timeout s]",
|
|
3052
3120
|
summary: "Replace the text of a message you sent (the id send gave; in a group, group edit)",
|
|
3053
3121
|
options: {
|
|
3054
3122
|
stdin: {
|
|
@@ -3213,6 +3281,19 @@ function noMoreThan(count, values, usage) {
|
|
|
3213
3281
|
if (values.length > count) throw new CliError("usage", `Too many arguments: ghostly ${usage}`);
|
|
3214
3282
|
}
|
|
3215
3283
|
//#endregion
|
|
3284
|
+
//#region src/jsonOut.ts
|
|
3285
|
+
/**
|
|
3286
|
+
* What `JSON.stringify` leaves raw and a terminal may act on: DEL and the C1 controls (CSI, OSC, ST, NEL... in UTF-8),
|
|
3287
|
+
* the line and paragraph separators, and the bidi marks, embeddings, overrides and isolates that reorder a line. Only
|
|
3288
|
+
* a string holds them, and a peer writes some of those strings (a message's text), so the CLI's output writes them as
|
|
3289
|
+
* `\uXXXX`: the same JSON value for every reader, nothing a terminal acts on. What is stored stays whole.
|
|
3290
|
+
*/
|
|
3291
|
+
var RAW = /[\u007f-\u009f\u061c\u200e\u200f\u2028\u2029\u202a-\u202e\u2066-\u2069]/g;
|
|
3292
|
+
/** `value` as the JSON the CLI prints: `JSON.stringify`, with `RAW` escaped. */
|
|
3293
|
+
function jsonOut(value, space) {
|
|
3294
|
+
return JSON.stringify(value, null, space)?.replace(RAW, (char) => "\\u" + char.charCodeAt(0).toString(16).padStart(4, "0"));
|
|
3295
|
+
}
|
|
3296
|
+
//#endregion
|
|
3216
3297
|
//#region src/listen.ts
|
|
3217
3298
|
/** The cursor's own write failed, not the event's handling. */
|
|
3218
3299
|
var CursorError = class extends Error {
|
|
@@ -3527,7 +3608,7 @@ async function post(url, event, retryMs) {
|
|
|
3527
3608
|
});
|
|
3528
3609
|
response.body?.cancel().catch(() => {});
|
|
3529
3610
|
if (response.ok) {
|
|
3530
|
-
if (holding) process.stderr.write(`ghostly: the webhook at ${url.
|
|
3611
|
+
if (holding) process.stderr.write(`ghostly: the webhook at ${url.origin} answers again: event ${event.seq} taken\n`);
|
|
3531
3612
|
return true;
|
|
3532
3613
|
}
|
|
3533
3614
|
status = response.status;
|
|
@@ -3536,7 +3617,7 @@ async function post(url, event, retryMs) {
|
|
|
3536
3617
|
if (!down && attempt >= 2) return status;
|
|
3537
3618
|
if (down && attempt >= 2 && !holding) {
|
|
3538
3619
|
holding = true;
|
|
3539
|
-
process.stderr.write(`ghostly: the webhook at ${url.
|
|
3620
|
+
process.stderr.write(`ghostly: the webhook at ${url.origin} is not answering: holding event ${event.seq} (${event.type}) until it does\n`);
|
|
3540
3621
|
}
|
|
3541
3622
|
await new Promise((resolve) => setTimeout(resolve, wait));
|
|
3542
3623
|
wait = Math.min(wait * 2, RETRY_MAX_MS);
|
|
@@ -3593,13 +3674,13 @@ function eventHandler(options) {
|
|
|
3593
3674
|
if (!next) return skip();
|
|
3594
3675
|
event = next;
|
|
3595
3676
|
}
|
|
3596
|
-
const full = options.print && options.write(
|
|
3677
|
+
const full = options.print && options.write(jsonOut(event)) === false;
|
|
3597
3678
|
if (options.exec) {
|
|
3598
3679
|
const code = await runExec(options.exec, event);
|
|
3599
3680
|
if (code !== 0) process.stderr.write(`ghostly: --exec exited ${code} on event ${event.seq} (${event.type})\n`);
|
|
3600
3681
|
}
|
|
3601
3682
|
const answered = webhook ? await post(webhook, event, options.retryMs ?? 500) : true;
|
|
3602
|
-
if (webhook && answered !== true) process.stderr.write(`ghostly: the webhook at ${webhook.
|
|
3683
|
+
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`);
|
|
3603
3684
|
if (full) await options.drained?.();
|
|
3604
3685
|
keep(event.seq);
|
|
3605
3686
|
}).catch((error) => {
|
|
@@ -3761,10 +3842,10 @@ var STDIN_GIVE_UP_MS = 6e4;
|
|
|
3761
3842
|
async function secretsFromStdin(method, params, read, tty = false, note = () => {}) {
|
|
3762
3843
|
const warning = (what) => `${what} on the command line shows in ps and the shell's history: give it on stdin instead`;
|
|
3763
3844
|
if (method === "wallet.redeem") {
|
|
3764
|
-
if (params.token !== void 0) return warning("A token");
|
|
3845
|
+
if (params.token !== void 0 && params.token !== "-") return warning("A token");
|
|
3765
3846
|
const missing = () => new CliError("usage", "Missing <cashu-token>: give it as an argument or on stdin (… | ghostly wallet redeem)");
|
|
3766
3847
|
if (tty) throw missing();
|
|
3767
|
-
const token = (await readUnasked(read, note, {
|
|
3848
|
+
const token = (params.token === "-" ? await read() : await readUnasked(read, note, {
|
|
3768
3849
|
what: "a Cashu token",
|
|
3769
3850
|
missing: "Missing <cashu-token>",
|
|
3770
3851
|
command: "wallet redeem",
|
|
@@ -3819,6 +3900,28 @@ async function textFromStdin(read, command, asked, note) {
|
|
|
3819
3900
|
as: "arguments"
|
|
3820
3901
|
})).replace(/\n$/, "");
|
|
3821
3902
|
}
|
|
3903
|
+
/**
|
|
3904
|
+
* `identity complete <draft>` with neither --evidence-file nor --stdin, stdin not a terminal: asked with nothing first,
|
|
3905
|
+
* since a published record takes none; a draft that answers it takes a tool's output (`details.needs`) is asked again
|
|
3906
|
+
* with what was piped, read as a send reads its text.
|
|
3907
|
+
*/
|
|
3908
|
+
async function completeWithPipedEvidence(call, params, read, note) {
|
|
3909
|
+
try {
|
|
3910
|
+
return await call(params);
|
|
3911
|
+
} catch (error) {
|
|
3912
|
+
if (!(error instanceof CliError) || error.details?.needs !== "evidence") throw error;
|
|
3913
|
+
}
|
|
3914
|
+
const evidence = await readUnasked(read, note, {
|
|
3915
|
+
what: "what the tool printed",
|
|
3916
|
+
missing: "Missing what the tool printed",
|
|
3917
|
+
command: `identity complete ${String(params.draft)}`,
|
|
3918
|
+
as: "--evidence-file f"
|
|
3919
|
+
});
|
|
3920
|
+
return call({
|
|
3921
|
+
...params,
|
|
3922
|
+
evidence
|
|
3923
|
+
});
|
|
3924
|
+
}
|
|
3822
3925
|
async function readUnasked(read, note, ask) {
|
|
3823
3926
|
let noteTimer, giveUpTimer;
|
|
3824
3927
|
const stop = () => {
|
|
@@ -3836,6 +3939,39 @@ async function readUnasked(read, note, ask) {
|
|
|
3836
3939
|
}
|
|
3837
3940
|
}
|
|
3838
3941
|
/**
|
|
3942
|
+
* `identity add`'s fields: each `--field name=value`, then with `--stdin` the `name=value` lines piped to it (a NIP-46
|
|
3943
|
+
* signer's bunker:// link holds the signer's secret). `secret`: the names the signer's form marks `kind: "secret"`
|
|
3944
|
+
* (`identitySecretFields`); one given as a `--field` still goes, with the warning. Neither error repeats a value.
|
|
3945
|
+
*/
|
|
3946
|
+
async function identityFields(items, stdin, secret, read, tty = false) {
|
|
3947
|
+
const fields = {};
|
|
3948
|
+
for (const item of items) {
|
|
3949
|
+
const eq = item.indexOf("=");
|
|
3950
|
+
if (eq < 1) throw new CliError("usage", "--field takes name=value, and one has no name or no =");
|
|
3951
|
+
fields[item.slice(0, eq)] = item.slice(eq + 1);
|
|
3952
|
+
}
|
|
3953
|
+
const onLine = secret.filter((name) => fields[name] !== void 0);
|
|
3954
|
+
if (stdin) {
|
|
3955
|
+
if (tty) throw new CliError("usage", "--stdin takes the fields as name=value lines piped to it (… | ghostly identity add <provider> --signer id --stdin), not a terminal");
|
|
3956
|
+
for (const line of (await read()).split(/\r?\n/)) {
|
|
3957
|
+
if (!line.trim()) continue;
|
|
3958
|
+
const eq = line.indexOf("=");
|
|
3959
|
+
if (eq < 1) throw new CliError("usage", "--stdin takes name=value lines, and one has no name or no =");
|
|
3960
|
+
fields[line.slice(0, eq).trim()] = line.slice(eq + 1);
|
|
3961
|
+
}
|
|
3962
|
+
}
|
|
3963
|
+
if (!onLine.length) return { fields };
|
|
3964
|
+
return {
|
|
3965
|
+
fields,
|
|
3966
|
+
warning: `${onLine.map((name) => `--field ${name}`).join(", ")} on the command line shows in ps and the shell's history: give ${onLine.length > 1 ? "them" : "it"} on stdin instead (--stdin, name=value lines)`
|
|
3967
|
+
};
|
|
3968
|
+
}
|
|
3969
|
+
/** The fields a provider's signer marks `kind: "secret"`: the one `--signer` names, or any of its signers when none is. */
|
|
3970
|
+
function identitySecretFields(provider, signer) {
|
|
3971
|
+
const signers = (provider?.signers ?? []).filter((s) => signer === void 0 || s.id === signer);
|
|
3972
|
+
return [...new Set(signers.flatMap((s) => (s.fields ?? []).filter((f) => f.kind === "secret").map((f) => f.name)))];
|
|
3973
|
+
}
|
|
3974
|
+
/**
|
|
3839
3975
|
* `wallet create --value`: the names given on the command line that the chosen source's form marks `kind: "secret"`
|
|
3840
3976
|
* (an NWC URI, a macaroon, a rune, an RPC password), as a warning. `list`: a `wallet.list` answer, where the forms are.
|
|
3841
3977
|
*/
|
|
@@ -3855,15 +3991,15 @@ var VERSION = package_default.version;
|
|
|
3855
3991
|
* command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
|
|
3856
3992
|
* cost every command ~100 ms before its socket was opened.
|
|
3857
3993
|
*/
|
|
3858
|
-
var engineApi = () => import("./api-
|
|
3859
|
-
var engineHost = () => import("./host-
|
|
3994
|
+
var engineApi = () => import("./api-B42F9ytB.js");
|
|
3995
|
+
var engineHost = () => import("./host-BX0DmKW6.js");
|
|
3860
3996
|
/**
|
|
3861
3997
|
* `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
|
|
3862
3998
|
* asked: the app's message parser it reads costs every other command nothing.
|
|
3863
3999
|
*/
|
|
3864
4000
|
async function translatorFor(value, home) {
|
|
3865
4001
|
if (value === void 0) return null;
|
|
3866
|
-
const { loadDetector, openTranslator, translateTarget } = await import("./translate-
|
|
4002
|
+
const { loadDetector, openTranslator, translateTarget } = await import("./translate-DObb-1tq.js");
|
|
3867
4003
|
return openTranslator({
|
|
3868
4004
|
home,
|
|
3869
4005
|
to: translateTarget(value),
|
|
@@ -3873,7 +4009,7 @@ async function translatorFor(value, home) {
|
|
|
3873
4009
|
}
|
|
3874
4010
|
var pretty = false;
|
|
3875
4011
|
function print(value) {
|
|
3876
|
-
process.stdout.write(
|
|
4012
|
+
process.stdout.write(jsonOut(value, pretty ? 2 : void 0) + "\n");
|
|
3877
4013
|
}
|
|
3878
4014
|
/** Done, with something to know (a voice note sent without its waveform): said on stderr, the JSON stays the answer. */
|
|
3879
4015
|
function printAnswer(result) {
|
|
@@ -4232,7 +4368,7 @@ var SPECIAL = [
|
|
|
4232
4368
|
"Keep the profile online (foreground; --detach runs it in the background)",
|
|
4233
4369
|
{
|
|
4234
4370
|
detach: o("boolean", "Run in the background (log in the profile folder)"),
|
|
4235
|
-
timeout: o("number", "Seconds
|
|
4371
|
+
timeout: o("number", "Seconds it waits for a command that holds the profile, and --detach for it to start (default 60)")
|
|
4236
4372
|
}
|
|
4237
4373
|
],
|
|
4238
4374
|
[
|
|
@@ -4289,11 +4425,12 @@ var SPECIAL = [
|
|
|
4289
4425
|
],
|
|
4290
4426
|
["call pipe [<chat|call>]", "A call's audio on stdin/stdout: raw s16le mono PCM at the call's rate (e.g. with sox or ffmpeg)"],
|
|
4291
4427
|
[
|
|
4292
|
-
"identity add <provider> [subject] [--signer id] [--field name=value]... [--days n]",
|
|
4428
|
+
"identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]",
|
|
4293
4429
|
"Make an identity proof (a tool's or a published one finishes with identity complete)",
|
|
4294
4430
|
{
|
|
4295
4431
|
signer: o("string", "Which signer makes the proof (identity providers lists them)"),
|
|
4296
4432
|
field: o("list", "A field of the provider's form, name=value"),
|
|
4433
|
+
stdin: o("boolean", "Take the fields as name=value lines on stdin (a signer's link: out of ps and the shell's history)"),
|
|
4297
4434
|
days: o("number", "How long the proof holds"),
|
|
4298
4435
|
timeout: o("number", "Seconds to wait for an approval")
|
|
4299
4436
|
}
|
|
@@ -4383,7 +4520,7 @@ function commandHelp(words) {
|
|
|
4383
4520
|
let rows = named(words);
|
|
4384
4521
|
while (!rows.length && words.length > 1) rows = named(words = words.slice(0, -1));
|
|
4385
4522
|
const asked = words.join(" ");
|
|
4386
|
-
if (!rows.length) throw new CliError("usage", `Unknown command: ${asked} (ghostly help)`);
|
|
4523
|
+
if (!rows.length) throw new CliError("usage", `Unknown command: ${asked || "\"\""} (ghostly help)`);
|
|
4387
4524
|
const exact = rows.filter((row) => commandWords(row.usage).join(" ") === asked);
|
|
4388
4525
|
if (!exact.length && words.length < given.length) throw unknownCommand(given[0], given[1], given[2]);
|
|
4389
4526
|
const lines = [];
|
|
@@ -4457,7 +4594,8 @@ async function profileCommand(sub, argv) {
|
|
|
4457
4594
|
},
|
|
4458
4595
|
"share-profile": {
|
|
4459
4596
|
type: "boolean",
|
|
4460
|
-
description: ""
|
|
4597
|
+
description: "",
|
|
4598
|
+
eitherWay: true
|
|
4461
4599
|
}
|
|
4462
4600
|
}
|
|
4463
4601
|
}[sub ?? ""] ?? {});
|
|
@@ -4466,7 +4604,8 @@ async function profileCommand(sub, argv) {
|
|
|
4466
4604
|
switch (sub) {
|
|
4467
4605
|
case "create": {
|
|
4468
4606
|
const [name] = parsed.positionals;
|
|
4469
|
-
if (!name
|
|
4607
|
+
if (!name) throw new CliError("usage", "Missing <name>: ghostly profile create <name> [--use] [--name <shown name>]");
|
|
4608
|
+
noMoreThan(1, parsed.positionals, "profile create <name> [--use] [--name <shown name>]");
|
|
4470
4609
|
const shownName = parsed.options.name === void 0 ? void 0 : checkShownName(parsed.options.name);
|
|
4471
4610
|
const paths = createProfile(g.home, name);
|
|
4472
4611
|
let shown = null;
|
|
@@ -4507,7 +4646,7 @@ async function profileCommand(sub, argv) {
|
|
|
4507
4646
|
}
|
|
4508
4647
|
case "use": {
|
|
4509
4648
|
const [name] = parsed.positionals;
|
|
4510
|
-
if (!name) throw new CliError("usage", "ghostly profile use <name>");
|
|
4649
|
+
if (!name) throw new CliError("usage", "Missing <name>: ghostly profile use <name>");
|
|
4511
4650
|
noMoreThan(1, parsed.positionals, "profile use <name>");
|
|
4512
4651
|
selectProfile(g.home, name);
|
|
4513
4652
|
print({ current: name });
|
|
@@ -4522,14 +4661,14 @@ async function profileCommand(sub, argv) {
|
|
|
4522
4661
|
const params = {};
|
|
4523
4662
|
if (parsed.options.name !== void 0) params.name = parsed.options.name;
|
|
4524
4663
|
if (parsed.options["share-profile"] !== void 0) params.shareProfile = parsed.options["share-profile"];
|
|
4525
|
-
if (!Object.keys(params).length) throw new CliError("usage", "ghostly profile set [--name <name>] [--share-profile | --no-share-profile]");
|
|
4664
|
+
if (!Object.keys(params).length) throw new CliError("usage", "Nothing to change: ghostly profile set [--name <name>] [--share-profile | --no-share-profile]");
|
|
4526
4665
|
print(await withSession(g, (s) => s.call("profile.set", params)));
|
|
4527
4666
|
return;
|
|
4528
4667
|
}
|
|
4529
4668
|
case "backup": {
|
|
4530
4669
|
noMoreThan(0, parsed.positionals, "profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light]");
|
|
4531
4670
|
const out = parsed.options.out;
|
|
4532
|
-
if (typeof out !== "string") throw new CliError("usage", "ghostly profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light]
|
|
4671
|
+
if (typeof out !== "string") throw new CliError("usage", "Missing --out: ghostly profile backup --out <file> [--passphrase-file f | --no-passphrase] [--light]");
|
|
4533
4672
|
const unsealed = parsed.options.passphrase === false;
|
|
4534
4673
|
if (parsed.options.passphrase === true) throw new CliError("usage", "The passphrase comes from --passphrase-file or GHOSTLY_BACKUP_PASSPHRASE, never the command line");
|
|
4535
4674
|
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");
|
|
@@ -4551,10 +4690,10 @@ async function profileCommand(sub, argv) {
|
|
|
4551
4690
|
}
|
|
4552
4691
|
case "restore": {
|
|
4553
4692
|
const [given, name] = parsed.positionals;
|
|
4554
|
-
if (!given || !name) throw new CliError("usage", "ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]
|
|
4693
|
+
if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
|
|
4555
4694
|
noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4556
4695
|
const file = here(given);
|
|
4557
|
-
const { backupFileProtection, restoreProfile } = await import("./backup-
|
|
4696
|
+
const { backupFileProtection, restoreProfile } = await import("./backup-BkUeeduy.js");
|
|
4558
4697
|
const protection = await backupFileProtection(file);
|
|
4559
4698
|
const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
|
|
4560
4699
|
if (parsed.options.use) selectProfile(g.home, name);
|
|
@@ -4615,11 +4754,30 @@ function backupPassphrase(file, missing = BACKUP_PASSPHRASE) {
|
|
|
4615
4754
|
if (!value) throw new CliError("bad_request", `${file} is empty: it holds the backup's passphrase`);
|
|
4616
4755
|
return value;
|
|
4617
4756
|
}
|
|
4618
|
-
|
|
4757
|
+
/** Set on `startDetached`'s child: its parent waits for the profile and starts it again, so the child does not wait too. */
|
|
4758
|
+
var DETACHED_CHILD = "GHOSTLY_DAEMON_DETACHED";
|
|
4759
|
+
/**
|
|
4760
|
+
* The daemon in this process. A one-shot command that holds the profile for a moment (a bot's `send` in the gap of a
|
|
4761
|
+
* service manager's restart) is waited for until `seconds`, as `daemon --detach` waits for it: the first look used to be
|
|
4762
|
+
* the answer, and the profile was left with no daemon. A daemon that comes up meanwhile is the answer instead.
|
|
4763
|
+
*/
|
|
4764
|
+
async function runDaemon(g, seconds) {
|
|
4619
4765
|
requireProfile(g);
|
|
4620
|
-
|
|
4766
|
+
const detached = process.env[DETACHED_CHILD] === "1";
|
|
4767
|
+
delete process.env[DETACHED_CHILD];
|
|
4621
4768
|
const { keepServing, openHost, serve } = await engineHost();
|
|
4622
|
-
const
|
|
4769
|
+
const until = Date.now() + seconds * 1e3;
|
|
4770
|
+
let host;
|
|
4771
|
+
for (;;) {
|
|
4772
|
+
if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
|
|
4773
|
+
try {
|
|
4774
|
+
host = await openHost(g.paths, "daemon", VERSION);
|
|
4775
|
+
break;
|
|
4776
|
+
} catch (error) {
|
|
4777
|
+
if (detached || !(error instanceof CliError) || error.code !== "busy" || Date.now() >= until) throw error;
|
|
4778
|
+
await new Promise((resolve) => setTimeout(resolve, Math.max(0, Math.min(100, until - Date.now()))));
|
|
4779
|
+
}
|
|
4780
|
+
}
|
|
4623
4781
|
let served;
|
|
4624
4782
|
try {
|
|
4625
4783
|
served = await serve(host);
|
|
@@ -4728,7 +4886,7 @@ async function daemonCommand(argv) {
|
|
|
4728
4886
|
if (sub) throw unknownCommand("daemon", sub);
|
|
4729
4887
|
const startFor = seconds(parsed, 60);
|
|
4730
4888
|
if (!parsed.options.detach) {
|
|
4731
|
-
await runDaemon(g);
|
|
4889
|
+
await runDaemon(g, startFor);
|
|
4732
4890
|
return;
|
|
4733
4891
|
}
|
|
4734
4892
|
print(await startDetached(g, startFor));
|
|
@@ -4838,7 +4996,11 @@ async function spawnDaemon(g, until) {
|
|
|
4838
4996
|
"ignore",
|
|
4839
4997
|
log,
|
|
4840
4998
|
log
|
|
4841
|
-
]
|
|
4999
|
+
],
|
|
5000
|
+
env: {
|
|
5001
|
+
...process.env,
|
|
5002
|
+
[DETACHED_CHILD]: "1"
|
|
5003
|
+
}
|
|
4842
5004
|
});
|
|
4843
5005
|
closeSync(log);
|
|
4844
5006
|
child.unref();
|
|
@@ -5122,7 +5284,8 @@ async function engineCommand(argv) {
|
|
|
5122
5284
|
return;
|
|
5123
5285
|
}
|
|
5124
5286
|
const [method, raw] = parsed.positionals;
|
|
5125
|
-
if (!method
|
|
5287
|
+
if (!method) throw new CliError("usage", "Missing <method>: ghostly engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]");
|
|
5288
|
+
noMoreThan(2, parsed.positionals, "engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]");
|
|
5126
5289
|
if (!ENGINE_METHODS.includes(method) && !ENGINE_READS.includes(method)) throw new CliError("not_found", `The engine has no call ${method} (ghostly engine --list)`);
|
|
5127
5290
|
const showSecret = parsed.options["show-secret"] === true;
|
|
5128
5291
|
if (SECRET_RESULTS.has(method) && !showSecret) throw new CliError("confirm", `${method} answers with secrets: add --show-secret to print them`);
|
|
@@ -5163,7 +5326,8 @@ async function settingsCommand(sub, argv) {
|
|
|
5163
5326
|
}
|
|
5164
5327
|
if (sub === "set") {
|
|
5165
5328
|
const [key, value] = parsed.positionals;
|
|
5166
|
-
if (!key || value === void 0
|
|
5329
|
+
if (!key || value === void 0) throw new CliError("usage", `Missing <${key ? "json-value" : "key"}>: ghostly settings set <key> <json-value>`);
|
|
5330
|
+
noMoreThan(2, parsed.positionals, "settings set <key> <json-value>");
|
|
5167
5331
|
let parsedValue;
|
|
5168
5332
|
try {
|
|
5169
5333
|
parsedValue = JSON.parse(value);
|
|
@@ -5183,7 +5347,7 @@ async function textCommand(name, argv) {
|
|
|
5183
5347
|
pretty = g.pretty;
|
|
5184
5348
|
const [target, ...rest] = parsed.positionals;
|
|
5185
5349
|
const [message, ...words] = spec.message ? rest : [void 0, ...rest];
|
|
5186
|
-
if (!target || spec.message && !message) throw new CliError("usage", `ghostly ${spec.usage}`);
|
|
5350
|
+
if (!target || spec.message && !message) throw new CliError("usage", `Missing <${target ? "message" : spec.target}>: ghostly ${spec.usage}`);
|
|
5187
5351
|
timeout(parsed.options);
|
|
5188
5352
|
let text = words.join(" ");
|
|
5189
5353
|
if (parsed.options.text !== void 0) {
|
|
@@ -5202,7 +5366,7 @@ async function textCommand(name, argv) {
|
|
|
5202
5366
|
};
|
|
5203
5367
|
if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
|
|
5204
5368
|
if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
|
|
5205
|
-
if (!spec.message) Object.assign(params, (await import("./buttons-
|
|
5369
|
+
if (!spec.message) Object.assign(params, (await import("./buttons-Be7u0V5g.js")).buttonsOf(parsed.options));
|
|
5206
5370
|
print(await withSession(g, (s) => {
|
|
5207
5371
|
if (spec.target === "chat") {
|
|
5208
5372
|
params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
|
|
@@ -5229,6 +5393,10 @@ async function identityAddCommand(argv) {
|
|
|
5229
5393
|
type: "list",
|
|
5230
5394
|
description: ""
|
|
5231
5395
|
},
|
|
5396
|
+
stdin: {
|
|
5397
|
+
type: "boolean",
|
|
5398
|
+
description: ""
|
|
5399
|
+
},
|
|
5232
5400
|
days: {
|
|
5233
5401
|
type: "number",
|
|
5234
5402
|
description: ""
|
|
@@ -5241,13 +5409,13 @@ async function identityAddCommand(argv) {
|
|
|
5241
5409
|
const g = globals(parsed);
|
|
5242
5410
|
pretty = g.pretty;
|
|
5243
5411
|
const [provider, ...subject] = parsed.positionals;
|
|
5244
|
-
if (!provider) throw new CliError("usage", "ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--days n]");
|
|
5245
|
-
|
|
5246
|
-
|
|
5247
|
-
|
|
5248
|
-
|
|
5249
|
-
|
|
5250
|
-
}
|
|
5412
|
+
if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
|
|
5413
|
+
inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
|
|
5414
|
+
const items = parsed.options.field ?? [];
|
|
5415
|
+
const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-CFtlhWCI.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
|
|
5416
|
+
if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
|
|
5417
|
+
const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
|
|
5418
|
+
if (warning) process.stderr.write(`ghostly: ${warning}\n`);
|
|
5251
5419
|
const params = {
|
|
5252
5420
|
provider,
|
|
5253
5421
|
subject: subject.join(" ") || void 0,
|
|
@@ -5301,6 +5469,7 @@ async function tableCommand(name, argv) {
|
|
|
5301
5469
|
const params = command.params?.(parsed, args) ?? {};
|
|
5302
5470
|
for (const key of Object.keys(params)) if (params[key] === void 0) delete params[key];
|
|
5303
5471
|
const translator = await translatorFor(parsed.options.translate, g.home);
|
|
5472
|
+
const pipedEvidence = command.method === "identity.complete" && !params.evidenceFile && !params.stdin && process.stdin.isTTY !== true;
|
|
5304
5473
|
if (command.method === "identity.complete") {
|
|
5305
5474
|
if (params.evidenceFile) try {
|
|
5306
5475
|
params.evidence = readFileSync(params.evidenceFile, "utf8");
|
|
@@ -5317,7 +5486,8 @@ async function tableCommand(name, argv) {
|
|
|
5317
5486
|
} catch (error) {
|
|
5318
5487
|
throw localFileError(error, params.file) ?? new CliError("usage", `Cannot read the credential: ${error instanceof Error ? error.message : String(error)}`);
|
|
5319
5488
|
}
|
|
5320
|
-
if (!params.credential
|
|
5489
|
+
if (!params.credential && params.file === "-") throw new CliError("usage", "Missing <file|->: give the SD-JWT VC on stdin (… | ghostly x401 credential add -) or as a file");
|
|
5490
|
+
if (!params.credential) throw new CliError("bad_request", `${params.file} is empty: it holds the SD-JWT VC the issuer sent`);
|
|
5321
5491
|
delete params.file;
|
|
5322
5492
|
}
|
|
5323
5493
|
const lineValues = command.method === "wallet.create" ? Object.keys(params.values ?? {}) : [];
|
|
@@ -5328,7 +5498,7 @@ async function tableCommand(name, argv) {
|
|
|
5328
5498
|
const warning = secretValuesWarning(await s.call("wallet.list", { network: params.network ?? "testnet" }).catch(() => void 0), params.type, params.provider, lineValues);
|
|
5329
5499
|
if (warning) process.stderr.write(`ghostly: ${warning}\n`);
|
|
5330
5500
|
}
|
|
5331
|
-
const result = await s.call(command.method, params);
|
|
5501
|
+
const result = await (pipedEvidence ? completeWithPipedEvidence((p) => s.call(command.method, p), params, readStdin, (note) => process.stderr.write(`ghostly: ${note}\n`)) : s.call(command.method, params));
|
|
5332
5502
|
if (command.method === "invite.join" && s.mode === "one-shot") {
|
|
5333
5503
|
const joined = await oneShotJoinWait(s, result, typeof params.label === "string" ? params.label : void 0);
|
|
5334
5504
|
if (joined.note) process.stderr.write(`ghostly: ${joined.note}\n`);
|
|
@@ -5342,7 +5512,7 @@ async function tableCommand(name, argv) {
|
|
|
5342
5512
|
});
|
|
5343
5513
|
if (translator) {
|
|
5344
5514
|
try {
|
|
5345
|
-
printAnswer(await (await import("./translate-
|
|
5515
|
+
printAnswer(await (await import("./translate-DObb-1tq.js")).translateAnswer(result, translator));
|
|
5346
5516
|
} finally {
|
|
5347
5517
|
translator.close();
|
|
5348
5518
|
}
|
|
@@ -5485,7 +5655,7 @@ function unknownCommand(first, second, third) {
|
|
|
5485
5655
|
const list = `${subs.slice(0, -1).join(", ")}${subs.length > 1 ? " or " : ""}${subs.at(-1)}`;
|
|
5486
5656
|
return new CliError("usage", extra ? `Unknown command: ${name} ${extra}: ghostly ${name} takes ${list} (ghostly help ${name})` : `ghostly ${name} takes a command: ${list} (ghostly help ${name})`);
|
|
5487
5657
|
}
|
|
5488
|
-
return new CliError("usage", `Unknown command: ${asked.slice(0, 2).join(" ")} (ghostly help)`);
|
|
5658
|
+
return new CliError("usage", `Unknown command: ${asked.slice(0, 2).join(" ") || "\"\""} (ghostly help)`);
|
|
5489
5659
|
}
|
|
5490
5660
|
/** Leaves once what was printed reached stdout (a pipe drains asynchronously). */
|
|
5491
5661
|
function exit(code) {
|
|
@@ -5521,4 +5691,4 @@ async function run(argv) {
|
|
|
5521
5691
|
//#endregion
|
|
5522
5692
|
export { run };
|
|
5523
5693
|
|
|
5524
|
-
//# sourceMappingURL=main-
|
|
5694
|
+
//# sourceMappingURL=main-6QOSvQ8b.js.map
|