@ghostlytools/cli 1.9.0 → 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.
Files changed (107) hide show
  1. package/README.md +28 -20
  2. package/SKILL.md +5 -1
  3. package/dist/assets/{api-DFCgr6RH.js → api-BF_KwecF.js} +84 -38
  4. package/dist/assets/api-BF_KwecF.js.map +1 -0
  5. package/dist/assets/{api-raWw9j_m.js → api-DdrA86Ur.js} +2 -2
  6. package/dist/assets/{apiKit-CCavJJcl.js → apiKit-Du1u2l4x.js} +8 -8
  7. package/dist/assets/apiKit-Du1u2l4x.js.map +1 -0
  8. package/dist/assets/{apps-B7o2BPj6.js → apps-Bti9fDoW.js} +1 -1
  9. package/dist/assets/{apps-DmxEG147.js → apps-DwPfp54I.js} +5 -3
  10. package/dist/assets/apps-DwPfp54I.js.map +1 -0
  11. package/dist/assets/{arkade-DtYR9H0c.js → arkade-DOWpA2Kr.js} +2 -2
  12. package/dist/assets/{arkade-DtYR9H0c.js.map → arkade-DOWpA2Kr.js.map} +1 -1
  13. package/dist/assets/{backup-BserdrNk.js → backup-CeRckyl2.js} +1 -1
  14. package/dist/assets/{backup-YIB2XIES.js → backup-DZ_Q1eSu.js} +6 -6
  15. package/dist/assets/{backup-YIB2XIES.js.map → backup-DZ_Q1eSu.js.map} +1 -1
  16. package/dist/assets/bitcoindevkit_bg-B-iLWrmX.js.map +1 -1
  17. package/dist/assets/{blobFiles-DOQDRdDI.js → blobFiles-BnjN_Vrz.js} +3 -3
  18. package/dist/assets/{blobFiles-DOQDRdDI.js.map → blobFiles-BnjN_Vrz.js.map} +1 -1
  19. package/dist/assets/buttons-BxIThdg9.js +332 -0
  20. package/dist/assets/buttons-BxIThdg9.js.map +1 -0
  21. package/dist/assets/buttons-D9QBHS9Y.js +2 -0
  22. package/dist/assets/client-D5E1RQYB.js +473 -0
  23. package/dist/assets/client-D5E1RQYB.js.map +1 -0
  24. package/dist/assets/{endpoint-BdaeBw2L.js → endpoint-DWHkXWVM.js} +101 -16
  25. package/dist/assets/endpoint-DWHkXWVM.js.map +1 -0
  26. package/dist/assets/{envelope-Dt75vrmY.js → envelope-CugS9qwQ.js} +2 -2
  27. package/dist/assets/{envelope-Dt75vrmY.js.map → envelope-CugS9qwQ.js.map} +1 -1
  28. package/dist/assets/fedimint_client_wasm_bg-BtHHlFpp.js.map +1 -1
  29. package/dist/assets/{fileBytes-BPDKufla.js → fileBytes-DMzrIdCu.js} +1 -1
  30. package/dist/assets/{fileBytes-DNgrRL0R.js → fileBytes-DjBYYyXT.js} +3 -3
  31. package/dist/assets/{fileBytes-DNgrRL0R.js.map → fileBytes-DjBYYyXT.js.map} +1 -1
  32. package/dist/assets/{fileBytes-Q3ehcEr8.js → fileBytes-Douk1yOp.js} +2 -2
  33. package/dist/assets/{fileBytes-Q3ehcEr8.js.map → fileBytes-Douk1yOp.js.map} +1 -1
  34. package/dist/assets/fileBytesIdb-CD5Uv490.js +2 -0
  35. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js → fileBytesIdb-CkClu9YI.js} +3 -3
  36. package/dist/assets/{fileBytesIdb-Dm1EyEbT.js.map → fileBytesIdb-CkClu9YI.js.map} +1 -1
  37. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js → fileBytesOpfs-WryQuOgK.js} +3 -3
  38. package/dist/assets/{fileBytesOpfs-ZGD21c4Q.js.map → fileBytesOpfs-WryQuOgK.js.map} +1 -1
  39. package/dist/assets/{fixedHosts-B598JzbC.js → fixedHosts-B4E4VrYE.js} +4 -4
  40. package/dist/assets/{fixedHosts-B598JzbC.js.map → fixedHosts-B4E4VrYE.js.map} +1 -1
  41. package/dist/assets/{groupFiles-FXel6zIc.js → groupFiles-NonOYBKN.js} +378 -59
  42. package/dist/assets/groupFiles-NonOYBKN.js.map +1 -0
  43. package/dist/assets/{host-DIBeK_c_.js → host-DvcVt5YI.js} +79 -23
  44. package/dist/assets/{host-DIBeK_c_.js.map → host-DvcVt5YI.js.map} +1 -1
  45. package/dist/assets/{hyperdhtRelay-D185dETu.js → hyperdhtRelay-Ce42sR8x.js} +2 -2
  46. package/dist/assets/{hyperdhtRelay-D185dETu.js.map → hyperdhtRelay-Ce42sR8x.js.map} +1 -1
  47. package/dist/assets/{idb-BkOJES5_.js → idb-BHsAqENE.js} +37 -6
  48. package/dist/assets/idb-BHsAqENE.js.map +1 -0
  49. package/dist/assets/{irohWeb-BSv_BWyG.js → irohWeb-C9ChbD-c.js} +57 -3
  50. package/dist/assets/{irohWeb-BSv_BWyG.js.map → irohWeb-C9ChbD-c.js.map} +1 -1
  51. package/dist/assets/{main-BbhfMTt8.js → main-4qE381KM.js} +194 -276
  52. package/dist/assets/main-4qE381KM.js.map +1 -0
  53. package/dist/assets/{mainline-9Vc3c3SA.js → mainline-DOwZDHVy.js} +2 -2
  54. package/dist/assets/{mainline-9Vc3c3SA.js.map → mainline-DOwZDHVy.js.map} +1 -1
  55. package/dist/assets/{networkReason-BncJ9KSM.js → networkReason-MInk1Y63.js} +3 -3
  56. package/dist/assets/{networkReason-BncJ9KSM.js.map → networkReason-MInk1Y63.js.map} +1 -1
  57. package/dist/assets/{nwc-QX3Yt1Sb.js → nwc-CHLWFV1R.js} +3 -3
  58. package/dist/assets/{nwc-QX3Yt1Sb.js.map → nwc-CHLWFV1R.js.map} +1 -1
  59. package/dist/assets/{nwcProvider-CzX3xH47.js → nwcProvider-BlkPOJen.js} +2 -2
  60. package/dist/assets/{nwcProvider-CzX3xH47.js.map → nwcProvider-BlkPOJen.js.map} +1 -1
  61. package/dist/assets/{ownDid-D8z5gwGI.js → ownDid-yXtY_1B5.js} +3 -3
  62. package/dist/assets/ownDid-yXtY_1B5.js.map +1 -0
  63. package/dist/assets/{profiles-MFtCmJwK.js → profiles-vbXHs0Mq.js} +40 -3
  64. package/dist/assets/profiles-vbXHs0Mq.js.map +1 -0
  65. package/dist/assets/{registry-PTtBMaYZ.js → registry-BN9r2pR4.js} +1 -1
  66. package/dist/assets/{registry-B2Dtnibo.js → registry-chCD0KWS.js} +5 -5
  67. package/dist/assets/registry-chCD0KWS.js.map +1 -0
  68. package/dist/assets/{resolve-ZxVzwFNA.js → resolve-Dtzogt2W.js} +2 -2
  69. package/dist/assets/{resolve-ZxVzwFNA.js.map → resolve-Dtzogt2W.js.map} +1 -1
  70. package/dist/assets/{restoredRows-BCRCjhdF.js → restoredRows-CRYwIx3g.js} +2 -2
  71. package/dist/assets/{restoredRows-BCRCjhdF.js.map → restoredRows-CRYwIx3g.js.map} +1 -1
  72. package/dist/assets/{buttons-CuRfKnPI.js → secretGuard-CSVNxXVW.js} +80 -330
  73. package/dist/assets/secretGuard-CSVNxXVW.js.map +1 -0
  74. package/dist/assets/secretGuard-Q2BKq0q0.js +2 -0
  75. package/dist/assets/{server-Dw1o8z1o.js → server-BZnsm5X5.js} +1749 -335
  76. package/dist/assets/server-BZnsm5X5.js.map +1 -0
  77. package/dist/assets/{src-BD8RBVEp.js → src-DZagapGt.js} +1043 -197
  78. package/dist/assets/src-DZagapGt.js.map +1 -0
  79. package/dist/assets/{sshForges-DWrESWkK.js → sshForges-BkTgy5rx.js} +16 -9
  80. package/dist/assets/{sshForges-DWrESWkK.js.map → sshForges-BkTgy5rx.js.map} +1 -1
  81. package/dist/assets/{translate-D1uP0q32.js → translate-B9SMd6uf.js} +8 -7
  82. package/dist/assets/translate-B9SMd6uf.js.map +1 -0
  83. package/dist/assets/{usdt-DhVN8geQ.js → usdt-BU4ezonh.js} +3 -3
  84. package/dist/assets/{usdt-DhVN8geQ.js.map → usdt-BU4ezonh.js.map} +1 -1
  85. package/dist/assets/{words-DdXPkB3n.js → words-jYy7lTcb.js} +4 -2
  86. package/dist/assets/words-jYy7lTcb.js.map +1 -0
  87. package/dist/ghostly.mjs +1 -1
  88. package/package.json +1 -1
  89. package/dist/assets/api-DFCgr6RH.js.map +0 -1
  90. package/dist/assets/apiKit-CCavJJcl.js.map +0 -1
  91. package/dist/assets/apps-DmxEG147.js.map +0 -1
  92. package/dist/assets/buttons-CuRfKnPI.js.map +0 -1
  93. package/dist/assets/buttons-De3LPdSG.js +0 -2
  94. package/dist/assets/daemonProof-DtrL5lE5.js +0 -236
  95. package/dist/assets/daemonProof-DtrL5lE5.js.map +0 -1
  96. package/dist/assets/endpoint-BdaeBw2L.js.map +0 -1
  97. package/dist/assets/fileBytesIdb-DZcESfTt.js +0 -2
  98. package/dist/assets/groupFiles-FXel6zIc.js.map +0 -1
  99. package/dist/assets/idb-BkOJES5_.js.map +0 -1
  100. package/dist/assets/main-BbhfMTt8.js.map +0 -1
  101. package/dist/assets/ownDid-D8z5gwGI.js.map +0 -1
  102. package/dist/assets/profiles-MFtCmJwK.js.map +0 -1
  103. package/dist/assets/registry-B2Dtnibo.js.map +0 -1
  104. package/dist/assets/server-Dw1o8z1o.js.map +0 -1
  105. package/dist/assets/src-BD8RBVEp.js.map +0 -1
  106. package/dist/assets/translate-D1uP0q32.js.map +0 -1
  107. package/dist/assets/words-DdXPkB3n.js.map +0 -1
