@kindgi/api 0.1.2 → 0.1.4-rc.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (250) hide show
  1. package/dist/agent-binding.d.ts +18 -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 +22 -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 +100 -5
  20. package/dist/cost-binding.d.ts.map +1 -1
  21. package/dist/cost-binding.js +10 -0
  22. package/dist/cost-binding.js.map +1 -1
  23. package/dist/deploy-versions.d.ts +58 -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 +69 -0
  30. package/dist/derive-agent-version.d.ts.map +1 -0
  31. package/dist/derive-agent-version.js +139 -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 +17 -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 +30 -0
  41. package/dist/eval-run-binding.d.ts.map +1 -1
  42. package/dist/eval-run-dispatcher.d.ts +38 -3
  43. package/dist/eval-run-dispatcher.d.ts.map +1 -1
  44. package/dist/eval-run-dispatcher.js +21 -15
  45. package/dist/eval-run-dispatcher.js.map +1 -1
  46. package/dist/eval-suite-binding.d.ts +1 -1
  47. package/dist/eval-suite-binding.d.ts.map +1 -1
  48. package/dist/eval-suite-binding.js +2 -0
  49. package/dist/eval-suite-binding.js.map +1 -1
  50. package/dist/flow-binding.d.ts +10 -4
  51. package/dist/flow-binding.d.ts.map +1 -1
  52. package/dist/flow-pins.d.ts +36 -0
  53. package/dist/flow-pins.d.ts.map +1 -0
  54. package/dist/flow-pins.js +81 -0
  55. package/dist/flow-pins.js.map +1 -0
  56. package/dist/hitl-binding.d.ts +20 -5
  57. package/dist/hitl-binding.d.ts.map +1 -1
  58. package/dist/index.d.ts +19 -8
  59. package/dist/index.d.ts.map +1 -1
  60. package/dist/index.js +8 -2
  61. package/dist/index.js.map +1 -1
  62. package/dist/judged-dispatcher.d.ts +134 -0
  63. package/dist/judged-dispatcher.d.ts.map +1 -0
  64. package/dist/judged-dispatcher.js +297 -0
  65. package/dist/judged-dispatcher.js.map +1 -0
  66. package/dist/judged-items.d.ts +86 -0
  67. package/dist/judged-items.d.ts.map +1 -0
  68. package/dist/judged-items.js +184 -0
  69. package/dist/judged-items.js.map +1 -0
  70. package/dist/judgment-binding.d.ts +316 -0
  71. package/dist/judgment-binding.d.ts.map +1 -0
  72. package/dist/judgment-binding.js +19 -0
  73. package/dist/judgment-binding.js.map +1 -0
  74. package/dist/middleware/auth.d.ts +3 -2
  75. package/dist/middleware/auth.d.ts.map +1 -1
  76. package/dist/middleware/auth.js.map +1 -1
  77. package/dist/middleware/idempotency.d.ts +5 -1
  78. package/dist/middleware/idempotency.d.ts.map +1 -1
  79. package/dist/middleware/idempotency.js +8 -1
  80. package/dist/middleware/idempotency.js.map +1 -1
  81. package/dist/openapi/generate.d.ts.map +1 -1
  82. package/dist/openapi/generate.js +4 -1
  83. package/dist/openapi/generate.js.map +1 -1
  84. package/dist/openapi/operations.d.ts.map +1 -1
  85. package/dist/openapi/operations.js +543 -24
  86. package/dist/openapi/operations.js.map +1 -1
  87. package/dist/openapi/schemas.d.ts +58 -0
  88. package/dist/openapi/schemas.d.ts.map +1 -1
  89. package/dist/openapi/schemas.js +1058 -27
  90. package/dist/openapi/schemas.js.map +1 -1
  91. package/dist/provenance-binding.d.ts +27 -1
  92. package/dist/provenance-binding.d.ts.map +1 -1
  93. package/dist/provenance-binding.js.map +1 -1
  94. package/dist/provider-binding.d.ts +12 -7
  95. package/dist/provider-binding.d.ts.map +1 -1
  96. package/dist/reviewer-binding.d.ts +10 -2
  97. package/dist/reviewer-binding.d.ts.map +1 -1
  98. package/dist/reviewer-role.d.ts +13 -0
  99. package/dist/reviewer-role.d.ts.map +1 -0
  100. package/dist/reviewer-role.js +27 -0
  101. package/dist/reviewer-role.js.map +1 -0
  102. package/dist/routes/agents.d.ts +9 -1
  103. package/dist/routes/agents.d.ts.map +1 -1
  104. package/dist/routes/agents.js +175 -11
  105. package/dist/routes/agents.js.map +1 -1
  106. package/dist/routes/approvals.d.ts +5 -4
  107. package/dist/routes/approvals.d.ts.map +1 -1
  108. package/dist/routes/approvals.js +52 -16
  109. package/dist/routes/approvals.js.map +1 -1
  110. package/dist/routes/blocks.d.ts +19 -0
  111. package/dist/routes/blocks.d.ts.map +1 -0
  112. package/dist/routes/blocks.js +281 -0
  113. package/dist/routes/blocks.js.map +1 -0
  114. package/dist/routes/conversations.d.ts +7 -1
  115. package/dist/routes/conversations.d.ts.map +1 -1
  116. package/dist/routes/conversations.js +41 -1
  117. package/dist/routes/conversations.js.map +1 -1
  118. package/dist/routes/cost.d.ts.map +1 -1
  119. package/dist/routes/cost.js +142 -11
  120. package/dist/routes/cost.js.map +1 -1
  121. package/dist/routes/deployments.d.ts +3 -0
  122. package/dist/routes/deployments.d.ts.map +1 -1
  123. package/dist/routes/deployments.js +208 -55
  124. package/dist/routes/deployments.js.map +1 -1
  125. package/dist/routes/eval-comparison.d.ts +14 -0
  126. package/dist/routes/eval-comparison.d.ts.map +1 -0
  127. package/dist/routes/eval-comparison.js +87 -0
  128. package/dist/routes/eval-comparison.js.map +1 -0
  129. package/dist/routes/eval-runs.d.ts.map +1 -1
  130. package/dist/routes/eval-runs.js +8 -0
  131. package/dist/routes/eval-runs.js.map +1 -1
  132. package/dist/routes/flows.d.ts +13 -1
  133. package/dist/routes/flows.d.ts.map +1 -1
  134. package/dist/routes/flows.js +44 -3
  135. package/dist/routes/flows.js.map +1 -1
  136. package/dist/routes/hierarchy-errors.d.ts +35 -0
  137. package/dist/routes/hierarchy-errors.d.ts.map +1 -0
  138. package/dist/routes/hierarchy-errors.js +39 -0
  139. package/dist/routes/hierarchy-errors.js.map +1 -0
  140. package/dist/routes/identity.d.ts +7 -0
  141. package/dist/routes/identity.d.ts.map +1 -1
  142. package/dist/routes/identity.js +3 -2
  143. package/dist/routes/identity.js.map +1 -1
  144. package/dist/routes/judged-suites.d.ts +20 -0
  145. package/dist/routes/judged-suites.d.ts.map +1 -0
  146. package/dist/routes/judged-suites.js +272 -0
  147. package/dist/routes/judged-suites.js.map +1 -0
  148. package/dist/routes/judgment-context.d.ts +22 -0
  149. package/dist/routes/judgment-context.d.ts.map +1 -0
  150. package/dist/routes/judgment-context.js +88 -0
  151. package/dist/routes/judgment-context.js.map +1 -0
  152. package/dist/routes/judgment-flow-context.d.ts +32 -0
  153. package/dist/routes/judgment-flow-context.d.ts.map +1 -0
  154. package/dist/routes/judgment-flow-context.js +195 -0
  155. package/dist/routes/judgment-flow-context.js.map +1 -0
  156. package/dist/routes/judgments.d.ts +41 -0
  157. package/dist/routes/judgments.d.ts.map +1 -0
  158. package/dist/routes/judgments.js +566 -0
  159. package/dist/routes/judgments.js.map +1 -0
  160. package/dist/routes/orgs.d.ts +5 -2
  161. package/dist/routes/orgs.d.ts.map +1 -1
  162. package/dist/routes/orgs.js +38 -22
  163. package/dist/routes/orgs.js.map +1 -1
  164. package/dist/routes/policies.d.ts.map +1 -1
  165. package/dist/routes/policies.js +12 -1
  166. package/dist/routes/policies.js.map +1 -1
  167. package/dist/routes/projects.d.ts +10 -2
  168. package/dist/routes/projects.d.ts.map +1 -1
  169. package/dist/routes/projects.js +87 -79
  170. package/dist/routes/projects.js.map +1 -1
  171. package/dist/routes/provenance.d.ts.map +1 -1
  172. package/dist/routes/provenance.js +32 -1
  173. package/dist/routes/provenance.js.map +1 -1
  174. package/dist/routes/providers.d.ts.map +1 -1
  175. package/dist/routes/providers.js +6 -1
  176. package/dist/routes/providers.js.map +1 -1
  177. package/dist/routes/runs.d.ts +0 -7
  178. package/dist/routes/runs.d.ts.map +1 -1
  179. package/dist/routes/runs.js +65 -20
  180. package/dist/routes/runs.js.map +1 -1
  181. package/dist/routes/scope-params.d.ts +16 -1
  182. package/dist/routes/scope-params.d.ts.map +1 -1
  183. package/dist/routes/scope-params.js +28 -0
  184. package/dist/routes/scope-params.js.map +1 -1
  185. package/dist/routes/teams.d.ts +6 -2
  186. package/dist/routes/teams.d.ts.map +1 -1
  187. package/dist/routes/teams.js +77 -73
  188. package/dist/routes/teams.js.map +1 -1
  189. package/dist/types.d.ts +4 -3
  190. package/dist/types.d.ts.map +1 -1
  191. package/dist/webhook-endpoint-binding.d.ts +11 -0
  192. package/dist/webhook-endpoint-binding.d.ts.map +1 -1
  193. package/dist/webhook-endpoint-binding.js.map +1 -1
  194. package/openapi.json +13316 -9299
  195. package/package.json +21 -21
  196. package/src/agent-binding.ts +19 -4
  197. package/src/agent-pins.ts +147 -0
  198. package/src/app.ts +76 -3
  199. package/src/block-binding.ts +137 -0
  200. package/src/block-pins.ts +148 -0
  201. package/src/cost-binding.ts +116 -5
  202. package/src/deploy-versions.ts +157 -0
  203. package/src/deployment-binding.ts +27 -3
  204. package/src/derive-agent-version.ts +206 -0
  205. package/src/errors.ts +17 -0
  206. package/src/eval-case-binding.ts +71 -0
  207. package/src/eval-run-binding.ts +33 -0
  208. package/src/eval-run-dispatcher.ts +57 -16
  209. package/src/eval-suite-binding.ts +2 -0
  210. package/src/flow-binding.ts +11 -4
  211. package/src/flow-pins.ts +113 -0
  212. package/src/hitl-binding.ts +20 -4
  213. package/src/index.ts +88 -2
  214. package/src/judged-dispatcher.ts +507 -0
  215. package/src/judged-items.ts +263 -0
  216. package/src/judgment-binding.ts +349 -0
  217. package/src/middleware/auth.ts +3 -2
  218. package/src/middleware/idempotency.ts +7 -1
  219. package/src/openapi/generate.ts +7 -1
  220. package/src/openapi/operations.ts +615 -24
  221. package/src/openapi/schemas.ts +1157 -22
  222. package/src/provenance-binding.ts +42 -1
  223. package/src/provider-binding.ts +12 -7
  224. package/src/reviewer-binding.ts +10 -2
  225. package/src/reviewer-role.ts +35 -0
  226. package/src/routes/agents.ts +243 -19
  227. package/src/routes/approvals.ts +70 -19
  228. package/src/routes/blocks.ts +362 -0
  229. package/src/routes/conversations.ts +57 -1
  230. package/src/routes/cost.ts +159 -21
  231. package/src/routes/deployments.ts +266 -56
  232. package/src/routes/eval-comparison.ts +101 -0
  233. package/src/routes/eval-runs.ts +11 -0
  234. package/src/routes/flows.ts +63 -5
  235. package/src/routes/hierarchy-errors.ts +51 -0
  236. package/src/routes/identity.ts +10 -2
  237. package/src/routes/judged-suites.ts +363 -0
  238. package/src/routes/judgment-context.ts +128 -0
  239. package/src/routes/judgment-flow-context.ts +245 -0
  240. package/src/routes/judgments.ts +743 -0
  241. package/src/routes/orgs.ts +44 -27
  242. package/src/routes/policies.ts +19 -0
  243. package/src/routes/projects.ts +106 -95
  244. package/src/routes/provenance.ts +48 -1
  245. package/src/routes/providers.ts +5 -0
  246. package/src/routes/runs.ts +79 -22
  247. package/src/routes/scope-params.ts +35 -1
  248. package/src/routes/teams.ts +96 -90
  249. package/src/types.ts +4 -3
  250. package/src/webhook-endpoint-binding.ts +11 -0
