@kindgi/api 0.0.0-bootstrap.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -0
- package/README.md +216 -1
- package/dist/adapter-binding.d.ts +177 -0
- package/dist/adapter-binding.d.ts.map +1 -0
- package/dist/adapter-binding.js +12 -0
- package/dist/adapter-binding.js.map +1 -0
- package/dist/agent-binding.d.ts +207 -0
- package/dist/agent-binding.d.ts.map +1 -0
- package/dist/agent-binding.js +4 -0
- package/dist/agent-binding.js.map +1 -0
- package/dist/app.d.ts +770 -0
- package/dist/app.d.ts.map +1 -0
- package/dist/app.js +396 -0
- package/dist/app.js.map +1 -0
- package/dist/capability-binding.d.ts +76 -0
- package/dist/capability-binding.d.ts.map +1 -0
- package/dist/capability-binding.js +4 -0
- package/dist/capability-binding.js.map +1 -0
- package/dist/cost-binding.d.ts +175 -0
- package/dist/cost-binding.d.ts.map +1 -0
- package/dist/cost-binding.js +13 -0
- package/dist/cost-binding.js.map +1 -0
- package/dist/deployment-binding.d.ts +201 -0
- package/dist/deployment-binding.d.ts.map +1 -0
- package/dist/deployment-binding.js +4 -0
- package/dist/deployment-binding.js.map +1 -0
- package/dist/env-binding.d.ts +132 -0
- package/dist/env-binding.d.ts.map +1 -0
- package/dist/env-binding.js +4 -0
- package/dist/env-binding.js.map +1 -0
- package/dist/errors.d.ts +37 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +264 -0
- package/dist/errors.js.map +1 -0
- package/dist/eval-run-binding.d.ts +196 -0
- package/dist/eval-run-binding.d.ts.map +1 -0
- package/dist/eval-run-binding.js +16 -0
- package/dist/eval-run-binding.js.map +1 -0
- package/dist/eval-run-dispatcher.d.ts +131 -0
- package/dist/eval-run-dispatcher.d.ts.map +1 -0
- package/dist/eval-run-dispatcher.js +368 -0
- package/dist/eval-run-dispatcher.js.map +1 -0
- package/dist/eval-suite-binding.d.ts +227 -0
- package/dist/eval-suite-binding.d.ts.map +1 -0
- package/dist/eval-suite-binding.js +24 -0
- package/dist/eval-suite-binding.js.map +1 -0
- package/dist/event-bus-binding.d.ts +107 -0
- package/dist/event-bus-binding.d.ts.map +1 -0
- package/dist/event-bus-binding.js +5 -0
- package/dist/event-bus-binding.js.map +1 -0
- package/dist/flow-binding.d.ts +194 -0
- package/dist/flow-binding.d.ts.map +1 -0
- package/dist/flow-binding.js +4 -0
- package/dist/flow-binding.js.map +1 -0
- package/dist/guardrail-binding.d.ts +138 -0
- package/dist/guardrail-binding.d.ts.map +1 -0
- package/dist/guardrail-binding.js +4 -0
- package/dist/guardrail-binding.js.map +1 -0
- package/dist/handler-binding.d.ts +126 -0
- package/dist/handler-binding.d.ts.map +1 -0
- package/dist/handler-binding.js +4 -0
- package/dist/handler-binding.js.map +1 -0
- package/dist/hitl-binding.d.ts +115 -0
- package/dist/hitl-binding.d.ts.map +1 -0
- package/dist/hitl-binding.js +4 -0
- package/dist/hitl-binding.js.map +1 -0
- package/dist/identity-directory-binding.d.ts +116 -0
- package/dist/identity-directory-binding.d.ts.map +1 -0
- package/dist/identity-directory-binding.js +4 -0
- package/dist/identity-directory-binding.js.map +1 -0
- package/dist/identity-provider-binding.d.ts +184 -0
- package/dist/identity-provider-binding.d.ts.map +1 -0
- package/dist/identity-provider-binding.js +4 -0
- package/dist/identity-provider-binding.js.map +1 -0
- package/dist/image-registry-binding.d.ts +165 -0
- package/dist/image-registry-binding.d.ts.map +1 -0
- package/dist/image-registry-binding.js +4 -0
- package/dist/image-registry-binding.js.map +1 -0
- package/dist/index.d.ts +72 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/key-management-binding.d.ts +101 -0
- package/dist/key-management-binding.d.ts.map +1 -0
- package/dist/key-management-binding.js +4 -0
- package/dist/key-management-binding.js.map +1 -0
- package/dist/mcp-endpoint-binding.d.ts +312 -0
- package/dist/mcp-endpoint-binding.d.ts.map +1 -0
- package/dist/mcp-endpoint-binding.js +12 -0
- package/dist/mcp-endpoint-binding.js.map +1 -0
- package/dist/memory-binding.d.ts +209 -0
- package/dist/memory-binding.d.ts.map +1 -0
- package/dist/memory-binding.js +4 -0
- package/dist/memory-binding.js.map +1 -0
- package/dist/middleware/auth.d.ts +168 -0
- package/dist/middleware/auth.d.ts.map +1 -0
- package/dist/middleware/auth.js +247 -0
- package/dist/middleware/auth.js.map +1 -0
- package/dist/middleware/authorize.d.ts +26 -0
- package/dist/middleware/authorize.d.ts.map +1 -0
- package/dist/middleware/authorize.js +65 -0
- package/dist/middleware/authorize.js.map +1 -0
- package/dist/middleware/error-mapper.d.ts +13 -0
- package/dist/middleware/error-mapper.d.ts.map +1 -0
- package/dist/middleware/error-mapper.js +32 -0
- package/dist/middleware/error-mapper.js.map +1 -0
- package/dist/middleware/idempotency.d.ts +43 -0
- package/dist/middleware/idempotency.d.ts.map +1 -0
- package/dist/middleware/idempotency.js +118 -0
- package/dist/middleware/idempotency.js.map +1 -0
- package/dist/middleware/principal.d.ts +4 -0
- package/dist/middleware/principal.d.ts.map +1 -0
- package/dist/middleware/principal.js +42 -0
- package/dist/middleware/principal.js.map +1 -0
- package/dist/middleware/public-run-routes.d.ts +16 -0
- package/dist/middleware/public-run-routes.d.ts.map +1 -0
- package/dist/middleware/public-run-routes.js +43 -0
- package/dist/middleware/public-run-routes.js.map +1 -0
- package/dist/middleware/request-id.d.ts +14 -0
- package/dist/middleware/request-id.d.ts.map +1 -0
- package/dist/middleware/request-id.js +24 -0
- package/dist/middleware/request-id.js.map +1 -0
- package/dist/middleware/sigv4-verify.d.ts +64 -0
- package/dist/middleware/sigv4-verify.d.ts.map +1 -0
- package/dist/middleware/sigv4-verify.js +286 -0
- package/dist/middleware/sigv4-verify.js.map +1 -0
- package/dist/middleware/sigv4.d.ts +25 -0
- package/dist/middleware/sigv4.d.ts.map +1 -0
- package/dist/middleware/sigv4.js +120 -0
- package/dist/middleware/sigv4.js.map +1 -0
- package/dist/openapi/generate.d.ts +15 -0
- package/dist/openapi/generate.d.ts.map +1 -0
- package/dist/openapi/generate.js +241 -0
- package/dist/openapi/generate.js.map +1 -0
- package/dist/openapi/operations.d.ts +70 -0
- package/dist/openapi/operations.d.ts.map +1 -0
- package/dist/openapi/operations.js +5051 -0
- package/dist/openapi/operations.js.map +1 -0
- package/dist/openapi/schemas.d.ts +590 -0
- package/dist/openapi/schemas.d.ts.map +1 -0
- package/dist/openapi/schemas.js +5820 -0
- package/dist/openapi/schemas.js.map +1 -0
- package/dist/provenance-binding.d.ts +116 -0
- package/dist/provenance-binding.d.ts.map +1 -0
- package/dist/provenance-binding.js +31 -0
- package/dist/provenance-binding.js.map +1 -0
- package/dist/provider-binding.d.ts +174 -0
- package/dist/provider-binding.d.ts.map +1 -0
- package/dist/provider-binding.js +4 -0
- package/dist/provider-binding.js.map +1 -0
- package/dist/public-run-token.d.ts +97 -0
- package/dist/public-run-token.d.ts.map +1 -0
- package/dist/public-run-token.js +167 -0
- package/dist/public-run-token.js.map +1 -0
- package/dist/retention-binding.d.ts +69 -0
- package/dist/retention-binding.d.ts.map +1 -0
- package/dist/retention-binding.js +4 -0
- package/dist/retention-binding.js.map +1 -0
- package/dist/reviewer-binding.d.ts +84 -0
- package/dist/reviewer-binding.d.ts.map +1 -0
- package/dist/reviewer-binding.js +4 -0
- package/dist/reviewer-binding.js.map +1 -0
- package/dist/rotation-status-store.d.ts +96 -0
- package/dist/rotation-status-store.d.ts.map +1 -0
- package/dist/rotation-status-store.js +106 -0
- package/dist/rotation-status-store.js.map +1 -0
- package/dist/routes/adapters.d.ts +29 -0
- package/dist/routes/adapters.d.ts.map +1 -0
- package/dist/routes/adapters.js +230 -0
- package/dist/routes/adapters.js.map +1 -0
- package/dist/routes/agents.d.ts +17 -0
- package/dist/routes/agents.d.ts.map +1 -0
- package/dist/routes/agents.js +342 -0
- package/dist/routes/agents.js.map +1 -0
- package/dist/routes/approvals.d.ts +37 -0
- package/dist/routes/approvals.d.ts.map +1 -0
- package/dist/routes/approvals.js +551 -0
- package/dist/routes/approvals.js.map +1 -0
- package/dist/routes/artifacts.d.ts +25 -0
- package/dist/routes/artifacts.d.ts.map +1 -0
- package/dist/routes/artifacts.js +265 -0
- package/dist/routes/artifacts.js.map +1 -0
- package/dist/routes/audit.d.ts +6 -0
- package/dist/routes/audit.d.ts.map +1 -0
- package/dist/routes/audit.js +162 -0
- package/dist/routes/audit.js.map +1 -0
- package/dist/routes/auth.d.ts +47 -0
- package/dist/routes/auth.d.ts.map +1 -0
- package/dist/routes/auth.js +630 -0
- package/dist/routes/auth.js.map +1 -0
- package/dist/routes/capabilities.d.ts +14 -0
- package/dist/routes/capabilities.d.ts.map +1 -0
- package/dist/routes/capabilities.js +62 -0
- package/dist/routes/capabilities.js.map +1 -0
- package/dist/routes/compliance.d.ts +37 -0
- package/dist/routes/compliance.d.ts.map +1 -0
- package/dist/routes/compliance.js +321 -0
- package/dist/routes/compliance.js.map +1 -0
- package/dist/routes/conversations.d.ts +13 -0
- package/dist/routes/conversations.d.ts.map +1 -0
- package/dist/routes/conversations.js +295 -0
- package/dist/routes/conversations.js.map +1 -0
- package/dist/routes/cost.d.ts +24 -0
- package/dist/routes/cost.d.ts.map +1 -0
- package/dist/routes/cost.js +243 -0
- package/dist/routes/cost.js.map +1 -0
- package/dist/routes/deployments.d.ts +122 -0
- package/dist/routes/deployments.d.ts.map +1 -0
- package/dist/routes/deployments.js +1036 -0
- package/dist/routes/deployments.js.map +1 -0
- package/dist/routes/env.d.ts +62 -0
- package/dist/routes/env.d.ts.map +1 -0
- package/dist/routes/env.js +311 -0
- package/dist/routes/env.js.map +1 -0
- package/dist/routes/eval-runs.d.ts +28 -0
- package/dist/routes/eval-runs.d.ts.map +1 -0
- package/dist/routes/eval-runs.js +479 -0
- package/dist/routes/eval-runs.js.map +1 -0
- package/dist/routes/eval-suites.d.ts +24 -0
- package/dist/routes/eval-suites.d.ts.map +1 -0
- package/dist/routes/eval-suites.js +381 -0
- package/dist/routes/eval-suites.js.map +1 -0
- package/dist/routes/event-triggers.d.ts +12 -0
- package/dist/routes/event-triggers.d.ts.map +1 -0
- package/dist/routes/event-triggers.js +218 -0
- package/dist/routes/event-triggers.js.map +1 -0
- package/dist/routes/flows.d.ts +23 -0
- package/dist/routes/flows.d.ts.map +1 -0
- package/dist/routes/flows.js +344 -0
- package/dist/routes/flows.js.map +1 -0
- package/dist/routes/guardrails.d.ts +33 -0
- package/dist/routes/guardrails.d.ts.map +1 -0
- package/dist/routes/guardrails.js +236 -0
- package/dist/routes/guardrails.js.map +1 -0
- package/dist/routes/identity.d.ts +39 -0
- package/dist/routes/identity.d.ts.map +1 -0
- package/dist/routes/identity.js +138 -0
- package/dist/routes/identity.js.map +1 -0
- package/dist/routes/mcp.d.ts +23 -0
- package/dist/routes/mcp.d.ts.map +1 -0
- package/dist/routes/mcp.js +727 -0
- package/dist/routes/mcp.js.map +1 -0
- package/dist/routes/memory.d.ts +16 -0
- package/dist/routes/memory.d.ts.map +1 -0
- package/dist/routes/memory.js +353 -0
- package/dist/routes/memory.js.map +1 -0
- package/dist/routes/observations.d.ts +19 -0
- package/dist/routes/observations.d.ts.map +1 -0
- package/dist/routes/observations.js +135 -0
- package/dist/routes/observations.js.map +1 -0
- package/dist/routes/orgs.d.ts +24 -0
- package/dist/routes/orgs.d.ts.map +1 -0
- package/dist/routes/orgs.js +208 -0
- package/dist/routes/orgs.js.map +1 -0
- package/dist/routes/pagination.d.ts +18 -0
- package/dist/routes/pagination.d.ts.map +1 -0
- package/dist/routes/pagination.js +35 -0
- package/dist/routes/pagination.js.map +1 -0
- package/dist/routes/policies.d.ts +23 -0
- package/dist/routes/policies.d.ts.map +1 -0
- package/dist/routes/policies.js +314 -0
- package/dist/routes/policies.js.map +1 -0
- package/dist/routes/projects.d.ts +45 -0
- package/dist/routes/projects.d.ts.map +1 -0
- package/dist/routes/projects.js +485 -0
- package/dist/routes/projects.js.map +1 -0
- package/dist/routes/proposals.d.ts +24 -0
- package/dist/routes/proposals.d.ts.map +1 -0
- package/dist/routes/proposals.js +581 -0
- package/dist/routes/proposals.js.map +1 -0
- package/dist/routes/provenance.d.ts +34 -0
- package/dist/routes/provenance.d.ts.map +1 -0
- package/dist/routes/provenance.js +274 -0
- package/dist/routes/provenance.js.map +1 -0
- package/dist/routes/providers.d.ts +32 -0
- package/dist/routes/providers.d.ts.map +1 -0
- package/dist/routes/providers.js +490 -0
- package/dist/routes/providers.js.map +1 -0
- package/dist/routes/public-run-tokens.d.ts +17 -0
- package/dist/routes/public-run-tokens.d.ts.map +1 -0
- package/dist/routes/public-run-tokens.js +69 -0
- package/dist/routes/public-run-tokens.js.map +1 -0
- package/dist/routes/retention.d.ts +19 -0
- package/dist/routes/retention.d.ts.map +1 -0
- package/dist/routes/retention.js +152 -0
- package/dist/routes/retention.js.map +1 -0
- package/dist/routes/reviewers.d.ts +5 -0
- package/dist/routes/reviewers.d.ts.map +1 -0
- package/dist/routes/reviewers.js +161 -0
- package/dist/routes/reviewers.js.map +1 -0
- package/dist/routes/runs.d.ts +34 -0
- package/dist/routes/runs.d.ts.map +1 -0
- package/dist/routes/runs.js +773 -0
- package/dist/routes/runs.js.map +1 -0
- package/dist/routes/s3.d.ts +31 -0
- package/dist/routes/s3.d.ts.map +1 -0
- package/dist/routes/s3.js +433 -0
- package/dist/routes/s3.js.map +1 -0
- package/dist/routes/schedules.d.ts +20 -0
- package/dist/routes/schedules.d.ts.map +1 -0
- package/dist/routes/schedules.js +234 -0
- package/dist/routes/schedules.js.map +1 -0
- package/dist/routes/scope-params.d.ts +57 -0
- package/dist/routes/scope-params.d.ts.map +1 -0
- package/dist/routes/scope-params.js +105 -0
- package/dist/routes/scope-params.js.map +1 -0
- package/dist/routes/secret-ref.d.ts +20 -0
- package/dist/routes/secret-ref.d.ts.map +1 -0
- package/dist/routes/secret-ref.js +42 -0
- package/dist/routes/secret-ref.js.map +1 -0
- package/dist/routes/secrets.d.ts +53 -0
- package/dist/routes/secrets.d.ts.map +1 -0
- package/dist/routes/secrets.js +715 -0
- package/dist/routes/secrets.js.map +1 -0
- package/dist/routes/signing-keys.d.ts +23 -0
- package/dist/routes/signing-keys.d.ts.map +1 -0
- package/dist/routes/signing-keys.js +212 -0
- package/dist/routes/signing-keys.js.map +1 -0
- package/dist/routes/sse.d.ts +58 -0
- package/dist/routes/sse.d.ts.map +1 -0
- package/dist/routes/sse.js +92 -0
- package/dist/routes/sse.js.map +1 -0
- package/dist/routes/teams.d.ts +30 -0
- package/dist/routes/teams.d.ts.map +1 -0
- package/dist/routes/teams.js +443 -0
- package/dist/routes/teams.js.map +1 -0
- package/dist/routes/tenant.d.ts +57 -0
- package/dist/routes/tenant.d.ts.map +1 -0
- package/dist/routes/tenant.js +352 -0
- package/dist/routes/tenant.js.map +1 -0
- package/dist/routes/tokens.d.ts +14 -0
- package/dist/routes/tokens.d.ts.map +1 -0
- package/dist/routes/tokens.js +231 -0
- package/dist/routes/tokens.js.map +1 -0
- package/dist/routes/tools.d.ts +33 -0
- package/dist/routes/tools.d.ts.map +1 -0
- package/dist/routes/tools.js +380 -0
- package/dist/routes/tools.js.map +1 -0
- package/dist/routes/webhook-endpoints.d.ts +10 -0
- package/dist/routes/webhook-endpoints.d.ts.map +1 -0
- package/dist/routes/webhook-endpoints.js +407 -0
- package/dist/routes/webhook-endpoints.js.map +1 -0
- package/dist/routes/webhooks.d.ts +21 -0
- package/dist/routes/webhooks.d.ts.map +1 -0
- package/dist/routes/webhooks.js +228 -0
- package/dist/routes/webhooks.js.map +1 -0
- package/dist/s3-credential-binding.d.ts +54 -0
- package/dist/s3-credential-binding.d.ts.map +1 -0
- package/dist/s3-credential-binding.js +4 -0
- package/dist/s3-credential-binding.js.map +1 -0
- package/dist/secrets-binding.d.ts +281 -0
- package/dist/secrets-binding.d.ts.map +1 -0
- package/dist/secrets-binding.js +10 -0
- package/dist/secrets-binding.js.map +1 -0
- package/dist/secrets-provider-binding.d.ts +164 -0
- package/dist/secrets-provider-binding.d.ts.map +1 -0
- package/dist/secrets-provider-binding.js +4 -0
- package/dist/secrets-provider-binding.js.map +1 -0
- package/dist/session-store-binding.d.ts +148 -0
- package/dist/session-store-binding.d.ts.map +1 -0
- package/dist/session-store-binding.js +4 -0
- package/dist/session-store-binding.js.map +1 -0
- package/dist/signing-key-binding.d.ts +210 -0
- package/dist/signing-key-binding.d.ts.map +1 -0
- package/dist/signing-key-binding.js +4 -0
- package/dist/signing-key-binding.js.map +1 -0
- package/dist/state-store-binding.d.ts +53 -0
- package/dist/state-store-binding.d.ts.map +1 -0
- package/dist/state-store-binding.js +38 -0
- package/dist/state-store-binding.js.map +1 -0
- package/dist/supervisor-binding.d.ts +526 -0
- package/dist/supervisor-binding.d.ts.map +1 -0
- package/dist/supervisor-binding.js +4 -0
- package/dist/supervisor-binding.js.map +1 -0
- package/dist/tenant-host-access.d.ts +41 -0
- package/dist/tenant-host-access.d.ts.map +1 -0
- package/dist/tenant-host-access.js +42 -0
- package/dist/tenant-host-access.js.map +1 -0
- package/dist/token-admin.d.ts +99 -0
- package/dist/token-admin.d.ts.map +1 -0
- package/dist/token-admin.js +4 -0
- package/dist/token-admin.js.map +1 -0
- package/dist/tool-binding.d.ts +247 -0
- package/dist/tool-binding.d.ts.map +1 -0
- package/dist/tool-binding.js +4 -0
- package/dist/tool-binding.js.map +1 -0
- package/dist/trigger-binding.d.ts +13 -0
- package/dist/trigger-binding.d.ts.map +1 -0
- package/dist/trigger-binding.js +4 -0
- package/dist/trigger-binding.js.map +1 -0
- package/dist/types.d.ts +71 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +4 -0
- package/dist/types.js.map +1 -0
- package/dist/webhook-endpoint-binding.d.ts +230 -0
- package/dist/webhook-endpoint-binding.d.ts.map +1 -0
- package/dist/webhook-endpoint-binding.js +12 -0
- package/dist/webhook-endpoint-binding.js.map +1 -0
- package/dist/xml.d.ts +79 -0
- package/dist/xml.d.ts.map +1 -0
- package/dist/xml.js +115 -0
- package/dist/xml.js.map +1 -0
- package/openapi.json +29659 -0
- package/package.json +76 -4
- package/scripts/emit-openapi.mjs +44 -0
- package/src/adapter-binding.ts +204 -0
- package/src/agent-binding.ts +231 -0
- package/src/app.ts +1285 -0
- package/src/capability-binding.ts +83 -0
- package/src/cost-binding.ts +213 -0
- package/src/deployment-binding.ts +225 -0
- package/src/env-binding.ts +140 -0
- package/src/errors.ts +291 -0
- package/src/eval-run-binding.ts +209 -0
- package/src/eval-run-dispatcher.ts +497 -0
- package/src/eval-suite-binding.ts +257 -0
- package/src/event-bus-binding.ts +127 -0
- package/src/flow-binding.ts +213 -0
- package/src/guardrail-binding.ts +151 -0
- package/src/handler-binding.ts +132 -0
- package/src/hitl-binding.ts +172 -0
- package/src/identity-directory-binding.ts +128 -0
- package/src/identity-provider-binding.ts +203 -0
- package/src/image-registry-binding.ts +193 -0
- package/src/index.ts +606 -0
- package/src/key-management-binding.ts +91 -0
- package/src/mcp-endpoint-binding.ts +311 -0
- package/src/memory-binding.ts +239 -0
- package/src/middleware/auth.ts +437 -0
- package/src/middleware/authorize.ts +125 -0
- package/src/middleware/error-mapper.ts +37 -0
- package/src/middleware/idempotency.ts +160 -0
- package/src/middleware/principal.ts +64 -0
- package/src/middleware/public-run-routes.ts +50 -0
- package/src/middleware/request-id.ts +28 -0
- package/src/middleware/sigv4-verify.ts +374 -0
- package/src/middleware/sigv4.ts +165 -0
- package/src/openapi/generate.ts +307 -0
- package/src/openapi/operations.ts +5445 -0
- package/src/openapi/schemas.ts +6363 -0
- package/src/provenance-binding.ts +169 -0
- package/src/provider-binding.ts +196 -0
- package/src/public-run-token.ts +263 -0
- package/src/retention-binding.ts +78 -0
- package/src/reviewer-binding.ts +99 -0
- package/src/rotation-status-store.ts +209 -0
- package/src/routes/adapters.ts +319 -0
- package/src/routes/agents.ts +424 -0
- package/src/routes/approvals.ts +759 -0
- package/src/routes/artifacts.ts +317 -0
- package/src/routes/audit.ts +219 -0
- package/src/routes/auth.ts +806 -0
- package/src/routes/capabilities.ts +79 -0
- package/src/routes/compliance.ts +482 -0
- package/src/routes/conversations.ts +369 -0
- package/src/routes/cost.ts +327 -0
- package/src/routes/deployments.ts +1493 -0
- package/src/routes/env.ts +429 -0
- package/src/routes/eval-runs.ts +631 -0
- package/src/routes/eval-suites.ts +490 -0
- package/src/routes/event-triggers.ts +283 -0
- package/src/routes/flows.ts +423 -0
- package/src/routes/guardrails.ts +320 -0
- package/src/routes/identity.ts +203 -0
- package/src/routes/mcp.ts +940 -0
- package/src/routes/memory.ts +430 -0
- package/src/routes/observations.ts +175 -0
- package/src/routes/orgs.ts +273 -0
- package/src/routes/pagination.ts +51 -0
- package/src/routes/policies.ts +413 -0
- package/src/routes/projects.ts +634 -0
- package/src/routes/proposals.ts +719 -0
- package/src/routes/provenance.ts +406 -0
- package/src/routes/providers.ts +624 -0
- package/src/routes/public-run-tokens.ts +104 -0
- package/src/routes/retention.ts +193 -0
- package/src/routes/reviewers.ts +209 -0
- package/src/routes/runs.ts +981 -0
- package/src/routes/s3.ts +519 -0
- package/src/routes/schedules.ts +300 -0
- package/src/routes/scope-params.ts +133 -0
- package/src/routes/secret-ref.ts +52 -0
- package/src/routes/secrets.ts +975 -0
- package/src/routes/signing-keys.ts +259 -0
- package/src/routes/sse.ts +148 -0
- package/src/routes/teams.ts +584 -0
- package/src/routes/tenant.ts +530 -0
- package/src/routes/tokens.ts +285 -0
- package/src/routes/tools.ts +491 -0
- package/src/routes/webhook-endpoints.ts +534 -0
- package/src/routes/webhooks.ts +296 -0
- package/src/s3-credential-binding.ts +58 -0
- package/src/secrets-binding.ts +308 -0
- package/src/secrets-provider-binding.ts +167 -0
- package/src/session-store-binding.ts +163 -0
- package/src/signing-key-binding.ts +235 -0
- package/src/state-store-binding.ts +84 -0
- package/src/supervisor-binding.ts +554 -0
- package/src/tenant-host-access.ts +62 -0
- package/src/token-admin.ts +104 -0
- package/src/tool-binding.ts +274 -0
- package/src/trigger-binding.ts +38 -0
- package/src/types.ts +74 -0
- package/src/webhook-endpoint-binding.ts +246 -0
- package/src/xml.ts +196 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
|
|
6
|
+
import type { Cursor, TenantId } from '@kindgi/types';
|
|
7
|
+
|
|
8
|
+
import type { CapabilityDescriptor, CapabilityRegistryBinding } from '../capability-binding.js';
|
|
9
|
+
import { statusFor, toWireError } from '../errors.js';
|
|
10
|
+
import type { AppEnv } from '../types.js';
|
|
11
|
+
import { clampLimit } from './pagination.js';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Capabilities resource routes — part of the admin control plane.
|
|
15
|
+
* Read-only. Capabilities are framework-declared
|
|
16
|
+
* (see `@kindgi/specs/capability.schema.json` + `@kindgi/capabilities.FEATURES`)
|
|
17
|
+
* and deployment-extended at boot time via the caller-plugged
|
|
18
|
+
* `CapabilityRegistryBinding`. Tenants do NOT author capabilities via
|
|
19
|
+
* the HTTP surface — that would fork the closed-enum feature set the
|
|
20
|
+
* router depends on.
|
|
21
|
+
*/
|
|
22
|
+
export function capabilitiesRouter(binding: CapabilityRegistryBinding): Hono<AppEnv> {
|
|
23
|
+
const r = new Hono<AppEnv>();
|
|
24
|
+
|
|
25
|
+
// ---------- GET / (list, cursor-paginated) ----------
|
|
26
|
+
r.get('/', async (c) => {
|
|
27
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
28
|
+
const limit = clampLimit(c.req.query('limit'));
|
|
29
|
+
|
|
30
|
+
const cursorRaw = c.req.query('cursor');
|
|
31
|
+
const featureRaw = c.req.query('feature');
|
|
32
|
+
const page = await binding.list({
|
|
33
|
+
tenantId,
|
|
34
|
+
limit,
|
|
35
|
+
...(cursorRaw !== undefined && cursorRaw.length > 0 && { cursor: cursorRaw as Cursor }),
|
|
36
|
+
...(featureRaw !== undefined && featureRaw.length > 0 && { featureFilter: featureRaw }),
|
|
37
|
+
});
|
|
38
|
+
return c.json({
|
|
39
|
+
data: page.data.map(serializeCapability),
|
|
40
|
+
hasMore: page.nextCursor !== undefined,
|
|
41
|
+
...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// ---------- GET /:capabilityId ----------
|
|
46
|
+
r.get('/:capabilityId', async (c) => {
|
|
47
|
+
const requestId = c.get('requestId');
|
|
48
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
49
|
+
const capabilityId = c.req.param('capabilityId');
|
|
50
|
+
|
|
51
|
+
const descriptor = await binding.get({ tenantId, capabilityId });
|
|
52
|
+
if (descriptor === null) {
|
|
53
|
+
c.status(statusFor('capability-not-found') as never);
|
|
54
|
+
return c.json(
|
|
55
|
+
toWireError(
|
|
56
|
+
{
|
|
57
|
+
code: 'capability-not-found',
|
|
58
|
+
message: `No capability registered with id "${capabilityId}"`,
|
|
59
|
+
capabilityId,
|
|
60
|
+
},
|
|
61
|
+
requestId,
|
|
62
|
+
),
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
return c.json(serializeCapability(descriptor));
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
return r;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function serializeCapability(d: CapabilityDescriptor): Record<string, unknown> {
|
|
72
|
+
return {
|
|
73
|
+
id: d.id,
|
|
74
|
+
feature: d.feature,
|
|
75
|
+
description: d.description,
|
|
76
|
+
...(d.kind !== undefined && { kind: d.kind }),
|
|
77
|
+
...(d.paramsSchema !== undefined && { paramsSchema: d.paramsSchema }),
|
|
78
|
+
};
|
|
79
|
+
}
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
|
|
6
|
+
import type { AuditEvent, AuditEventBinding, AuditEventFilter } from '@kindgi/audit-events';
|
|
7
|
+
import type {
|
|
8
|
+
ComplianceEvidence,
|
|
9
|
+
ComplianceEvidenceGenerator,
|
|
10
|
+
EvidenceFilter,
|
|
11
|
+
LoadedClassifier,
|
|
12
|
+
} from '@kindgi/compliance';
|
|
13
|
+
import { auditEventToEvidence } from '@kindgi/compliance';
|
|
14
|
+
import type { SigningKeyBinding } from '@kindgi/crypto';
|
|
15
|
+
import type {
|
|
16
|
+
AgentId,
|
|
17
|
+
ComplianceEvidenceId,
|
|
18
|
+
FlowId,
|
|
19
|
+
RunId,
|
|
20
|
+
SigningKeyId,
|
|
21
|
+
TenantId,
|
|
22
|
+
Timestamp,
|
|
23
|
+
} from '@kindgi/types';
|
|
24
|
+
|
|
25
|
+
import { statusFor, toWireError } from '../errors.js';
|
|
26
|
+
import type { AppEnv } from '../types.js';
|
|
27
|
+
import { clampLimit } from './pagination.js';
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Compliance-evidence readback + signed-export routes over the unified
|
|
31
|
+
* audit substrate.
|
|
32
|
+
*
|
|
33
|
+
* List + get read audit events via `AuditEventBinding`, filtered to
|
|
34
|
+
* classifier-marked exportable kinds. Signed export
|
|
35
|
+
* delegates to the generator bound to the same substrate + the
|
|
36
|
+
* caller-plugged `SigningKeyBinding` — verifiers reuse the identical
|
|
37
|
+
* Ed25519 envelope the provenance + audit-bundle surfaces produce.
|
|
38
|
+
*
|
|
39
|
+
* Every route is tenant-scoped via the bearer middleware upstream; the
|
|
40
|
+
* binding is threaded `tenantId` explicitly so its own storage layer
|
|
41
|
+
* enforces cross-tenant isolation redundantly. Idempotency-Key applies
|
|
42
|
+
* to the export mutation (same shape every other export route follows).
|
|
43
|
+
*/
|
|
44
|
+
export interface ComplianceRouterOptions {
|
|
45
|
+
readonly auditEvents: AuditEventBinding;
|
|
46
|
+
readonly classifier: LoadedClassifier;
|
|
47
|
+
readonly signingKey?: SigningKeyBinding;
|
|
48
|
+
/**
|
|
49
|
+
* Caller-plugged evidence generator. Supplied at app-composition
|
|
50
|
+
* time by the host (the Kindgi runtime provides one). Kept
|
|
51
|
+
* required — signed export routes cannot run without it, and the
|
|
52
|
+
* route mount guards (auditEvents + classifier) already imply
|
|
53
|
+
* signed-export capability.
|
|
54
|
+
*/
|
|
55
|
+
readonly complianceGenerator: ComplianceEvidenceGenerator;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export function complianceRouter(options: ComplianceRouterOptions): Hono<AppEnv> {
|
|
59
|
+
const r = new Hono<AppEnv>();
|
|
60
|
+
const { auditEvents, classifier, signingKey, complianceGenerator } = options;
|
|
61
|
+
|
|
62
|
+
const isExportable = (kind: string): boolean => classifier.resolve(kind).exportable;
|
|
63
|
+
const exportableKinds = (): readonly string[] =>
|
|
64
|
+
Object.keys(classifier.file.byKind).filter(isExportable);
|
|
65
|
+
|
|
66
|
+
// ---------- GET /evidence (list, cursor-paginated) ----------
|
|
67
|
+
r.get('/evidence', async (c) => {
|
|
68
|
+
const requestId = c.get('requestId');
|
|
69
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
70
|
+
const limit = clampLimit(c.req.query('limit'));
|
|
71
|
+
const rawCursor = c.req.query('cursor');
|
|
72
|
+
const cursor = rawCursor !== undefined && rawCursor.length > 0 ? rawCursor : undefined;
|
|
73
|
+
|
|
74
|
+
const parsedFilter = parseFilterFromQuery(c.req.query());
|
|
75
|
+
if (parsedFilter.kind === 'err') {
|
|
76
|
+
c.status(statusFor('bad-input') as never);
|
|
77
|
+
return c.json(toWireError({ code: 'bad-input', message: parsedFilter.message }, requestId));
|
|
78
|
+
}
|
|
79
|
+
const auditFilter = buildAuditFilter(parsedFilter.value, exportableKinds());
|
|
80
|
+
if (auditFilter === null) {
|
|
81
|
+
// Kind filter narrowed to a non-exportable kind — surface empty.
|
|
82
|
+
return c.json({ data: [], hasMore: false });
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
const page = await auditEvents.query({
|
|
86
|
+
tenantId,
|
|
87
|
+
filter: auditFilter,
|
|
88
|
+
...(cursor !== undefined && { cursor }),
|
|
89
|
+
limit,
|
|
90
|
+
});
|
|
91
|
+
if (page.kind === 'err') {
|
|
92
|
+
if (page.error.code === 'invalid-cursor') {
|
|
93
|
+
c.status(statusFor('bad-input') as never);
|
|
94
|
+
return c.json(
|
|
95
|
+
toWireError(
|
|
96
|
+
{ code: 'bad-input', message: `Malformed cursor: ${page.error.message}` },
|
|
97
|
+
requestId,
|
|
98
|
+
),
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
c.status(statusFor('persistence-error') as never);
|
|
102
|
+
return c.json(
|
|
103
|
+
toWireError(
|
|
104
|
+
{
|
|
105
|
+
code: 'persistence-error',
|
|
106
|
+
message: `Failed to list compliance evidence: ${page.error.message}`,
|
|
107
|
+
},
|
|
108
|
+
requestId,
|
|
109
|
+
),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
// Post-filter to exportable kinds (defensive — in case a binding
|
|
114
|
+
// does not apply the `kinds` filter).
|
|
115
|
+
const filtered = page.value.data.filter((e) => isExportable(e.kind));
|
|
116
|
+
return c.json({
|
|
117
|
+
data: filtered.map(serializeEvent),
|
|
118
|
+
hasMore: page.value.nextCursor !== undefined,
|
|
119
|
+
...(page.value.nextCursor !== undefined && { nextCursor: page.value.nextCursor }),
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
// ---------- GET /evidence/:evidenceId ----------
|
|
124
|
+
r.get('/evidence/:evidenceId', async (c) => {
|
|
125
|
+
const requestId = c.get('requestId');
|
|
126
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
127
|
+
const evidenceId = c.req.param('evidenceId');
|
|
128
|
+
|
|
129
|
+
const fetched = await auditEvents.query({
|
|
130
|
+
tenantId,
|
|
131
|
+
filter: { id: evidenceId },
|
|
132
|
+
limit: 2,
|
|
133
|
+
});
|
|
134
|
+
if (fetched.kind === 'err') {
|
|
135
|
+
c.status(statusFor('persistence-error') as never);
|
|
136
|
+
return c.json(
|
|
137
|
+
toWireError(
|
|
138
|
+
{
|
|
139
|
+
code: 'persistence-error',
|
|
140
|
+
message: `Failed to fetch compliance evidence: ${fetched.error.message}`,
|
|
141
|
+
},
|
|
142
|
+
requestId,
|
|
143
|
+
),
|
|
144
|
+
);
|
|
145
|
+
}
|
|
146
|
+
const hit = fetched.value.data.find((e) => e.id === evidenceId && isExportable(e.kind));
|
|
147
|
+
if (hit === undefined) {
|
|
148
|
+
c.status(statusFor('compliance-evidence-not-found') as never);
|
|
149
|
+
return c.json(
|
|
150
|
+
toWireError(
|
|
151
|
+
{
|
|
152
|
+
code: 'compliance-evidence-not-found',
|
|
153
|
+
message: `No evidence record with id "${evidenceId}" under this tenant.`,
|
|
154
|
+
evidenceId,
|
|
155
|
+
},
|
|
156
|
+
requestId,
|
|
157
|
+
),
|
|
158
|
+
);
|
|
159
|
+
}
|
|
160
|
+
return c.json(serializeEvent(hit));
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
// ---------- POST /evidence/export (signed bundle) ----------
|
|
164
|
+
r.post('/evidence/export', async (c) => {
|
|
165
|
+
const requestId = c.get('requestId');
|
|
166
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
167
|
+
|
|
168
|
+
if (signingKey === undefined) {
|
|
169
|
+
c.status(statusFor('signing-not-configured') as never);
|
|
170
|
+
return c.json(
|
|
171
|
+
toWireError(
|
|
172
|
+
{
|
|
173
|
+
code: 'signing-not-configured',
|
|
174
|
+
message:
|
|
175
|
+
'This deployment does not have a `signingKey` binding mounted; signed compliance exports are unavailable.',
|
|
176
|
+
},
|
|
177
|
+
requestId,
|
|
178
|
+
),
|
|
179
|
+
);
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
let body: unknown;
|
|
183
|
+
try {
|
|
184
|
+
body = await c.req.json();
|
|
185
|
+
} catch {
|
|
186
|
+
c.status(statusFor('bad-input') as never);
|
|
187
|
+
return c.json(
|
|
188
|
+
toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId),
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
if (body === null || typeof body !== 'object' || Array.isArray(body)) {
|
|
192
|
+
c.status(statusFor('bad-input') as never);
|
|
193
|
+
return c.json(
|
|
194
|
+
toWireError({ code: 'bad-input', message: 'Request body must be an object' }, requestId),
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
const parsed = parseExportBody(body as Record<string, unknown>);
|
|
198
|
+
if (parsed.kind === 'err') {
|
|
199
|
+
c.status(statusFor('bad-input') as never);
|
|
200
|
+
return c.json(toWireError({ code: 'bad-input', message: parsed.message }, requestId));
|
|
201
|
+
}
|
|
202
|
+
const { signingKeyId } = parsed.value;
|
|
203
|
+
// The bundle carries exportable kinds only: a named non-exportable
|
|
204
|
+
// kind is rejected below; without one, the classifier's exportable
|
|
205
|
+
// kinds are passed down (and recorded in the signed bundle's filter).
|
|
206
|
+
const filter =
|
|
207
|
+
parsed.value.filter.evidenceKind !== undefined
|
|
208
|
+
? parsed.value.filter
|
|
209
|
+
: { ...parsed.value.filter, evidenceKinds: exportableKinds() };
|
|
210
|
+
if (
|
|
211
|
+
filter.evidenceKind !== undefined &&
|
|
212
|
+
!isExportable(filter.evidenceKind as unknown as string)
|
|
213
|
+
) {
|
|
214
|
+
c.status(statusFor('bad-input') as never);
|
|
215
|
+
return c.json(
|
|
216
|
+
toWireError(
|
|
217
|
+
{
|
|
218
|
+
code: 'bad-input',
|
|
219
|
+
message: `Kind "${filter.evidenceKind as unknown as string}" is not marked exportable by the classifier`,
|
|
220
|
+
},
|
|
221
|
+
requestId,
|
|
222
|
+
),
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
const generator = complianceGenerator;
|
|
227
|
+
const bundle = await generator.exportSigned(tenantId, filter, signingKeyId);
|
|
228
|
+
if (bundle.kind === 'err') {
|
|
229
|
+
const err = bundle.error;
|
|
230
|
+
if (err.code === 'signing-key-missing') {
|
|
231
|
+
c.status(statusFor('signing-key-not-found') as never);
|
|
232
|
+
return c.json(
|
|
233
|
+
toWireError(
|
|
234
|
+
{
|
|
235
|
+
code: 'signing-key-not-found',
|
|
236
|
+
message: err.message,
|
|
237
|
+
signingKeyId: err.signingKeyId as unknown as string,
|
|
238
|
+
},
|
|
239
|
+
requestId,
|
|
240
|
+
),
|
|
241
|
+
);
|
|
242
|
+
}
|
|
243
|
+
if (err.code === 'signing-failure') {
|
|
244
|
+
c.status(statusFor('compliance-export-failed') as never);
|
|
245
|
+
return c.json(
|
|
246
|
+
toWireError(
|
|
247
|
+
{
|
|
248
|
+
code: 'compliance-export-failed',
|
|
249
|
+
message: err.message,
|
|
250
|
+
signingKeyId: err.signingKeyId as unknown as string,
|
|
251
|
+
},
|
|
252
|
+
requestId,
|
|
253
|
+
),
|
|
254
|
+
);
|
|
255
|
+
}
|
|
256
|
+
if (err.code === 'persistence-error') {
|
|
257
|
+
c.status(statusFor('persistence-error') as never);
|
|
258
|
+
return c.json(toWireError({ code: 'persistence-error', message: err.message }, requestId));
|
|
259
|
+
}
|
|
260
|
+
c.status(statusFor('compliance-export-failed') as never);
|
|
261
|
+
return c.json(
|
|
262
|
+
toWireError(
|
|
263
|
+
{
|
|
264
|
+
code: 'compliance-export-failed',
|
|
265
|
+
message: `Signed export failed: ${(err as { readonly message: string }).message}`,
|
|
266
|
+
},
|
|
267
|
+
requestId,
|
|
268
|
+
),
|
|
269
|
+
);
|
|
270
|
+
}
|
|
271
|
+
return c.json(bundle.value);
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
return r;
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
// -----------------------------------------------------------------------------
|
|
278
|
+
// helpers
|
|
279
|
+
// -----------------------------------------------------------------------------
|
|
280
|
+
|
|
281
|
+
type ParseResult<T> =
|
|
282
|
+
| { readonly kind: 'ok'; readonly value: T }
|
|
283
|
+
| { readonly kind: 'err'; readonly message: string };
|
|
284
|
+
|
|
285
|
+
function parseFilterFromQuery(
|
|
286
|
+
query: Readonly<Record<string, string | undefined>>,
|
|
287
|
+
): ParseResult<EvidenceFilter | undefined> {
|
|
288
|
+
const filter: {
|
|
289
|
+
runId?: RunId;
|
|
290
|
+
agentId?: AgentId;
|
|
291
|
+
flowId?: FlowId;
|
|
292
|
+
evidenceKind?: EvidenceFilter['evidenceKind'];
|
|
293
|
+
from?: Timestamp;
|
|
294
|
+
to?: Timestamp;
|
|
295
|
+
} = {};
|
|
296
|
+
const runId = query.runId;
|
|
297
|
+
if (runId !== undefined && runId.length > 0) filter.runId = runId as unknown as RunId;
|
|
298
|
+
const agentId = query.agentId;
|
|
299
|
+
if (agentId !== undefined && agentId.length > 0) filter.agentId = agentId as unknown as AgentId;
|
|
300
|
+
const flowId = query.flowId;
|
|
301
|
+
if (flowId !== undefined && flowId.length > 0) filter.flowId = flowId as unknown as FlowId;
|
|
302
|
+
const kind = query.kind;
|
|
303
|
+
if (kind !== undefined && kind.length > 0) {
|
|
304
|
+
filter.evidenceKind = kind as unknown as EvidenceFilter['evidenceKind'];
|
|
305
|
+
}
|
|
306
|
+
const from = query.from;
|
|
307
|
+
if (from !== undefined && from.length > 0) {
|
|
308
|
+
const parsed = new Date(from);
|
|
309
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
310
|
+
return { kind: 'err', message: '`from` must be an ISO 8601 timestamp' };
|
|
311
|
+
}
|
|
312
|
+
filter.from = parsed.toISOString() as Timestamp;
|
|
313
|
+
}
|
|
314
|
+
const to = query.to;
|
|
315
|
+
if (to !== undefined && to.length > 0) {
|
|
316
|
+
const parsed = new Date(to);
|
|
317
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
318
|
+
return { kind: 'err', message: '`to` must be an ISO 8601 timestamp' };
|
|
319
|
+
}
|
|
320
|
+
filter.to = parsed.toISOString() as Timestamp;
|
|
321
|
+
}
|
|
322
|
+
const empty = Object.keys(filter).length === 0;
|
|
323
|
+
return { kind: 'ok', value: empty ? undefined : (filter as EvidenceFilter) };
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Build the `AuditEventFilter` used against the binding. Returns
|
|
328
|
+
* `null` when the caller's `evidenceKind` is not exportable — the
|
|
329
|
+
* route short-circuits to an empty page in that case (rather than
|
|
330
|
+
* inventing a filter that would return non-exportable rows).
|
|
331
|
+
*/
|
|
332
|
+
function buildAuditFilter(
|
|
333
|
+
filter: EvidenceFilter | undefined,
|
|
334
|
+
exportable: readonly string[],
|
|
335
|
+
): AuditEventFilter | null {
|
|
336
|
+
const out: {
|
|
337
|
+
-readonly [K in keyof AuditEventFilter]: AuditEventFilter[K];
|
|
338
|
+
} = {};
|
|
339
|
+
if (filter?.evidenceKind !== undefined) {
|
|
340
|
+
const k = filter.evidenceKind as unknown as string;
|
|
341
|
+
if (!exportable.includes(k)) return null;
|
|
342
|
+
out.kind = k;
|
|
343
|
+
} else {
|
|
344
|
+
out.kinds = exportable;
|
|
345
|
+
}
|
|
346
|
+
if (filter?.runId !== undefined) out.runId = filter.runId as unknown as string;
|
|
347
|
+
if (filter?.agentId !== undefined) out.agentId = filter.agentId as unknown as string;
|
|
348
|
+
if (filter?.flowId !== undefined) out.flowId = filter.flowId as unknown as string;
|
|
349
|
+
if (filter?.from !== undefined) out.from = filter.from as unknown as string;
|
|
350
|
+
if (filter?.to !== undefined) out.to = filter.to as unknown as string;
|
|
351
|
+
return out as AuditEventFilter;
|
|
352
|
+
}
|
|
353
|
+
|
|
354
|
+
interface ValidatedExportBody {
|
|
355
|
+
readonly signingKeyId: SigningKeyId;
|
|
356
|
+
readonly filter: EvidenceFilter;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
function parseExportBody(body: Record<string, unknown>): ParseResult<ValidatedExportBody> {
|
|
360
|
+
const rawKey = body.signingKeyId;
|
|
361
|
+
if (typeof rawKey !== 'string' || rawKey.length === 0) {
|
|
362
|
+
return { kind: 'err', message: 'Field `signingKeyId` must be a non-empty string' };
|
|
363
|
+
}
|
|
364
|
+
const filterRaw = body.filter;
|
|
365
|
+
if (
|
|
366
|
+
filterRaw !== undefined &&
|
|
367
|
+
(filterRaw === null || typeof filterRaw !== 'object' || Array.isArray(filterRaw))
|
|
368
|
+
) {
|
|
369
|
+
return { kind: 'err', message: 'Field `filter` must be an object when present' };
|
|
370
|
+
}
|
|
371
|
+
const parsedFilter = parseFilterFromBody((filterRaw ?? {}) as Record<string, unknown>);
|
|
372
|
+
if (parsedFilter.kind === 'err') return parsedFilter;
|
|
373
|
+
return {
|
|
374
|
+
kind: 'ok',
|
|
375
|
+
value: {
|
|
376
|
+
signingKeyId: rawKey as SigningKeyId,
|
|
377
|
+
filter: parsedFilter.value ?? {},
|
|
378
|
+
},
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function parseFilterFromBody(
|
|
383
|
+
body: Record<string, unknown>,
|
|
384
|
+
): ParseResult<EvidenceFilter | undefined> {
|
|
385
|
+
const filter: {
|
|
386
|
+
runId?: RunId;
|
|
387
|
+
agentId?: AgentId;
|
|
388
|
+
flowId?: FlowId;
|
|
389
|
+
evidenceKind?: EvidenceFilter['evidenceKind'];
|
|
390
|
+
from?: Timestamp;
|
|
391
|
+
to?: Timestamp;
|
|
392
|
+
} = {};
|
|
393
|
+
const runId = body.runId;
|
|
394
|
+
if (runId !== undefined) {
|
|
395
|
+
if (typeof runId !== 'string' || runId.length === 0) {
|
|
396
|
+
return { kind: 'err', message: '`filter.runId` must be a non-empty string' };
|
|
397
|
+
}
|
|
398
|
+
filter.runId = runId as unknown as RunId;
|
|
399
|
+
}
|
|
400
|
+
const agentId = body.agentId;
|
|
401
|
+
if (agentId !== undefined) {
|
|
402
|
+
if (typeof agentId !== 'string' || agentId.length === 0) {
|
|
403
|
+
return { kind: 'err', message: '`filter.agentId` must be a non-empty string' };
|
|
404
|
+
}
|
|
405
|
+
filter.agentId = agentId as unknown as AgentId;
|
|
406
|
+
}
|
|
407
|
+
const flowId = body.flowId;
|
|
408
|
+
if (flowId !== undefined) {
|
|
409
|
+
if (typeof flowId !== 'string' || flowId.length === 0) {
|
|
410
|
+
return { kind: 'err', message: '`filter.flowId` must be a non-empty string' };
|
|
411
|
+
}
|
|
412
|
+
filter.flowId = flowId as unknown as FlowId;
|
|
413
|
+
}
|
|
414
|
+
const kind = body.kind;
|
|
415
|
+
if (kind !== undefined) {
|
|
416
|
+
if (typeof kind !== 'string' || kind.length === 0) {
|
|
417
|
+
return { kind: 'err', message: '`filter.kind` must be a non-empty string' };
|
|
418
|
+
}
|
|
419
|
+
filter.evidenceKind = kind as unknown as EvidenceFilter['evidenceKind'];
|
|
420
|
+
}
|
|
421
|
+
const from = body.from;
|
|
422
|
+
if (from !== undefined) {
|
|
423
|
+
if (typeof from !== 'string' || Number.isNaN(new Date(from).getTime())) {
|
|
424
|
+
return { kind: 'err', message: '`filter.from` must be an ISO 8601 timestamp' };
|
|
425
|
+
}
|
|
426
|
+
filter.from = new Date(from).toISOString() as Timestamp;
|
|
427
|
+
}
|
|
428
|
+
const to = body.to;
|
|
429
|
+
if (to !== undefined) {
|
|
430
|
+
if (typeof to !== 'string' || Number.isNaN(new Date(to).getTime())) {
|
|
431
|
+
return { kind: 'err', message: '`filter.to` must be an ISO 8601 timestamp' };
|
|
432
|
+
}
|
|
433
|
+
filter.to = new Date(to).toISOString() as Timestamp;
|
|
434
|
+
}
|
|
435
|
+
const empty = Object.keys(filter).length === 0;
|
|
436
|
+
return { kind: 'ok', value: empty ? undefined : (filter as EvidenceFilter) };
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
interface WireEvidence {
|
|
440
|
+
readonly id: string;
|
|
441
|
+
readonly tenantId: string;
|
|
442
|
+
readonly projectId?: string;
|
|
443
|
+
readonly kind: string;
|
|
444
|
+
readonly timestamp: string;
|
|
445
|
+
readonly actor?: unknown;
|
|
446
|
+
readonly subject?: unknown;
|
|
447
|
+
readonly outcome?: unknown;
|
|
448
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
449
|
+
readonly provenanceRef?: unknown;
|
|
450
|
+
readonly signature?: unknown;
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
/**
|
|
454
|
+
* Serialize an `AuditEvent` into the wire shape the compliance
|
|
455
|
+
* consumers expect. Wraps `auditEventToEvidence` so clients that read
|
|
456
|
+
* `ComplianceEvidence` see exactly the `ComplianceEvidence` shape.
|
|
457
|
+
*/
|
|
458
|
+
function serializeEvent(event: AuditEvent): WireEvidence {
|
|
459
|
+
return serializeEvidence(auditEventToEvidence(event));
|
|
460
|
+
}
|
|
461
|
+
|
|
462
|
+
function serializeEvidence(e: ComplianceEvidence): WireEvidence {
|
|
463
|
+
const out: Record<string, unknown> = {
|
|
464
|
+
id: e.id as unknown as string,
|
|
465
|
+
tenantId: e.tenantId as unknown as string,
|
|
466
|
+
kind: e.kind,
|
|
467
|
+
timestamp: e.timestamp as unknown as string,
|
|
468
|
+
payload: e.payload,
|
|
469
|
+
};
|
|
470
|
+
if (e.projectId !== undefined) out.projectId = e.projectId as unknown as string;
|
|
471
|
+
if (e.actor !== undefined) out.actor = e.actor;
|
|
472
|
+
if (e.subject !== undefined) out.subject = e.subject;
|
|
473
|
+
if (e.outcome !== undefined) out.outcome = e.outcome;
|
|
474
|
+
if (e.provenanceRef !== undefined) out.provenanceRef = e.provenanceRef;
|
|
475
|
+
if (e.signature !== undefined) out.signature = e.signature;
|
|
476
|
+
return out as unknown as WireEvidence;
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
// Kept for potential downstream use — the id path lookup returns
|
|
480
|
+
// `evidenceId` param verbatim; module consumers may rely on these
|
|
481
|
+
// re-exports.
|
|
482
|
+
export type { ComplianceEvidenceId };
|