botapp-cli 0.2.9 → 0.2.10
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/bin/bot.js +50 -28
- package/dist/bin/bot.js.map +1 -1
- package/dist/index.js +50 -28
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -955,32 +955,38 @@ async function ptyKill(params) {
|
|
|
955
955
|
async function openPty(opts) {
|
|
956
956
|
const nodePty = await loadNodePty();
|
|
957
957
|
if (nodePty) {
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
const ptyId2 = randomUUID();
|
|
966
|
-
proc2.onData((data) => {
|
|
967
|
-
opts.ctx.pushChunk({ kind: "data", data });
|
|
968
|
-
});
|
|
969
|
-
const exited2 = new Promise((resolve11) => {
|
|
970
|
-
proc2.onExit(({ exitCode }) => {
|
|
971
|
-
resolve11(exitCode);
|
|
958
|
+
try {
|
|
959
|
+
const proc2 = nodePty.spawn(opts.command, opts.args, {
|
|
960
|
+
name: "xterm-256color",
|
|
961
|
+
cols: opts.cols,
|
|
962
|
+
rows: opts.rows,
|
|
963
|
+
cwd: opts.cwd,
|
|
964
|
+
env: opts.env
|
|
972
965
|
});
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
966
|
+
const ptyId2 = randomUUID();
|
|
967
|
+
proc2.onData((data) => {
|
|
968
|
+
opts.ctx.pushChunk({ kind: "data", data });
|
|
969
|
+
});
|
|
970
|
+
const exited2 = new Promise((resolve11) => {
|
|
971
|
+
proc2.onExit(({ exitCode }) => {
|
|
972
|
+
resolve11(exitCode);
|
|
973
|
+
});
|
|
974
|
+
});
|
|
975
|
+
return {
|
|
976
|
+
mode: "pty",
|
|
977
|
+
exited: exited2,
|
|
978
|
+
handle: {
|
|
979
|
+
ptyId: ptyId2,
|
|
980
|
+
resize: (cols, rows) => proc2.resize(cols, rows),
|
|
981
|
+
write: (data) => proc2.write(data),
|
|
982
|
+
kill: (signal) => proc2.kill(signal)
|
|
983
|
+
}
|
|
984
|
+
};
|
|
985
|
+
} catch (e) {
|
|
986
|
+
console.warn(
|
|
987
|
+
`[pty] node-pty spawn failed (${e?.message ?? e}); falling back to line-oriented pipe mode`
|
|
988
|
+
);
|
|
989
|
+
}
|
|
984
990
|
}
|
|
985
991
|
const proc = spawn2(
|
|
986
992
|
opts.command,
|
|
@@ -999,7 +1005,23 @@ async function openPty(opts) {
|
|
|
999
1005
|
opts.ctx.pushChunk({ kind: "data", data: chunk.toString("utf8") });
|
|
1000
1006
|
});
|
|
1001
1007
|
const exited = new Promise((resolve11) => {
|
|
1002
|
-
|
|
1008
|
+
let settled = false;
|
|
1009
|
+
proc.on("close", (code) => {
|
|
1010
|
+
if (settled) return;
|
|
1011
|
+
settled = true;
|
|
1012
|
+
resolve11(code);
|
|
1013
|
+
});
|
|
1014
|
+
proc.on("error", (err) => {
|
|
1015
|
+
opts.ctx.pushChunk({
|
|
1016
|
+
kind: "data",
|
|
1017
|
+
data: `\r
|
|
1018
|
+
[shell failed to start: ${err.message}]\r
|
|
1019
|
+
`
|
|
1020
|
+
});
|
|
1021
|
+
if (settled) return;
|
|
1022
|
+
settled = true;
|
|
1023
|
+
resolve11(1);
|
|
1024
|
+
});
|
|
1003
1025
|
});
|
|
1004
1026
|
return {
|
|
1005
1027
|
mode: "pipe",
|
|
@@ -2387,7 +2409,7 @@ Invalid ACP stdout: ${line}`;
|
|
|
2387
2409
|
clientInfo: {
|
|
2388
2410
|
name: "botapp-daemon",
|
|
2389
2411
|
title: "botapp daemon",
|
|
2390
|
-
version: "0.2.
|
|
2412
|
+
version: "0.2.10"
|
|
2391
2413
|
}
|
|
2392
2414
|
});
|
|
2393
2415
|
const session = await request2("session/new", {
|
|
@@ -5055,7 +5077,7 @@ function die(msg) {
|
|
|
5055
5077
|
}
|
|
5056
5078
|
|
|
5057
5079
|
// src/index.ts
|
|
5058
|
-
var version = "0.2.
|
|
5080
|
+
var version = "0.2.10";
|
|
5059
5081
|
var program = new Command25().name("bot").description("botapp CLI \u2014 operate apps from the command line").version(version).enablePositionalOptions(true).option("--json", "Output as JSON").option("-s, --server <url>", "Server URL override").option("-t, --token <token>", "Auth token override").option("-v, --verbose", "Verbose output");
|
|
5060
5082
|
program.addCommand(launchCommand);
|
|
5061
5083
|
program.addCommand(runCommand);
|