oh-my-codex-pennix 0.18.13

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 (3061) hide show
  1. package/.agents/plugins/marketplace.json +20 -0
  2. package/Cargo.lock +185 -0
  3. package/Cargo.toml +24 -0
  4. package/README.md +445 -0
  5. package/crates/omx-api/Cargo.toml +19 -0
  6. package/crates/omx-api/src/lib.rs +2997 -0
  7. package/crates/omx-api/src/main.rs +10 -0
  8. package/crates/omx-api/tests/cli.rs +558 -0
  9. package/crates/omx-explore/Cargo.toml +14 -0
  10. package/crates/omx-explore/src/main.rs +2972 -0
  11. package/crates/omx-mux/Cargo.toml +11 -0
  12. package/crates/omx-mux/src/lib.rs +91 -0
  13. package/crates/omx-mux/src/tmux.rs +282 -0
  14. package/crates/omx-mux/src/types.rs +306 -0
  15. package/crates/omx-runtime/Cargo.toml +13 -0
  16. package/crates/omx-runtime/src/main.rs +125 -0
  17. package/crates/omx-runtime/tests/execution.rs +212 -0
  18. package/crates/omx-runtime-core/Cargo.toml +13 -0
  19. package/crates/omx-runtime-core/src/authority.rs +239 -0
  20. package/crates/omx-runtime-core/src/dispatch.rs +330 -0
  21. package/crates/omx-runtime-core/src/engine.rs +853 -0
  22. package/crates/omx-runtime-core/src/lib.rs +653 -0
  23. package/crates/omx-runtime-core/src/mailbox.rs +261 -0
  24. package/crates/omx-runtime-core/src/replay.rs +104 -0
  25. package/crates/omx-sparkshell/Cargo.lock +7 -0
  26. package/crates/omx-sparkshell/Cargo.toml +14 -0
  27. package/crates/omx-sparkshell/src/codex_bridge.rs +768 -0
  28. package/crates/omx-sparkshell/src/error.rs +45 -0
  29. package/crates/omx-sparkshell/src/exec.rs +241 -0
  30. package/crates/omx-sparkshell/src/main.rs +1133 -0
  31. package/crates/omx-sparkshell/src/prompt.rs +364 -0
  32. package/crates/omx-sparkshell/src/redaction.rs +241 -0
  33. package/crates/omx-sparkshell/src/registry/c_cpp.rs +9 -0
  34. package/crates/omx-sparkshell/src/registry/csharp.rs +10 -0
  35. package/crates/omx-sparkshell/src/registry/generic_shell.rs +11 -0
  36. package/crates/omx-sparkshell/src/registry/git.rs +10 -0
  37. package/crates/omx-sparkshell/src/registry/go.rs +9 -0
  38. package/crates/omx-sparkshell/src/registry/java_kotlin.rs +9 -0
  39. package/crates/omx-sparkshell/src/registry/mod.rs +85 -0
  40. package/crates/omx-sparkshell/src/registry/node_js.rs +9 -0
  41. package/crates/omx-sparkshell/src/registry/python.rs +9 -0
  42. package/crates/omx-sparkshell/src/registry/ruby.rs +9 -0
  43. package/crates/omx-sparkshell/src/registry/rust.rs +9 -0
  44. package/crates/omx-sparkshell/src/registry/swift.rs +10 -0
  45. package/crates/omx-sparkshell/src/test_support.rs +10 -0
  46. package/crates/omx-sparkshell/src/threshold.rs +75 -0
  47. package/crates/omx-sparkshell/tests/execution.rs +986 -0
  48. package/crates/omx-sparkshell/tests/registry.rs +99 -0
  49. package/dist/adapt/__tests__/foundation.test.d.ts +2 -0
  50. package/dist/adapt/__tests__/foundation.test.d.ts.map +1 -0
  51. package/dist/adapt/__tests__/foundation.test.js +171 -0
  52. package/dist/adapt/__tests__/foundation.test.js.map +1 -0
  53. package/dist/adapt/__tests__/hermes.test.d.ts +2 -0
  54. package/dist/adapt/__tests__/hermes.test.d.ts.map +1 -0
  55. package/dist/adapt/__tests__/hermes.test.js +137 -0
  56. package/dist/adapt/__tests__/hermes.test.js.map +1 -0
  57. package/dist/adapt/contracts.d.ts +157 -0
  58. package/dist/adapt/contracts.d.ts.map +1 -0
  59. package/dist/adapt/contracts.js +10 -0
  60. package/dist/adapt/contracts.js.map +1 -0
  61. package/dist/adapt/hermes.d.ts +83 -0
  62. package/dist/adapt/hermes.d.ts.map +1 -0
  63. package/dist/adapt/hermes.js +371 -0
  64. package/dist/adapt/hermes.js.map +1 -0
  65. package/dist/adapt/index.d.ts +14 -0
  66. package/dist/adapt/index.d.ts.map +1 -0
  67. package/dist/adapt/index.js +293 -0
  68. package/dist/adapt/index.js.map +1 -0
  69. package/dist/adapt/openclaw.d.ts +7 -0
  70. package/dist/adapt/openclaw.d.ts.map +1 -0
  71. package/dist/adapt/openclaw.js +299 -0
  72. package/dist/adapt/openclaw.js.map +1 -0
  73. package/dist/adapt/paths.d.ts +3 -0
  74. package/dist/adapt/paths.d.ts.map +1 -0
  75. package/dist/adapt/paths.js +15 -0
  76. package/dist/adapt/paths.js.map +1 -0
  77. package/dist/adapt/registry.d.ts +4 -0
  78. package/dist/adapt/registry.d.ts.map +1 -0
  79. package/dist/adapt/registry.js +48 -0
  80. package/dist/adapt/registry.js.map +1 -0
  81. package/dist/agents/__tests__/definitions.test.d.ts +2 -0
  82. package/dist/agents/__tests__/definitions.test.d.ts.map +1 -0
  83. package/dist/agents/__tests__/definitions.test.js +96 -0
  84. package/dist/agents/__tests__/definitions.test.js.map +1 -0
  85. package/dist/agents/__tests__/native-config.test.d.ts +2 -0
  86. package/dist/agents/__tests__/native-config.test.d.ts.map +1 -0
  87. package/dist/agents/__tests__/native-config.test.js +398 -0
  88. package/dist/agents/__tests__/native-config.test.js.map +1 -0
  89. package/dist/agents/definitions.d.ts +35 -0
  90. package/dist/agents/definitions.d.ts.map +1 -0
  91. package/dist/agents/definitions.js +371 -0
  92. package/dist/agents/definitions.js.map +1 -0
  93. package/dist/agents/native-config.d.ts +56 -0
  94. package/dist/agents/native-config.d.ts.map +1 -0
  95. package/dist/agents/native-config.js +285 -0
  96. package/dist/agents/native-config.js.map +1 -0
  97. package/dist/agents/policy.d.ts +10 -0
  98. package/dist/agents/policy.d.ts.map +1 -0
  99. package/dist/agents/policy.js +61 -0
  100. package/dist/agents/policy.js.map +1 -0
  101. package/dist/auth/__tests__/config-sessions.test.d.ts +2 -0
  102. package/dist/auth/__tests__/config-sessions.test.d.ts.map +1 -0
  103. package/dist/auth/__tests__/config-sessions.test.js +48 -0
  104. package/dist/auth/__tests__/config-sessions.test.js.map +1 -0
  105. package/dist/auth/__tests__/quota-rotation.test.d.ts +2 -0
  106. package/dist/auth/__tests__/quota-rotation.test.d.ts.map +1 -0
  107. package/dist/auth/__tests__/quota-rotation.test.js +33 -0
  108. package/dist/auth/__tests__/quota-rotation.test.js.map +1 -0
  109. package/dist/auth/__tests__/redact.test.d.ts +2 -0
  110. package/dist/auth/__tests__/redact.test.d.ts.map +1 -0
  111. package/dist/auth/__tests__/redact.test.js +20 -0
  112. package/dist/auth/__tests__/redact.test.js.map +1 -0
  113. package/dist/auth/__tests__/storage.test.d.ts +2 -0
  114. package/dist/auth/__tests__/storage.test.d.ts.map +1 -0
  115. package/dist/auth/__tests__/storage.test.js +108 -0
  116. package/dist/auth/__tests__/storage.test.js.map +1 -0
  117. package/dist/auth/config.d.ts +9 -0
  118. package/dist/auth/config.d.ts.map +1 -0
  119. package/dist/auth/config.js +77 -0
  120. package/dist/auth/config.js.map +1 -0
  121. package/dist/auth/hotswap.d.ts +36 -0
  122. package/dist/auth/hotswap.d.ts.map +1 -0
  123. package/dist/auth/hotswap.js +159 -0
  124. package/dist/auth/hotswap.js.map +1 -0
  125. package/dist/auth/index.d.ts +8 -0
  126. package/dist/auth/index.d.ts.map +1 -0
  127. package/dist/auth/index.js +8 -0
  128. package/dist/auth/index.js.map +1 -0
  129. package/dist/auth/paths.d.ts +12 -0
  130. package/dist/auth/paths.d.ts.map +1 -0
  131. package/dist/auth/paths.js +78 -0
  132. package/dist/auth/paths.js.map +1 -0
  133. package/dist/auth/quota-detector.d.ts +10 -0
  134. package/dist/auth/quota-detector.d.ts.map +1 -0
  135. package/dist/auth/quota-detector.js +40 -0
  136. package/dist/auth/quota-detector.js.map +1 -0
  137. package/dist/auth/redact.d.ts +2 -0
  138. package/dist/auth/redact.d.ts.map +1 -0
  139. package/dist/auth/redact.js +26 -0
  140. package/dist/auth/redact.js.map +1 -0
  141. package/dist/auth/rotation.d.ts +9 -0
  142. package/dist/auth/rotation.d.ts.map +1 -0
  143. package/dist/auth/rotation.js +26 -0
  144. package/dist/auth/rotation.js.map +1 -0
  145. package/dist/auth/sessions.d.ts +15 -0
  146. package/dist/auth/sessions.d.ts.map +1 -0
  147. package/dist/auth/sessions.js +62 -0
  148. package/dist/auth/sessions.js.map +1 -0
  149. package/dist/auth/storage.d.ts +27 -0
  150. package/dist/auth/storage.d.ts.map +1 -0
  151. package/dist/auth/storage.js +111 -0
  152. package/dist/auth/storage.js.map +1 -0
  153. package/dist/autopilot/__tests__/deep-interview-gate.test.d.ts +2 -0
  154. package/dist/autopilot/__tests__/deep-interview-gate.test.d.ts.map +1 -0
  155. package/dist/autopilot/__tests__/deep-interview-gate.test.js +215 -0
  156. package/dist/autopilot/__tests__/deep-interview-gate.test.js.map +1 -0
  157. package/dist/autopilot/__tests__/fsm.test.d.ts +2 -0
  158. package/dist/autopilot/__tests__/fsm.test.d.ts.map +1 -0
  159. package/dist/autopilot/__tests__/fsm.test.js +78 -0
  160. package/dist/autopilot/__tests__/fsm.test.js.map +1 -0
  161. package/dist/autopilot/__tests__/ralplan-gate.test.d.ts +2 -0
  162. package/dist/autopilot/__tests__/ralplan-gate.test.d.ts.map +1 -0
  163. package/dist/autopilot/__tests__/ralplan-gate.test.js +274 -0
  164. package/dist/autopilot/__tests__/ralplan-gate.test.js.map +1 -0
  165. package/dist/autopilot/completion-gate.d.ts +10 -0
  166. package/dist/autopilot/completion-gate.d.ts.map +1 -0
  167. package/dist/autopilot/completion-gate.js +154 -0
  168. package/dist/autopilot/completion-gate.js.map +1 -0
  169. package/dist/autopilot/deep-interview-gate.d.ts +18 -0
  170. package/dist/autopilot/deep-interview-gate.d.ts.map +1 -0
  171. package/dist/autopilot/deep-interview-gate.js +396 -0
  172. package/dist/autopilot/deep-interview-gate.js.map +1 -0
  173. package/dist/autopilot/fsm.d.ts +13 -0
  174. package/dist/autopilot/fsm.d.ts.map +1 -0
  175. package/dist/autopilot/fsm.js +70 -0
  176. package/dist/autopilot/fsm.js.map +1 -0
  177. package/dist/autopilot/ralplan-gate.d.ts +17 -0
  178. package/dist/autopilot/ralplan-gate.d.ts.map +1 -0
  179. package/dist/autopilot/ralplan-gate.js +68 -0
  180. package/dist/autopilot/ralplan-gate.js.map +1 -0
  181. package/dist/autoresearch/__tests__/contracts.test.d.ts +2 -0
  182. package/dist/autoresearch/__tests__/contracts.test.d.ts.map +1 -0
  183. package/dist/autoresearch/__tests__/contracts.test.js +127 -0
  184. package/dist/autoresearch/__tests__/contracts.test.js.map +1 -0
  185. package/dist/autoresearch/__tests__/runtime-parity-extra.test.d.ts +2 -0
  186. package/dist/autoresearch/__tests__/runtime-parity-extra.test.d.ts.map +1 -0
  187. package/dist/autoresearch/__tests__/runtime-parity-extra.test.js +349 -0
  188. package/dist/autoresearch/__tests__/runtime-parity-extra.test.js.map +1 -0
  189. package/dist/autoresearch/__tests__/runtime.test.d.ts +2 -0
  190. package/dist/autoresearch/__tests__/runtime.test.d.ts.map +1 -0
  191. package/dist/autoresearch/__tests__/runtime.test.js +211 -0
  192. package/dist/autoresearch/__tests__/runtime.test.js.map +1 -0
  193. package/dist/autoresearch/__tests__/skill-validation.test.d.ts +2 -0
  194. package/dist/autoresearch/__tests__/skill-validation.test.d.ts.map +1 -0
  195. package/dist/autoresearch/__tests__/skill-validation.test.js +91 -0
  196. package/dist/autoresearch/__tests__/skill-validation.test.js.map +1 -0
  197. package/dist/autoresearch/contracts.d.ts +31 -0
  198. package/dist/autoresearch/contracts.d.ts.map +1 -0
  199. package/dist/autoresearch/contracts.js +197 -0
  200. package/dist/autoresearch/contracts.js.map +1 -0
  201. package/dist/autoresearch/goal.d.ts +90 -0
  202. package/dist/autoresearch/goal.d.ts.map +1 -0
  203. package/dist/autoresearch/goal.js +237 -0
  204. package/dist/autoresearch/goal.js.map +1 -0
  205. package/dist/autoresearch/runtime.d.ts +132 -0
  206. package/dist/autoresearch/runtime.d.ts.map +1 -0
  207. package/dist/autoresearch/runtime.js +1022 -0
  208. package/dist/autoresearch/runtime.js.map +1 -0
  209. package/dist/autoresearch/skill-validation.d.ts +14 -0
  210. package/dist/autoresearch/skill-validation.d.ts.map +1 -0
  211. package/dist/autoresearch/skill-validation.js +172 -0
  212. package/dist/autoresearch/skill-validation.js.map +1 -0
  213. package/dist/catalog/__tests__/generator.test.d.ts +2 -0
  214. package/dist/catalog/__tests__/generator.test.d.ts.map +1 -0
  215. package/dist/catalog/__tests__/generator.test.js +60 -0
  216. package/dist/catalog/__tests__/generator.test.js.map +1 -0
  217. package/dist/catalog/__tests__/plugin-bundle-ssot.test.d.ts +2 -0
  218. package/dist/catalog/__tests__/plugin-bundle-ssot.test.d.ts.map +1 -0
  219. package/dist/catalog/__tests__/plugin-bundle-ssot.test.js +108 -0
  220. package/dist/catalog/__tests__/plugin-bundle-ssot.test.js.map +1 -0
  221. package/dist/catalog/__tests__/schema.test.d.ts +2 -0
  222. package/dist/catalog/__tests__/schema.test.d.ts.map +1 -0
  223. package/dist/catalog/__tests__/schema.test.js +84 -0
  224. package/dist/catalog/__tests__/schema.test.js.map +1 -0
  225. package/dist/catalog/installable.d.ts +5 -0
  226. package/dist/catalog/installable.d.ts.map +1 -0
  227. package/dist/catalog/installable.js +13 -0
  228. package/dist/catalog/installable.js.map +1 -0
  229. package/dist/catalog/reader.d.ts +19 -0
  230. package/dist/catalog/reader.d.ts.map +1 -0
  231. package/dist/catalog/reader.js +63 -0
  232. package/dist/catalog/reader.js.map +1 -0
  233. package/dist/catalog/schema.d.ts +32 -0
  234. package/dist/catalog/schema.d.ts.map +1 -0
  235. package/dist/catalog/schema.js +107 -0
  236. package/dist/catalog/schema.js.map +1 -0
  237. package/dist/catalog/skill-mirror.d.ts +20 -0
  238. package/dist/catalog/skill-mirror.d.ts.map +1 -0
  239. package/dist/catalog/skill-mirror.js +104 -0
  240. package/dist/catalog/skill-mirror.js.map +1 -0
  241. package/dist/cli/__tests__/adapt-help.test.d.ts +2 -0
  242. package/dist/cli/__tests__/adapt-help.test.d.ts.map +1 -0
  243. package/dist/cli/__tests__/adapt-help.test.js +39 -0
  244. package/dist/cli/__tests__/adapt-help.test.js.map +1 -0
  245. package/dist/cli/__tests__/adapt.test.d.ts +2 -0
  246. package/dist/cli/__tests__/adapt.test.d.ts.map +1 -0
  247. package/dist/cli/__tests__/adapt.test.js +62 -0
  248. package/dist/cli/__tests__/adapt.test.js.map +1 -0
  249. package/dist/cli/__tests__/agents-init.test.d.ts +2 -0
  250. package/dist/cli/__tests__/agents-init.test.d.ts.map +1 -0
  251. package/dist/cli/__tests__/agents-init.test.js +184 -0
  252. package/dist/cli/__tests__/agents-init.test.js.map +1 -0
  253. package/dist/cli/__tests__/agents.test.d.ts +2 -0
  254. package/dist/cli/__tests__/agents.test.d.ts.map +1 -0
  255. package/dist/cli/__tests__/agents.test.js +137 -0
  256. package/dist/cli/__tests__/agents.test.js.map +1 -0
  257. package/dist/cli/__tests__/api.test.d.ts +2 -0
  258. package/dist/cli/__tests__/api.test.d.ts.map +1 -0
  259. package/dist/cli/__tests__/api.test.js +175 -0
  260. package/dist/cli/__tests__/api.test.js.map +1 -0
  261. package/dist/cli/__tests__/ask.test.d.ts +2 -0
  262. package/dist/cli/__tests__/ask.test.d.ts.map +1 -0
  263. package/dist/cli/__tests__/ask.test.js +332 -0
  264. package/dist/cli/__tests__/ask.test.js.map +1 -0
  265. package/dist/cli/__tests__/auth.test.d.ts +2 -0
  266. package/dist/cli/__tests__/auth.test.d.ts.map +1 -0
  267. package/dist/cli/__tests__/auth.test.js +203 -0
  268. package/dist/cli/__tests__/auth.test.js.map +1 -0
  269. package/dist/cli/__tests__/autoresearch-goal.test.d.ts +2 -0
  270. package/dist/cli/__tests__/autoresearch-goal.test.d.ts.map +1 -0
  271. package/dist/cli/__tests__/autoresearch-goal.test.js +207 -0
  272. package/dist/cli/__tests__/autoresearch-goal.test.js.map +1 -0
  273. package/dist/cli/__tests__/autoresearch-guided.test.d.ts +2 -0
  274. package/dist/cli/__tests__/autoresearch-guided.test.d.ts.map +1 -0
  275. package/dist/cli/__tests__/autoresearch-guided.test.js +365 -0
  276. package/dist/cli/__tests__/autoresearch-guided.test.js.map +1 -0
  277. package/dist/cli/__tests__/autoresearch.test.d.ts +2 -0
  278. package/dist/cli/__tests__/autoresearch.test.d.ts.map +1 -0
  279. package/dist/cli/__tests__/autoresearch.test.js +155 -0
  280. package/dist/cli/__tests__/autoresearch.test.js.map +1 -0
  281. package/dist/cli/__tests__/catalog-contract.test.d.ts +2 -0
  282. package/dist/cli/__tests__/catalog-contract.test.d.ts.map +1 -0
  283. package/dist/cli/__tests__/catalog-contract.test.js +18 -0
  284. package/dist/cli/__tests__/catalog-contract.test.js.map +1 -0
  285. package/dist/cli/__tests__/cleanup.test.d.ts +2 -0
  286. package/dist/cli/__tests__/cleanup.test.d.ts.map +1 -0
  287. package/dist/cli/__tests__/cleanup.test.js +527 -0
  288. package/dist/cli/__tests__/cleanup.test.js.map +1 -0
  289. package/dist/cli/__tests__/codex-feature-probe.test.d.ts +2 -0
  290. package/dist/cli/__tests__/codex-feature-probe.test.d.ts.map +1 -0
  291. package/dist/cli/__tests__/codex-feature-probe.test.js +46 -0
  292. package/dist/cli/__tests__/codex-feature-probe.test.js.map +1 -0
  293. package/dist/cli/__tests__/codex-plugin-layout.test.d.ts +2 -0
  294. package/dist/cli/__tests__/codex-plugin-layout.test.d.ts.map +1 -0
  295. package/dist/cli/__tests__/codex-plugin-layout.test.js +778 -0
  296. package/dist/cli/__tests__/codex-plugin-layout.test.js.map +1 -0
  297. package/dist/cli/__tests__/doctor-context-window-warning.test.d.ts +2 -0
  298. package/dist/cli/__tests__/doctor-context-window-warning.test.d.ts.map +1 -0
  299. package/dist/cli/__tests__/doctor-context-window-warning.test.js +122 -0
  300. package/dist/cli/__tests__/doctor-context-window-warning.test.js.map +1 -0
  301. package/dist/cli/__tests__/doctor-invalid-config.test.d.ts +2 -0
  302. package/dist/cli/__tests__/doctor-invalid-config.test.d.ts.map +1 -0
  303. package/dist/cli/__tests__/doctor-invalid-config.test.js +52 -0
  304. package/dist/cli/__tests__/doctor-invalid-config.test.js.map +1 -0
  305. package/dist/cli/__tests__/doctor-spark-routing.test.d.ts +2 -0
  306. package/dist/cli/__tests__/doctor-spark-routing.test.d.ts.map +1 -0
  307. package/dist/cli/__tests__/doctor-spark-routing.test.js +79 -0
  308. package/dist/cli/__tests__/doctor-spark-routing.test.js.map +1 -0
  309. package/dist/cli/__tests__/doctor-team.test.d.ts +2 -0
  310. package/dist/cli/__tests__/doctor-team.test.d.ts.map +1 -0
  311. package/dist/cli/__tests__/doctor-team.test.js +299 -0
  312. package/dist/cli/__tests__/doctor-team.test.js.map +1 -0
  313. package/dist/cli/__tests__/doctor-warning-copy.test.d.ts +2 -0
  314. package/dist/cli/__tests__/doctor-warning-copy.test.d.ts.map +1 -0
  315. package/dist/cli/__tests__/doctor-warning-copy.test.js +1312 -0
  316. package/dist/cli/__tests__/doctor-warning-copy.test.js.map +1 -0
  317. package/dist/cli/__tests__/error-handling-warnings.test.d.ts +2 -0
  318. package/dist/cli/__tests__/error-handling-warnings.test.d.ts.map +1 -0
  319. package/dist/cli/__tests__/error-handling-warnings.test.js +52 -0
  320. package/dist/cli/__tests__/error-handling-warnings.test.js.map +1 -0
  321. package/dist/cli/__tests__/exec.test.d.ts +2 -0
  322. package/dist/cli/__tests__/exec.test.d.ts.map +1 -0
  323. package/dist/cli/__tests__/exec.test.js +213 -0
  324. package/dist/cli/__tests__/exec.test.js.map +1 -0
  325. package/dist/cli/__tests__/explore-windows-diagnostics.test.d.ts +2 -0
  326. package/dist/cli/__tests__/explore-windows-diagnostics.test.d.ts.map +1 -0
  327. package/dist/cli/__tests__/explore-windows-diagnostics.test.js +17 -0
  328. package/dist/cli/__tests__/explore-windows-diagnostics.test.js.map +1 -0
  329. package/dist/cli/__tests__/explore.test.d.ts +2 -0
  330. package/dist/cli/__tests__/explore.test.d.ts.map +1 -0
  331. package/dist/cli/__tests__/explore.test.js +104 -0
  332. package/dist/cli/__tests__/explore.test.js.map +1 -0
  333. package/dist/cli/__tests__/hooks.test.d.ts +2 -0
  334. package/dist/cli/__tests__/hooks.test.d.ts.map +1 -0
  335. package/dist/cli/__tests__/hooks.test.js +55 -0
  336. package/dist/cli/__tests__/hooks.test.js.map +1 -0
  337. package/dist/cli/__tests__/imagegen-continuation.test.d.ts +2 -0
  338. package/dist/cli/__tests__/imagegen-continuation.test.d.ts.map +1 -0
  339. package/dist/cli/__tests__/imagegen-continuation.test.js +135 -0
  340. package/dist/cli/__tests__/imagegen-continuation.test.js.map +1 -0
  341. package/dist/cli/__tests__/index.test.d.ts +2 -0
  342. package/dist/cli/__tests__/index.test.d.ts.map +1 -0
  343. package/dist/cli/__tests__/index.test.js +3619 -0
  344. package/dist/cli/__tests__/index.test.js.map +1 -0
  345. package/dist/cli/__tests__/install-docs-contract.test.d.ts +2 -0
  346. package/dist/cli/__tests__/install-docs-contract.test.d.ts.map +1 -0
  347. package/dist/cli/__tests__/install-docs-contract.test.js +55 -0
  348. package/dist/cli/__tests__/install-docs-contract.test.js.map +1 -0
  349. package/dist/cli/__tests__/launch-fallback.test.d.ts +2 -0
  350. package/dist/cli/__tests__/launch-fallback.test.d.ts.map +1 -0
  351. package/dist/cli/__tests__/launch-fallback.test.js +1285 -0
  352. package/dist/cli/__tests__/launch-fallback.test.js.map +1 -0
  353. package/dist/cli/__tests__/lifecycle-notifications.test.d.ts +2 -0
  354. package/dist/cli/__tests__/lifecycle-notifications.test.d.ts.map +1 -0
  355. package/dist/cli/__tests__/lifecycle-notifications.test.js +48 -0
  356. package/dist/cli/__tests__/lifecycle-notifications.test.js.map +1 -0
  357. package/dist/cli/__tests__/list.test.d.ts +2 -0
  358. package/dist/cli/__tests__/list.test.d.ts.map +1 -0
  359. package/dist/cli/__tests__/list.test.js +38 -0
  360. package/dist/cli/__tests__/list.test.js.map +1 -0
  361. package/dist/cli/__tests__/mcp-parity.test.d.ts +2 -0
  362. package/dist/cli/__tests__/mcp-parity.test.d.ts.map +1 -0
  363. package/dist/cli/__tests__/mcp-parity.test.js +228 -0
  364. package/dist/cli/__tests__/mcp-parity.test.js.map +1 -0
  365. package/dist/cli/__tests__/mcp-serve.test.d.ts +2 -0
  366. package/dist/cli/__tests__/mcp-serve.test.d.ts.map +1 -0
  367. package/dist/cli/__tests__/mcp-serve.test.js +68 -0
  368. package/dist/cli/__tests__/mcp-serve.test.js.map +1 -0
  369. package/dist/cli/__tests__/native-assets.test.d.ts +2 -0
  370. package/dist/cli/__tests__/native-assets.test.d.ts.map +1 -0
  371. package/dist/cli/__tests__/native-assets.test.js +296 -0
  372. package/dist/cli/__tests__/native-assets.test.js.map +1 -0
  373. package/dist/cli/__tests__/native-hook-dispatch-contract.test.d.ts +2 -0
  374. package/dist/cli/__tests__/native-hook-dispatch-contract.test.d.ts.map +1 -0
  375. package/dist/cli/__tests__/native-hook-dispatch-contract.test.js +11 -0
  376. package/dist/cli/__tests__/native-hook-dispatch-contract.test.js.map +1 -0
  377. package/dist/cli/__tests__/nested-help-routing.test.d.ts +2 -0
  378. package/dist/cli/__tests__/nested-help-routing.test.d.ts.map +1 -0
  379. package/dist/cli/__tests__/nested-help-routing.test.js +63 -0
  380. package/dist/cli/__tests__/nested-help-routing.test.js.map +1 -0
  381. package/dist/cli/__tests__/package-bin-contract.test.d.ts +2 -0
  382. package/dist/cli/__tests__/package-bin-contract.test.d.ts.map +1 -0
  383. package/dist/cli/__tests__/package-bin-contract.test.js +190 -0
  384. package/dist/cli/__tests__/package-bin-contract.test.js.map +1 -0
  385. package/dist/cli/__tests__/packaged-explore-harness-lock.d.ts +3 -0
  386. package/dist/cli/__tests__/packaged-explore-harness-lock.d.ts.map +1 -0
  387. package/dist/cli/__tests__/packaged-explore-harness-lock.js +67 -0
  388. package/dist/cli/__tests__/packaged-explore-harness-lock.js.map +1 -0
  389. package/dist/cli/__tests__/packaged-script-resolution.test.d.ts +2 -0
  390. package/dist/cli/__tests__/packaged-script-resolution.test.d.ts.map +1 -0
  391. package/dist/cli/__tests__/packaged-script-resolution.test.js +19 -0
  392. package/dist/cli/__tests__/packaged-script-resolution.test.js.map +1 -0
  393. package/dist/cli/__tests__/performance-goal.test.d.ts +2 -0
  394. package/dist/cli/__tests__/performance-goal.test.d.ts.map +1 -0
  395. package/dist/cli/__tests__/performance-goal.test.js +144 -0
  396. package/dist/cli/__tests__/performance-goal.test.js.map +1 -0
  397. package/dist/cli/__tests__/prompt-skill-sanitization.test.d.ts +2 -0
  398. package/dist/cli/__tests__/prompt-skill-sanitization.test.d.ts.map +1 -0
  399. package/dist/cli/__tests__/prompt-skill-sanitization.test.js +48 -0
  400. package/dist/cli/__tests__/prompt-skill-sanitization.test.js.map +1 -0
  401. package/dist/cli/__tests__/question.test.d.ts +2 -0
  402. package/dist/cli/__tests__/question.test.d.ts.map +1 -0
  403. package/dist/cli/__tests__/question.test.js +850 -0
  404. package/dist/cli/__tests__/question.test.js.map +1 -0
  405. package/dist/cli/__tests__/ralph-deslop-contract.test.d.ts +2 -0
  406. package/dist/cli/__tests__/ralph-deslop-contract.test.d.ts.map +1 -0
  407. package/dist/cli/__tests__/ralph-deslop-contract.test.js +28 -0
  408. package/dist/cli/__tests__/ralph-deslop-contract.test.js.map +1 -0
  409. package/dist/cli/__tests__/ralph-goal-mode-contract.test.d.ts +2 -0
  410. package/dist/cli/__tests__/ralph-goal-mode-contract.test.d.ts.map +1 -0
  411. package/dist/cli/__tests__/ralph-goal-mode-contract.test.js +49 -0
  412. package/dist/cli/__tests__/ralph-goal-mode-contract.test.js.map +1 -0
  413. package/dist/cli/__tests__/ralph-prd-deep-interview.test.d.ts +2 -0
  414. package/dist/cli/__tests__/ralph-prd-deep-interview.test.d.ts.map +1 -0
  415. package/dist/cli/__tests__/ralph-prd-deep-interview.test.js +25 -0
  416. package/dist/cli/__tests__/ralph-prd-deep-interview.test.js.map +1 -0
  417. package/dist/cli/__tests__/ralph-prd-smoke.test.d.ts +2 -0
  418. package/dist/cli/__tests__/ralph-prd-smoke.test.d.ts.map +1 -0
  419. package/dist/cli/__tests__/ralph-prd-smoke.test.js +174 -0
  420. package/dist/cli/__tests__/ralph-prd-smoke.test.js.map +1 -0
  421. package/dist/cli/__tests__/ralph.test.d.ts +2 -0
  422. package/dist/cli/__tests__/ralph.test.d.ts.map +1 -0
  423. package/dist/cli/__tests__/ralph.test.js +256 -0
  424. package/dist/cli/__tests__/ralph.test.js.map +1 -0
  425. package/dist/cli/__tests__/resume.test.d.ts +2 -0
  426. package/dist/cli/__tests__/resume.test.d.ts.map +1 -0
  427. package/dist/cli/__tests__/resume.test.js +133 -0
  428. package/dist/cli/__tests__/resume.test.js.map +1 -0
  429. package/dist/cli/__tests__/session-scoped-runtime.test.d.ts +2 -0
  430. package/dist/cli/__tests__/session-scoped-runtime.test.d.ts.map +1 -0
  431. package/dist/cli/__tests__/session-scoped-runtime.test.js +247 -0
  432. package/dist/cli/__tests__/session-scoped-runtime.test.js.map +1 -0
  433. package/dist/cli/__tests__/session-search-help.test.d.ts +2 -0
  434. package/dist/cli/__tests__/session-search-help.test.d.ts.map +1 -0
  435. package/dist/cli/__tests__/session-search-help.test.js +37 -0
  436. package/dist/cli/__tests__/session-search-help.test.js.map +1 -0
  437. package/dist/cli/__tests__/session-search.test.d.ts +2 -0
  438. package/dist/cli/__tests__/session-search.test.d.ts.map +1 -0
  439. package/dist/cli/__tests__/session-search.test.js +77 -0
  440. package/dist/cli/__tests__/session-search.test.js.map +1 -0
  441. package/dist/cli/__tests__/setup-agents-overwrite.test.d.ts +2 -0
  442. package/dist/cli/__tests__/setup-agents-overwrite.test.d.ts.map +1 -0
  443. package/dist/cli/__tests__/setup-agents-overwrite.test.js +776 -0
  444. package/dist/cli/__tests__/setup-agents-overwrite.test.js.map +1 -0
  445. package/dist/cli/__tests__/setup-gh-star.test.d.ts +2 -0
  446. package/dist/cli/__tests__/setup-gh-star.test.d.ts.map +1 -0
  447. package/dist/cli/__tests__/setup-gh-star.test.js +67 -0
  448. package/dist/cli/__tests__/setup-gh-star.test.js.map +1 -0
  449. package/dist/cli/__tests__/setup-hooks-shared-ownership.test.d.ts +2 -0
  450. package/dist/cli/__tests__/setup-hooks-shared-ownership.test.d.ts.map +1 -0
  451. package/dist/cli/__tests__/setup-hooks-shared-ownership.test.js +202 -0
  452. package/dist/cli/__tests__/setup-hooks-shared-ownership.test.js.map +1 -0
  453. package/dist/cli/__tests__/setup-install-mode.test.d.ts +2 -0
  454. package/dist/cli/__tests__/setup-install-mode.test.d.ts.map +1 -0
  455. package/dist/cli/__tests__/setup-install-mode.test.js +2103 -0
  456. package/dist/cli/__tests__/setup-install-mode.test.js.map +1 -0
  457. package/dist/cli/__tests__/setup-prompts-overwrite.test.d.ts +2 -0
  458. package/dist/cli/__tests__/setup-prompts-overwrite.test.d.ts.map +1 -0
  459. package/dist/cli/__tests__/setup-prompts-overwrite.test.js +191 -0
  460. package/dist/cli/__tests__/setup-prompts-overwrite.test.js.map +1 -0
  461. package/dist/cli/__tests__/setup-refresh.test.d.ts +2 -0
  462. package/dist/cli/__tests__/setup-refresh.test.d.ts.map +1 -0
  463. package/dist/cli/__tests__/setup-refresh.test.js +779 -0
  464. package/dist/cli/__tests__/setup-refresh.test.js.map +1 -0
  465. package/dist/cli/__tests__/setup-scope.test.d.ts +2 -0
  466. package/dist/cli/__tests__/setup-scope.test.d.ts.map +1 -0
  467. package/dist/cli/__tests__/setup-scope.test.js +367 -0
  468. package/dist/cli/__tests__/setup-scope.test.js.map +1 -0
  469. package/dist/cli/__tests__/setup-skill-validation.test.d.ts +2 -0
  470. package/dist/cli/__tests__/setup-skill-validation.test.d.ts.map +1 -0
  471. package/dist/cli/__tests__/setup-skill-validation.test.js +44 -0
  472. package/dist/cli/__tests__/setup-skill-validation.test.js.map +1 -0
  473. package/dist/cli/__tests__/setup-skills-overwrite.test.d.ts +2 -0
  474. package/dist/cli/__tests__/setup-skills-overwrite.test.d.ts.map +1 -0
  475. package/dist/cli/__tests__/setup-skills-overwrite.test.js +292 -0
  476. package/dist/cli/__tests__/setup-skills-overwrite.test.js.map +1 -0
  477. package/dist/cli/__tests__/sidecar.test.d.ts +2 -0
  478. package/dist/cli/__tests__/sidecar.test.d.ts.map +1 -0
  479. package/dist/cli/__tests__/sidecar.test.js +24 -0
  480. package/dist/cli/__tests__/sidecar.test.js.map +1 -0
  481. package/dist/cli/__tests__/sparkshell-cli.test.d.ts +2 -0
  482. package/dist/cli/__tests__/sparkshell-cli.test.d.ts.map +1 -0
  483. package/dist/cli/__tests__/sparkshell-cli.test.js +471 -0
  484. package/dist/cli/__tests__/sparkshell-cli.test.js.map +1 -0
  485. package/dist/cli/__tests__/sparkshell-packaging.test.d.ts +2 -0
  486. package/dist/cli/__tests__/sparkshell-packaging.test.d.ts.map +1 -0
  487. package/dist/cli/__tests__/sparkshell-packaging.test.js +105 -0
  488. package/dist/cli/__tests__/sparkshell-packaging.test.js.map +1 -0
  489. package/dist/cli/__tests__/star-prompt.test.d.ts +2 -0
  490. package/dist/cli/__tests__/star-prompt.test.d.ts.map +1 -0
  491. package/dist/cli/__tests__/star-prompt.test.js +172 -0
  492. package/dist/cli/__tests__/star-prompt.test.js.map +1 -0
  493. package/dist/cli/__tests__/state.test.d.ts +2 -0
  494. package/dist/cli/__tests__/state.test.d.ts.map +1 -0
  495. package/dist/cli/__tests__/state.test.js +160 -0
  496. package/dist/cli/__tests__/state.test.js.map +1 -0
  497. package/dist/cli/__tests__/team-decompose.test.d.ts +2 -0
  498. package/dist/cli/__tests__/team-decompose.test.d.ts.map +1 -0
  499. package/dist/cli/__tests__/team-decompose.test.js +138 -0
  500. package/dist/cli/__tests__/team-decompose.test.js.map +1 -0
  501. package/dist/cli/__tests__/team.test.d.ts +2 -0
  502. package/dist/cli/__tests__/team.test.d.ts.map +1 -0
  503. package/dist/cli/__tests__/team.test.js +2897 -0
  504. package/dist/cli/__tests__/team.test.js.map +1 -0
  505. package/dist/cli/__tests__/ultragoal.test.d.ts +2 -0
  506. package/dist/cli/__tests__/ultragoal.test.d.ts.map +1 -0
  507. package/dist/cli/__tests__/ultragoal.test.js +599 -0
  508. package/dist/cli/__tests__/ultragoal.test.js.map +1 -0
  509. package/dist/cli/__tests__/uninstall.test.d.ts +2 -0
  510. package/dist/cli/__tests__/uninstall.test.d.ts.map +1 -0
  511. package/dist/cli/__tests__/uninstall.test.js +865 -0
  512. package/dist/cli/__tests__/uninstall.test.js.map +1 -0
  513. package/dist/cli/__tests__/update.test.d.ts +2 -0
  514. package/dist/cli/__tests__/update.test.d.ts.map +1 -0
  515. package/dist/cli/__tests__/update.test.js +1182 -0
  516. package/dist/cli/__tests__/update.test.js.map +1 -0
  517. package/dist/cli/__tests__/version-sync-contract.test.d.ts +2 -0
  518. package/dist/cli/__tests__/version-sync-contract.test.d.ts.map +1 -0
  519. package/dist/cli/__tests__/version-sync-contract.test.js +47 -0
  520. package/dist/cli/__tests__/version-sync-contract.test.js.map +1 -0
  521. package/dist/cli/__tests__/version.test.d.ts +2 -0
  522. package/dist/cli/__tests__/version.test.d.ts.map +1 -0
  523. package/dist/cli/__tests__/version.test.js +21 -0
  524. package/dist/cli/__tests__/version.test.js.map +1 -0
  525. package/dist/cli/__tests__/windows-popup-loop-contract.test.d.ts +2 -0
  526. package/dist/cli/__tests__/windows-popup-loop-contract.test.d.ts.map +1 -0
  527. package/dist/cli/__tests__/windows-popup-loop-contract.test.js +31 -0
  528. package/dist/cli/__tests__/windows-popup-loop-contract.test.js.map +1 -0
  529. package/dist/cli/adapt.d.ts +6 -0
  530. package/dist/cli/adapt.d.ts.map +1 -0
  531. package/dist/cli/adapt.js +135 -0
  532. package/dist/cli/adapt.js.map +1 -0
  533. package/dist/cli/agents-init.d.ts +14 -0
  534. package/dist/cli/agents-init.d.ts.map +1 -0
  535. package/dist/cli/agents-init.js +274 -0
  536. package/dist/cli/agents-init.js.map +1 -0
  537. package/dist/cli/agents.d.ts +14 -0
  538. package/dist/cli/agents.d.ts.map +1 -0
  539. package/dist/cli/agents.js +267 -0
  540. package/dist/cli/agents.js.map +1 -0
  541. package/dist/cli/api.d.ts +26 -0
  542. package/dist/cli/api.d.ts.map +1 -0
  543. package/dist/cli/api.js +153 -0
  544. package/dist/cli/api.js.map +1 -0
  545. package/dist/cli/ask.d.ts +13 -0
  546. package/dist/cli/ask.d.ts.map +1 -0
  547. package/dist/cli/ask.js +178 -0
  548. package/dist/cli/ask.js.map +1 -0
  549. package/dist/cli/auth.d.ts +4 -0
  550. package/dist/cli/auth.d.ts.map +1 -0
  551. package/dist/cli/auth.js +113 -0
  552. package/dist/cli/auth.js.map +1 -0
  553. package/dist/cli/autoresearch-goal.d.ts +3 -0
  554. package/dist/cli/autoresearch-goal.d.ts.map +1 -0
  555. package/dist/cli/autoresearch-goal.js +175 -0
  556. package/dist/cli/autoresearch-goal.js.map +1 -0
  557. package/dist/cli/autoresearch-guided.d.ts +43 -0
  558. package/dist/cli/autoresearch-guided.d.ts.map +1 -0
  559. package/dist/cli/autoresearch-guided.js +282 -0
  560. package/dist/cli/autoresearch-guided.js.map +1 -0
  561. package/dist/cli/autoresearch-intake.d.ts +62 -0
  562. package/dist/cli/autoresearch-intake.d.ts.map +1 -0
  563. package/dist/cli/autoresearch-intake.js +336 -0
  564. package/dist/cli/autoresearch-intake.js.map +1 -0
  565. package/dist/cli/autoresearch.d.ts +16 -0
  566. package/dist/cli/autoresearch.d.ts.map +1 -0
  567. package/dist/cli/autoresearch.js +91 -0
  568. package/dist/cli/autoresearch.js.map +1 -0
  569. package/dist/cli/catalog-contract.d.ts +10 -0
  570. package/dist/cli/catalog-contract.d.ts.map +1 -0
  571. package/dist/cli/catalog-contract.js +34 -0
  572. package/dist/cli/catalog-contract.js.map +1 -0
  573. package/dist/cli/cleanup.d.ts +58 -0
  574. package/dist/cli/cleanup.d.ts.map +1 -0
  575. package/dist/cli/cleanup.js +444 -0
  576. package/dist/cli/cleanup.js.map +1 -0
  577. package/dist/cli/codex-feature-probe.d.ts +17 -0
  578. package/dist/cli/codex-feature-probe.d.ts.map +1 -0
  579. package/dist/cli/codex-feature-probe.js +50 -0
  580. package/dist/cli/codex-feature-probe.js.map +1 -0
  581. package/dist/cli/codex-home.d.ts +7 -0
  582. package/dist/cli/codex-home.d.ts.map +1 -0
  583. package/dist/cli/codex-home.js +26 -0
  584. package/dist/cli/codex-home.js.map +1 -0
  585. package/dist/cli/constants.d.ts +11 -0
  586. package/dist/cli/constants.d.ts.map +1 -0
  587. package/dist/cli/constants.js +11 -0
  588. package/dist/cli/constants.js.map +1 -0
  589. package/dist/cli/doctor.d.ts +43 -0
  590. package/dist/cli/doctor.d.ts.map +1 -0
  591. package/dist/cli/doctor.js +1956 -0
  592. package/dist/cli/doctor.js.map +1 -0
  593. package/dist/cli/explore.d.ts +14 -0
  594. package/dist/cli/explore.d.ts.map +1 -0
  595. package/dist/cli/explore.js +72 -0
  596. package/dist/cli/explore.js.map +1 -0
  597. package/dist/cli/hooks.d.ts +4 -0
  598. package/dist/cli/hooks.d.ts.map +1 -0
  599. package/dist/cli/hooks.js +201 -0
  600. package/dist/cli/hooks.js.map +1 -0
  601. package/dist/cli/index.d.ts +247 -0
  602. package/dist/cli/index.d.ts.map +1 -0
  603. package/dist/cli/index.js +4590 -0
  604. package/dist/cli/index.js.map +1 -0
  605. package/dist/cli/list.d.ts +2 -0
  606. package/dist/cli/list.d.ts.map +1 -0
  607. package/dist/cli/list.js +40 -0
  608. package/dist/cli/list.js.map +1 -0
  609. package/dist/cli/mcp-parity.d.ts +22 -0
  610. package/dist/cli/mcp-parity.d.ts.map +1 -0
  611. package/dist/cli/mcp-parity.js +251 -0
  612. package/dist/cli/mcp-parity.js.map +1 -0
  613. package/dist/cli/mcp-serve.d.ts +13 -0
  614. package/dist/cli/mcp-serve.d.ts.map +1 -0
  615. package/dist/cli/mcp-serve.js +75 -0
  616. package/dist/cli/mcp-serve.js.map +1 -0
  617. package/dist/cli/native-assets.d.ts +52 -0
  618. package/dist/cli/native-assets.d.ts.map +1 -0
  619. package/dist/cli/native-assets.js +302 -0
  620. package/dist/cli/native-assets.js.map +1 -0
  621. package/dist/cli/omx.d.ts +3 -0
  622. package/dist/cli/omx.d.ts.map +1 -0
  623. package/dist/cli/omx.js +25 -0
  624. package/dist/cli/omx.js.map +1 -0
  625. package/dist/cli/performance-goal.d.ts +3 -0
  626. package/dist/cli/performance-goal.d.ts.map +1 -0
  627. package/dist/cli/performance-goal.js +186 -0
  628. package/dist/cli/performance-goal.js.map +1 -0
  629. package/dist/cli/plugin-marketplace.d.ts +54 -0
  630. package/dist/cli/plugin-marketplace.d.ts.map +1 -0
  631. package/dist/cli/plugin-marketplace.js +369 -0
  632. package/dist/cli/plugin-marketplace.js.map +1 -0
  633. package/dist/cli/question.d.ts +3 -0
  634. package/dist/cli/question.d.ts.map +1 -0
  635. package/dist/cli/question.js +376 -0
  636. package/dist/cli/question.js.map +1 -0
  637. package/dist/cli/ralph.d.ts +17 -0
  638. package/dist/cli/ralph.d.ts.map +1 -0
  639. package/dist/cli/ralph.js +330 -0
  640. package/dist/cli/ralph.js.map +1 -0
  641. package/dist/cli/session-search.d.ts +8 -0
  642. package/dist/cli/session-search.d.ts.map +1 -0
  643. package/dist/cli/session-search.js +133 -0
  644. package/dist/cli/session-search.js.map +1 -0
  645. package/dist/cli/setup-preferences.d.ts +26 -0
  646. package/dist/cli/setup-preferences.d.ts.map +1 -0
  647. package/dist/cli/setup-preferences.js +82 -0
  648. package/dist/cli/setup-preferences.js.map +1 -0
  649. package/dist/cli/setup.d.ts +60 -0
  650. package/dist/cli/setup.d.ts.map +1 -0
  651. package/dist/cli/setup.js +2748 -0
  652. package/dist/cli/setup.js.map +1 -0
  653. package/dist/cli/sparkshell.d.ts +39 -0
  654. package/dist/cli/sparkshell.d.ts.map +1 -0
  655. package/dist/cli/sparkshell.js +299 -0
  656. package/dist/cli/sparkshell.js.map +1 -0
  657. package/dist/cli/star-prompt.d.ts +31 -0
  658. package/dist/cli/star-prompt.d.ts.map +1 -0
  659. package/dist/cli/star-prompt.js +97 -0
  660. package/dist/cli/star-prompt.js.map +1 -0
  661. package/dist/cli/state.d.ts +8 -0
  662. package/dist/cli/state.d.ts.map +1 -0
  663. package/dist/cli/state.js +149 -0
  664. package/dist/cli/state.js.map +1 -0
  665. package/dist/cli/team.d.ts +49 -0
  666. package/dist/cli/team.d.ts.map +1 -0
  667. package/dist/cli/team.js +1453 -0
  668. package/dist/cli/team.js.map +1 -0
  669. package/dist/cli/tmux-hook.d.ts +3 -0
  670. package/dist/cli/tmux-hook.d.ts.map +1 -0
  671. package/dist/cli/tmux-hook.js +403 -0
  672. package/dist/cli/tmux-hook.js.map +1 -0
  673. package/dist/cli/ultragoal.d.ts +3 -0
  674. package/dist/cli/ultragoal.d.ts.map +1 -0
  675. package/dist/cli/ultragoal.js +494 -0
  676. package/dist/cli/ultragoal.js.map +1 -0
  677. package/dist/cli/uninstall.d.ts +15 -0
  678. package/dist/cli/uninstall.d.ts.map +1 -0
  679. package/dist/cli/uninstall.js +476 -0
  680. package/dist/cli/uninstall.js.map +1 -0
  681. package/dist/cli/update.d.ts +86 -0
  682. package/dist/cli/update.d.ts.map +1 -0
  683. package/dist/cli/update.js +754 -0
  684. package/dist/cli/update.js.map +1 -0
  685. package/dist/cli/version.d.ts +2 -0
  686. package/dist/cli/version.d.ts.map +1 -0
  687. package/dist/cli/version.js +13 -0
  688. package/dist/cli/version.js.map +1 -0
  689. package/dist/compat/__tests__/doctor-contract.test.d.ts +2 -0
  690. package/dist/compat/__tests__/doctor-contract.test.d.ts.map +1 -0
  691. package/dist/compat/__tests__/doctor-contract.test.js +122 -0
  692. package/dist/compat/__tests__/doctor-contract.test.js.map +1 -0
  693. package/dist/compat/__tests__/rust-runtime-compat.test.d.ts +2 -0
  694. package/dist/compat/__tests__/rust-runtime-compat.test.d.ts.map +1 -0
  695. package/dist/compat/__tests__/rust-runtime-compat.test.js +218 -0
  696. package/dist/compat/__tests__/rust-runtime-compat.test.js.map +1 -0
  697. package/dist/config/__tests__/codex-feature-flags.test.d.ts +2 -0
  698. package/dist/config/__tests__/codex-feature-flags.test.d.ts.map +1 -0
  699. package/dist/config/__tests__/codex-feature-flags.test.js +45 -0
  700. package/dist/config/__tests__/codex-feature-flags.test.js.map +1 -0
  701. package/dist/config/__tests__/codex-hooks.test.d.ts +2 -0
  702. package/dist/config/__tests__/codex-hooks.test.d.ts.map +1 -0
  703. package/dist/config/__tests__/codex-hooks.test.js +524 -0
  704. package/dist/config/__tests__/codex-hooks.test.js.map +1 -0
  705. package/dist/config/__tests__/commit-lore-guard.test.d.ts +2 -0
  706. package/dist/config/__tests__/commit-lore-guard.test.d.ts.map +1 -0
  707. package/dist/config/__tests__/commit-lore-guard.test.js +20 -0
  708. package/dist/config/__tests__/commit-lore-guard.test.js.map +1 -0
  709. package/dist/config/__tests__/deep-interview.test.d.ts +2 -0
  710. package/dist/config/__tests__/deep-interview.test.d.ts.map +1 -0
  711. package/dist/config/__tests__/deep-interview.test.js +240 -0
  712. package/dist/config/__tests__/deep-interview.test.js.map +1 -0
  713. package/dist/config/__tests__/generator-idempotent.test.d.ts +2 -0
  714. package/dist/config/__tests__/generator-idempotent.test.d.ts.map +1 -0
  715. package/dist/config/__tests__/generator-idempotent.test.js +1150 -0
  716. package/dist/config/__tests__/generator-idempotent.test.js.map +1 -0
  717. package/dist/config/__tests__/generator-notify.test.d.ts +2 -0
  718. package/dist/config/__tests__/generator-notify.test.d.ts.map +1 -0
  719. package/dist/config/__tests__/generator-notify.test.js +512 -0
  720. package/dist/config/__tests__/generator-notify.test.js.map +1 -0
  721. package/dist/config/__tests__/generator-status-line-presets.test.d.ts +2 -0
  722. package/dist/config/__tests__/generator-status-line-presets.test.d.ts.map +1 -0
  723. package/dist/config/__tests__/generator-status-line-presets.test.js +203 -0
  724. package/dist/config/__tests__/generator-status-line-presets.test.js.map +1 -0
  725. package/dist/config/__tests__/mcp-registry.test.d.ts +2 -0
  726. package/dist/config/__tests__/mcp-registry.test.d.ts.map +1 -0
  727. package/dist/config/__tests__/mcp-registry.test.js +190 -0
  728. package/dist/config/__tests__/mcp-registry.test.js.map +1 -0
  729. package/dist/config/__tests__/models.test.d.ts +2 -0
  730. package/dist/config/__tests__/models.test.d.ts.map +1 -0
  731. package/dist/config/__tests__/models.test.js +241 -0
  732. package/dist/config/__tests__/models.test.js.map +1 -0
  733. package/dist/config/__tests__/wiki-config-contract.test.d.ts +2 -0
  734. package/dist/config/__tests__/wiki-config-contract.test.d.ts.map +1 -0
  735. package/dist/config/__tests__/wiki-config-contract.test.js +23 -0
  736. package/dist/config/__tests__/wiki-config-contract.test.js.map +1 -0
  737. package/dist/config/codex-feature-flags.d.ts +25 -0
  738. package/dist/config/codex-feature-flags.d.ts.map +1 -0
  739. package/dist/config/codex-feature-flags.js +60 -0
  740. package/dist/config/codex-feature-flags.js.map +1 -0
  741. package/dist/config/codex-hooks.d.ts +79 -0
  742. package/dist/config/codex-hooks.d.ts.map +1 -0
  743. package/dist/config/codex-hooks.js +578 -0
  744. package/dist/config/codex-hooks.js.map +1 -0
  745. package/dist/config/commit-lore-guard.d.ts +4 -0
  746. package/dist/config/commit-lore-guard.d.ts.map +1 -0
  747. package/dist/config/commit-lore-guard.js +35 -0
  748. package/dist/config/commit-lore-guard.js.map +1 -0
  749. package/dist/config/deep-interview.d.ts +22 -0
  750. package/dist/config/deep-interview.d.ts.map +1 -0
  751. package/dist/config/deep-interview.js +161 -0
  752. package/dist/config/deep-interview.js.map +1 -0
  753. package/dist/config/generator.d.ts +141 -0
  754. package/dist/config/generator.d.ts.map +1 -0
  755. package/dist/config/generator.js +1845 -0
  756. package/dist/config/generator.js.map +1 -0
  757. package/dist/config/mcp-registry.d.ts +35 -0
  758. package/dist/config/mcp-registry.d.ts.map +1 -0
  759. package/dist/config/mcp-registry.js +159 -0
  760. package/dist/config/mcp-registry.js.map +1 -0
  761. package/dist/config/models.d.ts +80 -0
  762. package/dist/config/models.d.ts.map +1 -0
  763. package/dist/config/models.js +251 -0
  764. package/dist/config/models.js.map +1 -0
  765. package/dist/config/omx-first-party-mcp.d.ts +21 -0
  766. package/dist/config/omx-first-party-mcp.d.ts.map +1 -0
  767. package/dist/config/omx-first-party-mcp.js +86 -0
  768. package/dist/config/omx-first-party-mcp.js.map +1 -0
  769. package/dist/config/team-mode.d.ts +12 -0
  770. package/dist/config/team-mode.d.ts.map +1 -0
  771. package/dist/config/team-mode.js +91 -0
  772. package/dist/config/team-mode.js.map +1 -0
  773. package/dist/document-refresh/__tests__/enforcer.test.d.ts +2 -0
  774. package/dist/document-refresh/__tests__/enforcer.test.d.ts.map +1 -0
  775. package/dist/document-refresh/__tests__/enforcer.test.js +128 -0
  776. package/dist/document-refresh/__tests__/enforcer.test.js.map +1 -0
  777. package/dist/document-refresh/config.d.ts +9 -0
  778. package/dist/document-refresh/config.d.ts.map +1 -0
  779. package/dist/document-refresh/config.js +70 -0
  780. package/dist/document-refresh/config.js.map +1 -0
  781. package/dist/document-refresh/enforcer.d.ts +43 -0
  782. package/dist/document-refresh/enforcer.d.ts.map +1 -0
  783. package/dist/document-refresh/enforcer.js +329 -0
  784. package/dist/document-refresh/enforcer.js.map +1 -0
  785. package/dist/exec/followup.d.ts +45 -0
  786. package/dist/exec/followup.d.ts.map +1 -0
  787. package/dist/exec/followup.js +355 -0
  788. package/dist/exec/followup.js.map +1 -0
  789. package/dist/goal-workflows/__tests__/artifacts.test.d.ts +2 -0
  790. package/dist/goal-workflows/__tests__/artifacts.test.d.ts.map +1 -0
  791. package/dist/goal-workflows/__tests__/artifacts.test.js +96 -0
  792. package/dist/goal-workflows/__tests__/artifacts.test.js.map +1 -0
  793. package/dist/goal-workflows/__tests__/codex-goal-snapshot.test.d.ts +2 -0
  794. package/dist/goal-workflows/__tests__/codex-goal-snapshot.test.d.ts.map +1 -0
  795. package/dist/goal-workflows/__tests__/codex-goal-snapshot.test.js +75 -0
  796. package/dist/goal-workflows/__tests__/codex-goal-snapshot.test.js.map +1 -0
  797. package/dist/goal-workflows/artifacts.d.ts +62 -0
  798. package/dist/goal-workflows/artifacts.d.ts.map +1 -0
  799. package/dist/goal-workflows/artifacts.js +132 -0
  800. package/dist/goal-workflows/artifacts.js.map +1 -0
  801. package/dist/goal-workflows/codex-goal-snapshot.d.ts +32 -0
  802. package/dist/goal-workflows/codex-goal-snapshot.d.ts.map +1 -0
  803. package/dist/goal-workflows/codex-goal-snapshot.js +157 -0
  804. package/dist/goal-workflows/codex-goal-snapshot.js.map +1 -0
  805. package/dist/goal-workflows/handoff.d.ts +10 -0
  806. package/dist/goal-workflows/handoff.d.ts.map +1 -0
  807. package/dist/goal-workflows/handoff.js +31 -0
  808. package/dist/goal-workflows/handoff.js.map +1 -0
  809. package/dist/goal-workflows/validation.d.ts +13 -0
  810. package/dist/goal-workflows/validation.d.ts.map +1 -0
  811. package/dist/goal-workflows/validation.js +36 -0
  812. package/dist/goal-workflows/validation.js.map +1 -0
  813. package/dist/hooks/__tests__/agents-overlay.test.d.ts +8 -0
  814. package/dist/hooks/__tests__/agents-overlay.test.d.ts.map +1 -0
  815. package/dist/hooks/__tests__/agents-overlay.test.js +761 -0
  816. package/dist/hooks/__tests__/agents-overlay.test.js.map +1 -0
  817. package/dist/hooks/__tests__/analyze-routing-contract.test.d.ts +2 -0
  818. package/dist/hooks/__tests__/analyze-routing-contract.test.d.ts.map +1 -0
  819. package/dist/hooks/__tests__/analyze-routing-contract.test.js +45 -0
  820. package/dist/hooks/__tests__/analyze-routing-contract.test.js.map +1 -0
  821. package/dist/hooks/__tests__/analyze-skill-contract.test.d.ts +2 -0
  822. package/dist/hooks/__tests__/analyze-skill-contract.test.d.ts.map +1 -0
  823. package/dist/hooks/__tests__/analyze-skill-contract.test.js +48 -0
  824. package/dist/hooks/__tests__/analyze-skill-contract.test.js.map +1 -0
  825. package/dist/hooks/__tests__/anti-slop-workflow.test.d.ts +2 -0
  826. package/dist/hooks/__tests__/anti-slop-workflow.test.d.ts.map +1 -0
  827. package/dist/hooks/__tests__/anti-slop-workflow.test.js +165 -0
  828. package/dist/hooks/__tests__/anti-slop-workflow.test.js.map +1 -0
  829. package/dist/hooks/__tests__/autopilot-skill-contract.test.d.ts +2 -0
  830. package/dist/hooks/__tests__/autopilot-skill-contract.test.d.ts.map +1 -0
  831. package/dist/hooks/__tests__/autopilot-skill-contract.test.js +90 -0
  832. package/dist/hooks/__tests__/autopilot-skill-contract.test.js.map +1 -0
  833. package/dist/hooks/__tests__/best-practice-research-skill.test.d.ts +2 -0
  834. package/dist/hooks/__tests__/best-practice-research-skill.test.d.ts.map +1 -0
  835. package/dist/hooks/__tests__/best-practice-research-skill.test.js +39 -0
  836. package/dist/hooks/__tests__/best-practice-research-skill.test.js.map +1 -0
  837. package/dist/hooks/__tests__/clawhip-event-contract.test.d.ts +2 -0
  838. package/dist/hooks/__tests__/clawhip-event-contract.test.d.ts.map +1 -0
  839. package/dist/hooks/__tests__/clawhip-event-contract.test.js +37 -0
  840. package/dist/hooks/__tests__/clawhip-event-contract.test.js.map +1 -0
  841. package/dist/hooks/__tests__/code-review-skill-contract.test.d.ts +2 -0
  842. package/dist/hooks/__tests__/code-review-skill-contract.test.d.ts.map +1 -0
  843. package/dist/hooks/__tests__/code-review-skill-contract.test.js +77 -0
  844. package/dist/hooks/__tests__/code-review-skill-contract.test.js.map +1 -0
  845. package/dist/hooks/__tests__/codebase-map.test.d.ts +8 -0
  846. package/dist/hooks/__tests__/codebase-map.test.d.ts.map +1 -0
  847. package/dist/hooks/__tests__/codebase-map.test.js +218 -0
  848. package/dist/hooks/__tests__/codebase-map.test.js.map +1 -0
  849. package/dist/hooks/__tests__/consensus-execution-handoff.test.d.ts +18 -0
  850. package/dist/hooks/__tests__/consensus-execution-handoff.test.d.ts.map +1 -0
  851. package/dist/hooks/__tests__/consensus-execution-handoff.test.js +266 -0
  852. package/dist/hooks/__tests__/consensus-execution-handoff.test.js.map +1 -0
  853. package/dist/hooks/__tests__/debugger-log-recency-contract.test.d.ts +2 -0
  854. package/dist/hooks/__tests__/debugger-log-recency-contract.test.d.ts.map +1 -0
  855. package/dist/hooks/__tests__/debugger-log-recency-contract.test.js +20 -0
  856. package/dist/hooks/__tests__/debugger-log-recency-contract.test.js.map +1 -0
  857. package/dist/hooks/__tests__/deep-interview-contract.test.d.ts +2 -0
  858. package/dist/hooks/__tests__/deep-interview-contract.test.d.ts.map +1 -0
  859. package/dist/hooks/__tests__/deep-interview-contract.test.js +309 -0
  860. package/dist/hooks/__tests__/deep-interview-contract.test.js.map +1 -0
  861. package/dist/hooks/__tests__/design-skill.test.d.ts +2 -0
  862. package/dist/hooks/__tests__/design-skill.test.d.ts.map +1 -0
  863. package/dist/hooks/__tests__/design-skill.test.js +55 -0
  864. package/dist/hooks/__tests__/design-skill.test.js.map +1 -0
  865. package/dist/hooks/__tests__/explicit-terminal-stop-docs-contract.test.d.ts +2 -0
  866. package/dist/hooks/__tests__/explicit-terminal-stop-docs-contract.test.d.ts.map +1 -0
  867. package/dist/hooks/__tests__/explicit-terminal-stop-docs-contract.test.js +43 -0
  868. package/dist/hooks/__tests__/explicit-terminal-stop-docs-contract.test.js.map +1 -0
  869. package/dist/hooks/__tests__/explicit-terminal-stop-model-docs-contract.test.d.ts +2 -0
  870. package/dist/hooks/__tests__/explicit-terminal-stop-model-docs-contract.test.d.ts.map +1 -0
  871. package/dist/hooks/__tests__/explicit-terminal-stop-model-docs-contract.test.js +38 -0
  872. package/dist/hooks/__tests__/explicit-terminal-stop-model-docs-contract.test.js.map +1 -0
  873. package/dist/hooks/__tests__/explore-routing.test.d.ts +2 -0
  874. package/dist/hooks/__tests__/explore-routing.test.d.ts.map +1 -0
  875. package/dist/hooks/__tests__/explore-routing.test.js +38 -0
  876. package/dist/hooks/__tests__/explore-routing.test.js.map +1 -0
  877. package/dist/hooks/__tests__/explore-sparkshell-guidance-contract.test.d.ts +2 -0
  878. package/dist/hooks/__tests__/explore-sparkshell-guidance-contract.test.d.ts.map +1 -0
  879. package/dist/hooks/__tests__/explore-sparkshell-guidance-contract.test.js +67 -0
  880. package/dist/hooks/__tests__/explore-sparkshell-guidance-contract.test.js.map +1 -0
  881. package/dist/hooks/__tests__/foreground-isolation-contract.test.d.ts +2 -0
  882. package/dist/hooks/__tests__/foreground-isolation-contract.test.d.ts.map +1 -0
  883. package/dist/hooks/__tests__/foreground-isolation-contract.test.js +28 -0
  884. package/dist/hooks/__tests__/foreground-isolation-contract.test.js.map +1 -0
  885. package/dist/hooks/__tests__/keyword-detector.test.d.ts +2 -0
  886. package/dist/hooks/__tests__/keyword-detector.test.d.ts.map +1 -0
  887. package/dist/hooks/__tests__/keyword-detector.test.js +3323 -0
  888. package/dist/hooks/__tests__/keyword-detector.test.js.map +1 -0
  889. package/dist/hooks/__tests__/notify-fallback-watcher.test.d.ts +2 -0
  890. package/dist/hooks/__tests__/notify-fallback-watcher.test.d.ts.map +1 -0
  891. package/dist/hooks/__tests__/notify-fallback-watcher.test.js +3956 -0
  892. package/dist/hooks/__tests__/notify-fallback-watcher.test.js.map +1 -0
  893. package/dist/hooks/__tests__/notify-hook-all-workers-idle.test.d.ts +2 -0
  894. package/dist/hooks/__tests__/notify-hook-all-workers-idle.test.d.ts.map +1 -0
  895. package/dist/hooks/__tests__/notify-hook-all-workers-idle.test.js +786 -0
  896. package/dist/hooks/__tests__/notify-hook-all-workers-idle.test.js.map +1 -0
  897. package/dist/hooks/__tests__/notify-hook-auto-nudge.test.d.ts +2 -0
  898. package/dist/hooks/__tests__/notify-hook-auto-nudge.test.d.ts.map +1 -0
  899. package/dist/hooks/__tests__/notify-hook-auto-nudge.test.js +2602 -0
  900. package/dist/hooks/__tests__/notify-hook-auto-nudge.test.js.map +1 -0
  901. package/dist/hooks/__tests__/notify-hook-cross-worktree-heartbeat.test.d.ts +2 -0
  902. package/dist/hooks/__tests__/notify-hook-cross-worktree-heartbeat.test.d.ts.map +1 -0
  903. package/dist/hooks/__tests__/notify-hook-cross-worktree-heartbeat.test.js +161 -0
  904. package/dist/hooks/__tests__/notify-hook-cross-worktree-heartbeat.test.js.map +1 -0
  905. package/dist/hooks/__tests__/notify-hook-managed-tmux.test.d.ts +2 -0
  906. package/dist/hooks/__tests__/notify-hook-managed-tmux.test.d.ts.map +1 -0
  907. package/dist/hooks/__tests__/notify-hook-managed-tmux.test.js +1178 -0
  908. package/dist/hooks/__tests__/notify-hook-managed-tmux.test.js.map +1 -0
  909. package/dist/hooks/__tests__/notify-hook-modules.test.d.ts +9 -0
  910. package/dist/hooks/__tests__/notify-hook-modules.test.d.ts.map +1 -0
  911. package/dist/hooks/__tests__/notify-hook-modules.test.js +529 -0
  912. package/dist/hooks/__tests__/notify-hook-modules.test.js.map +1 -0
  913. package/dist/hooks/__tests__/notify-hook-native-dispatch-contract.test.d.ts +2 -0
  914. package/dist/hooks/__tests__/notify-hook-native-dispatch-contract.test.d.ts.map +1 -0
  915. package/dist/hooks/__tests__/notify-hook-native-dispatch-contract.test.js +14 -0
  916. package/dist/hooks/__tests__/notify-hook-native-dispatch-contract.test.js.map +1 -0
  917. package/dist/hooks/__tests__/notify-hook-non-omx-guard.test.d.ts +2 -0
  918. package/dist/hooks/__tests__/notify-hook-non-omx-guard.test.d.ts.map +1 -0
  919. package/dist/hooks/__tests__/notify-hook-non-omx-guard.test.js +176 -0
  920. package/dist/hooks/__tests__/notify-hook-non-omx-guard.test.js.map +1 -0
  921. package/dist/hooks/__tests__/notify-hook-ralph-resume.test.d.ts +2 -0
  922. package/dist/hooks/__tests__/notify-hook-ralph-resume.test.d.ts.map +1 -0
  923. package/dist/hooks/__tests__/notify-hook-ralph-resume.test.js +890 -0
  924. package/dist/hooks/__tests__/notify-hook-ralph-resume.test.js.map +1 -0
  925. package/dist/hooks/__tests__/notify-hook-regression-205.test.d.ts +9 -0
  926. package/dist/hooks/__tests__/notify-hook-regression-205.test.d.ts.map +1 -0
  927. package/dist/hooks/__tests__/notify-hook-regression-205.test.js +255 -0
  928. package/dist/hooks/__tests__/notify-hook-regression-205.test.js.map +1 -0
  929. package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.d.ts +2 -0
  930. package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.d.ts.map +1 -0
  931. package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.js +162 -0
  932. package/dist/hooks/__tests__/notify-hook-session-idle-dedupe.test.js.map +1 -0
  933. package/dist/hooks/__tests__/notify-hook-session-scope.test.d.ts +2 -0
  934. package/dist/hooks/__tests__/notify-hook-session-scope.test.d.ts.map +1 -0
  935. package/dist/hooks/__tests__/notify-hook-session-scope.test.js +304 -0
  936. package/dist/hooks/__tests__/notify-hook-session-scope.test.js.map +1 -0
  937. package/dist/hooks/__tests__/notify-hook-team-dispatch.test.d.ts +2 -0
  938. package/dist/hooks/__tests__/notify-hook-team-dispatch.test.d.ts.map +1 -0
  939. package/dist/hooks/__tests__/notify-hook-team-dispatch.test.js +1511 -0
  940. package/dist/hooks/__tests__/notify-hook-team-dispatch.test.js.map +1 -0
  941. package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.d.ts +2 -0
  942. package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.d.ts.map +1 -0
  943. package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.js +2911 -0
  944. package/dist/hooks/__tests__/notify-hook-team-leader-nudge.test.js.map +1 -0
  945. package/dist/hooks/__tests__/notify-hook-team-tmux-guard.test.d.ts +2 -0
  946. package/dist/hooks/__tests__/notify-hook-team-tmux-guard.test.d.ts.map +1 -0
  947. package/dist/hooks/__tests__/notify-hook-team-tmux-guard.test.js +261 -0
  948. package/dist/hooks/__tests__/notify-hook-team-tmux-guard.test.js.map +1 -0
  949. package/dist/hooks/__tests__/notify-hook-team-worker-fail-closed.test.d.ts +2 -0
  950. package/dist/hooks/__tests__/notify-hook-team-worker-fail-closed.test.d.ts.map +1 -0
  951. package/dist/hooks/__tests__/notify-hook-team-worker-fail-closed.test.js +35 -0
  952. package/dist/hooks/__tests__/notify-hook-team-worker-fail-closed.test.js.map +1 -0
  953. package/dist/hooks/__tests__/notify-hook-tmux-heal.test.d.ts +2 -0
  954. package/dist/hooks/__tests__/notify-hook-tmux-heal.test.d.ts.map +1 -0
  955. package/dist/hooks/__tests__/notify-hook-tmux-heal.test.js +1854 -0
  956. package/dist/hooks/__tests__/notify-hook-tmux-heal.test.js.map +1 -0
  957. package/dist/hooks/__tests__/notify-hook-tmux-scrollback.test.d.ts +10 -0
  958. package/dist/hooks/__tests__/notify-hook-tmux-scrollback.test.d.ts.map +1 -0
  959. package/dist/hooks/__tests__/notify-hook-tmux-scrollback.test.js +0 -0
  960. package/dist/hooks/__tests__/notify-hook-tmux-scrollback.test.js.map +1 -0
  961. package/dist/hooks/__tests__/notify-hook-visual-verdict.test.d.ts +11 -0
  962. package/dist/hooks/__tests__/notify-hook-visual-verdict.test.d.ts.map +1 -0
  963. package/dist/hooks/__tests__/notify-hook-visual-verdict.test.js +266 -0
  964. package/dist/hooks/__tests__/notify-hook-visual-verdict.test.js.map +1 -0
  965. package/dist/hooks/__tests__/notify-hook-worker-idle.test.d.ts +2 -0
  966. package/dist/hooks/__tests__/notify-hook-worker-idle.test.d.ts.map +1 -0
  967. package/dist/hooks/__tests__/notify-hook-worker-idle.test.js +895 -0
  968. package/dist/hooks/__tests__/notify-hook-worker-idle.test.js.map +1 -0
  969. package/dist/hooks/__tests__/openclaw-setup-contract.test.d.ts +2 -0
  970. package/dist/hooks/__tests__/openclaw-setup-contract.test.d.ts.map +1 -0
  971. package/dist/hooks/__tests__/openclaw-setup-contract.test.js +61 -0
  972. package/dist/hooks/__tests__/openclaw-setup-contract.test.js.map +1 -0
  973. package/dist/hooks/__tests__/pre-context-gate-skills.test.d.ts +2 -0
  974. package/dist/hooks/__tests__/pre-context-gate-skills.test.d.ts.map +1 -0
  975. package/dist/hooks/__tests__/pre-context-gate-skills.test.js +40 -0
  976. package/dist/hooks/__tests__/pre-context-gate-skills.test.js.map +1 -0
  977. package/dist/hooks/__tests__/prometheus-strict-contract.test.d.ts +2 -0
  978. package/dist/hooks/__tests__/prometheus-strict-contract.test.d.ts.map +1 -0
  979. package/dist/hooks/__tests__/prometheus-strict-contract.test.js +320 -0
  980. package/dist/hooks/__tests__/prometheus-strict-contract.test.js.map +1 -0
  981. package/dist/hooks/__tests__/prompt-guidance-catalog.test.d.ts +2 -0
  982. package/dist/hooks/__tests__/prompt-guidance-catalog.test.d.ts.map +1 -0
  983. package/dist/hooks/__tests__/prompt-guidance-catalog.test.js +11 -0
  984. package/dist/hooks/__tests__/prompt-guidance-catalog.test.js.map +1 -0
  985. package/dist/hooks/__tests__/prompt-guidance-contract.test.d.ts +2 -0
  986. package/dist/hooks/__tests__/prompt-guidance-contract.test.d.ts.map +1 -0
  987. package/dist/hooks/__tests__/prompt-guidance-contract.test.js +38 -0
  988. package/dist/hooks/__tests__/prompt-guidance-contract.test.js.map +1 -0
  989. package/dist/hooks/__tests__/prompt-guidance-fragments.test.d.ts +2 -0
  990. package/dist/hooks/__tests__/prompt-guidance-fragments.test.d.ts.map +1 -0
  991. package/dist/hooks/__tests__/prompt-guidance-fragments.test.js +48 -0
  992. package/dist/hooks/__tests__/prompt-guidance-fragments.test.js.map +1 -0
  993. package/dist/hooks/__tests__/prompt-guidance-scenarios.test.d.ts +2 -0
  994. package/dist/hooks/__tests__/prompt-guidance-scenarios.test.d.ts.map +1 -0
  995. package/dist/hooks/__tests__/prompt-guidance-scenarios.test.js +11 -0
  996. package/dist/hooks/__tests__/prompt-guidance-scenarios.test.js.map +1 -0
  997. package/dist/hooks/__tests__/prompt-guidance-test-helpers.d.ts +5 -0
  998. package/dist/hooks/__tests__/prompt-guidance-test-helpers.d.ts.map +1 -0
  999. package/dist/hooks/__tests__/prompt-guidance-test-helpers.js +34 -0
  1000. package/dist/hooks/__tests__/prompt-guidance-test-helpers.js.map +1 -0
  1001. package/dist/hooks/__tests__/prompt-guidance-wave-two.test.d.ts +2 -0
  1002. package/dist/hooks/__tests__/prompt-guidance-wave-two.test.d.ts.map +1 -0
  1003. package/dist/hooks/__tests__/prompt-guidance-wave-two.test.js +81 -0
  1004. package/dist/hooks/__tests__/prompt-guidance-wave-two.test.js.map +1 -0
  1005. package/dist/hooks/__tests__/prompt-orchestration-boundary.test.d.ts +2 -0
  1006. package/dist/hooks/__tests__/prompt-orchestration-boundary.test.d.ts.map +1 -0
  1007. package/dist/hooks/__tests__/prompt-orchestration-boundary.test.js +38 -0
  1008. package/dist/hooks/__tests__/prompt-orchestration-boundary.test.js.map +1 -0
  1009. package/dist/hooks/__tests__/prompt-refactor-contract.test.d.ts +2 -0
  1010. package/dist/hooks/__tests__/prompt-refactor-contract.test.d.ts.map +1 -0
  1011. package/dist/hooks/__tests__/prompt-refactor-contract.test.js +22 -0
  1012. package/dist/hooks/__tests__/prompt-refactor-contract.test.js.map +1 -0
  1013. package/dist/hooks/__tests__/prompt-team-routing.test.d.ts +2 -0
  1014. package/dist/hooks/__tests__/prompt-team-routing.test.d.ts.map +1 -0
  1015. package/dist/hooks/__tests__/prompt-team-routing.test.js +49 -0
  1016. package/dist/hooks/__tests__/prompt-team-routing.test.js.map +1 -0
  1017. package/dist/hooks/__tests__/research-workflow-boundaries.test.d.ts +2 -0
  1018. package/dist/hooks/__tests__/research-workflow-boundaries.test.d.ts.map +1 -0
  1019. package/dist/hooks/__tests__/research-workflow-boundaries.test.js +35 -0
  1020. package/dist/hooks/__tests__/research-workflow-boundaries.test.js.map +1 -0
  1021. package/dist/hooks/__tests__/session.test.d.ts +2 -0
  1022. package/dist/hooks/__tests__/session.test.d.ts.map +1 -0
  1023. package/dist/hooks/__tests__/session.test.js +504 -0
  1024. package/dist/hooks/__tests__/session.test.js.map +1 -0
  1025. package/dist/hooks/__tests__/skill-catalog-hygiene.test.d.ts +2 -0
  1026. package/dist/hooks/__tests__/skill-catalog-hygiene.test.d.ts.map +1 -0
  1027. package/dist/hooks/__tests__/skill-catalog-hygiene.test.js +84 -0
  1028. package/dist/hooks/__tests__/skill-catalog-hygiene.test.js.map +1 -0
  1029. package/dist/hooks/__tests__/skill-guidance-contract.test.d.ts +2 -0
  1030. package/dist/hooks/__tests__/skill-guidance-contract.test.d.ts.map +1 -0
  1031. package/dist/hooks/__tests__/skill-guidance-contract.test.js +89 -0
  1032. package/dist/hooks/__tests__/skill-guidance-contract.test.js.map +1 -0
  1033. package/dist/hooks/__tests__/task-size-detector.test.d.ts +2 -0
  1034. package/dist/hooks/__tests__/task-size-detector.test.d.ts.map +1 -0
  1035. package/dist/hooks/__tests__/task-size-detector.test.js +330 -0
  1036. package/dist/hooks/__tests__/task-size-detector.test.js.map +1 -0
  1037. package/dist/hooks/__tests__/team-runtime-gating-docs-contract.test.d.ts +2 -0
  1038. package/dist/hooks/__tests__/team-runtime-gating-docs-contract.test.d.ts.map +1 -0
  1039. package/dist/hooks/__tests__/team-runtime-gating-docs-contract.test.js +28 -0
  1040. package/dist/hooks/__tests__/team-runtime-gating-docs-contract.test.js.map +1 -0
  1041. package/dist/hooks/__tests__/tmux-hook-engine-types-sync.test.d.ts +2 -0
  1042. package/dist/hooks/__tests__/tmux-hook-engine-types-sync.test.d.ts.map +1 -0
  1043. package/dist/hooks/__tests__/tmux-hook-engine-types-sync.test.js +24 -0
  1044. package/dist/hooks/__tests__/tmux-hook-engine-types-sync.test.js.map +1 -0
  1045. package/dist/hooks/__tests__/tmux-hook-engine.test.d.ts +2 -0
  1046. package/dist/hooks/__tests__/tmux-hook-engine.test.d.ts.map +1 -0
  1047. package/dist/hooks/__tests__/tmux-hook-engine.test.js +403 -0
  1048. package/dist/hooks/__tests__/tmux-hook-engine.test.js.map +1 -0
  1049. package/dist/hooks/__tests__/triage-config.test.d.ts +2 -0
  1050. package/dist/hooks/__tests__/triage-config.test.d.ts.map +1 -0
  1051. package/dist/hooks/__tests__/triage-config.test.js +211 -0
  1052. package/dist/hooks/__tests__/triage-config.test.js.map +1 -0
  1053. package/dist/hooks/__tests__/triage-heuristic.test.d.ts +2 -0
  1054. package/dist/hooks/__tests__/triage-heuristic.test.d.ts.map +1 -0
  1055. package/dist/hooks/__tests__/triage-heuristic.test.js +285 -0
  1056. package/dist/hooks/__tests__/triage-heuristic.test.js.map +1 -0
  1057. package/dist/hooks/__tests__/triage-state.test.d.ts +2 -0
  1058. package/dist/hooks/__tests__/triage-state.test.d.ts.map +1 -0
  1059. package/dist/hooks/__tests__/triage-state.test.js +426 -0
  1060. package/dist/hooks/__tests__/triage-state.test.js.map +1 -0
  1061. package/dist/hooks/__tests__/visual-ralph-skill.test.d.ts +2 -0
  1062. package/dist/hooks/__tests__/visual-ralph-skill.test.d.ts.map +1 -0
  1063. package/dist/hooks/__tests__/visual-ralph-skill.test.js +44 -0
  1064. package/dist/hooks/__tests__/visual-ralph-skill.test.js.map +1 -0
  1065. package/dist/hooks/__tests__/visual-verdict-loop.test.d.ts +2 -0
  1066. package/dist/hooks/__tests__/visual-verdict-loop.test.d.ts.map +1 -0
  1067. package/dist/hooks/__tests__/visual-verdict-loop.test.js +31 -0
  1068. package/dist/hooks/__tests__/visual-verdict-loop.test.js.map +1 -0
  1069. package/dist/hooks/__tests__/wiki-docs-contract.test.d.ts +2 -0
  1070. package/dist/hooks/__tests__/wiki-docs-contract.test.d.ts.map +1 -0
  1071. package/dist/hooks/__tests__/wiki-docs-contract.test.js +35 -0
  1072. package/dist/hooks/__tests__/wiki-docs-contract.test.js.map +1 -0
  1073. package/dist/hooks/agents-overlay.d.ts +51 -0
  1074. package/dist/hooks/agents-overlay.d.ts.map +1 -0
  1075. package/dist/hooks/agents-overlay.js +547 -0
  1076. package/dist/hooks/agents-overlay.js.map +1 -0
  1077. package/dist/hooks/code-simplifier/__tests__/index.test.d.ts +2 -0
  1078. package/dist/hooks/code-simplifier/__tests__/index.test.d.ts.map +1 -0
  1079. package/dist/hooks/code-simplifier/__tests__/index.test.js +187 -0
  1080. package/dist/hooks/code-simplifier/__tests__/index.test.js.map +1 -0
  1081. package/dist/hooks/code-simplifier/index.d.ts +80 -0
  1082. package/dist/hooks/code-simplifier/index.d.ts.map +1 -0
  1083. package/dist/hooks/code-simplifier/index.js +172 -0
  1084. package/dist/hooks/code-simplifier/index.js.map +1 -0
  1085. package/dist/hooks/codebase-map.d.ts +23 -0
  1086. package/dist/hooks/codebase-map.d.ts.map +1 -0
  1087. package/dist/hooks/codebase-map.js +234 -0
  1088. package/dist/hooks/codebase-map.js.map +1 -0
  1089. package/dist/hooks/deep-interview-config-instruction.d.ts +3 -0
  1090. package/dist/hooks/deep-interview-config-instruction.d.ts.map +1 -0
  1091. package/dist/hooks/deep-interview-config-instruction.js +47 -0
  1092. package/dist/hooks/deep-interview-config-instruction.js.map +1 -0
  1093. package/dist/hooks/explore-routing.d.ts +5 -0
  1094. package/dist/hooks/explore-routing.d.ts.map +1 -0
  1095. package/dist/hooks/explore-routing.js +37 -0
  1096. package/dist/hooks/explore-routing.js.map +1 -0
  1097. package/dist/hooks/extensibility/__tests__/dispatcher.test.d.ts +2 -0
  1098. package/dist/hooks/extensibility/__tests__/dispatcher.test.d.ts.map +1 -0
  1099. package/dist/hooks/extensibility/__tests__/dispatcher.test.js +265 -0
  1100. package/dist/hooks/extensibility/__tests__/dispatcher.test.js.map +1 -0
  1101. package/dist/hooks/extensibility/__tests__/events.test.d.ts +2 -0
  1102. package/dist/hooks/extensibility/__tests__/events.test.d.ts.map +1 -0
  1103. package/dist/hooks/extensibility/__tests__/events.test.js +125 -0
  1104. package/dist/hooks/extensibility/__tests__/events.test.js.map +1 -0
  1105. package/dist/hooks/extensibility/__tests__/example-hook-plugins.test.d.ts +2 -0
  1106. package/dist/hooks/extensibility/__tests__/example-hook-plugins.test.d.ts.map +1 -0
  1107. package/dist/hooks/extensibility/__tests__/example-hook-plugins.test.js +153 -0
  1108. package/dist/hooks/extensibility/__tests__/example-hook-plugins.test.js.map +1 -0
  1109. package/dist/hooks/extensibility/__tests__/loader.test.d.ts +2 -0
  1110. package/dist/hooks/extensibility/__tests__/loader.test.d.ts.map +1 -0
  1111. package/dist/hooks/extensibility/__tests__/loader.test.js +254 -0
  1112. package/dist/hooks/extensibility/__tests__/loader.test.js.map +1 -0
  1113. package/dist/hooks/extensibility/__tests__/logging.test.d.ts +2 -0
  1114. package/dist/hooks/extensibility/__tests__/logging.test.d.ts.map +1 -0
  1115. package/dist/hooks/extensibility/__tests__/logging.test.js +74 -0
  1116. package/dist/hooks/extensibility/__tests__/logging.test.js.map +1 -0
  1117. package/dist/hooks/extensibility/__tests__/plugin-runner.test.d.ts +2 -0
  1118. package/dist/hooks/extensibility/__tests__/plugin-runner.test.d.ts.map +1 -0
  1119. package/dist/hooks/extensibility/__tests__/plugin-runner.test.js +344 -0
  1120. package/dist/hooks/extensibility/__tests__/plugin-runner.test.js.map +1 -0
  1121. package/dist/hooks/extensibility/__tests__/runtime.test.d.ts +2 -0
  1122. package/dist/hooks/extensibility/__tests__/runtime.test.d.ts.map +1 -0
  1123. package/dist/hooks/extensibility/__tests__/runtime.test.js +198 -0
  1124. package/dist/hooks/extensibility/__tests__/runtime.test.js.map +1 -0
  1125. package/dist/hooks/extensibility/__tests__/sdk-public-surface.test.d.ts +2 -0
  1126. package/dist/hooks/extensibility/__tests__/sdk-public-surface.test.d.ts.map +1 -0
  1127. package/dist/hooks/extensibility/__tests__/sdk-public-surface.test.js +32 -0
  1128. package/dist/hooks/extensibility/__tests__/sdk-public-surface.test.js.map +1 -0
  1129. package/dist/hooks/extensibility/__tests__/sdk.test.d.ts +2 -0
  1130. package/dist/hooks/extensibility/__tests__/sdk.test.d.ts.map +1 -0
  1131. package/dist/hooks/extensibility/__tests__/sdk.test.js +479 -0
  1132. package/dist/hooks/extensibility/__tests__/sdk.test.js.map +1 -0
  1133. package/dist/hooks/extensibility/dispatcher.d.ts +4 -0
  1134. package/dist/hooks/extensibility/dispatcher.d.ts.map +1 -0
  1135. package/dist/hooks/extensibility/dispatcher.js +302 -0
  1136. package/dist/hooks/extensibility/dispatcher.js.map +1 -0
  1137. package/dist/hooks/extensibility/events.d.ts +18 -0
  1138. package/dist/hooks/extensibility/events.d.ts.map +1 -0
  1139. package/dist/hooks/extensibility/events.js +53 -0
  1140. package/dist/hooks/extensibility/events.js.map +1 -0
  1141. package/dist/hooks/extensibility/index.d.ts +6 -0
  1142. package/dist/hooks/extensibility/index.d.ts.map +1 -0
  1143. package/dist/hooks/extensibility/index.js +6 -0
  1144. package/dist/hooks/extensibility/index.js.map +1 -0
  1145. package/dist/hooks/extensibility/loader.d.ts +14 -0
  1146. package/dist/hooks/extensibility/loader.d.ts.map +1 -0
  1147. package/dist/hooks/extensibility/loader.js +117 -0
  1148. package/dist/hooks/extensibility/loader.js.map +1 -0
  1149. package/dist/hooks/extensibility/logging.d.ts +4 -0
  1150. package/dist/hooks/extensibility/logging.d.ts.map +1 -0
  1151. package/dist/hooks/extensibility/logging.js +22 -0
  1152. package/dist/hooks/extensibility/logging.js.map +1 -0
  1153. package/dist/hooks/extensibility/plugin-runner-stdin.d.ts +2 -0
  1154. package/dist/hooks/extensibility/plugin-runner-stdin.d.ts.map +1 -0
  1155. package/dist/hooks/extensibility/plugin-runner-stdin.js +16 -0
  1156. package/dist/hooks/extensibility/plugin-runner-stdin.js.map +1 -0
  1157. package/dist/hooks/extensibility/plugin-runner.d.ts +2 -0
  1158. package/dist/hooks/extensibility/plugin-runner.d.ts.map +1 -0
  1159. package/dist/hooks/extensibility/plugin-runner.js +63 -0
  1160. package/dist/hooks/extensibility/plugin-runner.js.map +1 -0
  1161. package/dist/hooks/extensibility/runtime.d.ts +3 -0
  1162. package/dist/hooks/extensibility/runtime.d.ts.map +1 -0
  1163. package/dist/hooks/extensibility/runtime.js +42 -0
  1164. package/dist/hooks/extensibility/runtime.js.map +1 -0
  1165. package/dist/hooks/extensibility/sdk/logging.d.ts +6 -0
  1166. package/dist/hooks/extensibility/sdk/logging.d.ts.map +1 -0
  1167. package/dist/hooks/extensibility/sdk/logging.js +32 -0
  1168. package/dist/hooks/extensibility/sdk/logging.js.map +1 -0
  1169. package/dist/hooks/extensibility/sdk/paths.d.ts +7 -0
  1170. package/dist/hooks/extensibility/sdk/paths.d.ts.map +1 -0
  1171. package/dist/hooks/extensibility/sdk/paths.js +23 -0
  1172. package/dist/hooks/extensibility/sdk/paths.js.map +1 -0
  1173. package/dist/hooks/extensibility/sdk/plugin-state.d.ts +5 -0
  1174. package/dist/hooks/extensibility/sdk/plugin-state.d.ts.map +1 -0
  1175. package/dist/hooks/extensibility/sdk/plugin-state.js +66 -0
  1176. package/dist/hooks/extensibility/sdk/plugin-state.js.map +1 -0
  1177. package/dist/hooks/extensibility/sdk/runtime-state.d.ts +3 -0
  1178. package/dist/hooks/extensibility/sdk/runtime-state.d.ts.map +1 -0
  1179. package/dist/hooks/extensibility/sdk/runtime-state.js +47 -0
  1180. package/dist/hooks/extensibility/sdk/runtime-state.js.map +1 -0
  1181. package/dist/hooks/extensibility/sdk/tmux.d.ts +10 -0
  1182. package/dist/hooks/extensibility/sdk/tmux.d.ts.map +1 -0
  1183. package/dist/hooks/extensibility/sdk/tmux.js +181 -0
  1184. package/dist/hooks/extensibility/sdk/tmux.js.map +1 -0
  1185. package/dist/hooks/extensibility/sdk.d.ts +11 -0
  1186. package/dist/hooks/extensibility/sdk.d.ts.map +1 -0
  1187. package/dist/hooks/extensibility/sdk.js +21 -0
  1188. package/dist/hooks/extensibility/sdk.js.map +1 -0
  1189. package/dist/hooks/extensibility/types.d.ts +175 -0
  1190. package/dist/hooks/extensibility/types.d.ts.map +1 -0
  1191. package/dist/hooks/extensibility/types.js +2 -0
  1192. package/dist/hooks/extensibility/types.js.map +1 -0
  1193. package/dist/hooks/keyword-detector.d.ts +170 -0
  1194. package/dist/hooks/keyword-detector.d.ts.map +1 -0
  1195. package/dist/hooks/keyword-detector.js +1363 -0
  1196. package/dist/hooks/keyword-detector.js.map +1 -0
  1197. package/dist/hooks/keyword-registry.d.ts +15 -0
  1198. package/dist/hooks/keyword-registry.d.ts.map +1 -0
  1199. package/dist/hooks/keyword-registry.js +56 -0
  1200. package/dist/hooks/keyword-registry.js.map +1 -0
  1201. package/dist/hooks/prompt-guidance-contract.d.ts +20 -0
  1202. package/dist/hooks/prompt-guidance-contract.d.ts.map +1 -0
  1203. package/dist/hooks/prompt-guidance-contract.js +380 -0
  1204. package/dist/hooks/prompt-guidance-contract.js.map +1 -0
  1205. package/dist/hooks/session.d.ts +83 -0
  1206. package/dist/hooks/session.d.ts.map +1 -0
  1207. package/dist/hooks/session.js +412 -0
  1208. package/dist/hooks/session.js.map +1 -0
  1209. package/dist/hooks/task-size-detector.d.ts +72 -0
  1210. package/dist/hooks/task-size-detector.d.ts.map +1 -0
  1211. package/dist/hooks/task-size-detector.js +203 -0
  1212. package/dist/hooks/task-size-detector.js.map +1 -0
  1213. package/dist/hooks/triage-config.d.ts +33 -0
  1214. package/dist/hooks/triage-config.d.ts.map +1 -0
  1215. package/dist/hooks/triage-config.js +87 -0
  1216. package/dist/hooks/triage-config.js.map +1 -0
  1217. package/dist/hooks/triage-heuristic.d.ts +20 -0
  1218. package/dist/hooks/triage-heuristic.d.ts.map +1 -0
  1219. package/dist/hooks/triage-heuristic.js +287 -0
  1220. package/dist/hooks/triage-heuristic.js.map +1 -0
  1221. package/dist/hooks/triage-state.d.ts +63 -0
  1222. package/dist/hooks/triage-state.d.ts.map +1 -0
  1223. package/dist/hooks/triage-state.js +139 -0
  1224. package/dist/hooks/triage-state.js.map +1 -0
  1225. package/dist/hud/__tests__/authority.test.d.ts +2 -0
  1226. package/dist/hud/__tests__/authority.test.d.ts.map +1 -0
  1227. package/dist/hud/__tests__/authority.test.js +527 -0
  1228. package/dist/hud/__tests__/authority.test.js.map +1 -0
  1229. package/dist/hud/__tests__/colors.test.d.ts +2 -0
  1230. package/dist/hud/__tests__/colors.test.d.ts.map +1 -0
  1231. package/dist/hud/__tests__/colors.test.js +92 -0
  1232. package/dist/hud/__tests__/colors.test.js.map +1 -0
  1233. package/dist/hud/__tests__/hud-tmux-injection.test.d.ts +10 -0
  1234. package/dist/hud/__tests__/hud-tmux-injection.test.d.ts.map +1 -0
  1235. package/dist/hud/__tests__/hud-tmux-injection.test.js +185 -0
  1236. package/dist/hud/__tests__/hud-tmux-injection.test.js.map +1 -0
  1237. package/dist/hud/__tests__/index.test.d.ts +2 -0
  1238. package/dist/hud/__tests__/index.test.d.ts.map +1 -0
  1239. package/dist/hud/__tests__/index.test.js +684 -0
  1240. package/dist/hud/__tests__/index.test.js.map +1 -0
  1241. package/dist/hud/__tests__/reconcile.test.d.ts +2 -0
  1242. package/dist/hud/__tests__/reconcile.test.d.ts.map +1 -0
  1243. package/dist/hud/__tests__/reconcile.test.js +1621 -0
  1244. package/dist/hud/__tests__/reconcile.test.js.map +1 -0
  1245. package/dist/hud/__tests__/render.test.d.ts +2 -0
  1246. package/dist/hud/__tests__/render.test.d.ts.map +1 -0
  1247. package/dist/hud/__tests__/render.test.js +983 -0
  1248. package/dist/hud/__tests__/render.test.js.map +1 -0
  1249. package/dist/hud/__tests__/resource-leak-watch.test.d.ts +2 -0
  1250. package/dist/hud/__tests__/resource-leak-watch.test.d.ts.map +1 -0
  1251. package/dist/hud/__tests__/resource-leak-watch.test.js +28 -0
  1252. package/dist/hud/__tests__/resource-leak-watch.test.js.map +1 -0
  1253. package/dist/hud/__tests__/state.test.d.ts +2 -0
  1254. package/dist/hud/__tests__/state.test.d.ts.map +1 -0
  1255. package/dist/hud/__tests__/state.test.js +1212 -0
  1256. package/dist/hud/__tests__/state.test.js.map +1 -0
  1257. package/dist/hud/__tests__/tmux.test.d.ts +2 -0
  1258. package/dist/hud/__tests__/tmux.test.d.ts.map +1 -0
  1259. package/dist/hud/__tests__/tmux.test.js +679 -0
  1260. package/dist/hud/__tests__/tmux.test.js.map +1 -0
  1261. package/dist/hud/__tests__/types.test.d.ts +2 -0
  1262. package/dist/hud/__tests__/types.test.d.ts.map +1 -0
  1263. package/dist/hud/__tests__/types.test.js +79 -0
  1264. package/dist/hud/__tests__/types.test.js.map +1 -0
  1265. package/dist/hud/__tests__/watch.test.d.ts +2 -0
  1266. package/dist/hud/__tests__/watch.test.d.ts.map +1 -0
  1267. package/dist/hud/__tests__/watch.test.js +63 -0
  1268. package/dist/hud/__tests__/watch.test.js.map +1 -0
  1269. package/dist/hud/authority.d.ts +22 -0
  1270. package/dist/hud/authority.d.ts.map +1 -0
  1271. package/dist/hud/authority.js +377 -0
  1272. package/dist/hud/authority.js.map +1 -0
  1273. package/dist/hud/colors.d.ts +20 -0
  1274. package/dist/hud/colors.d.ts.map +1 -0
  1275. package/dist/hud/colors.js +60 -0
  1276. package/dist/hud/colors.js.map +1 -0
  1277. package/dist/hud/constants.d.ts +16 -0
  1278. package/dist/hud/constants.d.ts.map +1 -0
  1279. package/dist/hud/constants.js +25 -0
  1280. package/dist/hud/constants.js.map +1 -0
  1281. package/dist/hud/index.d.ts +79 -0
  1282. package/dist/hud/index.d.ts.map +1 -0
  1283. package/dist/hud/index.js +384 -0
  1284. package/dist/hud/index.js.map +1 -0
  1285. package/dist/hud/reconcile.d.ts +37 -0
  1286. package/dist/hud/reconcile.d.ts.map +1 -0
  1287. package/dist/hud/reconcile.js +326 -0
  1288. package/dist/hud/reconcile.js.map +1 -0
  1289. package/dist/hud/render.d.ts +15 -0
  1290. package/dist/hud/render.d.ts.map +1 -0
  1291. package/dist/hud/render.js +453 -0
  1292. package/dist/hud/render.js.map +1 -0
  1293. package/dist/hud/state.d.ts +27 -0
  1294. package/dist/hud/state.d.ts.map +1 -0
  1295. package/dist/hud/state.js +477 -0
  1296. package/dist/hud/state.js.map +1 -0
  1297. package/dist/hud/tmux.d.ts +87 -0
  1298. package/dist/hud/tmux.d.ts.map +1 -0
  1299. package/dist/hud/tmux.js +572 -0
  1300. package/dist/hud/tmux.js.map +1 -0
  1301. package/dist/hud/types.d.ts +165 -0
  1302. package/dist/hud/types.d.ts.map +1 -0
  1303. package/dist/hud/types.js +14 -0
  1304. package/dist/hud/types.js.map +1 -0
  1305. package/dist/imagegen/continuation.d.ts +44 -0
  1306. package/dist/imagegen/continuation.d.ts.map +1 -0
  1307. package/dist/imagegen/continuation.js +220 -0
  1308. package/dist/imagegen/continuation.js.map +1 -0
  1309. package/dist/index.d.ts +19 -0
  1310. package/dist/index.d.ts.map +1 -0
  1311. package/dist/index.js +19 -0
  1312. package/dist/index.js.map +1 -0
  1313. package/dist/mcp/__tests__/bootstrap.test.d.ts +2 -0
  1314. package/dist/mcp/__tests__/bootstrap.test.d.ts.map +1 -0
  1315. package/dist/mcp/__tests__/bootstrap.test.js +372 -0
  1316. package/dist/mcp/__tests__/bootstrap.test.js.map +1 -0
  1317. package/dist/mcp/__tests__/code-intel-server.test.d.ts +2 -0
  1318. package/dist/mcp/__tests__/code-intel-server.test.d.ts.map +1 -0
  1319. package/dist/mcp/__tests__/code-intel-server.test.js +70 -0
  1320. package/dist/mcp/__tests__/code-intel-server.test.js.map +1 -0
  1321. package/dist/mcp/__tests__/hermes-bridge.test.d.ts +2 -0
  1322. package/dist/mcp/__tests__/hermes-bridge.test.d.ts.map +1 -0
  1323. package/dist/mcp/__tests__/hermes-bridge.test.js +651 -0
  1324. package/dist/mcp/__tests__/hermes-bridge.test.js.map +1 -0
  1325. package/dist/mcp/__tests__/memory-server.test.d.ts +2 -0
  1326. package/dist/mcp/__tests__/memory-server.test.d.ts.map +1 -0
  1327. package/dist/mcp/__tests__/memory-server.test.js +36 -0
  1328. package/dist/mcp/__tests__/memory-server.test.js.map +1 -0
  1329. package/dist/mcp/__tests__/memory-validation.test.d.ts +2 -0
  1330. package/dist/mcp/__tests__/memory-validation.test.d.ts.map +1 -0
  1331. package/dist/mcp/__tests__/memory-validation.test.js +29 -0
  1332. package/dist/mcp/__tests__/memory-validation.test.js.map +1 -0
  1333. package/dist/mcp/__tests__/path-traversal.test.d.ts +2 -0
  1334. package/dist/mcp/__tests__/path-traversal.test.d.ts.map +1 -0
  1335. package/dist/mcp/__tests__/path-traversal.test.js +83 -0
  1336. package/dist/mcp/__tests__/path-traversal.test.js.map +1 -0
  1337. package/dist/mcp/__tests__/server-lifecycle.test.d.ts +2 -0
  1338. package/dist/mcp/__tests__/server-lifecycle.test.d.ts.map +1 -0
  1339. package/dist/mcp/__tests__/server-lifecycle.test.js +308 -0
  1340. package/dist/mcp/__tests__/server-lifecycle.test.js.map +1 -0
  1341. package/dist/mcp/__tests__/state-paths.test.d.ts +2 -0
  1342. package/dist/mcp/__tests__/state-paths.test.d.ts.map +1 -0
  1343. package/dist/mcp/__tests__/state-paths.test.js +477 -0
  1344. package/dist/mcp/__tests__/state-paths.test.js.map +1 -0
  1345. package/dist/mcp/__tests__/state-server-ralph-phase.test.d.ts +2 -0
  1346. package/dist/mcp/__tests__/state-server-ralph-phase.test.d.ts.map +1 -0
  1347. package/dist/mcp/__tests__/state-server-ralph-phase.test.js +109 -0
  1348. package/dist/mcp/__tests__/state-server-ralph-phase.test.js.map +1 -0
  1349. package/dist/mcp/__tests__/state-server-schema.test.d.ts +2 -0
  1350. package/dist/mcp/__tests__/state-server-schema.test.d.ts.map +1 -0
  1351. package/dist/mcp/__tests__/state-server-schema.test.js +29 -0
  1352. package/dist/mcp/__tests__/state-server-schema.test.js.map +1 -0
  1353. package/dist/mcp/__tests__/state-server-team-tools.test.d.ts +2 -0
  1354. package/dist/mcp/__tests__/state-server-team-tools.test.d.ts.map +1 -0
  1355. package/dist/mcp/__tests__/state-server-team-tools.test.js +35 -0
  1356. package/dist/mcp/__tests__/state-server-team-tools.test.js.map +1 -0
  1357. package/dist/mcp/__tests__/state-server.test.d.ts +2 -0
  1358. package/dist/mcp/__tests__/state-server.test.d.ts.map +1 -0
  1359. package/dist/mcp/__tests__/state-server.test.js +1318 -0
  1360. package/dist/mcp/__tests__/state-server.test.js.map +1 -0
  1361. package/dist/mcp/__tests__/trace-server.test.d.ts +2 -0
  1362. package/dist/mcp/__tests__/trace-server.test.d.ts.map +1 -0
  1363. package/dist/mcp/__tests__/trace-server.test.js +119 -0
  1364. package/dist/mcp/__tests__/trace-server.test.js.map +1 -0
  1365. package/dist/mcp/__tests__/wiki-server.test.d.ts +2 -0
  1366. package/dist/mcp/__tests__/wiki-server.test.d.ts.map +1 -0
  1367. package/dist/mcp/__tests__/wiki-server.test.js +126 -0
  1368. package/dist/mcp/__tests__/wiki-server.test.js.map +1 -0
  1369. package/dist/mcp/bootstrap.d.ts +44 -0
  1370. package/dist/mcp/bootstrap.d.ts.map +1 -0
  1371. package/dist/mcp/bootstrap.js +520 -0
  1372. package/dist/mcp/bootstrap.js.map +1 -0
  1373. package/dist/mcp/code-intel-server.d.ts +333 -0
  1374. package/dist/mcp/code-intel-server.d.ts.map +1 -0
  1375. package/dist/mcp/code-intel-server.js +605 -0
  1376. package/dist/mcp/code-intel-server.js.map +1 -0
  1377. package/dist/mcp/hermes-bridge.d.ts +124 -0
  1378. package/dist/mcp/hermes-bridge.d.ts.map +1 -0
  1379. package/dist/mcp/hermes-bridge.js +549 -0
  1380. package/dist/mcp/hermes-bridge.js.map +1 -0
  1381. package/dist/mcp/hermes-server.d.ts +374 -0
  1382. package/dist/mcp/hermes-server.d.ts.map +1 -0
  1383. package/dist/mcp/hermes-server.js +158 -0
  1384. package/dist/mcp/hermes-server.js.map +1 -0
  1385. package/dist/mcp/lifecycle-telemetry.d.ts +16 -0
  1386. package/dist/mcp/lifecycle-telemetry.d.ts.map +1 -0
  1387. package/dist/mcp/lifecycle-telemetry.js +95 -0
  1388. package/dist/mcp/lifecycle-telemetry.js.map +1 -0
  1389. package/dist/mcp/memory-server.d.ts +201 -0
  1390. package/dist/mcp/memory-server.d.ts.map +1 -0
  1391. package/dist/mcp/memory-server.js +441 -0
  1392. package/dist/mcp/memory-server.js.map +1 -0
  1393. package/dist/mcp/memory-validation.d.ts +9 -0
  1394. package/dist/mcp/memory-validation.d.ts.map +1 -0
  1395. package/dist/mcp/memory-validation.js +11 -0
  1396. package/dist/mcp/memory-validation.js.map +1 -0
  1397. package/dist/mcp/state-paths.d.ts +91 -0
  1398. package/dist/mcp/state-paths.d.ts.map +1 -0
  1399. package/dist/mcp/state-paths.js +473 -0
  1400. package/dist/mcp/state-paths.js.map +1 -0
  1401. package/dist/mcp/state-server.d.ts +222 -0
  1402. package/dist/mcp/state-server.d.ts.map +1 -0
  1403. package/dist/mcp/state-server.js +181 -0
  1404. package/dist/mcp/state-server.js.map +1 -0
  1405. package/dist/mcp/trace-server.d.ts +81 -0
  1406. package/dist/mcp/trace-server.d.ts.map +1 -0
  1407. package/dist/mcp/trace-server.js +271 -0
  1408. package/dist/mcp/trace-server.js.map +1 -0
  1409. package/dist/mcp/wiki-server.d.ts +181 -0
  1410. package/dist/mcp/wiki-server.d.ts.map +1 -0
  1411. package/dist/mcp/wiki-server.js +244 -0
  1412. package/dist/mcp/wiki-server.js.map +1 -0
  1413. package/dist/modes/__tests__/base-autopilot-gates.test.d.ts +2 -0
  1414. package/dist/modes/__tests__/base-autopilot-gates.test.d.ts.map +1 -0
  1415. package/dist/modes/__tests__/base-autopilot-gates.test.js +154 -0
  1416. package/dist/modes/__tests__/base-autopilot-gates.test.js.map +1 -0
  1417. package/dist/modes/__tests__/base-autoresearch-contract.test.d.ts +2 -0
  1418. package/dist/modes/__tests__/base-autoresearch-contract.test.d.ts.map +1 -0
  1419. package/dist/modes/__tests__/base-autoresearch-contract.test.js +129 -0
  1420. package/dist/modes/__tests__/base-autoresearch-contract.test.js.map +1 -0
  1421. package/dist/modes/__tests__/base-multi-state-compat.test.d.ts +2 -0
  1422. package/dist/modes/__tests__/base-multi-state-compat.test.d.ts.map +1 -0
  1423. package/dist/modes/__tests__/base-multi-state-compat.test.js +38 -0
  1424. package/dist/modes/__tests__/base-multi-state-compat.test.js.map +1 -0
  1425. package/dist/modes/__tests__/base-ralph-contract.test.d.ts +2 -0
  1426. package/dist/modes/__tests__/base-ralph-contract.test.d.ts.map +1 -0
  1427. package/dist/modes/__tests__/base-ralph-contract.test.js +64 -0
  1428. package/dist/modes/__tests__/base-ralph-contract.test.js.map +1 -0
  1429. package/dist/modes/__tests__/base-session-scope.test.d.ts +2 -0
  1430. package/dist/modes/__tests__/base-session-scope.test.d.ts.map +1 -0
  1431. package/dist/modes/__tests__/base-session-scope.test.js +146 -0
  1432. package/dist/modes/__tests__/base-session-scope.test.js.map +1 -0
  1433. package/dist/modes/__tests__/base-tmux-pane.test.d.ts +2 -0
  1434. package/dist/modes/__tests__/base-tmux-pane.test.d.ts.map +1 -0
  1435. package/dist/modes/__tests__/base-tmux-pane.test.js +100 -0
  1436. package/dist/modes/__tests__/base-tmux-pane.test.js.map +1 -0
  1437. package/dist/modes/base.d.ts +60 -0
  1438. package/dist/modes/base.d.ts.map +1 -0
  1439. package/dist/modes/base.js +346 -0
  1440. package/dist/modes/base.js.map +1 -0
  1441. package/dist/notifications/__tests__/config.test.d.ts +2 -0
  1442. package/dist/notifications/__tests__/config.test.d.ts.map +1 -0
  1443. package/dist/notifications/__tests__/config.test.js +269 -0
  1444. package/dist/notifications/__tests__/config.test.js.map +1 -0
  1445. package/dist/notifications/__tests__/custom-alias-enablement.test.d.ts +2 -0
  1446. package/dist/notifications/__tests__/custom-alias-enablement.test.d.ts.map +1 -0
  1447. package/dist/notifications/__tests__/custom-alias-enablement.test.js +84 -0
  1448. package/dist/notifications/__tests__/custom-alias-enablement.test.js.map +1 -0
  1449. package/dist/notifications/__tests__/dispatch-cooldown.test.d.ts +5 -0
  1450. package/dist/notifications/__tests__/dispatch-cooldown.test.d.ts.map +1 -0
  1451. package/dist/notifications/__tests__/dispatch-cooldown.test.js +100 -0
  1452. package/dist/notifications/__tests__/dispatch-cooldown.test.js.map +1 -0
  1453. package/dist/notifications/__tests__/dispatcher.test.d.ts +2 -0
  1454. package/dist/notifications/__tests__/dispatcher.test.d.ts.map +1 -0
  1455. package/dist/notifications/__tests__/dispatcher.test.js +202 -0
  1456. package/dist/notifications/__tests__/dispatcher.test.js.map +1 -0
  1457. package/dist/notifications/__tests__/formatter.test.d.ts +2 -0
  1458. package/dist/notifications/__tests__/formatter.test.d.ts.map +1 -0
  1459. package/dist/notifications/__tests__/formatter.test.js +270 -0
  1460. package/dist/notifications/__tests__/formatter.test.js.map +1 -0
  1461. package/dist/notifications/__tests__/hook-config.test.d.ts +5 -0
  1462. package/dist/notifications/__tests__/hook-config.test.d.ts.map +1 -0
  1463. package/dist/notifications/__tests__/hook-config.test.js +139 -0
  1464. package/dist/notifications/__tests__/hook-config.test.js.map +1 -0
  1465. package/dist/notifications/__tests__/http-client-resource.test.d.ts +2 -0
  1466. package/dist/notifications/__tests__/http-client-resource.test.d.ts.map +1 -0
  1467. package/dist/notifications/__tests__/http-client-resource.test.js +41 -0
  1468. package/dist/notifications/__tests__/http-client-resource.test.js.map +1 -0
  1469. package/dist/notifications/__tests__/http-client.test.d.ts +2 -0
  1470. package/dist/notifications/__tests__/http-client.test.d.ts.map +1 -0
  1471. package/dist/notifications/__tests__/http-client.test.js +90 -0
  1472. package/dist/notifications/__tests__/http-client.test.js.map +1 -0
  1473. package/dist/notifications/__tests__/idle-cooldown.test.d.ts +5 -0
  1474. package/dist/notifications/__tests__/idle-cooldown.test.d.ts.map +1 -0
  1475. package/dist/notifications/__tests__/idle-cooldown.test.js +209 -0
  1476. package/dist/notifications/__tests__/idle-cooldown.test.js.map +1 -0
  1477. package/dist/notifications/__tests__/index.test.d.ts +2 -0
  1478. package/dist/notifications/__tests__/index.test.d.ts.map +1 -0
  1479. package/dist/notifications/__tests__/index.test.js +188 -0
  1480. package/dist/notifications/__tests__/index.test.js.map +1 -0
  1481. package/dist/notifications/__tests__/lifecycle-dedupe.test.d.ts +2 -0
  1482. package/dist/notifications/__tests__/lifecycle-dedupe.test.d.ts.map +1 -0
  1483. package/dist/notifications/__tests__/lifecycle-dedupe.test.js +86 -0
  1484. package/dist/notifications/__tests__/lifecycle-dedupe.test.js.map +1 -0
  1485. package/dist/notifications/__tests__/notifier.test.d.ts +2 -0
  1486. package/dist/notifications/__tests__/notifier.test.d.ts.map +1 -0
  1487. package/dist/notifications/__tests__/notifier.test.js +201 -0
  1488. package/dist/notifications/__tests__/notifier.test.js.map +1 -0
  1489. package/dist/notifications/__tests__/profiles.test.d.ts +2 -0
  1490. package/dist/notifications/__tests__/profiles.test.d.ts.map +1 -0
  1491. package/dist/notifications/__tests__/profiles.test.js +404 -0
  1492. package/dist/notifications/__tests__/profiles.test.js.map +1 -0
  1493. package/dist/notifications/__tests__/reply-config.test.d.ts +2 -0
  1494. package/dist/notifications/__tests__/reply-config.test.d.ts.map +1 -0
  1495. package/dist/notifications/__tests__/reply-config.test.js +79 -0
  1496. package/dist/notifications/__tests__/reply-config.test.js.map +1 -0
  1497. package/dist/notifications/__tests__/reply-listener.test.d.ts +2 -0
  1498. package/dist/notifications/__tests__/reply-listener.test.d.ts.map +1 -0
  1499. package/dist/notifications/__tests__/reply-listener.test.js +723 -0
  1500. package/dist/notifications/__tests__/reply-listener.test.js.map +1 -0
  1501. package/dist/notifications/__tests__/session-idle-tail-dedupe.test.d.ts +2 -0
  1502. package/dist/notifications/__tests__/session-idle-tail-dedupe.test.d.ts.map +1 -0
  1503. package/dist/notifications/__tests__/session-idle-tail-dedupe.test.js +93 -0
  1504. package/dist/notifications/__tests__/session-idle-tail-dedupe.test.js.map +1 -0
  1505. package/dist/notifications/__tests__/session-registry.test.d.ts +2 -0
  1506. package/dist/notifications/__tests__/session-registry.test.d.ts.map +1 -0
  1507. package/dist/notifications/__tests__/session-registry.test.js +234 -0
  1508. package/dist/notifications/__tests__/session-registry.test.js.map +1 -0
  1509. package/dist/notifications/__tests__/session-status.test.d.ts +2 -0
  1510. package/dist/notifications/__tests__/session-status.test.d.ts.map +1 -0
  1511. package/dist/notifications/__tests__/session-status.test.js +249 -0
  1512. package/dist/notifications/__tests__/session-status.test.js.map +1 -0
  1513. package/dist/notifications/__tests__/temp-mode.test.d.ts +2 -0
  1514. package/dist/notifications/__tests__/temp-mode.test.d.ts.map +1 -0
  1515. package/dist/notifications/__tests__/temp-mode.test.js +172 -0
  1516. package/dist/notifications/__tests__/temp-mode.test.js.map +1 -0
  1517. package/dist/notifications/__tests__/template-engine.test.d.ts +5 -0
  1518. package/dist/notifications/__tests__/template-engine.test.d.ts.map +1 -0
  1519. package/dist/notifications/__tests__/template-engine.test.js +158 -0
  1520. package/dist/notifications/__tests__/template-engine.test.js.map +1 -0
  1521. package/dist/notifications/__tests__/tmux-detector.test.d.ts +2 -0
  1522. package/dist/notifications/__tests__/tmux-detector.test.d.ts.map +1 -0
  1523. package/dist/notifications/__tests__/tmux-detector.test.js +204 -0
  1524. package/dist/notifications/__tests__/tmux-detector.test.js.map +1 -0
  1525. package/dist/notifications/__tests__/tmux.test.d.ts +2 -0
  1526. package/dist/notifications/__tests__/tmux.test.d.ts.map +1 -0
  1527. package/dist/notifications/__tests__/tmux.test.js +285 -0
  1528. package/dist/notifications/__tests__/tmux.test.js.map +1 -0
  1529. package/dist/notifications/__tests__/verbosity.test.d.ts +2 -0
  1530. package/dist/notifications/__tests__/verbosity.test.d.ts.map +1 -0
  1531. package/dist/notifications/__tests__/verbosity.test.js +257 -0
  1532. package/dist/notifications/__tests__/verbosity.test.js.map +1 -0
  1533. package/dist/notifications/config.d.ts +65 -0
  1534. package/dist/notifications/config.d.ts.map +1 -0
  1535. package/dist/notifications/config.js +615 -0
  1536. package/dist/notifications/config.js.map +1 -0
  1537. package/dist/notifications/dispatch-cooldown.d.ts +36 -0
  1538. package/dist/notifications/dispatch-cooldown.d.ts.map +1 -0
  1539. package/dist/notifications/dispatch-cooldown.js +109 -0
  1540. package/dist/notifications/dispatch-cooldown.js.map +1 -0
  1541. package/dist/notifications/dispatcher.d.ts +15 -0
  1542. package/dist/notifications/dispatcher.d.ts.map +1 -0
  1543. package/dist/notifications/dispatcher.js +385 -0
  1544. package/dist/notifications/dispatcher.js.map +1 -0
  1545. package/dist/notifications/formatter.d.ts +30 -0
  1546. package/dist/notifications/formatter.d.ts.map +1 -0
  1547. package/dist/notifications/formatter.js +234 -0
  1548. package/dist/notifications/formatter.js.map +1 -0
  1549. package/dist/notifications/hook-config-types.d.ts +43 -0
  1550. package/dist/notifications/hook-config-types.d.ts.map +1 -0
  1551. package/dist/notifications/hook-config-types.js +8 -0
  1552. package/dist/notifications/hook-config-types.js.map +1 -0
  1553. package/dist/notifications/hook-config.d.ts +40 -0
  1554. package/dist/notifications/hook-config.d.ts.map +1 -0
  1555. package/dist/notifications/hook-config.js +127 -0
  1556. package/dist/notifications/hook-config.js.map +1 -0
  1557. package/dist/notifications/http-client.d.ts +22 -0
  1558. package/dist/notifications/http-client.d.ts.map +1 -0
  1559. package/dist/notifications/http-client.js +349 -0
  1560. package/dist/notifications/http-client.js.map +1 -0
  1561. package/dist/notifications/idle-cooldown.d.ts +61 -0
  1562. package/dist/notifications/idle-cooldown.d.ts.map +1 -0
  1563. package/dist/notifications/idle-cooldown.js +207 -0
  1564. package/dist/notifications/idle-cooldown.js.map +1 -0
  1565. package/dist/notifications/index.d.ts +40 -0
  1566. package/dist/notifications/index.d.ts.map +1 -0
  1567. package/dist/notifications/index.js +228 -0
  1568. package/dist/notifications/index.js.map +1 -0
  1569. package/dist/notifications/lifecycle-dedupe.d.ts +8 -0
  1570. package/dist/notifications/lifecycle-dedupe.d.ts.map +1 -0
  1571. package/dist/notifications/lifecycle-dedupe.js +112 -0
  1572. package/dist/notifications/lifecycle-dedupe.js.map +1 -0
  1573. package/dist/notifications/notifier.d.ts +45 -0
  1574. package/dist/notifications/notifier.d.ts.map +1 -0
  1575. package/dist/notifications/notifier.js +146 -0
  1576. package/dist/notifications/notifier.js.map +1 -0
  1577. package/dist/notifications/reply-listener.d.ts +123 -0
  1578. package/dist/notifications/reply-listener.d.ts.map +1 -0
  1579. package/dist/notifications/reply-listener.js +846 -0
  1580. package/dist/notifications/reply-listener.js.map +1 -0
  1581. package/dist/notifications/session-registry.d.ts +26 -0
  1582. package/dist/notifications/session-registry.d.ts.map +1 -0
  1583. package/dist/notifications/session-registry.js +293 -0
  1584. package/dist/notifications/session-registry.js.map +1 -0
  1585. package/dist/notifications/session-status.d.ts +25 -0
  1586. package/dist/notifications/session-status.d.ts.map +1 -0
  1587. package/dist/notifications/session-status.js +202 -0
  1588. package/dist/notifications/session-status.js.map +1 -0
  1589. package/dist/notifications/temp-contract.d.ts +22 -0
  1590. package/dist/notifications/temp-contract.d.ts.map +1 -0
  1591. package/dist/notifications/temp-contract.js +147 -0
  1592. package/dist/notifications/temp-contract.js.map +1 -0
  1593. package/dist/notifications/template-engine.d.ts +34 -0
  1594. package/dist/notifications/template-engine.d.ts.map +1 -0
  1595. package/dist/notifications/template-engine.js +249 -0
  1596. package/dist/notifications/template-engine.js.map +1 -0
  1597. package/dist/notifications/tmux-detector.d.ts +59 -0
  1598. package/dist/notifications/tmux-detector.d.ts.map +1 -0
  1599. package/dist/notifications/tmux-detector.js +126 -0
  1600. package/dist/notifications/tmux-detector.js.map +1 -0
  1601. package/dist/notifications/tmux.d.ts +44 -0
  1602. package/dist/notifications/tmux.d.ts.map +1 -0
  1603. package/dist/notifications/tmux.js +293 -0
  1604. package/dist/notifications/tmux.js.map +1 -0
  1605. package/dist/notifications/types.d.ts +226 -0
  1606. package/dist/notifications/types.d.ts.map +1 -0
  1607. package/dist/notifications/types.js +9 -0
  1608. package/dist/notifications/types.js.map +1 -0
  1609. package/dist/openclaw/__tests__/config.test.d.ts +6 -0
  1610. package/dist/openclaw/__tests__/config.test.d.ts.map +1 -0
  1611. package/dist/openclaw/__tests__/config.test.js +344 -0
  1612. package/dist/openclaw/__tests__/config.test.js.map +1 -0
  1613. package/dist/openclaw/__tests__/dispatcher.test.d.ts +5 -0
  1614. package/dist/openclaw/__tests__/dispatcher.test.d.ts.map +1 -0
  1615. package/dist/openclaw/__tests__/dispatcher.test.js +278 -0
  1616. package/dist/openclaw/__tests__/dispatcher.test.js.map +1 -0
  1617. package/dist/openclaw/__tests__/index.test.d.ts +6 -0
  1618. package/dist/openclaw/__tests__/index.test.d.ts.map +1 -0
  1619. package/dist/openclaw/__tests__/index.test.js +382 -0
  1620. package/dist/openclaw/__tests__/index.test.js.map +1 -0
  1621. package/dist/openclaw/config.d.ts +59 -0
  1622. package/dist/openclaw/config.d.ts.map +1 -0
  1623. package/dist/openclaw/config.js +400 -0
  1624. package/dist/openclaw/config.js.map +1 -0
  1625. package/dist/openclaw/dispatcher.d.ts +75 -0
  1626. package/dist/openclaw/dispatcher.d.ts.map +1 -0
  1627. package/dist/openclaw/dispatcher.js +223 -0
  1628. package/dist/openclaw/dispatcher.js.map +1 -0
  1629. package/dist/openclaw/index.d.ts +29 -0
  1630. package/dist/openclaw/index.d.ts.map +1 -0
  1631. package/dist/openclaw/index.js +149 -0
  1632. package/dist/openclaw/index.js.map +1 -0
  1633. package/dist/openclaw/types.d.ts +123 -0
  1634. package/dist/openclaw/types.d.ts.map +1 -0
  1635. package/dist/openclaw/types.js +12 -0
  1636. package/dist/openclaw/types.js.map +1 -0
  1637. package/dist/performance-goal/artifacts.d.ts +76 -0
  1638. package/dist/performance-goal/artifacts.d.ts.map +1 -0
  1639. package/dist/performance-goal/artifacts.js +221 -0
  1640. package/dist/performance-goal/artifacts.js.map +1 -0
  1641. package/dist/pipeline/__tests__/orchestrator.test.d.ts +2 -0
  1642. package/dist/pipeline/__tests__/orchestrator.test.d.ts.map +1 -0
  1643. package/dist/pipeline/__tests__/orchestrator.test.js +645 -0
  1644. package/dist/pipeline/__tests__/orchestrator.test.js.map +1 -0
  1645. package/dist/pipeline/__tests__/stages.test.d.ts +2 -0
  1646. package/dist/pipeline/__tests__/stages.test.d.ts.map +1 -0
  1647. package/dist/pipeline/__tests__/stages.test.js +1638 -0
  1648. package/dist/pipeline/__tests__/stages.test.js.map +1 -0
  1649. package/dist/pipeline/index.d.ts +25 -0
  1650. package/dist/pipeline/index.d.ts.map +1 -0
  1651. package/dist/pipeline/index.js +17 -0
  1652. package/dist/pipeline/index.js.map +1 -0
  1653. package/dist/pipeline/orchestrator.d.ts +52 -0
  1654. package/dist/pipeline/orchestrator.d.ts.map +1 -0
  1655. package/dist/pipeline/orchestrator.js +392 -0
  1656. package/dist/pipeline/orchestrator.js.map +1 -0
  1657. package/dist/pipeline/review-verdict.d.ts +3 -0
  1658. package/dist/pipeline/review-verdict.d.ts.map +1 -0
  1659. package/dist/pipeline/review-verdict.js +14 -0
  1660. package/dist/pipeline/review-verdict.js.map +1 -0
  1661. package/dist/pipeline/stages/code-review.d.ts +35 -0
  1662. package/dist/pipeline/stages/code-review.d.ts.map +1 -0
  1663. package/dist/pipeline/stages/code-review.js +55 -0
  1664. package/dist/pipeline/stages/code-review.js.map +1 -0
  1665. package/dist/pipeline/stages/deep-interview.d.ts +15 -0
  1666. package/dist/pipeline/stages/deep-interview.d.ts.map +1 -0
  1667. package/dist/pipeline/stages/deep-interview.js +32 -0
  1668. package/dist/pipeline/stages/deep-interview.js.map +1 -0
  1669. package/dist/pipeline/stages/ralph-verify.d.ts +53 -0
  1670. package/dist/pipeline/stages/ralph-verify.d.ts.map +1 -0
  1671. package/dist/pipeline/stages/ralph-verify.js +89 -0
  1672. package/dist/pipeline/stages/ralph-verify.js.map +1 -0
  1673. package/dist/pipeline/stages/ralplan.d.ts +26 -0
  1674. package/dist/pipeline/stages/ralplan.d.ts.map +1 -0
  1675. package/dist/pipeline/stages/ralplan.js +151 -0
  1676. package/dist/pipeline/stages/ralplan.js.map +1 -0
  1677. package/dist/pipeline/stages/team-exec.d.ts +52 -0
  1678. package/dist/pipeline/stages/team-exec.d.ts.map +1 -0
  1679. package/dist/pipeline/stages/team-exec.js +266 -0
  1680. package/dist/pipeline/stages/team-exec.js.map +1 -0
  1681. package/dist/pipeline/stages/ultragoal.d.ts +19 -0
  1682. package/dist/pipeline/stages/ultragoal.d.ts.map +1 -0
  1683. package/dist/pipeline/stages/ultragoal.js +38 -0
  1684. package/dist/pipeline/stages/ultragoal.js.map +1 -0
  1685. package/dist/pipeline/stages/ultraqa.d.ts +33 -0
  1686. package/dist/pipeline/stages/ultraqa.d.ts.map +1 -0
  1687. package/dist/pipeline/stages/ultraqa.js +49 -0
  1688. package/dist/pipeline/stages/ultraqa.js.map +1 -0
  1689. package/dist/pipeline/types.d.ts +124 -0
  1690. package/dist/pipeline/types.d.ts.map +1 -0
  1691. package/dist/pipeline/types.js +8 -0
  1692. package/dist/pipeline/types.js.map +1 -0
  1693. package/dist/planning/__tests__/approved-execution-lifecycle-matrix.test.d.ts +2 -0
  1694. package/dist/planning/__tests__/approved-execution-lifecycle-matrix.test.d.ts.map +1 -0
  1695. package/dist/planning/__tests__/approved-execution-lifecycle-matrix.test.js +158 -0
  1696. package/dist/planning/__tests__/approved-execution-lifecycle-matrix.test.js.map +1 -0
  1697. package/dist/planning/__tests__/approved-launch-hint-lineage-matrix.test.d.ts +2 -0
  1698. package/dist/planning/__tests__/approved-launch-hint-lineage-matrix.test.d.ts.map +1 -0
  1699. package/dist/planning/__tests__/approved-launch-hint-lineage-matrix.test.js +440 -0
  1700. package/dist/planning/__tests__/approved-launch-hint-lineage-matrix.test.js.map +1 -0
  1701. package/dist/planning/__tests__/artifacts.test.d.ts +2 -0
  1702. package/dist/planning/__tests__/artifacts.test.d.ts.map +1 -0
  1703. package/dist/planning/__tests__/artifacts.test.js +942 -0
  1704. package/dist/planning/__tests__/artifacts.test.js.map +1 -0
  1705. package/dist/planning/__tests__/markdown-structure.test.d.ts +2 -0
  1706. package/dist/planning/__tests__/markdown-structure.test.d.ts.map +1 -0
  1707. package/dist/planning/__tests__/markdown-structure.test.js +459 -0
  1708. package/dist/planning/__tests__/markdown-structure.test.js.map +1 -0
  1709. package/dist/planning/artifact-names.d.ts +13 -0
  1710. package/dist/planning/artifact-names.d.ts.map +1 -0
  1711. package/dist/planning/artifact-names.js +108 -0
  1712. package/dist/planning/artifact-names.js.map +1 -0
  1713. package/dist/planning/artifacts.d.ts +65 -0
  1714. package/dist/planning/artifacts.d.ts.map +1 -0
  1715. package/dist/planning/artifacts.js +561 -0
  1716. package/dist/planning/artifacts.js.map +1 -0
  1717. package/dist/planning/markdown-structure.d.ts +20 -0
  1718. package/dist/planning/markdown-structure.d.ts.map +1 -0
  1719. package/dist/planning/markdown-structure.js +137 -0
  1720. package/dist/planning/markdown-structure.js.map +1 -0
  1721. package/dist/question/__tests__/client.test.d.ts +2 -0
  1722. package/dist/question/__tests__/client.test.d.ts.map +1 -0
  1723. package/dist/question/__tests__/client.test.js +90 -0
  1724. package/dist/question/__tests__/client.test.js.map +1 -0
  1725. package/dist/question/__tests__/deep-interview.test.d.ts +2 -0
  1726. package/dist/question/__tests__/deep-interview.test.d.ts.map +1 -0
  1727. package/dist/question/__tests__/deep-interview.test.js +440 -0
  1728. package/dist/question/__tests__/deep-interview.test.js.map +1 -0
  1729. package/dist/question/__tests__/policy.test.d.ts +2 -0
  1730. package/dist/question/__tests__/policy.test.d.ts.map +1 -0
  1731. package/dist/question/__tests__/policy.test.js +273 -0
  1732. package/dist/question/__tests__/policy.test.js.map +1 -0
  1733. package/dist/question/__tests__/renderer.test.d.ts +2 -0
  1734. package/dist/question/__tests__/renderer.test.d.ts.map +1 -0
  1735. package/dist/question/__tests__/renderer.test.js +1461 -0
  1736. package/dist/question/__tests__/renderer.test.js.map +1 -0
  1737. package/dist/question/__tests__/state.test.d.ts +2 -0
  1738. package/dist/question/__tests__/state.test.d.ts.map +1 -0
  1739. package/dist/question/__tests__/state.test.js +541 -0
  1740. package/dist/question/__tests__/state.test.js.map +1 -0
  1741. package/dist/question/__tests__/types.test.d.ts +2 -0
  1742. package/dist/question/__tests__/types.test.d.ts.map +1 -0
  1743. package/dist/question/__tests__/types.test.js +65 -0
  1744. package/dist/question/__tests__/types.test.js.map +1 -0
  1745. package/dist/question/__tests__/ui.test.d.ts +2 -0
  1746. package/dist/question/__tests__/ui.test.d.ts.map +1 -0
  1747. package/dist/question/__tests__/ui.test.js +483 -0
  1748. package/dist/question/__tests__/ui.test.js.map +1 -0
  1749. package/dist/question/autopilot-wait.d.ts +21 -0
  1750. package/dist/question/autopilot-wait.d.ts.map +1 -0
  1751. package/dist/question/autopilot-wait.js +251 -0
  1752. package/dist/question/autopilot-wait.js.map +1 -0
  1753. package/dist/question/client.d.ts +64 -0
  1754. package/dist/question/client.d.ts.map +1 -0
  1755. package/dist/question/client.js +77 -0
  1756. package/dist/question/client.js.map +1 -0
  1757. package/dist/question/deep-interview.d.ts +33 -0
  1758. package/dist/question/deep-interview.d.ts.map +1 -0
  1759. package/dist/question/deep-interview.js +216 -0
  1760. package/dist/question/deep-interview.js.map +1 -0
  1761. package/dist/question/events.d.ts +53 -0
  1762. package/dist/question/events.d.ts.map +1 -0
  1763. package/dist/question/events.js +201 -0
  1764. package/dist/question/events.js.map +1 -0
  1765. package/dist/question/policy.d.ts +19 -0
  1766. package/dist/question/policy.d.ts.map +1 -0
  1767. package/dist/question/policy.js +95 -0
  1768. package/dist/question/policy.js.map +1 -0
  1769. package/dist/question/renderer.d.ts +66 -0
  1770. package/dist/question/renderer.d.ts.map +1 -0
  1771. package/dist/question/renderer.js +748 -0
  1772. package/dist/question/renderer.js.map +1 -0
  1773. package/dist/question/state.d.ts +56 -0
  1774. package/dist/question/state.d.ts.map +1 -0
  1775. package/dist/question/state.js +432 -0
  1776. package/dist/question/state.js.map +1 -0
  1777. package/dist/question/types.d.ts +92 -0
  1778. package/dist/question/types.d.ts.map +1 -0
  1779. package/dist/question/types.js +117 -0
  1780. package/dist/question/types.js.map +1 -0
  1781. package/dist/question/ui.d.ts +66 -0
  1782. package/dist/question/ui.d.ts.map +1 -0
  1783. package/dist/question/ui.js +458 -0
  1784. package/dist/question/ui.js.map +1 -0
  1785. package/dist/ralph/__tests__/completion-audit.test.d.ts +2 -0
  1786. package/dist/ralph/__tests__/completion-audit.test.d.ts.map +1 -0
  1787. package/dist/ralph/__tests__/completion-audit.test.js +160 -0
  1788. package/dist/ralph/__tests__/completion-audit.test.js.map +1 -0
  1789. package/dist/ralph/__tests__/persistence.test.d.ts +2 -0
  1790. package/dist/ralph/__tests__/persistence.test.d.ts.map +1 -0
  1791. package/dist/ralph/__tests__/persistence.test.js +116 -0
  1792. package/dist/ralph/__tests__/persistence.test.js.map +1 -0
  1793. package/dist/ralph/completion-audit.d.ts +8 -0
  1794. package/dist/ralph/completion-audit.d.ts.map +1 -0
  1795. package/dist/ralph/completion-audit.js +99 -0
  1796. package/dist/ralph/completion-audit.js.map +1 -0
  1797. package/dist/ralph/contract.d.ts +17 -0
  1798. package/dist/ralph/contract.d.ts.map +1 -0
  1799. package/dist/ralph/contract.js +108 -0
  1800. package/dist/ralph/contract.js.map +1 -0
  1801. package/dist/ralph/persistence.d.ts +29 -0
  1802. package/dist/ralph/persistence.d.ts.map +1 -0
  1803. package/dist/ralph/persistence.js +273 -0
  1804. package/dist/ralph/persistence.js.map +1 -0
  1805. package/dist/ralplan/__tests__/consensus-gate.test.d.ts +2 -0
  1806. package/dist/ralplan/__tests__/consensus-gate.test.d.ts.map +1 -0
  1807. package/dist/ralplan/__tests__/consensus-gate.test.js +192 -0
  1808. package/dist/ralplan/__tests__/consensus-gate.test.js.map +1 -0
  1809. package/dist/ralplan/__tests__/runtime.test.d.ts +2 -0
  1810. package/dist/ralplan/__tests__/runtime.test.d.ts.map +1 -0
  1811. package/dist/ralplan/__tests__/runtime.test.js +548 -0
  1812. package/dist/ralplan/__tests__/runtime.test.js.map +1 -0
  1813. package/dist/ralplan/consensus-gate.d.ts +37 -0
  1814. package/dist/ralplan/consensus-gate.d.ts.map +1 -0
  1815. package/dist/ralplan/consensus-gate.js +422 -0
  1816. package/dist/ralplan/consensus-gate.js.map +1 -0
  1817. package/dist/ralplan/runtime.d.ts +86 -0
  1818. package/dist/ralplan/runtime.d.ts.map +1 -0
  1819. package/dist/ralplan/runtime.js +365 -0
  1820. package/dist/ralplan/runtime.js.map +1 -0
  1821. package/dist/runtime/__tests__/bridge.test.d.ts +2 -0
  1822. package/dist/runtime/__tests__/bridge.test.d.ts.map +1 -0
  1823. package/dist/runtime/__tests__/bridge.test.js +194 -0
  1824. package/dist/runtime/__tests__/bridge.test.js.map +1 -0
  1825. package/dist/runtime/__tests__/process-tree.test.d.ts +2 -0
  1826. package/dist/runtime/__tests__/process-tree.test.d.ts.map +1 -0
  1827. package/dist/runtime/__tests__/process-tree.test.js +107 -0
  1828. package/dist/runtime/__tests__/process-tree.test.js.map +1 -0
  1829. package/dist/runtime/__tests__/run-loop.test.d.ts +2 -0
  1830. package/dist/runtime/__tests__/run-loop.test.d.ts.map +1 -0
  1831. package/dist/runtime/__tests__/run-loop.test.js +35 -0
  1832. package/dist/runtime/__tests__/run-loop.test.js.map +1 -0
  1833. package/dist/runtime/__tests__/run-outcome.test.d.ts +2 -0
  1834. package/dist/runtime/__tests__/run-outcome.test.d.ts.map +1 -0
  1835. package/dist/runtime/__tests__/run-outcome.test.js +102 -0
  1836. package/dist/runtime/__tests__/run-outcome.test.js.map +1 -0
  1837. package/dist/runtime/__tests__/run-state.test.d.ts +2 -0
  1838. package/dist/runtime/__tests__/run-state.test.d.ts.map +1 -0
  1839. package/dist/runtime/__tests__/run-state.test.js +37 -0
  1840. package/dist/runtime/__tests__/run-state.test.js.map +1 -0
  1841. package/dist/runtime/bridge.d.ts +214 -0
  1842. package/dist/runtime/bridge.d.ts.map +1 -0
  1843. package/dist/runtime/bridge.js +223 -0
  1844. package/dist/runtime/bridge.js.map +1 -0
  1845. package/dist/runtime/process-tree.d.ts +28 -0
  1846. package/dist/runtime/process-tree.d.ts.map +1 -0
  1847. package/dist/runtime/process-tree.js +230 -0
  1848. package/dist/runtime/process-tree.js.map +1 -0
  1849. package/dist/runtime/run-loop.d.ts +45 -0
  1850. package/dist/runtime/run-loop.d.ts.map +1 -0
  1851. package/dist/runtime/run-loop.js +51 -0
  1852. package/dist/runtime/run-loop.js.map +1 -0
  1853. package/dist/runtime/run-outcome.d.ts +46 -0
  1854. package/dist/runtime/run-outcome.d.ts.map +1 -0
  1855. package/dist/runtime/run-outcome.js +285 -0
  1856. package/dist/runtime/run-outcome.js.map +1 -0
  1857. package/dist/runtime/run-state.d.ts +40 -0
  1858. package/dist/runtime/run-state.d.ts.map +1 -0
  1859. package/dist/runtime/run-state.js +120 -0
  1860. package/dist/runtime/run-state.js.map +1 -0
  1861. package/dist/runtime/terminal-lifecycle.d.ts +11 -0
  1862. package/dist/runtime/terminal-lifecycle.d.ts.map +1 -0
  1863. package/dist/runtime/terminal-lifecycle.js +52 -0
  1864. package/dist/runtime/terminal-lifecycle.js.map +1 -0
  1865. package/dist/scripts/__tests__/codex-native-hook.test.d.ts +2 -0
  1866. package/dist/scripts/__tests__/codex-native-hook.test.d.ts.map +1 -0
  1867. package/dist/scripts/__tests__/codex-native-hook.test.js +14253 -0
  1868. package/dist/scripts/__tests__/codex-native-hook.test.js.map +1 -0
  1869. package/dist/scripts/__tests__/docs-site-contract.test.d.ts +2 -0
  1870. package/dist/scripts/__tests__/docs-site-contract.test.d.ts.map +1 -0
  1871. package/dist/scripts/__tests__/docs-site-contract.test.js +42 -0
  1872. package/dist/scripts/__tests__/docs-site-contract.test.js.map +1 -0
  1873. package/dist/scripts/__tests__/generate-release-body.test.d.ts +2 -0
  1874. package/dist/scripts/__tests__/generate-release-body.test.d.ts.map +1 -0
  1875. package/dist/scripts/__tests__/generate-release-body.test.js +233 -0
  1876. package/dist/scripts/__tests__/generate-release-body.test.js.map +1 -0
  1877. package/dist/scripts/__tests__/hook-derived-watcher.test.d.ts +2 -0
  1878. package/dist/scripts/__tests__/hook-derived-watcher.test.d.ts.map +1 -0
  1879. package/dist/scripts/__tests__/hook-derived-watcher.test.js +227 -0
  1880. package/dist/scripts/__tests__/hook-derived-watcher.test.js.map +1 -0
  1881. package/dist/scripts/__tests__/notify-dispatcher.test.d.ts +2 -0
  1882. package/dist/scripts/__tests__/notify-dispatcher.test.d.ts.map +1 -0
  1883. package/dist/scripts/__tests__/notify-dispatcher.test.js +421 -0
  1884. package/dist/scripts/__tests__/notify-dispatcher.test.js.map +1 -0
  1885. package/dist/scripts/__tests__/notify-state-io.test.d.ts +2 -0
  1886. package/dist/scripts/__tests__/notify-state-io.test.d.ts.map +1 -0
  1887. package/dist/scripts/__tests__/notify-state-io.test.js +111 -0
  1888. package/dist/scripts/__tests__/notify-state-io.test.js.map +1 -0
  1889. package/dist/scripts/__tests__/notify-tmux-injection.test.d.ts +2 -0
  1890. package/dist/scripts/__tests__/notify-tmux-injection.test.d.ts.map +1 -0
  1891. package/dist/scripts/__tests__/notify-tmux-injection.test.js +57 -0
  1892. package/dist/scripts/__tests__/notify-tmux-injection.test.js.map +1 -0
  1893. package/dist/scripts/__tests__/postinstall.test.d.ts +2 -0
  1894. package/dist/scripts/__tests__/postinstall.test.d.ts.map +1 -0
  1895. package/dist/scripts/__tests__/postinstall.test.js +92 -0
  1896. package/dist/scripts/__tests__/postinstall.test.js.map +1 -0
  1897. package/dist/scripts/__tests__/prompt-inventory.test.d.ts +2 -0
  1898. package/dist/scripts/__tests__/prompt-inventory.test.d.ts.map +1 -0
  1899. package/dist/scripts/__tests__/prompt-inventory.test.js +56 -0
  1900. package/dist/scripts/__tests__/prompt-inventory.test.js.map +1 -0
  1901. package/dist/scripts/__tests__/run-test-files.test.d.ts +2 -0
  1902. package/dist/scripts/__tests__/run-test-files.test.d.ts.map +1 -0
  1903. package/dist/scripts/__tests__/run-test-files.test.js +365 -0
  1904. package/dist/scripts/__tests__/run-test-files.test.js.map +1 -0
  1905. package/dist/scripts/__tests__/smoke-packed-install.test.d.ts +2 -0
  1906. package/dist/scripts/__tests__/smoke-packed-install.test.d.ts.map +1 -0
  1907. package/dist/scripts/__tests__/smoke-packed-install.test.js +160 -0
  1908. package/dist/scripts/__tests__/smoke-packed-install.test.js.map +1 -0
  1909. package/dist/scripts/__tests__/test-reply-listener-live.test.d.ts +2 -0
  1910. package/dist/scripts/__tests__/test-reply-listener-live.test.d.ts.map +1 -0
  1911. package/dist/scripts/__tests__/test-reply-listener-live.test.js +82 -0
  1912. package/dist/scripts/__tests__/test-reply-listener-live.test.js.map +1 -0
  1913. package/dist/scripts/__tests__/verify-native-agents.test.d.ts +2 -0
  1914. package/dist/scripts/__tests__/verify-native-agents.test.d.ts.map +1 -0
  1915. package/dist/scripts/__tests__/verify-native-agents.test.js +246 -0
  1916. package/dist/scripts/__tests__/verify-native-agents.test.js.map +1 -0
  1917. package/dist/scripts/build-api.d.ts +2 -0
  1918. package/dist/scripts/build-api.d.ts.map +1 -0
  1919. package/dist/scripts/build-api.js +44 -0
  1920. package/dist/scripts/build-api.js.map +1 -0
  1921. package/dist/scripts/build-explore-harness.d.ts +3 -0
  1922. package/dist/scripts/build-explore-harness.d.ts.map +1 -0
  1923. package/dist/scripts/build-explore-harness.js +50 -0
  1924. package/dist/scripts/build-explore-harness.js.map +1 -0
  1925. package/dist/scripts/build-sparkshell.d.ts +2 -0
  1926. package/dist/scripts/build-sparkshell.d.ts.map +1 -0
  1927. package/dist/scripts/build-sparkshell.js +46 -0
  1928. package/dist/scripts/build-sparkshell.js.map +1 -0
  1929. package/dist/scripts/check-runtime-syntax.d.ts +3 -0
  1930. package/dist/scripts/check-runtime-syntax.d.ts.map +1 -0
  1931. package/dist/scripts/check-runtime-syntax.js +57 -0
  1932. package/dist/scripts/check-runtime-syntax.js.map +1 -0
  1933. package/dist/scripts/check-version-sync.d.ts +3 -0
  1934. package/dist/scripts/check-version-sync.d.ts.map +1 -0
  1935. package/dist/scripts/check-version-sync.js +53 -0
  1936. package/dist/scripts/check-version-sync.js.map +1 -0
  1937. package/dist/scripts/cleanup-explore-harness.d.ts +3 -0
  1938. package/dist/scripts/cleanup-explore-harness.d.ts.map +1 -0
  1939. package/dist/scripts/cleanup-explore-harness.js +17 -0
  1940. package/dist/scripts/cleanup-explore-harness.js.map +1 -0
  1941. package/dist/scripts/codex-execution-surface.d.ts +16 -0
  1942. package/dist/scripts/codex-execution-surface.d.ts.map +1 -0
  1943. package/dist/scripts/codex-execution-surface.js +42 -0
  1944. package/dist/scripts/codex-execution-surface.js.map +1 -0
  1945. package/dist/scripts/codex-native-hook.d.ts +26 -0
  1946. package/dist/scripts/codex-native-hook.d.ts.map +1 -0
  1947. package/dist/scripts/codex-native-hook.js +3842 -0
  1948. package/dist/scripts/codex-native-hook.js.map +1 -0
  1949. package/dist/scripts/codex-native-pre-post.d.ts +46 -0
  1950. package/dist/scripts/codex-native-pre-post.d.ts.map +1 -0
  1951. package/dist/scripts/codex-native-pre-post.js +1186 -0
  1952. package/dist/scripts/codex-native-pre-post.js.map +1 -0
  1953. package/dist/scripts/eval/eval-candidate-handoff.d.ts +2 -0
  1954. package/dist/scripts/eval/eval-candidate-handoff.d.ts.map +1 -0
  1955. package/dist/scripts/eval/eval-candidate-handoff.js +11 -0
  1956. package/dist/scripts/eval/eval-candidate-handoff.js.map +1 -0
  1957. package/dist/scripts/eval/eval-cli-discoverability.d.ts +3 -0
  1958. package/dist/scripts/eval/eval-cli-discoverability.d.ts.map +1 -0
  1959. package/dist/scripts/eval/eval-cli-discoverability.js +37 -0
  1960. package/dist/scripts/eval/eval-cli-discoverability.js.map +1 -0
  1961. package/dist/scripts/eval/eval-fresh-run-tagging.d.ts +2 -0
  1962. package/dist/scripts/eval/eval-fresh-run-tagging.d.ts.map +1 -0
  1963. package/dist/scripts/eval/eval-fresh-run-tagging.js +11 -0
  1964. package/dist/scripts/eval/eval-fresh-run-tagging.js.map +1 -0
  1965. package/dist/scripts/eval/eval-help-consistency.d.ts +2 -0
  1966. package/dist/scripts/eval/eval-help-consistency.d.ts.map +1 -0
  1967. package/dist/scripts/eval/eval-help-consistency.js +12 -0
  1968. package/dist/scripts/eval/eval-help-consistency.js.map +1 -0
  1969. package/dist/scripts/eval/eval-in-action-cat-shellout-demo.d.ts +2 -0
  1970. package/dist/scripts/eval/eval-in-action-cat-shellout-demo.d.ts.map +1 -0
  1971. package/dist/scripts/eval/eval-in-action-cat-shellout-demo.js +31 -0
  1972. package/dist/scripts/eval/eval-in-action-cat-shellout-demo.js.map +1 -0
  1973. package/dist/scripts/eval/eval-parity-smoke.d.ts +2 -0
  1974. package/dist/scripts/eval/eval-parity-smoke.d.ts.map +1 -0
  1975. package/dist/scripts/eval/eval-parity-smoke.js +23 -0
  1976. package/dist/scripts/eval/eval-parity-smoke.js.map +1 -0
  1977. package/dist/scripts/eval/eval-parity-sweep.d.ts +2 -0
  1978. package/dist/scripts/eval/eval-parity-sweep.d.ts.map +1 -0
  1979. package/dist/scripts/eval/eval-parity-sweep.js +29 -0
  1980. package/dist/scripts/eval/eval-parity-sweep.js.map +1 -0
  1981. package/dist/scripts/eval/eval-resume-dirty-guard.d.ts +2 -0
  1982. package/dist/scripts/eval/eval-resume-dirty-guard.d.ts.map +1 -0
  1983. package/dist/scripts/eval/eval-resume-dirty-guard.js +11 -0
  1984. package/dist/scripts/eval/eval-resume-dirty-guard.js.map +1 -0
  1985. package/dist/scripts/eval/eval-security-path-traversal.d.ts +3 -0
  1986. package/dist/scripts/eval/eval-security-path-traversal.d.ts.map +1 -0
  1987. package/dist/scripts/eval/eval-security-path-traversal.js +35 -0
  1988. package/dist/scripts/eval/eval-security-path-traversal.js.map +1 -0
  1989. package/dist/scripts/fixtures/ask-advisor-stub.d.ts +3 -0
  1990. package/dist/scripts/fixtures/ask-advisor-stub.d.ts.map +1 -0
  1991. package/dist/scripts/fixtures/ask-advisor-stub.js +13 -0
  1992. package/dist/scripts/fixtures/ask-advisor-stub.js.map +1 -0
  1993. package/dist/scripts/generate-catalog-docs.d.ts +3 -0
  1994. package/dist/scripts/generate-catalog-docs.d.ts.map +1 -0
  1995. package/dist/scripts/generate-catalog-docs.js +99 -0
  1996. package/dist/scripts/generate-catalog-docs.js.map +1 -0
  1997. package/dist/scripts/generate-native-release-manifest.d.ts +3 -0
  1998. package/dist/scripts/generate-native-release-manifest.d.ts.map +1 -0
  1999. package/dist/scripts/generate-native-release-manifest.js +107 -0
  2000. package/dist/scripts/generate-native-release-manifest.js.map +1 -0
  2001. package/dist/scripts/generate-release-body.d.ts +35 -0
  2002. package/dist/scripts/generate-release-body.d.ts.map +1 -0
  2003. package/dist/scripts/generate-release-body.js +278 -0
  2004. package/dist/scripts/generate-release-body.js.map +1 -0
  2005. package/dist/scripts/hook-derived-watcher.d.ts +3 -0
  2006. package/dist/scripts/hook-derived-watcher.d.ts.map +1 -0
  2007. package/dist/scripts/hook-derived-watcher.js +557 -0
  2008. package/dist/scripts/hook-derived-watcher.js.map +1 -0
  2009. package/dist/scripts/hook-payload-guard.d.ts +9 -0
  2010. package/dist/scripts/hook-payload-guard.d.ts.map +1 -0
  2011. package/dist/scripts/hook-payload-guard.js +111 -0
  2012. package/dist/scripts/hook-payload-guard.js.map +1 -0
  2013. package/dist/scripts/notify-dispatcher.d.ts +7 -0
  2014. package/dist/scripts/notify-dispatcher.d.ts.map +1 -0
  2015. package/dist/scripts/notify-dispatcher.js +359 -0
  2016. package/dist/scripts/notify-dispatcher.js.map +1 -0
  2017. package/dist/scripts/notify-fallback-watcher.d.ts +3 -0
  2018. package/dist/scripts/notify-fallback-watcher.d.ts.map +1 -0
  2019. package/dist/scripts/notify-fallback-watcher.js +1771 -0
  2020. package/dist/scripts/notify-fallback-watcher.js.map +1 -0
  2021. package/dist/scripts/notify-hook/__tests__/operational-events.test.d.ts +2 -0
  2022. package/dist/scripts/notify-hook/__tests__/operational-events.test.d.ts.map +1 -0
  2023. package/dist/scripts/notify-hook/__tests__/operational-events.test.js +24 -0
  2024. package/dist/scripts/notify-hook/__tests__/operational-events.test.js.map +1 -0
  2025. package/dist/scripts/notify-hook/__tests__/payload-guard.test.d.ts +2 -0
  2026. package/dist/scripts/notify-hook/__tests__/payload-guard.test.d.ts.map +1 -0
  2027. package/dist/scripts/notify-hook/__tests__/payload-guard.test.js +39 -0
  2028. package/dist/scripts/notify-hook/__tests__/payload-guard.test.js.map +1 -0
  2029. package/dist/scripts/notify-hook/__tests__/team-worker-posttooluse.test.d.ts +2 -0
  2030. package/dist/scripts/notify-hook/__tests__/team-worker-posttooluse.test.d.ts.map +1 -0
  2031. package/dist/scripts/notify-hook/__tests__/team-worker-posttooluse.test.js +153 -0
  2032. package/dist/scripts/notify-hook/__tests__/team-worker-posttooluse.test.js.map +1 -0
  2033. package/dist/scripts/notify-hook/active-team.d.ts +9 -0
  2034. package/dist/scripts/notify-hook/active-team.d.ts.map +1 -0
  2035. package/dist/scripts/notify-hook/active-team.js +45 -0
  2036. package/dist/scripts/notify-hook/active-team.js.map +1 -0
  2037. package/dist/scripts/notify-hook/auto-nudge.d.ts +96 -0
  2038. package/dist/scripts/notify-hook/auto-nudge.d.ts.map +1 -0
  2039. package/dist/scripts/notify-hook/auto-nudge.js +698 -0
  2040. package/dist/scripts/notify-hook/auto-nudge.js.map +1 -0
  2041. package/dist/scripts/notify-hook/log.d.ts +6 -0
  2042. package/dist/scripts/notify-hook/log.d.ts.map +1 -0
  2043. package/dist/scripts/notify-hook/log.js +22 -0
  2044. package/dist/scripts/notify-hook/log.js.map +1 -0
  2045. package/dist/scripts/notify-hook/managed-tmux.d.ts +21 -0
  2046. package/dist/scripts/notify-hook/managed-tmux.d.ts.map +1 -0
  2047. package/dist/scripts/notify-hook/managed-tmux.js +541 -0
  2048. package/dist/scripts/notify-hook/managed-tmux.js.map +1 -0
  2049. package/dist/scripts/notify-hook/operational-events.d.ts +14 -0
  2050. package/dist/scripts/notify-hook/operational-events.d.ts.map +1 -0
  2051. package/dist/scripts/notify-hook/operational-events.js +255 -0
  2052. package/dist/scripts/notify-hook/operational-events.js.map +1 -0
  2053. package/dist/scripts/notify-hook/orchestration-intent.d.ts +17 -0
  2054. package/dist/scripts/notify-hook/orchestration-intent.d.ts.map +1 -0
  2055. package/dist/scripts/notify-hook/orchestration-intent.js +71 -0
  2056. package/dist/scripts/notify-hook/orchestration-intent.js.map +1 -0
  2057. package/dist/scripts/notify-hook/payload-parser.d.ts +13 -0
  2058. package/dist/scripts/notify-hook/payload-parser.d.ts.map +1 -0
  2059. package/dist/scripts/notify-hook/payload-parser.js +134 -0
  2060. package/dist/scripts/notify-hook/payload-parser.js.map +1 -0
  2061. package/dist/scripts/notify-hook/process-runner.d.ts +9 -0
  2062. package/dist/scripts/notify-hook/process-runner.d.ts.map +1 -0
  2063. package/dist/scripts/notify-hook/process-runner.js +74 -0
  2064. package/dist/scripts/notify-hook/process-runner.js.map +1 -0
  2065. package/dist/scripts/notify-hook/ralph-session-resume.d.ts +22 -0
  2066. package/dist/scripts/notify-hook/ralph-session-resume.d.ts.map +1 -0
  2067. package/dist/scripts/notify-hook/ralph-session-resume.js +381 -0
  2068. package/dist/scripts/notify-hook/ralph-session-resume.js.map +1 -0
  2069. package/dist/scripts/notify-hook/state-io.d.ts +21 -0
  2070. package/dist/scripts/notify-hook/state-io.d.ts.map +1 -0
  2071. package/dist/scripts/notify-hook/state-io.js +169 -0
  2072. package/dist/scripts/notify-hook/state-io.js.map +1 -0
  2073. package/dist/scripts/notify-hook/team-dispatch.d.ts +36 -0
  2074. package/dist/scripts/notify-hook/team-dispatch.d.ts.map +1 -0
  2075. package/dist/scripts/notify-hook/team-dispatch.js +1084 -0
  2076. package/dist/scripts/notify-hook/team-dispatch.js.map +1 -0
  2077. package/dist/scripts/notify-hook/team-leader-nudge.d.ts +21 -0
  2078. package/dist/scripts/notify-hook/team-leader-nudge.d.ts.map +1 -0
  2079. package/dist/scripts/notify-hook/team-leader-nudge.js +1029 -0
  2080. package/dist/scripts/notify-hook/team-leader-nudge.js.map +1 -0
  2081. package/dist/scripts/notify-hook/team-tmux-guard.d.ts +15 -0
  2082. package/dist/scripts/notify-hook/team-tmux-guard.d.ts.map +1 -0
  2083. package/dist/scripts/notify-hook/team-tmux-guard.js +205 -0
  2084. package/dist/scripts/notify-hook/team-tmux-guard.js.map +1 -0
  2085. package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts +34 -0
  2086. package/dist/scripts/notify-hook/team-worker-posttooluse.d.ts.map +1 -0
  2087. package/dist/scripts/notify-hook/team-worker-posttooluse.js +434 -0
  2088. package/dist/scripts/notify-hook/team-worker-posttooluse.js.map +1 -0
  2089. package/dist/scripts/notify-hook/team-worker-stop.d.ts +15 -0
  2090. package/dist/scripts/notify-hook/team-worker-stop.d.ts.map +1 -0
  2091. package/dist/scripts/notify-hook/team-worker-stop.js +418 -0
  2092. package/dist/scripts/notify-hook/team-worker-stop.js.map +1 -0
  2093. package/dist/scripts/notify-hook/team-worker.d.ts +33 -0
  2094. package/dist/scripts/notify-hook/team-worker.d.ts.map +1 -0
  2095. package/dist/scripts/notify-hook/team-worker.js +705 -0
  2096. package/dist/scripts/notify-hook/team-worker.js.map +1 -0
  2097. package/dist/scripts/notify-hook/tmux-injection.d.ts +15 -0
  2098. package/dist/scripts/notify-hook/tmux-injection.d.ts.map +1 -0
  2099. package/dist/scripts/notify-hook/tmux-injection.js +673 -0
  2100. package/dist/scripts/notify-hook/tmux-injection.js.map +1 -0
  2101. package/dist/scripts/notify-hook/utils.d.ts +9 -0
  2102. package/dist/scripts/notify-hook/utils.d.ts.map +1 -0
  2103. package/dist/scripts/notify-hook/utils.js +36 -0
  2104. package/dist/scripts/notify-hook/utils.js.map +1 -0
  2105. package/dist/scripts/notify-hook/visual-verdict.d.ts +29 -0
  2106. package/dist/scripts/notify-hook/visual-verdict.d.ts.map +1 -0
  2107. package/dist/scripts/notify-hook/visual-verdict.js +145 -0
  2108. package/dist/scripts/notify-hook/visual-verdict.js.map +1 -0
  2109. package/dist/scripts/notify-hook.d.ts +20 -0
  2110. package/dist/scripts/notify-hook.d.ts.map +1 -0
  2111. package/dist/scripts/notify-hook.js +950 -0
  2112. package/dist/scripts/notify-hook.js.map +1 -0
  2113. package/dist/scripts/postinstall.d.ts +18 -0
  2114. package/dist/scripts/postinstall.d.ts.map +1 -0
  2115. package/dist/scripts/postinstall.js +66 -0
  2116. package/dist/scripts/postinstall.js.map +1 -0
  2117. package/dist/scripts/prompt-inventory.d.ts +29 -0
  2118. package/dist/scripts/prompt-inventory.d.ts.map +1 -0
  2119. package/dist/scripts/prompt-inventory.js +178 -0
  2120. package/dist/scripts/prompt-inventory.js.map +1 -0
  2121. package/dist/scripts/run-provider-advisor.d.ts +3 -0
  2122. package/dist/scripts/run-provider-advisor.d.ts.map +1 -0
  2123. package/dist/scripts/run-provider-advisor.js +177 -0
  2124. package/dist/scripts/run-provider-advisor.js.map +1 -0
  2125. package/dist/scripts/run-test-files.d.ts +2 -0
  2126. package/dist/scripts/run-test-files.d.ts.map +1 -0
  2127. package/dist/scripts/run-test-files.js +340 -0
  2128. package/dist/scripts/run-test-files.js.map +1 -0
  2129. package/dist/scripts/smoke-packed-install.d.ts +21 -0
  2130. package/dist/scripts/smoke-packed-install.d.ts.map +1 -0
  2131. package/dist/scripts/smoke-packed-install.js +221 -0
  2132. package/dist/scripts/smoke-packed-install.js.map +1 -0
  2133. package/dist/scripts/sync-plugin-mirror.d.ts +14 -0
  2134. package/dist/scripts/sync-plugin-mirror.d.ts.map +1 -0
  2135. package/dist/scripts/sync-plugin-mirror.js +306 -0
  2136. package/dist/scripts/sync-plugin-mirror.js.map +1 -0
  2137. package/dist/scripts/sync-prompt-guidance-fragments.d.ts +3 -0
  2138. package/dist/scripts/sync-prompt-guidance-fragments.d.ts.map +1 -0
  2139. package/dist/scripts/sync-prompt-guidance-fragments.js +50 -0
  2140. package/dist/scripts/sync-prompt-guidance-fragments.js.map +1 -0
  2141. package/dist/scripts/team-hardening-benchmark.d.ts +3 -0
  2142. package/dist/scripts/team-hardening-benchmark.d.ts.map +1 -0
  2143. package/dist/scripts/team-hardening-benchmark.js +91 -0
  2144. package/dist/scripts/team-hardening-benchmark.js.map +1 -0
  2145. package/dist/scripts/test-reply-listener-live.d.ts +24 -0
  2146. package/dist/scripts/test-reply-listener-live.d.ts.map +1 -0
  2147. package/dist/scripts/test-reply-listener-live.js +138 -0
  2148. package/dist/scripts/test-reply-listener-live.js.map +1 -0
  2149. package/dist/scripts/test-sparkshell.d.ts +2 -0
  2150. package/dist/scripts/test-sparkshell.d.ts.map +1 -0
  2151. package/dist/scripts/test-sparkshell.js +25 -0
  2152. package/dist/scripts/test-sparkshell.js.map +1 -0
  2153. package/dist/scripts/tmux-hook-engine.d.ts +45 -0
  2154. package/dist/scripts/tmux-hook-engine.d.ts.map +1 -0
  2155. package/dist/scripts/tmux-hook-engine.js +313 -0
  2156. package/dist/scripts/tmux-hook-engine.js.map +1 -0
  2157. package/dist/scripts/verify-native-agents.d.ts +16 -0
  2158. package/dist/scripts/verify-native-agents.d.ts.map +1 -0
  2159. package/dist/scripts/verify-native-agents.js +247 -0
  2160. package/dist/scripts/verify-native-agents.js.map +1 -0
  2161. package/dist/scripts/verify-native-release-assets.d.ts +3 -0
  2162. package/dist/scripts/verify-native-release-assets.d.ts.map +1 -0
  2163. package/dist/scripts/verify-native-release-assets.js +62 -0
  2164. package/dist/scripts/verify-native-release-assets.js.map +1 -0
  2165. package/dist/session-history/__tests__/search.test.d.ts +2 -0
  2166. package/dist/session-history/__tests__/search.test.d.ts.map +1 -0
  2167. package/dist/session-history/__tests__/search.test.js +150 -0
  2168. package/dist/session-history/__tests__/search.test.js.map +1 -0
  2169. package/dist/session-history/search.d.ts +31 -0
  2170. package/dist/session-history/search.d.ts.map +1 -0
  2171. package/dist/session-history/search.js +331 -0
  2172. package/dist/session-history/search.js.map +1 -0
  2173. package/dist/sidecar/__tests__/boundary.test.d.ts +2 -0
  2174. package/dist/sidecar/__tests__/boundary.test.d.ts.map +1 -0
  2175. package/dist/sidecar/__tests__/boundary.test.js +48 -0
  2176. package/dist/sidecar/__tests__/boundary.test.js.map +1 -0
  2177. package/dist/sidecar/__tests__/collector.test.d.ts +2 -0
  2178. package/dist/sidecar/__tests__/collector.test.d.ts.map +1 -0
  2179. package/dist/sidecar/__tests__/collector.test.js +162 -0
  2180. package/dist/sidecar/__tests__/collector.test.js.map +1 -0
  2181. package/dist/sidecar/__tests__/render.test.d.ts +2 -0
  2182. package/dist/sidecar/__tests__/render.test.d.ts.map +1 -0
  2183. package/dist/sidecar/__tests__/render.test.js +67 -0
  2184. package/dist/sidecar/__tests__/render.test.js.map +1 -0
  2185. package/dist/sidecar/__tests__/resource-leak-watch.test.d.ts +2 -0
  2186. package/dist/sidecar/__tests__/resource-leak-watch.test.d.ts.map +1 -0
  2187. package/dist/sidecar/__tests__/resource-leak-watch.test.js +38 -0
  2188. package/dist/sidecar/__tests__/resource-leak-watch.test.js.map +1 -0
  2189. package/dist/sidecar/__tests__/tmux.test.d.ts +2 -0
  2190. package/dist/sidecar/__tests__/tmux.test.d.ts.map +1 -0
  2191. package/dist/sidecar/__tests__/tmux.test.js +30 -0
  2192. package/dist/sidecar/__tests__/tmux.test.js.map +1 -0
  2193. package/dist/sidecar/__tests__/watch.test.d.ts +2 -0
  2194. package/dist/sidecar/__tests__/watch.test.d.ts.map +1 -0
  2195. package/dist/sidecar/__tests__/watch.test.js +42 -0
  2196. package/dist/sidecar/__tests__/watch.test.js.map +1 -0
  2197. package/dist/sidecar/collector.d.ts +4 -0
  2198. package/dist/sidecar/collector.d.ts.map +1 -0
  2199. package/dist/sidecar/collector.js +377 -0
  2200. package/dist/sidecar/collector.js.map +1 -0
  2201. package/dist/sidecar/index.d.ts +25 -0
  2202. package/dist/sidecar/index.d.ts.map +1 -0
  2203. package/dist/sidecar/index.js +182 -0
  2204. package/dist/sidecar/index.js.map +1 -0
  2205. package/dist/sidecar/render.d.ts +3 -0
  2206. package/dist/sidecar/render.d.ts.map +1 -0
  2207. package/dist/sidecar/render.js +72 -0
  2208. package/dist/sidecar/render.js.map +1 -0
  2209. package/dist/sidecar/tmux.d.ts +13 -0
  2210. package/dist/sidecar/tmux.d.ts.map +1 -0
  2211. package/dist/sidecar/tmux.js +44 -0
  2212. package/dist/sidecar/tmux.js.map +1 -0
  2213. package/dist/sidecar/types.d.ts +125 -0
  2214. package/dist/sidecar/types.d.ts.map +1 -0
  2215. package/dist/sidecar/types.js +2 -0
  2216. package/dist/sidecar/types.js.map +1 -0
  2217. package/dist/state/__tests__/mode-state-context.test.d.ts +2 -0
  2218. package/dist/state/__tests__/mode-state-context.test.d.ts.map +1 -0
  2219. package/dist/state/__tests__/mode-state-context.test.js +35 -0
  2220. package/dist/state/__tests__/mode-state-context.test.js.map +1 -0
  2221. package/dist/state/__tests__/operations-ralph-phase.test.d.ts +2 -0
  2222. package/dist/state/__tests__/operations-ralph-phase.test.d.ts.map +1 -0
  2223. package/dist/state/__tests__/operations-ralph-phase.test.js +190 -0
  2224. package/dist/state/__tests__/operations-ralph-phase.test.js.map +1 -0
  2225. package/dist/state/__tests__/operations.test.d.ts +2 -0
  2226. package/dist/state/__tests__/operations.test.d.ts.map +1 -0
  2227. package/dist/state/__tests__/operations.test.js +2753 -0
  2228. package/dist/state/__tests__/operations.test.js.map +1 -0
  2229. package/dist/state/__tests__/path-traversal.test.d.ts +2 -0
  2230. package/dist/state/__tests__/path-traversal.test.d.ts.map +1 -0
  2231. package/dist/state/__tests__/path-traversal.test.js +49 -0
  2232. package/dist/state/__tests__/path-traversal.test.js.map +1 -0
  2233. package/dist/state/__tests__/planning-gate.test.d.ts +2 -0
  2234. package/dist/state/__tests__/planning-gate.test.d.ts.map +1 -0
  2235. package/dist/state/__tests__/planning-gate.test.js +219 -0
  2236. package/dist/state/__tests__/planning-gate.test.js.map +1 -0
  2237. package/dist/state/__tests__/skill-active.test.d.ts +2 -0
  2238. package/dist/state/__tests__/skill-active.test.d.ts.map +1 -0
  2239. package/dist/state/__tests__/skill-active.test.js +314 -0
  2240. package/dist/state/__tests__/skill-active.test.js.map +1 -0
  2241. package/dist/state/__tests__/workflow-transition.test.d.ts +2 -0
  2242. package/dist/state/__tests__/workflow-transition.test.d.ts.map +1 -0
  2243. package/dist/state/__tests__/workflow-transition.test.js +293 -0
  2244. package/dist/state/__tests__/workflow-transition.test.js.map +1 -0
  2245. package/dist/state/mode-state-context.d.ts +14 -0
  2246. package/dist/state/mode-state-context.d.ts.map +1 -0
  2247. package/dist/state/mode-state-context.js +49 -0
  2248. package/dist/state/mode-state-context.js.map +1 -0
  2249. package/dist/state/operations.d.ts +13 -0
  2250. package/dist/state/operations.d.ts.map +1 -0
  2251. package/dist/state/operations.js +544 -0
  2252. package/dist/state/operations.js.map +1 -0
  2253. package/dist/state/paths.d.ts +3 -0
  2254. package/dist/state/paths.d.ts.map +1 -0
  2255. package/dist/state/paths.js +2 -0
  2256. package/dist/state/paths.js.map +1 -0
  2257. package/dist/state/skill-active.d.ts +64 -0
  2258. package/dist/state/skill-active.d.ts.map +1 -0
  2259. package/dist/state/skill-active.js +375 -0
  2260. package/dist/state/skill-active.js.map +1 -0
  2261. package/dist/state/workflow-transition-reconcile.d.ts +22 -0
  2262. package/dist/state/workflow-transition-reconcile.d.ts.map +1 -0
  2263. package/dist/state/workflow-transition-reconcile.js +144 -0
  2264. package/dist/state/workflow-transition-reconcile.js.map +1 -0
  2265. package/dist/state/workflow-transition.d.ts +45 -0
  2266. package/dist/state/workflow-transition.d.ts.map +1 -0
  2267. package/dist/state/workflow-transition.js +268 -0
  2268. package/dist/state/workflow-transition.js.map +1 -0
  2269. package/dist/subagents/__tests__/tracker.test.d.ts +2 -0
  2270. package/dist/subagents/__tests__/tracker.test.d.ts.map +1 -0
  2271. package/dist/subagents/__tests__/tracker.test.js +255 -0
  2272. package/dist/subagents/__tests__/tracker.test.js.map +1 -0
  2273. package/dist/subagents/tracker.d.ts +60 -0
  2274. package/dist/subagents/tracker.d.ts.map +1 -0
  2275. package/dist/subagents/tracker.js +229 -0
  2276. package/dist/subagents/tracker.js.map +1 -0
  2277. package/dist/team/__tests__/allocation-policy.test.d.ts +2 -0
  2278. package/dist/team/__tests__/allocation-policy.test.d.ts.map +1 -0
  2279. package/dist/team/__tests__/allocation-policy.test.js +111 -0
  2280. package/dist/team/__tests__/allocation-policy.test.js.map +1 -0
  2281. package/dist/team/__tests__/api-interop.test.d.ts +2 -0
  2282. package/dist/team/__tests__/api-interop.test.d.ts.map +1 -0
  2283. package/dist/team/__tests__/api-interop.test.js +2321 -0
  2284. package/dist/team/__tests__/api-interop.test.js.map +1 -0
  2285. package/dist/team/__tests__/approved-execution.test.d.ts +2 -0
  2286. package/dist/team/__tests__/approved-execution.test.d.ts.map +1 -0
  2287. package/dist/team/__tests__/approved-execution.test.js +304 -0
  2288. package/dist/team/__tests__/approved-execution.test.js.map +1 -0
  2289. package/dist/team/__tests__/commit-hygiene.test.d.ts +2 -0
  2290. package/dist/team/__tests__/commit-hygiene.test.d.ts.map +1 -0
  2291. package/dist/team/__tests__/commit-hygiene.test.js +93 -0
  2292. package/dist/team/__tests__/commit-hygiene.test.js.map +1 -0
  2293. package/dist/team/__tests__/coordination-protocol.test.d.ts +2 -0
  2294. package/dist/team/__tests__/coordination-protocol.test.d.ts.map +1 -0
  2295. package/dist/team/__tests__/coordination-protocol.test.js +173 -0
  2296. package/dist/team/__tests__/coordination-protocol.test.js.map +1 -0
  2297. package/dist/team/__tests__/cross-rebase-smoke.test.d.ts +2 -0
  2298. package/dist/team/__tests__/cross-rebase-smoke.test.d.ts.map +1 -0
  2299. package/dist/team/__tests__/cross-rebase-smoke.test.js +161 -0
  2300. package/dist/team/__tests__/cross-rebase-smoke.test.js.map +1 -0
  2301. package/dist/team/__tests__/current-task-baseline.test.d.ts +2 -0
  2302. package/dist/team/__tests__/current-task-baseline.test.d.ts.map +1 -0
  2303. package/dist/team/__tests__/current-task-baseline.test.js +87 -0
  2304. package/dist/team/__tests__/current-task-baseline.test.js.map +1 -0
  2305. package/dist/team/__tests__/delegation-policy.test.d.ts +2 -0
  2306. package/dist/team/__tests__/delegation-policy.test.d.ts.map +1 -0
  2307. package/dist/team/__tests__/delegation-policy.test.js +69 -0
  2308. package/dist/team/__tests__/delegation-policy.test.js.map +1 -0
  2309. package/dist/team/__tests__/delivery-e2e-smoke.test.d.ts +2 -0
  2310. package/dist/team/__tests__/delivery-e2e-smoke.test.d.ts.map +1 -0
  2311. package/dist/team/__tests__/delivery-e2e-smoke.test.js +677 -0
  2312. package/dist/team/__tests__/delivery-e2e-smoke.test.js.map +1 -0
  2313. package/dist/team/__tests__/delivery-log.test.d.ts +2 -0
  2314. package/dist/team/__tests__/delivery-log.test.d.ts.map +1 -0
  2315. package/dist/team/__tests__/delivery-log.test.js +62 -0
  2316. package/dist/team/__tests__/delivery-log.test.js.map +1 -0
  2317. package/dist/team/__tests__/events.test.d.ts +2 -0
  2318. package/dist/team/__tests__/events.test.d.ts.map +1 -0
  2319. package/dist/team/__tests__/events.test.js +313 -0
  2320. package/dist/team/__tests__/events.test.js.map +1 -0
  2321. package/dist/team/__tests__/followup-planner.test.d.ts +2 -0
  2322. package/dist/team/__tests__/followup-planner.test.d.ts.map +1 -0
  2323. package/dist/team/__tests__/followup-planner.test.js +100 -0
  2324. package/dist/team/__tests__/followup-planner.test.js.map +1 -0
  2325. package/dist/team/__tests__/hardening-e2e.test.d.ts +2 -0
  2326. package/dist/team/__tests__/hardening-e2e.test.d.ts.map +1 -0
  2327. package/dist/team/__tests__/hardening-e2e.test.js +98 -0
  2328. package/dist/team/__tests__/hardening-e2e.test.js.map +1 -0
  2329. package/dist/team/__tests__/hook-primary-e2e-contract.test.d.ts +2 -0
  2330. package/dist/team/__tests__/hook-primary-e2e-contract.test.d.ts.map +1 -0
  2331. package/dist/team/__tests__/hook-primary-e2e-contract.test.js +78 -0
  2332. package/dist/team/__tests__/hook-primary-e2e-contract.test.js.map +1 -0
  2333. package/dist/team/__tests__/idle-nudge.test.d.ts +2 -0
  2334. package/dist/team/__tests__/idle-nudge.test.d.ts.map +1 -0
  2335. package/dist/team/__tests__/idle-nudge.test.js +230 -0
  2336. package/dist/team/__tests__/idle-nudge.test.js.map +1 -0
  2337. package/dist/team/__tests__/leader-activity.test.d.ts +2 -0
  2338. package/dist/team/__tests__/leader-activity.test.d.ts.map +1 -0
  2339. package/dist/team/__tests__/leader-activity.test.js +261 -0
  2340. package/dist/team/__tests__/leader-activity.test.js.map +1 -0
  2341. package/dist/team/__tests__/mcp-comm.test.d.ts +2 -0
  2342. package/dist/team/__tests__/mcp-comm.test.d.ts.map +1 -0
  2343. package/dist/team/__tests__/mcp-comm.test.js +289 -0
  2344. package/dist/team/__tests__/mcp-comm.test.js.map +1 -0
  2345. package/dist/team/__tests__/model-contract.test.d.ts +2 -0
  2346. package/dist/team/__tests__/model-contract.test.d.ts.map +1 -0
  2347. package/dist/team/__tests__/model-contract.test.js +187 -0
  2348. package/dist/team/__tests__/model-contract.test.js.map +1 -0
  2349. package/dist/team/__tests__/orchestrator.test.d.ts +2 -0
  2350. package/dist/team/__tests__/orchestrator.test.d.ts.map +1 -0
  2351. package/dist/team/__tests__/orchestrator.test.js +111 -0
  2352. package/dist/team/__tests__/orchestrator.test.js.map +1 -0
  2353. package/dist/team/__tests__/phase-controller.test.d.ts +2 -0
  2354. package/dist/team/__tests__/phase-controller.test.d.ts.map +1 -0
  2355. package/dist/team/__tests__/phase-controller.test.js +50 -0
  2356. package/dist/team/__tests__/phase-controller.test.js.map +1 -0
  2357. package/dist/team/__tests__/rebalance-policy.test.d.ts +2 -0
  2358. package/dist/team/__tests__/rebalance-policy.test.d.ts.map +1 -0
  2359. package/dist/team/__tests__/rebalance-policy.test.js +168 -0
  2360. package/dist/team/__tests__/rebalance-policy.test.js.map +1 -0
  2361. package/dist/team/__tests__/repo-aware-decomposition.test.d.ts +2 -0
  2362. package/dist/team/__tests__/repo-aware-decomposition.test.d.ts.map +1 -0
  2363. package/dist/team/__tests__/repo-aware-decomposition.test.js +156 -0
  2364. package/dist/team/__tests__/repo-aware-decomposition.test.js.map +1 -0
  2365. package/dist/team/__tests__/role-router.test.d.ts +2 -0
  2366. package/dist/team/__tests__/role-router.test.d.ts.map +1 -0
  2367. package/dist/team/__tests__/role-router.test.js +263 -0
  2368. package/dist/team/__tests__/role-router.test.js.map +1 -0
  2369. package/dist/team/__tests__/runtime-boxed-state.test.d.ts +2 -0
  2370. package/dist/team/__tests__/runtime-boxed-state.test.d.ts.map +1 -0
  2371. package/dist/team/__tests__/runtime-boxed-state.test.js +39 -0
  2372. package/dist/team/__tests__/runtime-boxed-state.test.js.map +1 -0
  2373. package/dist/team/__tests__/runtime-cli.test.d.ts +2 -0
  2374. package/dist/team/__tests__/runtime-cli.test.d.ts.map +1 -0
  2375. package/dist/team/__tests__/runtime-cli.test.js +320 -0
  2376. package/dist/team/__tests__/runtime-cli.test.js.map +1 -0
  2377. package/dist/team/__tests__/runtime.test.d.ts +2 -0
  2378. package/dist/team/__tests__/runtime.test.d.ts.map +1 -0
  2379. package/dist/team/__tests__/runtime.test.js +6464 -0
  2380. package/dist/team/__tests__/runtime.test.js.map +1 -0
  2381. package/dist/team/__tests__/scaling.test.d.ts +2 -0
  2382. package/dist/team/__tests__/scaling.test.d.ts.map +1 -0
  2383. package/dist/team/__tests__/scaling.test.js +1664 -0
  2384. package/dist/team/__tests__/scaling.test.js.map +1 -0
  2385. package/dist/team/__tests__/shutdown-fallback.test.d.ts +2 -0
  2386. package/dist/team/__tests__/shutdown-fallback.test.d.ts.map +1 -0
  2387. package/dist/team/__tests__/shutdown-fallback.test.js +125 -0
  2388. package/dist/team/__tests__/shutdown-fallback.test.js.map +1 -0
  2389. package/dist/team/__tests__/state-root.test.d.ts +2 -0
  2390. package/dist/team/__tests__/state-root.test.d.ts.map +1 -0
  2391. package/dist/team/__tests__/state-root.test.js +208 -0
  2392. package/dist/team/__tests__/state-root.test.js.map +1 -0
  2393. package/dist/team/__tests__/state.test.d.ts +2 -0
  2394. package/dist/team/__tests__/state.test.d.ts.map +1 -0
  2395. package/dist/team/__tests__/state.test.js +1942 -0
  2396. package/dist/team/__tests__/state.test.js.map +1 -0
  2397. package/dist/team/__tests__/team-identity.test.d.ts +2 -0
  2398. package/dist/team/__tests__/team-identity.test.d.ts.map +1 -0
  2399. package/dist/team/__tests__/team-identity.test.js +166 -0
  2400. package/dist/team/__tests__/team-identity.test.js.map +1 -0
  2401. package/dist/team/__tests__/team-ops-contract.test.d.ts +2 -0
  2402. package/dist/team/__tests__/team-ops-contract.test.d.ts.map +1 -0
  2403. package/dist/team/__tests__/team-ops-contract.test.js +96 -0
  2404. package/dist/team/__tests__/team-ops-contract.test.js.map +1 -0
  2405. package/dist/team/__tests__/tmux-claude-workers-demo.test.d.ts +2 -0
  2406. package/dist/team/__tests__/tmux-claude-workers-demo.test.d.ts.map +1 -0
  2407. package/dist/team/__tests__/tmux-claude-workers-demo.test.js +191 -0
  2408. package/dist/team/__tests__/tmux-claude-workers-demo.test.js.map +1 -0
  2409. package/dist/team/__tests__/tmux-session.test.d.ts +2 -0
  2410. package/dist/team/__tests__/tmux-session.test.d.ts.map +1 -0
  2411. package/dist/team/__tests__/tmux-session.test.js +4546 -0
  2412. package/dist/team/__tests__/tmux-session.test.js.map +1 -0
  2413. package/dist/team/__tests__/tmux-test-fixture.d.ts +20 -0
  2414. package/dist/team/__tests__/tmux-test-fixture.d.ts.map +1 -0
  2415. package/dist/team/__tests__/tmux-test-fixture.js +148 -0
  2416. package/dist/team/__tests__/tmux-test-fixture.js.map +1 -0
  2417. package/dist/team/__tests__/tmux-test-fixture.test.d.ts +2 -0
  2418. package/dist/team/__tests__/tmux-test-fixture.test.d.ts.map +1 -0
  2419. package/dist/team/__tests__/tmux-test-fixture.test.js +114 -0
  2420. package/dist/team/__tests__/tmux-test-fixture.test.js.map +1 -0
  2421. package/dist/team/__tests__/worker-bootstrap.test.d.ts +2 -0
  2422. package/dist/team/__tests__/worker-bootstrap.test.d.ts.map +1 -0
  2423. package/dist/team/__tests__/worker-bootstrap.test.js +1122 -0
  2424. package/dist/team/__tests__/worker-bootstrap.test.js.map +1 -0
  2425. package/dist/team/__tests__/worker-runtime-identity.test.d.ts +2 -0
  2426. package/dist/team/__tests__/worker-runtime-identity.test.d.ts.map +1 -0
  2427. package/dist/team/__tests__/worker-runtime-identity.test.js +258 -0
  2428. package/dist/team/__tests__/worker-runtime-identity.test.js.map +1 -0
  2429. package/dist/team/__tests__/worktree.test.d.ts +2 -0
  2430. package/dist/team/__tests__/worktree.test.d.ts.map +1 -0
  2431. package/dist/team/__tests__/worktree.test.js +317 -0
  2432. package/dist/team/__tests__/worktree.test.js.map +1 -0
  2433. package/dist/team/allocation-policy.d.ts +29 -0
  2434. package/dist/team/allocation-policy.d.ts.map +1 -0
  2435. package/dist/team/allocation-policy.js +153 -0
  2436. package/dist/team/allocation-policy.js.map +1 -0
  2437. package/dist/team/api-interop.d.ts +20 -0
  2438. package/dist/team/api-interop.d.ts.map +1 -0
  2439. package/dist/team/api-interop.js +1084 -0
  2440. package/dist/team/api-interop.js.map +1 -0
  2441. package/dist/team/approved-execution.d.ts +64 -0
  2442. package/dist/team/approved-execution.d.ts.map +1 -0
  2443. package/dist/team/approved-execution.js +242 -0
  2444. package/dist/team/approved-execution.js.map +1 -0
  2445. package/dist/team/commit-hygiene.d.ts +79 -0
  2446. package/dist/team/commit-hygiene.d.ts.map +1 -0
  2447. package/dist/team/commit-hygiene.js +364 -0
  2448. package/dist/team/commit-hygiene.js.map +1 -0
  2449. package/dist/team/contracts.d.ts +26 -0
  2450. package/dist/team/contracts.d.ts.map +1 -0
  2451. package/dist/team/contracts.js +103 -0
  2452. package/dist/team/contracts.js.map +1 -0
  2453. package/dist/team/coordination-protocol.d.ts +14 -0
  2454. package/dist/team/coordination-protocol.d.ts.map +1 -0
  2455. package/dist/team/coordination-protocol.js +244 -0
  2456. package/dist/team/coordination-protocol.js.map +1 -0
  2457. package/dist/team/current-task-baseline.d.ts +32 -0
  2458. package/dist/team/current-task-baseline.d.ts.map +1 -0
  2459. package/dist/team/current-task-baseline.js +85 -0
  2460. package/dist/team/current-task-baseline.js.map +1 -0
  2461. package/dist/team/dag-schema.d.ts +38 -0
  2462. package/dist/team/dag-schema.d.ts.map +1 -0
  2463. package/dist/team/dag-schema.js +221 -0
  2464. package/dist/team/dag-schema.js.map +1 -0
  2465. package/dist/team/delegation-policy.d.ts +3 -0
  2466. package/dist/team/delegation-policy.d.ts.map +1 -0
  2467. package/dist/team/delegation-policy.js +82 -0
  2468. package/dist/team/delegation-policy.js.map +1 -0
  2469. package/dist/team/delivery-log.d.ts +14 -0
  2470. package/dist/team/delivery-log.d.ts.map +1 -0
  2471. package/dist/team/delivery-log.js +43 -0
  2472. package/dist/team/delivery-log.js.map +1 -0
  2473. package/dist/team/followup-planner.d.ts +45 -0
  2474. package/dist/team/followup-planner.d.ts.map +1 -0
  2475. package/dist/team/followup-planner.js +200 -0
  2476. package/dist/team/followup-planner.js.map +1 -0
  2477. package/dist/team/goal-workflow.d.ts +20 -0
  2478. package/dist/team/goal-workflow.d.ts.map +1 -0
  2479. package/dist/team/goal-workflow.js +57 -0
  2480. package/dist/team/goal-workflow.js.map +1 -0
  2481. package/dist/team/idle-nudge.d.ts +53 -0
  2482. package/dist/team/idle-nudge.d.ts.map +1 -0
  2483. package/dist/team/idle-nudge.js +141 -0
  2484. package/dist/team/idle-nudge.js.map +1 -0
  2485. package/dist/team/leader-activity.d.ts +15 -0
  2486. package/dist/team/leader-activity.d.ts.map +1 -0
  2487. package/dist/team/leader-activity.js +224 -0
  2488. package/dist/team/leader-activity.js.map +1 -0
  2489. package/dist/team/mcp-comm.d.ts +73 -0
  2490. package/dist/team/mcp-comm.d.ts.map +1 -0
  2491. package/dist/team/mcp-comm.js +314 -0
  2492. package/dist/team/mcp-comm.js.map +1 -0
  2493. package/dist/team/model-contract.d.ts +26 -0
  2494. package/dist/team/model-contract.d.ts.map +1 -0
  2495. package/dist/team/model-contract.js +205 -0
  2496. package/dist/team/model-contract.js.map +1 -0
  2497. package/dist/team/orchestrator.d.ts +47 -0
  2498. package/dist/team/orchestrator.d.ts.map +1 -0
  2499. package/dist/team/orchestrator.js +131 -0
  2500. package/dist/team/orchestrator.js.map +1 -0
  2501. package/dist/team/pane-status.d.ts +149 -0
  2502. package/dist/team/pane-status.d.ts.map +1 -0
  2503. package/dist/team/pane-status.js +558 -0
  2504. package/dist/team/pane-status.js.map +1 -0
  2505. package/dist/team/phase-controller.d.ts +12 -0
  2506. package/dist/team/phase-controller.d.ts.map +1 -0
  2507. package/dist/team/phase-controller.js +142 -0
  2508. package/dist/team/phase-controller.js.map +1 -0
  2509. package/dist/team/progress-evidence.d.ts +2 -0
  2510. package/dist/team/progress-evidence.d.ts.map +1 -0
  2511. package/dist/team/progress-evidence.js +77 -0
  2512. package/dist/team/progress-evidence.js.map +1 -0
  2513. package/dist/team/rebalance-policy.d.ts +19 -0
  2514. package/dist/team/rebalance-policy.d.ts.map +1 -0
  2515. package/dist/team/rebalance-policy.js +48 -0
  2516. package/dist/team/rebalance-policy.js.map +1 -0
  2517. package/dist/team/reminder-intents.d.ts +11 -0
  2518. package/dist/team/reminder-intents.d.ts.map +1 -0
  2519. package/dist/team/reminder-intents.js +40 -0
  2520. package/dist/team/reminder-intents.js.map +1 -0
  2521. package/dist/team/repo-aware-decomposition.d.ts +68 -0
  2522. package/dist/team/repo-aware-decomposition.d.ts.map +1 -0
  2523. package/dist/team/repo-aware-decomposition.js +235 -0
  2524. package/dist/team/repo-aware-decomposition.js.map +1 -0
  2525. package/dist/team/role-router.d.ts +32 -0
  2526. package/dist/team/role-router.d.ts.map +1 -0
  2527. package/dist/team/role-router.js +298 -0
  2528. package/dist/team/role-router.js.map +1 -0
  2529. package/dist/team/runtime-cli.d.ts +78 -0
  2530. package/dist/team/runtime-cli.d.ts.map +1 -0
  2531. package/dist/team/runtime-cli.js +376 -0
  2532. package/dist/team/runtime-cli.js.map +1 -0
  2533. package/dist/team/runtime.d.ts +162 -0
  2534. package/dist/team/runtime.d.ts.map +1 -0
  2535. package/dist/team/runtime.js +4160 -0
  2536. package/dist/team/runtime.js.map +1 -0
  2537. package/dist/team/scaling.d.ts +59 -0
  2538. package/dist/team/scaling.d.ts.map +1 -0
  2539. package/dist/team/scaling.js +650 -0
  2540. package/dist/team/scaling.js.map +1 -0
  2541. package/dist/team/state/approvals.d.ts +25 -0
  2542. package/dist/team/state/approvals.d.ts.map +1 -0
  2543. package/dist/team/state/approvals.js +31 -0
  2544. package/dist/team/state/approvals.js.map +1 -0
  2545. package/dist/team/state/config.d.ts +2 -0
  2546. package/dist/team/state/config.d.ts.map +1 -0
  2547. package/dist/team/state/config.js +2 -0
  2548. package/dist/team/state/config.js.map +1 -0
  2549. package/dist/team/state/dispatch-lock.d.ts +3 -0
  2550. package/dist/team/state/dispatch-lock.d.ts.map +1 -0
  2551. package/dist/team/state/dispatch-lock.js +81 -0
  2552. package/dist/team/state/dispatch-lock.js.map +1 -0
  2553. package/dist/team/state/dispatch.d.ts +67 -0
  2554. package/dist/team/state/dispatch.d.ts.map +1 -0
  2555. package/dist/team/state/dispatch.js +302 -0
  2556. package/dist/team/state/dispatch.js.map +1 -0
  2557. package/dist/team/state/events.d.ts +26 -0
  2558. package/dist/team/state/events.d.ts.map +1 -0
  2559. package/dist/team/state/events.js +145 -0
  2560. package/dist/team/state/events.js.map +1 -0
  2561. package/dist/team/state/index.d.ts +11 -0
  2562. package/dist/team/state/index.d.ts.map +1 -0
  2563. package/dist/team/state/index.js +11 -0
  2564. package/dist/team/state/index.js.map +1 -0
  2565. package/dist/team/state/io.d.ts +2 -0
  2566. package/dist/team/state/io.d.ts.map +1 -0
  2567. package/dist/team/state/io.js +2 -0
  2568. package/dist/team/state/io.js.map +1 -0
  2569. package/dist/team/state/locks.d.ts +16 -0
  2570. package/dist/team/state/locks.d.ts.map +1 -0
  2571. package/dist/team/state/locks.js +201 -0
  2572. package/dist/team/state/locks.js.map +1 -0
  2573. package/dist/team/state/mailbox.d.ts +43 -0
  2574. package/dist/team/state/mailbox.d.ts.map +1 -0
  2575. package/dist/team/state/mailbox.js +222 -0
  2576. package/dist/team/state/mailbox.js.map +1 -0
  2577. package/dist/team/state/monitor.d.ts +108 -0
  2578. package/dist/team/state/monitor.d.ts.map +1 -0
  2579. package/dist/team/state/monitor.js +193 -0
  2580. package/dist/team/state/monitor.js.map +1 -0
  2581. package/dist/team/state/shutdown.d.ts +2 -0
  2582. package/dist/team/state/shutdown.d.ts.map +1 -0
  2583. package/dist/team/state/shutdown.js +2 -0
  2584. package/dist/team/state/shutdown.js.map +1 -0
  2585. package/dist/team/state/summary.d.ts +2 -0
  2586. package/dist/team/state/summary.d.ts.map +1 -0
  2587. package/dist/team/state/summary.js +2 -0
  2588. package/dist/team/state/summary.js.map +1 -0
  2589. package/dist/team/state/tasks.d.ts +53 -0
  2590. package/dist/team/state/tasks.d.ts.map +1 -0
  2591. package/dist/team/state/tasks.js +284 -0
  2592. package/dist/team/state/tasks.js.map +1 -0
  2593. package/dist/team/state/types.d.ts +356 -0
  2594. package/dist/team/state/types.d.ts.map +1 -0
  2595. package/dist/team/state/types.js +3 -0
  2596. package/dist/team/state/types.js.map +1 -0
  2597. package/dist/team/state/workers.d.ts +2 -0
  2598. package/dist/team/state/workers.d.ts.map +1 -0
  2599. package/dist/team/state/workers.js +2 -0
  2600. package/dist/team/state/workers.js.map +1 -0
  2601. package/dist/team/state-root.d.ts +40 -0
  2602. package/dist/team/state-root.d.ts.map +1 -0
  2603. package/dist/team/state-root.js +297 -0
  2604. package/dist/team/state-root.js.map +1 -0
  2605. package/dist/team/state.d.ts +471 -0
  2606. package/dist/team/state.d.ts.map +1 -0
  2607. package/dist/team/state.js +1418 -0
  2608. package/dist/team/state.js.map +1 -0
  2609. package/dist/team/team-identity.d.ts +26 -0
  2610. package/dist/team/team-identity.d.ts.map +1 -0
  2611. package/dist/team/team-identity.js +169 -0
  2612. package/dist/team/team-identity.js.map +1 -0
  2613. package/dist/team/team-ops.d.ts +66 -0
  2614. package/dist/team/team-ops.d.ts.map +1 -0
  2615. package/dist/team/team-ops.js +79 -0
  2616. package/dist/team/team-ops.js.map +1 -0
  2617. package/dist/team/tmux-session.d.ts +190 -0
  2618. package/dist/team/tmux-session.d.ts.map +1 -0
  2619. package/dist/team/tmux-session.js +2071 -0
  2620. package/dist/team/tmux-session.js.map +1 -0
  2621. package/dist/team/ultragoal-context.d.ts +47 -0
  2622. package/dist/team/ultragoal-context.d.ts.map +1 -0
  2623. package/dist/team/ultragoal-context.js +215 -0
  2624. package/dist/team/ultragoal-context.js.map +1 -0
  2625. package/dist/team/worker-bootstrap.d.ts +92 -0
  2626. package/dist/team/worker-bootstrap.d.ts.map +1 -0
  2627. package/dist/team/worker-bootstrap.js +860 -0
  2628. package/dist/team/worker-bootstrap.js.map +1 -0
  2629. package/dist/team/worktree.d.ts +69 -0
  2630. package/dist/team/worktree.d.ts.map +1 -0
  2631. package/dist/team/worktree.js +437 -0
  2632. package/dist/team/worktree.js.map +1 -0
  2633. package/dist/ultragoal/__tests__/artifacts.test.d.ts +2 -0
  2634. package/dist/ultragoal/__tests__/artifacts.test.d.ts.map +1 -0
  2635. package/dist/ultragoal/__tests__/artifacts.test.js +1423 -0
  2636. package/dist/ultragoal/__tests__/artifacts.test.js.map +1 -0
  2637. package/dist/ultragoal/__tests__/docs-contract.test.d.ts +2 -0
  2638. package/dist/ultragoal/__tests__/docs-contract.test.d.ts.map +1 -0
  2639. package/dist/ultragoal/__tests__/docs-contract.test.js +132 -0
  2640. package/dist/ultragoal/__tests__/docs-contract.test.js.map +1 -0
  2641. package/dist/ultragoal/__tests__/steering-fixtures.d.ts +68 -0
  2642. package/dist/ultragoal/__tests__/steering-fixtures.d.ts.map +1 -0
  2643. package/dist/ultragoal/__tests__/steering-fixtures.js +259 -0
  2644. package/dist/ultragoal/__tests__/steering-fixtures.js.map +1 -0
  2645. package/dist/ultragoal/__tests__/steering-fixtures.test.d.ts +2 -0
  2646. package/dist/ultragoal/__tests__/steering-fixtures.test.d.ts.map +1 -0
  2647. package/dist/ultragoal/__tests__/steering-fixtures.test.js +65 -0
  2648. package/dist/ultragoal/__tests__/steering-fixtures.test.js.map +1 -0
  2649. package/dist/ultragoal/artifacts.d.ts +249 -0
  2650. package/dist/ultragoal/artifacts.d.ts.map +1 -0
  2651. package/dist/ultragoal/artifacts.js +1349 -0
  2652. package/dist/ultragoal/artifacts.js.map +1 -0
  2653. package/dist/utils/__tests__/agents-md.test.d.ts +2 -0
  2654. package/dist/utils/__tests__/agents-md.test.d.ts.map +1 -0
  2655. package/dist/utils/__tests__/agents-md.test.js +96 -0
  2656. package/dist/utils/__tests__/agents-md.test.js.map +1 -0
  2657. package/dist/utils/__tests__/agents-model-table.test.d.ts +2 -0
  2658. package/dist/utils/__tests__/agents-model-table.test.d.ts.map +1 -0
  2659. package/dist/utils/__tests__/agents-model-table.test.js +108 -0
  2660. package/dist/utils/__tests__/agents-model-table.test.js.map +1 -0
  2661. package/dist/utils/__tests__/dep-versions.test.d.ts +2 -0
  2662. package/dist/utils/__tests__/dep-versions.test.d.ts.map +1 -0
  2663. package/dist/utils/__tests__/dep-versions.test.js +46 -0
  2664. package/dist/utils/__tests__/dep-versions.test.js.map +1 -0
  2665. package/dist/utils/__tests__/package.test.d.ts +2 -0
  2666. package/dist/utils/__tests__/package.test.d.ts.map +1 -0
  2667. package/dist/utils/__tests__/package.test.js +21 -0
  2668. package/dist/utils/__tests__/package.test.js.map +1 -0
  2669. package/dist/utils/__tests__/paths.test.d.ts +2 -0
  2670. package/dist/utils/__tests__/paths.test.d.ts.map +1 -0
  2671. package/dist/utils/__tests__/paths.test.js +647 -0
  2672. package/dist/utils/__tests__/paths.test.js.map +1 -0
  2673. package/dist/utils/__tests__/platform-command.test.d.ts +2 -0
  2674. package/dist/utils/__tests__/platform-command.test.d.ts.map +1 -0
  2675. package/dist/utils/__tests__/platform-command.test.js +399 -0
  2676. package/dist/utils/__tests__/platform-command.test.js.map +1 -0
  2677. package/dist/utils/__tests__/repo-deps.test.d.ts +2 -0
  2678. package/dist/utils/__tests__/repo-deps.test.d.ts.map +1 -0
  2679. package/dist/utils/__tests__/repo-deps.test.js +71 -0
  2680. package/dist/utils/__tests__/repo-deps.test.js.map +1 -0
  2681. package/dist/utils/__tests__/sleep-resource.test.d.ts +2 -0
  2682. package/dist/utils/__tests__/sleep-resource.test.d.ts.map +1 -0
  2683. package/dist/utils/__tests__/sleep-resource.test.js +39 -0
  2684. package/dist/utils/__tests__/sleep-resource.test.js.map +1 -0
  2685. package/dist/utils/__tests__/version.test.d.ts +2 -0
  2686. package/dist/utils/__tests__/version.test.d.ts.map +1 -0
  2687. package/dist/utils/__tests__/version.test.js +78 -0
  2688. package/dist/utils/__tests__/version.test.js.map +1 -0
  2689. package/dist/utils/agents-md.d.ts +10 -0
  2690. package/dist/utils/agents-md.d.ts.map +1 -0
  2691. package/dist/utils/agents-md.js +76 -0
  2692. package/dist/utils/agents-md.js.map +1 -0
  2693. package/dist/utils/agents-model-table.d.ts +16 -0
  2694. package/dist/utils/agents-model-table.d.ts.map +1 -0
  2695. package/dist/utils/agents-model-table.js +102 -0
  2696. package/dist/utils/agents-model-table.js.map +1 -0
  2697. package/dist/utils/git-layout.d.ts +8 -0
  2698. package/dist/utils/git-layout.d.ts.map +1 -0
  2699. package/dist/utils/git-layout.js +58 -0
  2700. package/dist/utils/git-layout.js.map +1 -0
  2701. package/dist/utils/package.d.ts +9 -0
  2702. package/dist/utils/package.d.ts.map +1 -0
  2703. package/dist/utils/package.js +31 -0
  2704. package/dist/utils/package.js.map +1 -0
  2705. package/dist/utils/paths.d.ts +101 -0
  2706. package/dist/utils/paths.d.ts.map +1 -0
  2707. package/dist/utils/paths.js +314 -0
  2708. package/dist/utils/paths.js.map +1 -0
  2709. package/dist/utils/platform-command.d.ts +29 -0
  2710. package/dist/utils/platform-command.d.ts.map +1 -0
  2711. package/dist/utils/platform-command.js +239 -0
  2712. package/dist/utils/platform-command.js.map +1 -0
  2713. package/dist/utils/repo-deps.d.ts +20 -0
  2714. package/dist/utils/repo-deps.d.ts.map +1 -0
  2715. package/dist/utils/repo-deps.js +78 -0
  2716. package/dist/utils/repo-deps.js.map +1 -0
  2717. package/dist/utils/safe-json.d.ts +3 -0
  2718. package/dist/utils/safe-json.d.ts.map +1 -0
  2719. package/dist/utils/safe-json.js +19 -0
  2720. package/dist/utils/safe-json.js.map +1 -0
  2721. package/dist/utils/sleep.d.ts +3 -0
  2722. package/dist/utils/sleep.d.ts.map +1 -0
  2723. package/dist/utils/sleep.js +35 -0
  2724. package/dist/utils/sleep.js.map +1 -0
  2725. package/dist/utils/toml.d.ts +4 -0
  2726. package/dist/utils/toml.d.ts.map +1 -0
  2727. package/dist/utils/toml.js +75 -0
  2728. package/dist/utils/toml.js.map +1 -0
  2729. package/dist/utils/version.d.ts +7 -0
  2730. package/dist/utils/version.d.ts.map +1 -0
  2731. package/dist/utils/version.js +72 -0
  2732. package/dist/utils/version.js.map +1 -0
  2733. package/dist/verification/__tests__/ci-rust-gates.test.d.ts +2 -0
  2734. package/dist/verification/__tests__/ci-rust-gates.test.d.ts.map +1 -0
  2735. package/dist/verification/__tests__/ci-rust-gates.test.js +293 -0
  2736. package/dist/verification/__tests__/ci-rust-gates.test.js.map +1 -0
  2737. package/dist/verification/__tests__/dev-merge-issue-close-workflow.test.d.ts +2 -0
  2738. package/dist/verification/__tests__/dev-merge-issue-close-workflow.test.d.ts.map +1 -0
  2739. package/dist/verification/__tests__/dev-merge-issue-close-workflow.test.js +68 -0
  2740. package/dist/verification/__tests__/dev-merge-issue-close-workflow.test.js.map +1 -0
  2741. package/dist/verification/__tests__/explore-harness-release-workflow.test.d.ts +2 -0
  2742. package/dist/verification/__tests__/explore-harness-release-workflow.test.d.ts.map +1 -0
  2743. package/dist/verification/__tests__/explore-harness-release-workflow.test.js +74 -0
  2744. package/dist/verification/__tests__/explore-harness-release-workflow.test.js.map +1 -0
  2745. package/dist/verification/__tests__/native-release-manifest.test.d.ts +2 -0
  2746. package/dist/verification/__tests__/native-release-manifest.test.d.ts.map +1 -0
  2747. package/dist/verification/__tests__/native-release-manifest.test.js +80 -0
  2748. package/dist/verification/__tests__/native-release-manifest.test.js.map +1 -0
  2749. package/dist/verification/__tests__/pr-check-workflow.test.d.ts +2 -0
  2750. package/dist/verification/__tests__/pr-check-workflow.test.d.ts.map +1 -0
  2751. package/dist/verification/__tests__/pr-check-workflow.test.js +27 -0
  2752. package/dist/verification/__tests__/pr-check-workflow.test.js.map +1 -0
  2753. package/dist/verification/__tests__/ralph-persistence-gate.test.d.ts +2 -0
  2754. package/dist/verification/__tests__/ralph-persistence-gate.test.d.ts.map +1 -0
  2755. package/dist/verification/__tests__/ralph-persistence-gate.test.js +55 -0
  2756. package/dist/verification/__tests__/ralph-persistence-gate.test.js.map +1 -0
  2757. package/dist/verification/__tests__/rust-runtime-thin-adapter-gate.test.d.ts +2 -0
  2758. package/dist/verification/__tests__/rust-runtime-thin-adapter-gate.test.d.ts.map +1 -0
  2759. package/dist/verification/__tests__/rust-runtime-thin-adapter-gate.test.js +32 -0
  2760. package/dist/verification/__tests__/rust-runtime-thin-adapter-gate.test.js.map +1 -0
  2761. package/dist/verification/__tests__/verifier.test.d.ts +2 -0
  2762. package/dist/verification/__tests__/verifier.test.d.ts.map +1 -0
  2763. package/dist/verification/__tests__/verifier.test.js +113 -0
  2764. package/dist/verification/__tests__/verifier.test.js.map +1 -0
  2765. package/dist/verification/verifier.d.ts +37 -0
  2766. package/dist/verification/verifier.d.ts.map +1 -0
  2767. package/dist/verification/verifier.js +100 -0
  2768. package/dist/verification/verifier.js.map +1 -0
  2769. package/dist/visual/__tests__/verdict.test.d.ts +2 -0
  2770. package/dist/visual/__tests__/verdict.test.d.ts.map +1 -0
  2771. package/dist/visual/__tests__/verdict.test.js +81 -0
  2772. package/dist/visual/__tests__/verdict.test.js.map +1 -0
  2773. package/dist/visual/constants.d.ts +4 -0
  2774. package/dist/visual/constants.d.ts.map +1 -0
  2775. package/dist/visual/constants.js +3 -0
  2776. package/dist/visual/constants.js.map +1 -0
  2777. package/dist/visual/verdict.d.ts +17 -0
  2778. package/dist/visual/verdict.d.ts.map +1 -0
  2779. package/dist/visual/verdict.js +61 -0
  2780. package/dist/visual/verdict.js.map +1 -0
  2781. package/dist/wiki/__tests__/cjk-tokenize.test.d.ts +12 -0
  2782. package/dist/wiki/__tests__/cjk-tokenize.test.d.ts.map +1 -0
  2783. package/dist/wiki/__tests__/cjk-tokenize.test.js +139 -0
  2784. package/dist/wiki/__tests__/cjk-tokenize.test.js.map +1 -0
  2785. package/dist/wiki/__tests__/crlf-parse.test.d.ts +2 -0
  2786. package/dist/wiki/__tests__/crlf-parse.test.d.ts.map +1 -0
  2787. package/dist/wiki/__tests__/crlf-parse.test.js +24 -0
  2788. package/dist/wiki/__tests__/crlf-parse.test.js.map +1 -0
  2789. package/dist/wiki/__tests__/escape-newline.test.d.ts +2 -0
  2790. package/dist/wiki/__tests__/escape-newline.test.d.ts.map +1 -0
  2791. package/dist/wiki/__tests__/escape-newline.test.js +45 -0
  2792. package/dist/wiki/__tests__/escape-newline.test.js.map +1 -0
  2793. package/dist/wiki/__tests__/ingest.test.d.ts +5 -0
  2794. package/dist/wiki/__tests__/ingest.test.d.ts.map +1 -0
  2795. package/dist/wiki/__tests__/ingest.test.js +215 -0
  2796. package/dist/wiki/__tests__/ingest.test.js.map +1 -0
  2797. package/dist/wiki/__tests__/lint.test.d.ts +5 -0
  2798. package/dist/wiki/__tests__/lint.test.d.ts.map +1 -0
  2799. package/dist/wiki/__tests__/lint.test.js +176 -0
  2800. package/dist/wiki/__tests__/lint.test.js.map +1 -0
  2801. package/dist/wiki/__tests__/query.test.d.ts +5 -0
  2802. package/dist/wiki/__tests__/query.test.d.ts.map +1 -0
  2803. package/dist/wiki/__tests__/query.test.js +166 -0
  2804. package/dist/wiki/__tests__/query.test.js.map +1 -0
  2805. package/dist/wiki/__tests__/reserved-file-guard.test.d.ts +2 -0
  2806. package/dist/wiki/__tests__/reserved-file-guard.test.d.ts.map +1 -0
  2807. package/dist/wiki/__tests__/reserved-file-guard.test.js +44 -0
  2808. package/dist/wiki/__tests__/reserved-file-guard.test.js.map +1 -0
  2809. package/dist/wiki/__tests__/session-hooks.test.d.ts +5 -0
  2810. package/dist/wiki/__tests__/session-hooks.test.d.ts.map +1 -0
  2811. package/dist/wiki/__tests__/session-hooks.test.js +64 -0
  2812. package/dist/wiki/__tests__/session-hooks.test.js.map +1 -0
  2813. package/dist/wiki/__tests__/slug-nonascii.test.d.ts +2 -0
  2814. package/dist/wiki/__tests__/slug-nonascii.test.d.ts.map +1 -0
  2815. package/dist/wiki/__tests__/slug-nonascii.test.js +30 -0
  2816. package/dist/wiki/__tests__/slug-nonascii.test.js.map +1 -0
  2817. package/dist/wiki/__tests__/storage.test.d.ts +5 -0
  2818. package/dist/wiki/__tests__/storage.test.d.ts.map +1 -0
  2819. package/dist/wiki/__tests__/storage.test.js +318 -0
  2820. package/dist/wiki/__tests__/storage.test.js.map +1 -0
  2821. package/dist/wiki/__tests__/test-helpers.d.ts +31 -0
  2822. package/dist/wiki/__tests__/test-helpers.d.ts.map +1 -0
  2823. package/dist/wiki/__tests__/test-helpers.js +108 -0
  2824. package/dist/wiki/__tests__/test-helpers.js.map +1 -0
  2825. package/dist/wiki/index.d.ts +14 -0
  2826. package/dist/wiki/index.d.ts.map +1 -0
  2827. package/dist/wiki/index.js +17 -0
  2828. package/dist/wiki/index.js.map +1 -0
  2829. package/dist/wiki/ingest.d.ts +20 -0
  2830. package/dist/wiki/ingest.d.ts.map +1 -0
  2831. package/dist/wiki/ingest.js +115 -0
  2832. package/dist/wiki/ingest.js.map +1 -0
  2833. package/dist/wiki/lifecycle.d.ts +25 -0
  2834. package/dist/wiki/lifecycle.d.ts.map +1 -0
  2835. package/dist/wiki/lifecycle.js +239 -0
  2836. package/dist/wiki/lifecycle.js.map +1 -0
  2837. package/dist/wiki/lint.d.ts +25 -0
  2838. package/dist/wiki/lint.d.ts.map +1 -0
  2839. package/dist/wiki/lint.js +170 -0
  2840. package/dist/wiki/lint.js.map +1 -0
  2841. package/dist/wiki/query.d.ts +36 -0
  2842. package/dist/wiki/query.d.ts.map +1 -0
  2843. package/dist/wiki/query.js +139 -0
  2844. package/dist/wiki/query.js.map +1 -0
  2845. package/dist/wiki/storage.d.ts +37 -0
  2846. package/dist/wiki/storage.d.ts.map +1 -0
  2847. package/dist/wiki/storage.js +358 -0
  2848. package/dist/wiki/storage.js.map +1 -0
  2849. package/dist/wiki/types.d.ts +83 -0
  2850. package/dist/wiki/types.d.ts.map +1 -0
  2851. package/dist/wiki/types.js +15 -0
  2852. package/dist/wiki/types.js.map +1 -0
  2853. package/package.json +110 -0
  2854. package/plugins/oh-my-codex/.app.json +3 -0
  2855. package/plugins/oh-my-codex/.codex-plugin/plugin.json +31 -0
  2856. package/plugins/oh-my-codex/.mcp.json +52 -0
  2857. package/plugins/oh-my-codex/hooks/codex-native-hook.mjs +420 -0
  2858. package/plugins/oh-my-codex/hooks/hooks.json +76 -0
  2859. package/plugins/oh-my-codex/skills/ai-slop-cleaner/SKILL.md +148 -0
  2860. package/plugins/oh-my-codex/skills/analyze/SKILL.md +146 -0
  2861. package/plugins/oh-my-codex/skills/ask/SKILL.md +58 -0
  2862. package/plugins/oh-my-codex/skills/autopilot/SKILL.md +215 -0
  2863. package/plugins/oh-my-codex/skills/autoresearch/SKILL.md +72 -0
  2864. package/plugins/oh-my-codex/skills/autoresearch-goal/SKILL.md +36 -0
  2865. package/plugins/oh-my-codex/skills/best-practice-research/SKILL.md +88 -0
  2866. package/plugins/oh-my-codex/skills/cancel/SKILL.md +399 -0
  2867. package/plugins/oh-my-codex/skills/code-review/SKILL.md +292 -0
  2868. package/plugins/oh-my-codex/skills/configure-notifications/SKILL.md +287 -0
  2869. package/plugins/oh-my-codex/skills/deep-interview/SKILL.md +579 -0
  2870. package/plugins/oh-my-codex/skills/design/SKILL.md +180 -0
  2871. package/plugins/oh-my-codex/skills/doctor/SKILL.md +239 -0
  2872. package/plugins/oh-my-codex/skills/hud/SKILL.md +98 -0
  2873. package/plugins/oh-my-codex/skills/omx-setup/SKILL.md +135 -0
  2874. package/plugins/oh-my-codex/skills/performance-goal/SKILL.md +65 -0
  2875. package/plugins/oh-my-codex/skills/pipeline/SKILL.md +97 -0
  2876. package/plugins/oh-my-codex/skills/plan/SKILL.md +277 -0
  2877. package/plugins/oh-my-codex/skills/prometheus-strict/README.md +35 -0
  2878. package/plugins/oh-my-codex/skills/prometheus-strict/SKILL.md +219 -0
  2879. package/plugins/oh-my-codex/skills/ralph/SKILL.md +294 -0
  2880. package/plugins/oh-my-codex/skills/ralplan/SKILL.md +203 -0
  2881. package/plugins/oh-my-codex/skills/skill/SKILL.md +836 -0
  2882. package/plugins/oh-my-codex/skills/team/SKILL.md +536 -0
  2883. package/plugins/oh-my-codex/skills/ultragoal/SKILL.md +139 -0
  2884. package/plugins/oh-my-codex/skills/ultraqa/SKILL.md +263 -0
  2885. package/plugins/oh-my-codex/skills/ultrawork/SKILL.md +190 -0
  2886. package/plugins/oh-my-codex/skills/visual-ralph/SKILL.md +161 -0
  2887. package/plugins/oh-my-codex/skills/wiki/SKILL.md +57 -0
  2888. package/plugins/oh-my-codex/skills/worker/SKILL.md +120 -0
  2889. package/prompts/analyst.md +135 -0
  2890. package/prompts/api-reviewer.md +113 -0
  2891. package/prompts/architect.md +111 -0
  2892. package/prompts/build-fixer.md +115 -0
  2893. package/prompts/code-reviewer.md +139 -0
  2894. package/prompts/code-simplifier.md +134 -0
  2895. package/prompts/critic.md +80 -0
  2896. package/prompts/debugger.md +117 -0
  2897. package/prompts/dependency-expert.md +129 -0
  2898. package/prompts/designer.md +126 -0
  2899. package/prompts/executor.md +108 -0
  2900. package/prompts/explore-harness.md +64 -0
  2901. package/prompts/explore.md +85 -0
  2902. package/prompts/git-master.md +114 -0
  2903. package/prompts/information-architect.md +226 -0
  2904. package/prompts/performance-reviewer.md +109 -0
  2905. package/prompts/planner.md +110 -0
  2906. package/prompts/product-analyst.md +304 -0
  2907. package/prompts/product-manager.md +245 -0
  2908. package/prompts/prometheus-strict-metis.md +274 -0
  2909. package/prompts/prometheus-strict-momus.md +82 -0
  2910. package/prompts/prometheus-strict-oracle.md +107 -0
  2911. package/prompts/qa-tester.md +124 -0
  2912. package/prompts/quality-reviewer.md +123 -0
  2913. package/prompts/quality-strategist.md +274 -0
  2914. package/prompts/researcher.md +122 -0
  2915. package/prompts/scholastic.md +11 -0
  2916. package/prompts/security-reviewer.md +143 -0
  2917. package/prompts/sisyphus-lite.md +111 -0
  2918. package/prompts/style-reviewer.md +102 -0
  2919. package/prompts/team-executor.md +57 -0
  2920. package/prompts/team-orchestrator.md +8 -0
  2921. package/prompts/test-engineer.md +130 -0
  2922. package/prompts/ux-researcher.md +327 -0
  2923. package/prompts/verifier.md +85 -0
  2924. package/prompts/vision.md +98 -0
  2925. package/prompts/writer.md +109 -0
  2926. package/skills/ai-slop-cleaner/SKILL.md +148 -0
  2927. package/skills/analyze/SKILL.md +146 -0
  2928. package/skills/ask/SKILL.md +58 -0
  2929. package/skills/ask-claude/SKILL.md +12 -0
  2930. package/skills/ask-gemini/SKILL.md +12 -0
  2931. package/skills/autopilot/SKILL.md +215 -0
  2932. package/skills/autoresearch/SKILL.md +72 -0
  2933. package/skills/autoresearch-goal/SKILL.md +36 -0
  2934. package/skills/best-practice-research/SKILL.md +88 -0
  2935. package/skills/build-fix/SKILL.md +10 -0
  2936. package/skills/cancel/SKILL.md +399 -0
  2937. package/skills/code-review/SKILL.md +292 -0
  2938. package/skills/configure-notifications/SKILL.md +287 -0
  2939. package/skills/deep-interview/SKILL.md +579 -0
  2940. package/skills/deepsearch/SKILL.md +10 -0
  2941. package/skills/design/SKILL.md +180 -0
  2942. package/skills/doctor/SKILL.md +239 -0
  2943. package/skills/ecomode/SKILL.md +114 -0
  2944. package/skills/frontend-ui-ux/SKILL.md +16 -0
  2945. package/skills/git-master/SKILL.md +27 -0
  2946. package/skills/help/SKILL.md +10 -0
  2947. package/skills/hud/SKILL.md +98 -0
  2948. package/skills/note/SKILL.md +10 -0
  2949. package/skills/omx-setup/SKILL.md +135 -0
  2950. package/skills/performance-goal/SKILL.md +65 -0
  2951. package/skills/pipeline/SKILL.md +97 -0
  2952. package/skills/plan/SKILL.md +277 -0
  2953. package/skills/prometheus-strict/README.md +35 -0
  2954. package/skills/prometheus-strict/SKILL.md +219 -0
  2955. package/skills/ralph/SKILL.md +294 -0
  2956. package/skills/ralph-init/SKILL.md +10 -0
  2957. package/skills/ralplan/SKILL.md +203 -0
  2958. package/skills/review/SKILL.md +10 -0
  2959. package/skills/security-review/SKILL.md +10 -0
  2960. package/skills/skill/SKILL.md +836 -0
  2961. package/skills/swarm/SKILL.md +12 -0
  2962. package/skills/tdd/SKILL.md +104 -0
  2963. package/skills/team/SKILL.md +536 -0
  2964. package/skills/trace/SKILL.md +10 -0
  2965. package/skills/ultragoal/SKILL.md +139 -0
  2966. package/skills/ultraqa/SKILL.md +263 -0
  2967. package/skills/ultrawork/SKILL.md +190 -0
  2968. package/skills/visual-ralph/SKILL.md +161 -0
  2969. package/skills/visual-verdict/SKILL.md +10 -0
  2970. package/skills/web-clone/SKILL.md +357 -0
  2971. package/skills/wiki/SKILL.md +57 -0
  2972. package/skills/worker/SKILL.md +120 -0
  2973. package/src/scripts/__tests__/codex-native-hook.test.ts +17173 -0
  2974. package/src/scripts/__tests__/docs-site-contract.test.ts +47 -0
  2975. package/src/scripts/__tests__/generate-release-body.test.ts +275 -0
  2976. package/src/scripts/__tests__/hook-derived-watcher.test.ts +285 -0
  2977. package/src/scripts/__tests__/notify-dispatcher.test.ts +504 -0
  2978. package/src/scripts/__tests__/notify-state-io.test.ts +168 -0
  2979. package/src/scripts/__tests__/notify-tmux-injection.test.ts +82 -0
  2980. package/src/scripts/__tests__/postinstall.test.ts +113 -0
  2981. package/src/scripts/__tests__/prompt-inventory.test.ts +64 -0
  2982. package/src/scripts/__tests__/run-test-files.test.ts +455 -0
  2983. package/src/scripts/__tests__/smoke-packed-install.test.ts +192 -0
  2984. package/src/scripts/__tests__/test-reply-listener-live.test.ts +101 -0
  2985. package/src/scripts/__tests__/verify-native-agents.test.ts +299 -0
  2986. package/src/scripts/ask-claude.sh +17 -0
  2987. package/src/scripts/ask-gemini.sh +14 -0
  2988. package/src/scripts/build-api.ts +48 -0
  2989. package/src/scripts/build-explore-harness.ts +54 -0
  2990. package/src/scripts/build-sparkshell.ts +52 -0
  2991. package/src/scripts/check-runtime-syntax.ts +63 -0
  2992. package/src/scripts/check-version-sync.ts +54 -0
  2993. package/src/scripts/cleanup-explore-harness.ts +18 -0
  2994. package/src/scripts/codex-execution-surface.ts +75 -0
  2995. package/src/scripts/codex-native-hook.ts +4877 -0
  2996. package/src/scripts/codex-native-pre-post.ts +1360 -0
  2997. package/src/scripts/demo-claude-workers.sh +241 -0
  2998. package/src/scripts/demo-team-e2e.sh +184 -0
  2999. package/src/scripts/eval/eval-adaptive-sort-optimization.py +24 -0
  3000. package/src/scripts/eval/eval-candidate-handoff.ts +8 -0
  3001. package/src/scripts/eval/eval-cli-discoverability.ts +40 -0
  3002. package/src/scripts/eval/eval-fresh-run-tagging.ts +8 -0
  3003. package/src/scripts/eval/eval-help-consistency.ts +11 -0
  3004. package/src/scripts/eval/eval-in-action-cat-shellout-demo.ts +31 -0
  3005. package/src/scripts/eval/eval-ml-kaggle-model-optimization.py +29 -0
  3006. package/src/scripts/eval/eval-noisy-bayesopt-highdim.py +44 -0
  3007. package/src/scripts/eval/eval-noisy-latent-subspace-discovery.py +44 -0
  3008. package/src/scripts/eval/eval-parity-smoke.ts +20 -0
  3009. package/src/scripts/eval/eval-parity-sweep.ts +26 -0
  3010. package/src/scripts/eval/eval-resume-dirty-guard.ts +8 -0
  3011. package/src/scripts/eval/eval-security-path-traversal.ts +38 -0
  3012. package/src/scripts/fixtures/ask-advisor-stub.ts +12 -0
  3013. package/src/scripts/generate-catalog-docs.ts +112 -0
  3014. package/src/scripts/generate-native-release-manifest.ts +147 -0
  3015. package/src/scripts/generate-release-body.ts +327 -0
  3016. package/src/scripts/hook-derived-watcher.ts +649 -0
  3017. package/src/scripts/hook-payload-guard.ts +113 -0
  3018. package/src/scripts/notify-dispatcher.ts +408 -0
  3019. package/src/scripts/notify-fallback-watcher.ts +2022 -0
  3020. package/src/scripts/notify-hook/__tests__/operational-events.test.ts +24 -0
  3021. package/src/scripts/notify-hook/__tests__/payload-guard.test.ts +41 -0
  3022. package/src/scripts/notify-hook/__tests__/team-worker-posttooluse.test.ts +180 -0
  3023. package/src/scripts/notify-hook/active-team.ts +55 -0
  3024. package/src/scripts/notify-hook/auto-nudge.ts +758 -0
  3025. package/src/scripts/notify-hook/log.ts +30 -0
  3026. package/src/scripts/notify-hook/managed-tmux.ts +568 -0
  3027. package/src/scripts/notify-hook/operational-events.ts +282 -0
  3028. package/src/scripts/notify-hook/orchestration-intent.ts +80 -0
  3029. package/src/scripts/notify-hook/payload-parser.ts +143 -0
  3030. package/src/scripts/notify-hook/process-runner.ts +75 -0
  3031. package/src/scripts/notify-hook/ralph-session-resume.ts +465 -0
  3032. package/src/scripts/notify-hook/state-io.ts +220 -0
  3033. package/src/scripts/notify-hook/team-dispatch.ts +1162 -0
  3034. package/src/scripts/notify-hook/team-leader-nudge.ts +1068 -0
  3035. package/src/scripts/notify-hook/team-tmux-guard.ts +236 -0
  3036. package/src/scripts/notify-hook/team-worker-posttooluse.ts +536 -0
  3037. package/src/scripts/notify-hook/team-worker-stop.ts +438 -0
  3038. package/src/scripts/notify-hook/team-worker.ts +709 -0
  3039. package/src/scripts/notify-hook/tmux-injection.ts +740 -0
  3040. package/src/scripts/notify-hook/utils.ts +31 -0
  3041. package/src/scripts/notify-hook/visual-verdict.ts +158 -0
  3042. package/src/scripts/notify-hook.ts +1033 -0
  3043. package/src/scripts/postinstall.ts +107 -0
  3044. package/src/scripts/prepare-build.js +83 -0
  3045. package/src/scripts/prompt-inventory.ts +218 -0
  3046. package/src/scripts/run-autoresearch-showcase.sh +75 -0
  3047. package/src/scripts/run-provider-advisor.ts +213 -0
  3048. package/src/scripts/run-test-files.ts +379 -0
  3049. package/src/scripts/smoke-packed-install.ts +268 -0
  3050. package/src/scripts/sync-plugin-mirror.ts +458 -0
  3051. package/src/scripts/sync-prompt-guidance-fragments.ts +55 -0
  3052. package/src/scripts/team-hardening-benchmark.ts +90 -0
  3053. package/src/scripts/test-reply-listener-live.ts +188 -0
  3054. package/src/scripts/test-sparkshell.ts +29 -0
  3055. package/src/scripts/tmux-hook-engine.ts +349 -0
  3056. package/src/scripts/verify-native-agents.ts +311 -0
  3057. package/src/scripts/verify-native-release-assets.ts +68 -0
  3058. package/templates/AGENTS.md +187 -0
  3059. package/templates/catalog-manifest.json +547 -0
  3060. package/templates/model-instructions/explore-lightweight-AGENTS.md +11 -0
  3061. package/templates/model-instructions/sparkshell-lightweight-AGENTS.md +10 -0
@@ -0,0 +1,4877 @@
1
+ import { execFileSync } from "child_process";
2
+ import { closeSync, existsSync, openSync, readFileSync, readSync, statSync } from "fs";
3
+ import { appendFile, mkdir, readFile, readdir, stat, writeFile } from "fs/promises";
4
+ import { extname, join, relative, resolve } from "path";
5
+ import { pathToFileURL } from "url";
6
+ import { readModeStateForActiveDecision, readModeStateForSession, updateModeState } from "../modes/base.js";
7
+ import { redactAuthSecrets } from "../auth/redact.js";
8
+ import {
9
+ SKILL_ACTIVE_STATE_FILE,
10
+ extractSessionIdFromInitializedStatePath,
11
+ getSkillActiveStatePathsForStateDir,
12
+ listActiveSkills,
13
+ readSkillActiveState,
14
+ readVisibleSkillActiveStateForStateDir,
15
+ type SkillActiveStateLike,
16
+ } from "../state/skill-active.js";
17
+ import {
18
+ isTrustedSubagentThread,
19
+ readSubagentSessionSummary,
20
+ readSubagentTrackingState,
21
+ recordSubagentTurnForSession,
22
+ } from "../subagents/tracker.js";
23
+ import { resolveCanonicalTeamStateRoot, resolveWorkerNotifyTeamStateRootPath } from "../team/state-root.js";
24
+ import {
25
+ appendToLog,
26
+ isSessionStateUsable,
27
+ readSessionState,
28
+ readUsableSessionState,
29
+ reconcileNativeSessionStart,
30
+ type SessionState,
31
+ } from "../hooks/session.js";
32
+ import {
33
+ appendTeamEvent,
34
+ listTasks,
35
+ readTeamLeaderAttention,
36
+ readTeamConfig,
37
+ readTeamManifestV2,
38
+ readTeamPhase,
39
+ readWorkerStatus,
40
+ writeTeamLeaderAttention,
41
+ writeTeamPhase,
42
+ } from "../team/state.js";
43
+ import { omxNotepadPath, resolveProjectMemoryPath } from "../utils/paths.js";
44
+ import { findGitLayout } from "../utils/git-layout.js";
45
+ import { getBaseStateDir, getStateFilePath, getStatePath } from "../mcp/state-paths.js";
46
+ import {
47
+ detectKeywords,
48
+ detectPrimaryKeyword,
49
+ recordSkillActivation,
50
+ type SkillActiveState,
51
+ } from "../hooks/keyword-detector.js";
52
+ import { buildDeepInterviewConfigInstruction } from "../hooks/deep-interview-config-instruction.js";
53
+ import { readTeamModeConfig } from "../config/team-mode.js";
54
+ import {
55
+ detectNativeStopStallPattern,
56
+ loadAutoNudgeConfig,
57
+ normalizeAutoNudgeSignatureText,
58
+ resolveEffectiveAutoNudgeResponse,
59
+ } from "./notify-hook/auto-nudge.js";
60
+ import {
61
+ SLOPPY_FALLBACK_GROUNDING_PATTERNS,
62
+ SLOPPY_FALLBACK_IMPLEMENTATION_CONTEXT_PATTERNS,
63
+ SLOPPY_FALLBACK_PHRASE_PATTERNS,
64
+ buildNativePostToolUseOutput,
65
+ buildNativePreToolUseOutput,
66
+ detectMcpTransportFailure,
67
+ hasAnyPattern,
68
+ } from "./codex-native-pre-post.js";
69
+ import { handleTeamWorkerPostToolUseSuccess } from "./notify-hook/team-worker-posttooluse.js";
70
+ import { maybeNudgeLeaderForAllowedWorkerStop } from "./notify-hook/team-worker-stop.js";
71
+ import {
72
+ resolveCodexExecutionSurface,
73
+ type CodexLauncherKind,
74
+ type CodexTransportKind,
75
+ } from "./codex-execution-surface.js";
76
+ import {
77
+ buildNativeHookEvent,
78
+ } from "../hooks/extensibility/events.js";
79
+ import type { HookEventEnvelope } from "../hooks/extensibility/types.js";
80
+ import { dispatchHookEventRuntime } from "../hooks/extensibility/runtime.js";
81
+ import { getNotificationConfig, getVerbosity } from "../notifications/config.js";
82
+ import { reconcileHudForPromptSubmit } from "../hud/reconcile.js";
83
+ import {
84
+ onPreCompact as buildWikiPreCompactContext,
85
+ onSessionStart as buildWikiSessionStartContext,
86
+ } from "../wiki/lifecycle.js";
87
+ import { readAutoresearchCompletionStatus, readAutoresearchModeStateForActiveDecision } from "../autoresearch/skill-validation.js";
88
+ import { normalizeAutopilotPhase } from "../autopilot/fsm.js";
89
+ import { readRunState } from "../runtime/run-state.js";
90
+ import { evaluateRalphCompletionAuditEvidence, isRalphCompletePhase } from "../ralph/completion-audit.js";
91
+ import { getRunContinuationSnapshot, shouldContinueRun } from "../runtime/run-loop.js";
92
+ import {
93
+ parseUltragoalSteeringDirective,
94
+ steerUltragoal,
95
+ type UltragoalSteeringProposal,
96
+ } from "../ultragoal/artifacts.js";
97
+ import { triagePrompt } from "../hooks/triage-heuristic.js";
98
+ import { readTriageConfig } from "../hooks/triage-config.js";
99
+ import {
100
+ readTriageState,
101
+ writeTriageState,
102
+ shouldSuppressFollowup,
103
+ promptSignature,
104
+ type TriageStateFile,
105
+ } from "../hooks/triage-state.js";
106
+ import {
107
+ isPendingDeepInterviewQuestionEnforcement,
108
+ reconcileDeepInterviewQuestionEnforcementFromAnsweredRecords,
109
+ } from "../question/deep-interview.js";
110
+ import { readAutopilotDeepInterviewQuestionWaitState } from "../question/autopilot-wait.js";
111
+ import {
112
+ buildDocumentRefreshAdvisoryOutput,
113
+ evaluateFinalHandoffDocumentRefresh,
114
+ isFinalHandoffDocumentRefreshCandidate,
115
+ } from "../document-refresh/enforcer.js";
116
+ import { buildExecFollowupStopOutput } from "../exec/followup.js";
117
+ import {
118
+ MAX_NATIVE_STDIN_JSON_BYTES,
119
+ extractRawCodexHookEventName,
120
+ } from "./hook-payload-guard.js";
121
+
122
+ type CodexHookEventName =
123
+ | "SessionStart"
124
+ | "PreToolUse"
125
+ | "PostToolUse"
126
+ | "UserPromptSubmit"
127
+ | "PreCompact"
128
+ | "PostCompact"
129
+ | "Stop";
130
+
131
+ type CodexHookPayload = Record<string, unknown>;
132
+
133
+ interface NativeHookDispatchOptions {
134
+ cwd?: string;
135
+ sessionOwnerPid?: number;
136
+ reconcileHudForPromptSubmitFn?: typeof reconcileHudForPromptSubmit;
137
+ }
138
+
139
+ export interface NativeHookDispatchResult {
140
+ hookEventName: CodexHookEventName | null;
141
+ omxEventName: string | null;
142
+ skillState: SkillActiveState | null;
143
+ outputJson: Record<string, unknown> | null;
144
+ }
145
+
146
+ const TERMINAL_MODE_PHASES = new Set(["complete", "completed", "failed", "cancelled"]);
147
+ const SKILL_STOP_BLOCKERS = new Set(["ralplan"]);
148
+ const TEAM_STOP_BLOCKING_TASK_STATUSES = new Set(["pending", "in_progress", "blocked"]);
149
+ const TEAM_WORKER_TERMINAL_RUN_STATES = new Set(["done", "complete", "completed", "failed", "stopped", "cancelled"]);
150
+ const NATIVE_STOP_STATE_FILE = "native-stop-state.json";
151
+ const ORDINARY_STOP_NO_PROGRESS_DEFAULT_MAX_REPEATS = 8;
152
+ const RALPH_ORPHANED_STARTING_STALE_MS = 15 * 60_000;
153
+ const ORDINARY_STOP_NO_PROGRESS_DEFAULT_IDLE_MS = 10 * 60_000;
154
+ const ORDINARY_STOP_NO_PROGRESS_MAX_MESSAGE_LENGTH = 240;
155
+ const OMX_OWNER_SESSION_ID_PATTERN = /^omx-[A-Za-z0-9_-]{1,60}$/;
156
+ const STABLE_FINAL_RECOMMENDATION_PATTERNS = [
157
+ /^\s*(?:launch|release|ship)-?ready\s*:\s*(?:yes|no)\b[^\n\r]*/im,
158
+ /^\s*ready to release\s*:\s*(?:yes|no)\b[^\n\r]*/im,
159
+ /^\s*(?:final\s+)?recommendation\s*:\s*(?:yes|no|ship|hold|release|do not release|proceed|do not proceed)\b[^\n\r]*/im,
160
+ /^\s*decision\s*:\s*(?:yes|no|ship|hold|release|do not release|proceed|do not proceed)\b[^\n\r]*/im,
161
+ ] as const;
162
+ const RELEASE_READINESS_FINALIZE_SYSTEM_MESSAGE =
163
+ "OMX release-readiness detected a stable final recommendation with no active worker tasks; emit one concise final decision summary and finalize.";
164
+ const EXECUTION_HANDOFF_PATTERNS = [
165
+ /^(?:好|好的|行|可以|那就|那现在)?[,,\s]*(?:开始|继续|直接)\s*(?:执行|优化|实现|修改|修复)(?=$|\s|[,,。.!!??])/u,
166
+ /(?:按照|按|基于)(?:这个|上述|当前)?\s*(?:plan|计划|方案).{0,16}(?:开始|继续|直接)?\s*(?:执行|优化|实现|修改|修复)/u,
167
+ /(?:不用|别|不要).{0,6}讨论/u,
168
+ /\b(?:start|begin|go ahead(?: and)?|proceed(?: now)?)\s+(?:to\s+)?(?:implement|execute|apply|fix)\b/i,
169
+ /\b(?:according to|based on)\s+(?:the|this|that)\s+plan\b.{0,20}\b(?:start|begin|proceed(?: now)?|go ahead(?: and)?)\b/i,
170
+ ] as const;
171
+ const SHORT_FOLLOWUP_PRIORITY_PATTERNS = [
172
+ /^(?:继续|接着|然后|那就|那现在|还有(?:一个)?问题|这些优化都做了么|这些都做了么|现在呢|本轮|当前轮|这一轮)/u,
173
+ /(?:按照|按|基于)(?:这个|上述|当前)?(?:plan|计划|方案)/u,
174
+ /\b(?:follow up|latest request|this turn|current turn|newest request)\b/i,
175
+ ] as const;
176
+ const MAX_SESSION_META_LINE_BYTES = 256 * 1024;
177
+
178
+ function safeString(value: unknown): string {
179
+ return typeof value === "string" ? value : "";
180
+ }
181
+
182
+ function safeObject(value: unknown): Record<string, unknown> {
183
+ return value && typeof value === "object" ? value as Record<string, unknown> : {};
184
+ }
185
+
186
+ function resolveHudReconcileSessionId(
187
+ currentSessionState: SessionState | null,
188
+ canonicalSessionId: string | null,
189
+ sessionIdForState: string | null,
190
+ ): string | undefined {
191
+ const ownerOmxSessionId = safeString(currentSessionState?.owner_omx_session_id).trim();
192
+ if (OMX_OWNER_SESSION_ID_PATTERN.test(ownerOmxSessionId)) return ownerOmxSessionId;
193
+ return canonicalSessionId || sessionIdForState || undefined;
194
+ }
195
+
196
+ function resolveHudReconcileSessionIds(
197
+ currentSessionState: SessionState | null,
198
+ canonicalSessionId: string | null,
199
+ sessionIdForState: string | null,
200
+ nativeSessionId: string | null,
201
+ ): string[] {
202
+ const ownerOmxSessionId = safeString(currentSessionState?.owner_omx_session_id).trim();
203
+ return uniqueNonEmpty([
204
+ resolveHudReconcileSessionId(currentSessionState, canonicalSessionId, sessionIdForState),
205
+ canonicalSessionId ?? undefined,
206
+ sessionIdForState ?? undefined,
207
+ nativeSessionId ?? undefined,
208
+ safeString(currentSessionState?.session_id),
209
+ safeString(currentSessionState?.native_session_id),
210
+ OMX_OWNER_SESSION_ID_PATTERN.test(ownerOmxSessionId) ? ownerOmxSessionId : undefined,
211
+ safeString(currentSessionState?.owner_codex_session_id),
212
+ ]);
213
+ }
214
+
215
+ function safeContextSnippet(value: unknown, maxLength = 300): string {
216
+ const text = safeString(value).replace(/\s+/g, " ").trim();
217
+ if (text.length <= maxLength) return text;
218
+ return `${text.slice(0, maxLength - 1).trimEnd()}…`;
219
+ }
220
+
221
+ const SIDE_CONVERSATION_BOUNDARY_PATTERNS = [
222
+ /side conversation boundary/i,
223
+ /inherited history from the parent thread/i,
224
+ /reference context only/i,
225
+ /only messages submitted after this boundary are active/i,
226
+ /side-conversation assistant/i,
227
+ ] as const;
228
+
229
+ function textHasSideConversationBoundary(text: string): boolean {
230
+ return SIDE_CONVERSATION_BOUNDARY_PATTERNS.some((pattern) => pattern.test(text));
231
+ }
232
+
233
+ function isLikelySideConversationStopPayload(payload: CodexHookPayload): boolean {
234
+ const payloadText = [
235
+ payload.prompt,
236
+ payload.user_prompt,
237
+ payload.userPrompt,
238
+ payload.input,
239
+ payload.last_user_message,
240
+ payload.lastUserMessage,
241
+ payload.last_assistant_message,
242
+ payload.lastAssistantMessage,
243
+ ].map(safeString).join("\n");
244
+ if (textHasSideConversationBoundary(payloadText)) return true;
245
+
246
+ const transcriptPath = safeString(payload.transcript_path ?? payload.transcriptPath).trim();
247
+ if (!transcriptPath || !existsSync(transcriptPath)) return false;
248
+
249
+ try {
250
+ const maxBytes = 256 * 1024;
251
+ const stats = statSync(transcriptPath);
252
+ const fd = openSync(transcriptPath, "r");
253
+ try {
254
+ const bytesToRead = Math.min(maxBytes, Math.max(0, stats.size));
255
+ const buffer = Buffer.alloc(bytesToRead);
256
+ const position = Math.max(0, stats.size - bytesToRead);
257
+ const bytesRead = readSync(fd, buffer, 0, bytesToRead, position);
258
+ return textHasSideConversationBoundary(buffer.toString("utf-8", 0, bytesRead));
259
+ } finally {
260
+ closeSync(fd);
261
+ }
262
+ } catch {
263
+ return false;
264
+ }
265
+ }
266
+
267
+ function shouldSuppressParentWorkflowStopForSideConversation(payload: CodexHookPayload): boolean {
268
+ if (safeString(payload.hook_event_name ?? payload.hookEventName).trim() !== "Stop") return false;
269
+ return isLikelySideConversationStopPayload(payload);
270
+ }
271
+
272
+ interface NativeSubagentSessionStartMetadata {
273
+ parentThreadId: string;
274
+ agentNickname?: string;
275
+ agentRole?: string;
276
+ }
277
+
278
+ function readBoundedFirstLineSync(path: string): string {
279
+ const fd = openSync(path, "r");
280
+ try {
281
+ const chunks: Buffer[] = [];
282
+ const buffer = Buffer.alloc(Math.min(8192, MAX_SESSION_META_LINE_BYTES));
283
+ let totalBytesRead = 0;
284
+
285
+ while (totalBytesRead < MAX_SESSION_META_LINE_BYTES) {
286
+ const bytesToRead = Math.min(buffer.length, MAX_SESSION_META_LINE_BYTES - totalBytesRead);
287
+ const bytesRead = readSync(fd, buffer, 0, bytesToRead, totalBytesRead);
288
+ if (bytesRead <= 0) break;
289
+
290
+ totalBytesRead += bytesRead;
291
+ const chunk = buffer.subarray(0, bytesRead);
292
+ const newlineOffset = chunk.indexOf(0x0a);
293
+ if (newlineOffset >= 0) {
294
+ chunks.push(Buffer.from(chunk.subarray(0, newlineOffset)));
295
+ break;
296
+ }
297
+ chunks.push(Buffer.from(chunk));
298
+ }
299
+
300
+ return Buffer.concat(chunks).toString("utf-8").replace(/\r$/, "");
301
+ } finally {
302
+ closeSync(fd);
303
+ }
304
+ }
305
+
306
+ function readNativeSubagentSessionStartMetadata(transcriptPath: string): NativeSubagentSessionStartMetadata | null {
307
+ const normalizedPath = transcriptPath.trim();
308
+ if (!normalizedPath) return null;
309
+
310
+ try {
311
+ const firstLine = readBoundedFirstLineSync(normalizedPath).trim();
312
+ if (!firstLine) return null;
313
+ const firstRecord = safeObject(JSON.parse(firstLine));
314
+ if (safeString(firstRecord.type) !== "session_meta") return null;
315
+
316
+ const payload = safeObject(firstRecord.payload);
317
+ const source = safeObject(payload.source);
318
+ const subagent = safeObject(source.subagent);
319
+ const threadSpawn = safeObject(subagent.thread_spawn);
320
+ const parentThreadId = safeString(threadSpawn.parent_thread_id).trim();
321
+ if (!parentThreadId) return null;
322
+
323
+ const agentNickname = safeString(threadSpawn.agent_nickname ?? payload.agent_nickname).trim();
324
+ const agentRole = safeString(threadSpawn.agent_role ?? payload.agent_role).trim();
325
+ return {
326
+ parentThreadId,
327
+ ...(agentNickname ? { agentNickname } : {}),
328
+ ...(agentRole ? { agentRole } : {}),
329
+ };
330
+ } catch {
331
+ return null;
332
+ }
333
+ }
334
+
335
+ async function recordNativeSubagentSessionStart(
336
+ cwd: string,
337
+ canonicalSessionId: string,
338
+ childSessionId: string,
339
+ metadata: NativeSubagentSessionStartMetadata,
340
+ transcriptPath: string,
341
+ ): Promise<void> {
342
+ const parentThreadId = metadata.parentThreadId.trim();
343
+ const childThreadId = childSessionId.trim();
344
+ const trackingSessionIds = [...new Set([
345
+ canonicalSessionId.trim(),
346
+ parentThreadId,
347
+ ].filter(Boolean))];
348
+ for (const sessionId of trackingSessionIds) {
349
+ if (parentThreadId && parentThreadId !== childThreadId) {
350
+ await recordSubagentTurnForSession(cwd, {
351
+ sessionId,
352
+ threadId: parentThreadId,
353
+ kind: 'leader',
354
+ }).catch(() => {});
355
+ }
356
+ await recordSubagentTurnForSession(cwd, {
357
+ sessionId,
358
+ threadId: childThreadId,
359
+ kind: 'subagent',
360
+ ...(parentThreadId && parentThreadId !== childThreadId ? { leaderThreadId: parentThreadId } : {}),
361
+ mode: metadata.agentRole,
362
+ }).catch(() => {});
363
+ }
364
+ await appendToLog(cwd, {
365
+ event: "subagent_session_start",
366
+ session_id: canonicalSessionId,
367
+ native_owner_session_id: metadata.parentThreadId,
368
+ native_session_id: childSessionId,
369
+ parent_thread_id: metadata.parentThreadId,
370
+ ...(metadata.agentNickname ? { agent_nickname: metadata.agentNickname } : {}),
371
+ ...(metadata.agentRole ? { agent_role: metadata.agentRole } : {}),
372
+ ...(transcriptPath ? { transcript_path: transcriptPath } : {}),
373
+ timestamp: new Date().toISOString(),
374
+ }).catch(() => {});
375
+ }
376
+
377
+ async function nativeSubagentSessionStartBelongsToCanonicalSession(
378
+ cwd: string,
379
+ canonicalSessionId: string,
380
+ currentSessionState: SessionState | null,
381
+ metadata: NativeSubagentSessionStartMetadata,
382
+ ): Promise<boolean> {
383
+ const parentThreadId = metadata.parentThreadId.trim();
384
+ if (!parentThreadId) return false;
385
+
386
+ const currentNativeSessionId = safeString(currentSessionState?.native_session_id).trim();
387
+ if (currentNativeSessionId && currentNativeSessionId === parentThreadId) {
388
+ return true;
389
+ }
390
+
391
+ const summary = await readSubagentSessionSummary(cwd, canonicalSessionId).catch(() => null);
392
+ if (!summary) return false;
393
+ if (summary.leaderThreadId === parentThreadId) return true;
394
+ return summary.allThreadIds.includes(parentThreadId);
395
+ }
396
+
397
+ async function isNativeSubagentHook(
398
+ cwd: string,
399
+ canonicalSessionId: string,
400
+ nativeSessionId: string,
401
+ threadId: string,
402
+ canonicalLeaderNativeSessionId = "",
403
+ ): Promise<boolean> {
404
+ const nativeId = nativeSessionId.trim();
405
+ const promptThreadId = threadId.trim();
406
+ const candidateIds = [nativeId, promptThreadId]
407
+ .map((value) => value.trim())
408
+ .filter(Boolean);
409
+ if (candidateIds.length === 0) return false;
410
+
411
+ const sessionId = canonicalSessionId.trim();
412
+ const currentLeaderNativeSessionId = canonicalLeaderNativeSessionId.trim();
413
+ const summary = sessionId
414
+ ? await readSubagentSessionSummary(cwd, sessionId).catch(() => null)
415
+ : null;
416
+ const currentLeaderIds = new Set([
417
+ currentLeaderNativeSessionId,
418
+ summary?.leaderThreadId?.trim(),
419
+ ].filter(Boolean));
420
+ if (
421
+ summary
422
+ && candidateIds.some((id) => !currentLeaderIds.has(id) && summary.allSubagentThreadIds.includes(id))
423
+ ) {
424
+ return true;
425
+ }
426
+ // Native UserPromptSubmit can carry a per-turn thread_id that differs from
427
+ // the long-lived native session id. Treat the current canonical native
428
+ // session as the leader before consulting stale/global tracker state.
429
+ if (
430
+ sessionId
431
+ && currentLeaderNativeSessionId
432
+ && (
433
+ nativeId === currentLeaderNativeSessionId
434
+ || (!nativeId && promptThreadId === currentLeaderNativeSessionId)
435
+ )
436
+ ) {
437
+ return false;
438
+ }
439
+
440
+ if (summary) {
441
+ const leaderThreadId = summary.leaderThreadId?.trim();
442
+ if (
443
+ leaderThreadId
444
+ && (
445
+ nativeId === leaderThreadId
446
+ || (!nativeId && promptThreadId === leaderThreadId)
447
+ )
448
+ ) {
449
+ return false;
450
+ }
451
+ }
452
+
453
+ // Native Codex resume can report the child native session as the canonical
454
+ // session id before OMX reconciles it back to the owning session. In that
455
+ // window the per-session summary lookup above misses the child and a
456
+ // subagent UserPromptSubmit can accidentally activate workflow keywords from
457
+ // quoted review context. Fall back to the global tracking index so any known
458
+ // subagent thread is treated as subagent-scoped, regardless of the current
459
+ // hook payload's session-id mapping.
460
+ const trackingState = await readSubagentTrackingState(cwd).catch(() => null);
461
+ if (!trackingState) return false;
462
+
463
+ return Object.values(trackingState.sessions).some((session) => (
464
+ candidateIds.some((id) => isTrustedSubagentThread(session, id))
465
+ ));
466
+ }
467
+
468
+ function shouldSuppressSubagentLifecycleHookDispatch(): boolean {
469
+ const config = getNotificationConfig();
470
+ if (config?.includeChildAgents === true) return false;
471
+ const verbosity = getVerbosity(config);
472
+ return verbosity !== "agent" && verbosity !== "verbose";
473
+ }
474
+
475
+ async function recordIgnoredNativeSubagentSessionStart(
476
+ cwd: string,
477
+ canonicalSessionId: string,
478
+ childSessionId: string,
479
+ metadata: NativeSubagentSessionStartMetadata,
480
+ transcriptPath: string,
481
+ ): Promise<void> {
482
+ await appendToLog(cwd, {
483
+ event: "subagent_session_start_ignored",
484
+ reason: "parent_not_in_canonical_session",
485
+ session_id: canonicalSessionId,
486
+ native_session_id: childSessionId,
487
+ parent_thread_id: metadata.parentThreadId,
488
+ ...(metadata.agentNickname ? { agent_nickname: metadata.agentNickname } : {}),
489
+ ...(metadata.agentRole ? { agent_role: metadata.agentRole } : {}),
490
+ ...(transcriptPath ? { transcript_path: transcriptPath } : {}),
491
+ timestamp: new Date().toISOString(),
492
+ }).catch(() => {});
493
+ }
494
+
495
+ function safePositiveInteger(value: unknown): number | null {
496
+ if (typeof value === "number" && Number.isInteger(value) && value > 0) return value;
497
+ if (typeof value === "string" && value.trim() !== "") {
498
+ const parsed = Number.parseInt(value.trim(), 10);
499
+ if (Number.isInteger(parsed) && parsed > 0) return parsed;
500
+ }
501
+ return null;
502
+ }
503
+
504
+ function normalizePromptSignalText(text: string): string {
505
+ return text.trim().replace(/\s+/g, " ");
506
+ }
507
+
508
+ function looksLikeExecutionHandoffPrompt(prompt: string): boolean {
509
+ const normalized = normalizePromptSignalText(prompt);
510
+ if (!normalized) return false;
511
+ return EXECUTION_HANDOFF_PATTERNS.some((pattern) => pattern.test(normalized));
512
+ }
513
+
514
+ function looksLikeShortFollowupPrompt(prompt: string): boolean {
515
+ const normalized = normalizePromptSignalText(prompt);
516
+ if (!normalized) return false;
517
+ if (looksLikeExecutionHandoffPrompt(normalized)) return true;
518
+ if (normalized.length > 240) return false;
519
+ return SHORT_FOLLOWUP_PRIORITY_PATTERNS.some((pattern) => pattern.test(normalized));
520
+ }
521
+
522
+ function buildPromptPriorityMessage(prompt: string): string | null {
523
+ if (looksLikeExecutionHandoffPrompt(prompt)) {
524
+ return "Newest user input is an execution handoff for the current task. Treat it as authorization to act now against the latest approved plan/request. Do not restate the prior plan unless the user explicitly asks for a recap or status update.";
525
+ }
526
+ if (looksLikeShortFollowupPrompt(prompt)) {
527
+ return "Newest user input is a same-thread follow-up. Answer that latest follow-up directly and prefer it over older unresolved prompts when choosing what to do next.";
528
+ }
529
+ return null;
530
+ }
531
+
532
+ function readHookEventName(payload: CodexHookPayload): CodexHookEventName | null {
533
+ const raw = safeString(
534
+ payload.hook_event_name
535
+ ?? payload.hookEventName
536
+ ?? payload.event
537
+ ?? payload.name,
538
+ ).trim();
539
+ if (
540
+ raw === "SessionStart"
541
+ || raw === "PreToolUse"
542
+ || raw === "PostToolUse"
543
+ || raw === "UserPromptSubmit"
544
+ || raw === "PreCompact"
545
+ || raw === "PostCompact"
546
+ || raw === "Stop"
547
+ ) {
548
+ return raw;
549
+ }
550
+ return null;
551
+ }
552
+
553
+ export function mapCodexHookEventToOmxEvent(
554
+ hookEventName: CodexHookEventName | null,
555
+ ): string | null {
556
+ switch (hookEventName) {
557
+ case "SessionStart":
558
+ return "session-start";
559
+ case "PreToolUse":
560
+ return "pre-tool-use";
561
+ case "PostToolUse":
562
+ return "post-tool-use";
563
+ case "UserPromptSubmit":
564
+ return "keyword-detector";
565
+ case "PreCompact":
566
+ return "pre-compact";
567
+ case "PostCompact":
568
+ return "post-compact";
569
+ case "Stop":
570
+ return "stop";
571
+ default:
572
+ return null;
573
+ }
574
+ }
575
+
576
+ function readPromptText(payload: CodexHookPayload): string {
577
+ const candidates = [
578
+ payload.prompt,
579
+ payload.user_prompt,
580
+ payload.userPrompt,
581
+ ];
582
+ for (const candidate of candidates) {
583
+ const value = safeString(candidate).trim();
584
+ if (value) return value;
585
+ }
586
+ return "";
587
+ }
588
+
589
+
590
+ function extractBalancedJsonObject(text: string, startIndex: number): string | null {
591
+ let depth = 0;
592
+ let inString = false;
593
+ let escaped = false;
594
+ for (let index = startIndex; index < text.length; index++) {
595
+ const char = text[index];
596
+ if (inString) {
597
+ if (escaped) escaped = false;
598
+ else if (char === "\\") escaped = true;
599
+ else if (char === '"') inString = false;
600
+ continue;
601
+ }
602
+ if (char === '"') {
603
+ inString = true;
604
+ continue;
605
+ }
606
+ if (char === "{") depth += 1;
607
+ else if (char === "}") {
608
+ depth -= 1;
609
+ if (depth === 0) return text.slice(startIndex, index + 1);
610
+ }
611
+ }
612
+ return null;
613
+ }
614
+
615
+ function normalizePromptSteeringProposal(raw: unknown, prompt: string): UltragoalSteeringProposal | null {
616
+ const candidate = safeObject(raw);
617
+ const nested = candidate.omx_ultragoal_steer ?? candidate.ultragoal_steer ?? candidate.steering ?? candidate;
618
+ const proposal = parseUltragoalSteeringDirective(JSON.stringify(nested));
619
+ if (!proposal) return null;
620
+ if (proposal.source !== "user_prompt_submit") return null;
621
+ const normalized = prompt.trim().toLowerCase();
622
+ return {
623
+ ...proposal,
624
+ directiveText: proposal.directiveText ?? safeContextSnippet(prompt, 600),
625
+ promptSignature: proposal.promptSignature ?? promptSignature(normalized),
626
+ idempotencyKey: proposal.idempotencyKey ?? `user_prompt_submit:${promptSignature(normalized)}`,
627
+ };
628
+ }
629
+
630
+ function parseUserPromptUltragoalSteeringDirective(prompt: string): UltragoalSteeringProposal | null {
631
+ const trimmed = prompt.trim();
632
+ if (!trimmed) return null;
633
+ const fenced = trimmed.match(/```(?:omx-ultragoal-steer|ultragoal-steer)\s*([\s\S]*?)```/i);
634
+ if (fenced?.[1]) {
635
+ try {
636
+ return normalizePromptSteeringProposal(JSON.parse(fenced[1]), prompt);
637
+ } catch {
638
+ return null;
639
+ }
640
+ }
641
+
642
+ const label = trimmed.match(/(?:^|\n)\s*(?:OMX_ULTRAGOAL_STEER|omx\.ultragoal\.steer|omx ultragoal steer)\s*:\s*{/i);
643
+ if (label?.index !== undefined) {
644
+ const brace = trimmed.indexOf("{", label.index);
645
+ const json = brace >= 0 ? extractBalancedJsonObject(trimmed, brace) : null;
646
+ if (json) {
647
+ try {
648
+ return normalizePromptSteeringProposal(JSON.parse(json), prompt);
649
+ } catch {
650
+ return null;
651
+ }
652
+ }
653
+ }
654
+
655
+ if (trimmed.startsWith("{")) {
656
+ try {
657
+ const parsed = JSON.parse(trimmed);
658
+ const object = safeObject(parsed);
659
+ if ("omx_ultragoal_steer" in object || "ultragoal_steer" in object) {
660
+ return normalizePromptSteeringProposal(parsed, prompt);
661
+ }
662
+ } catch {
663
+ return null;
664
+ }
665
+ }
666
+ return null;
667
+ }
668
+
669
+ async function applyUserPromptUltragoalSteering(cwd: string, prompt: string): Promise<string | null> {
670
+ const proposal = parseUserPromptUltragoalSteeringDirective(prompt);
671
+ if (!proposal) return null;
672
+ try {
673
+ const result = await steerUltragoal(cwd, proposal);
674
+ const status = result.deduped ? "deduped" : result.accepted ? "accepted" : "rejected";
675
+ const reasons = result.rejectedReasons.length > 0 ? ` rejectedReasons=${result.rejectedReasons.join("; ")}` : "";
676
+ return [
677
+ `OMX native UserPromptSubmit applied bounded .omx/ultragoal steering for G002-cli-and-prompt-submit-bridge: ${status}.`,
678
+ `mutation=${result.audit.kind}; source=${result.audit.source}; targets=${result.audit.targetGoalIds.join(",") || "none"}; idempotencyKey=${result.audit.idempotencyKey ?? "none"}.${reasons}`,
679
+ "Only explicit structured steering directives are parsed; normal prose is ignored and cannot mutate .omx/ultragoal.",
680
+ ].join(" ");
681
+ } catch (error) {
682
+ const message = error instanceof Error ? error.message : String(error);
683
+ return `OMX native UserPromptSubmit rejected bounded .omx/ultragoal steering for G002-cli-and-prompt-submit-bridge: ${message}`;
684
+ }
685
+ }
686
+
687
+ function sanitizePayloadForHookContext(
688
+ payload: CodexHookPayload,
689
+ hookEventName: CodexHookEventName,
690
+ canonicalSessionId = "",
691
+ ): CodexHookPayload {
692
+ const sanitized = { ...payload };
693
+
694
+ if (hookEventName === "UserPromptSubmit") {
695
+ delete sanitized.prompt;
696
+ delete sanitized.input;
697
+ delete sanitized.user_prompt;
698
+ delete sanitized.userPrompt;
699
+ delete sanitized.text;
700
+ return sanitized;
701
+ }
702
+
703
+ if (hookEventName === "Stop") {
704
+ delete sanitized.stop_hook_active;
705
+ delete sanitized.stopHookActive;
706
+ delete sanitized.sessionId;
707
+ sanitized.session_id = canonicalSessionId.trim() || safeString(payload.session_id ?? payload.sessionId).trim();
708
+ }
709
+
710
+ return sanitized;
711
+ }
712
+
713
+ function buildBaseContext(
714
+ cwd: string,
715
+ payload: CodexHookPayload,
716
+ hookEventName: CodexHookEventName,
717
+ canonicalSessionId = "",
718
+ ): Record<string, unknown> {
719
+ return {
720
+ cwd,
721
+ project_path: cwd,
722
+ transcript_path: safeString(payload.transcript_path ?? payload.transcriptPath) || null,
723
+ source: safeString(payload.source),
724
+ payload: sanitizePayloadForHookContext(payload, hookEventName, canonicalSessionId),
725
+ };
726
+ }
727
+
728
+ async function readJsonIfExists(path: string): Promise<Record<string, unknown> | null> {
729
+ if (!existsSync(path)) return null;
730
+ try {
731
+ return JSON.parse(await readFile(path, "utf-8")) as Record<string, unknown>;
732
+ } catch {
733
+ return null;
734
+ }
735
+ }
736
+
737
+ function isNonTerminalPhase(value: unknown): boolean {
738
+ const phase = safeString(value).trim().toLowerCase();
739
+ return phase !== "" && !TERMINAL_MODE_PHASES.has(phase);
740
+ }
741
+
742
+ function formatPhase(value: unknown, fallback = "active"): string {
743
+ const phase = safeString(value).trim();
744
+ return phase || fallback;
745
+ }
746
+
747
+ async function readActiveAutoresearchState(
748
+ cwd: string,
749
+ sessionId?: string,
750
+ ): Promise<Record<string, unknown> | null> {
751
+ const normalizedSessionId = sessionId?.trim() || undefined;
752
+ if (!normalizedSessionId) return null;
753
+ const state = await readAutoresearchModeStateForActiveDecision(cwd, normalizedSessionId);
754
+ if (state?.active !== true) return null;
755
+ if (!isNonTerminalPhase(state.current_phase ?? state.currentPhase ?? 'executing')) return null;
756
+ return state;
757
+ }
758
+
759
+ interface ActiveRalphStopState {
760
+ state: Record<string, unknown>;
761
+ path: string;
762
+ }
763
+
764
+ interface RalphCompletionAuditBlockState {
765
+ state: Record<string, unknown>;
766
+ path: string;
767
+ reason: string;
768
+ }
769
+
770
+ interface RalphStopOwnershipContext {
771
+ sessionId: string;
772
+ payloadSessionId: string;
773
+ threadId: string;
774
+ currentNativeSessionId: string;
775
+ tmuxPaneId: string;
776
+ }
777
+
778
+ function isRalphStartingPhase(state: Record<string, unknown>): boolean {
779
+ return safeString(state.current_phase ?? state.currentPhase).trim().toLowerCase() === "starting";
780
+ }
781
+
782
+
783
+ function parseTimestampMs(value: unknown): number | null {
784
+ const text = safeString(value).trim();
785
+ if (!text) return null;
786
+ const ms = Date.parse(text);
787
+ return Number.isFinite(ms) ? ms : null;
788
+ }
789
+
790
+ function numericValue(value: unknown): number | null {
791
+ if (typeof value === "number" && Number.isFinite(value)) return value;
792
+ if (typeof value === "string" && value.trim()) {
793
+ const parsed = Number(value);
794
+ return Number.isFinite(parsed) ? parsed : null;
795
+ }
796
+ return null;
797
+ }
798
+
799
+ function hasRalphOwnerHint(state: Record<string, unknown>): boolean {
800
+ return [
801
+ state.owner_omx_session_id,
802
+ state.owner_codex_session_id,
803
+ state.owner_codex_thread_id,
804
+ state.thread_id,
805
+ state.tmux_pane_id,
806
+ state.task_slug,
807
+ ].some((value) => safeString(value).trim() !== "");
808
+ }
809
+
810
+ async function isStaleOrphanedRalphStartingState(
811
+ state: Record<string, unknown>,
812
+ path: string,
813
+ nowMs = Date.now(),
814
+ ): Promise<boolean> {
815
+ if (!isRalphStartingPhase(state)) return false;
816
+ if (numericValue(state.iteration) !== 0) return false;
817
+ if (hasRalphOwnerHint(state)) return false;
818
+
819
+ const timestampMs = parseTimestampMs(state.updated_at)
820
+ ?? parseTimestampMs(state.started_at)
821
+ ?? parseTimestampMs(state.created_at)
822
+ ?? await stat(path).then((info) => info.mtimeMs, () => null);
823
+ if (timestampMs === null) return false;
824
+
825
+ return nowMs - timestampMs > RALPH_ORPHANED_STARTING_STALE_MS;
826
+ }
827
+
828
+ function hasValue(values: string[], value: string): boolean {
829
+ return value !== "" && values.some((candidate) => candidate === value);
830
+ }
831
+
832
+ function activeRalphStateMatchesStopOwner(
833
+ state: Record<string, unknown>,
834
+ context: RalphStopOwnershipContext,
835
+ ): boolean {
836
+ const ownerOmxSessionId = safeString(state.owner_omx_session_id).trim();
837
+ if (ownerOmxSessionId && ownerOmxSessionId !== context.sessionId) {
838
+ return false;
839
+ }
840
+
841
+ const stateSessionId = safeString(state.session_id).trim();
842
+ if (!ownerOmxSessionId && stateSessionId && stateSessionId !== context.sessionId) {
843
+ return false;
844
+ }
845
+
846
+ const codexOwnerSessionId = safeString(state.owner_codex_session_id).trim();
847
+ if (codexOwnerSessionId) {
848
+ const stopCodexSessionIds = [
849
+ context.payloadSessionId,
850
+ context.currentNativeSessionId,
851
+ context.sessionId,
852
+ ].filter(Boolean);
853
+ if (!hasValue(stopCodexSessionIds, codexOwnerSessionId)) return false;
854
+ }
855
+
856
+ const stateThreadId = safeString(state.owner_codex_thread_id ?? state.thread_id).trim();
857
+ if (stateThreadId && context.threadId && stateThreadId !== context.threadId) {
858
+ return false;
859
+ }
860
+
861
+ const statePaneId = safeString(state.tmux_pane_id).trim();
862
+ if (statePaneId && context.tmuxPaneId && statePaneId !== context.tmuxPaneId) {
863
+ return false;
864
+ }
865
+
866
+ return true;
867
+ }
868
+
869
+ function shouldHonorCanonicalTerminalRunState(
870
+ runState: Record<string, unknown> | null,
871
+ mode: string,
872
+ ): boolean {
873
+ if (!runState) return false;
874
+ const runMode = safeString(runState.mode).trim();
875
+ if (runMode && runMode !== mode) return false;
876
+ return getRunContinuationSnapshot(runState)?.terminal === true;
877
+ }
878
+
879
+ async function readCanonicalTerminalRunStateForStop(
880
+ cwd: string,
881
+ sessionId: string | undefined,
882
+ mode: string,
883
+ ): Promise<Record<string, unknown> | null> {
884
+ if (!safeString(sessionId).trim()) return null;
885
+ const runState = await readRunState(cwd, sessionId).catch(() => null);
886
+ const runRecord = runState as unknown as Record<string, unknown> | null;
887
+ return shouldHonorCanonicalTerminalRunState(runRecord, mode) ? runRecord : null;
888
+ }
889
+
890
+ async function isVisibleRalphActiveForSession(stateDir: string, sessionId: string): Promise<boolean> {
891
+ const canonicalState = await readVisibleSkillActiveStateForStateDir(stateDir, sessionId);
892
+ if (!canonicalState) return false;
893
+ return listActiveSkills(canonicalState).some((entry) => (
894
+ entry.skill === "ralph"
895
+ && matchesSkillStopContext(entry, canonicalState, sessionId, "")
896
+ ));
897
+ }
898
+
899
+ async function hasConsistentRalphSkillActivation(stateDir: string, sessionId: string): Promise<boolean> {
900
+ const canonicalState = await readVisibleSkillActiveStateForStateDir(stateDir, sessionId);
901
+ if (!canonicalState) return true;
902
+
903
+ const initializedMode = safeString(canonicalState.initialized_mode).trim();
904
+ if (initializedMode && initializedMode !== "ralph") return true;
905
+
906
+ const initializedPathSessionId = extractSessionIdFromInitializedStatePath(canonicalState.initialized_state_path);
907
+ if (initializedPathSessionId && initializedPathSessionId !== sessionId) return false;
908
+
909
+ return true;
910
+ }
911
+
912
+ function isShadowableRalphStartingSeed(state: Record<string, unknown>): boolean {
913
+ if (state.active !== true) return false;
914
+ if (!isRalphStartingPhase(state)) return false;
915
+ if (state.completion_audit || state.completionAudit) return false;
916
+ const iteration = numericValue(state.iteration);
917
+ return iteration === null || iteration <= 0;
918
+ }
919
+
920
+ function hasPassingCompletedRalphAudit(state: Record<string, unknown> | null, cwd: string): boolean {
921
+ if (!state) return false;
922
+ if (state.mode && safeString(state.mode) !== "ralph") return false;
923
+ if (!isRalphCompletePhase(state.current_phase ?? state.currentPhase)) return false;
924
+ if (state.active === true) return false;
925
+ return evaluateRalphCompletionAuditEvidence(state, cwd).complete === true;
926
+ }
927
+
928
+ function shouldRetireShadowedRalphStartingSeed(
929
+ seedState: Record<string, unknown>,
930
+ completedState: Record<string, unknown> | null,
931
+ cwd: string,
932
+ ownerContext?: {
933
+ completedSessionId?: string;
934
+ payloadSessionId?: string;
935
+ threadId?: string;
936
+ currentNativeSessionId?: string;
937
+ tmuxPaneId?: string;
938
+ },
939
+ ): boolean {
940
+ if (!isShadowableRalphStartingSeed(seedState)) return false;
941
+ if (!hasPassingCompletedRalphAudit(completedState, cwd)) return false;
942
+ if (!completedState) return false;
943
+
944
+ const completedSessionId = safeString(ownerContext?.completedSessionId ?? completedState.session_id).trim();
945
+ if (
946
+ completedSessionId
947
+ && !activeRalphStateMatchesStopOwner(completedState, {
948
+ sessionId: completedSessionId,
949
+ payloadSessionId: safeString(ownerContext?.payloadSessionId).trim(),
950
+ threadId: safeString(ownerContext?.threadId).trim(),
951
+ currentNativeSessionId: safeString(ownerContext?.currentNativeSessionId).trim(),
952
+ tmuxPaneId: safeString(ownerContext?.tmuxPaneId).trim(),
953
+ })
954
+ ) {
955
+ return false;
956
+ }
957
+
958
+ const seedThreadId = safeString(seedState.owner_codex_thread_id ?? seedState.thread_id).trim();
959
+ const completedThreadId = safeString(completedState?.owner_codex_thread_id ?? completedState?.thread_id).trim();
960
+ const stopThreadId = safeString(ownerContext?.threadId).trim();
961
+ if (seedThreadId && completedThreadId && seedThreadId !== completedThreadId) return false;
962
+ if (seedThreadId && stopThreadId && seedThreadId !== stopThreadId) return false;
963
+ if (completedThreadId && stopThreadId && completedThreadId !== stopThreadId) return false;
964
+
965
+ const seedPaneId = safeString(seedState.tmux_pane_id).trim();
966
+ const completedPaneId = safeString(completedState?.tmux_pane_id).trim();
967
+ const stopPaneId = safeString(ownerContext?.tmuxPaneId).trim();
968
+ if (seedPaneId && completedPaneId && seedPaneId !== completedPaneId) return false;
969
+ if (seedPaneId && stopPaneId && seedPaneId !== stopPaneId) return false;
970
+ if (completedPaneId && stopPaneId && completedPaneId !== stopPaneId) return false;
971
+
972
+ const seedStartedAt = parseTimestampMs(seedState.started_at ?? seedState.startedAt);
973
+ const completedAt = parseTimestampMs(completedState?.completed_at ?? completedState?.completedAt);
974
+ if (completedAt === null) return false;
975
+ if (seedStartedAt !== null && seedStartedAt > completedAt) return false;
976
+
977
+ return true;
978
+ }
979
+
980
+ async function retireShadowedRalphStartingSeed(
981
+ path: string,
982
+ seedState: Record<string, unknown>,
983
+ completedSessionId: string,
984
+ completedPath: string,
985
+ completedState: Record<string, unknown>,
986
+ ): Promise<void> {
987
+ const nowIso = new Date().toISOString();
988
+ const completedAt = safeString(completedState.completed_at ?? completedState.completedAt).trim() || nowIso;
989
+ const next: Record<string, unknown> = {
990
+ ...seedState,
991
+ active: false,
992
+ current_phase: "complete",
993
+ completed_at: completedAt,
994
+ stop_reason: "shadowed_by_completed_canonical_ralph",
995
+ shadowed_by_completed_canonical_ralph: {
996
+ session_id: completedSessionId,
997
+ state_path: completedPath,
998
+ completed_at: completedAt,
999
+ reconciled_at: nowIso,
1000
+ },
1001
+ };
1002
+ await writeFile(path, JSON.stringify(next, null, 2));
1003
+ }
1004
+
1005
+
1006
+ async function readRalphCompletionAuditBlockState(
1007
+ cwd: string,
1008
+ stateDir: string,
1009
+ preferredSessionId?: string,
1010
+ ownerContext?: {
1011
+ payloadSessionId?: string;
1012
+ threadId?: string;
1013
+ tmuxPaneId?: string;
1014
+ },
1015
+ ): Promise<RalphCompletionAuditBlockState | null> {
1016
+ const [rawSessionInfo, usableSessionInfo] = await Promise.all([
1017
+ readSessionState(cwd),
1018
+ readUsableSessionState(cwd),
1019
+ ]);
1020
+ const currentOmxSessionId = safeString(usableSessionInfo?.session_id).trim();
1021
+ const currentNativeSessionId = safeString(usableSessionInfo?.native_session_id).trim();
1022
+ const staleCurrentSessionId = rawSessionInfo && !isSessionStateUsable(rawSessionInfo, cwd)
1023
+ ? safeString(rawSessionInfo.session_id).trim()
1024
+ : "";
1025
+ const sessionCandidates = [...new Set([
1026
+ safeString(preferredSessionId).trim(),
1027
+ currentOmxSessionId,
1028
+ ].filter(Boolean))];
1029
+
1030
+ const evaluateCandidate = (state: Record<string, unknown> | null, path: string, sessionId: string): RalphCompletionAuditBlockState | null => {
1031
+ if (!state || state.mode && safeString(state.mode) !== "ralph") return null;
1032
+ if (!isRalphCompletePhase(state.current_phase ?? state.currentPhase)) return null;
1033
+ if (activeRalphStateMatchesStopOwner(state, {
1034
+ sessionId,
1035
+ payloadSessionId: safeString(ownerContext?.payloadSessionId).trim(),
1036
+ threadId: safeString(ownerContext?.threadId).trim(),
1037
+ currentNativeSessionId,
1038
+ tmuxPaneId: safeString(ownerContext?.tmuxPaneId).trim(),
1039
+ }) !== true) return null;
1040
+ const audit = evaluateRalphCompletionAuditEvidence(state, cwd);
1041
+ return audit.complete ? null : { state, path, reason: audit.reason };
1042
+ };
1043
+
1044
+ for (const sessionId of sessionCandidates) {
1045
+ if (staleCurrentSessionId && sessionId === staleCurrentSessionId) continue;
1046
+ const sessionScopedPath = getStateFilePath("ralph-state.json", cwd, sessionId);
1047
+ const result = evaluateCandidate(await readJsonIfExists(sessionScopedPath), sessionScopedPath, sessionId);
1048
+ if (result) return result;
1049
+ }
1050
+
1051
+ if (sessionCandidates.length > 0) return null;
1052
+
1053
+ const directPath = join(stateDir, "ralph-state.json");
1054
+ return evaluateCandidate(await readJsonIfExists(directPath), directPath, "");
1055
+ }
1056
+
1057
+ async function reopenRalphCompletionAuditBlock(block: RalphCompletionAuditBlockState): Promise<void> {
1058
+ const nowIso = new Date().toISOString();
1059
+ const next: Record<string, unknown> = {
1060
+ ...block.state,
1061
+ active: false,
1062
+ current_phase: "complete",
1063
+ completion_audit_gate: "blocked",
1064
+ completion_audit_missing_reason: block.reason,
1065
+ completion_audit_blocked_at: nowIso,
1066
+ };
1067
+ await writeFile(block.path, JSON.stringify(next, null, 2));
1068
+ }
1069
+
1070
+ async function readActiveRalphState(
1071
+ cwd: string,
1072
+ stateDir: string,
1073
+ preferredSessionId?: string,
1074
+ ownerContext?: {
1075
+ payloadSessionId?: string;
1076
+ threadId?: string;
1077
+ tmuxPaneId?: string;
1078
+ },
1079
+ ): Promise<ActiveRalphStopState | null> {
1080
+ const [rawSessionInfo, usableSessionInfo] = await Promise.all([
1081
+ readSessionState(cwd),
1082
+ readUsableSessionState(cwd),
1083
+ ]);
1084
+ const currentOmxSessionId = safeString(usableSessionInfo?.session_id).trim();
1085
+ const currentNativeSessionId = safeString(usableSessionInfo?.native_session_id).trim();
1086
+ const staleCurrentSessionId = rawSessionInfo && !isSessionStateUsable(rawSessionInfo, cwd)
1087
+ ? safeString(rawSessionInfo.session_id).trim()
1088
+ : "";
1089
+ const sessionCandidates = [...new Set([
1090
+ safeString(preferredSessionId).trim(),
1091
+ currentOmxSessionId,
1092
+ ].filter(Boolean))];
1093
+ const completedCanonicalPath = currentOmxSessionId
1094
+ ? getStateFilePath("ralph-state.json", cwd, currentOmxSessionId)
1095
+ : "";
1096
+ const completedCanonicalState = completedCanonicalPath
1097
+ ? await readJsonIfExists(completedCanonicalPath)
1098
+ : null;
1099
+
1100
+ // Ralph Stop stays authoritative-scope-only once the Stop payload is session-bound.
1101
+ // That is intentionally stricter than generic state MCP reads: do not scan sibling
1102
+ // session scopes or fall back to root when a current/explicit session is in play.
1103
+ for (const sessionId of sessionCandidates) {
1104
+ if (staleCurrentSessionId && sessionId === staleCurrentSessionId) {
1105
+ continue;
1106
+ }
1107
+ if (await readCanonicalTerminalRunStateForStop(cwd, sessionId, "ralph")) {
1108
+ continue;
1109
+ }
1110
+ const sessionScopedPath = getStateFilePath("ralph-state.json", cwd, sessionId);
1111
+ const sessionScoped = await readJsonIfExists(sessionScopedPath);
1112
+ if (sessionScoped?.active === true) {
1113
+ if (
1114
+ currentOmxSessionId
1115
+ && sessionId !== currentOmxSessionId
1116
+ && completedCanonicalState
1117
+ && shouldRetireShadowedRalphStartingSeed(sessionScoped, completedCanonicalState, cwd, {
1118
+ completedSessionId: currentOmxSessionId,
1119
+ payloadSessionId: safeString(ownerContext?.payloadSessionId).trim(),
1120
+ threadId: safeString(ownerContext?.threadId).trim(),
1121
+ currentNativeSessionId,
1122
+ tmuxPaneId: safeString(ownerContext?.tmuxPaneId).trim(),
1123
+ })
1124
+ ) {
1125
+ await retireShadowedRalphStartingSeed(
1126
+ sessionScopedPath,
1127
+ sessionScoped,
1128
+ currentOmxSessionId,
1129
+ completedCanonicalPath,
1130
+ completedCanonicalState,
1131
+ );
1132
+ continue;
1133
+ }
1134
+ if (await isStaleOrphanedRalphStartingState(sessionScoped, sessionScopedPath)) {
1135
+ continue;
1136
+ }
1137
+ if (
1138
+ isRalphStartingPhase(sessionScoped)
1139
+ && !(await isVisibleRalphActiveForSession(stateDir, sessionId))
1140
+ ) {
1141
+ continue;
1142
+ }
1143
+ }
1144
+ if (
1145
+ sessionScoped?.active === true
1146
+ && shouldContinueRun(sessionScoped)
1147
+ && activeRalphStateMatchesStopOwner(sessionScoped, {
1148
+ sessionId,
1149
+ payloadSessionId: safeString(ownerContext?.payloadSessionId).trim(),
1150
+ threadId: safeString(ownerContext?.threadId).trim(),
1151
+ currentNativeSessionId,
1152
+ tmuxPaneId: safeString(ownerContext?.tmuxPaneId).trim(),
1153
+ })
1154
+ && await hasConsistentRalphSkillActivation(stateDir, sessionId)
1155
+ ) {
1156
+ return { state: sessionScoped, path: sessionScopedPath };
1157
+ }
1158
+ }
1159
+
1160
+ if (sessionCandidates.length > 0) return null;
1161
+
1162
+ const directPath = join(stateDir, "ralph-state.json");
1163
+ const direct = await readJsonIfExists(directPath);
1164
+ if (direct?.active === true && shouldContinueRun(direct)) {
1165
+ return { state: direct, path: directPath };
1166
+ }
1167
+
1168
+ return null;
1169
+ }
1170
+
1171
+ function readParentPid(pid: number): number | null {
1172
+ try {
1173
+ if (process.platform === "linux") {
1174
+ const stat = readFileSync(`/proc/${pid}/stat`, "utf-8");
1175
+ const commandEnd = stat.lastIndexOf(")");
1176
+ if (commandEnd === -1) return null;
1177
+ const remainder = stat.slice(commandEnd + 1).trim();
1178
+ const fields = remainder.split(/\s+/);
1179
+ const ppid = Number(fields[1]);
1180
+ return Number.isFinite(ppid) && ppid > 0 ? ppid : null;
1181
+ }
1182
+
1183
+ const raw = execFileSync("ps", ["-o", "ppid=", "-p", String(pid)], {
1184
+ encoding: "utf-8",
1185
+ stdio: ["ignore", "pipe", "ignore"],
1186
+ windowsHide: true,
1187
+ }).trim();
1188
+ const ppid = Number.parseInt(raw, 10);
1189
+ return Number.isFinite(ppid) && ppid > 0 ? ppid : null;
1190
+ } catch {
1191
+ return null;
1192
+ }
1193
+ }
1194
+
1195
+ function readProcessCommand(pid: number): string {
1196
+ try {
1197
+ if (process.platform === "linux") {
1198
+ return readFileSync(`/proc/${pid}/cmdline`, "utf-8")
1199
+ .replace(/\u0000+/g, " ")
1200
+ .trim();
1201
+ }
1202
+
1203
+ return execFileSync("ps", ["-o", "command=", "-p", String(pid)], {
1204
+ encoding: "utf-8",
1205
+ stdio: ["ignore", "pipe", "ignore"],
1206
+ windowsHide: true,
1207
+ }).trim();
1208
+ } catch {
1209
+ return "";
1210
+ }
1211
+ }
1212
+
1213
+ function looksLikeShellCommand(command: string): boolean {
1214
+ return /(^|[\/\s])(bash|zsh|sh|dash|fish|ksh)(\s|$)/i.test(command);
1215
+ }
1216
+
1217
+ function looksLikeCodexCommand(command: string): boolean {
1218
+ if (/codex-native-hook(?:\.js)?/i.test(command)) return false;
1219
+ return /\bcodex(?:\.js)?\b/i.test(command);
1220
+ }
1221
+
1222
+ export function resolveSessionOwnerPidFromAncestry(
1223
+ startPid: number,
1224
+ options: {
1225
+ readParentPid?: (pid: number) => number | null;
1226
+ readProcessCommand?: (pid: number) => string;
1227
+ } = {},
1228
+ ): number | null {
1229
+ const readParent = options.readParentPid ?? readParentPid;
1230
+ const readCommand = options.readProcessCommand ?? readProcessCommand;
1231
+ const lineage: Array<{ pid: number; command: string }> = [];
1232
+ let currentPid = startPid;
1233
+
1234
+ for (let i = 0; i < 6 && Number.isInteger(currentPid) && currentPid > 1; i += 1) {
1235
+ const command = readCommand(currentPid);
1236
+ lineage.push({ pid: currentPid, command });
1237
+ const nextPid = readParent(currentPid);
1238
+ if (!nextPid || nextPid === currentPid) break;
1239
+ currentPid = nextPid;
1240
+ }
1241
+
1242
+ const codexAncestor = lineage.find((entry) => looksLikeCodexCommand(entry.command));
1243
+ if (codexAncestor) return codexAncestor.pid;
1244
+
1245
+ if (lineage.length >= 2 && looksLikeShellCommand(lineage[0]?.command || "")) {
1246
+ return lineage[1].pid;
1247
+ }
1248
+
1249
+ if (lineage.length >= 1) return lineage[0].pid;
1250
+ return null;
1251
+ }
1252
+
1253
+ function resolveSessionOwnerPid(payload: CodexHookPayload): number {
1254
+ const explicitPid = [
1255
+ payload.session_pid,
1256
+ payload.sessionPid,
1257
+ payload.codex_pid,
1258
+ payload.codexPid,
1259
+ payload.parent_pid,
1260
+ payload.parentPid,
1261
+ ]
1262
+ .map(safePositiveInteger)
1263
+ .find((value): value is number => value !== null);
1264
+ if (explicitPid) return explicitPid;
1265
+
1266
+ const resolved = resolveSessionOwnerPidFromAncestry(process.ppid);
1267
+ if (resolved) return resolved;
1268
+ return process.pid;
1269
+ }
1270
+
1271
+ function tryReadGitValue(cwd: string, args: string[]): string | null {
1272
+ try {
1273
+ const value = execFileSync("git", args, {
1274
+ cwd,
1275
+ encoding: "utf-8",
1276
+ stdio: ["ignore", "pipe", "ignore"],
1277
+ windowsHide: true,
1278
+ }).trim();
1279
+ return value || null;
1280
+ } catch {
1281
+ return null;
1282
+ }
1283
+ }
1284
+
1285
+ interface SloppyFallbackDiffFinding {
1286
+ path: string;
1287
+ line: string;
1288
+ source: "staged" | "unstaged" | "untracked";
1289
+ }
1290
+
1291
+ const SOURCE_DIFF_EXTENSIONS = new Set([
1292
+ ".c",
1293
+ ".cc",
1294
+ ".cjs",
1295
+ ".cpp",
1296
+ ".cs",
1297
+ ".cts",
1298
+ ".go",
1299
+ ".h",
1300
+ ".hpp",
1301
+ ".java",
1302
+ ".js",
1303
+ ".jsx",
1304
+ ".kt",
1305
+ ".mjs",
1306
+ ".mts",
1307
+ ".php",
1308
+ ".py",
1309
+ ".rb",
1310
+ ".rs",
1311
+ ".sh",
1312
+ ".swift",
1313
+ ".ts",
1314
+ ".tsx",
1315
+ ]);
1316
+
1317
+ function gitOutput(cwd: string, args: string[]): string {
1318
+ try {
1319
+ return execFileSync("git", args, {
1320
+ cwd,
1321
+ encoding: "utf-8",
1322
+ stdio: ["ignore", "pipe", "ignore"],
1323
+ windowsHide: true,
1324
+ maxBuffer: 10 * 1024 * 1024,
1325
+ });
1326
+ } catch {
1327
+ return "";
1328
+ }
1329
+ }
1330
+
1331
+ function normalizeGitPath(path: string): string {
1332
+ return path.replace(/\\/g, "/").replace(/^\.\//, "");
1333
+ }
1334
+
1335
+ function isDiffAuditableSourcePath(path: string): boolean {
1336
+ const normalized = normalizeGitPath(path).toLowerCase();
1337
+ if (!normalized || normalized.startsWith(".git/") || normalized.startsWith(".omx/")) return false;
1338
+ if (/(^|\/)(?:docs?|documentation|changelog|changeset|\.github)(?:\/|$)/i.test(normalized)) return false;
1339
+ if (/(^|\/)(?:__tests__|__test__|test|tests|spec|specs|fixtures?|mocks?)(?:\/|$)/i.test(normalized)) return false;
1340
+ if (/(?:^|\/)[^\/]+\.(?:test|spec)\.[^.\/]+$/i.test(normalized)) return false;
1341
+ if (/(?:^|\/)(?:readme|changelog|changes|license|notice)(?:\.[^\/]*)?$/i.test(normalized)) return false;
1342
+ if (/\.(?:md|mdx|markdown|txt|rst|adoc|ya?ml|json|lock)$/i.test(normalized)) return false;
1343
+ return SOURCE_DIFF_EXTENSIONS.has(extname(normalized));
1344
+ }
1345
+
1346
+ function isDiffHeaderLine(line: string): boolean {
1347
+ return line.startsWith("+++") || line.startsWith("---") || line.startsWith("@@") || line.startsWith("diff --git ");
1348
+ }
1349
+
1350
+ function isSuspiciousSloppyFallbackAddedLine(line: string, nearbyContext: string): boolean {
1351
+ const trimmed = line.trim();
1352
+ if (!trimmed) return false;
1353
+ if (!hasAnyPattern(trimmed, SLOPPY_FALLBACK_PHRASE_PATTERNS)) return false;
1354
+ if (!hasAnyPattern(trimmed, SLOPPY_FALLBACK_IMPLEMENTATION_CONTEXT_PATTERNS)) return false;
1355
+ if (hasAnyPattern(nearbyContext, SLOPPY_FALLBACK_GROUNDING_PATTERNS)) return false;
1356
+ if (/compatib(?:le|ility)|fail-?safe|tested|regression|coverage|because|issue|PR\s*#?\d|#\d/i.test(nearbyContext)) return false;
1357
+ return true;
1358
+ }
1359
+
1360
+ interface SloppyFallbackCandidateLine {
1361
+ text: string;
1362
+ added: boolean;
1363
+ }
1364
+
1365
+ function collectFindingsFromCandidateLines(
1366
+ path: string,
1367
+ lines: SloppyFallbackCandidateLine[],
1368
+ source: SloppyFallbackDiffFinding["source"],
1369
+ ): SloppyFallbackDiffFinding[] {
1370
+ if (!path || !isDiffAuditableSourcePath(path)) return [];
1371
+ const findings: SloppyFallbackDiffFinding[] = [];
1372
+ for (let index = 0; index < lines.length; index += 1) {
1373
+ const candidate = lines[index];
1374
+ if (!candidate?.added) continue;
1375
+ const nearbyContext = lines
1376
+ .slice(Math.max(0, index - 2), Math.min(lines.length, index + 3))
1377
+ .map((line) => line.text)
1378
+ .join("\n");
1379
+ if (isSuspiciousSloppyFallbackAddedLine(candidate.text, nearbyContext)) {
1380
+ findings.push({ path, line: candidate.text.trim(), source });
1381
+ }
1382
+ }
1383
+ return findings;
1384
+ }
1385
+
1386
+ function collectSloppyFallbackFindingsFromPatch(
1387
+ patch: string,
1388
+ source: SloppyFallbackDiffFinding["source"],
1389
+ ): SloppyFallbackDiffFinding[] {
1390
+ const findings: SloppyFallbackDiffFinding[] = [];
1391
+ let currentPath = "";
1392
+ let hunkLines: SloppyFallbackCandidateLine[] = [];
1393
+
1394
+ const flushHunk = () => {
1395
+ findings.push(...collectFindingsFromCandidateLines(currentPath, hunkLines, source));
1396
+ hunkLines = [];
1397
+ };
1398
+
1399
+ for (const rawLine of patch.split(/\r?\n/)) {
1400
+ const fileMatch = rawLine.match(/^diff --git a\/(.*?) b\/(.*)$/);
1401
+ if (fileMatch) {
1402
+ flushHunk();
1403
+ currentPath = normalizeGitPath(fileMatch[2] || fileMatch[1] || "");
1404
+ continue;
1405
+ }
1406
+ const renameMatch = rawLine.match(/^\+\+\+ b\/(.*)$/);
1407
+ if (renameMatch) {
1408
+ currentPath = normalizeGitPath(renameMatch[1] || currentPath);
1409
+ continue;
1410
+ }
1411
+ if (rawLine.startsWith("@@")) {
1412
+ flushHunk();
1413
+ continue;
1414
+ }
1415
+ if (!currentPath || !isDiffAuditableSourcePath(currentPath) || isDiffHeaderLine(rawLine)) continue;
1416
+ if (rawLine.startsWith("+")) {
1417
+ hunkLines.push({ text: rawLine.slice(1), added: true });
1418
+ } else if (rawLine.startsWith(" ")) {
1419
+ hunkLines.push({ text: rawLine.slice(1), added: false });
1420
+ }
1421
+ }
1422
+ flushHunk();
1423
+ return findings;
1424
+ }
1425
+
1426
+ function collectSloppyFallbackFindingsFromUntracked(cwd: string): SloppyFallbackDiffFinding[] {
1427
+ const output = gitOutput(cwd, ["ls-files", "--others", "--exclude-standard", "-z"]);
1428
+ if (!output) return [];
1429
+ const findings: SloppyFallbackDiffFinding[] = [];
1430
+ for (const rawPath of output.split("\0")) {
1431
+ const path = normalizeGitPath(rawPath.trim());
1432
+ if (!path || !isDiffAuditableSourcePath(path)) continue;
1433
+ let content = "";
1434
+ try {
1435
+ content = readFileSync(join(cwd, path), "utf-8");
1436
+ } catch {
1437
+ continue;
1438
+ }
1439
+ findings.push(...collectFindingsFromCandidateLines(path, content.split(/\r?\n/).map((text) => ({ text, added: true })), "untracked"));
1440
+ }
1441
+ return findings;
1442
+ }
1443
+
1444
+ function findSloppyFallbackDiffFindings(cwd: string): SloppyFallbackDiffFinding[] {
1445
+ const layout = findGitLayout(cwd);
1446
+ if (!layout) return [];
1447
+ const auditRoot = layout.worktreeRoot;
1448
+ return [
1449
+ ...collectSloppyFallbackFindingsFromPatch(gitOutput(auditRoot, ["diff", "--cached", "--no-ext-diff", "--unified=3"]), "staged"),
1450
+ ...collectSloppyFallbackFindingsFromPatch(gitOutput(auditRoot, ["diff", "--no-ext-diff", "--unified=3"]), "unstaged"),
1451
+ ...collectSloppyFallbackFindingsFromUntracked(auditRoot),
1452
+ ];
1453
+ }
1454
+
1455
+ function buildSloppyFallbackDiffStopOutput(findings: SloppyFallbackDiffFinding[]): Record<string, unknown> | null {
1456
+ if (findings.length === 0) return null;
1457
+ const preview = findings
1458
+ .slice(0, 3)
1459
+ .map((finding) => `${finding.path} (${finding.source}): ${finding.line}`)
1460
+ .join("; ");
1461
+ const systemMessage =
1462
+ `Sloppy fallback/workaround diff audit detected ungrounded fallback code in added source lines: ${preview}. `
1463
+ + "Continue by replacing the bypass/workaround with a grounded design, or add explicit compatibility/fail-safe/tested/issue rationale near the code if the fallback is intentional.";
1464
+ return {
1465
+ decision: "block",
1466
+ reason: systemMessage,
1467
+ stopReason: "sloppy_fallback_diff_audit",
1468
+ systemMessage,
1469
+ };
1470
+ }
1471
+
1472
+ function localExcludeAlreadyIgnoresOmx(cwd: string): boolean {
1473
+ const layout = findGitLayout(cwd);
1474
+ if (!layout) return false;
1475
+ const excludePath = join(layout.gitDir, "info", "exclude");
1476
+ try {
1477
+ const lines = readFileSync(excludePath, "utf-8")
1478
+ .split(/\r?\n/)
1479
+ .map((line) => line.trim())
1480
+ .filter((line) => line && !line.startsWith("#"));
1481
+ return lines.includes(".omx/") || lines.includes(".omx");
1482
+ } catch {
1483
+ return false;
1484
+ }
1485
+ }
1486
+
1487
+ function isPathIgnoredByGit(cwd: string, path: string): boolean {
1488
+ try {
1489
+ execFileSync("git", ["check-ignore", "-q", path], {
1490
+ cwd,
1491
+ stdio: ["ignore", "ignore", "ignore"],
1492
+ windowsHide: true,
1493
+ });
1494
+ return true;
1495
+ } catch {
1496
+ return false;
1497
+ }
1498
+ }
1499
+
1500
+ async function ensureOmxLocalIgnoreEntry(cwd: string): Promise<{ changed: boolean; excludePath?: string }> {
1501
+ const repoRoot = tryReadGitValue(cwd, ["rev-parse", "--show-toplevel"]);
1502
+ if (!repoRoot) return { changed: false };
1503
+ if (localExcludeAlreadyIgnoresOmx(repoRoot) || isPathIgnoredByGit(repoRoot, ".omx/")) {
1504
+ return { changed: false };
1505
+ }
1506
+
1507
+ const excludePathValue = tryReadGitValue(repoRoot, ["rev-parse", "--git-path", "info/exclude"]);
1508
+ if (!excludePathValue) return { changed: false };
1509
+ const excludePath = resolve(repoRoot, excludePathValue);
1510
+
1511
+ const existing = existsSync(excludePath)
1512
+ ? await readFile(excludePath, "utf-8")
1513
+ : "";
1514
+ const lines = existing.split(/\r?\n/).map((line) => line.trim());
1515
+ if (lines.includes(".omx/")) {
1516
+ return { changed: false, excludePath };
1517
+ }
1518
+
1519
+ const next = `${existing}${existing.endsWith("\n") || existing.length === 0 ? "" : "\n"}.omx/\n`;
1520
+ await writeFile(excludePath, next);
1521
+ return { changed: true, excludePath };
1522
+ }
1523
+
1524
+ async function buildSessionStartContext(
1525
+ cwd: string,
1526
+ sessionId: string,
1527
+ options: {
1528
+ hookEventName?: CodexHookEventName | null;
1529
+ payload?: CodexHookPayload;
1530
+ canonicalSessionId?: string;
1531
+ nativeSessionId?: string;
1532
+ } = {},
1533
+ ): Promise<string | null> {
1534
+ const sections: string[] = [];
1535
+
1536
+ sections.push(buildExecutionEnvironmentSection(cwd, {
1537
+ hookEventName: options.hookEventName,
1538
+ payload: options.payload,
1539
+ canonicalSessionId: options.canonicalSessionId,
1540
+ nativeSessionId: options.nativeSessionId,
1541
+ }));
1542
+
1543
+ const localIgnoreResult = await ensureOmxLocalIgnoreEntry(cwd);
1544
+ if (localIgnoreResult.changed) {
1545
+ sections.push(`Added .omx/ to ${localIgnoreResult.excludePath} to keep local OMX state out of source control without mutating tracked repo ignores.`);
1546
+ }
1547
+
1548
+ const modeSummaries: string[] = [];
1549
+ for (const mode of ["ralph", "autopilot", "ultrawork", "ultraqa", "ralplan", "deep-interview", "team"] as const) {
1550
+ const state = await readJsonIfExists(getStatePath(mode, cwd, sessionId));
1551
+ if (state?.active !== true || !isNonTerminalPhase(state.current_phase)) continue;
1552
+ if (mode === "team") {
1553
+ const teamName = safeString(state.team_name).trim();
1554
+ if (teamName) {
1555
+ const phase = await readTeamPhase(teamName, cwd);
1556
+ const canonicalPhase = phase?.current_phase ?? state.current_phase;
1557
+ if (isNonTerminalPhase(canonicalPhase)) {
1558
+ modeSummaries.push(`- team (${teamName}) phase: ${formatPhase(canonicalPhase)}`);
1559
+ }
1560
+ continue;
1561
+ }
1562
+ }
1563
+ modeSummaries.push(`- ${mode} phase: ${formatPhase(state.current_phase)}`);
1564
+ }
1565
+ if (modeSummaries.length > 0) {
1566
+ sections.push(["[Active OMX modes]", ...modeSummaries].join("\n"));
1567
+ }
1568
+
1569
+ const projectMemoryPath = resolveProjectMemoryPath(cwd);
1570
+ const projectMemory = projectMemoryPath ? await readJsonIfExists(projectMemoryPath) : null;
1571
+ if (projectMemory && projectMemoryPath) {
1572
+ const directives = Array.isArray(projectMemory.directives) ? projectMemory.directives : [];
1573
+ const notes = Array.isArray(projectMemory.notes) ? projectMemory.notes : [];
1574
+ const techStack = safeContextSnippet(projectMemory.techStack);
1575
+ const conventions = safeContextSnippet(projectMemory.conventions);
1576
+ const build = safeContextSnippet(projectMemory.build);
1577
+ const summary: string[] = [];
1578
+ const relativeMemoryPath = relative(cwd, projectMemoryPath).replace(/\\/g, "/");
1579
+ summary.push(`- source: ${relativeMemoryPath === "project-memory.json" ? "project-memory.json" : ".omx/project-memory.json"}`);
1580
+ if (techStack) summary.push(`- stack: ${techStack}`);
1581
+ if (conventions) summary.push(`- conventions: ${conventions}`);
1582
+ if (build) summary.push(`- build: ${build}`);
1583
+ if (directives.length > 0) {
1584
+ const firstDirective = directives[0] as Record<string, unknown>;
1585
+ const directive = safeContextSnippet(firstDirective.directive);
1586
+ if (directive) summary.push(`- directive: ${directive}`);
1587
+ }
1588
+ if (notes.length > 0) {
1589
+ const firstNote = notes[0] as Record<string, unknown>;
1590
+ const note = safeContextSnippet(firstNote.content);
1591
+ if (note) summary.push(`- note: ${note}`);
1592
+ }
1593
+ if (summary.length > 1) {
1594
+ sections.push(["[Project memory]", ...summary].join("\n"));
1595
+ }
1596
+ }
1597
+
1598
+ if (existsSync(omxNotepadPath(cwd))) {
1599
+ try {
1600
+ const notepad = await readFile(omxNotepadPath(cwd), "utf-8");
1601
+ const header = "## PRIORITY";
1602
+ const idx = notepad.indexOf(header);
1603
+ if (idx >= 0) {
1604
+ const nextHeader = notepad.indexOf("\n## ", idx + header.length);
1605
+ const section = (
1606
+ nextHeader < 0
1607
+ ? notepad.slice(idx + header.length)
1608
+ : notepad.slice(idx + header.length, nextHeader)
1609
+ )
1610
+ .split(/\r?\n/)
1611
+ .map((line) => line.trim())
1612
+ .filter(Boolean)
1613
+ .join(" ");
1614
+ if (section) {
1615
+ sections.push(`[Priority notes]\n- ${section.slice(0, 220)}`);
1616
+ }
1617
+ }
1618
+ } catch {
1619
+ // best effort only
1620
+ }
1621
+ }
1622
+
1623
+ const wikiContext = buildWikiSessionStartContext({ cwd });
1624
+ if (wikiContext.additionalContext) {
1625
+ sections.push(wikiContext.additionalContext);
1626
+ }
1627
+
1628
+ const subagentSummary = await readSubagentSessionSummary(cwd, sessionId).catch(() => null);
1629
+ if (subagentSummary && subagentSummary.activeSubagentThreadIds.length > 0) {
1630
+ sections.push(`[Subagents]\n- active subagent threads: ${subagentSummary.activeSubagentThreadIds.length}`);
1631
+ }
1632
+
1633
+ return sections.length > 0 ? sections.join("\n\n") : null;
1634
+ }
1635
+
1636
+ type ExecutionEnvironmentKind =
1637
+ | "attached-tmux-runtime"
1638
+ | "outside-tmux-with-bridge"
1639
+ | "native-outside-tmux"
1640
+ | "direct-cli-outside-tmux";
1641
+
1642
+ interface ExecutionEnvironmentInfo {
1643
+ kind: ExecutionEnvironmentKind;
1644
+ launcher: CodexLauncherKind;
1645
+ transport: CodexTransportKind;
1646
+ surface: string;
1647
+ tmuxWorkflowGuidance: string;
1648
+ questionGuidance: string;
1649
+ teamRuntimeInstruction: string;
1650
+ teamHelpInstruction: string;
1651
+ deepInterviewInstruction: string;
1652
+ leaderPaneHint: string;
1653
+ }
1654
+
1655
+ function resolveExecutionEnvironment(
1656
+ cwd: string,
1657
+ options: {
1658
+ hookEventName?: CodexHookEventName | null;
1659
+ payload?: CodexHookPayload;
1660
+ canonicalSessionId?: string;
1661
+ nativeSessionId?: string;
1662
+ } = {},
1663
+ ): ExecutionEnvironmentInfo {
1664
+ const executionSurface = resolveCodexExecutionSurface(cwd, options);
1665
+ const leaderPaneHint = resolveQuestionLeaderPaneHint(cwd, options.payload);
1666
+ const questionBridgeHint = leaderPaneHint
1667
+ ? `tmux return bridge recorded at ${leaderPaneHint}, but this process is not attached to tmux; prefer native/user-input fallback unless running from an attached tmux pane`
1668
+ : "not available from this outside-tmux surface; use native structured input when available or ask one concise plain-text question";
1669
+
1670
+ if (executionSurface.transport === "attached-tmux") {
1671
+ return {
1672
+ kind: "attached-tmux-runtime",
1673
+ launcher: executionSurface.launcher,
1674
+ transport: executionSurface.transport,
1675
+ surface: "attached tmux runtime - tmux",
1676
+ tmuxWorkflowGuidance: "omx team, omx hud, and omx question are directly usable in this session",
1677
+ questionGuidance: "visible temporary renderer available from the current pane; primary success JSON is answers[]",
1678
+ teamRuntimeInstruction: "Use the durable OMX team runtime via `omx team ...` for coordinated execution; do not replace it with in-process fanout.",
1679
+ teamHelpInstruction: "If you need runtime syntax, run `omx team --help` yourself.",
1680
+ deepInterviewInstruction: "Deep-interview must ask each interview round via `omx question`; do not fall back to `request_user_input` or plain-text questioning. This session is already attached to tmux, so `omx question` can open its temporary renderer directly over the leader pane. After starting `omx question` in a background terminal, wait for that terminal to finish and read the JSON answer before continuing the interview. Prefer `answers[0].answer` / `answers[]`; use legacy `answer` only as fallback. Deep-interview remains one question per round, so do not batch multiple interview rounds into one `questions[]` form. Stop remains blocked while a deep-interview question obligation is pending.",
1681
+ leaderPaneHint,
1682
+ };
1683
+ }
1684
+
1685
+ if (leaderPaneHint) {
1686
+ const isNativeOutsideTmux = executionSurface.launcher === "native";
1687
+ return {
1688
+ kind: "outside-tmux-with-bridge",
1689
+ launcher: executionSurface.launcher,
1690
+ transport: executionSurface.transport,
1691
+ surface: isNativeOutsideTmux
1692
+ ? "native-hook / Codex App outside tmux with tmux return bridge"
1693
+ : "direct CLI outside tmux with tmux return bridge",
1694
+ tmuxWorkflowGuidance: "omx team and omx hud need an attached tmux OMX CLI shell from this surface; omx question can use the detected bridge",
1695
+ questionGuidance: questionBridgeHint,
1696
+ teamRuntimeInstruction: isNativeOutsideTmux
1697
+ ? "This session is native-hook / Codex App outside tmux; `omx team` is a CLI/tmux runtime surface, not directly available here. Launch OMX CLI from an attached tmux shell first; do not replace it with in-process fanout."
1698
+ : "This session is direct CLI outside tmux with a tmux return bridge for `omx question`; prompt-side `$team` does not auto-start the durable tmux team runtime here. If you intentionally want the runtime, run `omx team ...` yourself from shell instead of replacing it with in-process fanout.",
1699
+ teamHelpInstruction: isNativeOutsideTmux
1700
+ ? "If you need runtime syntax, run `omx team --help` from an attached tmux OMX CLI shell."
1701
+ : "If you need runtime syntax, run `omx team --help` yourself from shell.",
1702
+ deepInterviewInstruction: `Deep-interview is active, but this session is not attached to tmux. Do not invoke \`omx question\`, \`omx hud\`, or \`omx team\` from this surface. Ask each interview round through the native structured question tool when available; otherwise ask exactly one concise plain-text question and wait for the answer. A tmux return bridge (${leaderPaneHint}) is recorded for explicit attached-tmux recovery only, not for default Codex App/native fallback.`,
1703
+ leaderPaneHint,
1704
+ };
1705
+ }
1706
+
1707
+ const isNativeOutsideTmux = executionSurface.launcher === "native" && executionSurface.transport === "outside-tmux";
1708
+ const surface = isNativeOutsideTmux
1709
+ ? "native-hook / Codex App outside tmux"
1710
+ : "direct CLI outside tmux";
1711
+ const teamRuntimeInstruction = isNativeOutsideTmux
1712
+ ? "This session is native-hook / Codex App outside tmux; `omx team` is a CLI/tmux runtime surface, not directly available here. Launch OMX CLI from an attached tmux shell first; do not replace it with in-process fanout."
1713
+ : "This session is direct CLI outside tmux; prompt-side `$team` does not auto-start the durable tmux team runtime here. If you intentionally want the runtime, run `omx team ...` yourself from shell instead of replacing it with in-process fanout.";
1714
+ const teamHelpInstruction = isNativeOutsideTmux
1715
+ ? "If you need runtime syntax, run `omx team --help` from an attached tmux OMX CLI shell rather than from Codex App/native outside-tmux context."
1716
+ : "If you need runtime syntax, run `omx team --help` yourself from shell.";
1717
+ return {
1718
+ kind: isNativeOutsideTmux ? "native-outside-tmux" : "direct-cli-outside-tmux",
1719
+ launcher: executionSurface.launcher,
1720
+ transport: executionSurface.transport,
1721
+ surface,
1722
+ tmuxWorkflowGuidance: "omx team, omx hud, and omx question need an attached tmux OMX CLI shell or preserved question bridge from this surface",
1723
+ questionGuidance: questionBridgeHint,
1724
+ teamRuntimeInstruction,
1725
+ teamHelpInstruction,
1726
+ deepInterviewInstruction: "Deep-interview is active, but this session is not attached to tmux. Do not invoke `omx question`, `omx hud`, or `omx team` from this surface. Ask each interview round through the native structured question tool when available; otherwise ask exactly one concise plain-text question and wait for the answer. Stop gating still applies to the interview, but no tmux question obligation should be created outside tmux.",
1727
+ leaderPaneHint: "",
1728
+ };
1729
+ }
1730
+
1731
+ function buildExecutionEnvironmentSection(
1732
+ cwd: string,
1733
+ options: {
1734
+ hookEventName?: CodexHookEventName | null;
1735
+ payload?: CodexHookPayload;
1736
+ canonicalSessionId?: string;
1737
+ nativeSessionId?: string;
1738
+ } = {},
1739
+ ): string {
1740
+ const environment = resolveExecutionEnvironment(cwd, options);
1741
+ return [
1742
+ "[Execution environment]",
1743
+ `- surface: ${environment.surface}`,
1744
+ `- omx runtime surfaces: ${environment.tmuxWorkflowGuidance}`,
1745
+ `- omx question: ${environment.questionGuidance}`,
1746
+ ].join("\n");
1747
+ }
1748
+
1749
+ function resolveQuestionLeaderPaneHint(cwd: string, payload?: CodexHookPayload): string {
1750
+ const payloadSessionId = safeString(payload?.session_id).trim();
1751
+ const envSessionId = safeString(process.env.OMX_SESSION_ID || process.env.CODEX_SESSION_ID || process.env.SESSION_ID).trim();
1752
+ const sessionId = payloadSessionId || envSessionId;
1753
+ const candidatePaths = [
1754
+ ...(sessionId ? [getStatePath('deep-interview', cwd, sessionId), getStatePath('ralplan', cwd, sessionId), getStatePath('ralph', cwd, sessionId)] : []),
1755
+ getStatePath('deep-interview', cwd),
1756
+ getStatePath('ralplan', cwd),
1757
+ getStatePath('ralph', cwd),
1758
+ ];
1759
+
1760
+ for (const path of candidatePaths) {
1761
+ try {
1762
+ if (!existsSync(path)) continue;
1763
+ const parsed = JSON.parse(readFileSync(path, 'utf-8')) as Record<string, unknown>;
1764
+ const pane = safeString(parsed?.tmux_pane_id).trim();
1765
+ if (/^%\d+$/.test(pane)) return pane;
1766
+ } catch {
1767
+ // best effort only
1768
+ }
1769
+ }
1770
+
1771
+ const envPane = safeString(process.env.TMUX_PANE).trim();
1772
+ return /^%\d+$/.test(envPane) ? envPane : '';
1773
+ }
1774
+
1775
+ function buildDeepInterviewQuestionBridgeInstruction(cwd: string, payload?: CodexHookPayload): string {
1776
+ return resolveExecutionEnvironment(cwd, {
1777
+ hookEventName: "UserPromptSubmit",
1778
+ payload,
1779
+ nativeSessionId: safeString(payload?.session_id ?? payload?.sessionId).trim(),
1780
+ }).deepInterviewInstruction;
1781
+ }
1782
+
1783
+ function buildTeamRuntimeInstruction(cwd: string, payload?: CodexHookPayload): string {
1784
+ return resolveExecutionEnvironment(cwd, {
1785
+ hookEventName: "UserPromptSubmit",
1786
+ payload,
1787
+ nativeSessionId: safeString(payload?.session_id ?? payload?.sessionId).trim(),
1788
+ }).teamRuntimeInstruction;
1789
+ }
1790
+
1791
+ function buildTeamHelpInstruction(cwd: string, payload?: CodexHookPayload): string {
1792
+ return resolveExecutionEnvironment(cwd, {
1793
+ hookEventName: "UserPromptSubmit",
1794
+ payload,
1795
+ nativeSessionId: safeString(payload?.session_id ?? payload?.sessionId).trim(),
1796
+ }).teamHelpInstruction;
1797
+ }
1798
+
1799
+ function buildNativeOutsideTmuxTeamPromptBlockState(
1800
+ prompt: string,
1801
+ cwd: string,
1802
+ payload: CodexHookPayload,
1803
+ sessionId?: string,
1804
+ threadId?: string,
1805
+ turnId?: string,
1806
+ ): SkillActiveState | null {
1807
+ if (!readTeamModeConfig(cwd).enabled) return null;
1808
+ const match = detectPrimaryKeyword(prompt);
1809
+ if (match?.skill !== "team") return null;
1810
+
1811
+ const environment = resolveExecutionEnvironment(cwd, {
1812
+ hookEventName: "UserPromptSubmit",
1813
+ payload,
1814
+ canonicalSessionId: sessionId ?? "",
1815
+ nativeSessionId: safeString(payload.session_id ?? payload.sessionId).trim(),
1816
+ });
1817
+ if (!(environment.launcher === "native" && environment.transport === "outside-tmux")) return null;
1818
+
1819
+ const nowIso = new Date().toISOString();
1820
+ return {
1821
+ version: 1,
1822
+ active: false,
1823
+ skill: "team",
1824
+ keyword: match.keyword,
1825
+ phase: "planning",
1826
+ activated_at: nowIso,
1827
+ updated_at: nowIso,
1828
+ source: "keyword-detector",
1829
+ session_id: sessionId,
1830
+ thread_id: threadId,
1831
+ turn_id: turnId,
1832
+ active_skills: [],
1833
+ transition_error: "Codex App/native outside-tmux sessions cannot activate the tmux-only `team` workflow directly. Launch OMX CLI from an attached tmux shell first, then run `omx team ...` there.",
1834
+ };
1835
+ }
1836
+
1837
+ function buildSkillStateCliInstruction(mode: string, statePath: string): string {
1838
+ return `skill: ${mode} activated and initial state initialized at ${statePath}; use CLI-first state updates via \`omx state write/read/clear --input '<json>' --json\`; use omx_state MCP only when explicit MCP compatibility is enabled.`;
1839
+ }
1840
+
1841
+ function buildAutopilotPromptActivationNote(
1842
+ skillState?: SkillActiveState | null,
1843
+ options: { markedQuestionAnswer?: boolean; cwd?: string } = {},
1844
+ ): string | null {
1845
+ if (skillState?.initialized_mode !== "autopilot") return null;
1846
+ const teamHandoff = readTeamModeConfig(options.cwd).enabled
1847
+ ? " (+ $team if needed)"
1848
+ : "";
1849
+ return [
1850
+ `Autopilot protocol: the durable default chain is $deep-interview -> $ralplan -> $ultragoal${teamHandoff} -> $code-review -> $ultraqa (deep-interview -> ralplan -> ultragoal -> code-review -> ultraqa).`,
1851
+ "Start/resume at current_phase=deep-interview unless the task is clear and bounded; if deep-interview is intentionally skipped, persist and state an explicit deep_interview_gate.skip_reason before moving to ralplan.",
1852
+ "Deep-interview is a structured question chain, not a one-question gate: after an omx question answer, re-score ambiguity against the active threshold, treat max_rounds as a cap, and crystallize once ambiguity is at or below threshold and readiness gates pass.",
1853
+ options.markedQuestionAnswer
1854
+ ? "This turn is a marked omx question answer. Treat ordinary selected option/freeform answer text as interview input, then re-score. Do not close merely because the first question was answered; if ambiguity is at or below threshold and readiness gates pass, write interview_complete evidence and hand off. Ask another deep-interview follow-up only when a readiness gate remains unresolved and the answer would materially change execution."
1855
+ : null,
1856
+ "Do not advance from deep-interview to ralplan merely because the first question was answered; persist explicit interview_complete evidence before setting current_phase=ralplan, and do advance when threshold plus readiness gates are satisfied.",
1857
+ "The ralplan phase is not complete until Planner output has been reviewed sequentially by Architect and then Critic; do not hand off to Ultragoal or implementation until the ralplan state/artifact records both ralplan_architect_review and ralplan_critic_review with approval or an explicit blocker.",
1858
+ "Do not silently fall back to ordinary $plan/ralplan-only handling; keep autopilot-state.json, skill-active-state.json, HUD/statusline, and Codex goal-mode handoff guidance visible while the workflow is active.",
1859
+ "When Codex goal tools are available, call get_goal/create_goal only from the active thread handoff and treat the active goal as the completion contract until code-review and ultraqa are clean.",
1860
+ ].filter(Boolean).join(" ");
1861
+ }
1862
+
1863
+ function formatExecutionHandoffList(cwd: string): string {
1864
+ return readTeamModeConfig(cwd).enabled
1865
+ ? "`$ultragoal`, `$team`, or `$ralph`"
1866
+ : "`$ultragoal` or `$ralph`";
1867
+ }
1868
+
1869
+ function buildAdditionalContextMessage(
1870
+ prompt: string,
1871
+ skillState?: SkillActiveState | null,
1872
+ cwd: string = process.cwd(),
1873
+ payload?: CodexHookPayload,
1874
+ ): string | null {
1875
+ if (!prompt) return null;
1876
+ const promptPriorityMessage = buildPromptPriorityMessage(prompt);
1877
+ const teamMode = readTeamModeConfig(cwd);
1878
+ const matches = detectKeywords(prompt).filter((entry) => teamMode.enabled || entry.skill !== "team");
1879
+ const match = matches[0] ?? null;
1880
+ if (!match) {
1881
+ const continuedSkill = safeString(skillState?.skill).trim();
1882
+ if (!continuedSkill) return promptPriorityMessage;
1883
+ const deepInterviewPromptActivationNote = skillState?.initialized_mode === "deep-interview"
1884
+ ? buildDeepInterviewQuestionBridgeInstruction(cwd, payload)
1885
+ : null;
1886
+ const deepInterviewConfigPromptActivationNote = buildDeepInterviewConfigInstruction(cwd, skillState);
1887
+ const markedQuestionAnswer = /^\s*\[omx question answered\]/i.test(prompt);
1888
+ const autopilotPromptActivationNote = buildAutopilotPromptActivationNote(skillState, { markedQuestionAnswer, cwd });
1889
+ return [
1890
+ `OMX native UserPromptSubmit continued active workflow skill "${continuedSkill}".`,
1891
+ promptPriorityMessage,
1892
+ skillState?.initialized_mode && skillState.initialized_state_path
1893
+ ? buildSkillStateCliInstruction(skillState.initialized_mode, skillState.initialized_state_path)
1894
+ : null,
1895
+ deepInterviewPromptActivationNote,
1896
+ deepInterviewConfigPromptActivationNote,
1897
+ autopilotPromptActivationNote,
1898
+ "Follow AGENTS.md routing and preserve workflow transition and planning-safety rules.",
1899
+ ].filter(Boolean).join(" ");
1900
+ }
1901
+ const detectedKeywordMessage = matches.length > 1
1902
+ ? `OMX native UserPromptSubmit detected workflow keywords ${matches.map((entry) => `"${entry.keyword}" -> ${entry.skill}`).join(", ")}.`
1903
+ : `OMX native UserPromptSubmit detected workflow keyword "${match.keyword}" -> ${match.skill}.`;
1904
+ const continuedSkill = safeString(skillState?.skill).trim();
1905
+ if (
1906
+ continuedSkill
1907
+ && continuedSkill !== match.skill
1908
+ && /^\s*\[omx question answered\]/i.test(prompt)
1909
+ ) {
1910
+ const deepInterviewPromptActivationNote = skillState?.initialized_mode === "deep-interview"
1911
+ ? buildDeepInterviewQuestionBridgeInstruction(cwd, payload)
1912
+ : null;
1913
+ const deepInterviewConfigPromptActivationNote = buildDeepInterviewConfigInstruction(cwd, skillState);
1914
+ const autopilotPromptActivationNote = buildAutopilotPromptActivationNote(skillState, { markedQuestionAnswer: true, cwd });
1915
+ return [
1916
+ `OMX native UserPromptSubmit continued active workflow skill "${continuedSkill}"; workflow-like tokens inside the marked omx question answer are treated as answer text, not a new workflow activation.`,
1917
+ promptPriorityMessage,
1918
+ skillState?.initialized_mode && skillState.initialized_state_path
1919
+ ? buildSkillStateCliInstruction(skillState.initialized_mode, skillState.initialized_state_path)
1920
+ : null,
1921
+ deepInterviewPromptActivationNote,
1922
+ deepInterviewConfigPromptActivationNote,
1923
+ autopilotPromptActivationNote,
1924
+ "Follow AGENTS.md routing and preserve workflow transition and planning-safety rules.",
1925
+ ].filter(Boolean).join(" ");
1926
+ }
1927
+ const activeSkills = Array.isArray(skillState?.active_skills)
1928
+ ? skillState.active_skills.map((entry) => entry.skill)
1929
+ : [];
1930
+ const deferredSkills = Array.isArray(skillState?.deferred_skills)
1931
+ ? skillState.deferred_skills
1932
+ : [];
1933
+ const teamDetected = activeSkills.includes("team");
1934
+ const ralphPromptActivationNote = skillState?.initialized_mode === "ralph"
1935
+ ? "Prompt-side `$ralph` activation seeds Ralph workflow state only; it does not invoke `omx ralph`. Use `omx ralph --prd ...` only when you explicitly want the PRD-gated CLI startup path."
1936
+ : null;
1937
+ const deepInterviewPromptActivationNote = skillState?.initialized_mode === "deep-interview"
1938
+ ? buildDeepInterviewQuestionBridgeInstruction(cwd, payload)
1939
+ : null;
1940
+ const deepInterviewConfigPromptActivationNote = buildDeepInterviewConfigInstruction(cwd, skillState);
1941
+ const ultraworkPromptActivationNote = skillState?.initialized_mode === "ultrawork"
1942
+ ? "Ultrawork protocol: ground the task before editing, define pass/fail acceptance criteria, keep shared-file work local, and use direct-tool plus background evidence lanes only for truly independent work. Direct ultrawork provides lightweight verification only; Ralph owns persistence and the full verified-completion promise."
1943
+ : null;
1944
+ const ultragoalPromptActivationNote = match.skill === "ultragoal"
1945
+ ? "Ultragoal protocol: use `omx ultragoal create-goals` / `complete-goals` / `checkpoint` for `.omx/ultragoal` artifacts, then use Codex goal model tools only from the active agent handoff (`get_goal`, `create_goal`, `update_goal`) and never overwrite a different active Codex goal. Ultragoal does not call `/goal clear`; for multiple sequential ultragoal runs in one Codex session/thread, manually clear the completed Codex goal in the UI before creating the next aggregate goal."
1946
+ : null;
1947
+ const autopilotPromptActivationNote = buildAutopilotPromptActivationNote(skillState, { cwd });
1948
+ const combinedTransitionMessage = (() => {
1949
+ if (!skillState?.transition_message) return null;
1950
+ if (matches.length <= 1 || activeSkills.length <= 1) return skillState.transition_message;
1951
+ const source = skillState.transition_message.match(/^mode transiting: (.+?) -> /)?.[1];
1952
+ if (!source) return skillState.transition_message;
1953
+ return `mode transiting: ${source} -> ${activeSkills.join(" + ")}`;
1954
+ })();
1955
+
1956
+ if (skillState?.transition_error) {
1957
+ return [
1958
+ `OMX native UserPromptSubmit denied workflow keyword "${match.keyword}" -> ${match.skill}.`,
1959
+ skillState.transition_error,
1960
+ promptPriorityMessage,
1961
+ 'Follow AGENTS.md routing and preserve workflow transition and planning-safety rules.',
1962
+ ].join(' ');
1963
+ }
1964
+
1965
+ if (skillState?.transition_message) {
1966
+ return [
1967
+ detectedKeywordMessage,
1968
+ combinedTransitionMessage,
1969
+ activeSkills.length > 1 ? `active skills: ${activeSkills.join(", ")}.` : null,
1970
+ deferredSkills.length > 0
1971
+ ? `planning preserved over simultaneous execution follow-up; deferred skills: ${deferredSkills.join(", ")}.`
1972
+ : null,
1973
+ promptPriorityMessage,
1974
+ ultragoalPromptActivationNote,
1975
+ autopilotPromptActivationNote,
1976
+ deepInterviewConfigPromptActivationNote,
1977
+ skillState.initialized_mode && skillState.initialized_state_path
1978
+ ? buildSkillStateCliInstruction(skillState.initialized_mode, skillState.initialized_state_path)
1979
+ : null,
1980
+ teamDetected
1981
+ ? buildTeamRuntimeInstruction(cwd, payload)
1982
+ : null,
1983
+ teamDetected ? buildTeamHelpInstruction(cwd, payload) : null,
1984
+ 'Follow AGENTS.md routing and preserve workflow transition and planning-safety rules.',
1985
+ ].filter(Boolean).join(' ');
1986
+ }
1987
+
1988
+ if (teamDetected) {
1989
+ const initializedStateMessage = skillState?.initialized_mode && skillState.initialized_state_path
1990
+ ? buildSkillStateCliInstruction(skillState.initialized_mode, skillState.initialized_state_path)
1991
+ : null;
1992
+ return [
1993
+ detectedKeywordMessage,
1994
+ activeSkills.length > 1 ? `active skills: ${activeSkills.join(", ")}.` : null,
1995
+ deferredSkills.length > 0
1996
+ ? `planning preserved over simultaneous execution follow-up; deferred skills: ${deferredSkills.join(", ")}.`
1997
+ : null,
1998
+ promptPriorityMessage,
1999
+ initializedStateMessage,
2000
+ deepInterviewPromptActivationNote,
2001
+ deepInterviewConfigPromptActivationNote,
2002
+ ultraworkPromptActivationNote,
2003
+ ultragoalPromptActivationNote,
2004
+ autopilotPromptActivationNote,
2005
+ buildTeamRuntimeInstruction(cwd, payload),
2006
+ buildTeamHelpInstruction(cwd, payload),
2007
+ "Follow AGENTS.md routing and preserve workflow transition and planning-safety rules.",
2008
+ ].filter(Boolean).join(" ");
2009
+ }
2010
+
2011
+ if (skillState?.initialized_mode && skillState.initialized_state_path) {
2012
+ return [
2013
+ detectedKeywordMessage,
2014
+ activeSkills.length > 1 ? `active skills: ${activeSkills.join(", ")}.` : null,
2015
+ deferredSkills.length > 0
2016
+ ? `planning preserved over simultaneous execution follow-up; deferred skills: ${deferredSkills.join(", ")}.`
2017
+ : null,
2018
+ promptPriorityMessage,
2019
+ buildSkillStateCliInstruction(skillState.initialized_mode, skillState.initialized_state_path),
2020
+ deepInterviewPromptActivationNote,
2021
+ deepInterviewConfigPromptActivationNote,
2022
+ ultraworkPromptActivationNote,
2023
+ ultragoalPromptActivationNote,
2024
+ autopilotPromptActivationNote,
2025
+ ralphPromptActivationNote,
2026
+ "Follow AGENTS.md routing and preserve workflow transition and planning-safety rules.",
2027
+ ].join(" ");
2028
+ }
2029
+
2030
+ return [detectedKeywordMessage, promptPriorityMessage, ultragoalPromptActivationNote, autopilotPromptActivationNote, "Follow AGENTS.md routing and preserve workflow transition and planning-safety rules."].filter(Boolean).join(" ");
2031
+ }
2032
+
2033
+ function parseTeamWorkerEnv(rawValue: string): { teamName: string; workerName: string } | null {
2034
+ const match = /^([a-z0-9][a-z0-9-]{0,29})\/(worker-\d+)$/.exec(rawValue.trim());
2035
+ if (!match) return null;
2036
+ return {
2037
+ teamName: match[1] || "",
2038
+ workerName: match[2] || "",
2039
+ };
2040
+ }
2041
+
2042
+ async function resolveTeamStateDirForWorkerContext(
2043
+ cwd: string,
2044
+ workerContext: { teamName: string; workerName: string },
2045
+ ): Promise<string | null> {
2046
+ const resolved = await resolveWorkerNotifyTeamStateRootPath(cwd, workerContext, process.env).catch(() => null);
2047
+ if (resolved) return resolved;
2048
+ const explicit = safeString(process.env.OMX_TEAM_STATE_ROOT).trim();
2049
+ if (explicit) {
2050
+ const candidate = resolve(cwd, explicit);
2051
+ const workerRoot = join(candidate, "team", workerContext.teamName, "workers", workerContext.workerName);
2052
+ if (existsSync(workerRoot)) return candidate;
2053
+ return candidate;
2054
+ }
2055
+ return null;
2056
+ }
2057
+
2058
+ async function isConfirmedTeamWorkerPromptSubmitPane(cwd: string): Promise<boolean> {
2059
+ const workerContext =
2060
+ parseTeamWorkerEnv(safeString(process.env.OMX_TEAM_INTERNAL_WORKER))
2061
+ || parseTeamWorkerEnv(safeString(process.env.OMX_TEAM_WORKER));
2062
+ if (!workerContext) return false;
2063
+
2064
+ const currentPaneId = safeString(process.env.TMUX_PANE).trim();
2065
+ if (!currentPaneId) return false;
2066
+
2067
+ const config = await readTeamConfig(workerContext.teamName, cwd).catch(() => null);
2068
+ if (!config) return false;
2069
+
2070
+ const leaderPaneId = safeString(config.leader_pane_id).trim();
2071
+ if (leaderPaneId && leaderPaneId === currentPaneId) return false;
2072
+
2073
+ const workerPaneId = safeString(
2074
+ config.workers.find((worker) => worker.name === workerContext.workerName)?.pane_id,
2075
+ ).trim();
2076
+ return workerPaneId !== "" && workerPaneId === currentPaneId;
2077
+ }
2078
+
2079
+
2080
+ type TeamWorkerStopDecision =
2081
+ | {
2082
+ kind: "blocked";
2083
+ stateDir: string;
2084
+ workerContext: { teamName: string; workerName: string };
2085
+ output: Record<string, unknown>;
2086
+ allowRepeatDuringStopHook: boolean;
2087
+ }
2088
+ | {
2089
+ kind: "allowed";
2090
+ stateDir: string;
2091
+ workerContext: { teamName: string; workerName: string };
2092
+ }
2093
+ | {
2094
+ kind: "unresolved";
2095
+ reason: string;
2096
+ };
2097
+
2098
+ async function resolveTeamWorkerStopDecision(
2099
+ cwd: string,
2100
+ ): Promise<TeamWorkerStopDecision> {
2101
+ const workerContext =
2102
+ parseTeamWorkerEnv(safeString(process.env.OMX_TEAM_INTERNAL_WORKER))
2103
+ || parseTeamWorkerEnv(safeString(process.env.OMX_TEAM_WORKER));
2104
+ if (!workerContext) return { kind: "unresolved", reason: "missing_worker_context" };
2105
+
2106
+ const blockWorkerStop = (
2107
+ reasonCode: string,
2108
+ detail: string,
2109
+ stateDirForDecision = getBaseStateDir(cwd),
2110
+ ): TeamWorkerStopDecision => ({
2111
+ kind: "blocked",
2112
+ stateDir: stateDirForDecision,
2113
+ workerContext,
2114
+ allowRepeatDuringStopHook: false,
2115
+ output: {
2116
+ decision: "block",
2117
+ reason:
2118
+ `OMX team worker ${workerContext.workerName} Stop cannot be allowed for ${reasonCode}: ${detail}. ` +
2119
+ "Continue the assigned task, repair worker state, or report a concrete blocker before stopping.",
2120
+ stopReason: `team_worker_${workerContext.workerName}_${reasonCode}`,
2121
+ systemMessage:
2122
+ `OMX team worker ${workerContext.workerName} Stop lacks completed task evidence (${reasonCode}).`,
2123
+ },
2124
+ });
2125
+
2126
+ const stateDir = await resolveTeamStateDirForWorkerContext(cwd, workerContext);
2127
+ if (!stateDir) {
2128
+ return blockWorkerStop("missing_state_dir", "team state root could not be resolved");
2129
+ }
2130
+ const workerRoot = join(stateDir, "team", workerContext.teamName, "workers", workerContext.workerName);
2131
+ const [identity, status] = await Promise.all([
2132
+ readJsonIfExists(join(workerRoot, "identity.json")),
2133
+ readJsonIfExists(join(workerRoot, "status.json")),
2134
+ ]);
2135
+ const workerRunState = safeString(status?.state).trim().toLowerCase();
2136
+ const workerRunStateIsTerminal = TEAM_WORKER_TERMINAL_RUN_STATES.has(workerRunState);
2137
+ if (!identity && !status && !existsSync(workerRoot)) {
2138
+ return blockWorkerStop("missing_worker_state", "worker identity/status state is missing", stateDir);
2139
+ }
2140
+
2141
+ const candidateTaskIds = new Set<string>();
2142
+ const currentTaskId = safeString(status?.current_task_id).trim();
2143
+ if (currentTaskId) candidateTaskIds.add(currentTaskId);
2144
+ const assignedTasks = Array.isArray(identity?.assigned_tasks) ? identity?.assigned_tasks : [];
2145
+ for (const taskId of assignedTasks) {
2146
+ const normalized = safeString(taskId).trim();
2147
+ if (normalized) candidateTaskIds.add(normalized);
2148
+ }
2149
+
2150
+ const tasksDir = join(stateDir, "team", workerContext.teamName, "tasks");
2151
+ if (existsSync(tasksDir)) {
2152
+ const taskFiles = await readdir(tasksDir).catch(() => []);
2153
+ for (const entry of taskFiles) {
2154
+ if (!/^task-\d+\.json$/.test(entry)) continue;
2155
+ const task = await readJsonIfExists(join(tasksDir, entry));
2156
+ const taskOwner = safeString(task?.owner).trim();
2157
+ const taskClaimOwner = safeString(safeObject(task?.claim).owner).trim();
2158
+ if (taskOwner !== workerContext.workerName && taskClaimOwner !== workerContext.workerName) continue;
2159
+ const idFromFile = /^task-(\d+)\.json$/.exec(entry)?.[1] ?? "";
2160
+ const taskId = safeString(task?.id).trim() || idFromFile;
2161
+ if (taskId) candidateTaskIds.add(taskId);
2162
+ }
2163
+ }
2164
+
2165
+ if (candidateTaskIds.size === 0) {
2166
+ return blockWorkerStop("missing_task_assignment", "no current_task_id or assigned_tasks are recorded", stateDir);
2167
+ }
2168
+
2169
+ let completedTaskCount = 0;
2170
+ for (const taskId of candidateTaskIds) {
2171
+ const task = await readJsonIfExists(
2172
+ join(stateDir, "team", workerContext.teamName, "tasks", `task-${taskId}.json`),
2173
+ );
2174
+ const statusValue = safeString(task?.status).trim().toLowerCase();
2175
+ if (!statusValue) {
2176
+ return blockWorkerStop(`missing_task_state_${taskId}`, `task ${taskId} has no readable status`, stateDir);
2177
+ }
2178
+ if (statusValue === "completed") {
2179
+ completedTaskCount += 1;
2180
+ continue;
2181
+ }
2182
+ if (!TEAM_STOP_BLOCKING_TASK_STATUSES.has(statusValue)) {
2183
+ return blockWorkerStop(
2184
+ `non_completed_task_${taskId}_${statusValue}`,
2185
+ `task ${taskId} is ${statusValue}, not completed`,
2186
+ stateDir,
2187
+ );
2188
+ }
2189
+ return {
2190
+ kind: "blocked",
2191
+ stateDir,
2192
+ workerContext,
2193
+ allowRepeatDuringStopHook: !workerRunStateIsTerminal,
2194
+ output: {
2195
+ decision: "block",
2196
+ reason:
2197
+ `OMX team worker ${workerContext.workerName} is still assigned non-terminal task ${taskId} (${statusValue}); continue the current assigned task or report a concrete blocker before stopping.`,
2198
+ stopReason: `team_worker_${workerContext.workerName}_${taskId}_${statusValue}`,
2199
+ systemMessage:
2200
+ `OMX team worker ${workerContext.workerName} is still assigned task ${taskId} (${statusValue}).`,
2201
+ },
2202
+ };
2203
+ }
2204
+
2205
+ if (completedTaskCount === candidateTaskIds.size) {
2206
+ return { kind: "allowed", stateDir, workerContext };
2207
+ }
2208
+
2209
+ return blockWorkerStop("missing_completed_task_evidence", "no referenced worker task is completed", stateDir);
2210
+ }
2211
+
2212
+ function isStopExempt(payload: CodexHookPayload): boolean {
2213
+ const candidates = [
2214
+ payload.stop_reason,
2215
+ payload.stopReason,
2216
+ payload.reason,
2217
+ payload.exit_reason,
2218
+ payload.exitReason,
2219
+ ]
2220
+ .map((value) => safeString(value).toLowerCase())
2221
+ .filter(Boolean);
2222
+ return candidates.some((value) =>
2223
+ value.includes("cancel")
2224
+ || value.includes("abort")
2225
+ || value.includes("context")
2226
+ || value.includes("compact")
2227
+ || value.includes("limit"),
2228
+ );
2229
+ }
2230
+
2231
+ async function buildModeBasedStopOutput(
2232
+ mode: "autopilot" | "ultrawork" | "ultraqa",
2233
+ cwd: string,
2234
+ sessionId?: string,
2235
+ ): Promise<Record<string, unknown> | null> {
2236
+ if (await readCanonicalTerminalRunStateForStop(cwd, sessionId, mode)) {
2237
+ return null;
2238
+ }
2239
+ if (mode === "autopilot" && await readAutopilotDeepInterviewQuestionWaitState(cwd, sessionId)) {
2240
+ return null;
2241
+ }
2242
+ const state = await readModeStateForActiveDecision(mode, sessionId?.trim() || undefined, cwd);
2243
+ if (!state || !shouldContinueRun(state)) return null;
2244
+ const phase = formatPhase(state.current_phase);
2245
+ const systemMessage = mode === "autopilot" && phase.toLowerCase().replace(/_/g, "-") === "code-review"
2246
+ ? "OMX autopilot is still active (phase: code-review). Run the required $code-review step before completing or clearing Autopilot state."
2247
+ : `OMX ${mode} is still active (phase: ${phase}).`;
2248
+ return {
2249
+ decision: "block",
2250
+ reason: `OMX ${mode} is still active (phase: ${phase}); continue the task and gather fresh verification evidence before stopping.`,
2251
+ stopReason: `${mode}_${phase}`,
2252
+ systemMessage,
2253
+ };
2254
+ }
2255
+
2256
+ export function looksLikeGoalCompletionPrompt(text: string): boolean {
2257
+ return /\bupdate_goal\s*\(/i.test(text)
2258
+ || /\bomx\s+(?:ultragoal|performance-goal|autoresearch-goal)\s+(?:checkpoint|complete)\b/i.test(text)
2259
+ || /\b(?:complete|checkpoint|finish|close|mark)\b.{0,80}\b(?:goal|ultragoal|performance[-\s]goal|autoresearch[-\s]goal)\b/i.test(text)
2260
+ || /\b(?:ultragoal|performance[-\s]goal|autoresearch[-\s]goal)\b.{0,80}\b(?:complete|checkpoint|finish|close|mark)\b/i.test(text)
2261
+ || /(?:^|[.!?]\s+)(?:the\s+)?goal\s+(?:is\s+|now\s+|has\s+been\s+)?(?:complete|completed|finished|closed)(?:\s*(?:[.!?]|$)|\s*[:;]\s*\S|\s*[—–-]\s*\S)/i.test(text);
2262
+ }
2263
+
2264
+ function reportsAutoresearchGoalObjectiveMismatch(text: string): boolean {
2265
+ return /\bautoresearch[-\s]goal\b/i.test(text)
2266
+ && /\b(?:complete|completion|reconciliation)\b/i.test(text)
2267
+ && /objective mismatch/i.test(text);
2268
+ }
2269
+
2270
+ function reportsBlockedPerformanceGoalObjectiveMismatch(state: unknown): boolean {
2271
+ const performanceState = safeObject(state);
2272
+ const lastValidation = safeObject(performanceState.lastValidation);
2273
+ if (safeString(performanceState.workflow) !== "performance-goal") return false;
2274
+ if (safeString(performanceState.status) !== "blocked") return false;
2275
+ if (safeString(lastValidation.status) !== "blocked") return false;
2276
+
2277
+ const evidence = [
2278
+ safeString(lastValidation.evidence),
2279
+ safeString(lastValidation.message),
2280
+ safeString(performanceState.evidence),
2281
+ safeString(performanceState.message),
2282
+ ].join(" ");
2283
+ return /objective mismatch/i.test(evidence);
2284
+ }
2285
+
2286
+ function reportsBlockedUltragoalCompletedAggregateMicrogoalLoop(goal: Record<string, unknown>): boolean {
2287
+ const evidence = [
2288
+ safeString(goal.failureReason),
2289
+ safeString(goal.blockedReason),
2290
+ safeString(goal.evidence),
2291
+ ].join(" ");
2292
+ return /aggregate codex goal/i.test(evidence)
2293
+ && /\bcomplete(?:d)?\b/i.test(evidence)
2294
+ && /microgoal/i.test(evidence)
2295
+ && /\b(?:unreconcilable|mismatch|loop|already complete|already completed|blocks?)\b/i.test(evidence);
2296
+ }
2297
+
2298
+ async function findActiveGoalWorkflowReconciliationRequirement(cwd: string): Promise<{ workflow: string; command: string; remediation?: string } | null> {
2299
+ const ultragoal = await readJsonIfExists(join(cwd, ".omx", "ultragoal", "goals.json"));
2300
+ const aggregateCompletion = safeObject(ultragoal?.aggregateCompletion);
2301
+ const aggregateProductComplete = safeString(aggregateCompletion.status) === "complete";
2302
+ const ultragoals = Array.isArray(ultragoal?.goals) ? ultragoal.goals.map(safeObject) : [];
2303
+ const activeUltragoal = aggregateProductComplete
2304
+ ? undefined
2305
+ : ultragoals.find((goal) => safeString(goal.status) === "in_progress" || safeString(goal.id) === safeString(ultragoal?.activeGoalId));
2306
+ if (activeUltragoal && reportsBlockedUltragoalCompletedAggregateMicrogoalLoop(activeUltragoal)) {
2307
+ return null;
2308
+ }
2309
+ if (activeUltragoal) {
2310
+ const goalId = safeString(activeUltragoal.id) || "<goal-id>";
2311
+ return {
2312
+ workflow: "ultragoal",
2313
+ command: `omx ultragoal checkpoint --goal-id ${goalId} --status complete --codex-goal-json '<get_goal JSON or path>' --evidence '<evidence>'`,
2314
+ remediation: [
2315
+ `If get_goal returns a completed task-scoped objective for the same aggregate ultragoal plan, checkpoint ${goalId} with evidence naming ${goalId} plus .omx/ultragoal/goals.json or ledger.jsonl and pass final quality-gate JSON; OMX will reconcile the completed planned scope without mutating Codex goal state.`,
2316
+ `If get_goal instead returns a different completed legacy objective and complete checkpointing fails, do not repeat --status complete in this thread.`,
2317
+ `Record the non-terminal blocker with: omx ultragoal checkpoint --goal-id ${goalId} --status blocked --codex-goal-json '<different completed get_goal JSON or path>' --evidence '<completed legacy Codex goal blocks create_goal in this thread>'.`,
2318
+ `If get_goal itself is unavailable with a Codex DB/schema/context error such as "no such table: thread_goals", record an auditable safe-recovery blocker instead: omx ultragoal checkpoint --goal-id ${goalId} --status blocked --codex-goal-json '<unavailable get_goal error JSON or path>' --evidence '<get_goal unavailable due to Codex DB/schema/context error; safe recovery requires a working Codex goal context>'.`,
2319
+ "Then continue only from a Codex goal context with no active/completed conflicting goal in the same repo/worktree and create the intended goal there.",
2320
+ ].join(" "),
2321
+ };
2322
+ }
2323
+
2324
+ const performanceRoot = join(cwd, ".omx", "goals", "performance");
2325
+ for (const entry of await readdir(performanceRoot, { withFileTypes: true }).catch(() => [])) {
2326
+ if (!entry.isDirectory()) continue;
2327
+ const state = await readJsonIfExists(join(performanceRoot, entry.name, "state.json"));
2328
+ const status = safeString(state?.status);
2329
+ if (reportsBlockedPerformanceGoalObjectiveMismatch(state)) {
2330
+ continue;
2331
+ }
2332
+ if (state?.workflow === "performance-goal" && status && status !== "complete") {
2333
+ return {
2334
+ workflow: "performance-goal",
2335
+ command: `omx performance-goal complete --slug ${safeString(state.slug) || entry.name} --codex-goal-json '<get_goal JSON or path>' --evidence '<evidence>'`,
2336
+ };
2337
+ }
2338
+ }
2339
+
2340
+ const autoresearchRoot = join(cwd, ".omx", "goals", "autoresearch");
2341
+ for (const entry of await readdir(autoresearchRoot, { withFileTypes: true }).catch(() => [])) {
2342
+ if (!entry.isDirectory()) continue;
2343
+ const mission = await readJsonIfExists(join(autoresearchRoot, entry.name, "mission.json"));
2344
+ const status = safeString(mission?.status);
2345
+ const completion = await readJsonIfExists(join(autoresearchRoot, entry.name, "completion.json"));
2346
+ const completionVerdict = safeString(completion?.verdict);
2347
+ const completionPassed = completion?.passed === true || completionVerdict === "pass";
2348
+ if (
2349
+ mission?.workflow === "autoresearch-goal"
2350
+ && status
2351
+ && status !== "complete"
2352
+ && completionPassed
2353
+ ) {
2354
+ return {
2355
+ workflow: "autoresearch-goal",
2356
+ command: `omx autoresearch-goal complete --slug ${safeString(mission.slug) || entry.name} --codex-goal-json '<get_goal JSON or path>'`,
2357
+ remediation: [
2358
+ "If that command fails with a Codex goal objective mismatch after a refreshed get_goal snapshot, do not repeat the same complete command blindly in this thread.",
2359
+ "Either retry with a correct refreshed snapshot or record an explicit blocked verdict for this autoresearch-goal and continue from the explicit blocker path.",
2360
+ ].join(" "),
2361
+ };
2362
+ }
2363
+ }
2364
+
2365
+ return null;
2366
+ }
2367
+
2368
+ async function buildGoalWorkflowReconciliationPromptWarning(cwd: string, prompt: string): Promise<string | null> {
2369
+ if (!looksLikeGoalCompletionPrompt(prompt)) return null;
2370
+ const requirement = await findActiveGoalWorkflowReconciliationRequirement(cwd);
2371
+ if (!requirement) return null;
2372
+ return [
2373
+ `OMX ${requirement.workflow} goal workflow requires Codex goal snapshot reconciliation before completion.`,
2374
+ "Call get_goal, pass the resulting JSON or a path with --codex-goal-json, and do not rely on hooks or shell commands to mutate Codex-owned goal state.",
2375
+ `Required command shape: ${requirement.command}.`,
2376
+ requirement.remediation,
2377
+ ].filter(Boolean).join(" ");
2378
+ }
2379
+
2380
+ async function buildGoalWorkflowReconciliationStopOutput(
2381
+ payload: CodexHookPayload,
2382
+ cwd: string,
2383
+ ): Promise<Record<string, unknown> | null> {
2384
+ const lastAssistantMessage = safeString(payload.last_assistant_message ?? payload.lastAssistantMessage);
2385
+ if (!looksLikeGoalCompletionPrompt(lastAssistantMessage)) return null;
2386
+ const requirement = await findActiveGoalWorkflowReconciliationRequirement(cwd);
2387
+ if (!requirement) return null;
2388
+ if (requirement.workflow === "autoresearch-goal" && reportsAutoresearchGoalObjectiveMismatch(lastAssistantMessage)) {
2389
+ return null;
2390
+ }
2391
+ const systemMessage =
2392
+ [
2393
+ `OMX ${requirement.workflow} requires get_goal snapshot reconciliation before completion; call get_goal and pass --codex-goal-json to ${requirement.command}.`,
2394
+ requirement.remediation,
2395
+ "Hooks must not mutate Codex goal state.",
2396
+ ].filter(Boolean).join(" ");
2397
+ return {
2398
+ decision: "block",
2399
+ reason: systemMessage,
2400
+ stopReason: `${requirement.workflow}_codex_goal_snapshot_required`,
2401
+ systemMessage,
2402
+ };
2403
+ }
2404
+
2405
+ interface TeamModeStateForStop {
2406
+ state: Record<string, unknown>;
2407
+ scope: "session" | "root";
2408
+ }
2409
+
2410
+ function teamStateMatchesThreadForStop(
2411
+ state: Record<string, unknown>,
2412
+ threadId?: string,
2413
+ options: { requireOwnerThread?: boolean } = {},
2414
+ ): boolean {
2415
+ const normalizedThreadId = safeString(threadId).trim();
2416
+ if (!normalizedThreadId) return true;
2417
+
2418
+ const ownerThreadId = safeString(state.owner_codex_thread_id ?? state.thread_id).trim();
2419
+ if (!ownerThreadId) return options.requireOwnerThread !== true;
2420
+ return ownerThreadId === normalizedThreadId;
2421
+ }
2422
+
2423
+ async function readTeamModeStateForStop(
2424
+ cwd: string,
2425
+ stateDir: string,
2426
+ sessionId?: string,
2427
+ threadId?: string,
2428
+ ): Promise<TeamModeStateForStop | null> {
2429
+ const normalizedSessionId = safeString(sessionId).trim();
2430
+ if (!normalizedSessionId) return null;
2431
+
2432
+ const scopedState = await readStopSessionPinnedState("team-state.json", cwd, normalizedSessionId, stateDir);
2433
+ if (scopedState) {
2434
+ return teamStateMatchesThreadForStop(scopedState, threadId)
2435
+ ? { state: scopedState, scope: "session" }
2436
+ : null;
2437
+ }
2438
+
2439
+ const rootState = await readJsonIfExists(join(stateDir, "team-state.json"));
2440
+ if (rootState?.active !== true) return null;
2441
+
2442
+ const teamName = safeString(rootState.team_name).trim();
2443
+ if (!teamName) return null;
2444
+
2445
+ const ownerSessionId = safeString(rootState.session_id).trim();
2446
+ if (!ownerSessionId || ownerSessionId !== normalizedSessionId) return null;
2447
+ if (!teamStateMatchesThreadForStop(rootState, threadId, { requireOwnerThread: true })) return null;
2448
+
2449
+ return { state: rootState, scope: "root" };
2450
+ }
2451
+
2452
+ async function buildTeamStopOutput(cwd: string, sessionId?: string, threadId?: string): Promise<Record<string, unknown> | null> {
2453
+ if (await readCanonicalTerminalRunStateForStop(cwd, sessionId, "team")) {
2454
+ return null;
2455
+ }
2456
+ const teamStateForStop = await readTeamModeStateForStop(cwd, getBaseStateDir(cwd), sessionId, threadId);
2457
+ if (!teamStateForStop || teamStateForStop.state.active !== true) return null;
2458
+ const teamState = teamStateForStop.state;
2459
+ const teamName = safeString(teamState.team_name).trim();
2460
+ if (teamName) {
2461
+ const canonicalTeamDir = join(resolveCanonicalTeamStateRoot(cwd), "team", teamName);
2462
+ if (!existsSync(canonicalTeamDir)) {
2463
+ return null;
2464
+ }
2465
+ }
2466
+ const coarsePhase = teamState.current_phase;
2467
+ const canonicalPhaseState = teamName ? await readTeamPhase(teamName, cwd) : null;
2468
+ if (teamStateForStop.scope === "root" && !canonicalPhaseState) return null;
2469
+ const canonicalPhase = canonicalPhaseState?.current_phase ?? coarsePhase;
2470
+ if (!isNonTerminalPhase(canonicalPhase)) return null;
2471
+ return buildTeamStopOutputForPhase(teamName, formatPhase(canonicalPhase));
2472
+ }
2473
+
2474
+ function buildTeamStopReason(teamName: string, phase: string): string {
2475
+ const teamContext = teamName ? ` (${teamName})` : "";
2476
+ return `OMX team pipeline is still active${teamContext} at phase ${phase}; continue coordinating until the team reaches a terminal phase. If system-generated worker auto-checkpoint commits exist, rewrite them into Lore-format final commits before merge/finalization.`;
2477
+ }
2478
+
2479
+ function buildTeamStopOutputForPhase(teamName: string, phase: string): Record<string, unknown> {
2480
+ return {
2481
+ decision: "block",
2482
+ reason: buildTeamStopReason(teamName, phase),
2483
+ stopReason: `team_${phase}`,
2484
+ systemMessage: `OMX team pipeline is still active at phase ${phase}.`,
2485
+ };
2486
+ }
2487
+
2488
+ function extractStableFinalRecommendationSummary(message: string): string {
2489
+ for (const pattern of STABLE_FINAL_RECOMMENDATION_PATTERNS) {
2490
+ const match = pattern.exec(message);
2491
+ if (!match) continue;
2492
+ const summary = match[0]?.trim().replace(/\s+/g, " ");
2493
+ if (!summary) continue;
2494
+ return /[.!?]$/.test(summary) ? summary : `${summary}.`;
2495
+ }
2496
+ return "";
2497
+ }
2498
+
2499
+ function buildStableFinalRecommendationStopSignature(
2500
+ payload: CodexHookPayload,
2501
+ teamName: string,
2502
+ summary: string,
2503
+ ): string {
2504
+ const sessionId = readPayloadSessionId(payload) || "no-session";
2505
+ const threadId = readPayloadThreadId(payload) || "no-thread";
2506
+ const normalizedSummary = normalizeAutoNudgeSignatureText(summary) || summary.toLowerCase();
2507
+ return ["release-readiness-finalize", sessionId, threadId, teamName, normalizedSummary].join("|");
2508
+ }
2509
+
2510
+ function hasReleaseReadinessMode(payload: CodexHookPayload): boolean {
2511
+ const mode = safeString(payload.mode).trim().toLowerCase();
2512
+ return mode === "release-readiness";
2513
+ }
2514
+
2515
+ async function hasReleaseReadinessStopMarker(
2516
+ cwd: string,
2517
+ stateDir: string,
2518
+ sessionId: string,
2519
+ teamName: string,
2520
+ ): Promise<boolean> {
2521
+ if (!sessionId) return false;
2522
+
2523
+ const markerState = await readStopSessionPinnedState("release-readiness-state.json", cwd, sessionId, stateDir);
2524
+ if (markerState?.active !== true || markerState.stable_final_recommendation_emitted !== true) {
2525
+ return false;
2526
+ }
2527
+
2528
+ const markerTeamName = safeString(markerState.team_name).trim();
2529
+ if (markerTeamName && markerTeamName !== teamName) return false;
2530
+
2531
+ const markerSessionId = safeString(markerState.session_id).trim();
2532
+ if (markerSessionId && markerSessionId !== sessionId) return false;
2533
+
2534
+ return true;
2535
+ }
2536
+
2537
+ function readPayloadSessionId(payload: CodexHookPayload): string {
2538
+ return safeString(payload.session_id ?? payload.sessionId).trim();
2539
+ }
2540
+
2541
+ function readPayloadThreadId(payload: CodexHookPayload): string {
2542
+ return safeString(payload.owner_codex_thread_id ?? payload.thread_id ?? payload.threadId).trim();
2543
+ }
2544
+
2545
+ function readPayloadTurnId(payload: CodexHookPayload): string {
2546
+ return safeString(payload.turn_id ?? payload.turnId).trim();
2547
+ }
2548
+
2549
+ async function resolveInternalSessionIdForPayload(
2550
+ cwd: string,
2551
+ payloadSessionId: string,
2552
+ stateDir?: string,
2553
+ ): Promise<string> {
2554
+ const currentSession = stateDir
2555
+ ? await readUsableSessionStateFromStateDir(cwd, stateDir)
2556
+ : await readUsableSessionState(cwd);
2557
+ const canonicalSessionId = safeString(currentSession?.session_id).trim();
2558
+ if (!canonicalSessionId) return payloadSessionId;
2559
+
2560
+ const nativeSessionId = safeString(currentSession?.native_session_id).trim();
2561
+ if (!payloadSessionId) return canonicalSessionId;
2562
+ if (payloadSessionId === canonicalSessionId) return canonicalSessionId;
2563
+ if (nativeSessionId && payloadSessionId === nativeSessionId) return canonicalSessionId;
2564
+ return payloadSessionId;
2565
+ }
2566
+
2567
+ async function readUsableSessionStateFromStateDir(
2568
+ cwd: string,
2569
+ stateDir: string,
2570
+ ): Promise<SessionState | null> {
2571
+ const sessionPath = join(stateDir, "session.json");
2572
+ if (!existsSync(sessionPath)) return null;
2573
+
2574
+ try {
2575
+ const content = await readFile(sessionPath, "utf-8");
2576
+ const state = JSON.parse(content) as SessionState;
2577
+ return isSessionStateUsable(state, cwd) ? state : null;
2578
+ } catch {
2579
+ return null;
2580
+ }
2581
+ }
2582
+
2583
+ async function readStopSessionPinnedState(
2584
+ fileName: string,
2585
+ cwd: string,
2586
+ sessionId: string,
2587
+ stateDir?: string,
2588
+ ): Promise<Record<string, unknown> | null> {
2589
+ const statePath = stateDir && sessionId
2590
+ ? join(stateDir, "sessions", sessionId, fileName)
2591
+ : getStateFilePath(fileName, cwd, sessionId || undefined);
2592
+ return readJsonIfExists(statePath);
2593
+ }
2594
+
2595
+ const DEEP_INTERVIEW_ALLOWED_WRITE_PREFIXES = [
2596
+ ".omx/context",
2597
+ ".omx/interviews",
2598
+ ".omx/specs",
2599
+ ".omx/state",
2600
+ ] as const;
2601
+
2602
+ const RALPLAN_ALLOWED_WRITE_PREFIXES = [
2603
+ ".omx/context",
2604
+ ".omx/plans",
2605
+ ".omx/specs",
2606
+ ".omx/state",
2607
+ ] as const;
2608
+
2609
+ const PLANNING_MODE_IMPLEMENTATION_TOOL_NAMES = new Set([
2610
+ "Write",
2611
+ "Edit",
2612
+ "MultiEdit",
2613
+ "NotebookEdit",
2614
+ "apply_patch",
2615
+ "ApplyPatch",
2616
+ ]);
2617
+
2618
+ const DEEP_INTERVIEW_IMPLEMENTATION_TOOL_NAMES = PLANNING_MODE_IMPLEMENTATION_TOOL_NAMES;
2619
+
2620
+ const RALPLAN_EXECUTION_HANDOFF_SKILLS = new Set([
2621
+ // Autopilot is intentionally excluded: it supervises planning phases such as
2622
+ // ralplan/replan and is not by itself an execution authorization.
2623
+ "autoresearch",
2624
+ "ralph",
2625
+ "team",
2626
+ "ultragoal",
2627
+ "ultrawork",
2628
+ "ultraqa",
2629
+ ]);
2630
+
2631
+ function isActiveDeepInterviewPhase(state: Record<string, unknown> | null): boolean {
2632
+ if (!state || state.active !== true) return false;
2633
+ const mode = safeString(state.mode).trim();
2634
+ if (mode && mode !== "deep-interview") return false;
2635
+ const phase = safeString(state.current_phase ?? state.currentPhase).trim().toLowerCase();
2636
+ if (phase && (TERMINAL_MODE_PHASES.has(phase) || phase === "completing")) return false;
2637
+ return true;
2638
+ }
2639
+
2640
+ function isActiveRalplanPhase(state: Record<string, unknown> | null): boolean {
2641
+ if (!state || state.active !== true) return false;
2642
+ const mode = safeString(state.mode).trim();
2643
+ if (mode && mode !== "ralplan") return false;
2644
+ const phase = safeString(state.current_phase ?? state.currentPhase).trim().toLowerCase();
2645
+ if (phase && (TERMINAL_MODE_PHASES.has(phase) || phase === "completing")) return false;
2646
+ return true;
2647
+ }
2648
+
2649
+ function isAutopilotRalplanLikePhase(phase: string): boolean {
2650
+ return normalizeAutopilotPhase(phase) === "ralplan";
2651
+ }
2652
+
2653
+ function canAutopilotSkillMirrorSupplyRalplanPhase(phase: string): boolean {
2654
+ return phase === "" || normalizeAutopilotPhase(phase) === "ralplan";
2655
+ }
2656
+
2657
+ function hasExplicitExecutionHandoffSkill(
2658
+ state: SkillActiveStateLike | null,
2659
+ sessionId: string,
2660
+ threadId: string,
2661
+ ): boolean {
2662
+ return listActiveSkills(state ?? {}).some((entry) => (
2663
+ RALPLAN_EXECUTION_HANDOFF_SKILLS.has(entry.skill)
2664
+ && matchesSkillStopContext(entry, state ?? {}, sessionId, threadId)
2665
+ ));
2666
+ }
2667
+
2668
+ function isAllowedPlanningArtifactPath(
2669
+ cwd: string,
2670
+ rawPath: string,
2671
+ allowedPrefixes: readonly string[],
2672
+ ): boolean {
2673
+ const trimmed = rawPath.trim().replace(/^['"]|['"]$/g, "");
2674
+ if (!trimmed || trimmed.includes("\0")) return false;
2675
+ let relativePath: string;
2676
+ try {
2677
+ const absolute = resolve(cwd, trimmed);
2678
+ relativePath = relative(cwd, absolute).replace(/\\/g, "/");
2679
+ } catch {
2680
+ return false;
2681
+ }
2682
+ if (!relativePath || relativePath.startsWith("..") || relativePath.startsWith("/")) return false;
2683
+ return allowedPrefixes.some((prefix) => (
2684
+ relativePath === prefix || relativePath.startsWith(`${prefix}/`)
2685
+ ));
2686
+ }
2687
+
2688
+ function isAllowedDeepInterviewArtifactPath(cwd: string, rawPath: string): boolean {
2689
+ return isAllowedPlanningArtifactPath(cwd, rawPath, DEEP_INTERVIEW_ALLOWED_WRITE_PREFIXES);
2690
+ }
2691
+
2692
+ function isAllowedRalplanArtifactPath(cwd: string, rawPath: string): boolean {
2693
+ return isAllowedPlanningArtifactPath(cwd, rawPath, RALPLAN_ALLOWED_WRITE_PREFIXES);
2694
+ }
2695
+
2696
+ function readPreToolUseCommand(payload: CodexHookPayload): string {
2697
+ const toolInput = safeObject(payload.tool_input);
2698
+ return safeString(toolInput.command).trim();
2699
+ }
2700
+
2701
+ function readPreToolUsePathCandidates(payload: CodexHookPayload): string[] {
2702
+ const input = safeObject(payload.tool_input);
2703
+ const candidates = [
2704
+ input.file_path,
2705
+ input.filePath,
2706
+ input.path,
2707
+ input.target_path,
2708
+ input.targetPath,
2709
+ ];
2710
+ return candidates.map((candidate) => safeString(candidate).trim()).filter(Boolean);
2711
+ }
2712
+
2713
+ const APPLY_PATCH_TOOL_NAMES = new Set(["apply_patch", "ApplyPatch"]);
2714
+
2715
+ function isApplyPatchToolName(toolName: string): boolean {
2716
+ return APPLY_PATCH_TOOL_NAMES.has(toolName);
2717
+ }
2718
+
2719
+ function readApplyPatchText(payload: CodexHookPayload): string {
2720
+ const input = safeObject(payload.tool_input);
2721
+ for (const key of ["input", "patch", "content", "text", "command"]) {
2722
+ const value = safeString(input[key]).trim();
2723
+ if (value) return value;
2724
+ }
2725
+ return "";
2726
+ }
2727
+
2728
+ function extractApplyPatchTargetPaths(patchText: string): string[] {
2729
+ if (!patchText) return [];
2730
+ const paths: string[] = [];
2731
+ for (const match of patchText.matchAll(/^\s*\*\*\*\s+(?:Add|Update|Delete)\s+File:\s*(.+?)\s*$/gm)) {
2732
+ const candidate = safeString(match[1]).trim();
2733
+ if (candidate) paths.push(candidate);
2734
+ }
2735
+ for (const match of patchText.matchAll(/^\s*\*\*\*\s+Move\s+to:\s*(.+?)\s*$/gm)) {
2736
+ const candidate = safeString(match[1]).trim();
2737
+ if (candidate) paths.push(candidate);
2738
+ }
2739
+ return paths;
2740
+ }
2741
+
2742
+ function collectImplementationToolPathCandidates(
2743
+ payload: CodexHookPayload,
2744
+ toolName: string,
2745
+ structuredCandidates: string[],
2746
+ ): string[] {
2747
+ if (!isApplyPatchToolName(toolName)) return structuredCandidates;
2748
+ return [...structuredCandidates, ...extractApplyPatchTargetPaths(readApplyPatchText(payload))];
2749
+ }
2750
+
2751
+ function isNullDeviceRedirectTarget(target: string): boolean {
2752
+ const normalized = target.trim().replace(/^['"]|['"]$/g, "").toLowerCase();
2753
+ return normalized === "/dev/null" || normalized === "nul";
2754
+ }
2755
+
2756
+ function extractDeepInterviewCommandRedirectTargets(command: string): string[] {
2757
+ const targets: string[] = [];
2758
+ for (const match of command.matchAll(/(?:^|[^>])>{1,2}\s*(["']?)([^\s&|;<>]+)\1/g)) {
2759
+ const candidate = safeString(match[2]).trim();
2760
+ if (candidate && !isNullDeviceRedirectTarget(candidate)) targets.push(candidate);
2761
+ }
2762
+ return targets;
2763
+ }
2764
+
2765
+ function commandHasDeepInterviewWriteIntent(command: string): boolean {
2766
+ return /\bapply_patch\b/.test(command)
2767
+ || extractDeepInterviewCommandRedirectTargets(command).length > 0
2768
+ || /\btee\s+(?:-a\s+)?[^\s&|;]+/.test(command)
2769
+ || /\bsed\s+(?:[^\n;&|]*\s)?-i(?:\b|['"])/.test(command)
2770
+ || /\b(?:python3?|node|perl|ruby)\b[\s\S]{0,260}\b(?:writeFileSync|writeFile|write_text|open\([^)]*["']w|File\.write|Path\()/.test(command)
2771
+ || /\b(?:git\s+(?:checkout|switch|restore|reset|apply|am|merge|rebase)|npm\s+(?:install|i|ci)|pnpm\s+(?:install|i)|yarn\s+(?:install|add))\b/.test(command);
2772
+ }
2773
+
2774
+ function extractDeepInterviewCommandWriteTargets(command: string): string[] {
2775
+ const targets = extractDeepInterviewCommandRedirectTargets(command);
2776
+ for (const match of command.matchAll(/\btee\s+(?:-a\s+)?(["']?)([^\s&|;<>]+)\1/g)) {
2777
+ const candidate = safeString(match[2]).trim();
2778
+ if (candidate) targets.push(candidate);
2779
+ }
2780
+ return targets;
2781
+ }
2782
+
2783
+ function isAllowedDeepInterviewBashWrite(cwd: string, command: string): boolean {
2784
+ if (!commandHasDeepInterviewWriteIntent(command)) return true;
2785
+ if (/\bomx\s+(?:state\s+(?:write|read|clear)|question)\b/.test(command)) return true;
2786
+ const targets = extractDeepInterviewCommandWriteTargets(command);
2787
+ return targets.length > 0 && targets.every((target) => isAllowedDeepInterviewArtifactPath(cwd, target));
2788
+ }
2789
+
2790
+ async function readActiveDeepInterviewStateForPreToolUse(
2791
+ cwd: string,
2792
+ stateDir: string,
2793
+ sessionId: string,
2794
+ threadId: string,
2795
+ ): Promise<Record<string, unknown> | null> {
2796
+ const canonicalState = sessionId
2797
+ ? await readVisibleSkillActiveStateForStateDir(stateDir, sessionId)
2798
+ : await readSkillActiveState(join(stateDir, SKILL_ACTIVE_STATE_FILE));
2799
+ if (!canonicalState) return null;
2800
+
2801
+ const modeState = sessionId
2802
+ ? await readStopSessionPinnedState("deep-interview-state.json", cwd, sessionId, stateDir)
2803
+ : await readJsonIfExists(join(stateDir, "deep-interview-state.json"));
2804
+ if (isActiveDeepInterviewPhase(modeState) && modeState && modeStateMatchesSkillStopContext(modeState, cwd, sessionId)) {
2805
+ const hasActiveDeepInterviewSkill = listActiveSkills(canonicalState).some((entry) => (
2806
+ entry.skill === "deep-interview"
2807
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
2808
+ ));
2809
+ if (hasActiveDeepInterviewSkill) return modeState;
2810
+ }
2811
+
2812
+ const autopilotState = sessionId
2813
+ ? await readStopSessionPinnedState("autopilot-state.json", cwd, sessionId, stateDir)
2814
+ : await readJsonIfExists(join(stateDir, "autopilot-state.json"));
2815
+ if (!autopilotState || autopilotState.active !== true) return null;
2816
+ const autopilotMode = safeString(autopilotState.mode).trim();
2817
+ if (autopilotMode && autopilotMode !== "autopilot") return null;
2818
+ if (!modeStateMatchesSkillStopContext(autopilotState, cwd, sessionId)) return null;
2819
+ const terminalAutopilotRunState = await readCanonicalTerminalRunStateForStop(cwd, sessionId, "autopilot");
2820
+ if (terminalAutopilotRunState) return null;
2821
+
2822
+ const autopilotStatePhase = safeString(autopilotState.current_phase ?? autopilotState.currentPhase).trim().toLowerCase();
2823
+ const autopilotIsDeepInterview = normalizeAutopilotPhase(autopilotStatePhase) === "deep-interview";
2824
+ const hasDeepInterviewScopedAutopilotSkill = listActiveSkills(canonicalState).some((entry) => (
2825
+ entry.skill === "autopilot"
2826
+ && normalizeAutopilotPhase(safeString(entry.phase).trim().toLowerCase()) === "deep-interview"
2827
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
2828
+ ));
2829
+ const hasActiveAutopilotSkill = listActiveSkills(canonicalState).some((entry) => (
2830
+ entry.skill === "autopilot"
2831
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
2832
+ ));
2833
+ if (!hasActiveAutopilotSkill) return null;
2834
+ if (!autopilotIsDeepInterview && !hasDeepInterviewScopedAutopilotSkill) return null;
2835
+ return autopilotState;
2836
+ }
2837
+
2838
+ async function readActiveRalplanStateForPreToolUse(
2839
+ cwd: string,
2840
+ stateDir: string,
2841
+ sessionId: string,
2842
+ threadId: string,
2843
+ ): Promise<Record<string, unknown> | null> {
2844
+ const modeState = sessionId
2845
+ ? await readStopSessionPinnedState("ralplan-state.json", cwd, sessionId, stateDir)
2846
+ : await readJsonIfExists(join(stateDir, "ralplan-state.json"));
2847
+ const canonicalState = sessionId
2848
+ ? await readVisibleSkillActiveStateForStateDir(stateDir, sessionId)
2849
+ : await readSkillActiveState(join(stateDir, SKILL_ACTIVE_STATE_FILE));
2850
+ if (isActiveRalplanPhase(modeState) && modeState && modeStateMatchesSkillStopContext(modeState, cwd, sessionId)) {
2851
+ if (hasExplicitExecutionHandoffSkill(canonicalState, sessionId, threadId)) return null;
2852
+ if (!canonicalState) return null;
2853
+ const hasActiveRalplanSkill = listActiveSkills(canonicalState).some((entry) => (
2854
+ entry.skill === "ralplan"
2855
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
2856
+ ));
2857
+ if (hasActiveRalplanSkill) return modeState;
2858
+ }
2859
+
2860
+ const autopilotState = sessionId
2861
+ ? await readStopSessionPinnedState("autopilot-state.json", cwd, sessionId, stateDir)
2862
+ : await readJsonIfExists(join(stateDir, "autopilot-state.json"));
2863
+ if (!autopilotState || autopilotState.active !== true) return null;
2864
+ const autopilotMode = safeString(autopilotState.mode).trim();
2865
+ if (autopilotMode && autopilotMode !== "autopilot") return null;
2866
+ if (!modeStateMatchesSkillStopContext(autopilotState, cwd, sessionId)) return null;
2867
+ const terminalAutopilotRunState = await readCanonicalTerminalRunStateForStop(cwd, sessionId, "autopilot");
2868
+ if (terminalAutopilotRunState) return null;
2869
+ if (!canonicalState) return null;
2870
+ const hasActiveAutopilotSkill = listActiveSkills(canonicalState).some((entry) => (
2871
+ entry.skill === "autopilot"
2872
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
2873
+ ));
2874
+ if (!hasActiveAutopilotSkill) return null;
2875
+ const autopilotStatePhase = safeString(autopilotState.current_phase ?? autopilotState.currentPhase).trim().toLowerCase();
2876
+ if (!canAutopilotSkillMirrorSupplyRalplanPhase(autopilotStatePhase)) return null;
2877
+ const hasRalplanScopedAutopilotSkill = listActiveSkills(canonicalState).some((entry) => (
2878
+ entry.skill === "autopilot"
2879
+ && isAutopilotRalplanLikePhase(safeString(entry.phase).trim().toLowerCase())
2880
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
2881
+ ));
2882
+ if (!isAutopilotRalplanLikePhase(autopilotStatePhase) && !hasRalplanScopedAutopilotSkill) return null;
2883
+ return hasActiveAutopilotSkill ? autopilotState : null;
2884
+ }
2885
+
2886
+ function isAllowedRalplanBashWrite(cwd: string, command: string): boolean {
2887
+ if (!commandHasDeepInterviewWriteIntent(command)) return true;
2888
+ if (/\bomx\s+(?:state\s+(?:write|read|clear)|question)\b/.test(command)) return true;
2889
+ const targets = extractDeepInterviewCommandWriteTargets(command);
2890
+ return targets.length > 0 && targets.every((target) => isAllowedRalplanArtifactPath(cwd, target));
2891
+ }
2892
+
2893
+ async function buildRalplanPreToolUseBoundaryOutput(
2894
+ payload: CodexHookPayload,
2895
+ cwd: string,
2896
+ stateDir: string,
2897
+ resolvedSessionId?: string,
2898
+ ): Promise<Record<string, unknown> | null> {
2899
+ const sessionId = safeString(resolvedSessionId ?? readPayloadSessionId(payload)).trim();
2900
+ const threadId = readPayloadThreadId(payload);
2901
+ const activeState = await readActiveRalplanStateForPreToolUse(cwd, stateDir, sessionId, threadId);
2902
+ if (!activeState) return null;
2903
+
2904
+ const toolName = safeString(payload.tool_name).trim();
2905
+ const command = readPreToolUseCommand(payload);
2906
+ const pathCandidates = readPreToolUsePathCandidates(payload);
2907
+ let blocked = false;
2908
+ let blockedDetail = "implementation/write tools are blocked until an explicit execution handoff workflow is activated";
2909
+
2910
+ if (toolName === "Bash") {
2911
+ blocked = !isAllowedRalplanBashWrite(cwd, command);
2912
+ if (blocked) {
2913
+ const targets = extractDeepInterviewCommandWriteTargets(command);
2914
+ const blockedTarget = targets.find((target) => !isAllowedRalplanArtifactPath(cwd, target));
2915
+ blockedDetail = blockedTarget
2916
+ ? `write target ${blockedTarget} is not under allowed planning artifact paths (${RALPLAN_ALLOWED_WRITE_PREFIXES.join(", ")})`
2917
+ : "Bash write intent did not identify an allowed planning artifact path";
2918
+ }
2919
+ } else if (PLANNING_MODE_IMPLEMENTATION_TOOL_NAMES.has(toolName)) {
2920
+ if (pathCandidates.length === 0) {
2921
+ blocked = true;
2922
+ blockedDetail = `${toolName} did not include a file path; only planning artifact paths are allowed`;
2923
+ } else {
2924
+ const blockedPath = pathCandidates.find((candidate) => !isAllowedRalplanArtifactPath(cwd, candidate));
2925
+ blocked = blockedPath !== undefined;
2926
+ if (blockedPath !== undefined) {
2927
+ blockedDetail = `path ${blockedPath} is not under allowed planning artifact paths (${RALPLAN_ALLOWED_WRITE_PREFIXES.join(", ")})`;
2928
+ }
2929
+ }
2930
+ }
2931
+
2932
+ if (!blocked) return null;
2933
+
2934
+ const phase = formatPhase(activeState.current_phase ?? activeState.currentPhase, "planning");
2935
+ const activeMode = safeString(activeState.mode).trim().toLowerCase();
2936
+ const planningModeLabel = activeMode === "autopilot" ? "Autopilot planning" : "Ralplan";
2937
+ const planningModeDescription = activeMode === "autopilot"
2938
+ ? "Autopilot is supervising a planning phase"
2939
+ : "Ralplan is consensus-planning mode";
2940
+ return {
2941
+ decision: "block",
2942
+ reason: `${planningModeLabel} is active (phase: ${phase}); implementation/write tools are blocked until an explicit execution handoff workflow is activated; ${blockedDetail}.`,
2943
+ hookSpecificOutput: {
2944
+ hookEventName: "PreToolUse",
2945
+ additionalContext:
2946
+ `${planningModeDescription}. `
2947
+ + "Write only planning artifacts under `.omx/context/`, `.omx/plans/`, `.omx/specs/`, or required `.omx/state/` files. "
2948
+ + "Do not edit implementation files or run implementation-focused writes from planning phases. "
2949
+ + `To execute, first process an explicit handoff such as ${formatExecutionHandoffList(cwd)}, which must emit terminal planning state before implementation begins.`,
2950
+ },
2951
+ };
2952
+ }
2953
+
2954
+ async function buildDeepInterviewPreToolUseBoundaryOutput(
2955
+ payload: CodexHookPayload,
2956
+ cwd: string,
2957
+ stateDir: string,
2958
+ resolvedSessionId?: string,
2959
+ ): Promise<Record<string, unknown> | null> {
2960
+ const sessionId = safeString(resolvedSessionId ?? readPayloadSessionId(payload)).trim();
2961
+ const threadId = readPayloadThreadId(payload);
2962
+ const activeState = await readActiveDeepInterviewStateForPreToolUse(cwd, stateDir, sessionId, threadId);
2963
+ if (!activeState) return null;
2964
+
2965
+ const toolName = safeString(payload.tool_name).trim();
2966
+ const command = readPreToolUseCommand(payload);
2967
+ const pathCandidates = readPreToolUsePathCandidates(payload);
2968
+ let blocked = false;
2969
+
2970
+ if (toolName === "Bash") {
2971
+ blocked = !isAllowedDeepInterviewBashWrite(cwd, command);
2972
+ } else if (DEEP_INTERVIEW_IMPLEMENTATION_TOOL_NAMES.has(toolName)) {
2973
+ const candidates = collectImplementationToolPathCandidates(payload, toolName, pathCandidates);
2974
+ blocked = candidates.length === 0
2975
+ || !candidates.every((candidate) => isAllowedDeepInterviewArtifactPath(cwd, candidate));
2976
+ }
2977
+
2978
+ if (!blocked) return null;
2979
+
2980
+ const phase = formatPhase(activeState.current_phase ?? activeState.currentPhase, "planning");
2981
+ return {
2982
+ decision: "block",
2983
+ reason: `Deep-interview is active (phase: ${phase}); implementation/write tools are blocked until an explicit handoff workflow is activated.`,
2984
+ hookSpecificOutput: {
2985
+ hookEventName: "PreToolUse",
2986
+ additionalContext:
2987
+ `Deep-interview is requirements/spec mode. Treat detailed user answers as interview/spec material, not implicit implementation authorization. You may write only deep-interview artifacts under \`.omx/context/\`, \`.omx/interviews/\`, \`.omx/specs/\`, or required \`.omx/state/\` files. To implement, first ask for or process an explicit transition such as \`$ralplan\`, \`$autopilot\`, ${formatExecutionHandoffList(cwd)}.`,
2988
+ },
2989
+ };
2990
+ }
2991
+
2992
+ function matchesSkillStopContext(
2993
+ entry: { session_id?: string; thread_id?: string },
2994
+ state: { session_id?: string; thread_id?: string },
2995
+ sessionId: string,
2996
+ threadId: string,
2997
+ ): boolean {
2998
+ const entrySessionId = safeString(entry.session_id ?? state.session_id).trim();
2999
+ const entryThreadId = safeString(entry.thread_id ?? state.thread_id).trim();
3000
+ if (sessionId && entrySessionId && entrySessionId !== sessionId) return false;
3001
+ if (sessionId && !entrySessionId && threadId && entryThreadId && entryThreadId !== threadId) {
3002
+ return false;
3003
+ }
3004
+ return true;
3005
+ }
3006
+
3007
+ function modeStateMatchesSkillStopContext(
3008
+ state: Record<string, unknown>,
3009
+ cwd: string,
3010
+ sessionId: string,
3011
+ ): boolean {
3012
+ const stateSessionId = safeString(
3013
+ state.owner_omx_session_id
3014
+ ?? state.session_id
3015
+ ?? state.codex_session_id
3016
+ ?? state.owner_codex_session_id,
3017
+ ).trim();
3018
+ if (sessionId && stateSessionId && stateSessionId !== sessionId) return false;
3019
+
3020
+ const stateCwd = safeString(
3021
+ state.cwd
3022
+ ?? state.workingDirectory
3023
+ ?? state.working_directory
3024
+ ?? state.project_path,
3025
+ ).trim();
3026
+ if (stateCwd) {
3027
+ try {
3028
+ if (resolve(stateCwd) !== resolve(cwd)) return false;
3029
+ } catch {
3030
+ return false;
3031
+ }
3032
+ }
3033
+
3034
+ return true;
3035
+ }
3036
+
3037
+ async function readBlockingSkillForStop(
3038
+ cwd: string,
3039
+ stateDir: string,
3040
+ sessionId: string,
3041
+ threadId: string,
3042
+ requiredSkill?: string,
3043
+ ): Promise<{ skill: string; phase: string; latestPlanPath?: string; planningComplete?: boolean; runOutcome?: string } | null> {
3044
+ const canonicalState = await readVisibleSkillActiveStateForStateDir(stateDir, sessionId);
3045
+ const visibleEntries = canonicalState ? listActiveSkills(canonicalState) : [];
3046
+ const candidateSkills = requiredSkill
3047
+ ? [requiredSkill]
3048
+ : [...SKILL_STOP_BLOCKERS];
3049
+
3050
+ for (const skill of candidateSkills) {
3051
+ const terminalRunState = await readCanonicalTerminalRunStateForStop(cwd, sessionId, skill);
3052
+ if (terminalRunState) continue;
3053
+
3054
+ const modeState = await readStopSessionPinnedState(`${skill}-state.json`, cwd, sessionId, stateDir);
3055
+ if (!modeState || modeState.active !== true) continue;
3056
+ if (!modeStateMatchesSkillStopContext(modeState, cwd, sessionId)) continue;
3057
+
3058
+ const modeSnapshot = getRunContinuationSnapshot(modeState);
3059
+ if (modeSnapshot?.terminal === true) continue;
3060
+
3061
+ if (await shouldIgnoreSessionSkillBlockerForCanonicalInactiveRoot(
3062
+ cwd,
3063
+ stateDir,
3064
+ skill,
3065
+ sessionId,
3066
+ threadId,
3067
+ )) continue;
3068
+
3069
+ const phase = formatPhase(
3070
+ modeState.current_phase,
3071
+ formatPhase(
3072
+ visibleEntries.find((entry) => entry.skill === skill)?.phase,
3073
+ "planning",
3074
+ ),
3075
+ );
3076
+ if (TERMINAL_MODE_PHASES.has(phase.toLowerCase()) || phase === "completing") {
3077
+ continue;
3078
+ }
3079
+
3080
+ if (!canonicalState) {
3081
+ return {
3082
+ skill,
3083
+ phase,
3084
+ latestPlanPath: safeString(modeState.latest_plan_path ?? modeState.latestPlanPath).trim() || undefined,
3085
+ planningComplete: modeState.planning_complete === true || modeState.planningComplete === true,
3086
+ runOutcome: safeString(modeState.run_outcome ?? modeState.outcome).trim() || undefined,
3087
+ };
3088
+ }
3089
+
3090
+ const blocker = visibleEntries.find((entry) => (
3091
+ entry.skill === skill
3092
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
3093
+ ));
3094
+ if (!blocker) continue;
3095
+
3096
+ return {
3097
+ skill,
3098
+ phase: formatPhase(modeState.current_phase ?? blocker.phase ?? canonicalState.phase, "planning"),
3099
+ latestPlanPath: safeString(modeState.latest_plan_path ?? modeState.latestPlanPath).trim() || undefined,
3100
+ planningComplete: modeState.planning_complete === true || modeState.planningComplete === true,
3101
+ runOutcome: safeString(modeState.run_outcome ?? modeState.outcome).trim() || undefined,
3102
+ };
3103
+ }
3104
+
3105
+ return null;
3106
+ }
3107
+
3108
+ function uniqueNonEmpty(values: Array<string | undefined>): string[] {
3109
+ return [...new Set(values.map((value) => safeString(value).trim()).filter(Boolean))];
3110
+ }
3111
+
3112
+ function isTerminalOrInactiveModeState(state: Record<string, unknown> | null): boolean {
3113
+ if (!state) return true;
3114
+ if (state.active !== true) return true;
3115
+ if (getRunContinuationSnapshot(state)?.terminal === true) return true;
3116
+ const phase = safeString(state.current_phase ?? state.currentPhase).trim().toLowerCase();
3117
+ return phase !== "" && TERMINAL_MODE_PHASES.has(phase);
3118
+ }
3119
+
3120
+ function rootSkillStateHasNoActiveSkillForStopContext(
3121
+ rootState: SkillActiveStateLike | null,
3122
+ skill: string,
3123
+ sessionId: string,
3124
+ threadId: string,
3125
+ ): boolean {
3126
+ if (!rootState) return false;
3127
+ return !listActiveSkills(rootState).some((entry) => (
3128
+ entry.skill === skill
3129
+ && matchesSkillStopContext(entry, rootState, sessionId, threadId)
3130
+ ));
3131
+ }
3132
+
3133
+ function rootModeStateIsCanonicalForStopContext(
3134
+ state: Record<string, unknown>,
3135
+ cwd: string,
3136
+ sessionId: string,
3137
+ threadId: string,
3138
+ ): boolean {
3139
+ if (!modeStateMatchesSkillStopContext(state, cwd, sessionId)) return false;
3140
+
3141
+ const stateSessionId = safeString(
3142
+ state.owner_omx_session_id
3143
+ ?? state.session_id
3144
+ ?? state.codex_session_id
3145
+ ?? state.owner_codex_session_id,
3146
+ ).trim();
3147
+ if (sessionId && stateSessionId !== sessionId) return false;
3148
+
3149
+ const stateThreadId = safeString(state.owner_codex_thread_id ?? state.thread_id).trim();
3150
+ if (threadId && stateThreadId && stateThreadId !== threadId) return false;
3151
+
3152
+ return true;
3153
+ }
3154
+
3155
+ async function shouldIgnoreSessionSkillBlockerForCanonicalInactiveRoot(
3156
+ cwd: string,
3157
+ stateDir: string,
3158
+ skill: string,
3159
+ sessionId: string,
3160
+ threadId: string,
3161
+ ): Promise<boolean> {
3162
+ const rootModeState = await readJsonIfExists(join(stateDir, `${skill}-state.json`));
3163
+ if (!rootModeState) return false;
3164
+ if (!rootModeStateIsCanonicalForStopContext(rootModeState, cwd, sessionId, threadId)) return false;
3165
+ if (!isTerminalOrInactiveModeState(rootModeState)) return false;
3166
+
3167
+ const { rootPath } = getSkillActiveStatePathsForStateDir(stateDir);
3168
+ const rootSkillState = await readSkillActiveState(rootPath);
3169
+ return rootSkillStateHasNoActiveSkillForStopContext(rootSkillState, skill, sessionId, threadId);
3170
+ }
3171
+
3172
+ async function readSessionScopedModeStateForRootSkill(
3173
+ cwd: string,
3174
+ stateDir: string,
3175
+ skill: string,
3176
+ sessionIds: string[],
3177
+ ): Promise<Record<string, unknown> | null> {
3178
+ for (const sessionId of sessionIds) {
3179
+ const state = await readStopSessionPinnedState(`${skill}-state.json`, cwd, sessionId, stateDir);
3180
+ if (state) return state;
3181
+ }
3182
+ return null;
3183
+ }
3184
+
3185
+ async function reconcileStaleRootSkillActiveStateForStop(
3186
+ cwd: string,
3187
+ stateDir: string,
3188
+ sessionId: string,
3189
+ ): Promise<void> {
3190
+ const { rootPath } = getSkillActiveStatePathsForStateDir(stateDir);
3191
+ const rootState = await readSkillActiveState(rootPath);
3192
+ if (!rootState?.active) return;
3193
+
3194
+ const initializedSessionId = extractSessionIdFromInitializedStatePath(rootState.initialized_state_path);
3195
+ const rootSessionIds = uniqueNonEmpty([
3196
+ sessionId,
3197
+ safeString(rootState.session_id),
3198
+ initializedSessionId,
3199
+ ...listActiveSkills(rootState).map((entry) => safeString(entry.session_id)),
3200
+ ]);
3201
+ if (rootSessionIds.length === 0) return;
3202
+
3203
+ const activeEntries = listActiveSkills(rootState);
3204
+ let changed = false;
3205
+ const keptEntries = [];
3206
+ for (const entry of activeEntries) {
3207
+ const skill = safeString(entry.skill).trim();
3208
+ if (!skill) continue;
3209
+ const entrySessionId = safeString(entry.session_id).trim();
3210
+ const candidateSessionIds = uniqueNonEmpty([
3211
+ entrySessionId,
3212
+ sessionId,
3213
+ initializedSessionId,
3214
+ safeString(rootState.session_id),
3215
+ ]);
3216
+ const modeState = await readSessionScopedModeStateForRootSkill(cwd, stateDir, skill, candidateSessionIds);
3217
+ if (isTerminalOrInactiveModeState(modeState)) {
3218
+ changed = true;
3219
+ continue;
3220
+ }
3221
+ keptEntries.push(entry);
3222
+ }
3223
+
3224
+ if (!changed) return;
3225
+
3226
+ const nowIso = new Date().toISOString();
3227
+ const nextRoot: SkillActiveStateLike = {
3228
+ ...rootState,
3229
+ active: keptEntries.length > 0,
3230
+ skill: keptEntries[0]?.skill ?? safeString(rootState.skill).trim(),
3231
+ phase: keptEntries[0]?.phase ?? safeString(rootState.phase).trim(),
3232
+ updated_at: nowIso,
3233
+ active_skills: keptEntries,
3234
+ reconciled_at: nowIso,
3235
+ reconciliation_reason: "stop_hook_session_state_terminal",
3236
+ };
3237
+ if (keptEntries.length === 0) {
3238
+ nextRoot.phase = "inactive";
3239
+ }
3240
+ await writeFile(rootPath, JSON.stringify(nextRoot, null, 2));
3241
+ }
3242
+
3243
+ function buildRalplanContinuationStatus(
3244
+ blocker: { phase: string; latestPlanPath?: string; planningComplete?: boolean; runOutcome?: string },
3245
+ activeSubagentCount: number,
3246
+ cwd: string,
3247
+ ): { reason: string; systemMessage: string; stopReasonSuffix: string } {
3248
+ const phase = blocker.phase || "planning";
3249
+ const artifact = blocker.latestPlanPath
3250
+ ? ` Artifact: ${blocker.latestPlanPath}.`
3251
+ : " Artifact: use the latest `.omx/plans/` ralplan artifact if present.";
3252
+
3253
+ if (activeSubagentCount > 0) {
3254
+ return {
3255
+ reason:
3256
+ `Status: waiting — ralplan is waiting for ${activeSubagentCount} active native subagent thread(s) to finish (phase: ${phase}). Do not stop silently; wait for the subagent result, then continue from the current ralplan artifact and proceed to the next planning/review step.${artifact}`,
3257
+ stopReasonSuffix: "waiting_subagent",
3258
+ systemMessage:
3259
+ `OMX ralplan status: waiting for ${activeSubagentCount} active native subagent thread(s) at phase ${phase}; after they finish, continue from the current ralplan artifact and state the next status explicitly.`,
3260
+ };
3261
+ }
3262
+
3263
+ const normalizedPhase = phase.toLowerCase();
3264
+ const normalizedOutcome = (blocker.runOutcome ?? "").toLowerCase();
3265
+ const waitingForInput =
3266
+ normalizedOutcome === "blocked_on_user"
3267
+ || normalizedPhase.includes("blocked")
3268
+ || normalizedPhase.includes("input")
3269
+ || normalizedPhase.includes("question");
3270
+
3271
+ if (waitingForInput) {
3272
+ return {
3273
+ reason:
3274
+ `Status: waiting_for_input — ralplan is paused for required user/operator input (phase: ${phase}). Ask the missing question or present the review choice explicitly before stopping.${artifact}`,
3275
+ stopReasonSuffix: "waiting_input",
3276
+ systemMessage:
3277
+ `OMX ralplan status: waiting for input at phase ${phase}; ask the required question or present the explicit review choice before stopping.`,
3278
+ };
3279
+ }
3280
+
3281
+ const completeHint = blocker.planningComplete
3282
+ ? ` The planning artifacts are present; if consensus is approved, emit terminal ralplan complete/approved handoff state and stop planning. Implementation must wait for an explicit ${formatExecutionHandoffList(cwd).replaceAll("`", "")} handoff.`
3283
+ : "";
3284
+
3285
+ return {
3286
+ reason:
3287
+ `Status: continue_from_artifact — ralplan is still active (phase: ${phase}) and has not emitted a terminal complete/paused/waiting status. Continue from the current ralplan artifact, resolve any review ambiguity conservatively or ask the user if needed, and proceed to the next planning/review step before stopping; do not begin implementation from ralplan.${artifact}${completeHint}`,
3288
+ stopReasonSuffix: "continue_artifact",
3289
+ systemMessage:
3290
+ `OMX ralplan status: continue_from_artifact at phase ${phase}; continue from the current ralplan artifact and finish by stating whether ralplan is complete, paused for review, waiting for input, or still continuing; do not begin implementation from ralplan.`,
3291
+ };
3292
+ }
3293
+
3294
+ async function readStopAutoNudgePhase(
3295
+ cwd: string,
3296
+ stateDir: string,
3297
+ sessionId: string,
3298
+ threadId: string,
3299
+ ): Promise<string> {
3300
+ const normalizedSessionId = sessionId.trim();
3301
+ if (normalizedSessionId) {
3302
+ const scopedModeState = await readStopSessionPinnedState("deep-interview-state.json", cwd, normalizedSessionId, stateDir);
3303
+ if (
3304
+ scopedModeState?.active === true
3305
+ && safeString(scopedModeState.current_phase).trim().toLowerCase() === "intent-first"
3306
+ ) {
3307
+ return "planning";
3308
+ }
3309
+ } else {
3310
+ const rootModeState = await readJsonIfExists(join(stateDir, "deep-interview-state.json"));
3311
+ if (
3312
+ rootModeState?.active === true
3313
+ && safeString(rootModeState.current_phase).trim().toLowerCase() === "intent-first"
3314
+ ) {
3315
+ return "planning";
3316
+ }
3317
+ }
3318
+
3319
+ if (!normalizedSessionId) return "";
3320
+
3321
+ const canonicalState = await readVisibleSkillActiveStateForStateDir(stateDir, normalizedSessionId);
3322
+ const visibleEntries = canonicalState ? listActiveSkills(canonicalState) : [];
3323
+ const deepInterview = visibleEntries.find((entry) => (
3324
+ entry.skill === "deep-interview"
3325
+ && matchesSkillStopContext(entry, canonicalState ?? {}, normalizedSessionId, threadId)
3326
+ ));
3327
+ if (!deepInterview) return "";
3328
+
3329
+ const modeState = await readStopSessionPinnedState("deep-interview-state.json", cwd, normalizedSessionId, stateDir);
3330
+ if (!modeState || modeState.active !== true) return "";
3331
+
3332
+ const modePhase = safeString(modeState.current_phase).trim().toLowerCase();
3333
+ return modePhase === "intent-first" ? "planning" : "";
3334
+ }
3335
+
3336
+ async function buildDeepInterviewQuestionStopOutput(
3337
+ cwd: string,
3338
+ stateDir: string,
3339
+ sessionId: string,
3340
+ threadId: string,
3341
+ ): Promise<{ output: Record<string, unknown>; obligationId: string } | null> {
3342
+ await reconcileDeepInterviewQuestionEnforcementFromAnsweredRecords(cwd, sessionId);
3343
+ if (await readAutopilotDeepInterviewQuestionWaitState(cwd, sessionId)) {
3344
+ return null;
3345
+ }
3346
+ const modeState = await readStopSessionPinnedState("deep-interview-state.json", cwd, sessionId, stateDir);
3347
+ if (!modeState) return null;
3348
+
3349
+ const questionEnforcement = safeObject(modeState.question_enforcement);
3350
+ const hasPendingQuestionObligation = isPendingDeepInterviewQuestionEnforcement(questionEnforcement);
3351
+ if (modeState.active !== true && !hasPendingQuestionObligation) return null;
3352
+
3353
+ const phase = formatPhase(modeState.current_phase, "planning");
3354
+ if (TERMINAL_MODE_PHASES.has(phase.toLowerCase()) || phase === "completing") {
3355
+ return null;
3356
+ }
3357
+
3358
+ const canonicalState = await readVisibleSkillActiveStateForStateDir(stateDir, sessionId);
3359
+ if (canonicalState) {
3360
+ const blocker = listActiveSkills(canonicalState).find((entry) => (
3361
+ entry.skill === "deep-interview"
3362
+ && matchesSkillStopContext(entry, canonicalState, sessionId, threadId)
3363
+ ));
3364
+ if (!blocker) return null;
3365
+ }
3366
+
3367
+ if (!hasPendingQuestionObligation) {
3368
+ return null;
3369
+ }
3370
+
3371
+ const obligationId = safeString(questionEnforcement.obligation_id).trim();
3372
+ if (!obligationId) return null;
3373
+
3374
+ const systemMessage =
3375
+ `OMX deep-interview is still active (phase: ${phase}) and requires a structured question via omx question before stopping; read the returned answers[] JSON before continuing.`;
3376
+
3377
+ return {
3378
+ obligationId,
3379
+ output: {
3380
+ decision: "block",
3381
+ reason:
3382
+ `Deep interview is still active (phase: ${phase}) and has a pending structured question obligation; use \`omx question\` before stopping.`,
3383
+ stopReason: "deep_interview_question_required",
3384
+ systemMessage,
3385
+ },
3386
+ };
3387
+ }
3388
+
3389
+ function resolveRepeatableStopSessionId(
3390
+ payload: CodexHookPayload,
3391
+ canonicalSessionId?: string,
3392
+ ): string {
3393
+ const inheritedSessionId = safeString(process.env.OMX_SESSION_ID || process.env.CODEX_SESSION_ID).trim();
3394
+ return canonicalSessionId?.trim() || readPayloadSessionId(payload) || inheritedSessionId || "";
3395
+ }
3396
+
3397
+ function isStateLevelStopSignatureKind(kind: string): boolean {
3398
+ return kind === "team-worker-stop" || kind === "team-stop";
3399
+ }
3400
+
3401
+ function buildRepeatableStopSignature(
3402
+ payload: CodexHookPayload,
3403
+ kind: string,
3404
+ detail = "",
3405
+ canonicalSessionId?: string,
3406
+ ): string {
3407
+ const sessionId = resolveRepeatableStopSessionId(payload, canonicalSessionId) || "no-session";
3408
+ const threadId = readPayloadThreadId(payload) || "no-thread";
3409
+ const normalizedDetail = normalizeAutoNudgeSignatureText(detail) || safeString(detail).trim().toLowerCase();
3410
+ if (isStateLevelStopSignatureKind(kind)) {
3411
+ return [kind, sessionId, threadId, normalizedDetail || "no-detail"].join("|");
3412
+ }
3413
+ const turnId = readPayloadTurnId(payload);
3414
+ const transcriptPath = safeString(payload.transcript_path ?? payload.transcriptPath).trim() || "no-transcript";
3415
+ const lastAssistantMessage = normalizeAutoNudgeSignatureText(
3416
+ payload.last_assistant_message ?? payload.lastAssistantMessage,
3417
+ ) || "no-message";
3418
+ if (turnId) {
3419
+ return [
3420
+ kind,
3421
+ sessionId,
3422
+ threadId,
3423
+ turnId,
3424
+ transcriptPath,
3425
+ lastAssistantMessage,
3426
+ normalizedDetail || "no-detail",
3427
+ ].join("|");
3428
+ }
3429
+ return [
3430
+ kind,
3431
+ sessionId,
3432
+ threadId,
3433
+ transcriptPath,
3434
+ lastAssistantMessage,
3435
+ normalizedDetail || "no-detail",
3436
+ ].join("|");
3437
+ }
3438
+
3439
+ function formatStopStatePath(cwd: string, statePath: string): string {
3440
+ const relativePath = relative(cwd, statePath);
3441
+ if (!relativePath || relativePath.startsWith("..")) return statePath;
3442
+ return relativePath.replace(/\\/g, "/");
3443
+ }
3444
+
3445
+ function readNativeStopSessionKey(
3446
+ payload: CodexHookPayload,
3447
+ canonicalSessionId?: string,
3448
+ ): string {
3449
+ return resolveRepeatableStopSessionId(payload, canonicalSessionId) || readPayloadThreadId(payload) || "global";
3450
+ }
3451
+
3452
+ function readPreviousNativeStopSignature(
3453
+ state: Record<string, unknown>,
3454
+ sessionKey: string,
3455
+ ): string {
3456
+ const sessions = safeObject(state.sessions);
3457
+ const sessionState = safeObject(sessions[sessionKey]);
3458
+ return safeString(sessionState.last_signature).trim();
3459
+ }
3460
+
3461
+ function parseBoundedPositiveInteger(value: unknown, fallback: number): number {
3462
+ const parsed = Math.trunc(Number(value));
3463
+ return Number.isFinite(parsed) && parsed > 0 ? parsed : fallback;
3464
+ }
3465
+
3466
+ function parseBoundedNonNegativeInteger(value: unknown, fallback: number): number {
3467
+ const parsed = Math.trunc(Number(value));
3468
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback;
3469
+ }
3470
+
3471
+ function normalizeOrdinaryStopProgressText(value: unknown): string {
3472
+ return safeString(value)
3473
+ .replace(/\s+/g, " ")
3474
+ .trim()
3475
+ .toLowerCase();
3476
+ }
3477
+
3478
+ function shortenOrdinaryStopProgressText(value: string): string {
3479
+ const trimmed = value.replace(/\s+/g, " ").trim();
3480
+ if (trimmed.length <= ORDINARY_STOP_NO_PROGRESS_MAX_MESSAGE_LENGTH) return trimmed;
3481
+ return `${trimmed.slice(0, ORDINARY_STOP_NO_PROGRESS_MAX_MESSAGE_LENGTH - 1).trimEnd()}…`;
3482
+ }
3483
+
3484
+ function ordinaryStopProgressFingerprint(payload: CodexHookPayload): string {
3485
+ const message = normalizeOrdinaryStopProgressText(
3486
+ payload.last_assistant_message ?? payload.lastAssistantMessage,
3487
+ ) || "<no assistant message>";
3488
+ const mode = normalizeOrdinaryStopProgressText(payload.mode) || "ordinary";
3489
+ return `${mode}|${message}`;
3490
+ }
3491
+
3492
+ function readIsoTimeMs(value: unknown): number | null {
3493
+ const parsed = Date.parse(safeString(value));
3494
+ return Number.isFinite(parsed) ? parsed : null;
3495
+ }
3496
+
3497
+ async function maybeBuildOrdinaryStopNoProgressOutput(
3498
+ payload: CodexHookPayload,
3499
+ stateDir: string,
3500
+ canonicalSessionId?: string,
3501
+ ): Promise<Record<string, unknown> | null> {
3502
+ const lastAssistantMessage = safeString(
3503
+ payload.last_assistant_message ?? payload.lastAssistantMessage,
3504
+ ).trim();
3505
+ if (!lastAssistantMessage) return null;
3506
+
3507
+ const statePath = join(stateDir, NATIVE_STOP_STATE_FILE);
3508
+ const state = await readJsonIfExists(statePath) ?? {};
3509
+ const sessions = safeObject(state.sessions);
3510
+ const sessionKey = readNativeStopSessionKey(payload, canonicalSessionId);
3511
+ const sessionState = safeObject(sessions[sessionKey]);
3512
+ const previousGuard = safeObject(sessionState.ordinary_no_progress_guard);
3513
+ const fingerprint = ordinaryStopProgressFingerprint(payload);
3514
+ const nowIso = new Date().toISOString();
3515
+ const previousFingerprint = safeString(previousGuard.fingerprint).trim();
3516
+ const sameFingerprint = previousFingerprint === fingerprint;
3517
+ const firstSeenAt = sameFingerprint
3518
+ ? safeString(previousGuard.first_seen_at).trim() || nowIso
3519
+ : nowIso;
3520
+ const repeatCount = sameFingerprint
3521
+ ? parseBoundedPositiveInteger(previousGuard.repeat_count, 1) + 1
3522
+ : 1;
3523
+
3524
+ sessions[sessionKey] = {
3525
+ ...sessionState,
3526
+ ordinary_no_progress_guard: {
3527
+ fingerprint,
3528
+ first_seen_at: firstSeenAt,
3529
+ last_seen_at: nowIso,
3530
+ repeat_count: repeatCount,
3531
+ last_turn_id: readPayloadTurnId(payload) || null,
3532
+ last_thread_id: readPayloadThreadId(payload) || null,
3533
+ },
3534
+ };
3535
+ await mkdir(stateDir, { recursive: true });
3536
+ await writeFile(statePath, JSON.stringify({ ...state, sessions }, null, 2));
3537
+
3538
+ const maxRepeats = parseBoundedPositiveInteger(
3539
+ process.env.OMX_NATIVE_STOP_NO_PROGRESS_MAX_REPEATS,
3540
+ ORDINARY_STOP_NO_PROGRESS_DEFAULT_MAX_REPEATS,
3541
+ );
3542
+ const idleMs = parseBoundedNonNegativeInteger(
3543
+ process.env.OMX_NATIVE_STOP_NO_PROGRESS_IDLE_MS,
3544
+ ORDINARY_STOP_NO_PROGRESS_DEFAULT_IDLE_MS,
3545
+ );
3546
+ const firstSeenMs = readIsoTimeMs(firstSeenAt) ?? Date.now();
3547
+ const elapsedMs = Math.max(0, Date.now() - firstSeenMs);
3548
+ if (repeatCount < maxRepeats || elapsedMs < idleMs) return null;
3549
+
3550
+ const message = shortenOrdinaryStopProgressText(
3551
+ safeString(payload.last_assistant_message ?? payload.lastAssistantMessage) || "no assistant message recorded",
3552
+ );
3553
+ const elapsedSeconds = Math.round(elapsedMs / 1000);
3554
+ const diagnostic =
3555
+ `OMX ordinary task no-progress guard triggered after ${repeatCount} repeated Stop-hook pass(es) over ~${elapsedSeconds}s with unchanged status: "${message}". ` +
3556
+ "Emit a concise diagnostic summary now: state the last concrete progress/evidence, whether the task is complete, blocked, failed, or needs missing information, and stop instead of continuing a vague working loop.";
3557
+
3558
+ return {
3559
+ decision: "block",
3560
+ reason: diagnostic,
3561
+ stopReason: "ordinary_task_no_progress_guard",
3562
+ systemMessage: diagnostic,
3563
+ };
3564
+ }
3565
+
3566
+ async function persistNativeStopSignature(
3567
+ stateDir: string,
3568
+ payload: CodexHookPayload,
3569
+ signature: string,
3570
+ canonicalSessionId?: string,
3571
+ ): Promise<void> {
3572
+ if (!signature) return;
3573
+ const statePath = join(stateDir, NATIVE_STOP_STATE_FILE);
3574
+ const state = await readJsonIfExists(statePath) ?? {};
3575
+ const sessions = safeObject(state.sessions);
3576
+ const sessionKey = readNativeStopSessionKey(payload, canonicalSessionId);
3577
+ sessions[sessionKey] = {
3578
+ ...safeObject(sessions[sessionKey]),
3579
+ last_signature: signature,
3580
+ updated_at: new Date().toISOString(),
3581
+ };
3582
+ await mkdir(stateDir, { recursive: true });
3583
+ await writeFile(statePath, JSON.stringify({
3584
+ ...state,
3585
+ sessions,
3586
+ }, null, 2));
3587
+ }
3588
+
3589
+ async function maybeReturnRepeatableStopOutput(
3590
+ payload: CodexHookPayload,
3591
+ stateDir: string,
3592
+ signature: string,
3593
+ output: Record<string, unknown> | null,
3594
+ canonicalSessionId?: string,
3595
+ options: { allowRepeatDuringStopHook?: boolean } = {},
3596
+ ): Promise<Record<string, unknown> | null> {
3597
+ if (!output) return null;
3598
+ const stopHookActive = payload.stop_hook_active === true || payload.stopHookActive === true;
3599
+ if (stopHookActive && options.allowRepeatDuringStopHook !== true) {
3600
+ const state = await readJsonIfExists(join(stateDir, NATIVE_STOP_STATE_FILE)) ?? {};
3601
+ const previousSignature = readPreviousNativeStopSignature(
3602
+ state,
3603
+ readNativeStopSessionKey(payload, canonicalSessionId),
3604
+ );
3605
+ if (!signature || previousSignature === signature) {
3606
+ return null;
3607
+ }
3608
+ }
3609
+ await persistNativeStopSignature(stateDir, payload, signature, canonicalSessionId);
3610
+ return output;
3611
+ }
3612
+
3613
+ async function returnPersistentStopBlock(
3614
+ payload: CodexHookPayload,
3615
+ stateDir: string,
3616
+ signatureKind: string,
3617
+ signatureValue: string,
3618
+ output: Record<string, unknown> | null,
3619
+ canonicalSessionId?: string,
3620
+ options: { allowRepeatDuringStopHook?: boolean } = { allowRepeatDuringStopHook: true },
3621
+ ): Promise<Record<string, unknown> | null> {
3622
+ return await maybeReturnRepeatableStopOutput(
3623
+ payload,
3624
+ stateDir,
3625
+ buildRepeatableStopSignature(payload, signatureKind, signatureValue, canonicalSessionId),
3626
+ output,
3627
+ canonicalSessionId,
3628
+ options,
3629
+ );
3630
+ }
3631
+
3632
+ async function findCanonicalActiveTeamForSession(
3633
+ cwd: string,
3634
+ sessionId: string,
3635
+ threadId?: string,
3636
+ ): Promise<{ teamName: string; phase: string } | null> {
3637
+ if (!sessionId.trim()) return null;
3638
+ const teamsRoot = join(resolveCanonicalTeamStateRoot(cwd), "team");
3639
+ if (!existsSync(teamsRoot)) return null;
3640
+
3641
+ const entries = await readdir(teamsRoot, { withFileTypes: true }).catch(() => []);
3642
+ for (const entry of entries) {
3643
+ if (!entry.isDirectory()) continue;
3644
+ const teamName = entry.name.trim();
3645
+ if (!teamName) continue;
3646
+
3647
+ const [manifest, phaseState] = await Promise.all([
3648
+ readTeamManifestV2(teamName, cwd),
3649
+ readTeamPhase(teamName, cwd),
3650
+ ]);
3651
+ if (!manifest || !phaseState) continue;
3652
+ const ownerSessionId = (manifest.leader?.session_id ?? "").trim();
3653
+ if (ownerSessionId && ownerSessionId !== sessionId.trim()) continue;
3654
+ if (!teamStateMatchesThreadForStop(manifest.leader as unknown as Record<string, unknown>, threadId)) continue;
3655
+ if (!isNonTerminalPhase(phaseState.current_phase)) continue;
3656
+
3657
+ return {
3658
+ teamName,
3659
+ phase: formatPhase(phaseState.current_phase),
3660
+ };
3661
+ }
3662
+
3663
+ return null;
3664
+ }
3665
+
3666
+ async function resolveActiveTeamNameForStop(
3667
+ cwd: string,
3668
+ stateDir: string,
3669
+ sessionId: string,
3670
+ threadId?: string,
3671
+ ): Promise<string> {
3672
+ const directState = await readTeamModeStateForStop(cwd, stateDir, sessionId, threadId);
3673
+ const directTeamName = safeString(directState?.state.team_name).trim();
3674
+ if (directState?.state.active === true && directTeamName) return directTeamName;
3675
+
3676
+ const canonicalTeam = await findCanonicalActiveTeamForSession(cwd, sessionId, threadId);
3677
+ return canonicalTeam?.teamName ?? "";
3678
+ }
3679
+
3680
+ async function maybeBuildReleaseReadinessFinalizeStopOutput(
3681
+ payload: CodexHookPayload,
3682
+ cwd: string,
3683
+ stateDir: string,
3684
+ sessionId: string,
3685
+ ): Promise<{ matched: boolean; output: Record<string, unknown> | null }> {
3686
+ if (!sessionId) return { matched: false, output: null };
3687
+
3688
+ const teamName = await resolveActiveTeamNameForStop(cwd, stateDir, sessionId, readPayloadThreadId(payload));
3689
+ if (!teamName) return { matched: false, output: null };
3690
+
3691
+ const explicitReleaseReadinessContext =
3692
+ hasReleaseReadinessMode(payload)
3693
+ || await hasReleaseReadinessStopMarker(cwd, stateDir, sessionId, teamName);
3694
+ if (!explicitReleaseReadinessContext) {
3695
+ return { matched: false, output: null };
3696
+ }
3697
+
3698
+ const summary = extractStableFinalRecommendationSummary(
3699
+ safeString(payload.last_assistant_message ?? payload.lastAssistantMessage),
3700
+ );
3701
+ if (!summary) return { matched: false, output: null };
3702
+
3703
+ const leaderAttention = await readTeamLeaderAttention(teamName, cwd);
3704
+ if (
3705
+ !leaderAttention
3706
+ || leaderAttention.leader_decision_state !== "done_waiting_on_leader"
3707
+ || leaderAttention.work_remaining !== false
3708
+ ) {
3709
+ return { matched: false, output: null };
3710
+ }
3711
+
3712
+ const signature = buildStableFinalRecommendationStopSignature(payload, teamName, summary);
3713
+ const output = await maybeReturnRepeatableStopOutput(
3714
+ payload,
3715
+ stateDir,
3716
+ signature,
3717
+ {
3718
+ decision: "block",
3719
+ reason:
3720
+ `Stable final recommendation already reached with no active worker tasks. Emit exactly one concise final decision summary aligned to "${summary}" with no filler or residual acknowledgements (for example "yes"), then stop.`,
3721
+ stopReason: "release_readiness_auto_finalize",
3722
+ systemMessage: RELEASE_READINESS_FINALIZE_SYSTEM_MESSAGE,
3723
+ },
3724
+ sessionId,
3725
+ );
3726
+ return { matched: true, output };
3727
+ }
3728
+
3729
+ async function buildSkillStopOutput(
3730
+ cwd: string,
3731
+ stateDir: string,
3732
+ sessionId: string,
3733
+ threadId: string,
3734
+ ): Promise<Record<string, unknown> | null> {
3735
+ const blocker = await readBlockingSkillForStop(cwd, stateDir, sessionId, threadId);
3736
+ if (!blocker) return null;
3737
+
3738
+ const subagentSummary = await readSubagentSessionSummary(cwd, sessionId).catch(() => null);
3739
+ const activeSubagentCount = subagentSummary?.activeSubagentThreadIds.length ?? 0;
3740
+
3741
+ if (blocker.skill === "ralplan") {
3742
+ const status = buildRalplanContinuationStatus(blocker, activeSubagentCount, cwd);
3743
+ return {
3744
+ decision: "block",
3745
+ reason: status.reason,
3746
+ stopReason: `skill_${blocker.skill}_${blocker.phase}_${status.stopReasonSuffix}`,
3747
+ systemMessage: status.systemMessage,
3748
+ };
3749
+ }
3750
+
3751
+ if (activeSubagentCount > 0) {
3752
+ return null;
3753
+ }
3754
+
3755
+ return {
3756
+ decision: "block",
3757
+ reason: `OMX skill ${blocker.skill} is still active (phase: ${blocker.phase}); continue until the current ${blocker.skill} workflow reaches a terminal state.`,
3758
+ stopReason: `skill_${blocker.skill}_${blocker.phase}`,
3759
+ systemMessage: `OMX skill ${blocker.skill} is still active (phase: ${blocker.phase}).`,
3760
+ };
3761
+ }
3762
+
3763
+ async function findActiveTeamForTransportFailure(
3764
+ cwd: string,
3765
+ sessionId: string,
3766
+ ): Promise<{ teamName: string; phase: string } | null> {
3767
+ const teamState = await readModeStateForSession("team", sessionId, cwd);
3768
+ if (teamState?.active === true) {
3769
+ const teamName = safeString(teamState.team_name).trim();
3770
+ const coarsePhase = formatPhase(teamState.current_phase);
3771
+ if (teamName) {
3772
+ const canonicalPhase = (await readTeamPhase(teamName, cwd))?.current_phase ?? coarsePhase;
3773
+ if (isNonTerminalPhase(canonicalPhase)) {
3774
+ return { teamName, phase: formatPhase(canonicalPhase) };
3775
+ }
3776
+ }
3777
+ }
3778
+
3779
+ return await findCanonicalActiveTeamForSession(cwd, sessionId);
3780
+ }
3781
+
3782
+ async function markTeamTransportFailure(
3783
+ cwd: string,
3784
+ payload: CodexHookPayload,
3785
+ ): Promise<void> {
3786
+ const canonicalSessionId = await resolveInternalSessionIdForPayload(cwd, readPayloadSessionId(payload));
3787
+ const activeTeam = await findActiveTeamForTransportFailure(cwd, canonicalSessionId);
3788
+ if (!activeTeam) return;
3789
+
3790
+ const nowIso = new Date().toISOString();
3791
+ const existingPhase = await readTeamPhase(activeTeam.teamName, cwd);
3792
+ const currentPhase = existingPhase?.current_phase ?? activeTeam.phase;
3793
+ if (!isNonTerminalPhase(currentPhase)) return;
3794
+
3795
+ await writeTeamPhase(
3796
+ activeTeam.teamName,
3797
+ {
3798
+ current_phase: "failed",
3799
+ max_fix_attempts: existingPhase?.max_fix_attempts ?? 3,
3800
+ current_fix_attempt: existingPhase?.current_fix_attempt ?? 0,
3801
+ transitions: [
3802
+ ...(existingPhase?.transitions ?? []),
3803
+ {
3804
+ from: formatPhase(currentPhase),
3805
+ to: "failed",
3806
+ at: nowIso,
3807
+ reason: "mcp_transport_dead",
3808
+ },
3809
+ ],
3810
+ updated_at: nowIso,
3811
+ },
3812
+ cwd,
3813
+ );
3814
+
3815
+ const existingAttention = await readTeamLeaderAttention(activeTeam.teamName, cwd);
3816
+ await writeTeamLeaderAttention(
3817
+ activeTeam.teamName,
3818
+ {
3819
+ team_name: activeTeam.teamName,
3820
+ updated_at: nowIso,
3821
+ source: "notify_hook",
3822
+ leader_decision_state: existingAttention?.leader_decision_state ?? "still_actionable",
3823
+ leader_attention_pending: true,
3824
+ leader_attention_reason: "mcp_transport_dead",
3825
+ attention_reasons: [
3826
+ ...new Set([...(existingAttention?.attention_reasons ?? []), "mcp_transport_dead"]),
3827
+ ],
3828
+ leader_stale: existingAttention?.leader_stale ?? false,
3829
+ leader_session_active: existingAttention?.leader_session_active ?? true,
3830
+ leader_session_id: existingAttention?.leader_session_id ?? (canonicalSessionId || null),
3831
+ leader_session_stopped_at: existingAttention?.leader_session_stopped_at ?? null,
3832
+ unread_leader_message_count: existingAttention?.unread_leader_message_count ?? 0,
3833
+ work_remaining: existingAttention?.work_remaining ?? true,
3834
+ stalled_for_ms: existingAttention?.stalled_for_ms ?? null,
3835
+ },
3836
+ cwd,
3837
+ );
3838
+
3839
+ await appendTeamEvent(
3840
+ activeTeam.teamName,
3841
+ {
3842
+ type: "leader_attention",
3843
+ worker: "leader-fixed",
3844
+ reason: "mcp_transport_dead",
3845
+ metadata: {
3846
+ phase_before: formatPhase(currentPhase),
3847
+ },
3848
+ },
3849
+ cwd,
3850
+ ).catch(() => {});
3851
+
3852
+ try {
3853
+ await updateModeState(
3854
+ "team",
3855
+ {
3856
+ current_phase: "failed",
3857
+ error: "mcp_transport_dead",
3858
+ last_turn_at: nowIso,
3859
+ },
3860
+ cwd,
3861
+ canonicalSessionId || undefined,
3862
+ );
3863
+ } catch {
3864
+ // Canonical team state already carries the preserved failure for coarse-state-missing sessions.
3865
+ }
3866
+ }
3867
+
3868
+ async function buildStopHookOutput(
3869
+ payload: CodexHookPayload,
3870
+ cwd: string,
3871
+ stateDir: string,
3872
+ options: { skipRalphStopBlock?: boolean } = {},
3873
+ ): Promise<Record<string, unknown> | null> {
3874
+ if (isStopExempt(payload)) {
3875
+ return null;
3876
+ }
3877
+
3878
+ const sessionId = readPayloadSessionId(payload);
3879
+ const canonicalSessionId = await resolveInternalSessionIdForPayload(cwd, sessionId);
3880
+ const threadId = readPayloadThreadId(payload);
3881
+ const suppressParentWorkflowStop = shouldSuppressParentWorkflowStopForSideConversation(payload);
3882
+ if (canonicalSessionId) {
3883
+ await reconcileStaleRootSkillActiveStateForStop(cwd, stateDir, canonicalSessionId);
3884
+ }
3885
+ if (suppressParentWorkflowStop) {
3886
+ return null;
3887
+ }
3888
+ const execFollowupOutput = await buildExecFollowupStopOutput(cwd, canonicalSessionId);
3889
+ if (execFollowupOutput) return execFollowupOutput;
3890
+ const ralphOwnerContext = {
3891
+ payloadSessionId: sessionId,
3892
+ threadId,
3893
+ tmuxPaneId: safeString(process.env.TMUX_PANE).trim(),
3894
+ };
3895
+ const ralphCompletionAuditBlock = options.skipRalphStopBlock === true
3896
+ ? null
3897
+ : await readRalphCompletionAuditBlockState(cwd, stateDir, canonicalSessionId, ralphOwnerContext);
3898
+ if (ralphCompletionAuditBlock) {
3899
+ await reopenRalphCompletionAuditBlock(ralphCompletionAuditBlock);
3900
+ const blockingPath = formatStopStatePath(cwd, ralphCompletionAuditBlock.path);
3901
+ const systemMessage = [
3902
+ `OMX Ralph completion audit is missing required evidence (${ralphCompletionAuditBlock.reason}; state: ${blockingPath}).`,
3903
+ "Continue verification and do not report complete yet.",
3904
+ "Record machine-readable completion evidence before stopping:",
3905
+ '- either set "completion_audit" on the Ralph state object, for example: omx state write --input \'{"mode":"ralph","active":false,"current_phase":"complete","completion_audit":{"passed":true,"prompt_to_artifact_checklist":["..."],"verification_evidence":["..."]}}\' --json',
3906
+ "- or set completion_audit_path / completion_audit_evidence_path to a repo-relative JSON file with those same fields.",
3907
+ "Markdown artifacts and flat top-level checklist/evidence fields are not accepted by the Ralph Stop gate.",
3908
+ ].join(" ");
3909
+ return await returnPersistentStopBlock(
3910
+ payload,
3911
+ stateDir,
3912
+ "ralph-completion-audit-stop",
3913
+ `${blockingPath}|${ralphCompletionAuditBlock.reason}`,
3914
+ {
3915
+ decision: "block",
3916
+ reason: systemMessage,
3917
+ stopReason: `ralph_completion_audit_${ralphCompletionAuditBlock.reason}`,
3918
+ systemMessage,
3919
+ },
3920
+ canonicalSessionId,
3921
+ { allowRepeatDuringStopHook: true },
3922
+ );
3923
+ }
3924
+ const ralphState = options.skipRalphStopBlock === true
3925
+ ? null
3926
+ : await readActiveRalphState(cwd, stateDir, canonicalSessionId, ralphOwnerContext);
3927
+ if (!ralphState) {
3928
+ const autoresearchState = await readActiveAutoresearchState(cwd, canonicalSessionId);
3929
+ if (autoresearchState) {
3930
+ const completion = await readAutoresearchCompletionStatus(cwd, canonicalSessionId!.trim());
3931
+ if (!completion.complete) {
3932
+ const currentPhase = safeString(autoresearchState.current_phase ?? autoresearchState.currentPhase).trim() || 'executing';
3933
+ const systemMessage = `OMX autoresearch is still active (phase: ${currentPhase}); continue until validator evidence is complete before stopping.`;
3934
+ return await maybeReturnRepeatableStopOutput(
3935
+ payload,
3936
+ stateDir,
3937
+ buildRepeatableStopSignature(payload, 'autoresearch-stop', `${currentPhase}|${completion.reason}`, canonicalSessionId),
3938
+ {
3939
+ decision: 'block',
3940
+ reason: systemMessage,
3941
+ stopReason: `autoresearch_${currentPhase}`,
3942
+ systemMessage,
3943
+ },
3944
+ canonicalSessionId,
3945
+ { allowRepeatDuringStopHook: true },
3946
+ );
3947
+ }
3948
+ }
3949
+
3950
+ const teamWorkerDecision = await resolveTeamWorkerStopDecision(cwd);
3951
+ if (teamWorkerDecision.kind === "blocked") {
3952
+ return await returnPersistentStopBlock(
3953
+ payload,
3954
+ stateDir,
3955
+ "team-worker-stop",
3956
+ safeString(teamWorkerDecision.output.stopReason),
3957
+ teamWorkerDecision.output,
3958
+ canonicalSessionId,
3959
+ { allowRepeatDuringStopHook: teamWorkerDecision.allowRepeatDuringStopHook },
3960
+ );
3961
+ }
3962
+ if (teamWorkerDecision.kind === "allowed") {
3963
+ try {
3964
+ await maybeNudgeLeaderForAllowedWorkerStop({
3965
+ stateDir: teamWorkerDecision.stateDir,
3966
+ logsDir: join(cwd, ".omx", "logs"),
3967
+ workerContext: teamWorkerDecision.workerContext,
3968
+ });
3969
+ } catch (err) {
3970
+ void err;
3971
+ }
3972
+ return null;
3973
+ }
3974
+
3975
+ const autopilotOutput = await buildModeBasedStopOutput("autopilot", cwd, canonicalSessionId);
3976
+ if (autopilotOutput) {
3977
+ return await returnPersistentStopBlock(
3978
+ payload,
3979
+ stateDir,
3980
+ "autopilot-stop",
3981
+ safeString(autopilotOutput.stopReason),
3982
+ autopilotOutput,
3983
+ canonicalSessionId,
3984
+ { allowRepeatDuringStopHook: false },
3985
+ );
3986
+ }
3987
+
3988
+ const ultraworkOutput = await buildModeBasedStopOutput("ultrawork", cwd, canonicalSessionId);
3989
+ if (ultraworkOutput) {
3990
+ return await returnPersistentStopBlock(
3991
+ payload,
3992
+ stateDir,
3993
+ "ultrawork-stop",
3994
+ safeString(ultraworkOutput.stopReason),
3995
+ ultraworkOutput,
3996
+ canonicalSessionId,
3997
+ { allowRepeatDuringStopHook: false },
3998
+ );
3999
+ }
4000
+
4001
+ const ultraqaOutput = await buildModeBasedStopOutput("ultraqa", cwd, canonicalSessionId);
4002
+ if (ultraqaOutput) {
4003
+ return await returnPersistentStopBlock(
4004
+ payload,
4005
+ stateDir,
4006
+ "ultraqa-stop",
4007
+ safeString(ultraqaOutput.stopReason),
4008
+ ultraqaOutput,
4009
+ canonicalSessionId,
4010
+ );
4011
+ }
4012
+
4013
+ const releaseReadinessFinalizeResult = await maybeBuildReleaseReadinessFinalizeStopOutput(
4014
+ payload,
4015
+ cwd,
4016
+ stateDir,
4017
+ canonicalSessionId,
4018
+ );
4019
+ if (releaseReadinessFinalizeResult.matched) return releaseReadinessFinalizeResult.output;
4020
+
4021
+ const teamOutput = await buildTeamStopOutput(cwd, canonicalSessionId, threadId);
4022
+ if (teamOutput) {
4023
+ return await returnPersistentStopBlock(
4024
+ payload,
4025
+ stateDir,
4026
+ "team-stop",
4027
+ safeString(teamOutput.stopReason),
4028
+ teamOutput,
4029
+ canonicalSessionId,
4030
+ );
4031
+ }
4032
+
4033
+ if (canonicalSessionId) {
4034
+ const deepInterviewQuestionOutput = await buildDeepInterviewQuestionStopOutput(
4035
+ cwd,
4036
+ stateDir,
4037
+ canonicalSessionId,
4038
+ threadId,
4039
+ );
4040
+ if (deepInterviewQuestionOutput) {
4041
+ return await returnPersistentStopBlock(
4042
+ payload,
4043
+ stateDir,
4044
+ "deep-interview-question-stop",
4045
+ deepInterviewQuestionOutput.obligationId,
4046
+ deepInterviewQuestionOutput.output,
4047
+ canonicalSessionId,
4048
+ );
4049
+ }
4050
+
4051
+ const canonicalTeam = await readCanonicalTerminalRunStateForStop(cwd, canonicalSessionId, "team")
4052
+ ? null
4053
+ : await findCanonicalActiveTeamForSession(cwd, canonicalSessionId, threadId);
4054
+ if (canonicalTeam) {
4055
+ const canonicalTeamOutput = buildTeamStopOutputForPhase(
4056
+ canonicalTeam.teamName,
4057
+ canonicalTeam.phase,
4058
+ );
4059
+ const repeatedCanonicalTeamOutput = await returnPersistentStopBlock(
4060
+ payload,
4061
+ stateDir,
4062
+ "team-stop",
4063
+ `${canonicalTeam.teamName}|${canonicalTeam.phase}`,
4064
+ canonicalTeamOutput,
4065
+ canonicalSessionId,
4066
+ );
4067
+ if (repeatedCanonicalTeamOutput) return repeatedCanonicalTeamOutput;
4068
+ }
4069
+
4070
+ const skillOutput = await buildSkillStopOutput(cwd, stateDir, canonicalSessionId, threadId);
4071
+ if (skillOutput) {
4072
+ return await returnPersistentStopBlock(
4073
+ payload,
4074
+ stateDir,
4075
+ "skill-stop",
4076
+ safeString(skillOutput.stopReason),
4077
+ skillOutput,
4078
+ canonicalSessionId,
4079
+ );
4080
+ }
4081
+ }
4082
+
4083
+
4084
+ const lastAssistantMessage = safeString(
4085
+ payload.last_assistant_message ?? payload.lastAssistantMessage,
4086
+ );
4087
+ const goalWorkflowStopOutput = await buildGoalWorkflowReconciliationStopOutput(payload, cwd);
4088
+ if (goalWorkflowStopOutput) {
4089
+ return await returnPersistentStopBlock(
4090
+ payload,
4091
+ stateDir,
4092
+ "goal-workflow-reconciliation-stop",
4093
+ safeString(goalWorkflowStopOutput.stopReason),
4094
+ goalWorkflowStopOutput,
4095
+ canonicalSessionId,
4096
+ { allowRepeatDuringStopHook: true },
4097
+ );
4098
+ }
4099
+ const ordinaryNoProgressOutput = await maybeBuildOrdinaryStopNoProgressOutput(
4100
+ payload,
4101
+ stateDir,
4102
+ canonicalSessionId,
4103
+ );
4104
+ if (ordinaryNoProgressOutput) return ordinaryNoProgressOutput;
4105
+
4106
+ const autoNudgeConfig = await loadAutoNudgeConfig();
4107
+ const autoNudgePhase = await readStopAutoNudgePhase(cwd, stateDir, canonicalSessionId, threadId);
4108
+
4109
+ if (
4110
+ autoNudgeConfig.enabled
4111
+ && detectNativeStopStallPattern(lastAssistantMessage, autoNudgeConfig.patterns, autoNudgePhase)
4112
+ ) {
4113
+ const effectiveResponse = resolveEffectiveAutoNudgeResponse(autoNudgeConfig.response);
4114
+ return await returnPersistentStopBlock(
4115
+ payload,
4116
+ stateDir,
4117
+ "auto-nudge",
4118
+ lastAssistantMessage,
4119
+ {
4120
+ decision: "block",
4121
+ reason: effectiveResponse,
4122
+ stopReason: "auto_nudge",
4123
+ systemMessage:
4124
+ "OMX native Stop detected a stall/permission-style handoff and continued the turn automatically.",
4125
+ },
4126
+ canonicalSessionId,
4127
+ );
4128
+ }
4129
+
4130
+ const sloppyFallbackDiffFindings = findSloppyFallbackDiffFindings(cwd);
4131
+ const sloppyFallbackDiffOutput = buildSloppyFallbackDiffStopOutput(sloppyFallbackDiffFindings);
4132
+ if (sloppyFallbackDiffOutput) {
4133
+ return await returnPersistentStopBlock(
4134
+ payload,
4135
+ stateDir,
4136
+ "sloppy-fallback-diff-stop",
4137
+ JSON.stringify(sloppyFallbackDiffFindings),
4138
+ sloppyFallbackDiffOutput,
4139
+ canonicalSessionId,
4140
+ { allowRepeatDuringStopHook: true },
4141
+ );
4142
+ }
4143
+
4144
+ if (isFinalHandoffDocumentRefreshCandidate(lastAssistantMessage)) {
4145
+ const documentRefreshWarning = evaluateFinalHandoffDocumentRefresh(cwd, lastAssistantMessage);
4146
+ if (documentRefreshWarning) {
4147
+ return await maybeReturnRepeatableStopOutput(
4148
+ payload,
4149
+ stateDir,
4150
+ buildRepeatableStopSignature(
4151
+ payload,
4152
+ "document-refresh-stop",
4153
+ documentRefreshWarning.triggeringPaths.join("|"),
4154
+ canonicalSessionId,
4155
+ ),
4156
+ buildDocumentRefreshAdvisoryOutput(documentRefreshWarning, "Stop"),
4157
+ canonicalSessionId,
4158
+ { allowRepeatDuringStopHook: false },
4159
+ );
4160
+ }
4161
+ }
4162
+
4163
+ return null;
4164
+ }
4165
+
4166
+ const currentPhase = safeString(ralphState.state.current_phase).trim() || "executing";
4167
+ const blockingPath = formatStopStatePath(cwd, ralphState.path);
4168
+ const stopReason = `ralph_${currentPhase}`;
4169
+ const systemMessage =
4170
+ `OMX Ralph is still active (phase: ${currentPhase}; state: ${blockingPath}); continue the task and gather fresh verification evidence before stopping.`;
4171
+
4172
+ return await returnPersistentStopBlock(
4173
+ payload,
4174
+ stateDir,
4175
+ "ralph-stop",
4176
+ currentPhase,
4177
+ {
4178
+ decision: "block",
4179
+ reason: systemMessage,
4180
+ stopReason,
4181
+ systemMessage,
4182
+ },
4183
+ canonicalSessionId,
4184
+ );
4185
+ }
4186
+
4187
+ export async function dispatchCodexNativeHook(
4188
+ payload: CodexHookPayload,
4189
+ options: NativeHookDispatchOptions = {},
4190
+ ): Promise<NativeHookDispatchResult> {
4191
+ const hookEventName = readHookEventName(payload);
4192
+ const cwd = options.cwd ?? (safeString(payload.cwd).trim() || process.cwd());
4193
+ if (hookEventName === "Stop" && !hasNativeStopRuntimeSurface(cwd)) {
4194
+ return {
4195
+ hookEventName,
4196
+ omxEventName: mapCodexHookEventToOmxEvent(hookEventName),
4197
+ skillState: null,
4198
+ outputJson: null,
4199
+ };
4200
+ }
4201
+ // Native hooks must use the same authoritative runtime state root as HUD/MCP
4202
+ // when boxed/team roots are active; do not bypass it with cwd/.omx/state.
4203
+ const stateDir = getBaseStateDir(cwd);
4204
+ if (hookEventName !== "Stop") {
4205
+ await mkdir(stateDir, { recursive: true });
4206
+ }
4207
+
4208
+ const omxEventName = mapCodexHookEventToOmxEvent(hookEventName);
4209
+ let skillState: SkillActiveState | null = null;
4210
+ let triageAdditionalContext: string | null = null;
4211
+ let goalWorkflowAdditionalContext: string | null = null;
4212
+ let ultragoalSteeringAdditionalContext: string | null = null;
4213
+
4214
+ const nativeSessionId = safeString(payload.session_id ?? payload.sessionId).trim();
4215
+ const threadId = safeString(payload.thread_id ?? payload.threadId).trim();
4216
+ const turnId = safeString(payload.turn_id ?? payload.turnId).trim();
4217
+ const currentSessionState = await readUsableSessionState(cwd);
4218
+ let canonicalSessionId = safeString(currentSessionState?.session_id).trim();
4219
+ let resolvedNativeSessionId = nativeSessionId;
4220
+ let skipCanonicalSessionStartContext = false;
4221
+ let isSubagentSessionStart = false;
4222
+
4223
+ if (hookEventName === "SessionStart" && nativeSessionId) {
4224
+ const transcriptPath = safeString(payload.transcript_path ?? payload.transcriptPath).trim();
4225
+ const subagentSessionStart = readNativeSubagentSessionStartMetadata(transcriptPath);
4226
+ if (subagentSessionStart && canonicalSessionId) {
4227
+ isSubagentSessionStart = true;
4228
+ const belongsToCanonicalSession = await nativeSubagentSessionStartBelongsToCanonicalSession(
4229
+ cwd,
4230
+ canonicalSessionId,
4231
+ currentSessionState,
4232
+ subagentSessionStart,
4233
+ );
4234
+ if (belongsToCanonicalSession) {
4235
+ resolvedNativeSessionId = nativeSessionId;
4236
+ await recordNativeSubagentSessionStart(
4237
+ cwd,
4238
+ canonicalSessionId,
4239
+ nativeSessionId,
4240
+ subagentSessionStart,
4241
+ transcriptPath,
4242
+ );
4243
+ } else {
4244
+ skipCanonicalSessionStartContext = true;
4245
+ resolvedNativeSessionId =
4246
+ safeString(currentSessionState?.native_session_id).trim() || nativeSessionId;
4247
+ await recordIgnoredNativeSubagentSessionStart(
4248
+ cwd,
4249
+ canonicalSessionId,
4250
+ nativeSessionId,
4251
+ subagentSessionStart,
4252
+ transcriptPath,
4253
+ );
4254
+ }
4255
+ } else {
4256
+ const sessionState = await reconcileNativeSessionStart(cwd, nativeSessionId, {
4257
+ pid: options.sessionOwnerPid ?? resolveSessionOwnerPid(payload),
4258
+ });
4259
+ canonicalSessionId = safeString(sessionState.session_id).trim();
4260
+ resolvedNativeSessionId = safeString(sessionState.native_session_id).trim() || nativeSessionId;
4261
+ }
4262
+ } else if (!canonicalSessionId) {
4263
+ canonicalSessionId = safeString(currentSessionState?.session_id).trim();
4264
+ }
4265
+
4266
+ if (hookEventName === "Stop") {
4267
+ const inheritedSessionId = safeString(process.env.OMX_SESSION_ID || process.env.CODEX_SESSION_ID).trim();
4268
+ const stopCanonicalSessionId = await resolveInternalSessionIdForPayload(
4269
+ cwd,
4270
+ readPayloadSessionId(payload) || inheritedSessionId,
4271
+ );
4272
+ if (stopCanonicalSessionId) {
4273
+ canonicalSessionId = stopCanonicalSessionId;
4274
+ }
4275
+ if (canonicalSessionId && safeString(currentSessionState?.session_id).trim() === canonicalSessionId) {
4276
+ resolvedNativeSessionId =
4277
+ safeString(currentSessionState?.native_session_id).trim() || resolvedNativeSessionId;
4278
+ }
4279
+ }
4280
+
4281
+ const eventSessionId = canonicalSessionId || nativeSessionId || undefined;
4282
+ const sessionIdForState = canonicalSessionId || nativeSessionId;
4283
+ let outputJson: Record<string, unknown> | null = null;
4284
+ const isSubagentPromptSubmit = hookEventName === "UserPromptSubmit"
4285
+ ? await isNativeSubagentHook(
4286
+ cwd,
4287
+ canonicalSessionId,
4288
+ nativeSessionId,
4289
+ threadId,
4290
+ safeString(currentSessionState?.native_session_id).trim(),
4291
+ )
4292
+ : false;
4293
+ const isSubagentStop = hookEventName === "Stop"
4294
+ ? (await Promise.all(
4295
+ [...new Set([
4296
+ canonicalSessionId,
4297
+ safeString(currentSessionState?.session_id).trim(),
4298
+ ].filter(Boolean))]
4299
+ .map((candidateSessionId) => isNativeSubagentHook(
4300
+ cwd,
4301
+ candidateSessionId,
4302
+ nativeSessionId,
4303
+ threadId,
4304
+ candidateSessionId === safeString(currentSessionState?.session_id).trim()
4305
+ ? safeString(currentSessionState?.native_session_id).trim()
4306
+ : "",
4307
+ )),
4308
+ )).some(Boolean)
4309
+ : false;
4310
+ const suppressNoisySubagentLifecycleDispatch =
4311
+ (isSubagentSessionStart || isSubagentStop)
4312
+ && shouldSuppressSubagentLifecycleHookDispatch();
4313
+
4314
+ if (hookEventName === "UserPromptSubmit") {
4315
+ const prompt = readPromptText(payload);
4316
+ goalWorkflowAdditionalContext = await buildGoalWorkflowReconciliationPromptWarning(cwd, prompt).catch(() => null);
4317
+ ultragoalSteeringAdditionalContext = prompt && !isSubagentPromptSubmit
4318
+ ? await applyUserPromptUltragoalSteering(cwd, prompt).catch((error) => `OMX native UserPromptSubmit rejected bounded .omx/ultragoal steering for G002-cli-and-prompt-submit-bridge: ${error instanceof Error ? error.message : String(error)}`)
4319
+ : null;
4320
+ if (prompt && !isSubagentPromptSubmit) {
4321
+ skillState = buildNativeOutsideTmuxTeamPromptBlockState(
4322
+ prompt,
4323
+ cwd,
4324
+ payload,
4325
+ sessionIdForState,
4326
+ threadId || undefined,
4327
+ turnId || undefined,
4328
+ ) ?? await recordSkillActivation({
4329
+ stateDir,
4330
+ sourceCwd: cwd,
4331
+ text: prompt,
4332
+ sessionId: sessionIdForState,
4333
+ threadId,
4334
+ turnId,
4335
+ });
4336
+ }
4337
+ // --- Triage classifier (advisory-only, non-keyword prompts) ---
4338
+ if (prompt && skillState === null && !isSubagentPromptSubmit) {
4339
+ try {
4340
+ if (readTriageConfig().enabled) {
4341
+ const normalized = prompt.trim().toLowerCase();
4342
+ const previous = readTriageState({ cwd, sessionId: sessionIdForState || null });
4343
+ const suppress = shouldSuppressFollowup({
4344
+ previous,
4345
+ currentPrompt: normalized,
4346
+ currentHasKeyword: false,
4347
+ });
4348
+ if (!suppress) {
4349
+ const decision = triagePrompt(prompt);
4350
+ const nowIso = new Date().toISOString();
4351
+ const effectiveTurnId = turnId || nowIso;
4352
+ if (decision.lane === "HEAVY") {
4353
+ triageAdditionalContext =
4354
+ "OMX native UserPromptSubmit triage detected a multi-step goal with no workflow keyword. This is advisory prompt-routing context only; it did not activate autopilot or initialize workflow state. Prefer the existing autopilot-style workflow if AGENTS.md/runtime conditions allow it, unless newer user context narrows or opts out.";
4355
+ const newState: TriageStateFile = {
4356
+ version: 1,
4357
+ last_triage: {
4358
+ lane: "HEAVY",
4359
+ destination: "autopilot",
4360
+ reason: decision.reason,
4361
+ prompt_signature: promptSignature(normalized),
4362
+ turn_id: effectiveTurnId,
4363
+ created_at: nowIso,
4364
+ },
4365
+ suppress_followup: true,
4366
+ };
4367
+ writeTriageState({ cwd, sessionId: sessionIdForState || null, state: newState });
4368
+ } else if (decision.lane === "LIGHT") {
4369
+ if (decision.destination === "explore") {
4370
+ triageAdditionalContext =
4371
+ "OMX native UserPromptSubmit triage detected a read-only/question-shaped request with no workflow keyword. This is advisory prompt-routing context only. Prefer the explore role surface rather than escalating to autopilot.";
4372
+ } else if (decision.destination === "executor") {
4373
+ triageAdditionalContext =
4374
+ "OMX native UserPromptSubmit triage detected a narrow edit-shaped request with no workflow keyword. This is advisory prompt-routing context only. Prefer the executor role surface rather than autopilot.";
4375
+ } else if (decision.destination === "designer") {
4376
+ triageAdditionalContext =
4377
+ "OMX native UserPromptSubmit triage detected a visual/style request with no workflow keyword. This is advisory prompt-routing context only. Prefer the designer role surface.";
4378
+ } else if (decision.destination === "researcher") {
4379
+ triageAdditionalContext =
4380
+ "OMX native UserPromptSubmit triage detected an external documentation/reference research request with no workflow keyword. This is advisory prompt-routing context only. Prefer the researcher role surface rather than repo-local explore or autopilot.";
4381
+ }
4382
+ if (triageAdditionalContext !== null) {
4383
+ const dest = decision.destination as "explore" | "executor" | "designer" | "researcher";
4384
+ const newState: TriageStateFile = {
4385
+ version: 1,
4386
+ last_triage: {
4387
+ lane: "LIGHT",
4388
+ destination: dest,
4389
+ reason: decision.reason,
4390
+ prompt_signature: promptSignature(normalized),
4391
+ turn_id: effectiveTurnId,
4392
+ created_at: nowIso,
4393
+ },
4394
+ suppress_followup: true,
4395
+ };
4396
+ writeTriageState({ cwd, sessionId: sessionIdForState || null, state: newState });
4397
+ }
4398
+ }
4399
+ // lane === "PASS": no context, no state write
4400
+ }
4401
+ }
4402
+ } catch {
4403
+ // Swallow all triage errors; never break the hook
4404
+ triageAdditionalContext = null;
4405
+ }
4406
+ }
4407
+ const skipHudReconcileForDoctorSmoke = process.env.OMX_NATIVE_HOOK_DOCTOR_SMOKE === "1";
4408
+ const skipHudReconcileForTeamWorkerPane = !isSubagentPromptSubmit
4409
+ && await isConfirmedTeamWorkerPromptSubmitPane(cwd).catch(() => false);
4410
+ if (!skipHudReconcileForDoctorSmoke && !skipHudReconcileForTeamWorkerPane) {
4411
+ const reconcileHudForPromptSubmitFn = options.reconcileHudForPromptSubmitFn ?? reconcileHudForPromptSubmit;
4412
+ const hudSessionId = resolveHudReconcileSessionId(
4413
+ currentSessionState,
4414
+ canonicalSessionId,
4415
+ sessionIdForState,
4416
+ );
4417
+ const hudSessionIds = resolveHudReconcileSessionIds(
4418
+ currentSessionState,
4419
+ canonicalSessionId,
4420
+ sessionIdForState,
4421
+ nativeSessionId,
4422
+ );
4423
+ await reconcileHudForPromptSubmitFn(cwd, { sessionId: hudSessionId, sessionIds: hudSessionIds }).catch(() => {});
4424
+ }
4425
+ }
4426
+
4427
+ if (omxEventName && !skipCanonicalSessionStartContext && !suppressNoisySubagentLifecycleDispatch) {
4428
+ const baseContext = buildBaseContext(cwd, payload, hookEventName!, canonicalSessionId);
4429
+ if (resolvedNativeSessionId) {
4430
+ baseContext.native_session_id = resolvedNativeSessionId;
4431
+ baseContext.codex_session_id = resolvedNativeSessionId;
4432
+ }
4433
+ if (canonicalSessionId) {
4434
+ baseContext.omx_session_id = canonicalSessionId;
4435
+ }
4436
+ const event: HookEventEnvelope = buildNativeHookEvent(
4437
+ omxEventName,
4438
+ baseContext,
4439
+ {
4440
+ session_id: eventSessionId,
4441
+ thread_id: threadId || undefined,
4442
+ turn_id: turnId || undefined,
4443
+ mode: safeString(payload.mode).trim() || undefined,
4444
+ },
4445
+ );
4446
+ await dispatchHookEventRuntime({
4447
+ event,
4448
+ cwd,
4449
+ allowTeamWorkerSideEffects: false,
4450
+ });
4451
+ }
4452
+
4453
+ if (hookEventName === "PreCompact") {
4454
+ // Codex native PreCompact currently accepts only the common continuation fields.
4455
+ // Keep the OMX lifecycle dispatch above, but do not emit `hookSpecificOutput`
4456
+ // unless Codex defines a supported PreCompact output contract.
4457
+ buildWikiPreCompactContext({ cwd });
4458
+ } else if ((hookEventName === "SessionStart" && !skipCanonicalSessionStartContext) || hookEventName === "UserPromptSubmit") {
4459
+ const additionalContext = hookEventName === "SessionStart"
4460
+ ? await buildSessionStartContext(cwd, canonicalSessionId || nativeSessionId, {
4461
+ hookEventName,
4462
+ payload,
4463
+ canonicalSessionId,
4464
+ nativeSessionId: resolvedNativeSessionId || nativeSessionId,
4465
+ })
4466
+ : isSubagentPromptSubmit
4467
+ ? null
4468
+ : [
4469
+ buildAdditionalContextMessage(readPromptText(payload), skillState, cwd, payload),
4470
+ ultragoalSteeringAdditionalContext,
4471
+ goalWorkflowAdditionalContext,
4472
+ triageAdditionalContext,
4473
+ ].filter((entry): entry is string => Boolean(entry)).join("\n\n") || null;
4474
+ if (additionalContext) {
4475
+ outputJson = {
4476
+ hookSpecificOutput: {
4477
+ hookEventName,
4478
+ additionalContext,
4479
+ },
4480
+ };
4481
+ }
4482
+ } else if (hookEventName === "PreToolUse") {
4483
+ const payloadSessionId = readPayloadSessionId(payload);
4484
+ const preToolUseSessionId = payloadSessionId
4485
+ ? await resolveInternalSessionIdForPayload(cwd, payloadSessionId, stateDir)
4486
+ : "";
4487
+ outputJson = await buildDeepInterviewPreToolUseBoundaryOutput(payload, cwd, stateDir, preToolUseSessionId)
4488
+ ?? await buildRalplanPreToolUseBoundaryOutput(payload, cwd, stateDir, preToolUseSessionId)
4489
+ ?? await buildTeamAttentionOutput(cwd, stateDir)
4490
+ ?? buildNativePreToolUseOutput(payload);
4491
+ } else if (hookEventName === "PostToolUse") {
4492
+ if (detectMcpTransportFailure(payload)) {
4493
+ await markTeamTransportFailure(cwd, payload);
4494
+ }
4495
+ outputJson = buildNativePostToolUseOutput(payload);
4496
+ await handleTeamWorkerPostToolUseSuccess(payload, cwd);
4497
+ } else if (hookEventName === "Stop") {
4498
+ outputJson = await buildStopHookOutput(payload, cwd, stateDir, {
4499
+ skipRalphStopBlock: isSubagentStop,
4500
+ });
4501
+ }
4502
+
4503
+ return {
4504
+ hookEventName,
4505
+ omxEventName,
4506
+ skillState,
4507
+ outputJson,
4508
+ };
4509
+ }
4510
+
4511
+ function hasNativeStopRuntimeSurface(cwd: string): boolean {
4512
+ if (existsSync(join(cwd, ".omx"))) return true;
4513
+ if (findGitLayout(cwd)) return true;
4514
+ const omxRoot = safeString(process.env.OMX_ROOT).trim();
4515
+ if (omxRoot && existsSync(join(omxRoot, ".omx"))) return true;
4516
+ const stateRoot = safeString(process.env.OMX_STATE_ROOT).trim();
4517
+ if (stateRoot && existsSync(stateRoot)) return true;
4518
+ return [
4519
+ process.env.OMX_SESSION_ID,
4520
+ process.env.OMX_TEAM_INTERNAL_WORKER,
4521
+ process.env.OMX_TEAM_WORKER,
4522
+ process.env.OMX_TEAM_STATE_ROOT,
4523
+ process.env.OMX_TEAM_LEADER_CWD,
4524
+ process.env.OMX_NOTIFY_HOOK_TRUSTED_MANAGED_CWD,
4525
+ process.env.OMX_TMUX_HUD_OWNER,
4526
+ process.env.OMX_TMUX_HUD_LEADER_PANE,
4527
+ ].some((value) => safeString(value).trim() !== "");
4528
+ }
4529
+
4530
+ interface NativeHookCliReadResult {
4531
+ payload: CodexHookPayload;
4532
+ parseError: Error | null;
4533
+ rawInput: string;
4534
+ oversized: boolean;
4535
+ rawHookEventName: CodexHookEventName | null;
4536
+ }
4537
+
4538
+ export function isCodexNativeHookMainModule(
4539
+ moduleUrl: string,
4540
+ argv1: string | undefined,
4541
+ ): boolean {
4542
+ if (!argv1) return false;
4543
+ return moduleUrl === pathToFileURL(argv1).href;
4544
+ }
4545
+
4546
+ async function readStdinJson(): Promise<NativeHookCliReadResult> {
4547
+ const chunks: Buffer[] = [];
4548
+ let totalBytes = 0;
4549
+ let oversized = false;
4550
+ for await (const chunk of process.stdin) {
4551
+ const buffer = Buffer.isBuffer(chunk) ? chunk : Buffer.from(String(chunk));
4552
+ totalBytes += buffer.byteLength;
4553
+ if (totalBytes > MAX_NATIVE_STDIN_JSON_BYTES) {
4554
+ const remaining = Math.max(0, MAX_NATIVE_STDIN_JSON_BYTES - (totalBytes - buffer.byteLength));
4555
+ if (remaining > 0) chunks.push(Buffer.from(buffer.subarray(0, remaining)));
4556
+ oversized = true;
4557
+ process.stdin.destroy();
4558
+ break;
4559
+ }
4560
+ chunks.push(buffer);
4561
+ }
4562
+ const raw = Buffer.concat(chunks).toString("utf-8").trim();
4563
+ const rawHookEventName = extractRawCodexHookEventName(raw);
4564
+ if (oversized) {
4565
+ return {
4566
+ payload: {},
4567
+ parseError: null,
4568
+ rawInput: raw,
4569
+ oversized: true,
4570
+ rawHookEventName,
4571
+ };
4572
+ }
4573
+ if (!raw) {
4574
+ return { payload: {}, parseError: null, rawInput: raw, oversized: false, rawHookEventName };
4575
+ }
4576
+
4577
+ try {
4578
+ return {
4579
+ payload: safeObject(JSON.parse(raw)),
4580
+ parseError: null,
4581
+ rawInput: raw,
4582
+ oversized: false,
4583
+ rawHookEventName,
4584
+ };
4585
+ } catch (error) {
4586
+ return {
4587
+ payload: {},
4588
+ parseError: error instanceof Error ? error : new Error(String(error)),
4589
+ rawInput: raw,
4590
+ oversized: false,
4591
+ rawHookEventName,
4592
+ };
4593
+ }
4594
+ }
4595
+
4596
+ function inferHookEventNameFromMalformedInput(raw: string): CodexHookEventName | null {
4597
+ const match = raw.match(/(?:\"|['"])?hook[_-]?event[_-]?name(?:\"|['"])?\s*:\s*(?:\"|['"])?(SessionStart|PreToolUse|PostToolUse|UserPromptSubmit|PreCompact|PostCompact|Stop)\b/i);
4598
+ const value = match?.[1];
4599
+ if (!value) return null;
4600
+ return readHookEventName({ hook_event_name: value });
4601
+ }
4602
+
4603
+ /**
4604
+ * Check team state for tasks that have completed or failed since the leader
4605
+ * last acknowledged them. When there are pending items, inject a non-blocking
4606
+ * system reminder via {@code hookSpecificOutput.additionalContext} so the
4607
+ * leader sees it on the next turn without a tmux send-keys interrupt.
4608
+ *
4609
+ * This replaces the old inject-based leader nudge with async file-based
4610
+ * attention polling. The notify hook stays disabled; team workers still
4611
+ * write mailbox + status files independently.
4612
+ */
4613
+ async function buildTeamAttentionOutput(
4614
+ cwd: string,
4615
+ stateDir: string,
4616
+ ): Promise<Record<string, unknown> | null> {
4617
+ try {
4618
+ if (!readTeamModeConfig(cwd).enabled) return null;
4619
+
4620
+ const teamRoot = resolveCanonicalTeamStateRoot(cwd);
4621
+ const teamDir = join(teamRoot, "team");
4622
+ if (!existsSync(teamDir)) return null;
4623
+
4624
+ const entries = await readdir(teamDir).catch(() => [] as string[]);
4625
+ if (entries.length === 0) return null;
4626
+
4627
+ const parts: string[] = [];
4628
+ let pendingCount = 0;
4629
+
4630
+ for (const teamName of entries) {
4631
+ const teamPath = join(teamDir, teamName);
4632
+ try {
4633
+ if (!(await stat(teamPath)).isDirectory()) continue;
4634
+ } catch { continue; }
4635
+
4636
+ // ── tasks ────────────────────────────────────────────────
4637
+ let tasks: Array<{ id: string; status: string }> = [];
4638
+ try {
4639
+ tasks = await listTasks(teamName, cwd);
4640
+ } catch { /* best-effort */ }
4641
+
4642
+ const newlyDone = tasks
4643
+ .filter(t => t.status === "completed" || t.status === "failed")
4644
+ .map(t => `task-${t.id}(${t.status})`);
4645
+ if (newlyDone.length > 0) {
4646
+ parts.push(`Team ${teamName}: ${newlyDone.join(", ")}`);
4647
+ pendingCount += newlyDone.length;
4648
+ }
4649
+
4650
+ // ── workers ──────────────────────────────────────────────
4651
+ const workersDir = join(teamPath, "workers");
4652
+ let workerEntries: string[] = [];
4653
+ try { workerEntries = await readdir(workersDir); } catch { /* empty */ }
4654
+
4655
+ for (const workerName of workerEntries) {
4656
+ try {
4657
+ const ws = await readWorkerStatus(teamName, workerName, cwd);
4658
+ if (ws.state === "done" || ws.state === "failed") {
4659
+ parts.push(`Team ${teamName}: worker ${workerName} ${ws.state}`);
4660
+ pendingCount++;
4661
+ }
4662
+ } catch { /* best-effort */ }
4663
+ }
4664
+ }
4665
+
4666
+ if (pendingCount === 0) return null;
4667
+
4668
+ const summary = parts.join("; ") + ". ";
4669
+ const guidance =
4670
+ pendingCount === 1
4671
+ ? "Check with `omx team status` and handle the result at the next natural pause."
4672
+ : `Check with \`omx team status\` and handle ${pendingCount} completed items at the next natural pause.`;
4673
+
4674
+ return {
4675
+ decision: "block",
4676
+ reason: `team_attention_pending: ${pendingCount} item(s) need leader review`,
4677
+ hookSpecificOutput: {
4678
+ hookEventName: "PreToolUse",
4679
+ additionalContext: `[OMX team] ${summary}${guidance}`,
4680
+ },
4681
+ } as unknown as Record<string, unknown>;
4682
+ } catch {
4683
+ return null;
4684
+ }
4685
+ }
4686
+
4687
+ function buildMalformedStdinHookOutput(
4688
+ parseError: Error,
4689
+ rawInput: string,
4690
+ cwd = process.cwd(),
4691
+ ): Record<string, unknown> {
4692
+ const reason =
4693
+ "OMX native hook received malformed JSON input. Preserve runtime state, inspect the emitting hook payload yourself, and retry with valid JSON.";
4694
+ const systemMessage =
4695
+ `${reason} stdin JSON parsing failed inside codex-native-hook: ${parseError.message}.`;
4696
+ const inferredHookEventName = inferHookEventNameFromMalformedInput(rawInput);
4697
+ if (inferredHookEventName === "Stop" || (!inferredHookEventName && hasNativeStopRuntimeSurface(cwd))) {
4698
+ return {
4699
+ decision: "block",
4700
+ reason,
4701
+ stopReason: "native_hook_stdin_parse_error",
4702
+ systemMessage,
4703
+ };
4704
+ }
4705
+ return {
4706
+ continue: false,
4707
+ stopReason: "native_hook_stdin_parse_error",
4708
+ systemMessage,
4709
+ };
4710
+ }
4711
+
4712
+ async function buildOversizedStopActiveWorkflowOutput(cwd: string): Promise<Record<string, unknown> | null> {
4713
+ const currentSession = await readUsableSessionState(cwd);
4714
+ const currentSessionId = safeString(currentSession?.session_id).trim()
4715
+ || safeString(process.env.OMX_SESSION_ID || process.env.CODEX_SESSION_ID).trim();
4716
+ if (!currentSessionId) return null;
4717
+
4718
+ if (await readCanonicalTerminalRunStateForStop(cwd, currentSessionId, "autopilot")) return null;
4719
+
4720
+ const autopilotState = await readModeStateForActiveDecision("autopilot", currentSessionId, cwd);
4721
+ if (!autopilotState || !shouldContinueRun(autopilotState)) return null;
4722
+
4723
+ const phase = formatPhase(autopilotState.current_phase);
4724
+ const reason =
4725
+ `OMX native Stop received oversized stdin before parsing while the current session has active OMX autopilot state (phase: ${phase}); continue once with a compact response or reduce hook payload size so normal Stop gates can run.`;
4726
+ return {
4727
+ decision: "block",
4728
+ reason,
4729
+ stopReason: "native_stop_stdin_oversized_active_workflow",
4730
+ systemMessage:
4731
+ "OMX native Stop rejected oversized stdin before parsing; active current-session workflow state is present, so Stop is blocked instead of silently allowing termination.",
4732
+ };
4733
+ }
4734
+
4735
+ async function buildOversizedStdinHookOutput(
4736
+ rawHookEventName: CodexHookEventName | null,
4737
+ cwd: string,
4738
+ ): Promise<Record<string, unknown>> {
4739
+ if (rawHookEventName === "Stop") {
4740
+ return await buildOversizedStopActiveWorkflowOutput(cwd) ?? {};
4741
+ }
4742
+ const systemMessage =
4743
+ `OMX native hook rejected oversized stdin JSON before parsing; maxBytes=${MAX_NATIVE_STDIN_JSON_BYTES}.`;
4744
+ return {
4745
+ continue: false,
4746
+ stopReason: "native_hook_stdin_oversized",
4747
+ systemMessage,
4748
+ };
4749
+ }
4750
+
4751
+ function writeNativeHookJsonStdout(output: Record<string, unknown>): void {
4752
+ process.stdout.write(`${JSON.stringify(output)}\n`);
4753
+ }
4754
+
4755
+ function redactMalformedHookPreview(rawInput: string): string {
4756
+ const withoutControls = rawInput.replace(/[\u0000-\u001f\u007f-\u009f]/g, "");
4757
+ const withoutAuthSecrets = redactAuthSecrets(withoutControls);
4758
+ return withoutAuthSecrets
4759
+ .replace(
4760
+ /(["']?(?:prompt|user_prompt|input|text)["']?\s*:\s*)(["'])(?:\\.|(?!\2)[^\\])*\2/gi,
4761
+ "$1$2[REDACTED]$2",
4762
+ )
4763
+ .replace(
4764
+ /(["']?(?:prompt|user_prompt|input|text)["']?\s*:\s*)(["'])(?:\\.|[^\\])*$/gi,
4765
+ "$1$2[REDACTED]$2",
4766
+ )
4767
+ .replace(
4768
+ /(["']?(?:prompt|user_prompt|input|text)["']?\s*:\s*)(?!["'])[^,}]*/gi,
4769
+ "$1[REDACTED]",
4770
+ );
4771
+ }
4772
+
4773
+ function buildRawInputLogFields(rawInput: string): Record<string, unknown> {
4774
+ if (!rawInput) return {};
4775
+ return {
4776
+ raw_input_length: Buffer.byteLength(rawInput, "utf-8"),
4777
+ raw_input_prefix: redactMalformedHookPreview(rawInput).slice(0, 240),
4778
+ };
4779
+ }
4780
+
4781
+ async function logNativeHookCliError(
4782
+ cwd: string,
4783
+ type: string,
4784
+ error: unknown,
4785
+ payload: CodexHookPayload = {},
4786
+ details: Record<string, unknown> = {},
4787
+ ): Promise<void> {
4788
+ const logsDir = join(cwd || process.cwd(), ".omx", "logs");
4789
+ await mkdir(logsDir, { recursive: true }).catch(() => {});
4790
+ const logPath = join(logsDir, `native-hook-${new Date().toISOString().split("T")[0]}.jsonl`);
4791
+ await appendFile(
4792
+ logPath,
4793
+ JSON.stringify({
4794
+ timestamp: new Date().toISOString(),
4795
+ type,
4796
+ hook_event_name: readHookEventName(payload) ?? "Unknown",
4797
+ session_id: readPayloadSessionId(payload) || undefined,
4798
+ thread_id: readPayloadThreadId(payload) || undefined,
4799
+ turn_id: readPayloadTurnId(payload) || undefined,
4800
+ error: error instanceof Error ? error.message : String(error),
4801
+ ...details,
4802
+ }) + "\n",
4803
+ ).catch(() => {});
4804
+ }
4805
+
4806
+ function isStopDispatchFailureTestTrigger(payload: CodexHookPayload): boolean {
4807
+ return process.env.NODE_ENV === "test"
4808
+ && process.env.OMX_NATIVE_HOOK_TEST_THROW_STOP_DISPATCH === "1"
4809
+ && readHookEventName(payload) === "Stop";
4810
+ }
4811
+
4812
+ function isDispatchFailureTestTrigger(): boolean {
4813
+ return process.env.NODE_ENV === "test"
4814
+ && process.env.OMX_NATIVE_HOOK_TEST_THROW_DISPATCH === "1";
4815
+ }
4816
+
4817
+ function buildStopDispatchFailureOutput(error: unknown): Record<string, unknown> {
4818
+ const detail = error instanceof Error ? error.message : String(error);
4819
+ const reason =
4820
+ "OMX native Stop hook failed before normal continuation handling. Continue once more, preserve runtime state, inspect the hook logs, and retry with a valid Stop JSON response.";
4821
+ return {
4822
+ decision: "block",
4823
+ reason,
4824
+ stopReason: "native_stop_dispatch_failure",
4825
+ systemMessage: `${reason} Failure: ${detail}`,
4826
+ };
4827
+ }
4828
+
4829
+ export async function runCodexNativeHookCli(): Promise<void> {
4830
+ const { payload, parseError, rawInput, oversized, rawHookEventName } = await readStdinJson();
4831
+ if (oversized) {
4832
+ writeNativeHookJsonStdout(await buildOversizedStdinHookOutput(rawHookEventName, process.cwd()));
4833
+ return;
4834
+ }
4835
+ if (parseError) {
4836
+ await logNativeHookCliError(
4837
+ process.cwd(),
4838
+ "native_hook_stdin_parse_error",
4839
+ parseError,
4840
+ {},
4841
+ buildRawInputLogFields(rawInput),
4842
+ );
4843
+ writeNativeHookJsonStdout(buildMalformedStdinHookOutput(parseError, rawInput, process.cwd()));
4844
+ return;
4845
+ }
4846
+
4847
+ try {
4848
+ if (isStopDispatchFailureTestTrigger(payload)) {
4849
+ throw new Error("test-induced Stop dispatch failure");
4850
+ }
4851
+ if (isDispatchFailureTestTrigger()) {
4852
+ throw new Error("test-induced dispatch failure");
4853
+ }
4854
+
4855
+ const result = await dispatchCodexNativeHook(payload);
4856
+ if (result.outputJson) {
4857
+ writeNativeHookJsonStdout(result.outputJson);
4858
+ } else if (result.hookEventName === "Stop") {
4859
+ writeNativeHookJsonStdout({});
4860
+ }
4861
+ } catch (error) {
4862
+ const cwd = safeString(payload.cwd).trim() || process.cwd();
4863
+ await logNativeHookCliError(cwd, "native_hook_dispatch_error", error, payload);
4864
+ if (readHookEventName(payload) === "Stop") {
4865
+ writeNativeHookJsonStdout(buildStopDispatchFailureOutput(error));
4866
+ } else {
4867
+ process.exitCode = 1;
4868
+ }
4869
+ }
4870
+ }
4871
+
4872
+ if (isCodexNativeHookMainModule(import.meta.url, process.argv[1])) {
4873
+ runCodexNativeHookCli().catch((error) => {
4874
+ process.exitCode = 1;
4875
+ void logNativeHookCliError(process.cwd(), "native_hook_fatal_error", error);
4876
+ });
4877
+ }