@@ -1,19 +1,18 @@
1
- import { Qn as GROUP_FILE_LIMITS, _o as statusCardBytes, ao as PR_STATES, ba as VOICE_LIMITS, co as STATUS_CARD_LIMITS, io as PR_CHECKS, lo as TASK_STATUSES, mo as cardUrl, no as CRON_LINE, oo as ROUTINE_STATES, po as cardLine, ro as ITEM_STATES, so as RUN_RESULTS } from "./src-BD8RBVEp.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-DdXPkB3n.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 { m as namedByThem, t as CONTACT_KEY } from "./apiKit-CCavJJcl.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 ownSocket } from "./profiles-MFtCmJwK.js";
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
6
  import { n as waitNotice, r as waitsFor } from "./waitNotice-B8D8WhbE.js";
7
- 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-DtrL5lE5.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.9.0",
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",
@@ -285,232 +284,6 @@ function liftGlobals(argv) {
285
284
  ];
286
285
  }
287
286
  //#endregion
288
- //#region src/client.ts
289
- /** The id of the hello on every connection: a string, so it is never one of the calls' numbers. */
290
- var HELLO_ID = "hello";
291
- /**
292
- * How long a client waits for the daemon's greeting before it asks who holds the profile: a daemon greets as it
293
- * accepts the connection, and one of an older release (before the greeting) never does. A daemon of this release
294
- * holding the profile (`daemonOfThisRelease`) is busy and is waited for, under each call's own deadline; anything
295
- * else is refused then. It used to refuse every late greeting, after 10 s: a daemon busy that long on one task (an
296
- * outbox backlog, 14 to 29 s) had every command and `listen` refused as an older release's, to be restarted.
297
- */
298
- var GREETING_MS = 2e3;
299
- /** The refusal of a listener that did not prove it is the profile's daemon (`isNotTheDaemon` tells it apart). */
300
- function notTheDaemon(socket) {
301
- 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" });
302
- }
303
- function isNotTheDaemon(error) {
304
- return error instanceof CliError && error.code === "refused" && error.details?.reason === "not-the-daemon";
305
- }
306
- /**
307
- * A connection to a profile's daemon over its socket (WISP 1100 § Local control API). `null` from `connectDaemon`
308
- * means no daemon answers there: a one-shot command runs the profile itself.
309
- *
310
- * The client writes nothing on it until the daemon's greeting, its first line, proves the other end read the
311
- * profile's daemon secret and holds the profile's lock (`provesGreeting`): a listener that cannot prove it has read
312
- * nothing from this client, so it cannot impersonate it either (`daemonProof.ts`). Then the first line written is a
313
- * `daemon.hello`, and no call is written until its answer proves the same over the client's own nonce. Until then
314
- * every call waits, under its own deadline, and a listener that does not prove both gets every call refused
315
- * (`refused`, `isNotTheDaemon`). Nothing it writes before that is read either.
316
- */
317
- var DaemonClient = class {
318
- socket;
319
- address;
320
- nextId = 1;
321
- pending = /* @__PURE__ */ new Map();
322
- eventListener = null;
323
- closedListener = null;
324
- /** While paused: the events of the chunk already read, given to the listener on resume. */
325
- held = null;
326
- greeted = false;
327
- verified = false;
328
- refusal = null;
329
- ready;
330
- settle;
331
- constructor(socket, address, greetingMs = GREETING_MS) {
332
- this.socket = socket;
333
- this.address = address;
334
- this.ready = new Promise((resolve, reject) => {
335
- this.settle = {
336
- resolve,
337
- reject
338
- };
339
- });
340
- this.ready.catch(() => {});
341
- const nonce = newNonce();
342
- const waitedTooLong = setTimeout(() => {
343
- if (!this.greeted && !this.refusal && !daemonOfThisRelease(this.address.dir)) this.refuse();
344
- }, greetingMs);
345
- waitedTooLong.unref?.();
346
- const lines = createInterface({
347
- input: socket,
348
- crlfDelay: Infinity
349
- });
350
- lines.on("error", () => {});
351
- lines.on("line", (line) => {
352
- let message;
353
- try {
354
- message = JSON.parse(line);
355
- } catch {
356
- if (!this.greeted && !this.refusal) this.refuse();
357
- return;
358
- }
359
- if (this.refusal) return;
360
- if (!this.greeted) {
361
- clearTimeout(waitedTooLong);
362
- const secret = readDaemonSecret(this.address.dir);
363
- if (!secret || !provesGreeting(secret, this.address.dir, message)) {
364
- this.refuse();
365
- return;
366
- }
367
- this.greeted = true;
368
- if (socket.writableEnded || socket.destroyed) return;
369
- socket.write(JSON.stringify({
370
- id: HELLO_ID,
371
- method: HELLO,
372
- params: { nonce }
373
- }) + "\n");
374
- return;
375
- }
376
- if (!this.verified) {
377
- if (message?.id !== HELLO_ID) return;
378
- const secret = readDaemonSecret(this.address.dir);
379
- if (!message.error && secret && provesDaemon(secret, nonce, message.result)) {
380
- this.verified = true;
381
- this.settle.resolve();
382
- return;
383
- }
384
- this.refuse();
385
- return;
386
- }
387
- if (message.event) {
388
- if (this.held) this.held.push(message.event);
389
- else this.eventListener?.(message.event);
390
- return;
391
- }
392
- const waiting = typeof message.id === "number" ? this.pending.get(message.id) : void 0;
393
- if (!waiting) return;
394
- this.pending.delete(message.id);
395
- if (message.error) waiting.reject(new CliError(message.error.code, message.error.message, message.error.details));
396
- else waiting.resolve(message.result);
397
- });
398
- socket.on("close", () => {
399
- clearTimeout(waitedTooLong);
400
- const why = this.refusal ?? new CliError("unavailable", "The daemon went away");
401
- if (!this.verified) this.settle.reject(why);
402
- for (const waiting of this.pending.values()) waiting.reject(why);
403
- this.pending.clear();
404
- this.closedListener?.();
405
- });
406
- socket.on("error", () => {});
407
- }
408
- refuse() {
409
- this.refusal = notTheDaemon(this.address.socket);
410
- this.settle.reject(this.refusal);
411
- this.socket.destroy();
412
- }
413
- /**
414
- * `timeoutMs`: give up (code `timeout`, exit 4) when the daemon has not answered by then; without it the call waits
415
- * for as long as the connection holds. A call that timed out closes the connection: its answer, if one ever comes,
416
- * is of no use, and the process leaves once nothing else keeps it (not every caller reaches `exit`).
417
- */
418
- call(method, params = {}, { timeoutMs } = {}) {
419
- if (this.socket.destroyed) return Promise.reject(this.refusal ?? new CliError("unavailable", "The daemon went away"));
420
- const id = this.nextId++;
421
- return new Promise((resolve, reject) => {
422
- let timer;
423
- if (timeoutMs !== void 0) {
424
- timer = setTimeout(() => {
425
- if (!this.pending.delete(id)) return;
426
- reject(new CliError("timeout", `The daemon did not answer ${method} in ${timeoutMs / 1e3} s: \`ghostly daemon restart\` starts a fresh one`, { method }));
427
- this.destroy();
428
- }, timeoutMs);
429
- timer.unref?.();
430
- }
431
- const settle = {
432
- resolve: (value) => {
433
- if (timer) clearTimeout(timer);
434
- resolve(value);
435
- },
436
- reject: (error) => {
437
- if (timer) clearTimeout(timer);
438
- reject(error);
439
- }
440
- };
441
- this.pending.set(id, settle);
442
- this.ready.then(() => {
443
- if (this.pending.has(id) && !this.socket.destroyed) this.socket.write(JSON.stringify({
444
- id,
445
- method,
446
- params
447
- }) + "\n");
448
- }, (error) => {
449
- if (this.pending.delete(id)) settle.reject(error);
450
- });
451
- });
452
- }
453
- /** Events after `since` (replayed from the journal), then every new one, until the connection closes. */
454
- async subscribe(since, listener, onClosed) {
455
- this.eventListener = listener;
456
- this.closedListener = onClosed ?? null;
457
- return this.call("events.subscribe", since === void 0 ? {} : { since });
458
- }
459
- /**
460
- * Stops reading: what the daemon sends waits in the connection (and past its bound the daemon ends it), and no
461
- * event reaches the listener until `resume`.
462
- */
463
- pause() {
464
- if (this.held) return;
465
- this.held = [];
466
- this.socket.pause();
467
- }
468
- /** Gives the listener the events held, then reads again; a listener that pauses again keeps the rest held. */
469
- resume() {
470
- const held = this.held;
471
- if (!held) return;
472
- this.held = null;
473
- for (let i = 0; i < held.length; i++) {
474
- this.eventListener?.(held[i]);
475
- if (this.held) {
476
- this.held.unshift(...held.slice(i + 1));
477
- return;
478
- }
479
- }
480
- this.socket.resume();
481
- }
482
- close() {
483
- this.socket.end();
484
- }
485
- /** Closes at once: what the daemon still sends is not read. */
486
- destroy() {
487
- this.socket.destroy();
488
- }
489
- };
490
- /**
491
- * `timeoutMs` bounds the connect only; `greetingMs`, the wait for the daemon's greeting (above). The client it gives
492
- * has written nothing yet; whether the listener is the daemon is known at the first call.
493
- */
494
- function connectDaemon(address, timeoutMs = 2e3, { greetingMs = GREETING_MS } = {}) {
495
- const path = address.socket;
496
- if (!ownSocket(path)) return Promise.resolve(null);
497
- return new Promise((resolve) => {
498
- const socket = connect(path);
499
- const timer = setTimeout(() => {
500
- socket.destroy();
501
- resolve(null);
502
- }, timeoutMs);
503
- socket.once("connect", () => {
504
- clearTimeout(timer);
505
- resolve(new DaemonClient(socket, address, greetingMs));
506
- });
507
- socket.once("error", () => {
508
- clearTimeout(timer);
509
- resolve(null);
510
- });
511
- });
512
- }
513
- //#endregion
514
287
  //#region src/commands/shared.ts
