@kindgi/api 0.1.4 → 0.1.5-rc.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 (507) hide show
  1. package/dist/agent-binding.d.ts +13 -0
  2. package/dist/agent-binding.d.ts.map +1 -1
  3. package/dist/agent-pins.d.ts.map +1 -1
  4. package/dist/agent-pins.js +18 -2
  5. package/dist/agent-pins.js.map +1 -1
  6. package/dist/app.d.ts +110 -17
  7. package/dist/app.d.ts.map +1 -1
  8. package/dist/app.js +163 -35
  9. package/dist/app.js.map +1 -1
  10. package/dist/block-publish.d.ts +56 -0
  11. package/dist/block-publish.d.ts.map +1 -0
  12. package/dist/block-publish.js +132 -0
  13. package/dist/block-publish.js.map +1 -0
  14. package/dist/caller.d.ts +24 -0
  15. package/dist/caller.d.ts.map +1 -0
  16. package/dist/caller.js +47 -0
  17. package/dist/caller.js.map +1 -0
  18. package/dist/capability-binding.d.ts +11 -0
  19. package/dist/capability-binding.d.ts.map +1 -1
  20. package/dist/derive-agent-version.d.ts +7 -0
  21. package/dist/derive-agent-version.d.ts.map +1 -1
  22. package/dist/derive-agent-version.js +4 -0
  23. package/dist/derive-agent-version.js.map +1 -1
  24. package/dist/errors.d.ts.map +1 -1
  25. package/dist/errors.js +73 -7
  26. package/dist/errors.js.map +1 -1
  27. package/dist/eval-case-binding.d.ts +16 -4
  28. package/dist/eval-case-binding.d.ts.map +1 -1
  29. package/dist/eval-run-binding.d.ts +31 -0
  30. package/dist/eval-run-binding.d.ts.map +1 -1
  31. package/dist/eval-run-dispatcher.d.ts +7 -0
  32. package/dist/eval-run-dispatcher.d.ts.map +1 -1
  33. package/dist/eval-run-dispatcher.js.map +1 -1
  34. package/dist/eval-sample.d.ts +11 -0
  35. package/dist/eval-sample.d.ts.map +1 -0
  36. package/dist/eval-sample.js +34 -0
  37. package/dist/eval-sample.js.map +1 -0
  38. package/dist/eval-suite-binding.d.ts +13 -0
  39. package/dist/eval-suite-binding.d.ts.map +1 -1
  40. package/dist/eval-suite-binding.js.map +1 -1
  41. package/dist/flow-binding.d.ts +18 -0
  42. package/dist/flow-binding.d.ts.map +1 -1
  43. package/dist/flow-pins.d.ts.map +1 -1
  44. package/dist/flow-pins.js +18 -2
  45. package/dist/flow-pins.js.map +1 -1
  46. package/dist/gate.d.ts.map +1 -1
  47. package/dist/gate.js +25 -0
  48. package/dist/gate.js.map +1 -1
  49. package/dist/handler-binding.d.ts +32 -0
  50. package/dist/handler-binding.d.ts.map +1 -1
  51. package/dist/hitl-binding.d.ts +23 -0
  52. package/dist/hitl-binding.d.ts.map +1 -1
  53. package/dist/identity-directory-binding.d.ts +82 -4
  54. package/dist/identity-directory-binding.d.ts.map +1 -1
  55. package/dist/identity-provider-binding.d.ts +197 -17
  56. package/dist/identity-provider-binding.d.ts.map +1 -1
  57. package/dist/improvement-pass-binding.d.ts +196 -0
  58. package/dist/improvement-pass-binding.d.ts.map +1 -0
  59. package/dist/improvement-pass-binding.js +9 -0
  60. package/dist/improvement-pass-binding.js.map +1 -0
  61. package/dist/index.d.ts +35 -17
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +11 -3
  64. package/dist/index.js.map +1 -1
  65. package/dist/judged-dispatcher.d.ts +25 -4
  66. package/dist/judged-dispatcher.d.ts.map +1 -1
  67. package/dist/judged-dispatcher.js +43 -6
  68. package/dist/judged-dispatcher.js.map +1 -1
  69. package/dist/judgment-binding.d.ts +25 -1
  70. package/dist/judgment-binding.d.ts.map +1 -1
  71. package/dist/mcp-endpoint-binding.d.ts +7 -0
  72. package/dist/mcp-endpoint-binding.d.ts.map +1 -1
  73. package/dist/memory-binding.d.ts +124 -17
  74. package/dist/memory-binding.d.ts.map +1 -1
  75. package/dist/memory-erasure-binding.d.ts +145 -0
  76. package/dist/memory-erasure-binding.d.ts.map +1 -0
  77. package/dist/memory-erasure-binding.js +4 -0
  78. package/dist/memory-erasure-binding.js.map +1 -0
  79. package/dist/middleware/auth.d.ts +66 -13
  80. package/dist/middleware/auth.d.ts.map +1 -1
  81. package/dist/middleware/auth.js +150 -50
  82. package/dist/middleware/auth.js.map +1 -1
  83. package/dist/middleware/authorize.d.ts +6 -0
  84. package/dist/middleware/authorize.d.ts.map +1 -1
  85. package/dist/middleware/authorize.js +113 -4
  86. package/dist/middleware/authorize.js.map +1 -1
  87. package/dist/middleware/error-mapper.d.ts +5 -0
  88. package/dist/middleware/error-mapper.d.ts.map +1 -1
  89. package/dist/middleware/error-mapper.js +14 -1
  90. package/dist/middleware/error-mapper.js.map +1 -1
  91. package/dist/middleware/idempotency.d.ts +70 -5
  92. package/dist/middleware/idempotency.d.ts.map +1 -1
  93. package/dist/middleware/idempotency.js +174 -41
  94. package/dist/middleware/idempotency.js.map +1 -1
  95. package/dist/middleware/key-project.d.ts +17 -0
  96. package/dist/middleware/key-project.d.ts.map +1 -0
  97. package/dist/middleware/key-project.js +75 -0
  98. package/dist/middleware/key-project.js.map +1 -0
  99. package/dist/middleware/principal.d.ts.map +1 -1
  100. package/dist/middleware/principal.js +9 -5
  101. package/dist/middleware/principal.js.map +1 -1
  102. package/dist/middleware/project-ref.d.ts.map +1 -1
  103. package/dist/middleware/project-ref.js +3 -0
  104. package/dist/middleware/project-ref.js.map +1 -1
  105. package/dist/openapi/generate.d.ts.map +1 -1
  106. package/dist/openapi/generate.js +5 -2
  107. package/dist/openapi/generate.js.map +1 -1
  108. package/dist/openapi/operations.d.ts.map +1 -1
  109. package/dist/openapi/operations.js +918 -139
  110. package/dist/openapi/operations.js.map +1 -1
  111. package/dist/openapi/schemas.d.ts +90 -13
  112. package/dist/openapi/schemas.d.ts.map +1 -1
  113. package/dist/openapi/schemas.js +2081 -359
  114. package/dist/openapi/schemas.js.map +1 -1
  115. package/dist/person-grants-binding.d.ts +77 -0
  116. package/dist/person-grants-binding.d.ts.map +1 -0
  117. package/dist/person-grants-binding.js +4 -0
  118. package/dist/person-grants-binding.js.map +1 -0
  119. package/dist/proposal-service.d.ts +121 -0
  120. package/dist/proposal-service.d.ts.map +1 -0
  121. package/dist/proposal-service.js +447 -0
  122. package/dist/proposal-service.js.map +1 -0
  123. package/dist/proposal-status.d.ts +60 -0
  124. package/dist/proposal-status.d.ts.map +1 -0
  125. package/dist/proposal-status.js +109 -0
  126. package/dist/proposal-status.js.map +1 -0
  127. package/dist/provider-binding.d.ts +10 -0
  128. package/dist/provider-binding.d.ts.map +1 -1
  129. package/dist/publish-refused.d.ts +18 -3
  130. package/dist/publish-refused.d.ts.map +1 -1
  131. package/dist/publish-refused.js +18 -3
  132. package/dist/publish-refused.js.map +1 -1
  133. package/dist/routes/adapters.d.ts +2 -1
  134. package/dist/routes/adapters.d.ts.map +1 -1
  135. package/dist/routes/adapters.js +3 -1
  136. package/dist/routes/adapters.js.map +1 -1
  137. package/dist/routes/agent-releases.d.ts +55 -3
  138. package/dist/routes/agent-releases.d.ts.map +1 -1
  139. package/dist/routes/agent-releases.js +85 -55
  140. package/dist/routes/agent-releases.js.map +1 -1
  141. package/dist/routes/agents.d.ts +12 -1
  142. package/dist/routes/agents.d.ts.map +1 -1
  143. package/dist/routes/agents.js +100 -2
  144. package/dist/routes/agents.js.map +1 -1
  145. package/dist/routes/approvals.d.ts +15 -3
  146. package/dist/routes/approvals.d.ts.map +1 -1
  147. package/dist/routes/approvals.js +133 -122
  148. package/dist/routes/approvals.js.map +1 -1
  149. package/dist/routes/artifacts.d.ts +25 -3
  150. package/dist/routes/artifacts.d.ts.map +1 -1
  151. package/dist/routes/artifacts.js +116 -7
  152. package/dist/routes/artifacts.js.map +1 -1
  153. package/dist/routes/auth.d.ts +25 -1
  154. package/dist/routes/auth.d.ts.map +1 -1
  155. package/dist/routes/auth.js +655 -281
  156. package/dist/routes/auth.js.map +1 -1
  157. package/dist/routes/blocks.d.ts.map +1 -1
  158. package/dist/routes/blocks.js +2 -42
  159. package/dist/routes/blocks.js.map +1 -1
  160. package/dist/routes/capabilities.d.ts +2 -1
  161. package/dist/routes/capabilities.d.ts.map +1 -1
  162. package/dist/routes/capabilities.js +6 -1
  163. package/dist/routes/capabilities.js.map +1 -1
  164. package/dist/routes/compliance.d.ts +9 -10
  165. package/dist/routes/compliance.d.ts.map +1 -1
  166. package/dist/routes/compliance.js +42 -61
  167. package/dist/routes/compliance.js.map +1 -1
  168. package/dist/routes/conversations.d.ts +8 -1
  169. package/dist/routes/conversations.d.ts.map +1 -1
  170. package/dist/routes/conversations.js +87 -8
  171. package/dist/routes/conversations.js.map +1 -1
  172. package/dist/routes/cost.d.ts +7 -1
  173. package/dist/routes/cost.d.ts.map +1 -1
  174. package/dist/routes/cost.js +22 -3
  175. package/dist/routes/cost.js.map +1 -1
  176. package/dist/routes/denied.d.ts +11 -0
  177. package/dist/routes/denied.d.ts.map +1 -0
  178. package/dist/routes/denied.js +17 -0
  179. package/dist/routes/denied.js.map +1 -0
  180. package/dist/routes/deployments.d.ts +2 -1
  181. package/dist/routes/deployments.d.ts.map +1 -1
  182. package/dist/routes/deployments.js +44 -12
  183. package/dist/routes/deployments.js.map +1 -1
  184. package/dist/routes/eval-comparison.d.ts.map +1 -1
  185. package/dist/routes/eval-comparison.js +69 -1
  186. package/dist/routes/eval-comparison.js.map +1 -1
  187. package/dist/routes/eval-overrides.d.ts +18 -0
  188. package/dist/routes/eval-overrides.d.ts.map +1 -0
  189. package/dist/routes/eval-overrides.js +81 -0
  190. package/dist/routes/eval-overrides.js.map +1 -0
  191. package/dist/routes/eval-runs.d.ts +10 -1
  192. package/dist/routes/eval-runs.d.ts.map +1 -1
  193. package/dist/routes/eval-runs.js +63 -7
  194. package/dist/routes/eval-runs.js.map +1 -1
  195. package/dist/routes/eval-suites.d.ts.map +1 -1
  196. package/dist/routes/eval-suites.js +20 -1
  197. package/dist/routes/eval-suites.js.map +1 -1
  198. package/dist/routes/event-triggers.d.ts +5 -1
  199. package/dist/routes/event-triggers.d.ts.map +1 -1
  200. package/dist/routes/event-triggers.js +26 -3
  201. package/dist/routes/event-triggers.js.map +1 -1
  202. package/dist/routes/export-signing-keys.d.ts +12 -0
  203. package/dist/routes/export-signing-keys.d.ts.map +1 -0
  204. package/dist/routes/export-signing-keys.js +24 -0
  205. package/dist/routes/export-signing-keys.js.map +1 -0
  206. package/dist/routes/flows.d.ts.map +1 -1
  207. package/dist/routes/flows.js +9 -1
  208. package/dist/routes/flows.js.map +1 -1
  209. package/dist/routes/gate-policies.d.ts +4 -1
  210. package/dist/routes/gate-policies.d.ts.map +1 -1
  211. package/dist/routes/gate-policies.js +29 -5
  212. package/dist/routes/gate-policies.js.map +1 -1
  213. package/dist/routes/guardrails.d.ts +16 -14
  214. package/dist/routes/guardrails.d.ts.map +1 -1
  215. package/dist/routes/guardrails.js +39 -3
  216. package/dist/routes/guardrails.js.map +1 -1
  217. package/dist/routes/identity.d.ts +20 -4
  218. package/dist/routes/identity.d.ts.map +1 -1
  219. package/dist/routes/identity.js +246 -6
  220. package/dist/routes/identity.js.map +1 -1
  221. package/dist/routes/improvement-passes.d.ts +52 -0
  222. package/dist/routes/improvement-passes.d.ts.map +1 -0
  223. package/dist/routes/improvement-passes.js +449 -0
  224. package/dist/routes/improvement-passes.js.map +1 -0
  225. package/dist/routes/judged-suites.d.ts +50 -0
  226. package/dist/routes/judged-suites.d.ts.map +1 -1
  227. package/dist/routes/judged-suites.js +66 -27
  228. package/dist/routes/judged-suites.js.map +1 -1
  229. package/dist/routes/judgment-context.d.ts +18 -2
  230. package/dist/routes/judgment-context.d.ts.map +1 -1
  231. package/dist/routes/judgment-context.js +63 -5
  232. package/dist/routes/judgment-context.js.map +1 -1
  233. package/dist/routes/judgment-flow-context.d.ts.map +1 -1
  234. package/dist/routes/judgment-flow-context.js +14 -2
  235. package/dist/routes/judgment-flow-context.js.map +1 -1
  236. package/dist/routes/judgments.d.ts.map +1 -1
  237. package/dist/routes/judgments.js +8 -1
  238. package/dist/routes/judgments.js.map +1 -1
  239. package/dist/routes/mcp.d.ts.map +1 -1
  240. package/dist/routes/mcp.js +26 -1
  241. package/dist/routes/mcp.js.map +1 -1
  242. package/dist/routes/memory-access.d.ts +43 -0
  243. package/dist/routes/memory-access.d.ts.map +1 -0
  244. package/dist/routes/memory-access.js +129 -0
  245. package/dist/routes/memory-access.js.map +1 -0
  246. package/dist/routes/memory-erasures.d.ts +25 -0
  247. package/dist/routes/memory-erasures.d.ts.map +1 -0
  248. package/dist/routes/memory-erasures.js +214 -0
  249. package/dist/routes/memory-erasures.js.map +1 -0
  250. package/dist/routes/memory-parse.d.ts +38 -0
  251. package/dist/routes/memory-parse.d.ts.map +1 -0
  252. package/dist/routes/memory-parse.js +199 -0
  253. package/dist/routes/memory-parse.js.map +1 -0
  254. package/dist/routes/memory.d.ts +9 -4
  255. package/dist/routes/memory.d.ts.map +1 -1
  256. package/dist/routes/memory.js +226 -234
  257. package/dist/routes/memory.js.map +1 -1
  258. package/dist/routes/observations.d.ts +4 -1
  259. package/dist/routes/observations.d.ts.map +1 -1
  260. package/dist/routes/observations.js +8 -2
  261. package/dist/routes/observations.js.map +1 -1
  262. package/dist/routes/pagination.d.ts +7 -0
  263. package/dist/routes/pagination.d.ts.map +1 -1
  264. package/dist/routes/pagination.js +10 -0
  265. package/dist/routes/pagination.js.map +1 -1
  266. package/dist/routes/policies.d.ts +2 -1
  267. package/dist/routes/policies.d.ts.map +1 -1
  268. package/dist/routes/policies.js +3 -1
  269. package/dist/routes/policies.js.map +1 -1
  270. package/dist/routes/project-mismatch.d.ts +22 -0
  271. package/dist/routes/project-mismatch.d.ts.map +1 -0
  272. package/dist/routes/project-mismatch.js +34 -0
  273. package/dist/routes/project-mismatch.js.map +1 -0
  274. package/dist/routes/projects.d.ts +15 -4
  275. package/dist/routes/projects.d.ts.map +1 -1
  276. package/dist/routes/projects.js +100 -9
  277. package/dist/routes/projects.js.map +1 -1
  278. package/dist/routes/proposals.d.ts +25 -17
  279. package/dist/routes/proposals.d.ts.map +1 -1
  280. package/dist/routes/proposals.js +340 -507
  281. package/dist/routes/proposals.js.map +1 -1
  282. package/dist/routes/provenance.d.ts +17 -3
  283. package/dist/routes/provenance.d.ts.map +1 -1
  284. package/dist/routes/provenance.js +79 -103
  285. package/dist/routes/provenance.js.map +1 -1
  286. package/dist/routes/providers.d.ts +17 -1
  287. package/dist/routes/providers.d.ts.map +1 -1
  288. package/dist/routes/providers.js +110 -3
  289. package/dist/routes/providers.js.map +1 -1
  290. package/dist/routes/public-run-tokens.d.ts.map +1 -1
  291. package/dist/routes/public-run-tokens.js +3 -0
  292. package/dist/routes/public-run-tokens.js.map +1 -1
  293. package/dist/routes/runs.d.ts +10 -0
  294. package/dist/routes/runs.d.ts.map +1 -1
  295. package/dist/routes/runs.js +92 -42
  296. package/dist/routes/runs.js.map +1 -1
  297. package/dist/routes/schedules.d.ts +21 -13
  298. package/dist/routes/schedules.d.ts.map +1 -1
  299. package/dist/routes/schedules.js +416 -55
  300. package/dist/routes/schedules.js.map +1 -1
  301. package/dist/routes/segments.d.ts +2 -0
  302. package/dist/routes/segments.d.ts.map +1 -1
  303. package/dist/routes/segments.js +5 -0
  304. package/dist/routes/segments.js.map +1 -1
  305. package/dist/routes/service-accounts.d.ts +17 -0
  306. package/dist/routes/service-accounts.d.ts.map +1 -0
  307. package/dist/routes/service-accounts.js +212 -0
  308. package/dist/routes/service-accounts.js.map +1 -0
  309. package/dist/routes/sign-in-options.d.ts +50 -0
  310. package/dist/routes/sign-in-options.d.ts.map +1 -0
  311. package/dist/routes/sign-in-options.js +98 -0
  312. package/dist/routes/sign-in-options.js.map +1 -0
  313. package/dist/routes/signing-keys.d.ts +2 -1
  314. package/dist/routes/signing-keys.d.ts.map +1 -1
  315. package/dist/routes/signing-keys.js +3 -1
  316. package/dist/routes/signing-keys.js.map +1 -1
  317. package/dist/routes/tenant-access.d.ts +13 -0
  318. package/dist/routes/tenant-access.d.ts.map +1 -0
  319. package/dist/routes/tenant-access.js +26 -0
  320. package/dist/routes/tenant-access.js.map +1 -0
  321. package/dist/routes/tenant.d.ts.map +1 -1
  322. package/dist/routes/tenant.js +4 -0
  323. package/dist/routes/tenant.js.map +1 -1
  324. package/dist/routes/token-sign-in.d.ts +36 -0
  325. package/dist/routes/token-sign-in.d.ts.map +1 -0
  326. package/dist/routes/token-sign-in.js +101 -0
  327. package/dist/routes/token-sign-in.js.map +1 -0
  328. package/dist/routes/tokens.d.ts +15 -5
  329. package/dist/routes/tokens.d.ts.map +1 -1
  330. package/dist/routes/tokens.js +162 -43
  331. package/dist/routes/tokens.js.map +1 -1
  332. package/dist/routes/tools.d.ts.map +1 -1
  333. package/dist/routes/tools.js +9 -1
  334. package/dist/routes/tools.js.map +1 -1
  335. package/dist/routes/trigger-access.d.ts +29 -0
  336. package/dist/routes/trigger-access.d.ts.map +1 -0
  337. package/dist/routes/trigger-access.js +33 -0
  338. package/dist/routes/trigger-access.js.map +1 -0
  339. package/dist/routes/webhook-endpoints.d.ts +2 -1
  340. package/dist/routes/webhook-endpoints.d.ts.map +1 -1
  341. package/dist/routes/webhook-endpoints.js +11 -3
  342. package/dist/routes/webhook-endpoints.js.map +1 -1
  343. package/dist/routes/webhooks.d.ts +5 -1
  344. package/dist/routes/webhooks.d.ts.map +1 -1
  345. package/dist/routes/webhooks.js +25 -2
  346. package/dist/routes/webhooks.js.map +1 -1
  347. package/dist/run-failure.d.ts +21 -0
  348. package/dist/run-failure.d.ts.map +1 -0
  349. package/dist/run-failure.js +29 -0
  350. package/dist/run-failure.js.map +1 -0
  351. package/dist/service-account-binding.d.ts +108 -0
  352. package/dist/service-account-binding.d.ts.map +1 -0
  353. package/dist/service-account-binding.js +4 -0
  354. package/dist/service-account-binding.js.map +1 -0
  355. package/dist/session-store-binding.d.ts +61 -13
  356. package/dist/session-store-binding.d.ts.map +1 -1
  357. package/dist/signed-export.d.ts +89 -0
  358. package/dist/signed-export.d.ts.map +1 -0
  359. package/dist/signed-export.js +149 -0
  360. package/dist/signed-export.js.map +1 -0
  361. package/dist/supervisor-binding.d.ts +186 -413
  362. package/dist/supervisor-binding.d.ts.map +1 -1
  363. package/dist/testing/app-bindings.d.ts +33 -0
  364. package/dist/testing/app-bindings.d.ts.map +1 -0
  365. package/dist/testing/app-bindings.js +112 -0
  366. package/dist/testing/app-bindings.js.map +1 -0
  367. package/dist/testing/index.d.ts +11 -0
  368. package/dist/testing/index.d.ts.map +1 -0
  369. package/dist/testing/index.js +13 -0
  370. package/dist/testing/index.js.map +1 -0
  371. package/dist/testing/stub-binding.d.ts +34 -0
  372. package/dist/testing/stub-binding.d.ts.map +1 -0
  373. package/dist/testing/stub-binding.js +42 -0
  374. package/dist/testing/stub-binding.js.map +1 -0
  375. package/dist/testing/trigger-registry.d.ts +21 -0
  376. package/dist/testing/trigger-registry.d.ts.map +1 -0
  377. package/dist/testing/trigger-registry.js +206 -0
  378. package/dist/testing/trigger-registry.js.map +1 -0
  379. package/dist/token-admin.d.ts +46 -8
  380. package/dist/token-admin.d.ts.map +1 -1
  381. package/dist/token-admin.js.map +1 -1
  382. package/dist/tool-binding.d.ts +13 -0
  383. package/dist/tool-binding.d.ts.map +1 -1
  384. package/dist/trigger-binding.d.ts +2 -2
  385. package/dist/trigger-binding.d.ts.map +1 -1
  386. package/dist/trigger-binding.js +1 -1
  387. package/dist/trigger-binding.js.map +1 -1
  388. package/dist/types.d.ts +16 -0
  389. package/dist/types.d.ts.map +1 -1
  390. package/dist/webhook-endpoint-binding.d.ts +19 -3
  391. package/dist/webhook-endpoint-binding.d.ts.map +1 -1
  392. package/dist/webhook-endpoint-binding.js +1 -1
  393. package/dist/webhook-endpoint-binding.js.map +1 -1
  394. package/openapi.json +15385 -8788
  395. package/package.json +26 -22
  396. package/src/agent-binding.ts +14 -0
  397. package/src/agent-pins.ts +18 -2
  398. package/src/app.ts +366 -80
  399. package/src/block-publish.ts +181 -0
  400. package/src/caller.ts +62 -0
  401. package/src/capability-binding.ts +12 -0
  402. package/src/derive-agent-version.ts +9 -1
  403. package/src/errors.ts +73 -7
  404. package/src/eval-case-binding.ts +17 -1
  405. package/src/eval-run-binding.ts +31 -0
  406. package/src/eval-run-dispatcher.ts +7 -0
  407. package/src/eval-sample.ts +42 -0
  408. package/src/eval-suite-binding.ts +14 -0
  409. package/src/flow-binding.ts +19 -0
  410. package/src/flow-pins.ts +18 -2
  411. package/src/gate.ts +26 -0
  412. package/src/handler-binding.ts +36 -1
  413. package/src/hitl-binding.ts +24 -0
  414. package/src/identity-directory-binding.ts +85 -4
  415. package/src/identity-provider-binding.ts +216 -21
  416. package/src/improvement-pass-binding.ts +193 -0
  417. package/src/index.ts +153 -31
  418. package/src/judged-dispatcher.ts +78 -11
  419. package/src/judgment-binding.ts +25 -1
  420. package/src/mcp-endpoint-binding.ts +7 -0
  421. package/src/memory-binding.ts +121 -17
  422. package/src/memory-erasure-binding.ts +156 -0
  423. package/src/middleware/auth.ts +228 -62
  424. package/src/middleware/authorize.ts +139 -3
  425. package/src/middleware/error-mapper.ts +15 -1
  426. package/src/middleware/idempotency.ts +230 -43
  427. package/src/middleware/key-project.ts +86 -0
  428. package/src/middleware/principal.ts +9 -5
  429. package/src/middleware/project-ref.ts +3 -0
  430. package/src/openapi/generate.ts +11 -2
  431. package/src/openapi/operations.ts +1059 -142
  432. package/src/openapi/schemas.ts +2387 -469
  433. package/src/person-grants-binding.ts +76 -0
  434. package/src/proposal-service.ts +640 -0
  435. package/src/proposal-status.ts +176 -0
  436. package/src/provider-binding.ts +10 -0
  437. package/src/publish-refused.ts +38 -9
  438. package/src/routes/adapters.ts +4 -0
  439. package/src/routes/agent-releases.ts +121 -69
  440. package/src/routes/agents.ts +128 -1
  441. package/src/routes/approvals.ts +164 -154
  442. package/src/routes/artifacts.ts +181 -11
  443. package/src/routes/auth.ts +804 -336
  444. package/src/routes/blocks.ts +2 -53
  445. package/src/routes/capabilities.ts +10 -1
  446. package/src/routes/compliance.ts +60 -99
  447. package/src/routes/conversations.ts +101 -7
  448. package/src/routes/cost.ts +32 -3
  449. package/src/routes/denied.ts +28 -0
  450. package/src/routes/deployments.ts +62 -16
  451. package/src/routes/eval-comparison.ts +81 -2
  452. package/src/routes/eval-overrides.ts +108 -0
  453. package/src/routes/eval-runs.ts +86 -6
  454. package/src/routes/eval-suites.ts +25 -1
  455. package/src/routes/event-triggers.ts +27 -3
  456. package/src/routes/export-signing-keys.ts +31 -0
  457. package/src/routes/flows.ts +12 -1
  458. package/src/routes/gate-policies.ts +37 -6
  459. package/src/routes/guardrails.ts +61 -2
  460. package/src/routes/identity.ts +328 -10
  461. package/src/routes/improvement-passes.ts +541 -0
  462. package/src/routes/judged-suites.ts +113 -43
  463. package/src/routes/judgment-context.ts +76 -5
  464. package/src/routes/judgment-flow-context.ts +16 -2
  465. package/src/routes/judgments.ts +17 -3
  466. package/src/routes/mcp.ts +29 -1
  467. package/src/routes/memory-access.ts +179 -0
  468. package/src/routes/memory-erasures.ts +240 -0
  469. package/src/routes/memory-parse.ts +250 -0
  470. package/src/routes/memory.ts +244 -286
  471. package/src/routes/observations.ts +15 -2
  472. package/src/routes/pagination.ts +12 -0
  473. package/src/routes/policies.ts +7 -1
  474. package/src/routes/project-mismatch.ts +56 -0
  475. package/src/routes/projects.ts +107 -13
  476. package/src/routes/proposals.ts +370 -611
  477. package/src/routes/provenance.ts +99 -133
  478. package/src/routes/providers.ts +142 -3
  479. package/src/routes/public-run-tokens.ts +3 -0
  480. package/src/routes/runs.ts +119 -39
  481. package/src/routes/schedules.ts +472 -60
  482. package/src/routes/segments.ts +11 -0
  483. package/src/routes/service-accounts.ts +262 -0
  484. package/src/routes/sign-in-options.ts +168 -0
  485. package/src/routes/signing-keys.ts +7 -1
  486. package/src/routes/tenant-access.ts +37 -0
  487. package/src/routes/tenant.ts +6 -0
  488. package/src/routes/token-sign-in.ts +161 -0
  489. package/src/routes/tokens.ts +172 -46
  490. package/src/routes/tools.ts +12 -1
  491. package/src/routes/trigger-access.ts +72 -0
  492. package/src/routes/webhook-endpoints.ts +15 -3
  493. package/src/routes/webhooks.ts +26 -2
  494. package/src/run-failure.ts +42 -0
  495. package/src/service-account-binding.ts +113 -0
  496. package/src/session-store-binding.ts +65 -13
  497. package/src/signed-export.ts +250 -0
  498. package/src/supervisor-binding.ts +169 -409
  499. package/src/testing/app-bindings.ts +142 -0
  500. package/src/testing/index.ts +21 -0
  501. package/src/testing/stub-binding.ts +53 -0
  502. package/src/testing/trigger-registry.ts +259 -0
  503. package/src/token-admin.ts +40 -8
  504. package/src/tool-binding.ts +14 -0
  505. package/src/trigger-binding.ts +8 -1
  506. package/src/types.ts +16 -0
  507. package/src/webhook-endpoint-binding.ts +18 -3
