@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,99 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import type { ReviewerRole } from '@kindgi/authz';
|
|
5
|
+
import type { Cursor, ReviewerId, TenantId, Timestamp, UserId } from '@kindgi/types';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Translates the bearer-token identity (`UserId`) into the `ReviewerId`
|
|
9
|
+
* that `HitlBinding.submitReview` needs. The API package intentionally does
|
|
10
|
+
* NOT own the `user ↔ reviewer` mapping — deployments plug that in via
|
|
11
|
+
* this binding, same pattern as `TokenResolver` (for auth read) and
|
|
12
|
+
* `TokenAdmin` (for mint/revoke).
|
|
13
|
+
*
|
|
14
|
+
* Return `null` when the user has no registered reviewer row for the
|
|
15
|
+
* tenant (leads to `403 permission-denied` from the approvals route).
|
|
16
|
+
*/
|
|
17
|
+
export interface ReviewerBinding {
|
|
18
|
+
resolveReviewer(input: ReviewerLookupInput): Promise<ReviewerId | null>;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface ReviewerLookupInput {
|
|
22
|
+
readonly tenantId: TenantId;
|
|
23
|
+
readonly userId: UserId;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// ================ ReviewerRegistryBinding ================
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Caller-plugged surface for the reviewer roster. Same pattern as
|
|
30
|
+
* `AgentRegistryBinding` / `ToolRegistryBinding`: the API package does
|
|
31
|
+
* NOT own persistence. Deployments wire the runtime's reviewer store —
|
|
32
|
+
* or their own — through this binding.
|
|
33
|
+
*
|
|
34
|
+
* Distinct from `ReviewerBinding` (which resolves a token's `UserId` to
|
|
35
|
+
* a `ReviewerId`): a deployment may want a durable registry backend for
|
|
36
|
+
* the roster surface while keeping the resolver in-process. Callers
|
|
37
|
+
* mount them independently.
|
|
38
|
+
*/
|
|
39
|
+
export interface ReviewerRegistryBinding {
|
|
40
|
+
list(input: ReviewerListInput): Promise<ReviewerPage>;
|
|
41
|
+
get(input: ReviewerGetInput): Promise<ReviewerRecord | null>;
|
|
42
|
+
register(input: ReviewerRegisterInput): Promise<ReviewerRegisterOutcome>;
|
|
43
|
+
/**
|
|
44
|
+
* Unregister a reviewer. Semantic is "soft-delete / deactivate" so
|
|
45
|
+
* the audit trail survives — reviewer stops receiving approvals but
|
|
46
|
+
* historical decisions still resolve. Returns
|
|
47
|
+
* `{ unregistered: false }` when the id is unknown; the route flips
|
|
48
|
+
* that to `404`.
|
|
49
|
+
*/
|
|
50
|
+
unregister(input: ReviewerUnregisterInput): Promise<ReviewerUnregisterOutcome>;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface ReviewerListInput {
|
|
54
|
+
readonly tenantId: TenantId;
|
|
55
|
+
readonly limit: number;
|
|
56
|
+
readonly cursor?: Cursor;
|
|
57
|
+
readonly role?: ReviewerRole;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export interface ReviewerGetInput {
|
|
61
|
+
readonly tenantId: TenantId;
|
|
62
|
+
readonly reviewerId: ReviewerId;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface ReviewerRegisterInput {
|
|
66
|
+
readonly tenantId: TenantId;
|
|
67
|
+
readonly userId: UserId;
|
|
68
|
+
readonly role: ReviewerRole;
|
|
69
|
+
readonly displayName?: string;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export interface ReviewerUnregisterInput {
|
|
73
|
+
readonly tenantId: TenantId;
|
|
74
|
+
readonly reviewerId: ReviewerId;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface ReviewerRecord {
|
|
78
|
+
readonly id: ReviewerId;
|
|
79
|
+
readonly tenantId: TenantId;
|
|
80
|
+
readonly userId: UserId;
|
|
81
|
+
readonly role: ReviewerRole;
|
|
82
|
+
readonly displayName?: string;
|
|
83
|
+
readonly createdAt: Timestamp;
|
|
84
|
+
readonly deactivatedAt?: Timestamp;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export interface ReviewerPage {
|
|
88
|
+
readonly data: readonly ReviewerRecord[];
|
|
89
|
+
readonly nextCursor?: Cursor;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type ReviewerRegisterOutcome = {
|
|
93
|
+
readonly kind: 'ok';
|
|
94
|
+
readonly reviewer: ReviewerRecord;
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export type ReviewerUnregisterOutcome = {
|
|
98
|
+
readonly unregistered: boolean;
|
|
99
|
+
};
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import { randomUUID } from 'node:crypto';
|
|
5
|
+
|
|
6
|
+
import type { Scope } from '@kindgi/platform';
|
|
7
|
+
import type { EnvName } from '@kindgi/types';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Rotation-status store — durable substrate for the
|
|
11
|
+
* async-rotation wire. When a
|
|
12
|
+
* `SecretProviderBinding.rotateSecret` call returns the
|
|
13
|
+
* `rotation-pending` variant, the HTTP route mints a `rotationId` via
|
|
14
|
+
* this store, records the pending status, and returns 202 with a
|
|
15
|
+
* `statusUrl` + `eventsUrl` a caller can poll or subscribe to.
|
|
16
|
+
*
|
|
17
|
+
* A background reaper (not owned by this store) drives the pending
|
|
18
|
+
* rotation to terminal by polling the provider with the recorded
|
|
19
|
+
* `resumeToken`, then calling `update({ status: 'succeeded' | 'failed',
|
|
20
|
+
* … })`. Subscribed SSE streams receive the update via `subscribe`.
|
|
21
|
+
*
|
|
22
|
+
* The bundled implementation (`createInMemoryRotationStatusStore`) is
|
|
23
|
+
* in-memory only (dev + tests). Production deployments plug in a durable
|
|
24
|
+
* adapter that survives process restarts — an async rotation can take
|
|
25
|
+
* minutes to hours, so process-local state is not sufficient.
|
|
26
|
+
*/
|
|
27
|
+
export interface RotationStatusStore {
|
|
28
|
+
/**
|
|
29
|
+
* Mint a new rotation-status row. Returns the freshly-minted
|
|
30
|
+
* `rotationId` (UUID) that the wire response echoes back to the
|
|
31
|
+
* caller. `resumeToken` + `provider` are the opaque provider-side
|
|
32
|
+
* handles the reaper uses to poll the async workflow; the wire
|
|
33
|
+
* response NEVER exposes them.
|
|
34
|
+
*/
|
|
35
|
+
create(input: RotationStatusCreateInput): Promise<{ readonly rotationId: string }>;
|
|
36
|
+
|
|
37
|
+
/** Read the current status, or `null` when unknown / cross-scope. */
|
|
38
|
+
get(input: RotationStatusGetInput): Promise<RotationStatus | null>;
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Terminal-transition write. Called by the reaper (or an explicit
|
|
42
|
+
* admin op) when the async workflow completes. Publishes to every
|
|
43
|
+
* live SSE subscription for the `rotationId`.
|
|
44
|
+
*/
|
|
45
|
+
update(input: RotationStatusUpdateInput): Promise<void>;
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Subscribe to lifecycle updates for a single `rotationId`. Returns
|
|
49
|
+
* an unsubscribe function that the caller MUST call on stream close
|
|
50
|
+
* / client disconnect to avoid memory leaks.
|
|
51
|
+
*/
|
|
52
|
+
subscribe(input: RotationStatusSubscribeInput): () => void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface RotationStatusCreateInput {
|
|
56
|
+
readonly scope: Scope;
|
|
57
|
+
readonly envName: EnvName;
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly provider: string;
|
|
60
|
+
readonly resumeToken: string;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export interface RotationStatusGetInput {
|
|
64
|
+
readonly scope: Scope;
|
|
65
|
+
readonly envName: EnvName;
|
|
66
|
+
readonly name: string;
|
|
67
|
+
readonly rotationId: string;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export interface RotationStatusUpdateInput {
|
|
71
|
+
readonly rotationId: string;
|
|
72
|
+
readonly status: 'succeeded' | 'failed';
|
|
73
|
+
readonly newVersionId?: number;
|
|
74
|
+
readonly oldVersionId?: number;
|
|
75
|
+
readonly error?: string;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export interface RotationStatusSubscribeInput {
|
|
79
|
+
readonly rotationId: string;
|
|
80
|
+
readonly onUpdate: (status: RotationStatus) => void;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* Wire-safe rotation-status shape. `startedAt` + `updatedAt` are ISO
|
|
85
|
+
* 8601 strings. Terminal states populate `newVersionId` /
|
|
86
|
+
* `oldVersionId` (on `succeeded`) or `error` (on `failed`); pending
|
|
87
|
+
* states leave them absent.
|
|
88
|
+
*/
|
|
89
|
+
export interface RotationStatus {
|
|
90
|
+
readonly rotationId: string;
|
|
91
|
+
readonly status: 'pending' | 'succeeded' | 'failed';
|
|
92
|
+
readonly startedAt: string;
|
|
93
|
+
readonly updatedAt: string;
|
|
94
|
+
readonly newVersionId?: number;
|
|
95
|
+
readonly oldVersionId?: number;
|
|
96
|
+
readonly error?: string;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* In-memory reference `RotationStatusStore` — dev + tests only.
|
|
101
|
+
* Retains a `Map<rotationId, InternalRow>` for the lifetime of the
|
|
102
|
+
* process; multi-pod deployments MUST plug in a durable adapter (the
|
|
103
|
+
* rotation-status row must survive between the pod that minted the
|
|
104
|
+
* `rotationId` and any pod handling a poll or SSE subscribe).
|
|
105
|
+
*/
|
|
106
|
+
export function createInMemoryRotationStatusStore(options?: {
|
|
107
|
+
readonly now?: () => number;
|
|
108
|
+
}): RotationStatusStore {
|
|
109
|
+
interface Row {
|
|
110
|
+
readonly rotationId: string;
|
|
111
|
+
readonly scopeKey: string;
|
|
112
|
+
readonly envName: EnvName;
|
|
113
|
+
readonly name: string;
|
|
114
|
+
readonly provider: string;
|
|
115
|
+
readonly resumeToken: string;
|
|
116
|
+
status: 'pending' | 'succeeded' | 'failed';
|
|
117
|
+
readonly startedAt: string;
|
|
118
|
+
updatedAt: string;
|
|
119
|
+
newVersionId?: number;
|
|
120
|
+
oldVersionId?: number;
|
|
121
|
+
error?: string;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
const rows = new Map<string, Row>();
|
|
125
|
+
const subscribers = new Map<string, Set<(s: RotationStatus) => void>>();
|
|
126
|
+
const now = options?.now ?? (() => Date.now());
|
|
127
|
+
|
|
128
|
+
const toStatus = (row: Row): RotationStatus => ({
|
|
129
|
+
rotationId: row.rotationId,
|
|
130
|
+
status: row.status,
|
|
131
|
+
startedAt: row.startedAt,
|
|
132
|
+
updatedAt: row.updatedAt,
|
|
133
|
+
...(row.newVersionId !== undefined && { newVersionId: row.newVersionId }),
|
|
134
|
+
...(row.oldVersionId !== undefined && { oldVersionId: row.oldVersionId }),
|
|
135
|
+
...(row.error !== undefined && { error: row.error }),
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
return {
|
|
139
|
+
async create(input) {
|
|
140
|
+
const rotationId = randomUUID();
|
|
141
|
+
const ts = new Date(now()).toISOString();
|
|
142
|
+
rows.set(rotationId, {
|
|
143
|
+
rotationId,
|
|
144
|
+
scopeKey: scopeKey(input.scope),
|
|
145
|
+
envName: input.envName,
|
|
146
|
+
name: input.name,
|
|
147
|
+
provider: input.provider,
|
|
148
|
+
resumeToken: input.resumeToken,
|
|
149
|
+
status: 'pending',
|
|
150
|
+
startedAt: ts,
|
|
151
|
+
updatedAt: ts,
|
|
152
|
+
});
|
|
153
|
+
return { rotationId };
|
|
154
|
+
},
|
|
155
|
+
async get(input) {
|
|
156
|
+
const row = rows.get(input.rotationId);
|
|
157
|
+
if (row === undefined) return null;
|
|
158
|
+
// Cross-scope + cross-name reads return null — a caller looking
|
|
159
|
+
// for the rotation of secret X in project A cannot inadvertently
|
|
160
|
+
// observe the rotation of secret Y in project B.
|
|
161
|
+
if (row.scopeKey !== scopeKey(input.scope)) return null;
|
|
162
|
+
if (row.envName !== input.envName) return null;
|
|
163
|
+
if (row.name !== input.name) return null;
|
|
164
|
+
return toStatus(row);
|
|
165
|
+
},
|
|
166
|
+
async update(input) {
|
|
167
|
+
const row = rows.get(input.rotationId);
|
|
168
|
+
if (row === undefined) return;
|
|
169
|
+
row.status = input.status;
|
|
170
|
+
row.updatedAt = new Date(now()).toISOString();
|
|
171
|
+
if (input.newVersionId !== undefined) row.newVersionId = input.newVersionId;
|
|
172
|
+
if (input.oldVersionId !== undefined) row.oldVersionId = input.oldVersionId;
|
|
173
|
+
if (input.error !== undefined) row.error = input.error;
|
|
174
|
+
const status = toStatus(row);
|
|
175
|
+
const subs = subscribers.get(input.rotationId);
|
|
176
|
+
if (subs !== undefined) {
|
|
177
|
+
for (const cb of subs) {
|
|
178
|
+
try {
|
|
179
|
+
cb(status);
|
|
180
|
+
} catch {
|
|
181
|
+
// Subscriber-side crashes MUST NOT poison the store.
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
subscribe(input) {
|
|
187
|
+
const set = subscribers.get(input.rotationId) ?? new Set<(s: RotationStatus) => void>();
|
|
188
|
+
set.add(input.onUpdate);
|
|
189
|
+
subscribers.set(input.rotationId, set);
|
|
190
|
+
return () => {
|
|
191
|
+
const cur = subscribers.get(input.rotationId);
|
|
192
|
+
if (cur === undefined) return;
|
|
193
|
+
cur.delete(input.onUpdate);
|
|
194
|
+
if (cur.size === 0) subscribers.delete(input.rotationId);
|
|
195
|
+
};
|
|
196
|
+
},
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
function scopeKey(s: Scope): string {
|
|
201
|
+
switch (s.kind) {
|
|
202
|
+
case 'tenant':
|
|
203
|
+
return `tenant:${s.tenantId as unknown as string}`;
|
|
204
|
+
case 'org':
|
|
205
|
+
return `org:${s.tenantId as unknown as string}:${s.orgId as unknown as string}`;
|
|
206
|
+
case 'project':
|
|
207
|
+
return `project:${s.tenantId as unknown as string}:${s.projectId as unknown as string}`;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
import { streamSSE } from 'hono/streaming';
|
|
6
|
+
|
|
7
|
+
import type { AdapterFactoryRegistry, PrepareEvent } from '@kindgi/capabilities';
|
|
8
|
+
import type { Cursor, TenantId } from '@kindgi/types';
|
|
9
|
+
|
|
10
|
+
import {
|
|
11
|
+
ADAPTER_KINDS,
|
|
12
|
+
ADAPTER_STATUSES,
|
|
13
|
+
type AdapterInfo,
|
|
14
|
+
type AdapterKind,
|
|
15
|
+
type AdapterRegistryBinding,
|
|
16
|
+
type AdapterStatus,
|
|
17
|
+
type AdapterTestOutcome,
|
|
18
|
+
} from '../adapter-binding.js';
|
|
19
|
+
import { statusFor, toWireError } from '../errors.js';
|
|
20
|
+
import type { AppEnv } from '../types.js';
|
|
21
|
+
import { clampLimit } from './pagination.js';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Adapters resource routes — part of the admin control plane. Unified
|
|
25
|
+
* surface over every adapter kind the deployment wired: model
|
|
26
|
+
* providers, embedding providers, blob storage, sandbox providers,
|
|
27
|
+
* eval judges.
|
|
28
|
+
*
|
|
29
|
+
* Read-only over HTTP, plus a smoke-test probe and a prepare stream:
|
|
30
|
+
*
|
|
31
|
+
* - `GET /v1/adapters` — cursor-paginated list with
|
|
32
|
+
* optional `kind` / `status` filters.
|
|
33
|
+
* - `GET /v1/adapters/:adapterId` — single adapter (404 if unknown).
|
|
34
|
+
* - `POST /v1/adapters/:adapterId/test` — probe. Idempotency-Key applies.
|
|
35
|
+
* - `POST /v1/adapters/:adapterId/prepare` — SSE stream of the
|
|
36
|
+
* adapter's `prepare()` events.
|
|
37
|
+
*
|
|
38
|
+
* Adapter lifecycle (register / unregister / reconfigure) is a
|
|
39
|
+
* deployment concern — see `AdapterRegistryBinding` JSDoc. The routes
|
|
40
|
+
* here never mutate the wired set.
|
|
41
|
+
*
|
|
42
|
+
* Probe failures return HTTP 200 with `ok: false` — a failed probe is a
|
|
43
|
+
* valid observation, not a server error (`docs/API-ROUTE-CONVENTIONS.md` §4).
|
|
44
|
+
* The route only maps 5xx when the probe machinery itself broke.
|
|
45
|
+
*/
|
|
46
|
+
export function adaptersRouter(
|
|
47
|
+
binding: AdapterRegistryBinding,
|
|
48
|
+
factories?: AdapterFactoryRegistry,
|
|
49
|
+
): Hono<AppEnv> {
|
|
50
|
+
const r = new Hono<AppEnv>();
|
|
51
|
+
|
|
52
|
+
// ---------- GET / (list, cursor-paginated) ----------
|
|
53
|
+
r.get('/', async (c) => {
|
|
54
|
+
const requestId = c.get('requestId');
|
|
55
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
56
|
+
const limit = clampLimit(c.req.query('limit'));
|
|
57
|
+
|
|
58
|
+
const cursorRaw = c.req.query('cursor');
|
|
59
|
+
const kindRaw = c.req.query('kind');
|
|
60
|
+
const statusRaw = c.req.query('status');
|
|
61
|
+
|
|
62
|
+
let kindFilter: AdapterKind | undefined;
|
|
63
|
+
if (kindRaw !== undefined && kindRaw.length > 0) {
|
|
64
|
+
if (!(ADAPTER_KINDS as readonly string[]).includes(kindRaw)) {
|
|
65
|
+
c.status(statusFor('bad-input') as never);
|
|
66
|
+
return c.json(
|
|
67
|
+
toWireError(
|
|
68
|
+
{
|
|
69
|
+
code: 'bad-input',
|
|
70
|
+
message: `\`kind\` "${kindRaw}" is not a known adapter kind (one of: ${ADAPTER_KINDS.join(
|
|
71
|
+
', ',
|
|
72
|
+
)})`,
|
|
73
|
+
},
|
|
74
|
+
requestId,
|
|
75
|
+
),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
kindFilter = kindRaw as AdapterKind;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
let statusFilter: AdapterStatus | undefined;
|
|
82
|
+
if (statusRaw !== undefined && statusRaw.length > 0) {
|
|
83
|
+
if (!(ADAPTER_STATUSES as readonly string[]).includes(statusRaw)) {
|
|
84
|
+
c.status(statusFor('bad-input') as never);
|
|
85
|
+
return c.json(
|
|
86
|
+
toWireError(
|
|
87
|
+
{
|
|
88
|
+
code: 'bad-input',
|
|
89
|
+
message: `\`status\` "${statusRaw}" is not a known adapter status (one of: ${ADAPTER_STATUSES.join(
|
|
90
|
+
', ',
|
|
91
|
+
)})`,
|
|
92
|
+
},
|
|
93
|
+
requestId,
|
|
94
|
+
),
|
|
95
|
+
);
|
|
96
|
+
}
|
|
97
|
+
statusFilter = statusRaw as AdapterStatus;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const hasFilter = kindFilter !== undefined || statusFilter !== undefined;
|
|
101
|
+
const page = await binding.list({
|
|
102
|
+
tenantId,
|
|
103
|
+
limit,
|
|
104
|
+
...(cursorRaw !== undefined && cursorRaw.length > 0 && { cursor: cursorRaw as Cursor }),
|
|
105
|
+
...(hasFilter && {
|
|
106
|
+
filter: {
|
|
107
|
+
...(kindFilter !== undefined && { kind: kindFilter }),
|
|
108
|
+
...(statusFilter !== undefined && { status: statusFilter }),
|
|
109
|
+
},
|
|
110
|
+
}),
|
|
111
|
+
});
|
|
112
|
+
return c.json({
|
|
113
|
+
data: page.data.map(serializeAdapter),
|
|
114
|
+
hasMore: page.nextCursor !== undefined,
|
|
115
|
+
...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
// ---------- GET /:adapterId ----------
|
|
120
|
+
r.get('/:adapterId', async (c) => {
|
|
121
|
+
const requestId = c.get('requestId');
|
|
122
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
123
|
+
const adapterId = c.req.param('adapterId');
|
|
124
|
+
|
|
125
|
+
const adapter = await binding.get({ tenantId, adapterId });
|
|
126
|
+
if (adapter === null) {
|
|
127
|
+
c.status(statusFor('adapter-not-found') as never);
|
|
128
|
+
return c.json(
|
|
129
|
+
toWireError(
|
|
130
|
+
{
|
|
131
|
+
code: 'adapter-not-found',
|
|
132
|
+
message: `No adapter registered with id "${adapterId}"`,
|
|
133
|
+
adapterId,
|
|
134
|
+
},
|
|
135
|
+
requestId,
|
|
136
|
+
),
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
return c.json(serializeAdapter(adapter));
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
// ---------- POST /:adapterId/test ----------
|
|
143
|
+
r.post('/:adapterId/test', async (c) => {
|
|
144
|
+
const requestId = c.get('requestId');
|
|
145
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
146
|
+
const adapterId = c.req.param('adapterId');
|
|
147
|
+
|
|
148
|
+
// Body is optional. Empty body OR `{}` OR omitted body → no
|
|
149
|
+
// `input` handed to the binding (it picks the default probe).
|
|
150
|
+
let probeInput: Readonly<Record<string, unknown>> | undefined;
|
|
151
|
+
const raw = await c.req.text();
|
|
152
|
+
if (raw.length > 0) {
|
|
153
|
+
let parsed: unknown;
|
|
154
|
+
try {
|
|
155
|
+
parsed = JSON.parse(raw);
|
|
156
|
+
} catch {
|
|
157
|
+
c.status(statusFor('bad-input') as never);
|
|
158
|
+
return c.json(
|
|
159
|
+
toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId),
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
163
|
+
c.status(statusFor('bad-input') as never);
|
|
164
|
+
return c.json(
|
|
165
|
+
toWireError(
|
|
166
|
+
{ code: 'bad-input', message: 'Request body must be a JSON object' },
|
|
167
|
+
requestId,
|
|
168
|
+
),
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
probeInput = parsed as Readonly<Record<string, unknown>>;
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
const outcome = await binding.test({
|
|
175
|
+
tenantId,
|
|
176
|
+
adapterId,
|
|
177
|
+
...(probeInput !== undefined && { input: probeInput }),
|
|
178
|
+
});
|
|
179
|
+
if (outcome === null) {
|
|
180
|
+
c.status(statusFor('adapter-not-found') as never);
|
|
181
|
+
return c.json(
|
|
182
|
+
toWireError(
|
|
183
|
+
{
|
|
184
|
+
code: 'adapter-not-found',
|
|
185
|
+
message: `No adapter registered with id "${adapterId}"`,
|
|
186
|
+
adapterId,
|
|
187
|
+
},
|
|
188
|
+
requestId,
|
|
189
|
+
),
|
|
190
|
+
);
|
|
191
|
+
}
|
|
192
|
+
// Probe failure is data — HTTP 200 with `ok: false` in the body.
|
|
193
|
+
return c.json(serializeTestOutcome(outcome));
|
|
194
|
+
});
|
|
195
|
+
|
|
196
|
+
// ---------- POST /:adapterId/prepare ----------
|
|
197
|
+
// SSE stream — iterates `entry.prepare(params)` and pushes each
|
|
198
|
+
// PrepareEvent as an SSE `data:` line. Returns 404 if the adapter
|
|
199
|
+
// id is unknown to the in-process factory registry, 400 if the
|
|
200
|
+
// adapter has no `prepare()` (e.g. anthropic — nothing to
|
|
201
|
+
// download), and 501 if the deployment didn't wire an
|
|
202
|
+
// `adapterFactories` binding at all.
|
|
203
|
+
r.post('/:adapterId/prepare', async (c) => {
|
|
204
|
+
const requestId = c.get('requestId');
|
|
205
|
+
const adapterId = c.req.param('adapterId');
|
|
206
|
+
|
|
207
|
+
if (factories === undefined) {
|
|
208
|
+
c.status(statusFor('bad-input') as never);
|
|
209
|
+
return c.json(
|
|
210
|
+
toWireError(
|
|
211
|
+
{
|
|
212
|
+
code: 'bad-input',
|
|
213
|
+
message:
|
|
214
|
+
'Adapter prepare is not available — this deployment did not wire an adapterFactories binding.',
|
|
215
|
+
},
|
|
216
|
+
requestId,
|
|
217
|
+
),
|
|
218
|
+
);
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
const entry = factories.get(adapterId);
|
|
222
|
+
if (entry === undefined) {
|
|
223
|
+
c.status(statusFor('adapter-not-found') as never);
|
|
224
|
+
return c.json(
|
|
225
|
+
toWireError(
|
|
226
|
+
{
|
|
227
|
+
code: 'adapter-not-found',
|
|
228
|
+
message: `No adapter registered with id "${adapterId}"`,
|
|
229
|
+
adapterId,
|
|
230
|
+
},
|
|
231
|
+
requestId,
|
|
232
|
+
),
|
|
233
|
+
);
|
|
234
|
+
}
|
|
235
|
+
if (entry.prepare === undefined) {
|
|
236
|
+
c.status(statusFor('bad-input') as never);
|
|
237
|
+
return c.json(
|
|
238
|
+
toWireError(
|
|
239
|
+
{
|
|
240
|
+
code: 'bad-input',
|
|
241
|
+
message: `Adapter "${adapterId}" does not require preparation (no prepare() implemented).`,
|
|
242
|
+
},
|
|
243
|
+
requestId,
|
|
244
|
+
),
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// Body carries adapter-specific `params` — passed through
|
|
249
|
+
// unchanged (e.g. `{model: 'smollm2-360m'}` for in-process).
|
|
250
|
+
let params: Readonly<Record<string, unknown>> | undefined;
|
|
251
|
+
const bodyText = await c.req.text();
|
|
252
|
+
if (bodyText.length > 0) {
|
|
253
|
+
try {
|
|
254
|
+
const parsed = JSON.parse(bodyText) as { readonly params?: unknown };
|
|
255
|
+
if (parsed.params !== undefined) {
|
|
256
|
+
if (parsed.params === null || typeof parsed.params !== 'object') {
|
|
257
|
+
c.status(statusFor('bad-input') as never);
|
|
258
|
+
return c.json(
|
|
259
|
+
toWireError(
|
|
260
|
+
{ code: 'bad-input', message: '`params` must be an object when present.' },
|
|
261
|
+
requestId,
|
|
262
|
+
),
|
|
263
|
+
);
|
|
264
|
+
}
|
|
265
|
+
params = parsed.params as Readonly<Record<string, unknown>>;
|
|
266
|
+
}
|
|
267
|
+
} catch {
|
|
268
|
+
c.status(statusFor('bad-input') as never);
|
|
269
|
+
return c.json(
|
|
270
|
+
toWireError(
|
|
271
|
+
{ code: 'bad-input', message: 'Request body must be valid JSON.' },
|
|
272
|
+
requestId,
|
|
273
|
+
),
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
const prepareStream = entry.prepare(params);
|
|
279
|
+
|
|
280
|
+
return streamSSE(c, async (stream) => {
|
|
281
|
+
try {
|
|
282
|
+
for await (const event of prepareStream) {
|
|
283
|
+
await stream.writeSSE({
|
|
284
|
+
event: event.kind,
|
|
285
|
+
data: JSON.stringify(event),
|
|
286
|
+
});
|
|
287
|
+
if (event.kind === 'ready' || event.kind === 'error') break;
|
|
288
|
+
}
|
|
289
|
+
} catch (err) {
|
|
290
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
291
|
+
const errorEvent: PrepareEvent = { kind: 'error', message };
|
|
292
|
+
await stream.writeSSE({ event: 'error', data: JSON.stringify(errorEvent) });
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
return r;
|
|
298
|
+
}
|
|
299
|
+
|
|
300
|
+
function serializeAdapter(a: AdapterInfo): Record<string, unknown> {
|
|
301
|
+
return {
|
|
302
|
+
adapterId: a.adapterId,
|
|
303
|
+
kind: a.kind,
|
|
304
|
+
name: a.name,
|
|
305
|
+
version: a.version,
|
|
306
|
+
capabilities: a.capabilities,
|
|
307
|
+
status: a.status,
|
|
308
|
+
...(a.config !== undefined && { config: a.config }),
|
|
309
|
+
...(a.statusReason !== undefined && { statusReason: a.statusReason }),
|
|
310
|
+
};
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
function serializeTestOutcome(o: AdapterTestOutcome): Record<string, unknown> {
|
|
314
|
+
return {
|
|
315
|
+
ok: o.ok,
|
|
316
|
+
latencyMs: o.latencyMs,
|
|
317
|
+
probe: o.probe,
|
|
318
|
+
};
|
|
319
|
+
}
|