@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,169 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
//
|
|
5
|
+
// Provenance binding surface — types + `ProvenanceBinding` interface
|
|
6
|
+
// consumed by the provenance routes. Deployments plug in an
|
|
7
|
+
// implementation (the Kindgi runtime provides one); @kindgi/api never
|
|
8
|
+
// touches provenance storage directly.
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
import type { FlowId, ProvenanceId, Result, RunId, TenantId, Timestamp } from '@kindgi/types';
|
|
12
|
+
|
|
13
|
+
// ---------- domain type surface ----------
|
|
14
|
+
|
|
15
|
+
export const NODE_KINDS = [
|
|
16
|
+
'input',
|
|
17
|
+
'prompt',
|
|
18
|
+
'retrieval',
|
|
19
|
+
'tool-call',
|
|
20
|
+
'tool-result',
|
|
21
|
+
'model-call',
|
|
22
|
+
'model-output',
|
|
23
|
+
'artifact',
|
|
24
|
+
'guardrail-check',
|
|
25
|
+
'event',
|
|
26
|
+
'policy-decision',
|
|
27
|
+
'memory-read',
|
|
28
|
+
'memory-write',
|
|
29
|
+
'wait',
|
|
30
|
+
'resume',
|
|
31
|
+
] as const;
|
|
32
|
+
|
|
33
|
+
export type NodeKind = (typeof NODE_KINDS)[number];
|
|
34
|
+
|
|
35
|
+
export const EDGE_KINDS = [
|
|
36
|
+
'caused-by',
|
|
37
|
+
'influenced-by',
|
|
38
|
+
'retrieved-from',
|
|
39
|
+
'invoked',
|
|
40
|
+
'produced',
|
|
41
|
+
'checked-against',
|
|
42
|
+
'waited-on',
|
|
43
|
+
'resumed-from',
|
|
44
|
+
] as const;
|
|
45
|
+
|
|
46
|
+
export type EdgeKind = (typeof EDGE_KINDS)[number];
|
|
47
|
+
|
|
48
|
+
export interface ProvenanceNode {
|
|
49
|
+
readonly id: string;
|
|
50
|
+
readonly kind: NodeKind;
|
|
51
|
+
readonly timestamp: Timestamp;
|
|
52
|
+
readonly actor?: string;
|
|
53
|
+
readonly contentHash?: string;
|
|
54
|
+
readonly contentRef?: string;
|
|
55
|
+
readonly modelVersion?: string;
|
|
56
|
+
readonly policyDecisionId?: string;
|
|
57
|
+
readonly attributes?: Readonly<Record<string, unknown>>;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ProvenanceEdge {
|
|
61
|
+
readonly from: string;
|
|
62
|
+
readonly to: string;
|
|
63
|
+
readonly kind: EdgeKind;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface Signature {
|
|
67
|
+
readonly algorithm: 'ed25519';
|
|
68
|
+
readonly keyId: string;
|
|
69
|
+
readonly value: string;
|
|
70
|
+
readonly signedAt: Timestamp;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export interface Provenance {
|
|
74
|
+
readonly id: ProvenanceId;
|
|
75
|
+
readonly runId: RunId;
|
|
76
|
+
readonly tenantId: TenantId;
|
|
77
|
+
readonly version: string;
|
|
78
|
+
readonly createdAt: Timestamp;
|
|
79
|
+
readonly flowRef?: { readonly id: FlowId; readonly version: string };
|
|
80
|
+
readonly nodes: readonly ProvenanceNode[];
|
|
81
|
+
readonly edges: readonly ProvenanceEdge[];
|
|
82
|
+
readonly signature?: Signature;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// ---------- method inputs / outputs ----------
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* Keyset cursor for `listRecords`. Decoded shape — routes handle the
|
|
89
|
+
* base64 encoding envelope (`./routes/pagination.ts`). Binding consumers
|
|
90
|
+
* pass the decoded pair through so the binding never touches route-layer
|
|
91
|
+
* encoding conventions.
|
|
92
|
+
*/
|
|
93
|
+
export interface ProvenanceListCursor {
|
|
94
|
+
readonly createdAt: string;
|
|
95
|
+
readonly id: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export interface ListProvenanceRecordsInput {
|
|
99
|
+
readonly tenantId: TenantId;
|
|
100
|
+
readonly limit: number;
|
|
101
|
+
readonly runId?: RunId;
|
|
102
|
+
readonly agentId?: string;
|
|
103
|
+
readonly createdAfter?: Date;
|
|
104
|
+
readonly cursor?: ProvenanceListCursor;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Denormalized record metadata used by `GET /v1/provenance` list. Full
|
|
109
|
+
* DAG (`nodes`, `edges`) is fetched only via `getByRunId` — list only
|
|
110
|
+
* exposes summary rows.
|
|
111
|
+
*/
|
|
112
|
+
export interface ProvenanceRecordSummary {
|
|
113
|
+
readonly id: ProvenanceId;
|
|
114
|
+
readonly runId: RunId;
|
|
115
|
+
readonly tenantId: TenantId;
|
|
116
|
+
readonly version: string;
|
|
117
|
+
readonly createdAt: Timestamp;
|
|
118
|
+
readonly flowRef?: { readonly id: FlowId; readonly version: string };
|
|
119
|
+
readonly signed: boolean;
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export interface ListProvenanceRecordsResult {
|
|
123
|
+
readonly records: readonly ProvenanceRecordSummary[];
|
|
124
|
+
readonly nextCursor?: ProvenanceListCursor;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
// ---------- error shape ----------
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* Structural error surface returned by `ProvenanceBinding` methods.
|
|
131
|
+
* Implementations emit codes `provenance-not-found` + `persistence-error`
|
|
132
|
+
* — the routes pass them through to `statusFor()` / `toWireError()`.
|
|
133
|
+
*/
|
|
134
|
+
export interface ProvenanceBindingError {
|
|
135
|
+
readonly code: string;
|
|
136
|
+
readonly message: string;
|
|
137
|
+
readonly [key: string]: unknown;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// ---------- binding ----------
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Provenance data-access binding. Every method takes typed inputs and
|
|
144
|
+
* returns `Promise<Result<T, ProvenanceBindingError>>` — the
|
|
145
|
+
* implementation owns its storage client, so callers never touch
|
|
146
|
+
* storage directly.
|
|
147
|
+
*/
|
|
148
|
+
export interface ProvenanceBinding {
|
|
149
|
+
/**
|
|
150
|
+
* List provenance records, keyset-paginated by
|
|
151
|
+
* `(createdAt desc, id desc)`. Optional filters narrow by run, agent
|
|
152
|
+
* (node actor), and creation window. Returns already-shaped
|
|
153
|
+
* `ProvenanceRecordSummary` rows — the binding owns the storage →
|
|
154
|
+
* wire projection.
|
|
155
|
+
*
|
|
156
|
+
* The result carries `nextCursor` when more records exist; the route
|
|
157
|
+
* derives `hasMore` from it and encodes it as the next cursor.
|
|
158
|
+
*/
|
|
159
|
+
listRecords(
|
|
160
|
+
input: ListProvenanceRecordsInput,
|
|
161
|
+
): Promise<Result<ListProvenanceRecordsResult, ProvenanceBindingError>>;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Reconstruct the full provenance DAG for a run. Returns
|
|
165
|
+
* `provenance-not-found` (via `code`) when no record exists for the
|
|
166
|
+
* tenant/run pair.
|
|
167
|
+
*/
|
|
168
|
+
getByRunId(tenantId: TenantId, runId: RunId): Promise<Result<Provenance, ProvenanceBindingError>>;
|
|
169
|
+
}
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import type { AdapterConfig, ProviderMetadata } from '@kindgi/capabilities';
|
|
5
|
+
import type { Cursor, TenantId } from '@kindgi/types';
|
|
6
|
+
|
|
7
|
+
import type { CapabilityDescriptor } from './capability-binding.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Caller-plugged surface for the model-provider catalog — part of the
|
|
11
|
+
* admin control plane. Full CRUD: tenants register
|
|
12
|
+
* their own providers (hosted model APIs, self-hosted inference servers,
|
|
13
|
+
* embedding backends, sandbox-exec fleets, ...). The runtime's capability
|
|
14
|
+
* router consults the registered set at run time to pick a best-fit
|
|
15
|
+
* provider per capability requirement.
|
|
16
|
+
*
|
|
17
|
+
* `ProviderMetadata` is the **wire shape** — no secrets (API keys,
|
|
18
|
+
* endpoints, credentials) cross the HTTP boundary. Secrets stay inside
|
|
19
|
+
* the binding implementation; the wire surface returns only routing-
|
|
20
|
+
* relevant metadata: provider-level `id` / `region` / `attributes` /
|
|
21
|
+
* `capabilityKind` + `models[]` (each entry carries `name`,
|
|
22
|
+
* `contextWindow`, `features`, `cost`, optional `p95LatencyMs`,
|
|
23
|
+
* `maxOutputTokens`, `description`).
|
|
24
|
+
*
|
|
25
|
+
* Every method is tenant-scoped: callers pass `tenantId` explicitly so
|
|
26
|
+
* multi-tenant deployments can partition storage without exposing that
|
|
27
|
+
* scoping inside the API package.
|
|
28
|
+
*
|
|
29
|
+
* Cursors are opaque — the binding chooses its encoding. The API layer
|
|
30
|
+
* only validates round-trip as a string; it never inspects the payload.
|
|
31
|
+
*/
|
|
32
|
+
export interface ProviderRegistryBinding {
|
|
33
|
+
/**
|
|
34
|
+
* Cursor-paginated list of registered providers. Optional
|
|
35
|
+
* `featureFilter` narrows the result to providers that self-report
|
|
36
|
+
* support for the given capability feature — same semantics as the
|
|
37
|
+
* `?feature=` query param on the route.
|
|
38
|
+
*/
|
|
39
|
+
list(input: ProviderListInput): Promise<ProviderPage>;
|
|
40
|
+
/**
|
|
41
|
+
* Fetch a provider by id, or `null` when unknown. The route surfaces
|
|
42
|
+
* `null` as `404 provider-not-found`.
|
|
43
|
+
*/
|
|
44
|
+
get(input: ProviderGetInput): Promise<ProviderMetadata | null>;
|
|
45
|
+
/**
|
|
46
|
+
* Register a provider under the given tenant. The route validates
|
|
47
|
+
* the wire shape via the `@kindgi/capabilities` runtime rules
|
|
48
|
+
* before calling — the binding receives well-formed metadata.
|
|
49
|
+
* Bindings MAY reject with `already-registered` when the same
|
|
50
|
+
* `providerId` is re-registered; the route maps that to `409`.
|
|
51
|
+
*/
|
|
52
|
+
register(input: ProviderRegisterInput): Promise<ProviderRegisterOutcome>;
|
|
53
|
+
/**
|
|
54
|
+
* Remove a specific provider. Returns `{ unregistered: true }` on
|
|
55
|
+
* success; `{ unregistered: false }` when the id was unknown — the
|
|
56
|
+
* route flips the latter to `404`.
|
|
57
|
+
*/
|
|
58
|
+
unregister(input: ProviderUnregisterInput): Promise<ProviderUnregisterOutcome>;
|
|
59
|
+
/**
|
|
60
|
+
* Sub-resource: return the catalog capabilities this provider
|
|
61
|
+
* satisfies. Returns `null` when the provider is unknown so the
|
|
62
|
+
* route can flip that to `404 provider-not-found`. An empty array
|
|
63
|
+
* is a valid answer for a known provider with no matches.
|
|
64
|
+
*/
|
|
65
|
+
capabilitiesFor(
|
|
66
|
+
input: ProviderCapabilitiesForInput,
|
|
67
|
+
): Promise<readonly CapabilityDescriptor[] | null>;
|
|
68
|
+
/**
|
|
69
|
+
* Bulk-read for the runtime bridge. Returns every
|
|
70
|
+
* provider registered under `tenantId` bundled with the fields the
|
|
71
|
+
* runtime needs to instantiate a `ModelProvider`: the routing
|
|
72
|
+
* metadata (`metadata`), which adapter package to invoke
|
|
73
|
+
* (`adapterId`), and where to resolve the API key from
|
|
74
|
+
* (`secretRef`, optional).
|
|
75
|
+
*
|
|
76
|
+
* Consumed by the runtime at agent-turn start; separate from `list`
|
|
77
|
+
* because HTTP callers of `list` see only the wire-safe metadata,
|
|
78
|
+
* not the plumbing fields.
|
|
79
|
+
*/
|
|
80
|
+
resolveForRuntime(
|
|
81
|
+
input: ProviderResolveForRuntimeInput,
|
|
82
|
+
): Promise<readonly ProviderRuntimeEntry[]>;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ProviderListInput {
|
|
86
|
+
readonly tenantId: TenantId;
|
|
87
|
+
readonly limit: number;
|
|
88
|
+
readonly cursor?: Cursor;
|
|
89
|
+
/**
|
|
90
|
+
* Filter to providers whose `metadata.features` includes this feature
|
|
91
|
+
* name. Exact match, not prefix — `Feature` is a closed enum, so
|
|
92
|
+
* partial matches would over-match noisily.
|
|
93
|
+
*/
|
|
94
|
+
readonly featureFilter?: string;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export interface ProviderGetInput {
|
|
98
|
+
readonly tenantId: TenantId;
|
|
99
|
+
readonly providerId: string;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export interface ProviderRegisterInput {
|
|
103
|
+
readonly tenantId: TenantId;
|
|
104
|
+
readonly metadata: ProviderMetadata;
|
|
105
|
+
/**
|
|
106
|
+
* Identifies which adapter package instantiates the `ModelProvider`
|
|
107
|
+
* at invoke time (runtime bridge). MUST reference an adapter
|
|
108
|
+
* previously registered for this tenant (see `AdapterRegistryBinding`)
|
|
109
|
+
* — implementations reject an unknown adapter at register time
|
|
110
|
+
* rather than at agent-invoke time.
|
|
111
|
+
*/
|
|
112
|
+
readonly adapterId: string;
|
|
113
|
+
/**
|
|
114
|
+
* Optional pointer to the tenant-scoped secret carrying the
|
|
115
|
+
* adapter's credential. Shape: `{envName, name}`. The runtime bridge
|
|
116
|
+
* resolves it through the secrets binding for the calling tenant —
|
|
117
|
+
* tenant scoping applies at resolve time, so this ref is
|
|
118
|
+
* tenant-agnostic. Absent when the adapter needs no external
|
|
119
|
+
* credentials (dev-echo, local models).
|
|
120
|
+
*/
|
|
121
|
+
readonly secretRef?: ProviderSecretRef;
|
|
122
|
+
/**
|
|
123
|
+
* The adapter's connection settings (a cloud project, a base URL):
|
|
124
|
+
* flat, non-secret values the adapter factory receives as `config`.
|
|
125
|
+
* Like `secretRef`, plumbing — stored with the provider and handed
|
|
126
|
+
* to the runtime, never returned by `list` / `get`.
|
|
127
|
+
*/
|
|
128
|
+
readonly adapterConfig?: AdapterConfig;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export interface ProviderSecretRef {
|
|
132
|
+
readonly envName: string;
|
|
133
|
+
readonly name: string;
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/**
|
|
137
|
+
* Runtime-side persistence view bundled for the runtime bridge.
|
|
138
|
+
* `list`/`get` on the binding return the wire-safe `ProviderMetadata`
|
|
139
|
+
* only; this shape adds the plumbing fields (`adapterId`,
|
|
140
|
+
* `secretRef`) the runtime needs to instantiate a `ModelProvider`.
|
|
141
|
+
*
|
|
142
|
+
* Consumed by the runtime at agent-turn start via
|
|
143
|
+
* `resolveForRuntime`.
|
|
144
|
+
*/
|
|
145
|
+
export interface ProviderRuntimeEntry {
|
|
146
|
+
readonly metadata: ProviderMetadata;
|
|
147
|
+
readonly adapterId: string;
|
|
148
|
+
readonly secretRef?: ProviderSecretRef;
|
|
149
|
+
readonly adapterConfig?: AdapterConfig;
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
export interface ProviderResolveForRuntimeInput {
|
|
153
|
+
readonly tenantId: TenantId;
|
|
154
|
+
/**
|
|
155
|
+
* Optional capability-kind filter. When present, returns only
|
|
156
|
+
* providers whose declared `capabilityKind` matches — mirrors the
|
|
157
|
+
* router's own kind gate and lets the runtime bridge skip
|
|
158
|
+
* instantiating irrelevant providers.
|
|
159
|
+
*/
|
|
160
|
+
readonly capabilityKind?: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export interface ProviderUnregisterInput {
|
|
164
|
+
readonly tenantId: TenantId;
|
|
165
|
+
readonly providerId: string;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface ProviderCapabilitiesForInput {
|
|
169
|
+
readonly tenantId: TenantId;
|
|
170
|
+
readonly providerId: string;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface ProviderPage {
|
|
174
|
+
readonly data: readonly ProviderMetadata[];
|
|
175
|
+
readonly nextCursor?: Cursor;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
export type ProviderRegisterOutcome =
|
|
179
|
+
| {
|
|
180
|
+
readonly kind: 'ok';
|
|
181
|
+
readonly providerId: string;
|
|
182
|
+
}
|
|
183
|
+
| {
|
|
184
|
+
readonly kind: 'already-registered';
|
|
185
|
+
readonly providerId: string;
|
|
186
|
+
}
|
|
187
|
+
| {
|
|
188
|
+
readonly kind: 'invalid';
|
|
189
|
+
readonly providerId: string;
|
|
190
|
+
readonly message: string;
|
|
191
|
+
readonly reason?: string;
|
|
192
|
+
};
|
|
193
|
+
|
|
194
|
+
export type ProviderUnregisterOutcome = {
|
|
195
|
+
readonly unregistered: boolean;
|
|
196
|
+
};
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import { type SigningKeyBinding, signEd25519, verifyEd25519 } from '@kindgi/crypto';
|
|
5
|
+
import type { RunId, SigningKeyId, TenantId } from '@kindgi/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Public run tokens: short-lived, read-only tokens that let a browser
|
|
9
|
+
* follow specific runs (`GET /v1/runs/{runId}/progress` and its event stream) with
|
|
10
|
+
* nothing else allowed. The application's backend obtains one when it
|
|
11
|
+
* starts a run (`POST /v1/runs` returns `publicAccessToken`) or mints one
|
|
12
|
+
* (`POST /v1/tokens/public`), and hands it to the browser.
|
|
13
|
+
*
|
|
14
|
+
* Wire form: `kgi_pt_<base64url payload>.<base64url signature>`.
|
|
15
|
+
* - payload: JSON `{ v: 1, kid, tenantId, runIds, iat, exp }` (seconds);
|
|
16
|
+
* - signature: Ed25519 over the ASCII bytes of `kgi_pt_<base64url payload>`,
|
|
17
|
+
* by the key `kid` in the deployment's `SigningKeyBinding`.
|
|
18
|
+
*
|
|
19
|
+
* Stateless: nothing is stored. A token stops working when it expires;
|
|
20
|
+
* removing its key from the binding revokes every token signed with it.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
export const PUBLIC_RUN_TOKEN_PREFIX = 'kgi_pt_';
|
|
24
|
+
|
|
25
|
+
/** A token's lifetime when the caller doesn't choose one: 15 minutes. */
|
|
26
|
+
export const DEFAULT_PUBLIC_RUN_TOKEN_TTL_SECONDS = 900;
|
|
27
|
+
/** The longest lifetime a token can have: 24 hours. */
|
|
28
|
+
export const MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS = 86_400;
|
|
29
|
+
/** Runs one token can name. */
|
|
30
|
+
export const MAX_PUBLIC_RUN_TOKEN_RUNS = 50;
|
|
31
|
+
|
|
32
|
+
/** Tolerated clock difference for a token issued "in the future" (seconds). */
|
|
33
|
+
const CLOCK_SKEW_SECONDS = 60;
|
|
34
|
+
const PAYLOAD_VERSION = 1;
|
|
35
|
+
|
|
36
|
+
/** How a deployment issues and checks public run tokens. */
|
|
37
|
+
export interface PublicRunTokenConfig {
|
|
38
|
+
/** Key store holding the Ed25519 signing key(s). */
|
|
39
|
+
readonly signingKey: SigningKeyBinding;
|
|
40
|
+
/**
|
|
41
|
+
* The key new tokens are signed with. Tokens signed with another key in
|
|
42
|
+
* the binding stay valid until they expire, so keys rotate by adding
|
|
43
|
+
* the new key, switching `keyId`, and removing the old key a day later.
|
|
44
|
+
*/
|
|
45
|
+
readonly keyId: SigningKeyId;
|
|
46
|
+
/** Default lifetime; {@link DEFAULT_PUBLIC_RUN_TOKEN_TTL_SECONDS} when absent. */
|
|
47
|
+
readonly defaultTtlSeconds?: number;
|
|
48
|
+
/** Longest lifetime a mint may ask for; at most {@link MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS}. */
|
|
49
|
+
readonly maxTtlSeconds?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Browser origins (e.g. `https://app.example.com`) allowed to call the
|
|
52
|
+
* routes a public run token can use, cross-origin. Absent or empty: no
|
|
53
|
+
* CORS headers are sent.
|
|
54
|
+
*/
|
|
55
|
+
readonly allowedOrigins?: readonly string[];
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** What a verified token grants. */
|
|
59
|
+
export interface PublicRunTokenClaims {
|
|
60
|
+
readonly keyId: SigningKeyId;
|
|
61
|
+
readonly tenantId: TenantId;
|
|
62
|
+
/** The runs the token may read; their descendants are readable too. */
|
|
63
|
+
readonly runIds: readonly RunId[];
|
|
64
|
+
readonly issuedAt: Date;
|
|
65
|
+
readonly expiresAt: Date;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export interface MintPublicRunTokenInput {
|
|
69
|
+
readonly signingKey: SigningKeyBinding;
|
|
70
|
+
readonly keyId: SigningKeyId;
|
|
71
|
+
readonly tenantId: TenantId;
|
|
72
|
+
readonly runIds: readonly RunId[];
|
|
73
|
+
readonly ttlSeconds: number;
|
|
74
|
+
/** Clock in milliseconds; default `Date.now`. */
|
|
75
|
+
readonly now?: () => number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export type MintPublicRunTokenResult =
|
|
79
|
+
| { readonly kind: 'ok'; readonly token: string; readonly expiresAt: Date }
|
|
80
|
+
| {
|
|
81
|
+
readonly kind: 'err';
|
|
82
|
+
readonly reason: 'unknown-key' | 'invalid-input';
|
|
83
|
+
readonly message: string;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export type VerifyPublicRunTokenFailure = 'malformed' | 'unknown-key' | 'bad-signature' | 'expired';
|
|
87
|
+
|
|
88
|
+
export type VerifyPublicRunTokenResult =
|
|
89
|
+
| { readonly kind: 'ok'; readonly claims: PublicRunTokenClaims }
|
|
90
|
+
| { readonly kind: 'err'; readonly reason: VerifyPublicRunTokenFailure };
|
|
91
|
+
|
|
92
|
+
interface Payload {
|
|
93
|
+
readonly v: number;
|
|
94
|
+
readonly kid: string;
|
|
95
|
+
readonly tenantId: string;
|
|
96
|
+
readonly runIds: readonly string[];
|
|
97
|
+
readonly iat: number;
|
|
98
|
+
readonly exp: number;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Sign a token for `runIds` in `tenantId`, valid for `ttlSeconds`. */
|
|
102
|
+
export function mintPublicRunToken(input: MintPublicRunTokenInput): MintPublicRunTokenResult {
|
|
103
|
+
if (
|
|
104
|
+
input.runIds.length === 0 ||
|
|
105
|
+
input.runIds.length > MAX_PUBLIC_RUN_TOKEN_RUNS ||
|
|
106
|
+
!Number.isInteger(input.ttlSeconds) ||
|
|
107
|
+
input.ttlSeconds <= 0 ||
|
|
108
|
+
input.ttlSeconds > MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS
|
|
109
|
+
) {
|
|
110
|
+
return {
|
|
111
|
+
kind: 'err',
|
|
112
|
+
reason: 'invalid-input',
|
|
113
|
+
message: `a token names 1–${MAX_PUBLIC_RUN_TOKEN_RUNS} runs and lives 1–${MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS} seconds`,
|
|
114
|
+
};
|
|
115
|
+
}
|
|
116
|
+
const privateKey = ed25519Key(input.signingKey, input.keyId, 'private');
|
|
117
|
+
if (privateKey === null) {
|
|
118
|
+
return {
|
|
119
|
+
kind: 'err',
|
|
120
|
+
reason: 'unknown-key',
|
|
121
|
+
message: `no Ed25519 signing key "${input.keyId as unknown as string}" in the binding`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
const iat = Math.floor((input.now ?? Date.now)() / 1000);
|
|
125
|
+
const payload: Payload = {
|
|
126
|
+
v: PAYLOAD_VERSION,
|
|
127
|
+
kid: input.keyId as unknown as string,
|
|
128
|
+
tenantId: input.tenantId as unknown as string,
|
|
129
|
+
runIds: input.runIds.map((id) => id as unknown as string),
|
|
130
|
+
iat,
|
|
131
|
+
exp: iat + input.ttlSeconds,
|
|
132
|
+
};
|
|
133
|
+
const signed = `${PUBLIC_RUN_TOKEN_PREFIX}${Buffer.from(JSON.stringify(payload)).toString('base64url')}`;
|
|
134
|
+
const signature = signEd25519(privateKey, Buffer.from(signed, 'ascii'));
|
|
135
|
+
if (signature.kind === 'err') {
|
|
136
|
+
return { kind: 'err', reason: 'unknown-key', message: signature.error.message };
|
|
137
|
+
}
|
|
138
|
+
return {
|
|
139
|
+
kind: 'ok',
|
|
140
|
+
token: `${signed}.${Buffer.from(signature.value).toString('base64url')}`,
|
|
141
|
+
expiresAt: new Date(payload.exp * 1000),
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/** Check a token's form, signature and lifetime. Never throws. */
|
|
146
|
+
export function verifyPublicRunToken(
|
|
147
|
+
token: string,
|
|
148
|
+
options: { readonly signingKey: SigningKeyBinding; readonly now?: () => number },
|
|
149
|
+
): VerifyPublicRunTokenResult {
|
|
150
|
+
if (!token.startsWith(PUBLIC_RUN_TOKEN_PREFIX)) return fail('malformed');
|
|
151
|
+
const dot = token.lastIndexOf('.');
|
|
152
|
+
if (dot <= PUBLIC_RUN_TOKEN_PREFIX.length) return fail('malformed');
|
|
153
|
+
const signed = token.slice(0, dot);
|
|
154
|
+
const payloadPart = signed.slice(PUBLIC_RUN_TOKEN_PREFIX.length);
|
|
155
|
+
const signaturePart = token.slice(dot + 1);
|
|
156
|
+
if (!BASE64URL.test(payloadPart) || !BASE64URL.test(signaturePart)) return fail('malformed');
|
|
157
|
+
|
|
158
|
+
const payload = parsePayload(payloadPart);
|
|
159
|
+
if (payload === null) return fail('malformed');
|
|
160
|
+
|
|
161
|
+
const keyId = payload.kid as SigningKeyId;
|
|
162
|
+
const publicKey = ed25519Key(options.signingKey, keyId, 'public');
|
|
163
|
+
if (publicKey === null) return fail('unknown-key');
|
|
164
|
+
const verified = verifyEd25519(
|
|
165
|
+
publicKey,
|
|
166
|
+
Buffer.from(signed, 'ascii'),
|
|
167
|
+
Buffer.from(signaturePart, 'base64url'),
|
|
168
|
+
);
|
|
169
|
+
if (verified.kind === 'err' || !verified.value) return fail('bad-signature');
|
|
170
|
+
|
|
171
|
+
const now = Math.floor((options.now ?? Date.now)() / 1000);
|
|
172
|
+
if (now >= payload.exp || payload.iat > now + CLOCK_SKEW_SECONDS) return fail('expired');
|
|
173
|
+
|
|
174
|
+
return {
|
|
175
|
+
kind: 'ok',
|
|
176
|
+
claims: {
|
|
177
|
+
keyId,
|
|
178
|
+
tenantId: payload.tenantId as TenantId,
|
|
179
|
+
runIds: payload.runIds as readonly RunId[],
|
|
180
|
+
issuedAt: new Date(payload.iat * 1000),
|
|
181
|
+
expiresAt: new Date(payload.exp * 1000),
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Check a deployment's configuration at startup: the signing key exists
|
|
188
|
+
* and is Ed25519, and the lifetimes are in range. Returns the effective
|
|
189
|
+
* lifetimes; throws on a misconfiguration so the server fails to start.
|
|
190
|
+
*/
|
|
191
|
+
export function resolvePublicRunTokenConfig(config: PublicRunTokenConfig): {
|
|
192
|
+
readonly defaultTtlSeconds: number;
|
|
193
|
+
readonly maxTtlSeconds: number;
|
|
194
|
+
} {
|
|
195
|
+
if (ed25519Key(config.signingKey, config.keyId, 'private') === null) {
|
|
196
|
+
throw new Error(
|
|
197
|
+
`publicRunTokens: no Ed25519 key "${config.keyId as unknown as string}" with a private key in signingKey`,
|
|
198
|
+
);
|
|
199
|
+
}
|
|
200
|
+
const maxTtlSeconds = config.maxTtlSeconds ?? MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS;
|
|
201
|
+
const defaultTtlSeconds = config.defaultTtlSeconds ?? DEFAULT_PUBLIC_RUN_TOKEN_TTL_SECONDS;
|
|
202
|
+
if (
|
|
203
|
+
!Number.isInteger(maxTtlSeconds) ||
|
|
204
|
+
maxTtlSeconds <= 0 ||
|
|
205
|
+
maxTtlSeconds > MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS
|
|
206
|
+
) {
|
|
207
|
+
throw new Error(
|
|
208
|
+
`publicRunTokens.maxTtlSeconds must be an integer in 1–${MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS}`,
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
if (
|
|
212
|
+
!Number.isInteger(defaultTtlSeconds) ||
|
|
213
|
+
defaultTtlSeconds <= 0 ||
|
|
214
|
+
defaultTtlSeconds > maxTtlSeconds
|
|
215
|
+
) {
|
|
216
|
+
throw new Error('publicRunTokens.defaultTtlSeconds must be an integer in 1–maxTtlSeconds');
|
|
217
|
+
}
|
|
218
|
+
return { defaultTtlSeconds, maxTtlSeconds };
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const BASE64URL = /^[A-Za-z0-9_-]+$/;
|
|
222
|
+
|
|
223
|
+
function fail(reason: VerifyPublicRunTokenFailure): VerifyPublicRunTokenResult {
|
|
224
|
+
return { kind: 'err', reason };
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The key's bytes when the binding holds it as an Ed25519 key; else `null`. */
|
|
228
|
+
function ed25519Key(
|
|
229
|
+
binding: SigningKeyBinding,
|
|
230
|
+
keyId: SigningKeyId,
|
|
231
|
+
side: 'public' | 'private',
|
|
232
|
+
): Uint8Array | null {
|
|
233
|
+
const descriptor = binding.listKeys().find((key) => key.keyId === keyId);
|
|
234
|
+
if (descriptor === undefined || descriptor.algorithm !== 'ed25519') return null;
|
|
235
|
+
return side === 'public' ? binding.getPublicKey(keyId) : binding.getPrivateKey(keyId);
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
function parsePayload(encoded: string): Payload | null {
|
|
239
|
+
let value: unknown;
|
|
240
|
+
try {
|
|
241
|
+
value = JSON.parse(Buffer.from(encoded, 'base64url').toString('utf-8'));
|
|
242
|
+
} catch {
|
|
243
|
+
return null;
|
|
244
|
+
}
|
|
245
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) return null;
|
|
246
|
+
const p = value as Record<string, unknown>;
|
|
247
|
+
const runIds = p.runIds;
|
|
248
|
+
const valid =
|
|
249
|
+
p.v === PAYLOAD_VERSION &&
|
|
250
|
+
typeof p.kid === 'string' &&
|
|
251
|
+
p.kid.length > 0 &&
|
|
252
|
+
typeof p.tenantId === 'string' &&
|
|
253
|
+
p.tenantId.length > 0 &&
|
|
254
|
+
Array.isArray(runIds) &&
|
|
255
|
+
runIds.length > 0 &&
|
|
256
|
+
runIds.length <= MAX_PUBLIC_RUN_TOKEN_RUNS &&
|
|
257
|
+
runIds.every((id) => typeof id === 'string' && id.length > 0) &&
|
|
258
|
+
Number.isInteger(p.iat) &&
|
|
259
|
+
Number.isInteger(p.exp) &&
|
|
260
|
+
(p.exp as number) > (p.iat as number) &&
|
|
261
|
+
(p.exp as number) - (p.iat as number) <= MAX_PUBLIC_RUN_TOKEN_TTL_SECONDS;
|
|
262
|
+
return valid ? (p as unknown as Payload) : null;
|
|
263
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import type { RetentionDomain } from '@kindgi/policy-contract';
|
|
5
|
+
import type { TenantId } from '@kindgi/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Caller-plugged surface for the retention pipeline — the API routes
|
|
9
|
+
* (`/v1/retention/scheduled`, `/v1/retention/sweep`,
|
|
10
|
+
* `/v1/retention/sweep/:domain`) call this binding; the Kindgi runtime
|
|
11
|
+
* provides an implementation backed by its retention executor.
|
|
12
|
+
*
|
|
13
|
+
* Wire shape is deliberately kept minimal — the deep types (candidates,
|
|
14
|
+
* per-domain entries, missing-adapter marker) live in the runtime. The
|
|
15
|
+
* api package keeps a leaner projection here so the route body is easy
|
|
16
|
+
* to reason about.
|
|
17
|
+
*/
|
|
18
|
+
export interface RetentionBinding {
|
|
19
|
+
/**
|
|
20
|
+
* Enumerate tombstoned rows across every domain with an adapter
|
|
21
|
+
* registered. `pastGraceOnly = false` returns both in-grace and
|
|
22
|
+
* past-grace candidates — the "Scheduled for deletion" view uses
|
|
23
|
+
* that. `true` returns only rows the sweeper would purge right now.
|
|
24
|
+
*/
|
|
25
|
+
scheduled(input: RetentionScheduledInput): Promise<RetentionScheduledPage>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* Trigger a sweep across every domain (or `domain` if provided).
|
|
29
|
+
* Idempotent — a second call after a successful sweep returns
|
|
30
|
+
* `purged: 0` per domain.
|
|
31
|
+
*/
|
|
32
|
+
sweep(input: RetentionSweepInput): Promise<RetentionSweepResult>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export interface RetentionScheduledInput {
|
|
36
|
+
readonly tenantId: TenantId;
|
|
37
|
+
readonly domain?: RetentionDomain;
|
|
38
|
+
readonly limit: number;
|
|
39
|
+
readonly pastGraceOnly?: boolean;
|
|
40
|
+
readonly now?: Date;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface RetentionScheduledItem {
|
|
44
|
+
readonly domain: RetentionDomain;
|
|
45
|
+
readonly id: string;
|
|
46
|
+
readonly unregisteredAt: string;
|
|
47
|
+
readonly purgeAt: string;
|
|
48
|
+
readonly pastGrace: boolean;
|
|
49
|
+
readonly policyId: string;
|
|
50
|
+
readonly policyVersion: string;
|
|
51
|
+
readonly graceSeconds: number;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export interface RetentionScheduledPage {
|
|
55
|
+
readonly data: readonly RetentionScheduledItem[];
|
|
56
|
+
/** Domains a retention policy exists for but no adapter is wired in this deployment. */
|
|
57
|
+
readonly domainsMissingAdapter: readonly RetentionDomain[];
|
|
58
|
+
/** Domains that have an adapter but no matching policy — tombstones sit forever. */
|
|
59
|
+
readonly unpolicedDomains: readonly RetentionDomain[];
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
export interface RetentionSweepInput {
|
|
63
|
+
readonly tenantId: TenantId;
|
|
64
|
+
readonly domain?: RetentionDomain;
|
|
65
|
+
readonly maxPerDomain?: number;
|
|
66
|
+
readonly now?: Date;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export interface RetentionSweepResult {
|
|
70
|
+
readonly perDomain: readonly {
|
|
71
|
+
readonly domain: RetentionDomain;
|
|
72
|
+
readonly purged: number;
|
|
73
|
+
readonly remaining: number;
|
|
74
|
+
readonly policyId?: string;
|
|
75
|
+
readonly missingAdapter?: true;
|
|
76
|
+
}[];
|
|
77
|
+
readonly totalPurged: number;
|
|
78
|
+
}
|