@kindgi/api 0.1.3 → 0.1.4-rc.1

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 (222) hide show
  1. package/dist/agent-binding.d.ts +26 -4
  2. package/dist/agent-binding.d.ts.map +1 -1
  3. package/dist/agent-pins.d.ts +48 -0
  4. package/dist/agent-pins.d.ts.map +1 -0
  5. package/dist/agent-pins.js +102 -0
  6. package/dist/agent-pins.js.map +1 -0
  7. package/dist/app.d.ts +22 -0
  8. package/dist/app.d.ts.map +1 -1
  9. package/dist/app.js +27 -3
  10. package/dist/app.js.map +1 -1
  11. package/dist/block-binding.d.ts +132 -0
  12. package/dist/block-binding.d.ts.map +1 -0
  13. package/dist/block-binding.js +4 -0
  14. package/dist/block-binding.js.map +1 -0
  15. package/dist/block-pins.d.ts +22 -0
  16. package/dist/block-pins.d.ts.map +1 -0
  17. package/dist/block-pins.js +112 -0
  18. package/dist/block-pins.js.map +1 -0
  19. package/dist/cost-binding.d.ts +20 -1
  20. package/dist/cost-binding.d.ts.map +1 -1
  21. package/dist/cost-binding.js +4 -0
  22. package/dist/cost-binding.js.map +1 -1
  23. package/dist/deploy-versions.d.ts +60 -0
  24. package/dist/deploy-versions.d.ts.map +1 -0
  25. package/dist/deploy-versions.js +91 -0
  26. package/dist/deploy-versions.js.map +1 -0
  27. package/dist/deployment-binding.d.ts +24 -3
  28. package/dist/deployment-binding.d.ts.map +1 -1
  29. package/dist/derive-agent-version.d.ts +77 -0
  30. package/dist/derive-agent-version.d.ts.map +1 -0
  31. package/dist/derive-agent-version.js +149 -0
  32. package/dist/derive-agent-version.js.map +1 -0
  33. package/dist/errors.d.ts.map +1 -1
  34. package/dist/errors.js +18 -0
  35. package/dist/errors.js.map +1 -1
  36. package/dist/eval-case-binding.d.ts +65 -0
  37. package/dist/eval-case-binding.d.ts.map +1 -0
  38. package/dist/eval-case-binding.js +4 -0
  39. package/dist/eval-case-binding.js.map +1 -0
  40. package/dist/eval-run-binding.d.ts +37 -0
  41. package/dist/eval-run-binding.d.ts.map +1 -1
  42. package/dist/eval-run-binding.js.map +1 -1
  43. package/dist/eval-run-dispatcher.d.ts +41 -3
  44. package/dist/eval-run-dispatcher.d.ts.map +1 -1
  45. package/dist/eval-run-dispatcher.js +21 -15
  46. package/dist/eval-run-dispatcher.js.map +1 -1
  47. package/dist/eval-suite-binding.d.ts +1 -1
  48. package/dist/eval-suite-binding.d.ts.map +1 -1
  49. package/dist/eval-suite-binding.js +2 -0
  50. package/dist/eval-suite-binding.js.map +1 -1
  51. package/dist/flow-binding.d.ts +18 -4
  52. package/dist/flow-binding.d.ts.map +1 -1
  53. package/dist/flow-pins.d.ts +36 -0
  54. package/dist/flow-pins.d.ts.map +1 -0
  55. package/dist/flow-pins.js +81 -0
  56. package/dist/flow-pins.js.map +1 -0
  57. package/dist/guardrail-binding.d.ts +8 -0
  58. package/dist/guardrail-binding.d.ts.map +1 -1
  59. package/dist/handler-binding.d.ts +3 -0
  60. package/dist/handler-binding.d.ts.map +1 -1
  61. package/dist/index.d.ts +18 -6
  62. package/dist/index.d.ts.map +1 -1
  63. package/dist/index.js +8 -2
  64. package/dist/index.js.map +1 -1
  65. package/dist/judged-dispatcher.d.ts +138 -0
  66. package/dist/judged-dispatcher.d.ts.map +1 -0
  67. package/dist/judged-dispatcher.js +308 -0
  68. package/dist/judged-dispatcher.js.map +1 -0
  69. package/dist/judged-items.d.ts +86 -0
  70. package/dist/judged-items.d.ts.map +1 -0
  71. package/dist/judged-items.js +184 -0
  72. package/dist/judged-items.js.map +1 -0
  73. package/dist/judgment-binding.d.ts +316 -0
  74. package/dist/judgment-binding.d.ts.map +1 -0
  75. package/dist/judgment-binding.js +19 -0
  76. package/dist/judgment-binding.js.map +1 -0
  77. package/dist/openapi/generate.d.ts.map +1 -1
  78. package/dist/openapi/generate.js +4 -1
  79. package/dist/openapi/generate.js.map +1 -1
  80. package/dist/openapi/operations.d.ts.map +1 -1
  81. package/dist/openapi/operations.js +482 -13
  82. package/dist/openapi/operations.js.map +1 -1
  83. package/dist/openapi/schemas.d.ts +46 -0
  84. package/dist/openapi/schemas.d.ts.map +1 -1
  85. package/dist/openapi/schemas.js +1350 -175
  86. package/dist/openapi/schemas.js.map +1 -1
  87. package/dist/provider-binding.d.ts +12 -7
  88. package/dist/provider-binding.d.ts.map +1 -1
  89. package/dist/registry-read-only.d.ts +32 -0
  90. package/dist/registry-read-only.d.ts.map +1 -0
  91. package/dist/registry-read-only.js +22 -0
  92. package/dist/registry-read-only.js.map +1 -0
  93. package/dist/routes/agents.d.ts +9 -1
  94. package/dist/routes/agents.d.ts.map +1 -1
  95. package/dist/routes/agents.js +181 -11
  96. package/dist/routes/agents.js.map +1 -1
  97. package/dist/routes/blocks.d.ts +19 -0
  98. package/dist/routes/blocks.d.ts.map +1 -0
  99. package/dist/routes/blocks.js +306 -0
  100. package/dist/routes/blocks.js.map +1 -0
  101. package/dist/routes/cost.d.ts.map +1 -1
  102. package/dist/routes/cost.js +47 -2
  103. package/dist/routes/cost.js.map +1 -1
  104. package/dist/routes/deployments.d.ts +3 -0
  105. package/dist/routes/deployments.d.ts.map +1 -1
  106. package/dist/routes/deployments.js +224 -55
  107. package/dist/routes/deployments.js.map +1 -1
  108. package/dist/routes/eval-comparison.d.ts +15 -0
  109. package/dist/routes/eval-comparison.d.ts.map +1 -0
  110. package/dist/routes/eval-comparison.js +123 -0
  111. package/dist/routes/eval-comparison.js.map +1 -0
  112. package/dist/routes/eval-runs.d.ts +7 -1
  113. package/dist/routes/eval-runs.d.ts.map +1 -1
  114. package/dist/routes/eval-runs.js +42 -3
  115. package/dist/routes/eval-runs.js.map +1 -1
  116. package/dist/routes/eval-versions.d.ts +25 -0
  117. package/dist/routes/eval-versions.d.ts.map +1 -0
  118. package/dist/routes/eval-versions.js +66 -0
  119. package/dist/routes/eval-versions.js.map +1 -0
  120. package/dist/routes/flows.d.ts +13 -1
  121. package/dist/routes/flows.d.ts.map +1 -1
  122. package/dist/routes/flows.js +48 -3
  123. package/dist/routes/flows.js.map +1 -1
  124. package/dist/routes/guardrails.d.ts.map +1 -1
  125. package/dist/routes/guardrails.js +4 -0
  126. package/dist/routes/guardrails.js.map +1 -1
  127. package/dist/routes/hierarchy-errors.d.ts +45 -0
  128. package/dist/routes/hierarchy-errors.d.ts.map +1 -0
  129. package/dist/routes/hierarchy-errors.js +47 -0
  130. package/dist/routes/hierarchy-errors.js.map +1 -0
  131. package/dist/routes/judged-suites.d.ts +20 -0
  132. package/dist/routes/judged-suites.d.ts.map +1 -0
  133. package/dist/routes/judged-suites.js +272 -0
  134. package/dist/routes/judged-suites.js.map +1 -0
  135. package/dist/routes/judgment-context.d.ts +22 -0
  136. package/dist/routes/judgment-context.d.ts.map +1 -0
  137. package/dist/routes/judgment-context.js +88 -0
  138. package/dist/routes/judgment-context.js.map +1 -0
  139. package/dist/routes/judgment-flow-context.d.ts +32 -0
  140. package/dist/routes/judgment-flow-context.d.ts.map +1 -0
  141. package/dist/routes/judgment-flow-context.js +195 -0
  142. package/dist/routes/judgment-flow-context.js.map +1 -0
  143. package/dist/routes/judgments.d.ts +41 -0
  144. package/dist/routes/judgments.d.ts.map +1 -0
  145. package/dist/routes/judgments.js +566 -0
  146. package/dist/routes/judgments.js.map +1 -0
  147. package/dist/routes/orgs.d.ts +5 -2
  148. package/dist/routes/orgs.d.ts.map +1 -1
  149. package/dist/routes/orgs.js +38 -22
  150. package/dist/routes/orgs.js.map +1 -1
  151. package/dist/routes/policies.d.ts.map +1 -1
  152. package/dist/routes/policies.js +12 -1
  153. package/dist/routes/policies.js.map +1 -1
  154. package/dist/routes/projects.d.ts +10 -2
  155. package/dist/routes/projects.d.ts.map +1 -1
  156. package/dist/routes/projects.js +94 -80
  157. package/dist/routes/projects.js.map +1 -1
  158. package/dist/routes/providers.d.ts.map +1 -1
  159. package/dist/routes/providers.js +6 -1
  160. package/dist/routes/providers.js.map +1 -1
  161. package/dist/routes/runs.js +25 -3
  162. package/dist/routes/runs.js.map +1 -1
  163. package/dist/routes/teams.d.ts +6 -2
  164. package/dist/routes/teams.d.ts.map +1 -1
  165. package/dist/routes/teams.js +83 -73
  166. package/dist/routes/teams.js.map +1 -1
  167. package/dist/routes/tools.d.ts.map +1 -1
  168. package/dist/routes/tools.js +4 -0
  169. package/dist/routes/tools.js.map +1 -1
  170. package/dist/tool-binding.d.ts +8 -0
  171. package/dist/tool-binding.d.ts.map +1 -1
  172. package/openapi.json +14253 -10099
  173. package/package.json +21 -21
  174. package/src/agent-binding.ts +28 -4
  175. package/src/agent-pins.ts +147 -0
  176. package/src/app.ts +81 -3
  177. package/src/block-binding.ts +137 -0
  178. package/src/block-pins.ts +148 -0
  179. package/src/cost-binding.ts +21 -1
  180. package/src/deploy-versions.ts +157 -0
  181. package/src/deployment-binding.ts +27 -3
  182. package/src/derive-agent-version.ts +217 -0
  183. package/src/errors.ts +18 -0
  184. package/src/eval-case-binding.ts +71 -0
  185. package/src/eval-run-binding.ts +40 -0
  186. package/src/eval-run-dispatcher.ts +60 -16
  187. package/src/eval-suite-binding.ts +2 -0
  188. package/src/flow-binding.ts +20 -4
  189. package/src/flow-pins.ts +113 -0
  190. package/src/guardrail-binding.ts +9 -0
  191. package/src/handler-binding.ts +3 -0
  192. package/src/index.ts +86 -2
  193. package/src/judged-dispatcher.ts +530 -0
  194. package/src/judged-items.ts +263 -0
  195. package/src/judgment-binding.ts +349 -0
  196. package/src/openapi/generate.ts +7 -1
  197. package/src/openapi/operations.ts +579 -13
  198. package/src/openapi/schemas.ts +1408 -128
  199. package/src/provider-binding.ts +12 -7
  200. package/src/registry-read-only.ts +43 -0
  201. package/src/routes/agents.ts +252 -19
  202. package/src/routes/blocks.ts +387 -0
  203. package/src/routes/cost.ts +55 -1
  204. package/src/routes/deployments.ts +291 -56
  205. package/src/routes/eval-comparison.ts +135 -0
  206. package/src/routes/eval-runs.ts +57 -3
  207. package/src/routes/eval-versions.ts +110 -0
  208. package/src/routes/flows.ts +70 -5
  209. package/src/routes/guardrails.ts +7 -0
  210. package/src/routes/hierarchy-errors.ts +60 -0
  211. package/src/routes/judged-suites.ts +363 -0
  212. package/src/routes/judgment-context.ts +128 -0
  213. package/src/routes/judgment-flow-context.ts +245 -0
  214. package/src/routes/judgments.ts +743 -0
  215. package/src/routes/orgs.ts +44 -27
  216. package/src/routes/policies.ts +19 -0
  217. package/src/routes/projects.ts +118 -96
  218. package/src/routes/providers.ts +5 -0
  219. package/src/routes/runs.ts +29 -3
  220. package/src/routes/teams.ts +104 -90
  221. package/src/routes/tools.ts +7 -0
  222. package/src/tool-binding.ts +9 -0
