@proofoftech/flowsafe 0.11.0 → 0.12.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 +36 -0
- package/README.md +65 -43
- 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 +44 -182
- package/dist/do-runner/d1-storage.d.ts.map +1 -1
- package/dist/do-runner/d1-storage.js +102 -353
- 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/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 +149 -73
- package/dist/host-kit/flowsafe-worker.d.ts.map +1 -1
- package/dist/host-kit/flowsafe-worker.js +619 -141
- 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
|
@@ -1,30 +1,34 @@
|
|
|
1
1
|
import type { HubDurableObjectState, WebSocketLike } from './cf-types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The ONE name the trusted Worker addresses the deployment hub by
|
|
4
|
+
* (`createHubTopology`). A fixed name rather than a per-request value: the hub
|
|
5
|
+
* asserts its own `id.name` equals it, so an instance reached around the
|
|
6
|
+
* exported topology (a hand-rolled idFromName with some other name) refuses to
|
|
7
|
+
* serve instead of fanning events out from an unsanctioned identity.
|
|
8
|
+
*/
|
|
9
|
+
export declare const HUB_INSTANCE_NAME = "deployment-hub";
|
|
2
10
|
/**
|
|
3
11
|
* Minimal STRUCTURAL shape of the approval stream event this hub fans out.
|
|
4
12
|
*
|
|
5
|
-
* ACYCLIC LAYERING: approval-api already imports FROM do-runner
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* bridged onto the hub's POST body by host-kit through `createHubTopology`,
|
|
12
|
-
* which may import both packages.
|
|
13
|
+
* ACYCLIC LAYERING: approval-api already imports FROM do-runner, so do-runner
|
|
14
|
+
* must NOT import ApprovalStreamEvent back from approval-api — that would be a
|
|
15
|
+
* dependency cycle. The hub only re-serializes the whole event to subscribers,
|
|
16
|
+
* so this local subset is sufficient. The real ApprovalStreamEvent
|
|
17
|
+
* (approval-api/contract.ts) is bridged onto the hub's POST body by host-kit
|
|
18
|
+
* through `createHubTopology`, which may import both packages.
|
|
13
19
|
*/
|
|
14
20
|
export interface HubStreamEvent {
|
|
15
|
-
record:
|
|
16
|
-
tenantId: string;
|
|
17
|
-
};
|
|
21
|
+
record: Record<string, unknown>;
|
|
18
22
|
type?: string;
|
|
19
23
|
[key: string]: unknown;
|
|
20
24
|
}
|
|
21
|
-
/** A reviewer currently subscribed to
|
|
25
|
+
/** A reviewer currently subscribed to the hub, held in socket attachment. */
|
|
22
26
|
export interface PresenceMember {
|
|
23
27
|
actorId: string;
|
|
24
28
|
role: string;
|
|
25
29
|
}
|
|
26
30
|
/**
|
|
27
|
-
*
|
|
31
|
+
* Deployment hub Durable Object base. Hosts subclass it (ShowcaseHub /
|
|
28
32
|
* FlowsafeHub / DemoHub) and bind it under the wrangler HUB namespace; the
|
|
29
33
|
* subclass body is typically empty. Left `abstract` to signal "extend, do not
|
|
30
34
|
* instantiate directly".
|
|
@@ -35,18 +39,6 @@ export declare abstract class HubDurableObject<TEnv = unknown> {
|
|
|
35
39
|
/** Absent in node tests; present under workerd (Hibernatable-WebSocket API). */
|
|
36
40
|
protected readonly state?: HubDurableObjectState;
|
|
37
41
|
constructor(state: HubDurableObjectState | undefined, env: TEnv);
|
|
38
|
-
/**
|
|
39
|
-
* The tenant this hub serves, recovered from the DO's OWN identity. The
|
|
40
|
-
* trusted Worker addressed this instance via idFromName(tenantId), so
|
|
41
|
-
* `id.name` IS the bare tenantId (no ':' join, no runId decode). `id.name`
|
|
42
|
-
* is populated only for idFromName-created ids and is unforgeable at this
|
|
43
|
-
* boundary.
|
|
44
|
-
*
|
|
45
|
-
* THROWS rather than defaulting — a hub that cannot resolve its tenant must
|
|
46
|
-
* refuse to fan out, never fan one tenant's event to another's sockets.
|
|
47
|
-
* Mirrors DurableObjectRunner.tenantId's fail-closed posture.
|
|
48
|
-
*/
|
|
49
|
-
protected get tenantId(): string;
|
|
50
42
|
fetch(request: Request): Promise<Response>;
|
|
51
43
|
webSocketMessage(_ws: WebSocketLike, _message: string | ArrayBuffer): void;
|
|
52
44
|
webSocketClose(ws: WebSocketLike, _code: number, _reason: string): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-do.d.ts","sourceRoot":"","sources":["../../src/do-runner/hub-do.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"hub-do.d.ts","sourceRoot":"","sources":["../../src/do-runner/hub-do.ts"],"names":[],"mappings":"AAmBA,OAAO,KAAK,EAAE,qBAAqB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAK1E;;;;;;GAMG;AACH,eAAO,MAAM,iBAAiB,mBAAmB,CAAC;AAElD;;;;;;;;;GASG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAChC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED,6EAA6E;AAC7E,MAAM,WAAW,cAAc;IAC7B,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;;;GAKG;AACH,8BAAsB,gBAAgB,CAAC,IAAI,GAAG,OAAO;;IACnD,SAAS,CAAC,QAAQ,CAAC,GAAG,EAAE,IAAI,CAAC;IAC7B,gFAAgF;IAChF,SAAS,CAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,qBAAqB,CAAC;gBAErC,KAAK,EAAE,qBAAqB,GAAG,SAAS,EAAE,GAAG,EAAE,IAAI;IAKzD,KAAK,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAoIhD,gBAAgB,CAAC,GAAG,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,WAAW,GAAG,IAAI;IAK1E,cAAc,CAAC,EAAE,EAAE,aAAa,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI;IAKvE,cAAc,CAAC,EAAE,EAAE,aAAa,EAAE,MAAM,EAAE,OAAO,GAAG,IAAI;CAIzD"}
|
package/dist/do-runner/hub-do.js
CHANGED
|
@@ -1,25 +1,34 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
//
|
|
3
|
-
// stream events (queue inserts, claims, decisions, escalations) and
|
|
4
|
-
// presence. Run PROGRESS never flows through here (that rides the
|
|
5
|
-
// the runner DO, DL-009); the hub owns the
|
|
6
|
-
// per-run home.
|
|
2
|
+
// Deployment hub Durable Object — the fan-out channel for deployment-wide
|
|
3
|
+
// approval stream events (queue inserts, claims, decisions, escalations) and
|
|
4
|
+
// reviewer presence. Run PROGRESS never flows through here (that rides the
|
|
5
|
+
// per-run WS on the runner DO, DL-009); the hub owns the deployment-wide feed
|
|
6
|
+
// with no natural per-run home.
|
|
7
7
|
//
|
|
8
|
-
// Addressed idFromName(
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// contract — deliberately NOT `extends
|
|
12
|
-
// — so this module and its graph load
|
|
13
|
-
// WebSocket path (acceptWebSocket + the
|
|
14
|
-
//
|
|
15
|
-
// workerd spike (M-009)
|
|
16
|
-
// it is an ephemeral fan-out over the
|
|
17
|
-
// NO ticket verification (the Worker
|
|
18
|
-
//
|
|
19
|
-
// construction).
|
|
8
|
+
// Addressed idFromName(HUB_INSTANCE_NAME) by the trusted Worker — ONE hub per
|
|
9
|
+
// deployment, the singleton the physical-isolation topology implies (one
|
|
10
|
+
// deployment = one organization = one reviewer feed). Classic
|
|
11
|
+
// constructor(state,env)+fetch contract — deliberately NOT `extends
|
|
12
|
+
// DurableObject` from 'cloudflare:workers' — so this module and its graph load
|
|
13
|
+
// in node/vitest; the Hibernatable-WebSocket path (acceptWebSocket + the
|
|
14
|
+
// webSocket* handler methods) only runs under workerd, guarded by
|
|
15
|
+
// acceptWebSocket presence, and is proven by the workerd spike (M-009). The
|
|
16
|
+
// hub holds NO durable D1/DO state: it is an ephemeral fan-out over the
|
|
17
|
+
// sockets currently attached, and performs NO ticket verification (the Worker
|
|
18
|
+
// is the sole ticket authority).
|
|
20
19
|
import { newWebSocketPair, safeSend } from './cf-types.js';
|
|
20
|
+
import { verifyDurableObjectDeploymentRequest } from './deployment-identity.js';
|
|
21
|
+
import { doErrorResponse } from './do-error-response.js';
|
|
21
22
|
/**
|
|
22
|
-
*
|
|
23
|
+
* The ONE name the trusted Worker addresses the deployment hub by
|
|
24
|
+
* (`createHubTopology`). A fixed name rather than a per-request value: the hub
|
|
25
|
+
* asserts its own `id.name` equals it, so an instance reached around the
|
|
26
|
+
* exported topology (a hand-rolled idFromName with some other name) refuses to
|
|
27
|
+
* serve instead of fanning events out from an unsanctioned identity.
|
|
28
|
+
*/
|
|
29
|
+
export const HUB_INSTANCE_NAME = 'deployment-hub';
|
|
30
|
+
/**
|
|
31
|
+
* Deployment hub Durable Object base. Hosts subclass it (ShowcaseHub /
|
|
23
32
|
* FlowsafeHub / DemoHub) and bind it under the wrangler HUB namespace; the
|
|
24
33
|
* subclass body is typically empty. Left `abstract` to signal "extend, do not
|
|
25
34
|
* instantiate directly".
|
|
@@ -32,54 +41,49 @@ export class HubDurableObject {
|
|
|
32
41
|
this.state = state;
|
|
33
42
|
this.env = env;
|
|
34
43
|
}
|
|
35
|
-
/**
|
|
36
|
-
* The tenant this hub serves, recovered from the DO's OWN identity. The
|
|
37
|
-
* trusted Worker addressed this instance via idFromName(tenantId), so
|
|
38
|
-
* `id.name` IS the bare tenantId (no ':' join, no runId decode). `id.name`
|
|
39
|
-
* is populated only for idFromName-created ids and is unforgeable at this
|
|
40
|
-
* boundary.
|
|
41
|
-
*
|
|
42
|
-
* THROWS rather than defaulting — a hub that cannot resolve its tenant must
|
|
43
|
-
* refuse to fan out, never fan one tenant's event to another's sockets.
|
|
44
|
-
* Mirrors DurableObjectRunner.tenantId's fail-closed posture.
|
|
45
|
-
*/
|
|
46
|
-
get tenantId() {
|
|
47
|
-
const name = this.state?.id?.name;
|
|
48
|
-
if (!name) {
|
|
49
|
-
throw new Error('HubDurableObject.tenantId: the DO has no id.name (not created via idFromName, or running without state) — tenant unresolvable, refusing to fan out');
|
|
50
|
-
}
|
|
51
|
-
return name;
|
|
52
|
-
}
|
|
53
44
|
async fetch(request) {
|
|
54
45
|
try {
|
|
46
|
+
// Deployment-identity check before any fan-out: a hub namespace bound to
|
|
47
|
+
// the wrong deployment refuses rather than leaks its feed. No-op off
|
|
48
|
+
// workerd (state undefined), memoized after first success.
|
|
49
|
+
await verifyDurableObjectDeploymentRequest(request, this.state, this.env);
|
|
55
50
|
return await this.#route(request);
|
|
56
51
|
}
|
|
57
52
|
catch (error) {
|
|
58
|
-
|
|
53
|
+
// doErrorResponse keeps the taxonomy consistent with the other DO bases:
|
|
54
|
+
// a DeploymentIdentityError answers 503, everything unrecognized a 500.
|
|
55
|
+
return doErrorResponse(error);
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Assert this instance IS the deployment hub — its own idFromName identity
|
|
60
|
+
* equals HUB_INSTANCE_NAME. The trusted Worker only ever addresses that
|
|
61
|
+
* name (`createHubTopology`), so anything else was reached around the
|
|
62
|
+
* exported topology. Refuse loudly rather than fan out from an unsanctioned
|
|
63
|
+
* identity. `id.name` is populated only for idFromName-created ids and is
|
|
64
|
+
* unforgeable at this boundary.
|
|
65
|
+
*/
|
|
66
|
+
#assertHubIdentity() {
|
|
67
|
+
const name = this.state?.id?.name;
|
|
68
|
+
if (this.state === undefined)
|
|
69
|
+
return;
|
|
70
|
+
if (name !== HUB_INSTANCE_NAME) {
|
|
71
|
+
throw new Error(`HubDurableObject: instance name '${name}' is not the deployment hub '${HUB_INSTANCE_NAME}' — refusing to serve (address the hub through createHubTopology)`);
|
|
59
72
|
}
|
|
60
73
|
}
|
|
61
74
|
async #route(request) {
|
|
62
75
|
const segments = new URL(request.url).pathname.split('/').filter(Boolean);
|
|
63
76
|
// (1) POST /internal/event — the trusted host forwards each approval stream
|
|
64
|
-
// event here (createHubTopology, M-006). Fan it out to
|
|
77
|
+
// event here (createHubTopology, M-006). Fan it out to the deployment's
|
|
65
78
|
// subscribed sockets.
|
|
66
79
|
if (request.method === 'POST' &&
|
|
67
80
|
segments.length === 2 &&
|
|
68
81
|
segments[0] === 'internal' &&
|
|
69
82
|
segments[1] === 'event') {
|
|
83
|
+
this.#assertHubIdentity();
|
|
70
84
|
const event = await readJson(request);
|
|
71
|
-
if (!event || typeof event.record
|
|
72
|
-
return json({ error: 'a stream event with record
|
|
73
|
-
}
|
|
74
|
-
// Defense in depth: the Worker already routes by record.tenantId to
|
|
75
|
-
// idFromName(tenantId), so id.name === the event tenant by construction.
|
|
76
|
-
// Refuse a mismatch loudly rather than fan one tenant's event to
|
|
77
|
-
// another's sockets.
|
|
78
|
-
const tenantId = this.tenantId;
|
|
79
|
-
if (event.record.tenantId !== tenantId) {
|
|
80
|
-
return json({
|
|
81
|
-
error: `event tenant '${event.record.tenantId}' does not match this hub '${tenantId}'`,
|
|
82
|
-
}, 400);
|
|
85
|
+
if (!event || typeof event.record !== 'object' || event.record === null) {
|
|
86
|
+
return json({ error: 'a stream event with a record is required' }, 400);
|
|
83
87
|
}
|
|
84
88
|
const frame = JSON.stringify({ type: 'queue', event });
|
|
85
89
|
for (const ws of this.#sockets()) {
|
|
@@ -88,10 +92,10 @@ export class HubDurableObject {
|
|
|
88
92
|
return json({ ok: true });
|
|
89
93
|
}
|
|
90
94
|
// (2) GET /subscribe (Upgrade: websocket) — a reviewer dashboard subscribes
|
|
91
|
-
// to
|
|
92
|
-
// in its attachment, and broadcast the refreshed roster. The
|
|
93
|
-
// the ticket's actorId/role as query params (it is the sole
|
|
94
|
-
// authority; the hub trusts its routing and identity, M-006).
|
|
95
|
+
// to the deployment's live feed. Accept a hibernatable socket, record
|
|
96
|
+
// presence in its attachment, and broadcast the refreshed roster. The
|
|
97
|
+
// Worker passes the ticket's actorId/role as query params (it is the sole
|
|
98
|
+
// ticket authority; the hub trusts its routing and identity, M-006).
|
|
95
99
|
if (request.method === 'GET' &&
|
|
96
100
|
segments.length === 1 &&
|
|
97
101
|
segments[0] === 'subscribe') {
|
|
@@ -105,15 +109,15 @@ export class HubDurableObject {
|
|
|
105
109
|
error: 'websocket upgrade required to subscribe (workerd-only; poll the approval queue route as the fallback)',
|
|
106
110
|
}, 426);
|
|
107
111
|
}
|
|
108
|
-
// Bind this instance to its
|
|
109
|
-
//
|
|
110
|
-
// fan-out address sockets by
|
|
111
|
-
|
|
112
|
+
// Bind this instance to its singleton identity before accepting (fail
|
|
113
|
+
// closed on an unsanctioned instance); the role tag lets a future
|
|
114
|
+
// targeted fan-out address sockets by role.
|
|
115
|
+
this.#assertHubIdentity();
|
|
112
116
|
const url = new URL(request.url);
|
|
113
117
|
const actorId = url.searchParams.get('actorId') ?? 'anonymous';
|
|
114
118
|
const role = url.searchParams.get('role') ?? 'unknown';
|
|
115
119
|
const { 0: client, 1: server } = newWebSocketPair();
|
|
116
|
-
state.acceptWebSocket(server, [
|
|
120
|
+
state.acceptWebSocket(server, [HUB_INSTANCE_NAME, role]);
|
|
117
121
|
server.serializeAttachment?.({ actorId, role });
|
|
118
122
|
this.#broadcastPresence();
|
|
119
123
|
return new Response(null, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-do.js","sourceRoot":"","sources":["../../src/do-runner/hub-do.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC
|
|
1
|
+
{"version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3E,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;IAED,cAAc,CAAC,EAAiB,EAAE,MAAe;QAC/C,+DAA+D;QAC/D,IAAI,CAAC,kBAAkB,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC;CACF;AAED,SAAS,gBAAgB,CAAC,KAAc;IACtC,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,KAAK,IAAI;QACd,OAAQ,KAA+B,CAAC,OAAO,KAAK,QAAQ;QAC5D,OAAQ,KAA4B,CAAC,IAAI,KAAK,QAAQ,CACvD,CAAC;AACJ,CAAC;AAED,2EAA2E;AAC3E,SAAS,cAAc,CAAC,EAAiB;IACvC,IAAI,CAAC;QACH,OAAO,EAAE,CAAC,qBAAqB,EAAE,EAAE,CAAC;IACtC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;AACH,CAAC;AAED,KAAK,UAAU,QAAQ,CAAI,OAAgB;IACzC,IAAI,CAAC;QACH,OAAO,CAAC,MAAM,OAAO,CAAC,IAAI,EAAE,CAAM,CAAC;IACrC,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,IAAI,CAAC;IACd,CAAC;AACH,CAAC;AAED,SAAS,IAAI,CAAC,OAAgB,EAAE,MAAM,GAAG,GAAG;IAC1C,OAAO,IAAI,QAAQ,CAAC,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,EAAE;QAC3C,MAAM;QACN,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;KAChD,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,22 +1,24 @@
|
|
|
1
|
-
export type { D1DatabaseBinding, DurableObjectRunnerState, HubDurableObjectState, WebSocketLike, } from './cf-types.js';
|
|
2
|
-
export type { D1StorageOptions, PurgeExpiredBackgroundTasksOptions, PurgeExpiredBackgroundTasksResult, PurgeExpiredNotificationsOptions, PurgeExpiredRunsOptions, PurgeExpiredScheduleTriggersOptions, PurgeExpiredThreadStateOptions, PurgeExpiredThreadsOptions, PurgeExpiredThreadsResult,
|
|
3
|
-
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes,
|
|
1
|
+
export type { D1DatabaseBinding, DurableKeyValueStorage, DurableObjectRunnerState, HubDurableObjectState, WebSocketLike, } from './cf-types.js';
|
|
2
|
+
export type { D1StorageOptions, PurgeExpiredBackgroundTasksOptions, PurgeExpiredBackgroundTasksResult, PurgeExpiredNotificationsOptions, PurgeExpiredRunsOptions, PurgeExpiredScheduleTriggersOptions, PurgeExpiredThreadStateOptions, PurgeExpiredThreadsOptions, PurgeExpiredThreadsResult, RunArtifactPurger, SnapshotDatabase, SnapshotStatement, } from './d1-storage.js';
|
|
3
|
+
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes, NOTIFICATION_TTL_PURGE_TABLES, purgeExpiredBackgroundTasks, purgeExpiredNotifications, purgeExpiredScheduleTriggers, purgeExpiredThreadState, purgeExpiredThreads, purgeExpiredWorkflowRuns, RUN_TTL_PURGE_TABLES, SCHEDULE_TRIGGER_TTL_PURGE_TABLES, THREAD_STATE_TTL_PURGE_TABLES, THREAD_TTL_PURGE_TABLES, } from './d1-storage.js';
|
|
4
|
+
export type { DeploymentIdentityDatabase, DeploymentIdentityEnv, DeploymentIdentityStatement, } from './deployment-identity.js';
|
|
5
|
+
export { assertDeploymentIdentity, assertDeploymentIdentitySecret, DEPLOYMENT_IDENTITY_HEADER, DEPLOYMENT_TAG_PATTERN, DeploymentIdentityError, deploymentIdentityHeaders, ensureDeploymentIdentity, ensureDeploymentIdentityBindings, readDeploymentIdentity, seedDeploymentIdentity, stampDeploymentIdentityRequest, verifyDurableObjectDeploymentIdentity, verifyDurableObjectDeploymentRequest, } from './deployment-identity.js';
|
|
4
6
|
export { DoStatusError, doErrorResponse } from './do-error-response.js';
|
|
5
|
-
export { DurableObjectRunner } from './durable-object.js';
|
|
7
|
+
export { DurableObjectRunner, type DurableObjectRunOwner, type DurableObjectRunOwnershipStore, } from './durable-object.js';
|
|
6
8
|
export { assertNoReservedExecutionContext, findReservedExecutionContextKey, isReservedExecutionContextKey, RESERVED_EXECUTION_CONTEXT_KEYS, ReservedExecutionContextError, stripReservedExecutionContext, } from './execution-context.js';
|
|
9
|
+
export { EXECUTION_PRINCIPAL_HEADER } from './execution-principal-header.js';
|
|
7
10
|
export type { HubStreamEvent, PresenceMember } from './hub-do.js';
|
|
8
|
-
export { HubDurableObject } from './hub-do.js';
|
|
11
|
+
export { HUB_INSTANCE_NAME, HubDurableObject } from './hub-do.js';
|
|
9
12
|
export type { DORunnerEnv, InitOptions, InitResult, InitSource, } from './init.js';
|
|
10
13
|
export { init } from './init.js';
|
|
11
|
-
export {
|
|
12
|
-
export {
|
|
14
|
+
export { mintThreadId, resourceIdFromKey } from './memory-id.js';
|
|
15
|
+
export { isPathSafeId, PATH_SAFE_ID_PATTERN } from './path-safe-id.js';
|
|
13
16
|
export type { HostPubSub } from './pubsub.js';
|
|
14
17
|
export { createHostPubSub } from './pubsub.js';
|
|
15
|
-
export type { ResumeLedger, ResumeLedgerStorage } from './resume-ledger.js';
|
|
16
|
-
export { DurableStorageResumeLedger, InMemoryResumeLedger, } from './resume-ledger.js';
|
|
17
18
|
export type { RequestContextProvider, ResumeRunOptions, RunLeg, RunnerRuntimeOptions, RunSummary, StartRunOptions, } from './runtime.js';
|
|
18
19
|
export { InvalidRunRequestError, RunAlreadyExistsError, RunNotSuspendedError, RunnerRuntime, UnknownRunError, UnknownWorkflowError, } from './runtime.js';
|
|
20
|
+
export type { ResolvedScheduleStart, ScheduleSourceAgentTarget, ScheduleSourceOwner, ScheduleSourceOwnershipStore, ScheduleSourceStore, ScheduleSourceTarget, ScheduleSourceWorkflowTarget, ScheduleStartTarget, } from './schedule-source.js';
|
|
21
|
+
export { resolveScheduleStartOwner } from './schedule-source.js';
|
|
19
22
|
export type { ThreadScope } from './thread-do.js';
|
|
20
23
|
export { ThreadDurableObject, ThreadIdentityError } from './thread-do.js';
|
|
21
|
-
export { THREAD_PRINCIPAL_HEADER, THREAD_TENANT_HEADER, } from './thread-header.js';
|
|
22
24
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/do-runner/index.ts"],"names":[],"mappings":"AAMA,YAAY,EACV,iBAAiB,EACjB,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,gBAAgB,EAChB,kCAAkC,EAClC,iCAAiC,EACjC,gCAAgC,EAChC,uBAAuB,EACvB,mCAAmC,EACnC,8BAA8B,EAC9B,0BAA0B,EAC1B,yBAAyB,EACzB,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/do-runner/index.ts"],"names":[],"mappings":"AAMA,YAAY,EACV,iBAAiB,EACjB,sBAAsB,EACtB,wBAAwB,EACxB,qBAAqB,EACrB,aAAa,GACd,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,gBAAgB,EAChB,kCAAkC,EAClC,iCAAiC,EACjC,gCAAgC,EAChC,uBAAuB,EACvB,mCAAmC,EACnC,8BAA8B,EAC9B,0BAA0B,EAC1B,yBAAyB,EACzB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,GAClB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,gCAAgC,EAChC,eAAe,EACf,SAAS,EACT,6BAA6B,EAC7B,2BAA2B,EAC3B,yBAAyB,EACzB,4BAA4B,EAC5B,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,oBAAoB,EACpB,iCAAiC,EACjC,6BAA6B,EAC7B,uBAAuB,GACxB,MAAM,iBAAiB,CAAC;AAGzB,YAAY,EACV,0BAA0B,EAC1B,qBAAqB,EACrB,2BAA2B,GAC5B,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,wBAAwB,EACxB,8BAA8B,EAC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CAAC;AACtB,YAAY,EACV,qBAAqB,EACrB,yBAAyB,EACzB,mBAAmB,EACnB,4BAA4B,EAC5B,mBAAmB,EACnB,oBAAoB,EACpB,4BAA4B,EAC5B,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACjE,YAAY,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/do-runner/index.js
CHANGED
|
@@ -3,21 +3,22 @@
|
|
|
3
3
|
// counterpart of @mastra/inngest / @mastra/temporal. init() returns DO-bound
|
|
4
4
|
// createWorkflow/createStep (import-swap); DurableObjectRunner hosts
|
|
5
5
|
// execution; D1 holds run snapshots so suspend/resume survives restarts.
|
|
6
|
-
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes,
|
|
6
|
+
export { BACKGROUND_TASK_TTL_PURGE_TABLES, createD1Storage, d1Changes, NOTIFICATION_TTL_PURGE_TABLES, purgeExpiredBackgroundTasks, purgeExpiredNotifications, purgeExpiredScheduleTriggers, purgeExpiredThreadState, purgeExpiredThreads, purgeExpiredWorkflowRuns, RUN_TTL_PURGE_TABLES, SCHEDULE_TRIGGER_TTL_PURGE_TABLES, THREAD_STATE_TTL_PURGE_TABLES, THREAD_TTL_PURGE_TABLES, } from './d1-storage.js';
|
|
7
|
+
export { assertDeploymentIdentity, assertDeploymentIdentitySecret, DEPLOYMENT_IDENTITY_HEADER, DEPLOYMENT_TAG_PATTERN, DeploymentIdentityError, deploymentIdentityHeaders, ensureDeploymentIdentity, ensureDeploymentIdentityBindings, readDeploymentIdentity, seedDeploymentIdentity, stampDeploymentIdentityRequest, verifyDurableObjectDeploymentIdentity, verifyDurableObjectDeploymentRequest, } from './deployment-identity.js';
|
|
7
8
|
// The DO error taxonomy and its extension point: a host DO's own route states a
|
|
8
9
|
// status by extending DoStatusError (see do-error-response.ts).
|
|
9
10
|
export { DoStatusError, doErrorResponse } from './do-error-response.js';
|
|
10
|
-
export { DurableObjectRunner } from './durable-object.js';
|
|
11
|
+
export { DurableObjectRunner, } from './durable-object.js';
|
|
11
12
|
export { assertNoReservedExecutionContext, findReservedExecutionContextKey, isReservedExecutionContextKey, RESERVED_EXECUTION_CONTEXT_KEYS, ReservedExecutionContextError, stripReservedExecutionContext, } from './execution-context.js';
|
|
12
|
-
export {
|
|
13
|
+
export { EXECUTION_PRINCIPAL_HEADER } from './execution-principal-header.js';
|
|
14
|
+
export { HUB_INSTANCE_NAME, HubDurableObject } from './hub-do.js';
|
|
13
15
|
export { init } from './init.js';
|
|
14
|
-
// Agent-memory
|
|
15
|
-
//
|
|
16
|
-
export {
|
|
17
|
-
export {
|
|
16
|
+
// Agent-memory id chokepoint: mint server-owned thread ids and validate trusted
|
|
17
|
+
// host business keys used as resource ids (clients never supply either).
|
|
18
|
+
export { mintThreadId, resourceIdFromKey } from './memory-id.js';
|
|
19
|
+
export { isPathSafeId, PATH_SAFE_ID_PATTERN } from './path-safe-id.js';
|
|
18
20
|
export { createHostPubSub } from './pubsub.js';
|
|
19
|
-
export { DurableStorageResumeLedger, InMemoryResumeLedger, } from './resume-ledger.js';
|
|
20
21
|
export { InvalidRunRequestError, RunAlreadyExistsError, RunNotSuspendedError, RunnerRuntime, UnknownRunError, UnknownWorkflowError, } from './runtime.js';
|
|
22
|
+
export { resolveScheduleStartOwner } from './schedule-source.js';
|
|
21
23
|
export { ThreadDurableObject, ThreadIdentityError } from './thread-do.js';
|
|
22
|
-
export { THREAD_PRINCIPAL_HEADER, THREAD_TENANT_HEADER, } from './thread-header.js';
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/do-runner/index.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,qEAAqE;AACrE,6EAA6E;AAC7E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mBAAmB,CAAC;AAEvE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAS/C,OAAO,EACL,sBAAsB,EACtB,qBAAqB,EACrB,oBAAoB,EACpB,aAAa,EACb,eAAe,EACf,oBAAoB,GACrB,MAAM,cAAc,CAAC;AAWtB,OAAO,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/do-runner/init.d.ts
CHANGED
|
@@ -2,7 +2,6 @@ import type { MastraCompositeStore } from '@mastra/core/storage';
|
|
|
2
2
|
import { createWorkflow as coreCreateWorkflow, createStep } from '@mastra/core/workflows';
|
|
3
3
|
import type { D1DatabaseBinding } from './cf-types.js';
|
|
4
4
|
import type { HostPubSub } from './pubsub.js';
|
|
5
|
-
import type { ResumeLedger } from './resume-ledger.js';
|
|
6
5
|
import type { RequestContextProvider } from './runtime.js';
|
|
7
6
|
import { RunnerRuntime } from './runtime.js';
|
|
8
7
|
/** Workers env shape init() understands directly. */
|
|
@@ -23,12 +22,6 @@ export interface InitOptions {
|
|
|
23
22
|
* grant-minting seam. See RequestContextProvider in runtime.ts.
|
|
24
23
|
*/
|
|
25
24
|
requestContextForRun?: RequestContextProvider;
|
|
26
|
-
/**
|
|
27
|
-
* Explicit resume ledger (see RunnerRuntimeOptions.resumeLedger). When
|
|
28
|
-
* omitted, the runtime defaults to in-memory and the DO shell adopts a
|
|
29
|
-
* ctx.storage-backed ledger.
|
|
30
|
-
*/
|
|
31
|
-
resumeLedger?: ResumeLedger;
|
|
32
25
|
/**
|
|
33
26
|
* The host Durable Object's single pubsub identity — `createHostPubSub()` for the
|
|
34
27
|
* default in-process emitter, or any PubSub the host built. init() is where a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.d.ts","sourceRoot":"","sources":["../../src/do-runner/init.ts"],"names":[],"mappings":"AAYA,OAAO,KAAK,EAAE,oB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a,CAAC;IACvB;;;;OAIG;IACH,MAAM,CAAC,EAAE,UAAU,CAAC;CACrB;AAED,wBAAgB,IAAI,CAClB,MAAM,EAAE,UAAU,EAClB,OAAO,GAAE,WAAgB,GACxB,UAAU,CA6CZ"}
|
package/dist/do-runner/init.js
CHANGED
|
@@ -32,8 +32,7 @@ export function init(source, options = {}) {
|
|
|
32
32
|
const runtime = new RunnerRuntime({
|
|
33
33
|
storage,
|
|
34
34
|
requestContextForRun: options.requestContextForRun,
|
|
35
|
-
|
|
36
|
-
// Threaded like the ledger, and for the same reason: every DO subclass
|
|
35
|
+
// Threaded directly because every DO subclass
|
|
37
36
|
// returns THIS runtime from build(), so a host that configures a pubsub
|
|
38
37
|
// reaches the runtime's createRun sites with no host change (Track A wires
|
|
39
38
|
// those). Handing it only to InitResult would strand it — build() returns a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/do-runner/init.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,mDAAmD;AAInD,OAAO,EACL,cAAc,IAAI,kBAAkB,EACpC,UAAU,GACX,MAAM,wBAAwB,CAAC;AAGhC,OAAO,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"init.js","sourceRoot":"","sources":["../../src/do-runner/init.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,6EAA6E;AAC7E,8EAA8E;AAC9E,4EAA4E;AAC5E,+EAA+E;AAC/E,+DAA+D;AAC/D,EAAE;AACF,2EAA2E;AAC3E,2EAA2E;AAC3E,8EAA8E;AAC9E,mDAAmD;AAInD,OAAO,EACL,cAAc,IAAI,kBAAkB,EACpC,UAAU,GACX,MAAM,wBAAwB,CAAC;AAGhC,OAAO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1,28 +1,11 @@
|
|
|
1
|
-
/** Mint a
|
|
2
|
-
export declare function mintThreadId(
|
|
1
|
+
/** Mint a server-owned agent-memory threadId (a uuid by default). */
|
|
2
|
+
export declare function mintThreadId(mintUuid?: () => string): string;
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
* The key is
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* fine — the tenant-ID pattern excludes '_' from tenant ids, so the first underscore is
|
|
10
|
-
* always the tenant boundary.
|
|
4
|
+
* Validate a host business key (a user id, a lead id) into an agent-memory
|
|
5
|
+
* resourceId. The key is deliberately stable across runs — it IS the memory
|
|
6
|
+
* owner's identity inside this deployment. The validator enforces do-runner's
|
|
7
|
+
* PATH_SAFE_ID_PATTERN so the id stays unambiguous in every context it keys
|
|
8
|
+
* (D1 rows, DO names, URL paths).
|
|
11
9
|
*/
|
|
12
|
-
export declare function
|
|
13
|
-
/**
|
|
14
|
-
* Recover the validated tenant prefix of a memory id (threadId or
|
|
15
|
-
* resourceId), or undefined when it carries none. Memory ids share the runId
|
|
16
|
-
* carrier deliberately, so this delegates to the ONE decode (`tenantOfRunId`)
|
|
17
|
-
* instead of growing a second parse that could drift.
|
|
18
|
-
*/
|
|
19
|
-
export declare function tenantOfMemoryId(id: string): string | undefined;
|
|
20
|
-
/**
|
|
21
|
-
* Exact tenant ownership of a memory id — delegates to the ONE salted-id
|
|
22
|
-
* ownership predicate (`tenantOwnsSaltedId`) so memory and run ownership can
|
|
23
|
-
* never drift. Exact because the '_' delimiter cannot occur
|
|
24
|
-
* inside a tenantId, so 'acme' can never own 'acmecorp_...'. Assert on EVERY
|
|
25
|
-
* memory read/write path.
|
|
26
|
-
*/
|
|
27
|
-
export declare function tenantOwnsMemoryId(tenantId: string, id: string): boolean;
|
|
10
|
+
export declare function resourceIdFromKey(resourceKey: string): string;
|
|
28
11
|
//# sourceMappingURL=memory-id.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-id.d.ts","sourceRoot":"","sources":["../../src/do-runner/memory-id.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"memory-id.d.ts","sourceRoot":"","sources":["../../src/do-runner/memory-id.ts"],"names":[],"mappings":"AAcA,qEAAqE;AACrE,wBAAgB,YAAY,CAC1B,QAAQ,GAAE,MAAM,MAAkC,GACjD,MAAM,CAQR;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAO7D"}
|
|
@@ -1,61 +1,34 @@
|
|
|
1
1
|
// SPDX-License-Identifier: Apache-2.0
|
|
2
|
-
// Agent-memory id
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
// tenant A's messages. These mints make memory ids tenant-disjoint BY
|
|
7
|
-
// CONSTRUCTION — the same `${tenantId}_${suffix}` shape as runIds, so the
|
|
8
|
-
// INV-3 charset argument (exact prefix decode, exact range purge) transfers
|
|
9
|
-
// verbatim and purgeTenant's [`${tid}_`, `${tid}\x60`) predicate covers the
|
|
10
|
-
// memory tables with zero new reasoning.
|
|
2
|
+
// Agent-memory id construction. Mastra keys agent memory by caller-chosen
|
|
3
|
+
// threadId/resourceId; flowsafe mints the thread id and validates a host-owned
|
|
4
|
+
// resource business key so a client can never smuggle an id that collides with
|
|
5
|
+
// (or probes for) another user's memory keys.
|
|
11
6
|
//
|
|
12
7
|
// Chokepoint rule (INV-2 style): hosts NEVER accept a client-supplied
|
|
13
|
-
// threadId/resourceId — mint server-side
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
//
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
// (side effects) or throws (masking the INV-3/reserved rejection) for an
|
|
24
|
-
// invalid tenant.
|
|
25
|
-
return mintSaltedId(tenantId, mintUuid, 'mintThreadId');
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Mint a tenant-salted agent-memory resourceId: `${tenantId}_${resourceKey}`.
|
|
29
|
-
* The key is the host's business identity for the memory owner (a user id, a
|
|
30
|
-
* lead id) and is deliberately stable across runs — two tenants using the
|
|
31
|
-
* SAME key stay disjoint because the prefix differs. The key must match the
|
|
32
|
-
* do-runner's PATH_SAFE_ID_PATTERN (RFC 3986 unreserved); '_' inside it is
|
|
33
|
-
* fine — the tenant-ID pattern excludes '_' from tenant ids, so the first underscore is
|
|
34
|
-
* always the tenant boundary.
|
|
35
|
-
*/
|
|
36
|
-
export function mintResourceId(tenantId, resourceKey) {
|
|
37
|
-
if (!PATH_SAFE_ID_PATTERN.test(resourceKey)) {
|
|
38
|
-
throw new Error(`mintResourceId: resourceKey '${resourceKey}' must match PATH_SAFE_ID_PATTERN (RFC 3986 unreserved chars, 1-200 long, not '.' or '..')`);
|
|
8
|
+
// threadId/resourceId — mint the thread server-side and validate the resource
|
|
9
|
+
// key from trusted host data. ActorContext.newThreadId() and
|
|
10
|
+
// ActorContext.resourceIdFromKey() wrap these constructors. Message ids need no
|
|
11
|
+
// separate constructor: every scoped query rides the trusted thread_id/resourceId.
|
|
12
|
+
import { isPathSafeId } from './path-safe-id.js';
|
|
13
|
+
/** Mint a server-owned agent-memory threadId (a uuid by default). */
|
|
14
|
+
export function mintThreadId(mintUuid = () => crypto.randomUUID()) {
|
|
15
|
+
const threadId = mintUuid();
|
|
16
|
+
if (!isPathSafeId(threadId)) {
|
|
17
|
+
throw new Error(`mintThreadId: generated threadId '${threadId}' must match PATH_SAFE_ID_PATTERN (RFC 3986 unreserved chars, 1-200 long, not '.' or '..') — it becomes a DO name and a D1 key`);
|
|
39
18
|
}
|
|
40
|
-
return
|
|
19
|
+
return threadId;
|
|
41
20
|
}
|
|
42
21
|
/**
|
|
43
|
-
*
|
|
44
|
-
* resourceId
|
|
45
|
-
*
|
|
46
|
-
*
|
|
22
|
+
* Validate a host business key (a user id, a lead id) into an agent-memory
|
|
23
|
+
* resourceId. The key is deliberately stable across runs — it IS the memory
|
|
24
|
+
* owner's identity inside this deployment. The validator enforces do-runner's
|
|
25
|
+
* PATH_SAFE_ID_PATTERN so the id stays unambiguous in every context it keys
|
|
26
|
+
* (D1 rows, DO names, URL paths).
|
|
47
27
|
*/
|
|
48
|
-
export function
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
* ownership predicate (`tenantOwnsSaltedId`) so memory and run ownership can
|
|
54
|
-
* never drift. Exact because the '_' delimiter cannot occur
|
|
55
|
-
* inside a tenantId, so 'acme' can never own 'acmecorp_...'. Assert on EVERY
|
|
56
|
-
* memory read/write path.
|
|
57
|
-
*/
|
|
58
|
-
export function tenantOwnsMemoryId(tenantId, id) {
|
|
59
|
-
return tenantOwnsSaltedId(tenantId, id);
|
|
28
|
+
export function resourceIdFromKey(resourceKey) {
|
|
29
|
+
if (!isPathSafeId(resourceKey)) {
|
|
30
|
+
throw new Error(`resourceIdFromKey: resourceKey '${resourceKey}' must match PATH_SAFE_ID_PATTERN (RFC 3986 unreserved chars, 1-200 long, not '.' or '..')`);
|
|
31
|
+
}
|
|
32
|
+
return resourceKey;
|
|
60
33
|
}
|
|
61
34
|
//# sourceMappingURL=memory-id.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"memory-id.js","sourceRoot":"","sources":["../../src/do-runner/memory-id.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"memory-id.js","sourceRoot":"","sources":["../../src/do-runner/memory-id.ts"],"names":[],"mappings":"AAAA,sCAAsC;AACtC,0EAA0E;AAC1E,+EAA+E;AAC/E,+EAA+E;AAC/E,8CAA8C;AAC9C,EAAE;AACF,sEAAsE;AACtE,8EAA8E;AAC9E,6DAA6D;AAC7D,gFAAgF;AAChF,mFAAmF;AAEnF,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAEjD,qEAAqE;AACrE,MAAM,UAAU,YAAY,CAC1B,WAAyB,GAAG,EAAE,CAAC,MAAM,CAAC,UAAU,EAAE;IAElD,MAAM,QAAQ,GAAG,QAAQ,EAAE,CAAC;IAC5B,IAAI,CAAC,YAAY,CAAC,QAAQ,CAAC,EAAE,CAAC;QAC5B,MAAM,IAAI,KAAK,CACb,qCAAqC,QAAQ,gIAAgI,CAC9K,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,iBAAiB,CAAC,WAAmB;IACnD,IAAI,CAAC,YAAY,CAAC,WAAW,CAAC,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,mCAAmC,WAAW,4FAA4F,CAC3I,CAAC;IACJ,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|