@kindgi/api 0.1.4 → 0.1.5

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 (516) 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/cost-binding.d.ts +19 -0
  21. package/dist/cost-binding.d.ts.map +1 -1
  22. package/dist/cost-binding.js.map +1 -1
  23. package/dist/derive-agent-version.d.ts +7 -0
  24. package/dist/derive-agent-version.d.ts.map +1 -1
  25. package/dist/derive-agent-version.js +4 -0
  26. package/dist/derive-agent-version.js.map +1 -1
  27. package/dist/errors.d.ts.map +1 -1
  28. package/dist/errors.js +75 -7
  29. package/dist/errors.js.map +1 -1
  30. package/dist/eval-case-binding.d.ts +16 -4
  31. package/dist/eval-case-binding.d.ts.map +1 -1
  32. package/dist/eval-run-binding.d.ts +31 -0
  33. package/dist/eval-run-binding.d.ts.map +1 -1
  34. package/dist/eval-run-dispatcher.d.ts +7 -0
  35. package/dist/eval-run-dispatcher.d.ts.map +1 -1
  36. package/dist/eval-run-dispatcher.js.map +1 -1
  37. package/dist/eval-sample.d.ts +11 -0
  38. package/dist/eval-sample.d.ts.map +1 -0
  39. package/dist/eval-sample.js +34 -0
  40. package/dist/eval-sample.js.map +1 -0
  41. package/dist/eval-suite-binding.d.ts +13 -0
  42. package/dist/eval-suite-binding.d.ts.map +1 -1
  43. package/dist/eval-suite-binding.js.map +1 -1
  44. package/dist/flow-binding.d.ts +18 -0
  45. package/dist/flow-binding.d.ts.map +1 -1
  46. package/dist/flow-pins.d.ts.map +1 -1
  47. package/dist/flow-pins.js +18 -2
  48. package/dist/flow-pins.js.map +1 -1
  49. package/dist/gate.d.ts.map +1 -1
  50. package/dist/gate.js +25 -0
  51. package/dist/gate.js.map +1 -1
  52. package/dist/handler-binding.d.ts +32 -0
  53. package/dist/handler-binding.d.ts.map +1 -1
  54. package/dist/hitl-binding.d.ts +23 -0
  55. package/dist/hitl-binding.d.ts.map +1 -1
  56. package/dist/identity-directory-binding.d.ts +82 -4
  57. package/dist/identity-directory-binding.d.ts.map +1 -1
  58. package/dist/identity-provider-binding.d.ts +197 -17
  59. package/dist/identity-provider-binding.d.ts.map +1 -1
  60. package/dist/improvement-pass-binding.d.ts +196 -0
  61. package/dist/improvement-pass-binding.d.ts.map +1 -0
  62. package/dist/improvement-pass-binding.js +9 -0
  63. package/dist/improvement-pass-binding.js.map +1 -0
  64. package/dist/index.d.ts +35 -17
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +11 -3
  67. package/dist/index.js.map +1 -1
  68. package/dist/judged-dispatcher.d.ts +25 -4
  69. package/dist/judged-dispatcher.d.ts.map +1 -1
  70. package/dist/judged-dispatcher.js +43 -6
  71. package/dist/judged-dispatcher.js.map +1 -1
  72. package/dist/judgment-binding.d.ts +25 -1
  73. package/dist/judgment-binding.d.ts.map +1 -1
  74. package/dist/mcp-endpoint-binding.d.ts +7 -0
  75. package/dist/mcp-endpoint-binding.d.ts.map +1 -1
  76. package/dist/memory-binding.d.ts +124 -17
  77. package/dist/memory-binding.d.ts.map +1 -1
  78. package/dist/memory-erasure-binding.d.ts +145 -0
  79. package/dist/memory-erasure-binding.d.ts.map +1 -0
  80. package/dist/memory-erasure-binding.js +4 -0
  81. package/dist/memory-erasure-binding.js.map +1 -0
  82. package/dist/middleware/auth.d.ts +66 -13
  83. package/dist/middleware/auth.d.ts.map +1 -1
  84. package/dist/middleware/auth.js +150 -50
  85. package/dist/middleware/auth.js.map +1 -1
  86. package/dist/middleware/authorize.d.ts +9 -0
  87. package/dist/middleware/authorize.d.ts.map +1 -1
  88. package/dist/middleware/authorize.js +122 -4
  89. package/dist/middleware/authorize.js.map +1 -1
  90. package/dist/middleware/error-mapper.d.ts +5 -0
  91. package/dist/middleware/error-mapper.d.ts.map +1 -1
  92. package/dist/middleware/error-mapper.js +14 -1
  93. package/dist/middleware/error-mapper.js.map +1 -1
  94. package/dist/middleware/idempotency.d.ts +70 -5
  95. package/dist/middleware/idempotency.d.ts.map +1 -1
  96. package/dist/middleware/idempotency.js +174 -41
  97. package/dist/middleware/idempotency.js.map +1 -1
  98. package/dist/middleware/key-project.d.ts +17 -0
  99. package/dist/middleware/key-project.d.ts.map +1 -0
  100. package/dist/middleware/key-project.js +75 -0
  101. package/dist/middleware/key-project.js.map +1 -0
  102. package/dist/middleware/principal.d.ts.map +1 -1
  103. package/dist/middleware/principal.js +9 -5
  104. package/dist/middleware/principal.js.map +1 -1
  105. package/dist/middleware/project-ref.d.ts.map +1 -1
  106. package/dist/middleware/project-ref.js +3 -0
  107. package/dist/middleware/project-ref.js.map +1 -1
  108. package/dist/openapi/generate.d.ts.map +1 -1
  109. package/dist/openapi/generate.js +5 -2
  110. package/dist/openapi/generate.js.map +1 -1
  111. package/dist/openapi/operations.d.ts.map +1 -1
  112. package/dist/openapi/operations.js +919 -140
  113. package/dist/openapi/operations.js.map +1 -1
  114. package/dist/openapi/schemas.d.ts +90 -13
  115. package/dist/openapi/schemas.d.ts.map +1 -1
  116. package/dist/openapi/schemas.js +2081 -359
  117. package/dist/openapi/schemas.js.map +1 -1
  118. package/dist/person-grants-binding.d.ts +77 -0
  119. package/dist/person-grants-binding.d.ts.map +1 -0
  120. package/dist/person-grants-binding.js +4 -0
  121. package/dist/person-grants-binding.js.map +1 -0
  122. package/dist/proposal-service.d.ts +121 -0
  123. package/dist/proposal-service.d.ts.map +1 -0
  124. package/dist/proposal-service.js +447 -0
  125. package/dist/proposal-service.js.map +1 -0
  126. package/dist/proposal-status.d.ts +60 -0
  127. package/dist/proposal-status.d.ts.map +1 -0
  128. package/dist/proposal-status.js +109 -0
  129. package/dist/proposal-status.js.map +1 -0
  130. package/dist/provider-binding.d.ts +10 -0
  131. package/dist/provider-binding.d.ts.map +1 -1
  132. package/dist/publish-refused.d.ts +28 -3
  133. package/dist/publish-refused.d.ts.map +1 -1
  134. package/dist/publish-refused.js +24 -3
  135. package/dist/publish-refused.js.map +1 -1
  136. package/dist/routes/adapters.d.ts +2 -1
  137. package/dist/routes/adapters.d.ts.map +1 -1
  138. package/dist/routes/adapters.js +3 -1
  139. package/dist/routes/adapters.js.map +1 -1
  140. package/dist/routes/agent-releases.d.ts +55 -3
  141. package/dist/routes/agent-releases.d.ts.map +1 -1
  142. package/dist/routes/agent-releases.js +85 -55
  143. package/dist/routes/agent-releases.js.map +1 -1
  144. package/dist/routes/agents.d.ts +12 -1
  145. package/dist/routes/agents.d.ts.map +1 -1
  146. package/dist/routes/agents.js +100 -2
  147. package/dist/routes/agents.js.map +1 -1
  148. package/dist/routes/approvals.d.ts +15 -3
  149. package/dist/routes/approvals.d.ts.map +1 -1
  150. package/dist/routes/approvals.js +133 -122
  151. package/dist/routes/approvals.js.map +1 -1
  152. package/dist/routes/artifacts.d.ts +25 -3
  153. package/dist/routes/artifacts.d.ts.map +1 -1
  154. package/dist/routes/artifacts.js +116 -7
  155. package/dist/routes/artifacts.js.map +1 -1
  156. package/dist/routes/auth.d.ts +25 -1
  157. package/dist/routes/auth.d.ts.map +1 -1
  158. package/dist/routes/auth.js +655 -281
  159. package/dist/routes/auth.js.map +1 -1
  160. package/dist/routes/blocks.d.ts.map +1 -1
  161. package/dist/routes/blocks.js +2 -42
  162. package/dist/routes/blocks.js.map +1 -1
  163. package/dist/routes/capabilities.d.ts +2 -1
  164. package/dist/routes/capabilities.d.ts.map +1 -1
  165. package/dist/routes/capabilities.js +6 -1
  166. package/dist/routes/capabilities.js.map +1 -1
  167. package/dist/routes/compliance.d.ts +9 -10
  168. package/dist/routes/compliance.d.ts.map +1 -1
  169. package/dist/routes/compliance.js +42 -61
  170. package/dist/routes/compliance.js.map +1 -1
  171. package/dist/routes/conversations.d.ts +8 -1
  172. package/dist/routes/conversations.d.ts.map +1 -1
  173. package/dist/routes/conversations.js +87 -8
  174. package/dist/routes/conversations.js.map +1 -1
  175. package/dist/routes/cost.d.ts +12 -1
  176. package/dist/routes/cost.d.ts.map +1 -1
  177. package/dist/routes/cost.js +74 -3
  178. package/dist/routes/cost.js.map +1 -1
  179. package/dist/routes/denied.d.ts +11 -0
  180. package/dist/routes/denied.d.ts.map +1 -0
  181. package/dist/routes/denied.js +17 -0
  182. package/dist/routes/denied.js.map +1 -0
  183. package/dist/routes/deployments.d.ts +10 -1
  184. package/dist/routes/deployments.d.ts.map +1 -1
  185. package/dist/routes/deployments.js +171 -13
  186. package/dist/routes/deployments.js.map +1 -1
  187. package/dist/routes/eval-comparison.d.ts.map +1 -1
  188. package/dist/routes/eval-comparison.js +69 -1
  189. package/dist/routes/eval-comparison.js.map +1 -1
  190. package/dist/routes/eval-overrides.d.ts +18 -0
  191. package/dist/routes/eval-overrides.d.ts.map +1 -0
  192. package/dist/routes/eval-overrides.js +81 -0
  193. package/dist/routes/eval-overrides.js.map +1 -0
  194. package/dist/routes/eval-runs.d.ts +10 -1
  195. package/dist/routes/eval-runs.d.ts.map +1 -1
  196. package/dist/routes/eval-runs.js +66 -7
  197. package/dist/routes/eval-runs.js.map +1 -1
  198. package/dist/routes/eval-suites.d.ts.map +1 -1
  199. package/dist/routes/eval-suites.js +28 -2
  200. package/dist/routes/eval-suites.js.map +1 -1
  201. package/dist/routes/event-triggers.d.ts +5 -1
  202. package/dist/routes/event-triggers.d.ts.map +1 -1
  203. package/dist/routes/event-triggers.js +26 -3
  204. package/dist/routes/event-triggers.js.map +1 -1
  205. package/dist/routes/export-signing-keys.d.ts +12 -0
  206. package/dist/routes/export-signing-keys.d.ts.map +1 -0
  207. package/dist/routes/export-signing-keys.js +24 -0
  208. package/dist/routes/export-signing-keys.js.map +1 -0
  209. package/dist/routes/flows.d.ts.map +1 -1
  210. package/dist/routes/flows.js +9 -1
  211. package/dist/routes/flows.js.map +1 -1
  212. package/dist/routes/gate-policies.d.ts +4 -1
  213. package/dist/routes/gate-policies.d.ts.map +1 -1
  214. package/dist/routes/gate-policies.js +29 -5
  215. package/dist/routes/gate-policies.js.map +1 -1
  216. package/dist/routes/guardrails.d.ts +16 -14
  217. package/dist/routes/guardrails.d.ts.map +1 -1
  218. package/dist/routes/guardrails.js +39 -3
  219. package/dist/routes/guardrails.js.map +1 -1
  220. package/dist/routes/identity.d.ts +20 -4
  221. package/dist/routes/identity.d.ts.map +1 -1
  222. package/dist/routes/identity.js +246 -6
  223. package/dist/routes/identity.js.map +1 -1
  224. package/dist/routes/improvement-passes.d.ts +52 -0
  225. package/dist/routes/improvement-passes.d.ts.map +1 -0
  226. package/dist/routes/improvement-passes.js +449 -0
  227. package/dist/routes/improvement-passes.js.map +1 -0
  228. package/dist/routes/judged-suites.d.ts +50 -0
  229. package/dist/routes/judged-suites.d.ts.map +1 -1
  230. package/dist/routes/judged-suites.js +66 -27
  231. package/dist/routes/judged-suites.js.map +1 -1
  232. package/dist/routes/judgment-context.d.ts +18 -2
  233. package/dist/routes/judgment-context.d.ts.map +1 -1
  234. package/dist/routes/judgment-context.js +63 -5
  235. package/dist/routes/judgment-context.js.map +1 -1
  236. package/dist/routes/judgment-flow-context.d.ts.map +1 -1
  237. package/dist/routes/judgment-flow-context.js +14 -2
  238. package/dist/routes/judgment-flow-context.js.map +1 -1
  239. package/dist/routes/judgments.d.ts.map +1 -1
  240. package/dist/routes/judgments.js +8 -1
  241. package/dist/routes/judgments.js.map +1 -1
  242. package/dist/routes/mcp.d.ts.map +1 -1
  243. package/dist/routes/mcp.js +26 -1
  244. package/dist/routes/mcp.js.map +1 -1
  245. package/dist/routes/memory-access.d.ts +43 -0
  246. package/dist/routes/memory-access.d.ts.map +1 -0
  247. package/dist/routes/memory-access.js +114 -0
  248. package/dist/routes/memory-access.js.map +1 -0
  249. package/dist/routes/memory-erasures.d.ts +25 -0
  250. package/dist/routes/memory-erasures.d.ts.map +1 -0
  251. package/dist/routes/memory-erasures.js +214 -0
  252. package/dist/routes/memory-erasures.js.map +1 -0
  253. package/dist/routes/memory-parse.d.ts +38 -0
  254. package/dist/routes/memory-parse.d.ts.map +1 -0
  255. package/dist/routes/memory-parse.js +199 -0
  256. package/dist/routes/memory-parse.js.map +1 -0
  257. package/dist/routes/memory.d.ts +9 -4
  258. package/dist/routes/memory.d.ts.map +1 -1
  259. package/dist/routes/memory.js +226 -234
  260. package/dist/routes/memory.js.map +1 -1
  261. package/dist/routes/observations.d.ts +4 -1
  262. package/dist/routes/observations.d.ts.map +1 -1
  263. package/dist/routes/observations.js +8 -2
  264. package/dist/routes/observations.js.map +1 -1
  265. package/dist/routes/pagination.d.ts +7 -0
  266. package/dist/routes/pagination.d.ts.map +1 -1
  267. package/dist/routes/pagination.js +10 -0
  268. package/dist/routes/pagination.js.map +1 -1
  269. package/dist/routes/policies.d.ts +2 -1
  270. package/dist/routes/policies.d.ts.map +1 -1
  271. package/dist/routes/policies.js +3 -1
  272. package/dist/routes/policies.js.map +1 -1
  273. package/dist/routes/project-mismatch.d.ts +22 -0
  274. package/dist/routes/project-mismatch.d.ts.map +1 -0
  275. package/dist/routes/project-mismatch.js +34 -0
  276. package/dist/routes/project-mismatch.js.map +1 -0
  277. package/dist/routes/projects.d.ts +15 -4
  278. package/dist/routes/projects.d.ts.map +1 -1
  279. package/dist/routes/projects.js +100 -9
  280. package/dist/routes/projects.js.map +1 -1
  281. package/dist/routes/proposals.d.ts +25 -17
  282. package/dist/routes/proposals.d.ts.map +1 -1
  283. package/dist/routes/proposals.js +340 -507
  284. package/dist/routes/proposals.js.map +1 -1
  285. package/dist/routes/provenance.d.ts +17 -3
  286. package/dist/routes/provenance.d.ts.map +1 -1
  287. package/dist/routes/provenance.js +79 -103
  288. package/dist/routes/provenance.js.map +1 -1
  289. package/dist/routes/providers.d.ts +17 -1
  290. package/dist/routes/providers.d.ts.map +1 -1
  291. package/dist/routes/providers.js +110 -3
  292. package/dist/routes/providers.js.map +1 -1
  293. package/dist/routes/public-run-tokens.d.ts.map +1 -1
  294. package/dist/routes/public-run-tokens.js +3 -0
  295. package/dist/routes/public-run-tokens.js.map +1 -1
  296. package/dist/routes/readable-projects.d.ts +26 -0
  297. package/dist/routes/readable-projects.d.ts.map +1 -0
  298. package/dist/routes/readable-projects.js +39 -0
  299. package/dist/routes/readable-projects.js.map +1 -0
  300. package/dist/routes/runs.d.ts +10 -0
  301. package/dist/routes/runs.d.ts.map +1 -1
  302. package/dist/routes/runs.js +92 -42
  303. package/dist/routes/runs.js.map +1 -1
  304. package/dist/routes/schedules.d.ts +21 -13
  305. package/dist/routes/schedules.d.ts.map +1 -1
  306. package/dist/routes/schedules.js +416 -55
  307. package/dist/routes/schedules.js.map +1 -1
  308. package/dist/routes/segments.d.ts +2 -0
  309. package/dist/routes/segments.d.ts.map +1 -1
  310. package/dist/routes/segments.js +5 -0
  311. package/dist/routes/segments.js.map +1 -1
  312. package/dist/routes/service-accounts.d.ts +17 -0
  313. package/dist/routes/service-accounts.d.ts.map +1 -0
  314. package/dist/routes/service-accounts.js +212 -0
  315. package/dist/routes/service-accounts.js.map +1 -0
  316. package/dist/routes/sign-in-options.d.ts +50 -0
  317. package/dist/routes/sign-in-options.d.ts.map +1 -0
  318. package/dist/routes/sign-in-options.js +98 -0
  319. package/dist/routes/sign-in-options.js.map +1 -0
  320. package/dist/routes/signing-keys.d.ts +2 -1
  321. package/dist/routes/signing-keys.d.ts.map +1 -1
  322. package/dist/routes/signing-keys.js +3 -1
  323. package/dist/routes/signing-keys.js.map +1 -1
  324. package/dist/routes/tenant-access.d.ts +13 -0
  325. package/dist/routes/tenant-access.d.ts.map +1 -0
  326. package/dist/routes/tenant-access.js +26 -0
  327. package/dist/routes/tenant-access.js.map +1 -0
  328. package/dist/routes/tenant.d.ts.map +1 -1
  329. package/dist/routes/tenant.js +4 -0
  330. package/dist/routes/tenant.js.map +1 -1
  331. package/dist/routes/token-sign-in.d.ts +36 -0
  332. package/dist/routes/token-sign-in.d.ts.map +1 -0
  333. package/dist/routes/token-sign-in.js +101 -0
  334. package/dist/routes/token-sign-in.js.map +1 -0
  335. package/dist/routes/tokens.d.ts +15 -5
  336. package/dist/routes/tokens.d.ts.map +1 -1
  337. package/dist/routes/tokens.js +162 -43
  338. package/dist/routes/tokens.js.map +1 -1
  339. package/dist/routes/tools.d.ts.map +1 -1
  340. package/dist/routes/tools.js +9 -1
  341. package/dist/routes/tools.js.map +1 -1
  342. package/dist/routes/trigger-access.d.ts +29 -0
  343. package/dist/routes/trigger-access.d.ts.map +1 -0
  344. package/dist/routes/trigger-access.js +33 -0
  345. package/dist/routes/trigger-access.js.map +1 -0
  346. package/dist/routes/webhook-endpoints.d.ts +2 -1
  347. package/dist/routes/webhook-endpoints.d.ts.map +1 -1
  348. package/dist/routes/webhook-endpoints.js +11 -3
  349. package/dist/routes/webhook-endpoints.js.map +1 -1
  350. package/dist/routes/webhooks.d.ts +5 -1
  351. package/dist/routes/webhooks.d.ts.map +1 -1
  352. package/dist/routes/webhooks.js +25 -2
  353. package/dist/routes/webhooks.js.map +1 -1
  354. package/dist/run-failure.d.ts +21 -0
  355. package/dist/run-failure.d.ts.map +1 -0
  356. package/dist/run-failure.js +29 -0
  357. package/dist/run-failure.js.map +1 -0
  358. package/dist/service-account-binding.d.ts +108 -0
  359. package/dist/service-account-binding.d.ts.map +1 -0
  360. package/dist/service-account-binding.js +4 -0
  361. package/dist/service-account-binding.js.map +1 -0
  362. package/dist/session-store-binding.d.ts +61 -13
  363. package/dist/session-store-binding.d.ts.map +1 -1
  364. package/dist/signed-export.d.ts +89 -0
  365. package/dist/signed-export.d.ts.map +1 -0
  366. package/dist/signed-export.js +149 -0
  367. package/dist/signed-export.js.map +1 -0
  368. package/dist/supervisor-binding.d.ts +186 -413
  369. package/dist/supervisor-binding.d.ts.map +1 -1
  370. package/dist/testing/app-bindings.d.ts +33 -0
  371. package/dist/testing/app-bindings.d.ts.map +1 -0
  372. package/dist/testing/app-bindings.js +112 -0
  373. package/dist/testing/app-bindings.js.map +1 -0
  374. package/dist/testing/index.d.ts +11 -0
  375. package/dist/testing/index.d.ts.map +1 -0
  376. package/dist/testing/index.js +13 -0
  377. package/dist/testing/index.js.map +1 -0
  378. package/dist/testing/stub-binding.d.ts +34 -0
  379. package/dist/testing/stub-binding.d.ts.map +1 -0
  380. package/dist/testing/stub-binding.js +42 -0
  381. package/dist/testing/stub-binding.js.map +1 -0
  382. package/dist/testing/trigger-registry.d.ts +21 -0
  383. package/dist/testing/trigger-registry.d.ts.map +1 -0
  384. package/dist/testing/trigger-registry.js +206 -0
  385. package/dist/testing/trigger-registry.js.map +1 -0
  386. package/dist/token-admin.d.ts +46 -8
  387. package/dist/token-admin.d.ts.map +1 -1
  388. package/dist/token-admin.js.map +1 -1
  389. package/dist/tool-binding.d.ts +13 -0
  390. package/dist/tool-binding.d.ts.map +1 -1
  391. package/dist/trigger-binding.d.ts +2 -2
  392. package/dist/trigger-binding.d.ts.map +1 -1
  393. package/dist/trigger-binding.js +1 -1
  394. package/dist/trigger-binding.js.map +1 -1
  395. package/dist/types.d.ts +16 -0
  396. package/dist/types.d.ts.map +1 -1
  397. package/dist/webhook-endpoint-binding.d.ts +19 -3
  398. package/dist/webhook-endpoint-binding.d.ts.map +1 -1
  399. package/dist/webhook-endpoint-binding.js +1 -1
  400. package/dist/webhook-endpoint-binding.js.map +1 -1
  401. package/openapi.json +15387 -8789
  402. package/package.json +26 -22
  403. package/src/agent-binding.ts +14 -0
  404. package/src/agent-pins.ts +18 -2
  405. package/src/app.ts +366 -80
  406. package/src/block-publish.ts +181 -0
  407. package/src/caller.ts +62 -0
  408. package/src/capability-binding.ts +12 -0
  409. package/src/cost-binding.ts +19 -0
  410. package/src/derive-agent-version.ts +9 -1
  411. package/src/errors.ts +75 -7
  412. package/src/eval-case-binding.ts +17 -1
  413. package/src/eval-run-binding.ts +31 -0
  414. package/src/eval-run-dispatcher.ts +7 -0
  415. package/src/eval-sample.ts +42 -0
  416. package/src/eval-suite-binding.ts +14 -0
  417. package/src/flow-binding.ts +19 -0
  418. package/src/flow-pins.ts +18 -2
  419. package/src/gate.ts +26 -0
  420. package/src/handler-binding.ts +36 -1
  421. package/src/hitl-binding.ts +24 -0
  422. package/src/identity-directory-binding.ts +85 -4
  423. package/src/identity-provider-binding.ts +216 -21
  424. package/src/improvement-pass-binding.ts +193 -0
  425. package/src/index.ts +153 -31
  426. package/src/judged-dispatcher.ts +78 -11
  427. package/src/judgment-binding.ts +25 -1
  428. package/src/mcp-endpoint-binding.ts +7 -0
  429. package/src/memory-binding.ts +121 -17
  430. package/src/memory-erasure-binding.ts +156 -0
  431. package/src/middleware/auth.ts +228 -62
  432. package/src/middleware/authorize.ts +155 -3
  433. package/src/middleware/error-mapper.ts +15 -1
  434. package/src/middleware/idempotency.ts +230 -43
  435. package/src/middleware/key-project.ts +86 -0
  436. package/src/middleware/principal.ts +9 -5
  437. package/src/middleware/project-ref.ts +3 -0
  438. package/src/openapi/generate.ts +11 -2
  439. package/src/openapi/operations.ts +1060 -143
  440. package/src/openapi/schemas.ts +2387 -469
  441. package/src/person-grants-binding.ts +76 -0
  442. package/src/proposal-service.ts +640 -0
  443. package/src/proposal-status.ts +176 -0
  444. package/src/provider-binding.ts +10 -0
  445. package/src/publish-refused.ts +56 -9
  446. package/src/routes/adapters.ts +4 -0
  447. package/src/routes/agent-releases.ts +121 -69
  448. package/src/routes/agents.ts +128 -1
  449. package/src/routes/approvals.ts +164 -154
  450. package/src/routes/artifacts.ts +181 -11
  451. package/src/routes/auth.ts +804 -336
  452. package/src/routes/blocks.ts +2 -53
  453. package/src/routes/capabilities.ts +10 -1
  454. package/src/routes/compliance.ts +60 -99
  455. package/src/routes/conversations.ts +101 -7
  456. package/src/routes/cost.ts +110 -4
  457. package/src/routes/denied.ts +28 -0
  458. package/src/routes/deployments.ts +210 -17
  459. package/src/routes/eval-comparison.ts +81 -2
  460. package/src/routes/eval-overrides.ts +108 -0
  461. package/src/routes/eval-runs.ts +89 -6
  462. package/src/routes/eval-suites.ts +32 -2
  463. package/src/routes/event-triggers.ts +27 -3
  464. package/src/routes/export-signing-keys.ts +31 -0
  465. package/src/routes/flows.ts +12 -1
  466. package/src/routes/gate-policies.ts +37 -6
  467. package/src/routes/guardrails.ts +61 -2
  468. package/src/routes/identity.ts +328 -10
  469. package/src/routes/improvement-passes.ts +541 -0
  470. package/src/routes/judged-suites.ts +113 -43
  471. package/src/routes/judgment-context.ts +76 -5
  472. package/src/routes/judgment-flow-context.ts +16 -2
  473. package/src/routes/judgments.ts +17 -3
  474. package/src/routes/mcp.ts +29 -1
  475. package/src/routes/memory-access.ts +160 -0
  476. package/src/routes/memory-erasures.ts +240 -0
  477. package/src/routes/memory-parse.ts +250 -0
  478. package/src/routes/memory.ts +244 -286
  479. package/src/routes/observations.ts +15 -2
  480. package/src/routes/pagination.ts +12 -0
  481. package/src/routes/policies.ts +7 -1
  482. package/src/routes/project-mismatch.ts +56 -0
  483. package/src/routes/projects.ts +107 -13
  484. package/src/routes/proposals.ts +370 -611
  485. package/src/routes/provenance.ts +99 -133
  486. package/src/routes/providers.ts +142 -3
  487. package/src/routes/public-run-tokens.ts +3 -0
  488. package/src/routes/readable-projects.ts +66 -0
  489. package/src/routes/runs.ts +119 -39
  490. package/src/routes/schedules.ts +472 -60
  491. package/src/routes/segments.ts +11 -0
  492. package/src/routes/service-accounts.ts +262 -0
  493. package/src/routes/sign-in-options.ts +168 -0
  494. package/src/routes/signing-keys.ts +7 -1
  495. package/src/routes/tenant-access.ts +37 -0
  496. package/src/routes/tenant.ts +6 -0
  497. package/src/routes/token-sign-in.ts +161 -0
  498. package/src/routes/tokens.ts +172 -46
  499. package/src/routes/tools.ts +12 -1
  500. package/src/routes/trigger-access.ts +72 -0
  501. package/src/routes/webhook-endpoints.ts +15 -3
  502. package/src/routes/webhooks.ts +26 -2
  503. package/src/run-failure.ts +42 -0
  504. package/src/service-account-binding.ts +113 -0
  505. package/src/session-store-binding.ts +65 -13
  506. package/src/signed-export.ts +250 -0
  507. package/src/supervisor-binding.ts +169 -409
  508. package/src/testing/app-bindings.ts +142 -0
  509. package/src/testing/index.ts +21 -0
  510. package/src/testing/stub-binding.ts +53 -0
  511. package/src/testing/trigger-registry.ts +259 -0
  512. package/src/token-admin.ts +40 -8
  513. package/src/tool-binding.ts +14 -0
  514. package/src/trigger-binding.ts +8 -1
  515. package/src/types.ts +16 -0
  516. package/src/webhook-endpoint-binding.ts +18 -3
