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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/public-api.d.mts CHANGED
@@ -1,112 +1,16 @@
1
1
  import { ITerminalOptions, ITerminalInitOnlyOptions, Terminal, ITheme } from '@xterm/xterm';
2
2
  import { Subject, Observable, Subscription } from 'rxjs';
3
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
4
  type CliProcessCommand = {
104
5
  /**
105
6
  * The command that was entered
106
7
  */
107
8
  command: string;
108
9
  /**
109
- * The data that was entered
10
+ * Pipeline data passed from the previous command in a pipe chain.
11
+ * When commands are piped (e.g. `cmd1 | cmd2`), the output of `cmd1`
12
+ * is captured and passed here as input to `cmd2`. The shape depends
13
+ * on what the upstream command produced (string, JSON object, array, etc.).
110
14
  */
111
15
  data?: any;
112
16
  /**
@@ -126,6 +30,7 @@ type CliProcessCommand = {
126
30
  */
127
31
  args: Record<string, any>;
128
32
  };
33
+
129
34
  declare enum CliForegroundColor {
130
35
  Black = "\u001B[30m",
131
36
  Red = "\u001B[31m",
@@ -147,174 +52,124 @@ declare enum CliBackgroundColor {
147
52
  Cyan = "\u001B[46m",
148
53
  White = "\u001B[47m"
149
54
  }
55
+
150
56
  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",
57
+ CheckIcon = "\u2714",// Success, completion
58
+ CrossIcon = "\u2718",// Failure, error
59
+ InfoIcon = "\u2139",// Information
60
+ WarningIcon = "\u26A0",// Warning
61
+ QuestionMark = "?",// Help or unknown state
62
+ Exclamation = "\u2757",// Emphasis or alert
63
+ Ellipsis = "\u2026",// Loading or truncated text
64
+ Dot = "\u2022",// List item
65
+ Bullet = "\u2023",// Alternate bullet point
66
+ ArrowRight = "\u2192",// Navigation or next step
67
+ ArrowLeft = "\u2190",// Previous step or navigation
68
+ ArrowUp = "\u2191",// Up direction
69
+ ArrowDown = "\u2193",// Down direction
70
+ ArrowRightFilled = "\u25B6",// Navigation or next step (filled)
71
+ ArrowLeftFilled = "\u25C0",// Previous step or navigation (filled)
72
+ ArrowUpFilled = "\u25B2",// Up direction (filled)
73
+ ArrowDownFilled = "\u25BC",// Down direction (filled)
74
+ DoubleArrowRight = "\u00BB",// Fast forward or next
75
+ DoubleArrowLeft = "\u00AB",// Rewind or previous
76
+ Star = "\u2605",// Highlight or favorite (filled)
77
+ StarEmpty = "\u2606",// Highlight or favorite (empty)
78
+ Plus = "+",// Addition or increment
79
+ Minus = "-",// Subtraction or decrement
80
+ Progress = "\u23F3",// Indicating progress
81
+ Success = "\u2705",// Success (alternative to CheckIcon)
82
+ Failure = "\u274C",// Failure (alternative to CrossIcon)
83
+ Clock = "\u23F0",// Time-related
84
+ Timer = "\u23F1",// Stopwatch or timer
85
+ Alarm = "\uD83D\uDD14",// Alarm or alert
86
+ Calendar = "\uD83D\uDCC5",// Calendar or date
87
+ Folder = "\uD83D\uDCC1",// Directory or file grouping
88
+ FolderOpen = "\uD83D\uDCC2",// Open folder
89
+ File = "\uD83D\uDCC4",// File or document
90
+ Archive = "\uD83D\uDDC3",// Archive or file grouping
91
+ Link = "\uD83D\uDD17",// Hyperlink or connection
92
+ Chain = "\u26D3",// Chain or linked
93
+ Bookmark = "\uD83D\uDD16",// Bookmark or save
94
+ Edit = "\u270F",// Edit or modify
95
+ Trash = "\uD83D\uDDD1",// Deletion or removal
96
+ Add = "\u2795",// Add user or item
97
+ Remove = "\u2796",// Remove user or item
98
+ Reload = "\uD83D\uDD04",// Refresh or reload
99
+ Save = "\uD83D\uDCBE",// Save or store
100
+ Undo = "\u21A9",// Undo action
101
+ Redo = "\u21AA",// Redo action
102
+ Play = "\u25B6",// Start or play
103
+ Pause = "\u23F8",// Pause or stop temporarily
104
+ Stop = "\u23F9",// Stop or end
105
+ Cancel = "\u274E",// Cancel or close
106
+ User = "\uD83D\uDC64",// User or profile
107
+ Group = "\uD83D\uDC65",// Group or team
108
+ Lock = "\uD83D\uDD12",// Secured or locked
109
+ Unlock = "\uD83D\uDD13",// Unlocked or accessible
110
+ Help = "\u2753",// Help or support
111
+ Key = "\uD83D\uDD11",// Authentication or key
112
+ Shield = "\uD83D\uDEE1",// Security or protection
113
+ Gear = "\u2699",// Settings or configuration
114
+ Settings = "\u2699\uFE0F",// Settings (alternative)
115
+ Theme = "\uD83C\uDFA8",// Theme or appearance
116
+ Light = "\uD83D\uDCA1",// Light mode
117
+ Bug = "\uD83D\uDC1E",// Bug or issue
118
+ Wrench = "\uD83D\uDD27",// Maintenance or tools
119
+ Hammer = "\uD83D\uDD28",// Build or fix
120
+ Terminal = "\uD83D\uDCBB",// Terminal or command line
121
+ Database = "\uD83D\uDDC4",// Database or storage
122
+ Server = "\uD83D\uDDA5",// Server or host
123
+ Cloud = "\u2601",// Cloud or remote
124
+ Network = "\uD83C\uDF10",// Network or connection
125
+ Monitor = "\uD83D\uDCFA",// Monitor or display
126
+ Printer = "\uD83D\uDDA8",// Printer or output
127
+ USB = "\uD83D\uDD0C",// USB or connection
128
+ Speaker = "\uD83D\uDD0A",// Speaker or audio
129
+ Microphone = "\uD83C\uDF99",// Microphone or input
130
+ Camera = "\uD83D\uDCF7",// Camera or video
131
+ Video = "\uD83C\uDFA5",// Video or media
132
+ Music = "\uD83C\uDFB5",// Music or audio
133
+ Phone = "\uD83D\uDCDE",// Phone or communication
134
+ Package = "\uD83D\uDCE6",// Package or bundle
135
+ Plugin = "\uD83E\uDDE9",// Plugin or extension
136
+ Extension = "\uD83D\uDD0C",// Extension or connection
137
+ Module = "\uD83E\uDDF1",// Module or package
138
+ Evaluate = "\uD83D\uDD0D",// Evaluate or search
139
+ Variable = "\uD835\uDC65",// Variable or setting
140
+ Script = "\uD83D\uDCDC",// Script or code
141
+ Code = "\uD83D\uDCDD",// Code or file
142
+ Logs = "\uD83D\uDCCB",// Logs or history
143
+ Power = "\u23FB",// On/Off state
144
+ Heart = "\u2764",// Love or favorite
145
+ Flame = "\uD83D\uDD25",// Trending or hot
146
+ Growth = "\uD83D\uDCC8",// Growth or increase
147
+ Decline = "\uD83D\uDCC9",// Decline or decrease
148
+ WarningFilled = "\u26A0\uFE0F",// Warning (filled)
149
+ Sun = "\u2600",// Brightness or day
150
+ Moon = "\uD83C\uDF19",// Night or dark mode
151
+ Rain = "\uD83C\uDF27",// Rain or bad weather
152
+ Snow = "\u2744",// Snow or cold
153
+ Lightning = "\u26A1",// Lightning or danger
154
+ Tree = "\uD83C\uDF32",// Nature or environment
155
+ Smile = "\uD83D\uDE0A",// Happiness or positive state
156
+ Sad = "\uD83D\uDE22",// Sadness or negative state
157
+ Angry = "\uD83D\uDE21",// Anger or frustration
158
+ Clap = "\uD83D\uDC4F",// Applause or celebration
159
+ ThumbsUp = "\uD83D\uDC4D",// Approval or success
160
+ ThumbsDown = "\uD83D\uDC4E",// Disapproval or failure
161
+ Rocket = "\uD83D\uDE80",// Launch or deploy
162
+ Globe = "\uD83C\uDF0D",// Earth or international
163
+ Medal = "\uD83C\uDFC5",// Achievement or award
164
+ Trophy = "\uD83C\uDFC6",// Winner or champion
165
+ Flag = "\uD83D\uDEA9",// Mark or flag
166
+ StarFilled = "\u2B50",// Highlight or favorite
167
+ StarOutline = "\u2729",// Alternate star icon
168
+ Fireworks = "\uD83C\uDF86",// Celebration
169
+ Balloon = "\uD83C\uDF88",// Party or fun
264
170
  Gift = "\uD83C\uDF81"
265
171
  }
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
- };
172
+
318
173
  /**
319
174
  * Configuration for a remote CLI server
320
175
  */
@@ -363,7 +218,7 @@ type CliServerResponse = {
363
218
  outputs: CliServerOutput[];
364
219
  };
365
220
  /**
366
- * Metadata about a remote command processor, returned by GET /api/cli/commands
221
+ * Metadata about a remote command processor, returned by GET /api/qcli/commands
367
222
  */
368
223
  type CliServerCommandDescriptor = {
369
224
  command: string;
@@ -380,7 +235,7 @@ type CliServerCommandDescriptor = {
380
235
  processors?: CliServerCommandDescriptor[];
381
236
  };
382
237
  /**
383
- * Server capabilities returned by GET /api/cli/capabilities
238
+ * Server capabilities returned by GET /api/qcli/capabilities
384
239
  */
385
240
  type CliServerCapabilities = {
386
241
  /** Whether this server supports remote shell access */
@@ -391,6 +246,80 @@ type CliServerCapabilities = {
391
246
  shellPath?: string;
392
247
  /** Server version string */
393
248
  version?: string;
249
+ /** Whether this server supports SSE streaming execution */
250
+ streaming?: boolean;
251
+ };
252
+
253
+ /**
254
+ * Represents a package source for the CLI package manager
255
+ */
256
+ interface CliPackageSource {
257
+ /**
258
+ * The name of the source, e.g. 'local', 'unpkg', 'jsdelivr'
259
+ */
260
+ name: string;
261
+ /**
262
+ * The base URL for fetching package files, e.g. 'http://localhost:3000/'
263
+ */
264
+ url: string;
265
+ /**
266
+ * The kind of source.
267
+ * - 'registry': npm-compatible registry with search API (e.g. npmjs.org, Verdaccio)
268
+ * - 'file': static file server, packages are discovered by probing known paths
269
+ * @default 'file'
270
+ */
271
+ kind?: 'registry' | 'file';
272
+ }
273
+ /**
274
+ * Represents a log level for the CLI
275
+ */
276
+ declare enum CliLogLevel {
277
+ None = 0,
278
+ DEBUG = 1,
279
+ LOG = 2,
280
+ INFO = 3,
281
+ WARN = 4,
282
+ ERROR = 5
283
+ }
284
+ /**
285
+ * Options for the CLI
286
+ */
287
+ type CliOptions = Record<string, any> & {
288
+ /**
289
+ * Custom terminal options
290
+ */
291
+ terminalOptions?: ITerminalOptions & ITerminalInitOnlyOptions;
292
+ /**
293
+ * The minimum log level to display
294
+ */
295
+ logLevel?: CliLogLevel;
296
+ /**
297
+ * Custom package sources for the package manager.
298
+ * Built-in sources (unpkg, jsdelivr) are always available.
299
+ */
300
+ packageSources?: {
301
+ /**
302
+ * Name of the primary source. Defaults to 'unpkg'.
303
+ */
304
+ primary?: string;
305
+ /**
306
+ * Additional custom sources
307
+ */
308
+ sources?: CliPackageSource[];
309
+ };
310
+ /**
311
+ * Remote CLI servers to connect to.
312
+ * Commands from each server are discovered and registered as proxy processors.
313
+ */
314
+ servers?: CliServerConfig[];
315
+ /**
316
+ * Whether the `eval` / `js` / `calc` command is enabled.
317
+ * Disabled by default because it runs arbitrary JavaScript via `eval()`
318
+ * in the host page context — a security risk in multi-tenant or
319
+ * user-facing deployments.
320
+ * @default false
321
+ */
322
+ allowEval?: boolean;
394
323
  };
395
324
  /**
396
325
  * Represents a package that can be installed
@@ -468,24 +397,20 @@ type CliStateConfiguration = {
468
397
  */
469
398
  storeName?: string;
470
399
  };
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
400
  type CliState = Record<string, any>;
483
401
  /**
484
402
  * Position of the CLI panel relative to the viewport edge.
403
+ * - `'bottom'` — anchored to the bottom (default)
404
+ * - `'top'` — anchored to the top
405
+ * - `'left'` — anchored to the left (vertical layout)
406
+ * - `'right'` — anchored to the right (vertical layout)
485
407
  */
486
408
  type CliPanelPosition = 'bottom' | 'top' | 'left' | 'right';
487
409
  /**
488
410
  * Alignment of the hidden-mode tab along its viewport edge.
411
+ * - `'start'` — left for horizontal panels, top for vertical panels
412
+ * - `'center'` — centered along the edge (default)
413
+ * - `'end'` — right for horizontal panels, bottom for vertical panels
489
414
  */
490
415
  type CliPanelHideAlignment = 'start' | 'center' | 'end';
491
416
  /**
@@ -538,175 +463,632 @@ interface CliPanelConfig {
538
463
  */
539
464
  syncTheme?: boolean;
540
465
  }
