@qodalis/cli-core 0.0.15 → 2.0.0-beta.1

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 (51) hide show
  1. package/README.md +399 -31
  2. package/package.json +16 -23
  3. package/public-api.d.mts +2322 -0
  4. package/public-api.d.ts +2322 -8
  5. package/public-api.js +3597 -0
  6. package/public-api.js.map +1 -0
  7. package/public-api.mjs +3545 -0
  8. package/public-api.mjs.map +1 -0
  9. package/esm2022/lib/constants/index.mjs +0 -8
  10. package/esm2022/lib/interfaces/command-hooks.mjs +0 -2
  11. package/esm2022/lib/interfaces/command-processor.mjs +0 -2
  12. package/esm2022/lib/interfaces/execution-context.mjs +0 -2
  13. package/esm2022/lib/interfaces/index.mjs +0 -6
  14. package/esm2022/lib/interfaces/progress-bars.mjs +0 -2
  15. package/esm2022/lib/interfaces/users.mjs +0 -2
  16. package/esm2022/lib/models/index.mjs +0 -175
  17. package/esm2022/lib/models/services.mjs +0 -2
  18. package/esm2022/lib/models/users.mjs +0 -2
  19. package/esm2022/lib/modules/index.mjs +0 -30
  20. package/esm2022/lib/themes/index.mjs +0 -221
  21. package/esm2022/lib/types/CancellablePromise.mjs +0 -28
  22. package/esm2022/lib/types/index.mjs +0 -2
  23. package/esm2022/lib/utils/delay.mjs +0 -4
  24. package/esm2022/lib/utils/index.mjs +0 -80
  25. package/esm2022/lib/utils/object-describer.mjs +0 -134
  26. package/esm2022/lib/utils/terminal-utils.mjs +0 -16
  27. package/esm2022/lib/version.mjs +0 -3
  28. package/esm2022/public-api.mjs +0 -12
  29. package/esm2022/qodalis-cli-core.mjs +0 -5
  30. package/fesm2022/qodalis-cli-core.mjs +0 -697
  31. package/fesm2022/qodalis-cli-core.mjs.map +0 -1
  32. package/index.d.ts +0 -5
  33. package/lib/constants/index.d.ts +0 -5
  34. package/lib/interfaces/command-hooks.d.ts +0 -5
  35. package/lib/interfaces/command-processor.d.ts +0 -151
  36. package/lib/interfaces/execution-context.d.ts +0 -109
  37. package/lib/interfaces/index.d.ts +0 -349
  38. package/lib/interfaces/progress-bars.d.ts +0 -72
  39. package/lib/interfaces/users.d.ts +0 -42
  40. package/lib/models/index.d.ts +0 -293
  41. package/lib/models/services.d.ts +0 -20
  42. package/lib/models/users.d.ts +0 -30
  43. package/lib/modules/index.d.ts +0 -6
  44. package/lib/themes/index.d.ts +0 -16
  45. package/lib/types/CancellablePromise.d.ts +0 -8
  46. package/lib/types/index.d.ts +0 -1
  47. package/lib/utils/delay.d.ts +0 -1
  48. package/lib/utils/index.d.ts +0 -24
  49. package/lib/utils/object-describer.d.ts +0 -12
  50. package/lib/utils/terminal-utils.d.ts +0 -7
  51. package/lib/version.d.ts +0 -1
