@intentic/sandbox-contract 1.247.0 → 1.249.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 (883) hide show
  1. package/README.md +18 -15
  2. package/dist/chores/chores.d.ts.map +1 -1
  3. package/dist/chores/chores.js.map +1 -1
  4. package/dist/chores/digest.d.ts.map +1 -1
  5. package/dist/chores/digest.js.map +1 -1
  6. package/dist/chores/extension-update.d.ts.map +1 -1
  7. package/dist/chores/extension-update.js.map +1 -1
  8. package/dist/chores/fix-deps.d.ts.map +1 -1
  9. package/dist/chores/fix-deps.js.map +1 -1
  10. package/dist/chores/index.d.ts +2 -2
  11. package/dist/chores/index.d.ts.map +1 -1
  12. package/dist/chores/index.js +1 -1
  13. package/dist/chores/index.js.map +1 -1
  14. package/dist/chores/probes.d.ts.map +1 -1
  15. package/dist/chores/probes.js.map +1 -1
  16. package/dist/chores/prompt.d.ts.map +1 -1
  17. package/dist/chores/prompt.js.map +1 -1
  18. package/dist/chores/stack.d.ts.map +1 -1
  19. package/dist/chores/stack.js.map +1 -1
  20. package/dist/chores/verdict.d.ts +7 -1
  21. package/dist/chores/verdict.d.ts.map +1 -1
  22. package/dist/chores/verdict.js +8 -0
  23. package/dist/chores/verdict.js.map +1 -1
  24. package/dist/contracts/accounts.contract.d.ts.map +1 -1
  25. package/dist/contracts/accounts.contract.js.map +1 -1
  26. package/dist/contracts/activity.contract.d.ts +1 -0
  27. package/dist/contracts/activity.contract.d.ts.map +1 -1
  28. package/dist/contracts/agent.contract.d.ts +13 -205
  29. package/dist/contracts/agent.contract.d.ts.map +1 -1
  30. package/dist/contracts/agent.contract.js +2 -1
  31. package/dist/contracts/agent.contract.js.map +1 -1
  32. package/dist/contracts/agents.contract.d.ts +228 -54
  33. package/dist/contracts/agents.contract.d.ts.map +1 -1
  34. package/dist/contracts/agents.contract.js +11 -2
  35. package/dist/contracts/agents.contract.js.map +1 -1
  36. package/dist/contracts/automations.contract.d.ts +35 -17
  37. package/dist/contracts/automations.contract.d.ts.map +1 -1
  38. package/dist/contracts/automations.contract.js +10 -1
  39. package/dist/contracts/automations.contract.js.map +1 -1
  40. package/dist/contracts/capabilities.contract.d.ts +0 -12
  41. package/dist/contracts/capabilities.contract.d.ts.map +1 -1
  42. package/dist/contracts/capabilities.contract.js +1 -1
  43. package/dist/contracts/capabilities.contract.js.map +1 -1
  44. package/dist/contracts/chores.contract.d.ts.map +1 -1
  45. package/dist/contracts/chores.contract.js.map +1 -1
  46. package/dist/contracts/ci.contract.d.ts +9 -0
  47. package/dist/contracts/ci.contract.d.ts.map +1 -1
  48. package/dist/contracts/endpoints.contract.d.ts.map +1 -1
  49. package/dist/contracts/endpoints.contract.js.map +1 -1
  50. package/dist/contracts/exit.contract.d.ts.map +1 -1
  51. package/dist/contracts/exit.contract.js +1 -1
  52. package/dist/contracts/exit.contract.js.map +1 -1
  53. package/dist/contracts/extensions.contract.d.ts.map +1 -1
  54. package/dist/contracts/extensions.contract.js.map +1 -1
  55. package/dist/contracts/git.contract.d.ts +45 -6
  56. package/dist/contracts/git.contract.d.ts.map +1 -1
  57. package/dist/contracts/git.contract.js +9 -9
  58. package/dist/contracts/git.contract.js.map +1 -1
  59. package/dist/contracts/host.contract.d.ts +2 -0
  60. package/dist/contracts/host.contract.d.ts.map +1 -1
  61. package/dist/contracts/host.contract.js.map +1 -1
  62. package/dist/contracts/intentic.contract.js +1 -1
  63. package/dist/contracts/intentic.contract.js.map +1 -1
  64. package/dist/contracts/logs.contract.d.ts.map +1 -1
  65. package/dist/contracts/logs.contract.js.map +1 -1
  66. package/dist/contracts/loops.contract.d.ts.map +1 -1
  67. package/dist/contracts/loops.contract.js.map +1 -1
  68. package/dist/contracts/personas.contract.d.ts +39 -4
  69. package/dist/contracts/personas.contract.d.ts.map +1 -1
  70. package/dist/contracts/personas.contract.js +10 -1
  71. package/dist/contracts/personas.contract.js.map +1 -1
  72. package/dist/contracts/providers.contract.d.ts.map +1 -1
  73. package/dist/contracts/providers.contract.js.map +1 -1
  74. package/dist/contracts/runner.contract.d.ts +6 -80
  75. package/dist/contracts/runner.contract.d.ts.map +1 -1
  76. package/dist/contracts/runner.contract.js +2 -2
  77. package/dist/contracts/runner.contract.js.map +1 -1
  78. package/dist/contracts/safety.contract.d.ts.map +1 -1
  79. package/dist/contracts/safety.contract.js +1 -1
  80. package/dist/contracts/safety.contract.js.map +1 -1
  81. package/dist/contracts/secrets.contract.d.ts.map +1 -1
  82. package/dist/contracts/secrets.contract.js.map +1 -1
  83. package/dist/contracts/sessions.contract.d.ts +2 -41
  84. package/dist/contracts/sessions.contract.d.ts.map +1 -1
  85. package/dist/contracts/sessions.contract.js +1 -1
  86. package/dist/contracts/sessions.contract.js.map +1 -1
  87. package/dist/contracts/settings.contract.d.ts +10 -10
  88. package/dist/contracts/settings.contract.d.ts.map +1 -1
  89. package/dist/contracts/settings.contract.js.map +1 -1
  90. package/dist/contracts/share.contract.d.ts.map +1 -1
  91. package/dist/contracts/share.contract.js.map +1 -1
  92. package/dist/contracts/skills.contract.d.ts.map +1 -1
  93. package/dist/contracts/skills.contract.js.map +1 -1
  94. package/dist/contracts/system.contract.d.ts +49 -73
  95. package/dist/contracts/system.contract.d.ts.map +1 -1
  96. package/dist/contracts/system.contract.js +12 -2
  97. package/dist/contracts/system.contract.js.map +1 -1
  98. package/dist/contracts/usage.contract.d.ts.map +1 -1
  99. package/dist/contracts/usage.contract.js.map +1 -1
  100. package/dist/contracts/vpn.contract.d.ts.map +1 -1
  101. package/dist/contracts/vpn.contract.js +1 -1
  102. package/dist/contracts/vpn.contract.js.map +1 -1
  103. package/dist/contracts/webext.contract.d.ts.map +1 -1
  104. package/dist/contracts/webext.contract.js.map +1 -1
  105. package/dist/contracts/workflows.contract.d.ts +7 -6
  106. package/dist/contracts/workflows.contract.d.ts.map +1 -1
  107. package/dist/contracts/workflows.contract.js +12 -3
  108. package/dist/contracts/workflows.contract.js.map +1 -1
  109. package/dist/contracts/workspace.contract.d.ts.map +1 -1
  110. package/dist/contracts/workspace.contract.js.map +1 -1
  111. package/dist/events/agent-events.d.ts +1237 -0
  112. package/dist/events/agent-events.d.ts.map +1 -0
  113. package/dist/events/agent-events.js +226 -0
  114. package/dist/events/agent-events.js.map +1 -0
  115. package/dist/events/cards.d.ts +404 -0
  116. package/dist/events/cards.d.ts.map +1 -0
  117. package/dist/events/cards.js +179 -0
  118. package/dist/events/cards.js.map +1 -0
  119. package/dist/events/resume.d.ts +23 -0
  120. package/dist/events/resume.d.ts.map +1 -0
  121. package/dist/events/resume.js +31 -0
  122. package/dist/events/resume.js.map +1 -0
  123. package/dist/events/system-events.d.ts +615 -0
  124. package/dist/events/system-events.d.ts.map +1 -0
  125. package/dist/events/system-events.js +64 -0
  126. package/dist/events/system-events.js.map +1 -0
  127. package/dist/events/transcript.d.ts +1755 -0
  128. package/dist/events/transcript.d.ts.map +1 -0
  129. package/dist/events/transcript.js +205 -0
  130. package/dist/events/transcript.js.map +1 -0
  131. package/dist/ids/conversation-ids.d.ts +8 -0
  132. package/dist/ids/conversation-ids.d.ts.map +1 -0
  133. package/dist/{conversation-ids.js → ids/conversation-ids.js} +13 -0
  134. package/dist/ids/conversation-ids.js.map +1 -0
  135. package/dist/ids/hostnames.d.ts.map +1 -0
  136. package/dist/ids/hostnames.js.map +1 -0
  137. package/dist/ids/session-names.d.ts.map +1 -0
  138. package/dist/ids/session-names.js.map +1 -0
  139. package/dist/ids/share-paths.d.ts.map +1 -0
  140. package/dist/ids/share-paths.js.map +1 -0
  141. package/dist/{tunnel-ids.d.ts → ids/tunnel-ids.d.ts} +1 -0
  142. package/dist/ids/tunnel-ids.d.ts.map +1 -0
  143. package/dist/{tunnel-ids.js → ids/tunnel-ids.js} +1 -0
  144. package/dist/ids/tunnel-ids.js.map +1 -0
  145. package/dist/index.d.ts +464 -447
  146. package/dist/index.d.ts.map +1 -1
  147. package/dist/index.js +54 -47
  148. package/dist/index.js.map +1 -1
  149. package/dist/{agent-catalog.d.ts → models/agent-catalog.d.ts} +2 -2
  150. package/dist/models/agent-catalog.d.ts.map +1 -0
  151. package/dist/models/agent-catalog.js.map +1 -0
  152. package/dist/models/agent-runtimes.d.ts.map +1 -0
  153. package/dist/models/agent-runtimes.js.map +1 -0
  154. package/dist/{fast-tier.d.ts → models/fast-tier.d.ts} +1 -1
  155. package/dist/models/fast-tier.d.ts.map +1 -0
  156. package/dist/models/fast-tier.js.map +1 -0
  157. package/dist/models/model-order.d.ts.map +1 -0
  158. package/dist/models/model-order.js.map +1 -0
  159. package/dist/{model-pins.d.ts → models/model-pins.d.ts} +2 -4
  160. package/dist/models/model-pins.d.ts.map +1 -0
  161. package/dist/models/model-pins.js +22 -0
  162. package/dist/models/model-pins.js.map +1 -0
  163. package/dist/{model-roles.d.ts → models/model-roles.d.ts} +25 -30
  164. package/dist/models/model-roles.d.ts.map +1 -0
  165. package/dist/{model-roles.js → models/model-roles.js} +30 -27
  166. package/dist/models/model-roles.js.map +1 -0
  167. package/dist/{plan-pools.d.ts → models/plan-pools.d.ts} +1 -1
  168. package/dist/models/plan-pools.d.ts.map +1 -0
  169. package/dist/models/plan-pools.js.map +1 -0
  170. package/dist/models/prompt-complexity.d.ts.map +1 -0
  171. package/dist/models/prompt-complexity.js.map +1 -0
  172. package/dist/models/provider-specs.d.ts.map +1 -0
  173. package/dist/models/provider-specs.js.map +1 -0
  174. package/dist/policy/approvals-execution.d.ts.map +1 -0
  175. package/dist/policy/approvals-execution.js.map +1 -0
  176. package/dist/{batch-runs.d.ts → policy/batch-runs.d.ts} +5 -1
  177. package/dist/policy/batch-runs.d.ts.map +1 -0
  178. package/dist/{batch-runs.js → policy/batch-runs.js} +10 -7
  179. package/dist/policy/batch-runs.js.map +1 -0
  180. package/dist/policy/capability-env.d.ts.map +1 -0
  181. package/dist/policy/capability-env.js.map +1 -0
  182. package/dist/policy/capability-secrets.d.ts.map +1 -0
  183. package/dist/policy/capability-secrets.js.map +1 -0
  184. package/dist/{card-status.d.ts → policy/card-status.d.ts} +2 -2
  185. package/dist/policy/card-status.d.ts.map +1 -0
  186. package/dist/{card-status.js → policy/card-status.js} +1 -5
  187. package/dist/policy/card-status.js.map +1 -0
  188. package/dist/{command-classes.d.ts → policy/command-classes.d.ts} +6 -2
  189. package/dist/policy/command-classes.d.ts.map +1 -0
  190. package/dist/{command-classes.js → policy/command-classes.js} +48 -11
  191. package/dist/policy/command-classes.js.map +1 -0
  192. package/dist/{command-run.d.ts → policy/command-run.d.ts} +1 -1
  193. package/dist/policy/command-run.d.ts.map +1 -0
  194. package/dist/policy/command-run.js.map +1 -0
  195. package/dist/policy/control-scopes.d.ts +16 -0
  196. package/dist/policy/control-scopes.d.ts.map +1 -0
  197. package/dist/policy/control-scopes.js +26 -0
  198. package/dist/policy/control-scopes.js.map +1 -0
  199. package/dist/policy/credential-material.d.ts.map +1 -0
  200. package/dist/policy/credential-material.js.map +1 -0
  201. package/dist/policy/needs-action.d.ts.map +1 -0
  202. package/dist/policy/needs-action.js.map +1 -0
  203. package/dist/policy/output-fields.d.ts.map +1 -0
  204. package/dist/policy/output-fields.js.map +1 -0
  205. package/dist/policy/overlay-lint.d.ts.map +1 -0
  206. package/dist/policy/overlay-lint.js.map +1 -0
  207. package/dist/policy/owner-ticket.d.ts.map +1 -0
  208. package/dist/{owner-ticket.js → policy/owner-ticket.js} +1 -1
  209. package/dist/policy/owner-ticket.js.map +1 -0
  210. package/dist/{safety-policy.d.ts → policy/safety-policy.d.ts} +6 -5
  211. package/dist/policy/safety-policy.d.ts.map +1 -0
  212. package/dist/{safety-policy.js → policy/safety-policy.js} +12 -12
  213. package/dist/policy/safety-policy.js.map +1 -0
  214. package/dist/policy/search-globs.d.ts.map +1 -0
  215. package/dist/policy/search-globs.js.map +1 -0
  216. package/dist/protocol/container-requirements.d.ts +20 -0
  217. package/dist/protocol/container-requirements.d.ts.map +1 -0
  218. package/dist/protocol/container-requirements.js +23 -0
  219. package/dist/protocol/container-requirements.js.map +1 -0
  220. package/dist/{host-protocol.d.ts → protocol/host-protocol.d.ts} +1 -0
  221. package/dist/protocol/host-protocol.d.ts.map +1 -0
  222. package/dist/{host-protocol.js → protocol/host-protocol.js} +1 -0
  223. package/dist/protocol/host-protocol.js.map +1 -0
  224. package/dist/protocol/ingress-contract.d.ts.map +1 -0
  225. package/dist/{ingress-contract.js → protocol/ingress-contract.js} +1 -1
  226. package/dist/protocol/ingress-contract.js.map +1 -0
  227. package/dist/protocol/ingress-protocol.d.ts.map +1 -0
  228. package/dist/protocol/ingress-protocol.js.map +1 -0
  229. package/dist/protocol/listener-protocol.d.ts.map +1 -0
  230. package/dist/{listener-protocol.js → protocol/listener-protocol.js} +1 -1
  231. package/dist/protocol/listener-protocol.js.map +1 -0
  232. package/dist/{peer-dial.d.ts → protocol/peer-dial.d.ts} +4 -1
  233. package/dist/protocol/peer-dial.d.ts.map +1 -0
  234. package/dist/{peer-dial.js → protocol/peer-dial.js} +51 -10
  235. package/dist/protocol/peer-dial.js.map +1 -0
  236. package/dist/protocol/peer-mcp-server.d.ts.map +1 -0
  237. package/dist/protocol/peer-mcp-server.js.map +1 -0
  238. package/dist/protocol/request-id.d.ts.map +1 -0
  239. package/dist/protocol/request-id.js.map +1 -0
  240. package/dist/protocol/routes.d.ts.map +1 -0
  241. package/dist/protocol/routes.js.map +1 -0
  242. package/dist/{runner-protocol.d.ts → protocol/runner-protocol.d.ts} +1 -0
  243. package/dist/protocol/runner-protocol.d.ts.map +1 -0
  244. package/dist/{runner-protocol.js → protocol/runner-protocol.js} +2 -1
  245. package/dist/protocol/runner-protocol.js.map +1 -0
  246. package/dist/protocol/sse.d.ts.map +1 -0
  247. package/dist/protocol/sse.js.map +1 -0
  248. package/dist/{terminal-protocol.d.ts → protocol/terminal-protocol.d.ts} +1 -3
  249. package/dist/protocol/terminal-protocol.d.ts.map +1 -0
  250. package/dist/protocol/terminal-protocol.js.map +1 -0
  251. package/dist/protocol/webext-links.d.ts.map +1 -0
  252. package/dist/protocol/webext-links.js.map +1 -0
  253. package/dist/{webext-protocol.d.ts → protocol/webext-protocol.d.ts} +1 -0
  254. package/dist/protocol/webext-protocol.d.ts.map +1 -0
  255. package/dist/{webext-protocol.js → protocol/webext-protocol.js} +1 -0
  256. package/dist/protocol/webext-protocol.js.map +1 -0
  257. package/dist/schemas/activity.d.ts +2 -0
  258. package/dist/schemas/activity.d.ts.map +1 -1
  259. package/dist/schemas/activity.js +4 -0
  260. package/dist/schemas/activity.js.map +1 -1
  261. package/dist/schemas/agent.d.ts +17 -4
  262. package/dist/schemas/agent.d.ts.map +1 -1
  263. package/dist/schemas/agent.js +21 -4
  264. package/dist/schemas/agent.js.map +1 -1
  265. package/dist/schemas/agents.d.ts +17 -4
  266. package/dist/schemas/agents.d.ts.map +1 -1
  267. package/dist/schemas/agents.js +15 -4
  268. package/dist/schemas/agents.js.map +1 -1
  269. package/dist/schemas/approvals.d.ts.map +1 -1
  270. package/dist/schemas/approvals.js.map +1 -1
  271. package/dist/schemas/automations.d.ts +54 -28
  272. package/dist/schemas/automations.d.ts.map +1 -1
  273. package/dist/schemas/automations.js +26 -8
  274. package/dist/schemas/automations.js.map +1 -1
  275. package/dist/schemas/capabilities.d.ts +0 -8
  276. package/dist/schemas/capabilities.d.ts.map +1 -1
  277. package/dist/schemas/capabilities.js +0 -4
  278. package/dist/schemas/capabilities.js.map +1 -1
  279. package/dist/schemas/ci.d.ts +10 -0
  280. package/dist/schemas/ci.d.ts.map +1 -1
  281. package/dist/schemas/ci.js +9 -1
  282. package/dist/schemas/ci.js.map +1 -1
  283. package/dist/schemas/codebase-health.d.ts.map +1 -1
  284. package/dist/schemas/codebase-health.js.map +1 -1
  285. package/dist/schemas/devices.d.ts +90 -0
  286. package/dist/schemas/devices.d.ts.map +1 -1
  287. package/dist/schemas/devices.js +10 -1
  288. package/dist/schemas/devices.js.map +1 -1
  289. package/dist/schemas/engines.d.ts.map +1 -1
  290. package/dist/schemas/engines.js.map +1 -1
  291. package/dist/schemas/environment.d.ts.map +1 -1
  292. package/dist/schemas/environment.js.map +1 -1
  293. package/dist/schemas/exit.d.ts.map +1 -1
  294. package/dist/schemas/exit.js.map +1 -1
  295. package/dist/schemas/extension-updates.d.ts.map +1 -1
  296. package/dist/schemas/extension-updates.js.map +1 -1
  297. package/dist/schemas/git-history.d.ts.map +1 -1
  298. package/dist/schemas/git-history.js.map +1 -1
  299. package/dist/schemas/git.d.ts +80 -16
  300. package/dist/schemas/git.d.ts.map +1 -1
  301. package/dist/schemas/git.js +37 -25
  302. package/dist/schemas/git.js.map +1 -1
  303. package/dist/schemas/history.d.ts.map +1 -1
  304. package/dist/schemas/history.js.map +1 -1
  305. package/dist/schemas/hosts.d.ts.map +1 -1
  306. package/dist/schemas/hosts.js.map +1 -1
  307. package/dist/schemas/inventory.d.ts.map +1 -1
  308. package/dist/schemas/inventory.js.map +1 -1
  309. package/dist/schemas/issues.d.ts +0 -1
  310. package/dist/schemas/issues.d.ts.map +1 -1
  311. package/dist/schemas/issues.js +0 -1
  312. package/dist/schemas/issues.js.map +1 -1
  313. package/dist/schemas/logs.d.ts.map +1 -1
  314. package/dist/schemas/logs.js.map +1 -1
  315. package/dist/schemas/loops.d.ts.map +1 -1
  316. package/dist/schemas/loops.js +1 -1
  317. package/dist/schemas/loops.js.map +1 -1
  318. package/dist/schemas/maintenance.d.ts.map +1 -1
  319. package/dist/schemas/maintenance.js.map +1 -1
  320. package/dist/schemas/marketplace.d.ts +0 -4
  321. package/dist/schemas/marketplace.d.ts.map +1 -1
  322. package/dist/schemas/panels.d.ts.map +1 -1
  323. package/dist/schemas/panels.js.map +1 -1
  324. package/dist/schemas/personas.d.ts +49 -4
  325. package/dist/schemas/personas.d.ts.map +1 -1
  326. package/dist/schemas/personas.js +32 -5
  327. package/dist/schemas/personas.js.map +1 -1
  328. package/dist/schemas/plan-limits.d.ts +2 -4
  329. package/dist/schemas/plan-limits.d.ts.map +1 -1
  330. package/dist/schemas/plan-limits.js +5 -8
  331. package/dist/schemas/plan-limits.js.map +1 -1
  332. package/dist/schemas/ports.d.ts.map +1 -1
  333. package/dist/schemas/ports.js.map +1 -1
  334. package/dist/schemas/provider-oauth.d.ts.map +1 -1
  335. package/dist/schemas/provider-oauth.js.map +1 -1
  336. package/dist/schemas/provider-subscriptions.d.ts +1 -1
  337. package/dist/schemas/provider-subscriptions.d.ts.map +1 -1
  338. package/dist/schemas/provider-subscriptions.js +1 -1
  339. package/dist/schemas/provider-subscriptions.js.map +1 -1
  340. package/dist/schemas/public.d.ts.map +1 -1
  341. package/dist/schemas/public.js.map +1 -1
  342. package/dist/schemas/push.d.ts.map +1 -1
  343. package/dist/schemas/push.js.map +1 -1
  344. package/dist/schemas/secrets.d.ts.map +1 -1
  345. package/dist/schemas/secrets.js.map +1 -1
  346. package/dist/schemas/settings.d.ts +7 -5
  347. package/dist/schemas/settings.d.ts.map +1 -1
  348. package/dist/schemas/settings.js +18 -8
  349. package/dist/schemas/settings.js.map +1 -1
  350. package/dist/schemas/share.d.ts.map +1 -1
  351. package/dist/schemas/share.js.map +1 -1
  352. package/dist/schemas/shared.d.ts +4 -0
  353. package/dist/schemas/shared.d.ts.map +1 -1
  354. package/dist/schemas/shared.js +3 -0
  355. package/dist/schemas/shared.js.map +1 -1
  356. package/dist/schemas/system.d.ts +6 -0
  357. package/dist/schemas/system.d.ts.map +1 -1
  358. package/dist/schemas/system.js +10 -0
  359. package/dist/schemas/system.js.map +1 -1
  360. package/dist/schemas/terminal.d.ts.map +1 -1
  361. package/dist/schemas/terminal.js.map +1 -1
  362. package/dist/schemas/usage.d.ts.map +1 -1
  363. package/dist/schemas/usage.js.map +1 -1
  364. package/dist/schemas/vpn.d.ts.map +1 -1
  365. package/dist/schemas/vpn.js.map +1 -1
  366. package/dist/schemas/webext.d.ts.map +1 -1
  367. package/dist/schemas/webext.js.map +1 -1
  368. package/dist/schemas/workflows.d.ts +66 -9
  369. package/dist/schemas/workflows.d.ts.map +1 -1
  370. package/dist/schemas/workflows.js +6 -5
  371. package/dist/schemas/workflows.js.map +1 -1
  372. package/dist/schemas/workspace-repos.d.ts.map +1 -1
  373. package/dist/schemas/workspace-repos.js.map +1 -1
  374. package/dist/schemas/workspace-search.d.ts.map +1 -1
  375. package/dist/schemas/workspace-search.js.map +1 -1
  376. package/dist/schemas/workspace-setup.d.ts.map +1 -1
  377. package/dist/schemas/workspace-setup.js.map +1 -1
  378. package/dist/schemas/workspace-tree.d.ts.map +1 -1
  379. package/dist/schemas/workspace-tree.js.map +1 -1
  380. package/dist/state/arrival.d.ts.map +1 -0
  381. package/dist/{arrival.js → state/arrival.js} +1 -1
  382. package/dist/state/arrival.js.map +1 -0
  383. package/dist/state/contract-lock.d.ts.map +1 -0
  384. package/dist/{contract-lock.js → state/contract-lock.js} +1 -1
  385. package/dist/state/contract-lock.js.map +1 -0
  386. package/dist/{definition.d.ts → state/definition.d.ts} +21 -17
  387. package/dist/state/definition.d.ts.map +1 -0
  388. package/dist/{definition.js → state/definition.js} +4 -4
  389. package/dist/state/definition.js.map +1 -0
  390. package/dist/state/history-state.d.ts.map +1 -0
  391. package/dist/{history-state.js → state/history-state.js} +1 -0
  392. package/dist/state/history-state.js.map +1 -0
  393. package/dist/state/runtime-state.d.ts.map +1 -0
  394. package/dist/state/runtime-state.js.map +1 -0
  395. package/dist/state/starter.d.ts.map +1 -0
  396. package/dist/state/starter.js.map +1 -0
  397. package/dist/state/state-portability.d.ts.map +1 -0
  398. package/dist/state/state-portability.js.map +1 -0
  399. package/dist/state/versions.d.ts.map +1 -0
  400. package/dist/state/versions.js.map +1 -0
  401. package/dist/{workspace-state.d.ts → state/workspace-state.d.ts} +8 -5
  402. package/dist/state/workspace-state.d.ts.map +1 -0
  403. package/dist/{workspace-state.js → state/workspace-state.js} +25 -1
  404. package/dist/state/workspace-state.js.map +1 -0
  405. package/dist/{documents.d.ts → text/documents.d.ts} +1 -1
  406. package/dist/text/documents.d.ts.map +1 -0
  407. package/dist/{documents.js → text/documents.js} +1 -1
  408. package/dist/text/documents.js.map +1 -0
  409. package/dist/text/embed.d.ts.map +1 -0
  410. package/dist/text/embed.js.map +1 -0
  411. package/dist/text/mentions.d.ts.map +1 -0
  412. package/dist/text/mentions.js.map +1 -0
  413. package/dist/text/model-answer.d.ts +3 -0
  414. package/dist/text/model-answer.d.ts.map +1 -0
  415. package/dist/text/model-answer.js +3 -0
  416. package/dist/text/model-answer.js.map +1 -0
  417. package/dist/text/path-refs.d.ts.map +1 -0
  418. package/dist/text/path-refs.js.map +1 -0
  419. package/dist/{shell-regions.d.ts → text/shell-regions.d.ts} +1 -1
  420. package/dist/text/shell-regions.d.ts.map +1 -0
  421. package/dist/text/shell-regions.js.map +1 -0
  422. package/dist/text/title.d.ts.map +1 -0
  423. package/dist/text/title.js.map +1 -0
  424. package/dist/{transcript-fold.d.ts → text/transcript-fold.d.ts} +2 -1
  425. package/dist/text/transcript-fold.d.ts.map +1 -0
  426. package/dist/{transcript-fold.js → text/transcript-fold.js} +2 -16
  427. package/dist/text/transcript-fold.js.map +1 -0
  428. package/dist/text/whisper.d.ts +3 -0
  429. package/dist/text/whisper.d.ts.map +1 -0
  430. package/dist/text/whisper.js +11 -0
  431. package/dist/text/whisper.js.map +1 -0
  432. package/dist/{workflow-faults.d.ts → text/workflow-faults.d.ts} +1 -1
  433. package/dist/text/workflow-faults.d.ts.map +1 -0
  434. package/dist/{workflow-faults.js → text/workflow-faults.js} +1 -1
  435. package/dist/text/workflow-faults.js.map +1 -0
  436. package/package.json +70 -70
  437. package/src/chores/chores.test.ts +4 -10
  438. package/src/chores/chores.ts +148 -392
  439. package/src/chores/digest.ts +8 -28
  440. package/src/chores/extension-update.ts +3 -8
  441. package/src/chores/fix-deps.ts +4 -18
  442. package/src/chores/index.ts +2 -2
  443. package/src/chores/probes.test.ts +7 -43
  444. package/src/chores/probes.ts +62 -167
  445. package/src/chores/prompt.ts +10 -34
  446. package/src/chores/stack.test.ts +6 -45
  447. package/src/chores/stack.ts +27 -118
  448. package/src/chores/verdict.test.ts +101 -80
  449. package/src/chores/verdict.ts +54 -99
  450. package/src/contracts/accounts.contract.ts +4 -19
  451. package/src/contracts/agent.contract.ts +7 -22
  452. package/src/contracts/agents.contract.ts +25 -71
  453. package/src/contracts/automations.contract.ts +14 -30
  454. package/src/contracts/capabilities.contract.ts +8 -35
  455. package/src/contracts/chores.contract.ts +4 -15
  456. package/src/contracts/endpoints.contract.ts +5 -22
  457. package/src/contracts/exit.contract.ts +7 -30
  458. package/src/contracts/extensions.contract.ts +8 -30
  459. package/src/contracts/git.contract.ts +25 -49
  460. package/src/contracts/host.contract.ts +9 -44
  461. package/src/contracts/intentic.contract.ts +1 -1
  462. package/src/contracts/logs.contract.ts +3 -13
  463. package/src/contracts/loops.contract.ts +9 -40
  464. package/src/contracts/personas.contract.ts +22 -30
  465. package/src/contracts/providers.contract.ts +4 -17
  466. package/src/contracts/runner.contract.ts +12 -39
  467. package/src/contracts/safety.contract.ts +5 -14
  468. package/src/contracts/secrets.contract.ts +4 -22
  469. package/src/contracts/sessions.contract.ts +1 -1
  470. package/src/contracts/settings.contract.ts +4 -10
  471. package/src/contracts/share.contract.ts +3 -9
  472. package/src/contracts/skills.contract.ts +4 -15
  473. package/src/contracts/system.contract.ts +26 -52
  474. package/src/contracts/usage.contract.ts +7 -21
  475. package/src/contracts/vpn.contract.ts +9 -16
  476. package/src/contracts/webext.contract.ts +9 -25
  477. package/src/contracts/workflows.contract.ts +34 -58
  478. package/src/contracts/workspace.contract.ts +19 -50
  479. package/src/events/agent-events.ts +345 -0
  480. package/src/events/cards.ts +286 -0
  481. package/src/{events.test.ts → events/resume.test.ts} +4 -19
  482. package/src/events/resume.ts +60 -0
  483. package/src/events/system-events.ts +139 -0
  484. package/src/events/transcript.ts +320 -0
  485. package/src/{conversation-ids.test.ts → ids/conversation-ids.test.ts} +25 -13
  486. package/src/ids/conversation-ids.ts +178 -0
  487. package/src/ids/hostnames.ts +129 -0
  488. package/src/ids/session-names.ts +29 -0
  489. package/src/ids/share-paths.ts +43 -0
  490. package/src/{tunnel-ids.test.ts → ids/tunnel-ids.test.ts} +1 -14
  491. package/src/ids/tunnel-ids.ts +29 -0
  492. package/src/index.ts +71 -88
  493. package/src/{agent-catalog.test.ts → models/agent-catalog.test.ts} +19 -93
  494. package/src/models/agent-catalog.ts +174 -0
  495. package/src/models/agent-runtimes.ts +201 -0
  496. package/src/models/capability-ledger.test.ts +84 -0
  497. package/src/{fast-tier.test.ts → models/fast-tier.test.ts} +7 -18
  498. package/src/models/fast-tier.ts +36 -0
  499. package/src/{model-order.test.ts → models/model-order.test.ts} +19 -40
  500. package/src/models/model-order.ts +163 -0
  501. package/src/models/model-pins.test.ts +87 -0
  502. package/src/models/model-pins.ts +57 -0
  503. package/src/models/model-roles.test.ts +38 -0
  504. package/src/models/model-roles.ts +180 -0
  505. package/src/{plan-pools.test.ts → models/plan-pools.test.ts} +6 -11
  506. package/src/models/plan-pools.ts +65 -0
  507. package/src/{prompt-complexity.test.ts → models/prompt-complexity.test.ts} +8 -60
  508. package/src/models/prompt-complexity.ts +215 -0
  509. package/src/{provider-specs.test.ts → models/provider-specs.test.ts} +18 -47
  510. package/src/models/provider-specs.ts +272 -0
  511. package/src/policy/approvals-execution.ts +58 -0
  512. package/src/{batch-runs.test.ts → policy/batch-runs.test.ts} +4 -20
  513. package/src/policy/batch-runs.ts +137 -0
  514. package/src/policy/capability-secrets.ts +5 -0
  515. package/src/{card-status.ts → policy/card-status.ts} +11 -26
  516. package/src/{command-classes.test.ts → policy/command-classes.test.ts} +11 -118
  517. package/src/policy/command-classes.ts +395 -0
  518. package/src/policy/command-run.ts +65 -0
  519. package/src/policy/control-scopes.ts +38 -0
  520. package/src/{credential-material.test.ts → policy/credential-material.test.ts} +4 -26
  521. package/src/policy/credential-material.ts +91 -0
  522. package/src/policy/needs-action.ts +5 -0
  523. package/src/policy/output-fields.ts +86 -0
  524. package/src/policy/overlay-lint.ts +100 -0
  525. package/src/{owner-ticket.test.ts → policy/owner-ticket.test.ts} +1 -1
  526. package/src/{owner-ticket.ts → policy/owner-ticket.ts} +9 -31
  527. package/src/policy/safety-policy.test.ts +84 -0
  528. package/src/policy/safety-policy.ts +142 -0
  529. package/src/policy/search-globs.ts +60 -0
  530. package/src/protocol/container-requirements.test.ts +72 -0
  531. package/src/protocol/container-requirements.ts +58 -0
  532. package/src/protocol/host-protocol.ts +29 -0
  533. package/src/protocol/ingress-contract.ts +103 -0
  534. package/src/{ingress-protocol.test.ts → protocol/ingress-protocol.test.ts} +25 -90
  535. package/src/protocol/ingress-protocol.ts +441 -0
  536. package/src/protocol/listener-protocol.ts +75 -0
  537. package/src/{peer-dial.test.ts → protocol/peer-dial.test.ts} +52 -1
  538. package/src/protocol/peer-dial.ts +207 -0
  539. package/src/{peer-mcp-server.ts → protocol/peer-mcp-server.ts} +16 -41
  540. package/src/protocol/request-id.ts +5 -0
  541. package/src/{routes.test.ts → protocol/routes.test.ts} +14 -22
  542. package/src/protocol/routes.ts +159 -0
  543. package/src/protocol/runner-protocol.ts +197 -0
  544. package/src/protocol/terminal-protocol.ts +13 -0
  545. package/src/protocol/webext-links.ts +50 -0
  546. package/src/protocol/webext-protocol.ts +24 -0
  547. package/src/schemas/activity.ts +22 -30
  548. package/src/schemas/agent.ts +130 -238
  549. package/src/schemas/agents.ts +165 -483
  550. package/src/schemas/approvals.ts +23 -71
  551. package/src/schemas/automations.ts +145 -249
  552. package/src/schemas/capabilities.ts +127 -414
  553. package/src/schemas/ci.ts +56 -108
  554. package/src/schemas/codebase-health.ts +7 -11
  555. package/src/schemas/devices.ts +98 -321
  556. package/src/schemas/engines.ts +16 -44
  557. package/src/schemas/environment.ts +41 -91
  558. package/src/schemas/exit.ts +24 -81
  559. package/src/schemas/extension-updates.ts +42 -87
  560. package/src/schemas/git-history.ts +30 -84
  561. package/src/schemas/git.ts +141 -256
  562. package/src/schemas/history.ts +14 -40
  563. package/src/schemas/hosts.ts +9 -15
  564. package/src/schemas/inventory.ts +8 -10
  565. package/src/schemas/issues.ts +66 -134
  566. package/src/schemas/logs.ts +15 -34
  567. package/src/schemas/loops.ts +46 -163
  568. package/src/schemas/maintenance.ts +47 -172
  569. package/src/schemas/panels.ts +20 -45
  570. package/src/schemas/personas.ts +85 -168
  571. package/src/schemas/plan-limits.ts +58 -197
  572. package/src/schemas/ports.ts +14 -32
  573. package/src/schemas/provider-oauth.ts +23 -76
  574. package/src/schemas/provider-subscriptions.ts +4 -13
  575. package/src/schemas/public.ts +4 -15
  576. package/src/schemas/push.ts +8 -36
  577. package/src/schemas/secrets.ts +20 -64
  578. package/src/schemas/settings.ts +177 -597
  579. package/src/schemas/share.ts +14 -32
  580. package/src/schemas/shared.ts +14 -13
  581. package/src/schemas/system.ts +46 -78
  582. package/src/schemas/terminal.ts +41 -120
  583. package/src/schemas/usage.ts +44 -233
  584. package/src/schemas/version-seam.test.ts +9 -26
  585. package/src/schemas/vpn.ts +27 -64
  586. package/src/schemas/webext.ts +22 -53
  587. package/src/schemas/workflows.ts +57 -183
  588. package/src/schemas/workspace-repos.ts +12 -24
  589. package/src/schemas/workspace-search.ts +17 -35
  590. package/src/schemas/workspace-setup.ts +4 -11
  591. package/src/schemas/workspace-tree.ts +32 -91
  592. package/src/state/arrival.ts +109 -0
  593. package/src/state/contract-lock.test.ts +17 -0
  594. package/src/state/contract-lock.ts +49 -0
  595. package/src/state/definition.ts +143 -0
  596. package/src/state/history-state.ts +103 -0
  597. package/src/{runtime-state.test.ts → state/runtime-state.test.ts} +3 -10
  598. package/src/state/runtime-state.ts +62 -0
  599. package/src/state/starter.ts +5 -0
  600. package/src/state/state-portability.ts +27 -0
  601. package/src/state/versions.ts +26 -0
  602. package/src/{workspace-state.test.ts → state/workspace-state.test.ts} +65 -173
  603. package/src/state/workspace-state.ts +669 -0
  604. package/src/{documents.test.ts → text/documents.test.ts} +1 -1
  605. package/src/text/documents.ts +42 -0
  606. package/src/text/embed.ts +132 -0
  607. package/src/text/mentions.ts +21 -0
  608. package/src/text/model-answer.ts +9 -0
  609. package/src/text/path-refs.ts +39 -0
  610. package/src/text/shell-regions.ts +224 -0
  611. package/src/{title.test.ts → text/title.test.ts} +13 -32
  612. package/src/text/title.ts +202 -0
  613. package/src/{transcript-fold.test.ts → text/transcript-fold.test.ts} +5 -83
  614. package/src/{transcript-fold.ts → text/transcript-fold.ts} +65 -170
  615. package/src/text/whisper.test.ts +19 -0
  616. package/src/text/whisper.ts +17 -0
  617. package/src/{workflow-faults.test.ts → text/workflow-faults.test.ts} +6 -24
  618. package/src/{workflow-faults.ts → text/workflow-faults.ts} +20 -60
  619. package/dist/agent-catalog.d.ts.map +0 -1
  620. package/dist/agent-catalog.js.map +0 -1
  621. package/dist/agent-runtimes.d.ts.map +0 -1
  622. package/dist/agent-runtimes.js.map +0 -1
  623. package/dist/approvals-execution.d.ts.map +0 -1
  624. package/dist/approvals-execution.js.map +0 -1
  625. package/dist/arrival.d.ts.map +0 -1
  626. package/dist/arrival.js.map +0 -1
  627. package/dist/batch-runs.d.ts.map +0 -1
  628. package/dist/batch-runs.js.map +0 -1
  629. package/dist/capability-env.d.ts.map +0 -1
  630. package/dist/capability-env.js.map +0 -1
  631. package/dist/capability-secrets.d.ts.map +0 -1
  632. package/dist/capability-secrets.js.map +0 -1
  633. package/dist/card-status.d.ts.map +0 -1
  634. package/dist/card-status.js.map +0 -1
  635. package/dist/command-classes.d.ts.map +0 -1
  636. package/dist/command-classes.js.map +0 -1
  637. package/dist/command-run.d.ts.map +0 -1
  638. package/dist/command-run.js.map +0 -1
  639. package/dist/contract-lock.d.ts.map +0 -1
  640. package/dist/contract-lock.js.map +0 -1
  641. package/dist/conversation-ids.d.ts +0 -4
  642. package/dist/conversation-ids.d.ts.map +0 -1
  643. package/dist/conversation-ids.js.map +0 -1
  644. package/dist/credential-material.d.ts.map +0 -1
  645. package/dist/credential-material.js.map +0 -1
  646. package/dist/definition.d.ts.map +0 -1
  647. package/dist/definition.js.map +0 -1
  648. package/dist/documents.d.ts.map +0 -1
  649. package/dist/documents.js.map +0 -1
  650. package/dist/embed.d.ts.map +0 -1
  651. package/dist/embed.js.map +0 -1
  652. package/dist/events.d.ts +0 -4336
  653. package/dist/events.d.ts.map +0 -1
  654. package/dist/events.js +0 -725
  655. package/dist/events.js.map +0 -1
  656. package/dist/fast-tier.d.ts.map +0 -1
  657. package/dist/fast-tier.js.map +0 -1
  658. package/dist/history-state.d.ts.map +0 -1
  659. package/dist/history-state.js.map +0 -1
  660. package/dist/host-protocol.d.ts.map +0 -1
  661. package/dist/host-protocol.js.map +0 -1
  662. package/dist/hostnames.d.ts.map +0 -1
  663. package/dist/hostnames.js.map +0 -1
  664. package/dist/ingress-contract.d.ts.map +0 -1
  665. package/dist/ingress-contract.js.map +0 -1
  666. package/dist/ingress-protocol.d.ts.map +0 -1
  667. package/dist/ingress-protocol.js.map +0 -1
  668. package/dist/listener-protocol.d.ts.map +0 -1
  669. package/dist/listener-protocol.js.map +0 -1
  670. package/dist/mentions.d.ts.map +0 -1
  671. package/dist/mentions.js.map +0 -1
  672. package/dist/model-order.d.ts.map +0 -1
  673. package/dist/model-order.js.map +0 -1
  674. package/dist/model-pins.d.ts.map +0 -1
  675. package/dist/model-pins.js +0 -45
  676. package/dist/model-pins.js.map +0 -1
  677. package/dist/model-roles.d.ts.map +0 -1
  678. package/dist/model-roles.js.map +0 -1
  679. package/dist/needs-action.d.ts.map +0 -1
  680. package/dist/needs-action.js.map +0 -1
  681. package/dist/output-fields.d.ts.map +0 -1
  682. package/dist/output-fields.js.map +0 -1
  683. package/dist/overlay-lint.d.ts.map +0 -1
  684. package/dist/overlay-lint.js.map +0 -1
  685. package/dist/owner-ticket.d.ts.map +0 -1
  686. package/dist/owner-ticket.js.map +0 -1
  687. package/dist/path-refs.d.ts.map +0 -1
  688. package/dist/path-refs.js.map +0 -1
  689. package/dist/peer-dial.d.ts.map +0 -1
  690. package/dist/peer-dial.js.map +0 -1
  691. package/dist/peer-mcp-server.d.ts.map +0 -1
  692. package/dist/peer-mcp-server.js.map +0 -1
  693. package/dist/plan-pools.d.ts.map +0 -1
  694. package/dist/plan-pools.js.map +0 -1
  695. package/dist/prompt-complexity.d.ts.map +0 -1
  696. package/dist/prompt-complexity.js.map +0 -1
  697. package/dist/provider-specs.d.ts.map +0 -1
  698. package/dist/provider-specs.js.map +0 -1
  699. package/dist/request-id.d.ts.map +0 -1
  700. package/dist/request-id.js.map +0 -1
  701. package/dist/routes.d.ts.map +0 -1
  702. package/dist/routes.js.map +0 -1
  703. package/dist/runner-protocol.d.ts.map +0 -1
  704. package/dist/runner-protocol.js.map +0 -1
  705. package/dist/runtime-state.d.ts.map +0 -1
  706. package/dist/runtime-state.js.map +0 -1
  707. package/dist/safety-policy.d.ts.map +0 -1
  708. package/dist/safety-policy.js.map +0 -1
  709. package/dist/schemas/context.d.ts +0 -30
  710. package/dist/schemas/context.d.ts.map +0 -1
  711. package/dist/schemas/context.js +0 -34
  712. package/dist/schemas/context.js.map +0 -1
  713. package/dist/search-globs.d.ts.map +0 -1
  714. package/dist/search-globs.js.map +0 -1
  715. package/dist/session-names.d.ts.map +0 -1
  716. package/dist/session-names.js.map +0 -1
  717. package/dist/share-paths.d.ts.map +0 -1
  718. package/dist/share-paths.js.map +0 -1
  719. package/dist/shell-regions.d.ts.map +0 -1
  720. package/dist/shell-regions.js.map +0 -1
  721. package/dist/sse.d.ts.map +0 -1
  722. package/dist/sse.js.map +0 -1
  723. package/dist/starter.d.ts.map +0 -1
  724. package/dist/starter.js.map +0 -1
  725. package/dist/state-portability.d.ts.map +0 -1
  726. package/dist/state-portability.js.map +0 -1
  727. package/dist/terminal-protocol.d.ts.map +0 -1
  728. package/dist/terminal-protocol.js.map +0 -1
  729. package/dist/title.d.ts.map +0 -1
  730. package/dist/title.js.map +0 -1
  731. package/dist/transcript-fold.d.ts.map +0 -1
  732. package/dist/transcript-fold.js.map +0 -1
  733. package/dist/tunnel-ids.d.ts.map +0 -1
  734. package/dist/tunnel-ids.js.map +0 -1
  735. package/dist/versions.d.ts.map +0 -1
  736. package/dist/versions.js.map +0 -1
  737. package/dist/webext-links.d.ts.map +0 -1
  738. package/dist/webext-links.js.map +0 -1
  739. package/dist/webext-protocol.d.ts.map +0 -1
  740. package/dist/webext-protocol.js.map +0 -1
  741. package/dist/workflow-faults.d.ts.map +0 -1
  742. package/dist/workflow-faults.js.map +0 -1
  743. package/dist/workspace-state.d.ts.map +0 -1
  744. package/dist/workspace-state.js.map +0 -1
  745. package/src/agent-catalog.ts +0 -316
  746. package/src/agent-runtimes.ts +0 -419
  747. package/src/approvals-execution.ts +0 -96
  748. package/src/arrival.ts +0 -160
  749. package/src/batch-runs.ts +0 -188
  750. package/src/capability-ledger.test.ts +0 -140
  751. package/src/capability-secrets.ts +0 -20
  752. package/src/command-classes.ts +0 -617
  753. package/src/command-run.ts +0 -78
  754. package/src/contract-lock.test.ts +0 -23
  755. package/src/contract-lock.ts +0 -66
  756. package/src/conversation-ids.ts +0 -207
  757. package/src/credential-material.ts +0 -181
  758. package/src/definition.ts +0 -207
  759. package/src/documents.ts +0 -67
  760. package/src/embed.ts +0 -164
  761. package/src/events.ts +0 -1870
  762. package/src/fast-tier.ts +0 -72
  763. package/src/history-state.ts +0 -174
  764. package/src/host-protocol.ts +0 -36
  765. package/src/hostnames.ts +0 -180
  766. package/src/ingress-contract.ts +0 -157
  767. package/src/ingress-protocol.ts +0 -625
  768. package/src/listener-protocol.ts +0 -96
  769. package/src/mentions.ts +0 -25
  770. package/src/model-order.ts +0 -262
  771. package/src/model-pins.test.ts +0 -202
  772. package/src/model-pins.ts +0 -183
  773. package/src/model-roles.ts +0 -224
  774. package/src/needs-action.ts +0 -14
  775. package/src/output-fields.ts +0 -111
  776. package/src/overlay-lint.ts +0 -116
  777. package/src/path-refs.ts +0 -59
  778. package/src/peer-dial.ts +0 -163
  779. package/src/plan-pools.ts +0 -92
  780. package/src/prompt-complexity.ts +0 -334
  781. package/src/provider-specs.ts +0 -432
  782. package/src/request-id.ts +0 -41
  783. package/src/routes.ts +0 -219
  784. package/src/runner-protocol.ts +0 -239
  785. package/src/runtime-state.ts +0 -140
  786. package/src/safety-policy.test.ts +0 -88
  787. package/src/safety-policy.ts +0 -258
  788. package/src/schemas/context.ts +0 -87
  789. package/src/search-globs.ts +0 -76
  790. package/src/session-names.ts +0 -44
  791. package/src/share-paths.ts +0 -68
  792. package/src/shell-regions.ts +0 -289
  793. package/src/starter.ts +0 -13
  794. package/src/state-portability.ts +0 -56
  795. package/src/terminal-protocol.ts +0 -16
  796. package/src/title.ts +0 -267
  797. package/src/tunnel-ids.ts +0 -57
  798. package/src/versions.ts +0 -48
  799. package/src/webext-links.ts +0 -90
  800. package/src/webext-protocol.ts +0 -27
  801. package/src/workspace-state.ts +0 -1096
  802. /package/dist/{hostnames.d.ts → ids/hostnames.d.ts} +0 -0
  803. /package/dist/{hostnames.js → ids/hostnames.js} +0 -0
  804. /package/dist/{session-names.d.ts → ids/session-names.d.ts} +0 -0
  805. /package/dist/{session-names.js → ids/session-names.js} +0 -0
  806. /package/dist/{share-paths.d.ts → ids/share-paths.d.ts} +0 -0
  807. /package/dist/{share-paths.js → ids/share-paths.js} +0 -0
  808. /package/dist/{agent-catalog.js → models/agent-catalog.js} +0 -0
  809. /package/dist/{agent-runtimes.d.ts → models/agent-runtimes.d.ts} +0 -0
  810. /package/dist/{agent-runtimes.js → models/agent-runtimes.js} +0 -0
  811. /package/dist/{fast-tier.js → models/fast-tier.js} +0 -0
  812. /package/dist/{model-order.d.ts → models/model-order.d.ts} +0 -0
  813. /package/dist/{model-order.js → models/model-order.js} +0 -0
  814. /package/dist/{plan-pools.js → models/plan-pools.js} +0 -0
  815. /package/dist/{prompt-complexity.d.ts → models/prompt-complexity.d.ts} +0 -0
  816. /package/dist/{prompt-complexity.js → models/prompt-complexity.js} +0 -0
  817. /package/dist/{provider-specs.d.ts → models/provider-specs.d.ts} +0 -0
  818. /package/dist/{provider-specs.js → models/provider-specs.js} +0 -0
  819. /package/dist/{approvals-execution.d.ts → policy/approvals-execution.d.ts} +0 -0
  820. /package/dist/{approvals-execution.js → policy/approvals-execution.js} +0 -0
  821. /package/dist/{capability-env.d.ts → policy/capability-env.d.ts} +0 -0
  822. /package/dist/{capability-env.js → policy/capability-env.js} +0 -0
  823. /package/dist/{capability-secrets.d.ts → policy/capability-secrets.d.ts} +0 -0
  824. /package/dist/{capability-secrets.js → policy/capability-secrets.js} +0 -0
  825. /package/dist/{command-run.js → policy/command-run.js} +0 -0
  826. /package/dist/{credential-material.d.ts → policy/credential-material.d.ts} +0 -0
  827. /package/dist/{credential-material.js → policy/credential-material.js} +0 -0
  828. /package/dist/{needs-action.d.ts → policy/needs-action.d.ts} +0 -0
  829. /package/dist/{needs-action.js → policy/needs-action.js} +0 -0
  830. /package/dist/{output-fields.d.ts → policy/output-fields.d.ts} +0 -0
  831. /package/dist/{output-fields.js → policy/output-fields.js} +0 -0
  832. /package/dist/{overlay-lint.d.ts → policy/overlay-lint.d.ts} +0 -0
  833. /package/dist/{overlay-lint.js → policy/overlay-lint.js} +0 -0
  834. /package/dist/{owner-ticket.d.ts → policy/owner-ticket.d.ts} +0 -0
  835. /package/dist/{search-globs.d.ts → policy/search-globs.d.ts} +0 -0
  836. /package/dist/{search-globs.js → policy/search-globs.js} +0 -0
  837. /package/dist/{ingress-contract.d.ts → protocol/ingress-contract.d.ts} +0 -0
  838. /package/dist/{ingress-protocol.d.ts → protocol/ingress-protocol.d.ts} +0 -0
  839. /package/dist/{ingress-protocol.js → protocol/ingress-protocol.js} +0 -0
  840. /package/dist/{listener-protocol.d.ts → protocol/listener-protocol.d.ts} +0 -0
  841. /package/dist/{peer-mcp-server.d.ts → protocol/peer-mcp-server.d.ts} +0 -0
  842. /package/dist/{peer-mcp-server.js → protocol/peer-mcp-server.js} +0 -0
  843. /package/dist/{request-id.d.ts → protocol/request-id.d.ts} +0 -0
  844. /package/dist/{request-id.js → protocol/request-id.js} +0 -0
  845. /package/dist/{routes.d.ts → protocol/routes.d.ts} +0 -0
  846. /package/dist/{routes.js → protocol/routes.js} +0 -0
  847. /package/dist/{sse.d.ts → protocol/sse.d.ts} +0 -0
  848. /package/dist/{sse.js → protocol/sse.js} +0 -0
  849. /package/dist/{terminal-protocol.js → protocol/terminal-protocol.js} +0 -0
  850. /package/dist/{webext-links.d.ts → protocol/webext-links.d.ts} +0 -0
  851. /package/dist/{webext-links.js → protocol/webext-links.js} +0 -0
  852. /package/dist/{arrival.d.ts → state/arrival.d.ts} +0 -0
  853. /package/dist/{contract-lock.d.ts → state/contract-lock.d.ts} +0 -0
  854. /package/dist/{history-state.d.ts → state/history-state.d.ts} +0 -0
  855. /package/dist/{runtime-state.d.ts → state/runtime-state.d.ts} +0 -0
  856. /package/dist/{runtime-state.js → state/runtime-state.js} +0 -0
  857. /package/dist/{starter.d.ts → state/starter.d.ts} +0 -0
  858. /package/dist/{starter.js → state/starter.js} +0 -0
  859. /package/dist/{state-portability.d.ts → state/state-portability.d.ts} +0 -0
  860. /package/dist/{state-portability.js → state/state-portability.js} +0 -0
  861. /package/dist/{versions.d.ts → state/versions.d.ts} +0 -0
  862. /package/dist/{versions.js → state/versions.js} +0 -0
  863. /package/dist/{embed.d.ts → text/embed.d.ts} +0 -0
  864. /package/dist/{embed.js → text/embed.js} +0 -0
  865. /package/dist/{mentions.d.ts → text/mentions.d.ts} +0 -0
  866. /package/dist/{mentions.js → text/mentions.js} +0 -0
  867. /package/dist/{path-refs.d.ts → text/path-refs.d.ts} +0 -0
  868. /package/dist/{path-refs.js → text/path-refs.js} +0 -0
  869. /package/dist/{shell-regions.js → text/shell-regions.js} +0 -0
  870. /package/dist/{title.d.ts → text/title.d.ts} +0 -0
  871. /package/dist/{title.js → text/title.js} +0 -0
  872. /package/src/{hostnames.test.ts → ids/hostnames.test.ts} +0 -0
  873. /package/src/{share-paths.test.ts → ids/share-paths.test.ts} +0 -0
  874. /package/src/{capability-env.ts → policy/capability-env.ts} +0 -0
  875. /package/src/{overlay-lint.test.ts → policy/overlay-lint.test.ts} +0 -0
  876. /package/src/{search-globs.test.ts → policy/search-globs.test.ts} +0 -0
  877. /package/src/{ingress-contract.test.ts → protocol/ingress-contract.test.ts} +0 -0
  878. /package/src/{peer-mcp-server.test.ts → protocol/peer-mcp-server.test.ts} +0 -0
  879. /package/src/{sse.ts → protocol/sse.ts} +0 -0
  880. /package/src/{versions.test.ts → state/versions.test.ts} +0 -0
  881. /package/src/{embed.test.ts → text/embed.test.ts} +0 -0
  882. /package/src/{mentions.test.ts → text/mentions.test.ts} +0 -0
  883. /package/src/{path-refs.test.ts → text/path-refs.test.ts} +0 -0