515
288
  var wait = {
516
289
  wait: {
@@ -569,6 +342,29 @@ function here(path) {
569
342
  if (path === "") throw new CliError("usage", "A path given as \"\" names no file");
570
343
  return typeof path === "string" ? userPath(path) : void 0;
571
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
+ }
572
368
  /**
573
369
  * A list option that names chats (`--to`, `--from`): "" or "group:" alone (an unset variable in a script) names
574
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.
@@ -717,9 +513,9 @@ function cardJson(value) {
717
513
  const file = text.startsWith("{") || text === "-" ? void 0 : here(text);
718
514
  let raw;
719
515
  try {
720
- raw = text.startsWith("{") ? text : readFileSync(file ?? 0, "utf8");
516
+ raw = text.startsWith("{") ? text : readInput(file ?? 0);
721
517
  } catch (error) {
722
- 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)}`);
723
519
  }
724
520
  let parsed;
725
521
  try {
@@ -938,10 +734,58 @@ function quota(card, usage) {
938
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";
939
735
  /** An ISO date with no time, which `Date.parse` alone reads as UTC midnight: `2026-09-30`, `2026-09`. */
940
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
+ }
941
782
  /**
942
783
  * A time a command names: milliseconds, or a date the JavaScript Date reads (`2026-09-30T01:00:00Z`). A date with no
943
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
944
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.
945
789
  */
946
790
  function cardTime(value, flag) {
947
791
  if (value === void 0) return void 0;
@@ -949,6 +793,17 @@ function cardTime(value, flag) {
949
793
  const day = ISO_DAY.exec(text);
950
794
  const ms = /^\d+$/.test(text) ? milliseconds(text, flag) : Date.parse(day ? `${text}${day[1] ? "" : "-01"}T00:00` : text);
951
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
+ }
952
807
  return ms;
953
808
  }
954
809
  /** `--run ok`, `--run failed:"CI flaked"`: a run of a routine, recorded as its last. */
@@ -1006,7 +861,7 @@ var routineOptions = {
1006
861
  },
1007
862
  next: {
1008
863
  type: "string",
1009
- 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}`
1010
865
  },
1011
866
  run: {
1012
867
  type: "string",
@@ -1153,7 +1008,7 @@ var usageOptions = {
1153
1008
  },
1154
1009
  resets: {
1155
1010
  type: "string",
1156
- 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}`
1157
1012
  },
