olympus-ai 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (573) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +691 -0
  3. package/dist/__tests__/example.test.d.ts +2 -0
  4. package/dist/__tests__/example.test.d.ts.map +1 -0
  5. package/dist/__tests__/example.test.js +20 -0
  6. package/dist/__tests__/example.test.js.map +1 -0
  7. package/dist/__tests__/hooks.test.d.ts +2 -0
  8. package/dist/__tests__/hooks.test.d.ts.map +1 -0
  9. package/dist/__tests__/hooks.test.js +644 -0
  10. package/dist/__tests__/hooks.test.js.map +1 -0
  11. package/dist/__tests__/installer.test.d.ts +2 -0
  12. package/dist/__tests__/installer.test.d.ts.map +1 -0
  13. package/dist/__tests__/installer.test.js +369 -0
  14. package/dist/__tests__/installer.test.js.map +1 -0
  15. package/dist/__tests__/model-routing.test.d.ts +2 -0
  16. package/dist/__tests__/model-routing.test.d.ts.map +1 -0
  17. package/dist/__tests__/model-routing.test.js +814 -0
  18. package/dist/__tests__/model-routing.test.js.map +1 -0
  19. package/dist/__tests__/skills.test.d.ts +2 -0
  20. package/dist/__tests__/skills.test.d.ts.map +1 -0
  21. package/dist/__tests__/skills.test.js +126 -0
  22. package/dist/__tests__/skills.test.js.map +1 -0
  23. package/dist/__tests__/types.test.d.ts +2 -0
  24. package/dist/__tests__/types.test.d.ts.map +1 -0
  25. package/dist/__tests__/types.test.js +77 -0
  26. package/dist/__tests__/types.test.js.map +1 -0
  27. package/dist/agents/definitions.d.ts +105 -0
  28. package/dist/agents/definitions.d.ts.map +1 -0
  29. package/dist/agents/definitions.js +1379 -0
  30. package/dist/agents/definitions.js.map +1 -0
  31. package/dist/agents/document-writer.d.ts +11 -0
  32. package/dist/agents/document-writer.d.ts.map +1 -0
  33. package/dist/agents/document-writer.js +209 -0
  34. package/dist/agents/document-writer.js.map +1 -0
  35. package/dist/agents/explore.d.ts +12 -0
  36. package/dist/agents/explore.d.ts.map +1 -0
  37. package/dist/agents/explore.js +103 -0
  38. package/dist/agents/explore.js.map +1 -0
  39. package/dist/agents/frontend-engineer.d.ts +11 -0
  40. package/dist/agents/frontend-engineer.d.ts.map +1 -0
  41. package/dist/agents/frontend-engineer.js +115 -0
  42. package/dist/agents/frontend-engineer.js.map +1 -0
  43. package/dist/agents/index.d.ts +21 -0
  44. package/dist/agents/index.d.ts.map +1 -0
  45. package/dist/agents/index.js +27 -0
  46. package/dist/agents/index.js.map +1 -0
  47. package/dist/agents/librarian.d.ts +12 -0
  48. package/dist/agents/librarian.d.ts.map +1 -0
  49. package/dist/agents/librarian.js +103 -0
  50. package/dist/agents/librarian.js.map +1 -0
  51. package/dist/agents/metis.d.ts +12 -0
  52. package/dist/agents/metis.d.ts.map +1 -0
  53. package/dist/agents/metis.js +117 -0
  54. package/dist/agents/metis.js.map +1 -0
  55. package/dist/agents/momus.d.ts +12 -0
  56. package/dist/agents/momus.d.ts.map +1 -0
  57. package/dist/agents/momus.js +128 -0
  58. package/dist/agents/momus.js.map +1 -0
  59. package/dist/agents/multimodal-looker.d.ts +11 -0
  60. package/dist/agents/multimodal-looker.d.ts.map +1 -0
  61. package/dist/agents/multimodal-looker.js +70 -0
  62. package/dist/agents/multimodal-looker.js.map +1 -0
  63. package/dist/agents/olympian.d.ts +12 -0
  64. package/dist/agents/olympian.d.ts.map +1 -0
  65. package/dist/agents/olympian.js +93 -0
  66. package/dist/agents/olympian.js.map +1 -0
  67. package/dist/agents/oracle.d.ts +13 -0
  68. package/dist/agents/oracle.d.ts.map +1 -0
  69. package/dist/agents/oracle.js +191 -0
  70. package/dist/agents/oracle.js.map +1 -0
  71. package/dist/agents/orchestrator-olympus.d.ts +11 -0
  72. package/dist/agents/orchestrator-olympus.d.ts.map +1 -0
  73. package/dist/agents/orchestrator-olympus.js +115 -0
  74. package/dist/agents/orchestrator-olympus.js.map +1 -0
  75. package/dist/agents/orchestrator-sisyphus.d.ts +11 -0
  76. package/dist/agents/orchestrator-sisyphus.d.ts.map +1 -0
  77. package/dist/agents/orchestrator-sisyphus.js +115 -0
  78. package/dist/agents/orchestrator-sisyphus.js.map +1 -0
  79. package/dist/agents/prometheus.d.ts +12 -0
  80. package/dist/agents/prometheus.d.ts.map +1 -0
  81. package/dist/agents/prometheus.js +156 -0
  82. package/dist/agents/prometheus.js.map +1 -0
  83. package/dist/agents/qa-tester.d.ts +16 -0
  84. package/dist/agents/qa-tester.d.ts.map +1 -0
  85. package/dist/agents/qa-tester.js +367 -0
  86. package/dist/agents/qa-tester.js.map +1 -0
  87. package/dist/agents/sisyphus-junior.d.ts +12 -0
  88. package/dist/agents/sisyphus-junior.d.ts.map +1 -0
  89. package/dist/agents/sisyphus-junior.js +93 -0
  90. package/dist/agents/sisyphus-junior.js.map +1 -0
  91. package/dist/agents/types.d.ts +120 -0
  92. package/dist/agents/types.d.ts.map +1 -0
  93. package/dist/agents/types.js +38 -0
  94. package/dist/agents/types.js.map +1 -0
  95. package/dist/agents/utils.d.ts +49 -0
  96. package/dist/agents/utils.d.ts.map +1 -0
  97. package/dist/agents/utils.js +164 -0
  98. package/dist/agents/utils.js.map +1 -0
  99. package/dist/cli/index.d.ts +13 -0
  100. package/dist/cli/index.d.ts.map +1 -0
  101. package/dist/cli/index.js +496 -0
  102. package/dist/cli/index.js.map +1 -0
  103. package/dist/commands/index.d.ts +78 -0
  104. package/dist/commands/index.d.ts.map +1 -0
  105. package/dist/commands/index.js +148 -0
  106. package/dist/commands/index.js.map +1 -0
  107. package/dist/config/index.d.ts +5 -0
  108. package/dist/config/index.d.ts.map +1 -0
  109. package/dist/config/index.js +5 -0
  110. package/dist/config/index.js.map +1 -0
  111. package/dist/config/loader.d.ts +49 -0
  112. package/dist/config/loader.d.ts.map +1 -0
  113. package/dist/config/loader.js +380 -0
  114. package/dist/config/loader.js.map +1 -0
  115. package/dist/features/auto-update.d.ts +187 -0
  116. package/dist/features/auto-update.d.ts.map +1 -0
  117. package/dist/features/auto-update.js +539 -0
  118. package/dist/features/auto-update.js.map +1 -0
  119. package/dist/features/background-agent/concurrency.d.ts +53 -0
  120. package/dist/features/background-agent/concurrency.d.ts.map +1 -0
  121. package/dist/features/background-agent/concurrency.js +121 -0
  122. package/dist/features/background-agent/concurrency.js.map +1 -0
  123. package/dist/features/background-agent/index.d.ts +12 -0
  124. package/dist/features/background-agent/index.d.ts.map +1 -0
  125. package/dist/features/background-agent/index.js +12 -0
  126. package/dist/features/background-agent/index.js.map +1 -0
  127. package/dist/features/background-agent/manager.d.ts +134 -0
  128. package/dist/features/background-agent/manager.d.ts.map +1 -0
  129. package/dist/features/background-agent/manager.js +412 -0
  130. package/dist/features/background-agent/manager.js.map +1 -0
  131. package/dist/features/background-agent/types.d.ts +99 -0
  132. package/dist/features/background-agent/types.d.ts.map +1 -0
  133. package/dist/features/background-agent/types.js +9 -0
  134. package/dist/features/background-agent/types.js.map +1 -0
  135. package/dist/features/background-tasks.d.ts +99 -0
  136. package/dist/features/background-tasks.d.ts.map +1 -0
  137. package/dist/features/background-tasks.js +265 -0
  138. package/dist/features/background-tasks.js.map +1 -0
  139. package/dist/features/boulder-state/constants.d.ts +20 -0
  140. package/dist/features/boulder-state/constants.d.ts.map +1 -0
  141. package/dist/features/boulder-state/constants.js +20 -0
  142. package/dist/features/boulder-state/constants.js.map +1 -0
  143. package/dist/features/boulder-state/index.d.ts +12 -0
  144. package/dist/features/boulder-state/index.d.ts.map +1 -0
  145. package/dist/features/boulder-state/index.js +13 -0
  146. package/dist/features/boulder-state/index.js.map +1 -0
  147. package/dist/features/boulder-state/storage.d.ts +58 -0
  148. package/dist/features/boulder-state/storage.d.ts.map +1 -0
  149. package/dist/features/boulder-state/storage.js +174 -0
  150. package/dist/features/boulder-state/storage.js.map +1 -0
  151. package/dist/features/boulder-state/types.d.ts +48 -0
  152. package/dist/features/boulder-state/types.d.ts.map +1 -0
  153. package/dist/features/boulder-state/types.js +10 -0
  154. package/dist/features/boulder-state/types.js.map +1 -0
  155. package/dist/features/builtin-skills/index.d.ts +10 -0
  156. package/dist/features/builtin-skills/index.d.ts.map +1 -0
  157. package/dist/features/builtin-skills/index.js +10 -0
  158. package/dist/features/builtin-skills/index.js.map +1 -0
  159. package/dist/features/builtin-skills/skills.d.ts +21 -0
  160. package/dist/features/builtin-skills/skills.d.ts.map +1 -0
  161. package/dist/features/builtin-skills/skills.js +1082 -0
  162. package/dist/features/builtin-skills/skills.js.map +1 -0
  163. package/dist/features/builtin-skills/types.d.ts +60 -0
  164. package/dist/features/builtin-skills/types.d.ts.map +1 -0
  165. package/dist/features/builtin-skills/types.js +9 -0
  166. package/dist/features/builtin-skills/types.js.map +1 -0
  167. package/dist/features/context-injector/collector.d.ts +56 -0
  168. package/dist/features/context-injector/collector.d.ts.map +1 -0
  169. package/dist/features/context-injector/collector.js +122 -0
  170. package/dist/features/context-injector/collector.js.map +1 -0
  171. package/dist/features/context-injector/index.d.ts +12 -0
  172. package/dist/features/context-injector/index.d.ts.map +1 -0
  173. package/dist/features/context-injector/index.js +13 -0
  174. package/dist/features/context-injector/index.js.map +1 -0
  175. package/dist/features/context-injector/injector.d.ts +47 -0
  176. package/dist/features/context-injector/injector.d.ts.map +1 -0
  177. package/dist/features/context-injector/injector.js +103 -0
  178. package/dist/features/context-injector/injector.js.map +1 -0
  179. package/dist/features/context-injector/types.d.ts +103 -0
  180. package/dist/features/context-injector/types.d.ts.map +1 -0
  181. package/dist/features/context-injector/types.js +11 -0
  182. package/dist/features/context-injector/types.js.map +1 -0
  183. package/dist/features/continuation-enforcement.d.ts +36 -0
  184. package/dist/features/continuation-enforcement.d.ts.map +1 -0
  185. package/dist/features/continuation-enforcement.js +175 -0
  186. package/dist/features/continuation-enforcement.js.map +1 -0
  187. package/dist/features/index.d.ts +12 -0
  188. package/dist/features/index.d.ts.map +1 -0
  189. package/dist/features/index.js +49 -0
  190. package/dist/features/index.js.map +1 -0
  191. package/dist/features/magic-keywords.d.ts +28 -0
  192. package/dist/features/magic-keywords.d.ts.map +1 -0
  193. package/dist/features/magic-keywords.js +421 -0
  194. package/dist/features/magic-keywords.js.map +1 -0
  195. package/dist/features/model-routing/index.d.ts +34 -0
  196. package/dist/features/model-routing/index.d.ts.map +1 -0
  197. package/dist/features/model-routing/index.js +48 -0
  198. package/dist/features/model-routing/index.js.map +1 -0
  199. package/dist/features/model-routing/prompts/haiku.d.ts +54 -0
  200. package/dist/features/model-routing/prompts/haiku.d.ts.map +1 -0
  201. package/dist/features/model-routing/prompts/haiku.js +141 -0
  202. package/dist/features/model-routing/prompts/haiku.js.map +1 -0
  203. package/dist/features/model-routing/prompts/index.d.ts +45 -0
  204. package/dist/features/model-routing/prompts/index.d.ts.map +1 -0
  205. package/dist/features/model-routing/prompts/index.js +116 -0
  206. package/dist/features/model-routing/prompts/index.js.map +1 -0
  207. package/dist/features/model-routing/prompts/opus.d.ts +34 -0
  208. package/dist/features/model-routing/prompts/opus.d.ts.map +1 -0
  209. package/dist/features/model-routing/prompts/opus.js +153 -0
  210. package/dist/features/model-routing/prompts/opus.js.map +1 -0
  211. package/dist/features/model-routing/prompts/sonnet.d.ts +38 -0
  212. package/dist/features/model-routing/prompts/sonnet.d.ts.map +1 -0
  213. package/dist/features/model-routing/prompts/sonnet.js +149 -0
  214. package/dist/features/model-routing/prompts/sonnet.js.map +1 -0
  215. package/dist/features/model-routing/router.d.ts +92 -0
  216. package/dist/features/model-routing/router.d.ts.map +1 -0
  217. package/dist/features/model-routing/router.js +267 -0
  218. package/dist/features/model-routing/router.js.map +1 -0
  219. package/dist/features/model-routing/rules.d.ts +32 -0
  220. package/dist/features/model-routing/rules.d.ts.map +1 -0
  221. package/dist/features/model-routing/rules.js +224 -0
  222. package/dist/features/model-routing/rules.js.map +1 -0
  223. package/dist/features/model-routing/scorer.d.ts +35 -0
  224. package/dist/features/model-routing/scorer.d.ts.map +1 -0
  225. package/dist/features/model-routing/scorer.js +241 -0
  226. package/dist/features/model-routing/scorer.js.map +1 -0
  227. package/dist/features/model-routing/signals.d.ts +26 -0
  228. package/dist/features/model-routing/signals.d.ts.map +1 -0
  229. package/dist/features/model-routing/signals.js +283 -0
  230. package/dist/features/model-routing/signals.js.map +1 -0
  231. package/dist/features/model-routing/types.d.ts +195 -0
  232. package/dist/features/model-routing/types.d.ts.map +1 -0
  233. package/dist/features/model-routing/types.js +86 -0
  234. package/dist/features/model-routing/types.js.map +1 -0
  235. package/dist/hooks/agent-usage-reminder/constants.d.ts +17 -0
  236. package/dist/hooks/agent-usage-reminder/constants.d.ts.map +1 -0
  237. package/dist/hooks/agent-usage-reminder/constants.js +58 -0
  238. package/dist/hooks/agent-usage-reminder/constants.js.map +1 -0
  239. package/dist/hooks/agent-usage-reminder/index.d.ts +36 -0
  240. package/dist/hooks/agent-usage-reminder/index.d.ts.map +1 -0
  241. package/dist/hooks/agent-usage-reminder/index.js +89 -0
  242. package/dist/hooks/agent-usage-reminder/index.js.map +1 -0
  243. package/dist/hooks/agent-usage-reminder/storage.d.ts +12 -0
  244. package/dist/hooks/agent-usage-reminder/storage.d.ts.map +1 -0
  245. package/dist/hooks/agent-usage-reminder/storage.js +39 -0
  246. package/dist/hooks/agent-usage-reminder/storage.js.map +1 -0
  247. package/dist/hooks/agent-usage-reminder/types.d.ts +14 -0
  248. package/dist/hooks/agent-usage-reminder/types.d.ts.map +1 -0
  249. package/dist/hooks/agent-usage-reminder/types.js +9 -0
  250. package/dist/hooks/agent-usage-reminder/types.js.map +1 -0
  251. package/dist/hooks/ascent-verifier/index.d.ts +72 -0
  252. package/dist/hooks/ascent-verifier/index.d.ts.map +1 -0
  253. package/dist/hooks/ascent-verifier/index.js +223 -0
  254. package/dist/hooks/ascent-verifier/index.js.map +1 -0
  255. package/dist/hooks/auto-slash-command/constants.d.ts +19 -0
  256. package/dist/hooks/auto-slash-command/constants.d.ts.map +1 -0
  257. package/dist/hooks/auto-slash-command/constants.js +28 -0
  258. package/dist/hooks/auto-slash-command/constants.js.map +1 -0
  259. package/dist/hooks/auto-slash-command/detector.d.ts +33 -0
  260. package/dist/hooks/auto-slash-command/detector.d.ts.map +1 -0
  261. package/dist/hooks/auto-slash-command/detector.js +73 -0
  262. package/dist/hooks/auto-slash-command/detector.js.map +1 -0
  263. package/dist/hooks/auto-slash-command/executor.d.ts +29 -0
  264. package/dist/hooks/auto-slash-command/executor.d.ts.map +1 -0
  265. package/dist/hooks/auto-slash-command/executor.js +214 -0
  266. package/dist/hooks/auto-slash-command/executor.js.map +1 -0
  267. package/dist/hooks/auto-slash-command/index.d.ts +53 -0
  268. package/dist/hooks/auto-slash-command/index.d.ts.map +1 -0
  269. package/dist/hooks/auto-slash-command/index.js +105 -0
  270. package/dist/hooks/auto-slash-command/index.js.map +1 -0
  271. package/dist/hooks/auto-slash-command/types.d.ts +77 -0
  272. package/dist/hooks/auto-slash-command/types.d.ts.map +1 -0
  273. package/dist/hooks/auto-slash-command/types.js +9 -0
  274. package/dist/hooks/auto-slash-command/types.js.map +1 -0
  275. package/dist/hooks/background-notification/index.d.ts +60 -0
  276. package/dist/hooks/background-notification/index.d.ts.map +1 -0
  277. package/dist/hooks/background-notification/index.js +180 -0
  278. package/dist/hooks/background-notification/index.js.map +1 -0
  279. package/dist/hooks/background-notification/types.d.ts +64 -0
  280. package/dist/hooks/background-notification/types.d.ts.map +1 -0
  281. package/dist/hooks/background-notification/types.js +8 -0
  282. package/dist/hooks/background-notification/types.js.map +1 -0
  283. package/dist/hooks/bridge.d.ts +68 -0
  284. package/dist/hooks/bridge.d.ts.map +1 -0
  285. package/dist/hooks/bridge.js +321 -0
  286. package/dist/hooks/bridge.js.map +1 -0
  287. package/dist/hooks/comment-checker/constants.d.ts +28 -0
  288. package/dist/hooks/comment-checker/constants.d.ts.map +1 -0
  289. package/dist/hooks/comment-checker/constants.js +189 -0
  290. package/dist/hooks/comment-checker/constants.js.map +1 -0
  291. package/dist/hooks/comment-checker/filters.d.ts +39 -0
  292. package/dist/hooks/comment-checker/filters.d.ts.map +1 -0
  293. package/dist/hooks/comment-checker/filters.js +126 -0
  294. package/dist/hooks/comment-checker/filters.js.map +1 -0
  295. package/dist/hooks/comment-checker/index.d.ts +58 -0
  296. package/dist/hooks/comment-checker/index.d.ts.map +1 -0
  297. package/dist/hooks/comment-checker/index.js +298 -0
  298. package/dist/hooks/comment-checker/index.js.map +1 -0
  299. package/dist/hooks/comment-checker/types.d.ts +88 -0
  300. package/dist/hooks/comment-checker/types.d.ts.map +1 -0
  301. package/dist/hooks/comment-checker/types.js +9 -0
  302. package/dist/hooks/comment-checker/types.js.map +1 -0
  303. package/dist/hooks/context-window-limit-recovery/constants.d.ts +28 -0
  304. package/dist/hooks/context-window-limit-recovery/constants.d.ts.map +1 -0
  305. package/dist/hooks/context-window-limit-recovery/constants.js +85 -0
  306. package/dist/hooks/context-window-limit-recovery/constants.js.map +1 -0
  307. package/dist/hooks/context-window-limit-recovery/index.d.ts +62 -0
  308. package/dist/hooks/context-window-limit-recovery/index.d.ts.map +1 -0
  309. package/dist/hooks/context-window-limit-recovery/index.js +201 -0
  310. package/dist/hooks/context-window-limit-recovery/index.js.map +1 -0
  311. package/dist/hooks/context-window-limit-recovery/parser.d.ts +31 -0
  312. package/dist/hooks/context-window-limit-recovery/parser.d.ts.map +1 -0
  313. package/dist/hooks/context-window-limit-recovery/parser.js +241 -0
  314. package/dist/hooks/context-window-limit-recovery/parser.js.map +1 -0
  315. package/dist/hooks/context-window-limit-recovery/types.d.ts +84 -0
  316. package/dist/hooks/context-window-limit-recovery/types.d.ts.map +1 -0
  317. package/dist/hooks/context-window-limit-recovery/types.js +34 -0
  318. package/dist/hooks/context-window-limit-recovery/types.js.map +1 -0
  319. package/dist/hooks/directory-readme-injector/constants.d.ts +15 -0
  320. package/dist/hooks/directory-readme-injector/constants.d.ts.map +1 -0
  321. package/dist/hooks/directory-readme-injector/constants.js +17 -0
  322. package/dist/hooks/directory-readme-injector/constants.js.map +1 -0
  323. package/dist/hooks/directory-readme-injector/index.d.ts +41 -0
  324. package/dist/hooks/directory-readme-injector/index.d.ts.map +1 -0
  325. package/dist/hooks/directory-readme-injector/index.js +162 -0
  326. package/dist/hooks/directory-readme-injector/index.js.map +1 -0
  327. package/dist/hooks/directory-readme-injector/storage.d.ts +20 -0
  328. package/dist/hooks/directory-readme-injector/storage.d.ts.map +1 -0
  329. package/dist/hooks/directory-readme-injector/storage.js +56 -0
  330. package/dist/hooks/directory-readme-injector/storage.js.map +1 -0
  331. package/dist/hooks/directory-readme-injector/types.d.ts +20 -0
  332. package/dist/hooks/directory-readme-injector/types.d.ts.map +1 -0
  333. package/dist/hooks/directory-readme-injector/types.js +9 -0
  334. package/dist/hooks/directory-readme-injector/types.js.map +1 -0
  335. package/dist/hooks/edit-error-recovery/index.d.ts +62 -0
  336. package/dist/hooks/edit-error-recovery/index.d.ts.map +1 -0
  337. package/dist/hooks/edit-error-recovery/index.js +89 -0
  338. package/dist/hooks/edit-error-recovery/index.js.map +1 -0
  339. package/dist/hooks/empty-message-sanitizer/constants.d.ts +33 -0
  340. package/dist/hooks/empty-message-sanitizer/constants.d.ts.map +1 -0
  341. package/dist/hooks/empty-message-sanitizer/constants.js +37 -0
  342. package/dist/hooks/empty-message-sanitizer/constants.js.map +1 -0
  343. package/dist/hooks/empty-message-sanitizer/index.d.ts +59 -0
  344. package/dist/hooks/empty-message-sanitizer/index.d.ts.map +1 -0
  345. package/dist/hooks/empty-message-sanitizer/index.js +171 -0
  346. package/dist/hooks/empty-message-sanitizer/index.js.map +1 -0
  347. package/dist/hooks/empty-message-sanitizer/types.d.ts +79 -0
  348. package/dist/hooks/empty-message-sanitizer/types.d.ts.map +1 -0
  349. package/dist/hooks/empty-message-sanitizer/types.js +10 -0
  350. package/dist/hooks/empty-message-sanitizer/types.js.map +1 -0
  351. package/dist/hooks/index.d.ts +35 -0
  352. package/dist/hooks/index.d.ts.map +1 -0
  353. package/dist/hooks/index.js +81 -0
  354. package/dist/hooks/index.js.map +1 -0
  355. package/dist/hooks/keyword-detector/index.d.ts +40 -0
  356. package/dist/hooks/keyword-detector/index.d.ts.map +1 -0
  357. package/dist/hooks/keyword-detector/index.js +88 -0
  358. package/dist/hooks/keyword-detector/index.js.map +1 -0
  359. package/dist/hooks/non-interactive-env/constants.d.ts +35 -0
  360. package/dist/hooks/non-interactive-env/constants.d.ts.map +1 -0
  361. package/dist/hooks/non-interactive-env/constants.js +69 -0
  362. package/dist/hooks/non-interactive-env/constants.js.map +1 -0
  363. package/dist/hooks/non-interactive-env/detector.d.ts +2 -0
  364. package/dist/hooks/non-interactive-env/detector.d.ts.map +1 -0
  365. package/dist/hooks/non-interactive-env/detector.js +16 -0
  366. package/dist/hooks/non-interactive-env/detector.js.map +1 -0
  367. package/dist/hooks/non-interactive-env/index.d.ts +14 -0
  368. package/dist/hooks/non-interactive-env/index.d.ts.map +1 -0
  369. package/dist/hooks/non-interactive-env/index.js +72 -0
  370. package/dist/hooks/non-interactive-env/index.js.map +1 -0
  371. package/dist/hooks/non-interactive-env/types.d.ts +14 -0
  372. package/dist/hooks/non-interactive-env/types.d.ts.map +1 -0
  373. package/dist/hooks/non-interactive-env/types.js +2 -0
  374. package/dist/hooks/non-interactive-env/types.js.map +1 -0
  375. package/dist/hooks/olympus-orchestrator/constants.d.ts +23 -0
  376. package/dist/hooks/olympus-orchestrator/constants.d.ts.map +1 -0
  377. package/dist/hooks/olympus-orchestrator/constants.js +142 -0
  378. package/dist/hooks/olympus-orchestrator/constants.js.map +1 -0
  379. package/dist/hooks/olympus-orchestrator/index.d.ts +113 -0
  380. package/dist/hooks/olympus-orchestrator/index.d.ts.map +1 -0
  381. package/dist/hooks/olympus-orchestrator/index.js +283 -0
  382. package/dist/hooks/olympus-orchestrator/index.js.map +1 -0
  383. package/dist/hooks/persistent-mode/index.d.ts +40 -0
  384. package/dist/hooks/persistent-mode/index.d.ts.map +1 -0
  385. package/dist/hooks/persistent-mode/index.js +322 -0
  386. package/dist/hooks/persistent-mode/index.js.map +1 -0
  387. package/dist/hooks/plugin-patterns/index.d.ts +107 -0
  388. package/dist/hooks/plugin-patterns/index.d.ts.map +1 -0
  389. package/dist/hooks/plugin-patterns/index.js +289 -0
  390. package/dist/hooks/plugin-patterns/index.js.map +1 -0
  391. package/dist/hooks/preemptive-compaction/constants.d.ts +48 -0
  392. package/dist/hooks/preemptive-compaction/constants.d.ts.map +1 -0
  393. package/dist/hooks/preemptive-compaction/constants.js +90 -0
  394. package/dist/hooks/preemptive-compaction/constants.js.map +1 -0
  395. package/dist/hooks/preemptive-compaction/index.d.ts +55 -0
  396. package/dist/hooks/preemptive-compaction/index.d.ts.map +1 -0
  397. package/dist/hooks/preemptive-compaction/index.js +227 -0
  398. package/dist/hooks/preemptive-compaction/index.js.map +1 -0
  399. package/dist/hooks/preemptive-compaction/types.d.ts +76 -0
  400. package/dist/hooks/preemptive-compaction/types.d.ts.map +1 -0
  401. package/dist/hooks/preemptive-compaction/types.js +9 -0
  402. package/dist/hooks/preemptive-compaction/types.js.map +1 -0
  403. package/dist/hooks/ralph-loop/index.d.ts +60 -0
  404. package/dist/hooks/ralph-loop/index.d.ts.map +1 -0
  405. package/dist/hooks/ralph-loop/index.js +155 -0
  406. package/dist/hooks/ralph-loop/index.js.map +1 -0
  407. package/dist/hooks/ralph-verifier/index.d.ts +72 -0
  408. package/dist/hooks/ralph-verifier/index.d.ts.map +1 -0
  409. package/dist/hooks/ralph-verifier/index.js +223 -0
  410. package/dist/hooks/ralph-verifier/index.js.map +1 -0
  411. package/dist/hooks/rules-injector/constants.d.ts +25 -0
  412. package/dist/hooks/rules-injector/constants.d.ts.map +1 -0
  413. package/dist/hooks/rules-injector/constants.js +40 -0
  414. package/dist/hooks/rules-injector/constants.js.map +1 -0
  415. package/dist/hooks/rules-injector/finder.d.ts +24 -0
  416. package/dist/hooks/rules-injector/finder.d.ts.map +1 -0
  417. package/dist/hooks/rules-injector/finder.js +215 -0
  418. package/dist/hooks/rules-injector/finder.js.map +1 -0
  419. package/dist/hooks/rules-injector/index.d.ts +45 -0
  420. package/dist/hooks/rules-injector/index.d.ts.map +1 -0
  421. package/dist/hooks/rules-injector/index.js +187 -0
  422. package/dist/hooks/rules-injector/index.js.map +1 -0
  423. package/dist/hooks/rules-injector/matcher.d.ts +25 -0
  424. package/dist/hooks/rules-injector/matcher.d.ts.map +1 -0
  425. package/dist/hooks/rules-injector/matcher.js +70 -0
  426. package/dist/hooks/rules-injector/matcher.js.map +1 -0
  427. package/dist/hooks/rules-injector/parser.d.ts +20 -0
  428. package/dist/hooks/rules-injector/parser.d.ts.map +1 -0
  429. package/dist/hooks/rules-injector/parser.js +179 -0
  430. package/dist/hooks/rules-injector/parser.js.map +1 -0
  431. package/dist/hooks/rules-injector/storage.d.ts +26 -0
  432. package/dist/hooks/rules-injector/storage.d.ts.map +1 -0
  433. package/dist/hooks/rules-injector/storage.js +61 -0
  434. package/dist/hooks/rules-injector/storage.js.map +1 -0
  435. package/dist/hooks/rules-injector/types.d.ts +101 -0
  436. package/dist/hooks/rules-injector/types.d.ts.map +1 -0
  437. package/dist/hooks/rules-injector/types.js +10 -0
  438. package/dist/hooks/rules-injector/types.js.map +1 -0
  439. package/dist/hooks/session-recovery/constants.d.ts +56 -0
  440. package/dist/hooks/session-recovery/constants.d.ts.map +1 -0
  441. package/dist/hooks/session-recovery/constants.js +78 -0
  442. package/dist/hooks/session-recovery/constants.js.map +1 -0
  443. package/dist/hooks/session-recovery/index.d.ts +53 -0
  444. package/dist/hooks/session-recovery/index.d.ts.map +1 -0
  445. package/dist/hooks/session-recovery/index.js +321 -0
  446. package/dist/hooks/session-recovery/index.js.map +1 -0
  447. package/dist/hooks/session-recovery/storage.d.ts +76 -0
  448. package/dist/hooks/session-recovery/storage.d.ts.map +1 -0
  449. package/dist/hooks/session-recovery/storage.js +383 -0
  450. package/dist/hooks/session-recovery/storage.js.map +1 -0
  451. package/dist/hooks/session-recovery/types.d.ts +145 -0
  452. package/dist/hooks/session-recovery/types.d.ts.map +1 -0
  453. package/dist/hooks/session-recovery/types.js +8 -0
  454. package/dist/hooks/session-recovery/types.js.map +1 -0
  455. package/dist/hooks/sisyphus-orchestrator/constants.d.ts +23 -0
  456. package/dist/hooks/sisyphus-orchestrator/constants.d.ts.map +1 -0
  457. package/dist/hooks/sisyphus-orchestrator/constants.js +142 -0
  458. package/dist/hooks/sisyphus-orchestrator/constants.js.map +1 -0
  459. package/dist/hooks/sisyphus-orchestrator/index.d.ts +113 -0
  460. package/dist/hooks/sisyphus-orchestrator/index.d.ts.map +1 -0
  461. package/dist/hooks/sisyphus-orchestrator/index.js +283 -0
  462. package/dist/hooks/sisyphus-orchestrator/index.js.map +1 -0
  463. package/dist/hooks/the-ascent/index.d.ts +60 -0
  464. package/dist/hooks/the-ascent/index.d.ts.map +1 -0
  465. package/dist/hooks/the-ascent/index.js +155 -0
  466. package/dist/hooks/the-ascent/index.js.map +1 -0
  467. package/dist/hooks/think-mode/detector.d.ts +28 -0
  468. package/dist/hooks/think-mode/detector.d.ts.map +1 -0
  469. package/dist/hooks/think-mode/detector.js +105 -0
  470. package/dist/hooks/think-mode/detector.js.map +1 -0
  471. package/dist/hooks/think-mode/index.d.ts +70 -0
  472. package/dist/hooks/think-mode/index.d.ts.map +1 -0
  473. package/dist/hooks/think-mode/index.js +144 -0
  474. package/dist/hooks/think-mode/index.js.map +1 -0
  475. package/dist/hooks/think-mode/switcher.d.ts +39 -0
  476. package/dist/hooks/think-mode/switcher.d.ts.map +1 -0
  477. package/dist/hooks/think-mode/switcher.js +180 -0
  478. package/dist/hooks/think-mode/switcher.js.map +1 -0
  479. package/dist/hooks/think-mode/types.d.ts +60 -0
  480. package/dist/hooks/think-mode/types.d.ts.map +1 -0
  481. package/dist/hooks/think-mode/types.js +9 -0
  482. package/dist/hooks/think-mode/types.js.map +1 -0
  483. package/dist/hooks/thinking-block-validator/constants.d.ts +37 -0
  484. package/dist/hooks/thinking-block-validator/constants.d.ts.map +1 -0
  485. package/dist/hooks/thinking-block-validator/constants.js +50 -0
  486. package/dist/hooks/thinking-block-validator/constants.js.map +1 -0
  487. package/dist/hooks/thinking-block-validator/index.d.ts +35 -0
  488. package/dist/hooks/thinking-block-validator/index.d.ts.map +1 -0
  489. package/dist/hooks/thinking-block-validator/index.js +156 -0
  490. package/dist/hooks/thinking-block-validator/index.js.map +1 -0
  491. package/dist/hooks/thinking-block-validator/types.d.ts +67 -0
  492. package/dist/hooks/thinking-block-validator/types.d.ts.map +1 -0
  493. package/dist/hooks/thinking-block-validator/types.js +9 -0
  494. package/dist/hooks/thinking-block-validator/types.js.map +1 -0
  495. package/dist/hooks/todo-continuation/index.d.ts +39 -0
  496. package/dist/hooks/todo-continuation/index.d.ts.map +1 -0
  497. package/dist/hooks/todo-continuation/index.js +140 -0
  498. package/dist/hooks/todo-continuation/index.js.map +1 -0
  499. package/dist/hooks/ultrawork-state/index.d.ts +60 -0
  500. package/dist/hooks/ultrawork-state/index.d.ts.map +1 -0
  501. package/dist/hooks/ultrawork-state/index.js +207 -0
  502. package/dist/hooks/ultrawork-state/index.js.map +1 -0
  503. package/dist/index.d.ts +117 -0
  504. package/dist/index.d.ts.map +1 -0
  505. package/dist/index.js +175 -0
  506. package/dist/index.js.map +1 -0
  507. package/dist/installer/hooks.d.ts +196 -0
  508. package/dist/installer/hooks.d.ts.map +1 -0
  509. package/dist/installer/hooks.js +1385 -0
  510. package/dist/installer/hooks.js.map +1 -0
  511. package/dist/installer/index.d.ts +92 -0
  512. package/dist/installer/index.d.ts.map +1 -0
  513. package/dist/installer/index.js +2249 -0
  514. package/dist/installer/index.js.map +1 -0
  515. package/dist/mcp/index.d.ts +6 -0
  516. package/dist/mcp/index.d.ts.map +1 -0
  517. package/dist/mcp/index.js +5 -0
  518. package/dist/mcp/index.js.map +1 -0
  519. package/dist/mcp/servers.d.ts +77 -0
  520. package/dist/mcp/servers.d.ts.map +1 -0
  521. package/dist/mcp/servers.js +122 -0
  522. package/dist/mcp/servers.js.map +1 -0
  523. package/dist/shared/index.d.ts +5 -0
  524. package/dist/shared/index.d.ts.map +1 -0
  525. package/dist/shared/index.js +5 -0
  526. package/dist/shared/index.js.map +1 -0
  527. package/dist/shared/types.d.ts +159 -0
  528. package/dist/shared/types.d.ts.map +1 -0
  529. package/dist/shared/types.js +5 -0
  530. package/dist/shared/types.js.map +1 -0
  531. package/dist/tools/ast-tools.d.ts +63 -0
  532. package/dist/tools/ast-tools.d.ts.map +1 -0
  533. package/dist/tools/ast-tools.js +450 -0
  534. package/dist/tools/ast-tools.js.map +1 -0
  535. package/dist/tools/index.d.ts +52 -0
  536. package/dist/tools/index.d.ts.map +1 -0
  537. package/dist/tools/index.js +120 -0
  538. package/dist/tools/index.js.map +1 -0
  539. package/dist/tools/lsp/client.d.ts +201 -0
  540. package/dist/tools/lsp/client.d.ts.map +1 -0
  541. package/dist/tools/lsp/client.js +454 -0
  542. package/dist/tools/lsp/client.js.map +1 -0
  543. package/dist/tools/lsp/index.d.ts +9 -0
  544. package/dist/tools/lsp/index.d.ts.map +1 -0
  545. package/dist/tools/lsp/index.js +7 -0
  546. package/dist/tools/lsp/index.js.map +1 -0
  547. package/dist/tools/lsp/servers.d.ts +37 -0
  548. package/dist/tools/lsp/servers.d.ts.map +1 -0
  549. package/dist/tools/lsp/servers.js +149 -0
  550. package/dist/tools/lsp/servers.js.map +1 -0
  551. package/dist/tools/lsp/utils.d.ts +58 -0
  552. package/dist/tools/lsp/utils.d.ts.map +1 -0
  553. package/dist/tools/lsp/utils.js +236 -0
  554. package/dist/tools/lsp/utils.js.map +1 -0
  555. package/dist/tools/lsp-tools.d.ts +151 -0
  556. package/dist/tools/lsp-tools.d.ts.map +1 -0
  557. package/dist/tools/lsp-tools.js +358 -0
  558. package/dist/tools/lsp-tools.js.map +1 -0
  559. package/package.json +85 -0
  560. package/scripts/claude-sisyphus.sh +9 -0
  561. package/scripts/install.sh +1774 -0
  562. package/scripts/keyword-detector.mjs +209 -0
  563. package/scripts/keyword-detector.sh +71 -0
  564. package/scripts/persistent-mode.mjs +241 -0
  565. package/scripts/persistent-mode.sh +300 -0
  566. package/scripts/post-tool-verifier.mjs +217 -0
  567. package/scripts/post-tool-verifier.sh +196 -0
  568. package/scripts/pre-tool-enforcer.mjs +99 -0
  569. package/scripts/pre-tool-enforcer.sh +76 -0
  570. package/scripts/sisyphus-aliases.sh +18 -0
  571. package/scripts/stop-continuation.sh +31 -0
  572. package/scripts/test-pr25.sh +525 -0
  573. package/scripts/uninstall.sh +171 -0
