@qodalis/cli 2.0.0-beta.12 → 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/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.12";
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.get(
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.get(
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
- try {
2914
- const translator = context2.services.get(
2915
- ICliTranslationService_TOKEN
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
- try {
3070
- const translator = context2.services.get(
3071
- ICliTranslationService_TOKEN
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.get(
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.get(
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.get(
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.get(
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.get(
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
- writer.writeln();
3779
- writer.writeln(` ${icon}${icon ? " " : ""}${name} ${version}`);
3774
+ const headerLines = [];
3780
3775
  if (processor.description) {
3781
- const desc = this.translateDescription(
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
- writer.writeln(
3790
- ` ${DIM}${t.t("cli.help.aliases", "Aliases:")}${RESET} ${processor.aliases.map((a) => writer.wrapInColor(a, CliForegroundColor.Magenta)).join(", ")}`
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
- writer.writeln(
3959
- ` ${DIM2}CLI${RESET2} ${writer.wrapInColor(`v${LIBRARY_VERSION}`, CliForegroundColor.Green)} ${DIM2}Core${RESET2} ${writer.wrapInColor(`v${LIBRARY_VERSION$1}`, CliForegroundColor.Green)}`
3960
- );
3961
- let framework = "vanilla";
3962
- try {
3963
- framework = context2.services.get("cli-framework");
3964
- } catch {
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
- let framework = "vanilla";
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
- let framework = "vanilla";
4106
- try {
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.get(
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.get(
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.get(
4311
+ const commandHistory = context2.services.getRequired(
4330
4312
  CliCommandHistory_TOKEN
4331
4313
  );
4332
4314
  const history = commandHistory.getHistory();
@@ -4773,7 +4755,7 @@ var CliPackagesCommandProcessor = class {
4773
4755
  const { progressBar, writer } = context2;
4774
4756
  const { signal, cleanup } = scope.createAbortSignal(context2);
4775
4757
  progressBar.show();
4776
- context2.setStatusText("Browsing packages");
4758
+ context2.notifier.info("Browsing packages");
4777
4759
  const prefix = packagesManager.QODALIS_COMMAND_PREFIX;
4778
4760
  const knownShortNames = [
4779
4761
  "browser-storage",
@@ -4966,7 +4948,7 @@ var CliPackagesCommandProcessor = class {
4966
4948
  const packages = command2.value.split(" ");
4967
4949
  for (const pkg of packages) {
4968
4950
  if (signal.aborted) break;
4969
- context2.setStatusText(`Installing ${pkg}`);
4951
+ context2.notifier.info(`Installing ${pkg}`);
4970
4952
  await scope.addPackage(pkg, context2, signal);
4971
4953
  }
4972
4954
  cleanup();
@@ -5007,7 +4989,7 @@ var CliPackagesCommandProcessor = class {
5007
4989
  const packages = command2.value.split(" ");
5008
4990
  for (const pkg of packages) {
5009
4991
  if (signal.aborted) break;
5010
- context2.setStatusText(`Removing ${pkg}`);
4992
+ context2.notifier.info(`Removing ${pkg}`);
5011
4993
  await scope.removePackage(pkg, context2);
5012
4994
  }
5013
4995
  cleanup();
@@ -5043,7 +5025,7 @@ var CliPackagesCommandProcessor = class {
5043
5025
  const fullName = name.startsWith(prefix) ? name : `${prefix}${name}`;
5044
5026
  progressBar.show();
5045
5027
  progressBar.setText(`Fetching versions for ${name}`);
5046
- context2.setStatusText(`Fetching versions for ${name}`);
5028
+ context2.notifier.info(`Fetching versions for ${name}`);
5047
5029
  try {
5048
5030
  const response = await scriptsLoader.getScript(
5049
5031
  `https://registry.npmjs.org/${encodeURIComponent(fullName)}`,
@@ -5507,11 +5489,11 @@ var CliPackagesCommandProcessor = class {
5507
5489
  );
5508
5490
  }
5509
5491
  async initialize(context2) {
5510
- this.registry = context2.services.get(
5492
+ this.registry = context2.services.getRequired(
5511
5493
  CliProcessorsRegistry_TOKEN
5512
5494
  );
5513
- const store = context2.services.get(
5514
- "cli-key-value-store"
5495
+ const store = context2.services.getRequired(
5496
+ CliKeyValueStore_TOKEN
5515
5497
  );
5516
5498
  this.packagesManager.setStore(store);
5517
5499
  context2.services.set([{
@@ -5777,10 +5759,11 @@ var CliPackagesCommandProcessor = class {
5777
5759
  }
5778
5760
  };
5779
5761
  var CliServerConnection = class _CliServerConnection {
5780
- constructor(_config, _backgroundServices, _logger) {
5762
+ constructor(_config, _backgroundServices, _logger, _authService) {
5781
5763
  this._config = _config;
5782
5764
  this._backgroundServices = _backgroundServices;
5783
5765
  this._logger = _logger;
5766
+ this._authService = _authService;
5784
5767
  this._connected = false;
5785
5768
  this._commands = [];
5786
5769
  this._capabilities = null;
@@ -5819,10 +5802,21 @@ var CliServerConnection = class _CliServerConnection {
5819
5802
  get apiVersion() {
5820
5803
  return this._apiVersion;
5821
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
+ }
5822
5816
  async connect() {
5823
5817
  try {
5824
5818
  const baseUrl = this.normalizeUrl(this._config.url);
5825
- const negotiated = await ServerVersionNegotiator.discover(baseUrl);
5819
+ const negotiated = await ServerVersionNegotiator.discover(baseUrl, () => this.resolveAuthHeaders());
5826
5820
  if (negotiated) {
5827
5821
  this._apiVersion = negotiated.apiVersion;
5828
5822
  this._basePath = negotiated.basePath;
@@ -6017,7 +6011,10 @@ var CliServerConnection = class _CliServerConnection {
6017
6011
  type: "daemon",
6018
6012
  onStart: async (ctx) => {
6019
6013
  const baseUrl = this.normalizeUrl(this._config.url);
6020
- const wsUrl = this.toWebSocketUrl(baseUrl) + "/ws/v1/qcli/events";
6014
+ const wsUrl = buildAuthenticatedWebSocketUrl(
6015
+ this.toWebSocketUrl(baseUrl) + "/ws/v1/qcli/events",
6016
+ () => this.resolveAuthHeaders()
6017
+ );
6021
6018
  ctx.log(`Connecting to ${wsUrl}`);
6022
6019
  this._eventSocket = new WebSocket(wsUrl);
6023
6020
  this._eventSocket.onopen = () => {
@@ -6067,7 +6064,10 @@ var CliServerConnection = class _CliServerConnection {
6067
6064
  connectEventSocketDirect() {
6068
6065
  try {
6069
6066
  const baseUrl = this.normalizeUrl(this._config.url);
6070
- const wsUrl = this.toWebSocketUrl(baseUrl) + "/ws/v1/qcli/events";
6067
+ const wsUrl = buildAuthenticatedWebSocketUrl(
6068
+ this.toWebSocketUrl(baseUrl) + "/ws/v1/qcli/events",
6069
+ () => this.resolveAuthHeaders()
6070
+ );
6071
6071
  this._eventSocket = new WebSocket(wsUrl);
6072
6072
  this._eventSocket.onopen = () => {
6073
6073
  this._wsReconnectAttempts = 0;
@@ -6170,7 +6170,7 @@ var CliServerConnection = class _CliServerConnection {
6170
6170
  const controller = new AbortController();
6171
6171
  const timer = setTimeout(() => controller.abort(), timeout);
6172
6172
  const headers = {
6173
- ...this._config.headers ?? {},
6173
+ ...this.resolveAuthHeaders(),
6174
6174
  ...init?.headers ?? {}
6175
6175
  };
6176
6176
  return fetch(url, {
@@ -6251,7 +6251,7 @@ async function executeOnServer(connection, serverName, descriptor, command2, con
6251
6251
  chainCommands: commandPath && commandPath.length > 1 ? commandPath.slice(1) : []
6252
6252
  };
6253
6253
  const cmdLabel = commandPath && commandPath.length > 0 ? commandPath.join(" ") : descriptor.command;
6254
- context2.setStatusText(`executing command: ${cmdLabel} on server ${serverName}`);
6254
+ context2.notifier.info(`executing command: ${cmdLabel} on server ${serverName}`);
6255
6255
  try {
6256
6256
  if (connection.capabilities?.streaming) {
6257
6257
  const result = await connection.executeStream(
@@ -6439,8 +6439,9 @@ var CliServerMultiProxyProcessor = class _CliServerMultiProxyProcessor {
6439
6439
  // src/lib/server/cli-server-manager.ts
6440
6440
  var CliServerManager_TOKEN = "cli-server-manager";
6441
6441
  var CliServerManager = class {
6442
- constructor(registry) {
6442
+ constructor(registry, authService) {
6443
6443
  this.registry = registry;
6444
+ this.authService = authService;
6444
6445
  this.connections = /* @__PURE__ */ new Map();
6445
6446
  this._defaultServer = null;
6446
6447
  }
@@ -6461,7 +6462,7 @@ var CliServerManager = class {
6461
6462
  this._backgroundServices = backgroundServices;
6462
6463
  for (const config of servers) {
6463
6464
  if (config.enabled === false) continue;
6464
- const connection = new CliServerConnection(config, backgroundServices, cliLogger);
6465
+ const connection = new CliServerConnection(config, backgroundServices, cliLogger, this.authService);
6465
6466
  this.connections.set(config.name, connection);
6466
6467
  connection.onDisconnect = () => {
6467
6468
  this.handleDisconnect(config.name);
@@ -7012,7 +7013,7 @@ var CliDebugCommandProcessor = class {
7012
7013
  metadata: { icon: CliIcon.Extension, module: "system" },
7013
7014
  processCommand: async (_, context2) => {
7014
7015
  const { writer } = context2;
7015
- const registry = context2.services.get(
7016
+ const registry = context2.services.getRequired(
7016
7017
  CliProcessorsRegistry_TOKEN
7017
7018
  );
7018
7019
  writer.writeln(
@@ -7063,12 +7064,10 @@ var CliDebugCommandProcessor = class {
7063
7064
  metadata: { icon: CliIcon.Module, module: "system" },
7064
7065
  processCommand: async (_, context2) => {
7065
7066
  const { writer } = context2;
7066
- let moduleRegistry;
7067
- try {
7068
- moduleRegistry = context2.services.get(
7069
- CliModuleRegistry_TOKEN
7070
- );
7071
- } catch {
7067
+ const moduleRegistry = context2.services.get(
7068
+ CliModuleRegistry_TOKEN
7069
+ );
7070
+ if (!moduleRegistry) {
7072
7071
  writer.writeError("Module registry not available.");
7073
7072
  return;
7074
7073
  }
@@ -7109,7 +7108,7 @@ var CliDebugCommandProcessor = class {
7109
7108
  metadata: { icon: CliIcon.Database, module: "system" },
7110
7109
  processCommand: async (_, context2) => {
7111
7110
  const { writer } = context2;
7112
- const storeManager = context2.services.get(
7111
+ const storeManager = context2.services.getRequired(
7113
7112
  CliStateStoreManager_TOKEN
7114
7113
  );
7115
7114
  const entries = storeManager.getStoreEntries();
@@ -7188,11 +7187,7 @@ var CliDebugCommandProcessor = class {
7188
7187
  writer.writeln(
7189
7188
  ` ${writer.wrapInColor("CLI Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION}`
7190
7189
  );
7191
- let framework = "vanilla";
7192
- try {
7193
- framework = context2.services.get("cli-framework");
7194
- } catch {
7195
- }
7190
+ const framework = context2.services.get("cli-framework") ?? "vanilla";
7196
7191
  writer.writeln(
7197
7192
  ` ${writer.wrapInColor("Framework:", CliForegroundColor.Cyan)} ${framework}`
7198
7193
  );
@@ -7233,7 +7228,7 @@ var CliDebugCommandProcessor = class {
7233
7228
  metadata: { icon: CliIcon.Logs, module: "system" },
7234
7229
  processCommand: async (_, context2) => {
7235
7230
  const { writer } = context2;
7236
- const history = context2.services.get(
7231
+ const history = context2.services.getRequired(
7237
7232
  CliCommandHistory_TOKEN
7238
7233
  );
7239
7234
  const commands = history.getHistory();
@@ -7322,14 +7317,14 @@ var CliDebugCommandProcessor = class {
7322
7317
  writer.writeln(
7323
7318
  ` ${online ? CliIcon.CheckIcon : CliIcon.CrossIcon} Network: ${online ? "online" : "offline"}`
7324
7319
  );
7325
- const registry = context2.services.get(
7320
+ const registry = context2.services.getRequired(
7326
7321
  CliProcessorsRegistry_TOKEN
7327
7322
  );
7328
7323
  writer.writeln(
7329
7324
  ` ${CliIcon.CheckIcon} Processors: ${registry.processors.length} loaded`
7330
7325
  );
7331
7326
  try {
7332
- const moduleRegistry = context2.services.get(
7327
+ const moduleRegistry = context2.services.getRequired(
7333
7328
  CliModuleRegistry_TOKEN
7334
7329
  );
7335
7330
  const modules = moduleRegistry.getAll();
@@ -7345,7 +7340,7 @@ var CliDebugCommandProcessor = class {
7345
7340
  writer.writeln(
7346
7341
  ` ${wasmActive ? CliIcon.CheckIcon : CliIcon.WarningIcon} WASM Accelerator: ${wasmActive ? "loaded" : "using JS fallback"}`
7347
7342
  );
7348
- const historyService = context2.services.get(
7343
+ const historyService = context2.services.getRequired(
7349
7344
  CliCommandHistory_TOKEN
7350
7345
  );
7351
7346
  writer.writeln(
@@ -7359,13 +7354,13 @@ var CliDebugCommandProcessor = class {
7359
7354
  metadata: { icon: CliIcon.Save, module: "system" },
7360
7355
  processCommand: async (_, context2) => {
7361
7356
  const { writer } = context2;
7362
- const registry = context2.services.get(
7357
+ const registry = context2.services.getRequired(
7363
7358
  CliProcessorsRegistry_TOKEN
7364
7359
  );
7365
- const history = context2.services.get(
7360
+ const history = context2.services.getRequired(
7366
7361
  CliCommandHistory_TOKEN
7367
7362
  );
7368
- const storeManager = context2.services.get(
7363
+ const storeManager = context2.services.getRequired(
7369
7364
  CliStateStoreManager_TOKEN
7370
7365
  );
7371
7366
  const report = {
@@ -7398,7 +7393,7 @@ var CliDebugCommandProcessor = class {
7398
7393
  state: storeManager.getStoreEntries()
7399
7394
  };
7400
7395
  try {
7401
- const moduleRegistry = context2.services.get(
7396
+ const moduleRegistry = context2.services.getRequired(
7402
7397
  CliModuleRegistry_TOKEN
7403
7398
  );
7404
7399
  report["modules"] = moduleRegistry.getAll().map((m) => ({
@@ -7416,7 +7411,7 @@ var CliDebugCommandProcessor = class {
7416
7411
  report["services"] = container.getRegisteredTokens();
7417
7412
  }
7418
7413
  try {
7419
- const serverManager = context2.services.get(
7414
+ const serverManager = context2.services.getRequired(
7420
7415
  CliServerManager_TOKEN
7421
7416
  );
7422
7417
  if (serverManager && serverManager.connections.size > 0) {
@@ -7440,13 +7435,9 @@ var CliDebugCommandProcessor = class {
7440
7435
  metadata: { icon: CliIcon.Server, module: "system" },
7441
7436
  processCommand: async (_, context2) => {
7442
7437
  const { writer } = context2;
7443
- let manager;
7444
- try {
7445
- manager = context2.services.get(
7446
- CliServerManager_TOKEN
7447
- );
7448
- } catch {
7449
- }
7438
+ const manager = context2.services.get(
7439
+ CliServerManager_TOKEN
7440
+ );
7450
7441
  if (!manager || manager.connections.size === 0) {
7451
7442
  writer.writeInfo("No servers configured.");
7452
7443
  return;
@@ -7486,70 +7477,48 @@ var CliDebugCommandProcessor = class {
7486
7477
  }
7487
7478
  async processCommand(_, context2) {
7488
7479
  const { writer } = context2;
7489
- const registry = context2.services.get(
7480
+ const registry = context2.services.getRequired(
7490
7481
  CliProcessorsRegistry_TOKEN
7491
7482
  );
7492
- writer.writeln(
7493
- writer.wrapInColor(
7494
- `${CliIcon.Bug} CLI Debug Info`,
7495
- CliForegroundColor.Yellow
7496
- )
7497
- );
7498
- writer.writeDivider({ char: "=" });
7499
- writer.writeln(
7500
- ` ${writer.wrapInColor("Core Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION$1}`
7501
- );
7502
- writer.writeln(
7503
- ` ${writer.wrapInColor("CLI Version:", CliForegroundColor.Cyan)} ${LIBRARY_VERSION}`
7483
+ const summaryFramework = context2.services.get("cli-framework") ?? "vanilla";
7484
+ const summaryModuleRegistry = context2.services.get(
7485
+ CliModuleRegistry_TOKEN
7504
7486
  );
7505
- let framework = "vanilla";
7506
- try {
7507
- framework = context2.services.get("cli-framework");
7508
- } catch {
7509
- }
7510
- writer.writeln(
7511
- ` ${writer.wrapInColor("Framework:", CliForegroundColor.Cyan)} ${framework}`
7512
- );
7513
- writer.writeln(
7514
- ` ${writer.wrapInColor("Terminal:", CliForegroundColor.Cyan)} ${context2.terminal.cols}x${context2.terminal.rows}`
7487
+ const summaryServerManager = context2.services.get(
7488
+ CliServerManager_TOKEN
7515
7489
  );
7516
- writer.writeln(
7517
- ` ${writer.wrapInColor("Processors:", CliForegroundColor.Cyan)} ${registry.processors.length}`
7490
+ const history = context2.services.getRequired(
7491
+ CliCommandHistory_TOKEN
7518
7492
  );
7519
- try {
7520
- const moduleRegistry = context2.services.get(
7521
- CliModuleRegistry_TOKEN
7522
- );
7523
- writer.writeln(
7524
- ` ${writer.wrapInColor("Modules:", CliForegroundColor.Cyan)} ${moduleRegistry.getAll().length}`
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}`
7525
7504
  );
7526
- } catch {
7527
7505
  }
7528
- try {
7529
- const serverManager = context2.services.get(
7530
- CliServerManager_TOKEN
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`
7531
7512
  );
7532
- if (serverManager && serverManager.connections.size > 0) {
7533
- const connected = Array.from(
7534
- serverManager.connections.values()
7535
- ).filter((c) => c.connected).length;
7536
- writer.writeln(
7537
- ` ${writer.wrapInColor("Servers:", CliForegroundColor.Cyan)} ${connected}/${serverManager.connections.size} connected`
7538
- );
7539
- }
7540
- } catch {
7541
7513
  }
7542
- const history = context2.services.get(
7543
- CliCommandHistory_TOKEN
7544
- );
7545
- writer.writeln(
7546
- ` ${writer.wrapInColor("History:", CliForegroundColor.Cyan)} ${history.getHistory().length} commands`
7547
- );
7548
- const wasmStatus = isWasmAccelerated() ? "active" : "inactive (JS fallback)";
7549
- writer.writeln(
7550
- ` ${writer.wrapInColor("WASM Accelerator:", CliForegroundColor.Cyan)} ${wasmStatus}`
7514
+ lines.push(
7515
+ `${writer.wrapInColor("History:", CliForegroundColor.Cyan)} ${history.getHistory().length} commands`,
7516
+ `${writer.wrapInColor("WASM Accelerator:", CliForegroundColor.Cyan)} ${wasmStatus}`
7551
7517
  );
7552
- writer.writeDivider({ char: "=" });
7518
+ writer.writeBox(lines, {
7519
+ title: "CLI Debug Info",
7520
+ borderColor: CliForegroundColor.Yellow
7521
+ });
7553
7522
  writer.writeln();
7554
7523
  writer.writeln(`${CliIcon.Light} Subcommands:`);
7555
7524
  for (const sub of this.processors || []) {
@@ -8135,7 +8104,7 @@ var CliNanoCommandProcessor = class {
8135
8104
  this.replaceWith = "";
8136
8105
  this.statusMessage = void 0;
8137
8106
  try {
8138
- this.fs = context2.services.get(FS_TOKEN);
8107
+ this.fs = context2.services.getRequired(FS_TOKEN);
8139
8108
  } catch {
8140
8109
  this.fs = null;
8141
8110
  }
@@ -8474,8 +8443,8 @@ var CliNanoCommandProcessor = class {
8474
8443
  return;
8475
8444
  }
8476
8445
  try {
8477
- const registry = this.context.services.get(
8478
- "syntax-highlighter-registry"
8446
+ const registry = this.context.services.getRequired(
8447
+ SyntaxHighlighterRegistry_TOKEN
8479
8448
  );
8480
8449
  const ext = "." + filePath.split(".").pop()?.toLowerCase();
8481
8450
  const highlighter = registry.getByExtension(ext);
@@ -9112,7 +9081,7 @@ var CliPsCommandProcessor = class {
9112
9081
  async processCommand(_command, context2) {
9113
9082
  let registry;
9114
9083
  try {
9115
- registry = context2.services.get(
9084
+ registry = context2.services.getRequired(
9116
9085
  CliProcessRegistry_TOKEN
9117
9086
  );
9118
9087
  } catch {
@@ -9151,7 +9120,7 @@ var CliKillCommandProcessor = class {
9151
9120
  async processCommand(command2, context2) {
9152
9121
  let registry;
9153
9122
  try {
9154
- registry = context2.services.get(
9123
+ registry = context2.services.getRequired(
9155
9124
  CliProcessRegistry_TOKEN
9156
9125
  );
9157
9126
  } catch {
@@ -9266,11 +9235,10 @@ var CliHtopCommandProcessor = class {
9266
9235
  this.errorTimeout = null;
9267
9236
  }
9268
9237
  async processCommand(_command, context2) {
9269
- try {
9270
- this.registry = context2.services.get(
9271
- CliProcessRegistry_TOKEN
9272
- );
9273
- } catch {
9238
+ this.registry = context2.services.get(
9239
+ CliProcessRegistry_TOKEN
9240
+ ) ?? null;
9241
+ if (!this.registry) {
9274
9242
  context2.writer.writeError("Process registry not available");
9275
9243
  return;
9276
9244
  }
@@ -10410,7 +10378,7 @@ var CliPingCommandProcessor = class {
10410
10378
  context2.writer.writeln(
10411
10379
  `PING ${host} (${url}):`
10412
10380
  );
10413
- context2.setStatusText(`ping ${host}`);
10381
+ context2.notifier.info(`ping ${host}`);
10414
10382
  const times = [];
10415
10383
  let transmitted = 0;
10416
10384
  let received = 0;
@@ -10425,18 +10393,17 @@ var CliPingCommandProcessor = class {
10425
10393
  transmitted++;
10426
10394
  const start = performance.now();
10427
10395
  try {
10428
- const response = await fetch(url, {
10396
+ const response = await context2.http.fetch(url, {
10429
10397
  method: "HEAD",
10430
10398
  mode: "no-cors",
10431
- cache: "no-store",
10432
- signal: context2.signal
10399
+ cache: "no-store"
10433
10400
  });
10434
10401
  const elapsed = performance.now() - start;
10435
10402
  const ms = elapsed.toFixed(1);
10436
10403
  received++;
10437
10404
  times.push(elapsed);
10438
10405
  const status = response.type === "opaque" ? "ok" : `status=${response.status}`;
10439
- context2.setStatusText(`ping ${host}: seq=${seq} time=${ms}ms`);
10406
+ context2.notifier.info(`ping ${host}: seq=${seq} time=${ms}ms`);
10440
10407
  context2.writer.writeln(
10441
10408
  `${url}: seq=${seq} ${status} time=${ms} ms`
10442
10409
  );
@@ -10570,7 +10537,7 @@ var CliExportCommandProcessor = class {
10570
10537
  this.metadata = { icon: "\u{1F4E6}", module: "system" };
10571
10538
  }
10572
10539
  async processCommand(command2, context2) {
10573
- const env = context2.services.get(
10540
+ const env = context2.services.getRequired(
10574
10541
  ICliEnvironment_TOKEN
10575
10542
  );
10576
10543
  const raw = (command2.value || "").trim();
@@ -10624,7 +10591,7 @@ var CliUnsetCommandProcessor = class {
10624
10591
  this.metadata = { icon: "\u{1F5D1}\uFE0F", module: "system" };
10625
10592
  }
10626
10593
  async processCommand(command2, context2) {
10627
- const env = context2.services.get(
10594
+ const env = context2.services.getRequired(
10628
10595
  ICliEnvironment_TOKEN
10629
10596
  );
10630
10597
  const varName = (command2.value || "").trim();
@@ -10658,7 +10625,7 @@ var CliEnvCommandProcessor = class {
10658
10625
  this.metadata = { icon: "\u{1F30D}", module: "system" };
10659
10626
  }
10660
10627
  async processCommand(command2, context2) {
10661
- const env = context2.services.get(
10628
+ const env = context2.services.getRequired(
10662
10629
  ICliEnvironment_TOKEN
10663
10630
  );
10664
10631
  const varName = (command2.value || "").trim();
@@ -10906,16 +10873,9 @@ var CliCommandExecutionContext = class {
10906
10873
  this.createInterval = (cb, ms) => context2.createInterval(cb, ms);
10907
10874
  this.createTimeout = (cb, ms) => context2.createTimeout(cb, ms);
10908
10875
  this.backgroundServices = context2.backgroundServices;
10909
- this.state = context2.services.get(CliStateStoreManager_TOKEN).getProcessorStateStore(processor);
10910
- }
10911
- setStatusText(text) {
10912
- this.context.setStatusText(text);
10913
- }
10914
- clearStatusText() {
10915
- this.context.clearStatusText();
10916
- }
10917
- getStatusText() {
10918
- return this.context.getStatusText();
10876
+ this.http = context2.http;
10877
+ this.notifier = context2.notifier;
10878
+ this.state = context2.services.getRequired(CliStateStoreManager_TOKEN).getProcessorStateStore(processor);
10919
10879
  }
10920
10880
  get promptLength() {
10921
10881
  return this.context.promptLength;
@@ -11466,6 +11426,172 @@ var CliBackgroundServiceRegistry = class {
11466
11426
  }
11467
11427
  };
11468
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
+
11469
11595
  // src/lib/context/cli-fullscreen-manager.ts
11470
11596
  var CliFullScreenManager = class {
11471
11597
  constructor(terminal, backgroundServices) {
@@ -14488,7 +14614,6 @@ var CliExecutionContext = class {
14488
14614
  * Set by the command executor at start/end of executeCommand().
14489
14615
  */
14490
14616
  this.isExecuting = false;
14491
- this.statusTextChange$ = new Subject();
14492
14617
  this.lineBuffer = new CliLineBuffer();
14493
14618
  this.modeStack = [];
14494
14619
  this.timerManager = new CliTimerManager();
@@ -14533,6 +14658,8 @@ var CliExecutionContext = class {
14533
14658
  this.logger.setCliLogLevel(cliOptions?.logLevel || CliLogLevel.ERROR);
14534
14659
  this.commandHistory = deps.commandHistory;
14535
14660
  this.lineRenderer = new CliTerminalLineRenderer(terminal, this.writer);
14661
+ this.http = new CliHttpClient();
14662
+ this.notifier = new CliNotifier();
14536
14663
  this.backgroundServices = new CliBackgroundServiceRegistry(
14537
14664
  this.state,
14538
14665
  deps.services,
@@ -14543,17 +14670,6 @@ var CliExecutionContext = class {
14543
14670
  this.backgroundServices
14544
14671
  );
14545
14672
  }
14546
- setStatusText(text) {
14547
- this._statusText = text;
14548
- this.statusTextChange$.next(text);
14549
- }
14550
- clearStatusText() {
14551
- this._statusText = void 0;
14552
- this.statusTextChange$.next(void 0);
14553
- }
14554
- getStatusText() {
14555
- return this._statusText;
14556
- }
14557
14673
  // -- Public API (ICliExecutionContext) --
14558
14674
  writeToTerminal(text) {
14559
14675
  this.terminal.write(text);
@@ -14747,12 +14863,8 @@ var CliExecutionContext = class {
14747
14863
  }
14748
14864
  // -- CommandLineModeHost interface --
14749
14865
  getPromptOptions() {
14750
- let hideUserName = false;
14751
- try {
14752
- const config = this.services.get("cli-users-module-config");
14753
- hideUserName = config?.hideUserName ?? false;
14754
- } catch {
14755
- }
14866
+ const usersConfig = this.services.get("cli-users-module-config");
14867
+ const hideUserName = usersConfig?.hideUserName ?? false;
14756
14868
  return {
14757
14869
  userName: this.userSession?.displayName,
14758
14870
  hideUserName,
@@ -15000,10 +15112,8 @@ var contextGlobalParameter = {
15000
15112
  // src/lib/executor/cli-io-redirect-handler.ts
15001
15113
  var FS_TOKEN2 = "cli-file-system-service";
15002
15114
  async function writeOutputToFile(filePath, context2) {
15003
- let fs;
15004
- try {
15005
- fs = context2.services.get(FS_TOKEN2);
15006
- } catch {
15115
+ const fs = context2.services.get(FS_TOKEN2);
15116
+ if (!fs) {
15007
15117
  context2.writer.writeError(
15008
15118
  "> redirect requires @qodalis/cli-files plugin"
15009
15119
  );
@@ -15027,10 +15137,8 @@ async function writeOutputToFile(filePath, context2) {
15027
15137
  }
15028
15138
  }
15029
15139
  async function appendOutputToFile(filePath, context2) {
15030
- let fs;
15031
- try {
15032
- fs = context2.services.get(FS_TOKEN2);
15033
- } catch {
15140
+ const fs = context2.services.get(FS_TOKEN2);
15141
+ if (!fs) {
15034
15142
  context2.writer.writeError(
15035
15143
  ">> redirect requires @qodalis/cli-files plugin"
15036
15144
  );
@@ -15056,10 +15164,8 @@ async function appendOutputToFile(filePath, context2) {
15056
15164
  async function writeStderrToFile(filePath, context2, capturingWriter) {
15057
15165
  const stderr = capturingWriter?.getCapturedStderr();
15058
15166
  if (!stderr) return;
15059
- let fs;
15060
- try {
15061
- fs = context2.services.get(FS_TOKEN2);
15062
- } catch {
15167
+ const fs = context2.services.get(FS_TOKEN2);
15168
+ if (!fs) {
15063
15169
  context2.writer.writeError(
15064
15170
  "2> redirect requires @qodalis/cli-files plugin"
15065
15171
  );
@@ -15080,10 +15186,8 @@ async function writeStderrToFile(filePath, context2, capturingWriter) {
15080
15186
  async function appendStderrToFile(filePath, context2, capturingWriter) {
15081
15187
  const stderr = capturingWriter?.getCapturedStderr();
15082
15188
  if (!stderr) return;
15083
- let fs;
15084
- try {
15085
- fs = context2.services.get(FS_TOKEN2);
15086
- } catch {
15189
+ const fs = context2.services.get(FS_TOKEN2);
15190
+ if (!fs) {
15087
15191
  context2.writer.writeError(
15088
15192
  "2>> redirect requires @qodalis/cli-files plugin"
15089
15193
  );
@@ -15103,10 +15207,8 @@ async function appendStderrToFile(filePath, context2, capturingWriter) {
15103
15207
  }
15104
15208
  async function tryExecuteScript(filePath, context2, executeCommand) {
15105
15209
  const FS_TOKEN3 = "cli-file-system-service";
15106
- let fs;
15107
- try {
15108
- fs = context2.services.get(FS_TOKEN3);
15109
- } catch {
15210
+ const fs = context2.services.get(FS_TOKEN3);
15211
+ if (!fs) {
15110
15212
  return false;
15111
15213
  }
15112
15214
  const resolved = fs.resolvePath(filePath);
@@ -15183,10 +15285,8 @@ function substituteVars(input, variables) {
15183
15285
  return result;
15184
15286
  }
15185
15287
  function expandEnvironmentVars(command2, context2) {
15186
- let env;
15187
- try {
15188
- env = context2.services.get(ICliEnvironment_TOKEN);
15189
- } catch {
15288
+ const env = context2.services.get(ICliEnvironment_TOKEN);
15289
+ if (!env) {
15190
15290
  return command2;
15191
15291
  }
15192
15292
  const parts = command2.split("'");
@@ -15331,7 +15431,7 @@ var CliCommandExecutor = class {
15331
15431
  }
15332
15432
  } finally {
15333
15433
  rootContext.isExecuting = false;
15334
- rootContext.clearStatusText?.();
15434
+ rootContext.notifier?.clear();
15335
15435
  }
15336
15436
  }
15337
15437
  async executeSingleCommand(command2, data, context2) {
@@ -15339,8 +15439,8 @@ var CliCommandExecutor = class {
15339
15439
  command2 = expandEnvironmentVars(command2, context2);
15340
15440
  const assignMatch = command2.match(/^([A-Za-z_][A-Za-z0-9_]*)=(.*)$/);
15341
15441
  if (assignMatch) {
15342
- try {
15343
- const env = context2.services.get(ICliEnvironment_TOKEN);
15442
+ const env = context2.services.get(ICliEnvironment_TOKEN);
15443
+ if (env) {
15344
15444
  let val = assignMatch[2];
15345
15445
  if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
15346
15446
  val = val.slice(1, -1);
@@ -15349,15 +15449,13 @@ var CliCommandExecutor = class {
15349
15449
  process.start();
15350
15450
  process.end();
15351
15451
  return;
15352
- } catch {
15353
15452
  }
15354
15453
  }
15355
15454
  process.start();
15356
15455
  let processEntry;
15357
- try {
15358
- const procRegistry = context2.services.get(CliProcessRegistry_TOKEN);
15456
+ const procRegistry = context2.services.get(CliProcessRegistry_TOKEN);
15457
+ if (procRegistry) {
15359
15458
  processEntry = procRegistry.register(command2);
15360
- } catch {
15361
15459
  }
15362
15460
  const parsed = this.commandParser.parse(command2);
15363
15461
  let { commandName } = parsed;
@@ -15470,6 +15568,7 @@ var CliCommandExecutor = class {
15470
15568
  );
15471
15569
  const commandAbortController = new AbortController();
15472
15570
  commandContext.signal = commandAbortController.signal;
15571
+ commandContext.http = new CliHttpClient(commandAbortController.signal);
15473
15572
  const abortSub = context2.onAbort.subscribe(() => {
15474
15573
  commandAbortController.abort();
15475
15574
  });
@@ -15534,19 +15633,13 @@ var CliCommandExecutor = class {
15534
15633
  }
15535
15634
  completeProcess(processEntry, context2, exitCode) {
15536
15635
  if (!processEntry) return;
15537
- try {
15538
- const procRegistry = context2.services.get(CliProcessRegistry_TOKEN);
15539
- procRegistry.complete(processEntry.pid, exitCode);
15540
- } catch {
15541
- }
15636
+ const procRegistry = context2.services.get(CliProcessRegistry_TOKEN);
15637
+ procRegistry?.complete(processEntry.pid, exitCode);
15542
15638
  }
15543
15639
  failProcess(processEntry, context2) {
15544
15640
  if (!processEntry) return;
15545
- try {
15546
- const procRegistry = context2.services.get(CliProcessRegistry_TOKEN);
15547
- procRegistry.fail(processEntry.pid);
15548
- } catch {
15549
- }
15641
+ const failRegistry = context2.services.get(CliProcessRegistry_TOKEN);
15642
+ failRegistry?.fail(processEntry.pid);
15550
15643
  }
15551
15644
  async showHelp(command2, context2) {
15552
15645
  try {
@@ -15628,29 +15721,94 @@ var CliCommandExecutor = class {
15628
15721
  // src/lib/services/cli-service-container.ts
15629
15722
  var CliServiceContainer = class {
15630
15723
  constructor() {
15631
- /** Stores single-value providers (resolved or pending). */
15724
+ /** Stores single-value providers (resolved singletons). */
15632
15725
  this.services = /* @__PURE__ */ new Map();
15633
15726
  /** Stores multi-provider arrays. */
15634
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();
15635
15732
  }
15636
15733
  /**
15637
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).
15638
15737
  *
15639
15738
  * @param token The token used to register the service.
15640
- * @returns The resolved service instance (or array for multi providers).
15641
- * @throws Error if the token has not been registered.
15739
+ * @returns The resolved service instance, or `undefined` if not registered.
15642
15740
  */
15643
15741
  get(token) {
15742
+ if (this.transientRecipes.has(token)) {
15743
+ return this.resolveProvider(this.transientRecipes.get(token));
15744
+ }
15644
15745
  if (this.multiServices.has(token)) {
15645
- return this.multiServices.get(token);
15746
+ const arr = this.multiServices.get(token);
15747
+ return arr[arr.length - 1];
15646
15748
  }
15647
15749
  if (this.services.has(token)) {
15648
15750
  return this.services.get(token);
15649
15751
  }
15650
- const tokenName = typeof token === "string" ? token : typeof token === "function" ? token.name : String(token);
15651
- throw new Error(
15652
- `CliServiceContainer: No provider found for token "${tokenName}".`
15653
- );
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);
15654
15812
  }
15655
15813
  /**
15656
15814
  * Register one or more providers.
@@ -15672,13 +15830,13 @@ var CliServiceContainer = class {
15672
15830
  getRegisteredTokens() {
15673
15831
  const tokens = [];
15674
15832
  for (const key of this.services.keys()) {
15675
- tokens.push(
15676
- typeof key === "string" ? key : typeof key === "function" ? key.name : String(key)
15677
- );
15833
+ tokens.push(this.tokenToString(key));
15834
+ }
15835
+ for (const key of this.transientRecipes.keys()) {
15836
+ tokens.push(`${this.tokenToString(key)} (transient)`);
15678
15837
  }
15679
15838
  for (const key of this.multiServices.keys()) {
15680
- const name = typeof key === "string" ? key : typeof key === "function" ? key.name : String(key);
15681
- tokens.push(`${name} (multi)`);
15839
+ tokens.push(`${this.tokenToString(key)} (multi)`);
15682
15840
  }
15683
15841
  return tokens;
15684
15842
  }
@@ -15689,20 +15847,34 @@ var CliServiceContainer = class {
15689
15847
  const details = [];
15690
15848
  for (const [key, value] of this.services.entries()) {
15691
15849
  details.push({
15692
- token: typeof key === "string" ? key : typeof key === "function" ? key.name : String(key),
15850
+ token: this.tokenToString(key),
15693
15851
  type: this.describeValue(value),
15694
15852
  multi: false
15695
15853
  });
15696
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
+ }
15697
15863
  for (const [key, values] of this.multiServices.entries()) {
15698
15864
  details.push({
15699
- token: typeof key === "string" ? key : typeof key === "function" ? key.name : String(key),
15865
+ token: this.tokenToString(key),
15700
15866
  type: `[${values.map((v) => this.describeValue(v)).join(", ")}]`,
15701
15867
  multi: true
15702
15868
  });
15703
15869
  }
15704
15870
  return details;
15705
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
+ }
15706
15878
  /**
15707
15879
  * Describe a resolved value for diagnostic display.
15708
15880
  */
@@ -15722,27 +15894,45 @@ var CliServiceContainer = class {
15722
15894
  * Register a single provider.
15723
15895
  */
15724
15896
  registerProvider(provider) {
15725
- const value = this.resolveProvider(provider);
15726
- if (provider.multi) {
15727
- const existing = this.multiServices.get(provider.provide) ?? [];
15728
- existing.push(value);
15729
- this.multiServices.set(provider.provide, existing);
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);
15730
15905
  } else {
15731
- this.services.set(provider.provide, value);
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);
15732
15918
  }
15733
15919
  }
15734
15920
  /**
15735
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.
15736
15925
  */
15737
15926
  resolveProvider(provider) {
15738
15927
  if ("useValue" in provider) {
15739
15928
  return provider.useValue;
15740
15929
  }
15930
+ const deps = (provider["deps"] ?? []).map((dep) => this.getRequired(dep));
15741
15931
  if ("useFactory" in provider) {
15742
- return provider.useFactory();
15932
+ return provider.useFactory(...deps);
15743
15933
  }
15744
15934
  if ("useClass" in provider) {
15745
- return new provider.useClass();
15935
+ return new provider.useClass(...deps);
15746
15936
  }
15747
15937
  throw new Error(
15748
15938
  "CliServiceContainer: Provider must specify useValue, useFactory, or useClass."
@@ -15883,10 +16073,10 @@ var welcomeModule = {
15883
16073
  async onAfterBoot(context2) {
15884
16074
  const config = this.config || {};
15885
16075
  let showOption = config.show;
15886
- try {
15887
- const storeManager = context2.services.get(
15888
- CliStateStoreManager_TOKEN
15889
- );
16076
+ const storeManager = context2.services.get(
16077
+ CliStateStoreManager_TOKEN
16078
+ );
16079
+ if (storeManager) {
15890
16080
  const configureStore = storeManager.getStateStore(
15891
16081
  CLI_CONFIGURE_STORE_NAME
15892
16082
  );
@@ -15895,7 +16085,6 @@ var welcomeModule = {
15895
16085
  if (state?.["system"]?.["welcomeMessage"]) {
15896
16086
  showOption = state["system"]["welcomeMessage"];
15897
16087
  }
15898
- } catch {
15899
16088
  }
15900
16089
  if (showOption) {
15901
16090
  if (!shouldDisplayWelcomeMessage(showOption)) {
@@ -15923,11 +16112,11 @@ var welcomeModule = {
15923
16112
  recordWelcomeMessageDisplay();
15924
16113
  context2.showPrompt();
15925
16114
  let showGreeting = true;
15926
- try {
15927
- const storeManager = context2.services.get(
15928
- CliStateStoreManager_TOKEN
15929
- );
15930
- const configureStore = storeManager.getStateStore(
16115
+ const greetingStoreManager = context2.services.get(
16116
+ CliStateStoreManager_TOKEN
16117
+ );
16118
+ if (greetingStoreManager) {
16119
+ const configureStore = greetingStoreManager.getStateStore(
15931
16120
  CLI_CONFIGURE_STORE_NAME
15932
16121
  );
15933
16122
  await configureStore.initialize();
@@ -15935,7 +16124,6 @@ var welcomeModule = {
15935
16124
  if (configState?.["system"]?.["greeting"] === false) {
15936
16125
  showGreeting = false;
15937
16126
  }
15938
- } catch {
15939
16127
  }
15940
16128
  if (showGreeting) {
15941
16129
  await context2.textAnimator?.showText(getGreetingBasedOnTime(), {
@@ -16055,8 +16243,8 @@ var CliBoot = class {
16055
16243
  }
16056
16244
  }
16057
16245
  if (module.onSetup) {
16058
- const kvStore = context2.services.get(
16059
- "cli-key-value-store"
16246
+ const kvStore = context2.services.getRequired(
16247
+ CliKeyValueStore_TOKEN
16060
16248
  );
16061
16249
  const setupKey = `cli-module-setup:${module.name}`;
16062
16250
  const setupState = await kvStore.get(setupKey);
@@ -16436,16 +16624,19 @@ var CliStateStore = class {
16436
16624
  this.state$.next(this.initialState);
16437
16625
  }
16438
16626
  async persist() {
16439
- const keyValueStore = this.services.get(
16440
- "cli-key-value-store"
16627
+ const keyValueStore = this.services.getRequired(
16628
+ CliKeyValueStore_TOKEN
16441
16629
  );
16442
16630
  await keyValueStore.set(this.storageKey, this.getState());
16443
16631
  }
16444
16632
  async initialize() {
16633
+ const keyValueStore = this.services.get(
16634
+ CliKeyValueStore_TOKEN
16635
+ );
16636
+ if (!keyValueStore) {
16637
+ return;
16638
+ }
16445
16639
  try {
16446
- const keyValueStore = this.services.get(
16447
- "cli-key-value-store"
16448
- );
16449
16640
  const state = await keyValueStore.get(this.storageKey);
16450
16641
  if (state) {
16451
16642
  this.state$.next(state);
@@ -16512,6 +16703,23 @@ var CliStateStoreManager = class {
16512
16703
  this.stores.clear();
16513
16704
  }
16514
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
+ };
16515
16723
 
16516
16724
  // src/lib/completion/cli-command-completion-provider.ts
16517
16725
  var CliCommandCompletionProvider = class {
@@ -16659,12 +16867,10 @@ var CliPackageNameCompletionProvider = class {
16659
16867
  if (!INSTALLED_PKG_SUBCOMMANDS.has(subCommand)) {
16660
16868
  return [];
16661
16869
  }
16662
- let manager;
16663
- try {
16664
- manager = this.services.get(
16665
- CliPackageManagerService_TOKEN
16666
- );
16667
- } catch {
16870
+ const manager = this.services.get(
16871
+ CliPackageManagerService_TOKEN
16872
+ );
16873
+ if (!manager) {
16668
16874
  return [];
16669
16875
  }
16670
16876
  const packages = await manager.getPackages();
@@ -16867,7 +17073,7 @@ var ServerListProcessor = class {
16867
17073
  this.description = "Show configured servers and their connection status";
16868
17074
  }
16869
17075
  async processCommand(_command, context2) {
16870
- const manager = context2.services.get(
17076
+ const manager = context2.services.getRequired(
16871
17077
  CliServerManager_TOKEN
16872
17078
  );
16873
17079
  if (!manager || manager.connections.size === 0) {
@@ -16906,7 +17112,7 @@ var ServerStatusProcessor = class {
16906
17112
  context2.process.exit(1);
16907
17113
  return;
16908
17114
  }
16909
- const manager = context2.services.get(
17115
+ const manager = context2.services.getRequired(
16910
17116
  CliServerManager_TOKEN
16911
17117
  );
16912
17118
  const connection = manager?.getConnection(serverName);
@@ -16916,7 +17122,7 @@ var ServerStatusProcessor = class {
16916
17122
  return;
16917
17123
  }
16918
17124
  context2.spinner?.show(`Pinging ${serverName}...`);
16919
- context2.setStatusText(`Pinging ${serverName}`);
17125
+ context2.notifier.info(`Pinging ${serverName}`);
16920
17126
  const reachable = await connection.ping();
16921
17127
  context2.spinner?.hide();
16922
17128
  if (reachable) {
@@ -16947,7 +17153,7 @@ var ServerReconnectProcessor = class {
16947
17153
  context2.process.exit(1);
16948
17154
  return;
16949
17155
  }
16950
- const manager = context2.services.get(
17156
+ const manager = context2.services.getRequired(
16951
17157
  CliServerManager_TOKEN
16952
17158
  );
16953
17159
  if (!manager) {
@@ -16956,7 +17162,7 @@ var ServerReconnectProcessor = class {
16956
17162
  return;
16957
17163
  }
16958
17164
  context2.spinner?.show(`Reconnecting to ${serverName}...`);
16959
- context2.setStatusText(`Reconnecting to ${serverName}`);
17165
+ context2.notifier.info(`Reconnecting to ${serverName}`);
16960
17166
  const result = await manager.reconnect(serverName);
16961
17167
  context2.spinner?.hide();
16962
17168
  if (result.success) {
@@ -16986,7 +17192,7 @@ var ServerDefaultProcessor = class {
16986
17192
  ];
16987
17193
  }
16988
17194
  async processCommand(command2, context2) {
16989
- const manager = context2.services.get(
17195
+ const manager = context2.services.getRequired(
16990
17196
  CliServerManager_TOKEN
16991
17197
  );
16992
17198
  if (!manager) {
@@ -17022,8 +17228,6 @@ var ServerDefaultProcessor = class {
17022
17228
  }
17023
17229
  }
17024
17230
  };
17025
-
17026
- // src/lib/server/cli-ssh-command-processor.ts
17027
17231
  var CliSshCommandProcessor = class {
17028
17232
  constructor() {
17029
17233
  this.command = "ssh";
@@ -17047,7 +17251,7 @@ var CliSshCommandProcessor = class {
17047
17251
  this.resolved = false;
17048
17252
  }
17049
17253
  async processCommand(command2, context2) {
17050
- const manager = context2.services.get(
17254
+ const manager = context2.services.getRequired(
17051
17255
  CliServerManager_TOKEN
17052
17256
  );
17053
17257
  if (!manager) {
@@ -17141,7 +17345,7 @@ var CliSshCommandProcessor = class {
17141
17345
  connection: shellServers[0].connection
17142
17346
  };
17143
17347
  }
17144
- const manager = context2.services.get(
17348
+ const manager = context2.services.getRequired(
17145
17349
  CliServerManager_TOKEN
17146
17350
  );
17147
17351
  if (manager?.defaultServer) {
@@ -17334,7 +17538,10 @@ var CliSshCommandProcessor = class {
17334
17538
  if (cmd) {
17335
17539
  url += `&cmd=${encodeURIComponent(cmd)}`;
17336
17540
  }
17337
- return url;
17541
+ return buildAuthenticatedWebSocketUrl(
17542
+ url,
17543
+ () => connection.resolveAuthHeaders()
17544
+ );
17338
17545
  }
17339
17546
  cleanup() {
17340
17547
  if (this.socket) {
@@ -17383,6 +17590,11 @@ function initializeTerminal(container, opts) {
17383
17590
  terminal.open(container);
17384
17591
  fitAddon.fit();
17385
17592
  requestAnimationFrame(() => fitAddon.fit());
17593
+ if (document.fonts?.ready) {
17594
+ document.fonts.ready.then(() => {
17595
+ requestAnimationFrame(() => fitAddon.fit());
17596
+ });
17597
+ }
17386
17598
  container.classList.add("terminal-container");
17387
17599
  container.style.background = opts.theme?.background ?? "#000";
17388
17600
  const wheelListener = (e) => e.preventDefault();
@@ -17625,19 +17837,21 @@ async function initializeServices(options) {
17625
17837
  const logger = new CliLogger();
17626
17838
  const commandHistory = new CliCommandHistory(store);
17627
17839
  await commandHistory.initialize();
17628
- services.set([{ provide: "cli-key-value-store", useValue: store }]);
17840
+ services.set([{ provide: CliKeyValueStore_TOKEN, useValue: store, sealed: true }]);
17629
17841
  const stateStoreManager = new CliStateStoreManager(services, registry);
17630
17842
  const processRegistry = new CliProcessRegistry();
17631
17843
  services.set([
17632
17844
  {
17633
17845
  provide: CliStateStoreManager_TOKEN,
17634
- useValue: stateStoreManager
17846
+ useValue: stateStoreManager,
17847
+ sealed: true
17635
17848
  },
17636
- { provide: CliProcessorsRegistry_TOKEN, useValue: registry },
17637
- { provide: CliCommandHistory_TOKEN, useValue: commandHistory },
17849
+ { provide: CliProcessorsRegistry_TOKEN, useValue: registry, sealed: true },
17850
+ { provide: CliCommandHistory_TOKEN, useValue: commandHistory, sealed: true },
17638
17851
  {
17639
17852
  provide: CliProcessRegistry_TOKEN,
17640
- useValue: processRegistry
17853
+ useValue: processRegistry,
17854
+ sealed: true
17641
17855
  }
17642
17856
  ]);
17643
17857
  if (pendingServices.length > 0) {
@@ -17648,7 +17862,8 @@ async function initializeServices(options) {
17648
17862
  services.set([
17649
17863
  {
17650
17864
  provide: ICliPingServerService_TOKEN,
17651
- useValue: new CliDefaultPingServerService()
17865
+ useClass: CliDefaultPingServerService,
17866
+ sealed: true
17652
17867
  }
17653
17868
  ]);
17654
17869
  }
@@ -17658,25 +17873,27 @@ async function initializeServices(options) {
17658
17873
  syntaxRegistry.register(new MarkdownHighlighter());
17659
17874
  syntaxRegistry.register(new YamlHighlighter());
17660
17875
  services.set([
17661
- { provide: "syntax-highlighter-registry", useValue: syntaxRegistry }
17876
+ { provide: SyntaxHighlighterRegistry_TOKEN, useValue: syntaxRegistry, sealed: true }
17662
17877
  ]);
17663
17878
  if (!pendingTokens.has(ICliEnvironment_TOKEN)) {
17664
17879
  services.set([
17665
17880
  {
17666
17881
  provide: ICliEnvironment_TOKEN,
17667
- useValue: new CliEnvironment()
17882
+ useClass: CliEnvironment,
17883
+ sealed: true
17668
17884
  }
17669
17885
  ]);
17670
17886
  }
17671
17887
  services.set([
17672
17888
  {
17673
17889
  provide: ICliDragDropService_TOKEN,
17674
- useValue: dragDropService
17890
+ useValue: dragDropService,
17891
+ sealed: true
17675
17892
  }
17676
17893
  ]);
17677
17894
  const translator = new CliTranslationService();
17678
17895
  services.set([
17679
- { provide: ICliTranslationService_TOKEN, useValue: translator }
17896
+ { provide: ICliTranslationService_TOKEN, useValue: translator, sealed: true }
17680
17897
  ]);
17681
17898
  return {
17682
17899
  services,
@@ -17788,10 +18005,18 @@ var CliEngine = class {
17788
18005
  provide: CliBackgroundServiceRegistry_TOKEN,
17789
18006
  useValue: this.executionContext.backgroundServices
17790
18007
  }]);
17791
- const serverManager = new CliServerManager(this.registry);
18008
+ const serverAuthService = new CliServerAuthService(services);
18009
+ services.set([
18010
+ { provide: ICliServerAuthService_TOKEN, useValue: serverAuthService, sealed: true }
18011
+ ]);
17792
18012
  services.set([
17793
- { provide: CliServerManager_TOKEN, useValue: serverManager }
18013
+ {
18014
+ provide: CliServerManager_TOKEN,
18015
+ useClass: CliServerManager,
18016
+ deps: [CliProcessorsRegistry_TOKEN, ICliServerAuthService_TOKEN]
18017
+ }
17794
18018
  ]);
18019
+ const serverManager = services.getRequired(CliServerManager_TOKEN);
17795
18020
  if (this.options?.servers && this.options.servers.length > 0) {
17796
18021
  await serverManager.connectAll(this.options.servers, {
17797
18022
  warn: (msg) => this.executionContext.logger.warn(msg),
@@ -17811,13 +18036,9 @@ var CliEngine = class {
17811
18036
  new CliCommandCompletionProvider(this.registry),
17812
18037
  new CliParameterCompletionProvider(this.registry, executor)
17813
18038
  ];
17814
- let pluginProviders = [];
17815
- try {
17816
- pluginProviders = services.get(
17817
- ICliCompletionProvider_TOKEN
17818
- ) ?? [];
17819
- } catch {
17820
- }
18039
+ const pluginProviders = services.getAll(
18040
+ ICliCompletionProvider_TOKEN
18041
+ );
17821
18042
  this.executionContext.completionEngine.setProviders([
17822
18043
  ...pluginProviders,
17823
18044
  ...defaultProviders
@@ -17925,7 +18146,7 @@ var CliEngine = class {
17925
18146
  if (!this.executionContext) {
17926
18147
  throw new Error("Cannot snapshot before engine has started");
17927
18148
  }
17928
- const stateStoreManager = this.executionContext.services.get(
18149
+ const stateStoreManager = this.executionContext.services.getRequired(
17929
18150
  CliStateStoreManager_TOKEN
17930
18151
  );
17931
18152
  return {
@@ -17952,7 +18173,7 @@ var CliEngine = class {
17952
18173
  });
17953
18174
  }
17954
18175
  await this.executionContext.commandHistory.setHistory(snap.commandHistory);
17955
- const stateStoreManager = this.executionContext.services.get(
18176
+ const stateStoreManager = this.executionContext.services.getRequired(
17956
18177
  CliStateStoreManager_TOKEN
17957
18178
  );
17958
18179
  for (const entry of snap.stateStores) {
@@ -18012,7 +18233,7 @@ var CliTestHarness = class {
18012
18233
  this.services = new CliServiceContainer();
18013
18234
  this.processRegistry = new CliProcessRegistry();
18014
18235
  this.services.set({
18015
- provide: "cli-key-value-store",
18236
+ provide: CliKeyValueStore_TOKEN,
18016
18237
  useValue: createInMemoryKvStore()
18017
18238
  });
18018
18239
  this.services.set({
@@ -18122,6 +18343,7 @@ var CliTestHarness = class {
18122
18343
  userSession: this.userSession,
18123
18344
  state: this.stateStoreManager.getStateStore("shared"),
18124
18345
  backgroundServices: createNoopBackgroundServices(),
18346
+ http: new CliHttpClient(),
18125
18347
  promptLength: 0,
18126
18348
  currentLine: "",
18127
18349
  cursorPosition: 0,
@@ -18144,11 +18366,7 @@ var CliTestHarness = class {
18144
18366
  submitCommand: async (command2) => {
18145
18367
  await this.executor.executeCommand(command2, context2);
18146
18368
  },
18147
- setStatusText: () => {
18148
- },
18149
- clearStatusText: () => {
18150
- },
18151
- getStatusText: () => void 0,
18369
+ notifier: new CliNotifier(),
18152
18370
  createInterval: (cb, ms) => {
18153
18371
  const id = setInterval(cb, ms);
18154
18372
  return {
@@ -18354,6 +18572,6 @@ function createInMemoryKvStore() {
18354
18572
  };
18355
18573
  }
18356
18574
 
18357
- 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 };
18358
18576
  //# sourceMappingURL=public-api.mjs.map
18359
18577
  //# sourceMappingURL=public-api.mjs.map