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.
- package/dist/cli.js +52 -105
- package/dist/cli.js.map +4 -4
- package/dist/commands/close-session.js +19 -83
- package/dist/commands/close-session.js.map +3 -3
- package/dist/commands/create-session.js +19 -83
- package/dist/commands/create-session.js.map +3 -3
- package/dist/commands/fill.js +19 -83
- package/dist/commands/fill.js.map +3 -3
- package/dist/commands/get-session.js +19 -83
- package/dist/commands/get-session.js.map +3 -3
- package/dist/commands/index.js +27 -94
- package/dist/commands/index.js.map +4 -4
- package/dist/commands/install.js +2 -5
- package/dist/commands/install.js.map +4 -4
- package/dist/commands/installer.js +2 -5
- package/dist/commands/installer.js.map +4 -4
- package/dist/commands/list-sessions.js +19 -83
- package/dist/commands/list-sessions.js.map +3 -3
- package/dist/commands/press-key.js +19 -83
- package/dist/commands/press-key.js.map +3 -3
- package/dist/commands/read-history.js +19 -83
- package/dist/commands/read-history.js.map +3 -3
- package/dist/commands/read-screen.js +19 -83
- package/dist/commands/read-screen.js.map +3 -3
- package/dist/commands/resize.js +19 -83
- package/dist/commands/resize.js.map +3 -3
- package/dist/commands/runtime.js +19 -83
- package/dist/commands/runtime.js.map +3 -3
- package/dist/commands/screenshot.js +19 -83
- package/dist/commands/screenshot.js.map +3 -3
- package/dist/commands/send-signal.js +19 -83
- package/dist/commands/send-signal.js.map +3 -3
- package/dist/commands/type.js +19 -83
- package/dist/commands/type.js.map +3 -3
- package/dist/commands/uninstall.js +1 -4
- package/dist/commands/uninstall.js.map +4 -4
- package/dist/commands/wait-for-exit.js +19 -83
- package/dist/commands/wait-for-exit.js.map +3 -3
- package/dist/commands/wait-for.js +19 -83
- package/dist/commands/wait-for.js.map +3 -3
- package/dist/index.js +19 -83
- package/dist/index.js.map +3 -3
- package/dist/terminal-pilot.js +19 -83
- package/dist/terminal-pilot.js.map +3 -3
- package/dist/terminal-session.js +19 -83
- package/dist/terminal-session.js.map +3 -3
- package/dist/testing/cli-repl.js +52 -105
- package/dist/testing/cli-repl.js.map +4 -4
- package/dist/testing/qa-cli.js +52 -105
- package/dist/testing/qa-cli.js.map +4 -4
- 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,27 @@ function createPtyProcess({
|
|
|
1165
1167
|
cols,
|
|
1166
1168
|
rows
|
|
1167
1169
|
}) {
|
|
1168
|
-
|
|
1169
|
-
|
|
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
|
-
|
|
1174
|
+
cols,
|
|
1175
|
+
rows,
|
|
1176
|
+
encoding: "utf8"
|
|
1190
1177
|
});
|
|
1191
|
-
return new ChildProcessFallback(child);
|
|
1192
1178
|
}
|
|
1193
|
-
var
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
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);
|
|
1233
|
-
}
|
|
1234
|
-
};
|
|
1235
|
-
}
|
|
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;
|
|
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 {
|
|
1189
|
+
chmodSync(helper, 493);
|
|
1253
1190
|
}
|
|
1254
|
-
return 128 + signalNumber;
|
|
1255
1191
|
}
|
|
1256
1192
|
function matchPattern(buffer, pattern) {
|
|
1257
1193
|
const clean = normalizeHistoryBuffer(stripAnsi(buffer));
|