@@ -0,0 +1,180 @@
1
+ /**
2
+ * Think Mode Switcher
3
+ *
4
+ * Handles model switching to high-reasoning variants when think mode is activated.
5
+ * Supports Claude, GPT, and Gemini model families.
6
+ *
7
+ * Ported from oh-my-opencode's think-mode hook.
8
+ */
9
+ /**
10
+ * Extract provider prefix from model ID.
11
+ * Custom providers may use prefixes like vertex_ai/, openai/.
12
+ */
13
+ function extractModelPrefix(modelId) {
14
+ const slashIndex = modelId.indexOf('/');
15
+ if (slashIndex === -1) {
16
+ return { prefix: '', base: modelId };
17
+ }
18
+ return {
19
+ prefix: modelId.slice(0, slashIndex + 1),
20
+ base: modelId.slice(slashIndex + 1),
21
+ };
22
+ }
23
+ /**
24
+ * Normalize model ID to use consistent hyphen formatting.
25
+ * Handles version numbers like 4.5 → 4-5.
26
+ */
27
+ function normalizeModelId(modelId) {
28
+ return modelId.replace(/\.(\d+)/g, '-$1');
29
+ }
30
+ /**
31
+ * Map of model IDs to their high-reasoning variants.
32
+ */
33
+ const HIGH_VARIANT_MAP = {
34
+ // Claude
35
+ 'claude-sonnet-4-5': 'claude-sonnet-4-5-high',
36
+ 'claude-opus-4-5': 'claude-opus-4-5-high',
37
+ 'claude-3-5-sonnet': 'claude-3-5-sonnet-high',
38
+ 'claude-3-opus': 'claude-3-opus-high',
39
+ // GPT-4
40
+ 'gpt-4': 'gpt-4-high',
41
+ 'gpt-4-turbo': 'gpt-4-turbo-high',
42
+ 'gpt-4o': 'gpt-4o-high',
43
+ // GPT-5
44
+ 'gpt-5': 'gpt-5-high',
45
+ 'gpt-5-mini': 'gpt-5-mini-high',
46
+ // Gemini
47
+ 'gemini-2-pro': 'gemini-2-pro-high',
48
+ 'gemini-3-pro': 'gemini-3-pro-high',
49
+ 'gemini-3-flash': 'gemini-3-flash-high',
50
+ };
51
+ /** Set of models already in high variant */
52
+ const ALREADY_HIGH = new Set(Object.values(HIGH_VARIANT_MAP));
53
+ /**
54
+ * Provider-specific thinking configurations.
55
+ */
56
+ export const THINKING_CONFIGS = {
57
+ anthropic: {
58
+ thinking: {
59
+ type: 'enabled',
60
+ budgetTokens: 64000,
61
+ },
62
+ maxTokens: 128000,
63
+ },
64
+ 'amazon-bedrock': {
65
+ reasoningConfig: {
66
+ type: 'enabled',
67
+ budgetTokens: 32000,
68
+ },
69
+ maxTokens: 64000,
70
+ },
71
+ google: {
72
+ providerOptions: {
73
+ google: {
74
+ thinkingConfig: {
75
+ thinkingLevel: 'HIGH',
76
+ },
77
+ },
78
+ },
79
+ },
80
+ openai: {
81
+ reasoning_effort: 'high',
82
+ },
83
+ };
84
+ /**
85
+ * Models capable of thinking mode by provider.
86
+ */
87
+ const THINKING_CAPABLE_MODELS = {
88
+ anthropic: ['claude-sonnet-4', 'claude-opus-4', 'claude-3'],
89
+ 'amazon-bedrock': ['claude', 'anthropic'],
90
+ google: ['gemini-2', 'gemini-3'],
91
+ openai: ['gpt-4', 'gpt-5', 'o1', 'o3'],
92
+ };
93
+ /**
94
+ * Get the high-reasoning variant for a model ID.
95
+ * Returns null if already high or no variant exists.
96
+ */
97
+ export function getHighVariant(modelId) {
98
+ const normalized = normalizeModelId(modelId);
99
+ const { prefix, base } = extractModelPrefix(normalized);
100
+ // Check if already high variant
101
+ if (ALREADY_HIGH.has(base) || base.endsWith('-high')) {
102
+ return null;
103
+ }
104
+ // Look up high variant
105
+ const highBase = HIGH_VARIANT_MAP[base];
106
+ if (!highBase) {
107
+ return null;
108
+ }
109
+ // Preserve prefix in the high variant
110
+ return prefix + highBase;
111
+ }
112
+ /**
113
+ * Check if a model is already in high variant mode.
114
+ */
115
+ export function isAlreadyHighVariant(modelId) {
116
+ const normalized = normalizeModelId(modelId);
117
+ const { base } = extractModelPrefix(normalized);
118
+ return ALREADY_HIGH.has(base) || base.endsWith('-high');
119
+ }
120
+ /**
121
+ * Resolve proxy providers to their underlying provider.
122
+ */
123
+ function resolveProvider(providerId, modelId) {
124
+ // GitHub Copilot is a proxy - infer actual provider from model name
125
+ if (providerId === 'github-copilot') {
126
+ const modelLower = modelId.toLowerCase();
127
+ if (modelLower.includes('claude'))
128
+ return 'anthropic';
129
+ if (modelLower.includes('gemini'))
130
+ return 'google';
131
+ if (modelLower.includes('gpt') || modelLower.includes('o1') || modelLower.includes('o3')) {
132
+ return 'openai';
133
+ }
134
+ }
135
+ return providerId;
136
+ }
137
+ /**
138
+ * Check if provider has thinking configuration.
139
+ */
140
+ function isThinkingProvider(provider) {
141
+ return provider in THINKING_CONFIGS;
142
+ }
143
+ /**
144
+ * Get the thinking configuration for a provider and model.
145
+ * Returns null if not supported or already in high mode.
146
+ */
147
+ export function getThinkingConfig(providerId, modelId) {
148
+ const normalized = normalizeModelId(modelId);
149
+ const { base } = extractModelPrefix(normalized);
150
+ if (isAlreadyHighVariant(normalized)) {
151
+ return null;
152
+ }
153
+ const resolvedProvider = resolveProvider(providerId, modelId);
154
+ if (!isThinkingProvider(resolvedProvider)) {
155
+ return null;
156
+ }
157
+ const config = THINKING_CONFIGS[resolvedProvider];
158
+ const capablePatterns = THINKING_CAPABLE_MODELS[resolvedProvider];
159
+ if (!capablePatterns) {
160
+ return null;
161
+ }
162
+ // Check capability using base model name
163
+ const baseLower = base.toLowerCase();
164
+ const isCapable = capablePatterns.some((pattern) => baseLower.includes(pattern.toLowerCase()));
165
+ return isCapable ? config : null;
166
+ }
167
+ /**
168
+ * Get Claude-specific thinking configuration.
169
+ * This is used by Claude Code for extended thinking.
170
+ */
171
+ export function getClaudeThinkingConfig(budgetTokens = 64000) {
172
+ return {
173
+ thinking: {
174
+ type: 'enabled',
175
+ budgetTokens,
176
+ },
177
+ maxTokens: 128000,
178
+ };
179
+ }
180
+ //# sourceMappingURL=switcher.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switcher.js","sourceRoot":"","sources":["../../../src/hooks/think-mode/switcher.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH;;;GAGG;AACH,SAAS,kBAAkB,CAAC,OAAe;IACzC,MAAM,UAAU,GAAG,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;IACxC,IAAI,UAAU,KAAK,CAAC,CAAC,EAAE,CAAC;QACtB,OAAO,EAAE,MAAM,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;IACvC,CAAC;IACD,OAAO;QACL,MAAM,EAAE,OAAO,CAAC,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,CAAC,CAAC;QACxC,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,CAAC,CAAC;KACpC,CAAC;AACJ,CAAC;AAED;;;GAGG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACvC,OAAO,OAAO,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AAC5C,CAAC;AAED;;GAEG;AACH,MAAM,gBAAgB,GAA2B;IAC/C,SAAS;IACT,mBAAmB,EAAE,wBAAwB;IAC7C,iBAAiB,EAAE,sBAAsB;IACzC,mBAAmB,EAAE,wBAAwB;IAC7C,eAAe,EAAE,oBAAoB;IACrC,QAAQ;IACR,OAAO,EAAE,YAAY;IACrB,aAAa,EAAE,kBAAkB;IACjC,QAAQ,EAAE,aAAa;IACvB,QAAQ;IACR,OAAO,EAAE,YAAY;IACrB,YAAY,EAAE,iBAAiB;IAC/B,SAAS;IACT,cAAc,EAAE,mBAAmB;IACnC,cAAc,EAAE,mBAAmB;IACnC,gBAAgB,EAAE,qBAAqB;CACxC,CAAC;AAEF,4CAA4C;AAC5C,MAAM,YAAY,GAAgB,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC;AAE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CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,gBAAgB,GAAG,eAAe,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IAE9D,IAAI,CAAC,kBAAkB,CAAC,gBAAgB,CAAC,EAAE,CAAC;QAC1C,OAAO,IAAI,CAAC;IACd,CAAC;IAED,MAAM,MAAM,GAAG,gBAAgB,CAAC,gBAAgB,CAAC,CAAC;IAClD,MAAM,eAAe,GAAG,uBAAuB,CAAC,gBAAgB,CAAC,CAAC;IAElE,IAAI,CAAC,eAAe,EAAE,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yCAAyC;IACzC,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACrC,MAAM,SAAS,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CACjD,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC,CAC1C,CAAC;IAEF,OAAO,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC;AACnC,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,uBAAuB,CAAC,eAAuB,KAAK;IAClE,OAAO;QACL,QAAQ,EAAE;YACR,IAAI,EAAE,SAAkB;YACxB,YAAY;SACb;QACD,SAAS,EAAE,MAAM;KAClB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Think Mode Types
3
+ *
4
+ * Type definitions for think mode state and configuration.
5
+ *
6
+ * Ported from oh-my-opencode's think-mode hook.
7
+ */
8
+ /**
9
+ * State tracking for think mode in a session
10
+ */
11
+ export interface ThinkModeState {
12
+ /** Whether think mode was requested via keyword */
13
+ requested: boolean;
14
+ /** Whether model was switched to high variant */
15
+ modelSwitched: boolean;
16
+ /** Whether thinking config was injected */
17
+ thinkingConfigInjected: boolean;
18
+ /** Provider ID if known */
19
+ providerId?: string;
20
+ /** Model ID if known */
21
+ modelId?: string;
22
+ }
23
+ /**
24
+ * Model reference with provider and model ID
25
+ */
26
+ export interface ModelRef {
27
+ providerId: string;
28
+ modelId: string;
29
+ }
30
+ /**
31
+ * Message with optional model reference
32
+ */
33
+ export interface MessageWithModel {
34
+ model?: ModelRef;
35
+ }
36
+ /**
37
+ * Input for think mode hook processing
38
+ */
39
+ export interface ThinkModeInput {
40
+ parts: Array<{
41
+ type: string;
42
+ text?: string;
43
+ }>;
44
+ message: MessageWithModel;
45
+ }
46
+ /**
47
+ * Thinking configuration for Claude models
48
+ */
49
+ export interface ClaudeThinkingConfig {
50
+ thinking: {
51
+ type: 'enabled' | 'disabled';
52
+ budgetTokens: number;
53
+ };
54
+ maxTokens?: number;
55
+ }
56
+ /**
57
+ * Provider-specific thinking configurations
58
+ */
59
+ export type ThinkingConfig = Record<string, unknown>;
60
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/think-mode/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,mDAAmD;IACnD,SAAS,EAAE,OAAO,CAAC;IACnB,iDAAiD;IACjD,aAAa,EAAE,OAAO,CAAC;IACvB,2CAA2C;IAC3C,sBAAsB,EAAE,OAAO,CAAC;IAChC,2BAA2B;IAC3B,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wBAAwB;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,KAAK,CAAC,EAAE,QAAQ,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,KAAK,EAAE,KAAK,CAAC;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IAC9C,OAAO,EAAE,gBAAgB,CAAC;CAC3B;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE;QACR,IAAI,EAAE,SAAS,GAAG,UAAU,CAAC;QAC7B,YAAY,EAAE,MAAM,CAAC;KACtB,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Think Mode Types
3
+ *
4
+ * Type definitions for think mode state and configuration.
5
+ *
6
+ * Ported from oh-my-opencode's think-mode hook.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/think-mode/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Thinking Block Validator Constants
3
+ *
4
+ * Constants for validation patterns, messages, and model detection.
5
+ *
6
+ * Ported from oh-my-opencode's thinking-block-validator hook.
7
+ */
8
+ /**
9
+ * Hook name identifier
10
+ */
11
+ export declare const HOOK_NAME = "thinking-block-validator";
12
+ /**
13
+ * Part types that are considered "content" (non-thinking)
14
+ */
15
+ export declare const CONTENT_PART_TYPES: readonly ["tool", "tool_use", "text"];
16
+ /**
17
+ * Part types that are considered "thinking"
18
+ */
19
+ export declare const THINKING_PART_TYPES: readonly ["thinking", "reasoning"];
20
+ /**
21
+ * Model patterns that support extended thinking
22
+ * Aligns with think-mode/switcher.ts patterns
23
+ */
24
+ export declare const THINKING_MODEL_PATTERNS: readonly ["thinking", "-high", "claude-sonnet-4", "claude-opus-4", "claude-3"];
25
+ /**
26
+ * Default thinking content for synthetic blocks
27
+ */
28
+ export declare const DEFAULT_THINKING_CONTENT = "[Continuing from previous reasoning]";
29
+ /**
30
+ * Prefix for synthetic thinking part IDs
31
+ */
32
+ export declare const SYNTHETIC_THINKING_ID_PREFIX = "prt_0000000000_synthetic_thinking";
33
+ /**
34
+ * Error message that this hook prevents
35
+ */
36
+ export declare const PREVENTED_ERROR = "Expected thinking/redacted_thinking but found tool_use";
37
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/hooks/thinking-block-validator/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,6BAA6B,CAAC;AAEpD;;GAEG;AACH,eAAO,MAAM,kBAAkB,uCAIrB,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,mBAAmB,oCAGtB,CAAC;AAEX;;;GAGG;AACH,eAAO,MAAM,uBAAuB,gFAM1B,CAAC;AAEX;;GAEG;AACH,eAAO,MAAM,wBAAwB,yCAAyC,CAAC;AAE/E;;GAEG;AACH,eAAO,MAAM,4BAA4B,sCAAsC,CAAC;AAEhF;;GAEG;AACH,eAAO,MAAM,eAAe,2DAA2D,CAAC"}
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Thinking Block Validator Constants
3
+ *
4
+ * Constants for validation patterns, messages, and model detection.
5
+ *
6
+ * Ported from oh-my-opencode's thinking-block-validator hook.
7
+ */
8
+ /**
9
+ * Hook name identifier
10
+ */
11
+ export const HOOK_NAME = "thinking-block-validator";
12
+ /**
13
+ * Part types that are considered "content" (non-thinking)
14
+ */
15
+ export const CONTENT_PART_TYPES = [
16
+ "tool",
17
+ "tool_use",
18
+ "text"
19
+ ];
20
+ /**
21
+ * Part types that are considered "thinking"
22
+ */
23
+ export const THINKING_PART_TYPES = [
24
+ "thinking",
25
+ "reasoning"
26
+ ];
27
+ /**
28
+ * Model patterns that support extended thinking
29
+ * Aligns with think-mode/switcher.ts patterns
30
+ */
31
+ export const THINKING_MODEL_PATTERNS = [
32
+ "thinking",
33
+ "-high",
34
+ "claude-sonnet-4",
35
+ "claude-opus-4",
36
+ "claude-3"
37
+ ];
38
+ /**
39
+ * Default thinking content for synthetic blocks
40
+ */
41
+ export const DEFAULT_THINKING_CONTENT = "[Continuing from previous reasoning]";
42
+ /**
43
+ * Prefix for synthetic thinking part IDs
44
+ */
45
+ export const SYNTHETIC_THINKING_ID_PREFIX = "prt_0000000000_synthetic_thinking";
46
+ /**
47
+ * Error message that this hook prevents
48
+ */
49
+ export const PREVENTED_ERROR = "Expected thinking/redacted_thinking but found tool_use";
50
+ //# sourceMappingURL=constants.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/hooks/thinking-block-validator/constants.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;GAEG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,0BAA0B,CAAC;AAEpD;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG;IAChC,MAAM;IACN,UAAU;IACV,MAAM;CACE,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,UAAU;IACV,WAAW;CACH,CAAC;AAEX;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG;IACrC,UAAU;IACV,OAAO;IACP,iBAAiB;IACjB,eAAe;IACf,UAAU;CACF,CAAC;AAEX;;GAEG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,sCAAsC,CAAC;AAE/E;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,mCAAmC,CAAC;AAEhF;;GAEG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,wDAAwD,CAAC"}
@@ -0,0 +1,35 @@
1
+ /**
2
+ * Proactive Thinking Block Validator Hook
3
+ *
4
+ * Prevents "Expected thinking/redacted_thinking but found tool_use" errors
5
+ * by validating and fixing message structure BEFORE sending to Anthropic API.
6
+ *
7
+ * This hook runs on the "experimental.chat.messages.transform" hook point,
8
+ * which is called before messages are converted to ModelMessage format and
9
+ * sent to the API.
10
+ *
11
+ * Key differences from session-recovery hook:
12
+ * - PROACTIVE (prevents error) vs REACTIVE (fixes after error)
13
+ * - Runs BEFORE API call vs AFTER API error
14
+ * - User never sees the error vs User sees error then recovery
15
+ *
16
+ * Ported from oh-my-opencode's thinking-block-validator hook.
17
+ */
18
+ import type { MessagePart, MessageWithParts, MessagesTransformHook, ValidationResult } from "./types.js";
19
+ export * from "./types.js";
20
+ export * from "./constants.js";
21
+ export declare function isExtendedThinkingModel(modelID: string): boolean;
22
+ export declare function hasContentParts(parts: MessagePart[]): boolean;
23
+ export declare function startsWithThinkingBlock(parts: MessagePart[]): boolean;
24
+ export declare function findPreviousThinkingContent(messages: MessageWithParts[], currentIndex: number): string;
25
+ export declare function prependThinkingBlock(message: MessageWithParts, thinkingContent: string): void;
26
+ export declare function validateMessage(message: MessageWithParts, messages: MessageWithParts[], index: number, modelID: string): ValidationResult;
27
+ export declare function createThinkingBlockValidatorHook(): MessagesTransformHook;
28
+ export declare function validateMessages(messages: MessageWithParts[], modelID: string): ValidationResult[];
29
+ export declare function getValidationStats(results: ValidationResult[]): {
30
+ total: number;
31
+ valid: number;
32
+ fixed: number;
33
+ issues: number;
34
+ };
35
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/hooks/thinking-block-validator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EACV,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,gBAAgB,EACjB,MAAM,YAAY,CAAC;AAUpB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAU/B,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAahE;AAED,wBAAgB,eAAe,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAI7D;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,WAAW,EAAE,GAAG,OAAO,CAKrE;AAED,wBAAgB,2BAA2B,CACzC,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,YAAY,EAAE,MAAM,GACnB,MAAM,CAqBR;AAED,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,gBAAgB,EACzB,eAAe,EAAE,MAAM,GACtB,IAAI,CAeN;AAED,wBAAgB,eAAe,CAC7B,OAAO,EAAE,gBAAgB,EACzB,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,MAAM,GACd,gBAAgB,CA2BlB;AAED,wBAAgB,gCAAgC,IAAI,qBAAqB,CA4CxE;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,gBAAgB,EAAE,EAC5B,OAAO,EAAE,MAAM,GACd,gBAAgB,EAAE,CASpB;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,gBAAgB,EAAE,GAAG;IAC/D,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;CAChB,CAOA"}
@@ -0,0 +1,156 @@
1
+ /**
2
+ * Proactive Thinking Block Validator Hook
3
+ *
4
+ * Prevents "Expected thinking/redacted_thinking but found tool_use" errors
5
+ * by validating and fixing message structure BEFORE sending to Anthropic API.
6
+ *
7
+ * This hook runs on the "experimental.chat.messages.transform" hook point,
8
+ * which is called before messages are converted to ModelMessage format and
9
+ * sent to the API.
10
+ *
11
+ * Key differences from session-recovery hook:
12
+ * - PROACTIVE (prevents error) vs REACTIVE (fixes after error)
13
+ * - Runs BEFORE API call vs AFTER API error
14
+ * - User never sees the error vs User sees error then recovery
15
+ *
16
+ * Ported from oh-my-opencode's thinking-block-validator hook.
17
+ */
18
+ import { CONTENT_PART_TYPES, THINKING_PART_TYPES, DEFAULT_THINKING_CONTENT, SYNTHETIC_THINKING_ID_PREFIX, HOOK_NAME, } from "./constants.js";
19
+ export * from "./types.js";
20
+ export * from "./constants.js";
21
+ function isContentPartType(type) {
22
+ return CONTENT_PART_TYPES.includes(type);
23
+ }
24
+ function isThinkingPartType(type) {
25
+ return THINKING_PART_TYPES.includes(type);
26
+ }
27
+ export function isExtendedThinkingModel(modelID) {
28
+ if (!modelID)
29
+ return false;
30
+ const lower = modelID.toLowerCase();
31
+ if (lower.includes("thinking") || lower.endsWith("-high")) {
32
+ return true;
33
+ }
34
+ return (lower.includes("claude-sonnet-4") ||
35
+ lower.includes("claude-opus-4") ||
36
+ lower.includes("claude-3"));
37
+ }
38
+ export function hasContentParts(parts) {
39
+ if (!parts || parts.length === 0)
40
+ return false;
41
+ return parts.some((part) => isContentPartType(part.type));
42
+ }
43
+ export function startsWithThinkingBlock(parts) {
44
+ if (!parts || parts.length === 0)
45
+ return false;
46
+ const firstPart = parts[0];
47
+ return isThinkingPartType(firstPart.type);
48
+ }
49
+ export function findPreviousThinkingContent(messages, currentIndex) {
50
+ for (let i = currentIndex - 1; i >= 0; i--) {
51
+ const msg = messages[i];
52
+ if (msg.info.role !== "assistant")
53
+ continue;
54
+ if (!msg.parts)
55
+ continue;
56
+ for (const part of msg.parts) {
57
+ if (isThinkingPartType(part.type)) {
58
+ const thinking = part.thinking || part.text;
59
+ if (thinking &&
60
+ typeof thinking === "string" &&
61
+ thinking.trim().length > 0) {
62
+ return thinking;
63
+ }
64
+ }
65
+ }
66
+ }
67
+ return "";
68
+ }
69
+ export function prependThinkingBlock(message, thinkingContent) {
70
+ if (!message.parts) {
71
+ message.parts = [];
72
+ }
73
+ const thinkingPart = {
74
+ type: "thinking",
75
+ id: SYNTHETIC_THINKING_ID_PREFIX,
76
+ sessionID: message.info.sessionID || "",
77
+ messageID: message.info.id,
78
+ thinking: thinkingContent,
79
+ synthetic: true,
80
+ };
81
+ message.parts.unshift(thinkingPart);
82
+ }
83
+ export function validateMessage(message, messages, index, modelID) {
84
+ if (message.info.role !== "assistant") {
85
+ return { valid: true, fixed: false };
86
+ }
87
+ if (!isExtendedThinkingModel(modelID)) {
88
+ return { valid: true, fixed: false };
89
+ }
90
+ if (hasContentParts(message.parts) &&
91
+ !startsWithThinkingBlock(message.parts)) {
92
+ const previousThinking = findPreviousThinkingContent(messages, index);
93
+ const thinkingContent = previousThinking || DEFAULT_THINKING_CONTENT;
94
+ prependThinkingBlock(message, thinkingContent);
95
+ return {
96
+ valid: false,
97
+ fixed: true,
98
+ issue: "Assistant message has content but no thinking block",
99
+ action: `Prepended synthetic thinking block: "${thinkingContent.substring(0, 50)}..."`,
100
+ };
101
+ }
102
+ return { valid: true, fixed: false };
103
+ }
104
+ export function createThinkingBlockValidatorHook() {
105
+ return {
106
+ "experimental.chat.messages.transform": async (_input, output) => {
107
+ const { messages } = output;
108
+ if (!messages || messages.length === 0) {
109
+ return;
110
+ }
111
+ let lastUserMessage;
112
+ for (let i = messages.length - 1; i >= 0; i--) {
113
+ if (messages[i].info.role === "user") {
114
+ lastUserMessage = messages[i];
115
+ break;
116
+ }
117
+ }
118
+ const modelID = lastUserMessage?.info?.modelID || "";
119
+ if (!isExtendedThinkingModel(modelID)) {
120
+ return;
121
+ }
122
+ let fixedCount = 0;
123
+ for (let i = 0; i < messages.length; i++) {
124
+ const msg = messages[i];
125
+ if (msg.info.role !== "assistant")
126
+ continue;
127
+ if (hasContentParts(msg.parts) && !startsWithThinkingBlock(msg.parts)) {
128
+ const previousThinking = findPreviousThinkingContent(messages, i);
129
+ const thinkingContent = previousThinking || DEFAULT_THINKING_CONTENT;
130
+ prependThinkingBlock(msg, thinkingContent);
131
+ fixedCount++;
132
+ }
133
+ }
134
+ if (fixedCount > 0 && process.env.DEBUG_THINKING_VALIDATOR) {
135
+ console.log(`[${HOOK_NAME}] Fixed ${fixedCount} message(s) by prepending thinking blocks`);
136
+ }
137
+ },
138
+ };
139
+ }
140
+ export function validateMessages(messages, modelID) {
141
+ const results = [];
142
+ for (let i = 0; i < messages.length; i++) {
143
+ const result = validateMessage(messages[i], messages, i, modelID);
144
+ results.push(result);
145
+ }
146
+ return results;
147
+ }
148
+ export function getValidationStats(results) {
149
+ return {
150
+ total: results.length,
151
+ valid: results.filter((r) => r.valid && !r.fixed).length,
152
+ fixed: results.filter((r) => r.fixed).length,
153
+ issues: results.filter((r) => !r.valid).length,
154
+ };
155
+ }
156
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/hooks/thinking-block-validator/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AASH,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,4BAA4B,EAC5B,SAAS,GACV,MAAM,gBAAgB,CAAC;AAExB,cAAc,YAAY,CAAC;AAC3B,cAAc,gBAAgB,CAAC;AAE/B,SAAS,iBAAiB,CAAC,IAAY;IACrC,OAAQ,kBAAwC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AAClE,CAAC;AAED,SAAS,kBAAkB,CAAC,IAAY;IACtC,OAAQ,mBAAyC,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACnE,CAAC;AAED,MAAM,UAAU,uBAAuB,CAAC,OAAe;IACrD,IAAI,CAAC,OAAO;QAAE,OAAO,KAAK,CAAC;IAC3B,MAAM,KAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAEpC,IAAI,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;QAC1D,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO,CACL,KAAK,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QACjC,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC;QAC/B,KAAK,CAAC,QAAQ,CAAC,UAAU,CAAC,CAC3B,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAAC,KAAoB;IAClD,I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AE,EAAE,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,MAAM;KAC/C,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Thinking Block Validator Types
3
+ *
4
+ * Type definitions for validating and fixing thinking blocks in assistant messages.
5
+ *
6
+ * Ported from oh-my-opencode's thinking-block-validator hook.
7
+ */
8
+ /**
9
+ * Message part representing different content types
10
+ */
11
+ export interface MessagePart {
12
+ type: string;
13
+ id?: string;
14
+ sessionID?: string;
15
+ messageID?: string;
16
+ thinking?: string;
17
+ text?: string;
18
+ synthetic?: boolean;
19
+ }
20
+ /**
21
+ * Message information
22
+ */
23
+ export interface MessageInfo {
24
+ id: string;
25
+ role: 'user' | 'assistant' | 'system';
26
+ sessionID?: string;
27
+ modelID?: string;
28
+ }
29
+ /**
30
+ * Message with parts array
31
+ */
32
+ export interface MessageWithParts {
33
+ info: MessageInfo;
34
+ parts: MessagePart[];
35
+ }
36
+ /**
37
+ * Input for messages transform hook
38
+ */
39
+ export interface MessagesTransformInput {
40
+ messages: MessageWithParts[];
41
+ }
42
+ /**
43
+ * Output for messages transform hook
44
+ */
45
+ export interface MessagesTransformOutput {
46
+ messages: MessageWithParts[];
47
+ }
48
+ /**
49
+ * Hook for transforming messages before API call
50
+ */
51
+ export interface MessagesTransformHook {
52
+ "experimental.chat.messages.transform"?: (input: Record<string, never>, output: MessagesTransformOutput) => Promise<void>;
53
+ }
54
+ /**
55
+ * Validation result for a message
56
+ */
57
+ export interface ValidationResult {
58
+ /** Whether the message is valid */
59
+ valid: boolean;
60
+ /** Whether the message was fixed */
61
+ fixed: boolean;
62
+ /** Description of the issue found */
63
+ issue?: string;
64
+ /** Action taken to fix the issue */
65
+ action?: string;
66
+ }
67
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/hooks/thinking-block-validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AA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types
3
+ *
4
+ * Type definitions for validating and fixing thinking blocks in assistant messages.
5
+ *
6
+ * Ported from oh-my-opencode's thinking-block-validator hook.
7
+ */
8
+ export {};
9
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/hooks/thinking-block-validator/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG"}