@ghostlytools/cli 1.8.1 → 1.10.0
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 +34 -23
- package/SKILL.md +9 -4
- package/dist/assets/{api-BpQC8dAw.js → api-BF_KwecF.js} +115 -45
- package/dist/assets/api-BF_KwecF.js.map +1 -0
- package/dist/assets/{api-CttDF-S5.js → api-DdrA86Ur.js} +2 -2
- package/dist/assets/{apiKit-CSMeHKgo.js → apiKit-Du1u2l4x.js} +8 -8
- package/dist/assets/apiKit-Du1u2l4x.js.map +1 -0
- package/dist/assets/{apps-DzFMdVt6.js → apps-Bti9fDoW.js} +1 -1
- package/dist/assets/{apps-DqTyZ40T.js → apps-DwPfp54I.js} +5 -3
- package/dist/assets/apps-DwPfp54I.js.map +1 -0
- package/dist/assets/{arkade-Cu3TbPxC.js → arkade-DOWpA2Kr.js} +2 -2
- package/dist/assets/{arkade-Cu3TbPxC.js.map → arkade-DOWpA2Kr.js.map} +1 -1
- package/dist/assets/{backup-CLZOORFC.js → backup-CeRckyl2.js} +1 -1
- package/dist/assets/{backup-CyTZhu28.js → backup-DZ_Q1eSu.js} +6 -6
- package/dist/assets/{backup-CyTZhu28.js.map → backup-DZ_Q1eSu.js.map} +1 -1
- package/dist/assets/{blobFiles-DOQDRdDI.js → blobFiles-BnjN_Vrz.js} +3 -3
- package/dist/assets/{blobFiles-DOQDRdDI.js.map → blobFiles-BnjN_Vrz.js.map} +1 -1
- package/dist/assets/buttons-BxIThdg9.js +332 -0
- package/dist/assets/buttons-BxIThdg9.js.map +1 -0
- package/dist/assets/buttons-D9QBHS9Y.js +2 -0
- package/dist/assets/client-D5E1RQYB.js +473 -0
- package/dist/assets/client-D5E1RQYB.js.map +1 -0
- package/dist/assets/{endpoint-BdaeBw2L.js → endpoint-DWHkXWVM.js} +101 -16
- package/dist/assets/endpoint-DWHkXWVM.js.map +1 -0
- package/dist/assets/{envelope-CGfUsR1m.js → envelope-CugS9qwQ.js} +2 -2
- package/dist/assets/{envelope-CGfUsR1m.js.map → envelope-CugS9qwQ.js.map} +1 -1
- package/dist/assets/{fileBytes-BPDKufla.js → fileBytes-DMzrIdCu.js} +1 -1
- package/dist/assets/{fileBytes-DNgrRL0R.js → fileBytes-DjBYYyXT.js} +3 -3
- package/dist/assets/{fileBytes-DNgrRL0R.js.map → fileBytes-DjBYYyXT.js.map} +1 -1
- package/dist/assets/{fileBytes-Q3ehcEr8.js → fileBytes-Douk1yOp.js} +2 -2
- package/dist/assets/{fileBytes-Q3ehcEr8.js.map → fileBytes-Douk1yOp.js.map} +1 -1
- package/dist/assets/fileBytesIdb-CD5Uv490.js +2 -0
- package/dist/assets/{fileBytesIdb-Dm1EyEbT.js → fileBytesIdb-CkClu9YI.js} +3 -3
- package/dist/assets/{fileBytesIdb-Dm1EyEbT.js.map → fileBytesIdb-CkClu9YI.js.map} +1 -1
- package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js → fileBytesOpfs-WryQuOgK.js} +3 -3
- package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js.map → fileBytesOpfs-WryQuOgK.js.map} +1 -1
- package/dist/assets/{fixedHosts-BiukTsd9.js → fixedHosts-B4E4VrYE.js} +4 -4
- package/dist/assets/{fixedHosts-BiukTsd9.js.map → fixedHosts-B4E4VrYE.js.map} +1 -1
- package/dist/assets/{groupFiles-CeF9nPv9.js → groupFiles-NonOYBKN.js} +380 -650
- package/dist/assets/groupFiles-NonOYBKN.js.map +1 -0
- package/dist/assets/{host-CKAehWP6.js → host-DvcVt5YI.js} +144 -33
- package/dist/assets/host-DvcVt5YI.js.map +1 -0
- package/dist/assets/{hyperdhtRelay-B8Pdykhg.js → hyperdhtRelay-Ce42sR8x.js} +2 -2
- package/dist/assets/{hyperdhtRelay-B8Pdykhg.js.map → hyperdhtRelay-Ce42sR8x.js.map} +1 -1
- package/dist/assets/{idb-BkOJES5_.js → idb-BHsAqENE.js} +37 -6
- package/dist/assets/idb-BHsAqENE.js.map +1 -0
- package/dist/assets/{irohWeb-D6tAPHZa.js → irohWeb-C9ChbD-c.js} +71 -4
- package/dist/assets/{irohWeb-D6tAPHZa.js.map → irohWeb-C9ChbD-c.js.map} +1 -1
- package/dist/assets/{main-BDY-pfpz.js → main-4qE381KM.js} +226 -280
- package/dist/assets/main-4qE381KM.js.map +1 -0
- package/dist/assets/{mainline-3ueXpFQL.js → mainline-DOwZDHVy.js} +2 -2
- package/dist/assets/{mainline-3ueXpFQL.js.map → mainline-DOwZDHVy.js.map} +1 -1
- package/dist/assets/{networkReason-DhJYOomu.js → networkReason-MInk1Y63.js} +3 -3
- package/dist/assets/{networkReason-DhJYOomu.js.map → networkReason-MInk1Y63.js.map} +1 -1
- package/dist/assets/{nwc-B1Quqda-.js → nwc-CHLWFV1R.js} +3 -3
- package/dist/assets/{nwc-B1Quqda-.js.map → nwc-CHLWFV1R.js.map} +1 -1
- package/dist/assets/{nwcProvider-DUB6xO-b.js → nwcProvider-BlkPOJen.js} +2 -2
- package/dist/assets/{nwcProvider-DUB6xO-b.js.map → nwcProvider-BlkPOJen.js.map} +1 -1
- package/dist/assets/{ownDid-BfqHJdA6.js → ownDid-yXtY_1B5.js} +3 -3
- package/dist/assets/ownDid-yXtY_1B5.js.map +1 -0
- package/dist/assets/{profiles-MFtCmJwK.js → profiles-vbXHs0Mq.js} +40 -3
- package/dist/assets/profiles-vbXHs0Mq.js.map +1 -0
- package/dist/assets/{registry-CZTmtSws.js → registry-BN9r2pR4.js} +1 -1
- package/dist/assets/{registry-DwlTNQjr.js → registry-chCD0KWS.js} +5 -5
- package/dist/assets/registry-chCD0KWS.js.map +1 -0
- package/dist/assets/{resolve-BVwhiYjj.js → resolve-Dtzogt2W.js} +2 -2
- package/dist/assets/{resolve-BVwhiYjj.js.map → resolve-Dtzogt2W.js.map} +1 -1
- package/dist/assets/{restoredRows-BCRCjhdF.js → restoredRows-CRYwIx3g.js} +2 -2
- package/dist/assets/{restoredRows-BCRCjhdF.js.map → restoredRows-CRYwIx3g.js.map} +1 -1
- package/dist/assets/secretGuard-CSVNxXVW.js +1081 -0
- package/dist/assets/secretGuard-CSVNxXVW.js.map +1 -0
- package/dist/assets/secretGuard-Q2BKq0q0.js +2 -0
- package/dist/assets/{server-Br3XPwFG.js → server-BZnsm5X5.js} +2510 -569
- package/dist/assets/server-BZnsm5X5.js.map +1 -0
- package/dist/assets/{src-C4sOH4zH.js → src-DZagapGt.js} +2015 -161
- package/dist/assets/src-DZagapGt.js.map +1 -0
- package/dist/assets/{sshForges-CQQomStK.js → sshForges-BkTgy5rx.js} +16 -9
- package/dist/assets/{sshForges-CQQomStK.js.map → sshForges-BkTgy5rx.js.map} +1 -1
- package/dist/assets/{translate-C2aNyUkR.js → translate-B9SMd6uf.js} +15 -8
- package/dist/assets/translate-B9SMd6uf.js.map +1 -0
- package/dist/assets/{usdt-CMwatDnQ.js → usdt-BU4ezonh.js} +3 -3
- package/dist/assets/{usdt-CMwatDnQ.js.map → usdt-BU4ezonh.js.map} +1 -1
- package/dist/assets/{waitNotice-Ck3el3_Z.js → waitNotice-B8D8WhbE.js} +2 -2
- package/dist/assets/waitNotice-B8D8WhbE.js.map +1 -0
- package/dist/assets/{words-CqN2KG1r.js → words-jYy7lTcb.js} +5 -2
- package/dist/assets/words-jYy7lTcb.js.map +1 -0
- package/dist/ghostly.mjs +1 -1
- package/examples/call-echo.mjs +7 -5
- package/package.json +1 -1
- package/dist/assets/api-BpQC8dAw.js.map +0 -1
- package/dist/assets/apiKit-CSMeHKgo.js.map +0 -1
- package/dist/assets/apps-DqTyZ40T.js.map +0 -1
- package/dist/assets/buttons-Bd9fR31r.js +0 -698
- package/dist/assets/buttons-Bd9fR31r.js.map +0 -1
- package/dist/assets/buttons-c4CJnL6i.js +0 -2
- package/dist/assets/daemonProof-DtrL5lE5.js +0 -236
- package/dist/assets/daemonProof-DtrL5lE5.js.map +0 -1
- package/dist/assets/endpoint-BdaeBw2L.js.map +0 -1
- package/dist/assets/fileBytesIdb-DZcESfTt.js +0 -2
- package/dist/assets/groupFiles-CeF9nPv9.js.map +0 -1
- package/dist/assets/host-CKAehWP6.js.map +0 -1
- package/dist/assets/idb-BkOJES5_.js.map +0 -1
- package/dist/assets/main-BDY-pfpz.js.map +0 -1
- package/dist/assets/ownDid-BfqHJdA6.js.map +0 -1
- package/dist/assets/profiles-MFtCmJwK.js.map +0 -1
- package/dist/assets/registry-DwlTNQjr.js.map +0 -1
- package/dist/assets/server-Br3XPwFG.js.map +0 -1
- package/dist/assets/src-C4sOH4zH.js.map +0 -1
- package/dist/assets/translate-C2aNyUkR.js.map +0 -1
- package/dist/assets/waitNotice-Ck3el3_Z.js.map +0 -1
- package/dist/assets/words-CqN2KG1r.js.map +0 -1
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as WALLET_TYPES, d as ENGINE_READS, f as READ_PARAMS, i as TRANSPORT_NAMES, l as ENGINE_METHODS, n as CHAT_METHODS, o as turnRef, p as SECRET_RESULTS, r as PAY_METHODS, t as ADDRESS_TYPES, u as ENGINE_PARAMS } from "./words-CqN2KG1r.js";
|
|
1
|
+
import { Ca as VOICE_LIMITS, _o as cardUrl, ao as CRON_LINE, bo as statusCardBytes, co as PR_STATES, do as STATUS_CARD_LIMITS, er as GROUP_FILE_LIMITS, fo as TASK_STATUSES, go as cardLine, lo as ROUTINE_STATES, oo as ITEM_STATES, so as PR_CHECKS, uo as RUN_RESULTS } from "./src-DZagapGt.js";
|
|
3
2
|
import { i as localFileError, n as EXIT, r as asCliError, t as CliError } from "./errors-R4S2SAEM.js";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
3
|
+
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-jYy7lTcb.js";
|
|
4
|
+
import { m as namedByThem, t as CONTACT_KEY } from "./apiKit-Du1u2l4x.js";
|
|
5
|
+
import { _ as userPath, a as checkShownName, c as ghostlyHome, f as profileExists, h as startingDaemon, i as checkProfileName, l as listProfiles, m as selectProfile, o as createProfile, p as profilePaths, s as currentProfile, u as lockOwner, y as ownProfile } from "./profiles-vbXHs0Mq.js";
|
|
6
|
+
import { n as waitNotice, r as waitsFor } from "./waitNotice-B8D8WhbE.js";
|
|
7
|
+
import { g as isCallRate, i as isNotTheDaemon, r as connectDaemon, t as DaemonClient, u as CALL_RATES } from "./client-D5E1RQYB.js";
|
|
8
8
|
import { spawn } from "node:child_process";
|
|
9
9
|
import { accessSync, closeSync, constants, existsSync, fstatSync, openSync, readFileSync, readSync, renameSync, rmSync, statSync, writeFileSync } from "node:fs";
|
|
10
10
|
import { dirname, resolve } from "node:path";
|
|
11
11
|
import { connect } from "node:net";
|
|
12
|
-
import { createInterface } from "node:readline";
|
|
13
12
|
import { format } from "node:util";
|
|
14
13
|
var package_default = {
|
|
15
14
|
name: "@ghostlytools/cli",
|
|
16
|
-
version: "1.
|
|
15
|
+
version: "1.10.0",
|
|
17
16
|
type: "module",
|
|
18
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.",
|
|
19
18
|
license: "MIT",
|
|
@@ -159,7 +158,8 @@ function parseArgs(argv, spec, idSlot = () => false, parsing) {
|
|
|
159
158
|
if (!long) throw unknownOption(arg, all, parsing);
|
|
160
159
|
name = long;
|
|
161
160
|
}
|
|
162
|
-
if (name.startsWith("no-") && all[name.slice(3)]?.type === "boolean"
|
|
161
|
+
if (name.startsWith("no-") && all[name.slice(3)]?.type === "boolean") {
|
|
162
|
+
if (inline !== void 0) throw new CliError("usage", `--${name} takes no value`);
|
|
163
163
|
setBoolean(name.slice(3), false);
|
|
164
164
|
continue;
|
|
165
165
|
}
|
|
@@ -284,232 +284,6 @@ function liftGlobals(argv) {
|
|
|
284
284
|
];
|
|
285
285
|
}
|
|
286
286
|
//#endregion
|
|
287
|
-
//#region src/client.ts
|
|
288
|
-
/** The id of the hello on every connection: a string, so it is never one of the calls' numbers. */
|
|
289
|
-
var HELLO_ID = "hello";
|
|
290
|
-
/**
|
|
291
|
-
* How long a client waits for the daemon's greeting before it asks who holds the profile: a daemon greets as it
|
|
292
|
-
* accepts the connection, and one of an older release (before the greeting) never does. A daemon of this release
|
|
293
|
-
* holding the profile (`daemonOfThisRelease`) is busy and is waited for, under each call's own deadline; anything
|
|
294
|
-
* else is refused then. It used to refuse every late greeting, after 10 s: a daemon busy that long on one task (an
|
|
295
|
-
* outbox backlog, 14 to 29 s) had every command and `listen` refused as an older release's, to be restarted.
|
|
296
|
-
*/
|
|
297
|
-
var GREETING_MS = 2e3;
|
|
298
|
-
/** The refusal of a listener that did not prove it is the profile's daemon (`isNotTheDaemon` tells it apart). */
|
|
299
|
-
function notTheDaemon(socket) {
|
|
300
|
-
return new CliError("refused", `What answers on ${socket} did not prove it is this profile's daemon, so nothing was sent to it. A daemon of an older release cannot: \`ghostly daemon restart\` starts this one's`, { reason: "not-the-daemon" });
|
|
301
|
-
}
|
|
302
|
-
function isNotTheDaemon(error) {
|
|
303
|
-
return error instanceof CliError && error.code === "refused" && error.details?.reason === "not-the-daemon";
|
|
304
|
-
}
|
|
305
|
-
/**
|
|
306
|
-
* A connection to a profile's daemon over its socket (WISP 1100 § Local control API). `null` from `connectDaemon`
|
|
307
|
-
* means no daemon answers there: a one-shot command runs the profile itself.
|
|
308
|
-
*
|
|
309
|
-
* The client writes nothing on it until the daemon's greeting, its first line, proves the other end read the
|
|
310
|
-
* profile's daemon secret and holds the profile's lock (`provesGreeting`): a listener that cannot prove it has read
|
|
311
|
-
* nothing from this client, so it cannot impersonate it either (`daemonProof.ts`). Then the first line written is a
|
|
312
|
-
* `daemon.hello`, and no call is written until its answer proves the same over the client's own nonce. Until then
|
|
313
|
-
* every call waits, under its own deadline, and a listener that does not prove both gets every call refused
|
|
314
|
-
* (`refused`, `isNotTheDaemon`). Nothing it writes before that is read either.
|
|
315
|
-
*/
|
|
316
|
-
var DaemonClient = class {
|
|
317
|
-
socket;
|
|
318
|
-
address;
|
|
319
|
-
nextId = 1;
|
|
320
|
-
pending = /* @__PURE__ */ new Map();
|
|
321
|
-
eventListener = null;
|
|
322
|
-
closedListener = null;
|
|
323
|
-
/** While paused: the events of the chunk already read, given to the listener on resume. */
|
|
324
|
-
held = null;
|
|
325
|
-
greeted = false;
|
|
326
|
-
verified = false;
|
|
327
|
-
refusal = null;
|
|
328
|
-
ready;
|
|
329
|
-
settle;
|
|
330
|
-
constructor(socket, address, greetingMs = GREETING_MS) {
|
|
331
|
-
this.socket = socket;
|
|
332
|
-
this.address = address;
|
|
333
|
-
this.ready = new Promise((resolve, reject) => {
|
|
334
|
-
this.settle = {
|
|
335
|
-
resolve,
|
|
336
|
-
reject
|
|
337
|
-
};
|
|
338
|
-
});
|
|
339
|
-
this.ready.catch(() => {});
|
|
340
|
-
const nonce = newNonce();
|
|
341
|
-
const waitedTooLong = setTimeout(() => {
|
|
342
|
-
if (!this.greeted && !this.refusal && !daemonOfThisRelease(this.address.dir)) this.refuse();
|
|
343
|
-
}, greetingMs);
|
|
344
|
-
waitedTooLong.unref?.();
|
|
345
|
-
const lines = createInterface({
|
|
346
|
-
input: socket,
|
|
347
|
-
crlfDelay: Infinity
|
|
348
|
-
});
|
|
349
|
-
lines.on("error", () => {});
|
|
350
|
-
lines.on("line", (line) => {
|
|
351
|
-
let message;
|
|
352
|
-
try {
|
|
353
|
-
message = JSON.parse(line);
|
|
354
|
-
} catch {
|
|
355
|
-
if (!this.greeted && !this.refusal) this.refuse();
|
|
356
|
-
return;
|
|
357
|
-
}
|
|
358
|
-
if (this.refusal) return;
|
|
359
|
-
if (!this.greeted) {
|
|
360
|
-
clearTimeout(waitedTooLong);
|
|
361
|
-
const secret = readDaemonSecret(this.address.dir);
|
|
362
|
-
if (!secret || !provesGreeting(secret, this.address.dir, message)) {
|
|
363
|
-
this.refuse();
|
|
364
|
-
return;
|
|
365
|
-
}
|
|
366
|
-
this.greeted = true;
|
|
367
|
-
if (socket.writableEnded || socket.destroyed) return;
|
|
368
|
-
socket.write(JSON.stringify({
|
|
369
|
-
id: HELLO_ID,
|
|
370
|
-
method: HELLO,
|
|
371
|
-
params: { nonce }
|
|
372
|
-
}) + "\n");
|
|
373
|
-
return;
|
|
374
|
-
}
|
|
375
|
-
if (!this.verified) {
|
|
376
|
-
if (message?.id !== HELLO_ID) return;
|
|
377
|
-
const secret = readDaemonSecret(this.address.dir);
|
|
378
|
-
if (!message.error && secret && provesDaemon(secret, nonce, message.result)) {
|
|
379
|
-
this.verified = true;
|
|
380
|
-
this.settle.resolve();
|
|
381
|
-
return;
|
|
382
|
-
}
|
|
383
|
-
this.refuse();
|
|
384
|
-
return;
|
|
385
|
-
}
|
|
386
|
-
if (message.event) {
|
|
387
|
-
if (this.held) this.held.push(message.event);
|
|
388
|
-
else this.eventListener?.(message.event);
|
|
389
|
-
return;
|
|
390
|
-
}
|
|
391
|
-
const waiting = typeof message.id === "number" ? this.pending.get(message.id) : void 0;
|
|
392
|
-
if (!waiting) return;
|
|
393
|
-
this.pending.delete(message.id);
|
|
394
|
-
if (message.error) waiting.reject(new CliError(message.error.code, message.error.message, message.error.details));
|
|
395
|
-
else waiting.resolve(message.result);
|
|
396
|
-
});
|
|
397
|
-
socket.on("close", () => {
|
|
398
|
-
clearTimeout(waitedTooLong);
|
|
399
|
-
const why = this.refusal ?? new CliError("unavailable", "The daemon went away");
|
|
400
|
-
if (!this.verified) this.settle.reject(why);
|
|
401
|
-
for (const waiting of this.pending.values()) waiting.reject(why);
|
|
402
|
-
this.pending.clear();
|
|
403
|
-
this.closedListener?.();
|
|
404
|
-
});
|
|
405
|
-
socket.on("error", () => {});
|
|
406
|
-
}
|
|
407
|
-
refuse() {
|
|
408
|
-
this.refusal = notTheDaemon(this.address.socket);
|
|
409
|
-
this.settle.reject(this.refusal);
|
|
410
|
-
this.socket.destroy();
|
|
411
|
-
}
|
|
412
|
-
/**
|
|
413
|
-
* `timeoutMs`: give up (code `timeout`, exit 4) when the daemon has not answered by then; without it the call waits
|
|
414
|
-
* for as long as the connection holds. A call that timed out closes the connection: its answer, if one ever comes,
|
|
415
|
-
* is of no use, and the process leaves once nothing else keeps it (not every caller reaches `exit`).
|
|
416
|
-
*/
|
|
417
|
-
call(method, params = {}, { timeoutMs } = {}) {
|
|
418
|
-
if (this.socket.destroyed) return Promise.reject(this.refusal ?? new CliError("unavailable", "The daemon went away"));
|
|
419
|
-
const id = this.nextId++;
|
|
420
|
-
return new Promise((resolve, reject) => {
|
|
421
|
-
let timer;
|
|
422
|
-
if (timeoutMs !== void 0) {
|
|
423
|
-
timer = setTimeout(() => {
|
|
424
|
-
if (!this.pending.delete(id)) return;
|
|
425
|
-
reject(new CliError("timeout", `The daemon did not answer ${method} in ${timeoutMs / 1e3} s: \`ghostly daemon restart\` starts a fresh one`, { method }));
|
|
426
|
-
this.destroy();
|
|
427
|
-
}, timeoutMs);
|
|
428
|
-
timer.unref?.();
|
|
429
|
-
}
|
|
430
|
-
const settle = {
|
|
431
|
-
resolve: (value) => {
|
|
432
|
-
if (timer) clearTimeout(timer);
|
|
433
|
-
resolve(value);
|
|
434
|
-
},
|
|
435
|
-
reject: (error) => {
|
|
436
|
-
if (timer) clearTimeout(timer);
|
|
437
|
-
reject(error);
|
|
438
|
-
}
|
|
439
|
-
};
|
|
440
|
-
this.pending.set(id, settle);
|
|
441
|
-
this.ready.then(() => {
|
|
442
|
-
if (this.pending.has(id) && !this.socket.destroyed) this.socket.write(JSON.stringify({
|
|
443
|
-
id,
|
|
444
|
-
method,
|
|
445
|
-
params
|
|
446
|
-
}) + "\n");
|
|
447
|
-
}, (error) => {
|
|
448
|
-
if (this.pending.delete(id)) settle.reject(error);
|
|
449
|
-
});
|
|
450
|
-
});
|
|
451
|
-
}
|
|
452
|
-
/** Events after `since` (replayed from the journal), then every new one, until the connection closes. */
|
|
453
|
-
async subscribe(since, listener, onClosed) {
|
|
454
|
-
this.eventListener = listener;
|
|
455
|
-
this.closedListener = onClosed ?? null;
|
|
456
|
-
return this.call("events.subscribe", since === void 0 ? {} : { since });
|
|
457
|
-
}
|
|
458
|
-
/**
|
|
459
|
-
* Stops reading: what the daemon sends waits in the connection (and past its bound the daemon ends it), and no
|
|
460
|
-
* event reaches the listener until `resume`.
|
|
461
|
-
*/
|
|
462
|
-
pause() {
|
|
463
|
-
if (this.held) return;
|
|
464
|
-
this.held = [];
|
|
465
|
-
this.socket.pause();
|
|
466
|
-
}
|
|
467
|
-
/** Gives the listener the events held, then reads again; a listener that pauses again keeps the rest held. */
|
|
468
|
-
resume() {
|
|
469
|
-
const held = this.held;
|
|
470
|
-
if (!held) return;
|
|
471
|
-
this.held = null;
|
|
472
|
-
for (let i = 0; i < held.length; i++) {
|
|
473
|
-
this.eventListener?.(held[i]);
|
|
474
|
-
if (this.held) {
|
|
475
|
-
this.held.unshift(...held.slice(i + 1));
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
}
|
|
479
|
-
this.socket.resume();
|
|
480
|
-
}
|
|
481
|
-
close() {
|
|
482
|
-
this.socket.end();
|
|
483
|
-
}
|
|
484
|
-
/** Closes at once: what the daemon still sends is not read. */
|
|
485
|
-
destroy() {
|
|
486
|
-
this.socket.destroy();
|
|
487
|
-
}
|
|
488
|
-
};
|
|
489
|
-
/**
|
|
490
|
-
* `timeoutMs` bounds the connect only; `greetingMs`, the wait for the daemon's greeting (above). The client it gives
|
|
491
|
-
* has written nothing yet; whether the listener is the daemon is known at the first call.
|
|
492
|
-
*/
|
|
493
|
-
function connectDaemon(address, timeoutMs = 2e3, { greetingMs = GREETING_MS } = {}) {
|
|
494
|
-
const path = address.socket;
|
|
495
|
-
if (!ownSocket(path)) return Promise.resolve(null);
|
|
496
|
-
return new Promise((resolve) => {
|
|
497
|
-
const socket = connect(path);
|
|
498
|
-
const timer = setTimeout(() => {
|
|
499
|
-
socket.destroy();
|
|
500
|
-
resolve(null);
|
|
501
|
-
}, timeoutMs);
|
|
502
|
-
socket.once("connect", () => {
|
|
503
|
-
clearTimeout(timer);
|
|
504
|
-
resolve(new DaemonClient(socket, address, greetingMs));
|
|
505
|
-
});
|
|
506
|
-
socket.once("error", () => {
|
|
507
|
-
clearTimeout(timer);
|
|
508
|
-
resolve(null);
|
|
509
|
-
});
|
|
510
|
-
});
|
|
511
|
-
}
|
|
512
|
-
//#endregion
|
|
513
287
|
//#region src/commands/shared.ts
|
|
514
288
|
var wait = {
|
|
515
289
|
wait: {
|
|
@@ -568,6 +342,29 @@ function here(path) {
|
|
|
568
342
|
if (path === "") throw new CliError("usage", "A path given as \"\" names no file");
|
|
569
343
|
return typeof path === "string" ? userPath(path) : void 0;
|
|
570
344
|
}
|
|
345
|
+
var STDIN_TOO_BIG = "More than 16 MiB came on stdin, more than any command takes (a long text goes as a file: ghostly file send <chat|group> <path>)";
|
|
346
|
+
/**
|
|
347
|
+
* A file's text, or stdin's (`0`), up to `INPUT_BYTES`: more is refused as it comes. `app send … -`, a card's `--json`
|
|
348
|
+
* and the files `identity complete` and `x401 credential add` send were read whole: 600 MiB answered V8's "Cannot
|
|
349
|
+
* create a string longer than 0x1fffffe8 characters", and past 16 MiB a daemon cut the line ("The daemon went away").
|
|
350
|
+
*/
|
|
351
|
+
function readInput(file) {
|
|
352
|
+
const fd = file === 0 ? 0 : openSync(file, "r");
|
|
353
|
+
try {
|
|
354
|
+
const chunks = [];
|
|
355
|
+
let bytes = 0;
|
|
356
|
+
for (;;) {
|
|
357
|
+
const chunk = Buffer.allocUnsafe(1048576);
|
|
358
|
+
const read = readSync(fd, chunk, 0, chunk.length, null);
|
|
359
|
+
if (!read) return Buffer.concat(chunks).toString("utf8");
|
|
360
|
+
bytes += read;
|
|
361
|
+
if (bytes > 16777216) throw new CliError("bad_request", file === 0 ? STDIN_TOO_BIG : `${file} holds more than 16 MiB, more than any command takes (a file to share goes as one: ghostly file send <chat|group> <path>)`);
|
|
362
|
+
chunks.push(chunk.subarray(0, read));
|
|
363
|
+
}
|
|
364
|
+
} finally {
|
|
365
|
+
if (file !== 0) closeSync(fd);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
571
368
|
/**
|
|
572
369
|
* A list option that names chats (`--to`, `--from`): "" or "group:" alone (an unset variable in a script) names
|
|
573
370
|
* nothing, and is a usage error before the profile opens; it was a prefix of every id and took the only chat or group.
|
|
@@ -716,9 +513,9 @@ function cardJson(value) {
|
|
|
716
513
|
const file = text.startsWith("{") || text === "-" ? void 0 : here(text);
|
|
717
514
|
let raw;
|
|
718
515
|
try {
|
|
719
|
-
raw = text.startsWith("{") ? text :
|
|
516
|
+
raw = text.startsWith("{") ? text : readInput(file ?? 0);
|
|
720
517
|
} catch (error) {
|
|
721
|
-
throw file !== void 0 && localFileError(error, file) || new CliError("usage", `--json takes a card as JSON, - for stdin, or a file: ${error instanceof Error ? error.message : String(error)}`);
|
|
518
|
+
throw error instanceof CliError && error || file !== void 0 && localFileError(error, file) || new CliError("usage", `--json takes a card as JSON, - for stdin, or a file: ${error instanceof Error ? error.message : String(error)}`);
|
|
722
519
|
}
|
|
723
520
|
let parsed;
|
|
724
521
|
try {
|
|
@@ -823,6 +620,12 @@ function percent(options, flag) {
|
|
|
823
620
|
const value = options[flag];
|
|
824
621
|
if (value !== void 0 && !(typeof value === "number" && value >= 0 && value <= 100)) throw new CliError("usage", `--${flag} takes a percent from 0 to 100, not ${JSON.stringify(value)}`);
|
|
825
622
|
}
|
|
623
|
+
/**
|
|
624
|
+
* `--pr-number`, `--additions`, `--used`, `--limit`…: a count as the card takes it, a whole number from `min` up to
|
|
625
|
+
* `STATUS_CARD_LIMITS.count`. Before, it reached the card's check: `bad_request` (exit 1), "Status card: pr.number is a
|
|
626
|
+
* whole number from 1".
|
|
627
|
+
*/
|
|
628
|
+
var cardCount = (options, flag, min) => inRange(options, flag, "a whole number", min, STATUS_CARD_LIMITS.count, true);
|
|
826
629
|
/** The flags of a task's pull request, and the field of `pr` each one gives. */
|
|
827
630
|
var PR_FLAGS = [
|
|
828
631
|
["pr-url", "url"],
|
|
@@ -864,9 +667,16 @@ function taskFields(options) {
|
|
|
864
667
|
if (!match) throw new CliError("usage", `--steps takes done/total, like 2/5, not ${JSON.stringify(options.steps)}`);
|
|
865
668
|
fields.done = Number(match[1]);
|
|
866
669
|
fields.total = Number(match[2]);
|
|
670
|
+
if (Number(match[2]) > STATUS_CARD_LIMITS.count) throw new CliError("usage", `--steps takes done/total of at most ${STATUS_CARD_LIMITS.count} steps, like 2/5, not ${JSON.stringify(options.steps)}`);
|
|
867
671
|
if (Number(match[2]) < 1 || Number(match[1]) > Number(match[2])) throw new CliError("usage", `--steps takes done/total with done at most total, like 2/5, not ${JSON.stringify(options.steps)}`);
|
|
868
672
|
}
|
|
869
673
|
if (options["pr-url"] !== void 0 && !cardUrl(options["pr-url"])) throw new CliError("usage", `--pr-url takes an https link of at most ${STATUS_CARD_LIMITS.url} characters, not ${JSON.stringify(options["pr-url"])}`);
|
|
674
|
+
for (const flag of [
|
|
675
|
+
"pr-number",
|
|
676
|
+
"additions",
|
|
677
|
+
"deletions",
|
|
678
|
+
"files"
|
|
679
|
+
]) cardCount(options, flag, flag === "pr-number" ? 1 : 0);
|
|
870
680
|
const pr = {};
|
|
871
681
|
for (const [flag, key] of PR_FLAGS) if (options[flag] !== void 0) pr[key] = options[flag];
|
|
872
682
|
if (Object.keys(pr).length) fields.pr = {
|
|
@@ -924,10 +734,58 @@ function quota(card, usage) {
|
|
|
924
734
|
var CARD_TIME_FORMS = "2026-09-30 or 2026-09-30 01:00 (no zone: local time; a date alone is its midnight), 2026-09-30T01:00:00Z or 2026-09-30T01:00+02:00";
|
|
925
735
|
/** An ISO date with no time, which `Date.parse` alone reads as UTC midnight: `2026-09-30`, `2026-09`. */
|
|
926
736
|
var ISO_DAY = /^(?:[+-]\d{6}|\d{4})-\d{2}(-\d{2})?$/;
|
|
737
|
+
var MONTHS = [
|
|
738
|
+
"jan",
|
|
739
|
+
"feb",
|
|
740
|
+
"mar",
|
|
741
|
+
"apr",
|
|
742
|
+
"may",
|
|
743
|
+
"jun",
|
|
744
|
+
"jul",
|
|
745
|
+
"aug",
|
|
746
|
+
"sep",
|
|
747
|
+
"oct",
|
|
748
|
+
"nov",
|
|
749
|
+
"dec"
|
|
750
|
+
];
|
|
751
|
+
/** What `Date.parse` takes between a month's name and a number: `Apr 31`, `Apr-31`, `31/Apr`, `Apr.31`, `31 Apr,`. */
|
|
752
|
+
var NAME_SEP = "[\\s,./-]*";
|
|
753
|
+
var MONTH_DAY = new RegExp(`\\b(${MONTHS.join("|")})[a-z]*${NAME_SEP}(\\d{1,2})(?!\\d)`, "i");
|
|
754
|
+
var DAY_MONTH = new RegExp(`(?<!\\d)(\\d{1,2})${NAME_SEP}(${MONTHS.join("|")})`, "i");
|
|
755
|
+
/**
|
|
756
|
+
* The year, month (1 to 12) and day a date is written with: `2026-04-31`, `2026/4/31`, `4/31/2026` (month first, as
|
|
757
|
+
* `Date.parse` reads it, also with dashes or dots and a two-digit year), `Apr 31 2026`, `31-Apr-2026`. `Date.parse`
|
|
758
|
+
* takes any day up to 31 and moves it past the month's end, so the day is checked here.
|
|
759
|
+
*/
|
|
760
|
+
function writtenDay(text) {
|
|
761
|
+
const numeric = /^([+-]\d{6}|\d{4})[-/](\d{1,2})[-/](\d{1,2})(?!\d)/.exec(text);
|
|
762
|
+
if (numeric) return [
|
|
763
|
+
Number(numeric[1]),
|
|
764
|
+
Number(numeric[2]),
|
|
765
|
+
Number(numeric[3])
|
|
766
|
+
];
|
|
767
|
+
const monthFirst = /^(\d{1,2})[-/.](\d{1,2})[-/.](\d{4}|\d{2})(?!\d)/.exec(text);
|
|
768
|
+
const yy = (y) => y.length === 2 ? Number(y) + (Number(y) < 50 ? 2e3 : 1900) : Number(y);
|
|
769
|
+
if (monthFirst) return [
|
|
770
|
+
yy(monthFirst[3]),
|
|
771
|
+
Number(monthFirst[1]),
|
|
772
|
+
Number(monthFirst[2])
|
|
773
|
+
];
|
|
774
|
+
const year = /\b(\d{4})\b/.exec(text), monthDay = MONTH_DAY.exec(text), dayMonth = monthDay ? null : DAY_MONTH.exec(text);
|
|
775
|
+
const [word, day] = monthDay ? [monthDay[1], monthDay[2]] : dayMonth ? [dayMonth[2], dayMonth[1]] : [];
|
|
776
|
+
return year && word ? [
|
|
777
|
+
Number(year[1]),
|
|
778
|
+
MONTHS.indexOf(word.toLowerCase()) + 1,
|
|
779
|
+
Number(day)
|
|
780
|
+
] : void 0;
|
|
781
|
+
}
|
|
927
782
|
/**
|
|
928
783
|
* A time a command names: milliseconds, or a date the JavaScript Date reads (`2026-09-30T01:00:00Z`). A date with no
|
|
929
784
|
* zone is local time in every form: `Date.parse` reads `2026-09-30 01:00` and `Sep 30 2026` as local but an ISO date
|
|
930
785
|
* alone as UTC midnight (21:00 the day before in UTC-03, agents#2355), so that one is read as `2026-09-30T00:00`.
|
|
786
|
+
* A day the month does not have (`2026-04-31`) is refused, where `Date.parse` made it May 1. A time more than a year
|
|
787
|
+
* ahead is a usage error that names the flag and the last time it takes: before, it reached the card's check and failed
|
|
788
|
+
* as `bad_request` (exit 1), "Status card: resetsAt is a time in milliseconds, within a year". A time past is taken.
|
|
931
789
|
*/
|
|
932
790
|
function cardTime(value, flag) {
|
|
933
791
|
if (value === void 0) return void 0;
|
|
@@ -935,6 +793,17 @@ function cardTime(value, flag) {
|
|
|
935
793
|
const day = ISO_DAY.exec(text);
|
|
936
794
|
const ms = /^\d+$/.test(text) ? milliseconds(text, flag) : Date.parse(day ? `${text}${day[1] ? "" : "-01"}T00:00` : text);
|
|
937
795
|
if (!Number.isSafeInteger(ms) || ms <= 0) throw new CliError("usage", `--${flag} takes a time in milliseconds or a date: ${CARD_TIME_FORMS}, not ${JSON.stringify(value)}`);
|
|
796
|
+
const written = writtenDay(text);
|
|
797
|
+
if (written) {
|
|
798
|
+
const [year, month, date] = written, days = new Date(Date.UTC(year, month, 0)).getUTCDate();
|
|
799
|
+
if (date > days) throw new CliError("usage", `--${flag} takes a day the month has (${year}-${String(month).padStart(2, "0")} has ${days}), not ${JSON.stringify(value)}`);
|
|
800
|
+
}
|
|
801
|
+
const last = new Date(Date.now() + STATUS_CARD_LIMITS.nextRunMs);
|
|
802
|
+
if (ms > last.getTime()) {
|
|
803
|
+
const two = (n) => String(n).padStart(2, "0");
|
|
804
|
+
const shown = `${last.getFullYear()}-${two(last.getMonth() + 1)}-${two(last.getDate())} ${two(last.getHours())}:${two(last.getMinutes())}`;
|
|
805
|
+
throw new CliError("usage", `--${flag} takes a time within a year from now (until ${shown}), not ${JSON.stringify(value)}`);
|
|
806
|
+
}
|
|
938
807
|
return ms;
|
|
939
808
|
}
|
|
940
809
|
/** `--run ok`, `--run failed:"CI flaked"`: a run of a routine, recorded as its last. */
|
|
@@ -992,7 +861,7 @@ var routineOptions = {
|
|
|
992
861
|
},
|
|
993
862
|
next: {
|
|
994
863
|
type: "string",
|
|
995
|
-
description: `Its next run: milliseconds or a date: ${CARD_TIME_FORMS}`
|
|
864
|
+
description: `Its next run, within a year: milliseconds or a date: ${CARD_TIME_FORMS}`
|
|
996
865
|
},
|
|
997
866
|
run: {
|
|
998
867
|
type: "string",
|
|
@@ -1089,6 +958,8 @@ function usageFields(options) {
|
|
|
1089
958
|
const fields = { ...cardJson(options.json) };
|
|
1090
959
|
percent(options, "left");
|
|
1091
960
|
if (options.left !== void 0 && (options.used !== void 0 || options.limit !== void 0)) throw new CliError("usage", "--left or --used with --limit, not both");
|
|
961
|
+
const used = cardCount(options, "used", 0), limit = cardCount(options, "limit", 1);
|
|
962
|
+
if (used !== void 0 && limit !== void 0 && used > limit) throw new CliError("usage", `--used takes at most --limit (${limit}), not ${used}`);
|
|
1092
963
|
for (const [flag, max] of [
|
|
1093
964
|
["label", STATUS_CARD_LIMITS.usageLabel],
|
|
1094
965
|
["account", STATUS_CARD_LIMITS.usageLabel],
|
|
@@ -1137,7 +1008,7 @@ var usageOptions = {
|
|
|
1137
1008
|
},
|
|
1138
1009
|
resets: {
|
|
1139
1010
|
type: "string",
|
|
1140
|
-
description: `When the window starts again: milliseconds or a date: ${CARD_TIME_FORMS}`
|
|
1011
|
+
description: `When the window starts again, within a year: milliseconds or a date: ${CARD_TIME_FORMS}`
|
|
1141
1012
|
},
|
|
1142
1013
|
also: {
|
|
1143
1014
|
type: "list",
|
|
@@ -1165,7 +1036,7 @@ function keyFile(value, usage) {
|
|
|
1165
1036
|
/** `app send`'s message: JSON on the command line, or `-` for stdin. */
|
|
1166
1037
|
function appData(value) {
|
|
1167
1038
|
if (value === void 0) throw new CliError("usage", "The message is needed, as JSON or - for stdin: ghostly app send <chat> <ref|name> <json|->");
|
|
1168
|
-
const text = value.trim() === "-" ?
|
|
1039
|
+
const text = value.trim() === "-" ? readInput(0) : value;
|
|
1169
1040
|
try {
|
|
1170
1041
|
return JSON.parse(text);
|
|
1171
1042
|
} catch {
|
|
@@ -1211,7 +1082,7 @@ var commands$8 = {
|
|
|
1211
1082
|
description: "Replace the three files when they are there"
|
|
1212
1083
|
}
|
|
1213
1084
|
},
|
|
1214
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1085
|
+
run: async ({ options }, a) => (await import("./apps-Bti9fDoW.js")).initApp(a.dir, {
|
|
1215
1086
|
name: options.name,
|
|
1216
1087
|
title: options.title,
|
|
1217
1088
|
force: options.force === true
|
|
@@ -1251,7 +1122,7 @@ var commands$8 = {
|
|
|
1251
1122
|
description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
|
|
1252
1123
|
}
|
|
1253
1124
|
},
|
|
1254
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1125
|
+
run: async ({ options }, a) => (await import("./apps-Bti9fDoW.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
|
|
1255
1126
|
},
|
|
1256
1127
|
"app revoke": {
|
|
1257
1128
|
method: "app.revoke",
|
|
@@ -1281,10 +1152,10 @@ var commands$8 = {
|
|
|
1281
1152
|
},
|
|
1282
1153
|
force: {
|
|
1283
1154
|
type: "boolean",
|
|
1284
|
-
description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere)"
|
|
1155
|
+
description: "Allow --up-to past the bundle's own sequence (versions published from elsewhere), and a --reason that looks like a seed, a key or ecash"
|
|
1285
1156
|
}
|
|
1286
1157
|
},
|
|
1287
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1158
|
+
run: async ({ options }, a) => (await import("./apps-Bti9fDoW.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
|
|
1288
1159
|
digests: options.digest,
|
|
1289
1160
|
upTo: options["up-to"],
|
|
1290
1161
|
reason: options.reason,
|
|
@@ -1345,7 +1216,7 @@ var commands$8 = {
|
|
|
1345
1216
|
usage: "app verify <bundle|url>",
|
|
1346
1217
|
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",
|
|
1347
1218
|
args: ["bundle"],
|
|
1348
|
-
run: async (_, a) => (await import("./apps-
|
|
1219
|
+
run: async (_, a) => (await import("./apps-Bti9fDoW.js")).verifyApp(a.bundle)
|
|
1349
1220
|
},
|
|
1350
1221
|
"store sign": {
|
|
1351
1222
|
method: "store.sign",
|
|
@@ -1362,7 +1233,7 @@ var commands$8 = {
|
|
|
1362
1233
|
description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
|
|
1363
1234
|
}
|
|
1364
1235
|
},
|
|
1365
|
-
run: async ({ options }, a) => (await import("./apps-
|
|
1236
|
+
run: async ({ options }, a) => (await import("./apps-Bti9fDoW.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
|
|
1366
1237
|
}
|
|
1367
1238
|
};
|
|
1368
1239
|
//#endregion
|
|
@@ -2185,7 +2056,7 @@ var commands$5 = {
|
|
|
2185
2056
|
},
|
|
2186
2057
|
"file send": {
|
|
2187
2058
|
method: "file.send",
|
|
2188
|
-
usage: "file send <chat|group> <path> [--name n] [--mime t] [--voice [ms] [--peaks 0,40,…]] [--reply <message>]",
|
|
2059
|
+
usage: "file send <chat|group> <path> [--name n] [--mime t] [--voice [ms] [--peaks 0,40,…]] [--reply <message>] [--force] [--wait none|sent] [--timeout s]",
|
|
2189
2060
|
summary: `Send a file (or, with --voice, a voice note), as a reply with --reply; to a group, every member's app fetches it (up to ${GROUP_FILE_LIMITS.maxBytes / 1024 / 1024} MiB)`,
|
|
2190
2061
|
args: ["chat", "path"],
|
|
2191
2062
|
options: {
|
|
@@ -2206,7 +2077,20 @@ var commands$5 = {
|
|
|
2206
2077
|
type: "string",
|
|
2207
2078
|
description: "Loudness bars 0-255, comma-separated (default: measured from the sound)"
|
|
2208
2079
|
},
|
|
2209
|
-
reply
|
|
2080
|
+
reply,
|
|
2081
|
+
wait: {
|
|
2082
|
+
type: "string",
|
|
2083
|
+
choices: ["none", "sent"],
|
|
2084
|
+
description: "none or sent: until the contact has the whole file, in a 1:1 chat (default: none with a daemon, sent without; a group: none)"
|
|
2085
|
+
},
|
|
2086
|
+
timeout: {
|
|
2087
|
+
type: "number",
|
|
2088
|
+
description: "Seconds --wait sent waits (default 300)"
|
|
2089
|
+
},
|
|
2090
|
+
force: {
|
|
2091
|
+
type: "boolean",
|
|
2092
|
+
description: "Send even if --name looks like a seed, a key or ecash"
|
|
2093
|
+
}
|
|
2210
2094
|
},
|
|
2211
2095
|
params: ({ options }, a) => ({
|
|
2212
2096
|
chat: a.chat,
|
|
@@ -2214,7 +2098,10 @@ var commands$5 = {
|
|
|
2214
2098
|
name: options.name,
|
|
2215
2099
|
mime: options.mime,
|
|
2216
2100
|
...voiceOf(options),
|
|
2217
|
-
reply: options.reply
|
|
2101
|
+
reply: options.reply,
|
|
2102
|
+
force: options.force === true,
|
|
2103
|
+
wait: options.wait,
|
|
2104
|
+
timeout: timeout(options, LONG_WAIT_SECONDS)
|
|
2218
2105
|
})
|
|
2219
2106
|
},
|
|
2220
2107
|
"file wait": {
|
|
@@ -2276,6 +2163,11 @@ var commands$4 = {
|
|
|
2276
2163
|
};
|
|
2277
2164
|
//#endregion
|
|
2278
2165
|
//#region src/commands/groups.ts
|
|
2166
|
+
var nameForce = {
|
|
2167
|
+
type: "boolean",
|
|
2168
|
+
description: "Use the name even if it looks like a seed, a key or ecash"
|
|
2169
|
+
};
|
|
2170
|
+
var forced = (options) => options.force === true ? { force: true } : {};
|
|
2279
2171
|
/** Groups: one entry per command, in alphabetical order (test/commands.test.ts checks). */
|
|
2280
2172
|
var commands$3 = {
|
|
2281
2173
|
"group accept": {
|
|
@@ -2299,16 +2191,20 @@ var commands$3 = {
|
|
|
2299
2191
|
},
|
|
2300
2192
|
"group create": {
|
|
2301
2193
|
method: "group.create",
|
|
2302
|
-
usage: "group create <name...> [--mesh]",
|
|
2194
|
+
usage: "group create <name...> [--mesh] [--force]",
|
|
2303
2195
|
summary: "A community (a link anyone can open) or, with --mesh, a private group of up to 32",
|
|
2304
2196
|
args: ["name..."],
|
|
2305
|
-
options: {
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2197
|
+
options: {
|
|
2198
|
+
mesh: {
|
|
2199
|
+
type: "boolean",
|
|
2200
|
+
description: "A private mesh of contacts instead of a community"
|
|
2201
|
+
},
|
|
2202
|
+
force: nameForce
|
|
2203
|
+
},
|
|
2309
2204
|
params: ({ options }, { name }) => ({
|
|
2310
2205
|
name,
|
|
2311
|
-
profile: options.mesh ? "mesh" : "community"
|
|
2206
|
+
profile: options.mesh ? "mesh" : "community",
|
|
2207
|
+
...forced(options)
|
|
2312
2208
|
})
|
|
2313
2209
|
},
|
|
2314
2210
|
"group decline": {
|
|
@@ -2510,13 +2406,17 @@ var commands$3 = {
|
|
|
2510
2406
|
},
|
|
2511
2407
|
"group rename": {
|
|
2512
2408
|
method: "group.rename",
|
|
2513
|
-
usage: "group rename <group> <name...> [--show-secret]",
|
|
2409
|
+
usage: "group rename <group> <name...> [--force] [--show-secret]",
|
|
2514
2410
|
summary: "Rename the group (admin; the picture stays)",
|
|
2515
2411
|
args: ["group", "name..."],
|
|
2516
|
-
options:
|
|
2412
|
+
options: {
|
|
2413
|
+
...showSecret,
|
|
2414
|
+
force: nameForce
|
|
2415
|
+
},
|
|
2517
2416
|
params: ({ options }, a) => ({
|
|
2518
2417
|
group: a.group,
|
|
2519
2418
|
name: a.name,
|
|
2419
|
+
...forced(options),
|
|
2520
2420
|
...secret(options)
|
|
2521
2421
|
})
|
|
2522
2422
|
},
|
|
@@ -2664,13 +2564,13 @@ var commands$2 = {
|
|
|
2664
2564
|
method: "x401.credential.add",
|
|
2665
2565
|
usage: "x401 credential add <file|-> [--label <name>]",
|
|
2666
2566
|
summary: "Keep an issued SD-JWT VC bound to a key from x401 key new (a file, or - for stdin)",
|
|
2667
|
-
args: ["
|
|
2567
|
+
args: ["path"],
|
|
2668
2568
|
options: { label: {
|
|
2669
2569
|
type: "string",
|
|
2670
2570
|
description: "Your name for it, up to 80 characters on one line (default: its type)"
|
|
2671
2571
|
} },
|
|
2672
2572
|
params: ({ options }, a) => ({
|
|
2673
|
-
file: a.
|
|
2573
|
+
file: a.path === "-" ? "-" : here(a.path),
|
|
2674
2574
|
label: options.label
|
|
2675
2575
|
})
|
|
2676
2576
|
},
|
|
@@ -2832,7 +2732,7 @@ var commands$1 = {
|
|
|
2832
2732
|
},
|
|
2833
2733
|
"pay": {
|
|
2834
2734
|
method: "pay",
|
|
2835
|
-
usage: "pay <invoice|lightning-address|lnurl> [--amount sats] [--network n] [--max-fee sats] [--card <id>] [--comment t] [--confirm-real] [--force]",
|
|
2735
|
+
usage: "pay <invoice|lightning-address|lnurl> [--amount sats] [--network n] [--max-fee sats] [--card <id>] [--comment t] [--chat <chat>] [--confirm-real] [--force]",
|
|
2836
2736
|
summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real",
|
|
2837
2737
|
args: ["target"],
|
|
2838
2738
|
options: {
|
|
@@ -2850,6 +2750,10 @@ var commands$1 = {
|
|
|
2850
2750
|
type: "string",
|
|
2851
2751
|
description: "For the address's owner"
|
|
2852
2752
|
},
|
|
2753
|
+
chat: {
|
|
2754
|
+
type: "string",
|
|
2755
|
+
description: "The chat the invoice came from: on Testnet its contact is told it was paid"
|
|
2756
|
+
},
|
|
2853
2757
|
"confirm-real": confirmReal,
|
|
2854
2758
|
force
|
|
2855
2759
|
},
|
|
@@ -2860,6 +2764,7 @@ var commands$1 = {
|
|
|
2860
2764
|
maxFee: options["max-fee"],
|
|
2861
2765
|
card: options.card,
|
|
2862
2766
|
comment: options.comment,
|
|
2767
|
+
chat: options.chat,
|
|
2863
2768
|
confirmReal: options["confirm-real"] === true,
|
|
2864
2769
|
force: options.force === true
|
|
2865
2770
|
})
|
|
@@ -4093,15 +3998,15 @@ var VERSION = package_default.version;
|
|
|
4093
3998
|
* command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
|
|
4094
3999
|
* cost every command ~100 ms before its socket was opened.
|
|
4095
4000
|
*/
|
|
4096
|
-
var engineApi = () => import("./api-
|
|
4097
|
-
var engineHost = () => import("./host-
|
|
4001
|
+
var engineApi = () => import("./api-DdrA86Ur.js");
|
|
4002
|
+
var engineHost = () => import("./host-DvcVt5YI.js");
|
|
4098
4003
|
/**
|
|
4099
4004
|
* `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
|
|
4100
4005
|
* asked: the app's message parser it reads costs every other command nothing.
|
|
4101
4006
|
*/
|
|
4102
4007
|
async function translatorFor(value, home) {
|
|
4103
4008
|
if (value === void 0) return null;
|
|
4104
|
-
const { loadDetector, openTranslator, translateTarget } = await import("./translate-
|
|
4009
|
+
const { loadDetector, openTranslator, translateTarget } = await import("./translate-B9SMd6uf.js");
|
|
4105
4010
|
return openTranslator({
|
|
4106
4011
|
home,
|
|
4107
4012
|
to: translateTarget(value),
|
|
@@ -4483,10 +4388,19 @@ async function oneShotJoinWait(s, result, label) {
|
|
|
4483
4388
|
note: `Not paired yet: the inviter's app is offline. It pairs when both are online: keep this profile running (ghostly daemon --detach), then ghostly chat wait ${label?.trim() && !/\s/.test(label.trim()) ? label.trim() : String(result.chat)} --until paired`
|
|
4484
4389
|
};
|
|
4485
4390
|
}
|
|
4391
|
+
/**
|
|
4392
|
+
* Stdin up to `INPUT_BYTES` (commands/shared.ts, as `readInput` reads it where a command reads it at once); more is refused as it comes. It was read to its end first: `send bob --stdin < big.log`
|
|
4393
|
+
* with 1 GiB took 3 GB and answered V8's "Cannot create a string longer than 0x1fffffe8 characters", 128 MiB to
|
|
4394
|
+
* `settings set nick -` ran the CLI out of memory, an endless pipe never ended, and past 16 MiB a daemon cut the line,
|
|
4395
|
+
* answered "The daemon went away".
|
|
4396
|
+
*/
|
|
4486
4397
|
async function readStdin(onData) {
|
|
4487
4398
|
const chunks = [];
|
|
4399
|
+
let bytes = 0;
|
|
4488
4400
|
for await (const chunk of process.stdin) {
|
|
4489
4401
|
onData?.();
|
|
4402
|
+
bytes += chunk.length;
|
|
4403
|
+
if (bytes > 16777216) throw new CliError("bad_request", STDIN_TOO_BIG);
|
|
4490
4404
|
chunks.push(chunk);
|
|
4491
4405
|
}
|
|
4492
4406
|
return Buffer.concat(chunks).toString("utf8");
|
|
@@ -4502,7 +4416,8 @@ var SPECIAL = [
|
|
|
4502
4416
|
"Make a profile (its own keys, chats and wallets)",
|
|
4503
4417
|
{
|
|
4504
4418
|
use: o("boolean", "Make it the current profile"),
|
|
4505
|
-
name: o("string", "The name contacts see")
|
|
4419
|
+
name: o("string", "The name contacts see"),
|
|
4420
|
+
force: o("boolean", "Use --name even if it looks like a seed, a key or ecash")
|
|
4506
4421
|
}
|
|
4507
4422
|
],
|
|
4508
4423
|
["profile list", "Profiles, and which one is current"],
|
|
@@ -4513,7 +4428,8 @@ var SPECIAL = [
|
|
|
4513
4428
|
"Change the name contacts see",
|
|
4514
4429
|
{
|
|
4515
4430
|
name: o("string", "The name contacts see"),
|
|
4516
|
-
"share-profile": o("boolean", "Share the name and picture with contacts (--no-share-profile: do not)")
|
|
4431
|
+
"share-profile": o("boolean", "Share the name and picture with contacts (--no-share-profile: do not)"),
|
|
4432
|
+
force: o("boolean", "Use --name even if it looks like a seed, a key or ecash")
|
|
4517
4433
|
}
|
|
4518
4434
|
],
|
|
4519
4435
|
[
|
|
@@ -4581,7 +4497,11 @@ var SPECIAL = [
|
|
|
4581
4497
|
"The profile's settings",
|
|
4582
4498
|
{ "show-secret": o("boolean", "Show credentials too") }
|
|
4583
4499
|
],
|
|
4584
|
-
[
|
|
4500
|
+
[
|
|
4501
|
+
"settings set <key> <json-value>",
|
|
4502
|
+
"Change one: relays, irohRelays, hyperdhtRelay, iceServers, publicProfiles, online, shareProfile, sendTyping, autoDownloads, serveFiles, nick. <json-value> - (or none, piped) reads it from stdin: a TURN password stays out of ps",
|
|
4503
|
+
{ force: o("boolean", "Set a nick even if it looks like a seed, a key or ecash") }
|
|
4504
|
+
],
|
|
4585
4505
|
[
|
|
4586
4506
|
"engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]",
|
|
4587
4507
|
"Any call of the app's engine, with its own parameters (engine --list --verbose names them)",
|
|
@@ -4788,6 +4708,10 @@ async function profileCommand(sub, argv) {
|
|
|
4788
4708
|
name: {
|
|
4789
4709
|
type: "string",
|
|
4790
4710
|
description: ""
|
|
4711
|
+
},
|
|
4712
|
+
force: {
|
|
4713
|
+
type: "boolean",
|
|
4714
|
+
description: ""
|
|
4791
4715
|
}
|
|
4792
4716
|
},
|
|
4793
4717
|
backup: {
|
|
@@ -4827,6 +4751,10 @@ async function profileCommand(sub, argv) {
|
|
|
4827
4751
|
type: "boolean",
|
|
4828
4752
|
description: "",
|
|
4829
4753
|
eitherWay: true
|
|
4754
|
+
},
|
|
4755
|
+
force: {
|
|
4756
|
+
type: "boolean",
|
|
4757
|
+
description: ""
|
|
4830
4758
|
}
|
|
4831
4759
|
}
|
|
4832
4760
|
}[sub ?? ""] ?? {}, void 0, { command: commandOf("profile", sub) });
|
|
@@ -4838,6 +4766,8 @@ async function profileCommand(sub, argv) {
|
|
|
4838
4766
|
if (!name) throw new CliError("usage", "Missing <name>: ghostly profile create <name> [--use] [--name <shown name>]");
|
|
4839
4767
|
noMoreThan(1, parsed.positionals, "profile create <name> [--use] [--name <shown name>]");
|
|
4840
4768
|
const shownName = parsed.options.name === void 0 ? void 0 : checkShownName(parsed.options.name);
|
|
4769
|
+
const force = parsed.options.force === true;
|
|
4770
|
+
if (shownName) (await import("./secretGuard-Q2BKq0q0.js")).guardText(shownName, force, "name", "set it");
|
|
4841
4771
|
const paths = createProfile(g.home, name);
|
|
4842
4772
|
let shown = null;
|
|
4843
4773
|
if (shownName !== void 0) try {
|
|
@@ -4845,7 +4775,10 @@ async function profileCommand(sub, argv) {
|
|
|
4845
4775
|
...g,
|
|
4846
4776
|
profile: name,
|
|
4847
4777
|
paths
|
|
4848
|
-
}, (s) => s.call("profile.set", {
|
|
4778
|
+
}, (s) => s.call("profile.set", {
|
|
4779
|
+
name: shownName,
|
|
4780
|
+
force
|
|
4781
|
+
}));
|
|
4849
4782
|
} catch (e) {
|
|
4850
4783
|
rmSync(paths.dir, {
|
|
4851
4784
|
recursive: true,
|
|
@@ -4893,6 +4826,7 @@ async function profileCommand(sub, argv) {
|
|
|
4893
4826
|
if (parsed.options.name !== void 0) params.name = parsed.options.name;
|
|
4894
4827
|
if (parsed.options["share-profile"] !== void 0) params.shareProfile = parsed.options["share-profile"];
|
|
4895
4828
|
if (!Object.keys(params).length) throw new CliError("usage", "Nothing to change: ghostly profile set [--name <name>] [--share-profile | --no-share-profile]");
|
|
4829
|
+
if (parsed.options.force === true) params.force = true;
|
|
4896
4830
|
print(await withSession(g, (s) => s.call("profile.set", params)));
|
|
4897
4831
|
return;
|
|
4898
4832
|
}
|
|
@@ -4924,7 +4858,7 @@ async function profileCommand(sub, argv) {
|
|
|
4924
4858
|
if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
|
|
4925
4859
|
noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
|
|
4926
4860
|
const file = here(given);
|
|
4927
|
-
const { backupFileProtection, restoreProfile } = await import("./backup-
|
|
4861
|
+
const { backupFileProtection, restoreProfile } = await import("./backup-CeRckyl2.js");
|
|
4928
4862
|
const protection = await backupFileProtection(file);
|
|
4929
4863
|
const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
|
|
4930
4864
|
if (parsed.options.use) selectProfile(g.home, name);
|
|
@@ -5235,6 +5169,7 @@ function processAlive(pid) {
|
|
|
5235
5169
|
*/
|
|
5236
5170
|
async function startDetached(g, seconds) {
|
|
5237
5171
|
requireProfile(g);
|
|
5172
|
+
ownProfile(g.paths.dir);
|
|
5238
5173
|
const until = Date.now() + seconds * 1e3;
|
|
5239
5174
|
for (;;) {
|
|
5240
5175
|
if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
|
|
@@ -5590,10 +5525,16 @@ async function engineCommand(argv) {
|
|
|
5590
5525
|
print(result);
|
|
5591
5526
|
}
|
|
5592
5527
|
async function settingsCommand(sub, argv) {
|
|
5593
|
-
const parsed = parseArgs(argv, {
|
|
5594
|
-
|
|
5595
|
-
|
|
5596
|
-
|
|
5528
|
+
const parsed = parseArgs(argv, {
|
|
5529
|
+
"show-secret": {
|
|
5530
|
+
type: "boolean",
|
|
5531
|
+
description: ""
|
|
5532
|
+
},
|
|
5533
|
+
force: {
|
|
5534
|
+
type: "boolean",
|
|
5535
|
+
description: ""
|
|
5536
|
+
}
|
|
5537
|
+
}, void 0, {
|
|
5597
5538
|
command: commandOf("settings", sub),
|
|
5598
5539
|
text: sub === "set"
|
|
5599
5540
|
});
|
|
@@ -5617,7 +5558,11 @@ async function settingsCommand(sub, argv) {
|
|
|
5617
5558
|
parsedValue = value;
|
|
5618
5559
|
}
|
|
5619
5560
|
if ((await engineApi()).SETTABLE[key] === "string" && typeof parsedValue !== "string") parsedValue = value;
|
|
5620
|
-
|
|
5561
|
+
const force = parsed.options.force === true ? { force: true } : {};
|
|
5562
|
+
printAnswer(await withSession(g, (s) => s.call("settings.set", {
|
|
5563
|
+
[key]: parsedValue,
|
|
5564
|
+
...force
|
|
5565
|
+
}), { offline: LOCAL_SETTINGS.has(key) }));
|
|
5621
5566
|
return;
|
|
5622
5567
|
}
|
|
5623
5568
|
throw unknownCommand("settings", sub);
|
|
@@ -5651,7 +5596,7 @@ async function textCommand(name, argv) {
|
|
|
5651
5596
|
};
|
|
5652
5597
|
if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
|
|
5653
5598
|
if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
|
|
5654
|
-
if (!spec.message) Object.assign(params, (await import("./buttons-
|
|
5599
|
+
if (!spec.message) Object.assign(params, (await import("./buttons-D9QBHS9Y.js")).buttonsOf(parsed.options));
|
|
5655
5600
|
print(await withSession(g, (s) => {
|
|
5656
5601
|
if (spec.target === "chat") {
|
|
5657
5602
|
params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
|
|
@@ -5697,7 +5642,7 @@ async function identityAddCommand(argv) {
|
|
|
5697
5642
|
if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
|
|
5698
5643
|
inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
|
|
5699
5644
|
const items = parsed.options.field ?? [];
|
|
5700
|
-
const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-
|
|
5645
|
+
const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-BN9r2pR4.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
|
|
5701
5646
|
if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
|
|
5702
5647
|
const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
|
|
5703
5648
|
if (warning) process.stderr.write(`ghostly: ${warning}\n`);
|
|
@@ -5767,7 +5712,7 @@ async function tableCommand(name, argv) {
|
|
|
5767
5712
|
const pipedEvidence = command.method === "identity.complete" && !params.evidenceFile && !params.stdin && process.stdin.isTTY !== true;
|
|
5768
5713
|
if (command.method === "identity.complete") {
|
|
5769
5714
|
if (params.evidenceFile) try {
|
|
5770
|
-
params.evidence =
|
|
5715
|
+
params.evidence = readInput(params.evidenceFile);
|
|
5771
5716
|
} catch (error) {
|
|
5772
5717
|
throw localFileError(error, params.evidenceFile) ?? error;
|
|
5773
5718
|
}
|
|
@@ -5777,9 +5722,9 @@ async function tableCommand(name, argv) {
|
|
|
5777
5722
|
}
|
|
5778
5723
|
if (command.method === "x401.credential.add") {
|
|
5779
5724
|
try {
|
|
5780
|
-
params.credential = params.file === "-" ? await readStdin() :
|
|
5725
|
+
params.credential = params.file === "-" ? await readStdin() : readInput(params.file);
|
|
5781
5726
|
} catch (error) {
|
|
5782
|
-
throw localFileError(error, params.file)
|
|
5727
|
+
throw error instanceof CliError && error || localFileError(error, params.file) || new CliError("usage", `Cannot read the credential: ${error instanceof Error ? error.message : String(error)}`);
|
|
5783
5728
|
}
|
|
5784
5729
|
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");
|
|
5785
5730
|
if (!params.credential) throw new CliError("bad_request", `${params.file} is empty: it holds the SD-JWT VC the issuer sent`);
|
|
@@ -5807,7 +5752,7 @@ async function tableCommand(name, argv) {
|
|
|
5807
5752
|
});
|
|
5808
5753
|
if (translator) {
|
|
5809
5754
|
try {
|
|
5810
|
-
printAnswer(await (await import("./translate-
|
|
5755
|
+
printAnswer(await (await import("./translate-B9SMd6uf.js")).translateAnswer(result, translator));
|
|
5811
5756
|
} finally {
|
|
5812
5757
|
translator.close();
|
|
5813
5758
|
}
|
|
@@ -5838,6 +5783,7 @@ async function callPipeCommand(argv) {
|
|
|
5838
5783
|
socket.once("connect", resolve);
|
|
5839
5784
|
socket.once("error", reject);
|
|
5840
5785
|
});
|
|
5786
|
+
socket.write(`${audio.token}\n`);
|
|
5841
5787
|
process.stderr.write(`ghostly: call ${call.call}: s16le mono ${audio.rate} Hz on stdin/stdout\n`);
|
|
5842
5788
|
process.stdin.pipe(socket, { end: false });
|
|
5843
5789
|
socket.pipe(process.stdout);
|
|
@@ -6027,4 +5973,4 @@ async function run(argv) {
|
|
|
6027
5973
|
//#endregion
|
|
6028
5974
|
export { run };
|
|
6029
5975
|
|
|
6030
|
-
//# sourceMappingURL=main-
|
|
5976
|
+
//# sourceMappingURL=main-4qE381KM.js.map
|