@kindgi/api 0.0.0-bootstrap.0 → 0.1.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 (505) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +216 -1
  3. package/dist/adapter-binding.d.ts +177 -0
  4. package/dist/adapter-binding.d.ts.map +1 -0
  5. package/dist/adapter-binding.js +12 -0
  6. package/dist/adapter-binding.js.map +1 -0
  7. package/dist/agent-binding.d.ts +207 -0
  8. package/dist/agent-binding.d.ts.map +1 -0
  9. package/dist/agent-binding.js +4 -0
  10. package/dist/agent-binding.js.map +1 -0
  11. package/dist/app.d.ts +770 -0
  12. package/dist/app.d.ts.map +1 -0
  13. package/dist/app.js +396 -0
  14. package/dist/app.js.map +1 -0
  15. package/dist/capability-binding.d.ts +76 -0
  16. package/dist/capability-binding.d.ts.map +1 -0
  17. package/dist/capability-binding.js +4 -0
  18. package/dist/capability-binding.js.map +1 -0
  19. package/dist/cost-binding.d.ts +175 -0
  20. package/dist/cost-binding.d.ts.map +1 -0
  21. package/dist/cost-binding.js +13 -0
  22. package/dist/cost-binding.js.map +1 -0
  23. package/dist/deployment-binding.d.ts +201 -0
  24. package/dist/deployment-binding.d.ts.map +1 -0
  25. package/dist/deployment-binding.js +4 -0
  26. package/dist/deployment-binding.js.map +1 -0
  27. package/dist/env-binding.d.ts +132 -0
  28. package/dist/env-binding.d.ts.map +1 -0
  29. package/dist/env-binding.js +4 -0
  30. package/dist/env-binding.js.map +1 -0
  31. package/dist/errors.d.ts +37 -0
  32. package/dist/errors.d.ts.map +1 -0
  33. package/dist/errors.js +264 -0
  34. package/dist/errors.js.map +1 -0
  35. package/dist/eval-run-binding.d.ts +196 -0
  36. package/dist/eval-run-binding.d.ts.map +1 -0
  37. package/dist/eval-run-binding.js +16 -0
  38. package/dist/eval-run-binding.js.map +1 -0
  39. package/dist/eval-run-dispatcher.d.ts +131 -0
  40. package/dist/eval-run-dispatcher.d.ts.map +1 -0
  41. package/dist/eval-run-dispatcher.js +368 -0
  42. package/dist/eval-run-dispatcher.js.map +1 -0
  43. package/dist/eval-suite-binding.d.ts +227 -0
  44. package/dist/eval-suite-binding.d.ts.map +1 -0
  45. package/dist/eval-suite-binding.js +24 -0
  46. package/dist/eval-suite-binding.js.map +1 -0
  47. package/dist/event-bus-binding.d.ts +107 -0
  48. package/dist/event-bus-binding.d.ts.map +1 -0
  49. package/dist/event-bus-binding.js +5 -0
  50. package/dist/event-bus-binding.js.map +1 -0
  51. package/dist/flow-binding.d.ts +194 -0
  52. package/dist/flow-binding.d.ts.map +1 -0
  53. package/dist/flow-binding.js +4 -0
  54. package/dist/flow-binding.js.map +1 -0
  55. package/dist/guardrail-binding.d.ts +138 -0
  56. package/dist/guardrail-binding.d.ts.map +1 -0
  57. package/dist/guardrail-binding.js +4 -0
  58. package/dist/guardrail-binding.js.map +1 -0
  59. package/dist/handler-binding.d.ts +126 -0
  60. package/dist/handler-binding.d.ts.map +1 -0
  61. package/dist/handler-binding.js +4 -0
  62. package/dist/handler-binding.js.map +1 -0
  63. package/dist/hitl-binding.d.ts +115 -0
  64. package/dist/hitl-binding.d.ts.map +1 -0
  65. package/dist/hitl-binding.js +4 -0
  66. package/dist/hitl-binding.js.map +1 -0
  67. package/dist/identity-directory-binding.d.ts +116 -0
  68. package/dist/identity-directory-binding.d.ts.map +1 -0
  69. package/dist/identity-directory-binding.js +4 -0
  70. package/dist/identity-directory-binding.js.map +1 -0
  71. package/dist/identity-provider-binding.d.ts +184 -0
  72. package/dist/identity-provider-binding.d.ts.map +1 -0
  73. package/dist/identity-provider-binding.js +4 -0
  74. package/dist/identity-provider-binding.js.map +1 -0
  75. package/dist/image-registry-binding.d.ts +165 -0
  76. package/dist/image-registry-binding.d.ts.map +1 -0
  77. package/dist/image-registry-binding.js +4 -0
  78. package/dist/image-registry-binding.js.map +1 -0
  79. package/dist/index.d.ts +72 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +26 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/key-management-binding.d.ts +101 -0
  84. package/dist/key-management-binding.d.ts.map +1 -0
  85. package/dist/key-management-binding.js +4 -0
  86. package/dist/key-management-binding.js.map +1 -0
  87. package/dist/mcp-endpoint-binding.d.ts +312 -0
  88. package/dist/mcp-endpoint-binding.d.ts.map +1 -0
  89. package/dist/mcp-endpoint-binding.js +12 -0
  90. package/dist/mcp-endpoint-binding.js.map +1 -0
  91. package/dist/memory-binding.d.ts +209 -0
  92. package/dist/memory-binding.d.ts.map +1 -0
  93. package/dist/memory-binding.js +4 -0
  94. package/dist/memory-binding.js.map +1 -0
  95. package/dist/middleware/auth.d.ts +168 -0
  96. package/dist/middleware/auth.d.ts.map +1 -0
  97. package/dist/middleware/auth.js +247 -0
  98. package/dist/middleware/auth.js.map +1 -0
  99. package/dist/middleware/authorize.d.ts +26 -0
  100. package/dist/middleware/authorize.d.ts.map +1 -0
  101. package/dist/middleware/authorize.js +65 -0
  102. package/dist/middleware/authorize.js.map +1 -0
  103. package/dist/middleware/error-mapper.d.ts +13 -0
  104. package/dist/middleware/error-mapper.d.ts.map +1 -0
  105. package/dist/middleware/error-mapper.js +32 -0
  106. package/dist/middleware/error-mapper.js.map +1 -0
  107. package/dist/middleware/idempotency.d.ts +43 -0
  108. package/dist/middleware/idempotency.d.ts.map +1 -0
  109. package/dist/middleware/idempotency.js +118 -0
  110. package/dist/middleware/idempotency.js.map +1 -0
  111. package/dist/middleware/principal.d.ts +4 -0
  112. package/dist/middleware/principal.d.ts.map +1 -0
  113. package/dist/middleware/principal.js +42 -0
  114. package/dist/middleware/principal.js.map +1 -0
  115. package/dist/middleware/public-run-routes.d.ts +16 -0
  116. package/dist/middleware/public-run-routes.d.ts.map +1 -0
  117. package/dist/middleware/public-run-routes.js +43 -0
  118. package/dist/middleware/public-run-routes.js.map +1 -0
  119. package/dist/middleware/request-id.d.ts +14 -0
  120. package/dist/middleware/request-id.d.ts.map +1 -0
  121. package/dist/middleware/request-id.js +24 -0
  122. package/dist/middleware/request-id.js.map +1 -0
  123. package/dist/middleware/sigv4-verify.d.ts +64 -0
  124. package/dist/middleware/sigv4-verify.d.ts.map +1 -0
  125. package/dist/middleware/sigv4-verify.js +286 -0
  126. package/dist/middleware/sigv4-verify.js.map +1 -0
  127. package/dist/middleware/sigv4.d.ts +25 -0
  128. package/dist/middleware/sigv4.d.ts.map +1 -0
  129. package/dist/middleware/sigv4.js +120 -0
  130. package/dist/middleware/sigv4.js.map +1 -0
  131. package/dist/openapi/generate.d.ts +15 -0
  132. package/dist/openapi/generate.d.ts.map +1 -0
  133. package/dist/openapi/generate.js +241 -0
  134. package/dist/openapi/generate.js.map +1 -0
  135. package/dist/openapi/operations.d.ts +70 -0
  136. package/dist/openapi/operations.d.ts.map +1 -0
  137. package/dist/openapi/operations.js +5051 -0
  138. package/dist/openapi/operations.js.map +1 -0
  139. package/dist/openapi/schemas.d.ts +590 -0
  140. package/dist/openapi/schemas.d.ts.map +1 -0
  141. package/dist/openapi/schemas.js +5820 -0
  142. package/dist/openapi/schemas.js.map +1 -0
  143. package/dist/provenance-binding.d.ts +116 -0
  144. package/dist/provenance-binding.d.ts.map +1 -0
  145. package/dist/provenance-binding.js +31 -0
  146. package/dist/provenance-binding.js.map +1 -0
  147. package/dist/provider-binding.d.ts +174 -0
  148. package/dist/provider-binding.d.ts.map +1 -0
  149. package/dist/provider-binding.js +4 -0
  150. package/dist/provider-binding.js.map +1 -0
  151. package/dist/public-run-token.d.ts +97 -0
  152. package/dist/public-run-token.d.ts.map +1 -0
  153. package/dist/public-run-token.js +167 -0
  154. package/dist/public-run-token.js.map +1 -0
  155. package/dist/retention-binding.d.ts +69 -0
  156. package/dist/retention-binding.d.ts.map +1 -0
  157. package/dist/retention-binding.js +4 -0
  158. package/dist/retention-binding.js.map +1 -0
  159. package/dist/reviewer-binding.d.ts +84 -0
  160. package/dist/reviewer-binding.d.ts.map +1 -0
  161. package/dist/reviewer-binding.js +4 -0
  162. package/dist/reviewer-binding.js.map +1 -0
  163. package/dist/rotation-status-store.d.ts +96 -0
  164. package/dist/rotation-status-store.d.ts.map +1 -0
  165. package/dist/rotation-status-store.js +106 -0
  166. package/dist/rotation-status-store.js.map +1 -0
  167. package/dist/routes/adapters.d.ts +29 -0
  168. package/dist/routes/adapters.d.ts.map +1 -0
  169. package/dist/routes/adapters.js +230 -0
  170. package/dist/routes/adapters.js.map +1 -0
  171. package/dist/routes/agents.d.ts +17 -0
  172. package/dist/routes/agents.d.ts.map +1 -0
  173. package/dist/routes/agents.js +342 -0
  174. package/dist/routes/agents.js.map +1 -0
  175. package/dist/routes/approvals.d.ts +37 -0
  176. package/dist/routes/approvals.d.ts.map +1 -0
  177. package/dist/routes/approvals.js +551 -0
  178. package/dist/routes/approvals.js.map +1 -0
  179. package/dist/routes/artifacts.d.ts +25 -0
  180. package/dist/routes/artifacts.d.ts.map +1 -0
  181. package/dist/routes/artifacts.js +265 -0
  182. package/dist/routes/artifacts.js.map +1 -0
  183. package/dist/routes/audit.d.ts +6 -0
  184. package/dist/routes/audit.d.ts.map +1 -0
  185. package/dist/routes/audit.js +162 -0
  186. package/dist/routes/audit.js.map +1 -0
  187. package/dist/routes/auth.d.ts +47 -0
  188. package/dist/routes/auth.d.ts.map +1 -0
  189. package/dist/routes/auth.js +630 -0
  190. package/dist/routes/auth.js.map +1 -0
  191. package/dist/routes/capabilities.d.ts +14 -0
  192. package/dist/routes/capabilities.d.ts.map +1 -0
  193. package/dist/routes/capabilities.js +62 -0
  194. package/dist/routes/capabilities.js.map +1 -0
  195. package/dist/routes/compliance.d.ts +37 -0
  196. package/dist/routes/compliance.d.ts.map +1 -0
  197. package/dist/routes/compliance.js +321 -0
  198. package/dist/routes/compliance.js.map +1 -0
  199. package/dist/routes/conversations.d.ts +13 -0
  200. package/dist/routes/conversations.d.ts.map +1 -0
  201. package/dist/routes/conversations.js +295 -0
  202. package/dist/routes/conversations.js.map +1 -0
  203. package/dist/routes/cost.d.ts +24 -0
  204. package/dist/routes/cost.d.ts.map +1 -0
  205. package/dist/routes/cost.js +243 -0
  206. package/dist/routes/cost.js.map +1 -0
  207. package/dist/routes/deployments.d.ts +122 -0
  208. package/dist/routes/deployments.d.ts.map +1 -0
  209. package/dist/routes/deployments.js +1036 -0
  210. package/dist/routes/deployments.js.map +1 -0
  211. package/dist/routes/env.d.ts +62 -0
  212. package/dist/routes/env.d.ts.map +1 -0
  213. package/dist/routes/env.js +311 -0
  214. package/dist/routes/env.js.map +1 -0
  215. package/dist/routes/eval-runs.d.ts +28 -0
  216. package/dist/routes/eval-runs.d.ts.map +1 -0
  217. package/dist/routes/eval-runs.js +479 -0
  218. package/dist/routes/eval-runs.js.map +1 -0
  219. package/dist/routes/eval-suites.d.ts +24 -0
  220. package/dist/routes/eval-suites.d.ts.map +1 -0
  221. package/dist/routes/eval-suites.js +381 -0
  222. package/dist/routes/eval-suites.js.map +1 -0
  223. package/dist/routes/event-triggers.d.ts +12 -0
  224. package/dist/routes/event-triggers.d.ts.map +1 -0
  225. package/dist/routes/event-triggers.js +218 -0
  226. package/dist/routes/event-triggers.js.map +1 -0
  227. package/dist/routes/flows.d.ts +23 -0
  228. package/dist/routes/flows.d.ts.map +1 -0
  229. package/dist/routes/flows.js +344 -0
  230. package/dist/routes/flows.js.map +1 -0
  231. package/dist/routes/guardrails.d.ts +33 -0
  232. package/dist/routes/guardrails.d.ts.map +1 -0
  233. package/dist/routes/guardrails.js +236 -0
  234. package/dist/routes/guardrails.js.map +1 -0
  235. package/dist/routes/identity.d.ts +39 -0
  236. package/dist/routes/identity.d.ts.map +1 -0
  237. package/dist/routes/identity.js +138 -0
  238. package/dist/routes/identity.js.map +1 -0
  239. package/dist/routes/mcp.d.ts +23 -0
  240. package/dist/routes/mcp.d.ts.map +1 -0
  241. package/dist/routes/mcp.js +727 -0
  242. package/dist/routes/mcp.js.map +1 -0
  243. package/dist/routes/memory.d.ts +16 -0
  244. package/dist/routes/memory.d.ts.map +1 -0
  245. package/dist/routes/memory.js +353 -0
  246. package/dist/routes/memory.js.map +1 -0
  247. package/dist/routes/observations.d.ts +19 -0
  248. package/dist/routes/observations.d.ts.map +1 -0
  249. package/dist/routes/observations.js +135 -0
  250. package/dist/routes/observations.js.map +1 -0
  251. package/dist/routes/orgs.d.ts +24 -0
  252. package/dist/routes/orgs.d.ts.map +1 -0
  253. package/dist/routes/orgs.js +208 -0
  254. package/dist/routes/orgs.js.map +1 -0
  255. package/dist/routes/pagination.d.ts +18 -0
  256. package/dist/routes/pagination.d.ts.map +1 -0
  257. package/dist/routes/pagination.js +35 -0
  258. package/dist/routes/pagination.js.map +1 -0
  259. package/dist/routes/policies.d.ts +23 -0
  260. package/dist/routes/policies.d.ts.map +1 -0
  261. package/dist/routes/policies.js +314 -0
  262. package/dist/routes/policies.js.map +1 -0
  263. package/dist/routes/projects.d.ts +45 -0
  264. package/dist/routes/projects.d.ts.map +1 -0
  265. package/dist/routes/projects.js +485 -0
  266. package/dist/routes/projects.js.map +1 -0
  267. package/dist/routes/proposals.d.ts +24 -0
  268. package/dist/routes/proposals.d.ts.map +1 -0
  269. package/dist/routes/proposals.js +581 -0
  270. package/dist/routes/proposals.js.map +1 -0
  271. package/dist/routes/provenance.d.ts +34 -0
  272. package/dist/routes/provenance.d.ts.map +1 -0
  273. package/dist/routes/provenance.js +274 -0
  274. package/dist/routes/provenance.js.map +1 -0
  275. package/dist/routes/providers.d.ts +32 -0
  276. package/dist/routes/providers.d.ts.map +1 -0
  277. package/dist/routes/providers.js +490 -0
  278. package/dist/routes/providers.js.map +1 -0
  279. package/dist/routes/public-run-tokens.d.ts +17 -0
  280. package/dist/routes/public-run-tokens.d.ts.map +1 -0
  281. package/dist/routes/public-run-tokens.js +69 -0
  282. package/dist/routes/public-run-tokens.js.map +1 -0
  283. package/dist/routes/retention.d.ts +19 -0
  284. package/dist/routes/retention.d.ts.map +1 -0
  285. package/dist/routes/retention.js +152 -0
  286. package/dist/routes/retention.js.map +1 -0
  287. package/dist/routes/reviewers.d.ts +5 -0
  288. package/dist/routes/reviewers.d.ts.map +1 -0
  289. package/dist/routes/reviewers.js +161 -0
  290. package/dist/routes/reviewers.js.map +1 -0
  291. package/dist/routes/runs.d.ts +34 -0
  292. package/dist/routes/runs.d.ts.map +1 -0
  293. package/dist/routes/runs.js +773 -0
  294. package/dist/routes/runs.js.map +1 -0
  295. package/dist/routes/s3.d.ts +31 -0
  296. package/dist/routes/s3.d.ts.map +1 -0
  297. package/dist/routes/s3.js +433 -0
  298. package/dist/routes/s3.js.map +1 -0
  299. package/dist/routes/schedules.d.ts +20 -0
  300. package/dist/routes/schedules.d.ts.map +1 -0
  301. package/dist/routes/schedules.js +234 -0
  302. package/dist/routes/schedules.js.map +1 -0
  303. package/dist/routes/scope-params.d.ts +57 -0
  304. package/dist/routes/scope-params.d.ts.map +1 -0
  305. package/dist/routes/scope-params.js +105 -0
  306. package/dist/routes/scope-params.js.map +1 -0
  307. package/dist/routes/secret-ref.d.ts +20 -0
  308. package/dist/routes/secret-ref.d.ts.map +1 -0
  309. package/dist/routes/secret-ref.js +42 -0
  310. package/dist/routes/secret-ref.js.map +1 -0
  311. package/dist/routes/secrets.d.ts +53 -0
  312. package/dist/routes/secrets.d.ts.map +1 -0
  313. package/dist/routes/secrets.js +715 -0
  314. package/dist/routes/secrets.js.map +1 -0
  315. package/dist/routes/signing-keys.d.ts +23 -0
  316. package/dist/routes/signing-keys.d.ts.map +1 -0
  317. package/dist/routes/signing-keys.js +212 -0
  318. package/dist/routes/signing-keys.js.map +1 -0
  319. package/dist/routes/sse.d.ts +58 -0
  320. package/dist/routes/sse.d.ts.map +1 -0
  321. package/dist/routes/sse.js +92 -0
  322. package/dist/routes/sse.js.map +1 -0
  323. package/dist/routes/teams.d.ts +30 -0
  324. package/dist/routes/teams.d.ts.map +1 -0
  325. package/dist/routes/teams.js +443 -0
  326. package/dist/routes/teams.js.map +1 -0
  327. package/dist/routes/tenant.d.ts +57 -0
  328. package/dist/routes/tenant.d.ts.map +1 -0
  329. package/dist/routes/tenant.js +352 -0
  330. package/dist/routes/tenant.js.map +1 -0
  331. package/dist/routes/tokens.d.ts +14 -0
  332. package/dist/routes/tokens.d.ts.map +1 -0
  333. package/dist/routes/tokens.js +231 -0
  334. package/dist/routes/tokens.js.map +1 -0
  335. package/dist/routes/tools.d.ts +33 -0
  336. package/dist/routes/tools.d.ts.map +1 -0
  337. package/dist/routes/tools.js +380 -0
  338. package/dist/routes/tools.js.map +1 -0
  339. package/dist/routes/webhook-endpoints.d.ts +10 -0
  340. package/dist/routes/webhook-endpoints.d.ts.map +1 -0
  341. package/dist/routes/webhook-endpoints.js +407 -0
  342. package/dist/routes/webhook-endpoints.js.map +1 -0
  343. package/dist/routes/webhooks.d.ts +21 -0
  344. package/dist/routes/webhooks.d.ts.map +1 -0
  345. package/dist/routes/webhooks.js +228 -0
  346. package/dist/routes/webhooks.js.map +1 -0
  347. package/dist/s3-credential-binding.d.ts +54 -0
  348. package/dist/s3-credential-binding.d.ts.map +1 -0
  349. package/dist/s3-credential-binding.js +4 -0
  350. package/dist/s3-credential-binding.js.map +1 -0
  351. package/dist/secrets-binding.d.ts +281 -0
  352. package/dist/secrets-binding.d.ts.map +1 -0
  353. package/dist/secrets-binding.js +10 -0
  354. package/dist/secrets-binding.js.map +1 -0
  355. package/dist/secrets-provider-binding.d.ts +164 -0
  356. package/dist/secrets-provider-binding.d.ts.map +1 -0
  357. package/dist/secrets-provider-binding.js +4 -0
  358. package/dist/secrets-provider-binding.js.map +1 -0
  359. package/dist/session-store-binding.d.ts +148 -0
  360. package/dist/session-store-binding.d.ts.map +1 -0
  361. package/dist/session-store-binding.js +4 -0
  362. package/dist/session-store-binding.js.map +1 -0
  363. package/dist/signing-key-binding.d.ts +210 -0
  364. package/dist/signing-key-binding.d.ts.map +1 -0
  365. package/dist/signing-key-binding.js +4 -0
  366. package/dist/signing-key-binding.js.map +1 -0
  367. package/dist/state-store-binding.d.ts +53 -0
  368. package/dist/state-store-binding.d.ts.map +1 -0
  369. package/dist/state-store-binding.js +38 -0
  370. package/dist/state-store-binding.js.map +1 -0
  371. package/dist/supervisor-binding.d.ts +526 -0
  372. package/dist/supervisor-binding.d.ts.map +1 -0
  373. package/dist/supervisor-binding.js +4 -0
  374. package/dist/supervisor-binding.js.map +1 -0
  375. package/dist/tenant-host-access.d.ts +41 -0
  376. package/dist/tenant-host-access.d.ts.map +1 -0
  377. package/dist/tenant-host-access.js +42 -0
  378. package/dist/tenant-host-access.js.map +1 -0
  379. package/dist/token-admin.d.ts +99 -0
  380. package/dist/token-admin.d.ts.map +1 -0
  381. package/dist/token-admin.js +4 -0
  382. package/dist/token-admin.js.map +1 -0
  383. package/dist/tool-binding.d.ts +247 -0
  384. package/dist/tool-binding.d.ts.map +1 -0
  385. package/dist/tool-binding.js +4 -0
  386. package/dist/tool-binding.js.map +1 -0
  387. package/dist/trigger-binding.d.ts +13 -0
  388. package/dist/trigger-binding.d.ts.map +1 -0
  389. package/dist/trigger-binding.js +4 -0
  390. package/dist/trigger-binding.js.map +1 -0
  391. package/dist/types.d.ts +71 -0
  392. package/dist/types.d.ts.map +1 -0
  393. package/dist/types.js +4 -0
  394. package/dist/types.js.map +1 -0
  395. package/dist/webhook-endpoint-binding.d.ts +230 -0
  396. package/dist/webhook-endpoint-binding.d.ts.map +1 -0
  397. package/dist/webhook-endpoint-binding.js +12 -0
  398. package/dist/webhook-endpoint-binding.js.map +1 -0
  399. package/dist/xml.d.ts +79 -0
  400. package/dist/xml.d.ts.map +1 -0
  401. package/dist/xml.js +115 -0
  402. package/dist/xml.js.map +1 -0
  403. package/openapi.json +29659 -0
  404. package/package.json +76 -4
  405. package/scripts/emit-openapi.mjs +44 -0
  406. package/src/adapter-binding.ts +204 -0
  407. package/src/agent-binding.ts +231 -0
  408. package/src/app.ts +1285 -0
  409. package/src/capability-binding.ts +83 -0
  410. package/src/cost-binding.ts +213 -0
  411. package/src/deployment-binding.ts +225 -0
  412. package/src/env-binding.ts +140 -0
  413. package/src/errors.ts +291 -0
  414. package/src/eval-run-binding.ts +209 -0
  415. package/src/eval-run-dispatcher.ts +497 -0
  416. package/src/eval-suite-binding.ts +257 -0
  417. package/src/event-bus-binding.ts +127 -0
  418. package/src/flow-binding.ts +213 -0
  419. package/src/guardrail-binding.ts +151 -0
  420. package/src/handler-binding.ts +132 -0
  421. package/src/hitl-binding.ts +172 -0
  422. package/src/identity-directory-binding.ts +128 -0
  423. package/src/identity-provider-binding.ts +203 -0
  424. package/src/image-registry-binding.ts +193 -0
  425. package/src/index.ts +606 -0
  426. package/src/key-management-binding.ts +91 -0
  427. package/src/mcp-endpoint-binding.ts +311 -0
  428. package/src/memory-binding.ts +239 -0
  429. package/src/middleware/auth.ts +437 -0
  430. package/src/middleware/authorize.ts +125 -0
  431. package/src/middleware/error-mapper.ts +37 -0
  432. package/src/middleware/idempotency.ts +160 -0
  433. package/src/middleware/principal.ts +64 -0
  434. package/src/middleware/public-run-routes.ts +50 -0
  435. package/src/middleware/request-id.ts +28 -0
  436. package/src/middleware/sigv4-verify.ts +374 -0
  437. package/src/middleware/sigv4.ts +165 -0
  438. package/src/openapi/generate.ts +307 -0
  439. package/src/openapi/operations.ts +5445 -0
  440. package/src/openapi/schemas.ts +6363 -0
  441. package/src/provenance-binding.ts +169 -0
  442. package/src/provider-binding.ts +196 -0
  443. package/src/public-run-token.ts +263 -0
  444. package/src/retention-binding.ts +78 -0
  445. package/src/reviewer-binding.ts +99 -0
  446. package/src/rotation-status-store.ts +209 -0
  447. package/src/routes/adapters.ts +319 -0
  448. package/src/routes/agents.ts +424 -0
  449. package/src/routes/approvals.ts +759 -0
  450. package/src/routes/artifacts.ts +317 -0
  451. package/src/routes/audit.ts +219 -0
  452. package/src/routes/auth.ts +806 -0
  453. package/src/routes/capabilities.ts +79 -0
  454. package/src/routes/compliance.ts +482 -0
  455. package/src/routes/conversations.ts +369 -0
  456. package/src/routes/cost.ts +327 -0
  457. package/src/routes/deployments.ts +1493 -0
  458. package/src/routes/env.ts +429 -0
  459. package/src/routes/eval-runs.ts +631 -0
  460. package/src/routes/eval-suites.ts +490 -0
  461. package/src/routes/event-triggers.ts +283 -0
  462. package/src/routes/flows.ts +423 -0
  463. package/src/routes/guardrails.ts +320 -0
  464. package/src/routes/identity.ts +203 -0
  465. package/src/routes/mcp.ts +940 -0
  466. package/src/routes/memory.ts +430 -0
  467. package/src/routes/observations.ts +175 -0
  468. package/src/routes/orgs.ts +273 -0
  469. package/src/routes/pagination.ts +51 -0
  470. package/src/routes/policies.ts +413 -0
  471. package/src/routes/projects.ts +634 -0
  472. package/src/routes/proposals.ts +719 -0
  473. package/src/routes/provenance.ts +406 -0
  474. package/src/routes/providers.ts +624 -0
  475. package/src/routes/public-run-tokens.ts +104 -0
  476. package/src/routes/retention.ts +193 -0
  477. package/src/routes/reviewers.ts +209 -0
  478. package/src/routes/runs.ts +981 -0
  479. package/src/routes/s3.ts +519 -0
  480. package/src/routes/schedules.ts +300 -0
  481. package/src/routes/scope-params.ts +133 -0
  482. package/src/routes/secret-ref.ts +52 -0
  483. package/src/routes/secrets.ts +975 -0
  484. package/src/routes/signing-keys.ts +259 -0
  485. package/src/routes/sse.ts +148 -0
  486. package/src/routes/teams.ts +584 -0
  487. package/src/routes/tenant.ts +530 -0
  488. package/src/routes/tokens.ts +285 -0
  489. package/src/routes/tools.ts +491 -0
  490. package/src/routes/webhook-endpoints.ts +534 -0
  491. package/src/routes/webhooks.ts +296 -0
  492. package/src/s3-credential-binding.ts +58 -0
  493. package/src/secrets-binding.ts +308 -0
  494. package/src/secrets-provider-binding.ts +167 -0
  495. package/src/session-store-binding.ts +163 -0
  496. package/src/signing-key-binding.ts +235 -0
  497. package/src/state-store-binding.ts +84 -0
  498. package/src/supervisor-binding.ts +554 -0
  499. package/src/tenant-host-access.ts +62 -0
  500. package/src/token-admin.ts +104 -0
  501. package/src/tool-binding.ts +274 -0
  502. package/src/trigger-binding.ts +38 -0
  503. package/src/types.ts +74 -0
  504. package/src/webhook-endpoint-binding.ts +246 -0
  505. package/src/xml.ts +196 -0
