open-multi-agent-kit 0.99.0 → 1.2.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 (464) hide show
  1. package/CHANGELOG.md +30 -1
  2. package/README.md +3 -3
  3. package/dist/bun/cli.d.ts.map +1 -1
  4. package/dist/bun/cli.js +1 -0
  5. package/dist/bun/cli.js.map +1 -1
  6. package/dist/bun/register-bundled-coding-agent.d.ts +10 -0
  7. package/dist/bun/register-bundled-coding-agent.d.ts.map +1 -0
  8. package/dist/bun/register-bundled-coding-agent.js +12 -0
  9. package/dist/bun/register-bundled-coding-agent.js.map +1 -0
  10. package/dist/cli/args.d.ts +1 -1
  11. package/dist/cli/args.d.ts.map +1 -1
  12. package/dist/cli/args.js +1 -1
  13. package/dist/cli/args.js.map +1 -1
  14. package/dist/cli/help.d.ts.map +1 -1
  15. package/dist/cli/help.js +2 -1
  16. package/dist/cli/help.js.map +1 -1
  17. package/dist/cli.d.ts.map +1 -1
  18. package/dist/cli.js +14 -2
  19. package/dist/cli.js.map +1 -1
  20. package/dist/commands/neo-cli.d.ts +9 -0
  21. package/dist/commands/neo-cli.d.ts.map +1 -0
  22. package/dist/commands/neo-cli.js +61 -0
  23. package/dist/commands/neo-cli.js.map +1 -0
  24. package/dist/coordination/awareness.d.ts +32 -0
  25. package/dist/coordination/awareness.d.ts.map +1 -0
  26. package/dist/coordination/awareness.js +55 -0
  27. package/dist/coordination/awareness.js.map +1 -0
  28. package/dist/coordination/broker.d.ts +79 -0
  29. package/dist/coordination/broker.d.ts.map +1 -0
  30. package/dist/coordination/broker.js +195 -0
  31. package/dist/coordination/broker.js.map +1 -0
  32. package/dist/coordination/index.d.ts +16 -0
  33. package/dist/coordination/index.d.ts.map +1 -0
  34. package/dist/coordination/index.js +16 -0
  35. package/dist/coordination/index.js.map +1 -0
  36. package/dist/coordination/integration.d.ts +59 -0
  37. package/dist/coordination/integration.d.ts.map +1 -0
  38. package/dist/coordination/integration.js +126 -0
  39. package/dist/coordination/integration.js.map +1 -0
  40. package/dist/coordination/operation.d.ts +106 -0
  41. package/dist/coordination/operation.d.ts.map +1 -0
  42. package/dist/coordination/operation.js +179 -0
  43. package/dist/coordination/operation.js.map +1 -0
  44. package/dist/coordination/resource.d.ts +33 -0
  45. package/dist/coordination/resource.d.ts.map +1 -0
  46. package/dist/coordination/resource.js +89 -0
  47. package/dist/coordination/resource.js.map +1 -0
  48. package/dist/coordination/session.d.ts +74 -0
  49. package/dist/coordination/session.d.ts.map +1 -0
  50. package/dist/coordination/session.js +143 -0
  51. package/dist/coordination/session.js.map +1 -0
  52. package/dist/coordination/types.d.ts +68 -0
  53. package/dist/coordination/types.d.ts.map +1 -0
  54. package/dist/coordination/types.js +26 -0
  55. package/dist/coordination/types.js.map +1 -0
  56. package/dist/core/agent-session.d.ts +29 -2
  57. package/dist/core/agent-session.d.ts.map +1 -1
  58. package/dist/core/agent-session.js +135 -37
  59. package/dist/core/agent-session.js.map +1 -1
  60. package/dist/core/bundled-skills.d.ts +4 -0
  61. package/dist/core/bundled-skills.d.ts.map +1 -0
  62. package/dist/core/bundled-skills.js +32 -0
  63. package/dist/core/bundled-skills.js.map +1 -0
  64. package/dist/core/cli-diagnostics.d.ts +6 -0
  65. package/dist/core/cli-diagnostics.d.ts.map +1 -0
  66. package/dist/core/cli-diagnostics.js +20 -0
  67. package/dist/core/cli-diagnostics.js.map +1 -0
  68. package/dist/core/compaction/control-state.d.ts +41 -0
  69. package/dist/core/compaction/control-state.d.ts.map +1 -0
  70. package/dist/core/compaction/control-state.js +85 -0
  71. package/dist/core/compaction/control-state.js.map +1 -0
  72. package/dist/core/compaction/fallback.d.ts +60 -0
  73. package/dist/core/compaction/fallback.d.ts.map +1 -0
  74. package/dist/core/compaction/fallback.js +117 -0
  75. package/dist/core/compaction/fallback.js.map +1 -0
  76. package/dist/core/compaction/index.d.ts +2 -0
  77. package/dist/core/compaction/index.d.ts.map +1 -1
  78. package/dist/core/compaction/index.js +2 -0
  79. package/dist/core/compaction/index.js.map +1 -1
  80. package/dist/core/context-budget-headroom-candidates.d.ts +16 -1
  81. package/dist/core/context-budget-headroom-candidates.d.ts.map +1 -1
  82. package/dist/core/context-budget-headroom-candidates.js +31 -13
  83. package/dist/core/context-budget-headroom-candidates.js.map +1 -1
  84. package/dist/core/context-budget-headroom-types.d.ts +7 -1
  85. package/dist/core/context-budget-headroom-types.d.ts.map +1 -1
  86. package/dist/core/context-budget-headroom-types.js +0 -1
  87. package/dist/core/context-budget-headroom-types.js.map +1 -1
  88. package/dist/core/context-budget-headroom.d.ts +22 -0
  89. package/dist/core/context-budget-headroom.d.ts.map +1 -1
  90. package/dist/core/context-budget-headroom.js +46 -2
  91. package/dist/core/context-budget-headroom.js.map +1 -1
  92. package/dist/core/context-budget-v2-global-pass.d.ts +21 -0
  93. package/dist/core/context-budget-v2-global-pass.d.ts.map +1 -0
  94. package/dist/core/context-budget-v2-global-pass.js +203 -0
  95. package/dist/core/context-budget-v2-global-pass.js.map +1 -0
  96. package/dist/core/context-budget-v2-input-validation.d.ts +4 -0
  97. package/dist/core/context-budget-v2-input-validation.d.ts.map +1 -0
  98. package/dist/core/context-budget-v2-input-validation.js +79 -0
  99. package/dist/core/context-budget-v2-input-validation.js.map +1 -0
  100. package/dist/core/context-budget-v2-observability.d.ts +15 -0
  101. package/dist/core/context-budget-v2-observability.d.ts.map +1 -0
  102. package/dist/core/context-budget-v2-observability.js +35 -0
  103. package/dist/core/context-budget-v2-observability.js.map +1 -0
  104. package/dist/core/context-budget-v2-planned-items.d.ts +17 -0
  105. package/dist/core/context-budget-v2-planned-items.d.ts.map +1 -0
  106. package/dist/core/context-budget-v2-planned-items.js +59 -0
  107. package/dist/core/context-budget-v2-planned-items.js.map +1 -0
  108. package/dist/core/context-budget-v2-planner.d.ts.map +1 -1
  109. package/dist/core/context-budget-v2-planner.js +69 -51
  110. package/dist/core/context-budget-v2-planner.js.map +1 -1
  111. package/dist/core/context-budget-v2-scoring.d.ts +7 -1
  112. package/dist/core/context-budget-v2-scoring.d.ts.map +1 -1
  113. package/dist/core/context-budget-v2-scoring.js.map +1 -1
  114. package/dist/core/context-budget-v2-selection.d.ts +22 -3
  115. package/dist/core/context-budget-v2-selection.d.ts.map +1 -1
  116. package/dist/core/context-budget-v2-selection.js +41 -59
  117. package/dist/core/context-budget-v2-selection.js.map +1 -1
  118. package/dist/core/context-budget-v2-tiers.d.ts.map +1 -1
  119. package/dist/core/context-budget-v2-tiers.js +9 -42
  120. package/dist/core/context-budget-v2-tiers.js.map +1 -1
  121. package/dist/core/context-budget-v2-types.d.ts +14 -2
  122. package/dist/core/context-budget-v2-types.d.ts.map +1 -1
  123. package/dist/core/context-budget-v2-types.js +6 -1
  124. package/dist/core/context-budget-v2-types.js.map +1 -1
  125. package/dist/core/extensions/bundled-virtual-modules.d.ts +15 -0
  126. package/dist/core/extensions/bundled-virtual-modules.d.ts.map +1 -0
  127. package/dist/core/extensions/bundled-virtual-modules.js +63 -0
  128. package/dist/core/extensions/bundled-virtual-modules.js.map +1 -0
  129. package/dist/core/extensions/loader.d.ts.map +1 -1
  130. package/dist/core/extensions/loader.js +2 -42
  131. package/dist/core/extensions/loader.js.map +1 -1
  132. package/dist/core/extensions/runner.d.ts +1 -0
  133. package/dist/core/extensions/runner.d.ts.map +1 -1
  134. package/dist/core/extensions/runner.js +6 -0
  135. package/dist/core/extensions/runner.js.map +1 -1
  136. package/dist/core/extensions/types.d.ts +10 -0
  137. package/dist/core/extensions/types.d.ts.map +1 -1
  138. package/dist/core/extensions/types.js.map +1 -1
  139. package/dist/core/index.d.ts +2 -1
  140. package/dist/core/index.d.ts.map +1 -1
  141. package/dist/core/index.js +2 -1
  142. package/dist/core/index.js.map +1 -1
  143. package/dist/core/loadout-runtime.d.ts +2 -8
  144. package/dist/core/loadout-runtime.d.ts.map +1 -1
  145. package/dist/core/loadout-runtime.js.map +1 -1
  146. package/dist/core/mcp/client.d.ts +27 -6
  147. package/dist/core/mcp/client.d.ts.map +1 -1
  148. package/dist/core/mcp/client.js +80 -20
  149. package/dist/core/mcp/client.js.map +1 -1
  150. package/dist/core/mcp/manager.d.ts +10 -1
  151. package/dist/core/mcp/manager.d.ts.map +1 -1
  152. package/dist/core/mcp/manager.js +68 -9
  153. package/dist/core/mcp/manager.js.map +1 -1
  154. package/dist/core/mcp/protocol.d.ts +9 -3
  155. package/dist/core/mcp/protocol.d.ts.map +1 -1
  156. package/dist/core/mcp/protocol.js +61 -15
  157. package/dist/core/mcp/protocol.js.map +1 -1
  158. package/dist/core/mcp/stdio-transport.d.ts +12 -1
  159. package/dist/core/mcp/stdio-transport.d.ts.map +1 -1
  160. package/dist/core/mcp/stdio-transport.js +30 -2
  161. package/dist/core/mcp/stdio-transport.js.map +1 -1
  162. package/dist/core/mcp-descriptor-injection.d.ts +26 -0
  163. package/dist/core/mcp-descriptor-injection.d.ts.map +1 -0
  164. package/dist/core/mcp-descriptor-injection.js +25 -0
  165. package/dist/core/mcp-descriptor-injection.js.map +1 -0
  166. package/dist/core/mcp-public-presets.d.ts +1 -3
  167. package/dist/core/mcp-public-presets.d.ts.map +1 -1
  168. package/dist/core/mcp-public-presets.js +3 -15
  169. package/dist/core/mcp-public-presets.js.map +1 -1
  170. package/dist/core/model-registry.d.ts.map +1 -1
  171. package/dist/core/model-registry.js +24 -3
  172. package/dist/core/model-registry.js.map +1 -1
  173. package/dist/core/neo/catalog.d.ts +20 -0
  174. package/dist/core/neo/catalog.d.ts.map +1 -0
  175. package/dist/core/neo/catalog.js +50 -0
  176. package/dist/core/neo/catalog.js.map +1 -0
  177. package/dist/core/neo/setup.d.ts +3 -0
  178. package/dist/core/neo/setup.d.ts.map +1 -0
  179. package/dist/core/neo/setup.js +47 -0
  180. package/dist/core/neo/setup.js.map +1 -0
  181. package/dist/core/provider-default-models.d.ts +2 -0
  182. package/dist/core/provider-default-models.d.ts.map +1 -1
  183. package/dist/core/provider-default-models.js +2 -0
  184. package/dist/core/provider-default-models.js.map +1 -1
  185. package/dist/core/provider-display-names.d.ts.map +1 -1
  186. package/dist/core/provider-display-names.js +2 -0
  187. package/dist/core/provider-display-names.js.map +1 -1
  188. package/dist/core/provider-error-classification.d.ts +57 -0
  189. package/dist/core/provider-error-classification.d.ts.map +1 -0
  190. package/dist/core/provider-error-classification.js +103 -0
  191. package/dist/core/provider-error-classification.js.map +1 -0
  192. package/dist/core/provider-resilience.d.ts +10 -0
  193. package/dist/core/provider-resilience.d.ts.map +1 -1
  194. package/dist/core/provider-resilience.js +36 -3
  195. package/dist/core/provider-resilience.js.map +1 -1
  196. package/dist/core/provider-usage-commandcode.d.ts +9 -0
  197. package/dist/core/provider-usage-commandcode.d.ts.map +1 -0
  198. package/dist/core/provider-usage-commandcode.js +198 -0
  199. package/dist/core/provider-usage-commandcode.js.map +1 -0
  200. package/dist/core/provider-usage-devin.d.ts +5 -3
  201. package/dist/core/provider-usage-devin.d.ts.map +1 -1
  202. package/dist/core/provider-usage-devin.js +15 -5
  203. package/dist/core/provider-usage-devin.js.map +1 -1
  204. package/dist/core/provider-usage-types.d.ts +1 -1
  205. package/dist/core/provider-usage-types.d.ts.map +1 -1
  206. package/dist/core/provider-usage-types.js.map +1 -1
  207. package/dist/core/provider-usage.d.ts.map +1 -1
  208. package/dist/core/provider-usage.js +6 -0
  209. package/dist/core/provider-usage.js.map +1 -1
  210. package/dist/core/reasoning-router-resolver.d.ts +7 -0
  211. package/dist/core/reasoning-router-resolver.d.ts.map +1 -1
  212. package/dist/core/reasoning-router-resolver.js +21 -3
  213. package/dist/core/reasoning-router-resolver.js.map +1 -1
  214. package/dist/core/reasoning-router-v4.d.ts +8 -5
  215. package/dist/core/reasoning-router-v4.d.ts.map +1 -1
  216. package/dist/core/reasoning-router-v4.js +8 -5
  217. package/dist/core/reasoning-router-v4.js.map +1 -1
  218. package/dist/core/resource-admission.d.ts +36 -0
  219. package/dist/core/resource-admission.d.ts.map +1 -1
  220. package/dist/core/resource-admission.js +59 -0
  221. package/dist/core/resource-admission.js.map +1 -1
  222. package/dist/core/resource-loader.d.ts.map +1 -1
  223. package/dist/core/resource-loader.js +2 -2
  224. package/dist/core/resource-loader.js.map +1 -1
  225. package/dist/core/run-usage-ledger.d.ts +47 -0
  226. package/dist/core/run-usage-ledger.d.ts.map +1 -0
  227. package/dist/core/run-usage-ledger.js +162 -0
  228. package/dist/core/run-usage-ledger.js.map +1 -0
  229. package/dist/core/run-usage-operation.d.ts +8 -0
  230. package/dist/core/run-usage-operation.d.ts.map +1 -0
  231. package/dist/core/run-usage-operation.js +12 -0
  232. package/dist/core/run-usage-operation.js.map +1 -0
  233. package/dist/core/sdk.d.ts.map +1 -1
  234. package/dist/core/sdk.js +5 -6
  235. package/dist/core/sdk.js.map +1 -1
  236. package/dist/core/session-compaction-service.d.ts +15 -0
  237. package/dist/core/session-compaction-service.d.ts.map +1 -1
  238. package/dist/core/session-compaction-service.js +17 -4
  239. package/dist/core/session-compaction-service.js.map +1 -1
  240. package/dist/core/session-failure-cause.d.ts.map +1 -1
  241. package/dist/core/session-failure-cause.js +14 -5
  242. package/dist/core/session-failure-cause.js.map +1 -1
  243. package/dist/core/session-prompt-lifecycle.d.ts +6 -0
  244. package/dist/core/session-prompt-lifecycle.d.ts.map +1 -1
  245. package/dist/core/session-prompt-lifecycle.js +47 -2
  246. package/dist/core/session-prompt-lifecycle.js.map +1 -1
  247. package/dist/core/session-termination.d.ts.map +1 -1
  248. package/dist/core/session-termination.js +4 -2
  249. package/dist/core/session-termination.js.map +1 -1
  250. package/dist/core/subagent-lane-authority.d.ts +28 -0
  251. package/dist/core/subagent-lane-authority.d.ts.map +1 -0
  252. package/dist/core/subagent-lane-authority.js +119 -0
  253. package/dist/core/subagent-lane-authority.js.map +1 -0
  254. package/dist/core/subagent-lane-contract.d.ts +114 -0
  255. package/dist/core/subagent-lane-contract.d.ts.map +1 -0
  256. package/dist/core/subagent-lane-contract.js +18 -0
  257. package/dist/core/subagent-lane-contract.js.map +1 -0
  258. package/dist/core/subagent-lane-launcher.d.ts +3 -6
  259. package/dist/core/subagent-lane-launcher.d.ts.map +1 -1
  260. package/dist/core/subagent-lane-launcher.js +53 -12
  261. package/dist/core/subagent-lane-launcher.js.map +1 -1
  262. package/dist/core/subagent-orchestration.d.ts +4 -17
  263. package/dist/core/subagent-orchestration.d.ts.map +1 -1
  264. package/dist/core/subagent-orchestration.js.map +1 -1
  265. package/dist/core/todo-runtime-state.d.ts +12 -0
  266. package/dist/core/todo-runtime-state.d.ts.map +1 -1
  267. package/dist/core/todo-runtime-state.js +23 -0
  268. package/dist/core/todo-runtime-state.js.map +1 -1
  269. package/dist/core/verified-run/broker.d.ts.map +1 -1
  270. package/dist/core/verified-run/broker.js +4 -1
  271. package/dist/core/verified-run/broker.js.map +1 -1
  272. package/dist/core/workload-permit-pool.d.ts +1 -1
  273. package/dist/core/workload-permit-pool.d.ts.map +1 -1
  274. package/dist/core/workload-permit-pool.js +3 -0
  275. package/dist/core/workload-permit-pool.js.map +1 -1
  276. package/dist/guardrails/strict-evidence-approval-adapter.d.ts +34 -0
  277. package/dist/guardrails/strict-evidence-approval-adapter.d.ts.map +1 -0
  278. package/dist/guardrails/strict-evidence-approval-adapter.js +70 -0
  279. package/dist/guardrails/strict-evidence-approval-adapter.js.map +1 -0
  280. package/dist/index.d.ts +5 -0
  281. package/dist/index.d.ts.map +1 -1
  282. package/dist/index.js +3 -0
  283. package/dist/index.js.map +1 -1
  284. package/dist/main.d.ts.map +1 -1
  285. package/dist/main.js +11 -18
  286. package/dist/main.js.map +1 -1
  287. package/dist/metacognition/calibration-selective.d.ts +78 -0
  288. package/dist/metacognition/calibration-selective.d.ts.map +1 -0
  289. package/dist/metacognition/calibration-selective.js +161 -0
  290. package/dist/metacognition/calibration-selective.js.map +1 -0
  291. package/dist/metacognition/calibration.d.ts +62 -0
  292. package/dist/metacognition/calibration.d.ts.map +1 -0
  293. package/dist/metacognition/calibration.js +122 -0
  294. package/dist/metacognition/calibration.js.map +1 -0
  295. package/dist/metacognition/checkpoint.d.ts +60 -0
  296. package/dist/metacognition/checkpoint.d.ts.map +1 -0
  297. package/dist/metacognition/checkpoint.js +57 -0
  298. package/dist/metacognition/checkpoint.js.map +1 -0
  299. package/dist/metacognition/context7.d.ts +48 -0
  300. package/dist/metacognition/context7.d.ts.map +1 -0
  301. package/dist/metacognition/context7.js +154 -0
  302. package/dist/metacognition/context7.js.map +1 -0
  303. package/dist/metacognition/decision.d.ts +44 -0
  304. package/dist/metacognition/decision.d.ts.map +1 -0
  305. package/dist/metacognition/decision.js +111 -0
  306. package/dist/metacognition/decision.js.map +1 -0
  307. package/dist/metacognition/evaluation.d.ts +73 -0
  308. package/dist/metacognition/evaluation.d.ts.map +1 -0
  309. package/dist/metacognition/evaluation.js +97 -0
  310. package/dist/metacognition/evaluation.js.map +1 -0
  311. package/dist/metacognition/index.d.ts +31 -0
  312. package/dist/metacognition/index.d.ts.map +1 -0
  313. package/dist/metacognition/index.js +31 -0
  314. package/dist/metacognition/index.js.map +1 -0
  315. package/dist/metacognition/knowledge-action.d.ts +43 -0
  316. package/dist/metacognition/knowledge-action.d.ts.map +1 -0
  317. package/dist/metacognition/knowledge-action.js +60 -0
  318. package/dist/metacognition/knowledge-action.js.map +1 -0
  319. package/dist/metacognition/knowledge.d.ts +84 -0
  320. package/dist/metacognition/knowledge.d.ts.map +1 -0
  321. package/dist/metacognition/knowledge.js +165 -0
  322. package/dist/metacognition/knowledge.js.map +1 -0
  323. package/dist/metacognition/obligations.d.ts +82 -0
  324. package/dist/metacognition/obligations.d.ts.map +1 -0
  325. package/dist/metacognition/obligations.js +139 -0
  326. package/dist/metacognition/obligations.js.map +1 -0
  327. package/dist/metacognition/observation-validity.d.ts +83 -0
  328. package/dist/metacognition/observation-validity.d.ts.map +1 -0
  329. package/dist/metacognition/observation-validity.js +118 -0
  330. package/dist/metacognition/observation-validity.js.map +1 -0
  331. package/dist/metacognition/observe.d.ts +45 -0
  332. package/dist/metacognition/observe.d.ts.map +1 -0
  333. package/dist/metacognition/observe.js +59 -0
  334. package/dist/metacognition/observe.js.map +1 -0
  335. package/dist/metacognition/policy.d.ts +53 -0
  336. package/dist/metacognition/policy.d.ts.map +1 -0
  337. package/dist/metacognition/policy.js +155 -0
  338. package/dist/metacognition/policy.js.map +1 -0
  339. package/dist/metacognition/predictions.d.ts +78 -0
  340. package/dist/metacognition/predictions.d.ts.map +1 -0
  341. package/dist/metacognition/predictions.js +181 -0
  342. package/dist/metacognition/predictions.js.map +1 -0
  343. package/dist/metacognition/retrieval.d.ts +53 -0
  344. package/dist/metacognition/retrieval.d.ts.map +1 -0
  345. package/dist/metacognition/retrieval.js +170 -0
  346. package/dist/metacognition/retrieval.js.map +1 -0
  347. package/dist/metacognition/risk.d.ts +48 -0
  348. package/dist/metacognition/risk.d.ts.map +1 -0
  349. package/dist/metacognition/risk.js +165 -0
  350. package/dist/metacognition/risk.js.map +1 -0
  351. package/dist/metacognition/route-economics.d.ts +95 -0
  352. package/dist/metacognition/route-economics.d.ts.map +1 -0
  353. package/dist/metacognition/route-economics.js +110 -0
  354. package/dist/metacognition/route-economics.js.map +1 -0
  355. package/dist/metacognition/runtime-bridge.d.ts +54 -0
  356. package/dist/metacognition/runtime-bridge.d.ts.map +1 -0
  357. package/dist/metacognition/runtime-bridge.js +140 -0
  358. package/dist/metacognition/runtime-bridge.js.map +1 -0
  359. package/dist/metacognition/skills.d.ts +42 -0
  360. package/dist/metacognition/skills.d.ts.map +1 -0
  361. package/dist/metacognition/skills.js +220 -0
  362. package/dist/metacognition/skills.js.map +1 -0
  363. package/dist/metacognition/state.d.ts +110 -0
  364. package/dist/metacognition/state.d.ts.map +1 -0
  365. package/dist/metacognition/state.js +52 -0
  366. package/dist/metacognition/state.js.map +1 -0
  367. package/dist/metacognition/validation.d.ts +19 -0
  368. package/dist/metacognition/validation.d.ts.map +1 -0
  369. package/dist/metacognition/validation.js +58 -0
  370. package/dist/metacognition/validation.js.map +1 -0
  371. package/dist/metacognition/verification.d.ts +93 -0
  372. package/dist/metacognition/verification.d.ts.map +1 -0
  373. package/dist/metacognition/verification.js +132 -0
  374. package/dist/metacognition/verification.js.map +1 -0
  375. package/dist/metacognition/verifier.d.ts +49 -0
  376. package/dist/metacognition/verifier.d.ts.map +1 -0
  377. package/dist/metacognition/verifier.js +88 -0
  378. package/dist/metacognition/verifier.js.map +1 -0
  379. package/dist/modes/acp/acp-agent.d.ts +24 -0
  380. package/dist/modes/acp/acp-agent.d.ts.map +1 -0
  381. package/dist/modes/acp/acp-agent.js +133 -0
  382. package/dist/modes/acp/acp-agent.js.map +1 -0
  383. package/dist/modes/acp/acp-mode.d.ts +4 -0
  384. package/dist/modes/acp/acp-mode.d.ts.map +1 -0
  385. package/dist/modes/acp/acp-mode.js +34 -0
  386. package/dist/modes/acp/acp-mode.js.map +1 -0
  387. package/dist/modes/acp/acp-session.d.ts +4 -0
  388. package/dist/modes/acp/acp-session.d.ts.map +1 -0
  389. package/dist/modes/acp/acp-session.js +76 -0
  390. package/dist/modes/acp/acp-session.js.map +1 -0
  391. package/dist/modes/acp/acp-transport.d.ts +5 -0
  392. package/dist/modes/acp/acp-transport.d.ts.map +1 -0
  393. package/dist/modes/acp/acp-transport.js +90 -0
  394. package/dist/modes/acp/acp-transport.js.map +1 -0
  395. package/dist/modes/interactive/interactive-mode.d.ts.map +1 -1
  396. package/dist/modes/interactive/interactive-mode.js +1 -0
  397. package/dist/modes/interactive/interactive-mode.js.map +1 -1
  398. package/dist/observation/identity.d.ts +14 -0
  399. package/dist/observation/identity.d.ts.map +1 -0
  400. package/dist/observation/identity.js +29 -0
  401. package/dist/observation/identity.js.map +1 -0
  402. package/dist/observation/index.d.ts +13 -0
  403. package/dist/observation/index.d.ts.map +1 -0
  404. package/dist/observation/index.js +13 -0
  405. package/dist/observation/index.js.map +1 -0
  406. package/dist/observation/observe-mode.d.ts +46 -0
  407. package/dist/observation/observe-mode.d.ts.map +1 -0
  408. package/dist/observation/observe-mode.js +83 -0
  409. package/dist/observation/observe-mode.js.map +1 -0
  410. package/dist/observation/store.d.ts +53 -0
  411. package/dist/observation/store.d.ts.map +1 -0
  412. package/dist/observation/store.js +126 -0
  413. package/dist/observation/store.js.map +1 -0
  414. package/dist/observation/types.d.ts +72 -0
  415. package/dist/observation/types.d.ts.map +1 -0
  416. package/dist/observation/types.js +9 -0
  417. package/dist/observation/types.js.map +1 -0
  418. package/dist/observation/view.d.ts +39 -0
  419. package/dist/observation/view.d.ts.map +1 -0
  420. package/dist/observation/view.js +173 -0
  421. package/dist/observation/view.js.map +1 -0
  422. package/docs/audit-revalidation-2026-09-17.md +77 -0
  423. package/docs/devin-harness.md +33 -4
  424. package/docs/ecraf-normalization.md +83 -0
  425. package/docs/metacognition.md +51 -0
  426. package/docs/model-catalog-refresh.md +110 -1
  427. package/docs/models.md +1 -1
  428. package/docs/neo.md +134 -0
  429. package/docs/providers.md +125 -6
  430. package/docs/run-usage-ledger.md +56 -0
  431. package/docs/runtime-algorithms.md +151 -3
  432. package/docs/skills.md +1 -1
  433. package/docs/usage.md +2 -1
  434. package/examples/extensions/custom-provider-anthropic/package-lock.json +2 -2
  435. package/examples/extensions/custom-provider-anthropic/package.json +1 -1
  436. package/examples/extensions/custom-provider-gitlab-duo/package.json +1 -1
  437. package/examples/extensions/gondolin/package-lock.json +2 -2
  438. package/examples/extensions/gondolin/package.json +1 -1
  439. package/examples/extensions/sandbox/package-lock.json +2 -2
  440. package/examples/extensions/sandbox/package.json +1 -1
  441. package/examples/extensions/subagent/adaptive-agent-runtime.ts +14 -1
  442. package/examples/extensions/subagent/graph-result.ts +48 -0
  443. package/examples/extensions/subagent/index.ts +246 -111
  444. package/examples/extensions/subagent/managed-process-tree.ts +42 -0
  445. package/examples/extensions/subagent/managed-process.test.ts +24 -0
  446. package/examples/extensions/subagent/managed-process.ts +93 -112
  447. package/examples/extensions/subagent/subagent-runtime-types.ts +17 -1
  448. package/examples/extensions/subagent/subagent-stream.ts +161 -0
  449. package/examples/extensions/terminal-browser/README.md +54 -0
  450. package/examples/extensions/terminal-browser/bridge-protocol.ts +29 -0
  451. package/examples/extensions/terminal-browser/bridge.ts +219 -0
  452. package/examples/extensions/terminal-browser/browser-surface.ts +288 -0
  453. package/examples/extensions/terminal-browser/index.ts +215 -0
  454. package/examples/extensions/terminal-browser/placeholders.ts +49 -0
  455. package/examples/extensions/with-deps/package-lock.json +2 -2
  456. package/examples/extensions/with-deps/package.json +1 -1
  457. package/npm-shrinkwrap.json +18 -18
  458. package/package.json +8 -7
  459. package/resources/neo/skills/omk-browser/SKILL.md +32 -0
  460. package/resources/neo/skills/omk-code-review/SKILL.md +24 -0
  461. package/resources/neo/skills/omk-computeruse/SKILL.md +34 -0
  462. package/resources/neo/skills/omk-mcp-setup/SKILL.md +48 -0
  463. package/resources/neo/skills/omk-research/SKILL.md +24 -0
  464. package/resources/neo/skills/omk-site/SKILL.md +28 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"resource.js","sourceRoot":"","sources":["../../src/coordination/resource.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAGH,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAEtC,MAAM,gBAAgB,GAAwB,IAAI,GAAG,CAAiB;IACrE,YAAY;IACZ,SAAS;IACT,UAAU;IACV,QAAQ;IACR,UAAU;IACV,aAAa;CACb,CAAC,CAAC;AACH,MAAM,YAAY,GAAwB,IAAI,GAAG,CAAc,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;AAClF,MAAM,cAAc,GAAG,IAAI,CAAC;AAU5B;;;;;;GAMG;AACH,MAAM,UAAU,cAAc,CAAC,KAAyB,EAAiB;IACxE,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,SAAS,CAAC,gCAAgC,MAAM,CAAC,KAAK,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,K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K,CAAC;IACxC,MAAM,UAAU,GAAG,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE,CAAC;QACpD,IAAI,CAAC,GAAG,CAAC;YAAE,OAAO,CAAC,CAAC,CAAC;QACrB,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAAA,CACrB,CAAC;IACF,MAAM,IAAI,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC9C,MAAM,KAAK,GAAG,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;IAC/C,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAAA,CAC5D","sourcesContent":["/**\n * Resource claim identity and conflict algebra.\n *\n * Two claims conflict when they name overlapping resources and at least one\n * side writes. Overlap is prefix containment on path components, so `src`\n * covers `src/a/x` but never `src/ab` — a shared character prefix that straddles\n * a component boundary is a different resource, not a nested one.\n */\n\nimport type { ClaimAccess, ClaimNamespace, ResourceClaim } from \"./types.ts\";\nimport { sequence } from \"./types.ts\";\n\nconst CLAIM_NAMESPACES: ReadonlySet<string> = new Set<ClaimNamespace>([\n\t\"filesystem\",\n\t\"git-ref\",\n\t\"contract\",\n\t\"socket\",\n\t\"database\",\n\t\"host-budget\",\n]);\nconst CLAIM_ACCESS: ReadonlySet<string> = new Set<ClaimAccess>([\"read\", \"write\"]);\nconst MAX_KEY_LENGTH = 4096;\n\nexport interface ResourceClaimInput {\n\treadonly namespace: string;\n\treadonly instanceId: string;\n\treadonly canonicalKey: string;\n\treadonly access: string;\n\treadonly generation: string;\n}\n\n/**\n * Validate and freeze one claim.\n *\n * A non-canonical key is rejected rather than normalized: normalizing\n * `a/../b` here would let one session hold `a/../b` and another hold `b`\n * while both believe their scopes are disjoint.\n */\nexport function canonicalClaim(input: ResourceClaimInput): ResourceClaim {\n\tif (!CLAIM_NAMESPACES.has(input.namespace)) {\n\t\tthrow new TypeError(`unsupported claim namespace: ${String(input.namespace)}`);\n\t}\n\tif (!CLAIM_ACCESS.has(input.access)) {\n\t\tthrow new TypeError(`unsupported claim access: ${String(input.access)}`);\n\t}\n\tif (typeof input.instanceId !== \"string\" || input.instanceId.length === 0) {\n\t\tthrow new TypeError(\"claim instanceId must be a non-empty string\");\n\t}\n\tassertCanonicalKey(input.canonicalKey);\n\treturn Object.freeze({\n\t\tnamespace: input.namespace as ClaimNamespace,\n\t\tinstanceId: input.instanceId,\n\t\tcanonicalKey: input.canonicalKey,\n\t\taccess: input.access as ClaimAccess,\n\t\tgeneration: sequence(input.generation),\n\t});\n}\n\nfunction assertCanonicalKey(key: unknown): asserts key is string {\n\tif (typeof key !== \"string\" || key.length === 0 || key.length > MAX_KEY_LENGTH) {\n\t\tthrow new TypeError(\"claim canonicalKey must be a bounded non-empty string\");\n\t}\n\tif (key.startsWith(\"/\")) throw new TypeError(\"claim canonicalKey must be relative\");\n\tfor (const part of key.split(\"/\")) {\n\t\tif (part === \"\" || part === \".\" || part === \"..\") {\n\t\t\tthrow new TypeError(`claim canonicalKey is not canonical: ${key}`);\n\t\t}\n\t}\n}\n\n/** Same resource identity, or one key nested under the other. Ignores access. */\nexport function resourcesOverlap(a: ResourceClaim, b: ResourceClaim): boolean {\n\tif (a.namespace !== b.namespace || a.instanceId !== b.instanceId) return false;\n\tif (a.canonicalKey === b.canonicalKey) return true;\n\treturn a.canonicalKey.startsWith(`${b.canonicalKey}/`) || b.canonicalKey.startsWith(`${a.canonicalKey}/`);\n}\n\nexport function claimsConflict(a: ResourceClaim, b: ResourceClaim): boolean {\n\treturn resourcesOverlap(a, b) && (a.access === \"write\" || b.access === \"write\");\n}\n\nexport function claimSetsConflict(a: readonly ResourceClaim[], b: readonly ResourceClaim[]): boolean {\n\treturn a.some((x) => b.some((y) => claimsConflict(x, y)));\n}\n\n/** Stable key for exact-set comparison when binding a start to its reservation. */\nexport function claimKey(claim: ResourceClaim): string {\n\treturn `${claim.namespace}\\u0000${claim.instanceId}\\u0000${claim.canonicalKey}\\u0000${claim.access}`;\n}\n\n/** Exact set equality by identity+access; a post-hook that widened scope fails this. */\nexport function sameClaimSet(a: readonly ResourceClaim[], b: readonly ResourceClaim[]): boolean {\n\tif (a.length !== b.length) return false;\n\tconst byCodeUnit = (x: string, y: string): number => {\n\t\tif (x < y) return -1;\n\t\treturn x > y ? 1 : 0;\n\t};\n\tconst left = a.map(claimKey).sort(byCodeUnit);\n\tconst right = b.map(claimKey).sort(byCodeUnit);\n\treturn left.every((value, index) => value === right[index]);\n}\n"]}