@@ -0,0 +1,108 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ /**
5
+ * An agent candidate's `overrides`, checked when the comparison starts:
6
+ * each settings block must be one the version pins, its values satisfying
7
+ * the schema of the version it pins (model settings, for the
8
+ * model-settings block); a prompt template must be for the prompt block
9
+ * the version pins, and pass `checkDraftedTemplate` (it reads and names
10
+ * only what the agent has). Checked once, here, before any run exists:
11
+ * the replays use them as given, on resume too.
12
+ */
13
+
14
+ import {
15
+ type AgentId,
16
+ MODEL_SETTINGS_SCHEMA,
17
+ checkDraftedTemplate,
18
+ settingsSchemaIssues,
19
+ } from '@kindgi/agents';
20
+ import type { Semver, TenantId } from '@kindgi/types';
21
+
22
+ import type { AgentRegistryBinding } from '../agent-binding.js';
23
+ import type { BlockRegistryBinding } from '../block-binding.js';
24
+ import type { EvalOverrides } from '../eval-run-binding.js';
25
+
26
+ /** Where the check reads the agent version and its blocks. */
27
+ export interface SettingsOverridesCheck {
28
+ readonly agents: AgentRegistryBinding;
29
+ readonly blocks: BlockRegistryBinding;
30
+ }
31
+
32
+ export interface OverridesIssue {
33
+ readonly path: string;
34
+ readonly message: string;
35
+ }
36
+
37
+ /** A JSON Pointer token: `~` and `/` escaped. */
38
+ const token = (id: string): string => id.replaceAll('~', '~0').replaceAll('/', '~1');
39
+
40
+ export async function checkSettingsOverrides(
41
+ check: SettingsOverridesCheck,
42
+ tenantId: TenantId,
43
+ candidate: { readonly agentId: string; readonly version: string },
44
+ overrides: EvalOverrides,
45
+ ): Promise<OverridesIssue[]> {
46
+ const settings = overrides.settings ?? {};
47
+ const label = `${candidate.agentId} ${candidate.version}`;
48
+ const found = await check.agents.getVersion({
49
+ tenantId,
50
+ agentId: candidate.agentId as AgentId,
51
+ version: candidate.version as Semver,
52
+ });
53
+ if (found === null) {
54
+ return [{ path: '/agentRef/version', message: `agent ${label} isn't registered` }];
55
+ }
56
+ if (found.pins === undefined) {
57
+ return [
58
+ {
59
+ path: '/overrides/settings',
60
+ message: `${label} was published before pins: it has no pinned settings to replace`,
61
+ },
62
+ ];
63
+ }
64
+ const issues: OverridesIssue[] = [];
65
+ for (const [id, values] of Object.entries(settings)) {
66
+ const path = `/overrides/settings/${token(id)}`;
67
+ const version = found.pins.settings[id];
68
+ if (version === undefined) {
69
+ issues.push({ path, message: `${label} doesn't pin settings block "${id}"` });
70
+ continue;
71
+ }
72
+ const block = await check.blocks.getVersion({ tenantId, blockId: id, version });
73
+ if (block === null || block.kind !== 'settings') {
74
+ issues.push({ path, message: `settings block "${id}" version ${version} isn't published` });
75
+ continue;
76
+ }
77
+ const schema = found.modelSettings?.id === id ? MODEL_SETTINGS_SCHEMA : block.content.schema;
78
+ if (schema === undefined) continue;
79
+ for (const issue of settingsSchemaIssues(values, schema)) {
80
+ issues.push({ path: `${path}${issue.path}`, message: issue.message });
81
+ }
82
+ }
83
+ for (const [id, { template }] of Object.entries(overrides.prompts ?? {})) {
84
+ const path = `/overrides/prompts/${token(id)}`;
85
+ const version = found.pins.prompts[id];
86
+ if (version === undefined) {
87
+ issues.push({ path, message: `${label} doesn't pin prompt block "${id}"` });
88
+ continue;
89
+ }
90
+ const block = await check.blocks.getVersion({ tenantId, blockId: id, version });
91
+ if (block === null || block.kind !== 'prompt') {
92
+ issues.push({ path, message: `prompt block "${id}" version ${version} isn't published` });
93
+ continue;
94
+ }
95
+ const drafted = checkDraftedTemplate(template, {
96
+ current: block.content,
97
+ settingsBlocks: Object.keys(found.pins.settings),
98
+ knownIds: [
99
+ candidate.agentId,
100
+ ...Object.keys(found.pins.tools),
101
+ ...Object.keys(found.pins.prompts),
102
+ ...Object.keys(found.pins.settings),
103
+ ],
104
+ });
105
+ for (const issue of drafted) issues.push({ path, message: issue.message });
106
+ }
107
+ return issues;
108
+ }
@@ -2,8 +2,10 @@
2
2
  // Copyright (C) 2026 Kindgi Inc.
