arco-workbench 0.1.7 → 0.1.9

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 (301) hide show
  1. package/CONTRIBUTING.md +63 -12
  2. package/README.md +21 -17
  3. package/client/dist/assets/{PhosphorBackdrop-DVQdBrTw.js → PhosphorBackdrop-DRu16-Is.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-BfSs2tB4.js → ThemedBackgroundShaderImpl-BLdwwQ4D.js} +1 -1
  5. package/client/dist/assets/{XtermView-DaMjC8Ny.js → XtermView-Xk7_9JaH.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-BCQnXj7R.js → galleryEditor-CI8ClzBa.js} +1 -1
  7. package/client/dist/assets/{index-DD9kFGsF.css → index-BEFgrUJJ.css} +1 -1
  8. package/client/dist/assets/{index-COfbHCYv.js → index-C7WzZfsr.js} +257 -255
  9. package/client/dist/index.html +2 -2
  10. package/client/src/App.tsx +2 -0
  11. package/client/src/components/ChatMessage.tsx +33 -8
  12. package/client/src/components/ChatModeView.tsx +2 -0
  13. package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
  14. package/client/src/components/ClusterRightPanel/SkillsControl.tsx +124 -0
  15. package/client/src/components/ClusterRightPanel/index.tsx +4 -0
  16. package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
  17. package/client/src/components/CodexLateCommand.tsx +34 -0
  18. package/client/src/components/DialogShell.tsx +2 -0
  19. package/client/src/components/MemberCard.tsx +4 -1
  20. package/client/src/components/MemberPane.tsx +3 -1
  21. package/client/src/components/NeedsYouBadge.tsx +3 -3
  22. package/client/src/components/PhoneUpload.tsx +288 -0
  23. package/client/src/components/PrimaryStatus.tsx +14 -6
  24. package/client/src/components/ProviderReleasesModal.tsx +8 -4
  25. package/client/src/components/ProvidersPopover.tsx +28 -23
  26. package/client/src/components/RuntimeStateBanner.tsx +5 -0
  27. package/client/src/components/SettingsPanel.tsx +2 -2
  28. package/client/src/components/SkillEditorDialog.tsx +2 -2
  29. package/client/src/components/SkillsSettings.tsx +21 -4
  30. package/client/src/components/TabBar.tsx +91 -9
  31. package/client/src/components/TerminalInput.tsx +15 -11
  32. package/client/src/components/TranscriptSendDialog.tsx +12 -8
  33. package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
  34. package/client/src/components/WorkflowView.tsx +2 -0
  35. package/client/src/components/clusterNeedsYou.ts +11 -18
  36. package/client/src/explorer/ArtifactsLens.tsx +37 -28
  37. package/client/src/explorer/ExplorerApp.tsx +5 -4
  38. package/client/src/explorer/types.ts +8 -3
  39. package/client/src/help/content/cluster.tsx +48 -17
  40. package/client/src/help/content/composer.tsx +40 -1
  41. package/client/src/help/content/header.tsx +18 -1
  42. package/client/src/help/content/misc.tsx +9 -1
  43. package/client/src/help/content/settings.tsx +18 -4
  44. package/client/src/help/content/tabbar.tsx +5 -0
  45. package/client/src/help/manualSections/actions.tsx +31 -0
  46. package/client/src/help/manualSections/clusters.tsx +44 -20
  47. package/client/src/help/manualSections/configuration.tsx +20 -0
  48. package/client/src/help/manualSections/gettingStarted.tsx +4 -4
  49. package/client/src/help/manualSections/maintenance.tsx +25 -6
  50. package/client/src/help/manualSections/powerFeatures.tsx +3 -2
  51. package/client/src/help/manualSections/providers.tsx +32 -8
  52. package/client/src/help/manualSections/troubleshooting.tsx +2 -1
  53. package/client/src/help/manualSections/workflows.tsx +12 -0
  54. package/client/src/help/manualSections/workspace.tsx +36 -0
  55. package/client/src/stores/appStore.ts +7 -0
  56. package/client/src/stores/appStore.types.ts +4 -0
  57. package/client/src/styles/global.css +109 -0
  58. package/client/src/utils/phoneTheme.ts +38 -0
  59. package/client/src/utils/phoneUploadApi.ts +10 -0
  60. package/client/src/utils/transcriptWorkerRequest.ts +24 -0
  61. package/client/src/ws/handleServerMessage.ts +31 -8
  62. package/docs/ARCHITECTURE.md +1 -1
  63. package/docs/CLIENT.md +16 -9
  64. package/docs/FEATURES.md +13 -7
  65. package/docs/GETTING_STARTED.md +12 -6
  66. package/docs/GOTCHAS.md +2 -1
  67. package/docs/INDEX.md +1 -1
  68. package/docs/OPERATIONS.md +213 -52
  69. package/docs/PERSISTENCE.md +7 -2
  70. package/docs/PRIMITIVES.md +42 -0
  71. package/docs/PROTOCOL_CLUSTER.md +51 -4
  72. package/docs/PROTOCOL_PRIMITIVES.md +39 -0
  73. package/docs/PROVIDERS.md +84 -13
  74. package/docs/SETTINGS.md +29 -3
  75. package/docs/TASK_LEDGER.md +7 -15
  76. package/native/linux-x64/manifest.json +1 -1
  77. package/native/win32-x64/manifest.json +1 -1
  78. package/node_modules/@arco/shared/dist/clusterCoordination.d.ts +2 -0
  79. package/node_modules/@arco/shared/dist/clusterCoordination.js +5 -1
  80. package/node_modules/@arco/shared/dist/protocol/chat.d.ts +1 -0
  81. package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +3 -2
  82. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -1
  83. package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
  84. package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
  85. package/node_modules/@arco/shared/dist/protocol/models.d.ts +4 -3
  86. package/node_modules/@arco/shared/dist/protocol/models.js +26 -2
  87. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +13 -1
  88. package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +4 -0
  89. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  90. package/node_modules/@arco/shared/dist/protocol/transcriptWorker.js +2 -0
  91. package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
  92. package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +1 -0
  93. package/node_modules/@arco/shared/dist/runtimeVersions.js +14 -0
  94. package/node_modules/@arco/shared/package.json +1 -1
  95. package/package.json +2 -2
  96. package/scripts/packaging/arco.mjs +1 -1
  97. package/scripts/packaging/native-repair.mjs +32 -4
  98. package/server/dist/atomicFile.js +1 -2
  99. package/server/dist/capabilities.d.ts +5 -2
  100. package/server/dist/capabilities.js +59 -9
  101. package/server/dist/cliUpdateDecision.d.ts +1 -1
  102. package/server/dist/cliUpdateDecision.js +5 -3
  103. package/server/dist/clusterDirector.js +2 -1
  104. package/server/dist/clusterPeerOps.js +14 -8
  105. package/server/dist/clusterProgress.js +1 -1
  106. package/server/dist/clusterRehydrate.js +2 -0
  107. package/server/dist/clusterSkills.d.ts +13 -0
  108. package/server/dist/clusterSkills.js +81 -0
  109. package/server/dist/clusterSnapshots.js +2 -0
  110. package/server/dist/clusterStore.d.ts +7 -2
  111. package/server/dist/clusterStore.js +42 -1
  112. package/server/dist/diagnostics/codeSkew.js +1 -0
  113. package/server/dist/eventLog.d.ts +7 -0
  114. package/server/dist/eventLog.js +70 -13
  115. package/server/dist/explorerDocs.d.ts +10 -6
  116. package/server/dist/explorerDocs.js +75 -34
  117. package/server/dist/historyLimits.d.ts +1 -0
  118. package/server/dist/historyLimits.js +3 -0
  119. package/server/dist/http/attachmentUpload.d.ts +13 -0
  120. package/server/dist/http/attachmentUpload.js +38 -0
  121. package/server/dist/http/browserWorktrees.d.ts +23 -0
  122. package/server/dist/http/browserWorktrees.js +120 -0
  123. package/server/dist/http/phoneUploadDrafts.d.ts +13 -0
  124. package/server/dist/http/phoneUploadDrafts.js +125 -0
  125. package/server/dist/http/phoneUploadListener.d.ts +17 -0
  126. package/server/dist/http/phoneUploadListener.js +81 -0
  127. package/server/dist/http/phoneUploadNetwork.d.ts +9 -0
  128. package/server/dist/http/phoneUploadNetwork.js +106 -0
  129. package/server/dist/http/phoneUploadPage.d.ts +2 -0
  130. package/server/dist/http/phoneUploadPage.js +136 -0
  131. package/server/dist/http/phoneUploadRouteHistory.d.ts +4 -0
  132. package/server/dist/http/phoneUploadRouteHistory.js +72 -0
  133. package/server/dist/http/phoneUploadRoutes.d.ts +4 -0
  134. package/server/dist/http/phoneUploadRoutes.js +419 -0
  135. package/server/dist/http/phoneUploadTheme.d.ts +17 -0
  136. package/server/dist/http/phoneUploadTheme.js +96 -0
  137. package/server/dist/http/projectBinding.d.ts +1 -0
  138. package/server/dist/http/projectBinding.js +3 -2
  139. package/server/dist/http/readConfinement.js +5 -1
  140. package/server/dist/http/router.js +14 -25
  141. package/server/dist/http/writeConfinement.js +19 -2
  142. package/server/dist/index.js +24 -1
  143. package/server/dist/jsonlLines.d.ts +4 -0
  144. package/server/dist/jsonlLines.js +53 -0
  145. package/server/dist/management/identity.js +1 -0
  146. package/server/dist/mcp/clusterMcpTools.js +4 -4
  147. package/server/dist/primitives/seedWorker.d.ts +1 -0
  148. package/server/dist/primitives/seedWorker.js +2 -1
  149. package/server/dist/project/taskLedger.d.ts +4 -0
  150. package/server/dist/project/taskLedger.js +7 -4
  151. package/server/dist/providerConversation.d.ts +1 -0
  152. package/server/dist/providerConversation.js +17 -0
  153. package/server/dist/providers/claude-native/resumeSummary.d.ts +9 -0
  154. package/server/dist/providers/claude-native/resumeSummary.js +102 -49
  155. package/server/dist/providers/claude-native/worker.js +8 -4
  156. package/server/dist/providers/claude.js +2 -1
  157. package/server/dist/providers/clusterTaskToolDefinitions.js +4 -4
  158. package/server/dist/providers/codex-appserver/catalog.js +16 -1
  159. package/server/dist/providers/codex-appserver/heldCommands.d.ts +14 -0
  160. package/server/dist/providers/codex-appserver/heldCommands.js +54 -0
  161. package/server/dist/providers/codex-appserver/index.d.ts +52 -2
  162. package/server/dist/providers/codex-appserver/index.js +239 -21
  163. package/server/dist/providers/codex-appserver/lateCommands.d.ts +62 -0
  164. package/server/dist/providers/codex-appserver/lateCommands.js +195 -0
  165. package/server/dist/providers/codex-appserver/worker.d.ts +23 -1
  166. package/server/dist/providers/codex-appserver/worker.js +89 -20
  167. package/server/dist/providers/codex.js +2 -1
  168. package/server/dist/providers/codexCodeMode.d.ts +2 -1
  169. package/server/dist/providers/codexCodeMode.js +8 -3
  170. package/server/dist/providers/cursor/print.js +2 -1
  171. package/server/dist/providers/cursor/worker.js +2 -1
  172. package/server/dist/providers/llamacpp.js +17 -8
  173. package/server/dist/providers/ollamaRecovery.js +6 -6
  174. package/server/dist/providers/ollamaResilience.js +3 -3
  175. package/server/dist/providers/ollamaTokens.js +1 -1
  176. package/server/dist/quota.d.ts +0 -18
  177. package/server/dist/quota.js +0 -44
  178. package/server/dist/replacementHistory.d.ts +19 -0
  179. package/server/dist/replacementHistory.js +49 -0
  180. package/server/dist/server/broadcast.d.ts +2 -1
  181. package/server/dist/server/broadcast.js +1 -0
  182. package/server/dist/server/prompts.d.ts +1 -0
  183. package/server/dist/server/prompts.js +6 -1
  184. package/server/dist/sessionJsonl.d.ts +1 -1
  185. package/server/dist/sessionJsonl.js +115 -40
  186. package/server/dist/smartPickupAdapters.js +15 -2
  187. package/server/dist/transcriptWorker.d.ts +34 -0
  188. package/server/dist/transcriptWorker.js +201 -0
  189. package/server/dist/workers/WorkerManager.d.ts +1 -0
  190. package/server/dist/workers/WorkerManager.js +1 -0
  191. package/server/dist/workers/processKill.d.ts +9 -1
  192. package/server/dist/workers/processKill.js +26 -10
  193. package/server/dist/workflowStore.d.ts +1 -0
  194. package/server/dist/workflowStore.js +31 -0
  195. package/server/dist/ws/clusterHandlers.d.ts +1 -0
  196. package/server/dist/ws/clusterHandlers.js +62 -26
  197. package/server/dist/ws/handoffHandlers.js +7 -2
  198. package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
  199. package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
  200. package/server/dist/ws/turnEngine.js +40 -9
  201. package/server/dist/ws/updatePrimaryConfig.js +27 -8
  202. package/server/dist/ws/workflowHandlers.d.ts +4 -1
  203. package/server/dist/ws/workflowHandlers.js +3 -1
  204. package/server/package.json +1 -1
  205. package/server/src/atomicFile.ts +1 -2
  206. package/server/src/capabilities.ts +58 -17
  207. package/server/src/cliUpdateDecision.ts +5 -4
  208. package/server/src/clusterDirector.ts +2 -1
  209. package/server/src/clusterPeerOps.ts +15 -9
  210. package/server/src/clusterProgress.ts +1 -1
  211. package/server/src/clusterRehydrate.ts +2 -0
  212. package/server/src/clusterSkills.ts +79 -0
  213. package/server/src/clusterSnapshots.ts +1 -0
  214. package/server/src/clusterStore.ts +38 -0
  215. package/server/src/diagnostics/codeSkew.ts +1 -0
  216. package/server/src/eventLog.ts +73 -13
  217. package/server/src/explorerDocs.ts +75 -34
  218. package/server/src/historyLimits.ts +2 -0
  219. package/server/src/http/attachmentUpload.ts +49 -0
  220. package/server/src/http/browserWorktrees.ts +124 -0
  221. package/server/src/http/phoneUploadDrafts.ts +118 -0
  222. package/server/src/http/phoneUploadListener.ts +96 -0
  223. package/server/src/http/phoneUploadNetwork.ts +117 -0
  224. package/server/src/http/phoneUploadPage.ts +137 -0
  225. package/server/src/http/phoneUploadRouteHistory.ts +73 -0
  226. package/server/src/http/phoneUploadRoutes.ts +398 -0
  227. package/server/src/http/phoneUploadTheme.ts +97 -0
  228. package/server/src/http/projectBinding.ts +3 -2
  229. package/server/src/http/readConfinement.ts +5 -1
  230. package/server/src/http/router.ts +12 -26
  231. package/server/src/http/writeConfinement.ts +13 -2
  232. package/server/src/index.ts +23 -0
  233. package/server/src/jsonlLines.ts +52 -0
  234. package/server/src/management/identity.ts +1 -0
  235. package/server/src/mcp/clusterMcpTools.ts +4 -4
  236. package/server/src/primitives/seedWorker.ts +3 -1
  237. package/server/src/project/taskLedger.ts +7 -5
  238. package/server/src/providerConversation.ts +15 -0
  239. package/server/src/providers/claude-native/resumeSummary.ts +98 -50
  240. package/server/src/providers/claude-native/worker.ts +8 -4
  241. package/server/src/providers/claude.ts +2 -1
  242. package/server/src/providers/clusterTaskToolDefinitions.ts +4 -4
  243. package/server/src/providers/codex-appserver/catalog.ts +14 -1
  244. package/server/src/providers/codex-appserver/heldCommands.ts +58 -0
  245. package/server/src/providers/codex-appserver/index.ts +222 -20
  246. package/server/src/providers/codex-appserver/lateCommands.ts +225 -0
  247. package/server/src/providers/codex-appserver/worker.ts +85 -21
  248. package/server/src/providers/codex.ts +2 -1
  249. package/server/src/providers/codexCodeMode.ts +9 -4
  250. package/server/src/providers/cursor/print.ts +2 -1
  251. package/server/src/providers/cursor/worker.ts +2 -1
  252. package/server/src/providers/llamacpp.ts +18 -7
  253. package/server/src/providers/llamacppRecovery.ts +2 -0
  254. package/server/src/providers/ollamaRecovery.ts +6 -6
  255. package/server/src/providers/ollamaResilience.ts +3 -3
  256. package/server/src/providers/ollamaTokens.ts +1 -1
  257. package/server/src/providers/ollamaToolSubset.ts +3 -3
  258. package/server/src/quota.ts +0 -50
  259. package/server/src/replacementHistory.ts +44 -0
  260. package/server/src/server/broadcast.ts +2 -0
  261. package/server/src/server/prompts.ts +8 -1
  262. package/server/src/sessionJsonl.ts +92 -32
  263. package/server/src/smartPickupAdapters.ts +17 -3
  264. package/server/src/transcriptWorker.ts +182 -0
  265. package/server/src/workers/WorkerManager.ts +2 -0
  266. package/server/src/workers/processKill.ts +35 -7
  267. package/server/src/workflowStore.ts +21 -0
  268. package/server/src/ws/clusterHandlers.ts +43 -25
  269. package/server/src/ws/handoffHandlers.ts +7 -1
  270. package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
  271. package/server/src/ws/turnEngine.ts +35 -8
  272. package/server/src/ws/updatePrimaryConfig.ts +25 -6
  273. package/server/src/ws/workflowHandlers.ts +3 -1
  274. package/shared/dist/clusterCoordination.d.ts +2 -0
  275. package/shared/dist/clusterCoordination.js +5 -1
  276. package/shared/dist/protocol/chat.d.ts +1 -0
  277. package/shared/dist/protocol/clientMessages.d.ts +3 -2
  278. package/shared/dist/protocol/clusters.d.ts +15 -1
  279. package/shared/dist/protocol/index.d.ts +1 -0
  280. package/shared/dist/protocol/index.js +1 -0
  281. package/shared/dist/protocol/models.d.ts +4 -3
  282. package/shared/dist/protocol/models.js +26 -2
  283. package/shared/dist/protocol/serverMessages.d.ts +13 -1
  284. package/shared/dist/protocol/tasks.d.ts +4 -0
  285. package/shared/dist/protocol/transcriptWorker.d.ts +47 -0
  286. package/shared/dist/protocol/transcriptWorker.js +2 -0
  287. package/shared/dist/protocol/workflows.d.ts +1 -0
  288. package/shared/dist/runtimeVersions.d.ts +1 -0
  289. package/shared/dist/runtimeVersions.js +14 -0
  290. package/shared/src/clusterCoordination.ts +7 -1
  291. package/shared/src/protocol/chat.ts +1 -0
  292. package/shared/src/protocol/clientMessages.ts +5 -0
  293. package/shared/src/protocol/clusters.ts +20 -6
  294. package/shared/src/protocol/index.ts +1 -0
  295. package/shared/src/protocol/models.ts +31 -5
  296. package/shared/src/protocol/serverMessages.ts +13 -0
  297. package/shared/src/protocol/settings.ts +2 -3
  298. package/shared/src/protocol/tasks.ts +4 -7
  299. package/shared/src/protocol/transcriptWorker.ts +49 -0
  300. package/shared/src/protocol/workflows.ts +4 -0
  301. package/shared/src/runtimeVersions.ts +14 -0
