@elie-laloum/outpost 4.2.0 → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (450) hide show
  1. package/CHANGELOG.md +27 -0
  2. package/README.md +5 -3
  3. package/dist/{cli/init-authentication.constants.js → adapters/agents/authentication.constants.js} +1 -1
  4. package/dist/adapters/agents/authentication.constants.js.map +1 -0
  5. package/dist/adapters/agents/authentication.d.ts +2 -0
  6. package/dist/adapters/agents/authentication.js +52 -0
  7. package/dist/adapters/agents/authentication.js.map +1 -0
  8. package/dist/adapters/agents/claude-adapter.d.ts +2 -2
  9. package/dist/adapters/agents/claude-adapter.js +30 -2
  10. package/dist/adapters/agents/claude-adapter.js.map +1 -1
  11. package/dist/adapters/agents/claude-request.d.ts +2 -2
  12. package/dist/adapters/agents/claude-request.js +3 -3
  13. package/dist/adapters/agents/claude-request.js.map +1 -1
  14. package/dist/adapters/agents/codex-adapter.d.ts +2 -2
  15. package/dist/adapters/agents/codex-adapter.js +17 -1
  16. package/dist/adapters/agents/codex-adapter.js.map +1 -1
  17. package/dist/adapters/agents/codex-provider.d.ts +2 -2
  18. package/dist/adapters/agents/codex-provider.js +1 -1
  19. package/dist/adapters/agents/codex-provider.js.map +1 -1
  20. package/dist/adapters/agents/codex-request.d.ts +2 -2
  21. package/dist/adapters/agents/codex-request.js +3 -3
  22. package/dist/adapters/agents/codex-request.js.map +1 -1
  23. package/dist/adapters/agents/gemini-adapter.d.ts +2 -2
  24. package/dist/adapters/agents/gemini-adapter.js +20 -1
  25. package/dist/adapters/agents/gemini-adapter.js.map +1 -1
  26. package/dist/adapters/agents/gemini-request.d.ts +2 -1
  27. package/dist/adapters/agents/gemini-request.js +1 -1
  28. package/dist/adapters/agents/gemini-request.js.map +1 -1
  29. package/dist/adapters/agents/gemini.types.d.ts +2 -1
  30. package/dist/adapters/agents/gemini.types.js.map +1 -1
  31. package/dist/adapters/agents/model-support.constants.d.ts +6 -0
  32. package/dist/adapters/agents/model-support.constants.js +18 -0
  33. package/dist/adapters/agents/model-support.constants.js.map +1 -0
  34. package/dist/adapters/agents/model-support.d.ts +4 -0
  35. package/dist/adapters/agents/model-support.js +11 -0
  36. package/dist/adapters/agents/model-support.js.map +1 -0
  37. package/dist/adapters/agents/settings.types.d.ts +11 -3
  38. package/dist/adapters/agents/settings.types.js.map +1 -1
  39. package/dist/adapters/models/anthropic-model-provider.constants.d.ts +3 -0
  40. package/dist/adapters/models/anthropic-model-provider.constants.js +17 -0
  41. package/dist/adapters/models/anthropic-model-provider.constants.js.map +1 -0
  42. package/dist/adapters/models/anthropic-model-provider.d.ts +3 -0
  43. package/dist/adapters/models/anthropic-model-provider.js +31 -0
  44. package/dist/adapters/models/anthropic-model-provider.js.map +1 -0
  45. package/dist/adapters/models/anthropic-model-provider.types.d.ts +7 -0
  46. package/dist/adapters/models/anthropic-model-provider.types.js +2 -0
  47. package/dist/adapters/models/anthropic-model-provider.types.js.map +1 -0
  48. package/dist/adapters/models/anthropic-request.d.ts +4 -0
  49. package/dist/adapters/models/anthropic-request.js +81 -0
  50. package/dist/adapters/models/anthropic-request.js.map +1 -0
  51. package/dist/adapters/models/anthropic-response.d.ts +3 -0
  52. package/dist/adapters/models/anthropic-response.js +55 -0
  53. package/dist/adapters/models/anthropic-response.js.map +1 -0
  54. package/dist/adapters/models/anthropic-stream.d.ts +2 -0
  55. package/dist/adapters/models/anthropic-stream.js +96 -0
  56. package/dist/adapters/models/anthropic-stream.js.map +1 -0
  57. package/dist/adapters/models/http-provider.d.ts +3 -0
  58. package/dist/adapters/models/http-provider.js +113 -0
  59. package/dist/adapters/models/http-provider.js.map +1 -0
  60. package/dist/adapters/models/{openai-http.js → model-http.js} +1 -1
  61. package/dist/adapters/models/model-http.js.map +1 -0
  62. package/dist/adapters/models/model-protocol.types.d.ts +41 -0
  63. package/dist/adapters/models/model-protocol.types.js +2 -0
  64. package/dist/adapters/models/model-protocol.types.js.map +1 -0
  65. package/dist/adapters/models/model-request.d.ts +2 -0
  66. package/dist/adapters/models/model-request.js +18 -0
  67. package/dist/adapters/models/model-request.js.map +1 -0
  68. package/dist/adapters/models/model-response.d.ts +7 -0
  69. package/dist/adapters/models/model-response.js +41 -0
  70. package/dist/adapters/models/model-response.js.map +1 -0
  71. package/dist/adapters/models/{openai-compatible.constants.js → model.constants.js} +6 -1
  72. package/dist/adapters/models/model.constants.js.map +1 -0
  73. package/dist/adapters/models/openai-chat-stream.d.ts +2 -0
  74. package/dist/adapters/models/openai-chat-stream.js +66 -0
  75. package/dist/adapters/models/openai-chat-stream.js.map +1 -0
  76. package/dist/adapters/models/openai-chat.d.ts +4 -0
  77. package/dist/adapters/models/openai-chat.js +108 -0
  78. package/dist/adapters/models/openai-chat.js.map +1 -0
  79. package/dist/adapters/models/openai-model-provider.d.ts +3 -0
  80. package/dist/adapters/models/openai-model-provider.js +13 -0
  81. package/dist/adapters/models/openai-model-provider.js.map +1 -0
  82. package/dist/adapters/models/openai-model-provider.types.d.ts +4 -0
  83. package/dist/adapters/models/openai-model-provider.types.js +2 -0
  84. package/dist/adapters/models/openai-model-provider.types.js.map +1 -0
  85. package/dist/adapters/models/openai-protocols.d.ts +2 -0
  86. package/dist/adapters/models/openai-protocols.js +22 -0
  87. package/dist/adapters/models/openai-protocols.js.map +1 -0
  88. package/dist/adapters/models/openai-responses-stream.d.ts +2 -0
  89. package/dist/adapters/models/openai-responses-stream.js +35 -0
  90. package/dist/adapters/models/openai-responses-stream.js.map +1 -0
  91. package/dist/adapters/models/openai-responses.d.ts +4 -0
  92. package/dist/adapters/models/openai-responses.js +107 -0
  93. package/dist/adapters/models/openai-responses.js.map +1 -0
  94. package/dist/adapters/models/openai-usage.d.ts +3 -0
  95. package/dist/adapters/models/openai-usage.js +20 -0
  96. package/dist/adapters/models/openai-usage.js.map +1 -0
  97. package/dist/adapters/models/stop-reasons.constants.d.ts +4 -0
  98. package/dist/adapters/models/stop-reasons.constants.js +19 -0
  99. package/dist/adapters/models/stop-reasons.constants.js.map +1 -0
  100. package/dist/adapters/models/stream-events.d.ts +3 -0
  101. package/dist/adapters/models/stream-events.js +22 -0
  102. package/dist/adapters/models/stream-events.js.map +1 -0
  103. package/dist/adapters/tools/edit-tools.d.ts +2 -0
  104. package/dist/adapters/tools/edit-tools.js +84 -0
  105. package/dist/adapters/tools/edit-tools.js.map +1 -0
  106. package/dist/adapters/tools/file-tools.d.ts +2 -0
  107. package/dist/adapters/tools/file-tools.js +97 -0
  108. package/dist/adapters/tools/file-tools.js.map +1 -0
  109. package/dist/adapters/tools/git-tools.d.ts +2 -0
  110. package/dist/adapters/tools/git-tools.js +54 -0
  111. package/dist/adapters/tools/git-tools.js.map +1 -0
  112. package/dist/adapters/tools/sandbox-files.d.ts +10 -0
  113. package/dist/adapters/tools/sandbox-files.js +60 -0
  114. package/dist/adapters/tools/sandbox-files.js.map +1 -0
  115. package/dist/adapters/tools/search-tools.d.ts +2 -0
  116. package/dist/adapters/tools/search-tools.js +65 -0
  117. package/dist/adapters/tools/search-tools.js.map +1 -0
  118. package/dist/adapters/tools/shell-tools.d.ts +3 -0
  119. package/dist/adapters/tools/shell-tools.js +38 -0
  120. package/dist/adapters/tools/shell-tools.js.map +1 -0
  121. package/dist/adapters/tools/tools.constants.d.ts +11 -0
  122. package/dist/adapters/tools/tools.constants.js +17 -0
  123. package/dist/adapters/tools/tools.constants.js.map +1 -0
  124. package/dist/adapters/tools/tools.types.d.ts +41 -0
  125. package/dist/adapters/tools/tools.types.js +2 -0
  126. package/dist/adapters/tools/tools.types.js.map +1 -0
  127. package/dist/application/activity-watchdog.js +15 -2
  128. package/dist/application/activity-watchdog.js.map +1 -1
  129. package/dist/application/agent-bootstrap.d.ts +2 -2
  130. package/dist/application/agent-bootstrap.js +2 -0
  131. package/dist/application/agent-bootstrap.js.map +1 -1
  132. package/dist/application/agent-storage.d.ts +3 -2
  133. package/dist/application/agent-storage.js +9 -2
  134. package/dist/application/agent-storage.js.map +1 -1
  135. package/dist/application/agent-turn.d.ts +3 -3
  136. package/dist/application/agent-turn.js +7 -1
  137. package/dist/application/agent-turn.js.map +1 -1
  138. package/dist/application/attach.js +1 -0
  139. package/dist/application/attach.js.map +1 -1
  140. package/dist/application/custom-turn.d.ts +5 -0
  141. package/dist/application/custom-turn.js +190 -0
  142. package/dist/application/custom-turn.js.map +1 -0
  143. package/dist/application/dispatch-observation.d.ts +3 -0
  144. package/dist/application/dispatch-observation.js +51 -0
  145. package/dist/application/dispatch-observation.js.map +1 -0
  146. package/dist/application/dispatch-observation.types.d.ts +5 -0
  147. package/dist/application/dispatch-observation.types.js +2 -0
  148. package/dist/application/dispatch-observation.types.js.map +1 -0
  149. package/dist/application/dispatch-validation.d.ts +2 -2
  150. package/dist/application/dispatch-validation.js.map +1 -1
  151. package/dist/application/dispatch.js +8 -3
  152. package/dist/application/dispatch.js.map +1 -1
  153. package/dist/application/doctor-image.js +3 -3
  154. package/dist/application/doctor-image.js.map +1 -1
  155. package/dist/application/doctor-protocol.js +9 -4
  156. package/dist/application/doctor-protocol.js.map +1 -1
  157. package/dist/application/doctor-sandbox.js +4 -4
  158. package/dist/application/doctor-sandbox.js.map +1 -1
  159. package/dist/application/doctor-sandbox.types.d.ts +2 -2
  160. package/dist/application/doctor-sandbox.types.js.map +1 -1
  161. package/dist/application/doctor.constants.d.ts +1 -1
  162. package/dist/application/doctor.constants.js +1 -1
  163. package/dist/application/doctor.constants.js.map +1 -1
  164. package/dist/application/doctor.js +10 -9
  165. package/dist/application/doctor.js.map +1 -1
  166. package/dist/application/doctor.types.d.ts +3 -3
  167. package/dist/application/doctor.types.js.map +1 -1
  168. package/dist/application/execution.d.ts +2 -2
  169. package/dist/application/execution.js +1 -1
  170. package/dist/application/execution.js.map +1 -1
  171. package/dist/application/execution.types.d.ts +9 -2
  172. package/dist/application/execution.types.js.map +1 -1
  173. package/dist/application/harness-context.d.ts +2 -0
  174. package/dist/application/harness-context.js +54 -0
  175. package/dist/application/harness-context.js.map +1 -0
  176. package/dist/application/harness-history.d.ts +3 -0
  177. package/dist/application/harness-history.js +17 -0
  178. package/dist/application/harness-history.js.map +1 -0
  179. package/dist/application/harness-hooks.d.ts +9 -0
  180. package/dist/application/harness-hooks.js +90 -0
  181. package/dist/application/harness-hooks.js.map +1 -0
  182. package/dist/application/harness-loop.d.ts +2 -0
  183. package/dist/application/harness-loop.js +132 -0
  184. package/dist/application/harness-loop.js.map +1 -0
  185. package/dist/application/harness.types.d.ts +55 -0
  186. package/dist/application/harness.types.js +2 -0
  187. package/dist/application/harness.types.js.map +1 -0
  188. package/dist/application/lifecycle.constants.d.ts +1 -1
  189. package/dist/application/lifecycle.constants.js +1 -1
  190. package/dist/application/lifecycle.constants.js.map +1 -1
  191. package/dist/application/outpost.types.d.ts +6 -6
  192. package/dist/application/outpost.types.js.map +1 -1
  193. package/dist/application/remote-download.js +1 -1
  194. package/dist/application/remote-download.js.map +1 -1
  195. package/dist/application/sandbox-agents.js +12 -4
  196. package/dist/application/sandbox-agents.js.map +1 -1
  197. package/dist/application/sandbox-attach.js +5 -2
  198. package/dist/application/sandbox-attach.js.map +1 -1
  199. package/dist/application/sandbox-dispatch.js +3 -3
  200. package/dist/application/sandbox-dispatch.js.map +1 -1
  201. package/dist/application/sandbox-provision.js +13 -10
  202. package/dist/application/sandbox-provision.js.map +1 -1
  203. package/dist/application/sandbox-session.types.d.ts +8 -8
  204. package/dist/application/sandbox-session.types.js.map +1 -1
  205. package/dist/application/sandbox.js +6 -3
  206. package/dist/application/sandbox.js.map +1 -1
  207. package/dist/application/speculation.js +1 -1
  208. package/dist/application/speculation.js.map +1 -1
  209. package/dist/application/speculation.types.d.ts +3 -3
  210. package/dist/application/speculation.types.js.map +1 -1
  211. package/dist/application/tasks.types.d.ts +2 -2
  212. package/dist/application/tasks.types.js.map +1 -1
  213. package/dist/application/tool-execution.d.ts +3 -0
  214. package/dist/application/tool-execution.js +211 -0
  215. package/dist/application/tool-execution.js.map +1 -0
  216. package/dist/cli/commands.js +4 -2
  217. package/dist/cli/commands.js.map +1 -1
  218. package/dist/cli/doctor-command.js +6 -6
  219. package/dist/cli/doctor-command.js.map +1 -1
  220. package/dist/cli/init-authentication.js +6 -7
  221. package/dist/cli/init-authentication.js.map +1 -1
  222. package/dist/cli/init-command.js +3 -3
  223. package/dist/cli/init-command.js.map +1 -1
  224. package/dist/cli/main.constants.d.ts +4 -4
  225. package/dist/cli/main.constants.js +4 -4
  226. package/dist/cli/main.constants.js.map +1 -1
  227. package/dist/cli/recovery-command.js +1 -1
  228. package/dist/cli/recovery-command.js.map +1 -1
  229. package/dist/cli/scaffold-files.js +5 -4
  230. package/dist/cli/scaffold-files.js.map +1 -1
  231. package/dist/cli/scaffold-validation.js +13 -10
  232. package/dist/cli/scaffold-validation.js.map +1 -1
  233. package/dist/cli/scaffold.js +8 -4
  234. package/dist/cli/scaffold.js.map +1 -1
  235. package/dist/cli/scaffold.types.d.ts +1 -1
  236. package/dist/cli/scaffold.types.js.map +1 -1
  237. package/dist/cli/starters.js +8 -8
  238. package/dist/cli/starters.js.map +1 -1
  239. package/dist/domain/agent-model.d.ts +3 -0
  240. package/dist/domain/agent-model.js +22 -0
  241. package/dist/domain/agent-model.js.map +1 -0
  242. package/dist/domain/agent.d.ts +4 -0
  243. package/dist/domain/agent.js +32 -0
  244. package/dist/domain/agent.js.map +1 -0
  245. package/dist/domain/agent.types.d.ts +69 -2
  246. package/dist/domain/agent.types.js.map +1 -1
  247. package/dist/domain/context.constants.d.ts +7 -0
  248. package/dist/domain/context.constants.js +8 -0
  249. package/dist/domain/context.constants.js.map +1 -0
  250. package/dist/domain/context.d.ts +4 -0
  251. package/dist/domain/context.js +81 -0
  252. package/dist/domain/context.js.map +1 -0
  253. package/dist/domain/context.types.d.ts +26 -0
  254. package/dist/domain/context.types.js +2 -0
  255. package/dist/domain/context.types.js.map +1 -0
  256. package/dist/domain/dispatch-telemetry.types.d.ts +12 -0
  257. package/dist/domain/dispatch-telemetry.types.js +2 -0
  258. package/dist/domain/dispatch-telemetry.types.js.map +1 -0
  259. package/dist/domain/errors.types.d.ts +1 -1
  260. package/dist/domain/errors.types.js.map +1 -1
  261. package/dist/domain/glob.d.ts +2 -0
  262. package/dist/domain/glob.js +25 -0
  263. package/dist/domain/glob.js.map +1 -0
  264. package/dist/domain/glob.types.d.ts +1 -0
  265. package/dist/domain/glob.types.js +2 -0
  266. package/dist/domain/glob.types.js.map +1 -0
  267. package/dist/domain/harness.constants.d.ts +11 -0
  268. package/dist/domain/harness.constants.js +24 -0
  269. package/dist/domain/harness.constants.js.map +1 -0
  270. package/dist/domain/harness.d.ts +2 -0
  271. package/dist/domain/harness.js +89 -0
  272. package/dist/domain/harness.js.map +1 -0
  273. package/dist/domain/harness.types.d.ts +60 -0
  274. package/dist/domain/harness.types.js +2 -0
  275. package/dist/domain/harness.types.js.map +1 -0
  276. package/dist/domain/hook.constants.d.ts +3 -0
  277. package/dist/domain/hook.constants.js +10 -0
  278. package/dist/domain/hook.constants.js.map +1 -0
  279. package/dist/domain/hook.d.ts +3 -0
  280. package/dist/domain/hook.js +25 -0
  281. package/dist/domain/hook.js.map +1 -0
  282. package/dist/domain/hook.types.d.ts +66 -0
  283. package/dist/domain/hook.types.js +2 -0
  284. package/dist/domain/hook.types.js.map +1 -0
  285. package/dist/domain/instructions.d.ts +3 -0
  286. package/dist/domain/instructions.js +25 -0
  287. package/dist/domain/instructions.js.map +1 -0
  288. package/dist/domain/model-messages.d.ts +5 -0
  289. package/dist/domain/model-messages.js +81 -0
  290. package/dist/domain/model-messages.js.map +1 -0
  291. package/dist/domain/model-messages.types.d.ts +6 -0
  292. package/dist/domain/model-messages.types.js +2 -0
  293. package/dist/domain/model-messages.types.js.map +1 -0
  294. package/dist/domain/model.constants.d.ts +4 -0
  295. package/dist/domain/model.constants.js +16 -0
  296. package/dist/domain/model.constants.js.map +1 -0
  297. package/dist/domain/model.types.d.ts +59 -2
  298. package/dist/domain/model.types.js.map +1 -1
  299. package/dist/domain/permissions.d.ts +3 -0
  300. package/dist/domain/permissions.js +92 -0
  301. package/dist/domain/permissions.js.map +1 -0
  302. package/dist/domain/permissions.types.d.ts +34 -0
  303. package/dist/domain/permissions.types.js +2 -0
  304. package/dist/domain/permissions.types.js.map +1 -0
  305. package/dist/domain/response.js +3 -2
  306. package/dist/domain/response.js.map +1 -1
  307. package/dist/domain/response.types.d.ts +12 -0
  308. package/dist/domain/response.types.js.map +1 -1
  309. package/dist/domain/skill.constants.d.ts +2 -0
  310. package/dist/domain/skill.constants.js +8 -0
  311. package/dist/domain/skill.constants.js.map +1 -0
  312. package/dist/domain/skill.d.ts +8 -0
  313. package/dist/domain/skill.js +79 -0
  314. package/dist/domain/skill.js.map +1 -0
  315. package/dist/domain/skill.types.d.ts +18 -0
  316. package/dist/domain/skill.types.js +2 -0
  317. package/dist/domain/skill.types.js.map +1 -0
  318. package/dist/domain/standard-schema.d.ts +6 -0
  319. package/dist/domain/standard-schema.js +45 -0
  320. package/dist/domain/standard-schema.js.map +1 -0
  321. package/dist/domain/tool-schema.d.ts +3 -0
  322. package/dist/domain/tool-schema.js +109 -0
  323. package/dist/domain/tool-schema.js.map +1 -0
  324. package/dist/domain/tool.constants.d.ts +4 -0
  325. package/dist/domain/tool.constants.js +36 -0
  326. package/dist/domain/tool.constants.js.map +1 -0
  327. package/dist/domain/tool.d.ts +4 -0
  328. package/dist/domain/tool.js +66 -0
  329. package/dist/domain/tool.js.map +1 -0
  330. package/dist/domain/tool.types.d.ts +62 -0
  331. package/dist/domain/tool.types.js +2 -0
  332. package/dist/domain/tool.types.js.map +1 -0
  333. package/dist/domain/transcript.d.ts +4 -0
  334. package/dist/domain/transcript.js +48 -0
  335. package/dist/domain/transcript.js.map +1 -0
  336. package/dist/domain/transcript.types.d.ts +15 -0
  337. package/dist/domain/transcript.types.js +2 -0
  338. package/dist/domain/transcript.types.js.map +1 -0
  339. package/dist/domain/workflow/workflow-state.js +13 -6
  340. package/dist/domain/workflow/workflow-state.js.map +1 -1
  341. package/dist/domain/workflow.d.ts +1 -1
  342. package/dist/domain/workflow.js.map +1 -1
  343. package/dist/domain/workflow.types.d.ts +4 -0
  344. package/dist/domain/workflow.types.js.map +1 -1
  345. package/dist/index.d.ts +34 -8
  346. package/dist/index.js +19 -4
  347. package/dist/index.js.map +1 -1
  348. package/dist/infrastructure/conversations/harness-store.d.ts +3 -0
  349. package/dist/infrastructure/conversations/harness-store.js +27 -0
  350. package/dist/infrastructure/conversations/harness-store.js.map +1 -0
  351. package/dist/infrastructure/conversations/harness-transcript.d.ts +2 -0
  352. package/dist/infrastructure/conversations/harness-transcript.js +50 -0
  353. package/dist/infrastructure/conversations/harness-transcript.js.map +1 -0
  354. package/dist/infrastructure/conversations/harness-transcript.types.d.ts +18 -0
  355. package/dist/infrastructure/conversations/harness-transcript.types.js +2 -0
  356. package/dist/infrastructure/conversations/harness-transcript.types.js.map +1 -0
  357. package/dist/infrastructure/conversations.d.ts +4 -1
  358. package/dist/infrastructure/conversations.js +3 -0
  359. package/dist/infrastructure/conversations.js.map +1 -1
  360. package/dist/infrastructure/conversations.types.d.ts +1 -0
  361. package/dist/infrastructure/conversations.types.js.map +1 -1
  362. package/dist/infrastructure/custom-reporter.d.ts +2 -0
  363. package/dist/infrastructure/custom-reporter.js +33 -0
  364. package/dist/infrastructure/custom-reporter.js.map +1 -0
  365. package/dist/infrastructure/custom-reporter.types.d.ts +13 -0
  366. package/dist/infrastructure/custom-reporter.types.js +2 -0
  367. package/dist/infrastructure/custom-reporter.types.js.map +1 -0
  368. package/dist/infrastructure/git/git.constants.d.ts +1 -1
  369. package/dist/infrastructure/git/git.constants.js +1 -0
  370. package/dist/infrastructure/git/git.constants.js.map +1 -1
  371. package/dist/infrastructure/journal.constants.d.ts +1 -0
  372. package/dist/infrastructure/journal.constants.js +2 -0
  373. package/dist/infrastructure/journal.constants.js.map +1 -0
  374. package/dist/infrastructure/journal.js +4 -1
  375. package/dist/infrastructure/journal.js.map +1 -1
  376. package/dist/infrastructure/opentelemetry-dispatch.d.ts +6 -0
  377. package/dist/infrastructure/opentelemetry-dispatch.js +70 -0
  378. package/dist/infrastructure/opentelemetry-dispatch.js.map +1 -0
  379. package/dist/infrastructure/opentelemetry.constants.d.ts +3 -0
  380. package/dist/infrastructure/opentelemetry.constants.js +3 -0
  381. package/dist/infrastructure/opentelemetry.constants.js.map +1 -1
  382. package/dist/infrastructure/opentelemetry.js +4 -0
  383. package/dist/infrastructure/opentelemetry.js.map +1 -1
  384. package/dist/infrastructure/opentelemetry.types.d.ts +3 -3
  385. package/dist/infrastructure/opentelemetry.types.js.map +1 -1
  386. package/dist/infrastructure/reporter.js +27 -2
  387. package/dist/infrastructure/reporter.js.map +1 -1
  388. package/dist/infrastructure/resource-activity-inspection.js +3 -2
  389. package/dist/infrastructure/resource-activity-inspection.js.map +1 -1
  390. package/dist/infrastructure/resource-activity.js +2 -2
  391. package/dist/infrastructure/resource-activity.js.map +1 -1
  392. package/dist/infrastructure/resource-activity.types.d.ts +2 -2
  393. package/dist/infrastructure/resource-activity.types.js.map +1 -1
  394. package/dist/infrastructure/settings.d.ts +1 -1
  395. package/dist/infrastructure/settings.js +3 -3
  396. package/dist/infrastructure/settings.js.map +1 -1
  397. package/dist/infrastructure/sse.d.ts +2 -0
  398. package/dist/infrastructure/sse.js +64 -0
  399. package/dist/infrastructure/sse.js.map +1 -0
  400. package/dist/infrastructure/sse.types.d.ts +4 -0
  401. package/dist/infrastructure/sse.types.js +2 -0
  402. package/dist/infrastructure/sse.types.js.map +1 -0
  403. package/dist/infrastructure/transport-conversations.d.ts +2 -2
  404. package/dist/infrastructure/transport-conversations.js +8 -1
  405. package/dist/infrastructure/transport-conversations.js.map +1 -1
  406. package/dist/infrastructure/transport-journal.js +2 -1
  407. package/dist/infrastructure/transport-journal.js.map +1 -1
  408. package/dist/providers/agents.d.ts +3 -3
  409. package/dist/providers/agents.js +3 -3
  410. package/dist/providers/agents.js.map +1 -1
  411. package/dist/providers/daytona.d.ts +1 -1
  412. package/dist/providers/daytona.js +1 -1
  413. package/dist/providers/daytona.js.map +1 -1
  414. package/dist/providers/docker.d.ts +1 -1
  415. package/dist/providers/docker.js +1 -1
  416. package/dist/providers/docker.js.map +1 -1
  417. package/dist/providers/factories.d.ts +2 -2
  418. package/dist/providers/factories.js +3 -3
  419. package/dist/providers/factories.js.map +1 -1
  420. package/dist/providers/firecracker.d.ts +1 -1
  421. package/dist/providers/firecracker.js +1 -1
  422. package/dist/providers/firecracker.js.map +1 -1
  423. package/dist/providers/local.d.ts +1 -1
  424. package/dist/providers/local.js +1 -1
  425. package/dist/providers/local.js.map +1 -1
  426. package/dist/providers/podman.d.ts +1 -1
  427. package/dist/providers/podman.js +1 -1
  428. package/dist/providers/podman.js.map +1 -1
  429. package/dist/providers/vercel.d.ts +1 -1
  430. package/dist/providers/vercel.js +1 -1
  431. package/dist/providers/vercel.js.map +1 -1
  432. package/package.json +1 -1
  433. package/dist/adapters/models/openai-compatible.constants.js.map +0 -1
  434. package/dist/adapters/models/openai-compatible.d.ts +0 -3
  435. package/dist/adapters/models/openai-compatible.js +0 -78
  436. package/dist/adapters/models/openai-compatible.js.map +0 -1
  437. package/dist/adapters/models/openai-compatible.types.d.ts +0 -14
  438. package/dist/adapters/models/openai-compatible.types.js +0 -2
  439. package/dist/adapters/models/openai-compatible.types.js.map +0 -1
  440. package/dist/adapters/models/openai-http.js.map +0 -1
  441. package/dist/adapters/models/openai-request.d.ts +0 -4
  442. package/dist/adapters/models/openai-request.js +0 -46
  443. package/dist/adapters/models/openai-request.js.map +0 -1
  444. package/dist/adapters/models/openai-response.d.ts +0 -3
  445. package/dist/adapters/models/openai-response.js +0 -65
  446. package/dist/adapters/models/openai-response.js.map +0 -1
  447. package/dist/cli/init-authentication.constants.js.map +0 -1
  448. /package/dist/{cli/init-authentication.constants.d.ts → adapters/agents/authentication.constants.d.ts} +0 -0
  449. /package/dist/adapters/models/{openai-http.d.ts → model-http.d.ts} +0 -0
  450. /package/dist/adapters/models/{openai-compatible.constants.d.ts → model.constants.d.ts} +0 -0