1158
1013
  also: {
1159
1014
  type: "list",
@@ -1181,7 +1036,7 @@ function keyFile(value, usage) {
1181
1036
  /** `app send`'s message: JSON on the command line, or `-` for stdin. */
1182
1037
  function appData(value) {
1183
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|->");
1184
- const text = value.trim() === "-" ? readFileSync(0, "utf8") : value;
1039
+ const text = value.trim() === "-" ? readInput(0) : value;
1185
1040
  try {
1186
1041
  return JSON.parse(text);
1187
1042
  } catch {
@@ -1227,7 +1082,7 @@ var commands$8 = {
1227
1082
  description: "Replace the three files when they are there"
1228
1083
  }
1229
1084
  },
1230
- run: async ({ options }, a) => (await import("./apps-B7o2BPj6.js")).initApp(a.dir, {
1085
+ run: async ({ options }, a) => (await import("./apps-Bti9fDoW.js")).initApp(a.dir, {
1231
1086
  name: options.name,
1232
1087
  title: options.title,
1233
1088
  force: options.force === true
@@ -1267,7 +1122,7 @@ var commands$8 = {
1267
1122
  description: "This version's sequence, higher than the bundle at --out's (default: one more than it)"
1268
1123
  }
1269
1124
  },
1270
- run: async ({ options }, a) => (await import("./apps-B7o2BPj6.js")).publishApp(a.dir, keyFile(options.key, "app publish <dir> --key <file> [--out <file>] [--sequence n]"), here(options.out), options.sequence)
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)
1271
1126
  },
1272
1127
  "app revoke": {
1273
1128
  method: "app.revoke",
@@ -1297,10 +1152,10 @@ var commands$8 = {
1297
1152
  },
1298
1153
  force: {
1299
1154
  type: "boolean",
1300
- 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"
1301
1156
  }
1302
1157
  },
1303
- run: async ({ options }, a) => (await import("./apps-B7o2BPj6.js")).revokeApp(a.dir, keyFile(options.key, "app revoke <dir> --key <file> (--digest <digest>... | --up-to <sequence>) [--reason <text>] [--bundle <file>] [--force]"), {
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]"), {
1304
1159
  digests: options.digest,
1305
1160
  upTo: options["up-to"],
1306
1161
  reason: options.reason,
@@ -1361,7 +1216,7 @@ var commands$8 = {
1361
1216
  usage: "app verify <bundle|url>",
1362
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",
1363
1218
  args: ["bundle"],
1364
- run: async (_, a) => (await import("./apps-B7o2BPj6.js")).verifyApp(a.bundle)
1219
+ run: async (_, a) => (await import("./apps-Bti9fDoW.js")).verifyApp(a.bundle)
1365
1220
  },
1366
1221
  "store sign": {
1367
1222
  method: "store.sign",
@@ -1378,7 +1233,7 @@ var commands$8 = {
1378
1233
  description: "The folder to write ghostly-store.json and ghostly-store.sig in (default: the index's)"
1379
1234
  }
1380
1235
  },
1381
- run: async ({ options }, a) => (await import("./apps-B7o2BPj6.js")).signStore(a.index, keyFile(options.key, "store sign <index> --key <file> [--out <dir>]"), here(options.out))
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))
1382
1237
  }
1383
1238
  };
1384
1239
  //#endregion
@@ -2201,7 +2056,7 @@ var commands$5 = {
2201
2056
  },
2202
2057
  "file send": {
2203
2058
  method: "file.send",
2204
- usage: "file send <chat|group> <path> [--name n] [--mime t] [--voice [ms] [--peaks 0,40,…]] [--reply <message>] [--wait none|sent] [--timeout s]",
2059
+ usage: "file send <chat|group> <path> [--name n] [--mime t] [--voice [ms] [--peaks 0,40,…]] [--reply <message>] [--force] [--wait none|sent] [--timeout s]",
2205
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)`,
2206
2061
  args: ["chat", "path"],
2207
2062
  options: {
@@ -2231,6 +2086,10 @@ var commands$5 = {
2231
2086
  timeout: {
2232
2087
  type: "number",
2233
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"
2234
2093
  }
2235
2094
  },
2236
2095
  params: ({ options }, a) => ({
@@ -2240,6 +2099,7 @@ var commands$5 = {
2240
2099
  mime: options.mime,
2241
2100
  ...voiceOf(options),
2242
2101
  reply: options.reply,
2102
+ force: options.force === true,
2243
2103
  wait: options.wait,
2244
2104
  timeout: timeout(options, LONG_WAIT_SECONDS)
2245
2105
  })
@@ -2303,6 +2163,11 @@ var commands$4 = {
2303
2163
  };
2304
2164
  //#endregion
2305
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 } : {};
2306
2171
  /** Groups: one entry per command, in alphabetical order (test/commands.test.ts checks). */
2307
2172
  var commands$3 = {
2308
2173
  "group accept": {
@@ -2326,16 +2191,20 @@ var commands$3 = {
2326
2191
  },
2327
2192
  "group create": {
2328
2193
  method: "group.create",
2329
- usage: "group create <name...> [--mesh]",
2194
+ usage: "group create <name...> [--mesh] [--force]",
2330
2195
  summary: "A community (a link anyone can open) or, with --mesh, a private group of up to 32",
2331
2196
  args: ["name..."],
2332
- options: { mesh: {
2333
- type: "boolean",
2334
- description: "A private mesh of contacts instead of a community"
2335
- } },
2197
+ options: {
2198
+ mesh: {
2199
+ type: "boolean",
2200
+ description: "A private mesh of contacts instead of a community"
2201
+ },
2202
+ force: nameForce
2203
+ },
2336
2204
  params: ({ options }, { name }) => ({
2337
2205
  name,
2338
- profile: options.mesh ? "mesh" : "community"
2206
+ profile: options.mesh ? "mesh" : "community",
2207
+ ...forced(options)
2339
2208
  })
2340
2209
  },
2341
2210
  "group decline": {
@@ -2537,13 +2406,17 @@ var commands$3 = {
2537
2406
  },
2538
2407
  "group rename": {
2539
2408
  method: "group.rename",
2540
- usage: "group rename <group> <name...> [--show-secret]",
2409
+ usage: "group rename <group> <name...> [--force] [--show-secret]",
2541
2410
  summary: "Rename the group (admin; the picture stays)",
2542
2411
  args: ["group", "name..."],
2543
- options: showSecret,
2412
+ options: {
2413
+ ...showSecret,
2414
+ force: nameForce
2415
+ },
2544
2416
  params: ({ options }, a) => ({
2545
2417
  group: a.group,
2546
2418
  name: a.name,
2419
+ ...forced(options),
2547
2420
  ...secret(options)
2548
2421
  })
2549
2422
  },
@@ -2691,13 +2564,13 @@ var commands$2 = {
2691
2564
  method: "x401.credential.add",
2692
2565
  usage: "x401 credential add <file|-> [--label <name>]",
2693
2566
  summary: "Keep an issued SD-JWT VC bound to a key from x401 key new (a file, or - for stdin)",
2694
- args: ["file"],
2567
+ args: ["path"],
2695
2568
  options: { label: {
2696
2569
  type: "string",
2697
2570
  description: "Your name for it, up to 80 characters on one line (default: its type)"
2698
2571
  } },
2699
2572
  params: ({ options }, a) => ({
2700
- file: a.file === "-" ? "-" : here(a.file),
2573
+ file: a.path === "-" ? "-" : here(a.path),
2701
2574
  label: options.label
2702
2575
  })
2703
2576
  },
@@ -2859,7 +2732,7 @@ var commands$1 = {
2859
2732
  },
2860
2733
  "pay": {
2861
2734
  method: "pay",
2862
- 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]",
2863
2736
  summary: "Pay over Lightning from Testnet, or --network mainnet with --confirm-real",
2864
2737
  args: ["target"],
2865
2738
  options: {
@@ -2877,6 +2750,10 @@ var commands$1 = {
2877
2750
  type: "string",
2878
2751
  description: "For the address's owner"
2879
2752
  },
2753
+ chat: {
2754
+ type: "string",
2755
+ description: "The chat the invoice came from: on Testnet its contact is told it was paid"
2756
+ },
2880
2757
  "confirm-real": confirmReal,
2881
2758
  force
2882
2759
  },
@@ -2887,6 +2764,7 @@ var commands$1 = {
2887
2764
  maxFee: options["max-fee"],
2888
2765
  card: options.card,
2889
2766
  comment: options.comment,
2767
+ chat: options.chat,
2890
2768
  confirmReal: options["confirm-real"] === true,
2891
2769
  force: options.force === true
2892
2770
  })
@@ -4120,15 +3998,15 @@ var VERSION = package_default.version;
4120
3998
  * command a running daemon answers loads none of them, and starts about as fast as Node does. Statically imported, they
4121
3999
  * cost every command ~100 ms before its socket was opened.
4122
4000
  */
4123
- var engineApi = () => import("./api-raWw9j_m.js");
4124
- var engineHost = () => import("./host-DIBeK_c_.js");
4001
+ var engineApi = () => import("./api-DdrA86Ur.js");
4002
+ var engineHost = () => import("./host-DvcVt5YI.js");
4125
4003
  /**
4126
4004
  * `--translate <lang>`'s translator, or null (not asked; or the runtime is not there, said on stderr). Loaded only when
4127
4005
  * asked: the app's message parser it reads costs every other command nothing.
4128
4006
  */
4129
4007
  async function translatorFor(value, home) {
4130
4008
  if (value === void 0) return null;
4131
- const { loadDetector, openTranslator, translateTarget } = await import("./translate-D1uP0q32.js");
4009
+ const { loadDetector, openTranslator, translateTarget } = await import("./translate-B9SMd6uf.js");
4132
4010
  return openTranslator({
4133
4011
  home,
4134
4012
  to: translateTarget(value),
@@ -4510,10 +4388,19 @@ async function oneShotJoinWait(s, result, label) {
4510
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`
4511
4389
  };
