@kindgi/api 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (516) hide show
  1. package/dist/agent-binding.d.ts +13 -0
  2. package/dist/agent-binding.d.ts.map +1 -1
  3. package/dist/agent-pins.d.ts.map +1 -1
  4. package/dist/agent-pins.js +18 -2
  5. package/dist/agent-pins.js.map +1 -1
  6. package/dist/app.d.ts +110 -17
  7. package/dist/app.d.ts.map +1 -1
  8. package/dist/app.js +163 -35
  9. package/dist/app.js.map +1 -1
  10. package/dist/block-publish.d.ts +56 -0
  11. package/dist/block-publish.d.ts.map +1 -0
  12. package/dist/block-publish.js +132 -0
  13. package/dist/block-publish.js.map +1 -0
  14. package/dist/caller.d.ts +24 -0
  15. package/dist/caller.d.ts.map +1 -0
  16. package/dist/caller.js +47 -0
  17. package/dist/caller.js.map +1 -0
  18. package/dist/capability-binding.d.ts +11 -0
  19. package/dist/capability-binding.d.ts.map +1 -1
  20. package/dist/cost-binding.d.ts +19 -0
  21. package/dist/cost-binding.d.ts.map +1 -1
  22. package/dist/cost-binding.js.map +1 -1
  23. package/dist/derive-agent-version.d.ts +7 -0
  24. package/dist/derive-agent-version.d.ts.map +1 -1
  25. package/dist/derive-agent-version.js +4 -0
  26. package/dist/derive-agent-version.js.map +1 -1
  27. package/dist/errors.d.ts.map +1 -1
  28. package/dist/errors.js +75 -7
  29. package/dist/errors.js.map +1 -1
  30. package/dist/eval-case-binding.d.ts +16 -4
  31. package/dist/eval-case-binding.d.ts.map +1 -1
  32. package/dist/eval-run-binding.d.ts +31 -0
  33. package/dist/eval-run-binding.d.ts.map +1 -1
  34. package/dist/eval-run-dispatcher.d.ts +7 -0
  35. package/dist/eval-run-dispatcher.d.ts.map +1 -1
  36. package/dist/eval-run-dispatcher.js.map +1 -1
  37. package/dist/eval-sample.d.ts +11 -0
  38. package/dist/eval-sample.d.ts.map +1 -0
  39. package/dist/eval-sample.js +34 -0
  40. package/dist/eval-sample.js.map +1 -0
  41. package/dist/eval-suite-binding.d.ts +13 -0
  42. package/dist/eval-suite-binding.d.ts.map +1 -1
  43. package/dist/eval-suite-binding.js.map +1 -1
  44. package/dist/flow-binding.d.ts +18 -0
  45. package/dist/flow-binding.d.ts.map +1 -1
  46. package/dist/flow-pins.d.ts.map +1 -1
  47. package/dist/flow-pins.js +18 -2
  48. package/dist/flow-pins.js.map +1 -1
  49. package/dist/gate.d.ts.map +1 -1
  50. package/dist/gate.js +25 -0
  51. package/dist/gate.js.map +1 -1
  52. package/dist/handler-binding.d.ts +32 -0
  53. package/dist/handler-binding.d.ts.map +1 -1
  54. package/dist/hitl-binding.d.ts +23 -0
  55. package/dist/hitl-binding.d.ts.map +1 -1
  56. package/dist/identity-directory-binding.d.ts +82 -4
  57. package/dist/identity-directory-binding.d.ts.map +1 -1
  58. package/dist/identity-provider-binding.d.ts +197 -17
  59. package/dist/identity-provider-binding.d.ts.map +1 -1
  60. package/dist/improvement-pass-binding.d.ts +196 -0
  61. package/dist/improvement-pass-binding.d.ts.map +1 -0
  62. package/dist/improvement-pass-binding.js +9 -0
  63. package/dist/improvement-pass-binding.js.map +1 -0
  64. package/dist/index.d.ts +35 -17
  65. package/dist/index.d.ts.map +1 -1
  66. package/dist/index.js +11 -3
  67. package/dist/index.js.map +1 -1
  68. package/dist/judged-dispatcher.d.ts +25 -4
  69. package/dist/judged-dispatcher.d.ts.map +1 -1
  70. package/dist/judged-dispatcher.js +43 -6
  71. package/dist/judged-dispatcher.js.map +1 -1
  72. package/dist/judgment-binding.d.ts +25 -1
  73. package/dist/judgment-binding.d.ts.map +1 -1
  74. package/dist/mcp-endpoint-binding.d.ts +7 -0
  75. package/dist/mcp-endpoint-binding.d.ts.map +1 -1
  76. package/dist/memory-binding.d.ts +124 -17
  77. package/dist/memory-binding.d.ts.map +1 -1
  78. package/dist/memory-erasure-binding.d.ts +145 -0
  79. package/dist/memory-erasure-binding.d.ts.map +1 -0
  80. package/dist/memory-erasure-binding.js +4 -0
  81. package/dist/memory-erasure-binding.js.map +1 -0
  82. package/dist/middleware/auth.d.ts +66 -13
  83. package/dist/middleware/auth.d.ts.map +1 -1
  84. package/dist/middleware/auth.js +150 -50
  85. package/dist/middleware/auth.js.map +1 -1
  86. package/dist/middleware/authorize.d.ts +9 -0
  87. package/dist/middleware/authorize.d.ts.map +1 -1
  88. package/dist/middleware/authorize.js +122 -4
  89. package/dist/middleware/authorize.js.map +1 -1
  90. package/dist/middleware/error-mapper.d.ts +5 -0
  91. package/dist/middleware/error-mapper.d.ts.map +1 -1
  92. package/dist/middleware/error-mapper.js +14 -1
  93. package/dist/middleware/error-mapper.js.map +1 -1
  94. package/dist/middleware/idempotency.d.ts +70 -5
  95. package/dist/middleware/idempotency.d.ts.map +1 -1
  96. package/dist/middleware/idempotency.js +174 -41
  97. package/dist/middleware/idempotency.js.map +1 -1
  98. package/dist/middleware/key-project.d.ts +17 -0
  99. package/dist/middleware/key-project.d.ts.map +1 -0
  100. package/dist/middleware/key-project.js +75 -0
  101. package/dist/middleware/key-project.js.map +1 -0
  102. package/dist/middleware/principal.d.ts.map +1 -1
  103. package/dist/middleware/principal.js +9 -5
  104. package/dist/middleware/principal.js.map +1 -1
  105. package/dist/middleware/project-ref.d.ts.map +1 -1
  106. package/dist/middleware/project-ref.js +3 -0
  107. package/dist/middleware/project-ref.js.map +1 -1
  108. package/dist/openapi/generate.d.ts.map +1 -1
  109. package/dist/openapi/generate.js +5 -2
  110. package/dist/openapi/generate.js.map +1 -1
  111. package/dist/openapi/operations.d.ts.map +1 -1
  112. package/dist/openapi/operations.js +919 -140
  113. package/dist/openapi/operations.js.map +1 -1
  114. package/dist/openapi/schemas.d.ts +90 -13
  115. package/dist/openapi/schemas.d.ts.map +1 -1
  116. package/dist/openapi/schemas.js +2081 -359
  117. package/dist/openapi/schemas.js.map +1 -1
  118. package/dist/person-grants-binding.d.ts +77 -0
  119. package/dist/person-grants-binding.d.ts.map +1 -0
  120. package/dist/person-grants-binding.js +4 -0
  121. package/dist/person-grants-binding.js.map +1 -0
  122. package/dist/proposal-service.d.ts +121 -0
  123. package/dist/proposal-service.d.ts.map +1 -0
  124. package/dist/proposal-service.js +447 -0
  125. package/dist/proposal-service.js.map +1 -0
  126. package/dist/proposal-status.d.ts +60 -0
  127. package/dist/proposal-status.d.ts.map +1 -0
  128. package/dist/proposal-status.js +109 -0
  129. package/dist/proposal-status.js.map +1 -0
  130. package/dist/provider-binding.d.ts +10 -0
  131. package/dist/provider-binding.d.ts.map +1 -1
  132. package/dist/publish-refused.d.ts +28 -3
  133. package/dist/publish-refused.d.ts.map +1 -1
  134. package/dist/publish-refused.js +24 -3
  135. package/dist/publish-refused.js.map +1 -1
  136. package/dist/routes/adapters.d.ts +2 -1
  137. package/dist/routes/adapters.d.ts.map +1 -1
  138. package/dist/routes/adapters.js +3 -1
  139. package/dist/routes/adapters.js.map +1 -1
  140. package/dist/routes/agent-releases.d.ts +55 -3
  141. package/dist/routes/agent-releases.d.ts.map +1 -1
  142. package/dist/routes/agent-releases.js +85 -55
  143. package/dist/routes/agent-releases.js.map +1 -1
  144. package/dist/routes/agents.d.ts +12 -1
  145. package/dist/routes/agents.d.ts.map +1 -1
  146. package/dist/routes/agents.js +100 -2
  147. package/dist/routes/agents.js.map +1 -1
  148. package/dist/routes/approvals.d.ts +15 -3
  149. package/dist/routes/approvals.d.ts.map +1 -1
  150. package/dist/routes/approvals.js +133 -122
  151. package/dist/routes/approvals.js.map +1 -1
  152. package/dist/routes/artifacts.d.ts +25 -3
  153. package/dist/routes/artifacts.d.ts.map +1 -1
  154. package/dist/routes/artifacts.js +116 -7
  155. package/dist/routes/artifacts.js.map +1 -1
  156. package/dist/routes/auth.d.ts +25 -1
  157. package/dist/routes/auth.d.ts.map +1 -1
  158. package/dist/routes/auth.js +655 -281
  159. package/dist/routes/auth.js.map +1 -1
  160. package/dist/routes/blocks.d.ts.map +1 -1
  161. package/dist/routes/blocks.js +2 -42
  162. package/dist/routes/blocks.js.map +1 -1
  163. package/dist/routes/capabilities.d.ts +2 -1
  164. package/dist/routes/capabilities.d.ts.map +1 -1
  165. package/dist/routes/capabilities.js +6 -1
  166. package/dist/routes/capabilities.js.map +1 -1
  167. package/dist/routes/compliance.d.ts +9 -10
  168. package/dist/routes/compliance.d.ts.map +1 -1
  169. package/dist/routes/compliance.js +42 -61
  170. package/dist/routes/compliance.js.map +1 -1
  171. package/dist/routes/conversations.d.ts +8 -1
  172. package/dist/routes/conversations.d.ts.map +1 -1
  173. package/dist/routes/conversations.js +87 -8
  174. package/dist/routes/conversations.js.map +1 -1
  175. package/dist/routes/cost.d.ts +12 -1
  176. package/dist/routes/cost.d.ts.map +1 -1
  177. package/dist/routes/cost.js +74 -3
  178. package/dist/routes/cost.js.map +1 -1
  179. package/dist/routes/denied.d.ts +11 -0
  180. package/dist/routes/denied.d.ts.map +1 -0
  181. package/dist/routes/denied.js +17 -0
  182. package/dist/routes/denied.js.map +1 -0
  183. package/dist/routes/deployments.d.ts +10 -1
  184. package/dist/routes/deployments.d.ts.map +1 -1
  185. package/dist/routes/deployments.js +171 -13
  186. package/dist/routes/deployments.js.map +1 -1
  187. package/dist/routes/eval-comparison.d.ts.map +1 -1
  188. package/dist/routes/eval-comparison.js +69 -1
  189. package/dist/routes/eval-comparison.js.map +1 -1
  190. package/dist/routes/eval-overrides.d.ts +18 -0
  191. package/dist/routes/eval-overrides.d.ts.map +1 -0
  192. package/dist/routes/eval-overrides.js +81 -0
  193. package/dist/routes/eval-overrides.js.map +1 -0
  194. package/dist/routes/eval-runs.d.ts +10 -1
  195. package/dist/routes/eval-runs.d.ts.map +1 -1
  196. package/dist/routes/eval-runs.js +66 -7
  197. package/dist/routes/eval-runs.js.map +1 -1
  198. package/dist/routes/eval-suites.d.ts.map +1 -1
  199. package/dist/routes/eval-suites.js +28 -2
  200. package/dist/routes/eval-suites.js.map +1 -1
  201. package/dist/routes/event-triggers.d.ts +5 -1
  202. package/dist/routes/event-triggers.d.ts.map +1 -1
  203. package/dist/routes/event-triggers.js +26 -3
  204. package/dist/routes/event-triggers.js.map +1 -1
  205. package/dist/routes/export-signing-keys.d.ts +12 -0
  206. package/dist/routes/export-signing-keys.d.ts.map +1 -0
  207. package/dist/routes/export-signing-keys.js +24 -0
  208. package/dist/routes/export-signing-keys.js.map +1 -0
  209. package/dist/routes/flows.d.ts.map +1 -1
  210. package/dist/routes/flows.js +9 -1
  211. package/dist/routes/flows.js.map +1 -1
  212. package/dist/routes/gate-policies.d.ts +4 -1
  213. package/dist/routes/gate-policies.d.ts.map +1 -1
  214. package/dist/routes/gate-policies.js +29 -5
  215. package/dist/routes/gate-policies.js.map +1 -1
  216. package/dist/routes/guardrails.d.ts +16 -14
  217. package/dist/routes/guardrails.d.ts.map +1 -1
  218. package/dist/routes/guardrails.js +39 -3
  219. package/dist/routes/guardrails.js.map +1 -1
  220. package/dist/routes/identity.d.ts +20 -4
  221. package/dist/routes/identity.d.ts.map +1 -1
  222. package/dist/routes/identity.js +246 -6
  223. package/dist/routes/identity.js.map +1 -1
  224. package/dist/routes/improvement-passes.d.ts +52 -0
  225. package/dist/routes/improvement-passes.d.ts.map +1 -0
  226. package/dist/routes/improvement-passes.js +449 -0
  227. package/dist/routes/improvement-passes.js.map +1 -0
  228. package/dist/routes/judged-suites.d.ts +50 -0
  229. package/dist/routes/judged-suites.d.ts.map +1 -1
  230. package/dist/routes/judged-suites.js +66 -27
  231. package/dist/routes/judged-suites.js.map +1 -1
  232. package/dist/routes/judgment-context.d.ts +18 -2
  233. package/dist/routes/judgment-context.d.ts.map +1 -1
  234. package/dist/routes/judgment-context.js +63 -5
  235. package/dist/routes/judgment-context.js.map +1 -1
  236. package/dist/routes/judgment-flow-context.d.ts.map +1 -1
  237. package/dist/routes/judgment-flow-context.js +14 -2
  238. package/dist/routes/judgment-flow-context.js.map +1 -1
  239. package/dist/routes/judgments.d.ts.map +1 -1
  240. package/dist/routes/judgments.js +8 -1
  241. package/dist/routes/judgments.js.map +1 -1
  242. package/dist/routes/mcp.d.ts.map +1 -1
  243. package/dist/routes/mcp.js +26 -1
  244. package/dist/routes/mcp.js.map +1 -1
  245. package/dist/routes/memory-access.d.ts +43 -0
  246. package/dist/routes/memory-access.d.ts.map +1 -0
  247. package/dist/routes/memory-access.js +114 -0
  248. package/dist/routes/memory-access.js.map +1 -0
  249. package/dist/routes/memory-erasures.d.ts +25 -0
  250. package/dist/routes/memory-erasures.d.ts.map +1 -0
  251. package/dist/routes/memory-erasures.js +214 -0
  252. package/dist/routes/memory-erasures.js.map +1 -0
  253. package/dist/routes/memory-parse.d.ts +38 -0
  254. package/dist/routes/memory-parse.d.ts.map +1 -0
  255. package/dist/routes/memory-parse.js +199 -0
  256. package/dist/routes/memory-parse.js.map +1 -0
  257. package/dist/routes/memory.d.ts +9 -4
  258. package/dist/routes/memory.d.ts.map +1 -1
  259. package/dist/routes/memory.js +226 -234
  260. package/dist/routes/memory.js.map +1 -1
  261. package/dist/routes/observations.d.ts +4 -1
  262. package/dist/routes/observations.d.ts.map +1 -1
  263. package/dist/routes/observations.js +8 -2
  264. package/dist/routes/observations.js.map +1 -1
  265. package/dist/routes/pagination.d.ts +7 -0
  266. package/dist/routes/pagination.d.ts.map +1 -1
  267. package/dist/routes/pagination.js +10 -0
  268. package/dist/routes/pagination.js.map +1 -1
  269. package/dist/routes/policies.d.ts +2 -1
  270. package/dist/routes/policies.d.ts.map +1 -1
  271. package/dist/routes/policies.js +3 -1
  272. package/dist/routes/policies.js.map +1 -1
  273. package/dist/routes/project-mismatch.d.ts +22 -0
  274. package/dist/routes/project-mismatch.d.ts.map +1 -0
  275. package/dist/routes/project-mismatch.js +34 -0
  276. package/dist/routes/project-mismatch.js.map +1 -0
  277. package/dist/routes/projects.d.ts +15 -4
  278. package/dist/routes/projects.d.ts.map +1 -1
  279. package/dist/routes/projects.js +100 -9
  280. package/dist/routes/projects.js.map +1 -1
  281. package/dist/routes/proposals.d.ts +25 -17
  282. package/dist/routes/proposals.d.ts.map +1 -1
  283. package/dist/routes/proposals.js +340 -507
  284. package/dist/routes/proposals.js.map +1 -1
  285. package/dist/routes/provenance.d.ts +17 -3
  286. package/dist/routes/provenance.d.ts.map +1 -1
  287. package/dist/routes/provenance.js +79 -103
  288. package/dist/routes/provenance.js.map +1 -1
  289. package/dist/routes/providers.d.ts +17 -1
  290. package/dist/routes/providers.d.ts.map +1 -1
  291. package/dist/routes/providers.js +110 -3
  292. package/dist/routes/providers.js.map +1 -1
  293. package/dist/routes/public-run-tokens.d.ts.map +1 -1
  294. package/dist/routes/public-run-tokens.js +3 -0
  295. package/dist/routes/public-run-tokens.js.map +1 -1
  296. package/dist/routes/readable-projects.d.ts +26 -0
  297. package/dist/routes/readable-projects.d.ts.map +1 -0
  298. package/dist/routes/readable-projects.js +39 -0
  299. package/dist/routes/readable-projects.js.map +1 -0
  300. package/dist/routes/runs.d.ts +10 -0
  301. package/dist/routes/runs.d.ts.map +1 -1
  302. package/dist/routes/runs.js +92 -42
  303. package/dist/routes/runs.js.map +1 -1
  304. package/dist/routes/schedules.d.ts +21 -13
  305. package/dist/routes/schedules.d.ts.map +1 -1
  306. package/dist/routes/schedules.js +416 -55
  307. package/dist/routes/schedules.js.map +1 -1
  308. package/dist/routes/segments.d.ts +2 -0
  309. package/dist/routes/segments.d.ts.map +1 -1
  310. package/dist/routes/segments.js +5 -0
  311. package/dist/routes/segments.js.map +1 -1
  312. package/dist/routes/service-accounts.d.ts +17 -0
  313. package/dist/routes/service-accounts.d.ts.map +1 -0
  314. package/dist/routes/service-accounts.js +212 -0
  315. package/dist/routes/service-accounts.js.map +1 -0
  316. package/dist/routes/sign-in-options.d.ts +50 -0
  317. package/dist/routes/sign-in-options.d.ts.map +1 -0
  318. package/dist/routes/sign-in-options.js +98 -0
  319. package/dist/routes/sign-in-options.js.map +1 -0
  320. package/dist/routes/signing-keys.d.ts +2 -1
  321. package/dist/routes/signing-keys.d.ts.map +1 -1
  322. package/dist/routes/signing-keys.js +3 -1
  323. package/dist/routes/signing-keys.js.map +1 -1
  324. package/dist/routes/tenant-access.d.ts +13 -0
  325. package/dist/routes/tenant-access.d.ts.map +1 -0
  326. package/dist/routes/tenant-access.js +26 -0
  327. package/dist/routes/tenant-access.js.map +1 -0
  328. package/dist/routes/tenant.d.ts.map +1 -1
  329. package/dist/routes/tenant.js +4 -0
  330. package/dist/routes/tenant.js.map +1 -1
  331. package/dist/routes/token-sign-in.d.ts +36 -0
  332. package/dist/routes/token-sign-in.d.ts.map +1 -0
  333. package/dist/routes/token-sign-in.js +101 -0
  334. package/dist/routes/token-sign-in.js.map +1 -0
  335. package/dist/routes/tokens.d.ts +15 -5
  336. package/dist/routes/tokens.d.ts.map +1 -1
  337. package/dist/routes/tokens.js +162 -43
  338. package/dist/routes/tokens.js.map +1 -1
  339. package/dist/routes/tools.d.ts.map +1 -1
  340. package/dist/routes/tools.js +9 -1
  341. package/dist/routes/tools.js.map +1 -1
  342. package/dist/routes/trigger-access.d.ts +29 -0
  343. package/dist/routes/trigger-access.d.ts.map +1 -0
  344. package/dist/routes/trigger-access.js +33 -0
  345. package/dist/routes/trigger-access.js.map +1 -0
  346. package/dist/routes/webhook-endpoints.d.ts +2 -1
  347. package/dist/routes/webhook-endpoints.d.ts.map +1 -1
  348. package/dist/routes/webhook-endpoints.js +11 -3
  349. package/dist/routes/webhook-endpoints.js.map +1 -1
  350. package/dist/routes/webhooks.d.ts +5 -1
  351. package/dist/routes/webhooks.d.ts.map +1 -1
  352. package/dist/routes/webhooks.js +25 -2
  353. package/dist/routes/webhooks.js.map +1 -1
  354. package/dist/run-failure.d.ts +21 -0
  355. package/dist/run-failure.d.ts.map +1 -0
  356. package/dist/run-failure.js +29 -0
  357. package/dist/run-failure.js.map +1 -0
  358. package/dist/service-account-binding.d.ts +108 -0
  359. package/dist/service-account-binding.d.ts.map +1 -0
  360. package/dist/service-account-binding.js +4 -0
  361. package/dist/service-account-binding.js.map +1 -0
  362. package/dist/session-store-binding.d.ts +61 -13
  363. package/dist/session-store-binding.d.ts.map +1 -1
  364. package/dist/signed-export.d.ts +89 -0
  365. package/dist/signed-export.d.ts.map +1 -0
  366. package/dist/signed-export.js +149 -0
  367. package/dist/signed-export.js.map +1 -0
  368. package/dist/supervisor-binding.d.ts +186 -413
  369. package/dist/supervisor-binding.d.ts.map +1 -1
  370. package/dist/testing/app-bindings.d.ts +33 -0
  371. package/dist/testing/app-bindings.d.ts.map +1 -0
  372. package/dist/testing/app-bindings.js +112 -0
  373. package/dist/testing/app-bindings.js.map +1 -0
  374. package/dist/testing/index.d.ts +11 -0
  375. package/dist/testing/index.d.ts.map +1 -0
  376. package/dist/testing/index.js +13 -0
  377. package/dist/testing/index.js.map +1 -0
  378. package/dist/testing/stub-binding.d.ts +34 -0
  379. package/dist/testing/stub-binding.d.ts.map +1 -0
  380. package/dist/testing/stub-binding.js +42 -0
  381. package/dist/testing/stub-binding.js.map +1 -0
  382. package/dist/testing/trigger-registry.d.ts +21 -0
  383. package/dist/testing/trigger-registry.d.ts.map +1 -0
  384. package/dist/testing/trigger-registry.js +206 -0
  385. package/dist/testing/trigger-registry.js.map +1 -0
  386. package/dist/token-admin.d.ts +46 -8
  387. package/dist/token-admin.d.ts.map +1 -1
  388. package/dist/token-admin.js.map +1 -1
  389. package/dist/tool-binding.d.ts +13 -0
  390. package/dist/tool-binding.d.ts.map +1 -1
  391. package/dist/trigger-binding.d.ts +2 -2
  392. package/dist/trigger-binding.d.ts.map +1 -1
  393. package/dist/trigger-binding.js +1 -1
  394. package/dist/trigger-binding.js.map +1 -1
  395. package/dist/types.d.ts +16 -0
  396. package/dist/types.d.ts.map +1 -1
  397. package/dist/webhook-endpoint-binding.d.ts +19 -3
  398. package/dist/webhook-endpoint-binding.d.ts.map +1 -1
  399. package/dist/webhook-endpoint-binding.js +1 -1
  400. package/dist/webhook-endpoint-binding.js.map +1 -1
  401. package/openapi.json +15387 -8789
  402. package/package.json +26 -22
  403. package/src/agent-binding.ts +14 -0
  404. package/src/agent-pins.ts +18 -2
  405. package/src/app.ts +366 -80
  406. package/src/block-publish.ts +181 -0
  407. package/src/caller.ts +62 -0
  408. package/src/capability-binding.ts +12 -0
  409. package/src/cost-binding.ts +19 -0
  410. package/src/derive-agent-version.ts +9 -1
  411. package/src/errors.ts +75 -7
  412. package/src/eval-case-binding.ts +17 -1
  413. package/src/eval-run-binding.ts +31 -0
  414. package/src/eval-run-dispatcher.ts +7 -0
  415. package/src/eval-sample.ts +42 -0
  416. package/src/eval-suite-binding.ts +14 -0
  417. package/src/flow-binding.ts +19 -0
  418. package/src/flow-pins.ts +18 -2
  419. package/src/gate.ts +26 -0
  420. package/src/handler-binding.ts +36 -1
  421. package/src/hitl-binding.ts +24 -0
  422. package/src/identity-directory-binding.ts +85 -4
  423. package/src/identity-provider-binding.ts +216 -21
  424. package/src/improvement-pass-binding.ts +193 -0
  425. package/src/index.ts +153 -31
  426. package/src/judged-dispatcher.ts +78 -11
  427. package/src/judgment-binding.ts +25 -1
  428. package/src/mcp-endpoint-binding.ts +7 -0
  429. package/src/memory-binding.ts +121 -17
  430. package/src/memory-erasure-binding.ts +156 -0
  431. package/src/middleware/auth.ts +228 -62
  432. package/src/middleware/authorize.ts +155 -3
  433. package/src/middleware/error-mapper.ts +15 -1
  434. package/src/middleware/idempotency.ts +230 -43
  435. package/src/middleware/key-project.ts +86 -0
  436. package/src/middleware/principal.ts +9 -5
  437. package/src/middleware/project-ref.ts +3 -0
  438. package/src/openapi/generate.ts +11 -2
  439. package/src/openapi/operations.ts +1060 -143
  440. package/src/openapi/schemas.ts +2387 -469
  441. package/src/person-grants-binding.ts +76 -0
  442. package/src/proposal-service.ts +640 -0
  443. package/src/proposal-status.ts +176 -0
  444. package/src/provider-binding.ts +10 -0
  445. package/src/publish-refused.ts +56 -9
  446. package/src/routes/adapters.ts +4 -0
  447. package/src/routes/agent-releases.ts +121 -69
  448. package/src/routes/agents.ts +128 -1
  449. package/src/routes/approvals.ts +164 -154
  450. package/src/routes/artifacts.ts +181 -11
  451. package/src/routes/auth.ts +804 -336
  452. package/src/routes/blocks.ts +2 -53
  453. package/src/routes/capabilities.ts +10 -1
  454. package/src/routes/compliance.ts +60 -99
  455. package/src/routes/conversations.ts +101 -7
  456. package/src/routes/cost.ts +110 -4
  457. package/src/routes/denied.ts +28 -0
  458. package/src/routes/deployments.ts +210 -17
  459. package/src/routes/eval-comparison.ts +81 -2
  460. package/src/routes/eval-overrides.ts +108 -0
  461. package/src/routes/eval-runs.ts +89 -6
  462. package/src/routes/eval-suites.ts +32 -2
  463. package/src/routes/event-triggers.ts +27 -3
  464. package/src/routes/export-signing-keys.ts +31 -0
  465. package/src/routes/flows.ts +12 -1
  466. package/src/routes/gate-policies.ts +37 -6
  467. package/src/routes/guardrails.ts +61 -2
  468. package/src/routes/identity.ts +328 -10
  469. package/src/routes/improvement-passes.ts +541 -0
  470. package/src/routes/judged-suites.ts +113 -43
  471. package/src/routes/judgment-context.ts +76 -5
  472. package/src/routes/judgment-flow-context.ts +16 -2
  473. package/src/routes/judgments.ts +17 -3
  474. package/src/routes/mcp.ts +29 -1
  475. package/src/routes/memory-access.ts +160 -0
  476. package/src/routes/memory-erasures.ts +240 -0
  477. package/src/routes/memory-parse.ts +250 -0
  478. package/src/routes/memory.ts +244 -286
  479. package/src/routes/observations.ts +15 -2
  480. package/src/routes/pagination.ts +12 -0
  481. package/src/routes/policies.ts +7 -1
  482. package/src/routes/project-mismatch.ts +56 -0
  483. package/src/routes/projects.ts +107 -13
  484. package/src/routes/proposals.ts +370 -611
  485. package/src/routes/provenance.ts +99 -133
  486. package/src/routes/providers.ts +142 -3
  487. package/src/routes/public-run-tokens.ts +3 -0
  488. package/src/routes/readable-projects.ts +66 -0
  489. package/src/routes/runs.ts +119 -39
  490. package/src/routes/schedules.ts +472 -60
  491. package/src/routes/segments.ts +11 -0
  492. package/src/routes/service-accounts.ts +262 -0
  493. package/src/routes/sign-in-options.ts +168 -0
  494. package/src/routes/signing-keys.ts +7 -1
  495. package/src/routes/tenant-access.ts +37 -0
  496. package/src/routes/tenant.ts +6 -0
  497. package/src/routes/token-sign-in.ts +161 -0
  498. package/src/routes/tokens.ts +172 -46
  499. package/src/routes/tools.ts +12 -1
  500. package/src/routes/trigger-access.ts +72 -0
  501. package/src/routes/webhook-endpoints.ts +15 -3
  502. package/src/routes/webhooks.ts +26 -2
  503. package/src/run-failure.ts +42 -0
  504. package/src/service-account-binding.ts +113 -0
  505. package/src/session-store-binding.ts +65 -13
  506. package/src/signed-export.ts +250 -0
  507. package/src/supervisor-binding.ts +169 -409
  508. package/src/testing/app-bindings.ts +142 -0
  509. package/src/testing/index.ts +21 -0
  510. package/src/testing/stub-binding.ts +53 -0
  511. package/src/testing/trigger-registry.ts +259 -0
  512. package/src/token-admin.ts +40 -8
  513. package/src/tool-binding.ts +14 -0
  514. package/src/trigger-binding.ts +8 -1
  515. package/src/types.ts +16 -0
  516. package/src/webhook-endpoint-binding.ts +18 -3