@@ -149,6 +149,24 @@ const RunAgentIdQueryParam: ParameterSpec = {
149
149
  schema: { type: 'string', minLength: 1 },
150
150
  };
151
151
 
152
+ const RunReplaysQueryParam: ParameterSpec = {
153
+ name: 'replays',
154
+ in: 'query',
155
+ required: false,
156
+ description:
157
+ 'Replay runs (an eval run re-running a past run). `exclude` (default) leaves them out; `include` lists them with the other runs; `only` lists just them.',
158
+ schema: { type: 'string', enum: ['exclude', 'include', 'only'], default: 'exclude' },
159
+ };
160
+
161
+ const RunEvalRunIdQueryParam: ParameterSpec = {
162
+ name: 'evalRunId',
163
+ in: 'query',
164
+ required: false,
165
+ description:
166
+ 'Only the replay runs of this eval run. Implies replays are included; cannot be combined with `replays=exclude`.',
167
+ schema: { type: 'string', minLength: 1 },
168
+ };
169
+
152
170
  const RunIncludeQueryParam: ParameterSpec = {
153
171
  name: 'include',
154
172
  in: 'query',
@@ -554,6 +572,15 @@ const CostGroupByQueryParam: ParameterSpec = {
554
572
  schema: { type: 'string' },
555
573
  };
556
574
 
575
+ const CostAggregateLimitQueryParam: ParameterSpec = {
576
+ name: 'limit',
577
+ in: 'query',
578
+ required: false,
579
+ description:
580
+ 'The most groups to return: the most expensive ones (`groups` is ordered by `totalUsd`, highest first). 1 to 10000, default 1000. When there were more, `truncated` is `true` and `totalGroups` says how many; the totals still cover every record.',
581
+ schema: { type: 'integer', minimum: 1, maximum: 10000, default: 1000 },
582
+ };
583
+
557
584
  const CostModelQueryParam: ParameterSpec = {
558
585
  name: 'model',
559
586
  in: 'query',
@@ -777,7 +804,7 @@ const EvalSuiteKindFilterQueryParam: ParameterSpec = {
777
804
  in: 'query',
778
805
  required: false,
779
806
  description:
780
- 'Filter to eval suites of a single kind. Values: `accuracy | pairwise | regression | human-review | benchmark | custom`.',
807
+ 'Filter to eval suites of a single kind. Values: `accuracy | pairwise | regression | human-review | benchmark | custom | judged`.',
781
808
  schema: { $ref: '#/components/schemas/EvalKind' },
782
809
  };
783
810
 
@@ -789,6 +816,38 @@ const EvalSuiteNameFilterQueryParam: ParameterSpec = {
789
816
  schema: { type: 'string' },
790
817
  };
791
818
 
819
+ const BlockIdPathParam: ParameterSpec = {
820
+ name: 'blockId',
821
+ in: 'path',
822
+ required: true,
823
+ description: 'Block id: dotted lowercase (e.g. `acme.intake-prompt`).',
824
+ schema: { type: 'string', minLength: 1 },
825
+ };
826
+
827
+ const BlockVersionPathParam: ParameterSpec = {
828
+ name: 'version',
829
+ in: 'path',
830
+ required: true,
831
+ description: 'Exact block version (`major.minor.patch`).',
832
+ schema: { type: 'string', minLength: 1 },
833
+ };
834
+
835
+ const BlockKindFilterQueryParam: ParameterSpec = {
836
+ name: 'kind',
837
+ in: 'query',
838
+ required: false,
839
+ description: 'Only blocks of this kind: `prompt` or `settings`.',
840
+ schema: { $ref: '#/components/schemas/BlockKind' },
841
+ };
842
+
843
+ const BlockNameFilterQueryParam: ParameterSpec = {
844
+ name: 'name',
845
+ in: 'query',
846
+ required: false,
847
+ description: 'Prefix match on the block id.',
848
+ schema: { type: 'string' },
849
+ };
850
+
792
851
  // Admin plane — eval-run data plane.
793
852
 
794
853
  const EvalRunIdPathParam: ParameterSpec = {
@@ -910,6 +969,75 @@ const SecretNamePathParam: ParameterSpec = {
910
969
  schema: { type: 'string', minLength: 1 },
911
970
  };
912
971
 
972
+ // ---------------- judgments + judge classes: parameters ----------------
973
+
974
+ const JudgmentIdPathParam: ParameterSpec = {
975
+ name: 'judgmentId',
976
+ in: 'path',
977
+ required: true,
978
+ description: 'Judgment id.',
979
+ schema: { type: 'string', minLength: 1 },
980
+ };
981
+
982
+ const JudgeClassIdPathParam: ParameterSpec = {
983
+ name: 'judgeClassId',
984
+ in: 'path',
985
+ required: true,
986
+ description: 'Judge class id.',
987
+ schema: { type: 'string', minLength: 1 },
988
+ };
989
+
990
+ const judgmentQuery = (name: string, description: string, schema: JsonSchema): ParameterSpec => ({
991
+ name,
992
+ in: 'query',
993
+ required: false,
994
+ description,
995
+ schema,
996
+ });
997
+
998
+ const JudgmentListQueryParams: readonly ParameterSpec[] = [
999
+ judgmentQuery('runId', 'Only judgments of this run.', { type: 'string', minLength: 1 }),
1000
+ judgmentQuery('agentId', 'Only judgments of runs of this agent.', {
1001
+ type: 'string',
1002
+ minLength: 1,
1003
+ }),
1004
+ judgmentQuery('agentVersion', 'Only judgments of runs of this agent version. Needs `agentId`.', {
1005
+ type: 'string',
1006
+ minLength: 1,
1007
+ }),
1008
+ judgmentQuery('flowId', 'Only judgments of runs of this flow.', { type: 'string', minLength: 1 }),
1009
+ judgmentQuery('verdict', 'Only judgments with this verdict.', {
1010
+ type: 'string',
1011
+ enum: ['yes', 'no'],
1012
+ }),
1013
+ judgmentQuery('judgeClassId', 'Only judgments recorded under this judge class.', {
1014
+ type: 'string',
1015
+ minLength: 1,
1016
+ }),
1017
+ judgmentQuery('participantId', "Only judgments made for this app end user's opaque id.", {
1018
+ type: 'string',
1019
+ minLength: 1,
1020
+ }),
1021
+ ];
1022
+
1023
+ const JudgeClassScopeKindQueryParam: ParameterSpec = judgmentQuery(
1024
+ 'scopeKind',
1025
+ 'Only classes of this scope kind. `project` and `agent` need `projectId`; `agent` also needs `agentId`.',
1026
+ { type: 'string', enum: ['tenant', 'project', 'agent'] },
1027
+ );
1028
+
1029
+ const JudgeClassProjectIdQueryParam: ParameterSpec = judgmentQuery(
1030
+ 'projectId',
1031
+ 'Project of the scope, for `scopeKind=project|agent`.',
1032
+ { type: 'string', minLength: 1 },
1033
+ );
1034
+
1035
+ const JudgeClassAgentIdQueryParam: ParameterSpec = judgmentQuery(
1036
+ 'agentId',
1037
+ 'Agent of the scope, for `scopeKind=agent`.',
1038
+ { type: 'string', minLength: 1 },
1039
+ );
1040
+
913
1041
  // ---------------- shared responses ----------------
914
1042
 
915
1043
  const ErrorResponse = (description: string): ResponseSpec => ({
@@ -1008,6 +1136,8 @@ export const OPERATIONS: readonly OperationSpec[] = [
1008
1136
  ParentRunIdQueryParam,
1009
1137
  TopLevelQueryParam,
1010
1138
  RunAgentIdQueryParam,
1139
+ RunReplaysQueryParam,
1140
+ RunEvalRunIdQueryParam,
1011
1141
  RunIncludeQueryParam,
1012
1142
  ],
1013
1143
  responses: {
@@ -1543,6 +1673,35 @@ export const OPERATIONS: readonly OperationSpec[] = [
1543
1673
  '404': ErrorResponse('No agent with that id under this tenant.'),
1544
1674
  },
1545
1675
  },
1676
+ {
1677
+ method: 'post',
1678
+ honoPath: '/v1/agents/:agentId/versions',
1679
+ openapiPath: '/v1/agents/{agentId}/versions',
1680
+ operationId: 'agents.deriveVersion',
1681
+ summary: 'Derive an agent version with data-block pins swapped',
1682
+ description:
1683
+ "An expert's edit, without a code change: a new agent version that is `from`'s bag with some prompt or settings pins swapped (`derivedFrom: { version, reason: 'edited', label, by }`), numbered the next free patch after the agent's highest version. Only blocks `from` already references swap, to a published, active version of the right kind (model settings for the model-settings block); tool pins come from code. Needs `publish` on the agent.",
1684
+ tags: ['agents'],
1685
+ security: 'bearer',
1686
+ parameters: [AgentIdPathParam, IdempotencyKeyParam],
1687
+ requestBody: { required: true, schema: ref('DeriveAgentVersionBody') },
1688
+ responses: {
1689
+ '200': {
1690
+ description:
1691
+ 'An active version already holds this definition and these pins (the same swap derived before, or a deploy that registered it): that version, unchanged.',
1692
+ schema: ref('Agent'),
1693
+ },
1694
+ '201': { description: 'The derived agent version.', schema: ref('Agent') },
1695
+ ...CommonMutationErrors,
1696
+ '409': ErrorResponse(
1697
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1698
+ ),
1699
+ '400': ErrorResponse(
1700
+ "`validation-failed`: `from` has no pins, a swap names a block it doesn't reference, or a version that isn't published, active or the right kind (see `details.issues`).",
1701
+ ),
1702
+ '404': ErrorResponse('`agent-not-found`: no agent at `from`.'),
1703
+ },
1704
+ },
1546
1705
  {
1547
1706
  method: 'get',
1548
1707
  honoPath: '/v1/agents/:agentId/versions/:version',
@@ -1574,7 +1733,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1574
1733
  '201': { description: 'Agent published.', schema: ref('PublishAgentResult') },
1575
1734
  ...CommonMutationErrors,
1576
1735
  '400': ErrorResponse('Validation failed (see `details.issues`).'),
1577
- '409': ErrorResponse('Agent already registered at that (id, version).'),
1736
+ '409': ErrorResponse(
1737
+ "Agent already registered at that (id, version). Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1738
+ ),
1578
1739
  },
1579
1740
  },
1580
1741
  {
@@ -1589,6 +1750,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1589
1750
  responses: {
1590
1751
  '200': { description: 'Unregistered.', schema: ref('UnregisterAgentResult') },
1591
1752
  ...CommonMutationErrors,
1753
+ '409': ErrorResponse(
1754
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1755
+ ),
1592
1756
  '404': ErrorResponse('No agent at that (id, version) under this tenant.'),
1593
1757
  },
1594
1758
  },
@@ -1606,6 +1770,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1606
1770
  responses: {
1607
1771
  '200': { description: 'Reinstated.', schema: ref('ReinstateAgentVersionResult') },
1608
1772
  ...CommonMutationErrors,
1773
+ '409': ErrorResponse(
1774
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1775
+ ),
1609
1776
  '404': ErrorResponse('No agent at that (id, version) under this tenant.'),
1610
1777
  },
1611
1778
  },
@@ -1697,7 +1864,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1697
1864
  '201': { description: 'Flow published.', schema: ref('PublishFlowResult') },
1698
1865
  ...CommonMutationErrors,
1699
1866
  '400': ErrorResponse('Validation failed (see `details.issues`).'),
1700
- '409': ErrorResponse('Flow already registered at that (id, version).'),
1867
+ '409': ErrorResponse(
1868
+ "Flow already registered at that (id, version). Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1869
+ ),
1701
1870
  },
1702
1871
  },
1703
1872
  {
@@ -1712,6 +1881,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1712
1881
  responses: {
1713
1882
  '200': { description: 'Unregistered.', schema: ref('UnregisterFlowResult') },
1714
1883
  ...CommonMutationErrors,
1884
+ '409': ErrorResponse(
1885
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1886
+ ),
1715
1887
  '404': ErrorResponse('No flow at that (id, version) under this tenant.'),
1716
1888
  },
1717
1889
  },
@@ -1729,6 +1901,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1729
1901
  responses: {
1730
1902
  '200': { description: 'Reinstated.', schema: ref('ReinstateFlowVersionResult') },
1731
1903
  ...CommonMutationErrors,
1904
+ '409': ErrorResponse(
1905
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
1906
+ ),
1732
1907
  '404': ErrorResponse('No flow at that (id, version) under this tenant.'),
1733
1908
  },
1734
1909
  },