@@ -1,103 +1,44 @@
1
- import type { Scope } from '@kindgi/platform';
2
- import type { AgentId, ApprovalId, Cursor, FixProposalId, ObservationId, ProvenanceId, RunId, Semver, SupervisorId, TenantId, Timestamp } from '@kindgi/types';
1
+ import type { AgentId, Cursor, FixProposalId, LiveScope, ObservationId, ProjectId, ProvenanceId, RunId, Semver, SupervisorId, TenantId, Timestamp } from '@kindgi/types';
3
2
  /**
4
- * Caller-plugged surface for the supervisor's fix-proposal lifecycle
5
- * + observation readback. Same shape as
6
- * `AgentRegistryBinding` / `MemoryBinding` / `ReviewerBinding`: the API
7
- * package does NOT own supervisor runtime, agent registry, HITL wiring,
8
- * or eval invocation. A binding implementation composes:
3
+ * Caller-plugged store behind improvement proposals (`/v1/proposals`)
4
+ * and the supervisor's observation readback (`/v1/observations`). Same
5
+ * shape as `AgentRegistryBinding` / `MemoryBinding`: the API package
6
+ * doesn't own the storage.
9
7
  *
10
- * - the supervisor runtime (draft, dry-run, submit for review, apply,
11
- * roll back, withdraw, list / get proposals, query observations);
12
- * - its `Supervisor` registry (`supervisorId → Supervisor`);
13
- * - its agent registry (for the dry-run baseline lookup + `apply`);
14
- * - its eval dataset + judge registries and an agent-invocation
15
- * closure (all needed by the dry-run);
16
- * - its HITL surface (submitting for review enqueues an approval —
17
- * the binding surfaces the resulting `ApprovalId` back to the route
18
- * so the response body carries it).
19
- *
20
- * Every proposal method is tenant-scoped AND supervisor-scoped: callers
21
- * pass both `tenantId` and `supervisorId`. `supervisorId` comes from the
22
- * `X-Supervisor-Id` request header — tenant flows from the token,
23
- * supervisor is a per-request scope the caller supplies.
24
- *
25
- * State transitions are enforced by the supervisor runtime
26
- * (`invalid-transition` domain error). The route layer surfaces those
27
- * as `409 conflict` with error code
28
- * `proposal-invalid-state-transition` — out-of-order lifecycle calls
29
- * are caller/state conflicts.
8
+ * A proposal is a change to one data block an agent version pins (new
9
+ * settings values, or a new prompt template), for one live scope. The
10
+ * API package runs its lifecycle from bindings that exist already:
11
+ * evaluating publishes the block version and derives the agent version
12
+ * (both serve nowhere until promoted) and starts a comparison eval run;
13
+ * requesting runs the scope's gated promotion. This binding only keeps
14
+ * the rows: what was proposed, then each step's outcome, recorded with
15
+ * a compare-and-set on `revision`. A proposal's status is never stored:
16
+ * the route derives it from the eval run and the promotion
17
+ * (`proposalStatus`).
30
18
  *
31
19
  * `queryObservations` is the supervisor readback for `/v1/observations`
32
20
  * — a straight paginated list over the observation stream. Tenant-scoped
33
- * only; `supervisorId` is an optional filter, not a mount-time scope.
21
+ * only; `supervisorId` is an optional filter.
34
22
  */