package/public-api.d.ts CHANGED
@@ -1,8 +1,2322 @@
1
- export * from './lib/models';
2
- export * from './lib/interfaces';
3
- export * from './lib/modules';
4
- export * from './lib/utils';
5
- export * from './lib/constants';
6
- export * from './lib/types';
7
- export * from './lib/themes';
8
- export * from './lib/version';
1
+ import { ITerminalOptions, ITerminalInitOnlyOptions, Terminal, ITheme } from '@xterm/xterm';
2
+ import { Subject, Observable, Subscription } from 'rxjs';
3
+
4
+ type MultiServices = {
5
+ /**
6
+ * When true, injector returns an array of instances. This is useful to allow multiple
7
+ * providers spread across many files to provide configuration information to a common token.
8
+ */
9
+ multi?: boolean;
10
+ };
11
+ type CliValueProvider = MultiServices & {
12
+ useValue: any;
13
+ };
14
+ type CliTypeProvider = MultiServices & {
15
+ useClass: any;
16
+ };
17
+ type CliFactoryProvider = MultiServices & {
18
+ useFactory: Function;
19
+ };
20
+ type CliProvider = {
21
+ provide: any;
22
+ } & (CliValueProvider | CliTypeProvider | CliFactoryProvider) & Record<string, any>;
23
+
24
+ /**
25
+ * Represents a user in the CLI
26
+ */
27
+ interface ICliUser {
28
+ /** Unique user identifier */
29
+ id: string;
30
+ /** Login name (unique) */
31
+ name: string;
32
+ /** Email address (unique) */
33
+ email: string;
34
+ /** Group IDs this user belongs to */
35
+ groups: string[];
36
+ /** Virtual home directory path, e.g. /home/root */
37
+ homeDir?: string;
38
+ /** Account creation timestamp */
39
+ createdAt: number;
40
+ /** Last modification timestamp */
41
+ updatedAt: number;
42
+ /** Whether the account is locked */
43
+ disabled?: boolean;
44
+ }
45
+ /**
46
+ * Represents user credentials (shadow pattern — stored separately from ICliUser)
47
+ */
48
+ interface ICliUserCredentials {
49
+ /** The user ID this credential belongs to */
50
+ userId: string;
51
+ /** SHA-256 hash of salt + password */
52
+ passwordHash: string;
53
+ /** Random salt for this user */
54
+ salt: string;
55
+ /** Timestamp of last password change */
56
+ lastChanged: number;
57
+ }
58
+ /**
59
+ * Represents a group in the CLI
60
+ */
61
+ interface ICliGroup {
62
+ /** Unique group identifier */
63
+ id: string;
64
+ /** Group name (unique) */
65
+ name: string;
66
+ /** Optional group description */
67
+ description?: string;
68
+ /** Group creation timestamp */
69
+ createdAt: number;
70
+ }
71
+ /**
72
+ * Represents an active user session
73
+ */
74
+ interface ICliUserSession {
75
+ /** The user associated with this session */
76
+ user: ICliUser;
77
+ /** Pre-computed display name for the prompt (set by users module) */
78
+ displayName?: string;
79
+ /** Timestamp when the session started */
80
+ loginTime: number;
81
+ /** Timestamp of last activity */
82
+ lastActivity: number;
83
+ /** Extensible data (tokens, metadata, etc.) */
84
+ data?: Record<string, any>;
85
+ }
86
+ /** Fields required to create a new user */
87
+ type CliAddUser = Omit<ICliUser, 'id' | 'createdAt' | 'updatedAt'>;
88
+ /** Fields that can be updated on a user */
89
+ type CliUpdateUser = Partial<Omit<ICliUser, 'id' | 'createdAt'>>;
90
+
91
+ /** Ownership metadata attached to files, directories, or other resources */
92
+ interface ICliOwnership {
93
+ /** User ID of the owner */
94
+ uid: string;
95
+ /** Primary group name */
96
+ gid: string;
97
+ }
98
+ /** Default file permissions: rw-r--r-- (644) */
99
+ declare const DEFAULT_FILE_PERMISSIONS = "rw-r--r--";
100
+ /** Default directory permissions: rwxr-xr-x (755) */
101
+ declare const DEFAULT_DIR_PERMISSIONS = "rwxr-xr-x";
102
+
103
+ type CliProcessCommand = {
104
+ /**
105
+ * The command that was entered
106
+ */
107
+ command: string;
108
+ /**
109
+ * The data that was entered
110
+ */
111
+ data?: any;
112
+ /**
113
+ * The chain of commands that were entered
114
+ */
115
+ chainCommands: string[];
116
+ /**
117
+ * The raw command that was entered
118
+ */
119
+ rawCommand: string;
120
+ /**
121
+ * The value of the command
122
+ */
123
+ value?: string;
124
+ /**
125
+ * The arguments that were entered
126
+ */
127
+ args: Record<string, any>;
128
+ };
129
+ declare enum CliForegroundColor {
130
+ Black = "\u001B[30m",
131
+ Red = "\u001B[31m",
132
+ Green = "\u001B[32m",
133
+ Yellow = "\u001B[33m",
134
+ Blue = "\u001B[34m",
135
+ Magenta = "\u001B[35m",
136
+ Cyan = "\u001B[36m",
137
+ White = "\u001B[37m",
138
+ Reset = "\u001B[0m"
139
+ }
140
+ declare enum CliBackgroundColor {
141
+ Black = "\u001B[40m",
142
+ Red = "\u001B[41m",
143
+ Green = "\u001B[42m",
144
+ Yellow = "\u001B[43m",
145
+ Blue = "\u001B[44m",
146
+ Magenta = "\u001B[45m",
147
+ Cyan = "\u001B[46m",
148
+ White = "\u001B[47m"
149
+ }
150
+ declare enum CliIcon {
151
+ CheckIcon = "\u2714",
152
+ CrossIcon = "\u2718",
153
+ InfoIcon = "\u2139",
154
+ WarningIcon = "\u26A0",
155
+ QuestionMark = "?",
156
+ Exclamation = "\u2757",
157
+ Ellipsis = "\u2026",
158
+ Dot = "\u2022",
159
+ Bullet = "\u2023",
160
+ ArrowRight = "\u2192",
161
+ ArrowLeft = "\u2190",
162
+ ArrowUp = "\u2191",
163
+ ArrowDown = "\u2193",
164
+ ArrowRightFilled = "\u25B6",
165
+ ArrowLeftFilled = "\u25C0",
166
+ ArrowUpFilled = "\u25B2",
167
+ ArrowDownFilled = "\u25BC",
168
+ DoubleArrowRight = "\u00BB",
169
+ DoubleArrowLeft = "\u00AB",
170
+ Star = "\u2605",
171
+ StarEmpty = "\u2606",
172
+ Plus = "+",
173
+ Minus = "-",
174
+ Progress = "\u23F3",
175
+ Success = "\u2705",
176
+ Failure = "\u274C",
177
+ Clock = "\u23F0",
178
+ Timer = "\u23F1",
179
+ Alarm = "\uD83D\uDD14",
180
+ Calendar = "\uD83D\uDCC5",
181
+ Folder = "\uD83D\uDCC1",
182
+ FolderOpen = "\uD83D\uDCC2",
183
+ File = "\uD83D\uDCC4",
184
+ Archive = "\uD83D\uDDC3",
185
+ Link = "\uD83D\uDD17",
186
+ Chain = "\u26D3",
187
+ Bookmark = "\uD83D\uDD16",
188
+ Edit = "\u270F",
189
+ Trash = "\uD83D\uDDD1",
190
+ Add = "\u2795",
191
+ Remove = "\u2796",
192
+ Reload = "\uD83D\uDD04",
193
+ Save = "\uD83D\uDCBE",
194
+ Undo = "\u21A9",
195
+ Redo = "\u21AA",
196
+ Play = "\u25B6",
197
+ Pause = "\u23F8",
198
+ Stop = "\u23F9",
199
+ Cancel = "\u274E",
200
+ User = "\uD83D\uDC64",
201
+ Group = "\uD83D\uDC65",
202
+ Lock = "\uD83D\uDD12",
203
+ Unlock = "\uD83D\uDD13",
204
+ Help = "\u2753",
205
+ Key = "\uD83D\uDD11",
206
+ Shield = "\uD83D\uDEE1",
207
+ Gear = "\u2699",
208
+ Settings = "\u2699\uFE0F",
209
+ Theme = "\uD83C\uDFA8",
210
+ Light = "\uD83D\uDCA1",
211
+ Bug = "\uD83D\uDC1E",
212
+ Wrench = "\uD83D\uDD27",
213
+ Hammer = "\uD83D\uDD28",
214
+ Terminal = "\uD83D\uDCBB",
215
+ Database = "\uD83D\uDDC4",
216
+ Server = "\uD83D\uDDA5",
217
+ Cloud = "\u2601",
218
+ Network = "\uD83C\uDF10",
219
+ Monitor = "\uD83D\uDDA5",
220
+ Printer = "\uD83D\uDDA8",
221
+ USB = "\uD83D\uDD0C",
222
+ Speaker = "\uD83D\uDD0A",
223
+ Microphone = "\uD83C\uDF99",
224
+ Camera = "\uD83D\uDCF7",
225
+ Video = "\uD83C\uDFA5",
226
+ Music = "\uD83C\uDFB5",
227
+ Phone = "\uD83D\uDCDE",
228
+ Package = "\uD83D\uDCE6",
229
+ Plugin = "\uD83D\uDD0C",
230
+ Extension = "\uD83E\uDDE9",
231
+ Module = "\uD83D\uDCE6",
232
+ Evaluate = "\uD83D\uDD0D",
233
+ Variable = "\uD83D\uDD27",
234
+ Script = "\uD83D\uDCDC",
235
+ Code = "\uD83D\uDCBE",
236
+ Logs = "\uD83D\uDCDC",
237
+ Power = "\u23FB",
238
+ Heart = "\u2764",
239
+ Flame = "\uD83D\uDD25",
240
+ Growth = "\uD83D\uDCC8",
241
+ Decline = "\uD83D\uDCC9",
242
+ WarningFilled = "\u26A0\uFE0F",
243
+ Sun = "\u2600",
244
+ Moon = "\uD83C\uDF19",
245
+ Rain = "\uD83C\uDF27",
246
+ Snow = "\u2744",
247
+ Lightning = "\u26A1",
248
+ Tree = "\uD83C\uDF32",
249
+ Smile = "\uD83D\uDE0A",
250
+ Sad = "\uD83D\uDE22",
251
+ Angry = "\uD83D\uDE21",
252
+ Clap = "\uD83D\uDC4F",
253
+ ThumbsUp = "\uD83D\uDC4D",
254
+ ThumbsDown = "\uD83D\uDC4E",
255
+ Rocket = "\uD83D\uDE80",
256
+ Globe = "\uD83C\uDF0D",
257
+ Medal = "\uD83C\uDFC5",
258
+ Trophy = "\uD83C\uDFC6",
259
+ Flag = "\uD83D\uDEA9",
260
+ StarFilled = "\u2B50",
261
+ StarOutline = "\u2729",
262
+ Fireworks = "\uD83C\uDF86",
263
+ Balloon = "\uD83C\uDF88",
264
+ Gift = "\uD83C\uDF81"
265
+ }
266
+ /**
267
+ * Represents a package source for the CLI package manager
268
+ */
269
+ interface CliPackageSource {
270
+ /**
271
+ * The name of the source, e.g. 'local', 'unpkg', 'jsdelivr'
272
+ */
273
+ name: string;
274
+ /**
275
+ * The base URL for fetching package files, e.g. 'http://localhost:3000/'
276
+ */
277
+ url: string;
278
+ /**
279
+ * The kind of source.
280
+ * - 'registry': npm-compatible registry with search API (e.g. npmjs.org, Verdaccio)
281
+ * - 'file': static file server, packages are discovered by probing known paths
282
+ * @default 'file'
283
+ */
284
+ kind?: 'registry' | 'file';
285
+ }
286
+ /**
287
+ * Options for the CLI
288
+ */
289
+ type CliOptions = Record<string, any> & {
290
+ /**
291
+ * Custom terminal options
292
+ */
293
+ terminalOptions?: ITerminalOptions & ITerminalInitOnlyOptions;
294
+ /**
295
+ * The minimum log level to display
296
+ */
297
+ logLevel?: CliLogLevel;
298
+ /**
299
+ * Custom package sources for the package manager.
300
+ * Built-in sources (unpkg, jsdelivr) are always available.
301
+ */
302
+ packageSources?: {
303
+ /**
304
+ * Name of the primary source. Defaults to 'unpkg'.
305
+ */
306
+ primary?: string;
307
+ /**
308
+ * Additional custom sources
309
+ */
310
+ sources?: CliPackageSource[];
311
+ };
312
+ /**
313
+ * Remote CLI servers to connect to.
314
+ * Commands from each server are discovered and registered as proxy processors.
315
+ */
316
+ servers?: CliServerConfig[];
317
+ };
318
+ /**
319
+ * Configuration for a remote CLI server
320
+ */
321
+ type CliServerConfig = {
322
+ /** Unique identifier, used for namespacing commands */
323
+ name: string;
324
+ /** Base URL of the server, e.g. "https://api.example.com" */
325
+ url: string;
326
+ /** Whether this server is enabled. @default true */
327
+ enabled?: boolean;
328
+ /** Custom headers sent with every request (e.g. auth tokens) */
329
+ headers?: Record<string, string>;
330
+ /** Request timeout in milliseconds. @default 30000 */
331
+ timeout?: number;
332
+ };
333
+ /**
334
+ * A single output item in a server response
335
+ */
336
+ type CliServerOutput = {
337
+ type: 'text';
338
+ value: string;
339
+ style?: 'success' | 'error' | 'info' | 'warning';
340
+ } | {
341
+ type: 'table';
342
+ headers: string[];
343
+ rows: string[][];
344
+ } | {
345
+ type: 'list';
346
+ items: string[];
347
+ ordered?: boolean;
348
+ } | {
349
+ type: 'json';
350
+ value: any;
351
+ } | {
352
+ type: 'key-value';
353
+ entries: {
354
+ key: string;
355
+ value: string;
356
+ }[];
357
+ };
358
+ /**
359
+ * Structured response from a server command execution
360
+ */
361
+ type CliServerResponse = {
362
+ exitCode: number;
363
+ outputs: CliServerOutput[];
364
+ };
365
+ /**
366
+ * Metadata about a remote command processor, returned by GET /api/cli/commands
367
+ */
368
+ type CliServerCommandDescriptor = {
369
+ command: string;
370
+ description?: string;
371
+ version?: string;
372
+ parameters?: {
373
+ name: string;
374
+ aliases?: string[];
375
+ description: string;
376
+ required: boolean;
377
+ type: string;
378
+ defaultValue?: any;
379
+ }[];
380
+ processors?: CliServerCommandDescriptor[];
381
+ };
382
+ /**
383
+ * Server capabilities returned by GET /api/cli/capabilities
384
+ */
385
+ type CliServerCapabilities = {
386
+ /** Whether this server supports remote shell access */
387
+ shell: boolean;
388
+ /** Server operating system (e.g. "linux", "win32", "darwin") */
389
+ os?: string;
390
+ /** Path to the shell binary on the server */
391
+ shellPath?: string;
392
+ /** Server version string */
393
+ version?: string;
394
+ };
395
+ /**
396
+ * Represents a package that can be installed
397
+ */
398
+ interface Package {
399
+ /**
400
+ * The name of the package
401
+ */
402
+ name: string;
403
+ /**
404
+ * The global name used to access the package
405
+ */
406
+ globalName?: string;
407
+ /**
408
+ * The version of the package
409
+ */
410
+ version: string;
411
+ /**
412
+ * The unpkg url to the package
413
+ */
414
+ url: string;
415
+ /**
416
+ * The dependencies for the module
417
+ */
418
+ dependencies?: Package[];
419
+ }
420
+ /**
421
+ * Represents command processor metadata
422
+ */
423
+ type CliProcessorMetadata = Record<string, any> & {
424
+ /**
425
+ * If true, the processor is sealed and cannot be replaced or removed.
426
+ * Sealed processors can still be extended (wrapped) by processors with `extendsProcessor = true`.
427
+ */
428
+ sealed?: boolean;
429
+ /**
430
+ * If true, the processor requires the server to be running
431
+ */
432
+ requireServer?: boolean;
433
+ /**
434
+ * The module the processor belongs to
435
+ */
436
+ module?: string;
437
+ /**
438
+ * An icon to display for the processor
439
+ */
440
+ icon?: CliIcon | string;
441
+ /**
442
+ * The minimum required version of @qodalis/cli-core for this processor.
443
+ * If the installed core version is lower, the processor will be skipped during boot.
444
+ */
445
+ requiredCoreVersion?: string;
446
+ /**
447
+ * The minimum required version of @qodalis/cli for this processor.
448
+ * If the installed CLI version is lower, the processor will be skipped during boot.
449
+ */
450
+ requiredCliVersion?: string;
451
+ /**
452
+ * If true, the processor is hidden from the help command listing.
453
+ * The command still works when typed directly and `help <command>` still shows its details.
454
+ */
455
+ hidden?: boolean;
456
+ };
457
+ /**
458
+ * Represents a state configuration for the CLI processor
459
+ */
460
+ type CliStateConfiguration = {
461
+ /**
462
+ * The initial state for the processor
463
+ */
464
+ initialState: Record<string, any>;
465
+ /**
466
+ * The store identifier for the processor, if any
467
+ * @remarks If the store identifier is not set, the processor command name is used
468
+ */
469
+ storeName?: string;
470
+ };
471
+ /**
472
+ * Represents a log level for the CLI
473
+ */
474
+ declare enum CliLogLevel {
475
+ None = 0,
476
+ DEBUG = 1,
477
+ LOG = 2,
478
+ INFO = 3,
479
+ WARN = 4,
480
+ ERROR = 5
481
+ }
482
+ type CliState = Record<string, any>;
483
+ /**
484
+ * Position of the CLI panel relative to the viewport edge.
485
+ */
486
+ type CliPanelPosition = 'bottom' | 'top' | 'left' | 'right';
487
+ /**
488
+ * Alignment of the hidden-mode tab along its viewport edge.
489
+ */
490
+ type CliPanelHideAlignment = 'start' | 'center' | 'end';
491
+ /**
492
+ * Configuration for the CLI panel component.
493
+ */
494
+ interface CliPanelConfig {
495
+ /**
496
+ * Whether the CLI should be collapsed by default.
497
+ * @default true
498
+ */
499
+ isCollapsed?: boolean;
500
+ /**
501
+ * Whether the panel starts hidden (showing only the small tab/arrow).
502
+ * @default false
503
+ */
504
+ isHidden?: boolean;
505
+ /**
506
+ * Position of the panel relative to the viewport.
507
+ * @default 'bottom'
508
+ */
509
+ position?: CliPanelPosition;
510
+ /**
511
+ * Whether the close button is shown.
512
+ * @default true
513
+ */
514
+ closable?: boolean;
515
+ /**
516
+ * Whether the panel can be resized by dragging.
517
+ * @default true
518
+ */
519
+ resizable?: boolean;
520
+ /**
521
+ * Whether the hide button is shown. When hidden, the panel collapses
522
+ * to a small tab at the viewport edge.
523
+ * @default true
524
+ */
525
+ hideable?: boolean;
526
+ /**
527
+ * Alignment of the hide tab along the panel's viewport edge.
528
+ * For bottom/top: 'start' = left, 'center', 'end' = right.
529
+ * For left/right: 'start' = top, 'center', 'end' = bottom.
530
+ * @default 'center'
531
+ */
532
+ hideAlignment?: CliPanelHideAlignment;
533
+ /**
534
+ * When true, the panel's chrome (header, border, background) automatically
535
+ * syncs its colors with the active terminal theme. CSS custom properties
536
+ * are derived from the xterm theme and applied as inline styles.
537
+ * @default false
538
+ */
539
+ syncTheme?: boolean;
540
+ }
541
+ declare const enums: {
542
+ CliForegroundColor: typeof CliForegroundColor;
543
+ CliBackgroundColor: typeof CliBackgroundColor;
544
+ CliIcon: typeof CliIcon;
545
+ CliLogLevel: typeof CliLogLevel;
546
+ };
547
+
548
+ /**
549
+ * Represents an option for the readSelect prompt.
550
+ */
551
+ interface CliSelectOption {
552
+ /** Display text shown to the user */
553
+ label: string;
554
+ /** Value returned when this option is selected */
555
+ value: string;
556
+ }
557
+ /**
558
+ * Represents an option for the readMultiSelect prompt.
559
+ */
560
+ interface CliMultiSelectOption extends CliSelectOption {
561
+ /** Whether the option is pre-selected */
562
+ checked?: boolean;
563
+ }
564
+ /**
565
+ * Provides interactive input reading from the terminal.
566
+ * All methods resolve with `null` when the user aborts (Ctrl+C or Escape).
567
+ */
568
+ interface ICliInputReader {
569
+ /**
570
+ * Prompt the user for a line of text input.
571
+ * @param prompt The prompt text to display (e.g. "Enter your name: ")
572
+ * @returns The entered text, empty string if Enter pressed with no input, or null if aborted
573
+ */
574
+ readLine(prompt: string): Promise<string | null>;
575
+ /**
576
+ * Prompt the user for password input. Characters are masked with asterisks.
577
+ * @param prompt The prompt text to display (e.g. "Password: ")
578
+ * @returns The entered password, empty string if Enter pressed with no input, or null if aborted
579
+ */
580
+ readPassword(prompt: string): Promise<string | null>;
581
+ /**
582
+ * Prompt the user for a yes/no confirmation.
583
+ * @param prompt The prompt text to display (e.g. "Continue?")
584
+ * @param defaultValue The default value when Enter is pressed without input (defaults to false)
585
+ * @returns true for yes, false for no, defaultValue on empty Enter, or null if aborted
586
+ */
587
+ readConfirm(prompt: string, defaultValue?: boolean): Promise<boolean | null>;
588
+ /**
589
+ * Prompt the user to select from a list of options using arrow keys.
590
+ * @param prompt The prompt text to display (e.g. "Pick one:")
591
+ * @param options The list of options to choose from
592
+ * @param onChange Optional callback invoked each time the highlighted option changes
593
+ * @returns The value of the selected option, or null if aborted
594
+ */
595
+ readSelect(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
596
+ /**
597
+ * Prompt the user to select from a horizontal single-line option picker.
598
+ * Navigate with Left/Right arrow keys.
599
+ * @param prompt The prompt text to display
600
+ * @param options The list of options to choose from
601
+ * @param onChange Optional callback invoked each time the highlighted option changes
602
+ * @returns The value of the selected option, or null if aborted
603
+ */
604
+ readSelectInline(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
605
+ /**
606
+ * Prompt the user to select multiple items from a checkbox list.
607
+ * Navigate with Up/Down, toggle with Space, confirm with Enter.
608
+ * @param prompt The prompt text to display
609
+ * @param options The list of options with optional pre-checked state
610
+ * @returns Array of selected values, or null if aborted
611
+ */
612
+ readMultiSelect(prompt: string, options: CliMultiSelectOption[]): Promise<string[] | null>;
613
+ /**
614
+ * Prompt the user for numeric input with optional min/max validation.
615
+ * @param prompt The prompt text to display
616
+ * @param options Optional constraints: min, max, and default value
617
+ * @returns The entered number, or null if aborted
618
+ */
619
+ readNumber(prompt: string, options?: {
620
+ min?: number;
621
+ max?: number;
622
+ default?: number;
623
+ }): Promise<number | null>;
624
+ }
625
+
626
+ /**
627
+ * Whether a background service is a long-running daemon or a one-shot job.
628
+ */
629
+ type CliBackgroundServiceType = 'daemon' | 'job';
630
+ /**
631
+ * Lifecycle status of a background service.
632
+ */
633
+ type CliBackgroundServiceStatus = 'pending' | 'running' | 'stopped' | 'failed' | 'done';
634
+ /**
635
+ * Where the service code is executing.
636
+ */
637
+ type CliServiceExecutionMode = 'main-thread' | 'worker';
638
+ /**
639
+ * An event emitted by a background service.
640
+ * Services control terminal notification visibility by setting `data.notify: true`.
641
+ */
642
+ interface ICliServiceEvent {
643
+ /** Name of the service that emitted this event */
644
+ source: string;
645
+ /** Event type — services define their own, registry emits lifecycle events */
646
+ type: string;
647
+ /** Arbitrary payload */
648
+ data?: unknown;
649
+ /** Set automatically by the registry */
650
+ timestamp?: Date;
651
+ }
652
+ /**
653
+ * Handler function for service events.
654
+ */
655
+ type CliServiceEventHandler = (event: ICliServiceEvent) => void;
656
+ /**
657
+ * A single log entry from a background service.
658
+ */
659
+ interface ICliServiceLogEntry {
660
+ timestamp: Date;
661
+ level: 'info' | 'warn' | 'error';
662
+ message: string;
663
+ }
664
+ /**
665
+ * Per-service runtime context.
666
+ * Each background service receives its own context with an independent abort signal
667
+ * and scoped timers (not shared with the full-screen timer set).
668
+ */
669
+ interface ICliServiceContext {
670
+ /** AbortSignal scoped to this service — independent of Ctrl+C */
671
+ signal: AbortSignal;
672
+ /** Emit an event from this service */
673
+ emit(event: ICliServiceEvent): void;
674
+ /** Log a message to this service's private log buffer */
675
+ log(message: string, level?: 'info' | 'warn' | 'error'): void;
676
+ /** Create an interval scoped to this service (auto-cleared on stop) */
677
+ createInterval(callback: () => void, ms: number): ICliManagedInterval;
678
+ /** Create a timeout scoped to this service (auto-cleared on stop) */
679
+ createTimeout(callback: () => void, ms: number): ICliManagedTimer;
680
+ /** Access the shared state store */
681
+ state: ICliStateStore;
682
+ /** Access the shared service container */
683
+ services: ICliServiceProvider;
684
+ }
685
+ /**
686
+ * A background service that can run as a daemon or job.
687
+ */
688
+ interface ICliBackgroundService {
689
+ /** Unique name for this service */
690
+ name: string;
691
+ /** Human-readable description */
692
+ description?: string;
693
+ /** 'daemon' for long-running, 'job' for run-to-completion */
694
+ type: CliBackgroundServiceType;
695
+ /** Whether this service can run in a Web Worker */
696
+ workerCompatible?: boolean;
697
+ /** Factory that creates the Worker instance (when workerCompatible) */
698
+ workerFactory?: () => Worker;
699
+ /** Called when the service starts */
700
+ onStart(context: ICliServiceContext): Promise<void>;
701
+ /** Called for graceful shutdown */
702
+ onStop?(context: ICliServiceContext): Promise<void>;
703
+ /** Called on unrecoverable error */
704
+ onError?(error: Error, context: ICliServiceContext): void;
705
+ }
706
+ /**
707
+ * Read-only snapshot of a background service's current state.
708
+ */
709
+ interface ICliBackgroundServiceInfo {
710
+ name: string;
711
+ description?: string;
712
+ type: CliBackgroundServiceType;
713
+ status: CliBackgroundServiceStatus;
714
+ executionMode: CliServiceExecutionMode;
715
+ startedAt?: Date;
716
+ stoppedAt?: Date;
717
+ error?: string;
718
+ /** Uptime in milliseconds (only when running) */
719
+ uptime?: number;
720
+ }
721
+ /**
722
+ * Registry that manages background service lifecycle.
723
+ * Exposed on `ICliExecutionContext.backgroundServices`.
724
+ */
725
+ interface ICliBackgroundServiceRegistry {
726
+ register(service: ICliBackgroundService): void;
727
+ start(name: string): Promise<void>;
728
+ stop(name: string): Promise<void>;
729
+ restart(name: string): Promise<void>;
730
+ startJob(name: string, task: (context: ICliServiceContext) => Promise<void>, options?: {
731
+ workerCompatible?: boolean;
732
+ }): void;
733
+ getStatus(name: string): ICliBackgroundServiceInfo | undefined;
734
+ list(): ICliBackgroundServiceInfo[];
735
+ getLogs(name: string, limit?: number): ICliServiceLogEntry[];
736
+ on(handler: CliServiceEventHandler, filter?: {
737
+ source?: string;
738
+ type?: string;
739
+ }): () => void;
740
+ destroyAll(): Promise<void>;
741
+ }
742
+
743
+ /**
744
+ * A managed timer handle returned by createInterval/createTimeout.
745
+ * Managed timers are automatically cleared when full-screen mode exits
746
+ * or the CLI component is destroyed.
747
+ */
748
+ interface ICliManagedTimer {
749
+ /** Clear this timer immediately. */
750
+ clear(): void;
751
+ }
752
+ /**
753
+ * A managed interval handle with the ability to change the delay.
754
+ */
755
+ interface ICliManagedInterval extends ICliManagedTimer {
756
+ /** Change the interval delay. Restarts the interval with the new delay. */
757
+ setDelay(ms: number): void;
758
+ }
759
+ /**
760
+ * Represents the context in which a command is executed
761
+ */
762
+ interface ICliExecutionContext {
763
+ /**
764
+ * The current user session
765
+ */
766
+ userSession?: ICliUserSession;
767
+ /**
768
+ * The spinner to use for showing/hiding the loader
769
+ */
770
+ spinner?: ICliSpinner;
771
+ /**
772
+ * The text animator to use for showing/hiding text
773
+ */
774
+ textAnimator?: ICliTextAnimator;
775
+ /**
776
+ * The progress bar to use for showing progress
777
+ */
778
+ progressBar: ICliPercentageProgressBar;
779
+ /**
780
+ * A subject that emits when the command is aborted
781
+ */
782
+ onAbort: Subject<void>;
783
+ /**
784
+ * Abort signal for the current command. Fires when the command is
785
+ * cancelled via Ctrl+C or killed. Commands should check this signal
786
+ * or listen to onAbort for cooperative cancellation.
787
+ */
788
+ signal?: AbortSignal;
789
+ /**
790
+ * The terminal to use for writing
791
+ */
792
+ terminal: Terminal;
793
+ /**
794
+ * The writer to use for writing to the terminal
795
+ */
796
+ writer: ICliTerminalWriter;
797
+ /**
798
+ * The reader to use for interactive input prompts (text, password, confirm, select)
799
+ */
800
+ reader: ICliInputReader;
801
+ /**
802
+ * The command executor to use for executing commands
803
+ */
804
+ executor: ICliCommandExecutorService;
805
+ /**
806
+ * The clipboard to use for copying/pasting
807
+ */
808
+ clipboard: ICliClipboard;
809
+ /**
810
+ * The state store to use for storing state
811
+ */
812
+ state: ICliStateStore;
813
+ /**
814
+ * The options for the CLI
815
+ */
816
+ options?: CliOptions;
817
+ /**
818
+ * Prints the prompt to the terminal.
819
+ */
820
+ showPrompt: (options?: {
821
+ reset?: boolean;
822
+ newLine?: boolean;
823
+ keepCurrentLine?: boolean;
824
+ }) => void;
825
+ /**
826
+ * Set the current processor as the context processor, i.e. the processor that will handle the command
827
+ * @param processor The processor to set
828
+ * @param silent Indicates if the setting should be silent, i.e. not write to the terminal
829
+ * @param fullScreen When true, Ctrl+C is passed through to the processor (full-screen apps manage their own exit)
830
+ */
831
+ setContextProcessor: (processor: ICliCommandProcessor | undefined, silent?: boolean, fullScreen?: boolean) => void;
832
+ /**
833
+ * The number of visible characters the prompt occupies on the current line.
834
+ */
835
+ promptLength: number;
836
+ /**
837
+ * The current user input text on the active line.
838
+ */
839
+ readonly currentLine: string;
840
+ /**
841
+ * Sets the current line text.
842
+ * @param line The new line content
843
+ */
844
+ setCurrentLine: (line: string) => void;
845
+ /**
846
+ * The cursor position within the current line.
847
+ */
848
+ cursorPosition: number;
849
+ /**
850
+ * Clears the current terminal line, including content that wraps across multiple rows.
851
+ * Uses promptLength + currentLine.length to determine how many rows to clear.
852
+ */
853
+ clearLine: () => void;
854
+ /**
855
+ * Clears the current line content and reprints the prompt.
856
+ */
857
+ clearCurrentLine: () => void;
858
+ /**
859
+ * Refreshes the display of the current line (clears and redraws prompt + input).
860
+ */
861
+ refreshCurrentLine: () => void;
862
+ /**
863
+ * The process to use for exiting the CLI
864
+ */
865
+ process: ICliExecutionProcess;
866
+ /**
867
+ * The logger to use for logging
868
+ */
869
+ logger: ICliLogger;
870
+ /**
871
+ * The services to use for the CLI context
872
+ */
873
+ services: ICliServiceProvider;
874
+ /**
875
+ * The translation service for i18n string resolution.
876
+ * Use `translator.t(key, defaultValue)` to get translated strings.
877
+ */
878
+ translator: ICliTranslationService;
879
+ /**
880
+ * Optional callback that returns the current path to display in the prompt.
881
+ * Any plugin can set this to customize the path segment of the prompt
882
+ * (e.g. a filesystem plugin showing the current working directory).
883
+ * When set, the returned path replaces the default `~` in the prompt.
884
+ * Return null to fall back to the default `~`.
885
+ */
886
+ promptPathProvider?: () => string | null;
887
+ /**
888
+ * Enter full-screen mode: switches to the alternate screen buffer,
889
+ * hides the cursor, and sets the given processor as the context processor
890
+ * so that all terminal input is routed to its `onData` method.
891
+ * @param processor The processor that will handle all input in full-screen mode
892
+ */
893
+ enterFullScreenMode: (processor: ICliCommandProcessor) => void;
894
+ /**
895
+ * Exit full-screen mode: restores the cursor, leaves the alternate screen buffer,
896
+ * clears the context processor, and re-displays the prompt.
897
+ */
898
+ exitFullScreenMode: () => void;
899
+ /**
900
+ * Creates a managed interval that is automatically cleared when full-screen
901
+ * mode exits or the CLI component is destroyed.
902
+ * @param callback The function to call on each interval tick
903
+ * @param ms The interval delay in milliseconds
904
+ * @returns A managed interval handle with clear() and setDelay() methods
905
+ */
906
+ createInterval: (callback: () => void, ms: number) => ICliManagedInterval;
907
+ /**
908
+ * Creates a managed timeout that is automatically cleared when full-screen
909
+ * mode exits or the CLI component is destroyed.
910
+ * @param callback The function to call when the timeout fires
911
+ * @param ms The timeout delay in milliseconds
912
+ * @returns A managed timer handle with a clear() method
913
+ */
914
+ createTimeout: (callback: () => void, ms: number) => ICliManagedTimer;
915
+ /**
916
+ * Registry for managing background services and jobs.
917
+ * Each CLI session owns its own isolated registry. Services registered here
918
+ * are scoped to this session and destroyed when the engine shuts down.
919
+ */
920
+ backgroundServices: ICliBackgroundServiceRegistry;
921
+ }
922
+
923
+ interface ICliProcessorHook {
924
+ when: 'before' | 'after';
925
+ execute: (context: ICliExecutionContext) => Promise<void>;
926
+ }
927
+
928
+ interface ICliCommandAuthor {
929
+ /**
930
+ * The name of the author
931
+ */
932
+ name: string;
933
+ /**
934
+ * The email of the author
935
+ */
936
+ email: string;
937
+ }
938
+ /**
939
+ * Represents a command parameter
940
+ */
941
+ interface ICliCommandParameterDescriptor {
942
+ /**
943
+ * The name of the parameter
944
+ */
945
+ name: string;
946
+ /**
947
+ * Aliases for the parameter
948
+ */
949
+ aliases?: string[];
950
+ /**
951
+ * A description of the parameter
952
+ */
953
+ description: string;
954
+ /**
955
+ * If true, the parameter is required
956
+ */
957
+ required: boolean;
958
+ /**
959
+ * The type of the parameter
960
+ */
961
+ type: 'string' | 'number' | 'boolean' | 'array' | 'object' | string;
962
+ /**
963
+ * The default value of the parameter
964
+ */
965
+ defaultValue?: any;
966
+ /**
967
+ * A validator function that validates the value of the parameter
968
+ * @param value The value to validate
969
+ * @returns An object with a valid property that indicates if the value is valid and an optional message property that contains a message to display if the value is not valid
970
+ */
971
+ validator?: (value: any) => {
972
+ /**
973
+ * Indicates if the value is valid
974
+ */
975
+ valid: boolean;
976
+ /**
977
+ * An optional message to display if the value is not valid
978
+ */
979
+ message?: string;
980
+ };
981
+ }
982
+ /**
983
+ * Represents a configuration option that a command processor exposes
984
+ * for management via the `configure` command.
985
+ */
986
+ interface ICliConfigurationOption {
987
+ /**
988
+ * The key used to store and retrieve this option, e.g. 'maxItems'
989
+ */
990
+ key: string;
991
+ /**
992
+ * Human-readable label shown in the interactive menu
993
+ */
994
+ label: string;
995
+ /**
996
+ * Description of what this option controls
997
+ */
998
+ description: string;
999
+ /**
1000
+ * The data type of the option
1001
+ */
1002
+ type: 'string' | 'number' | 'boolean' | 'select';
1003
+ /**
1004
+ * The default value when no configuration has been set
1005
+ */
1006
+ defaultValue: any;
1007
+ /**
1008
+ * Available choices for 'select' type options
1009
+ */
1010
+ options?: {
1011
+ label: string;
1012
+ value: any;
1013
+ }[];
1014
+ /**
1015
+ * Optional validator function
1016
+ */
1017
+ validator?: (value: any) => {
1018
+ valid: boolean;
1019
+ message?: string;
1020
+ };
1021
+ /**
1022
+ * Override the category grouping (defaults to the processor command name)
1023
+ */
1024
+ category?: string;
1025
+ }
1026
+ /**
1027
+ * Represents a command processor
1028
+ */
1029
+ interface ICliCommandProcessor {
1030
+ /**
1031
+ * The command that this processor handles
1032
+ */
1033
+ command: string;
1034
+ /**
1035
+ * Alternative names for the command
1036
+ */
1037
+ aliases?: string[];
1038
+ /**
1039
+ * A description of the command
1040
+ */
1041
+ description?: string;
1042
+ /**
1043
+ * The author of the command
1044
+ */
1045
+ author?: ICliCommandAuthor;
1046
+ /**
1047
+ * If true, the processor accepts raw text input after the command name as its value.
1048
+ * The captured text is available via `command.value` in `processCommand`.
1049
+ * @default false
1050
+ * @remarks When true, any text following the command name is extracted as the command value
1051
+ * rather than being interpreted as sub-commands. Use `valueRequired` instead if the value is mandatory.
1052
+ */
1053
+ acceptsRawInput?: boolean;
1054
+ /**
1055
+ * If true, the command requires some form of input before it can execute.
1056
+ *
1057
+ * The requirement is satisfied by **any** of:
1058
+ * - A positional value (text after the command name, available via `command.value`)
1059
+ * - Piped data from a previous command (available via `command.data`)
1060
+ * - Named arguments (e.g. `--server=node --path=/app`)
1061
+ *
1062
+ * When set, `command.value` is automatically extracted from the raw input
1063
+ * (equivalent to setting `acceptsRawInput`).
1064
+ *
1065
+ * Additionally, when positional input is present the engine skips
1066
+ * required-parameter validation — the processor is responsible for
1067
+ * parsing positional text into individual values. Required-parameter
1068
+ * checks still apply when the user provides only named arguments.
1069
+ *
1070
+ * @default false
1071
+ */
1072
+ valueRequired?: boolean;
1073
+ /**
1074
+ * The version of the command processor
1075
+ * @default '1.0.0'
1076
+ */
1077
+ version?: string;
1078
+ /**
1079
+ * The metadata for the command processor
1080
+ */
1081
+ metadata?: CliProcessorMetadata;
1082
+ /**
1083
+ * Processors that are nested under this processor
1084
+ */
1085
+ processors?: ICliCommandChildProcessor[];
1086
+ /**
1087
+ * Parameters that the command accepts
1088
+ */
1089
+ parameters?: ICliCommandParameterDescriptor[];
1090
+ /**
1091
+ * Hooks that are executed before and after the command is processed
1092
+ */
1093
+ hooks?: ICliProcessorHook[];
1094
+ /**
1095
+ * Represents the state configuration for the command processor
1096
+ * @remarks The state configuration is used to store and retrieve state information for the command processor
1097
+ * @remarks State confihuration is optional and can be used to store and retrieve state information for the command processor
1098
+ * @remarks The state configuration is used only for root command processors and not for child command processors
1099
+ */
1100
+ stateConfiguration?: CliStateConfiguration;
1101
+ /**
1102
+ * Configuration options exposed by this processor for the `configure` command.
1103
+ * When defined, these options appear in the interactive configuration menu
1104
+ * and can be managed via `configure get/set` subcommands.
1105
+ */
1106
+ configurationOptions?: ICliConfigurationOption[];
1107
+ /**
1108
+ * When true, this processor extends (wraps) an existing processor with the same
1109
+ * command name instead of replacing it. The registry sets `originalProcessor`
1110
+ * to the previous processor so this one can delegate to it.
1111
+ */
1112
+ extendsProcessor?: boolean;
1113
+ /**
1114
+ * Reference to the original processor that this one extends.
1115
+ * Set automatically by the registry — do not set manually.
1116
+ * Call `this.originalProcessor.processCommand(command, context)` to delegate.
1117
+ */
1118
+ originalProcessor?: ICliCommandProcessor;
1119
+ /**
1120
+ * Process the command
1121
+ * @param command The command to process
1122
+ * @param context The context in which the command is executed
1123
+ */
1124
+ processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
1125
+ /**
1126
+ * Write the description of the command
1127
+ * @param context The context in which the command is executed
1128
+ */
1129
+ writeDescription?(context: ICliExecutionContext): void;
1130
+ /**
1131
+ * A function that validates the command before execution
1132
+ * @param value The value to validate
1133
+ * @returns An object with a valid property that indicates if the value is valid and an optional message property that contains a message to display if the value is not valid
1134
+ */
1135
+ validateBeforeExecution?: (command: CliProcessCommand, context: ICliExecutionContext) => {
1136
+ valid: boolean;
1137
+ message?: string;
1138
+ };
1139
+ /**
1140
+ * Initialize the command processor
1141
+ * @param context The context in which the command is executed
1142
+ */
1143
+ initialize?(context: ICliExecutionContext): Promise<void>;
1144
+ /**
1145
+ * Handle raw terminal data when this processor is the active context processor.
1146
+ * When implemented, ALL terminal input is routed here instead of normal CLI input handling.
1147
+ * Used for full-screen interactive modes (editors, pagers, etc.).
1148
+ * @param data The raw terminal data string (escape sequences, control chars, printable text)
1149
+ * @param context The execution context
1150
+ */
1151
+ onData?(data: string, context: ICliExecutionContext): Promise<void>;
1152
+ /**
1153
+ * Called when the terminal is resized while this processor is the active
1154
+ * full-screen context processor. Allows processors to adapt their rendering
1155
+ * to the new terminal dimensions.
1156
+ * @param cols The new number of columns
1157
+ * @param rows The new number of rows
1158
+ * @param context The execution context
1159
+ */
1160
+ onResize?(cols: number, rows: number, context: ICliExecutionContext): void;
1161
+ /**
1162
+ * Called when the processor is being disposed — either because full-screen
1163
+ * mode ended, the terminal disconnected, or the CLI component is being
1164
+ * destroyed. Use this to clean up resources (timers, subscriptions, etc.).
1165
+ * @param context The execution context
1166
+ */
1167
+ onDispose?(context: ICliExecutionContext): void;
1168
+ }
1169
+ /**
1170
+ * Represents a child command processor
1171
+ */
1172
+ interface ICliCommandChildProcessor extends ICliCommandProcessor {
1173
+ /**
1174
+ * The parent processor, it is populated by the processor manager
1175
+ */
1176
+ parent?: ICliCommandProcessor;
1177
+ }
1178
+
1179
+ /**
1180
+ * Describes a global parameter (e.g. --help, --version) together with
1181
+ * the handler that executes when the parameter is present.
1182
+ *
1183
+ * Global parameters are checked for every command before the command
1184
+ * processor's own `processCommand` runs. If the handler returns `true`,
1185
+ * command execution is halted (the parameter "consumed" the invocation).
1186
+ */
1187
+ interface ICliGlobalParameterHandler {
1188
+ /**
1189
+ * The parameter descriptor shown in help output and used for tab-completion.
1190
+ */
1191
+ parameter: ICliCommandParameterDescriptor;
1192
+ /**
1193
+ * Execution priority — lower values run first.
1194
+ * @default 0
1195
+ */
1196
+ priority?: number;
1197
+ /**
1198
+ * Evaluate and optionally handle the parameter.
1199
+ * @returns `true` to halt command execution, `false` to continue.
1200
+ */
1201
+ handle(args: Record<string, any>, processor: ICliCommandProcessor, command: CliProcessCommand, context: ICliExecutionContext): boolean | Promise<boolean>;
1202
+ }
1203
+
1204
+ /**
1205
+ * Token for registering completion providers via module services (multi: true).
1206
+ */
1207
+ declare const ICliCompletionProvider_TOKEN = "cli-completion-provider";
1208
+ /**
1209
+ * Context passed to completion providers describing the current input state.
1210
+ */
1211
+ interface ICliCompletionContext {
1212
+ /** Full current line text */
1213
+ input: string;
1214
+ /** Cursor position in the line */
1215
+ cursor: number;
1216
+ /** The token (word) being completed at the cursor position */
1217
+ token: string;
1218
+ /** Start index of the token in the input string */
1219
+ tokenStart: number;
1220
+ /** Index of the token among all tokens (0 = command, 1+ = arguments) */
1221
+ tokenIndex: number;
1222
+ /** All tokens parsed from the input */
1223
+ tokens: string[];
1224
+ }
1225
+ /**
1226
+ * Provides tab-completion candidates for CLI input.
1227
+ * Plugins can register providers to extend completion (e.g. file paths, custom values).
1228
+ */
1229
+ interface ICliCompletionProvider {
1230
+ /**
1231
+ * Priority order. Lower values are checked first.
1232
+ * Built-in defaults: 100 (commands), 200 (parameters).
1233
+ * Plugins should use lower values (e.g. 50) to take precedence for specific commands.
1234
+ */
1235
+ priority: number;
1236
+ /**
1237
+ * Return completion candidates for the current input context.
1238
+ * Return an empty array if this provider does not apply.
1239
+ */
1240
+ getCompletions(context: ICliCompletionContext): string[] | Promise<string[]>;
1241
+ }
1242
+
1243
+ interface ICliProgressBar {
1244
+ /**
1245
+ * Indicates if the progress bar is running
1246
+ */
1247
+ isRunning: boolean;
1248
+ /**
1249
+ * Show the progress bar
1250
+ */
1251
+ show: (text?: string) => void;
1252
+ /**
1253
+ * Hide the progress bar
1254
+ */
1255
+ hide: () => void;
1256
+ }
1257
+ /**
1258
+ * Represents a spinner for the CLI
1259
+ */
1260
+ interface ICliSpinner extends ICliProgressBar {
1261
+ /**
1262
+ * Set the text of the spinner
1263
+ * @param text The text to set
1264
+ */
1265
+ setText: (text: string) => void;
1266
+ }
1267
+ type CliPercentageProgressBarUpdateValueOptions = {
1268
+ /**
1269
+ * The type of update to perform
1270
+ * @default 'replace'
1271
+ */
1272
+ type?: 'replace' | 'increment';
1273
+ };
1274
+ /**
1275
+ * Represents a progress bar for the CLI
1276
+ */
1277
+ interface ICliPercentageProgressBar extends ICliProgressBar {
1278
+ /**
1279
+ * Update the progress of the progress bar
1280
+ * @param progress The progress to update to
1281
+ * @returns void
1282
+ */
1283
+ update: (progress: number, options?: CliPercentageProgressBarUpdateValueOptions) => void;
1284
+ /**
1285
+ * Complete the progress bar
1286
+ * @returns void
1287
+ */
1288
+ complete: () => void;
1289
+ /**
1290
+ * Set the text of the spinner
1291
+ * @param text The text to set
1292
+ */
1293
+ setText: (text: string) => void;
1294
+ }
1295
+ type CliTextAnimatorOptions = {
1296
+ /**
1297
+ * The speed of the animation
1298
+ * @default 100
1299
+ */
1300
+ speed?: number;
1301
+ /**
1302
+ * The text will be removed after typing
1303
+ */
1304
+ removeAfterTyping?: boolean;
1305
+ };
1306
+ interface ICliTextAnimator extends ICliProgressBar {
1307
+ /**
1308
+ * Show animated text in a typing and erasing effect.
1309
+ * @param text
1310
+ * @param options
1311
+ * @returns
1312
+ */
1313
+ showText: (text: string, options?: CliTextAnimatorOptions) => Promise<void>;
1314
+ }
1315
+
1316
+ /**
1317
+ * Represents a service that manages user sessions in the CLI
1318
+ */
1319
+ interface ICliUserSessionService {
1320
+ /** Gets the current user session as a reactive stream */
1321
+ getUserSession(): Observable<ICliUserSession | undefined>;
1322
+ /** Sets the current user session */
1323
+ setUserSession(session: ICliUserSession): Promise<void>;
1324
+ /** Clears the current session (logout) */
1325
+ clearSession(): Promise<void>;
1326
+ /** Persists the current session to storage */
1327
+ persistSession(): Promise<void>;
1328
+ /** Restores a session from storage (called on boot) */
1329
+ restoreSession(): Promise<ICliUserSession | undefined>;
1330
+ }
1331
+ /**
1332
+ * Represents a service that manages users in the CLI
1333
+ */
1334
+ interface ICliUsersStoreService {
1335
+ /** Gets users with optional filtering and pagination */
1336
+ getUsers(options?: {
1337
+ query?: string;
1338
+ skip?: number;
1339
+ take?: number;
1340
+ }): Observable<ICliUser[]>;
1341
+ /** Creates a new user */
1342
+ createUser(user: CliAddUser): Promise<ICliUser>;
1343
+ /** Gets a user by id, name, or email */
1344
+ getUser(id: string): Observable<ICliUser | undefined>;
1345
+ /** Updates an existing user */
1346
+ updateUser(id: string, updates: CliUpdateUser): Promise<ICliUser>;
1347
+ /** Deletes a user by id */
1348
+ deleteUser(id: string): Promise<void>;
1349
+ }
1350
+ /**
1351
+ * Represents a service that manages groups in the CLI
1352
+ */
1353
+ interface ICliGroupsStoreService {
1354
+ /** Gets all groups */
1355
+ getGroups(): Observable<ICliGroup[]>;
1356
+ /** Gets a group by id or name */
1357
+ getGroup(id: string): Observable<ICliGroup | undefined>;
1358
+ /** Creates a new group */
1359
+ createGroup(name: string, description?: string): Promise<ICliGroup>;
1360
+ /** Deletes a group by id */
1361
+ deleteGroup(id: string): Promise<void>;
1362
+ /** Gets all users that belong to a group */
1363
+ getGroupMembers(groupId: string): Observable<ICliUser[]>;
1364
+ }
1365
+ /**
1366
+ * Represents a service that handles authentication in the CLI
1367
+ */
1368
+ interface ICliAuthService {
1369
+ /** Authenticates a user and returns a session */
1370
+ login(username: string, password: string): Promise<ICliUserSession>;
1371
+ /** Ends the current session */
1372
+ logout(): Promise<void>;
1373
+ /** Sets or updates a user's password */
1374
+ setPassword(userId: string, password: string): Promise<void>;
1375
+ /** Verifies a password against stored credentials */
1376
+ verifyPassword(userId: string, password: string): Promise<boolean>;
1377
+ /** Hashes a password with a salt using Web Crypto SHA-256 */
1378
+ hashPassword(password: string, salt: string): Promise<string>;
1379
+ }
1380
+
1381
+ /**
1382
+ * Represents a serialized snapshot of a CLI engine's state.
1383
+ * Used to duplicate terminal tabs with full state preservation.
1384
+ */
1385
+ interface CliEngineSnapshot {
1386
+ /** Schema version for forward compatibility */
1387
+ version: 1;
1388
+ /** Timestamp (ms since epoch) when the snapshot was taken */
1389
+ timestamp: number;
1390
+ /** Serialized terminal state */
1391
+ terminal: {
1392
+ /** Terminal buffer serialized via @xterm/addon-serialize */
1393
+ serializedBuffer: string;
1394
+ /** Terminal column count at time of snapshot */
1395
+ cols: number;
1396
+ /** Terminal row count at time of snapshot */
1397
+ rows: number;
1398
+ };
1399
+ /** Command history entries (most recent last) */
1400
+ commandHistory: string[];
1401
+ /** Named state store entries */
1402
+ stateStores: Array<{
1403
+ name: string;
1404
+ state: Record<string, any>;
1405
+ }>;
1406
+ }
1407
+
1408
+ /**
1409
+ * Messages sent from the main thread to a background service Worker.
1410
+ */
1411
+ type CliWorkerInboundMessage = {
1412
+ type: 'start';
1413
+ config?: Record<string, unknown>;
1414
+ } | {
1415
+ type: 'stop';
1416
+ } | {
1417
+ type: 'abort';
1418
+ };
1419
+ /**
1420
+ * Messages sent from a background service Worker to the main thread.
1421
+ */
1422
+ type CliWorkerOutboundMessage = {
1423
+ type: 'log';
1424
+ level: 'info' | 'warn' | 'error';
1425
+ message: string;
1426
+ } | {
1427
+ type: 'event';
1428
+ event: Omit<ICliServiceEvent, 'timestamp'>;
1429
+ } | {
1430
+ type: 'state-update';
1431
+ patch: Record<string, unknown>;
1432
+ } | {
1433
+ type: 'status';
1434
+ status: CliBackgroundServiceStatus;
1435
+ } | {
1436
+ type: 'error';
1437
+ message: string;
1438
+ stack?: string;
1439
+ };
1440
+
1441
+ /**
1442
+ * Represents an entry in a file listing.
1443
+ */
1444
+ interface ICliFileEntry {
1445
+ name: string;
1446
+ type: 'file' | 'directory';
1447
+ size: number;
1448
+ modified: string;
1449
+ }
1450
+ /**
1451
+ * Token for the file transfer service.
1452
+ */
1453
+ declare const ICliFileTransferService_TOKEN = "cli-file-transfer-service";
1454
+ /**
1455
+ * Abstraction for file transfer operations.
1456
+ * Default implementation uses browser-native APIs (file picker, download dialog).
1457
+ * @qodalis/cli-files overrides with virtual FS backed by IndexedDB.
1458
+ */
1459
+ interface ICliFileTransferService {
1460
+ readFile(path: string): Promise<string | null>;
1461
+ writeFile(path: string, content: string): Promise<void>;
1462
+ listFiles(path: string): Promise<ICliFileEntry[]>;
1463
+ exists(path: string): Promise<boolean>;
1464
+ downloadToBrowser(filename: string, content: string | Blob): void;
1465
+ uploadFromBrowser(accept?: string): Promise<{
1466
+ name: string;
1467
+ content: string;
1468
+ } | null>;
1469
+ }
1470
+
1471
+ declare const ICliDragDropService_TOKEN = "cli-drag-drop-service";
1472
+ interface ICliDragDropService {
1473
+ /** Emits an array of dropped File objects each time files are dropped onto the terminal */
1474
+ readonly onFileDrop: Observable<File[]>;
1475
+ }
1476
+
1477
+ interface ICliTerminalWriter {
1478
+ /**
1479
+ * Write text to the terminal
1480
+ * @param text The text to write
1481
+ */
1482
+ write(text: string): void;
1483
+ /**
1484
+ * Write text to the terminal followed by a newline
1485
+ * @param text The text to write
1486
+ */
1487
+ writeln(text?: string): void;
1488
+ /**
1489
+ * Write a success message to the terminal
1490
+ * @param messag The message to write
1491
+ * @returns void
1492
+ */
1493
+ writeSuccess: (message: string) => void;
1494
+ /**
1495
+ * Write an info message to the terminal
1496
+ * @param messag The message to write
1497
+ * @returns void
1498
+ */
1499
+ writeInfo: (message: string) => void;
1500
+ /**
1501
+ * Write an error message to the terminal
1502
+ * @param message The message to write
1503
+ * @returns void
1504
+ */
1505
+ writeError: (message: string) => void;
1506
+ /**
1507
+ * Write a warning message to the terminal
1508
+ * @param message The message to write
1509
+ * @returns void
1510
+ */
1511
+ writeWarning: (message: string) => void;
1512
+ /**
1513
+ * Write a message to the terminal with the specified color
1514
+ * @param message The message to write
1515
+ * @param color The color to use
1516
+ * @returns void
1517
+ */
1518
+ wrapInColor: (text: string, color: CliForegroundColor) => string;
1519
+ /**
1520
+ * Write a message to the terminal with the specified background color
1521
+ * @param message The message to write
1522
+ * @param color The background color to use
1523
+ * @returns void
1524
+ */
1525
+ wrapInBackgroundColor: (text: string, color: CliBackgroundColor) => string;
1526
+ /**
1527
+ * Write a JSON object to the terminal
1528
+ * @param json The JSON object to write
1529
+ * @returns void
1530
+ */
1531
+ writeJson: (json: any) => void;
1532
+ /**
1533
+ * Write content to a file
1534
+ * @param fileName The name of the file to write to
1535
+ * @param content The content to write to the file
1536
+ * @returns void
1537
+ */
1538
+ writeToFile: (fileName: string, content: string) => void;
1539
+ /**
1540
+ * Write an object array as a table to the terminal
1541
+ * @param objects The objects to write to the table
1542
+ * @returns void
1543
+ */
1544
+ writeObjectsAsTable(objects: any[]): void;
1545
+ /**
1546
+ * Write a table to the terminal
1547
+ * @param headers The headers of the table
1548
+ * @param rows The rows of the table
1549
+ * @returns void
1550
+ */
1551
+ writeTable(headers: string[], rows: string[][]): void;
1552
+ /**
1553
+ * Write a divider to the terminal
1554
+ * @param options The options for the divider
1555
+ * @returns void
1556
+ */
1557
+ writeDivider(options?: {
1558
+ color?: CliForegroundColor;
1559
+ length?: number;
1560
+ char?: string;
1561
+ }): void;
1562
+ /**
1563
+ * Write a list of items to the terminal with bullet, numbered, or custom prefix.
1564
+ * @param items The list items to display
1565
+ * @param options Optional: ordered (numbered), prefix (custom marker), color
1566
+ */
1567
+ writeList(items: string[], options?: {
1568
+ ordered?: boolean;
1569
+ prefix?: string;
1570
+ color?: CliForegroundColor;
1571
+ }): void;
1572
+ /**
1573
+ * Write aligned key-value pairs to the terminal.
1574
+ * @param entries Key-value pairs as a Record or array of tuples
1575
+ * @param options Optional: separator string, key color
1576
+ */
1577
+ writeKeyValue(entries: Record<string, string> | [string, string][], options?: {
1578
+ separator?: string;
1579
+ keyColor?: CliForegroundColor;
1580
+ }): void;
1581
+ /**
1582
+ * Write items in a multi-column layout.
1583
+ * @param items The items to arrange in columns
1584
+ * @param options Optional: number of columns, padding between columns
1585
+ */
1586
+ writeColumns(items: string[], options?: {
1587
+ columns?: number;
1588
+ padding?: number;
1589
+ }): void;
1590
+ }
1591
+ /**
1592
+ * Represents a clipboard for the CLI
1593
+ */
1594
+ interface ICliClipboard {
1595
+ /**
1596
+ * Write text to the clipboard
1597
+ * @param text The text to write to the clipboard
1598
+ * @returns void
1599
+ */
1600
+ write: (text: string) => Promise<void>;
1601
+ /**
1602
+ * Read text from the clipboard
1603
+ * @returns The text read from the clipboard
1604
+ */
1605
+ read: () => Promise<string>;
1606
+ }
1607
+ /**
1608
+ * Represents a service that executes commands
1609
+ */
1610
+ interface ICliCommandExecutorService {
1611
+ /**
1612
+ *
1613
+ * @param command
1614
+ * @param context
1615
+ */
1616
+ showHelp(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
1617
+ /**
1618
+ * Execute a command
1619
+ * @param command The command to execute
1620
+ * @param context The context in which the command is executed
1621
+ */
1622
+ executeCommand(command: string, context: ICliExecutionContext): Promise<void>;
1623
+ /**
1624
+ * Register a global parameter handler.
1625
+ * Global parameters (e.g. --help, --version) are evaluated for every
1626
+ * command before the processor's own processCommand runs.
1627
+ * @param handler The global parameter handler to register
1628
+ */
1629
+ registerGlobalParameter(handler: ICliGlobalParameterHandler): void;
1630
+ /**
1631
+ * Returns the descriptors of all registered global parameters.
1632
+ * Used by help output and tab-completion.
1633
+ */
1634
+ getGlobalParameters(): ICliCommandParameterDescriptor[];
1635
+ }
1636
+ /**
1637
+ * Represents a registry for command processors
1638
+ */
1639
+ interface ICliCommandProcessorRegistry {
1640
+ /**
1641
+ * The processors registered with the registry
1642
+ */
1643
+ readonly processors: ICliCommandProcessor[];
1644
+ /**
1645
+ * Find a processor for a command
1646
+ * @param mainCommand
1647
+ * @param chainCommands
1648
+ */
1649
+ findProcessor(mainCommand: string, chainCommands: string[]): ICliCommandProcessor | undefined;
1650
+ /**
1651
+ * Recursively searches for a processor matching the given command.
1652
+ * @param mainCommand The main command name.
1653
+ * @param chainCommands The remaining chain commands (if any).
1654
+ * @param processors The list of available processors.
1655
+ * @returns The matching processor or undefined if not found.
1656
+ */
1657
+ findProcessorInCollection(mainCommand: string, chainCommands: string[], processors: ICliCommandProcessor[]): ICliCommandProcessor | undefined;
1658
+ /**
1659
+ * Get the root processor for a child processor
1660
+ * @param child The child processor
1661
+ */
1662
+ getRootProcessor(child: ICliCommandChildProcessor): ICliCommandProcessor;
1663
+ /**
1664
+ * Register a processor
1665
+ * @param processor
1666
+ */
1667
+ registerProcessor(processor: ICliCommandProcessor): void;
1668
+ /**
1669
+ * Unregister a processor
1670
+ * @param processor
1671
+ */
1672
+ unregisterProcessor(processor: ICliCommandProcessor): void;
1673
+ }
1674
+ interface ICliExecutionProcess {
1675
+ /**
1676
+ * Indicates if the process has exited
1677
+ */
1678
+ exited?: boolean;
1679
+ /**
1680
+ * The exit code of the process
1681
+ */
1682
+ exitCode?: number;
1683
+ /**
1684
+ * Indicates if the process is running
1685
+ */
1686
+ running: boolean;
1687
+ /**
1688
+ * The data of the process
1689
+ */
1690
+ data: any | undefined;
1691
+ /**
1692
+ * Exit the process
1693
+ * @param code The exit code
1694
+ * @returns void
1695
+ */
1696
+ exit: (
1697
+ /**
1698
+ * The exit code
1699
+ */
1700
+ code?: number,
1701
+ /**
1702
+ * Options for exiting the process
1703
+ */
1704
+ options?: {
1705
+ /**
1706
+ * Indicates if the exit should be silent, i.e. not throw an error
1707
+ */
1708
+ silent?: boolean;
1709
+ }) => void;
1710
+ /**
1711
+ * Output data from the process
1712
+ * @param data The data to output
1713
+ */
1714
+ output(data: any): void;
1715
+ }
1716
+ /**
1717
+ * Represents a tracked CLI process entry
1718
+ */
1719
+ interface ICliProcessEntry {
1720
+ pid: number;
1721
+ command: string;
1722
+ startTime: number;
1723
+ status: 'running' | 'completed' | 'failed' | 'killed';
1724
+ exitCode?: number;
1725
+ }
1726
+ /**
1727
+ * Registry for tracking CLI processes
1728
+ */
1729
+ interface ICliProcessRegistry {
1730
+ /** Register a new process, returns assigned PID */
1731
+ register(command: string): {
1732
+ pid: number;
1733
+ abortController: AbortController;
1734
+ };
1735
+ /** Mark process as completed */
1736
+ complete(pid: number, exitCode: number): void;
1737
+ /** Mark process as failed */
1738
+ fail(pid: number): void;
1739
+ /** Kill a process by PID */
1740
+ kill(pid: number): boolean;
1741
+ /** List all processes (running + recent completed) */
1742
+ list(): ICliProcessEntry[];
1743
+ /** Get the current foreground process PID */
1744
+ readonly currentPid: number | undefined;
1745
+ }
1746
+ /**
1747
+ * Represents a key-value store for the CLI
1748
+ */
1749
+ interface ICliKeyValueStore {
1750
+ /**
1751
+ * Retrieves a value by key.
1752
+ * @param key - The key to retrieve the value for.
1753
+ * @returns A promise resolving to the value or undefined if not found.
1754
+ */
1755
+ get<T = any>(key: string): Promise<T | undefined>;
1756
+ /**
1757
+ * Sets a key-value pair in the store.
1758
+ * @param key - The key to set.
1759
+ * @param value - The value to store.
1760
+ * @returns A promise resolving when the value is stored.
1761
+ */
1762
+ set(key: string, value: any): Promise<void>;
1763
+ /**
1764
+ * Removes a key-value pair by key.
1765
+ * @param key - The key to remove.
1766
+ * @returns A promise resolving when the key is removed.
1767
+ */
1768
+ remove(key: string): Promise<void>;
1769
+ /**
1770
+ * Clears all key-value pairs from the store.
1771
+ * @returns A promise resolving when the store is cleared.
1772
+ */
1773
+ clear(): Promise<void>;
1774
+ }
1775
+ /**
1776
+ * Represents a store for storing data associated with commands
1777
+ */
1778
+ interface ICliStateStore {
1779
+ /**
1780
+ * Get the current state as an object.
1781
+ */
1782
+ getState<T extends CliState = CliState>(): T;
1783
+ /**
1784
+ * Update the state with new values. Supports partial updates.
1785
+ * @param newState Partial state to merge with the current state.
1786
+ */
1787
+ updateState(newState: Partial<CliState>): void;
1788
+ /**
1789
+ * Select a specific property or computed value from the state.
1790
+ * @param selector A function to project a slice of the state.
1791
+ * @returns Observable of the selected value.
1792
+ */
1793
+ select<K>(selector: (state: CliState) => K): Observable<K>;
1794
+ /**
1795
+ * Subscribe to state changes.
1796
+ * @param callback Callback function to handle state changes.
1797
+ * @returns Subscription object to manage the subscription.
1798
+ */
1799
+ subscribe(callback: (state: CliState) => void): Subscription;
1800
+ /**
1801
+ * Reset the state to its initial value.
1802
+ */
1803
+ reset(): void;
1804
+ /**
1805
+ * Persist the state to storage.
1806
+ */
1807
+ persist(): Promise<void>;
1808
+ /**
1809
+ * Initialize the state from storage.
1810
+ */
1811
+ initialize(): Promise<void>;
1812
+ }
1813
+ /**
1814
+ * Represents a service that pings the server
1815
+ */
1816
+ interface ICliPingServerService {
1817
+ /**
1818
+ * Pings the server
1819
+ */
1820
+ ping(): Promise<void>;
1821
+ }
1822
+ /**
1823
+ * Represents a module for the CLI
1824
+ */
1825
+ interface ICliModule {
1826
+ /**
1827
+ * API version this module targets.
1828
+ * Modules with apiVersion < 2 (or missing) are rejected by v2 runtimes.
1829
+ */
1830
+ apiVersion: number;
1831
+ /** Unique module identifier, e.g. '@qodalis/cli-guid' */
1832
+ name: string;
1833
+ /** Semver version string */
1834
+ version?: string;
1835
+ /** Human-readable description */
1836
+ description?: string;
1837
+ /** Module names this module depends on (resolved before this module boots) */
1838
+ dependencies?: string[];
1839
+ /** Boot priority — lower values boot first (default: 0) */
1840
+ priority?: number;
1841
+ /** Command processors provided by this module */
1842
+ processors?: ICliCommandProcessor[];
1843
+ /** Services registered into the shared service container */
1844
+ services?: CliProvider[];
1845
+ /** Module configuration, set via configure() */
1846
+ config?: Record<string, any>;
1847
+ /**
1848
+ * Per-locale translation maps shipped by this module.
1849
+ * Keyed by locale code (e.g. 'es', 'fr'), each value is a flat
1850
+ * key-value map of translation keys to translated strings.
1851
+ *
1852
+ * These are automatically registered with the translation service
1853
+ * during module boot — no manual onInit() code required.
1854
+ *
1855
+ * @example
1856
+ * translations: {
1857
+ * es: { 'cli.guid.description': 'Generar y validar UUIDs' },
1858
+ * fr: { 'cli.guid.description': 'Générer et valider des UUIDs' },
1859
+ * }
1860
+ */
1861
+ translations?: Record<string, Record<string, string>>;
1862
+ /**
1863
+ * Returns a configured copy of this module.
1864
+ * Modules should narrow the config type via a module-specific interface.
1865
+ */
1866
+ configure?(config: any): ICliModule;
1867
+ /** Called after services are registered and before processors are initialized */
1868
+ onInit?(context: ICliExecutionContext): Promise<void>;
1869
+ /**
1870
+ * Optional first-run setup flow. Called during boot if the module
1871
+ * has not been set up yet (determined by a persisted flag in the
1872
+ * key-value store). Use context.reader to prompt the user for
1873
+ * initial configuration.
1874
+ *
1875
+ * @returns true to mark setup as complete; false/throw to abort
1876
+ * (module still loads, setup re-triggers next boot).
1877
+ */
1878
+ onSetup?(context: ICliExecutionContext): Promise<boolean>;
1879
+ /** Called after all modules have booted and the terminal is interactive */
1880
+ onAfterBoot?(context: ICliExecutionContext): Promise<void>;
1881
+ /** Called when the module is being torn down */
1882
+ onDestroy?(context: ICliExecutionContext): Promise<void>;
1883
+ }
1884
+ /**
1885
+ * @deprecated Use ICliModule instead
1886
+ */
1887
+ type ICliUmdModule = ICliModule;
1888
+ /**
1889
+ * Represents a logger for the CLI
1890
+ */
1891
+ interface ICliLogger {
1892
+ /**
1893
+ * Set the log level of the logger
1894
+ * @param level The log level to set
1895
+ * @returns void
1896
+ * @default CliLogLevel.ERROR
1897
+ */
1898
+ setCliLogLevel(level: CliLogLevel): void;
1899
+ /**
1900
+ * Log a message
1901
+ * @param args The arguments to log
1902
+ */
1903
+ log(...args: any[]): void;
1904
+ /**
1905
+ * Log a message
1906
+ * @param args The arguments to log
1907
+ */
1908
+ info(...args: any[]): void;
1909
+ /**
1910
+ * Log a message
1911
+ * @param args The arguments to log
1912
+ */
1913
+ warn(...args: any[]): void;
1914
+ /**
1915
+ * Log a message
1916
+ * @param args The arguments to log
1917
+ */
1918
+ error(...args: any[]): void;
1919
+ /**
1920
+ * Log a message
1921
+ * @param args The arguments to log
1922
+ */
1923
+ debug(...args: any[]): void;
1924
+ }
1925
+ declare const ICliTranslationService_TOKEN = "cli-translation-service";
1926
+ /**
1927
+ * Provides internationalization (i18n) support for CLI strings.
1928
+ */
1929
+ interface ICliTranslationService {
1930
+ /**
1931
+ * Translate a key to the current locale.
1932
+ * @param key The translation key (e.g. 'cli.echo.description')
1933
+ * @param defaultValue The English fallback string (returned if no translation found)
1934
+ * @param params Optional interpolation parameters for `{param}` placeholders
1935
+ */
1936
+ t(key: string, defaultValue: string, params?: Record<string, string | number>): string;
1937
+ /**
1938
+ * Get the current locale code (e.g. 'en', 'es', 'fr').
1939
+ */
1940
+ getLocale(): string;
1941
+ /**
1942
+ * Set the active locale.
1943
+ * @param locale The locale code to switch to
1944
+ */
1945
+ setLocale(locale: string): void;
1946
+ /**
1947
+ * Register translations for a locale.
1948
+ * Can be called multiple times — translations are merged, with later calls overriding earlier ones.
1949
+ * @param locale The locale code
1950
+ * @param translations Flat key-value map of translation keys to translated strings
1951
+ */
1952
+ addTranslations(locale: string, translations: Record<string, string>): void;
1953
+ /**
1954
+ * Get all locale codes that have at least one registered translation.
1955
+ */
1956
+ getAvailableLocales(): string[];
1957
+ }
1958
+ /**
1959
+ * Represents a service provider for the CLI
1960
+ */
1961
+ interface ICliServiceProvider {
1962
+ /**
1963
+ * Get a service
1964
+ * @param service The service to get
1965
+ */
1966
+ get<T>(service: any): T;
1967
+ /**
1968
+ * Set a service
1969
+ * @param definition The definition of the service
1970
+ */
1971
+ set(definition: CliProvider | CliProvider[]): void;
1972
+ }
1973
+
1974
+ declare const ICliPermissionService_TOKEN = "cli-permission-service";
1975
+
1976
+ /**
1977
+ * Abstract permission service for checking rwx permissions on resources.
1978
+ * The default implementation lives in @qodalis/cli-users; consumers can
1979
+ * replace it via the DI container.
1980
+ */
1981
+ interface ICliPermissionService {
1982
+ /**
1983
+ * Check whether a user may perform an action on a resource.
1984
+ * @param user The acting user.
1985
+ * @param action The requested operation.
1986
+ * @param ownership Owner/group of the resource.
1987
+ * @param permissions Permission string (e.g. "rwxr-xr-x").
1988
+ * @returns true if allowed.
1989
+ */
1990
+ check(user: ICliUser, action: 'read' | 'write' | 'execute', ownership: ICliOwnership, permissions: string): boolean;
1991
+ /** Parse octal (e.g. "755") to a permission string (e.g. "rwxr-xr-x"). */
1992
+ parseOctal(octal: string): string;
1993
+ /** Convert a permission string (e.g. "rwxr-xr-x") to octal (e.g. "755"). */
1994
+ toOctal(permissions: string): string;
1995
+ }
1996
+
1997
+ /**
1998
+ * Registry that tracks loaded CLI modules and dispatches boot handlers
1999
+ * when new modules are registered (including dynamically via UMD).
2000
+ */
2001
+ declare class CliModuleRegistry {
2002
+ private readonly modules;
2003
+ private readonly bootHandlers;
2004
+ /**
2005
+ * Register a handler that is called whenever a new module is registered.
2006
+ */
2007
+ onModuleBoot(handler: (module: ICliModule) => Promise<void>): void;
2008
+ /**
2009
+ * Register a module and notify all boot handlers.
2010
+ * Modules that do not meet the required API version are silently skipped.
2011
+ */
2012
+ register(module: ICliModule): Promise<void>;
2013
+ /**
2014
+ * Get a module by name.
2015
+ */
2016
+ getModule(name: string): ICliModule | undefined;
2017
+ /**
2018
+ * Get all registered modules.
2019
+ */
2020
+ getAll(): ICliModule[];
2021
+ /**
2022
+ * Track a module without triggering boot handlers.
2023
+ * Used by the boot service for statically-provided modules that are
2024
+ * already being booted through the normal pipeline.
2025
+ */
2026
+ track(module: ICliModule): void;
2027
+ /**
2028
+ * Check if a module is registered.
2029
+ */
2030
+ has(name: string): boolean;
2031
+ }
2032
+
2033
+ declare const initializeBrowserEnvironment: ({ context, registry, }: {
2034
+ context: ICliExecutionContext;
2035
+ registry: CliModuleRegistry;
2036
+ }) => void;
2037
+ /**
2038
+ * Boot a CLI module by registering it with the global module registry.
2039
+ * Used by UMD entrypoints to register themselves when loaded dynamically.
2040
+ */
2041
+ declare const bootCliModule: (module: ICliModule) => Promise<void>;
2042
+ /**
2043
+ * @deprecated Use bootCliModule instead
2044
+ */
2045
+ declare const bootUmdModule: (module: ICliModule) => Promise<void>;
2046
+
2047
+ declare class ObjectDescriber {
2048
+ static describe(obj: any, options?: {
2049
+ filter?: (o: {
2050
+ funcName: string;
2051
+ func: any;
2052
+ args: string[];
2053
+ }) => boolean;
2054
+ }): ICliCommandProcessor[];
2055
+ static supportsDynamicArgs(func: any): boolean;
2056
+ static getFunctionArguments(func: any): string[];
2057
+ }
2058
+
2059
+ /**
2060
+ * Token for the configure command's state store.
2061
+ */
2062
+ declare const CLI_CONFIGURE_STORE_NAME = "configure";
2063
+ /**
2064
+ * Retrieves a configuration value for a given category and key
2065
+ * from a configuration state store.
2066
+ *
2067
+ * @param state The state store to read from (should be the 'configure' store)
2068
+ * @param category The category (processor command name or 'system')
2069
+ * @param key The configuration key
2070
+ * @param defaultValue Fallback value if not configured
2071
+ * @returns The configured value or the default
2072
+ */
2073
+ declare function getConfigValue<T = any>(state: ICliStateStore, category: string, key: string, defaultValue: T): T;
2074
+ /**
2075
+ * Resolves all configuration options from registered processors,
2076
+ * grouped by category.
2077
+ */
2078
+ declare function resolveConfigurationCategories(registry: ICliCommandProcessorRegistry): Map<string, {
2079
+ processorCommand: string;
2080
+ options: ICliConfigurationOption[];
2081
+ }>;
2082
+
2083
+ declare const delay: (ms: number) => Promise<void>;
2084
+
2085
+ /**
2086
+ * Clears the current line in the terminal, accounting for text that wraps across multiple lines.
2087
+ * @param terminal The xterm terminal instance
2088
+ * @param contentLength The total visible character count on the line (prompt + text)
2089
+ */
2090
+ declare const clearTerminalLine: (terminal: Terminal, contentLength: number) => void;
2091
+
2092
+ /**
2093
+ * Compares two dotted version strings.
2094
+ * Returns -1 if a < b, 0 if equal, 1 if a > b.
2095
+ */
2096
+ declare function compareVersions(a: string, b: string): -1 | 0 | 1;
2097
+ /**
2098
+ * Returns true if the installed version satisfies the minimum required version.
2099
+ */
2100
+ declare function satisfiesMinVersion(installed: string, required: string): boolean;
2101
+ /**
2102
+ * Returns true if the installed version satisfies the given semver range.
2103
+ * If range is undefined/empty, returns true (no constraint).
2104
+ * If range looks like a plain version (no operators), treats it as >= that version.
2105
+ */
2106
+ declare function satisfiesVersionRange(installed: string, range: string | undefined): boolean;
2107
+
2108
+ /**
2109
+ * Describes the version information returned by a CLI server's discovery endpoint.
2110
+ */
2111
+ interface ServerVersionInfo {
2112
+ supportedVersions: number[];
2113
+ preferredVersion: number;
2114
+ serverVersion: string;
2115
+ }
2116
+ /**
2117
+ * Negotiates the API version between a frontend CLI client and a backend server.
2118
+ *
2119
+ * Flow:
2120
+ * 1. Client calls `discover(baseUrl)` which hits `GET /api/cli/versions`
2121
+ * 2. Server returns supported versions
2122
+ * 3. Client picks the highest mutually supported version
2123
+ * 4. All subsequent calls use `/api/v{n}/cli/*`
2124
+ */
2125
+ declare class ServerVersionNegotiator {
2126
+ private static readonly CLIENT_SUPPORTED_VERSIONS;
2127
+ /**
2128
+ * Given a server's version info, pick the highest mutually compatible version.
2129
+ * Returns null if no compatible version exists.
2130
+ */
2131
+ static negotiate(serverInfo: ServerVersionInfo): number | null;
2132
+ /**
2133
+ * Discover the server's supported versions and negotiate the best match.
2134
+ * Returns the negotiated API version and the base path for all subsequent calls,
2135
+ * or null if the server is unreachable or incompatible.
2136
+ */
2137
+ static discover(baseUrl: string): Promise<{
2138
+ apiVersion: number;
2139
+ basePath: string;
2140
+ } | null>;
2141
+ }
2142
+
2143
+ /**
2144
+ * Derives CLI panel CSS custom property values from an xterm ITheme object.
2145
+ * Used when `syncTheme` is enabled on the panel config.
2146
+ */
2147
+ interface ThemeLike {
2148
+ background?: string;
2149
+ foreground?: string;
2150
+ cursor?: string;
2151
+ cyan?: string;
2152
+ blue?: string;
2153
+ magenta?: string;
2154
+ selectionBackground?: string;
2155
+ }
2156
+ /**
2157
+ * Derive CSS custom properties for the CLI panel from the active xterm theme.
2158
+ * Returns a record of property name → value that can be applied as inline styles.
2159
+ */
2160
+ declare function derivePanelThemeStyles(theme: ThemeLike): Record<string, string>;
2161
+
2162
+ /**
2163
+ * Load the user's saved panel position from localStorage.
2164
+ * Returns null if no preference is saved or localStorage is unavailable.
2165
+ */
2166
+ declare function loadPanelPosition(): CliPanelPosition | null;
2167
+ /**
2168
+ * Save the user's panel position preference to localStorage.
2169
+ */
2170
+ declare function savePanelPosition(position: CliPanelPosition): void;
2171
+ /**
2172
+ * Get the next position in the cycle: bottom -> right -> top -> left -> bottom
2173
+ */
2174
+ declare function nextPanelPosition(current: CliPanelPosition): CliPanelPosition;
2175
+
2176
+ declare const getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
2177
+ declare const formatJson: (json: any) => string;
2178
+ declare const colorizeJson: (jsonString: any) => string;
2179
+ declare const toQueryString: (params: Record<string, any>) => string;
2180
+ declare const highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
2181
+ declare const getRightOfWord: (command: string, word: string) => string | undefined;
2182
+ declare const colorFirstWord: (text: string, colorFunction: (word: string) => string) => string;
2183
+
2184
+ declare const utils: {
2185
+ getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
2186
+ formatJson: (json: any) => string;
2187
+ colorizeJson: (jsonString: any) => string;
2188
+ toQueryString: (params: Record<string, any>) => string;
2189
+ highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
2190
+ getRightOfWord: (command: string, word: string) => string | undefined;
2191
+ colorFirstWord: (text: string, colorFunction: (word: string) => string) => string;
2192
+ ObjectDescriber: typeof ObjectDescriber;
2193
+ delay: (ms: number) => Promise<void>;
2194
+ getConfigValue: typeof getConfigValue;
2195
+ resolveConfigurationCategories: typeof resolveConfigurationCategories;
2196
+ CLI_CONFIGURE_STORE_NAME: string;
2197
+ };
2198
+
2199
+ declare const DefaultLibraryAuthor: ICliCommandAuthor;
2200
+ declare const constants: {
2201
+ DefaultLibraryAuthor: ICliCommandAuthor;
2202
+ };
2203
+
2204
+ declare class CancellablePromise<T> {
2205
+ private executor;
2206
+ private hasCancelled;
2207
+ private abortController;
2208
+ constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void) => void);
2209
+ execute(): Promise<T>;
2210
+ cancel(): void;
2211
+ }
2212
+
2213
+ type CliThemeCategory = 'dark' | 'light';
2214
+ interface CliThemeInfo {
2215
+ theme: ITheme;
2216
+ category: CliThemeCategory;
2217
+ tags: string[];
2218
+ description: string;
2219
+ }
2220
+
2221
+ type CliTheme = ITheme;
2222
+ type DefaultThemesType = {
2223
+ default: CliTheme;
2224
+ classic: CliTheme;
2225
+ dracula: CliTheme;
2226
+ monokai: CliTheme;
2227
+ solarizedDark: CliTheme;
2228
+ solarizedLight: CliTheme;
2229
+ gruvboxDark: CliTheme;
2230
+ gruvboxLight: CliTheme;
2231
+ nord: CliTheme;
2232
+ oneDark: CliTheme;
2233
+ material: CliTheme;
2234
+ highContrastLight: CliTheme;
2235
+ tokyoNight: CliTheme;
2236
+ catppuccinMocha: CliTheme;
2237
+ catppuccinFrappe: CliTheme;
2238
+ rosePine: CliTheme;
2239
+ kanagawa: CliTheme;
2240
+ everforestDark: CliTheme;
2241
+ ayuDark: CliTheme;
2242
+ catppuccinLatte: CliTheme;
2243
+ rosePineDawn: CliTheme;
2244
+ everforestLight: CliTheme;
2245
+ githubLight: CliTheme;
2246
+ cyberpunk: CliTheme;
2247
+ retroGreen: CliTheme;
2248
+ retroAmber: CliTheme;
2249
+ matrix: CliTheme;
2250
+ synthwave: CliTheme;
2251
+ highContrastDark: CliTheme;
2252
+ yellow: CliTheme;
2253
+ [key: string]: CliTheme;
2254
+ };
2255
+ declare const DefaultThemes: DefaultThemesType;
2256
+
2257
+ declare const DefaultThemeInfos: Record<string, CliThemeInfo>;
2258
+
2259
+ declare const LIBRARY_VERSION = "2.0.0-beta.1";
2260
+ declare const API_VERSION = 2;
2261
+
2262
+ /**
2263
+ * Framework-agnostic token for the CLI user session service.
2264
+ * Used as a key in the service provider to retrieve the user session service.
2265
+ */
2266
+ declare const ICliUserSessionService_TOKEN = "cli-user-session-service";
2267
+ /**
2268
+ * Framework-agnostic token for the CLI users store service.
2269
+ * Used as a key in the service provider to retrieve the users store service.
2270
+ */
2271
+ declare const ICliUsersStoreService_TOKEN = "cli-users-store-service";
2272
+ /**
2273
+ * Framework-agnostic token for the CLI groups store service.
2274
+ * Used as a key in the service provider to retrieve the groups store service.
2275
+ */
2276
+ declare const ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
2277
+ /**
2278
+ * Framework-agnostic token for the CLI auth service.
2279
+ * Used as a key in the service provider to retrieve the auth service.
2280
+ */
2281
+ declare const ICliAuthService_TOKEN = "cli-auth-service";
2282
+
2283
+ /**
2284
+ * Context provided to worker service handlers inside a Web Worker.
2285
+ */
2286
+ interface WorkerServiceContext {
2287
+ /** Emit an event to the main thread */
2288
+ emit(event: Omit<ICliServiceEvent, 'timestamp'>): void;
2289
+ /** Log a message (forwarded to the main-thread log buffer) */
2290
+ log(message: string, level?: 'info' | 'warn' | 'error'): void;
2291
+ /** Update state on the main thread */
2292
+ updateState(patch: Record<string, unknown>): void;
2293
+ /** Create an interval that is auto-cleared on stop */
2294
+ createInterval(callback: () => void, ms: number): ICliManagedInterval;
2295
+ /** Create a timeout that is auto-cleared on stop */
2296
+ createTimeout(callback: () => void, ms: number): ICliManagedTimer;
2297
+ /** AbortSignal scoped to this service */
2298
+ signal: AbortSignal;
2299
+ }
2300
+ /**
2301
+ * Lightweight helper for authoring worker-compatible background services.
2302
+ * Call this at the top level of your worker script.
2303
+ */
2304
+ declare function createWorkerService(handlers: {
2305
+ onStart(ctx: WorkerServiceContext): Promise<void>;
2306
+ onStop?(): Promise<void>;
2307
+ }): void;
2308
+
2309
+ declare class BrowserFileTransferService implements ICliFileTransferService {
2310
+ readFile(_path: string): Promise<string | null>;
2311
+ writeFile(path: string, content: string): Promise<void>;
2312
+ listFiles(_path: string): Promise<ICliFileEntry[]>;
2313
+ exists(_path: string): Promise<boolean>;
2314
+ downloadToBrowser(filename: string, content: string | Blob): void;
2315
+ uploadFromBrowser(accept?: string): Promise<{
2316
+ name: string;
2317
+ content: string;
2318
+ } | null>;
2319
+ private _pickFile;
2320
+ }
2321
+
2322
+ export { API_VERSION, BrowserFileTransferService, CLI_CONFIGURE_STORE_NAME, CancellablePromise, type CliAddUser, CliBackgroundColor, type CliBackgroundServiceStatus, type CliBackgroundServiceType, type CliEngineSnapshot, type CliFactoryProvider, CliForegroundColor, CliIcon, CliLogLevel, CliModuleRegistry, type CliMultiSelectOption, type CliOptions, type CliPackageSource, type CliPanelConfig, type CliPanelHideAlignment, type CliPanelPosition, type CliPercentageProgressBarUpdateValueOptions, type CliProcessCommand, type CliProcessorMetadata, type CliProvider, type CliSelectOption, type CliServerCapabilities, type CliServerCommandDescriptor, type CliServerConfig, type CliServerOutput, type CliServerResponse, type CliServiceEventHandler, type CliServiceExecutionMode, type CliState, type CliStateConfiguration, type CliTextAnimatorOptions, type CliTheme, type CliThemeCategory, type CliThemeInfo, type CliTypeProvider, type CliUpdateUser, type CliValueProvider, type CliWorkerInboundMessage, type CliWorkerOutboundMessage, DEFAULT_DIR_PERMISSIONS, DEFAULT_FILE_PERMISSIONS, DefaultLibraryAuthor, DefaultThemeInfos, DefaultThemes, type ICliAuthService, ICliAuthService_TOKEN, type ICliBackgroundService, type ICliBackgroundServiceInfo, type ICliBackgroundServiceRegistry, type ICliClipboard, type ICliCommandAuthor, type ICliCommandChildProcessor, type ICliCommandExecutorService, type ICliCommandParameterDescriptor, type ICliCommandProcessor, type ICliCommandProcessorRegistry, type ICliCompletionContext, type ICliCompletionProvider, ICliCompletionProvider_TOKEN, type ICliConfigurationOption, type ICliDragDropService, ICliDragDropService_TOKEN, type ICliExecutionContext, type ICliExecutionProcess, type ICliFileEntry, type ICliFileTransferService, ICliFileTransferService_TOKEN, type ICliGlobalParameterHandler, type ICliGroup, type ICliGroupsStoreService, ICliGroupsStoreService_TOKEN, type ICliInputReader, type ICliKeyValueStore, type ICliLogger, type ICliManagedInterval, type ICliManagedTimer, type ICliModule, type ICliOwnership, type ICliPercentageProgressBar, type ICliPermissionService, ICliPermissionService_TOKEN, type ICliPingServerService, type ICliProcessEntry, type ICliProcessRegistry, type ICliProcessorHook, type ICliProgressBar, type ICliServiceContext, type ICliServiceEvent, type ICliServiceLogEntry, type ICliServiceProvider, type ICliSpinner, type ICliStateStore, type ICliTerminalWriter, type ICliTextAnimator, type ICliTranslationService, ICliTranslationService_TOKEN, type ICliUmdModule, type ICliUser, type ICliUserCredentials, type ICliUserSession, type ICliUserSessionService, ICliUserSessionService_TOKEN, type ICliUsersStoreService, ICliUsersStoreService_TOKEN, LIBRARY_VERSION, ObjectDescriber, type Package, type ServerVersionInfo, ServerVersionNegotiator, type WorkerServiceContext, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, toQueryString, utils };