@@ -1824,7 +1999,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1824
1999
  '201': { description: 'Tool registered.', schema: ref('RegisterToolResult') },
1825
2000
  ...CommonMutationErrors,
1826
2001
  '400': ErrorResponse('Validation failed (see `details.issues`).'),
1827
- '409': ErrorResponse('Tool already registered at that id.'),
2002
+ '409': ErrorResponse(
2003
+ "Tool already registered at that id. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
2004
+ ),
1828
2005
  },
1829
2006
  },
1830
2007
  {
@@ -1839,6 +2016,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1839
2016
  responses: {
1840
2017
  '200': { description: 'Unregistered.', schema: ref('UnregisterToolResult') },
1841
2018
  ...CommonMutationErrors,
2019
+ '409': ErrorResponse(
2020
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
2021
+ ),
1842
2022
  '404': ErrorResponse('No tool at that (id, version) under this tenant.'),
1843
2023
  },
1844
2024
  },
@@ -1856,6 +2036,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1856
2036
  responses: {
1857
2037
  '200': { description: 'Reinstated.', schema: ref('ReinstateToolVersionResult') },
1858
2038
  ...CommonMutationErrors,
2039
+ '409': ErrorResponse(
2040
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
2041
+ ),
1859
2042
  '404': ErrorResponse('No tool at that (id, version) under this tenant.'),
1860
2043
  },