@@ -4,7 +4,7 @@
4
4
  import { type Context, Hono } from 'hono';
5
5
 
6
6
  import { type Principal, ref, tuplesForCreate } from '@kindgi/authz';
7
- import type { Cursor, ProjectId, TenantId, UserId } from '@kindgi/types';
7
+ import type { Cursor, ProjectId, ScopeSegment, TenantId, UserId } from '@kindgi/types';
8
8
 
9
9
  import { statusFor, toWireError } from '../errors.js';
10
10
  import type {
@@ -22,6 +22,8 @@ import type {
22
22
  import type { Authorizer } from '../middleware/authorize.js';
23
23
  import type { AppEnv } from '../types.js';
24
24
  import { clampLimit } from './pagination.js';
25
+ import { projectMismatch } from './project-mismatch.js';
26
+ import { parseSegmentsBody } from './segments.js';
25
27
 
26
28
  /** The most cases a test set built from judgments holds. */
27
29
  export const MAX_JUDGED_CASES = 1000;
@@ -66,35 +68,13 @@ export function judgedSuitesRouter(
66
68
  );
67
69
  }
68
70
 
69
- const built = await buildCases(judgments, tenantId, body);
70
71
  const principal = c.get('principal') as Principal | undefined;
71
72
  const creatorUserId =
72
73
  principal?.actor.kind === 'user' ? (principal.actor.id as UserId) : undefined;
73
- const outcome = await suites.publish({
74
- tenantId,
75
- projectId: body.projectId,
76
- suite: {
77
- id: suiteId,
78
- tenantId,
79
- version: body.version,
80
- kind: 'judged',
81
- ...(body.description !== undefined && { description: body.description }),
82
- spec: {
83
- source: 'judgments',
84
- // Where the judgments came from: a comparison's summary names it.
85
- projectId: body.projectId,
86
- query: body.query,
87
- caseCount: built.cases.length,
88
- truncated: built.truncated,
89
- builtAt: new Date().toISOString(),
90
- },
91
- },
92
- enqueueTuples: (id) =>
93
- tuplesForCreate(
94
- { kind: 'eval_suite', id, tenantId, projectId: body.projectId },
95
- creatorUserId,
96
- ),
97
- });
74
+ const outcome = await buildJudgedSuite(
75
+ { suites, judgments, cases },
76
+ { tenantId, suiteId, ...body, ...(creatorUserId !== undefined && { creatorUserId }) },
77
+ );
98
78
  if (outcome.kind === 'already-registered') {
99
79
  return fail(
100
80
  c,
@@ -105,14 +85,16 @@ export function judgedSuitesRouter(
105
85
  if (outcome.kind === 'project-not-found') {
106
86
  return fail(c, 'bad-input', `\`projectId\` "${body.projectId}" is not a project here.`);
107
87
  }
108
- await cases.putCases({ tenantId, suiteId, version: body.version, cases: built.cases });
88
+ if (outcome.kind === 'project-mismatch') {
89
+ return projectMismatch(c, 'eval-suite', suiteId, outcome.projectId, 'build');
90
+ }
109
91
  c.status(201);
110
92
  return c.json({
111
93
  suiteId,
112
94
  version: body.version,
113
95
  kind: 'judged',
114
- caseCount: built.cases.length,
115
- truncated: built.truncated,
96
+ caseCount: outcome.caseCount,
97
+ truncated: outcome.truncated,
116
98
  });
117
99
  });
118
100
 
@@ -144,6 +126,87 @@ export function judgedSuitesRouter(
144
126
  return r;
145
127
  }
146
128
 
129
+ /** Which judged runs a test set is built from, and which of their judgments count. */
130
+ export interface JudgedSuiteQuery {
131
+ readonly agentId?: string;
132
+ readonly agentVersion?: string;
133
+ readonly flowId?: string;
134
+ readonly since?: string;
135
+ readonly until?: string;
136
+ readonly judgeClassIds?: readonly string[];
137
+ readonly minJudgments?: number;
138
+ /** Only runs started in this segment path or below it. */
139
+ readonly segments?: readonly ScopeSegment[];
140
+ }
141
+
142
+ export interface BuildJudgedSuiteInput {
143
+ readonly tenantId: TenantId;
144
+ readonly suiteId: string;
145
+ readonly version: string;
146
+ /** The project whose judged runs it takes, and the suite's project. */
147
+ readonly projectId: ProjectId;
148
+ readonly description?: string;
149
+ readonly query: JudgedSuiteQuery;
150
+ /** The user who built it, made the suite's creator. */
151
+ readonly creatorUserId?: UserId;
152
+ }
153
+
154
+ export type BuildJudgedSuiteOutcome =
155
+ | { readonly kind: 'ok'; readonly caseCount: number; readonly truncated: boolean }
156
+ | { readonly kind: 'already-registered' }
157
+ | { readonly kind: 'project-not-found' }
158
+ /** The suite belongs to another project: nothing is written. */
159
+ | { readonly kind: 'project-mismatch'; readonly projectId: ProjectId };
160
+
161
+ /**
162
+ * Build a test set and publish it as a `judged` suite version, as
163
+ * `POST /v1/eval-suites/{suiteId}/versions/from-judgments` does: the
164
+ * judged runs the query picks (newest first, at most `MAX_JUDGED_CASES`),
165
+ * each a case with its items' judgments summed up. The binding must list
166
+ * judged runs (`listJudgedRuns`).
167
+ */
168
+ export async function buildJudgedSuite(
169
+ deps: {
170
+ readonly suites: EvalSuiteRegistryBinding;
171
+ readonly judgments: JudgmentRegistryBinding;
172
+ readonly cases: EvalCaseStoreBinding;
173
+ },
174
+ input: BuildJudgedSuiteInput,
175
+ ): Promise<BuildJudgedSuiteOutcome> {
176
+ const { tenantId, suiteId, version, projectId } = input;
177
+ const built = await buildCases(deps.judgments, tenantId, input);
178
+ const outcome = await deps.suites.publish({
179
+ tenantId,
180
+ projectId,
181
+ suite: {
182
+ id: suiteId,
183
+ tenantId,
184
+ version,
185
+ kind: 'judged',
186
+ ...(input.description !== undefined && { description: input.description }),
187
+ spec: {
188
+ source: 'judgments',
189
+ // Where the judgments came from: a comparison's summary names it.
190
+ projectId,
191
+ query: input.query,
192
+ caseCount: built.cases.length,
193
+ truncated: built.truncated,
194
+ builtAt: new Date().toISOString(),
195
+ },
196
+ },
197
+ enqueueTuples: (id) =>
198
+ tuplesForCreate({ kind: 'eval_suite', id, tenantId, projectId }, input.creatorUserId),
199
+ });
200
+ if (outcome.kind === 'already-registered' || outcome.kind === 'project-not-found') {
201
+ return { kind: outcome.kind };
202
+ }
203
+ if (outcome.kind === 'project-mismatch') {
204
+ return { kind: 'project-mismatch', projectId: outcome.projectId };
205
+ }
206
+ await deps.cases.putCases({ tenantId, suiteId, version, cases: built.cases });
207
+ return { kind: 'ok', caseCount: built.cases.length, truncated: built.truncated };
208
+ }
209
+
147
210
  function fail(c: Context<AppEnv>, code: string, message: string): Response {
148
211
  c.status(statusFor(code) as never);
149
212
  return c.json(toWireError({ code, message }, c.get('requestId')));
@@ -156,15 +219,7 @@ interface BuildBody {
156
219
  readonly projectId: ProjectId;
157
220
  readonly description?: string;
158
221
  /** The judged-run filter, as recorded in the suite's spec. */
159
- readonly query: {
160
- readonly agentId?: string;
161
- readonly agentVersion?: string;
162
- readonly flowId?: string;
163
- readonly since?: string;
164
- readonly until?: string;
165
- readonly judgeClassIds?: readonly string[];
166
- readonly minJudgments?: number;
167
- };
222
+ readonly query: JudgedSuiteQuery;
168
223
  }
169
224
 
170
225
  /** Each class's weight, read once (an unclassified judgment counts 1; a missing class too). */
@@ -186,7 +241,7 @@ function classWeights(
186
241
 
187
242
  function judgedRunFilter(
188
243
  tenantId: TenantId,
189
- body: BuildBody,
244
+ body: Pick<BuildBody, 'projectId' | 'query'>,
190
245
  ): Omit<JudgedRunListInput, 'limit' | 'cursor'> {
191
246
  const { judgeClassIds: _ids, minJudgments: _min, ...runFilter } = body.query;
192
247
  return { tenantId, projectId: body.projectId, ...runFilter };
@@ -196,7 +251,7 @@ function judgedRunFilter(
196
251
  async function buildCases(
197
252
  judgments: JudgmentRegistryBinding,
198
253
  tenantId: TenantId,
199
- body: BuildBody,
254
+ body: Pick<BuildBody, 'projectId' | 'query'>,
200
255
  ): Promise<{ readonly cases: JudgedEvalCase[]; readonly truncated: boolean }> {
201
256
  const list = judgments.listJudgedRuns as NonNullable<JudgmentRegistryBinding['listJudgedRuns']>;
202
257
  const weightOf = classWeights(judgments, tenantId);
@@ -277,7 +332,16 @@ async function summarize(
277
332
  totalWeight,
278
333
  restricted,
279
334
  reasons: judgments.flatMap((j) =>
280
- j.reason !== undefined ? [{ verdict: j.verdict, reason: j.reason }] : [],
335
+ j.reason !== undefined
336
+ ? [
337
+ {
338
+ verdict: j.verdict,
339
+ reason: j.reason,
340
+ ...(j.judgeClassId !== undefined && { judgeClassId: j.judgeClassId }),
341
+ ...(j.restricted === true && { restricted: true as const }),
342
+ },
343
+ ]
344
+ : [],
281
345
  ),
282
346
  };
283
347
  }
@@ -335,7 +399,13 @@ function parseQuery(b: Record<string, unknown>): BuildBody['query'] | string {
335
399
  if (typeof strings === 'string') return strings;
336
400
  const counted = parseJudgmentFilters(b);
337
401
  if (typeof counted === 'string') return counted;
338
- return { ...strings, ...counted };
402
+ const segments = parseSegmentsBody(b.segments);
403
+ if (segments.kind === 'err') return segments.message;
404
+ return {
405
+ ...strings,
406
+ ...counted,
407
+ ...(segments.segments !== undefined && { segments: segments.segments }),
408
+ };
339
409
  }
340
410
 
341
411
  function parseBuildBody(raw: unknown): Parsed<BuildBody> {
@@ -8,6 +8,7 @@ import {
8
8
  readGateDecision,
9
9
  } from '@kindgi/agents';
10
10
  import type { JournalEntry, RunBinding } from '@kindgi/runtime';
11
+ import { TOOL_ENV_RECORD_KEY, toolCallRecordKey } from '@kindgi/tools';
11
12
  import type { ConversationId, RunId, TenantId } from '@kindgi/types';
12
13
 
13
14
  import type { JudgedRunContext } from '../judgment-binding.js';
@@ -53,28 +54,97 @@ async function readHistory(
53
54
  };
54
55
  }
55
56
 
56
- type JournalParts = Pick<JudgedRunContext, 'retrieved' | 'sessionApproval'>;
57
+ type JournalParts = Pick<
58
+ JudgedRunContext,
59
+ 'retrieved' | 'recalled' | 'sessionApproval' | 'toolEnv'
60
+ >;
57
61
 
58
- /** What the turn's journal says it retrieved, and how its session approval was decided. */
62
+ /** A record's value when it's env values: an object whose values are strings. */
63
+ function envValues(value: unknown): Readonly<Record<string, string>> | undefined {
64
+ const o = obj(value);
65
+ if (o === undefined) return undefined;
66
+ return Object.values(o).every((v) => typeof v === 'string')
67
+ ? (o as Record<string, string>)
68
+ : undefined;
69
+ }
70
+
71
+ /**
72
+ * The env values each tool's calls were sent, by tool id, from a run's
73
+ * journal, added to `into`: for each call given (an agent turn's, with its
74
+ * call id; a flow's tool step, without), its recorded env
75
+ * (`toolCallRecordKey(…, TOOL_ENV_RECORD_KEY)`). A tool's first call wins.
76
+ */
77
+ export function addToolEnv(
78
+ entries: readonly JournalEntry[],
79
+ calls: readonly { readonly toolId: string; readonly callId?: string }[],
80
+ into: Record<string, Readonly<Record<string, string>>>,
81
+ ): void {
82
+ const recorded = new Map<string, unknown>();
83
+ for (const e of entries) {
84
+ const payload = obj(e.payload);
85
+ const key = payload?.key;
86
+ if (e.kind === 'value.recorded' && typeof key === 'string' && !recorded.has(key)) {
87
+ recorded.set(key, payload?.value);
88
+ }
89
+ }
90
+ for (const call of calls) {
91
+ if (into[call.toolId] !== undefined) continue;
92
+ const env = envValues(
93
+ recorded.get(
94
+ toolCallRecordKey({
95
+ toolId: call.toolId,
96
+ key: TOOL_ENV_RECORD_KEY,
97
+ ...(call.callId !== undefined && { callId: call.callId }),
98
+ }),
99
+ ),
100
+ );
101
+ if (env !== undefined) into[call.toolId] = env;
102
+ }
103
+ }
104
+
105
+ /** An agent turn's tool calls, from its output: each `tool` message's tool and call id. */
106
+ export function turnCallIds(
107
+ output: unknown,
108
+ ): readonly { readonly toolId: string; readonly callId: string }[] {
109
+ const appended = obj(output)?.appended;
110
+ if (!Array.isArray(appended)) return [];
111
+ return appended.flatMap((m) => {
112
+ const toolCall = obj(obj(m)?.toolCall);
113
+ const toolId = toolCall?.toolId;
114
+ const callId = toolCall?.invocationId;
115
+ return obj(m)?.role === 'tool' && typeof toolId === 'string' && typeof callId === 'string'
116
+ ? [{ toolId, callId }]
117
+ : [];
118
+ });
119
+ }
120
+
121
+ /** What the turn's journal says it retrieved and recalled, and how its session approval was decided. */
59
122
  async function readJournalParts(
60
123
  runBinding: RunBinding,
61
124
  tenantId: TenantId,
62
125
  runId: string,
126
+ output: unknown,
63
127
  ): Promise<JournalParts> {
64
128
  const journal = await runBinding.readJournal(tenantId, runId as RunId);
65
129
  if (journal.kind === 'err') return {};
66
130
  const entries = journal.value;
131
+ const toolEnv: Record<string, Readonly<Record<string, string>>> = {};
132
+ addToolEnv(entries, turnCallIds(output), toolEnv);
67
133
  const step = entries.find(
68
134
  (e) =>
69
135
  e.kind === 'step.completed' &&
70
136
  typeof e.nodeId === 'string' &&
71
137
  (e.nodeId === RUN_RETRIEVALS_NODE || e.nodeId.endsWith(`/${RUN_RETRIEVALS_NODE}`)),
72
138
  );
73
- const retrieved = obj(obj(step?.payload)?.output)?.retrieved;
139
+ const stepOutput = obj(obj(step?.payload)?.output);
140
+ const retrieved = stepOutput?.retrieved;
141
+ const recalled = stepOutput?.recalled;
74
142
  const sessionApproval = sessionApprovalOf(entries);
75
143
  return {
76
144
  ...(retrieved !== undefined && { retrieved }),
145
+ ...(recalled !== undefined && { recalled }),
77
146
  ...(sessionApproval !== undefined && { sessionApproval }),
147
+ ...(Object.keys(toolEnv).length > 0 && { toolEnv }),
78
148
  };
79
149
  }
80
150
 
@@ -102,7 +172,8 @@ function sessionApprovalOf(
102
172
  /**
103
173
  * What a judged agent turn read besides its input, so it can be replayed
104
174
  * faithfully later: the conversation before the turn, what its
105
- * retrievals returned, and the decision at its session approval gate. Best effort and read-only: a part that can't be
175
+ * retrievals returned, the decision at its session approval gate, and the
176
+ * env values its tools were sent. Best effort and read-only: a part that can't be
106
177
  * read is left out (the judgment never fails over it). `undefined` for
107
178
  * a flow run, or when nothing could be read.
108
179
  */
@@ -121,7 +192,7 @@ export async function captureTurnContext(input: {
121
192
  () => ({}),
122
193
  )
123
194
  : Promise.resolve({}),
124
- readJournalParts(input.runBinding, input.tenantId, input.runId).catch(() => ({})),
195
+ readJournalParts(input.runBinding, input.tenantId, input.runId, input.output).catch(() => ({})),
125
196
  ]);
126
197
  const context: JudgedRunContext = { ...history, ...journal };
127
198
  return Object.keys(context).length > 0 ? context : undefined;
@@ -22,6 +22,7 @@ import type {
22
22
  JudgedRunContext,
23
23
  JudgedToolCall,
24
24
  } from '../judgment-binding.js';
25
+ import { addToolEnv, turnCallIds } from './judgment-context.js';
25
26
 
26
27
  /** The most tool calls a judged flow run keeps. */
27
28
  export const MAX_JUDGED_FLOW_CALLS = 500;
@@ -94,6 +95,8 @@ function scopeOf(loopContext: unknown): string | undefined {
94
95
  class Collector {
95
96
  readonly calls: JudgedToolCall[] = [];
96
97
  readonly steps: JudgedFlowStep[] = [];
98
+ /** The env values each tool's calls were sent, by tool id (`JudgedRunContext.toolEnv`). */
99
+ readonly toolEnv: Record<string, Readonly<Record<string, string>>> = {};
97
100
  truncated = false;
98
101
 
99
102
  add(call: JudgedToolCall): void {
@@ -127,6 +130,11 @@ async function nodeCalls(
127
130
  ]);
128
131
  const tools = toolNodes(flow);
129
132
  if (journal.kind === 'err' || tools.size === 0) return;
133
+ addToolEnv(
134
+ journal.value,
135
+ [...new Set(tools.values())].map((toolId) => ({ toolId })),
136
+ c.toolEnv,
137
+ );
130
138
  const inputs = new Map<string, unknown>();
131
139
  for (const e of journal.value) {
132
140
  if (typeof e.nodeId !== 'string' || !tools.has(e.nodeId)) continue;
@@ -147,7 +155,7 @@ async function nodeCalls(
147
155
  }
148
156
  }
149
157
 
150
- /** An agent step's turn: its calls, and what it retrieved. */
158
+ /** An agent step's turn: its calls, and what it retrieved and recalled. */
151
159
  async function stepTurn(r: Reader, c: Collector, child: KernelRunRecord): Promise<void> {
152
160
  const agent = child.agent;
153
161
  if (agent === undefined) return;
@@ -156,6 +164,7 @@ async function stepTurn(r: Reader, c: Collector, child: KernelRunRecord): Promis
156
164
  const nodeId = (child.parentNodeId as unknown as string | null | undefined) ?? undefined;
157
165
  const scope = child.parentScope ?? undefined;
158
166
  const retrieved = obj(output)?.retrieved;
167
+ const recalled = obj(output)?.recalled;
159
168
  c.steps.push({
160
169
  runId: child.runId as unknown as string,
161
170
  ...(nodeId !== undefined && { nodeId }),
@@ -163,6 +172,7 @@ async function stepTurn(r: Reader, c: Collector, child: KernelRunRecord): Promis
163
172
  agentId: agent.id,
164
173
  agentVersion: agent.version,
165
174
  ...(retrieved !== undefined && { retrieved }),
175
+ ...(recalled !== undefined && { recalled }),
166
176
  });
167
177
  for (const call of turnToolCalls(output)) {
168
178
  c.add({
@@ -172,6 +182,10 @@ async function stepTurn(r: Reader, c: Collector, child: KernelRunRecord): Promis
172
182
  ...call,
173
183
  });
174
184
  }
185
+ const calls = turnCallIds(output);
186
+ if (calls.length === 0) return;
187
+ const journal = await r.runBinding.readJournal(r.tenantId, child.runId);
188
+ if (journal.kind === 'ok') addToolEnv(journal.value, calls, c.toolEnv);
175
189
  }
176
190
 
177
191
  /** A run's child runs (agent steps' turns, sub-flows); none when they can't be read. */
@@ -241,5 +255,5 @@ export async function captureFlowContext(input: {
241
255
  steps: c.steps,
242
256
  ...(c.truncated && { truncated: true }),
243
257
  };
244
- return { flow };
258
+ return { flow, ...(Object.keys(c.toolEnv).length > 0 && { toolEnv: c.toolEnv }) };
245
259
  }
@@ -6,7 +6,7 @@ import { type Context, Hono } from 'hono';
6
6
  import type { ConversationBinding } from '@kindgi/agents';
7
7
  import { REVIEWER_ROLE_RANK, type ReviewerRole, ref } from '@kindgi/authz';
8
8
  import type { RunBinding } from '@kindgi/runtime';
9
- import type { Cursor, ProjectId, RunId, TenantId } from '@kindgi/types';
9
+ import type { Cursor, ProjectId, RunId, ScopeSegment, TenantId } from '@kindgi/types';
10
10
 
11
11
  import { statusFor, toWireError } from '../errors.js';
12
12
  import type { FlowRegistryBinding } from '../flow-binding.js';
@@ -105,6 +105,9 @@ export function judgmentsRouter(
105
105
  subject,
106
106
  input: run.input,
107
107
  output: run.output,
108
+ // Which segment the run was in, kept with the copy: a test set for a
109
+ // segment takes only its runs.
110
+ segments: run.segments,
108
111
  ...(context !== undefined && { context }),
109
112
  },
110
113
  item: body.item,
@@ -395,7 +398,11 @@ export function judgeClassesRouter(
395
398
  type Prepared =
396
399
  | {
397
400
  readonly kind: 'ok';
398
- readonly run: { readonly input: unknown; readonly output: unknown };
401
+ readonly run: {
402
+ readonly input: unknown;
403
+ readonly output: unknown;
404
+ readonly segments: readonly ScopeSegment[];
405
+ };
399
406
  readonly subject: JudgedSubject;
400
407
  readonly projectId: ProjectId;
401
408
  readonly itemValue?: unknown;
@@ -430,6 +437,13 @@ async function prepareJudgment(
430
437
  ) {
431
438
  return err('permission-denied', `Not allowed to judge run "${body.runId}".`);
432
439
  }
440
+ // An erasure cleared its content: there's nothing to judge (T273 M-5).
441
+ if (run.contentErasedAt !== undefined) {
442
+ return err(
443
+ 'run-erased',
444
+ `Run "${body.runId}" was erased (a person's words were removed): there's nothing to judge.`,
445
+ );
446
+ }
433
447
  if (run.status !== 'completed' || run.output === undefined || run.output === null) {
434
448
  return err(
435
449
  'run-not-finished',
@@ -462,7 +476,7 @@ async function prepareJudgment(
462
476
  restricted = true;
463
477
  }
464
478
  }
465
- const copy = { input: run.input, output: run.output };
479
+ const copy = { input: run.input, output: run.output, segments: run.segments ?? [] };
466
480
  const extra = {
467
481
  ...(run.agent !== undefined && { conversationId: run.agent.conversationId as string }),
468
482
  ...(restricted && { restricted: true as const }),
package/src/routes/mcp.ts CHANGED
@@ -133,8 +133,15 @@ export function mcpRouter(
133
133
  ...(scopeParsed.scope !== undefined && { scope: scopeParsed.scope }),
134
134
  ...(scopeParsed.inherit !== undefined && { inherit: scopeParsed.inherit }),
135
135
  });
136
+ // Only what the caller may read (T243 A), as `GET …/:id` asks.
137
+ const visible =
138
+ authorizer === undefined
139
+ ? page.data
140
+ : await authorizer.filterByCan(c, 'read', page.data, (a) =>
141
+ ref('mcp_endpoint', a.endpointId as unknown as string),
142
+ );
136
143
  return c.json({
137
- data: page.data.map(serializeEndpoint),
144
+ data: visible.map(serializeEndpoint),
138
145
  hasMore: page.nextCursor !== undefined,
139
146
  ...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
140
147
  });
@@ -624,6 +631,7 @@ function serializeEndpoint(e: MCPEndpoint): Record<string, unknown> {
624
631
  ...(e.secretRef !== undefined && { secretRef: e.secretRef }),
625
632
  ...(e.instructions !== undefined && { instructions: e.instructions }),
626
633
  ...(e.metadata !== undefined && { metadata: e.metadata }),
634
+ ...(e.sendTraceparent !== undefined && { sendTraceparent: e.sendTraceparent }),
627
635
  };
628
636
  }
629
637
 
@@ -636,6 +644,7 @@ const REGISTER_BODY_FIELDS = new Set([
636
644
  'secretRef',
637
645
  'instructions',
638
646
  'metadata',
647
+ 'sendTraceparent',
639
648
  'scopeKind',
640
649
  'scopeId',
641
650
  ]);
@@ -736,6 +745,24 @@ function validateMCPEndpoint(
736
745
  },
737
746
  };
738
747
  }
748
+ if (b.sendTraceparent !== undefined && typeof b.sendTraceparent !== 'boolean') {
749
+ return {
750
+ kind: 'err',
751
+ error: {
752
+ message: `endpoint "${b.endpointId}" sendTraceparent must be true or false`,
753
+ reason: 'invalid-send-traceparent',
754
+ },
755
+ };
756
+ }
757
+ if (b.sendTraceparent === true && b.transport === 'stdio') {
758
+ return {
759
+ kind: 'err',
760
+ error: {
761
+ message: `endpoint "${b.endpointId}" sendTraceparent needs an HTTP transport: a stdio server gets no headers`,
762
+ reason: 'invalid-send-traceparent',
763
+ },
764
+ };
765
+ }
739
766
 
740
767
  const value: MCPEndpoint = {
741
768
  endpointId: b.endpointId,
@@ -747,6 +774,7 @@ function validateMCPEndpoint(
747
774
  ...(b.metadata !== undefined && {
748
775
  metadata: b.metadata as Readonly<Record<string, unknown>>,
749
776
  }),
777
+ ...(b.sendTraceparent !== undefined && { sendTraceparent: b.sendTraceparent }),
750
778
  };
751
779
  return { kind: 'ok', value };
752
780
  }