@useconvoy/cli 0.48.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 (664) hide show
  1. package/LICENSE +90 -0
  2. package/README.md +495 -0
  3. package/dist/bin/convoy.d.ts +2 -0
  4. package/dist/bin/convoy.js +129 -0
  5. package/dist/bin/convoy.js.map +1 -0
  6. package/dist/marketplace/.claude-plugin/marketplace.json +14 -0
  7. package/dist/marketplace/opensana/.claude-plugin/plugin.json +5 -0
  8. package/dist/marketplace/opensana/README.md +90 -0
  9. package/dist/marketplace/opensana/skills/tasks/SKILL.md +133 -0
  10. package/dist/marketplace/opensana/skills/tasks/references/mcp-setup.md +164 -0
  11. package/dist/src/agent/app/chunk-flush-buffer.d.ts +35 -0
  12. package/dist/src/agent/app/chunk-flush-buffer.js +133 -0
  13. package/dist/src/agent/app/chunk-flush-buffer.js.map +1 -0
  14. package/dist/src/agent/app/chunk-scrub.d.ts +9 -0
  15. package/dist/src/agent/app/chunk-scrub.js +120 -0
  16. package/dist/src/agent/app/chunk-scrub.js.map +1 -0
  17. package/dist/src/agent/app/interaction-router.d.ts +16 -0
  18. package/dist/src/agent/app/interaction-router.js +29 -0
  19. package/dist/src/agent/app/interaction-router.js.map +1 -0
  20. package/dist/src/agent/app/runner.d.ts +41 -0
  21. package/dist/src/agent/app/runner.js +353 -0
  22. package/dist/src/agent/app/runner.js.map +1 -0
  23. package/dist/src/agent/app/runtime-config.d.ts +3 -0
  24. package/dist/src/agent/app/runtime-config.js +4 -0
  25. package/dist/src/agent/app/runtime-config.js.map +1 -0
  26. package/dist/src/agent/app/thread-attachment-cache.d.ts +17 -0
  27. package/dist/src/agent/app/thread-attachment-cache.js +124 -0
  28. package/dist/src/agent/app/thread-attachment-cache.js.map +1 -0
  29. package/dist/src/agent/app/thread-processor.d.ts +40 -0
  30. package/dist/src/agent/app/thread-processor.js +792 -0
  31. package/dist/src/agent/app/thread-processor.js.map +1 -0
  32. package/dist/src/agent/app/worktree-op-processor.d.ts +27 -0
  33. package/dist/src/agent/app/worktree-op-processor.js +173 -0
  34. package/dist/src/agent/app/worktree-op-processor.js.map +1 -0
  35. package/dist/src/agent/runtimes/agent-instructions.d.ts +16 -0
  36. package/dist/src/agent/runtimes/agent-instructions.js +33 -0
  37. package/dist/src/agent/runtimes/agent-instructions.js.map +1 -0
  38. package/dist/src/agent/runtimes/claudeCode/continuation.d.ts +1 -0
  39. package/dist/src/agent/runtimes/claudeCode/continuation.js +30 -0
  40. package/dist/src/agent/runtimes/claudeCode/continuation.js.map +1 -0
  41. package/dist/src/agent/runtimes/claudeCode/detect.d.ts +12 -0
  42. package/dist/src/agent/runtimes/claudeCode/detect.js +109 -0
  43. package/dist/src/agent/runtimes/claudeCode/detect.js.map +1 -0
  44. package/dist/src/agent/runtimes/claudeCode/interactions.d.ts +13 -0
  45. package/dist/src/agent/runtimes/claudeCode/interactions.js +167 -0
  46. package/dist/src/agent/runtimes/claudeCode/interactions.js.map +1 -0
  47. package/dist/src/agent/runtimes/claudeCode/models.d.ts +3 -0
  48. package/dist/src/agent/runtimes/claudeCode/models.js +16 -0
  49. package/dist/src/agent/runtimes/claudeCode/models.js.map +1 -0
  50. package/dist/src/agent/runtimes/claudeCode/prompts.d.ts +1 -0
  51. package/dist/src/agent/runtimes/claudeCode/prompts.js +5 -0
  52. package/dist/src/agent/runtimes/claudeCode/prompts.js.map +1 -0
  53. package/dist/src/agent/runtimes/claudeCode/runner.d.ts +32 -0
  54. package/dist/src/agent/runtimes/claudeCode/runner.js +941 -0
  55. package/dist/src/agent/runtimes/claudeCode/runner.js.map +1 -0
  56. package/dist/src/agent/runtimes/claudeCode/runtime.d.ts +2 -0
  57. package/dist/src/agent/runtimes/claudeCode/runtime.js +126 -0
  58. package/dist/src/agent/runtimes/claudeCode/runtime.js.map +1 -0
  59. package/dist/src/agent/runtimes/claudeCode/streaming.d.ts +8 -0
  60. package/dist/src/agent/runtimes/claudeCode/streaming.js +88 -0
  61. package/dist/src/agent/runtimes/claudeCode/streaming.js.map +1 -0
  62. package/dist/src/agent/runtimes/codex/app-server-rpc.d.ts +26 -0
  63. package/dist/src/agent/runtimes/codex/app-server-rpc.js +109 -0
  64. package/dist/src/agent/runtimes/codex/app-server-rpc.js.map +1 -0
  65. package/dist/src/agent/runtimes/codex/app-server-runner.d.ts +59 -0
  66. package/dist/src/agent/runtimes/codex/app-server-runner.js +688 -0
  67. package/dist/src/agent/runtimes/codex/app-server-runner.js.map +1 -0
  68. package/dist/src/agent/runtimes/codex/commands.d.ts +23 -0
  69. package/dist/src/agent/runtimes/codex/commands.js +25 -0
  70. package/dist/src/agent/runtimes/codex/commands.js.map +1 -0
  71. package/dist/src/agent/runtimes/codex/detect.d.ts +5 -0
  72. package/dist/src/agent/runtimes/codex/detect.js +17 -0
  73. package/dist/src/agent/runtimes/codex/detect.js.map +1 -0
  74. package/dist/src/agent/runtimes/codex/models.d.ts +2 -0
  75. package/dist/src/agent/runtimes/codex/models.js +4 -0
  76. package/dist/src/agent/runtimes/codex/models.js.map +1 -0
  77. package/dist/src/agent/runtimes/codex/runner.d.ts +46 -0
  78. package/dist/src/agent/runtimes/codex/runner.js +298 -0
  79. package/dist/src/agent/runtimes/codex/runner.js.map +1 -0
  80. package/dist/src/agent/runtimes/codex/runtime.d.ts +10 -0
  81. package/dist/src/agent/runtimes/codex/runtime.js +73 -0
  82. package/dist/src/agent/runtimes/codex/runtime.js.map +1 -0
  83. package/dist/src/agent/runtimes/contracts.d.ts +215 -0
  84. package/dist/src/agent/runtimes/contracts.js +33 -0
  85. package/dist/src/agent/runtimes/contracts.js.map +1 -0
  86. package/dist/src/agent/runtimes/cursor/commands.d.ts +7 -0
  87. package/dist/src/agent/runtimes/cursor/commands.js +39 -0
  88. package/dist/src/agent/runtimes/cursor/commands.js.map +1 -0
  89. package/dist/src/agent/runtimes/cursor/detect.d.ts +17 -0
  90. package/dist/src/agent/runtimes/cursor/detect.js +54 -0
  91. package/dist/src/agent/runtimes/cursor/detect.js.map +1 -0
  92. package/dist/src/agent/runtimes/cursor/models.d.ts +9 -0
  93. package/dist/src/agent/runtimes/cursor/models.js +97 -0
  94. package/dist/src/agent/runtimes/cursor/models.js.map +1 -0
  95. package/dist/src/agent/runtimes/cursor/runner.d.ts +36 -0
  96. package/dist/src/agent/runtimes/cursor/runner.js +293 -0
  97. package/dist/src/agent/runtimes/cursor/runner.js.map +1 -0
  98. package/dist/src/agent/runtimes/cursor/runtime.d.ts +2 -0
  99. package/dist/src/agent/runtimes/cursor/runtime.js +48 -0
  100. package/dist/src/agent/runtimes/cursor/runtime.js.map +1 -0
  101. package/dist/src/agent/runtimes/cursor/streaming.d.ts +8 -0
  102. package/dist/src/agent/runtimes/cursor/streaming.js +78 -0
  103. package/dist/src/agent/runtimes/cursor/streaming.js.map +1 -0
  104. package/dist/src/agent/runtimes/debug.d.ts +8 -0
  105. package/dist/src/agent/runtimes/debug.js +19 -0
  106. package/dist/src/agent/runtimes/debug.js.map +1 -0
  107. package/dist/src/agent/runtimes/message-format.d.ts +6 -0
  108. package/dist/src/agent/runtimes/message-format.js +31 -0
  109. package/dist/src/agent/runtimes/message-format.js.map +1 -0
  110. package/dist/src/agent/runtimes/opencode/client.d.ts +82 -0
  111. package/dist/src/agent/runtimes/opencode/client.js +109 -0
  112. package/dist/src/agent/runtimes/opencode/client.js.map +1 -0
  113. package/dist/src/agent/runtimes/opencode/detect.d.ts +18 -0
  114. package/dist/src/agent/runtimes/opencode/detect.js +100 -0
  115. package/dist/src/agent/runtimes/opencode/detect.js.map +1 -0
  116. package/dist/src/agent/runtimes/opencode/json.d.ts +4 -0
  117. package/dist/src/agent/runtimes/opencode/json.js +17 -0
  118. package/dist/src/agent/runtimes/opencode/json.js.map +1 -0
  119. package/dist/src/agent/runtimes/opencode/runner.d.ts +50 -0
  120. package/dist/src/agent/runtimes/opencode/runner.js +598 -0
  121. package/dist/src/agent/runtimes/opencode/runner.js.map +1 -0
  122. package/dist/src/agent/runtimes/opencode/runtime.d.ts +9 -0
  123. package/dist/src/agent/runtimes/opencode/runtime.js +82 -0
  124. package/dist/src/agent/runtimes/opencode/runtime.js.map +1 -0
  125. package/dist/src/agent/runtimes/opencode/server.d.ts +36 -0
  126. package/dist/src/agent/runtimes/opencode/server.js +210 -0
  127. package/dist/src/agent/runtimes/opencode/server.js.map +1 -0
  128. package/dist/src/agent/runtimes/opencode/streaming.d.ts +7 -0
  129. package/dist/src/agent/runtimes/opencode/streaming.js +47 -0
  130. package/dist/src/agent/runtimes/opencode/streaming.js.map +1 -0
  131. package/dist/src/agent/runtimes/registry.d.ts +10 -0
  132. package/dist/src/agent/runtimes/registry.js +48 -0
  133. package/dist/src/agent/runtimes/registry.js.map +1 -0
  134. package/dist/src/agent/sdk/adapters/adapter-interface.d.ts +2 -0
  135. package/dist/src/agent/sdk/adapters/adapter-interface.js +4 -0
  136. package/dist/src/agent/sdk/adapters/adapter-interface.js.map +1 -0
  137. package/dist/src/agent/sdk/adapters/claude/claude-adapter.d.ts +9 -0
  138. package/dist/src/agent/sdk/adapters/claude/claude-adapter.js +95 -0
  139. package/dist/src/agent/sdk/adapters/claude/claude-adapter.js.map +1 -0
  140. package/dist/src/agent/sdk/adapters/codex/codex-adapter.d.ts +10 -0
  141. package/dist/src/agent/sdk/adapters/codex/codex-adapter.js +87 -0
  142. package/dist/src/agent/sdk/adapters/codex/codex-adapter.js.map +1 -0
  143. package/dist/src/agent/sdk/adapters/executable-resolution.d.ts +2 -0
  144. package/dist/src/agent/sdk/adapters/executable-resolution.js +50 -0
  145. package/dist/src/agent/sdk/adapters/executable-resolution.js.map +1 -0
  146. package/dist/src/agent/sdk/adapters/generic/generic-subprocess-adapter.d.ts +11 -0
  147. package/dist/src/agent/sdk/adapters/generic/generic-subprocess-adapter.js +61 -0
  148. package/dist/src/agent/sdk/adapters/generic/generic-subprocess-adapter.js.map +1 -0
  149. package/dist/src/agent/sdk/adapters/provider-registry.d.ts +8 -0
  150. package/dist/src/agent/sdk/adapters/provider-registry.js +32 -0
  151. package/dist/src/agent/sdk/adapters/provider-registry.js.map +1 -0
  152. package/dist/src/agent/sdk/constants.d.ts +5 -0
  153. package/dist/src/agent/sdk/constants.js +29 -0
  154. package/dist/src/agent/sdk/constants.js.map +1 -0
  155. package/dist/src/agent/sdk/index.d.ts +2 -0
  156. package/dist/src/agent/sdk/index.js +2 -0
  157. package/dist/src/agent/sdk/index.js.map +1 -0
  158. package/dist/src/agent/sdk/run-handle.d.ts +22 -0
  159. package/dist/src/agent/sdk/run-handle.js +90 -0
  160. package/dist/src/agent/sdk/run-handle.js.map +1 -0
  161. package/dist/src/agent/sdk/runtime/isolation-env.d.ts +9 -0
  162. package/dist/src/agent/sdk/runtime/isolation-env.js +39 -0
  163. package/dist/src/agent/sdk/runtime/isolation-env.js.map +1 -0
  164. package/dist/src/agent/sdk/runtime/line-parser.d.ts +11 -0
  165. package/dist/src/agent/sdk/runtime/line-parser.js +59 -0
  166. package/dist/src/agent/sdk/runtime/line-parser.js.map +1 -0
  167. package/dist/src/agent/sdk/runtime/output-pump.d.ts +20 -0
  168. package/dist/src/agent/sdk/runtime/output-pump.js +88 -0
  169. package/dist/src/agent/sdk/runtime/output-pump.js.map +1 -0
  170. package/dist/src/agent/sdk/runtime/process-group.d.ts +9 -0
  171. package/dist/src/agent/sdk/runtime/process-group.js +69 -0
  172. package/dist/src/agent/sdk/runtime/process-group.js.map +1 -0
  173. package/dist/src/agent/sdk/runtime/provider-supervisor-entrypoint.d.ts +1 -0
  174. package/dist/src/agent/sdk/runtime/provider-supervisor-entrypoint.js +3 -0
  175. package/dist/src/agent/sdk/runtime/provider-supervisor-entrypoint.js.map +1 -0
  176. package/dist/src/agent/sdk/runtime/provider-supervisor.d.ts +1 -0
  177. package/dist/src/agent/sdk/runtime/provider-supervisor.js +190 -0
  178. package/dist/src/agent/sdk/runtime/provider-supervisor.js.map +1 -0
  179. package/dist/src/agent/sdk/runtime/spawn-process.d.ts +7 -0
  180. package/dist/src/agent/sdk/runtime/spawn-process.js +16 -0
  181. package/dist/src/agent/sdk/runtime/spawn-process.js.map +1 -0
  182. package/dist/src/agent/sdk/runtime/spawn-supervised-process.d.ts +17 -0
  183. package/dist/src/agent/sdk/runtime/spawn-supervised-process.js +203 -0
  184. package/dist/src/agent/sdk/runtime/spawn-supervised-process.js.map +1 -0
  185. package/dist/src/agent/sdk/runtime/supervisor-protocol.d.ts +29 -0
  186. package/dist/src/agent/sdk/runtime/supervisor-protocol.js +90 -0
  187. package/dist/src/agent/sdk/runtime/supervisor-protocol.js.map +1 -0
  188. package/dist/src/agent/sdk/runtime/timeouts.d.ts +24 -0
  189. package/dist/src/agent/sdk/runtime/timeouts.js +65 -0
  190. package/dist/src/agent/sdk/runtime/timeouts.js.map +1 -0
  191. package/dist/src/agent/sdk/session-manager.d.ts +38 -0
  192. package/dist/src/agent/sdk/session-manager.js +557 -0
  193. package/dist/src/agent/sdk/session-manager.js.map +1 -0
  194. package/dist/src/agent/sdk/transport/json-stream-decoder.d.ts +6 -0
  195. package/dist/src/agent/sdk/transport/json-stream-decoder.js +29 -0
  196. package/dist/src/agent/sdk/transport/json-stream-decoder.js.map +1 -0
  197. package/dist/src/agent/sdk/transport/line-text-decoder.d.ts +6 -0
  198. package/dist/src/agent/sdk/transport/line-text-decoder.js +9 -0
  199. package/dist/src/agent/sdk/transport/line-text-decoder.js.map +1 -0
  200. package/dist/src/agent/sdk/transport/pty-contract.d.ts +12 -0
  201. package/dist/src/agent/sdk/transport/pty-contract.js +2 -0
  202. package/dist/src/agent/sdk/transport/pty-contract.js.map +1 -0
  203. package/dist/src/agent/sdk/types.d.ts +194 -0
  204. package/dist/src/agent/sdk/types.js +2 -0
  205. package/dist/src/agent/sdk/types.js.map +1 -0
  206. package/dist/src/agent/sdk/versioning/provider-version.d.ts +9 -0
  207. package/dist/src/agent/sdk/versioning/provider-version.js +41 -0
  208. package/dist/src/agent/sdk/versioning/provider-version.js.map +1 -0
  209. package/dist/src/cli.d.ts +7 -0
  210. package/dist/src/cli.js +56 -0
  211. package/dist/src/cli.js.map +1 -0
  212. package/dist/src/commands/config/command.d.ts +2 -0
  213. package/dist/src/commands/config/command.js +150 -0
  214. package/dist/src/commands/config/command.js.map +1 -0
  215. package/dist/src/commands/connect/command.d.ts +4 -0
  216. package/dist/src/commands/connect/command.js +19 -0
  217. package/dist/src/commands/connect/command.js.map +1 -0
  218. package/dist/src/commands/connect/workflow.d.ts +92 -0
  219. package/dist/src/commands/connect/workflow.js +381 -0
  220. package/dist/src/commands/connect/workflow.js.map +1 -0
  221. package/dist/src/commands/devcontainer/command.d.ts +2 -0
  222. package/dist/src/commands/devcontainer/command.js +49 -0
  223. package/dist/src/commands/devcontainer/command.js.map +1 -0
  224. package/dist/src/commands/devcontainer/install.d.ts +46 -0
  225. package/dist/src/commands/devcontainer/install.js +107 -0
  226. package/dist/src/commands/devcontainer/install.js.map +1 -0
  227. package/dist/src/commands/init/config/claude-mcp.d.ts +27 -0
  228. package/dist/src/commands/init/config/claude-mcp.js +56 -0
  229. package/dist/src/commands/init/config/claude-mcp.js.map +1 -0
  230. package/dist/src/commands/init/config/codex-mcp.d.ts +12 -0
  231. package/dist/src/commands/init/config/codex-mcp.js +83 -0
  232. package/dist/src/commands/init/config/codex-mcp.js.map +1 -0
  233. package/dist/src/commands/init/config/opencode-mcp.d.ts +16 -0
  234. package/dist/src/commands/init/config/opencode-mcp.js +55 -0
  235. package/dist/src/commands/init/config/opencode-mcp.js.map +1 -0
  236. package/dist/src/commands/init/errors.d.ts +3 -0
  237. package/dist/src/commands/init/errors.js +7 -0
  238. package/dist/src/commands/init/errors.js.map +1 -0
  239. package/dist/src/commands/init/index.d.ts +9 -0
  240. package/dist/src/commands/init/index.js +10 -0
  241. package/dist/src/commands/init/index.js.map +1 -0
  242. package/dist/src/commands/init/io/file-copy.d.ts +18 -0
  243. package/dist/src/commands/init/io/file-copy.js +129 -0
  244. package/dist/src/commands/init/io/file-copy.js.map +1 -0
  245. package/dist/src/commands/init/marketplace.d.ts +8 -0
  246. package/dist/src/commands/init/marketplace.js +25 -0
  247. package/dist/src/commands/init/marketplace.js.map +1 -0
  248. package/dist/src/commands/init/mcp-service.d.ts +2 -0
  249. package/dist/src/commands/init/mcp-service.js +66 -0
  250. package/dist/src/commands/init/mcp-service.js.map +1 -0
  251. package/dist/src/commands/init/parsers.d.ts +4 -0
  252. package/dist/src/commands/init/parsers.js +40 -0
  253. package/dist/src/commands/init/parsers.js.map +1 -0
  254. package/dist/src/commands/init/prompts.d.ts +4 -0
  255. package/dist/src/commands/init/prompts.js +72 -0
  256. package/dist/src/commands/init/prompts.js.map +1 -0
  257. package/dist/src/commands/init/skill-service.d.ts +2 -0
  258. package/dist/src/commands/init/skill-service.js +36 -0
  259. package/dist/src/commands/init/skill-service.js.map +1 -0
  260. package/dist/src/commands/init/summary.d.ts +2 -0
  261. package/dist/src/commands/init/summary.js +22 -0
  262. package/dist/src/commands/init/summary.js.map +1 -0
  263. package/dist/src/commands/init/targets/claude.d.ts +4 -0
  264. package/dist/src/commands/init/targets/claude.js +178 -0
  265. package/dist/src/commands/init/targets/claude.js.map +1 -0
  266. package/dist/src/commands/init/targets/codex.d.ts +4 -0
  267. package/dist/src/commands/init/targets/codex.js +75 -0
  268. package/dist/src/commands/init/targets/codex.js.map +1 -0
  269. package/dist/src/commands/init/targets/driver.d.ts +28 -0
  270. package/dist/src/commands/init/targets/driver.js +2 -0
  271. package/dist/src/commands/init/targets/driver.js.map +1 -0
  272. package/dist/src/commands/init/targets/opencode.d.ts +4 -0
  273. package/dist/src/commands/init/targets/opencode.js +77 -0
  274. package/dist/src/commands/init/targets/opencode.js.map +1 -0
  275. package/dist/src/commands/init/targets/registry.d.ts +4 -0
  276. package/dist/src/commands/init/targets/registry.js +15 -0
  277. package/dist/src/commands/init/targets/registry.js.map +1 -0
  278. package/dist/src/commands/init/types.d.ts +30 -0
  279. package/dist/src/commands/init/types.js +7 -0
  280. package/dist/src/commands/init/types.js.map +1 -0
  281. package/dist/src/commands/init.d.ts +3 -0
  282. package/dist/src/commands/init.js +143 -0
  283. package/dist/src/commands/init.js.map +1 -0
  284. package/dist/src/commands/keys/command.d.ts +2 -0
  285. package/dist/src/commands/keys/command.js +154 -0
  286. package/dist/src/commands/keys/command.js.map +1 -0
  287. package/dist/src/commands/labels/create.d.ts +2 -0
  288. package/dist/src/commands/labels/create.js +31 -0
  289. package/dist/src/commands/labels/create.js.map +1 -0
  290. package/dist/src/commands/labels/delete.d.ts +2 -0
  291. package/dist/src/commands/labels/delete.js +51 -0
  292. package/dist/src/commands/labels/delete.js.map +1 -0
  293. package/dist/src/commands/labels/formatters.d.ts +4 -0
  294. package/dist/src/commands/labels/formatters.js +6 -0
  295. package/dist/src/commands/labels/formatters.js.map +1 -0
  296. package/dist/src/commands/labels/index.d.ts +2 -0
  297. package/dist/src/commands/labels/index.js +13 -0
  298. package/dist/src/commands/labels/index.js.map +1 -0
  299. package/dist/src/commands/labels/list.d.ts +2 -0
  300. package/dist/src/commands/labels/list.js +29 -0
  301. package/dist/src/commands/labels/list.js.map +1 -0
  302. package/dist/src/commands/labels/resolve.d.ts +9 -0
  303. package/dist/src/commands/labels/resolve.js +23 -0
  304. package/dist/src/commands/labels/resolve.js.map +1 -0
  305. package/dist/src/commands/labels/update.d.ts +2 -0
  306. package/dist/src/commands/labels/update.js +37 -0
  307. package/dist/src/commands/labels/update.js.map +1 -0
  308. package/dist/src/commands/lists/constants.d.ts +7 -0
  309. package/dist/src/commands/lists/constants.js +14 -0
  310. package/dist/src/commands/lists/constants.js.map +1 -0
  311. package/dist/src/commands/lists/create.d.ts +2 -0
  312. package/dist/src/commands/lists/create.js +45 -0
  313. package/dist/src/commands/lists/create.js.map +1 -0
  314. package/dist/src/commands/lists/index.d.ts +2 -0
  315. package/dist/src/commands/lists/index.js +10 -0
  316. package/dist/src/commands/lists/index.js.map +1 -0
  317. package/dist/src/commands/lists/list.d.ts +2 -0
  318. package/dist/src/commands/lists/list.js +66 -0
  319. package/dist/src/commands/lists/list.js.map +1 -0
  320. package/dist/src/commands/lists/resolve.d.ts +11 -0
  321. package/dist/src/commands/lists/resolve.js +24 -0
  322. package/dist/src/commands/lists/resolve.js.map +1 -0
  323. package/dist/src/commands/lists/update.d.ts +2 -0
  324. package/dist/src/commands/lists/update.js +61 -0
  325. package/dist/src/commands/lists/update.js.map +1 -0
  326. package/dist/src/commands/login/command.d.ts +8 -0
  327. package/dist/src/commands/login/command.js +20 -0
  328. package/dist/src/commands/login/command.js.map +1 -0
  329. package/dist/src/commands/orgs/index.d.ts +2 -0
  330. package/dist/src/commands/orgs/index.js +6 -0
  331. package/dist/src/commands/orgs/index.js.map +1 -0
  332. package/dist/src/commands/orgs/list.d.ts +2 -0
  333. package/dist/src/commands/orgs/list.js +29 -0
  334. package/dist/src/commands/orgs/list.js.map +1 -0
  335. package/dist/src/commands/paths/command.d.ts +2 -0
  336. package/dist/src/commands/paths/command.js +90 -0
  337. package/dist/src/commands/paths/command.js.map +1 -0
  338. package/dist/src/commands/profiles/index.d.ts +2 -0
  339. package/dist/src/commands/profiles/index.js +6 -0
  340. package/dist/src/commands/profiles/index.js.map +1 -0
  341. package/dist/src/commands/profiles/list.d.ts +2 -0
  342. package/dist/src/commands/profiles/list.js +50 -0
  343. package/dist/src/commands/profiles/list.js.map +1 -0
  344. package/dist/src/commands/project-agents/create.d.ts +2 -0
  345. package/dist/src/commands/project-agents/create.js +53 -0
  346. package/dist/src/commands/project-agents/create.js.map +1 -0
  347. package/dist/src/commands/project-agents/index.d.ts +2 -0
  348. package/dist/src/commands/project-agents/index.js +10 -0
  349. package/dist/src/commands/project-agents/index.js.map +1 -0
  350. package/dist/src/commands/project-agents/list.d.ts +2 -0
  351. package/dist/src/commands/project-agents/list.js +30 -0
  352. package/dist/src/commands/project-agents/list.js.map +1 -0
  353. package/dist/src/commands/project-agents/parsers.d.ts +16 -0
  354. package/dist/src/commands/project-agents/parsers.js +80 -0
  355. package/dist/src/commands/project-agents/parsers.js.map +1 -0
  356. package/dist/src/commands/project-agents/update.d.ts +2 -0
  357. package/dist/src/commands/project-agents/update.js +74 -0
  358. package/dist/src/commands/project-agents/update.js.map +1 -0
  359. package/dist/src/commands/projects/index.d.ts +2 -0
  360. package/dist/src/commands/projects/index.js +6 -0
  361. package/dist/src/commands/projects/index.js.map +1 -0
  362. package/dist/src/commands/projects/list.d.ts +2 -0
  363. package/dist/src/commands/projects/list.js +41 -0
  364. package/dist/src/commands/projects/list.js.map +1 -0
  365. package/dist/src/commands/prompts/create.d.ts +2 -0
  366. package/dist/src/commands/prompts/create.js +48 -0
  367. package/dist/src/commands/prompts/create.js.map +1 -0
  368. package/dist/src/commands/prompts/formatters.d.ts +4 -0
  369. package/dist/src/commands/prompts/formatters.js +7 -0
  370. package/dist/src/commands/prompts/formatters.js.map +1 -0
  371. package/dist/src/commands/prompts/index.d.ts +2 -0
  372. package/dist/src/commands/prompts/index.js +11 -0
  373. package/dist/src/commands/prompts/index.js.map +1 -0
  374. package/dist/src/commands/prompts/list.d.ts +2 -0
  375. package/dist/src/commands/prompts/list.js +34 -0
  376. package/dist/src/commands/prompts/list.js.map +1 -0
  377. package/dist/src/commands/prompts/parsers.d.ts +9 -0
  378. package/dist/src/commands/prompts/parsers.js +12 -0
  379. package/dist/src/commands/prompts/parsers.js.map +1 -0
  380. package/dist/src/commands/prompts/resolve.d.ts +17 -0
  381. package/dist/src/commands/prompts/resolve.js +43 -0
  382. package/dist/src/commands/prompts/resolve.js.map +1 -0
  383. package/dist/src/commands/prompts/update.d.ts +2 -0
  384. package/dist/src/commands/prompts/update.js +58 -0
  385. package/dist/src/commands/prompts/update.js.map +1 -0
  386. package/dist/src/commands/setup/command.d.ts +2 -0
  387. package/dist/src/commands/setup/command.js +15 -0
  388. package/dist/src/commands/setup/command.js.map +1 -0
  389. package/dist/src/commands/setup/prompts.d.ts +66 -0
  390. package/dist/src/commands/setup/prompts.js +199 -0
  391. package/dist/src/commands/setup/prompts.js.map +1 -0
  392. package/dist/src/commands/setup/workflow.d.ts +17 -0
  393. package/dist/src/commands/setup/workflow.js +141 -0
  394. package/dist/src/commands/setup/workflow.js.map +1 -0
  395. package/dist/src/commands/status/command.d.ts +2 -0
  396. package/dist/src/commands/status/command.js +83 -0
  397. package/dist/src/commands/status/command.js.map +1 -0
  398. package/dist/src/commands/task-types/index.d.ts +2 -0
  399. package/dist/src/commands/task-types/index.js +6 -0
  400. package/dist/src/commands/task-types/index.js.map +1 -0
  401. package/dist/src/commands/task-types/list.d.ts +2 -0
  402. package/dist/src/commands/task-types/list.js +32 -0
  403. package/dist/src/commands/task-types/list.js.map +1 -0
  404. package/dist/src/commands/tasks/artifacts/comments/add.d.ts +2 -0
  405. package/dist/src/commands/tasks/artifacts/comments/add.js +32 -0
  406. package/dist/src/commands/tasks/artifacts/comments/add.js.map +1 -0
  407. package/dist/src/commands/tasks/artifacts/comments/formatters.d.ts +7 -0
  408. package/dist/src/commands/tasks/artifacts/comments/formatters.js +32 -0
  409. package/dist/src/commands/tasks/artifacts/comments/formatters.js.map +1 -0
  410. package/dist/src/commands/tasks/artifacts/comments/index.d.ts +2 -0
  411. package/dist/src/commands/tasks/artifacts/comments/index.js +13 -0
  412. package/dist/src/commands/tasks/artifacts/comments/index.js.map +1 -0
  413. package/dist/src/commands/tasks/artifacts/comments/list.d.ts +2 -0
  414. package/dist/src/commands/tasks/artifacts/comments/list.js +24 -0
  415. package/dist/src/commands/tasks/artifacts/comments/list.js.map +1 -0
  416. package/dist/src/commands/tasks/artifacts/comments/parsers.d.ts +6 -0
  417. package/dist/src/commands/tasks/artifacts/comments/parsers.js +8 -0
  418. package/dist/src/commands/tasks/artifacts/comments/parsers.js.map +1 -0
  419. package/dist/src/commands/tasks/artifacts/comments/reply.d.ts +2 -0
  420. package/dist/src/commands/tasks/artifacts/comments/reply.js +23 -0
  421. package/dist/src/commands/tasks/artifacts/comments/reply.js.map +1 -0
  422. package/dist/src/commands/tasks/artifacts/comments/resolve.d.ts +3 -0
  423. package/dist/src/commands/tasks/artifacts/comments/resolve.js +26 -0
  424. package/dist/src/commands/tasks/artifacts/comments/resolve.js.map +1 -0
  425. package/dist/src/commands/tasks/artifacts/create.d.ts +2 -0
  426. package/dist/src/commands/tasks/artifacts/create.js +63 -0
  427. package/dist/src/commands/tasks/artifacts/create.js.map +1 -0
  428. package/dist/src/commands/tasks/artifacts/delete.d.ts +2 -0
  429. package/dist/src/commands/tasks/artifacts/delete.js +27 -0
  430. package/dist/src/commands/tasks/artifacts/delete.js.map +1 -0
  431. package/dist/src/commands/tasks/artifacts/get.d.ts +2 -0
  432. package/dist/src/commands/tasks/artifacts/get.js +54 -0
  433. package/dist/src/commands/tasks/artifacts/get.js.map +1 -0
  434. package/dist/src/commands/tasks/artifacts/index.d.ts +2 -0
  435. package/dist/src/commands/tasks/artifacts/index.js +18 -0
  436. package/dist/src/commands/tasks/artifacts/index.js.map +1 -0
  437. package/dist/src/commands/tasks/artifacts/list.d.ts +2 -0
  438. package/dist/src/commands/tasks/artifacts/list.js +31 -0
  439. package/dist/src/commands/tasks/artifacts/list.js.map +1 -0
  440. package/dist/src/commands/tasks/artifacts/parsers.d.ts +13 -0
  441. package/dist/src/commands/tasks/artifacts/parsers.js +24 -0
  442. package/dist/src/commands/tasks/artifacts/parsers.js.map +1 -0
  443. package/dist/src/commands/tasks/artifacts/replace.d.ts +2 -0
  444. package/dist/src/commands/tasks/artifacts/replace.js +62 -0
  445. package/dist/src/commands/tasks/artifacts/replace.js.map +1 -0
  446. package/dist/src/commands/tasks/artifacts/update.d.ts +2 -0
  447. package/dist/src/commands/tasks/artifacts/update.js +55 -0
  448. package/dist/src/commands/tasks/artifacts/update.js.map +1 -0
  449. package/dist/src/commands/tasks/attach.d.ts +2 -0
  450. package/dist/src/commands/tasks/attach.js +70 -0
  451. package/dist/src/commands/tasks/attach.js.map +1 -0
  452. package/dist/src/commands/tasks/attachments/delete.d.ts +2 -0
  453. package/dist/src/commands/tasks/attachments/delete.js +61 -0
  454. package/dist/src/commands/tasks/attachments/delete.js.map +1 -0
  455. package/dist/src/commands/tasks/attachments/download.d.ts +2 -0
  456. package/dist/src/commands/tasks/attachments/download.js +42 -0
  457. package/dist/src/commands/tasks/attachments/download.js.map +1 -0
  458. package/dist/src/commands/tasks/attachments/formatters.d.ts +5 -0
  459. package/dist/src/commands/tasks/attachments/formatters.js +18 -0
  460. package/dist/src/commands/tasks/attachments/formatters.js.map +1 -0
  461. package/dist/src/commands/tasks/attachments/index.d.ts +2 -0
  462. package/dist/src/commands/tasks/attachments/index.js +11 -0
  463. package/dist/src/commands/tasks/attachments/index.js.map +1 -0
  464. package/dist/src/commands/tasks/attachments/list.d.ts +2 -0
  465. package/dist/src/commands/tasks/attachments/list.js +36 -0
  466. package/dist/src/commands/tasks/attachments/list.js.map +1 -0
  467. package/dist/src/commands/tasks/attachments/resolve.d.ts +6 -0
  468. package/dist/src/commands/tasks/attachments/resolve.js +15 -0
  469. package/dist/src/commands/tasks/attachments/resolve.js.map +1 -0
  470. package/dist/src/commands/tasks/attachments/transfer.d.ts +11 -0
  471. package/dist/src/commands/tasks/attachments/transfer.js +71 -0
  472. package/dist/src/commands/tasks/attachments/transfer.js.map +1 -0
  473. package/dist/src/commands/tasks/comments/add.d.ts +2 -0
  474. package/dist/src/commands/tasks/comments/add.js +44 -0
  475. package/dist/src/commands/tasks/comments/add.js.map +1 -0
  476. package/dist/src/commands/tasks/comments/index.d.ts +2 -0
  477. package/dist/src/commands/tasks/comments/index.js +6 -0
  478. package/dist/src/commands/tasks/comments/index.js.map +1 -0
  479. package/dist/src/commands/tasks/create.d.ts +2 -0
  480. package/dist/src/commands/tasks/create.js +77 -0
  481. package/dist/src/commands/tasks/create.js.map +1 -0
  482. package/dist/src/commands/tasks/delete.d.ts +2 -0
  483. package/dist/src/commands/tasks/delete.js +31 -0
  484. package/dist/src/commands/tasks/delete.js.map +1 -0
  485. package/dist/src/commands/tasks/formatters.d.ts +25 -0
  486. package/dist/src/commands/tasks/formatters.js +40 -0
  487. package/dist/src/commands/tasks/formatters.js.map +1 -0
  488. package/dist/src/commands/tasks/get.d.ts +2 -0
  489. package/dist/src/commands/tasks/get.js +94 -0
  490. package/dist/src/commands/tasks/get.js.map +1 -0
  491. package/dist/src/commands/tasks/hydrate.d.ts +20 -0
  492. package/dist/src/commands/tasks/hydrate.js +47 -0
  493. package/dist/src/commands/tasks/hydrate.js.map +1 -0
  494. package/dist/src/commands/tasks/index.d.ts +2 -0
  495. package/dist/src/commands/tasks/index.js +33 -0
  496. package/dist/src/commands/tasks/index.js.map +1 -0
  497. package/dist/src/commands/tasks/links.d.ts +4 -0
  498. package/dist/src/commands/tasks/links.js +121 -0
  499. package/dist/src/commands/tasks/links.js.map +1 -0
  500. package/dist/src/commands/tasks/list.d.ts +2 -0
  501. package/dist/src/commands/tasks/list.js +47 -0
  502. package/dist/src/commands/tasks/list.js.map +1 -0
  503. package/dist/src/commands/tasks/move-to-list.d.ts +2 -0
  504. package/dist/src/commands/tasks/move-to-list.js +41 -0
  505. package/dist/src/commands/tasks/move-to-list.js.map +1 -0
  506. package/dist/src/commands/tasks/move.d.ts +2 -0
  507. package/dist/src/commands/tasks/move.js +61 -0
  508. package/dist/src/commands/tasks/move.js.map +1 -0
  509. package/dist/src/commands/tasks/parsers.d.ts +22 -0
  510. package/dist/src/commands/tasks/parsers.js +118 -0
  511. package/dist/src/commands/tasks/parsers.js.map +1 -0
  512. package/dist/src/commands/tasks/refs.d.ts +2 -0
  513. package/dist/src/commands/tasks/refs.js +89 -0
  514. package/dist/src/commands/tasks/refs.js.map +1 -0
  515. package/dist/src/commands/tasks/resolve.d.ts +20 -0
  516. package/dist/src/commands/tasks/resolve.js +57 -0
  517. package/dist/src/commands/tasks/resolve.js.map +1 -0
  518. package/dist/src/commands/tasks/search.d.ts +2 -0
  519. package/dist/src/commands/tasks/search.js +110 -0
  520. package/dist/src/commands/tasks/search.js.map +1 -0
  521. package/dist/src/commands/tasks/update.d.ts +2 -0
  522. package/dist/src/commands/tasks/update.js +101 -0
  523. package/dist/src/commands/tasks/update.js.map +1 -0
  524. package/dist/src/commands/test-helpers.d.ts +2 -0
  525. package/dist/src/commands/test-helpers.js +6 -0
  526. package/dist/src/commands/test-helpers.js.map +1 -0
  527. package/dist/src/commands/threads/create.d.ts +2 -0
  528. package/dist/src/commands/threads/create.js +99 -0
  529. package/dist/src/commands/threads/create.js.map +1 -0
  530. package/dist/src/commands/threads/formatters.d.ts +10 -0
  531. package/dist/src/commands/threads/formatters.js +17 -0
  532. package/dist/src/commands/threads/formatters.js.map +1 -0
  533. package/dist/src/commands/threads/get.d.ts +2 -0
  534. package/dist/src/commands/threads/get.js +53 -0
  535. package/dist/src/commands/threads/get.js.map +1 -0
  536. package/dist/src/commands/threads/index.d.ts +2 -0
  537. package/dist/src/commands/threads/index.js +14 -0
  538. package/dist/src/commands/threads/index.js.map +1 -0
  539. package/dist/src/commands/threads/list.d.ts +2 -0
  540. package/dist/src/commands/threads/list.js +69 -0
  541. package/dist/src/commands/threads/list.js.map +1 -0
  542. package/dist/src/commands/threads/messages.d.ts +2 -0
  543. package/dist/src/commands/threads/messages.js +59 -0
  544. package/dist/src/commands/threads/messages.js.map +1 -0
  545. package/dist/src/commands/threads/parsers.d.ts +5 -0
  546. package/dist/src/commands/threads/parsers.js +19 -0
  547. package/dist/src/commands/threads/parsers.js.map +1 -0
  548. package/dist/src/commands/threads/send.d.ts +2 -0
  549. package/dist/src/commands/threads/send.js +49 -0
  550. package/dist/src/commands/threads/send.js.map +1 -0
  551. package/dist/src/commands/threads/spawn-target.d.ts +29 -0
  552. package/dist/src/commands/threads/spawn-target.js +62 -0
  553. package/dist/src/commands/threads/spawn-target.js.map +1 -0
  554. package/dist/src/convex/_generated/ai/ai-files.state.json +6 -0
  555. package/dist/src/convex/_generated/ai/guidelines.md +371 -0
  556. package/dist/src/convex/_generated/api.d.ts +598 -0
  557. package/dist/src/convex/_generated/api.js +23 -0
  558. package/dist/src/convex/_generated/dataModel.d.ts +60 -0
  559. package/dist/src/convex/_generated/server.d.ts +143 -0
  560. package/dist/src/convex/_generated/server.js +93 -0
  561. package/dist/src/lib/argv.d.ts +1 -0
  562. package/dist/src/lib/argv.js +7 -0
  563. package/dist/src/lib/argv.js.map +1 -0
  564. package/dist/src/lib/browser-login.d.ts +43 -0
  565. package/dist/src/lib/browser-login.js +216 -0
  566. package/dist/src/lib/browser-login.js.map +1 -0
  567. package/dist/src/lib/config/convex-client.d.ts +41 -0
  568. package/dist/src/lib/config/convex-client.js +53 -0
  569. package/dist/src/lib/config/convex-client.js.map +1 -0
  570. package/dist/src/lib/config/index.d.ts +7 -0
  571. package/dist/src/lib/config/index.js +13 -0
  572. package/dist/src/lib/config/index.js.map +1 -0
  573. package/dist/src/lib/config/profile.d.ts +40 -0
  574. package/dist/src/lib/config/profile.js +155 -0
  575. package/dist/src/lib/config/profile.js.map +1 -0
  576. package/dist/src/lib/config/provider-keys.d.ts +47 -0
  577. package/dist/src/lib/config/provider-keys.js +97 -0
  578. package/dist/src/lib/config/provider-keys.js.map +1 -0
  579. package/dist/src/lib/config/toml.d.ts +78 -0
  580. package/dist/src/lib/config/toml.js +228 -0
  581. package/dist/src/lib/config/toml.js.map +1 -0
  582. package/dist/src/lib/config/types.d.ts +98 -0
  583. package/dist/src/lib/config/types.js +65 -0
  584. package/dist/src/lib/config/types.js.map +1 -0
  585. package/dist/src/lib/config/validate.d.ts +30 -0
  586. package/dist/src/lib/config/validate.js +66 -0
  587. package/dist/src/lib/config/validate.js.map +1 -0
  588. package/dist/src/lib/connect-events.d.ts +42 -0
  589. package/dist/src/lib/connect-events.js +65 -0
  590. package/dist/src/lib/connect-events.js.map +1 -0
  591. package/dist/src/lib/constants.d.ts +20 -0
  592. package/dist/src/lib/constants.js +27 -0
  593. package/dist/src/lib/constants.js.map +1 -0
  594. package/dist/src/lib/content-type.d.ts +1 -0
  595. package/dist/src/lib/content-type.js +27 -0
  596. package/dist/src/lib/content-type.js.map +1 -0
  597. package/dist/src/lib/convex-error.d.ts +12 -0
  598. package/dist/src/lib/convex-error.js +33 -0
  599. package/dist/src/lib/convex-error.js.map +1 -0
  600. package/dist/src/lib/git/checkpoint.d.ts +74 -0
  601. package/dist/src/lib/git/checkpoint.js +210 -0
  602. package/dist/src/lib/git/checkpoint.js.map +1 -0
  603. package/dist/src/lib/git/exec.d.ts +23 -0
  604. package/dist/src/lib/git/exec.js +46 -0
  605. package/dist/src/lib/git/exec.js.map +1 -0
  606. package/dist/src/lib/git/file-index.d.ts +8 -0
  607. package/dist/src/lib/git/file-index.js +125 -0
  608. package/dist/src/lib/git/file-index.js.map +1 -0
  609. package/dist/src/lib/git/index.d.ts +5 -0
  610. package/dist/src/lib/git/index.js +6 -0
  611. package/dist/src/lib/git/index.js.map +1 -0
  612. package/dist/src/lib/git/repo.d.ts +32 -0
  613. package/dist/src/lib/git/repo.js +95 -0
  614. package/dist/src/lib/git/repo.js.map +1 -0
  615. package/dist/src/lib/git/worktrees.d.ts +49 -0
  616. package/dist/src/lib/git/worktrees.js +97 -0
  617. package/dist/src/lib/git/worktrees.js.map +1 -0
  618. package/dist/src/lib/global-options.d.ts +3 -0
  619. package/dist/src/lib/global-options.js +8 -0
  620. package/dist/src/lib/global-options.js.map +1 -0
  621. package/dist/src/lib/id.d.ts +3 -0
  622. package/dist/src/lib/id.js +14 -0
  623. package/dist/src/lib/id.js.map +1 -0
  624. package/dist/src/lib/one-shot-command.d.ts +7 -0
  625. package/dist/src/lib/one-shot-command.js +30 -0
  626. package/dist/src/lib/one-shot-command.js.map +1 -0
  627. package/dist/src/lib/one-shot-config.d.ts +3 -0
  628. package/dist/src/lib/one-shot-config.js +7 -0
  629. package/dist/src/lib/one-shot-config.js.map +1 -0
  630. package/dist/src/lib/output.d.ts +10 -0
  631. package/dist/src/lib/output.js +27 -0
  632. package/dist/src/lib/output.js.map +1 -0
  633. package/dist/src/lib/pagination.d.ts +16 -0
  634. package/dist/src/lib/pagination.js +45 -0
  635. package/dist/src/lib/pagination.js.map +1 -0
  636. package/dist/src/lib/parsers.d.ts +2 -0
  637. package/dist/src/lib/parsers.js +21 -0
  638. package/dist/src/lib/parsers.js.map +1 -0
  639. package/dist/src/lib/project-resolution.d.ts +41 -0
  640. package/dist/src/lib/project-resolution.js +84 -0
  641. package/dist/src/lib/project-resolution.js.map +1 -0
  642. package/dist/src/lib/pull-requests.d.ts +47 -0
  643. package/dist/src/lib/pull-requests.js +305 -0
  644. package/dist/src/lib/pull-requests.js.map +1 -0
  645. package/dist/src/lib/skill-install-guidance.d.ts +5 -0
  646. package/dist/src/lib/skill-install-guidance.js +41 -0
  647. package/dist/src/lib/skill-install-guidance.js.map +1 -0
  648. package/dist/src/lib/text-input.d.ts +18 -0
  649. package/dist/src/lib/text-input.js +36 -0
  650. package/dist/src/lib/text-input.js.map +1 -0
  651. package/dist/src/lib/thread-attachments.d.ts +21 -0
  652. package/dist/src/lib/thread-attachments.js +104 -0
  653. package/dist/src/lib/thread-attachments.js.map +1 -0
  654. package/dist/src/lib/url.d.ts +13 -0
  655. package/dist/src/lib/url.js +25 -0
  656. package/dist/src/lib/url.js.map +1 -0
  657. package/dist/src/lib/version.d.ts +2 -0
  658. package/dist/src/lib/version.js +33 -0
  659. package/dist/src/lib/version.js.map +1 -0
  660. package/dist/templates/devcontainer/Dockerfile +95 -0
  661. package/dist/templates/devcontainer/README.md +129 -0
  662. package/dist/templates/devcontainer/devcontainer.json +92 -0
  663. package/dist/templates/devcontainer/init-firewall.sh +271 -0
  664. package/package.json +79 -0
