@yjjeong/omg 0.1.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 (702) hide show
  1. package/CHANGELOG.md +85 -0
  2. package/LICENSE +21 -0
  3. package/README.md +153 -0
  4. package/dist/cli/args.d.ts +39 -0
  5. package/dist/cli/args.d.ts.map +1 -0
  6. package/dist/cli/args.js +129 -0
  7. package/dist/cli/args.js.map +1 -0
  8. package/dist/cli/autoCommit.d.ts +20 -0
  9. package/dist/cli/autoCommit.d.ts.map +1 -0
  10. package/dist/cli/autoCommit.js +121 -0
  11. package/dist/cli/autoCommit.js.map +1 -0
  12. package/dist/cli/bgTasks.d.ts +57 -0
  13. package/dist/cli/bgTasks.d.ts.map +1 -0
  14. package/dist/cli/bgTasks.js +193 -0
  15. package/dist/cli/bgTasks.js.map +1 -0
  16. package/dist/cli/compactor.d.ts +48 -0
  17. package/dist/cli/compactor.d.ts.map +1 -0
  18. package/dist/cli/compactor.js +73 -0
  19. package/dist/cli/compactor.js.map +1 -0
  20. package/dist/cli/doctor.d.ts +77 -0
  21. package/dist/cli/doctor.d.ts.map +1 -0
  22. package/dist/cli/doctor.js +279 -0
  23. package/dist/cli/doctor.js.map +1 -0
  24. package/dist/cli/gitStatus.d.ts +7 -0
  25. package/dist/cli/gitStatus.d.ts.map +1 -0
  26. package/dist/cli/gitStatus.js +70 -0
  27. package/dist/cli/gitStatus.js.map +1 -0
  28. package/dist/cli/handoff.d.ts +36 -0
  29. package/dist/cli/handoff.d.ts.map +1 -0
  30. package/dist/cli/handoff.js +60 -0
  31. package/dist/cli/handoff.js.map +1 -0
  32. package/dist/cli/interactive/brokers.d.ts +31 -0
  33. package/dist/cli/interactive/brokers.d.ts.map +1 -0
  34. package/dist/cli/interactive/brokers.js +259 -0
  35. package/dist/cli/interactive/brokers.js.map +1 -0
  36. package/dist/cli/interactive/index.d.ts +8 -0
  37. package/dist/cli/interactive/index.d.ts.map +1 -0
  38. package/dist/cli/interactive/index.js +731 -0
  39. package/dist/cli/interactive/index.js.map +1 -0
  40. package/dist/cli/interactive/proxyQuestions.d.ts +15 -0
  41. package/dist/cli/interactive/proxyQuestions.d.ts.map +1 -0
  42. package/dist/cli/interactive/proxyQuestions.js +48 -0
  43. package/dist/cli/interactive/proxyQuestions.js.map +1 -0
  44. package/dist/cli/interactive/tabManager.d.ts +32 -0
  45. package/dist/cli/interactive/tabManager.d.ts.map +1 -0
  46. package/dist/cli/interactive/tabManager.js +244 -0
  47. package/dist/cli/interactive/tabManager.js.map +1 -0
  48. package/dist/cli/interactive/teamHint.d.ts +2 -0
  49. package/dist/cli/interactive/teamHint.d.ts.map +1 -0
  50. package/dist/cli/interactive/teamHint.js +14 -0
  51. package/dist/cli/interactive/teamHint.js.map +1 -0
  52. package/dist/cli/login.d.ts +13 -0
  53. package/dist/cli/login.d.ts.map +1 -0
  54. package/dist/cli/login.js +53 -0
  55. package/dist/cli/login.js.map +1 -0
  56. package/dist/cli/modes/demo.d.ts +12 -0
  57. package/dist/cli/modes/demo.d.ts.map +1 -0
  58. package/dist/cli/modes/demo.js +48 -0
  59. package/dist/cli/modes/demo.js.map +1 -0
  60. package/dist/cli/modes/doctor.d.ts +28 -0
  61. package/dist/cli/modes/doctor.d.ts.map +1 -0
  62. package/dist/cli/modes/doctor.js +79 -0
  63. package/dist/cli/modes/doctor.js.map +1 -0
  64. package/dist/cli/modes/login.d.ts +5 -0
  65. package/dist/cli/modes/login.d.ts.map +1 -0
  66. package/dist/cli/modes/login.js +40 -0
  67. package/dist/cli/modes/login.js.map +1 -0
  68. package/dist/cli/modes/mcpServe.d.ts +9 -0
  69. package/dist/cli/modes/mcpServe.d.ts.map +1 -0
  70. package/dist/cli/modes/mcpServe.js +112 -0
  71. package/dist/cli/modes/mcpServe.js.map +1 -0
  72. package/dist/cli/modes/orchestrator.d.ts +14 -0
  73. package/dist/cli/modes/orchestrator.d.ts.map +1 -0
  74. package/dist/cli/modes/orchestrator.js +64 -0
  75. package/dist/cli/modes/orchestrator.js.map +1 -0
  76. package/dist/cli/modes/team.d.ts +14 -0
  77. package/dist/cli/modes/team.d.ts.map +1 -0
  78. package/dist/cli/modes/team.js +87 -0
  79. package/dist/cli/modes/team.js.map +1 -0
  80. package/dist/cli/registry.d.ts +3 -0
  81. package/dist/cli/registry.d.ts.map +1 -0
  82. package/dist/cli/registry.js +15 -0
  83. package/dist/cli/registry.js.map +1 -0
  84. package/dist/cli/slash/core.d.ts +3 -0
  85. package/dist/cli/slash/core.d.ts.map +1 -0
  86. package/dist/cli/slash/core.js +509 -0
  87. package/dist/cli/slash/core.js.map +1 -0
  88. package/dist/cli/slash/index.d.ts +3 -0
  89. package/dist/cli/slash/index.d.ts.map +1 -0
  90. package/dist/cli/slash/index.js +28 -0
  91. package/dist/cli/slash/index.js.map +1 -0
  92. package/dist/cli/slash/modes.d.ts +3 -0
  93. package/dist/cli/slash/modes.d.ts.map +1 -0
  94. package/dist/cli/slash/modes.js +530 -0
  95. package/dist/cli/slash/modes.js.map +1 -0
  96. package/dist/cli/slash/session.d.ts +3 -0
  97. package/dist/cli/slash/session.d.ts.map +1 -0
  98. package/dist/cli/slash/session.js +376 -0
  99. package/dist/cli/slash/session.js.map +1 -0
  100. package/dist/cli/slash/shared.d.ts +43 -0
  101. package/dist/cli/slash/shared.d.ts.map +1 -0
  102. package/dist/cli/slash/shared.js +6 -0
  103. package/dist/cli/slash/shared.js.map +1 -0
  104. package/dist/cli/slash/tabs.d.ts +3 -0
  105. package/dist/cli/slash/tabs.d.ts.map +1 -0
  106. package/dist/cli/slash/tabs.js +497 -0
  107. package/dist/cli/slash/tabs.js.map +1 -0
  108. package/dist/cli/slash/team.d.ts +3 -0
  109. package/dist/cli/slash/team.d.ts.map +1 -0
  110. package/dist/cli/slash/team.js +85 -0
  111. package/dist/cli/slash/team.js.map +1 -0
  112. package/dist/cli/slash.d.ts +3 -0
  113. package/dist/cli/slash.d.ts.map +1 -0
  114. package/dist/cli/slash.js +8 -0
  115. package/dist/cli/slash.js.map +1 -0
  116. package/dist/cli/teamPipeline.d.ts +42 -0
  117. package/dist/cli/teamPipeline.d.ts.map +1 -0
  118. package/dist/cli/teamPipeline.js +406 -0
  119. package/dist/cli/teamPipeline.js.map +1 -0
  120. package/dist/cli/touchedFiles.d.ts +14 -0
  121. package/dist/cli/touchedFiles.d.ts.map +1 -0
  122. package/dist/cli/touchedFiles.js +66 -0
  123. package/dist/cli/touchedFiles.js.map +1 -0
  124. package/dist/cli/turn.d.ts +47 -0
  125. package/dist/cli/turn.d.ts.map +1 -0
  126. package/dist/cli/turn.js +626 -0
  127. package/dist/cli/turn.js.map +1 -0
  128. package/dist/cli/types.d.ts +47 -0
  129. package/dist/cli/types.d.ts.map +1 -0
  130. package/dist/cli/types.js +5 -0
  131. package/dist/cli/types.js.map +1 -0
  132. package/dist/cli/uiSession.d.ts +10 -0
  133. package/dist/cli/uiSession.d.ts.map +1 -0
  134. package/dist/cli/uiSession.js +66 -0
  135. package/dist/cli/uiSession.js.map +1 -0
  136. package/dist/cli.d.ts +3 -0
  137. package/dist/cli.d.ts.map +1 -0
  138. package/dist/cli.js +128 -0
  139. package/dist/cli.js.map +1 -0
  140. package/dist/core/adapter.d.ts +47 -0
  141. package/dist/core/adapter.d.ts.map +1 -0
  142. package/dist/core/adapter.js +48 -0
  143. package/dist/core/adapter.js.map +1 -0
  144. package/dist/core/adapters/anthropic.d.ts +35 -0
  145. package/dist/core/adapters/anthropic.d.ts.map +1 -0
  146. package/dist/core/adapters/anthropic.js +203 -0
  147. package/dist/core/adapters/anthropic.js.map +1 -0
  148. package/dist/core/adapters/claudeCli.d.ts +126 -0
  149. package/dist/core/adapters/claudeCli.d.ts.map +1 -0
  150. package/dist/core/adapters/claudeCli.js +584 -0
  151. package/dist/core/adapters/claudeCli.js.map +1 -0
  152. package/dist/core/adapters/cliAdapterBase.d.ts +48 -0
  153. package/dist/core/adapters/cliAdapterBase.d.ts.map +1 -0
  154. package/dist/core/adapters/cliAdapterBase.js +105 -0
  155. package/dist/core/adapters/cliAdapterBase.js.map +1 -0
  156. package/dist/core/adapters/cliStderr.d.ts +35 -0
  157. package/dist/core/adapters/cliStderr.d.ts.map +1 -0
  158. package/dist/core/adapters/cliStderr.js +87 -0
  159. package/dist/core/adapters/cliStderr.js.map +1 -0
  160. package/dist/core/adapters/codexCli.d.ts +113 -0
  161. package/dist/core/adapters/codexCli.d.ts.map +1 -0
  162. package/dist/core/adapters/codexCli.js +424 -0
  163. package/dist/core/adapters/codexCli.js.map +1 -0
  164. package/dist/core/adapters/gemini.d.ts +17 -0
  165. package/dist/core/adapters/gemini.d.ts.map +1 -0
  166. package/dist/core/adapters/gemini.js +133 -0
  167. package/dist/core/adapters/gemini.js.map +1 -0
  168. package/dist/core/adapters/geminiCli.d.ts +91 -0
  169. package/dist/core/adapters/geminiCli.d.ts.map +1 -0
  170. package/dist/core/adapters/geminiCli.js +276 -0
  171. package/dist/core/adapters/geminiCli.js.map +1 -0
  172. package/dist/core/adapters/nudges.d.ts +21 -0
  173. package/dist/core/adapters/nudges.d.ts.map +1 -0
  174. package/dist/core/adapters/nudges.js +75 -0
  175. package/dist/core/adapters/nudges.js.map +1 -0
  176. package/dist/core/adapters/openai.d.ts +17 -0
  177. package/dist/core/adapters/openai.d.ts.map +1 -0
  178. package/dist/core/adapters/openai.js +138 -0
  179. package/dist/core/adapters/openai.js.map +1 -0
  180. package/dist/core/adapters/parseFailures.d.ts +10 -0
  181. package/dist/core/adapters/parseFailures.d.ts.map +1 -0
  182. package/dist/core/adapters/parseFailures.js +35 -0
  183. package/dist/core/adapters/parseFailures.js.map +1 -0
  184. package/dist/core/adapters/utils.d.ts +11 -0
  185. package/dist/core/adapters/utils.d.ts.map +1 -0
  186. package/dist/core/adapters/utils.js +33 -0
  187. package/dist/core/adapters/utils.js.map +1 -0
  188. package/dist/core/askBroker.d.ts +11 -0
  189. package/dist/core/askBroker.d.ts.map +1 -0
  190. package/dist/core/askBroker.js +78 -0
  191. package/dist/core/askBroker.js.map +1 -0
  192. package/dist/core/atomicWrite.d.ts +5 -0
  193. package/dist/core/atomicWrite.d.ts.map +1 -0
  194. package/dist/core/atomicWrite.js +18 -0
  195. package/dist/core/atomicWrite.js.map +1 -0
  196. package/dist/core/brokers/askBroker.d.ts +11 -0
  197. package/dist/core/brokers/askBroker.d.ts.map +1 -0
  198. package/dist/core/brokers/askBroker.js +78 -0
  199. package/dist/core/brokers/askBroker.js.map +1 -0
  200. package/dist/core/brokers/permissionBroker.d.ts +7 -0
  201. package/dist/core/brokers/permissionBroker.d.ts.map +1 -0
  202. package/dist/core/brokers/permissionBroker.js +63 -0
  203. package/dist/core/brokers/permissionBroker.js.map +1 -0
  204. package/dist/core/brokers/socketBroker.d.ts +35 -0
  205. package/dist/core/brokers/socketBroker.d.ts.map +1 -0
  206. package/dist/core/brokers/socketBroker.js +74 -0
  207. package/dist/core/brokers/socketBroker.js.map +1 -0
  208. package/dist/core/clipboard.d.ts +4 -0
  209. package/dist/core/clipboard.d.ts.map +1 -0
  210. package/dist/core/clipboard.js +46 -0
  211. package/dist/core/clipboard.js.map +1 -0
  212. package/dist/core/compactor.d.ts +32 -0
  213. package/dist/core/compactor.d.ts.map +1 -0
  214. package/dist/core/compactor.js +91 -0
  215. package/dist/core/compactor.js.map +1 -0
  216. package/dist/core/consensusEngine.d.ts +21 -0
  217. package/dist/core/consensusEngine.d.ts.map +1 -0
  218. package/dist/core/consensusEngine.js +116 -0
  219. package/dist/core/consensusEngine.js.map +1 -0
  220. package/dist/core/context/contextCompressor.d.ts +10 -0
  221. package/dist/core/context/contextCompressor.d.ts.map +1 -0
  222. package/dist/core/context/contextCompressor.js +54 -0
  223. package/dist/core/context/contextCompressor.js.map +1 -0
  224. package/dist/core/context/contextWindows.d.ts +25 -0
  225. package/dist/core/context/contextWindows.d.ts.map +1 -0
  226. package/dist/core/context/contextWindows.js +101 -0
  227. package/dist/core/context/contextWindows.js.map +1 -0
  228. package/dist/core/context/summarizer.d.ts +65 -0
  229. package/dist/core/context/summarizer.d.ts.map +1 -0
  230. package/dist/core/context/summarizer.js +184 -0
  231. package/dist/core/context/summarizer.js.map +1 -0
  232. package/dist/core/context/usageCache.d.ts +19 -0
  233. package/dist/core/context/usageCache.d.ts.map +1 -0
  234. package/dist/core/context/usageCache.js +157 -0
  235. package/dist/core/context/usageCache.js.map +1 -0
  236. package/dist/core/context/usageWindow.d.ts +19 -0
  237. package/dist/core/context/usageWindow.d.ts.map +1 -0
  238. package/dist/core/context/usageWindow.js +73 -0
  239. package/dist/core/context/usageWindow.js.map +1 -0
  240. package/dist/core/contextCompressor.d.ts +10 -0
  241. package/dist/core/contextCompressor.d.ts.map +1 -0
  242. package/dist/core/contextCompressor.js +54 -0
  243. package/dist/core/contextCompressor.js.map +1 -0
  244. package/dist/core/contextWindows.d.ts +5 -0
  245. package/dist/core/contextWindows.d.ts.map +1 -0
  246. package/dist/core/contextWindows.js +60 -0
  247. package/dist/core/contextWindows.js.map +1 -0
  248. package/dist/core/continuum/digest.d.ts +35 -0
  249. package/dist/core/continuum/digest.d.ts.map +1 -0
  250. package/dist/core/continuum/digest.js +91 -0
  251. package/dist/core/continuum/digest.js.map +1 -0
  252. package/dist/core/continuum/index.d.ts +6 -0
  253. package/dist/core/continuum/index.d.ts.map +1 -0
  254. package/dist/core/continuum/index.js +7 -0
  255. package/dist/core/continuum/index.js.map +1 -0
  256. package/dist/core/continuum/inject.d.ts +9 -0
  257. package/dist/core/continuum/inject.d.ts.map +1 -0
  258. package/dist/core/continuum/inject.js +78 -0
  259. package/dist/core/continuum/inject.js.map +1 -0
  260. package/dist/core/continuum/projectId.d.ts +10 -0
  261. package/dist/core/continuum/projectId.d.ts.map +1 -0
  262. package/dist/core/continuum/projectId.js +60 -0
  263. package/dist/core/continuum/projectId.js.map +1 -0
  264. package/dist/core/continuum/store.d.ts +24 -0
  265. package/dist/core/continuum/store.d.ts.map +1 -0
  266. package/dist/core/continuum/store.js +144 -0
  267. package/dist/core/continuum/store.js.map +1 -0
  268. package/dist/core/continuum/types.d.ts +87 -0
  269. package/dist/core/continuum/types.d.ts.map +1 -0
  270. package/dist/core/continuum/types.js +9 -0
  271. package/dist/core/continuum/types.js.map +1 -0
  272. package/dist/core/dag.d.ts +21 -0
  273. package/dist/core/dag.d.ts.map +1 -0
  274. package/dist/core/dag.js +71 -0
  275. package/dist/core/dag.js.map +1 -0
  276. package/dist/core/director.d.ts +11 -0
  277. package/dist/core/director.d.ts.map +1 -0
  278. package/dist/core/director.js +37 -0
  279. package/dist/core/director.js.map +1 -0
  280. package/dist/core/hookedToolBroker.d.ts +25 -0
  281. package/dist/core/hookedToolBroker.d.ts.map +1 -0
  282. package/dist/core/hookedToolBroker.js +95 -0
  283. package/dist/core/hookedToolBroker.js.map +1 -0
  284. package/dist/core/langHint.d.ts +9 -0
  285. package/dist/core/langHint.d.ts.map +1 -0
  286. package/dist/core/langHint.js +33 -0
  287. package/dist/core/langHint.js.map +1 -0
  288. package/dist/core/mcp/mcpClient.d.ts +42 -0
  289. package/dist/core/mcp/mcpClient.d.ts.map +1 -0
  290. package/dist/core/mcp/mcpClient.js +134 -0
  291. package/dist/core/mcp/mcpClient.js.map +1 -0
  292. package/dist/core/mcp/mcpConfig.d.ts +58 -0
  293. package/dist/core/mcp/mcpConfig.d.ts.map +1 -0
  294. package/dist/core/mcp/mcpConfig.js +148 -0
  295. package/dist/core/mcp/mcpConfig.js.map +1 -0
  296. package/dist/core/mcp/mcpManager.d.ts +31 -0
  297. package/dist/core/mcp/mcpManager.d.ts.map +1 -0
  298. package/dist/core/mcp/mcpManager.js +83 -0
  299. package/dist/core/mcp/mcpManager.js.map +1 -0
  300. package/dist/core/mcpClient.d.ts +42 -0
  301. package/dist/core/mcpClient.d.ts.map +1 -0
  302. package/dist/core/mcpClient.js +134 -0
  303. package/dist/core/mcpClient.js.map +1 -0
  304. package/dist/core/mcpConfig.d.ts +24 -0
  305. package/dist/core/mcpConfig.d.ts.map +1 -0
  306. package/dist/core/mcpConfig.js +74 -0
  307. package/dist/core/mcpConfig.js.map +1 -0
  308. package/dist/core/mcpManager.d.ts +31 -0
  309. package/dist/core/mcpManager.d.ts.map +1 -0
  310. package/dist/core/mcpManager.js +83 -0
  311. package/dist/core/mcpManager.js.map +1 -0
  312. package/dist/core/memory.d.ts +22 -0
  313. package/dist/core/memory.d.ts.map +1 -0
  314. package/dist/core/memory.js +102 -0
  315. package/dist/core/memory.js.map +1 -0
  316. package/dist/core/omgToolManifest.d.ts +34 -0
  317. package/dist/core/omgToolManifest.d.ts.map +1 -0
  318. package/dist/core/omgToolManifest.js +59 -0
  319. package/dist/core/omgToolManifest.js.map +1 -0
  320. package/dist/core/orchestration/consensusEngine.d.ts +21 -0
  321. package/dist/core/orchestration/consensusEngine.d.ts.map +1 -0
  322. package/dist/core/orchestration/consensusEngine.js +116 -0
  323. package/dist/core/orchestration/consensusEngine.js.map +1 -0
  324. package/dist/core/orchestration/dag.d.ts +21 -0
  325. package/dist/core/orchestration/dag.d.ts.map +1 -0
  326. package/dist/core/orchestration/dag.js +71 -0
  327. package/dist/core/orchestration/dag.js.map +1 -0
  328. package/dist/core/orchestration/director.d.ts +11 -0
  329. package/dist/core/orchestration/director.d.ts.map +1 -0
  330. package/dist/core/orchestration/director.js +37 -0
  331. package/dist/core/orchestration/director.js.map +1 -0
  332. package/dist/core/orchestration/orchestrator.d.ts +32 -0
  333. package/dist/core/orchestration/orchestrator.d.ts.map +1 -0
  334. package/dist/core/orchestration/orchestrator.js +214 -0
  335. package/dist/core/orchestration/orchestrator.js.map +1 -0
  336. package/dist/core/orchestration/roleRouter.d.ts +28 -0
  337. package/dist/core/orchestration/roleRouter.d.ts.map +1 -0
  338. package/dist/core/orchestration/roleRouter.js +64 -0
  339. package/dist/core/orchestration/roleRouter.js.map +1 -0
  340. package/dist/core/orchestration/teamRunner.d.ts +69 -0
  341. package/dist/core/orchestration/teamRunner.d.ts.map +1 -0
  342. package/dist/core/orchestration/teamRunner.js +477 -0
  343. package/dist/core/orchestration/teamRunner.js.map +1 -0
  344. package/dist/core/orchestration/types.d.ts +115 -0
  345. package/dist/core/orchestration/types.d.ts.map +1 -0
  346. package/dist/core/orchestration/types.js +71 -0
  347. package/dist/core/orchestration/types.js.map +1 -0
  348. package/dist/core/orchestrator.d.ts +32 -0
  349. package/dist/core/orchestrator.d.ts.map +1 -0
  350. package/dist/core/orchestrator.js +214 -0
  351. package/dist/core/orchestrator.js.map +1 -0
  352. package/dist/core/permissionBroker.d.ts +7 -0
  353. package/dist/core/permissionBroker.d.ts.map +1 -0
  354. package/dist/core/permissionBroker.js +63 -0
  355. package/dist/core/permissionBroker.js.map +1 -0
  356. package/dist/core/planConfig.d.ts +15 -0
  357. package/dist/core/planConfig.d.ts.map +1 -0
  358. package/dist/core/planConfig.js +98 -0
  359. package/dist/core/planConfig.js.map +1 -0
  360. package/dist/core/presetPersistence.d.ts +4 -0
  361. package/dist/core/presetPersistence.d.ts.map +1 -0
  362. package/dist/core/presetPersistence.js +64 -0
  363. package/dist/core/presetPersistence.js.map +1 -0
  364. package/dist/core/roleRouter.d.ts +26 -0
  365. package/dist/core/roleRouter.d.ts.map +1 -0
  366. package/dist/core/roleRouter.js +62 -0
  367. package/dist/core/roleRouter.js.map +1 -0
  368. package/dist/core/sessionList.d.ts +26 -0
  369. package/dist/core/sessionList.d.ts.map +1 -0
  370. package/dist/core/sessionList.js +278 -0
  371. package/dist/core/sessionList.js.map +1 -0
  372. package/dist/core/slugify.d.ts +2 -0
  373. package/dist/core/slugify.d.ts.map +1 -0
  374. package/dist/core/slugify.js +17 -0
  375. package/dist/core/slugify.js.map +1 -0
  376. package/dist/core/socketBroker.d.ts +19 -0
  377. package/dist/core/socketBroker.d.ts.map +1 -0
  378. package/dist/core/socketBroker.js +48 -0
  379. package/dist/core/socketBroker.js.map +1 -0
  380. package/dist/core/state/agentsMdScaffold.d.ts +15 -0
  381. package/dist/core/state/agentsMdScaffold.d.ts.map +1 -0
  382. package/dist/core/state/agentsMdScaffold.js +118 -0
  383. package/dist/core/state/agentsMdScaffold.js.map +1 -0
  384. package/dist/core/state/atomicWrite.d.ts +5 -0
  385. package/dist/core/state/atomicWrite.d.ts.map +1 -0
  386. package/dist/core/state/atomicWrite.js +18 -0
  387. package/dist/core/state/atomicWrite.js.map +1 -0
  388. package/dist/core/state/handoff.d.ts +20 -0
  389. package/dist/core/state/handoff.d.ts.map +1 -0
  390. package/dist/core/state/handoff.js +71 -0
  391. package/dist/core/state/handoff.js.map +1 -0
  392. package/dist/core/state/mcpCatalog.d.ts +11 -0
  393. package/dist/core/state/mcpCatalog.d.ts.map +1 -0
  394. package/dist/core/state/mcpCatalog.js +51 -0
  395. package/dist/core/state/mcpCatalog.js.map +1 -0
  396. package/dist/core/state/mcpRecommendations.d.ts +7 -0
  397. package/dist/core/state/mcpRecommendations.d.ts.map +1 -0
  398. package/dist/core/state/mcpRecommendations.js +57 -0
  399. package/dist/core/state/mcpRecommendations.js.map +1 -0
  400. package/dist/core/state/memory.d.ts +22 -0
  401. package/dist/core/state/memory.d.ts.map +1 -0
  402. package/dist/core/state/memory.js +102 -0
  403. package/dist/core/state/memory.js.map +1 -0
  404. package/dist/core/state/planConfig.d.ts +15 -0
  405. package/dist/core/state/planConfig.d.ts.map +1 -0
  406. package/dist/core/state/planConfig.js +98 -0
  407. package/dist/core/state/planConfig.js.map +1 -0
  408. package/dist/core/state/presetPersistence.d.ts +4 -0
  409. package/dist/core/state/presetPersistence.d.ts.map +1 -0
  410. package/dist/core/state/presetPersistence.js +67 -0
  411. package/dist/core/state/presetPersistence.js.map +1 -0
  412. package/dist/core/state/sessionList.d.ts +26 -0
  413. package/dist/core/state/sessionList.d.ts.map +1 -0
  414. package/dist/core/state/sessionList.js +278 -0
  415. package/dist/core/state/sessionList.js.map +1 -0
  416. package/dist/core/state/stackDetect.d.ts +8 -0
  417. package/dist/core/state/stackDetect.d.ts.map +1 -0
  418. package/dist/core/state/stackDetect.js +40 -0
  419. package/dist/core/state/stackDetect.js.map +1 -0
  420. package/dist/core/state/tabPersistence.d.ts +29 -0
  421. package/dist/core/state/tabPersistence.d.ts.map +1 -0
  422. package/dist/core/state/tabPersistence.js +65 -0
  423. package/dist/core/state/tabPersistence.js.map +1 -0
  424. package/dist/core/tabPersistence.d.ts +29 -0
  425. package/dist/core/tabPersistence.d.ts.map +1 -0
  426. package/dist/core/tabPersistence.js +65 -0
  427. package/dist/core/tabPersistence.js.map +1 -0
  428. package/dist/core/teamRunner.d.ts +42 -0
  429. package/dist/core/teamRunner.d.ts.map +1 -0
  430. package/dist/core/teamRunner.js +248 -0
  431. package/dist/core/teamRunner.js.map +1 -0
  432. package/dist/core/toolGate.d.ts +23 -0
  433. package/dist/core/toolGate.d.ts.map +1 -0
  434. package/dist/core/toolGate.js +51 -0
  435. package/dist/core/toolGate.js.map +1 -0
  436. package/dist/core/toolInterceptor.d.ts +7 -0
  437. package/dist/core/toolInterceptor.d.ts.map +1 -0
  438. package/dist/core/toolInterceptor.js +108 -0
  439. package/dist/core/toolInterceptor.js.map +1 -0
  440. package/dist/core/tools/hookedToolBroker.d.ts +25 -0
  441. package/dist/core/tools/hookedToolBroker.d.ts.map +1 -0
  442. package/dist/core/tools/hookedToolBroker.js +95 -0
  443. package/dist/core/tools/hookedToolBroker.js.map +1 -0
  444. package/dist/core/tools/omgToolManifest.d.ts +42 -0
  445. package/dist/core/tools/omgToolManifest.d.ts.map +1 -0
  446. package/dist/core/tools/omgToolManifest.js +66 -0
  447. package/dist/core/tools/omgToolManifest.js.map +1 -0
  448. package/dist/core/tools/toolGate.d.ts +23 -0
  449. package/dist/core/tools/toolGate.d.ts.map +1 -0
  450. package/dist/core/tools/toolGate.js +51 -0
  451. package/dist/core/tools/toolGate.js.map +1 -0
  452. package/dist/core/tools/toolInterceptor.d.ts +7 -0
  453. package/dist/core/tools/toolInterceptor.d.ts.map +1 -0
  454. package/dist/core/tools/toolInterceptor.js +108 -0
  455. package/dist/core/tools/toolInterceptor.js.map +1 -0
  456. package/dist/core/tools/tools.d.ts +34 -0
  457. package/dist/core/tools/tools.d.ts.map +1 -0
  458. package/dist/core/tools/tools.js +328 -0
  459. package/dist/core/tools/tools.js.map +1 -0
  460. package/dist/core/tools.d.ts +34 -0
  461. package/dist/core/tools.d.ts.map +1 -0
  462. package/dist/core/tools.js +300 -0
  463. package/dist/core/tools.js.map +1 -0
  464. package/dist/core/types.d.ts +107 -0
  465. package/dist/core/types.d.ts.map +1 -0
  466. package/dist/core/types.js +55 -0
  467. package/dist/core/types.js.map +1 -0
  468. package/dist/core/usageCache.d.ts +19 -0
  469. package/dist/core/usageCache.d.ts.map +1 -0
  470. package/dist/core/usageCache.js +157 -0
  471. package/dist/core/usageCache.js.map +1 -0
  472. package/dist/core/usageWindow.d.ts +19 -0
  473. package/dist/core/usageWindow.d.ts.map +1 -0
  474. package/dist/core/usageWindow.js +73 -0
  475. package/dist/core/usageWindow.js.map +1 -0
  476. package/dist/core/util/bgProtocol.d.ts +5 -0
  477. package/dist/core/util/bgProtocol.d.ts.map +1 -0
  478. package/dist/core/util/bgProtocol.js +20 -0
  479. package/dist/core/util/bgProtocol.js.map +1 -0
  480. package/dist/core/util/clipboard.d.ts +4 -0
  481. package/dist/core/util/clipboard.d.ts.map +1 -0
  482. package/dist/core/util/clipboard.js +46 -0
  483. package/dist/core/util/clipboard.js.map +1 -0
  484. package/dist/core/util/clipboardImage.d.ts +3 -0
  485. package/dist/core/util/clipboardImage.d.ts.map +1 -0
  486. package/dist/core/util/clipboardImage.js +58 -0
  487. package/dist/core/util/clipboardImage.js.map +1 -0
  488. package/dist/core/util/langHint.d.ts +9 -0
  489. package/dist/core/util/langHint.d.ts.map +1 -0
  490. package/dist/core/util/langHint.js +33 -0
  491. package/dist/core/util/langHint.js.map +1 -0
  492. package/dist/core/util/slugify.d.ts +2 -0
  493. package/dist/core/util/slugify.d.ts.map +1 -0
  494. package/dist/core/util/slugify.js +28 -0
  495. package/dist/core/util/slugify.js.map +1 -0
  496. package/dist/hooks/hookedToolProxy.mjs +118 -0
  497. package/dist/index.d.ts +2 -0
  498. package/dist/index.d.ts.map +1 -0
  499. package/dist/index.js +8 -0
  500. package/dist/index.js.map +1 -0
  501. package/dist/ipc/dispatcher.d.ts +21 -0
  502. package/dist/ipc/dispatcher.d.ts.map +1 -0
  503. package/dist/ipc/dispatcher.js +160 -0
  504. package/dist/ipc/dispatcher.js.map +1 -0
  505. package/dist/ipc/events.d.ts +33 -0
  506. package/dist/ipc/events.d.ts.map +1 -0
  507. package/dist/ipc/events.js +42 -0
  508. package/dist/ipc/events.js.map +1 -0
  509. package/dist/ipc/rpc.d.ts +31 -0
  510. package/dist/ipc/rpc.d.ts.map +1 -0
  511. package/dist/ipc/rpc.js +110 -0
  512. package/dist/ipc/rpc.js.map +1 -0
  513. package/dist/ipc/stdio.d.ts +11 -0
  514. package/dist/ipc/stdio.d.ts.map +1 -0
  515. package/dist/ipc/stdio.js +52 -0
  516. package/dist/ipc/stdio.js.map +1 -0
  517. package/dist/mcp/askClient.d.ts +9 -0
  518. package/dist/mcp/askClient.d.ts.map +1 -0
  519. package/dist/mcp/askClient.js +70 -0
  520. package/dist/mcp/askClient.js.map +1 -0
  521. package/dist/mcp/constants.d.ts +6 -0
  522. package/dist/mcp/constants.d.ts.map +1 -0
  523. package/dist/mcp/constants.js +8 -0
  524. package/dist/mcp/constants.js.map +1 -0
  525. package/dist/mcp/permissionClient.d.ts +5 -0
  526. package/dist/mcp/permissionClient.d.ts.map +1 -0
  527. package/dist/mcp/permissionClient.js +71 -0
  528. package/dist/mcp/permissionClient.js.map +1 -0
  529. package/dist/mcp/schemas.d.ts +9 -0
  530. package/dist/mcp/schemas.d.ts.map +1 -0
  531. package/dist/mcp/schemas.js +121 -0
  532. package/dist/mcp/schemas.js.map +1 -0
  533. package/dist/mcp/server.d.ts +41 -0
  534. package/dist/mcp/server.d.ts.map +1 -0
  535. package/dist/mcp/server.js +204 -0
  536. package/dist/mcp/server.js.map +1 -0
  537. package/dist/policy/loader.d.ts +27 -0
  538. package/dist/policy/loader.d.ts.map +1 -0
  539. package/dist/policy/loader.js +89 -0
  540. package/dist/policy/loader.js.map +1 -0
  541. package/dist/policy/team-claude-only.yaml +46 -0
  542. package/dist/policy/team-codex-only.yaml +46 -0
  543. package/dist/policy/team-codex.yaml +54 -0
  544. package/dist/policy/team.yaml +104 -0
  545. package/dist/toolhook/hookedToolProxy.mjs +118 -0
  546. package/dist/ui/components/App.d.ts +14 -0
  547. package/dist/ui/components/App.d.ts.map +1 -0
  548. package/dist/ui/components/App.js +803 -0
  549. package/dist/ui/components/App.js.map +1 -0
  550. package/dist/ui/components/AskPicker.d.ts +8 -0
  551. package/dist/ui/components/AskPicker.d.ts.map +1 -0
  552. package/dist/ui/components/AskPicker.js +202 -0
  553. package/dist/ui/components/AskPicker.js.map +1 -0
  554. package/dist/ui/components/CommandInput.d.ts +63 -0
  555. package/dist/ui/components/CommandInput.d.ts.map +1 -0
  556. package/dist/ui/components/CommandInput.js +994 -0
  557. package/dist/ui/components/CommandInput.js.map +1 -0
  558. package/dist/ui/components/DiffView.d.ts +19 -0
  559. package/dist/ui/components/DiffView.d.ts.map +1 -0
  560. package/dist/ui/components/DiffView.js +93 -0
  561. package/dist/ui/components/DiffView.js.map +1 -0
  562. package/dist/ui/components/Dock.d.ts +49 -0
  563. package/dist/ui/components/Dock.d.ts.map +1 -0
  564. package/dist/ui/components/Dock.js +52 -0
  565. package/dist/ui/components/Dock.js.map +1 -0
  566. package/dist/ui/components/EventLog.d.ts +42 -0
  567. package/dist/ui/components/EventLog.d.ts.map +1 -0
  568. package/dist/ui/components/EventLog.js +450 -0
  569. package/dist/ui/components/EventLog.js.map +1 -0
  570. package/dist/ui/components/FileSuggest.d.ts +8 -0
  571. package/dist/ui/components/FileSuggest.d.ts.map +1 -0
  572. package/dist/ui/components/FileSuggest.js +19 -0
  573. package/dist/ui/components/FileSuggest.js.map +1 -0
  574. package/dist/ui/components/HRule.d.ts +27 -0
  575. package/dist/ui/components/HRule.d.ts.map +1 -0
  576. package/dist/ui/components/HRule.js +75 -0
  577. package/dist/ui/components/HRule.js.map +1 -0
  578. package/dist/ui/components/HintBar.d.ts +2 -0
  579. package/dist/ui/components/HintBar.d.ts.map +1 -0
  580. package/dist/ui/components/HintBar.js +19 -0
  581. package/dist/ui/components/HintBar.js.map +1 -0
  582. package/dist/ui/components/MarkdownText.d.ts +13 -0
  583. package/dist/ui/components/MarkdownText.d.ts.map +1 -0
  584. package/dist/ui/components/MarkdownText.js +255 -0
  585. package/dist/ui/components/MarkdownText.js.map +1 -0
  586. package/dist/ui/components/PermissionPrompt.d.ts +8 -0
  587. package/dist/ui/components/PermissionPrompt.d.ts.map +1 -0
  588. package/dist/ui/components/PermissionPrompt.js +37 -0
  589. package/dist/ui/components/PermissionPrompt.js.map +1 -0
  590. package/dist/ui/components/SessionPicker.d.ts +16 -0
  591. package/dist/ui/components/SessionPicker.d.ts.map +1 -0
  592. package/dist/ui/components/SessionPicker.js +116 -0
  593. package/dist/ui/components/SessionPicker.js.map +1 -0
  594. package/dist/ui/components/SlashPalette.d.ts +8 -0
  595. package/dist/ui/components/SlashPalette.d.ts.map +1 -0
  596. package/dist/ui/components/SlashPalette.js +41 -0
  597. package/dist/ui/components/SlashPalette.js.map +1 -0
  598. package/dist/ui/components/Spinner.d.ts +37 -0
  599. package/dist/ui/components/Spinner.d.ts.map +1 -0
  600. package/dist/ui/components/Spinner.js +139 -0
  601. package/dist/ui/components/Spinner.js.map +1 -0
  602. package/dist/ui/components/StatusBar.d.ts +92 -0
  603. package/dist/ui/components/StatusBar.d.ts.map +1 -0
  604. package/dist/ui/components/StatusBar.js +268 -0
  605. package/dist/ui/components/StatusBar.js.map +1 -0
  606. package/dist/ui/components/TabChip.d.ts +11 -0
  607. package/dist/ui/components/TabChip.d.ts.map +1 -0
  608. package/dist/ui/components/TabChip.js +23 -0
  609. package/dist/ui/components/TabChip.js.map +1 -0
  610. package/dist/ui/components/TeamIndicator.d.ts +6 -0
  611. package/dist/ui/components/TeamIndicator.d.ts.map +1 -0
  612. package/dist/ui/components/TeamIndicator.js +17 -0
  613. package/dist/ui/components/TeamIndicator.js.map +1 -0
  614. package/dist/ui/components/TeamStatusPanel.d.ts +14 -0
  615. package/dist/ui/components/TeamStatusPanel.d.ts.map +1 -0
  616. package/dist/ui/components/TeamStatusPanel.js +65 -0
  617. package/dist/ui/components/TeamStatusPanel.js.map +1 -0
  618. package/dist/ui/components/ThinkingBlock.d.ts +10 -0
  619. package/dist/ui/components/ThinkingBlock.d.ts.map +1 -0
  620. package/dist/ui/components/ThinkingBlock.js +21 -0
  621. package/dist/ui/components/ThinkingBlock.js.map +1 -0
  622. package/dist/ui/components/TodoIndicator.d.ts +11 -0
  623. package/dist/ui/components/TodoIndicator.d.ts.map +1 -0
  624. package/dist/ui/components/TodoIndicator.js +37 -0
  625. package/dist/ui/components/TodoIndicator.js.map +1 -0
  626. package/dist/ui/components/ToolCallCard.d.ts +16 -0
  627. package/dist/ui/components/ToolCallCard.d.ts.map +1 -0
  628. package/dist/ui/components/ToolCallCard.js +195 -0
  629. package/dist/ui/components/ToolCallCard.js.map +1 -0
  630. package/dist/ui/components/Welcome.d.ts +8 -0
  631. package/dist/ui/components/Welcome.d.ts.map +1 -0
  632. package/dist/ui/components/Welcome.js +53 -0
  633. package/dist/ui/components/Welcome.js.map +1 -0
  634. package/dist/ui/cursorState.d.ts +29 -0
  635. package/dist/ui/cursorState.d.ts.map +1 -0
  636. package/dist/ui/cursorState.js +49 -0
  637. package/dist/ui/cursorState.js.map +1 -0
  638. package/dist/ui/diff.d.ts +34 -0
  639. package/dist/ui/diff.d.ts.map +1 -0
  640. package/dist/ui/diff.js +184 -0
  641. package/dist/ui/diff.js.map +1 -0
  642. package/dist/ui/diffLang.d.ts +2 -0
  643. package/dist/ui/diffLang.d.ts.map +1 -0
  644. package/dist/ui/diffLang.js +36 -0
  645. package/dist/ui/diffLang.js.map +1 -0
  646. package/dist/ui/emoji.d.ts +4 -0
  647. package/dist/ui/emoji.d.ts.map +1 -0
  648. package/dist/ui/emoji.js +73 -0
  649. package/dist/ui/emoji.js.map +1 -0
  650. package/dist/ui/fileMentions.d.ts +41 -0
  651. package/dist/ui/fileMentions.d.ts.map +1 -0
  652. package/dist/ui/fileMentions.js +135 -0
  653. package/dist/ui/fileMentions.js.map +1 -0
  654. package/dist/ui/hooks/useLineEditor.d.ts +44 -0
  655. package/dist/ui/hooks/useLineEditor.d.ts.map +1 -0
  656. package/dist/ui/hooks/useLineEditor.js +142 -0
  657. package/dist/ui/hooks/useLineEditor.js.map +1 -0
  658. package/dist/ui/inputHistory.d.ts +8 -0
  659. package/dist/ui/inputHistory.d.ts.map +1 -0
  660. package/dist/ui/inputHistory.js +56 -0
  661. package/dist/ui/inputHistory.js.map +1 -0
  662. package/dist/ui/jsonrpc.d.ts +17 -0
  663. package/dist/ui/jsonrpc.d.ts.map +1 -0
  664. package/dist/ui/jsonrpc.js +41 -0
  665. package/dist/ui/jsonrpc.js.map +1 -0
  666. package/dist/ui/launcher.d.ts +20 -0
  667. package/dist/ui/launcher.d.ts.map +1 -0
  668. package/dist/ui/launcher.js +185 -0
  669. package/dist/ui/launcher.js.map +1 -0
  670. package/dist/ui/markdown.d.ts +104 -0
  671. package/dist/ui/markdown.d.ts.map +1 -0
  672. package/dist/ui/markdown.js +449 -0
  673. package/dist/ui/markdown.js.map +1 -0
  674. package/dist/ui/mouse.d.ts +22 -0
  675. package/dist/ui/mouse.d.ts.map +1 -0
  676. package/dist/ui/mouse.js +31 -0
  677. package/dist/ui/mouse.js.map +1 -0
  678. package/dist/ui/outbound.d.ts +20 -0
  679. package/dist/ui/outbound.d.ts.map +1 -0
  680. package/dist/ui/outbound.js +49 -0
  681. package/dist/ui/outbound.js.map +1 -0
  682. package/dist/ui/screenMode.d.ts +25 -0
  683. package/dist/ui/screenMode.d.ts.map +1 -0
  684. package/dist/ui/screenMode.js +43 -0
  685. package/dist/ui/screenMode.js.map +1 -0
  686. package/dist/ui/slashCatalog.d.ts +18 -0
  687. package/dist/ui/slashCatalog.d.ts.map +1 -0
  688. package/dist/ui/slashCatalog.js +243 -0
  689. package/dist/ui/slashCatalog.js.map +1 -0
  690. package/dist/ui/syntax.d.ts +11 -0
  691. package/dist/ui/syntax.d.ts.map +1 -0
  692. package/dist/ui/syntax.js +78 -0
  693. package/dist/ui/syntax.js.map +1 -0
  694. package/dist/ui/theme.d.ts +165 -0
  695. package/dist/ui/theme.d.ts.map +1 -0
  696. package/dist/ui/theme.js +394 -0
  697. package/dist/ui/theme.js.map +1 -0
  698. package/dist/ui/types.d.ts +203 -0
  699. package/dist/ui/types.d.ts.map +1 -0
  700. package/dist/ui/types.js +53 -0
  701. package/dist/ui/types.js.map +1 -0
  702. package/package.json +104 -0
