pi-better-background-tasks 0.2.3 → 0.2.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pi-better-background-tasks",
3
- "version": "0.2.3",
3
+ "version": "0.2.4",
4
4
  "description": "Pi extension for durable background shell tasks, watchers, logs, and status inspection.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -113,8 +113,14 @@ const REQUIRED_SSH_OPTIONS = new Set(["batchmode", "connecttimeout", "requesttty
113
113
  const DIRECT_STOP_WARNING = "Direct SSH mode has weak stop semantics: stopping the local SSH client may leave the remote process running.";
114
114
  const TMUX_STATUS_PREFIX = "__PI_BG_STATUS__=";
115
115
  const TMUX_SIZE_PREFIX = "__PI_BG_SIZE__=";
116
+ const TMUX_PATH_PREFIX = "__PI_BG_TMUX_PATH__=";
117
+ const TMUX_VERSION_PREFIX = "__PI_BG_TMUX_VERSION__=";
116
118
  const TMUX_CAPTURE_CHUNK_BYTES = 256 * 1024;
117
- const TMUX_PROBE_COMMAND = "tmux_path=$(command -v tmux) || exit 127; printf '%s\\n' \"$tmux_path\" && \"$tmux_path\" -V";
119
+ const TMUX_PROBE_COMMAND = [
120
+ "tmux_path=$(command -v tmux) || exit 127",
121
+ `printf '${TMUX_PATH_PREFIX}%s\\n' "$tmux_path"`,
122
+ `printf '${TMUX_VERSION_PREFIX}%s\\n' "$("$tmux_path" -V)"`,
123
+ ].join("; ");
118
124
  const TMUX_PACKAGE_MANAGERS: TmuxPackageManager[] = ["apt-get", "dnf", "yum", "apk", "pacman", "zypper", "brew"];
119
125
  const TMUX_INSTALL_COMMANDS: Record<TmuxPackageManager, string> = {
120
126
  "apt-get": "apt-get update && apt-get install -y tmux",
@@ -523,8 +529,16 @@ function resolveBootstrapTimeoutMs(timeoutMs: number | undefined): number {
523
529
  }
524
530
 
525
531
  function parseTmuxCapability(result: CommandResult): { tmuxPath: string; tmuxVersion: string } | undefined {
526
- const [tmuxPath, tmuxVersion] = result.stdout.trim().split("\n");
527
- if (result.exitCode !== 0 || !tmuxPath || !tmuxVersion) return undefined;
532
+ if (result.exitCode !== 0) return undefined;
533
+ let tmuxPath: string | undefined;
534
+ let tmuxVersion: string | undefined;
535
+ for (const line of result.stdout.split("\n")) {
536
+ if (line.startsWith(TMUX_PATH_PREFIX)) tmuxPath = line.slice(TMUX_PATH_PREFIX.length);
537
+ if (line.startsWith(TMUX_VERSION_PREFIX)) tmuxVersion = line.slice(TMUX_VERSION_PREFIX.length);
538
+ }
539
+ if (!tmuxPath || !tmuxVersion) return undefined;
540
+ if (!tmuxPath.startsWith("/") || /\s/.test(tmuxPath)) return undefined;
541
+ if (!/^tmux\b/i.test(tmuxVersion)) return undefined;
528
542
  return { tmuxPath, tmuxVersion };
529
543
  }
530
544