@qodalis/cli 2.0.0-beta.11 → 2.0.0-beta.13
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/assets/cli-panel.css +394 -0
- package/package.json +2 -2
- package/public-api.d.mts +154 -9
- package/public-api.d.ts +154 -9
- package/public-api.js +687 -386
- package/public-api.js.map +1 -1
- package/public-api.mjs +685 -388
- package/public-api.mjs.map +1 -1
- package/wasm/qodalis_cli_wasm_bg.wasm +0 -0
package/public-api.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CliLogLevel, DefaultThemes, DefaultThemeInfos, DefaultLibraryAuthor, CliIcon, CliForegroundColor, LIBRARY_VERSION as LIBRARY_VERSION$1, resolveConfigurationCategories, ICliTranslationService_TOKEN, ServerVersionNegotiator, formatJson, visibleLength, stripAnsi, getRightOfWord, CancellablePromise, getParameterValue, CLI_CONFIGURE_STORE_NAME, CliModuleRegistry, initializeBrowserEnvironment, satisfiesVersionRange, ICliDragDropService_TOKEN, ICliCompletionProvider_TOKEN, delay, colorFirstWord, clearTerminalLine } from '@qodalis/cli-core';
|
|
1
|
+
import { CliLogLevel, DefaultThemes, DefaultThemeInfos, DefaultLibraryAuthor, CliIcon, CliForegroundColor, LIBRARY_VERSION as LIBRARY_VERSION$1, resolveConfigurationCategories, ICliTranslationService_TOKEN, resolveHeaders, ServerVersionNegotiator, buildAuthenticatedWebSocketUrl, formatJson, visibleLength, stripAnsi, getRightOfWord, CancellablePromise, getParameterValue, CLI_CONFIGURE_STORE_NAME, CliModuleRegistry, initializeBrowserEnvironment, satisfiesVersionRange, ICliDragDropService_TOKEN, ICliServerAuthService_TOKEN, ICliCompletionProvider_TOKEN, delay, colorFirstWord, clearTerminalLine, ICliServerAuthTokenProvider_TOKEN } from '@qodalis/cli-core';
|
|
2
2
|
export { ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN } from '@qodalis/cli-core';
|
|
3
3
|
import { Subject, BehaviorSubject } from 'rxjs';
|
|
4
4
|
import { map, distinctUntilChanged } from 'rxjs/operators';
|
|
@@ -408,9 +408,11 @@ var ICliPingServerService_TOKEN = "cli-ping-server-service";
|
|
|
408
408
|
var CliModuleRegistry_TOKEN = "cli-module-registry";
|
|
409
409
|
var CliBackgroundServiceRegistry_TOKEN = "cli-background-service-registry";
|
|
410
410
|
var CliPackageManagerService_TOKEN = "cli-package-manager-service";
|
|
411
|
+
var CliKeyValueStore_TOKEN = "cli-key-value-store";
|
|
412
|
+
var SyntaxHighlighterRegistry_TOKEN = "syntax-highlighter-registry";
|
|
411
413
|
|
|
412
414
|
// src/lib/version.ts
|
|
413
|
-
var LIBRARY_VERSION = "2.0.0-beta.
|
|
415
|
+
var LIBRARY_VERSION = "2.0.0-beta.13";
|
|
414
416
|
var API_VERSION = 2;
|
|
415
417
|
var CliAliasCommandProcessor = class {
|
|
416
418
|
constructor() {
|
|
@@ -473,7 +475,7 @@ var CliAliasCommandProcessor = class {
|
|
|
473
475
|
);
|
|
474
476
|
}
|
|
475
477
|
async processCommand(command2, context2) {
|
|
476
|
-
const registry = context2.services.
|
|
478
|
+
const registry = context2.services.getRequired(
|
|
477
479
|
CliProcessorsRegistry_TOKEN
|
|
478
480
|
);
|
|
479
481
|
const { writer } = context2;
|
|
@@ -2813,7 +2815,7 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
2813
2815
|
];
|
|
2814
2816
|
}
|
|
2815
2817
|
async processCommand(command2, context2) {
|
|
2816
|
-
const registry = context2.services.
|
|
2818
|
+
const registry = context2.services.getRequired(
|
|
2817
2819
|
CliProcessorsRegistry_TOKEN
|
|
2818
2820
|
);
|
|
2819
2821
|
const pluginCategories = resolveConfigurationCategories(registry);
|
|
@@ -2910,10 +2912,10 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
2910
2912
|
if (stateKey === "system") {
|
|
2911
2913
|
const langOption = options.find((o) => o.key === "language");
|
|
2912
2914
|
if (langOption) {
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2915
|
+
const translator = context2.services.get(
|
|
2916
|
+
ICliTranslationService_TOKEN
|
|
2917
|
+
);
|
|
2918
|
+
if (translator) {
|
|
2917
2919
|
const locales = translator.getAvailableLocales();
|
|
2918
2920
|
if (locales.length > 0) {
|
|
2919
2921
|
langOption.options = locales.map((l) => ({
|
|
@@ -2921,7 +2923,6 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
2921
2923
|
value: l
|
|
2922
2924
|
}));
|
|
2923
2925
|
}
|
|
2924
|
-
} catch {
|
|
2925
2926
|
}
|
|
2926
2927
|
}
|
|
2927
2928
|
}
|
|
@@ -3066,13 +3067,10 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
3066
3067
|
}
|
|
3067
3068
|
}
|
|
3068
3069
|
if (settings["language"]) {
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
|
|
3073
|
-
translator.setLocale(settings["language"]);
|
|
3074
|
-
} catch {
|
|
3075
|
-
}
|
|
3070
|
+
const translator = context2.services.get(
|
|
3071
|
+
ICliTranslationService_TOKEN
|
|
3072
|
+
);
|
|
3073
|
+
translator?.setLocale(settings["language"]);
|
|
3076
3074
|
}
|
|
3077
3075
|
if (context2.terminal?.options) {
|
|
3078
3076
|
if (settings["cursorBlink"] !== void 0) {
|
|
@@ -3102,7 +3100,7 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
3102
3100
|
aliases: ["ls"],
|
|
3103
3101
|
description: "List all configuration options and their current values",
|
|
3104
3102
|
processCommand: async (_, context2) => {
|
|
3105
|
-
const registry = context2.services.
|
|
3103
|
+
const registry = context2.services.getRequired(
|
|
3106
3104
|
CliProcessorsRegistry_TOKEN
|
|
3107
3105
|
);
|
|
3108
3106
|
const allOptions = this.getAllOptions(registry);
|
|
@@ -3164,7 +3162,7 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
3164
3162
|
}
|
|
3165
3163
|
const category = path.substring(0, dotIndex);
|
|
3166
3164
|
const key = path.substring(dotIndex + 1);
|
|
3167
|
-
const registry = context2.services.
|
|
3165
|
+
const registry = context2.services.getRequired(
|
|
3168
3166
|
CliProcessorsRegistry_TOKEN
|
|
3169
3167
|
);
|
|
3170
3168
|
const allOptions = this.getAllOptions(registry);
|
|
@@ -3216,7 +3214,7 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
3216
3214
|
}
|
|
3217
3215
|
const category = path.substring(0, dotIndex);
|
|
3218
3216
|
const key = path.substring(dotIndex + 1);
|
|
3219
|
-
const registry = context2.services.
|
|
3217
|
+
const registry = context2.services.getRequired(
|
|
3220
3218
|
CliProcessorsRegistry_TOKEN
|
|
3221
3219
|
);
|
|
3222
3220
|
const allOptions = this.getAllOptions(registry);
|
|
@@ -3276,7 +3274,7 @@ var CliConfigureCommandProcessor = class _CliConfigureCommandProcessor {
|
|
|
3276
3274
|
t.t("cli.configure.system_reset", "System configuration reset to defaults")
|
|
3277
3275
|
);
|
|
3278
3276
|
} else {
|
|
3279
|
-
const registry = context2.services.
|
|
3277
|
+
const registry = context2.services.getRequired(
|
|
3280
3278
|
CliProcessorsRegistry_TOKEN
|
|
3281
3279
|
);
|
|
3282
3280
|
const categories2 = resolveConfigurationCategories(registry);
|
|
@@ -3672,7 +3670,7 @@ var CliHelpCommandProcessor = class {
|
|
|
3672
3670
|
async processCommand(command2, context2) {
|
|
3673
3671
|
const { writer } = context2;
|
|
3674
3672
|
const t = context2.translator;
|
|
3675
|
-
const registry = context2.services.
|
|
3673
|
+
const registry = context2.services.getRequired(
|
|
3676
3674
|
CliProcessorsRegistry_TOKEN
|
|
3677
3675
|
);
|
|
3678
3676
|
const [_, ...commandsToHelp] = command2.command.split(" ");
|
|
@@ -3772,24 +3770,23 @@ var CliHelpCommandProcessor = class {
|
|
|
3772
3770
|
writeProcessorDescription(processor, context2) {
|
|
3773
3771
|
const { writer } = context2;
|
|
3774
3772
|
const t = context2.translator;
|
|
3775
|
-
const icon = processor.metadata?.icon || "";
|
|
3776
|
-
const name = `${BOLD}${writer.wrapInColor(processor.command, CliForegroundColor.Cyan)}${RESET}`;
|
|
3777
3773
|
const version = `${DIM}v${processor.version || "1.0.0"}${RESET}`;
|
|
3778
|
-
|
|
3779
|
-
writer.writeln(` ${icon}${icon ? " " : ""}${name} ${version}`);
|
|
3774
|
+
const headerLines = [];
|
|
3780
3775
|
if (processor.description) {
|
|
3781
|
-
|
|
3782
|
-
processor.description,
|
|
3783
|
-
processor.command,
|
|
3784
|
-
context2
|
|
3776
|
+
headerLines.push(
|
|
3777
|
+
this.translateDescription(processor.description, processor.command, context2)
|
|
3785
3778
|
);
|
|
3786
|
-
writer.writeln(` ${desc}`);
|
|
3787
3779
|
}
|
|
3788
3780
|
if (processor.aliases?.length) {
|
|
3789
|
-
|
|
3790
|
-
|
|
3781
|
+
headerLines.push(
|
|
3782
|
+
`${DIM}${t.t("cli.help.aliases", "Aliases:")}${RESET} ${processor.aliases.map((a) => writer.wrapInColor(a, CliForegroundColor.Magenta)).join(", ")}`
|
|
3791
3783
|
);
|
|
3792
3784
|
}
|
|
3785
|
+
writer.writeln();
|
|
3786
|
+
writer.writeBox(headerLines, {
|
|
3787
|
+
title: `${writer.wrapInColor(processor.command, CliForegroundColor.Cyan)} ${version}`,
|
|
3788
|
+
borderColor: CliForegroundColor.White
|
|
3789
|
+
});
|
|
3793
3790
|
if (processor.originalProcessor) {
|
|
3794
3791
|
writer.writeln();
|
|
3795
3792
|
writer.writeln(
|
|
@@ -3955,20 +3952,13 @@ var CliVersionCommandProcessor = class {
|
|
|
3955
3952
|
writer.writeln(
|
|
3956
3953
|
writer.wrapInColor(getCliNameArt(context2.terminal.cols), CliForegroundColor.Cyan)
|
|
3957
3954
|
);
|
|
3958
|
-
|
|
3959
|
-
|
|
3960
|
-
|
|
3961
|
-
|
|
3962
|
-
|
|
3963
|
-
|
|
3964
|
-
|
|
3965
|
-
}
|
|
3966
|
-
writer.writeln(
|
|
3967
|
-
` ${DIM2}Framework${RESET2} ${writer.wrapInColor(framework, CliForegroundColor.Cyan)}`
|
|
3968
|
-
);
|
|
3969
|
-
writer.writeln(
|
|
3970
|
-
` ${DIM2}Docs${RESET2} ${writer.wrapInColor("https://cli.qodalis.com/docs/", CliForegroundColor.Blue)}`
|
|
3971
|
-
);
|
|
3955
|
+
const framework = context2.services.get("cli-framework") ?? "vanilla";
|
|
3956
|
+
writer.writeBox([
|
|
3957
|
+
`${DIM2}CLI${RESET2} ${writer.wrapInColor(`v${LIBRARY_VERSION}`, CliForegroundColor.Green)}`,
|
|
3958
|
+
`${DIM2}Core${RESET2} ${writer.wrapInColor(`v${LIBRARY_VERSION$1}`, CliForegroundColor.Green)}`,
|
|
3959
|
+
`${DIM2}Framework${RESET2} ${writer.wrapInColor(framework, CliForegroundColor.Cyan)}`,
|
|
3960
|
+
`${DIM2}Docs${RESET2} ${writer.wrapInColor("https://cli.qodalis.com/docs/", CliForegroundColor.Blue)}`
|
|
3961
|
+
], { borderColor: CliForegroundColor.White });
|
|
3972
3962
|
writer.writeln();
|
|
3973
3963
|
}
|
|
3974
3964
|
writeDescription(context2) {
|
|
@@ -4026,11 +4016,7 @@ function collectSystemInfo(context2) {
|
|
|
4026
4016
|
const lines = [];
|
|
4027
4017
|
lines.push(`- **CLI Version:** ${LIBRARY_VERSION}`);
|
|
4028
4018
|
lines.push(`- **Core Version:** ${LIBRARY_VERSION$1}`);
|
|
4029
|
-
|
|
4030
|
-
try {
|
|
4031
|
-
framework = context2.services.get("cli-framework");
|
|
4032
|
-
} catch {
|
|
4033
|
-
}
|
|
4019
|
+
const framework = context2.services.get("cli-framework") ?? "vanilla";
|
|
4034
4020
|
lines.push(`- **Framework:** ${framework}`);
|
|
4035
4021
|
lines.push(`- **Terminal:** ${context2.terminal.cols}x${context2.terminal.rows}`);
|
|
4036
4022
|
if (typeof navigator !== "undefined") {
|
|
@@ -4102,12 +4088,8 @@ async function runInteractiveFlow(type, initialTitle, context2) {
|
|
|
4102
4088
|
`${writer.wrapInColor("\u2500\u2500 System Info (auto-attached) \u2500\u2500", CliForegroundColor.Cyan)}`
|
|
4103
4089
|
);
|
|
4104
4090
|
writer.writeln(` CLI: ${LIBRARY_VERSION} Core: ${LIBRARY_VERSION$1}`);
|
|
4105
|
-
|
|
4106
|
-
|
|
4107
|
-
framework = context2.services.get("cli-framework");
|
|
4108
|
-
} catch {
|
|
4109
|
-
}
|
|
4110
|
-
writer.writeln(` Framework: ${framework} Terminal: ${context2.terminal.cols}x${context2.terminal.rows}`);
|
|
4091
|
+
const previewFramework = context2.services.get("cli-framework") ?? "vanilla";
|
|
4092
|
+
writer.writeln(` Framework: ${previewFramework} Terminal: ${context2.terminal.cols}x${context2.terminal.rows}`);
|
|
4111
4093
|
if (typeof navigator !== "undefined") {
|
|
4112
4094
|
writer.writeln(` Platform: ${navigator.platform} Language: ${navigator.language}`);
|
|
4113
4095
|
}
|
|
@@ -4249,7 +4231,7 @@ var CliHistoryCommandProcessor = class {
|
|
|
4249
4231
|
command: "clear",
|
|
4250
4232
|
description: "Clears the command history",
|
|
4251
4233
|
processCommand: async (_, context2) => {
|
|
4252
|
-
const commandHistory = context2.services.
|
|
4234
|
+
const commandHistory = context2.services.getRequired(
|
|
4253
4235
|
CliCommandHistory_TOKEN
|
|
4254
4236
|
);
|
|
4255
4237
|
await commandHistory.clearHistory();
|
|
@@ -4272,7 +4254,7 @@ var CliHistoryCommandProcessor = class {
|
|
|
4272
4254
|
description: "Search command history for a pattern",
|
|
4273
4255
|
parameters: searchParameters,
|
|
4274
4256
|
processCommand: async (cmd, context2) => {
|
|
4275
|
-
const commandHistory = context2.services.
|
|
4257
|
+
const commandHistory = context2.services.getRequired(
|
|
4276
4258
|
CliCommandHistory_TOKEN
|
|
4277
4259
|
);
|
|
4278
4260
|
const query = (cmd.value ?? "").trim();
|
|
@@ -4326,7 +4308,7 @@ var CliHistoryCommandProcessor = class {
|
|
|
4326
4308
|
}
|
|
4327
4309
|
async processCommand(_, context2) {
|
|
4328
4310
|
const { writer } = context2;
|
|
4329
|
-
const commandHistory = context2.services.
|
|
4311
|
+
const commandHistory = context2.services.getRequired(
|
|
4330
4312
|
CliCommandHistory_TOKEN
|
|
4331
4313
|
);
|
|
4332
4314
|
const history = commandHistory.getHistory();
|
|
@@ -4773,6 +4755,7 @@ var CliPackagesCommandProcessor = class {
|
|
|
4773
4755
|
const { progressBar, writer } = context2;
|
|
4774
4756
|
const { signal, cleanup } = scope.createAbortSignal(context2);
|
|
4775
4757
|
progressBar.show();
|
|
4758
|
+
context2.notifier.info("Browsing packages");
|
|
4776
4759
|
const prefix = packagesManager.QODALIS_COMMAND_PREFIX;
|
|
4777
4760
|
const knownShortNames = [
|
|
4778
4761
|
"browser-storage",
|
|
@@ -4965,6 +4948,7 @@ var CliPackagesCommandProcessor = class {
|
|
|
4965
4948
|
const packages = command2.value.split(" ");
|
|
4966
4949
|
for (const pkg of packages) {
|
|
4967
4950
|
if (signal.aborted) break;
|
|
4951
|
+
context2.notifier.info(`Installing ${pkg}`);
|
|
4968
4952
|
await scope.addPackage(pkg, context2, signal);
|
|
4969
4953
|
}
|
|
4970
4954
|
cleanup();
|
|
@@ -5005,6 +4989,7 @@ var CliPackagesCommandProcessor = class {
|
|
|
5005
4989
|
const packages = command2.value.split(" ");
|
|
5006
4990
|
for (const pkg of packages) {
|
|
5007
4991
|
if (signal.aborted) break;
|
|
4992
|
+
context2.notifier.info(`Removing ${pkg}`);
|
|
5008
4993
|
await scope.removePackage(pkg, context2);
|
|
5009
4994
|
}
|
|
5010
4995
|
cleanup();
|
|
@@ -5040,6 +5025,7 @@ var CliPackagesCommandProcessor = class {
|
|
|
5040
5025
|
const fullName = name.startsWith(prefix) ? name : `${prefix}${name}`;
|
|
5041
5026
|
progressBar.show();
|
|
5042
5027
|
progressBar.setText(`Fetching versions for ${name}`);
|
|
5028
|
+
context2.notifier.info(`Fetching versions for ${name}`);
|
|
5043
5029
|
try {
|
|
5044
5030
|
const response = await scriptsLoader.getScript(
|
|
5045
5031
|
`https://registry.npmjs.org/${encodeURIComponent(fullName)}`,
|
|
@@ -5503,11 +5489,11 @@ var CliPackagesCommandProcessor = class {
|
|
|
5503
5489
|
);
|
|
5504
5490
|
}
|
|
5505
5491
|
async initialize(context2) {
|
|
5506
|
-
this.registry = context2.services.
|
|
5492
|
+
this.registry = context2.services.getRequired(
|
|
5507
5493
|
CliProcessorsRegistry_TOKEN
|
|
5508
5494
|
);
|
|
5509
|
-
const store = context2.services.
|
|
5510
|
-
|
|
5495
|
+
const store = context2.services.getRequired(
|
|
5496
|
+
CliKeyValueStore_TOKEN
|
|
5511
5497
|
);
|
|
5512
5498
|
this.packagesManager.setStore(store);
|
|
5513
5499
|
context2.services.set([{
|
|
@@ -5773,10 +5759,11 @@ var CliPackagesCommandProcessor = class {
|
|
|
5773
5759
|
}
|
|
5774
5760
|
};
|
|
5775
5761
|
var CliServerConnection = class _CliServerConnection {
|
|
5776
|
-
constructor(_config, _backgroundServices, _logger) {
|
|
5762
|
+
constructor(_config, _backgroundServices, _logger, _authService) {
|
|
5777
5763
|
this._config = _config;
|
|
5778
5764
|
this._backgroundServices = _backgroundServices;
|
|
5779
5765
|
this._logger = _logger;
|
|
5766
|
+
this._authService = _authService;
|
|
5780
5767
|
this._connected = false;
|
|
5781
5768
|
this._commands = [];
|
|
5782
5769
|
this._capabilities = null;
|
|
@@ -5815,10 +5802,21 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
5815
5802
|
get apiVersion() {
|
|
5816
5803
|
return this._apiVersion;
|
|
5817
5804
|
}
|
|
5805
|
+
/**
|
|
5806
|
+
* Resolve auth headers for this server connection.
|
|
5807
|
+
* Uses the auth service (which merges config headers with registered
|
|
5808
|
+
* ICliServerAuthTokenProviders), or falls back to config headers directly.
|
|
5809
|
+
*/
|
|
5810
|
+
resolveAuthHeaders() {
|
|
5811
|
+
if (this._authService) {
|
|
5812
|
+
return this._authService.getHeaders(this._config.name, this._config.headers);
|
|
5813
|
+
}
|
|
5814
|
+
return resolveHeaders(this._config.headers);
|
|
5815
|
+
}
|
|
5818
5816
|
async connect() {
|
|
5819
5817
|
try {
|
|
5820
5818
|
const baseUrl = this.normalizeUrl(this._config.url);
|
|
5821
|
-
const negotiated = await ServerVersionNegotiator.discover(baseUrl);
|
|
5819
|
+
const negotiated = await ServerVersionNegotiator.discover(baseUrl, () => this.resolveAuthHeaders());
|
|
5822
5820
|
if (negotiated) {
|
|
5823
5821
|
this._apiVersion = negotiated.apiVersion;
|
|
5824
5822
|
this._basePath = negotiated.basePath;
|
|
@@ -6013,7 +6011,10 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
6013
6011
|
type: "daemon",
|
|
6014
6012
|
onStart: async (ctx) => {
|
|
6015
6013
|
const baseUrl = this.normalizeUrl(this._config.url);
|
|
6016
|
-
const wsUrl =
|
|
6014
|
+
const wsUrl = buildAuthenticatedWebSocketUrl(
|
|
6015
|
+
this.toWebSocketUrl(baseUrl) + "/ws/v1/qcli/events",
|
|
6016
|
+
() => this.resolveAuthHeaders()
|
|
6017
|
+
);
|
|
6017
6018
|
ctx.log(`Connecting to ${wsUrl}`);
|
|
6018
6019
|
this._eventSocket = new WebSocket(wsUrl);
|
|
6019
6020
|
this._eventSocket.onopen = () => {
|
|
@@ -6063,7 +6064,10 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
6063
6064
|
connectEventSocketDirect() {
|
|
6064
6065
|
try {
|
|
6065
6066
|
const baseUrl = this.normalizeUrl(this._config.url);
|
|
6066
|
-
const wsUrl =
|
|
6067
|
+
const wsUrl = buildAuthenticatedWebSocketUrl(
|
|
6068
|
+
this.toWebSocketUrl(baseUrl) + "/ws/v1/qcli/events",
|
|
6069
|
+
() => this.resolveAuthHeaders()
|
|
6070
|
+
);
|
|
6067
6071
|
this._eventSocket = new WebSocket(wsUrl);
|
|
6068
6072
|
this._eventSocket.onopen = () => {
|
|
6069
6073
|
this._wsReconnectAttempts = 0;
|
|
@@ -6166,7 +6170,7 @@ var CliServerConnection = class _CliServerConnection {
|
|
|
6166
6170
|
const controller = new AbortController();
|
|
6167
6171
|
const timer = setTimeout(() => controller.abort(), timeout);
|
|
6168
6172
|
const headers = {
|
|
6169
|
-
...this.
|
|
6173
|
+
...this.resolveAuthHeaders(),
|
|
6170
6174
|
...init?.headers ?? {}
|
|
6171
6175
|
};
|
|
6172
6176
|
return fetch(url, {
|
|
@@ -6246,6 +6250,8 @@ async function executeOnServer(connection, serverName, descriptor, command2, con
|
|
|
6246
6250
|
command: commandPath && commandPath.length > 0 ? commandPath[0] : descriptor.command,
|
|
6247
6251
|
chainCommands: commandPath && commandPath.length > 1 ? commandPath.slice(1) : []
|
|
6248
6252
|
};
|
|
6253
|
+
const cmdLabel = commandPath && commandPath.length > 0 ? commandPath.join(" ") : descriptor.command;
|
|
6254
|
+
context2.notifier.info(`executing command: ${cmdLabel} on server ${serverName}`);
|
|
6249
6255
|
try {
|
|
6250
6256
|
if (connection.capabilities?.streaming) {
|
|
6251
6257
|
const result = await connection.executeStream(
|
|
@@ -6433,8 +6439,9 @@ var CliServerMultiProxyProcessor = class _CliServerMultiProxyProcessor {
|
|
|
6433
6439
|
// src/lib/server/cli-server-manager.ts
|
|
6434
6440
|
var CliServerManager_TOKEN = "cli-server-manager";
|
|
6435
6441
|
var CliServerManager = class {
|
|
6436
|
-
constructor(registry) {
|
|
6442
|
+
constructor(registry, authService) {
|
|
6437
6443
|
this.registry = registry;
|
|
6444
|
+
this.authService = authService;
|
|
6438
6445
|
this.connections = /* @__PURE__ */ new Map();
|
|
6439
6446
|
this._defaultServer = null;
|
|
6440
6447
|
}
|
|
@@ -6455,7 +6462,7 @@ var CliServerManager = class {
|
|
|
6455
6462
|
this._backgroundServices = backgroundServices;
|
|
6456
6463
|
for (const config of servers) {
|
|
6457
6464
|
if (config.enabled === false) continue;
|
|
6458
|
-
const connection = new CliServerConnection(config, backgroundServices, cliLogger);
|
|
6465
|
+
const connection = new CliServerConnection(config, backgroundServices, cliLogger, this.authService);
|
|
6459
6466
|
this.connections.set(config.name, connection);
|
|
6460
6467
|
connection.onDisconnect = () => {
|
|
6461
6468
|
this.handleDisconnect(config.name);
|
|
@@ -7006,7 +7013,7 @@ var CliDebugCommandProcessor = class {
|
|
|
7006
7013
|
metadata: { icon: CliIcon.Extension, module: "system" },
|
|
7007
7014
|
processCommand: async (_, context2) => {
|
|
7008
7015
|
const { writer } = context2;
|
|
7009
|
-
const registry = context2.services.
|
|
7016
|
+
const registry = context2.services.getRequired(
|
|
7010
7017
|
CliProcessorsRegistry_TOKEN
|
|
7011
7018
|
);
|
|
7012
7019
|
writer.writeln(
|
|
@@ -7057,12 +7064,10 @@ var CliDebugCommandProcessor = class {
|
|
|
7057
7064
|
metadata: { icon: CliIcon.Module, module: "system" },
|
|
7058
7065
|
processCommand: async (_, context2) => {
|
|
7059
7066
|
const { writer } = context2;
|
|
7060
|
-
|
|
7061
|
-
|
|
7062
|
-
|
|
7063
|
-
|
|
7064
|
-
);
|
|
7065
|
-
} catch {
|
|
7067
|
+
const moduleRegistry = context2.services.get(
|
|
7068
|
+
CliModuleRegistry_TOKEN
|
|
7069
|
+
);
|
|
7070
|
+
if (!moduleRegistry) {
|
|
7066
7071
|
writer.writeError("Module registry not available.");
|
|
7067
7072
|
return;
|
|
7068
7073
|
}
|
|
@@ -7103,7 +7108,7 @@ var CliDebugCommandProcessor = class {
|
|
|
7103
7108
|
metadata: { icon: CliIcon.Database, module: "system" },
|
|
7104
7109
|
processCommand: async (_, context2) => {
|
|
7105
7110
|
const { writer } = context2;
|
|
7106
|
-
const storeManager = context2.services.
|
|
7111
|
+
const storeManager = context2.services.getRequired(
|
|
7107
7112
|
CliStateStoreManager_TOKEN
|
|
7108
7113
|
);
|
|
7109
7114
|
const entries = storeManager.getStoreEntries();
|
|
@@ -7182,11 +7187,7 @@ var CliDebugCommandProcessor = class {
|
|
|
7182
7187
|
writer.writeln(
|
|
7183
7188
|
` ${writer.wrapInColor("CLI Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION}`
|
|
7184
7189
|
);
|
|
7185
|
-
|
|
7186
|
-
try {
|
|
7187
|
-
framework = context2.services.get("cli-framework");
|
|
7188
|
-
} catch {
|
|
7189
|
-
}
|
|
7190
|
+
const framework = context2.services.get("cli-framework") ?? "vanilla";
|
|
7190
7191
|
writer.writeln(
|
|
7191
7192
|
` ${writer.wrapInColor("Framework:", CliForegroundColor.Cyan)} ${framework}`
|
|
7192
7193
|
);
|
|
@@ -7227,7 +7228,7 @@ var CliDebugCommandProcessor = class {
|
|
|
7227
7228
|
metadata: { icon: CliIcon.Logs, module: "system" },
|
|
7228
7229
|
processCommand: async (_, context2) => {
|
|
7229
7230
|
const { writer } = context2;
|
|
7230
|
-
const history = context2.services.
|
|
7231
|
+
const history = context2.services.getRequired(
|
|
7231
7232
|
CliCommandHistory_TOKEN
|
|
7232
7233
|
);
|
|
7233
7234
|
const commands = history.getHistory();
|
|
@@ -7316,14 +7317,14 @@ var CliDebugCommandProcessor = class {
|
|
|
7316
7317
|
writer.writeln(
|
|
7317
7318
|
` ${online ? CliIcon.CheckIcon : CliIcon.CrossIcon} Network: ${online ? "online" : "offline"}`
|
|
7318
7319
|
);
|
|
7319
|
-
const registry = context2.services.
|
|
7320
|
+
const registry = context2.services.getRequired(
|
|
7320
7321
|
CliProcessorsRegistry_TOKEN
|
|
7321
7322
|
);
|
|
7322
7323
|
writer.writeln(
|
|
7323
7324
|
` ${CliIcon.CheckIcon} Processors: ${registry.processors.length} loaded`
|
|
7324
7325
|
);
|
|
7325
7326
|
try {
|
|
7326
|
-
const moduleRegistry = context2.services.
|
|
7327
|
+
const moduleRegistry = context2.services.getRequired(
|
|
7327
7328
|
CliModuleRegistry_TOKEN
|
|
7328
7329
|
);
|
|
7329
7330
|
const modules = moduleRegistry.getAll();
|
|
@@ -7339,7 +7340,7 @@ var CliDebugCommandProcessor = class {
|
|
|
7339
7340
|
writer.writeln(
|
|
7340
7341
|
` ${wasmActive ? CliIcon.CheckIcon : CliIcon.WarningIcon} WASM Accelerator: ${wasmActive ? "loaded" : "using JS fallback"}`
|
|
7341
7342
|
);
|
|
7342
|
-
const historyService = context2.services.
|
|
7343
|
+
const historyService = context2.services.getRequired(
|
|
7343
7344
|
CliCommandHistory_TOKEN
|
|
7344
7345
|
);
|
|
7345
7346
|
writer.writeln(
|
|
@@ -7353,13 +7354,13 @@ var CliDebugCommandProcessor = class {
|
|
|
7353
7354
|
metadata: { icon: CliIcon.Save, module: "system" },
|
|
7354
7355
|
processCommand: async (_, context2) => {
|
|
7355
7356
|
const { writer } = context2;
|
|
7356
|
-
const registry = context2.services.
|
|
7357
|
+
const registry = context2.services.getRequired(
|
|
7357
7358
|
CliProcessorsRegistry_TOKEN
|
|
7358
7359
|
);
|
|
7359
|
-
const history = context2.services.
|
|
7360
|
+
const history = context2.services.getRequired(
|
|
7360
7361
|
CliCommandHistory_TOKEN
|
|
7361
7362
|
);
|
|
7362
|
-
const storeManager = context2.services.
|
|
7363
|
+
const storeManager = context2.services.getRequired(
|
|
7363
7364
|
CliStateStoreManager_TOKEN
|
|
7364
7365
|
);
|
|
7365
7366
|
const report = {
|
|
@@ -7392,7 +7393,7 @@ var CliDebugCommandProcessor = class {
|
|
|
7392
7393
|
state: storeManager.getStoreEntries()
|
|
7393
7394
|
};
|
|
7394
7395
|
try {
|
|
7395
|
-
const moduleRegistry = context2.services.
|
|
7396
|
+
const moduleRegistry = context2.services.getRequired(
|
|
7396
7397
|
CliModuleRegistry_TOKEN
|
|
7397
7398
|
);
|
|
7398
7399
|
report["modules"] = moduleRegistry.getAll().map((m) => ({
|
|
@@ -7410,7 +7411,7 @@ var CliDebugCommandProcessor = class {
|
|
|
7410
7411
|
report["services"] = container.getRegisteredTokens();
|
|
7411
7412
|
}
|
|
7412
7413
|
try {
|
|
7413
|
-
const serverManager = context2.services.
|
|
7414
|
+
const serverManager = context2.services.getRequired(
|
|
7414
7415
|
CliServerManager_TOKEN
|
|
7415
7416
|
);
|
|
7416
7417
|
if (serverManager && serverManager.connections.size > 0) {
|
|
@@ -7434,13 +7435,9 @@ var CliDebugCommandProcessor = class {
|
|
|
7434
7435
|
metadata: { icon: CliIcon.Server, module: "system" },
|
|
7435
7436
|
processCommand: async (_, context2) => {
|
|
7436
7437
|
const { writer } = context2;
|
|
7437
|
-
|
|
7438
|
-
|
|
7439
|
-
|
|
7440
|
-
CliServerManager_TOKEN
|
|
7441
|
-
);
|
|
7442
|
-
} catch {
|
|
7443
|
-
}
|
|
7438
|
+
const manager = context2.services.get(
|
|
7439
|
+
CliServerManager_TOKEN
|
|
7440
|
+
);
|
|
7444
7441
|
if (!manager || manager.connections.size === 0) {
|
|
7445
7442
|
writer.writeInfo("No servers configured.");
|
|
7446
7443
|
return;
|
|
@@ -7480,70 +7477,48 @@ var CliDebugCommandProcessor = class {
|
|
|
7480
7477
|
}
|
|
7481
7478
|
async processCommand(_, context2) {
|
|
7482
7479
|
const { writer } = context2;
|
|
7483
|
-
const registry = context2.services.
|
|
7480
|
+
const registry = context2.services.getRequired(
|
|
7484
7481
|
CliProcessorsRegistry_TOKEN
|
|
7485
7482
|
);
|
|
7486
|
-
|
|
7487
|
-
|
|
7488
|
-
|
|
7489
|
-
CliForegroundColor.Yellow
|
|
7490
|
-
)
|
|
7483
|
+
const summaryFramework = context2.services.get("cli-framework") ?? "vanilla";
|
|
7484
|
+
const summaryModuleRegistry = context2.services.get(
|
|
7485
|
+
CliModuleRegistry_TOKEN
|
|
7491
7486
|
);
|
|
7492
|
-
|
|
7493
|
-
|
|
7494
|
-
` ${writer.wrapInColor("Core Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION$1}`
|
|
7495
|
-
);
|
|
7496
|
-
writer.writeln(
|
|
7497
|
-
` ${writer.wrapInColor("CLI Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION}`
|
|
7498
|
-
);
|
|
7499
|
-
let framework = "vanilla";
|
|
7500
|
-
try {
|
|
7501
|
-
framework = context2.services.get("cli-framework");
|
|
7502
|
-
} catch {
|
|
7503
|
-
}
|
|
7504
|
-
writer.writeln(
|
|
7505
|
-
` ${writer.wrapInColor("Framework:", CliForegroundColor.Cyan)} ${framework}`
|
|
7506
|
-
);
|
|
7507
|
-
writer.writeln(
|
|
7508
|
-
` ${writer.wrapInColor("Terminal:", CliForegroundColor.Cyan)} ${context2.terminal.cols}x${context2.terminal.rows}`
|
|
7487
|
+
const summaryServerManager = context2.services.get(
|
|
7488
|
+
CliServerManager_TOKEN
|
|
7509
7489
|
);
|
|
7510
|
-
|
|
7511
|
-
|
|
7490
|
+
const history = context2.services.getRequired(
|
|
7491
|
+
CliCommandHistory_TOKEN
|
|
7512
7492
|
);
|
|
7513
|
-
|
|
7514
|
-
|
|
7515
|
-
|
|
7516
|
-
)
|
|
7517
|
-
writer.
|
|
7518
|
-
|
|
7493
|
+
const wasmStatus = isWasmAccelerated() ? "active" : "inactive (JS fallback)";
|
|
7494
|
+
const lines = [
|
|
7495
|
+
`${writer.wrapInColor("Core Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION$1}`,
|
|
7496
|
+
`${writer.wrapInColor("CLI Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION}`,
|
|
7497
|
+
`${writer.wrapInColor("Framework:", CliForegroundColor.Cyan)} ${summaryFramework}`,
|
|
7498
|
+
`${writer.wrapInColor("Terminal:", CliForegroundColor.Cyan)} ${context2.terminal.cols}x${context2.terminal.rows}`,
|
|
7499
|
+
`${writer.wrapInColor("Processors:", CliForegroundColor.Cyan)} ${registry.processors.length}`
|
|
7500
|
+
];
|
|
7501
|
+
if (summaryModuleRegistry) {
|
|
7502
|
+
lines.push(
|
|
7503
|
+
`${writer.wrapInColor("Modules:", CliForegroundColor.Cyan)} ${summaryModuleRegistry.getAll().length}`
|
|
7519
7504
|
);
|
|
7520
|
-
} catch {
|
|
7521
7505
|
}
|
|
7522
|
-
|
|
7523
|
-
const
|
|
7524
|
-
|
|
7506
|
+
if (summaryServerManager && summaryServerManager.connections.size > 0) {
|
|
7507
|
+
const connected = Array.from(
|
|
7508
|
+
summaryServerManager.connections.values()
|
|
7509
|
+
).filter((c) => c.connected).length;
|
|
7510
|
+
lines.push(
|
|
7511
|
+
`${writer.wrapInColor("Servers:", CliForegroundColor.Cyan)} ${connected}/${summaryServerManager.connections.size} connected`
|
|
7525
7512
|
);
|
|
7526
|
-
if (serverManager && serverManager.connections.size > 0) {
|
|
7527
|
-
const connected = Array.from(
|
|
7528
|
-
serverManager.connections.values()
|
|
7529
|
-
).filter((c) => c.connected).length;
|
|
7530
|
-
writer.writeln(
|
|
7531
|
-
` ${writer.wrapInColor("Servers:", CliForegroundColor.Cyan)} ${connected}/${serverManager.connections.size} connected`
|
|
7532
|
-
);
|
|
7533
|
-
}
|
|
7534
|
-
} catch {
|
|
7535
7513
|
}
|
|
7536
|
-
|
|
7537
|
-
|
|
7538
|
-
|
|
7539
|
-
writer.writeln(
|
|
7540
|
-
` ${writer.wrapInColor("History:", CliForegroundColor.Cyan)} ${history.getHistory().length} commands`
|
|
7514
|
+
lines.push(
|
|
7515
|
+
`${writer.wrapInColor("History:", CliForegroundColor.Cyan)} ${history.getHistory().length} commands`,
|
|
7516
|
+
`${writer.wrapInColor("WASM Accelerator:", CliForegroundColor.Cyan)} ${wasmStatus}`
|
|
7541
7517
|
);
|
|
7542
|
-
|
|
7543
|
-
|
|
7544
|
-
|
|
7545
|
-
);
|
|
7546
|
-
writer.writeDivider({ char: "=" });
|
|
7518
|
+
writer.writeBox(lines, {
|
|
7519
|
+
title: "CLI Debug Info",
|
|
7520
|
+
borderColor: CliForegroundColor.Yellow
|
|
7521
|
+
});
|
|
7547
7522
|
writer.writeln();
|
|
7548
7523
|
writer.writeln(`${CliIcon.Light} Subcommands:`);
|
|
7549
7524
|
for (const sub of this.processors || []) {
|
|
@@ -8129,7 +8104,7 @@ var CliNanoCommandProcessor = class {
|
|
|
8129
8104
|
this.replaceWith = "";
|
|
8130
8105
|
this.statusMessage = void 0;
|
|
8131
8106
|
try {
|
|
8132
|
-
this.fs = context2.services.
|
|
8107
|
+
this.fs = context2.services.getRequired(FS_TOKEN);
|
|
8133
8108
|
} catch {
|
|
8134
8109
|
this.fs = null;
|
|
8135
8110
|
}
|
|
@@ -8468,8 +8443,8 @@ var CliNanoCommandProcessor = class {
|
|
|
8468
8443
|
return;
|
|
8469
8444
|
}
|
|
8470
8445
|
try {
|
|
8471
|
-
const registry = this.context.services.
|
|
8472
|
-
|
|
8446
|
+
const registry = this.context.services.getRequired(
|
|
8447
|
+
SyntaxHighlighterRegistry_TOKEN
|
|
8473
8448
|
);
|
|
8474
8449
|
const ext = "." + filePath.split(".").pop()?.toLowerCase();
|
|
8475
8450
|
const highlighter = registry.getByExtension(ext);
|
|
@@ -9106,7 +9081,7 @@ var CliPsCommandProcessor = class {
|
|
|
9106
9081
|
async processCommand(_command, context2) {
|
|
9107
9082
|
let registry;
|
|
9108
9083
|
try {
|
|
9109
|
-
registry = context2.services.
|
|
9084
|
+
registry = context2.services.getRequired(
|
|
9110
9085
|
CliProcessRegistry_TOKEN
|
|
9111
9086
|
);
|
|
9112
9087
|
} catch {
|
|
@@ -9145,7 +9120,7 @@ var CliKillCommandProcessor = class {
|
|
|
9145
9120
|
async processCommand(command2, context2) {
|
|
9146
9121
|
let registry;
|
|
9147
9122
|
try {
|
|
9148
|
-
registry = context2.services.
|
|
9123
|
+
registry = context2.services.getRequired(
|
|
9149
9124
|
CliProcessRegistry_TOKEN
|
|
9150
9125
|
);
|
|
9151
9126
|
} catch {
|
|
@@ -9260,11 +9235,10 @@ var CliHtopCommandProcessor = class {
|
|
|
9260
9235
|
this.errorTimeout = null;
|
|
9261
9236
|
}
|
|
9262
9237
|
async processCommand(_command, context2) {
|
|
9263
|
-
|
|
9264
|
-
|
|
9265
|
-
|
|
9266
|
-
|
|
9267
|
-
} catch {
|
|
9238
|
+
this.registry = context2.services.get(
|
|
9239
|
+
CliProcessRegistry_TOKEN
|
|
9240
|
+
) ?? null;
|
|
9241
|
+
if (!this.registry) {
|
|
9268
9242
|
context2.writer.writeError("Process registry not available");
|
|
9269
9243
|
return;
|
|
9270
9244
|
}
|
|
@@ -10404,6 +10378,7 @@ var CliPingCommandProcessor = class {
|
|
|
10404
10378
|
context2.writer.writeln(
|
|
10405
10379
|
`PING ${host} (${url}):`
|
|
10406
10380
|
);
|
|
10381
|
+
context2.notifier.info(`ping ${host}`);
|
|
10407
10382
|
const times = [];
|
|
10408
10383
|
let transmitted = 0;
|
|
10409
10384
|
let received = 0;
|
|
@@ -10418,17 +10393,17 @@ var CliPingCommandProcessor = class {
|
|
|
10418
10393
|
transmitted++;
|
|
10419
10394
|
const start = performance.now();
|
|
10420
10395
|
try {
|
|
10421
|
-
const response = await fetch(url, {
|
|
10396
|
+
const response = await context2.http.fetch(url, {
|
|
10422
10397
|
method: "HEAD",
|
|
10423
10398
|
mode: "no-cors",
|
|
10424
|
-
cache: "no-store"
|
|
10425
|
-
signal: context2.signal
|
|
10399
|
+
cache: "no-store"
|
|
10426
10400
|
});
|
|
10427
10401
|
const elapsed = performance.now() - start;
|
|
10428
10402
|
const ms = elapsed.toFixed(1);
|
|
10429
10403
|
received++;
|
|
10430
10404
|
times.push(elapsed);
|
|
10431
10405
|
const status = response.type === "opaque" ? "ok" : `status=${response.status}`;
|
|
10406
|
+
context2.notifier.info(`ping ${host}: seq=${seq} time=${ms}ms`);
|
|
10432
10407
|
context2.writer.writeln(
|
|
10433
10408
|
`${url}: seq=${seq} ${status} time=${ms} ms`
|
|
10434
10409
|
);
|
|
@@ -10562,7 +10537,7 @@ var CliExportCommandProcessor = class {
|
|
|
10562
10537
|
this.metadata = { icon: "\u{1F4E6}", module: "system" };
|
|
10563
10538
|
}
|
|
10564
10539
|
async processCommand(command2, context2) {
|
|
10565
|
-
const env = context2.services.
|
|
10540
|
+
const env = context2.services.getRequired(
|
|
10566
10541
|
ICliEnvironment_TOKEN
|
|
10567
10542
|
);
|
|
10568
10543
|
const raw = (command2.value || "").trim();
|
|
@@ -10616,7 +10591,7 @@ var CliUnsetCommandProcessor = class {
|
|
|
10616
10591
|
this.metadata = { icon: "\u{1F5D1}\uFE0F", module: "system" };
|
|
10617
10592
|
}
|
|
10618
10593
|
async processCommand(command2, context2) {
|
|
10619
|
-
const env = context2.services.
|
|
10594
|
+
const env = context2.services.getRequired(
|
|
10620
10595
|
ICliEnvironment_TOKEN
|
|
10621
10596
|
);
|
|
10622
10597
|
const varName = (command2.value || "").trim();
|
|
@@ -10650,7 +10625,7 @@ var CliEnvCommandProcessor = class {
|
|
|
10650
10625
|
this.metadata = { icon: "\u{1F30D}", module: "system" };
|
|
10651
10626
|
}
|
|
10652
10627
|
async processCommand(command2, context2) {
|
|
10653
|
-
const env = context2.services.
|
|
10628
|
+
const env = context2.services.getRequired(
|
|
10654
10629
|
ICliEnvironment_TOKEN
|
|
10655
10630
|
);
|
|
10656
10631
|
const varName = (command2.value || "").trim();
|
|
@@ -10894,10 +10869,13 @@ var CliCommandExecutionContext = class {
|
|
|
10894
10869
|
this.reader = context2.reader;
|
|
10895
10870
|
this.enterFullScreenMode = (p, o) => context2.enterFullScreenMode(p, o);
|
|
10896
10871
|
this.exitFullScreenMode = () => context2.exitFullScreenMode();
|
|
10872
|
+
this.submitCommand = (command2) => context2.submitCommand(command2);
|
|
10897
10873
|
this.createInterval = (cb, ms) => context2.createInterval(cb, ms);
|
|
10898
10874
|
this.createTimeout = (cb, ms) => context2.createTimeout(cb, ms);
|
|
10899
10875
|
this.backgroundServices = context2.backgroundServices;
|
|
10900
|
-
this.
|
|
10876
|
+
this.http = context2.http;
|
|
10877
|
+
this.notifier = context2.notifier;
|
|
10878
|
+
this.state = context2.services.getRequired(CliStateStoreManager_TOKEN).getProcessorStateStore(processor);
|
|
10901
10879
|
}
|
|
10902
10880
|
get promptLength() {
|
|
10903
10881
|
return this.context.promptLength;
|
|
@@ -11448,6 +11426,172 @@ var CliBackgroundServiceRegistry = class {
|
|
|
11448
11426
|
}
|
|
11449
11427
|
};
|
|
11450
11428
|
|
|
11429
|
+
// src/lib/services/cli-http-client.ts
|
|
11430
|
+
var CliHttpClient = class {
|
|
11431
|
+
constructor(signal) {
|
|
11432
|
+
this.signal = signal;
|
|
11433
|
+
}
|
|
11434
|
+
async fetch(url, init) {
|
|
11435
|
+
return fetch(url, {
|
|
11436
|
+
...init,
|
|
11437
|
+
signal: this.mergeSignal(init?.signal)
|
|
11438
|
+
});
|
|
11439
|
+
}
|
|
11440
|
+
async get(url, options) {
|
|
11441
|
+
return this.jsonRequest("GET", url, void 0, options);
|
|
11442
|
+
}
|
|
11443
|
+
async post(url, body, options) {
|
|
11444
|
+
return this.jsonRequest("POST", url, body, options);
|
|
11445
|
+
}
|
|
11446
|
+
async put(url, body, options) {
|
|
11447
|
+
return this.jsonRequest("PUT", url, body, options);
|
|
11448
|
+
}
|
|
11449
|
+
async patch(url, body, options) {
|
|
11450
|
+
return this.jsonRequest("PATCH", url, body, options);
|
|
11451
|
+
}
|
|
11452
|
+
async delete(url, options) {
|
|
11453
|
+
return this.jsonRequest("DELETE", url, void 0, options);
|
|
11454
|
+
}
|
|
11455
|
+
async head(url, options) {
|
|
11456
|
+
const { timeout, signal: callerSignal, ...fetchOptions } = options ?? {};
|
|
11457
|
+
let timeoutController;
|
|
11458
|
+
let timeoutId;
|
|
11459
|
+
if (timeout) {
|
|
11460
|
+
timeoutController = new AbortController();
|
|
11461
|
+
timeoutId = setTimeout(() => timeoutController.abort(), timeout);
|
|
11462
|
+
}
|
|
11463
|
+
try {
|
|
11464
|
+
return await fetch(url, {
|
|
11465
|
+
...fetchOptions,
|
|
11466
|
+
method: "HEAD",
|
|
11467
|
+
signal: this.mergeSignal(callerSignal, timeoutController?.signal)
|
|
11468
|
+
});
|
|
11469
|
+
} finally {
|
|
11470
|
+
if (timeoutId !== void 0) clearTimeout(timeoutId);
|
|
11471
|
+
}
|
|
11472
|
+
}
|
|
11473
|
+
async options(url, options) {
|
|
11474
|
+
return this.jsonRequest("OPTIONS", url, void 0, options);
|
|
11475
|
+
}
|
|
11476
|
+
// ── Internals ────────────────────────────────────────────────────
|
|
11477
|
+
async jsonRequest(method, url, body, options) {
|
|
11478
|
+
const { timeout, ...fetchOptions } = options ?? {};
|
|
11479
|
+
const headers = {
|
|
11480
|
+
...fetchOptions.headers ?? {}
|
|
11481
|
+
};
|
|
11482
|
+
let resolvedBody;
|
|
11483
|
+
if (body !== void 0 && body !== null) {
|
|
11484
|
+
if (this.isRawBody(body)) {
|
|
11485
|
+
resolvedBody = body;
|
|
11486
|
+
} else {
|
|
11487
|
+
resolvedBody = JSON.stringify(body);
|
|
11488
|
+
if (!headers["Content-Type"]) {
|
|
11489
|
+
headers["Content-Type"] = "application/json";
|
|
11490
|
+
}
|
|
11491
|
+
}
|
|
11492
|
+
}
|
|
11493
|
+
let timeoutId;
|
|
11494
|
+
let timeoutController;
|
|
11495
|
+
if (timeout) {
|
|
11496
|
+
timeoutController = new AbortController();
|
|
11497
|
+
timeoutId = setTimeout(() => timeoutController.abort(), timeout);
|
|
11498
|
+
}
|
|
11499
|
+
const signal = this.mergeSignal(
|
|
11500
|
+
fetchOptions.signal,
|
|
11501
|
+
timeoutController?.signal
|
|
11502
|
+
);
|
|
11503
|
+
try {
|
|
11504
|
+
const response = await fetch(url, {
|
|
11505
|
+
...fetchOptions,
|
|
11506
|
+
method,
|
|
11507
|
+
headers,
|
|
11508
|
+
body: resolvedBody,
|
|
11509
|
+
signal
|
|
11510
|
+
});
|
|
11511
|
+
if (!response.ok) {
|
|
11512
|
+
let errorMessage = `${response.status} ${response.statusText}`;
|
|
11513
|
+
try {
|
|
11514
|
+
const errorBody = await response.json();
|
|
11515
|
+
if (errorBody.error) {
|
|
11516
|
+
errorMessage = errorBody.error;
|
|
11517
|
+
} else if (errorBody.message) {
|
|
11518
|
+
errorMessage = errorBody.message;
|
|
11519
|
+
}
|
|
11520
|
+
} catch {
|
|
11521
|
+
}
|
|
11522
|
+
throw new Error(errorMessage);
|
|
11523
|
+
}
|
|
11524
|
+
const text = await response.text();
|
|
11525
|
+
if (!text) {
|
|
11526
|
+
return void 0;
|
|
11527
|
+
}
|
|
11528
|
+
return JSON.parse(text);
|
|
11529
|
+
} finally {
|
|
11530
|
+
if (timeoutId !== void 0) {
|
|
11531
|
+
clearTimeout(timeoutId);
|
|
11532
|
+
}
|
|
11533
|
+
}
|
|
11534
|
+
}
|
|
11535
|
+
isRawBody(body) {
|
|
11536
|
+
return typeof body === "string" || body instanceof FormData || body instanceof Blob || body instanceof ArrayBuffer || body instanceof URLSearchParams || body instanceof ReadableStream;
|
|
11537
|
+
}
|
|
11538
|
+
/**
|
|
11539
|
+
* Merge the command signal with any additional signals (caller, timeout).
|
|
11540
|
+
* Uses AbortSignal.any() when available, falls back to a manual composite
|
|
11541
|
+
* controller for older browsers (pre-Chrome 116 / Safari 17.4).
|
|
11542
|
+
*/
|
|
11543
|
+
mergeSignal(...additional) {
|
|
11544
|
+
const signals = [];
|
|
11545
|
+
if (this.signal) signals.push(this.signal);
|
|
11546
|
+
for (const s of additional) {
|
|
11547
|
+
if (s) signals.push(s);
|
|
11548
|
+
}
|
|
11549
|
+
if (signals.length === 0) return void 0;
|
|
11550
|
+
if (signals.length === 1) return signals[0];
|
|
11551
|
+
if (typeof AbortSignal.any === "function") {
|
|
11552
|
+
return AbortSignal.any(signals);
|
|
11553
|
+
}
|
|
11554
|
+
const controller = new AbortController();
|
|
11555
|
+
for (const s of signals) {
|
|
11556
|
+
if (s.aborted) {
|
|
11557
|
+
controller.abort(s.reason);
|
|
11558
|
+
return controller.signal;
|
|
11559
|
+
}
|
|
11560
|
+
s.addEventListener("abort", () => controller.abort(s.reason), { once: true });
|
|
11561
|
+
}
|
|
11562
|
+
return controller.signal;
|
|
11563
|
+
}
|
|
11564
|
+
};
|
|
11565
|
+
var CliNotifier = class {
|
|
11566
|
+
constructor() {
|
|
11567
|
+
this._change$ = new Subject();
|
|
11568
|
+
this.change$ = this._change$.asObservable();
|
|
11569
|
+
}
|
|
11570
|
+
get current() {
|
|
11571
|
+
return this._current;
|
|
11572
|
+
}
|
|
11573
|
+
info(message) {
|
|
11574
|
+
this.set("info", message);
|
|
11575
|
+
}
|
|
11576
|
+
success(message) {
|
|
11577
|
+
this.set("success", message);
|
|
11578
|
+
}
|
|
11579
|
+
warn(message) {
|
|
11580
|
+
this.set("warn", message);
|
|
11581
|
+
}
|
|
11582
|
+
error(message) {
|
|
11583
|
+
this.set("error", message);
|
|
11584
|
+
}
|
|
11585
|
+
clear() {
|
|
11586
|
+
this._current = void 0;
|
|
11587
|
+
this._change$.next(void 0);
|
|
11588
|
+
}
|
|
11589
|
+
set(level, message) {
|
|
11590
|
+
this._current = { level, message, timestamp: Date.now() };
|
|
11591
|
+
this._change$.next(this._current);
|
|
11592
|
+
}
|
|
11593
|
+
};
|
|
11594
|
+
|
|
11451
11595
|
// src/lib/context/cli-fullscreen-manager.ts
|
|
11452
11596
|
var CliFullScreenManager = class {
|
|
11453
11597
|
constructor(terminal, backgroundServices) {
|
|
@@ -14075,18 +14219,15 @@ var CommandLineMode = class {
|
|
|
14075
14219
|
if (data === "\r") {
|
|
14076
14220
|
this.clearGhostText();
|
|
14077
14221
|
this.host.terminal.write("\r\n");
|
|
14078
|
-
|
|
14079
|
-
|
|
14222
|
+
const text = buffer.text;
|
|
14223
|
+
if (text) {
|
|
14080
14224
|
this.historyIndex = this.host.commandHistory.getLastIndex();
|
|
14081
14225
|
this.bufferSetByHistory = false;
|
|
14082
|
-
this.isExecutingCommand = true;
|
|
14083
|
-
const ctx = this.host.getExecutionContext();
|
|
14084
|
-
await ctx.executor.executeCommand(buffer.text, ctx);
|
|
14085
|
-
this.isExecutingCommand = false;
|
|
14086
|
-
}
|
|
14087
|
-
if (!this.host.isRawModeActive()) {
|
|
14088
|
-
this.host.showPrompt();
|
|
14089
14226
|
}
|
|
14227
|
+
this.isExecutingCommand = true;
|
|
14228
|
+
const ctx = this.host.getExecutionContext();
|
|
14229
|
+
await ctx.submitCommand(text);
|
|
14230
|
+
this.isExecutingCommand = false;
|
|
14090
14231
|
} else if (data === "\x1B[A") {
|
|
14091
14232
|
this.showPreviousCommand();
|
|
14092
14233
|
} else if (data === "\x1B[B") {
|
|
@@ -14468,6 +14609,11 @@ var CliExecutionContext = class {
|
|
|
14468
14609
|
this.onAbort = new Subject();
|
|
14469
14610
|
this.completionEngine = new CliCompletionEngine();
|
|
14470
14611
|
this.promptLength = 0;
|
|
14612
|
+
/**
|
|
14613
|
+
* Whether a command is currently being executed.
|
|
14614
|
+
* Set by the command executor at start/end of executeCommand().
|
|
14615
|
+
*/
|
|
14616
|
+
this.isExecuting = false;
|
|
14471
14617
|
this.lineBuffer = new CliLineBuffer();
|
|
14472
14618
|
this.modeStack = [];
|
|
14473
14619
|
this.timerManager = new CliTimerManager();
|
|
@@ -14512,6 +14658,8 @@ var CliExecutionContext = class {
|
|
|
14512
14658
|
this.logger.setCliLogLevel(cliOptions?.logLevel || CliLogLevel.ERROR);
|
|
14513
14659
|
this.commandHistory = deps.commandHistory;
|
|
14514
14660
|
this.lineRenderer = new CliTerminalLineRenderer(terminal, this.writer);
|
|
14661
|
+
this.http = new CliHttpClient();
|
|
14662
|
+
this.notifier = new CliNotifier();
|
|
14515
14663
|
this.backgroundServices = new CliBackgroundServiceRegistry(
|
|
14516
14664
|
this.state,
|
|
14517
14665
|
deps.services,
|
|
@@ -14601,6 +14749,20 @@ var CliExecutionContext = class {
|
|
|
14601
14749
|
this.getPromptOptions()
|
|
14602
14750
|
);
|
|
14603
14751
|
}
|
|
14752
|
+
/**
|
|
14753
|
+
* Submit and execute a command — shared by interactive Enter key
|
|
14754
|
+
* and programmatic engine.execute(). Adds to history, runs the
|
|
14755
|
+
* command, and shows a new prompt afterwards.
|
|
14756
|
+
*/
|
|
14757
|
+
async submitCommand(command2) {
|
|
14758
|
+
if (command2.trim()) {
|
|
14759
|
+
await this.commandHistory.addCommand(command2);
|
|
14760
|
+
await this.executor.executeCommand(command2, this);
|
|
14761
|
+
}
|
|
14762
|
+
if (!this.isRawModeActive()) {
|
|
14763
|
+
this.showPrompt();
|
|
14764
|
+
}
|
|
14765
|
+
}
|
|
14604
14766
|
clearCurrentLine() {
|
|
14605
14767
|
this.clearLine();
|
|
14606
14768
|
this.showPrompt();
|
|
@@ -14701,12 +14863,8 @@ var CliExecutionContext = class {
|
|
|
14701
14863
|
}
|
|
14702
14864
|
// -- CommandLineModeHost interface --
|
|
14703
14865
|
getPromptOptions() {
|
|
14704
|
-
|
|
14705
|
-
|
|
14706
|
-
const config = this.services.get("cli-users-module-config");
|
|
14707
|
-
hideUserName = config?.hideUserName ?? false;
|
|
14708
|
-
} catch {
|
|
14709
|
-
}
|
|
14866
|
+
const usersConfig = this.services.get("cli-users-module-config");
|
|
14867
|
+
const hideUserName = usersConfig?.hideUserName ?? false;
|
|
14710
14868
|
return {
|
|
14711
14869
|
userName: this.userSession?.displayName,
|
|
14712
14870
|
hideUserName,
|
|
@@ -14954,10 +15112,8 @@ var contextGlobalParameter = {
|
|
|
14954
15112
|
// src/lib/executor/cli-io-redirect-handler.ts
|
|
14955
15113
|
var FS_TOKEN2 = "cli-file-system-service";
|
|
14956
15114
|
async function writeOutputToFile(filePath, context2) {
|
|
14957
|
-
|
|
14958
|
-
|
|
14959
|
-
fs = context2.services.get(FS_TOKEN2);
|
|
14960
|
-
} catch {
|
|
15115
|
+
const fs = context2.services.get(FS_TOKEN2);
|
|
15116
|
+
if (!fs) {
|
|
14961
15117
|
context2.writer.writeError(
|
|
14962
15118
|
"> redirect requires @qodalis/cli-files plugin"
|
|
14963
15119
|
);
|
|
@@ -14981,10 +15137,8 @@ async function writeOutputToFile(filePath, context2) {
|
|
|
14981
15137
|
}
|
|
14982
15138
|
}
|
|
14983
15139
|
async function appendOutputToFile(filePath, context2) {
|
|
14984
|
-
|
|
14985
|
-
|
|
14986
|
-
fs = context2.services.get(FS_TOKEN2);
|
|
14987
|
-
} catch {
|
|
15140
|
+
const fs = context2.services.get(FS_TOKEN2);
|
|
15141
|
+
if (!fs) {
|
|
14988
15142
|
context2.writer.writeError(
|
|
14989
15143
|
">> redirect requires @qodalis/cli-files plugin"
|
|
14990
15144
|
);
|
|
@@ -15010,10 +15164,8 @@ async function appendOutputToFile(filePath, context2) {
|
|
|
15010
15164
|
async function writeStderrToFile(filePath, context2, capturingWriter) {
|
|
15011
15165
|
const stderr = capturingWriter?.getCapturedStderr();
|
|
15012
15166
|
if (!stderr) return;
|
|
15013
|
-
|
|
15014
|
-
|
|
15015
|
-
fs = context2.services.get(FS_TOKEN2);
|
|
15016
|
-
} catch {
|
|
15167
|
+
const fs = context2.services.get(FS_TOKEN2);
|
|
15168
|
+
if (!fs) {
|
|
15017
15169
|
context2.writer.writeError(
|
|
15018
15170
|
"2> redirect requires @qodalis/cli-files plugin"
|
|
15019
15171
|
);
|
|
@@ -15034,10 +15186,8 @@ async function writeStderrToFile(filePath, context2, capturingWriter) {
|
|
|
15034
15186
|
async function appendStderrToFile(filePath, context2, capturingWriter) {
|
|
15035
15187
|
const stderr = capturingWriter?.getCapturedStderr();
|
|
15036
15188
|
if (!stderr) return;
|
|
15037
|
-
|
|
15038
|
-
|
|
15039
|
-
fs = context2.services.get(FS_TOKEN2);
|
|
15040
|
-
} catch {
|
|
15189
|
+
const fs = context2.services.get(FS_TOKEN2);
|
|
15190
|
+
if (!fs) {
|
|
15041
15191
|
context2.writer.writeError(
|
|
15042
15192
|
"2>> redirect requires @qodalis/cli-files plugin"
|
|
15043
15193
|
);
|
|
@@ -15057,10 +15207,8 @@ async function appendStderrToFile(filePath, context2, capturingWriter) {
|
|
|
15057
15207
|
}
|
|
15058
15208
|
async function tryExecuteScript(filePath, context2, executeCommand) {
|
|
15059
15209
|
const FS_TOKEN3 = "cli-file-system-service";
|
|
15060
|
-
|
|
15061
|
-
|
|
15062
|
-
fs = context2.services.get(FS_TOKEN3);
|
|
15063
|
-
} catch {
|
|
15210
|
+
const fs = context2.services.get(FS_TOKEN3);
|
|
15211
|
+
if (!fs) {
|
|
15064
15212
|
return false;
|
|
15065
15213
|
}
|
|
15066
15214
|
const resolved = fs.resolvePath(filePath);
|
|
@@ -15137,10 +15285,8 @@ function substituteVars(input, variables) {
|
|
|
15137
15285
|
return result;
|
|
15138
15286
|
}
|
|
15139
15287
|
function expandEnvironmentVars(command2, context2) {
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
env = context2.services.get(ICliEnvironment_TOKEN);
|
|
15143
|
-
} catch {
|
|
15288
|
+
const env = context2.services.get(ICliEnvironment_TOKEN);
|
|
15289
|
+
if (!env) {
|
|
15144
15290
|
return command2;
|
|
15145
15291
|
}
|
|
15146
15292
|
const parts = command2.split("'");
|
|
@@ -15186,92 +15332,106 @@ var CliCommandExecutor = class {
|
|
|
15186
15332
|
} else {
|
|
15187
15333
|
rootContext = context2;
|
|
15188
15334
|
}
|
|
15189
|
-
|
|
15190
|
-
|
|
15191
|
-
|
|
15192
|
-
|
|
15193
|
-
|
|
15194
|
-
|
|
15195
|
-
|
|
15196
|
-
|
|
15197
|
-
|
|
15198
|
-
|
|
15199
|
-
shouldRunNext = !lastExitSuccess;
|
|
15200
|
-
continue;
|
|
15201
|
-
} else if (part.type === "|") {
|
|
15202
|
-
shouldRunNext = true;
|
|
15203
|
-
continue;
|
|
15204
|
-
} else if (part.type === ";") {
|
|
15205
|
-
shouldRunNext = true;
|
|
15206
|
-
pipelineData = void 0;
|
|
15207
|
-
continue;
|
|
15208
|
-
} else if (part.type === ">>") {
|
|
15209
|
-
const nextPart = parts[i + 1];
|
|
15210
|
-
i++;
|
|
15211
|
-
if (!nextPart || nextPart.type !== "command") {
|
|
15212
|
-
context2.writer.writeError("Missing file path after >>");
|
|
15213
|
-
lastExitSuccess = false;
|
|
15335
|
+
rootContext.isExecuting = true;
|
|
15336
|
+
try {
|
|
15337
|
+
let lastExitSuccess = true;
|
|
15338
|
+
let shouldRunNext = true;
|
|
15339
|
+
let pipelineData = void 0;
|
|
15340
|
+
let lastCapturingWriter;
|
|
15341
|
+
for (let i = 0; i < parts.length; i++) {
|
|
15342
|
+
const part = parts[i];
|
|
15343
|
+
if (part.type === "&&") {
|
|
15344
|
+
shouldRunNext = lastExitSuccess;
|
|
15214
15345
|
continue;
|
|
15215
|
-
}
|
|
15216
|
-
|
|
15217
|
-
await appendOutputToFile(nextPart.value, context2);
|
|
15218
|
-
pipelineData = void 0;
|
|
15219
|
-
}
|
|
15220
|
-
continue;
|
|
15221
|
-
} else if (part.type === ">") {
|
|
15222
|
-
const nextPart = parts[i + 1];
|
|
15223
|
-
i++;
|
|
15224
|
-
if (!nextPart || nextPart.type !== "command") {
|
|
15225
|
-
context2.writer.writeError("Missing file path after >");
|
|
15226
|
-
lastExitSuccess = false;
|
|
15346
|
+
} else if (part.type === "||") {
|
|
15347
|
+
shouldRunNext = !lastExitSuccess;
|
|
15227
15348
|
continue;
|
|
15228
|
-
}
|
|
15229
|
-
|
|
15230
|
-
|
|
15349
|
+
} else if (part.type === "|") {
|
|
15350
|
+
shouldRunNext = true;
|
|
15351
|
+
continue;
|
|
15352
|
+
} else if (part.type === ";") {
|
|
15353
|
+
shouldRunNext = true;
|
|
15231
15354
|
pipelineData = void 0;
|
|
15232
|
-
|
|
15233
|
-
|
|
15234
|
-
|
|
15235
|
-
|
|
15236
|
-
|
|
15237
|
-
|
|
15238
|
-
|
|
15239
|
-
|
|
15355
|
+
continue;
|
|
15356
|
+
} else if (part.type === ">>") {
|
|
15357
|
+
const nextPart = parts[i + 1];
|
|
15358
|
+
i++;
|
|
15359
|
+
if (!nextPart || nextPart.type !== "command") {
|
|
15360
|
+
context2.writer.writeError("Missing file path after >>");
|
|
15361
|
+
lastExitSuccess = false;
|
|
15362
|
+
continue;
|
|
15363
|
+
}
|
|
15364
|
+
if (shouldRunNext) {
|
|
15365
|
+
await appendOutputToFile(nextPart.value, context2);
|
|
15366
|
+
pipelineData = void 0;
|
|
15367
|
+
}
|
|
15368
|
+
continue;
|
|
15369
|
+
} else if (part.type === ">") {
|
|
15370
|
+
const nextPart = parts[i + 1];
|
|
15371
|
+
i++;
|
|
15372
|
+
if (!nextPart || nextPart.type !== "command") {
|
|
15373
|
+
context2.writer.writeError("Missing file path after >");
|
|
15374
|
+
lastExitSuccess = false;
|
|
15375
|
+
continue;
|
|
15376
|
+
}
|
|
15377
|
+
if (shouldRunNext) {
|
|
15378
|
+
await writeOutputToFile(nextPart.value, context2);
|
|
15379
|
+
pipelineData = void 0;
|
|
15380
|
+
}
|
|
15381
|
+
continue;
|
|
15382
|
+
} else if (part.type === "2>>") {
|
|
15383
|
+
const nextPart = parts[i + 1];
|
|
15384
|
+
i++;
|
|
15385
|
+
if (!nextPart || nextPart.type !== "command") {
|
|
15386
|
+
context2.writer.writeError("Missing file path after 2>>");
|
|
15387
|
+
lastExitSuccess = false;
|
|
15388
|
+
continue;
|
|
15389
|
+
}
|
|
15390
|
+
if (shouldRunNext) {
|
|
15391
|
+
await appendStderrToFile(nextPart.value, context2, lastCapturingWriter);
|
|
15392
|
+
}
|
|
15393
|
+
continue;
|
|
15394
|
+
} else if (part.type === "2>") {
|
|
15395
|
+
const nextPart = parts[i + 1];
|
|
15396
|
+
i++;
|
|
15397
|
+
if (!nextPart || nextPart.type !== "command") {
|
|
15398
|
+
context2.writer.writeError("Missing file path after 2>");
|
|
15399
|
+
lastExitSuccess = false;
|
|
15400
|
+
continue;
|
|
15401
|
+
}
|
|
15402
|
+
if (shouldRunNext) {
|
|
15403
|
+
await writeStderrToFile(nextPart.value, context2, lastCapturingWriter);
|
|
15404
|
+
}
|
|
15240
15405
|
continue;
|
|
15241
15406
|
}
|
|
15242
|
-
if (shouldRunNext) {
|
|
15243
|
-
await appendStderrToFile(nextPart.value, context2, lastCapturingWriter);
|
|
15244
|
-
}
|
|
15245
|
-
continue;
|
|
15246
|
-
} else if (part.type === "2>") {
|
|
15247
|
-
const nextPart = parts[i + 1];
|
|
15248
|
-
i++;
|
|
15249
|
-
if (!nextPart || nextPart.type !== "command") {
|
|
15250
|
-
context2.writer.writeError("Missing file path after 2>");
|
|
15251
|
-
lastExitSuccess = false;
|
|
15407
|
+
if (!shouldRunNext) {
|
|
15252
15408
|
continue;
|
|
15253
15409
|
}
|
|
15254
|
-
|
|
15255
|
-
await
|
|
15410
|
+
try {
|
|
15411
|
+
lastCapturingWriter = await this.executeSingleCommand(
|
|
15412
|
+
part.value,
|
|
15413
|
+
pipelineData,
|
|
15414
|
+
rootContext
|
|
15415
|
+
);
|
|
15416
|
+
lastExitSuccess = context2.process.exitCode === void 0 || context2.process.exitCode === 0;
|
|
15417
|
+
rootContext.lastCommandResult = {
|
|
15418
|
+
command: part.value,
|
|
15419
|
+
success: lastExitSuccess
|
|
15420
|
+
};
|
|
15421
|
+
pipelineData = context2.process.data;
|
|
15422
|
+
} catch (e) {
|
|
15423
|
+
lastExitSuccess = false;
|
|
15424
|
+
rootContext.lastCommandResult = {
|
|
15425
|
+
command: part.value,
|
|
15426
|
+
success: false
|
|
15427
|
+
};
|
|
15428
|
+
context2.writer.writeError(`Command ${part.value} failed: ${e}`);
|
|
15256
15429
|
}
|
|
15257
|
-
|
|
15258
|
-
}
|
|
15259
|
-
if (!shouldRunNext) {
|
|
15260
|
-
continue;
|
|
15261
|
-
}
|
|
15262
|
-
try {
|
|
15263
|
-
lastCapturingWriter = await this.executeSingleCommand(
|
|
15264
|
-
part.value,
|
|
15265
|
-
pipelineData,
|
|
15266
|
-
rootContext
|
|
15267
|
-
);
|
|
15268
|
-
lastExitSuccess = context2.process.exitCode === void 0 || context2.process.exitCode === 0;
|
|
15269
|
-
pipelineData = context2.process.data;
|
|
15270
|
-
} catch (e) {
|
|
15271
|
-
lastExitSuccess = false;
|
|
15272
|
-
context2.writer.writeError(`Command ${part.value} failed: ${e}`);
|
|
15430
|
+
shouldRunNext = true;
|
|
15273
15431
|
}
|
|
15274
|
-
|
|
15432
|
+
} finally {
|
|
15433
|
+
rootContext.isExecuting = false;
|
|
15434
|
+
rootContext.notifier?.clear();
|
|
15275
15435
|
}
|
|
15276
15436
|
}
|
|
15277
15437
|
async executeSingleCommand(command2, data, context2) {
|
|
@@ -15279,8 +15439,8 @@ var CliCommandExecutor = class {
|
|
|
15279
15439
|
command2 = expandEnvironmentVars(command2, context2);
|
|
15280
15440
|
const assignMatch = command2.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
|
|
15281
15441
|
if (assignMatch) {
|
|
15282
|
-
|
|
15283
|
-
|
|
15442
|
+
const env = context2.services.get(ICliEnvironment_TOKEN);
|
|
15443
|
+
if (env) {
|
|
15284
15444
|
let val = assignMatch[2];
|
|
15285
15445
|
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
15286
15446
|
val = val.slice(1, -1);
|
|
@@ -15289,15 +15449,13 @@ var CliCommandExecutor = class {
|
|
|
15289
15449
|
process.start();
|
|
15290
15450
|
process.end();
|
|
15291
15451
|
return;
|
|
15292
|
-
} catch {
|
|
15293
15452
|
}
|
|
15294
15453
|
}
|
|
15295
15454
|
process.start();
|
|
15296
15455
|
let processEntry;
|
|
15297
|
-
|
|
15298
|
-
|
|
15456
|
+
const procRegistry = context2.services.get(CliProcessRegistry_TOKEN);
|
|
15457
|
+
if (procRegistry) {
|
|
15299
15458
|
processEntry = procRegistry.register(command2);
|
|
15300
|
-
} catch {
|
|
15301
15459
|
}
|
|
15302
15460
|
const parsed = this.commandParser.parse(command2);
|
|
15303
15461
|
let { commandName } = parsed;
|
|
@@ -15410,6 +15568,7 @@ var CliCommandExecutor = class {
|
|
|
15410
15568
|
);
|
|
15411
15569
|
const commandAbortController = new AbortController();
|
|
15412
15570
|
commandContext.signal = commandAbortController.signal;
|
|
15571
|
+
commandContext.http = new CliHttpClient(commandAbortController.signal);
|
|
15413
15572
|
const abortSub = context2.onAbort.subscribe(() => {
|
|
15414
15573
|
commandAbortController.abort();
|
|
15415
15574
|
});
|
|
@@ -15474,19 +15633,13 @@ var CliCommandExecutor = class {
|
|
|
15474
15633
|
}
|
|
15475
15634
|
completeProcess(processEntry, context2, exitCode) {
|
|
15476
15635
|
if (!processEntry) return;
|
|
15477
|
-
|
|
15478
|
-
|
|
15479
|
-
procRegistry.complete(processEntry.pid, exitCode);
|
|
15480
|
-
} catch {
|
|
15481
|
-
}
|
|
15636
|
+
const procRegistry = context2.services.get(CliProcessRegistry_TOKEN);
|
|
15637
|
+
procRegistry?.complete(processEntry.pid, exitCode);
|
|
15482
15638
|
}
|
|
15483
15639
|
failProcess(processEntry, context2) {
|
|
15484
15640
|
if (!processEntry) return;
|
|
15485
|
-
|
|
15486
|
-
|
|
15487
|
-
procRegistry.fail(processEntry.pid);
|
|
15488
|
-
} catch {
|
|
15489
|
-
}
|
|
15641
|
+
const failRegistry = context2.services.get(CliProcessRegistry_TOKEN);
|
|
15642
|
+
failRegistry?.fail(processEntry.pid);
|
|
15490
15643
|
}
|
|
15491
15644
|
async showHelp(command2, context2) {
|
|
15492
15645
|
try {
|
|
@@ -15568,29 +15721,94 @@ var CliCommandExecutor = class {
|
|
|
15568
15721
|
// src/lib/services/cli-service-container.ts
|
|
15569
15722
|
var CliServiceContainer = class {
|
|
15570
15723
|
constructor() {
|
|
15571
|
-
/** Stores single-value providers (resolved
|
|
15724
|
+
/** Stores single-value providers (resolved singletons). */
|
|
15572
15725
|
this.services = /* @__PURE__ */ new Map();
|
|
15573
15726
|
/** Stores multi-provider arrays. */
|
|
15574
15727
|
this.multiServices = /* @__PURE__ */ new Map();
|
|
15728
|
+
/** Tokens that cannot be overwritten by subsequent `set()` calls. */
|
|
15729
|
+
this.sealedTokens = /* @__PURE__ */ new Set();
|
|
15730
|
+
/** Stores provider recipes for transient tokens (re-resolved on every get). */
|
|
15731
|
+
this.transientRecipes = /* @__PURE__ */ new Map();
|
|
15575
15732
|
}
|
|
15576
15733
|
/**
|
|
15577
15734
|
* Retrieve a service by its token.
|
|
15735
|
+
* Returns `undefined` when no provider is registered for the token.
|
|
15736
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
15578
15737
|
*
|
|
15579
15738
|
* @param token The token used to register the service.
|
|
15580
|
-
* @returns The resolved service instance
|
|
15581
|
-
* @throws Error if the token has not been registered.
|
|
15739
|
+
* @returns The resolved service instance, or `undefined` if not registered.
|
|
15582
15740
|
*/
|
|
15583
15741
|
get(token) {
|
|
15742
|
+
if (this.transientRecipes.has(token)) {
|
|
15743
|
+
return this.resolveProvider(this.transientRecipes.get(token));
|
|
15744
|
+
}
|
|
15584
15745
|
if (this.multiServices.has(token)) {
|
|
15585
|
-
|
|
15746
|
+
const arr = this.multiServices.get(token);
|
|
15747
|
+
return arr[arr.length - 1];
|
|
15586
15748
|
}
|
|
15587
15749
|
if (this.services.has(token)) {
|
|
15588
15750
|
return this.services.get(token);
|
|
15589
15751
|
}
|
|
15590
|
-
|
|
15591
|
-
|
|
15592
|
-
|
|
15593
|
-
|
|
15752
|
+
return void 0;
|
|
15753
|
+
}
|
|
15754
|
+
/**
|
|
15755
|
+
* Retrieve all registered services for a multi-provider token.
|
|
15756
|
+
* Returns an empty array when no provider is registered for the token.
|
|
15757
|
+
*
|
|
15758
|
+
* @param token The token used to register the service.
|
|
15759
|
+
* @returns Array of all resolved service instances.
|
|
15760
|
+
*/
|
|
15761
|
+
getAll(token) {
|
|
15762
|
+
if (this.multiServices.has(token)) {
|
|
15763
|
+
return this.multiServices.get(token);
|
|
15764
|
+
}
|
|
15765
|
+
const single = this.get(token);
|
|
15766
|
+
return single !== void 0 ? [single] : [];
|
|
15767
|
+
}
|
|
15768
|
+
/**
|
|
15769
|
+
* Retrieve a service by its token, throwing if not registered.
|
|
15770
|
+
* Use this when the service is required and its absence is a programming error.
|
|
15771
|
+
* For multi-provider tokens, returns the last registered value (use `getAll` for the full array).
|
|
15772
|
+
*
|
|
15773
|
+
* @param token The token used to register the service.
|
|
15774
|
+
* @returns The resolved service instance.
|
|
15775
|
+
* @throws Error if the token has not been registered.
|
|
15776
|
+
*/
|
|
15777
|
+
getRequired(token) {
|
|
15778
|
+
const value = this.get(token);
|
|
15779
|
+
if (value === void 0 && !this.has(token)) {
|
|
15780
|
+
throw new Error(
|
|
15781
|
+
`CliServiceContainer: No provider found for token "${this.tokenToString(token)}".`
|
|
15782
|
+
);
|
|
15783
|
+
}
|
|
15784
|
+
return value;
|
|
15785
|
+
}
|
|
15786
|
+
/**
|
|
15787
|
+
* Check whether a service is registered for the given token.
|
|
15788
|
+
*/
|
|
15789
|
+
has(token) {
|
|
15790
|
+
return this.services.has(token) || this.multiServices.has(token) || this.transientRecipes.has(token);
|
|
15791
|
+
}
|
|
15792
|
+
/**
|
|
15793
|
+
* Mark a token as sealed so it cannot be overwritten by future `set()` calls.
|
|
15794
|
+
* Only available on the concrete container — not exposed on `ICliServiceProvider`.
|
|
15795
|
+
*/
|
|
15796
|
+
seal(token) {
|
|
15797
|
+
this.sealedTokens.add(token);
|
|
15798
|
+
}
|
|
15799
|
+
/**
|
|
15800
|
+
* Mark multiple tokens as sealed at once.
|
|
15801
|
+
*/
|
|
15802
|
+
sealAll(tokens) {
|
|
15803
|
+
for (const token of tokens) {
|
|
15804
|
+
this.sealedTokens.add(token);
|
|
15805
|
+
}
|
|
15806
|
+
}
|
|
15807
|
+
/**
|
|
15808
|
+
* Check whether a token is sealed.
|
|
15809
|
+
*/
|
|
15810
|
+
isSealed(token) {
|
|
15811
|
+
return this.sealedTokens.has(token);
|
|
15594
15812
|
}
|
|
15595
15813
|
/**
|
|
15596
15814
|
* Register one or more providers.
|
|
@@ -15612,13 +15830,13 @@ var CliServiceContainer = class {
|
|
|
15612
15830
|
getRegisteredTokens() {
|
|
15613
15831
|
const tokens = [];
|
|
15614
15832
|
for (const key of this.services.keys()) {
|
|
15615
|
-
tokens.push(
|
|
15616
|
-
|
|
15617
|
-
|
|
15833
|
+
tokens.push(this.tokenToString(key));
|
|
15834
|
+
}
|
|
15835
|
+
for (const key of this.transientRecipes.keys()) {
|
|
15836
|
+
tokens.push(`${this.tokenToString(key)} (transient)`);
|
|
15618
15837
|
}
|
|
15619
15838
|
for (const key of this.multiServices.keys()) {
|
|
15620
|
-
|
|
15621
|
-
tokens.push(`${name} (multi)`);
|
|
15839
|
+
tokens.push(`${this.tokenToString(key)} (multi)`);
|
|
15622
15840
|
}
|
|
15623
15841
|
return tokens;
|
|
15624
15842
|
}
|
|
@@ -15629,20 +15847,34 @@ var CliServiceContainer = class {
|
|
|
15629
15847
|
const details = [];
|
|
15630
15848
|
for (const [key, value] of this.services.entries()) {
|
|
15631
15849
|
details.push({
|
|
15632
|
-
token:
|
|
15850
|
+
token: this.tokenToString(key),
|
|
15633
15851
|
type: this.describeValue(value),
|
|
15634
15852
|
multi: false
|
|
15635
15853
|
});
|
|
15636
15854
|
}
|
|
15855
|
+
for (const [key, provider] of this.transientRecipes.entries()) {
|
|
15856
|
+
const className = provider["useClass"]?.name ?? provider["useFactory"]?.name ?? "transient";
|
|
15857
|
+
details.push({
|
|
15858
|
+
token: this.tokenToString(key),
|
|
15859
|
+
type: `transient(${className})`,
|
|
15860
|
+
multi: false
|
|
15861
|
+
});
|
|
15862
|
+
}
|
|
15637
15863
|
for (const [key, values] of this.multiServices.entries()) {
|
|
15638
15864
|
details.push({
|
|
15639
|
-
token:
|
|
15865
|
+
token: this.tokenToString(key),
|
|
15640
15866
|
type: `[${values.map((v) => this.describeValue(v)).join(", ")}]`,
|
|
15641
15867
|
multi: true
|
|
15642
15868
|
});
|
|
15643
15869
|
}
|
|
15644
15870
|
return details;
|
|
15645
15871
|
}
|
|
15872
|
+
/**
|
|
15873
|
+
* Convert a token to a human-readable string for diagnostics/errors.
|
|
15874
|
+
*/
|
|
15875
|
+
tokenToString(token) {
|
|
15876
|
+
return typeof token === "string" ? token : typeof token === "function" ? token.name : String(token);
|
|
15877
|
+
}
|
|
15646
15878
|
/**
|
|
15647
15879
|
* Describe a resolved value for diagnostic display.
|
|
15648
15880
|
*/
|
|
@@ -15662,27 +15894,45 @@ var CliServiceContainer = class {
|
|
|
15662
15894
|
* Register a single provider.
|
|
15663
15895
|
*/
|
|
15664
15896
|
registerProvider(provider) {
|
|
15665
|
-
|
|
15666
|
-
|
|
15667
|
-
|
|
15668
|
-
|
|
15669
|
-
|
|
15897
|
+
if (!provider.multi && this.sealedTokens.has(provider.provide)) {
|
|
15898
|
+
throw new Error(
|
|
15899
|
+
`CliServiceContainer: Cannot override sealed service "${this.tokenToString(provider.provide)}".`
|
|
15900
|
+
);
|
|
15901
|
+
}
|
|
15902
|
+
if (provider["transient"] && !provider.multi) {
|
|
15903
|
+
this.transientRecipes.set(provider.provide, provider);
|
|
15904
|
+
this.services.delete(provider.provide);
|
|
15670
15905
|
} else {
|
|
15671
|
-
this.
|
|
15906
|
+
const value = this.resolveProvider(provider);
|
|
15907
|
+
if (provider.multi) {
|
|
15908
|
+
const existing = this.multiServices.get(provider.provide) ?? [];
|
|
15909
|
+
existing.push(value);
|
|
15910
|
+
this.multiServices.set(provider.provide, existing);
|
|
15911
|
+
} else {
|
|
15912
|
+
this.services.set(provider.provide, value);
|
|
15913
|
+
this.transientRecipes.delete(provider.provide);
|
|
15914
|
+
}
|
|
15915
|
+
}
|
|
15916
|
+
if (provider.sealed) {
|
|
15917
|
+
this.sealedTokens.add(provider.provide);
|
|
15672
15918
|
}
|
|
15673
15919
|
}
|
|
15674
15920
|
/**
|
|
15675
15921
|
* Resolve a provider definition to a concrete value.
|
|
15922
|
+
*
|
|
15923
|
+
* Note: `deps` are resolved eagerly at registration time, so
|
|
15924
|
+
* dependency tokens must be registered before the provider that needs them.
|
|
15676
15925
|
*/
|
|
15677
15926
|
resolveProvider(provider) {
|
|
15678
15927
|
if ("useValue" in provider) {
|
|
15679
15928
|
return provider.useValue;
|
|
15680
15929
|
}
|
|
15930
|
+
const deps = (provider["deps"] ?? []).map((dep) => this.getRequired(dep));
|
|
15681
15931
|
if ("useFactory" in provider) {
|
|
15682
|
-
return provider.useFactory();
|
|
15932
|
+
return provider.useFactory(...deps);
|
|
15683
15933
|
}
|
|
15684
15934
|
if ("useClass" in provider) {
|
|
15685
|
-
return new provider.useClass();
|
|
15935
|
+
return new provider.useClass(...deps);
|
|
15686
15936
|
}
|
|
15687
15937
|
throw new Error(
|
|
15688
15938
|
"CliServiceContainer: Provider must specify useValue, useFactory, or useClass."
|
|
@@ -15823,10 +16073,10 @@ var welcomeModule = {
|
|
|
15823
16073
|
async onAfterBoot(context2) {
|
|
15824
16074
|
const config = this.config || {};
|
|
15825
16075
|
let showOption = config.show;
|
|
15826
|
-
|
|
15827
|
-
|
|
15828
|
-
|
|
15829
|
-
|
|
16076
|
+
const storeManager = context2.services.get(
|
|
16077
|
+
CliStateStoreManager_TOKEN
|
|
16078
|
+
);
|
|
16079
|
+
if (storeManager) {
|
|
15830
16080
|
const configureStore = storeManager.getStateStore(
|
|
15831
16081
|
CLI_CONFIGURE_STORE_NAME
|
|
15832
16082
|
);
|
|
@@ -15835,7 +16085,6 @@ var welcomeModule = {
|
|
|
15835
16085
|
if (state?.["system"]?.["welcomeMessage"]) {
|
|
15836
16086
|
showOption = state["system"]["welcomeMessage"];
|
|
15837
16087
|
}
|
|
15838
|
-
} catch {
|
|
15839
16088
|
}
|
|
15840
16089
|
if (showOption) {
|
|
15841
16090
|
if (!shouldDisplayWelcomeMessage(showOption)) {
|
|
@@ -15863,11 +16112,11 @@ var welcomeModule = {
|
|
|
15863
16112
|
recordWelcomeMessageDisplay();
|
|
15864
16113
|
context2.showPrompt();
|
|
15865
16114
|
let showGreeting = true;
|
|
15866
|
-
|
|
15867
|
-
|
|
15868
|
-
|
|
15869
|
-
|
|
15870
|
-
const configureStore =
|
|
16115
|
+
const greetingStoreManager = context2.services.get(
|
|
16116
|
+
CliStateStoreManager_TOKEN
|
|
16117
|
+
);
|
|
16118
|
+
if (greetingStoreManager) {
|
|
16119
|
+
const configureStore = greetingStoreManager.getStateStore(
|
|
15871
16120
|
CLI_CONFIGURE_STORE_NAME
|
|
15872
16121
|
);
|
|
15873
16122
|
await configureStore.initialize();
|
|
@@ -15875,7 +16124,6 @@ var welcomeModule = {
|
|
|
15875
16124
|
if (configState?.["system"]?.["greeting"] === false) {
|
|
15876
16125
|
showGreeting = false;
|
|
15877
16126
|
}
|
|
15878
|
-
} catch {
|
|
15879
16127
|
}
|
|
15880
16128
|
if (showGreeting) {
|
|
15881
16129
|
await context2.textAnimator?.showText(getGreetingBasedOnTime(), {
|
|
@@ -15995,8 +16243,8 @@ var CliBoot = class {
|
|
|
15995
16243
|
}
|
|
15996
16244
|
}
|
|
15997
16245
|
if (module.onSetup) {
|
|
15998
|
-
const kvStore = context2.services.
|
|
15999
|
-
|
|
16246
|
+
const kvStore = context2.services.getRequired(
|
|
16247
|
+
CliKeyValueStore_TOKEN
|
|
16000
16248
|
);
|
|
16001
16249
|
const setupKey = `cli-module-setup:${module.name}`;
|
|
16002
16250
|
const setupState = await kvStore.get(setupKey);
|
|
@@ -16376,16 +16624,19 @@ var CliStateStore = class {
|
|
|
16376
16624
|
this.state$.next(this.initialState);
|
|
16377
16625
|
}
|
|
16378
16626
|
async persist() {
|
|
16379
|
-
const keyValueStore = this.services.
|
|
16380
|
-
|
|
16627
|
+
const keyValueStore = this.services.getRequired(
|
|
16628
|
+
CliKeyValueStore_TOKEN
|
|
16381
16629
|
);
|
|
16382
16630
|
await keyValueStore.set(this.storageKey, this.getState());
|
|
16383
16631
|
}
|
|
16384
16632
|
async initialize() {
|
|
16633
|
+
const keyValueStore = this.services.get(
|
|
16634
|
+
CliKeyValueStore_TOKEN
|
|
16635
|
+
);
|
|
16636
|
+
if (!keyValueStore) {
|
|
16637
|
+
return;
|
|
16638
|
+
}
|
|
16385
16639
|
try {
|
|
16386
|
-
const keyValueStore = this.services.get(
|
|
16387
|
-
"cli-key-value-store"
|
|
16388
|
-
);
|
|
16389
16640
|
const state = await keyValueStore.get(this.storageKey);
|
|
16390
16641
|
if (state) {
|
|
16391
16642
|
this.state$.next(state);
|
|
@@ -16452,6 +16703,23 @@ var CliStateStoreManager = class {
|
|
|
16452
16703
|
this.stores.clear();
|
|
16453
16704
|
}
|
|
16454
16705
|
};
|
|
16706
|
+
var CliServerAuthService = class {
|
|
16707
|
+
constructor(services) {
|
|
16708
|
+
this.services = services;
|
|
16709
|
+
}
|
|
16710
|
+
getHeaders(serverName, configHeaders) {
|
|
16711
|
+
const merged = {
|
|
16712
|
+
...resolveHeaders(configHeaders)
|
|
16713
|
+
};
|
|
16714
|
+
const providers = this.services.getAll(
|
|
16715
|
+
ICliServerAuthTokenProvider_TOKEN
|
|
16716
|
+
);
|
|
16717
|
+
for (const provider of providers) {
|
|
16718
|
+
Object.assign(merged, provider.getHeaders(serverName));
|
|
16719
|
+
}
|
|
16720
|
+
return merged;
|
|
16721
|
+
}
|
|
16722
|
+
};
|
|
16455
16723
|
|
|
16456
16724
|
// src/lib/completion/cli-command-completion-provider.ts
|
|
16457
16725
|
var CliCommandCompletionProvider = class {
|
|
@@ -16599,12 +16867,10 @@ var CliPackageNameCompletionProvider = class {
|
|
|
16599
16867
|
if (!INSTALLED_PKG_SUBCOMMANDS.has(subCommand)) {
|
|
16600
16868
|
return [];
|
|
16601
16869
|
}
|
|
16602
|
-
|
|
16603
|
-
|
|
16604
|
-
|
|
16605
|
-
|
|
16606
|
-
);
|
|
16607
|
-
} catch {
|
|
16870
|
+
const manager = this.services.get(
|
|
16871
|
+
CliPackageManagerService_TOKEN
|
|
16872
|
+
);
|
|
16873
|
+
if (!manager) {
|
|
16608
16874
|
return [];
|
|
16609
16875
|
}
|
|
16610
16876
|
const packages = await manager.getPackages();
|
|
@@ -16807,7 +17073,7 @@ var ServerListProcessor = class {
|
|
|
16807
17073
|
this.description = "Show configured servers and their connection status";
|
|
16808
17074
|
}
|
|
16809
17075
|
async processCommand(_command, context2) {
|
|
16810
|
-
const manager = context2.services.
|
|
17076
|
+
const manager = context2.services.getRequired(
|
|
16811
17077
|
CliServerManager_TOKEN
|
|
16812
17078
|
);
|
|
16813
17079
|
if (!manager || manager.connections.size === 0) {
|
|
@@ -16846,7 +17112,7 @@ var ServerStatusProcessor = class {
|
|
|
16846
17112
|
context2.process.exit(1);
|
|
16847
17113
|
return;
|
|
16848
17114
|
}
|
|
16849
|
-
const manager = context2.services.
|
|
17115
|
+
const manager = context2.services.getRequired(
|
|
16850
17116
|
CliServerManager_TOKEN
|
|
16851
17117
|
);
|
|
16852
17118
|
const connection = manager?.getConnection(serverName);
|
|
@@ -16856,6 +17122,7 @@ var ServerStatusProcessor = class {
|
|
|
16856
17122
|
return;
|
|
16857
17123
|
}
|
|
16858
17124
|
context2.spinner?.show(`Pinging ${serverName}...`);
|
|
17125
|
+
context2.notifier.info(`Pinging ${serverName}`);
|
|
16859
17126
|
const reachable = await connection.ping();
|
|
16860
17127
|
context2.spinner?.hide();
|
|
16861
17128
|
if (reachable) {
|
|
@@ -16886,7 +17153,7 @@ var ServerReconnectProcessor = class {
|
|
|
16886
17153
|
context2.process.exit(1);
|
|
16887
17154
|
return;
|
|
16888
17155
|
}
|
|
16889
|
-
const manager = context2.services.
|
|
17156
|
+
const manager = context2.services.getRequired(
|
|
16890
17157
|
CliServerManager_TOKEN
|
|
16891
17158
|
);
|
|
16892
17159
|
if (!manager) {
|
|
@@ -16895,6 +17162,7 @@ var ServerReconnectProcessor = class {
|
|
|
16895
17162
|
return;
|
|
16896
17163
|
}
|
|
16897
17164
|
context2.spinner?.show(`Reconnecting to ${serverName}...`);
|
|
17165
|
+
context2.notifier.info(`Reconnecting to ${serverName}`);
|
|
16898
17166
|
const result = await manager.reconnect(serverName);
|
|
16899
17167
|
context2.spinner?.hide();
|
|
16900
17168
|
if (result.success) {
|
|
@@ -16924,7 +17192,7 @@ var ServerDefaultProcessor = class {
|
|
|
16924
17192
|
];
|
|
16925
17193
|
}
|
|
16926
17194
|
async processCommand(command2, context2) {
|
|
16927
|
-
const manager = context2.services.
|
|
17195
|
+
const manager = context2.services.getRequired(
|
|
16928
17196
|
CliServerManager_TOKEN
|
|
16929
17197
|
);
|
|
16930
17198
|
if (!manager) {
|
|
@@ -16960,8 +17228,6 @@ var ServerDefaultProcessor = class {
|
|
|
16960
17228
|
}
|
|
16961
17229
|
}
|
|
16962
17230
|
};
|
|
16963
|
-
|
|
16964
|
-
// src/lib/server/cli-ssh-command-processor.ts
|
|
16965
17231
|
var CliSshCommandProcessor = class {
|
|
16966
17232
|
constructor() {
|
|
16967
17233
|
this.command = "ssh";
|
|
@@ -16985,7 +17251,7 @@ var CliSshCommandProcessor = class {
|
|
|
16985
17251
|
this.resolved = false;
|
|
16986
17252
|
}
|
|
16987
17253
|
async processCommand(command2, context2) {
|
|
16988
|
-
const manager = context2.services.
|
|
17254
|
+
const manager = context2.services.getRequired(
|
|
16989
17255
|
CliServerManager_TOKEN
|
|
16990
17256
|
);
|
|
16991
17257
|
if (!manager) {
|
|
@@ -17079,7 +17345,7 @@ var CliSshCommandProcessor = class {
|
|
|
17079
17345
|
connection: shellServers[0].connection
|
|
17080
17346
|
};
|
|
17081
17347
|
}
|
|
17082
|
-
const manager = context2.services.
|
|
17348
|
+
const manager = context2.services.getRequired(
|
|
17083
17349
|
CliServerManager_TOKEN
|
|
17084
17350
|
);
|
|
17085
17351
|
if (manager?.defaultServer) {
|
|
@@ -17272,7 +17538,10 @@ var CliSshCommandProcessor = class {
|
|
|
17272
17538
|
if (cmd) {
|
|
17273
17539
|
url += `&cmd=${encodeURIComponent(cmd)}`;
|
|
17274
17540
|
}
|
|
17275
|
-
return
|
|
17541
|
+
return buildAuthenticatedWebSocketUrl(
|
|
17542
|
+
url,
|
|
17543
|
+
() => connection.resolveAuthHeaders()
|
|
17544
|
+
);
|
|
17276
17545
|
}
|
|
17277
17546
|
cleanup() {
|
|
17278
17547
|
if (this.socket) {
|
|
@@ -17321,6 +17590,11 @@ function initializeTerminal(container, opts) {
|
|
|
17321
17590
|
terminal.open(container);
|
|
17322
17591
|
fitAddon.fit();
|
|
17323
17592
|
requestAnimationFrame(() => fitAddon.fit());
|
|
17593
|
+
if (document.fonts?.ready) {
|
|
17594
|
+
document.fonts.ready.then(() => {
|
|
17595
|
+
requestAnimationFrame(() => fitAddon.fit());
|
|
17596
|
+
});
|
|
17597
|
+
}
|
|
17324
17598
|
container.classList.add("terminal-container");
|
|
17325
17599
|
container.style.background = opts.theme?.background ?? "#000";
|
|
17326
17600
|
const wheelListener = (e) => e.preventDefault();
|
|
@@ -17563,19 +17837,21 @@ async function initializeServices(options) {
|
|
|
17563
17837
|
const logger = new CliLogger();
|
|
17564
17838
|
const commandHistory = new CliCommandHistory(store);
|
|
17565
17839
|
await commandHistory.initialize();
|
|
17566
|
-
services.set([{ provide:
|
|
17840
|
+
services.set([{ provide: CliKeyValueStore_TOKEN, useValue: store, sealed: true }]);
|
|
17567
17841
|
const stateStoreManager = new CliStateStoreManager(services, registry);
|
|
17568
17842
|
const processRegistry = new CliProcessRegistry();
|
|
17569
17843
|
services.set([
|
|
17570
17844
|
{
|
|
17571
17845
|
provide: CliStateStoreManager_TOKEN,
|
|
17572
|
-
useValue: stateStoreManager
|
|
17846
|
+
useValue: stateStoreManager,
|
|
17847
|
+
sealed: true
|
|
17573
17848
|
},
|
|
17574
|
-
{ provide: CliProcessorsRegistry_TOKEN, useValue: registry },
|
|
17575
|
-
{ provide: CliCommandHistory_TOKEN, useValue: commandHistory },
|
|
17849
|
+
{ provide: CliProcessorsRegistry_TOKEN, useValue: registry, sealed: true },
|
|
17850
|
+
{ provide: CliCommandHistory_TOKEN, useValue: commandHistory, sealed: true },
|
|
17576
17851
|
{
|
|
17577
17852
|
provide: CliProcessRegistry_TOKEN,
|
|
17578
|
-
useValue: processRegistry
|
|
17853
|
+
useValue: processRegistry,
|
|
17854
|
+
sealed: true
|
|
17579
17855
|
}
|
|
17580
17856
|
]);
|
|
17581
17857
|
if (pendingServices.length > 0) {
|
|
@@ -17586,7 +17862,8 @@ async function initializeServices(options) {
|
|
|
17586
17862
|
services.set([
|
|
17587
17863
|
{
|
|
17588
17864
|
provide: ICliPingServerService_TOKEN,
|
|
17589
|
-
|
|
17865
|
+
useClass: CliDefaultPingServerService,
|
|
17866
|
+
sealed: true
|
|
17590
17867
|
}
|
|
17591
17868
|
]);
|
|
17592
17869
|
}
|
|
@@ -17596,25 +17873,27 @@ async function initializeServices(options) {
|
|
|
17596
17873
|
syntaxRegistry.register(new MarkdownHighlighter());
|
|
17597
17874
|
syntaxRegistry.register(new YamlHighlighter());
|
|
17598
17875
|
services.set([
|
|
17599
|
-
{ provide:
|
|
17876
|
+
{ provide: SyntaxHighlighterRegistry_TOKEN, useValue: syntaxRegistry, sealed: true }
|
|
17600
17877
|
]);
|
|
17601
17878
|
if (!pendingTokens.has(ICliEnvironment_TOKEN)) {
|
|
17602
17879
|
services.set([
|
|
17603
17880
|
{
|
|
17604
17881
|
provide: ICliEnvironment_TOKEN,
|
|
17605
|
-
|
|
17882
|
+
useClass: CliEnvironment,
|
|
17883
|
+
sealed: true
|
|
17606
17884
|
}
|
|
17607
17885
|
]);
|
|
17608
17886
|
}
|
|
17609
17887
|
services.set([
|
|
17610
17888
|
{
|
|
17611
17889
|
provide: ICliDragDropService_TOKEN,
|
|
17612
|
-
useValue: dragDropService
|
|
17890
|
+
useValue: dragDropService,
|
|
17891
|
+
sealed: true
|
|
17613
17892
|
}
|
|
17614
17893
|
]);
|
|
17615
17894
|
const translator = new CliTranslationService();
|
|
17616
17895
|
services.set([
|
|
17617
|
-
{ provide: ICliTranslationService_TOKEN, useValue: translator }
|
|
17896
|
+
{ provide: ICliTranslationService_TOKEN, useValue: translator, sealed: true }
|
|
17618
17897
|
]);
|
|
17619
17898
|
return {
|
|
17620
17899
|
services,
|
|
@@ -17726,10 +18005,18 @@ var CliEngine = class {
|
|
|
17726
18005
|
provide: CliBackgroundServiceRegistry_TOKEN,
|
|
17727
18006
|
useValue: this.executionContext.backgroundServices
|
|
17728
18007
|
}]);
|
|
17729
|
-
const
|
|
18008
|
+
const serverAuthService = new CliServerAuthService(services);
|
|
17730
18009
|
services.set([
|
|
17731
|
-
{ provide:
|
|
18010
|
+
{ provide: ICliServerAuthService_TOKEN, useValue: serverAuthService, sealed: true }
|
|
17732
18011
|
]);
|
|
18012
|
+
services.set([
|
|
18013
|
+
{
|
|
18014
|
+
provide: CliServerManager_TOKEN,
|
|
18015
|
+
useClass: CliServerManager,
|
|
18016
|
+
deps: [CliProcessorsRegistry_TOKEN, ICliServerAuthService_TOKEN]
|
|
18017
|
+
}
|
|
18018
|
+
]);
|
|
18019
|
+
const serverManager = services.getRequired(CliServerManager_TOKEN);
|
|
17733
18020
|
if (this.options?.servers && this.options.servers.length > 0) {
|
|
17734
18021
|
await serverManager.connectAll(this.options.servers, {
|
|
17735
18022
|
warn: (msg) => this.executionContext.logger.warn(msg),
|
|
@@ -17749,13 +18036,9 @@ var CliEngine = class {
|
|
|
17749
18036
|
new CliCommandCompletionProvider(this.registry),
|
|
17750
18037
|
new CliParameterCompletionProvider(this.registry, executor)
|
|
17751
18038
|
];
|
|
17752
|
-
|
|
17753
|
-
|
|
17754
|
-
|
|
17755
|
-
ICliCompletionProvider_TOKEN
|
|
17756
|
-
) ?? [];
|
|
17757
|
-
} catch {
|
|
17758
|
-
}
|
|
18039
|
+
const pluginProviders = services.getAll(
|
|
18040
|
+
ICliCompletionProvider_TOKEN
|
|
18041
|
+
);
|
|
17759
18042
|
this.executionContext.completionEngine.setProviders([
|
|
17760
18043
|
...pluginProviders,
|
|
17761
18044
|
...defaultProviders
|
|
@@ -17778,6 +18061,8 @@ var CliEngine = class {
|
|
|
17778
18061
|
if (this.options?.snapshot) {
|
|
17779
18062
|
await this.restoreSnapshot(this.options.snapshot);
|
|
17780
18063
|
}
|
|
18064
|
+
this._startedAt = Date.now();
|
|
18065
|
+
this.safeFit();
|
|
17781
18066
|
}
|
|
17782
18067
|
/**
|
|
17783
18068
|
* Clean up terminal and event listeners.
|
|
@@ -17836,15 +18121,22 @@ var CliEngine = class {
|
|
|
17836
18121
|
return this.registry;
|
|
17837
18122
|
}
|
|
17838
18123
|
/**
|
|
17839
|
-
*
|
|
18124
|
+
* Timestamp (ms since epoch) when the engine finished starting.
|
|
18125
|
+
*/
|
|
18126
|
+
get startedAt() {
|
|
18127
|
+
return this._startedAt;
|
|
18128
|
+
}
|
|
18129
|
+
/**
|
|
18130
|
+
* Execute a command programmatically, behaving the same as if the user
|
|
18131
|
+
* typed it and pressed Enter: echoes the command, adds it to history,
|
|
18132
|
+
* executes it, and shows a new prompt afterwards.
|
|
17840
18133
|
*/
|
|
17841
18134
|
async execute(command2) {
|
|
17842
|
-
if (this.executionContext)
|
|
17843
|
-
|
|
17844
|
-
|
|
17845
|
-
|
|
17846
|
-
|
|
17847
|
-
}
|
|
18135
|
+
if (!this.executionContext) return;
|
|
18136
|
+
const ctx = this.executionContext;
|
|
18137
|
+
ctx.showPrompt({ reset: true });
|
|
18138
|
+
this.terminal.write(command2 + "\r\n");
|
|
18139
|
+
await ctx.submitCommand(command2);
|
|
17848
18140
|
}
|
|
17849
18141
|
/**
|
|
17850
18142
|
* Capture a snapshot of the current engine state.
|
|
@@ -17854,7 +18146,7 @@ var CliEngine = class {
|
|
|
17854
18146
|
if (!this.executionContext) {
|
|
17855
18147
|
throw new Error("Cannot snapshot before engine has started");
|
|
17856
18148
|
}
|
|
17857
|
-
const stateStoreManager = this.executionContext.services.
|
|
18149
|
+
const stateStoreManager = this.executionContext.services.getRequired(
|
|
17858
18150
|
CliStateStoreManager_TOKEN
|
|
17859
18151
|
);
|
|
17860
18152
|
return {
|
|
@@ -17881,7 +18173,7 @@ var CliEngine = class {
|
|
|
17881
18173
|
});
|
|
17882
18174
|
}
|
|
17883
18175
|
await this.executionContext.commandHistory.setHistory(snap.commandHistory);
|
|
17884
|
-
const stateStoreManager = this.executionContext.services.
|
|
18176
|
+
const stateStoreManager = this.executionContext.services.getRequired(
|
|
17885
18177
|
CliStateStoreManager_TOKEN
|
|
17886
18178
|
);
|
|
17887
18179
|
for (const entry of snap.stateStores) {
|
|
@@ -17941,7 +18233,7 @@ var CliTestHarness = class {
|
|
|
17941
18233
|
this.services = new CliServiceContainer();
|
|
17942
18234
|
this.processRegistry = new CliProcessRegistry();
|
|
17943
18235
|
this.services.set({
|
|
17944
|
-
provide:
|
|
18236
|
+
provide: CliKeyValueStore_TOKEN,
|
|
17945
18237
|
useValue: createInMemoryKvStore()
|
|
17946
18238
|
});
|
|
17947
18239
|
this.services.set({
|
|
@@ -18051,6 +18343,7 @@ var CliTestHarness = class {
|
|
|
18051
18343
|
userSession: this.userSession,
|
|
18052
18344
|
state: this.stateStoreManager.getStateStore("shared"),
|
|
18053
18345
|
backgroundServices: createNoopBackgroundServices(),
|
|
18346
|
+
http: new CliHttpClient(),
|
|
18054
18347
|
promptLength: 0,
|
|
18055
18348
|
currentLine: "",
|
|
18056
18349
|
cursorPosition: 0,
|
|
@@ -18070,6 +18363,10 @@ var CliTestHarness = class {
|
|
|
18070
18363
|
},
|
|
18071
18364
|
exitFullScreenMode: () => {
|
|
18072
18365
|
},
|
|
18366
|
+
submitCommand: async (command2) => {
|
|
18367
|
+
await this.executor.executeCommand(command2, context2);
|
|
18368
|
+
},
|
|
18369
|
+
notifier: new CliNotifier(),
|
|
18073
18370
|
createInterval: (cb, ms) => {
|
|
18074
18371
|
const id = setInterval(cb, ms);
|
|
18075
18372
|
return {
|
|
@@ -18275,6 +18572,6 @@ function createInMemoryKvStore() {
|
|
|
18275
18572
|
};
|
|
18276
18573
|
}
|
|
18277
18574
|
|
|
18278
|
-
export { API_VERSION, CLi_Name_Art, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, CliFeedbackCommandProcessor, CliFontSizeCommandProcessor, CliFullScreenManager, CliHelpCommandProcessor, CliHistoryCommandProcessor, CliHotKeysCommandProcessor, CliHtopCommandProcessor, CliInputReader, CliJsonCommandProcessor, CliKeyValueStore, CliKillCommandProcessor, CliLogger, CliLoremCommandProcessor, CliModuleRegistry_TOKEN, CliNanoCommandProcessor, CliOpenCommandProcessor, CliPackageManagerService, CliPackageManagerService_TOKEN, CliPackagesCommandProcessor, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, OverlayAddon, ProcessExitedError, ScriptLoaderService, appendOutputToFile, appendStderrToFile, builtinProcessors, computeDiff, contextGlobalParameter, createServerModule, executeOnServer, expandEnvironmentVars, formatDiff, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, groupBy, helpGlobalParameter, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, isWasmAccelerated, miscProcessors, openLink, reconcileArgs, renderServerResponse, renderSingleOutput, substituteVars, systemProcessors, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
|
|
18575
|
+
export { API_VERSION, CLi_Name_Art, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, 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, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, OverlayAddon, ProcessExitedError, ScriptLoaderService, SyntaxHighlighterRegistry_TOKEN, appendOutputToFile, appendStderrToFile, builtinProcessors, computeDiff, contextGlobalParameter, createServerModule, executeOnServer, expandEnvironmentVars, formatDiff, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, groupBy, helpGlobalParameter, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, isWasmAccelerated, miscProcessors, openLink, reconcileArgs, renderServerResponse, renderSingleOutput, substituteVars, systemProcessors, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
|
|
18279
18576
|
//# sourceMappingURL=public-api.mjs.map
|
|
18280
18577
|
//# sourceMappingURL=public-api.mjs.map
|