@cluesmith/codev 3.3.2 → 3.3.4

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 (257) hide show
  1. package/dashboard-dist/assets/{index-D3XaKpZW.js → index-DZf6pNPE.js} +41 -41
  2. package/dashboard-dist/assets/index-DZf6pNPE.js.map +1 -0
  3. package/dashboard-dist/assets/index-DnYLy5C_.css +32 -0
  4. package/dashboard-dist/index.html +2 -2
  5. package/dist/agent-farm/cli.d.ts.map +1 -1
  6. package/dist/agent-farm/cli.js +48 -0
  7. package/dist/agent-farm/cli.js.map +1 -1
  8. package/dist/agent-farm/commands/ide.d.ts +20 -0
  9. package/dist/agent-farm/commands/ide.d.ts.map +1 -0
  10. package/dist/agent-farm/commands/ide.js +138 -0
  11. package/dist/agent-farm/commands/ide.js.map +1 -0
  12. package/dist/agent-farm/commands/inbox.d.ts.map +1 -1
  13. package/dist/agent-farm/commands/inbox.js +79 -10
  14. package/dist/agent-farm/commands/inbox.js.map +1 -1
  15. package/dist/agent-farm/commands/interrupt.d.ts +4 -1
  16. package/dist/agent-farm/commands/interrupt.d.ts.map +1 -1
  17. package/dist/agent-farm/commands/interrupt.js +6 -3
  18. package/dist/agent-farm/commands/interrupt.js.map +1 -1
  19. package/dist/agent-farm/commands/reset.d.ts +4 -1
  20. package/dist/agent-farm/commands/reset.d.ts.map +1 -1
  21. package/dist/agent-farm/commands/reset.js +6 -3
  22. package/dist/agent-farm/commands/reset.js.map +1 -1
  23. package/dist/agent-farm/commands/send.d.ts +28 -0
  24. package/dist/agent-farm/commands/send.d.ts.map +1 -1
  25. package/dist/agent-farm/commands/send.js +79 -6
  26. package/dist/agent-farm/commands/send.js.map +1 -1
  27. package/dist/agent-farm/commands/spawn-worktree.d.ts.map +1 -1
  28. package/dist/agent-farm/commands/spawn-worktree.js +16 -7
  29. package/dist/agent-farm/commands/spawn-worktree.js.map +1 -1
  30. package/dist/agent-farm/commands/tower.d.ts +21 -9
  31. package/dist/agent-farm/commands/tower.d.ts.map +1 -1
  32. package/dist/agent-farm/commands/tower.js +90 -30
  33. package/dist/agent-farm/commands/tower.js.map +1 -1
  34. package/dist/agent-farm/db/index.d.ts +3 -1
  35. package/dist/agent-farm/db/index.d.ts.map +1 -1
  36. package/dist/agent-farm/db/index.js +8 -443
  37. package/dist/agent-farm/db/index.js.map +1 -1
  38. package/dist/agent-farm/db/mailbox.d.ts +47 -7
  39. package/dist/agent-farm/db/mailbox.d.ts.map +1 -1
  40. package/dist/agent-farm/db/mailbox.js +56 -12
  41. package/dist/agent-farm/db/mailbox.js.map +1 -1
  42. package/dist/agent-farm/db/migrations.d.ts +57 -0
  43. package/dist/agent-farm/db/migrations.d.ts.map +1 -0
  44. package/dist/agent-farm/db/migrations.js +530 -0
  45. package/dist/agent-farm/db/migrations.js.map +1 -0
  46. package/dist/agent-farm/db/schema.d.ts +1 -1
  47. package/dist/agent-farm/db/schema.d.ts.map +1 -1
  48. package/dist/agent-farm/db/schema.js +1 -0
  49. package/dist/agent-farm/db/schema.js.map +1 -1
  50. package/dist/agent-farm/db/tower-owner.d.ts +168 -0
  51. package/dist/agent-farm/db/tower-owner.d.ts.map +1 -0
  52. package/dist/agent-farm/db/tower-owner.js +369 -0
  53. package/dist/agent-farm/db/tower-owner.js.map +1 -0
  54. package/dist/agent-farm/db/types.d.ts +47 -0
  55. package/dist/agent-farm/db/types.d.ts.map +1 -1
  56. package/dist/agent-farm/db/types.js.map +1 -1
  57. package/dist/agent-farm/lib/ide-record.d.ts +65 -0
  58. package/dist/agent-farm/lib/ide-record.d.ts.map +1 -0
  59. package/dist/agent-farm/lib/ide-record.js +118 -0
  60. package/dist/agent-farm/lib/ide-record.js.map +1 -0
  61. package/dist/agent-farm/lib/tunnel-client.d.ts +22 -0
  62. package/dist/agent-farm/lib/tunnel-client.d.ts.map +1 -1
  63. package/dist/agent-farm/lib/tunnel-client.js +96 -19
  64. package/dist/agent-farm/lib/tunnel-client.js.map +1 -1
  65. package/dist/agent-farm/servers/cron-delivery.d.ts +7 -1
  66. package/dist/agent-farm/servers/cron-delivery.d.ts.map +1 -1
  67. package/dist/agent-farm/servers/cron-delivery.js +2 -1
  68. package/dist/agent-farm/servers/cron-delivery.js.map +1 -1
  69. package/dist/agent-farm/servers/gate-profiles.d.ts +44 -2
  70. package/dist/agent-farm/servers/gate-profiles.d.ts.map +1 -1
  71. package/dist/agent-farm/servers/gate-profiles.js +79 -6
  72. package/dist/agent-farm/servers/gate-profiles.js.map +1 -1
  73. package/dist/agent-farm/servers/ide-forward.d.ts +62 -0
  74. package/dist/agent-farm/servers/ide-forward.d.ts.map +1 -0
  75. package/dist/agent-farm/servers/ide-forward.js +274 -0
  76. package/dist/agent-farm/servers/ide-forward.js.map +1 -0
  77. package/dist/agent-farm/servers/ide-server.d.ts +68 -0
  78. package/dist/agent-farm/servers/ide-server.d.ts.map +1 -0
  79. package/dist/agent-farm/servers/ide-server.js +281 -0
  80. package/dist/agent-farm/servers/ide-server.js.map +1 -0
  81. package/dist/agent-farm/servers/mailbox-delivery.d.ts +296 -12
  82. package/dist/agent-farm/servers/mailbox-delivery.d.ts.map +1 -1
  83. package/dist/agent-farm/servers/mailbox-delivery.js +566 -69
  84. package/dist/agent-farm/servers/mailbox-delivery.js.map +1 -1
  85. package/dist/agent-farm/servers/mailbox-wiring.d.ts +66 -19
  86. package/dist/agent-farm/servers/mailbox-wiring.d.ts.map +1 -1
  87. package/dist/agent-farm/servers/mailbox-wiring.js +204 -37
  88. package/dist/agent-farm/servers/mailbox-wiring.js.map +1 -1
  89. package/dist/agent-farm/servers/message-write.d.ts +138 -11
  90. package/dist/agent-farm/servers/message-write.d.ts.map +1 -1
  91. package/dist/agent-farm/servers/message-write.js +144 -35
  92. package/dist/agent-farm/servers/message-write.js.map +1 -1
  93. package/dist/agent-farm/servers/overview.d.ts +28 -12
  94. package/dist/agent-farm/servers/overview.d.ts.map +1 -1
  95. package/dist/agent-farm/servers/overview.js +130 -79
  96. package/dist/agent-farm/servers/overview.js.map +1 -1
  97. package/dist/agent-farm/servers/render-gate.d.ts +77 -1
  98. package/dist/agent-farm/servers/render-gate.d.ts.map +1 -1
  99. package/dist/agent-farm/servers/render-gate.js +174 -25
  100. package/dist/agent-farm/servers/render-gate.js.map +1 -1
  101. package/dist/agent-farm/servers/session-submit.d.ts +7 -4
  102. package/dist/agent-farm/servers/session-submit.d.ts.map +1 -1
  103. package/dist/agent-farm/servers/session-submit.js +7 -4
  104. package/dist/agent-farm/servers/session-submit.js.map +1 -1
  105. package/dist/agent-farm/servers/tower-cron.d.ts.map +1 -1
  106. package/dist/agent-farm/servers/tower-cron.js +7 -3
  107. package/dist/agent-farm/servers/tower-cron.js.map +1 -1
  108. package/dist/agent-farm/servers/tower-instances.d.ts.map +1 -1
  109. package/dist/agent-farm/servers/tower-instances.js +17 -10
  110. package/dist/agent-farm/servers/tower-instances.js.map +1 -1
  111. package/dist/agent-farm/servers/tower-routes.d.ts +32 -0
  112. package/dist/agent-farm/servers/tower-routes.d.ts.map +1 -1
  113. package/dist/agent-farm/servers/tower-routes.js +186 -26
  114. package/dist/agent-farm/servers/tower-routes.js.map +1 -1
  115. package/dist/agent-farm/servers/tower-server.js +79 -9
  116. package/dist/agent-farm/servers/tower-server.js.map +1 -1
  117. package/dist/agent-farm/servers/tower-terminals.d.ts +21 -0
  118. package/dist/agent-farm/servers/tower-terminals.d.ts.map +1 -1
  119. package/dist/agent-farm/servers/tower-terminals.js +106 -13
  120. package/dist/agent-farm/servers/tower-terminals.js.map +1 -1
  121. package/dist/agent-farm/servers/tower-utils.d.ts +35 -0
  122. package/dist/agent-farm/servers/tower-utils.d.ts.map +1 -1
  123. package/dist/agent-farm/servers/tower-utils.js +39 -0
  124. package/dist/agent-farm/servers/tower-utils.js.map +1 -1
  125. package/dist/agent-farm/servers/tower-websocket.d.ts.map +1 -1
  126. package/dist/agent-farm/servers/tower-websocket.js +26 -2
  127. package/dist/agent-farm/servers/tower-websocket.js.map +1 -1
  128. package/dist/agent-farm/utils/message-format.d.ts +78 -2
  129. package/dist/agent-farm/utils/message-format.d.ts.map +1 -1
  130. package/dist/agent-farm/utils/message-format.js +107 -11
  131. package/dist/agent-farm/utils/message-format.js.map +1 -1
  132. package/dist/agent-farm/utils/port.d.ts +22 -0
  133. package/dist/agent-farm/utils/port.d.ts.map +1 -0
  134. package/dist/agent-farm/utils/port.js +35 -0
  135. package/dist/agent-farm/utils/port.js.map +1 -0
  136. package/dist/agent-farm/utils/server-utils.d.ts +26 -0
  137. package/dist/agent-farm/utils/server-utils.d.ts.map +1 -1
  138. package/dist/agent-farm/utils/server-utils.js +36 -0
  139. package/dist/agent-farm/utils/server-utils.js.map +1 -1
  140. package/dist/cli.d.ts.map +1 -1
  141. package/dist/cli.js +3 -1
  142. package/dist/cli.js.map +1 -1
  143. package/dist/commands/consult/index.d.ts.map +1 -1
  144. package/dist/commands/consult/index.js +61 -1
  145. package/dist/commands/consult/index.js.map +1 -1
  146. package/dist/commands/consult/tree-tripwire.d.ts +177 -0
  147. package/dist/commands/consult/tree-tripwire.d.ts.map +1 -0
  148. package/dist/commands/consult/tree-tripwire.js +356 -0
  149. package/dist/commands/consult/tree-tripwire.js.map +1 -0
  150. package/dist/commands/doctor.d.ts +69 -0
  151. package/dist/commands/doctor.d.ts.map +1 -1
  152. package/dist/commands/doctor.js +165 -2
  153. package/dist/commands/doctor.js.map +1 -1
  154. package/dist/commands/generate-image.d.ts +25 -1
  155. package/dist/commands/generate-image.d.ts.map +1 -1
  156. package/dist/commands/generate-image.js +410 -2
  157. package/dist/commands/generate-image.js.map +1 -1
  158. package/dist/commands/porch/prompts.d.ts.map +1 -1
  159. package/dist/commands/porch/prompts.js +18 -2
  160. package/dist/commands/porch/prompts.js.map +1 -1
  161. package/dist/lib/agent-env.d.ts +86 -0
  162. package/dist/lib/agent-env.d.ts.map +1 -0
  163. package/dist/lib/agent-env.js +126 -0
  164. package/dist/lib/agent-env.js.map +1 -0
  165. package/dist/lib/forge-contracts.d.ts +76 -5
  166. package/dist/lib/forge-contracts.d.ts.map +1 -1
  167. package/dist/lib/forge-contracts.js.map +1 -1
  168. package/dist/lib/forge-rate-limit.d.ts +45 -0
  169. package/dist/lib/forge-rate-limit.d.ts.map +1 -0
  170. package/dist/lib/forge-rate-limit.js +89 -0
  171. package/dist/lib/forge-rate-limit.js.map +1 -0
  172. package/dist/lib/forge.d.ts +29 -1
  173. package/dist/lib/forge.d.ts.map +1 -1
  174. package/dist/lib/forge.js +96 -21
  175. package/dist/lib/forge.js.map +1 -1
  176. package/dist/lib/github.d.ts +13 -1
  177. package/dist/lib/github.d.ts.map +1 -1
  178. package/dist/lib/github.js +58 -15
  179. package/dist/lib/github.js.map +1 -1
  180. package/dist/lib/test-env.d.ts +17 -0
  181. package/dist/lib/test-env.d.ts.map +1 -1
  182. package/dist/lib/test-env.js +20 -0
  183. package/dist/lib/test-env.js.map +1 -1
  184. package/dist/terminal/pty-manager.d.ts +10 -1
  185. package/dist/terminal/pty-manager.d.ts.map +1 -1
  186. package/dist/terminal/pty-manager.js +38 -9
  187. package/dist/terminal/pty-manager.js.map +1 -1
  188. package/dist/terminal/pty-session.d.ts +174 -8
  189. package/dist/terminal/pty-session.d.ts.map +1 -1
  190. package/dist/terminal/pty-session.js +299 -25
  191. package/dist/terminal/pty-session.js.map +1 -1
  192. package/dist/terminal/session-manager.d.ts +23 -2
  193. package/dist/terminal/session-manager.d.ts.map +1 -1
  194. package/dist/terminal/session-manager.js +115 -36
  195. package/dist/terminal/session-manager.js.map +1 -1
  196. package/dist/terminal/session-screen.d.ts +34 -5
  197. package/dist/terminal/session-screen.d.ts.map +1 -1
  198. package/dist/terminal/session-screen.js +52 -6
  199. package/dist/terminal/session-screen.js.map +1 -1
  200. package/dist/terminal/shellper-client.d.ts +73 -0
  201. package/dist/terminal/shellper-client.d.ts.map +1 -1
  202. package/dist/terminal/shellper-client.js +151 -0
  203. package/dist/terminal/shellper-client.js.map +1 -1
  204. package/dist/terminal/shellper-main.js +20 -3
  205. package/dist/terminal/shellper-main.js.map +1 -1
  206. package/dist/terminal/shellper-process.d.ts +2 -0
  207. package/dist/terminal/shellper-process.d.ts.map +1 -1
  208. package/dist/terminal/shellper-process.js +17 -1
  209. package/dist/terminal/shellper-process.js.map +1 -1
  210. package/dist/terminal/shellper-protocol.d.ts +28 -0
  211. package/dist/terminal/shellper-protocol.d.ts.map +1 -1
  212. package/dist/terminal/shellper-protocol.js.map +1 -1
  213. package/dist/terminal/terminal-replies.d.ts +102 -0
  214. package/dist/terminal/terminal-replies.d.ts.map +1 -0
  215. package/dist/terminal/terminal-replies.js +181 -0
  216. package/dist/terminal/terminal-replies.js.map +1 -0
  217. package/package.json +4 -4
  218. package/scripts/forge/gitea/_lib.sh +214 -0
  219. package/scripts/forge/gitea/issue-comment.sh +8 -1
  220. package/scripts/forge/gitea/issue-view.sh +95 -4
  221. package/scripts/forge/gitea/pr-create.sh +155 -0
  222. package/scripts/forge/gitea/pr-exists.sh +32 -4
  223. package/scripts/forge/gitea/pr-list.sh +40 -31
  224. package/scripts/forge/gitea/pr-view.sh +65 -4
  225. package/scripts/forge/gitea/recently-merged.sh +91 -21
  226. package/scripts/forge/gitea/user-identity.sh +30 -1
  227. package/scripts/forge/github/issue-view.sh +5 -2
  228. package/scripts/forge/github/pr-create.sh +47 -0
  229. package/scripts/forge/github/pr-list.sh +6 -2
  230. package/scripts/forge/github/pr-search.sh +6 -2
  231. package/scripts/forge/gitlab/issue-search.sh +1 -0
  232. package/scripts/forge/gitlab/issue-view.sh +24 -4
  233. package/scripts/forge/gitlab/pr-create.sh +53 -0
  234. package/scripts/forge/gitlab/pr-search.sh +37 -2
  235. package/scripts/forge/linear/auth-status.sh +1 -0
  236. package/scripts/forge/linear/issue-comment.sh +1 -0
  237. package/scripts/forge/linear/issue-list.sh +1 -0
  238. package/scripts/forge/linear/issue-search.sh +1 -0
  239. package/scripts/forge/linear/issue-view.sh +14 -2
  240. package/scripts/forge/linear/recently-closed.sh +1 -0
  241. package/scripts/forge/linear/user-identity.sh +1 -0
  242. package/skeleton/.claude/skills/generate-image/SKILL.md +39 -1
  243. package/skeleton/.codex/skills/generate-image/SKILL.md +39 -1
  244. package/skeleton/protocols/air/prompts/pr.md +6 -1
  245. package/skeleton/protocols/aspir/prompts/review.md +6 -1
  246. package/skeleton/protocols/bugfix/prompts/pr.md +6 -1
  247. package/skeleton/protocols/bugfix/protocol.md +2 -1
  248. package/skeleton/protocols/maintain/prompts/review.md +6 -1
  249. package/skeleton/protocols/pir/prompts/review.md +10 -7
  250. package/skeleton/protocols/spir/prompts/review.md +6 -1
  251. package/skeleton/resources/commands/agent-farm.md +28 -3
  252. package/skeleton/roles/consultant.md +32 -0
  253. package/skeleton/templates/AGENTS.md +1 -1
  254. package/skeleton/templates/CLAUDE.md +1 -1
  255. package/templates/tower.html +16 -1
  256. package/dashboard-dist/assets/index-BZRTEMtH.css +0 -32
  257. package/dashboard-dist/assets/index-D3XaKpZW.js.map +0 -1
