@scotthuang/agent-knock-knock 0.13.2 → 0.13.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 (278) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +27 -6
  3. package/dist/src/callback-outbox-policy.js +27 -6
  4. package/dist/src/callback-outbox-policy.js.map +1 -1
  5. package/dist/src/callback-outbox-service.d.ts +4 -30
  6. package/dist/src/callback-outbox-service.js +21 -154
  7. package/dist/src/callback-outbox-service.js.map +1 -1
  8. package/dist/src/callback-outbox-settlement.js +13 -8
  9. package/dist/src/callback-outbox-settlement.js.map +1 -1
  10. package/dist/src/callback-route-service.d.ts +46 -0
  11. package/dist/src/callback-route-service.js +155 -0
  12. package/dist/src/callback-route-service.js.map +1 -0
  13. package/dist/src/claude-terminal-agent-adapter.js +4 -0
  14. package/dist/src/claude-terminal-agent-adapter.js.map +1 -1
  15. package/dist/src/cli-core.js +9 -1
  16. package/dist/src/cli-core.js.map +1 -1
  17. package/dist/src/codex-process-incarnation.d.ts +8 -0
  18. package/dist/src/codex-process-incarnation.js +36 -0
  19. package/dist/src/codex-process-incarnation.js.map +1 -0
  20. package/dist/src/codex-terminal-agent-adapter.js +4 -0
  21. package/dist/src/codex-terminal-agent-adapter.js.map +1 -1
  22. package/dist/src/deferred-foreground-conflict-policy.d.ts +22 -0
  23. package/dist/src/deferred-foreground-conflict-policy.js +52 -0
  24. package/dist/src/deferred-foreground-conflict-policy.js.map +1 -0
  25. package/dist/src/durable-notification-kernel.d.ts +94 -0
  26. package/dist/src/durable-notification-kernel.js +68 -0
  27. package/dist/src/durable-notification-kernel.js.map +1 -0
  28. package/dist/src/herdr-socket-transport.d.ts +43 -0
  29. package/dist/src/herdr-socket-transport.js +170 -0
  30. package/dist/src/herdr-socket-transport.js.map +1 -0
  31. package/dist/src/herdr-terminal-control-provider.d.ts +2 -45
  32. package/dist/src/herdr-terminal-control-provider.js +8 -173
  33. package/dist/src/herdr-terminal-control-provider.js.map +1 -1
  34. package/dist/src/host-adapter-capabilities.d.ts +35 -0
  35. package/dist/src/host-adapter-capabilities.js +146 -0
  36. package/dist/src/host-adapter-capabilities.js.map +1 -0
  37. package/dist/src/host-adapter.d.ts +9 -3
  38. package/dist/src/host-adapter.js +33 -9
  39. package/dist/src/host-adapter.js.map +1 -1
  40. package/dist/src/host-bridge-tools.d.ts +3 -4
  41. package/dist/src/host-bridge-tools.js +49 -92
  42. package/dist/src/host-bridge-tools.js.map +1 -1
  43. package/dist/src/host-bridge.js +5 -5
  44. package/dist/src/host-bridge.js.map +1 -1
  45. package/dist/src/host-monitor-reconciliation.d.ts +6 -0
  46. package/dist/src/host-monitor-reconciliation.js +96 -0
  47. package/dist/src/host-monitor-reconciliation.js.map +1 -0
  48. package/dist/src/managed-session.js +2 -18
  49. package/dist/src/managed-session.js.map +1 -1
  50. package/dist/src/native-thread-lifecycle-cli-adapter.d.ts +13 -0
  51. package/dist/src/native-thread-lifecycle-cli-adapter.js +635 -3
  52. package/dist/src/native-thread-lifecycle-cli-adapter.js.map +1 -1
  53. package/dist/src/openclaw-list-projection.d.ts +2 -0
  54. package/dist/src/openclaw-list-projection.js +3 -0
  55. package/dist/src/openclaw-list-projection.js.map +1 -0
  56. package/dist/src/openclaw-model-facing-field-policy.d.ts +2 -0
  57. package/dist/src/openclaw-model-facing-field-policy.js +3 -0
  58. package/dist/src/openclaw-model-facing-field-policy.js.map +1 -0
  59. package/dist/src/openclaw-plugin-command-adapter.d.ts +6 -29
  60. package/dist/src/openclaw-plugin-command-adapter.js +7 -2370
  61. package/dist/src/openclaw-plugin-command-adapter.js.map +1 -1
  62. package/dist/src/openclaw-plugin-helpers.d.ts +2 -121
  63. package/dist/src/openclaw-plugin-helpers.js +2 -1164
  64. package/dist/src/openclaw-plugin-helpers.js.map +1 -1
  65. package/dist/src/openclaw-plugin-schemas.d.ts +2 -510
  66. package/dist/src/openclaw-plugin-schemas.js +2 -519
  67. package/dist/src/openclaw-plugin-schemas.js.map +1 -1
  68. package/dist/src/openclaw-plugin-supervisor.d.ts +4 -5
  69. package/dist/src/openclaw-plugin-supervisor.js +5 -94
  70. package/dist/src/openclaw-plugin-supervisor.js.map +1 -1
  71. package/dist/src/openclaw-plugin-value-helpers.d.ts +2 -0
  72. package/dist/src/openclaw-plugin-value-helpers.js +3 -0
  73. package/dist/src/openclaw-plugin-value-helpers.js.map +1 -0
  74. package/dist/src/openclaw-private-authority-offers.d.ts +4 -39
  75. package/dist/src/openclaw-private-authority-offers.js +3 -258
  76. package/dist/src/openclaw-private-authority-offers.js.map +1 -1
  77. package/dist/src/semantic-private-authority-offers.d.ts +41 -0
  78. package/dist/src/semantic-private-authority-offers.js +261 -0
  79. package/dist/src/semantic-private-authority-offers.js.map +1 -0
  80. package/dist/src/semantic-tool-arguments.d.ts +9 -0
  81. package/dist/src/semantic-tool-arguments.js +64 -0
  82. package/dist/src/semantic-tool-arguments.js.map +1 -0
  83. package/dist/src/semantic-tool-catalog.d.ts +48 -0
  84. package/dist/src/semantic-tool-catalog.js +105 -0
  85. package/dist/src/semantic-tool-catalog.js.map +1 -0
  86. package/dist/src/semantic-tool-command-helpers.d.ts +145 -0
  87. package/dist/src/semantic-tool-command-helpers.js +1272 -0
  88. package/dist/src/semantic-tool-command-helpers.js.map +1 -0
  89. package/dist/src/semantic-tool-list-projection.d.ts +10 -0
  90. package/dist/src/semantic-tool-list-projection.js +497 -0
  91. package/dist/src/semantic-tool-list-projection.js.map +1 -0
  92. package/dist/src/semantic-tool-model-facing-field-policy.d.ts +3 -0
  93. package/dist/src/semantic-tool-model-facing-field-policy.js +66 -0
  94. package/dist/src/semantic-tool-model-facing-field-policy.js.map +1 -0
  95. package/dist/src/semantic-tool-presentation.d.ts +37 -0
  96. package/dist/src/semantic-tool-presentation.js +680 -0
  97. package/dist/src/semantic-tool-presentation.js.map +1 -0
  98. package/dist/src/semantic-tool-private-authority.d.ts +39 -0
  99. package/dist/src/semantic-tool-private-authority.js +602 -0
  100. package/dist/src/semantic-tool-private-authority.js.map +1 -0
  101. package/dist/src/semantic-tool-relay.d.ts +16 -0
  102. package/dist/src/semantic-tool-relay.js +175 -0
  103. package/dist/src/semantic-tool-relay.js.map +1 -0
  104. package/dist/src/semantic-tool-runtime.d.ts +10 -0
  105. package/dist/src/semantic-tool-runtime.js +1157 -0
  106. package/dist/src/semantic-tool-runtime.js.map +1 -0
  107. package/dist/src/semantic-tool-schemas.d.ts +563 -0
  108. package/dist/src/semantic-tool-schemas.js +573 -0
  109. package/dist/src/semantic-tool-schemas.js.map +1 -0
  110. package/dist/src/semantic-tool-value-helpers.d.ts +5 -0
  111. package/dist/src/semantic-tool-value-helpers.js +27 -0
  112. package/dist/src/semantic-tool-value-helpers.js.map +1 -0
  113. package/dist/src/store-event-presentation.d.ts +17 -0
  114. package/dist/src/store-event-presentation.js +33 -0
  115. package/dist/src/store-event-presentation.js.map +1 -0
  116. package/dist/src/store.d.ts +3 -16
  117. package/dist/src/store.js +2 -30
  118. package/dist/src/store.js.map +1 -1
  119. package/dist/src/terminal-action-projection.d.ts +3 -17
  120. package/dist/src/terminal-action-projection.js +13 -41
  121. package/dist/src/terminal-action-projection.js.map +1 -1
  122. package/dist/src/terminal-agent-adapter.d.ts +7 -0
  123. package/dist/src/terminal-agent-adapter.js +8 -0
  124. package/dist/src/terminal-agent-adapter.js.map +1 -1
  125. package/dist/src/terminal-agent-bridge.d.ts +35 -332
  126. package/dist/src/terminal-agent-bridge.js +293 -2798
  127. package/dist/src/terminal-agent-bridge.js.map +1 -1
  128. package/dist/src/terminal-approval-cli-adapter.d.ts +17 -0
  129. package/dist/src/terminal-approval-cli-adapter.js +921 -0
  130. package/dist/src/terminal-approval-cli-adapter.js.map +1 -0
  131. package/dist/src/terminal-command-cli-adapter.d.ts +2 -429
  132. package/dist/src/terminal-command-cli-adapter.js +344 -6061
  133. package/dist/src/terminal-command-cli-adapter.js.map +1 -1
  134. package/dist/src/terminal-command-cli-ports.d.ts +443 -0
  135. package/dist/src/terminal-command-cli-ports.js +2 -0
  136. package/dist/src/terminal-command-cli-ports.js.map +1 -0
  137. package/dist/src/terminal-command-dispatch-preparation.d.ts +81 -0
  138. package/dist/src/terminal-command-dispatch-preparation.js +209 -0
  139. package/dist/src/terminal-command-dispatch-preparation.js.map +1 -0
  140. package/dist/src/terminal-command-dispatch-transport.d.ts +35 -0
  141. package/dist/src/terminal-command-dispatch-transport.js +859 -0
  142. package/dist/src/terminal-command-dispatch-transport.js.map +1 -0
  143. package/dist/src/terminal-command-foreground-proof.d.ts +32 -0
  144. package/dist/src/terminal-command-foreground-proof.js +72 -0
  145. package/dist/src/terminal-command-foreground-proof.js.map +1 -0
  146. package/dist/src/terminal-command-send-preflight.d.ts +41 -0
  147. package/dist/src/terminal-command-send-preflight.js +86 -0
  148. package/dist/src/terminal-command-send-preflight.js.map +1 -0
  149. package/dist/src/terminal-composer-classifier.d.ts +55 -0
  150. package/dist/src/terminal-composer-classifier.js +638 -0
  151. package/dist/src/terminal-composer-classifier.js.map +1 -0
  152. package/dist/src/terminal-control-ref.d.ts +23 -0
  153. package/dist/src/terminal-control-ref.js +32 -0
  154. package/dist/src/terminal-control-ref.js.map +1 -1
  155. package/dist/src/terminal-dispatch-recovery-authority.d.ts +56 -0
  156. package/dist/src/terminal-dispatch-recovery-authority.js +251 -0
  157. package/dist/src/terminal-dispatch-recovery-authority.js.map +1 -0
  158. package/dist/src/terminal-dispatch-recovery-cli-adapter.d.ts +1 -9
  159. package/dist/src/terminal-dispatch-recovery-cli-adapter.js +5 -240
  160. package/dist/src/terminal-dispatch-recovery-cli-adapter.js.map +1 -1
  161. package/dist/src/terminal-handoff-cli-adapter.d.ts +1 -11
  162. package/dist/src/terminal-handoff-cli-adapter.js +2 -39
  163. package/dist/src/terminal-handoff-cli-adapter.js.map +1 -1
  164. package/dist/src/terminal-human-explicit-send-cli-adapter.d.ts +25 -0
  165. package/dist/src/terminal-human-explicit-send-cli-adapter.js +903 -0
  166. package/dist/src/terminal-human-explicit-send-cli-adapter.js.map +1 -0
  167. package/dist/src/terminal-identity-authority-cli-adapter.d.ts +1 -6
  168. package/dist/src/terminal-identity-authority-cli-adapter.js +3 -33
  169. package/dist/src/terminal-identity-authority-cli-adapter.js.map +1 -1
  170. package/dist/src/terminal-interaction-cli-adapter.js +209 -210
  171. package/dist/src/terminal-interaction-cli-adapter.js.map +1 -1
  172. package/dist/src/terminal-interaction-core.d.ts +0 -2
  173. package/dist/src/terminal-interaction-core.js +4 -3
  174. package/dist/src/terminal-interaction-core.js.map +1 -1
  175. package/dist/src/terminal-interaction-protocol.d.ts +21 -0
  176. package/dist/src/terminal-interaction-protocol.js +74 -0
  177. package/dist/src/terminal-interaction-protocol.js.map +1 -1
  178. package/dist/src/terminal-interaction-response-bridge.d.ts +126 -0
  179. package/dist/src/terminal-interaction-response-bridge.js +579 -0
  180. package/dist/src/terminal-interaction-response-bridge.js.map +1 -0
  181. package/dist/src/terminal-interaction-response-transaction.d.ts +44 -0
  182. package/dist/src/terminal-interaction-response-transaction.js +56 -0
  183. package/dist/src/terminal-interaction-response-transaction.js.map +1 -0
  184. package/dist/src/terminal-list-action-policy.d.ts +43 -0
  185. package/dist/src/terminal-list-action-policy.js +164 -0
  186. package/dist/src/terminal-list-action-policy.js.map +1 -0
  187. package/dist/src/terminal-list-cli-adapter.d.ts +6 -36
  188. package/dist/src/terminal-list-cli-adapter.js +314 -1711
  189. package/dist/src/terminal-list-cli-adapter.js.map +1 -1
  190. package/dist/src/terminal-list-facts.d.ts +129 -0
  191. package/dist/src/terminal-list-facts.js +179 -0
  192. package/dist/src/terminal-list-facts.js.map +1 -0
  193. package/dist/src/terminal-list-inventory.d.ts +59 -0
  194. package/dist/src/terminal-list-inventory.js +194 -0
  195. package/dist/src/terminal-list-inventory.js.map +1 -0
  196. package/dist/src/terminal-list-ownership-service.d.ts +118 -0
  197. package/dist/src/terminal-list-ownership-service.js +1003 -0
  198. package/dist/src/terminal-list-ownership-service.js.map +1 -0
  199. package/dist/src/terminal-list-projection-service.d.ts +49 -0
  200. package/dist/src/terminal-list-projection-service.js +407 -0
  201. package/dist/src/terminal-list-projection-service.js.map +1 -0
  202. package/dist/src/terminal-list-renderer.d.ts +12 -11
  203. package/dist/src/terminal-list-renderer.js +237 -104
  204. package/dist/src/terminal-list-renderer.js.map +1 -1
  205. package/dist/src/terminal-managed-send-cli-adapter.d.ts +33 -0
  206. package/dist/src/terminal-managed-send-cli-adapter.js +994 -0
  207. package/dist/src/terminal-managed-send-cli-adapter.js.map +1 -0
  208. package/dist/src/terminal-managed-turn-list-action-policy.d.ts +47 -0
  209. package/dist/src/terminal-managed-turn-list-action-policy.js +64 -0
  210. package/dist/src/terminal-managed-turn-list-action-policy.js.map +1 -0
  211. package/dist/src/terminal-model-control-action-policy.d.ts +60 -0
  212. package/dist/src/terminal-model-control-action-policy.js +96 -0
  213. package/dist/src/terminal-model-control-action-policy.js.map +1 -0
  214. package/dist/src/terminal-model-control-availability.d.ts +68 -0
  215. package/dist/src/terminal-model-control-availability.js +157 -0
  216. package/dist/src/terminal-model-control-availability.js.map +1 -0
  217. package/dist/src/terminal-model-control-bridge.d.ts +48 -0
  218. package/dist/src/terminal-model-control-bridge.js +259 -0
  219. package/dist/src/terminal-model-control-bridge.js.map +1 -0
  220. package/dist/src/terminal-model-control-profile.d.ts +55 -0
  221. package/dist/src/terminal-model-control-profile.js +137 -0
  222. package/dist/src/terminal-model-control-profile.js.map +1 -0
  223. package/dist/src/terminal-model-control-subject.d.ts +34 -0
  224. package/dist/src/terminal-model-control-subject.js +58 -0
  225. package/dist/src/terminal-model-control-subject.js.map +1 -0
  226. package/dist/src/terminal-model-control-transaction.d.ts +19 -0
  227. package/dist/src/terminal-model-control-transaction.js +39 -0
  228. package/dist/src/terminal-model-control-transaction.js.map +1 -0
  229. package/dist/src/terminal-model-control.d.ts +331 -0
  230. package/dist/src/terminal-model-control.js +1686 -0
  231. package/dist/src/terminal-model-control.js.map +1 -0
  232. package/dist/src/terminal-monitor-application-service.js +50 -17
  233. package/dist/src/terminal-monitor-application-service.js.map +1 -1
  234. package/dist/src/terminal-native-inspection-bridge.d.ts +211 -0
  235. package/dist/src/terminal-native-inspection-bridge.js +1127 -0
  236. package/dist/src/terminal-native-inspection-bridge.js.map +1 -0
  237. package/dist/src/terminal-runtime-cli-adapter.d.ts +2 -0
  238. package/dist/src/terminal-runtime-cli-adapter.js +59 -17
  239. package/dist/src/terminal-runtime-cli-adapter.js.map +1 -1
  240. package/dist/src/terminal-submission-retry-application.d.ts +24 -0
  241. package/dist/src/terminal-submission-retry-application.js +402 -0
  242. package/dist/src/terminal-submission-retry-application.js.map +1 -0
  243. package/dist/src/terminal-submission-retry-ports.d.ts +30 -0
  244. package/dist/src/terminal-submission-retry-ports.js +2 -0
  245. package/dist/src/terminal-submission-retry-ports.js.map +1 -0
  246. package/dist/src/terminal-submission-retry-reconciliation.d.ts +236 -0
  247. package/dist/src/terminal-submission-retry-reconciliation.js +1130 -0
  248. package/dist/src/terminal-submission-retry-reconciliation.js.map +1 -0
  249. package/dist/src/terminal-submission-retry-transport.d.ts +58 -0
  250. package/dist/src/terminal-submission-retry-transport.js +675 -0
  251. package/dist/src/terminal-submission-retry-transport.js.map +1 -0
  252. package/dist/src/terminal-text-submission-bridge.d.ts +200 -0
  253. package/dist/src/terminal-text-submission-bridge.js +632 -0
  254. package/dist/src/terminal-text-submission-bridge.js.map +1 -0
  255. package/dist/src/terminal-user-explicit-send-policy.d.ts +29 -0
  256. package/dist/src/terminal-user-explicit-send-policy.js +46 -0
  257. package/dist/src/terminal-user-explicit-send-policy.js.map +1 -0
  258. package/dist/src/terminal-watch-cli-adapter.js +91 -143
  259. package/dist/src/terminal-watch-cli-adapter.js.map +1 -1
  260. package/dist/src/terminal-watch-codec.d.ts +9 -0
  261. package/dist/src/terminal-watch-codec.js +1051 -0
  262. package/dist/src/terminal-watch-codec.js.map +1 -0
  263. package/dist/src/terminal-watch-interaction-response-store.d.ts +19 -0
  264. package/dist/src/terminal-watch-interaction-response-store.js +87 -0
  265. package/dist/src/terminal-watch-interaction-response-store.js.map +1 -0
  266. package/dist/src/terminal-watch-record.d.ts +319 -0
  267. package/dist/src/terminal-watch-record.js +742 -0
  268. package/dist/src/terminal-watch-record.js.map +1 -0
  269. package/dist/src/terminal-watch-service.js +48 -27
  270. package/dist/src/terminal-watch-service.js.map +1 -1
  271. package/dist/src/terminal-watch-store.d.ts +3 -279
  272. package/dist/src/terminal-watch-store.js +5 -1779
  273. package/dist/src/terminal-watch-store.js.map +1 -1
  274. package/docs/quickstart-herdr.md +1 -1
  275. package/docs/quickstart-tmux.md +27 -2
  276. package/openclaw.plugin.json +13 -1
  277. package/package.json +7 -2
  278. package/templates/openclaw-skills/agent-knock-knock/SKILL.md +54 -11