@@ -15,6 +15,7 @@ import { CodexAppServerWorker, computeMcpSignature, bootstrapSurfaceKey } from '
15
15
  import { codexContextWindowOverride } from '../codexContextWindow.js';
16
16
  import { allowVoiceTools, blockVoiceTools, observeVoiceTools } from '../../voice/operatorTools.js';
17
17
  import { ComputerTurnWatchdog } from '../../voice/turnWatchdog.js';
18
+ import { HELD_BATCH_MS, HELD_CONTINUATION_LIMIT, HELD_WAIT_LIMIT_MS, formatDuration, heldResultNotice, heldResultsMessage, shortCommand, } from './heldCommands.js';
18
19
  const workersByWorkflow = new Map();
19
20
  const compactReservations = new Map();
20
21
  // Children being torn down for a recycle (bootstrap-signature change,
@@ -60,7 +61,7 @@ function resetFailureCount(workflowId) {
60
61
  }
61
62
  // One operator turn against the long-lived worker. ProviderProcess shape
62
63
  // preserved so WorkerManager / seedWorker can stay unchanged.
63
- class CodexAppServerTurn extends EventEmitter {
64
+ export class CodexAppServerTurn extends EventEmitter {
64
65
  worker;
65
66
  config;
66
67
  appendSystemPrompt;
@@ -80,6 +81,24 @@ class CodexAppServerTurn extends EventEmitter {
80
81
  watchdog;
81
82
  stopToolObserver;
82
83
  timeoutReason;
84
+ // docs/PROVIDERS.md - the Arco turn stays open while a command the agent
85
+ // started is still running after its Codex turn completed. Each Codex turn
86
+ // inside it adds its cost; the result is reported once, at the end.
87
+ startedAt = Date.now();
88
+ costUsd = 0;
89
+ lastResult;
90
+ continuations = 0;
91
+ waitedMs = 0;
92
+ waitStartedAt = 0;
93
+ waitTimer;
94
+ inputTimer;
95
+ batchTimer;
96
+ resultSteer;
97
+ // STOP: nothing continues, and no later result restarts the turn.
98
+ stopped = false;
99
+ // Interrupt & send: the wait ends, but the commands stay held so the
100
+ // operator's next turn receives their results.
101
+ interrupting = false;
83
102
  constructor(id, worker, config, appendSystemPrompt, workflowId) {
84
103
  super();
85
104
  this.worker = worker;
@@ -160,12 +179,18 @@ class CodexAppServerTurn extends EventEmitter {
160
179
  });
161
180
  }
162
181
  async interrupt() {
163
- if (!this.settled)
164
- await this.worker.cancelCurrentTurn();
182
+ if (this.settled)
183
+ return;
184
+ this.interrupting = true;
185
+ this.stopWaitClock();
186
+ await this.worker.cancelCurrentTurn();
165
187
  }
166
188
  kill() {
167
189
  if (this.settled)
168
190
  return;
191
+ this.stopped = true;
192
+ this.stopWaitClock();
193
+ this.worker.abandonHeldCommands();
169
194
  // Async; the wrapper's `error` event fires when `turn_settled` lands.
170
195
  void this.worker.cancelCurrentTurn().catch((err) => {
171
196
  if (this.settled)
@@ -223,26 +248,28 @@ class CodexAppServerTurn extends EventEmitter {
223
248
  this.fail('turn settled with no result');
224
249
  return;
225
250
  }
226
- this.settled = true;
227
- this._status = 'completed';
228
- this.unwire();
229
251
  // Successful turn — the spawn-failure circuit breaker resets so any
230
252
  // earlier intermittent crashes stop counting toward the 3-strike cap.
231
253
  resetFailureCount(this.workflowId);
232
- this.emit('result', {
233
- text: this._output.length >= r.text.length ? this._output : r.text,
234
- costUsd: r.costUsd,
235
- durationMs: r.durationMs,
236
- ...(r.usage ? { usage: r.usage } : {}),
237
- ...(typeof r.modelContextWindow === 'number' ? { modelContextWindow: r.modelContextWindow } : {}),
238
- ...(typeof r.freshContextWindow === 'number' ? { freshContextWindow: r.freshContextWindow } : {}),
239
- ...(typeof r.lastPromptTokens === 'number' ? { lastPromptTokens: r.lastPromptTokens } : {}),
240
- // docs/PROVIDERS.md - Codex doesn't expose tool_result bytes
241
- // through the app-server JSON-RPC surface. Sentinel: -1 = unknown.
242
- thinkingBytes: 0,
243
- toolResultBytes: -1,
244
- toolResultBytesRaw: -1,
245
- });
254
+ this.costUsd += r.costUsd ?? 0;
255
+ this.lastResult = r;
256
+ void this.afterCodexTurn();
257
+ };
258
+ const onHeldCommands = () => {
259
+ if (this.settled || this.stopped)
260
+ return;
261
+ if (this.waitStartedAt) {
262
+ // Ends that arrive close together go to the agent in one turn.
263
+ if (!this.batchTimer)
264
+ this.batchTimer = setTimeout(() => { this.batchTimer = undefined; this.reviewWait(); }, HELD_BATCH_MS);
265
+ return;
266
+ }
267
+ // A result that arrives while the final answer is being written waits
268
+ // for the turn to complete and continues it, so it is never lost.
269
+ if (this.worker.hasHeldResults() && !this.resultSteer && !this.lastResult && this.worker.acceptsResultSteer) {
270
+ // A Codex turn is running: the result goes into it, never a second turn.
271
+ this.resultSteer = this.steerResults().finally(() => { this.resultSteer = undefined; });
272
+ }
246
273
  };
247
274
  const onFatal = (reason) => {
248
275
  if (this.settled)
@@ -260,13 +287,15 @@ class CodexAppServerTurn extends EventEmitter {
260
287
  this.worker.on('system_notice', onSystemNotice);
261
288
  this.worker.on('turn_settled', onSettled);
262
289
  this.worker.on('fatal', onFatal);
263
- this.wired.push({ event: 'init', fn: onInit }, { event: 'text', fn: onText }, { event: 'thinking', fn: onThinking }, { event: 'tool_use', fn: onToolUse }, { event: 'primary_artifact', fn: onPrimaryArtifact }, { event: 'system_notice', fn: onSystemNotice }, { event: 'turn_settled', fn: onSettled }, { event: 'fatal', fn: onFatal });
290
+ this.worker.on('held_commands', onHeldCommands);
291
+ this.wired.push({ event: 'init', fn: onInit }, { event: 'text', fn: onText }, { event: 'thinking', fn: onThinking }, { event: 'tool_use', fn: onToolUse }, { event: 'primary_artifact', fn: onPrimaryArtifact }, { event: 'system_notice', fn: onSystemNotice }, { event: 'turn_settled', fn: onSettled }, { event: 'fatal', fn: onFatal }, { event: 'held_commands', fn: onHeldCommands });
264
292
  // Phase 6a unused but harmless — silences "WorkerConfig.appendSystemPrompt
265
293
  // is read-only / accessed once" linter complaint. The field flows
266
294
  // through to beginTurn() at spawn time.
267
295
  void this.config;
268
296
  }
269
297
  unwire() {
298
+ this.stopWaitClock();
270
299
  this.watchdog?.stop();
271
300
  this.watchdog = undefined;
272
301
  this.stopToolObserver?.();
@@ -282,8 +311,174 @@ class CodexAppServerTurn extends EventEmitter {
282
311
  this.settled = true;
283
312
  this._status = 'failed';
284
313
  this.unwire();
314
+ // After Interrupt & send the operator's message runs next and takes the
315
+ // results; any other failure leaves nobody to deliver them to.
316
+ if (!this.interrupting)
317
+ this.worker.abandonHeldCommands();
285
318
  this.emit('error', reason);
286
319
  }
320
+ // ── Waiting on commands the agent started ───────────────────────────
321
+ async afterCodexTurn() {
322
+ // A result steer still in flight either landed in the turn that just
323
+ // ended or comes back to the queue of results; wait to know which.
324
+ if (this.resultSteer)
325
+ await this.resultSteer;
326
+ if (this.settled)
327
+ return;
328
+ const running = this.worker.heldCommands;
329
+ const ready = this.worker.hasHeldResults();
330
+ if (this.stopped || (!ready && running.length === 0))
331
+ return this.finish();
332
+ if (this.continuations >= HELD_CONTINUATION_LIMIT) {
333
+ return this.giveUp(`Arco stopped continuing Codex after ${HELD_CONTINUATION_LIMIT} command results in this turn.`);
334
+ }
335
+ if (ready && (running.length === 0 || this.worker.hasFailedHeldResult()))
336
+ return this.continueWith([]);
337
+ this.startWait();
338
+ }
339
+ startWait() {
340
+ const remaining = HELD_WAIT_LIMIT_MS - this.waitedMs;
341
+ if (remaining <= 0)
342
+ return this.giveUp(`Arco stopped waiting after ${formatDuration(HELD_WAIT_LIMIT_MS)} in this turn.`);
343
+ this.waitStartedAt = Date.now();
344
+ this.worker.showHeldUntil(this.waitStartedAt + remaining);
345
+ this.waitTimer = setTimeout(() => {
346
+ this.stopWaitClock();
347
+ this.giveUp(`Arco stopped waiting after ${formatDuration(HELD_WAIT_LIMIT_MS)} in this turn.`);
348
+ }, remaining);
349
+ this.waitTimer.unref?.();
350
+ this.inputTimer = setInterval(() => this.checkInput(), 500);
351
+ this.inputTimer.unref?.();
352
+ }
353
+ stopWaitClock() {
354
+ if (this.waitStartedAt) {
355
+ this.waitedMs += Date.now() - this.waitStartedAt;
356
+ this.worker.releaseHeldWait();
357
+ }
358
+ this.waitStartedAt = 0;
359
+ clearTimeout(this.waitTimer);
360
+ this.waitTimer = undefined;
361
+ clearInterval(this.inputTimer);
362
+ this.inputTimer = undefined;
363
+ clearTimeout(this.batchTimer);
364
+ this.batchTimer = undefined;
365
+ }
366
+ reviewWait() {
367
+ if (this.settled || !this.waitStartedAt)
368
+ return;
369
+ const running = this.worker.heldCommands;
370
+ const ready = this.worker.hasHeldResults();
371
+ if (ready && (running.length === 0 || this.worker.hasFailedHeldResult())) {
372
+ this.stopWaitClock();
373
+ this.continueWith([]);
374
+ }
375
+ else if (!ready && running.length === 0) {
376
+ // Codex lost the commands (connection or thread closed); the lost
377
+ // line has already been shown.
378
+ this.stopWaitClock();
379
+ this.finish();
380
+ }
381
+ }
382
+ // Direct operator input or an explicit nudge ends the wait. A steer goes
383
+ // to the agent at once; a follow-up waits for the turn to end, so the
384
+ // turn ends here and the follow-up turn takes over the held commands.
385
+ checkInput() {
386
+ if (this.settled || !this.waitStartedAt)
387
+ return;
388
+ const pending = this.config.pendingInput?.();
389
+ if (!pending)
390
+ return;
391
+ const peeked = this.config.peekSteer?.() ?? [];
392
+ if (pending === 'follow-up' || peeked.some(item => item.attachments?.length)) {
393
+ this.stopWaitClock();
394
+ this.emit('system_notice', `Stopped waiting for ${this.runningLabel()}: your message is next. Arco still passes the result on when it ends.`);
395
+ return this.finish();
396
+ }
397
+ const items = this.config.drainSteer?.() ?? [];
398
+ if (!items.length)
399
+ return;
400
+ this.stopWaitClock();
401
+ this.continueWith(items);
402
+ }
403
+ continueWith(items) {
404
+ this.continuations += 1;
405
+ const results = this.worker.takeHeldResults();
406
+ const running = this.worker.heldCommands;
407
+ for (const result of results)
408
+ this.emit('system_notice', heldResultNotice(result, true));
409
+ const message = [
410
+ ...(results.length ? [heldResultsMessage(results, running)] : []),
411
+ ...items.map(item => item.content),
412
+ ...(!results.length && running.length ? [`[Arco] Still running: ${running.map(item => shortCommand(item.command)).join('; ')}. Arco tells you when it ends.`] : []),
413
+ ].join('\n\n');
414
+ this._output += this._output ? '\n\n' : '';
415
+ this.lastResult = undefined;
416
+ this.worker.beginTurn(message, undefined, { continuation: true })
417
+ .then(() => {
418
+ if (items.length)
419
+ this.config.onSteerDelivered?.(items);
420
+ if (this.settled)
421
+ void this.worker.cancelCurrentTurn().catch(() => { });
422
+ })
423
+ .catch((err) => {
424
+ if (this.settled)
425
+ return;
426
+ this.worker.restoreHeldResults(results);
427
+ if (items.length)
428
+ this.config.requeueSteer?.(items, 'follow-up');
429
+ this.fail(err instanceof Error ? err.message : String(err));
430
+ });
431
+ }
432
+ async steerResults() {
433
+ const results = this.worker.takeHeldResults();
434
+ if (!results.length)
435
+ return;
436
+ const delivered = await this.worker.steerText(heldResultsMessage(results, this.worker.heldCommands));
437
+ if (!delivered) {
438
+ this.worker.restoreHeldResults(results);
439
+ return;
440
+ }
441
+ for (const result of results)
442
+ this.emit('system_notice', heldResultNotice(result, false));
443
+ }
444
+ runningLabel() {
445
+ const running = this.worker.heldCommands;
446
+ return running.length ? running.map(item => `\`${shortCommand(item.command)}\``).join(', ') : 'the command';
447
+ }
448
+ giveUp(line) {
449
+ const running = this.worker.heldCommands;
450
+ this.worker.abandonHeldCommands();
451
+ this.emit('system_notice', running.length
452
+ ? `${line} Still running: ${running.map(item => `\`${shortCommand(item.command)}\``).join(', ')}. Its row records how it ends.`
453
+ : line);
454
+ this.finish();
455
+ }
456
+ finish() {
457
+ if (this.settled)
458
+ return;
459
+ const r = this.lastResult;
460
+ if (!r) {
461
+ this.fail('turn settled with no result');
462
+ return;
463
+ }
464
+ this.settled = true;
465
+ this._status = 'completed';
466
+ this.unwire();
467
+ this.emit('result', {
468
+ text: this._output.length >= r.text.length ? this._output : r.text,
469
+ costUsd: this.costUsd,
470
+ durationMs: Math.max(r.durationMs ?? 0, Date.now() - this.startedAt),
471
+ ...(r.usage ? { usage: r.usage } : {}),
472
+ ...(typeof r.modelContextWindow === 'number' ? { modelContextWindow: r.modelContextWindow } : {}),
473
+ ...(typeof r.freshContextWindow === 'number' ? { freshContextWindow: r.freshContextWindow } : {}),
474
+ ...(typeof r.lastPromptTokens === 'number' ? { lastPromptTokens: r.lastPromptTokens } : {}),
475
+ // docs/PROVIDERS.md - Codex doesn't expose tool_result bytes
476
+ // through the app-server JSON-RPC surface. Sentinel: -1 = unknown.
477
+ thinkingBytes: 0,
478
+ toolResultBytes: -1,
479
+ toolResultBytesRaw: -1,
480
+ });
481
+ }
287
482
  }
288
483
  // Long-lived worker accessor. Creates lazily on first turn for a given
289
484
  // workflow; subsequent turns reuse the cached worker (same `app-server`
@@ -311,6 +506,26 @@ function acquireWorker(workflowId, config, resumeSessionId) {
311
506
  }
312
507
  const fresh = new CodexAppServerWorker(workflowId, config, resumeSessionId);
313
508
  workersByWorkflow.set(workflowId, fresh);
509
+ fresh.on('late_command', (event, lateCommand) => {
510
+ void import('../../server/broadcast.js').then(({ broadcastWorkflow }) => {
511
+ const { name: tool, ...entry } = event;
512
+ broadcastWorkflow(workflowId, {
513
+ ...entry, type: 'primary_tool_use', workflowId, tool, lateCommand,
514
+ ...(lateCommand?.state === 'finished' ? {} : { status: 'in_progress' }),
515
+ });
516
+ if (lateCommand?.state === 'lost') {
517
+ let command = 'A command';
518
+ try {
519
+ command = JSON.parse(event.input).command || command;
520
+ }
521
+ catch { /* use the fallback */ }
522
+ broadcastWorkflow(workflowId, {
523
+ type: 'system_notice', workflowId,
524
+ content: `Codex lost the result for ${command.slice(0, 240)} when its connection closed.`,
525
+ });
526
+ }
527
+ }).catch(error => console.warn('[arco] could not record a late Codex command result', error));
528
+ });
314
529
  fresh.on('fatal', (reason) => {
315
530
  // Drop the cache entry so the next operator turn re-spawns. Don't
316
531
  // dispose() — the entry is already torn down by `onChildDeath`.
@@ -325,6 +540,9 @@ function acquireWorker(workflowId, config, resumeSessionId) {
325
540
  });
326
541
  return fresh;
327
542
  }
543
+ export function runningCodexLateCommands(workflowId) {
544
+ return workersByWorkflow.get(workflowId)?.runningLateCommands ?? [];
545
+ }
328
546
  // Operator-triggered native compaction against the long-lived per-workflow
329
547
  // thread (the app-server equivalent of `/compact` in Codex CLI). Out-of-band
330
548
  // vs. the per-turn CodexAppServerTurn wrapper — it talks straight to the
@@ -0,0 +1,62 @@
1
+ import type { CodexLateCommand, PrimaryToolUseMessage } from '@arco/shared';
2
+ import type { ToolUseEvent } from './worker.js';
3
+ export declare function isLongRunningProgram(command: string): boolean;
4
+ export interface HeldCommandResult {
5
+ itemId: string;
6
+ command: string;
7
+ cwd?: string;
8
+ startedAt: number;
9
+ endedAt: number;
10
+ exitCode?: number;
11
+ output?: string;
12
+ failed: boolean;
13
+ }
14
+ export declare function commandText(event: Pick<ToolUseEvent, 'input'>): {
15
+ command: string;
16
+ cwd?: string;
17
+ };
18
+ export declare class CodexLateCommands {
19
+ private readonly publish;
20
+ private readonly onHeldChange;
21
+ private readonly commands;
22
+ private readonly results;
23
+ constructor(publish: (event: ToolUseEvent, state: NonNullable<PrimaryToolUseMessage['lateCommand']>) => void, onHeldChange?: () => void);
24
+ start(turnId: string, event: ToolUseEvent): void;
25
+ /** True once the long-lived publisher owns this completion. */
26
+ complete(turnId: string, event: ToolUseEvent): boolean;
27
+ /**
28
+ * A command that ended inside its own turn after the agent's final answer
29
+ * had started: the model never saw the result, so it is kept for delivery
30
+ * once that turn has completed. The completion is still shown in the turn.
31
+ * False when the command is unknown, belongs to another turn or has
32
+ * already outlived its turn.
33
+ */
34
+ completeUnseen(turnId: string, event: ToolUseEvent): boolean;
35
+ settle(turnId: string): void;
36
+ /** Commands the agent still waits on, oldest first. */
37
+ running(): Array<{
38
+ itemId: string;
39
+ command: string;
40
+ startedAt: number;
41
+ }>;
42
+ hasResults(): boolean;
43
+ hasFailedResult(): boolean;
44
+ /** Ended results; each is handed out exactly once. */
45
+ takeResults(): HeldCommandResult[];
46
+ /** Put back results whose delivery failed, ahead of any newer ones. */
47
+ restoreResults(results: HeldCommandResult[]): void;
48
+ /** The Arco turn now waits on the held commands, at most until `until`. */
49
+ hold(until: number): void;
50
+ /** The turn no longer waits (it continued, ended or was stopped). */
51
+ release(): void;
52
+ /**
53
+ * Nobody waits on these commands any more (STOP, the wait limit, a failed
54
+ * turn). They keep running and their rows still record how they end, but
55
+ * no result reaches the agent.
56
+ */
57
+ abandon(): void;
58
+ snapshot(): CodexLateCommand[];
59
+ disconnect(): void;
60
+ private result;
61
+ private notify;
62
+ }
@@ -0,0 +1,195 @@
1
+ const DISPLAY_MS = 5 * 60_000;
2
+ const MAX_COMMANDS = 64;
3
+ // A program meant to keep running (a server or a watcher) must never hold a
4
+ // turn open. Programs the shell put in the background (`&`, `nohup`) end the
5
+ // shell at once, so Codex completes their item inside the turn; only a known
6
+ // long-running program started in the foreground needs this pattern. Kept
7
+ // narrower than the preview detector's pattern: `vite build` or `deno run
8
+ // script.ts` end on their own and must still be waited on.
9
+ const LONG_RUNNING_RE = new RegExp([
10
+ String.raw `\b(?:npm|pnpm|yarn|bun)\s+(?:run\s+)?(?:dev|start|serve|watch)\b`,
11
+ String.raw `\b(?:vite|next|astro|nuxt|remix|gatsby|docusaurus)\s+(?:dev|develop|start|serve|preview)\b`,
12
+ String.raw `\bvite\s*(?:$|['"]|--(?:host|port)\b)`,
13
+ String.raw `\bpython3?\s+-m\s+http\.server\b`,
14
+ String.raw `\buvicorn\b`, String.raw `\bflask\s+run\b`, String.raw `\brails\s+s(?:erver)?\b`, String.raw `\bphp\s+-S\b`,
15
+ String.raw `(?:^|\s)--watch\b`, String.raw `\bwatch\s+-n\b`, String.raw `\btail\s+(?:-\w+\s+)*-\w*[fF]\b`,
16
+ String.raw `\bsleep\s+infinity\b`,
17
+ String.raw `\bdocker[\s-]compose\s+(?:\S+\s+)*up\b(?![^|;&]*\s(?:-d|--detach)\b)`,
18
+ ].join('|'));
19
+ export function isLongRunningProgram(command) {
20
+ return LONG_RUNNING_RE.test(command);
21
+ }
22
+ export function commandText(event) {
23
+ try {
24
+ const parsed = JSON.parse(event.input);
25
+ return {
26
+ command: typeof parsed.command === 'string' ? parsed.command : 'a shell command',
27
+ ...(typeof parsed.cwd === 'string' ? { cwd: parsed.cwd } : {}),
28
+ };
29
+ }
30
+ catch {
31
+ return { command: 'a shell command' };
32
+ }
33
+ }
34
+ export class CodexLateCommands {
35
+ publish;
36
+ onHeldChange;
37
+ commands = new Map();
38
+ // Ended held commands whose result has not yet been delivered to the agent.
39
+ results = [];
40
+ constructor(publish, onHeldChange = () => { }) {
41
+ this.publish = publish;
42
+ this.onHeldChange = onHeldChange;
43
+ }
44
+ start(turnId, event) {
45
+ if (!event.itemId || this.commands.has(event.itemId))
46
+ return;
47
+ if (this.commands.size >= MAX_COMMANDS) {
48
+ const oldest = this.commands.keys().next().value;
49
+ if (oldest) {
50
+ const previous = this.commands.get(oldest);
51
+ if (previous.waitingUntil)
52
+ this.notify(previous, 'untracked');
53
+ clearTimeout(previous.timer);
54
+ this.commands.delete(oldest);
55
+ if (previous.held)
56
+ this.onHeldChange();
57
+ }
58
+ }
59
+ this.commands.set(event.itemId, { turnId, event, startedAt: Date.now() });
60
+ }
61
+ /** True once the long-lived publisher owns this completion. */
62
+ complete(turnId, event) {
63
+ const id = event.itemId;
64
+ const command = id ? this.commands.get(id) : undefined;
65
+ if (!id || !command || command.turnId !== turnId)
66
+ return false;
67
+ this.commands.delete(id);
68
+ clearTimeout(command.timer);
69
+ if (!command.waitingUntil)
70
+ return false;
71
+ this.notify(command, 'finished', event);
72
+ if (command.held) {
73
+ this.results.push(this.result(command, event));
74
+ this.onHeldChange();
75
+ }
76
+ return true;
77
+ }
78
+ /**
79
+ * A command that ended inside its own turn after the agent's final answer
80
+ * had started: the model never saw the result, so it is kept for delivery
81
+ * once that turn has completed. The completion is still shown in the turn.
82
+ * False when the command is unknown, belongs to another turn or has
83
+ * already outlived its turn.
84
+ */
85
+ completeUnseen(turnId, event) {
86
+ const id = event.itemId;
87
+ const command = id ? this.commands.get(id) : undefined;
88
+ if (!id || !command || command.turnId !== turnId || command.waitingUntil)
89
+ return false;
90
+ this.commands.delete(id);
91
+ clearTimeout(command.timer);
92
+ if (!isLongRunningProgram(commandText(command.event).command)) {
93
+ this.results.push(this.result(command, event));
94
+ this.onHeldChange();
95
+ }
96
+ return true;
97
+ }
98
+ settle(turnId) {
99
+ let held = false;
100
+ for (const command of this.commands.values()) {
101
+ if (command.turnId !== turnId || command.waitingUntil)
102
+ continue;
103
+ command.waitingUntil = Date.now() + DISPLAY_MS;
104
+ command.held = !isLongRunningProgram(commandText(command.event).command);
105
+ held ||= command.held;
106
+ this.notify(command, 'running');
107
+ command.timer = setTimeout(() => this.notify(command, 'untracked'), DISPLAY_MS);
108
+ command.timer.unref();
109
+ }
110
+ if (held)
111
+ this.onHeldChange();
112
+ }
113
+ /** Commands the agent still waits on, oldest first. */
114
+ running() {
115
+ return [...this.commands.values()].flatMap(command => command.held && command.event.itemId
116
+ ? [{ itemId: command.event.itemId, command: commandText(command.event).command, startedAt: command.startedAt }] : []);
117
+ }
118
+ hasResults() { return this.results.length > 0; }
119
+ hasFailedResult() { return this.results.some(result => result.failed); }
120
+ /** Ended results; each is handed out exactly once. */
121
+ takeResults() { return this.results.splice(0); }
122
+ /** Put back results whose delivery failed, ahead of any newer ones. */
123
+ restoreResults(results) {
124
+ if (results.length)
125
+ this.results.unshift(...results);
126
+ }
127
+ /** The Arco turn now waits on the held commands, at most until `until`. */
128
+ hold(until) {
129
+ for (const command of this.commands.values()) {
130
+ if (!command.held || !command.waitingUntil)
131
+ continue;
132
+ command.waiting = true;
133
+ if (command.waitingUntil < until) {
134
+ command.waitingUntil = until;
135
+ clearTimeout(command.timer);
136
+ command.timer = setTimeout(() => this.notify(command, 'untracked'), Math.max(0, until - Date.now()));
137
+ command.timer.unref();
138
+ }
139
+ this.notify(command, 'running');
140
+ }
141
+ }
142
+ /** The turn no longer waits (it continued, ended or was stopped). */
143
+ release() {
144
+ for (const command of this.commands.values()) {
145
+ if (!command.waiting)
146
+ continue;
147
+ command.waiting = false;
148
+ this.notify(command, 'running');
149
+ }
150
+ }
151
+ /**
152
+ * Nobody waits on these commands any more (STOP, the wait limit, a failed
153
+ * turn). They keep running and their rows still record how they end, but
154
+ * no result reaches the agent.
155
+ */
156
+ abandon() {
157
+ this.release();
158
+ this.results.length = 0;
159
+ for (const command of this.commands.values())
160
+ command.held = false;
161
+ }
162
+ snapshot() {
163
+ const now = Date.now();
164
+ return [...this.commands.values()].flatMap(({ event, startedAt, waitingUntil, waiting }) => event.itemId && waitingUntil && waitingUntil > now
165
+ ? [{ itemId: event.itemId, input: event.input, startedAt, waitingUntil, ...(waiting ? { waiting } : {}) }] : []);
166
+ }
167
+ disconnect() {
168
+ const held = this.results.length > 0 || [...this.commands.values()].some(command => command.held);
169
+ for (const command of this.commands.values()) {
170
+ clearTimeout(command.timer);
171
+ this.notify(command, 'lost');
172
+ }
173
+ this.commands.clear();
174
+ this.results.length = 0;
175
+ if (held)
176
+ this.onHeldChange();
177
+ }
178
+ result(command, event) {
179
+ const { command: text, cwd } = commandText(command.event);
180
+ return {
181
+ itemId: command.event.itemId, command: text, ...(cwd ? { cwd } : {}),
182
+ startedAt: command.startedAt, endedAt: Date.now(),
183
+ ...(typeof event.exitCode === 'number' ? { exitCode: event.exitCode } : {}),
184
+ ...(typeof event.output === 'string' ? { output: event.output } : {}),
185
+ failed: event.status === 'failed' || (typeof event.exitCode === 'number' && event.exitCode !== 0),
186
+ };
187
+ }
188
+ notify(command, state, result) {
189
+ this.publish(result ?? command.event, {
190
+ state, startedAt: command.startedAt, waitingUntil: command.waitingUntil ?? Date.now(),
191
+ ...(command.waiting && state === 'running' ? { waiting: true } : {}),
192
+ });
193
+ }
194
+ }
195
+ //# sourceMappingURL=lateCommands.js.map
@@ -1,3 +1,4 @@
1
+ import { type HeldCommandResult } from './lateCommands.js';
1
2
  import { EventEmitter } from 'events';
2
3
  import { type ProviderName, type WorkerConfig } from '@arco/shared';
3
4
  import type { ThreadStartParams } from './bindings/v2/ThreadStartParams.js';
@@ -81,7 +82,9 @@ export declare class CodexAppServerWorker extends EventEmitter {
81
82
  updateConfig(next: WorkerConfig): void;
82
83
  ensureStarted(): Promise<void>;
83
84
  private clearThreadGoal;
84
- beginTurn(prompt: string, appendSystemPrompt: string | undefined): Promise<void>;
85
+ beginTurn(prompt: string, appendSystemPrompt: string | undefined, options?: {
86
+ continuation?: boolean;
87
+ }): Promise<void>;
85
88
  private cancellation;
86
89
  cancelCurrentTurn(): Promise<void>;
87
90
  private interruptCurrentTurn;
@@ -96,6 +99,25 @@ export declare class CodexAppServerWorker extends EventEmitter {
96
99
  private requeueSteer;
97
100
  dispose(): Promise<void>;
98
101
  private buildSandboxPolicy;
102
+ private readonly lateCommands;
103
+ get runningLateCommands(): import("@arco/shared").CodexLateCommand[];
104
+ get heldCommands(): {
105
+ itemId: string;
106
+ command: string;
107
+ startedAt: number;
108
+ }[];
109
+ hasHeldResults(): boolean;
110
+ hasFailedHeldResult(): boolean;
111
+ takeHeldResults(): HeldCommandResult[];
112
+ restoreHeldResults(results: HeldCommandResult[]): void;
113
+ showHeldUntil(until: number): void;
114
+ releaseHeldWait(): void;
115
+ get acceptsResultSteer(): boolean;
116
+ abandonHeldCommands(): void;
117
+ /** Add Arco's text to the running turn. False when no turn takes it. */
118
+ steerText(text: string): Promise<boolean>;
119
+ private commandToolUse;
120
+ private handleCommandItem;
99
121
  private onNotification;
100
122
  private countedCompactionTurns;
101
123
  private countCompaction;