1861
2044
  },
@@ -1916,7 +2099,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1916
2099
  '201': { description: 'Guardrail registered.', schema: ref('RegisterGuardrailResult') },
1917
2100
  ...CommonMutationErrors,
1918
2101
  '400': ErrorResponse('Validation failed (see `details.issues`).'),
1919
- '409': ErrorResponse('Guardrail already registered at that id.'),
2102
+ '409': ErrorResponse(
2103
+ "Guardrail already registered at that id. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
2104
+ ),
1920
2105
  },
1921
2106
  },
1922
2107
  {
@@ -1931,6 +2116,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
1931
2116
  responses: {
1932
2117
  '200': { description: 'Unregistered.', schema: ref('UnregisterGuardrailResult') },
1933
2118
  ...CommonMutationErrors,
2119
+ '409': ErrorResponse(
2120
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
2121
+ ),
1934
2122
  '404': ErrorResponse('No guardrail with that id under this tenant.'),
1935
2123
  },
1936
2124
  },
@@ -2635,7 +2823,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
2635
2823
  operationId: 'providers.register',
2636
2824
  summary: 'Register a model provider',
2637
2825
  description:
2638
- 'Body is a full `ProviderMetadata`. Server validates shape: provider-level `id` + `region` non-empty; `models[]` non-empty with unique `name` per entry; per-model `contextWindow` positive integer; per-model `features` against the closed enum; per-model `cost` non-negative; optional per-model `p95LatencyMs` / `maxOutputTokens` well-shaped — same rules as `@kindgi/capabilities.createProviderRegistry`. Secrets (API keys, endpoints) are NOT part of the wire shape; deployments store them inside the binding.',
2826
+ 'Body is a full `ProviderMetadata`. Server validates shape: provider-level `id` + `region` non-empty; `models[]` non-empty with unique `name` per entry; per-model `contextWindow` positive integer; per-model `features` against the closed enum; per-model `cost` non-negative; optional per-model `p95LatencyMs` / `maxOutputTokens` well-shaped; optional `labels` within their limits — same rules as `@kindgi/capabilities.createProviderRegistry`. Secrets (API keys, endpoints) are NOT part of the wire shape; deployments store them inside the binding.',
2639
2827
  tags: ['providers'],
2640
2828
  security: 'bearer',
2641
2829
  parameters: [IdempotencyKeyParam],