@@ -17,15 +17,16 @@ import { terminalDeliverySignals } from '../../terminal/pty-session.js';
17
17
  import { getWorkspaceTerminals, getTerminalManager } from './tower-terminals.js';
18
18
  import { broadcastMessage, resolveAgentInRegistry, isResolveError } from './tower-messages.js';
19
19
  import { submitMessagePaced } from './message-write.js';
20
- import { bufferLines, classifyBuffer } from './render-gate.js';
20
+ import { bufferLines, classifyBuffer, composerRegionFingerprint, } from './render-gate.js';
21
21
  import { resolveProfile } from './gate-profiles.js';
22
22
  import { buildContextFsPort, harnessFromLaunchScript, } from '../commands/reset/context.js';
23
23
  import { getGlobalDb } from '../db/index.js';
24
24
  import { getArchitectByName } from '../state.js';
25
25
  import { formatBuilderMessage } from '../utils/message-format.js';
26
+ import { formatVerdict, isUnverifiableVerdict } from '@cluesmith/codev-sdk/hold-verdict';
26
27
  import { supersede as supersedeMailbox, dismissHeldWithKey, NOTICE_SUPERSEDE_PREFIX } from '../db/mailbox.js';
27
28
  import path from 'node:path';
28
- import { MailboxDrainer, normalizeForEcho, } from './mailbox-delivery.js';
29
+ import { MailboxDrainer, normalizeForEcho, PASTE_PLACARD_NEEDLES, } from './mailbox-delivery.js';
29
30
  /**
30
31
  * "Recent output" window for the liveness diagnostic (Spec 1313, Phase 7 — spec line
31
32
  * 91). A `no-profile` streak only raises the loud log/broadcast when the session emitted
@@ -103,16 +104,25 @@ export function resolveAgentForSession(sessionId) {
103
104
  * (fail-safe by construction: an unknown agent is held and surfaced, never guessed
104
105
  * — this is what correctly trips on wrapper/boot/relaunch screens too).
105
106
  *
106
- * Stale-identity note (Spec 1313): `session.command` is now sourced from the
107
- * persisted `terminal_sessions.command` on reconnect. If it ever goes stale (a
108
- * user re-points `shell.architect` at a different harness and the shellper later
109
- * auto-restarts into it while the row still names the old one), this can resolve
110
- * the WRONG profile — but it fails CLOSED today, not misdelivered: CLAUDE_PROFILE
111
- * and CODEX_PROFILE are behaviourally identical (same marker + region patterns),
112
- * and any cross-family mismatch (e.g. agy's `> ` marker) fails the composer-marker
113
- * test → not clean → held. That safety is a property of the current profile TABLE,
114
- * not of this design; the day codex/claude markers diverge, stale identity becomes
115
- * a live bug and the authoritative fix is WELCOME-frame hydration (see review).
107
+ * Identity precedence (PIR #1475): `session.command` is AUTHORITATIVE where it can
108
+ * be — it reads through to the identity the attached shellper states in its WELCOME
109
+ * frame, i.e. the argv the process that owns the PTY actually spawned, refreshed
110
+ * across reconnects and SPAWN relaunches. Only when no shellper identity is
111
+ * available (a local node-pty session, a pre-#1475 shellper still running from
112
+ * before an upgrade, or a payload that failed validation) does it fall back to the
113
+ * Spec 1313 chain: the persisted `terminal_sessions.command`, then the legacy
114
+ * self-heal from config. So the stale-row hazard this comment used to describe — a
115
+ * user re-points `shell.architect` at a different harness while the row still names
116
+ * the old one — no longer decides the profile for a shellper-backed session; the
117
+ * running process does.
118
+ *
119
+ * The fallback tier keeps its original safety property, and it is worth knowing why
120
+ * it is thin: a stale command fails CLOSED rather than misdelivering only because
121
+ * CLAUDE_PROFILE and CODEX_PROFILE are behaviourally identical (same marker + region
122
+ * patterns) and any cross-family mismatch (e.g. agy's `> ` marker) fails the
123
+ * composer-marker test → not clean → held. That is a property of the current profile
124
+ * TABLE, not of the design. It matters less now that the authoritative tier exists,
125
+ * but it is still what protects the fallback the day codex/claude markers diverge.
116
126
  */
