agent-yes 1.39.0 → 1.40.0
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 +55 -21
- package/dist/index.js +30 -17
- package/package.json +1 -1
- package/ts/index.ts +27 -3
package/dist/cli.js
CHANGED
|
@@ -21282,14 +21282,6 @@ function spawnAgent(options) {
|
|
|
21282
21282
|
throw error;
|
|
21283
21283
|
}, spawn2)();
|
|
21284
21284
|
}
|
|
21285
|
-
function getTerminalDimensions() {
|
|
21286
|
-
if (!process.stdout.isTTY)
|
|
21287
|
-
return { cols: 80, rows: 30 };
|
|
21288
|
-
return {
|
|
21289
|
-
cols: Math.min(Math.max(20, process.stdout.columns), 80),
|
|
21290
|
-
rows: process.stdout.rows
|
|
21291
|
-
};
|
|
21292
|
-
}
|
|
21293
21285
|
var init_spawner = __esm(async () => {
|
|
21294
21286
|
init_execa();
|
|
21295
21287
|
init_logger();
|
|
@@ -21297,7 +21289,7 @@ var init_spawner = __esm(async () => {
|
|
|
21297
21289
|
});
|
|
21298
21290
|
|
|
21299
21291
|
// ts/ReadyManager.ts
|
|
21300
|
-
class
|
|
21292
|
+
class ReadyManager2 {
|
|
21301
21293
|
isReady = false;
|
|
21302
21294
|
readyQueue = [];
|
|
21303
21295
|
wait() {
|
|
@@ -21342,9 +21334,9 @@ class AgentContext {
|
|
|
21342
21334
|
cliConf;
|
|
21343
21335
|
verbose;
|
|
21344
21336
|
robust;
|
|
21345
|
-
stdinReady = new
|
|
21346
|
-
stdinFirstReady = new
|
|
21347
|
-
nextStdout = new
|
|
21337
|
+
stdinReady = new ReadyManager2;
|
|
21338
|
+
stdinFirstReady = new ReadyManager2;
|
|
21339
|
+
nextStdout = new ReadyManager2;
|
|
21348
21340
|
idleWaiter = new IdleWaiter;
|
|
21349
21341
|
isFatal = false;
|
|
21350
21342
|
shouldRestartWithoutContinue = false;
|
|
@@ -21713,6 +21705,19 @@ async function agentYes2({
|
|
|
21713
21705
|
}
|
|
21714
21706
|
const pidStore = new PidStore(workingDir);
|
|
21715
21707
|
await pidStore.init();
|
|
21708
|
+
const stdinReady = new ReadyManager;
|
|
21709
|
+
const stdinFirstReady = new ReadyManager;
|
|
21710
|
+
if (conf.ready && conf.ready.length === 0) {
|
|
21711
|
+
stdinReady.ready();
|
|
21712
|
+
stdinFirstReady.ready();
|
|
21713
|
+
}
|
|
21714
|
+
sleep3(1e4).then(() => {
|
|
21715
|
+
if (!stdinReady.isReady)
|
|
21716
|
+
stdinReady.ready();
|
|
21717
|
+
if (!stdinFirstReady.isReady)
|
|
21718
|
+
stdinFirstReady.ready();
|
|
21719
|
+
});
|
|
21720
|
+
const nextStdout = new ReadyManager;
|
|
21716
21721
|
process.stdin.setRawMode?.(true);
|
|
21717
21722
|
const shellOutputStream = new TransformStream;
|
|
21718
21723
|
const outputWriter = shellOutputStream.writable.getWriter();
|
|
@@ -21818,7 +21823,7 @@ ${prompt}` : prefix;
|
|
|
21818
21823
|
const ptyEnv = { ...env2 ?? process.env };
|
|
21819
21824
|
const ptyOptions = {
|
|
21820
21825
|
name: "xterm-color",
|
|
21821
|
-
...
|
|
21826
|
+
...getTerminalDimensions3(),
|
|
21822
21827
|
cwd: cwd ?? process.cwd(),
|
|
21823
21828
|
env: ptyEnv
|
|
21824
21829
|
};
|
|
@@ -21871,7 +21876,7 @@ ${prompt}` : prefix;
|
|
|
21871
21876
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
21872
21877
|
const restartPtyOptions = {
|
|
21873
21878
|
name: "xterm-color",
|
|
21874
|
-
...
|
|
21879
|
+
...getTerminalDimensions3(),
|
|
21875
21880
|
cwd: cwd ?? process.cwd(),
|
|
21876
21881
|
env: ptyEnv
|
|
21877
21882
|
};
|
|
@@ -21910,7 +21915,7 @@ ${prompt}` : prefix;
|
|
|
21910
21915
|
}
|
|
21911
21916
|
const restorePtyOptions = {
|
|
21912
21917
|
name: "xterm-color",
|
|
21913
|
-
...
|
|
21918
|
+
...getTerminalDimensions3(),
|
|
21914
21919
|
cwd: cwd ?? process.cwd(),
|
|
21915
21920
|
env: ptyEnv
|
|
21916
21921
|
};
|
|
@@ -21928,7 +21933,7 @@ ${prompt}` : prefix;
|
|
|
21928
21933
|
return pendingExitCode.resolve(exitCode2);
|
|
21929
21934
|
});
|
|
21930
21935
|
process.stdout.on("resize", () => {
|
|
21931
|
-
const { cols, rows } =
|
|
21936
|
+
const { cols, rows } = getTerminalDimensions3();
|
|
21932
21937
|
shell.resize(cols, rows);
|
|
21933
21938
|
});
|
|
21934
21939
|
const terminalRender = new TerminalTextRender;
|
|
@@ -22023,6 +22028,14 @@ ${prompt}` : prefix;
|
|
|
22023
22028
|
}, 5000))
|
|
22024
22029
|
]);
|
|
22025
22030
|
}
|
|
22031
|
+
function getTerminalDimensions3() {
|
|
22032
|
+
if (!process.stdout.isTTY)
|
|
22033
|
+
return { cols: 80, rows: 30 };
|
|
22034
|
+
return {
|
|
22035
|
+
cols: Math.max(20, process.stdout.columns),
|
|
22036
|
+
rows: process.stdout.rows
|
|
22037
|
+
};
|
|
22038
|
+
}
|
|
22026
22039
|
}
|
|
22027
22040
|
function sleep3(ms2) {
|
|
22028
22041
|
return new Promise((resolve5) => setTimeout(resolve5, ms2));
|
|
@@ -22120,6 +22133,19 @@ async function agentYes({
|
|
|
22120
22133
|
}
|
|
22121
22134
|
const pidStore = new PidStore(workingDir);
|
|
22122
22135
|
await pidStore.init();
|
|
22136
|
+
const stdinReady = new ReadyManager;
|
|
22137
|
+
const stdinFirstReady = new ReadyManager;
|
|
22138
|
+
if (conf.ready && conf.ready.length === 0) {
|
|
22139
|
+
stdinReady.ready();
|
|
22140
|
+
stdinFirstReady.ready();
|
|
22141
|
+
}
|
|
22142
|
+
sleep2(1e4).then(() => {
|
|
22143
|
+
if (!stdinReady.isReady)
|
|
22144
|
+
stdinReady.ready();
|
|
22145
|
+
if (!stdinFirstReady.isReady)
|
|
22146
|
+
stdinFirstReady.ready();
|
|
22147
|
+
});
|
|
22148
|
+
const nextStdout = new ReadyManager;
|
|
22123
22149
|
process.stdin.setRawMode?.(true);
|
|
22124
22150
|
const shellOutputStream = new TransformStream;
|
|
22125
22151
|
const outputWriter = shellOutputStream.writable.getWriter();
|
|
@@ -22225,7 +22251,7 @@ ${prompt}` : prefix;
|
|
|
22225
22251
|
const ptyEnv = { ...env ?? process.env };
|
|
22226
22252
|
const ptyOptions = {
|
|
22227
22253
|
name: "xterm-color",
|
|
22228
|
-
...
|
|
22254
|
+
...getTerminalDimensions2(),
|
|
22229
22255
|
cwd: cwd ?? process.cwd(),
|
|
22230
22256
|
env: ptyEnv
|
|
22231
22257
|
};
|
|
@@ -22278,7 +22304,7 @@ ${prompt}` : prefix;
|
|
|
22278
22304
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
22279
22305
|
const restartPtyOptions = {
|
|
22280
22306
|
name: "xterm-color",
|
|
22281
|
-
...
|
|
22307
|
+
...getTerminalDimensions2(),
|
|
22282
22308
|
cwd: cwd ?? process.cwd(),
|
|
22283
22309
|
env: ptyEnv
|
|
22284
22310
|
};
|
|
@@ -22317,7 +22343,7 @@ ${prompt}` : prefix;
|
|
|
22317
22343
|
}
|
|
22318
22344
|
const restorePtyOptions = {
|
|
22319
22345
|
name: "xterm-color",
|
|
22320
|
-
...
|
|
22346
|
+
...getTerminalDimensions2(),
|
|
22321
22347
|
cwd: cwd ?? process.cwd(),
|
|
22322
22348
|
env: ptyEnv
|
|
22323
22349
|
};
|
|
@@ -22335,7 +22361,7 @@ ${prompt}` : prefix;
|
|
|
22335
22361
|
return pendingExitCode.resolve(exitCode2);
|
|
22336
22362
|
});
|
|
22337
22363
|
process.stdout.on("resize", () => {
|
|
22338
|
-
const { cols, rows } =
|
|
22364
|
+
const { cols, rows } = getTerminalDimensions2();
|
|
22339
22365
|
shell.resize(cols, rows);
|
|
22340
22366
|
});
|
|
22341
22367
|
const terminalRender = new TerminalTextRender;
|
|
@@ -22430,6 +22456,14 @@ ${prompt}` : prefix;
|
|
|
22430
22456
|
}, 5000))
|
|
22431
22457
|
]);
|
|
22432
22458
|
}
|
|
22459
|
+
function getTerminalDimensions2() {
|
|
22460
|
+
if (!process.stdout.isTTY)
|
|
22461
|
+
return { cols: 80, rows: 30 };
|
|
22462
|
+
return {
|
|
22463
|
+
cols: Math.max(20, process.stdout.columns),
|
|
22464
|
+
rows: process.stdout.rows
|
|
22465
|
+
};
|
|
22466
|
+
}
|
|
22433
22467
|
}
|
|
22434
22468
|
function sleep2(ms) {
|
|
22435
22469
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -28370,5 +28404,5 @@ var { exitCode } = await cliYes(config3);
|
|
|
28370
28404
|
console.log("exiting process");
|
|
28371
28405
|
process.exit(exitCode ?? 1);
|
|
28372
28406
|
|
|
28373
|
-
//# debugId=
|
|
28407
|
+
//# debugId=CCC14C4166DA3C6B64756E2164756E21
|
|
28374
28408
|
//# sourceMappingURL=cli.js.map
|
package/dist/index.js
CHANGED
|
@@ -21280,14 +21280,6 @@ function spawnAgent(options) {
|
|
|
21280
21280
|
throw error;
|
|
21281
21281
|
}, spawn2)();
|
|
21282
21282
|
}
|
|
21283
|
-
function getTerminalDimensions() {
|
|
21284
|
-
if (!process.stdout.isTTY)
|
|
21285
|
-
return { cols: 80, rows: 30 };
|
|
21286
|
-
return {
|
|
21287
|
-
cols: Math.min(Math.max(20, process.stdout.columns), 80),
|
|
21288
|
-
rows: process.stdout.rows
|
|
21289
|
-
};
|
|
21290
|
-
}
|
|
21291
21283
|
var init_spawner = __esm(async () => {
|
|
21292
21284
|
init_execa();
|
|
21293
21285
|
init_logger();
|
|
@@ -21295,7 +21287,7 @@ var init_spawner = __esm(async () => {
|
|
|
21295
21287
|
});
|
|
21296
21288
|
|
|
21297
21289
|
// ts/ReadyManager.ts
|
|
21298
|
-
class
|
|
21290
|
+
class ReadyManager2 {
|
|
21299
21291
|
isReady = false;
|
|
21300
21292
|
readyQueue = [];
|
|
21301
21293
|
wait() {
|
|
@@ -21340,9 +21332,9 @@ class AgentContext {
|
|
|
21340
21332
|
cliConf;
|
|
21341
21333
|
verbose;
|
|
21342
21334
|
robust;
|
|
21343
|
-
stdinReady = new
|
|
21344
|
-
stdinFirstReady = new
|
|
21345
|
-
nextStdout = new
|
|
21335
|
+
stdinReady = new ReadyManager2;
|
|
21336
|
+
stdinFirstReady = new ReadyManager2;
|
|
21337
|
+
nextStdout = new ReadyManager2;
|
|
21346
21338
|
idleWaiter = new IdleWaiter;
|
|
21347
21339
|
isFatal = false;
|
|
21348
21340
|
shouldRestartWithoutContinue = false;
|
|
@@ -21696,6 +21688,19 @@ async function agentYes({
|
|
|
21696
21688
|
}
|
|
21697
21689
|
const pidStore = new PidStore(workingDir);
|
|
21698
21690
|
await pidStore.init();
|
|
21691
|
+
const stdinReady = new ReadyManager;
|
|
21692
|
+
const stdinFirstReady = new ReadyManager;
|
|
21693
|
+
if (conf.ready && conf.ready.length === 0) {
|
|
21694
|
+
stdinReady.ready();
|
|
21695
|
+
stdinFirstReady.ready();
|
|
21696
|
+
}
|
|
21697
|
+
sleep2(1e4).then(() => {
|
|
21698
|
+
if (!stdinReady.isReady)
|
|
21699
|
+
stdinReady.ready();
|
|
21700
|
+
if (!stdinFirstReady.isReady)
|
|
21701
|
+
stdinFirstReady.ready();
|
|
21702
|
+
});
|
|
21703
|
+
const nextStdout = new ReadyManager;
|
|
21699
21704
|
process.stdin.setRawMode?.(true);
|
|
21700
21705
|
const shellOutputStream = new TransformStream;
|
|
21701
21706
|
const outputWriter = shellOutputStream.writable.getWriter();
|
|
@@ -21801,7 +21806,7 @@ ${prompt}` : prefix;
|
|
|
21801
21806
|
const ptyEnv = { ...env ?? process.env };
|
|
21802
21807
|
const ptyOptions = {
|
|
21803
21808
|
name: "xterm-color",
|
|
21804
|
-
...
|
|
21809
|
+
...getTerminalDimensions2(),
|
|
21805
21810
|
cwd: cwd ?? process.cwd(),
|
|
21806
21811
|
env: ptyEnv
|
|
21807
21812
|
};
|
|
@@ -21854,7 +21859,7 @@ ${prompt}` : prefix;
|
|
|
21854
21859
|
logger.info(`Restarting ${cli} ${JSON.stringify([bin, ...args])}`);
|
|
21855
21860
|
const restartPtyOptions = {
|
|
21856
21861
|
name: "xterm-color",
|
|
21857
|
-
...
|
|
21862
|
+
...getTerminalDimensions2(),
|
|
21858
21863
|
cwd: cwd ?? process.cwd(),
|
|
21859
21864
|
env: ptyEnv
|
|
21860
21865
|
};
|
|
@@ -21893,7 +21898,7 @@ ${prompt}` : prefix;
|
|
|
21893
21898
|
}
|
|
21894
21899
|
const restorePtyOptions = {
|
|
21895
21900
|
name: "xterm-color",
|
|
21896
|
-
...
|
|
21901
|
+
...getTerminalDimensions2(),
|
|
21897
21902
|
cwd: cwd ?? process.cwd(),
|
|
21898
21903
|
env: ptyEnv
|
|
21899
21904
|
};
|
|
@@ -21911,7 +21916,7 @@ ${prompt}` : prefix;
|
|
|
21911
21916
|
return pendingExitCode.resolve(exitCode2);
|
|
21912
21917
|
});
|
|
21913
21918
|
process.stdout.on("resize", () => {
|
|
21914
|
-
const { cols, rows } =
|
|
21919
|
+
const { cols, rows } = getTerminalDimensions2();
|
|
21915
21920
|
shell.resize(cols, rows);
|
|
21916
21921
|
});
|
|
21917
21922
|
const terminalRender = new TerminalTextRender;
|
|
@@ -22006,6 +22011,14 @@ ${prompt}` : prefix;
|
|
|
22006
22011
|
}, 5000))
|
|
22007
22012
|
]);
|
|
22008
22013
|
}
|
|
22014
|
+
function getTerminalDimensions2() {
|
|
22015
|
+
if (!process.stdout.isTTY)
|
|
22016
|
+
return { cols: 80, rows: 30 };
|
|
22017
|
+
return {
|
|
22018
|
+
cols: Math.max(20, process.stdout.columns),
|
|
22019
|
+
rows: process.stdout.rows
|
|
22020
|
+
};
|
|
22021
|
+
}
|
|
22009
22022
|
}
|
|
22010
22023
|
function sleep2(ms) {
|
|
22011
22024
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -22017,5 +22030,5 @@ export {
|
|
|
22017
22030
|
CLIS_CONFIG
|
|
22018
22031
|
};
|
|
22019
22032
|
|
|
22020
|
-
//# debugId=
|
|
22033
|
+
//# debugId=074FBBA13726BF4864756E2164756E21
|
|
22021
22034
|
//# sourceMappingURL=index.js.map
|
package/package.json
CHANGED
package/ts/index.ts
CHANGED
|
@@ -41,7 +41,7 @@ export type AgentCliConfig = {
|
|
|
41
41
|
defaultArgs?: string[]; // function to ensure certain args are present
|
|
42
42
|
|
|
43
43
|
// status detect, and actions
|
|
44
|
-
ready?: RegExp[]; // regex matcher for stdin ready, or line index for gemini
|
|
44
|
+
ready?: RegExp[]; // regex matcher for stdin ready, or line index for gemini. Set to empty array [] to disable ready check entirely.
|
|
45
45
|
fatal?: RegExp[]; // array of regex to match for fatal errors
|
|
46
46
|
exitCommands?: string[]; // commands to exit the cli gracefully
|
|
47
47
|
promptArg?: (string & {}) | "first-arg" | "last-arg"; // argument name to pass the prompt, e.g. --prompt, or first-arg for positional arg
|
|
@@ -167,6 +167,21 @@ export default async function agentYes({
|
|
|
167
167
|
const pidStore = new PidStore(workingDir);
|
|
168
168
|
await pidStore.init();
|
|
169
169
|
|
|
170
|
+
const stdinReady = new ReadyManager();
|
|
171
|
+
const stdinFirstReady = new ReadyManager(); // if user send ctrl+c before
|
|
172
|
+
|
|
173
|
+
// If ready check is disabled (empty array), mark stdin ready immediately
|
|
174
|
+
if (conf.ready && conf.ready.length === 0) {
|
|
175
|
+
stdinReady.ready();
|
|
176
|
+
stdinFirstReady.ready();
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
// force ready after 10s to avoid stuck forever if the ready-word mismatched
|
|
180
|
+
sleep(10e3).then(() => {
|
|
181
|
+
if (!stdinReady.isReady) stdinReady.ready();
|
|
182
|
+
if (!stdinFirstReady.isReady) stdinFirstReady.ready();
|
|
183
|
+
});
|
|
184
|
+
const nextStdout = new ReadyManager();
|
|
170
185
|
process.stdin.setRawMode?.(true); // must be called any stdout/stdin usage
|
|
171
186
|
|
|
172
187
|
const shellOutputStream = new TransformStream<string, string>();
|
|
@@ -436,8 +451,8 @@ export default async function agentYes({
|
|
|
436
451
|
|
|
437
452
|
// when current tty resized, resize the pty too
|
|
438
453
|
process.stdout.on("resize", () => {
|
|
439
|
-
const { cols, rows } = getTerminalDimensions();
|
|
440
|
-
shell.resize(cols, rows);
|
|
454
|
+
const { cols, rows } = getTerminalDimensions();
|
|
455
|
+
shell.resize(cols, rows);
|
|
441
456
|
});
|
|
442
457
|
|
|
443
458
|
const terminalRender = new TerminalTextRender();
|
|
@@ -598,6 +613,15 @@ export default async function agentYes({
|
|
|
598
613
|
), // 5 seconds timeout
|
|
599
614
|
]);
|
|
600
615
|
}
|
|
616
|
+
|
|
617
|
+
function getTerminalDimensions() {
|
|
618
|
+
if (!process.stdout.isTTY) return { cols: 80, rows: 30 }; // default size when not tty
|
|
619
|
+
return {
|
|
620
|
+
// Enforce minimum 20 columns to avoid layout issues
|
|
621
|
+
cols: Math.max(20, process.stdout.columns),
|
|
622
|
+
rows: process.stdout.rows,
|
|
623
|
+
};
|
|
624
|
+
}
|
|
601
625
|
}
|
|
602
626
|
|
|
603
627
|
function sleep(ms: number) {
|