@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,727 @@
1
+ // SPDX-License-Identifier: Apache-2.0
2
+ // Copyright (C) 2026 Kindgi Inc.
3
+ import { Hono } from 'hono';
4
+ import { ref, tuplesForCreate } from '@kindgi/authz';
5
+ import { statusFor, toWireError } from '../errors.js';
6
+ import { MCP_TRANSPORTS, } from '../mcp-endpoint-binding.js';
7
+ import { deniesHostReach, stdioRefusal } from '../tenant-host-access.js';
8
+ import { clampLimit } from './pagination.js';
9
+ import { parseScopeParams, scopeResourceRef } from './scope-params.js';
10
+ import { parseSecretRef } from './secret-ref.js';
11
+ /**
12
+ * MCP-endpoint routes (mounted at `/v1/mcp`). Tenants declare the
13
+ * remote MCP servers they want the runtime to consume; at boot the
14
+ * runtime discovers each endpoint's tools and registers them into
15
+ * `ToolRegistryBinding` under the same tenant.
16
+ *
17
+ * Secrets do NOT cross the wire — `MCPEndpoint.secretRef` names a
18
+ * secret in the deployment's store, never a plaintext credential. The
19
+ * API surface accepts, stores, and returns only the reference.
20
+ *
21
+ * `hostAccess` (`KINDGI_TENANT_HOST_ACCESS`): under `deployed`, a stdio
22
+ * endpoint — a command the server would run on its own host — is
23
+ * refused with `403 host-access-denied`.
24
+ */
25
+ export function mcpRouter(binding, clientProbe, authorizer, options) {
26
+ const r = new Hono();
27
+ // Authorization PEP — config-shaped resource. `mcp_endpoint` has
28
+ // `admin from scope`, so cascade fires when scope tuple exists.
29
+ // Register gates at admin on the body's `scopeKind` + `scopeId`, parsed
30
+ // as the handler parses them (parseBodyScope); reads on :id gate at read
31
+ // on `mcp_endpoint:<id>`.
32
+ if (authorizer !== undefined) {
33
+ r.use('/endpoints', async (c, next) => {
34
+ if (c.req.method !== 'POST')
35
+ return next();
36
+ const tenantId = c.get('tenantId');
37
+ const mw = authorizer.authorize('admin', async () => {
38
+ let body = {};
39
+ try {
40
+ body = await c.req.json();
41
+ }
42
+ catch {
43
+ // POST handler validates + returns 400
44
+ }
45
+ const s = body !== null && typeof body === 'object'
46
+ ? parseBodyScope(body, tenantId)
47
+ : { kind: 'err' };
48
+ return scopeResourceRef(s.kind === 'ok' ? s.scope : undefined, tenantId);
49
+ });
50
+ return mw(c, next);
51
+ });
52
+ r.use('/endpoints/:endpointId/*', async (c, next) => {
53
+ const action = c.req.method === 'GET' ? 'read' : 'admin';
54
+ const endpointId = c.req.param('endpointId') ?? '';
55
+ const mw = authorizer.authorize(action, () => ref('mcp_endpoint', endpointId));
56
+ return mw(c, next);
57
+ });
58
+ r.use('/endpoints/:endpointId', async (c, next) => {
59
+ const action = c.req.method === 'GET' ? 'read' : 'admin';
60
+ const endpointId = c.req.param('endpointId') ?? '';
61
+ const mw = authorizer.authorize(action, () => ref('mcp_endpoint', endpointId));
62
+ return mw(c, next);
63
+ });
64
+ }
65
+ // ---------- GET /endpoints (list, cursor-paginated, optional ?transport=) ----------
66
+ r.get('/endpoints', async (c) => {
67
+ const requestId = c.get('requestId');
68
+ const tenantId = c.get('tenantId');
69
+ const limit = clampLimit(c.req.query('limit'));
70
+ const cursorRaw = c.req.query('cursor');
71
+ const transportRaw = c.req.query('transport');
72
+ let transportFilter;
73
+ if (transportRaw !== undefined && transportRaw.length > 0) {
74
+ if (!MCP_TRANSPORTS.includes(transportRaw)) {
75
+ c.status(statusFor('bad-input'));
76
+ return c.json(toWireError({
77
+ code: 'bad-input',
78
+ message: `Unknown transport "${transportRaw}" — must be one of ${MCP_TRANSPORTS.join(' / ')}`,
79
+ }, requestId));
80
+ }
81
+ transportFilter = transportRaw;
82
+ }
83
+ // `inherit` IS LOAD-BEARING for this
84
+ // policy/config-scoped binding: the mcp-endpoint list does an
85
+ // upward hierarchy walk (project → org → tenant) when inherit=true
86
+ // (default). Pass the parsed values through faithfully;
87
+ // do NOT default them in the route.
88
+ const scopeParsed = parseScopeParams(c.req.query(), { tenantId });
89
+ if (scopeParsed.kind === 'err') {
90
+ c.status(statusFor('scope-invalid'));
91
+ return c.json(toWireError({ code: 'scope-invalid', message: scopeParsed.message }, requestId));
92
+ }
93
+ const page = await binding.list({
94
+ tenantId,
95
+ limit,
96
+ ...(cursorRaw !== undefined && cursorRaw.length > 0 && { cursor: cursorRaw }),
97
+ ...(transportFilter !== undefined && { transportFilter }),
98
+ ...(scopeParsed.scope !== undefined && { scope: scopeParsed.scope }),
99
+ ...(scopeParsed.inherit !== undefined && { inherit: scopeParsed.inherit }),
100
+ });
101
+ return c.json({
102
+ data: page.data.map(serializeEndpoint),
103
+ hasMore: page.nextCursor !== undefined,
104
+ ...(page.nextCursor !== undefined && { nextCursor: page.nextCursor }),
105
+ });
106
+ });
107
+ // ---------- GET /endpoints/:endpointId ----------
108
+ r.get('/endpoints/:endpointId', async (c) => {
109
+ const requestId = c.get('requestId');
110
+ const tenantId = c.get('tenantId');
111
+ const endpointId = c.req.param('endpointId');
112
+ const endpoint = await binding.get({ tenantId, endpointId });
113
+ if (endpoint === null) {
114
+ c.status(statusFor('mcp-endpoint-not-found'));
115
+ return c.json(toWireError({
116
+ code: 'mcp-endpoint-not-found',
117
+ message: `No MCP endpoint registered with id "${endpointId}"`,
118
+ endpointId,
119
+ }, requestId));
120
+ }
121
+ return c.json(serializeEndpoint(endpoint));
122
+ });
123
+ // ---------- POST /endpoints (register) ----------
124
+ r.post('/endpoints', async (c) => {
125
+ const requestId = c.get('requestId');
126
+ const tenantId = c.get('tenantId');
127
+ let body;
128
+ try {
129
+ body = await c.req.json();
130
+ }
131
+ catch {
132
+ c.status(statusFor('bad-input'));
133
+ return c.json(toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId));
134
+ }
135
+ if (body === null || typeof body !== 'object') {
136
+ c.status(statusFor('bad-input'));
137
+ return c.json(toWireError({ code: 'bad-input', message: 'Request body must be an object' }, requestId));
138
+ }
139
+ const validation = validateMCPEndpoint(body);
140
+ if (validation.kind === 'err') {
141
+ c.status(statusFor('invalid-mcp-endpoint'));
142
+ return c.json(toWireError({
143
+ code: 'invalid-mcp-endpoint',
144
+ message: validation.error.message,
145
+ reason: validation.error.reason,
146
+ }, requestId));
147
+ }
148
+ if (validation.value.transport === 'stdio' && deniesHostReach(options.hostAccess, 'exec')) {
149
+ c.status(statusFor('host-access-denied'));
150
+ return c.json(toWireError({ code: 'host-access-denied', message: stdioRefusal(validation.value.endpointId) }, requestId));
151
+ }
152
+ // Policy/config: register requires an explicit scope. Wire
153
+ // shape mirrors the query-param triplet used by list routes —
154
+ // `scopeKind + scopeId` in the body — for uniformity.
155
+ const scopeParsed = parseBodyScope(body, tenantId);
156
+ if (scopeParsed.kind === 'err') {
157
+ c.status(statusFor('scope-invalid'));
158
+ return c.json(toWireError({ code: 'scope-invalid', message: scopeParsed.message }, requestId));
159
+ }
160
+ const registerScope = scopeParsed.scope;
161
+ const outcome = await binding.register({
162
+ tenantId,
163
+ endpoint: validation.value,
164
+ scope: registerScope,
165
+ enqueueTuples: (endpointId) => tuplesForCreate({
166
+ kind: 'mcp_endpoint',
167
+ id: endpointId,
168
+ tenantId,
169
+ scope: registerScope,
170
+ }),
171
+ });
172
+ if (outcome.kind === 'already-registered') {
173
+ c.status(statusFor('mcp-endpoint-already-registered'));
174
+ return c.json(toWireError({
175
+ code: 'mcp-endpoint-already-registered',
176
+ message: `MCP endpoint "${outcome.endpointId}" is already registered`,
177
+ endpointId: outcome.endpointId,
178
+ }, requestId));
179
+ }
180
+ if (outcome.kind === 'project-not-found') {
181
+ c.status(statusFor('scope-invalid'));
182
+ return c.json(toWireError({
183
+ code: 'scope-invalid',
184
+ message: `Project "${outcome.projectId}" not found for tenant`,
185
+ projectId: outcome.projectId,
186
+ }, requestId));
187
+ }
188
+ if (outcome.kind === 'org-not-found') {
189
+ c.status(statusFor('scope-invalid'));
190
+ return c.json(toWireError({
191
+ code: 'scope-invalid',
192
+ message: `Org "${outcome.orgId}" not found for tenant`,
193
+ orgId: outcome.orgId,
194
+ }, requestId));
195
+ }
196
+ c.status(201);
197
+ return c.json({ endpointId: outcome.endpointId });
198
+ });
199
+ // ---------- GET /endpoints/:endpointId/resources (list) ----------
200
+ r.get('/endpoints/:endpointId/resources', async (c) => {
201
+ const requestId = c.get('requestId');
202
+ const tenantId = c.get('tenantId');
203
+ const endpointId = c.req.param('endpointId');
204
+ if (clientProbe === undefined) {
205
+ c.status(statusFor('mcp-endpoint-not-found'));
206
+ return c.json(toWireError({
207
+ code: 'mcp-endpoint-not-found',
208
+ message: 'MCP client probe not configured on this deployment',
209
+ endpointId,
210
+ }, requestId));
211
+ }
212
+ const outcome = await clientProbe.listResources({ tenantId, endpointId });
213
+ if (outcome.kind === 'endpoint-not-found') {
214
+ c.status(statusFor('mcp-endpoint-not-found'));
215
+ return c.json(toWireError({
216
+ code: 'mcp-endpoint-not-found',
217
+ message: `No MCP endpoint registered with id "${endpointId}"`,
218
+ endpointId,
219
+ }, requestId));
220
+ }
221
+ if (outcome.kind === 'protocol-error') {
222
+ c.status(statusFor('mcp-resource-read-failed'));
223
+ return c.json(toWireError({
224
+ code: 'mcp-resource-read-failed',
225
+ message: outcome.message,
226
+ endpointId,
227
+ }, requestId));
228
+ }
229
+ return c.json({ data: outcome.resources.map(serializeResource) });
230
+ });
231
+ // ---------- GET /endpoints/:endpointId/resources/:uri (read; uri URL-encoded) ----------
232
+ r.get('/endpoints/:endpointId/resources/:uri', async (c) => {
233
+ const requestId = c.get('requestId');
234
+ const tenantId = c.get('tenantId');
235
+ const endpointId = c.req.param('endpointId');
236
+ const uri = decodeURIComponent(c.req.param('uri'));
237
+ if (clientProbe === undefined) {
238
+ c.status(statusFor('mcp-endpoint-not-found'));
239
+ return c.json(toWireError({
240
+ code: 'mcp-endpoint-not-found',
241
+ message: 'MCP client probe not configured on this deployment',
242
+ endpointId,
243
+ }, requestId));
244
+ }
245
+ const outcome = await clientProbe.readResource({ tenantId, endpointId, uri });
246
+ if (outcome.kind === 'endpoint-not-found') {
247
+ c.status(statusFor('mcp-endpoint-not-found'));
248
+ return c.json(toWireError({
249
+ code: 'mcp-endpoint-not-found',
250
+ message: `No MCP endpoint registered with id "${endpointId}"`,
251
+ endpointId,
252
+ }, requestId));
253
+ }
254
+ if (outcome.kind === 'resource-not-found') {
255
+ c.status(statusFor('mcp-resource-not-found'));
256
+ return c.json(toWireError({
257
+ code: 'mcp-resource-not-found',
258
+ message: `No MCP resource "${outcome.uri}" at endpoint "${endpointId}"`,
259
+ endpointId,
260
+ uri: outcome.uri,
261
+ }, requestId));
262
+ }
263
+ if (outcome.kind === 'read-failed') {
264
+ c.status(statusFor('mcp-resource-read-failed'));
265
+ return c.json(toWireError({
266
+ code: 'mcp-resource-read-failed',
267
+ message: outcome.message,
268
+ endpointId,
269
+ uri,
270
+ }, requestId));
271
+ }
272
+ return c.json(serializeResourceContent(outcome.content));
273
+ });
274
+ // ---------- GET /endpoints/:endpointId/prompts (list) ----------
275
+ r.get('/endpoints/:endpointId/prompts', async (c) => {
276
+ const requestId = c.get('requestId');
277
+ const tenantId = c.get('tenantId');
278
+ const endpointId = c.req.param('endpointId');
279
+ if (clientProbe === undefined) {
280
+ c.status(statusFor('mcp-endpoint-not-found'));
281
+ return c.json(toWireError({
282
+ code: 'mcp-endpoint-not-found',
283
+ message: 'MCP client probe not configured on this deployment',
284
+ endpointId,
285
+ }, requestId));
286
+ }
287
+ const outcome = await clientProbe.listPrompts({ tenantId, endpointId });
288
+ if (outcome.kind === 'endpoint-not-found') {
289
+ c.status(statusFor('mcp-endpoint-not-found'));
290
+ return c.json(toWireError({
291
+ code: 'mcp-endpoint-not-found',
292
+ message: `No MCP endpoint registered with id "${endpointId}"`,
293
+ endpointId,
294
+ }, requestId));
295
+ }
296
+ if (outcome.kind === 'protocol-error') {
297
+ c.status(statusFor('mcp-prompt-get-failed'));
298
+ return c.json(toWireError({
299
+ code: 'mcp-prompt-get-failed',
300
+ message: outcome.message,
301
+ endpointId,
302
+ }, requestId));
303
+ }
304
+ return c.json({ data: outcome.prompts.map(serializePrompt) });
305
+ });
306
+ // ---------- POST /endpoints/:endpointId/prompts/:name (get, args in body) ----------
307
+ r.post('/endpoints/:endpointId/prompts/:name', async (c) => {
308
+ const requestId = c.get('requestId');
309
+ const tenantId = c.get('tenantId');
310
+ const endpointId = c.req.param('endpointId');
311
+ const name = c.req.param('name');
312
+ if (clientProbe === undefined) {
313
+ c.status(statusFor('mcp-endpoint-not-found'));
314
+ return c.json(toWireError({
315
+ code: 'mcp-endpoint-not-found',
316
+ message: 'MCP client probe not configured on this deployment',
317
+ endpointId,
318
+ }, requestId));
319
+ }
320
+ let body = {};
321
+ const raw = await c.req.text();
322
+ if (raw.length > 0) {
323
+ try {
324
+ body = JSON.parse(raw);
325
+ }
326
+ catch {
327
+ c.status(statusFor('bad-input'));
328
+ return c.json(toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId));
329
+ }
330
+ }
331
+ if (body === null || typeof body !== 'object') {
332
+ c.status(statusFor('bad-input'));
333
+ return c.json(toWireError({ code: 'bad-input', message: 'Request body must be an object' }, requestId));
334
+ }
335
+ const argsRaw = body.arguments;
336
+ let args;
337
+ if (argsRaw !== undefined) {
338
+ if (typeof argsRaw !== 'object' ||
339
+ argsRaw === null ||
340
+ Object.values(argsRaw).some((v) => typeof v !== 'string')) {
341
+ c.status(statusFor('bad-input'));
342
+ return c.json(toWireError({
343
+ code: 'bad-input',
344
+ message: 'arguments must be a Record<string, string>',
345
+ }, requestId));
346
+ }
347
+ args = argsRaw;
348
+ }
349
+ const outcome = await clientProbe.getPrompt({
350
+ tenantId,
351
+ endpointId,
352
+ name,
353
+ ...(args !== undefined && { args }),
354
+ });
355
+ if (outcome.kind === 'endpoint-not-found') {
356
+ c.status(statusFor('mcp-endpoint-not-found'));
357
+ return c.json(toWireError({
358
+ code: 'mcp-endpoint-not-found',
359
+ message: `No MCP endpoint registered with id "${endpointId}"`,
360
+ endpointId,
361
+ }, requestId));
362
+ }
363
+ if (outcome.kind === 'prompt-not-found') {
364
+ c.status(statusFor('mcp-prompt-not-found'));
365
+ return c.json(toWireError({
366
+ code: 'mcp-prompt-not-found',
367
+ message: `No MCP prompt "${outcome.name}" at endpoint "${endpointId}"`,
368
+ endpointId,
369
+ promptName: outcome.name,
370
+ }, requestId));
371
+ }
372
+ if (outcome.kind === 'get-failed') {
373
+ c.status(statusFor('mcp-prompt-get-failed'));
374
+ return c.json(toWireError({
375
+ code: 'mcp-prompt-get-failed',
376
+ message: outcome.message,
377
+ endpointId,
378
+ promptName: name,
379
+ }, requestId));
380
+ }
381
+ return c.json({ messages: outcome.messages.map(serializePromptMessage) });
382
+ });
383
+ // ---------- POST /endpoints/:endpointId/unregister ----------
384
+ r.post('/endpoints/:endpointId/unregister', async (c) => {
385
+ const requestId = c.get('requestId');
386
+ const tenantId = c.get('tenantId');
387
+ const endpointId = c.req.param('endpointId');
388
+ const outcome = await binding.unregister({ tenantId, endpointId });
389
+ if (!outcome.unregistered) {
390
+ c.status(statusFor('mcp-endpoint-not-found'));
391
+ return c.json(toWireError({
392
+ code: 'mcp-endpoint-not-found',
393
+ message: `No MCP endpoint "${endpointId}" to unregister`,
394
+ endpointId,
395
+ }, requestId));
396
+ }
397
+ return c.json({ endpointId, unregistered: true });
398
+ });
399
+ return r;
400
+ }
401
+ function serializeResource(r) {
402
+ return {
403
+ uri: r.uri,
404
+ name: r.name,
405
+ ...(r.description !== undefined && { description: r.description }),
406
+ ...(r.mimeType !== undefined && { mimeType: r.mimeType }),
407
+ };
408
+ }
409
+ function serializeResourceContent(c) {
410
+ return {
411
+ uri: c.uri,
412
+ ...(c.mimeType !== undefined && { mimeType: c.mimeType }),
413
+ ...(c.text !== undefined && { text: c.text }),
414
+ ...(c.blob !== undefined && { blob: c.blob }),
415
+ };
416
+ }
417
+ function serializePrompt(p) {
418
+ return {
419
+ name: p.name,
420
+ ...(p.description !== undefined && { description: p.description }),
421
+ ...(p.arguments !== undefined && {
422
+ arguments: p.arguments.map((a) => ({
423
+ name: a.name,
424
+ ...(a.description !== undefined && { description: a.description }),
425
+ ...(a.required !== undefined && { required: a.required }),
426
+ })),
427
+ }),
428
+ };
429
+ }
430
+ function serializePromptMessage(m) {
431
+ return { role: m.role, content: m.content };
432
+ }
433
+ function serializeEndpoint(e) {
434
+ return {
435
+ endpointId: e.endpointId,
436
+ name: e.name,
437
+ transport: e.transport,
438
+ config: e.config,
439
+ ...(e.secretRef !== undefined && { secretRef: e.secretRef }),
440
+ ...(e.instructions !== undefined && { instructions: e.instructions }),
441
+ ...(e.metadata !== undefined && { metadata: e.metadata }),
442
+ };
443
+ }
444
+ /** The register body: the endpoint, plus the scope it's registered in. */
445
+ const REGISTER_BODY_FIELDS = new Set([
446
+ 'endpointId',
447
+ 'name',
448
+ 'transport',
449
+ 'config',
450
+ 'secretRef',
451
+ 'instructions',
452
+ 'metadata',
453
+ 'scopeKind',
454
+ 'scopeId',
455
+ ]);
456
+ /**
457
+ * Wire-shape validator. Enforces the closed transport enum + the
458
+ * config-transport-matches-top-level guardrail + required fields per
459
+ * variant. Returns a `Result`-ish shape.
460
+ */
461
+ function validateMCPEndpoint(body) {
462
+ const b = body;
463
+ const unknown = Object.keys(b).find((key) => !REGISTER_BODY_FIELDS.has(key));
464
+ if (unknown !== undefined) {
465
+ return {
466
+ kind: 'err',
467
+ error: { message: `Unknown field \`${unknown}\``, reason: 'unknown-field' },
468
+ };
469
+ }
470
+ if (typeof b.endpointId !== 'string' || b.endpointId.length === 0) {
471
+ return {
472
+ kind: 'err',
473
+ error: { message: 'endpointId required (non-empty string)', reason: 'empty-endpoint-id' },
474
+ };
475
+ }
476
+ if (typeof b.name !== 'string' || b.name.length === 0) {
477
+ return {
478
+ kind: 'err',
479
+ error: {
480
+ message: `endpoint "${b.endpointId}" missing name`,
481
+ reason: 'empty-name',
482
+ },
483
+ };
484
+ }
485
+ if (typeof b.transport !== 'string' ||
486
+ !MCP_TRANSPORTS.includes(b.transport)) {
487
+ return {
488
+ kind: 'err',
489
+ error: {
490
+ message: `endpoint "${b.endpointId}" transport must be one of ${MCP_TRANSPORTS.join(' / ')} — got "${String(b.transport)}"`,
491
+ reason: 'unknown-transport',
492
+ },
493
+ };
494
+ }
495
+ const cfg = b.config;
496
+ if (cfg === undefined || cfg === null || typeof cfg !== 'object') {
497
+ return {
498
+ kind: 'err',
499
+ error: {
500
+ message: `endpoint "${b.endpointId}" config required (object)`,
501
+ reason: 'missing-config',
502
+ },
503
+ };
504
+ }
505
+ const cfgAny = cfg;
506
+ if (cfgAny.transport !== b.transport) {
507
+ return {
508
+ kind: 'err',
509
+ error: {
510
+ message: `endpoint "${b.endpointId}" config.transport must match top-level transport (got "${String(cfgAny.transport)}" vs "${b.transport}")`,
511
+ reason: 'config-transport-mismatch',
512
+ },
513
+ };
514
+ }
515
+ const configResult = validateConfig(b.endpointId, cfgAny);
516
+ if (configResult.kind === 'err')
517
+ return configResult;
518
+ const secretRef = b.secretRef === undefined ? undefined : parseSecretRef(b.secretRef);
519
+ if (secretRef?.kind === 'err') {
520
+ return {
521
+ kind: 'err',
522
+ error: {
523
+ message: `endpoint "${b.endpointId}": ${secretRef.message}`,
524
+ reason: 'invalid-secret-ref',
525
+ },
526
+ };
527
+ }
528
+ if (b.instructions !== undefined && typeof b.instructions !== 'string') {
529
+ return {
530
+ kind: 'err',
531
+ error: {
532
+ message: `endpoint "${b.endpointId}" instructions must be a string`,
533
+ reason: 'invalid-instructions',
534
+ },
535
+ };
536
+ }
537
+ if (b.metadata !== undefined && (typeof b.metadata !== 'object' || b.metadata === null)) {
538
+ return {
539
+ kind: 'err',
540
+ error: {
541
+ message: `endpoint "${b.endpointId}" metadata must be an object`,
542
+ reason: 'invalid-metadata',
543
+ },
544
+ };
545
+ }
546
+ const value = {
547
+ endpointId: b.endpointId,
548
+ name: b.name,
549
+ transport: b.transport,
550
+ config: configResult.value,
551
+ ...(secretRef !== undefined && { secretRef: secretRef.value }),
552
+ ...(b.instructions !== undefined && { instructions: b.instructions }),
553
+ ...(b.metadata !== undefined && {
554
+ metadata: b.metadata,
555
+ }),
556
+ };
557
+ return { kind: 'ok', value };
558
+ }
559
+ function validateConfig(endpointId, cfg) {
560
+ if (cfg.transport === 'stdio') {
561
+ if (typeof cfg.command !== 'string' || cfg.command.length === 0) {
562
+ return {
563
+ kind: 'err',
564
+ error: {
565
+ message: `endpoint "${endpointId}" stdio config.command required (non-empty string)`,
566
+ reason: 'invalid-stdio-command',
567
+ },
568
+ };
569
+ }
570
+ if (cfg.args !== undefined) {
571
+ if (!Array.isArray(cfg.args) || cfg.args.some((a) => typeof a !== 'string')) {
572
+ return {
573
+ kind: 'err',
574
+ error: {
575
+ message: `endpoint "${endpointId}" stdio config.args must be an array of strings`,
576
+ reason: 'invalid-stdio-args',
577
+ },
578
+ };
579
+ }
580
+ }
581
+ if (cfg.env !== undefined) {
582
+ if (typeof cfg.env !== 'object' ||
583
+ cfg.env === null ||
584
+ Object.values(cfg.env).some((v) => typeof v !== 'string')) {
585
+ return {
586
+ kind: 'err',
587
+ error: {
588
+ message: `endpoint "${endpointId}" stdio config.env must be a Record<string, string>`,
589
+ reason: 'invalid-stdio-env',
590
+ },
591
+ };
592
+ }
593
+ }
594
+ return {
595
+ kind: 'ok',
596
+ value: {
597
+ transport: 'stdio',
598
+ command: cfg.command,
599
+ ...(cfg.args !== undefined && { args: cfg.args }),
600
+ ...(cfg.env !== undefined && { env: cfg.env }),
601
+ },
602
+ };
603
+ }
604
+ if (cfg.transport === 'http-sse') {
605
+ if (typeof cfg.url !== 'string' || cfg.url.length === 0) {
606
+ return {
607
+ kind: 'err',
608
+ error: {
609
+ message: `endpoint "${endpointId}" http-sse config.url required (non-empty string)`,
610
+ reason: 'invalid-http-sse-url',
611
+ },
612
+ };
613
+ }
614
+ if (cfg.sseUrl !== undefined && typeof cfg.sseUrl !== 'string') {
615
+ return {
616
+ kind: 'err',
617
+ error: {
618
+ message: `endpoint "${endpointId}" http-sse config.sseUrl must be a string`,
619
+ reason: 'invalid-http-sse-sse-url',
620
+ },
621
+ };
622
+ }
623
+ if (cfg.headers !== undefined &&
624
+ (typeof cfg.headers !== 'object' ||
625
+ cfg.headers === null ||
626
+ Object.values(cfg.headers).some((v) => typeof v !== 'string'))) {
627
+ return {
628
+ kind: 'err',
629
+ error: {
630
+ message: `endpoint "${endpointId}" http-sse config.headers must be a Record<string, string>`,
631
+ reason: 'invalid-http-sse-headers',
632
+ },
633
+ };
634
+ }
635
+ return {
636
+ kind: 'ok',
637
+ value: {
638
+ transport: 'http-sse',
639
+ url: cfg.url,
640
+ ...(cfg.sseUrl !== undefined && { sseUrl: cfg.sseUrl }),
641
+ ...(cfg.headers !== undefined && {
642
+ headers: cfg.headers,
643
+ }),
644
+ },
645
+ };
646
+ }
647
+ // streamable-http
648
+ if (typeof cfg.url !== 'string' || cfg.url.length === 0) {
649
+ return {
650
+ kind: 'err',
651
+ error: {
652
+ message: `endpoint "${endpointId}" streamable-http config.url required (non-empty string)`,
653
+ reason: 'invalid-streamable-http-url',
654
+ },
655
+ };
656
+ }
657
+ if (cfg.headers !== undefined &&
658
+ (typeof cfg.headers !== 'object' ||
659
+ cfg.headers === null ||
660
+ Object.values(cfg.headers).some((v) => typeof v !== 'string'))) {
661
+ return {
662
+ kind: 'err',
663
+ error: {
664
+ message: `endpoint "${endpointId}" streamable-http config.headers must be a Record<string, string>`,
665
+ reason: 'invalid-streamable-http-headers',
666
+ },
667
+ };
668
+ }
669
+ return {
670
+ kind: 'ok',
671
+ value: {
672
+ transport: 'streamable-http',
673
+ url: cfg.url,
674
+ ...(cfg.headers !== undefined && {
675
+ headers: cfg.headers,
676
+ }),
677
+ },
678
+ };
679
+ }
680
+ /**
681
+ * Parse the register-body's `scopeKind + scopeId` triplet into a
682
+ * discriminated `Scope`. Mirrors the query-param triplet shape from
683
+ * `parseScopeParams` so write bodies and read query params
684
+ * stay uniform. Cross-field validation:
685
+ *
686
+ * - `scopeKind` required, one of `'tenant' | 'org' | 'project'`.
687
+ * - `scopeKind = 'tenant'` → `scopeId` MUST be absent (tenant is
688
+ * implicit from the session).
689
+ * - `scopeKind ∈ {'org','project'}` → `scopeId` required, non-empty.
690
+ */
691
+ function parseBodyScope(body, tenantId) {
692
+ const b = body;
693
+ const kindRaw = b.scopeKind;
694
+ const idRaw = b.scopeId;
695
+ if (typeof kindRaw !== 'string' || kindRaw.length === 0) {
696
+ return {
697
+ kind: 'err',
698
+ message: 'scopeKind required in register body: one of "tenant" | "org" | "project"',
699
+ };
700
+ }
701
+ if (kindRaw !== 'tenant' && kindRaw !== 'org' && kindRaw !== 'project') {
702
+ return {
703
+ kind: 'err',
704
+ message: `scopeKind must be one of "tenant" | "org" | "project", got "${kindRaw}"`,
705
+ };
706
+ }
707
+ if (kindRaw === 'tenant') {
708
+ if (idRaw !== undefined && idRaw !== null && String(idRaw).length > 0) {
709
+ return {
710
+ kind: 'err',
711
+ message: `scopeKind="tenant" takes no scopeId (tenant is implicit from the session)`,
712
+ };
713
+ }
714
+ return { kind: 'ok', scope: { kind: 'tenant', tenantId } };
715
+ }
716
+ if (typeof idRaw !== 'string' || idRaw.length === 0) {
717
+ return {
718
+ kind: 'err',
719
+ message: `scopeKind="${kindRaw}" requires a non-empty scopeId in the body`,
720
+ };
721
+ }
722
+ const scope = kindRaw === 'org'
723
+ ? { kind: 'org', tenantId, orgId: idRaw }
724
+ : { kind: 'project', tenantId, projectId: idRaw };
725
+ return { kind: 'ok', scope };
726
+ }
727
+ //# sourceMappingURL=mcp.js.map