35
23
  export interface SupervisorBinding {
36
24
  /**
37
- * Cursor-paginated list of proposals scoped to `(tenantId,
38
- * supervisorId)`. Filters:
39
- * - `status` — single `FixProposalStatus` value.
40
- * - `agentId` — exact match on target agent id.
41
- * - `tier` — `'prompt' | 'retrieval' | 'tool-config'`.
42
- *
43
- * Sort order is binding-defined (for example `createdAt desc, id desc`).
44
- */
45
- listProposals(input: SupervisorListProposalsInput): Promise<SupervisorProposalPage>;
46
- /**
47
- * Get a proposal by id, or `null` when unknown. The route surfaces
48
- * `null` as `404 proposal-not-found`. The binding MUST also return
49
- * `null` when the proposal exists but is not owned by the caller's
50
- * supervisor id — cross-supervisor reads leak tier boundaries the
51
- * same way cross-tenant reads leak resource existence (avoid via
52
- * `null → 404` per `docs/API-ROUTE-CONVENTIONS.md` §2.4).
25
+ * Cursor-paginated proposals in the tenant, newest first
26
+ * (`createdAt desc, id desc`). Filters are optional.
53
27
  */
54
- getProposal(input: SupervisorGetProposalInput): Promise<FixProposal | null>;
28
+ listProposals(input: ListProposalsInput): Promise<StoredProposalPage>;
29
+ /** One proposal, or `null` when the tenant has none with that id. */
30
+ getProposal(input: GetProposalInput): Promise<StoredProposal | null>;
55
31
  /**
56
- * Draft a new proposal in `draft` state. The dedup fingerprint is
57
- * computed from `(tier, agentId, agentVersion, canonical(change))`;
58
- * duplicate proposals short-circuit to the existing non-terminal row —
59
- * discriminated on `SupervisorDraftOutcome.kind`.
32
+ * Store a new proposal at revision 1. One with the same `fingerprint`
33
+ * that isn't withdrawn yet answers `dedup` with that row instead.
60
34
  */
61
- draftProposal(input: SupervisorDraftProposalInput): Promise<SupervisorDraftOutcome>;
35
+ createProposal(input: CreateProposalInput): Promise<CreateProposalOutcome>;
62
36
  /**
63
- * Trigger a dry-run for a proposal. A dry-run needs a dataset, judges,
64
- * eval bindings and an agent-invocation closure — all of which the
65
- * binding assembles from `input.datasetId` / `input.datasetVersion`
66
- * and its own runtime wiring. Returns the updated proposal (`dry-run-passed` or
67
- * `dry-run-failed`) or a discriminated error outcome so the route
68
- * can map `invalid-transition` → `409` without touching the runtime
69
- * error union directly.
37
+ * Record a step on a proposal if it's still at `expectRevision`; the
38
+ * row's revision goes up by one. `conflict` when another call recorded
39
+ * a step first: the caller reads it again.
70
40
  */
71
- dryRunProposal(input: SupervisorDryRunProposalInput): Promise<SupervisorDryRunOutcome>;
72
- /**
73
- * Submit an approved dry-run proposal for HITL review. The binding
74
- * forwards the resolved `Supervisor` (for ground-layer enforcement +
75
- * meta-fix detection) and enqueues the approval. Returns the updated proposal (in
76
- * `proposed-for-review` state) plus the created approval id so the
77
- * route can surface it in the response body (the SDK correlates
78
- * proposal → approval via that id).
79
- */
80
- submitReview(input: SupervisorSubmitReviewInput): Promise<SupervisorSubmitReviewOutcome>;
81
- /**
82
- * Apply an `approved` proposal — registers a new agent version.
83
- * Returns a minimal ack shape
84
- * (`proposalId`, `appliedVersion`, `appliedAt`) rather than the
85
- * full runtime result — the route body stays lean; callers who
86
- * need the full `Agent` snapshot can `GET /v1/agents/:agentId`.
87
- */
88
- applyProposal(input: SupervisorApplyProposalInput): Promise<SupervisorApplyOutcome>;
89
- /**
90
- * Roll back an `applied` proposal — unregisters the applied
91
- * version from the agent registry + transitions to `rolled-back`.
92
- */
93
- rollbackProposal(input: SupervisorRollbackProposalInput): Promise<SupervisorRollbackOutcome>;
94
- /**
95
- * Withdraw a non-terminal proposal. Legal from any of
96
- * `draft | dry-running | dry-run-passed | dry-run-failed |
97
- * proposed-for-review`. Terminal states surface as
98
- * `invalid-transition` (which the route maps to 409).
99
- */
100
- withdrawProposal(input: SupervisorWithdrawProposalInput): Promise<SupervisorWithdrawOutcome>;
41
+ recordProposal(input: RecordProposalInput): Promise<RecordProposalOutcome>;
101
42
  /**
102
43
  * Cursor-paginated observation readback for `/v1/observations`.
103
44
  * Tenant-scoped; supervisor/agent/conversation/time-window filters
@@ -108,94 +49,181 @@ export interface SupervisorBinding {
108
49
  */
109
50
  queryObservations(input: SupervisorQueryObservationsInput): Promise<SupervisorQueryObservationsOutcome>;
110
51
  }