@@ -2653,13 +2841,193 @@ export const OPERATIONS: readonly OperationSpec[] = [
2653
2841
  openapiPath: '/v1/providers/{providerId}/unregister',
2654
2842
  operationId: 'providers.unregister',
2655
2843
  summary: 'Unregister a model provider',
2844
+ description:
2845
+ 'A tombstone, not an erase: from then on the provider is gone from list, get and capabilities, and the router never picks it. Its id is free to register again. A retention policy on the `provider` domain purges the row.',
2656
2846
  tags: ['providers'],
2657
2847
  security: 'bearer',
2658
2848
  parameters: [ProviderIdPathParam, IdempotencyKeyParam],
2659
2849
  responses: {
2660
2850
  '200': { description: 'Unregistered.', schema: ref('UnregisterProviderResult') },
2661
2851
  ...CommonMutationErrors,
2662
- '404': ErrorResponse('No provider with that id under this tenant.'),
2852
+ '404': ErrorResponse('No provider with that id under this tenant, or already unregistered.'),
2853
+ },
2854
+ },
2855
+
2856
+ // ---------- judgments ----------
2857
+ {
2858
+ method: 'post',
2859
+ honoPath: '/v1/judgments',
2860
+ openapiPath: '/v1/judgments',
2861
+ operationId: 'judgments.create',
2862
+ summary: "Judge an item of a run's output",
2863
+ description:
2864
+ "Records yes or no, with an optional reason, about one item of a finished run's output, optionally under a judge class that applies to the run's project or agent (unclassified judgments count with weight 1). `item.pointer` (a JSON Pointer) must resolve in the run's output; its value is kept as `itemValue`. The first judgment of a run also stores a copy of the run's input and output. `assertedBy` is the authenticated caller, never the body. Judging again as the same caller for the same run, item key and `participantId` supersedes the earlier judgment. Needs `judge` on the run.",
2865
+ tags: ['judgments'],
2866
+ security: 'bearer',
2867
+ parameters: [IdempotencyKeyParam],
2868
+ requestBody: { required: true, schema: ref('CreateJudgmentBody') },
2869
+ responses: {
2870
+ '201': { description: 'Judgment recorded.', schema: ref('Judgment') },
2871
+ ...CommonMutationErrors,
2872
+ '400': ErrorResponse(
2873
+ 'Malformed body, or `item-not-found` (the pointer resolves to nothing in the output), or `judge-class-not-applicable`.',
2874
+ ),
2875
+ '403': ErrorResponse('`permission-denied`: not allowed to judge this run.'),
2876
+ '404': ErrorResponse('`run-not-found`.'),
2877
+ '409': ErrorResponse('`run-not-finished`: the run has no output to judge yet.'),
2878
+ },
2879
+ },
2880
+ {
2881
+ method: 'get',
2882
+ honoPath: '/v1/judgments',
2883
+ openapiPath: '/v1/judgments',
2884
+ operationId: 'judgments.list',
2885
+ summary: 'List judgments',
2886
+ description:
2887
+ 'Live judgments (not removed or superseded), newest first, cursor-paginated. Filter by run, agent (and version), flow, verdict, judge class or participant; `?scopeKind + ?scopeId` narrow to a project.',
2888
+ tags: ['judgments'],
2889
+ security: 'bearer',
2890
+ parameters: [
2891
+ LimitQueryParam,
2892
+ CursorQueryParam,
2893
+ ...JudgmentListQueryParams,
2894
+ ScopeKindQueryParam,
2895
+ ScopeIdQueryParam,
2896
+ ],
2897
+ responses: {
2898
+ '200': { description: 'Page of judgments.', schema: ref('JudgmentCollectionPage') },
2899
+ ...CommonAuthErrors,
2900
+ '400': ErrorResponse('Malformed query parameter.'),
2901
+ },
2902
+ },
2903
+ {
2904
+ method: 'get',
2905
+ honoPath: '/v1/judgments/:judgmentId',
2906
+ openapiPath: '/v1/judgments/{judgmentId}',
2907
+ operationId: 'judgments.get',
2908
+ summary: 'Fetch a judgment with its copies',
2909
+ description:
2910
+ "Returns the judgment (live or not) with the stored copy of the run's input and output and, when the judgment pointed at an item, its value.",
2911
+ tags: ['judgments'],
2912
+ security: 'bearer',
2913
+ parameters: [JudgmentIdPathParam],
2914
+ responses: {
2915
+ '200': { description: 'Judgment with copies.', schema: ref('JudgmentWithCopies') },
2916
+ ...CommonAuthErrors,
2917
+ '404': ErrorResponse('No judgment with that id under this tenant.'),
2918
+ },
2919
+ },
2920
+ {
2921
+ method: 'post',
2922
+ honoPath: '/v1/judgments/:judgmentId/unregister',
2923
+ openapiPath: '/v1/judgments/{judgmentId}/unregister',
2924
+ operationId: 'judgments.unregister',
2925
+ summary: 'Remove a judgment',
2926
+ description:
2927
+ 'Soft delete: the judgment stops listing; retention policy decides when it is purged.',
2928
+ tags: ['judgments'],
2929
+ security: 'bearer',
2930
+ parameters: [JudgmentIdPathParam, IdempotencyKeyParam],
2931
+ responses: {
2932
+ '200': { description: 'Removed.', schema: ref('UnregisterJudgmentResult') },
2933
+ ...CommonMutationErrors,
2934
+ '403': ErrorResponse('`permission-denied`.'),
2935
+ '404': ErrorResponse('No live judgment with that id under this tenant.'),
2936
+ },
2937
+ },
2938
+
2939
+ // ---------- judge classes ----------
2940
+ {
2941
+ method: 'post',
2942
+ honoPath: '/v1/judge-classes',
2943
+ openapiPath: '/v1/judge-classes',
2944
+ operationId: 'judgeClasses.create',
2945
+ summary: 'Create a judge class',
2946
+ description:
2947
+ 'A named kind of judge with a weight, scoped to the tenant, a project, or an agent in a project. Names are unique among the live classes of a scope. Needs `admin` on the tenant (tenant scope) or the project.',
2948
+ tags: ['judge-classes'],
2949
+ security: 'bearer',
2950
+ parameters: [IdempotencyKeyParam],
2951
+ requestBody: { required: true, schema: ref('CreateJudgeClassBody') },
2952
+ responses: {
2953
+ '201': { description: 'Judge class created.', schema: ref('JudgeClass') },
2954
+ ...CommonMutationErrors,
2955
+ '403': ErrorResponse('`permission-denied`.'),
2956
+ '409': ErrorResponse('`judge-class-name-taken`, or an idempotency conflict.'),
2957
+ },
2958
+ },
2959
+ {
2960
+ method: 'get',
2961
+ honoPath: '/v1/judge-classes',
2962
+ openapiPath: '/v1/judge-classes',
2963
+ operationId: 'judgeClasses.list',
2964
+ summary: 'List judge classes',
2965
+ description:
2966
+ 'Live classes, newest first, cursor-paginated. `?scopeKind=tenant|project|agent` (with `projectId` / `agentId`) narrows to one scope.',
2967
+ tags: ['judge-classes'],
2968
+ security: 'bearer',
2969
+ parameters: [
2970
+ LimitQueryParam,
2971
+ CursorQueryParam,
2972
+ JudgeClassScopeKindQueryParam,
2973
+ JudgeClassProjectIdQueryParam,
2974
+ JudgeClassAgentIdQueryParam,
2975
+ ],
2976
+ responses: {
2977
+ '200': { description: 'Page of judge classes.', schema: ref('JudgeClassCollectionPage') },
2978
+ ...CommonAuthErrors,
2979
+ '400': ErrorResponse('Malformed scope parameters.'),
2980
+ },
2981
+ },
2982
+ {
2983
+ method: 'get',
2984
+ honoPath: '/v1/judge-classes/:judgeClassId',
2985
+ openapiPath: '/v1/judge-classes/{judgeClassId}',
2986
+ operationId: 'judgeClasses.get',
2987
+ summary: 'Fetch a judge class',
2988
+ description:
2989
+ 'Also returns a retired class (`unregisteredAt` set): judgments keep naming theirs.',
2990
+ tags: ['judge-classes'],
2991
+ security: 'bearer',
2992
+ parameters: [JudgeClassIdPathParam],
2993
+ responses: {
2994
+ '200': { description: 'Judge class.', schema: ref('JudgeClass') },
2995
+ ...CommonAuthErrors,
2996
+ '404': ErrorResponse('No judge class with that id under this tenant.'),
2997
+ },
2998
+ },
2999
+ {
3000
+ method: 'patch',
3001
+ honoPath: '/v1/judge-classes/:judgeClassId',
3002
+ openapiPath: '/v1/judge-classes/{judgeClassId}',
3003
+ operationId: 'judgeClasses.update',
3004
+ summary: "Change a judge class's weight or description",
3005
+ tags: ['judge-classes'],
3006
+ security: 'bearer',
3007
+ parameters: [JudgeClassIdPathParam, IdempotencyKeyParam],
3008
+ requestBody: { required: true, schema: ref('UpdateJudgeClassBody') },
3009
+ responses: {
3010
+ '200': { description: 'Updated judge class.', schema: ref('JudgeClass') },
3011
+ ...CommonMutationErrors,
3012
+ '403': ErrorResponse('`permission-denied`.'),
3013
+ '404': ErrorResponse('No live judge class with that id under this tenant.'),
3014
+ },
3015
+ },
3016
+ {
3017
+ method: 'post',
3018
+ honoPath: '/v1/judge-classes/:judgeClassId/unregister',
3019
+ openapiPath: '/v1/judge-classes/{judgeClassId}/unregister',
3020
+ operationId: 'judgeClasses.unregister',
3021
+ summary: 'Retire a judge class',
3022
+ description: 'No new judgments may name it; existing judgments keep it.',
3023
+ tags: ['judge-classes'],
3024
+ security: 'bearer',
3025
+ parameters: [JudgeClassIdPathParam, IdempotencyKeyParam],
3026
+ responses: {
3027
+ '200': { description: 'Retired.', schema: ref('UnregisterJudgeClassResult') },
3028
+ ...CommonMutationErrors,
3029
+ '403': ErrorResponse('`permission-denied`.'),
3030
+ '404': ErrorResponse('No live judge class with that id under this tenant.'),
2663
3031
  },
2664
3032
  },