4512
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
+ */
4513
4397
  async function readStdin(onData) {
4514
4398
  const chunks = [];
4399
+ let bytes = 0;
4515
4400
  for await (const chunk of process.stdin) {
4516
4401
  onData?.();
4402
+ bytes += chunk.length;
4403
+ if (bytes > 16777216) throw new CliError("bad_request", STDIN_TOO_BIG);
4517
4404
  chunks.push(chunk);
4518
4405
  }
4519
4406
  return Buffer.concat(chunks).toString("utf8");
@@ -4529,7 +4416,8 @@ var SPECIAL = [
4529
4416
  "Make a profile (its own keys, chats and wallets)",
4530
4417
  {
4531
4418
  use: o("boolean", "Make it the current profile"),
4532
- 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")
4533
4421
  }
4534
4422
  ],
4535
4423
  ["profile list", "Profiles, and which one is current"],
@@ -4540,7 +4428,8 @@ var SPECIAL = [
4540
4428
  "Change the name contacts see",
4541
4429
  {
4542
4430
  name: o("string", "The name contacts see"),
4543
- "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")
4544
4433
  }
4545
4434
  ],
4546
4435
  [
@@ -4608,7 +4497,11 @@ var SPECIAL = [
4608
4497
  "The profile's settings",
4609
4498
  { "show-secret": o("boolean", "Show credentials too") }
4610
4499
  ],
4611
- ["settings set <key> <json-value>", "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"],
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
+ ],
4612
4505
  [
4613
4506
  "engine <method> [json-params | -] [--confirm-real] [--show-secret] [--yes] [--force]",
4614
4507
  "Any call of the app's engine, with its own parameters (engine --list --verbose names them)",
@@ -4815,6 +4708,10 @@ async function profileCommand(sub, argv) {
4815
4708
  name: {
4816
4709
  type: "string",
4817
4710
  description: ""
4711
+ },
4712
+ force: {
4713
+ type: "boolean",
4714
+ description: ""
4818
4715
  }
4819
4716
  },
4820
4717
  backup: {
@@ -4854,6 +4751,10 @@ async function profileCommand(sub, argv) {
4854
4751
  type: "boolean",
4855
4752
  description: "",
4856
4753
  eitherWay: true
4754
+ },
4755
+ force: {
4756
+ type: "boolean",
4757
+ description: ""
4857
4758
  }
4858
4759
  }
4859
4760
  }[sub ?? ""] ?? {}, void 0, { command: commandOf("profile", sub) });
