open-multi-agent-kit 0.98.4 → 0.99.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 (357) hide show
  1. package/CHANGELOG.md +36 -0
  2. package/README.md +4 -2
  3. package/dist/cli/help.d.ts.map +1 -1
  4. package/dist/cli/help.js +1 -0
  5. package/dist/cli/help.js.map +1 -1
  6. package/dist/commands/run-command.d.ts +2 -1
  7. package/dist/commands/run-command.d.ts.map +1 -1
  8. package/dist/commands/run-command.js +9 -1
  9. package/dist/commands/run-command.js.map +1 -1
  10. package/dist/commands/verified-run-cli.d.ts +6 -0
  11. package/dist/commands/verified-run-cli.d.ts.map +1 -0
  12. package/dist/commands/verified-run-cli.js +190 -0
  13. package/dist/commands/verified-run-cli.js.map +1 -0
  14. package/dist/core/agent-session-services.d.ts +8 -1
  15. package/dist/core/agent-session-services.d.ts.map +1 -1
  16. package/dist/core/agent-session-services.js +41 -0
  17. package/dist/core/agent-session-services.js.map +1 -1
  18. package/dist/core/agent-session.d.ts +7 -8
  19. package/dist/core/agent-session.d.ts.map +1 -1
  20. package/dist/core/agent-session.js +80 -43
  21. package/dist/core/agent-session.js.map +1 -1
  22. package/dist/core/devin-harness-dispatch.d.ts +12 -0
  23. package/dist/core/devin-harness-dispatch.d.ts.map +1 -0
  24. package/dist/core/devin-harness-dispatch.js +12 -0
  25. package/dist/core/devin-harness-dispatch.js.map +1 -0
  26. package/dist/core/devin-harness.d.ts +53 -0
  27. package/dist/core/devin-harness.d.ts.map +1 -0
  28. package/dist/core/devin-harness.js +112 -0
  29. package/dist/core/devin-harness.js.map +1 -0
  30. package/dist/core/domain-dispatch.d.ts +4 -1
  31. package/dist/core/domain-dispatch.d.ts.map +1 -1
  32. package/dist/core/domain-dispatch.js +5 -0
  33. package/dist/core/domain-dispatch.js.map +1 -1
  34. package/dist/core/domain-loadouts-provider-harness.d.ts +12 -0
  35. package/dist/core/domain-loadouts-provider-harness.d.ts.map +1 -0
  36. package/dist/core/domain-loadouts-provider-harness.js +122 -0
  37. package/dist/core/domain-loadouts-provider-harness.js.map +1 -0
  38. package/dist/core/domain-loadouts.d.ts +2 -33
  39. package/dist/core/domain-loadouts.d.ts.map +1 -1
  40. package/dist/core/domain-loadouts.js +3 -56
  41. package/dist/core/domain-loadouts.js.map +1 -1
  42. package/dist/core/domain-profile.d.ts +40 -0
  43. package/dist/core/domain-profile.d.ts.map +1 -0
  44. package/dist/core/domain-profile.js +7 -0
  45. package/dist/core/domain-profile.js.map +1 -0
  46. package/dist/core/grok-harness-dispatch.d.ts +6 -20
  47. package/dist/core/grok-harness-dispatch.d.ts.map +1 -1
  48. package/dist/core/grok-harness-dispatch.js +6 -55
  49. package/dist/core/grok-harness-dispatch.js.map +1 -1
  50. package/dist/core/grok-harness.d.ts +7 -9
  51. package/dist/core/grok-harness.d.ts.map +1 -1
  52. package/dist/core/grok-harness.js +9 -23
  53. package/dist/core/grok-harness.js.map +1 -1
  54. package/dist/core/harness-skills.d.ts +20 -0
  55. package/dist/core/harness-skills.d.ts.map +1 -0
  56. package/dist/core/harness-skills.js +36 -0
  57. package/dist/core/harness-skills.js.map +1 -0
  58. package/dist/core/loadout-runtime-state.d.ts +25 -0
  59. package/dist/core/loadout-runtime-state.d.ts.map +1 -0
  60. package/dist/core/loadout-runtime-state.js +39 -0
  61. package/dist/core/loadout-runtime-state.js.map +1 -0
  62. package/dist/core/loadout-runtime.d.ts +2 -12
  63. package/dist/core/loadout-runtime.d.ts.map +1 -1
  64. package/dist/core/loadout-runtime.js +6 -13
  65. package/dist/core/loadout-runtime.js.map +1 -1
  66. package/dist/core/model-resolver.d.ts +1 -41
  67. package/dist/core/model-resolver.d.ts.map +1 -1
  68. package/dist/core/model-resolver.js +2 -49
  69. package/dist/core/model-resolver.js.map +1 -1
  70. package/dist/core/prompt-settlement.d.ts +4 -3
  71. package/dist/core/prompt-settlement.d.ts.map +1 -1
  72. package/dist/core/prompt-settlement.js.map +1 -1
  73. package/dist/core/provider-default-models.d.ts +42 -0
  74. package/dist/core/provider-default-models.d.ts.map +1 -0
  75. package/dist/core/provider-default-models.js +50 -0
  76. package/dist/core/provider-default-models.js.map +1 -0
  77. package/dist/core/provider-display-names.d.ts.map +1 -1
  78. package/dist/core/provider-display-names.js +1 -0
  79. package/dist/core/provider-display-names.js.map +1 -1
  80. package/dist/core/provider-harness-dispatch.d.ts +63 -0
  81. package/dist/core/provider-harness-dispatch.d.ts.map +1 -0
  82. package/dist/core/provider-harness-dispatch.js +60 -0
  83. package/dist/core/provider-harness-dispatch.js.map +1 -0
  84. package/dist/core/provider-usage-devin.d.ts +16 -0
  85. package/dist/core/provider-usage-devin.d.ts.map +1 -0
  86. package/dist/core/provider-usage-devin.js +61 -0
  87. package/dist/core/provider-usage-devin.js.map +1 -0
  88. package/dist/core/provider-usage-text.d.ts +5 -0
  89. package/dist/core/provider-usage-text.d.ts.map +1 -0
  90. package/dist/core/provider-usage-text.js +15 -0
  91. package/dist/core/provider-usage-text.js.map +1 -0
  92. package/dist/core/provider-usage-types.d.ts +2 -1
  93. package/dist/core/provider-usage-types.d.ts.map +1 -1
  94. package/dist/core/provider-usage-types.js.map +1 -1
  95. package/dist/core/provider-usage.d.ts +1 -2
  96. package/dist/core/provider-usage.d.ts.map +1 -1
  97. package/dist/core/provider-usage.js +12 -7
  98. package/dist/core/provider-usage.js.map +1 -1
  99. package/dist/core/run-budget-policy.d.ts +18 -0
  100. package/dist/core/run-budget-policy.d.ts.map +1 -0
  101. package/dist/core/run-budget-policy.js +52 -0
  102. package/dist/core/run-budget-policy.js.map +1 -0
  103. package/dist/core/run-budget.d.ts +33 -0
  104. package/dist/core/run-budget.d.ts.map +1 -0
  105. package/dist/core/run-budget.js +89 -0
  106. package/dist/core/run-budget.js.map +1 -0
  107. package/dist/core/run-execution-api.d.ts +15 -0
  108. package/dist/core/run-execution-api.d.ts.map +1 -0
  109. package/dist/core/run-execution-api.js +7 -0
  110. package/dist/core/run-execution-api.js.map +1 -0
  111. package/dist/core/run-journal.d.ts.map +1 -1
  112. package/dist/core/run-journal.js +30 -208
  113. package/dist/core/run-journal.js.map +1 -1
  114. package/dist/core/sdk.d.ts.map +1 -1
  115. package/dist/core/sdk.js +23 -18
  116. package/dist/core/sdk.js.map +1 -1
  117. package/dist/core/session-bash-service.d.ts +2 -2
  118. package/dist/core/session-bash-service.d.ts.map +1 -1
  119. package/dist/core/session-bash-service.js +21 -9
  120. package/dist/core/session-bash-service.js.map +1 -1
  121. package/dist/core/session-failure-cause.d.ts.map +1 -1
  122. package/dist/core/session-failure-cause.js +5 -0
  123. package/dist/core/session-failure-cause.js.map +1 -1
  124. package/dist/core/session-prompt-lifecycle.d.ts +25 -0
  125. package/dist/core/session-prompt-lifecycle.d.ts.map +1 -0
  126. package/dist/core/session-prompt-lifecycle.js +87 -0
  127. package/dist/core/session-prompt-lifecycle.js.map +1 -0
  128. package/dist/core/session-run-budget.d.ts +28 -0
  129. package/dist/core/session-run-budget.d.ts.map +1 -0
  130. package/dist/core/session-run-budget.js +127 -0
  131. package/dist/core/session-run-budget.js.map +1 -0
  132. package/dist/core/session-run-termination.d.ts.map +1 -1
  133. package/dist/core/session-run-termination.js +14 -3
  134. package/dist/core/session-run-termination.js.map +1 -1
  135. package/dist/core/session-termination-types.d.ts +97 -0
  136. package/dist/core/session-termination-types.d.ts.map +1 -0
  137. package/dist/core/session-termination-types.js +26 -0
  138. package/dist/core/session-termination-types.js.map +1 -0
  139. package/dist/core/session-termination.d.ts +3 -97
  140. package/dist/core/session-termination.d.ts.map +1 -1
  141. package/dist/core/session-termination.js +24 -28
  142. package/dist/core/session-termination.js.map +1 -1
  143. package/dist/core/slash-commands.d.ts.map +1 -1
  144. package/dist/core/slash-commands.js +1 -0
  145. package/dist/core/slash-commands.js.map +1 -1
  146. package/dist/core/subagent-lane-launcher.d.ts +3 -2
  147. package/dist/core/subagent-lane-launcher.d.ts.map +1 -1
  148. package/dist/core/subagent-lane-launcher.js +24 -13
  149. package/dist/core/subagent-lane-launcher.js.map +1 -1
  150. package/dist/core/verified-run/broker.d.ts +26 -0
  151. package/dist/core/verified-run/broker.d.ts.map +1 -0
  152. package/dist/core/verified-run/broker.js +210 -0
  153. package/dist/core/verified-run/broker.js.map +1 -0
  154. package/dist/core/verified-run/candidate.d.ts +24 -0
  155. package/dist/core/verified-run/candidate.d.ts.map +1 -0
  156. package/dist/core/verified-run/candidate.js +167 -0
  157. package/dist/core/verified-run/candidate.js.map +1 -0
  158. package/dist/core/verified-run/check-receipt.d.ts +18 -0
  159. package/dist/core/verified-run/check-receipt.d.ts.map +1 -0
  160. package/dist/core/verified-run/check-receipt.js +92 -0
  161. package/dist/core/verified-run/check-receipt.js.map +1 -0
  162. package/dist/core/verified-run/coordinator.d.ts +39 -0
  163. package/dist/core/verified-run/coordinator.d.ts.map +1 -0
  164. package/dist/core/verified-run/coordinator.js +190 -0
  165. package/dist/core/verified-run/coordinator.js.map +1 -0
  166. package/dist/core/verified-run/dag-candidates.d.ts +8 -0
  167. package/dist/core/verified-run/dag-candidates.d.ts.map +1 -0
  168. package/dist/core/verified-run/dag-candidates.js +65 -0
  169. package/dist/core/verified-run/dag-candidates.js.map +1 -0
  170. package/dist/core/verified-run/dag-phase.d.ts +7 -0
  171. package/dist/core/verified-run/dag-phase.d.ts.map +1 -0
  172. package/dist/core/verified-run/dag-phase.js +130 -0
  173. package/dist/core/verified-run/dag-phase.js.map +1 -0
  174. package/dist/core/verified-run/dag-projection.d.ts +7 -0
  175. package/dist/core/verified-run/dag-projection.d.ts.map +1 -0
  176. package/dist/core/verified-run/dag-projection.js +103 -0
  177. package/dist/core/verified-run/dag-projection.js.map +1 -0
  178. package/dist/core/verified-run/dag-recovery.d.ts +13 -0
  179. package/dist/core/verified-run/dag-recovery.d.ts.map +1 -0
  180. package/dist/core/verified-run/dag-recovery.js +98 -0
  181. package/dist/core/verified-run/dag-recovery.js.map +1 -0
  182. package/dist/core/verified-run/dag-retry-projection.d.ts +9 -0
  183. package/dist/core/verified-run/dag-retry-projection.d.ts.map +1 -0
  184. package/dist/core/verified-run/dag-retry-projection.js +43 -0
  185. package/dist/core/verified-run/dag-retry-projection.js.map +1 -0
  186. package/dist/core/verified-run/dag-types.d.ts +58 -0
  187. package/dist/core/verified-run/dag-types.d.ts.map +1 -0
  188. package/dist/core/verified-run/dag-types.js +2 -0
  189. package/dist/core/verified-run/dag-types.js.map +1 -0
  190. package/dist/core/verified-run/event-parser.d.ts +3 -0
  191. package/dist/core/verified-run/event-parser.d.ts.map +1 -0
  192. package/dist/core/verified-run/event-parser.js +154 -0
  193. package/dist/core/verified-run/event-parser.js.map +1 -0
  194. package/dist/core/verified-run/events.d.ts +4 -0
  195. package/dist/core/verified-run/events.d.ts.map +1 -0
  196. package/dist/core/verified-run/events.js +3 -0
  197. package/dist/core/verified-run/events.js.map +1 -0
  198. package/dist/core/verified-run/evidence-binding.d.ts +18 -0
  199. package/dist/core/verified-run/evidence-binding.d.ts.map +1 -0
  200. package/dist/core/verified-run/evidence-binding.js +81 -0
  201. package/dist/core/verified-run/evidence-binding.js.map +1 -0
  202. package/dist/core/verified-run/evidence.d.ts +27 -0
  203. package/dist/core/verified-run/evidence.d.ts.map +1 -0
  204. package/dist/core/verified-run/evidence.js +100 -0
  205. package/dist/core/verified-run/evidence.js.map +1 -0
  206. package/dist/core/verified-run/journal.d.ts +32 -0
  207. package/dist/core/verified-run/journal.d.ts.map +1 -0
  208. package/dist/core/verified-run/journal.js +103 -0
  209. package/dist/core/verified-run/journal.js.map +1 -0
  210. package/dist/core/verified-run/namespace-identity.d.ts +11 -0
  211. package/dist/core/verified-run/namespace-identity.d.ts.map +1 -0
  212. package/dist/core/verified-run/namespace-identity.js +77 -0
  213. package/dist/core/verified-run/namespace-identity.js.map +1 -0
  214. package/dist/core/verified-run/owned-execution.d.ts +22 -0
  215. package/dist/core/verified-run/owned-execution.d.ts.map +1 -0
  216. package/dist/core/verified-run/owned-execution.js +49 -0
  217. package/dist/core/verified-run/owned-execution.js.map +1 -0
  218. package/dist/core/verified-run/phase-context.d.ts +9 -0
  219. package/dist/core/verified-run/phase-context.d.ts.map +1 -0
  220. package/dist/core/verified-run/phase-context.js +2 -0
  221. package/dist/core/verified-run/phase-context.js.map +1 -0
  222. package/dist/core/verified-run/process-gate.d.ts +5 -0
  223. package/dist/core/verified-run/process-gate.d.ts.map +1 -0
  224. package/dist/core/verified-run/process-gate.js +31 -0
  225. package/dist/core/verified-run/process-gate.js.map +1 -0
  226. package/dist/core/verified-run/process-projection.d.ts +13 -0
  227. package/dist/core/verified-run/process-projection.d.ts.map +1 -0
  228. package/dist/core/verified-run/process-projection.js +82 -0
  229. package/dist/core/verified-run/process-projection.js.map +1 -0
  230. package/dist/core/verified-run/projection.d.ts +4 -0
  231. package/dist/core/verified-run/projection.d.ts.map +1 -0
  232. package/dist/core/verified-run/projection.js +175 -0
  233. package/dist/core/verified-run/projection.js.map +1 -0
  234. package/dist/core/verified-run/recovery-clock.d.ts +19 -0
  235. package/dist/core/verified-run/recovery-clock.d.ts.map +1 -0
  236. package/dist/core/verified-run/recovery-clock.js +69 -0
  237. package/dist/core/verified-run/recovery-clock.js.map +1 -0
  238. package/dist/core/verified-run/recovery-command.d.ts +11 -0
  239. package/dist/core/verified-run/recovery-command.d.ts.map +1 -0
  240. package/dist/core/verified-run/recovery-command.js +73 -0
  241. package/dist/core/verified-run/recovery-command.js.map +1 -0
  242. package/dist/core/verified-run/recovery-projection.d.ts +12 -0
  243. package/dist/core/verified-run/recovery-projection.d.ts.map +1 -0
  244. package/dist/core/verified-run/recovery-projection.js +88 -0
  245. package/dist/core/verified-run/recovery-projection.js.map +1 -0
  246. package/dist/core/verified-run/recovery.d.ts +12 -0
  247. package/dist/core/verified-run/recovery.d.ts.map +1 -0
  248. package/dist/core/verified-run/recovery.js +115 -0
  249. package/dist/core/verified-run/recovery.js.map +1 -0
  250. package/dist/core/verified-run/run-types.d.ts +104 -0
  251. package/dist/core/verified-run/run-types.d.ts.map +1 -0
  252. package/dist/core/verified-run/run-types.js +2 -0
  253. package/dist/core/verified-run/run-types.js.map +1 -0
  254. package/dist/core/verified-run/scripted-writer.d.ts +15 -0
  255. package/dist/core/verified-run/scripted-writer.d.ts.map +1 -0
  256. package/dist/core/verified-run/scripted-writer.js +94 -0
  257. package/dist/core/verified-run/scripted-writer.js.map +1 -0
  258. package/dist/core/verified-run/session-port.d.ts +27 -0
  259. package/dist/core/verified-run/session-port.d.ts.map +1 -0
  260. package/dist/core/verified-run/session-port.js +2 -0
  261. package/dist/core/verified-run/session-port.js.map +1 -0
  262. package/dist/core/verified-run/storage.d.ts +15 -0
  263. package/dist/core/verified-run/storage.d.ts.map +1 -0
  264. package/dist/core/verified-run/storage.js +96 -0
  265. package/dist/core/verified-run/storage.js.map +1 -0
  266. package/dist/core/verified-run/task-execution.d.ts +9 -0
  267. package/dist/core/verified-run/task-execution.d.ts.map +1 -0
  268. package/dist/core/verified-run/task-execution.js +29 -0
  269. package/dist/core/verified-run/task-execution.js.map +1 -0
  270. package/dist/core/verified-run/verification-phase.d.ts +5 -0
  271. package/dist/core/verified-run/verification-phase.d.ts.map +1 -0
  272. package/dist/core/verified-run/verification-phase.js +56 -0
  273. package/dist/core/verified-run/verification-phase.js.map +1 -0
  274. package/dist/core/verified-run/work-recovery.d.ts +8 -0
  275. package/dist/core/verified-run/work-recovery.d.ts.map +1 -0
  276. package/dist/core/verified-run/work-recovery.js +44 -0
  277. package/dist/core/verified-run/work-recovery.js.map +1 -0
  278. package/dist/core/verified-run/writer-completion.d.ts +4 -0
  279. package/dist/core/verified-run/writer-completion.d.ts.map +1 -0
  280. package/dist/core/verified-run/writer-completion.js +27 -0
  281. package/dist/core/verified-run/writer-completion.js.map +1 -0
  282. package/dist/core/verified-run/writer-phase.d.ts +8 -0
  283. package/dist/core/verified-run/writer-phase.d.ts.map +1 -0
  284. package/dist/core/verified-run/writer-phase.js +76 -0
  285. package/dist/core/verified-run/writer-phase.js.map +1 -0
  286. package/dist/core/verified-run/writer-projection.d.ts +11 -0
  287. package/dist/core/verified-run/writer-projection.d.ts.map +1 -0
  288. package/dist/core/verified-run/writer-projection.js +71 -0
  289. package/dist/core/verified-run/writer-projection.js.map +1 -0
  290. package/dist/core/verified-run/writer-recovery.d.ts +16 -0
  291. package/dist/core/verified-run/writer-recovery.d.ts.map +1 -0
  292. package/dist/core/verified-run/writer-recovery.js +107 -0
  293. package/dist/core/verified-run/writer-recovery.js.map +1 -0
  294. package/dist/core/workload-permit-pool.d.ts +1 -3
  295. package/dist/core/workload-permit-pool.d.ts.map +1 -1
  296. package/dist/core/workload-permit-pool.js +11 -11
  297. package/dist/core/workload-permit-pool.js.map +1 -1
  298. package/dist/index.d.ts +3 -2
  299. package/dist/index.d.ts.map +1 -1
  300. package/dist/index.js +2 -2
  301. package/dist/index.js.map +1 -1
  302. package/dist/main.d.ts.map +1 -1
  303. package/dist/main.js +2 -8
  304. package/dist/main.js.map +1 -1
  305. package/dist/modes/interactive/components/session-failure.d.ts +13 -0
  306. package/dist/modes/interactive/components/session-failure.d.ts.map +1 -0
  307. package/dist/modes/interactive/components/session-failure.js +81 -0
  308. package/dist/modes/interactive/components/session-failure.js.map +1 -0
  309. package/dist/modes/interactive/interactive-mode.d.ts +1 -0
  310. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  311. package/dist/modes/interactive/interactive-mode.js +47 -36
  312. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  313. package/dist/modes/interactive/resource-description.d.ts +3 -0
  314. package/dist/modes/interactive/resource-description.d.ts.map +1 -0
  315. package/dist/modes/interactive/resource-description.js +15 -0
  316. package/dist/modes/interactive/resource-description.js.map +1 -0
  317. package/dist/modes/interactive/tui-diagnostics.d.ts +36 -0
  318. package/dist/modes/interactive/tui-diagnostics.d.ts.map +1 -0
  319. package/dist/modes/interactive/tui-diagnostics.js +105 -0
  320. package/dist/modes/interactive/tui-diagnostics.js.map +1 -0
  321. package/dist/modes/interactive/tui-runtime-info.d.ts +20 -0
  322. package/dist/modes/interactive/tui-runtime-info.d.ts.map +1 -0
  323. package/dist/modes/interactive/tui-runtime-info.js +76 -0
  324. package/dist/modes/interactive/tui-runtime-info.js.map +1 -0
  325. package/docs/development.md +10 -0
  326. package/docs/devin-harness.md +121 -0
  327. package/docs/docs.json +4 -0
  328. package/docs/environment-variables.md +2 -1
  329. package/docs/index.md +1 -0
  330. package/docs/keybindings.md +1 -1
  331. package/docs/loadout-domains/README.md +2 -1
  332. package/docs/loadout-domains/devin-harness.md +72 -0
  333. package/docs/metrics.md +57 -16
  334. package/docs/providers.md +76 -0
  335. package/docs/release-audit-0.98.5.md +101 -0
  336. package/docs/release-audit-0.99.0.md +68 -0
  337. package/docs/run-protocol.md +34 -1
  338. package/docs/runtime-algorithms.md +30 -1
  339. package/docs/sdk.md +198 -1
  340. package/docs/settings.md +1 -1
  341. package/docs/startup-resource-labels-testing.md +47 -0
  342. package/docs/tb21-audit.md +18 -4
  343. package/docs/usage.md +59 -0
  344. package/docs/verified-run-remaining-design.md +881 -0
  345. package/docs/verified-run-testing.md +508 -0
  346. package/docs/verified-run.md +409 -0
  347. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  348. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  349. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  350. package/examples/extensions/gondolin/package-lock.json +2 -2
  351. package/examples/extensions/gondolin/package.json +1 -1
  352. package/examples/extensions/sandbox/package-lock.json +2 -2
  353. package/examples/extensions/sandbox/package.json +1 -1
  354. package/examples/extensions/with-deps/package-lock.json +2 -2
  355. package/examples/extensions/with-deps/package.json +1 -1
  356. package/npm-shrinkwrap.json +18 -18
  357. package/package.json +6 -6
