@kindgi/api 0.1.4 → 0.1.5-rc.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/agent-binding.d.ts +13 -0
- package/dist/agent-binding.d.ts.map +1 -1
- package/dist/agent-pins.d.ts.map +1 -1
- package/dist/agent-pins.js +18 -2
- package/dist/agent-pins.js.map +1 -1
- package/dist/app.d.ts +110 -17
- package/dist/app.d.ts.map +1 -1
- package/dist/app.js +163 -35
- package/dist/app.js.map +1 -1
- package/dist/block-publish.d.ts +56 -0
- package/dist/block-publish.d.ts.map +1 -0
- package/dist/block-publish.js +132 -0
- package/dist/block-publish.js.map +1 -0
- package/dist/caller.d.ts +24 -0
- package/dist/caller.d.ts.map +1 -0
- package/dist/caller.js +47 -0
- package/dist/caller.js.map +1 -0
- package/dist/capability-binding.d.ts +11 -0
- package/dist/capability-binding.d.ts.map +1 -1
- package/dist/derive-agent-version.d.ts +7 -0
- package/dist/derive-agent-version.d.ts.map +1 -1
- package/dist/derive-agent-version.js +4 -0
- package/dist/derive-agent-version.js.map +1 -1
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +73 -7
- package/dist/errors.js.map +1 -1
- package/dist/eval-case-binding.d.ts +16 -4
- package/dist/eval-case-binding.d.ts.map +1 -1
- package/dist/eval-run-binding.d.ts +31 -0
- package/dist/eval-run-binding.d.ts.map +1 -1
- package/dist/eval-run-dispatcher.d.ts +7 -0
- package/dist/eval-run-dispatcher.d.ts.map +1 -1
- package/dist/eval-run-dispatcher.js.map +1 -1
- package/dist/eval-sample.d.ts +11 -0
- package/dist/eval-sample.d.ts.map +1 -0
- package/dist/eval-sample.js +34 -0
- package/dist/eval-sample.js.map +1 -0
- package/dist/eval-suite-binding.d.ts +13 -0
- package/dist/eval-suite-binding.d.ts.map +1 -1
- package/dist/eval-suite-binding.js.map +1 -1
- package/dist/flow-binding.d.ts +18 -0
- package/dist/flow-binding.d.ts.map +1 -1
- package/dist/flow-pins.d.ts.map +1 -1
- package/dist/flow-pins.js +18 -2
- package/dist/flow-pins.js.map +1 -1
- package/dist/gate.d.ts.map +1 -1
- package/dist/gate.js +25 -0
- package/dist/gate.js.map +1 -1
- package/dist/handler-binding.d.ts +32 -0
- package/dist/handler-binding.d.ts.map +1 -1
- package/dist/hitl-binding.d.ts +23 -0
- package/dist/hitl-binding.d.ts.map +1 -1
- package/dist/identity-directory-binding.d.ts +82 -4
- package/dist/identity-directory-binding.d.ts.map +1 -1
- package/dist/identity-provider-binding.d.ts +197 -17
- package/dist/identity-provider-binding.d.ts.map +1 -1
- package/dist/improvement-pass-binding.d.ts +196 -0
- package/dist/improvement-pass-binding.d.ts.map +1 -0
- package/dist/improvement-pass-binding.js +9 -0
- package/dist/improvement-pass-binding.js.map +1 -0
- package/dist/index.d.ts +35 -17
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -3
- package/dist/index.js.map +1 -1
- package/dist/judged-dispatcher.d.ts +25 -4
- package/dist/judged-dispatcher.d.ts.map +1 -1
- package/dist/judged-dispatcher.js +43 -6
- package/dist/judged-dispatcher.js.map +1 -1
- package/dist/judgment-binding.d.ts +25 -1
- package/dist/judgment-binding.d.ts.map +1 -1
- package/dist/mcp-endpoint-binding.d.ts +7 -0
- package/dist/mcp-endpoint-binding.d.ts.map +1 -1
- package/dist/memory-binding.d.ts +124 -17
- package/dist/memory-binding.d.ts.map +1 -1
- package/dist/memory-erasure-binding.d.ts +145 -0
- package/dist/memory-erasure-binding.d.ts.map +1 -0
- package/dist/memory-erasure-binding.js +4 -0
- package/dist/memory-erasure-binding.js.map +1 -0
- package/dist/middleware/auth.d.ts +66 -13
- package/dist/middleware/auth.d.ts.map +1 -1
- package/dist/middleware/auth.js +150 -50
- package/dist/middleware/auth.js.map +1 -1
- package/dist/middleware/authorize.d.ts +6 -0
- package/dist/middleware/authorize.d.ts.map +1 -1
- package/dist/middleware/authorize.js +113 -4
- package/dist/middleware/authorize.js.map +1 -1
- package/dist/middleware/error-mapper.d.ts +5 -0
- package/dist/middleware/error-mapper.d.ts.map +1 -1
- package/dist/middleware/error-mapper.js +14 -1
- package/dist/middleware/error-mapper.js.map +1 -1
- package/dist/middleware/idempotency.d.ts +70 -5
- package/dist/middleware/idempotency.d.ts.map +1 -1
- package/dist/middleware/idempotency.js +174 -41
- package/dist/middleware/idempotency.js.map +1 -1
- package/dist/middleware/key-project.d.ts +17 -0
- package/dist/middleware/key-project.d.ts.map +1 -0
- package/dist/middleware/key-project.js +75 -0
- package/dist/middleware/key-project.js.map +1 -0
- package/dist/middleware/principal.d.ts.map +1 -1
- package/dist/middleware/principal.js +9 -5
- package/dist/middleware/principal.js.map +1 -1
- package/dist/middleware/project-ref.d.ts.map +1 -1
- package/dist/middleware/project-ref.js +3 -0
- package/dist/middleware/project-ref.js.map +1 -1
- package/dist/openapi/generate.d.ts.map +1 -1
- package/dist/openapi/generate.js +5 -2
- package/dist/openapi/generate.js.map +1 -1
- package/dist/openapi/operations.d.ts.map +1 -1
- package/dist/openapi/operations.js +918 -139
- package/dist/openapi/operations.js.map +1 -1
- package/dist/openapi/schemas.d.ts +90 -13
- package/dist/openapi/schemas.d.ts.map +1 -1
- package/dist/openapi/schemas.js +2081 -359
- package/dist/openapi/schemas.js.map +1 -1
- package/dist/person-grants-binding.d.ts +77 -0
- package/dist/person-grants-binding.d.ts.map +1 -0
- package/dist/person-grants-binding.js +4 -0
- package/dist/person-grants-binding.js.map +1 -0
- package/dist/proposal-service.d.ts +121 -0
- package/dist/proposal-service.d.ts.map +1 -0
- package/dist/proposal-service.js +447 -0
- package/dist/proposal-service.js.map +1 -0
- package/dist/proposal-status.d.ts +60 -0
- package/dist/proposal-status.d.ts.map +1 -0
- package/dist/proposal-status.js +109 -0
- package/dist/proposal-status.js.map +1 -0
- package/dist/provider-binding.d.ts +10 -0
- package/dist/provider-binding.d.ts.map +1 -1
- package/dist/publish-refused.d.ts +18 -3
- package/dist/publish-refused.d.ts.map +1 -1
- package/dist/publish-refused.js +18 -3
- package/dist/publish-refused.js.map +1 -1
- package/dist/routes/adapters.d.ts +2 -1
- package/dist/routes/adapters.d.ts.map +1 -1
- package/dist/routes/adapters.js +3 -1
- package/dist/routes/adapters.js.map +1 -1
- package/dist/routes/agent-releases.d.ts +55 -3
- package/dist/routes/agent-releases.d.ts.map +1 -1
- package/dist/routes/agent-releases.js +85 -55
- package/dist/routes/agent-releases.js.map +1 -1
- package/dist/routes/agents.d.ts +12 -1
- package/dist/routes/agents.d.ts.map +1 -1
- package/dist/routes/agents.js +100 -2
- package/dist/routes/agents.js.map +1 -1
- package/dist/routes/approvals.d.ts +15 -3
- package/dist/routes/approvals.d.ts.map +1 -1
- package/dist/routes/approvals.js +133 -122
- package/dist/routes/approvals.js.map +1 -1
- package/dist/routes/artifacts.d.ts +25 -3
- package/dist/routes/artifacts.d.ts.map +1 -1
- package/dist/routes/artifacts.js +116 -7
- package/dist/routes/artifacts.js.map +1 -1
- package/dist/routes/auth.d.ts +25 -1
- package/dist/routes/auth.d.ts.map +1 -1
- package/dist/routes/auth.js +655 -281
- package/dist/routes/auth.js.map +1 -1
- package/dist/routes/blocks.d.ts.map +1 -1
- package/dist/routes/blocks.js +2 -42
- package/dist/routes/blocks.js.map +1 -1
- package/dist/routes/capabilities.d.ts +2 -1
- package/dist/routes/capabilities.d.ts.map +1 -1
- package/dist/routes/capabilities.js +6 -1
- package/dist/routes/capabilities.js.map +1 -1
- package/dist/routes/compliance.d.ts +9 -10
- package/dist/routes/compliance.d.ts.map +1 -1
- package/dist/routes/compliance.js +42 -61
- package/dist/routes/compliance.js.map +1 -1
- package/dist/routes/conversations.d.ts +8 -1
- package/dist/routes/conversations.d.ts.map +1 -1
- package/dist/routes/conversations.js +87 -8
- package/dist/routes/conversations.js.map +1 -1
- package/dist/routes/cost.d.ts +7 -1
- package/dist/routes/cost.d.ts.map +1 -1
- package/dist/routes/cost.js +22 -3
- package/dist/routes/cost.js.map +1 -1
- package/dist/routes/denied.d.ts +11 -0
- package/dist/routes/denied.d.ts.map +1 -0
- package/dist/routes/denied.js +17 -0
- package/dist/routes/denied.js.map +1 -0
- package/dist/routes/deployments.d.ts +2 -1
- package/dist/routes/deployments.d.ts.map +1 -1
- package/dist/routes/deployments.js +44 -12
- package/dist/routes/deployments.js.map +1 -1
- package/dist/routes/eval-comparison.d.ts.map +1 -1
- package/dist/routes/eval-comparison.js +69 -1
- package/dist/routes/eval-comparison.js.map +1 -1
- package/dist/routes/eval-overrides.d.ts +18 -0
- package/dist/routes/eval-overrides.d.ts.map +1 -0
- package/dist/routes/eval-overrides.js +81 -0
- package/dist/routes/eval-overrides.js.map +1 -0
- package/dist/routes/eval-runs.d.ts +10 -1
- package/dist/routes/eval-runs.d.ts.map +1 -1
- package/dist/routes/eval-runs.js +63 -7
- package/dist/routes/eval-runs.js.map +1 -1
- package/dist/routes/eval-suites.d.ts.map +1 -1
- package/dist/routes/eval-suites.js +20 -1
- package/dist/routes/eval-suites.js.map +1 -1
- package/dist/routes/event-triggers.d.ts +5 -1
- package/dist/routes/event-triggers.d.ts.map +1 -1
- package/dist/routes/event-triggers.js +26 -3
- package/dist/routes/event-triggers.js.map +1 -1
- package/dist/routes/export-signing-keys.d.ts +12 -0
- package/dist/routes/export-signing-keys.d.ts.map +1 -0
- package/dist/routes/export-signing-keys.js +24 -0
- package/dist/routes/export-signing-keys.js.map +1 -0
- package/dist/routes/flows.d.ts.map +1 -1
- package/dist/routes/flows.js +9 -1
- package/dist/routes/flows.js.map +1 -1
- package/dist/routes/gate-policies.d.ts +4 -1
- package/dist/routes/gate-policies.d.ts.map +1 -1
- package/dist/routes/gate-policies.js +29 -5
- package/dist/routes/gate-policies.js.map +1 -1
- package/dist/routes/guardrails.d.ts +16 -14
- package/dist/routes/guardrails.d.ts.map +1 -1
- package/dist/routes/guardrails.js +39 -3
- package/dist/routes/guardrails.js.map +1 -1
- package/dist/routes/identity.d.ts +20 -4
- package/dist/routes/identity.d.ts.map +1 -1
- package/dist/routes/identity.js +246 -6
- package/dist/routes/identity.js.map +1 -1
- package/dist/routes/improvement-passes.d.ts +52 -0
- package/dist/routes/improvement-passes.d.ts.map +1 -0
- package/dist/routes/improvement-passes.js +449 -0
- package/dist/routes/improvement-passes.js.map +1 -0
- package/dist/routes/judged-suites.d.ts +50 -0
- package/dist/routes/judged-suites.d.ts.map +1 -1
- package/dist/routes/judged-suites.js +66 -27
- package/dist/routes/judged-suites.js.map +1 -1
- package/dist/routes/judgment-context.d.ts +18 -2
- package/dist/routes/judgment-context.d.ts.map +1 -1
- package/dist/routes/judgment-context.js +63 -5
- package/dist/routes/judgment-context.js.map +1 -1
- package/dist/routes/judgment-flow-context.d.ts.map +1 -1
- package/dist/routes/judgment-flow-context.js +14 -2
- package/dist/routes/judgment-flow-context.js.map +1 -1
- package/dist/routes/judgments.d.ts.map +1 -1
- package/dist/routes/judgments.js +8 -1
- package/dist/routes/judgments.js.map +1 -1
- package/dist/routes/mcp.d.ts.map +1 -1
- package/dist/routes/mcp.js +26 -1
- package/dist/routes/mcp.js.map +1 -1
- package/dist/routes/memory-access.d.ts +43 -0
- package/dist/routes/memory-access.d.ts.map +1 -0
- package/dist/routes/memory-access.js +129 -0
- package/dist/routes/memory-access.js.map +1 -0
- package/dist/routes/memory-erasures.d.ts +25 -0
- package/dist/routes/memory-erasures.d.ts.map +1 -0
- package/dist/routes/memory-erasures.js +214 -0
- package/dist/routes/memory-erasures.js.map +1 -0
- package/dist/routes/memory-parse.d.ts +38 -0
- package/dist/routes/memory-parse.d.ts.map +1 -0
- package/dist/routes/memory-parse.js +199 -0
- package/dist/routes/memory-parse.js.map +1 -0
- package/dist/routes/memory.d.ts +9 -4
- package/dist/routes/memory.d.ts.map +1 -1
- package/dist/routes/memory.js +226 -234
- package/dist/routes/memory.js.map +1 -1
- package/dist/routes/observations.d.ts +4 -1
- package/dist/routes/observations.d.ts.map +1 -1
- package/dist/routes/observations.js +8 -2
- package/dist/routes/observations.js.map +1 -1
- package/dist/routes/pagination.d.ts +7 -0
- package/dist/routes/pagination.d.ts.map +1 -1
- package/dist/routes/pagination.js +10 -0
- package/dist/routes/pagination.js.map +1 -1
- package/dist/routes/policies.d.ts +2 -1
- package/dist/routes/policies.d.ts.map +1 -1
- package/dist/routes/policies.js +3 -1
- package/dist/routes/policies.js.map +1 -1
- package/dist/routes/project-mismatch.d.ts +22 -0
- package/dist/routes/project-mismatch.d.ts.map +1 -0
- package/dist/routes/project-mismatch.js +34 -0
- package/dist/routes/project-mismatch.js.map +1 -0
- package/dist/routes/projects.d.ts +15 -4
- package/dist/routes/projects.d.ts.map +1 -1
- package/dist/routes/projects.js +100 -9
- package/dist/routes/projects.js.map +1 -1
- package/dist/routes/proposals.d.ts +25 -17
- package/dist/routes/proposals.d.ts.map +1 -1
- package/dist/routes/proposals.js +340 -507
- package/dist/routes/proposals.js.map +1 -1
- package/dist/routes/provenance.d.ts +17 -3
- package/dist/routes/provenance.d.ts.map +1 -1
- package/dist/routes/provenance.js +79 -103
- package/dist/routes/provenance.js.map +1 -1
- package/dist/routes/providers.d.ts +17 -1
- package/dist/routes/providers.d.ts.map +1 -1
- package/dist/routes/providers.js +110 -3
- package/dist/routes/providers.js.map +1 -1
- package/dist/routes/public-run-tokens.d.ts.map +1 -1
- package/dist/routes/public-run-tokens.js +3 -0
- package/dist/routes/public-run-tokens.js.map +1 -1
- package/dist/routes/runs.d.ts +10 -0
- package/dist/routes/runs.d.ts.map +1 -1
- package/dist/routes/runs.js +92 -42
- package/dist/routes/runs.js.map +1 -1
- package/dist/routes/schedules.d.ts +21 -13
- package/dist/routes/schedules.d.ts.map +1 -1
- package/dist/routes/schedules.js +416 -55
- package/dist/routes/schedules.js.map +1 -1
- package/dist/routes/segments.d.ts +2 -0
- package/dist/routes/segments.d.ts.map +1 -1
- package/dist/routes/segments.js +5 -0
- package/dist/routes/segments.js.map +1 -1
- package/dist/routes/service-accounts.d.ts +17 -0
- package/dist/routes/service-accounts.d.ts.map +1 -0
- package/dist/routes/service-accounts.js +212 -0
- package/dist/routes/service-accounts.js.map +1 -0
- package/dist/routes/sign-in-options.d.ts +50 -0
- package/dist/routes/sign-in-options.d.ts.map +1 -0
- package/dist/routes/sign-in-options.js +98 -0
- package/dist/routes/sign-in-options.js.map +1 -0
- package/dist/routes/signing-keys.d.ts +2 -1
- package/dist/routes/signing-keys.d.ts.map +1 -1
- package/dist/routes/signing-keys.js +3 -1
- package/dist/routes/signing-keys.js.map +1 -1
- package/dist/routes/tenant-access.d.ts +13 -0
- package/dist/routes/tenant-access.d.ts.map +1 -0
- package/dist/routes/tenant-access.js +26 -0
- package/dist/routes/tenant-access.js.map +1 -0
- package/dist/routes/tenant.d.ts.map +1 -1
- package/dist/routes/tenant.js +4 -0
- package/dist/routes/tenant.js.map +1 -1
- package/dist/routes/token-sign-in.d.ts +36 -0
- package/dist/routes/token-sign-in.d.ts.map +1 -0
- package/dist/routes/token-sign-in.js +101 -0
- package/dist/routes/token-sign-in.js.map +1 -0
- package/dist/routes/tokens.d.ts +15 -5
- package/dist/routes/tokens.d.ts.map +1 -1
- package/dist/routes/tokens.js +162 -43
- package/dist/routes/tokens.js.map +1 -1
- package/dist/routes/tools.d.ts.map +1 -1
- package/dist/routes/tools.js +9 -1
- package/dist/routes/tools.js.map +1 -1
- package/dist/routes/trigger-access.d.ts +29 -0
- package/dist/routes/trigger-access.d.ts.map +1 -0
- package/dist/routes/trigger-access.js +33 -0
- package/dist/routes/trigger-access.js.map +1 -0
- package/dist/routes/webhook-endpoints.d.ts +2 -1
- package/dist/routes/webhook-endpoints.d.ts.map +1 -1
- package/dist/routes/webhook-endpoints.js +11 -3
- package/dist/routes/webhook-endpoints.js.map +1 -1
- package/dist/routes/webhooks.d.ts +5 -1
- package/dist/routes/webhooks.d.ts.map +1 -1
- package/dist/routes/webhooks.js +25 -2
- package/dist/routes/webhooks.js.map +1 -1
- package/dist/run-failure.d.ts +21 -0
- package/dist/run-failure.d.ts.map +1 -0
- package/dist/run-failure.js +29 -0
- package/dist/run-failure.js.map +1 -0
- package/dist/service-account-binding.d.ts +108 -0
- package/dist/service-account-binding.d.ts.map +1 -0
- package/dist/service-account-binding.js +4 -0
- package/dist/service-account-binding.js.map +1 -0
- package/dist/session-store-binding.d.ts +61 -13
- package/dist/session-store-binding.d.ts.map +1 -1
- package/dist/signed-export.d.ts +89 -0
- package/dist/signed-export.d.ts.map +1 -0
- package/dist/signed-export.js +149 -0
- package/dist/signed-export.js.map +1 -0
- package/dist/supervisor-binding.d.ts +186 -413
- package/dist/supervisor-binding.d.ts.map +1 -1
- package/dist/testing/app-bindings.d.ts +33 -0
- package/dist/testing/app-bindings.d.ts.map +1 -0
- package/dist/testing/app-bindings.js +112 -0
- package/dist/testing/app-bindings.js.map +1 -0
- package/dist/testing/index.d.ts +11 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +13 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/stub-binding.d.ts +34 -0
- package/dist/testing/stub-binding.d.ts.map +1 -0
- package/dist/testing/stub-binding.js +42 -0
- package/dist/testing/stub-binding.js.map +1 -0
- package/dist/testing/trigger-registry.d.ts +21 -0
- package/dist/testing/trigger-registry.d.ts.map +1 -0
- package/dist/testing/trigger-registry.js +206 -0
- package/dist/testing/trigger-registry.js.map +1 -0
- package/dist/token-admin.d.ts +46 -8
- package/dist/token-admin.d.ts.map +1 -1
- package/dist/token-admin.js.map +1 -1
- package/dist/tool-binding.d.ts +13 -0
- package/dist/tool-binding.d.ts.map +1 -1
- package/dist/trigger-binding.d.ts +2 -2
- package/dist/trigger-binding.d.ts.map +1 -1
- package/dist/trigger-binding.js +1 -1
- package/dist/trigger-binding.js.map +1 -1
- package/dist/types.d.ts +16 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/webhook-endpoint-binding.d.ts +19 -3
- package/dist/webhook-endpoint-binding.d.ts.map +1 -1
- package/dist/webhook-endpoint-binding.js +1 -1
- package/dist/webhook-endpoint-binding.js.map +1 -1
- package/openapi.json +15385 -8788
- package/package.json +26 -22
- package/src/agent-binding.ts +14 -0
- package/src/agent-pins.ts +18 -2
- package/src/app.ts +366 -80
- package/src/block-publish.ts +181 -0
- package/src/caller.ts +62 -0
- package/src/capability-binding.ts +12 -0
- package/src/derive-agent-version.ts +9 -1
- package/src/errors.ts +73 -7
- package/src/eval-case-binding.ts +17 -1
- package/src/eval-run-binding.ts +31 -0
- package/src/eval-run-dispatcher.ts +7 -0
- package/src/eval-sample.ts +42 -0
- package/src/eval-suite-binding.ts +14 -0
- package/src/flow-binding.ts +19 -0
- package/src/flow-pins.ts +18 -2
- package/src/gate.ts +26 -0
- package/src/handler-binding.ts +36 -1
- package/src/hitl-binding.ts +24 -0
- package/src/identity-directory-binding.ts +85 -4
- package/src/identity-provider-binding.ts +216 -21
- package/src/improvement-pass-binding.ts +193 -0
- package/src/index.ts +153 -31
- package/src/judged-dispatcher.ts +78 -11
- package/src/judgment-binding.ts +25 -1
- package/src/mcp-endpoint-binding.ts +7 -0
- package/src/memory-binding.ts +121 -17
- package/src/memory-erasure-binding.ts +156 -0
- package/src/middleware/auth.ts +228 -62
- package/src/middleware/authorize.ts +139 -3
- package/src/middleware/error-mapper.ts +15 -1
- package/src/middleware/idempotency.ts +230 -43
- package/src/middleware/key-project.ts +86 -0
- package/src/middleware/principal.ts +9 -5
- package/src/middleware/project-ref.ts +3 -0
- package/src/openapi/generate.ts +11 -2
- package/src/openapi/operations.ts +1059 -142
- package/src/openapi/schemas.ts +2387 -469
- package/src/person-grants-binding.ts +76 -0
- package/src/proposal-service.ts +640 -0
- package/src/proposal-status.ts +176 -0
- package/src/provider-binding.ts +10 -0
- package/src/publish-refused.ts +38 -9
- package/src/routes/adapters.ts +4 -0
- package/src/routes/agent-releases.ts +121 -69
- package/src/routes/agents.ts +128 -1
- package/src/routes/approvals.ts +164 -154
- package/src/routes/artifacts.ts +181 -11
- package/src/routes/auth.ts +804 -336
- package/src/routes/blocks.ts +2 -53
- package/src/routes/capabilities.ts +10 -1
- package/src/routes/compliance.ts +60 -99
- package/src/routes/conversations.ts +101 -7
- package/src/routes/cost.ts +32 -3
- package/src/routes/denied.ts +28 -0
- package/src/routes/deployments.ts +62 -16
- package/src/routes/eval-comparison.ts +81 -2
- package/src/routes/eval-overrides.ts +108 -0
- package/src/routes/eval-runs.ts +86 -6
- package/src/routes/eval-suites.ts +25 -1
- package/src/routes/event-triggers.ts +27 -3
- package/src/routes/export-signing-keys.ts +31 -0
- package/src/routes/flows.ts +12 -1
- package/src/routes/gate-policies.ts +37 -6
- package/src/routes/guardrails.ts +61 -2
- package/src/routes/identity.ts +328 -10
- package/src/routes/improvement-passes.ts +541 -0
- package/src/routes/judged-suites.ts +113 -43
- package/src/routes/judgment-context.ts +76 -5
- package/src/routes/judgment-flow-context.ts +16 -2
- package/src/routes/judgments.ts +17 -3
- package/src/routes/mcp.ts +29 -1
- package/src/routes/memory-access.ts +179 -0
- package/src/routes/memory-erasures.ts +240 -0
- package/src/routes/memory-parse.ts +250 -0
- package/src/routes/memory.ts +244 -286
- package/src/routes/observations.ts +15 -2
- package/src/routes/pagination.ts +12 -0
- package/src/routes/policies.ts +7 -1
- package/src/routes/project-mismatch.ts +56 -0
- package/src/routes/projects.ts +107 -13
- package/src/routes/proposals.ts +370 -611
- package/src/routes/provenance.ts +99 -133
- package/src/routes/providers.ts +142 -3
- package/src/routes/public-run-tokens.ts +3 -0
- package/src/routes/runs.ts +119 -39
- package/src/routes/schedules.ts +472 -60
- package/src/routes/segments.ts +11 -0
- package/src/routes/service-accounts.ts +262 -0
- package/src/routes/sign-in-options.ts +168 -0
- package/src/routes/signing-keys.ts +7 -1
- package/src/routes/tenant-access.ts +37 -0
- package/src/routes/tenant.ts +6 -0
- package/src/routes/token-sign-in.ts +161 -0
- package/src/routes/tokens.ts +172 -46
- package/src/routes/tools.ts +12 -1
- package/src/routes/trigger-access.ts +72 -0
- package/src/routes/webhook-endpoints.ts +15 -3
- package/src/routes/webhooks.ts +26 -2
- package/src/run-failure.ts +42 -0
- package/src/service-account-binding.ts +113 -0
- package/src/session-store-binding.ts +65 -13
- package/src/signed-export.ts +250 -0
- package/src/supervisor-binding.ts +169 -409
- package/src/testing/app-bindings.ts +142 -0
- package/src/testing/index.ts +21 -0
- package/src/testing/stub-binding.ts +53 -0
- package/src/testing/trigger-registry.ts +259 -0
- package/src/token-admin.ts +40 -8
- package/src/tool-binding.ts +14 -0
- package/src/trigger-binding.ts +8 -1
- package/src/types.ts +16 -0
- package/src/webhook-endpoint-binding.ts +18 -3
package/dist/routes/schedules.js
CHANGED
|
@@ -1,25 +1,60 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
2
|
// Copyright (C) 2026 Kindgi Inc.
|
|
3
3
|
import { Hono } from 'hono';
|
|
4
|
+
import { ref } from '@kindgi/authz';
|
|
4
5
|
import { statusFor, toWireError } from '../errors.js';
|
|
6
|
+
import { SCHEDULE_DEFAULTS, } from '../trigger-binding.js';
|
|
7
|
+
import { parseImproveScheduleInput } from './improvement-passes.js';
|
|
8
|
+
import { liveScopeToWire, parseLiveScopeBody } from './live-scope-wire.js';
|
|
5
9
|
import { clampLimit } from './pagination.js';
|
|
10
|
+
import { UUID_RE } from './uuid-param.js';
|
|
6
11
|
/**
|
|
7
|
-
* Schedules
|
|
12
|
+
* Schedules: cron-kind triggers that start a run of an agent or a flow.
|
|
8
13
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
14
|
+
* POST /v1/schedules register
|
|
15
|
+
* GET /v1/schedules list (cursor-paginated)
|
|
16
|
+
* GET /v1/schedules/:triggerId[?upcoming=N] get, with its next N occurrences
|
|
17
|
+
* PATCH /v1/schedules/:triggerId update
|
|
18
|
+
* POST /v1/schedules/:triggerId/pause | resume | unregister
|
|
19
|
+
* GET /v1/schedules/:triggerId/fires its fire history, newest first
|
|
20
|
+
* POST /v1/schedules/:triggerId/run-now fire it now, outside the schedule
|
|
21
|
+
* POST /v1/schedules/:triggerId/owner the caller becomes the owner
|
|
17
22
|
*
|
|
18
|
-
*
|
|
19
|
-
*
|
|
23
|
+
* A schedule's runs act as its owner (whoever registered it, until an
|
|
24
|
+
* admin takes it over), checked again at every fire. With an authorizer:
|
|
25
|
+
* reads need `read` on the schedule's project, changes `write`, taking
|
|
26
|
+
* ownership `admin`, and registering or retargeting also needs `execute`
|
|
27
|
+
* on what it runs, as starting that run does. The `triggerId` is aliased
|
|
28
|
+
* as `scheduleId` in bodies.
|
|
20
29
|
*/
|
|
21
|
-
export function schedulesRouter(binding
|
|
30
|
+
export function schedulesRouter(binding, authorizer,
|
|
31
|
+
/** The tenant's Default project: where a schedule that names no project goes. */
|
|
32
|
+
projects) {
|
|
22
33
|
const r = new Hono();
|
|
34
|
+
/** Nothing, when allowed; else the authorizer's own 403. */
|
|
35
|
+
async function denied(c, action, resource) {
|
|
36
|
+
if (authorizer === undefined)
|
|
37
|
+
return undefined;
|
|
38
|
+
let allowed = false;
|
|
39
|
+
const answer = await authorizer.authorize(action, async () => resource)(c, async () => {
|
|
40
|
+
allowed = true;
|
|
41
|
+
});
|
|
42
|
+
return allowed ? undefined : answer;
|
|
43
|
+
}
|
|
44
|
+
/** The schedule, if it is one (another kind's id is not found here), and the caller may `action` it. */
|
|
45
|
+
async function scheduleFor(c, action) {
|
|
46
|
+
const requestId = c.get('requestId');
|
|
47
|
+
const tenantId = c.get('tenantId');
|
|
48
|
+
const triggerId = c.req.param('triggerId');
|
|
49
|
+
const rec = UUID_RE.test(triggerId) ? await binding.get({ tenantId, triggerId }) : null;
|
|
50
|
+
if (rec === null || rec.kind !== 'cron') {
|
|
51
|
+
return { kind: 'err', response: notFound(c, requestId, triggerId) };
|
|
52
|
+
}
|
|
53
|
+
const refused = await denied(c, action, ref('project', rec.projectId));
|
|
54
|
+
if (refused !== undefined)
|
|
55
|
+
return { kind: 'err', response: refused };
|
|
56
|
+
return { kind: 'ok', value: rec };
|
|
57
|
+
}
|
|
23
58
|
// ---------- POST / (register) ----------
|
|
24
59
|
r.post('/', async (c) => {
|
|
25
60
|
const requestId = c.get('requestId');
|
|
@@ -28,26 +63,51 @@ export function schedulesRouter(binding) {
|
|
|
28
63
|
if (parsed.kind === 'err')
|
|
29
64
|
return parsed.response;
|
|
30
65
|
const body = parsed.value;
|
|
31
|
-
const
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return bad(c, requestId, flowId.message);
|
|
36
|
-
if (flowVersion.kind === 'err')
|
|
37
|
-
return bad(c, requestId, flowVersion.message);
|
|
66
|
+
const target = parseTarget(body);
|
|
67
|
+
if (target.kind === 'err')
|
|
68
|
+
return bad(c, requestId, target.message);
|
|
69
|
+
const cronExpression = requireString(body, 'config.cronExpression');
|
|
38
70
|
if (cronExpression.kind === 'err')
|
|
39
71
|
return bad(c, requestId, cronExpression.message);
|
|
72
|
+
const policy = parsePolicy(body);
|
|
73
|
+
if (policy.kind === 'err')
|
|
74
|
+
return bad(c, requestId, policy.message);
|
|
75
|
+
const projectId = body.projectId;
|
|
76
|
+
if (projectId !== undefined && (typeof projectId !== 'string' || !UUID_RE.test(projectId))) {
|
|
77
|
+
return bad(c, requestId, '`projectId` must be a project id (a UUID)');
|
|
78
|
+
}
|
|
40
79
|
const rawConfig = (body.config ?? {});
|
|
80
|
+
const input = targetInput(target.value, rawConfig.input);
|
|
81
|
+
if (input.kind === 'err')
|
|
82
|
+
return bad(c, requestId, input.message);
|
|
83
|
+
// A schedule that names no project goes in its improve scope's
|
|
84
|
+
// project, else the tenant's Default project: checked and stored as
|
|
85
|
+
// that project. With no Default to find, the registry picks it, and
|
|
86
|
+
// only a tenant admin may.
|
|
87
|
+
const project = projectId ??
|
|
88
|
+
scopeProjectOf(target.value) ??
|
|
89
|
+
(await projects?.getDefault(tenantId))?.id;
|
|
90
|
+
const scopeProblem = improveScopeProblem(target.value, project);
|
|
91
|
+
if (scopeProblem !== undefined)
|
|
92
|
+
return bad(c, requestId, scopeProblem);
|
|
93
|
+
const refused = (project === undefined
|
|
94
|
+
? await denied(c, 'admin', ref('tenant', tenantId))
|
|
95
|
+
: await denied(c, 'write', ref('project', project))) ??
|
|
96
|
+
(await denied(c, ...targetAccess(target.value)));
|
|
97
|
+
if (refused !== undefined)
|
|
98
|
+
return refused;
|
|
41
99
|
const registerInput = {
|
|
42
100
|
kind: 'cron',
|
|
43
101
|
tenantId,
|
|
44
|
-
|
|
45
|
-
|
|
102
|
+
target: target.value,
|
|
103
|
+
...(project !== undefined && { projectId: project }),
|
|
104
|
+
owner: ownerOf(c),
|
|
46
105
|
config: {
|
|
47
106
|
cronExpression: cronExpression.value,
|
|
48
107
|
...(typeof rawConfig.timezone === 'string' && { timezone: rawConfig.timezone }),
|
|
49
|
-
...(
|
|
108
|
+
...(input.input !== undefined && { input: input.input }),
|
|
50
109
|
},
|
|
110
|
+
...policy.value,
|
|
51
111
|
...(typeof body.label === 'string' && body.label.length > 0 && { label: body.label }),
|
|
52
112
|
};
|
|
53
113
|
const result = await binding.register(registerInput);
|
|
@@ -59,6 +119,10 @@ export function schedulesRouter(binding) {
|
|
|
59
119
|
return c.json(serializeSchedule(result.value));
|
|
60
120
|
});
|
|
61
121
|
// ---------- GET / (list) ----------
|
|
122
|
+
// The tenant's schedules, then only those whose project the caller may
|
|
123
|
+
// read (`read` on it, as reading one schedule needs): a schedule's input
|
|
124
|
+
// and target are its project's. The page and its cursor are the
|
|
125
|
+
// tenant's, so a page can hold fewer than `limit` rows and still have more.
|
|
62
126
|
r.get('/', async (c) => {
|
|
63
127
|
const tenantId = c.get('tenantId');
|
|
64
128
|
const limit = clampLimit(c.req.query('limit'));
|
|
@@ -74,8 +138,12 @@ export function schedulesRouter(binding) {
|
|
|
74
138
|
...(cursorRaw !== undefined && cursorRaw.length > 0 && { cursor: cursorRaw }),
|
|
75
139
|
...(statusFilter !== undefined && { status: statusFilter }),
|
|
76
140
|
});
|
|
141
|
+
const rows = page.data;
|
|
142
|
+
const visible = authorizer === undefined
|
|
143
|
+
? rows
|
|
144
|
+
: await authorizer.filterByCan(c, 'read', rows, (rec) => ref('project', rec.projectId));
|
|
77
145
|
return c.json({
|
|
78
|
-
data:
|
|
146
|
+
data: visible.map((row) => serializeSchedule(row)),
|
|
79
147
|
hasMore: page.nextCursor !== undefined,
|
|
80
148
|
...(page.nextCursor !== undefined && { nextCursor: page.nextCursor }),
|
|
81
149
|
});
|
|
@@ -83,22 +151,53 @@ export function schedulesRouter(binding) {
|
|
|
83
151
|
// ---------- GET /:triggerId (get) ----------
|
|
84
152
|
r.get('/:triggerId', async (c) => {
|
|
85
153
|
const requestId = c.get('requestId');
|
|
86
|
-
const
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
154
|
+
const upcomingRaw = c.req.query('upcoming');
|
|
155
|
+
const upcoming = upcomingRaw === undefined ? undefined : Number(upcomingRaw);
|
|
156
|
+
if (upcoming !== undefined && (!Number.isInteger(upcoming) || upcoming < 1 || upcoming > 20)) {
|
|
157
|
+
return bad(c, requestId, '`upcoming` must be a whole number from 1 to 20');
|
|
158
|
+
}
|
|
159
|
+
const found = await scheduleFor(c, 'read');
|
|
160
|
+
if (found.kind === 'err')
|
|
161
|
+
return found.response;
|
|
162
|
+
if (upcoming === undefined)
|
|
163
|
+
return c.json(serializeSchedule(found.value));
|
|
164
|
+
const rec = await binding.get({
|
|
165
|
+
tenantId: c.get('tenantId'),
|
|
166
|
+
triggerId: found.value.triggerId,
|
|
167
|
+
upcoming,
|
|
168
|
+
});
|
|
169
|
+
return c.json(serializeSchedule((rec ?? found.value)));
|
|
92
170
|
});
|
|
93
171
|
// ---------- PATCH /:triggerId (update) ----------
|
|
94
172
|
r.patch('/:triggerId', async (c) => {
|
|
95
173
|
const requestId = c.get('requestId');
|
|
96
174
|
const tenantId = c.get('tenantId');
|
|
97
|
-
const triggerId = c.req.param('triggerId');
|
|
98
175
|
const parsed = await parseJsonObject(c, requestId);
|
|
99
176
|
if (parsed.kind === 'err')
|
|
100
177
|
return parsed.response;
|
|
101
178
|
const body = parsed.value;
|
|
179
|
+
const retarget = 'flowId' in body ||
|
|
180
|
+
'agentId' in body ||
|
|
181
|
+
'flowVersion' in body ||
|
|
182
|
+
'agentVersion' in body ||
|
|
183
|
+
'improve' in body;
|
|
184
|
+
const target = retarget ? parseTarget(body) : undefined;
|
|
185
|
+
if (target?.kind === 'err')
|
|
186
|
+
return bad(c, requestId, target.message);
|
|
187
|
+
const policy = parsePolicy(body);
|
|
188
|
+
if (policy.kind === 'err')
|
|
189
|
+
return bad(c, requestId, policy.message);
|
|
190
|
+
const found = await scheduleFor(c, 'write');
|
|
191
|
+
if (found.kind === 'err')
|
|
192
|
+
return found.response;
|
|
193
|
+
if (target !== undefined) {
|
|
194
|
+
const scopeProblem = improveScopeProblem(target.value, found.value.projectId);
|
|
195
|
+
if (scopeProblem !== undefined)
|
|
196
|
+
return bad(c, requestId, scopeProblem);
|
|
197
|
+
const refused = await denied(c, ...targetAccess(target.value));
|
|
198
|
+
if (refused !== undefined)
|
|
199
|
+
return refused;
|
|
200
|
+
}
|
|
102
201
|
const patchConfig = body.config;
|
|
103
202
|
const cfg = {};
|
|
104
203
|
if (patchConfig !== undefined) {
|
|
@@ -109,13 +208,22 @@ export function schedulesRouter(binding) {
|
|
|
109
208
|
if ('input' in patchConfig)
|
|
110
209
|
cfg.input = patchConfig.input;
|
|
111
210
|
}
|
|
211
|
+
if (target !== undefined || 'input' in cfg) {
|
|
212
|
+
const input = targetInput(target?.value ?? found.value.target, 'input' in cfg ? cfg.input : found.value.config.input);
|
|
213
|
+
if (input.kind === 'err')
|
|
214
|
+
return bad(c, requestId, input.message);
|
|
215
|
+
if (input.input !== undefined)
|
|
216
|
+
cfg.input = input.input;
|
|
217
|
+
}
|
|
218
|
+
const triggerId = found.value.triggerId;
|
|
112
219
|
const updateInput = {
|
|
113
220
|
kind: 'cron',
|
|
114
221
|
tenantId,
|
|
115
222
|
triggerId,
|
|
116
223
|
...(Object.keys(cfg).length > 0 && { config: cfg }),
|
|
224
|
+
...(target !== undefined && { target: target.value }),
|
|
225
|
+
...policy.value,
|
|
117
226
|
...('label' in body && { label: body.label === null ? null : body.label }),
|
|
118
|
-
...(typeof body.flowVersion === 'string' && { flowVersion: body.flowVersion }),
|
|
119
227
|
};
|
|
120
228
|
const result = await binding.update(updateInput);
|
|
121
229
|
if (result.kind === 'err') {
|
|
@@ -128,58 +236,304 @@ export function schedulesRouter(binding) {
|
|
|
128
236
|
}
|
|
129
237
|
return c.json(serializeSchedule(result.value));
|
|
130
238
|
});
|
|
131
|
-
// ---------- POST /:triggerId/pause ----------
|
|
132
|
-
|
|
239
|
+
// ---------- POST /:triggerId/pause | resume ----------
|
|
240
|
+
for (const verb of ['pause', 'resume']) {
|
|
241
|
+
r.post(`/:triggerId/${verb}`, async (c) => {
|
|
242
|
+
const requestId = c.get('requestId');
|
|
243
|
+
const found = await scheduleFor(c, 'write');
|
|
244
|
+
if (found.kind === 'err')
|
|
245
|
+
return found.response;
|
|
246
|
+
const { tenantId, triggerId } = found.value;
|
|
247
|
+
const result = await binding[verb]({ tenantId, triggerId });
|
|
248
|
+
if (result.kind === 'err')
|
|
249
|
+
return lifecycleError(c, requestId, result.error, triggerId);
|
|
250
|
+
return c.json(serializeSchedule(result.value));
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
// ---------- POST /:triggerId/unregister (soft delete) ----------
|
|
254
|
+
r.post('/:triggerId/unregister', async (c) => {
|
|
255
|
+
const found = await scheduleFor(c, 'write');
|
|
256
|
+
if (found.kind === 'err')
|
|
257
|
+
return found.response;
|
|
258
|
+
const { tenantId, triggerId } = found.value;
|
|
259
|
+
const outcome = await binding.unregister({ tenantId, triggerId });
|
|
260
|
+
return c.json({
|
|
261
|
+
scheduleId: triggerId,
|
|
262
|
+
unregistered: outcome.unregistered,
|
|
263
|
+
});
|
|
264
|
+
});
|
|
265
|
+
// ---------- GET /:triggerId/fires (history) ----------
|
|
266
|
+
r.get('/:triggerId/fires', async (c) => {
|
|
133
267
|
const requestId = c.get('requestId');
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
268
|
+
const found = await scheduleFor(c, 'read');
|
|
269
|
+
if (found.kind === 'err')
|
|
270
|
+
return found.response;
|
|
271
|
+
if (binding.listFires === undefined)
|
|
272
|
+
return unsupported(c, requestId, 'fire history');
|
|
273
|
+
const cursorRaw = c.req.query('cursor');
|
|
274
|
+
const page = await binding.listFires({
|
|
275
|
+
tenantId: found.value.tenantId,
|
|
276
|
+
triggerId: found.value.triggerId,
|
|
277
|
+
limit: clampLimit(c.req.query('limit')),
|
|
278
|
+
...(cursorRaw !== undefined && cursorRaw.length > 0 && { cursor: cursorRaw }),
|
|
279
|
+
});
|
|
280
|
+
return c.json({
|
|
281
|
+
data: page.data.map(serializeFire),
|
|
282
|
+
hasMore: page.nextCursor !== undefined,
|
|
283
|
+
...(page.nextCursor !== undefined && { nextCursor: page.nextCursor }),
|
|
284
|
+
});
|
|
285
|
+
});
|
|
286
|
+
// ---------- POST /:triggerId/run-now ----------
|
|
287
|
+
r.post('/:triggerId/run-now', async (c) => {
|
|
288
|
+
const requestId = c.get('requestId');
|
|
289
|
+
const found = await scheduleFor(c, 'write');
|
|
290
|
+
if (found.kind === 'err')
|
|
291
|
+
return found.response;
|
|
292
|
+
if (binding.fireNow === undefined)
|
|
293
|
+
return unsupported(c, requestId, 'run-now');
|
|
294
|
+
const { tenantId, triggerId } = found.value;
|
|
295
|
+
const result = await binding.fireNow({ tenantId, triggerId });
|
|
137
296
|
if (result.kind === 'err')
|
|
138
297
|
return lifecycleError(c, requestId, result.error, triggerId);
|
|
139
|
-
|
|
298
|
+
c.status(202);
|
|
299
|
+
return c.json(serializeFire(result.value));
|
|
140
300
|
});
|
|
141
|
-
// ---------- POST /:triggerId/
|
|
142
|
-
r.post('/:triggerId/
|
|
301
|
+
// ---------- POST /:triggerId/owner (take ownership) ----------
|
|
302
|
+
r.post('/:triggerId/owner', async (c) => {
|
|
143
303
|
const requestId = c.get('requestId');
|
|
144
|
-
const
|
|
145
|
-
|
|
146
|
-
|
|
304
|
+
const found = await scheduleFor(c, 'admin');
|
|
305
|
+
if (found.kind === 'err')
|
|
306
|
+
return found.response;
|
|
307
|
+
if (binding.setOwner === undefined)
|
|
308
|
+
return unsupported(c, requestId, 'changing the owner');
|
|
309
|
+
const refused = await denied(c, ...targetAccess(found.value.target));
|
|
310
|
+
if (refused !== undefined)
|
|
311
|
+
return refused;
|
|
312
|
+
const { tenantId, triggerId } = found.value;
|
|
313
|
+
const result = await binding.setOwner({ tenantId, triggerId, owner: ownerOf(c) });
|
|
147
314
|
if (result.kind === 'err')
|
|
148
315
|
return lifecycleError(c, requestId, result.error, triggerId);
|
|
149
316
|
return c.json(serializeSchedule(result.value));
|
|
150
317
|
});
|
|
151
|
-
// ---------- POST /:triggerId/unregister (soft delete) ----------
|
|
152
|
-
r.post('/:triggerId/unregister', async (c) => {
|
|
153
|
-
const tenantId = c.get('tenantId');
|
|
154
|
-
const triggerId = c.req.param('triggerId');
|
|
155
|
-
const outcome = await binding.unregister({ tenantId, triggerId });
|
|
156
|
-
return c.json({
|
|
157
|
-
scheduleId: triggerId,
|
|
158
|
-
unregistered: outcome.unregistered,
|
|
159
|
-
});
|
|
160
|
-
});
|
|
161
318
|
return r;
|
|
162
319
|
}
|
|
163
320
|
// -----------------------------------------------------------------------
|
|
164
321
|
// Shared helpers (co-located to keep each router self-contained).
|
|
165
322
|
// -----------------------------------------------------------------------
|
|
323
|
+
/** A target on the wire: `flowId` + `flowVersion`, `agentId` (+ `agentVersion`), or `improve`. */
|
|
324
|
+
function targetFields(target) {
|
|
325
|
+
switch (target.kind) {
|
|
326
|
+
case 'flow':
|
|
327
|
+
return { flowId: target.flowId, flowVersion: target.flowVersion };
|
|
328
|
+
case 'agent':
|
|
329
|
+
return {
|
|
330
|
+
agentId: target.agentId,
|
|
331
|
+
...(target.agentVersion !== undefined && { agentVersion: target.agentVersion }),
|
|
332
|
+
};
|
|
333
|
+
case 'improve':
|
|
334
|
+
return { improve: { agentId: target.agentId, scope: liveScopeToWire(target.scope) } };
|
|
335
|
+
}
|
|
336
|
+
}
|
|
166
337
|
function serializeSchedule(r) {
|
|
167
338
|
return {
|
|
168
339
|
scheduleId: r.triggerId,
|
|
169
340
|
triggerId: r.triggerId,
|
|
170
|
-
|
|
171
|
-
|
|
341
|
+
...targetFields(r.target),
|
|
342
|
+
projectId: r.projectId,
|
|
343
|
+
owner: { kind: r.owner.kind, id: r.owner.id },
|
|
172
344
|
cronExpression: r.config.cronExpression,
|
|
173
345
|
...(r.config.timezone !== undefined && { timezone: r.config.timezone }),
|
|
174
346
|
...(r.config.input !== undefined && { input: r.config.input }),
|
|
347
|
+
catchUp: r.catchUp,
|
|
348
|
+
overlap: r.overlap,
|
|
349
|
+
startingDeadlineSeconds: r.startingDeadlineSeconds,
|
|
175
350
|
label: r.label,
|
|
176
351
|
status: r.status,
|
|
352
|
+
...(r.statusReason !== undefined && { statusReason: r.statusReason }),
|
|
177
353
|
nextFireAt: r.nextFireAt,
|
|
354
|
+
...(r.upcoming !== undefined && { upcoming: r.upcoming }),
|
|
178
355
|
lastFiredAt: r.lastFiredAt,
|
|
179
356
|
createdAt: r.createdAt,
|
|
180
357
|
updatedAt: r.updatedAt,
|
|
181
358
|
};
|
|
182
359
|
}
|
|
360
|
+
function serializeFire(f) {
|
|
361
|
+
return {
|
|
362
|
+
fireId: f.fireId,
|
|
363
|
+
scheduleId: f.triggerId,
|
|
364
|
+
triggerId: f.triggerId,
|
|
365
|
+
...(f.scheduledFor !== undefined && { scheduledFor: f.scheduledFor }),
|
|
366
|
+
firedAt: f.firedAt,
|
|
367
|
+
outcome: f.outcome,
|
|
368
|
+
...(f.runId !== undefined && { runId: f.runId }),
|
|
369
|
+
...(f.passId !== undefined && { passId: f.passId }),
|
|
370
|
+
...(f.detail !== undefined && { detail: f.detail }),
|
|
371
|
+
...(f.missedCount !== undefined && { missedCount: f.missedCount }),
|
|
372
|
+
...(f.manual === true && { manual: true }),
|
|
373
|
+
};
|
|
374
|
+
}
|
|
375
|
+
/**
|
|
376
|
+
* What firing the target needs, as starting it by hand does: `execute` on
|
|
377
|
+
* the agent or flow a run starts; `publish` on the agent an improvement
|
|
378
|
+
* pass works on (as `POST /v1/proposals/improve`).
|
|
379
|
+
*/
|
|
380
|
+
function targetAccess(target) {
|
|
381
|
+
switch (target.kind) {
|
|
382
|
+
case 'flow':
|
|
383
|
+
return ['execute', ref('flow', target.flowId)];
|
|
384
|
+
case 'agent':
|
|
385
|
+
return ['execute', ref('agent', target.agentId)];
|
|
386
|
+
case 'improve':
|
|
387
|
+
return ['publish', ref('agent', target.agentId)];
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/** Who a schedule's runs act as: the request's principal. */
|
|
391
|
+
function ownerOf(c) {
|
|
392
|
+
const actor = c.get('principal')?.actor;
|
|
393
|
+
if (actor === undefined)
|
|
394
|
+
return { kind: 'service', id: 'unknown' };
|
|
395
|
+
return { kind: actor.kind === 'user' ? 'user' : 'service', id: actor.id };
|
|
396
|
+
}
|
|
397
|
+
/** `flowId` + `flowVersion`, `agentId` (+ `agentVersion`), or `improve`: exactly one target. */
|
|
398
|
+
function parseTarget(body) {
|
|
399
|
+
const { flowId, flowVersion, agentId, agentVersion, improve } = body;
|
|
400
|
+
const named = (v) => typeof v === 'string' && v.length > 0;
|
|
401
|
+
if ([named(flowId), named(agentId), improve !== undefined].filter(Boolean).length !== 1) {
|
|
402
|
+
return {
|
|
403
|
+
kind: 'err',
|
|
404
|
+
message: 'Name what the schedule runs: `flowId` (with `flowVersion`), `agentId`, or `improve` ({ agentId, scope }), one of them',
|
|
405
|
+
};
|
|
406
|
+
}
|
|
407
|
+
if (improve !== undefined)
|
|
408
|
+
return parseImproveTarget(improve, flowVersion, agentVersion);
|
|
409
|
+
if (named(flowId)) {
|
|
410
|
+
if (!named(flowVersion))
|
|
411
|
+
return { kind: 'err', message: '`flowVersion` is required with `flowId`' };
|
|
412
|
+
if (agentVersion !== undefined) {
|
|
413
|
+
return { kind: 'err', message: '`agentVersion` goes with `agentId`, not `flowId`' };
|
|
414
|
+
}
|
|
415
|
+
return {
|
|
416
|
+
kind: 'ok',
|
|
417
|
+
value: { kind: 'flow', flowId: flowId, flowVersion: flowVersion },
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
if (flowVersion !== undefined) {
|
|
421
|
+
return { kind: 'err', message: '`flowVersion` goes with `flowId`, not `agentId`' };
|
|
422
|
+
}
|
|
423
|
+
if (agentVersion !== undefined && !named(agentVersion)) {
|
|
424
|
+
return { kind: 'err', message: '`agentVersion` must be a version (semver)' };
|
|
425
|
+
}
|
|
426
|
+
return {
|
|
427
|
+
kind: 'ok',
|
|
428
|
+
value: {
|
|
429
|
+
kind: 'agent',
|
|
430
|
+
agentId: agentId,
|
|
431
|
+
...(agentVersion !== undefined && { agentVersion: agentVersion }),
|
|
432
|
+
},
|
|
433
|
+
};
|
|
434
|
+
}
|
|
435
|
+
/** An improve scope's project, when it names one. */
|
|
436
|
+
function scopeProjectOf(target) {
|
|
437
|
+
if (target.kind !== 'improve')
|
|
438
|
+
return undefined;
|
|
439
|
+
const { scope } = target;
|
|
440
|
+
return scope.kind === 'project' || scope.kind === 'segment'
|
|
441
|
+
? scope.projectId
|
|
442
|
+
: undefined;
|
|
443
|
+
}
|
|
444
|
+
/**
|
|
445
|
+
* A pass's evidence must cover the scope it changes: an improve schedule
|
|
446
|
+
* learns from its project's runs (for a segment scope, that segment's),
|
|
447
|
+
* so its scope is the schedule's own project or a segment of it. The
|
|
448
|
+
* tenant and an org span projects: going wider stays a promotion by hand,
|
|
449
|
+
* through that scope's gate.
|
|
450
|
+
*/
|
|
451
|
+
function improveScopeProblem(target, project) {
|
|
452
|
+
if (target.kind !== 'improve')
|
|
453
|
+
return undefined;
|
|
454
|
+
if (target.scope.kind === 'tenant' || target.scope.kind === 'org') {
|
|
455
|
+
return `An improve schedule's scope is a project or a segment of it, not the ${target.scope.kind === 'org' ? 'org' : 'tenant'}: a pass's evidence must cover the scope it changes, and it learns from one project's runs. Use the project (or a segment) scope; promote to the ${target.scope.kind === 'org' ? 'org' : 'tenant'} by hand after review.`;
|
|
456
|
+
}
|
|
457
|
+
const own = scopeProjectOf(target);
|
|
458
|
+
if (own !== undefined && project !== undefined && own !== project) {
|
|
459
|
+
return "An improve schedule's scope must be in the schedule's project (`projectId`): it learns from that project's runs";
|
|
460
|
+
}
|
|
461
|
+
return undefined;
|
|
462
|
+
}
|
|
463
|
+
function parseImproveTarget(improve, flowVersion, agentVersion) {
|
|
464
|
+
const shape = 'An improve schedule names `improve: { agentId, scope }`: the agent its passes work on, and the live scope they propose for';
|
|
465
|
+
if (flowVersion !== undefined || agentVersion !== undefined) {
|
|
466
|
+
return {
|
|
467
|
+
kind: 'err',
|
|
468
|
+
message: `${shape}; \`flowVersion\` and \`agentVersion\` don't go with it`,
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
const o = typeof improve === 'object' && improve !== null && !Array.isArray(improve)
|
|
472
|
+
? improve
|
|
473
|
+
: undefined;
|
|
474
|
+
if (o === undefined ||
|
|
475
|
+
Object.keys(o).some((k) => k !== 'agentId' && k !== 'scope') ||
|
|
476
|
+
typeof o.agentId !== 'string' ||
|
|
477
|
+
o.agentId.length === 0) {
|
|
478
|
+
return { kind: 'err', message: shape };
|
|
479
|
+
}
|
|
480
|
+
const scope = parseLiveScopeBody(o.scope);
|
|
481
|
+
if (scope.kind === 'err')
|
|
482
|
+
return { kind: 'err', message: `\`improve.scope\`: ${scope.message}` };
|
|
483
|
+
return { kind: 'ok', value: { kind: 'improve', agentId: o.agentId, scope: scope.scope } };
|
|
484
|
+
}
|
|
485
|
+
/**
|
|
486
|
+
* The input a target's fires get, or why it can't be: an agent's run takes
|
|
487
|
+
* the agent payload, so an agent schedule's input must carry the message
|
|
488
|
+
* each run sends (without it every fire would be refused); an improve
|
|
489
|
+
* schedule's input is its pass options, kept with the defaults applied; a
|
|
490
|
+
* flow's input is the flow's own.
|
|
491
|
+
*/
|
|
492
|
+
function targetInput(target, input) {
|
|
493
|
+
if (target.kind === 'improve') {
|
|
494
|
+
const parsed = parseImproveScheduleInput(input);
|
|
495
|
+
return parsed.kind === 'ok' ? { kind: 'ok', input: parsed.input } : parsed;
|
|
496
|
+
}
|
|
497
|
+
if (target.kind === 'flow')
|
|
498
|
+
return { kind: 'ok', ...(input !== undefined && { input }) };
|
|
499
|
+
const message = typeof input === 'object' && input !== null
|
|
500
|
+
? input.userMessage
|
|
501
|
+
: undefined;
|
|
502
|
+
if (typeof message === 'string' && message.length > 0)
|
|
503
|
+
return { kind: 'ok', input };
|
|
504
|
+
return {
|
|
505
|
+
kind: 'err',
|
|
506
|
+
message: 'An agent schedule needs `config.input.userMessage`: the message each run sends the agent (`{ userMessage, parameters? }`)',
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
/** `catchUp`, `overlap` and `startingDeadlineSeconds`, each optional. */
|
|
510
|
+
function parsePolicy(body) {
|
|
511
|
+
const { catchUp, overlap, startingDeadlineSeconds } = body;
|
|
512
|
+
if (catchUp !== undefined && catchUp !== 'latest' && catchUp !== 'skip') {
|
|
513
|
+
return { kind: 'err', message: '`catchUp` must be `latest` or `skip`' };
|
|
514
|
+
}
|
|
515
|
+
if (overlap !== undefined && overlap !== 'skip' && overlap !== 'allow') {
|
|
516
|
+
return { kind: 'err', message: '`overlap` must be `skip` or `allow`' };
|
|
517
|
+
}
|
|
518
|
+
if (startingDeadlineSeconds !== undefined &&
|
|
519
|
+
(typeof startingDeadlineSeconds !== 'number' ||
|
|
520
|
+
!Number.isInteger(startingDeadlineSeconds) ||
|
|
521
|
+
startingDeadlineSeconds < 1 ||
|
|
522
|
+
startingDeadlineSeconds > 86_400)) {
|
|
523
|
+
return {
|
|
524
|
+
kind: 'err',
|
|
525
|
+
message: `\`startingDeadlineSeconds\` must be a whole number of seconds from 1 to 86400 (default ${SCHEDULE_DEFAULTS.startingDeadlineSeconds})`,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
return {
|
|
529
|
+
kind: 'ok',
|
|
530
|
+
value: {
|
|
531
|
+
...(catchUp !== undefined && { catchUp }),
|
|
532
|
+
...(overlap !== undefined && { overlap }),
|
|
533
|
+
...(startingDeadlineSeconds !== undefined && { startingDeadlineSeconds }),
|
|
534
|
+
},
|
|
535
|
+
};
|
|
536
|
+
}
|
|
183
537
|
async function parseJsonObject(c, requestId) {
|
|
184
538
|
let body;
|
|
185
539
|
try {
|
|
@@ -219,11 +573,18 @@ function bad(c, requestId, message) {
|
|
|
219
573
|
c.status(statusFor('bad-input'));
|
|
220
574
|
return c.json(toWireError({ code: 'bad-input', message }, requestId));
|
|
221
575
|
}
|
|
576
|
+
function unsupported(c, requestId, what) {
|
|
577
|
+
c.status(statusFor('trigger-operation-unsupported'));
|
|
578
|
+
return c.json(toWireError({
|
|
579
|
+
code: 'trigger-operation-unsupported',
|
|
580
|
+
message: `This deployment's schedules don't support ${what} yet.`,
|
|
581
|
+
}, requestId));
|
|
582
|
+
}
|
|
222
583
|
function notFound(c, requestId, triggerId) {
|
|
223
584
|
c.status(statusFor('trigger-not-found'));
|
|
224
585
|
return c.json(toWireError({
|
|
225
586
|
code: 'trigger-not-found',
|
|
226
|
-
message: `No
|
|
587
|
+
message: `No schedule with id "${triggerId}"`,
|
|
227
588
|
triggerId: triggerId,
|
|
228
589
|
}, requestId));
|
|
229
590
|
}
|