agent-yes 1.304.0 → 1.304.1

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 (35) hide show
  1. package/default.config.yaml +6 -0
  2. package/dist/{SUPPORTED_CLIS-C_1IiOj3.js → SUPPORTED_CLIS-D1BObsKi.js} +2 -2
  3. package/dist/{SUPPORTED_CLIS-Do3GHAY1.js → SUPPORTED_CLIS-R2KdLsVb.js} +3 -3
  4. package/dist/{agentShare-BvpEm-Fr.js → agentShare-pQedI_ay.js} +2 -2
  5. package/dist/{callback-BiSUhjw7.js → callback-Bd_uX6c9.js} +3 -3
  6. package/dist/{callback-SqLD2mMX.js → callback-WJ1STnzc.js} +2 -2
  7. package/dist/cli.js +5 -5
  8. package/dist/{cmdPs-DBt23Qz0.js → cmdPs-Bzld9JDB.js} +2 -2
  9. package/dist/index.js +2 -2
  10. package/dist/{notifyDaemon-DkUB7GV2.js → notifyDaemon-D_fT6Xht.js} +2 -2
  11. package/dist/{parentPingLoop-DDO592Wh.js → parentPingLoop-CVqnIzti.js} +2 -2
  12. package/dist/{rustBinary-BrJ2p8wy.js → rustBinary-AJOmpsZY.js} +2 -2
  13. package/dist/{rustBinary-vpfpWj1q.js → rustBinary-BEUXAC5F.js} +2 -2
  14. package/dist/{schedule-Bzjhl6-h.js → schedule-CeSvliXR.js} +4 -4
  15. package/dist/{serve-XwFYE0cE.js → serve-Dn24AExp.js} +21 -21
  16. package/dist/{setup-D4-s2VZw.js → setup-onxpwXOt.js} +2 -2
  17. package/dist/{shareCmd-DUBsVI3e.js → shareCmd-Bfxkzdm6.js} +5 -5
  18. package/dist/{subcommands-B7YZJL8n.js → subcommands--RGuFC68.js} +123 -29
  19. package/dist/{subcommands-BZPxFgkT.js → subcommands-B-VG0io0.js} +1 -1
  20. package/dist/{terminal-13cGj3h6.js → terminal-Jsj7SgxD.js} +2 -2
  21. package/dist/trayApp-Bngl2X4e.js +5 -0
  22. package/dist/{trayApp-5_OlvQcz.js → trayApp-lEZ-Wa4D.js} +2 -2
  23. package/dist/{ts-njuddXQz.js → ts-DLPvUXQS.js} +3 -3
  24. package/dist/{versionChecker-BJycAanp.js → versionChecker-Dtj0d8dY.js} +2 -2
  25. package/dist/{widget-DmRwOlco.js → widget-CyoP4Stv.js} +3 -3
  26. package/dist/{ws-ByO6JO6m.js → ws-CDZj5r8l.js} +2 -2
  27. package/dist/{ws-D0-Jg88z.js → ws-DtFNNKlC.js} +2 -2
  28. package/package.json +1 -1
  29. package/ts/composerGuard.edges.spec.ts +2 -0
  30. package/ts/composerGuard.spec.ts +51 -0
  31. package/ts/composerGuard.ts +44 -3
  32. package/ts/configShared.spec.ts +9 -0
  33. package/ts/subcommands.spec.ts +100 -0
  34. package/ts/subcommands.ts +108 -9
  35. package/dist/trayApp-DkAPo0m6.js +0 -5
@@ -35,6 +35,8 @@ export interface ComposerCell {
35
35
  inverse: boolean;
36
36
  /** Drawn in a non-default foreground colour (Claude's footer is; typed text is not). */
37
37
  colored: boolean;
38
+ /** Drawn in bright black (SGR 90): agy's input-row notices; typed text is not. */
39
+ gray?: boolean;
38
40
  }
39
41
 