@@ -0,0 +1,167 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ import type { Scope } from '@kindgi/platform';
5
+ import type { EnvName, Result } from '@kindgi/types';
6
+
7
+ /**
8
+ * Adapter surface below `SecretBinding`. External-secret-manager
9
+ * deployments plug this in behind a secrets router (a thin
10
+ * `SecretBinding` implementation that delegates every method to a
11
+ * wired provider). Provider adapter packages MUST ship under
12
+ * a secrets-provider adapter naming for discoverability.
13
+ *
14
+ * Provider adapters MUST NOT emit compliance-evidence events
15
+ * themselves — the `SecretBinding` router owns that. Adapters are
16
+ * dumb translators between the framework's uniform surface and the
17
+ * provider's native API.
18
+ */
19
+ export interface SecretProviderBinding {
20
+ readonly providerName: string;
21
+ getSecret(
22
+ input: SecretProviderGetInput,
23
+ ): Promise<Result<SecretProviderPayload | null, SecretProviderError>>;
24
+ getSecretVersion(
25
+ input: SecretProviderGetVersionInput,
26
+ ): Promise<Result<SecretProviderPayload | null, SecretProviderError>>;
27
+ listSecrets(
28
+ input: SecretProviderListInput,
29
+ ): Promise<Result<SecretProviderListOutput, SecretProviderError>>;
30
+ putSecret(
31
+ input: SecretProviderPutInput,
32
+ ): Promise<Result<SecretProviderPutOutput, SecretProviderError>>;
33
+ rotateSecret(
34
+ input: SecretProviderRotateInput,
35
+ ): Promise<Result<SecretProviderRotateOutput, SecretProviderError>>;
36
+ deleteSecret(
37
+ input: SecretProviderDeleteInput,
38
+ ): Promise<Result<SecretProviderDeleteOutput, SecretProviderError>>;
39
+ probe(): Promise<Result<SecretProviderProbeOutput, SecretProviderError>>;
40
+ }
41
+
42
+ /**
43
+ * How the provider knows which scope + env to talk to. Three
44
+ * strategies (mode governs provider-instance sharing; `scope` carries
45
+ * the full discriminated `Scope` from `@kindgi/platform` for
46
+ * path-encoding):
47
+ *
48
+ * - `mode: 'shared-provider'` — one provider instance for all
49
+ * tenants + envs; adapter encodes scope + env into `name`
50
+ * (e.g. Vault: `secret/data/<scopeKind>/<tenantId>/<orgId|projectId|_>/<envName>/<name>`).
51
+ * - `mode: 'per-tenant-provider'` — provider constructed per
52
+ * tenant; adapter encodes scope-level (org/project id) + env.
53
+ * - `mode: 'per-tenant-env-provider'` — provider constructed per
54
+ * (tenant, env) pair; adapter still encodes scope-level
55
+ * (org/project) into `name` when non-tenant. For providers with a
56
+ * native `environment` concept (env dimension only).
57
+ *
58
+ * Scope-hierarchy resolution is done framework-side by the
59
+ * `SecretBinding` router BEFORE delegating to a provider — each
60
+ * `Provider*Input` call targets exactly one scope level. Providers
61
+ * do not walk the hierarchy.
62
+ *
63
+ * `SecretProviderScope` carries the full discriminated `Scope`
64
+ * primitive, not just `tenantId`.
65
+ */
66
+ export type SecretProviderScope =
67
+ | {
68
+ readonly mode: 'shared-provider';
69
+ readonly scope: Scope;
70
+ readonly envName: EnvName;
71
+ readonly namespace?: string;
72
+ }
73
+ | { readonly mode: 'per-tenant-provider'; readonly scope: Scope; readonly envName: EnvName }
74
+ | { readonly mode: 'per-tenant-env-provider'; readonly scope: Scope; readonly envName: EnvName };
75
+
76
+ export interface SecretProviderGetInput {
77
+ readonly providerScope: SecretProviderScope;
78
+ readonly name: string;
79
+ }
80
+
81
+ export interface SecretProviderGetVersionInput {
82
+ readonly providerScope: SecretProviderScope;
83
+ readonly name: string;
84
+ readonly versionId: number;
85
+ }
86
+
87
+ export interface SecretProviderPayload {
88
+ readonly name: string;
89
+ readonly versionId: number;
90
+ readonly createdAt: string;
91
+ readonly value: string;
92
+ }
93
+
94
+ export interface SecretProviderListInput {
95
+ readonly providerScope: SecretProviderScope;
96
+ readonly namePrefix?: string;
97
+ readonly cursor?: string;
98
+ readonly limit: number;
99
+ }
100
+
101
+ export interface SecretProviderListOutput {
102
+ readonly data: readonly SecretProviderMetadata[];
103
+ readonly nextCursor?: string;
104
+ }
105
+
106
+ export interface SecretProviderMetadata {
107
+ readonly name: string;
108
+ readonly currentVersion: number;
109
+ readonly createdAt: string;
110
+ readonly updatedAt: string;
111
+ readonly revokedAt?: string;
112
+ }
113
+
114
+ export interface SecretProviderPutInput {
115
+ readonly providerScope: SecretProviderScope;
116
+ readonly name: string;
117
+ readonly value: string;
118
+ readonly writeMode: 'create-new' | 'add-version';
119
+ }
120
+
121
+ export type SecretProviderPutOutput =
122
+ | { readonly kind: 'ok'; readonly versionId: number; readonly createdAt: string }
123
+ | { readonly kind: 'already-exists' }
124
+ | { readonly kind: 'version-conflict'; readonly currentVersion: number };
125
+
126
+ export interface SecretProviderRotateInput {
127
+ readonly providerScope: SecretProviderScope;
128
+ readonly name: string;
129
+ readonly newValue?: string;
130
+ readonly revokeOldAfterMs?: number;
131
+ }
132
+
133
+ export type SecretProviderRotateOutput =
134
+ | { readonly kind: 'ok'; readonly newVersionId: number; readonly oldVersionId: number }
135
+ | { readonly kind: 'rotation-pending'; readonly resumeToken: string };
136
+
137
+ export interface SecretProviderDeleteInput {
138
+ readonly providerScope: SecretProviderScope;
139
+ readonly name: string;
140
+ readonly hard: boolean;
141
+ }
142
+
143
+ export interface SecretProviderDeleteOutput {
144
+ readonly deleted: boolean;
145
+ }
146
+
147
+ export interface SecretProviderProbeOutput {
148
+ readonly reachable: true;
149
+ readonly providerVersion?: string;
150
+ readonly latencyMs?: number;
151
+ }
152
+
153
+ /**
154
+ * Uniform error shape across every provider adapter. Adapters map
155
+ * their native failure conditions to these codes; the router
156
+ * translates them further into `SecretError` codes.
157
+ */
158
+ export type SecretProviderError =
159
+ | { readonly code: 'unreachable'; readonly message: string; readonly cause?: unknown }
160
+ | { readonly code: 'unauthorized'; readonly message: string; readonly cause?: unknown }
161
+ | {
162
+ readonly code: 'rate-limited';
163
+ readonly message: string;
164
+ readonly retryAfterMs?: number;
165
+ }
166
+ | { readonly code: 'unsupported'; readonly message: string; readonly feature: string }
167
+ | { readonly code: 'provider-error'; readonly message: string; readonly cause?: unknown };
@@ -0,0 +1,163 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ import type { Cursor, SessionId, TenantId, Timestamp, UserId } from '@kindgi/types';
5
+
6
+ /**
7
+ * Caller-plugged surface for OAuth/OIDC session persistence. Same
8
+ * pattern as `TokenAdmin` (write path for bearer tokens) — the API
9
+ * package does NOT own session persistence. Deployments plug in a
10
+ * durable store.
11
+ *
12
+ * Sessions are the byproduct of a successful OAuth callback:
13
+ * `POST /v1/auth/callback/:providerId` exchanges the authorization code
14
+ * for provider tokens, fetches the userinfo, and calls
15
+ * `SessionStoreBinding.create` to persist the resulting session; the
16
+ * route then hands the caller an opaque framework-issued token
17
+ * (`kgi_sk_<sessionId>`) that never leaks the provider access-token or
18
+ * refresh-token to the client.
19
+ *
20
+ * The bearer-auth middleware routes session-token requests through
21
+ * `get(tenantId, sessionId)`; the resolver hot path runs on every
22
+ * authenticated request that carries a session token, so implementations
23
+ * SHOULD keep `get` cheap (e.g. a single indexed lookup by id and
24
+ * expiry, or a cache).
25
+ */
26
+ export interface SessionStoreBinding {
27
+ create(input: SessionCreateInput): Promise<SessionCreateOutput>;
28
+ get(input: SessionGetInput): Promise<Session | null>;
29
+ list(input: SessionListInput): Promise<SessionPage>;
30
+ revoke(input: SessionRevokeInput): Promise<SessionRevokeOutcome>;
31
+ revokeAllForUser(input: SessionRevokeAllForUserInput): Promise<SessionRevokeAllForUserOutcome>;
32
+ /**
33
+ * Update the session's `lastActiveAt` marker. Called by the auth
34
+ * middleware on each successful authenticated request (throttled, by
35
+ * default to at most once per minute per session, so the write path
36
+ * doesn't hot-spot under load). Absent = the middleware only enforces absolute
37
+ * TTL; inactivity timeout is disabled.
38
+ *
39
+ * The tenant sentinel `MULTI_TENANT_LOOKUP` is honored the same way
40
+ * as `get` — the middleware doesn't know the tenant ahead of time.
41
+ */
42
+ readonly touch?: (input: SessionTouchInput) => Promise<SessionTouchOutcome>;
43
+ }
44
+
45
+ export interface SessionCreateInput {
46
+ readonly tenantId: TenantId;
47
+ readonly userId: UserId;
48
+ /** ProviderId of the `IdentityProviderBinding` that authenticated the user. */
49
+ readonly providerId: string;
50
+ /** Opaque provider access-token — server-side only. */
51
+ readonly accessToken: string;
52
+ /** Opaque provider refresh-token — server-side only, may be absent. */
53
+ readonly refreshToken?: string;
54
+ readonly expiresAt: Timestamp;
55
+ readonly scopes: readonly string[];
56
+ /** Free-form provider claims (e.g. `email`, `name`, `sub`). */
57
+ readonly metadata?: Record<string, unknown>;
58
+ }
59
+
60
+ export interface SessionCreateOutput {
61
+ readonly sessionId: SessionId;
62
+ readonly expiresAt: Timestamp;
63
+ }
64
+
65
+ export interface SessionGetInput {
66
+ readonly tenantId: TenantId;
67
+ readonly sessionId: SessionId;
68
+ }
69
+
70
+ export interface SessionListInput {
71
+ readonly tenantId: TenantId;
72
+ readonly limit: number;
73
+ readonly cursor?: Cursor;
74
+ /** Filter to sessions for a single user. Absent → all users in tenant. */
75
+ readonly userId?: UserId;
76
+ }
77
+
78
+ export interface SessionRevokeInput {
79
+ readonly tenantId: TenantId;
80
+ readonly sessionId: SessionId;
81
+ /**
82
+ * Distinguishes an explicit revoke (user logout, admin action) from
83
+ * a rotation (`POST /v1/auth/refresh` retiring the old session). The
84
+ * adapter uses this to set both `revokedAt` AND `rotatedAt` on the
85
+ * session so the middleware can return `401 refresh-token-invalid` when
86
+ * the OLD session token is reused after rotation. Defaults to
87
+ * `'revoke'`.
88
+ */
89
+ readonly reason?: 'revoke' | 'rotate';
90
+ }
91
+
92
+ export interface SessionRevokeAllForUserInput {
93
+ readonly tenantId: TenantId;
94
+ readonly userId: UserId;
95
+ }
96
+
97
+ export interface Session {
98
+ readonly id: SessionId;
99
+ readonly tenantId: TenantId;
100
+ readonly userId: UserId;
101
+ readonly providerId: string;
102
+ readonly accessToken: string;
103
+ readonly refreshToken?: string;
104
+ readonly expiresAt: Timestamp;
105
+ readonly scopes: readonly string[];
106
+ readonly metadata?: Record<string, unknown>;
107
+ readonly createdAt: Timestamp;
108
+ /**
109
+ * Last-observed activity timestamp. Populated by adapters that
110
+ * implement `touch()` — the middleware bumps it (throttled) on each
111
+ * authenticated request so the deployment can enforce an
112
+ * inactivity-based logout independent of the absolute session TTL.
113
+ *
114
+ * Adapters MAY leave this undefined when the deployment has opted
115
+ * out of inactivity tracking; in that case the middleware skips the
116
+ * inactivity check and enforces only absolute TTL.
117
+ */
118
+ readonly lastActiveAt?: Timestamp;
119
+ /**
120
+ * Set by `POST /v1/auth/refresh` on the OLD session when it mints a
121
+ * new one. Distinguishes rotation (client should retry with the
122
+ * fresh token — OAuth 2.1 BCP refresh-token reuse detection) from
123
+ * an explicit revocation (user logged out). The middleware surfaces
124
+ * this via `401 refresh-token-invalid` vs `401 auth-revoked`. Set
125
+ * atomically with `revokedAt`.
126
+ */
127
+ readonly rotatedAt?: Timestamp;
128
+ readonly revokedAt?: Timestamp;
129
+ }
130
+
131
+ export interface SessionTouchInput {
132
+ readonly tenantId: TenantId;
133
+ readonly sessionId: SessionId;
134
+ /**
135
+ * The observed activity timestamp. Adapters SHOULD accept a
136
+ * caller-supplied instant so tests can drive the clock; production
137
+ * middleware passes `new Date()`.
138
+ */
139
+ readonly at: Date;
140
+ }
141
+
142
+ export interface SessionTouchOutcome {
143
+ /**
144
+ * `false` when the session was already revoked or the row is
145
+ * unknown — the middleware treats either case as a soft-fail (no
146
+ * fatal error, but the caller's next request will 401 via the
147
+ * standard checks).
148
+ */
149
+ readonly touched: boolean;
150
+ }
151
+
152
+ export interface SessionPage {
153
+ readonly data: readonly Session[];
154
+ readonly nextCursor?: Cursor;
155
+ }
156
+
157
+ export interface SessionRevokeOutcome {
158
+ readonly revoked: boolean;
159
+ }
160
+
161
+ export interface SessionRevokeAllForUserOutcome {
162
+ readonly revokedCount: number;
163
+ }
@@ -0,0 +1,235 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ import type { Cursor, Result, SigningKeyId, TenantId } from '@kindgi/types';
5
+
6
+ /**
7
+ * Caller-plugged surface for the API layer's **tenant-scoped signing-key
8
+ * trust registry** — the seam behind the deploy route's signature
9
+ * verification + trust-list cross-check.
10
+ *
11
+ * ## Position vs `SigningKeyBinding`
12
+ *
13
+ * the crypto module already exposes a `SigningKeyBinding` — a low-level
14
+ * KMS seam that returns raw key bytes for a `SigningKeyId`. That binding
15
+ * is deployment-wide; every request finds the same keys.
16
+ *
17
+ * THIS binding is a **higher-level, tenant-scoped trust registry**. It
18
+ * answers "for tenant T, is this public key allowed to sign deploys /
19
+ * artifacts?" and performs signature verification against the registered
20
+ * trust list. A production adapter typically wraps the crypto-layer
21
+ * binding for the underlying primitive ops and layers tenant-scoping,
22
+ * revocation, and audit on top.
23
+ *
24
+ * Consumers alias one of the two when importing both — TypeScript resolves
25
+ * them by module path but the local name collides.
26
+ *
27
+ * ## Two responsibilities
28
+ *
29
+ * 1. **Trust registry** (`listTrusted` / `getTrusted` / `addTrusted` /
30
+ * `revokeTrusted`) — per-tenant CRUD over the set of public keys
31
+ * permitted to sign deploys and admin operations.
32
+ * 2. **Verification** (`isTrusted` / `verify`) — cheap boolean trust
33
+ * check + a full signature-verification call. The `POST /v1/deployments`
34
+ * route calls `isTrusted` (which must be `true`) and then verifies the
35
+ * Ed25519 signature itself; it does not call `verify`.
36
+ *
37
+ * Tenant-scoped: callers pass `tenantId` explicitly. Same trust list
38
+ * partitioning as every other admin surface.
39
+ *
40
+ * ## Seam only
41
+ *
42
+ * No implementation is bundled here; the `POST /v1/deployments` route
43
+ * runs its trust check through this interface.
44
+ */
45
+ export interface SigningKeyBinding {
46
+ // -------------- verification --------------
47
+
48
+ /**
49
+ * Cheap trust check for the signature step of `POST /v1/deployments`.
50
+ * Returns `true` when the given `(keyId, publicKey)` pair appears on
51
+ * the tenant's trust list AND has not been revoked. `false` otherwise —
52
+ * the route surfaces `false` as `403 signer-not-trusted`.
53
+ *
54
+ * The pair is checked jointly to defend against a key-id collision
55
+ * across tenants: two tenants MAY use the same `SigningKeyId` for
56
+ * their own keys as long as the public bytes differ. Trust is bound
57
+ * to the exact bytes.
58
+ */
59
+ isTrusted(input: IsTrustedInput): Promise<Result<boolean, SigningKeyError>>;
60
+ /**
61
+ * Verify a raw Ed25519 signature over a canonicalised payload against
62
+ * the trusted key — e.g. the canonical deploy envelope
63
+ * (`(imageDigest, artifactVersion, indexHash, tenantId, publishedAt)`)
64
+ * as `payload`. The binding computes the verification and returns
65
+ * `valid: true` on cryptographic match.
66
+ *
67
+ * Bindings MUST NOT trust the caller's assertion that the key is
68
+ * trusted — they re-run the trust check as part of `verify`, so
69
+ * `signer-not-trusted` shortcuts before `signature-invalid`.
70
+ */
71
+ verify(input: VerifyInput): Promise<Result<VerifyOutcome, SigningKeyError>>;
72
+
73
+ // -------------- trust registry --------------
74
+
75
+ /**
76
+ * Cursor-paginated list of trusted keys for the tenant. Sort order is
77
+ * binding-defined (e.g. `createdAt desc, keyId desc`).
78
+ */
79
+ listTrusted(input: ListTrustedInput): Promise<TrustedKeyPage>;
80
+ /**
81
+ * Look up a single trusted key by id. `null` when unknown to the
82
+ * tenant OR revoked; revoked entries are excluded here (they still
83
+ * appear via `listTrusted` with `includeRevoked: true`).
84
+ */
85
+ getTrusted(input: GetTrustedInput): Promise<TrustedKey | null>;
86
+ /**
87
+ * Add a key to the tenant's trust list. Idempotent per `(keyId,
88
+ * publicKey)` — re-adding the same pair returns
89
+ * `{ kind: 'already-trusted' }` with the existing entry (no bump to
90
+ * `createdAt`). Different `publicKey` under the same `keyId` is
91
+ * rejected with `key-id-conflict` — callers rotate by allocating a
92
+ * new keyId, not by rebinding one.
93
+ */
94
+ addTrusted(input: AddTrustedInput): Promise<AddTrustedOutcome>;
95
+ /**
96
+ * Revoke a trusted key. Idempotent — revoking an already-revoked or
97
+ * unknown key returns `{ revoked: false }`; first-time revocation
98
+ * returns `{ revoked: true }`. The entry is retained (soft-delete)
99
+ * so historical `Deployment.signerKeyId` refs remain resolvable for
100
+ * audit; `isTrusted` returns `false` for revoked entries.
101
+ */
102
+ revokeTrusted(input: RevokeTrustedInput): Promise<RevokeTrustedOutcome>;
103
+ }
104
+
105
+ // -------------------- record --------------------
106
+
107
+ /**
108
+ * Wire shape for a trusted-key registration. `publicKey` is base64 of
109
+ * the raw key bytes (Ed25519 = 32 bytes); `algorithm` is the closed set
110
+ * from the crypto module — extended here as an open string so future
111
+ * algorithms don't require a package bump on this file.
112
+ */
113
+ export interface TrustedKey {
114
+ readonly keyId: SigningKeyId;
115
+ readonly tenantId: TenantId;
116
+ /** `'ed25519'` today. Open string for future algorithms. */
117
+ readonly algorithm: string;
118
+ /** Base64 of the raw public key bytes. */
119
+ readonly publicKey: string;
120
+ /** Optional human-readable label — e.g. `'acme-staging-2026-01'`. */
121
+ readonly label?: string;
122
+ /** ISO-8601 timestamp of first registration. */
123
+ readonly createdAt: string;
124
+ /** ISO-8601 timestamp of revocation; absent when active. */
125
+ readonly revokedAt?: string;
126
+ /** Reason string supplied at revocation time. */
127
+ readonly revokedReason?: string;
128
+ }
129
+
130
+ // -------------------- verify --------------------
131
+
132
+ export interface IsTrustedInput {
133
+ readonly tenantId: TenantId;
134
+ readonly keyId: SigningKeyId;
135
+ /** Base64 of the raw public-key bytes the signer presented. */
136
+ readonly publicKey: string;
137
+ }
138
+
139
+ export interface VerifyInput {
140
+ readonly tenantId: TenantId;
141
+ readonly keyId: SigningKeyId;
142
+ /** Base64 of the raw public-key bytes. */
143
+ readonly publicKey: string;
144
+ /** Raw bytes over which the signature was computed. */
145
+ readonly payload: Uint8Array;
146
+ /** Base64 of the signature bytes. */
147
+ readonly signature: string;
148
+ }
149
+
150
+ export interface VerifyOutcome {
151
+ readonly valid: boolean;
152
+ /**
153
+ * When `valid: false`, a hint at why — `signature-mismatch` /
154
+ * `signer-not-trusted` / `algorithm-unsupported`. Useful for logs.
155
+ */
156
+ readonly reason?: string;
157
+ }
158
+
159
+ // -------------------- registry --------------------
160
+
161
+ export interface ListTrustedInput {
162
+ readonly tenantId: TenantId;
163
+ readonly limit: number;
164
+ readonly cursor?: Cursor;
165
+ /** When `true`, revoked entries are included. Default `false`. */
166
+ readonly includeRevoked?: boolean;
167
+ /** Prefix match on `TrustedKey.label` — useful for env-scoped listings. */
168
+ readonly labelFilter?: string;
169
+ }
170
+
171
+ export interface TrustedKeyPage {
172
+ readonly data: readonly TrustedKey[];
173
+ readonly nextCursor?: Cursor;
174
+ }
175
+
176
+ export interface GetTrustedInput {
177
+ readonly tenantId: TenantId;
178
+ readonly keyId: SigningKeyId;
179
+ }
180
+
181
+ export interface AddTrustedInput {
182
+ readonly tenantId: TenantId;
183
+ readonly keyId: SigningKeyId;
184
+ readonly algorithm: string;
185
+ readonly publicKey: string;
186
+ readonly label?: string;
187
+ }
188
+
189
+ export type AddTrustedOutcome =
190
+ | { readonly kind: 'ok'; readonly key: TrustedKey }
191
+ | { readonly kind: 'already-trusted'; readonly key: TrustedKey }
192
+ | {
193
+ /**
194
+ * Same `keyId` already registered but with different `publicKey`
195
+ * bytes. Callers rotate by allocating a fresh `keyId`.
196
+ */
197
+ readonly kind: 'key-id-conflict';
198
+ readonly existing: TrustedKey;
199
+ }
200
+ | {
201
+ /**
202
+ * The key couldn't be trusted. `signing-key-revoked`: the id was
203
+ * revoked, and revocation is final (rotate under a new id). Other
204
+ * codes are store failures.
205
+ */
206
+ readonly kind: 'error';
207
+ readonly code: string;
208
+ readonly message: string;
209
+ };
210
+
211
+ export interface RevokeTrustedInput {
212
+ readonly tenantId: TenantId;
213
+ readonly keyId: SigningKeyId;
214
+ /** Optional audit reason surfaced through `TrustedKey.revokedReason`. */
215
+ readonly reason?: string;
216
+ }
217
+
218
+ export interface RevokeTrustedOutcome {
219
+ readonly revoked: boolean;
220
+ }
221
+
222
+ // -------------------- error --------------------
223
+
224
+ export type SigningKeyError =
225
+ | { readonly code: 'signing-key-not-found'; readonly message: string; readonly keyId: string }
226
+ | {
227
+ readonly code: 'signing-key-algorithm-unsupported';
228
+ readonly message: string;
229
+ readonly algorithm: string;
230
+ }
231
+ | {
232
+ readonly code: 'signing-key-store-error';
233
+ readonly message: string;
234
+ readonly cause?: unknown;
235
+ };
@@ -0,0 +1,84 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+
4
+ import type { TenantId } from '@kindgi/types';
5
+
6
+ /**
7
+ * Short-lived CSRF-`state` + PKCE-`code_verifier` cache used by the
8
+ * OAuth login/callback pair. Values live between `/v1/auth/login/:id`
9
+ * (which generates `state` + `code_verifier`) and
10
+ * `/v1/auth/callback/:id` (which reads them back). TTL is measured in
11
+ * minutes — long enough for a user to complete the provider hop, short
12
+ * enough that a lost row is a non-event.
13
+ *
14
+ * The default `createInMemoryOauthStateStore` is appropriate for
15
+ * single-process dev + tests. Multi-pod deployments MUST plug in a
16
+ * shared store (Redis, Postgres) because the callback usually lands on
17
+ * a different pod than the login. Mirror of the `IdempotencyStore`
18
+ * caller-plugged pattern.
19
+ *
20
+ * Keyed by `state` alone — `state` carries 256 bits of entropy, so it
21
+ * is uniquely identifying without a namespace. `take` matches on
22
+ * `providerId` when supplied to guard against a stolen `state` being
23
+ * replayed against the wrong provider mount; `tenantId` is returned in
24
+ * the entry (the callback route learns it from the row, not the URL).
25
+ */
26
+ export interface OauthStateStore {
27
+ put(entry: OauthStateEntry): Promise<void>;
28
+ /**
29
+ * Consume the entry keyed by `state`. Returns `null` when unknown or
30
+ * expired. When `providerId` is supplied, the returned entry MUST
31
+ * match — the store returns `null` (and leaves the entry in place)
32
+ * otherwise. `tenantId` is derived from the entry.
33
+ */
34
+ take(input: OauthStateTakeInput): Promise<OauthStateEntry | null>;
35
+ }
36
+
37
+ export interface OauthStateEntry {
38
+ readonly state: string;
39
+ readonly tenantId: TenantId;
40
+ readonly providerId: string;
41
+ readonly codeVerifier: string;
42
+ readonly redirectUri: string;
43
+ readonly expiresAt: number;
44
+ }
45
+
46
+ export interface OauthStateTakeInput {
47
+ readonly state: string;
48
+ /** Optional cross-check — when set, entry must match or `take` returns null. */
49
+ readonly providerId?: string;
50
+ }
51
+
52
+ /**
53
+ * Trivial in-memory store — appropriate for tests + single-process dev.
54
+ * Entries are single-use (`take` deletes on hit) and time out on their
55
+ * own; the store performs a shallow expired-entry sweep on every call
56
+ * so long-lived processes don't leak memory when a callback never
57
+ * arrives.
58
+ */
59
+ export function createInMemoryOauthStateStore(): OauthStateStore {
60
+ const entries = new Map<string, OauthStateEntry>();
61
+
62
+ const sweep = (now: number): void => {
63
+ for (const [key, entry] of entries) {
64
+ if (entry.expiresAt <= now) entries.delete(key);
65
+ }
66
+ };
67
+
68
+ return {
69
+ async put(entry) {
70
+ sweep(Date.now());
71
+ entries.set(entry.state, entry);
72
+ },
73
+ async take({ state, providerId }) {
74
+ const now = Date.now();
75
+ sweep(now);
76
+ const entry = entries.get(state);
77
+ if (entry === undefined) return null;
78
+ if (providerId !== undefined && entry.providerId !== providerId) return null;
79
+ entries.delete(state);
80
+ if (entry.expiresAt <= now) return null;
81
+ return entry;
82
+ },
83
+ };
84
+ }