3
3
 
4
4
  import { Hono } from 'hono';
5
+ import type { Context } from 'hono';
5
6
 
6
7
  import type { AgentId } from '@kindgi/agents';
8
+ import { type Action, ref } from '@kindgi/authz';
7
9
  import type { Cursor, FlowId, ProjectId, RunId, Semver, TenantId, Timestamp } from '@kindgi/types';
8
10
 
9
11
  import { statusFor, toWireError } from '../errors.js';
@@ -18,8 +20,11 @@ import {
18
20
  type FlowRef,
19
21
  } from '../eval-run-binding.js';
20
22
  import { VERSIONS_NEED_A_FLOW } from '../judged-dispatcher.js';
23
+ import type { Authorizer } from '../middleware/authorize.js';
21
24
  import type { AppEnv } from '../types.js';
25
+ import { deniedBy } from './denied.js';
22
26
  import { parseComparison } from './eval-comparison.js';
27
+ import { type SettingsOverridesCheck, checkSettingsOverrides } from './eval-overrides.js';
23
28
  import { type FlowVersionsCheck, checkFlowVersions } from './eval-versions.js';
24
29
  import { clampLimit } from './pagination.js';
25
30
  import { parseScopeParams } from './scope-params.js';
@@ -43,6 +48,13 @@ import { formatSseFrame } from './sse.js';
43
48
  * The binding chooses its underlying substrate (the in-process
44
49
  * reference keeps runs in memory; a durable binding can back them with
45
50
  * runs and their journal); this route only sees the surface.