package/src/path-refs.ts DELETED
@@ -1,59 +0,0 @@
1
- /* Which file a NAMED reference means. A path written in prose is only loosely anchored to the workspace: an
2
- * agent that has been working in `_editor/web/src` writes `pages/workspace/Foo.vue`, and a turn running in an
3
- * isolated worktree prints `/history/worktrees/<id>/_editor/web/src/foo.ts`, neither is the workspace-relative
4
- * path the file routes speak, but both END in it.
5
- *
6
- * So a reference is resolved by matching progressively shorter TAILS of it against the real tree. The rules
7
- * live here, in the contract package, because both sides run them: the browser first against the workspace
8
- * tree it already has cached, then the daemon (/workspace/resolve) against the iq engine's full sweep, which
9
- * sees the files the capped tree walk left out. Two matchers that disagreed would make a link's destination
10
- * depend on which one answered. */
11
-
12
- // How many leading segments a reference may carry that the workspace doesn't (the `/history/worktrees/<id>/`
13
- // lead of a worktree path is 3; a foreign absolute root is rarely deeper).
14
- const MAX_DROPS = 6;
15
- // A tail is never cut down to a bare filename: `index.ts` names a hundred files in a monorepo and picking one
16
- // at random is worse than not linking. The link grammar never emits a slash-less reference either.
17
- const MIN_SEGMENTS = 2;
18
- // Enough candidates for a picker; a reference matching more than this is ambiguous by any measure.
19
- export const MAX_REF_CANDIDATES = 10;
20
-
21
- // The tails worth matching, longest (most specific) first. `root` is the container workspace root: a path
22
- // under it is already the answer minus that lead, and a path under any OTHER absolute root (a worktree) still
23
- // mirrors the layout below its own lead, which the successive drops strip.
24
- export const referenceTails = (raw: string, root: string): readonly string[] => {
25
- const normalized = raw.replaceAll(`\\`, `/`).replace(/^\.\//, ``);
26
- const anchored = normalized.startsWith(`${root}/`) ? normalized.slice(root.length + 1) : normalized.replace(/^\/+/, ``);
27
- const segments = anchored.split(`/`).filter((segment) => segment !== `` && segment !== `.`);
28
- const tails: string[] = [];
29
- for (let drop = 0; drop <= MAX_DROPS && segments.length - drop >= MIN_SEGMENTS; drop++) {
30
- tails.push(segments.slice(drop).join(`/`));
31
- }
32
- return tails;
33
- };
34
-
35
- // The paths that genuinely END in `tail` on a segment boundary, best first, the shared ranking both matchers
36
- // return their candidates in. Shallowest wins: `pages/Foo.vue` means the app's page, not the copy six
37
- // directories down in a fixture tree. (The daemon's glob is anchored only at the string level, `**/pages/x.vue`
38
- // also matches `mypages/x.vue`, so the boundary is enforced here rather than by the pattern.)
39
- export const rankRefCandidates = (tail: string, paths: readonly string[]): readonly string[] =>
40
- paths
41
- .filter((path) => path === tail || path.endsWith(`/${tail}`))
42
- .toSorted((a, b) => a.split(`/`).length - b.split(`/`).length || a.length - b.length || (a < b ? -1 : 1))
43
- .slice(0, MAX_REF_CANDIDATES);
44
-
45
- /* IS THIS FILE TEST CODE, the one classification rule for every surface that splits a diff into "the
46
- * change" and "the proof". The agent review header answers "how much of this is tests?" with it; anything
47
- * else that wants the split (fleet cards, commit summaries) must use this same predicate, because two
48
- * classifiers that disagree turn the readout into a lie the user can't detect.
49
- *
50
- * Convention-based, matching what this monorepo (and the ecosystems it scaffolds) actually writes: a
51
- * `.test.` / `.spec.` filename in any extension, a `__tests__` / `__fixtures__` directory anywhere on the
52
- * path, an `e2e-harness`, or a test-runner config. Deliberately NOT "anything containing 'test'": a
53
- * `testimonials/` page or a `latest.ts` is product code, and a false "tests" tag is worse than a missed one,
54
- * it tells a reviewer not to look. */
55
- const TEST_DIRS = new Set([`__tests__`, `__fixtures__`, `__mocks__`, `__snapshots__`]);
56
- const TEST_FILE =
57
- /(?:^|\/)(?:[^/]+\.(?:test|spec)\.[^/.]+|[^/]*\.e2e\.[^/]+|e2e-harness\.[^/]+|(?:vitest|jest|playwright)(?:\.[\w-]+)*\.config\.[^/]+)$/;
58
-
59
- export const isTestPath = (path: string): boolean => TEST_FILE.test(path) || path.split(`/`).some((segment) => TEST_DIRS.has(segment));
package/src/peer-dial.ts DELETED
@@ -1,163 +0,0 @@
1
- /* THE ONE SOCKET a peer holds to its sandbox, written once for the three things that hold one: the machine
2
- * agent (@intentic/machine), the browser extension (@intentic/webext) and a runner (the daemon itself, in
3
- * runner mode). Each dials OUT, sends a plain-JSON hello carrying its enrollment token (host-protocol.ts,
4
- * webext-protocol.ts, runner-protocol.ts), and from then on everything the sandbox asks arrives on the socket
5
- * as oRPC against the door's contract, with the PEER serving.
6
- *
7
- * OUTBOUND ONLY, and that is the entire networking story: no port is opened, no router configured, no VPN
8
- * joined. A laptop on hotel wifi behind a corporate proxy holds this connection because it is an ordinary
9
- * outbound wss://, the same thing every chat app on the machine is already doing.
10
- *
11
- * The socket has exactly two phases. First the hello, plain JSON, because the sandbox has nothing to call until
12
- * it knows whose socket this is (the token rides the FRAME, never the URL, which would write a durable key into
13
- * every proxy log between the peer and the sandbox). Then the sandbox attaches its client and the socket is pure
14
- * oRPC: request/response correlation, argument validation and error shape all belong to the link from that
15
- * point on, which is why there is no message plumbing here.
16
- *
17
- * THE HANDLER IS ATTACHED BEFORE THE HELLO GOES OUT: the sandbox may call the moment it has verified the token,
18
- * and a race there would drop the first `setScopes`, the one call whose loss would leave a device enforcing a
19
- * stale grant.
20
- *
21
- * RECONNECTION IS THE NORMAL CASE, not the failure case. Lids close, wifi changes, tunnels idle out, sandboxes
22
- * restart on every rebuild. So a dropped socket is routine and comes back on an exponential ladder the caller
23
- * supplies (@intentic/base's createBackoff, over PEER_LINK_BACKOFF): a link that held for a minute was working
24
- * and its drop redials at the floor; one that opened and died at once keeps climbing. The one thing that is NOT
25
- * retried is a refused enrollment (close code 1008): the owner revoked this peer, that never heals on its own,
26
- * and hammering a door that has been locked is how an agent turns a revocation into a support ticket.
27
- *
28
- * Here, in the contract, beside the hello schemas it sends and the URL builders it dials, rather than in a
29
- * package of its own: every peer already depends on this one, and the loop is the far end of the same wire. */
30
-
31
- // Backoff bounds. The first retry is fast because the overwhelmingly common cause is a sandbox restart, which
32
- // takes seconds; the ceiling is low enough that a laptop opened after a night asleep is back within a minute.
33
- export const PEER_LINK_BACKOFF = { floorMs: 1_000, capMs: 30_000, stableMs: 60_000 } as const;
34
-
35
- // The sandbox closes with this when the token is not enrolled: a decision, not a fault, and one that never heals.
36
- const UNAUTHORIZED = 1008;
37
-
38
- // A socket's readyState value for "open", per the WebSocket spec, named so a caller's fake need not import a class.
39
- const OPEN = 1;
40
-
41
- // What the two runtimes' sockets have in common, taken structurally: a browser's WebSocket, node's global one,
42
- // and a test's fake all satisfy it without a cast.
43
- export interface SocketLike {
44
- readonly readyState: number;
45
- addEventListener(type: "open" | "close" | "error", listener: (event: { readonly code?: number }) => void): void;
46
- send(data: string): void;
47
- close(code?: number, reason?: string): void;
48
- }
49
-
50
- export interface PeerDialSpec<S extends SocketLike> {
51
- /* ONE ATTEMPT'S SOCKET, dialled at whatever address the caller resolves for THIS attempt: a sandbox on the
52
- * same machine is a loopback hop away on one attempt and behind its tunnel on the next, and asking on every
53
- * attempt rather than once at startup is exactly what a reconnect is about. `said` is the line the log gets
54
- * once the socket is open. Undefined ⇒ there is nothing to dial any more (the pairing was forgotten), and
55
- * the loop ends. `signal` is aborted by `stop`, so a resolution that outlives the stop opens nothing. */
56
- readonly open: (signal: AbortSignal) => Promise<{ readonly socket: S; readonly said?: string } | undefined>;
57
- // The first frame, carrying the enrollment token and whatever the door's hello schema asks for.
58
- readonly hello: () => Promise<Record<string, unknown>> | Record<string, unknown>;
59
- // Hand the open socket to the oRPC handler serving the door's contract.
60
- readonly attach: (socket: S) => void;
61
- // The retry ladder: how long to wait after a drop, given how long the socket had held.
62
- readonly backoff: { readonly next: (heldMs: number) => number };
63
- readonly log: (message: string) => void;
64
- // The sandbox refused the enrollment (1008). The loop has already stopped; this is where the peer says so.
65
- readonly revoked: () => void;
66
- }
67
-
68
- export interface PeerLink {
69
- // Resolves when the loop is asked to stop or refused for good; never rejects, a connection error is a retry.
70
- readonly done: Promise<void>;
71
- readonly stop: (reason?: string) => void;
72
- // "connecting" covers a dial in flight AND a retry waiting on the ladder: both mean nobody should start another.
73
- readonly state: () => "open" | "connecting" | "closed";
74
- }
75
-
76
- export const dialPeer = <S extends SocketLike>(spec: PeerDialSpec<S>): PeerLink => {
77
- const stopping = new AbortController();
78
- let socket: S | undefined;
79
- let waiting = false;
80
- let openedAt: number | undefined;
81
- let resolveDone: () => void = () => undefined;
82
- const done = new Promise<void>((resolve) => {
83
- resolveDone = resolve;
84
- });
85
-
86
- const open = async (): Promise<void> => {
87
- waiting = true;
88
- const attempt = await spec.open(stopping.signal);
89
- waiting = false;
90
- // Stopped while the address was still being decided: there is nothing to open, and `stop` has already
91
- // settled `done`. A socket a slow resolver still handed over is closed rather than left dialling.
92
- if (stopping.signal.aborted) {
93
- attempt?.socket.close(1000, "stopping");
94
- return;
95
- }
96
- if (attempt === undefined) {
97
- stopping.abort();
98
- resolveDone();
99
- return;
100
- }
101
- const ws = attempt.socket;
102
- socket = ws;
103
-
104
- ws.addEventListener("open", () => {
105
- openedAt = Date.now();
106
- spec.attach(ws);
107
- const send = (hello: Record<string, unknown>): void => {
108
- ws.send(JSON.stringify(hello));
109
- if (attempt.said !== undefined) {
110
- spec.log(attempt.said);
111
- }
112
- };
113
- // Sent in the open handler's own tick where the hello is already in hand: the sandbox's auth
114
- // deadline is generous, but a frame that could go now and waits a tick is a frame a test cannot
115
- // read, and a hello that needs a read first (a runner's settings claim) simply follows it.
116
- const hello = spec.hello();
117
- if (hello instanceof Promise) {
118
- void hello.then(send);
119
- } else {
120
- send(hello);
121
- }
122
- });
123
-
124
- ws.addEventListener("close", (event) => {
125
- socket = undefined;
126
- if (stopping.signal.aborted) {
127
- resolveDone();
128
- return;
129
- }
130
- if (event.code === UNAUTHORIZED) {
131
- stopping.abort();
132
- resolveDone();
133
- spec.revoked();
134
- return;
135
- }
136
- const delay = spec.backoff.next(openedAt === undefined ? 0 : Date.now() - openedAt);
137
- openedAt = undefined;
138
- spec.log(`disconnected (${event.code ?? "no code"}); reconnecting in ${Math.round(delay / 1000)}s`);
139
- waiting = true;
140
- setTimeout(() => void open(), delay);
141
- });
142
-
143
- // A socket error is always followed by a close event, which owns the retry; this only records the cause,
144
- // which the close code alone never carries.
145
- ws.addEventListener("error", () => spec.log("connection error"));
146
- };
147
-
148
- void open();
149
-
150
- return {
151
- done,
152
- stop: (reason = "stopping") => {
153
- stopping.abort();
154
- waiting = false;
155
- // Forgotten before the close frame arrives, so `state` reads closed the moment the peer asked.
156
- const held = socket;
157
- socket = undefined;
158
- held?.close(1000, reason);
159
- resolveDone();
160
- },
161
- state: () => (socket?.readyState === OPEN ? "open" : socket !== undefined || waiting ? "connecting" : "closed"),
162
- };
163
- };
package/src/plan-pools.ts DELETED
@@ -1,92 +0,0 @@
1
- import type { AccountUsage, UsageWindow, WindowGates } from "./schemas/plan-limits.js";
2
-
3
- /* WHICH OF AN ACCOUNT'S POOLS STAND BETWEEN A TURN AND A MODEL, read once, for both sides of the wire.
4
- *
5
- * Every question about headroom is really a question about ONE model: which account should serve this Haiku
6
- * call, is this Google fleet spent for Claude Opus, when does the pool that refused this turn reopen, what
7
- * does the ring beside the composer measure. The pools a reading carries answer that only through their
8
- * `gates` (UsageWindowSchema says why the reader decides them), and this file is the one place the gate is
9
- * read, so the daemon's account picker, its one-shot helper walk, its refusal dressing and the browser's rings,
10
- * rail and picker rows all agree about which pool is binding for a given model.
11
- *
12
- * WITHOUT A MODEL the answer is the account's own tightest pool, which is what a roster or a rail that has not
13
- * chosen a model yet is asking. Pools gated to `none` are left out of that too: a code-review limit is the
14
- * account's to see, never the thing that decides whether a chat turn can run. */
15
-
16
- /* WHEN A POOL HAS NOTHING LEFT IN IT, on the wire's own scale, read the same way by both sides.
17
- *
18
- * 100, and deliberately not the browser's 90 (usageStatus' SPENT_PERCENT): the two thresholds answer different
19
- * questions. 90 is a WARNING — the point at which a surface stops recommending an account for a long turn, and
20
- * what the rings and the bands take their red from. This is EXHAUSTION: the point past which a call is certain
21
- * to be refused, which is what the daemon needs before it steers a turn elsewhere and the only line a list of
22
- * offers may hide an account behind. A subscription with a tenth of its week left can still run the next task,
23
- * and dropping it off a rail titled "Ready to run" answers the reader's question with the wrong one. */
24
- export const SPENT_UTILIZATION = 100;
25
-
26
- export interface ModelRef {
27
- // The wire id ("claude-opus-4-6", "gemini-3-pro").
28
- readonly id: string;
29
- // What the picker calls it ("Claude Opus 4.6"), when the caller has it. Both are matched, because which of
30
- // the two carries the tier word differs by vendor.
31
- readonly label?: string | undefined;
32
- }
33
-
34
- /* TOKENS, NOT SUBSTRINGS. A pool is named by the plan ("Opus", "gemini") and the model by its vendor
35
- * ("claude-opus-4-6", "Claude Opus 4.6"), and the two only ever agree on a word. A substring test would match
36
- * "opus" inside an id that merely mentions it, and a normalized-string equality would match nothing at all. */
37
- export const wordsOf = (text: string): readonly string[] =>
38
- text
39
- .toLowerCase()
40
- .split(/[^a-z0-9]+/)
41
- .filter(Boolean);
42
-
43
- // Whether `needle` appears as a run of whole words in `words`: "claude opus" is in "claude-opus-4-6", "opus" is
44
- // in "Claude Opus 4.6", and "sonnet" is in neither.
45
- export const runOfWords = (words: readonly string[], needle: readonly string[]): boolean =>
46
- needle.length > 0 && words.some((_, at) => needle.every((word, index) => words[at + index] === word));
47
-
48
- const nameMatches = (name: string, model: ModelRef): boolean => {
49
- const needle = wordsOf(name);
50
- return runOfWords(wordsOf(model.id), needle) || (model.label !== undefined && runOfWords(wordsOf(model.label), needle));
51
- };
52
-
53
- export const gatesModel = (gates: WindowGates, model: ModelRef): boolean =>
54
- gates === "all" ? true : gates === "none" ? false : gates.models.some((name) => nameMatches(name, model));
55
-
56
- // The pools that gate a model, or, with no model named, every pool that gates anything at all.
57
- export const gatingWindows = (usage: AccountUsage | undefined, model?: ModelRef): readonly UsageWindow[] =>
58
- (usage?.windows ?? []).filter((window) => (model === undefined ? window.gates !== "none" : gatesModel(window.gates, model)));
59
-
60
- const fullest = (windows: readonly UsageWindow[]): UsageWindow | undefined =>
61
- windows.reduce<UsageWindow | undefined>((worst, window) => (worst === undefined || window.utilization > worst.utilization ? window : worst), undefined);
62
-
63
- /* THE POOL THAT WILL GATE THE NEXT TURN: the fullest of the ones this model spends. A single headroom number
64
- * can only ever be this one, the account is as constrained as its tightest allowance, whichever that happens
65
- * to be today. Undefined when nothing gates the model (or nothing was measured), which every reader keeps
66
- * distinct from a measured 0%. */
67
- export const bindingWindow = (usage: AccountUsage | undefined, model?: ModelRef): UsageWindow | undefined => fullest(gatingWindows(usage, model));
68
-
69
- /* THE POOL A PLAN METERS THIS MODEL BY ON ITS OWN, when it does: the model-scoped window whose name is the most
70
- * specific match. Distinct from bindingWindow, which answers "what stops the next turn" and may well be the
71
- * all-models weekly; this answers "does the plan keep a separate allowance for this tier", which is what a
72
- * sentence naming the allowance wants ("Opus 82% used").
73
- *
74
- * AMBIGUITY ANSWERS NOTHING. Two pools matching one model at the same specificity (a plan metering "Opus" and
75
- * "Claude Opus" separately, or the same name twice) means we cannot say which allowance a turn spends, so the
76
- * more specific one wins and a tie returns undefined: no sentence beats a sentence naming the wrong pool. */
77
- export const scopedWindow = (usage: AccountUsage | undefined, model: ModelRef): UsageWindow | undefined => {
78
- const matched = (usage?.windows ?? [])
79
- .flatMap((window) => {
80
- if (window.gates === "all" || window.gates === "none") {
81
- return [];
82
- }
83
- const specificity = Math.max(0, ...window.gates.models.filter((name) => nameMatches(name, model)).map((name) => wordsOf(name).length));
84
- return specificity === 0 ? [] : [{ window, specificity }];
85
- })
86
- .toSorted((left, right) => right.specificity - left.specificity);
87
- const best = matched[0];
88
- if (best === undefined || matched[1]?.specificity === best.specificity) {
89
- return undefined;
90
- }
91
- return best.window;
92
- };
@@ -1,334 +0,0 @@
1
- /* HOW HARD A TURN LOOKS BEFORE ANYTHING HAS BEEN SPENT ON IT, the judge behind automatic tier selection.
2
- *
3
- * The job is narrow on purpose: decide whether this turn could have run on the cheap rung of the provider the
4
- * user is already on. Nothing here picks a model, nothing here reads a catalog, and nothing here calls
5
- * anything. It is a pure function over the turn's own words and shape, so the daemon and the composer can both
6
- * ask it and get the same answer, which is the same reason model-pins.ts lives in the contract rather than in
7
- * either of them.
8
- *
9
- * IT CAN ONLY EVER ROUTE DOWN. The standard tier is not a setting: it is whatever the user already picked. So
10
- * the question this file answers is never "which of two models" but "may we substitute something cheaper for
11
- * the one they chose", and every ambiguous answer is NO. That asymmetry is the whole safety argument, and it is
12
- * why there is no fail-up branch to get wrong: failing up means doing exactly what was asked.
13
- *
14
- * WHY RULES AND NOT A MODEL. Two findings decide this. Across the routing literature nothing sophisticated
15
- * beats a simple predictor over decent features (a tuned kNN and a linear head tie, and both beat graph and
16
- * attention routers costing 13-14x more), and a router that spends an LLM call to save an LLM call has spent
17
- * the saving. So the layer is deliberately narrow, transparent, and free. See docs/model-routing-design.md.
18
- *
19
- * WHY EVERY RULE IS NAMED. A verdict carries the rules that fired, not just a number. That is what lets a
20
- * screen say WHY a turn was downgraded, what makes a bad call reportable rather than mysterious, and what makes
21
- * the shadow ledger analysable later: a score alone tells you a threshold was crossed, the rules tell you which
22
- * feature is doing the work. The interpretable-router literature (Routesplain, COLM 2026) reaches the same
23
- * conclusion from the accuracy side, but the operational one is enough on its own. */
24
-
25
- // The named features. A verdict lists these, the shadow ledger stores them, and a screen renders them, so they
26
- // are a vocabulary rather than debug strings: renaming one is a breaking change to what past rows mean.
27
- export type ComplexityRule =
28
- // Gates. Any one of these ends the question: the turn is standard and no score is computed.
29
- | "images"
30
- | "plan-mode"
31
- | "unattended"
32
- // Escalating rules. Any one forces standard. Order between them cannot matter, which is the point.
33
- | "code-block"
34
- | "stack-trace"
35
- | "hard-words"
36
- | "multi-step"
37
- | "cross-cutting"
38
- | "long-prompt"
39
- | "many-attachments"
40
- // Graded features. These only move the score.
41
- | "medium-prompt"
42
- | "attachment"
43
- | "editor-context"
44
- | "paths"
45
- | "many-verbs"
46
- | "after-hard-turn"
47
- | "short-prompt"
48
- | "easy-words"
49
- | "bare-question"
50
- | "no-workspace-reference";
51
-
52
- export type ComplexityTier = "fast" | "standard";
53
-
54
- /* Everything the judge is allowed to know. Deliberately primitive: counts, flags and the prompt itself, no
55
- * objects owned by either side, so the daemon's turn and the composer's draft can each build one without
56
- * agreeing about anything else. The same "compress route state into cheap primitive fields" shape the serving
57
- * literature converges on. */
58
- export interface ComplexityInput {
59
- readonly prompt: string;
60
- // Uploaded files plus @-mentioned workspace paths; the daemon resolves both into one list, so one count.
61
- readonly attachments: number;
62
- // Any attachment the model will read as an image. A cheap rung reading a screenshot is the worst cell in
63
- // the matrix: it is the tier most likely to misread it and the turn least likely to notice.
64
- readonly hasImages: boolean;
65
- // The opt-in editor chip: the user pointed at a file and a selection, so the turn is about real code.
66
- readonly editorContext: boolean;
67
- // A surface started this, not a person at a composer (AgentTurn.unattended).
68
- readonly unattended: boolean;
69
- // The turn opens in plan mode: it is being asked to think before it acts, which is the request itself.
70
- readonly planMode: boolean;
71
- /* THE TURN BEFORE THIS ONE, IN THIS CONVERSATION, WAS JUDGED STANDARD.
72
- *
73
- * The most important field, and the one a prompt-only judge cannot derive. "now do the same for the other
74
- * file" is nine easy words carrying the whole weight of the task before it, and a judge reading only the
75
- * words will downgrade it every time. The routing work closest to this product (SWE-Router, over SWE-bench)
76
- * states the general form: prompt-only routers inherit an information-theoretic error floor because the
77
- * difficulty lives in the trajectory rather than in the request. Their answer is a 7B value model reading
78
- * partial trajectories; ours is one boolean, which costs nothing and catches the case that actually bites.
79
- *
80
- * IT RAISES THE BAR, IT DOES NOT LOCK THE DOOR, and that is a deliberate softening of the rule this was
81
- * designed as. A hard "once standard, always standard" lock reads well and is nearly useless: opening
82
- * messages are substantive, so almost every conversation would take standard on turn one and never be
83
- * eligible again, which is a mechanism that saves nothing while carrying all of the risk. As a weight it
84
- * still stops the deceptive follow-up (which scores near the base and cannot afford the penalty) while a
85
- * genuinely trivial aside inside a hard conversation still gets through, and that aside is a real and
86
- * common turn.
87
- *
88
- * The JUDGEMENT, not what ran: a turn judged fast that ran standard anyway (nothing cheaper in the catalog,
89
- * or the feature switched off) says nothing about the difficulty of the work, and reading it as escalation
90
- * would make the sandbox's configuration leak into its opinion about a sentence. */
91
- readonly afterHardTurn: boolean;
92
- /* HOW EAGER THE OWNER ASKED THIS TO BE (settings.autoTierEagerness), the one preference the judge takes.
93
- * Absent ⇒ `balanced`, which is the stop every verdict recorded before the knob existed was judged
94
- * against, so an absent value and an old row mean the same thing. See FAST_CEILINGS. */
95
- readonly eagerness?: TierEagerness;
96
- }
97
-
98
- export interface ComplexityVerdict {
99
- readonly tier: ComplexityTier;
100
- // 0..1, rounded to three places so ledger rows compare exactly and do not carry float noise. 1 whenever a
101
- // gate or an escalating rule fired: those do not produce a degree of difficulty, they produce an answer.
102
- readonly score: number;
103
- // Every rule that fired, in declaration order. Empty is legal and means "nothing distinctive": the score is
104
- // the base, which sits above the fast ceiling, so an unremarkable turn stays on the user's own pick.
105
- readonly rules: readonly ComplexityRule[];
106
- /* The cutoff this score was judged against, carried out so the caller can record it beside the score.
107
- * A score is only half a verdict once the ceiling is a setting: 0.35 was standard yesterday and is fast
108
- * today, and a refit reading a column of bare scores could not tell those rows apart. */
109
- readonly ceiling: number;
110
- }
111
-
112
- /* WHERE AN UNREMARKABLE TURN STARTS, and it starts ABOVE the fast ceiling on purpose: a prompt that matches no
113
- * rule at all is medium, not simple. That is the reference keyword-router convention and it is the conservative
114
- * reading of silence, which is the only safe one when the downside of a wrong downgrade is a retry, an
115
- * escalation, and a user who stops trusting the feature. */
116
- const BASE_SCORE = 0.5;
117
-
118
- /* HOW EAGER THE JUDGE IS, the one knob this feature exposes, and deliberately the only one.
119
- *
120
- * The routing literature's own answer to "how do you tune a router in public" is a single aggressiveness
121
- * threshold (RouteLLM ships it in the model name, `router-mf-0.3` against `router-mf-0.7`); everything else it
122
- * learns stays inside. Same here: the weights below are a hypothesis with a ledger under them and are nobody's
123
- * business, while "should this err toward my model or toward the cheap one" is a preference only the owner can
124
- * hold, and the shadow numbers are useless without a way to act on what they say.
125
- *
126
- * THREE NAMED STOPS, not a slider, because the page has no slider idiom and, more to the point, a continuous
127
- * control here invites fiddling with a number whose meaning nobody can feel. Each stop is a sentence about
128
- * which turns move:
129
- * cautious — every easing signal at once and nothing pulling the other way: a short bare question, in easy
130
- * words, naming no file. "what is a closure?" and very little else. The zero is not a disabled
131
- * state, it is the floor the score clamps to, so it means exactly "leave no room for doubt".
132
- * balanced — the shipped default, and what every stored verdict before this knob existed was judged against.
133
- * Easy words carry a turn on their own; naming a file still holds it back.
134
- * eager — an easy-worded question about real code goes too ("explain what this file does").
135
- *
136
- * NONE OF THEM CAN REACH THE ABSENCE FEATURES, at any setting, because that property is enforced structurally
137
- * now rather than by the weights happening to sum above the ceiling (see `easing` below). That is what makes an
138
- * eager stop safe to offer at all: raising a bare number would, at 0.3, have started downgrading every short
139
- * vague request in the product, which is the single worst population to be wrong about. */
140
- export const FAST_CEILINGS = { cautious: 0, balanced: 0.25, eager: 0.4 } as const;
141
- export type TierEagerness = keyof typeof FAST_CEILINGS;
142
-
143
- // The stop a turn is judged against when nobody has chosen one, and the one every verdict recorded before the
144
- // knob existed was judged against. Exported because a reader of a stored score needs the ceiling behind it, and
145
- // a row written before ceilings were recorded was written against exactly this.
146
- export const FAST_CEILING = FAST_CEILINGS.balanced;
147
-
148
- // Characters, not tokens: nothing here can tokenize, and for a threshold the constant cancels. ~600 chars is
149
- // where a request stops being a sentence and starts being a brief; ~2400 is where it is carrying pasted
150
- // material it has not fenced.
151
- const MEDIUM_PROMPT_CHARS = 600;
152
- const LONG_PROMPT_CHARS = 2400;
153
- const SHORT_PROMPT_CHARS = 140;
154
- // Three files in is a job about a shape rather than about a file, whatever the words say.
155
- const MANY_ATTACHMENTS = 3;
156
- // Three or more distinct imperatives is a list of jobs wearing the grammar of one.
157
- const MANY_VERBS = 3;
158
-
159
- /* THE WORD LISTS. Kept short and boring, because a hand-written lexicon is the part of a router that rots: it
160
- * is inflexible by construction and every addition is a guess about traffic nobody has measured yet. It exists
161
- * to catch the unambiguous ends of the distribution and to hand everything else to the score.
162
- *
163
- * Both lists are matched on word boundaries and case-insensitively. `easy` only ever lowers a score; `hard`
164
- * forces standard outright, which is the asymmetry the rest of this file is built on. */
165
- const EASY_WORDS =
166
- /\b(?:what(?:'s| is| are)|explain|describe|summari[sz]e|list|show me|where(?:'s| is| are)|rename|typo|reword|reformat|format this|tidy|define|translate|spell|abbreviat)/i;
167
-
168
- const HARD_WORDS =
169
- /\b(?:refactor|redesign|architect|architecture|migrat|root cause|debug|investigat|diagnos|optimi[sz]|race condition|deadlock|memory leak|regression|security|threat model|benchmark|profil|audit|design a|plan (?:a|the|out)|why (?:does|is|are|did|would|can't|cannot))/i;
170
-
171
- // "Do this, and also that." The strongest cheap signal of a job that is several jobs, and the one an easy-
172
- // sounding sentence hides behind most often.
173
- const MULTI_STEP = /\b(?:and then|after that|once (?:that|you)|followed by|as well as|then also)\b/i;
174
-
175
- // A job whose subject is the shape of the codebase rather than a place in it. A cheap rung asked to be
176
- // consistent across twenty files is being asked the one thing it is worst at.
177
- const CROSS_CUTTING =
178
- /\b(?:across (?:the|all|every)|every(?: single)? (?:file|module|package|component|usage|call ?site)|all (?:the|of the) (?:files|usages|call ?sites|places)|everywhere|throughout the|codebase-wide|repo-wide)\b/i;
179
-
180
- // Fenced code, a unified diff, or an inline patch. Pasted code is not proof of difficulty by itself, but it is
181
- // proof the turn is about real code rather than about a word, and the cheap rung's failures there are silent.
182
- const CODE_BLOCK = /```|^diff --git |^@@ .* @@|^[+-]{3} [ab]\//m;
183
-
184
- // A thrown error the user has pasted in. Debugging from a trace is the canonical case where the expensive tier
185
- // earns its price, and it is trivially detectable.
186
- const STACK_TRACE =
187
- /(?:^|\n)\s*(?:at [\w$.<>]+ \(|Traceback \(most recent call last\)|Caused by:|panic:|thread '.*' panicked|Unhandled|[A-Z]\w*(?:Error|Exception): )/;
188
-
189
- // A workspace path or an @-mention in the prose. Distinguishes "explain closures" from "explain what this file
190
- // does" without claiming either is hard.
191
- const PATH_LIKE =
192
- /(?:^|\s)(?:@[\w./-]+|[\w-]+\/[\w./-]+\.[a-z]{1,5}\b|\b[\w-]+\.(?:ts|tsx|js|jsx|vue|py|go|rs|java|rb|css|scss|json|ya?ml|md|sql|sh)\b)/i;
193
-
194
- // One sentence, ending in a question mark, with no second clause. Knowledge, not work.
195
- const BARE_QUESTION = /^[^.!?]{0,200}\?\s*$/;
196
-
197
- // Imperatives that start a request. Counted, not matched: one is a task, three is a list.
198
- const VERBS =
199
- /\b(?:add|remove|delete|fix|write|create|make|update|change|move|rename|split|merge|extract|inline|wire|hook|test|check|run|build|deploy|document|implement|replace|convert|handle|support|expose|log|render|validate|parse|sort|filter|cache)\b/gi;
200
-
201
- // Bullets and numbered steps, which is a checklist however casually it is written.
202
- const LIST_LINES = /^\s*(?:[-*+]\s|\d+[.)]\s)/gm;
203
-
204
- // Every rule that ends the question on its own, paired with the test that fires it. Split from the graded
205
- // features below because the two are read differently: these are answers, those are evidence.
206
- const forcing = (input: ComplexityInput, text: string): ComplexityRule[] => {
207
- const rules: ComplexityRule[] = [];
208
- // Gates first, cheapest and least arguable. They are about the turn's SITUATION rather than its words.
209
- if (input.hasImages) {
210
- rules.push("images");
211
- }
212
- if (input.planMode) {
213
- rules.push("plan-mode");
214
- }
215
- /* An unattended run is billed whole and nobody is watching it fail. The settings this repo already ships
216
- * make the same call in the other direction: a `run` role resolves to NOTHING when empty precisely
217
- * because "nothing here can judge whether a job is worth the frontier tier". This file does judge, but not
218
- * for the runs where a wrong guess costs a whole session with a worktree in it. */
219
- if (input.unattended) {
220
- rules.push("unattended");
221
- }
222
- // Then the words. Every one of these is a claim that the turn is about real code doing something real.
223
- if (CODE_BLOCK.test(text)) {
224
- rules.push("code-block");
225
- }
226
- if (STACK_TRACE.test(text)) {
227
- rules.push("stack-trace");
228
- }
229
- if (HARD_WORDS.test(text)) {
230
- rules.push("hard-words");
231
- }
232
- if (MULTI_STEP.test(text) || (text.match(LIST_LINES)?.length ?? 0) >= 2) {
233
- rules.push("multi-step");
234
- }
235
- if (CROSS_CUTTING.test(text)) {
236
- rules.push("cross-cutting");
237
- }
238
- if (text.length > LONG_PROMPT_CHARS) {
239
- rules.push("long-prompt");
240
- }
241
- if (input.attachments >= MANY_ATTACHMENTS) {
242
- rules.push("many-attachments");
243
- }
244
- return rules;
245
- };
246
-
247
- /* The graded half: what nudges an otherwise ordinary request either way. Weights are a starting shape fitted to
248
- * nothing, which is exactly why the mechanism ships in shadow first — see docs/model-routing-design.md §4. They
249
- * are not a claim, they are a hypothesis with a ledger under it.
250
- *
251
- * ONE PROPERTY IS NOT A HYPOTHESIS AND MUST SURVIVE ANY REFIT, and it is a RULE here rather than an accident of
252
- * arithmetic: absence of complexity is not evidence of simplicity. "fix the bug" is four words naming no file
253
- * and is not a cheap turn, so a downgrade always requires something POSITIVE to have been said — an easy word,
254
- * or a bare question. Those two are marked `easing`, and `judgeComplexity` refuses a fast verdict without one
255
- * whatever the score says.
256
- *
257
- * It used to hold only because the two ABSENCE features (`short-prompt`, `no-workspace-reference`) summed to
258
- * 0.3 against a ceiling of 0.25, which is a coincidence of two numbers rather than a property, and the moment
259
- * the ceiling became a setting it was one click from being false. Weighted the obvious way, the judge
260
- * downgraded every short vague request in the product, which is the single worst population to be wrong
261
- * about. */
262
- interface GradedFeature {
263
- readonly rule: ComplexityRule;
264
- readonly weight: number;
265
- readonly of: (input: ComplexityInput, text: string) => boolean;
266
- // A POSITIVE reason to think this is easy, as opposed to the mere absence of reasons to think it is hard.
267
- // At least one has to fire before any turn is called fast; see the note above.
268
- readonly easing?: true;
269
- }
270
-
271
- const GRADED: readonly GradedFeature[] = [
272
- { rule: "medium-prompt", weight: +0.2, of: (_input, text) => text.length > MEDIUM_PROMPT_CHARS },
273
- { rule: "attachment", weight: +0.15, of: (input) => input.attachments > 0 },
274
- { rule: "editor-context", weight: +0.1, of: (input) => input.editorContext },
275
- // Enough on its own to hold an easy-worded question at standard on the middle stop: "explain what this file
276
- // does" is a question about real code in this repo, and the cheap rung's failures on real code are the
277
- // silent kind. The `eager` stop is precisely the choice to let that one through.
278
- { rule: "paths", weight: +0.15, of: (_input, text) => PATH_LIKE.test(text) },
279
- {
280
- rule: "many-verbs",
281
- weight: +0.15,
282
- of: (_input, text) => new Set((text.match(VERBS) ?? []).map((verb) => verb.toLowerCase())).size >= MANY_VERBS,
283
- },
284
- // The heaviest single weight, because it is the only feature that can see past the words. See
285
- // ComplexityInput.afterHardTurn for why it is a weight rather than the gate it was designed as. Heavy enough
286
- // that even the eager stop cannot route a follow-up to hard work on easy words alone.
287
- { rule: "after-hard-turn", weight: +0.25, of: (input) => input.afterHardTurn },
288
- /* The easing half, in the order it has always been declared, because that order is the order a verdict
289
- * lists its rules in and the ledger has rows written against it. `easing` marks the two POSITIVE ones, one
290
- * of which every fast verdict must carry; the other two are the absence features, deliberately light and,
291
- * by the rule above, never enough by themselves. */
292
- { rule: "short-prompt", weight: -0.1, of: (_input, text) => text.length <= SHORT_PROMPT_CHARS },
293
- { rule: "easy-words", weight: -0.25, easing: true, of: (_input, text) => EASY_WORDS.test(text) },
294
- { rule: "bare-question", weight: -0.15, easing: true, of: (_input, text) => BARE_QUESTION.test(text) },
295
- {
296
- rule: "no-workspace-reference",
297
- weight: -0.1,
298
- of: (input, text) => input.attachments === 0 && !input.editorContext && !PATH_LIKE.test(text),
299
- },
300
- ];
301
-
302
- // Three places, so a stored score is a value rather than a float artefact and two rows written by the same
303
- // rules compare equal.
304
- const round3 = (value: number): number => Math.round(value * 1000) / 1000;
305
-
306
- /* THE VERDICT. Gates and escalating rules first, and if any fired the answer is standard at score 1 — no
307
- * partial credit, no weight to tune, and no way for rule ORDER to change the outcome. That monotone-escalation
308
- * property is worth more than the accuracy it costs: it means adding a rule tomorrow can only ever move turns
309
- * up a tier, never silently move a different set of turns down.
310
- *
311
- * Only what survives all of that gets scored, which keeps the graded layer doing the one job it is good at:
312
- * separating "explain this" from "wire this up" among requests that look alike.
313
- *
314
- * TWO CONDITIONS FOR FAST, not one, and the second is the one that does not move: the score has to clear the
315
- * owner's chosen ceiling AND something POSITIVE has to have been said (a `easing` feature). The ceiling is a
316
- * preference and belongs to whoever pays the bill; "we downgraded it because you didn't say much" is not a
317
- * preference, it is a bug, and it stays impossible at every stop of the knob. */
318
- export const judgeComplexity = (input: ComplexityInput): ComplexityVerdict => {
319
- const ceiling = FAST_CEILINGS[input.eagerness ?? "balanced"];
320
- const text = input.prompt.trim();
321
- const forced = forcing(input, text);
322
- if (forced.length > 0) {
323
- return { tier: "standard", score: 1, rules: forced, ceiling };
324
- }
325
- const hits = GRADED.filter((feature) => feature.of(input, text));
326
- const score = Math.min(1, Math.max(0, BASE_SCORE + hits.reduce((total, feature) => total + feature.weight, 0)));
327
- const eased = hits.some((feature) => feature.easing === true);
328
- return {
329
- tier: eased && score <= ceiling ? "fast" : "standard",
330
- score: round3(score),
331
- rules: hits.map((feature) => feature.rule),
332
- ceiling,
333
- };
334
- };