2665
3033
 
@@ -2880,11 +3248,12 @@ export const OPERATIONS: readonly OperationSpec[] = [
2880
3248
  operationId: 'cost.aggregate',
2881
3249
  summary: 'Aggregate cost across a time window',
2882
3250
  description:
2883
- "Primary consumer path for dashboards. `groupBy` is required (comma-separated dimensions from the closed set); time range is required (both `from` and `to`, or both omitted for the default last-30-days window echoed back in `timeRange`). Filters compose on top of the time window. `?scopeKind + ?scopeId` narrow the aggregate to a scope: `org` covers every project in the org, so one call sums an org's spend. Each group, and the total, carries its cost and its token sums (`tokens`). `inherit` has no effect on cost records, which always belong to a project.",
3251
+ "Primary consumer path for dashboards. `groupBy` is required (comma-separated dimensions from the closed set); time range is required (both `from` and `to`, or both omitted for the default last-30-days window echoed back in `timeRange`). Filters compose on top of the time window. `?scopeKind + ?scopeId` narrow the aggregate to a scope: `org` covers every project in the org, so one call sums an org's spend. Each group, and the total, carries its cost and its token sums (`tokens`). `groups` is ordered by `totalUsd`, highest first (ties by key), and capped at `limit` (default 1000): `truncated` and `totalGroups` say when there were more, and the totals still cover every record. For every record, page through `/v1/cost/records`. `inherit` has no effect on cost records, which always belong to a project.",
2884
3252
  tags: ['cost'],
2885
3253
  security: 'bearer',
2886
3254
  parameters: [
2887
3255
  CostGroupByQueryParam,
3256
+ CostAggregateLimitQueryParam,
2888
3257
  CostFromQueryParam,
2889
3258
  CostToQueryParam,
2890
3259
  CostCategoryQueryParam,
@@ -3072,7 +3441,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
3072
3441
  operationId: 'policies.publish',
3073
3442
  summary: 'Publish a policy',
3074
3443
  description:
3075
- "Body is a full `Policy` — the server validates top-level shape (id, tenantId, semver version, kind ∈ closed enum, spec is an object). Deeper `spec` validation is the runtime consumer's responsibility per kind. Re-publishing an existing `(policyId, version)` returns `409 policy-already-registered`. Idempotency-Key applies (retries with the same key replay the original 201).",
3444
+ "Body is a full `Policy` — the server validates top-level shape (id, tenantId, semver version, kind ∈ closed enum, spec is an object). Deeper `spec` validation is the runtime consumer's responsibility per kind. Re-publishing an existing `(policyId, version)` returns `409 policy-already-registered`. A known kind that no runtime consumer applies yet (`access-control`, `adapter-allowlist`, `rate-limit`, `compliance`) is refused with `400 kind-not-applied` (`details.appliedKinds` lists the ones that are): publishing it would change nothing. Idempotency-Key applies (retries with the same key replay the original 201).",
3076
3445
  tags: ['policies'],
3077
3446
  security: 'bearer',
3078
3447
  parameters: [IdempotencyKeyParam],
@@ -3080,7 +3449,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
3080
3449
  responses: {
3081
3450
  '201': { description: 'Policy published.', schema: ref('PublishPolicyResult') },
3082
3451
  ...CommonMutationErrors,
3083
- '400': ErrorResponse('Validation failed (see `details.issues`).'),
3452
+ '400': ErrorResponse(
3453
+ 'Validation failed (see `details.issues`), or `kind-not-applied`: no runtime consumer applies that kind yet.',
3454
+ ),
3084
3455
  '409': ErrorResponse('Policy already registered at that (id, version).'),
3085
3456
  },
3086
3457
  },
@@ -3211,6 +3582,48 @@ export const OPERATIONS: readonly OperationSpec[] = [
3211
3582
  '409': ErrorResponse('Eval suite already registered at that (id, version).'),
3212
3583
  },
3213
3584
  },