@@ -0,0 +1,74 @@
1
+ /**
2
+ * Generation-tagged browser session lifecycle (Jev audit F03, algorithm A6 §12.5).
3
+ *
4
+ * idle → initializing(g) → ready(g) → draining(g) → closed(g)
5
+ * ↘ init failure → idle
6
+ * ready | draining → close failure → close-failed(g)
7
+ *
8
+ * Two reproduced defects motivate every rule here:
9
+ * R09 — shutdown read an empty session slot while init was in flight, then
10
+ * the init completed and assigned it, resurrecting a closed session.
11
+ * R10 — close cleared the handle before the driver call resolved, so a close
12
+ * that threw left no handle and the next call claimed success.
13
+ *
14
+ * The invariant is that a handle is never dropped on the floor: a late init
15
+ * from a superseded generation is moved to `discardedHandles` for the caller
16
+ * to clean up, and a failed close keeps its handle in `close-failed`.
17
+ */
18
+ import type { Sequence } from "./types.ts";
19
+ export type SessionState = "idle" | "initializing" | "ready" | "draining" | "closed" | "close-failed";
20
+ export declare class SessionLifecycle<THandle = unknown> {
21
+ private currentState;
22
+ private generation;
23
+ private currentHandle;
24
+ private failure;
25
+ private shutdownRequested;
26
+ private readonly discarded;
27
+ get state(): SessionState;
28
+ get currentGeneration(): Sequence;
29
+ get handle(): THandle | undefined;
30
+ /** Handles from superseded or unknown generations; the caller must close them. */
31
+ get discardedHandles(): readonly THandle[];
32
+ get closeFailure(): Error | undefined;
33
+ /** Only a completed close counts. A close failure is not closed. */
34
+ get isClosed(): boolean;
35
+ /**
36
+ * Open a new generation.
37
+ *
38
+ * Refused while a close failure is unresolved: launching a second browser
39
+ * on top of one that may still be running is how orphan processes and
40
+ * duplicate effects start.
41
+ */
42
+ beginInit(): Sequence;
43
+ /**
44
+ * Adopt an initialized handle.
45
+ *
46
+ * Returns false when this generation is no longer the one being awaited —
47
+ * the handle is retained for cleanup rather than installed, because the
48
+ * session it belonged to is already gone.
49
+ */
50
+ completeInit(generation: Sequence, handle: THandle): boolean;
51
+ failInit(generation: Sequence, error: Error): boolean;
52
+ /**
53
+ * Ask the session to stop.
54
+ *
55
+ * With no handle yet there is nothing to drain, so this closes immediately
56
+ * and any in-flight init will be discarded on arrival. With a live handle
57
+ * the session must drain: the caller still has to close the driver.
58
+ */
59
+ requestShutdown(): void;
60
+ beginClose(): void;
61
+ /** The driver confirmed the session is gone; only now is the handle released. */
62
+ completeClose(): void;
63
+ /** The close attempt threw. Keep the handle so a retry can still reach it. */
64
+ failClose(error: Error): void;
65
+ /**
66
+ * Fencing gate: accept a command only from the current generation of a
67
+ * ready session. A generation number in a log proves nothing; the gate that
68
+ * hands commands to the driver has to be the one refusing stale ones.
69
+ */
70
+ accepts(generation: Sequence): boolean;
71
+ /** True once a shutdown was asked for, regardless of how far draining got. */
72
+ get shutdownPending(): boolean;
73
+ }
74
+ //# sourceMappingURL=session.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.d.ts","sourceRoot":"","sources":["../../src/coordination/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAG3C,MAAM,MAAM,YAAY,GAAG,MAAM,GAAG,cAAc,GAAG,OAAO,GAAG,UAAU,GAAG,QAAQ,GAAG,cAAc,CAAC;AAEtG,qBAAa,gBAAgB,CAAC,OAAO,GAAG,OAAO;IAC9C,OAAO,CAAC,YAAY,CAAwB;IAC5C,OAAO,CAAC,UAAU,CAA2B;IAC7C,OAAO,CAAC,aAAa,CAAsB;IAC3C,OAAO,CAAC,OAAO,CAAoB;IACnC,OAAO,CAAC,iBAAiB,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAiB;IAE3C,IAAI,KAAK,IAAI,YAAY,CAExB;IAED,IAAI,iBAAiB,IAAI,QAAQ,CAEhC;IAED,IAAI,MAAM,IAAI,OAAO,GAAG,SAAS,CAEhC;IAED,kFAAkF;IAClF,IAAI,gBAAgB,IAAI,SAAS,OAAO,EAAE,CAEzC;IAED,IAAI,YAAY,IAAI,KAAK,GAAG,SAAS,CAEpC;IAED,oEAAoE;IACpE,IAAI,QAAQ,IAAI,OAAO,CAEtB;IAED;;;;;;OAMG;IACH,SAAS,IAAI,QAAQ,CAWpB;IAED;;;;;;OAMG;IACH,YAAY,CAAC,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAG,OAAO,CAQ3D;IAED,QAAQ,CAAC,UAAU,EAAE,QAAQ,EAAE,KAAK,EAAE,KAAK,GAAG,OAAO,CAOpD;IAED;;;;;;OAMG;IACH,eAAe,IAAI,IAAI,CAOtB;IAED,UAAU,IAAI,IAAI,CAMjB;IAED,iFAAiF;IACjF,aAAa,IAAI,IAAI,CAOpB;IAED,8EAA8E;IAC9E,SAAS,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAM5B;IAED;;;;OAIG;IACH,OAAO,CAAC,UAAU,EAAE,QAAQ,GAAG,OAAO,CAErC;IAED,8EAA8E;IAC9E,IAAI,eAAe,IAAI,OAAO,CAE7B;CACD","sourcesContent":["/**\n * Generation-tagged browser session lifecycle (Jev audit F03, algorithm A6 §12.5).\n *\n * idle → initializing(g) → ready(g) → draining(g) → closed(g)\n * ↘ init failure → idle\n * ready | draining → close failure → close-failed(g)\n *\n * Two reproduced defects motivate every rule here:\n * R09 — shutdown read an empty session slot while init was in flight, then\n * the init completed and assigned it, resurrecting a closed session.\n * R10 — close cleared the handle before the driver call resolved, so a close\n * that threw left no handle and the next call claimed success.\n *\n * The invariant is that a handle is never dropped on the floor: a late init\n * from a superseded generation is moved to `discardedHandles` for the caller\n * to clean up, and a failed close keeps its handle in `close-failed`.\n */\n\nimport type { Sequence } from \"./types.ts\";\nimport { nextSequence, sequence } from \"./types.ts\";\n\nexport type SessionState = \"idle\" | \"initializing\" | \"ready\" | \"draining\" | \"closed\" | \"close-failed\";\n\nexport class SessionLifecycle<THandle = unknown> {\n\tprivate currentState: SessionState = \"idle\";\n\tprivate generation: Sequence = sequence(\"0\");\n\tprivate currentHandle: THandle | undefined;\n\tprivate failure: Error | undefined;\n\tprivate shutdownRequested = false;\n\tprivate readonly discarded: THandle[] = [];\n\n\tget state(): SessionState {\n\t\treturn this.currentState;\n\t}\n\n\tget currentGeneration(): Sequence {\n\t\treturn this.generation;\n\t}\n\n\tget handle(): THandle | undefined {\n\t\treturn this.currentHandle;\n\t}\n\n\t/** Handles from superseded or unknown generations; the caller must close them. */\n\tget discardedHandles(): readonly THandle[] {\n\t\treturn [...this.discarded];\n\t}\n\n\tget closeFailure(): Error | undefined {\n\t\treturn this.failure;\n\t}\n\n\t/** Only a completed close counts. A close failure is not closed. */\n\tget isClosed(): boolean {\n\t\treturn this.currentState === \"closed\";\n\t}\n\n\t/**\n\t * Open a new generation.\n\t *\n\t * Refused while a close failure is unresolved: launching a second browser\n\t * on top of one that may still be running is how orphan processes and\n\t * duplicate effects start.\n\t */\n\tbeginInit(): Sequence {\n\t\tif (this.currentState === \"close-failed\") {\n\t\t\tthrow new Error(\"cannot initialize while a close-failed session is unresolved\");\n\t\t}\n\t\tif (this.currentState === \"initializing\" || this.currentState === \"ready\" || this.currentState === \"draining\") {\n\t\t\tthrow new Error(`cannot initialize from state ${this.currentState}`);\n\t\t}\n\t\tthis.generation = nextSequence(this.generation);\n\t\tthis.shutdownRequested = false;\n\t\tthis.currentState = \"initializing\";\n\t\treturn this.generation;\n\t}\n\n\t/**\n\t * Adopt an initialized handle.\n\t *\n\t * Returns false when this generation is no longer the one being awaited —\n\t * the handle is retained for cleanup rather than installed, because the\n\t * session it belonged to is already gone.\n\t */\n\tcompleteInit(generation: Sequence, handle: THandle): boolean {\n\t\tif (generation !== this.generation || this.currentState !== \"initializing\") {\n\t\t\tthis.discarded.push(handle);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentHandle = handle;\n\t\tthis.currentState = \"ready\";\n\t\treturn true;\n\t}\n\n\tfailInit(generation: Sequence, error: Error): boolean {\n\t\tif (generation !== this.generation || this.currentState !== \"initializing\") return false;\n\t\tthis.failure = undefined;\n\t\tthis.currentHandle = undefined;\n\t\tthis.currentState = \"idle\";\n\t\tvoid error;\n\t\treturn true;\n\t}\n\n\t/**\n\t * Ask the session to stop.\n\t *\n\t * With no handle yet there is nothing to drain, so this closes immediately\n\t * and any in-flight init will be discarded on arrival. With a live handle\n\t * the session must drain: the caller still has to close the driver.\n\t */\n\trequestShutdown(): void {\n\t\tthis.shutdownRequested = true;\n\t\tif (this.currentState === \"initializing\" || this.currentState === \"idle\") {\n\t\t\tthis.currentState = \"closed\";\n\t\t\treturn;\n\t\t}\n\t\tif (this.currentState === \"ready\") this.currentState = \"draining\";\n\t}\n\n\tbeginClose(): void {\n\t\tif (this.currentState !== \"ready\" && this.currentState !== \"close-failed\") {\n\t\t\tthrow new Error(`cannot close from state ${this.currentState}`);\n\t\t}\n\t\tthis.failure = undefined;\n\t\tthis.currentState = \"draining\";\n\t}\n\n\t/** The driver confirmed the session is gone; only now is the handle released. */\n\tcompleteClose(): void {\n\t\tif (this.currentState !== \"draining\") {\n\t\t\tthrow new Error(`cannot complete close from state ${this.currentState}`);\n\t\t}\n\t\tthis.currentHandle = undefined;\n\t\tthis.failure = undefined;\n\t\tthis.currentState = \"closed\";\n\t}\n\n\t/** The close attempt threw. Keep the handle so a retry can still reach it. */\n\tfailClose(error: Error): void {\n\t\tif (this.currentState !== \"draining\") {\n\t\t\tthrow new Error(`cannot fail close from state ${this.currentState}`);\n\t\t}\n\t\tthis.failure = error;\n\t\tthis.currentState = \"close-failed\";\n\t}\n\n\t/**\n\t * Fencing gate: accept a command only from the current generation of a\n\t * ready session. A generation number in a log proves nothing; the gate that\n\t * hands commands to the driver has to be the one refusing stale ones.\n\t */\n\taccepts(generation: Sequence): boolean {\n\t\treturn this.currentState === \"ready\" && generation === this.generation;\n\t}\n\n\t/** True once a shutdown was asked for, regardless of how far draining got. */\n\tget shutdownPending(): boolean {\n\t\treturn this.shutdownRequested;\n\t}\n}\n"]}
@@ -0,0 +1,143 @@
1
+ /**
2
+ * Generation-tagged browser session lifecycle (Jev audit F03, algorithm A6 §12.5).
3
+ *
4
+ * idle → initializing(g) → ready(g) → draining(g) → closed(g)
5
+ * ↘ init failure → idle
6
+ * ready | draining → close failure → close-failed(g)
7
+ *
8
+ * Two reproduced defects motivate every rule here:
9
+ * R09 — shutdown read an empty session slot while init was in flight, then
10
+ * the init completed and assigned it, resurrecting a closed session.
11
+ * R10 — close cleared the handle before the driver call resolved, so a close
12
+ * that threw left no handle and the next call claimed success.
13
+ *
14
+ * The invariant is that a handle is never dropped on the floor: a late init
15
+ * from a superseded generation is moved to `discardedHandles` for the caller
16
+ * to clean up, and a failed close keeps its handle in `close-failed`.
17
+ */
18
+ import { nextSequence, sequence } from "./types.js";
19
+ export class SessionLifecycle {
20
+ currentState = "idle";
21
+ generation = sequence("0");
22
+ currentHandle;
23
+ failure;
24
+ shutdownRequested = false;
25
+ discarded = [];
26
+ get state() {
27
+ return this.currentState;
28
+ }
29
+ get currentGeneration() {
30
+ return this.generation;
31
+ }
32
+ get handle() {
33
+ return this.currentHandle;
34
+ }
35
+ /** Handles from superseded or unknown generations; the caller must close them. */
36
+ get discardedHandles() {
37
+ return [...this.discarded];
38
+ }
39
+ get closeFailure() {
40
+ return this.failure;
41
+ }
42
+ /** Only a completed close counts. A close failure is not closed. */
43
+ get isClosed() {
44
+ return this.currentState === "closed";
45
+ }
46
+ /**
47
+ * Open a new generation.
48
+ *
49
+ * Refused while a close failure is unresolved: launching a second browser
50
+ * on top of one that may still be running is how orphan processes and
51
+ * duplicate effects start.
52
+ */
53
+ beginInit() {
54
+ if (this.currentState === "close-failed") {
55
+ throw new Error("cannot initialize while a close-failed session is unresolved");
56
+ }
57
+ if (this.currentState === "initializing" || this.currentState === "ready" || this.currentState === "draining") {
58
+ throw new Error(`cannot initialize from state ${this.currentState}`);
59
+ }
60
+ this.generation = nextSequence(this.generation);
61
+ this.shutdownRequested = false;
62
+ this.currentState = "initializing";
63
+ return this.generation;
64
+ }
65
+ /**
66
+ * Adopt an initialized handle.
67
+ *
68
+ * Returns false when this generation is no longer the one being awaited —
69
+ * the handle is retained for cleanup rather than installed, because the
70
+ * session it belonged to is already gone.
71
+ */
72
+ completeInit(generation, handle) {
73
+ if (generation !== this.generation || this.currentState !== "initializing") {
74
+ this.discarded.push(handle);
75
+ return false;
76
+ }
77
+ this.currentHandle = handle;
78
+ this.currentState = "ready";
79
+ return true;
80
+ }
81
+ failInit(generation, error) {
82
+ if (generation !== this.generation || this.currentState !== "initializing")
83
+ return false;
84
+ this.failure = undefined;
85
+ this.currentHandle = undefined;
86
+ this.currentState = "idle";
87
+ void error;
88
+ return true;
89
+ }
90
+ /**
91
+ * Ask the session to stop.
92
+ *
93
+ * With no handle yet there is nothing to drain, so this closes immediately
94
+ * and any in-flight init will be discarded on arrival. With a live handle
95
+ * the session must drain: the caller still has to close the driver.
96
+ */
97
+ requestShutdown() {
98
+ this.shutdownRequested = true;
99
+ if (this.currentState === "initializing" || this.currentState === "idle") {
100
+ this.currentState = "closed";
101
+ return;
102
+ }
103
+ if (this.currentState === "ready")
104
+ this.currentState = "draining";
105
+ }
106
+ beginClose() {
107
+ if (this.currentState !== "ready" && this.currentState !== "close-failed") {
108
+ throw new Error(`cannot close from state ${this.currentState}`);
109
+ }
110
+ this.failure = undefined;
111
+ this.currentState = "draining";
112
+ }
113
+ /** The driver confirmed the session is gone; only now is the handle released. */
114
+ completeClose() {
115
+ if (this.currentState !== "draining") {
116
+ throw new Error(`cannot complete close from state ${this.currentState}`);
117
+ }
118
+ this.currentHandle = undefined;
119
+ this.failure = undefined;
120
+ this.currentState = "closed";
121
+ }
122
+ /** The close attempt threw. Keep the handle so a retry can still reach it. */
123
+ failClose(error) {
124
+ if (this.currentState !== "draining") {
125
+ throw new Error(`cannot fail close from state ${this.currentState}`);
126
+ }
127
+ this.failure = error;
128
+ this.currentState = "close-failed";
129
+ }
130
+ /**
131
+ * Fencing gate: accept a command only from the current generation of a
132
+ * ready session. A generation number in a log proves nothing; the gate that
133
+ * hands commands to the driver has to be the one refusing stale ones.
134
+ */
135
+ accepts(generation) {
136
+ return this.currentState === "ready" && generation === this.generation;
137
+ }
138
+ /** True once a shutdown was asked for, regardless of how far draining got. */
139
+ get shutdownPending() {
140
+ return this.shutdownRequested;
141
+ }
142
+ }
143
+ //# sourceMappingURL=session.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session.js","sourceRoot":"","sources":["../../src/coordination/session.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAIpD,MAAM,OAAO,gBAAgB;IACpB,YAAY,GAAiB,MAAM,CAAC;IACpC,UAAU,GAAa,QAAQ,CAAC,GAAG,CAAC,CAAC;IACrC,aAAa,CAAsB;IACnC,OAAO,CAAoB;IAC3B,iBAAiB,GAAG,KAAK,CAAC;IACjB,SAAS,GAAc,EAAE,CAAC;IAE3C,IAAI,KAAK,GAAiB;QACzB,OAAO,IAAI,CAAC,YAAY,CAAC;IAAA,CACzB;IAED,IAAI,iBAAiB,GAAa;QACjC,OAAO,IAAI,CAAC,UAAU,CAAC;IAAA,CACvB;IAED,IAAI,MAAM,GAAwB;QACjC,OAAO,IAAI,CAAC,aAAa,CAAC;IAAA,CAC1B;IAED,kFAAk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CAAC;IAAA,CAC7B;IAED,8EAA8E;IAC9E,SAAS,CAAC,KAAY,EAAQ;QAC7B,IAAI,IAAI,CAAC,YAAY,KAAK,UAAU,EAAE,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC;QACtE,CAAC;QACD,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACrB,IAAI,CAAC,YAAY,GAAG,cAAc,CAAC;IAAA,CACnC;IAED;;;;OAIG;IACH,OAAO,CAAC,UAAoB,EAAW;QACtC,OAAO,IAAI,CAAC,YAAY,KAAK,OAAO,IAAI,UAAU,KAAK,IAAI,CAAC,UAAU,CAAC;IAAA,CACvE;IAED,8EAA8E;IAC9E,IAAI,eAAe,GAAY;QAC9B,OAAO,IAAI,CAAC,iBAAiB,CAAC;IAAA,CAC9B;CACD","sourcesContent":["/**\n * Generation-tagged browser session lifecycle (Jev audit F03, algorithm A6 §12.5).\n *\n * idle → initializing(g) → ready(g) → draining(g) → closed(g)\n * ↘ init failure → idle\n * ready | draining → close failure → close-failed(g)\n *\n * Two reproduced defects motivate every rule here:\n * R09 — shutdown read an empty session slot while init was in flight, then\n * the init completed and assigned it, resurrecting a closed session.\n * R10 — close cleared the handle before the driver call resolved, so a close\n * that threw left no handle and the next call claimed success.\n *\n * The invariant is that a handle is never dropped on the floor: a late init\n * from a superseded generation is moved to `discardedHandles` for the caller\n * to clean up, and a failed close keeps its handle in `close-failed`.\n */\n\nimport type { Sequence } from \"./types.ts\";\nimport { nextSequence, sequence } from \"./types.ts\";\n\nexport type SessionState = \"idle\" | \"initializing\" | \"ready\" | \"draining\" | \"closed\" | \"close-failed\";\n\nexport class SessionLifecycle<THandle = unknown> {\n\tprivate currentState: SessionState = \"idle\";\n\tprivate generation: Sequence = sequence(\"0\");\n\tprivate currentHandle: THandle | undefined;\n\tprivate failure: Error | undefined;\n\tprivate shutdownRequested = false;\n\tprivate readonly discarded: THandle[] = [];\n\n\tget state(): SessionState {\n\t\treturn this.currentState;\n\t}\n\n\tget currentGeneration(): Sequence {\n\t\treturn this.generation;\n\t}\n\n\tget handle(): THandle | undefined {\n\t\treturn this.currentHandle;\n\t}\n\n\t/** Handles from superseded or unknown generations; the caller must close them. */\n\tget discardedHandles(): readonly THandle[] {\n\t\treturn [...this.discarded];\n\t}\n\n\tget closeFailure(): Error | undefined {\n\t\treturn this.failure;\n\t}\n\n\t/** Only a completed close counts. A close failure is not closed. */\n\tget isClosed(): boolean {\n\t\treturn this.currentState === \"closed\";\n\t}\n\n\t/**\n\t * Open a new generation.\n\t *\n\t * Refused while a close failure is unresolved: launching a second browser\n\t * on top of one that may still be running is how orphan processes and\n\t * duplicate effects start.\n\t */\n\tbeginInit(): Sequence {\n\t\tif (this.currentState === \"close-failed\") {\n\t\t\tthrow new Error(\"cannot initialize while a close-failed session is unresolved\");\n\t\t}\n\t\tif (this.currentState === \"initializing\" || this.currentState === \"ready\" || this.currentState === \"draining\") {\n\t\t\tthrow new Error(`cannot initialize from state ${this.currentState}`);\n\t\t}\n\t\tthis.generation = nextSequence(this.generation);\n\t\tthis.shutdownRequested = false;\n\t\tthis.currentState = \"initializing\";\n\t\treturn this.generation;\n\t}\n\n\t/**\n\t * Adopt an initialized handle.\n\t *\n\t * Returns false when this generation is no longer the one being awaited —\n\t * the handle is retained for cleanup rather than installed, because the\n\t * session it belonged to is already gone.\n\t */\n\tcompleteInit(generation: Sequence, handle: THandle): boolean {\n\t\tif (generation !== this.generation || this.currentState !== \"initializing\") {\n\t\t\tthis.discarded.push(handle);\n\t\t\treturn false;\n\t\t}\n\t\tthis.currentHandle = handle;\n\t\tthis.currentState = \"ready\";\n\t\treturn true;\n\t}\n\n\tfailInit(generation: Sequence, error: Error): boolean {\n\t\tif (generation !== this.generation || this.currentState !== \"initializing\") return false;\n\t\tthis.failure = undefined;\n\t\tthis.currentHandle = undefined;\n\t\tthis.currentState = \"idle\";\n\t\tvoid error;\n\t\treturn true;\n\t}\n\n\t/**\n\t * Ask the session to stop.\n\t *\n\t * With no handle yet there is nothing to drain, so this closes immediately\n\t * and any in-flight init will be discarded on arrival. With a live handle\n\t * the session must drain: the caller still has to close the driver.\n\t */\n\trequestShutdown(): void {\n\t\tthis.shutdownRequested = true;\n\t\tif (this.currentState === \"initializing\" || this.currentState === \"idle\") {\n\t\t\tthis.currentState = \"closed\";\n\t\t\treturn;\n\t\t}\n\t\tif (this.currentState === \"ready\") this.currentState = \"draining\";\n\t}\n\n\tbeginClose(): void {\n\t\tif (this.currentState !== \"ready\" && this.currentState !== \"close-failed\") {\n\t\t\tthrow new Error(`cannot close from state ${this.currentState}`);\n\t\t}\n\t\tthis.failure = undefined;\n\t\tthis.currentState = \"draining\";\n\t}\n\n\t/** The driver confirmed the session is gone; only now is the handle released. */\n\tcompleteClose(): void {\n\t\tif (this.currentState !== \"draining\") {\n\t\t\tthrow new Error(`cannot complete close from state ${this.currentState}`);\n\t\t}\n\t\tthis.currentHandle = undefined;\n\t\tthis.failure = undefined;\n\t\tthis.currentState = \"closed\";\n\t}\n\n\t/** The close attempt threw. Keep the handle so a retry can still reach it. */\n\tfailClose(error: Error): void {\n\t\tif (this.currentState !== \"draining\") {\n\t\t\tthrow new Error(`cannot fail close from state ${this.currentState}`);\n\t\t}\n\t\tthis.failure = error;\n\t\tthis.currentState = \"close-failed\";\n\t}\n\n\t/**\n\t * Fencing gate: accept a command only from the current generation of a\n\t * ready session. A generation number in a log proves nothing; the gate that\n\t * hands commands to the driver has to be the one refusing stale ones.\n\t */\n\taccepts(generation: Sequence): boolean {\n\t\treturn this.currentState === \"ready\" && generation === this.generation;\n\t}\n\n\t/** True once a shutdown was asked for, regardless of how far draining got. */\n\tget shutdownPending(): boolean {\n\t\treturn this.shutdownRequested;\n\t}\n}\n"]}
@@ -0,0 +1,68 @@
1
+ /**
2
+ * Wire contracts for parallel-session coordination.
3
+ *
4
+ * Ported from the proposed `contracts.ts` of the 2026-09-20 coordination
5
+ * design. These are new contracts, not pre-existing OMK exports.
6
+ *
7
+ * The central distinction the types encode: an authorization deadline is not a
8
+ * termination proof. A grant whose deadline passed while an external effect was
9
+ * live becomes `quarantined` — still holding its claims — rather than free.
10
+ */
11
+ /** Canonical nonnegative decimal string. Ordering is numeric, not lexical. */
12
+ export type Sequence = string & {
13
+ readonly __sequence: unique symbol;
14
+ };
15
+ export declare function sequence(value: unknown): Sequence;
16
+ export declare function nextSequence(value: Sequence): Sequence;
17
+ /**
18
+ * Lifecycle of an authorized effect.
19
+ *
20
+ * The in-process broker currently mints `reserved`, `running`, `quarantined`,
21
+ * `terminated` and `cancelled`. `starting` and `terminating` are reserved for
22
+ * the out-of-process supervisor that reports those transitions over the wire;
23
+ * nothing emits them yet, and the broker must not infer them.
24
+ */
25
+ export type EffectState = "reserved" | "starting" | "running" | "terminating" | "quarantined" | "terminated" | "cancelled";
26
+ /** States in which a grant no longer holds its claims. */
27
+ export declare const SETTLED_EFFECT_STATES: ReadonlySet<EffectState>;
28
+ export type ClaimNamespace = "filesystem" | "git-ref" | "contract" | "socket" | "database" | "host-budget";
29
+ export type ClaimAccess = "read" | "write";
30
+ /**
31
+ * One declared resource claim.
32
+ *
33
+ * `canonicalKey` must already be normalized by the caller: the broker rejects
34
+ * rather than guesses, because silently normalizing `a/../b` would let two
35
+ * sessions believe they hold disjoint keys.
36
+ */
37
+ export interface ResourceClaim {
38
+ readonly namespace: ClaimNamespace;
39
+ readonly instanceId: string;
40
+ readonly canonicalKey: string;
41
+ readonly access: ClaimAccess;
42
+ readonly generation: Sequence;
43
+ }
44
+ /**
45
+ * Proof of admission for exactly one operation of one session incarnation.
46
+ *
47
+ * `authorizationDeadline` bounds the authorization only. Termination is a
48
+ * separate, supervisor-reported fact.
49
+ */
50
+ export interface GrantToken {
51
+ readonly authorityEpoch: Sequence;
52
+ readonly grantSequence: Sequence;
53
+ readonly sessionId: string;
54
+ readonly sessionIncarnation: Sequence;
55
+ readonly authorizationDeadline: number;
56
+ }
57
+ export type AdmissionOutcome = {
58
+ readonly status: "granted";
59
+ readonly token: GrantToken;
60
+ } | {
61
+ readonly status: "blocked";
62
+ readonly blockers: readonly Sequence[];
63
+ } | {
64
+ readonly status: "over-capacity";
65
+ readonly requestedWeight: number;
66
+ readonly availableWeight: number;
67
+ };
68
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/coordination/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,8EAA8E;AAC9E,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG;IAAE,QAAQ,CAAC,UAAU,EAAE,OAAO,MAAM,CAAA;CAAE,CAAC;AAKvE,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,QAAQ,CAMjD;AAED,wBAAgB,YAAY,CAAC,KAAK,EAAE,QAAQ,GAAG,QAAQ,CAEtD;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,WAAW,GACpB,UAAU,GACV,UAAU,GACV,SAAS,GACT,aAAa,GACb,aAAa,GACb,YAAY,GACZ,WAAW,CAAC;AAEf,0DAA0D;AAC1D,eAAO,MAAM,qBAAqB,EAAE,WAAW,CAAC,WAAW,CAAqD,CAAC;AAEjH,MAAM,MAAM,cAAc,GAAG,YAAY,GAAG,SAAS,GAAG,UAAU,GAAG,QAAQ,GAAG,UAAU,GAAG,aAAa,CAAC;AAC3G,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,OAAO,CAAC;AAE3C;;;;;;GAMG;AACH,MAAM,WAAW,aAAa;IAC7B,QAAQ,CAAC,SAAS,EAAE,cAAc,CAAC;IACnC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC;CAC9B;AAED;;;;;GAKG;AACH,MAAM,WAAW,UAAU;IAC1B,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC;IAClC,QAAQ,CAAC,aAAa,EAAE,QAAQ,CAAC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,kBAAkB,EAAE,QAAQ,CAAC;IACtC,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;CACvC;AAED,MAAM,MAAM,gBAAgB,GACzB;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,UAAU,CAAA;CAAE,GAC1D;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,QAAQ,EAAE,CAAA;CAAE,GACtE;IAAE,QAAQ,CAAC,MAAM,EAAE,eAAe,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,eAAe,EAAE,MAAM,CAAA;CAAE,CAAC","sourcesContent":["/**\n * Wire contracts for parallel-session coordination.\n *\n * Ported from the proposed `contracts.ts` of the 2026-09-20 coordination\n * design. These are new contracts, not pre-existing OMK exports.\n *\n * The central distinction the types encode: an authorization deadline is not a\n * termination proof. A grant whose deadline passed while an external effect was\n * live becomes `quarantined` — still holding its claims — rather than free.\n */\n\n/** Canonical nonnegative decimal string. Ordering is numeric, not lexical. */\nexport type Sequence = string & { readonly __sequence: unique symbol };\n\nconst SEQUENCE_PATTERN = /^(0|[1-9][0-9]*)$/;\nconst MAX_SEQUENCE_LENGTH = 40;\n\nexport function sequence(value: unknown): Sequence {\n\tif (typeof value !== \"string\" || !SEQUENCE_PATTERN.test(value)) {\n\t\tthrow new TypeError(\"sequence must be a canonical nonnegative decimal string\");\n\t}\n\tif (value.length > MAX_SEQUENCE_LENGTH) throw new RangeError(\"sequence too long\");\n\treturn value as Sequence;\n}\n\nexport function nextSequence(value: Sequence): Sequence {\n\treturn String(BigInt(value) + 1n) as Sequence;\n}\n\n/**\n * Lifecycle of an authorized effect.\n *\n * The in-process broker currently mints `reserved`, `running`, `quarantined`,\n * `terminated` and `cancelled`. `starting` and `terminating` are reserved for\n * the out-of-process supervisor that reports those transitions over the wire;\n * nothing emits them yet, and the broker must not infer them.\n */\nexport type EffectState =\n\t| \"reserved\"\n\t| \"starting\"\n\t| \"running\"\n\t| \"terminating\"\n\t| \"quarantined\"\n\t| \"terminated\"\n\t| \"cancelled\";\n\n/** States in which a grant no longer holds its claims. */\nexport const SETTLED_EFFECT_STATES: ReadonlySet<EffectState> = new Set<EffectState>([\"terminated\", \"cancelled\"]);\n\nexport type ClaimNamespace = \"filesystem\" | \"git-ref\" | \"contract\" | \"socket\" | \"database\" | \"host-budget\";\nexport type ClaimAccess = \"read\" | \"write\";\n\n/**\n * One declared resource claim.\n *\n * `canonicalKey` must already be normalized by the caller: the broker rejects\n * rather than guesses, because silently normalizing `a/../b` would let two\n * sessions believe they hold disjoint keys.\n */\nexport interface ResourceClaim {\n\treadonly namespace: ClaimNamespace;\n\treadonly instanceId: string;\n\treadonly canonicalKey: string;\n\treadonly access: ClaimAccess;\n\treadonly generation: Sequence;\n}\n\n/**\n * Proof of admission for exactly one operation of one session incarnation.\n *\n * `authorizationDeadline` bounds the authorization only. Termination is a\n * separate, supervisor-reported fact.\n */\nexport interface GrantToken {\n\treadonly authorityEpoch: Sequence;\n\treadonly grantSequence: Sequence;\n\treadonly sessionId: string;\n\treadonly sessionIncarnation: Sequence;\n\treadonly authorizationDeadline: number;\n}\n\nexport type AdmissionOutcome =\n\t| { readonly status: \"granted\"; readonly token: GrantToken }\n\t| { readonly status: \"blocked\"; readonly blockers: readonly Sequence[] }\n\t| { readonly status: \"over-capacity\"; readonly requestedWeight: number; readonly availableWeight: number };\n"]}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Wire contracts for parallel-session coordination.
3
+ *
4
+ * Ported from the proposed `contracts.ts` of the 2026-09-20 coordination
5
+ * design. These are new contracts, not pre-existing OMK exports.
6
+ *
7
+ * The central distinction the types encode: an authorization deadline is not a
8
+ * termination proof. A grant whose deadline passed while an external effect was
9
+ * live becomes `quarantined` — still holding its claims — rather than free.
10
+ */
11
+ const SEQUENCE_PATTERN = /^(0|[1-9][0-9]*)$/;
12
+ const MAX_SEQUENCE_LENGTH = 40;
13
+ export function sequence(value) {
14
+ if (typeof value !== "string" || !SEQUENCE_PATTERN.test(value)) {
15
+ throw new TypeError("sequence must be a canonical nonnegative decimal string");
16
+ }
17
+ if (value.length > MAX_SEQUENCE_LENGTH)
18
+ throw new RangeError("sequence too long");
19
+ return value;
20
+ }
21
+ export function nextSequence(value) {
22
+ return String(BigInt(value) + 1n);
23
+ }
24
+ /** States in which a grant no longer holds its claims. */
25
+ export const SETTLED_EFFECT_STATES = new Set(["terminated", "cancelled"]);
26
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/coordination/types.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAKH,MAAM,gBAAgB,GAAG,mBAAmB,CAAC;AAC7C,MAAM,mBAAmB,GAAG,EAAE,CAAC;AAE/B,MAAM,UAAU,QAAQ,CAAC,KAAc,EAAY;IAClD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;QAChE,MAAM,IAAI,SAAS,CAAC,yDAAyD,CAAC,CAAC;IAChF,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,mBAAmB;QAAE,MAAM,IAAI,UAAU,CAAC,mBAAmB,CAAC,CAAC;IAClF,OAAO,KAAiB,CAAC;AAAA,CACzB;AAED,MAAM,UAAU,YAAY,CAAC,KAAe,EAAY;IACvD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,GAAG,EAAE,CAAa,CAAC;AAAA,CAC9C;AAmBD,0DAA0D;AAC1D,MAAM,CAAC,MAAM,qBAAqB,GAA6B,IAAI,GAAG,CAAc,CAAC,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC","sourcesContent":["/**\n * Wire contracts for parallel-session coordination.\n *\n * Ported from the proposed `contracts.ts` of the 2026-09-20 coordination\n * design. These are new contracts, not pre-existing OMK exports.\n *\n * The central distinction the types encode: an authorization deadline is not a\n * termination proof. A grant whose deadline passed while an external effect was\n * live becomes `quarantined` — still holding its claims — rather than free.\n */\n\n/** Canonical nonnegative decimal string. Ordering is numeric, not lexical. */\nexport type Sequence = string & { readonly __sequence: unique symbol };\n\nconst SEQUENCE_PATTERN = /^(0|[1-9][0-9]*)$/;\nconst MAX_SEQUENCE_LENGTH = 40;\n\nexport function sequence(value: unknown): Sequence {\n\tif (typeof value !== \"string\" || !SEQUENCE_PATTERN.test(value)) {\n\t\tthrow new TypeError(\"sequence must be a canonical nonnegative decimal string\");\n\t}\n\tif (value.length > MAX_SEQUENCE_LENGTH) throw new RangeError(\"sequence too long\");\n\treturn value as Sequence;\n}\n\nexport function nextSequence(value: Sequence): Sequence {\n\treturn String(BigInt(value) + 1n) as Sequence;\n}\n\n/**\n * Lifecycle of an authorized effect.\n *\n * The in-process broker currently mints `reserved`, `running`, `quarantined`,\n * `terminated` and `cancelled`. `starting` and `terminating` are reserved for\n * the out-of-process supervisor that reports those transitions over the wire;\n * nothing emits them yet, and the broker must not infer them.\n */\nexport type EffectState =\n\t| \"reserved\"\n\t| \"starting\"\n\t| \"running\"\n\t| \"terminating\"\n\t| \"quarantined\"\n\t| \"terminated\"\n\t| \"cancelled\";\n\n/** States in which a grant no longer holds its claims. */\nexport const SETTLED_EFFECT_STATES: ReadonlySet<EffectState> = new Set<EffectState>([\"terminated\", \"cancelled\"]);\n\nexport type ClaimNamespace = \"filesystem\" | \"git-ref\" | \"contract\" | \"socket\" | \"database\" | \"host-budget\";\nexport type ClaimAccess = \"read\" | \"write\";\n\n/**\n * One declared resource claim.\n *\n * `canonicalKey` must already be normalized by the caller: the broker rejects\n * rather than guesses, because silently normalizing `a/../b` would let two\n * sessions believe they hold disjoint keys.\n */\nexport interface ResourceClaim {\n\treadonly namespace: ClaimNamespace;\n\treadonly instanceId: string;\n\treadonly canonicalKey: string;\n\treadonly access: ClaimAccess;\n\treadonly generation: Sequence;\n}\n\n/**\n * Proof of admission for exactly one operation of one session incarnation.\n *\n * `authorizationDeadline` bounds the authorization only. Termination is a\n * separate, supervisor-reported fact.\n */\nexport interface GrantToken {\n\treadonly authorityEpoch: Sequence;\n\treadonly grantSequence: Sequence;\n\treadonly sessionId: string;\n\treadonly sessionIncarnation: Sequence;\n\treadonly authorizationDeadline: number;\n}\n\nexport type AdmissionOutcome =\n\t| { readonly status: \"granted\"; readonly token: GrantToken }\n\t| { readonly status: \"blocked\"; readonly blockers: readonly Sequence[] }\n\t| { readonly status: \"over-capacity\"; readonly requestedWeight: number; readonly availableWeight: number };\n"]}
@@ -348,6 +348,7 @@ export declare class AgentSession {
348
348
  private readonly _resourceObservationJournals;
349
349
  private _latestResourcePromptRunId;
350
350
  private _lastResourceAdmission;
351
+ private _resourcePressureStabilizer;
351
352
  private _workloadPermitPool;
352
353
  private _pendingRuntimeTerminationCause;
353
354
  private _activeRunToolTermination;
@@ -550,6 +551,14 @@ export declare class AgentSession {
550
551
  * Extract the most recent user query text from conversation messages.
551
552
  * Returns undefined when no user message exists or content is empty.
552
553
  * Handles both string content and multimodal (array) content.
554
+ *
555
+ * The scan walks the whole transcript backwards and stops at the first user
556
+ * message. A fixed tail window cannot work here: tool results are their own
557
+ * messages, so a single turn that calls two tools already leaves
558
+ * `[user, assistant, toolResult, toolResult]` and buries the task four deep.
559
+ * Losing it mid-turn collapses every skill to the neutral relevance score and
560
+ * degrades ranking to catalogue order, precisely while tools are running and
561
+ * a matching skill matters most.
553
562
  */
554
563
  private _extractCurrentQuery;
555
564
  private _getContextBudgetOptions;
@@ -562,11 +571,24 @@ export declare class AgentSession {
562
571
  private _rebuildSystemPrompt;
563
572
  private _runAgentPrompt;
564
573
  private _beginResourceGovernedRun;
574
+ /**
575
+ * Feed one snapshot's raw pressure through the per-session stabilizer.
576
+ * Created lazily so sessions that never probe carry no state; the first
577
+ * observation installs its own level directly (no warmup lag).
578
+ */
579
+ private _stabilizeResourcePressure;
565
580
  private _openResourceObservations;
566
581
  /** §20.2: record the TUI-side completion sound result in its originating run journal. */
567
582
  recordCompletionSoundResult(promptRunId: string, result: import("./completion-sound.ts").CompletionSoundResult): void;
568
583
  /** §19.4 read-only SDK surface: the most recent resource admission decision, if any. */
569
584
  getCurrentResourceAdmission(): ResourceAdmissionDecision | null;
585
+ /**
586
+ * Spec 020 Req1 — canonical subagent lane authority bound to this session.
587
+ * Rebuilt on each call so it tracks the live admission decision, shared
588
+ * permit pool, and open prompt run. Extension tool contexts read it through
589
+ * `ctx.getSubagentLaneAuthority()`.
590
+ */
591
+ private _getSubagentLaneAuthority;
570
592
  /** §19.4 read-only SDK surface: capture a fresh host resource snapshot. */
571
593
  getHostResourceSnapshot(): Promise<HostResourceSnapshot>;
572
594
  /** §19.4 read-only SDK surface: shared workload permit pool state, if any. */
@@ -830,8 +852,13 @@ export declare class AgentSession {
830
852
  /**
831
853
  * Effective context window for the upcoming turn.
832
854
  * Image-bearing turns with a text-only session model are auto-routed to the
833
- * vision model (gpt-5.6-luna, 1M) — that window is the real limit. Text-only
834
- * turns keep the session model's (typically much larger) window.
855
+ * vision model (gpt-5.6-luna, 1M), so the request has to fit both windows and
856
+ * the binding limit is the smaller one. Session windows fall on both sides of
857
+ * 1M: most catalogued models are smaller (median near 300K) and keep their own
858
+ * window as the limit, while the larger-than-1M models are the ones the clamp
859
+ * exists for — without it their threshold is computed against a window the
860
+ * vision route will not honour, and the request overflows before compaction
861
+ * fires. Text-only turns keep the session model's window untouched.
835
862
  */
836
863
  private _effectiveTurnContextWindow;
837
864
  private _checkProjectedCompaction;