@@ -4865,6 +4766,8 @@ async function profileCommand(sub, argv) {
4865
4766
  if (!name) throw new CliError("usage", "Missing <name>: ghostly profile create <name> [--use] [--name <shown name>]");
4866
4767
  noMoreThan(1, parsed.positionals, "profile create <name> [--use] [--name <shown name>]");
4867
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");
4868
4771
  const paths = createProfile(g.home, name);
4869
4772
  let shown = null;
4870
4773
  if (shownName !== void 0) try {
@@ -4872,7 +4775,10 @@ async function profileCommand(sub, argv) {
4872
4775
  ...g,
4873
4776
  profile: name,
4874
4777
  paths
4875
- }, (s) => s.call("profile.set", { name: shownName }));
4778
+ }, (s) => s.call("profile.set", {
4779
+ name: shownName,
4780
+ force
4781
+ }));
4876
4782
  } catch (e) {
4877
4783
  rmSync(paths.dir, {
4878
4784
  recursive: true,
@@ -4920,6 +4826,7 @@ async function profileCommand(sub, argv) {
4920
4826
  if (parsed.options.name !== void 0) params.name = parsed.options.name;
4921
4827
  if (parsed.options["share-profile"] !== void 0) params.shareProfile = parsed.options["share-profile"];
4922
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;
4923
4830
  print(await withSession(g, (s) => s.call("profile.set", params)));
4924
4831
  return;
4925
4832
  }
@@ -4951,7 +4858,7 @@ async function profileCommand(sub, argv) {
4951
4858
  if (!given || !name) throw new CliError("usage", `Missing <${given ? "new profile" : "file"}>: ghostly profile restore <file> <new profile> [--passphrase-file f] [--use]`);
4952
4859
  noMoreThan(2, parsed.positionals, "profile restore <file> <new profile> [--passphrase-file f] [--use]");
4953
4860
  const file = here(given);
4954
- const { backupFileProtection, restoreProfile } = await import("./backup-BserdrNk.js");
4861
+ const { backupFileProtection, restoreProfile } = await import("./backup-CeRckyl2.js");
4955
4862
  const protection = await backupFileProtection(file);
4956
4863
  const paths = await restoreProfile(g.home, checkProfileName(name), file, protection === "none" ? void 0 : backupPassphrase(parsed.options["passphrase-file"], RESTORE_PASSPHRASE));
4957
4864
  if (parsed.options.use) selectProfile(g.home, name);
@@ -5262,6 +5169,7 @@ function processAlive(pid) {
5262
5169
  */
5263
5170
  async function startDetached(g, seconds) {
5264
5171
  requireProfile(g);
5172
+ ownProfile(g.paths.dir);
5265
5173
  const until = Date.now() + seconds * 1e3;
5266
5174
  for (;;) {
5267
5175
  if (await connectDaemon(g.paths)) throw new CliError("busy", `A daemon already runs profile ${g.profile}`);
@@ -5617,10 +5525,16 @@ async function engineCommand(argv) {
5617
5525
  print(result);
5618
5526
  }
5619
5527
  async function settingsCommand(sub, argv) {
5620
- const parsed = parseArgs(argv, { "show-secret": {
5621
- type: "boolean",
5622
- description: ""
5623
- } }, void 0, {
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, {
5624
5538
  command: commandOf("settings", sub),
5625
5539
  text: sub === "set"
5626
5540
  });
@@ -5644,7 +5558,11 @@ async function settingsCommand(sub, argv) {
5644
5558
  parsedValue = value;
5645
5559
  }
5646
5560
  if ((await engineApi()).SETTABLE[key] === "string" && typeof parsedValue !== "string") parsedValue = value;
5647
- printAnswer(await withSession(g, (s) => s.call("settings.set", { [key]: parsedValue }), { offline: LOCAL_SETTINGS.has(key) }));
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) }));
5648
5566
  return;
5649
5567
  }
5650
5568
  throw unknownCommand("settings", sub);
@@ -5678,7 +5596,7 @@ async function textCommand(name, argv) {
5678
5596
  };
5679
5597
  if (spec.target === "group") params.mentions = parsed.options.mention ?? [];
5680
5598
  if (parsed.options.reply !== void 0) params.reply = parsed.options.reply;
5681
- if (!spec.message) Object.assign(params, (await import("./buttons-De3LPdSG.js")).buttonsOf(parsed.options));
5599
+ if (!spec.message) Object.assign(params, (await import("./buttons-D9QBHS9Y.js")).buttonsOf(parsed.options));
5682
5600
  print(await withSession(g, (s) => {
5683
5601
  if (spec.target === "chat") {
5684
5602
  params.wait = parsed.options.wait ?? (s.mode === "one-shot" ? spec.message ? "confirmed" : "sent" : "none");
@@ -5724,7 +5642,7 @@ async function identityAddCommand(argv) {
5724
5642
  if (!provider) throw new CliError("usage", "Missing <provider>: ghostly identity add <provider> [subject] [--signer id] [--field name=value]... [--stdin] [--days n] [--timeout s]");
5725
5643
  inRange(parsed.options, "timeout", "a number of seconds", 5, 3600);
5726
5644
  const items = parsed.options.field ?? [];
5727
- const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-PTtBMaYZ.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
5645
+ const known = parsed.options.days !== void 0 || items.length ? (await import("./registry-BN9r2pR4.js")).IDENTITY_PROVIDERS.find((p) => p.id === provider) : void 0;
5728
5646
  if (known && parsed.options.days !== void 0) inRange(parsed.options, "days", "a whole number", 1, known.validity.maxDays, true);
5729
5647
  const { fields, warning } = await identityFields(items, parsed.options.stdin === true, identitySecretFields(known, parsed.options.signer), readStdin, process.stdin.isTTY === true);
5730
5648
  if (warning) process.stderr.write(`ghostly: ${warning}\n`);
@@ -5794,7 +5712,7 @@ async function tableCommand(name, argv) {
5794
5712
  const pipedEvidence = command.method === "identity.complete" && !params.evidenceFile && !params.stdin && process.stdin.isTTY !== true;
5795
5713
  if (command.method === "identity.complete") {
5796
5714
  if (params.evidenceFile) try {
5797
- params.evidence = readFileSync(params.evidenceFile, "utf8");
5715
+ params.evidence = readInput(params.evidenceFile);
5798
5716
  } catch (error) {
5799
5717
  throw localFileError(error, params.evidenceFile) ?? error;
5800
5718
  }
@@ -5804,9 +5722,9 @@ async function tableCommand(name, argv) {
5804
5722
  }
5805
5723
  if (command.method === "x401.credential.add") {
5806
5724
  try {
5807
- params.credential = params.file === "-" ? await readStdin() : readFileSync(params.file, "utf8");
5725
+ params.credential = params.file === "-" ? await readStdin() : readInput(params.file);
5808
5726
  } catch (error) {
5809
- throw localFileError(error, params.file) ?? new CliError("usage", `Cannot read the credential: ${error instanceof Error ? error.message : String(error)}`);
5727
+ throw error instanceof CliError && error || localFileError(error, params.file) || new CliError("usage", `Cannot read the credential: ${error instanceof Error ? error.message : String(error)}`);
5810
5728
  }
5811
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");
5812
5730
  if (!params.credential) throw new CliError("bad_request", `${params.file} is empty: it holds the SD-JWT VC the issuer sent`);
@@ -5834,7 +5752,7 @@ async function tableCommand(name, argv) {
5834
5752
  });
5835
5753
  if (translator) {
5836
5754
  try {
5837
- printAnswer(await (await import("./translate-D1uP0q32.js")).translateAnswer(result, translator));
5755
+ printAnswer(await (await import("./translate-B9SMd6uf.js")).translateAnswer(result, translator));
5838
5756
  } finally {
5839
5757
  translator.close();
5840
5758
  }
@@ -6055,4 +5973,4 @@ async function run(argv) {
6055
5973
  //#endregion
6056
5974
  export { run };
6057
5975
 
6058
- //# sourceMappingURL=main-BbhfMTt8.js.map
5976
+ //# sourceMappingURL=main-4qE381KM.js.map