51
+ *
52
+ * With an authorizer (T243 A): starting a run needs `write` on the
53
+ * project it lands in and `execute` on what it evaluates (the agent or
54
+ * flow), on top of the eval-suites router's own check on the suite. An
55
+ * eval run is read through its suite: `read` on the suite to list, get or
56
+ * follow it, `write` to cancel it. A run that isn't there is still the
57
+ * handler's 404.
46
58
  */
47
59
  export interface EvalRunsRouters {
48
60
  readonly start: Hono<AppEnv>;
@@ -57,10 +69,12 @@ export interface EvalRunsRouters {
57
69
  export function evalRunsRouters(
58
70
  binding: EvalRunBinding,
59
71
  versionsCheck?: FlowVersionsCheck,
72
+ overridesCheck?: SettingsOverridesCheck,
73
+ authorizer?: Authorizer,
60
74
  ): EvalRunsRouters {
61
75
  return {
62
- start: startRouter(binding, versionsCheck),
63
- readback: readbackRouter(binding),
76
+ start: startRouter(binding, versionsCheck, overridesCheck, authorizer),
77
+ readback: readbackRouter(binding, authorizer),
64
78
  };
65
79
  }
66
80
 
@@ -91,7 +105,42 @@ async function versionsRefusal(
91
105
  };
92
106
  }
93
107
 
94
- function startRouter(binding: EvalRunBinding, versionsCheck?: FlowVersionsCheck): Hono<AppEnv> {
108
+ /** The `validation-failed` error for an agent candidate's settings `overrides` that don't fit it; `undefined` when they do. */
109
+ async function overridesRefusal(
110
+ check: SettingsOverridesCheck | undefined,
111
+ tenantId: TenantId,
112
+ start: ParsedStartBody,
113
+ ) {
114
+ const overrides = start.comparison?.overrides;
115
+ const agentRef = start.agentRef;
116
+ if (overrides === undefined || agentRef?.version === undefined) return undefined;
117
+ if (check === undefined) {
118
+ return {
119
+ code: 'validation-failed' as const,
120
+ message: "This runtime can't check overrides (it serves no agent or block registry).",
121
+ issues: [],
122
+ };
123
+ }
124
+ const issues = await checkSettingsOverrides(
125
+ check,
126
+ tenantId,
127
+ { agentId: agentRef.agentId as unknown as string, version: agentRef.version },
128
+ overrides,
129
+ );
130
+ if (issues.length === 0) return undefined;
131
+ return {
132
+ code: 'validation-failed' as const,
133
+ message: `The overrides don't fit ${agentRef.agentId as unknown as string} ${agentRef.version} (${issues.length} issue${issues.length === 1 ? '' : 's'})`,
134
+ issues: issues as unknown as Record<string, unknown>[],
135
+ };
136
+ }
137
+
138
+ function startRouter(
139
+ binding: EvalRunBinding,
140
+ versionsCheck?: FlowVersionsCheck,
141
+ overridesCheck?: SettingsOverridesCheck,
142
+ authorizer?: Authorizer,
143
+ ): Hono<AppEnv> {
95
144
  const r = new Hono<AppEnv>();
96
145
 
97
146
  r.post('/:suiteId/runs', async (c) => {
@@ -119,7 +168,21 @@ function startRouter(binding: EvalRunBinding, versionsCheck?: FlowVersionsCheck)
119
168
  c.status(statusFor(parsed.error.code) as never);
120
169
  return c.json(toWireError(parsed.error, requestId));
121
170
  }
122
- const refusal = await versionsRefusal(versionsCheck, tenantId, parsed.value);
171
+ const { projectId, agentRef, flowRef } = parsed.value;
172
+ const target =
173
+ agentRef !== undefined
174
+ ? ref('agent', agentRef.agentId as unknown as string)
175
+ : ref('flow', flowRef?.flowId as unknown as string);
176
+ // Running the suite takes `execute` on it (an editor of its project, or
177
+ // an executor), whichever project the run lands in.
178
+ const refused =
179
+ (await deniedBy(authorizer, c, 'execute', ref('eval_suite', suiteId))) ??
180
+ (await deniedBy(authorizer, c, 'write', ref('project', projectId as unknown as string))) ??
181
+ (await deniedBy(authorizer, c, 'execute', target));
182
+ if (refused !== undefined) return refused;
183
+ const refusal =
184
+ (await versionsRefusal(versionsCheck, tenantId, parsed.value)) ??
185
+ (await overridesRefusal(overridesCheck, tenantId, parsed.value));
123
186
  if (refusal !== undefined) {
124
187
  c.status(statusFor(refusal.code) as never);
125
188
  return c.json(toWireError(refusal, requestId));
@@ -206,8 +269,16 @@ function startRouter(binding: EvalRunBinding, versionsCheck?: FlowVersionsCheck)
206
269
 
207
270
  // ---------- /v1/eval-runs/* (readback + cancel + SSE) ----------
208
271
 
209
- function readbackRouter(binding: EvalRunBinding): Hono<AppEnv> {
272
+ function readbackRouter(binding: EvalRunBinding, authorizer?: Authorizer): Hono<AppEnv> {
210
273
  const r = new Hono<AppEnv>();
274
+ /** The refusal, if any, of `action` on the suite of the run named in the path. */
275
+ const onRunSuite = async (c: Context<AppEnv>, action: Action): Promise<Response | undefined> => {
276
+ if (authorizer === undefined) return undefined;
277
+ const tenantId = c.get('tenantId') as TenantId;
278
+ const run = await binding.get({ tenantId, runId: c.req.param('runId') as RunId });
279
+ if (run === null) return undefined;
280
+ return deniedBy(authorizer, c, action, ref('eval_suite', run.suiteId));
281
+ };
211
282
 
212
283
  // ---------- GET / (list) ----------
213
284
  r.get('/', async (c) => {
@@ -270,8 +341,14 @@ function readbackRouter(binding: EvalRunBinding): Hono<AppEnv> {
270
341
  ...(scopeParsed.scope !== undefined && { scope: scopeParsed.scope }),
271
342
  ...(scopeParsed.inherit !== undefined && { inherit: scopeParsed.inherit }),
272
343
  });
344
+ const visible =
345
+ authorizer === undefined
346
+ ? page.data
347
+ : await authorizer.filterByCan(c, 'read', page.data, (run) =>
348
+ ref('eval_suite', run.suiteId),
349
+ );
273
350
  return c.json({
274
- data: page.data.map(serializeEvalRun),
351
+ data: visible.map(serializeEvalRun),
275
352
  hasMore: page.nextCursor !== undefined,
276
353
  ...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
277
354
  });
@@ -279,6 +356,8 @@ function readbackRouter(binding: EvalRunBinding): Hono<AppEnv> {
279
356
 
280
357
  // ---------- GET /:runId ----------
281
358
  r.get('/:runId', async (c) => {
359
+ const refused = await onRunSuite(c, 'read');
360
+ if (refused !== undefined) return refused;
282
361
  const requestId = c.get('requestId');
283
362
  const tenantId = c.get('tenantId') as TenantId;
284
363
  const runId = c.req.param('runId') as RunId;
@@ -298,6 +377,8 @@ function readbackRouter(binding: EvalRunBinding): Hono<AppEnv> {
298
377
 
299
378
  // ---------- POST /:runId/cancel ----------
300
379
  r.post('/:runId/cancel', async (c) => {
380
+ const refused = await onRunSuite(c, 'write');
381
+ if (refused !== undefined) return refused;
301
382
  const requestId = c.get('requestId');
302
383
  const tenantId = c.get('tenantId') as TenantId;
303
384
  const runId = c.req.param('runId') as RunId;
@@ -340,6 +421,8 @@ function readbackRouter(binding: EvalRunBinding): Hono<AppEnv> {
340
421
 
341
422
  // ---------- GET /:runId/events (SSE) ----------
342
423
  r.get('/:runId/events', async (c) => {
424
+ const refused = await onRunSuite(c, 'read');
425
+ if (refused !== undefined) return refused;
343
426
  const requestId = c.get('requestId');
344
427
  const tenantId = c.get('tenantId') as TenantId;
345
428
  const runId = c.req.param('runId') as RunId;
@@ -2,6 +2,7 @@
2
2
  // Copyright (C) 2026 Kindgi Inc.
3
3
 
4
4
  import { Hono } from 'hono';
5
+ import { routePath } from 'hono/route';
5
6
 
6
7
  import { type Principal, ref, tuplesForCreate } from '@kindgi/authz';
7
8
  import type { Cursor, ProjectId, TenantId, UserId } from '@kindgi/types';
@@ -16,6 +17,7 @@ import {
16
17
  import type { Authorizer } from '../middleware/authorize.js';
17
18
  import type { AppEnv } from '../types.js';
18
19
  import { clampLimit } from './pagination.js';
20
+ import { projectMismatch } from './project-mismatch.js';
19
21
  import { parseScopeParams } from './scope-params.js';
20
22
 
21
23
  /**
@@ -75,8 +77,26 @@ export function evalSuitesRouter(
75
77
  return mw(c, next);
76
78
  });
77
79
  r.use('/:suiteId/*', async (c, next) => {
78
- const action = c.req.method === 'GET' ? 'read' : 'admin';
79
80
  const suiteId = c.req.param('suiteId') ?? '';
81
+ // Starting a run (`POST /:suiteId/runs`, exactly) doesn't change the
82
+ // suite, and the start route checks it all itself: `execute` on the
83
+ // suite, `write` on the project and `execute` on the agent or flow.
84
+ const under = c.req.path.split('/').slice(routePath(c).split('/').length - 1);
85
+ if (c.req.method === 'POST' && under.length === 1 && under[0] === 'runs') return next();
86
+ const action = c.req.method === 'GET' ? 'read' : 'admin';
87
+ // A test set built from judgments under a suite id never registered
88
+ // (no head row) has no suite to check yet: the build checks `admin`
89
+ // on the project it names, the project the new suite belongs to. A
90
+ // tombstoned suite keeps its head row, so it's checked as an existing
91
+ // one. Anything else under a suite id, and a build under an existing
92
+ // suite, checks the suite.
93
+ if (
94
+ c.req.method === 'POST' &&
95
+ c.req.path.endsWith('/versions/from-judgments') &&
96
+ !(await binding.headExists({ tenantId: c.get('tenantId') as TenantId, suiteId }))
97
+ ) {
98
+ return next();
99
+ }
80
100
  const mw = authorizer.authorize(action, () => ref('eval_suite', suiteId));
81
101
  return mw(c, next);
82
102
  });
@@ -128,8 +148,15 @@ export function evalSuitesRouter(
128
148
  ...(scopeParsed.scope !== undefined && { scope: scopeParsed.scope }),
129
149
  ...(scopeParsed.inherit !== undefined && { inherit: scopeParsed.inherit }),
130
150
  });
151
+ // Only what the caller may read (T243 A), as `GET …/:id` asks.
152
+ const visible =
153
+ authorizer === undefined
154
+ ? page.data
155
+ : await authorizer.filterByCan(c, 'read', page.data, (a) =>
156
+ ref('eval_suite', a.id as unknown as string),
157
+ );
131
158
  return c.json({
132
- data: page.data.map(serializeEvalSuite),
159
+ data: visible.map(serializeEvalSuite),
133
160
  hasMore: page.nextCursor !== undefined,
134
161
  ...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
135
162
  });
@@ -318,6 +345,9 @@ export function evalSuitesRouter(
318
345
  ),
319
346
  );
320
347
  }
348
+ if (outcome.kind === 'project-mismatch') {
349
+ return projectMismatch(c, 'eval-suite', outcome.suiteId, outcome.projectId);
350
+ }
321
351
  if (outcome.kind === 'project-not-found') {
322
352
  // Caller supplied a `projectId` that does not resolve within
323
353
  // this tenant. Distinct signal from `already-registered` so the
@@ -7,6 +7,7 @@ import type { Context } from 'hono';
7
7
  import type { Cursor, TenantId, TriggerId } from '@kindgi/types';
8
8
 
9
9
  import { statusFor, toWireError } from '../errors.js';
10
+ import type { Authorizer } from '../middleware/authorize.js';
10
11
  import type {
11
12
  EventTriggerRecord,
12
13
  RegisterEventTriggerInput,
@@ -15,6 +16,7 @@ import type {
15
16
  } from '../trigger-binding.js';
16
17
  import type { AppEnv } from '../types.js';
17
18
  import { clampLimit } from './pagination.js';
19
+ import { triggerAccess } from './trigger-access.js';
18
20
 
19
21
  /**
20
22
  * Event triggers — fire a flow run when a matching event arrives on
@@ -22,9 +24,16 @@ import { clampLimit } from './pagination.js';
22
24
  *
23
25
  * Seven routes, mirroring the schedules surface. This surface registers
24
26
  * triggers; it does not publish events.
27
+ *
28
+ * With an authorizer (T243 A), the trigger's flow decides who may see or
29
+ * change it (`trigger-access.ts`).
25
30
  */
26
- export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEnv> {
31
+ export function eventTriggersRouter(
32
+ binding: TriggerRegistryBinding,
33
+ authorizer?: Authorizer,
34
+ ): Hono<AppEnv> {
27
35
  const r = new Hono<AppEnv>();
36
+ const access = triggerAccess(binding, 'event', authorizer);
28
37
 
29
38
  // ---------- POST / (register) ----------
30
39
  r.post('/', async (c) => {
@@ -37,11 +46,14 @@ export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEn
37
46
 
38
47
  const flowId = requireString(body, 'flowId');
39
48
  const flowVersion = requireString(body, 'flowVersion');
40
- const eventKind = requireString(body.config, 'config.eventKind');
49
+ const eventKind = requireString(body, 'config.eventKind');
41
50
  if (flowId.kind === 'err') return bad(c, requestId, flowId.message);
42
51
  if (flowVersion.kind === 'err') return bad(c, requestId, flowVersion.message);
43
52
  if (eventKind.kind === 'err') return bad(c, requestId, eventKind.message);
44
53
 
54
+ const refused = await access.onRegister(c, flowId.value);
55
+ if (refused !== undefined) return refused;
56
+
45
57
  const rawConfig = (body.config ?? {}) as Record<string, unknown>;
46
58
  const registerInput: RegisterEventTriggerInput = {
47
59
  kind: 'event',
@@ -84,7 +96,9 @@ export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEn
84
96
  ...(statusFilter !== undefined && { status: statusFilter }),
85
97
  });
86
98
  return c.json({
87
- data: page.data.map((row) => serializeEventTrigger(row as EventTriggerRecord)),
99
+ data: (await access.visible(c, page.data as readonly EventTriggerRecord[])).map(
100
+ serializeEventTrigger,
101
+ ),
88
102
  hasMore: page.nextCursor !== undefined,
89
103
  ...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
90
104
  });
@@ -95,6 +109,8 @@ export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEn
95
109
  const requestId = c.get('requestId');
96
110
  const tenantId = c.get('tenantId') as TenantId;
97
111
  const triggerId = c.req.param('triggerId') as TriggerId;
112
+ const refused = await access.onTrigger(c, triggerId, ['read']);
113
+ if (refused !== undefined) return refused;
98
114
 
99
115
  const rec = await binding.get({ tenantId, triggerId });
100
116
  if (rec === null || rec.kind !== 'event') return notFound(c, requestId, triggerId);
@@ -106,6 +122,8 @@ export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEn
106
122
  const requestId = c.get('requestId');
107
123
  const tenantId = c.get('tenantId') as TenantId;
108
124
  const triggerId = c.req.param('triggerId') as TriggerId;
125
+ const refused = await access.onTrigger(c, triggerId, ['write', 'execute']);
126
+ if (refused !== undefined) return refused;
109
127
 
110
128
  const parsed = await parseJsonObject(c, requestId);
111
129
  if (parsed.kind === 'err') return parsed.response;
@@ -149,6 +167,8 @@ export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEn
149
167
  const requestId = c.get('requestId');
150
168
  const tenantId = c.get('tenantId') as TenantId;
151
169
  const triggerId = c.req.param('triggerId') as TriggerId;
170
+ const refused = await access.onTrigger(c, triggerId, ['write']);
171
+ if (refused !== undefined) return refused;
152
172
  const result = await binding.pause({ tenantId, triggerId });
153
173
  if (result.kind === 'err') return lifecycleError(c, requestId, result.error, triggerId);
154
174
  return c.json(serializeEventTrigger(result.value as EventTriggerRecord));
@@ -159,6 +179,8 @@ export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEn
159
179
  const requestId = c.get('requestId');
160
180
  const tenantId = c.get('tenantId') as TenantId;
161
181
  const triggerId = c.req.param('triggerId') as TriggerId;
182
+ const refused = await access.onTrigger(c, triggerId, ['write']);
183
+ if (refused !== undefined) return refused;
162
184
  const result = await binding.resume({ tenantId, triggerId });
163
185
  if (result.kind === 'err') return lifecycleError(c, requestId, result.error, triggerId);
164
186
  return c.json(serializeEventTrigger(result.value as EventTriggerRecord));
@@ -168,6 +190,8 @@ export function eventTriggersRouter(binding: TriggerRegistryBinding): Hono<AppEn
168
190
  r.post('/:triggerId/unregister', async (c) => {
169
191
  const tenantId = c.get('tenantId') as TenantId;
170
192
  const triggerId = c.req.param('triggerId') as TriggerId;
193
+ const refused = await access.onTrigger(c, triggerId, ['write']);
194
+ if (refused !== undefined) return refused;
171
195
  const outcome = await binding.unregister({ tenantId, triggerId });
172
196
  return c.json({
173
197
  eventTriggerId: triggerId as unknown as string,
@@ -0,0 +1,31 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ import { Hono } from 'hono';
5
+
6
+ import type { ExportSigningBinding } from '@kindgi/crypto';
7
+
8
+ import type { AppEnv } from '../types.js';
9
+
10
+ /**
11
+ * `GET /v1/export-signing-keys`: the public keys this deployment signs
12
+ * its exports with, active first. A verifier pins them: an export's own
13
+ * embedded `publicKey` only proves it wasn't changed, these say who
14
+ * signed it. Empty when the deployment doesn't sign exports. Any
15
+ * authenticated caller may read them; they're public keys.
16
+ */
17
+ export function exportSigningKeysRouter(signer: ExportSigningBinding | undefined): Hono<AppEnv> {
18
+ const r = new Hono<AppEnv>();
19
+ r.get('/', (c) =>
20
+ c.json({
21
+ data: (signer?.listKeys() ?? []).map((key, index) => ({
22
+ keyId: key.keyId,
23
+ algorithm: key.algorithm,
24
+ publicKeyPem: key.publicKeyPem,
25
+ fingerprint: key.fingerprint,
26
+ active: index === 0,
27
+ })),
28
+ }),
29
+ );
30
+ return r;
31
+ }
@@ -18,6 +18,7 @@ import { refuseWritesWhenReadOnly } from '../registry-read-only.js';
18
18
  import type { ToolRegistryBinding } from '../tool-binding.js';
19
19
  import type { AppEnv } from '../types.js';
20
20
  import { clampLimit } from './pagination.js';
21
+ import { projectMismatch } from './project-mismatch.js';
21
22
  import { parseScopeParams } from './scope-params.js';
22
23
 
23
24
  /**
@@ -132,8 +133,15 @@ export function flowsRouter(
132
133
  ...(scopeParsed.scope !== undefined && { scope: scopeParsed.scope }),
133
134
  ...(scopeParsed.inherit !== undefined && { inherit: scopeParsed.inherit }),
134
135
  });
136
+ // Only what the caller may read (T243 A), as `GET …/:id` asks.
137
+ const visible =
138
+ authorizer === undefined
139
+ ? page.data
140
+ : await authorizer.filterByCan(c, 'read', page.data, (a) =>
141
+ ref('flow', a.id as unknown as string),
142
+ );
135
143
  return c.json({
136
- data: page.data.map(serializeGraph),
144
+ data: visible.map(serializeGraph),
137
145
  hasMore: page.nextCursor !== undefined,
138
146
  ...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
139
147
  });
@@ -334,6 +342,9 @@ export function flowsRouter(
334
342
  ),
335
343
  );
336
344
  }
345
+ if (outcome.kind === 'project-mismatch') {
346
+ return projectMismatch(c, 'flow', outcome.flowId as unknown as string, outcome.projectId);
347
+ }
337
348
  if (outcome.kind === 'project-not-found') {
338
349
  // Caller supplied a `projectId` that does not resolve within
339
350
  // this tenant. Distinct signal from `already-registered` so the
@@ -4,7 +4,7 @@
4
4
  import { type Context, Hono } from 'hono';
5
5
 
6
6
  import { ref } from '@kindgi/authz';
7
- import type { Cursor, TenantId } from '@kindgi/types';
7
+ import type { Cursor, LiveScope, TenantId } from '@kindgi/types';
8
8
 
9
9
  import { statusFor, toWireError } from '../errors.js';
10
10
  import type { GatePolicyBinding, GatePolicyError } from '../gate-policy-binding.js';
@@ -30,7 +30,10 @@ const ID_RE = /^[a-z0-9][a-z0-9._-]{0,127}$/;
30
30
  * POST /:policyId/versions/:version/unregister|reinstate
31
31
  *
32
32
  * Writes need `admin` on the tenant: whoever may promote mustn't be able
33
- * to loosen the gate on their own promotion.
33
+ * to loosen the gate on their own promotion. Reads need `read` on the
34
+ * policy's scope (a segment's: its project), as judge classes do: one the
35
+ * caller can't read answers 404, as if it weren't there, and the list
36
+ * shows only those they can.
34
37
  */
35
38
  export function gatePoliciesRouter(
36
39
  binding: GatePolicyBinding,
@@ -46,6 +49,11 @@ export function gatePoliciesRouter(
46
49
  });
47
50
  }
48
51
 
52
+ /** Whether the caller may read a policy: `read` on its scope. */
53
+ const canRead = async (c: Ctx, policy: { readonly scope: LiveScope }): Promise<boolean> =>
54
+ authorizer === undefined ||
55
+ authorizer.can(c, 'read', scopeRef(c.get('tenantId') as TenantId, policy.scope));
56
+
49
57
  r.get('/', async (c) => {
50
58
  const requestId = c.get('requestId');
51
59
  const scope = scopeFromQuery((n) => c.req.query(n), c.req.queries('segment') ?? []);
@@ -59,8 +67,14 @@ export function gatePoliciesRouter(
59
67
  ...(scope.scope !== undefined && { scope: scope.scope }),
60
68
  ...(cursor !== undefined && cursor.length > 0 && { cursor: cursor as Cursor }),
61
69
  });
70
+ const visible =
71
+ authorizer === undefined
72
+ ? page.data
73
+ : await authorizer.filterByCan(c, 'read', page.data, (p) =>
74
+ scopeRef(c.get('tenantId') as TenantId, p.scope),
75
+ );
62
76
  return c.json({
63
- data: page.data.map(serializeGatePolicy),
77
+ data: visible.map(serializeGatePolicy),
64
78
  hasMore: page.nextCursor !== undefined,
65
79
  ...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
66
80
  });
@@ -71,7 +85,7 @@ export function gatePoliciesRouter(
71
85
  tenantId: c.get('tenantId') as TenantId,
72
86
  id: c.req.param('policyId'),
73
87
  });
74
- if (found === null) return notFound(c, c.req.param('policyId'));
88
+ if (found === null || !(await canRead(c, found))) return notFound(c, c.req.param('policyId'));
75
89
  return c.json(serializeGatePolicy(found));
76
90
  });
77
91
 
@@ -80,7 +94,11 @@ export function gatePoliciesRouter(
80
94
  tenantId: c.get('tenantId') as TenantId,
81
95
  id: c.req.param('policyId'),
82
96
  });
83
- if (versions.length === 0) return notFound(c, c.req.param('policyId'));
97
+ // A policy's versions share its scope (`gate-policy-scope-changed`).
98
+ const first = versions[0];
99
+ if (first === undefined || !(await canRead(c, first))) {
100
+ return notFound(c, c.req.param('policyId'));
101
+ }
84
102
  return c.json({ data: versions.map(serializeGatePolicy), hasMore: false });
85
103
  });
86
104
 
@@ -90,7 +108,7 @@ export function gatePoliciesRouter(
90
108
  id: c.req.param('policyId'),
91
109
  version: c.req.param('version'),
92
110
  });
93
- if (found === null) {
111
+ if (found === null || !(await canRead(c, found))) {
94
112
  return notFound(c, c.req.param('policyId'), c.req.param('version'));
95
113
  }
96
114
  return c.json(serializeGatePolicy(found));
@@ -144,6 +162,19 @@ export function gatePoliciesRouter(
144
162
 
145
163
  type Ctx = Context<AppEnv>;
146
164
 
165
+ /** The resource a gate policy's scope is: what reading it needs `read` on. */
166
+ function scopeRef(tenantId: TenantId, scope: LiveScope) {
167
+ switch (scope.kind) {
168
+ case 'tenant':
169
+ return ref('tenant', tenantId as unknown as string);
170
+ case 'org':
171
+ return ref('org', scope.orgId as unknown as string);
172
+ case 'project':
173
+ case 'segment':
174
+ return ref('project', scope.projectId as unknown as string);
175
+ }
176
+ }
177
+
147
178
  function badInput(c: Ctx, requestId: string, message: string) {
148
179
  c.status(statusFor('bad-input') as never);
149
180
  return c.json(toWireError({ code: 'bad-input', message }, requestId));