terminal-pilot 0.0.7 → 0.0.9

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 +66 -103
  2. package/dist/cli.js.map +4 -4
  3. package/dist/commands/close-session.js +33 -81
  4. package/dist/commands/close-session.js.map +3 -3
  5. package/dist/commands/create-session.js +33 -81
  6. package/dist/commands/create-session.js.map +3 -3
  7. package/dist/commands/fill.js +33 -81
  8. package/dist/commands/fill.js.map +3 -3
  9. package/dist/commands/get-session.js +33 -81
  10. package/dist/commands/get-session.js.map +3 -3
  11. package/dist/commands/index.js +41 -92
  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 +33 -81
  18. package/dist/commands/list-sessions.js.map +3 -3
  19. package/dist/commands/press-key.js +33 -81
  20. package/dist/commands/press-key.js.map +3 -3
  21. package/dist/commands/read-history.js +33 -81
  22. package/dist/commands/read-history.js.map +3 -3
  23. package/dist/commands/read-screen.js +33 -81
  24. package/dist/commands/read-screen.js.map +3 -3
  25. package/dist/commands/resize.js +33 -81
  26. package/dist/commands/resize.js.map +3 -3
  27. package/dist/commands/runtime.js +33 -81
  28. package/dist/commands/runtime.js.map +3 -3
  29. package/dist/commands/screenshot.js +33 -81
  30. package/dist/commands/screenshot.js.map +3 -3
  31. package/dist/commands/send-signal.js +33 -81
  32. package/dist/commands/send-signal.js.map +3 -3
  33. package/dist/commands/type.js +33 -81
  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 +33 -81
  38. package/dist/commands/wait-for-exit.js.map +3 -3
  39. package/dist/commands/wait-for.js +33 -81
  40. package/dist/commands/wait-for.js.map +3 -3
  41. package/dist/index.js +33 -81
  42. package/dist/index.js.map +3 -3
  43. package/dist/terminal-pilot.js +33 -81
  44. package/dist/terminal-pilot.js.map +3 -3
  45. package/dist/terminal-session.js +33 -81
  46. package/dist/terminal-session.js.map +3 -3
  47. package/dist/testing/cli-repl.js +66 -103
  48. package/dist/testing/cli-repl.js.map +4 -4
  49. package/dist/testing/qa-cli.js +66 -103
  50. package/dist/testing/qa-cli.js.map +4 -4
  51. package/package.json +1 -1
@@ -253,8 +253,10 @@ function defineCommand(config) {
253
253
  import { randomUUID } from "node:crypto";
254
254
 
255
255
  // src/terminal-session.ts
256
- import { spawn as spawnChildProcess } from "node:child_process";
257
256
  import { EventEmitter } from "node:events";
257
+ import { accessSync, chmodSync, constants } from "node:fs";
258
+ import { createRequire } from "node:module";
259
+ import { dirname, join } from "node:path";
258
260
  import * as nodePty from "node-pty";
259
261
 
260
262
  // src/ansi.ts
@@ -1165,93 +1167,43 @@ function createPtyProcess({
1165
1167
  cols,
1166
1168
  rows
1167
1169
  }) {
1168
- try {
1169
- return nodePty.spawn(command, args, {
1170
- cwd,
1171
- env,
1172
- cols,
1173
- rows,
1174
- encoding: "utf8"
1175
- });
1176
- } catch {
1177
- return createChildProcessFallback({ command, args, cwd, env });
1178
- }
1179
- }
1180
- function createChildProcessFallback({
1181
- command,
1182
- args,
1183
- cwd,
1184
- env
1185
- }) {
1186
- const child = spawnChildProcess(command, args, {
1170
+ ensureSpawnHelperExecutable();
1171
+ return nodePty.spawn(command, args, {
1187
1172
  cwd,
1188
1173
  env,
1189
- stdio: ["pipe", "pipe", "pipe"]
1174
+ cols,
1175
+ rows,
1176
+ encoding: "utf8"
1190
1177
  });
1191
- return new ChildProcessFallback(child);
1192
1178
  }
1193
- var ChildProcessFallback = class {
1194
- pid;
1195
- child;
1196
- dataEmitter = new EventEmitter();
1197
- exitEmitter = new EventEmitter();
1198
- constructor(child) {
1199
- this.child = child;
1200
- this.pid = child.pid ?? -1;
1201
- child.stdout.setEncoding("utf8");
1202
- child.stderr.setEncoding("utf8");
1203
- child.stdout.on("data", this.handleData);
1204
- child.stderr.on("data", this.handleData);
1205
- child.on("exit", (exitCode, signal) => {
1206
- this.exitEmitter.emit("exit", {
1207
- exitCode: exitCode ?? signalToExitCode(signal),
1208
- signal: void 0
1209
- });
1210
- });
1211
- }
1212
- write(data) {
1213
- this.child.stdin.write(data);
1214
- }
1215
- resize() {
1216
- }
1217
- kill(signal) {
1218
- this.child.kill(signal);
1219
- }
1220
- onData(listener) {
1221
- this.dataEmitter.on("data", listener);
1222
- return {
1223
- dispose: () => {
1224
- this.dataEmitter.off("data", listener);
1225
- }
1226
- };
1227
- }
1228
- onExit(listener) {
1229
- this.exitEmitter.on("exit", listener);
1230
- return {
1231
- dispose: () => {
1232
- this.exitEmitter.off("exit", listener);
1179
+ var spawnHelperChecked = false;
1180
+ function ensureSpawnHelperExecutable() {
1181
+ if (spawnHelperChecked) return;
1182
+ spawnHelperChecked = true;
1183
+ const require2 = createRequire(import.meta.url);
1184
+ const nodePtyDir = dirname(require2.resolve("node-pty"));
1185
+ const helper = join(nodePtyDir, "..", "prebuilds", `${process.platform}-${process.arch}`, "spawn-helper");
1186
+ try {
1187
+ accessSync(helper, constants.X_OK);
1188
+ } catch (error) {
1189
+ if (isMissingFileError(error)) {
1190
+ return;
1191
+ }
1192
+ try {
1193
+ chmodSync(helper, 493);
1194
+ } catch (chmodError) {
1195
+ if (isMissingFileError(chmodError)) {
1196
+ return;
1233
1197
  }
1234
- };
1198
+ throw chmodError;
1199
+ }
1235
1200
  }
1236
- handleData = (chunk) => {
1237
- this.dataEmitter.emit("data", String(chunk));
1238
- };
1239
- };
1240
- function signalToExitCode(signal) {
1241
- if (signal === null) {
1242
- return 0;
1243
- }
1244
- const signalNumbers = {
1245
- SIGTERM: 15,
1246
- SIGINT: 2,
1247
- SIGHUP: 1,
1248
- SIGKILL: 9
1249
- };
1250
- const signalNumber = signalNumbers[signal];
1251
- if (signalNumber === void 0) {
1252
- return 1;
1201
+ }
1202
+ function isMissingFileError(error) {
1203
+ if (!(error instanceof Error)) {
1204
+ return false;
1253
1205
  }
1254
- return 128 + signalNumber;
1206
+ return "code" in error && error.code === "ENOENT";
1255
1207
  }
1256
1208
  function matchPattern(buffer, pattern) {
1257
1209
  const clean = normalizeHistoryBuffer(stripAnsi(buffer));