@proofoftech/flowsafe 0.11.0 → 0.13.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/CHANGELOG.md +54 -0
- package/README.md +91 -44
- package/deployment-identity-protocol.d.mts +52 -0
- package/deployment-identity-protocol.mjs +231 -0
- package/dist/agent-host/approval-resumer.d.ts +3 -3
- package/dist/agent-host/approval-resumer.d.ts.map +1 -1
- package/dist/agent-host/approval-resumer.js +6 -7
- package/dist/agent-host/approval-resumer.js.map +1 -1
- package/dist/agent-host/catalog.js +2 -2
- package/dist/agent-host/catalog.js.map +1 -1
- package/dist/agent-host/index.d.ts +2 -2
- package/dist/agent-host/index.d.ts.map +1 -1
- package/dist/agent-host/index.js.map +1 -1
- package/dist/agent-host/router.d.ts +2 -2
- package/dist/agent-host/router.d.ts.map +1 -1
- package/dist/agent-host/router.js +22 -54
- package/dist/agent-host/router.js.map +1 -1
- package/dist/agent-host/thread-host.d.ts +42 -8
- package/dist/agent-host/thread-host.d.ts.map +1 -1
- package/dist/agent-host/thread-host.js +533 -106
- package/dist/agent-host/thread-host.js.map +1 -1
- package/dist/agent-host/thread-topology.d.ts +28 -7
- package/dist/agent-host/thread-topology.d.ts.map +1 -1
- package/dist/agent-host/thread-topology.js +97 -39
- package/dist/agent-host/thread-topology.js.map +1 -1
- package/dist/agent-host/trusted-context.d.ts.map +1 -1
- package/dist/agent-host/trusted-context.js +3 -1
- package/dist/agent-host/trusted-context.js.map +1 -1
- package/dist/agent-host/types.d.ts +2 -0
- package/dist/agent-host/types.d.ts.map +1 -1
- package/dist/agent-runner/agent-run-state.d.ts +9 -8
- package/dist/agent-runner/agent-run-state.d.ts.map +1 -1
- package/dist/agent-runner/agent-run-state.js +78 -40
- package/dist/agent-runner/agent-run-state.js.map +1 -1
- package/dist/agent-runner/durable-agent-runner.d.ts +18 -16
- package/dist/agent-runner/durable-agent-runner.d.ts.map +1 -1
- package/dist/agent-runner/durable-agent-runner.js +120 -43
- package/dist/agent-runner/durable-agent-runner.js.map +1 -1
- package/dist/agent-runner/index.d.ts +1 -1
- package/dist/agent-runner/index.d.ts.map +1 -1
- package/dist/agent-runner/index.js +1 -1
- package/dist/agent-runner/index.js.map +1 -1
- package/dist/approval-api/actor-context.d.ts +67 -0
- package/dist/approval-api/actor-context.d.ts.map +1 -0
- package/dist/approval-api/actor-context.js +120 -0
- package/dist/approval-api/actor-context.js.map +1 -0
- package/dist/approval-api/contract.d.ts +12 -23
- package/dist/approval-api/contract.d.ts.map +1 -1
- package/dist/approval-api/d1-store.d.ts +7 -15
- package/dist/approval-api/d1-store.d.ts.map +1 -1
- package/dist/approval-api/d1-store.js +83 -159
- package/dist/approval-api/d1-store.js.map +1 -1
- package/dist/approval-api/grants.d.ts +3 -17
- package/dist/approval-api/grants.d.ts.map +1 -1
- package/dist/approval-api/grants.js +19 -39
- package/dist/approval-api/grants.js.map +1 -1
- package/dist/approval-api/index.d.ts +8 -8
- package/dist/approval-api/index.d.ts.map +1 -1
- package/dist/approval-api/index.js +5 -5
- package/dist/approval-api/index.js.map +1 -1
- package/dist/approval-api/principal.d.ts +29 -30
- package/dist/approval-api/principal.d.ts.map +1 -1
- package/dist/approval-api/principal.js +73 -54
- package/dist/approval-api/principal.js.map +1 -1
- package/dist/approval-api/resource-ownership.d.ts +64 -0
- package/dist/approval-api/resource-ownership.d.ts.map +1 -0
- package/dist/approval-api/resource-ownership.js +329 -0
- package/dist/approval-api/resource-ownership.js.map +1 -0
- package/dist/approval-api/retention.d.ts +6 -11
- package/dist/approval-api/retention.d.ts.map +1 -1
- package/dist/approval-api/retention.js +7 -12
- package/dist/approval-api/retention.js.map +1 -1
- package/dist/approval-api/router.d.ts +9 -8
- package/dist/approval-api/router.d.ts.map +1 -1
- package/dist/approval-api/router.js +50 -18
- package/dist/approval-api/router.js.map +1 -1
- package/dist/approval-api/service.d.ts +26 -36
- package/dist/approval-api/service.d.ts.map +1 -1
- package/dist/approval-api/service.js +104 -166
- package/dist/approval-api/service.js.map +1 -1
- package/dist/approval-api/store-factory.d.ts +19 -0
- package/dist/approval-api/store-factory.d.ts.map +1 -0
- package/dist/approval-api/store-factory.js +49 -0
- package/dist/approval-api/store-factory.js.map +1 -0
- package/dist/approval-api/store.d.ts +22 -36
- package/dist/approval-api/store.d.ts.map +1 -1
- package/dist/approval-api/store.js +48 -66
- package/dist/approval-api/store.js.map +1 -1
- package/dist/approval-api/types.d.ts +28 -22
- package/dist/approval-api/types.d.ts.map +1 -1
- package/dist/approval-api/types.js +51 -3
- package/dist/approval-api/types.js.map +1 -1
- package/dist/approval-ui/client.js +3 -3
- package/dist/approval-ui/client.js.map +1 -1
- package/dist/approval-ui/stream.d.ts +4 -4
- package/dist/approval-ui/stream.d.ts.map +1 -1
- package/dist/approval-ui/stream.js +2 -2
- package/dist/approval-ui/tips.d.ts +1 -1
- package/dist/approval-ui/tips.js +1 -1
- package/dist/approval-ui/tips.js.map +1 -1
- package/dist/approval-ui/use-approval-dashboard.d.ts +3 -3
- package/dist/approval-ui/use-approval-dashboard.js +1 -1
- package/dist/artifacts/index.d.ts +2 -3
- package/dist/artifacts/index.d.ts.map +1 -1
- package/dist/artifacts/index.js +9 -8
- package/dist/artifacts/index.js.map +1 -1
- package/dist/audit-export/audit-proxy.d.ts +71 -0
- package/dist/audit-export/audit-proxy.d.ts.map +1 -0
- package/dist/audit-export/audit-proxy.js +142 -0
- package/dist/audit-export/audit-proxy.js.map +1 -0
- package/dist/audit-export/index.d.ts +4 -7
- package/dist/audit-export/index.d.ts.map +1 -1
- package/dist/audit-export/index.js +1 -4
- package/dist/audit-export/index.js.map +1 -1
- package/dist/audit-export/queue-types.d.ts +5 -0
- package/dist/audit-export/queue-types.d.ts.map +1 -0
- package/dist/audit-export/queue-types.js +3 -0
- package/dist/audit-export/queue-types.js.map +1 -0
- package/dist/background-tasks/d1-storage.d.ts +9 -19
- package/dist/background-tasks/d1-storage.d.ts.map +1 -1
- package/dist/background-tasks/d1-storage.js +22 -52
- package/dist/background-tasks/d1-storage.js.map +1 -1
- package/dist/background-tasks/host.d.ts +4 -6
- package/dist/background-tasks/host.d.ts.map +1 -1
- package/dist/background-tasks/host.js +14 -17
- package/dist/background-tasks/host.js.map +1 -1
- package/dist/background-tasks/index.d.ts +1 -1
- package/dist/background-tasks/index.d.ts.map +1 -1
- package/dist/background-tasks/index.js +3 -3
- package/dist/background-tasks/index.js.map +1 -1
- package/dist/background-tasks/routes.d.ts +8 -4
- package/dist/background-tasks/routes.d.ts.map +1 -1
- package/dist/background-tasks/routes.js +33 -31
- package/dist/background-tasks/routes.js.map +1 -1
- package/dist/deployment-identity-protocol.d.ts +3 -0
- package/dist/deployment-identity-protocol.d.ts.map +1 -0
- package/dist/deployment-identity-protocol.js +3 -0
- package/dist/deployment-identity-protocol.js.map +1 -0
- package/dist/do-runner/breakwater-keys.d.ts +7 -5
- package/dist/do-runner/breakwater-keys.d.ts.map +1 -1
- package/dist/do-runner/breakwater-keys.js +7 -5
- package/dist/do-runner/breakwater-keys.js.map +1 -1
- package/dist/do-runner/cf-types.d.ts +18 -12
- package/dist/do-runner/cf-types.d.ts.map +1 -1
- package/dist/do-runner/cf-types.js.map +1 -1
- package/dist/do-runner/d1-storage.d.ts +51 -189
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +111 -362
- package/dist/do-runner/d1-storage.js.map +1 -1
- package/dist/do-runner/deployment-identity.d.ts +121 -0
- package/dist/do-runner/deployment-identity.d.ts.map +1 -0
- package/dist/do-runner/deployment-identity.js +272 -0
- package/dist/do-runner/deployment-identity.js.map +1 -0
- package/dist/do-runner/do-error-response.d.ts +1 -1
- package/dist/do-runner/do-error-response.d.ts.map +1 -1
- package/dist/do-runner/do-error-response.js +7 -1
- package/dist/do-runner/do-error-response.js.map +1 -1
- package/dist/do-runner/durable-object.d.ts +23 -16
- package/dist/do-runner/durable-object.d.ts.map +1 -1
- package/dist/do-runner/durable-object.js +303 -70
- package/dist/do-runner/durable-object.js.map +1 -1
- package/dist/do-runner/execution-context.d.ts +1 -0
- package/dist/do-runner/execution-context.d.ts.map +1 -1
- package/dist/do-runner/execution-context.js +4 -7
- package/dist/do-runner/execution-context.js.map +1 -1
- package/dist/do-runner/execution-principal-header.d.ts +16 -0
- package/dist/do-runner/execution-principal-header.d.ts.map +1 -0
- package/dist/do-runner/execution-principal-header.js +20 -0
- package/dist/do-runner/execution-principal-header.js.map +1 -0
- package/dist/do-runner/hub-do.d.ts +17 -25
- package/dist/do-runner/hub-do.d.ts.map +1 -1
- package/dist/do-runner/hub-do.js +63 -59
- package/dist/do-runner/hub-do.js.map +1 -1
- package/dist/do-runner/index.d.ts +12 -10
- package/dist/do-runner/index.d.ts.map +1 -1
- package/dist/do-runner/index.js +10 -9
- package/dist/do-runner/index.js.map +1 -1
- package/dist/do-runner/init.d.ts +0 -7
- package/dist/do-runner/init.d.ts.map +1 -1
- package/dist/do-runner/init.js +1 -2
- package/dist/do-runner/init.js.map +1 -1
- package/dist/do-runner/memory-id.d.ts +8 -25
- package/dist/do-runner/memory-id.d.ts.map +1 -1
- package/dist/do-runner/memory-id.js +25 -52
- package/dist/do-runner/memory-id.js.map +1 -1
- package/dist/do-runner/path-safe-id.d.ts +2 -48
- package/dist/do-runner/path-safe-id.d.ts.map +1 -1
- package/dist/do-runner/path-safe-id.js +3 -93
- package/dist/do-runner/path-safe-id.js.map +1 -1
- package/dist/do-runner/pubsub.d.ts +1 -1
- package/dist/do-runner/pubsub.js +1 -1
- package/dist/do-runner/runtime.d.ts +47 -34
- package/dist/do-runner/runtime.d.ts.map +1 -1
- package/dist/do-runner/runtime.js +281 -143
- package/dist/do-runner/runtime.js.map +1 -1
- package/dist/do-runner/schedule-source.d.ts +81 -0
- package/dist/do-runner/schedule-source.d.ts.map +1 -0
- package/dist/do-runner/schedule-source.js +64 -0
- package/dist/do-runner/schedule-source.js.map +1 -0
- package/dist/do-runner/table-prefix.d.ts +3 -0
- package/dist/do-runner/table-prefix.d.ts.map +1 -0
- package/dist/do-runner/table-prefix.js +17 -0
- package/dist/do-runner/table-prefix.js.map +1 -0
- package/dist/do-runner/thread-do.d.ts +18 -32
- package/dist/do-runner/thread-do.d.ts.map +1 -1
- package/dist/do-runner/thread-do.js +52 -74
- package/dist/do-runner/thread-do.js.map +1 -1
- package/dist/goals/objective-routes.d.ts +7 -4
- package/dist/goals/objective-routes.d.ts.map +1 -1
- package/dist/goals/objective-routes.js +58 -43
- package/dist/goals/objective-routes.js.map +1 -1
- package/dist/host-kit/approval-bridge.d.ts +18 -21
- package/dist/host-kit/approval-bridge.d.ts.map +1 -1
- package/dist/host-kit/approval-bridge.js +37 -37
- package/dist/host-kit/approval-bridge.js.map +1 -1
- package/dist/host-kit/bearer-auth.d.ts +3 -4
- package/dist/host-kit/bearer-auth.d.ts.map +1 -1
- package/dist/host-kit/bearer-auth.js +7 -11
- package/dist/host-kit/bearer-auth.js.map +1 -1
- package/dist/host-kit/do-run-topology.d.ts +14 -5
- package/dist/host-kit/do-run-topology.d.ts.map +1 -1
- package/dist/host-kit/do-run-topology.js +47 -15
- package/dist/host-kit/do-run-topology.js.map +1 -1
- package/dist/host-kit/env-vars.d.ts +1 -1
- package/dist/host-kit/env-vars.js +1 -1
- package/dist/host-kit/flowsafe-worker.d.ts +159 -80
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +629 -142
- package/dist/host-kit/flowsafe-worker.js.map +1 -1
- package/dist/host-kit/host-approval-service.d.ts +62 -54
- package/dist/host-kit/host-approval-service.d.ts.map +1 -1
- package/dist/host-kit/host-approval-service.js +90 -61
- package/dist/host-kit/host-approval-service.js.map +1 -1
- package/dist/host-kit/hub-topology.d.ts +6 -7
- package/dist/host-kit/hub-topology.d.ts.map +1 -1
- package/dist/host-kit/hub-topology.js +16 -12
- package/dist/host-kit/hub-topology.js.map +1 -1
- package/dist/host-kit/index.d.ts +13 -11
- package/dist/host-kit/index.d.ts.map +1 -1
- package/dist/host-kit/index.js +9 -12
- package/dist/host-kit/index.js.map +1 -1
- package/dist/host-kit/maintenance-capability.d.ts +58 -0
- package/dist/host-kit/maintenance-capability.d.ts.map +1 -0
- package/dist/host-kit/maintenance-capability.js +268 -0
- package/dist/host-kit/maintenance-capability.js.map +1 -0
- package/dist/host-kit/memory-boundary.d.ts +4 -19
- package/dist/host-kit/memory-boundary.d.ts.map +1 -1
- package/dist/host-kit/memory-boundary.js +12 -27
- package/dist/host-kit/memory-boundary.js.map +1 -1
- package/dist/host-kit/resource-access.d.ts +4 -0
- package/dist/host-kit/resource-access.d.ts.map +1 -0
- package/dist/host-kit/resource-access.js +12 -0
- package/dist/host-kit/resource-access.js.map +1 -0
- package/dist/host-kit/run-router.d.ts +25 -15
- package/dist/host-kit/run-router.d.ts.map +1 -1
- package/dist/host-kit/run-router.js +61 -46
- package/dist/host-kit/run-router.js.map +1 -1
- package/dist/host-kit/state-egress.d.ts +51 -0
- package/dist/host-kit/state-egress.d.ts.map +1 -0
- package/dist/host-kit/state-egress.js +120 -0
- package/dist/host-kit/state-egress.js.map +1 -0
- package/dist/host-kit/stream-router.d.ts +9 -4
- package/dist/host-kit/stream-router.d.ts.map +1 -1
- package/dist/host-kit/stream-router.js +45 -38
- package/dist/host-kit/stream-router.js.map +1 -1
- package/dist/host-kit/stream-ticket.d.ts +10 -10
- package/dist/host-kit/stream-ticket.d.ts.map +1 -1
- package/dist/host-kit/stream-ticket.js +60 -90
- package/dist/host-kit/stream-ticket.js.map +1 -1
- package/dist/host-kit/thread-topology.d.ts +17 -11
- package/dist/host-kit/thread-topology.d.ts.map +1 -1
- package/dist/host-kit/thread-topology.js +33 -59
- package/dist/host-kit/thread-topology.js.map +1 -1
- package/dist/host-kit/verifier.d.ts +6 -6
- package/dist/host-kit/verifier.d.ts.map +1 -1
- package/dist/host-kit/verifier.js +51 -119
- package/dist/host-kit/verifier.js.map +1 -1
- package/dist/http-body.d.ts +20 -0
- package/dist/http-body.d.ts.map +1 -0
- package/dist/http-body.js +67 -0
- package/dist/http-body.js.map +1 -0
- package/dist/schedules/index.d.ts +3 -2
- package/dist/schedules/index.d.ts.map +1 -1
- package/dist/schedules/index.js +5 -4
- package/dist/schedules/index.js.map +1 -1
- package/dist/schedules/router.d.ts +16 -10
- package/dist/schedules/router.d.ts.map +1 -1
- package/dist/schedules/router.js +153 -91
- package/dist/schedules/router.js.map +1 -1
- package/dist/schedules/schedules-d1.d.ts +88 -0
- package/dist/schedules/schedules-d1.d.ts.map +1 -1
- package/dist/schedules/schedules-d1.js +411 -50
- package/dist/schedules/schedules-d1.js.map +1 -1
- package/dist/schedules/target-policy.d.ts +29 -0
- package/dist/schedules/target-policy.d.ts.map +1 -0
- package/dist/schedules/target-policy.js +70 -0
- package/dist/schedules/target-policy.js.map +1 -0
- package/dist/schedules/tick.d.ts +125 -21
- package/dist/schedules/tick.d.ts.map +1 -1
- package/dist/schedules/tick.js +637 -160
- package/dist/schedules/tick.js.map +1 -1
- package/dist/signal-providers/delivery.d.ts +0 -19
- package/dist/signal-providers/delivery.d.ts.map +1 -1
- package/dist/signal-providers/delivery.js +5 -54
- package/dist/signal-providers/delivery.js.map +1 -1
- package/dist/signal-providers/github-provider.d.ts.map +1 -1
- package/dist/signal-providers/github-provider.js +9 -16
- package/dist/signal-providers/github-provider.js.map +1 -1
- package/dist/signal-providers/host-do.d.ts +3 -45
- package/dist/signal-providers/host-do.d.ts.map +1 -1
- package/dist/signal-providers/host-do.js +86 -106
- package/dist/signal-providers/host-do.js.map +1 -1
- package/dist/signal-providers/host-topology.d.ts +5 -14
- package/dist/signal-providers/host-topology.d.ts.map +1 -1
- package/dist/signal-providers/host-topology.js +11 -25
- package/dist/signal-providers/host-topology.js.map +1 -1
- package/dist/signal-providers/index.d.ts +3 -3
- package/dist/signal-providers/index.d.ts.map +1 -1
- package/dist/signal-providers/index.js +3 -3
- package/dist/signal-providers/index.js.map +1 -1
- package/dist/signal-providers/provider.d.ts +4 -5
- package/dist/signal-providers/provider.d.ts.map +1 -1
- package/dist/signal-providers/provider.js +5 -6
- package/dist/signal-providers/provider.js.map +1 -1
- package/dist/signal-providers/subscription-d1.d.ts +10 -57
- package/dist/signal-providers/subscription-d1.d.ts.map +1 -1
- package/dist/signal-providers/subscription-d1.js +208 -155
- package/dist/signal-providers/subscription-d1.js.map +1 -1
- package/dist/signal-providers/webhook-route.d.ts +28 -14
- package/dist/signal-providers/webhook-route.d.ts.map +1 -1
- package/dist/signal-providers/webhook-route.js +117 -88
- package/dist/signal-providers/webhook-route.js.map +1 -1
- package/dist/signals/client.js +8 -8
- package/dist/signals/client.js.map +1 -1
- package/dist/signals/d1-shared.js +1 -1
- package/dist/signals/d1-shared.js.map +1 -1
- package/dist/signals/index.d.ts +1 -1
- package/dist/signals/index.d.ts.map +1 -1
- package/dist/signals/index.js.map +1 -1
- package/dist/signals/notification-dispatch.d.ts +12 -6
- package/dist/signals/notification-dispatch.d.ts.map +1 -1
- package/dist/signals/notification-dispatch.js +37 -21
- package/dist/signals/notification-dispatch.js.map +1 -1
- package/dist/signals/notifications-d1.d.ts +5 -8
- package/dist/signals/notifications-d1.d.ts.map +1 -1
- package/dist/signals/notifications-d1.js +8 -13
- package/dist/signals/notifications-d1.js.map +1 -1
- package/dist/signals/router.d.ts +10 -10
- package/dist/signals/router.d.ts.map +1 -1
- package/dist/signals/router.js +49 -51
- package/dist/signals/router.js.map +1 -1
- package/dist/signals/thread-do-routes.d.ts +74 -15
- package/dist/signals/thread-do-routes.d.ts.map +1 -1
- package/dist/signals/thread-do-routes.js +484 -41
- package/dist/signals/thread-do-routes.js.map +1 -1
- package/dist/signals/thread-state-d1.d.ts.map +1 -1
- package/dist/signals/thread-state-d1.js +2 -3
- package/dist/signals/thread-state-d1.js.map +1 -1
- package/package.json +29 -6
- package/scripts/seed-deployment-identity.mjs +252 -0
- package/dist/approval-api/tenant-brand.d.ts +0 -35
- package/dist/approval-api/tenant-brand.d.ts.map +0 -1
- package/dist/approval-api/tenant-brand.js +0 -19
- package/dist/approval-api/tenant-brand.js.map +0 -1
- package/dist/approval-api/tenant-context.d.ts +0 -84
- package/dist/approval-api/tenant-context.d.ts.map +0 -1
- package/dist/approval-api/tenant-context.js +0 -112
- package/dist/approval-api/tenant-context.js.map +0 -1
- package/dist/approval-api/tenant-store.d.ts +0 -36
- package/dist/approval-api/tenant-store.d.ts.map +0 -1
- package/dist/approval-api/tenant-store.js +0 -129
- package/dist/approval-api/tenant-store.js.map +0 -1
- package/dist/do-runner/resume-ledger.d.ts +0 -48
- package/dist/do-runner/resume-ledger.d.ts.map +0 -1
- package/dist/do-runner/resume-ledger.js +0 -60
- package/dist/do-runner/resume-ledger.js.map +0 -1
- package/dist/do-runner/thread-header.d.ts +0 -31
- package/dist/do-runner/thread-header.d.ts.map +0 -1
- package/dist/do-runner/thread-header.js +0 -39
- package/dist/do-runner/thread-header.js.map +0 -1
- package/dist/host-kit/subdomain-check.d.ts +0 -23
- package/dist/host-kit/subdomain-check.d.ts.map +0 -1
- package/dist/host-kit/subdomain-check.js +0 -61
- package/dist/host-kit/subdomain-check.js.map +0 -1
- package/dist/host-kit/tenant-registry.d.ts +0 -51
- package/dist/host-kit/tenant-registry.d.ts.map +0 -1
- package/dist/host-kit/tenant-registry.js +0 -88
- package/dist/host-kit/tenant-registry.js.map +0 -1
|
@@ -2,10 +2,9 @@ import type { ApprovalActor } from '../approval-api/index.js';
|
|
|
2
2
|
import { type TokenVerifier } from './verifier.js';
|
|
3
3
|
/**
|
|
4
4
|
* Parse the `APPROVAL_ACTOR_TOKENS` secret:
|
|
5
|
-
* `{"<token>": {"id","role"
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* than trusted; there is no `as`-cast at this JSON boundary.
|
|
5
|
+
* `{"<token>": {"id","role"}}`. Every entry passes the real validator
|
|
6
|
+
* (`toApprovalActor`) — unknown roles and empty ids are dropped rather than
|
|
7
|
+
* trusted; there is no `as` cast at this JSON boundary.
|
|
9
8
|
*/
|
|
10
9
|
export declare function parseActorTokens(raw: string | undefined): Map<string, ApprovalActor>;
|
|
11
10
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bearer-auth.d.ts","sourceRoot":"","sources":["../../src/host-kit/bearer-auth.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"bearer-auth.d.ts","sourceRoot":"","sources":["../../src/host-kit/bearer-auth.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AAC9D,OAAO,EAAE,KAAK,aAAa,EAAmB,MAAM,eAAe,CAAC;AAEpE;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,GAAG,SAAS,GACtB,GAAG,CAAC,MAAM,EAAE,aAAa,CAAC,CAiC5B;AAED;;;;;;GAMG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,aAAa,GACtB,CAAC,OAAO,EAAE,OAAO,KAAK,OAAO,CAAC,aAAa,GAAG,SAAS,CAAC,CAO1D"}
|
|
@@ -3,19 +3,15 @@
|
|
|
3
3
|
// to a TokenVerifier (static map or HS256 JWT — verifier.ts), get back an
|
|
4
4
|
// ApprovalActor or undefined.
|
|
5
5
|
//
|
|
6
|
-
// This is trusted-computing-base code: it
|
|
7
|
-
//
|
|
8
|
-
//
|
|
9
|
-
// empty map and every authenticated route 401s, and an entry without an
|
|
10
|
-
// INV-3-valid tenantId is dropped (its token 401s) rather than admitted
|
|
11
|
-
// tenant-less.
|
|
6
|
+
// This is trusted-computing-base code: it asserts the identity and role that
|
|
7
|
+
// authorization consumes. A malformed map fails closed — an unparseable or
|
|
8
|
+
// absent secret yields an empty map and every authenticated route 401s.
|
|
12
9
|
import { toApprovalActor } from './verifier.js';
|
|
13
10
|
/**
|
|
14
11
|
* Parse the `APPROVAL_ACTOR_TOKENS` secret:
|
|
15
|
-
* `{"<token>": {"id","role"
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* than trusted; there is no `as`-cast at this JSON boundary.
|
|
12
|
+
* `{"<token>": {"id","role"}}`. Every entry passes the real validator
|
|
13
|
+
* (`toApprovalActor`) — unknown roles and empty ids are dropped rather than
|
|
14
|
+
* trusted; there is no `as` cast at this JSON boundary.
|
|
19
15
|
*/
|
|
20
16
|
export function parseActorTokens(raw) {
|
|
21
17
|
const actors = new Map();
|
|
@@ -44,7 +40,7 @@ export function parseActorTokens(raw) {
|
|
|
44
40
|
console.error(JSON.stringify({
|
|
45
41
|
type: 'config-error',
|
|
46
42
|
var: 'APPROVAL_ACTOR_TOKENS',
|
|
47
|
-
reason:
|
|
43
|
+
reason: 'entry dropped: needs a non-empty id and a known role — its token will 401',
|
|
48
44
|
}));
|
|
49
45
|
}
|
|
50
46
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bearer-auth.js","sourceRoot":"","sources":["../../src/host-kit/bearer-auth.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,4EAA4E;AAC5E,0EAA0E;AAC1E,8BAA8B;AAC9B,EAAE;AACF,
|
|
1
|
+
{"version":3,"file":"bearer-auth.js","sourceRoot":"","sources":["../../src/host-kit/bearer-auth.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,4EAA4E;AAC5E,0EAA0E;AAC1E,8BAA8B;AAC9B,EAAE;AACF,6EAA6E;AAC7E,2EAA2E;AAC3E,wEAAwE;AAGxE,OAAO,EAAsB,eAAe,EAAE,MAAM,eAAe,CAAC;AAEpE;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,GAAuB;IAEvB,MAAM,MAAM,GAAG,IAAI,GAAG,EAAyB,CAAC;IAChD,IAAI,CAAC,GAAG;QAAE,OAAO,MAAM,CAAC;IACxB,IAAI,MAAe,CAAC;IACpB,IAAI,CAAC;QACH,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAC3B,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,KAAK,CACX,IAAI,CAAC,SAAS,CAAC;YACb,IAAI,EAAE,cAAc;YACpB,GAAG,EAAE,uBAAuB;YAC5B,MAAM,EAAE,oDAAoD;SAC7D,CAAC,CACH,CAAC;QACF,OAAO,MAAM,CAAC;IAChB,CAAC;IACD,IAAI,MAAM,KAAK,IAAI,IAAI,OAAO,MAAM,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC;IACjE,KAAK,MAAM,CAAC,KAAK,EAAE,SAAS,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,eAAe,CAAC,SAAS,CAAC,CAAC;QACzC,IAAI,KAAK,EAAE,CAAC;YACV,MAAM,CAAC,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3B,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,KAAK,CACX,IAAI,CAAC,SAAS,CAAC;gBACb,IAAI,EAAE,cAAc;gBACpB,GAAG,EAAE,uBAAuB;gBAC5B,MAAM,EACJ,2EAA2E;aAC9E,CAAC,CACH,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAAuB;IAEvB,OAAO,KAAK,EAAE,OAAO,EAAE,EAAE;QACvB,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO;aAC1B,GAAG,CAAC,eAAe,CAAC;YACrB,EAAE,KAAK,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACnC,OAAO,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACpD,CAAC,CAAC;AACJ,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { ApprovalDecision, ApprovalRecord } from '../approval-api/index.js';
|
|
2
|
-
import type
|
|
1
|
+
import type { ApprovalDecision, ApprovalRecord, ExecutionPrincipalKind } from '../approval-api/index.js';
|
|
2
|
+
import { type RunSummary } from '../do-runner/index.js';
|
|
3
3
|
import { type DoResponseLike } from './do-response.js';
|
|
4
|
+
import type { RunStartInput } from './run-router.js';
|
|
4
5
|
/** The subset of a DurableObjectStub the topology uses. */
|
|
5
6
|
export interface RunnerStubLike {
|
|
6
7
|
fetch(url: string, init?: {
|
|
@@ -16,11 +17,13 @@ export interface RunnerNamespaceLike<Id = unknown> {
|
|
|
16
17
|
}
|
|
17
18
|
export interface DoRunTopology {
|
|
18
19
|
/** createRunRouter's `start` thunk. */
|
|
19
|
-
start(
|
|
20
|
+
start(input: DoRunStartInput): Promise<RunSummary>;
|
|
20
21
|
/** createRunRouter's `status` thunk (a DO 404 reads as undefined). */
|
|
21
22
|
status(workflowId: string, runId: string): Promise<RunSummary | undefined>;
|
|
23
|
+
/** Waits behind start/recovery before declaring a dispatch absent. */
|
|
24
|
+
dispatchStatus(workflowId: string, runId: string): Promise<RunSummary | undefined>;
|
|
22
25
|
/** createRunRouter's `resume` thunk. */
|
|
23
|
-
resume(workflowId: string, runId: string, body: unknown): Promise<RunSummary>;
|
|
26
|
+
resume(workflowId: string, runId: string, body: unknown, requestedBy: string, requestedByKind: ExecutionPrincipalKind): Promise<RunSummary>;
|
|
24
27
|
/**
|
|
25
28
|
* ApprovalServiceOptions.resumeRun base: resume a DECIDED approval's run
|
|
26
29
|
* through its DO stub with the standard resumeData contract. Hand this to
|
|
@@ -28,5 +31,11 @@ export interface DoRunTopology {
|
|
|
28
31
|
*/
|
|
29
32
|
resumeRecord(record: ApprovalRecord, decision: ApprovalDecision): Promise<RunSummary>;
|
|
30
33
|
}
|
|
31
|
-
export
|
|
34
|
+
export type DoRunStartInput = RunStartInput & {
|
|
35
|
+
/** Prepared trigger paired with scheduleId for a one-shot schedule fire. */
|
|
36
|
+
dispatchId?: string;
|
|
37
|
+
/** Ordinary trusted starts may seed core workflow state. */
|
|
38
|
+
initialState?: unknown;
|
|
39
|
+
};
|
|
40
|
+
export declare function createDoRunTopology<Id>(namespace: RunnerNamespaceLike<Id>, deploymentIdentitySecret: string): DoRunTopology;
|
|
32
41
|
//# sourceMappingURL=do-run-topology.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"do-run-topology.d.ts","sourceRoot":"","sources":["../../src/host-kit/do-run-topology.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,
|
|
1
|
+
{"version":3,"file":"do-run-topology.d.ts","sourceRoot":"","sources":["../../src/host-kit/do-run-topology.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAKlC,OAAO,EAGL,KAAK,UAAU,EAChB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,KAAK,cAAc,EAAa,MAAM,kBAAkB,CAAC;AAClE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAErD,2DAA2D;AAC3D,MAAM,WAAW,cAAc;IAC7B,KAAK,CACH,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;QACL,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GACA,OAAO,CAAC,cAAc,CAAC,CAAC;CAC5B;AAED,gEAAgE;AAChE,MAAM,WAAW,mBAAmB,CAAC,EAAE,GAAG,OAAO;IAC/C,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,EAAE,CAAC;IAC7B,GAAG,CAAC,EAAE,EAAE,EAAE,GAAG,cAAc,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,uCAAuC;IACvC,KAAK,CAAC,KAAK,EAAE,eAAe,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IACnD,sEAAsE;IACtE,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IAC3E,sEAAsE;IACtE,cAAc,CACZ,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CAAC;IACnC,wCAAwC;IACxC,MAAM,CACJ,UAAU,EAAE,MAAM,EAClB,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,OAAO,EACb,WAAW,EAAE,MAAM,EACnB,eAAe,EAAE,sBAAsB,GACtC,OAAO,CAAC,UAAU,CAAC,CAAC;IACvB;;;;OAIG;IACH,YAAY,CACV,MAAM,EAAE,cAAc,EACtB,QAAQ,EAAE,gBAAgB,GACzB,OAAO,CAAC,UAAU,CAAC,CAAC;CACxB;AAED,MAAM,MAAM,eAAe,GAAG,aAAa,GAAG;IAC5C,4EAA4E;IAC5E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB,CAAC;AAEF,wBAAgB,mBAAmB,CAAC,EAAE,EACpC,SAAS,EAAE,mBAAmB,CAAC,EAAE,CAAC,EAClC,wBAAwB,EAAE,MAAM,GAC/B,aAAa,CAiGf"}
|
|
@@ -5,36 +5,68 @@
|
|
|
5
5
|
// via doSummary. Hosts pass their `env.RUNNER` binding directly — the
|
|
6
6
|
// namespace/stub types are structural subsets so this module (like the rest
|
|
7
7
|
// of host-kit) never imports @cloudflare/workers-types.
|
|
8
|
-
import { defaultResumeData } from '../approval-api/index.js';
|
|
8
|
+
import { defaultResumeData, encodeExecutionPrincipal, } from '../approval-api/index.js';
|
|
9
|
+
import { deploymentIdentityHeaders, EXECUTION_PRINCIPAL_HEADER, } from '../do-runner/index.js';
|
|
9
10
|
import { doSummary } from './do-response.js';
|
|
10
|
-
export function createDoRunTopology(namespace) {
|
|
11
|
+
export function createDoRunTopology(namespace, deploymentIdentitySecret) {
|
|
11
12
|
// One DO per (workflowId, runId): the name join is unambiguous because
|
|
12
13
|
// PATH_SAFE_ID_PATTERN excludes ':' from both ids.
|
|
13
14
|
const stub = (workflowId, runId) => namespace.get(namespace.idFromName(`${workflowId}:${runId}`));
|
|
14
|
-
const resume = async (workflowId, runId, body) => doSummary(await stub(workflowId, runId).fetch(`http://do/runs/${workflowId}/${runId}/resume`, {
|
|
15
|
+
const resume = async (workflowId, runId, body, requestedBy, requestedByKind) => doSummary(await stub(workflowId, runId).fetch(`http://do/runs/${workflowId}/${runId}/resume`, {
|
|
15
16
|
method: 'POST',
|
|
16
|
-
headers: {
|
|
17
|
-
|
|
17
|
+
headers: deploymentIdentityHeaders(deploymentIdentitySecret, {
|
|
18
|
+
'content-type': 'application/json',
|
|
19
|
+
}),
|
|
20
|
+
body: JSON.stringify({
|
|
21
|
+
...(body && typeof body === 'object' ? body : {}),
|
|
22
|
+
requestedBy,
|
|
23
|
+
requestedByKind,
|
|
24
|
+
}),
|
|
18
25
|
}));
|
|
19
26
|
return {
|
|
20
|
-
start: async (workflowId, runId, inputData
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
27
|
+
start: async ({ workflowId, runId, inputData, initialState, principal, scheduleId, dispatchId, }) => {
|
|
28
|
+
if ((scheduleId === undefined) !== (dispatchId === undefined)) {
|
|
29
|
+
throw new Error('scheduled run starts require both scheduleId and dispatchId');
|
|
30
|
+
}
|
|
31
|
+
return doSummary(await stub(workflowId, runId).fetch('http://do/runs', {
|
|
32
|
+
method: 'POST',
|
|
33
|
+
headers: deploymentIdentityHeaders(deploymentIdentitySecret, {
|
|
34
|
+
'content-type': 'application/json',
|
|
35
|
+
[EXECUTION_PRINCIPAL_HEADER]: encodeExecutionPrincipal(principal),
|
|
36
|
+
}),
|
|
37
|
+
body: JSON.stringify({
|
|
38
|
+
workflowId,
|
|
39
|
+
runId,
|
|
40
|
+
...(scheduleId === undefined
|
|
41
|
+
? { inputData, initialState }
|
|
42
|
+
: { scheduleId, dispatchId }),
|
|
43
|
+
}),
|
|
44
|
+
}));
|
|
45
|
+
},
|
|
25
46
|
// The DO answers 404 for a run it has never seen; the router turns the
|
|
26
47
|
// undefined into its own 404 rather than leaking the DO's body.
|
|
27
48
|
status: async (workflowId, runId) => {
|
|
28
|
-
const response = await stub(workflowId, runId).fetch(`http://do/runs/${workflowId}/${runId}
|
|
49
|
+
const response = await stub(workflowId, runId).fetch(`http://do/runs/${workflowId}/${runId}`, { headers: deploymentIdentityHeaders(deploymentIdentitySecret) });
|
|
50
|
+
if (response.status === 404)
|
|
51
|
+
return undefined;
|
|
52
|
+
return doSummary(response);
|
|
53
|
+
},
|
|
54
|
+
dispatchStatus: async (workflowId, runId) => {
|
|
55
|
+
const response = await stub(workflowId, runId).fetch(`http://do/runs/${workflowId}/${runId}/dispatch-status`, { headers: deploymentIdentityHeaders(deploymentIdentitySecret) });
|
|
29
56
|
if (response.status === 404)
|
|
30
57
|
return undefined;
|
|
31
58
|
return doSummary(response);
|
|
32
59
|
},
|
|
33
60
|
resume,
|
|
34
|
-
resumeRecord: (record, decision) =>
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
61
|
+
resumeRecord: (record, decision) => {
|
|
62
|
+
if (!record.decidedBy) {
|
|
63
|
+
throw new Error(`approval '${record.id}' has no decision actor`);
|
|
64
|
+
}
|
|
65
|
+
return resume(record.workflowId, record.runId, {
|
|
66
|
+
step: record.stepPath,
|
|
67
|
+
resumeData: defaultResumeData(record, decision),
|
|
68
|
+
}, record.decidedBy, 'human');
|
|
69
|
+
},
|
|
38
70
|
};
|
|
39
71
|
}
|
|
40
72
|
//# sourceMappingURL=do-run-topology.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"do-run-topology.js","sourceRoot":"","sources":["../../src/host-kit/do-run-topology.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,wEAAwE;AACxE,4EAA4E;AAC5E,6EAA6E;AAC7E,sEAAsE;AACtE,4EAA4E;AAC5E,wDAAwD;
|
|
1
|
+
{"version":3,"file":"do-run-topology.js","sourceRoot":"","sources":["../../src/host-kit/do-run-topology.ts"],"names":[],"mappings":"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"}
|
|
@@ -22,7 +22,7 @@ export declare function numberVar(raw: string | undefined, fallback: number, nam
|
|
|
22
22
|
* IRREVERSIBLE delete happens at all, so a fallback would not preserve behavior,
|
|
23
23
|
* it would INVENT it — and invent a threshold the caller has already decided it
|
|
24
24
|
* cannot pick on the operator's behalf. Never expiring is recoverable; deleting
|
|
25
|
-
* a
|
|
25
|
+
* a deployment's conversations because a var was mistyped is not.
|
|
26
26
|
*
|
|
27
27
|
* The empty-string case is not hypothetical: `''` is what an unset CI/CD
|
|
28
28
|
* variable interpolates to and what a blank wrangler `vars` entry produces, and
|
|
@@ -30,7 +30,7 @@ export function numberVar(raw, fallback, name, options = {}) {
|
|
|
30
30
|
* IRREVERSIBLE delete happens at all, so a fallback would not preserve behavior,
|
|
31
31
|
* it would INVENT it — and invent a threshold the caller has already decided it
|
|
32
32
|
* cannot pick on the operator's behalf. Never expiring is recoverable; deleting
|
|
33
|
-
* a
|
|
33
|
+
* a deployment's conversations because a var was mistyped is not.
|
|
34
34
|
*
|
|
35
35
|
* The empty-string case is not hypothetical: `''` is what an unset CI/CD
|
|
36
36
|
* variable interpolates to and what a blank wrangler `vars` entry produces, and
|
|
@@ -1,15 +1,60 @@
|
|
|
1
|
-
import type { ApprovalAuditEvent, ApprovalDatabase, ApprovalNotificationSink
|
|
2
|
-
import type
|
|
3
|
-
import type {
|
|
1
|
+
import type { ActorContext, ActorResolver, ApprovalAuditEvent, ApprovalDatabase, ApprovalNotificationSink } from '../approval-api/index.js';
|
|
2
|
+
import { type AuditProxyNamespaceLike, type AuditQueue, type InfrastructureAuditEnvelope } from '../audit-export/index.js';
|
|
3
|
+
import type { DeploymentIdentityDatabase, RunArtifactPurger, SnapshotDatabase } from '../do-runner/index.js';
|
|
4
4
|
import type { ResumeRunFn } from './approval-bridge.js';
|
|
5
5
|
import { type DoRunTopology, type RunnerNamespaceLike } from './do-run-topology.js';
|
|
6
|
+
import { type MaintenanceOutcome } from './host-approval-service.js';
|
|
6
7
|
import { type HubNamespaceLike } from './hub-topology.js';
|
|
8
|
+
import { type StateEgressBinding } from './state-egress.js';
|
|
7
9
|
import type { TokenVerifier } from './verifier.js';
|
|
8
10
|
import type { WorkflowMeta } from './workflow-meta.js';
|
|
9
11
|
/** The ExecutionContext subset the composer needs (structural, like the rest of host-kit). */
|
|
10
12
|
export interface FlowsafeWorkerContext {
|
|
11
13
|
waitUntil(promise: Promise<unknown>): void;
|
|
12
14
|
}
|
|
15
|
+
/** Fixed instance name used by every deployment maintenance namespace. */
|
|
16
|
+
export declare const MAINTENANCE_INSTANCE_NAME = "deployment-maintenance";
|
|
17
|
+
export interface MaintenanceStubLike {
|
|
18
|
+
fetch(url: string, init?: {
|
|
19
|
+
method?: string;
|
|
20
|
+
headers?: Record<string, string>;
|
|
21
|
+
}): Promise<Response>;
|
|
22
|
+
}
|
|
23
|
+
export interface MaintenanceNamespaceLike<Id = unknown> {
|
|
24
|
+
idFromName(name: string): Id;
|
|
25
|
+
get(id: Id): MaintenanceStubLike;
|
|
26
|
+
}
|
|
27
|
+
export interface MaintenanceHealth {
|
|
28
|
+
nextSweepAt: number;
|
|
29
|
+
nextPurgeAt: number;
|
|
30
|
+
nextTickAt?: number;
|
|
31
|
+
lastSweepAt?: number;
|
|
32
|
+
lastPurgeAt?: number;
|
|
33
|
+
lastTickAt?: number;
|
|
34
|
+
lastSweepAttemptAt?: number;
|
|
35
|
+
lastPurgeAttemptAt?: number;
|
|
36
|
+
lastTickAttemptAt?: number;
|
|
37
|
+
lastSweepError?: string;
|
|
38
|
+
lastPurgeError?: string;
|
|
39
|
+
lastTickError?: string;
|
|
40
|
+
}
|
|
41
|
+
export interface MaintenanceStorage {
|
|
42
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
43
|
+
getAlarm(): Promise<number | null>;
|
|
44
|
+
setAlarm(scheduledTime: number | Date): Promise<void>;
|
|
45
|
+
transaction<T>(closure: (transaction: MaintenanceStorageTransaction) => Promise<T>): Promise<T>;
|
|
46
|
+
}
|
|
47
|
+
export interface MaintenanceStorageTransaction {
|
|
48
|
+
get<T = unknown>(key: string): Promise<T | undefined>;
|
|
49
|
+
put<T>(key: string, value: T): Promise<void>;
|
|
50
|
+
setAlarm(scheduledTime: number | Date): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export interface MaintenanceDurableObjectState {
|
|
53
|
+
readonly id: {
|
|
54
|
+
readonly name?: string;
|
|
55
|
+
};
|
|
56
|
+
readonly storage: MaintenanceStorage;
|
|
57
|
+
}
|
|
13
58
|
/**
|
|
14
59
|
* The env bindings the composed Worker reads. A host's own Env extends this
|
|
15
60
|
* (its workers-typed D1Database/DurableObjectNamespace/Queue bindings satisfy
|
|
@@ -17,13 +62,37 @@ export interface FlowsafeWorkerContext {
|
|
|
17
62
|
*/
|
|
18
63
|
export interface FlowsafeWorkerEnv {
|
|
19
64
|
/** D1: the approval store AND the Mastra snapshot table live here. */
|
|
20
|
-
DB: ApprovalDatabase & SnapshotDatabase;
|
|
65
|
+
DB: ApprovalDatabase & SnapshotDatabase & DeploymentIdentityDatabase;
|
|
66
|
+
/** Provisioning-stamped deployment tag; must match the D1 sentinel. */
|
|
67
|
+
DEPLOYMENT_TENANT: string;
|
|
68
|
+
/** Optional fleet release identity returned only by authenticated maintenance routes. */
|
|
69
|
+
FLEET_SPEC_DIGEST?: string;
|
|
70
|
+
/** Fleet-controlled marker: maintenance routes relay one-shot capabilities. */
|
|
71
|
+
FLEET_MAINTENANCE_CAPABILITIES?: 'required';
|
|
72
|
+
/** Fleet Ed25519 public JWK used before external maintenance execution. */
|
|
73
|
+
FLEET_MAINTENANCE_CAPABILITY_PUBLIC_KEY?: string;
|
|
74
|
+
/** Fleet-controlled marker: audit export must use the trusted state proxy. */
|
|
75
|
+
FLEET_AUDIT_PROXY?: 'required';
|
|
76
|
+
/** Fleet-controlled marker: this private Worker terminates audit proxy calls. */
|
|
77
|
+
FLEET_AUDIT_PROXY_INGRESS?: 'required';
|
|
78
|
+
/** Fleet-controlled environment attribution for trusted state. */
|
|
79
|
+
FLEET_ENVIRONMENT?: string;
|
|
80
|
+
/** Fleet-controlled logical release-family name for trusted audit attribution. */
|
|
81
|
+
FLEET_DEPLOYMENT_SCRIPT?: string;
|
|
82
|
+
/** Fleet resource group stamped onto trusted state. */
|
|
83
|
+
FLEET_RESOURCE_GROUP?: string;
|
|
84
|
+
/** Distinguishes the trusted state runtime from an external candidate. */
|
|
85
|
+
FLEET_RESOURCE_ROLE?: 'platform-state';
|
|
86
|
+
/** Per-deployment Worker-to-Durable-Object credential. */
|
|
87
|
+
DEPLOYMENT_IDENTITY_SECRET: string;
|
|
21
88
|
/** The runner DO namespace createDoRunTopology drives. */
|
|
22
89
|
RUNNER: RunnerNamespaceLike;
|
|
90
|
+
/** Fixed-name singleton that owns deployment maintenance alarms. */
|
|
91
|
+
MAINTENANCE: MaintenanceNamespaceLike;
|
|
23
92
|
/**
|
|
24
|
-
* Optional
|
|
93
|
+
* Optional deployment hub Durable Object namespace for live streaming.
|
|
25
94
|
* Present together with STREAM_TICKET_SECRET => the composer mounts the stream
|
|
26
|
-
* stage and fans approval mutations out to the
|
|
95
|
+
* stage and fans approval mutations out to the deployment hub; either absent =>
|
|
27
96
|
* streaming stays unmounted and the client remains poll-only.
|
|
28
97
|
*/
|
|
29
98
|
HUB?: HubNamespaceLike;
|
|
@@ -38,13 +107,13 @@ export interface FlowsafeWorkerEnv {
|
|
|
38
107
|
* value falls back to OFF (fail closed).
|
|
39
108
|
*/
|
|
40
109
|
APPROVAL_ALLOW_SELF_DECISION?: string;
|
|
41
|
-
/**
|
|
110
|
+
/** Maintenance purges terminal run snapshots older than this (default 30 days). */
|
|
42
111
|
RUN_RETENTION_DAYS?: string;
|
|
43
|
-
/**
|
|
112
|
+
/** Maintenance purges DECIDED approval records older than this (default 30 days). */
|
|
44
113
|
APPROVAL_RETENTION_DAYS?: string;
|
|
45
114
|
/**
|
|
46
|
-
* Agent-memory thread TTL in days (
|
|
47
|
-
* the purge
|
|
115
|
+
* Agent-memory thread TTL in days (docs/agent-memory-isolation.md#thread-retention):
|
|
116
|
+
* the purge duty deletes threads untouched for longer than this, with their
|
|
48
117
|
* messages. UNSET, EMPTY, or INVALID => the duty does not run and no thread
|
|
49
118
|
* ever expires — the opt-in default, because a thread is a conversation a host
|
|
50
119
|
* means to keep, not a terminal run snapshot that is finished by definition.
|
|
@@ -56,7 +125,7 @@ export interface FlowsafeWorkerEnv {
|
|
|
56
125
|
*/
|
|
57
126
|
THREAD_RETENTION_DAYS?: string;
|
|
58
127
|
/**
|
|
59
|
-
* Agent-inbox TTL in days. The purge
|
|
128
|
+
* Agent-inbox TTL in days. The purge duty reaps terminal
|
|
60
129
|
* `mastra_notifications` rows past this age (pending rows are never reaped —
|
|
61
130
|
* one may await a future deliverAt). UNSET/EMPTY/INVALID => the duty does not
|
|
62
131
|
* run and no notification ever expires (opt-in, like THREAD_RETENTION_DAYS —
|
|
@@ -64,24 +133,37 @@ export interface FlowsafeWorkerEnv {
|
|
|
64
133
|
*/
|
|
65
134
|
NOTIFICATION_RETENTION_DAYS?: string;
|
|
66
135
|
/**
|
|
67
|
-
* Thread-state TTL in days. The purge
|
|
136
|
+
* Thread-state TTL in days. The purge duty reaps
|
|
68
137
|
* `mastra_thread_state` rows (state-signal lanes + goals) untouched for longer
|
|
69
138
|
* than this. UNSET/EMPTY/INVALID => the duty does not run (opt-in; an active
|
|
70
139
|
* goal bumps updatedAt so it never ages out).
|
|
71
140
|
*/
|
|
72
141
|
THREAD_STATE_RETENTION_DAYS?: string;
|
|
73
142
|
/**
|
|
74
|
-
* Schedule-trigger history TTL in days. The purge
|
|
143
|
+
* Schedule-trigger history TTL in days. The purge duty reaps
|
|
75
144
|
* `mastra_schedule_triggers` rows past this age by their `actualFireAt`.
|
|
76
145
|
* UNSET/EMPTY/INVALID => the duty does not run (opt-in; a schedule's fire
|
|
77
|
-
* history is inspectable until the host sets a window).
|
|
78
|
-
*
|
|
146
|
+
* history is inspectable until the host sets a window). Schedule rows are
|
|
147
|
+
* standing config with no TTL; an authorized DELETE removes them, and
|
|
148
|
+
* deployment decommissioning removes any that remain.
|
|
79
149
|
*/
|
|
80
150
|
SCHEDULE_TRIGGER_RETENTION_DAYS?: string;
|
|
81
|
-
/** Optional audit
|
|
82
|
-
AUDIT_QUEUE?: AuditQueue<ApprovalAuditEvent>;
|
|
83
|
-
|
|
84
|
-
|
|
151
|
+
/** Optional audit queue producer; delivery belongs to the control plane. */
|
|
152
|
+
AUDIT_QUEUE?: AuditQueue<ApprovalAuditEvent | InfrastructureAuditEnvelope>;
|
|
153
|
+
/** Remote trusted-state Durable Object namespace used by external releases. */
|
|
154
|
+
AUDIT_PROXY?: AuditProxyNamespaceLike;
|
|
155
|
+
/** Named StateEgress service binding, present only on trusted state. */
|
|
156
|
+
OUTBOUND_PROXY?: StateEgressBinding;
|
|
157
|
+
/** Dedicated trusted-state credential for the shared outbound entrypoint. */
|
|
158
|
+
OUTBOUND_PROXY_CREDENTIAL?: string;
|
|
159
|
+
OUTBOUND_TENANT_ID?: string;
|
|
160
|
+
OUTBOUND_ENVIRONMENT?: string;
|
|
161
|
+
OUTBOUND_RESOURCE_GROUP_ID?: string;
|
|
162
|
+
OUTBOUND_STATE_SCRIPT_NAME?: string;
|
|
163
|
+
OUTBOUND_ROUTE_HOSTNAME?: string;
|
|
164
|
+
OUTBOUND_POLICY_ID?: string;
|
|
165
|
+
/** Dedicated control-plane credential for maintenance administration. */
|
|
166
|
+
MAINTENANCE_ADMIN_SECRET?: string;
|
|
85
167
|
}
|
|
86
168
|
/**
|
|
87
169
|
* Background-task TTL cleanup config, surfaced through
|
|
@@ -100,51 +182,42 @@ export interface FlowsafeWorkerConfig<Env extends FlowsafeWorkerEnv> {
|
|
|
100
182
|
/** The catalog createRunRouter serves and gates (hosts pass their metas). */
|
|
101
183
|
workflows: ReadonlyArray<WorkflowMeta>;
|
|
102
184
|
/**
|
|
103
|
-
*
|
|
104
|
-
*
|
|
105
|
-
*
|
|
185
|
+
* System-principal id for bridge bookkeeping and alarm maintenance
|
|
186
|
+
* attribution. Requester kind is persisted separately, so ids may overlap
|
|
187
|
+
* across principal kinds.
|
|
106
188
|
*/
|
|
107
|
-
|
|
189
|
+
systemPrincipalId: string;
|
|
108
190
|
/**
|
|
109
|
-
* The identity seam: env -> TokenVerifier. Called once per fetch
|
|
110
|
-
*
|
|
191
|
+
* The identity seam: env -> TokenVerifier. Called once per fetch, so hosts
|
|
192
|
+
* keep their own per-isolate memoization —
|
|
111
193
|
* re-parsing a token map on every request is pure waste, but that is the
|
|
112
194
|
* host's trade to make.
|
|
113
195
|
*/
|
|
114
196
|
buildVerifier: (env: Env) => TokenVerifier;
|
|
115
197
|
/**
|
|
116
|
-
*
|
|
117
|
-
*
|
|
118
|
-
*
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
* schedule-tick invocation, byte-identical.
|
|
125
|
-
*/
|
|
126
|
-
crons: {
|
|
127
|
-
sweep: string;
|
|
128
|
-
purge: string;
|
|
129
|
-
tick?: string;
|
|
198
|
+
* Recurrence intervals for the singleton maintenance Durable Object. Every
|
|
199
|
+
* duty receives its own alarm invocation; `tickIntervalMs` is required when
|
|
200
|
+
* `scheduleTick` is configured and omitted otherwise.
|
|
201
|
+
*/
|
|
202
|
+
maintenance: {
|
|
203
|
+
sweepIntervalMs: number;
|
|
204
|
+
purgeIntervalMs: number;
|
|
205
|
+
tickIntervalMs?: number;
|
|
130
206
|
};
|
|
131
207
|
/**
|
|
132
208
|
* Deployment-specific routes tried AFTER /healthz and BEFORE the approval
|
|
133
|
-
* and run routers (the showcase mounts its demo sign-in
|
|
134
|
-
*
|
|
135
|
-
*
|
|
136
|
-
* through the same resolve). Return null to fall through.
|
|
209
|
+
* and run routers (the showcase mounts its demo sign-in here). `kit` hands
|
|
210
|
+
* over the request's already-built resolver and DO topology so a pre-route
|
|
211
|
+
* can share them. Return null to fall through.
|
|
137
212
|
*/
|
|
138
213
|
preRoutes?: (request: Request, env: Env, ctx: FlowsafeWorkerContext, kit: {
|
|
139
|
-
resolve:
|
|
214
|
+
resolve: ActorResolver;
|
|
140
215
|
topology: DoRunTopology;
|
|
141
216
|
}) => Promise<Response | null>;
|
|
142
|
-
/**
|
|
143
|
-
|
|
144
|
-
/**
|
|
145
|
-
|
|
146
|
-
/** Wrap the raw-resume thunk (metered like starts on budgeted hosts). */
|
|
147
|
-
wrapResume?: (resume: DoRunTopology['resume'], env: Env) => DoRunTopology['resume'];
|
|
217
|
+
/** Host policy immediately before a validated start reaches the run DO. */
|
|
218
|
+
beforeStart?: (context: ActorContext, env: Env, workflowId: string, inputData: unknown) => Promise<void>;
|
|
219
|
+
/** Host policy immediately before a validated raw resume reaches the run DO. */
|
|
220
|
+
beforeResume?: (context: ActorContext, env: Env, workflowId: string, runId: string, body: unknown) => Promise<void>;
|
|
148
221
|
/**
|
|
149
222
|
* Compose approval-driven resume handling. Agent hosts use this to handle
|
|
150
223
|
* agent-thread targets and delegate generic workflow targets to fallback.
|
|
@@ -157,19 +230,22 @@ export interface FlowsafeWorkerConfig<Env extends FlowsafeWorkerEnv> {
|
|
|
157
230
|
*/
|
|
158
231
|
notify?: (env: Env) => ApprovalNotificationSink | undefined;
|
|
159
232
|
/**
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
* snapshot row. The snapshot row is the only enumerable record of a run's
|
|
163
|
-
* artifact keys
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
|
|
168
|
-
|
|
233
|
+
* Builds the artifact purger from the current invocation's environment.
|
|
234
|
+
* When set, the retention purge deletes each expired run's R2 artifacts WITH
|
|
235
|
+
* its snapshot row. The snapshot row is the only enumerable record of a run's
|
|
236
|
+
* artifact keys, so a retention purge without this pairing strands artifacts
|
|
237
|
+
* until deployment teardown. Return the same R2-backed store used for runtime
|
|
238
|
+
* writes, or undefined for row-only purge. NOT via extraPurgeDuties: that hook
|
|
239
|
+
* runs after the rows are deleted, when the keys are already unenumerable.
|
|
240
|
+
*/
|
|
241
|
+
artifactStore?: (env: Env) => RunArtifactPurger | undefined;
|
|
242
|
+
/**
|
|
243
|
+
* Prefix for every prefix-aware built-in retention table. Must match the
|
|
244
|
+
* max-39 `tablePrefix` contract used when the deployment creates D1 storage.
|
|
169
245
|
*/
|
|
170
|
-
|
|
246
|
+
storageTablePrefix?: string;
|
|
171
247
|
/**
|
|
172
|
-
* Opt-in background-task TTL cleanup. When present, the purge
|
|
248
|
+
* Opt-in background-task TTL cleanup. When present, the purge duty
|
|
173
249
|
* reaps terminal `mastra_background_tasks` rows past the TTL as its OWN
|
|
174
250
|
* failure-isolated duty — the storage-layer belt to a hosting DO's manager
|
|
175
251
|
* cleanup (which needs the DO alive). Absent => no duty, byte-identical
|
|
@@ -181,68 +257,71 @@ export interface FlowsafeWorkerConfig<Env extends FlowsafeWorkerEnv> {
|
|
|
181
257
|
* Opt-in authenticated agent catalog/run router. Structurally typed so this
|
|
182
258
|
* module does not import the server-only agent-host subpath.
|
|
183
259
|
*/
|
|
184
|
-
buildAgentRouter?: (resolve:
|
|
260
|
+
buildAgentRouter?: (resolve: ActorResolver, env: Env) => AgentRouter | undefined;
|
|
185
261
|
/**
|
|
186
262
|
* Opt-in signal-ingestion stage. The host builds its
|
|
187
263
|
* `createSignalRouter` (which needs its per-thread DO namespace via
|
|
188
264
|
* createThreadTopology, plus its audit/rate/allowlist config) and returns it
|
|
189
|
-
* here, closed over the request's
|
|
265
|
+
* here, closed over the request's ActorResolver; the composer mounts
|
|
190
266
|
* it after preRoutes, ahead of approvals/runs (its `/api/threads/*` routes
|
|
191
267
|
* don't overlap). INJECTED rather than built here because createSignalRouter
|
|
192
268
|
* lives in `signals/`, which imports host-kit — host-kit importing it back
|
|
193
269
|
* would cycle. Absent (or returns undefined) => no signal stage, byte-identical.
|
|
194
270
|
*/
|
|
195
|
-
buildSignalRouter?: (resolve:
|
|
271
|
+
buildSignalRouter?: (resolve: ActorResolver, env: Env) => ((request: Request) => Promise<Response | null>) | undefined;
|
|
196
272
|
/**
|
|
197
273
|
* Opt-in goal-objective stage. Mirrors
|
|
198
274
|
* buildSignalRouter: the host builds its `createObjectiveRouter` (which needs
|
|
199
275
|
* the thread-state store from its D1 domains, plus its audit/maxRuns config)
|
|
200
|
-
* and returns it here, closed over the request's
|
|
276
|
+
* and returns it here, closed over the request's ActorResolver; the
|
|
201
277
|
* composer mounts it after the signal stage. Both live under `/api/threads/*`
|
|
202
278
|
* but do not overlap — goals use the `/goal` segment, signals the channel
|
|
203
279
|
* segments. INJECTED rather than built here because createObjectiveRouter lives
|
|
204
280
|
* in `goals/`, which imports host-kit — host-kit importing it back would cycle.
|
|
205
281
|
* Absent (or returns undefined) ⇒ no goal stage, byte-identical.
|
|
206
282
|
*/
|
|
207
|
-
buildObjectiveRouter?: (resolve:
|
|
283
|
+
buildObjectiveRouter?: (resolve: ActorResolver, env: Env) => ((request: Request) => Promise<Response | null>) | undefined;
|
|
208
284
|
/**
|
|
209
285
|
* Opt-in schedule CRUD facade. Mirrors buildSignalRouter/
|
|
210
286
|
* buildObjectiveRouter: the host builds its `createScheduleRouter` (which needs
|
|
211
287
|
* the schedules store from its D1 domains + its audit/cap config) and returns it
|
|
212
|
-
* here, closed over the request's
|
|
288
|
+
* here, closed over the request's ActorResolver; the composer mounts it
|
|
213
289
|
* after the goal stage. Its `/api/schedules/*` routes don't overlap the others.
|
|
214
290
|
* INJECTED (not built here, typed structurally) because createScheduleRouter
|
|
215
291
|
* lives in `schedules/`, which transitively imports host-kit — importing it back
|
|
216
292
|
* would cycle. Absent (or returns undefined) ⇒ no schedule surface, byte-identical.
|
|
217
293
|
*/
|
|
218
|
-
buildScheduleRouter?: (resolve:
|
|
294
|
+
buildScheduleRouter?: (resolve: ActorResolver, env: Env) => ((request: Request) => Promise<Response | null>) | undefined;
|
|
219
295
|
/**
|
|
220
296
|
* Opt-in schedule tick. The host builds its `createScheduleTick`
|
|
221
297
|
* (which needs the schedules store, its run-start seam — topology.start — and
|
|
222
298
|
* the run-cap + audit config) and returns the closure here. The composer runs
|
|
223
|
-
* it
|
|
299
|
+
* it as its OWN failure-isolated alarm duty (own try/catch,
|
|
224
300
|
* own `schedule-tick` log line). INJECTED (not built here, structurally typed as
|
|
225
301
|
* `() => Promise<unknown>`) because createScheduleTick lives in `schedules/`,
|
|
226
302
|
* which transitively imports host-kit — host-kit importing it back would cycle.
|
|
227
|
-
* Absent (or `
|
|
303
|
+
* Absent (or `tickIntervalMs` unset) ⇒ no tick invocation.
|
|
228
304
|
*/
|
|
229
305
|
scheduleTick?: (env: Env) => (() => Promise<unknown>) | undefined;
|
|
230
306
|
/**
|
|
231
|
-
* Extra purge
|
|
307
|
+
* Extra purge duties. The
|
|
232
308
|
* returned fields fold into the ONE combined `{type:'maintenance'}` log
|
|
233
|
-
* line.
|
|
234
|
-
*
|
|
235
|
-
* error surface stays specific.
|
|
309
|
+
* line. A throw reports the purge attempt as failed while the worker still
|
|
310
|
+
* contains it, logs a maintenance-error, and emits the combined log.
|
|
236
311
|
*/
|
|
237
|
-
extraPurgeDuties?: (env: Env
|
|
312
|
+
extraPurgeDuties?: (env: Env) => Promise<Record<string, unknown>>;
|
|
238
313
|
}
|
|
239
|
-
|
|
314
|
+
export type MaintenanceDuty = 'sweep' | 'purge' | 'tick';
|
|
315
|
+
/** The Worker handler plus the maintenance duty seam consumed by its DO. */
|
|
240
316
|
export interface FlowsafeWorker<Env extends FlowsafeWorkerEnv> {
|
|
241
317
|
fetch(request: Request, env: Env, ctx: FlowsafeWorkerContext): Promise<Response>;
|
|
242
|
-
|
|
243
|
-
cron: string;
|
|
244
|
-
}, env: Env, ctx: FlowsafeWorkerContext): Promise<void>;
|
|
245
|
-
queue(batch: AuditMessageBatch<unknown>, env: Env): Promise<void>;
|
|
318
|
+
runMaintenanceDuty(duty: MaintenanceDuty, env: Env): Promise<MaintenanceOutcome>;
|
|
246
319
|
}
|
|
247
320
|
export declare function createFlowsafeWorker<Env extends FlowsafeWorkerEnv>(config: FlowsafeWorkerConfig<Env>): FlowsafeWorker<Env>;
|
|
321
|
+
export type MaintenanceDurableObjectConstructor<Env extends FlowsafeWorkerEnv> = new (state: MaintenanceDurableObjectState, env: Env) => {
|
|
322
|
+
fetch(request: Request): Promise<Response>;
|
|
323
|
+
alarm(): Promise<void>;
|
|
324
|
+
};
|
|
325
|
+
/** Build the fixed-name maintenance Durable Object class for one host. */
|
|
326
|
+
export declare function createFlowsafeMaintenanceDurableObject<Env extends FlowsafeWorkerEnv>(config: FlowsafeWorkerConfig<Env>): MaintenanceDurableObjectConstructor<Env>;
|
|
248
327
|
//# sourceMappingURL=flowsafe-worker.d.ts.map
|