@@ -77,6 +77,27 @@ const TopLevelQueryParam = {
77
77
  description: 'When true, only runs that are not a child of another run.',
78
78
  schema: { type: 'boolean' },
79
79
  };
80
+ const RunAgentIdQueryParam = {
81
+ name: 'agentId',
82
+ in: 'query',
83
+ required: false,
84
+ description: "Only this agent's turns, at any version. Turns that ran before Kindgi 0.1.3 don't name their agent and aren't matched.",
85
+ schema: { type: 'string', minLength: 1 },
86
+ };
87
+ const RunReplaysQueryParam = {
88
+ name: 'replays',
89
+ in: 'query',
90
+ required: false,
91
+ description: '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.',
92
+ schema: { type: 'string', enum: ['exclude', 'include', 'only'], default: 'exclude' },
93
+ };
94
+ const RunEvalRunIdQueryParam = {
95
+ name: 'evalRunId',
96
+ in: 'query',
97
+ required: false,
98
+ description: 'Only the replay runs of this eval run. Implies replays are included; cannot be combined with `replays=exclude`.',
99
+ schema: { type: 'string', minLength: 1 },
100
+ };
80
101
  const RunIncludeQueryParam = {
81
102
  name: 'include',
82
103
  in: 'query',
@@ -410,16 +431,58 @@ const CostToQueryParam = {
410
431
  name: 'to',
411
432
  in: 'query',
412
433
  required: false,
413
- description: 'ISO 8601 timestamp; records with `occurredAt <= to`. Required on `/v1/cost/aggregate` (or both endpoints omitted for default last-30-days window).',
434
+ description: 'ISO 8601 timestamp; records with `occurredAt < to` (exclusive). Required on `/v1/cost/aggregate` (or both endpoints omitted for default last-30-days window).',
414
435
  schema: { type: 'string', format: 'date-time' },
415
436
  };
416
437
  const CostGroupByQueryParam = {
417
438
  name: 'groupBy',
418
439
  in: 'query',
419
440
  required: true,
420
- description: 'Comma-separated list of dimensions to aggregate over. Each value must be one of `agentId | runId | category | providerId | day | month | tenant | conversationId`. Duplicates collapse.',
441
+ description: "Comma-separated list of dimensions to aggregate over. Each value must be one of `agentId | runId | category | providerId | day | month | tenant | conversationId | model | servedModel | projectId | orgId | rootRunId | flowId`. `model` is the model actually called; `servedModel` the exact version the vendor reported; `orgId` the org of the record's project. Duplicates collapse.",
421
442
  schema: { type: 'string' },
422
443
  };
444
+ const CostAggregateLimitQueryParam = {
445
+ name: 'limit',
446
+ in: 'query',
447
+ required: false,
448
+ description: '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.',
449
+ schema: { type: 'integer', minimum: 1, maximum: 10000, default: 1000 },
450
+ };
451
+ const CostModelQueryParam = {
452
+ name: 'model',
453
+ in: 'query',
454
+ required: false,
455
+ description: 'Filter model calls to this model, the one actually called (exact match).',
456
+ schema: { type: 'string' },
457
+ };
458
+ const CostServedModelQueryParam = {
459
+ name: 'servedModel',
460
+ in: 'query',
461
+ required: false,
462
+ description: 'Filter model calls to the exact model version the vendor reported (exact match).',
463
+ schema: { type: 'string' },
464
+ };
465
+ const CostRootRunIdQueryParam = {
466
+ name: 'rootRunId',
467
+ in: 'query',
468
+ required: false,
469
+ description: 'Every record of the run tree whose root is this run: a flow run and the agent turns and sub-flows it started.',
470
+ schema: { type: 'string', format: 'uuid' },
471
+ };
472
+ const CostIncludeDescendantsQueryParam = {
473
+ name: 'includeDescendants',
474
+ in: 'query',
475
+ required: false,
476
+ description: "With `runId`: the run's records and those of every run it started, at any depth. `true` or `false` (default).",
477
+ schema: { type: 'boolean', default: false },
478
+ };
479
+ const CostIncludeQueryParam = {
480
+ name: 'include',
481
+ in: 'query',
482
+ required: false,
483
+ description: "Extra fields, comma-separated. `rawUsage`: each model call's usage object exactly as the vendor reported it.",
484
+ schema: { type: 'string', enum: ['rawUsage'] },
485
+ };
423
486
  const ProviderIdPathParam = {
424
487
  name: 'providerId',
425
488
  in: 'path',
@@ -569,7 +632,7 @@ const EvalSuiteKindFilterQueryParam = {
569
632
  name: 'kind',
570
633
  in: 'query',
571
634
  required: false,
572
- description: 'Filter to eval suites of a single kind. Values: `accuracy | pairwise | regression | human-review | benchmark | custom`.',
635
+ description: 'Filter to eval suites of a single kind. Values: `accuracy | pairwise | regression | human-review | benchmark | custom | judged`.',
573
636
  schema: { $ref: '#/components/schemas/EvalKind' },
574
637
  };
575
638
  const EvalSuiteNameFilterQueryParam = {
@@ -579,6 +642,34 @@ const EvalSuiteNameFilterQueryParam = {
579
642
  description: 'Prefix match on `EvalSuite.id`. Dotted namespaces are the natural filter shape.',
580
643
  schema: { type: 'string' },
581
644
  };
645
+ const BlockIdPathParam = {
646
+ name: 'blockId',
647
+ in: 'path',
648
+ required: true,
649
+ description: 'Block id: dotted lowercase (e.g. `acme.intake-prompt`).',
650
+ schema: { type: 'string', minLength: 1 },
651
+ };
652
+ const BlockVersionPathParam = {
653
+ name: 'version',
654
+ in: 'path',
655
+ required: true,
656
+ description: 'Exact block version (`major.minor.patch`).',
657
+ schema: { type: 'string', minLength: 1 },
658
+ };
659
+ const BlockKindFilterQueryParam = {
660
+ name: 'kind',
661
+ in: 'query',
662
+ required: false,
663
+ description: 'Only blocks of this kind: `prompt` or `settings`.',
664
+ schema: { $ref: '#/components/schemas/BlockKind' },
665
+ };
666
+ const BlockNameFilterQueryParam = {
667
+ name: 'name',
668
+ in: 'query',
669
+ required: false,
670
+ description: 'Prefix match on the block id.',
671
+ schema: { type: 'string' },
672
+ };
582
673
  // Admin plane — eval-run data plane.
583
674
  const EvalRunIdPathParam = {
584
675
  name: 'runId',
@@ -681,6 +772,55 @@ const SecretNamePathParam = {
681
772
  description: 'Secret name (opaque string within the tenant + envName).',
682
773
  schema: { type: 'string', minLength: 1 },
683
774
  };
775
+ // ---------------- judgments + judge classes: parameters ----------------
776
+ const JudgmentIdPathParam = {
777
+ name: 'judgmentId',
778
+ in: 'path',
779
+ required: true,
780
+ description: 'Judgment id.',
781
+ schema: { type: 'string', minLength: 1 },
782
+ };
783
+ const JudgeClassIdPathParam = {
784
+ name: 'judgeClassId',
785
+ in: 'path',
786
+ required: true,
787
+ description: 'Judge class id.',
788
+ schema: { type: 'string', minLength: 1 },
789
+ };
790
+ const judgmentQuery = (name, description, schema) => ({
791
+ name,
792
+ in: 'query',
793
+ required: false,
794
+ description,
795
+ schema,
796
+ });
797
+ const JudgmentListQueryParams = [
798
+ judgmentQuery('runId', 'Only judgments of this run.', { type: 'string', minLength: 1 }),
799
+ judgmentQuery('agentId', 'Only judgments of runs of this agent.', {
800
+ type: 'string',
801
+ minLength: 1,
802
+ }),
803
+ judgmentQuery('agentVersion', 'Only judgments of runs of this agent version. Needs `agentId`.', {
804
+ type: 'string',
805
+ minLength: 1,
806
+ }),
807
+ judgmentQuery('flowId', 'Only judgments of runs of this flow.', { type: 'string', minLength: 1 }),
808
+ judgmentQuery('verdict', 'Only judgments with this verdict.', {
809
+ type: 'string',
810
+ enum: ['yes', 'no'],
811
+ }),
812
+ judgmentQuery('judgeClassId', 'Only judgments recorded under this judge class.', {
813
+ type: 'string',
814
+ minLength: 1,
815
+ }),
816
+ judgmentQuery('participantId', "Only judgments made for this app end user's opaque id.", {
817
+ type: 'string',
818
+ minLength: 1,
819
+ }),
820
+ ];
821
+ const JudgeClassScopeKindQueryParam = judgmentQuery('scopeKind', 'Only classes of this scope kind. `project` and `agent` need `projectId`; `agent` also needs `agentId`.', { type: 'string', enum: ['tenant', 'project', 'agent'] });
822
+ const JudgeClassProjectIdQueryParam = judgmentQuery('projectId', 'Project of the scope, for `scopeKind=project|agent`.', { type: 'string', minLength: 1 });
823
+ const JudgeClassAgentIdQueryParam = judgmentQuery('agentId', 'Agent of the scope, for `scopeKind=agent`.', { type: 'string', minLength: 1 });
684
824
  // ---------------- shared responses ----------------
685
825
  const ErrorResponse = (description) => ({
686
826
  description,
@@ -763,14 +903,19 @@ export const OPERATIONS = [
763
903
  parameters: [
764
904
  LimitQueryParam,
765
905
  CursorQueryParam,
906
+ ScopeKindQueryParam,
907
+ ScopeIdQueryParam,
766
908
  ParentRunIdQueryParam,
767
909
  TopLevelQueryParam,
910
+ RunAgentIdQueryParam,
911
+ RunReplaysQueryParam,
912
+ RunEvalRunIdQueryParam,
768
913
  RunIncludeQueryParam,
769
914
  ],
770
915
  responses: {
771
916
  '200': { description: 'Page of runs.', schema: ref('RunCollectionPage') },
772
917
  ...CommonAuthErrors,
773
- '400': ErrorResponse('Malformed cursor or filter.'),
918
+ '400': ErrorResponse('Malformed cursor, filter or scope.'),
774
919
  },
775
920
  },
776
921
  {
@@ -783,6 +928,7 @@ export const OPERATIONS = [
783
928
  security: 'bearer',
784
929
  parameters: [RunIdPathParam],
785
930
  responses: {
931
+ '400': ErrorResponse('`runId` is not a run id (a UUID).'),
786
932
  '200': { description: 'Run row.', schema: ref('Run') },
787
933
  ...CommonAuthErrors,
788
934
  '404': ErrorResponse('No run with that id under this tenant.'),
@@ -831,6 +977,7 @@ export const OPERATIONS = [
831
977
  security: 'bearer',
832
978
  parameters: [RunIdPathParam, JournalSinceQueryParam],
833
979
  responses: {
980
+ '400': ErrorResponse('`runId` is not a run id (a UUID).'),
834
981
  '200': { description: 'Journal page.', schema: ref('RunJournalPage') },
835
982
  ...CommonAuthErrors,
836
983
  '404': ErrorResponse('No run with that id under this tenant.'),
@@ -847,6 +994,7 @@ export const OPERATIONS = [
847
994
  security: 'bearer',
848
995
  parameters: [RunIdPathParam, LastEventIdParam],
849
996
  responses: {
997
+ '400': ErrorResponse('`runId` is not a run id (a UUID).'),
850
998
  '200': {
851
999
  description: 'text/event-stream. Each frame is one RunEvent.',
852
1000
  contentType: 'text/event-stream',
@@ -867,6 +1015,7 @@ export const OPERATIONS = [
867
1015
  security: 'bearer-or-public-run',
868
1016
  parameters: [RunIdPathParam],
869
1017
  responses: {
1018
+ '400': ErrorResponse('`runId` is not a run id (a UUID).'),
870
1019
  '200': { description: "The run's progress.", schema: ref('RunProgress') },
871
1020
  ...CommonAuthErrors,
872
1021
  '404': ErrorResponse('No run with that id that the token may read.'),
@@ -883,6 +1032,7 @@ export const OPERATIONS = [
883
1032
  security: 'bearer-or-public-run',
884
1033
  parameters: [RunIdPathParam, LastEventIdParam],
885
1034
  responses: {
1035
+ '400': ErrorResponse('`runId` is not a run id (a UUID).'),
886
1036
  '200': {
887
1037
  description: 'text/event-stream. Each frame is one RunProgressEvent.',
888
1038
  contentType: 'text/event-stream',
@@ -1073,12 +1223,14 @@ export const OPERATIONS = [
1073
1223
  openapiPath: '/v1/approvals',
1074
1224
  operationId: 'approvals.list',
1075
1225
  summary: 'List approvals visible to the caller',
1076
- description: 'Requires the token to carry a `reviewerRole`. Role-scoped: reviewers only see approvals whose `requiredRole` rank ≤ their rank (standard < senior < admin).',
1226
+ description: "Requires a reviewer: a token that carries a `reviewerRole`, or whose user is a registered reviewer (the roster gives the role). Role-scoped: reviewers only see approvals whose `requiredRole` rank ≤ their rank (standard < senior < admin). `scopeKind`/`scopeId` narrow to one project's approvals, or every project's in an org; approvals from before Kindgi 0.1.3 have no project and are listed only without a scope.",
1077
1227
  tags: ['approvals'],
1078
1228
  security: 'bearer',
1079
1229
  parameters: [
1080
1230
  LimitQueryParam,
1081
1231
  CursorQueryParam,
1232
+ ScopeKindQueryParam,
1233
+ ScopeIdQueryParam,
1082
1234
  ApprovalStatusQueryParam,
1083
1235
  ApprovalRequiredRoleQueryParam,
1084
1236
  CreatedAfterQueryParam,
@@ -1086,8 +1238,8 @@ export const OPERATIONS = [
1086
1238
  responses: {
1087
1239
  '200': { description: 'Page of approvals.', schema: ref('ApprovalCollectionPage') },
1088
1240
  ...CommonAuthErrors,
1089
- '400': ErrorResponse('Malformed query parameter.'),
1090
- '403': ErrorResponse('Token lacks a reviewer role or asked for a tier above the caller.'),
1241
+ '400': ErrorResponse('Malformed query parameter or scope.'),
1242
+ '403': ErrorResponse("The caller isn't a reviewer, or asked for a tier above its own."),
1091
1243
  },
1092
1244
  },
1093
1245
  {
@@ -1096,14 +1248,14 @@ export const OPERATIONS = [
1096
1248
  openapiPath: '/v1/approvals/{approvalId}',
1097
1249
  operationId: 'approvals.get',
1098
1250
  summary: 'Fetch a single approval',
1099
- description: 'Returns 404 for ids that exist but require a higher role than the caller (avoids cross-tier existence leaks — see API-ROUTE-CONVENTIONS.md §2.4).',
1251
+ description: 'Returns 404 for ids that exist but require a higher role than the caller (avoids cross-tier existence leaks — see API-ROUTE-CONVENTIONS.md §2.4). A decided approval carries its `decision`: what the reviewer decided, why, and who (`decidedBy`, `user:<userId>`).',
1100
1252
  tags: ['approvals'],
1101
1253
  security: 'bearer',
1102
1254
  parameters: [ApprovalIdPathParam],
1103
1255
  responses: {
1104
1256
  '200': { description: 'Approval.', schema: ref('Approval') },
1105
1257
  ...CommonAuthErrors,
1106
- '403': ErrorResponse('Token lacks a reviewer role.'),
1258
+ '403': ErrorResponse("The caller isn't a reviewer."),
1107
1259
  '404': ErrorResponse('No approval with that id — or the caller cannot see it.'),
1108
1260
  },
1109
1261
  },
@@ -1113,7 +1265,7 @@ export const OPERATIONS = [
1113
1265
  openapiPath: '/v1/approvals/{approvalId}/complete',
1114
1266
  operationId: 'approvals.complete',
1115
1267
  summary: 'Submit a decision on an approval',
1116
- description: 'Records the decision (`HitlBinding.submitReview`). When the approval carries a `waitTokenId` and the decision is `approve` or `reject`, also completes the waitpoint so the suspended run resumes.',
1268
+ description: "Records the decision (`HitlBinding.submitReview`). When the approval carries a `waitTokenId` and the decision is `approve` or `reject`, also completes the waitpoint so the suspended run resumes, with `{ decided, rationale?, decidedBy, approvalId }`: the run's journal records who decided which approval (`decidedBy` is `user:<userId>`).",
1117
1269
  tags: ['approvals'],
1118
1270
  security: 'bearer',
1119
1271
  parameters: [ApprovalIdPathParam, IdempotencyKeyParam],
@@ -1206,7 +1358,7 @@ export const OPERATIONS = [
1206
1358
  responses: {
1207
1359
  '200': { description: 'Signed audit bundle.', schema: ref('ExportAuditBundleResult') },
1208
1360
  ...CommonMutationErrors,
1209
- '403': ErrorResponse('Token lacks a reviewer role.'),
1361
+ '403': ErrorResponse("The caller isn't a reviewer."),
1210
1362
  '404': ErrorResponse('Approval not found, signing key id unknown, or signing not configured on this deployment.'),
1211
1363
  },
1212
1364
  },
@@ -1265,6 +1417,24 @@ export const OPERATIONS = [
1265
1417
  '404': ErrorResponse('No agent with that id under this tenant.'),
1266
1418
  },
1267
1419
  },
1420
+ {
1421
+ method: 'post',
1422
+ honoPath: '/v1/agents/:agentId/versions',
1423
+ openapiPath: '/v1/agents/{agentId}/versions',
1424
+ operationId: 'agents.deriveVersion',
1425
+ summary: 'Derive an agent version with data-block pins swapped',
1426
+ description: "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.",
1427
+ tags: ['agents'],
1428
+ security: 'bearer',
1429
+ parameters: [AgentIdPathParam, IdempotencyKeyParam],
1430
+ requestBody: { required: true, schema: ref('DeriveAgentVersionBody') },
1431
+ responses: {
1432
+ '201': { description: 'The derived agent version.', schema: ref('Agent') },
1433
+ ...CommonMutationErrors,
1434
+ '400': ErrorResponse("`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`)."),
1435
+ '404': ErrorResponse('`agent-not-found`: no agent at `from`.'),
1436
+ },
1437
+ },
1268
1438
  {
1269
1439
  method: 'get',
1270
1440
  honoPath: '/v1/agents/:agentId/versions/:version',
@@ -1648,12 +1818,14 @@ export const OPERATIONS = [
1648
1818
  openapiPath: '/v1/conversations',
1649
1819
  operationId: 'conversations.list',
1650
1820
  summary: 'List conversations',
1651
- description: 'Cursor-paginated. Fixed sort: `openedAt desc, id desc`. Filters: `?agentId=`, `?status=open|closed`.',
1821
+ description: "Cursor-paginated. Fixed sort: `openedAt desc, id desc`. Filters: `?agentId=`, `?status=open|closed`, and `scopeKind`/`scopeId` for one project's conversations, or every project's in an org. Conversations from before Kindgi 0.1.3 have no project and are listed only without a scope.",
1652
1822
  tags: ['conversations'],
1653
1823
  security: 'bearer',
1654
1824
  parameters: [
1655
1825
  LimitQueryParam,
1656
1826
  CursorQueryParam,
1827
+ ScopeKindQueryParam,
1828
+ ScopeIdQueryParam,
1657
1829
  AgentIdQueryParam,
1658
1830
  ConversationStatusQueryParam,
1659
1831
  ],
@@ -1663,7 +1835,7 @@ export const OPERATIONS = [
1663
1835
  schema: ref('ConversationCollectionPage'),
1664
1836
  },
1665
1837
  ...CommonAuthErrors,
1666
- '400': ErrorResponse('Malformed query parameter.'),
1838
+ '400': ErrorResponse('Malformed query parameter or scope.'),
1667
1839
  },
1668
1840
  },
1669
1841
  {
@@ -1687,7 +1859,7 @@ export const OPERATIONS = [
1687
1859
  openapiPath: '/v1/conversations',
1688
1860
  operationId: 'conversations.open',
1689
1861
  summary: 'Open a conversation',
1690
- description: 'Pins `(agentId, agentVersion)` at open time. `title` defaults to `"Untitled conversation"` when omitted; `scope` accepts arbitrary JSON.',
1862
+ description: 'Pins `(agentId, agentVersion)` at open time. `title` defaults to `"Untitled conversation"` when omitted; `projectId` puts it in a project (lists filter by it; omitted, the Default project); `scope` accepts arbitrary JSON.',
1691
1863
  tags: ['conversations'],
1692
1864
  security: 'bearer',
1693
1865
  parameters: [IdempotencyKeyParam],
@@ -1986,12 +2158,14 @@ export const OPERATIONS = [
1986
2158
  openapiPath: '/v1/provenance',
1987
2159
  operationId: 'provenance.list',
1988
2160
  summary: 'List provenance records',
1989
- description: 'Cursor-paginated. Metadata rows only — clients fetch the DAG payload via `GET /v1/provenance/{runId}`. Fixed sort: `createdAt desc, id desc`. Filters: `?runId=`, `?agentId=`, `?createdAfter=`.',
2161
+ description: "Cursor-paginated. Metadata rows only — clients fetch the DAG payload via `GET /v1/provenance/{runId}`. Fixed sort: `createdAt desc, id desc`. Filters: `?runId=`, `?agentId=`, `?createdAfter=`, and `scopeKind`/`scopeId` for one project's records, or every project's in an org (records from before Kindgi 0.1.3 have no project and are listed only without a scope).",
1990
2162
  tags: ['provenance'],
1991
2163
  security: 'bearer',
1992
2164
  parameters: [
1993
2165
  LimitQueryParam,
1994
2166
  CursorQueryParam,
2167
+ ScopeKindQueryParam,
2168
+ ScopeIdQueryParam,
1995
2169
  ProvenanceRunIdQueryParam,
1996
2170
  ProvenanceAgentIdQueryParam,
1997
2171
  ProvenanceCreatedAfterQueryParam,
@@ -1999,7 +2173,7 @@ export const OPERATIONS = [
1999
2173
  responses: {
2000
2174
  '200': { description: 'Page of records.', schema: ref('ProvenanceCollectionPage') },
2001
2175
  ...CommonAuthErrors,
2002
- '400': ErrorResponse('Malformed cursor or `createdAfter` timestamp.'),
2176
+ '400': ErrorResponse('Malformed cursor, `createdAfter` timestamp or scope.'),
2003
2177
  },
2004
2178
  },
2005
2179
  {
@@ -2291,7 +2465,7 @@ export const OPERATIONS = [
2291
2465
  openapiPath: '/v1/providers',
2292
2466
  operationId: 'providers.register',
2293
2467
  summary: 'Register a model provider',
2294
- description: '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.',
2468
+ description: '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.',
2295
2469
  tags: ['providers'],
2296
2470
  security: 'bearer',
2297
2471
  parameters: [IdempotencyKeyParam],
@@ -2309,13 +2483,181 @@ export const OPERATIONS = [
2309
2483
  openapiPath: '/v1/providers/{providerId}/unregister',
2310
2484
  operationId: 'providers.unregister',
2311
2485
  summary: 'Unregister a model provider',
2486
+ description: '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.',
2312
2487
  tags: ['providers'],
2313
2488
  security: 'bearer',
2314
2489
  parameters: [ProviderIdPathParam, IdempotencyKeyParam],
2315
2490
  responses: {
2316
2491
  '200': { description: 'Unregistered.', schema: ref('UnregisterProviderResult') },
2317
2492
  ...CommonMutationErrors,
2318
- '404': ErrorResponse('No provider with that id under this tenant.'),
2493
+ '404': ErrorResponse('No provider with that id under this tenant, or already unregistered.'),
2494
+ },
2495
+ },
2496
+ // ---------- judgments ----------
2497
+ {
2498
+ method: 'post',
2499
+ honoPath: '/v1/judgments',
2500
+ openapiPath: '/v1/judgments',
2501
+ operationId: 'judgments.create',
2502
+ summary: "Judge an item of a run's output",
2503
+ description: "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.",
2504
+ tags: ['judgments'],
2505
+ security: 'bearer',
2506
+ parameters: [IdempotencyKeyParam],
2507
+ requestBody: { required: true, schema: ref('CreateJudgmentBody') },
2508
+ responses: {
2509
+ '201': { description: 'Judgment recorded.', schema: ref('Judgment') },
2510
+ ...CommonMutationErrors,
2511
+ '400': ErrorResponse('Malformed body, or `item-not-found` (the pointer resolves to nothing in the output), or `judge-class-not-applicable`.'),
2512
+ '403': ErrorResponse('`permission-denied`: not allowed to judge this run.'),
2513
+ '404': ErrorResponse('`run-not-found`.'),
2514
+ '409': ErrorResponse('`run-not-finished`: the run has no output to judge yet.'),
2515
+ },
2516
+ },
2517
+ {
2518
+ method: 'get',
2519
+ honoPath: '/v1/judgments',
2520
+ openapiPath: '/v1/judgments',
2521
+ operationId: 'judgments.list',
2522
+ summary: 'List judgments',
2523
+ description: '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.',
2524
+ tags: ['judgments'],
2525
+ security: 'bearer',
2526
+ parameters: [
2527
+ LimitQueryParam,
2528
+ CursorQueryParam,
2529
+ ...JudgmentListQueryParams,
2530
+ ScopeKindQueryParam,
2531
+ ScopeIdQueryParam,
2532
+ ],
2533
+ responses: {
2534
+ '200': { description: 'Page of judgments.', schema: ref('JudgmentCollectionPage') },
2535
+ ...CommonAuthErrors,
2536
+ '400': ErrorResponse('Malformed query parameter.'),
2537
+ },
2538
+ },
2539
+ {
2540
+ method: 'get',
2541
+ honoPath: '/v1/judgments/:judgmentId',
2542
+ openapiPath: '/v1/judgments/{judgmentId}',
2543
+ operationId: 'judgments.get',
2544
+ summary: 'Fetch a judgment with its copies',
2545
+ description: "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.",
2546
+ tags: ['judgments'],
2547
+ security: 'bearer',
2548
+ parameters: [JudgmentIdPathParam],
2549
+ responses: {
2550
+ '200': { description: 'Judgment with copies.', schema: ref('JudgmentWithCopies') },
2551
+ ...CommonAuthErrors,
2552
+ '404': ErrorResponse('No judgment with that id under this tenant.'),
2553
+ },
2554
+ },
2555
+ {
2556
+ method: 'post',
2557
+ honoPath: '/v1/judgments/:judgmentId/unregister',
2558
+ openapiPath: '/v1/judgments/{judgmentId}/unregister',
2559
+ operationId: 'judgments.unregister',
2560
+ summary: 'Remove a judgment',
2561
+ description: 'Soft delete: the judgment stops listing; retention policy decides when it is purged.',
2562
+ tags: ['judgments'],
2563
+ security: 'bearer',
2564
+ parameters: [JudgmentIdPathParam, IdempotencyKeyParam],
2565
+ responses: {
2566
+ '200': { description: 'Removed.', schema: ref('UnregisterJudgmentResult') },
2567
+ ...CommonMutationErrors,
2568
+ '403': ErrorResponse('`permission-denied`.'),
2569
+ '404': ErrorResponse('No live judgment with that id under this tenant.'),
2570
+ },
2571
+ },
2572
+ // ---------- judge classes ----------
2573
+ {
2574
+ method: 'post',
2575
+ honoPath: '/v1/judge-classes',
2576
+ openapiPath: '/v1/judge-classes',
2577
+ operationId: 'judgeClasses.create',
2578
+ summary: 'Create a judge class',
2579
+ description: '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.',
2580
+ tags: ['judge-classes'],
2581
+ security: 'bearer',
2582
+ parameters: [IdempotencyKeyParam],
2583
+ requestBody: { required: true, schema: ref('CreateJudgeClassBody') },
2584
+ responses: {
2585
+ '201': { description: 'Judge class created.', schema: ref('JudgeClass') },
2586
+ ...CommonMutationErrors,
2587
+ '403': ErrorResponse('`permission-denied`.'),
2588
+ '409': ErrorResponse('`judge-class-name-taken`, or an idempotency conflict.'),
2589
+ },
2590
+ },
2591
+ {
2592
+ method: 'get',
2593
+ honoPath: '/v1/judge-classes',
2594
+ openapiPath: '/v1/judge-classes',
2595
+ operationId: 'judgeClasses.list',
2596
+ summary: 'List judge classes',
2597
+ description: 'Live classes, newest first, cursor-paginated. `?scopeKind=tenant|project|agent` (with `projectId` / `agentId`) narrows to one scope.',
2598
+ tags: ['judge-classes'],
2599
+ security: 'bearer',
2600
+ parameters: [
2601
+ LimitQueryParam,
2602
+ CursorQueryParam,
2603
+ JudgeClassScopeKindQueryParam,
2604
+ JudgeClassProjectIdQueryParam,
2605
+ JudgeClassAgentIdQueryParam,
2606
+ ],
2607
+ responses: {
2608
+ '200': { description: 'Page of judge classes.', schema: ref('JudgeClassCollectionPage') },
2609
+ ...CommonAuthErrors,
2610
+ '400': ErrorResponse('Malformed scope parameters.'),
2611
+ },
2612
+ },
2613
+ {
2614
+ method: 'get',
2615
+ honoPath: '/v1/judge-classes/:judgeClassId',
2616
+ openapiPath: '/v1/judge-classes/{judgeClassId}',
2617
+ operationId: 'judgeClasses.get',
2618
+ summary: 'Fetch a judge class',
2619
+ description: 'Also returns a retired class (`unregisteredAt` set): judgments keep naming theirs.',
2620
+ tags: ['judge-classes'],
2621
+ security: 'bearer',
2622
+ parameters: [JudgeClassIdPathParam],
2623
+ responses: {
2624
+ '200': { description: 'Judge class.', schema: ref('JudgeClass') },
2625
+ ...CommonAuthErrors,
2626
+ '404': ErrorResponse('No judge class with that id under this tenant.'),
2627
+ },
2628
+ },
2629
+ {
2630
+ method: 'patch',
2631
+ honoPath: '/v1/judge-classes/:judgeClassId',
2632
+ openapiPath: '/v1/judge-classes/{judgeClassId}',
2633
+ operationId: 'judgeClasses.update',
2634
+ summary: "Change a judge class's weight or description",
2635
+ tags: ['judge-classes'],
2636
+ security: 'bearer',
2637
+ parameters: [JudgeClassIdPathParam, IdempotencyKeyParam],
2638
+ requestBody: { required: true, schema: ref('UpdateJudgeClassBody') },
2639
+ responses: {
2640
+ '200': { description: 'Updated judge class.', schema: ref('JudgeClass') },
2641
+ ...CommonMutationErrors,
2642
+ '403': ErrorResponse('`permission-denied`.'),
2643
+ '404': ErrorResponse('No live judge class with that id under this tenant.'),
2644
+ },
2645
+ },
2646
+ {
2647
+ method: 'post',
2648
+ honoPath: '/v1/judge-classes/:judgeClassId/unregister',
2649
+ openapiPath: '/v1/judge-classes/{judgeClassId}/unregister',
2650
+ operationId: 'judgeClasses.unregister',
2651
+ summary: 'Retire a judge class',
2652
+ description: 'No new judgments may name it; existing judgments keep it.',
2653
+ tags: ['judge-classes'],
2654
+ security: 'bearer',
2655
+ parameters: [JudgeClassIdPathParam, IdempotencyKeyParam],
2656
+ responses: {
2657
+ '200': { description: 'Retired.', schema: ref('UnregisterJudgeClassResult') },
2658
+ ...CommonMutationErrors,
2659
+ '403': ErrorResponse('`permission-denied`.'),
2660
+ '404': ErrorResponse('No live judge class with that id under this tenant.'),
2319
2661
  },
2320
2662
  },
2321
2663
  // ---------- mcp (interop plane) ----------
@@ -2473,7 +2815,7 @@ export const OPERATIONS = [
2473
2815
  openapiPath: '/v1/cost/records',
2474
2816
  operationId: 'cost.records.list',
2475
2817
  summary: 'List cost records',
2476
- description: 'Cursor-paginated. Filters (all AND): `runId`, `agentId`, `conversationId`, `category`, `providerId`, `from`, `to`. Sort order is fixed: `occurredAt desc, id desc`. Records represent one accounted resource event each — LLM inference, tool invocation, storage write, sandbox execution, etc.',
2818
+ description: "Cursor-paginated. Filters (all AND): `runId` (with `includeDescendants`, its whole subtree), `rootRunId`, `agentId`, `conversationId`, `category`, `providerId`, `model`, `servedModel`, `from`, `to`. Sort order is fixed: `occurredAt desc, id desc`. Records represent one accounted resource event each — a model call (`category` `llm.inference`: one record per call, with its model, usage and what the vendor said about it), tool invocation, storage write, sandbox execution, etc. `include=rawUsage` adds each model call's usage as the vendor reported it.",
2477
2819
  tags: ['cost'],
2478
2820
  security: 'bearer',
2479
2821
  parameters: [
@@ -2484,11 +2826,16 @@ export const OPERATIONS = [
2484
2826
  CostConversationIdQueryParam,
2485
2827
  CostCategoryQueryParam,
2486
2828
  CostProviderIdQueryParam,
2829
+ CostModelQueryParam,
2830
+ CostServedModelQueryParam,
2831
+ CostRootRunIdQueryParam,
2832
+ CostIncludeDescendantsQueryParam,
2487
2833
  CostFromQueryParam,
2488
2834
  CostToQueryParam,
2489
2835
  ScopeKindQueryParam,
2490
2836
  ScopeIdQueryParam,
2491
2837
  InheritQueryParam,
2838
+ CostIncludeQueryParam,
2492
2839
  ],
2493
2840
  responses: {
2494
2841
  '200': { description: 'Page of cost records.', schema: ref('CostRecordCollectionPage') },
@@ -2504,7 +2851,7 @@ export const OPERATIONS = [
2504
2851
  summary: 'Fetch a cost record',
2505
2852
  tags: ['cost'],
2506
2853
  security: 'bearer',
2507
- parameters: [CostRecordIdPathParam],
2854
+ parameters: [CostRecordIdPathParam, CostIncludeQueryParam],
2508
2855
  responses: {
2509
2856
  '200': { description: 'Cost record.', schema: ref('CostRecord') },
2510
2857
  ...CommonAuthErrors,
@@ -2517,11 +2864,12 @@ export const OPERATIONS = [
2517
2864
  openapiPath: '/v1/cost/aggregate',
2518
2865
  operationId: 'cost.aggregate',
2519
2866
  summary: 'Aggregate cost across a time window',
2520
- description: '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 + ?inherit` narrow the aggregate to a specific scope — reconciles byte-for-byte with the same scoped `/records` list.',
2867
+ description: "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.",
2521
2868
  tags: ['cost'],
2522
2869
  security: 'bearer',
2523
2870
  parameters: [
2524
2871
  CostGroupByQueryParam,
2872
+ CostAggregateLimitQueryParam,
2525
2873
  CostFromQueryParam,
2526
2874
  CostToQueryParam,
2527
2875
  CostCategoryQueryParam,
@@ -2529,6 +2877,10 @@ export const OPERATIONS = [
2529
2877
  CostAgentIdQueryParam,
2530
2878
  CostRunIdQueryParam,
2531
2879
  CostConversationIdQueryParam,
2880
+ CostModelQueryParam,
2881
+ CostServedModelQueryParam,
2882
+ CostRootRunIdQueryParam,
2883
+ CostIncludeDescendantsQueryParam,
2532
2884
  ScopeKindQueryParam,
2533
2885
  ScopeIdQueryParam,
2534
2886
  InheritQueryParam,
@@ -2692,7 +3044,7 @@ export const OPERATIONS = [
2692
3044
  openapiPath: '/v1/policies',
2693
3045
  operationId: 'policies.publish',
2694
3046
  summary: 'Publish a policy',
2695
- description: "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).",
3047
+ description: "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).",
2696
3048
  tags: ['policies'],
2697
3049
  security: 'bearer',
2698
3050
  parameters: [IdempotencyKeyParam],
@@ -2700,7 +3052,7 @@ export const OPERATIONS = [
2700
3052
  responses: {
2701
3053
  '201': { description: 'Policy published.', schema: ref('PublishPolicyResult') },
2702
3054
  ...CommonMutationErrors,
2703
- '400': ErrorResponse('Validation failed (see `details.issues`).'),
3055
+ '400': ErrorResponse('Validation failed (see `details.issues`), or `kind-not-applied`: no runtime consumer applies that kind yet.'),
2704
3056
  '409': ErrorResponse('Policy already registered at that (id, version).'),
2705
3057
  },
2706
3058
  },
@@ -2827,6 +3179,47 @@ export const OPERATIONS = [
2827
3179
  '409': ErrorResponse('Eval suite already registered at that (id, version).'),
2828
3180
  },
2829
3181
  },
3182
+ {
3183
+ method: 'post',
3184
+ honoPath: '/v1/eval-suites/:suiteId/versions/from-judgments',
3185
+ openapiPath: '/v1/eval-suites/{suiteId}/versions/from-judgments',
3186
+ operationId: 'evalSuites.buildFromJudgments',
3187
+ summary: 'Build a test set from judgments',
3188
+ description: "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.",
3189
+ tags: ['eval-suites'],
3190
+ security: 'bearer',
3191
+ parameters: [EvalSuiteIdPathParam, IdempotencyKeyParam],
3192
+ requestBody: { required: true, schema: ref('BuildJudgedSuiteBody') },
3193
+ responses: {
3194
+ '201': { description: 'Version published.', schema: ref('BuildJudgedSuiteResult') },
3195
+ ...CommonMutationErrors,
3196
+ '400': ErrorResponse('Malformed body.'),
3197
+ '403': ErrorResponse('`permission-denied`.'),
3198
+ '409': ErrorResponse('Eval suite already registered at that (id, version).'),
3199
+ '501': ErrorResponse('`test-sets-not-supported`: this deployment cannot build test sets.'),
3200
+ },
3201
+ },
3202
+ {
3203
+ method: 'get',
3204
+ honoPath: '/v1/eval-suites/:suiteId/versions/:version/cases',
3205
+ openapiPath: '/v1/eval-suites/{suiteId}/versions/{version}/cases',
3206
+ operationId: 'evalSuites.listCases',
3207
+ summary: 'List the cases of a judged eval suite version',
3208
+ description: 'Cursor-paginated, in the order the cases were stored (newest judged run first).',
3209
+ tags: ['eval-suites'],
3210
+ security: 'bearer',
3211
+ parameters: [
3212
+ EvalSuiteIdPathParam,
3213
+ EvalSuiteVersionPathParam,
3214
+ LimitQueryParam,
3215
+ CursorQueryParam,
3216
+ ],
3217
+ responses: {
3218
+ '200': { description: 'Page of cases.', schema: ref('JudgedEvalCaseCollectionPage') },
3219
+ ...CommonAuthErrors,
3220
+ '404': ErrorResponse('No eval suite with that id.'),
3221
+ },
3222
+ },
2830
3223
  {
2831
3224
  method: 'post',
2832
3225
  honoPath: '/v1/eval-suites/:suiteId/versions/:version/unregister',
@@ -2859,6 +3252,129 @@ export const OPERATIONS = [
2859
3252
  },
2860
3253
  },
2861
3254
  // ---------- eval runs (data plane) ----------
3255
+ {
3256
+ method: 'get',
3257
+ honoPath: '/v1/blocks',
3258
+ openapiPath: '/v1/blocks',
3259
+ operationId: 'blocks.list',
3260
+ summary: 'List data blocks (latest version of each)',
3261
+ description: '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.',
3262
+ tags: ['blocks'],
3263
+ security: 'bearer',
3264
+ parameters: [
3265
+ LimitQueryParam,
3266
+ CursorQueryParam,
3267
+ BlockKindFilterQueryParam,
3268
+ BlockNameFilterQueryParam,
3269
+ ScopeKindQueryParam,
3270
+ ScopeIdQueryParam,
3271
+ ],
3272
+ responses: {
3273
+ '200': { description: 'Page of blocks.', schema: ref('BlockCollectionPage') },
3274
+ ...CommonAuthErrors,
3275
+ '400': ErrorResponse('Malformed query parameter: an unknown `kind`, or `scope-invalid` for a malformed scope.'),
3276
+ },
3277
+ },
3278
+ {
3279
+ method: 'get',
3280
+ honoPath: '/v1/blocks/:blockId',
3281
+ openapiPath: '/v1/blocks/{blockId}',
3282
+ operationId: 'blocks.get',
3283
+ summary: 'Fetch a data block (latest version)',
3284
+ tags: ['blocks'],
3285
+ security: 'bearer',
3286
+ parameters: [BlockIdPathParam],
3287
+ responses: {
3288
+ '200': { description: 'Latest active version.', schema: ref('Block') },
3289
+ ...CommonAuthErrors,
3290
+ '404': ErrorResponse("`block-not-found`: no such block, or one in a project the caller can't read."),
3291
+ },
3292
+ },
3293
+ {
3294
+ method: 'get',
3295
+ honoPath: '/v1/blocks/:blockId/versions',
3296
+ openapiPath: '/v1/blocks/{blockId}/versions',
3297
+ operationId: 'blocks.versions.list',
3298
+ summary: 'List versions of a data block',
3299
+ description: 'Newest published first. `?includeTombstoned=true` includes unregistered versions, each with `unregisteredAt`.',
3300
+ tags: ['blocks'],
3301
+ security: 'bearer',
3302
+ parameters: [BlockIdPathParam, LimitQueryParam, CursorQueryParam, IncludeTombstonedQueryParam],
3303
+ responses: {
3304
+ '200': { description: 'Page of versions.', schema: ref('BlockCollectionPage') },
3305
+ ...CommonAuthErrors,
3306
+ '404': ErrorResponse('`block-not-found`.'),
3307
+ },
3308
+ },
3309
+ {
3310
+ method: 'get',
3311
+ honoPath: '/v1/blocks/:blockId/versions/:version',
3312
+ openapiPath: '/v1/blocks/{blockId}/versions/{version}',
3313
+ operationId: 'blocks.versions.get',
3314
+ summary: 'Fetch a specific data block version',
3315
+ description: 'An unregistered version is returned too, with `unregisteredAt`.',
3316
+ tags: ['blocks'],
3317
+ security: 'bearer',
3318
+ parameters: [BlockIdPathParam, BlockVersionPathParam],
3319
+ responses: {
3320
+ '200': { description: 'The block at that version.', schema: ref('Block') },
3321
+ ...CommonAuthErrors,
3322
+ '404': ErrorResponse('`block-not-found`.'),
3323
+ },
3324
+ },
3325
+ {
3326
+ method: 'post',
3327
+ honoPath: '/v1/blocks',
3328
+ openapiPath: '/v1/blocks',
3329
+ operationId: 'blocks.publish',
3330
+ summary: 'Publish a data block version',
3331
+ description: "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.",
3332
+ tags: ['blocks'],
3333
+ security: 'bearer',
3334
+ parameters: [IdempotencyKeyParam],
3335
+ requestBody: { required: true, schema: ref('PublishBlockBody') },
3336
+ responses: {
3337
+ '201': { description: 'Published.', schema: ref('PublishBlockResult') },
3338
+ ...CommonMutationErrors,
3339
+ '400': ErrorResponse('`validation-failed` (see `details.issues`), or an unknown `projectId`.'),
3340
+ '403': ErrorResponse('`permission-denied`: no `write` on the project.'),
3341
+ '409': ErrorResponse('`block-already-registered` or `block-project-mismatch`.'),
3342
+ },
3343
+ },
3344
+ {
3345
+ method: 'post',
3346
+ honoPath: '/v1/blocks/:blockId/versions/:version/unregister',
3347
+ openapiPath: '/v1/blocks/{blockId}/versions/{version}/unregister',
3348
+ operationId: 'blocks.versions.unregister',
3349
+ summary: 'Unregister a data block version',
3350
+ description: '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.',
3351
+ tags: ['blocks'],
3352
+ security: 'bearer',
3353
+ parameters: [BlockIdPathParam, BlockVersionPathParam, IdempotencyKeyParam],
3354
+ responses: {
3355
+ '200': { description: 'Unregistered.', schema: ref('UnregisterBlockResult') },
3356
+ ...CommonMutationErrors,
3357
+ '403': ErrorResponse('`permission-denied`: no `write` on the project.'),
3358
+ '404': ErrorResponse('`block-not-found`, or already unregistered.'),
3359
+ },
3360
+ },
3361
+ {
3362
+ method: 'post',
3363
+ honoPath: '/v1/blocks/:blockId/versions/:version/reinstate',
3364
+ openapiPath: '/v1/blocks/{blockId}/versions/{version}/reinstate',
3365
+ operationId: 'blocks.versions.reinstate',
3366
+ summary: 'Reinstate an unregistered data block version',
3367
+ description: 'Unchanged, as published. Idempotent. Needs `write` on the project.',
3368
+ tags: ['blocks'],
3369
+ security: 'bearer',
3370
+ parameters: [BlockIdPathParam, BlockVersionPathParam, IdempotencyKeyParam],
3371
+ responses: {
3372
+ '200': { description: 'Reinstated.', schema: ref('ReinstateBlockResult') },
3373
+ ...CommonMutationErrors,
3374
+ '403': ErrorResponse('`permission-denied`: no `write` on the project.'),
3375
+ '404': ErrorResponse('`block-not-found`.'),
3376
+ },
3377
+ },
2862
3378
  {
2863
3379
  method: 'post',
2864
3380
  honoPath: '/v1/eval-suites/:suiteId/runs',
@@ -3634,7 +4150,7 @@ export const OPERATIONS = [
3634
4150
  openapiPath: '/v1/orgs/{orgId}',
3635
4151
  operationId: 'orgs.delete',
3636
4152
  summary: 'Delete an org (idempotent)',
3637
- description: 'Idempotent — deleting an unknown or already-deleted org returns 204 per the binding contract.',
4153
+ description: "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.",
3638
4154
  tags: ['orgs'],
3639
4155
  security: 'bearer',
3640
4156
  parameters: [
@@ -3650,6 +4166,7 @@ export const OPERATIONS = [
3650
4166
  responses: {
3651
4167
  '204': { description: 'Deleted (or already absent). No body.' },
3652
4168
  ...CommonAuthErrors,
4169
+ '409': ErrorResponse("slug-conflict: the org's projects would leave it with slugs that projects without an org already have."),
3653
4170
  },
3654
4171
  },
3655
4172
  // ---------- teams ----------
@@ -3944,6 +4461,7 @@ export const OPERATIONS = [
3944
4461
  openapiPath: '/v1/projects',
3945
4462
  operationId: 'projects.create',
3946
4463
  summary: 'Create a project',
4464
+ description: "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`.",
3947
4465
  tags: ['projects'],
3948
4466
  security: 'bearer',
3949
4467
  parameters: [IdempotencyKeyParam],
@@ -3982,6 +4500,7 @@ export const OPERATIONS = [
3982
4500
  openapiPath: '/v1/projects/{projectId}',
3983
4501
  operationId: 'projects.update',
3984
4502
  summary: 'Partially update a project',
4503
+ description: '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.',
3985
4504
  tags: ['projects'],
3986
4505
  security: 'bearer',
3987
4506
  parameters: [