111
- export interface SupervisorListProposalsInput {
112
- readonly tenantId: TenantId;
113
- readonly supervisorId: SupervisorId;
114
- readonly limit: number;
115
- readonly cursor?: Cursor;
116
- readonly status?: FixProposalStatus;
117
- readonly agentId?: AgentId;
118
- readonly tier?: ProposedChange['tier'];
119
- /**
120
- * Narrow the list to a specific scope. Absent = no scope narrow
121
- * (return every row in the tenant the caller can see — admin/audit
122
- * default).
123
- *
124
- * Content-scoped semantics (this binding — fix-proposals attribute
125
- * to the project of the agent they target):
126
- * - `{ kind: 'project', projectId }` — rows in that project.
127
- * - `{ kind: 'org', orgId }` — rows in every project belonging to
128
- * that org.
129
- * - `{ kind: 'tenant', tenantId }` — every row in the tenant.
130
- *
131
- * Proposals are content: every row belongs to a project, so `inherit`
132
- * has no effect here.
133
- */
134
- readonly scope?: Scope;
135
- /**
136
- * `false` = literal-at-this-scope only (admin/audit view).
137
- * `true` (default) = inheritance walk (user-facing view).
138
- * No-op for content-scoped bindings (rows only exist at
139
- * project-level — there is no upward hierarchy to walk). Kept for
140
- * uniformity: scope-aware bindings share one filter shape across the
141
- * SDK and OpenAPI schemas.
142
- */
143
- readonly inherit?: boolean;
52
+ /** What a proposal changes: a data block the agent version pins. */
53
+ export type ProposalTier = 'settings-block' | 'prompt-block';
54
+ /**
55
+ * The change: one block, from the version the agent version pins, to new
56
+ * content. Settings proposals give new `values` (the schema carries
57
+ * over); prompt proposals give a new `template` (the parameters carry
58
+ * over).
59
+ */
60
+ export type ProposedChange = {
61
+ readonly tier: 'settings-block';
62
+ readonly change: {
63
+ readonly blockId: string;
64
+ readonly fromVersion: string;
65
+ readonly content: {
66
+ readonly values: Readonly<Record<string, unknown>>;
67
+ };
68
+ };
69
+ } | {
70
+ readonly tier: 'prompt-block';
71
+ readonly change: {
72
+ readonly blockId: string;
73
+ readonly fromVersion: string;
74
+ readonly content: {
75
+ readonly template: string;
76
+ };
77
+ };
78
+ };
79
+ /** Who wrote a proposal: a person, or one of the runtime's drafters. */
80
+ export type ProposalDrafter = {
81
+ readonly kind: 'person';
82
+ readonly by: string;
83
+ } | {
84
+ readonly kind: 'settings-optimizer' | 'prompt-drafter';
85
+ readonly version: string;
86
+ readonly model?: {
87
+ readonly providerId: string;
88
+ readonly model: string;
89
+ };
90
+ /** The improvement pass that drafted it. */
91
+ readonly passId?: string;
92
+ };
93
+ /** What a proposal rests on. */
94
+ export interface ProposalEvidence {
95
+ /** The judgments that motivated it. */
96
+ readonly judgmentIds?: readonly string[];
144
97
  }
145
- export interface SupervisorGetProposalInput {
146
- readonly tenantId: TenantId;
147
- readonly supervisorId: SupervisorId;
148
- readonly proposalId: FixProposalId;
98
+ /** The versions evaluating a proposal published: inert until a promotion makes them live. */
99
+ export interface ProposalCandidate {
100
+ /** The derived agent version (`derivedFrom.proposalId` names this proposal). */
101
+ readonly agentVersion: string;
102
+ /** The block version published from the proposal's content. */
103
+ readonly blockVersion: string;
104
+ readonly pinsDigest: string;
105
+ }
106
+ /** The metric that says whether a candidate is better. */
107
+ export type ProposalObjective = 'weightedYesShare' | 'weightedPrecisionAtK';
108
+ /** The comparison a proposal was evaluated with. */
109
+ export interface ProposalEvaluationRef {
110
+ readonly evalRunId: string;
111
+ readonly suiteId: string;
112
+ readonly objective: ProposalObjective;
113
+ readonly startedAt: Timestamp;
149
114
  }
150
- export interface SupervisorDraftProposalInput {
115
+ /** A proposal as the binding stores it (no status: that's derived). */
116
+ export interface StoredProposal {
117
+ readonly id: FixProposalId;
151
118
  readonly tenantId: TenantId;
152
- readonly supervisorId: SupervisorId;
119
+ /** The agent version's project, when known. */
120
+ readonly projectId?: ProjectId;
153
121
  readonly agentId: AgentId;
154
- readonly agentVersion: string;
155
- readonly tier: ProposedChange['tier'];
122
+ /** The agent version the change applies to. */
123
+ readonly fromVersion: string;
124
+ /** The live scope it's for. */
125
+ readonly scope: LiveScope;
126
+ readonly tier: ProposalTier;
156
127
  readonly change: ProposedChange['change'];
157
- readonly patternRefs: readonly PatternRef[];
158
128
  readonly hypothesis: string;
159
- readonly proposerRuleId: string;
129
+ readonly evidence?: ProposalEvidence;
130
+ readonly drafter: ProposalDrafter;
131
+ /** Dedup key: the same change for the same scope is one proposal. */
132
+ readonly fingerprint: string;
133
+ /** Goes up by one with each recorded step. */
134
+ readonly revision: number;
135
+ readonly candidate?: ProposalCandidate;
136
+ readonly evaluation?: ProposalEvaluationRef;
137
+ /** The promotion its request made (the latest, after a re-request). */
138
+ readonly promotionId?: string;
139
+ readonly rolledBack?: {
140
+ readonly at: Timestamp;
141
+ /** The rollback's own promotion row. */
142
+ readonly promotionId: string;
143
+ readonly by: string;
144
+ readonly reason?: string;
145
+ };
146
+ readonly withdrawn?: {
147
+ readonly at: Timestamp;
148
+ readonly by: string;
149
+ readonly reason: string;
150
+ };
151
+ readonly createdAt: Timestamp;
152
+ readonly updatedAt: Timestamp;
160
153
  }
161
- export interface SupervisorDryRunProposalInput {
154
+ export interface ListProposalsInput {
162
155
  readonly tenantId: TenantId;
163
- readonly supervisorId: SupervisorId;
164
- readonly proposalId: FixProposalId;
165
- /**
166
- * Dataset the binding uses for the dry-run.
167
- * The wire carries just `(datasetId, datasetVersion)` — the binding
168
- * resolves both to the actual `Dataset<TInput, TExpected>` from its
169
- * own registry.
170
- */
171
- readonly datasetId: string;
172
- readonly datasetVersion: string;
173
- readonly criterion: PassCriterion;
156
+ readonly limit: number;
157
+ readonly cursor?: Cursor;
158
+ readonly agentId?: AgentId;
159
+ readonly tier?: ProposalTier;
160
+ /** Only proposals for exactly this live scope. */
161
+ readonly liveScope?: LiveScope;
174
162
  }
175
- export interface SupervisorSubmitReviewInput {
163
+ export interface GetProposalInput {
176
164
  readonly tenantId: TenantId;
177
- readonly supervisorId: SupervisorId;
178
165
  readonly proposalId: FixProposalId;
179
- readonly requiredRole?: 'standard' | 'senior' | 'admin';
180
- readonly expiresAt?: Timestamp;
181
166
  }
182
- export interface SupervisorApplyProposalInput {
167
+ export interface CreateProposalInput {
183
168
  readonly tenantId: TenantId;
184
- readonly supervisorId: SupervisorId;
185
- readonly proposalId: FixProposalId;
186
- readonly newVersion?: string;
169
+ /** The agent version's project, when the agent store records one: what a scoped list narrows by. */
170
+ readonly projectId?: ProjectId;
171
+ readonly agentId: AgentId;
172
+ readonly fromVersion: string;
173
+ readonly scope: LiveScope;
174
+ readonly tier: ProposalTier;
175
+ readonly change: ProposedChange['change'];
176
+ readonly hypothesis: string;
177
+ readonly evidence?: ProposalEvidence;
178
+ readonly drafter: ProposalDrafter;
179
+ readonly fingerprint: string;
187
180
  }
188
- export interface SupervisorRollbackProposalInput {
181
+ export type CreateProposalOutcome = {
182
+ readonly kind: 'ok';
183
+ readonly proposal: StoredProposal;
184
+ } | {
185
+ readonly kind: 'dedup';
186
+ readonly proposal: StoredProposal;
187
+ };
188
+ /**
189
+ * One step's outcome, recorded on the proposal. An `evaluation` replaces
190
+ * the one before and clears `promotionId`: a new comparison starts the
191
+ * request over. A `candidate` is recorded once.
192
+ */
193
+ export type ProposalStep = {
194
+ readonly kind: 'candidate';
195
+ readonly candidate: ProposalCandidate;
196
+ } | {
197
+ readonly kind: 'evaluation';
198
+ readonly evaluation: ProposalEvaluationRef;
199
+ } | {
200
+ readonly kind: 'promotion';
201
+ readonly promotionId: string;
202
+ } | {
203
+ readonly kind: 'rolled-back';
204
+ readonly rolledBack: NonNullable<StoredProposal['rolledBack']>;
205
+ } | {
206
+ readonly kind: 'withdrawn';
207
+ readonly withdrawn: NonNullable<StoredProposal['withdrawn']>;
208
+ };
209
+ export interface RecordProposalInput {
189
210
  readonly tenantId: TenantId;
190
- readonly supervisorId: SupervisorId;
191
211
  readonly proposalId: FixProposalId;
192
- readonly reason: string;
212
+ readonly expectRevision: number;
213
+ readonly step: ProposalStep;
193
214
  }
194
- export interface SupervisorWithdrawProposalInput {
195
- readonly tenantId: TenantId;
196
- readonly supervisorId: SupervisorId;
197
- readonly proposalId: FixProposalId;
198
- readonly reason: string;
215
+ export type RecordProposalOutcome = {
216
+ readonly kind: 'ok';
217
+ readonly proposal: StoredProposal;
218
+ } | {
219
+ readonly kind: 'not-found';
220
+ } | {
221
+ readonly kind: 'conflict';
222
+ readonly proposal: StoredProposal;
223
+ };
224
+ export interface StoredProposalPage {
225
+ readonly data: readonly StoredProposal[];
226
+ readonly nextCursor?: Cursor;
199
227
  }
200
228
  /**
201
229
  * Observation readback filter. Tenant-scoped; every other filter is
@@ -215,132 +243,6 @@ export interface SupervisorQueryObservationsInput {
215
243
  readonly since?: Timestamp;
216
244
  readonly until?: Timestamp;
217
245
  }
218
- export interface SupervisorProposalPage {
219
- readonly data: readonly FixProposal[];
220
- readonly nextCursor?: Cursor;
221
- }
222
- /**
223
- * Result of a draft attempt. Deduplication is by
224
- * `(supervisorId, fingerprint)`:
225
- *
226
- * - `ok` — a new draft row was inserted.
227
- * - `dedup` — an existing non-terminal proposal has the same
228
- * fingerprint; caller can treat it as their own
229
- * draft. `proposal` is the pre-existing row.
230
- */
231
- export type SupervisorDraftOutcome = {
232
- readonly kind: 'ok';
233
- readonly proposal: FixProposal;
234
- } | {
235
- readonly kind: 'dedup';
236
- readonly proposal: FixProposal;
237
- };
238
- /**
239
- * Result of a dry-run attempt. `ok` carries the updated proposal
240
- * (either `dry-run-passed` or `dry-run-failed` — both are legitimate
241
- * outcomes; `failed` means "the criterion was not met," not "the
242
- * request errored"). Failure outcomes surface as discriminated errors
243
- * the route layer maps to specific HTTP statuses.
244
- */
245
- export type SupervisorDryRunOutcome = {
246
- readonly kind: 'ok';
247
- readonly proposal: FixProposal;
248
- readonly passed: boolean;
249
- } | {
250
- readonly kind: 'not-found';
251
- readonly proposalId: FixProposalId;
252
- } | {
253
- readonly kind: 'invalid-transition';
254
- readonly proposalId: FixProposalId;
255
- readonly from: FixProposalStatus;
256
- readonly to: FixProposalStatus;
257
- } | {
258
- /**
259
- * Wire back `apply-change-failed` (change couldn't be applied
260
- * against the current baseline), `baseline-mismatch` (proposal
261
- * targets a stale version), or any other runtime failure. The
262
- * route maps the code through `statusFor`: the two named codes are
263
- * `422 unprocessable` (the request was well-formed but the domain
264
- * state prevents dry-running); unknown codes are `500`.
265
- */
266
- readonly kind: 'runtime-error';
267
- readonly code: string;
268
- readonly message: string;
269
- };
270
- export type SupervisorSubmitReviewOutcome = {
271
- readonly kind: 'ok';
272
- readonly proposal: FixProposal;
273
- readonly approvalId: ApprovalId;
274
- readonly metaFix: boolean;
275
- } | {
276
- readonly kind: 'not-found';
277
- readonly proposalId: FixProposalId;
278
- } | {
279
- readonly kind: 'invalid-transition';
280
- readonly proposalId: FixProposalId;
281
- readonly from: FixProposalStatus;
282
- readonly to: FixProposalStatus;
283
- } | {
284
- readonly kind: 'ground-layer-violation';
285
- readonly proposalId: FixProposalId;
286
- readonly guardrailId: string;
287
- readonly reason: string;
288
- } | {
289
- readonly kind: 'runtime-error';
290
- readonly code: string;
291
- readonly message: string;
292
- };
293
- export type SupervisorApplyOutcome = {
294
- readonly kind: 'ok';
295
- readonly proposalId: FixProposalId;
296
- readonly appliedVersion: string;
297
- readonly appliedAt: Timestamp;
298
- } | {
299
- readonly kind: 'not-found';
300
- readonly proposalId: FixProposalId;
301
- } | {
302
- readonly kind: 'invalid-transition';
303
- readonly proposalId: FixProposalId;
304
- readonly from: FixProposalStatus;
305
- readonly to: FixProposalStatus;
306
- } | {
307
- readonly kind: 'runtime-error';
308
- readonly code: string;
309
- readonly message: string;
310
- };
311
- export type SupervisorRollbackOutcome = {
312
- readonly kind: 'ok';
313
- readonly proposalId: FixProposalId;
314
- readonly rolledBackAt: Timestamp;
315
- } | {
316
- readonly kind: 'not-found';
317
- readonly proposalId: FixProposalId;
318
- } | {
319
- readonly kind: 'invalid-transition';
320
- readonly proposalId: FixProposalId;
321
- readonly from: FixProposalStatus;
322
- readonly to: FixProposalStatus;
323
- } | {
324
- readonly kind: 'runtime-error';
325
- readonly code: string;
326
- readonly message: string;
327
- };
328
- export type SupervisorWithdrawOutcome = {
329
- readonly kind: 'ok';
330
- readonly proposal: FixProposal;
331
- } | {
332
- readonly kind: 'not-found';
333
- readonly proposalId: FixProposalId;
334
- } | {
335
- readonly kind: 'invalid-transition';
336
- readonly proposalId: FixProposalId;
337
- readonly from: FixProposalStatus;
338
- readonly to: FixProposalStatus;
339
- } | {
340
- readonly kind: 'runtime-error';
341
- readonly code: string;
342
- readonly message: string;
343
- };
344
246
  export interface SupervisorObservationPage {
345
247
  readonly data: readonly Observation[];
346
248
  readonly nextCursor?: Cursor;
@@ -353,135 +255,6 @@ export type SupervisorQueryObservationsOutcome = {
353
255
  readonly code: string;
354
256
  readonly message: string;
355
257
  };
356
- /**
357
- * Lifecycle of a fix proposal.
358
- *
359
- * `draft` — initial state after `POST /v1/proposals`.
360
- * `dry-running` — transient state while a dry-run executes.
361
- * `dry-run-passed` / `dry-run-failed` — dry-run terminated with a
362
- * criterion result. `failed` is a legitimate domain outcome, not an
363
- * error.
364
- * `proposed-for-review` — submitted for HITL. `reviewApprovalId` is set.
365
- * `approved` / `rejected` — HITL terminal states.
366
- * `applied` — the change materialized. `appliedVersion` + `appliedAt` set.
367
- * `rolled-back` — a prior `applied` proposal was undone.
368
- * `withdrawn` — the caller withdrew the proposal before terminal review.
369
- */
370
- export type FixProposalStatus = 'draft' | 'dry-running' | 'dry-run-passed' | 'dry-run-failed' | 'proposed-for-review' | 'approved' | 'rejected' | 'applied' | 'rolled-back' | 'withdrawn';
371
- /** The aggregated fingerprint kind for a failure pattern. */
372
- export type PatternKind = 'guardrail-violation' | 'tool-error' | 'budget-exceeded' | 'model-error' | 'aborted';
373
- /**
374
- * A change to an agent's prompt (the `instructions` string). Three
375
- * kinds cover the common shapes. Extensible via the `kind` discriminant.
376
- */
377
- export type PromptChange = {
378
- readonly kind: 'append';
379
- readonly text: string;
380
- } | {
381
- readonly kind: 'replace-section';
382
- readonly section: string;
383
- readonly newText: string;
384
- } | {
385
- readonly kind: 'replace';
386
- readonly beforeText: string;
387
- readonly afterText: string;
388
- };
389
- /**
390
- * A retrieval intent — mirror of `Agent.retrieval[]` shape.
391
- */
392
- export interface RetrievalIntentShape {
393
- readonly types: readonly string[];
394
- readonly scope: 'same-conversation' | 'same-project' | 'tenant';
395
- readonly limit?: number;
396
- }
397
- export type RetrievalChange = {
398
- readonly kind: 'add-intent';
399
- readonly intent: RetrievalIntentShape;
400
- } | {
401
- readonly kind: 'remove-intent';
402
- readonly index: number;
403
- } | {
404
- readonly kind: 'replace-intent';
405
- readonly index: number;
406
- readonly intent: RetrievalIntentShape;
407
- } | {
408
- readonly kind: 'update-limit';
409
- readonly index: number;
410
- readonly limit: number;
411
- };
412
- export type ToolConfigChange = {
413
- readonly kind: 'add-tool';
414
- readonly toolId: string;
415
- readonly toolVersion: string;
416
- } | {
417
- readonly kind: 'remove-tool';
418
- readonly toolId: string;
419
- } | {
420
- readonly kind: 'set-tools';
421
- readonly tools: readonly {
422
- readonly id: string;
423
- readonly version: string;
424
- }[];
425
- };
426
- /**
427
- * The change payload — polymorphic over tier.
428
- */
429
- export type ProposedChange = {
430
- readonly tier: 'prompt';
431
- readonly change: PromptChange;
432
- } | {
433
- readonly tier: 'retrieval';
434
- readonly change: RetrievalChange;
435
- } | {
436
- readonly tier: 'tool-config';
437
- readonly change: ToolConfigChange;
438
- };
439
- /**
440
- * A reference to a failure pattern that motivated a proposal.
441
- */
442
- export interface PatternRef {
443
- readonly kind: PatternKind;
444
- readonly key: string;
445
- readonly count: number;
446
- readonly firstSeenAt: Timestamp;
447
- readonly lastSeenAt: Timestamp;
448
- readonly sampleConversations: readonly RunId[];
449
- }
450
- /**
451
- * A fix proposal drafted by the supervisor. Every field is declared here
452
- * so the API package does not depend on the supervisor runtime's types.
453
- */
454
- export interface FixProposal {
455
- readonly id: FixProposalId;
456
- readonly tenantId: TenantId;
457
- readonly supervisorId: SupervisorId;
458
- readonly agentId: AgentId;
459
- readonly agentVersion: string;
460
- readonly tier: ProposedChange['tier'];
461
- readonly change: ProposedChange['change'];
462
- readonly patternRefs: readonly PatternRef[];
463
- readonly hypothesis: string;
464
- readonly proposerRuleId: string;
465
- readonly status: FixProposalStatus;
466
- readonly fingerprint: string;
467
- readonly resolutionReason?: string;
468
- readonly reviewApprovalId?: ApprovalId;
469
- readonly appliedVersion?: string;
470
- readonly appliedAt?: Timestamp;
471
- readonly rolledBackAt?: Timestamp;
472
- readonly createdAt: Timestamp;
473
- readonly updatedAt: Timestamp;
474
- readonly resolvedAt?: Timestamp;
475
- }
476
- /** Dry-run pass criterion. */
477
- export type PassCriterion = {
478
- readonly kind: 'min-pass-rate';
479
- readonly minPassRate: number;
480
- } | {
481
- readonly kind: 'strict-improvement';
482
- readonly baselinePassRate: number;
483
- readonly minDelta: number;
484
- };
485
258
  /**
486
259
  * Classified outcome of an observed turn. The observations route
487
260
  * validates the query param against this union.