@@ -40,6 +40,7 @@ import { createDiskContextBudgetCacheProviderV2, DiskContextBudgetCacheProviderV
40
40
  import { applyContextCacheInvalidation, createContextCacheInvalidationSnapshot, } from "./context-budget-v2-cache-invalidation.js";
41
41
  import { createMemoryContextBudgetCacheProviderV2 } from "./context-budget-v2-cache-provider.js";
42
42
  import { DEFAULT_THINKING_LEVEL } from "./defaults.js";
43
+ import { devinHarnessAutoApplyEnabled, devinPlaybookAppendForProvider, isDevinProvider, selectDevinHarnessSkills, } from "./devin-harness.js";
43
44
  import { exportSessionToHtml } from "./export-html/index.js";
44
45
  import { createToolHtmlRenderer } from "./export-html/tool-renderer.js";
45
46
  import { ExtensionRunner, wrapRegisteredTools, } from "./extensions/index.js";
@@ -103,6 +104,7 @@ import { resolveResourceGovernorSettings } from "./resource-governor-settings.js
103
104
  import { admissionObservationFacts, classificationObservationFacts, ResourceObservationJournal, settledObservationFacts, snapshotObservationFacts, soundObservationFacts, } from "./resource-observation-journal.js";
104
105
  import { decideResourceSafetyGate, RESOURCE_PRESSURE_REQUIRED_ACTION } from "./resource-safety-gate.js";
105
106
  import { appendRouterFeedbackRecord, ROUTER_FEEDBACK_LEVELS, } from "./router-feedback-collector.js";
107
+ import { RunBudgetExceededError, RunBudgetPolicyError } from "./run-budget-policy.js";
106
108
  import { RunJournalStore } from "./run-journal-store.js";
107
109
  import { RunResourceLeaseController } from "./run-resource-lease.js";
108
110
  import { SessionBashRuntime } from "./session-bash-runtime.js";
@@ -111,6 +113,8 @@ import { SessionCompactionService } from "./session-compaction-service.js";
111
113
  import { preflightFailureCause, runtimeFailureCause, terminationMessage } from "./session-failure-cause.js";
112
114
  import { CURRENT_SESSION_VERSION, getLatestCompactionEntry } from "./session-manager.js";
113
115
  import { acquireSessionOwnerLeaseSync } from "./session-owner-lease.js";
116
+ import { PromptExecutionBusyError, SessionPromptLifecycle } from "./session-prompt-lifecycle.js";
117
+ import { SessionRunBudget } from "./session-run-budget.js";
114
118
  import { classifyRunTermination } from "./session-run-termination.js";
115
119
  import { assembleSessionSystemPrompt } from "./session-system-prompt.js";
116
120
  import { classifySessionTermination, } from "./session-termination.js";
@@ -217,6 +221,11 @@ export class AgentSession {
217
221
  // Event subscription state
218
222
  _unsubscribeAgent;
219
223
  _eventListeners = [];
224
+ _runBudget;
225
+ _promptLifecycle = new SessionPromptLifecycle({
226
+ canSettle: () => !this.isStreaming && !this.agent.hasQueuedMessages(),
227
+ auditsLateSettlement: () => this.agent.toolExecutionPolicy?.lateSettlement !== "ignore",
228
+ });
220
229
  _messageEndReplacements = new WeakMap();
221
230
  /** Tracks pending steering messages for UI display. Removed when delivered. */
222
231
  _steeringMessages = [];
@@ -313,6 +322,21 @@ export class AgentSession {
313
322
  _promptCacheLastBreakReason;
314
323
  constructor(config) {
315
324
  this.agent = config.agent;
325
+ this._runBudget = new SessionRunBudget(this.agent, {
326
+ assertIdle: () => {
327
+ this._promptLifecycle.assertIdle();
328
+ if (this.isRetrying || this.isCompacting || this._branchSummaryAbortController)
329
+ throw new PromptExecutionBusyError();
330
+ },
331
+ stop: (error) => {
332
+ this._pendingRuntimeTerminationCause = { area: "budget", code: error.code };
333
+ this.agent.abort();
334
+ this.abortRetry();
335
+ this.abortCompaction();
336
+ this.abortBranchSummary();
337
+ },
338
+ reject: (error) => this._publishRuntimeFailure(error),
339
+ });
316
340
  this.sessionManager = config.sessionManager;
317
341
  this.settingsManager = config.settingsManager;
318
342
  this._scopedModels = config.scopedModels ?? [];
@@ -511,6 +535,12 @@ export class AgentSession {
511
535
  this._emit({ type: "session_termination", termination });
512
536
  }
513
537
  _publishRuntimeFailure(error) {
538
+ // A caller rejected by "Agent is already processing" never owned a run: the
539
+ // open journal run belongs to the live run, and closing it here would make
540
+ // that run die later with "agent_end without run_started". Let the caller
541
+ // surface its own error and leave the live run's journal alone.
542
+ if (this.isStreaming)
543
+ return;
514
544
  const cause = this._pendingRuntimeTerminationCause ?? runtimeFailureCause(error);
515
545
  const runId = this._activeRunId ?? `runtime-${randomUUID()}`;
516
546
  const timestamp = new Date().toISOString();
@@ -688,6 +718,7 @@ export class AgentSession {
688
718
  throw new Error(formatNoApiKeyFoundMessage(model.provider));
689
719
  }
690
720
  async _getCompactionRequestAuth(model) {
721
+ this._runBudget.assertAdmission();
691
722
  const options = { minRemainingMs: COMPACTION_MIN_TOKEN_VALIDITY_MS };
692
723
  if (isBuiltinStreamFn(this.agent.streamFn)) {
693
724
  return this._getRequiredRequestAuth(model, options);
@@ -842,6 +873,8 @@ export class AgentSession {
842
873
  }
843
874
  }
844
875
  }
876
+ if (event.type === "tool_execution_late_settlement")
877
+ this._promptLifecycle.flush();
845
878
  };
846
879
  _willRetryAfterAgentEnd(event) {
847
880
  const settings = this.settingsManager.getRetrySettings();
@@ -1109,6 +1142,8 @@ export class AgentSession {
1109
1142
  * Call this when completely done with the session.
1110
1143
  */
1111
1144
  dispose() {
1145
+ this._promptLifecycle.dispose();
1146
+ this._runBudget.close();
1112
1147
  try {
1113
1148
  try {
1114
1149
  this.abortRetry();
@@ -1235,7 +1270,7 @@ export class AgentSession {
1235
1270
  for (const name of desiredToolNames) {
1236
1271
  const tool = this._toolRegistry.get(name);
1237
1272
  if (tool) {
1238
- tools.push(tool);
1273
+ tools.push(this._promptLifecycle.wrapTool(tool));
1239
1274
  validToolNames.push(name);
1240
1275
  }
1241
1276
  else if (lockedToolNames?.includes(name)) {
@@ -1442,7 +1477,7 @@ export class AgentSession {
1442
1477
  toolPromptGuidelines: this._toolPromptGuidelines,
1443
1478
  customPrompt: this._resourceLoader.getSystemPrompt(),
1444
1479
  appendSystemPrompt: this._resourceLoader.getAppendSystemPrompt(),
1445
- providerAppend: grokPlaybookAppendForProvider(model?.provider),
1480
+ providerAppend: grokPlaybookAppendForProvider(model?.provider) ?? devinPlaybookAppendForProvider(model?.provider),
1446
1481
  skills: this._resourceLoader.getSkills().skills,
1447
1482
  activeSkillNames: defaultActiveSkills,
1448
1483
  activeSkillSource: defaultActiveSkills.length > 0 ? "settings" : undefined,
@@ -1460,13 +1495,14 @@ export class AgentSession {
1460
1495
  // One identity per top-level run (§16.2): internal retries and
1461
1496
  // continuations inside this call share it, as does the resource lease.
1462
1497
  const promptRunId = `prompt-run-${randomUUID()}`;
1463
- const startedAtEpochMs = Date.now();
1498
+ const ownedRun = this._promptLifecycle.begin(promptRunId);
1464
1499
  // Roadmap M2: the lease spans the whole run including internal retries
1465
1500
  // and continuations, so they share one admission decision (§8.3).
1466
1501
  const resourceLease = await this._beginResourceGovernedRun(promptRunId);
1467
1502
  const resourceObservations = this._resourceObservationJournals.get(promptRunId) ?? null;
1468
1503
  let outcome = "completed";
1469
1504
  try {
1505
+ this._runBudget.assertActive();
1470
1506
  await this.agent.prompt(messages);
1471
1507
  while (await this._handlePostAgentRun()) {
1472
1508
  await this.agent.continue();
@@ -1478,43 +1514,18 @@ export class AgentSession {
1478
1514
  throw error;
1479
1515
  }
1480
1516
  finally {
1517
+ if (this._runBudget.failure && this._lastTermination?.kind !== "budget_exhausted")
1518
+ this._publishRuntimeFailure(this._runBudget.failure);
1481
1519
  outcome = promptSettlement.resolvePromptSettlementOutcome(outcome, this._lastTermination?.kind);
1482
- if (resourceLease !== null) {
1483
- // Generation-safe: a stale release after another run acquired the
1484
- // lease is a no-op instead of clobbering the newer cap (§8.1).
1485
- this._resourceLeaseController?.release(resourceLease);
1486
- resourceObservations?.record("resource_lease_released_v1", { promptRunId });
1487
- }
1488
1520
  this._flushPendingBashMessages();
1489
- // §16.4 (M4): settle only after every in-run continuation drained.
1490
- this._emitPromptSettledIfReady({ promptRunId, startedAtEpochMs, outcome, resourceObservations });
1491
- }
1492
- }
1493
- /**
1494
- * Emit `prompt_settled` when the §16.4 conditions hold. Called exactly
1495
- * once per promptRunId (from `_runAgentPrompt`'s finally), so the same
1496
- * run can never emit twice; late-queued messages block emission
1497
- * conservatively — the continuation run settles under its own id.
1498
- * Settlement is a UX signal only and must never affect the run (§16.1).
1499
- */
1500
- _emitPromptSettledIfReady(input) {
1501
- try {
1502
- let state = promptSettlement.createPromptSettlementState(input.promptRunId, input.startedAtEpochMs);
1503
- state = promptSettlement.reducePromptSettlement(state, { kind: "terminal", outcome: input.outcome });
1504
- if (this.isStreaming) {
1505
- state = promptSettlement.reducePromptSettlement(state, { kind: "tool", delta: 1 });
1506
- }
1507
- if (this.agent.hasQueuedMessages()) {
1508
- state = promptSettlement.reducePromptSettlement(state, { kind: "continuation", delta: 1 });
1509
- }
1510
- const settled = promptSettlement.settlePromptIfReady(state, Date.now());
1511
- if (settled.event !== null) {
1512
- input.resourceObservations?.record("prompt_settled_v1", settledObservationFacts(settled.event));
1513
- this._emit(settled.event);
1514
- }
1515
- }
1516
- catch {
1517
- // Never let settlement bookkeeping break a run.
1521
+ ownedRun.finish(outcome, (event) => {
1522
+ if (resourceLease !== null) {
1523
+ this._resourceLeaseController?.release(resourceLease);
1524
+ resourceObservations?.record("resource_lease_released_v1", { promptRunId });
1525
+ }
1526
+ resourceObservations?.record("prompt_settled_v1", settledObservationFacts(event));
1527
+ this._emit(event);
1528
+ });
1518
1529
  }
1519
1530
  }
1520
1531
  /**
@@ -1526,7 +1537,7 @@ export class AgentSession {
1526
1537
  * delayed. The pending probe is bounded (~cpuSampleMs) and never rejects.
1527
1538
  * - `adaptive`/`strict`: bounded blocking probe (default 300 ms deadline),
1528
1539
  * then a generation-safe lease applies the effective tool cap for this
1529
- * run. The caller's `finally` releases it exactly once.
1540
+ * run. Prompt settlement releases it after owned tool promises terminate.
1530
1541
  *
1531
1542
  * Never throws: any probe or policy failure leaves this run ungoverned
1532
1543
  * (§2.1: probe failure must not crash or block the prompt).
@@ -1721,6 +1732,7 @@ export class AgentSession {
1721
1732
  }
1722
1733
  }
1723
1734
  async _handlePostAgentRun() {
1735
+ this._runBudget.assertActive();
1724
1736
  const msg = this._lastAssistantMessage;
1725
1737
  this._lastAssistantMessage = undefined;
1726
1738
  if (!msg) {
@@ -1755,7 +1767,15 @@ export class AgentSession {
1755
1767
  * @throws Error if streaming and no streamingBehavior specified
1756
1768
  * @throws Error if no model selected or no API key available (when not streaming)
1757
1769
  */
1758
- async prompt(text, options) {
1770
+ prompt(text, options) {
1771
+ if (options?.runBudget === undefined && (this.isStreaming || this.isRetrying))
1772
+ return this._prompt(text, options);
1773
+ return this._runBudget.execute(options?.runBudget, () => this._prompt(text, options), options?.preflightResult);
1774
+ }
1775
+ getRunBudgetSnapshot() {
1776
+ return this._runBudget.snapshot();
1777
+ }
1778
+ async _prompt(text, options) {
1759
1779
  const expandPromptTemplates = options?.expandPromptTemplates ?? true;
1760
1780
  const preflightResult = options?.preflightResult;
1761
1781
  let currentText = redactSensitiveText(text);
@@ -1820,6 +1840,7 @@ export class AgentSession {
1820
1840
  preflightResult?.(true);
1821
1841
  return;
1822
1842
  }
1843
+ this._promptLifecycle.assertIdle();
1823
1844
  // Flush any pending bash messages before the new prompt
1824
1845
  this._flushPendingBashMessages();
1825
1846
  // Validate model
@@ -1879,6 +1900,13 @@ export class AgentSession {
1879
1900
  });
1880
1901
  promptSkills = addActiveSkills(promptSkills, grokSkills, "grok-harness");
1881
1902
  }
1903
+ else if (isDevinProvider(this.model?.provider) && devinHarnessAutoApplyEnabled(process.env)) {
1904
+ const skillQuery = isBangSkillInvocation ? currentText : expandedText;
1905
+ const devinSkills = selectDevinHarnessSkills(skillQuery, this._resourceLoader.getSkills().skills, {
1906
+ contextPressure: this._computePressureBucket(messages) > 0,
1907
+ });
1908
+ promptSkills = addActiveSkills(promptSkills, devinSkills, "devin-harness");
1909
+ }
1882
1910
  const turnSystemPromptOptions = {
1883
1911
  ...this._baseSystemPromptOptions,
1884
1912
  contextBudget: this._getContextBudgetOptions(expandedText),
@@ -1918,11 +1946,16 @@ export class AgentSession {
1918
1946
  }
1919
1947
  this._recordPromptCachePlan(result?.systemPrompt ? "extension-override" : "turn-plan");
1920
1948
  await this._checkProjectedCompaction(messages);
1949
+ this._runBudget.assertActive();
1921
1950
  }
1922
1951
  catch (error) {
1923
1952
  preflightResult?.(false);
1924
1953
  const rawMessage = error instanceof Error ? error.message : String(error);
1925
- const cause = preflightFailureCause(rawMessage, Boolean(this.model));
1954
+ const cause = error instanceof RunBudgetExceededError
1955
+ ? { area: "budget", code: error.code }
1956
+ : error instanceof RunBudgetPolicyError
1957
+ ? { area: "configuration", code: "invalid" }
1958
+ : preflightFailureCause(rawMessage, Boolean(this.model));
1926
1959
  const timestamp = new Date().toISOString();
1927
1960
  this._publishTermination(classifySessionTermination({
1928
1961
  sessionId: this.sessionId,
@@ -2105,7 +2138,10 @@ export class AgentSession {
2105
2138
  if (options?.deliverAs === "nextTurn") {
2106
2139
  this._pendingNextTurnMessages.push(appMessage);
2107
2140
  }
2108
- else if (this.isStreaming) {
2141
+ else if (this.isStreaming || this.isRetrying) {
2142
+ // Retry backoff still owns the session (mirrors prompt()): starting a
2143
+ // top-level run here races the pending agent.continue() and wedges the
2144
+ // run journal, so queue for the retried run to drain instead.
2109
2145
  if (options?.deliverAs === "followUp") {
2110
2146
  this.agent.followUp(appMessage);
2111
2147
  }
@@ -2172,6 +2208,7 @@ export class AgentSession {
2172
2208
  this._followUpMessages = [];
2173
2209
  this.agent.clearAllQueues();
2174
2210
  this._emitQueueUpdate();
2211
+ this._promptLifecycle.flush();
2175
2212
  return { steering, followUp };
2176
2213
  }
2177
2214
  /** Number of pending messages (includes both steering and follow-up) */
@@ -3938,7 +3975,7 @@ export class AgentSession {
3938
3975
  const failoverTo = await this._maybeFailoverFromSafetyStop(message);
3939
3976
  const switchedVia = failoverTo ? `failover ${failoverTo}` : rotatedTo ? `route ${rotatedTo}` : undefined;
3940
3977
  // Safety stops are usually immediate false positives — short delay after failover, full backoff otherwise.
3941
- const delayMs = computeRetryDelayMs(settings.baseDelayMs, attempt, switchedVia !== undefined);
3978
+ const delayMs = Math.min(computeRetryDelayMs(settings.baseDelayMs, attempt, switchedVia !== undefined), this._runBudget.remainingMs ?? Infinity);
3942
3979
  const errorMessage = switchedVia
3943
3980
  ? `${message.errorMessage || "content/safety stop"} → ${switchedVia}`
3944
3981
  : message.errorMessage || "Unknown error";