terminal-pilot 0.0.7 → 0.0.8

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.
Files changed (51) hide show
  1. package/dist/cli.js +52 -105
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.js +19 -83
  4. package/dist/commands/close-session.js.map +3 -3
  5. package/dist/commands/create-session.js +19 -83
  6. package/dist/commands/create-session.js.map +3 -3
  7. package/dist/commands/fill.js +19 -83
  8. package/dist/commands/fill.js.map +3 -3
  9. package/dist/commands/get-session.js +19 -83
  10. package/dist/commands/get-session.js.map +3 -3
  11. package/dist/commands/index.js +27 -94
  12. package/dist/commands/index.js.map +4 -4
  13. package/dist/commands/install.js +2 -5
  14. package/dist/commands/install.js.map +4 -4
  15. package/dist/commands/installer.js +2 -5
  16. package/dist/commands/installer.js.map +4 -4
  17. package/dist/commands/list-sessions.js +19 -83
  18. package/dist/commands/list-sessions.js.map +3 -3
  19. package/dist/commands/press-key.js +19 -83
  20. package/dist/commands/press-key.js.map +3 -3
  21. package/dist/commands/read-history.js +19 -83
  22. package/dist/commands/read-history.js.map +3 -3
  23. package/dist/commands/read-screen.js +19 -83
  24. package/dist/commands/read-screen.js.map +3 -3
  25. package/dist/commands/resize.js +19 -83
  26. package/dist/commands/resize.js.map +3 -3
  27. package/dist/commands/runtime.js +19 -83
  28. package/dist/commands/runtime.js.map +3 -3
  29. package/dist/commands/screenshot.js +19 -83
  30. package/dist/commands/screenshot.js.map +3 -3
  31. package/dist/commands/send-signal.js +19 -83
  32. package/dist/commands/send-signal.js.map +3 -3
  33. package/dist/commands/type.js +19 -83
  34. package/dist/commands/type.js.map +3 -3
  35. package/dist/commands/uninstall.js +1 -4
  36. package/dist/commands/uninstall.js.map +4 -4
  37. package/dist/commands/wait-for-exit.js +19 -83
  38. package/dist/commands/wait-for-exit.js.map +3 -3
  39. package/dist/commands/wait-for.js +19 -83
  40. package/dist/commands/wait-for.js.map +3 -3
  41. package/dist/index.js +19 -83
  42. package/dist/index.js.map +3 -3
  43. package/dist/terminal-pilot.js +19 -83
  44. package/dist/terminal-pilot.js.map +3 -3
  45. package/dist/terminal-session.js +19 -83
  46. package/dist/terminal-session.js.map +3 -3
  47. package/dist/testing/cli-repl.js +52 -105
  48. package/dist/testing/cli-repl.js.map +4 -4
  49. package/dist/testing/qa-cli.js +52 -105
  50. package/dist/testing/qa-cli.js.map +4 -4
  51. package/package.json +1 -1
@@ -1015,8 +1015,10 @@ async function renderTerminalPng(ansiText, options = {}) {
1015
1015
  import { randomUUID } from "node:crypto";
1016
1016
 
1017
1017
  // src/terminal-session.ts
1018
- import { spawn as spawnChildProcess } from "node:child_process";
1019
1018
  import { EventEmitter } from "node:events";
1019
+ import { accessSync, chmodSync, constants } from "node:fs";
1020
+ import { createRequire as createRequire2 } from "node:module";
1021
+ import { dirname as dirname2, join as join2 } from "node:path";
1020
1022
  import * as nodePty from "node-pty";
1021
1023
 
1022
1024
  // src/ansi.ts
@@ -1927,93 +1929,27 @@ function createPtyProcess({
1927
1929
  cols,
1928
1930
  rows
1929
1931
  }) {
1930
- try {
1931
- return nodePty.spawn(command, args, {
1932
- cwd,
1933
- env,
1934
- cols,
1935
- rows,
1936
- encoding: "utf8"
1937
- });
1938
- } catch {
1939
- return createChildProcessFallback({ command, args, cwd, env });
1940
- }
1941
- }
1942
- function createChildProcessFallback({
1943
- command,
1944
- args,
1945
- cwd,
1946
- env
1947
- }) {
1948
- const child = spawnChildProcess(command, args, {
1932
+ ensureSpawnHelperExecutable();
1933
+ return nodePty.spawn(command, args, {
1949
1934
  cwd,
1950
1935
  env,
1951
- stdio: ["pipe", "pipe", "pipe"]
1936
+ cols,
1937
+ rows,
1938
+ encoding: "utf8"
1952
1939
  });
1953
- return new ChildProcessFallback(child);
1954
1940
  }
1955
- var ChildProcessFallback = class {
1956
- pid;
1957
- child;
1958
- dataEmitter = new EventEmitter();
1959
- exitEmitter = new EventEmitter();
1960
- constructor(child) {
1961
- this.child = child;
1962
- this.pid = child.pid ?? -1;
1963
- child.stdout.setEncoding("utf8");
1964
- child.stderr.setEncoding("utf8");
1965
- child.stdout.on("data", this.handleData);
1966
- child.stderr.on("data", this.handleData);
1967
- child.on("exit", (exitCode, signal) => {
1968
- this.exitEmitter.emit("exit", {
1969
- exitCode: exitCode ?? signalToExitCode(signal),
1970
- signal: void 0
1971
- });
1972
- });
1973
- }
1974
- write(data) {
1975
- this.child.stdin.write(data);
1976
- }
1977
- resize() {
1978
- }
1979
- kill(signal) {
1980
- this.child.kill(signal);
1981
- }
1982
- onData(listener) {
1983
- this.dataEmitter.on("data", listener);
1984
- return {
1985
- dispose: () => {
1986
- this.dataEmitter.off("data", listener);
1987
- }
1988
- };
1989
- }
1990
- onExit(listener) {
1991
- this.exitEmitter.on("exit", listener);
1992
- return {
1993
- dispose: () => {
1994
- this.exitEmitter.off("exit", listener);
1995
- }
1996
- };
1997
- }
1998
- handleData = (chunk) => {
1999
- this.dataEmitter.emit("data", String(chunk));
2000
- };
2001
- };
2002
- function signalToExitCode(signal) {
2003
- if (signal === null) {
2004
- return 0;
2005
- }
2006
- const signalNumbers = {
2007
- SIGTERM: 15,
2008
- SIGINT: 2,
2009
- SIGHUP: 1,
2010
- SIGKILL: 9
2011
- };
2012
- const signalNumber = signalNumbers[signal];
2013
- if (signalNumber === void 0) {
2014
- return 1;
1941
+ var spawnHelperChecked = false;
1942
+ function ensureSpawnHelperExecutable() {
1943
+ if (spawnHelperChecked) return;
1944
+ spawnHelperChecked = true;
1945
+ const require3 = createRequire2(import.meta.url);
1946
+ const nodePtyDir = dirname2(require3.resolve("node-pty"));
1947
+ const helper = join2(nodePtyDir, "..", "prebuilds", `${process.platform}-${process.arch}`, "spawn-helper");
1948
+ try {
1949
+ accessSync(helper, constants.X_OK);
1950
+ } catch {
1951
+ chmodSync(helper, 493);
2015
1952
  }
2016
- return 128 + signalNumber;
2017
1953
  }
2018
1954
  function matchPattern(buffer, pattern) {
2019
1955
  const clean = normalizeHistoryBuffer(stripAnsi(buffer));