@qodalis/cli-core 2.0.0-beta.8 → 2.0.0-beta.9

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.ts CHANGED
@@ -106,7 +106,10 @@ type CliProcessCommand = {
106
106
  */
107
107
  command: string;
108
108
  /**
109
- * The data that was entered
109
+ * Pipeline data passed from the previous command in a pipe chain.
110
+ * When commands are piped (e.g. `cmd1 | cmd2`), the output of `cmd1`
111
+ * is captured and passed here as input to `cmd2`. The shape depends
112
+ * on what the upstream command produced (string, JSON object, array, etc.).
110
113
  */
111
114
  data?: any;
112
115
  /**
@@ -216,7 +219,7 @@ declare enum CliIcon {
216
219
  Server = "\uD83D\uDDA5",// Server or host
217
220
  Cloud = "\u2601",// Cloud or remote
218
221
  Network = "\uD83C\uDF10",// Network or connection
219
- Monitor = "\uD83D\uDDA5",// Monitor or display
222
+ Monitor = "\uD83D\uDCFA",// Monitor or display
220
223
  Printer = "\uD83D\uDDA8",// Printer or output
221
224
  USB = "\uD83D\uDD0C",// USB or connection
222
225
  Speaker = "\uD83D\uDD0A",// Speaker or audio
@@ -226,14 +229,14 @@ declare enum CliIcon {
226
229
  Music = "\uD83C\uDFB5",// Music or audio
227
230
  Phone = "\uD83D\uDCDE",// Phone or communication
228
231
  Package = "\uD83D\uDCE6",// Package or bundle
229
- Plugin = "\uD83D\uDD0C",// Plugin or extension
230
- Extension = "\uD83E\uDDE9",// Extension or component
231
- Module = "\uD83D\uDCE6",// Module or package
232
+ Plugin = "\uD83E\uDDE9",// Plugin or extension
233
+ Extension = "\uD83D\uDD0C",// Extension or connection
234
+ Module = "\uD83E\uDDF1",// Module or package
232
235
  Evaluate = "\uD83D\uDD0D",// Evaluate or search
233
- Variable = "\uD83D\uDD27",// Variable or setting
236
+ Variable = "\uD835\uDC65",// Variable or setting
234
237
  Script = "\uD83D\uDCDC",// Script or code
235
- Code = "\uD83D\uDCBE",// Code or file
236
- Logs = "\uD83D\uDCDC",// Logs or history
238
+ Code = "\uD83D\uDCDD",// Code or file
239
+ Logs = "\uD83D\uDCCB",// Logs or history
237
240
  Power = "\u23FB",// On/Off state
238
241
  Heart = "\u2764",// Love or favorite
239
242
  Flame = "\uD83D\uDD25",// Trending or hot
@@ -314,6 +317,14 @@ type CliOptions = Record<string, any> & {
314
317
  * Commands from each server are discovered and registered as proxy processors.
315
318
  */
316
319
  servers?: CliServerConfig[];
320
+ /**
321
+ * Whether the `eval` / `js` / `calc` command is enabled.
322
+ * Disabled by default because it runs arbitrary JavaScript via `eval()`
323
+ * in the host page context — a security risk in multi-tenant or
324
+ * user-facing deployments.
325
+ * @default false
326
+ */
327
+ allowEval?: boolean;
317
328
  };
318
329
  /**
319
330
  * Configuration for a remote CLI server
@@ -482,10 +493,17 @@ declare enum CliLogLevel {
482
493
  type CliState = Record<string, any>;
483
494
  /**
484
495
  * Position of the CLI panel relative to the viewport edge.
496
+ * - `'bottom'` — anchored to the bottom (default)
497
+ * - `'top'` — anchored to the top
498
+ * - `'left'` — anchored to the left (vertical layout)
499
+ * - `'right'` — anchored to the right (vertical layout)
485
500
  */
486
501
  type CliPanelPosition = 'bottom' | 'top' | 'left' | 'right';
487
502
  /**
488
503
  * Alignment of the hidden-mode tab along its viewport edge.
504
+ * - `'start'` — left for horizontal panels, top for vertical panels
505
+ * - `'center'` — centered along the edge (default)
506
+ * - `'end'` — right for horizontal panels, bottom for vertical panels
489
507
  */
490
508
  type CliPanelHideAlignment = 'start' | 'center' | 'end';