@@ -0,0 +1,688 @@
1
+ import { randomUUID } from "node:crypto";
2
+ import { spawn } from "node:child_process";
3
+ import { createInterface } from "node:readline";
4
+ import { getCliVersion } from "../../../lib/version.js";
5
+ import { isRecord } from "../../sdk/adapters/adapter-interface.js";
6
+ import { RunnerExecutionError, } from "../contracts.js";
7
+ import { getDebugLevel } from "../debug.js";
8
+ import { threadIdentityInstruction } from "../agent-instructions.js";
9
+ import { createAppServerRpc } from "./app-server-rpc.js";
10
+ import { discoverCodexCommands, isCodexAppServerCommand } from "./commands.js";
11
+ import { buildCodexSubprocessEnv, codexWritableRootsConfigArgs, killCodexProcess, resolveCodexExecutablePath, } from "./runner.js";
12
+ /**
13
+ * Codex runner over the experimental `codex app-server` JSON-RPC transport
14
+ * (OS-1109; the default transport, opt out via `convoy connect
15
+ * --codex-exec`). Unlike the `codex exec --json` runner, this transport
16
+ * supports interactive approvals (through the interaction bridge), plan mode,
17
+ * live text/reasoning deltas, and context-window token usage.
18
+ */
19
+ /** No app-server notifications for this long mid-run fails the run. */
20
+ const IDLE_TIMEOUT_MS = 600_000;
21
+ const IDLE_CHECK_INTERVAL_MS = 30_000;
22
+ const ABORT_FORCE_KILL_MS = 5_000;
23
+ /**
24
+ * Thread mode → app-server approval policy + sandbox. `agent` (and unset) matches
25
+ * Claude's bypassPermissions; `auto`/`dontAsk` keep the exec transport's "sandboxed,
26
+ * never asks"; `default` asks for every untrusted action; `plan` is read-only with
27
+ * on-request escalation. Isolation (OS-1242) removes `danger-full-access`.
28
+ */
29
+ export function threadPermissionsForMode(mode, isolated = false) {
30
+ switch (mode) {
31
+ case undefined:
32
+ case "agent":
33
+ return isolated
34
+ ? { approvalPolicy: "never", sandbox: "workspace-write" }
35
+ : { approvalPolicy: "never", sandbox: "danger-full-access" };
36
+ case "plan":
37
+ return { approvalPolicy: "on-request", sandbox: "read-only" };
38
+ case "default":
39
+ return { approvalPolicy: "untrusted", sandbox: "workspace-write" };
40
+ case "acceptEdits":
41
+ return { approvalPolicy: "on-request", sandbox: "workspace-write" };
42
+ case "auto":
43
+ case "dontAsk":
44
+ return { approvalPolicy: "never", sandbox: "workspace-write" };
45
+ }
46
+ }
47
+ /**
48
+ * Codex has no built-in plan-approval gate (unlike Claude's ExitPlanMode);
49
+ * the read-only sandbox enforces the "no changes" rule and these developer
50
+ * instructions steer the model toward producing a plan.
51
+ */
52
+ export const CODEX_PLAN_MODE_INSTRUCTIONS = [
53
+ "You are in plan mode. Investigate the codebase and produce a concrete,",
54
+ "actionable implementation plan instead of making changes. Do not modify",
55
+ "files, write to disk, or run state-changing commands. End your reply with",
56
+ "the proposed plan so the user can review it before implementation starts.",
57
+ ].join(" ");
58
+ /**
59
+ * `collaborationMode` for `turn/start`. Codex requires `settings.model`, so plan mode
60
+ * without a known model sends none — the read-only sandbox still applies.
61
+ *
62
+ * A set `collaborationMode` outranks the thread-level `developerInstructions`, so a bound
63
+ * agent prompt must be concatenated into this one field: agent prompt first, plan
64
+ * instructions after (run-mode rules take precedence over the persona).
65
+ */
66
+ export function collaborationModeForRun(options) {
67
+ if (options.cliMode !== "plan") {
68
+ return undefined;
69
+ }
70
+ const model = options.runModel ?? options.threadModel;
71
+ if (!model) {
72
+ return undefined;
73
+ }
74
+ return {
75
+ mode: "plan",
76
+ settings: {
77
+ model,
78
+ reasoning_effort: options.runEffort ?? null,
79
+ developer_instructions: options.agentPrompt
80
+ ? `${options.agentPrompt}\n\n${CODEX_PLAN_MODE_INSTRUCTIONS}`
81
+ : CODEX_PLAN_MODE_INSTRUCTIONS,
82
+ },
83
+ };
84
+ }
85
+ function safeJsonParse(data) {
86
+ try {
87
+ return JSON.parse(data);
88
+ }
89
+ catch {
90
+ return null;
91
+ }
92
+ }
93
+ function getString(value) {
94
+ return typeof value === "string" ? value : undefined;
95
+ }
96
+ /** Web tool-approval response → codex approval decision. */
97
+ export function toCodexApprovalDecision(responseJson) {
98
+ const parsed = safeJsonParse(responseJson);
99
+ const decision = isRecord(parsed) ? getString(parsed.decision) : undefined;
100
+ if (decision === "allow") {
101
+ return "accept";
102
+ }
103
+ if (decision === "allow-always") {
104
+ return "acceptForSession";
105
+ }
106
+ return "decline";
107
+ }
108
+ /** `item/tool/requestUserInput` questions → typed entries (unknown shapes dropped). */
109
+ export function parseCodexUserInputQuestions(value) {
110
+ if (!Array.isArray(value)) {
111
+ return [];
112
+ }
113
+ return value
114
+ .map((entry) => {
115
+ if (!isRecord(entry)) {
116
+ return null;
117
+ }
118
+ const id = getString(entry.id);
119
+ const question = getString(entry.question);
120
+ if (!id || !question) {
121
+ return null;
122
+ }
123
+ const options = Array.isArray(entry.options)
124
+ ? entry.options
125
+ .map((option) => {
126
+ if (!isRecord(option)) {
127
+ return null;
128
+ }
129
+ const label = getString(option.label);
130
+ return label
131
+ ? { label, description: getString(option.description) ?? "" }
132
+ : null;
133
+ })
134
+ .filter((option) => option !== null)
135
+ : [];
136
+ return { id, question, header: getString(entry.header) ?? "", options };
137
+ })
138
+ .filter((entry) => entry !== null);
139
+ }
140
+ /**
141
+ * Web question answers (`{ answers: { [questionText]: value } }`) → codex
142
+ * `ToolRequestUserInputResponse` keyed by question id.
143
+ */
144
+ export function toCodexUserInputAnswers(questions, responseJson) {
145
+ const parsed = safeJsonParse(responseJson);
146
+ const answers = isRecord(parsed) && isRecord(parsed.answers) ? parsed.answers : {};
147
+ const result = {};
148
+ for (const question of questions) {
149
+ const value = getString(answers[question.question]);
150
+ result[question.id] = { answers: value ? [value] : [] };
151
+ }
152
+ return { answers: result };
153
+ }
154
+ /** Chunk-forwarded notification methods (beyond deltas, which gate on streaming). */
155
+ const FORWARDED_NOTIFICATIONS = new Set([
156
+ "turn/started",
157
+ "turn/completed",
158
+ // Full plan snapshot on every `update_plan`; forwarded unconditionally
159
+ // because it is state, not partial text (so it does not gate on streaming).
160
+ "turn/plan/updated",
161
+ "item/started",
162
+ "item/completed",
163
+ "thread/tokenUsage/updated",
164
+ "error",
165
+ ]);
166
+ const DELTA_NOTIFICATIONS = new Set([
167
+ "item/agentMessage/delta",
168
+ "item/reasoning/textDelta",
169
+ "item/reasoning/summaryTextDelta",
170
+ ]);
171
+ function debugLog(kind, payload) {
172
+ if (getDebugLevel() < 1) {
173
+ return;
174
+ }
175
+ console.log(`[CodexAppServer:${kind}] ${payload.slice(0, 400)}`);
176
+ }
177
+ function formatStderrTail(stderrTail) {
178
+ return stderrTail.length > 0 ? ` Stderr: ${stderrTail.join(" | ")}` : "";
179
+ }
180
+ /** Single-consumer queue bridging notification callbacks into the generator. */
181
+ function createChunkQueue() {
182
+ const items = [];
183
+ let ended = false;
184
+ let wake = null;
185
+ return {
186
+ push(chunk) {
187
+ if (ended) {
188
+ return;
189
+ }
190
+ items.push(chunk);
191
+ wake?.();
192
+ },
193
+ end() {
194
+ ended = true;
195
+ wake?.();
196
+ },
197
+ async next() {
198
+ for (;;) {
199
+ const item = items.shift();
200
+ if (item) {
201
+ return item;
202
+ }
203
+ if (ended) {
204
+ return null;
205
+ }
206
+ await new Promise((resolve) => {
207
+ wake = resolve;
208
+ });
209
+ wake = null;
210
+ }
211
+ },
212
+ };
213
+ }
214
+ async function openThread(rpc, options) {
215
+ // Agent prompt delivery (system-append, OS-1138): `developerInstructions` appends the bound
216
+ // agent's prompt snapshot per-thread through the RPC, on both thread/start and thread/resume.
217
+ // Never `baseInstructions` (the replacement path) and never a spawn-level `-c` override — one
218
+ // app-server can serve parallel threads, so process-wide config can't carry a persona.
219
+ const params = {
220
+ cwd: options.workingDirectory,
221
+ approvalPolicy: options.permissions.approvalPolicy,
222
+ sandbox: options.permissions.sandbox,
223
+ ...(options.runModel ? { model: options.runModel } : {}),
224
+ ...(options.developerInstructions
225
+ ? { developerInstructions: options.developerInstructions }
226
+ : {}),
227
+ };
228
+ const opened = options.continuationId
229
+ ? await rpc.request("thread/resume", { threadId: options.continuationId, ...params })
230
+ : await rpc.request("thread/start", params);
231
+ const thread = isRecord(opened) && isRecord(opened.thread) ? opened.thread : null;
232
+ const threadId = getString(thread?.id);
233
+ if (!threadId) {
234
+ throw new Error("codex app-server did not return a thread id");
235
+ }
236
+ return {
237
+ threadId,
238
+ threadModel: isRecord(opened) ? getString(opened.model) : undefined,
239
+ };
240
+ }
241
+ /**
242
+ * Dispatch a runtime command to its dedicated app-server RPC (OS-1582).
243
+ * `thread/compact/start` takes only `threadId` and returns an empty result;
244
+ * the compaction itself proceeds as a normal turn. `/compact` takes no
245
+ * arguments, so any are ignored rather than rejected — the runtime is the
246
+ * authority on its own command surface.
247
+ */
248
+ async function startCodexRuntimeCommand(rpc, threadId, runtimeCommand) {
249
+ // Guarded against the advertised inventory (commands.ts) so discovery and
250
+ // execution cannot drift: anything the composer can offer must map here.
251
+ // Fail loudly on a miss rather than running it as prose — the OS-1582
252
+ // failure mode, where the model answered as though it had run the command.
253
+ if (!isCodexAppServerCommand(runtimeCommand.command)) {
254
+ throw new RunnerExecutionError(`Codex cannot execute the "/${runtimeCommand.command}" command.`, { continuationId: threadId });
255
+ }
256
+ switch (runtimeCommand.command) {
257
+ case "compact":
258
+ await rpc.request("thread/compact/start", { threadId });
259
+ return;
260
+ }
261
+ }
262
+ export function createCodexAppServerRunner(factoryOptions) {
263
+ const partialStreaming = factoryOptions?.partialStreaming ?? false;
264
+ const sandbox = factoryOptions?.sandbox;
265
+ let aborted = false;
266
+ let forceKillTimer = null;
267
+ let activeChild = null;
268
+ let requestInterrupt = null;
269
+ // Mid-run steering (OS-1111): injects a user turn into the active turn via
270
+ // the `turn/steer` RPC. Set per execute, null between runs.
271
+ let activeSteer = null;
272
+ // The processor may abandon the generator mid-yield after an unrelated
273
+ // error, so abort() must also run the per-run cleanup that the generator's
274
+ // own finally would otherwise handle.
275
+ let cleanupActiveRun = null;
276
+ const abort = () => {
277
+ aborted = true;
278
+ requestInterrupt?.();
279
+ cleanupActiveRun?.();
280
+ const child = activeChild;
281
+ if (!child || child.exitCode !== null || child.signalCode !== null) {
282
+ return;
283
+ }
284
+ forceKillTimer = setTimeout(() => {
285
+ killCodexProcess(child, "SIGKILL");
286
+ }, ABORT_FORCE_KILL_MS);
287
+ forceKillTimer.unref?.();
288
+ };
289
+ return {
290
+ async *execute(workingDirectory, prompt, options) {
291
+ aborted = false;
292
+ const executable = await resolveCodexExecutablePath();
293
+ debugLog("spawn", `${executable.command} app-server`);
294
+ // Writable roots are profile-scoped (isolation, OS-1242), so a
295
+ // process-level `-c` override is correct even with parallel threads —
296
+ // unlike per-thread personas, which must go through the RPC.
297
+ const child = spawn(executable.command, [...(sandbox ? codexWritableRootsConfigArgs(sandbox) : []), "app-server"], {
298
+ cwd: workingDirectory,
299
+ env: buildCodexSubprocessEnv(options.threadId),
300
+ stdio: ["pipe", "pipe", "pipe"],
301
+ // Own process group so aborts can kill the wrapper and the native
302
+ // binary together (see killCodexProcess).
303
+ detached: process.platform !== "win32",
304
+ });
305
+ activeChild = child;
306
+ const stderrTail = [];
307
+ if (child.stderr) {
308
+ createInterface({ input: child.stderr }).on("line", (line) => {
309
+ const trimmed = line.trim();
310
+ if (!trimmed) {
311
+ return;
312
+ }
313
+ debugLog("stderr", trimmed);
314
+ stderrTail.push(trimmed);
315
+ if (stderrTail.length > 12) {
316
+ stderrTail.shift();
317
+ }
318
+ });
319
+ }
320
+ let spawnError = null;
321
+ let exited = false;
322
+ const queue = createChunkQueue();
323
+ const bridgeAbort = new AbortController();
324
+ const bridge = options.interactionBridge;
325
+ const pendingInteractionIds = new Set();
326
+ let threadId = options.continuationId;
327
+ let turnId;
328
+ let turnCompleted = false;
329
+ let failureMessage = null;
330
+ let lastActivityAt = Date.now();
331
+ let idleTimedOut = false;
332
+ // fileChange approval params carry no diff; enrich from item/started.
333
+ const fileChangesByItemId = new Map();
334
+ const idleWatchdog = setInterval(() => {
335
+ // A run parked on a web approval/question emits nothing while the
336
+ // user thinks; that is not idleness (OS-1463, matching OS-1458 for
337
+ // Claude). Re-arm instead of killing the very run the user is
338
+ // deciding about.
339
+ if (pendingInteractionIds.size > 0) {
340
+ lastActivityAt = Date.now();
341
+ return;
342
+ }
343
+ if (Date.now() - lastActivityAt > IDLE_TIMEOUT_MS) {
344
+ idleTimedOut = true;
345
+ killCodexProcess(child, "SIGKILL");
346
+ }
347
+ }, IDLE_CHECK_INTERVAL_MS);
348
+ idleWatchdog.unref?.();
349
+ const requestApproval = async (kind, payload) => {
350
+ if (!bridge) {
351
+ // No interactive-approval support on this connection; a parked
352
+ // approval would hang the run forever.
353
+ debugLog("approval", "auto-declining (no bridge)");
354
+ return { decision: "decline" };
355
+ }
356
+ const requestId = randomUUID();
357
+ pendingInteractionIds.add(requestId);
358
+ try {
359
+ const responseJson = await bridge.request({ requestId, kind, payloadJson: JSON.stringify(payload) }, bridgeAbort.signal);
360
+ return { decision: toCodexApprovalDecision(responseJson) };
361
+ }
362
+ catch {
363
+ bridge.cancel(requestId, { abandoned: true, reason: "run ended" });
364
+ // `cancel` also interrupts the turn — correct when the run is over.
365
+ return { decision: "cancel" };
366
+ }
367
+ finally {
368
+ pendingInteractionIds.delete(requestId);
369
+ }
370
+ };
371
+ const requestUserInput = async (params) => {
372
+ const questions = parseCodexUserInputQuestions(params.questions);
373
+ if (!bridge || questions.length === 0) {
374
+ debugLog("question", "auto-answering empty (no bridge or questions)");
375
+ return { answers: {} };
376
+ }
377
+ const requestId = randomUUID();
378
+ pendingInteractionIds.add(requestId);
379
+ try {
380
+ const responseJson = await bridge.request({
381
+ requestId,
382
+ kind: "question",
383
+ payloadJson: JSON.stringify({
384
+ toolName: "AskUserQuestion",
385
+ questions: questions.map((question) => ({
386
+ question: question.question,
387
+ header: question.header,
388
+ options: question.options,
389
+ multiSelect: false,
390
+ })),
391
+ }),
392
+ }, bridgeAbort.signal);
393
+ return toCodexUserInputAnswers(questions, responseJson);
394
+ }
395
+ catch {
396
+ bridge.cancel(requestId, { abandoned: true, reason: "run ended" });
397
+ return { answers: {} };
398
+ }
399
+ finally {
400
+ pendingInteractionIds.delete(requestId);
401
+ }
402
+ };
403
+ const rpc = createAppServerRpc({ stdin: child.stdin, stdout: child.stdout }, {
404
+ onNotification: (method, params) => {
405
+ lastActivityAt = Date.now();
406
+ debugLog(method, JSON.stringify(params));
407
+ if (DELTA_NOTIFICATIONS.has(method)) {
408
+ if (partialStreaming) {
409
+ queue.push({ type: method, data: JSON.stringify(params) });
410
+ }
411
+ return;
412
+ }
413
+ if (!FORWARDED_NOTIFICATIONS.has(method)) {
414
+ return;
415
+ }
416
+ if (method === "turn/started" && isRecord(params.turn)) {
417
+ turnId = getString(params.turn.id) ?? turnId;
418
+ }
419
+ if (method === "item/started" && isRecord(params.item)) {
420
+ const item = params.item;
421
+ if (item.type === "fileChange" && typeof item.id === "string") {
422
+ fileChangesByItemId.set(item.id, item.changes);
423
+ }
424
+ }
425
+ if (method === "error" && isRecord(params.error)) {
426
+ if (params.willRetry !== true) {
427
+ failureMessage =
428
+ getString(params.error.message) ?? "Codex reported an error.";
429
+ }
430
+ }
431
+ queue.push({ type: method, data: JSON.stringify(params) });
432
+ if (method === "turn/completed") {
433
+ if (isRecord(params.turn) && params.turn.status === "failed") {
434
+ const error = isRecord(params.turn.error) ? params.turn.error : null;
435
+ failureMessage =
436
+ getString(error?.message) ?? "Codex could not complete the turn.";
437
+ }
438
+ turnCompleted = true;
439
+ queue.end();
440
+ }
441
+ else if (method === "error" && failureMessage !== null) {
442
+ // Fatal (non-retried) error: a turn/completed may never follow.
443
+ queue.end();
444
+ }
445
+ },
446
+ onRequest: async (method, params) => {
447
+ lastActivityAt = Date.now();
448
+ debugLog(`request:${method}`, JSON.stringify(params));
449
+ if (method === "item/commandExecution/requestApproval") {
450
+ return requestApproval("tool-approval", {
451
+ toolName: "Shell",
452
+ inputJson: JSON.stringify({
453
+ command: params.command ?? "",
454
+ cwd: params.cwd ?? null,
455
+ }),
456
+ title: "Codex wants to run a command",
457
+ ...(getString(params.reason) ? { description: params.reason } : {}),
458
+ hasSuggestions: true,
459
+ });
460
+ }
461
+ if (method === "item/fileChange/requestApproval") {
462
+ const itemId = getString(params.itemId);
463
+ const changes = itemId ? (fileChangesByItemId.get(itemId) ?? []) : [];
464
+ return requestApproval("tool-approval", {
465
+ toolName: "Apply changes",
466
+ inputJson: JSON.stringify({
467
+ changes,
468
+ ...(getString(params.reason) ? { reason: params.reason } : {}),
469
+ ...(getString(params.grantRoot) ? { grantRoot: params.grantRoot } : {}),
470
+ }),
471
+ title: "Codex wants to edit files",
472
+ hasSuggestions: true,
473
+ });
474
+ }
475
+ if (method === "item/tool/requestUserInput") {
476
+ return requestUserInput(params);
477
+ }
478
+ throw new Error(`Unsupported codex app-server request "${method}"`);
479
+ },
480
+ });
481
+ const exitPromise = new Promise((resolve) => {
482
+ child.once("error", (error) => {
483
+ spawnError = error;
484
+ exited = true;
485
+ rpc.close("codex app-server failed to start");
486
+ queue.end();
487
+ resolve({ code: null, signal: null });
488
+ });
489
+ child.once("close", (code, signal) => {
490
+ exited = true;
491
+ rpc.close("codex app-server exited");
492
+ queue.end();
493
+ resolve({ code, signal });
494
+ });
495
+ });
496
+ // EPIPE guard: codex may exit while a message is being written.
497
+ child.stdin?.on("error", () => { });
498
+ requestInterrupt = () => {
499
+ bridgeAbort.abort();
500
+ if (threadId && turnId && !exited) {
501
+ rpc.request("turn/interrupt", { threadId, turnId }).catch(() => { });
502
+ }
503
+ };
504
+ // `expectedTurnId` makes codex reject the steer when the turn already
505
+ // ended, so a false return here reliably means "left queued for the
506
+ // next batch" — the push-first/consume-after contract holds.
507
+ const steerThisRun = async (injection) => {
508
+ if (aborted || exited || turnCompleted || !threadId || !turnId) {
509
+ return false;
510
+ }
511
+ try {
512
+ await rpc.request("turn/steer", {
513
+ threadId,
514
+ input: [{ type: "text", text: injection.prompt }],
515
+ expectedTurnId: turnId,
516
+ });
517
+ return true;
518
+ }
519
+ catch {
520
+ return false;
521
+ }
522
+ };
523
+ activeSteer = steerThisRun;
524
+ const cleanupRun = () => {
525
+ clearInterval(idleWatchdog);
526
+ bridgeAbort.abort();
527
+ queue.end();
528
+ if (cleanupActiveRun === cleanupRun) {
529
+ cleanupActiveRun = null;
530
+ }
531
+ };
532
+ cleanupActiveRun = cleanupRun;
533
+ try {
534
+ await rpc.request("initialize", {
535
+ clientInfo: {
536
+ name: "opensana-cli",
537
+ title: "OpenSana",
538
+ version: getCliVersion(),
539
+ },
540
+ capabilities: { experimentalApi: true },
541
+ });
542
+ rpc.notify("initialized");
543
+ const permissions = threadPermissionsForMode(options.cliMode, sandbox !== undefined);
544
+ // Thread identity (OS-1223) rides developerInstructions alongside the
545
+ // agent prompt — re-passed on every thread/start and thread/resume.
546
+ const developerInstructions = [
547
+ options.agentPrompt,
548
+ threadIdentityInstruction(options.threadId),
549
+ ]
550
+ .filter((part) => typeof part === "string" && part.length > 0)
551
+ .join("\n\n");
552
+ const opened = await openThread(rpc, {
553
+ workingDirectory,
554
+ permissions,
555
+ runModel: options.resolvedCliModel,
556
+ continuationId: options.continuationId,
557
+ developerInstructions,
558
+ });
559
+ threadId = opened.threadId;
560
+ // Synthetic thread marker: continuation extraction reads this chunk
561
+ // (the live `thread/started` notification is not forwarded).
562
+ yield {
563
+ type: "thread/started",
564
+ data: JSON.stringify({ thread: { id: threadId } }),
565
+ };
566
+ // Advertise the commands this transport can execute so the web
567
+ // composer can autocomplete them (OS-1582). Captured server-side
568
+ // into cliRuntimeFacts, same path as Claude's system/init.
569
+ yield {
570
+ type: "opensana.commands",
571
+ data: JSON.stringify({
572
+ commands: discoverCodexCommands({ appServer: true }),
573
+ }),
574
+ };
575
+ const collaborationMode = collaborationModeForRun({
576
+ cliMode: options.cliMode,
577
+ runModel: options.resolvedCliModel,
578
+ threadModel: opened.threadModel,
579
+ runEffort: options.resolvedCliEffort,
580
+ // Plan-mode collaborationMode outranks thread-level
581
+ // developerInstructions, so the composed string (agent prompt +
582
+ // thread identity) must ride here too or the identity is dropped.
583
+ agentPrompt: developerInstructions,
584
+ });
585
+ if (options.cliMode === "plan" && !collaborationMode) {
586
+ // Read-only sandbox still applies, but the plan developer
587
+ // instructions are dropped — surface it for diagnosis.
588
+ debugLog("plan", "no model resolved; starting plan turn without collaborationMode");
589
+ }
590
+ // Runtime commands (OS-1582) run through their own RPC; codex does not interpret slash
591
+ // text in prompts. Compaction still runs as an ordinary turn server-side, so the event
592
+ // loop needs no special casing — but the RPC returns an empty result, so `turnId` is
593
+ // only learned from `turn/started`.
594
+ const runtimeCommand = options.runtimeCommand;
595
+ if (runtimeCommand) {
596
+ await startCodexRuntimeCommand(rpc, threadId, runtimeCommand);
597
+ }
598
+ else {
599
+ const turn = await rpc.request("turn/start", {
600
+ threadId,
601
+ input: [{ type: "text", text: prompt }],
602
+ ...(options.resolvedCliModel ? { model: options.resolvedCliModel } : {}),
603
+ ...(options.resolvedCliEffort ? { effort: options.resolvedCliEffort } : {}),
604
+ ...(collaborationMode ? { collaborationMode } : {}),
605
+ });
606
+ if (isRecord(turn) && isRecord(turn.turn)) {
607
+ turnId = getString(turn.turn.id) ?? turnId;
608
+ }
609
+ }
610
+ for (;;) {
611
+ const chunk = await queue.next();
612
+ if (chunk === null) {
613
+ break;
614
+ }
615
+ yield chunk;
616
+ }
617
+ if (aborted) {
618
+ throw new RunnerExecutionError("Codex run aborted", {
619
+ continuationId: threadId,
620
+ });
621
+ }
622
+ if (idleTimedOut) {
623
+ throw new RunnerExecutionError(`Codex produced no output for ${Math.round(IDLE_TIMEOUT_MS / 60_000)} minutes and was terminated.`, { continuationId: threadId });
624
+ }
625
+ if (failureMessage !== null) {
626
+ throw new RunnerExecutionError(failureMessage, {
627
+ continuationId: threadId,
628
+ });
629
+ }
630
+ if (!turnCompleted) {
631
+ const exit = await exitPromise;
632
+ const exitDetail = spawnError
633
+ ? spawnError.message
634
+ : exit.code !== null
635
+ ? `exit code ${exit.code}`
636
+ : `signal ${exit.signal ?? "unknown"}`;
637
+ throw new RunnerExecutionError(`Codex app-server ended before the turn completed (${exitDetail}).${formatStderrTail(stderrTail)}`, { continuationId: threadId });
638
+ }
639
+ return { continuationId: threadId };
640
+ }
641
+ catch (error) {
642
+ if (error instanceof RunnerExecutionError) {
643
+ if (error.continuationId === undefined && threadId) {
644
+ error.continuationId = threadId;
645
+ }
646
+ throw error;
647
+ }
648
+ if (aborted) {
649
+ throw new RunnerExecutionError("Codex run aborted", {
650
+ continuationId: threadId,
651
+ });
652
+ }
653
+ throw new RunnerExecutionError(error instanceof Error ? error.message : String(error), { continuationId: threadId });
654
+ }
655
+ finally {
656
+ cleanupRun();
657
+ rpc.close("run finished");
658
+ for (const requestId of pendingInteractionIds) {
659
+ bridge?.cancel(requestId, { abandoned: true, reason: "run ended" });
660
+ }
661
+ pendingInteractionIds.clear();
662
+ if (forceKillTimer) {
663
+ clearTimeout(forceKillTimer);
664
+ forceKillTimer = null;
665
+ }
666
+ if (child.exitCode === null && child.signalCode === null) {
667
+ killCodexProcess(child, "SIGKILL");
668
+ }
669
+ if (activeChild === child) {
670
+ activeChild = null;
671
+ requestInterrupt = null;
672
+ }
673
+ if (activeSteer === steerThisRun) {
674
+ activeSteer = null;
675
+ }
676
+ }
677
+ },
678
+ steer(injection) {
679
+ const steerFn = activeSteer;
680
+ return steerFn ? steerFn(injection) : Promise.resolve(false);
681
+ },
682
+ abort,
683
+ async shutdown() {
684
+ abort();
685
+ },
686
+ };
687
+ }
688
+ //# sourceMappingURL=app-server-runner.js.map