3585
+ {
3586
+ method: 'post',
3587
+ honoPath: '/v1/eval-suites/:suiteId/versions/from-judgments',
3588
+ openapiPath: '/v1/eval-suites/{suiteId}/versions/from-judgments',
3589
+ operationId: 'evalSuites.buildFromJudgments',
3590
+ summary: 'Build a test set from judgments',
3591
+ description:
3592
+ "Publishes a `judged` eval suite version whose cases are copies of judged runs of one agent (optionally one version) or flow, newest first, at most 1000. Each case holds the run's input, what the turn read (`context`), the judged output, and each item's judgments summed up: yes and no counts, the weight behind yes and behind all judgments (an unclassified judgment counts 1), and the reasons. `judgeClassIds` counts only judgments of those classes; `minJudgments` leaves out runs with fewer. Needs `admin` on the project.",
3593
+ tags: ['eval-suites'],
3594
+ security: 'bearer',
3595
+ parameters: [EvalSuiteIdPathParam, IdempotencyKeyParam],
3596
+ requestBody: { required: true, schema: ref('BuildJudgedSuiteBody') },
3597
+ responses: {
3598
+ '201': { description: 'Version published.', schema: ref('BuildJudgedSuiteResult') },
3599
+ ...CommonMutationErrors,
3600
+ '400': ErrorResponse('Malformed body.'),
3601
+ '403': ErrorResponse('`permission-denied`.'),
3602
+ '409': ErrorResponse('Eval suite already registered at that (id, version).'),
3603
+ '501': ErrorResponse('`test-sets-not-supported`: this deployment cannot build test sets.'),
3604
+ },
3605
+ },
3606
+ {
3607
+ method: 'get',
3608
+ honoPath: '/v1/eval-suites/:suiteId/versions/:version/cases',
3609
+ openapiPath: '/v1/eval-suites/{suiteId}/versions/{version}/cases',
3610
+ operationId: 'evalSuites.listCases',
3611
+ summary: 'List the cases of a judged eval suite version',
3612
+ description: 'Cursor-paginated, in the order the cases were stored (newest judged run first).',
3613
+ tags: ['eval-suites'],
3614
+ security: 'bearer',
3615
+ parameters: [
3616
+ EvalSuiteIdPathParam,
3617
+ EvalSuiteVersionPathParam,
3618
+ LimitQueryParam,
3619
+ CursorQueryParam,
3620
+ ],
3621
+ responses: {
3622
+ '200': { description: 'Page of cases.', schema: ref('JudgedEvalCaseCollectionPage') },
3623
+ ...CommonAuthErrors,
3624
+ '404': ErrorResponse('No eval suite with that id.'),
3625
+ },
3626
+ },
3214
3627
  {
3215
3628
  method: 'post',
3216
3629
  honoPath: '/v1/eval-suites/:suiteId/versions/:version/unregister',
@@ -3245,6 +3658,139 @@ export const OPERATIONS: readonly OperationSpec[] = [
3245
3658
  },
3246
3659
 
3247
3660
  // ---------- eval runs (data plane) ----------
3661
+ {
3662
+ method: 'get',
3663
+ honoPath: '/v1/blocks',
3664
+ openapiPath: '/v1/blocks',
3665
+ operationId: 'blocks.list',
3666
+ summary: 'List data blocks (latest version of each)',
3667
+ description:
3668
+ 'Cursor-paginated. Only the blocks of projects the caller can read. `?kind=` narrows to prompts or settings, `?name=` is a prefix match on the id, and `?scopeKind=` + `?scopeId=` narrow to a project or an org, as the other lists do.',
3669
+ tags: ['blocks'],
3670
+ security: 'bearer',
3671
+ parameters: [
3672
+ LimitQueryParam,
3673
+ CursorQueryParam,
3674
+ BlockKindFilterQueryParam,
3675
+ BlockNameFilterQueryParam,
3676
+ ScopeKindQueryParam,
3677
+ ScopeIdQueryParam,
3678
+ ],
3679
+ responses: {
3680
+ '200': { description: 'Page of blocks.', schema: ref('BlockCollectionPage') },
3681
+ ...CommonAuthErrors,
3682
+ '400': ErrorResponse(
3683
+ 'Malformed query parameter: an unknown `kind`, or `scope-invalid` for a malformed scope.',
3684
+ ),
3685
+ },
3686
+ },
3687
+ {
3688
+ method: 'get',
3689
+ honoPath: '/v1/blocks/:blockId',
3690
+ openapiPath: '/v1/blocks/{blockId}',
3691
+ operationId: 'blocks.get',
3692
+ summary: 'Fetch a data block (latest version)',
3693
+ tags: ['blocks'],
3694
+ security: 'bearer',
3695
+ parameters: [BlockIdPathParam],
3696
+ responses: {
3697
+ '200': { description: 'Latest active version.', schema: ref('Block') },
3698
+ ...CommonAuthErrors,
3699
+ '404': ErrorResponse(
3700
+ "`block-not-found`: no such block, or one in a project the caller can't read.",
3701
+ ),
3702
+ },
3703
+ },
3704
+ {
3705
+ method: 'get',
3706
+ honoPath: '/v1/blocks/:blockId/versions',
3707
+ openapiPath: '/v1/blocks/{blockId}/versions',
3708
+ operationId: 'blocks.versions.list',
3709
+ summary: 'List versions of a data block',
3710
+ description:
3711
+ 'Newest published first. `?includeTombstoned=true` includes unregistered versions, each with `unregisteredAt`.',
3712
+ tags: ['blocks'],
3713
+ security: 'bearer',
3714
+ parameters: [BlockIdPathParam, LimitQueryParam, CursorQueryParam, IncludeTombstonedQueryParam],
3715
+ responses: {
3716
+ '200': { description: 'Page of versions.', schema: ref('BlockCollectionPage') },
3717
+ ...CommonAuthErrors,
3718
+ '404': ErrorResponse('`block-not-found`.'),
3719
+ },
3720
+ },
3721
+ {
3722
+ method: 'get',
3723
+ honoPath: '/v1/blocks/:blockId/versions/:version',
3724
+ openapiPath: '/v1/blocks/{blockId}/versions/{version}',
3725
+ operationId: 'blocks.versions.get',
3726
+ summary: 'Fetch a specific data block version',
3727
+ description: 'An unregistered version is returned too, with `unregisteredAt`.',
3728
+ tags: ['blocks'],
3729
+ security: 'bearer',
3730
+ parameters: [BlockIdPathParam, BlockVersionPathParam],
3731
+ responses: {
3732
+ '200': { description: 'The block at that version.', schema: ref('Block') },
3733
+ ...CommonAuthErrors,
3734
+ '404': ErrorResponse('`block-not-found`.'),
3735
+ },
3736
+ },
3737
+ {
3738
+ method: 'post',
3739
+ honoPath: '/v1/blocks',
3740
+ openapiPath: '/v1/blocks',
3741
+ operationId: 'blocks.publish',
3742
+ summary: 'Publish a data block version',
3743
+ description:
3744
+ "Needs `write` on the project. A prompt's template must parse as Liquid; a settings block's `values` must satisfy its `schema` and the latest version's. A taken version is `409 block-already-registered` (versions never change); a block keeps its kind, and its versions stay in its first version's project (`409 block-project-mismatch`). Idempotency-Key applies.",
3745
+ tags: ['blocks'],
3746
+ security: 'bearer',
3747
+ parameters: [IdempotencyKeyParam],
3748
+ requestBody: { required: true, schema: ref('PublishBlockBody') },
3749
+ responses: {
3750
+ '201': { description: 'Published.', schema: ref('PublishBlockResult') },
3751
+ ...CommonMutationErrors,
3752
+ '400': ErrorResponse(
3753
+ '`validation-failed` (see `details.issues`), or an unknown `projectId`.',
3754
+ ),
3755
+ '403': ErrorResponse('`permission-denied`: no `write` on the project.'),
3756
+ '409': ErrorResponse('`block-already-registered` or `block-project-mismatch`.'),
3757
+ },
3758
+ },
3759
+ {
3760
+ method: 'post',
3761
+ honoPath: '/v1/blocks/:blockId/versions/:version/unregister',
3762
+ openapiPath: '/v1/blocks/{blockId}/versions/{version}/unregister',
3763
+ operationId: 'blocks.versions.unregister',
3764
+ summary: 'Unregister a data block version',
3765
+ description:
3766
+ 'Soft: no range picks it any more, but the agent versions that pin it keep running it, and GET still reads it. Needs `write` on the project.',
3767
+ tags: ['blocks'],
3768
+ security: 'bearer',
3769
+ parameters: [BlockIdPathParam, BlockVersionPathParam, IdempotencyKeyParam],
3770
+ responses: {
3771
+ '200': { description: 'Unregistered.', schema: ref('UnregisterBlockResult') },
3772
+ ...CommonMutationErrors,
3773
+ '403': ErrorResponse('`permission-denied`: no `write` on the project.'),
3774
+ '404': ErrorResponse('`block-not-found`, or already unregistered.'),
3775
+ },
3776
+ },
3777
+ {
3778
+ method: 'post',
3779
+ honoPath: '/v1/blocks/:blockId/versions/:version/reinstate',
3780
+ openapiPath: '/v1/blocks/{blockId}/versions/{version}/reinstate',
3781
+ operationId: 'blocks.versions.reinstate',
3782
+ summary: 'Reinstate an unregistered data block version',
3783
+ description: 'Unchanged, as published. Idempotent. Needs `write` on the project.',
3784
+ tags: ['blocks'],
3785
+ security: 'bearer',
3786
+ parameters: [BlockIdPathParam, BlockVersionPathParam, IdempotencyKeyParam],
3787
+ responses: {
3788
+ '200': { description: 'Reinstated.', schema: ref('ReinstateBlockResult') },
3789
+ ...CommonMutationErrors,
3790
+ '403': ErrorResponse('`permission-denied`: no `write` on the project.'),
3791
+ '404': ErrorResponse('`block-not-found`.'),
3792
+ },
3793
+ },
3248
3794
  {
3249
3795
  method: 'post',
3250
3796
  honoPath: '/v1/eval-suites/:suiteId/runs',
@@ -3622,6 +4168,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
3622
4168
  schema: ref('DeploymentRecord'),
3623
4169
  },
3624
4170
  ...CommonMutationErrors,
4171
+ '409': ErrorResponse(
4172
+ "Idempotency-Key was reused with a different body, or resource-state conflict. Or `registry-read-only`: this registry takes no writes (under `kindgi dev`, the pack's files are the source); the message says what to do instead.",
4173
+ ),
3625
4174
  '400': ErrorResponse(
3626
4175
  'Signature invalid, image unverifiable, or deployment-validation-failed with per-primitive `details[]`.',
3627
4176
  ),
@@ -4053,7 +4602,7 @@ export const OPERATIONS: readonly OperationSpec[] = [
4053
4602
  operationId: 'orgs.delete',
4054
4603
  summary: 'Delete an org (idempotent)',
4055
4604
  description:
4056
- 'Idempotent — deleting an unknown or already-deleted org returns 204 per the binding contract.',
4605
+ "A tombstone, not an erase: from then on the org is gone from get and list, and its slug is free for a new org. Its projects and teams stay, without an org; when one of those projects has the slug of a project that has none, nothing is deleted: `409 slug-conflict` names the slugs (rename or move those projects first). In the Kindgi runtime, the org's own secrets and secret mappings are deleted with it, for good, and its own environments and MCP endpoints are unregistered. A retention policy on the `org` domain purges the org's row. Idempotent: deleting an unknown or already-deleted org returns 204.",
4057
4606
  tags: ['orgs'],
4058
4607
  security: 'bearer',
4059
4608
  parameters: [
@@ -4069,6 +4618,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
4069
4618
  responses: {
4070
4619
  '204': { description: 'Deleted (or already absent). No body.' },
4071
4620
  ...CommonAuthErrors,
4621
+ '409': ErrorResponse(
4622
+ "slug-conflict: the org's projects would leave it with slugs that projects without an org already have.",
4623
+ ),
4072
4624
  },
4073
4625
  },
4074
4626
 
@@ -4120,6 +4672,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
4120
4672
  responses: {
4121
4673
  '201': { description: 'Team created.', schema: ref('CreateResourceResult') },
4122
4674
  ...CommonMutationErrors,
4675
+ '404': ErrorResponse(
4676
+ 'org-not-found: `orgId` names no org of the tenant (it never existed, or it was deleted).',
4677
+ ),
4123
4678
  },
4124
4679
  },
4125
4680
  {
@@ -4167,7 +4722,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
4167
4722
  responses: {
4168
4723
  '204': { description: 'Updated. No body.' },
4169
4724
  ...CommonMutationErrors,
4170
- '404': ErrorResponse('No team with that id under this tenant.'),
4725
+ '404': ErrorResponse(
4726
+ 'team-not-found: no team with that id under this tenant; or org-not-found: `orgId` names no org of the tenant (it never existed, or it was deleted).',
4727
+ ),
4171
4728
  },
4172
4729
  },
4173
4730
  {
@@ -4372,6 +4929,8 @@ export const OPERATIONS: readonly OperationSpec[] = [
4372
4929
  openapiPath: '/v1/projects',
4373
4930
  operationId: 'projects.create',
4374
4931
  summary: 'Create a project',
4932
+ description:
4933
+ "A project's slug is unique within its org, and a project without an org's among the tenant's projects without one: two orgs may each have a project with the same slug. A taken slug answers `409 slug-conflict`; a second Default, `409 project-default-already-exists`.",
4375
4934
  tags: ['projects'],
4376
4935
  security: 'bearer',
4377
4936
  parameters: [IdempotencyKeyParam],
@@ -4379,6 +4938,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
4379
4938
  responses: {
4380
4939
  '201': { description: 'Project created.', schema: ref('CreateResourceResult') },
4381
4940
  ...CommonMutationErrors,
4941
+ '404': ErrorResponse(
4942
+ 'org-not-found: `orgId` names no org of the tenant (it never existed, or it was deleted).',
4943
+ ),
4382
4944
  },
4383
4945
  },
4384
4946
  {
@@ -4410,6 +4972,8 @@ export const OPERATIONS: readonly OperationSpec[] = [
4410
4972
  openapiPath: '/v1/projects/{projectId}',
4411
4973
  operationId: 'projects.update',
4412
4974
  summary: 'Partially update a project',
4975
+ description:
4976
+ 'A new `slug`, or a move to another org (`orgId`, or `null` for none), answers `409 slug-conflict` when the slug is taken where the project ends up.',
4413
4977
  tags: ['projects'],
4414
4978
  security: 'bearer',
4415
4979
  parameters: [
@@ -4426,7 +4990,9 @@ export const OPERATIONS: readonly OperationSpec[] = [
4426
4990
  responses: {
4427
4991
  '204': { description: 'Updated. No body.' },
4428
4992
  ...CommonMutationErrors,
4429
- '404': ErrorResponse('No project with that id under this tenant.'),
4993
+ '404': ErrorResponse(
4994
+ 'project-not-found: no project with that id under this tenant; or org-not-found: `orgId` names no org of the tenant (it never existed, or it was deleted).',
4995
+ ),
4430
4996
  },
4431
4997
  },
4432
4998
  {