@kindgi/api 0.1.4 → 0.1.5-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.
- package/dist/agent-binding.d.ts +13 -0
- package/dist/agent-binding.d.ts.map +1 -1
- package/dist/agent-pins.d.ts.map +1 -1
- package/dist/agent-pins.js +18 -2
- package/dist/agent-pins.js.map +1 -1
- package/dist/app.d.ts +110 -17
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +163 -35
- package/dist/app.js.map +1 -1
- package/dist/block-publish.d.ts +56 -0
- package/dist/block-publish.d.ts.map +1 -0
- package/dist/block-publish.js +132 -0
- package/dist/block-publish.js.map +1 -0
- package/dist/caller.d.ts +24 -0
- package/dist/caller.d.ts.map +1 -0
- package/dist/caller.js +47 -0
- package/dist/caller.js.map +1 -0
- package/dist/capability-binding.d.ts +11 -0
- package/dist/capability-binding.d.ts.map +1 -1
- package/dist/derive-agent-version.d.ts +7 -0
- package/dist/derive-agent-version.d.ts.map +1 -1
- package/dist/derive-agent-version.js +4 -0
- package/dist/derive-agent-version.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +73 -7
- package/dist/errors.js.map +1 -1
- package/dist/eval-case-binding.d.ts +16 -4
- package/dist/eval-case-binding.d.ts.map +1 -1
- package/dist/eval-run-binding.d.ts +31 -0
- package/dist/eval-run-binding.d.ts.map +1 -1
- package/dist/eval-run-dispatcher.d.ts +7 -0
- package/dist/eval-run-dispatcher.d.ts.map +1 -1
- package/dist/eval-run-dispatcher.js.map +1 -1
- package/dist/eval-sample.d.ts +11 -0
- package/dist/eval-sample.d.ts.map +1 -0
- package/dist/eval-sample.js +34 -0
- package/dist/eval-sample.js.map +1 -0
- package/dist/eval-suite-binding.d.ts +13 -0
- package/dist/eval-suite-binding.d.ts.map +1 -1
- package/dist/eval-suite-binding.js.map +1 -1
- package/dist/flow-binding.d.ts +18 -0
- package/dist/flow-binding.d.ts.map +1 -1
- package/dist/flow-pins.d.ts.map +1 -1
- package/dist/flow-pins.js +18 -2
- package/dist/flow-pins.js.map +1 -1
- package/dist/gate.d.ts.map +1 -1
- package/dist/gate.js +25 -0
- package/dist/gate.js.map +1 -1
- package/dist/handler-binding.d.ts +32 -0
- package/dist/handler-binding.d.ts.map +1 -1
- package/dist/hitl-binding.d.ts +23 -0
- package/dist/hitl-binding.d.ts.map +1 -1
- package/dist/identity-directory-binding.d.ts +82 -4
- package/dist/identity-directory-binding.d.ts.map +1 -1
- package/dist/identity-provider-binding.d.ts +197 -17
- package/dist/identity-provider-binding.d.ts.map +1 -1
- package/dist/improvement-pass-binding.d.ts +196 -0
- package/dist/improvement-pass-binding.d.ts.map +1 -0
- package/dist/improvement-pass-binding.js +9 -0
- package/dist/improvement-pass-binding.js.map +1 -0
- package/dist/index.d.ts +35 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/judged-dispatcher.d.ts +25 -4
- package/dist/judged-dispatcher.d.ts.map +1 -1
- package/dist/judged-dispatcher.js +43 -6
- package/dist/judged-dispatcher.js.map +1 -1
- package/dist/judgment-binding.d.ts +25 -1
- package/dist/judgment-binding.d.ts.map +1 -1
- package/dist/mcp-endpoint-binding.d.ts +7 -0
- package/dist/mcp-endpoint-binding.d.ts.map +1 -1
- package/dist/memory-binding.d.ts +124 -17
- package/dist/memory-binding.d.ts.map +1 -1
- package/dist/memory-erasure-binding.d.ts +145 -0
- package/dist/memory-erasure-binding.d.ts.map +1 -0
- package/dist/memory-erasure-binding.js +4 -0
- package/dist/memory-erasure-binding.js.map +1 -0
- package/dist/middleware/auth.d.ts +66 -13
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +150 -50
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/authorize.d.ts +6 -0
- package/dist/middleware/authorize.d.ts.map +1 -1
- package/dist/middleware/authorize.js +113 -4
- package/dist/middleware/authorize.js.map +1 -1
- package/dist/middleware/error-mapper.d.ts +5 -0
- package/dist/middleware/error-mapper.d.ts.map +1 -1
- package/dist/middleware/error-mapper.js +14 -1
- package/dist/middleware/error-mapper.js.map +1 -1
- package/dist/middleware/idempotency.d.ts +70 -5
- package/dist/middleware/idempotency.d.ts.map +1 -1
- package/dist/middleware/idempotency.js +174 -41
- package/dist/middleware/idempotency.js.map +1 -1
- package/dist/middleware/key-project.d.ts +17 -0
- package/dist/middleware/key-project.d.ts.map +1 -0
- package/dist/middleware/key-project.js +75 -0
- package/dist/middleware/key-project.js.map +1 -0
- package/dist/middleware/principal.d.ts.map +1 -1
- package/dist/middleware/principal.js +9 -5
- package/dist/middleware/principal.js.map +1 -1
- package/dist/middleware/project-ref.d.ts.map +1 -1
- package/dist/middleware/project-ref.js +3 -0
- package/dist/middleware/project-ref.js.map +1 -1
- package/dist/openapi/generate.d.ts.map +1 -1
- package/dist/openapi/generate.js +5 -2
- package/dist/openapi/generate.js.map +1 -1
- package/dist/openapi/operations.d.ts.map +1 -1
- package/dist/openapi/operations.js +918 -139
- package/dist/openapi/operations.js.map +1 -1
- package/dist/openapi/schemas.d.ts +90 -13
- package/dist/openapi/schemas.d.ts.map +1 -1
- package/dist/openapi/schemas.js +2081 -359
- package/dist/openapi/schemas.js.map +1 -1
- package/dist/person-grants-binding.d.ts +77 -0
- package/dist/person-grants-binding.d.ts.map +1 -0
- package/dist/person-grants-binding.js +4 -0
- package/dist/person-grants-binding.js.map +1 -0
- package/dist/proposal-service.d.ts +121 -0
- package/dist/proposal-service.d.ts.map +1 -0
- package/dist/proposal-service.js +447 -0
- package/dist/proposal-service.js.map +1 -0
- package/dist/proposal-status.d.ts +60 -0
- package/dist/proposal-status.d.ts.map +1 -0
- package/dist/proposal-status.js +109 -0
- package/dist/proposal-status.js.map +1 -0
- package/dist/provider-binding.d.ts +10 -0
- package/dist/provider-binding.d.ts.map +1 -1
- package/dist/publish-refused.d.ts +18 -3
- package/dist/publish-refused.d.ts.map +1 -1
- package/dist/publish-refused.js +18 -3
- package/dist/publish-refused.js.map +1 -1
- package/dist/routes/adapters.d.ts +2 -1
- package/dist/routes/adapters.d.ts.map +1 -1
- package/dist/routes/adapters.js +3 -1
- package/dist/routes/adapters.js.map +1 -1
- package/dist/routes/agent-releases.d.ts +55 -3
- package/dist/routes/agent-releases.d.ts.map +1 -1
- package/dist/routes/agent-releases.js +85 -55
- package/dist/routes/agent-releases.js.map +1 -1
- package/dist/routes/agents.d.ts +12 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +100 -2
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/approvals.d.ts +15 -3
- package/dist/routes/approvals.d.ts.map +1 -1
- package/dist/routes/approvals.js +133 -122
- package/dist/routes/approvals.js.map +1 -1
- package/dist/routes/artifacts.d.ts +25 -3
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/artifacts.js +116 -7
- package/dist/routes/artifacts.js.map +1 -1
- package/dist/routes/auth.d.ts +25 -1
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/auth.js +655 -281
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/blocks.d.ts.map +1 -1
- package/dist/routes/blocks.js +2 -42
- package/dist/routes/blocks.js.map +1 -1
- package/dist/routes/capabilities.d.ts +2 -1
- package/dist/routes/capabilities.d.ts.map +1 -1
- package/dist/routes/capabilities.js +6 -1
- package/dist/routes/capabilities.js.map +1 -1
- package/dist/routes/compliance.d.ts +9 -10
- package/dist/routes/compliance.d.ts.map +1 -1
- package/dist/routes/compliance.js +42 -61
- package/dist/routes/compliance.js.map +1 -1
- package/dist/routes/conversations.d.ts +8 -1
- package/dist/routes/conversations.d.ts.map +1 -1
- package/dist/routes/conversations.js +87 -8
- package/dist/routes/conversations.js.map +1 -1
- package/dist/routes/cost.d.ts +7 -1
- package/dist/routes/cost.d.ts.map +1 -1
- package/dist/routes/cost.js +22 -3
- package/dist/routes/cost.js.map +1 -1
- package/dist/routes/denied.d.ts +11 -0
- package/dist/routes/denied.d.ts.map +1 -0
- package/dist/routes/denied.js +17 -0
- package/dist/routes/denied.js.map +1 -0
- package/dist/routes/deployments.d.ts +2 -1
- package/dist/routes/deployments.d.ts.map +1 -1
- package/dist/routes/deployments.js +44 -12
- package/dist/routes/deployments.js.map +1 -1
- package/dist/routes/eval-comparison.d.ts.map +1 -1
- package/dist/routes/eval-comparison.js +69 -1
- package/dist/routes/eval-comparison.js.map +1 -1
- package/dist/routes/eval-overrides.d.ts +18 -0
- package/dist/routes/eval-overrides.d.ts.map +1 -0
- package/dist/routes/eval-overrides.js +81 -0
- package/dist/routes/eval-overrides.js.map +1 -0
- package/dist/routes/eval-runs.d.ts +10 -1
- package/dist/routes/eval-runs.d.ts.map +1 -1
- package/dist/routes/eval-runs.js +63 -7
- package/dist/routes/eval-runs.js.map +1 -1
- package/dist/routes/eval-suites.d.ts.map +1 -1
- package/dist/routes/eval-suites.js +20 -1
- package/dist/routes/eval-suites.js.map +1 -1
- package/dist/routes/event-triggers.d.ts +5 -1
- package/dist/routes/event-triggers.d.ts.map +1 -1
- package/dist/routes/event-triggers.js +26 -3
- package/dist/routes/event-triggers.js.map +1 -1
- package/dist/routes/export-signing-keys.d.ts +12 -0
- package/dist/routes/export-signing-keys.d.ts.map +1 -0
- package/dist/routes/export-signing-keys.js +24 -0
- package/dist/routes/export-signing-keys.js.map +1 -0
- package/dist/routes/flows.d.ts.map +1 -1
- package/dist/routes/flows.js +9 -1
- package/dist/routes/flows.js.map +1 -1
- package/dist/routes/gate-policies.d.ts +4 -1
- package/dist/routes/gate-policies.d.ts.map +1 -1
- package/dist/routes/gate-policies.js +29 -5
- package/dist/routes/gate-policies.js.map +1 -1
- package/dist/routes/guardrails.d.ts +16 -14
- package/dist/routes/guardrails.d.ts.map +1 -1
- package/dist/routes/guardrails.js +39 -3
- package/dist/routes/guardrails.js.map +1 -1
- package/dist/routes/identity.d.ts +20 -4
- package/dist/routes/identity.d.ts.map +1 -1
- package/dist/routes/identity.js +246 -6
- package/dist/routes/identity.js.map +1 -1
- package/dist/routes/improvement-passes.d.ts +52 -0
- package/dist/routes/improvement-passes.d.ts.map +1 -0
- package/dist/routes/improvement-passes.js +449 -0
- package/dist/routes/improvement-passes.js.map +1 -0
- package/dist/routes/judged-suites.d.ts +50 -0
- package/dist/routes/judged-suites.d.ts.map +1 -1
- package/dist/routes/judged-suites.js +66 -27
- package/dist/routes/judged-suites.js.map +1 -1
- package/dist/routes/judgment-context.d.ts +18 -2
- package/dist/routes/judgment-context.d.ts.map +1 -1
- package/dist/routes/judgment-context.js +63 -5
- package/dist/routes/judgment-context.js.map +1 -1
- package/dist/routes/judgment-flow-context.d.ts.map +1 -1
- package/dist/routes/judgment-flow-context.js +14 -2
- package/dist/routes/judgment-flow-context.js.map +1 -1
- package/dist/routes/judgments.d.ts.map +1 -1
- package/dist/routes/judgments.js +8 -1
- package/dist/routes/judgments.js.map +1 -1
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +26 -1
- package/dist/routes/mcp.js.map +1 -1
- package/dist/routes/memory-access.d.ts +43 -0
- package/dist/routes/memory-access.d.ts.map +1 -0
- package/dist/routes/memory-access.js +129 -0
- package/dist/routes/memory-access.js.map +1 -0
- package/dist/routes/memory-erasures.d.ts +25 -0
- package/dist/routes/memory-erasures.d.ts.map +1 -0
- package/dist/routes/memory-erasures.js +214 -0
- package/dist/routes/memory-erasures.js.map +1 -0
- package/dist/routes/memory-parse.d.ts +38 -0
- package/dist/routes/memory-parse.d.ts.map +1 -0
- package/dist/routes/memory-parse.js +199 -0
- package/dist/routes/memory-parse.js.map +1 -0
- package/dist/routes/memory.d.ts +9 -4
- package/dist/routes/memory.d.ts.map +1 -1
- package/dist/routes/memory.js +226 -234
- package/dist/routes/memory.js.map +1 -1
- package/dist/routes/observations.d.ts +4 -1
- package/dist/routes/observations.d.ts.map +1 -1
- package/dist/routes/observations.js +8 -2
- package/dist/routes/observations.js.map +1 -1
- package/dist/routes/pagination.d.ts +7 -0
- package/dist/routes/pagination.d.ts.map +1 -1
- package/dist/routes/pagination.js +10 -0
- package/dist/routes/pagination.js.map +1 -1
- package/dist/routes/policies.d.ts +2 -1
- package/dist/routes/policies.d.ts.map +1 -1
- package/dist/routes/policies.js +3 -1
- package/dist/routes/policies.js.map +1 -1
- package/dist/routes/project-mismatch.d.ts +22 -0
- package/dist/routes/project-mismatch.d.ts.map +1 -0
- package/dist/routes/project-mismatch.js +34 -0
- package/dist/routes/project-mismatch.js.map +1 -0
- package/dist/routes/projects.d.ts +15 -4
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +100 -9
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/proposals.d.ts +25 -17
- package/dist/routes/proposals.d.ts.map +1 -1
- package/dist/routes/proposals.js +340 -507
- package/dist/routes/proposals.js.map +1 -1
- package/dist/routes/provenance.d.ts +17 -3
- package/dist/routes/provenance.d.ts.map +1 -1
- package/dist/routes/provenance.js +79 -103
- package/dist/routes/provenance.js.map +1 -1
- package/dist/routes/providers.d.ts +17 -1
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +110 -3
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/public-run-tokens.d.ts.map +1 -1
- package/dist/routes/public-run-tokens.js +3 -0
- package/dist/routes/public-run-tokens.js.map +1 -1
- package/dist/routes/runs.d.ts +10 -0
- package/dist/routes/runs.d.ts.map +1 -1
- package/dist/routes/runs.js +92 -42
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/schedules.d.ts +21 -13
- package/dist/routes/schedules.d.ts.map +1 -1
- package/dist/routes/schedules.js +416 -55
- package/dist/routes/schedules.js.map +1 -1
- package/dist/routes/segments.d.ts +2 -0
- package/dist/routes/segments.d.ts.map +1 -1
- package/dist/routes/segments.js +5 -0
- package/dist/routes/segments.js.map +1 -1
- package/dist/routes/service-accounts.d.ts +17 -0
- package/dist/routes/service-accounts.d.ts.map +1 -0
- package/dist/routes/service-accounts.js +212 -0
- package/dist/routes/service-accounts.js.map +1 -0
- package/dist/routes/sign-in-options.d.ts +50 -0
- package/dist/routes/sign-in-options.d.ts.map +1 -0
- package/dist/routes/sign-in-options.js +98 -0
- package/dist/routes/sign-in-options.js.map +1 -0
- package/dist/routes/signing-keys.d.ts +2 -1
- package/dist/routes/signing-keys.d.ts.map +1 -1
- package/dist/routes/signing-keys.js +3 -1
- package/dist/routes/signing-keys.js.map +1 -1
- package/dist/routes/tenant-access.d.ts +13 -0
- package/dist/routes/tenant-access.d.ts.map +1 -0
- package/dist/routes/tenant-access.js +26 -0
- package/dist/routes/tenant-access.js.map +1 -0
- package/dist/routes/tenant.d.ts.map +1 -1
- package/dist/routes/tenant.js +4 -0
- package/dist/routes/tenant.js.map +1 -1
- package/dist/routes/token-sign-in.d.ts +36 -0
- package/dist/routes/token-sign-in.d.ts.map +1 -0
- package/dist/routes/token-sign-in.js +101 -0
- package/dist/routes/token-sign-in.js.map +1 -0
- package/dist/routes/tokens.d.ts +15 -5
- package/dist/routes/tokens.d.ts.map +1 -1
- package/dist/routes/tokens.js +162 -43
- package/dist/routes/tokens.js.map +1 -1
- package/dist/routes/tools.d.ts.map +1 -1
- package/dist/routes/tools.js +9 -1
- package/dist/routes/tools.js.map +1 -1
- package/dist/routes/trigger-access.d.ts +29 -0
- package/dist/routes/trigger-access.d.ts.map +1 -0
- package/dist/routes/trigger-access.js +33 -0
- package/dist/routes/trigger-access.js.map +1 -0
- package/dist/routes/webhook-endpoints.d.ts +2 -1
- package/dist/routes/webhook-endpoints.d.ts.map +1 -1
- package/dist/routes/webhook-endpoints.js +11 -3
- package/dist/routes/webhook-endpoints.js.map +1 -1
- package/dist/routes/webhooks.d.ts +5 -1
- package/dist/routes/webhooks.d.ts.map +1 -1
- package/dist/routes/webhooks.js +25 -2
- package/dist/routes/webhooks.js.map +1 -1
- package/dist/run-failure.d.ts +21 -0
- package/dist/run-failure.d.ts.map +1 -0
- package/dist/run-failure.js +29 -0
- package/dist/run-failure.js.map +1 -0
- package/dist/service-account-binding.d.ts +108 -0
- package/dist/service-account-binding.d.ts.map +1 -0
- package/dist/service-account-binding.js +4 -0
- package/dist/service-account-binding.js.map +1 -0
- package/dist/session-store-binding.d.ts +61 -13
- package/dist/session-store-binding.d.ts.map +1 -1
- package/dist/signed-export.d.ts +89 -0
- package/dist/signed-export.d.ts.map +1 -0
- package/dist/signed-export.js +149 -0
- package/dist/signed-export.js.map +1 -0
- package/dist/supervisor-binding.d.ts +186 -413
- package/dist/supervisor-binding.d.ts.map +1 -1
- package/dist/testing/app-bindings.d.ts +33 -0
- package/dist/testing/app-bindings.d.ts.map +1 -0
- package/dist/testing/app-bindings.js +112 -0
- package/dist/testing/app-bindings.js.map +1 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +13 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/stub-binding.d.ts +34 -0
- package/dist/testing/stub-binding.d.ts.map +1 -0
- package/dist/testing/stub-binding.js +42 -0
- package/dist/testing/stub-binding.js.map +1 -0
- package/dist/testing/trigger-registry.d.ts +21 -0
- package/dist/testing/trigger-registry.d.ts.map +1 -0
- package/dist/testing/trigger-registry.js +206 -0
- package/dist/testing/trigger-registry.js.map +1 -0
- package/dist/token-admin.d.ts +46 -8
- package/dist/token-admin.d.ts.map +1 -1
- package/dist/token-admin.js.map +1 -1
- package/dist/tool-binding.d.ts +13 -0
- package/dist/tool-binding.d.ts.map +1 -1
- package/dist/trigger-binding.d.ts +2 -2
- package/dist/trigger-binding.d.ts.map +1 -1
- package/dist/trigger-binding.js +1 -1
- package/dist/trigger-binding.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/webhook-endpoint-binding.d.ts +19 -3
- package/dist/webhook-endpoint-binding.d.ts.map +1 -1
- package/dist/webhook-endpoint-binding.js +1 -1
- package/dist/webhook-endpoint-binding.js.map +1 -1
- package/openapi.json +15385 -8788
- package/package.json +26 -22
- package/src/agent-binding.ts +14 -0
- package/src/agent-pins.ts +18 -2
- package/src/app.ts +366 -80
- package/src/block-publish.ts +181 -0
- package/src/caller.ts +62 -0
- package/src/capability-binding.ts +12 -0
- package/src/derive-agent-version.ts +9 -1
- package/src/errors.ts +73 -7
- package/src/eval-case-binding.ts +17 -1
- package/src/eval-run-binding.ts +31 -0
- package/src/eval-run-dispatcher.ts +7 -0
- package/src/eval-sample.ts +42 -0
- package/src/eval-suite-binding.ts +14 -0
- package/src/flow-binding.ts +19 -0
- package/src/flow-pins.ts +18 -2
- package/src/gate.ts +26 -0
- package/src/handler-binding.ts +36 -1
- package/src/hitl-binding.ts +24 -0
- package/src/identity-directory-binding.ts +85 -4
- package/src/identity-provider-binding.ts +216 -21
- package/src/improvement-pass-binding.ts +193 -0
- package/src/index.ts +153 -31
- package/src/judged-dispatcher.ts +78 -11
- package/src/judgment-binding.ts +25 -1
- package/src/mcp-endpoint-binding.ts +7 -0
- package/src/memory-binding.ts +121 -17
- package/src/memory-erasure-binding.ts +156 -0
- package/src/middleware/auth.ts +228 -62
- package/src/middleware/authorize.ts +139 -3
- package/src/middleware/error-mapper.ts +15 -1
- package/src/middleware/idempotency.ts +230 -43
- package/src/middleware/key-project.ts +86 -0
- package/src/middleware/principal.ts +9 -5
- package/src/middleware/project-ref.ts +3 -0
- package/src/openapi/generate.ts +11 -2
- package/src/openapi/operations.ts +1059 -142
- package/src/openapi/schemas.ts +2387 -469
- package/src/person-grants-binding.ts +76 -0
- package/src/proposal-service.ts +640 -0
- package/src/proposal-status.ts +176 -0
- package/src/provider-binding.ts +10 -0
- package/src/publish-refused.ts +38 -9
- package/src/routes/adapters.ts +4 -0
- package/src/routes/agent-releases.ts +121 -69
- package/src/routes/agents.ts +128 -1
- package/src/routes/approvals.ts +164 -154
- package/src/routes/artifacts.ts +181 -11
- package/src/routes/auth.ts +804 -336
- package/src/routes/blocks.ts +2 -53
- package/src/routes/capabilities.ts +10 -1
- package/src/routes/compliance.ts +60 -99
- package/src/routes/conversations.ts +101 -7
- package/src/routes/cost.ts +32 -3
- package/src/routes/denied.ts +28 -0
- package/src/routes/deployments.ts +62 -16
- package/src/routes/eval-comparison.ts +81 -2
- package/src/routes/eval-overrides.ts +108 -0
- package/src/routes/eval-runs.ts +86 -6
- package/src/routes/eval-suites.ts +25 -1
- package/src/routes/event-triggers.ts +27 -3
- package/src/routes/export-signing-keys.ts +31 -0
- package/src/routes/flows.ts +12 -1
- package/src/routes/gate-policies.ts +37 -6
- package/src/routes/guardrails.ts +61 -2
- package/src/routes/identity.ts +328 -10
- package/src/routes/improvement-passes.ts +541 -0
- package/src/routes/judged-suites.ts +113 -43
- package/src/routes/judgment-context.ts +76 -5
- package/src/routes/judgment-flow-context.ts +16 -2
- package/src/routes/judgments.ts +17 -3
- package/src/routes/mcp.ts +29 -1
- package/src/routes/memory-access.ts +179 -0
- package/src/routes/memory-erasures.ts +240 -0
- package/src/routes/memory-parse.ts +250 -0
- package/src/routes/memory.ts +244 -286
- package/src/routes/observations.ts +15 -2
- package/src/routes/pagination.ts +12 -0
- package/src/routes/policies.ts +7 -1
- package/src/routes/project-mismatch.ts +56 -0
- package/src/routes/projects.ts +107 -13
- package/src/routes/proposals.ts +370 -611
- package/src/routes/provenance.ts +99 -133
- package/src/routes/providers.ts +142 -3
- package/src/routes/public-run-tokens.ts +3 -0
- package/src/routes/runs.ts +119 -39
- package/src/routes/schedules.ts +472 -60
- package/src/routes/segments.ts +11 -0
- package/src/routes/service-accounts.ts +262 -0
- package/src/routes/sign-in-options.ts +168 -0
- package/src/routes/signing-keys.ts +7 -1
- package/src/routes/tenant-access.ts +37 -0
- package/src/routes/tenant.ts +6 -0
- package/src/routes/token-sign-in.ts +161 -0
- package/src/routes/tokens.ts +172 -46
- package/src/routes/tools.ts +12 -1
- package/src/routes/trigger-access.ts +72 -0
- package/src/routes/webhook-endpoints.ts +15 -3
- package/src/routes/webhooks.ts +26 -2
- package/src/run-failure.ts +42 -0
- package/src/service-account-binding.ts +113 -0
- package/src/session-store-binding.ts +65 -13
- package/src/signed-export.ts +250 -0
- package/src/supervisor-binding.ts +169 -409
- package/src/testing/app-bindings.ts +142 -0
- package/src/testing/index.ts +21 -0
- package/src/testing/stub-binding.ts +53 -0
- package/src/testing/trigger-registry.ts +259 -0
- package/src/token-admin.ts +40 -8
- package/src/tool-binding.ts +14 -0
- package/src/trigger-binding.ts +8 -1
- package/src/types.ts +16 -0
- 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
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
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
|
-
|
|
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:
|
|
115
|
-
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
|
|
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
|
-
|
|
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<
|
|
57
|
+
type JournalParts = Pick<
|
|
58
|
+
JudgedRunContext,
|
|
59
|
+
'retrieved' | 'recalled' | 'sessionApproval' | 'toolEnv'
|
|
60
|
+
>;
|
|
57
61
|
|
|
58
|
-
/**
|
|
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
|
|
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,
|
|
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
|
}
|
package/src/routes/judgments.ts
CHANGED
|
@@ -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: {
|
|
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:
|
|
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
|
}
|