40
42
  /** A rendered row: its plain text plus per-cell attributes. */
@@ -47,7 +49,12 @@ export type ComposerState =
47
49
  /** Nothing typed: an empty prompt, possibly showing dim ghost text. */
48
50
  | { kind: "empty"; ghost: boolean }
49
51
  /** Real input is sitting in the composer. `chars` counts the real cells. */
50
- | { kind: "draft"; chars: number }
52
+ | {
53
+ kind: "draft";
54
+ chars: number;
55
+ /** The draft is a whole `ay send` envelope with this nonce (see ownEnvelopeNonce). */
56
+ own?: string;
57
+ }
51
58
  /** No composer is visible (menu, trust dialog, unknown CLI screen). */
52
59
  | { kind: "unknown"; reason: string }
53
60
  /**
@@ -103,6 +110,25 @@ export function composerPromptRow(texts: string[], cli?: string): number {
103
110
  return texts.findLastIndex((t) => re.test(t));
104
111
  }
105
112
 
113
+ /**
114
+ * The nonce of an `ay send` envelope sitting whole in the input box — its
115
+ * `<ay-msg NONCE …` header on the prompt row and its `</ay-msg NONCE>` closer as
116
+ * the last text above the footer — or null. That is ay's own message whose Enter
117
+ * was swallowed, not someone's draft, however many rows it spans.
118
+ */
119
+ export function ownEnvelopeNonce(texts: string[], cli?: string): string | null {
120
+ const prompt = composerPromptRow(texts, cli);
121
+ if (prompt < 0) return null;
122
+ const nonce = /^<ay-msg ([0-9a-f]{8}) /.exec(stripPromptGlyph(texts[prompt]!, cli))?.[1];
123
+ if (!nonce) return null;
124
+ const close = texts.findLastIndex((t, i) => i > prompt && t.trim() === `</ay-msg ${nonce}>`);
125
+ if (close < 0) return null;
126
+ const below = texts.slice(close + 1).filter((t) => t.trim());
127
+ if (below.length > MAX_ROWS_BELOW_AGY_BOX || below.some((t) => promptRe(cli).test(t)))
128
+ return null;
129
+ return nonce;
130
+ }
131
+
106
132
  /**
107
133
  * Is Claude Code's composer box the bottom of the screen: a rule directly above a
108
134
  * prompt row, at most a few draft rows (none of them another prompt) up to the
@@ -123,11 +149,16 @@ export function composerBoxed(texts: string[], cli?: string, needRule = true): b
123
149
  const nonBlank = (rows: string[]) => rows.filter((t) => t.trim());
124
150
  const close = texts.findIndex((t, i) => i > prompt && isComposerChrome(t));
125
151
  if (close < 0) return false;
152
+ // agy's box is closed by a rule and has its task list (a few rows, a rule) and
153
+ // footer under it. Its past turns are drawn as a rule over a `> …` row too, so
154
+ // a box closed only by the footer is an old turn left above a partial redraw.
155
+ const agy = cli === "agy";
156
+ if (agy && !SEPARATOR_RE.test(texts[close]!)) return false;
126
157
  const inside = nonBlank(texts.slice(prompt + 1, close));
127
158
  const below = nonBlank(texts.slice(close + 1));
128
159
  return (
129
160
  inside.length <= MAX_DRAFT_ROWS &&
130
- below.length <= MAX_ROWS_BELOW_BOX &&
161
+ below.length <= (agy ? MAX_ROWS_BELOW_AGY_BOX : MAX_ROWS_BELOW_BOX) &&
131
162
  ![...inside, ...below].some((t) => promptRe(cli).test(t))
132
163
  );
133
164
  }
@@ -136,6 +167,10 @@ export function composerBoxed(texts: string[], cli?: string, needRule = true): b
136
167
  const MAX_DRAFT_ROWS = 8;
137
168
  /** Footer rows Claude Code draws under its composer box (mode, hints, agents, notices). */