541
- declare const enums: {
542
- CliForegroundColor: typeof CliForegroundColor;
543
- CliBackgroundColor: typeof CliBackgroundColor;
544
- CliIcon: typeof CliIcon;
545
- CliLogLevel: typeof CliLogLevel;
466
+
467
+ type MultiServices = {
468
+ /**
469
+ * When true, injector returns an array of instances. This is useful to allow multiple
470
+ * providers spread across many files to provide configuration information to a common token.
471
+ */
472
+ multi?: boolean;
473
+ };
474
+ type CliValueProvider = MultiServices & {
475
+ useValue: any;
476
+ };
477
+ type CliTypeProvider = MultiServices & {
478
+ useClass: any;
479
+ };
480
+ type CliFactoryProvider = MultiServices & {
481
+ useFactory: Function;
546
482
  };
483
+ type CliProvider = {
484
+ provide: any;
485
+ } & (CliValueProvider | CliTypeProvider | CliFactoryProvider) & Record<string, any>;
547
486
 
548
487
  /**
549
- * Represents an option for the readSelect prompt.
488
+ * Represents a user in the CLI
550
489
  */
551
- interface CliSelectOption {
552
- /** Display text shown to the user */
553
- label: string;
554
- /** Value returned when this option is selected */
555
- value: string;
490
+ interface ICliUser {
491
+ /** Unique user identifier */
492
+ id: string;
493
+ /** Login name (unique) */
494
+ name: string;
495
+ /** Email address (unique) */
496
+ email: string;
497
+ /** Group IDs this user belongs to */
498
+ groups: string[];
499
+ /** Virtual home directory path, e.g. /home/root */
500
+ homeDir?: string;
501
+ /** Account creation timestamp */
502
+ createdAt: number;
503
+ /** Last modification timestamp */
504
+ updatedAt: number;
505
+ /** Whether the account is locked */
506
+ disabled?: boolean;
556
507
  }
557
508
  /**
558
- * Represents an option for the readMultiSelect prompt.
509
+ * Represents user credentials (shadow pattern — stored separately from ICliUser)
559
510
  */
560
- interface CliMultiSelectOption extends CliSelectOption {
561
- /** Whether the option is pre-selected */
562
- checked?: boolean;
511
+ interface ICliUserCredentials {
512
+ /** The user ID this credential belongs to */
513
+ userId: string;
514
+ /** SHA-256 hash of salt + password */
515
+ passwordHash: string;
516
+ /** Random salt for this user */
517
+ salt: string;
518
+ /** Timestamp of last password change */
519
+ lastChanged: number;
563
520
  }
564
521
  /**
565
- * Provides interactive input reading from the terminal.
566
- * All methods resolve with `null` when the user aborts (Ctrl+C or Escape).
522
+ * Represents a group in the CLI
567
523
  */
568
- interface ICliInputReader {
524
+ interface ICliGroup {
525
+ /** Unique group identifier */
526
+ id: string;
527
+ /** Group name (unique) */
528
+ name: string;
529
+ /** Optional group description */
530
+ description?: string;
531
+ /** Group creation timestamp */
532
+ createdAt: number;
533
+ }
534
+ /**
535
+ * Represents an active user session
536
+ */
537
+ interface ICliUserSession {
538
+ /** The user associated with this session */
539
+ user: ICliUser;
540
+ /** Pre-computed display name for the prompt (set by users module) */
541
+ displayName?: string;
542
+ /** Timestamp when the session started */
543
+ loginTime: number;
544
+ /** Timestamp of last activity */
545
+ lastActivity: number;
546
+ /** Extensible data (tokens, metadata, etc.) */
547
+ data?: Record<string, any>;
548
+ }
549
+ /** Fields required to create a new user */
550
+ type CliAddUser = Omit<ICliUser, 'id' | 'createdAt' | 'updatedAt'>;
551
+ /** Fields that can be updated on a user */
552
+ type CliUpdateUser = Partial<Omit<ICliUser, 'id' | 'createdAt'>>;
553
+
554
+ /** Ownership metadata attached to files, directories, or other resources */
555
+ interface ICliOwnership {
556
+ /** User ID of the owner */
557
+ uid: string;
558
+ /** Primary group name */
559
+ gid: string;
560
+ }
561
+ /** Default file permissions: rw-r--r-- (644) */
562
+ declare const DEFAULT_FILE_PERMISSIONS = "rw-r--r--";
563
+ /** Default directory permissions: rwxr-xr-x (755) */
564
+ declare const DEFAULT_DIR_PERMISSIONS = "rwxr-xr-x";
565
+
566
+ declare const enums: {
567
+ CliForegroundColor: typeof CliForegroundColor;
568
+ CliBackgroundColor: typeof CliBackgroundColor;
569
+ CliIcon: typeof CliIcon;
570
+ CliLogLevel: typeof CliLogLevel;
571
+ };
572
+
573
+ interface CliTableOptions {
574
+ /** Expand columns to fill the full terminal width. Default: false */
575
+ fullWidth?: boolean;
576
+ }
577
+ interface ICliTerminalWriter {
578
+ /**
579
+ * Write text to the terminal
580
+ * @param text The text to write
581
+ */
582
+ write(text: string): void;
569
583
  /**
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
584
+ * Write text to the terminal followed by a newline
585
+ * @param text The text to write
573
586
  */
574
- readLine(prompt: string): Promise<string | null>;
587
+ writeln(text?: string): void;
575
588
  /**
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
589
+ * Write a success message to the terminal
590
+ * @param message The message to write
579
591
  */
580
- readPassword(prompt: string): Promise<string | null>;
592
+ writeSuccess(message: string): void;
581
593
  /**
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
594
+ * Write an info message to the terminal
595
+ * @param message The message to write
586
596
  */
587
- readConfirm(prompt: string, defaultValue?: boolean): Promise<boolean | null>;
597
+ writeInfo(message: string): void;
588
598
  /**
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
599
+ * Write an error message to the terminal
600
+ * @param message The message to write
594
601
  */
595
- readSelect(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
602
+ writeError(message: string): void;
596
603
  /**
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
604
+ * Write a warning message to the terminal
605
+ * @param message The message to write
603
606
  */
604
- readSelectInline(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
607
+ writeWarning(message: string): void;
605
608
  /**
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
609
+ * Wrap text in the specified foreground color.
610
+ * @param text The text to wrap
611
+ * @param color The foreground color to apply
612
+ * @returns The text wrapped in ANSI color codes
611
613
  */
612
- readMultiSelect(prompt: string, options: CliMultiSelectOption[]): Promise<string[] | null>;
614
+ wrapInColor(text: string, color: CliForegroundColor): string;
613
615
  /**
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
616
+ * Wrap text in the specified background color.
617
+ * @param text The text to wrap
618
+ * @param color The background color to apply
619
+ * @returns The text wrapped in ANSI background color codes
620
+ */
621
+ wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
622
+ /**
623
+ * Write a JSON object to the terminal
624
+ * @param json The JSON object to write
625
+ */
626
+ writeJson(json: any): void;
627
+ /**
628
+ * Write content to a file (triggers a browser download)
629
+ * @param fileName The name of the file to download
630
+ * @param content The content to write to the file
631
+ */
632
+ writeToFile(fileName: string, content: string): void;
633
+ /**
634
+ * Write an object array as a table to the terminal
635
+ * @param objects The objects to write to the table
636
+ */
637
+ writeObjectsAsTable(objects: any[]): void;
638
+ /**
639
+ * Write a table to the terminal
640
+ * @param headers The headers of the table
641
+ * @param rows The rows of the table
642
+ * @param options Optional table rendering options
618
643
  */
619
- readNumber(prompt: string, options?: {
620
- min?: number;
621
- max?: number;
622
- default?: number;
623
- }): Promise<number | null>;
644
+ writeTable(headers: string[], rows: string[][], options?: CliTableOptions): void;
645
+ /**
646
+ * Write a divider to the terminal
647
+ * @param options Optional: color, length, character
648
+ */
649
+ writeDivider(options?: {
650
+ color?: CliForegroundColor;
651
+ length?: number;
652
+ char?: string;
653
+ }): void;
654
+ /**
655
+ * Write a list of items to the terminal with bullet, numbered, or custom prefix.
656
+ * @param items The list items to display
657
+ * @param options Optional: ordered (numbered), prefix (custom marker), color
658
+ */
659
+ writeList(items: string[], options?: {
660
+ ordered?: boolean;
661
+ prefix?: string;
662
+ color?: CliForegroundColor;
663
+ }): void;
664
+ /**
665
+ * Write aligned key-value pairs to the terminal.
666
+ * @param entries Key-value pairs as a Record or array of tuples
667
+ * @param options Optional: separator string, key color
668
+ */
669
+ writeKeyValue(entries: Record<string, string> | [string, string][], options?: {
670
+ separator?: string;
671
+ keyColor?: CliForegroundColor;
672
+ }): void;
673
+ /**
674
+ * Write items in a multi-column layout.
675
+ * @param items The items to arrange in columns
676
+ * @param options Optional: number of columns, padding between columns
677
+ */
678
+ writeColumns(items: string[], options?: {
679
+ columns?: number;
680
+ padding?: number;
681
+ }): void;
682
+ /**
683
+ * Write a clickable hyperlink using OSC 8 escape sequences.
684
+ * In terminals that support OSC 8, the text is clickable. In others,
685
+ * it falls back to displaying "text (url)".
686
+ * @param text The visible link text
687
+ * @param url The URL to link to
688
+ */
689
+ writeLink(text: string, url: string): void;
690
+ /**
691
+ * Write text inside a bordered box.
692
+ * Useful for callouts, notices, and highlighted information.
693
+ * @param content The content lines to display inside the box
694
+ * @param options Optional: title, border color, padding
695
+ */
696
+ writeBox(content: string | string[], options?: {
697
+ title?: string;
698
+ borderColor?: CliForegroundColor;
699
+ padding?: number;
700
+ }): void;
701
+ /**
702
+ * Write text with a specified indentation level.
703
+ * Each level adds 2 spaces of indentation.
704
+ * @param text The text to write
705
+ * @param level The indentation level (default: 1)
706
+ */
707
+ writeIndented(text: string, level?: number): void;
624
708
  }
625
709
 
626
710
  /**
627
- * Whether a background service is a long-running daemon or a one-shot job.
711
+ * Represents a clipboard for the CLI
628
712
  */
629
- type CliBackgroundServiceType = 'daemon' | 'job';
713
+ interface ICliClipboard {
714
+ /**
715
+ * Write text to the clipboard
716
+ * @param text The text to write to the clipboard
717
+ * @returns void
718
+ */
719
+ write: (text: string) => Promise<void>;
720
+ /**
721
+ * Read text from the clipboard
722
+ * @returns The text read from the clipboard
723
+ */
724
+ read: () => Promise<string>;
725
+ }
726
+
630
727
  /**
631
- * Lifecycle status of a background service.
728
+ * Token for the CLI user session service.
632
729
  */
633
- type CliBackgroundServiceStatus = 'pending' | 'running' | 'stopped' | 'failed' | 'done';
730
+ declare const ICliUserSessionService_TOKEN = "cli-user-session-service";
634
731
  /**
635
- * Where the service code is executing.
732
+ * Token for the CLI users store service.
636
733
  */
637
- type CliServiceExecutionMode = 'main-thread' | 'worker';
734
+ declare const ICliUsersStoreService_TOKEN = "cli-users-store-service";
638
735
  /**
639
- * An event emitted by a background service.
640
- * Services control terminal notification visibility by setting `data.notify: true`.
736
+ * Token for the CLI groups store service.
641
737
  */
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
- }
738
+ declare const ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
652
739
  /**
653
- * Handler function for service events.
740
+ * Token for the CLI auth service.
654
741
  */
655
- type CliServiceEventHandler = (event: ICliServiceEvent) => void;
742
+ declare const ICliAuthService_TOKEN = "cli-auth-service";
656
743
  /**
657
- * A single log entry from a background service.
744
+ * Token for registering completion providers via module services (multi: true).
658
745
  */
659
- interface ICliServiceLogEntry {
660
- timestamp: Date;
661
- level: 'info' | 'warn' | 'error';
662
- message: string;
663
- }
746
+ declare const ICliCompletionProvider_TOKEN = "cli-completion-provider";
664
747
  /**
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).
748
+ * Token for the drag-and-drop service.
668
749
  */
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
- }
750
+ declare const ICliDragDropService_TOKEN = "cli-drag-drop-service";
685
751
  /**
686
- * A background service that can run as a daemon or job.
752
+ * Token for the file transfer service.
687
753
  */
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;
754
+ declare const ICliFileTransferService_TOKEN = "cli-file-transfer-service";
755
+ /**
756
+ * Token for the translation service.
757
+ */
758
+ declare const ICliTranslationService_TOKEN = "cli-translation-service";
759
+ /**
760
+ * Token for the permission service.
761
+ */
762
+ declare const ICliPermissionService_TOKEN = "cli-permission-service";
763
+ /**
764
+ * Token for the file picker provider.
765
+ */
766
+ declare const ICliFilePickerProvider_TOKEN = "cli-file-picker-provider";
767
+
768
+ /**
769
+ * Options for readFile file picker.
770
+ */
771
+ interface CliFilePickerOptions {
772
+ /** Allow selecting multiple files. Default: false. */
773
+ multiple?: boolean;
774
+ /**
775
+ * File type filter. Accepts MIME types (e.g. 'image/*') or extensions
776
+ * (e.g. '.json,.txt'). Maps to the HTML accept attribute in browsers
777
+ * and file filter in Electron.
778
+ */
779
+ accept?: string;
780
+ /**
781
+ * When true, pick a directory instead of files. Default: false.
782
+ * Cannot be combined with `multiple` — if both are set, `directory` takes precedence
783
+ * and a single directory is returned.
784
+ */
785
+ directory?: boolean;
786
+ /**
787
+ * How to read file content. Default: 'text'.
788
+ * - 'text': Read as UTF-8 string (suitable for text files)
789
+ * - 'arraybuffer': Read as ArrayBuffer (suitable for binary files like images)
790
+ */
791
+ readAs?: 'text' | 'arraybuffer';
792
+ }
793
+ /**
794
+ * Result returned by readFile for each selected file.
795
+ */
796
+ interface CliFileResult {
797
+ /** File name without path (e.g. 'config.json') */
798
+ name: string;
799
+ /** Full file path. Available in Electron, undefined in browser. */
800
+ path?: string;
801
+ /**
802
+ * File content. Type depends on `CliFilePickerOptions.readAs`:
803
+ * - 'text' (default): `string` (UTF-8 decoded)
804
+ * - 'arraybuffer': `ArrayBuffer` (raw bytes)
805
+ */
806
+ content: string | ArrayBuffer;
807
+ /** File size in bytes */
808
+ size: number;
809
+ /** MIME type (e.g. 'application/json', 'image/png') */
810
+ type: string;
811
+ }
812
+ /**
813
+ * Abstraction for environment-specific file picking.
814
+ * Implementations handle the actual dialog interaction for their environment.
815
+ */
816
+ interface ICliFilePickerProvider {
817
+ /** Whether file picking is supported in this environment */
818
+ readonly isSupported: boolean;
819
+ /**
820
+ * Open a file picker dialog and return selected files.
821
+ * @returns Array of selected files, or null if the user cancelled
822
+ */
823
+ pickFiles(options?: CliFilePickerOptions): Promise<CliFileResult[] | null>;
824
+ /**
825
+ * Open a directory picker dialog and return the selected directory.
826
+ * @returns The selected directory, or null if the user cancelled
827
+ */
828
+ pickDirectory(): Promise<CliFileResult | null>;
829
+ }
830
+
831
+ /**
832
+ * Represents an option for the readSelect and readSelectInline prompts.
833
+ */
834
+ interface CliSelectOption {
835
+ /** Display text shown to the user */
836
+ label: string;
837
+ /** Value returned when this option is selected */
838
+ value: string;
839
+ /** Optional description shown as dimmed italic text after the label */
840
+ description?: string;
841
+ /** Group name — options sharing the same group are displayed under a group header */
842
+ group?: string;
843
+ /** When true, the option is visible but cannot be selected (rendered dimmed) */
844
+ disabled?: boolean;
845
+ }
846
+ /**
847
+ * Represents an option for the readMultiSelect prompt.
848
+ */
849
+ interface CliMultiSelectOption extends CliSelectOption {
850
+ /** Whether the option is pre-selected */
851
+ checked?: boolean;
852
+ }
853
+ /**
854
+ * Options for readLine input.
855
+ */
856
+ interface CliLineOptions {
857
+ /**
858
+ * Pre-filled default value. Shown in the buffer when the prompt opens.
859
+ * The cursor starts at the end of the default text.
860
+ */
861
+ default?: string;
862
+ /**
863
+ * Validation function called on Enter.
864
+ * Return an error message string to reject the input and display the error.
865
+ * Return null to accept the input.
866
+ */
867
+ validate?: (value: string) => string | null;
868
+ /** Placeholder text shown dimmed when the buffer is empty */
869
+ placeholder?: string;
870
+ }
871
+ /**
872
+ * Options for readSelect and readSelectInline.
873
+ */
874
+ interface CliSelectOptions {
875
+ /** Pre-select an option by its value */
876
+ default?: string;
877
+ /** Enable type-to-filter. When true, printable keystrokes filter the option list. Default: false. */
878
+ searchable?: boolean;
879
+ /** Callback invoked each time the highlighted option changes */
880
+ onChange?: (value: string) => void;
881
+ }
882
+ /**
883
+ * Options for readMultiSelect.
884
+ */
885
+ interface CliMultiSelectOptions {
886
+ /** Enable type-to-filter. When true, printable keystrokes filter the option list. Default: false. */
887
+ searchable?: boolean;
888
+ /** Callback invoked each time the set of checked options changes */
889
+ onChange?: (values: string[]) => void;
890
+ }
891
+ /**
892
+ * Options for readNumber input.
893
+ */
894
+ interface CliNumberOptions {
895
+ /** Minimum allowed value */
896
+ min?: number;
897
+ /** Maximum allowed value */
898
+ max?: number;
899
+ /** Pre-filled default value */
900
+ default?: number;
901
+ }
902
+ /**
903
+ * Options for readDate input.
904
+ */
905
+ interface CliDateOptions {
906
+ /**
907
+ * Date format string. Supported tokens: YYYY (4-digit year), MM (2-digit month),
908
+ * DD (2-digit day). Separators can be `-`, `/`, or `.`.
909
+ * @default 'YYYY-MM-DD'
910
+ */
911
+ format?: string;
912
+ /** Minimum allowed date in the same format as `format` */
913
+ min?: string;
914
+ /** Maximum allowed date in the same format as `format` */
915
+ max?: string;
916
+ /** Pre-filled default value */
917
+ default?: string;
918
+ }
919
+ /**
920
+ * Provides interactive input reading from the terminal.
921
+ * All methods resolve with `null` when the user aborts (Ctrl+C or Escape).
922
+ */
923
+ interface ICliInputReader {
924
+ /**
925
+ * Read a line of text input.
926
+ * @param prompt - The prompt text displayed to the user
927
+ * @param options - Optional configuration for default value, validation, and placeholder
928
+ * @returns The entered text, or null if aborted
929
+ */
930
+ readLine(prompt: string, options?: CliLineOptions): Promise<string | null>;
931
+ /**
932
+ * Read a password (masked input).
933
+ * @param prompt - The prompt text displayed to the user
934
+ * @returns The entered password, or null if aborted
935
+ */
936
+ readPassword(prompt: string): Promise<string | null>;
937
+ /**
938
+ * Read a yes/no confirmation.
939
+ * @param prompt - The prompt text displayed to the user
940
+ * @param defaultValue - Default value when Enter is pressed without input
941
+ * @returns true for yes, false for no, or null if aborted
942
+ */
943
+ readConfirm(prompt: string, defaultValue?: boolean): Promise<boolean | null>;
944
+ /**
945
+ * Read a selection from a vertical list of options.
946
+ * @param prompt - The prompt text displayed to the user
947
+ * @param options - Array of options to choose from
948
+ * @param selectOptions - Optional configuration for default, search, onChange
949
+ * @returns The selected option's value, or null if aborted
950
+ */
951
+ readSelect(prompt: string, options: CliSelectOption[], selectOptions?: CliSelectOptions): Promise<string | null>;
952
+ /**
953
+ * Read a selection from an inline horizontal list.
954
+ * @param prompt - The prompt text displayed to the user
955
+ * @param options - Array of options to choose from
956
+ * @param selectOptions - Optional configuration for default, search, onChange
957
+ * @returns The selected option's value, or null if aborted
958
+ */
959
+ readSelectInline(prompt: string, options: CliSelectOption[], selectOptions?: CliSelectOptions): Promise<string | null>;
960
+ /**
961
+ * Read multiple selections from a checkbox list.
962
+ * @param prompt - The prompt text displayed to the user
963
+ * @param options - Array of options with optional pre-checked state
964
+ * @param selectOptions - Optional configuration for search, onChange
965
+ * @returns Array of selected option values, or null if aborted
966
+ */
967
+ readMultiSelect(prompt: string, options: CliMultiSelectOption[], selectOptions?: CliMultiSelectOptions): Promise<string[] | null>;
968
+ /**
969
+ * Read a number input.
970
+ * @param prompt - The prompt text displayed to the user
971
+ * @param options - Optional configuration for min, max, and default value
972
+ * @returns The entered number, or null if aborted
973
+ */
974
+ readNumber(prompt: string, options?: CliNumberOptions): Promise<number | null>;
975
+ /**
976
+ * Read a date input with format validation.
977
+ * @param prompt - The prompt text displayed to the user
978
+ * @param options - Optional configuration for format, min/max range, default
979
+ * @returns The date string in the specified format, or null if aborted
980
+ */
981
+ readDate(prompt: string, options?: CliDateOptions): Promise<string | null>;
982
+ /**
983
+ * Read file(s) via the environment's file picker dialog.
984
+ * @param prompt - The prompt text displayed to the user
985
+ * @param options - Optional configuration for multiple, accept filter, directory mode
986
+ * @returns Array of selected files with content, or null if cancelled/unsupported
987
+ */
988
+ readFile(prompt: string, options?: CliFilePickerOptions): Promise<CliFileResult[] | null>;
989
+ }
990
+
991
+ /**
992
+ * Background service lifecycle type.
993
+ * - `'daemon'` — Long-running service whose `onStart` blocks until the abort signal
994
+ * fires. Suitable for event loops, polling, or WebSocket connections. Can be
995
+ * stopped and restarted.
996
+ * - `'job'` — Run-to-completion task whose `onStart` resolves when the work is done.
997
+ * Automatically transitions to `'done'` status on success. Cannot be restarted.
998
+ */
999
+ type CliBackgroundServiceType = 'daemon' | 'job';
1000
+ /**
1001
+ * Lifecycle status of a background service.
1002
+ */
1003
+ type CliBackgroundServiceStatus = 'pending' | 'running' | 'stopped' | 'failed' | 'done';
1004
+ /**
1005
+ * Where the service code is executing.
1006
+ */
1007
+ type CliServiceExecutionMode = 'main-thread' | 'worker';
1008
+ /**
1009
+ * An event emitted by a background service.
1010
+ * Services control terminal notification visibility by setting `data.notify: true`.
1011
+ */
1012
+ interface ICliServiceEvent {
1013
+ /** Name of the service that emitted this event */
1014
+ source: string;
1015
+ /** Event type — services define their own, registry emits lifecycle events */
1016
+ type: string;
1017
+ /** Arbitrary payload */
1018
+ data?: unknown;
1019
+ /** Set automatically by the registry */
1020
+ timestamp?: Date;
1021
+ }
1022
+ /**
1023
+ * Handler function for service events.
1024
+ */
1025
+ type CliServiceEventHandler = (event: ICliServiceEvent) => void;
1026
+ /**
1027
+ * Log severity level for background service messages.
1028
+ * Shared by `ICliServiceLogEntry`, `ICliServiceContext.log()`,
1029
+ * and `WorkerServiceContext.log()`.
1030
+ */
1031
+ type CliServiceLogLevel = 'info' | 'warn' | 'error';
1032
+ /**
1033
+ * A single log entry from a background service.
1034
+ */
1035
+ interface ICliServiceLogEntry {
1036
+ timestamp: Date;
1037
+ level: CliServiceLogLevel;
1038
+ message: string;
1039
+ }
1040
+ /**
1041
+ * Per-service runtime context.
1042
+ * Each background service receives its own context with an independent abort signal
1043
+ * and scoped timers (not shared with the full-screen timer set).
1044
+ */
1045
+ interface ICliServiceContext {
1046
+ /** AbortSignal scoped to this service — independent of Ctrl+C */
1047
+ signal: AbortSignal;
1048
+ /** Emit an event from this service */
1049
+ emit(event: ICliServiceEvent): void;
1050
+ /** Log a message to this service's private log buffer */
1051
+ log(message: string, level?: CliServiceLogLevel): void;
1052
+ /** Create an interval scoped to this service (auto-cleared on stop) */
1053
+ createInterval(callback: () => void, ms: number): ICliManagedInterval;
1054
+ /** Create a timeout scoped to this service (auto-cleared on stop) */
1055
+ createTimeout(callback: () => void, ms: number): ICliManagedTimer;
1056
+ /** Access the shared state store */
1057
+ state: ICliStateStore;
1058
+ /** Access the shared service container */
1059
+ services: ICliServiceProvider;
1060
+ }
1061
+ /**
1062
+ * A background service that can run as a daemon or job.
1063
+ */
1064
+ interface ICliBackgroundService {
1065
+ /** Unique name for this service */
1066
+ name: string;
1067
+ /** Human-readable description */
1068
+ description?: string;
1069
+ /** 'daemon' for long-running, 'job' for run-to-completion */
1070
+ type: CliBackgroundServiceType;
1071
+ /** Whether this service can run in a Web Worker */
1072
+ workerCompatible?: boolean;
1073
+ /** Factory that creates the Worker instance (when workerCompatible) */
1074
+ workerFactory?: () => Worker;
1075
+ /** Called when the service starts */
1076
+ onStart(context: ICliServiceContext): Promise<void>;
1077
+ /** Called for graceful shutdown */
1078
+ onStop?(context: ICliServiceContext): Promise<void>;
1079
+ /**
1080
+ * Called when the service throws an unrecoverable error.
1081
+ * Use this hook for logging or cleanup; throwing from `onError` itself
1082
+ * is safe — the registry catches it and marks the service as failed.
1083
+ */
1084
+ onError?(error: Error, context: ICliServiceContext): void;
705
1085
  }
706
1086
  /**
707
1087
  * Read-only snapshot of a background service's current state.
708
1088
  */
709
1089
  interface ICliBackgroundServiceInfo {
1090
+ /** Process ID assigned by the process registry */
1091
+ pid?: number;
710
1092
  name: string;
711
1093
  description?: string;
712
1094
  type: CliBackgroundServiceType;
@@ -729,7 +1111,7 @@ interface ICliBackgroundServiceRegistry {
729
1111
  restart(name: string): Promise<void>;
730
1112
  startJob(name: string, task: (context: ICliServiceContext) => Promise<void>, options?: {
731
1113
  workerCompatible?: boolean;
732
- }): void;
1114
+ }): Promise<void>;
733
1115
  getStatus(name: string): ICliBackgroundServiceInfo | undefined;
734
1116
  list(): ICliBackgroundServiceInfo[];
735
1117
  getLogs(name: string, limit?: number): ICliServiceLogEntry[];
@@ -747,14 +1129,24 @@ interface ICliBackgroundServiceRegistry {
747
1129
  */
748
1130
  interface ICliManagedTimer {
749
1131
  /** Clear this timer immediately. */
750
- clear(): void;
1132
+ readonly clear: () => void;
751
1133
  }
752
1134
  /**
753
1135
  * A managed interval handle with the ability to change the delay.
754
1136
  */
755
1137
  interface ICliManagedInterval extends ICliManagedTimer {
756
1138
  /** Change the interval delay. Restarts the interval with the new delay. */
757
- setDelay(ms: number): void;
1139
+ readonly setDelay: (ms: number) => void;
1140
+ }
1141
+ /**
1142
+ * Options for entering full-screen mode.
1143
+ */
1144
+ interface CliFullScreenOptions {
1145
+ /**
1146
+ * Whether to show the terminal cursor. Defaults to `false` (cursor hidden).
1147
+ * Set to `true` for REPL / input-line interfaces where the user types text.
1148
+ */
1149
+ showCursor?: boolean;
758
1150
  }
759
1151
  /**
760
1152
  * Represents the context in which a command is executed
@@ -886,11 +1278,18 @@ interface ICliExecutionContext {
886
1278
  promptPathProvider?: () => string | null;
887
1279
  /**
888
1280
  * 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.
1281
+ * positions the cursor at row 1 col 1, and sets the given processor
1282
+ * as the context processor so that all terminal input is routed to
1283
+ * its `onData` method.
1284
+ *
1285
+ * By default the cursor is hidden (suitable for games / editors that
1286
+ * manage their own cursor). Pass `{ showCursor: true }` to keep it
1287
+ * visible (suitable for REPL / input-line interfaces).
1288
+ *
891
1289
  * @param processor The processor that will handle all input in full-screen mode
1290
+ * @param options Optional settings for full-screen mode
892
1291
  */
893
- enterFullScreenMode: (processor: ICliCommandProcessor) => void;
1292
+ enterFullScreenMode: (processor: ICliCommandProcessor, options?: CliFullScreenOptions) => void;
894
1293
  /**
895
1294
  * Exit full-screen mode: restores the cursor, leaves the alternate screen buffer,
896
1295
  * clears the context processor, and re-displays the prompt.
@@ -1094,7 +1493,7 @@ interface ICliCommandProcessor {
1094
1493
  /**
1095
1494
  * Represents the state configuration for the command processor
1096
1495
  * @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
1496
+ * @remarks State configuration is optional and can be used to store and retrieve state information for the command processor
1098
1497
  * @remarks The state configuration is used only for root command processors and not for child command processors
1099
1498
  */
1100
1499
  stateConfiguration?: CliStateConfiguration;
@@ -1188,430 +1587,28 @@ interface ICliGlobalParameterHandler {
1188
1587
  /**
1189
1588
  * The parameter descriptor shown in help output and used for tab-completion.
1190
1589
  */
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 {
1590
+ parameter: ICliCommandParameterDescriptor;
1595
1591
  /**
1596
- * Write text to the clipboard
1597
- * @param text The text to write to the clipboard
1598
- * @returns void
1592
+ * Execution priority — lower values run first.
1593
+ * @default 0
1599
1594
  */
1600
- write: (text: string) => Promise<void>;
1595
+ priority?: number;
1601
1596
  /**
1602
- * Read text from the clipboard
1603
- * @returns The text read from the clipboard
1597
+ * Evaluate and optionally handle the parameter.
1598
+ * @returns `true` to halt command execution, `false` to continue.
1604
1599
  */
1605
- read: () => Promise<string>;
1600
+ handle(args: Record<string, any>, processor: ICliCommandProcessor, command: CliProcessCommand, context: ICliExecutionContext): boolean | Promise<boolean>;
1606
1601
  }
1602
+
1607
1603
  /**
1608
1604
  * Represents a service that executes commands
1609
1605
  */
1610
1606
  interface ICliCommandExecutorService {
1611
1607
  /**
1612
- *
1613
- * @param command
1614
- * @param context
1608
+ * Display the help output for a command, including its description,
1609
+ * sub-commands, and parameters.
1610
+ * @param command The parsed command to show help for
1611
+ * @param context The execution context
1615
1612
  */
1616
1613
  showHelp(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
1617
1614
  /**
@@ -1633,6 +1630,7 @@ interface ICliCommandExecutorService {
1633
1630
  */
1634
1631
  getGlobalParameters(): ICliCommandParameterDescriptor[];
1635
1632
  }
1633
+
1636
1634
  /**
1637
1635
  * Represents a registry for command processors
1638
1636
  */
@@ -1671,6 +1669,50 @@ interface ICliCommandProcessorRegistry {
1671
1669
  */
1672
1670
  unregisterProcessor(processor: ICliCommandProcessor): void;
1673
1671
  }
1672
+ /**
1673
+ * Represents a tracked CLI process entry
1674
+ */
1675
+ interface ICliProcessEntry {
1676
+ pid: number;
1677
+ /** Display name (service name for bg services, command text for commands) */
1678
+ name: string;
1679
+ /** Process type */
1680
+ type: 'command' | 'daemon' | 'job' | 'service';
1681
+ command: string;
1682
+ startTime: number;
1683
+ status: 'running' | 'completed' | 'failed' | 'killed';
1684
+ exitCode?: number;
1685
+ }
1686
+ /** Options for registering a process */
1687
+ interface ICliProcessRegisterOptions {
1688
+ /** Display name (defaults to command) */
1689
+ name?: string;
1690
+ /** Process type (defaults to 'command') */
1691
+ type?: 'command' | 'daemon' | 'job' | 'service';
1692
+ /** Custom kill handler (e.g. for background services) */
1693
+ onKill?: () => Promise<void> | void;
1694
+ }
1695
+ /**
1696
+ * Registry for tracking CLI processes
1697
+ */
1698
+ interface ICliProcessRegistry {
1699
+ /** Register a new process, returns assigned PID */
1700
+ register(command: string, options?: ICliProcessRegisterOptions): {
1701
+ pid: number;
1702
+ abortController: AbortController;
1703
+ };
1704
+ /** Mark process as completed */
1705
+ complete(pid: number, exitCode: number): void;
1706
+ /** Mark process as failed */
1707
+ fail(pid: number): void;
1708
+ /** Kill a process by PID */
1709
+ kill(pid: number): boolean;
1710
+ /** List all processes (running + recent completed) */
1711
+ list(): ICliProcessEntry[];
1712
+ /** Get the current foreground process PID */
1713
+ readonly currentPid: number | undefined;
1714
+ }
1715
+
1674
1716
  interface ICliExecutionProcess {
1675
1717
  /**
1676
1718
  * Indicates if the process has exited
@@ -1713,301 +1755,687 @@ interface ICliExecutionProcess {
1713
1755
  */
1714
1756
  output(data: any): void;
1715
1757
  }
1758
+
1716
1759
  /**
1717
- * Represents a tracked CLI process entry
1760
+ * Represents a key-value store for the CLI
1718
1761
  */
1719
- interface ICliProcessEntry {
1720
- pid: number;
1721
- command: string;
1722
- startTime: number;
1723
- status: 'running' | 'completed' | 'failed' | 'killed';
1724
- exitCode?: number;
1762
+ interface ICliKeyValueStore {
1763
+ /**
1764
+ * Retrieves a value by key.
1765
+ * @param key - The key to retrieve the value for.
1766
+ * @returns A promise resolving to the value or undefined if not found.
1767
+ */
1768
+ get<T = any>(key: string): Promise<T | undefined>;
1769
+ /**
1770
+ * Sets a key-value pair in the store.
1771
+ * @param key - The key to set.
1772
+ * @param value - The value to store.
1773
+ * @returns A promise resolving when the value is stored.
1774
+ */
1775
+ set(key: string, value: any): Promise<void>;
1776
+ /**
1777
+ * Removes a key-value pair by key.
1778
+ * @param key - The key to remove.
1779
+ * @returns A promise resolving when the key is removed.
1780
+ */
1781
+ remove(key: string): Promise<void>;
1782
+ /**
1783
+ * Clears all key-value pairs from the store.
1784
+ * @returns A promise resolving when the store is cleared.
1785
+ */
1786
+ clear(): Promise<void>;
1725
1787
  }
1726
1788
  /**
1727
- * Registry for tracking CLI processes
1789
+ * Reactive state store scoped to a command processor or module.
1790
+ *
1791
+ * State is a plain object (`Record<string, any>`). Updates are shallow-merged
1792
+ * (top-level keys are replaced, nested objects are not deep-merged).
1793
+ * `getState()` returns a snapshot — mutating the returned object has no effect;
1794
+ * always use `updateState()` to change state.
1728
1795
  */
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;
1796
+ interface ICliStateStore {
1797
+ /**
1798
+ * Get a snapshot of the current state.
1799
+ * @returns A shallow copy of the state object
1800
+ */
1801
+ getState<T extends CliState = CliState>(): T;
1802
+ /**
1803
+ * Shallow-merge new values into the current state.
1804
+ * Only the provided keys are updated; other keys are preserved.
1805
+ * Triggers subscribers and persists if a storage backend is configured.
1806
+ * @param newState Partial state to merge with the current state
1807
+ */
1808
+ updateState(newState: Partial<CliState>): void;
1809
+ /**
1810
+ * Select a specific property or computed value from the state.
1811
+ * @param selector A function to project a slice of the state.
1812
+ * @returns Observable of the selected value.
1813
+ */
1814
+ select<K>(selector: (state: CliState) => K): Observable<K>;
1815
+ /**
1816
+ * Subscribe to state changes.
1817
+ * @param callback Callback function to handle state changes.
1818
+ * @returns Subscription object to manage the subscription.
1819
+ */
1820
+ subscribe(callback: (state: CliState) => void): Subscription;
1821
+ /**
1822
+ * Reset the state to its initial value.
1823
+ */
1824
+ reset(): void;
1825
+ /**
1826
+ * Persist the state to storage.
1827
+ */
1828
+ persist(): Promise<void>;
1829
+ /**
1830
+ * Initialize the state from storage.
1831
+ */
1832
+ initialize(): Promise<void>;
1745
1833
  }
1834
+
1746
1835
  /**
1747
- * Represents a key-value store for the CLI
1836
+ * Represents a service that pings the server
1748
1837
  */
1749
- interface ICliKeyValueStore {
1838
+ interface ICliPingServerService {
1839
+ /**
1840
+ * Pings the server
1841
+ */
1842
+ ping(): Promise<void>;
1843
+ }
1844
+ /**
1845
+ * Represents a module for the web CLI (frontend).
1846
+ *
1847
+ * This interface is for **web/frontend plugins only** — browser-side modules
1848
+ * that extend the CLI terminal UI (e.g. `@qodalis/cli-guid`, `@qodalis/cli-tetris`).
1849
+ *
1850
+ * It is **not** related to backend server processors (Node/Python/.NET).
1851
+ * Backend command processors implement their own `ICliCommandProcessor` interfaces
1852
+ * in their respective server packages and do not use `apiVersion`.
1853
+ */
1854
+ interface ICliModule {
1855
+ /**
1856
+ * The web plugin API version this module targets.
1857
+ *
1858
+ * This is a **frontend-only** concept used by the browser CLI runtime
1859
+ * to ensure plugin compatibility. It has no relation to backend server
1860
+ * API versioning (e.g. `/api/v1/qcli/`).
1861
+ *
1862
+ * Modules with `apiVersion` less than the runtime's `API_VERSION` are
1863
+ * rejected with a warning at boot time.
1864
+ *
1865
+ * Use the `API_VERSION` constant exported from `@qodalis/cli-core` to
1866
+ * target the current runtime version.
1867
+ */
1868
+ apiVersion: number;
1869
+ /** Unique module identifier, e.g. '@qodalis/cli-guid' */
1870
+ name: string;
1871
+ /** Semver version string */
1872
+ version?: string;
1873
+ /** Human-readable description */
1874
+ description?: string;
1875
+ /** Module names this module depends on (resolved before this module boots) */
1876
+ dependencies?: string[];
1877
+ /** Boot priority — lower values boot first (default: 0) */
1878
+ priority?: number;
1879
+ /** Command processors provided by this module */
1880
+ processors?: ICliCommandProcessor[];
1881
+ /** Services registered into the shared service container */
1882
+ services?: CliProvider[];
1883
+ /** Module configuration, set via configure() */
1884
+ config?: Record<string, any>;
1885
+ /**
1886
+ * Per-locale translation maps shipped by this module.
1887
+ * Keyed by locale code (e.g. 'es', 'fr'), each value is a flat
1888
+ * key-value map of translation keys to translated strings.
1889
+ *
1890
+ * These are automatically registered with the translation service
1891
+ * during module boot — no manual onInit() code required.
1892
+ *
1893
+ * @example
1894
+ * translations: {
1895
+ * es: { 'cli.guid.description': 'Generar y validar UUIDs' },
1896
+ * fr: { 'cli.guid.description': 'Générer et valider des UUIDs' },
1897
+ * }
1898
+ */
1899
+ translations?: Record<string, Record<string, string>>;
1900
+ /**
1901
+ * Returns a configured copy of this module.
1902
+ * Modules should narrow the config type via a module-specific interface.
1903
+ */
1904
+ configure?(config: any): ICliModule;
1905
+ /** Called after services are registered and before processors are initialized */
1906
+ onInit?(context: ICliExecutionContext): Promise<void>;
1907
+ /**
1908
+ * Optional first-run setup flow. Called during boot if the module
1909
+ * has not been set up yet (determined by a persisted flag in the
1910
+ * key-value store). Use context.reader to prompt the user for
1911
+ * initial configuration.
1912
+ *
1913
+ * @returns true to mark setup as complete; false/throw to abort
1914
+ * (module still loads, setup re-triggers next boot).
1915
+ */
1916
+ onSetup?(context: ICliExecutionContext): Promise<boolean>;
1917
+ /** Called after all modules have booted and the terminal is interactive */
1918
+ onAfterBoot?(context: ICliExecutionContext): Promise<void>;
1919
+ /** Called when the module is being torn down */
1920
+ onDestroy?(context: ICliExecutionContext): Promise<void>;
1921
+ }
1922
+ /**
1923
+ * A module that accepts typed configuration via `configure()`.
1924
+ * Extend this instead of `ICliModule` when your module has a config type.
1925
+ *
1926
+ * @example
1927
+ * ```ts
1928
+ * interface MyModuleConfig { verbose?: boolean }
1929
+ * const myModule: ICliConfigurableModule<MyModuleConfig> = {
1930
+ * configure(config) { return { ...this, config }; },
1931
+ * // ...
1932
+ * };
1933
+ * ```
1934
+ */
1935
+ interface ICliConfigurableModule<T extends Record<string, any> = Record<string, any>> extends ICliModule {
1936
+ configure(config: T): ICliModule;
1937
+ }
1938
+ /**
1939
+ * @deprecated Use ICliModule instead
1940
+ */
1941
+ type ICliUmdModule = ICliModule;
1942
+ /**
1943
+ * Represents a logger for the CLI
1944
+ */
1945
+ interface ICliLogger {
1946
+ /**
1947
+ * Set the log level of the logger
1948
+ * @param level The log level to set
1949
+ * @returns void
1950
+ * @default CliLogLevel.ERROR
1951
+ */
1952
+ setCliLogLevel(level: CliLogLevel): void;
1953
+ /**
1954
+ * Log a general message (LOG level)
1955
+ * @param args The arguments to log
1956
+ */
1957
+ log(...args: any[]): void;
1958
+ /**
1959
+ * Log an informational message (INFO level)
1960
+ * @param args The arguments to log
1961
+ */
1962
+ info(...args: any[]): void;
1963
+ /**
1964
+ * Log a warning message (WARN level)
1965
+ * @param args The arguments to log
1966
+ */
1967
+ warn(...args: any[]): void;
1968
+ /**
1969
+ * Log an error message (ERROR level)
1970
+ * @param args The arguments to log
1971
+ */
1972
+ error(...args: any[]): void;
1973
+ /**
1974
+ * Log a debug message (DEBUG level)
1975
+ * @param args The arguments to log
1976
+ */
1977
+ debug(...args: any[]): void;
1978
+ }
1979
+
1980
+ /**
1981
+ * Provides internationalization (i18n) support for CLI strings.
1982
+ */
1983
+ interface ICliTranslationService {
1984
+ /**
1985
+ * Translate a key to the current locale.
1986
+ * @param key The translation key (e.g. 'cli.echo.description')
1987
+ * @param defaultValue The English fallback string (returned if no translation found)
1988
+ * @param params Optional interpolation parameters for `{param}` placeholders
1989
+ */
1990
+ t(key: string, defaultValue: string, params?: Record<string, string | number>): string;
1750
1991
  /**
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.
1992
+ * Get the current locale code (e.g. 'en', 'es', 'fr').
1754
1993
  */
1755
- get<T = any>(key: string): Promise<T | undefined>;
1994
+ getLocale(): string;
1756
1995
  /**
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.
1996
+ * Set the active locale.
1997
+ * @param locale The locale code to switch to
1761
1998
  */
1762
- set(key: string, value: any): Promise<void>;
1999
+ setLocale(locale: string): void;
1763
2000
  /**
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.
2001
+ * Register translations for a locale.
2002
+ * Can be called multiple times — translations are merged, with later calls overriding earlier ones.
2003
+ * @param locale The locale code
2004
+ * @param translations Flat key-value map of translation keys to translated strings
1767
2005
  */
1768
- remove(key: string): Promise<void>;
2006
+ addTranslations(locale: string, translations: Record<string, string>): void;
1769
2007
  /**
1770
- * Clears all key-value pairs from the store.
1771
- * @returns A promise resolving when the store is cleared.
2008
+ * Get all locale codes that have at least one registered translation.
1772
2009
  */
1773
- clear(): Promise<void>;
2010
+ getAvailableLocales(): string[];
1774
2011
  }
1775
2012
  /**
1776
- * Represents a store for storing data associated with commands
2013
+ * Dependency injection container for CLI services.
2014
+ * Services are registered with string tokens and retrieved by type.
1777
2015
  */
1778
- interface ICliStateStore {
2016
+ interface ICliServiceProvider {
1779
2017
  /**
1780
- * Get the current state as an object.
2018
+ * Retrieve a service by its injection token.
2019
+ * @param service The token (typically a `*_TOKEN` constant) identifying the service
2020
+ * @returns The service instance, cast to `T`
2021
+ * @throws If no service is registered for the given token
1781
2022
  */
1782
- getState<T extends CliState = CliState>(): T;
2023
+ get<T = unknown>(service: any): T;
1783
2024
  /**
1784
- * Update the state with new values. Supports partial updates.
1785
- * @param newState Partial state to merge with the current state.
2025
+ * Register one or more service definitions.
2026
+ * @param definition A single provider or an array of providers to register
1786
2027
  */
1787
- updateState(newState: Partial<CliState>): void;
2028
+ set(definition: CliProvider | CliProvider[]): void;
2029
+ }
2030
+
2031
+ /**
2032
+ * Abstract permission service for checking rwx permissions on resources.
2033
+ * The default implementation lives in @qodalis/cli-users; consumers can
2034
+ * replace it via the DI container.
2035
+ */
2036
+ interface ICliPermissionService {
1788
2037
  /**
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.
2038
+ * Check whether a user may perform an action on a resource.
2039
+ * @param user The acting user.
2040
+ * @param action The requested operation.
2041
+ * @param ownership Owner/group of the resource.
2042
+ * @param permissions Permission string (e.g. "rwxr-xr-x").
2043
+ * @returns true if allowed.
1792
2044
  */
1793
- select<K>(selector: (state: CliState) => K): Observable<K>;
2045
+ check(user: ICliUser, action: 'read' | 'write' | 'execute', ownership: ICliOwnership, permissions: string): boolean;
2046
+ /** Parse octal (e.g. "755") to a permission string (e.g. "rwxr-xr-x"). */
2047
+ parseOctal(octal: string): string;
2048
+ /** Convert a permission string (e.g. "rwxr-xr-x") to octal (e.g. "755"). */
2049
+ toOctal(permissions: string): string;
2050
+ }
2051
+
2052
+ /**
2053
+ * Context passed to completion providers describing the current input state.
2054
+ */
2055
+ interface ICliCompletionContext {
2056
+ /** Full current line text */
2057
+ input: string;
2058
+ /** Cursor position in the line */
2059
+ cursor: number;
2060
+ /** The token (word) being completed at the cursor position */
2061
+ token: string;
2062
+ /** Start index of the token in the input string */
2063
+ tokenStart: number;
2064
+ /** Index of the token among all tokens (0 = command, 1+ = arguments) */
2065
+ tokenIndex: number;
2066
+ /** All tokens parsed from the input */
2067
+ tokens: string[];
2068
+ }
2069
+ /**
2070
+ * Provides tab-completion candidates for CLI input.
2071
+ * Plugins can register providers to extend completion (e.g. file paths, custom values).
2072
+ */
2073
+ interface ICliCompletionProvider {
1794
2074
  /**
1795
- * Subscribe to state changes.
1796
- * @param callback Callback function to handle state changes.
1797
- * @returns Subscription object to manage the subscription.
2075
+ * Priority order. Lower values are checked first.
2076
+ * Built-in defaults: 100 (commands), 200 (parameters).
2077
+ * Plugins should use lower values (e.g. 50) to take precedence for specific commands.
1798
2078
  */
1799
- subscribe(callback: (state: CliState) => void): Subscription;
2079
+ priority: number;
1800
2080
  /**
1801
- * Reset the state to its initial value.
2081
+ * Return completion candidates for the current input context.
2082
+ * Return an empty array if this provider does not apply.
1802
2083
  */
1803
- reset(): void;
2084
+ getCompletions(context: ICliCompletionContext): string[] | Promise<string[]>;
2085
+ }
2086
+
2087
+ interface ICliProgressBar {
1804
2088
  /**
1805
- * Persist the state to storage.
2089
+ * Indicates if the progress bar is running
1806
2090
  */
1807
- persist(): Promise<void>;
2091
+ isRunning: boolean;
1808
2092
  /**
1809
- * Initialize the state from storage.
2093
+ * Show the progress bar
1810
2094
  */
1811
- initialize(): Promise<void>;
2095
+ show: (text?: string) => void;
2096
+ /**
2097
+ * Hide the progress bar
2098
+ */
2099
+ hide: () => void;
1812
2100
  }
1813
2101
  /**
1814
- * Represents a service that pings the server
2102
+ * Represents a spinner for the CLI
1815
2103
  */
1816
- interface ICliPingServerService {
2104
+ interface ICliSpinner extends ICliProgressBar {
1817
2105
  /**
1818
- * Pings the server
2106
+ * Set the text of the spinner
2107
+ * @param text The text to set
1819
2108
  */
1820
- ping(): Promise<void>;
2109
+ setText: (text: string) => void;
1821
2110
  }
2111
+ type CliPercentageProgressBarUpdateValueOptions = {
2112
+ /**
2113
+ * The type of update to perform
2114
+ * @default 'replace'
2115
+ */
2116
+ type?: 'replace' | 'increment';
2117
+ };
1822
2118
  /**
1823
- * Represents a module for the CLI
2119
+ * Represents a progress bar for the CLI
1824
2120
  */
1825
- interface ICliModule {
2121
+ interface ICliPercentageProgressBar extends ICliProgressBar {
1826
2122
  /**
1827
- * API version this module targets.
1828
- * Modules with apiVersion < 2 (or missing) are rejected by v2 runtimes.
2123
+ * Update the progress of the progress bar.
2124
+ * @param progress The progress value (0–100). Values outside this range are clamped.
2125
+ * @param options Optional: update type ('replace' or 'increment')
1829
2126
  */
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>;
2127
+ update: (progress: number, options?: CliPercentageProgressBarUpdateValueOptions) => void;
1847
2128
  /**
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
- * }
2129
+ * Complete the progress bar
2130
+ * @returns void
1860
2131
  */
1861
- translations?: Record<string, Record<string, string>>;
2132
+ complete: () => void;
1862
2133
  /**
1863
- * Returns a configured copy of this module.
1864
- * Modules should narrow the config type via a module-specific interface.
2134
+ * Set the text of the spinner
2135
+ * @param text The text to set
1865
2136
  */
1866
- configure?(config: any): ICliModule;
1867
- /** Called after services are registered and before processors are initialized */
1868
- onInit?(context: ICliExecutionContext): Promise<void>;
2137
+ setText: (text: string) => void;
2138
+ }
2139
+ type CliTextAnimatorOptions = {
1869
2140
  /**
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).
2141
+ * The speed of the animation
2142
+ * @default 100
1877
2143
  */
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>;
2144
+ speed?: number;
2145
+ /**
2146
+ * The text will be removed after typing
2147
+ */
2148
+ removeAfterTyping?: boolean;
2149
+ };
2150
+ interface ICliTextAnimator extends ICliProgressBar {
2151
+ /**
2152
+ * Show animated text in a typing and erasing effect.
2153
+ * @param text The text to animate
2154
+ * @param options Optional: speed (ms per character), removeAfterTyping
2155
+ * @returns A promise that resolves when the animation completes
2156
+ */
2157
+ showText: (text: string, options?: CliTextAnimatorOptions) => Promise<void>;
2158
+ }
2159
+
2160
+ /**
2161
+ * Represents a service that manages user sessions in the CLI
2162
+ */
2163
+ interface ICliUserSessionService {
2164
+ /** Gets the current user session as a reactive stream */
2165
+ getUserSession(): Observable<ICliUserSession | undefined>;
2166
+ /** Sets the current user session */
2167
+ setUserSession(session: ICliUserSession): Promise<void>;
2168
+ /** Clears the current session (logout) */
2169
+ clearSession(): Promise<void>;
2170
+ /** Persists the current session to storage */
2171
+ persistSession(): Promise<void>;
2172
+ /** Restores a session from storage (called on boot) */
2173
+ restoreSession(): Promise<ICliUserSession | undefined>;
2174
+ }
2175
+ /**
2176
+ * Represents a service that manages users in the CLI
2177
+ */
2178
+ interface ICliUsersStoreService {
2179
+ /** Gets users with optional filtering and pagination */
2180
+ getUsers(options?: {
2181
+ query?: string;
2182
+ skip?: number;
2183
+ take?: number;
2184
+ }): Observable<ICliUser[]>;
2185
+ /** Creates a new user */
2186
+ createUser(user: CliAddUser): Promise<ICliUser>;
2187
+ /** Gets a user by id, name, or email */
2188
+ getUser(id: string): Observable<ICliUser | undefined>;
2189
+ /** Updates an existing user */
2190
+ updateUser(id: string, updates: CliUpdateUser): Promise<ICliUser>;
2191
+ /** Deletes a user by id */
2192
+ deleteUser(id: string): Promise<void>;
2193
+ }
2194
+ /**
2195
+ * Represents a service that manages groups in the CLI
2196
+ */
2197
+ interface ICliGroupsStoreService {
2198
+ /** Gets all groups */
2199
+ getGroups(): Observable<ICliGroup[]>;
2200
+ /** Gets a group by id or name */
2201
+ getGroup(id: string): Observable<ICliGroup | undefined>;
2202
+ /** Creates a new group */
2203
+ createGroup(name: string, description?: string): Promise<ICliGroup>;
2204
+ /** Deletes a group by id */
2205
+ deleteGroup(id: string): Promise<void>;
2206
+ /** Gets all users that belong to a group */
2207
+ getGroupMembers(groupId: string): Observable<ICliUser[]>;
2208
+ }
2209
+ /**
2210
+ * Represents a service that handles authentication in the CLI
2211
+ */
2212
+ interface ICliAuthService {
2213
+ /** Authenticates a user and returns a session */
2214
+ login(username: string, password: string): Promise<ICliUserSession>;
2215
+ /** Ends the current session */
2216
+ logout(): Promise<void>;
2217
+ /** Sets or updates a user's password */
2218
+ setPassword(userId: string, password: string): Promise<void>;
2219
+ /** Verifies a password against stored credentials */
2220
+ verifyPassword(userId: string, password: string): Promise<boolean>;
2221
+ /** Hashes a password with a salt using Web Crypto SHA-256 */
2222
+ hashPassword(password: string, salt: string): Promise<string>;
1883
2223
  }
2224
+
1884
2225
  /**
1885
- * @deprecated Use ICliModule instead
2226
+ * Represents a serialized snapshot of a CLI engine's state.
2227
+ * Used to duplicate terminal tabs with full state preservation.
1886
2228
  */
1887
- type ICliUmdModule = ICliModule;
2229
+ interface CliEngineSnapshot {
2230
+ /** Schema version for forward compatibility */
2231
+ version: 1;
2232
+ /** Timestamp (ms since epoch) when the snapshot was taken */
2233
+ timestamp: number;
2234
+ /** Serialized terminal state */
2235
+ terminal: {
2236
+ /** Terminal buffer serialized via @xterm/addon-serialize */
2237
+ serializedBuffer: string;
2238
+ /** Terminal column count at time of snapshot */
2239
+ cols: number;
2240
+ /** Terminal row count at time of snapshot */
2241
+ rows: number;
2242
+ };
2243
+ /** Command history entries (most recent last) */
2244
+ commandHistory: string[];
2245
+ /** Named state store entries */
2246
+ stateStores: Array<{
2247
+ name: string;
2248
+ state: Record<string, any>;
2249
+ }>;
2250
+ }
2251
+
1888
2252
  /**
1889
- * Represents a logger for the CLI
2253
+ * Messages sent from the main thread to a background service Worker.
1890
2254
  */
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";
2255
+ type CliWorkerInboundMessage = {
2256
+ type: 'start';
2257
+ config?: Record<string, unknown>;
2258
+ } | {
2259
+ type: 'stop';
2260
+ } | {
2261
+ type: 'abort';
2262
+ };
1926
2263
  /**
1927
- * Provides internationalization (i18n) support for CLI strings.
2264
+ * Messages sent from a background service Worker to the main thread.
1928
2265
  */
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[];
2266
+ type CliWorkerOutboundMessage = {
2267
+ type: 'log';
2268
+ level: 'info' | 'warn' | 'error';
2269
+ message: string;
2270
+ } | {
2271
+ type: 'event';
2272
+ event: Omit<ICliServiceEvent, 'timestamp'>;
2273
+ } | {
2274
+ type: 'state-update';
2275
+ patch: Record<string, unknown>;
2276
+ } | {
2277
+ type: 'status';
2278
+ status: CliBackgroundServiceStatus;
2279
+ } | {
2280
+ type: 'error';
2281
+ message: string;
2282
+ stack?: string;
2283
+ };
2284
+
2285
+ /**
2286
+ * Represents an entry in a file listing.
2287
+ */
2288
+ interface ICliFileEntry {
2289
+ name: string;
2290
+ type: 'file' | 'directory';
2291
+ size: number;
2292
+ modified: string;
1957
2293
  }
2294
+
1958
2295
  /**
1959
- * Represents a service provider for the CLI
2296
+ * Abstraction for file transfer operations.
2297
+ * Default implementation uses browser-native APIs (file picker, download dialog).
2298
+ * @qodalis/cli-files overrides with virtual FS backed by IndexedDB.
1960
2299
  */
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;
2300
+ interface ICliFileTransferService {
2301
+ readFile(path: string): Promise<string | null>;
2302
+ writeFile(path: string, content: string): Promise<void>;
2303
+ listFiles(path: string): Promise<ICliFileEntry[]>;
2304
+ exists(path: string): Promise<boolean>;
2305
+ downloadToBrowser(filename: string, content: string | Blob): void;
2306
+ uploadFromBrowser(accept?: string): Promise<{
2307
+ name: string;
2308
+ content: string;
2309
+ } | null>;
1972
2310
  }
1973
2311
 
1974
- declare const ICliPermissionService_TOKEN = "cli-permission-service";
2312
+ interface ICliDragDropService {
2313
+ /** Emits an array of dropped File objects each time files are dropped onto the terminal */
2314
+ readonly onFileDrop: Observable<File[]>;
2315
+ }
1975
2316
 
1976
2317
  /**
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.
2318
+ * Opaque state value carried between lines during syntax highlighting.
2319
+ * Encodes context such as "inside a multi-line string" or "inside a block comment"
2320
+ * so the highlighter can resume correctly on the next line.
2321
+ * `0` typically represents the default/root state.
1980
2322
  */
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;
2323
+ type LineState = number;
2324
+ interface ISyntaxHighlightRule {
2325
+ pattern: RegExp;
2326
+ tokenType: string;
2327
+ captureGroup?: number;
2328
+ }
2329
+ interface ISyntaxHighlighter {
2330
+ id: string;
2331
+ /** Human-readable language name (e.g. 'TypeScript'). Falls back to `id` when absent. */
2332
+ name?: string;
2333
+ extensions: string[];
2334
+ initialState: LineState;
2335
+ getRules(state: LineState): ISyntaxHighlightRule[];
2336
+ getNextLineState(line: string, currentState: LineState): LineState;
2337
+ }
2338
+ interface ISyntaxTheme {
2339
+ name: string;
2340
+ colors: Record<string, string>;
2341
+ }
2342
+
2343
+ /**
2344
+ * Framework-agnostic interface for programmatic control of the CLI panel.
2345
+ *
2346
+ * CliEngine is referenced as a generic to avoid a circular dependency
2347
+ * between @qodalis/cli-core and @qodalis/cli. Framework implementations
2348
+ * resolve this to the concrete CliEngine class.
2349
+ */
2350
+ interface ICliPanelRef<TEngine = unknown> {
2351
+ /** Expand the panel (sets collapsed=false). Initializes the first tab on first call. */
2352
+ open(): void;
2353
+ /** Collapse the panel body (sets collapsed=true). */
2354
+ collapse(): void;
2355
+ toggleCollapse(): void;
2356
+ /** Hide the panel to a small viewport-edge tab (reversible via unhide). */
2357
+ hide(): void;
2358
+ unhide(): void;
2359
+ toggleHide(): void;
2360
+ /** Destroy the panel (removes from DOM). Irreversible. */
2361
+ close(): void;
2362
+ maximize(): void;
2363
+ restore(): void;
2364
+ toggleMaximize(): void;
2365
+ /**
2366
+ * Set panel dimensions. Only the dimension relevant to the current
2367
+ * position is applied immediately (height for top/bottom, width for
2368
+ * left/right). The other dimension is stored for when the position changes.
2369
+ */
2370
+ resize(dimensions: {
2371
+ height?: number;
2372
+ width?: number;
2373
+ }): void;
2374
+ setPosition(position: CliPanelPosition): void;
2375
+ /** Create a new tab. Returns the new tab's ID. Title defaults to "Terminal {id}". */
2376
+ addTab(title?: string): number;
2377
+ /** Close a tab by ID. No-op if the ID does not exist. */
2378
+ closeTab(tabId: number): void;
2379
+ /** Activate a tab by ID. No-op if the ID does not exist. */
2380
+ selectTab(tabId: number): void;
2381
+ /** Programmatically rename a tab. No-op if the ID does not exist. */
2382
+ renameTab(tabId: number, title: string): void;
2383
+ /**
2384
+ * Split the active pane (or a pane within the specified tab) to create
2385
+ * a new pane to the right. Returns the new pane's ID.
2386
+ */
2387
+ splitPane(tabId?: number): number;
2388
+ /**
2389
+ * Close a pane by ID. Searches all tabs for the pane.
2390
+ * No-op if the ID does not exist.
2391
+ */
2392
+ closePane(paneId: number): void;
2393
+ /** Get the engine for a specific pane, or the active pane if omitted. */
2394
+ getEngine(paneId?: number): TEngine | undefined;
2395
+ getState(): CliPanelState;
2396
+ }
2397
+ interface CliPanelState {
2398
+ collapsed: boolean;
2399
+ hidden: boolean;
2400
+ maximized: boolean;
2401
+ position: CliPanelPosition;
2402
+ height: number;
2403
+ width: number;
2404
+ activeTabId: number;
2405
+ activePaneId: number;
2406
+ tabs: CliPanelTabState[];
2407
+ }
2408
+ interface CliPanelTabState {
2409
+ id: number;
2410
+ title: string;
2411
+ panes: CliPanelPaneState[];
2412
+ }
2413
+ interface CliPanelPaneState {
2414
+ id: number;
2415
+ widthPercent: number;
1995
2416
  }
1996
2417
 
1997
2418
  /**
1998
- * Registry that tracks loaded CLI modules and dispatches boot handlers
1999
- * when new modules are registered (including dynamically via UMD).
2419
+ * Registry that tracks loaded web CLI modules (frontend plugins) and dispatches
2420
+ * boot handlers when new modules are registered (including dynamically via UMD).
2421
+ *
2422
+ * This registry is for **browser-side web plugins only**. Backend server
2423
+ * processors (Node/Python/.NET) have their own registries and do not use
2424
+ * this class or the `apiVersion` gating mechanism.
2000
2425
  */
2001
2426
  declare class CliModuleRegistry {
2002
2427
  private readonly modules;
2003
2428
  private readonly bootHandlers;
2429
+ /** Optional warning callback — set by the engine to route through ICliLogger */
2430
+ onWarn?: (message: string) => void;
2004
2431
  /**
2005
2432
  * Register a handler that is called whenever a new module is registered.
2006
2433
  */
2007
2434
  onModuleBoot(handler: (module: ICliModule) => Promise<void>): void;
2008
2435
  /**
2009
- * Register a module and notify all boot handlers.
2010
- * Modules that do not meet the required API version are silently skipped.
2436
+ * Register a web plugin module and notify all boot handlers.
2437
+ * Modules whose `apiVersion` is below the runtime's `API_VERSION` are
2438
+ * skipped with a warning — this ensures only compatible frontend plugins load.
2011
2439
  */
2012
2440
  register(module: ICliModule): Promise<void>;
2013
2441
  /**
@@ -2071,6 +2499,17 @@ declare const CLI_CONFIGURE_STORE_NAME = "configure";
2071
2499
  * @returns The configured value or the default
2072
2500
  */
2073
2501
  declare function getConfigValue<T = any>(state: ICliStateStore, category: string, key: string, defaultValue: T): T;
2502
+ /**
2503
+ * Retrieves a plugin configuration value from the execution context.
2504
+ * This is a convenience wrapper for plugins — handles store lookup internally.
2505
+ *
2506
+ * @param context The execution context
2507
+ * @param category The category (usually the processor's command name)
2508
+ * @param key The configuration key
2509
+ * @param defaultValue Fallback value if not configured
2510
+ * @returns The configured value or the default
2511
+ */
2512
+ declare function getPluginConfigValue<T = any>(context: ICliExecutionContext, category: string, key: string, defaultValue: T): T;
2074
2513
  /**
2075
2514
  * Resolves all configuration options from registered processors,
2076
2515
  * grouped by category.
@@ -2080,6 +2519,10 @@ declare function resolveConfigurationCategories(registry: ICliCommandProcessorRe
2080
2519
  options: ICliConfigurationOption[];
2081
2520
  }>;
2082
2521
 
2522
+ /**
2523
+ * Returns a promise that resolves after the given number of milliseconds.
2524
+ * @param ms Delay duration in milliseconds
2525
+ */
2083
2526
  declare const delay: (ms: number) => Promise<void>;
2084
2527
 
2085
2528
  /**
@@ -2117,10 +2560,10 @@ interface ServerVersionInfo {
2117
2560
  * Negotiates the API version between a frontend CLI client and a backend server.
2118
2561
  *
2119
2562
  * Flow:
2120
- * 1. Client calls `discover(baseUrl)` which hits `GET /api/cli/versions`
2563
+ * 1. Client calls `discover(baseUrl)` which hits `GET ${VERSIONS_ENDPOINT}`
2121
2564
  * 2. Server returns supported versions
2122
2565
  * 3. Client picks the highest mutually supported version
2123
- * 4. All subsequent calls use `/api/v{n}/cli/*`
2566
+ * 4. All subsequent calls use `/api/v{n}/qcli/*`
2124
2567
  */
2125
2568
  declare class ServerVersionNegotiator {
2126
2569
  private static readonly CLIENT_SUPPORTED_VERSIONS;
@@ -2173,18 +2616,73 @@ declare function savePanelPosition(position: CliPanelPosition): void;
2173
2616
  */
2174
2617
  declare function nextPanelPosition(current: CliPanelPosition): CliPanelPosition;
2175
2618
 
2176
- declare const getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
2619
+ /**
2620
+ * Strip all ANSI escape sequences from a string.
2621
+ * @param text The text potentially containing ANSI codes
2622
+ * @returns The text with all ANSI codes removed
2623
+ */
2624
+ declare function stripAnsi(text: string): string;
2625
+ /**
2626
+ * Return the visible length of a string, ignoring ANSI escape codes.
2627
+ * Useful for padding/alignment calculations in terminal output.
2628
+ * @param text The text potentially containing ANSI codes
2629
+ * @returns The number of visible characters
2630
+ */
2631
+ declare function visibleLength(text: string): number;
2632
+
2633
+ /**
2634
+ * Retrieve a parameter's value from the parsed arguments, checking aliases.
2635
+ * @param p The parameter descriptor
2636
+ * @param args The parsed command arguments
2637
+ * @returns The matched value, or `undefined` if not found
2638
+ */
2639
+ declare const getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => unknown;
2640
+ /**
2641
+ * Pretty-print a JSON value with ANSI color highlighting.
2642
+ * @param json The value to format
2643
+ * @returns A colorized, indented string suitable for terminal output
2644
+ */
2177
2645
  declare const formatJson: (json: any) => string;
2178
- declare const colorizeJson: (jsonString: any) => string;
2646
+ /**
2647
+ * Apply ANSI color codes to a JSON string using token-based scanning.
2648
+ * Handles keys, strings, numbers, booleans, null, and structural characters.
2649
+ * @param jsonString The raw JSON string to colorize
2650
+ * @returns The colorized string
2651
+ */
2652
+ declare const colorizeJson: (jsonString: string) => string;
2653
+ /**
2654
+ * Convert a key-value object to a URL query string. Arrays produce repeated keys.
2655
+ * @param params The parameters to encode
2656
+ * @returns The encoded query string (without leading `?`)
2657
+ */
2179
2658
  declare const toQueryString: (params: Record<string, any>) => string;
2659
+ /**
2660
+ * Highlight regex matches in text using an ANSI background color.
2661
+ * @param text The source text
2662
+ * @param pattern The regex pattern to highlight
2663
+ * @param bgColor The background color to apply (default: Yellow)
2664
+ * @returns The text with matching segments wrapped in ANSI background color codes
2665
+ */
2180
2666
  declare const highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
2667
+ /**
2668
+ * Extract the substring to the right of a given word in a command string.
2669
+ * @param command The full command string
2670
+ * @param word The word to search for
2671
+ * @returns The trimmed text after the word, or `undefined` if not found
2672
+ */
2181
2673
  declare const getRightOfWord: (command: string, word: string) => string | undefined;
2674
+ /**
2675
+ * Apply a color function to the first word of a text string, preserving leading whitespace.
2676
+ * @param text The text to process
2677
+ * @param colorFunction A function that wraps a word in ANSI color codes
2678
+ * @returns The text with only the first word colorized
2679
+ */
2182
2680
  declare const colorFirstWord: (text: string, colorFunction: (word: string) => string) => string;
2183
2681
 
2184
2682
  declare const utils: {
2185
- getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
2683
+ getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => unknown;
2186
2684
  formatJson: (json: any) => string;
2187
- colorizeJson: (jsonString: any) => string;
2685
+ colorizeJson: (jsonString: string) => string;
2188
2686
  toQueryString: (params: Record<string, any>) => string;
2189
2687
  highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
2190
2688
  getRightOfWord: (command: string, word: string) => string | undefined;
@@ -2192,6 +2690,7 @@ declare const utils: {
2192
2690
  ObjectDescriber: typeof ObjectDescriber;
2193
2691
  delay: (ms: number) => Promise<void>;
2194
2692
  getConfigValue: typeof getConfigValue;
2693
+ getPluginConfigValue: typeof getPluginConfigValue;
2195
2694
  resolveConfigurationCategories: typeof resolveConfigurationCategories;
2196
2695
  CLI_CONFIGURE_STORE_NAME: string;
2197
2696
  };
@@ -2201,23 +2700,41 @@ declare const constants: {
2201
2700
  DefaultLibraryAuthor: ICliCommandAuthor;
2202
2701
  };
2203
2702
 
2703
+ /** Error message used when a `CancellablePromise` is cancelled. */
2704
+ declare const CANCELLATION_ERROR_MESSAGE = "Promise cancelled";
2705
+ /**
2706
+ * A promise wrapper that supports cooperative cancellation.
2707
+ *
2708
+ * Create with an executor (like `new Promise`), then call `execute()` to run.
2709
+ * Call `cancel()` to reject with a cancellation error and prevent further
2710
+ * resolve/reject callbacks from firing.
2711
+ *
2712
+ * @example
2713
+ * ```ts
2714
+ * const cp = new CancellablePromise<string>((resolve) => {
2715
+ * setTimeout(() => resolve('done'), 5000);
2716
+ * });
2717
+ * cp.execute().catch(e => console.log(e.message)); // 'Promise cancelled'
2718
+ * cp.cancel();
2719
+ * ```
2720
+ */
2204
2721
  declare class CancellablePromise<T> {
2205
2722
  private executor;
2206
2723
  private hasCancelled;
2207
2724
  private abortController;
2208
2725
  constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void) => void);
2726
+ /**
2727
+ * Run the executor and return a promise for its result.
2728
+ * If `cancel()` has been called, the promise rejects immediately.
2729
+ */
2209
2730
  execute(): Promise<T>;
2731
+ /**
2732
+ * Cancel the promise. The executing promise rejects with
2733
+ * `Error('Promise cancelled')` and subsequent resolve/reject calls are ignored.
2734
+ */
2210
2735
  cancel(): void;
2211
2736
  }
2212
2737
 
2213
- type CliThemeCategory = 'dark' | 'light';
2214
- interface CliThemeInfo {
2215
- theme: ITheme;
2216
- category: CliThemeCategory;
2217
- tags: string[];
2218
- description: string;
2219
- }
2220
-
2221
2738
  type CliTheme = ITheme;
2222
2739
  type DefaultThemesType = {
2223
2740
  default: CliTheme;
@@ -2252,34 +2769,22 @@ type DefaultThemesType = {
2252
2769
  yellow: CliTheme;
2253
2770
  [key: string]: CliTheme;
2254
2771
  };
2772
+
2255
2773
  declare const DefaultThemes: DefaultThemesType;
2256
2774
 
2775
+ type CliThemeCategory = 'dark' | 'light';
2776
+ interface CliThemeInfo {
2777
+ theme: ITheme;
2778
+ category: CliThemeCategory;
2779
+ tags: string[];
2780
+ description: string;
2781
+ }
2782
+
2257
2783
  declare const DefaultThemeInfos: Record<string, CliThemeInfo>;
2258
2784
 
2259
- declare const LIBRARY_VERSION = "2.0.0-beta.1";
2785
+ declare const LIBRARY_VERSION = "2.0.0-beta.11";
2260
2786
  declare const API_VERSION = 2;
2261
2787
 
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
2788
  /**
2284
2789
  * Context provided to worker service handlers inside a Web Worker.
2285
2790
  */
@@ -2287,7 +2792,7 @@ interface WorkerServiceContext {
2287
2792
  /** Emit an event to the main thread */
2288
2793
  emit(event: Omit<ICliServiceEvent, 'timestamp'>): void;
2289
2794
  /** Log a message (forwarded to the main-thread log buffer) */
2290
- log(message: string, level?: 'info' | 'warn' | 'error'): void;
2795
+ log(message: string, level?: CliServiceLogLevel): void;
2291
2796
  /** Update state on the main thread */
2292
2797
  updateState(patch: Record<string, unknown>): void;
2293
2798
  /** Create an interval that is auto-cleared on stop */
@@ -2306,10 +2811,29 @@ declare function createWorkerService(handlers: {
2306
2811
  onStop?(): Promise<void>;
2307
2812
  }): void;
2308
2813
 
2814
+ /**
2815
+ * Browser-based file transfer service using native browser APIs.
2816
+ *
2817
+ * This is the default implementation when no virtual filesystem is available.
2818
+ * `readFile` and `uploadFromBrowser` open a file picker dialog.
2819
+ * `writeFile` and `downloadToBrowser` trigger a browser download.
2820
+ *
2821
+ * **Limitations:** `listFiles()` and `exists()` are not supported in the
2822
+ * browser environment and always return empty/false respectively.
2823
+ * Use `@qodalis/cli-files` for full filesystem capabilities.
2824
+ */
2309
2825
  declare class BrowserFileTransferService implements ICliFileTransferService {
2310
2826
  readFile(_path: string): Promise<string | null>;
2311
2827
  writeFile(path: string, content: string): Promise<void>;
2828
+ /**
2829
+ * Not supported in browser — always returns an empty array.
2830
+ * Use `@qodalis/cli-files` for directory listing.
2831
+ */
2312
2832
  listFiles(_path: string): Promise<ICliFileEntry[]>;
2833
+ /**
2834
+ * Not supported in browser — always returns `false`.
2835
+ * Use `@qodalis/cli-files` for file existence checks.
2836
+ */
2313
2837
  exists(_path: string): Promise<boolean>;
2314
2838
  downloadToBrowser(filename: string, content: string | Blob): void;
2315
2839
  uploadFromBrowser(accept?: string): Promise<{
@@ -2319,4 +2843,4 @@ declare class BrowserFileTransferService implements ICliFileTransferService {
2319
2843
  private _pickFile;
2320
2844
  }
2321
2845
 
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 };
2846
+ export { API_VERSION, BrowserFileTransferService, CANCELLATION_ERROR_MESSAGE, CLI_CONFIGURE_STORE_NAME, CancellablePromise, type CliAddUser, CliBackgroundColor, type CliBackgroundServiceStatus, type CliBackgroundServiceType, type CliDateOptions, type CliEngineSnapshot, type CliFactoryProvider, type CliFilePickerOptions, type CliFileResult, CliForegroundColor, type CliFullScreenOptions, CliIcon, type CliLineOptions, CliLogLevel, CliModuleRegistry, type CliMultiSelectOption, type CliMultiSelectOptions, type CliNumberOptions, type CliOptions, type CliPackageSource, type CliPanelConfig, type CliPanelHideAlignment, type CliPanelPaneState, type CliPanelPosition, type CliPanelState, type CliPanelTabState, type CliPercentageProgressBarUpdateValueOptions, type CliProcessCommand, type CliProcessorMetadata, type CliProvider, type CliSelectOption, type CliSelectOptions, type CliServerCapabilities, type CliServerCommandDescriptor, type CliServerConfig, type CliServerOutput, type CliServerResponse, type CliServiceEventHandler, type CliServiceExecutionMode, type CliServiceLogLevel, type CliState, type CliStateConfiguration, type CliTableOptions, 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 DefaultThemesType, 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 ICliConfigurableModule, type ICliConfigurationOption, type ICliDragDropService, ICliDragDropService_TOKEN, type ICliExecutionContext, type ICliExecutionProcess, type ICliFileEntry, type ICliFilePickerProvider, ICliFilePickerProvider_TOKEN, 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 ICliPanelRef, type ICliPercentageProgressBar, type ICliPermissionService, ICliPermissionService_TOKEN, type ICliPingServerService, type ICliProcessEntry, type ICliProcessRegisterOptions, 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, type ISyntaxHighlightRule, type ISyntaxHighlighter, type ISyntaxTheme, LIBRARY_VERSION, type LineState, ObjectDescriber, type Package, type ServerVersionInfo, ServerVersionNegotiator, type WorkerServiceContext, bootCliModule, bootUmdModule, clearTerminalLine, colorFirstWord, colorizeJson, compareVersions, constants, createWorkerService, delay, derivePanelThemeStyles, enums, formatJson, getConfigValue, getParameterValue, getPluginConfigValue, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, stripAnsi, toQueryString, utils, visibleLength };