@vaultkeepr/cli 0.0.0-stage → 0.2.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.
@@ -0,0 +1,794 @@
1
+ import { PairPayload, Vault, PairKeypair, VaultEntry, AgentVaultSummary } from '@vaultkeepr/core';
2
+
3
+ interface CliIO {
4
+ out(text: string): void;
5
+ err(text: string): void;
6
+ }
7
+ declare const defaultIO: CliIO;
8
+ interface Palette {
9
+ bold(text: string): string;
10
+ dim(text: string): string;
11
+ red(text: string): string;
12
+ green(text: string): string;
13
+ yellow(text: string): string;
14
+ cyan(text: string): string;
15
+ magenta(text: string): string;
16
+ }
17
+ declare function palette(enabled: boolean): Palette;
18
+ /** Colour is for humans: off when piped, off with NO_COLOR, off with TERM=dumb. */
19
+ declare function colorEnabled(): boolean;
20
+ interface TableStyle {
21
+ colors?: boolean;
22
+ /** Column index whose cell is coloured by `cellColor`. */
23
+ cellColor?: Record<number, (value: string) => string>;
24
+ }
25
+ /** Column-aligned table with a header rule. Widths are computed on plain text. */
26
+ declare function formatTable(headers: string[], rows: string[][], style?: TableStyle): string;
27
+ /** One-line spinner on stderr. No-op (and silent) when stderr is not a TTY. */
28
+ declare class Spinner {
29
+ private readonly io;
30
+ private timer;
31
+ private frame;
32
+ private label;
33
+ private readonly interactive;
34
+ constructor(io: CliIO, label: string);
35
+ start(): this;
36
+ update(label: string): void;
37
+ stop(): void;
38
+ }
39
+ interface AskOptions {
40
+ /** Secret answers are never echoed, never printed back. */
41
+ secret?: boolean;
42
+ input?: NodeJS.ReadStream;
43
+ output?: NodeJS.WritableStream;
44
+ }
45
+ /** Prompts for a line. `secret` masks the echo when a TTY is available. */
46
+ declare function ask(question: string, options?: AskOptions): Promise<string>;
47
+
48
+ declare class PromptCancelledError extends Error {
49
+ constructor();
50
+ }
51
+ interface PromptChoice<T extends string> {
52
+ value: T;
53
+ label: string;
54
+ hint?: string;
55
+ }
56
+ interface PromptSpinner {
57
+ start(message?: string): void;
58
+ stop(message?: string): void;
59
+ error(message?: string): void;
60
+ }
61
+ /**
62
+ * The prompt surface the commands use. Two implementations: `clackPrompter`
63
+ * (arrow-key selects, masked secrets, spinners, framed intro/outro) and
64
+ * `plainPrompter` (readline, no ANSI, no menu) for piped stdin and tests.
65
+ */
66
+ interface Prompter {
67
+ readonly interactive: boolean;
68
+ intro(title: string): void;
69
+ outro(message: string): void;
70
+ text(options: {
71
+ message: string;
72
+ placeholder?: string;
73
+ defaultValue?: string;
74
+ }): Promise<string>;
75
+ /**
76
+ * Yes/no confirmation. `initialValue` is the answer a bare Enter gives
77
+ * (default `false`): a destructive or overriding choice is never the default.
78
+ */
79
+ confirm(options: {
80
+ message: string;
81
+ initialValue?: boolean;
82
+ }): Promise<boolean>;
83
+ secret(options: {
84
+ message: string;
85
+ }): Promise<string>;
86
+ select<T extends string>(options: {
87
+ message: string;
88
+ choices: PromptChoice<T>[];
89
+ initialValue?: T;
90
+ }): Promise<T | null>;
91
+ /**
92
+ * Multiple-choice list (space to toggle, `a` for all). `initialValues`
93
+ * pre-checks the entries the caller suggests; `null` means cancelled.
94
+ */
95
+ multiselect<T extends string>(options: {
96
+ message: string;
97
+ choices: PromptChoice<T>[];
98
+ initialValues?: T[];
99
+ required?: boolean;
100
+ }): Promise<T[] | null>;
101
+ spinner(): PromptSpinner;
102
+ info(message: string): void;
103
+ success(message: string): void;
104
+ warn(message: string): void;
105
+ error(message: string): void;
106
+ }
107
+ /** @clack/prompts backed prompter, used when stdin and stdout are a TTY. */
108
+ declare function clackPrompter(overrides?: {
109
+ input?: NodeJS.ReadStream;
110
+ output?: NodeJS.WritableStream;
111
+ }): Prompter;
112
+ /**
113
+ * Readline backed prompter: no ANSI, no frames, no menu. Used for piped stdin
114
+ * (scripts, CI) and by tests, which inject their own `askFn`.
115
+ */
116
+ declare function plainPrompter(io: CliIO, askFn?: (question: string, options?: AskOptions) => Promise<string>): Prompter;
117
+ /** True when a real interactive session can be offered (both ends are a TTY). */
118
+ declare function interactiveTTY(): boolean;
119
+
120
+ declare const USAGE: string;
121
+ declare const MENU_ACTIONS: readonly [{
122
+ readonly value: "list";
123
+ readonly label: "List entries";
124
+ readonly hint: "type, label, ID — never a value";
125
+ }, {
126
+ readonly value: "get";
127
+ readonly label: "Copy a value";
128
+ readonly hint: "choose an entry, copies to the clipboard";
129
+ }, {
130
+ readonly value: "add";
131
+ readonly label: "Add an entry";
132
+ readonly hint: "interactive form per type";
133
+ }, {
134
+ readonly value: "status";
135
+ readonly label: "Status";
136
+ readonly hint: "account, vault, sync state";
137
+ }, {
138
+ readonly value: "sync";
139
+ readonly label: "Sync once";
140
+ readonly hint: "read the pointer, merge, publish";
141
+ }, {
142
+ readonly value: "pair";
143
+ readonly label: "Pair this terminal";
144
+ readonly hint: "scan a QR from the phone";
145
+ }, {
146
+ readonly value: "agent-mandate";
147
+ readonly label: "Mandate an agent";
148
+ readonly hint: "QR carries the request, the phone signs";
149
+ }, {
150
+ readonly value: "agent-list";
151
+ readonly label: "Agent mandates";
152
+ readonly hint: "entries, commands, domains, expiry";
153
+ }, {
154
+ readonly value: "quit";
155
+ readonly label: "Quit";
156
+ readonly hint: "leave without changing anything";
157
+ }];
158
+ type MenuAction = (typeof MENU_ACTIONS)[number]["value"];
159
+ interface CommandMenuOptions {
160
+ /** Injected prompt surface (tests). */
161
+ prompter?: Prompter;
162
+ /** Injected output (tests). */
163
+ io?: CliIO;
164
+ /**
165
+ * Injected action runner (tests). Defaults to the real one, which calls the
166
+ * same command functions as the CLI flags: the menu is a shell, not a second
167
+ * implementation.
168
+ */
169
+ runAction?: (action: MenuAction, prompter: Prompter) => Promise<number>;
170
+ }
171
+ /**
172
+ * Bare `vaultkeepr` on a TTY: brand banner, then an arrow-key command menu that
173
+ * keeps the session open — an action returns to the menu, only Quit (or
174
+ * Ctrl-C at any prompt) leaves. The loop is TTY-only: a command, a piped stdin
175
+ * or `--json` all stay single-shot.
176
+ */
177
+ declare function commandMenu(env: NodeJS.ProcessEnv, options?: CommandMenuOptions): Promise<number>;
178
+ interface ParsedArgs {
179
+ positional: string[];
180
+ flags: Set<string>;
181
+ values: Map<string, string>;
182
+ error?: string;
183
+ }
184
+ declare function parseArgs(argv: string[]): ParsedArgs;
185
+ interface MainOptions {
186
+ /**
187
+ * Called from the interactive menu session: prompts that are cancelled leave
188
+ * the whole session instead of failing the single action.
189
+ */
190
+ interactiveSession?: boolean;
191
+ }
192
+ declare function main(argv: string[], env?: NodeJS.ProcessEnv, options?: MainOptions): Promise<number>;
193
+
194
+ /** Directory holding the paired identity, the local vault and the sync state. */
195
+ declare const CONFIG_DIR_ENV = "VK_CONFIG_DIR";
196
+ /** Current directory name under `~/.config`. */
197
+ declare const CONFIG_DIR_NAME = "vaultkeepr";
198
+ /** Pre-rename directory name, migrated once at startup (see below). */
199
+ declare const LEGACY_CONFIG_DIR_NAME = "vaultkeeper";
200
+ interface VaultkeeprPaths {
201
+ dir: string;
202
+ identityPath: string;
203
+ vaultPath: string;
204
+ syncStatePath: string;
205
+ }
206
+ /**
207
+ * One-time migration of the pre-rename directory: when `~/.config/vaultkeeper`
208
+ * exists and `~/.config/vaultkeepr` does not, rename it (never copy). A live
209
+ * pairing must survive the rename; a failed rename keeps the legacy directory
210
+ * in use rather than silently starting from an empty one. Returns the
211
+ * directory to use. `legacyDir` is injectable for tests.
212
+ */
213
+ declare function migrateLegacyConfigDir(dir: string, legacyDir?: string): string;
214
+ /**
215
+ * Resolves `~/.config/vaultkeepr` (migrating the legacy directory once). The
216
+ * env override exists so tests (and a throw-away profile) never touch the real
217
+ * vault directory.
218
+ */
219
+ declare function vaultkeeprConfigDir(env?: NodeJS.ProcessEnv): string;
220
+ declare function configPaths(dir?: string): VaultkeeprPaths;
221
+ /** Creates the config directory with mode 700 (the identity file holds secrets). */
222
+ declare function ensurePrivateDir(dir: string): Promise<void>;
223
+
224
+ /**
225
+ * What the CLI needs to be a vault client: the vault password received from the
226
+ * phone (never typed in the terminal), the account secret key when the phone
227
+ * has one, and the sync parameters. Stored owner-only (600) in `identity.json`.
228
+ */
229
+ interface PairedIdentity {
230
+ version: 1;
231
+ /** Owner EOA the pointer, the proofs and the sync payload key are keyed on, lowercase. */
232
+ address: string;
233
+ authType: "password" | "passkey";
234
+ masterPassword: string;
235
+ secretKey?: string;
236
+ walletAddress?: string;
237
+ licenseKey?: string;
238
+ apiBase: string;
239
+ deviceName: string;
240
+ pairedAt: number;
241
+ }
242
+ interface VaultAccount {
243
+ address: string;
244
+ signMessage(input: {
245
+ message: string;
246
+ }): Promise<string>;
247
+ }
248
+ /**
249
+ * Turns the sealed `PairPayload` into the stored identity. The address is
250
+ * derived from the account key, never read from the payload: it is what the
251
+ * pointer and the sync payload are keyed on.
252
+ */
253
+ declare function identityFromPairPayload(payload: PairPayload, options: {
254
+ apiBase: string;
255
+ deviceName: string;
256
+ pairedAt?: number;
257
+ }): Promise<PairedIdentity>;
258
+ /** The signing account of a paired identity (proofs, pointer writes). */
259
+ declare function accountForIdentity(identity: PairedIdentity): Promise<VaultAccount>;
260
+ /**
261
+ * Key material sealing the sync payload and the local vault file: the secret
262
+ * key when the account has one, the password otherwise (same rule as
263
+ * `deriveSyncPayloadKey` in the extension and `ipfsSync.ts` on mobile).
264
+ */
265
+ declare function payloadKeyMaterial(identity: PairedIdentity): string;
266
+ declare function parseIdentity(json: string): PairedIdentity;
267
+ declare function saveIdentity(path: string, identity: PairedIdentity): Promise<void>;
268
+ /** Loads the paired identity, or null when this machine was never paired. */
269
+ declare function loadIdentity(path: string): Promise<PairedIdentity | null>;
270
+
271
+ interface SyncState {
272
+ version: 1;
273
+ address: string;
274
+ vaultCid: string | null;
275
+ lastKnownUpdatedAt: number;
276
+ lastPublishAt: number | null;
277
+ lastResolveAt: number | null;
278
+ lastError: string | null;
279
+ }
280
+ declare function emptySyncState(address: string): SyncState;
281
+ declare function loadSyncState(path: string, address: string): Promise<SyncState>;
282
+ declare function saveSyncState(path: string, state: SyncState): Promise<void>;
283
+ /**
284
+ * Network surface of the sync, kept behind an interface so the merge and the
285
+ * publish ordering are testable against a fixture instead of the live relay.
286
+ */
287
+ interface SyncTransport {
288
+ readPointerCid(address: string): Promise<string | null>;
289
+ fetchPayload(cid: string): Promise<string>;
290
+ uploadPayload(payloadStr: string, address: string): Promise<string>;
291
+ publishPointer(address: string, cid: string): Promise<boolean>;
292
+ }
293
+ interface SyncContext {
294
+ identity: PairedIdentity;
295
+ paths: VaultkeeprPaths;
296
+ transport: SyncTransport;
297
+ /** Signing account, injectable so merge/publish are testable without Argon2. */
298
+ account?: VaultAccount;
299
+ now?: () => number;
300
+ }
301
+ type PullStatus = "no-pointer" | "up-to-date" | "merged";
302
+ interface PullResult {
303
+ status: PullStatus;
304
+ remoteUpdatedAt?: number;
305
+ cid?: string;
306
+ }
307
+ /**
308
+ * Reads the remote pointer, then the payload, and merges it into the local
309
+ * vault with the same three-way merge the extension uses (`threeWayMerge` with
310
+ * the last shared state as base). Returns "up-to-date" without fetching when
311
+ * the pointer CID is the one already known.
312
+ */
313
+ declare function pullMerge(ctx: SyncContext): Promise<PullResult>;
314
+ interface PublishResult {
315
+ cid: string;
316
+ }
317
+ /**
318
+ * Seals the current vault, uploads it and repoints the account pointer. The
319
+ * pointer write is signed over the CID just published, as the server requires.
320
+ * Pull first (`pullMerge`): a push after a merge never drops a remote edit.
321
+ */
322
+ declare function publishVault(ctx: SyncContext, vault: Vault): Promise<PublishResult>;
323
+ interface SyncOnceResult {
324
+ pull: PullResult;
325
+ pushed: PublishResult | null;
326
+ }
327
+ /** One reconciliation pass: pull and merge, then publish local pending edits. */
328
+ declare function syncOnce(ctx: SyncContext, options?: {
329
+ publish?: boolean;
330
+ }): Promise<SyncOnceResult>;
331
+ interface RunSyncOptions {
332
+ intervalMs: number;
333
+ signal?: AbortSignal;
334
+ onEvent?: (line: string) => void;
335
+ maxIterations?: number;
336
+ }
337
+ /**
338
+ * Continuous peer loop: pull/merge then publish pending edits on every tick.
339
+ * The daemon is the CLI's continuous-sync mode; each command also reconciles
340
+ * once before acting, so a terminal session never works on a stale vault.
341
+ */
342
+ declare function runSyncLoop(ctx: SyncContext, options: RunSyncOptions): Promise<number>;
343
+
344
+ /** Same default as the extension's pair flow and the agent CLI. */
345
+ declare const DEFAULT_API_BASE = "https://app.vaultkeepr.xyz";
346
+ type FetchLike = (input: string, init?: {
347
+ method?: string;
348
+ headers?: Record<string, string>;
349
+ body?: string;
350
+ }) => Promise<{
351
+ ok: boolean;
352
+ status: number;
353
+ json(): Promise<unknown>;
354
+ }>;
355
+ interface PairSession {
356
+ sessionId: string;
357
+ expiresAt: number;
358
+ }
359
+ interface PairStatus {
360
+ completed: boolean;
361
+ expiresAt?: number;
362
+ sourcePublicKeyHex?: string;
363
+ encryptedPayload?: string;
364
+ }
365
+ interface PairTransport {
366
+ createSession(publicKeyHex: string, deviceName: string): Promise<PairSession>;
367
+ /** `null` means the session is gone (expired, consumed or unknown). */
368
+ pollStatus(sessionId: string): Promise<PairStatus | null>;
369
+ }
370
+ /** Thin client over the existing `/api/pair` relay, unchanged (mode receive). */
371
+ declare function createPairTransport(apiBase: string, fetchImpl: FetchLike): PairTransport;
372
+ /** Decrypts the sealed `PairPayload` with the private key of this session. */
373
+ declare function openPairPayload(status: PairStatus, keypair: PairKeypair): PairPayload;
374
+ declare function newPairKeypair(): PairKeypair;
375
+ declare function pairUri(sessionId: string, publicKeyHex: string): string;
376
+ /** Owner proof, same format as the extension (`background-src/proof.js`). */
377
+ declare function formatProofMessage(address: string, action: string, nowMs: number): string;
378
+ declare const CID_UPDATE_PREFIX = "VaultKeepR CID Update:";
379
+ interface HttpSyncTransportOptions {
380
+ apiBase: string;
381
+ account: VaultAccount;
382
+ fetchImpl: FetchLike;
383
+ now?: () => number;
384
+ }
385
+ /**
386
+ * Sync transport over the existing API: the account pointer (`/api/vault-cid`)
387
+ * and the managed IPFS upload (`/api/ipfs/upload`). No other endpoint, no new
388
+ * protocol. Every request carries a dated owner proof signed now with the
389
+ * account key, exactly as the clients do.
390
+ */
391
+ declare function createHttpSyncTransport({ apiBase, account, fetchImpl, now }: HttpSyncTransportOptions): SyncTransport;
392
+
393
+ interface PairCommandOptions {
394
+ apiBase?: string;
395
+ configDir?: string;
396
+ paths?: VaultkeeprPaths;
397
+ fetchImpl?: FetchLike;
398
+ io?: CliIO;
399
+ renderQr?: (uri: string) => Promise<string>;
400
+ pollIntervalMs?: number;
401
+ now?: () => number;
402
+ sleep?: (ms: number) => Promise<void>;
403
+ deviceName?: string;
404
+ /** Overrides the whole wait loop (tests): returns the completed status. */
405
+ awaitPayload?: (sessionId: string) => Promise<PairStatus>;
406
+ }
407
+ /**
408
+ * `vaultkeepr pair`: generates an ephemeral P256 pair, shows the `vk-pair://`
409
+ * URI as a large QR, waits for the phone to send the sealed vault, decrypts it
410
+ * and stores the identity (600) plus the local vault. No password is typed in
411
+ * the terminal: the phone sends it sealed to this session's key.
412
+ */
413
+ declare function runPair(options?: PairCommandOptions): Promise<number>;
414
+
415
+ /** Kinds the human client exposes. `passkey` is present but cannot be created here. */
416
+ declare const ENTRY_KINDS: readonly ["api", "login", "card", "identity", "note", "seed", "passkey"];
417
+ type EntryKind = (typeof ENTRY_KINDS)[number];
418
+ /**
419
+ * API key entry: the shape the phone emits for the "Clé API" item — one secret
420
+ * value in the password field (this is what the agent CLI injects), an optional
421
+ * service URL, an optional note, and NO username/password pair.
422
+ */
423
+ interface ApiEntry extends VaultEntry {
424
+ type: "api";
425
+ }
426
+ declare function isEntryKind(value: string): value is EntryKind;
427
+ declare function entryKind(entry: VaultEntry): EntryKind;
428
+ declare const KIND_LABELS: Record<EntryKind, string>;
429
+ declare function entryLabel(entry: VaultEntry): string;
430
+ /** The value the vault client reveals or copies: the account secret. */
431
+ declare function entrySecret(entry: VaultEntry): string;
432
+ declare function filterByKind(entries: VaultEntry[], kind?: EntryKind): VaultEntry[];
433
+ interface EntryMatch {
434
+ entry: VaultEntry;
435
+ kind: EntryKind;
436
+ }
437
+ /**
438
+ * Finds one entry by exact id, id prefix, or label/username substring. Two
439
+ * different entries matching the same query is an error, not a silent pick.
440
+ */
441
+ declare function findEntry(entries: VaultEntry[], query: string): EntryMatch;
442
+ interface FormField {
443
+ key: string;
444
+ label: string;
445
+ secret?: boolean;
446
+ optional?: boolean;
447
+ }
448
+ /**
449
+ * Interactive form per kind. The API key form is its own form (Justin's scope
450
+ * decision): label, value, optional service URL, optional note — never a
451
+ * username/password pair.
452
+ */
453
+ declare const FORM_FIELDS: Record<EntryKind, FormField[]>;
454
+ declare function buildEntry(kind: EntryKind, values: Record<string, string>, now?: number): VaultEntry;
455
+ /** Current values of an entry, shaped like the add form for its kind. */
456
+ declare function formValuesFromEntry(entry: VaultEntry): Record<string, string>;
457
+ /** Hint shown next to an edit prompt; never contains a secret value. */
458
+ declare function formHintForField(field: FormField, current: Record<string, string>): string;
459
+ /**
460
+ * Applies edited form values onto an existing entry: id, creation date and
461
+ * kind-specific structure are preserved, `modifiedAt` is bumped so the merge
462
+ * picks this side, and the card custom fields keep their other entries.
463
+ */
464
+ declare function updateEntryFromValues(existing: VaultEntry, values: Record<string, string>, now?: number): VaultEntry;
465
+
466
+ interface ClipboardCandidate {
467
+ bin: string;
468
+ args: string[];
469
+ }
470
+ interface ClipboardEnv {
471
+ platform?: NodeJS.Platform;
472
+ waylandDisplay?: string;
473
+ display?: string;
474
+ termux?: string;
475
+ }
476
+ /**
477
+ * Clipboard writers, most specific first: Wayland, X11, macOS, Termux. The
478
+ * value travels on stdin, never in argv (ps and shell history would see it).
479
+ */
480
+ declare function clipboardCandidates(env?: ClipboardEnv): ClipboardCandidate[];
481
+ type ClipboardRunner = (candidate: ClipboardCandidate, text: string) => Promise<boolean>;
482
+ interface CopyResult {
483
+ ok: boolean;
484
+ bin?: string;
485
+ }
486
+ /** Tries each writer in order; reports which one worked, never the value. */
487
+ declare function copyToClipboard(text: string, options?: {
488
+ candidates?: ClipboardCandidate[];
489
+ runner?: ClipboardRunner;
490
+ }): Promise<CopyResult>;
491
+
492
+ interface CommandOptions {
493
+ configDir?: string;
494
+ paths?: VaultkeeprPaths;
495
+ io?: CliIO;
496
+ fetchImpl?: FetchLike;
497
+ now?: () => number;
498
+ /** Injected transport (tests, mock e2e): skips the HTTP transport. */
499
+ transport?: SyncTransport;
500
+ askFn?: (question: string, options?: AskOptions) => Promise<string>;
501
+ /** Injected prompt surface (tests, non-TTY scripts). */
502
+ prompter?: Prompter;
503
+ copy?: (text: string) => Promise<CopyResult>;
504
+ /** Injected signing account (tests): avoids Argon2 in command tests. */
505
+ account?: VaultAccount;
506
+ colors?: boolean;
507
+ }
508
+ interface ListOptions extends CommandOptions {
509
+ kind?: string;
510
+ json?: boolean;
511
+ offline?: boolean;
512
+ }
513
+ declare function runList(options?: ListOptions): Promise<number>;
514
+ interface GetOptions extends CommandOptions {
515
+ query: string;
516
+ reveal?: boolean;
517
+ json?: boolean;
518
+ offline?: boolean;
519
+ }
520
+ declare function runGet(options: GetOptions): Promise<number>;
521
+ interface AddOptions extends CommandOptions {
522
+ kind: string;
523
+ fields?: Record<string, string>;
524
+ offline?: boolean;
525
+ /**
526
+ * Interactive session mode: a Ctrl-C at a form prompt means "leave the
527
+ * session", so the cancellation is re-thrown instead of becoming a failed
528
+ * `add` (exit 1). Single-shot `vaultkeepr add` keeps its current behaviour.
529
+ */
530
+ propagateCancel?: boolean;
531
+ }
532
+ /**
533
+ * `vaultkeepr add --kind <kind>`: interactive form for the human. Secret
534
+ * fields are only ever read from the prompt, never from argv.
535
+ */
536
+ declare function runAdd(options: AddOptions): Promise<number>;
537
+ interface EditOptions extends CommandOptions {
538
+ query: string;
539
+ /** Flags that skip the corresponding prompt (non-secret fields only). */
540
+ fields?: Record<string, string>;
541
+ offline?: boolean;
542
+ }
543
+ /**
544
+ * `vaultkeepr edit <entry>`: same per-kind form as `add`, pre-filled from the
545
+ * current entry. Enter keeps the current value; a lone `-` clears an optional
546
+ * field. Secret values are never echoed, only "kept" is shown.
547
+ * Sync-published like `add`.
548
+ */
549
+ declare function runEdit(options: EditOptions): Promise<number>;
550
+ interface DeleteOptions extends CommandOptions {
551
+ query: string;
552
+ offline?: boolean;
553
+ /** Skips the confirmation prompt (prompt-free scripted use). */
554
+ yes?: boolean;
555
+ confirmFn?: (question: string) => Promise<string>;
556
+ }
557
+ /**
558
+ * `vaultkeepr delete <entry>`: confirmation shows label, kind and id only —
559
+ * never the value — then removes the entry and publishes a tombstone so the
560
+ * deletion propagates on the next merge instead of resurrecting the entry.
561
+ */
562
+ declare function runDelete(options: DeleteOptions): Promise<number>;
563
+ interface StatusOptions extends CommandOptions {
564
+ json?: boolean;
565
+ offline?: boolean;
566
+ }
567
+ interface AgentMenuEntry {
568
+ id: string;
569
+ label: string;
570
+ kind: EntryKind;
571
+ url?: string;
572
+ }
573
+ /**
574
+ * Lists the entries the interactive menu may offer to delegate. Read-only and
575
+ * deliberately the same path as `agent mandate` (paired session + local vault +
576
+ * `sortEntries`): a passkey can never be handed to an agent, so it is excluded
577
+ * here exactly as the command refuses it.
578
+ */
579
+ declare function listDelegatableEntries(options?: CommandOptions & {
580
+ offline?: boolean;
581
+ }): Promise<AgentMenuEntry[]>;
582
+ interface AgentMandateOptions extends CommandOptions {
583
+ /** Repeatable `--entry`, resolved like `get` (id, id prefix, label, url). */
584
+ entries: string[];
585
+ /** `--bin`: binary each requested entry may be handed to. */
586
+ bin: string;
587
+ ttlDays?: number;
588
+ /** `--prefixes`: comma-separated URL prefixes applied to every entry. */
589
+ prefixes?: string;
590
+ /** Base of the pair API; defaults to the paired identity's API base. */
591
+ apiBase?: string;
592
+ offline?: boolean;
593
+ env?: NodeJS.ProcessEnv;
594
+ /** Injected spawn for tests: receives the candidate binaries and argv. */
595
+ spawn?: (candidates: string[], argv: string[], env?: NodeJS.ProcessEnv) => Promise<number | null>;
596
+ /** Injected temp dir parent for tests. */
597
+ tempRoot?: string;
598
+ }
599
+ /**
600
+ * `vaultkeepr agent mandate`: builds the requested mandate spec from the local
601
+ * vault, then hands the QR/wait loop to `vaultkeepr-agent mandate` with the
602
+ * request attached to the pair session. The phone stays the only signer: this
603
+ * command never seals a mandate, it only asks for one.
604
+ */
605
+ declare function runAgentMandate(options: AgentMandateOptions): Promise<number>;
606
+ declare function runStatus(options?: StatusOptions): Promise<number>;
607
+ interface SyncOptions extends CommandOptions {
608
+ intervalSeconds?: number;
609
+ once?: boolean;
610
+ maxIterations?: number;
611
+ }
612
+ declare function runSync(options?: SyncOptions): Promise<number>;
613
+ /** Static completions: commands, kinds, entry titles from the local vault. */
614
+ declare function completionScript(shell: "bash" | "zsh"): string;
615
+ interface CompletionsOptions extends CommandOptions {
616
+ shell: string;
617
+ }
618
+ declare function runCompletions(options: CompletionsOptions): Promise<number>;
619
+
620
+ /**
621
+ * `vaultkeepr agent <sous-commande>`: single entry point of the agent family.
622
+ *
623
+ * The models stay separated (README): the vault client (human) delegates to
624
+ * the agent binaries instead of reimplementing them. `mandate` is the one
625
+ * exception handled in-process, because it needs the vault to resolve entries;
626
+ * it still hands the QR/wait loop to `vaultkeepr-agent mandate`.
627
+ */
628
+ interface AgentIO {
629
+ out(text: string): void;
630
+ err(text: string): void;
631
+ }
632
+ declare const AGENT_SUBCOMMANDS: readonly ["init", "list", "run", "http", "mandate"];
633
+ type AgentSubcommand = (typeof AGENT_SUBCOMMANDS)[number];
634
+ interface AgentBinaries {
635
+ agent: string;
636
+ http: string;
637
+ }
638
+ declare function resolveAgentBinaries(env?: NodeJS.ProcessEnv): AgentBinaries;
639
+ declare function agentBinaryCandidates(env?: NodeJS.ProcessEnv, kind?: "agent" | "http"): string[];
640
+ /** Spawned child exit code, or null when no candidate binary exists at all. */
641
+ declare function spawnAgentBinary(candidates: string[], argv: string[], env?: NodeJS.ProcessEnv): Promise<number | null>;
642
+ interface AgentDispatchOptions {
643
+ /** Arguments after `vaultkeepr agent`, subcommand first. */
644
+ argv: string[];
645
+ io: AgentIO;
646
+ env?: NodeJS.ProcessEnv;
647
+ }
648
+ /**
649
+ * Delegates `init|list|run|http` to the agent binaries. `mandate` is refused
650
+ * here: the vault client handles it (it needs the vault) and then delegates
651
+ * the QR/wait loop to `vaultkeepr-agent mandate`.
652
+ */
653
+ declare function runAgentDispatch(options: AgentDispatchOptions): Promise<number>;
654
+ declare function agentUsage(): string;
655
+
656
+ interface StoredVault {
657
+ vault: Vault;
658
+ base: Vault | null;
659
+ savedAt: number;
660
+ }
661
+ declare function emptyVault(now?: number): Vault;
662
+ /**
663
+ * Seals the local vault at rest with the same key material as the sync
664
+ * payload. The file sits next to the identity and is never the only copy of
665
+ * the vault: the remote payload and the phone remain the sources of truth.
666
+ */
667
+ declare function saveLocalVault(path: string, identity: PairedIdentity, stored: {
668
+ vault: Vault;
669
+ base: Vault | null;
670
+ }, now?: number): Promise<void>;
671
+ /** Loads the local vault; null when this machine has none yet (just paired). */
672
+ declare function loadLocalVault(path: string, identity: PairedIdentity): Promise<StoredVault | null>;
673
+
674
+ /**
675
+ * Writes the non-secret projection of the local vault next to `vault.json`
676
+ * (see `@vaultkeepr/core`'s `agent-vault-summary`). The scoped agent CLI
677
+ * consumes it to warn when a mandate's sealed snapshot no longer matches the
678
+ * synced vault; the sealed vault itself stays out of the agent's reach.
679
+ *
680
+ * It carries ids, labels, service URLs and edit timestamps only — never a
681
+ * password, a note or a TOTP secret.
682
+ */
683
+ declare const VAULT_SUMMARY_FILENAME = "vault-summary.json";
684
+ declare function vaultSummaryPath(dir: string): string;
685
+ /** Builds the summary of a vault as of `savedAt`. */
686
+ declare function buildVaultSummary(vault: Vault, savedAt?: number): AgentVaultSummary;
687
+ /** Writes the derived summary, owner-only, next to the sealed vault file. */
688
+ declare function writeVaultSummary(dir: string, vault: Vault, savedAt?: number): Promise<void>;
689
+
690
+ /** Key sealing one payload: Argon2id(key material, salt), the clients' rule. */
691
+ declare function derivePayloadKey(keyMaterial: string, salt: Uint8Array): Promise<Uint8Array>;
692
+ /** Seals the vault as the wire envelope every client expects. */
693
+ declare function sealVaultPayload(vault: Vault, keyMaterial: string, now?: number): Promise<string>;
694
+ interface OpenedPayload {
695
+ vault: Vault;
696
+ updatedAt: number;
697
+ format: "legacy" | "crdt";
698
+ keyLabel: string;
699
+ }
700
+ /**
701
+ * Opens a remote payload. The candidate walk mirrors the extension: the
702
+ * password first, then the account secret key, then the legacy V3
703
+ * password+signature derivation. A wrong candidate never stops the list.
704
+ */
705
+ declare function openVaultPayload(raw: string, identity: PairedIdentity, options?: {
706
+ account?: VaultAccount;
707
+ now?: number;
708
+ }): Promise<OpenedPayload>;
709
+
710
+ declare const QR_QUIET_ZONE = 2;
711
+ interface QrRenderOptions {
712
+ /** ANSI colours force the polarity, so the code stays scannable on any theme. */
713
+ color?: boolean;
714
+ quietZone?: number;
715
+ }
716
+ /**
717
+ * Renders a QR code for the terminal: one character per module wide, two modules
718
+ * per line via half blocks (roughly square cells), quiet zone included. With
719
+ * `color`, the block is wrapped in black-on-white so an inverted terminal theme
720
+ * cannot flip the code.
721
+ */
722
+ declare function renderQr(text: string, options?: QrRenderOptions): string;
723
+ /** Command-facing wrapper: pairing code resolves the render through this. */
724
+ declare function renderTerminalQr(text: string): Promise<string>;
725
+
726
+ /**
727
+ * Brand banner for the terminal client.
728
+ *
729
+ * The wordmark IS the logo: a figlet **"doh"** rendering of `vaultkeepr`,
730
+ * baked below as a string constant (generated once with pyfiglet —
731
+ * `python3 -c "import pyfiglet; print(pyfiglet.figlet_format('vaultkeepr', font='doh', width=200))"`
732
+ * — no figlet dependency at runtime, no image dependency). The thin figlet
733
+ * "standard" font it replaced was not recognisable as the logo.
734
+ *
735
+ * The banner is responsive: a four-step size ladder picks the largest
736
+ * wordmark that fits the terminal width (see {@link BANNER_TIERS}). Scaling
737
+ * only ever swaps the whole wordmark for a smaller one — glyphs are never
738
+ * wrapped or truncated mid-stroke.
739
+ *
740
+ * Colour is optional: with `colors: false` (piped stdout, NO_COLOR, TERM=dumb)
741
+ * the banner carries no ANSI at all (the mid tier uses Unicode block glyphs,
742
+ * all other tiers are pure ASCII). `--json` output never contains the banner
743
+ * nor ANSI — callers must not render it on that path.
744
+ */
745
+ type RGB = [number, number, number];
746
+ /** House accent `#e55757` (crimson-coral), as used across the web app. */
747
+ declare const ACCENT_CORAL: RGB;
748
+ /**
749
+ * figlet "doh" font, `pyfiglet.figlet_format("vaultkeepr", font="doh", width=200)`,
750
+ * blank rows dropped, trailing blanks stripped: 22 rows, 184 columns.
751
+ * Regenerate the same way if the letterforms must change; the tests pin these
752
+ * exact rows.
753
+ */
754
+ declare const WORDMARK: readonly string[];
755
+ /** Widest wordmark row in columns (the gradient is mapped against it). */
756
+ declare const WORDMARK_WIDTH: number;
757
+ /** Narrowest terminal still showing the full "doh" wordmark. */
758
+ declare const MIN_FULL_BANNER_COLUMNS = 190;
759
+ /** Official slogan — verbatim from apps/web/src/lib/branding.ts (APP_SLOGAN). */
760
+ declare const APP_SLOGAN = "The password manager that doesn't ask you to trust it.";
761
+ interface BannerOptions {
762
+ version: string;
763
+ /** ANSI colour; false when piped, NO_COLOR or TERM=dumb. */
764
+ colors: boolean;
765
+ /** Terminal width in columns; undefined = resolve from COLUMNS, else assume wide. */
766
+ columns?: number;
767
+ }
768
+ /**
769
+ * Compact one-line brand header (`vaultkeepr · v0.2.0`): the narrow-terminal
770
+ * fallback of the banner, and the body of the status mini-header.
771
+ */
772
+ declare function renderCompactHeader(options: BannerOptions): string;
773
+ /**
774
+ * Full banner: the largest wordmark fitting the terminal width, then the
775
+ * official slogan + version on the line below it. Falls back to the compact
776
+ * one-line header below {@link MIN_SMALL_BANNER_COLUMNS}.
777
+ */
778
+ declare function renderBanner(options: BannerOptions): string;
779
+ /**
780
+ * Compact one-line header for `status`: small mark + wordmark + version.
781
+ * Same plain-ASCII rule when colour is disabled.
782
+ */
783
+ declare function renderMiniHeader(options: BannerOptions): string;
784
+
785
+ /** Display helpers. Every identifier shown leaves its middle out. */
786
+ declare function redactAddress(address: string): string;
787
+ declare function redactCid(cid: string | null | undefined): string;
788
+ /** "12s ago", "3m ago", "2h ago", then a date. */
789
+ declare function formatWhen(ms: number | null | undefined, now?: number): string;
790
+ declare function formatDate(ms: number | null | undefined): string;
791
+
792
+ declare const VERSION: string;
793
+
794
+ export { ACCENT_CORAL, AGENT_SUBCOMMANDS, APP_SLOGAN, type AddOptions, type AgentBinaries, type AgentDispatchOptions, type AgentMandateOptions, type AgentMenuEntry, type AgentSubcommand, type ApiEntry, type AskOptions, CID_UPDATE_PREFIX, CONFIG_DIR_ENV, CONFIG_DIR_NAME, type CliIO, type ClipboardCandidate, type ClipboardRunner, type CommandMenuOptions, type CommandOptions, type CopyResult, DEFAULT_API_BASE, type DeleteOptions, ENTRY_KINDS, type EditOptions, type EntryKind, FORM_FIELDS, type FetchLike, type FormField, type GetOptions, KIND_LABELS, LEGACY_CONFIG_DIR_NAME, type ListOptions, MENU_ACTIONS, MIN_FULL_BANNER_COLUMNS, type MainOptions, type MenuAction, type PairCommandOptions, type PairSession, type PairStatus, type PairTransport, type PairedIdentity, type Palette, PromptCancelledError, type PromptChoice, type PromptSpinner, type Prompter, type PublishResult, type PullResult, QR_QUIET_ZONE, Spinner, type StatusOptions, type StoredVault, type SyncContext, type SyncOptions, type SyncState, type SyncTransport, USAGE, VAULT_SUMMARY_FILENAME, VERSION, type VaultAccount, type VaultkeeprPaths, WORDMARK, WORDMARK_WIDTH, accountForIdentity, agentBinaryCandidates, agentUsage, ask, buildEntry, buildVaultSummary, clackPrompter, clipboardCandidates, colorEnabled, commandMenu, completionScript, configPaths, copyToClipboard, createHttpSyncTransport, createPairTransport, defaultIO, derivePayloadKey, emptySyncState, emptyVault, ensurePrivateDir, entryKind, entryLabel, entrySecret, filterByKind, findEntry, formHintForField, formValuesFromEntry, formatDate, formatProofMessage, formatTable, formatWhen, identityFromPairPayload, interactiveTTY, isEntryKind, listDelegatableEntries, loadIdentity, loadLocalVault, loadSyncState, main, migrateLegacyConfigDir, newPairKeypair, openPairPayload, openVaultPayload, pairUri, palette, parseArgs, parseIdentity, payloadKeyMaterial, plainPrompter, publishVault, pullMerge, redactAddress, redactCid, renderBanner, renderCompactHeader, renderMiniHeader, renderQr, renderTerminalQr, resolveAgentBinaries, runAdd, runAgentDispatch, runAgentMandate, runCompletions, runDelete, runEdit, runGet, runList, runPair, runStatus, runSync, runSyncLoop, saveIdentity, saveLocalVault, saveSyncState, sealVaultPayload, spawnAgentBinary, syncOnce, updateEntryFromValues, vaultSummaryPath, vaultkeeprConfigDir, writeVaultSummary };