138
169
  const MAX_ROWS_BELOW_BOX = 4;
170
+ /** agy: its task list (up to ~5 rows and a "↓ N more" row), a rule, the footer. */
171
+ const MAX_ROWS_BELOW_AGY_BOX = 10;
172
+ /** CLIs whose composer box has a rule above its prompt row (composerBoxed's needRule). */
173
+ export const BOXED_COMPOSER_CLIS = new Set(["claude", "agy"]);
139
174
 
140
175
  /**
141
176
  * Is this row composer chrome (a rule or a Claude/Codex footer) — the end of the
@@ -172,6 +207,7 @@ export function classifyComposer(rows: ComposerRow[], cli?: string): ComposerSta
172
207
  cli,
173
208
  );
174
209
  if (prompt < 0) return { kind: "unknown", reason: "no prompt row on screen" };
210
+ const agyGhost = cli === "agy";
175
211
  let real = 0;
176
212
  let ghost = false;
177
213
  for (let i = prompt; i < rows.length; i++) {
@@ -190,7 +226,9 @@ export function classifyComposer(rows: ComposerRow[], cli?: string): ComposerSta
190
226
  for (const c of cells) {
191
227
  if (!c.ch.trim() || c.ch === "\u00a0") continue;
192
228
  if (c.inverse) continue;
193
- if (c.dim) ghost = true;
229
+ // agy writes its mode notice ("Auto mode: … (shift+tab to cycle)") into the
230
+ // empty input row in gray, where Claude/Codex use dim ghost text.
231
+ if (c.dim || (c.gray && agyGhost)) ghost = true;
194
232
  else real++;
195
233
  }
196
234
  }
@@ -211,6 +249,8 @@ type XtermLike = {
211
249
  isDim(): number;
212
250
  isInverse(): number;
213
251
  isFgDefault(): boolean;
252
+ isFgPalette(): boolean;
253
+ getFgColor(): number;
214
254
  getWidth(): number;
215
255
  }
216
256
  | undefined;
@@ -246,6 +286,7 @@ export function rowsFromXterm(term: XtermLike, n: number, fromContent = false):
246
286
  dim: c.isDim() !== 0,
247
287
  inverse: c.isInverse() !== 0,
248
288
  colored: !c.isFgDefault(),
289
+ gray: c.isFgPalette() && c.getFgColor() === 8,
249
290
  });
250
291
  }
251
292
  rows.push({ text: line.translateToString(true), cells });
@@ -128,6 +128,15 @@ describe("configShared", () => {
128
128
  expect(decide("no-such-cli", "the deploy is green")).toBe(false);
129
129
  });
130
130
 
131
+ it("skips agy's feedback survey with 0, and only the survey row", async () => {
132
+ const clis = await loadSharedCliDefaults(import.meta.url);
133
+ const skip = clis.agy?.typingRespond?.["0"]?.map((p) => compileRegexSource(p)) ?? [];
134
+ const hits = (line: string) => skip.some((rx) => rx.test(line));
135
+ expect(hits(" [1] Good [2] Fine [3] Bad [0] Skip")).toBe(true);
136
+ expect(hits(" How's the CLI experience so far? Help us improve:")).toBe(false);
137
+ expect(hits("> rate it [1] Good")).toBe(false);
138
+ });
139
+
131
140
  it("finds the shared defaults file by walking upward", async () => {
132
141
  const found = await findSharedCliDefaultsPath(import.meta.url);
133
142
  expect(found.endsWith("default.config.yaml")).toBe(true);
@@ -5036,6 +5036,32 @@ describe("readComposerState on a lane idle for hours", { timeout: 60_000 }, () =
5036
5036
  return readComposerState({ pid: 1111, cli, log_file: file } as never, windows);
5037
5037
  }
5038
5038
 
5039
+ // A codex screen whose input box holds a whole `ay send` envelope, taller than
5040
+ // a draft may be for the box to count as on screen.
5041
+ function codexEnvelopeLog(withDraft: boolean | "plain" = true): string {
5042
+ const rows = ["• done: committed, not pushed", ""];
5043
+ if (withDraft === "plain") {
5044
+ rows.push("› a long pasted note");
5045
+ for (let i = 0; i < 12; i++) rows.push(` - note ${i}`);
5046
+ } else if (withDraft) {
5047
+ rows.push(
5048
+ '› <ay-msg 1a2b3c4d from claude alice@box:/repo/alpha:main#1111 — reply: ay send 1111 "...">',
5049
+ );
5050
+ for (let i = 0; i < 12; i++) rows.push(` - note ${i}`);
5051
+ rows.push(" </ay-msg 1a2b3c4d>");
5052
+ } else rows.push("› ");
5053
+ rows.push("", " gpt-x default · ~/repo", " ? for shortcuts");
5054
+ return "\x1b[2J" + rows.map((t, i) => at(50 - rows.length + i + 1, t)).join("");
5055
+ }
5056
+
5057
+ it("reads ay's own tall envelope in a codex box as a draft it owns, not hidden", async () => {
5058
+ expect(await stateOf(codexEnvelopeLog(), "codex")).toEqual({
5059
+ kind: "draft",
5060
+ chars: expect.any(Number),
5061
+ own: "1a2b3c4d",
5062
+ });
5063
+ });
5064
+
5039
5065
  describe("submitStableDraft", () => {
5040
5066
  async function setup(draft: string) {
5041
5067
  const { submitStableDraft } = await loadModule();
@@ -5076,6 +5102,51 @@ describe("readComposerState on a lane idle for hours", { timeout: 60_000 }, () =
5076
5102
  expect(await readFile(fifo_file, "utf-8")).toBe("");
5077
5103
  });
5078
5104
 
5105
+ // writeToIpc connects to a named pipe on Windows; this fake FIFO is a plain file.
5106
+ it.skipIf(process.platform === "win32")(
5107
+ "submits ay's own envelope left in a codex box at once, without the stability waits",
5108
+ async () => {
5109
+ const { submitStableDraft } = await loadModule();
5110
+ const n = 2000 + logs++;
5111
+ const log_file = path.join(testHome, `${n}.raw.log`);
5112
+ const fifo_file = path.join(testHome, `${n}.fifo`);
5113
+ await writeFile(log_file, codexEnvelopeLog());
5114
+ await writeFile(fifo_file, "");
5115
+ const record = { pid: n, cli: "codex", log_file, fifo_file } as never;
5116
+ const waits: number[] = [];
5117
+ const sent = await submitStableDraft(record, [1, 2, 4, 8], async (ms) => {
5118
+ waits.push(ms);
5119
+ if ((await readFile(fifo_file, "utf-8")).includes("\r"))
5120
+ await writeFile(log_file, codexEnvelopeLog(false));
5121
+ });
5122
+ expect(sent).toBe(true);
5123
+ expect(waits.slice(0, 4)).not.toEqual([1, 2, 4, 8]);
5124
+ expect(await readFile(fifo_file, "utf-8")).toBe("\r");
5125
+ },
5126
+ );
5127
+
5128
+ it.skipIf(process.platform === "win32")(
5129
+ "submits a tall draft that reads hidden only after twice the wait",
5130
+ async () => {
5131
+ const { submitStableDraft } = await loadModule();
5132
+ const n = 2000 + logs++;
5133
+ const log_file = path.join(testHome, `${n}.raw.log`);
5134
+ const fifo_file = path.join(testHome, `${n}.fifo`);
5135
+ await writeFile(log_file, codexEnvelopeLog("plain"));
5136
+ await writeFile(fifo_file, "");
5137
+ const record = { pid: n, cli: "codex", log_file, fifo_file } as never;
5138
+ const waits: number[] = [];
5139
+ const sent = await submitStableDraft(record, [1, 2, 4, 8], async (ms) => {
5140
+ waits.push(ms);
5141
+ if ((await readFile(fifo_file, "utf-8")).includes("\r"))
5142
+ await writeFile(log_file, codexEnvelopeLog(false));
5143
+ });
5144
+ expect(sent).toBe(true);
5145
+ expect(waits.slice(0, 5)).toEqual([1, 2, 4, 8, 15]);
5146
+ expect(await readFile(fifo_file, "utf-8")).toBe("\r");
5147
+ },
5148
+ );
5149
+
5079
5150
  it("does nothing for an empty box", async () => {
5080
5151
  const { submitStableDraft, record, fifo_file } = await setup("");
5081
5152
  expect(await submitStableDraft(record, [1], async () => {})).toBe(false);
@@ -5119,6 +5190,35 @@ describe("readComposerState on a lane idle for hours", { timeout: 60_000 }, () =
5119
5190
  expect((await stateOf(turn.repeat(3000), "codex")).kind).toBe("hidden");
5120
5191
  });
5121
5192
 
5193
+ // agy: past turns are a rule over a `> …` row, like its input row; the box is
5194
+ // followed by a task list, a rule and the footer. The full frame is drawn once,
5195
+ // then >32 KB of redraws touch only the last past turn, the tasks and the footer.
5196
+ function agyIdleLog(composer: string, bytes = 200 * 1024): string {
5197
+ const rule = `${GRAY}${"─".repeat(COLS)}\x1b[0m`;
5198
+ const screen: string[] = [];
5199
+ for (let i = 0; i < 30; i++) screen.push(` step ${i}: lorem ipsum dolor sit amet`);
5200
+ screen.push(rule, "> please summarise the plan", " answer 1", " answer 2", " answer 3");
5201
+ screen.push("", rule, `> ${composer}`, rule);
5202
+ screen.push(" ● [10:00:00] build", " ● [10:01:00] test", " ↓ 3 more", rule);
5203
+ screen.push(`${GRAY}? for shortcuts\x1b[0m`);
5204
+ const redrawn = new Set([31, 32, 33, 34, 35, 40, 41, 42, 44]);
5205
+ let log = "\x1b[2J" + screen.map((t, i) => at(i + 1, t)).join("") + "\x1b[38;3H";
5206
+ for (let k = 0; log.length < bytes; k++) {
5207
+ for (const r of redrawn) log += at(r, screen[r - 1]! + (r === 42 ? ` ${k % 10}` : ""));
5208
+ log += "\x1b[38;3H";
5209
+ }
5210
+ return log;
5211
+ }
5212
+
5213
+ it("reads agy's empty box drawn before the last 32 KB, not a past `>` turn", async () => {
5214
+ // The 32 KB tail alone shows the past turn as the prompt and its answer as a draft.
5215
+ expect(await stateOf(agyIdleLog(""), "agy")).toEqual({ kind: "empty", ghost: false });
5216
+ });
5217
+
5218
+ it("still reads a typed draft in agy's box", async () => {
5219
+ expect(await stateOf(agyIdleLog("btw how"), "agy")).toEqual({ kind: "draft", chars: 6 });
5220
+ });
5221
+
5122
5222
  it("follows what is appended after the first reading, and a truncated log", async () => {
5123
5223
  const { readComposerState } = await loadModule();
5124
5224
  const file = path.join(testHome, "2222.raw.log");
package/ts/subcommands.ts CHANGED
@@ -131,8 +131,10 @@ import { isWithin, resolveWorkDir } from "./workDir.ts";
131
131
  import {
132
132
  bodyHash,
133
133
  classifyComposer,
134
+ BOXED_COMPOSER_CLIS,
134
135
  composerBoxed,
135
136
  composerPromptRow,
137
+ ownEnvelopeNonce,
136
138
  stripPromptGlyph,
137
139
  DUPLICATE_WINDOW_MS,
138
140
  findRecentDuplicate,
@@ -686,6 +688,7 @@ const SUBCOMMANDS = new Set([
686
688
  "history",
687
689
  "send",
688
690
  "send-drain",
691
+ "submit",
689
692
  "msgs",
690
693
  "key",
691
694
  "select",
@@ -1101,6 +1104,8 @@ export async function runSubcommand(argv: string[]): Promise<number | null> {
1101
1104
  return await cmdSend(rest);
1102
1105
  case "send-drain":
1103
1106
  return await cmdSendDrain(rest);
1107
+ case "submit":
1108
+ return await cmdSubmit(rest);
1104
1109
  case "ls-refresh":
1105
1110
  return await cmdLsRefresh(rest);
1106
1111
  case "msgs":
@@ -1407,6 +1412,7 @@ export async function cmdHelp(managerCommands = true): Promise<number> {
1407
1412
  ` ay widget ls | read selection|dom read an opted-in page widget's context (selection/DOM) (ay widget help)\n` +
1408
1413
  ` ay mint <target> --caps ... mint a scoped, short-TTL capability token (embeddable in a page)\n` +
1409
1414
  ` ay key <keyword> <key...> send raw keystrokes (down/up/enter/esc/…) — drives menus\n` +
1415
+ ` ay submit <keyword> press Enter on text left in its input box\n` +
1410
1416
  ` ay select <keyword> <N> pick option N of a needs_input selection menu\n` +
1411
1417
  ` ay attach <keyword> interactive attach (detach: Ctrl-\\)\n` +
1412
1418
  ` ay stop <keyword> graceful shutdown (/exit for claude/codex)\n` +
@@ -4753,7 +4759,7 @@ function dropComposerTerm(logPath: string) {
4753
4759
 
4754
4760
  /**
4755
4761
  * The bottom 40 rows of a log as the composer check sees them: rendered from
4756
- * the 32 KB tail and, for Claude, from further back until its composer box is
4762
+ * the 32 KB tail and, for Claude and agy, from further back until its composer box is
4757
4763
  * on screen (see COMPOSER_WINDOWS). Keeps per-cell attributes. Null for an
4758
4764
  * empty log; throws when the log cannot be read or rendered.
4759
4765
  */