491
509
  /**
@@ -545,6 +563,47 @@ declare const enums: {
545
563
  CliLogLevel: typeof CliLogLevel;
546
564
  };
547
565
 
566
+ /**
567
+ * Token for the CLI user session service.
568
+ */
569
+ declare const ICliUserSessionService_TOKEN = "cli-user-session-service";
570
+ /**
571
+ * Token for the CLI users store service.
572
+ */
573
+ declare const ICliUsersStoreService_TOKEN = "cli-users-store-service";
574
+ /**
575
+ * Token for the CLI groups store service.
576
+ */
577
+ declare const ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
578
+ /**
579
+ * Token for the CLI auth service.
580
+ */
581
+ declare const ICliAuthService_TOKEN = "cli-auth-service";
582
+ /**
583
+ * Token for registering completion providers via module services (multi: true).
584
+ */
585
+ declare const ICliCompletionProvider_TOKEN = "cli-completion-provider";
586
+ /**
587
+ * Token for the drag-and-drop service.
588
+ */
589
+ declare const ICliDragDropService_TOKEN = "cli-drag-drop-service";
590
+ /**
591
+ * Token for the file transfer service.
592
+ */
593
+ declare const ICliFileTransferService_TOKEN = "cli-file-transfer-service";
594
+ /**
595
+ * Token for the translation service.
596
+ */
597
+ declare const ICliTranslationService_TOKEN = "cli-translation-service";
598
+ /**
599
+ * Token for the permission service.
600
+ */
601
+ declare const ICliPermissionService_TOKEN = "cli-permission-service";
602
+ /**
603
+ * Token for the file picker provider.
604
+ */
605
+ declare const ICliFilePickerProvider_TOKEN = "cli-file-picker-provider";
606
+
548
607
  /**
549
608
  * Options for readFile file picker.
550
609
  */
@@ -668,6 +727,17 @@ interface CliMultiSelectOptions {
668
727
  /** Callback invoked each time the set of checked options changes */
669
728
  onChange?: (values: string[]) => void;
670
729
  }
730
+ /**
731
+ * Options for readNumber input.
732
+ */
733
+ interface CliNumberOptions {
734
+ /** Minimum allowed value */
735
+ min?: number;
736
+ /** Maximum allowed value */
737
+ max?: number;
738
+ /** Pre-filled default value */
739
+ default?: number;
740
+ }
671
741
  /**
672
742
  * Options for readDate input.
673
743
  */
