@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,430 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
|
|
6
|
+
import type { Fact, MemoryScope, Retention } from '@kindgi/memory';
|
|
7
|
+
import type { FactId, TenantId } from '@kindgi/types';
|
|
8
|
+
|
|
9
|
+
import { statusFor, toWireError } from '../errors.js';
|
|
10
|
+
import type { MemoryBinding, MemoryRetrievalHit, MemoryRetrieveIntent } from '../memory-binding.js';
|
|
11
|
+
import type { AppEnv } from '../types.js';
|
|
12
|
+
import { clampLimit } from './pagination.js';
|
|
13
|
+
import { parseScopeParams } from './scope-params.js';
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Memory resource routes.
|
|
17
|
+
*
|
|
18
|
+
* Storage is caller-plugged via `MemoryBinding`. The API package does
|
|
19
|
+
* not own memory persistence, retrieval, or embeddings — deployments
|
|
20
|
+
* wire a binding that wraps the memory subsystem alongside their own
|
|
21
|
+
* `EmbeddingProviderRegistry` and per-type retrieval policies.
|
|
22
|
+
*
|
|
23
|
+
* Facts are append-only: supersession replaces delete. Physical removal
|
|
24
|
+
* is left to the retention sweep.
|
|
25
|
+
*/
|
|
26
|
+
export function memoryRouter(binding: MemoryBinding): Hono<AppEnv> {
|
|
27
|
+
const r = new Hono<AppEnv>();
|
|
28
|
+
|
|
29
|
+
// ---------- GET /facts (list, cursor-paginated) ----------
|
|
30
|
+
r.get('/facts', async (c) => {
|
|
31
|
+
const requestId = c.get('requestId');
|
|
32
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
33
|
+
const limit = clampLimit(c.req.query('limit'));
|
|
34
|
+
|
|
35
|
+
const cursorRaw = c.req.query('cursor');
|
|
36
|
+
const typeRaw = c.req.query('type');
|
|
37
|
+
const scopeRaw = c.req.query('scope');
|
|
38
|
+
|
|
39
|
+
let scope: Partial<MemoryScope> | undefined;
|
|
40
|
+
if (scopeRaw !== undefined && scopeRaw.length > 0) {
|
|
41
|
+
const parsed = parseScopeParam(scopeRaw);
|
|
42
|
+
if (parsed === null) {
|
|
43
|
+
c.status(statusFor('bad-input') as never);
|
|
44
|
+
return c.json(
|
|
45
|
+
toWireError(
|
|
46
|
+
{ code: 'bad-input', message: 'Query parameter `scope` must be a JSON object' },
|
|
47
|
+
requestId,
|
|
48
|
+
),
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
scope = parsed;
|
|
52
|
+
}
|
|
53
|
+
if (scopeNamesOtherTenant(scope, tenantId)) {
|
|
54
|
+
c.status(statusFor('scope-mismatch') as never);
|
|
55
|
+
return c.json(toWireError(SCOPE_MISMATCH, requestId));
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// Thread the ?scopeKind + ?scopeId + ?inherit
|
|
59
|
+
// triplet into `platformScope` (NOT `scope`). The JSON-encoded
|
|
60
|
+
// `?scope=` query param + `scope: Partial<MemoryScope>` field above
|
|
61
|
+
// are a separate filter — both coexist by design.
|
|
62
|
+
const scopeParsed = parseScopeParams(c.req.query(), { tenantId });
|
|
63
|
+
if (scopeParsed.kind === 'err') {
|
|
64
|
+
c.status(statusFor('scope-invalid') as never);
|
|
65
|
+
return c.json(
|
|
66
|
+
toWireError({ code: 'scope-invalid', message: scopeParsed.message }, requestId),
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const page = await binding.listFacts({
|
|
71
|
+
tenantId,
|
|
72
|
+
limit,
|
|
73
|
+
...(cursorRaw !== undefined &&
|
|
74
|
+
cursorRaw.length > 0 && {
|
|
75
|
+
cursor: cursorRaw as import('@kindgi/types').Cursor,
|
|
76
|
+
}),
|
|
77
|
+
...(typeRaw !== undefined && typeRaw.length > 0 && { type: typeRaw }),
|
|
78
|
+
...(scope !== undefined && { scope }),
|
|
79
|
+
...(scopeParsed.scope !== undefined && { platformScope: scopeParsed.scope }),
|
|
80
|
+
...(scopeParsed.inherit !== undefined && { inherit: scopeParsed.inherit }),
|
|
81
|
+
});
|
|
82
|
+
return c.json({
|
|
83
|
+
data: page.data.map(serializeFact),
|
|
84
|
+
hasMore: page.nextCursor !== undefined,
|
|
85
|
+
...(page.nextCursor !== undefined && { nextCursor: page.nextCursor as unknown as string }),
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
// ---------- GET /facts/:factId ----------
|
|
90
|
+
r.get('/facts/:factId', async (c) => {
|
|
91
|
+
const requestId = c.get('requestId');
|
|
92
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
93
|
+
const factId = c.req.param('factId') as FactId;
|
|
94
|
+
|
|
95
|
+
const fact = await binding.getFact({ tenantId, factId });
|
|
96
|
+
if (fact === null) {
|
|
97
|
+
c.status(statusFor('fact-not-found') as never);
|
|
98
|
+
return c.json(
|
|
99
|
+
toWireError(
|
|
100
|
+
{
|
|
101
|
+
code: 'fact-not-found',
|
|
102
|
+
message: `No fact with id "${factId as unknown as string}"`,
|
|
103
|
+
factId: factId as unknown as string,
|
|
104
|
+
},
|
|
105
|
+
requestId,
|
|
106
|
+
),
|
|
107
|
+
);
|
|
108
|
+
}
|
|
109
|
+
return c.json(serializeFact(fact));
|
|
110
|
+
});
|
|
111
|
+
|
|
112
|
+
// ---------- POST /facts (write) ----------
|
|
113
|
+
r.post('/facts', async (c) => {
|
|
114
|
+
const requestId = c.get('requestId');
|
|
115
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
116
|
+
|
|
117
|
+
let body: unknown;
|
|
118
|
+
try {
|
|
119
|
+
body = await c.req.json();
|
|
120
|
+
} catch {
|
|
121
|
+
c.status(statusFor('bad-input') as never);
|
|
122
|
+
return c.json(
|
|
123
|
+
toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId),
|
|
124
|
+
);
|
|
125
|
+
}
|
|
126
|
+
if (body === null || typeof body !== 'object') {
|
|
127
|
+
c.status(statusFor('bad-input') as never);
|
|
128
|
+
return c.json(
|
|
129
|
+
toWireError({ code: 'bad-input', message: 'Request body must be an object' }, requestId),
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const validation = validateWriteFactBody(body as Record<string, unknown>);
|
|
134
|
+
if (validation.kind === 'err') {
|
|
135
|
+
c.status(statusFor('bad-input') as never);
|
|
136
|
+
return c.json(toWireError({ code: 'bad-input', message: validation.message }, requestId));
|
|
137
|
+
}
|
|
138
|
+
const { type, scope, content, retention, contentHash } = validation.value;
|
|
139
|
+
if (scopeNamesOtherTenant(scope, tenantId)) {
|
|
140
|
+
c.status(statusFor('scope-mismatch') as never);
|
|
141
|
+
return c.json(toWireError(SCOPE_MISMATCH, requestId));
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const outcome = await binding.writeFact({
|
|
145
|
+
tenantId,
|
|
146
|
+
type,
|
|
147
|
+
scope,
|
|
148
|
+
content,
|
|
149
|
+
...(retention !== undefined && { retention }),
|
|
150
|
+
...(contentHash !== undefined && { contentHash }),
|
|
151
|
+
});
|
|
152
|
+
if (outcome.kind === 'embedding-unavailable') {
|
|
153
|
+
c.status(statusFor('bad-input') as never);
|
|
154
|
+
return c.json(toWireError({ code: 'bad-input', message: outcome.message }, requestId));
|
|
155
|
+
}
|
|
156
|
+
if (outcome.kind === 'error') {
|
|
157
|
+
c.status(statusFor(outcome.code) as never);
|
|
158
|
+
return c.json(toWireError({ code: outcome.code, message: outcome.message }, requestId));
|
|
159
|
+
}
|
|
160
|
+
c.status(201);
|
|
161
|
+
return c.json(serializeFact(outcome.fact));
|
|
162
|
+
});
|
|
163
|
+
|
|
164
|
+
// ---------- POST /facts/:factId/supersede ----------
|
|
165
|
+
r.post('/facts/:factId/supersede', async (c) => {
|
|
166
|
+
const requestId = c.get('requestId');
|
|
167
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
168
|
+
const factId = c.req.param('factId') as FactId;
|
|
169
|
+
|
|
170
|
+
const outcome = await binding.supersedeFact({ tenantId, factId });
|
|
171
|
+
if (!outcome.superseded) {
|
|
172
|
+
c.status(statusFor('fact-not-found') as never);
|
|
173
|
+
return c.json(
|
|
174
|
+
toWireError(
|
|
175
|
+
{
|
|
176
|
+
code: 'fact-not-found',
|
|
177
|
+
message: `No fact with id "${factId as unknown as string}" to supersede`,
|
|
178
|
+
factId: factId as unknown as string,
|
|
179
|
+
},
|
|
180
|
+
requestId,
|
|
181
|
+
),
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
return c.json({
|
|
185
|
+
factId: factId as unknown as string,
|
|
186
|
+
superseded: true,
|
|
187
|
+
});
|
|
188
|
+
});
|
|
189
|
+
|
|
190
|
+
// ---------- POST /retrieve ----------
|
|
191
|
+
r.post('/retrieve', async (c) => {
|
|
192
|
+
const requestId = c.get('requestId');
|
|
193
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
194
|
+
|
|
195
|
+
let body: unknown;
|
|
196
|
+
try {
|
|
197
|
+
body = await c.req.json();
|
|
198
|
+
} catch {
|
|
199
|
+
c.status(statusFor('bad-input') as never);
|
|
200
|
+
return c.json(
|
|
201
|
+
toWireError({ code: 'bad-input', message: 'Request body must be valid JSON' }, requestId),
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
if (body === null || typeof body !== 'object') {
|
|
205
|
+
c.status(statusFor('bad-input') as never);
|
|
206
|
+
return c.json(
|
|
207
|
+
toWireError({ code: 'bad-input', message: 'Request body must be an object' }, requestId),
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
const validation = validateRetrieveIntent(body as Record<string, unknown>);
|
|
212
|
+
if (validation.kind === 'err') {
|
|
213
|
+
c.status(statusFor('bad-input') as never);
|
|
214
|
+
return c.json(toWireError({ code: 'bad-input', message: validation.message }, requestId));
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
if (scopeNamesOtherTenant(validation.value.scope, tenantId)) {
|
|
218
|
+
c.status(statusFor('scope-mismatch') as never);
|
|
219
|
+
return c.json(toWireError(SCOPE_MISMATCH, requestId));
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
const outcome = await binding.retrieve({ tenantId, intent: validation.value });
|
|
223
|
+
if (outcome.kind === 'embedding-unavailable') {
|
|
224
|
+
c.status(statusFor('bad-input') as never);
|
|
225
|
+
return c.json(toWireError({ code: 'bad-input', message: outcome.message }, requestId));
|
|
226
|
+
}
|
|
227
|
+
if (outcome.kind === 'error') {
|
|
228
|
+
c.status(statusFor(outcome.code) as never);
|
|
229
|
+
return c.json(toWireError({ code: outcome.code, message: outcome.message }, requestId));
|
|
230
|
+
}
|
|
231
|
+
return c.json({
|
|
232
|
+
results: outcome.results.map(serializeRetrievalHit),
|
|
233
|
+
});
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
return r;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
// -------------------- serialization --------------------
|
|
240
|
+
|
|
241
|
+
function serializeFact(f: Fact): Record<string, unknown> {
|
|
242
|
+
return {
|
|
243
|
+
id: f.id as unknown as string,
|
|
244
|
+
type: f.type,
|
|
245
|
+
scope: f.scope,
|
|
246
|
+
version: f.version,
|
|
247
|
+
createdAt: f.createdAt as unknown as string,
|
|
248
|
+
...(f.updatedAt !== undefined && { updatedAt: f.updatedAt as unknown as string }),
|
|
249
|
+
...(f.content !== undefined && { content: f.content }),
|
|
250
|
+
...(f.contentRef !== undefined && { contentRef: f.contentRef }),
|
|
251
|
+
...(f.contentHash !== undefined && { contentHash: f.contentHash }),
|
|
252
|
+
...(f.size !== undefined && { size: f.size }),
|
|
253
|
+
...(f.embeddingModel !== undefined && { embeddingModel: f.embeddingModel }),
|
|
254
|
+
...(f.retention !== undefined && { retention: f.retention }),
|
|
255
|
+
...(f.source !== undefined && { source: f.source }),
|
|
256
|
+
...(f.causedByLogId !== undefined && { causedByLogId: f.causedByLogId }),
|
|
257
|
+
...(f.supersedes !== undefined && { supersedes: f.supersedes as unknown as string }),
|
|
258
|
+
};
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
function serializeRetrievalHit(h: MemoryRetrievalHit): Record<string, unknown> {
|
|
262
|
+
return {
|
|
263
|
+
fact: serializeFact(h.fact),
|
|
264
|
+
...(h.score !== undefined && { score: h.score }),
|
|
265
|
+
};
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
// -------------------- request parsing --------------------
|
|
269
|
+
|
|
270
|
+
const SCOPE_MISMATCH = {
|
|
271
|
+
code: 'scope-mismatch',
|
|
272
|
+
message: '`scope.tenantId` does not match the caller tenant.',
|
|
273
|
+
} as const;
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* A memory scope in a request may name a tenant; it must be the caller's
|
|
277
|
+
* (derived from the token). Same rule as the secrets, env and policy
|
|
278
|
+
* routes — a request can never read or write another tenant's memory.
|
|
279
|
+
*/
|
|
280
|
+
function scopeNamesOtherTenant(
|
|
281
|
+
scope: Partial<MemoryScope> | undefined,
|
|
282
|
+
tenantId: TenantId,
|
|
283
|
+
): boolean {
|
|
284
|
+
return scope?.tenantId !== undefined && scope.tenantId !== tenantId;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
function parseScopeParam(raw: string): Partial<MemoryScope> | null {
|
|
288
|
+
try {
|
|
289
|
+
const decoded = JSON.parse(raw) as unknown;
|
|
290
|
+
if (decoded === null || typeof decoded !== 'object' || Array.isArray(decoded)) return null;
|
|
291
|
+
return decoded as Partial<MemoryScope>;
|
|
292
|
+
} catch {
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
// -------------------- validators --------------------
|
|
298
|
+
|
|
299
|
+
type ValidationResult<T> =
|
|
300
|
+
| { readonly kind: 'ok'; readonly value: T }
|
|
301
|
+
| { readonly kind: 'err'; readonly message: string };
|
|
302
|
+
|
|
303
|
+
interface ValidatedWriteFactBody {
|
|
304
|
+
readonly type: string;
|
|
305
|
+
readonly scope: MemoryScope;
|
|
306
|
+
readonly content: unknown;
|
|
307
|
+
readonly retention?: Retention;
|
|
308
|
+
readonly contentHash?: string;
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
function validateWriteFactBody(
|
|
312
|
+
body: Record<string, unknown>,
|
|
313
|
+
): ValidationResult<ValidatedWriteFactBody> {
|
|
314
|
+
const type = body.type;
|
|
315
|
+
if (typeof type !== 'string' || type.length === 0) {
|
|
316
|
+
return { kind: 'err', message: 'Field `type` must be a non-empty string' };
|
|
317
|
+
}
|
|
318
|
+
const rawScope = body.scope;
|
|
319
|
+
if (rawScope === null || typeof rawScope !== 'object' || Array.isArray(rawScope)) {
|
|
320
|
+
return { kind: 'err', message: 'Field `scope` must be an object' };
|
|
321
|
+
}
|
|
322
|
+
const scope = rawScope as MemoryScope;
|
|
323
|
+
if (typeof (scope as { tenantId?: unknown }).tenantId !== 'string') {
|
|
324
|
+
return { kind: 'err', message: 'Field `scope.tenantId` must be a string' };
|
|
325
|
+
}
|
|
326
|
+
if (!('content' in body)) {
|
|
327
|
+
return { kind: 'err', message: 'Field `content` is required' };
|
|
328
|
+
}
|
|
329
|
+
const rawRetention = body.retention;
|
|
330
|
+
let retention: Retention | undefined;
|
|
331
|
+
if (rawRetention !== undefined) {
|
|
332
|
+
if (rawRetention === null || typeof rawRetention !== 'object' || Array.isArray(rawRetention)) {
|
|
333
|
+
return { kind: 'err', message: 'Field `retention` must be an object when present' };
|
|
334
|
+
}
|
|
335
|
+
retention = rawRetention as Retention;
|
|
336
|
+
}
|
|
337
|
+
const rawContentHash = body.contentHash;
|
|
338
|
+
let contentHash: string | undefined;
|
|
339
|
+
if (rawContentHash !== undefined) {
|
|
340
|
+
if (typeof rawContentHash !== 'string' || rawContentHash.length === 0) {
|
|
341
|
+
return {
|
|
342
|
+
kind: 'err',
|
|
343
|
+
message: 'Field `contentHash` must be a non-empty string when present',
|
|
344
|
+
};
|
|
345
|
+
}
|
|
346
|
+
contentHash = rawContentHash;
|
|
347
|
+
}
|
|
348
|
+
return {
|
|
349
|
+
kind: 'ok',
|
|
350
|
+
value: {
|
|
351
|
+
type,
|
|
352
|
+
scope,
|
|
353
|
+
content: body.content,
|
|
354
|
+
...(retention !== undefined && { retention }),
|
|
355
|
+
...(contentHash !== undefined && { contentHash }),
|
|
356
|
+
},
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
function validateRetrieveIntent(
|
|
361
|
+
body: Record<string, unknown>,
|
|
362
|
+
): ValidationResult<MemoryRetrieveIntent> {
|
|
363
|
+
const mode = body.mode;
|
|
364
|
+
if (mode !== 'list' && mode !== 'keyword' && mode !== 'semantic' && mode !== 'both') {
|
|
365
|
+
return {
|
|
366
|
+
kind: 'err',
|
|
367
|
+
message: 'Field `mode` must be one of "list", "keyword", "semantic", "both"',
|
|
368
|
+
};
|
|
369
|
+
}
|
|
370
|
+
let query: string | undefined;
|
|
371
|
+
const rawQuery = body.query;
|
|
372
|
+
if (rawQuery !== undefined) {
|
|
373
|
+
if (typeof rawQuery !== 'string') {
|
|
374
|
+
return { kind: 'err', message: 'Field `query` must be a string when present' };
|
|
375
|
+
}
|
|
376
|
+
query = rawQuery;
|
|
377
|
+
}
|
|
378
|
+
if ((mode === 'keyword' || mode === 'semantic' || mode === 'both') && query === undefined) {
|
|
379
|
+
return {
|
|
380
|
+
kind: 'err',
|
|
381
|
+
message: `Field \`query\` is required when \`mode\` is "${mode}"`,
|
|
382
|
+
};
|
|
383
|
+
}
|
|
384
|
+
let type: string | undefined;
|
|
385
|
+
const rawType = body.type;
|
|
386
|
+
if (rawType !== undefined) {
|
|
387
|
+
if (typeof rawType !== 'string' || rawType.length === 0) {
|
|
388
|
+
return { kind: 'err', message: 'Field `type` must be a non-empty string when present' };
|
|
389
|
+
}
|
|
390
|
+
type = rawType;
|
|
391
|
+
}
|
|
392
|
+
let scope: Partial<MemoryScope> | undefined;
|
|
393
|
+
const rawScope = body.scope;
|
|
394
|
+
if (rawScope !== undefined) {
|
|
395
|
+
if (rawScope === null || typeof rawScope !== 'object' || Array.isArray(rawScope)) {
|
|
396
|
+
return { kind: 'err', message: 'Field `scope` must be an object when present' };
|
|
397
|
+
}
|
|
398
|
+
scope = rawScope as Partial<MemoryScope>;
|
|
399
|
+
}
|
|
400
|
+
let limit: number | undefined;
|
|
401
|
+
const rawLimit = body.limit;
|
|
402
|
+
if (rawLimit !== undefined) {
|
|
403
|
+
if (typeof rawLimit !== 'number' || !Number.isFinite(rawLimit) || rawLimit < 1) {
|
|
404
|
+
return { kind: 'err', message: 'Field `limit` must be a positive number when present' };
|
|
405
|
+
}
|
|
406
|
+
limit = Math.floor(rawLimit);
|
|
407
|
+
}
|
|
408
|
+
let embeddingModel: string | undefined;
|
|
409
|
+
const rawEmbeddingModel = body.embeddingModel;
|
|
410
|
+
if (rawEmbeddingModel !== undefined) {
|
|
411
|
+
if (typeof rawEmbeddingModel !== 'string' || rawEmbeddingModel.length === 0) {
|
|
412
|
+
return {
|
|
413
|
+
kind: 'err',
|
|
414
|
+
message: 'Field `embeddingModel` must be a non-empty string when present',
|
|
415
|
+
};
|
|
416
|
+
}
|
|
417
|
+
embeddingModel = rawEmbeddingModel;
|
|
418
|
+
}
|
|
419
|
+
return {
|
|
420
|
+
kind: 'ok',
|
|
421
|
+
value: {
|
|
422
|
+
mode,
|
|
423
|
+
...(query !== undefined && { query }),
|
|
424
|
+
...(type !== undefined && { type }),
|
|
425
|
+
...(scope !== undefined && { scope }),
|
|
426
|
+
...(limit !== undefined && { limit }),
|
|
427
|
+
...(embeddingModel !== undefined && { embeddingModel }),
|
|
428
|
+
},
|
|
429
|
+
};
|
|
430
|
+
}
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
+
// Copyright (C) 2026 Kindgi Inc.
|
|
3
|
+
|
|
4
|
+
import { Hono } from 'hono';
|
|
5
|
+
|
|
6
|
+
import type {
|
|
7
|
+
AgentId,
|
|
8
|
+
Cursor,
|
|
9
|
+
RunId,
|
|
10
|
+
Semver,
|
|
11
|
+
SupervisorId,
|
|
12
|
+
TenantId,
|
|
13
|
+
Timestamp,
|
|
14
|
+
} from '@kindgi/types';
|
|
15
|
+
|
|
16
|
+
import { statusFor, toWireError } from '../errors.js';
|
|
17
|
+
import type { Observation, ObservationStatus, SupervisorBinding } from '../supervisor-binding.js';
|
|
18
|
+
import type { AppEnv } from '../types.js';
|
|
19
|
+
import { clampLimit } from './pagination.js';
|
|
20
|
+
|
|
21
|
+
const OBSERVATION_STATUSES: ReadonlySet<ObservationStatus> = new Set([
|
|
22
|
+
'succeeded',
|
|
23
|
+
'guardrail-violation',
|
|
24
|
+
'guardrail-warning',
|
|
25
|
+
'tool-error',
|
|
26
|
+
'model-error',
|
|
27
|
+
'budget-exceeded',
|
|
28
|
+
'aborted',
|
|
29
|
+
'other',
|
|
30
|
+
]);
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Observations resource — supervisor readback of run outcomes.
|
|
34
|
+
*
|
|
35
|
+
* Any authenticated caller can list observations for their tenant.
|
|
36
|
+
* Filtering is deliberately narrow: `agentId`, `status`,
|
|
37
|
+
* `supervisorId`. Time-window + conversation filters can be added when
|
|
38
|
+
* a caller needs them.
|
|
39
|
+
*
|
|
40
|
+
* Cursor is the ISO `observedAt` of the tail row — same convention as
|
|
41
|
+
* `SupervisorBinding.queryObservations`.
|
|
42
|
+
*
|
|
43
|
+
* Persistence + query wiring is caller-plugged via `SupervisorBinding`
|
|
44
|
+
* — the API package doesn't own the supervisor runtime.
|
|
45
|
+
*/
|
|
46
|
+
export function observationsRouter(binding: SupervisorBinding): Hono<AppEnv> {
|
|
47
|
+
const r = new Hono<AppEnv>();
|
|
48
|
+
|
|
49
|
+
r.get('/', async (c) => {
|
|
50
|
+
const requestId = c.get('requestId');
|
|
51
|
+
const tenantId = c.get('tenantId') as TenantId;
|
|
52
|
+
const limit = clampLimit(c.req.query('limit'));
|
|
53
|
+
|
|
54
|
+
const statusRaw = c.req.query('status');
|
|
55
|
+
if (
|
|
56
|
+
statusRaw !== undefined &&
|
|
57
|
+
statusRaw.length > 0 &&
|
|
58
|
+
!OBSERVATION_STATUSES.has(statusRaw as ObservationStatus)
|
|
59
|
+
) {
|
|
60
|
+
c.status(statusFor('bad-input') as never);
|
|
61
|
+
return c.json(
|
|
62
|
+
toWireError(
|
|
63
|
+
{ code: 'bad-input', message: `Unknown \`status\` value: ${statusRaw}` },
|
|
64
|
+
requestId,
|
|
65
|
+
),
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const cursor = c.req.query('cursor');
|
|
70
|
+
if (cursor !== undefined && cursor.length > 0) {
|
|
71
|
+
const parsed = new Date(cursor);
|
|
72
|
+
if (Number.isNaN(parsed.getTime())) {
|
|
73
|
+
c.status(statusFor('bad-input') as never);
|
|
74
|
+
return c.json(
|
|
75
|
+
toWireError({ code: 'bad-input', message: '`cursor` is malformed' }, requestId),
|
|
76
|
+
);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
const agentIdRaw = c.req.query('agentId');
|
|
81
|
+
const agentVersionRaw = c.req.query('agentVersion');
|
|
82
|
+
const supervisorIdRaw = c.req.query('supervisorId');
|
|
83
|
+
const conversationIdRaw = c.req.query('conversationId');
|
|
84
|
+
const sinceRaw = c.req.query('since');
|
|
85
|
+
const untilRaw = c.req.query('until');
|
|
86
|
+
|
|
87
|
+
const validIso = (raw: string | undefined): string | undefined | 'invalid' => {
|
|
88
|
+
if (raw === undefined || raw.length === 0) return undefined;
|
|
89
|
+
const d = new Date(raw);
|
|
90
|
+
if (Number.isNaN(d.getTime())) return 'invalid';
|
|
91
|
+
return d.toISOString();
|
|
92
|
+
};
|
|
93
|
+
const since = validIso(sinceRaw);
|
|
94
|
+
if (since === 'invalid') {
|
|
95
|
+
c.status(statusFor('bad-input') as never);
|
|
96
|
+
return c.json(
|
|
97
|
+
toWireError(
|
|
98
|
+
{ code: 'bad-input', message: '`since` must be an ISO date string' },
|
|
99
|
+
requestId,
|
|
100
|
+
),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
const until = validIso(untilRaw);
|
|
104
|
+
if (until === 'invalid') {
|
|
105
|
+
c.status(statusFor('bad-input') as never);
|
|
106
|
+
return c.json(
|
|
107
|
+
toWireError(
|
|
108
|
+
{ code: 'bad-input', message: '`until` must be an ISO date string' },
|
|
109
|
+
requestId,
|
|
110
|
+
),
|
|
111
|
+
);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
const outcome = await binding.queryObservations({
|
|
115
|
+
tenantId,
|
|
116
|
+
limit,
|
|
117
|
+
...(statusRaw !== undefined &&
|
|
118
|
+
statusRaw.length > 0 && {
|
|
119
|
+
status: statusRaw as ObservationStatus,
|
|
120
|
+
}),
|
|
121
|
+
...(agentIdRaw !== undefined &&
|
|
122
|
+
agentIdRaw.length > 0 && {
|
|
123
|
+
agentId: agentIdRaw as AgentId,
|
|
124
|
+
}),
|
|
125
|
+
...(agentVersionRaw !== undefined &&
|
|
126
|
+
agentVersionRaw.length > 0 && {
|
|
127
|
+
agentVersion: agentVersionRaw as unknown as Semver,
|
|
128
|
+
}),
|
|
129
|
+
...(supervisorIdRaw !== undefined &&
|
|
130
|
+
supervisorIdRaw.length > 0 && {
|
|
131
|
+
supervisorId: supervisorIdRaw as SupervisorId,
|
|
132
|
+
}),
|
|
133
|
+
...(conversationIdRaw !== undefined &&
|
|
134
|
+
conversationIdRaw.length > 0 && {
|
|
135
|
+
conversationId: conversationIdRaw as RunId,
|
|
136
|
+
}),
|
|
137
|
+
...(since !== undefined && { since: since as unknown as Timestamp }),
|
|
138
|
+
...(until !== undefined && { until: until as unknown as Timestamp }),
|
|
139
|
+
...(cursor !== undefined && cursor.length > 0 && { cursor: cursor as Cursor }),
|
|
140
|
+
});
|
|
141
|
+
if (outcome.kind === 'runtime-error') {
|
|
142
|
+
c.status(statusFor(outcome.code) as never);
|
|
143
|
+
return c.json(toWireError({ code: outcome.code, message: outcome.message }, requestId));
|
|
144
|
+
}
|
|
145
|
+
const { data, nextCursor } = outcome.page;
|
|
146
|
+
return c.json({
|
|
147
|
+
data: data.map(serializeObservation),
|
|
148
|
+
hasMore: nextCursor !== undefined,
|
|
149
|
+
...(nextCursor !== undefined && { nextCursor: nextCursor as unknown as string }),
|
|
150
|
+
});
|
|
151
|
+
});
|
|
152
|
+
|
|
153
|
+
return r;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
function serializeObservation(o: Observation): Record<string, unknown> {
|
|
157
|
+
return {
|
|
158
|
+
id: o.id as unknown as string,
|
|
159
|
+
tenantId: o.tenantId as unknown as string,
|
|
160
|
+
supervisorId: o.supervisorId as unknown as string,
|
|
161
|
+
agentId: o.agentId as unknown as string,
|
|
162
|
+
agentVersion: o.agentVersion,
|
|
163
|
+
conversationId: o.conversationId as unknown as string,
|
|
164
|
+
turnNumber: o.turnNumber,
|
|
165
|
+
status: o.status,
|
|
166
|
+
...(o.failureCode !== undefined && { failureCode: o.failureCode }),
|
|
167
|
+
violations: o.violations,
|
|
168
|
+
...(o.failureDetail !== undefined && { failureDetail: o.failureDetail }),
|
|
169
|
+
durationMs: o.durationMs,
|
|
170
|
+
costUsd: o.costUsd,
|
|
171
|
+
...(o.provider !== undefined && { provider: o.provider }),
|
|
172
|
+
...(o.provenanceRef !== undefined && { provenanceRef: o.provenanceRef }),
|
|
173
|
+
observedAt: o.observedAt as unknown as string,
|
|
174
|
+
};
|
|
175
|
+
}
|