@termix-ssh/cli 1.3.1 → 1.3.2

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/dist/index.js CHANGED
@@ -44797,7 +44797,7 @@ function unavailableFor(pluginId, reason) {
44797
44797
  }
44798
44798
 
44799
44799
  // src/version.ts
44800
- var CLI_VERSION = true ? "1.3.1" : "0.0.0-dev";
44800
+ var CLI_VERSION = true ? "1.3.2" : "0.0.0-dev";
44801
44801
 
44802
44802
  // src/core/http.ts
44803
44803
  var MAX_ATTEMPTS = 3;
@@ -45972,6 +45972,10 @@ ${command}
45972
45972
  )
45973
45973
  printf '\\n${EXIT_MARKER}%d\\n' "$?"`;
45974
45974
  }
45975
+ function reportsExitCode(version2) {
45976
+ const [major = 0, minor = 0, patch = 0] = (version2 ?? "").split(/[.-]/).map((part) => Number(part) || 0);
45977
+ return major > 1 || major === 1 && (minor > 4 || minor === 4 && patch >= 1);
45978
+ }
45975
45979
  var EXIT_MARKER_RE = new RegExp(`\\n?${EXIT_MARKER}(\\d+)\\s*$`);
45976
45980
  function parseExecOutput(raw) {
45977
45981
  const match = raw.match(EXIT_MARKER_RE);
@@ -46032,13 +46036,20 @@ function registerExecCommands(program3) {
46032
46036
  const command = commandParts.join(" ");
46033
46037
  const { client, requireFeature: requireFeature2 } = await createContext(this);
46034
46038
  await requireFeature2("snippets");
46039
+ const snippets = (await getServerPlugins(client)).find(
46040
+ (plugin) => plugin.id === FEATURES.snippets.pluginId
46041
+ );
46042
+ const direct = reportsExitCode(snippets?.version);
46035
46043
  const result = await executeOnHost(
46036
46044
  client,
46037
46045
  hostId,
46038
- wrapCommand(command),
46046
+ direct ? command : wrapCommand(command),
46039
46047
  `cli-exec-${randomUUID()}`
46040
46048
  );
46041
- const { output: output2, exitCode } = parseExecOutput(result.output ?? "");
46049
+ const { output: output2, exitCode } = direct ? {
46050
+ output: result.output ?? "",
46051
+ exitCode: typeof result.exitCode === "number" ? result.exitCode : null
46052
+ } : parseExecOutput(result.output ?? "");
46042
46053
  if (output2) process.stdout.write(output2);
46043
46054
  if (result.error) process.stderr.write(result.error);
46044
46055
  process.exitCode = exitCode ?? (result.success ? 0 : 1);
@@ -46302,6 +46313,7 @@ function toHostConfig(id, host) {
46302
46313
  credentialId: host.credentialId
46303
46314
  };
46304
46315
  }
46316
+ var EXIT_LINE = "exit\r";
46305
46317
  function registerSshCommands(program3) {
46306
46318
  program3.command("ssh <hostId>").description(
46307
46319
  "Open an interactive terminal on a host. Requires a session token: API keys cannot open a WebSocket."
@@ -46462,7 +46474,7 @@ async function runSession(socket, opts) {
46462
46474
  const scheduleExit = () => {
46463
46475
  if (opts.interactive || !opts.command) return;
46464
46476
  if (idleTimer) clearTimeout(idleTimer);
46465
- idleTimer = setTimeout(() => socket.input("exit\n"), 1500);
46477
+ idleTimer = setTimeout(() => socket.input(EXIT_LINE), 1500);
46466
46478
  idleTimer.unref?.();
46467
46479
  };
46468
46480
  socket.onMessage((message) => {