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