@@ -4765,7 +4771,7 @@ async function renderComposerRows(
4765
4771
  const logPath = record.log_file;
4766
4772
  const geom = (await readAgentPtysize(record)) ?? undefined;
4767
4773
  const key = `${geom?.cols}x${geom?.rows}:${record.cli}:${windows.join()}`;
4768
- const claude = record.cli === "claude";
4774
+ const ruled = BOXED_COMPOSER_CLIS.has(record.cli);
4769
4775
  try {
4770
4776
  const { size } = await stat(logPath);
4771
4777
  if (size === 0) return null;
@@ -4788,7 +4794,7 @@ async function renderComposerRows(
4788
4794
  composerBoxed(
4789
4795
  rows.map((r) => r.text),
4790
4796
  record.cli,
4791
- claude,
4797
+ ruled,
4792
4798
  )
4793
4799
  )
4794
4800
  next = windows.length;
@@ -4820,7 +4826,7 @@ async function renderComposerRows(
4820
4826
  composerBoxed(
4821
4827
  rows.map((r) => r.text),
4822
4828
  record.cli,
4823
- claude,
4829
+ ruled,
4824
4830
  )
4825
4831
  )
4826
4832
  break;
@@ -4844,11 +4850,19 @@ export async function readComposerState(
4844
4850
  ): Promise<ComposerState> {
4845
4851
  const logPath = record.log_file;
4846
4852
  if (!logPath) return { kind: "unknown", reason: "no log file recorded" };
4847
- const claude = record.cli === "claude";
4853
+ const ruled = BOXED_COMPOSER_CLIS.has(record.cli);
4848
4854
  try {
4849
4855
  const rows = await renderComposerRows({ ...record, log_file: logPath }, windows);
4850
4856
  if (!rows) return { kind: "unknown", reason: "log unreadable or empty" };
4851
4857
  const state = classifyComposer(rows, record.cli);
4858
+ const own =
4859
+ state.kind === "draft"
4860
+ ? ownEnvelopeNonce(
4861
+ rows.map((r) => r.text),
4862
+ record.cli,
4863
+ )
4864
+ : null;
4865
+ if (state.kind === "draft" && own) return { ...state, own };
4852
4866
  // No window showed the box, so a "draft" was read under some other prompt
4853
4867
  // row, possibly an old turn: say so instead of reporting it as a draft.
4854
4868
  if (
@@ -4856,7 +4870,7 @@ export async function readComposerState(
4856
4870
  !composerBoxed(
4857
4871
  rows.map((r) => r.text),
4858
4872
  record.cli,
4859
- claude,
4873
+ ruled,
4860
4874
  )
4861
4875
  )
4862
4876
  return { kind: "hidden", reason: "its input box is not on screen" };
@@ -4893,17 +4907,30 @@ async function composerFingerprint(record: GlobalPidRecord): Promise<string | nu
4893
4907
  * (1, 2, 4, 8 s): nobody is typing, so submit it with Enter and report true once
4894
4908
  * the box reads empty again. Only a draft: a menu or yes/no prompt is a question
4895
4909
  * agent-yes deliberately does not answer. Any change, or a box that never clears,
4896
- * returns false and the caller parks the message as before.
4910
+ * returns false and the caller parks the message as before. An `ay send`
4911
+ * envelope whose Enter was swallowed (ownEnvelopeNonce) is submitted at once; a
4912
+ * "hidden" box (a draft taller than the box check allows) after twice the wait,
4913
+ * unless the screen shows a menu or dialog.
4897
4914
  */
4898
4915
  export async function submitStableDraft(
4899
4916
  record: GlobalPidRecord,
4900
4917
  waits: number[] = DRAFT_STABLE_WAITS_MS,
4901
4918
  sleep: (ms: number) => Promise<void> = (ms) => new Promise((r) => setTimeout(r, ms)),
4902
4919
  ): Promise<boolean> {
4903
- if ((await readComposerState(record)).kind !== "draft") return false;
4920
+ const state = await readComposerState(record);
4921
+ if (state.kind !== "draft" && state.kind !== "hidden") return false;
4922
+ // A draft too tall for the box to read as on screen is "hidden": give it twice
4923
+ // the wait (~30 s by default), and never press Enter on a menu or dialog.
4924
+ if (state.kind === "hidden") {
4925
+ if (!record.log_file || (await extractNeedsInput(record.log_file, record.cli))) return false;
4926
+ }
4904
4927
  const base = await composerFingerprint(record);
4905
4928
  if (base === null) return false;
4906
- for (const ms of waits) {
4929
+ const total = waits.reduce((a, b) => a + b, 0);
4930
+ // ay's own envelope left whole in the box lost its Enter: nobody is editing it.
4931
+ const plan =
4932
+ state.kind === "draft" && state.own ? [] : state.kind === "hidden" ? [...waits, total] : waits;
4933
+ for (const ms of plan) {
4907
4934
  await sleep(ms);
4908
4935
  if ((await composerFingerprint(record)) !== base) return false;
4909
4936
  }
@@ -6578,6 +6605,78 @@ async function recordKeyEvent(
6578
6605
  });
6579
6606
  }
6580
6607
 
6608
+ /**
6609
+ * `ay submit <keyword>`: press Enter on whatever sits in the target's input box —
6610
+ * typically an `ay send` whose Enter was swallowed, holding every later message
6611
+ * in the queue. Does nothing to an empty box or a screen without one (a menu is
6612
+ * answered with `ay key`/`ay select`, not Enter).
6613
+ */
6614
+ async function cmdSubmit(rest: string[]): Promise<number> {
6615
+ const y = yargs(rest)
6616
+ .usage(
6617
+ "Usage: ay submit <keyword> [options]\n\n" +
6618
+ "Press Enter on the text left in a live agent's input box, e.g. an `ay send`\n" +
6619
+ "whose Enter was swallowed and that is now holding later messages in the\n" +
6620
+ "queue. Leaves an empty box and any menu or dialog alone.",
6621
+ )
6622
+ .option("all", { type: "boolean", default: false, description: "Include exited agents" })
6623
+ .option("latest", { type: "boolean", default: false, description: "Use most recent match" })
6624
+ .option("cwd", { type: "string", description: "Restrict to agents under this dir" })
6625
+ .option("force", {
6626
+ type: "boolean",
6627
+ default: false,
6628
+ description: "Skip the recency/self-send guard (also: AGENT_YES_FORCE_SEND=1)",
6629
+ })
6630
+ .help(false)
6631
+ .version(false)
6632
+ .exitProcess(false);
6633
+ const argv = await y.parseAsync();
6634
+ const keyword = argv._[0] !== undefined ? String(argv._[0]) : undefined;
6635
+ if (!keyword) throw new Error("usage: ay submit <keyword>");
6636
+ const opts: CommonOpts = {
6637
+ all: argv.all,
6638
+ active: false,
6639
+ json: false,
6640
+ latest: argv.latest,
6641
+ cwdScope: typeof argv.cwd === "string" ? path.resolve(argv.cwd) : null,
6642
+ };
6643
+ const record = await resolveWritableAgent(keyword, opts);
6644
+ const force = Boolean(argv.force) || process.env.AGENT_YES_FORCE_SEND === "1";
6645
+ const sender = await enforceSendGuards(record, force);
6646
+ const before = await readComposerState(record);
6647
+ if (before.kind !== "draft" && before.kind !== "hidden") {
6648
+ process.stdout.write(
6649
+ `nothing to submit in pid ${record.pid} (${record.cli}): ${
6650
+ before.kind === "empty" ? "its input box is empty" : before.reason
6651
+ }\n`,
6652
+ );
6653
+ return 0;
6654
+ }
6655
+ await withIpcLock(
6656
+ record.pid,
6657
+ () => writeToIpc(record.fifo_file!, "\r"),
6658
+ (why) =>
6659
+ process.stderr.write(
6660
+ `warning: ay submit writing pid ${record.pid} without the input lock (${why})\n`,
6661
+ ),
6662
+ );
6663
+ await recordKeyEvent(sender, record, "key", "enter");
6664
+ let after: ComposerState = before;
6665
+ for (let i = 0; i < 6 && after.kind !== "empty"; i++) {
6666
+ await new Promise((r) => setTimeout(r, 500));
6667
+ after = await readComposerState(record);
6668
+ }
6669
+ if ((await listPending(record.pid)).length) await ensureSendDrainer(record.pid);
6670
+ if (after.kind === "empty") {
6671
+ process.stdout.write(`submitted pid ${record.pid} (${record.cli})'s input box\n`);
6672
+ return 0;
6673
+ }
6674
+ process.stdout.write(
6675
+ `pressed Enter on pid ${record.pid} (${record.cli}), but its input box still reads ${after.kind} — check: ay tail ${record.pid}\n`,
6676
+ );
6677
+ return 1;
6678
+ }
6679
+
6581
6680
  async function cmdKey(rest: string[]): Promise<number> {
6582
6681
  const y = yargs(rest)
6583
6682
  .usage(
@@ -1,5 +0,0 @@
1
- import "./versionChecker-BJycAanp.js";
2
- import "./rustBinary-BrJ2p8wy.js";
3
- import { a as trayHiddenMarker, i as launchTray, n as hasDesktop, r as isTrayHidden, t as cmdTray } from "./trayApp-5_OlvQcz.js";
4
-
5
- export { cmdTray };