@a5c-ai/babysitter-sdk 0.0.187-staging.eb2fe8ce → 0.0.187-staging.fb5368f2

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 (421) hide show
  1. package/dist/api/index.d.ts +3 -0
  2. package/dist/api/index.d.ts.map +1 -0
  3. package/dist/api/index.js +9 -0
  4. package/dist/api/runs.d.ts +79 -0
  5. package/dist/api/runs.d.ts.map +1 -0
  6. package/dist/api/runs.js +246 -0
  7. package/dist/breakpoints/evaluator.d.ts +25 -0
  8. package/dist/breakpoints/evaluator.d.ts.map +1 -0
  9. package/dist/breakpoints/evaluator.js +72 -0
  10. package/dist/breakpoints/index.d.ts +7 -0
  11. package/dist/breakpoints/index.d.ts.map +1 -0
  12. package/dist/breakpoints/index.js +16 -0
  13. package/dist/breakpoints/patterns.d.ts +24 -0
  14. package/dist/breakpoints/patterns.d.ts.map +1 -0
  15. package/dist/breakpoints/patterns.js +88 -0
  16. package/dist/breakpoints/rules.d.ts +26 -0
  17. package/dist/breakpoints/rules.d.ts.map +1 -0
  18. package/dist/breakpoints/rules.js +110 -0
  19. package/dist/breakpoints/types.d.ts +48 -0
  20. package/dist/breakpoints/types.d.ts.map +1 -0
  21. package/dist/breakpoints/types.js +7 -0
  22. package/dist/cli/commandRegistry.d.ts +27 -0
  23. package/dist/cli/commandRegistry.d.ts.map +1 -0
  24. package/dist/cli/commandRegistry.js +126 -0
  25. package/dist/cli/commands/breakpointRules.d.ts +26 -0
  26. package/dist/cli/commands/breakpointRules.d.ts.map +1 -0
  27. package/dist/cli/commands/breakpointRules.js +219 -0
  28. package/dist/cli/commands/costStats.d.ts +13 -0
  29. package/dist/cli/commands/costStats.d.ts.map +1 -0
  30. package/dist/cli/commands/costStats.js +319 -0
  31. package/dist/cli/commands/harnessCreateRun.d.ts.map +1 -1
  32. package/dist/cli/commands/harnessCreateRun.js +13 -9
  33. package/dist/cli/commands/harnessPhase1.d.ts +1 -0
  34. package/dist/cli/commands/harnessPhase1.d.ts.map +1 -1
  35. package/dist/cli/commands/harnessPhase1.js +12 -12
  36. package/dist/cli/commands/harnessPhase2.d.ts +8 -0
  37. package/dist/cli/commands/harnessPhase2.d.ts.map +1 -1
  38. package/dist/cli/commands/harnessPhase2.js +289 -75
  39. package/dist/cli/commands/harnessPrompts.d.ts +1 -0
  40. package/dist/cli/commands/harnessPrompts.d.ts.map +1 -1
  41. package/dist/cli/commands/harnessPrompts.js +13 -0
  42. package/dist/cli/commands/harnessResumeRun.d.ts +1 -0
  43. package/dist/cli/commands/harnessResumeRun.d.ts.map +1 -1
  44. package/dist/cli/commands/harnessResumeRun.js +13 -11
  45. package/dist/cli/commands/harnessUtils.d.ts +18 -5
  46. package/dist/cli/commands/harnessUtils.d.ts.map +1 -1
  47. package/dist/cli/commands/harnessUtils.js +25 -8
  48. package/dist/cli/commands/instructions.d.ts +1 -0
  49. package/dist/cli/commands/instructions.d.ts.map +1 -1
  50. package/dist/cli/commands/instructions.js +33 -2
  51. package/dist/cli/commands/runIterate.d.ts +13 -0
  52. package/dist/cli/commands/runIterate.d.ts.map +1 -1
  53. package/dist/cli/commands/runIterate.js +21 -0
  54. package/dist/cli/commands/session.d.ts.map +1 -1
  55. package/dist/cli/commands/session.js +2 -0
  56. package/dist/cli/commands/sessionHistory.d.ts +14 -0
  57. package/dist/cli/commands/sessionHistory.d.ts.map +1 -0
  58. package/dist/cli/commands/sessionHistory.js +82 -0
  59. package/dist/cli/commands/tui.d.ts +25 -0
  60. package/dist/cli/commands/tui.d.ts.map +1 -0
  61. package/dist/cli/commands/tui.js +193 -0
  62. package/dist/cli/main.d.ts.map +1 -1
  63. package/dist/cli/main.js +242 -12
  64. package/dist/cost/claudeCodeParser.d.ts +81 -0
  65. package/dist/cost/claudeCodeParser.d.ts.map +1 -0
  66. package/dist/cost/claudeCodeParser.js +232 -0
  67. package/dist/cost/collector.d.ts +42 -0
  68. package/dist/cost/collector.d.ts.map +1 -0
  69. package/dist/cost/collector.js +105 -0
  70. package/dist/cost/effectCost.d.ts +21 -0
  71. package/dist/cost/effectCost.d.ts.map +1 -0
  72. package/dist/cost/effectCost.js +26 -0
  73. package/dist/cost/index.d.ts +19 -0
  74. package/dist/cost/index.d.ts.map +1 -0
  75. package/dist/cost/index.js +39 -0
  76. package/dist/cost/journal.d.ts +40 -0
  77. package/dist/cost/journal.d.ts.map +1 -0
  78. package/dist/cost/journal.js +137 -0
  79. package/dist/cost/types.d.ts +164 -0
  80. package/dist/cost/types.d.ts.map +1 -0
  81. package/dist/cost/types.js +231 -0
  82. package/dist/dashboard/colors.d.ts +26 -0
  83. package/dist/dashboard/colors.d.ts.map +1 -0
  84. package/dist/dashboard/colors.js +38 -0
  85. package/dist/dashboard/components/BreakpointApproval.d.ts +25 -0
  86. package/dist/dashboard/components/BreakpointApproval.d.ts.map +1 -0
  87. package/dist/dashboard/components/BreakpointApproval.js +77 -0
  88. package/dist/dashboard/components/EffectTree.d.ts +17 -0
  89. package/dist/dashboard/components/EffectTree.d.ts.map +1 -0
  90. package/dist/dashboard/components/EffectTree.js +53 -0
  91. package/dist/dashboard/components/KeyValue.d.ts +7 -0
  92. package/dist/dashboard/components/KeyValue.d.ts.map +1 -0
  93. package/dist/dashboard/components/KeyValue.js +19 -0
  94. package/dist/dashboard/components/ProgressBar.d.ts +7 -0
  95. package/dist/dashboard/components/ProgressBar.d.ts.map +1 -0
  96. package/dist/dashboard/components/ProgressBar.js +34 -0
  97. package/dist/dashboard/components/StatusBadge.d.ts +4 -0
  98. package/dist/dashboard/components/StatusBadge.d.ts.map +1 -0
  99. package/dist/dashboard/components/StatusBadge.js +28 -0
  100. package/dist/dashboard/components/StatusLine.d.ts +13 -0
  101. package/dist/dashboard/components/StatusLine.d.ts.map +1 -0
  102. package/dist/dashboard/components/StatusLine.js +70 -0
  103. package/dist/dashboard/components/StructuredDiff.d.ts +6 -0
  104. package/dist/dashboard/components/StructuredDiff.d.ts.map +1 -0
  105. package/dist/dashboard/components/StructuredDiff.js +47 -0
  106. package/dist/dashboard/components/Table.d.ts +5 -0
  107. package/dist/dashboard/components/Table.d.ts.map +1 -0
  108. package/dist/dashboard/components/Table.js +25 -0
  109. package/dist/dashboard/components/index.d.ts +11 -0
  110. package/dist/dashboard/components/index.d.ts.map +1 -0
  111. package/dist/dashboard/components/index.js +25 -0
  112. package/dist/dashboard/components/messages/EffectRequestedMessage.d.ts +3 -0
  113. package/dist/dashboard/components/messages/EffectRequestedMessage.d.ts.map +1 -0
  114. package/dist/dashboard/components/messages/EffectRequestedMessage.js +21 -0
  115. package/dist/dashboard/components/messages/EffectResolvedMessage.d.ts +3 -0
  116. package/dist/dashboard/components/messages/EffectResolvedMessage.d.ts.map +1 -0
  117. package/dist/dashboard/components/messages/EffectResolvedMessage.js +20 -0
  118. package/dist/dashboard/components/messages/EventMessage.d.ts +3 -0
  119. package/dist/dashboard/components/messages/EventMessage.d.ts.map +1 -0
  120. package/dist/dashboard/components/messages/EventMessage.js +27 -0
  121. package/dist/dashboard/components/messages/RunCompletedMessage.d.ts +3 -0
  122. package/dist/dashboard/components/messages/RunCompletedMessage.d.ts.map +1 -0
  123. package/dist/dashboard/components/messages/RunCompletedMessage.js +17 -0
  124. package/dist/dashboard/components/messages/RunCreatedMessage.d.ts +3 -0
  125. package/dist/dashboard/components/messages/RunCreatedMessage.d.ts.map +1 -0
  126. package/dist/dashboard/components/messages/RunCreatedMessage.js +18 -0
  127. package/dist/dashboard/components/messages/RunFailedMessage.d.ts +3 -0
  128. package/dist/dashboard/components/messages/RunFailedMessage.d.ts.map +1 -0
  129. package/dist/dashboard/components/messages/RunFailedMessage.js +23 -0
  130. package/dist/dashboard/components/messages/index.d.ts +8 -0
  131. package/dist/dashboard/components/messages/index.d.ts.map +1 -0
  132. package/dist/dashboard/components/messages/index.js +15 -0
  133. package/dist/dashboard/components/messages/types.d.ts +9 -0
  134. package/dist/dashboard/components/messages/types.d.ts.map +1 -0
  135. package/dist/dashboard/components/messages/types.js +5 -0
  136. package/dist/dashboard/diffParser.d.ts +20 -0
  137. package/dist/dashboard/diffParser.d.ts.map +1 -0
  138. package/dist/dashboard/diffParser.js +58 -0
  139. package/dist/dashboard/index.d.ts +13 -0
  140. package/dist/dashboard/index.d.ts.map +1 -0
  141. package/dist/dashboard/index.js +34 -0
  142. package/dist/dashboard/ink/App.d.ts +27 -0
  143. package/dist/dashboard/ink/App.d.ts.map +1 -0
  144. package/dist/dashboard/ink/App.js +88 -0
  145. package/dist/dashboard/ink/components/ActionMenu.d.ts +14 -0
  146. package/dist/dashboard/ink/components/ActionMenu.d.ts.map +1 -0
  147. package/dist/dashboard/ink/components/ActionMenu.js +39 -0
  148. package/dist/dashboard/ink/components/Message.d.ts +17 -0
  149. package/dist/dashboard/ink/components/Message.d.ts.map +1 -0
  150. package/dist/dashboard/ink/components/Message.js +142 -0
  151. package/dist/dashboard/ink/components/MessagePane.d.ts +25 -0
  152. package/dist/dashboard/ink/components/MessagePane.d.ts.map +1 -0
  153. package/dist/dashboard/ink/components/MessagePane.js +156 -0
  154. package/dist/dashboard/ink/components/PromptBar.d.ts +32 -0
  155. package/dist/dashboard/ink/components/PromptBar.d.ts.map +1 -0
  156. package/dist/dashboard/ink/components/PromptBar.js +158 -0
  157. package/dist/dashboard/ink/components/RunListTable.d.ts +28 -0
  158. package/dist/dashboard/ink/components/RunListTable.d.ts.map +1 -0
  159. package/dist/dashboard/ink/components/RunListTable.js +115 -0
  160. package/dist/dashboard/ink/components/RunningIndicator.d.ts +25 -0
  161. package/dist/dashboard/ink/components/RunningIndicator.d.ts.map +1 -0
  162. package/dist/dashboard/ink/components/RunningIndicator.js +38 -0
  163. package/dist/dashboard/ink/components/StatusBar.d.ts +37 -0
  164. package/dist/dashboard/ink/components/StatusBar.d.ts.map +1 -0
  165. package/dist/dashboard/ink/components/StatusBar.js +109 -0
  166. package/dist/dashboard/ink/components/StatusLine.d.ts +30 -0
  167. package/dist/dashboard/ink/components/StatusLine.d.ts.map +1 -0
  168. package/dist/dashboard/ink/components/StatusLine.js +122 -0
  169. package/dist/dashboard/ink/components/index.d.ts +24 -0
  170. package/dist/dashboard/ink/components/index.d.ts.map +1 -0
  171. package/dist/dashboard/ink/components/index.js +41 -0
  172. package/dist/dashboard/ink/components/primitives/BorderBox.d.ts +47 -0
  173. package/dist/dashboard/ink/components/primitives/BorderBox.d.ts.map +1 -0
  174. package/dist/dashboard/ink/components/primitives/BorderBox.js +107 -0
  175. package/dist/dashboard/ink/components/primitives/ProgressBar.d.ts +25 -0
  176. package/dist/dashboard/ink/components/primitives/ProgressBar.d.ts.map +1 -0
  177. package/dist/dashboard/ink/components/primitives/ProgressBar.js +55 -0
  178. package/dist/dashboard/ink/components/primitives/Tree.d.ts +27 -0
  179. package/dist/dashboard/ink/components/primitives/Tree.d.ts.map +1 -0
  180. package/dist/dashboard/ink/components/primitives/Tree.js +73 -0
  181. package/dist/dashboard/ink/components/primitives/index.d.ts +10 -0
  182. package/dist/dashboard/ink/components/primitives/index.d.ts.map +1 -0
  183. package/dist/dashboard/ink/components/primitives/index.js +16 -0
  184. package/dist/dashboard/ink/contexts/ClockContext.d.ts +26 -0
  185. package/dist/dashboard/ink/contexts/ClockContext.d.ts.map +1 -0
  186. package/dist/dashboard/ink/contexts/ClockContext.js +43 -0
  187. package/dist/dashboard/ink/contexts/InkContext.d.ts +58 -0
  188. package/dist/dashboard/ink/contexts/InkContext.d.ts.map +1 -0
  189. package/dist/dashboard/ink/contexts/InkContext.js +77 -0
  190. package/dist/dashboard/ink/contexts/NavigationContext.d.ts +44 -0
  191. package/dist/dashboard/ink/contexts/NavigationContext.d.ts.map +1 -0
  192. package/dist/dashboard/ink/contexts/NavigationContext.js +91 -0
  193. package/dist/dashboard/ink/contexts/SessionContext.d.ts +54 -0
  194. package/dist/dashboard/ink/contexts/SessionContext.d.ts.map +1 -0
  195. package/dist/dashboard/ink/contexts/SessionContext.js +87 -0
  196. package/dist/dashboard/ink/contexts/ThemeContext.d.ts +17 -0
  197. package/dist/dashboard/ink/contexts/ThemeContext.d.ts.map +1 -0
  198. package/dist/dashboard/ink/contexts/ThemeContext.js +46 -0
  199. package/dist/dashboard/ink/data/runScanner.d.ts +42 -0
  200. package/dist/dashboard/ink/data/runScanner.d.ts.map +1 -0
  201. package/dist/dashboard/ink/data/runScanner.js +145 -0
  202. package/dist/dashboard/ink/helpers.d.ts +173 -0
  203. package/dist/dashboard/ink/helpers.d.ts.map +1 -0
  204. package/dist/dashboard/ink/helpers.js +561 -0
  205. package/dist/dashboard/ink/hooks/useClock.d.ts +14 -0
  206. package/dist/dashboard/ink/hooks/useClock.d.ts.map +1 -0
  207. package/dist/dashboard/ink/hooks/useClock.js +13 -0
  208. package/dist/dashboard/ink/hooks/useNavigation.d.ts +7 -0
  209. package/dist/dashboard/ink/hooks/useNavigation.d.ts.map +1 -0
  210. package/dist/dashboard/ink/hooks/useNavigation.js +10 -0
  211. package/dist/dashboard/ink/hooks/useRunScanner.d.ts +15 -0
  212. package/dist/dashboard/ink/hooks/useRunScanner.d.ts.map +1 -0
  213. package/dist/dashboard/ink/hooks/useRunScanner.js +57 -0
  214. package/dist/dashboard/ink/hooks/useSession.d.ts +14 -0
  215. package/dist/dashboard/ink/hooks/useSession.d.ts.map +1 -0
  216. package/dist/dashboard/ink/hooks/useSession.js +13 -0
  217. package/dist/dashboard/ink/hooks/useTheme.d.ts +8 -0
  218. package/dist/dashboard/ink/hooks/useTheme.d.ts.map +1 -0
  219. package/dist/dashboard/ink/hooks/useTheme.js +12 -0
  220. package/dist/dashboard/ink/index.d.ts +26 -0
  221. package/dist/dashboard/ink/index.d.ts.map +1 -0
  222. package/dist/dashboard/ink/index.js +70 -0
  223. package/dist/dashboard/ink/render.d.ts +31 -0
  224. package/dist/dashboard/ink/render.d.ts.map +1 -0
  225. package/dist/dashboard/ink/render.js +97 -0
  226. package/dist/dashboard/ink/types.d.ts +161 -0
  227. package/dist/dashboard/ink/types.d.ts.map +1 -0
  228. package/dist/dashboard/ink/types.js +8 -0
  229. package/dist/dashboard/ink/views/DashboardView.d.ts +23 -0
  230. package/dist/dashboard/ink/views/DashboardView.d.ts.map +1 -0
  231. package/dist/dashboard/ink/views/DashboardView.js +156 -0
  232. package/dist/dashboard/ink/views/SessionView.d.ts +14 -0
  233. package/dist/dashboard/ink/views/SessionView.d.ts.map +1 -0
  234. package/dist/dashboard/ink/views/SessionView.js +89 -0
  235. package/dist/dashboard/ink/views/index.d.ts +6 -0
  236. package/dist/dashboard/ink/views/index.d.ts.map +1 -0
  237. package/dist/dashboard/ink/views/index.js +10 -0
  238. package/dist/dashboard/render.d.ts +20 -0
  239. package/dist/dashboard/render.d.ts.map +1 -0
  240. package/dist/dashboard/render.js +30 -0
  241. package/dist/governance/bridge.d.ts +17 -0
  242. package/dist/governance/bridge.d.ts.map +1 -0
  243. package/dist/governance/bridge.js +46 -0
  244. package/dist/governance/builtins.d.ts +25 -0
  245. package/dist/governance/builtins.d.ts.map +1 -0
  246. package/dist/governance/builtins.js +67 -0
  247. package/dist/governance/engine.d.ts +20 -0
  248. package/dist/governance/engine.d.ts.map +1 -0
  249. package/dist/governance/engine.js +124 -0
  250. package/dist/governance/index.d.ts +11 -0
  251. package/dist/governance/index.d.ts.map +1 -0
  252. package/dist/governance/index.js +25 -0
  253. package/dist/governance/logging.d.ts +18 -0
  254. package/dist/governance/logging.d.ts.map +1 -0
  255. package/dist/governance/logging.js +83 -0
  256. package/dist/governance/types.d.ts +106 -0
  257. package/dist/governance/types.d.ts.map +1 -0
  258. package/dist/governance/types.js +13 -0
  259. package/dist/harness/agenticTools.d.ts +7 -1
  260. package/dist/harness/agenticTools.d.ts.map +1 -1
  261. package/dist/harness/agenticTools.js +419 -17
  262. package/dist/harness/backgroundProcessRegistry.d.ts +63 -0
  263. package/dist/harness/backgroundProcessRegistry.d.ts.map +1 -0
  264. package/dist/harness/backgroundProcessRegistry.js +199 -0
  265. package/dist/harness/backgroundTracker.d.ts +64 -0
  266. package/dist/harness/backgroundTracker.d.ts.map +1 -0
  267. package/dist/harness/backgroundTracker.js +107 -0
  268. package/dist/harness/claudeCode.d.ts +1 -1
  269. package/dist/harness/claudeCode.d.ts.map +1 -1
  270. package/dist/harness/claudeCode.js +133 -34
  271. package/dist/harness/codex.d.ts.map +1 -1
  272. package/dist/harness/codex.js +1 -0
  273. package/dist/harness/cursor.d.ts.map +1 -1
  274. package/dist/harness/cursor.js +2 -0
  275. package/dist/harness/geminiCli.d.ts.map +1 -1
  276. package/dist/harness/geminiCli.js +2 -0
  277. package/dist/harness/githubCopilot.d.ts.map +1 -1
  278. package/dist/harness/githubCopilot.js +2 -0
  279. package/dist/harness/index.d.ts +4 -2
  280. package/dist/harness/index.d.ts.map +1 -1
  281. package/dist/harness/index.js +7 -1
  282. package/dist/harness/internal.d.ts.map +1 -1
  283. package/dist/harness/internal.js +10 -2
  284. package/dist/harness/invoker.d.ts +16 -0
  285. package/dist/harness/invoker.d.ts.map +1 -1
  286. package/dist/harness/invoker.js +70 -0
  287. package/dist/harness/ohMyPi.d.ts.map +1 -1
  288. package/dist/harness/ohMyPi.js +1 -0
  289. package/dist/harness/openclaw.d.ts.map +1 -1
  290. package/dist/harness/openclaw.js +2 -0
  291. package/dist/harness/opencode.d.ts.map +1 -1
  292. package/dist/harness/opencode.js +2 -0
  293. package/dist/harness/pi.d.ts.map +1 -1
  294. package/dist/harness/pi.js +1 -0
  295. package/dist/harness/streamingCapture.d.ts +44 -0
  296. package/dist/harness/streamingCapture.d.ts.map +1 -0
  297. package/dist/harness/streamingCapture.js +249 -0
  298. package/dist/harness/types.d.ts +22 -1
  299. package/dist/harness/types.d.ts.map +1 -1
  300. package/dist/harness/types.js +6 -0
  301. package/dist/hooks/dispatcher.d.ts +9 -0
  302. package/dist/hooks/dispatcher.d.ts.map +1 -1
  303. package/dist/hooks/dispatcher.js +94 -0
  304. package/dist/hooks/index.d.ts +2 -1
  305. package/dist/hooks/index.d.ts.map +1 -1
  306. package/dist/hooks/index.js +2 -1
  307. package/dist/index.d.ts +4 -0
  308. package/dist/index.d.ts.map +1 -1
  309. package/dist/index.js +5 -1
  310. package/dist/mcp/tools/runs.d.ts.map +1 -1
  311. package/dist/mcp/tools/runs.js +59 -94
  312. package/dist/mcp/tools/sessions.d.ts.map +1 -1
  313. package/dist/mcp/tools/sessions.js +2 -0
  314. package/dist/processLibrary/active.js +1 -1
  315. package/dist/prompts/compose.d.ts.map +1 -1
  316. package/dist/prompts/compose.js +2 -0
  317. package/dist/prompts/context.d.ts +8 -0
  318. package/dist/prompts/context.d.ts.map +1 -1
  319. package/dist/prompts/context.js +50 -9
  320. package/dist/prompts/index.d.ts +3 -2
  321. package/dist/prompts/index.d.ts.map +1 -1
  322. package/dist/prompts/index.js +10 -1
  323. package/dist/prompts/parts/index.d.ts +1 -0
  324. package/dist/prompts/parts/index.d.ts.map +1 -1
  325. package/dist/prompts/parts/index.js +3 -1
  326. package/dist/prompts/parts/parallelDispatch.d.ts +15 -0
  327. package/dist/prompts/parts/parallelDispatch.d.ts.map +1 -0
  328. package/dist/prompts/parts/parallelDispatch.js +46 -0
  329. package/dist/prompts/strata.d.ts +39 -0
  330. package/dist/prompts/strata.d.ts.map +1 -0
  331. package/dist/prompts/strata.js +140 -0
  332. package/dist/prompts/templates/breakpoint-handling.md +37 -1
  333. package/dist/prompts/templates/intent-fidelity-checks.md +3 -1
  334. package/dist/prompts/templates/process-creation.md +9 -2
  335. package/dist/prompts/templates/process-guidelines.md +6 -3
  336. package/dist/prompts/templates/task-examples.md +47 -0
  337. package/dist/prompts/templates/task-kinds.md +45 -3
  338. package/dist/prompts/types.d.ts +28 -0
  339. package/dist/prompts/types.d.ts.map +1 -1
  340. package/dist/runtime/asyncEffects.d.ts +22 -0
  341. package/dist/runtime/asyncEffects.d.ts.map +1 -0
  342. package/dist/runtime/asyncEffects.js +86 -0
  343. package/dist/runtime/commitEffectResult.d.ts +9 -0
  344. package/dist/runtime/commitEffectResult.d.ts.map +1 -1
  345. package/dist/runtime/commitEffectResult.js +59 -0
  346. package/dist/runtime/createRun.d.ts.map +1 -1
  347. package/dist/runtime/createRun.js +12 -1
  348. package/dist/runtime/effectGroupRegistry.d.ts +57 -0
  349. package/dist/runtime/effectGroupRegistry.d.ts.map +1 -0
  350. package/dist/runtime/effectGroupRegistry.js +107 -0
  351. package/dist/runtime/exceptions.d.ts +5 -0
  352. package/dist/runtime/exceptions.d.ts.map +1 -1
  353. package/dist/runtime/exceptions.js +13 -1
  354. package/dist/runtime/index.d.ts +2 -2
  355. package/dist/runtime/index.d.ts.map +1 -1
  356. package/dist/runtime/index.js +3 -1
  357. package/dist/runtime/intrinsics/breakpoint.d.ts +5 -0
  358. package/dist/runtime/intrinsics/breakpoint.d.ts.map +1 -1
  359. package/dist/runtime/intrinsics/breakpoint.js +50 -8
  360. package/dist/runtime/intrinsics/parallel.d.ts +5 -1
  361. package/dist/runtime/intrinsics/parallel.d.ts.map +1 -1
  362. package/dist/runtime/intrinsics/parallel.js +124 -18
  363. package/dist/runtime/intrinsics/parallelGroup.d.ts +16 -0
  364. package/dist/runtime/intrinsics/parallelGroup.d.ts.map +1 -0
  365. package/dist/runtime/intrinsics/parallelGroup.js +105 -0
  366. package/dist/runtime/intrinsics/task.d.ts +2 -0
  367. package/dist/runtime/intrinsics/task.d.ts.map +1 -1
  368. package/dist/runtime/intrinsics/task.js +64 -1
  369. package/dist/runtime/orchestrateIteration.d.ts +6 -0
  370. package/dist/runtime/orchestrateIteration.d.ts.map +1 -1
  371. package/dist/runtime/orchestrateIteration.js +69 -0
  372. package/dist/runtime/replay/effectIndex.d.ts +3 -0
  373. package/dist/runtime/replay/effectIndex.d.ts.map +1 -1
  374. package/dist/runtime/replay/effectIndex.js +74 -0
  375. package/dist/runtime/replay/stateCache.js +1 -1
  376. package/dist/runtime/schemaValidator.d.ts +16 -0
  377. package/dist/runtime/schemaValidator.d.ts.map +1 -0
  378. package/dist/runtime/schemaValidator.js +92 -0
  379. package/dist/runtime/types.d.ts +34 -1
  380. package/dist/runtime/types.d.ts.map +1 -1
  381. package/dist/session/context.d.ts +22 -0
  382. package/dist/session/context.d.ts.map +1 -0
  383. package/dist/session/context.js +108 -0
  384. package/dist/session/history.d.ts +30 -0
  385. package/dist/session/history.d.ts.map +1 -0
  386. package/dist/session/history.js +143 -0
  387. package/dist/session/index.d.ts +4 -2
  388. package/dist/session/index.d.ts.map +1 -1
  389. package/dist/session/index.js +15 -1
  390. package/dist/session/parse.d.ts.map +1 -1
  391. package/dist/session/parse.js +7 -0
  392. package/dist/session/types.d.ts +62 -1
  393. package/dist/session/types.d.ts.map +1 -1
  394. package/dist/session/write.d.ts +20 -0
  395. package/dist/session/write.d.ts.map +1 -1
  396. package/dist/session/write.js +44 -0
  397. package/dist/storage/createRunDir.d.ts.map +1 -1
  398. package/dist/storage/createRunDir.js +3 -1
  399. package/dist/storage/types.d.ts +7 -2
  400. package/dist/storage/types.d.ts.map +1 -1
  401. package/dist/tasks/batching.d.ts +6 -1
  402. package/dist/tasks/batching.d.ts.map +1 -1
  403. package/dist/tasks/batching.js +33 -8
  404. package/dist/tasks/effectGroup.d.ts +19 -0
  405. package/dist/tasks/effectGroup.d.ts.map +1 -0
  406. package/dist/tasks/effectGroup.js +58 -0
  407. package/dist/tasks/grouping.d.ts +19 -0
  408. package/dist/tasks/grouping.d.ts.map +1 -0
  409. package/dist/tasks/grouping.js +54 -0
  410. package/dist/tasks/index.d.ts +1 -0
  411. package/dist/tasks/index.d.ts.map +1 -1
  412. package/dist/tasks/index.js +1 -0
  413. package/dist/tasks/partitioning.d.ts +11 -0
  414. package/dist/tasks/partitioning.d.ts.map +1 -0
  415. package/dist/tasks/partitioning.js +20 -0
  416. package/dist/tasks/registry.d.ts +1 -1
  417. package/dist/tasks/registry.d.ts.map +1 -1
  418. package/dist/tasks/serializer.d.ts +3 -1
  419. package/dist/tasks/serializer.d.ts.map +1 -1
  420. package/dist/tasks/serializer.js +1 -0
  421. package/package.json +7 -1