117
127
  export function resolveProfileForSession(session) {
118
128
  const direct = resolveProfile({ command: session.command, args: session.launchArgs });
@@ -135,8 +145,10 @@ export function resolveProfileForSession(session) {
135
145
  * cast is sound. A session that has produced NO output yet has no mirror (`gateScreen` is null);
136
146
  * that is not a verified-empty prompt, so it classifies not-clean (`no-composer-marker`), exactly
137
147
  * as an empty replay always did. `SessionScreen.read()` flushes the parser, so the buffer the
138
- * shared {@link classifyBuffer} reads reflects every byte counted by the change token the
139
- * delivery path sampled — the property its gate→write TOCTOU relies on.
148
+ * shared {@link classifyBuffer} reads reflects every byte the session had emitted when this was
149
+ * called — which is what makes the composer fingerprint the delivery path takes immediately
150
+ * afterwards (with no intervening await) the freshest reading of the composer available to it.
151
+ * Issue #1664 retired the whole-screen `bytesWritten` TOCTOU this note used to name.
140
152
  */
141
153
  export async function classifyAgentScreen(session, profile) {
142
154
  const screen = session.gateScreen;
@@ -145,6 +157,29 @@ export async function classifyAgentScreen(session, profile) {
145
157
  const { term, cols, rows } = await screen.read();
146
158
  return classifyBuffer(term, cols, rows, profile);
147
159
  }
160
+ /**
161
+ * The live binding for {@link DeliveryPorts.composerFingerprint} (Issue #1664) — the delivery
162
+ * path's composer-stability signal.
163
+ *
164
+ * Reads the SAME `SessionScreen` mirror {@link classifyAgentScreen} classifies, so stability
165
+ * and emptiness can never be answered about different screens. SYNCHRONOUS, via
166
+ * `SessionScreen.peek()`: the in-lock precheck that consumes it cannot await (see the port's
167
+ * contract). A session with no mirror has produced no output and shows no composer, so it
168
+ * fingerprints `null` — indeterminate, which the delivery path treats as moved.
169
+ */
170
+ export function composerFingerprintForSession(session, profile) {
171
+ const screen = session.gateScreen;
172
+ if (!screen)
173
+ return null;
174
+ // `peek()` answers `null` while any fed byte is still unparsed (CMAP round 2 — codex): a grid
175
+ // that is missing the very redraw we are checking for would compare EQUAL and permit the
176
+ // write. Pass the refusal straight through — the delivery path reads `null` as "the composer
177
+ // moved" and holds, which self-clears a parse turn later.
178
+ const view = screen.peek();
179
+ if (!view)
180
+ return null;
181
+ return composerRegionFingerprint(view.term, view.cols, view.rows, profile);
182
+ }
148
183
  /**
149
184
  * How long {@link watchEchoOnScreen}'s verification waits for a delivered message's header to
150
185
  * show up, and how often it re-reads while waiting (Issue #1573).
@@ -155,11 +190,16 @@ export async function classifyAgentScreen(session, profile) {
155
190
  * therefore slack for a loaded machine, not the expected cost — the common case returns on the
156
191
  * first read with no added latency. It is bounded because the `afx send` request path awaits
157
192
  * this before answering the sender.
193
+ *
194
+ * Issue #1584: the delivery path calls `verify()` at most TWICE (a second window for a slow
195
+ * renderer, no bytes written), so this constant is half the worst-case wait a sender sees —
196
+ * ~1.2 s. Raising it raises that, and the answer is no longer a retry decision: an unconfirmed
197
+ * delivery is recorded as delivered-unverified, never re-written.
158
198
  */
159
199
  const ECHO_VERIFY_TIMEOUT_MS = 600;
160
200
  const ECHO_VERIFY_POLL_MS = 50;
161
201
  /**
162
- * How many times `needle` appears in the session's rendered mirror right now.
202
+ * How many times each of `needles` appears in the session's rendered mirror right now.
163
203
  *
164
204
  * A COUNT rather than a boolean because presence alone is not evidence (CMAP round 1 — codex):
165
205
  * a previous delivery attempt's echo sits in the same scrollback, so "the header is on screen"
@@ -170,45 +210,57 @@ const ECHO_VERIFY_POLL_MS = 50;
170
210
  * never disagree about what the terminal shows, and scans its full retained buffer rather than
171
211
  * the viewport — a long message scrolls its own header into scrollback while it types.
172
212
  */
173
- async function countEchoOnScreen(screen, needle) {
213
+ async function countEchoOnScreen(screen, needles) {
174
214
  const { term } = await screen.read();
175
215
  const text = normalizeForEcho(bufferLines(term).join('\n'));
176
- let count = 0;
177
- for (let at = text.indexOf(needle); at !== -1; at = text.indexOf(needle, at + needle.length))
178
- count++;
179
- return count;
216
+ return needles.map((needle) => {
217
+ let count = 0;
218
+ for (let at = text.indexOf(needle); at !== -1; at = text.indexOf(needle, at + needle.length))
219
+ count++;
220
+ return count;
221
+ });
180
222
  }
181
223
  /**
182
224
  * Open an echo watch on a session (Issue #1573) — the live binding for
183
225
  * {@link DeliveryPorts.watchEcho}.
184
226
  *
185
- * Samples the terminal BEFORE the write, then `verify()` polls until the needle appears MORE
186
- * often than it did in that sample. New evidence, not mere presence.
227
+ * Samples the terminal BEFORE the write, then `verify()` polls until the needle — or a paste
228
+ * placard (Issue #1567, {@link PASTE_PLACARD_NEEDLES}) — appears MORE often than it did in that
229
+ * sample. New evidence, not mere presence.
187
230
  *
188
231
  * A session with no mirror has produced no output and therefore cannot echo anything, so its
189
232
  * watch verifies `false` rather than passing.
190
233
  *
191
- * Known residuals, all of which fail in the SAFE direction (a redelivery, never a dropped
192
- * message), and none of which are designed around here:
234
+ * Known residuals — these are why a negative is "could not confirm", not "not delivered". Issue
235
+ * #1584: they are also why a negative must NOT trigger a redelivery. Each recurs for the same
236
+ * message on every attempt, so holding-and-rewriting on one of them is a loop that cannot
237
+ * converge — #1583 saw a message re-injected dozens of times on exactly the second one. The
238
+ * caller now commits the delivery and reports it unverified instead. None is designed around
239
+ * here; #1578 tracks smarter verification:
193
240
  * - a harness on the ALTERNATE screen buffer has no scrollback, so a message longer than one
194
241
  * viewport can scroll its header out of reach and never confirm. The agy profile boots into
195
242
  * the alternate buffer and was not measurable here (unauthenticated).
196
243
  * - a very long write can evict the pre-write copy from the 1000-line mirror, so the count
197
244
  * comes back equal rather than greater and a genuine delivery reads as unconfirmed.
198
245
  * - an unconfirmed delivery re-reads and re-normalizes the retained buffer once per poll
199
- * while the `afx send` request waits. Bounded by the timeout, and off the happy path
200
- * entirely — the measured case confirms on the first read.
246
+ * while the `afx send` request waits. Bounded by the timeout (and by the delivery path's
247
+ * two windows, ~1.2 s total), and off the happy path entirely — the measured case confirms
248
+ * on the first read.
201
249
  */
202
250
  export async function watchEchoOnScreen(session, needle) {
203
251
  const screen = session.gateScreen;
204
252
  if (!screen)
205
253
  return { verify: () => Promise.resolve(false) };
206
- const before = await countEchoOnScreen(screen, needle);
254
+ // Issue #1567: a long frame is a bracketed paste, which the composer shows as a placard
255
+ // until it is submitted — so a new placard is as much evidence as a new header.
256
+ const needles = [needle, ...PASTE_PLACARD_NEEDLES];
257
+ const before = await countEchoOnScreen(screen, needles);
207
258
  return {
208
259
  verify: async () => {
209
260
  const deadline = Date.now() + ECHO_VERIFY_TIMEOUT_MS;
210
261
  for (;;) {
211
- if (await countEchoOnScreen(screen, needle) > before)
262
+ const after = await countEchoOnScreen(screen, needles);
263
+ if (after.some((n, i) => n > before[i]))
212
264
  return true;
213
265
  if (Date.now() >= deadline)
214
266
  return false;
@@ -239,21 +291,28 @@ export function makeDeliveryPorts(log) {
239
291
  getSessionForAgent: (ws, agent) => resolveLiveSessionForAgent(ws, agent),
240
292
  resolveProfile: (session) => resolveProfileForSession(session),
241
293
  classify: (session, profile) => classifyAgentScreen(session, profile),
294
+ // Issue #1664: the composer-stability signal that replaced whole-screen output quiescence.
295
+ // Same mirror as `classify`, read synchronously so the in-lock precheck can use it too.
296
+ composerFingerprint: (session, profile) => composerFingerprintForSession(session, profile),
242
297
  // Issue #1365: the write edge takes the session's per-terminal submission lock as a
243
298
  // LEAF inside the per-agent serializer, so a gated delivery and a concurrent
244
299
  // `--interrupt`/`--escape` can no longer interleave. The precheck is the delivery
245
300
  // module's, re-run inside that lock.
246
- writeMessage: (session, msg, noEnter, precheck) => submitMessagePaced(session, msg, noEnter, precheck),
301
+ writeMessage: (session, msg, noEnter, precheck, strategy) => submitMessagePaced(session, msg, noEnter, precheck, undefined, strategy),
247
302
  // Issue #1573: the only end-to-end evidence that the bytes reached the terminal — opened
248
- // before the write, consulted before the row is marked delivered.
303
+ // before the write. Issue #1584: consulted AFTER the row is marked delivered, because the
304
+ // commit is what makes a completed write un-repeatable; this only decides what we report.
249
305
  watchEcho: (session, needle) => watchEchoOnScreen(session, needle),
250
306
  broadcast: (frame) => broadcastDelivered(frame),
251
307
  onHeldStateChange: () => broadcastHeldStateChange(),
252
308
  onEscalation: (info) => broadcastEscalation(info),
253
309
  onLiveness: (info) => surfaceLiveness(info, log),
310
+ // Issue #1584: an unconfirmed delivery is committed, not retried, so this notice is the
311
+ // only human-facing trace for a cron/backstop send with no sender waiting on a response.
312
+ onUnverifiedDelivery: (info) => surfaceUnverifiedDelivery(info),
254
313
  escalateHeldToOwner: (info) => escalateHeldToOwner(info, log),
255
314
  clearHeldOwnerNotice: (ws, agent) => clearHeldOwnerNotice(ws, agent),
256
- log: (m) => log('INFO', m),
315
+ log: (m, level) => log(level ?? 'INFO', m),
257
316
  now: () => Date.now(),
258
317
  };
259
318
  }
@@ -263,13 +322,86 @@ const NOTICE_SENDER = 'af-mailbox';
263
322
  function noticeSupersedeKey(toAgent) {
264
323
  return `${NOTICE_SUPERSEDE_PREFIX}${toAgent}`;
265
324
  }
266
- /** Human-readable notice body (metadata only — never the starved messages' contents). */
267
- function formatOwnerNoticeBody(info) {
325
+ /**
326
+ * Human-readable notice body (metadata only — never the starved messages' contents).
327
+ *
328
+ * TWO notices, not one (Issue #1482). The old single body said "its composer never classifies
329
+ * as a ready prompt" and offered `afx interrupt` for every hold, which is wrong advice in the
330
+ * commonest case: when the detail is `user-text` a human is sitting at that composer with a
331
+ * draft, and interrupting them is the last thing the owner should do. The gate has always
332
+ * known which case it is; now the row carries it, so the notice can say it.
333
+ *
334
+ * The `streak` — how many consecutive gate checks re-confirmed the same verdict — is what
335
+ * separates "held ~7m" (which could be one unlucky sample) from "held ~7m, re-confirmed across
336
+ * 41 checks" (which cannot be).
337
+ *
338
+ * Exported for unit testing. This text is operator-facing INSTRUCTIONS during an incident, and
339
+ * it went un-asserted long enough to ship a remedy line naming `afx interrupt` at a composer a
340
+ * human was actively typing in. Prose that tells someone what to do to a live terminal is
341
+ * behaviour, and gets tested like behaviour.
342
+ */
343
+ export function formatOwnerNoticeBody(info) {
268
344
  const mins = Math.max(1, Math.round(info.ageMs / 60_000));
269
345
  const plural = info.heldCount === 1 ? 'message' : 'messages';
270
- return (`Mailbox delivery is STUCK for builder '${info.toAgent}' @ ${path.basename(info.workspacePath)}. ` +
271
- `${info.heldCount} ${plural} held ~${mins}m (reason: ${info.reason ?? 'held'}) — its composer never classifies as a ready prompt, ` +
272
- `so nothing is being delivered (cron nudges included). ` +
346
+ const confirmed = info.streak > 1 ? `, re-confirmed across ${info.streak} consecutive gate checks` : '';
347
+ const head = `Mailbox delivery is STUCK for builder '${info.toAgent}' @ ${path.basename(info.workspacePath)}. ` +
348
+ `${info.heldCount} ${plural} held ~${mins}m (${formatVerdict(info.reason, info.detail)}${confirmed}).`;
349
+ if (info.detail === 'user-text') {
350
+ // The SAFE hold: the classifier positively identified a draft or menu in the composer.
351
+ //
352
+ // This branch names NO command that touches the terminal, deliberately — not even hedged
353
+ // with "only if you are sure". An operator reading a notice headed "delivery is STUCK"
354
+ // treats the remedy line as the instruction, and the person at that composer is mid-thought
355
+ // by definition of this verdict. The #1583 loop was aggravated by exactly that: an operator
356
+ // followed an `afx interrupt` suggestion out of this notice. A hedge is not a safeguard
357
+ // when the surrounding text reads as an incident.
358
+ return (`${head} Its composer has been OCCUPIED that whole time — a draft or an open menu is on ` +
359
+ `the line, which usually means a human is working there, and delivery resumes by itself ` +
360
+ `the moment the line clears. ` +
361
+ `Remedy: usually none — let it clear. 'afx inbox' inspects the queue (metadata only, ` +
362
+ `never bodies) if you want to see what is waiting, and talking to whoever is at that ` +
363
+ `terminal is the only other thing worth doing.`);
364
+ }
365
+ if (!isUnverifiableVerdict(info.reason, info.detail) && info.detail) {
366
+ // The OTHER self-clearing holds — `recent-input` (Issue #1473) and `composer-redraw`
367
+ // (Issue #1664). Neither is a draft, so the `user-text` wording above would be wrong; but
368
+ // both clear by themselves, so the defect wording below is worse than wrong — it tells the
369
+ // owner the mail will NEVER deliver and hands them `afx interrupt`, which kills the turn of
370
+ // an agent that is merely working, or wipes the line of someone who is merely typing.
371
+ //
372
+ // This branch used to not exist: the test was `if (info.detail || …)`, so every detail but
373
+ // `user-text` fell into the defect arm. That was already wrong for `recent-input` before
374
+ // this issue added a second self-clearing value to the same arm (CMAP round 3 — codex). The
375
+ // routing question is exactly the one `isUnverifiableVerdict` answers, so it is asked here
376
+ // rather than restated as a list of names that the next detail will silently fall out of.
377
+ //
378
+ // Like the `user-text` branch, this one deliberately names NO command that touches the
379
+ // terminal. A notice headed "delivery is STUCK" reads as an incident, and an operator takes
380
+ // its remedy line as the instruction (the #1583 loop was aggravated by exactly that).
381
+ const because = info.detail === 'recent-input'
382
+ ? `the terminal keeps RECEIVING INPUT — keystrokes, clicks, or an interrupt/escape write ` +
383
+ `— and delivery pauses for a fraction of a second after each one`
384
+ : `the composer keeps being REPAINTED — a turn ending, a rotating placeholder, a resize ` +
385
+ `— and delivery pauses for a fraction of a second after each redraw`;
386
+ return (`${head} Its composer is EMPTY and the gate can read it fine: ${because}. This clears by ` +
387
+ `itself, so a hold this old means the activity has been essentially continuous — someone ` +
388
+ `typing steadily, or something emitting on every repaint. ` +
389
+ `Remedy: usually none — delivery resumes on its own. 'afx inbox' inspects the queue ` +
390
+ `(metadata only, never bodies); if it truly never clears, what to look at is whatever ` +
391
+ `keeps touching that terminal, not the composer.`);
392
+ }
393
+ if (isUnverifiableVerdict(info.reason, info.detail)) {
394
+ // The DEFECT class: the gate could not verify the composer at all, so nothing will clear
395
+ // this without intervention.
396
+ return (`${head} The render gate CANNOT VERIFY that composer — this is not a busy human, it is a ` +
397
+ `classifier that cannot find a bounded composer region, so the mail will never deliver on ` +
398
+ `its own. Usual causes: a drifted TUI profile, a torn/mid-repaint frame, or Tower's ` +
399
+ `terminal dimensions diverging from the real PTY (Issue #1482). ` +
400
+ `Remedy: 'afx inbox' to inspect; resizing the viewer forces a repaint; ` +
401
+ `'afx interrupt ${info.toAgent}' clears a stuck composer.`);
402
+ }
403
+ return (`${head} Its composer never classifies as a ready prompt, so nothing is being delivered ` +
404
+ `(cron nudges included). ` +
273
405
  `Remedy: run 'afx inbox' to inspect; 'afx interrupt ${info.toAgent}' clears a stuck composer.`);
274
406
  }
275
407
  /**
@@ -312,7 +444,8 @@ function escalateHeldToOwner(info, log) {
312
444
  // Deliver the notice promptly through the SAME gate (it holds if the architect is busy).
313
445
  void ensureDrainer().scheduleDrain(owner.workspacePath, owner.agent);
314
446
  log('WARN', `[mailbox] STARVATION notice → ${owner.agent} about ${info.toAgent} @ ${path.basename(info.workspacePath)} ` +
315
- `(${info.heldCount} held ~${Math.round(info.ageMs / 1000)}s, reason ${info.reason ?? 'held'})`);
447
+ `(${info.heldCount} held ~${Math.round(info.ageMs / 1000)}s, ${formatVerdict(info.reason, info.detail)}` +
448
+ `${info.streak > 1 ? `, streak ${info.streak}` : ''})`);
316
449
  return true;
317
450
  }
318
451
  /**
@@ -351,6 +484,10 @@ function broadcastEscalation(info) {
351
484
  mailboxId: info.mailboxId,
352
485
  ageMs: info.ageMs,
353
486
  reason: info.reason,
487
+ // Issue #1482: a client showing only `busy` cannot tell an occupied composer from one the
488
+ // gate could not read. The wire is additive — an older client that ignores the field is
489
+ // unaffected — but the TYPE is required, so this producer cannot forget it.
490
+ detail: info.detail,
354
491
  };
355
492
  mailboxBroadcaster?.({
356
493
  type: 'mailbox-escalation',
@@ -384,6 +521,36 @@ function surfaceLiveness(info, log) {
384
521
  workspace: info.workspacePath,
385
522
  });
386
523
  }
524
+ /**
525
+ * Surface an unconfirmed delivery (Issue #1584) on the generic `notification` SSE channel that
526
+ * {@link surfaceLiveness} already uses — human title/body, no message body.
527
+ *
528
+ * Deliberately NOT the `mailbox-escalation` event: that one means "held past the escalation
529
+ * age", and saying that about a row we just delivered would be false. The wording here states
530
+ * exactly what is and is not known — the bytes went out, the screen never showed them, and it
531
+ * will not be sent again.
532
+ */
533
+ function surfaceUnverifiedDelivery(info) {
534
+ const where = `${info.toAgent} @ ${path.basename(info.workspacePath)}`;
535
+ // Issue #1473: the body branches on the cause. The no-echo wording asserts the header never
536
+ // appeared, and saying that about a delivery whose header DID appear — and whose tail a human
537
+ // keystroke truncated or submitted early — points the reader at the wrong thing entirely.
538
+ const raced = info.cause === 'input-raced';
539
+ const what = raced
540
+ ? `every byte was accepted, but the terminal received input while the message was going out, so ` +
541
+ `the body may have been truncated or submitted early`
542
+ : `every byte was accepted, but its header never appeared on that screen`;
543
+ mailboxBroadcaster?.({
544
+ type: 'notification',
545
+ title: raced
546
+ ? 'Mailbox: delivered, but raced by terminal input'
547
+ : 'Mailbox: delivered but not confirmed on screen',
548
+ body: `${where} — the message was written to terminal ${info.terminalId.slice(0, 8)}… and ${what}. It is ` +
549
+ `recorded as delivered and will NOT be sent again (mailbox id ${info.mailboxId.slice(0, 8)}…). ` +
550
+ `Check the agent's transcript.`,
551
+ workspace: info.workspacePath,
552
+ });
553
+ }
387
554
  // The single backstop drainer instance (replaces the retired SendBuffer). Created
388
555
  // lazily so it picks up the configured retention window (below) at first use.
389
556
  let drainer;
@@ -1 +1 @@
1
- {"version":3,"file":"mailbox-wiring.js","sourceRoot":"","sources":["../../../src/agent-farm/servers/mailbox-wiring.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,uBAAuB,EAAmB,MAAM,+BAA+B,CAAC;AAEzF,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AACjF,OAAO,EAAE,gBAAgB,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAC/F,OAAO,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,EAAE,WAAW,EAAE,cAAc,EAAsC,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,cAAc,E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AG,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;IAC7D,uBAAuB,CAAC,GAAG,CAAC,YAAY,EAAE,qBAAqB,CAAC,CAAC;IACjE,qBAAqB,GAAG,SAAS,CAAC;AACpC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,mBAAmB,CAAC,GAAU;IAC5C,aAAa,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,GAAG,CAAC,EAAE,WAAW,EAAE,CAAC,CAAC;IAC7D,wBAAwB,EAAE,CAAC;IAC3B,GAAG,CAAC,MAAM,EAAE,oCAAoC,CAAC,CAAC;AACpD,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB;IAChC,0BAA0B,EAAE,CAAC;IAC7B,OAAO,EAAE,IAAI,EAAE,CAAC;AAClB,CAAC;AAED,4EAA4E;AAC5E,MAAM,UAAU,iBAAiB;IAC/B,OAAO,aAAa,EAAE,CAAC;AACzB,CAAC"}
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Paced message writing for PTY sessions (Bugfix #584).
2
+ * Paced message writing for PTY sessions (Bugfix #584, Issue #1567).
3
3
  *
4
4
  * Extracted to a shared module to avoid circular imports between
5
5
  * tower-routes.ts and tower-cron.ts.
@@ -16,6 +16,111 @@ export interface WritableSession {
16
16
  */
17
17
  write(data: string): boolean;
18
18
  }
19
+ /**
20
+ * The session shape {@link submitMessagePaced} needs, over and above {@link WritableSession}
21
+ * (Issue #1473).
22
+ *
23
+ * Kept SEPARATE from `WritableSession` rather than widening it: the escape/message helpers and
24
+ * every fake behind them need only the one-arg `write`, and requiring an id + counter of them
25
+ * would be churn for a field they never read.
26
+ *
27
+ * `write` takes the origin here because the delivery's own bytes must NOT move the gate's input
28
+ * signal — the gate has just authorised precisely these bytes, and counting them would make
29
+ * every delivery block the one after it. `'delivery'` is the only value this module ever passes,
30
+ * so that is the only one it names; the full vocabulary is `WriteOrigin` in `pty-session.ts`,
31
+ * which this module deliberately does not import (a one-arg `write` is still assignable here,
32
+ * which is what keeps the delivery module's structural fakes working).
33
+ */
34
+ export interface PacedWriteSession {
35
+ /**
36
+ * The per-terminal submission lock's key (Issue #1365). A double MUST supply a real, distinct
37
+ * one — see the throw in {@link submitMessagePaced}.
38
+ */
39
+ readonly id: string;
40
+ /**
41
+ * The session's monotone input-change counter (Issue #1473). Sampled either side of the paced
42
+ * write so a human keystroke that landed BETWEEN the first byte and the trailing Enter can be
43
+ * REPORTED. It cannot be prevented — the bytes are already going out — so this is a reporting
44
+ * signal, not a gate.
45
+ */
46
+ readonly inputSeq: number;
47
+ write(data: string, origin?: 'delivery'): boolean;
48
+ }
49
+ /**
50
+ * Issue #1567 — why long frames are no longer handed to the PTY in one write.
51
+ *
52
+ * The kernel splits a large master-side write at the slave's input-queue high-water mark
53
+ * (TTYHOG − 2 = 1022 bytes on macOS). The receiving TUI reads the first ~1 KB as one chunk,
54
+ * its paste heuristic classifies that chunk as a paste and DISCARDS it, then types the
55
+ * remainder and the Enter normally — so the agent saw a mid-sentence tail-only fragment
56
+ * while every `write()` reported success. Measured on claude 2.1.263 (harness in
57
+ * `scripts/bugfix-1567-head-loss-harness.mts`, evidence in `codev/evidence/1567-head-loss/`):
58
+ * a 1,172-byte 3-line frame lost its head 14/20 times on an IDLE composer; a 1,000-byte frame
59
+ * never did. Two independent changes each measured 0 losses, and both are applied:
60
+ *
61
+ * 1. **No single write exceeds {@link PASTE_CHUNK_BYTES}** — comfortably under the queue
62
+ * limit, so the kernel never splits a read and the reader drains between writes.
63
+ * 2. **Long frames travel as ONE explicit bracketed paste** (`ESC[200~` … `ESC[201~`), so the
64
+ * TUI's paste heuristic never runs on chunk boundaries and newlines inside the body can
65
+ * never be read as Enter. The Enter is a separate write OUTSIDE the bracket, after a
66
+ * settle. Inside the bracket newlines travel as `\r`, which is what a terminal emulator
67
+ * emits on paste (xterm.js) and what claude's composer expects there — the same convention
68
+ * `apps/vscode/src/review-queue/queue.ts` already uses to type a review into a builder.
69
+ *
70
+ * This replaces the #584-era per-line pacing for frames of {@link BRACKET_MIN_LINES} lines or
71
+ * more, which was tuned against an older TUI's heuristic. Short frames keep the pre-existing
72
+ * single write + delayed Enter, byte for byte, so `--raw` slash commands and short sends are
73
+ * untouched.
74
+ */
75
+ export declare const PASTE_CHUNK_BYTES = 512;
76
+ /** Gap between consecutive chunk writes; the reader drains a chunk in well under this. */
77
+ export declare const PASTE_CHUNK_GAP_MS = 5;
78
+ /** Settle between the paste's closing marker and the Enter that submits it (measured: 0/29 losses). */
79
+ export declare const PASTE_ENTER_DELAY_MS = 80;
80
+ /**
81
+ * Frames LONGER than this many bytes, or of {@link BRACKET_MIN_LINES} lines or more, are
82
+ * bracketed and chunked. Well under the 1,022-byte queue limit where the loss starts: the
83
+ * field's smallest confirmed truncations were ~500-byte bodies, and a bracketed short paste
84
+ * costs nothing on the measured harnesses.
85
+ */
86
+ export declare const BRACKET_MIN_BYTES = 256;
87
+ /** The #584 threshold, kept: any frame of this many lines or more is never typed line by line. */
88
+ export declare const BRACKET_MIN_LINES = 4;
89
+ export declare const PASTE_BEGIN = "\u001B[200~";
90
+ export declare const PASTE_END = "\u001B[201~";
91
+ /**
92
+ * Per-harness write strategy (Issue #1567). Bracketed paste is measured safe on claude
93
+ * (2.1.263) and codex (0.146.0); a harness that has not been measured can opt out and gets the
94
+ * pre-#1567 per-line semantics, still chunked so no write exceeds the PTY input queue.
95
+ */
96
+ export interface WriteStrategy {
97
+ /** Wrap long frames in bracketed-paste markers (with `\n` → `\r` inside). */
98
+ bracketedPaste: boolean;
99
+ }
100
+ export declare const BRACKETED_PASTE: WriteStrategy;
101
+ export declare const PLAIN_CHUNKED: WriteStrategy;
102
+ /**
103
+ * The write strategy for a gate profile's `app`. agy is the one modeled harness whose paste
104
+ * handling was not measurable (unauthenticated), so it keeps the per-line shape; anything
105
+ * else is bracketed. Unknown apps never reach the write edge (the gate holds `no-profile`).
106
+ */
107
+ export declare function writeStrategyForApp(app: string | undefined): WriteStrategy;
108
+ /** Does this frame take the bracketed/chunked path rather than the single short write? */
109
+ export declare function isLongFrame(message: string): boolean;
110
+ /**
111
+ * Split `text` into pieces of at most `max` bytes, never inside a UTF-8 sequence (a split
112
+ * continuation byte would reach the TUI as two invalid characters).
113
+ */
114
+ export declare function chunkForPty(text: string, max?: number): string[];
115
+ /**
116
+ * The pieces of a long frame, in write order, for a strategy. Bracketed: the body (newlines
117
+ * as `\r`) chunked, with the opening marker on the first piece and the closing marker on the
118
+ * last — the markers are never split across writes, so no chunk boundary can land inside an
119
+ * escape sequence, and every piece INCLUDING its marker stays within {@link PASTE_CHUNK_BYTES}.
120
+ * Plain: one piece per line (`\n` kept, as #584 wrote it), with any line over
121
+ * the chunk size split further.
122
+ */
123
+ export declare function framePieces(message: string, strategy: WriteStrategy): string[];
19
124
  /** ESC keystroke — ends the agent's current turn (Spec 1273). */
20
125
  export declare const ESC = "\u001B";
21
126
  /**
@@ -41,27 +146,51 @@ export declare const ESCAPE_ENTER_DELAY_MS = 50;
41
146
  */
42
147
  export declare function writeEscapeToSession(session: WritableSession, noEnter: boolean): number;
43
148
  /**
44
- * Write a message to a PTY session, pacing multi-line output to prevent
45
- * the terminal from treating it as a paste (Bugfix #584).
149
+ * Write a message to a PTY session (Bugfix #584, Issue #1567).
150
+ *
151
+ * Short frames (under {@link BRACKET_MIN_LINES} lines AND at most {@link BRACKET_MIN_BYTES}
152
+ * bytes): a single write, then Enter after 50 ms — unchanged since #584.
46
153
  *
47
- * Short messages (≤3 lines): single write + delayed Enter.
48
- * Long messages (>3 lines): line-by-line writes with 10ms gaps, then Enter
49
- * after all lines are delivered.
154
+ * Long frames: {@link framePieces} written {@link PASTE_CHUNK_GAP_MS} apart (bracketed by
155
+ * default; see {@link WriteStrategy}), then Enter as its own write
156
+ * {@link PASTE_ENTER_DELAY_MS} after the last piece. The Enter is always outside the paste
157
+ * bracket, so a TUI that collapses the paste into a placard still submits it.
50
158
  *
51
159
  * @param delayOffset ms offset for all scheduled writes (used to serialize
52
160
  * multiple messages to the same session without interleaving)
53
161
  * @returns ms timestamp (from call time) when all writes complete
54
162
  */
55
- export declare function writeMessageToSession(session: WritableSession, message: string, noEnter: boolean, delayOffset?: number): number;
163
+ export declare function writeMessageToSession(session: WritableSession, message: string, noEnter: boolean, delayOffset?: number, strategy?: WriteStrategy): number;
56
164
  /**
57
165
  * Outcome of a {@link submitMessagePaced} attempt. Generic in the caller's own abort
58
166
  * vocabulary so this module stays free of mailbox concepts — the delivery layer
59
167
  * instantiates `A` with its hold reasons.
60
168
  */
61
169
  export type PacedSubmitResult<A> =
62
- /** The whole submit — text and, unless `noEnter`, the trailing Enter — reached the PTY. */
170
+ /**
171
+ * The whole submit — text and, unless `noEnter`, the trailing Enter — reached the PTY.
172
+ *
173
+ * `racedByInput` (Issue #1473) means the terminal's input counter moved between the first
174
+ * byte and the last: something typed into the terminal while our body was going out, so it
175
+ * may have been TRUNCATED (`^U`/`^W`/`^C`) or SUBMITTED EARLY (their Enter carrying our
176
+ * partial text). It is a FLAG, not a hold — the bytes are already on the wire, and re-writing
177
+ * a message that landed is the #1584 re-injection failure this module is forbidden to
178
+ * reproduce.
179
+ *
180
+ * The SHAPE of the damage now depends on the strategy (Issue #1567). On the bracketed path a
181
+ * `\r` inside `ESC[200~ … ESC[201~` is literal, so a human's Enter cannot submit early — it is
182
+ * absorbed INTO our pasted body instead. The flag is right either way; only the operator's
183
+ * "what do I look for" answer differs, which is why the sender-facing warning names all three
184
+ * outcomes. #1567 also shrank the window it covers, because the pacing is now per CHUNK
185
+ * rather than per line: a 100-line frame took `99×10+80` ≈ 1,070 ms to write, and bracketed
186
+ * takes `(chunks−1)×5+80` — ~100 ms for a 2.5 KB body.
187
+ *
188
+ * OMITTED when false, never `racedByInput: false`, so exact `{ status: 'written' }` equality
189
+ * assertions keep meaning what they meant.
190
+ */
63
191
  {
64
192
  status: 'written';
193
+ racedByInput?: boolean;
65
194
  }
66
195
  /** #1198: a scheduled write was dropped mid-pace (the shellper socket died). */
67
196
  | {
@@ -110,7 +239,5 @@ export type PacedSubmitResult<A> =
110
239
  * `submitToSession` schedules its own equal-offset sleep, so the Enter still executes
111
240
  * first — which is what makes the per-agent serializer's completion-chaining real.
112
241
  */
113
- export declare function submitMessagePaced<A>(session: WritableSession & {
114
- id: string;
115
- }, message: string, noEnter: boolean, precheck: () => A | null, clock?: SubmitClock): Promise<PacedSubmitResult<A>>;
242
+ export declare function submitMessagePaced<A>(session: PacedWriteSession, message: string, noEnter: boolean, precheck: () => A | null, clock?: SubmitClock, strategy?: WriteStrategy): Promise<PacedSubmitResult<A>>;
116
243
  //# sourceMappingURL=message-write.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"message-write.d.ts","sourceRoot":"","sources":["../../../src/agent-farm/servers/message-write.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAqC,KAAK,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAE1F,0EAA0E;AAC1E,MAAM,WAAW,eAAe;IAC9B;;;;;;OAMG;IACH,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;CAC9B;AAUD,iEAAiE;AACjE,eAAO,MAAM,GAAG,WAAS,CAAC;AAE1B;;;GAGG;AACH,eAAO,MAAM,qBAAqB,KAAwB,CAAC;AAE3D;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAKvF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CACnC,OAAO,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,WAAW,SAAI,GAC3E,MAAM,CAqCR;AAED;;;;GAIG;AACH,MAAM,MAAM,iBAAiB,CAAC,CAAC;AAC7B,2FAA2F;AACzF;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE;AACvB,gFAAgF;GAC9E;IAAE,MAAM,EAAE,SAAS,CAAA;CAAE;AACv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