@@ -0,0 +1,731 @@
1
+ // omg — interactive chat assembler, moved verbatim from cli.ts
2
+ // runInteractive (Phase 282 refactor 4). The in-process Ink REPL: builds
3
+ // per-tab adapters, the event bus, the permission/ask/hooked-tool brokers,
4
+ // the slash + turn contexts, and runs the main input loop. Pure move —
5
+ // behavior is byte-identical; only the file location and import depths
6
+ // changed.
7
+ import { makeAdapter, } from "../../core/orchestration/orchestrator.js";
8
+ import { RoleRouter, UnknownRoleError } from "../../core/orchestration/roleRouter.js";
9
+ import { contextWindowForProvider } from "../../core/context/contextWindows.js";
10
+ import { RollingUsage, planCapFor } from "../../core/context/usageWindow.js";
11
+ import { loadUsageCache, usageStatusFields } from "../../core/context/usageCache.js";
12
+ import { appendEntry as appendContinuumEntry } from "../../core/continuum/index.js";
13
+ import { buildInjectionPrefix } from "../../core/state/memory.js";
14
+ import { dispatchSlash, } from "../slash.js";
15
+ import { runTurnFor } from "../turn.js";
16
+ import { runProviderLogin } from "../login.js";
17
+ import { makeTabManager } from "./tabManager.js";
18
+ import { makeBrokers } from "./brokers.js";
19
+ import { looksLikeTeamResume } from "./teamHint.js";
20
+ export async function runInteractive(opts) {
21
+ const router = RoleRouter.default();
22
+ let config;
23
+ try {
24
+ config = router.configFor(opts.role);
25
+ }
26
+ catch (e) {
27
+ if (e instanceof UnknownRoleError) {
28
+ process.stderr.write(`${e.message}\n`);
29
+ return 2;
30
+ }
31
+ throw e;
32
+ }
33
+ // Phase 48: provider+model are per-tab. The default tab uses the
34
+ // CLI-supplied or policy-resolved provider; later tabs created
35
+ // via /new can pick their own with `--provider <p>`.
36
+ const defaultProvider = opts.provider === "policy"
37
+ ? config.llm.provider
38
+ : opts.provider;
39
+ const defaultModel = defaultProvider === config.llm.provider ? config.llm.model : "";
40
+ const adapterOptsBase = { ...opts.adapterOpts };
41
+ // Phase 160: ask_user is an available tool the model uses if it wants —
42
+ // we no longer force it via the system prompt. Pushing a model to call
43
+ // a specific tool is unreliable (it just asks in prose anyway) and only
44
+ // pollutes the prompt; a plain-text question is a fine normal turn, and
45
+ // the message queue lets the user answer mid-stream. The picker shows
46
+ // when the model naturally chooses ask_user.
47
+ // Force session resume on; bind throttle forwarder later (post-pushStatus).
48
+ // Phase 238: the forwarder now takes an optional tab so the
49
+ // throttle status lands on the adapter's owning tab — not on
50
+ // whichever tab the user happens to be viewing. buildAdapter
51
+ // accepts a deferred `owningTab` callback because the Tab object
52
+ // is constructed AFTER the adapter (see makeTab); the callback is
53
+ // invoked only on stderr fire, by which time the Tab exists.
54
+ let throttleForwarder = null;
55
+ // Phase 309: when on, codex-cli adapters are built WITHOUT session
56
+ // resume so omg sends the full conversation each turn and owns the
57
+ // context (tab.messages) — which lets /compact + auto-compact actually
58
+ // shrink it. codex `exec` can't compact its own thread (upstream bugs
59
+ // openai/codex#16033/#16068; it hard-errors at the window), so this is
60
+ // the only way to keep a long codex turn under the limit. Phase 333 (W1):
61
+ // default ON now (explicit OMG_CODEX_STATELESS=0 opts out) — stateless
62
+ // also re-prepends the behavioral nudges (composeSystem) on every fresh
63
+ // exec, so codex gets `via claude`-equivalent guidance each turn, not
64
+ // just the first. Toggled at runtime via /codex-stateless.
65
+ let codexStateless = process.env.OMG_CODEX_STATELESS !== "0";
66
+ const buildAdapter = async (provider, model, owningTab) => makeAdapter(provider, model, {
67
+ ...adapterOptsBase,
68
+ // Codex stateless mode drops resume so omg manages context.
69
+ enableSessionResume: !(provider === "codex-cli" && codexStateless),
70
+ onThrottle: (info) => throttleForwarder?.(info, owningTab?.()),
71
+ // Phase 243: claudeCli adapter threads this into OMG_TAB_NAME
72
+ // on each spawn so the PreToolUse hook can name the source
73
+ // tab when it forwards AskUserQuestion to the broker.
74
+ getTabName: owningTab ? () => owningTab()?.name : undefined,
75
+ });
76
+ // Phase 344: one-shot provider-setup nudge before the TUI takes the
77
+ // screen. No-op when every required provider is usable, for the stub
78
+ // provider, or with OMG_SKIP_PREFLIGHT=1.
79
+ const { runPreflightNudge } = await import("../modes/doctor.js");
80
+ await runPreflightNudge({ defaultProvider });
81
+ const { launchInk } = await import("../../ui/launcher.js");
82
+ // Phase 294: `let` (not const) so /login can unmount Ink, hand the TTY
83
+ // to a provider login, then repoint this to a fresh session. pushNotif
84
+ // and the input loop read `ink` through this binding, so reassigning
85
+ // it after relaunch is enough — no other rewiring of those closures.
86
+ let ink = launchInk();
87
+ // Phase 51: pushNotif optionally targets a specific tab so the
88
+ // turn writer can route to whichever tab owned the user message
89
+ // — even after the user has /switch'd elsewhere. The default
90
+ // (no tab) routes to whatever tab is currently active, which is
91
+ // what slash handlers want.
92
+ // - log events (text / thinking / tool_use_* / end / verdict)
93
+ // get appended to the target tab's event log so /switch can
94
+ // replay them later.
95
+ // - the ink push only fires when the target tab is the active
96
+ // tab — otherwise the user sees a background-tab's stream
97
+ // leaking into the tab they're actively reading.
98
+ // Phase 240 (audit): `tab.events` had no cap — every event/text
99
+ // chunk on every turn lived forever, and the auto-compact in Phase
100
+ // 182 only trimmed `tab.messages` (conversation tokens), not the
101
+ // event log. A 10-hour session × N tabs reached easy 100K+ entries
102
+ // per tab. Cap is generous (5000 entries ≈ thousands of chat
103
+ // rows); when we exceed it we trim the oldest 1000 in one shot so
104
+ // amortized cost stays at O(1). The user loses oldest scrollback
105
+ // history, but the trade-off is bounded memory for arbitrarily
106
+ // long sessions.
107
+ const EVENTS_CAP = 5000;
108
+ const EVENTS_TRIM = 1000;
109
+ const pushNotif = (n, tab) => {
110
+ const target = tab ?? currentTab();
111
+ const method = n.method;
112
+ if (method === "event/text" ||
113
+ method === "event/thinking" ||
114
+ method === "event/user_echo" ||
115
+ method === "event/tool_use_start" ||
116
+ method === "event/tool_use_progress" ||
117
+ method === "event/tool_use_end" ||
118
+ method === "event/end" ||
119
+ method === "event/verdict") {
120
+ target.events.push(n);
121
+ if (target.events.length > EVENTS_CAP) {
122
+ target.events.splice(0, EVENTS_TRIM);
123
+ }
124
+ }
125
+ if (target === currentTab()) {
126
+ ink.push(n);
127
+ }
128
+ };
129
+ // Phase 220 (hotfix, post-219 distribution): `tab` parameter routes
130
+ // the status through pushNotif's `target === currentTab()` filter so
131
+ // per-tab transient state (teamPhase / teamRoles / etc.) emitted by
132
+ // a background tab does NOT leak into the currently-displayed tab's
133
+ // UI. Without the routing, /team on tab 2 while the user was viewing
134
+ // tab 1 made the team status panel pop up on tab 1.
135
+ const pushStatus = (s, tab) => {
136
+ pushNotif({ jsonrpc: "2.0", method: "event/status", params: s }, tab);
137
+ };
138
+ // Phase 162: catch handler for fire-and-forget async work. An
139
+ // uncaught rejection in a `void (async …)()` used to vanish silently
140
+ // (the team / turn just stalled with no message). Surface it, and —
141
+ // for a turn — clear the tab's in-flight state so it isn't stuck.
142
+ const reportAsyncError = (label, tab) => (e) => {
143
+ if (tab) {
144
+ tab.inFlight = false;
145
+ tab.inFlightSince = undefined;
146
+ tab.cancel = undefined;
147
+ }
148
+ pushNotif({
149
+ jsonrpc: "2.0",
150
+ method: "event/text",
151
+ params: {
152
+ text: `\n[${label} error: ${e instanceof Error ? e.message : String(e)}]\n`,
153
+ },
154
+ }, tab);
155
+ };
156
+ // Phase 37: bind the throttle forwarder now that pushStatus exists.
157
+ // Adapter stderr → onThrottle → event/status carrying the resetMs
158
+ // deadline. UI ticks it down to zero, then auto-clears.
159
+ // Phase 238: route to the owning tab so a background adapter's 429
160
+ // doesn't paint the throttle badge on whichever tab the user is
161
+ // looking at.
162
+ throttleForwarder = (info, tab) => {
163
+ // Some lines (bare "429") report no number; show a 5 s default so
164
+ // the indicator still flashes — better than nothing.
165
+ const resetMs = info.resetMs > 0 ? info.resetMs : 5_000;
166
+ pushStatus({
167
+ throttleUntil: Date.now() + resetMs,
168
+ throttleReason: info.reason,
169
+ }, tab);
170
+ };
171
+ const slashState = {
172
+ activeTabName: "main",
173
+ nextTabSerial: 2,
174
+ askMode: !!opts.ask,
175
+ planMode: false,
176
+ predictMode: true,
177
+ };
178
+ // Phase 283 (refactor 4b): the tabs Map and its lifecycle closures
179
+ // live in tabManager.ts. buildAdapter is injected because it closes
180
+ // over the throttle forwarder bound just above.
181
+ const { tabs, makeTab, persistTabs, currentTab, tabIndex, readyCount, snapshotTabsState, renameTab, maybeAutoName, } = await makeTabManager({
182
+ slashState,
183
+ buildAdapter,
184
+ defaultProvider,
185
+ defaultModel,
186
+ });
187
+ // Phase 284 (refactor 4b): the permission / ask / hooked-tool brokers,
188
+ // their pending-reply maps, findAskingTab, and the AskUserQuestion
189
+ // handler live in brokers.ts. They round-trip through the Ink UI, so
190
+ // ink + the event bus + the tab accessors are injected. The factory
191
+ // sets the OMG_*_SOCKET env vars; the finally below owns the deletes.
192
+ const brokers = await makeBrokers({
193
+ ink,
194
+ slashState,
195
+ tabs,
196
+ currentTab,
197
+ pushStatus,
198
+ snapshotTabsState,
199
+ });
200
+ // Phase 340: the resolved value carries optional image attachments
201
+ // (absolute paths) alongside the text so a turn can attach images.
202
+ let userInputResolver = null;
203
+ let quitRequested = false;
204
+ // Phase 120 → 155: next-message prediction (/predict). Default ON —
205
+ // each turn fires a small (haiku) inference to ghost the likely next
206
+ // message. `/predict off` disables it for the session.
207
+ const sessionStartedAt = Date.now();
208
+ // Phase 45: rolling-window usage trackers. Each adapter usage chunk
209
+ // (output_tokens for that turn) feeds these; the bar reads the
210
+ // resulting sums and a user-supplied cap (if any) to display a %.
211
+ const usage5h = new RollingUsage(5 * 3600_000);
212
+ const usageWeekly = new RollingUsage(7 * 24 * 3600_000);
213
+ // Phase 175 (B2): session total wrapped in an object so the extracted
214
+ // turn module can mutate it by reference (a context field can't reassign
215
+ // a parent `let`).
216
+ const usageSession = { tokens: 0 };
217
+ const capFiveHour = planCapFor("five_hour");
218
+ const capWeekly = planCapFor("weekly");
219
+ const capSession = planCapFor("session");
220
+ // Phase 112: opt-in usage cache (OMG_USAGE_CACHE). When set, push
221
+ // the real cap + used numbers from the cache so the status-bar
222
+ // gauges show true percentages. Re-read each time (the producing
223
+ // tool refreshes the file independently).
224
+ const refreshUsageFromCache = () => {
225
+ const snap = loadUsageCache();
226
+ if (!snap)
227
+ return;
228
+ const fields = usageStatusFields(snap);
229
+ if (Object.keys(fields).length > 0)
230
+ pushStatus(fields);
231
+ };
232
+ // Phase 229: poll git status for the active tab's cwd every ~5s
233
+ // and on turn end. Status bar's git field renders branch + diff
234
+ // line counts in color. Out-of-repo cwds push `git: null` so the
235
+ // field hides cleanly.
236
+ const { readGitStatus } = await import("../gitStatus.js");
237
+ let lastGitCwd = "";
238
+ const refreshGit = async () => {
239
+ const t = currentTab();
240
+ const cwd = t.cwd;
241
+ lastGitCwd = cwd;
242
+ try {
243
+ const status = await readGitStatus(cwd);
244
+ // Skip the push if the active cwd changed mid-call — the next
245
+ // poll will catch the new tab.
246
+ if (lastGitCwd !== cwd)
247
+ return;
248
+ pushStatus({ git: status });
249
+ }
250
+ catch {
251
+ pushStatus({ git: null });
252
+ }
253
+ };
254
+ void refreshGit();
255
+ const gitInterval = setInterval(() => void refreshGit(), 5000);
256
+ gitInterval.unref?.();
257
+ // Slash handlers that mutate runInteractive's local state. The TUI
258
+ // already wipes its own event log for /clear and /reset; here we
259
+ // also drop our conversation memory + (for /reset) the adapter
260
+ // session id so the next user message starts a fresh CLI session.
261
+ // Phase 239: on /close we have to settle any in-flight broker
262
+ // round-trips that were targeted at the dying tab. The proxy ask
263
+ // map holds Promise resolvers; if we just drop the tab, those
264
+ // resolvers stay parked forever (memory leak + the calling broker
265
+ // thread hangs). Resolve with the NO_ANSWER sentinel so the
266
+ // adapter side gets a finite reply and clears its own state.
267
+ const cleanupTabBrokers = (tab) => {
268
+ // brokers.ts resolves the dying tab's parked ask_user round-trips
269
+ // with the NO_ANSWER sentinel so the calling broker thread doesn't
270
+ // hang; the bg-task watcher untrack (Phase 257) stays here because
271
+ // bgTaskWatcher is built later in this scope.
272
+ const { dropped } = brokers.cleanupPendingForTab(tab);
273
+ bgTaskWatcher.untrackTab(tab.name);
274
+ return { dropped };
275
+ };
276
+ const slashCtx = {
277
+ state: slashState,
278
+ tabs,
279
+ ink,
280
+ adapterOptsBase,
281
+ pushNotif,
282
+ pushStatus,
283
+ currentTab,
284
+ tabIndex,
285
+ readyCount,
286
+ snapshotTabsState,
287
+ makeTab,
288
+ renameTab,
289
+ buildAdapter,
290
+ cleanupTabBrokers,
291
+ };
292
+ // Phase 294: in-TUI provider login. Unmount Ink so the login CLI owns
293
+ // the real terminal, run it, then relaunch a fresh session and repaint
294
+ // the active tab. State lives in core (tabs/events), so the new Ink is
295
+ // just re-fed via log_replace — nothing is lost. Returns the login
296
+ // exit code. NOTE: the unmount/relaunch path needs a real TTY to
297
+ // verify; it is a no-op-safe sequence but untested under the sandbox.
298
+ // Defined after slashCtx so it can repoint slashCtx.ink: pushNotif
299
+ // reads the `ink` binding (repointed below), but slash handlers reach
300
+ // the session through `ctx.ink` (e.g. tabs.ts replays pickers via
301
+ // ctx.ink.push), so that reference must follow the relaunch too.
302
+ const suspendForLogin = async (provider) => {
303
+ ink.unmount();
304
+ await ink.waitUntilExit();
305
+ const code = await runProviderLogin(provider);
306
+ ink = launchInk();
307
+ ink.onOutbound(handleOutbound);
308
+ slashCtx.ink = ink;
309
+ // Repaint the active tab into the fresh session (same shape /switch
310
+ // uses): replace the log wholesale, then re-emit the tab snapshot.
311
+ const cur = currentTab();
312
+ ink.push({
313
+ jsonrpc: "2.0",
314
+ method: "event/log_replace",
315
+ params: { events: cur.events },
316
+ });
317
+ pushStatus({ tabsState: snapshotTabsState() });
318
+ return code;
319
+ };
320
+ slashCtx.suspendForLogin = suspendForLogin;
321
+ // Phase 309: toggle codex stateless mode. Flips the flag and, if the
322
+ // active tab is codex, rebuilds its adapter so the change takes effect
323
+ // now (rebuild starts a fresh session — the old codex thread, which omg
324
+ // can't compact, is dropped; omg owns the context from here). Returns
325
+ // the new state.
326
+ slashCtx.toggleCodexStateless = async (force) => {
327
+ codexStateless = force === undefined ? !codexStateless : force;
328
+ const tab = currentTab();
329
+ if (tab.provider === "codex-cli") {
330
+ try {
331
+ const a = await buildAdapter(tab.provider, tab.model, () => tab);
332
+ a.setCwd?.(tab.cwd);
333
+ tab.adapter = a;
334
+ tab.adapter.resetSession?.();
335
+ tab.sessionId = undefined;
336
+ tab.messages.length = 0;
337
+ pushStatus({ sessionId: "—", tokensIn: 0, tokensOut: 0 }, tab);
338
+ }
339
+ catch (e) {
340
+ reportAsyncError("codex-stateless", tab)(e);
341
+ }
342
+ }
343
+ return codexStateless;
344
+ };
345
+ const onSlash = (name, args) => dispatchSlash(name, args, slashCtx);
346
+ // Phase 294: named so a post-/login relaunch can re-register it on the
347
+ // fresh InkSession (onOutbound holds a single handler).
348
+ const handleOutbound = (msg) => {
349
+ const m = msg;
350
+ // UI reply (no `method`, has `id`) → resolve against whichever
351
+ // broker pending-map owns it. brokers.ts holds the three maps.
352
+ if (brokers.resolvePendingReply(m))
353
+ return;
354
+ if (m.method === "user/quit") {
355
+ quitRequested = true;
356
+ if (userInputResolver) {
357
+ userInputResolver({ text: null, attachments: [] });
358
+ userInputResolver = null;
359
+ }
360
+ return;
361
+ }
362
+ if (m.method === "user/input") {
363
+ const text = m.params?.text;
364
+ // Phase 340: absolute image paths attached to this turn (clipboard
365
+ // capture / @path), validated to a string[] of non-empty entries.
366
+ const rawAtt = m.params?.attachments;
367
+ const attachments = Array.isArray(rawAtt)
368
+ ? rawAtt.filter((a) => typeof a === "string" && a.length > 0)
369
+ : [];
370
+ if (typeof text === "string" && userInputResolver) {
371
+ // Phase 225 (hotfix, root cause): persist the user echo on
372
+ // the tab's own event log via pushNotif. Pre-225, App.tsx
373
+ // pushed the echo only to its local events state; on /switch
374
+ // the log_replace overwrote App.events with tab.events and
375
+ // the echo vanished. /team-route echoes were fine because
376
+ // slash.ts already used pushNotif; only the regular-turn
377
+ // path was missing the persistence step.
378
+ const echoTab = currentTab();
379
+ pushNotif({
380
+ jsonrpc: "2.0",
381
+ method: "event/user_echo",
382
+ params: { text },
383
+ }, echoTab);
384
+ // Phase 77: optionally prefix the *first* user message of a
385
+ // tab with persistent memory bullets. Only fires when the
386
+ // tab has no prior messages — subsequent turns reuse the
387
+ // adapter's session and don't need re-injection.
388
+ let resolved = text;
389
+ if (process.env.OMG_INJECT_MEMORY &&
390
+ echoTab.messages.length === 0) {
391
+ const prefix = buildInjectionPrefix();
392
+ if (prefix)
393
+ resolved = prefix + text;
394
+ }
395
+ userInputResolver({ text: resolved, attachments });
396
+ userInputResolver = null;
397
+ }
398
+ return;
399
+ }
400
+ if (m.method === "user/slash") {
401
+ const name = typeof m.params?.name === "string" ? m.params.name : "";
402
+ const args = typeof m.params?.args === "string" ? m.params.args : "";
403
+ // Phase 72: persist tab layout after each slash dispatch.
404
+ // onSlash mutates Tab state for new/switch/close/rename/cd/dup
405
+ // /team; covering the dispatcher with one save keeps the
406
+ // individual handlers free of bookkeeping.
407
+ void onSlash(name, args)
408
+ .then(() => persistTabs())
409
+ // Phase 229: cwd may have changed (/cd, /switch, /new) — refresh
410
+ // git status immediately rather than waiting for the next poll.
411
+ .then(() => refreshGit())
412
+ .catch(reportAsyncError("slash"));
413
+ return;
414
+ }
415
+ if (m.method === "user/cancel") {
416
+ // Phase 149: cancel whatever the active tab is running. The
417
+ // per-tab hook handles both a plain turn (SIGTERM the adapter)
418
+ // and a team run (abort the loop + kill every role adapter). Fall
419
+ // back to the adapter directly for tabs without a hook.
420
+ const tab = currentTab();
421
+ if (typeof tab.cancel === "function") {
422
+ tab.cancel();
423
+ }
424
+ else {
425
+ tab.adapter.cancel?.();
426
+ }
427
+ // The dispatcher.run will see the child exit and throw; the catch
428
+ // block in the turn loop pushes an error event + stream_end.
429
+ return;
430
+ }
431
+ if (m.method === "user/picker_close") {
432
+ pushNotif({
433
+ jsonrpc: "2.0",
434
+ method: "event/text",
435
+ params: { text: `[sessions] cancelled\n` },
436
+ });
437
+ return;
438
+ }
439
+ if (m.method === "user/select_session") {
440
+ const params = m.params;
441
+ const id = typeof params?.id === "string" ? params.id : "";
442
+ if (!id)
443
+ return;
444
+ const pickedProvider = typeof params?.provider === "string" ? params.provider : "";
445
+ const tab = currentTab();
446
+ void (async () => {
447
+ // Phase 76: if the session belongs to a different provider
448
+ // than the active tab (cross-provider "all" picker), rebuild
449
+ // the tab's adapter for that provider first.
450
+ if (pickedProvider && pickedProvider !== tab.provider) {
451
+ try {
452
+ const newAdapter = await buildAdapter(pickedProvider, "", () => tab);
453
+ newAdapter.setCwd?.(tab.cwd);
454
+ tab.adapter = newAdapter;
455
+ tab.provider = pickedProvider;
456
+ tab.model = "";
457
+ pushStatus({
458
+ provider: tab.provider,
459
+ model: "(default)",
460
+ contextWindow: contextWindowForProvider(tab.provider, ""),
461
+ });
462
+ }
463
+ catch (e) {
464
+ pushNotif({
465
+ jsonrpc: "2.0",
466
+ method: "event/text",
467
+ params: {
468
+ text: `[sessions] failed to switch to ${pickedProvider}: ${e.message}\n`,
469
+ },
470
+ });
471
+ return;
472
+ }
473
+ }
474
+ // Inject the chosen id into the adapter; runInteractive always
475
+ // turns enableSessionResume on so the next turn's buildArgs
476
+ // will use it.
477
+ tab.adapter.restoreSession?.(id);
478
+ tab.sessionId = id;
479
+ tab.messages.length = 0;
480
+ pushStatus({ sessionId: id, tokensIn: 0, tokensOut: 0 });
481
+ pushNotif({
482
+ jsonrpc: "2.0",
483
+ method: "event/text",
484
+ params: {
485
+ text: `[sessions] resuming ${id.slice(0, 8)}${pickedProvider ? ` on ${pickedProvider}` : ""} — type a message to continue.\n`,
486
+ },
487
+ });
488
+ })();
489
+ return;
490
+ }
491
+ };
492
+ ink.onOutbound(handleOutbound);
493
+ // Phase 340: resolves text + image attachments for the next turn.
494
+ const waitForUserInput = () => new Promise((resolve) => {
495
+ userInputResolver = resolve;
496
+ });
497
+ // Seed status bar with everything we know up front.
498
+ pushStatus({
499
+ role: opts.role,
500
+ provider: currentTab().provider,
501
+ model: currentTab().model || "(default)",
502
+ cwd: currentTab().cwd,
503
+ mode: "chat",
504
+ tokensIn: 0,
505
+ tokensOut: 0,
506
+ ask: !!opts.ask,
507
+ plan: slashState.planMode,
508
+ contextWindow: contextWindowForProvider(currentTab().provider, currentTab().model),
509
+ sessionStartedAt,
510
+ toolCalls: 0,
511
+ });
512
+ // Phase 112: seed usage gauges from the cache (if configured).
513
+ refreshUsageFromCache();
514
+ // Phase 257: claude-cli's `run_in_background` Bash promises a
515
+ // notification when the task completes, but the print-mode
516
+ // process exits at end-of-turn — there's no live session to
517
+ // surface the notification on. The watcher polls the task's
518
+ // output file and auto-injects a continuation into the owning tab
519
+ // when the file settles. See bgTasks.ts for the polling heuristic.
520
+ const { BgTaskWatcher } = await import("../bgTasks.js");
521
+ const bgTaskWatcher = new BgTaskWatcher((task, output) => {
522
+ const owning = tabs.get(task.tabName);
523
+ if (!owning)
524
+ return; // tab was /closed before the task finished
525
+ // Truncate massive outputs so the continuation prompt doesn't
526
+ // blow past the model's context — Read can pull more if needed.
527
+ const MAX_INLINE = 8000;
528
+ const trimmed = output.length > MAX_INLINE
529
+ ? output.slice(0, MAX_INLINE) +
530
+ `\n\n[…truncated; ${output.length - MAX_INLINE} more bytes available at ${task.outputPath}]`
531
+ : output;
532
+ const text = `[Background task completed: ${task.command}]\n\n` +
533
+ (trimmed.trim().length > 0 ? trimmed : "(no output captured)");
534
+ // Echo into the owning tab's events so the user sees what just
535
+ // resumed — without this they'd see a sudden response with no
536
+ // visible cause.
537
+ pushNotif({
538
+ jsonrpc: "2.0",
539
+ method: "event/text",
540
+ params: {
541
+ text: `\n[bg] ${task.command} completed — auto-resuming\n`,
542
+ },
543
+ }, owning);
544
+ // Inject into the owning tab. If a turn is in flight we queue
545
+ // (same path as type-ahead); if idle, push directly and start a
546
+ // fresh turn. Either way the message threads through the
547
+ // adapter's resumed session.
548
+ if (owning.inFlight) {
549
+ (owning.queued ??= []).push(text);
550
+ }
551
+ else {
552
+ owning.messages.push({ role: "user", text });
553
+ void runTurnFor(owning, turnCtx).catch(reportAsyncError("bgtask-resume", owning));
554
+ }
555
+ });
556
+ // Phase 175 (B2): turn execution lives in ./cli/turn.ts. The closures
557
+ // it replaced captured runInteractive scope; that travels through
558
+ // turnCtx. runTurn is set after construction so the queued-drain
559
+ // recursion can re-enter the module function.
560
+ const turnCtx = {
561
+ state: slashState,
562
+ tabs,
563
+ pushNotif,
564
+ pushStatus,
565
+ currentTab,
566
+ tabIndex,
567
+ readyCount,
568
+ snapshotTabsState,
569
+ maybeAutoName,
570
+ persistTabs,
571
+ refreshUsageFromCache,
572
+ adapterOptsBase,
573
+ usage: {
574
+ five: usage5h,
575
+ weekly: usageWeekly,
576
+ session: usageSession,
577
+ capFive: capFiveHour,
578
+ capWeekly,
579
+ capSession,
580
+ },
581
+ reportAsyncError,
582
+ runTurn: (tab) => runTurnFor(tab, turnCtx),
583
+ bgTasks: bgTaskWatcher,
584
+ };
585
+ try {
586
+ // Seed first user input (either from CLI arg or interactive).
587
+ let firstText;
588
+ let firstAttachments = [];
589
+ if (opts.initialPrompt !== undefined && opts.initialPrompt.length > 0) {
590
+ firstText = opts.initialPrompt;
591
+ }
592
+ else {
593
+ const seed = await waitForUserInput();
594
+ firstText = seed.text;
595
+ firstAttachments = seed.attachments;
596
+ }
597
+ if (quitRequested || firstText === null)
598
+ return 0;
599
+ let pendingText = firstText;
600
+ // Phase 340: image paths for the pending turn (cleared after consumed).
601
+ let pendingAttachments = firstAttachments;
602
+ while (!quitRequested) {
603
+ if (pendingText !== null) {
604
+ const owning = currentTab();
605
+ // Phase 287 (B): on a team-* tab, a chat message that reads like
606
+ // "resume the team" can't drive omg's /team pipeline — it only
607
+ // talks to this tab's single adapter. Surface a one-line hint
608
+ // (non-blocking; the turn still runs) pointing at /team.
609
+ // Phase 287 (B) / 288: the team-resume hint only applies to a
610
+ // solo follow-up turn (input goes to this tab's single adapter).
611
+ // During an active team pipeline, mid-run input IS folded into
612
+ // the team as checkpoint steering, so suppress the misleading
613
+ // "single adapter only" hint while teamInFlight.
614
+ if (owning.name.startsWith("team-") &&
615
+ !owning.teamInFlight &&
616
+ looksLikeTeamResume(pendingText)) {
617
+ pushNotif({
618
+ jsonrpc: "2.0",
619
+ method: "event/text",
620
+ params: {
621
+ text: "[team] omg 팀은 슬래시 명령으로 동작합니다 — 멀티역할로 다시 실행하려면 `/team <작업>`을 쓰세요. (이 메시지는 이 탭의 단일 어댑터로만 전달됩니다.)\n",
622
+ },
623
+ }, owning);
624
+ }
625
+ if (owning.inFlight) {
626
+ // Phase 159 / 288: queue it. On an active team pipeline this is
627
+ // checkpoint steering — the runner drains tab.queued at the next
628
+ // role boundary and folds it into the implementer. On any other
629
+ // in-flight turn it's plain type-ahead (claude-cli print mode
630
+ // can't be steered mid-turn), auto-sent when the turn ends.
631
+ (owning.queued ??= []).push(pendingText);
632
+ const steering = owning.teamInFlight === true;
633
+ pushNotif({
634
+ jsonrpc: "2.0",
635
+ method: "event/text",
636
+ params: {
637
+ text: steering
638
+ ? `[steering] 다음 역할 경계에서 팀 implementer에 반영됩니다 (${owning.queued.length} 대기). Esc는 팀 전체를 취소합니다.\n`
639
+ : `[queued] will send when the current turn ends (${owning.queued.length} waiting). Esc cancels the current turn to send sooner.\n`,
640
+ },
641
+ });
642
+ }
643
+ else {
644
+ // Phase 340: attach this turn's images (idle send only; ephemeral).
645
+ owning.messages.push(pendingAttachments.length > 0
646
+ ? { role: "user", text: pendingText, attachments: pendingAttachments }
647
+ : { role: "user", text: pendingText });
648
+ // Phase 201b: mirror to the continuum so the persistent
649
+ // transcript captures user prompts across sessions.
650
+ if (owning.continuumId) {
651
+ try {
652
+ appendContinuumEntry(owning.continuumId, {
653
+ version: 1,
654
+ kind: "user",
655
+ text: pendingText,
656
+ ts: Date.now(),
657
+ tabName: owning.name,
658
+ });
659
+ }
660
+ catch {
661
+ /* continuum write best-effort */
662
+ }
663
+ }
664
+ // Fire-and-forget: don't await. The main loop loops back
665
+ // to waitForUserInput so the user can switch tabs / start
666
+ // another turn elsewhere immediately.
667
+ void runTurnFor(owning, turnCtx).catch(reportAsyncError("turn", owning));
668
+ }
669
+ pendingText = null;
670
+ pendingAttachments = [];
671
+ }
672
+ const next = await waitForUserInput();
673
+ if (quitRequested || next.text === null)
674
+ break;
675
+ pendingText = next.text;
676
+ pendingAttachments = next.attachments;
677
+ }
678
+ // Phase 207: cancel ALL adapter children (and any tab.cancel
679
+ // wired by /team) and put a hard ceiling on the cleanup wait.
680
+ // Pre-Phase-207, an in-flight haiku from continuum auto-digest
681
+ // or a /team's per-role pool would keep the process alive for
682
+ // ~30s while the user wondered if /q was even acknowledged.
683
+ for (const t of tabs.values()) {
684
+ try {
685
+ t.cancel?.();
686
+ }
687
+ catch {
688
+ /* tab cancel best-effort */
689
+ }
690
+ try {
691
+ t.adapter.cancel?.();
692
+ }
693
+ catch {
694
+ /* adapter cancel best-effort */
695
+ }
696
+ }
697
+ // Brief grace for cancels to land + writers to drain.
698
+ const deadline = Date.now() + 1_000;
699
+ while (Date.now() < deadline) {
700
+ const busy = [...tabs.values()].filter((t) => t.inFlight);
701
+ if (busy.length === 0)
702
+ break;
703
+ await new Promise((r) => setTimeout(r, 25));
704
+ }
705
+ return 0;
706
+ }
707
+ finally {
708
+ ink.close();
709
+ // Phase 207: hard cap on shutdown. Brokers / continuum digest /
710
+ // detached children that haven't drained get cut off here so /q
711
+ // can't appear to hang. waitUntilExit + broker.close races a
712
+ // 1.5s ceiling; whichever finishes first wins.
713
+ const SHUTDOWN_CEILING_MS = 1_500;
714
+ const ceiling = new Promise((resolve) => setTimeout(resolve, SHUTDOWN_CEILING_MS));
715
+ // Phase 257: stop the bg-task polling timer so node can exit
716
+ // cleanly on /quit even if a task was mid-watch.
717
+ bgTaskWatcher.close();
718
+ const drain = Promise.all([
719
+ ink.waitUntilExit(),
720
+ brokers.permBroker.close(),
721
+ brokers.askBroker.close(),
722
+ brokers.hookedToolBroker.close(),
723
+ ]).then(() => undefined);
724
+ await Promise.race([drain, ceiling]);
725
+ delete process.env.OMG_PERMISSION_SOCKET;
726
+ delete process.env.OMG_ASK_SOCKET;
727
+ delete process.env.OMG_HOOKED_TOOL_SOCKET;
728
+ delete process.env.OMG_HOOKED_TOOLS;
729
+ }
730
+ }
731
+ //# sourceMappingURL=index.js.map