@@ -0,0 +1,3 @@
1
+ export { apiCreateRun, apiIterate, apiCommitEffect, apiRunStatus, apiRunEvents, } from "./runs";
2
+ export type { ApiResult, ApiCreateRunInput, ApiIterateOutput, RunStatusOutput, RunEventsOutput, } from "./runs";
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,UAAU,EACV,eAAe,EACf,YAAY,EACZ,YAAY,GACb,MAAM,QAAQ,CAAC;AAEhB,YAAY,EACV,SAAS,EACT,iBAAiB,EACjB,gBAAgB,EAChB,eAAe,EACf,eAAe,GAChB,MAAM,QAAQ,CAAC"}
@@ -0,0 +1,9 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.apiRunEvents = exports.apiRunStatus = exports.apiCommitEffect = exports.apiIterate = exports.apiCreateRun = void 0;
4
+ var runs_1 = require("./runs");
5
+ Object.defineProperty(exports, "apiCreateRun", { enumerable: true, get: function () { return runs_1.apiCreateRun; } });
6
+ Object.defineProperty(exports, "apiIterate", { enumerable: true, get: function () { return runs_1.apiIterate; } });
7
+ Object.defineProperty(exports, "apiCommitEffect", { enumerable: true, get: function () { return runs_1.apiCommitEffect; } });
8
+ Object.defineProperty(exports, "apiRunStatus", { enumerable: true, get: function () { return runs_1.apiRunStatus; } });
9
+ Object.defineProperty(exports, "apiRunEvents", { enumerable: true, get: function () { return runs_1.apiRunEvents; } });
@@ -0,0 +1,79 @@
1
+ /**
2
+ * GAP-JSON-001: Programmatic API for run lifecycle.
3
+ *
4
+ * Thin typed wrappers over existing runtime functions with validation,
5
+ * error handling, and ApiResult envelopes. These functions never throw.
6
+ */
7
+ import type { EffectAction, IterationResult } from "../runtime/types";
8
+ import type { JsonRecord } from "../storage/types";
9
+ export type ApiResult<T> = {
10
+ ok: true;
11
+ data: T;
12
+ } | {
13
+ ok: false;
14
+ error: {
15
+ code: string;
16
+ message: string;
17
+ };
18
+ };
19
+ export interface ApiCreateRunInput {
20
+ processId: string;
21
+ entrypoint: string;
22
+ runsDir: string;
23
+ inputs?: unknown;
24
+ prompt?: string;
25
+ harness?: string;
26
+ }
27
+ export interface ApiIterateOutput {
28
+ status: IterationResult["status"];
29
+ output?: unknown;
30
+ error?: unknown;
31
+ nextActions?: EffectAction[];
32
+ metadata?: unknown;
33
+ }
34
+ export interface RunStatusOutput {
35
+ state: "created" | "running" | "waiting" | "completed" | "failed";
36
+ processId: string;
37
+ runId: string;
38
+ pendingEffects: Array<{
39
+ effectId: string;
40
+ kind?: string;
41
+ }>;
42
+ }
43
+ export interface RunEventsOutput {
44
+ events: Array<{
45
+ seq: number;
46
+ type: string;
47
+ recordedAt: string;
48
+ data: JsonRecord;
49
+ }>;
50
+ }
51
+ export declare function apiCreateRun(input: ApiCreateRunInput): Promise<ApiResult<{
52
+ runId: string;
53
+ runDir: string;
54
+ }>>;
55
+ export declare function apiIterate(input: {
56
+ runDir: string;
57
+ }): Promise<ApiResult<ApiIterateOutput>>;
58
+ export declare function apiCommitEffect(input: {
59
+ runDir: string;
60
+ effectId: string;
61
+ result: {
62
+ status: "ok" | "error";
63
+ value?: unknown;
64
+ error?: string;
65
+ };
66
+ }): Promise<ApiResult<{
67
+ resultRef: string;
68
+ }>>;
69
+ export declare function apiRunStatus(input: {
70
+ runId: string;
71
+ runsDir: string;
72
+ }): Promise<ApiResult<RunStatusOutput>>;
73
+ export declare function apiRunEvents(input: {
74
+ runId: string;
75
+ runsDir: string;
76
+ limit?: number;
77
+ filterType?: string;
78
+ }): Promise<ApiResult<RunEventsOutput>>;
79
+ //# sourceMappingURL=runs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"runs.d.ts","sourceRoot":"","sources":["../../src/api/runs.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAUH,OAAO,KAAK,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACtE,OAAO,KAAK,EAAgB,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAIjE,MAAM,MAAM,SAAS,CAAC,CAAC,IACnB;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,IAAI,EAAE,CAAC,CAAA;CAAE,GACrB;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,OAAO,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,CAAC;AAY5D,MAAM,WAAW,iBAAiB;IAChC,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,eAAe,CAAC,QAAQ,CAAC,CAAC;IAClC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC;IAC7B,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,SAAS,GAAG,SAAS,GAAG,SAAS,GAAG,WAAW,GAAG,QAAQ,CAAC;IAClE,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,KAAK,CAAC;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,IAAI,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;CAC5D;AAED,MAAM,WAAW,eAAe;IAC9B,MAAM,EAAE,KAAK,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;QACZ,IAAI,EAAE,MAAM,CAAC;QACb,UAAU,EAAE,MAAM,CAAC;QACnB,IAAI,EAAE,UAAU,CAAC;KAClB,CAAC,CAAC;CACJ;AAoCD,wBAAsB,YAAY,CAChC,KAAK,EAAE,iBAAiB,GACvB,OAAO,CAAC,SAAS,CAAC;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAgCvD;AAED,wBAAsB,UAAU,CAC9B,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,GACxB,OAAO,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC,CA0BtC;AAED,wBAAsB,eAAe,CACnC,KAAK,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE;QAAE,MAAM,EAAE,IAAI,GAAG,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAA;CAAE,GAC/G,OAAO,CAAC,SAAS,CAAC;IAAE,SAAS,EAAE,MAAM,CAAA;CAAE,CAAC,CAAC,CAwB3C;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GACxC,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAwBrC;AAED,wBAAsB,YAAY,CAChC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,GAC7E,OAAO,CAAC,SAAS,CAAC,eAAe,CAAC,CAAC,CAkCrC"}
@@ -0,0 +1,246 @@
1
+ "use strict";
2
+ /**
3
+ * GAP-JSON-001: Programmatic API for run lifecycle.
4
+ *
5
+ * Thin typed wrappers over existing runtime functions with validation,
6
+ * error handling, and ApiResult envelopes. These functions never throw.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.apiCreateRun = apiCreateRun;
10
+ exports.apiIterate = apiIterate;
11
+ exports.apiCommitEffect = apiCommitEffect;
12
+ exports.apiRunStatus = apiRunStatus;
13
+ exports.apiRunEvents = apiRunEvents;
14
+ const fs_1 = require("fs");
15
+ const createRun_1 = require("../runtime/createRun");
16
+ const orchestrateIteration_1 = require("../runtime/orchestrateIteration");
17
+ const commitEffectResult_1 = require("../runtime/commitEffectResult");
18
+ const runFiles_1 = require("../storage/runFiles");
19
+ const journal_1 = require("../storage/journal");
20
+ const paths_1 = require("../storage/paths");
21
+ const exceptions_1 = require("../runtime/exceptions");
22
+ function ok(data) {
23
+ return { ok: true, data };
24
+ }
25
+ function fail(code, message) {
26
+ return { ok: false, error: { code, message } };
27
+ }
28
+ // ── Helpers ─────────────────────────────────────────────────────────────────
29
+ function parseEntrypoint(entrypoint) {
30
+ const hashIndex = entrypoint.lastIndexOf("#");
31
+ if (hashIndex <= 0) {
32
+ return { importPath: entrypoint, exportName: undefined };
33
+ }
34
+ return {
35
+ importPath: entrypoint.slice(0, hashIndex),
36
+ exportName: entrypoint.slice(hashIndex + 1) || undefined,
37
+ };
38
+ }
39
+ async function pathExists(p) {
40
+ try {
41
+ await fs_1.promises.access(p);
42
+ return true;
43
+ }
44
+ catch {
45
+ return false;
46
+ }
47
+ }
48
+ function classifyError(error) {
49
+ const msg = error instanceof Error ? error.message : String(error);
50
+ if (error instanceof exceptions_1.RunFailedError && msg.startsWith("Unknown effectId")) {
51
+ return { code: "UNKNOWN_EFFECT", message: msg };
52
+ }
53
+ return { code: "INTERNAL_ERROR", message: msg };
54
+ }
55
+ // ── API functions ───────────────────────────────────────────────────────────
56
+ async function apiCreateRun(input) {
57
+ try {
58
+ // Validate inputs
59
+ if (!input.processId || typeof input.processId !== "string") {
60
+ return fail("INVALID_INPUT", "processId must be a non-empty string");
61
+ }
62
+ if (!input.entrypoint || typeof input.entrypoint !== "string") {
63
+ return fail("INVALID_INPUT", "entrypoint must be a non-empty string");
64
+ }
65
+ if (!input.runsDir || typeof input.runsDir !== "string") {
66
+ return fail("INVALID_INPUT", "runsDir must be a non-empty string");
67
+ }
68
+ const { importPath, exportName } = parseEntrypoint(input.entrypoint);
69
+ const result = await (0, createRun_1.createRun)({
70
+ runsDir: input.runsDir,
71
+ process: {
72
+ processId: input.processId,
73
+ importPath,
74
+ exportName,
75
+ },
76
+ inputs: input.inputs,
77
+ prompt: input.prompt,
78
+ harness: input.harness,
79
+ });
80
+ return ok({ runId: result.runId, runDir: result.runDir });
81
+ }
82
+ catch (error) {
83
+ const classified = classifyError(error);
84
+ return fail(classified.code, classified.message);
85
+ }
86
+ }
87
+ async function apiIterate(input) {
88
+ try {
89
+ if (!(await pathExists(input.runDir))) {
90
+ return fail("RUN_NOT_FOUND", `Run directory not found: ${input.runDir}`);
91
+ }
92
+ const result = await (0, orchestrateIteration_1.orchestrateIteration)({ runDir: input.runDir });
93
+ const output = { status: result.status };
94
+ if (result.metadata !== undefined) {
95
+ output.metadata = result.metadata;
96
+ }
97
+ if (result.status === "completed") {
98
+ output.output = result.output;
99
+ }
100
+ else if (result.status === "waiting") {
101
+ output.nextActions = result.nextActions;
102
+ }
103
+ else if (result.status === "failed" || result.status === "process-error") {
104
+ output.error = result.error;
105
+ }
106
+ return ok(output);
107
+ }
108
+ catch (error) {
109
+ const classified = classifyError(error);
110
+ return fail(classified.code, classified.message);
111
+ }
112
+ }
113
+ async function apiCommitEffect(input) {
114
+ try {
115
+ if (input.result.status === "ok" && input.result.value === undefined) {
116
+ return fail("INVALID_INPUT", "value is required when status is 'ok'");
117
+ }
118
+ if (input.result.status === "error" && !input.result.error) {
119
+ return fail("INVALID_INPUT", "error is required when status is 'error'");
120
+ }
121
+ const commitResult = await (0, commitEffectResult_1.commitEffectResult)({
122
+ runDir: input.runDir,
123
+ effectId: input.effectId,
124
+ result: {
125
+ status: input.result.status,
126
+ value: input.result.status === "ok" ? input.result.value : undefined,
127
+ error: input.result.status === "error" ? input.result.error : undefined,
128
+ },
129
+ });
130
+ return ok({ resultRef: commitResult.resultRef });
131
+ }
132
+ catch (error) {
133
+ const classified = classifyError(error);
134
+ return fail(classified.code, classified.message);
135
+ }
136
+ }
137
+ async function apiRunStatus(input) {
138
+ try {
139
+ const runDir = (0, paths_1.getRunDir)(input.runsDir, input.runId);
140
+ if (!(await pathExists(runDir))) {
141
+ return fail("RUN_NOT_FOUND", `Run not found: ${input.runId}`);
142
+ }
143
+ const metadata = await (0, runFiles_1.readRunMetadata)(runDir);
144
+ const events = await (0, journal_1.loadJournal)(runDir);
145
+ const state = deriveRunState(events);
146
+ const pendingEffects = derivePendingEffects(events);
147
+ return ok({
148
+ state,
149
+ processId: metadata.processId,
150
+ runId: metadata.runId,
151
+ pendingEffects,
152
+ });
153
+ }
154
+ catch (error) {
155
+ const classified = classifyError(error);
156
+ return fail(classified.code, classified.message);
157
+ }
158
+ }
159
+ async function apiRunEvents(input) {
160
+ try {
161
+ if (input.limit !== undefined && input.limit < 0) {
162
+ return fail("INVALID_INPUT", "limit must be a non-negative number");
163
+ }
164
+ const runDir = (0, paths_1.getRunDir)(input.runsDir, input.runId);
165
+ if (!(await pathExists(runDir))) {
166
+ return fail("RUN_NOT_FOUND", `Run not found: ${input.runId}`);
167
+ }
168
+ let events = await (0, journal_1.loadJournal)(runDir);
169
+ if (input.filterType) {
170
+ events = events.filter((e) => e.type === input.filterType);
171
+ }
172
+ if (input.limit !== undefined) {
173
+ events = events.slice(0, input.limit);
174
+ }
175
+ return ok({
176
+ events: events.map((e) => ({
177
+ seq: e.seq,
178
+ type: e.type,
179
+ recordedAt: e.recordedAt,
180
+ data: e.data,
181
+ })),
182
+ });
183
+ }
184
+ catch (error) {
185
+ const classified = classifyError(error);
186
+ return fail(classified.code, classified.message);
187
+ }
188
+ }
189
+ // ── State derivation helpers ────────────────────────────────────────────────
190
+ function deriveRunState(events) {
191
+ // Walk events in reverse to find the latest terminal or pending state.
192
+ for (let i = events.length - 1; i >= 0; i--) {
193
+ const type = events[i].type;
194
+ if (type === "RUN_COMPLETED")
195
+ return "completed";
196
+ if (type === "RUN_FAILED")
197
+ return "failed";
198
+ }
199
+ // Check if there are any unresolved EFFECT_REQUESTED events.
200
+ const requested = new Set();
201
+ const resolved = new Set();
202
+ for (const event of events) {
203
+ if (event.type === "EFFECT_REQUESTED") {
204
+ const effectId = event.data.effectId;
205
+ if (effectId)
206
+ requested.add(effectId);
207
+ }
208
+ else if (event.type === "EFFECT_RESOLVED" || event.type === "EFFECT_CANCELLED") {
209
+ const effectId = event.data.effectId;
210
+ if (effectId)
211
+ resolved.add(effectId);
212
+ }
213
+ }
214
+ const pending = [...requested].filter((id) => !resolved.has(id));
215
+ if (pending.length > 0)
216
+ return "waiting";
217
+ // Has any iteration happened?
218
+ const hasCreated = events.some((e) => e.type === "RUN_CREATED");
219
+ if (hasCreated && resolved.size > 0)
220
+ return "running";
221
+ return "created";
222
+ }
223
+ function derivePendingEffects(events) {
224
+ const requested = new Map();
225
+ const resolved = new Set();
226
+ for (const event of events) {
227
+ if (event.type === "EFFECT_REQUESTED") {
228
+ const data = event.data;
229
+ const effectId = data.effectId;
230
+ if (effectId) {
231
+ requested.set(effectId, {
232
+ effectId,
233
+ kind: typeof data.kind === "string" ? data.kind : undefined,
234
+ });
235
+ }
236
+ }
237
+ else if (event.type === "EFFECT_RESOLVED" || event.type === "EFFECT_CANCELLED") {
238
+ const effectId = event.data.effectId;
239
+ if (effectId)
240
+ resolved.add(effectId);
241
+ }
242
+ }
243
+ return [...requested.entries()]
244
+ .filter(([id]) => !resolved.has(id))
245
+ .map(([, info]) => info);
246
+ }
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Auto-approval evaluator.
3
+ *
4
+ * Precedence (highest wins):
5
+ * 1. never-auto-approve rule match
6
+ * 2. alwaysBreakOn profile tags
7
+ * 3. auto-approve rule match
8
+ * 4. autoApproveAfterN threshold (consecutive approvals from journal history)
9
+ * 5. prompt (default — no auto-approval)
10
+ */
11
+ import type { BreakpointRule, AutoApprovalResult } from "./types";
12
+ import type { BreakpointConfig } from "../profiles/types";
13
+ export interface EvaluateAutoApprovalOptions {
14
+ breakpointId: string;
15
+ tags?: string[];
16
+ expert?: string;
17
+ rules: BreakpointRule[];
18
+ profileConfig?: BreakpointConfig;
19
+ /** Number of consecutive past approvals for this breakpointId. */
20
+ consecutiveApprovals?: number;
21
+ /** autoApproveAfterN from breakpoint definition (-1 = disabled). */
22
+ autoApproveAfterN?: number;
23
+ }
24
+ export declare function evaluateAutoApproval(options: EvaluateAutoApprovalOptions): AutoApprovalResult;
25
+ //# sourceMappingURL=evaluator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"evaluator.d.ts","sourceRoot":"","sources":["../../src/breakpoints/evaluator.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,KAAK,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,SAAS,CAAC;AAClE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAG1D,MAAM,WAAW,2BAA2B;IAC1C,YAAY,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,cAAc,EAAE,CAAC;IACxB,aAAa,CAAC,EAAE,gBAAgB,CAAC;IACjC,kEAAkE;IAClE,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,oEAAoE;IACpE,iBAAiB,CAAC,EAAE,MAAM,CAAC;CAC5B;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,2BAA2B,GAAG,kBAAkB,CAqE7F"}
@@ -0,0 +1,72 @@
1
+ "use strict";
2
+ /**
3
+ * Auto-approval evaluator.
4
+ *
5
+ * Precedence (highest wins):
6
+ * 1. never-auto-approve rule match
7
+ * 2. alwaysBreakOn profile tags
8
+ * 3. auto-approve rule match
9
+ * 4. autoApproveAfterN threshold (consecutive approvals from journal history)
10
+ * 5. prompt (default — no auto-approval)
11
+ */
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.evaluateAutoApproval = evaluateAutoApproval;
14
+ const patterns_1 = require("./patterns");
15
+ function evaluateAutoApproval(options) {
16
+ const { breakpointId, tags, expert, rules, profileConfig, consecutiveApprovals = 0, autoApproveAfterN = -1, } = options;
17
+ const attributes = { tags, expert };
18
+ // 1. Check never-auto-approve rules (highest precedence)
19
+ for (const rule of rules) {
20
+ if (rule.action !== "never-auto-approve")
21
+ continue;
22
+ const pattern = (0, patterns_1.parsePattern)(rule.pattern);
23
+ if ((0, patterns_1.matchPattern)(pattern, breakpointId, attributes)) {
24
+ return {
25
+ recommended: false,
26
+ reason: `Blocked by never-auto-approve rule: ${rule.id}`,
27
+ matchedRule: rule.id,
28
+ consecutiveApprovals,
29
+ };
30
+ }
31
+ }
32
+ // 2. Check alwaysBreakOn profile tags
33
+ if (profileConfig?.alwaysBreakOn && tags) {
34
+ for (const alwaysTag of profileConfig.alwaysBreakOn) {
35
+ if (tags.includes(alwaysTag)) {
36
+ return {
37
+ recommended: false,
38
+ reason: `Blocked by alwaysBreakOn tag: ${alwaysTag}`,
39
+ consecutiveApprovals,
40
+ };
41
+ }
42
+ }
43
+ }
44
+ // 3. Check auto-approve rules
45
+ for (const rule of rules) {
46
+ if (rule.action !== "auto-approve")
47
+ continue;
48
+ const pattern = (0, patterns_1.parsePattern)(rule.pattern);
49
+ if ((0, patterns_1.matchPattern)(pattern, breakpointId, attributes)) {
50
+ return {
51
+ recommended: true,
52
+ reason: `Matched auto-approve rule: ${rule.id}`,
53
+ matchedRule: rule.id,
54
+ consecutiveApprovals,
55
+ };
56
+ }
57
+ }
58
+ // 4. Check autoApproveAfterN threshold
59
+ if (autoApproveAfterN > 0 && consecutiveApprovals >= autoApproveAfterN) {
60
+ return {
61
+ recommended: true,
62
+ reason: `Auto-approved after ${consecutiveApprovals} consecutive approvals (threshold: ${autoApproveAfterN})`,
63
+ consecutiveApprovals,
64
+ };
65
+ }
66
+ // 5. Default: prompt (no auto-approval)
67
+ return {
68
+ recommended: false,
69
+ reason: "No matching auto-approval rule",
70
+ consecutiveApprovals,
71
+ };
72
+ }
@@ -0,0 +1,7 @@
1
+ export type { BreakpointRule, BreakpointRuleAction, BreakpointRulesFile, AutoApprovalResult, BreakpointPattern, AttributePredicate, PredicateOp, } from "./types";
2
+ export { BREAKPOINT_RULES_SCHEMA_VERSION } from "./types";
3
+ export { parsePattern, matchPattern } from "./patterns";
4
+ export { readRules, writeRules, addRule, removeRule, listRules } from "./rules";
5
+ export { evaluateAutoApproval } from "./evaluator";
6
+ export type { EvaluateAutoApprovalOptions } from "./evaluator";
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/breakpoints/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,kBAAkB,EAClB,iBAAiB,EACjB,kBAAkB,EAClB,WAAW,GACZ,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,+BAA+B,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAChF,OAAO,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AACnD,YAAY,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.evaluateAutoApproval = exports.listRules = exports.removeRule = exports.addRule = exports.writeRules = exports.readRules = exports.matchPattern = exports.parsePattern = exports.BREAKPOINT_RULES_SCHEMA_VERSION = void 0;
4
+ var types_1 = require("./types");
5
+ Object.defineProperty(exports, "BREAKPOINT_RULES_SCHEMA_VERSION", { enumerable: true, get: function () { return types_1.BREAKPOINT_RULES_SCHEMA_VERSION; } });
6
+ var patterns_1 = require("./patterns");
7
+ Object.defineProperty(exports, "parsePattern", { enumerable: true, get: function () { return patterns_1.parsePattern; } });
8
+ Object.defineProperty(exports, "matchPattern", { enumerable: true, get: function () { return patterns_1.matchPattern; } });
9
+ var rules_1 = require("./rules");
10
+ Object.defineProperty(exports, "readRules", { enumerable: true, get: function () { return rules_1.readRules; } });
11
+ Object.defineProperty(exports, "writeRules", { enumerable: true, get: function () { return rules_1.writeRules; } });
12
+ Object.defineProperty(exports, "addRule", { enumerable: true, get: function () { return rules_1.addRule; } });
13
+ Object.defineProperty(exports, "removeRule", { enumerable: true, get: function () { return rules_1.removeRule; } });
14
+ Object.defineProperty(exports, "listRules", { enumerable: true, get: function () { return rules_1.listRules; } });
15
+ var evaluator_1 = require("./evaluator");
16
+ Object.defineProperty(exports, "evaluateAutoApproval", { enumerable: true, get: function () { return evaluator_1.evaluateAutoApproval; } });
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Pattern parsing and matching for breakpoint auto-approval rules.
3
+ *
4
+ * Pattern syntax:
5
+ * <id-glob> — e.g., "confirm.*"
6
+ * <id-glob>(<predicate> [AND ...]) — e.g., "*.review(tags contains 'design')"
7
+ *
8
+ * Id-glob supports * as a wildcard matching any segment(s).
9
+ * Attribute predicates: "tags contains '<value>'" or "expert = '<value>'"
10
+ * Multiple predicates joined with AND.
11
+ */
12
+ import type { BreakpointPattern } from "./types";
13
+ /**
14
+ * Parse a pattern string into a structured BreakpointPattern.
15
+ */
16
+ export declare function parsePattern(raw: string): BreakpointPattern;
17
+ /**
18
+ * Match a breakpointId and attributes against a parsed pattern.
19
+ */
20
+ export declare function matchPattern(pattern: BreakpointPattern, breakpointId: string, attributes: {
21
+ tags?: string[];
22
+ expert?: string;
23
+ }): boolean;
24
+ //# sourceMappingURL=patterns.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"patterns.d.ts","sourceRoot":"","sources":["../../src/breakpoints/patterns.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAsB,iBAAiB,EAAe,MAAM,SAAS,CAAC;AAElF;;GAEG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,iBAAiB,CAsB3D;AAwBD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,OAAO,EAAE,iBAAiB,EAC1B,YAAY,EAAE,MAAM,EACpB,UAAU,EAAE;IAAE,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GAC/C,OAAO,CAYT"}
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ /**
3
+ * Pattern parsing and matching for breakpoint auto-approval rules.
4
+ *
5
+ * Pattern syntax:
6
+ * <id-glob> — e.g., "confirm.*"
7
+ * <id-glob>(<predicate> [AND ...]) — e.g., "*.review(tags contains 'design')"
8
+ *
9
+ * Id-glob supports * as a wildcard matching any segment(s).
10
+ * Attribute predicates: "tags contains '<value>'" or "expert = '<value>'"
11
+ * Multiple predicates joined with AND.
12
+ */
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.parsePattern = parsePattern;
15
+ exports.matchPattern = matchPattern;
16
+ /**
17
+ * Parse a pattern string into a structured BreakpointPattern.
18
+ */
19
+ function parsePattern(raw) {
20
+ const trimmed = raw.trim();
21
+ const parenOpen = trimmed.indexOf("(");
22
+ if (parenOpen === -1) {
23
+ return { idGlob: trimmed, predicates: [] };
24
+ }
25
+ const parenClose = trimmed.lastIndexOf(")");
26
+ if (parenClose === -1 || parenClose <= parenOpen) {
27
+ throw new Error(`Invalid pattern: unmatched parenthesis in "${raw}"`);
28
+ }
29
+ const idGlob = trimmed.slice(0, parenOpen).trim();
30
+ const predicateStr = trimmed.slice(parenOpen + 1, parenClose).trim();
31
+ if (!predicateStr) {
32
+ return { idGlob, predicates: [] };
33
+ }
34
+ const predicates = parsePredicates(predicateStr);
35
+ return { idGlob, predicates };
36
+ }
37
+ function parsePredicates(str) {
38
+ // Split on " AND " (case-insensitive)
39
+ const parts = str.split(/\s+AND\s+/i);
40
+ return parts.map(parseSinglePredicate);
41
+ }
42
+ function parseSinglePredicate(str) {
43
+ const trimmed = str.trim();
44
+ // Match: attr contains 'value' or attr = 'value'
45
+ const match = trimmed.match(/^(\w+)\s+(contains|=)\s+'([^']*)'$/);
46
+ if (!match) {
47
+ throw new Error(`Invalid predicate: "${trimmed}". Expected: attr contains 'value' or attr = 'value'`);
48
+ }
49
+ return {
50
+ attr: match[1],
51
+ op: match[2],
52
+ value: match[3],
53
+ };
54
+ }
55
+ /**
56
+ * Match a breakpointId and attributes against a parsed pattern.
57
+ */
58
+ function matchPattern(pattern, breakpointId, attributes) {
59
+ if (!matchGlob(pattern.idGlob, breakpointId)) {
60
+ return false;
61
+ }
62
+ for (const pred of pattern.predicates) {
63
+ if (!matchPredicate(pred, attributes)) {
64
+ return false;
65
+ }
66
+ }
67
+ return true;
68
+ }
69
+ /**
70
+ * Simple glob matching with * wildcards.
71
+ * Each * matches zero or more characters (including dots).
72
+ */
73
+ function matchGlob(glob, value) {
74
+ // Escape regex special chars except *, then replace * with .*
75
+ const escaped = glob.replace(/[.+?^${}()|[\]\\]/g, "\\$&");
76
+ const regexStr = "^" + escaped.replace(/\*/g, ".*") + "$";
77
+ return new RegExp(regexStr).test(value);
78
+ }
79
+ function matchPredicate(pred, attributes) {
80
+ if (pred.attr === "tags" && pred.op === "contains") {
81
+ return Array.isArray(attributes.tags) && attributes.tags.includes(pred.value);
82
+ }
83
+ if (pred.attr === "expert" && pred.op === "=") {
84
+ return attributes.expert === pred.value;
85
+ }
86
+ // Unknown attribute — no match
87
+ return false;
88
+ }
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Rules CRUD for breakpoint auto-approval.
3
+ * Rules stored at ~/.a5c/breakpoint-approvals/rules.json with atomic writes.
4
+ */
5
+ import type { BreakpointRule } from "./types";
6
+ /**
7
+ * Read rules from the rules file. Returns empty array if file doesn't exist.
8
+ */
9
+ export declare function readRules(rulesPath?: string): Promise<BreakpointRule[]>;
10
+ /**
11
+ * Write rules to the rules file atomically.
12
+ */
13
+ export declare function writeRules(rules: BreakpointRule[], rulesPath?: string): Promise<void>;
14
+ /**
15
+ * Add a rule. Deduplicates by rule id.
16
+ */
17
+ export declare function addRule(rule: BreakpointRule, rulesPath?: string): Promise<BreakpointRule[]>;
18
+ /**
19
+ * Remove a rule by id. Returns the updated list.
20
+ */
21
+ export declare function removeRule(ruleId: string, rulesPath?: string): Promise<BreakpointRule[]>;
22
+ /**
23
+ * List all rules.
24
+ */
25
+ export declare function listRules(rulesPath?: string): Promise<BreakpointRule[]>;
26
+ //# sourceMappingURL=rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rules.d.ts","sourceRoot":"","sources":["../../src/breakpoints/rules.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAMH,OAAO,KAAK,EAAE,cAAc,EAAuB,MAAM,SAAS,CAAC;AAOnE;;GAEG;AACH,wBAAsB,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAe7E;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,KAAK,EAAE,cAAc,EAAE,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAS3F;AAED;;GAEG;AACH,wBAAsB,OAAO,CAAC,IAAI,EAAE,cAAc,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAMjG;AAED;;GAEG;AACH,wBAAsB,UAAU,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAK9F;AAED;;GAEG;AACH,wBAAsB,SAAS,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAE7E"}