@@ -740,11 +810,7 @@ interface ICliInputReader {
740
810
  * @param options - Optional configuration for min, max, and default value
741
811
  * @returns The entered number, or null if aborted
742
812
  */
743
- readNumber(prompt: string, options?: {
744
- min?: number;
745
- max?: number;
746
- default?: number;
747
- }): Promise<number | null>;
813
+ readNumber(prompt: string, options?: CliNumberOptions): Promise<number | null>;
748
814
  /**
749
815
  * Read a date input with format validation.
750
816
  * @param prompt - The prompt text displayed to the user
@@ -762,7 +828,12 @@ interface ICliInputReader {
762
828
  }
763
829
 
764
830
  /**
765
- * Whether a background service is a long-running daemon or a one-shot job.
831
+ * Background service lifecycle type.
832
+ * - `'daemon'` — Long-running service whose `onStart` blocks until the abort signal
833
+ * fires. Suitable for event loops, polling, or WebSocket connections. Can be
834
+ * stopped and restarted.
835
+ * - `'job'` — Run-to-completion task whose `onStart` resolves when the work is done.
836
+ * Automatically transitions to `'done'` status on success. Cannot be restarted.
766
837
  */
767
838
  type CliBackgroundServiceType = 'daemon' | 'job';
768
839
  /**
@@ -791,12 +862,18 @@ interface ICliServiceEvent {
791
862
  * Handler function for service events.
792
863
  */
793
864
  type CliServiceEventHandler = (event: ICliServiceEvent) => void;
865
+ /**
866
+ * Log severity level for background service messages.
867
+ * Shared by `ICliServiceLogEntry`, `ICliServiceContext.log()`,
868
+ * and `WorkerServiceContext.log()`.
869
+ */
870
+ type CliServiceLogLevel = 'info' | 'warn' | 'error';
794
871
  /**
795
872
  * A single log entry from a background service.
796
873
  */
797
874
  interface ICliServiceLogEntry {
798
875
  timestamp: Date;
799
- level: 'info' | 'warn' | 'error';
876
+ level: CliServiceLogLevel;
800
877
  message: string;
801
878
  }
802
879
  /**
@@ -810,7 +887,7 @@ interface ICliServiceContext {
810
887
  /** Emit an event from this service */
811
888
  emit(event: ICliServiceEvent): void;
812
889
  /** Log a message to this service's private log buffer */
813
- log(message: string, level?: 'info' | 'warn' | 'error'): void;
890
+ log(message: string, level?: CliServiceLogLevel): void;
814
891
  /** Create an interval scoped to this service (auto-cleared on stop) */
815
892
  createInterval(callback: () => void, ms: number): ICliManagedInterval;
816
893
  /** Create a timeout scoped to this service (auto-cleared on stop) */
@@ -838,7 +915,11 @@ interface ICliBackgroundService {
838
915
  onStart(context: ICliServiceContext): Promise<void>;
839
916
  /** Called for graceful shutdown */
840
917
  onStop?(context: ICliServiceContext): Promise<void>;
841
- /** Called on unrecoverable error */
918
+ /**
919
+ * Called when the service throws an unrecoverable error.
920
+ * Use this hook for logging or cleanup; throwing from `onError` itself
921
+ * is safe — the registry catches it and marks the service as failed.
922
+ */
842
923
  onError?(error: Error, context: ICliServiceContext): void;
843
924
  }
844
925
  /**
@@ -869,7 +950,7 @@ interface ICliBackgroundServiceRegistry {
869
950
  restart(name: string): Promise<void>;
870
951
  startJob(name: string, task: (context: ICliServiceContext) => Promise<void>, options?: {
871
952
  workerCompatible?: boolean;
872
- }): void;
953
+ }): Promise<void>;
873
954
  getStatus(name: string): ICliBackgroundServiceInfo | undefined;
874
955
  list(): ICliBackgroundServiceInfo[];
875
956
  getLogs(name: string, limit?: number): ICliServiceLogEntry[];
@@ -887,14 +968,14 @@ interface ICliBackgroundServiceRegistry {
887
968
  */
888
969
  interface ICliManagedTimer {
889
970
  /** Clear this timer immediately. */
890
- clear(): void;
971
+ readonly clear: () => void;
891
972
  }
892
973
  /**
893
974
  * A managed interval handle with the ability to change the delay.
894
975
  */
895
976
  interface ICliManagedInterval extends ICliManagedTimer {
896
977
  /** Change the interval delay. Restarts the interval with the new delay. */
897
- setDelay(ms: number): void;
978
+ readonly setDelay: (ms: number) => void;
898
979
  }
899
980
  /**
900
981
  * Represents the context in which a command is executed
@@ -1234,7 +1315,7 @@ interface ICliCommandProcessor {
1234
1315
  /**
1235
1316
  * Represents the state configuration for the command processor
1236
1317
  * @remarks The state configuration is used to store and retrieve state information for the command processor
1237
- * @remarks State confihuration is optional and can be used to store and retrieve state information for the command processor
1318
+ * @remarks State configuration is optional and can be used to store and retrieve state information for the command processor
1238
1319
  * @remarks The state configuration is used only for root command processors and not for child command processors
1239
1320
  */
1240
1321
  stateConfiguration?: CliStateConfiguration;
@@ -1341,10 +1422,6 @@ interface ICliGlobalParameterHandler {
1341
1422
  handle(args: Record<string, any>, processor: ICliCommandProcessor, command: CliProcessCommand, context: ICliExecutionContext): boolean | Promise<boolean>;
1342
1423
  }
1343
1424
 
1344
- /**
1345
- * Token for registering completion providers via module services (multi: true).
1346
- */
1347
- declare const ICliCompletionProvider_TOKEN = "cli-completion-provider";
1348
1425
  /**
1349
1426
  * Context passed to completion providers describing the current input state.
1350
1427
  */
@@ -1416,9 +1493,9 @@ type CliPercentageProgressBarUpdateValueOptions = {
1416
1493
  */
1417
1494
  interface ICliPercentageProgressBar extends ICliProgressBar {
1418
1495
  /**
1419
- * Update the progress of the progress bar
1420
- * @param progress The progress to update to
1421
- * @returns void
1496
+ * Update the progress of the progress bar.
1497
+ * @param progress The progress value (0–100). Values outside this range are clamped.
1498
+ * @param options Optional: update type ('replace' or 'increment')
1422
1499
  */
1423
1500
  update: (progress: number, options?: CliPercentageProgressBarUpdateValueOptions) => void;
1424
1501
  /**
@@ -1446,9 +1523,9 @@ type CliTextAnimatorOptions = {
1446
1523
  interface ICliTextAnimator extends ICliProgressBar {
1447
1524
  /**
1448
1525
  * Show animated text in a typing and erasing effect.
1449
- * @param text
1450
- * @param options
1451
- * @returns
1526
+ * @param text The text to animate
1527
+ * @param options Optional: speed (ms per character), removeAfterTyping
1528
+ * @returns A promise that resolves when the animation completes
1452
1529
  */
1453
1530
  showText: (text: string, options?: CliTextAnimatorOptions) => Promise<void>;
1454
1531
  }
@@ -1587,10 +1664,7 @@ interface ICliFileEntry {
1587
1664
  size: number;
1588
1665
  modified: string;
1589
1666
  }
1590
- /**
1591
- * Token for the file transfer service.
1592
- */
1593
- declare const ICliFileTransferService_TOKEN = "cli-file-transfer-service";
1667
+
1594
1668
  /**
1595
1669
  * Abstraction for file transfer operations.
1596
1670
  * Default implementation uses browser-native APIs (file picker, download dialog).
@@ -1608,12 +1682,17 @@ interface ICliFileTransferService {
1608
1682
  } | null>;
1609
1683
  }
1610
1684
 
1611
- declare const ICliDragDropService_TOKEN = "cli-drag-drop-service";
1612
1685
  interface ICliDragDropService {
1613
1686
  /** Emits an array of dropped File objects each time files are dropped onto the terminal */
1614
1687
  readonly onFileDrop: Observable<File[]>;
1615
1688
  }
1616
1689
 
1690
+ /**
1691
+ * Opaque state value carried between lines during syntax highlighting.
1692
+ * Encodes context such as "inside a multi-line string" or "inside a block comment"
1693
+ * so the highlighter can resume correctly on the next line.
1694
+ * `0` typically represents the default/root state.
1695
+ */
1617
1696
  type LineState = number;
1618
1697
  interface ISyntaxHighlightRule {
1619
1698
  pattern: RegExp;
@@ -1622,6 +1701,8 @@ interface ISyntaxHighlightRule {
1622
1701
  }
1623
1702
  interface ISyntaxHighlighter {
1624
1703
  id: string;
1704
+ /** Human-readable language name (e.g. 'TypeScript'). Falls back to `id` when absent. */
1705
+ name?: string;
1625
1706
  extensions: string[];
1626
1707
  initialState: LineState;
1627
1708
  getRules(state: LineState): ISyntaxHighlightRule[];
@@ -1645,72 +1726,63 @@ interface ICliTerminalWriter {
1645
1726
  writeln(text?: string): void;
1646
1727
  /**
1647
1728
  * Write a success message to the terminal
1648
- * @param messag The message to write
1649
- * @returns void
1729
+ * @param message The message to write
1650
1730
  */
1651
- writeSuccess: (message: string) => void;
1731
+ writeSuccess(message: string): void;
1652
1732
  /**
1653
1733
  * Write an info message to the terminal
1654
- * @param messag The message to write
1655
- * @returns void
1734
+ * @param message The message to write
1656
1735
  */
1657
- writeInfo: (message: string) => void;
1736
+ writeInfo(message: string): void;
1658
1737
  /**
1659
1738
  * Write an error message to the terminal
1660
1739
  * @param message The message to write
1661
- * @returns void
1662
1740
  */
1663
- writeError: (message: string) => void;
1741
+ writeError(message: string): void;
1664
1742
  /**
1665
1743
  * Write a warning message to the terminal
1666
1744
  * @param message The message to write
1667
- * @returns void
1668
1745
  */
1669
- writeWarning: (message: string) => void;
1746
+ writeWarning(message: string): void;
1670
1747
  /**
1671
- * Write a message to the terminal with the specified color
1672
- * @param message The message to write
1673
- * @param color The color to use
1674
- * @returns void
1748
+ * Wrap text in the specified foreground color.
1749
+ * @param text The text to wrap
1750
+ * @param color The foreground color to apply
1751
+ * @returns The text wrapped in ANSI color codes
1675
1752
  */
1676
- wrapInColor: (text: string, color: CliForegroundColor) => string;
1753
+ wrapInColor(text: string, color: CliForegroundColor): string;
1677
1754
  /**
1678
- * Write a message to the terminal with the specified background color
1679
- * @param message The message to write
1680
- * @param color The background color to use
1681
- * @returns void
1755
+ * Wrap text in the specified background color.
1756
+ * @param text The text to wrap
1757
+ * @param color The background color to apply
1758
+ * @returns The text wrapped in ANSI background color codes
1682
1759
  */
1683
- wrapInBackgroundColor: (text: string, color: CliBackgroundColor) => string;
1760
+ wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
1684
1761
  /**
1685
1762
  * Write a JSON object to the terminal
1686
1763
  * @param json The JSON object to write
1687
- * @returns void
1688
1764
  */
1689
- writeJson: (json: any) => void;
1765
+ writeJson(json: any): void;
1690
1766
  /**
1691
- * Write content to a file
1692
- * @param fileName The name of the file to write to
1767
+ * Write content to a file (triggers a browser download)
1768
+ * @param fileName The name of the file to download
1693
1769
  * @param content The content to write to the file
1694
- * @returns void
1695
1770
  */
1696
- writeToFile: (fileName: string, content: string) => void;
1771
+ writeToFile(fileName: string, content: string): void;
1697
1772
  /**
1698
1773
  * Write an object array as a table to the terminal
1699
1774
  * @param objects The objects to write to the table
1700
- * @returns void
1701
1775
  */
1702
1776
  writeObjectsAsTable(objects: any[]): void;
1703
1777
  /**
1704
1778
  * Write a table to the terminal
1705
1779
  * @param headers The headers of the table
1706
1780
  * @param rows The rows of the table
1707
- * @returns void
1708
1781
  */
1709
1782
  writeTable(headers: string[], rows: string[][]): void;
1710
1783
  /**
1711
1784
  * Write a divider to the terminal
1712
- * @param options The options for the divider
1713
- * @returns void
1785
+ * @param options Optional: color, length, character
1714
1786
  */
1715
1787
  writeDivider(options?: {
1716
1788
  color?: CliForegroundColor;
@@ -1745,6 +1817,32 @@ interface ICliTerminalWriter {
1745
1817
  columns?: number;
1746
1818
  padding?: number;
1747
1819
  }): void;
1820
+ /**
1821
+ * Write a clickable hyperlink using OSC 8 escape sequences.
1822
+ * In terminals that support OSC 8, the text is clickable. In others,
1823
+ * it falls back to displaying "text (url)".
1824
+ * @param text The visible link text
1825
+ * @param url The URL to link to
1826
+ */
1827
+ writeLink(text: string, url: string): void;
1828
+ /**
1829
+ * Write text inside a bordered box.
1830
+ * Useful for callouts, notices, and highlighted information.
1831
+ * @param content The content lines to display inside the box
1832
+ * @param options Optional: title, border color, padding
1833
+ */
1834
+ writeBox(content: string | string[], options?: {
1835
+ title?: string;
1836
+ borderColor?: CliForegroundColor;
1837
+ padding?: number;
1838
+ }): void;
1839
+ /**
1840
+ * Write text with a specified indentation level.
1841
+ * Each level adds 2 spaces of indentation.
1842
+ * @param text The text to write
1843
+ * @param level The indentation level (default: 1)
1844
+ */
1845
+ writeIndented(text: string, level?: number): void;
1748
1846
  }
1749
1847
  /**
1750
1848
  * Represents a clipboard for the CLI
@@ -1767,9 +1865,10 @@ interface ICliClipboard {
1767
1865
  */
1768
1866
  interface ICliCommandExecutorService {
1769
1867
  /**
1770
- *
1771
- * @param command
1772
- * @param context
1868
+ * Display the help output for a command, including its description,
1869
+ * sub-commands, and parameters.
1870
+ * @param command The parsed command to show help for
1871
+ * @param context The execution context
1773
1872
  */
1774
1873
  showHelp(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
1775
1874
  /**
@@ -1944,16 +2043,24 @@ interface ICliKeyValueStore {
1944
2043
  clear(): Promise<void>;
1945
2044
  }
1946
2045
  /**
1947
- * Represents a store for storing data associated with commands
2046
+ * Reactive state store scoped to a command processor or module.
2047
+ *
2048
+ * State is a plain object (`Record<string, any>`). Updates are shallow-merged
2049
+ * (top-level keys are replaced, nested objects are not deep-merged).
2050
+ * `getState()` returns a snapshot — mutating the returned object has no effect;
2051
+ * always use `updateState()` to change state.
1948
2052
  */
1949
2053
  interface ICliStateStore {
1950
2054
  /**
1951
- * Get the current state as an object.
2055
+ * Get a snapshot of the current state.
2056
+ * @returns A shallow copy of the state object
1952
2057
  */
1953
2058
  getState<T extends CliState = CliState>(): T;
1954
2059
  /**
1955
- * Update the state with new values. Supports partial updates.
1956
- * @param newState Partial state to merge with the current state.
2060
+ * Shallow-merge new values into the current state.
2061
+ * Only the provided keys are updated; other keys are preserved.
2062
+ * Triggers subscribers and persists if a storage backend is configured.
2063
+ * @param newState Partial state to merge with the current state
1957
2064
  */
1958
2065
  updateState(newState: Partial<CliState>): void;
1959
2066
  /**
@@ -2052,6 +2159,22 @@ interface ICliModule {
2052
2159
  /** Called when the module is being torn down */
2053
2160
  onDestroy?(context: ICliExecutionContext): Promise<void>;
2054
2161
  }
2162
+ /**
2163
+ * A module that accepts typed configuration via `configure()`.
2164
+ * Extend this instead of `ICliModule` when your module has a config type.
2165
+ *
2166
+ * @example
2167
+ * ```ts
2168
+ * interface MyModuleConfig { verbose?: boolean }
2169
+ * const myModule: ICliConfigurableModule<MyModuleConfig> = {
2170
+ * configure(config) { return { ...this, config }; },
2171
+ * // ...
2172
+ * };
2173
+ * ```
2174
+ */
2175
+ interface ICliConfigurableModule<T extends Record<string, any> = Record<string, any>> extends ICliModule {
2176
+ configure(config: T): ICliModule;
2177
+ }
2055
2178
  /**
2056
2179
  * @deprecated Use ICliModule instead
2057
2180
  */
@@ -2068,32 +2191,32 @@ interface ICliLogger {
2068
2191
  */
2069
2192
  setCliLogLevel(level: CliLogLevel): void;
2070
2193
  /**
2071
- * Log a message
2194
+ * Log a general message (LOG level)
2072
2195
  * @param args The arguments to log
2073
2196
  */
2074
2197
  log(...args: any[]): void;
2075
2198
  /**
2076
- * Log a message
2199
+ * Log an informational message (INFO level)
2077
2200
  * @param args The arguments to log
2078
2201
  */
2079
2202
  info(...args: any[]): void;
2080
2203
  /**
2081
- * Log a message
2204
+ * Log a warning message (WARN level)
2082
2205
  * @param args The arguments to log
2083
2206
  */
2084
2207
  warn(...args: any[]): void;
2085
2208
  /**
2086
- * Log a message
2209
+ * Log an error message (ERROR level)
2087
2210
  * @param args The arguments to log
2088
2211
  */
2089
2212
  error(...args: any[]): void;
2090
2213
  /**
2091
- * Log a message
2214
+ * Log a debug message (DEBUG level)
2092
2215
  * @param args The arguments to log
2093
2216
  */
2094
2217
  debug(...args: any[]): void;
2095
2218
  }
2096
- declare const ICliTranslationService_TOKEN = "cli-translation-service";
2219
+
2097
2220
  /**
2098
2221
  * Provides internationalization (i18n) support for CLI strings.
2099
2222
  */
@@ -2127,23 +2250,24 @@ interface ICliTranslationService {
2127
2250
  getAvailableLocales(): string[];
2128
2251
  }
2129
2252
  /**
2130
- * Represents a service provider for the CLI
2253
+ * Dependency injection container for CLI services.
2254
+ * Services are registered with string tokens and retrieved by type.
2131
2255
  */
2132
2256
  interface ICliServiceProvider {
2133
2257
  /**
2134
- * Get a service
2135
- * @param service The service to get
2258
+ * Retrieve a service by its injection token.
2259
+ * @param service The token (typically a `*_TOKEN` constant) identifying the service
2260
+ * @returns The service instance, cast to `T`
2261
+ * @throws If no service is registered for the given token
2136
2262
  */
2137
- get<T>(service: any): T;
2263
+ get<T = unknown>(service: any): T;
2138
2264
  /**
2139
- * Set a service
2140
- * @param definition The definition of the service
2265
+ * Register one or more service definitions.
2266
+ * @param definition A single provider or an array of providers to register
2141
2267
  */
2142
2268
  set(definition: CliProvider | CliProvider[]): void;
2143
2269
  }
2144
2270
 
2145
- declare const ICliPermissionService_TOKEN = "cli-permission-service";
2146
-
2147
2271
  /**
2148
2272
  * Abstract permission service for checking rwx permissions on resources.
2149
2273
  * The default implementation lives in @qodalis/cli-users; consumers can
@@ -2172,13 +2296,15 @@ interface ICliPermissionService {
2172
2296
  declare class CliModuleRegistry {
2173
2297
  private readonly modules;
2174
2298
  private readonly bootHandlers;
2299
+ /** Optional warning callback — set by the engine to route through ICliLogger */
2300
+ onWarn?: (message: string) => void;
2175
2301
  /**
2176
2302
  * Register a handler that is called whenever a new module is registered.
2177
2303
  */
2178
2304
  onModuleBoot(handler: (module: ICliModule) => Promise<void>): void;
2179
2305
  /**
2180
2306
  * Register a module and notify all boot handlers.
2181
- * Modules that do not meet the required API version are silently skipped.
2307
+ * Modules that do not meet the required API version are skipped with a warning.
2182
2308
  */
2183
2309
  register(module: ICliModule): Promise<void>;
2184
2310
  /**
@@ -2242,6 +2368,17 @@ declare const CLI_CONFIGURE_STORE_NAME = "configure";
2242
2368
  * @returns The configured value or the default
2243
2369
  */
2244
2370
  declare function getConfigValue<T = any>(state: ICliStateStore, category: string, key: string, defaultValue: T): T;
2371
+ /**
2372
+ * Retrieves a plugin configuration value from the execution context.
2373
+ * This is a convenience wrapper for plugins — handles store lookup internally.
2374
+ *
2375
+ * @param context The execution context
2376
+ * @param category The category (usually the processor's command name)
2377
+ * @param key The configuration key
2378
+ * @param defaultValue Fallback value if not configured
2379
+ * @returns The configured value or the default
2380
+ */
2381
+ declare function getPluginConfigValue<T = any>(context: ICliExecutionContext, category: string, key: string, defaultValue: T): T;
2245
2382
  /**
2246
2383
  * Resolves all configuration options from registered processors,
2247
2384
  * grouped by category.
@@ -2251,6 +2388,10 @@ declare function resolveConfigurationCategories(registry: ICliCommandProcessorRe
2251
2388
  options: ICliConfigurationOption[];
2252
2389
  }>;
2253
2390
 
2391
+ /**
2392
+ * Returns a promise that resolves after the given number of milliseconds.
2393
+ * @param ms Delay duration in milliseconds
2394
+ */
2254
2395
  declare const delay: (ms: number) => Promise<void>;
2255
2396
 
2256
2397
  /**
@@ -2288,7 +2429,7 @@ interface ServerVersionInfo {
2288
2429
  * Negotiates the API version between a frontend CLI client and a backend server.
2289
2430
  *
2290
2431
  * Flow:
2291
- * 1. Client calls `discover(baseUrl)` which hits `GET /api/qcli/versions`
2432
+ * 1. Client calls `discover(baseUrl)` which hits `GET ${VERSIONS_ENDPOINT}`
2292
2433
  * 2. Server returns supported versions
2293
2434
  * 3. Client picks the highest mutually supported version
2294
2435
  * 4. All subsequent calls use `/api/v{n}/qcli/*`
@@ -2344,18 +2485,72 @@ declare function savePanelPosition(position: CliPanelPosition): void;
2344
2485
  */
2345
2486
  declare function nextPanelPosition(current: CliPanelPosition): CliPanelPosition;
2346
2487
 
2347
- declare const getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
2488
+ /**
2489
+ * Strip all ANSI escape sequences from a string.
2490
+ * @param text The text potentially containing ANSI codes
2491
+ * @returns The text with all ANSI codes removed
2492
+ */
2493
+ declare function stripAnsi(text: string): string;
2494
+ /**
2495
+ * Return the visible length of a string, ignoring ANSI escape codes.
2496
+ * Useful for padding/alignment calculations in terminal output.
2497
+ * @param text The text potentially containing ANSI codes
2498
+ * @returns The number of visible characters
2499
+ */
2500
+ declare function visibleLength(text: string): number;
2501
+
2502
+ /**
2503
+ * Retrieve a parameter's value from the parsed arguments, checking aliases.
2504
+ * @param p The parameter descriptor
2505
+ * @param args The parsed command arguments
2506
+ * @returns The matched value, or `undefined` if not found
2507
+ */
2508
+ declare const getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => unknown;
2509
+ /**
2510
+ * Pretty-print a JSON value with ANSI color highlighting.
2511
+ * @param json The value to format
2512
+ * @returns A colorized, indented string suitable for terminal output
2513
+ */
2348
2514
  declare const formatJson: (json: any) => string;
2349
- declare const colorizeJson: (jsonString: any) => string;
2515
+ /**
2516
+ * Apply ANSI color codes to a JSON string (keys, strings, numbers, booleans, null).
2517
+ * @param jsonString The raw JSON string to colorize
2518
+ * @returns The colorized string
2519
+ */
2520
+ declare const colorizeJson: (jsonString: string) => string;
2521
+ /**
2522
+ * Convert a key-value object to a URL query string. Arrays produce repeated keys.
2523
+ * @param params The parameters to encode
2524
+ * @returns The encoded query string (without leading `?`)
2525
+ */
2350
2526
  declare const toQueryString: (params: Record<string, any>) => string;
2527
+ /**
2528
+ * Highlight regex matches in text using an ANSI background color.
2529
+ * @param text The source text
2530
+ * @param pattern The regex pattern to highlight
2531
+ * @param bgColor The background color to apply (default: Yellow)
2532
+ * @returns The text with matching segments wrapped in ANSI background color codes
2533
+ */
2351
2534
  declare const highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
2535
+ /**
2536
+ * Extract the substring to the right of a given word in a command string.
2537
+ * @param command The full command string
2538
+ * @param word The word to search for
2539
+ * @returns The trimmed text after the word, or `undefined` if not found
2540
+ */
2352
2541
  declare const getRightOfWord: (command: string, word: string) => string | undefined;
2542
+ /**
2543
+ * Apply a color function to the first word of a text string, preserving leading whitespace.
2544
+ * @param text The text to process
2545
+ * @param colorFunction A function that wraps a word in ANSI color codes
2546
+ * @returns The text with only the first word colorized
2547
+ */
2353
2548
  declare const colorFirstWord: (text: string, colorFunction: (word: string) => string) => string;
2354
2549
 
2355
2550
  declare const utils: {
2356
- getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => any | undefined;
2551
+ getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => unknown;
2357
2552
  formatJson: (json: any) => string;
2358
- colorizeJson: (jsonString: any) => string;
2553
+ colorizeJson: (jsonString: string) => string;
2359
2554
  toQueryString: (params: Record<string, any>) => string;
2360
2555
  highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
2361
2556
  getRightOfWord: (command: string, word: string) => string | undefined;
@@ -2363,6 +2558,7 @@ declare const utils: {
2363
2558
  ObjectDescriber: typeof ObjectDescriber;
2364
2559
  delay: (ms: number) => Promise<void>;
2365
2560
  getConfigValue: typeof getConfigValue;
2561
+ getPluginConfigValue: typeof getPluginConfigValue;
2366
2562
  resolveConfigurationCategories: typeof resolveConfigurationCategories;
2367
2563
  CLI_CONFIGURE_STORE_NAME: string;
2368
2564
  };
@@ -2372,12 +2568,38 @@ declare const constants: {
2372
2568
  DefaultLibraryAuthor: ICliCommandAuthor;
2373
2569
  };
2374
2570
 
2571
+ /** Error message used when a `CancellablePromise` is cancelled. */
2572
+ declare const CANCELLATION_ERROR_MESSAGE = "Promise cancelled";
2573
+ /**
2574
+ * A promise wrapper that supports cooperative cancellation.
2575
+ *
2576
+ * Create with an executor (like `new Promise`), then call `execute()` to run.
2577
+ * Call `cancel()` to reject with a cancellation error and prevent further
2578
+ * resolve/reject callbacks from firing.
2579
+ *
2580
+ * @example
2581
+ * ```ts
2582
+ * const cp = new CancellablePromise<string>((resolve) => {
2583
+ * setTimeout(() => resolve('done'), 5000);
2584
+ * });
2585
+ * cp.execute().catch(e => console.log(e.message)); // 'Promise cancelled'
2586
+ * cp.cancel();
2587
+ * ```
2588
+ */
2375
2589
  declare class CancellablePromise<T> {
2376
2590
  private executor;
2377
2591
  private hasCancelled;
2378
2592
  private abortController;
2379
2593
  constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void) => void);
2594
+ /**
2595
+ * Run the executor and return a promise for its result.
2596
+ * If `cancel()` has been called, the promise rejects immediately.
2597
+ */
2380
2598
  execute(): Promise<T>;
2599
+ /**
2600
+ * Cancel the promise. The executing promise rejects with
2601
+ * `Error('Promise cancelled')` and subsequent resolve/reject calls are ignored.
2602
+ */
2381
2603
  cancel(): void;
2382
2604
  }
2383
2605
 
@@ -2427,30 +2649,9 @@ declare const DefaultThemes: DefaultThemesType;
2427
2649
 
2428
2650
  declare const DefaultThemeInfos: Record<string, CliThemeInfo>;
2429
2651
 
2430
- declare const LIBRARY_VERSION = "2.0.0-beta.8";
2652
+ declare const LIBRARY_VERSION = "2.0.0-beta.9";
2431
2653
  declare const API_VERSION = 2;
2432
2654
 
2433
- /**
2434
- * Framework-agnostic token for the CLI user session service.
2435
- * Used as a key in the service provider to retrieve the user session service.
2436
- */
2437
- declare const ICliUserSessionService_TOKEN = "cli-user-session-service";
2438
- /**
2439
- * Framework-agnostic token for the CLI users store service.
2440
- * Used as a key in the service provider to retrieve the users store service.
2441
- */
2442
- declare const ICliUsersStoreService_TOKEN = "cli-users-store-service";
2443
- /**
2444
- * Framework-agnostic token for the CLI groups store service.
2445
- * Used as a key in the service provider to retrieve the groups store service.
2446
- */
2447
- declare const ICliGroupsStoreService_TOKEN = "cli-groups-store-service";
2448
- /**
2449
- * Framework-agnostic token for the CLI auth service.
2450
- * Used as a key in the service provider to retrieve the auth service.
2451
- */
2452
- declare const ICliAuthService_TOKEN = "cli-auth-service";
2453
-
2454
2655
  /**
2455
2656
  * Context provided to worker service handlers inside a Web Worker.
2456
2657
  */
@@ -2458,7 +2659,7 @@ interface WorkerServiceContext {
2458
2659
  /** Emit an event to the main thread */
2459
2660
  emit(event: Omit<ICliServiceEvent, 'timestamp'>): void;
2460
2661
  /** Log a message (forwarded to the main-thread log buffer) */
2461
- log(message: string, level?: 'info' | 'warn' | 'error'): void;
2662
+ log(message: string, level?: CliServiceLogLevel): void;
2462
2663
  /** Update state on the main thread */
2463
2664
  updateState(patch: Record<string, unknown>): void;
2464
2665
  /** Create an interval that is auto-cleared on stop */
@@ -2477,10 +2678,29 @@ declare function createWorkerService(handlers: {
2477
2678
  onStop?(): Promise<void>;
2478
2679
  }): void;
2479
2680
 
2681
+ /**
2682
+ * Browser-based file transfer service using native browser APIs.
2683
+ *
2684
+ * This is the default implementation when no virtual filesystem is available.
2685
+ * `readFile` and `uploadFromBrowser` open a file picker dialog.
2686
+ * `writeFile` and `downloadToBrowser` trigger a browser download.
2687
+ *
2688
+ * **Limitations:** `listFiles()` and `exists()` are not supported in the
2689
+ * browser environment and always return empty/false respectively.
2690
+ * Use `@qodalis/cli-files` for full filesystem capabilities.
2691
+ */
2480
2692
  declare class BrowserFileTransferService implements ICliFileTransferService {
2481
2693
  readFile(_path: string): Promise<string | null>;
2482
2694
  writeFile(path: string, content: string): Promise<void>;
2695
+ /**
2696
+ * Not supported in browser — always returns an empty array.
2697
+ * Use `@qodalis/cli-files` for directory listing.
2698
+ */
2483
2699
  listFiles(_path: string): Promise<ICliFileEntry[]>;
2700
+ /**
2701
+ * Not supported in browser — always returns `false`.
2702
+ * Use `@qodalis/cli-files` for file existence checks.
2703
+ */
2484
2704
  exists(_path: string): Promise<boolean>;
2485
2705
  downloadToBrowser(filename: string, content: string | Blob): void;
2486
2706
  uploadFromBrowser(accept?: string): Promise<{
@@ -2490,4 +2710,4 @@ declare class BrowserFileTransferService implements ICliFileTransferService {
2490
2710
  private _pickFile;
2491
2711
  }
2492
2712
 
2493
- export { API_VERSION, BrowserFileTransferService, CLI_CONFIGURE_STORE_NAME, CancellablePromise, type CliAddUser, CliBackgroundColor, type CliBackgroundServiceStatus, type CliBackgroundServiceType, type CliDateOptions, type CliEngineSnapshot, type CliFactoryProvider, type CliFilePickerOptions, type CliFileResult, CliForegroundColor, CliIcon, type CliLineOptions, CliLogLevel, CliModuleRegistry, type CliMultiSelectOption, type CliMultiSelectOptions, type CliOptions, type CliPackageSource, type CliPanelConfig, type CliPanelHideAlignment, type CliPanelPosition, 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 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 ICliFilePickerProvider, 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 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, getRightOfWord, highlightTextWithBg, initializeBrowserEnvironment, loadPanelPosition, nextPanelPosition, resolveConfigurationCategories, satisfiesMinVersion, satisfiesVersionRange, savePanelPosition, toQueryString, utils };
2713
+ 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, CliIcon, type CliLineOptions, CliLogLevel, CliModuleRegistry, type CliMultiSelectOption, type CliMultiSelectOptions, type CliNumberOptions, type CliOptions, type CliPackageSource, type CliPanelConfig, type CliPanelHideAlignment, type CliPanelPosition, 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 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 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 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 };