agent-yes 1.62.0 → 1.62.2
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/{SUPPORTED_CLIS-4TAXzvkb.js → SUPPORTED_CLIS-CxaWfAAA.js} +12 -10
- package/dist/cli.js +1 -2
- package/dist/index.js +1 -1
- package/package.json +1 -1
- package/ts/index.ts +52 -48
- package/ts/parseCliArgs.ts +0 -2
- package/ts/rustBinary.ts +0 -1
|
@@ -10,7 +10,7 @@ import sflow from "sflow";
|
|
|
10
10
|
import { TerminalRenderStream } from "terminal-render";
|
|
11
11
|
import { homedir } from "os";
|
|
12
12
|
import winston from "winston";
|
|
13
|
-
import { closeSync, existsSync, fsyncSync, openSync } from "fs";
|
|
13
|
+
import { closeSync, existsSync, fsyncSync, mkdirSync, openSync } from "fs";
|
|
14
14
|
import { lock } from "proper-lockfile";
|
|
15
15
|
import { execSync as execSync$1 } from "node:child_process";
|
|
16
16
|
import { fileURLToPath } from "url";
|
|
@@ -798,11 +798,11 @@ async function sendEnter(context, waitms = 1e3) {
|
|
|
798
798
|
context.shell.write("\r");
|
|
799
799
|
logger.debug(`enterSent| idleWaiter.wait(${String(waitms)}) took ${String(et - st)}ms`);
|
|
800
800
|
await Promise.race([context.nextStdout.wait(), new Promise((resolve) => setTimeout(() => {
|
|
801
|
-
if (!context.nextStdout.
|
|
801
|
+
if (!context.nextStdout.isReady) context.shell.write("\r");
|
|
802
802
|
resolve();
|
|
803
803
|
}, 1e3))]);
|
|
804
804
|
await Promise.race([context.nextStdout.wait(), new Promise((resolve) => setTimeout(() => {
|
|
805
|
-
if (!context.nextStdout.
|
|
805
|
+
if (!context.nextStdout.isReady) context.shell.write("\r");
|
|
806
806
|
resolve();
|
|
807
807
|
}, 3e3))]);
|
|
808
808
|
}
|
|
@@ -819,7 +819,10 @@ async function sendMessage(context, message, { waitForReady = true } = {}) {
|
|
|
819
819
|
context.shell.write(message);
|
|
820
820
|
context.idleWaiter.ping();
|
|
821
821
|
logger.debug(`waiting next stdout|${message}`);
|
|
822
|
-
await context.nextStdout.wait()
|
|
822
|
+
await Promise.race([context.nextStdout.wait(), new Promise((resolve) => setTimeout(() => {
|
|
823
|
+
logger.warn(`nextStdout.wait() timed out after 30s for message: ${message}`);
|
|
824
|
+
resolve();
|
|
825
|
+
}, 3e4))]);
|
|
823
826
|
logger.debug(`sending enter`);
|
|
824
827
|
await sendEnter(context, 1e3);
|
|
825
828
|
logger.debug(`sent enter`);
|
|
@@ -904,7 +907,7 @@ function tryCatch(catchFn, fn) {
|
|
|
904
907
|
//#endregion
|
|
905
908
|
//#region package.json
|
|
906
909
|
var name = "agent-yes";
|
|
907
|
-
var version = "1.62.
|
|
910
|
+
var version = "1.62.2";
|
|
908
911
|
|
|
909
912
|
//#endregion
|
|
910
913
|
//#region ts/pty-fix.ts
|
|
@@ -1069,7 +1072,7 @@ function isCommandNotFoundError(e) {
|
|
|
1069
1072
|
* ```
|
|
1070
1073
|
*/
|
|
1071
1074
|
function spawnAgent(options) {
|
|
1072
|
-
const { cli, cliConf, cliArgs,
|
|
1075
|
+
const { cli, cliConf, cliArgs, install, ptyOptions } = options;
|
|
1073
1076
|
const spawn = () => {
|
|
1074
1077
|
let [bin, ...args] = [...parseCommandString(cliConf?.binary || cli), ...cliArgs];
|
|
1075
1078
|
logger.debug(`Spawning ${bin} with args: ${JSON.stringify(args)}`);
|
|
@@ -1077,7 +1080,7 @@ function spawnAgent(options) {
|
|
|
1077
1080
|
logger.info(`[${cli}-yes] Spawned ${bin} with PID ${spawned.pid} (agent-yes v${version})`);
|
|
1078
1081
|
return spawned;
|
|
1079
1082
|
};
|
|
1080
|
-
return tryCatch((error,
|
|
1083
|
+
return tryCatch((error, attempts, spawn, ...args) => {
|
|
1081
1084
|
logger.error(`Fatal: Failed to start ${cli}.`);
|
|
1082
1085
|
const isNotFound = isCommandNotFoundError(error);
|
|
1083
1086
|
if (cliConf?.install && isNotFound) {
|
|
@@ -1777,7 +1780,7 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
|
|
|
1777
1780
|
cancel(_reason) {
|
|
1778
1781
|
process.stdin.pause();
|
|
1779
1782
|
}
|
|
1780
|
-
});
|
|
1783
|
+
}, { highWaterMark: 16 });
|
|
1781
1784
|
let aborted = false;
|
|
1782
1785
|
await sflow(stdinStream).map((buffer) => {
|
|
1783
1786
|
const str = buffer.toString();
|
|
@@ -1864,7 +1867,6 @@ async function agentYes({ cli, cliArgs = [], prompt, robust = true, cwd, env, ex
|
|
|
1864
1867
|
}).by(function consoleResponder(e) {
|
|
1865
1868
|
let lastRendered = "";
|
|
1866
1869
|
return e.forEach((chunk) => {
|
|
1867
|
-
terminalRender.write(chunk);
|
|
1868
1870
|
if (chunk.includes("\x1B[c") || chunk.includes("\x1B[0c")) {
|
|
1869
1871
|
shell.write("\x1B[?1;2c");
|
|
1870
1872
|
if (verbose) logger.debug("device|respond DA: VT100 with Advanced Video Option");
|
|
@@ -1951,4 +1953,4 @@ const SUPPORTED_CLIS = Object.keys(CLIS_CONFIG);
|
|
|
1951
1953
|
|
|
1952
1954
|
//#endregion
|
|
1953
1955
|
export { AgentContext as a, PidStore as c, config as i, removeControlCharacters as l, CLIS_CONFIG as n, name as o, agentYes as r, version as s, SUPPORTED_CLIS as t };
|
|
1954
|
-
//# sourceMappingURL=SUPPORTED_CLIS-
|
|
1956
|
+
//# sourceMappingURL=SUPPORTED_CLIS-CxaWfAAA.js.map
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bun
|
|
2
|
-
import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-
|
|
2
|
+
import { c as PidStore, o as name, s as version, t as SUPPORTED_CLIS } from "./SUPPORTED_CLIS-CxaWfAAA.js";
|
|
3
3
|
import { t as logger } from "./logger-CX77vJDA.js";
|
|
4
4
|
import { argv } from "process";
|
|
5
5
|
import { spawn } from "child_process";
|
|
@@ -271,7 +271,6 @@ function getBinDir() {
|
|
|
271
271
|
*/
|
|
272
272
|
function findRustBinary(verbose = false) {
|
|
273
273
|
const binaryName = getBinaryName();
|
|
274
|
-
binaryName.replace(/\.exe$/, "");
|
|
275
274
|
const searchPaths = [
|
|
276
275
|
path.join(getBinDir(), binaryName),
|
|
277
276
|
path.resolve(import.meta.dirname ?? import.meta.dir, "../rs/target/release/agent-yes"),
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as AgentContext, i as config, l as removeControlCharacters, n as CLIS_CONFIG, r as agentYes } from "./SUPPORTED_CLIS-
|
|
1
|
+
import { a as AgentContext, i as config, l as removeControlCharacters, n as CLIS_CONFIG, r as agentYes } from "./SUPPORTED_CLIS-CxaWfAAA.js";
|
|
2
2
|
import "./logger-CX77vJDA.js";
|
|
3
3
|
|
|
4
4
|
export { AgentContext, CLIS_CONFIG, config, agentYes as default, removeControlCharacters };
|
package/package.json
CHANGED
package/ts/index.ts
CHANGED
|
@@ -14,7 +14,8 @@ import pty, { ptyPackage } from "./pty.ts";
|
|
|
14
14
|
import { removeControlCharacters } from "./removeControlCharacters.ts";
|
|
15
15
|
import { acquireLock, releaseLock, shouldUseLock } from "./runningLock.ts";
|
|
16
16
|
import { logger } from "./logger.ts";
|
|
17
|
-
//
|
|
17
|
+
// oxlint-disable-next-line no-unused-vars -- kept for FIFO re-enable (see TODO at index.ts:833)
|
|
18
|
+
import { createFifoStream } from "./beta/fifo.ts";
|
|
18
19
|
import { PidStore } from "./pidStore.ts";
|
|
19
20
|
import { SUPPORTED_CLIS } from "./SUPPORTED_CLIS.ts";
|
|
20
21
|
import { sendEnter, sendMessage } from "./core/messaging.ts";
|
|
@@ -26,10 +27,8 @@ import {
|
|
|
26
27
|
} from "./core/logging.ts";
|
|
27
28
|
import { spawnAgent } from "./core/spawner.ts";
|
|
28
29
|
import { AgentContext } from "./core/context.ts";
|
|
29
|
-
// import { createAutoResponseHandler } from "./core/responders.ts";
|
|
30
30
|
import { createTerminatorStream } from "./core/streamHelpers.ts";
|
|
31
31
|
import { globalAgentRegistry } from "./agentRegistry.ts";
|
|
32
|
-
// import { ReadyManager } from "./ReadyManager.ts";
|
|
33
32
|
import { notifyWebhook } from "./webhookNotifier.ts";
|
|
34
33
|
|
|
35
34
|
export { removeControlCharacters };
|
|
@@ -688,52 +687,55 @@ export default async function agentYes({
|
|
|
688
687
|
// CRITICAL FIX: fromReadable() from 'from-node-stream' doesn't work properly with stdin
|
|
689
688
|
// because it doesn't handle Node.js stream modes correctly. We create a custom ReadableStream
|
|
690
689
|
// that properly manages stdin's flowing mode and event listeners.
|
|
691
|
-
const stdinStream = new ReadableStream<Buffer>(
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
690
|
+
const stdinStream = new ReadableStream<Buffer>(
|
|
691
|
+
{
|
|
692
|
+
start(controller) {
|
|
693
|
+
// Set up stdin in flowing mode so 'data' events fire
|
|
694
|
+
process.stdin.resume();
|
|
695
|
+
|
|
696
|
+
let closed = false;
|
|
697
|
+
|
|
698
|
+
// Handle data events
|
|
699
|
+
const dataHandler = (chunk: Buffer) => {
|
|
700
|
+
try {
|
|
701
|
+
controller.enqueue(chunk);
|
|
702
|
+
} catch {
|
|
703
|
+
// Ignore enqueue errors (stream may be closed)
|
|
704
|
+
}
|
|
705
|
+
};
|
|
706
706
|
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
707
|
+
// Handle end/close - both events can fire, so track state
|
|
708
|
+
const endHandler = () => {
|
|
709
|
+
if (closed) return;
|
|
710
|
+
closed = true;
|
|
711
|
+
try {
|
|
712
|
+
controller.close();
|
|
713
|
+
} catch {
|
|
714
|
+
// Ignore close errors (already closed)
|
|
715
|
+
}
|
|
716
|
+
};
|
|
717
717
|
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
718
|
+
const errorHandler = (err: Error) => {
|
|
719
|
+
if (closed) return;
|
|
720
|
+
closed = true;
|
|
721
|
+
try {
|
|
722
|
+
controller.error(err);
|
|
723
|
+
} catch {
|
|
724
|
+
// Ignore error after close
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
727
|
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
728
|
+
process.stdin.on("data", dataHandler);
|
|
729
|
+
process.stdin.on("end", endHandler);
|
|
730
|
+
process.stdin.on("close", endHandler);
|
|
731
|
+
process.stdin.on("error", errorHandler);
|
|
732
|
+
},
|
|
733
|
+
cancel(_reason) {
|
|
734
|
+
process.stdin.pause();
|
|
735
|
+
},
|
|
732
736
|
},
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
},
|
|
736
|
-
});
|
|
737
|
+
{ highWaterMark: 16 },
|
|
738
|
+
);
|
|
737
739
|
|
|
738
740
|
let aborted = false;
|
|
739
741
|
await sflow(stdinStream)
|
|
@@ -802,7 +804,7 @@ export default async function agentYes({
|
|
|
802
804
|
// Only check for /auto if line is short enough
|
|
803
805
|
if (line.length <= 20) {
|
|
804
806
|
const cleanLine = line
|
|
805
|
-
// oxlint-disable-next-line no-control-regex
|
|
807
|
+
// oxlint-disable-next-line no-control-regex -- intentional: strip ANSI/control chars
|
|
806
808
|
.replace(/[\x00-\x1f]|\x1b\[[0-9;]*[A-Za-z]|\[[A-Z]/g, "")
|
|
807
809
|
.trim();
|
|
808
810
|
if (cleanLine === "/auto") {
|
|
@@ -894,8 +896,10 @@ export default async function agentYes({
|
|
|
894
896
|
let lastRendered = "";
|
|
895
897
|
return e
|
|
896
898
|
.forEach((chunk) => {
|
|
897
|
-
//
|
|
898
|
-
|
|
899
|
+
// NOTE: terminalRender is already updated by terminalStream.writable.write() in onData()
|
|
900
|
+
// (terminal-render v1.5+ calls renderer.write() as a side effect of the writable).
|
|
901
|
+
// Calling terminalRender.write(chunk) here again would double-process every chunk,
|
|
902
|
+
// corrupting cursor state and breaking all pattern matching.
|
|
899
903
|
// ============ HANDLE special control sequences
|
|
900
904
|
// Handle Device Attributes query (DA) - ESC[c or ESC[0c
|
|
901
905
|
// This must be handled regardless of TTY status
|
package/ts/parseCliArgs.ts
CHANGED
|
@@ -2,8 +2,6 @@ import ms from "ms";
|
|
|
2
2
|
import yargs from "yargs";
|
|
3
3
|
import { hideBin } from "yargs/helpers";
|
|
4
4
|
import { SUPPORTED_CLIS } from "./SUPPORTED_CLIS.ts";
|
|
5
|
-
|
|
6
|
-
// const pkg = await JSON.parse(await readFile(path.resolve((import.meta.dir) + "/../package.json"), 'utf8'))
|
|
7
5
|
/**
|
|
8
6
|
* Parse CLI arguments the same way cli.ts does
|
|
9
7
|
* This is a test helper that mirrors the parsing logic in cli.ts
|
package/ts/rustBinary.ts
CHANGED
|
@@ -60,7 +60,6 @@ export function getBinDir(): string {
|
|
|
60
60
|
*/
|
|
61
61
|
export function findRustBinary(verbose = false): string | undefined {
|
|
62
62
|
const binaryName = getBinaryName();
|
|
63
|
-
const _baseName = binaryName.replace(/\.exe$/, "");
|
|
64
63
|
|
|
65
64
|
const searchPaths = [
|
|
66
65
|
// 1. Check in npm package bin directory
|