@qodalis/cli 2.0.0-beta.2 → 2.0.0-beta.20
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 +230 -12
- package/assets/cli-panel.css +406 -0
- package/assets/styles.css +8 -0
- package/package.json +4 -3
- package/public-api.d.mts +2124 -408
- package/public-api.d.ts +2124 -408
- package/public-api.js +20424 -11750
- package/public-api.js.map +1 -1
- package/public-api.mjs +20237 -11663
- package/public-api.mjs.map +1 -1
- package/wasm/qodalis_cli_wasm_bg.wasm +0 -0
package/public-api.d.mts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ICliCommandProcessor, ICliCommandParameterDescriptor, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliManagedInterval, ICliManagedTimer, ICliKeyValueStore, CliSelectOption, CliMultiSelectOption, ICliCompletionProvider, ICliGlobalParameterHandler, CliProvider, CliForegroundColor, CliBackgroundColor, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, ICliProcessRegistry, ICliProcessEntry, ICliDragDropService, CliState, CliEngineSnapshot, CliServerConfig, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliIcon } from '@qodalis/cli-core';
|
|
1
|
+
import { ICliCommandProcessor, ICliCommandParameterDescriptor as ICliCommandParameterDescriptor$1, ICliCommandProcessorRegistry, ICliCommandChildProcessor, CliProcessorMetadata, CliStateConfiguration, ICliExecutionContext, CliProcessCommand, ICliCommandAuthor, CliThemeInfo, ICliExecutionProcess, ICliUserSession, ICliSpinner, ICliPercentageProgressBar, ICliTextAnimator, ICliTerminalWriter, ICliCommandExecutorService, ICliClipboard, ICliStateStore, CliOptions, ICliLogger, ICliServiceProvider, ICliTranslationService, ICliInputReader, ICliBackgroundServiceRegistry, ICliHttpClient, ICliNotifier, ICliManagedInterval, ICliManagedTimer, ICliEventBus, ICliKeyValueStore, CliStateStoreOptions, ICliCompletionProvider, ICliFilePickerProvider, CliFullScreenOptions, ICliProcessRegistry, ICliBackgroundService, ICliServiceContext, ICliBackgroundServiceInfo, ICliServiceLogEntry, CliServiceEventHandler, ICliGlobalParameterHandler, CliForegroundColor, CliBackgroundColor, CliToken, CliProvider, CliTableOptions, CliLogLevel, CliPercentageProgressBarUpdateValueOptions, CliTextAnimatorOptions, ICliModule, CliModuleRegistry, Package, ICliPingServerService, CliLineOptions, CliSelectOption, CliSelectOptions, CliMultiSelectOption, CliMultiSelectOptions, CliNumberOptions, CliDateOptions, CliFilePickerOptions, CliFileResult, ICliProcessRegisterOptions, ICliProcessEntry, ICliDragDropService, CliHttpRequestOptions, CliNotification, ICliPermissionRegistry, CliPermissionDefinition, CliState, CliEngineSnapshot, CliEvent, CliEventType, CliEventMap, CliEmitOptions, CustomEventType, CliEventHandler, CliServerConfig, ICliServerAuthService, CliServerCommandDescriptor, CliServerCapabilities, CliServerResponse, CliServerOutput, CliPanelPosition, CliPanelConfig, CliPanelHideAlignment, ICliPanelRef, CliPanelState } from '@qodalis/cli-core';
|
|
3
2
|
export { ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN } from '@qodalis/cli-core';
|
|
4
3
|
import { ITheme, Terminal, ITerminalAddon, ITerminalOptions, ITerminalInitOnlyOptions } from '@xterm/xterm';
|
|
4
|
+
import * as rxjs from 'rxjs';
|
|
5
5
|
import { Subject, Observable, Subscription } from 'rxjs';
|
|
6
|
+
import { FitAddon } from '@xterm/addon-fit';
|
|
7
|
+
import { SerializeAddon } from '@xterm/addon-serialize';
|
|
6
8
|
|
|
7
9
|
type ParsedArg = {
|
|
8
10
|
name: string;
|
|
@@ -13,6 +15,8 @@ type ParsedToken = {
|
|
|
13
15
|
name: string;
|
|
14
16
|
value: string | number | boolean;
|
|
15
17
|
hasEquals: boolean;
|
|
18
|
+
/** Written with one dash (`-rf`), so it may be several short flags */
|
|
19
|
+
short?: boolean;
|
|
16
20
|
} | {
|
|
17
21
|
kind: 'word';
|
|
18
22
|
value: string;
|
|
@@ -70,7 +74,7 @@ declare class CliArgsParser {
|
|
|
70
74
|
* @param descriptors - Parameter descriptors from the matched processor.
|
|
71
75
|
* @returns Reconciled args array and remaining command parts.
|
|
72
76
|
*/
|
|
73
|
-
declare function reconcileArgs(tokens: ParsedToken[], descriptors: ICliCommandParameterDescriptor[] | undefined): {
|
|
77
|
+
declare function reconcileArgs(tokens: ParsedToken[], descriptors: ICliCommandParameterDescriptor$1[] | undefined): {
|
|
74
78
|
args: ParsedArg[];
|
|
75
79
|
commandParts: string[];
|
|
76
80
|
};
|
|
@@ -88,6 +92,11 @@ declare class ProcessExitedError extends Error {
|
|
|
88
92
|
|
|
89
93
|
declare class CliCommandProcessorRegistry implements ICliCommandProcessorRegistry {
|
|
90
94
|
readonly processors: ICliCommandProcessor[];
|
|
95
|
+
/**
|
|
96
|
+
* Sub-commands each extension (`extendsProcessor`) merged into an
|
|
97
|
+
* existing command, removed again when the extension is unregistered.
|
|
98
|
+
*/
|
|
99
|
+
private readonly mergedByExtension;
|
|
91
100
|
constructor(initialProcessors?: ICliCommandProcessor[]);
|
|
92
101
|
registerProcessor(processor: ICliCommandProcessor): void;
|
|
93
102
|
unregisterProcessor(processor: ICliCommandProcessor): void;
|
|
@@ -108,73 +117,82 @@ declare class CliCommandProcessorRegistry implements ICliCommandProcessorRegistr
|
|
|
108
117
|
* Framework-agnostic token for the CLI command processor registry.
|
|
109
118
|
* Used as a key in the service provider to retrieve the registry.
|
|
110
119
|
*/
|
|
111
|
-
declare const CliProcessorsRegistry_TOKEN
|
|
120
|
+
declare const CliProcessorsRegistry_TOKEN: any;
|
|
112
121
|
/**
|
|
113
122
|
* Framework-agnostic token for the CLI state store manager.
|
|
114
123
|
* Used as a key in the service provider to retrieve the state store manager.
|
|
115
124
|
*/
|
|
116
|
-
declare const CliStateStoreManager_TOKEN
|
|
125
|
+
declare const CliStateStoreManager_TOKEN: any;
|
|
117
126
|
/**
|
|
118
127
|
* Framework-agnostic token for the CLI command history service.
|
|
119
128
|
* Used as a key in the service provider to retrieve the command history.
|
|
120
129
|
*/
|
|
121
|
-
declare const CliCommandHistory_TOKEN
|
|
130
|
+
declare const CliCommandHistory_TOKEN: any;
|
|
122
131
|
/**
|
|
123
132
|
* Framework-agnostic token for the CLI ping server service.
|
|
124
133
|
* Used as a key in the service provider to retrieve the ping server service.
|
|
125
134
|
*/
|
|
126
|
-
declare const ICliPingServerService_TOKEN
|
|
135
|
+
declare const ICliPingServerService_TOKEN: any;
|
|
127
136
|
/**
|
|
128
137
|
* Framework-agnostic token for the CLI module registry.
|
|
129
138
|
* Used as a key in the service provider to retrieve the module registry.
|
|
130
139
|
*/
|
|
131
|
-
declare const CliModuleRegistry_TOKEN
|
|
140
|
+
declare const CliModuleRegistry_TOKEN: any;
|
|
141
|
+
/**
|
|
142
|
+
* The live boot report (`CliBootLog`) while the CLI starts. Processors and
|
|
143
|
+
* modules can add steps and lines from `initialize`/`onInit`; it ignores
|
|
144
|
+
* entries once boot has finished.
|
|
145
|
+
*/
|
|
146
|
+
declare const CliBootLog_TOKEN: any;
|
|
132
147
|
/**
|
|
133
148
|
* Framework-agnostic token for the CLI background service registry.
|
|
134
149
|
* Used as a key in the service provider to retrieve the background service registry.
|
|
135
150
|
*/
|
|
136
|
-
declare const CliBackgroundServiceRegistry_TOKEN
|
|
151
|
+
declare const CliBackgroundServiceRegistry_TOKEN: any;
|
|
137
152
|
/**
|
|
138
153
|
* Framework-agnostic token for the CLI package manager service.
|
|
139
154
|
* Used as a key in the service provider to retrieve the package manager.
|
|
140
155
|
*/
|
|
141
|
-
declare const CliPackageManagerService_TOKEN
|
|
156
|
+
declare const CliPackageManagerService_TOKEN: any;
|
|
157
|
+
/**
|
|
158
|
+
* Framework-agnostic token for the CLI key-value store.
|
|
159
|
+
* Used as a key in the service provider to retrieve the persistent storage.
|
|
160
|
+
*/
|
|
161
|
+
declare const CliKeyValueStore_TOKEN: any;
|
|
162
|
+
/**
|
|
163
|
+
* Framework-agnostic token for the syntax highlighter registry.
|
|
164
|
+
* Used as a key in the service provider to retrieve the syntax highlighter registry.
|
|
165
|
+
*/
|
|
166
|
+
declare const SyntaxHighlighterRegistry_TOKEN: any;
|
|
142
167
|
|
|
143
|
-
declare const LIBRARY_VERSION = "2.0.0-beta.
|
|
168
|
+
declare const LIBRARY_VERSION = "2.0.0-beta.20";
|
|
144
169
|
declare const API_VERSION = 2;
|
|
145
170
|
|
|
146
171
|
declare class CliAliasCommandProcessor implements ICliCommandProcessor {
|
|
147
172
|
command: string;
|
|
148
|
-
author:
|
|
173
|
+
author: any;
|
|
149
174
|
description: string;
|
|
150
|
-
|
|
175
|
+
acceptsRawInput: boolean;
|
|
151
176
|
metadata?: CliProcessorMetadata | undefined;
|
|
152
177
|
stateConfiguration?: CliStateConfiguration | undefined;
|
|
178
|
+
/** Shared aliases (used when no auth module is loaded) */
|
|
153
179
|
userAliases: Record<string, string>;
|
|
180
|
+
private aliasState;
|
|
181
|
+
/** Aliases visible to the current principal */
|
|
182
|
+
aliasesFor(context: Pick<ICliExecutionContext, 'services'>): Record<string, string>;
|
|
154
183
|
private stateSubscription?;
|
|
155
|
-
|
|
184
|
+
/** `alias ls`: list the aliases visible to the current principal */
|
|
185
|
+
private listAliases;
|
|
156
186
|
writeDescription(context: ICliExecutionContext): void;
|
|
157
187
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
158
188
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
159
189
|
}
|
|
160
190
|
|
|
161
|
-
declare class CliBase64CommandProcessor implements ICliCommandProcessor {
|
|
162
|
-
command: string;
|
|
163
|
-
aliases: string[];
|
|
164
|
-
description: string;
|
|
165
|
-
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
166
|
-
processors?: ICliCommandProcessor[];
|
|
167
|
-
metadata?: CliProcessorMetadata;
|
|
168
|
-
constructor();
|
|
169
|
-
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
170
|
-
writeDescription(context: ICliExecutionContext): void;
|
|
171
|
-
}
|
|
172
|
-
|
|
173
191
|
declare class CliCalCommandProcessor implements ICliCommandProcessor {
|
|
174
192
|
command: string;
|
|
175
193
|
aliases: string[];
|
|
176
194
|
description: string;
|
|
177
|
-
author:
|
|
195
|
+
author: any;
|
|
178
196
|
metadata?: CliProcessorMetadata;
|
|
179
197
|
parameters: {
|
|
180
198
|
name: string;
|
|
@@ -191,7 +209,7 @@ declare class CliClearCommandProcessor implements ICliCommandProcessor {
|
|
|
191
209
|
command: string;
|
|
192
210
|
aliases: string[];
|
|
193
211
|
description?: string | undefined;
|
|
194
|
-
author:
|
|
212
|
+
author: any;
|
|
195
213
|
metadata?: CliProcessorMetadata | undefined;
|
|
196
214
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
197
215
|
writeDescription(context: ICliExecutionContext): void;
|
|
@@ -201,7 +219,7 @@ declare class CliClipboardCommandProcessor implements ICliCommandProcessor {
|
|
|
201
219
|
command: string;
|
|
202
220
|
aliases: string[];
|
|
203
221
|
description: string;
|
|
204
|
-
author:
|
|
222
|
+
author: any;
|
|
205
223
|
processors?: ICliCommandProcessor[];
|
|
206
224
|
metadata?: CliProcessorMetadata;
|
|
207
225
|
constructor();
|
|
@@ -213,7 +231,7 @@ declare class CliColorCommandProcessor implements ICliCommandProcessor {
|
|
|
213
231
|
command: string;
|
|
214
232
|
aliases: string[];
|
|
215
233
|
description: string;
|
|
216
|
-
author:
|
|
234
|
+
author: any;
|
|
217
235
|
acceptsRawInput: boolean;
|
|
218
236
|
valueRequired: boolean;
|
|
219
237
|
metadata?: CliProcessorMetadata;
|
|
@@ -231,7 +249,7 @@ declare class CliConvertCommandProcessor implements ICliCommandProcessor {
|
|
|
231
249
|
command: string;
|
|
232
250
|
aliases: string[];
|
|
233
251
|
description: string;
|
|
234
|
-
author:
|
|
252
|
+
author: any;
|
|
235
253
|
acceptsRawInput: boolean;
|
|
236
254
|
valueRequired: boolean;
|
|
237
255
|
metadata?: CliProcessorMetadata;
|
|
@@ -247,11 +265,9 @@ declare class CliEchoCommandProcessor implements ICliCommandProcessor {
|
|
|
247
265
|
aliases: string[];
|
|
248
266
|
description: string;
|
|
249
267
|
acceptsRawInput: boolean;
|
|
250
|
-
author:
|
|
268
|
+
author: any;
|
|
251
269
|
metadata?: CliProcessorMetadata | undefined;
|
|
252
270
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
253
|
-
/** Remove surrounding quotes from the text. */
|
|
254
|
-
private stripQuotes;
|
|
255
271
|
/** Interpret common escape sequences like a POSIX echo -e. */
|
|
256
272
|
private interpretEscapes;
|
|
257
273
|
writeDescription(context: ICliExecutionContext): void;
|
|
@@ -261,63 +277,29 @@ declare class CliEvalCommandProcessor implements ICliCommandProcessor {
|
|
|
261
277
|
command: string;
|
|
262
278
|
aliases: string[];
|
|
263
279
|
description: string;
|
|
264
|
-
author:
|
|
280
|
+
author: any;
|
|
265
281
|
acceptsRawInput: boolean;
|
|
266
282
|
metadata?: CliProcessorMetadata | undefined;
|
|
267
283
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
268
284
|
writeDescription(context: ICliExecutionContext): void;
|
|
269
285
|
}
|
|
270
286
|
|
|
271
|
-
declare class CliHashCommandProcessor implements ICliCommandProcessor {
|
|
272
|
-
command: string;
|
|
273
|
-
description: string;
|
|
274
|
-
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
275
|
-
processors?: ICliCommandProcessor[];
|
|
276
|
-
metadata?: CliProcessorMetadata;
|
|
277
|
-
constructor();
|
|
278
|
-
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
279
|
-
writeDescription(context: ICliExecutionContext): void;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
declare class CliHexCommandProcessor implements ICliCommandProcessor {
|
|
283
|
-
command: string;
|
|
284
|
-
description: string;
|
|
285
|
-
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
286
|
-
processors?: ICliCommandProcessor[];
|
|
287
|
-
metadata?: CliProcessorMetadata;
|
|
288
|
-
constructor();
|
|
289
|
-
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
290
|
-
writeDescription(context: ICliExecutionContext): void;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
287
|
declare class CliJsonCommandProcessor implements ICliCommandProcessor {
|
|
294
288
|
command: string;
|
|
295
289
|
description: string;
|
|
296
|
-
author:
|
|
297
|
-
processors?: ICliCommandProcessor[];
|
|
298
|
-
metadata?: CliProcessorMetadata;
|
|
299
|
-
constructor();
|
|
300
|
-
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
301
|
-
writeDescription(context: ICliExecutionContext): void;
|
|
302
|
-
}
|
|
303
|
-
|
|
304
|
-
declare class CliJwtCommandProcessor implements ICliCommandProcessor {
|
|
305
|
-
command: string;
|
|
306
|
-
description: string;
|
|
307
|
-
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
290
|
+
author: any;
|
|
308
291
|
processors?: ICliCommandProcessor[];
|
|
309
292
|
metadata?: CliProcessorMetadata;
|
|
310
293
|
constructor();
|
|
311
294
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
312
295
|
writeDescription(context: ICliExecutionContext): void;
|
|
313
|
-
private base64UrlDecode;
|
|
314
296
|
}
|
|
315
297
|
|
|
316
298
|
declare class CliLoremCommandProcessor implements ICliCommandProcessor {
|
|
317
299
|
command: string;
|
|
318
300
|
aliases: string[];
|
|
319
301
|
description: string;
|
|
320
|
-
author:
|
|
302
|
+
author: any;
|
|
321
303
|
processors?: ICliCommandProcessor[];
|
|
322
304
|
metadata?: CliProcessorMetadata;
|
|
323
305
|
constructor();
|
|
@@ -329,7 +311,7 @@ declare class CliLoremCommandProcessor implements ICliCommandProcessor {
|
|
|
329
311
|
declare class CliOpenCommandProcessor implements ICliCommandProcessor {
|
|
330
312
|
command: string;
|
|
331
313
|
description: string;
|
|
332
|
-
author:
|
|
314
|
+
author: any;
|
|
333
315
|
acceptsRawInput: boolean;
|
|
334
316
|
valueRequired: boolean;
|
|
335
317
|
metadata?: CliProcessorMetadata;
|
|
@@ -341,7 +323,7 @@ declare class CliRandomCommandProcessor implements ICliCommandProcessor {
|
|
|
341
323
|
command: string;
|
|
342
324
|
aliases: string[];
|
|
343
325
|
description: string;
|
|
344
|
-
author:
|
|
326
|
+
author: any;
|
|
345
327
|
processors?: ICliCommandProcessor[];
|
|
346
328
|
metadata?: CliProcessorMetadata;
|
|
347
329
|
constructor();
|
|
@@ -353,7 +335,7 @@ declare class CliScreenCommandProcessor implements ICliCommandProcessor {
|
|
|
353
335
|
command: string;
|
|
354
336
|
aliases: string[];
|
|
355
337
|
description: string;
|
|
356
|
-
author:
|
|
338
|
+
author: any;
|
|
357
339
|
metadata?: CliProcessorMetadata;
|
|
358
340
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
359
341
|
writeDescription(context: ICliExecutionContext): void;
|
|
@@ -363,7 +345,7 @@ declare class CliSeqCommandProcessor implements ICliCommandProcessor {
|
|
|
363
345
|
command: string;
|
|
364
346
|
aliases: string[];
|
|
365
347
|
description: string;
|
|
366
|
-
author:
|
|
348
|
+
author: any;
|
|
367
349
|
acceptsRawInput: boolean;
|
|
368
350
|
valueRequired: boolean;
|
|
369
351
|
metadata?: CliProcessorMetadata;
|
|
@@ -388,7 +370,7 @@ declare class CliSleepCommandProcessor implements ICliCommandProcessor {
|
|
|
388
370
|
command: string;
|
|
389
371
|
aliases: string[];
|
|
390
372
|
description?: string | undefined;
|
|
391
|
-
author:
|
|
373
|
+
author: any;
|
|
392
374
|
metadata?: CliProcessorMetadata | undefined;
|
|
393
375
|
valueRequired?: boolean | undefined;
|
|
394
376
|
constructor();
|
|
@@ -400,7 +382,7 @@ declare class CliTimeCommandProcessor implements ICliCommandProcessor {
|
|
|
400
382
|
command: string;
|
|
401
383
|
aliases: string[];
|
|
402
384
|
description: string;
|
|
403
|
-
author:
|
|
385
|
+
author: any;
|
|
404
386
|
version: string;
|
|
405
387
|
processors?: ICliCommandProcessor[] | undefined;
|
|
406
388
|
metadata?: CliProcessorMetadata | undefined;
|
|
@@ -413,7 +395,7 @@ declare class CliTimestampCommandProcessor implements ICliCommandProcessor {
|
|
|
413
395
|
command: string;
|
|
414
396
|
aliases: string[];
|
|
415
397
|
description: string;
|
|
416
|
-
author:
|
|
398
|
+
author: any;
|
|
417
399
|
processors?: ICliCommandProcessor[];
|
|
418
400
|
metadata?: CliProcessorMetadata;
|
|
419
401
|
constructor();
|
|
@@ -423,7 +405,7 @@ declare class CliTimestampCommandProcessor implements ICliCommandProcessor {
|
|
|
423
405
|
|
|
424
406
|
declare class CliUnAliasCommandProcessor implements ICliCommandProcessor {
|
|
425
407
|
command: string;
|
|
426
|
-
author:
|
|
408
|
+
author: any;
|
|
427
409
|
description: string;
|
|
428
410
|
valueRequired?: boolean | undefined;
|
|
429
411
|
stateConfiguration?: CliStateConfiguration | undefined;
|
|
@@ -436,7 +418,7 @@ declare class CliUnameCommandProcessor implements ICliCommandProcessor {
|
|
|
436
418
|
command: string;
|
|
437
419
|
aliases: string[];
|
|
438
420
|
description?: string | undefined;
|
|
439
|
-
author:
|
|
421
|
+
author: any;
|
|
440
422
|
metadata?: CliProcessorMetadata | undefined;
|
|
441
423
|
writeDescription(context: ICliExecutionContext): void;
|
|
442
424
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -450,29 +432,17 @@ declare class CliUnameCommandProcessor implements ICliCommandProcessor {
|
|
|
450
432
|
declare class CliUptimeCommandProcessor implements ICliCommandProcessor {
|
|
451
433
|
command: string;
|
|
452
434
|
description: string;
|
|
453
|
-
author:
|
|
435
|
+
author: any;
|
|
454
436
|
metadata?: CliProcessorMetadata;
|
|
455
|
-
private sessionStartTimes;
|
|
456
437
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
457
438
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
458
439
|
writeDescription(context: ICliExecutionContext): void;
|
|
459
440
|
}
|
|
460
441
|
|
|
461
|
-
declare class CliUrlCommandProcessor implements ICliCommandProcessor {
|
|
462
|
-
command: string;
|
|
463
|
-
description: string;
|
|
464
|
-
author: _qodalis_cli_core.ICliCommandAuthor;
|
|
465
|
-
processors?: ICliCommandProcessor[];
|
|
466
|
-
metadata?: CliProcessorMetadata;
|
|
467
|
-
constructor();
|
|
468
|
-
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
469
|
-
writeDescription(context: ICliExecutionContext): void;
|
|
470
|
-
}
|
|
471
|
-
|
|
472
442
|
declare class CliYesCommandProcessor implements ICliCommandProcessor {
|
|
473
443
|
command: string;
|
|
474
444
|
description: string;
|
|
475
|
-
author:
|
|
445
|
+
author: any;
|
|
476
446
|
acceptsRawInput: boolean;
|
|
477
447
|
metadata?: CliProcessorMetadata;
|
|
478
448
|
parameters: {
|
|
@@ -486,14 +456,49 @@ declare class CliYesCommandProcessor implements ICliCommandProcessor {
|
|
|
486
456
|
writeDescription(context: ICliExecutionContext): void;
|
|
487
457
|
}
|
|
488
458
|
|
|
459
|
+
/**
|
|
460
|
+
* `test EXPR` / `[ EXPR ]`: evaluate a condition; exit status 0 when true,
|
|
461
|
+
* 1 when false and 2 on an error. Used by `if`, `while` and `&&`/`||`.
|
|
462
|
+
*/
|
|
463
|
+
declare class CliTestCommandProcessor implements ICliCommandProcessor {
|
|
464
|
+
command: string;
|
|
465
|
+
aliases: string[];
|
|
466
|
+
description: string;
|
|
467
|
+
author: any;
|
|
468
|
+
acceptsRawInput: boolean;
|
|
469
|
+
metadata?: CliProcessorMetadata;
|
|
470
|
+
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
471
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
472
|
+
}
|
|
473
|
+
/** `true`: do nothing, successfully (also `:`). */
|
|
474
|
+
declare class CliTrueCommandProcessor implements ICliCommandProcessor {
|
|
475
|
+
command: string;
|
|
476
|
+
aliases: string[];
|
|
477
|
+
description: string;
|
|
478
|
+
author: any;
|
|
479
|
+
acceptsRawInput: boolean;
|
|
480
|
+
metadata?: CliProcessorMetadata;
|
|
481
|
+
processCommand(): Promise<void>;
|
|
482
|
+
}
|
|
483
|
+
/** `false`: do nothing, unsuccessfully (exit status 1). */
|
|
484
|
+
declare class CliFalseCommandProcessor implements ICliCommandProcessor {
|
|
485
|
+
command: string;
|
|
486
|
+
description: string;
|
|
487
|
+
author: any;
|
|
488
|
+
acceptsRawInput: boolean;
|
|
489
|
+
metadata?: CliProcessorMetadata;
|
|
490
|
+
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
491
|
+
}
|
|
492
|
+
|
|
489
493
|
declare class CliCaptureCommandProcessor implements ICliCommandProcessor {
|
|
490
494
|
command: string;
|
|
491
495
|
description: string;
|
|
492
496
|
aliases: string[];
|
|
493
497
|
author: ICliCommandAuthor;
|
|
494
498
|
metadata: CliProcessorMetadata;
|
|
495
|
-
parameters: ICliCommandParameterDescriptor[];
|
|
499
|
+
parameters: ICliCommandParameterDescriptor$1[];
|
|
496
500
|
processCommand(cmd: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
501
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
497
502
|
private sanitizeCssColor;
|
|
498
503
|
private toHtml;
|
|
499
504
|
private escapeHtml;
|
|
@@ -508,6 +513,7 @@ declare class CliSnippetCommandProcessor implements ICliCommandProcessor {
|
|
|
508
513
|
metadata: CliProcessorMetadata;
|
|
509
514
|
stateConfiguration: CliStateConfiguration;
|
|
510
515
|
processors: ICliCommandChildProcessor[];
|
|
516
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
511
517
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
512
518
|
}
|
|
513
519
|
|
|
@@ -516,8 +522,9 @@ declare class CliDiffCommandProcessor implements ICliCommandProcessor {
|
|
|
516
522
|
description: string;
|
|
517
523
|
author: ICliCommandAuthor;
|
|
518
524
|
metadata: CliProcessorMetadata;
|
|
519
|
-
parameters: ICliCommandParameterDescriptor[];
|
|
525
|
+
parameters: ICliCommandParameterDescriptor$1[];
|
|
520
526
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
527
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
521
528
|
}
|
|
522
529
|
|
|
523
530
|
type DiffType = 'same' | 'add' | 'remove';
|
|
@@ -539,11 +546,17 @@ declare class CliHelpCommandProcessor implements ICliCommandProcessor {
|
|
|
539
546
|
aliases: string[];
|
|
540
547
|
description: string;
|
|
541
548
|
acceptsRawInput?: boolean | undefined;
|
|
542
|
-
author:
|
|
549
|
+
author: any;
|
|
543
550
|
metadata?: CliProcessorMetadata | undefined;
|
|
544
551
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
545
552
|
writeDescription(context: ICliExecutionContext): void;
|
|
546
553
|
private translateDescription;
|
|
554
|
+
/**
|
|
555
|
+
* Canonical path of the command being described (`server.status` for
|
|
556
|
+
* `help srv ping`), so a sub-command's translation keys include its
|
|
557
|
+
* parents: `cli.server.status.description`.
|
|
558
|
+
*/
|
|
559
|
+
private commandPath;
|
|
547
560
|
private writeProcessorDescription;
|
|
548
561
|
private formatModuleName;
|
|
549
562
|
private writeParameter;
|
|
@@ -589,44 +602,45 @@ declare class CliHotKeysCommandProcessor implements ICliCommandProcessor {
|
|
|
589
602
|
aliases: string[];
|
|
590
603
|
description: string;
|
|
591
604
|
processors?: ICliCommandProcessor[] | undefined;
|
|
592
|
-
author:
|
|
605
|
+
author: any;
|
|
593
606
|
metadata?: CliProcessorMetadata | undefined;
|
|
594
607
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
595
608
|
writeDescription(context: ICliExecutionContext): void;
|
|
596
609
|
}
|
|
597
610
|
|
|
611
|
+
/** `pkg`: install, update and remove CLI plugins at runtime from npm/CDN sources. */
|
|
598
612
|
declare class CliPackagesCommandProcessor implements ICliCommandProcessor {
|
|
599
613
|
readonly command = "pkg";
|
|
600
614
|
readonly aliases: string[];
|
|
601
615
|
description: string;
|
|
602
|
-
author:
|
|
603
|
-
readonly version = "1.0
|
|
604
|
-
readonly processors
|
|
616
|
+
author: any;
|
|
617
|
+
readonly version = "1.1.0";
|
|
618
|
+
readonly processors: ICliCommandProcessor[];
|
|
605
619
|
readonly metadata?: CliProcessorMetadata | undefined;
|
|
606
620
|
stateConfiguration?: CliStateConfiguration | undefined;
|
|
607
|
-
private
|
|
608
|
-
private
|
|
609
|
-
private
|
|
610
|
-
private registry;
|
|
611
|
-
private createAbortSignal;
|
|
621
|
+
private readonly loader;
|
|
622
|
+
private readonly manager;
|
|
623
|
+
private readonly installer;
|
|
612
624
|
constructor();
|
|
613
625
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
614
|
-
writeDescription
|
|
626
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
615
627
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
616
|
-
private
|
|
617
|
-
private
|
|
618
|
-
private
|
|
619
|
-
private
|
|
620
|
-
private
|
|
621
|
-
private
|
|
622
|
-
private
|
|
623
|
-
private
|
|
628
|
+
private lsCommand;
|
|
629
|
+
private browseCommand;
|
|
630
|
+
private addCommand;
|
|
631
|
+
private removeCommand;
|
|
632
|
+
private versionsCommand;
|
|
633
|
+
private checkCommand;
|
|
634
|
+
private updateCommand;
|
|
635
|
+
private sourceCommand;
|
|
636
|
+
/** Install as a tracked background job (visible in `services`), or inline if that fails. */
|
|
637
|
+
private installInBackground;
|
|
624
638
|
}
|
|
625
639
|
|
|
626
640
|
declare class CliDebugCommandProcessor implements ICliCommandProcessor {
|
|
627
641
|
command: string;
|
|
628
642
|
description: string;
|
|
629
|
-
author:
|
|
643
|
+
author: any;
|
|
630
644
|
metadata?: CliProcessorMetadata;
|
|
631
645
|
processors?: ICliCommandProcessor[];
|
|
632
646
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
@@ -638,7 +652,7 @@ declare class CliNanoCommandProcessor implements ICliCommandProcessor {
|
|
|
638
652
|
command: string;
|
|
639
653
|
aliases: string[];
|
|
640
654
|
description: string;
|
|
641
|
-
author:
|
|
655
|
+
author: any;
|
|
642
656
|
acceptsRawInput: boolean;
|
|
643
657
|
metadata: CliProcessorMetadata;
|
|
644
658
|
private buffer;
|
|
@@ -657,6 +671,7 @@ declare class CliNanoCommandProcessor implements ICliCommandProcessor {
|
|
|
657
671
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
658
672
|
onData(data: string, context: ICliExecutionContext): Promise<void>;
|
|
659
673
|
writeDescription(context: ICliExecutionContext): void;
|
|
674
|
+
private setupHighlighting;
|
|
660
675
|
private render;
|
|
661
676
|
private renderPrompt;
|
|
662
677
|
private showStatus;
|
|
@@ -675,7 +690,7 @@ declare class CliServicesCommandProcessor implements ICliCommandProcessor {
|
|
|
675
690
|
command: string;
|
|
676
691
|
aliases: string[];
|
|
677
692
|
description: string;
|
|
678
|
-
author:
|
|
693
|
+
author: any;
|
|
679
694
|
processors?: ICliCommandProcessor[];
|
|
680
695
|
metadata?: CliProcessorMetadata;
|
|
681
696
|
constructor();
|
|
@@ -683,27 +698,81 @@ declare class CliServicesCommandProcessor implements ICliCommandProcessor {
|
|
|
683
698
|
writeDescription(context: ICliExecutionContext): void;
|
|
684
699
|
}
|
|
685
700
|
|
|
701
|
+
/**
|
|
702
|
+
* `events`: inspect the terminal's event bus — watch events live, show the
|
|
703
|
+
* recent ones, or emit one (for testing plugins).
|
|
704
|
+
*/
|
|
705
|
+
declare class CliEventsCommandProcessor implements ICliCommandProcessor {
|
|
706
|
+
command: string;
|
|
707
|
+
description: string;
|
|
708
|
+
author: any;
|
|
709
|
+
version: string;
|
|
710
|
+
metadata?: CliProcessorMetadata;
|
|
711
|
+
processors: ICliCommandProcessor[];
|
|
712
|
+
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
713
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
714
|
+
}
|
|
715
|
+
|
|
686
716
|
declare class CliPsCommandProcessor implements ICliCommandProcessor {
|
|
687
717
|
command: string;
|
|
688
718
|
description: string;
|
|
689
|
-
author:
|
|
719
|
+
author: any;
|
|
690
720
|
metadata: {
|
|
691
721
|
icon: string;
|
|
692
722
|
sealed: boolean;
|
|
693
723
|
};
|
|
694
724
|
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
725
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
695
726
|
}
|
|
696
727
|
|
|
697
728
|
declare class CliKillCommandProcessor implements ICliCommandProcessor {
|
|
698
729
|
command: string;
|
|
699
730
|
description: string;
|
|
700
|
-
author:
|
|
731
|
+
author: any;
|
|
701
732
|
valueRequired: boolean;
|
|
702
733
|
metadata: {
|
|
703
734
|
icon: string;
|
|
704
735
|
sealed: boolean;
|
|
705
736
|
};
|
|
706
737
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
738
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
739
|
+
}
|
|
740
|
+
|
|
741
|
+
declare class CliHtopCommandProcessor implements ICliCommandProcessor {
|
|
742
|
+
command: string;
|
|
743
|
+
description: string;
|
|
744
|
+
author: any;
|
|
745
|
+
metadata?: CliProcessorMetadata;
|
|
746
|
+
private context;
|
|
747
|
+
private registry;
|
|
748
|
+
private refreshTimer;
|
|
749
|
+
private rows;
|
|
750
|
+
private selectedIndex;
|
|
751
|
+
private scrollOffset;
|
|
752
|
+
private termCols;
|
|
753
|
+
private termRows;
|
|
754
|
+
private showingLogs;
|
|
755
|
+
private errorMessage;
|
|
756
|
+
private errorTimeout;
|
|
757
|
+
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
758
|
+
onData(data: string, context: ICliExecutionContext): Promise<void>;
|
|
759
|
+
onResize(cols: number, rows: number, _context: ICliExecutionContext): void;
|
|
760
|
+
onDispose(_context: ICliExecutionContext): void;
|
|
761
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
762
|
+
private refreshData;
|
|
763
|
+
private actionKill;
|
|
764
|
+
private actionStart;
|
|
765
|
+
private actionStop;
|
|
766
|
+
private actionRestart;
|
|
767
|
+
private actionLogs;
|
|
768
|
+
private moveSelection;
|
|
769
|
+
private get visibleRows();
|
|
770
|
+
private clampScroll;
|
|
771
|
+
private render;
|
|
772
|
+
private buildFooter;
|
|
773
|
+
private renderLogsOverlay;
|
|
774
|
+
private showError;
|
|
775
|
+
private exit;
|
|
707
776
|
}
|
|
708
777
|
|
|
709
778
|
declare const systemProcessors: ICliCommandProcessor[];
|
|
@@ -721,6 +790,8 @@ declare class CliThemeCommandProcessor implements ICliCommandProcessor {
|
|
|
721
790
|
private defaultTheme;
|
|
722
791
|
constructor();
|
|
723
792
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
793
|
+
/** Apply the saved theme (or the default one when `reset` and none is saved). */
|
|
794
|
+
private applySavedTheme;
|
|
724
795
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
725
796
|
private renderThemePreview;
|
|
726
797
|
private applyStyles;
|
|
@@ -732,39 +803,7 @@ type ThemeState = {
|
|
|
732
803
|
selectedTheme?: string;
|
|
733
804
|
customOptions?: ITheme;
|
|
734
805
|
};
|
|
735
|
-
declare const themes:
|
|
736
|
-
[x: string]: ITheme;
|
|
737
|
-
default: ITheme;
|
|
738
|
-
classic: ITheme;
|
|
739
|
-
dracula: ITheme;
|
|
740
|
-
monokai: ITheme;
|
|
741
|
-
solarizedDark: ITheme;
|
|
742
|
-
solarizedLight: ITheme;
|
|
743
|
-
gruvboxDark: ITheme;
|
|
744
|
-
gruvboxLight: ITheme;
|
|
745
|
-
nord: ITheme;
|
|
746
|
-
oneDark: ITheme;
|
|
747
|
-
material: ITheme;
|
|
748
|
-
highContrastLight: ITheme;
|
|
749
|
-
tokyoNight: ITheme;
|
|
750
|
-
catppuccinMocha: ITheme;
|
|
751
|
-
catppuccinFrappe: ITheme;
|
|
752
|
-
rosePine: ITheme;
|
|
753
|
-
kanagawa: ITheme;
|
|
754
|
-
everforestDark: ITheme;
|
|
755
|
-
ayuDark: ITheme;
|
|
756
|
-
catppuccinLatte: ITheme;
|
|
757
|
-
rosePineDawn: ITheme;
|
|
758
|
-
everforestLight: ITheme;
|
|
759
|
-
githubLight: ITheme;
|
|
760
|
-
cyberpunk: ITheme;
|
|
761
|
-
retroGreen: ITheme;
|
|
762
|
-
retroAmber: ITheme;
|
|
763
|
-
matrix: ITheme;
|
|
764
|
-
synthwave: ITheme;
|
|
765
|
-
highContrastDark: ITheme;
|
|
766
|
-
yellow: ITheme;
|
|
767
|
-
};
|
|
806
|
+
declare const themes: any;
|
|
768
807
|
declare const themeInfos: Record<string, CliThemeInfo>;
|
|
769
808
|
|
|
770
809
|
declare class CliConfigureCommandProcessor implements ICliCommandProcessor {
|
|
@@ -784,7 +823,16 @@ declare class CliConfigureCommandProcessor implements ICliCommandProcessor {
|
|
|
784
823
|
private editOption;
|
|
785
824
|
private setConfigValue;
|
|
786
825
|
private getConfigValue;
|
|
826
|
+
/**
|
|
827
|
+
* The language choices are the locales loaded so far: a language pack
|
|
828
|
+
* installed after boot (`pkg add @qodalis/cli-lang-de`) adds one.
|
|
829
|
+
*/
|
|
830
|
+
private refreshLanguageOptions;
|
|
787
831
|
private getAllOptions;
|
|
832
|
+
/**
|
|
833
|
+
* @param onBoot at startup, terminal options still at their default are skipped so the
|
|
834
|
+
* host's `terminalOptions` (e.g. its own fontSize) are not overridden.
|
|
835
|
+
*/
|
|
788
836
|
private applySystemSettings;
|
|
789
837
|
private buildListProcessor;
|
|
790
838
|
private buildGetProcessor;
|
|
@@ -819,22 +867,39 @@ declare class CliPingCommandProcessor implements ICliCommandProcessor {
|
|
|
819
867
|
private sleep;
|
|
820
868
|
}
|
|
821
869
|
|
|
870
|
+
/** Permission to change shared variables, when an auth module is loaded. */
|
|
871
|
+
declare const CLI_ENV_GLOBAL_PERMISSION = "system:env:global";
|
|
872
|
+
/** Parse `A=1 B="two words" C` into assignments; bare names have no value. */
|
|
873
|
+
declare function parseAssignments(raw: string): {
|
|
874
|
+
name: string;
|
|
875
|
+
value?: string;
|
|
876
|
+
}[] | null;
|
|
822
877
|
/**
|
|
823
878
|
* `export` — set environment variables.
|
|
824
879
|
*
|
|
825
880
|
* Usage:
|
|
826
881
|
* export VAR=value
|
|
827
|
-
* export VAR="value with spaces"
|
|
882
|
+
* export VAR="value with spaces" OTHER=1
|
|
883
|
+
*
|
|
884
|
+
* Variables are saved for the signed-in user (`--global`: for everyone) and
|
|
885
|
+
* restored on the next visit. `NAME=value` alone is for this terminal only.
|
|
828
886
|
*/
|
|
829
887
|
declare class CliExportCommandProcessor implements ICliCommandProcessor {
|
|
830
888
|
command: string;
|
|
831
889
|
description: string;
|
|
832
|
-
author:
|
|
890
|
+
author: any;
|
|
833
891
|
acceptsRawInput: boolean;
|
|
834
892
|
metadata: {
|
|
835
893
|
icon: string;
|
|
836
894
|
module: string;
|
|
837
895
|
};
|
|
896
|
+
parameters: ICliCommandParameterDescriptor[];
|
|
897
|
+
stateConfiguration: CliStateConfiguration;
|
|
898
|
+
/**
|
|
899
|
+
* Restore saved variables, save every later change (export, unset) and
|
|
900
|
+
* follow changes saved in other tabs and terminals.
|
|
901
|
+
*/
|
|
902
|
+
initialize(context: ICliExecutionContext): Promise<void>;
|
|
838
903
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
839
904
|
writeDescription(context: ICliExecutionContext): void;
|
|
840
905
|
}
|
|
@@ -844,12 +909,13 @@ declare class CliExportCommandProcessor implements ICliCommandProcessor {
|
|
|
844
909
|
declare class CliUnsetCommandProcessor implements ICliCommandProcessor {
|
|
845
910
|
command: string;
|
|
846
911
|
description: string;
|
|
847
|
-
author:
|
|
912
|
+
author: any;
|
|
848
913
|
acceptsRawInput: boolean;
|
|
849
914
|
metadata: {
|
|
850
915
|
icon: string;
|
|
851
916
|
module: string;
|
|
852
917
|
};
|
|
918
|
+
parameters: any[];
|
|
853
919
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
854
920
|
writeDescription(context: ICliExecutionContext): void;
|
|
855
921
|
}
|
|
@@ -860,7 +926,7 @@ declare class CliEnvCommandProcessor implements ICliCommandProcessor {
|
|
|
860
926
|
command: string;
|
|
861
927
|
aliases: string[];
|
|
862
928
|
description: string;
|
|
863
|
-
author:
|
|
929
|
+
author: any;
|
|
864
930
|
acceptsRawInput: boolean;
|
|
865
931
|
metadata: {
|
|
866
932
|
icon: string;
|
|
@@ -878,13 +944,18 @@ declare class CliFontSizeCommandProcessor implements ICliCommandProcessor {
|
|
|
878
944
|
metadata: CliProcessorMetadata;
|
|
879
945
|
stateConfiguration: CliStateConfiguration;
|
|
880
946
|
processors: ICliCommandProcessor[];
|
|
947
|
+
/** The size the host configured (or the built-in default), restored by `font-size reset`. */
|
|
948
|
+
private hostFontSize?;
|
|
881
949
|
initialize(context: ICliExecutionContext): Promise<void>;
|
|
882
950
|
processCommand(_: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
951
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
883
952
|
private getCurrent;
|
|
953
|
+
private getDefault;
|
|
954
|
+
private resetFontSize;
|
|
884
955
|
private setFontSize;
|
|
885
956
|
}
|
|
886
957
|
|
|
887
|
-
declare const miscProcessors: (
|
|
958
|
+
declare const miscProcessors: (CliClearCommandProcessor | CliEchoCommandProcessor | CliEvalCommandProcessor | CliAliasCommandProcessor | CliUnAliasCommandProcessor | CliSleepCommandProcessor | CliUnameCommandProcessor | CliTimeCommandProcessor | CliJsonCommandProcessor | CliRandomCommandProcessor | CliUptimeCommandProcessor | CliOpenCommandProcessor | CliLoremCommandProcessor | CliTimestampCommandProcessor | CliColorCommandProcessor | CliCalCommandProcessor | CliSeqCommandProcessor | CliScreenCommandProcessor | CliClipboardCommandProcessor | CliConvertCommandProcessor | CliYesCommandProcessor | CliTestCommandProcessor | CliTrueCommandProcessor | CliFalseCommandProcessor)[];
|
|
888
959
|
declare const builtinProcessors: ICliCommandProcessor[];
|
|
889
960
|
|
|
890
961
|
declare class CliExecutionProcess implements ICliExecutionProcess {
|
|
@@ -928,6 +999,8 @@ declare class CliCommandExecutionContext implements ICliExecutionContext {
|
|
|
928
999
|
translator: ICliTranslationService;
|
|
929
1000
|
reader: ICliInputReader;
|
|
930
1001
|
readonly backgroundServices: ICliBackgroundServiceRegistry;
|
|
1002
|
+
http: ICliHttpClient;
|
|
1003
|
+
notifier: ICliNotifier;
|
|
931
1004
|
get promptLength(): number;
|
|
932
1005
|
set promptLength(value: number);
|
|
933
1006
|
get currentLine(): string;
|
|
@@ -946,14 +1019,35 @@ declare class CliCommandExecutionContext implements ICliExecutionContext {
|
|
|
946
1019
|
exitFullScreenMode: () => void;
|
|
947
1020
|
createInterval: (callback: () => void, ms: number) => ICliManagedInterval;
|
|
948
1021
|
createTimeout: (callback: () => void, ms: number) => ICliManagedTimer;
|
|
1022
|
+
submitCommand: (command: string) => Promise<void>;
|
|
1023
|
+
events?: ICliEventBus;
|
|
1024
|
+
get isBooted(): boolean | undefined;
|
|
949
1025
|
constructor(context: ICliExecutionContext, processor: ICliCommandProcessor);
|
|
950
1026
|
}
|
|
951
1027
|
|
|
1028
|
+
/**
|
|
1029
|
+
* Command history, kept per user like a shell's `~/.bash_history`: each
|
|
1030
|
+
* signed-in user (by id) has their own, and the shared one is used while
|
|
1031
|
+
* nobody is signed in.
|
|
1032
|
+
*/
|
|
952
1033
|
declare class CliCommandHistory {
|
|
953
1034
|
private readonly store;
|
|
954
|
-
private readonly storageKey;
|
|
955
1035
|
private commandHistory;
|
|
1036
|
+
/** Id of the user whose history is loaded; undefined: nobody signed in */
|
|
1037
|
+
private userId;
|
|
1038
|
+
private loading;
|
|
1039
|
+
/** Counts user switches (a load for an older one is dropped) */
|
|
1040
|
+
private switches;
|
|
1041
|
+
private _generation;
|
|
956
1042
|
constructor(store: ICliKeyValueStore);
|
|
1043
|
+
/** Changes whenever the history is replaced: switched or loaded (positions into it are stale) */
|
|
1044
|
+
get generation(): number;
|
|
1045
|
+
private get storageKey();
|
|
1046
|
+
/**
|
|
1047
|
+
* Switch to the history of `userId` (undefined: nobody signed in).
|
|
1048
|
+
* Resolves once it is loaded; a no-op for the user already loaded.
|
|
1049
|
+
*/
|
|
1050
|
+
useUser(userId: string | undefined): Promise<void>;
|
|
957
1051
|
addCommand(command: string): Promise<void>;
|
|
958
1052
|
getLastIndex(): number;
|
|
959
1053
|
getHistory(): string[];
|
|
@@ -984,7 +1078,7 @@ declare class CliCommandHistory {
|
|
|
984
1078
|
|
|
985
1079
|
interface ICliStateStoreManager {
|
|
986
1080
|
getProcessorStateStore(processor: ICliCommandProcessor): ICliStateStore;
|
|
987
|
-
getStateStore(name: string, defaultState?: Record<string, any
|
|
1081
|
+
getStateStore(name: string, defaultState?: Record<string, any>, options?: CliStateStoreOptions): ICliStateStore;
|
|
988
1082
|
getStoreEntries(): {
|
|
989
1083
|
name: string;
|
|
990
1084
|
state: Record<string, any>;
|
|
@@ -994,9 +1088,25 @@ declare class CliStateStoreManager implements ICliStateStoreManager {
|
|
|
994
1088
|
private readonly services;
|
|
995
1089
|
private readonly registry;
|
|
996
1090
|
private stores;
|
|
1091
|
+
private channel?;
|
|
1092
|
+
/** The signed-in user (for `scope: 'user'` stores). */
|
|
1093
|
+
private user?;
|
|
1094
|
+
private stopFollowingUser?;
|
|
997
1095
|
constructor(services: ICliServiceProvider, registry: ICliCommandProcessorRegistry);
|
|
998
|
-
|
|
1096
|
+
/**
|
|
1097
|
+
* Get (or create) the store `name`. Defaults and options passed for a
|
|
1098
|
+
* store that already exists are added to it: a store read early (e.g.
|
|
1099
|
+
* by the boot report) still gets its command's initial state.
|
|
1100
|
+
*/
|
|
1101
|
+
getStateStore(name: string, defaultState?: Record<string, any>, options?: CliStateStoreOptions): ICliStateStore;
|
|
999
1102
|
getProcessorStateStore(processor: ICliCommandProcessor): ICliStateStore;
|
|
1103
|
+
/**
|
|
1104
|
+
* Follow the signed-in user (`session:changed` events), so `scope: 'user'`
|
|
1105
|
+
* stores switch to that user's state.
|
|
1106
|
+
*/
|
|
1107
|
+
followUser(events: ICliEventBus): void;
|
|
1108
|
+
/** Switch `scope: 'user'` stores to `user`'s saved state. */
|
|
1109
|
+
setUser(user: string | undefined): void;
|
|
1000
1110
|
/**
|
|
1001
1111
|
* Returns all store names and their current state values.
|
|
1002
1112
|
*/
|
|
@@ -1004,53 +1114,14 @@ declare class CliStateStoreManager implements ICliStateStoreManager {
|
|
|
1004
1114
|
name: string;
|
|
1005
1115
|
state: Record<string, any>;
|
|
1006
1116
|
}[];
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
cursorPosition: number;
|
|
1016
|
-
defaultValue?: boolean;
|
|
1017
|
-
options?: CliSelectOption[];
|
|
1018
|
-
selectedIndex?: number;
|
|
1019
|
-
onChange?: (value: string) => void;
|
|
1020
|
-
checkedIndices?: Set<number>;
|
|
1021
|
-
numberOptions?: {
|
|
1022
|
-
min?: number;
|
|
1023
|
-
max?: number;
|
|
1024
|
-
default?: number;
|
|
1025
|
-
};
|
|
1026
|
-
scrollOffset?: number;
|
|
1027
|
-
maxVisible?: number;
|
|
1028
|
-
displayLines?: number;
|
|
1029
|
-
}
|
|
1030
|
-
interface CliInputReaderHost {
|
|
1031
|
-
readonly activeInputRequest: ActiveInputRequest | null;
|
|
1032
|
-
setActiveInputRequest(request: ActiveInputRequest | null): void;
|
|
1033
|
-
writeToTerminal(text: string): void;
|
|
1034
|
-
getTerminalRows?(): number;
|
|
1035
|
-
}
|
|
1036
|
-
declare class CliInputReader implements ICliInputReader {
|
|
1037
|
-
private readonly host;
|
|
1038
|
-
constructor(host: CliInputReaderHost);
|
|
1039
|
-
readLine(prompt: string): Promise<string | null>;
|
|
1040
|
-
readPassword(prompt: string): Promise<string | null>;
|
|
1041
|
-
readConfirm(prompt: string, defaultValue?: boolean): Promise<boolean | null>;
|
|
1042
|
-
readSelect(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
|
|
1043
|
-
readSelectInline(prompt: string, options: CliSelectOption[], onChange?: (value: string) => void): Promise<string | null>;
|
|
1044
|
-
readMultiSelect(prompt: string, options: CliMultiSelectOption[]): Promise<string[] | null>;
|
|
1045
|
-
readNumber(prompt: string, options?: {
|
|
1046
|
-
min?: number;
|
|
1047
|
-
max?: number;
|
|
1048
|
-
default?: number;
|
|
1049
|
-
}): Promise<number | null>;
|
|
1050
|
-
renderSelectOptions(options: CliSelectOption[], selectedIndex: number, scrollOffset?: number, maxVisible?: number): number;
|
|
1051
|
-
renderInlineSelectOptions(options: CliSelectOption[], selectedIndex: number): string;
|
|
1052
|
-
renderMultiSelectOptions(options: CliSelectOption[], selectedIndex: number, checkedIndices: Set<number>, scrollOffset?: number, maxVisible?: number): number;
|
|
1053
|
-
private createInputRequest;
|
|
1117
|
+
/**
|
|
1118
|
+
* Dispose all stores (completes their BehaviorSubjects).
|
|
1119
|
+
* Called during engine teardown.
|
|
1120
|
+
*/
|
|
1121
|
+
dispose(): void;
|
|
1122
|
+
/** Tell other tabs and terminals that a store was saved. */
|
|
1123
|
+
private publish;
|
|
1124
|
+
private listen;
|
|
1054
1125
|
}
|
|
1055
1126
|
|
|
1056
1127
|
/**
|
|
@@ -1086,6 +1157,10 @@ declare class CliCompletionEngine {
|
|
|
1086
1157
|
candidates?: string[];
|
|
1087
1158
|
}>;
|
|
1088
1159
|
private buildContext;
|
|
1160
|
+
/**
|
|
1161
|
+
* Words with their start, quote-aware: `cat "my notes.txt"` has two, and an
|
|
1162
|
+
* unclosed quote runs to the end (`cat "my no` is being typed).
|
|
1163
|
+
*/
|
|
1089
1164
|
private tokenize;
|
|
1090
1165
|
private fetchCompletions;
|
|
1091
1166
|
/**
|
|
@@ -1099,7 +1174,7 @@ declare class CliCompletionEngine {
|
|
|
1099
1174
|
/**
|
|
1100
1175
|
* Reusable text buffer with cursor management.
|
|
1101
1176
|
* Eliminates duplicated line-editing logic across CommandLineMode,
|
|
1102
|
-
*
|
|
1177
|
+
* LineInputMode, and any future input mode.
|
|
1103
1178
|
*/
|
|
1104
1179
|
declare class CliLineBuffer {
|
|
1105
1180
|
private _text;
|
|
@@ -1116,6 +1191,12 @@ declare class CliLineBuffer {
|
|
|
1116
1191
|
moveEnd(): void;
|
|
1117
1192
|
clear(): void;
|
|
1118
1193
|
setText(str: string): void;
|
|
1194
|
+
/** Remove the text before the cursor (Ctrl+U); returns it */
|
|
1195
|
+
deleteToStart(): string;
|
|
1196
|
+
/** Remove the text from the cursor to the end (Ctrl+K); returns it */
|
|
1197
|
+
deleteToEnd(): string;
|
|
1198
|
+
/** Remove the whitespace-delimited word before the cursor (Ctrl+W); returns it */
|
|
1199
|
+
deleteWordBefore(): string;
|
|
1119
1200
|
}
|
|
1120
1201
|
|
|
1121
1202
|
/**
|
|
@@ -1143,11 +1224,38 @@ interface IInputMode {
|
|
|
1143
1224
|
* Called when this mode is no longer the active input mode.
|
|
1144
1225
|
*/
|
|
1145
1226
|
deactivate?(): void;
|
|
1227
|
+
/** Called when the terminal is resized while this mode is active. */
|
|
1228
|
+
onResize?(cols: number, rows: number): void;
|
|
1229
|
+
}
|
|
1230
|
+
/**
|
|
1231
|
+
* Host interface for input modes. Provides access to terminal I/O,
|
|
1232
|
+
* dimensions, and mode stack management.
|
|
1233
|
+
*/
|
|
1234
|
+
interface InputModeHost {
|
|
1235
|
+
/** Write raw text/ANSI to the terminal */
|
|
1236
|
+
writeToTerminal(text: string): void;
|
|
1237
|
+
/** Get terminal row count for scroll window sizing */
|
|
1238
|
+
getTerminalRows(): number;
|
|
1239
|
+
/** Get terminal column count for overflow calculations */
|
|
1240
|
+
getTerminalCols(): number;
|
|
1241
|
+
/** Push a mode onto the input mode stack */
|
|
1242
|
+
pushMode(mode: IInputMode): void;
|
|
1243
|
+
/** Pop the current mode from the input mode stack */
|
|
1244
|
+
popMode(): void;
|
|
1245
|
+
/** The xterm.js Terminal instance (for direct write when needed) */
|
|
1246
|
+
readonly terminal: Terminal;
|
|
1247
|
+
/** File picker provider for the current environment */
|
|
1248
|
+
readonly filePickerProvider: ICliFilePickerProvider;
|
|
1146
1249
|
}
|
|
1147
1250
|
|
|
1148
1251
|
interface PromptOptions {
|
|
1149
1252
|
userName?: string;
|
|
1150
1253
|
hideUserName?: boolean;
|
|
1254
|
+
/**
|
|
1255
|
+
* Shown (dimmed) instead of the user name when an auth module is loaded
|
|
1256
|
+
* but nobody is signed in, e.g. `anonymous:/$`. Empty/undefined: nothing.
|
|
1257
|
+
*/
|
|
1258
|
+
anonymousName?: string;
|
|
1151
1259
|
contextProcessor?: string;
|
|
1152
1260
|
pathProvider?: () => string | null;
|
|
1153
1261
|
}
|
|
@@ -1202,16 +1310,6 @@ interface CommandLineModeHost {
|
|
|
1202
1310
|
}): void;
|
|
1203
1311
|
}
|
|
1204
1312
|
|
|
1205
|
-
/**
|
|
1206
|
-
* Host interface for ReaderMode — provides access to the active input request.
|
|
1207
|
-
*/
|
|
1208
|
-
interface ReaderModeHost {
|
|
1209
|
-
readonly terminal: Terminal;
|
|
1210
|
-
getActiveInputRequest(): ActiveInputRequest | null;
|
|
1211
|
-
setActiveInputRequest(request: ActiveInputRequest | null): void;
|
|
1212
|
-
popMode(): void;
|
|
1213
|
-
}
|
|
1214
|
-
|
|
1215
1313
|
interface CliExecutionContextDeps {
|
|
1216
1314
|
services: ICliServiceProvider;
|
|
1217
1315
|
logger: ICliLogger;
|
|
@@ -1219,10 +1317,15 @@ interface CliExecutionContextDeps {
|
|
|
1219
1317
|
stateStoreManager: CliStateStoreManager;
|
|
1220
1318
|
translator: ICliTranslationService;
|
|
1221
1319
|
}
|
|
1222
|
-
declare class CliExecutionContext implements ICliExecutionContext,
|
|
1320
|
+
declare class CliExecutionContext implements ICliExecutionContext, InputModeHost, CommandLineModeHost {
|
|
1223
1321
|
terminal: Terminal;
|
|
1224
1322
|
executor: ICliCommandExecutorService;
|
|
1225
|
-
|
|
1323
|
+
private _userSession?;
|
|
1324
|
+
/** The signed-in user; changing it emits `session:changed`. */
|
|
1325
|
+
get userSession(): ICliUserSession | undefined;
|
|
1326
|
+
set userSession(session: ICliUserSession | undefined);
|
|
1327
|
+
/** The terminal's event bus. */
|
|
1328
|
+
readonly events?: ICliEventBus;
|
|
1226
1329
|
contextProcessor?: ICliCommandProcessor;
|
|
1227
1330
|
readonly writer: ICliTerminalWriter;
|
|
1228
1331
|
readonly spinner: ICliSpinner;
|
|
@@ -1237,31 +1340,65 @@ declare class CliExecutionContext implements ICliExecutionContext, CliInputReade
|
|
|
1237
1340
|
readonly services: ICliServiceProvider;
|
|
1238
1341
|
readonly translator: ICliTranslationService;
|
|
1239
1342
|
readonly backgroundServices: ICliBackgroundServiceRegistry;
|
|
1343
|
+
http: ICliHttpClient;
|
|
1344
|
+
readonly notifier: ICliNotifier;
|
|
1240
1345
|
promptPathProvider?: () => string | null;
|
|
1241
1346
|
readonly completionEngine: CliCompletionEngine;
|
|
1242
1347
|
promptLength: number;
|
|
1243
1348
|
readonly reader: ICliInputReader;
|
|
1349
|
+
/**
|
|
1350
|
+
* Result of the most recently executed command.
|
|
1351
|
+
* Updated by the command executor after each command completes.
|
|
1352
|
+
*/
|
|
1353
|
+
lastCommandResult?: {
|
|
1354
|
+
command: string;
|
|
1355
|
+
success: boolean;
|
|
1356
|
+
};
|
|
1357
|
+
/**
|
|
1358
|
+
* Whether a command is currently being executed.
|
|
1359
|
+
* Set by the command executor at start/end of executeCommand().
|
|
1360
|
+
*/
|
|
1361
|
+
isExecuting: boolean;
|
|
1244
1362
|
readonly lineBuffer: CliLineBuffer;
|
|
1245
1363
|
readonly lineRenderer: CliTerminalLineRenderer;
|
|
1246
1364
|
readonly commandHistory: CliCommandHistory;
|
|
1247
|
-
|
|
1365
|
+
readonly filePickerProvider: ICliFilePickerProvider;
|
|
1248
1366
|
private readonly modeStack;
|
|
1249
|
-
|
|
1250
|
-
private
|
|
1367
|
+
/** Command-line input typed while booting; `null` when not holding. */
|
|
1368
|
+
private heldInput;
|
|
1369
|
+
private releaseHeldInputAtPrompt;
|
|
1370
|
+
private _typedDuringBoot;
|
|
1371
|
+
private readonly stateStoreManager;
|
|
1372
|
+
private readonly timerManager;
|
|
1373
|
+
private readonly fullScreenManager;
|
|
1374
|
+
private windowKeydownListener?;
|
|
1251
1375
|
constructor(deps: CliExecutionContextDeps, terminal: Terminal, executor: ICliCommandExecutorService, cliOptions?: CliOptions);
|
|
1252
|
-
get activeInputRequest(): ActiveInputRequest | null;
|
|
1253
|
-
/**
|
|
1254
|
-
* Sets the active input request. When a non-null request is provided,
|
|
1255
|
-
* pushes ReaderMode onto the mode stack. ReaderMode pops itself on
|
|
1256
|
-
* completion, so passing null here does NOT pop the mode.
|
|
1257
|
-
*/
|
|
1258
|
-
setActiveInputRequest(request: ActiveInputRequest | null): void;
|
|
1259
1376
|
writeToTerminal(text: string): void;
|
|
1260
1377
|
getTerminalRows(): number;
|
|
1378
|
+
getTerminalCols(): number;
|
|
1261
1379
|
get currentLine(): string;
|
|
1262
1380
|
get cursorPosition(): number;
|
|
1263
1381
|
set cursorPosition(value: number);
|
|
1264
1382
|
initializeTerminalListeners(): void;
|
|
1383
|
+
private handleTerminalData;
|
|
1384
|
+
private _isBooted;
|
|
1385
|
+
/** `true` once boot has completed and the terminal is ready. */
|
|
1386
|
+
get isBooted(): boolean;
|
|
1387
|
+
/** Called by the engine when boot has completed. */
|
|
1388
|
+
markBooted(): void;
|
|
1389
|
+
/** Start keeping command-line input instead of handling it (boot). */
|
|
1390
|
+
holdInput(): void;
|
|
1391
|
+
/**
|
|
1392
|
+
* Stop holding input: what was typed is replayed at the next prompt, or
|
|
1393
|
+
* right away when `immediately` is set (e.g. no prompt will be drawn).
|
|
1394
|
+
*/
|
|
1395
|
+
releaseInput(immediately?: boolean): void;
|
|
1396
|
+
/** Whether a prompt (readLine, readSelect, ...) or full-screen mode owns the input. */
|
|
1397
|
+
get isReadingInput(): boolean;
|
|
1398
|
+
/** Whether keys were typed while input was held (boot). */
|
|
1399
|
+
get typedDuringBoot(): boolean;
|
|
1400
|
+
private replayHeldInput;
|
|
1401
|
+
private initializeWindowListeners;
|
|
1265
1402
|
setContextProcessor: (processor: ICliCommandProcessor | undefined, silent?: boolean, fullScreen?: boolean) => void;
|
|
1266
1403
|
setCurrentLine(line: string): void;
|
|
1267
1404
|
clearLine(): void;
|
|
@@ -1270,6 +1407,12 @@ declare class CliExecutionContext implements ICliExecutionContext, CliInputReade
|
|
|
1270
1407
|
newLine?: boolean;
|
|
1271
1408
|
keepCurrentLine?: boolean;
|
|
1272
1409
|
}): void;
|
|
1410
|
+
/**
|
|
1411
|
+
* Submit and execute a command — shared by interactive Enter key
|
|
1412
|
+
* and programmatic engine.execute(). Adds to history, runs the
|
|
1413
|
+
* command, and shows a new prompt afterwards.
|
|
1414
|
+
*/
|
|
1415
|
+
submitCommand(command: string): Promise<void>;
|
|
1273
1416
|
clearCurrentLine(): void;
|
|
1274
1417
|
refreshCurrentLine(previousContentLength?: number): void;
|
|
1275
1418
|
/**
|
|
@@ -1285,7 +1428,7 @@ declare class CliExecutionContext implements ICliExecutionContext, CliInputReade
|
|
|
1285
1428
|
*/
|
|
1286
1429
|
handleTerminalResize(): void;
|
|
1287
1430
|
isRawModeActive(): boolean;
|
|
1288
|
-
enterFullScreenMode(processor: ICliCommandProcessor): void;
|
|
1431
|
+
enterFullScreenMode(processor: ICliCommandProcessor, options?: CliFullScreenOptions): void;
|
|
1289
1432
|
exitFullScreenMode(): void;
|
|
1290
1433
|
createInterval(callback: () => void, ms: number): ICliManagedInterval;
|
|
1291
1434
|
createTimeout(callback: () => void, ms: number): ICliManagedTimer;
|
|
@@ -1296,8 +1439,6 @@ declare class CliExecutionContext implements ICliExecutionContext, CliInputReade
|
|
|
1296
1439
|
getPromptLength(): number;
|
|
1297
1440
|
setPromptLength(value: number): void;
|
|
1298
1441
|
getExecutionContext(): ICliExecutionContext;
|
|
1299
|
-
getActiveInputRequest(): ActiveInputRequest | null;
|
|
1300
|
-
private clearAllManagedTimers;
|
|
1301
1442
|
/**
|
|
1302
1443
|
* Dispose all resources. Called by CliEngine.destroy() when the
|
|
1303
1444
|
* CLI component is being torn down.
|
|
@@ -1308,6 +1449,100 @@ declare class CliExecutionContext implements ICliExecutionContext, CliInputReade
|
|
|
1308
1449
|
popMode(): void;
|
|
1309
1450
|
}
|
|
1310
1451
|
|
|
1452
|
+
/**
|
|
1453
|
+
* Per-session registry that manages background service lifecycle.
|
|
1454
|
+
*/
|
|
1455
|
+
declare class CliBackgroundServiceRegistry implements ICliBackgroundServiceRegistry {
|
|
1456
|
+
private readonly state;
|
|
1457
|
+
private readonly services;
|
|
1458
|
+
private readonly writer?;
|
|
1459
|
+
private readonly entries;
|
|
1460
|
+
private readonly handlers;
|
|
1461
|
+
private isFullScreen;
|
|
1462
|
+
private notificationQueue;
|
|
1463
|
+
private processRegistry?;
|
|
1464
|
+
constructor(state: ICliStateStore, services: ICliServiceProvider, writer?: ICliTerminalWriter);
|
|
1465
|
+
/** Attach the process registry so background services get PIDs */
|
|
1466
|
+
setProcessRegistry(registry: ICliProcessRegistry): void;
|
|
1467
|
+
register(service: ICliBackgroundService): void;
|
|
1468
|
+
start(name: string): Promise<void>;
|
|
1469
|
+
stop(name: string): Promise<void>;
|
|
1470
|
+
restart(name: string): Promise<void>;
|
|
1471
|
+
startJob(name: string, task: (context: ICliServiceContext) => Promise<void>, _options?: {
|
|
1472
|
+
workerCompatible?: boolean;
|
|
1473
|
+
}): Promise<void>;
|
|
1474
|
+
getStatus(name: string): ICliBackgroundServiceInfo | undefined;
|
|
1475
|
+
list(): ICliBackgroundServiceInfo[];
|
|
1476
|
+
getLogs(name: string, limit?: number): ICliServiceLogEntry[];
|
|
1477
|
+
on(handler: CliServiceEventHandler, filter?: {
|
|
1478
|
+
source?: string;
|
|
1479
|
+
type?: string;
|
|
1480
|
+
}): () => void;
|
|
1481
|
+
destroyAll(): Promise<void>;
|
|
1482
|
+
/** Called by the execution context when entering/exiting full-screen mode */
|
|
1483
|
+
setFullScreen(isFullScreen: boolean): void;
|
|
1484
|
+
private getEntry;
|
|
1485
|
+
private toInfo;
|
|
1486
|
+
private updateStatus;
|
|
1487
|
+
private handleStartError;
|
|
1488
|
+
private dispatchEvent;
|
|
1489
|
+
/**
|
|
1490
|
+
* Publish service events on the terminal's event bus: lifecycle events as
|
|
1491
|
+
* `service:<started|stopped|...>`, events relayed from a server's event
|
|
1492
|
+
* socket as `server:event`, other custom events as `service:event`.
|
|
1493
|
+
*/
|
|
1494
|
+
private forwardToEventBus;
|
|
1495
|
+
private emitLifecycleEvent;
|
|
1496
|
+
private notify;
|
|
1497
|
+
private flushNotificationQueue;
|
|
1498
|
+
private writeNotification;
|
|
1499
|
+
private completeInProcessRegistry;
|
|
1500
|
+
private failInProcessRegistry;
|
|
1501
|
+
}
|
|
1502
|
+
|
|
1503
|
+
/**
|
|
1504
|
+
* Manages full-screen terminal mode (alternate screen buffer).
|
|
1505
|
+
* Used by interactive commands like nano, htop, etc.
|
|
1506
|
+
*/
|
|
1507
|
+
declare class CliFullScreenManager {
|
|
1508
|
+
private readonly terminal;
|
|
1509
|
+
private readonly backgroundServices;
|
|
1510
|
+
private resizeDisposable;
|
|
1511
|
+
constructor(terminal: Terminal, backgroundServices: CliBackgroundServiceRegistry);
|
|
1512
|
+
/**
|
|
1513
|
+
* Enter full-screen mode using the alternate screen buffer.
|
|
1514
|
+
*/
|
|
1515
|
+
enter(processor: ICliCommandProcessor, setContextProcessor: (p: ICliCommandProcessor | undefined, silent?: boolean, fullScreen?: boolean) => void, context: ICliExecutionContext, options?: CliFullScreenOptions): void;
|
|
1516
|
+
/**
|
|
1517
|
+
* Exit full-screen mode and return to the main buffer.
|
|
1518
|
+
*/
|
|
1519
|
+
exit(contextProcessor: ICliCommandProcessor | undefined, setContextProcessor: (p: ICliCommandProcessor | undefined) => void, clearTimers: () => void, showPrompt: () => void, context: ICliExecutionContext): void;
|
|
1520
|
+
/**
|
|
1521
|
+
* Dispose resize subscription.
|
|
1522
|
+
*/
|
|
1523
|
+
dispose(): void;
|
|
1524
|
+
}
|
|
1525
|
+
|
|
1526
|
+
/**
|
|
1527
|
+
* Manages timers and intervals with automatic cleanup.
|
|
1528
|
+
* All managed timers are cleared when the execution context is disposed.
|
|
1529
|
+
*/
|
|
1530
|
+
declare class CliTimerManager {
|
|
1531
|
+
private readonly managedTimers;
|
|
1532
|
+
/**
|
|
1533
|
+
* Create a managed interval that will be automatically cleared on dispose.
|
|
1534
|
+
*/
|
|
1535
|
+
createInterval(callback: () => void, ms: number): ICliManagedInterval;
|
|
1536
|
+
/**
|
|
1537
|
+
* Create a managed timeout that will be automatically cleared on dispose.
|
|
1538
|
+
*/
|
|
1539
|
+
createTimeout(callback: () => void, ms: number): ICliManagedTimer;
|
|
1540
|
+
/**
|
|
1541
|
+
* Clear all managed timers and intervals.
|
|
1542
|
+
*/
|
|
1543
|
+
clearAll(): void;
|
|
1544
|
+
}
|
|
1545
|
+
|
|
1311
1546
|
/**
|
|
1312
1547
|
* Extended execution context interface used internally by the command executor.
|
|
1313
1548
|
* The concrete implementation (e.g. CliExecutionContext in angular-cli) provides these.
|
|
@@ -1315,34 +1550,37 @@ declare class CliExecutionContext implements ICliExecutionContext, CliInputReade
|
|
|
1315
1550
|
interface ICliExecutionHost extends ICliExecutionContext {
|
|
1316
1551
|
contextProcessor?: ICliCommandProcessor;
|
|
1317
1552
|
abort?(): void;
|
|
1553
|
+
lastCommandResult?: {
|
|
1554
|
+
command: string;
|
|
1555
|
+
success: boolean;
|
|
1556
|
+
};
|
|
1557
|
+
isExecuting?: boolean;
|
|
1318
1558
|
}
|
|
1319
1559
|
declare class CliCommandExecutor implements ICliCommandExecutorService {
|
|
1320
1560
|
protected readonly registry: ICliCommandProcessorRegistry;
|
|
1321
1561
|
private commandParser;
|
|
1322
1562
|
private globalParameters;
|
|
1323
|
-
|
|
1563
|
+
/** Exit status of the last command, expanded as `$?` (0 = success). */
|
|
1564
|
+
private lastExitCode;
|
|
1565
|
+
/** Command lines running per terminal (they can overlap). */
|
|
1566
|
+
private readonly running;
|
|
1567
|
+
/** Exit status of the last command line run (`$?`). */
|
|
1568
|
+
get exitStatus(): number;
|
|
1324
1569
|
constructor(registry: ICliCommandProcessorRegistry);
|
|
1325
1570
|
registerGlobalParameter(handler: ICliGlobalParameterHandler): void;
|
|
1326
|
-
getGlobalParameters(): ICliCommandParameterDescriptor[];
|
|
1571
|
+
getGlobalParameters(): ICliCommandParameterDescriptor$1[];
|
|
1327
1572
|
executeCommand(command: string, context: ICliExecutionContext): Promise<void>;
|
|
1328
|
-
|
|
1329
|
-
private
|
|
1330
|
-
private executeSingleCommand;
|
|
1331
|
-
private writeStderrToFile;
|
|
1332
|
-
private appendStderrToFile;
|
|
1333
|
-
showHelp(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
1573
|
+
/** Whether the command named first on the line takes literal input. */
|
|
1574
|
+
private isLiteralInput;
|
|
1334
1575
|
/**
|
|
1335
|
-
*
|
|
1336
|
-
*
|
|
1337
|
-
* Requires the @qodalis/cli-files plugin for filesystem access.
|
|
1576
|
+
* Run a command line and return its output as text instead of showing
|
|
1577
|
+
* it (`$(...)`); its errors and warnings are still shown.
|
|
1338
1578
|
*/
|
|
1339
|
-
|
|
1340
|
-
private
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
*/
|
|
1345
|
-
private expandEnvironmentVars;
|
|
1579
|
+
capture(command: string, from: ICliExecutionContext): Promise<string>;
|
|
1580
|
+
private executeSingleCommand;
|
|
1581
|
+
private completeProcess;
|
|
1582
|
+
private failProcess;
|
|
1583
|
+
showHelp(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
1346
1584
|
/**
|
|
1347
1585
|
* Validates the command arguments before execution.
|
|
1348
1586
|
* @param context The current CLI execution context.
|
|
@@ -1360,6 +1598,19 @@ declare class CliCommandExecutor implements ICliCommandExecutorService {
|
|
|
1360
1598
|
* parameter. In that case the global handler must be skipped so the
|
|
1361
1599
|
* processor can handle the flag itself.
|
|
1362
1600
|
*/
|
|
1601
|
+
/**
|
|
1602
|
+
* Runs all registered {@link ICliCommandGuard}s that apply to this command,
|
|
1603
|
+
* in priority order. Returns the block message of the first guard that
|
|
1604
|
+
* denies the command, or `undefined` when every guard allows it.
|
|
1605
|
+
* A guard that throws is treated as a denial (fail closed).
|
|
1606
|
+
*/
|
|
1607
|
+
private runGuards;
|
|
1608
|
+
/**
|
|
1609
|
+
* The text after the word that selected `processor`, which may be its
|
|
1610
|
+
* command or one of its aliases (e.g. `pkg rm guid` -> `guid`).
|
|
1611
|
+
*/
|
|
1612
|
+
private extractPositionalValue;
|
|
1613
|
+
private guardDenial;
|
|
1363
1614
|
private processorOwnsParameter;
|
|
1364
1615
|
}
|
|
1365
1616
|
|
|
@@ -1377,57 +1628,395 @@ declare const helpGlobalParameter: ICliGlobalParameterHandler;
|
|
|
1377
1628
|
declare const contextGlobalParameter: ICliGlobalParameterHandler;
|
|
1378
1629
|
|
|
1379
1630
|
/**
|
|
1380
|
-
* A
|
|
1631
|
+
* A terminal writer wrapper that captures "stdout-equivalent" output
|
|
1632
|
+
* (`write`, `writeln`, `writeJson`, `writeObjectsAsTable`, `writeTable`)
|
|
1633
|
+
* while passing everything through to the underlying writer unchanged.
|
|
1381
1634
|
*
|
|
1382
|
-
*
|
|
1383
|
-
*
|
|
1384
|
-
* - `useFactory` : registers a factory function, invoked once on first `get`
|
|
1385
|
-
* - `useClass` : registers a class constructor, instantiated once on first `get`
|
|
1635
|
+
* Diagnostic methods (`writeError`, `writeWarning`, `writeInfo`, `writeSuccess`)
|
|
1636
|
+
* are NOT captured — they are the equivalent of stderr.
|
|
1386
1637
|
*
|
|
1387
|
-
*
|
|
1388
|
-
*
|
|
1638
|
+
* After a command finishes, the executor can retrieve the captured data to use
|
|
1639
|
+
* as implicit pipeline output when the command did not call `process.output()`.
|
|
1640
|
+
*
|
|
1641
|
+
* `muted` (output going into a pipe or a file) captures stdout-equivalent
|
|
1642
|
+
* output without showing it; diagnostics are still shown.
|
|
1389
1643
|
*/
|
|
1390
|
-
declare class
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1644
|
+
declare class CapturingTerminalWriter implements ICliTerminalWriter {
|
|
1645
|
+
private readonly inner;
|
|
1646
|
+
/** Raw text lines captured from write/writeln calls. */
|
|
1647
|
+
private _lines;
|
|
1648
|
+
/** Structured data captured from writeJson calls. */
|
|
1649
|
+
private _jsonValues;
|
|
1650
|
+
/** Structured data captured from writeObjectsAsTable calls. */
|
|
1651
|
+
private _tableObjects;
|
|
1652
|
+
/** Raw text lines captured from writeError/writeWarning calls. */
|
|
1653
|
+
private _stderrLines;
|
|
1654
|
+
/** Number of writeError calls (warnings excluded). */
|
|
1655
|
+
private _errorCount;
|
|
1656
|
+
private readonly muted;
|
|
1657
|
+
constructor(inner: ICliTerminalWriter, options?: {
|
|
1658
|
+
muted?: boolean;
|
|
1659
|
+
});
|
|
1660
|
+
/** Show stdout-equivalent output unless muted. */
|
|
1661
|
+
private show;
|
|
1662
|
+
private captureText;
|
|
1663
|
+
write(text: string): void;
|
|
1664
|
+
writeln(text?: string): void;
|
|
1665
|
+
writeJson(json: any): void;
|
|
1666
|
+
writeObjectsAsTable(objects: any[]): void;
|
|
1667
|
+
writeTable(headers: string[], rows: string[][]): void;
|
|
1668
|
+
writeSuccess(message: string): void;
|
|
1669
|
+
writeInfo(message: string): void;
|
|
1670
|
+
writeWarning(message: string): void;
|
|
1671
|
+
writeError(message: string): void;
|
|
1672
|
+
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
1673
|
+
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
1674
|
+
writeToFile(fileName: string, content: string): void;
|
|
1675
|
+
writeDivider(options?: {
|
|
1676
|
+
color?: CliForegroundColor;
|
|
1677
|
+
length?: number;
|
|
1678
|
+
char?: string;
|
|
1679
|
+
}): void;
|
|
1680
|
+
writeList(items: string[], options?: {
|
|
1681
|
+
ordered?: boolean;
|
|
1682
|
+
prefix?: string;
|
|
1683
|
+
color?: CliForegroundColor;
|
|
1684
|
+
}): void;
|
|
1685
|
+
writeKeyValue(entries: Record<string, string> | [string, string][], options?: {
|
|
1686
|
+
separator?: string;
|
|
1687
|
+
keyColor?: CliForegroundColor;
|
|
1688
|
+
}): void;
|
|
1689
|
+
writeColumns(items: string[], options?: {
|
|
1690
|
+
columns?: number;
|
|
1691
|
+
padding?: number;
|
|
1692
|
+
}): void;
|
|
1693
|
+
writeLink(text: string, url: string): void;
|
|
1694
|
+
writeBox(content: string | string[], options?: {
|
|
1695
|
+
title?: string;
|
|
1696
|
+
borderColor?: CliForegroundColor;
|
|
1697
|
+
padding?: number;
|
|
1698
|
+
}): void;
|
|
1699
|
+
writeIndented(text: string, level?: number): void;
|
|
1700
|
+
/**
|
|
1701
|
+
* Returns true if any stdout-equivalent output was captured.
|
|
1702
|
+
*/
|
|
1703
|
+
hasOutput(): boolean;
|
|
1704
|
+
/**
|
|
1705
|
+
* Returns the captured data in the most useful form:
|
|
1706
|
+
*
|
|
1707
|
+
* 1. If structured JSON was written (via `writeJson`), return the last
|
|
1708
|
+
* JSON value (preserving its original type — object, array, etc.).
|
|
1709
|
+
* 2. If objects were written as a table, return the last array of objects.
|
|
1710
|
+
* 3. Otherwise return the captured text lines joined with newlines,
|
|
1711
|
+
* with ANSI codes stripped and whitespace trimmed.
|
|
1712
|
+
* 4. Returns `undefined` if nothing was captured.
|
|
1713
|
+
*/
|
|
1714
|
+
getCapturedData(): any | undefined;
|
|
1715
|
+
/** Whether the command wrote an error message itself. */
|
|
1716
|
+
hasErrors(): boolean;
|
|
1717
|
+
/**
|
|
1718
|
+
* Returns true if any stderr-equivalent output was captured.
|
|
1719
|
+
*/
|
|
1720
|
+
hasStderr(): boolean;
|
|
1721
|
+
/**
|
|
1722
|
+
* Returns captured stderr text joined with newlines, or undefined if empty.
|
|
1723
|
+
*/
|
|
1724
|
+
getCapturedStderr(): string | undefined;
|
|
1725
|
+
}
|
|
1726
|
+
|
|
1727
|
+
/**
|
|
1728
|
+
* Write stdout data to a file (overwrite mode).
|
|
1729
|
+
*/
|
|
1730
|
+
declare function writeOutputToFile(filePath: string, context: ICliExecutionContext): Promise<void>;
|
|
1731
|
+
/**
|
|
1732
|
+
* Append stdout data to a file.
|
|
1733
|
+
*/
|
|
1734
|
+
declare function appendOutputToFile(filePath: string, context: ICliExecutionContext): Promise<void>;
|
|
1735
|
+
/**
|
|
1736
|
+
* Write stderr data to a file (overwrite mode).
|
|
1737
|
+
*/
|
|
1738
|
+
declare function writeStderrToFile(filePath: string, context: ICliExecutionContext, capturingWriter?: CapturingTerminalWriter): Promise<void>;
|
|
1739
|
+
/**
|
|
1740
|
+
* Append stderr data to a file.
|
|
1741
|
+
*/
|
|
1742
|
+
declare function appendStderrToFile(filePath: string, context: ICliExecutionContext, capturingWriter?: CapturingTerminalWriter): Promise<void>;
|
|
1743
|
+
|
|
1744
|
+
/**
|
|
1745
|
+
* Attempt to execute a file path as a script.
|
|
1746
|
+
* Returns true if the file was found and executed, false otherwise.
|
|
1747
|
+
* Requires the @qodalis/cli-files plugin for filesystem access.
|
|
1748
|
+
*/
|
|
1749
|
+
declare function tryExecuteScript(filePath: string, context: ICliExecutionHost, executeCommand: (command: string, context: ICliExecutionContext) => Promise<void>): Promise<boolean>;
|
|
1750
|
+
/**
|
|
1751
|
+
* Substitute script-local variables ($VAR / ${VAR}) in a string.
|
|
1752
|
+
*/
|
|
1753
|
+
declare function substituteVars(input: string, variables: Record<string, string>): string;
|
|
1754
|
+
/**
|
|
1755
|
+
* Expand `$VAR` and `${VAR}` references using the global environment store, `$?`
|
|
1756
|
+
* to the last exit status, and a leading `~` (alone or as `~/…`) to `$HOME`.
|
|
1757
|
+
* Nothing is expanded inside single-quoted strings (like bash).
|
|
1758
|
+
*/
|
|
1759
|
+
declare function expandEnvironmentVars(command: string, context: ICliExecutionContext, lastExitCode?: number): string;
|
|
1760
|
+
|
|
1761
|
+
/**
|
|
1762
|
+
* Shell-style script runner shared by `sh <file>` / `source` (files plugin)
|
|
1763
|
+
* and `./script.sh` (the executor).
|
|
1764
|
+
*
|
|
1765
|
+
* Supported (a POSIX sh subset):
|
|
1766
|
+
* - one command per line or several separated by `;` (pipes, `&&`, `||`
|
|
1767
|
+
* and redirects are left to the executor)
|
|
1768
|
+
* - `# comments`, blank lines, `\` line continuation
|
|
1769
|
+
* - `set -e` (default) / `set +e`, `VAR=value` (script-scoped), `exit [n]`
|
|
1770
|
+
* - `if cmd; then ...; elif cmd; then ...; else ...; fi`
|
|
1771
|
+
* - `for NAME in words...; do ...; done` (words after `$VAR` and wildcard
|
|
1772
|
+
* expansion; NAME is set for this terminal)
|
|
1773
|
+
* - `while cmd; do ...; done`, `until cmd; do ...; done`
|
|
1774
|
+
* - `break [n]`, `continue [n]`, `! cmd` (negated status)
|
|
1775
|
+
*
|
|
1776
|
+
* Every simple command runs through the executor; its status is
|
|
1777
|
+
* `context.process.exitCode` (0 or undefined = success).
|
|
1778
|
+
*/
|
|
1779
|
+
/** Service token under which the engine provides the runner (for plugins). */
|
|
1780
|
+
declare const ICliScriptRunner_TOKEN: any;
|
|
1781
|
+
interface ICliScriptRunOptions {
|
|
1782
|
+
/** Prefix for error messages (`sh: line 4: ...`). Default `sh`. */
|
|
1783
|
+
name?: string;
|
|
1784
|
+
/** Runs one command line. Default `context.executor.executeCommand`. */
|
|
1785
|
+
executeCommand?: (command: string, context: ICliExecutionContext) => Promise<void>;
|
|
1786
|
+
/** Loop iterations allowed before a `while`/`until` is stopped. Default 10000. */
|
|
1787
|
+
maxLoopIterations?: number;
|
|
1788
|
+
/** Stop at the first failing command (`set -e`). Default true; false for typed lines. */
|
|
1789
|
+
stopOnError?: boolean;
|
|
1790
|
+
}
|
|
1791
|
+
interface ICliScriptRunner {
|
|
1792
|
+
/** Run script `content`; resolves to its exit status. */
|
|
1793
|
+
run(content: string, context: ICliExecutionContext, options?: ICliScriptRunOptions): Promise<number>;
|
|
1794
|
+
}
|
|
1795
|
+
/** The runner as a service value. */
|
|
1796
|
+
declare const cliScriptRunner: ICliScriptRunner;
|
|
1797
|
+
interface CommandNode {
|
|
1798
|
+
type: 'command';
|
|
1799
|
+
text: string;
|
|
1800
|
+
line: number;
|
|
1801
|
+
negate: boolean;
|
|
1802
|
+
}
|
|
1803
|
+
interface IfNode {
|
|
1804
|
+
type: 'if';
|
|
1805
|
+
line: number;
|
|
1806
|
+
branches: {
|
|
1807
|
+
condition: ScriptNode[];
|
|
1808
|
+
body: ScriptNode[];
|
|
1809
|
+
}[];
|
|
1810
|
+
elseBody?: ScriptNode[];
|
|
1811
|
+
}
|
|
1812
|
+
interface ForNode {
|
|
1813
|
+
type: 'for';
|
|
1814
|
+
line: number;
|
|
1815
|
+
name: string;
|
|
1816
|
+
words: string;
|
|
1817
|
+
body: ScriptNode[];
|
|
1818
|
+
}
|
|
1819
|
+
interface WhileNode {
|
|
1820
|
+
type: 'while';
|
|
1821
|
+
line: number;
|
|
1822
|
+
until: boolean;
|
|
1823
|
+
condition: ScriptNode[];
|
|
1824
|
+
body: ScriptNode[];
|
|
1825
|
+
}
|
|
1826
|
+
type ScriptNode = CommandNode | IfNode | ForNode | WhileNode;
|
|
1827
|
+
/** A syntax error found while parsing. */
|
|
1828
|
+
declare class CliScriptSyntaxError extends Error {
|
|
1829
|
+
readonly line: number;
|
|
1830
|
+
readonly detail: string;
|
|
1831
|
+
constructor(line: number, detail: string);
|
|
1832
|
+
}
|
|
1833
|
+
/** Parse script content (throws {@link CliScriptSyntaxError}). */
|
|
1834
|
+
declare function parseScript(content: string): ScriptNode[];
|
|
1835
|
+
/** Split a line into words, removing quotes (empty quoted words are kept). */
|
|
1836
|
+
declare function splitWords(text: string): string[];
|
|
1837
|
+
/**
|
|
1838
|
+
* Run script content with shell control flow. Resolves to the exit status
|
|
1839
|
+
* (also set as the context's process exit code).
|
|
1840
|
+
*/
|
|
1841
|
+
declare function runScript(content: string, context: ICliExecutionContext, options?: ICliScriptRunOptions): Promise<number>;
|
|
1842
|
+
|
|
1843
|
+
/** The file system calls glob expansion needs (`@qodalis/cli-files`). */
|
|
1844
|
+
interface GlobFileSystem {
|
|
1845
|
+
getCurrentDirectory(): string;
|
|
1846
|
+
resolvePath(path: string): string;
|
|
1847
|
+
listDirectory(path: string): {
|
|
1848
|
+
name: string;
|
|
1849
|
+
type: 'file' | 'directory';
|
|
1850
|
+
}[];
|
|
1851
|
+
exists(path: string): boolean;
|
|
1852
|
+
isDirectory(path: string): boolean;
|
|
1853
|
+
}
|
|
1854
|
+
/**
|
|
1855
|
+
* Expand `*`, `?` and `[...]` in unquoted arguments to the matching paths,
|
|
1856
|
+
* as a shell does: `rm *.txt`, `cat docs/*.md`. The command name and flags
|
|
1857
|
+
* are left alone, names starting with `.` match only a pattern that starts
|
|
1858
|
+
* with `.`, and a pattern that matches nothing is kept as typed.
|
|
1859
|
+
* Without the files plugin the command is returned unchanged.
|
|
1860
|
+
*/
|
|
1861
|
+
declare function expandGlobs(command: string, context: ICliExecutionContext): string;
|
|
1862
|
+
/** Paths matching `pattern`, sorted, relative when the pattern is. */
|
|
1863
|
+
declare function matchGlob(fs: GlobFileSystem, pattern: string): string[];
|
|
1864
|
+
/**
|
|
1865
|
+
* Brace expansion, as a shell does before wildcards: `file.{ts,js}` is
|
|
1866
|
+
* `file.ts file.js`, `img{1..3}.png` is `img1.png img2.png img3.png`
|
|
1867
|
+
* (letters too: `{a..c}`). Only unquoted words with a `,` or `..` inside
|
|
1868
|
+
* balanced braces; `${VAR}` and quoted text are left alone. Works without
|
|
1869
|
+
* the files plugin.
|
|
1870
|
+
*/
|
|
1871
|
+
declare function expandBraces(command: string): string;
|
|
1872
|
+
|
|
1873
|
+
/**
|
|
1874
|
+
* Replace `$(command)` and `` `command` `` with the command's output, as a
|
|
1875
|
+
* shell does: `echo "Today: $(date)"`. Not inside single quotes; inside
|
|
1876
|
+
* double quotes yes. Trailing newlines of the output are removed, and the
|
|
1877
|
+
* output is escaped so it is only ever text: inside double quotes `"`, `\`,
|
|
1878
|
+
* `$` and `` ` ``; outside quotes every shell character but spaces (which
|
|
1879
|
+
* still separate words), so quotes, operators, `$`, wildcards and braces in
|
|
1880
|
+
* the output are not interpreted.
|
|
1881
|
+
*/
|
|
1882
|
+
declare function substituteCommands(command: string, run: (inner: string) => Promise<string>): Promise<string>;
|
|
1883
|
+
|
|
1884
|
+
/**
|
|
1885
|
+
* A simple Map-based service container implementing ICliServiceProvider.
|
|
1886
|
+
*
|
|
1887
|
+
* Supports three provider types:
|
|
1888
|
+
* - `useValue` : registers a static value
|
|
1889
|
+
* - `useFactory` : registers a factory function, invoked once on the first `get`
|
|
1890
|
+
* - `useClass` : registers a class constructor, instantiated once on the first `get`
|
|
1891
|
+
*
|
|
1892
|
+
* Factories and classes are created lazily, so their `deps` only have to be
|
|
1893
|
+
* registered by the time the service is first used. Add `transient: true` to
|
|
1894
|
+
* create a new instance on every `get`.
|
|
1895
|
+
*
|
|
1896
|
+
* When `multi: true`, multiple providers for the same token are accumulated
|
|
1897
|
+
* and `getAll()` returns all of them.
|
|
1898
|
+
*
|
|
1899
|
+
* Registering a single token again overrides it; removing that registration
|
|
1900
|
+
* (`remove(token, provider)`, e.g. when a module is unloaded) makes the
|
|
1901
|
+
* previous one active again.
|
|
1902
|
+
*/
|
|
1903
|
+
declare class CliServiceContainer implements ICliServiceProvider {
|
|
1904
|
+
/** Single-value registrations; the last one is active. */
|
|
1905
|
+
private readonly services;
|
|
1906
|
+
/** Multi-provider registrations, in registration order. */
|
|
1907
|
+
private readonly multiServices;
|
|
1908
|
+
/** Tokens that cannot be overwritten by subsequent `set()` calls. */
|
|
1909
|
+
private readonly sealedTokens;
|
|
1910
|
+
/** Stores provider recipes for transient tokens (re-resolved on every get). */
|
|
1911
|
+
private readonly transientRecipes;
|
|
1912
|
+
private disposed;
|
|
1913
|
+
/** Registrations being created, to report dependency cycles. */
|
|
1914
|
+
private readonly resolving;
|
|
1915
|
+
/**
|
|
1916
|
+
* Retrieve a service by its token.
|
|
1917
|
+
* Returns `undefined` when no provider is registered for the token.
|
|
1918
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
1919
|
+
*
|
|
1920
|
+
* @param token The token used to register the service.
|
|
1921
|
+
* @returns The resolved service instance, or `undefined` if not registered.
|
|
1922
|
+
*/
|
|
1923
|
+
get<T>(token: CliToken<T>): T | undefined;
|
|
1924
|
+
get<T>(token: any): T | undefined;
|
|
1925
|
+
/**
|
|
1926
|
+
* Retrieve all registered services for a multi-provider token.
|
|
1927
|
+
* Returns an empty array when no provider is registered for the token.
|
|
1928
|
+
*
|
|
1929
|
+
* @param token The token used to register the service.
|
|
1930
|
+
* @returns Array of all resolved service instances.
|
|
1931
|
+
*/
|
|
1932
|
+
getAll<T>(token: CliToken<T>): T[];
|
|
1933
|
+
getAll<T>(token: any): T[];
|
|
1934
|
+
/**
|
|
1935
|
+
* Retrieve a service by its token, throwing if not registered.
|
|
1936
|
+
* Use this when the service is required and its absence is a programming error.
|
|
1937
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
1938
|
+
*
|
|
1939
|
+
* @param token The token used to register the service.
|
|
1940
|
+
* @returns The resolved service instance.
|
|
1941
|
+
* @throws Error if the token has not been registered.
|
|
1942
|
+
*/
|
|
1943
|
+
getRequired<T>(token: CliToken<T>): T;
|
|
1944
|
+
getRequired<T>(token: any): T;
|
|
1945
|
+
/**
|
|
1946
|
+
* Check whether a service is registered for the given token.
|
|
1947
|
+
*/
|
|
1948
|
+
has(token: any): boolean;
|
|
1949
|
+
/**
|
|
1950
|
+
* Mark a token as sealed so it cannot be overwritten by future `set()` calls.
|
|
1951
|
+
* Only available on the concrete container — not exposed on `ICliServiceProvider`.
|
|
1952
|
+
*/
|
|
1953
|
+
seal(token: any): void;
|
|
1954
|
+
/**
|
|
1955
|
+
* Mark multiple tokens as sealed at once.
|
|
1956
|
+
*/
|
|
1957
|
+
sealAll(tokens: any[]): void;
|
|
1958
|
+
/**
|
|
1959
|
+
* Check whether a token is sealed.
|
|
1960
|
+
*/
|
|
1961
|
+
isSealed(token: any): boolean;
|
|
1962
|
+
/**
|
|
1963
|
+
* Register one or more providers.
|
|
1964
|
+
*
|
|
1965
|
+
* @param definition A single CliProvider or an array of CliProviders.
|
|
1966
|
+
*/
|
|
1967
|
+
set(definition: CliProvider | CliProvider[]): void;
|
|
1968
|
+
/**
|
|
1969
|
+
* Remove a registration. With `provider` (the provider object passed to
|
|
1970
|
+
* `set`, or the registered value), only that registration is removed: for
|
|
1971
|
+
* a single token the previous registration becomes active again, for a
|
|
1972
|
+
* multi token the others remain. Without it, every registration of the
|
|
1973
|
+
* token is removed.
|
|
1974
|
+
*
|
|
1975
|
+
* @throws Error if the token is sealed.
|
|
1976
|
+
* @returns Whether something was removed.
|
|
1977
|
+
*/
|
|
1978
|
+
remove(token: any, provider?: unknown): boolean;
|
|
1979
|
+
/**
|
|
1980
|
+
* Dispose the services the container created (`useFactory` / `useClass`)
|
|
1981
|
+
* that have a `dispose()` method. Values registered with `useValue`
|
|
1982
|
+
* belong to whoever registered them and are not disposed. Registrations
|
|
1983
|
+
* are kept, so late callbacks still find their services. Called when the
|
|
1984
|
+
* engine is destroyed; later calls do nothing.
|
|
1985
|
+
*/
|
|
1986
|
+
dispose(): void;
|
|
1987
|
+
/**
|
|
1410
1988
|
* Returns all registered service tokens (single + multi providers).
|
|
1411
1989
|
*/
|
|
1412
1990
|
getRegisteredTokens(): string[];
|
|
1413
1991
|
/**
|
|
1414
1992
|
* Returns detailed info for each registered service: token name, value type, and multi flag.
|
|
1993
|
+
* Services not created yet are listed as `lazy(Name)` (listing does not create them).
|
|
1415
1994
|
*/
|
|
1416
1995
|
getRegisteredServiceDetails(): {
|
|
1417
1996
|
token: string;
|
|
1418
1997
|
type: string;
|
|
1419
1998
|
multi: boolean;
|
|
1420
1999
|
}[];
|
|
2000
|
+
/**
|
|
2001
|
+
* Convert a token to a human-readable string for diagnostics/errors.
|
|
2002
|
+
*/
|
|
2003
|
+
private tokenToString;
|
|
2004
|
+
private describeRegistration;
|
|
1421
2005
|
/**
|
|
1422
2006
|
* Describe a resolved value for diagnostic display.
|
|
1423
2007
|
*/
|
|
1424
2008
|
private describeValue;
|
|
2009
|
+
/** Whether `registration` is the one `provider` refers to. */
|
|
2010
|
+
private matches;
|
|
1425
2011
|
/**
|
|
1426
2012
|
* Register a single provider.
|
|
1427
2013
|
*/
|
|
1428
2014
|
private registerProvider;
|
|
2015
|
+
/** The value of a registration, created on first use. */
|
|
2016
|
+
private resolve;
|
|
1429
2017
|
/**
|
|
1430
|
-
* Resolve a provider definition to a concrete value
|
|
2018
|
+
* Resolve a provider definition to a concrete value, resolving its `deps`
|
|
2019
|
+
* from the container.
|
|
1431
2020
|
*/
|
|
1432
2021
|
private resolveProvider;
|
|
1433
2022
|
}
|
|
@@ -1465,7 +2054,16 @@ declare class CliTerminalWriter implements ICliTerminalWriter {
|
|
|
1465
2054
|
columns?: number;
|
|
1466
2055
|
padding?: number;
|
|
1467
2056
|
}): void;
|
|
1468
|
-
|
|
2057
|
+
writeLink(text: string, url: string): void;
|
|
2058
|
+
writeBox(content: string | string[], options?: {
|
|
2059
|
+
title?: string;
|
|
2060
|
+
borderColor?: CliForegroundColor;
|
|
2061
|
+
padding?: number;
|
|
2062
|
+
}): void;
|
|
2063
|
+
writeIndented(text: string, level?: number): void;
|
|
2064
|
+
/** One block per row, header names as keys; used when a table cannot fit the terminal. */
|
|
2065
|
+
private writeRecords;
|
|
2066
|
+
writeTable(headers: string[], rows: string[][], options?: CliTableOptions): void;
|
|
1469
2067
|
}
|
|
1470
2068
|
|
|
1471
2069
|
declare class CliClipboard implements ICliClipboard {
|
|
@@ -1528,11 +2126,6 @@ declare class CliTerminalProgressBar implements ICliPercentageProgressBar {
|
|
|
1528
2126
|
complete(): void;
|
|
1529
2127
|
setText(text: string): void;
|
|
1530
2128
|
private updateProgressBar;
|
|
1531
|
-
/**
|
|
1532
|
-
* Returns an ANSI 256-color escape for a position in the progress bar.
|
|
1533
|
-
* Gradient: red (0%) -> yellow (50%) -> green (100%).
|
|
1534
|
-
*/
|
|
1535
|
-
private progressGradientColor;
|
|
1536
2129
|
private clearCurrentLine;
|
|
1537
2130
|
private calcLineCount;
|
|
1538
2131
|
}
|
|
@@ -1542,11 +2135,22 @@ declare class CliTerminalTextAnimator implements ICliTextAnimator {
|
|
|
1542
2135
|
isRunning: boolean;
|
|
1543
2136
|
context?: ICliExecutionContext;
|
|
1544
2137
|
private animationInterval?;
|
|
2138
|
+
/** Characters of the current animation still visible on the line. */
|
|
2139
|
+
private visibleChars;
|
|
2140
|
+
/** Ends the current `showText` promise early (set while it runs). */
|
|
2141
|
+
private finish?;
|
|
1545
2142
|
private text;
|
|
1546
2143
|
private textColor;
|
|
1547
2144
|
constructor(terminal: Terminal);
|
|
1548
2145
|
show(text?: string): void;
|
|
1549
2146
|
showText(text: string, options?: CliTextAnimatorOptions): Promise<void>;
|
|
2147
|
+
/** Cursor position as `row:col`, or `null` when unavailable. */
|
|
2148
|
+
private cursorPosition;
|
|
2149
|
+
/**
|
|
2150
|
+
* Stop the animation, erase the text it wrote and resolve its `showText`
|
|
2151
|
+
* promise. Used when the user starts typing over the greeting.
|
|
2152
|
+
*/
|
|
2153
|
+
cancel(): void;
|
|
1550
2154
|
/**
|
|
1551
2155
|
* Hide the animation and reset the state.
|
|
1552
2156
|
*/
|
|
@@ -1563,6 +2167,101 @@ interface ICliWelcomeModule extends ICliModule {
|
|
|
1563
2167
|
configure(config: CliWelcomeMessageConfig): ICliModule;
|
|
1564
2168
|
}
|
|
1565
2169
|
declare const welcomeModule: ICliWelcomeModule;
|
|
2170
|
+
/**
|
|
2171
|
+
* Animated, time-based greeting on the first prompt. Runs after every other
|
|
2172
|
+
* module's `onAfterBoot` hook (setup and sign-in prompts come first), and
|
|
2173
|
+
* only when the welcome banner was shown.
|
|
2174
|
+
*/
|
|
2175
|
+
declare const greetingModule: ICliModule;
|
|
2176
|
+
|
|
2177
|
+
interface CliBootLogOptions {
|
|
2178
|
+
/** Steps taking at least this long are highlighted as slow. */
|
|
2179
|
+
slowStepMs?: number;
|
|
2180
|
+
/** When boot started (ms since epoch); defaults to now. */
|
|
2181
|
+
startedAt?: number;
|
|
2182
|
+
}
|
|
2183
|
+
/**
|
|
2184
|
+
* Live boot report written to the terminal while the CLI starts: a list of
|
|
2185
|
+
* the steps (terminal, services, servers, modules) with a thin progress bar
|
|
2186
|
+
* and percentage pinned below it.
|
|
2187
|
+
*
|
|
2188
|
+
* Anything else written to the terminal meanwhile is captured and the bar
|
|
2189
|
+
* steps aside for it. When boot is complete the report is cleared so the
|
|
2190
|
+
* regular terminal takes over; warnings, errors and other output (plugin
|
|
2191
|
+
* warnings) are written again in order. First-run setup prompts, answered
|
|
2192
|
+
* while the report is suspended, are cleared with it.
|
|
2193
|
+
*
|
|
2194
|
+
* A disabled log records problems but writes nothing.
|
|
2195
|
+
*/
|
|
2196
|
+
declare class CliBootLog {
|
|
2197
|
+
private readonly terminal;
|
|
2198
|
+
readonly enabled: boolean;
|
|
2199
|
+
private readonly startedAt;
|
|
2200
|
+
private readonly slowStepMs;
|
|
2201
|
+
private readonly problems;
|
|
2202
|
+
private finished;
|
|
2203
|
+
private totalSteps;
|
|
2204
|
+
private completedSteps;
|
|
2205
|
+
private current;
|
|
2206
|
+
private barVisible;
|
|
2207
|
+
private cursorHidden;
|
|
2208
|
+
private suspended;
|
|
2209
|
+
private startRow;
|
|
2210
|
+
/** Output written by others during boot, replayed after the report is cleared. */
|
|
2211
|
+
private readonly captured;
|
|
2212
|
+
private originalWrite?;
|
|
2213
|
+
private originalWriteln?;
|
|
2214
|
+
private redrawScheduled;
|
|
2215
|
+
/** The last setup output did not end its line (cursor after a prompt). */
|
|
2216
|
+
private promptOpen;
|
|
2217
|
+
constructor(terminal: Terminal | undefined, enabled: boolean, options?: CliBootLogOptions);
|
|
2218
|
+
/** Milliseconds since boot started. */
|
|
2219
|
+
get elapsedMs(): number;
|
|
2220
|
+
/** Whether `finish()` was called; later entries are ignored. */
|
|
2221
|
+
get isFinished(): boolean;
|
|
2222
|
+
/** Completed share of the planned steps, 0–100. */
|
|
2223
|
+
get percent(): number;
|
|
2224
|
+
/** Announce `count` more steps that will each be completed with `completeStep`. */
|
|
2225
|
+
addSteps(count: number): void;
|
|
2226
|
+
/** Name what is being set up now (shown next to the bar). */
|
|
2227
|
+
setCurrent(text: string): void;
|
|
2228
|
+
/** Mark one planned step as done (successfully or not). */
|
|
2229
|
+
completeStep(): void;
|
|
2230
|
+
/**
|
|
2231
|
+
* Step aside for interactive output (e.g. a module's first-run setup
|
|
2232
|
+
* prompt): remove the bar and show the cursor until `resume()`.
|
|
2233
|
+
*/
|
|
2234
|
+
suspend(): void;
|
|
2235
|
+
/** Bring the bar back after `suspend()`. */
|
|
2236
|
+
resume(): void;
|
|
2237
|
+
info(text: string): void;
|
|
2238
|
+
/** A completed step, optionally with how long it took. */
|
|
2239
|
+
ok(text: string, durationMs?: number): void;
|
|
2240
|
+
warn(text: string): void;
|
|
2241
|
+
error(text: string): void;
|
|
2242
|
+
/**
|
|
2243
|
+
* Write the summary line, then hand the screen over to the terminal:
|
|
2244
|
+
* clear the report (unless `keep`), then write warnings, errors and the
|
|
2245
|
+
* output captured during boot again. The report is not cleared when the
|
|
2246
|
+
* terminal already held something before boot started.
|
|
2247
|
+
*/
|
|
2248
|
+
finish(summary: string, keep?: boolean): Promise<void>;
|
|
2249
|
+
private write;
|
|
2250
|
+
/** Redraw the bar on the line below the list (the cursor stays on it). */
|
|
2251
|
+
private drawBar;
|
|
2252
|
+
/** First output: remember where the report starts and capture other writes. */
|
|
2253
|
+
private begin;
|
|
2254
|
+
private stopCapture;
|
|
2255
|
+
/** Someone else writes during boot: move the bar aside and keep a copy. */
|
|
2256
|
+
private onExternalWrite;
|
|
2257
|
+
/** Write without being captured. */
|
|
2258
|
+
private out;
|
|
2259
|
+
private hideBar;
|
|
2260
|
+
private format;
|
|
2261
|
+
private absoluteRow;
|
|
2262
|
+
/** Resolve once xterm has parsed everything written so far. */
|
|
2263
|
+
private flush;
|
|
2264
|
+
}
|
|
1566
2265
|
|
|
1567
2266
|
declare class CliBoot {
|
|
1568
2267
|
private readonly registry;
|
|
@@ -1571,13 +2270,61 @@ declare class CliBoot {
|
|
|
1571
2270
|
private initializing;
|
|
1572
2271
|
private readonly moduleRegistry;
|
|
1573
2272
|
private readonly bootedModules;
|
|
2273
|
+
private readonly initializedProcessors;
|
|
2274
|
+
/** Services and guards each module registered, removed when it is unloaded. */
|
|
2275
|
+
private readonly moduleProviders;
|
|
2276
|
+
/** Context modules were booted with (passed to `onDestroy` on unload). */
|
|
2277
|
+
private context?;
|
|
2278
|
+
/** Boot report of the startup boot. */
|
|
2279
|
+
private bootLogRef?;
|
|
2280
|
+
/** The boot report while startup is still in progress, else `undefined`. */
|
|
2281
|
+
private get bootLog();
|
|
1574
2282
|
constructor(registry: ICliCommandProcessorRegistry, services: ICliServiceProvider);
|
|
1575
2283
|
/**
|
|
1576
2284
|
* Get the module registry for external access.
|
|
1577
2285
|
*/
|
|
1578
2286
|
getModuleRegistry(): CliModuleRegistry;
|
|
1579
|
-
boot(context: CliExecutionContext, modules: ICliModule[]): Promise<void>;
|
|
2287
|
+
boot(context: CliExecutionContext, modules: ICliModule[], bootLog?: CliBootLog): Promise<void>;
|
|
2288
|
+
private bootAll;
|
|
2289
|
+
/**
|
|
2290
|
+
* Boot one module: declarations (services, guards, permissions,
|
|
2291
|
+
* translations), lifecycle (`onInit`, first-run `onSetup`), then its
|
|
2292
|
+
* commands. Modules already booted or with missing dependencies are skipped.
|
|
2293
|
+
*/
|
|
1580
2294
|
private bootModule;
|
|
2295
|
+
private dependenciesLoaded;
|
|
2296
|
+
/** Services, guards, permissions and translations the module declares. */
|
|
2297
|
+
private registerDeclarations;
|
|
2298
|
+
/** `onInit` runs before the module's commands are registered. */
|
|
2299
|
+
private runOnInit;
|
|
2300
|
+
/** `onSetup` runs once per browser (first-run flow), until it succeeds. */
|
|
2301
|
+
private runFirstSetup;
|
|
2302
|
+
/** Register and initialize the module's commands; returns how many. */
|
|
2303
|
+
private registerCommands;
|
|
2304
|
+
/** One boot-log line per module that does something at boot. */
|
|
2305
|
+
private reportModule;
|
|
2306
|
+
/**
|
|
2307
|
+
* Unload a module (`pkg remove`, or before `pkg update` boots the new
|
|
2308
|
+
* version): its commands, guards and permissions are removed at once,
|
|
2309
|
+
* then `onDestroy` runs, then its services are removed (so `onDestroy`
|
|
2310
|
+
* can still use them). Services are removed by registration, so a newer
|
|
2311
|
+
* version registered meanwhile keeps its own.
|
|
2312
|
+
*/
|
|
2313
|
+
private unloadModule;
|
|
2314
|
+
private removeProviders;
|
|
2315
|
+
/** Publish on the event bus; never lets the bus break booting. */
|
|
2316
|
+
private emitEvent;
|
|
2317
|
+
/** Boot warning: into the boot log when it is shown, else the terminal. */
|
|
2318
|
+
private warn;
|
|
2319
|
+
/** Boot error: into the boot log when it is shown, else the terminal. */
|
|
2320
|
+
private fail;
|
|
2321
|
+
/**
|
|
2322
|
+
* Sub-processors of an `extendsProcessor` processor are merged into the
|
|
2323
|
+
* processor it extends, so they belong to that one: re-parent them so they
|
|
2324
|
+
* inherit its access rules (`requiredPermissions` etc.) and help/root
|
|
2325
|
+
* lookups resolve to the registered processor.
|
|
2326
|
+
*/
|
|
2327
|
+
private adoptMergedSubProcessors;
|
|
1581
2328
|
private buildCoreModule;
|
|
1582
2329
|
/**
|
|
1583
2330
|
* Topologically sort modules by their dependencies using DFS.
|
|
@@ -1641,6 +2388,13 @@ declare class ScriptLoaderService {
|
|
|
1641
2388
|
content?: string;
|
|
1642
2389
|
error?: any;
|
|
1643
2390
|
}>;
|
|
2391
|
+
/**
|
|
2392
|
+
* Inject an inline script into the page.
|
|
2393
|
+
*
|
|
2394
|
+
* **Security:** This runs `code` in the host page context with full
|
|
2395
|
+
* DOM access. Only call with trusted content (e.g. verified UMD bundles
|
|
2396
|
+
* loaded via the package manager). Never pass user-supplied strings.
|
|
2397
|
+
*/
|
|
1644
2398
|
injectBodyScript(code: string): void;
|
|
1645
2399
|
/**
|
|
1646
2400
|
* Returns CDN URLs for a given npm package path.
|
|
@@ -1671,14 +2425,18 @@ declare class CliPackageManagerService {
|
|
|
1671
2425
|
private readonly storageKey;
|
|
1672
2426
|
QODALIS_COMMAND_PREFIX: string;
|
|
1673
2427
|
private store;
|
|
2428
|
+
/** In-memory cache; `null` means "not yet loaded from storage". */
|
|
2429
|
+
private cache;
|
|
2430
|
+
/** Whether the one-time localStorage migration has been checked. */
|
|
2431
|
+
private migrationDone;
|
|
1674
2432
|
constructor();
|
|
1675
2433
|
/**
|
|
1676
2434
|
* Set the key-value store instance for persistence.
|
|
1677
2435
|
*/
|
|
1678
2436
|
setStore(store: ICliKeyValueStore): void;
|
|
1679
2437
|
/**
|
|
1680
|
-
* Retrieves the list of packages
|
|
1681
|
-
*
|
|
2438
|
+
* Retrieves the list of packages.
|
|
2439
|
+
* Uses an in-memory cache after the first load.
|
|
1682
2440
|
*/
|
|
1683
2441
|
getPackages(): Promise<Package[]>;
|
|
1684
2442
|
/**
|
|
@@ -1709,90 +2467,31 @@ declare class CliDefaultPingServerService implements ICliPingServerService {
|
|
|
1709
2467
|
}
|
|
1710
2468
|
|
|
1711
2469
|
/**
|
|
1712
|
-
*
|
|
1713
|
-
*
|
|
1714
|
-
* while passing everything through to the underlying writer unchanged.
|
|
1715
|
-
*
|
|
1716
|
-
* Diagnostic methods (`writeError`, `writeWarning`, `writeInfo`, `writeSuccess`)
|
|
1717
|
-
* are NOT captured — they are the equivalent of stderr.
|
|
1718
|
-
*
|
|
1719
|
-
* After a command finishes, the executor can retrieve the captured data to use
|
|
1720
|
-
* as implicit pipeline output when the command did not call `process.output()`.
|
|
2470
|
+
* Factory-based input reader. Creates the appropriate input mode
|
|
2471
|
+
* and pushes it onto the mode stack for each request.
|
|
1721
2472
|
*/
|
|
1722
|
-
declare class
|
|
1723
|
-
private readonly
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
writeln(text?: string): void;
|
|
1735
|
-
writeJson(json: any): void;
|
|
1736
|
-
writeObjectsAsTable(objects: any[]): void;
|
|
1737
|
-
writeTable(headers: string[], rows: string[][]): void;
|
|
1738
|
-
writeSuccess(message: string): void;
|
|
1739
|
-
writeInfo(message: string): void;
|
|
1740
|
-
writeWarning(message: string): void;
|
|
1741
|
-
writeError(message: string): void;
|
|
1742
|
-
wrapInColor(text: string, color: CliForegroundColor): string;
|
|
1743
|
-
wrapInBackgroundColor(text: string, color: CliBackgroundColor): string;
|
|
1744
|
-
writeToFile(fileName: string, content: string): void;
|
|
1745
|
-
writeDivider(options?: {
|
|
1746
|
-
color?: CliForegroundColor;
|
|
1747
|
-
length?: number;
|
|
1748
|
-
char?: string;
|
|
1749
|
-
}): void;
|
|
1750
|
-
writeList(items: string[], options?: {
|
|
1751
|
-
ordered?: boolean;
|
|
1752
|
-
prefix?: string;
|
|
1753
|
-
color?: CliForegroundColor;
|
|
1754
|
-
}): void;
|
|
1755
|
-
writeKeyValue(entries: Record<string, string> | [string, string][], options?: {
|
|
1756
|
-
separator?: string;
|
|
1757
|
-
keyColor?: CliForegroundColor;
|
|
1758
|
-
}): void;
|
|
1759
|
-
writeColumns(items: string[], options?: {
|
|
1760
|
-
columns?: number;
|
|
1761
|
-
padding?: number;
|
|
1762
|
-
}): void;
|
|
1763
|
-
/**
|
|
1764
|
-
* Returns true if any stdout-equivalent output was captured.
|
|
1765
|
-
*/
|
|
1766
|
-
hasOutput(): boolean;
|
|
1767
|
-
/**
|
|
1768
|
-
* Returns the captured data in the most useful form:
|
|
1769
|
-
*
|
|
1770
|
-
* 1. If structured JSON was written (via `writeJson`), return the last
|
|
1771
|
-
* JSON value (preserving its original type — object, array, etc.).
|
|
1772
|
-
* 2. If objects were written as a table, return the last array of objects.
|
|
1773
|
-
* 3. Otherwise return the captured text lines joined with newlines,
|
|
1774
|
-
* with ANSI codes stripped and whitespace trimmed.
|
|
1775
|
-
* 4. Returns `undefined` if nothing was captured.
|
|
1776
|
-
*/
|
|
1777
|
-
getCapturedData(): any | undefined;
|
|
1778
|
-
/**
|
|
1779
|
-
* Returns true if any stderr-equivalent output was captured.
|
|
1780
|
-
*/
|
|
1781
|
-
hasStderr(): boolean;
|
|
1782
|
-
/**
|
|
1783
|
-
* Returns captured stderr text joined with newlines, or undefined if empty.
|
|
1784
|
-
*/
|
|
1785
|
-
getCapturedStderr(): string | undefined;
|
|
2473
|
+
declare class CliInputReader implements ICliInputReader {
|
|
2474
|
+
private readonly host;
|
|
2475
|
+
constructor(host: InputModeHost);
|
|
2476
|
+
readLine(prompt: string, options?: CliLineOptions): Promise<string | null>;
|
|
2477
|
+
readPassword(prompt: string): Promise<string | null>;
|
|
2478
|
+
readConfirm(prompt: string, defaultValue?: boolean): Promise<boolean | null>;
|
|
2479
|
+
readSelect(prompt: string, options: CliSelectOption[], selectOptions?: CliSelectOptions): Promise<string | null>;
|
|
2480
|
+
readSelectInline(prompt: string, options: CliSelectOption[], selectOptions?: CliSelectOptions): Promise<string | null>;
|
|
2481
|
+
readMultiSelect(prompt: string, options: CliMultiSelectOption[], selectOptions?: CliMultiSelectOptions): Promise<string[] | null>;
|
|
2482
|
+
readNumber(prompt: string, options?: CliNumberOptions): Promise<number | null>;
|
|
2483
|
+
readDate(prompt: string, options?: CliDateOptions): Promise<string | null>;
|
|
2484
|
+
readFile(prompt: string, options?: CliFilePickerOptions): Promise<CliFileResult[] | null>;
|
|
1786
2485
|
}
|
|
1787
2486
|
|
|
1788
|
-
declare const CliProcessRegistry_TOKEN
|
|
2487
|
+
declare const CliProcessRegistry_TOKEN: any;
|
|
1789
2488
|
declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
1790
2489
|
private nextPid;
|
|
1791
2490
|
private processes;
|
|
1792
2491
|
private _currentPid;
|
|
1793
2492
|
private maxHistory;
|
|
1794
2493
|
get currentPid(): number | undefined;
|
|
1795
|
-
register(command: string): {
|
|
2494
|
+
register(command: string, options?: ICliProcessRegisterOptions): {
|
|
1796
2495
|
pid: number;
|
|
1797
2496
|
abortController: AbortController;
|
|
1798
2497
|
};
|
|
@@ -1804,7 +2503,7 @@ declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
|
1804
2503
|
}
|
|
1805
2504
|
|
|
1806
2505
|
/**
|
|
1807
|
-
*
|
|
2506
|
+
* Environment variables for the CLI.
|
|
1808
2507
|
*
|
|
1809
2508
|
* Variables set here are available to all commands via `$VAR` / `${VAR}`
|
|
1810
2509
|
* substitution in the executor. Commands can also read/write the store
|
|
@@ -1813,29 +2512,106 @@ declare class CliProcessRegistry implements ICliProcessRegistry {
|
|
|
1813
2512
|
interface ICliEnvironment {
|
|
1814
2513
|
/** Get a variable value (undefined if not set). */
|
|
1815
2514
|
get(name: string): string | undefined;
|
|
1816
|
-
/**
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
2515
|
+
/**
|
|
2516
|
+
* Set a variable: for the signed-in user (`'user'`, the default, saved),
|
|
2517
|
+
* for everyone (`'global'`, saved) or for this terminal only (`'session'`).
|
|
2518
|
+
*/
|
|
2519
|
+
set(name: string, value: string, scope?: CliEnvironmentScope): void;
|
|
2520
|
+
/**
|
|
2521
|
+
* Remove a variable. Without a scope it is removed for this terminal and
|
|
2522
|
+
* the user (and hidden when it still comes from a shared or built-in
|
|
2523
|
+
* value); `'global'` removes the shared value.
|
|
2524
|
+
*/
|
|
2525
|
+
unset(name: string, scope?: CliEnvironmentScope): void;
|
|
1820
2526
|
/** Get all variables as a record. */
|
|
1821
2527
|
getAll(): Record<string, string>;
|
|
1822
2528
|
/** Check if a variable is set. */
|
|
1823
2529
|
has(name: string): boolean;
|
|
1824
|
-
|
|
1825
|
-
|
|
2530
|
+
/** Where the current value of `name` comes from. */
|
|
2531
|
+
scopeOf?(name: string): CliEnvironmentSource | undefined;
|
|
2532
|
+
}
|
|
2533
|
+
declare const ICliEnvironment_TOKEN: any;
|
|
2534
|
+
/** Where a variable is set: this terminal, the signed-in user, or everyone. */
|
|
2535
|
+
type CliEnvironmentScope = 'session' | 'user' | 'global';
|
|
2536
|
+
/** Where a value comes from: a scope, or computed / built in (`HOME`, `SHELL`, …). */
|
|
2537
|
+
type CliEnvironmentSource = CliEnvironmentScope | 'builtin';
|
|
2538
|
+
/** What one user (or the signed-out session, key '') changed: values set and defaults removed. */
|
|
2539
|
+
interface CliEnvironmentProfile {
|
|
2540
|
+
vars: Record<string, string>;
|
|
2541
|
+
unset: string[];
|
|
2542
|
+
}
|
|
2543
|
+
/** Saved environment: one profile per user name ('' when nobody is signed in). */
|
|
2544
|
+
type CliEnvironmentSnapshot = Record<string, CliEnvironmentProfile>;
|
|
2545
|
+
/**
|
|
2546
|
+
* One saved change, applied by the host to the latest saved state (so two
|
|
2547
|
+
* tabs changing different variables never overwrite each other).
|
|
2548
|
+
*/
|
|
2549
|
+
type CliEnvironmentChange = {
|
|
2550
|
+
scope: 'user';
|
|
2551
|
+
profile: string;
|
|
2552
|
+
name: string;
|
|
2553
|
+
value: string;
|
|
2554
|
+
} | {
|
|
2555
|
+
scope: 'user';
|
|
2556
|
+
profile: string;
|
|
2557
|
+
name: string;
|
|
2558
|
+
unset: true;
|
|
2559
|
+
hide: boolean;
|
|
2560
|
+
} | {
|
|
2561
|
+
scope: 'global';
|
|
2562
|
+
name: string;
|
|
2563
|
+
value: string;
|
|
2564
|
+
} | {
|
|
2565
|
+
scope: 'global';
|
|
2566
|
+
name: string;
|
|
2567
|
+
unset: true;
|
|
2568
|
+
};
|
|
1826
2569
|
/**
|
|
1827
2570
|
* Default in-memory implementation.
|
|
1828
|
-
*
|
|
2571
|
+
*
|
|
2572
|
+
* A variable resolves, in order, from this terminal's variables
|
|
2573
|
+
* (`NAME=value`), the current user's own (`export`), the shared ones
|
|
2574
|
+
* (`export --global`), then bound live values (USER, HOME, PWD follow the
|
|
2575
|
+
* session and directory), then the standard variables seeded on
|
|
2576
|
+
* construction. Each user has a separate set, so `su`/`login` switch
|
|
2577
|
+
* environments, and `onChange` lets the host save each change.
|
|
1829
2578
|
*/
|
|
1830
2579
|
declare class CliEnvironment implements ICliEnvironment {
|
|
1831
|
-
private readonly
|
|
2580
|
+
private readonly defaults;
|
|
2581
|
+
/** Variables computed on read; a user's own value wins over them. */
|
|
2582
|
+
private readonly bound;
|
|
2583
|
+
private readonly profiles;
|
|
2584
|
+
private readonly global;
|
|
2585
|
+
private readonly session;
|
|
2586
|
+
private profileKey;
|
|
2587
|
+
/** Called after every saved change (user or global), to persist it. */
|
|
2588
|
+
onChange?: (change: CliEnvironmentChange) => void;
|
|
1832
2589
|
constructor();
|
|
2590
|
+
/** Compute a variable on every read; the seeded value is the fallback while it returns nothing. */
|
|
2591
|
+
bind(name: string, resolver: () => string | null | undefined): void;
|
|
2592
|
+
/** Pick whose changes apply (the signed-in user's name, '' when signed out). */
|
|
2593
|
+
setProfileResolver(resolver: () => string | null | undefined): void;
|
|
2594
|
+
/** Restore saved profiles and shared variables (replaces the saved ones in memory). */
|
|
2595
|
+
load(snapshot: CliEnvironmentSnapshot | undefined, global?: Record<string, string>): void;
|
|
2596
|
+
snapshot(): CliEnvironmentSnapshot;
|
|
2597
|
+
/** The shared variables. */
|
|
2598
|
+
globals(): Record<string, string>;
|
|
1833
2599
|
get(name: string): string | undefined;
|
|
1834
|
-
|
|
1835
|
-
|
|
2600
|
+
scopeOf(name: string): CliEnvironmentSource | undefined;
|
|
2601
|
+
set(name: string, value: string, scope?: CliEnvironmentScope): void;
|
|
2602
|
+
unset(name: string, scope?: CliEnvironmentScope): void;
|
|
1836
2603
|
getAll(): Record<string, string>;
|
|
1837
2604
|
has(name: string): boolean;
|
|
1838
|
-
|
|
2605
|
+
private profileOf;
|
|
2606
|
+
}
|
|
2607
|
+
/** Apply one change to saved state (the host does this under the cross-tab lock). */
|
|
2608
|
+
declare function applyEnvironmentChange(state: {
|
|
2609
|
+
profiles?: CliEnvironmentSnapshot;
|
|
2610
|
+
global?: Record<string, string>;
|
|
2611
|
+
}, change: CliEnvironmentChange): {
|
|
2612
|
+
profiles: CliEnvironmentSnapshot;
|
|
2613
|
+
global: Record<string, string>;
|
|
2614
|
+
};
|
|
1839
2615
|
|
|
1840
2616
|
declare class CliDragDropService implements ICliDragDropService {
|
|
1841
2617
|
private readonly _container;
|
|
@@ -1847,6 +2623,58 @@ declare class CliDragDropService implements ICliDragDropService {
|
|
|
1847
2623
|
destroy(): void;
|
|
1848
2624
|
}
|
|
1849
2625
|
|
|
2626
|
+
/**
|
|
2627
|
+
* Default HTTP client implementation.
|
|
2628
|
+
*
|
|
2629
|
+
* Wraps the global `fetch()` and automatically merges an abort signal
|
|
2630
|
+
* so that in-flight requests are cancelled when the user presses Ctrl+C.
|
|
2631
|
+
*
|
|
2632
|
+
* Created per-command by the executor — each instance is bound to the
|
|
2633
|
+
* command's own AbortSignal.
|
|
2634
|
+
*/
|
|
2635
|
+
declare class CliHttpClient implements ICliHttpClient {
|
|
2636
|
+
private readonly signal?;
|
|
2637
|
+
constructor(signal?: AbortSignal | undefined);
|
|
2638
|
+
fetch(url: string, init?: RequestInit): Promise<Response>;
|
|
2639
|
+
get<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2640
|
+
post<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2641
|
+
put<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2642
|
+
patch<T = any>(url: string, body?: any, options?: CliHttpRequestOptions): Promise<T>;
|
|
2643
|
+
delete<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2644
|
+
head(url: string, options?: CliHttpRequestOptions): Promise<Response>;
|
|
2645
|
+
options<T = any>(url: string, options?: CliHttpRequestOptions): Promise<T>;
|
|
2646
|
+
private jsonRequest;
|
|
2647
|
+
private isRawBody;
|
|
2648
|
+
/**
|
|
2649
|
+
* Merge the command signal with any additional signals (caller, timeout).
|
|
2650
|
+
* Uses AbortSignal.any() when available, falls back to a manual composite
|
|
2651
|
+
* controller for older browsers (pre-Chrome 116 / Safari 17.4).
|
|
2652
|
+
*/
|
|
2653
|
+
private mergeSignal;
|
|
2654
|
+
}
|
|
2655
|
+
|
|
2656
|
+
declare class CliNotifier implements ICliNotifier {
|
|
2657
|
+
private _current;
|
|
2658
|
+
private readonly _change$;
|
|
2659
|
+
readonly change$: rxjs.Observable<any>;
|
|
2660
|
+
get current(): CliNotification | undefined;
|
|
2661
|
+
info(message: string): void;
|
|
2662
|
+
success(message: string): void;
|
|
2663
|
+
warn(message: string): void;
|
|
2664
|
+
error(message: string): void;
|
|
2665
|
+
clear(): void;
|
|
2666
|
+
private set;
|
|
2667
|
+
}
|
|
2668
|
+
|
|
2669
|
+
/** Default {@link ICliPermissionRegistry}: permissions declared by modules. */
|
|
2670
|
+
declare class CliPermissionRegistry implements ICliPermissionRegistry {
|
|
2671
|
+
private readonly definitions;
|
|
2672
|
+
register(definitions: CliPermissionDefinition[], module?: string): void;
|
|
2673
|
+
unregister(module: string): void;
|
|
2674
|
+
list(): CliPermissionDefinition[];
|
|
2675
|
+
get(name: string): CliPermissionDefinition | undefined;
|
|
2676
|
+
}
|
|
2677
|
+
|
|
1850
2678
|
declare class OverlayAddon implements ITerminalAddon {
|
|
1851
2679
|
private terminal;
|
|
1852
2680
|
private overlayNode;
|
|
@@ -1903,23 +2731,125 @@ declare class CliKeyValueStore implements ICliKeyValueStore {
|
|
|
1903
2731
|
declare class CliStateStore implements ICliStateStore {
|
|
1904
2732
|
private readonly services;
|
|
1905
2733
|
readonly name: string;
|
|
1906
|
-
private readonly initialState;
|
|
1907
2734
|
private state$;
|
|
1908
|
-
|
|
1909
|
-
|
|
2735
|
+
/** Signed-in user, for `scope: 'user'` stores. */
|
|
2736
|
+
private user?;
|
|
2737
|
+
private initialState;
|
|
2738
|
+
private options;
|
|
2739
|
+
/** The first load from storage (see `initialize`). */
|
|
2740
|
+
private loading?;
|
|
2741
|
+
private loaded;
|
|
2742
|
+
/** Keys changed before the saved state was loaded: they win over it. */
|
|
2743
|
+
private readonly changedBeforeLoad;
|
|
2744
|
+
/** Keys changed since the last save (only these are written). */
|
|
2745
|
+
private readonly unsaved;
|
|
2746
|
+
/** When each key was last changed here (`updateState`), to tell local edits from synced ones. */
|
|
2747
|
+
private readonly editedAt;
|
|
2748
|
+
private edits;
|
|
2749
|
+
/** `reset()` since the last save: the whole state is written. */
|
|
2750
|
+
private replaceOnSave;
|
|
2751
|
+
/**
|
|
2752
|
+
* Each key as last loaded, saved or received (JSON), to also find keys
|
|
2753
|
+
* changed in place without `updateState`.
|
|
2754
|
+
*/
|
|
2755
|
+
private baseline;
|
|
2756
|
+
private persistScheduled;
|
|
2757
|
+
/**
|
|
2758
|
+
* Called after the state was saved (set by the store manager to share it
|
|
2759
|
+
* with other tabs).
|
|
2760
|
+
*/
|
|
2761
|
+
onPersisted?: (storageKey: string, state: CliState) => void;
|
|
2762
|
+
constructor(services: ICliServiceProvider, name: string, initialState: CliState, options?: CliStateStoreOptions);
|
|
2763
|
+
/** Key the state is saved under. */
|
|
2764
|
+
get key(): string;
|
|
2765
|
+
/**
|
|
2766
|
+
* Saved per store, or per signed-in user for `scope: 'user'` (signed
|
|
2767
|
+
* out, the state is shared like a global store).
|
|
2768
|
+
*/
|
|
2769
|
+
private get storageKey();
|
|
2770
|
+
/**
|
|
2771
|
+
* The signed-in user changed: a `scope: 'user'` store switches to that
|
|
2772
|
+
* user's saved state (unsaved changes of the previous user are dropped,
|
|
2773
|
+
* so save before switching users).
|
|
2774
|
+
*/
|
|
2775
|
+
setUser(user: string | undefined): void;
|
|
2776
|
+
/** Whether changes saved by other tabs are applied to this store. */
|
|
2777
|
+
get syncAcrossTabs(): boolean;
|
|
2778
|
+
/** A session store lives in this terminal only and is never saved. */
|
|
2779
|
+
private get isSession();
|
|
1910
2780
|
getState<T extends CliState = CliState>(): T;
|
|
1911
2781
|
updateState(newState: Partial<CliState>): void;
|
|
1912
2782
|
select<K>(selector: (state: CliState) => K): Observable<K>;
|
|
1913
2783
|
subscribe(callback: (state: CliState) => void): Subscription;
|
|
1914
2784
|
reset(): void;
|
|
2785
|
+
/**
|
|
2786
|
+
* Save the state. The saved state is loaded first, so saving before the
|
|
2787
|
+
* store was loaded never replaces data with the initial state.
|
|
2788
|
+
*/
|
|
1915
2789
|
persist(): Promise<void>;
|
|
2790
|
+
/**
|
|
2791
|
+
* Change the state from its latest saved value and save it, atomically:
|
|
2792
|
+
* under the cross-tab lock, `change` gets the state as saved (plus this
|
|
2793
|
+
* terminal's unsaved changes) and its result is merged and written. Two
|
|
2794
|
+
* terminals updating the same key never lose each other's change, e.g.
|
|
2795
|
+
* both adding an item to a list. Without storage (or for a session
|
|
2796
|
+
* store) it is a plain `updateState`.
|
|
2797
|
+
*/
|
|
2798
|
+
update(change: (state: CliState) => Partial<CliState>): Promise<void>;
|
|
1916
2799
|
initialize(): Promise<void>;
|
|
2800
|
+
reload(): Promise<void>;
|
|
2801
|
+
/**
|
|
2802
|
+
* Add defaults for keys the store does not have yet (when it was first
|
|
2803
|
+
* created without them, e.g. read before its command registered).
|
|
2804
|
+
*/
|
|
2805
|
+
applyDefaults(defaults: CliState): void;
|
|
2806
|
+
/** Merge store options (later options win). */
|
|
2807
|
+
setOptions(options: CliStateStoreOptions): void;
|
|
2808
|
+
/**
|
|
2809
|
+
* State saved by another tab or terminal: apply it without saving again,
|
|
2810
|
+
* keeping the keys changed here and not saved yet.
|
|
2811
|
+
*/
|
|
2812
|
+
applySaved(state: CliState): void;
|
|
2813
|
+
/**
|
|
2814
|
+
* Another tab or terminal saved this store: apply what is saved now.
|
|
2815
|
+
* Messages can arrive out of order (one sent before this terminal's own
|
|
2816
|
+
* save can arrive after it), so storage, not the message, is the truth.
|
|
2817
|
+
* Reads are chained so the last one applied is the latest.
|
|
2818
|
+
*/
|
|
2819
|
+
refreshFromStorage(fallback?: CliState): Promise<void>;
|
|
2820
|
+
private refreshing;
|
|
2821
|
+
/**
|
|
2822
|
+
* Complete the BehaviorSubject so all subscribers are notified
|
|
2823
|
+
* and no further emissions occur. Called during engine teardown.
|
|
2824
|
+
*/
|
|
2825
|
+
dispose(): void;
|
|
2826
|
+
private load;
|
|
2827
|
+
/**
|
|
2828
|
+
* Save the keys changed here, merged into the saved state (the whole
|
|
2829
|
+
* state after `reset()` or a migration). Runs under a lock shared by all
|
|
2830
|
+
* tabs, so two terminals saving at once do not lose each other's keys.
|
|
2831
|
+
* Keys others saved meanwhile are applied here.
|
|
2832
|
+
*/
|
|
2833
|
+
private write;
|
|
2834
|
+
/** Keys changed here since the last load, save or received state. */
|
|
2835
|
+
private changedKeys;
|
|
2836
|
+
private setBaseline;
|
|
2837
|
+
private pick;
|
|
2838
|
+
private get versionKey();
|
|
2839
|
+
/** With `autoPersist`, save once after the changes of this tick. */
|
|
2840
|
+
private schedulePersist;
|
|
1917
2841
|
}
|
|
1918
2842
|
|
|
1919
2843
|
interface CliEngineOptions extends CliOptions {
|
|
1920
2844
|
terminalOptions?: Partial<ITerminalOptions & ITerminalInitOnlyOptions>;
|
|
1921
2845
|
/** Optional snapshot to restore on start() */
|
|
1922
2846
|
snapshot?: CliEngineSnapshot;
|
|
2847
|
+
/**
|
|
2848
|
+
* Explicit URL of `qodalis_cli_wasm_bg.wasm` (optional accelerator). When
|
|
2849
|
+
* omitted it is looked up next to the page (`document.baseURI`), then at
|
|
2850
|
+
* `/assets/wasm/` and `/wasm/`; the CLI works without it.
|
|
2851
|
+
*/
|
|
2852
|
+
wasmUrl?: string;
|
|
1923
2853
|
}
|
|
1924
2854
|
declare class CliEngine {
|
|
1925
2855
|
private readonly container;
|
|
@@ -1938,6 +2868,11 @@ declare class CliEngine {
|
|
|
1938
2868
|
private resizeScheduled;
|
|
1939
2869
|
private bootService?;
|
|
1940
2870
|
private dragDropService?;
|
|
2871
|
+
private _startedAt?;
|
|
2872
|
+
private terminalOptions;
|
|
2873
|
+
private _isBooted;
|
|
2874
|
+
private resolveBooted;
|
|
2875
|
+
private readonly bootedPromise;
|
|
1941
2876
|
constructor(container: HTMLElement, options?: CliEngineOptions | undefined);
|
|
1942
2877
|
/**
|
|
1943
2878
|
* Register a CLI module to be loaded on start().
|
|
@@ -1964,9 +2899,47 @@ declare class CliEngine {
|
|
|
1964
2899
|
*/
|
|
1965
2900
|
registerService(token: string, value: any): void;
|
|
1966
2901
|
/**
|
|
1967
|
-
*
|
|
2902
|
+
* Start the CLI: set up the terminal and services, boot the modules
|
|
2903
|
+
* (reporting progress in the terminal), then hand over to the prompt.
|
|
2904
|
+
*
|
|
2905
|
+
* Phases, in order:
|
|
2906
|
+
* 1. terminal xterm.js in the container
|
|
2907
|
+
* 2. services service container, executor, execution context
|
|
2908
|
+
* 3. boot report hold typed keys, show the boot log
|
|
2909
|
+
* 4. runtime environment, background services, servers
|
|
2910
|
+
* 5. modules core + welcome + server + user modules
|
|
2911
|
+
* 6. completion tab-completion providers
|
|
2912
|
+
* 7. ready clear the report, replay typed keys, `isBooted`
|
|
2913
|
+
* 8. after boot `onAfterBoot` hooks (welcome message), snapshot
|
|
1968
2914
|
*/
|
|
1969
2915
|
start(): Promise<void>;
|
|
2916
|
+
/** 1. Wait for the container to have a size, then create xterm.js. */
|
|
2917
|
+
private setupTerminal;
|
|
2918
|
+
/** 2. Service container, boot service, executor and execution context. */
|
|
2919
|
+
private setupServices;
|
|
2920
|
+
/**
|
|
2921
|
+
* 3. Keep what the user types until the terminal is ready (replayed at
|
|
2922
|
+
* the first prompt) and start the boot report (configurable).
|
|
2923
|
+
*/
|
|
2924
|
+
private beginBootReport;
|
|
2925
|
+
/** 4. Environment variables, background services, server auth and manager. */
|
|
2926
|
+
private registerRuntimeServices;
|
|
2927
|
+
/** 4. Connect to the configured servers, one boot step each. */
|
|
2928
|
+
private connectServers;
|
|
2929
|
+
/**
|
|
2930
|
+
* 5. Built-in welcome and server modules, the app's modules, and the
|
|
2931
|
+
* greeting, which runs after every other `onAfterBoot` hook.
|
|
2932
|
+
*/
|
|
2933
|
+
private modulesToBoot;
|
|
2934
|
+
/** 7. Replace the boot report with the terminal and mark the CLI booted. */
|
|
2935
|
+
private completeBoot;
|
|
2936
|
+
/**
|
|
2937
|
+
* Boot threw: never leave the terminal unusable. Keep the report with the
|
|
2938
|
+
* error on screen, show the cursor and hand over typed keys.
|
|
2939
|
+
*/
|
|
2940
|
+
private failBoot;
|
|
2941
|
+
/** 8. `onAfterBoot` hooks by priority (lower first); one failing hook does not stop the rest. */
|
|
2942
|
+
private runAfterBootHooks;
|
|
1970
2943
|
/**
|
|
1971
2944
|
* Clean up terminal and event listeners.
|
|
1972
2945
|
*/
|
|
@@ -1988,7 +2961,23 @@ declare class CliEngine {
|
|
|
1988
2961
|
*/
|
|
1989
2962
|
getRegistry(): CliCommandProcessorRegistry;
|
|
1990
2963
|
/**
|
|
1991
|
-
*
|
|
2964
|
+
* `true` once boot has completed: modules are set up and the terminal
|
|
2965
|
+
* accepts input. `onAfterBoot` hooks (welcome message) run right after.
|
|
2966
|
+
*/
|
|
2967
|
+
get isBooted(): boolean;
|
|
2968
|
+
/**
|
|
2969
|
+
* Resolves when boot has completed (see `isBooted`). Never rejects; if
|
|
2970
|
+
* `start()` fails it stays pending.
|
|
2971
|
+
*/
|
|
2972
|
+
get booted(): Promise<void>;
|
|
2973
|
+
/**
|
|
2974
|
+
* Timestamp (ms since epoch) when the engine finished starting.
|
|
2975
|
+
*/
|
|
2976
|
+
get startedAt(): number | undefined;
|
|
2977
|
+
/**
|
|
2978
|
+
* Execute a command programmatically, behaving the same as if the user
|
|
2979
|
+
* typed it and pressed Enter: echoes the command, adds it to history,
|
|
2980
|
+
* executes it, and shows a new prompt afterwards.
|
|
1992
2981
|
*/
|
|
1993
2982
|
execute(command: string): Promise<void>;
|
|
1994
2983
|
/**
|
|
@@ -2002,8 +2991,6 @@ declare class CliEngine {
|
|
|
2002
2991
|
* source, the restored content may reflow differently.
|
|
2003
2992
|
*/
|
|
2004
2993
|
private restoreSnapshot;
|
|
2005
|
-
private getTerminalOptions;
|
|
2006
|
-
private initializeTerminal;
|
|
2007
2994
|
private handleResize;
|
|
2008
2995
|
/**
|
|
2009
2996
|
* Call fitAddon.fit() only when the container has non-zero dimensions.
|
|
@@ -2017,51 +3004,218 @@ declare class CliEngine {
|
|
|
2017
3004
|
* so intermediate resize events cannot leave stale artefacts.
|
|
2018
3005
|
*/
|
|
2019
3006
|
private deferResizeFix;
|
|
2020
|
-
/**
|
|
2021
|
-
* Wait until the container element has non-zero dimensions.
|
|
2022
|
-
* xterm.js requires the host element to be laid out before open() is called.
|
|
2023
|
-
*/
|
|
2024
|
-
private waitForLayout;
|
|
2025
3007
|
}
|
|
2026
3008
|
|
|
3009
|
+
interface TerminalSetupResult {
|
|
3010
|
+
terminal: Terminal;
|
|
3011
|
+
fitAddon: FitAddon;
|
|
3012
|
+
serializeAddon: SerializeAddon;
|
|
3013
|
+
dragDropService: CliDragDropService;
|
|
3014
|
+
wheelListener: (e: WheelEvent) => void;
|
|
3015
|
+
}
|
|
3016
|
+
/**
|
|
3017
|
+
* Default terminal font size: 20px, or 14px on phone-sized viewports so a
|
|
3018
|
+
* line still fits a useful number of columns (about 26 at 20px on a 390px screen).
|
|
3019
|
+
*/
|
|
3020
|
+
declare function defaultFontSize(): number;
|
|
3021
|
+
/**
|
|
3022
|
+
* Merge user-supplied terminal options with sensible defaults.
|
|
3023
|
+
*/
|
|
3024
|
+
declare function getTerminalOptions(userOptions?: Partial<ITerminalOptions & ITerminalInitOnlyOptions>): ITerminalOptions & ITerminalInitOnlyOptions;
|
|
3025
|
+
/**
|
|
3026
|
+
* Create and configure an xterm.js Terminal with all required addons,
|
|
3027
|
+
* open it into the given container, and return the instances.
|
|
3028
|
+
*/
|
|
3029
|
+
declare function initializeTerminal(container: HTMLElement, opts: ITerminalOptions & ITerminalInitOnlyOptions): TerminalSetupResult;
|
|
3030
|
+
/**
|
|
3031
|
+
* Wait until the container element has non-zero dimensions.
|
|
3032
|
+
* xterm.js requires the host element to be laid out before open() is called.
|
|
3033
|
+
* Rejects after {@link LAYOUT_TIMEOUT_MS} if the container stays hidden.
|
|
3034
|
+
*/
|
|
3035
|
+
declare function waitForLayout(container: HTMLElement): Promise<void>;
|
|
3036
|
+
|
|
3037
|
+
/**
|
|
3038
|
+
* In-memory publish/subscribe bus of one terminal. Handlers run
|
|
3039
|
+
* synchronously in subscription order; a throwing handler is reported to
|
|
3040
|
+
* `onHandlerError` and does not stop delivery. Keeps the last
|
|
3041
|
+
* {@link CLI_EVENT_HISTORY_SIZE} events; nothing is persisted.
|
|
3042
|
+
*/
|
|
3043
|
+
declare class CliEventBus implements ICliEventBus {
|
|
3044
|
+
private readonly onHandlerError;
|
|
3045
|
+
private readonly historySize;
|
|
3046
|
+
private readonly subject;
|
|
3047
|
+
private readonly recent;
|
|
3048
|
+
private disposed;
|
|
3049
|
+
constructor(onHandlerError?: (error: unknown, event: CliEvent) => void, historySize?: number);
|
|
3050
|
+
emit<K extends CliEventType>(type: K, data: CliEventMap[K], options?: CliEmitOptions): void;
|
|
3051
|
+
emit<T = unknown, K extends string = string>(type: K & CustomEventType<K>, data?: T, options?: CliEmitOptions): void;
|
|
3052
|
+
on<K extends CliEventType>(pattern: K, handler: CliEventHandler<CliEventMap[K]>): () => void;
|
|
3053
|
+
on<T = unknown>(pattern: string, handler: CliEventHandler<T>): () => void;
|
|
3054
|
+
once<K extends CliEventType>(pattern: K, handler: CliEventHandler<CliEventMap[K]>): () => void;
|
|
3055
|
+
once<T = unknown>(pattern: string, handler: CliEventHandler<T>): () => void;
|
|
3056
|
+
events$<K extends CliEventType>(pattern: K): Observable<CliEvent<CliEventMap[K]>>;
|
|
3057
|
+
events$<T = unknown>(pattern?: string): Observable<CliEvent<T>>;
|
|
3058
|
+
history<K extends CliEventType>(pattern: K, limit?: number): CliEvent<CliEventMap[K]>[];
|
|
3059
|
+
history<T = unknown>(pattern?: string, limit?: number): CliEvent<T>[];
|
|
3060
|
+
/** Stop delivering events and complete all observables. */
|
|
3061
|
+
dispose(): void;
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
/**
|
|
3065
|
+
* Default implementation of the translation service.
|
|
3066
|
+
*
|
|
3067
|
+
* Maintains a map of locale -> flat key-value translations.
|
|
3068
|
+
* The 'en' locale is always implicitly available via defaultValue fallbacks.
|
|
3069
|
+
* Supports simple {param} interpolation.
|
|
3070
|
+
*/
|
|
3071
|
+
declare class CliTranslationService implements ICliTranslationService {
|
|
3072
|
+
private locale;
|
|
3073
|
+
private readonly translations;
|
|
3074
|
+
t(key: string, defaultValue: string, params?: Record<string, string | number>): string;
|
|
3075
|
+
getLocale(): string;
|
|
3076
|
+
setLocale(locale: string): void;
|
|
3077
|
+
addTranslations(locale: string, translations: Record<string, string>): void;
|
|
3078
|
+
getAvailableLocales(): string[];
|
|
3079
|
+
}
|
|
3080
|
+
|
|
3081
|
+
interface InitializeServicesOptions {
|
|
3082
|
+
registry: CliCommandProcessorRegistry;
|
|
3083
|
+
pendingServices: CliProvider[];
|
|
3084
|
+
dragDropService?: CliDragDropService;
|
|
3085
|
+
}
|
|
3086
|
+
interface InitializeServicesResult {
|
|
3087
|
+
services: CliServiceContainer;
|
|
3088
|
+
events: CliEventBus;
|
|
3089
|
+
logger: CliLogger;
|
|
3090
|
+
commandHistory: CliCommandHistory;
|
|
3091
|
+
stateStoreManager: CliStateStoreManager;
|
|
3092
|
+
processRegistry: CliProcessRegistry;
|
|
3093
|
+
translator: CliTranslationService;
|
|
3094
|
+
}
|
|
3095
|
+
/**
|
|
3096
|
+
* Build and populate the service container with all core services.
|
|
3097
|
+
* Takes the registry, pending (user-registered) services, and the drag-drop
|
|
3098
|
+
* service instance, and returns all initialized services ready for wiring
|
|
3099
|
+
* into the execution context.
|
|
3100
|
+
*/
|
|
3101
|
+
declare function initializeServices(options: InitializeServicesOptions): Promise<InitializeServicesResult>;
|
|
3102
|
+
|
|
3103
|
+
/** Service token holding the name of the framework hosting the CLI. */
|
|
3104
|
+
declare const CLI_FRAMEWORK_SERVICE = "cli-framework";
|
|
3105
|
+
/** What a framework wrapper passes to an engine: shared by components, providers and config contexts. */
|
|
3106
|
+
interface CliHostConfig {
|
|
3107
|
+
modules?: ICliModule[];
|
|
3108
|
+
/** @deprecated Use modules instead. */
|
|
3109
|
+
processors?: ICliCommandProcessor[];
|
|
3110
|
+
options?: CliEngineOptions;
|
|
3111
|
+
/** Extra services registered by token before start. */
|
|
3112
|
+
services?: Record<string, any>;
|
|
3113
|
+
}
|
|
3114
|
+
interface CreateCliEngineConfig extends CliHostConfig {
|
|
3115
|
+
/** Reported by `version`, `debug` and `feedback`, e.g. 'React'. */
|
|
3116
|
+
framework?: string;
|
|
3117
|
+
/** Terminal state to restore on start. */
|
|
3118
|
+
snapshot?: CliEngineSnapshot;
|
|
3119
|
+
}
|
|
3120
|
+
/**
|
|
3121
|
+
* Create an engine for `container` with the services, modules and
|
|
3122
|
+
* processors of a wrapper registered (in that order). Call `start()` on it.
|
|
3123
|
+
*/
|
|
3124
|
+
declare function createCliEngine(container: HTMLElement, config?: CreateCliEngineConfig): CliEngine;
|
|
3125
|
+
/**
|
|
3126
|
+
* Resolve a component's config: each field set locally wins over the one
|
|
3127
|
+
* inherited from a surrounding config provider.
|
|
3128
|
+
*/
|
|
3129
|
+
declare function resolveCliHostConfig(local: CliHostConfig, inherited?: CliHostConfig | null): CliHostConfig;
|
|
3130
|
+
/** Merge option objects key by key: `local` overrides `inherited`. */
|
|
3131
|
+
declare function mergeCliOptions<T extends object>(local: T | undefined, inherited: object | undefined): T | undefined;
|
|
3132
|
+
|
|
2027
3133
|
declare class CliServerConnection {
|
|
2028
3134
|
private readonly _config;
|
|
2029
3135
|
private readonly _backgroundServices?;
|
|
3136
|
+
private readonly _logger?;
|
|
3137
|
+
private readonly _authService?;
|
|
2030
3138
|
private _connected;
|
|
2031
3139
|
private _commands;
|
|
2032
3140
|
private _capabilities;
|
|
2033
3141
|
private _eventSocket;
|
|
3142
|
+
private _apiVersion;
|
|
3143
|
+
private _basePath;
|
|
3144
|
+
private _wsReconnectAttempts;
|
|
3145
|
+
private _wsReconnectTimer;
|
|
3146
|
+
/** True once this connection registered its `server-events:<name>` background service */
|
|
3147
|
+
private _eventServiceRegistered;
|
|
3148
|
+
private static readonly WS_MAX_RECONNECT_ATTEMPTS;
|
|
3149
|
+
private static readonly WS_MAX_RECONNECT_DELAY_MS;
|
|
3150
|
+
private _healthCheckTimer;
|
|
3151
|
+
private _healthCheckAttempts;
|
|
3152
|
+
private static readonly HEALTH_CHECK_INTERVAL_MS;
|
|
3153
|
+
private static readonly HEALTH_CHECK_MAX_ATTEMPTS;
|
|
2034
3154
|
onDisconnect?: () => void;
|
|
2035
|
-
|
|
3155
|
+
onReconnected?: () => void;
|
|
3156
|
+
constructor(_config: CliServerConfig, _backgroundServices?: ICliBackgroundServiceRegistry, _logger?: ICliLogger, _authService?: ICliServerAuthService);
|
|
2036
3157
|
get config(): CliServerConfig;
|
|
2037
3158
|
get connected(): boolean;
|
|
2038
3159
|
get commands(): CliServerCommandDescriptor[];
|
|
2039
3160
|
get capabilities(): CliServerCapabilities | null;
|
|
3161
|
+
get apiVersion(): number;
|
|
3162
|
+
/**
|
|
3163
|
+
* Resolve auth headers for this server connection.
|
|
3164
|
+
* Uses the auth service (which merges config headers with registered
|
|
3165
|
+
* ICliServerAuthTokenProviders), or falls back to config headers directly.
|
|
3166
|
+
*/
|
|
3167
|
+
resolveAuthHeaders(): Record<string, string>;
|
|
3168
|
+
/**
|
|
3169
|
+
* WebSocket URL for this server with auth: single-use upgrade params from
|
|
3170
|
+
* auth providers when available, otherwise headers copied into the URL.
|
|
3171
|
+
*/
|
|
3172
|
+
buildWebSocketUrl(path: string): Promise<string>;
|
|
2040
3173
|
connect(): Promise<void>;
|
|
2041
3174
|
disconnect(): void;
|
|
3175
|
+
startHealthCheck(): void;
|
|
3176
|
+
private scheduleNextHealthCheck;
|
|
3177
|
+
stopHealthCheck(): void;
|
|
2042
3178
|
fetchCommands(): Promise<CliServerCommandDescriptor[]>;
|
|
2043
3179
|
fetchCapabilities(): Promise<CliServerCapabilities | null>;
|
|
2044
3180
|
execute(command: CliProcessCommand): Promise<CliServerResponse>;
|
|
3181
|
+
executeStream(command: CliProcessCommand, onOutput: (output: CliServerOutput) => void): Promise<{
|
|
3182
|
+
exitCode: number;
|
|
3183
|
+
}>;
|
|
2045
3184
|
ping(): Promise<boolean>;
|
|
3185
|
+
/** Whether the server answers HTTP at all (any status: it is running). */
|
|
3186
|
+
private answers;
|
|
2046
3187
|
private connectEventSocket;
|
|
2047
3188
|
private connectEventSocketDirect;
|
|
3189
|
+
private connectEventSocketDirectAsync;
|
|
3190
|
+
/**
|
|
3191
|
+
* The server closes the event socket with 4401 when the session behind it
|
|
3192
|
+
* ended (logout, revoke, expiry). Retrying with the same credentials cannot
|
|
3193
|
+
* succeed; the auth layer reconnects the server when the session changes.
|
|
3194
|
+
*/
|
|
3195
|
+
private isSessionEndedClose;
|
|
2048
3196
|
private handleServerDisconnect;
|
|
2049
3197
|
private closeEventSocket;
|
|
2050
3198
|
private closeEventSocketDirect;
|
|
3199
|
+
private scheduleWsReconnect;
|
|
3200
|
+
private httpFetchWithRetry;
|
|
2051
3201
|
private httpFetch;
|
|
2052
3202
|
private normalizeUrl;
|
|
2053
3203
|
private toWebSocketUrl;
|
|
2054
3204
|
}
|
|
2055
3205
|
|
|
2056
3206
|
/**
|
|
2057
|
-
*
|
|
2058
|
-
* Shared by both single-proxy and multi-proxy processors.
|
|
3207
|
+
* Render a single CliServerOutput to the terminal.
|
|
2059
3208
|
*/
|
|
2060
|
-
declare function
|
|
3209
|
+
declare function renderSingleOutput(output: CliServerOutput, context: ICliExecutionContext): void;
|
|
2061
3210
|
/**
|
|
2062
3211
|
* Render a CliServerResponse to the terminal.
|
|
2063
3212
|
*/
|
|
2064
3213
|
declare function renderServerResponse(response: CliServerResponse, context: ICliExecutionContext): void;
|
|
3214
|
+
/**
|
|
3215
|
+
* Execute a command on a specific server connection and render the response.
|
|
3216
|
+
* Shared by both single-proxy and multi-proxy processors.
|
|
3217
|
+
*/
|
|
3218
|
+
declare function executeOnServer(connection: CliServerConnection, serverName: string, descriptor: CliServerCommandDescriptor, command: CliProcessCommand, context: ICliExecutionContext, commandPath?: string[]): Promise<void>;
|
|
2065
3219
|
declare class CliServerProxyProcessor implements ICliCommandProcessor {
|
|
2066
3220
|
private readonly connection;
|
|
2067
3221
|
private readonly descriptor;
|
|
@@ -2071,9 +3225,12 @@ declare class CliServerProxyProcessor implements ICliCommandProcessor {
|
|
|
2071
3225
|
description?: string;
|
|
2072
3226
|
version?: string;
|
|
2073
3227
|
metadata?: CliProcessorMetadata;
|
|
2074
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
3228
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2075
3229
|
processors?: ICliCommandProcessor[];
|
|
2076
|
-
|
|
3230
|
+
acceptsRawInput?: boolean;
|
|
3231
|
+
/** Full command path from root to this processor (e.g. ["aws", "lambda", "list"]) */
|
|
3232
|
+
private readonly commandPath;
|
|
3233
|
+
constructor(connection: CliServerConnection, descriptor: CliServerCommandDescriptor, serverName: string, isNested?: boolean, parentPath?: string[]);
|
|
2077
3234
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2078
3235
|
}
|
|
2079
3236
|
|
|
@@ -2097,31 +3254,41 @@ declare class CliServerMultiProxyProcessor implements ICliCommandProcessor {
|
|
|
2097
3254
|
command: string;
|
|
2098
3255
|
description?: string;
|
|
2099
3256
|
metadata?: CliProcessorMetadata;
|
|
2100
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
3257
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2101
3258
|
processors?: ICliCommandProcessor[];
|
|
2102
|
-
|
|
3259
|
+
acceptsRawInput?: boolean;
|
|
3260
|
+
/** Full command path from root to this processor */
|
|
3261
|
+
private readonly commandPath;
|
|
3262
|
+
constructor(entries: MultiProxyEntry[], provider: DefaultServerProvider, parentPath?: string[]);
|
|
2103
3263
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2104
3264
|
}
|
|
2105
3265
|
|
|
2106
|
-
declare const CliServerManager_TOKEN
|
|
3266
|
+
declare const CliServerManager_TOKEN: any;
|
|
2107
3267
|
declare class CliServerManager implements DefaultServerProvider {
|
|
2108
3268
|
private readonly registry;
|
|
3269
|
+
private readonly authService?;
|
|
3270
|
+
private readonly events?;
|
|
2109
3271
|
readonly connections: Map<string, CliServerConnection>;
|
|
2110
3272
|
private _logger?;
|
|
3273
|
+
private _cliLogger?;
|
|
2111
3274
|
private _defaultServer;
|
|
3275
|
+
/** Bare-name aliases this manager registered (only these are ever removed) */
|
|
3276
|
+
private readonly _bareAliases;
|
|
2112
3277
|
private _backgroundServices?;
|
|
2113
|
-
constructor(registry: ICliCommandProcessorRegistry);
|
|
3278
|
+
constructor(registry: ICliCommandProcessorRegistry, authService?: ICliServerAuthService, events?: ICliEventBus);
|
|
2114
3279
|
get defaultServer(): string | null;
|
|
3280
|
+
preferredServer(): string | null;
|
|
2115
3281
|
setDefaultServer(name: string | null): void;
|
|
2116
3282
|
connectAll(servers: CliServerConfig[], logger?: {
|
|
2117
3283
|
warn(msg: string): void;
|
|
2118
3284
|
info(msg: string): void;
|
|
2119
|
-
}, backgroundServices?: ICliBackgroundServiceRegistry): Promise<void>;
|
|
3285
|
+
}, backgroundServices?: ICliBackgroundServiceRegistry, cliLogger?: ICliLogger): Promise<void>;
|
|
2120
3286
|
reconnect(name: string): Promise<{
|
|
2121
3287
|
success: boolean;
|
|
2122
3288
|
commandCount: number;
|
|
2123
3289
|
}>;
|
|
2124
3290
|
getConnection(name: string): CliServerConnection | undefined;
|
|
3291
|
+
private emitConnected;
|
|
2125
3292
|
private handleDisconnect;
|
|
2126
3293
|
private unregisterServerProcessors;
|
|
2127
3294
|
private unregisterBareAliases;
|
|
@@ -2131,37 +3298,60 @@ declare class CliServerManager implements DefaultServerProvider {
|
|
|
2131
3298
|
|
|
2132
3299
|
declare function createServerModule(): ICliModule;
|
|
2133
3300
|
|
|
3301
|
+
/**
|
|
3302
|
+
* `server`: the servers this terminal is connected to (configured by the
|
|
3303
|
+
* app in `options.servers`). Their commands are available directly (`echo`)
|
|
3304
|
+
* and namespaced (`node:echo`).
|
|
3305
|
+
*/
|
|
2134
3306
|
declare class CliServerCommandProcessor implements ICliCommandProcessor {
|
|
2135
3307
|
command: string;
|
|
3308
|
+
aliases: string[];
|
|
2136
3309
|
description: string;
|
|
2137
3310
|
metadata: {
|
|
2138
|
-
icon:
|
|
3311
|
+
icon: any;
|
|
2139
3312
|
module: string;
|
|
2140
3313
|
sealed: boolean;
|
|
2141
3314
|
};
|
|
3315
|
+
stateConfiguration: CliStateConfiguration;
|
|
2142
3316
|
processors: ICliCommandChildProcessor[];
|
|
3317
|
+
/** Restore the default server saved by `server default <name>`. */
|
|
3318
|
+
initialize(context: ICliExecutionContext): Promise<void>;
|
|
3319
|
+
/** `server` alone: the servers, then what can be done with them. */
|
|
2143
3320
|
processCommand(_command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
3321
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
2144
3322
|
}
|
|
2145
3323
|
|
|
2146
3324
|
declare class CliSshCommandProcessor implements ICliCommandProcessor {
|
|
2147
3325
|
command: string;
|
|
3326
|
+
aliases: string[];
|
|
2148
3327
|
description: string;
|
|
2149
3328
|
acceptsRawInput: boolean;
|
|
2150
3329
|
valueRequired: boolean;
|
|
2151
3330
|
metadata: CliProcessorMetadata;
|
|
2152
|
-
parameters?: ICliCommandParameterDescriptor[];
|
|
2153
|
-
private socket;
|
|
2154
|
-
private context;
|
|
3331
|
+
parameters?: ICliCommandParameterDescriptor$1[];
|
|
2155
3332
|
processCommand(command: CliProcessCommand, context: ICliExecutionContext): Promise<void>;
|
|
2156
|
-
|
|
2157
|
-
|
|
2158
|
-
|
|
3333
|
+
/**
|
|
3334
|
+
* Full-screen handler for one session: input, resize and disposal go to
|
|
3335
|
+
* that session's socket only.
|
|
3336
|
+
*/
|
|
3337
|
+
private fullScreenHandler;
|
|
2159
3338
|
private resolveServer;
|
|
3339
|
+
/** Why `name` cannot be used: unknown, unreachable or without a shell. */
|
|
3340
|
+
private writeWhyNotAvailable;
|
|
3341
|
+
/** No server has a shell: say whether none is configured, connected or shell-enabled. */
|
|
3342
|
+
private writeNoShellServers;
|
|
3343
|
+
writeDescription(context: ICliExecutionContext): void;
|
|
2160
3344
|
private executeInteractive;
|
|
2161
3345
|
private executeOneShot;
|
|
3346
|
+
/** `ssh <server> <cmd...>` → `<cmd...>` exactly as typed */
|
|
3347
|
+
private remoteCommandFromRaw;
|
|
2162
3348
|
private buildShellUrl;
|
|
2163
3349
|
private cleanup;
|
|
2164
3350
|
}
|
|
3351
|
+
declare function describeShellClose(event: {
|
|
3352
|
+
code?: number;
|
|
3353
|
+
reason?: string;
|
|
3354
|
+
}, serverName: string): string | null;
|
|
2165
3355
|
|
|
2166
3356
|
/**
|
|
2167
3357
|
* Result of executing a command through the test harness.
|
|
@@ -2207,20 +3397,30 @@ declare class CliTestHarness {
|
|
|
2207
3397
|
readonly registry: CliCommandProcessorRegistry;
|
|
2208
3398
|
readonly executor: CliCommandExecutor;
|
|
2209
3399
|
readonly services: CliServiceContainer;
|
|
3400
|
+
/** Shared by every command: add a language pack and switch locale to test translations. */
|
|
3401
|
+
readonly translator: CliTranslationService;
|
|
2210
3402
|
private readonly stateStoreManager;
|
|
3403
|
+
private readonly initialized;
|
|
2211
3404
|
private readonly processRegistry;
|
|
2212
3405
|
/** Current user session — set via setUserSession() */
|
|
2213
3406
|
userSession?: ICliUserSession;
|
|
2214
3407
|
/** Reader responses — set via setReaderResponses() for interactive commands */
|
|
2215
3408
|
private readerResponses;
|
|
3409
|
+
private userSessionProvider?;
|
|
2216
3410
|
constructor();
|
|
3411
|
+
/**
|
|
3412
|
+
* Resolve `context.userSession` on every command from this function
|
|
3413
|
+
* (e.g. a session service), instead of the value set via setUserSession().
|
|
3414
|
+
*/
|
|
3415
|
+
setUserSessionProvider(provider: () => ICliUserSession | undefined): void;
|
|
2217
3416
|
/**
|
|
2218
3417
|
* Register a service in the test container.
|
|
2219
3418
|
*/
|
|
2220
3419
|
registerService(token: any, value: any): void;
|
|
2221
3420
|
/**
|
|
2222
3421
|
* Register a command processor. If the processor has an `initialize()`
|
|
2223
|
-
* method, it
|
|
3422
|
+
* method, it is called (with the processor's own state store, as in the
|
|
3423
|
+
* engine) before the first `execute()`, or by `initializeProcessors()`.
|
|
2224
3424
|
*/
|
|
2225
3425
|
registerProcessor(processor: ICliCommandProcessor): void;
|
|
2226
3426
|
/**
|
|
@@ -2232,6 +3432,8 @@ declare class CliTestHarness {
|
|
|
2232
3432
|
* Call this after registering all services and processors.
|
|
2233
3433
|
*/
|
|
2234
3434
|
initializeProcessors(): Promise<void>;
|
|
3435
|
+
/** As the engine's boot: link sub-commands to their parent, then initialize. */
|
|
3436
|
+
private initializeTree;
|
|
2235
3437
|
/**
|
|
2236
3438
|
* Set the active user session. Commands that check `context.userSession`
|
|
2237
3439
|
* will see this session.
|
|
@@ -2262,6 +3464,10 @@ interface ICliWasmAccelerator {
|
|
|
2262
3464
|
prefixMatch(candidates: string[], prefix: string): string[];
|
|
2263
3465
|
/** Longest common prefix of the given strings. */
|
|
2264
3466
|
commonPrefix(strings: string[]): string;
|
|
3467
|
+
/** Register a named rule set for syntax highlighting tokenization. */
|
|
3468
|
+
registerRuleSet(ruleSetId: string, rules: string): void;
|
|
3469
|
+
/** Tokenize a line using a previously registered rule set. Returns newline-separated "start,end,tokenType" entries. */
|
|
3470
|
+
tokenizeLine(line: string, ruleSetId: string): string;
|
|
2265
3471
|
}
|
|
2266
3472
|
|
|
2267
3473
|
/**
|
|
@@ -2275,6 +3481,9 @@ declare class JsFallbackAccelerator implements ICliWasmAccelerator {
|
|
|
2275
3481
|
text: string;
|
|
2276
3482
|
};
|
|
2277
3483
|
prefixMatch(candidates: string[], prefix: string): string[];
|
|
3484
|
+
private ruleSets;
|
|
3485
|
+
registerRuleSet(ruleSetId: string, rules: string): void;
|
|
3486
|
+
tokenizeLine(line: string, ruleSetId: string): string;
|
|
2278
3487
|
commonPrefix(strings: string[]): string;
|
|
2279
3488
|
}
|
|
2280
3489
|
|
|
@@ -2299,4 +3508,511 @@ declare function getAccelerator(): ICliWasmAccelerator;
|
|
|
2299
3508
|
*/
|
|
2300
3509
|
declare function isWasmAccelerated(): boolean;
|
|
2301
3510
|
|
|
2302
|
-
|
|
3511
|
+
/** One terminal inside a tab. */
|
|
3512
|
+
interface CliPanelPane {
|
|
3513
|
+
id: number;
|
|
3514
|
+
widthPercent: number;
|
|
3515
|
+
/** Snapshot to restore when the pane's engine starts (used by "Duplicate"). */
|
|
3516
|
+
snapshot?: CliEngineSnapshot;
|
|
3517
|
+
}
|
|
3518
|
+
/** One tab of the panel: a title and one or more panes side by side. */
|
|
3519
|
+
interface CliPanelTab {
|
|
3520
|
+
id: number;
|
|
3521
|
+
title: string;
|
|
3522
|
+
isEditing: boolean;
|
|
3523
|
+
panes: CliPanelPane[];
|
|
3524
|
+
}
|
|
3525
|
+
interface CliPanelContextMenu {
|
|
3526
|
+
visible: boolean;
|
|
3527
|
+
x: number;
|
|
3528
|
+
y: number;
|
|
3529
|
+
tabId: number;
|
|
3530
|
+
}
|
|
3531
|
+
interface CliPanelServiceDetail {
|
|
3532
|
+
name: string;
|
|
3533
|
+
status: string;
|
|
3534
|
+
description?: string;
|
|
3535
|
+
}
|
|
3536
|
+
interface CliPanelServerDetail {
|
|
3537
|
+
name: string;
|
|
3538
|
+
url: string;
|
|
3539
|
+
connected: boolean;
|
|
3540
|
+
apiVersion?: string;
|
|
3541
|
+
commandCount?: number;
|
|
3542
|
+
}
|
|
3543
|
+
type CliPanelExecutionState = 'idle' | 'running';
|
|
3544
|
+
type CliPanelServerState = 'connected' | 'disconnected' | 'none';
|
|
3545
|
+
/** Status derived from the engines of a single tab. */
|
|
3546
|
+
interface CliPanelTabStatus {
|
|
3547
|
+
executionState: CliPanelExecutionState;
|
|
3548
|
+
lastCommand: {
|
|
3549
|
+
name: string;
|
|
3550
|
+
success: boolean;
|
|
3551
|
+
} | null;
|
|
3552
|
+
notification: CliNotification | null;
|
|
3553
|
+
}
|
|
3554
|
+
/** Status derived from the first engine of the active tab. */
|
|
3555
|
+
interface CliPanelGlobalStatus {
|
|
3556
|
+
serviceCount: {
|
|
3557
|
+
running: number;
|
|
3558
|
+
total: number;
|
|
3559
|
+
};
|
|
3560
|
+
serviceDetails: CliPanelServiceDetail[];
|
|
3561
|
+
serverState: CliPanelServerState;
|
|
3562
|
+
serverDetails: CliPanelServerDetail[];
|
|
3563
|
+
/** Milliseconds since the engine started, 0 when unknown. */
|
|
3564
|
+
uptime: number;
|
|
3565
|
+
}
|
|
3566
|
+
declare const DEFAULT_TAB_STATUS: CliPanelTabStatus;
|
|
3567
|
+
declare const DEFAULT_GLOBAL_STATUS: CliPanelGlobalStatus;
|
|
3568
|
+
/**
|
|
3569
|
+
* Values a host may control from the outside. A defined value wins over the
|
|
3570
|
+
* panel's own state; `undefined` leaves the panel uncontrolled for that field.
|
|
3571
|
+
*/
|
|
3572
|
+
interface CliPanelControlledState {
|
|
3573
|
+
collapsed?: boolean;
|
|
3574
|
+
hidden?: boolean;
|
|
3575
|
+
maximized?: boolean;
|
|
3576
|
+
activeTabId?: number;
|
|
3577
|
+
position?: CliPanelPosition;
|
|
3578
|
+
height?: number;
|
|
3579
|
+
width?: number;
|
|
3580
|
+
}
|
|
3581
|
+
/** Change notifications and structural events, mapped by each framework wrapper. */
|
|
3582
|
+
interface CliPanelCallbacks {
|
|
3583
|
+
onCollapsedChange?: (collapsed: boolean) => void;
|
|
3584
|
+
onHiddenChange?: (hidden: boolean) => void;
|
|
3585
|
+
onMaximizedChange?: (maximized: boolean) => void;
|
|
3586
|
+
onActiveTabIdChange?: (tabId: number) => void;
|
|
3587
|
+
onPositionChange?: (position: CliPanelPosition) => void;
|
|
3588
|
+
onHeightChange?: (height: number) => void;
|
|
3589
|
+
onWidthChange?: (width: number) => void;
|
|
3590
|
+
onClose?: () => void;
|
|
3591
|
+
onTabAdded?: (event: {
|
|
3592
|
+
tabId: number;
|
|
3593
|
+
}) => void;
|
|
3594
|
+
onTabClosed?: (event: {
|
|
3595
|
+
tabId: number;
|
|
3596
|
+
}) => void;
|
|
3597
|
+
onPaneSplit?: (event: {
|
|
3598
|
+
paneId: number;
|
|
3599
|
+
tabId: number;
|
|
3600
|
+
}) => void;
|
|
3601
|
+
onPaneClosed?: (event: {
|
|
3602
|
+
paneId: number;
|
|
3603
|
+
}) => void;
|
|
3604
|
+
}
|
|
3605
|
+
interface CliPanelViewport {
|
|
3606
|
+
width: number;
|
|
3607
|
+
height: number;
|
|
3608
|
+
}
|
|
3609
|
+
interface CliPanelControllerOptions {
|
|
3610
|
+
/** Panel configuration (initial state, chrome buttons, theme sync). */
|
|
3611
|
+
config?: CliPanelConfig;
|
|
3612
|
+
callbacks?: CliPanelCallbacks;
|
|
3613
|
+
controlled?: CliPanelControlledState;
|
|
3614
|
+
/** Viewport size used for maximize and resize clamping. Defaults to `window`. */
|
|
3615
|
+
viewport?: () => CliPanelViewport;
|
|
3616
|
+
/**
|
|
3617
|
+
* Restore and persist the position through localStorage.
|
|
3618
|
+
* @default true
|
|
3619
|
+
*/
|
|
3620
|
+
persistPosition?: boolean;
|
|
3621
|
+
}
|
|
3622
|
+
/**
|
|
3623
|
+
* Immutable view of the whole panel. A new object is produced on every
|
|
3624
|
+
* change, so views can compare by reference.
|
|
3625
|
+
*/
|
|
3626
|
+
interface CliPanelSnapshot {
|
|
3627
|
+
visible: boolean;
|
|
3628
|
+
/** True once the first tab has been created (content rendered). */
|
|
3629
|
+
initialized: boolean;
|
|
3630
|
+
collapsed: boolean;
|
|
3631
|
+
hidden: boolean;
|
|
3632
|
+
maximized: boolean;
|
|
3633
|
+
position: CliPanelPosition;
|
|
3634
|
+
height: number;
|
|
3635
|
+
width: number;
|
|
3636
|
+
isHorizontal: boolean;
|
|
3637
|
+
/** Status text is shown in the header for top/bottom, compact dots otherwise. */
|
|
3638
|
+
showStatusIndicators: boolean;
|
|
3639
|
+
panelResizing: boolean;
|
|
3640
|
+
themeStyles: Record<string, string>;
|
|
3641
|
+
closable: boolean;
|
|
3642
|
+
resizable: boolean;
|
|
3643
|
+
hideable: boolean;
|
|
3644
|
+
hideAlignment: CliPanelHideAlignment;
|
|
3645
|
+
syncTheme: boolean;
|
|
3646
|
+
tabs: readonly CliPanelTab[];
|
|
3647
|
+
activeTabId: number;
|
|
3648
|
+
activePaneId: number;
|
|
3649
|
+
paneResizing: boolean;
|
|
3650
|
+
contextMenu: CliPanelContextMenu;
|
|
3651
|
+
positionDropdownOpen: boolean;
|
|
3652
|
+
servicesDropdownOpen: boolean;
|
|
3653
|
+
servicesDropdownStyle: Record<string, string>;
|
|
3654
|
+
serversDropdownOpen: boolean;
|
|
3655
|
+
serversDropdownStyle: Record<string, string>;
|
|
3656
|
+
/** Status of the active tab. */
|
|
3657
|
+
status: CliPanelTabStatus;
|
|
3658
|
+
tabStatuses: Readonly<Record<number, CliPanelTabStatus>>;
|
|
3659
|
+
global: CliPanelGlobalStatus;
|
|
3660
|
+
formattedUptime: string;
|
|
3661
|
+
}
|
|
3662
|
+
|
|
3663
|
+
declare const MIN_PANE_WIDTH_PERCENT = 10;
|
|
3664
|
+
declare const MIN_PANEL_SIZE = 100;
|
|
3665
|
+
declare const DEFAULT_PANEL_HEIGHT = 600;
|
|
3666
|
+
declare const DEFAULT_PANEL_WIDTH = 400;
|
|
3667
|
+
declare const PANEL_POSITIONS: readonly CliPanelPosition[];
|
|
3668
|
+
/** Scale pane widths so they add up to 100. Returns new pane objects. */
|
|
3669
|
+
declare function normalizePaneWidths(panes: readonly CliPanelPane[]): CliPanelPane[];
|
|
3670
|
+
/** Give every pane the same width. Returns new pane objects. */
|
|
3671
|
+
declare function distributePaneWidths(panes: readonly CliPanelPane[]): CliPanelPane[];
|
|
3672
|
+
/**
|
|
3673
|
+
* Move the divider between pane `dividerIndex` and `dividerIndex + 1` by
|
|
3674
|
+
* `deltaPercent`, keeping both panes at least `MIN_PANE_WIDTH_PERCENT` wide.
|
|
3675
|
+
*/
|
|
3676
|
+
declare function resizePaneWidths(startWidths: readonly number[], dividerIndex: number, deltaPercent: number): number[];
|
|
3677
|
+
/** Clamp a dragged panel size between the minimum and the viewport. */
|
|
3678
|
+
declare function clampPanelSize(size: number, max: number): number;
|
|
3679
|
+
/**
|
|
3680
|
+
* New panel size for a drag that started at `start` and moved by
|
|
3681
|
+
* (`deltaX`, `deltaY`). Only the axis matching the position matters.
|
|
3682
|
+
*/
|
|
3683
|
+
declare function resizedPanelSize(position: CliPanelPosition, start: {
|
|
3684
|
+
width: number;
|
|
3685
|
+
height: number;
|
|
3686
|
+
}, deltaX: number, deltaY: number, viewport: CliPanelViewport): {
|
|
3687
|
+
width?: number;
|
|
3688
|
+
height?: number;
|
|
3689
|
+
};
|
|
3690
|
+
interface AnchorRect {
|
|
3691
|
+
top: number;
|
|
3692
|
+
bottom: number;
|
|
3693
|
+
left: number;
|
|
3694
|
+
right: number;
|
|
3695
|
+
}
|
|
3696
|
+
/**
|
|
3697
|
+
* Fixed-position style for a dropdown opened from `anchor`, placed on the
|
|
3698
|
+
* side of the panel that faces the page.
|
|
3699
|
+
*/
|
|
3700
|
+
declare function dropdownAnchorStyle(anchor: AnchorRect, position: CliPanelPosition, viewport: CliPanelViewport): Record<string, string>;
|
|
3701
|
+
/** "12m", "1h05m"-style uptime label. */
|
|
3702
|
+
declare function formatUptime(ms: number): string;
|
|
3703
|
+
declare function isHorizontalPosition(position: CliPanelPosition): boolean;
|
|
3704
|
+
|
|
3705
|
+
/** Poll interval for execution state, last command and notifications. */
|
|
3706
|
+
declare const EXEC_POLL_MS = 300;
|
|
3707
|
+
/** Poll interval for services, servers and uptime. */
|
|
3708
|
+
declare const GLOBAL_POLL_MS = 2000;
|
|
3709
|
+
/** Status of a tab from all of its pane engines. */
|
|
3710
|
+
declare function computeTabStatus(engines: Iterable<CliEngine>): CliPanelTabStatus;
|
|
3711
|
+
/** Services, servers and uptime of one engine. */
|
|
3712
|
+
declare function computeGlobalStatus(engine: CliEngine | undefined, now?: number): CliPanelGlobalStatus;
|
|
3713
|
+
interface CliPanelStatusTrackerListener {
|
|
3714
|
+
onTabStatus(tabId: number, status: CliPanelTabStatus): void;
|
|
3715
|
+
onGlobalStatus(status: CliPanelGlobalStatus): void;
|
|
3716
|
+
}
|
|
3717
|
+
/**
|
|
3718
|
+
* Watches the engines of every tab and reports status changes. Execution
|
|
3719
|
+
* state is polled quickly, services and servers slowly; engine events
|
|
3720
|
+
* (notifier, background services) trigger an immediate refresh.
|
|
3721
|
+
*/
|
|
3722
|
+
declare class CliPanelStatusTracker {
|
|
3723
|
+
private readonly listener;
|
|
3724
|
+
private tabs;
|
|
3725
|
+
private activeTabId?;
|
|
3726
|
+
private globalStatus;
|
|
3727
|
+
private execTimer?;
|
|
3728
|
+
private globalTimer?;
|
|
3729
|
+
constructor(listener: CliPanelStatusTrackerListener);
|
|
3730
|
+
registerEngine(tabId: number, paneId: number, engine: CliEngine): void;
|
|
3731
|
+
unregisterPane(paneId: number): void;
|
|
3732
|
+
unregisterTab(tabId: number): void;
|
|
3733
|
+
setActiveTab(tabId: number): void;
|
|
3734
|
+
/** Recompute everything now. */
|
|
3735
|
+
refresh(): void;
|
|
3736
|
+
destroy(): void;
|
|
3737
|
+
private ensurePolling;
|
|
3738
|
+
private stopPolling;
|
|
3739
|
+
private refreshTab;
|
|
3740
|
+
private refreshGlobal;
|
|
3741
|
+
}
|
|
3742
|
+
|
|
3743
|
+
/**
|
|
3744
|
+
* Framework-agnostic state and behaviour of the collapsible CLI panel:
|
|
3745
|
+
* tabs and panes, chrome (collapse, hide, maximize, position, size),
|
|
3746
|
+
* menus, drag resizing, theme sync and the status bar.
|
|
3747
|
+
*
|
|
3748
|
+
* Views subscribe with {@link subscribe} and render {@link getSnapshot};
|
|
3749
|
+
* every change produces a new immutable snapshot. Hosts may control any of
|
|
3750
|
+
* the bindable values through {@link setControlled}; the matching
|
|
3751
|
+
* `onXChange` callback is invoked whenever the panel wants to change it.
|
|
3752
|
+
*/
|
|
3753
|
+
declare class CliPanelController implements ICliPanelRef<CliEngine> {
|
|
3754
|
+
callbacks: CliPanelCallbacks;
|
|
3755
|
+
private snapshot;
|
|
3756
|
+
private internal;
|
|
3757
|
+
private controlled;
|
|
3758
|
+
private readonly listeners;
|
|
3759
|
+
private readonly engines;
|
|
3760
|
+
private readonly tracker;
|
|
3761
|
+
private readonly viewport;
|
|
3762
|
+
private readonly persistPosition;
|
|
3763
|
+
private nextTabId;
|
|
3764
|
+
private nextPaneId;
|
|
3765
|
+
private preHideCollapsed;
|
|
3766
|
+
private previousHeight;
|
|
3767
|
+
private previousWidth;
|
|
3768
|
+
private panelDrag?;
|
|
3769
|
+
private paneDrag?;
|
|
3770
|
+
private documentListenersAttached;
|
|
3771
|
+
private rootElement;
|
|
3772
|
+
private themeObserver?;
|
|
3773
|
+
constructor(options?: CliPanelControllerOptions);
|
|
3774
|
+
readonly subscribe: (listener: () => void) => (() => void);
|
|
3775
|
+
readonly getSnapshot: () => CliPanelSnapshot;
|
|
3776
|
+
/** Apply a new panel configuration (chrome buttons, theme sync). */
|
|
3777
|
+
setOptions(config: CliPanelConfig | undefined): void;
|
|
3778
|
+
/** Replace the change callbacks (wrappers call this when their props change). */
|
|
3779
|
+
setCallbacks(callbacks: CliPanelCallbacks): void;
|
|
3780
|
+
/** Update host-controlled values. Unchanged values are ignored. */
|
|
3781
|
+
setControlled(values: CliPanelControlledState): void;
|
|
3782
|
+
/** Element containing the terminals, used for theme sync. */
|
|
3783
|
+
setRootElement(element: ParentNode | null): void;
|
|
3784
|
+
/**
|
|
3785
|
+
* Stop timers, observers and document listeners. Engines are not
|
|
3786
|
+
* destroyed (their views own them). Registering an engine again
|
|
3787
|
+
* restarts status tracking, so a remounted view can reuse the controller.
|
|
3788
|
+
*/
|
|
3789
|
+
destroy(): void;
|
|
3790
|
+
/** Header collapse button: expand (creating the first tab) or collapse. */
|
|
3791
|
+
toggle(): void;
|
|
3792
|
+
open(): void;
|
|
3793
|
+
collapse(): void;
|
|
3794
|
+
toggleCollapse(): void;
|
|
3795
|
+
hide(): void;
|
|
3796
|
+
unhide(): void;
|
|
3797
|
+
toggleHide(): void;
|
|
3798
|
+
close(): void;
|
|
3799
|
+
maximize(): void;
|
|
3800
|
+
restore(): void;
|
|
3801
|
+
toggleMaximize(): void;
|
|
3802
|
+
resize(dimensions: {
|
|
3803
|
+
height?: number;
|
|
3804
|
+
width?: number;
|
|
3805
|
+
}): void;
|
|
3806
|
+
setPosition(position: CliPanelPosition): void;
|
|
3807
|
+
addTab(title?: string): number;
|
|
3808
|
+
closeTab(tabId: number): void;
|
|
3809
|
+
selectTab(tabId: number): void;
|
|
3810
|
+
renameTab(tabId: number, title: string): void;
|
|
3811
|
+
/** Switch a tab's title into inline editing. */
|
|
3812
|
+
startRename(tabId: number): void;
|
|
3813
|
+
/** Finish inline editing; an empty value keeps the old title. */
|
|
3814
|
+
commitRename(tabId: number, value: string): void;
|
|
3815
|
+
cancelRename(): void;
|
|
3816
|
+
/** Open a new tab next to `tabId` with a copy of its first terminal's content. */
|
|
3817
|
+
duplicateTab(tabId: number): number;
|
|
3818
|
+
closeOtherTabs(tabId: number): void;
|
|
3819
|
+
closeTabsToTheRight(tabId: number): void;
|
|
3820
|
+
closeAllTabs(): void;
|
|
3821
|
+
splitPane(tabId?: number): number;
|
|
3822
|
+
closePane(paneId: number): void;
|
|
3823
|
+
/** A pane was clicked: make it (and its tab) active and focus its terminal. */
|
|
3824
|
+
activatePane(tabId: number, paneId: number): void;
|
|
3825
|
+
/** Called by the view once a pane's terminal engine is running. */
|
|
3826
|
+
registerEngine(tabId: number, paneId: number, engine: CliEngine): void;
|
|
3827
|
+
getEngine(paneId?: number): CliEngine | undefined;
|
|
3828
|
+
getState(): CliPanelState;
|
|
3829
|
+
openContextMenu(tabId: number, x: number, y: number): void;
|
|
3830
|
+
closeContextMenu(): void;
|
|
3831
|
+
togglePositionDropdown(): void;
|
|
3832
|
+
/** `anchor` is the clicked status item; the dropdown is placed next to it. */
|
|
3833
|
+
toggleServicesDropdown(anchor?: Element | null): void;
|
|
3834
|
+
toggleServersDropdown(anchor?: Element | null): void;
|
|
3835
|
+
/** Close the context menu and every dropdown. */
|
|
3836
|
+
closeMenus(): void;
|
|
3837
|
+
/** Mouse down on the panel's resize bar. */
|
|
3838
|
+
startPanelResize(clientX: number, clientY: number): void;
|
|
3839
|
+
/** Mouse down on the divider before pane `dividerIndex + 1` of a tab. */
|
|
3840
|
+
startPaneResize(tabId: number, dividerIndex: number, clientX: number, containerWidth: number): void;
|
|
3841
|
+
private readonly onPanelResizeMove;
|
|
3842
|
+
private readonly onPanelResizeEnd;
|
|
3843
|
+
private endPanelResize;
|
|
3844
|
+
private readonly onPaneResizeMove;
|
|
3845
|
+
private readonly onPaneResizeEnd;
|
|
3846
|
+
private endPaneResize;
|
|
3847
|
+
private readonly onDocumentClick;
|
|
3848
|
+
private readonly onDocumentKeydown;
|
|
3849
|
+
private syncDocumentListeners;
|
|
3850
|
+
private detachDocumentListeners;
|
|
3851
|
+
/** Read the first terminal's theme and derive the panel colours from it. */
|
|
3852
|
+
syncThemeFromEngine(): void;
|
|
3853
|
+
/**
|
|
3854
|
+
* Sync now and follow the first terminal's container: the `theme`
|
|
3855
|
+
* command restyles it, which re-derives the panel colours.
|
|
3856
|
+
* Engines are registered after they start, so their theme is set.
|
|
3857
|
+
*/
|
|
3858
|
+
private startThemeSync;
|
|
3859
|
+
private stopThemeSync;
|
|
3860
|
+
private ensureInitialized;
|
|
3861
|
+
private updateCollapsed;
|
|
3862
|
+
private updateHidden;
|
|
3863
|
+
private updateMaximized;
|
|
3864
|
+
private updateHeight;
|
|
3865
|
+
private updateWidth;
|
|
3866
|
+
private updateActiveTabId;
|
|
3867
|
+
private findTab;
|
|
3868
|
+
private patchTab;
|
|
3869
|
+
/** Remove tabs without touching collapsed/initialized state. */
|
|
3870
|
+
private removeTabs;
|
|
3871
|
+
private releaseTab;
|
|
3872
|
+
private releasePane;
|
|
3873
|
+
private focusPane;
|
|
3874
|
+
private anchorStyle;
|
|
3875
|
+
private setTabStatus;
|
|
3876
|
+
private configFields;
|
|
3877
|
+
/** Resolve controlled values and derived fields on top of a snapshot. */
|
|
3878
|
+
private derive;
|
|
3879
|
+
private commit;
|
|
3880
|
+
}
|
|
3881
|
+
|
|
3882
|
+
/**
|
|
3883
|
+
* Geometry of the panel's SVG icons, shared by every framework wrapper.
|
|
3884
|
+
* All icons use a 24x24 view box, `stroke="currentColor"`, round caps and
|
|
3885
|
+
* joins, and no fill unless a shape says otherwise.
|
|
3886
|
+
*/
|
|
3887
|
+
interface SvgShape {
|
|
3888
|
+
tag: 'polyline' | 'line' | 'rect';
|
|
3889
|
+
attrs: Record<string, string>;
|
|
3890
|
+
}
|
|
3891
|
+
interface SvgIcon {
|
|
3892
|
+
size: number;
|
|
3893
|
+
strokeWidth: number;
|
|
3894
|
+
shapes: SvgShape[];
|
|
3895
|
+
}
|
|
3896
|
+
declare const SVG_VIEW_BOX = "0 0 24 24";
|
|
3897
|
+
declare const SVG_COMMON_ATTRS: Record<string, string>;
|
|
3898
|
+
declare const TERMINAL_ICON: SvgIcon;
|
|
3899
|
+
declare const HIDE_TAB_TERMINAL_ICON: SvgIcon;
|
|
3900
|
+
declare const MAXIMIZE_ICON: SvgIcon;
|
|
3901
|
+
declare const RESTORE_ICON: SvgIcon;
|
|
3902
|
+
declare const CLOSE_ICON: SvgIcon;
|
|
3903
|
+
declare const HIDE_ICON: SvgIcon;
|
|
3904
|
+
/** Chevron that points where the panel body will go when the collapse button is pressed. */
|
|
3905
|
+
declare function collapseChevronIcon(position: CliPanelPosition, collapsed: boolean): SvgIcon;
|
|
3906
|
+
/** Chevron on the small "show CLI" tab, pointing into the page. */
|
|
3907
|
+
declare function hideTabChevronIcon(position: CliPanelPosition): SvgIcon;
|
|
3908
|
+
/** Square with a filled bar on the side the panel is docked to. */
|
|
3909
|
+
declare function positionIcon(position: CliPanelPosition, size?: number): SvgIcon;
|
|
3910
|
+
/** Attributes for the `<svg>` element of an icon. */
|
|
3911
|
+
declare function svgAttrs(icon: SvgIcon): Record<string, string>;
|
|
3912
|
+
|
|
3913
|
+
/**
|
|
3914
|
+
* View helpers shared by the React, Vue and Angular panels: class names,
|
|
3915
|
+
* inline styles, labels and the lists the header and menus are built from.
|
|
3916
|
+
*/
|
|
3917
|
+
declare const PANEL_LABELS: {
|
|
3918
|
+
readonly title: "CLI";
|
|
3919
|
+
readonly showCli: "Show CLI";
|
|
3920
|
+
readonly movePanel: "Move panel";
|
|
3921
|
+
readonly hide: "Hide";
|
|
3922
|
+
readonly maximize: "Maximize";
|
|
3923
|
+
readonly restore: "Restore";
|
|
3924
|
+
readonly expand: "Expand";
|
|
3925
|
+
readonly collapse: "Collapse";
|
|
3926
|
+
readonly close: "Close";
|
|
3927
|
+
readonly newTerminal: "New terminal";
|
|
3928
|
+
readonly closeTab: "Close tab";
|
|
3929
|
+
readonly closePane: "Close pane";
|
|
3930
|
+
readonly servicesHeader: "Background Services";
|
|
3931
|
+
readonly servicesEmpty: "No services registered";
|
|
3932
|
+
readonly serversHeader: "Server Connections";
|
|
3933
|
+
readonly serversEmpty: "No servers configured";
|
|
3934
|
+
};
|
|
3935
|
+
declare const SERVICES_ICON = "\u2699";
|
|
3936
|
+
declare const UPTIME_ICON = "\u2191";
|
|
3937
|
+
declare const SUCCESS_ICON = "\u2713";
|
|
3938
|
+
declare const ERROR_ICON = "\u2717";
|
|
3939
|
+
declare const CLOSE_GLYPH = "\u00D7";
|
|
3940
|
+
declare function capitalize(value: string): string;
|
|
3941
|
+
declare function joinClasses(...classes: Array<string | false | null | undefined>): string;
|
|
3942
|
+
declare function panelWrapperClass(s: CliPanelSnapshot, extra?: string): string;
|
|
3943
|
+
declare function panelTabClass(s: CliPanelSnapshot, tab: CliPanelTab): string;
|
|
3944
|
+
/** Activity dot of a tab: running, last command failed, or idle. */
|
|
3945
|
+
declare function tabDotClass(status: CliPanelTabStatus | undefined): string;
|
|
3946
|
+
declare function panelTabDotClass(s: CliPanelSnapshot, tab: CliPanelTab): string;
|
|
3947
|
+
declare function panesContainerClass(s: CliPanelSnapshot): string;
|
|
3948
|
+
declare function paneClass(s: CliPanelSnapshot, tabId: number, paneId: number): string;
|
|
3949
|
+
declare function glowLineClass(s: CliPanelSnapshot): string;
|
|
3950
|
+
declare function positionDropdownItemClass(s: CliPanelSnapshot, position: CliPanelPosition): string;
|
|
3951
|
+
/** Size, visibility and theme variables of the panel wrapper. */
|
|
3952
|
+
declare function panelWrapperStyle(s: CliPanelSnapshot): Record<string, string>;
|
|
3953
|
+
declare function paneStyle(widthPercent: number): Record<string, string>;
|
|
3954
|
+
declare function contextMenuStyle(s: CliPanelSnapshot): Record<string, string>;
|
|
3955
|
+
interface PanelStatusIndicator {
|
|
3956
|
+
key: 'execution' | 'services' | 'lastCommand' | 'servers' | 'uptime' | 'notification';
|
|
3957
|
+
/** Extra classes on the full item (top/bottom positions). */
|
|
3958
|
+
itemClass: string;
|
|
3959
|
+
/** Extra classes on the compact item (left/right positions). */
|
|
3960
|
+
compactClass: string;
|
|
3961
|
+
/** Class of the leading dot, when the indicator shows a dot. */
|
|
3962
|
+
dotClass?: string;
|
|
3963
|
+
/** Glyph shown before the label, when the indicator shows an icon. */
|
|
3964
|
+
icon?: string;
|
|
3965
|
+
iconClass?: string;
|
|
3966
|
+
label: string;
|
|
3967
|
+
/** Tooltip of the compact variant. */
|
|
3968
|
+
title: string;
|
|
3969
|
+
/** Compact variant shows only this dot (notifications). */
|
|
3970
|
+
compactDotClass?: string;
|
|
3971
|
+
/** Which dropdown a click opens. */
|
|
3972
|
+
dropdown?: 'services' | 'servers';
|
|
3973
|
+
}
|
|
3974
|
+
/** Items of the header status bar, in display order. */
|
|
3975
|
+
declare function statusIndicators(s: CliPanelSnapshot): PanelStatusIndicator[];
|
|
3976
|
+
interface PanelPositionOption {
|
|
3977
|
+
position: CliPanelPosition;
|
|
3978
|
+
label: string;
|
|
3979
|
+
className: string;
|
|
3980
|
+
}
|
|
3981
|
+
declare function positionOptions(s: CliPanelSnapshot): PanelPositionOption[];
|
|
3982
|
+
type PanelContextMenuAction = 'rename' | 'duplicate' | 'split-right' | 'close' | 'close-others' | 'close-right' | 'close-all';
|
|
3983
|
+
interface PanelContextMenuItem {
|
|
3984
|
+
action: PanelContextMenuAction;
|
|
3985
|
+
label: string;
|
|
3986
|
+
disabled: boolean;
|
|
3987
|
+
destructive: boolean;
|
|
3988
|
+
/** Draw a separator above this item. */
|
|
3989
|
+
separatorBefore: boolean;
|
|
3990
|
+
}
|
|
3991
|
+
declare function contextMenuItems(s: CliPanelSnapshot): PanelContextMenuItem[];
|
|
3992
|
+
/** Run a context-menu action against the tab the menu was opened for. */
|
|
3993
|
+
declare function runContextMenuAction(controller: CliPanelController, action: PanelContextMenuAction): void;
|
|
3994
|
+
/** Enter commits, Escape cancels an inline tab rename. */
|
|
3995
|
+
declare function handleRenameKey(controller: CliPanelController, tabId: number, key: string, value: string): void;
|
|
3996
|
+
/** Width of the panes container the divider belongs to, for drag math. */
|
|
3997
|
+
declare function panesContainerWidth(target: EventTarget | null): number;
|
|
3998
|
+
interface PanelDropdownRow {
|
|
3999
|
+
key: string;
|
|
4000
|
+
dotClass: string;
|
|
4001
|
+
name: string;
|
|
4002
|
+
description?: string;
|
|
4003
|
+
status: string;
|
|
4004
|
+
/** Extra lines under the status (servers: API version, command count). */
|
|
4005
|
+
meta: string[];
|
|
4006
|
+
}
|
|
4007
|
+
interface PanelStatusDropdown {
|
|
4008
|
+
kind: 'services' | 'servers';
|
|
4009
|
+
header: string;
|
|
4010
|
+
emptyText: string;
|
|
4011
|
+
style: Record<string, string>;
|
|
4012
|
+
rows: PanelDropdownRow[];
|
|
4013
|
+
}
|
|
4014
|
+
/** The open services or servers dropdown, or null when neither is open. */
|
|
4015
|
+
declare function openStatusDropdown(s: CliPanelSnapshot): PanelStatusDropdown | null;
|
|
4016
|
+
|
|
4017
|
+
export { API_VERSION, CLI_ENV_GLOBAL_PERMISSION, CLI_FRAMEWORK_SERVICE, CLOSE_GLYPH, CLOSE_ICON, CLi_Name_Art, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliBootLog, CliBootLog_TOKEN, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliEventsCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, CliFalseCommandProcessor, CliFeedbackCommandProcessor, CliFontSizeCommandProcessor, CliFullScreenManager, CliHelpCommandProcessor, CliHistoryCommandProcessor, CliHotKeysCommandProcessor, CliHtopCommandProcessor, CliHttpClient, CliInputReader, CliJsonCommandProcessor, CliKeyValueStore, CliKeyValueStore_TOKEN, CliKillCommandProcessor, CliLogger, CliLoremCommandProcessor, CliModuleRegistry_TOKEN, CliNanoCommandProcessor, CliNotifier, CliOpenCommandProcessor, CliPackageManagerService, CliPackageManagerService_TOKEN, CliPackagesCommandProcessor, CliPanelController, CliPanelStatusTracker, CliPermissionRegistry, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliScriptSyntaxError, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestCommandProcessor, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliTrueCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, DEFAULT_GLOBAL_STATUS, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH, DEFAULT_TAB_STATUS, ERROR_ICON, EXEC_POLL_MS, GLOBAL_POLL_MS, HIDE_ICON, HIDE_TAB_TERMINAL_ICON, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, ICliScriptRunner_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, MAXIMIZE_ICON, MIN_PANEL_SIZE, MIN_PANE_WIDTH_PERCENT, OverlayAddon, PANEL_LABELS, PANEL_POSITIONS, ProcessExitedError, RESTORE_ICON, SERVICES_ICON, SUCCESS_ICON, SVG_COMMON_ATTRS, SVG_VIEW_BOX, ScriptLoaderService, SyntaxHighlighterRegistry_TOKEN, TERMINAL_ICON, UPTIME_ICON, appendOutputToFile, appendStderrToFile, applyEnvironmentChange, builtinProcessors, capitalize, clampPanelSize, cliScriptRunner, collapseChevronIcon, computeDiff, computeGlobalStatus, computeTabStatus, contextGlobalParameter, contextMenuItems, contextMenuStyle, createCliEngine, createServerModule, defaultFontSize, describeShellClose, distributePaneWidths, dropdownAnchorStyle, executeOnServer, expandBraces, expandEnvironmentVars, expandGlobs, formatDiff, formatUptime, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, glowLineClass, greetingModule, groupBy, handleRenameKey, helpGlobalParameter, hideTabChevronIcon, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, isHorizontalPosition, isWasmAccelerated, joinClasses, matchGlob, mergeCliOptions, miscProcessors, normalizePaneWidths, openLink, openStatusDropdown, paneClass, paneStyle, panelTabClass, panelTabDotClass, panelWrapperClass, panelWrapperStyle, panesContainerClass, panesContainerWidth, parseAssignments, parseScript, positionDropdownItemClass, positionIcon, positionOptions, reconcileArgs, renderServerResponse, renderSingleOutput, resizePaneWidths, resizedPanelSize, resolveCliHostConfig, runContextMenuAction, runScript, splitWords, statusIndicators, substituteCommands, substituteVars, svgAttrs, systemProcessors, tabDotClass, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
|
|
4018
|
+
export type { AnchorRect, CdnSourceName, CliBootLogOptions, CliEngineOptions, CliEnvironmentChange, CliEnvironmentProfile, CliEnvironmentScope, CliEnvironmentSnapshot, CliEnvironmentSource, CliExecutionContextDeps, CliHostConfig, CliPanelCallbacks, CliPanelContextMenu, CliPanelControlledState, CliPanelControllerOptions, CliPanelExecutionState, CliPanelGlobalStatus, CliPanelPane, CliPanelServerDetail, CliPanelServerState, CliPanelServiceDetail, CliPanelSnapshot, CliPanelStatusTrackerListener, CliPanelTab, CliPanelTabStatus, CliPanelViewport, CliTestResult, CliWelcomeMessageConfig, CommandParserOutput, CommandPart, ConfigureState, CreateCliEngineConfig, DefaultServerProvider, DiffLine, DiffType, ICliEnvironment, ICliExecutionHost, ICliScriptRunOptions, ICliScriptRunner, ICliStateStoreManager, ICliWasmAccelerator, InitializeServicesOptions, InitializeServicesResult, MultiProxyEntry, PanelContextMenuAction, PanelContextMenuItem, PanelDropdownRow, PanelPositionOption, PanelStatusDropdown, PanelStatusIndicator, ParsedArg, ParsedToken, SvgIcon, SvgShape, TerminalSetupResult, ThemeState };
|