@@ -5,19 +5,24 @@ import { continuationConfiguration } from "./continuation.js";
5
5
  import { preflightDispatch } from "./dispatch-validation.js";
6
6
  import { executionDefaults } from "./execution.constants.js";
7
7
  import { notify } from "./observation.js";
8
+ import { observeDispatch } from "./dispatch-observation.js";
8
9
  import { createSandbox } from "./sandbox.js";
9
10
  export async function dispatch(options) {
11
+ const { telemetry: _telemetry, ...configuration } = options;
12
+ return observeDispatch(options, (observed) => dispatchOperation({ ...configuration, ...observed }, options));
13
+ }
14
+ async function dispatchOperation(options, original) {
10
15
  options.signal?.throwIfAborted();
11
16
  await preflightDispatch(options, options.workspace?.repository ?? options.repository ?? process.cwd(), options.agent);
12
17
  if ((options.passes ?? executionDefaults.passes) > 1) {
13
18
  const outputs = [];
14
19
  for (let index = 0; index < options.passes; index++) {
15
20
  options.signal?.throwIfAborted();
16
- const output = await dispatch({
21
+ const output = await dispatchOperation({
17
22
  ...options,
18
23
  passes: 1,
19
24
  observe: (event) => notify(options.observe, { ...event, pass: index + 1 }),
20
- });
25
+ }, original);
21
26
  outputs.push(output);
22
27
  if (output.completed)
23
28
  break;
@@ -41,7 +46,7 @@ export async function dispatch(options) {
41
46
  await storage.locate(options.continuation.id, options.workspace?.repository ?? options.repository ?? process.cwd(), options.conversationHome);
42
47
  }
43
48
  const sandbox = await createSandbox(options);
44
- const { brief: _brief, response: _response, continuation: _continuation, passes: _passes, ...configuration } = options;
49
+ const { brief: _brief, response: _response, continuation: _continuation, passes: _passes, ...configuration } = original;
45
50
  let successful = false;
46
51
  try {
47
52
  const output = await sandbox.dispatch(options);
@@ -1 +1 @@
1
- {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/application/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAo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Usage } from \"../domain/agent.types.ts\";\nimport { invariant, recordRecovery } from \"../domain/errors.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { continuationConfiguration } from \"./continuation.ts\";\nimport { preflightDispatch } from \"./dispatch-validation.ts\";\nimport { executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\nimport type {\n ContinuationOptions,\n DispatchResult,\n SandboxOptions,\n} from \"./outpost.types.ts\";\nimport { createSandbox } from \"./sandbox.ts\";\n\nexport async function dispatch<T = undefined>(\n options: SandboxOptions & DispatchOptions<T> & RequiredAgent,\n): Promise<DispatchResult<T>> {\n options.signal?.throwIfAborted();\n await preflightDispatch(\n options,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.agent,\n );\n if ((options.passes ?? executionDefaults.passes) > 1) {\n const outputs: DispatchResult<T>[] = [];\n for (let index = 0; index < options.passes!; index++) {\n options.signal?.throwIfAborted();\n const output = await dispatch({\n ...options,\n passes: 1,\n observe: (event) =>\n notify(options.observe, { ...event, pass: index + 1 }),\n });\n outputs.push(output);\n if (output.completed) break;\n }\n const last = outputs.at(-1)!;\n return {\n ...last,\n text: outputs.map((output) => output.text).join(\"\\n\"),\n turns: outputs.flatMap((output) => output.turns),\n commits: outputs.flatMap((output) => output.commits),\n usage: outputs.reduce((sum, output) => addUsage(sum, output.usage), {\n input: 0,\n cached: 0,\n output: 0,\n } as Usage),\n };\n }\n if (options.continuation) {\n const storage = storageFor(options.agent);\n invariant(storage, \"This adapter does not support native conversations\");\n await storage.locate(\n options.continuation.id,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.conversationHome,\n );\n }\n const sandbox = await createSandbox(options);\n const {\n brief: _brief,\n response: _response,\n continuation: _continuation,\n passes: _passes,\n ...configuration\n } = options;\n let successful = false;\n try {\n const output = await sandbox.dispatch(options);\n await sandbox.workspace.integrate();\n successful = true;\n const disposed = await sandbox.close();\n const continuation = output.conversation;\n return {\n ...output,\n ...disposed,\n resume<U>(next: ContinuationOptions<U>) {\n invariant(continuation, \"No conversation was emitted\");\n return dispatch({\n ...continuationConfiguration(configuration, next),\n ...next,\n continuation: { id: continuation },\n });\n },\n fork<U>(next: ContinuationOptions<U>) {\n invariant(continuation, \"No conversation was emitted\");\n return dispatch({\n ...continuationConfiguration(configuration, next),\n ...next,\n continuation: { id: continuation, fork: true },\n });\n },\n };\n } catch (cause) {\n recordRecovery(cause, {\n branch: sandbox.workspace.branch,\n directory: sandbox.workspace.directory,\n });\n throw cause;\n } finally {\n if (!successful) await sandbox.close({ preserve: true });\n }\n}\n"]}
1
+ {"version":3,"file":"dispatch.js","sourceRoot":"","sources":["../../src/application/dispatch.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAM1C,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAA4D;IAE5D,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,aAAa,EAAE,GAAG,OAAO,CAAC;IAC5D,OAAO,eAAe,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAC3C,iBAAiB,CAAC,EAAE,GAAG,aAAa,EAAE,GAAG,QAAQ,EAAE,EA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;QACvC,MAAM,YAAY,GAAG,MAAM,CAAC,YAAY,CAAC;QACzC,OAAO;YACL,GAAG,MAAM;YACT,GAAG,QAAQ;YACX,MAAM,CAAI,IAA4B;gBACpC,SAAS,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;gBACvD,OAAO,QAAQ,CAAC;oBACd,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC;oBACjD,GAAG,IAAI;oBACP,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE;iBACnC,CAAC,CAAC;YACL,CAAC;YACD,IAAI,CAAI,IAA4B;gBAClC,SAAS,CAAC,YAAY,EAAE,6BAA6B,CAAC,CAAC;gBACvD,OAAO,QAAQ,CAAC;oBACd,GAAG,yBAAyB,CAAC,aAAa,EAAE,IAAI,CAAC;oBACjD,GAAG,IAAI;oBACP,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,IAAI,EAAE,IAAI,EAAE;iBAC/C,CAAC,CAAC;YACL,CAAC;SACF,CAAC;IACJ,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,cAAc,CAAC,KAAK,EAAE;YACpB,MAAM,EAAE,OAAO,CAAC,SAAS,CAAC,MAAM;YAChC,SAAS,EAAE,OAAO,CAAC,SAAS,CAAC,SAAS;SACvC,CAAC,CAAC;QACH,MAAM,KAAK,CAAC;IACd,CAAC;YAAS,CAAC;QACT,IAAI,CAAC,UAAU;YAAE,MAAM,OAAO,CAAC,KAAK,CAAC,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;IAC3D,CAAC;AACH,CAAC","sourcesContent":["import type { RequiredAgent, Usage } from \"../domain/agent.types.ts\";\nimport { invariant, recordRecovery } from \"../domain/errors.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport { storageFor } from \"./agent-storage.ts\";\nimport { continuationConfiguration } from \"./continuation.ts\";\nimport { preflightDispatch } from \"./dispatch-validation.ts\";\nimport { executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\nimport type {\n ContinuationOptions,\n DispatchResult,\n SandboxOptions,\n} from \"./outpost.types.ts\";\nimport { observeDispatch } from \"./dispatch-observation.ts\";\nimport { createSandbox } from \"./sandbox.ts\";\n\nexport async function dispatch<T = undefined>(\n options: SandboxOptions & DispatchOptions<T> & RequiredAgent,\n): Promise<DispatchResult<T>> {\n const { telemetry: _telemetry, ...configuration } = options;\n return observeDispatch(options, (observed) =>\n dispatchOperation({ ...configuration, ...observed }, options),\n );\n}\n\nasync function dispatchOperation<T>(\n options: SandboxOptions & DispatchOptions<T> & RequiredAgent,\n original: SandboxOptions & DispatchOptions<T> & RequiredAgent,\n): Promise<DispatchResult<T>> {\n options.signal?.throwIfAborted();\n await preflightDispatch(\n options,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.agent,\n );\n if ((options.passes ?? executionDefaults.passes) > 1) {\n const outputs: DispatchResult<T>[] = [];\n for (let index = 0; index < options.passes!; index++) {\n options.signal?.throwIfAborted();\n const output = await dispatchOperation(\n {\n ...options,\n passes: 1,\n observe: (event) =>\n notify(options.observe, { ...event, pass: index + 1 }),\n },\n original,\n );\n outputs.push(output);\n if (output.completed) break;\n }\n const last = outputs.at(-1)!;\n return {\n ...last,\n text: outputs.map((output) => output.text).join(\"\\n\"),\n turns: outputs.flatMap((output) => output.turns),\n commits: outputs.flatMap((output) => output.commits),\n usage: outputs.reduce((sum, output) => addUsage(sum, output.usage), {\n input: 0,\n cached: 0,\n output: 0,\n } as Usage),\n };\n }\n if (options.continuation) {\n const storage = storageFor(options.agent);\n invariant(storage, \"This adapter does not support native conversations\");\n await storage.locate(\n options.continuation.id,\n options.workspace?.repository ?? options.repository ?? process.cwd(),\n options.conversationHome,\n );\n }\n const sandbox = await createSandbox(options);\n const {\n brief: _brief,\n response: _response,\n continuation: _continuation,\n passes: _passes,\n ...configuration\n } = original;\n let successful = false;\n try {\n const output = await sandbox.dispatch(options);\n await sandbox.workspace.integrate();\n successful = true;\n const disposed = await sandbox.close();\n const continuation = output.conversation;\n return {\n ...output,\n ...disposed,\n resume<U>(next: ContinuationOptions<U>) {\n invariant(continuation, \"No conversation was emitted\");\n return dispatch({\n ...continuationConfiguration(configuration, next),\n ...next,\n continuation: { id: continuation },\n });\n },\n fork<U>(next: ContinuationOptions<U>) {\n invariant(continuation, \"No conversation was emitted\");\n return dispatch({\n ...continuationConfiguration(configuration, next),\n ...next,\n continuation: { id: continuation, fork: true },\n });\n },\n };\n } catch (cause) {\n recordRecovery(cause, {\n branch: sandbox.workspace.branch,\n directory: sandbox.workspace.directory,\n });\n throw cause;\n } finally {\n if (!successful) await sandbox.close({ preserve: true });\n }\n}\n"]}
@@ -23,7 +23,7 @@ export async function diagnoseImage(options, execute = executeProcess) {
23
23
  unregister();
24
24
  }
25
25
  }
26
- async function inspectImage({ provider, agent, image }, execute, signal) {
26
+ async function inspectImage({ sandboxProvider, agent, image }, execute, signal) {
27
27
  const directory = await mkdtemp(join(tmpdir(), "outpost-doctor-"));
28
28
  const checks = [];
29
29
  let lease;
@@ -37,7 +37,7 @@ async function inspectImage({ provider, agent, image }, execute, signal) {
37
37
  return execute(command);
38
38
  };
39
39
  try {
40
- lease = await diagnosticContainer(provider, image, doctorDefaults.deadlineMs, tracked).acquire({
40
+ lease = await diagnosticContainer(sandboxProvider, image, doctorDefaults.deadlineMs, tracked).acquire({
41
41
  repository: directory,
42
42
  directory,
43
43
  gitDirectories: [],
@@ -113,7 +113,7 @@ async function inspectImage({ provider, agent, image }, execute, signal) {
113
113
  checks.push({
114
114
  id: "image.cleanup",
115
115
  status: "fail",
116
- message: `Cleanup could not be confirmed. Inspect container ${container ?? "creation state"} with ${provider}; temporary workspace retained at ${directory}.`,
116
+ message: `Cleanup could not be confirmed. Inspect container ${container ?? "creation state"} with ${sandboxProvider}; temporary workspace retained at ${directory}.`,
117
117
  });
118
118
  if (!retained) {
119
119
  try {
@@ -1 +1 @@
1
- {"version":3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,IAAI,CAAC;YACV,EAAE,EAAE,eAAe;YACnB,MAAM,EAAE,MAAM;YACd,OAAO,EACL,kLAAkL;SACrL,CAAC,CAAC;IACL,CAAC;YAAS,CAAC;QACT,IAAI,KAAK,EAAE,CAAC;YACV,IAAI,CAAC;gBACH,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,CAAC;oBACV,EAAE,EAAE,eAAe;oBACnB,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,+BAA+B;iBACzC,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;QACH,CAAC;QACD,IAAI,QAAQ;YACV,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,eAAe;gBACnB,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,qDAAqD,SAAS,IAAI,gBAAgB,SAAS,QAAQ,qCAAqC,SAAS,GAAG;aAC9J,CAAC,CAAC;QACL,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACxD,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,CAAC,IAAI,CAAC;oBACV,EAAE,EAAE,iBAAiB;oBACrB,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,wCAAwC,SAAS,GAAG;iBAC9D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { mkdtemp, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { executeProcess } from \"../infrastructure/process.ts\";\nimport type { Executor } from \"../infrastructure/process.types.ts\";\nimport { registerCleanup } from \"../infrastructure/shutdown.ts\";\nimport { diagnosticContainer } from \"../providers/diagnostic-container.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport { diagnoseAgentCli } from \"./doctor-agent.ts\";\nimport { diagnosticProbe } from \"./diagnostic-probe.ts\";\nimport { doctorDefaults } from \"./doctor.constants.ts\";\nimport type { DiagnosticCheck, DoctorImageOptions } from \"./doctor.types.ts\";\n\nexport async function diagnoseImage(\n options: DoctorImageOptions,\n execute: Executor = executeProcess,\n): Promise<readonly DiagnosticCheck[]> {\n const stop = new AbortController();\n const pending = inspectImage(options, execute, stop.signal);\n const unregister = registerCleanup(async () => {\n stop.abort(new OutpostError(\"aborted\", \"Image diagnostics interrupted\"));\n await pending;\n });\n try {\n return await pending;\n } finally {\n unregister();\n }\n}\n\nasync function inspectImage(\n { provider, agent, image }: DoctorImageOptions,\n execute: Executor,\n signal: AbortSignal,\n): Promise<readonly DiagnosticCheck[]> {\n const directory = await mkdtemp(join(tmpdir(), \"outpost-doctor-\"));\n const checks: DiagnosticCheck[] = [];\n let lease: SandboxLease | undefined;\n let retained = false;\n let container: string | undefined;\n const tracked: Executor = (command) => {\n if (command.arguments?.[0] === \"create\") {\n const index = command.arguments.indexOf(\"--name\");\n container = command.arguments[index + 1];\n }\n return execute(command);\n };\n try {\n lease = await diagnosticContainer(\n provider,\n image,\n doctorDefaults.deadlineMs,\n tracked,\n ).acquire({\n repository: directory,\n directory,\n gitDirectories: [],\n variables: {},\n signal,\n });\n checks.push({\n id: \"image.runtime\",\n status: \"pass\",\n message:\n \"Temporary sandbox started with network disabled and an empty workspace.\",\n });\n const sandbox = lease;\n const invoke: Executor = (command) =>\n sandbox.invoke({ ...command, signal });\n for (const executable of [\"node\", \"git\"]) {\n checks.push(\n await diagnosticProbe(\n {\n id: `image.${executable}`,\n command: { executable, arguments: [\"--version\"] },\n failureStatus: \"fail\",\n readVersion: true,\n remedy: `Install ${executable} in the image and rebuild it.`,\n },\n invoke,\n ),\n );\n }\n checks.push(\n await diagnosticProbe(\n {\n id: \"image.home\",\n command: {\n executable: \"sh\",\n arguments: [\"-c\", 'test -d \"$HOME\" && test -w \"$HOME\"'],\n },\n failureStatus: \"fail\",\n remedy:\n \"Check the image user and permissions of the private agent home.\",\n },\n invoke,\n ),\n );\n const agentVersion = await diagnosticProbe(\n {\n id: \"agent.sandbox\",\n command: { executable: agent, arguments: [\"--version\"] },\n failureStatus: \"fail\",\n readVersion: true,\n referenceVersion: agentVersions[agent],\n remedy: `Install ${agent} in the image and rebuild it. This check does not bootstrap agents.`,\n },\n invoke,\n );\n checks.push(agentVersion);\n if (agentVersion.status === \"fail\")\n checks.push({\n id: \"agent.cli\",\n status: \"skipped\",\n message: \"CLI help checks require a successful agent version probe.\",\n });\n else checks.push(...(await diagnoseAgentCli(agent, invoke)));\n } catch (error) {\n retained = error instanceof AggregateError;\n checks.push({\n id: \"image.runtime\",\n status: \"fail\",\n message:\n \"Image diagnostics could not start. Check that the image exists locally, its UID matches the host, and sh, sleep, setsid, kill, tar and cp are installed. No image is downloaded.\",\n });\n } finally {\n if (lease) {\n try {\n await lease.release();\n checks.push({\n id: \"image.cleanup\",\n status: \"pass\",\n message: \"Diagnostic container removed.\",\n });\n } catch {\n retained = true;\n }\n }\n if (retained)\n checks.push({\n id: \"image.cleanup\",\n status: \"fail\",\n message: `Cleanup could not be confirmed. Inspect container ${container ?? \"creation state\"} with ${provider}; temporary workspace retained at ${directory}.`,\n });\n if (!retained) {\n try {\n await rm(directory, { recursive: true, force: true });\n } catch {\n checks.push({\n id: \"image.workspace\",\n status: \"fail\",\n message: `Could not remove temporary workspace ${directory}.`,\n });\n }\n }\n }\n return checks;\n}\n"]}
1
+ {"version":3,"file":"doctor-image.js","sourceRoot":"","sources":["../../src/application/doctor-image.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,MAAM,kBAAkB,CAAC;AAC/C,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CA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,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;gBACtB,MAAM,CAAC,IAAI,CAAC;oBACV,EAAE,EAAE,eAAe;oBACnB,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,+BAA+B;iBACzC,CAAC,CAAC;YACL,CAAC;YAAC,MAAM,CAAC;gBACP,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;QACH,CAAC;QACD,IAAI,QAAQ;YACV,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,eAAe;gBACnB,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE,qDAAqD,SAAS,IAAI,gBAAgB,SAAS,eAAe,qCAAqC,SAAS,GAAG;aACrK,CAAC,CAAC;QACL,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,IAAI,CAAC;gBACH,MAAM,EAAE,CAAC,SAAS,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;YACxD,CAAC;YAAC,MAAM,CAAC;gBACP,MAAM,CAAC,IAAI,CAAC;oBACV,EAAE,EAAE,iBAAiB;oBACrB,MAAM,EAAE,MAAM;oBACd,OAAO,EAAE,wCAAwC,SAAS,GAAG;iBAC9D,CAAC,CAAC;YACL,CAAC;QACH,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import { mkdtemp, rm } from \"node:fs/promises\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { OutpostError } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { executeProcess } from \"../infrastructure/process.ts\";\nimport type { Executor } from \"../infrastructure/process.types.ts\";\nimport { registerCleanup } from \"../infrastructure/shutdown.ts\";\nimport { diagnosticContainer } from \"../providers/diagnostic-container.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport { diagnoseAgentCli } from \"./doctor-agent.ts\";\nimport { diagnosticProbe } from \"./diagnostic-probe.ts\";\nimport { doctorDefaults } from \"./doctor.constants.ts\";\nimport type { DiagnosticCheck, DoctorImageOptions } from \"./doctor.types.ts\";\n\nexport async function diagnoseImage(\n options: DoctorImageOptions,\n execute: Executor = executeProcess,\n): Promise<readonly DiagnosticCheck[]> {\n const stop = new AbortController();\n const pending = inspectImage(options, execute, stop.signal);\n const unregister = registerCleanup(async () => {\n stop.abort(new OutpostError(\"aborted\", \"Image diagnostics interrupted\"));\n await pending;\n });\n try {\n return await pending;\n } finally {\n unregister();\n }\n}\n\nasync function inspectImage(\n { sandboxProvider, agent, image }: DoctorImageOptions,\n execute: Executor,\n signal: AbortSignal,\n): Promise<readonly DiagnosticCheck[]> {\n const directory = await mkdtemp(join(tmpdir(), \"outpost-doctor-\"));\n const checks: DiagnosticCheck[] = [];\n let lease: SandboxLease | undefined;\n let retained = false;\n let container: string | undefined;\n const tracked: Executor = (command) => {\n if (command.arguments?.[0] === \"create\") {\n const index = command.arguments.indexOf(\"--name\");\n container = command.arguments[index + 1];\n }\n return execute(command);\n };\n try {\n lease = await diagnosticContainer(\n sandboxProvider,\n image,\n doctorDefaults.deadlineMs,\n tracked,\n ).acquire({\n repository: directory,\n directory,\n gitDirectories: [],\n variables: {},\n signal,\n });\n checks.push({\n id: \"image.runtime\",\n status: \"pass\",\n message:\n \"Temporary sandbox started with network disabled and an empty workspace.\",\n });\n const sandbox = lease;\n const invoke: Executor = (command) =>\n sandbox.invoke({ ...command, signal });\n for (const executable of [\"node\", \"git\"]) {\n checks.push(\n await diagnosticProbe(\n {\n id: `image.${executable}`,\n command: { executable, arguments: [\"--version\"] },\n failureStatus: \"fail\",\n readVersion: true,\n remedy: `Install ${executable} in the image and rebuild it.`,\n },\n invoke,\n ),\n );\n }\n checks.push(\n await diagnosticProbe(\n {\n id: \"image.home\",\n command: {\n executable: \"sh\",\n arguments: [\"-c\", 'test -d \"$HOME\" && test -w \"$HOME\"'],\n },\n failureStatus: \"fail\",\n remedy:\n \"Check the image user and permissions of the private agent home.\",\n },\n invoke,\n ),\n );\n const agentVersion = await diagnosticProbe(\n {\n id: \"agent.sandbox\",\n command: { executable: agent, arguments: [\"--version\"] },\n failureStatus: \"fail\",\n readVersion: true,\n referenceVersion: agentVersions[agent],\n remedy: `Install ${agent} in the image and rebuild it. This check does not bootstrap agents.`,\n },\n invoke,\n );\n checks.push(agentVersion);\n if (agentVersion.status === \"fail\")\n checks.push({\n id: \"agent.cli\",\n status: \"skipped\",\n message: \"CLI help checks require a successful agent version probe.\",\n });\n else checks.push(...(await diagnoseAgentCli(agent, invoke)));\n } catch (error) {\n retained = error instanceof AggregateError;\n checks.push({\n id: \"image.runtime\",\n status: \"fail\",\n message:\n \"Image diagnostics could not start. Check that the image exists locally, its UID matches the host, and sh, sleep, setsid, kill, tar and cp are installed. No image is downloaded.\",\n });\n } finally {\n if (lease) {\n try {\n await lease.release();\n checks.push({\n id: \"image.cleanup\",\n status: \"pass\",\n message: \"Diagnostic container removed.\",\n });\n } catch {\n retained = true;\n }\n }\n if (retained)\n checks.push({\n id: \"image.cleanup\",\n status: \"fail\",\n message: `Cleanup could not be confirmed. Inspect container ${container ?? \"creation state\"} with ${sandboxProvider}; temporary workspace retained at ${directory}.`,\n });\n if (!retained) {\n try {\n await rm(directory, { recursive: true, force: true });\n } catch {\n checks.push({\n id: \"image.workspace\",\n status: \"fail\",\n message: `Could not remove temporary workspace ${directory}.`,\n });\n }\n }\n }\n return checks;\n}\n"]}
@@ -1,11 +1,16 @@
1
1
  import { isDeepStrictEqual } from "node:util";
2
- import { claude } from "../adapters/agents/claude-adapter.js";
3
- import { codex } from "../adapters/agents/codex-adapter.js";
4
- import { gemini } from "../adapters/agents/gemini-adapter.js";
2
+ import { claudeHarness } from "../adapters/agents/claude-adapter.js";
3
+ import { codexHarness } from "../adapters/agents/codex-adapter.js";
4
+ import { geminiHarness } from "../adapters/agents/gemini-adapter.js";
5
5
  import { protocolFixtures } from "../adapters/agents/protocol-fixtures.constants.js";
6
6
  import { agentVersions } from "../providers/versions.constants.js";
7
7
  export function diagnoseAgentProtocol(agent) {
8
- const adapter = { claude, codex, gemini }[agent]();
8
+ const adapter = {
9
+ claude: claudeHarness,
10
+ codex: codexHarness,
11
+ gemini: geminiHarness,
12
+ }[agent]()
13
+ .bind();
9
14
  const checks = protocolFixtures[agent].map((fixture) => {
10
15
  const events = fixture.lines.flatMap((line) => adapter.events(line));
11
16
  const passed = isDeepStrictEqual(events, fixture.expected);
@@ -1 +1 @@
1
- {"version":3,"file":"doctor-protocol.js","sourceRoot":"","sources":["../../src/application/doctor-protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,qCAAqC,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,sCAAsC,CAAC;AAC9D,OAAO,EAAE,gBAAgB,EAAE,MAAM,mDAAmD,CAAC;AACrF,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AAInE,MAAM,UAAU,qBAAqB,CAAC,KAAkB;IACtD,MAAM,OAAO,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IACnD,MAAM,MAAM,GAAsB,gBAAgB,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE;QACxE,MAAM,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC;QACrE,MAAM,MAAM,GAAG,iBAAiB,CAAC,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC3D,OAAO;YACL,EAAE,EAAE,oBAAoB,OAAO,CAAC,IAAI,EAAE;YACtC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM;YAChC,OAAO,EAAE,MAAM;gBACb,CAAC,CAAC,iHAAiH;gBACnH,CAAC,CAAC,6EAA6E;SAClF,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,OAAO;QACL,KAAK,EAAE,2BAA2B;QAClC,KAAK;QACL,gBAAgB,EAAE,aAAa,CAAC,KAAK,CAAC;QACtC,YAAY,EAAE,YAAY;QAC1B,kBAAkB,EAAE,YAAY;QAChC,MAAM;QACN,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import { isDeepStrictEqual } from \"node:util\";\nimport { claude } from \"../adapters/agents/claude-adapter.ts\";\nimport { codex } from \"../adapters/agents/codex-adapter.ts\";\nimport { gemini } from \"../adapters/agents/gemini-adapter.ts\";\nimport { protocolFixtures } from \"../adapters/agents/protocol-fixtures.constants.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport type { AgentProtocolReport } from \"./doctor-protocol.types.ts\";\nimport type { DiagnosticCheck, DoctorAgent } from \"./doctor.types.ts\";\n\nexport function diagnoseAgentProtocol(agent: DoctorAgent): AgentProtocolReport {\n const adapter = { claude, codex, gemini }[agent]();\n const checks: DiagnosticCheck[] = protocolFixtures[agent].map((fixture) => {\n const events = fixture.lines.flatMap((line) => adapter.events(line));\n const passed = isDeepStrictEqual(events, fixture.expected);\n return {\n id: `protocol.fixture.${fixture.name}`,\n status: passed ? \"pass\" : \"fail\",\n message: passed\n ? \"Bundled synthetic events decode to the expected structural observations. No installed CLI or model was invoked.\"\n : \"Bundled synthetic events do not match the expected structural observations.\",\n };\n });\n return {\n scope: \"bundled-protocol-fixtures\",\n agent,\n referenceVersion: agentVersions[agent],\n installedCli: \"unverified\",\n modelCompatibility: \"unverified\",\n checks,\n hasFailures: checks.some((check) => check.status === \"fail\"),\n };\n}\n"]}
1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AAY,EAAE,YAAY;QAC1B,kBAAkB,EAAE,YAAY;QAChC,MAAM;QACN,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import { isDeepStrictEqual } from \"node:util\";\nimport { claudeHarness } from \"../adapters/agents/claude-adapter.ts\";\nimport { codexHarness } from \"../adapters/agents/codex-adapter.ts\";\nimport { geminiHarness } from \"../adapters/agents/gemini-adapter.ts\";\nimport { protocolFixtures } from \"../adapters/agents/protocol-fixtures.constants.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport type { AgentProtocolReport } from \"./doctor-protocol.types.ts\";\nimport type { DiagnosticCheck, DoctorAgent } from \"./doctor.types.ts\";\n\nexport function diagnoseAgentProtocol(agent: DoctorAgent): AgentProtocolReport {\n const adapter = {\n claude: claudeHarness,\n codex: codexHarness,\n gemini: geminiHarness,\n }\n [agent]()\n .bind();\n const checks: DiagnosticCheck[] = protocolFixtures[agent].map((fixture) => {\n const events = fixture.lines.flatMap((line) => adapter.events(line));\n const passed = isDeepStrictEqual(events, fixture.expected);\n return {\n id: `protocol.fixture.${fixture.name}`,\n status: passed ? \"pass\" : \"fail\",\n message: passed\n ? \"Bundled synthetic events decode to the expected structural observations. No installed CLI or model was invoked.\"\n : \"Bundled synthetic events do not match the expected structural observations.\",\n };\n });\n return {\n scope: \"bundled-protocol-fixtures\",\n agent,\n referenceVersion: agentVersions[agent],\n installedCli: \"unverified\",\n modelCompatibility: \"unverified\",\n checks,\n hasFailures: checks.some((check) => check.status === \"fail\"),\n };\n}\n"]}
@@ -95,11 +95,11 @@ export async function diagnoseSandbox(target, options = {}) {
95
95
  return {
96
96
  scope: "owned-sandbox",
97
97
  ownership: "caller",
98
- ...(options.provider
98
+ ...(options.sandboxProvider
99
99
  ? {
100
- provider: {
101
- name: options.provider.name,
102
- placement: options.provider.placement,
100
+ sandboxProvider: {
101
+ name: options.sandboxProvider.name,
102
+ placement: options.sandboxProvider.placement,
103
103
  },
104
104
  }
105
105
  : {}),
@@ -1 +1 @@
1
- {"version":3,"file":"doctor-sandbox.js","sourceRoot":"","sources":["../../src/application/doctor-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAO1E,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAA8B,EAC9B,UAAoC,EAAE;IAEtC,IAAI,UAAU,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,cAAc,CAAC,UAAU,CAAC;IACnE,SAAS,CACP,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;QAC1B,UAAU,GAAG,CAAC;QACd,UAAU,IAAI,yBAAyB,CAAC,iBAAiB,EAC3D,0DAA0D,CAC3D,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAa,CAAC,OAAO,EAAE,EAAE;QACnC,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;QACjC,OAAO,MAAM,CAAC,MAAM,CAAC;YACnB,GAAG,OAAO;YACV,UAAU;YACV,MAAM,EAAE,OAAO,CAAC,MAAM,IAAI,cAAc,CAAC,MAAM;YAC/C,MAAM,EAAE,OAAO,CAAC,MAAM;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AAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type { Executor } from \"../infrastructure/process.types.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport { diagnoseAgentCli } from \"./doctor-agent.ts\";\nimport { diagnosticProbe } from \"./diagnostic-probe.ts\";\nimport { doctorDefaults } from \"./doctor.constants.ts\";\nimport type { DiagnosticCheck } from \"./doctor.types.ts\";\nimport { diagnoseTransfers } from \"./doctor-transfers.ts\";\nimport { sandboxDiagnosticDefaults } from \"./doctor-sandbox.constants.ts\";\nimport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n} from \"./doctor-sandbox.types.ts\";\nimport type { Sandbox } from \"./outpost.types.ts\";\n\nexport async function diagnoseSandbox(\n target: Sandbox | SandboxLease,\n options: SandboxDiagnosticOptions = {},\n): Promise<SandboxDiagnosticReport> {\n if (\"diagnose\" in target) return target.diagnose(options);\n const deadlineMs = options.deadlineMs ?? doctorDefaults.deadlineMs;\n invariant(\n Number.isInteger(deadlineMs) &&\n deadlineMs > 0 &&\n deadlineMs <= sandboxDiagnosticDefaults.maximumDeadlineMs,\n \"Diagnostic deadlineMs must be an integer from 1 to 60000\",\n );\n options.signal?.throwIfAborted();\n const invoke: Executor = (command) => {\n options.signal?.throwIfAborted();\n return target.invoke({\n ...command,\n deadlineMs,\n retain: command.retain ?? doctorDefaults.retain,\n signal: options.signal\n ? AbortSignal.any([options.signal, AbortSignal.timeout(deadlineMs)])\n : AbortSignal.timeout(deadlineMs),\n });\n };\n const checks: DiagnosticCheck[] = [];\n for (const executable of [\"node\", \"git\"]) {\n checks.push(\n await diagnosticProbe(\n {\n id: `sandbox.${executable}`,\n command: { executable, arguments: [\"--version\"] },\n readVersion: true,\n failureStatus: \"fail\",\n remedy: `Install ${executable} in this sandbox.`,\n },\n invoke,\n ),\n );\n }\n try {\n const result = await invoke({\n executable: \"node\",\n arguments: [\"-e\", sandboxDiagnosticDefaults.command],\n });\n const passed =\n result.status === 7 &&\n result.stdout === \"outpost-stdout\" &&\n result.stderr === \"outpost-stderr\";\n checks.push({\n id: \"sandbox.command\",\n status: passed ? \"pass\" : \"fail\",\n message: passed\n ? \"Observed separate output streams and nonzero process exit status.\"\n : \"Command output or exit status did not match the diagnostic sentinel.\",\n });\n } catch {\n checks.push({\n id: \"sandbox.command\",\n status: \"fail\",\n message: \"Bounded command probe failed or was interrupted.\",\n });\n }\n checks.push(\n await diagnosticProbe(\n {\n id: \"sandbox.home\",\n command: {\n executable: \"node\",\n arguments: [\"-e\", sandboxDiagnosticDefaults.home, target.home],\n },\n failureStatus: \"fail\",\n remedy: \"Check the lease home directory and its permissions.\",\n },\n invoke,\n ),\n );\n if (options.agent) {\n const version = await diagnosticProbe(\n {\n id: \"agent.sandbox\",\n command: { executable: options.agent, arguments: [\"--version\"] },\n readVersion: true,\n referenceVersion: agentVersions[options.agent],\n failureStatus: \"fail\",\n remedy: \"Install the agent explicitly; diagnostics never bootstrap it.\",\n },\n invoke,\n );\n checks.push(version);\n if (version.status !== \"fail\")\n checks.push(...(await diagnoseAgentCli(options.agent, invoke)));\n }\n if (options.transfers === true)\n checks.push(\n ...(await diagnoseTransfers(\n target,\n { deadlineMs, ...(options.signal ? { signal: options.signal } : {}) },\n invoke,\n )),\n );\n checks.push({\n id: \"model\",\n status: \"skipped\",\n message:\n \"Authentication, model access and installed agent protocol compatibility are unverified. No model request was made.\",\n });\n const observed = (id: string) => {\n const check = checks.find((check) => check.id === id);\n if (!check) return \"unverified\" as const;\n return check.status === \"pass\" ? (\"pass\" as const) : (\"fail\" as const);\n };\n return {\n scope: \"owned-sandbox\",\n ownership: \"caller\",\n ...(options.provider\n ? {\n provider: {\n name: options.provider.name,\n placement: options.provider.placement,\n },\n }\n : {}),\n capabilities: [\n {\n id: \"command\",\n advertised: true,\n observed: observed(\"sandbox.command\"),\n },\n {\n id: \"transfers\",\n advertised: true,\n observed: observed(\"sandbox.transfers\"),\n },\n {\n id: \"batchTransfers\",\n advertised: target.fileTransfers !== undefined,\n observed: \"unverified\",\n },\n {\n id: \"interactiveTerminal\",\n advertised: \"unknown\",\n observed: \"unverified\",\n },\n ],\n checks,\n modelCompatibility: \"unverified\",\n hasFailures: checks.some((check) => check.status === \"fail\"),\n };\n}\n"]}
1
+ {"version":3,"file":"doctor-sandbox.js","sourceRoot":"","sources":["../../src/application/doctor-sandbox.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAGhD,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAC1D,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAO1E,MAAM,CAAC,KAAK,UAAU,eAAe,CACnC,MAA8B,EAC9B,UAAoC,EAAE;IAEtC,IAAI,UAAU,IAAI,MAAM;QAAE,OAAO,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC1D,MAAM,UAAU,GAAG,OAAO,CAAC,UAAU,IAAI,cAAc,CAAC,UAAU,CAAC;IACnE,SAAS,CACP,MAAM,CAAC,SAAS,CAAC,UAAU,CAAC;QAC1B,UAAU,GAAG,CAAC;QACd,UAAU,IAAI,yBAAyB,CAAC,iBAAiB,EAC3D,0DAA0D,CAC3D,CAAC;IACF,OAAO,CAAC,MAAM,EAAE,cAAc,EAAE,CAAC;IACjC,MAAM,MAAM,GAAa,CAAC,OAAO,EAAE,EAAE;QACnC,OAAO,CAAC,MAAM,EA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AAY;aACvB;YACD;gBACE,EAAE,EAAE,qBAAqB;gBACzB,UAAU,EAAE,SAAS;gBACrB,QAAQ,EAAE,YAAY;aACvB;SACF;QACD,MAAM;QACN,kBAAkB,EAAE,YAAY;QAChC,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../domain/errors.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport type { Executor } from \"../infrastructure/process.types.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport { diagnoseAgentCli } from \"./doctor-agent.ts\";\nimport { diagnosticProbe } from \"./diagnostic-probe.ts\";\nimport { doctorDefaults } from \"./doctor.constants.ts\";\nimport type { DiagnosticCheck } from \"./doctor.types.ts\";\nimport { diagnoseTransfers } from \"./doctor-transfers.ts\";\nimport { sandboxDiagnosticDefaults } from \"./doctor-sandbox.constants.ts\";\nimport type {\n SandboxDiagnosticOptions,\n SandboxDiagnosticReport,\n} from \"./doctor-sandbox.types.ts\";\nimport type { Sandbox } from \"./outpost.types.ts\";\n\nexport async function diagnoseSandbox(\n target: Sandbox | SandboxLease,\n options: SandboxDiagnosticOptions = {},\n): Promise<SandboxDiagnosticReport> {\n if (\"diagnose\" in target) return target.diagnose(options);\n const deadlineMs = options.deadlineMs ?? doctorDefaults.deadlineMs;\n invariant(\n Number.isInteger(deadlineMs) &&\n deadlineMs > 0 &&\n deadlineMs <= sandboxDiagnosticDefaults.maximumDeadlineMs,\n \"Diagnostic deadlineMs must be an integer from 1 to 60000\",\n );\n options.signal?.throwIfAborted();\n const invoke: Executor = (command) => {\n options.signal?.throwIfAborted();\n return target.invoke({\n ...command,\n deadlineMs,\n retain: command.retain ?? doctorDefaults.retain,\n signal: options.signal\n ? AbortSignal.any([options.signal, AbortSignal.timeout(deadlineMs)])\n : AbortSignal.timeout(deadlineMs),\n });\n };\n const checks: DiagnosticCheck[] = [];\n for (const executable of [\"node\", \"git\"]) {\n checks.push(\n await diagnosticProbe(\n {\n id: `sandbox.${executable}`,\n command: { executable, arguments: [\"--version\"] },\n readVersion: true,\n failureStatus: \"fail\",\n remedy: `Install ${executable} in this sandbox.`,\n },\n invoke,\n ),\n );\n }\n try {\n const result = await invoke({\n executable: \"node\",\n arguments: [\"-e\", sandboxDiagnosticDefaults.command],\n });\n const passed =\n result.status === 7 &&\n result.stdout === \"outpost-stdout\" &&\n result.stderr === \"outpost-stderr\";\n checks.push({\n id: \"sandbox.command\",\n status: passed ? \"pass\" : \"fail\",\n message: passed\n ? \"Observed separate output streams and nonzero process exit status.\"\n : \"Command output or exit status did not match the diagnostic sentinel.\",\n });\n } catch {\n checks.push({\n id: \"sandbox.command\",\n status: \"fail\",\n message: \"Bounded command probe failed or was interrupted.\",\n });\n }\n checks.push(\n await diagnosticProbe(\n {\n id: \"sandbox.home\",\n command: {\n executable: \"node\",\n arguments: [\"-e\", sandboxDiagnosticDefaults.home, target.home],\n },\n failureStatus: \"fail\",\n remedy: \"Check the lease home directory and its permissions.\",\n },\n invoke,\n ),\n );\n if (options.agent) {\n const version = await diagnosticProbe(\n {\n id: \"agent.sandbox\",\n command: { executable: options.agent, arguments: [\"--version\"] },\n readVersion: true,\n referenceVersion: agentVersions[options.agent],\n failureStatus: \"fail\",\n remedy: \"Install the agent explicitly; diagnostics never bootstrap it.\",\n },\n invoke,\n );\n checks.push(version);\n if (version.status !== \"fail\")\n checks.push(...(await diagnoseAgentCli(options.agent, invoke)));\n }\n if (options.transfers === true)\n checks.push(\n ...(await diagnoseTransfers(\n target,\n { deadlineMs, ...(options.signal ? { signal: options.signal } : {}) },\n invoke,\n )),\n );\n checks.push({\n id: \"model\",\n status: \"skipped\",\n message:\n \"Authentication, model access and installed agent protocol compatibility are unverified. No model request was made.\",\n });\n const observed = (id: string) => {\n const check = checks.find((check) => check.id === id);\n if (!check) return \"unverified\" as const;\n return check.status === \"pass\" ? (\"pass\" as const) : (\"fail\" as const);\n };\n return {\n scope: \"owned-sandbox\",\n ownership: \"caller\",\n ...(options.sandboxProvider\n ? {\n sandboxProvider: {\n name: options.sandboxProvider.name,\n placement: options.sandboxProvider.placement,\n },\n }\n : {}),\n capabilities: [\n {\n id: \"command\",\n advertised: true,\n observed: observed(\"sandbox.command\"),\n },\n {\n id: \"transfers\",\n advertised: true,\n observed: observed(\"sandbox.transfers\"),\n },\n {\n id: \"batchTransfers\",\n advertised: target.fileTransfers !== undefined,\n observed: \"unverified\",\n },\n {\n id: \"interactiveTerminal\",\n advertised: \"unknown\",\n observed: \"unverified\",\n },\n ],\n checks,\n modelCompatibility: \"unverified\",\n hasFailures: checks.some((check) => check.status === \"fail\"),\n };\n}\n"]}
@@ -5,7 +5,7 @@ export interface SandboxDiagnosticOptions {
5
5
  readonly deadlineMs?: number;
6
6
  readonly signal?: AbortSignal;
7
7
  readonly transfers?: boolean;
8
- readonly provider?: Pick<SandboxProvider, "name" | "placement">;
8
+ readonly sandboxProvider?: Pick<SandboxProvider, "name" | "placement">;
9
9
  }
10
10
  export interface DiagnosticCapability {
11
11
  readonly id: "command" | "transfers" | "batchTransfers" | "interactiveTerminal";
@@ -15,7 +15,7 @@ export interface DiagnosticCapability {
15
15
  export interface SandboxDiagnosticReport {
16
16
  readonly scope: "owned-sandbox";
17
17
  readonly ownership: "caller";
18
- readonly provider?: Pick<SandboxProvider, "name" | "placement">;
18
+ readonly sandboxProvider?: Pick<SandboxProvider, "name" | "placement">;
19
19
  readonly capabilities: readonly DiagnosticCapability[];
20
20
  readonly checks: readonly DiagnosticCheck[];
21
21
  readonly modelCompatibility: "unverified";
@@ -1 +1 @@
1
- {"version":3,"file":"doctor-sandbox.types.js","sourceRoot":"","sources":["../../src/application/doctor-sandbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SandboxProvider } from \"../domain/sandbox.types.ts\";\nimport type { DiagnosticCheck, DoctorAgent } from \"./doctor.types.ts\";\n\nexport interface SandboxDiagnosticOptions {\n readonly agent?: DoctorAgent;\n readonly deadlineMs?: number;\n readonly signal?: AbortSignal;\n readonly transfers?: boolean;\n readonly provider?: Pick<SandboxProvider, \"name\" | \"placement\">;\n}\n\nexport interface DiagnosticCapability {\n readonly id:\n \"command\" | \"transfers\" | \"batchTransfers\" | \"interactiveTerminal\";\n readonly advertised: boolean | \"unknown\";\n readonly observed: \"pass\" | \"fail\" | \"unverified\";\n}\n\nexport interface SandboxDiagnosticReport {\n readonly scope: \"owned-sandbox\";\n readonly ownership: \"caller\";\n readonly provider?: Pick<SandboxProvider, \"name\" | \"placement\">;\n readonly capabilities: readonly DiagnosticCapability[];\n readonly checks: readonly DiagnosticCheck[];\n readonly modelCompatibility: \"unverified\";\n readonly hasFailures: boolean;\n}\n"]}
1
+ {"version":3,"file":"doctor-sandbox.types.js","sourceRoot":"","sources":["../../src/application/doctor-sandbox.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { SandboxProvider } from \"../domain/sandbox.types.ts\";\nimport type { DiagnosticCheck, DoctorAgent } from \"./doctor.types.ts\";\n\nexport interface SandboxDiagnosticOptions {\n readonly agent?: DoctorAgent;\n readonly deadlineMs?: number;\n readonly signal?: AbortSignal;\n readonly transfers?: boolean;\n readonly sandboxProvider?: Pick<SandboxProvider, \"name\" | \"placement\">;\n}\n\nexport interface DiagnosticCapability {\n readonly id:\n \"command\" | \"transfers\" | \"batchTransfers\" | \"interactiveTerminal\";\n readonly advertised: boolean | \"unknown\";\n readonly observed: \"pass\" | \"fail\" | \"unverified\";\n}\n\nexport interface SandboxDiagnosticReport {\n readonly scope: \"owned-sandbox\";\n readonly ownership: \"caller\";\n readonly sandboxProvider?: Pick<SandboxProvider, \"name\" | \"placement\">;\n readonly capabilities: readonly DiagnosticCapability[];\n readonly checks: readonly DiagnosticCheck[];\n readonly modelCompatibility: \"unverified\";\n readonly hasFailures: boolean;\n}\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { DoctorProvider, DoctorReport } from "./doctor.types.ts";
2
2
  export declare const doctorDefaults: Readonly<{
3
- readonly provider: "docker";
3
+ readonly sandboxProvider: "docker";
4
4
  readonly agent: "codex";
5
5
  readonly deadlineMs: 5000;
6
6
  readonly retain: 4096;
@@ -1,5 +1,5 @@
1
1
  export const doctorDefaults = Object.freeze({
2
- provider: "docker",
2
+ sandboxProvider: "docker",
3
3
  agent: "codex",
4
4
  deadlineMs: 5_000,
5
5
  retain: 4_096,
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.constants.js","sourceRoot":"","sources":["../../src/application/doctor.constants.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,QAAQ,EAAE,QAAQ;IAClB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,KAAK;IACb,gBAAgB,EAAE,EAAE;CACZ,CAAC,CAAC;AACZ,MAAM,CAAC,MAAM,mBAAmB,GAK5B;IACF,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,IAAI,EAAE;IAC3D,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,IAAI,EAAE;IAC3D,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE;IACvD,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,KAAK,EAAE;IAC3D,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAE;CAC5D,CAAC","sourcesContent":["import type { DoctorProvider, DoctorReport } from \"./doctor.types.ts\";\nexport const doctorDefaults = Object.freeze({\n provider: \"docker\",\n agent: \"codex\",\n deadlineMs: 5_000,\n retain: 4_096,\n minimumNodeMajor: 24,\n} as const);\nexport const providerDiagnostics: Readonly<\n Record<\n DoctorProvider,\n Pick<DoctorReport, \"placement\" | \"interactiveTerminal\">\n >\n> = {\n docker: { placement: \"mounted\", interactiveTerminal: true },\n podman: { placement: \"mounted\", interactiveTerminal: true },\n local: { placement: \"host\", interactiveTerminal: true },\n vercel: { placement: \"remote\", interactiveTerminal: false },\n daytona: { placement: \"remote\", interactiveTerminal: true },\n};\n"]}
1
+ {"version":3,"file":"doctor.constants.js","sourceRoot":"","sources":["../../src/application/doctor.constants.ts"],"names":[],"mappings":"AACA,MAAM,CAAC,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAC1C,eAAe,EAAE,QAAQ;IACzB,KAAK,EAAE,OAAO;IACd,UAAU,EAAE,KAAK;IACjB,MAAM,EAAE,KAAK;IACb,gBAAgB,EAAE,EAAE;CACZ,CAAC,CAAC;AACZ,MAAM,CAAC,MAAM,mBAAmB,GAK5B;IACF,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,IAAI,EAAE;IAC3D,MAAM,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,mBAAmB,EAAE,IAAI,EAAE;IAC3D,KAAK,EAAE,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,IAAI,EAAE;IACvD,MAAM,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,KAAK,EAAE;IAC3D,OAAO,EAAE,EAAE,SAAS,EAAE,QAAQ,EAAE,mBAAmB,EAAE,IAAI,EAAE;CAC5D,CAAC","sourcesContent":["import type { DoctorProvider, DoctorReport } from \"./doctor.types.ts\";\nexport const doctorDefaults = Object.freeze({\n sandboxProvider: \"docker\",\n agent: \"codex\",\n deadlineMs: 5_000,\n retain: 4_096,\n minimumNodeMajor: 24,\n} as const);\nexport const providerDiagnostics: Readonly<\n Record<\n DoctorProvider,\n Pick<DoctorReport, \"placement\" | \"interactiveTerminal\">\n >\n> = {\n docker: { placement: \"mounted\", interactiveTerminal: true },\n podman: { placement: \"mounted\", interactiveTerminal: true },\n local: { placement: \"host\", interactiveTerminal: true },\n vercel: { placement: \"remote\", interactiveTerminal: false },\n daytona: { placement: \"remote\", interactiveTerminal: true },\n};\n"]}
@@ -5,14 +5,14 @@ import { diagnoseImage } from "./doctor-image.js";
5
5
  import { diagnosticProbe } from "./diagnostic-probe.js";
6
6
  import { doctorDefaults, providerDiagnostics } from "./doctor.constants.js";
7
7
  export async function diagnose(options, execute = executeProcess) {
8
- const { provider, agent, image } = options;
8
+ const { sandboxProvider, agent, image } = options;
9
9
  if (image !== undefined) {
10
- invariant(provider === "docker" || provider === "podman", "--image requires docker or podman.");
10
+ invariant(sandboxProvider === "docker" || sandboxProvider === "podman", "--image requires docker or podman.");
11
11
  invariant(image.length > 0 &&
12
12
  !image.startsWith("-") &&
13
13
  !/[\x00-\x20\x7f]/.test(image), "Invalid diagnostic image name.");
14
14
  }
15
- const capabilities = providerDiagnostics[provider];
15
+ const capabilities = providerDiagnostics[sandboxProvider];
16
16
  const checks = [
17
17
  {
18
18
  id: "host.node",
@@ -34,9 +34,9 @@ export async function diagnose(options, execute = executeProcess) {
34
34
  if (capabilities.placement === "mounted") {
35
35
  const engine = await diagnosticProbe({
36
36
  id: "provider.cli",
37
- command: { executable: provider, arguments: ["--version"] },
37
+ command: { executable: sandboxProvider, arguments: ["--version"] },
38
38
  failureStatus: "fail",
39
- remedy: `Install ${provider} and make it available on PATH.`,
39
+ remedy: `Install ${sandboxProvider} and make it available on PATH.`,
40
40
  readVersion: true,
41
41
  }, execute);
42
42
  checks.push(engine);
@@ -44,11 +44,11 @@ export async function diagnose(options, execute = executeProcess) {
44
44
  checks.push(await diagnosticProbe({
45
45
  id: "provider.connection",
46
46
  command: {
47
- executable: provider,
47
+ executable: sandboxProvider,
48
48
  arguments: ["info"],
49
49
  },
50
50
  failureStatus: "fail",
51
- remedy: `Check ${provider} is running and accessible to this user; on macOS, start its virtual machine.`,
51
+ remedy: `Check ${sandboxProvider} is running and accessible to this user; on macOS, start its virtual machine.`,
52
52
  }, execute));
53
53
  checks.push(await diagnosticProbe({
54
54
  id: "host.tar",
@@ -71,10 +71,11 @@ export async function diagnose(options, execute = executeProcess) {
71
71
  readVersion: true,
72
72
  referenceVersion: agentVersions[agent],
73
73
  }, execute));
74
- if (image !== undefined && (provider === "docker" || provider === "podman")) {
74
+ if (image !== undefined &&
75
+ (sandboxProvider === "docker" || sandboxProvider === "podman")) {
75
76
  const connected = checks.some((check) => check.id === "provider.connection" && check.status === "pass");
76
77
  if (connected)
77
- checks.push(...(await diagnoseImage({ provider, agent, image }, execute)));
78
+ checks.push(...(await diagnoseImage({ sandboxProvider, agent, image }, execute)));
78
79
  else
79
80
  checks.push({
80
81
  id: "image.runtime",
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/application/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5E,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAsB,EACtB,UAAoB,cAAc;IAElC,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,OAAO,CAAC;IAC3C,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;QACxB,SAAS,CACP,QAAQ,KAAK,QAAQ,IAAI,QAAQ,KAAK,QAAQ,EAC9C,oCAAoC,CACrC,CAAC;QACF,SAAS,CACP,KAAK,CAAC,MAAM,GAAG,CAAC;YACd,CAAC,KAAK,CAAC,UAAU,CAAC,GAAG,CAAC;YACtB,CAAC,iBAAiB,CAAC,IAAI,CAAC,KAAK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AE,QAAQ,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC,CAC9D,CAAC;;YAEF,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,eAAe;gBACnB,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,oDAAoD;aAC9D,CAAC,CAAC;IACP,CAAC;IACD,IAAI,YAAY,CAAC,SAAS,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS;QAC1D,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,eAAe;YACnB,MAAM,EAAE,SAAS;YACjB,OAAO,EACL,kGAAkG;SACrG,CAAC,CAAC;IACL,MAAM,CAAC,IAAI,CAAC;QACV,EAAE,EAAE,WAAW;QACf,MAAM,EAAE,SAAS;QACjB,OAAO,EACL,KAAK,KAAK,SAAS;YACjB,CAAC,CAAC,4GAA4G;YAC9G,CAAC,CAAC,mIAAmI;KAC1I,CAAC,CAAC;IACH,OAAO;QACL,GAAG,OAAO;QACV,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB;QACtD,GAAG,YAAY;QACf,MAAM;QACN,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../domain/errors.ts\";\nimport { executeProcess } from \"../infrastructure/process.ts\";\nimport type { Executor } from \"../infrastructure/process.types.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport { diagnoseImage } from \"./doctor-image.ts\";\nimport { diagnosticProbe } from \"./diagnostic-probe.ts\";\nimport { doctorDefaults, providerDiagnostics } from \"./doctor.constants.ts\";\nimport type {\n DiagnosticCheck,\n DoctorOptions,\n DoctorReport,\n} from \"./doctor.types.ts\";\n\nexport async function diagnose(\n options: DoctorOptions,\n execute: Executor = executeProcess,\n): Promise<DoctorReport> {\n const { provider, agent, image } = options;\n if (image !== undefined) {\n invariant(\n provider === \"docker\" || provider === \"podman\",\n \"--image requires docker or podman.\",\n );\n invariant(\n image.length > 0 &&\n !image.startsWith(\"-\") &&\n !/[\\x00-\\x20\\x7f]/.test(image),\n \"Invalid diagnostic image name.\",\n );\n }\n const capabilities = providerDiagnostics[provider];\n const checks: DiagnosticCheck[] = [\n {\n id: \"host.node\",\n status:\n Number(process.versions.node.split(\".\")[0]) >=\n doctorDefaults.minimumNodeMajor\n ? \"pass\"\n : \"fail\",\n version: process.versions.node,\n message: `Outpost requires Node.js ${doctorDefaults.minimumNodeMajor}+.`,\n },\n ];\n checks.push(\n await diagnosticProbe(\n {\n id: \"host.git\",\n command: { executable: \"git\", arguments: [\"--version\"] },\n failureStatus: \"fail\",\n remedy: \"Install Git and make it available on PATH.\",\n readVersion: true,\n },\n execute,\n ),\n );\n if (capabilities.placement === \"mounted\") {\n const engine = await diagnosticProbe(\n {\n id: \"provider.cli\",\n command: { executable: provider, arguments: [\"--version\"] },\n failureStatus: \"fail\",\n remedy: `Install ${provider} and make it available on PATH.`,\n readVersion: true,\n },\n execute,\n );\n checks.push(engine);\n if (engine.status === \"pass\")\n checks.push(\n await diagnosticProbe(\n {\n id: \"provider.connection\",\n command: {\n executable: provider,\n arguments: [\"info\"],\n },\n failureStatus: \"fail\",\n remedy: `Check ${provider} is running and accessible to this user; on macOS, start its virtual machine.`,\n },\n execute,\n ),\n );\n checks.push(\n await diagnosticProbe(\n {\n id: \"host.tar\",\n command: { executable: \"tar\", arguments: [\"--version\"] },\n failureStatus: \"fail\",\n remedy: \"Install GNU tar or bsdtar for container transfers.\",\n },\n execute,\n ),\n );\n }\n if (capabilities.placement === \"remote\")\n checks.push({\n id: \"provider.cloud\",\n status: \"skipped\",\n message:\n \"Cloud SDK, credentials, account access and allocation are not checked.\",\n });\n checks.push(\n await diagnosticProbe(\n {\n id: \"agent.host\",\n command: { executable: agent, arguments: [\"--version\"] },\n failureStatus: \"warn\",\n remedy:\n \"Host CLI is unavailable or unverified. A sandbox may have its own CLI; dispatch can bootstrap a missing agent.\",\n readVersion: true,\n referenceVersion: agentVersions[agent],\n },\n execute,\n ),\n );\n if (image !== undefined && (provider === \"docker\" || provider === \"podman\")) {\n const connected = checks.some(\n (check) => check.id === \"provider.connection\" && check.status === \"pass\",\n );\n if (connected)\n checks.push(\n ...(await diagnoseImage({ provider, agent, image }, execute)),\n );\n else\n checks.push({\n id: \"image.runtime\",\n status: \"skipped\",\n message: \"Image checks require a reachable container engine.\",\n });\n }\n if (capabilities.placement !== \"host\" && image === undefined)\n checks.push({\n id: \"agent.sandbox\",\n status: \"skipped\",\n message:\n \"Agent version inside the sandbox is not checked; the host version does not describe the sandbox.\",\n });\n checks.push({\n id: \"execution\",\n status: \"skipped\",\n message:\n image === undefined\n ? \"Images, mounts, repository state, authentication and model access are not tested. No sandbox is allocated.\"\n : \"Workflow mounts, repository state, authentication and model access are not tested. Image checks use a separate temporary sandbox.\",\n });\n return {\n ...options,\n scope: image === undefined ? \"host\" : \"host-and-image\",\n ...capabilities,\n checks,\n hasFailures: checks.some((check) => check.status === \"fail\"),\n };\n}\n"]}
1
+ {"version":3,"file":"doctor.js","sourceRoot":"","sources":["../../src/application/doctor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,oCAAoC,CAAC;AACnE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAO5E,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,OAAsB,EACtB,UAAoB,cAAc;IAElC,MAAM,EAAE,eAAe,EAAE,KAAK,EAAE,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AAQ,IAAI,eAAe,KAAK,QAAQ,CAAC,EAC9D,CAAC;QACD,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAC3B,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,EAAE,KAAK,qBAAqB,IAAI,KAAK,CAAC,MAAM,KAAK,MAAM,CACzE,CAAC;QACF,IAAI,SAAS;YACX,MAAM,CAAC,IAAI,CACT,GAAG,CAAC,MAAM,aAAa,CAAC,EAAE,eAAe,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE,OAAO,CAAC,CAAC,CACrE,CAAC;;YAEF,MAAM,CAAC,IAAI,CAAC;gBACV,EAAE,EAAE,eAAe;gBACnB,MAAM,EAAE,SAAS;gBACjB,OAAO,EAAE,oDAAoD;aAC9D,CAAC,CAAC;IACP,CAAC;IACD,IAAI,YAAY,CAAC,SAAS,KAAK,MAAM,IAAI,KAAK,KAAK,SAAS;QAC1D,MAAM,CAAC,IAAI,CAAC;YACV,EAAE,EAAE,eAAe;YACnB,MAAM,EAAE,SAAS;YACjB,OAAO,EACL,kGAAkG;SACrG,CAAC,CAAC;IACL,MAAM,CAAC,IAAI,CAAC;QACV,EAAE,EAAE,WAAW;QACf,MAAM,EAAE,SAAS;QACjB,OAAO,EACL,KAAK,KAAK,SAAS;YACjB,CAAC,CAAC,4GAA4G;YAC9G,CAAC,CAAC,mIAAmI;KAC1I,CAAC,CAAC;IACH,OAAO;QACL,GAAG,OAAO;QACV,KAAK,EAAE,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,gBAAgB;QACtD,GAAG,YAAY;QACf,MAAM;QACN,WAAW,EAAE,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,MAAM,KAAK,MAAM,CAAC;KAC7D,CAAC;AACJ,CAAC","sourcesContent":["import { invariant } from \"../domain/errors.ts\";\nimport { executeProcess } from \"../infrastructure/process.ts\";\nimport type { Executor } from \"../infrastructure/process.types.ts\";\nimport { agentVersions } from \"../providers/versions.constants.ts\";\nimport { diagnoseImage } from \"./doctor-image.ts\";\nimport { diagnosticProbe } from \"./diagnostic-probe.ts\";\nimport { doctorDefaults, providerDiagnostics } from \"./doctor.constants.ts\";\nimport type {\n DiagnosticCheck,\n DoctorOptions,\n DoctorReport,\n} from \"./doctor.types.ts\";\n\nexport async function diagnose(\n options: DoctorOptions,\n execute: Executor = executeProcess,\n): Promise<DoctorReport> {\n const { sandboxProvider, agent, image } = options;\n if (image !== undefined) {\n invariant(\n sandboxProvider === \"docker\" || sandboxProvider === \"podman\",\n \"--image requires docker or podman.\",\n );\n invariant(\n image.length > 0 &&\n !image.startsWith(\"-\") &&\n !/[\\x00-\\x20\\x7f]/.test(image),\n \"Invalid diagnostic image name.\",\n );\n }\n const capabilities = providerDiagnostics[sandboxProvider];\n const checks: DiagnosticCheck[] = [\n {\n id: \"host.node\",\n status:\n Number(process.versions.node.split(\".\")[0]) >=\n doctorDefaults.minimumNodeMajor\n ? \"pass\"\n : \"fail\",\n version: process.versions.node,\n message: `Outpost requires Node.js ${doctorDefaults.minimumNodeMajor}+.`,\n },\n ];\n checks.push(\n await diagnosticProbe(\n {\n id: \"host.git\",\n command: { executable: \"git\", arguments: [\"--version\"] },\n failureStatus: \"fail\",\n remedy: \"Install Git and make it available on PATH.\",\n readVersion: true,\n },\n execute,\n ),\n );\n if (capabilities.placement === \"mounted\") {\n const engine = await diagnosticProbe(\n {\n id: \"provider.cli\",\n command: { executable: sandboxProvider, arguments: [\"--version\"] },\n failureStatus: \"fail\",\n remedy: `Install ${sandboxProvider} and make it available on PATH.`,\n readVersion: true,\n },\n execute,\n );\n checks.push(engine);\n if (engine.status === \"pass\")\n checks.push(\n await diagnosticProbe(\n {\n id: \"provider.connection\",\n command: {\n executable: sandboxProvider,\n arguments: [\"info\"],\n },\n failureStatus: \"fail\",\n remedy: `Check ${sandboxProvider} is running and accessible to this user; on macOS, start its virtual machine.`,\n },\n execute,\n ),\n );\n checks.push(\n await diagnosticProbe(\n {\n id: \"host.tar\",\n command: { executable: \"tar\", arguments: [\"--version\"] },\n failureStatus: \"fail\",\n remedy: \"Install GNU tar or bsdtar for container transfers.\",\n },\n execute,\n ),\n );\n }\n if (capabilities.placement === \"remote\")\n checks.push({\n id: \"provider.cloud\",\n status: \"skipped\",\n message:\n \"Cloud SDK, credentials, account access and allocation are not checked.\",\n });\n checks.push(\n await diagnosticProbe(\n {\n id: \"agent.host\",\n command: { executable: agent, arguments: [\"--version\"] },\n failureStatus: \"warn\",\n remedy:\n \"Host CLI is unavailable or unverified. A sandbox may have its own CLI; dispatch can bootstrap a missing agent.\",\n readVersion: true,\n referenceVersion: agentVersions[agent],\n },\n execute,\n ),\n );\n if (\n image !== undefined &&\n (sandboxProvider === \"docker\" || sandboxProvider === \"podman\")\n ) {\n const connected = checks.some(\n (check) => check.id === \"provider.connection\" && check.status === \"pass\",\n );\n if (connected)\n checks.push(\n ...(await diagnoseImage({ sandboxProvider, agent, image }, execute)),\n );\n else\n checks.push({\n id: \"image.runtime\",\n status: \"skipped\",\n message: \"Image checks require a reachable container engine.\",\n });\n }\n if (capabilities.placement !== \"host\" && image === undefined)\n checks.push({\n id: \"agent.sandbox\",\n status: \"skipped\",\n message:\n \"Agent version inside the sandbox is not checked; the host version does not describe the sandbox.\",\n });\n checks.push({\n id: \"execution\",\n status: \"skipped\",\n message:\n image === undefined\n ? \"Images, mounts, repository state, authentication and model access are not tested. No sandbox is allocated.\"\n : \"Workflow mounts, repository state, authentication and model access are not tested. Image checks use a separate temporary sandbox.\",\n });\n return {\n ...options,\n scope: image === undefined ? \"host\" : \"host-and-image\",\n ...capabilities,\n checks,\n hasFailures: checks.some((check) => check.status === \"fail\"),\n };\n}\n"]}
@@ -11,16 +11,16 @@ export interface DiagnosticCheck {
11
11
  }
12
12
  export interface DoctorOptions {
13
13
  readonly image?: string;
14
- readonly provider: DoctorProvider;
14
+ readonly sandboxProvider: DoctorProvider;
15
15
  readonly agent: DoctorAgent;
16
16
  }
17
17
  export interface DoctorImageOptions {
18
- readonly provider: "docker" | "podman";
18
+ readonly sandboxProvider: "docker" | "podman";
19
19
  readonly agent: DoctorAgent;
20
20
  readonly image: string;
21
21
  }
22
22
  export interface DoctorReport {
23
- readonly provider: DoctorProvider;
23
+ readonly sandboxProvider: DoctorProvider;
24
24
  readonly agent: DoctorAgent;
25
25
  readonly scope: "host" | "host-and-image";
26
26
  readonly image?: string;
@@ -1 +1 @@
1
- {"version":3,"file":"doctor.types.js","sourceRoot":"","sources":["../../src/application/doctor.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command } from \"../domain/command.types.ts\";\nexport type DoctorProvider =\n \"docker\" | \"podman\" | \"local\" | \"vercel\" | \"daytona\";\nexport type DoctorAgent = \"codex\" | \"claude\" | \"gemini\";\nexport type DiagnosticStatus = \"pass\" | \"warn\" | \"fail\" | \"skipped\";\nexport interface DiagnosticCheck {\n readonly id: string;\n readonly status: DiagnosticStatus;\n readonly message: string;\n readonly version?: string;\n readonly referenceVersion?: string;\n}\nexport interface DoctorOptions {\n readonly image?: string;\n readonly provider: DoctorProvider;\n readonly agent: DoctorAgent;\n}\nexport interface DoctorImageOptions {\n readonly provider: \"docker\" | \"podman\";\n readonly agent: DoctorAgent;\n readonly image: string;\n}\nexport interface DoctorReport {\n readonly provider: DoctorProvider;\n readonly agent: DoctorAgent;\n readonly scope: \"host\" | \"host-and-image\";\n readonly image?: string;\n readonly placement: \"mounted\" | \"host\" | \"remote\";\n readonly interactiveTerminal: boolean;\n readonly checks: readonly DiagnosticCheck[];\n readonly hasFailures: boolean;\n}\nexport interface DiagnosticProbe {\n readonly id: string;\n readonly command: Command;\n readonly failureStatus: \"fail\" | \"warn\";\n readonly remedy: string;\n readonly readVersion?: boolean;\n readonly referenceVersion?: string;\n}\n"]}
1
+ {"version":3,"file":"doctor.types.js","sourceRoot":"","sources":["../../src/application/doctor.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Command } from \"../domain/command.types.ts\";\nexport type DoctorProvider =\n \"docker\" | \"podman\" | \"local\" | \"vercel\" | \"daytona\";\nexport type DoctorAgent = \"codex\" | \"claude\" | \"gemini\";\nexport type DiagnosticStatus = \"pass\" | \"warn\" | \"fail\" | \"skipped\";\nexport interface DiagnosticCheck {\n readonly id: string;\n readonly status: DiagnosticStatus;\n readonly message: string;\n readonly version?: string;\n readonly referenceVersion?: string;\n}\nexport interface DoctorOptions {\n readonly image?: string;\n readonly sandboxProvider: DoctorProvider;\n readonly agent: DoctorAgent;\n}\nexport interface DoctorImageOptions {\n readonly sandboxProvider: \"docker\" | \"podman\";\n readonly agent: DoctorAgent;\n readonly image: string;\n}\nexport interface DoctorReport {\n readonly sandboxProvider: DoctorProvider;\n readonly agent: DoctorAgent;\n readonly scope: \"host\" | \"host-and-image\";\n readonly image?: string;\n readonly placement: \"mounted\" | \"host\" | \"remote\";\n readonly interactiveTerminal: boolean;\n readonly checks: readonly DiagnosticCheck[];\n readonly hasFailures: boolean;\n}\nexport interface DiagnosticProbe {\n readonly id: string;\n readonly command: Command;\n readonly failureStatus: \"fail\" | \"warn\";\n readonly remedy: string;\n readonly readVersion?: boolean;\n readonly referenceVersion?: string;\n}\n"]}
@@ -1,4 +1,4 @@
1
- import type { AgentAdapter } from "../domain/agent.types.ts";
1
+ import type { Agent } from "../domain/agent.types.ts";
2
2
  import type { SandboxLease } from "../domain/sandbox.types.ts";
3
3
  import type { WorkspaceRecord } from "../domain/workspace.types.ts";
4
4
  import type { DispatchOptions, Execution, Turn } from "./execution.types.ts";
@@ -6,4 +6,4 @@ export { renderBrief } from "./brief-renderer.ts";
6
6
  export { preflightDispatch, validateDispatch } from "./dispatch-validation.ts";
7
7
  export type { DispatchOptions, Execution, Turn } from "./execution.types.ts";
8
8
  export { notify } from "./observation.ts";
9
- export declare function execute<T>(workspace: WorkspaceRecord, lease: SandboxLease, agent: AgentAdapter, host: boolean, options: DispatchOptions<T>, afterTurn?: (turn: Turn) => Promise<Turn>): Promise<Execution<T>>;
9
+ export declare function execute<T>(workspace: WorkspaceRecord, lease: SandboxLease, agent: Agent, host: boolean, options: DispatchOptions<T>, afterTurn?: (turn: Turn) => Promise<Turn>): Promise<Execution<T>>;
@@ -51,7 +51,7 @@ export async function execute(workspace, lease, agent, host, options, afterTurn)
51
51
  pass: index + 1,
52
52
  at: new Date().toISOString(),
53
53
  });
54
- const finished = await turn(lease, agent, prompt, options, continuation, markers, index + 1);
54
+ const finished = await turn(lease, agent, prompt, options, continuation, markers, index + 1, { repository: workspace.repository, repair: repair !== undefined });
55
55
  const current = afterTurn ? await afterTurn(finished) : finished;
56
56
  turns.push(current);
57
57
  notify(options.observe, {
@@ -1 +1 @@
1
- {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/application/execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAE7D,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,MAAM,CAAC,KAAK,UAAU,OAAO,CAC3B,SAA0B,EAC1B,KAAmB,EACnB,KAAmB,EACnB,IAAa,EACb,OAA2B,EAC3B,SAAyC;IAEzC,gBAAgB,CAAC,OAAO,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BAClG,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACf,CAAC;QACH,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,SAAS;YAAE,MAAM;IAC5C,CAAC;IACD,MAAM,YAAY,GAAG,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,YAAY,CAAC;IAChD,MAAM,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC,MAAM,EAAE,EAAE,CACzC,KAAK,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC,CACpC,CAAC;IACF,OAAO;QACL,IAAI,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC;QAC/C,KAAK;QACL,KAAK;QACL,SAAS;QACT,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACrC,GAAG,CAAC,YAAY,CAAC,CAAC,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACzC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE;YAC5D,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;SACD,CAAC;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import type { AgentAdapter, Usage } from \"../domain/agent.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport { ResponseError } from \"../domain/response.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport type { WorkspaceRecord } from \"../domain/workspace.types.ts\";\nimport { turn } from \"./agent-turn.ts\";\nimport { renderBrief } from \"./brief-renderer.ts\";\nimport { validateDispatch } from \"./dispatch-validation.ts\";\nimport { executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions, Execution, Turn } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\n\nexport { renderBrief } from \"./brief-renderer.ts\";\nexport { preflightDispatch, validateDispatch } from \"./dispatch-validation.ts\";\nexport type { DispatchOptions, Execution, Turn } from \"./execution.types.ts\";\nexport { notify } from \"./observation.ts\";\n\nexport async function execute<T>(\n workspace: WorkspaceRecord,\n lease: SandboxLease,\n agent: AgentAdapter,\n host: boolean,\n options: DispatchOptions<T>,\n afterTurn?: (turn: Turn) => Promise<Turn>,\n): Promise<Execution<T>> {\n validateDispatch(options);\n const markers =\n options.until === undefined\n ? [executionDefaults.completion]\n : typeof options.until === \"string\"\n ? [options.until]\n : options.until;\n const turns: Turn[] = [];\n let value: T = undefined as T,\n completed = false,\n continuation = options.continuation;\n let repair: string | undefined;\n const attempts = options.response\n ? 1 + options.response.repairs\n : (options.passes ?? executionDefaults.passes);\n for (let index = 0; index < attempts; index++) {\n options.signal?.throwIfAborted();\n notify(options.observe, {\n kind: \"phase\",\n name: \"preparing prompt\",\n agent: agent.name,\n branch: workspace.branch,\n directory: workspace.directory,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n const prompt =\n repair ??\n (await renderBrief(options.brief, workspace, lease, host, options));\n if (options.response && !repair)\n invariant(\n prompt.includes(`<${options.response.tag}>`),\n `Brief must request an opening <${options.response.tag}> tag`,\n );\n notify(options.observe, {\n kind: \"prompt\",\n text: prompt,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n notify(options.observe, {\n kind: \"phase\",\n name: \"running\",\n agent: agent.name,\n branch: workspace.branch,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n const finished = await turn(\n lease,\n agent,\n prompt,\n options,\n continuation,\n markers,\n index + 1,\n );\n const current = afterTurn ? await afterTurn(finished) : finished;\n turns.push(current);\n notify(options.observe, {\n kind: \"summary\",\n durationMs: current.durationMs,\n status: current.status,\n tokens: current.usage,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n completed = markers.some((marker) => current.text.includes(marker));\n if (options.response) {\n try {\n value = await options.response.read(current.text);\n completed = true;\n break;\n } catch (error) {\n if (!(error instanceof ResponseError)) throw error;\n error.recovery = {\n conversation: current.conversation,\n branch: workspace.branch,\n directory: workspace.directory,\n turns,\n };\n if (index + 1 >= attempts || !current.conversation) throw error;\n continuation = { id: current.conversation };\n repair = [\n `Correct the response inside <${options.response.tag}> and </${options.response.tag}>.`,\n `Validation failure: ${error.message}`,\n `Previous content: ${error.raw ?? \"No complete tagged response was returned.\"}`,\n `Cause: ${error.cause instanceof Error ? error.cause.message : (JSON.stringify(error.cause) ?? \"unspecified\")}`,\n `Further repair attempts after this one: ${attempts - index - 2}.`,\n \"Do not edit files, run commands or continue implementation. Only return the corrected response.\",\n ].join(\"\\n\");\n }\n }\n if (!options.response && completed) break;\n }\n const conversation = turns.at(-1)?.conversation;\n const completion = markers.find((marker) =>\n turns.at(-1)?.text.includes(marker),\n );\n return {\n text: turns.map((item) => item.text).join(\"\\n\"),\n turns,\n value,\n completed,\n ...(completion ? { completion } : {}),\n ...(conversation ? { conversation } : {}),\n usage: turns.reduce((sum, item) => addUsage(sum, item.usage), {\n input: 0,\n cached: 0,\n output: 0,\n } as Usage),\n };\n}\n"]}
1
+ {"version":3,"file":"execution.js","sourceRoot":"","sources":["../../src/application/execution.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;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,CAAC,EAAE,CAAC;QACzC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC,KAAK,CAAC,EAAE;YAC5D,KAAK,EAAE,CAAC;YACR,MAAM,EAAE,CAAC;YACT,MAAM,EAAE,CAAC;SACD,CAAC;KACZ,CAAC;AACJ,CAAC","sourcesContent":["import type { Agent, Usage } from \"../domain/agent.types.ts\";\nimport { invariant } from \"../domain/errors.ts\";\nimport { ResponseError } from \"../domain/response.ts\";\nimport type { SandboxLease } from \"../domain/sandbox.types.ts\";\nimport { addUsage } from \"../domain/usage.ts\";\nimport type { WorkspaceRecord } from \"../domain/workspace.types.ts\";\nimport { turn } from \"./agent-turn.ts\";\nimport { renderBrief } from \"./brief-renderer.ts\";\nimport { validateDispatch } from \"./dispatch-validation.ts\";\nimport { executionDefaults } from \"./execution.constants.ts\";\nimport type { DispatchOptions, Execution, Turn } from \"./execution.types.ts\";\nimport { notify } from \"./observation.ts\";\n\nexport { renderBrief } from \"./brief-renderer.ts\";\nexport { preflightDispatch, validateDispatch } from \"./dispatch-validation.ts\";\nexport type { DispatchOptions, Execution, Turn } from \"./execution.types.ts\";\nexport { notify } from \"./observation.ts\";\n\nexport async function execute<T>(\n workspace: WorkspaceRecord,\n lease: SandboxLease,\n agent: Agent,\n host: boolean,\n options: DispatchOptions<T>,\n afterTurn?: (turn: Turn) => Promise<Turn>,\n): Promise<Execution<T>> {\n validateDispatch(options);\n const markers =\n options.until === undefined\n ? [executionDefaults.completion]\n : typeof options.until === \"string\"\n ? [options.until]\n : options.until;\n const turns: Turn[] = [];\n let value: T = undefined as T,\n completed = false,\n continuation = options.continuation;\n let repair: string | undefined;\n const attempts = options.response\n ? 1 + options.response.repairs\n : (options.passes ?? executionDefaults.passes);\n for (let index = 0; index < attempts; index++) {\n options.signal?.throwIfAborted();\n notify(options.observe, {\n kind: \"phase\",\n name: \"preparing prompt\",\n agent: agent.name,\n branch: workspace.branch,\n directory: workspace.directory,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n const prompt =\n repair ??\n (await renderBrief(options.brief, workspace, lease, host, options));\n if (options.response && !repair)\n invariant(\n prompt.includes(`<${options.response.tag}>`),\n `Brief must request an opening <${options.response.tag}> tag`,\n );\n notify(options.observe, {\n kind: \"prompt\",\n text: prompt,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n notify(options.observe, {\n kind: \"phase\",\n name: \"running\",\n agent: agent.name,\n branch: workspace.branch,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n const finished = await turn(\n lease,\n agent,\n prompt,\n options,\n continuation,\n markers,\n index + 1,\n { repository: workspace.repository, repair: repair !== undefined },\n );\n const current = afterTurn ? await afterTurn(finished) : finished;\n turns.push(current);\n notify(options.observe, {\n kind: \"summary\",\n durationMs: current.durationMs,\n status: current.status,\n tokens: current.usage,\n pass: index + 1,\n at: new Date().toISOString(),\n });\n completed = markers.some((marker) => current.text.includes(marker));\n if (options.response) {\n try {\n value = await options.response.read(current.text);\n completed = true;\n break;\n } catch (error) {\n if (!(error instanceof ResponseError)) throw error;\n error.recovery = {\n conversation: current.conversation,\n branch: workspace.branch,\n directory: workspace.directory,\n turns,\n };\n if (index + 1 >= attempts || !current.conversation) throw error;\n continuation = { id: current.conversation };\n repair = [\n `Correct the response inside <${options.response.tag}> and </${options.response.tag}>.`,\n `Validation failure: ${error.message}`,\n `Previous content: ${error.raw ?? \"No complete tagged response was returned.\"}`,\n `Cause: ${error.cause instanceof Error ? error.cause.message : (JSON.stringify(error.cause) ?? \"unspecified\")}`,\n `Further repair attempts after this one: ${attempts - index - 2}.`,\n \"Do not edit files, run commands or continue implementation. Only return the corrected response.\",\n ].join(\"\\n\");\n }\n }\n if (!options.response && completed) break;\n }\n const conversation = turns.at(-1)?.conversation;\n const completion = markers.find((marker) =>\n turns.at(-1)?.text.includes(marker),\n );\n return {\n text: turns.map((item) => item.text).join(\"\\n\"),\n turns,\n value,\n completed,\n ...(completion ? { completion } : {}),\n ...(conversation ? { conversation } : {}),\n usage: turns.reduce((sum, item) => addUsage(sum, item.usage), {\n input: 0,\n cached: 0,\n output: 0,\n } as Usage),\n };\n}\n"]}
@@ -1,10 +1,11 @@
1
1
  import type { TransportReference } from "../domain/transport.types.ts";
2
- import type { AgentAdapter, AgentObservation, Usage } from "../domain/agent.types.ts";
2
+ import type { Agent, AgentObservation, Usage } from "../domain/agent.types.ts";
3
+ import type { DispatchTelemetry } from "../domain/dispatch-telemetry.types.ts";
3
4
  import type { Brief } from "../domain/prompts.types.ts";
4
5
  import type { ResponseSpec } from "../domain/response.types.ts";
5
6
  import type { Logging } from "../infrastructure/journal.types.ts";
6
7
  export interface DispatchOptions<T = undefined> {
7
- readonly agent?: AgentAdapter;
8
+ readonly agent?: Agent;
8
9
  readonly logging?: Logging;
9
10
  readonly label?: string;
10
11
  readonly brief: Brief;
@@ -21,10 +22,15 @@ export interface DispatchOptions<T = undefined> {
21
22
  readonly fork?: boolean;
22
23
  };
23
24
  readonly response?: ResponseSpec<T>;
25
+ readonly telemetry?: DispatchTelemetry;
24
26
  readonly observe?: (event: AgentObservation) => void;
25
27
  readonly warn?: (message: string) => void;
26
28
  readonly diagnostic?: (message: string) => void;
27
29
  }
30
+ export interface TurnContext {
31
+ readonly repository: string;
32
+ readonly repair: boolean;
33
+ }
28
34
  export interface Turn {
29
35
  readonly text: string;
30
36
  readonly status: number;
@@ -43,6 +49,7 @@ export interface AgentOutput {
43
49
  }
44
50
  export interface ActivityWatchdog {
45
51
  refresh(completed: boolean): void;
52
+ hold(): () => void;
46
53
  close(): void;
47
54
  }
48
55
  export interface Execution<T> {
@@ -1 +1 @@
1
- {"version":3,"file":"execution.types.js","sourceRoot":"","sources":["../../src/application/execution.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TransportReference } from \"../domain/transport.types.ts\";\nimport type {\n AgentAdapter,\n AgentObservation,\n Usage,\n} from \"../domain/agent.types.ts\";\nimport type { Brief } from \"../domain/prompts.types.ts\";\nimport type { ResponseSpec } from \"../domain/response.types.ts\";\nimport type { Logging } from \"../infrastructure/journal.types.ts\";\n\nexport interface DispatchOptions<T = undefined> {\n readonly agent?: AgentAdapter;\n readonly logging?: Logging;\n readonly label?: string;\n readonly brief: Brief;\n readonly passes?: number;\n readonly until?: string | readonly string[];\n readonly idleMs?: number;\n readonly idleWarningMs?: number;\n readonly settleMs?: number;\n readonly deadlineMs?: number;\n readonly expansionMs?: number;\n readonly signal?: AbortSignal;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n readonly response?: ResponseSpec<T>;\n readonly observe?: (event: AgentObservation) => void;\n readonly warn?: (message: string) => void;\n readonly diagnostic?: (message: string) => void;\n}\n\nexport interface Turn {\n readonly text: string;\n readonly status: number;\n readonly conversation?: string;\n readonly transcript?: string;\n readonly transcriptReference?: TransportReference;\n readonly usage: Usage;\n readonly durationMs: number;\n}\n\nexport interface AgentOutput {\n readonly completed: boolean;\n readonly conversation: string | undefined;\n append(chunk: string): void;\n flush(): void;\n result(): Pick<Turn, \"text\" | \"usage\" | \"conversation\">;\n}\n\nexport interface ActivityWatchdog {\n refresh(completed: boolean): void;\n close(): void;\n}\n\nexport interface Execution<T> {\n readonly text: string;\n readonly turns: readonly Turn[];\n readonly usage: Usage;\n readonly conversation?: string;\n readonly value: T;\n readonly completed: boolean;\n readonly completion?: string;\n}\n"]}
1
+ {"version":3,"file":"execution.types.js","sourceRoot":"","sources":["../../src/application/execution.types.ts"],"names":[],"mappings":"","sourcesContent":["import type { TransportReference } from \"../domain/transport.types.ts\";\nimport type { Agent, AgentObservation, Usage } from \"../domain/agent.types.ts\";\nimport type { DispatchTelemetry } from \"../domain/dispatch-telemetry.types.ts\";\nimport type { Brief } from \"../domain/prompts.types.ts\";\nimport type { ResponseSpec } from \"../domain/response.types.ts\";\nimport type { Logging } from \"../infrastructure/journal.types.ts\";\n\nexport interface DispatchOptions<T = undefined> {\n readonly agent?: Agent;\n readonly logging?: Logging;\n readonly label?: string;\n readonly brief: Brief;\n readonly passes?: number;\n readonly until?: string | readonly string[];\n readonly idleMs?: number;\n readonly idleWarningMs?: number;\n readonly settleMs?: number;\n readonly deadlineMs?: number;\n readonly expansionMs?: number;\n readonly signal?: AbortSignal;\n readonly continuation?: { readonly id: string; readonly fork?: boolean };\n readonly response?: ResponseSpec<T>;\n readonly telemetry?: DispatchTelemetry;\n readonly observe?: (event: AgentObservation) => void;\n readonly warn?: (message: string) => void;\n readonly diagnostic?: (message: string) => void;\n}\n\nexport interface TurnContext {\n readonly repository: string;\n readonly repair: boolean;\n}\n\nexport interface Turn {\n readonly text: string;\n readonly status: number;\n readonly conversation?: string;\n readonly transcript?: string;\n readonly transcriptReference?: TransportReference;\n readonly usage: Usage;\n readonly durationMs: number;\n}\n\nexport interface AgentOutput {\n readonly completed: boolean;\n readonly conversation: string | undefined;\n append(chunk: string): void;\n flush(): void;\n result(): Pick<Turn, \"text\" | \"usage\" | \"conversation\">;\n}\n\nexport interface ActivityWatchdog {\n refresh(completed: boolean): void;\n hold(): () => void;\n close(): void;\n}\n\nexport interface Execution<T> {\n readonly text: string;\n readonly turns: readonly Turn[];\n readonly usage: Usage;\n readonly conversation?: string;\n readonly value: T;\n readonly completed: boolean;\n readonly completion?: string;\n}\n"]}
@@ -0,0 +1,2 @@
1
+ import type { HarnessHistory, HarnessRuntime } from "./harness.types.ts";
2
+ export declare function compact(runtime: HarnessRuntime, history: HarnessHistory, step: number): Promise<void>;