@qodalis/cli-core 2.0.0-beta.1 → 2.0.0-beta.10
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/README.md +213 -9
- package/package.json +1 -1
- package/public-api.d.mts +1700 -1251
- package/public-api.d.ts +1700 -1251
- package/public-api.js +150 -55
- package/public-api.js.map +1 -1
- package/public-api.mjs +146 -56
- package/public-api.mjs.map +1 -1
package/public-api.d.ts
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
|
-
*
|
|
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\
|
|
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 = "\
|
|
230
|
-
Extension = "\
|
|
231
|
-
Module = "\
|
|
232
|
-
Evaluate = "\uD83D\uDD0D"
|
|
233
|
-
Variable = "\
|
|
234
|
-
Script = "\uD83D\uDCDC"
|
|
235
|
-
Code = "\uD83D\
|
|
236
|
-
Logs = "\uD83D\
|
|
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/
|
|
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/
|
|
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
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
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
|
|
488
|
+
* Represents a user in the CLI
|
|
550
489
|
*/
|
|
551
|
-
interface
|
|
552
|
-
/**
|
|
553
|
-
|
|
554
|
-
/**
|
|
555
|
-
|
|
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
|
|
509
|
+
* Represents user credentials (shadow pattern — stored separately from ICliUser)
|
|
559
510
|
*/
|
|
560
|
-
interface
|
|
561
|
-
/**
|
|
562
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
*
|
|
571
|
-
* @param
|
|
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
|
-
|
|
587
|
+
writeln(text?: string): void;
|
|
575
588
|
/**
|
|
576
|
-
*
|
|
577
|
-
* @param
|
|
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
|
-
|
|
592
|
+
writeSuccess(message: string): void;
|
|
581
593
|
/**
|
|
582
|
-
*
|
|
583
|
-
* @param
|
|
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
|
-
|
|
597
|
+
writeInfo(message: string): void;
|
|
588
598
|
/**
|
|
589
|
-
*
|
|
590
|
-
* @param
|
|
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
|
-
|
|
602
|
+
writeError(message: string): void;
|
|
596
603
|
/**
|
|
597
|
-
*
|
|
598
|
-
*
|
|
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
|
-
|
|
607
|
+
writeWarning(message: string): void;
|
|
605
608
|
/**
|
|
606
|
-
*
|
|
607
|
-
*
|
|
608
|
-
* @param
|
|
609
|
-
* @
|
|
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
|
-
|
|
614
|
+
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
613
615
|
/**
|
|
614
|
-
*
|
|
615
|
-
* @param
|
|
616
|
-
* @param
|
|
617
|
-
* @returns The
|
|
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
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
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
|
-
*
|
|
711
|
+
* Represents a clipboard for the CLI
|
|
628
712
|
*/
|
|
629
|
-
|
|
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
|
-
*
|
|
728
|
+
* Token for the CLI user session service.
|
|
632
729
|
*/
|
|
633
|
-
|
|
730
|
+
declare const ICliUserSessionService_TOKEN = "cli-user-session-service";
|
|
634
731
|
/**
|
|
635
|
-
*
|
|
732
|
+
* Token for the CLI users store service.
|
|
636
733
|
*/
|
|
637
|
-
|
|
734
|
+
declare const ICliUsersStoreService_TOKEN = "cli-users-store-service";
|
|
638
735
|
/**
|
|
639
|
-
*
|
|
640
|
-
* Services control terminal notification visibility by setting `data.notify: true`.
|
|
736
|
+
* Token for the CLI groups store service.
|
|
641
737
|
*/
|
|
642
|
-
|
|
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
|
-
*
|
|
740
|
+
* Token for the CLI auth service.
|
|
654
741
|
*/
|
|
655
|
-
|
|
742
|
+
declare const ICliAuthService_TOKEN = "cli-auth-service";
|
|
656
743
|
/**
|
|
657
|
-
*
|
|
744
|
+
* Token for registering completion providers via module services (multi: true).
|
|
658
745
|
*/
|
|
659
|
-
|
|
660
|
-
timestamp: Date;
|
|
661
|
-
level: 'info' | 'warn' | 'error';
|
|
662
|
-
message: string;
|
|
663
|
-
}
|
|
746
|
+
declare const ICliCompletionProvider_TOKEN = "cli-completion-provider";
|
|
664
747
|
/**
|
|
665
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
752
|
+
* Token for the file transfer service.
|
|
687
753
|
*/
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
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()
|
|
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)
|
|
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
|
-
*
|
|
890
|
-
* so that all terminal input is routed to
|
|
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.
|
|
@@ -974,644 +1373,242 @@ interface ICliCommandParameterDescriptor {
|
|
|
974
1373
|
*/
|
|
975
1374
|
valid: boolean;
|
|
976
1375
|
/**
|
|
977
|
-
* An optional message to display if the value is not valid
|
|
978
|
-
*/
|
|
979
|
-
message?: string;
|
|
980
|
-
};
|
|
981
|
-
}
|
|
982
|
-
/**
|
|
983
|
-
* Represents a configuration option that a command processor exposes
|
|
984
|
-
* for management via the `configure` command.
|
|
985
|
-
*/
|
|
986
|
-
interface ICliConfigurationOption {
|
|
987
|
-
/**
|
|
988
|
-
* The key used to store and retrieve this option, e.g. 'maxItems'
|
|
989
|
-
*/
|
|
990
|
-
key: string;
|
|
991
|
-
/**
|
|
992
|
-
* Human-readable label shown in the interactive menu
|
|
993
|
-
*/
|
|
994
|
-
label: string;
|
|
995
|
-
/**
|
|
996
|
-
* Description of what this option controls
|
|
997
|
-
*/
|
|
998
|
-
description: string;
|
|
999
|
-
/**
|
|
1000
|
-
* The data type of the option
|
|
1001
|
-
*/
|
|
1002
|
-
type: 'string' | 'number' | 'boolean' | 'select';
|
|
1003
|
-
/**
|
|
1004
|
-
* The default value when no configuration has been set
|
|
1005
|
-
*/
|
|
1006
|
-
defaultValue: any;
|
|
1007
|
-
/**
|
|
1008
|
-
* Available choices for 'select' type options
|
|
1009
|
-
*/
|
|
1010
|
-
options?: {
|
|
1011
|
-
label: string;
|
|
1012
|
-
value: any;
|
|
1013
|
-
}[];
|
|
1014
|
-
/**
|
|
1015
|
-
* Optional validator function
|
|
1016
|
-
*/
|
|
1017
|
-
validator?: (value: any) => {
|
|
1018
|
-
valid: boolean;
|
|
1019
|
-
message?: string;
|
|
1020
|
-
};
|
|
1021
|
-
/**
|
|
1022
|
-
* Override the category grouping (defaults to the processor command name)
|
|
1023
|
-
*/
|
|
1024
|
-
category?: string;
|
|
1025
|
-
}
|
|
1026
|
-
/**
|
|
1027
|
-
* Represents a command processor
|
|
1028
|
-
*/
|
|
1029
|
-
interface ICliCommandProcessor {
|
|
1030
|
-
/**
|
|
1031
|
-
* The command that this processor handles
|
|
1032
|
-
*/
|
|
1033
|
-
command: string;
|
|
1034
|
-
/**
|
|
1035
|
-
* Alternative names for the command
|
|
1036
|
-
*/
|
|
1037
|
-
aliases?: string[];
|
|
1038
|
-
/**
|
|
1039
|
-
* A description of the command
|
|
1040
|
-
*/
|
|
1041
|
-
description?: string;
|
|
1042
|
-
/**
|
|
1043
|
-
* The author of the command
|
|
1044
|
-
*/
|
|
1045
|
-
author?: ICliCommandAuthor;
|
|
1046
|
-
/**
|
|
1047
|
-
* If true, the processor accepts raw text input after the command name as its value.
|
|
1048
|
-
* The captured text is available via `command.value` in `processCommand`.
|
|
1049
|
-
* @default false
|
|
1050
|
-
* @remarks When true, any text following the command name is extracted as the command value
|
|
1051
|
-
* rather than being interpreted as sub-commands. Use `valueRequired` instead if the value is mandatory.
|
|
1052
|
-
*/
|
|
1053
|
-
acceptsRawInput?: boolean;
|
|
1054
|
-
/**
|
|
1055
|
-
* If true, the command requires some form of input before it can execute.
|
|
1056
|
-
*
|
|
1057
|
-
* The requirement is satisfied by **any** of:
|
|
1058
|
-
* - A positional value (text after the command name, available via `command.value`)
|
|
1059
|
-
* - Piped data from a previous command (available via `command.data`)
|
|
1060
|
-
* - Named arguments (e.g. `--server=node --path=/app`)
|
|
1061
|
-
*
|
|
1062
|
-
* When set, `command.value` is automatically extracted from the raw input
|
|
1063
|
-
* (equivalent to setting `acceptsRawInput`).
|
|
1064
|
-
*
|
|
1065
|
-
* Additionally, when positional input is present the engine skips
|
|
1066
|
-
* required-parameter validation — the processor is responsible for
|
|
1067
|
-
* parsing positional text into individual values. Required-parameter
|
|
1068
|
-
* checks still apply when the user provides only named arguments.
|
|
1069
|
-
*
|
|
1070
|
-
* @default false
|
|
1071
|
-
*/
|
|
1072
|
-
valueRequired?: boolean;
|
|
1073
|
-
/**
|
|
1074
|
-
* The version of the command processor
|
|
1075
|
-
* @default '1.0.0'
|
|
1076
|
-
*/
|
|
1077
|
-
version?: string;
|
|
1078
|
-
/**
|
|
1079
|
-
* The metadata for the command processor
|
|
1080
|
-
*/
|
|
1081
|
-
metadata?: CliProcessorMetadata;
|
|
1082
|
-
/**
|
|
1083
|
-
* Processors that are nested under this processor
|
|
1084
|
-
*/
|
|
1085
|
-
processors?: ICliCommandChildProcessor[];
|
|
1086
|
-
/**
|
|
1087
|
-
* Parameters that the command accepts
|
|
1088
|
-
*/
|
|
1089
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
1090
|
-
/**
|
|
1091
|
-
* Hooks that are executed before and after the command is processed
|
|
1092
|
-
*/
|
|
1093
|
-
hooks?: ICliProcessorHook[];
|
|
1094
|
-
/**
|
|
1095
|
-
* Represents the state configuration for the command processor
|
|
1096
|
-
* @remarks The state configuration is used to store and retrieve state information for the command processor
|
|
1097
|
-
* @remarks State confihuration is optional and can be used to store and retrieve state information for the command processor
|
|
1098
|
-
* @remarks The state configuration is used only for root command processors and not for child command processors
|
|
1099
|
-
*/
|
|
1100
|
-
stateConfiguration?: CliStateConfiguration;
|
|
1101
|
-
/**
|
|
1102
|
-
* Configuration options exposed by this processor for the `configure` command.
|
|
1103
|
-
* When defined, these options appear in the interactive configuration menu
|
|
1104
|
-
* and can be managed via `configure get/set` subcommands.
|
|
1105
|
-
*/
|
|
1106
|
-
configurationOptions?: ICliConfigurationOption[];
|
|
1107
|
-
/**
|
|
1108
|
-
* When true, this processor extends (wraps) an existing processor with the same
|
|
1109
|
-
* command name instead of replacing it. The registry sets `originalProcessor`
|
|
1110
|
-
* to the previous processor so this one can delegate to it.
|
|
1111
|
-
*/
|
|
1112
|
-
extendsProcessor?: boolean;
|
|
1113
|
-
/**
|
|
1114
|
-
* Reference to the original processor that this one extends.
|
|
1115
|
-
* Set automatically by the registry — do not set manually.
|
|
1116
|
-
* Call `this.originalProcessor.processCommand(command, context)` to delegate.
|
|
1117
|
-
*/
|
|
1118
|
-
originalProcessor?: ICliCommandProcessor;
|
|
1119
|
-
/**
|
|
1120
|
-
* Process the command
|
|
1121
|
-
* @param command The command to process
|
|
1122
|
-
* @param context The context in which the command is executed
|
|
1123
|
-
*/
|
|
1124
|
-
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
1125
|
-
/**
|
|
1126
|
-
* Write the description of the command
|
|
1127
|
-
* @param context The context in which the command is executed
|
|
1128
|
-
*/
|
|
1129
|
-
writeDescription?(context: ICliExecutionContext): void;
|
|
1130
|
-
/**
|
|
1131
|
-
* A function that validates the command before execution
|
|
1132
|
-
* @param value The value to validate
|
|
1133
|
-
* @returns An object with a valid property that indicates if the value is valid and an optional message property that contains a message to display if the value is not valid
|
|
1134
|
-
*/
|
|
1135
|
-
validateBeforeExecution?: (command: CliProcessCommand, context: ICliExecutionContext) => {
|
|
1136
|
-
valid: boolean;
|
|
1137
|
-
message?: string;
|
|
1138
|
-
};
|
|
1139
|
-
/**
|
|
1140
|
-
* Initialize the command processor
|
|
1141
|
-
* @param context The context in which the command is executed
|
|
1142
|
-
*/
|
|
1143
|
-
initialize?(context: ICliExecutionContext): Promise<void>;
|
|
1144
|
-
/**
|
|
1145
|
-
* Handle raw terminal data when this processor is the active context processor.
|
|
1146
|
-
* When implemented, ALL terminal input is routed here instead of normal CLI input handling.
|
|
1147
|
-
* Used for full-screen interactive modes (editors, pagers, etc.).
|
|
1148
|
-
* @param data The raw terminal data string (escape sequences, control chars, printable text)
|
|
1149
|
-
* @param context The execution context
|
|
1150
|
-
*/
|
|
1151
|
-
onData?(data: string, context: ICliExecutionContext): Promise<void>;
|
|
1152
|
-
/**
|
|
1153
|
-
* Called when the terminal is resized while this processor is the active
|
|
1154
|
-
* full-screen context processor. Allows processors to adapt their rendering
|
|
1155
|
-
* to the new terminal dimensions.
|
|
1156
|
-
* @param cols The new number of columns
|
|
1157
|
-
* @param rows The new number of rows
|
|
1158
|
-
* @param context The execution context
|
|
1159
|
-
*/
|
|
1160
|
-
onResize?(cols: number, rows: number, context: ICliExecutionContext): void;
|
|
1161
|
-
/**
|
|
1162
|
-
* Called when the processor is being disposed — either because full-screen
|
|
1163
|
-
* mode ended, the terminal disconnected, or the CLI component is being
|
|
1164
|
-
* destroyed. Use this to clean up resources (timers, subscriptions, etc.).
|
|
1165
|
-
* @param context The execution context
|
|
1166
|
-
*/
|
|
1167
|
-
onDispose?(context: ICliExecutionContext): void;
|
|
1168
|
-
}
|
|
1169
|
-
/**
|
|
1170
|
-
* Represents a child command processor
|
|
1171
|
-
*/
|
|
1172
|
-
interface ICliCommandChildProcessor extends ICliCommandProcessor {
|
|
1173
|
-
/**
|
|
1174
|
-
* The parent processor, it is populated by the processor manager
|
|
1175
|
-
*/
|
|
1176
|
-
parent?: ICliCommandProcessor;
|
|
1177
|
-
}
|
|
1178
|
-
|
|
1179
|
-
/**
|
|
1180
|
-
* Describes a global parameter (e.g. --help, --version) together with
|
|
1181
|
-
* the handler that executes when the parameter is present.
|
|
1182
|
-
*
|
|
1183
|
-
* Global parameters are checked for every command before the command
|
|
1184
|
-
* processor's own `processCommand` runs. If the handler returns `true`,
|
|
1185
|
-
* command execution is halted (the parameter "consumed" the invocation).
|
|
1186
|
-
*/
|
|
1187
|
-
interface ICliGlobalParameterHandler {
|
|
1188
|
-
/**
|
|
1189
|
-
* The parameter descriptor shown in help output and used for tab-completion.
|
|
1190
|
-
*/
|
|
1191
|
-
parameter: ICliCommandParameterDescriptor;
|
|
1192
|
-
/**
|
|
1193
|
-
* Execution priority — lower values run first.
|
|
1194
|
-
* @default 0
|
|
1195
|
-
*/
|
|
1196
|
-
priority?: number;
|
|
1197
|
-
/**
|
|
1198
|
-
* Evaluate and optionally handle the parameter.
|
|
1199
|
-
* @returns `true` to halt command execution, `false` to continue.
|
|
1200
|
-
*/
|
|
1201
|
-
handle(args: Record<string, any>, processor: ICliCommandProcessor, command: CliProcessCommand, context: ICliExecutionContext): boolean | Promise<boolean>;
|
|
1202
|
-
}
|
|
1203
|
-
|
|
1204
|
-
/**
|
|
1205
|
-
* Token for registering completion providers via module services (multi: true).
|
|
1206
|
-
*/
|
|
1207
|
-
declare const ICliCompletionProvider_TOKEN = "cli-completion-provider";
|
|
1208
|
-
/**
|
|
1209
|
-
* Context passed to completion providers describing the current input state.
|
|
1210
|
-
*/
|
|
1211
|
-
interface ICliCompletionContext {
|
|
1212
|
-
/** Full current line text */
|
|
1213
|
-
input: string;
|
|
1214
|
-
/** Cursor position in the line */
|
|
1215
|
-
cursor: number;
|
|
1216
|
-
/** The token (word) being completed at the cursor position */
|
|
1217
|
-
token: string;
|
|
1218
|
-
/** Start index of the token in the input string */
|
|
1219
|
-
tokenStart: number;
|
|
1220
|
-
/** Index of the token among all tokens (0 = command, 1+ = arguments) */
|
|
1221
|
-
tokenIndex: number;
|
|
1222
|
-
/** All tokens parsed from the input */
|
|
1223
|
-
tokens: string[];
|
|
1224
|
-
}
|
|
1225
|
-
/**
|
|
1226
|
-
* Provides tab-completion candidates for CLI input.
|
|
1227
|
-
* Plugins can register providers to extend completion (e.g. file paths, custom values).
|
|
1228
|
-
*/
|
|
1229
|
-
interface ICliCompletionProvider {
|
|
1230
|
-
/**
|
|
1231
|
-
* Priority order. Lower values are checked first.
|
|
1232
|
-
* Built-in defaults: 100 (commands), 200 (parameters).
|
|
1233
|
-
* Plugins should use lower values (e.g. 50) to take precedence for specific commands.
|
|
1234
|
-
*/
|
|
1235
|
-
priority: number;
|
|
1236
|
-
/**
|
|
1237
|
-
* Return completion candidates for the current input context.
|
|
1238
|
-
* Return an empty array if this provider does not apply.
|
|
1239
|
-
*/
|
|
1240
|
-
getCompletions(context: ICliCompletionContext): string[] | Promise<string[]>;
|
|
1241
|
-
}
|
|
1242
|
-
|
|
1243
|
-
interface ICliProgressBar {
|
|
1244
|
-
/**
|
|
1245
|
-
* Indicates if the progress bar is running
|
|
1246
|
-
*/
|
|
1247
|
-
isRunning: boolean;
|
|
1248
|
-
/**
|
|
1249
|
-
* Show the progress bar
|
|
1250
|
-
*/
|
|
1251
|
-
show: (text?: string) => void;
|
|
1252
|
-
/**
|
|
1253
|
-
* Hide the progress bar
|
|
1254
|
-
*/
|
|
1255
|
-
hide: () => void;
|
|
1256
|
-
}
|
|
1257
|
-
/**
|
|
1258
|
-
* Represents a spinner for the CLI
|
|
1259
|
-
*/
|
|
1260
|
-
interface ICliSpinner extends ICliProgressBar {
|
|
1261
|
-
/**
|
|
1262
|
-
* Set the text of the spinner
|
|
1263
|
-
* @param text The text to set
|
|
1264
|
-
*/
|
|
1265
|
-
setText: (text: string) => void;
|
|
1266
|
-
}
|
|
1267
|
-
type CliPercentageProgressBarUpdateValueOptions = {
|
|
1268
|
-
/**
|
|
1269
|
-
* The type of update to perform
|
|
1270
|
-
* @default 'replace'
|
|
1271
|
-
*/
|
|
1272
|
-
type?: 'replace' | 'increment';
|
|
1273
|
-
};
|
|
1274
|
-
/**
|
|
1275
|
-
* Represents a progress bar for the CLI
|
|
1276
|
-
*/
|
|
1277
|
-
interface ICliPercentageProgressBar extends ICliProgressBar {
|
|
1278
|
-
/**
|
|
1279
|
-
* Update the progress of the progress bar
|
|
1280
|
-
* @param progress The progress to update to
|
|
1281
|
-
* @returns void
|
|
1282
|
-
*/
|
|
1283
|
-
update: (progress: number, options?: CliPercentageProgressBarUpdateValueOptions) => void;
|
|
1284
|
-
/**
|
|
1285
|
-
* Complete the progress bar
|
|
1286
|
-
* @returns void
|
|
1287
|
-
*/
|
|
1288
|
-
complete: () => void;
|
|
1289
|
-
/**
|
|
1290
|
-
* Set the text of the spinner
|
|
1291
|
-
* @param text The text to set
|
|
1292
|
-
*/
|
|
1293
|
-
setText: (text: string) => void;
|
|
1294
|
-
}
|
|
1295
|
-
type CliTextAnimatorOptions = {
|
|
1296
|
-
/**
|
|
1297
|
-
* The speed of the animation
|
|
1298
|
-
* @default 100
|
|
1299
|
-
*/
|
|
1300
|
-
speed?: number;
|
|
1301
|
-
/**
|
|
1302
|
-
* The text will be removed after typing
|
|
1303
|
-
*/
|
|
1304
|
-
removeAfterTyping?: boolean;
|
|
1305
|
-
};
|
|
1306
|
-
interface ICliTextAnimator extends ICliProgressBar {
|
|
1307
|
-
/**
|
|
1308
|
-
* Show animated text in a typing and erasing effect.
|
|
1309
|
-
* @param text
|
|
1310
|
-
* @param options
|
|
1311
|
-
* @returns
|
|
1312
|
-
*/
|
|
1313
|
-
showText: (text: string, options?: CliTextAnimatorOptions) => Promise<void>;
|
|
1314
|
-
}
|
|
1315
|
-
|
|
1316
|
-
/**
|
|
1317
|
-
* Represents a service that manages user sessions in the CLI
|
|
1318
|
-
*/
|
|
1319
|
-
interface ICliUserSessionService {
|
|
1320
|
-
/** Gets the current user session as a reactive stream */
|
|
1321
|
-
getUserSession(): Observable<ICliUserSession | undefined>;
|
|
1322
|
-
/** Sets the current user session */
|
|
1323
|
-
setUserSession(session: ICliUserSession): Promise<void>;
|
|
1324
|
-
/** Clears the current session (logout) */
|
|
1325
|
-
clearSession(): Promise<void>;
|
|
1326
|
-
/** Persists the current session to storage */
|
|
1327
|
-
persistSession(): Promise<void>;
|
|
1328
|
-
/** Restores a session from storage (called on boot) */
|
|
1329
|
-
restoreSession(): Promise<ICliUserSession | undefined>;
|
|
1330
|
-
}
|
|
1331
|
-
/**
|
|
1332
|
-
* Represents a service that manages users in the CLI
|
|
1333
|
-
*/
|
|
1334
|
-
interface ICliUsersStoreService {
|
|
1335
|
-
/** Gets users with optional filtering and pagination */
|
|
1336
|
-
getUsers(options?: {
|
|
1337
|
-
query?: string;
|
|
1338
|
-
skip?: number;
|
|
1339
|
-
take?: number;
|
|
1340
|
-
}): Observable<ICliUser[]>;
|
|
1341
|
-
/** Creates a new user */
|
|
1342
|
-
createUser(user: CliAddUser): Promise<ICliUser>;
|
|
1343
|
-
/** Gets a user by id, name, or email */
|
|
1344
|
-
getUser(id: string): Observable<ICliUser | undefined>;
|
|
1345
|
-
/** Updates an existing user */
|
|
1346
|
-
updateUser(id: string, updates: CliUpdateUser): Promise<ICliUser>;
|
|
1347
|
-
/** Deletes a user by id */
|
|
1348
|
-
deleteUser(id: string): Promise<void>;
|
|
1349
|
-
}
|
|
1350
|
-
/**
|
|
1351
|
-
* Represents a service that manages groups in the CLI
|
|
1352
|
-
*/
|
|
1353
|
-
interface ICliGroupsStoreService {
|
|
1354
|
-
/** Gets all groups */
|
|
1355
|
-
getGroups(): Observable<ICliGroup[]>;
|
|
1356
|
-
/** Gets a group by id or name */
|
|
1357
|
-
getGroup(id: string): Observable<ICliGroup | undefined>;
|
|
1358
|
-
/** Creates a new group */
|
|
1359
|
-
createGroup(name: string, description?: string): Promise<ICliGroup>;
|
|
1360
|
-
/** Deletes a group by id */
|
|
1361
|
-
deleteGroup(id: string): Promise<void>;
|
|
1362
|
-
/** Gets all users that belong to a group */
|
|
1363
|
-
getGroupMembers(groupId: string): Observable<ICliUser[]>;
|
|
1364
|
-
}
|
|
1365
|
-
/**
|
|
1366
|
-
* Represents a service that handles authentication in the CLI
|
|
1367
|
-
*/
|
|
1368
|
-
interface ICliAuthService {
|
|
1369
|
-
/** Authenticates a user and returns a session */
|
|
1370
|
-
login(username: string, password: string): Promise<ICliUserSession>;
|
|
1371
|
-
/** Ends the current session */
|
|
1372
|
-
logout(): Promise<void>;
|
|
1373
|
-
/** Sets or updates a user's password */
|
|
1374
|
-
setPassword(userId: string, password: string): Promise<void>;
|
|
1375
|
-
/** Verifies a password against stored credentials */
|
|
1376
|
-
verifyPassword(userId: string, password: string): Promise<boolean>;
|
|
1377
|
-
/** Hashes a password with a salt using Web Crypto SHA-256 */
|
|
1378
|
-
hashPassword(password: string, salt: string): Promise<string>;
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
/**
|
|
1382
|
-
* Represents a serialized snapshot of a CLI engine's state.
|
|
1383
|
-
* Used to duplicate terminal tabs with full state preservation.
|
|
1384
|
-
*/
|
|
1385
|
-
interface CliEngineSnapshot {
|
|
1386
|
-
/** Schema version for forward compatibility */
|
|
1387
|
-
version: 1;
|
|
1388
|
-
/** Timestamp (ms since epoch) when the snapshot was taken */
|
|
1389
|
-
timestamp: number;
|
|
1390
|
-
/** Serialized terminal state */
|
|
1391
|
-
terminal: {
|
|
1392
|
-
/** Terminal buffer serialized via @xterm/addon-serialize */
|
|
1393
|
-
serializedBuffer: string;
|
|
1394
|
-
/** Terminal column count at time of snapshot */
|
|
1395
|
-
cols: number;
|
|
1396
|
-
/** Terminal row count at time of snapshot */
|
|
1397
|
-
rows: number;
|
|
1398
|
-
};
|
|
1399
|
-
/** Command history entries (most recent last) */
|
|
1400
|
-
commandHistory: string[];
|
|
1401
|
-
/** Named state store entries */
|
|
1402
|
-
stateStores: Array<{
|
|
1403
|
-
name: string;
|
|
1404
|
-
state: Record<string, any>;
|
|
1405
|
-
}>;
|
|
1406
|
-
}
|
|
1407
|
-
|
|
1408
|
-
/**
|
|
1409
|
-
* Messages sent from the main thread to a background service Worker.
|
|
1410
|
-
*/
|
|
1411
|
-
type CliWorkerInboundMessage = {
|
|
1412
|
-
type: 'start';
|
|
1413
|
-
config?: Record<string, unknown>;
|
|
1414
|
-
} | {
|
|
1415
|
-
type: 'stop';
|
|
1416
|
-
} | {
|
|
1417
|
-
type: 'abort';
|
|
1418
|
-
};
|
|
1419
|
-
/**
|
|
1420
|
-
* Messages sent from a background service Worker to the main thread.
|
|
1421
|
-
*/
|
|
1422
|
-
type CliWorkerOutboundMessage = {
|
|
1423
|
-
type: 'log';
|
|
1424
|
-
level: 'info' | 'warn' | 'error';
|
|
1425
|
-
message: string;
|
|
1426
|
-
} | {
|
|
1427
|
-
type: 'event';
|
|
1428
|
-
event: Omit<ICliServiceEvent, 'timestamp'>;
|
|
1429
|
-
} | {
|
|
1430
|
-
type: 'state-update';
|
|
1431
|
-
patch: Record<string, unknown>;
|
|
1432
|
-
} | {
|
|
1433
|
-
type: 'status';
|
|
1434
|
-
status: CliBackgroundServiceStatus;
|
|
1435
|
-
} | {
|
|
1436
|
-
type: 'error';
|
|
1437
|
-
message: string;
|
|
1438
|
-
stack?: string;
|
|
1439
|
-
};
|
|
1440
|
-
|
|
1441
|
-
/**
|
|
1442
|
-
* Represents an entry in a file listing.
|
|
1443
|
-
*/
|
|
1444
|
-
interface ICliFileEntry {
|
|
1445
|
-
name: string;
|
|
1446
|
-
type: 'file' | 'directory';
|
|
1447
|
-
size: number;
|
|
1448
|
-
modified: string;
|
|
1376
|
+
* An optional message to display if the value is not valid
|
|
1377
|
+
*/
|
|
1378
|
+
message?: string;
|
|
1379
|
+
};
|
|
1449
1380
|
}
|
|
1450
1381
|
/**
|
|
1451
|
-
*
|
|
1382
|
+
* Represents a configuration option that a command processor exposes
|
|
1383
|
+
* for management via the `configure` command.
|
|
1452
1384
|
*/
|
|
1453
|
-
|
|
1385
|
+
interface ICliConfigurationOption {
|
|
1386
|
+
/**
|
|
1387
|
+
* The key used to store and retrieve this option, e.g. 'maxItems'
|
|
1388
|
+
*/
|
|
1389
|
+
key: string;
|
|
1390
|
+
/**
|
|
1391
|
+
* Human-readable label shown in the interactive menu
|
|
1392
|
+
*/
|
|
1393
|
+
label: string;
|
|
1394
|
+
/**
|
|
1395
|
+
* Description of what this option controls
|
|
1396
|
+
*/
|
|
1397
|
+
description: string;
|
|
1398
|
+
/**
|
|
1399
|
+
* The data type of the option
|
|
1400
|
+
*/
|
|
1401
|
+
type: 'string' | 'number' | 'boolean' | 'select';
|
|
1402
|
+
/**
|
|
1403
|
+
* The default value when no configuration has been set
|
|
1404
|
+
*/
|
|
1405
|
+
defaultValue: any;
|
|
1406
|
+
/**
|
|
1407
|
+
* Available choices for 'select' type options
|
|
1408
|
+
*/
|
|
1409
|
+
options?: {
|
|
1410
|
+
label: string;
|
|
1411
|
+
value: any;
|
|
1412
|
+
}[];
|
|
1413
|
+
/**
|
|
1414
|
+
* Optional validator function
|
|
1415
|
+
*/
|
|
1416
|
+
validator?: (value: any) => {
|
|
1417
|
+
valid: boolean;
|
|
1418
|
+
message?: string;
|
|
1419
|
+
};
|
|
1420
|
+
/**
|
|
1421
|
+
* Override the category grouping (defaults to the processor command name)
|
|
1422
|
+
*/
|
|
1423
|
+
category?: string;
|
|
1424
|
+
}
|
|
1454
1425
|
/**
|
|
1455
|
-
*
|
|
1456
|
-
* Default implementation uses browser-native APIs (file picker, download dialog).
|
|
1457
|
-
* @qodalis/cli-files overrides with virtual FS backed by IndexedDB.
|
|
1426
|
+
* Represents a command processor
|
|
1458
1427
|
*/
|
|
1459
|
-
interface
|
|
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 {
|
|
1428
|
+
interface ICliCommandProcessor {
|
|
1478
1429
|
/**
|
|
1479
|
-
*
|
|
1480
|
-
* @param text The text to write
|
|
1430
|
+
* The command that this processor handles
|
|
1481
1431
|
*/
|
|
1482
|
-
|
|
1432
|
+
command: string;
|
|
1483
1433
|
/**
|
|
1484
|
-
*
|
|
1485
|
-
* @param text The text to write
|
|
1434
|
+
* Alternative names for the command
|
|
1486
1435
|
*/
|
|
1487
|
-
|
|
1436
|
+
aliases?: string[];
|
|
1488
1437
|
/**
|
|
1489
|
-
*
|
|
1490
|
-
* @param messag The message to write
|
|
1491
|
-
* @returns void
|
|
1438
|
+
* A description of the command
|
|
1492
1439
|
*/
|
|
1493
|
-
|
|
1440
|
+
description?: string;
|
|
1494
1441
|
/**
|
|
1495
|
-
*
|
|
1496
|
-
* @param messag The message to write
|
|
1497
|
-
* @returns void
|
|
1442
|
+
* The author of the command
|
|
1498
1443
|
*/
|
|
1499
|
-
|
|
1444
|
+
author?: ICliCommandAuthor;
|
|
1500
1445
|
/**
|
|
1501
|
-
*
|
|
1502
|
-
*
|
|
1503
|
-
* @
|
|
1446
|
+
* If true, the processor accepts raw text input after the command name as its value.
|
|
1447
|
+
* The captured text is available via `command.value` in `processCommand`.
|
|
1448
|
+
* @default false
|
|
1449
|
+
* @remarks When true, any text following the command name is extracted as the command value
|
|
1450
|
+
* rather than being interpreted as sub-commands. Use `valueRequired` instead if the value is mandatory.
|
|
1504
1451
|
*/
|
|
1505
|
-
|
|
1452
|
+
acceptsRawInput?: boolean;
|
|
1506
1453
|
/**
|
|
1507
|
-
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1454
|
+
* If true, the command requires some form of input before it can execute.
|
|
1455
|
+
*
|
|
1456
|
+
* The requirement is satisfied by **any** of:
|
|
1457
|
+
* - A positional value (text after the command name, available via `command.value`)
|
|
1458
|
+
* - Piped data from a previous command (available via `command.data`)
|
|
1459
|
+
* - Named arguments (e.g. `--server=node --path=/app`)
|
|
1460
|
+
*
|
|
1461
|
+
* When set, `command.value` is automatically extracted from the raw input
|
|
1462
|
+
* (equivalent to setting `acceptsRawInput`).
|
|
1463
|
+
*
|
|
1464
|
+
* Additionally, when positional input is present the engine skips
|
|
1465
|
+
* required-parameter validation — the processor is responsible for
|
|
1466
|
+
* parsing positional text into individual values. Required-parameter
|
|
1467
|
+
* checks still apply when the user provides only named arguments.
|
|
1468
|
+
*
|
|
1469
|
+
* @default false
|
|
1510
1470
|
*/
|
|
1511
|
-
|
|
1471
|
+
valueRequired?: boolean;
|
|
1512
1472
|
/**
|
|
1513
|
-
*
|
|
1514
|
-
* @
|
|
1515
|
-
* @param color The color to use
|
|
1516
|
-
* @returns void
|
|
1473
|
+
* The version of the command processor
|
|
1474
|
+
* @default '1.0.0'
|
|
1517
1475
|
*/
|
|
1518
|
-
|
|
1476
|
+
version?: string;
|
|
1519
1477
|
/**
|
|
1520
|
-
*
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1478
|
+
* The metadata for the command processor
|
|
1479
|
+
*/
|
|
1480
|
+
metadata?: CliProcessorMetadata;
|
|
1481
|
+
/**
|
|
1482
|
+
* Processors that are nested under this processor
|
|
1524
1483
|
*/
|
|
1525
|
-
|
|
1484
|
+
processors?: ICliCommandChildProcessor[];
|
|
1526
1485
|
/**
|
|
1527
|
-
*
|
|
1528
|
-
* @param json The JSON object to write
|
|
1529
|
-
* @returns void
|
|
1486
|
+
* Parameters that the command accepts
|
|
1530
1487
|
*/
|
|
1531
|
-
|
|
1488
|
+
parameters?: ICliCommandParameterDescriptor[];
|
|
1532
1489
|
/**
|
|
1533
|
-
*
|
|
1534
|
-
* @param fileName The name of the file to write to
|
|
1535
|
-
* @param content The content to write to the file
|
|
1536
|
-
* @returns void
|
|
1490
|
+
* Hooks that are executed before and after the command is processed
|
|
1537
1491
|
*/
|
|
1538
|
-
|
|
1492
|
+
hooks?: ICliProcessorHook[];
|
|
1539
1493
|
/**
|
|
1540
|
-
*
|
|
1541
|
-
* @
|
|
1542
|
-
* @
|
|
1494
|
+
* Represents the state configuration for the command processor
|
|
1495
|
+
* @remarks The state configuration is 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
|
|
1497
|
+
* @remarks The state configuration is used only for root command processors and not for child command processors
|
|
1543
1498
|
*/
|
|
1544
|
-
|
|
1499
|
+
stateConfiguration?: CliStateConfiguration;
|
|
1545
1500
|
/**
|
|
1546
|
-
*
|
|
1547
|
-
*
|
|
1548
|
-
*
|
|
1549
|
-
* @returns void
|
|
1501
|
+
* Configuration options exposed by this processor for the `configure` command.
|
|
1502
|
+
* When defined, these options appear in the interactive configuration menu
|
|
1503
|
+
* and can be managed via `configure get/set` subcommands.
|
|
1550
1504
|
*/
|
|
1551
|
-
|
|
1505
|
+
configurationOptions?: ICliConfigurationOption[];
|
|
1552
1506
|
/**
|
|
1553
|
-
*
|
|
1554
|
-
*
|
|
1555
|
-
*
|
|
1507
|
+
* When true, this processor extends (wraps) an existing processor with the same
|
|
1508
|
+
* command name instead of replacing it. The registry sets `originalProcessor`
|
|
1509
|
+
* to the previous processor so this one can delegate to it.
|
|
1556
1510
|
*/
|
|
1557
|
-
|
|
1558
|
-
color?: CliForegroundColor;
|
|
1559
|
-
length?: number;
|
|
1560
|
-
char?: string;
|
|
1561
|
-
}): void;
|
|
1511
|
+
extendsProcessor?: boolean;
|
|
1562
1512
|
/**
|
|
1563
|
-
*
|
|
1564
|
-
*
|
|
1565
|
-
*
|
|
1513
|
+
* Reference to the original processor that this one extends.
|
|
1514
|
+
* Set automatically by the registry — do not set manually.
|
|
1515
|
+
* Call `this.originalProcessor.processCommand(command, context)` to delegate.
|
|
1566
1516
|
*/
|
|
1567
|
-
|
|
1568
|
-
ordered?: boolean;
|
|
1569
|
-
prefix?: string;
|
|
1570
|
-
color?: CliForegroundColor;
|
|
1571
|
-
}): void;
|
|
1517
|
+
originalProcessor?: ICliCommandProcessor;
|
|
1572
1518
|
/**
|
|
1573
|
-
*
|
|
1574
|
-
* @param
|
|
1575
|
-
* @param
|
|
1519
|
+
* Process the command
|
|
1520
|
+
* @param command The command to process
|
|
1521
|
+
* @param context The context in which the command is executed
|
|
1576
1522
|
*/
|
|
1577
|
-
|
|
1578
|
-
separator?: string;
|
|
1579
|
-
keyColor?: CliForegroundColor;
|
|
1580
|
-
}): void;
|
|
1523
|
+
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
1581
1524
|
/**
|
|
1582
|
-
* Write
|
|
1583
|
-
* @param
|
|
1584
|
-
* @param options Optional: number of columns, padding between columns
|
|
1525
|
+
* Write the description of the command
|
|
1526
|
+
* @param context The context in which the command is executed
|
|
1585
1527
|
*/
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1528
|
+
writeDescription?(context: ICliExecutionContext): void;
|
|
1529
|
+
/**
|
|
1530
|
+
* A function that validates the command before execution
|
|
1531
|
+
* @param value The value to validate
|
|
1532
|
+
* @returns An object with a valid property that indicates if the value is valid and an optional message property that contains a message to display if the value is not valid
|
|
1533
|
+
*/
|
|
1534
|
+
validateBeforeExecution?: (command: CliProcessCommand, context: ICliExecutionContext) => {
|
|
1535
|
+
valid: boolean;
|
|
1536
|
+
message?: string;
|
|
1537
|
+
};
|
|
1538
|
+
/**
|
|
1539
|
+
* Initialize the command processor
|
|
1540
|
+
* @param context The context in which the command is executed
|
|
1541
|
+
*/
|
|
1542
|
+
initialize?(context: ICliExecutionContext): Promise<void>;
|
|
1543
|
+
/**
|
|
1544
|
+
* Handle raw terminal data when this processor is the active context processor.
|
|
1545
|
+
* When implemented, ALL terminal input is routed here instead of normal CLI input handling.
|
|
1546
|
+
* Used for full-screen interactive modes (editors, pagers, etc.).
|
|
1547
|
+
* @param data The raw terminal data string (escape sequences, control chars, printable text)
|
|
1548
|
+
* @param context The execution context
|
|
1549
|
+
*/
|
|
1550
|
+
onData?(data: string, context: ICliExecutionContext): Promise<void>;
|
|
1551
|
+
/**
|
|
1552
|
+
* Called when the terminal is resized while this processor is the active
|
|
1553
|
+
* full-screen context processor. Allows processors to adapt their rendering
|
|
1554
|
+
* to the new terminal dimensions.
|
|
1555
|
+
* @param cols The new number of columns
|
|
1556
|
+
* @param rows The new number of rows
|
|
1557
|
+
* @param context The execution context
|
|
1558
|
+
*/
|
|
1559
|
+
onResize?(cols: number, rows: number, context: ICliExecutionContext): void;
|
|
1560
|
+
/**
|
|
1561
|
+
* Called when the processor is being disposed — either because full-screen
|
|
1562
|
+
* mode ended, the terminal disconnected, or the CLI component is being
|
|
1563
|
+
* destroyed. Use this to clean up resources (timers, subscriptions, etc.).
|
|
1564
|
+
* @param context The execution context
|
|
1565
|
+
*/
|
|
1566
|
+
onDispose?(context: ICliExecutionContext): void;
|
|
1590
1567
|
}
|
|
1591
1568
|
/**
|
|
1592
|
-
* Represents a
|
|
1569
|
+
* Represents a child command processor
|
|
1570
|
+
*/
|
|
1571
|
+
interface ICliCommandChildProcessor extends ICliCommandProcessor {
|
|
1572
|
+
/**
|
|
1573
|
+
* The parent processor, it is populated by the processor manager
|
|
1574
|
+
*/
|
|
1575
|
+
parent?: ICliCommandProcessor;
|
|
1576
|
+
}
|
|
1577
|
+
|
|
1578
|
+
/**
|
|
1579
|
+
* Describes a global parameter (e.g. --help, --version) together with
|
|
1580
|
+
* the handler that executes when the parameter is present.
|
|
1581
|
+
*
|
|
1582
|
+
* Global parameters are checked for every command before the command
|
|
1583
|
+
* processor's own `processCommand` runs. If the handler returns `true`,
|
|
1584
|
+
* command execution is halted (the parameter "consumed" the invocation).
|
|
1593
1585
|
*/
|
|
1594
|
-
interface
|
|
1586
|
+
interface ICliGlobalParameterHandler {
|
|
1595
1587
|
/**
|
|
1596
|
-
*
|
|
1597
|
-
* @param text The text to write to the clipboard
|
|
1598
|
-
* @returns void
|
|
1588
|
+
* The parameter descriptor shown in help output and used for tab-completion.
|
|
1599
1589
|
*/
|
|
1600
|
-
|
|
1590
|
+
parameter: ICliCommandParameterDescriptor;
|
|
1601
1591
|
/**
|
|
1602
|
-
*
|
|
1603
|
-
* @
|
|
1592
|
+
* Execution priority — lower values run first.
|
|
1593
|
+
* @default 0
|
|
1604
1594
|
*/
|
|
1605
|
-
|
|
1595
|
+
priority?: number;
|
|
1596
|
+
/**
|
|
1597
|
+
* Evaluate and optionally handle the parameter.
|
|
1598
|
+
* @returns `true` to halt command execution, `false` to continue.
|
|
1599
|
+
*/
|
|
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
|
-
*
|
|
1614
|
-
* @param
|
|
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,612 @@ interface ICliExecutionProcess {
|
|
|
1713
1755
|
*/
|
|
1714
1756
|
output(data: any): void;
|
|
1715
1757
|
}
|
|
1758
|
+
|
|
1716
1759
|
/**
|
|
1717
|
-
* Represents a
|
|
1760
|
+
* Represents a key-value store for the CLI
|
|
1718
1761
|
*/
|
|
1719
|
-
interface
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
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
|
-
*
|
|
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
|
|
1730
|
-
/**
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
/**
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
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
|
|
1836
|
+
* Represents a service that pings the server
|
|
1748
1837
|
*/
|
|
1749
|
-
interface
|
|
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 {
|
|
1750
1984
|
/**
|
|
1751
|
-
*
|
|
1752
|
-
* @param key
|
|
1753
|
-
* @
|
|
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
|
|
1754
1989
|
*/
|
|
1755
|
-
|
|
1990
|
+
t(key: string, defaultValue: string, params?: Record<string, string | number>): string;
|
|
1756
1991
|
/**
|
|
1757
|
-
*
|
|
1758
|
-
* @param key - The key to set.
|
|
1759
|
-
* @param value - The value to store.
|
|
1760
|
-
* @returns A promise resolving when the value is stored.
|
|
1992
|
+
* Get the current locale code (e.g. 'en', 'es', 'fr').
|
|
1761
1993
|
*/
|
|
1762
|
-
|
|
1994
|
+
getLocale(): string;
|
|
1763
1995
|
/**
|
|
1764
|
-
*
|
|
1765
|
-
* @param
|
|
1766
|
-
* @returns A promise resolving when the key is removed.
|
|
1996
|
+
* Set the active locale.
|
|
1997
|
+
* @param locale The locale code to switch to
|
|
1767
1998
|
*/
|
|
1768
|
-
|
|
1999
|
+
setLocale(locale: string): void;
|
|
1769
2000
|
/**
|
|
1770
|
-
*
|
|
1771
|
-
*
|
|
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
|
|
1772
2005
|
*/
|
|
1773
|
-
|
|
2006
|
+
addTranslations(locale: string, translations: Record<string, string>): void;
|
|
2007
|
+
/**
|
|
2008
|
+
* Get all locale codes that have at least one registered translation.
|
|
2009
|
+
*/
|
|
2010
|
+
getAvailableLocales(): string[];
|
|
1774
2011
|
}
|
|
1775
2012
|
/**
|
|
1776
|
-
*
|
|
2013
|
+
* Dependency injection container for CLI services.
|
|
2014
|
+
* Services are registered with string tokens and retrieved by type.
|
|
1777
2015
|
*/
|
|
1778
|
-
interface
|
|
2016
|
+
interface ICliServiceProvider {
|
|
1779
2017
|
/**
|
|
1780
|
-
*
|
|
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
|
-
|
|
2023
|
+
get<T = unknown>(service: any): T;
|
|
1783
2024
|
/**
|
|
1784
|
-
*
|
|
1785
|
-
* @param
|
|
2025
|
+
* Register one or more service definitions.
|
|
2026
|
+
* @param definition A single provider or an array of providers to register
|
|
1786
2027
|
*/
|
|
1787
|
-
|
|
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
|
-
*
|
|
1790
|
-
* @param
|
|
1791
|
-
* @
|
|
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
|
-
|
|
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
|
-
*
|
|
1796
|
-
*
|
|
1797
|
-
*
|
|
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
|
-
|
|
2079
|
+
priority: number;
|
|
1800
2080
|
/**
|
|
1801
|
-
*
|
|
2081
|
+
* Return completion candidates for the current input context.
|
|
2082
|
+
* Return an empty array if this provider does not apply.
|
|
1802
2083
|
*/
|
|
1803
|
-
|
|
2084
|
+
getCompletions(context: ICliCompletionContext): string[] | Promise<string[]>;
|
|
2085
|
+
}
|
|
2086
|
+
|
|
2087
|
+
interface ICliProgressBar {
|
|
1804
2088
|
/**
|
|
1805
|
-
*
|
|
2089
|
+
* Indicates if the progress bar is running
|
|
1806
2090
|
*/
|
|
1807
|
-
|
|
2091
|
+
isRunning: boolean;
|
|
1808
2092
|
/**
|
|
1809
|
-
*
|
|
2093
|
+
* Show the progress bar
|
|
1810
2094
|
*/
|
|
1811
|
-
|
|
2095
|
+
show: (text?: string) => void;
|
|
2096
|
+
/**
|
|
2097
|
+
* Hide the progress bar
|
|
2098
|
+
*/
|
|
2099
|
+
hide: () => void;
|
|
1812
2100
|
}
|
|
1813
2101
|
/**
|
|
1814
|
-
* Represents a
|
|
2102
|
+
* Represents a spinner for the CLI
|
|
1815
2103
|
*/
|
|
1816
|
-
interface
|
|
2104
|
+
interface ICliSpinner extends ICliProgressBar {
|
|
1817
2105
|
/**
|
|
1818
|
-
*
|
|
2106
|
+
* Set the text of the spinner
|
|
2107
|
+
* @param text The text to set
|
|
1819
2108
|
*/
|
|
1820
|
-
|
|
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
|
|
2119
|
+
* Represents a progress bar for the CLI
|
|
1824
2120
|
*/
|
|
1825
|
-
interface
|
|
2121
|
+
interface ICliPercentageProgressBar extends ICliProgressBar {
|
|
1826
2122
|
/**
|
|
1827
|
-
*
|
|
1828
|
-
*
|
|
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
|
-
|
|
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
|
-
*
|
|
1849
|
-
*
|
|
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
|
-
|
|
2132
|
+
complete: () => void;
|
|
1862
2133
|
/**
|
|
1863
|
-
*
|
|
1864
|
-
*
|
|
2134
|
+
* Set the text of the spinner
|
|
2135
|
+
* @param text The text to set
|
|
1865
2136
|
*/
|
|
1866
|
-
|
|
1867
|
-
|
|
1868
|
-
|
|
2137
|
+
setText: (text: string) => void;
|
|
2138
|
+
}
|
|
2139
|
+
type CliTextAnimatorOptions = {
|
|
1869
2140
|
/**
|
|
1870
|
-
*
|
|
1871
|
-
*
|
|
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
|
-
|
|
1879
|
-
/**
|
|
1880
|
-
|
|
1881
|
-
|
|
1882
|
-
|
|
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
|
-
*
|
|
2226
|
+
* Represents a serialized snapshot of a CLI engine's state.
|
|
2227
|
+
* Used to duplicate terminal tabs with full state preservation.
|
|
1886
2228
|
*/
|
|
1887
|
-
|
|
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
|
-
*
|
|
2253
|
+
* Messages sent from the main thread to a background service Worker.
|
|
1890
2254
|
*/
|
|
1891
|
-
|
|
1892
|
-
|
|
1893
|
-
|
|
1894
|
-
|
|
1895
|
-
|
|
1896
|
-
|
|
1897
|
-
|
|
1898
|
-
|
|
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
|
-
*
|
|
2264
|
+
* Messages sent from a background service Worker to the main thread.
|
|
1928
2265
|
*/
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
|
|
1936
|
-
|
|
1937
|
-
|
|
1938
|
-
|
|
1939
|
-
|
|
1940
|
-
|
|
1941
|
-
|
|
1942
|
-
|
|
1943
|
-
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
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
|
-
*
|
|
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
|
|
1962
|
-
|
|
1963
|
-
|
|
1964
|
-
|
|
1965
|
-
|
|
1966
|
-
|
|
1967
|
-
|
|
1968
|
-
|
|
1969
|
-
|
|
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
|
-
|
|
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
|
-
*
|
|
1978
|
-
*
|
|
1979
|
-
*
|
|
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
|
-
|
|
1982
|
-
|
|
1983
|
-
|
|
1984
|
-
|
|
1985
|
-
|
|
1986
|
-
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
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>;
|
|
1995
2341
|
}
|
|
1996
2342
|
|
|
1997
2343
|
/**
|
|
1998
|
-
* Registry that tracks loaded CLI modules and dispatches
|
|
1999
|
-
* when new modules are registered (including dynamically via UMD).
|
|
2344
|
+
* Registry that tracks loaded web CLI modules (frontend plugins) and dispatches
|
|
2345
|
+
* boot handlers when new modules are registered (including dynamically via UMD).
|
|
2346
|
+
*
|
|
2347
|
+
* This registry is for **browser-side web plugins only**. Backend server
|
|
2348
|
+
* processors (Node/Python/.NET) have their own registries and do not use
|
|
2349
|
+
* this class or the `apiVersion` gating mechanism.
|
|
2000
2350
|
*/
|
|
2001
2351
|
declare class CliModuleRegistry {
|
|
2002
2352
|
private readonly modules;
|
|
2003
2353
|
private readonly bootHandlers;
|
|
2354
|
+
/** Optional warning callback — set by the engine to route through ICliLogger */
|
|
2355
|
+
onWarn?: (message: string) => void;
|
|
2004
2356
|
/**
|
|
2005
2357
|
* Register a handler that is called whenever a new module is registered.
|
|
2006
2358
|
*/
|
|
2007
2359
|
onModuleBoot(handler: (module: ICliModule) => Promise<void>): void;
|
|
2008
2360
|
/**
|
|
2009
|
-
* Register a module and notify all boot handlers.
|
|
2010
|
-
* Modules
|
|
2361
|
+
* Register a web plugin module and notify all boot handlers.
|
|
2362
|
+
* Modules whose `apiVersion` is below the runtime's `API_VERSION` are
|
|
2363
|
+
* skipped with a warning — this ensures only compatible frontend plugins load.
|
|
2011
2364
|
*/
|
|
2012
2365
|
register(module: ICliModule): Promise<void>;
|
|
2013
2366
|
/**
|
|
@@ -2071,6 +2424,17 @@ declare const CLI_CONFIGURE_STORE_NAME = "configure";
|
|
|
2071
2424
|
* @returns The configured value or the default
|
|
2072
2425
|
*/
|
|
2073
2426
|
declare function getConfigValue<T = any>(state: ICliStateStore, category: string, key: string, defaultValue: T): T;
|
|
2427
|
+
/**
|
|
2428
|
+
* Retrieves a plugin configuration value from the execution context.
|
|
2429
|
+
* This is a convenience wrapper for plugins — handles store lookup internally.
|
|
2430
|
+
*
|
|
2431
|
+
* @param context The execution context
|
|
2432
|
+
* @param category The category (usually the processor's command name)
|
|
2433
|
+
* @param key The configuration key
|
|
2434
|
+
* @param defaultValue Fallback value if not configured
|
|
2435
|
+
* @returns The configured value or the default
|
|
2436
|
+
*/
|
|
2437
|
+
declare function getPluginConfigValue<T = any>(context: ICliExecutionContext, category: string, key: string, defaultValue: T): T;
|
|
2074
2438
|
/**
|
|
2075
2439
|
* Resolves all configuration options from registered processors,
|
|
2076
2440
|
* grouped by category.
|
|
@@ -2080,6 +2444,10 @@ declare function resolveConfigurationCategories(registry: ICliCommandProcessorRe
|
|
|
2080
2444
|
options: ICliConfigurationOption[];
|
|
2081
2445
|
}>;
|
|
2082
2446
|
|
|
2447
|
+
/**
|
|
2448
|
+
* Returns a promise that resolves after the given number of milliseconds.
|
|
2449
|
+
* @param ms Delay duration in milliseconds
|
|
2450
|
+
*/
|
|
2083
2451
|
declare const delay: (ms: number) => Promise<void>;
|
|
2084
2452
|
|
|
2085
2453
|
/**
|
|
@@ -2117,10 +2485,10 @@ interface ServerVersionInfo {
|
|
|
2117
2485
|
* Negotiates the API version between a frontend CLI client and a backend server.
|
|
2118
2486
|
*
|
|
2119
2487
|
* Flow:
|
|
2120
|
-
* 1. Client calls `discover(baseUrl)` which hits `GET
|
|
2488
|
+
* 1. Client calls `discover(baseUrl)` which hits `GET ${VERSIONS_ENDPOINT}`
|
|
2121
2489
|
* 2. Server returns supported versions
|
|
2122
2490
|
* 3. Client picks the highest mutually supported version
|
|
2123
|
-
* 4. All subsequent calls use `/api/v{n}/
|
|
2491
|
+
* 4. All subsequent calls use `/api/v{n}/qcli/*`
|
|
2124
2492
|
*/
|
|
2125
2493
|
declare class ServerVersionNegotiator {
|
|
2126
2494
|
private static readonly CLIENT_SUPPORTED_VERSIONS;
|
|
@@ -2173,18 +2541,73 @@ declare function savePanelPosition(position: CliPanelPosition): void;
|
|
|
2173
2541
|
*/
|
|
2174
2542
|
declare function nextPanelPosition(current: CliPanelPosition): CliPanelPosition;
|
|
2175
2543
|
|
|
2176
|
-
|
|
2544
|
+
/**
|
|
2545
|
+
* Strip all ANSI escape sequences from a string.
|
|
2546
|
+
* @param text The text potentially containing ANSI codes
|
|
2547
|
+
* @returns The text with all ANSI codes removed
|
|
2548
|
+
*/
|
|
2549
|
+
declare function stripAnsi(text: string): string;
|
|
2550
|
+
/**
|
|
2551
|
+
* Return the visible length of a string, ignoring ANSI escape codes.
|
|
2552
|
+
* Useful for padding/alignment calculations in terminal output.
|
|
2553
|
+
* @param text The text potentially containing ANSI codes
|
|
2554
|
+
* @returns The number of visible characters
|
|
2555
|
+
*/
|
|
2556
|
+
declare function visibleLength(text: string): number;
|
|
2557
|
+
|
|
2558
|
+
/**
|
|
2559
|
+
* Retrieve a parameter's value from the parsed arguments, checking aliases.
|
|
2560
|
+
* @param p The parameter descriptor
|
|
2561
|
+
* @param args The parsed command arguments
|
|
2562
|
+
* @returns The matched value, or `undefined` if not found
|
|
2563
|
+
*/
|
|
2564
|
+
declare const getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => unknown;
|
|
2565
|
+
/**
|
|
2566
|
+
* Pretty-print a JSON value with ANSI color highlighting.
|
|
2567
|
+
* @param json The value to format
|
|
2568
|
+
* @returns A colorized, indented string suitable for terminal output
|
|
2569
|
+
*/
|
|
2177
2570
|
declare const formatJson: (json: any) => string;
|
|
2178
|
-
|
|
2571
|
+
/**
|
|
2572
|
+
* Apply ANSI color codes to a JSON string using token-based scanning.
|
|
2573
|
+
* Handles keys, strings, numbers, booleans, null, and structural characters.
|
|
2574
|
+
* @param jsonString The raw JSON string to colorize
|
|
2575
|
+
* @returns The colorized string
|
|
2576
|
+
*/
|
|
2577
|
+
declare const colorizeJson: (jsonString: string) => string;
|
|
2578
|
+
/**
|
|
2579
|
+
* Convert a key-value object to a URL query string. Arrays produce repeated keys.
|
|
2580
|
+
* @param params The parameters to encode
|
|
2581
|
+
* @returns The encoded query string (without leading `?`)
|
|
2582
|
+
*/
|
|
2179
2583
|
declare const toQueryString: (params: Record<string, any>) => string;
|
|
2584
|
+
/**
|
|
2585
|
+
* Highlight regex matches in text using an ANSI background color.
|
|
2586
|
+
* @param text The source text
|
|
2587
|
+
* @param pattern The regex pattern to highlight
|
|
2588
|
+
* @param bgColor The background color to apply (default: Yellow)
|
|
2589
|
+
* @returns The text with matching segments wrapped in ANSI background color codes
|
|
2590
|
+
*/
|
|
2180
2591
|
declare const highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
|
|
2592
|
+
/**
|
|
2593
|
+
* Extract the substring to the right of a given word in a command string.
|
|
2594
|
+
* @param command The full command string
|
|
2595
|
+
* @param word The word to search for
|
|
2596
|
+
* @returns The trimmed text after the word, or `undefined` if not found
|
|
2597
|
+
*/
|
|
2181
2598
|
declare const getRightOfWord: (command: string, word: string) => string | undefined;
|
|
2599
|
+
/**
|
|
2600
|
+
* Apply a color function to the first word of a text string, preserving leading whitespace.
|
|
2601
|
+
* @param text The text to process
|
|
2602
|
+
* @param colorFunction A function that wraps a word in ANSI color codes
|
|
2603
|
+
* @returns The text with only the first word colorized
|
|
2604
|
+
*/
|
|
2182
2605
|
declare const colorFirstWord: (text: string, colorFunction: (word: string) => string) => string;
|
|
2183
2606
|
|
|
2184
2607
|
declare const utils: {
|
|
2185
|
-
getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) =>
|
|
2608
|
+
getParameterValue: (p: ICliCommandParameterDescriptor, args: Record<string, any>) => unknown;
|
|
2186
2609
|
formatJson: (json: any) => string;
|
|
2187
|
-
colorizeJson: (jsonString:
|
|
2610
|
+
colorizeJson: (jsonString: string) => string;
|
|
2188
2611
|
toQueryString: (params: Record<string, any>) => string;
|
|
2189
2612
|
highlightTextWithBg: (text: string, pattern: RegExp, bgColor?: CliBackgroundColor) => string;
|
|
2190
2613
|
getRightOfWord: (command: string, word: string) => string | undefined;
|
|
@@ -2192,6 +2615,7 @@ declare const utils: {
|
|
|
2192
2615
|
ObjectDescriber: typeof ObjectDescriber;
|
|
2193
2616
|
delay: (ms: number) => Promise<void>;
|
|
2194
2617
|
getConfigValue: typeof getConfigValue;
|
|
2618
|
+
getPluginConfigValue: typeof getPluginConfigValue;
|
|
2195
2619
|
resolveConfigurationCategories: typeof resolveConfigurationCategories;
|
|
2196
2620
|
CLI_CONFIGURE_STORE_NAME: string;
|
|
2197
2621
|
};
|
|
@@ -2201,23 +2625,41 @@ declare const constants: {
|
|
|
2201
2625
|
DefaultLibraryAuthor: ICliCommandAuthor;
|
|
2202
2626
|
};
|
|
2203
2627
|
|
|
2628
|
+
/** Error message used when a `CancellablePromise` is cancelled. */
|
|
2629
|
+
declare const CANCELLATION_ERROR_MESSAGE = "Promise cancelled";
|
|
2630
|
+
/**
|
|
2631
|
+
* A promise wrapper that supports cooperative cancellation.
|
|
2632
|
+
*
|
|
2633
|
+
* Create with an executor (like `new Promise`), then call `execute()` to run.
|
|
2634
|
+
* Call `cancel()` to reject with a cancellation error and prevent further
|
|
2635
|
+
* resolve/reject callbacks from firing.
|
|
2636
|
+
*
|
|
2637
|
+
* @example
|
|
2638
|
+
* ```ts
|
|
2639
|
+
* const cp = new CancellablePromise<string>((resolve) => {
|
|
2640
|
+
* setTimeout(() => resolve('done'), 5000);
|
|
2641
|
+
* });
|
|
2642
|
+
* cp.execute().catch(e => console.log(e.message)); // 'Promise cancelled'
|
|
2643
|
+
* cp.cancel();
|
|
2644
|
+
* ```
|
|
2645
|
+
*/
|
|
2204
2646
|
declare class CancellablePromise<T> {
|
|
2205
2647
|
private executor;
|
|
2206
2648
|
private hasCancelled;
|
|
2207
2649
|
private abortController;
|
|
2208
2650
|
constructor(executor: (resolve: (value: T) => void, reject: (reason?: any) => void) => void);
|
|
2651
|
+
/**
|
|
2652
|
+
* Run the executor and return a promise for its result.
|
|
2653
|
+
* If `cancel()` has been called, the promise rejects immediately.
|
|
2654
|
+
*/
|
|
2209
2655
|
execute(): Promise<T>;
|
|
2656
|
+
/**
|
|
2657
|
+
* Cancel the promise. The executing promise rejects with
|
|
2658
|
+
* `Error('Promise cancelled')` and subsequent resolve/reject calls are ignored.
|
|
2659
|
+
*/
|
|
2210
2660
|
cancel(): void;
|
|
2211
2661
|
}
|
|
2212
2662
|
|
|
2213
|
-
type CliThemeCategory = 'dark' | 'light';
|
|
2214
|
-
interface CliThemeInfo {
|
|
2215
|
-
theme: ITheme;
|
|
2216
|
-
category: CliThemeCategory;
|
|
2217
|
-
tags: string[];
|
|
2218
|
-
description: string;
|
|
2219
|
-
}
|
|
2220
|
-
|
|
2221
2663
|
type CliTheme = ITheme;
|
|
2222
2664
|
type DefaultThemesType = {
|
|
2223
2665
|
default: CliTheme;
|
|
@@ -2252,34 +2694,22 @@ type DefaultThemesType = {
|
|
|
2252
2694
|
yellow: CliTheme;
|
|
2253
2695
|
[key: string]: CliTheme;
|
|
2254
2696
|
};
|
|
2697
|
+
|
|
2255
2698
|
declare const DefaultThemes: DefaultThemesType;
|
|
2256
2699
|
|
|
2700
|
+
type CliThemeCategory = 'dark' | 'light';
|
|
2701
|
+
interface CliThemeInfo {
|
|
2702
|
+
theme: ITheme;
|
|
2703
|
+
category: CliThemeCategory;
|
|
2704
|
+
tags: string[];
|
|
2705
|
+
description: string;
|
|
2706
|
+
}
|
|
2707
|
+
|
|
2257
2708
|
declare const DefaultThemeInfos: Record<string, CliThemeInfo>;
|
|
2258
2709
|
|
|
2259
|
-
declare const LIBRARY_VERSION = "2.0.0-beta.
|
|
2710
|
+
declare const LIBRARY_VERSION = "2.0.0-beta.10";
|
|
2260
2711
|
declare const API_VERSION = 2;
|
|
2261
2712
|
|
|
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
2713
|
/**
|
|
2284
2714
|
* Context provided to worker service handlers inside a Web Worker.
|
|
2285
2715
|
*/
|
|
@@ -2287,7 +2717,7 @@ interface WorkerServiceContext {
|
|
|
2287
2717
|
/** Emit an event to the main thread */
|
|
2288
2718
|
emit(event: Omit<ICliServiceEvent, 'timestamp'>): void;
|
|
2289
2719
|
/** Log a message (forwarded to the main-thread log buffer) */
|
|
2290
|
-
log(message: string, level?:
|
|
2720
|
+
log(message: string, level?: CliServiceLogLevel): void;
|
|
2291
2721
|
/** Update state on the main thread */
|
|
2292
2722
|
updateState(patch: Record<string, unknown>): void;
|
|
2293
2723
|
/** Create an interval that is auto-cleared on stop */
|
|
@@ -2306,10 +2736,29 @@ declare function createWorkerService(handlers: {
|
|
|
2306
2736
|
onStop?(): Promise<void>;
|
|
2307
2737
|
}): void;
|
|
2308
2738
|
|
|
2739
|
+
/**
|
|
2740
|
+
* Browser-based file transfer service using native browser APIs.
|
|
2741
|
+
*
|
|
2742
|
+
* This is the default implementation when no virtual filesystem is available.
|
|
2743
|
+
* `readFile` and `uploadFromBrowser` open a file picker dialog.
|
|
2744
|
+
* `writeFile` and `downloadToBrowser` trigger a browser download.
|
|
2745
|
+
*
|
|
2746
|
+
* **Limitations:** `listFiles()` and `exists()` are not supported in the
|
|
2747
|
+
* browser environment and always return empty/false respectively.
|
|
2748
|
+
* Use `@qodalis/cli-files` for full filesystem capabilities.
|
|
2749
|
+
*/
|
|
2309
2750
|
declare class BrowserFileTransferService implements ICliFileTransferService {
|
|
2310
2751
|
readFile(_path: string): Promise<string | null>;
|
|
2311
2752
|
writeFile(path: string, content: string): Promise<void>;
|
|
2753
|
+
/**
|
|
2754
|
+
* Not supported in browser — always returns an empty array.
|
|
2755
|
+
* Use `@qodalis/cli-files` for directory listing.
|
|
2756
|
+
*/
|
|
2312
2757
|
listFiles(_path: string): Promise<ICliFileEntry[]>;
|
|
2758
|
+
/**
|
|
2759
|
+
* Not supported in browser — always returns `false`.
|
|
2760
|
+
* Use `@qodalis/cli-files` for file existence checks.
|
|
2761
|
+
*/
|
|
2313
2762
|
exists(_path: string): Promise<boolean>;
|
|
2314
2763
|
downloadToBrowser(filename: string, content: string | Blob): void;
|
|
2315
2764
|
uploadFromBrowser(accept?: string): Promise<{
|
|
@@ -2319,4 +2768,4 @@ declare class BrowserFileTransferService implements ICliFileTransferService {
|
|
|
2319
2768
|
private _pickFile;
|
|
2320
2769
|
}
|
|
2321
2770
|
|
|
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 };
|
|
2771
|
+
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 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 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 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 };
|