@@ -0,0 +1,675 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { nonBlankString as stringValue } from "./value-guards.js";
3
+ import { turnIdForConversation } from "./protocol.js";
4
+ import { appendEvent, loadState, saveState } from "./store.js";
5
+ import { terminalSubmissionRetryLedgerFields } from "./terminal-submission-retry-service.js";
6
+ import * as deferredRecoveryAdapter from "./deferred-foreground-recovery-cli-adapter.js";
7
+ import { deferredForegroundBoundaryProjection } from "./deferred-foreground-preparation-cli-adapter.js";
8
+ import * as dispatchReceipt from "./terminal-dispatch-receipt.js";
9
+ import { positiveMilliseconds } from "./cli-command-runtime.js";
10
+ import { cliNow } from "./cli-runtime-context.js";
11
+ const DEFAULT_TERMINAL_ACCEPTANCE_TIMEOUT_MS = 5000;
12
+ const DEFAULT_TERMINAL_ACCEPTANCE_POLL_INTERVAL_MS = 50;
13
+ const terminalBridgeSubmission = dispatchReceipt.terminalBridgeSubmission;
14
+ export class TerminalSubmissionRetryTransport {
15
+ ports;
16
+ reconciliation;
17
+ constructor(ports, reconciliation) {
18
+ this.ports = ports;
19
+ this.reconciliation = reconciliation;
20
+ }
21
+ async runTerminalSubmissionExactDraftEnter(input) {
22
+ let attempt = input.attempt;
23
+ const reserveEnter = () => {
24
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
25
+ statePath: input.statePath,
26
+ exactTurnId: turnIdForConversation(input.conversation)
27
+ });
28
+ const at = cliNow().toISOString();
29
+ const persistAttemptLedger = () => {
30
+ this.ports.mutationDispatchLedger.save(input.scopes, input.resources, {
31
+ ...this.ports.mutationDispatchLedger.load(input.scopes, input.resources),
32
+ ...terminalSubmissionRetryLedgerFields(attempt)
33
+ });
34
+ };
35
+ const advanceDeferred = (stage, stageAt) => {
36
+ if (!input.deferred || !attempt)
37
+ return;
38
+ input.deferred.transfer = this.ports.deferredForegroundApplication(input.options, input.deferred.boundary.terminal).advanceSubmissionRetry({
39
+ scope: input.deferred.scope,
40
+ boundary: deferredForegroundBoundaryProjection(input.deferred.boundary),
41
+ attemptId: attempt.attempt_id,
42
+ messageId: attempt.active_message_id,
43
+ stage,
44
+ at: stageAt
45
+ });
46
+ };
47
+ if (!attempt) {
48
+ attempt = this.reconciliation.saveTerminalSubmissionRetryForOpenTurn(input.statePath, {
49
+ ...this.reconciliation.terminalSubmissionRetryBaseRecord({
50
+ mode: "exact_draft_enter",
51
+ state: "enter_reserved",
52
+ attemptId: `submission-retry-${randomUUID()}`,
53
+ storeDir: input.storeDir,
54
+ statePath: input.statePath,
55
+ conversation: input.conversation,
56
+ originalMessageId: input.originalMessageId,
57
+ activeMessageId: input.activeMessageId,
58
+ requestHash: input.requestHash,
59
+ terminalControl: input.terminalControl,
60
+ at,
61
+ deferredTransferId: input.deferred?.transfer.transfer_id
62
+ }),
63
+ enter_reserved_at: at
64
+ }, null);
65
+ if (input.deferred) {
66
+ input.deferred.transfer = this.ports.deferredForegroundApplication(input.options, input.deferred.boundary.terminal).reserveSubmissionRetry({
67
+ scope: input.deferred.scope,
68
+ boundary: deferredForegroundBoundaryProjection(input.deferred.boundary),
69
+ attemptId: attempt.attempt_id,
70
+ mode: attempt.mode,
71
+ messageId: attempt.active_message_id,
72
+ preparedAt: this.ports.required(stringValue(input.submission.prepared_at), "deferred retry prepared timestamp is unavailable")
73
+ });
74
+ }
75
+ advanceDeferred("enter_reserved", at);
76
+ persistAttemptLedger();
77
+ return;
78
+ }
79
+ if (attempt.mode === "replacement_send" &&
80
+ attempt.state === "replacement_text_reserved") {
81
+ attempt = this.reconciliation.saveTerminalSubmissionRetryForOpenTurn(input.statePath, {
82
+ ...attempt,
83
+ state: "replacement_text_injected",
84
+ replacement_text_injected_at: at,
85
+ updated_at: at
86
+ }, attempt.revision);
87
+ advanceDeferred("text_injected", at);
88
+ persistAttemptLedger();
89
+ }
90
+ if (attempt.state !== "replacement_text_injected") {
91
+ throw new Error("submission retry Enter is no longer reservable; no key was sent");
92
+ }
93
+ const enterReservedAt = cliNow().toISOString();
94
+ attempt = this.reconciliation.saveTerminalSubmissionRetryForOpenTurn(input.statePath, {
95
+ ...attempt,
96
+ state: "enter_reserved",
97
+ enter_reserved_at: enterReservedAt,
98
+ updated_at: enterReservedAt
99
+ }, attempt.revision);
100
+ advanceDeferred("enter_reserved", enterReservedAt);
101
+ persistAttemptLedger();
102
+ };
103
+ await input.bridge.submitExactCodexDraft(input.terminalControl, input.requestText, {
104
+ runtime: this.ports.terminalRuntimeIdentityForConversation(input.conversation, input.terminalControl),
105
+ beforeEnterReservation: reserveEnter
106
+ });
107
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
108
+ statePath: input.statePath,
109
+ exactTurnId: turnIdForConversation(input.conversation)
110
+ });
111
+ if (!attempt || attempt.state !== "enter_reserved") {
112
+ throw new Error("terminal bridge dispatched Enter without a durable retry reservation");
113
+ }
114
+ const enterAt = cliNow().toISOString();
115
+ attempt = this.reconciliation.saveTerminalSubmissionRetryForOpenTurn(input.statePath, {
116
+ ...attempt,
117
+ state: "enter_dispatched",
118
+ enter_dispatched_at: enterAt,
119
+ updated_at: enterAt
120
+ }, attempt.revision);
121
+ if (input.deferred) {
122
+ input.deferred.transfer = this.ports.deferredForegroundApplication(input.options, input.deferred.boundary.terminal).advanceSubmissionRetry({
123
+ scope: input.deferred.scope,
124
+ boundary: deferredForegroundBoundaryProjection(input.deferred.boundary),
125
+ attemptId: attempt.attempt_id,
126
+ messageId: attempt.active_message_id,
127
+ stage: "enter_dispatched",
128
+ at: enterAt
129
+ });
130
+ }
131
+ const current = loadState(input.statePath);
132
+ const currentSubmission = this.ports.required(terminalBridgeSubmission(current), "terminal submission receipt disappeared after retry Enter");
133
+ const enteredConversation = this.ports.withTerminalBridgeSubmission({
134
+ conversation: this.reconciliation.withTerminalSubmissionRetryMonitorEpoch(this.reconciliation.terminalSubmissionRetryUnstalled(current), enterAt),
135
+ messageId: input.activeMessageId,
136
+ messageType: this.reconciliation.terminalSubmissionRetryMessageType(currentSubmission),
137
+ requestText: input.requestText,
138
+ status: "enter_dispatched",
139
+ preparedAt: this.ports.required(stringValue(currentSubmission.prepared_at), "terminal submission retry prepared timestamp is unavailable"),
140
+ textInjectedAt: stringValue(currentSubmission.text_injected_at) ??
141
+ attempt.replacement_text_injected_at ?? attempt.reserved_at,
142
+ enterDispatchedAt: enterAt,
143
+ lastProvenStage: "enter_dispatched"
144
+ });
145
+ saveState(input.statePath, enteredConversation);
146
+ let enteredLedger = {
147
+ ...this.ports.mutationDispatchLedger.load(input.scopes, input.resources),
148
+ ...terminalSubmissionRetryLedgerFields(attempt),
149
+ status: "enter_dispatched",
150
+ text_injected_at: stringValue(currentSubmission.text_injected_at) ??
151
+ attempt.replacement_text_injected_at ?? attempt.reserved_at,
152
+ enter_dispatched_at: enterAt,
153
+ dispatcher_pid: null
154
+ };
155
+ this.ports.mutationDispatchLedger.save(input.scopes, input.resources, enteredLedger);
156
+ appendEvent(input.logPath, {
157
+ ts: enterAt,
158
+ conversation_id: enteredConversation.conversation_id,
159
+ event: "terminal_submission_retry_enter_dispatched",
160
+ message_id: input.activeMessageId,
161
+ terminal_input_sent: true
162
+ });
163
+ if (input.deferred) {
164
+ const transfer = input.deferred.scope.loadTransfer(input.deferred.transfer.transfer_id);
165
+ const recovered = await deferredRecoveryAdapter
166
+ .recoverAcceptedDeferredForegroundDispatch(this.ports.deferredForegroundRecoveryAdapterPorts(), {
167
+ options: input.options,
168
+ scope: input.deferred.scope,
169
+ storeDir: input.storeDir,
170
+ terminal: input.deferred.boundary.terminal,
171
+ transfer,
172
+ boundary: input.deferred.boundary
173
+ });
174
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
175
+ statePath: input.statePath,
176
+ exactTurnId: turnIdForConversation(input.conversation)
177
+ });
178
+ if (recovered) {
179
+ const finalized = this.reconciliation.finalizeDeferredTerminalSubmissionRetryAccepted({
180
+ statePath: input.statePath,
181
+ scopes: input.scopes,
182
+ resources: input.resources,
183
+ attempt
184
+ });
185
+ attempt = this.ports.required(finalized.attempt, "deferred retry attempt disappeared after accepted finalization");
186
+ const acceptedConversation = finalized.conversation;
187
+ this.ports.startTerminalBridgeMonitorForConversation({
188
+ conversation: acceptedConversation,
189
+ statePath: input.statePath,
190
+ logPath: input.logPath,
191
+ options: input.options
192
+ });
193
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
194
+ conversation: acceptedConversation,
195
+ terminalControl: input.terminalControl,
196
+ attempt,
197
+ outcome: "agent_accepted",
198
+ terminalInputSent: true,
199
+ reason: "The exact deferred Codex draft was submitted once and its transfer and source/target Sessions were committed."
200
+ });
201
+ return;
202
+ }
203
+ this.ports.startTerminalBridgeMonitorForConversation({
204
+ conversation: enteredConversation,
205
+ statePath: input.statePath,
206
+ logPath: input.logPath,
207
+ options: input.options
208
+ });
209
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
210
+ conversation: enteredConversation,
211
+ terminalControl: input.terminalControl,
212
+ attempt,
213
+ outcome: "enter_dispatched",
214
+ terminalInputSent: true,
215
+ reason: "The exact deferred Codex draft received one Enter; dedicated transfer acceptance remains pending and another retry is forbidden."
216
+ });
217
+ return;
218
+ }
219
+ const timeoutMs = positiveMilliseconds(input.options.terminalAcceptanceTimeoutMs ??
220
+ DEFAULT_TERMINAL_ACCEPTANCE_TIMEOUT_MS, "--terminal-acceptance-timeout-ms");
221
+ const acceptance = await input.execution.pollAcceptance({
222
+ executor: "codex",
223
+ conversation: enteredConversation,
224
+ terminalControl: input.terminalControl,
225
+ ...this.ports.terminalAcceptanceCompanionFences(enteredConversation, input.terminalControl),
226
+ timeoutMs,
227
+ pollIntervalMs: Math.max(10, Math.min(timeoutMs, Number(input.options.terminalAcceptancePollIntervalMs ??
228
+ DEFAULT_TERMINAL_ACCEPTANCE_POLL_INTERVAL_MS))),
229
+ scrollbackLines: Number(input.options.scrollbackLines ?? 240)
230
+ });
231
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
232
+ statePath: input.statePath,
233
+ exactTurnId: turnIdForConversation(input.conversation)
234
+ });
235
+ if (acceptance.outcome === "agent_accepted") {
236
+ const repaired = this.reconciliation.terminalSubmissionRetryAccepted({
237
+ conversation: enteredConversation,
238
+ submission: this.ports.required(terminalBridgeSubmission(enteredConversation), "terminal submission receipt disappeared after retry acceptance"),
239
+ ledger: enteredLedger,
240
+ evidence: acceptance.evidence,
241
+ requestText: input.requestText,
242
+ at: cliNow().toISOString(),
243
+ statePath: input.statePath,
244
+ logPath: input.logPath,
245
+ scopes: input.scopes,
246
+ resources: input.resources,
247
+ attempt,
248
+ terminalInputSent: true
249
+ });
250
+ this.ports.startTerminalBridgeMonitorForConversation({
251
+ conversation: repaired.conversation,
252
+ statePath: input.statePath,
253
+ logPath: input.logPath,
254
+ options: input.options
255
+ });
256
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
257
+ conversation: repaired.conversation,
258
+ terminalControl: input.terminalControl,
259
+ attempt: repaired.attempt,
260
+ outcome: "agent_accepted",
261
+ terminalInputSent: true,
262
+ reason: "The exact existing Codex draft was submitted once and native acceptance was proven."
263
+ });
264
+ return;
265
+ }
266
+ if (acceptance.outcome === "not_accepted") {
267
+ const notAcceptedAt = cliNow().toISOString();
268
+ const notAcceptedConversation = this.reconciliation.terminalSubmissionRetryTerminalOutcome({
269
+ conversation: enteredConversation,
270
+ submission: this.ports.required(terminalBridgeSubmission(enteredConversation), "terminal submission receipt disappeared after retry rejection"),
271
+ ledger: enteredLedger,
272
+ requestText: input.requestText,
273
+ reason: acceptance.reason,
274
+ at: notAcceptedAt,
275
+ statePath: input.statePath,
276
+ logPath: input.logPath,
277
+ scopes: input.scopes,
278
+ resources: input.resources,
279
+ attempt,
280
+ outcome: "not_accepted"
281
+ });
282
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
283
+ conversation: notAcceptedConversation,
284
+ terminalControl: input.terminalControl,
285
+ attempt,
286
+ outcome: "not_accepted",
287
+ terminalInputSent: true,
288
+ reason: "The exact draft remains in the Codex composer after one Enter; it was durably recorded as not accepted and another retry is forbidden."
289
+ });
290
+ return;
291
+ }
292
+ if (acceptance.outcome === "uncertain") {
293
+ const uncertainConversation = this.reconciliation.terminalSubmissionRetryTerminalOutcome({
294
+ conversation: enteredConversation,
295
+ submission: this.ports.required(terminalBridgeSubmission(enteredConversation), "terminal submission receipt disappeared after uncertain retry acceptance"),
296
+ ledger: enteredLedger,
297
+ requestText: input.requestText,
298
+ reason: acceptance.reason,
299
+ at: cliNow().toISOString(),
300
+ statePath: input.statePath,
301
+ logPath: input.logPath,
302
+ scopes: input.scopes,
303
+ resources: input.resources,
304
+ attempt,
305
+ outcome: "uncertain"
306
+ });
307
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
308
+ conversation: uncertainConversation,
309
+ terminalControl: input.terminalControl,
310
+ attempt,
311
+ outcome: "refused",
312
+ terminalInputSent: true,
313
+ reason: `Exact-draft acceptance is uncertain (${acceptance.reason}); the terminal outcome is durable and another retry is forbidden.`
314
+ });
315
+ return;
316
+ }
317
+ this.ports.startTerminalBridgeMonitorForConversation({
318
+ conversation: enteredConversation,
319
+ statePath: input.statePath,
320
+ logPath: input.logPath,
321
+ options: input.options
322
+ });
323
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
324
+ conversation: enteredConversation,
325
+ terminalControl: input.terminalControl,
326
+ attempt,
327
+ outcome: "enter_dispatched",
328
+ terminalInputSent: true,
329
+ reason: "The exact existing Codex draft received one Enter; acceptance remains pending and another retry is forbidden."
330
+ });
331
+ }
332
+ async runTerminalSubmissionReplacement(input) {
333
+ if (input.observation.state !== "exact_empty") {
334
+ throw new Error("replacement send lost its positive empty-composer proof; no terminal input was sent");
335
+ }
336
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
337
+ statePath: input.statePath,
338
+ exactTurnId: turnIdForConversation(input.conversation)
339
+ });
340
+ let attempt = input.attempt;
341
+ if (!attempt) {
342
+ const at = cliNow().toISOString();
343
+ attempt = this.reconciliation.saveTerminalSubmissionRetryForOpenTurn(input.statePath, this.reconciliation.terminalSubmissionRetryBaseRecord({
344
+ mode: "replacement_send",
345
+ state: "replacement_reserved",
346
+ attemptId: `submission-retry-${randomUUID()}`,
347
+ storeDir: input.storeDir,
348
+ statePath: input.statePath,
349
+ conversation: input.conversation,
350
+ originalMessageId: input.originalMessageId,
351
+ activeMessageId: input.originalMessageId,
352
+ requestHash: input.requestHash,
353
+ terminalControl: input.terminalControl,
354
+ at,
355
+ deferredTransferId: input.deferred?.transfer.transfer_id
356
+ }), null);
357
+ if (input.deferred) {
358
+ input.deferred.transfer = this.ports.deferredForegroundApplication(input.options, input.deferred.boundary.terminal).reserveSubmissionRetry({
359
+ scope: input.deferred.scope,
360
+ boundary: deferredForegroundBoundaryProjection(input.deferred.boundary),
361
+ attemptId: attempt.attempt_id,
362
+ mode: attempt.mode,
363
+ messageId: attempt.active_message_id,
364
+ preparedAt: this.ports.required(stringValue(input.submission.prepared_at), "deferred retry prepared timestamp is unavailable")
365
+ });
366
+ }
367
+ const reservedLedger = this.ports.required(this.ports.mutationDispatchLedger.load(input.scopes, input.resources), "terminal submission retry ledger disappeared after reservation");
368
+ this.ports.mutationDispatchLedger.save(input.scopes, input.resources, {
369
+ ...reservedLedger,
370
+ ...terminalSubmissionRetryLedgerFields(attempt)
371
+ });
372
+ }
373
+ if (attempt.mode !== "replacement_send" ||
374
+ attempt.state !== "replacement_reserved") {
375
+ throw new Error("replacement text transport was already reserved; no additional text was sent");
376
+ }
377
+ const currentAttempt = () => this.ports.required(attempt, "terminal submission retry attempt is unavailable");
378
+ const saveAttempt = (state, at, fields) => {
379
+ const current = currentAttempt();
380
+ attempt = this.reconciliation.saveTerminalSubmissionRetryForOpenTurn(input.statePath, {
381
+ ...current,
382
+ ...fields,
383
+ state,
384
+ updated_at: at
385
+ }, current.revision);
386
+ };
387
+ const persistRetryLedger = (fields = {}) => {
388
+ const current = this.ports.required(this.ports.mutationDispatchLedger.load(input.scopes, input.resources), "terminal submission retry ledger disappeared");
389
+ const next = {
390
+ ...current,
391
+ ...terminalSubmissionRetryLedgerFields(attempt),
392
+ ...fields
393
+ };
394
+ this.ports.mutationDispatchLedger.save(input.scopes, input.resources, next);
395
+ return next;
396
+ };
397
+ let enteredConversation;
398
+ let enteredLedger;
399
+ await input.bridge.send("codex", input.terminalControl, input.requestText, {
400
+ runtime: this.ports.terminalRuntimeIdentityForConversation(input.conversation, input.terminalControl),
401
+ requireExactComposerBeforeEnter: true,
402
+ requireExactEmptyComposerAfterBeforeText: {
403
+ preliminaryComposerDigest: input.observation.digest
404
+ },
405
+ beforeText: () => {
406
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
407
+ statePath: input.statePath,
408
+ exactTurnId: turnIdForConversation(input.conversation)
409
+ });
410
+ const at = cliNow().toISOString();
411
+ saveAttempt("replacement_text_reserved", at, {
412
+ replacement_text_reserved_at: at
413
+ });
414
+ if (input.deferred) {
415
+ input.deferred.transfer = this.ports.deferredForegroundApplication(input.options, input.deferred.boundary.terminal).advanceSubmissionRetry({
416
+ scope: input.deferred.scope,
417
+ boundary: deferredForegroundBoundaryProjection(input.deferred.boundary),
418
+ attemptId: currentAttempt().attempt_id,
419
+ messageId: currentAttempt().active_message_id,
420
+ stage: "text_reserved",
421
+ at
422
+ });
423
+ }
424
+ persistRetryLedger();
425
+ },
426
+ beforeEnter: () => {
427
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
428
+ statePath: input.statePath,
429
+ exactTurnId: turnIdForConversation(input.conversation)
430
+ });
431
+ const at = cliNow().toISOString();
432
+ saveAttempt("enter_reserved", at, { enter_reserved_at: at });
433
+ if (input.deferred) {
434
+ input.deferred.transfer = this.ports.deferredForegroundApplication(input.options, input.deferred.boundary.terminal).advanceSubmissionRetry({
435
+ scope: input.deferred.scope,
436
+ boundary: deferredForegroundBoundaryProjection(input.deferred.boundary),
437
+ attemptId: currentAttempt().attempt_id,
438
+ messageId: currentAttempt().active_message_id,
439
+ stage: "enter_reserved",
440
+ at
441
+ });
442
+ }
443
+ persistRetryLedger();
444
+ },
445
+ onTransportStage: ({ stage }) => {
446
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
447
+ statePath: input.statePath,
448
+ exactTurnId: turnIdForConversation(input.conversation)
449
+ });
450
+ const at = cliNow().toISOString();
451
+ if (stage === "text_injected") {
452
+ saveAttempt("replacement_text_injected", at, {
453
+ replacement_text_injected_at: at
454
+ });
455
+ }
456
+ else {
457
+ saveAttempt("enter_dispatched", at, {
458
+ enter_dispatched_at: at
459
+ });
460
+ }
461
+ if (input.deferred) {
462
+ input.deferred.transfer = this.ports.deferredForegroundApplication(input.options, input.deferred.boundary.terminal).advanceSubmissionRetry({
463
+ scope: input.deferred.scope,
464
+ boundary: deferredForegroundBoundaryProjection(input.deferred.boundary),
465
+ attemptId: currentAttempt().attempt_id,
466
+ messageId: currentAttempt().active_message_id,
467
+ stage,
468
+ at
469
+ });
470
+ }
471
+ if (stage === "text_injected") {
472
+ persistRetryLedger();
473
+ return;
474
+ }
475
+ const current = loadState(input.statePath);
476
+ const submission = this.ports.required(terminalBridgeSubmission(current), "terminal submission receipt disappeared after replacement Enter");
477
+ enteredConversation = this.ports.withTerminalBridgeSubmission({
478
+ conversation: this.reconciliation.withTerminalSubmissionRetryMonitorEpoch(this.reconciliation.terminalSubmissionRetryUnstalled(current), at),
479
+ messageId: input.originalMessageId,
480
+ messageType: this.reconciliation.terminalSubmissionRetryMessageType(submission),
481
+ requestText: input.requestText,
482
+ status: "enter_dispatched",
483
+ preparedAt: this.ports.required(stringValue(submission.prepared_at), "terminal submission retry prepared timestamp is unavailable"),
484
+ textInjectedAt: currentAttempt().replacement_text_injected_at,
485
+ enterDispatchedAt: at,
486
+ lastProvenStage: "enter_dispatched"
487
+ });
488
+ saveState(input.statePath, enteredConversation);
489
+ enteredLedger = persistRetryLedger({
490
+ status: "enter_dispatched",
491
+ text_injected_at: currentAttempt().replacement_text_injected_at,
492
+ enter_dispatched_at: at,
493
+ enter_not_attempted_at: undefined,
494
+ enter_not_attempted_reason: undefined,
495
+ uncertain_at: undefined,
496
+ safe_to_retry: undefined,
497
+ acceptance_evidence: undefined,
498
+ agent_accepted_at: undefined,
499
+ not_accepted_at: undefined,
500
+ dispatcher_pid: null
501
+ });
502
+ appendEvent(input.logPath, {
503
+ ts: at,
504
+ conversation_id: enteredConversation.conversation_id,
505
+ event: "terminal_submission_retry_enter_dispatched",
506
+ message_id: input.originalMessageId,
507
+ terminal_input_sent: true
508
+ });
509
+ }
510
+ });
511
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
512
+ statePath: input.statePath,
513
+ exactTurnId: turnIdForConversation(input.conversation)
514
+ });
515
+ if (currentAttempt().state !== "enter_dispatched" ||
516
+ !enteredConversation || !enteredLedger) {
517
+ throw new Error("replacement transport returned without durable Enter evidence");
518
+ }
519
+ if (input.deferred) {
520
+ const transfer = input.deferred.scope.loadTransfer(input.deferred.transfer.transfer_id);
521
+ const recovered = await deferredRecoveryAdapter
522
+ .recoverAcceptedDeferredForegroundDispatch(this.ports.deferredForegroundRecoveryAdapterPorts(), {
523
+ options: input.options,
524
+ scope: input.deferred.scope,
525
+ storeDir: input.storeDir,
526
+ terminal: input.deferred.boundary.terminal,
527
+ transfer,
528
+ boundary: input.deferred.boundary
529
+ });
530
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
531
+ statePath: input.statePath,
532
+ exactTurnId: turnIdForConversation(input.conversation)
533
+ });
534
+ if (recovered) {
535
+ const finalized = this.reconciliation.finalizeDeferredTerminalSubmissionRetryAccepted({
536
+ statePath: input.statePath,
537
+ scopes: input.scopes,
538
+ resources: input.resources,
539
+ attempt
540
+ });
541
+ attempt = this.ports.required(finalized.attempt, "deferred replacement retry attempt disappeared after accepted finalization");
542
+ const acceptedConversation = finalized.conversation;
543
+ this.ports.startTerminalBridgeMonitorForConversation({
544
+ conversation: acceptedConversation,
545
+ statePath: input.statePath,
546
+ logPath: input.logPath,
547
+ options: input.options
548
+ });
549
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
550
+ conversation: acceptedConversation,
551
+ terminalControl: input.terminalControl,
552
+ attempt,
553
+ outcome: "agent_accepted",
554
+ terminalInputSent: true,
555
+ reason: "The missing deferred Codex submission was completed once and its source/target Sessions were committed."
556
+ });
557
+ return;
558
+ }
559
+ }
560
+ else {
561
+ const timeoutMs = positiveMilliseconds(input.options.terminalAcceptanceTimeoutMs ??
562
+ DEFAULT_TERMINAL_ACCEPTANCE_TIMEOUT_MS, "--terminal-acceptance-timeout-ms");
563
+ const acceptance = await input.execution.pollAcceptance({
564
+ executor: "codex",
565
+ conversation: enteredConversation,
566
+ terminalControl: input.terminalControl,
567
+ ...this.ports.terminalAcceptanceCompanionFences(enteredConversation, input.terminalControl),
568
+ timeoutMs,
569
+ pollIntervalMs: Math.max(10, Math.min(timeoutMs, Number(input.options.terminalAcceptancePollIntervalMs ??
570
+ DEFAULT_TERMINAL_ACCEPTANCE_POLL_INTERVAL_MS))),
571
+ scrollbackLines: Number(input.options.scrollbackLines ?? 240)
572
+ });
573
+ this.reconciliation.assertTerminalSubmissionRetryTurnOpen({
574
+ statePath: input.statePath,
575
+ exactTurnId: turnIdForConversation(input.conversation)
576
+ });
577
+ if (acceptance.outcome === "agent_accepted") {
578
+ const repaired = this.reconciliation.terminalSubmissionRetryAccepted({
579
+ conversation: enteredConversation,
580
+ submission: this.ports.required(terminalBridgeSubmission(enteredConversation), "terminal submission receipt disappeared after replacement acceptance"),
581
+ ledger: enteredLedger,
582
+ evidence: acceptance.evidence,
583
+ requestText: input.requestText,
584
+ at: cliNow().toISOString(),
585
+ statePath: input.statePath,
586
+ logPath: input.logPath,
587
+ scopes: input.scopes,
588
+ resources: input.resources,
589
+ attempt,
590
+ terminalInputSent: true
591
+ });
592
+ this.ports.startTerminalBridgeMonitorForConversation({
593
+ conversation: repaired.conversation,
594
+ statePath: input.statePath,
595
+ logPath: input.logPath,
596
+ options: input.options
597
+ });
598
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
599
+ conversation: repaired.conversation,
600
+ terminalControl: input.terminalControl,
601
+ attempt: repaired.attempt,
602
+ outcome: "agent_accepted",
603
+ terminalInputSent: true,
604
+ reason: "The missing Codex submission was completed once and native acceptance was proven."
605
+ });
606
+ return;
607
+ }
608
+ if (acceptance.outcome === "not_accepted") {
609
+ const notAcceptedConversation = this.reconciliation.terminalSubmissionRetryTerminalOutcome({
610
+ conversation: enteredConversation,
611
+ submission: this.ports.required(terminalBridgeSubmission(enteredConversation), "terminal submission receipt disappeared after replacement rejection"),
612
+ ledger: enteredLedger,
613
+ requestText: input.requestText,
614
+ reason: acceptance.reason,
615
+ at: cliNow().toISOString(),
616
+ statePath: input.statePath,
617
+ logPath: input.logPath,
618
+ scopes: input.scopes,
619
+ resources: input.resources,
620
+ attempt,
621
+ outcome: "not_accepted"
622
+ });
623
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
624
+ conversation: notAcceptedConversation,
625
+ terminalControl: input.terminalControl,
626
+ attempt,
627
+ outcome: "not_accepted",
628
+ terminalInputSent: true,
629
+ reason: "The replacement text remains in the Codex composer after one Enter; it was not accepted and another retry is forbidden."
630
+ });
631
+ return;
632
+ }
633
+ if (acceptance.outcome === "uncertain") {
634
+ const uncertainConversation = this.reconciliation.terminalSubmissionRetryTerminalOutcome({
635
+ conversation: enteredConversation,
636
+ submission: this.ports.required(terminalBridgeSubmission(enteredConversation), "terminal submission receipt disappeared after uncertain replacement acceptance"),
637
+ ledger: enteredLedger,
638
+ requestText: input.requestText,
639
+ reason: acceptance.reason,
640
+ at: cliNow().toISOString(),
641
+ statePath: input.statePath,
642
+ logPath: input.logPath,
643
+ scopes: input.scopes,
644
+ resources: input.resources,
645
+ attempt,
646
+ outcome: "uncertain"
647
+ });
648
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
649
+ conversation: uncertainConversation,
650
+ terminalControl: input.terminalControl,
651
+ attempt,
652
+ outcome: "refused",
653
+ terminalInputSent: true,
654
+ reason: `Replacement acceptance is uncertain (${acceptance.reason}); another retry is forbidden.`
655
+ });
656
+ return;
657
+ }
658
+ }
659
+ this.ports.startTerminalBridgeMonitorForConversation({
660
+ conversation: enteredConversation,
661
+ statePath: input.statePath,
662
+ logPath: input.logPath,
663
+ options: input.options
664
+ });
665
+ this.reconciliation.printTerminalSubmissionRetryOutcome({
666
+ conversation: enteredConversation,
667
+ terminalControl: input.terminalControl,
668
+ attempt,
669
+ outcome: "enter_dispatched",
670
+ terminalInputSent: true,
671
+ reason: "The missing Codex submission received one text injection and one Enter; acceptance remains pending and another retry is forbidden."
672
+ });
673
+ }
674
+ }
675
+ //# sourceMappingURL=terminal-submission-retry-transport.js.map