@maiaos/node 0.1.0-canary.44938d4.manual.1
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/README.md +517 -0
- package/dist/admin-monitor/application-projection.d.ts +27 -0
- package/dist/admin-monitor/application-projection.d.ts.map +1 -0
- package/dist/admin-monitor/application-projection.js +299 -0
- package/dist/admin-monitor/application-projection.js.map +1 -0
- package/dist/admin-monitor/application-reads.d.ts +20 -0
- package/dist/admin-monitor/application-reads.d.ts.map +1 -0
- package/dist/admin-monitor/application-reads.js +82 -0
- package/dist/admin-monitor/application-reads.js.map +1 -0
- package/dist/admin-monitor/assets.d.ts +7 -0
- package/dist/admin-monitor/assets.d.ts.map +1 -0
- package/dist/admin-monitor/assets.js +506 -0
- package/dist/admin-monitor/assets.js.map +1 -0
- package/dist/admin-monitor/housekeeping.d.ts +12 -0
- package/dist/admin-monitor/housekeeping.d.ts.map +1 -0
- package/dist/admin-monitor/housekeeping.js +59 -0
- package/dist/admin-monitor/housekeeping.js.map +1 -0
- package/dist/admin-monitor/http.d.ts +22 -0
- package/dist/admin-monitor/http.d.ts.map +1 -0
- package/dist/admin-monitor/http.js +219 -0
- package/dist/admin-monitor/http.js.map +1 -0
- package/dist/admin-monitor/listener.d.ts +9 -0
- package/dist/admin-monitor/listener.d.ts.map +1 -0
- package/dist/admin-monitor/listener.js +118 -0
- package/dist/admin-monitor/listener.js.map +1 -0
- package/dist/admin-monitor/model.d.ts +71 -0
- package/dist/admin-monitor/model.d.ts.map +1 -0
- package/dist/admin-monitor/model.js +31 -0
- package/dist/admin-monitor/model.js.map +1 -0
- package/dist/admin-monitor/projection.d.ts +10 -0
- package/dist/admin-monitor/projection.d.ts.map +1 -0
- package/dist/admin-monitor/projection.js +48 -0
- package/dist/admin-monitor/projection.js.map +1 -0
- package/dist/admin-monitor/routes.d.ts +13 -0
- package/dist/admin-monitor/routes.d.ts.map +1 -0
- package/dist/admin-monitor/routes.js +290 -0
- package/dist/admin-monitor/routes.js.map +1 -0
- package/dist/admin-monitor/service.d.ts +5 -0
- package/dist/admin-monitor/service.d.ts.map +1 -0
- package/dist/admin-monitor/service.js +155 -0
- package/dist/admin-monitor/service.js.map +1 -0
- package/dist/application/control-request.d.ts +38 -0
- package/dist/application/control-request.d.ts.map +1 -0
- package/dist/application/control-request.js +164 -0
- package/dist/application/control-request.js.map +1 -0
- package/dist/application/run-desktop-node.d.ts +18 -0
- package/dist/application/run-desktop-node.d.ts.map +1 -0
- package/dist/application/run-desktop-node.js +482 -0
- package/dist/application/run-desktop-node.js.map +1 -0
- package/dist/bin/maia-node.NOTICES.txt +100 -0
- package/dist/bin/maia-node.cdx.json +273 -0
- package/dist/bin/maia-node.d.ts +3 -0
- package/dist/bin/maia-node.d.ts.map +1 -0
- package/dist/bin/maia-node.meta.json +1 -0
- package/dist/bin/maia-node.mjs +4546 -0
- package/dist/bin/maia-node.mjs.map +6 -0
- package/dist/bin/maia-node.release.json +90 -0
- package/dist/bin/maia-process-host-darwin-arm64 +0 -0
- package/dist/bin/maia-process-host-darwin-arm64.build.json +59 -0
- package/dist/command-receipt/storage/codec.d.ts +16 -0
- package/dist/command-receipt/storage/codec.d.ts.map +1 -0
- package/dist/command-receipt/storage/codec.js +51 -0
- package/dist/command-receipt/storage/codec.js.map +1 -0
- package/dist/command-receipt/storage/cursor.d.ts +7 -0
- package/dist/command-receipt/storage/cursor.d.ts.map +1 -0
- package/dist/command-receipt/storage/cursor.js +62 -0
- package/dist/command-receipt/storage/cursor.js.map +1 -0
- package/dist/command-receipt/storage/list.d.ts +28 -0
- package/dist/command-receipt/storage/list.d.ts.map +1 -0
- package/dist/command-receipt/storage/list.js +113 -0
- package/dist/command-receipt/storage/list.js.map +1 -0
- package/dist/configuration/document-role.d.ts +4 -0
- package/dist/configuration/document-role.d.ts.map +1 -0
- package/dist/configuration/document-role.js +10 -0
- package/dist/configuration/document-role.js.map +1 -0
- package/dist/configuration/filesystem.d.ts +27 -0
- package/dist/configuration/filesystem.d.ts.map +1 -0
- package/dist/configuration/filesystem.js +227 -0
- package/dist/configuration/filesystem.js.map +1 -0
- package/dist/configuration/model.d.ts +68 -0
- package/dist/configuration/model.d.ts.map +1 -0
- package/dist/configuration/model.js +2 -0
- package/dist/configuration/model.js.map +1 -0
- package/dist/configuration/parser.d.ts +49 -0
- package/dist/configuration/parser.d.ts.map +1 -0
- package/dist/configuration/parser.js +35 -0
- package/dist/configuration/parser.js.map +1 -0
- package/dist/configuration/policy.d.ts +15 -0
- package/dist/configuration/policy.d.ts.map +1 -0
- package/dist/configuration/policy.js +15 -0
- package/dist/configuration/policy.js.map +1 -0
- package/dist/configuration/resolver.d.ts +15 -0
- package/dist/configuration/resolver.d.ts.map +1 -0
- package/dist/configuration/resolver.js +260 -0
- package/dist/configuration/resolver.js.map +1 -0
- package/dist/configuration/writer-child.d.ts +2 -0
- package/dist/configuration/writer-child.d.ts.map +1 -0
- package/dist/configuration/writer-child.js +32 -0
- package/dist/configuration/writer-child.js.map +1 -0
- package/dist/configuration/writer.d.ts +15 -0
- package/dist/configuration/writer.d.ts.map +1 -0
- package/dist/configuration/writer.js +789 -0
- package/dist/configuration/writer.js.map +1 -0
- package/dist/execution/application.d.ts +135 -0
- package/dist/execution/application.d.ts.map +1 -0
- package/dist/execution/application.js +14 -0
- package/dist/execution/application.js.map +1 -0
- package/dist/execution/database-operations.d.ts +15 -0
- package/dist/execution/database-operations.d.ts.map +1 -0
- package/dist/execution/database-operations.js +9 -0
- package/dist/execution/database-operations.js.map +1 -0
- package/dist/execution/request-digest.d.ts +3 -0
- package/dist/execution/request-digest.d.ts.map +1 -0
- package/dist/execution/request-digest.js +22 -0
- package/dist/execution/request-digest.js.map +1 -0
- package/dist/execution/service.d.ts +14 -0
- package/dist/execution/service.d.ts.map +1 -0
- package/dist/execution/service.js +19 -0
- package/dist/execution/service.js.map +1 -0
- package/dist/execution/storage.d.ts +20 -0
- package/dist/execution/storage.d.ts.map +1 -0
- package/dist/execution/storage.js +349 -0
- package/dist/execution/storage.js.map +1 -0
- package/dist/harness/application/requests.d.ts +304 -0
- package/dist/harness/application/requests.d.ts.map +1 -0
- package/dist/harness/application/requests.js +45 -0
- package/dist/harness/application/requests.js.map +1 -0
- package/dist/harness/codex/lifecycle.d.ts +39 -0
- package/dist/harness/codex/lifecycle.d.ts.map +1 -0
- package/dist/harness/codex/lifecycle.js +55 -0
- package/dist/harness/codex/lifecycle.js.map +1 -0
- package/dist/harness/codex/observability.d.ts +6 -0
- package/dist/harness/codex/observability.d.ts.map +1 -0
- package/dist/harness/codex/observability.js +58 -0
- package/dist/harness/codex/observability.js.map +1 -0
- package/dist/harness/codex/policy.d.ts +15 -0
- package/dist/harness/codex/policy.d.ts.map +1 -0
- package/dist/harness/codex/policy.js +15 -0
- package/dist/harness/codex/policy.js.map +1 -0
- package/dist/harness/codex/probe.d.ts +173 -0
- package/dist/harness/codex/probe.d.ts.map +1 -0
- package/dist/harness/codex/probe.js +134 -0
- package/dist/harness/codex/probe.js.map +1 -0
- package/dist/harness/codex/protocol.d.ts +15 -0
- package/dist/harness/codex/protocol.d.ts.map +1 -0
- package/dist/harness/codex/protocol.js +52 -0
- package/dist/harness/codex/protocol.js.map +1 -0
- package/dist/harness/codex/service.d.ts +196 -0
- package/dist/harness/codex/service.d.ts.map +1 -0
- package/dist/harness/codex/service.js +141 -0
- package/dist/harness/codex/service.js.map +1 -0
- package/dist/harness/codex/session-lifecycle.d.ts +40 -0
- package/dist/harness/codex/session-lifecycle.d.ts.map +1 -0
- package/dist/harness/codex/session-lifecycle.js +39 -0
- package/dist/harness/codex/session-lifecycle.js.map +1 -0
- package/dist/harness/codex/session-observability.d.ts +7 -0
- package/dist/harness/codex/session-observability.d.ts.map +1 -0
- package/dist/harness/codex/session-observability.js +39 -0
- package/dist/harness/codex/session-observability.js.map +1 -0
- package/dist/harness/codex/session-protocol.d.ts +92 -0
- package/dist/harness/codex/session-protocol.d.ts.map +1 -0
- package/dist/harness/codex/session-protocol.js +475 -0
- package/dist/harness/codex/session-protocol.js.map +1 -0
- package/dist/harness/codex/session-service.d.ts +59 -0
- package/dist/harness/codex/session-service.d.ts.map +1 -0
- package/dist/harness/codex/session-service.js +340 -0
- package/dist/harness/codex/session-service.js.map +1 -0
- package/dist/harness/codex/session-transport.d.ts +22 -0
- package/dist/harness/codex/session-transport.d.ts.map +1 -0
- package/dist/harness/codex/session-transport.js +152 -0
- package/dist/harness/codex/session-transport.js.map +1 -0
- package/dist/harness/codex/transport.d.ts +104 -0
- package/dist/harness/codex/transport.d.ts.map +1 -0
- package/dist/harness/codex/transport.js +645 -0
- package/dist/harness/codex/transport.js.map +1 -0
- package/dist/harness/codex/turn/lifecycle.d.ts +40 -0
- package/dist/harness/codex/turn/lifecycle.d.ts.map +1 -0
- package/dist/harness/codex/turn/lifecycle.js +43 -0
- package/dist/harness/codex/turn/lifecycle.js.map +1 -0
- package/dist/harness/codex/turn/observability.d.ts +8 -0
- package/dist/harness/codex/turn/observability.d.ts.map +1 -0
- package/dist/harness/codex/turn/observability.js +63 -0
- package/dist/harness/codex/turn/observability.js.map +1 -0
- package/dist/harness/codex/turn/transport.d.ts +21 -0
- package/dist/harness/codex/turn/transport.d.ts.map +1 -0
- package/dist/harness/codex/turn/transport.js +387 -0
- package/dist/harness/codex/turn/transport.js.map +1 -0
- package/dist/harness/installed/catalog.d.ts +30 -0
- package/dist/harness/installed/catalog.d.ts.map +1 -0
- package/dist/harness/installed/catalog.js +29 -0
- package/dist/harness/installed/catalog.js.map +1 -0
- package/dist/harness/installed/policy.d.ts +23 -0
- package/dist/harness/installed/policy.d.ts.map +1 -0
- package/dist/harness/installed/policy.js +29 -0
- package/dist/harness/installed/policy.js.map +1 -0
- package/dist/harness/installed/resolver.d.ts +39 -0
- package/dist/harness/installed/resolver.d.ts.map +1 -0
- package/dist/harness/installed/resolver.js +93 -0
- package/dist/harness/installed/resolver.js.map +1 -0
- package/dist/harness/installed/scan.d.ts +61 -0
- package/dist/harness/installed/scan.d.ts.map +1 -0
- package/dist/harness/installed/scan.js +327 -0
- package/dist/harness/installed/scan.js.map +1 -0
- package/dist/harness/installed/service.d.ts +99 -0
- package/dist/harness/installed/service.d.ts.map +1 -0
- package/dist/harness/installed/service.js +206 -0
- package/dist/harness/installed/service.js.map +1 -0
- package/dist/harness/pi-rpc/artifact.d.ts +57 -0
- package/dist/harness/pi-rpc/artifact.d.ts.map +1 -0
- package/dist/harness/pi-rpc/artifact.js +431 -0
- package/dist/harness/pi-rpc/artifact.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/authorization-store.d.ts +41 -0
- package/dist/harness/pi-rpc/authorization/authorization-store.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/authorization-store.js +235 -0
- package/dist/harness/pi-rpc/authorization/authorization-store.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/database.d.ts +99 -0
- package/dist/harness/pi-rpc/authorization/database.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/database.js +94 -0
- package/dist/harness/pi-rpc/authorization/database.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/index.d.ts +7 -0
- package/dist/harness/pi-rpc/authorization/index.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/index.js +6 -0
- package/dist/harness/pi-rpc/authorization/index.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/permit-compaction-store.d.ts +3 -0
- package/dist/harness/pi-rpc/authorization/permit-compaction-store.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/permit-compaction-store.js +61 -0
- package/dist/harness/pi-rpc/authorization/permit-compaction-store.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/permit-store.d.ts +38 -0
- package/dist/harness/pi-rpc/authorization/permit-store.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/permit-store.js +310 -0
- package/dist/harness/pi-rpc/authorization/permit-store.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/plan-store.d.ts +14 -0
- package/dist/harness/pi-rpc/authorization/plan-store.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/plan-store.js +205 -0
- package/dist/harness/pi-rpc/authorization/plan-store.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/policy.d.ts +18 -0
- package/dist/harness/pi-rpc/authorization/policy.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/policy.js +131 -0
- package/dist/harness/pi-rpc/authorization/policy.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/projection.d.ts +7 -0
- package/dist/harness/pi-rpc/authorization/projection.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/projection.js +195 -0
- package/dist/harness/pi-rpc/authorization/projection.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/recovery-store.d.ts +3 -0
- package/dist/harness/pi-rpc/authorization/recovery-store.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/recovery-store.js +63 -0
- package/dist/harness/pi-rpc/authorization/recovery-store.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/replay-store.d.ts +11 -0
- package/dist/harness/pi-rpc/authorization/replay-store.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/replay-store.js +60 -0
- package/dist/harness/pi-rpc/authorization/replay-store.js.map +1 -0
- package/dist/harness/pi-rpc/authorization/types.d.ts +117 -0
- package/dist/harness/pi-rpc/authorization/types.d.ts.map +1 -0
- package/dist/harness/pi-rpc/authorization/types.js +3 -0
- package/dist/harness/pi-rpc/authorization/types.js.map +1 -0
- package/dist/harness/pi-rpc/contract.d.ts +86 -0
- package/dist/harness/pi-rpc/contract.d.ts.map +1 -0
- package/dist/harness/pi-rpc/contract.js +206 -0
- package/dist/harness/pi-rpc/contract.js.map +1 -0
- package/dist/harness/pi-rpc/conversation.d.ts +129 -0
- package/dist/harness/pi-rpc/conversation.d.ts.map +1 -0
- package/dist/harness/pi-rpc/conversation.js +885 -0
- package/dist/harness/pi-rpc/conversation.js.map +1 -0
- package/dist/harness/pi-rpc/jsonl.d.ts +16 -0
- package/dist/harness/pi-rpc/jsonl.d.ts.map +1 -0
- package/dist/harness/pi-rpc/jsonl.js +115 -0
- package/dist/harness/pi-rpc/jsonl.js.map +1 -0
- package/dist/harness/pi-rpc/managed-process.d.ts +13 -0
- package/dist/harness/pi-rpc/managed-process.d.ts.map +1 -0
- package/dist/harness/pi-rpc/managed-process.js +64 -0
- package/dist/harness/pi-rpc/managed-process.js.map +1 -0
- package/dist/harness/pi-rpc/manifest-order.d.ts +7 -0
- package/dist/harness/pi-rpc/manifest-order.d.ts.map +1 -0
- package/dist/harness/pi-rpc/manifest-order.js +11 -0
- package/dist/harness/pi-rpc/manifest-order.js.map +1 -0
- package/dist/harness/pi-rpc/probe.d.ts +18 -0
- package/dist/harness/pi-rpc/probe.d.ts.map +1 -0
- package/dist/harness/pi-rpc/probe.js +168 -0
- package/dist/harness/pi-rpc/probe.js.map +1 -0
- package/dist/harness/pi-rpc/runtime-probe.d.ts +93 -0
- package/dist/harness/pi-rpc/runtime-probe.d.ts.map +1 -0
- package/dist/harness/pi-rpc/runtime-probe.js +381 -0
- package/dist/harness/pi-rpc/runtime-probe.js.map +1 -0
- package/dist/harness/pi-rpc/session-launch.d.ts +46 -0
- package/dist/harness/pi-rpc/session-launch.d.ts.map +1 -0
- package/dist/harness/pi-rpc/session-launch.js +547 -0
- package/dist/harness/pi-rpc/session-launch.js.map +1 -0
- package/dist/harness/pi-rpc/session-service.d.ts +71 -0
- package/dist/harness/pi-rpc/session-service.d.ts.map +1 -0
- package/dist/harness/pi-rpc/session-service.js +336 -0
- package/dist/harness/pi-rpc/session-service.js.map +1 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +173 -0
- package/dist/index.js.map +1 -0
- package/dist/integration-authorization/application.d.ts +56 -0
- package/dist/integration-authorization/application.d.ts.map +1 -0
- package/dist/integration-authorization/application.js +185 -0
- package/dist/integration-authorization/application.js.map +1 -0
- package/dist/integration-authorization/pi-rpc-application.d.ts +46 -0
- package/dist/integration-authorization/pi-rpc-application.d.ts.map +1 -0
- package/dist/integration-authorization/pi-rpc-application.js +201 -0
- package/dist/integration-authorization/pi-rpc-application.js.map +1 -0
- package/dist/integration-authorization/pi-rpc-requests.d.ts +10 -0
- package/dist/integration-authorization/pi-rpc-requests.d.ts.map +1 -0
- package/dist/integration-authorization/pi-rpc-requests.js +221 -0
- package/dist/integration-authorization/pi-rpc-requests.js.map +1 -0
- package/dist/integration-authorization/requests.d.ts +10 -0
- package/dist/integration-authorization/requests.d.ts.map +1 -0
- package/dist/integration-authorization/requests.js +208 -0
- package/dist/integration-authorization/requests.js.map +1 -0
- package/dist/invocation-context/application.d.ts +34 -0
- package/dist/invocation-context/application.d.ts.map +1 -0
- package/dist/invocation-context/application.js +14 -0
- package/dist/invocation-context/application.js.map +1 -0
- package/dist/invocation-context/resolver.d.ts +6 -0
- package/dist/invocation-context/resolver.d.ts.map +1 -0
- package/dist/invocation-context/resolver.js +15 -0
- package/dist/invocation-context/resolver.js.map +1 -0
- package/dist/lifecycle/node-machine.d.ts +45 -0
- package/dist/lifecycle/node-machine.d.ts.map +1 -0
- package/dist/lifecycle/node-machine.js +64 -0
- package/dist/lifecycle/node-machine.js.map +1 -0
- package/dist/orchestration/application.d.ts +10 -0
- package/dist/orchestration/application.d.ts.map +1 -0
- package/dist/orchestration/application.js +97 -0
- package/dist/orchestration/application.js.map +1 -0
- package/dist/orchestration/lifecycle.d.ts +98 -0
- package/dist/orchestration/lifecycle.d.ts.map +1 -0
- package/dist/orchestration/lifecycle.js +118 -0
- package/dist/orchestration/lifecycle.js.map +1 -0
- package/dist/orchestration/mutations.d.ts +28 -0
- package/dist/orchestration/mutations.d.ts.map +1 -0
- package/dist/orchestration/mutations.js +562 -0
- package/dist/orchestration/mutations.js.map +1 -0
- package/dist/orchestration/storage.d.ts +200 -0
- package/dist/orchestration/storage.d.ts.map +1 -0
- package/dist/orchestration/storage.js +1214 -0
- package/dist/orchestration/storage.js.map +1 -0
- package/dist/project-workspace/application/requests.d.ts +44 -0
- package/dist/project-workspace/application/requests.d.ts.map +1 -0
- package/dist/project-workspace/application/requests.js +92 -0
- package/dist/project-workspace/application/requests.js.map +1 -0
- package/dist/project-workspace/repository/inspector.d.ts +47 -0
- package/dist/project-workspace/repository/inspector.d.ts.map +1 -0
- package/dist/project-workspace/repository/inspector.js +311 -0
- package/dist/project-workspace/repository/inspector.js.map +1 -0
- package/dist/project-workspace/storage/request-digest.d.ts +11 -0
- package/dist/project-workspace/storage/request-digest.d.ts.map +1 -0
- package/dist/project-workspace/storage/request-digest.js +21 -0
- package/dist/project-workspace/storage/request-digest.js.map +1 -0
- package/dist/project-workspace/storage/store.d.ts +34 -0
- package/dist/project-workspace/storage/store.d.ts.map +1 -0
- package/dist/project-workspace/storage/store.js +603 -0
- package/dist/project-workspace/storage/store.js.map +1 -0
- package/dist/runtime/connection-descriptor.d.ts +19 -0
- package/dist/runtime/connection-descriptor.d.ts.map +1 -0
- package/dist/runtime/connection-descriptor.js +136 -0
- package/dist/runtime/connection-descriptor.js.map +1 -0
- package/dist/runtime/errors.d.ts +21 -0
- package/dist/runtime/errors.d.ts.map +1 -0
- package/dist/runtime/errors.js +48 -0
- package/dist/runtime/errors.js.map +1 -0
- package/dist/runtime/framing.d.ts +9 -0
- package/dist/runtime/framing.d.ts.map +1 -0
- package/dist/runtime/framing.js +48 -0
- package/dist/runtime/framing.js.map +1 -0
- package/dist/runtime/instance-lock.d.ts +54 -0
- package/dist/runtime/instance-lock.d.ts.map +1 -0
- package/dist/runtime/instance-lock.js +566 -0
- package/dist/runtime/instance-lock.js.map +1 -0
- package/dist/runtime/local-credential.d.ts +16 -0
- package/dist/runtime/local-credential.d.ts.map +1 -0
- package/dist/runtime/local-credential.js +66 -0
- package/dist/runtime/local-credential.js.map +1 -0
- package/dist/runtime/local-server-channels.d.ts +11 -0
- package/dist/runtime/local-server-channels.d.ts.map +1 -0
- package/dist/runtime/local-server-channels.js +21 -0
- package/dist/runtime/local-server-channels.js.map +1 -0
- package/dist/runtime/local-server-listener.d.ts +12 -0
- package/dist/runtime/local-server-listener.d.ts.map +1 -0
- package/dist/runtime/local-server-listener.js +41 -0
- package/dist/runtime/local-server-listener.js.map +1 -0
- package/dist/runtime/local-server.d.ts +27 -0
- package/dist/runtime/local-server.d.ts.map +1 -0
- package/dist/runtime/local-server.js +639 -0
- package/dist/runtime/local-server.js.map +1 -0
- package/dist/runtime/observability.d.ts +21 -0
- package/dist/runtime/observability.d.ts.map +1 -0
- package/dist/runtime/observability.js +164 -0
- package/dist/runtime/observability.js.map +1 -0
- package/dist/runtime/process/owned-tree.d.ts +24 -0
- package/dist/runtime/process/owned-tree.d.ts.map +1 -0
- package/dist/runtime/process/owned-tree.js +228 -0
- package/dist/runtime/process/owned-tree.js.map +1 -0
- package/dist/runtime/process/resource/cleanup.d.ts +13 -0
- package/dist/runtime/process/resource/cleanup.d.ts.map +1 -0
- package/dist/runtime/process/resource/cleanup.js +196 -0
- package/dist/runtime/process/resource/cleanup.js.map +1 -0
- package/dist/runtime/process/resource/contract.d.ts +382 -0
- package/dist/runtime/process/resource/contract.d.ts.map +1 -0
- package/dist/runtime/process/resource/contract.js +2 -0
- package/dist/runtime/process/resource/contract.js.map +1 -0
- package/dist/runtime/process/resource/darwin-native-host-bootstrap.d.ts +7 -0
- package/dist/runtime/process/resource/darwin-native-host-bootstrap.d.ts.map +1 -0
- package/dist/runtime/process/resource/darwin-native-host-bootstrap.js +196 -0
- package/dist/runtime/process/resource/darwin-native-host-bootstrap.js.map +1 -0
- package/dist/runtime/process/resource/darwin-source-candidate-layer.d.ts +16 -0
- package/dist/runtime/process/resource/darwin-source-candidate-layer.d.ts.map +1 -0
- package/dist/runtime/process/resource/darwin-source-candidate-layer.js +51 -0
- package/dist/runtime/process/resource/darwin-source-candidate-layer.js.map +1 -0
- package/dist/runtime/process/resource/darwin-vouch-policy.d.ts +44 -0
- package/dist/runtime/process/resource/darwin-vouch-policy.d.ts.map +1 -0
- package/dist/runtime/process/resource/darwin-vouch-policy.js +253 -0
- package/dist/runtime/process/resource/darwin-vouch-policy.js.map +1 -0
- package/dist/runtime/process/resource/health.d.ts +45 -0
- package/dist/runtime/process/resource/health.d.ts.map +1 -0
- package/dist/runtime/process/resource/health.js +197 -0
- package/dist/runtime/process/resource/health.js.map +1 -0
- package/dist/runtime/process/resource/host-frame.d.ts +39 -0
- package/dist/runtime/process/resource/host-frame.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-frame.js +266 -0
- package/dist/runtime/process/resource/host-frame.js.map +1 -0
- package/dist/runtime/process/resource/host-launch.d.ts +11 -0
- package/dist/runtime/process/resource/host-launch.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-launch.js +296 -0
- package/dist/runtime/process/resource/host-launch.js.map +1 -0
- package/dist/runtime/process/resource/host-lifecycle.d.ts +91 -0
- package/dist/runtime/process/resource/host-lifecycle.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-lifecycle.js +96 -0
- package/dist/runtime/process/resource/host-lifecycle.js.map +1 -0
- package/dist/runtime/process/resource/host-message.d.ts +15 -0
- package/dist/runtime/process/resource/host-message.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-message.js +538 -0
- package/dist/runtime/process/resource/host-message.js.map +1 -0
- package/dist/runtime/process/resource/host-protocol-contract.d.ts +222 -0
- package/dist/runtime/process/resource/host-protocol-contract.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-protocol-contract.js +69 -0
- package/dist/runtime/process/resource/host-protocol-contract.js.map +1 -0
- package/dist/runtime/process/resource/host-protocol-sequence.d.ts +14 -0
- package/dist/runtime/process/resource/host-protocol-sequence.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-protocol-sequence.js +304 -0
- package/dist/runtime/process/resource/host-protocol-sequence.js.map +1 -0
- package/dist/runtime/process/resource/host-protocol.d.ts +5 -0
- package/dist/runtime/process/resource/host-protocol.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-protocol.js +5 -0
- package/dist/runtime/process/resource/host-protocol.js.map +1 -0
- package/dist/runtime/process/resource/host-snapshot.d.ts +11 -0
- package/dist/runtime/process/resource/host-snapshot.d.ts.map +1 -0
- package/dist/runtime/process/resource/host-snapshot.js +239 -0
- package/dist/runtime/process/resource/host-snapshot.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/authorization-store.d.ts +48 -0
- package/dist/runtime/process/resource/integration-authorization/authorization-store.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/authorization-store.js +269 -0
- package/dist/runtime/process/resource/integration-authorization/authorization-store.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/database.d.ts +10 -0
- package/dist/runtime/process/resource/integration-authorization/database.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/database.js +98 -0
- package/dist/runtime/process/resource/integration-authorization/database.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/index.d.ts +7 -0
- package/dist/runtime/process/resource/integration-authorization/index.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/index.js +6 -0
- package/dist/runtime/process/resource/integration-authorization/index.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/permit-compaction-store.d.ts +3 -0
- package/dist/runtime/process/resource/integration-authorization/permit-compaction-store.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/permit-compaction-store.js +87 -0
- package/dist/runtime/process/resource/integration-authorization/permit-compaction-store.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/permit-store.d.ts +44 -0
- package/dist/runtime/process/resource/integration-authorization/permit-store.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/permit-store.js +486 -0
- package/dist/runtime/process/resource/integration-authorization/permit-store.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/plan-integrity.d.ts +21 -0
- package/dist/runtime/process/resource/integration-authorization/plan-integrity.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/plan-integrity.js +172 -0
- package/dist/runtime/process/resource/integration-authorization/plan-integrity.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/plan-payload.d.ts +31 -0
- package/dist/runtime/process/resource/integration-authorization/plan-payload.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/plan-payload.js +15 -0
- package/dist/runtime/process/resource/integration-authorization/plan-payload.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/plan-store.d.ts +11 -0
- package/dist/runtime/process/resource/integration-authorization/plan-store.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/plan-store.js +124 -0
- package/dist/runtime/process/resource/integration-authorization/plan-store.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/policy.d.ts +37 -0
- package/dist/runtime/process/resource/integration-authorization/policy.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/policy.js +141 -0
- package/dist/runtime/process/resource/integration-authorization/policy.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/projection.d.ts +5 -0
- package/dist/runtime/process/resource/integration-authorization/projection.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/projection.js +56 -0
- package/dist/runtime/process/resource/integration-authorization/projection.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/replay-store.d.ts +9 -0
- package/dist/runtime/process/resource/integration-authorization/replay-store.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/replay-store.js +55 -0
- package/dist/runtime/process/resource/integration-authorization/replay-store.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/types.d.ts +152 -0
- package/dist/runtime/process/resource/integration-authorization/types.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization/types.js +3 -0
- package/dist/runtime/process/resource/integration-authorization/types.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization-manager.d.ts +9 -0
- package/dist/runtime/process/resource/integration-authorization-manager.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization-manager.js +353 -0
- package/dist/runtime/process/resource/integration-authorization-manager.js.map +1 -0
- package/dist/runtime/process/resource/integration-authorization-storage.d.ts +2 -0
- package/dist/runtime/process/resource/integration-authorization-storage.d.ts.map +1 -0
- package/dist/runtime/process/resource/integration-authorization-storage.js +2 -0
- package/dist/runtime/process/resource/integration-authorization-storage.js.map +1 -0
- package/dist/runtime/process/resource/internal-spawn.d.ts +27 -0
- package/dist/runtime/process/resource/internal-spawn.d.ts.map +1 -0
- package/dist/runtime/process/resource/internal-spawn.js +7 -0
- package/dist/runtime/process/resource/internal-spawn.js.map +1 -0
- package/dist/runtime/process/resource/launch-authority.d.ts +5 -0
- package/dist/runtime/process/resource/launch-authority.d.ts.map +1 -0
- package/dist/runtime/process/resource/launch-authority.js +37 -0
- package/dist/runtime/process/resource/launch-authority.js.map +1 -0
- package/dist/runtime/process/resource/launch-gate.d.ts +19 -0
- package/dist/runtime/process/resource/launch-gate.d.ts.map +1 -0
- package/dist/runtime/process/resource/launch-gate.js +16 -0
- package/dist/runtime/process/resource/launch-gate.js.map +1 -0
- package/dist/runtime/process/resource/linux-process-identity.d.ts +13 -0
- package/dist/runtime/process/resource/linux-process-identity.d.ts.map +1 -0
- package/dist/runtime/process/resource/linux-process-identity.js +40 -0
- package/dist/runtime/process/resource/linux-process-identity.js.map +1 -0
- package/dist/runtime/process/resource/managed-tree.d.ts +28 -0
- package/dist/runtime/process/resource/managed-tree.d.ts.map +1 -0
- package/dist/runtime/process/resource/managed-tree.js +79 -0
- package/dist/runtime/process/resource/managed-tree.js.map +1 -0
- package/dist/runtime/process/resource/native-host-adapter.d.ts +17 -0
- package/dist/runtime/process/resource/native-host-adapter.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-adapter.js +169 -0
- package/dist/runtime/process/resource/native-host-adapter.js.map +1 -0
- package/dist/runtime/process/resource/native-host-artifact.d.ts +28 -0
- package/dist/runtime/process/resource/native-host-artifact.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-artifact.js +110 -0
- package/dist/runtime/process/resource/native-host-artifact.js.map +1 -0
- package/dist/runtime/process/resource/native-host-bootstrap.d.ts +29 -0
- package/dist/runtime/process/resource/native-host-bootstrap.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-bootstrap.js +2 -0
- package/dist/runtime/process/resource/native-host-bootstrap.js.map +1 -0
- package/dist/runtime/process/resource/native-host-capability.d.ts +5 -0
- package/dist/runtime/process/resource/native-host-capability.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-capability.js +86 -0
- package/dist/runtime/process/resource/native-host-capability.js.map +1 -0
- package/dist/runtime/process/resource/native-host-connection.d.ts +82 -0
- package/dist/runtime/process/resource/native-host-connection.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-connection.js +448 -0
- package/dist/runtime/process/resource/native-host-connection.js.map +1 -0
- package/dist/runtime/process/resource/native-host-contract.d.ts +47 -0
- package/dist/runtime/process/resource/native-host-contract.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-contract.js +2 -0
- package/dist/runtime/process/resource/native-host-contract.js.map +1 -0
- package/dist/runtime/process/resource/native-host-frame-parser.d.ts +22 -0
- package/dist/runtime/process/resource/native-host-frame-parser.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-frame-parser.js +110 -0
- package/dist/runtime/process/resource/native-host-frame-parser.js.map +1 -0
- package/dist/runtime/process/resource/native-host-output.d.ts +16 -0
- package/dist/runtime/process/resource/native-host-output.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-output.js +94 -0
- package/dist/runtime/process/resource/native-host-output.js.map +1 -0
- package/dist/runtime/process/resource/native-host-projection.d.ts +20 -0
- package/dist/runtime/process/resource/native-host-projection.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-projection.js +74 -0
- package/dist/runtime/process/resource/native-host-projection.js.map +1 -0
- package/dist/runtime/process/resource/native-host-release-identity.d.ts +19 -0
- package/dist/runtime/process/resource/native-host-release-identity.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-release-identity.js +56 -0
- package/dist/runtime/process/resource/native-host-release-identity.js.map +1 -0
- package/dist/runtime/process/resource/native-host-state.d.ts +38 -0
- package/dist/runtime/process/resource/native-host-state.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-host-state.js +303 -0
- package/dist/runtime/process/resource/native-host-state.js.map +1 -0
- package/dist/runtime/process/resource/native-manager.d.ts +11 -0
- package/dist/runtime/process/resource/native-manager.d.ts.map +1 -0
- package/dist/runtime/process/resource/native-manager.js +646 -0
- package/dist/runtime/process/resource/native-manager.js.map +1 -0
- package/dist/runtime/process/resource/pi-rpc-launch-authority.d.ts +8 -0
- package/dist/runtime/process/resource/pi-rpc-launch-authority.d.ts.map +1 -0
- package/dist/runtime/process/resource/pi-rpc-launch-authority.js +158 -0
- package/dist/runtime/process/resource/pi-rpc-launch-authority.js.map +1 -0
- package/dist/runtime/process/resource/policy.d.ts +53 -0
- package/dist/runtime/process/resource/policy.d.ts.map +1 -0
- package/dist/runtime/process/resource/policy.js +501 -0
- package/dist/runtime/process/resource/policy.js.map +1 -0
- package/dist/runtime/process/resource/process-identity.d.ts +29 -0
- package/dist/runtime/process/resource/process-identity.d.ts.map +1 -0
- package/dist/runtime/process/resource/process-identity.js +199 -0
- package/dist/runtime/process/resource/process-identity.js.map +1 -0
- package/dist/runtime/process/resource/ps-snapshot.d.ts +12 -0
- package/dist/runtime/process/resource/ps-snapshot.d.ts.map +1 -0
- package/dist/runtime/process/resource/ps-snapshot.js +77 -0
- package/dist/runtime/process/resource/ps-snapshot.js.map +1 -0
- package/dist/runtime/process/resource/sampler.d.ts +18 -0
- package/dist/runtime/process/resource/sampler.d.ts.map +1 -0
- package/dist/runtime/process/resource/sampler.js +19 -0
- package/dist/runtime/process/resource/sampler.js.map +1 -0
- package/dist/runtime/process/resource/sampling.d.ts +23 -0
- package/dist/runtime/process/resource/sampling.d.ts.map +1 -0
- package/dist/runtime/process/resource/sampling.js +131 -0
- package/dist/runtime/process/resource/sampling.js.map +1 -0
- package/dist/runtime/process/resource/service.d.ts +15 -0
- package/dist/runtime/process/resource/service.d.ts.map +1 -0
- package/dist/runtime/process/resource/service.js +39 -0
- package/dist/runtime/process/resource/service.js.map +1 -0
- package/dist/runtime/process/resource/snapshot.d.ts +24 -0
- package/dist/runtime/process/resource/snapshot.d.ts.map +1 -0
- package/dist/runtime/process/resource/snapshot.js +149 -0
- package/dist/runtime/process/resource/snapshot.js.map +1 -0
- package/dist/runtime/process/resource/telemetry.d.ts +9 -0
- package/dist/runtime/process/resource/telemetry.d.ts.map +1 -0
- package/dist/runtime/process/resource/telemetry.js +51 -0
- package/dist/runtime/process/resource/telemetry.js.map +1 -0
- package/dist/runtime/process/resource/test-runtime-layer.d.ts +25 -0
- package/dist/runtime/process/resource/test-runtime-layer.d.ts.map +1 -0
- package/dist/runtime/process/resource/test-runtime-layer.js +296 -0
- package/dist/runtime/process/resource/test-runtime-layer.js.map +1 -0
- package/dist/runtime/process/resource/testing.d.ts +18 -0
- package/dist/runtime/process/resource/testing.d.ts.map +1 -0
- package/dist/runtime/process/resource/testing.js +216 -0
- package/dist/runtime/process/resource/testing.js.map +1 -0
- package/dist/runtime/profile-paths.d.ts +27 -0
- package/dist/runtime/profile-paths.d.ts.map +1 -0
- package/dist/runtime/profile-paths.js +111 -0
- package/dist/runtime/profile-paths.js.map +1 -0
- package/dist/runtime/startup/testing/benchmark-evidence.d.ts +45 -0
- package/dist/runtime/startup/testing/benchmark-evidence.d.ts.map +1 -0
- package/dist/runtime/startup/testing/benchmark-evidence.js +261 -0
- package/dist/runtime/startup/testing/benchmark-evidence.js.map +1 -0
- package/dist/session/application/activation.d.ts +22 -0
- package/dist/session/application/activation.d.ts.map +1 -0
- package/dist/session/application/activation.js +202 -0
- package/dist/session/application/activation.js.map +1 -0
- package/dist/session/application/requests.d.ts +25 -0
- package/dist/session/application/requests.d.ts.map +1 -0
- package/dist/session/application/requests.js +76 -0
- package/dist/session/application/requests.js.map +1 -0
- package/dist/session/application/testing/activation-barrier.d.ts +8 -0
- package/dist/session/application/testing/activation-barrier.d.ts.map +1 -0
- package/dist/session/application/testing/activation-barrier.js +55 -0
- package/dist/session/application/testing/activation-barrier.js.map +1 -0
- package/dist/session/runtime/admission.d.ts +8 -0
- package/dist/session/runtime/admission.d.ts.map +1 -0
- package/dist/session/runtime/admission.js +22 -0
- package/dist/session/runtime/admission.js.map +1 -0
- package/dist/session/runtime/policy.d.ts +5 -0
- package/dist/session/runtime/policy.d.ts.map +1 -0
- package/dist/session/runtime/policy.js +5 -0
- package/dist/session/runtime/policy.js.map +1 -0
- package/dist/session/storage/activation-command.d.ts +12 -0
- package/dist/session/storage/activation-command.d.ts.map +1 -0
- package/dist/session/storage/activation-command.js +146 -0
- package/dist/session/storage/activation-command.js.map +1 -0
- package/dist/session/storage/activation-mutations.d.ts +25 -0
- package/dist/session/storage/activation-mutations.d.ts.map +1 -0
- package/dist/session/storage/activation-mutations.js +34 -0
- package/dist/session/storage/activation-mutations.js.map +1 -0
- package/dist/session/storage/activation-record.d.ts +28 -0
- package/dist/session/storage/activation-record.d.ts.map +1 -0
- package/dist/session/storage/activation-record.js +109 -0
- package/dist/session/storage/activation-record.js.map +1 -0
- package/dist/session/storage/activation-state.d.ts +18 -0
- package/dist/session/storage/activation-state.d.ts.map +1 -0
- package/dist/session/storage/activation-state.js +173 -0
- package/dist/session/storage/activation-state.js.map +1 -0
- package/dist/session/storage/activation.d.ts +4 -0
- package/dist/session/storage/activation.d.ts.map +1 -0
- package/dist/session/storage/activation.js +4 -0
- package/dist/session/storage/activation.js.map +1 -0
- package/dist/session/storage/create.d.ts +12 -0
- package/dist/session/storage/create.d.ts.map +1 -0
- package/dist/session/storage/create.js +115 -0
- package/dist/session/storage/create.js.map +1 -0
- package/dist/session/storage/events.d.ts +4 -0
- package/dist/session/storage/events.d.ts.map +1 -0
- package/dist/session/storage/events.js +119 -0
- package/dist/session/storage/events.js.map +1 -0
- package/dist/session/storage/queries.d.ts +5 -0
- package/dist/session/storage/queries.d.ts.map +1 -0
- package/dist/session/storage/queries.js +24 -0
- package/dist/session/storage/queries.js.map +1 -0
- package/dist/session/storage/request-digest.d.ts +4 -0
- package/dist/session/storage/request-digest.d.ts.map +1 -0
- package/dist/session/storage/request-digest.js +19 -0
- package/dist/session/storage/request-digest.js.map +1 -0
- package/dist/session/storage/runtime-profile.d.ts +15 -0
- package/dist/session/storage/runtime-profile.d.ts.map +1 -0
- package/dist/session/storage/runtime-profile.js +4 -0
- package/dist/session/storage/runtime-profile.js.map +1 -0
- package/dist/session/storage/session-record.d.ts +25 -0
- package/dist/session/storage/session-record.d.ts.map +1 -0
- package/dist/session/storage/session-record.js +53 -0
- package/dist/session/storage/session-record.js.map +1 -0
- package/dist/session/storage/testing/database.d.ts +13 -0
- package/dist/session/storage/testing/database.d.ts.map +1 -0
- package/dist/session/storage/testing/database.js +63 -0
- package/dist/session/storage/testing/database.js.map +1 -0
- package/dist/session/testing/activation-waiter.d.ts +7 -0
- package/dist/session/testing/activation-waiter.d.ts.map +1 -0
- package/dist/session/testing/activation-waiter.js +38 -0
- package/dist/session/testing/activation-waiter.js.map +1 -0
- package/dist/session/testing/built-session-bounded-capture.d.ts +15 -0
- package/dist/session/testing/built-session-bounded-capture.d.ts.map +1 -0
- package/dist/session/testing/built-session-bounded-capture.js +136 -0
- package/dist/session/testing/built-session-bounded-capture.js.map +1 -0
- package/dist/session/testing/built-session-cli-supervisor.d.ts +36 -0
- package/dist/session/testing/built-session-cli-supervisor.d.ts.map +1 -0
- package/dist/session/testing/built-session-cli-supervisor.js +52 -0
- package/dist/session/testing/built-session-cli-supervisor.js.map +1 -0
- package/dist/session/testing/built-session-execution-authenticator.d.ts +11 -0
- package/dist/session/testing/built-session-execution-authenticator.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-authenticator.js +33 -0
- package/dist/session/testing/built-session-execution-authenticator.js.map +1 -0
- package/dist/session/testing/built-session-execution-authority.d.ts +12 -0
- package/dist/session/testing/built-session-execution-authority.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-authority.js +1242 -0
- package/dist/session/testing/built-session-execution-authority.js.map +1 -0
- package/dist/session/testing/built-session-execution-budget.d.ts +29 -0
- package/dist/session/testing/built-session-execution-budget.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-budget.js +72 -0
- package/dist/session/testing/built-session-execution-budget.js.map +1 -0
- package/dist/session/testing/built-session-execution-contract.d.ts +64 -0
- package/dist/session/testing/built-session-execution-contract.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-contract.js +4 -0
- package/dist/session/testing/built-session-execution-contract.js.map +1 -0
- package/dist/session/testing/built-session-execution-failure.d.ts +32 -0
- package/dist/session/testing/built-session-execution-failure.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-failure.js +51 -0
- package/dist/session/testing/built-session-execution-failure.js.map +1 -0
- package/dist/session/testing/built-session-execution-handle.d.ts +29 -0
- package/dist/session/testing/built-session-execution-handle.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-handle.js +37 -0
- package/dist/session/testing/built-session-execution-handle.js.map +1 -0
- package/dist/session/testing/built-session-execution-input.d.ts +94 -0
- package/dist/session/testing/built-session-execution-input.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-input.js +356 -0
- package/dist/session/testing/built-session-execution-input.js.map +1 -0
- package/dist/session/testing/built-session-execution-lifecycle.d.ts +36 -0
- package/dist/session/testing/built-session-execution-lifecycle.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-lifecycle.js +143 -0
- package/dist/session/testing/built-session-execution-lifecycle.js.map +1 -0
- package/dist/session/testing/built-session-execution-policy.d.ts +67 -0
- package/dist/session/testing/built-session-execution-policy.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-policy.js +110 -0
- package/dist/session/testing/built-session-execution-policy.js.map +1 -0
- package/dist/session/testing/built-session-execution-private-types.d.ts +137 -0
- package/dist/session/testing/built-session-execution-private-types.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-private-types.js +2 -0
- package/dist/session/testing/built-session-execution-private-types.js.map +1 -0
- package/dist/session/testing/built-session-execution-projection.d.ts +177 -0
- package/dist/session/testing/built-session-execution-projection.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-projection.js +226 -0
- package/dist/session/testing/built-session-execution-projection.js.map +1 -0
- package/dist/session/testing/built-session-execution-provider.d.ts +36 -0
- package/dist/session/testing/built-session-execution-provider.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-provider.js +2 -0
- package/dist/session/testing/built-session-execution-provider.js.map +1 -0
- package/dist/session/testing/built-session-execution-receipt.d.ts +331 -0
- package/dist/session/testing/built-session-execution-receipt.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-receipt.js +243 -0
- package/dist/session/testing/built-session-execution-receipt.js.map +1 -0
- package/dist/session/testing/built-session-execution-record.d.ts +15 -0
- package/dist/session/testing/built-session-execution-record.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-record.js +27 -0
- package/dist/session/testing/built-session-execution-record.js.map +1 -0
- package/dist/session/testing/built-session-execution-snapshot.d.ts +83 -0
- package/dist/session/testing/built-session-execution-snapshot.d.ts.map +1 -0
- package/dist/session/testing/built-session-execution-snapshot.js +5 -0
- package/dist/session/testing/built-session-execution-snapshot.js.map +1 -0
- package/dist/session/testing/built-session-node.d.ts +110 -0
- package/dist/session/testing/built-session-node.d.ts.map +1 -0
- package/dist/session/testing/built-session-node.js +715 -0
- package/dist/session/testing/built-session-node.js.map +1 -0
- package/dist/session/testing/built-session-structural-gate.d.ts +40 -0
- package/dist/session/testing/built-session-structural-gate.d.ts.map +1 -0
- package/dist/session/testing/built-session-structural-gate.js +207 -0
- package/dist/session/testing/built-session-structural-gate.js.map +1 -0
- package/dist/session/testing/built-session-temporary-lifecycle.d.ts +35 -0
- package/dist/session/testing/built-session-temporary-lifecycle.d.ts.map +1 -0
- package/dist/session/testing/built-session-temporary-lifecycle.js +314 -0
- package/dist/session/testing/built-session-temporary-lifecycle.js.map +1 -0
- package/dist/session/testing/git-repository.d.ts +2 -0
- package/dist/session/testing/git-repository.d.ts.map +1 -0
- package/dist/session/testing/git-repository.js +29 -0
- package/dist/session/testing/git-repository.js.map +1 -0
- package/dist/session/testing/session-fixture.d.ts +7 -0
- package/dist/session/testing/session-fixture.d.ts.map +1 -0
- package/dist/session/testing/session-fixture.js +53 -0
- package/dist/session/testing/session-fixture.js.map +1 -0
- package/dist/session/turn/application/requests.d.ts +24 -0
- package/dist/session/turn/application/requests.d.ts.map +1 -0
- package/dist/session/turn/application/requests.js +164 -0
- package/dist/session/turn/application/requests.js.map +1 -0
- package/dist/session/turn/application/source-candidate-authority.d.ts +5 -0
- package/dist/session/turn/application/source-candidate-authority.d.ts.map +1 -0
- package/dist/session/turn/application/source-candidate-authority.js +4 -0
- package/dist/session/turn/application/source-candidate-authority.js.map +1 -0
- package/dist/session/turn/storage/interrupt.d.ts +74 -0
- package/dist/session/turn/storage/interrupt.d.ts.map +1 -0
- package/dist/session/turn/storage/interrupt.js +757 -0
- package/dist/session/turn/storage/interrupt.js.map +1 -0
- package/dist/session/turn/storage/lifecycle.d.ts +29 -0
- package/dist/session/turn/storage/lifecycle.d.ts.map +1 -0
- package/dist/session/turn/storage/lifecycle.js +310 -0
- package/dist/session/turn/storage/lifecycle.js.map +1 -0
- package/dist/session/turn/storage/queries.d.ts +4 -0
- package/dist/session/turn/storage/queries.d.ts.map +1 -0
- package/dist/session/turn/storage/queries.js +7 -0
- package/dist/session/turn/storage/queries.js.map +1 -0
- package/dist/session/turn/storage/record.d.ts +28 -0
- package/dist/session/turn/storage/record.d.ts.map +1 -0
- package/dist/session/turn/storage/record.js +84 -0
- package/dist/session/turn/storage/record.js.map +1 -0
- package/dist/session/turn/storage/request-digest.d.ts +8 -0
- package/dist/session/turn/storage/request-digest.d.ts.map +1 -0
- package/dist/session/turn/storage/request-digest.js +20 -0
- package/dist/session/turn/storage/request-digest.js.map +1 -0
- package/dist/session/turn/storage/send.d.ts +12 -0
- package/dist/session/turn/storage/send.d.ts.map +1 -0
- package/dist/session/turn/storage/send.js +149 -0
- package/dist/session/turn/storage/send.js.map +1 -0
- package/dist/storage/database-files.d.ts +6 -0
- package/dist/storage/database-files.d.ts.map +1 -0
- package/dist/storage/database-files.js +146 -0
- package/dist/storage/database-files.js.map +1 -0
- package/dist/storage/integration-authorization-operations.d.ts +7 -0
- package/dist/storage/integration-authorization-operations.d.ts.map +1 -0
- package/dist/storage/integration-authorization-operations.js +134 -0
- package/dist/storage/integration-authorization-operations.js.map +1 -0
- package/dist/storage/journal.d.ts +108 -0
- package/dist/storage/journal.d.ts.map +1 -0
- package/dist/storage/journal.js +459 -0
- package/dist/storage/journal.js.map +1 -0
- package/dist/storage/migration-eleven.d.ts +2 -0
- package/dist/storage/migration-eleven.d.ts.map +1 -0
- package/dist/storage/migration-eleven.js +298 -0
- package/dist/storage/migration-eleven.js.map +1 -0
- package/dist/storage/migration-fourteen.d.ts +2 -0
- package/dist/storage/migration-fourteen.d.ts.map +1 -0
- package/dist/storage/migration-fourteen.js +316 -0
- package/dist/storage/migration-fourteen.js.map +1 -0
- package/dist/storage/migration-nine.d.ts +2 -0
- package/dist/storage/migration-nine.d.ts.map +1 -0
- package/dist/storage/migration-nine.js +1224 -0
- package/dist/storage/migration-nine.js.map +1 -0
- package/dist/storage/migration-ten.d.ts +2 -0
- package/dist/storage/migration-ten.d.ts.map +1 -0
- package/dist/storage/migration-ten.js +14 -0
- package/dist/storage/migration-ten.js.map +1 -0
- package/dist/storage/migration-thirteen.d.ts +2 -0
- package/dist/storage/migration-thirteen.d.ts.map +1 -0
- package/dist/storage/migration-thirteen.js +380 -0
- package/dist/storage/migration-thirteen.js.map +1 -0
- package/dist/storage/migration-twelve.d.ts +2 -0
- package/dist/storage/migration-twelve.d.ts.map +1 -0
- package/dist/storage/migration-twelve.js +85 -0
- package/dist/storage/migration-twelve.js.map +1 -0
- package/dist/storage/migrations.d.ts +20 -0
- package/dist/storage/migrations.d.ts.map +1 -0
- package/dist/storage/migrations.js +909 -0
- package/dist/storage/migrations.js.map +1 -0
- package/dist/storage/node-database.d.ts +282 -0
- package/dist/storage/node-database.d.ts.map +1 -0
- package/dist/storage/node-database.js +448 -0
- package/dist/storage/node-database.js.map +1 -0
- package/dist/storage/pi-rpc-authorization-operations.d.ts +91 -0
- package/dist/storage/pi-rpc-authorization-operations.d.ts.map +1 -0
- package/dist/storage/pi-rpc-authorization-operations.js +136 -0
- package/dist/storage/pi-rpc-authorization-operations.js.map +1 -0
- package/dist/storage/policy.d.ts +8 -0
- package/dist/storage/policy.d.ts.map +1 -0
- package/dist/storage/policy.js +8 -0
- package/dist/storage/policy.js.map +1 -0
- package/dist/storage/sqlite-integer.d.ts +3 -0
- package/dist/storage/sqlite-integer.d.ts.map +1 -0
- package/dist/storage/sqlite-integer.js +25 -0
- package/dist/storage/sqlite-integer.js.map +1 -0
- package/dist/storage/store-effect.d.ts +5 -0
- package/dist/storage/store-effect.d.ts.map +1 -0
- package/dist/storage/store-effect.js +15 -0
- package/dist/storage/store-effect.js.map +1 -0
- package/dist/terminal/application/live-requests.d.ts +18 -0
- package/dist/terminal/application/live-requests.d.ts.map +1 -0
- package/dist/terminal/application/live-requests.js +24 -0
- package/dist/terminal/application/live-requests.js.map +1 -0
- package/dist/terminal/application/requests.d.ts +10 -0
- package/dist/terminal/application/requests.d.ts.map +1 -0
- package/dist/terminal/application/requests.js +50 -0
- package/dist/terminal/application/requests.js.map +1 -0
- package/dist/terminal/live-launch.d.ts +16 -0
- package/dist/terminal/live-launch.d.ts.map +1 -0
- package/dist/terminal/live-launch.js +213 -0
- package/dist/terminal/live-launch.js.map +1 -0
- package/dist/terminal/live-lifecycle.d.ts +104 -0
- package/dist/terminal/live-lifecycle.d.ts.map +1 -0
- package/dist/terminal/live-lifecycle.js +185 -0
- package/dist/terminal/live-lifecycle.js.map +1 -0
- package/dist/terminal/live-native-control.d.ts +7 -0
- package/dist/terminal/live-native-control.d.ts.map +1 -0
- package/dist/terminal/live-native-control.js +233 -0
- package/dist/terminal/live-native-control.js.map +1 -0
- package/dist/terminal/live-runtime-state.d.ts +69 -0
- package/dist/terminal/live-runtime-state.d.ts.map +1 -0
- package/dist/terminal/live-runtime-state.js +75 -0
- package/dist/terminal/live-runtime-state.js.map +1 -0
- package/dist/terminal/live-service.d.ts +29 -0
- package/dist/terminal/live-service.d.ts.map +1 -0
- package/dist/terminal/live-service.js +79 -0
- package/dist/terminal/live-service.js.map +1 -0
- package/dist/terminal/live-supervision.d.ts +19 -0
- package/dist/terminal/live-supervision.d.ts.map +1 -0
- package/dist/terminal/live-supervision.js +78 -0
- package/dist/terminal/live-supervision.js.map +1 -0
- package/dist/terminal/storage/create.d.ts +23 -0
- package/dist/terminal/storage/create.d.ts.map +1 -0
- package/dist/terminal/storage/create.js +151 -0
- package/dist/terminal/storage/create.js.map +1 -0
- package/dist/terminal/storage/events.d.ts +4 -0
- package/dist/terminal/storage/events.d.ts.map +1 -0
- package/dist/terminal/storage/events.js +151 -0
- package/dist/terminal/storage/events.js.map +1 -0
- package/dist/terminal/storage/live-command-shared.d.ts +39 -0
- package/dist/terminal/storage/live-command-shared.d.ts.map +1 -0
- package/dist/terminal/storage/live-command-shared.js +142 -0
- package/dist/terminal/storage/live-command-shared.js.map +1 -0
- package/dist/terminal/storage/live-commands.d.ts +7 -0
- package/dist/terminal/storage/live-commands.d.ts.map +1 -0
- package/dist/terminal/storage/live-commands.js +7 -0
- package/dist/terminal/storage/live-commands.js.map +1 -0
- package/dist/terminal/storage/live-controller-commands.d.ts +4 -0
- package/dist/terminal/storage/live-controller-commands.d.ts.map +1 -0
- package/dist/terminal/storage/live-controller-commands.js +4 -0
- package/dist/terminal/storage/live-controller-commands.js.map +1 -0
- package/dist/terminal/storage/live-controller-lease.d.ts +17 -0
- package/dist/terminal/storage/live-controller-lease.d.ts.map +1 -0
- package/dist/terminal/storage/live-controller-lease.js +316 -0
- package/dist/terminal/storage/live-controller-lease.js.map +1 -0
- package/dist/terminal/storage/live-controller-policy.d.ts +44 -0
- package/dist/terminal/storage/live-controller-policy.d.ts.map +1 -0
- package/dist/terminal/storage/live-controller-policy.js +135 -0
- package/dist/terminal/storage/live-controller-policy.js.map +1 -0
- package/dist/terminal/storage/live-controller-request.d.ts +15 -0
- package/dist/terminal/storage/live-controller-request.d.ts.map +1 -0
- package/dist/terminal/storage/live-controller-request.js +166 -0
- package/dist/terminal/storage/live-controller-request.js.map +1 -0
- package/dist/terminal/storage/live-controller-shared.d.ts +40 -0
- package/dist/terminal/storage/live-controller-shared.d.ts.map +1 -0
- package/dist/terminal/storage/live-controller-shared.js +74 -0
- package/dist/terminal/storage/live-controller-shared.js.map +1 -0
- package/dist/terminal/storage/live-create-commands.d.ts +21 -0
- package/dist/terminal/storage/live-create-commands.d.ts.map +1 -0
- package/dist/terminal/storage/live-create-commands.js +227 -0
- package/dist/terminal/storage/live-create-commands.js.map +1 -0
- package/dist/terminal/storage/live-launch-context.d.ts +17 -0
- package/dist/terminal/storage/live-launch-context.d.ts.map +1 -0
- package/dist/terminal/storage/live-launch-context.js +44 -0
- package/dist/terminal/storage/live-launch-context.js.map +1 -0
- package/dist/terminal/storage/live-mutations.d.ts +65 -0
- package/dist/terminal/storage/live-mutations.d.ts.map +1 -0
- package/dist/terminal/storage/live-mutations.js +291 -0
- package/dist/terminal/storage/live-mutations.js.map +1 -0
- package/dist/terminal/storage/live-native-commands.d.ts +77 -0
- package/dist/terminal/storage/live-native-commands.d.ts.map +1 -0
- package/dist/terminal/storage/live-native-commands.js +728 -0
- package/dist/terminal/storage/live-native-commands.js.map +1 -0
- package/dist/terminal/storage/live-process-settlement.d.ts +30 -0
- package/dist/terminal/storage/live-process-settlement.d.ts.map +1 -0
- package/dist/terminal/storage/live-process-settlement.js +159 -0
- package/dist/terminal/storage/live-process-settlement.js.map +1 -0
- package/dist/terminal/storage/live-record.d.ts +36 -0
- package/dist/terminal/storage/live-record.d.ts.map +1 -0
- package/dist/terminal/storage/live-record.js +153 -0
- package/dist/terminal/storage/live-record.js.map +1 -0
- package/dist/terminal/storage/live-recovery.d.ts +6 -0
- package/dist/terminal/storage/live-recovery.d.ts.map +1 -0
- package/dist/terminal/storage/live-recovery.js +539 -0
- package/dist/terminal/storage/live-recovery.js.map +1 -0
- package/dist/terminal/storage/live-retention.d.ts +46 -0
- package/dist/terminal/storage/live-retention.d.ts.map +1 -0
- package/dist/terminal/storage/live-retention.js +362 -0
- package/dist/terminal/storage/live-retention.js.map +1 -0
- package/dist/terminal/storage/queries.d.ts +6 -0
- package/dist/terminal/storage/queries.d.ts.map +1 -0
- package/dist/terminal/storage/queries.js +85 -0
- package/dist/terminal/storage/queries.js.map +1 -0
- package/dist/terminal/storage/record.d.ts +29 -0
- package/dist/terminal/storage/record.d.ts.map +1 -0
- package/dist/terminal/storage/record.js +87 -0
- package/dist/terminal/storage/record.js.map +1 -0
- package/dist/terminal/storage/request-digest.d.ts +3 -0
- package/dist/terminal/storage/request-digest.d.ts.map +1 -0
- package/dist/terminal/storage/request-digest.js +10 -0
- package/dist/terminal/storage/request-digest.js.map +1 -0
- package/dist/terminal/storage/sqlite-counter.d.ts +4 -0
- package/dist/terminal/storage/sqlite-counter.d.ts.map +1 -0
- package/dist/terminal/storage/sqlite-counter.js +15 -0
- package/dist/terminal/storage/sqlite-counter.js.map +1 -0
- package/package.json +70 -0
|
@@ -0,0 +1,1214 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
import { createHash, randomUUID } from "node:crypto";
|
|
3
|
+
import { inspectOrchestrationRunCreateAdmission, MAX_ORCHESTRATION_CHECK_RESULT_BYTES, MAX_ORCHESTRATION_DELIVERIES_PER_MAILBOX, MAX_ORCHESTRATION_DELIVERY_ATTEMPTS, MAX_ORCHESTRATION_DISPATCH_SHOW_RESULT_BYTES, MAX_ORCHESTRATION_LIST_RESULT_BYTES, MAX_ORCHESTRATION_MAILBOX_CONTENT_BYTES, MAX_ORCHESTRATION_RUN_MESSAGE_CONTENT_BYTES, MAX_ORCHESTRATION_TASK_LIST_RESULT_BYTES, MAX_ORCHESTRATION_TASK_SHOW_RESULT_BYTES, ORCHESTRATION_MESSAGE_SCHEMA_VERSION, ORCHESTRATION_SCHEMA_VERSION, orchestrationAggregateSchema, orchestrationDeliverySchema, orchestrationDispatchShowParametersSchema, orchestrationDispatchShowResultSchema, orchestrationInboxAckResultSchema, orchestrationInboxCheckResultSchema, orchestrationMailboxSchema, orchestrationRunCreateParametersSchema, orchestrationRunCreateResultSchema, orchestrationRunListParametersSchema, orchestrationRunListResultSchema, orchestrationRunShowResultSchema, orchestrationTaskListParametersSchema, orchestrationTaskListResultSchema, orchestrationTaskShowParametersSchema, orchestrationTaskShowResultSchema, } from "@maiaos/protocol";
|
|
4
|
+
import { Schema } from "effect";
|
|
5
|
+
import { commandReceiptFromPersisted } from "../command-receipt/storage/codec.js";
|
|
6
|
+
import { makeNodeRuntimeError, NodeRuntimeError } from "../runtime/errors.js";
|
|
7
|
+
import { commitCommandWithMutation, commitIdempotentCommandReceipt, findPersistedCommand, } from "../storage/journal.js";
|
|
8
|
+
import { advanceSignedSqliteInteger } from "../storage/sqlite-integer.js";
|
|
9
|
+
export const ORCHESTRATION_RUN_AGGREGATE_TYPE = "orchestration-run";
|
|
10
|
+
export const ORCHESTRATION_MAILBOX_AGGREGATE_TYPE = "orchestration-mailbox";
|
|
11
|
+
const LOCAL_USER_ACTOR_ID = "actor_local_user";
|
|
12
|
+
export const id = (prefix) => `${prefix}_${randomUUID().replaceAll("-", "")}`;
|
|
13
|
+
export const requireLocalCoordinatorActor = (actorId) => {
|
|
14
|
+
if (actorId !== LOCAL_USER_ACTOR_ID) {
|
|
15
|
+
throw makeNodeRuntimeError("authentication_failed", "Only the authenticated local Run coordinator may mutate orchestration state.");
|
|
16
|
+
}
|
|
17
|
+
};
|
|
18
|
+
export const statementWithBigInts = (database, sql) => {
|
|
19
|
+
const statement = database.prepare(sql);
|
|
20
|
+
statement.setReadBigInts(true);
|
|
21
|
+
return statement;
|
|
22
|
+
};
|
|
23
|
+
const runRowSchema = Schema.Struct({
|
|
24
|
+
coordinatorActorId: Schema.String,
|
|
25
|
+
coordinatorEpoch: Schema.BigInt,
|
|
26
|
+
createdAt: Schema.String,
|
|
27
|
+
dispatchTaskId: Schema.String,
|
|
28
|
+
id: Schema.String,
|
|
29
|
+
messageContentBytes: Schema.BigInt,
|
|
30
|
+
revision: Schema.BigInt,
|
|
31
|
+
rootTaskId: Schema.String,
|
|
32
|
+
state: Schema.String,
|
|
33
|
+
terminalId: Schema.String,
|
|
34
|
+
updatedAt: Schema.String,
|
|
35
|
+
workspaceId: Schema.String,
|
|
36
|
+
});
|
|
37
|
+
const decodeRunRow = Schema.decodeUnknownSync(runRowSchema);
|
|
38
|
+
const taskRowSchema = Schema.Struct({
|
|
39
|
+
clientKey: Schema.String,
|
|
40
|
+
createdAt: Schema.String,
|
|
41
|
+
id: Schema.String,
|
|
42
|
+
objective: Schema.String,
|
|
43
|
+
revision: Schema.BigInt,
|
|
44
|
+
runId: Schema.String,
|
|
45
|
+
state: Schema.String,
|
|
46
|
+
updatedAt: Schema.String,
|
|
47
|
+
workspaceId: Schema.String,
|
|
48
|
+
});
|
|
49
|
+
const decodeTaskRow = Schema.decodeUnknownSync(taskRowSchema);
|
|
50
|
+
const taskDependencyRowSchema = Schema.Struct({
|
|
51
|
+
dependencyTaskId: Schema.String,
|
|
52
|
+
taskId: Schema.String,
|
|
53
|
+
});
|
|
54
|
+
const decodeTaskDependencyRow = Schema.decodeUnknownSync(taskDependencyRowSchema);
|
|
55
|
+
const attemptRowSchema = Schema.Struct({
|
|
56
|
+
createdAt: Schema.String,
|
|
57
|
+
id: Schema.String,
|
|
58
|
+
ordinal: Schema.BigInt,
|
|
59
|
+
revision: Schema.BigInt,
|
|
60
|
+
runId: Schema.String,
|
|
61
|
+
state: Schema.String,
|
|
62
|
+
taskId: Schema.String,
|
|
63
|
+
updatedAt: Schema.String,
|
|
64
|
+
});
|
|
65
|
+
const decodeAttemptRow = Schema.decodeUnknownSync(attemptRowSchema);
|
|
66
|
+
const dispatchRowSchema = Schema.Struct({
|
|
67
|
+
attemptId: Schema.String,
|
|
68
|
+
createdAt: Schema.String,
|
|
69
|
+
failureCode: Schema.NullOr(Schema.String),
|
|
70
|
+
failurePlatform: Schema.NullOr(Schema.String),
|
|
71
|
+
id: Schema.String,
|
|
72
|
+
revision: Schema.BigInt,
|
|
73
|
+
runId: Schema.String,
|
|
74
|
+
state: Schema.String,
|
|
75
|
+
taskId: Schema.String,
|
|
76
|
+
terminalId: Schema.String,
|
|
77
|
+
updatedAt: Schema.String,
|
|
78
|
+
});
|
|
79
|
+
const decodeDispatchRow = Schema.decodeUnknownSync(dispatchRowSchema);
|
|
80
|
+
const mailboxRowSchema = Schema.Struct({
|
|
81
|
+
contentBytes: Schema.BigInt,
|
|
82
|
+
createdAt: Schema.String,
|
|
83
|
+
deliveryCount: Schema.BigInt,
|
|
84
|
+
headSequence: Schema.BigInt,
|
|
85
|
+
id: Schema.String,
|
|
86
|
+
ownerId: Schema.String,
|
|
87
|
+
ownerKind: Schema.String,
|
|
88
|
+
revision: Schema.BigInt,
|
|
89
|
+
runId: Schema.String,
|
|
90
|
+
updatedAt: Schema.String,
|
|
91
|
+
});
|
|
92
|
+
const decodeMailboxRow = Schema.decodeUnknownSync(mailboxRowSchema);
|
|
93
|
+
const questionRowSchema = Schema.Struct({
|
|
94
|
+
answer: Schema.NullOr(Schema.String),
|
|
95
|
+
askMessageId: Schema.String,
|
|
96
|
+
attemptId: Schema.String,
|
|
97
|
+
body: Schema.String,
|
|
98
|
+
createdAt: Schema.String,
|
|
99
|
+
dispatchId: Schema.String,
|
|
100
|
+
id: Schema.String,
|
|
101
|
+
replyMessageId: Schema.NullOr(Schema.String),
|
|
102
|
+
revision: Schema.BigInt,
|
|
103
|
+
runId: Schema.String,
|
|
104
|
+
state: Schema.String,
|
|
105
|
+
subject: Schema.String,
|
|
106
|
+
taskId: Schema.String,
|
|
107
|
+
updatedAt: Schema.String,
|
|
108
|
+
});
|
|
109
|
+
export const decodeQuestionRow = Schema.decodeUnknownSync(questionRowSchema);
|
|
110
|
+
const deliveryRowSchema = Schema.Struct({
|
|
111
|
+
acknowledgedAt: Schema.NullOr(Schema.String),
|
|
112
|
+
acknowledgingActorId: Schema.NullOr(Schema.String),
|
|
113
|
+
attemptCount: Schema.BigInt,
|
|
114
|
+
body: Schema.String,
|
|
115
|
+
createdAt: Schema.String,
|
|
116
|
+
digest: Schema.String,
|
|
117
|
+
firstDeliveredAt: Schema.NullOr(Schema.String),
|
|
118
|
+
id: Schema.String,
|
|
119
|
+
lastDeliveredAt: Schema.NullOr(Schema.String),
|
|
120
|
+
mailboxId: Schema.String,
|
|
121
|
+
messageCreatedAt: Schema.String,
|
|
122
|
+
messageId: Schema.String,
|
|
123
|
+
messageType: Schema.String,
|
|
124
|
+
questionId: Schema.NullOr(Schema.String),
|
|
125
|
+
recipientId: Schema.String,
|
|
126
|
+
recipientKind: Schema.String,
|
|
127
|
+
runId: Schema.String,
|
|
128
|
+
senderActorId: Schema.String,
|
|
129
|
+
senderKind: Schema.String,
|
|
130
|
+
senderRunId: Schema.String,
|
|
131
|
+
sequence: Schema.BigInt,
|
|
132
|
+
state: Schema.String,
|
|
133
|
+
subject: Schema.String,
|
|
134
|
+
});
|
|
135
|
+
const decodeDeliveryRow = Schema.decodeUnknownSync(deliveryRowSchema);
|
|
136
|
+
const terminalAuthorityRowSchema = Schema.Struct({
|
|
137
|
+
code: Schema.String,
|
|
138
|
+
platform: Schema.String,
|
|
139
|
+
revision: Schema.BigInt,
|
|
140
|
+
state: Schema.String,
|
|
141
|
+
workspaceId: Schema.String,
|
|
142
|
+
workspaceRevision: Schema.BigInt,
|
|
143
|
+
});
|
|
144
|
+
const decodeTerminalAuthorityRow = Schema.decodeUnknownSync(terminalAuthorityRowSchema);
|
|
145
|
+
export const readRunRow = (database, runId) => {
|
|
146
|
+
const row = statementWithBigInts(database, `SELECT run_id AS id, workspace_id AS workspaceId,
|
|
147
|
+
terminal_id AS terminalId, root_task_id AS rootTaskId,
|
|
148
|
+
dispatch_task_id AS dispatchTaskId,
|
|
149
|
+
coordinator_actor_id AS coordinatorActorId,
|
|
150
|
+
coordinator_epoch AS coordinatorEpoch, state, revision,
|
|
151
|
+
message_content_bytes AS messageContentBytes,
|
|
152
|
+
created_at AS createdAt, updated_at AS updatedAt
|
|
153
|
+
FROM orchestration_runs WHERE run_id = ?`).get(runId);
|
|
154
|
+
if (row === undefined) {
|
|
155
|
+
throw makeNodeRuntimeError("resource_not_found", "The Run was not found.");
|
|
156
|
+
}
|
|
157
|
+
return decodeRunRow(row);
|
|
158
|
+
};
|
|
159
|
+
export const readTaskRows = (database, runId) => statementWithBigInts(database, `SELECT task_id AS id, run_id AS runId, client_key AS clientKey,
|
|
160
|
+
workspace_id AS workspaceId, objective, state, revision,
|
|
161
|
+
created_at AS createdAt, updated_at AS updatedAt
|
|
162
|
+
FROM orchestration_tasks WHERE run_id = ? ORDER BY sequence`)
|
|
163
|
+
.all(runId)
|
|
164
|
+
.map((row) => decodeTaskRow(row));
|
|
165
|
+
export const readAttemptRow = (database, runId) => {
|
|
166
|
+
const row = statementWithBigInts(database, `SELECT attempt_id AS id, run_id AS runId, task_id AS taskId,
|
|
167
|
+
ordinal, state, revision, created_at AS createdAt, updated_at AS updatedAt
|
|
168
|
+
FROM orchestration_attempts WHERE run_id = ?`).get(runId);
|
|
169
|
+
if (row === undefined) {
|
|
170
|
+
throw makeNodeRuntimeError("storage_corrupt", "The Run Attempt is missing.");
|
|
171
|
+
}
|
|
172
|
+
return decodeAttemptRow(row);
|
|
173
|
+
};
|
|
174
|
+
export const readDispatchRow = (database, runId) => {
|
|
175
|
+
const row = statementWithBigInts(database, `SELECT dispatch_id AS id, run_id AS runId, task_id AS taskId,
|
|
176
|
+
attempt_id AS attemptId, terminal_id AS terminalId, state,
|
|
177
|
+
failure_code AS failureCode, failure_platform AS failurePlatform,
|
|
178
|
+
revision, created_at AS createdAt, updated_at AS updatedAt
|
|
179
|
+
FROM orchestration_dispatches WHERE run_id = ?`).get(runId);
|
|
180
|
+
if (row === undefined) {
|
|
181
|
+
throw makeNodeRuntimeError("storage_corrupt", "The Run Dispatch is missing.");
|
|
182
|
+
}
|
|
183
|
+
return decodeDispatchRow(row);
|
|
184
|
+
};
|
|
185
|
+
const readMailboxRows = (database, runId) => statementWithBigInts(database, `SELECT mailbox_id AS id, run_id AS runId, owner_kind AS ownerKind,
|
|
186
|
+
owner_id AS ownerId, head_sequence AS headSequence,
|
|
187
|
+
delivery_count AS deliveryCount, content_bytes AS contentBytes,
|
|
188
|
+
revision, created_at AS createdAt, updated_at AS updatedAt
|
|
189
|
+
FROM orchestration_mailboxes WHERE run_id = ? ORDER BY sequence`)
|
|
190
|
+
.all(runId)
|
|
191
|
+
.map((row) => decodeMailboxRow(row));
|
|
192
|
+
const readQuestionRow = (database, runId) => {
|
|
193
|
+
const row = statementWithBigInts(database, `SELECT question_id AS id, run_id AS runId, task_id AS taskId,
|
|
194
|
+
attempt_id AS attemptId, dispatch_id AS dispatchId,
|
|
195
|
+
ask_message_id AS askMessageId, reply_message_id AS replyMessageId,
|
|
196
|
+
subject, body, answer, state, revision,
|
|
197
|
+
created_at AS createdAt, updated_at AS updatedAt
|
|
198
|
+
FROM orchestration_questions WHERE run_id = ?
|
|
199
|
+
ORDER BY sequence DESC LIMIT 1`).get(runId);
|
|
200
|
+
return row === undefined ? undefined : decodeQuestionRow(row);
|
|
201
|
+
};
|
|
202
|
+
const mailboxFromRow = (row) => orchestrationMailboxSchema.parse({
|
|
203
|
+
contentBytes: row.contentBytes.toString(),
|
|
204
|
+
createdAt: row.createdAt,
|
|
205
|
+
deliveryCount: row.deliveryCount.toString(),
|
|
206
|
+
headSequence: row.headSequence.toString(),
|
|
207
|
+
id: row.id,
|
|
208
|
+
owner: { id: row.ownerId, kind: row.ownerKind },
|
|
209
|
+
revision: row.revision.toString(),
|
|
210
|
+
runId: row.runId,
|
|
211
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
212
|
+
updatedAt: row.updatedAt,
|
|
213
|
+
});
|
|
214
|
+
const readDependencyTaskIdsByTask = (database, runId) => {
|
|
215
|
+
const rows = database
|
|
216
|
+
.prepare(`SELECT d.task_id AS taskId, d.dependency_task_id AS dependencyTaskId
|
|
217
|
+
FROM orchestration_task_dependencies d
|
|
218
|
+
JOIN orchestration_tasks t
|
|
219
|
+
ON t.run_id = d.run_id AND t.task_id = d.task_id
|
|
220
|
+
WHERE d.run_id = ?
|
|
221
|
+
ORDER BY t.sequence, d.position`)
|
|
222
|
+
.all(runId)
|
|
223
|
+
.map((row) => decodeTaskDependencyRow(row));
|
|
224
|
+
return rows.reduce((grouped, row) => {
|
|
225
|
+
const dependencyTaskIds = grouped.get(row.taskId) ?? [];
|
|
226
|
+
dependencyTaskIds.push(row.dependencyTaskId);
|
|
227
|
+
grouped.set(row.taskId, dependencyTaskIds);
|
|
228
|
+
return grouped;
|
|
229
|
+
}, new Map());
|
|
230
|
+
};
|
|
231
|
+
const attemptFromRow = (attempt) => ({
|
|
232
|
+
createdAt: attempt.createdAt,
|
|
233
|
+
id: attempt.id,
|
|
234
|
+
ordinal: Number(attempt.ordinal),
|
|
235
|
+
revision: attempt.revision.toString(),
|
|
236
|
+
runId: attempt.runId,
|
|
237
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
238
|
+
state: attempt.state,
|
|
239
|
+
taskId: attempt.taskId,
|
|
240
|
+
updatedAt: attempt.updatedAt,
|
|
241
|
+
});
|
|
242
|
+
const dispatchFromRow = (dispatch) => ({
|
|
243
|
+
attemptId: dispatch.attemptId,
|
|
244
|
+
createdAt: dispatch.createdAt,
|
|
245
|
+
...(dispatch.failureCode === null || dispatch.failurePlatform === null
|
|
246
|
+
? {}
|
|
247
|
+
: {
|
|
248
|
+
failure: {
|
|
249
|
+
code: dispatch.failureCode,
|
|
250
|
+
platform: dispatch.failurePlatform,
|
|
251
|
+
},
|
|
252
|
+
}),
|
|
253
|
+
id: dispatch.id,
|
|
254
|
+
revision: dispatch.revision.toString(),
|
|
255
|
+
runId: dispatch.runId,
|
|
256
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
257
|
+
state: dispatch.state,
|
|
258
|
+
taskId: dispatch.taskId,
|
|
259
|
+
terminalId: dispatch.terminalId,
|
|
260
|
+
updatedAt: dispatch.updatedAt,
|
|
261
|
+
});
|
|
262
|
+
const questionFromRow = (question) => ({
|
|
263
|
+
...(question.answer === null ? {} : { answer: question.answer }),
|
|
264
|
+
askMessageId: question.askMessageId,
|
|
265
|
+
attemptId: question.attemptId,
|
|
266
|
+
body: question.body,
|
|
267
|
+
createdAt: question.createdAt,
|
|
268
|
+
dispatchId: question.dispatchId,
|
|
269
|
+
id: question.id,
|
|
270
|
+
...(question.replyMessageId === null
|
|
271
|
+
? {}
|
|
272
|
+
: { replyMessageId: question.replyMessageId }),
|
|
273
|
+
revision: question.revision.toString(),
|
|
274
|
+
runId: question.runId,
|
|
275
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
276
|
+
state: question.state,
|
|
277
|
+
subject: question.subject,
|
|
278
|
+
taskId: question.taskId,
|
|
279
|
+
updatedAt: question.updatedAt,
|
|
280
|
+
});
|
|
281
|
+
const runFromRow = (run) => ({
|
|
282
|
+
coordinator: {
|
|
283
|
+
actorId: run.coordinatorActorId,
|
|
284
|
+
epoch: Number(run.coordinatorEpoch),
|
|
285
|
+
},
|
|
286
|
+
createdAt: run.createdAt,
|
|
287
|
+
dispatchTaskId: run.dispatchTaskId,
|
|
288
|
+
id: run.id,
|
|
289
|
+
revision: run.revision.toString(),
|
|
290
|
+
rootTaskId: run.rootTaskId,
|
|
291
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
292
|
+
state: run.state,
|
|
293
|
+
terminalId: run.terminalId,
|
|
294
|
+
updatedAt: run.updatedAt,
|
|
295
|
+
workspaceId: run.workspaceId,
|
|
296
|
+
});
|
|
297
|
+
const taskFromRow = (task, dependencyTaskIdsByTask) => ({
|
|
298
|
+
clientKey: task.clientKey,
|
|
299
|
+
createdAt: task.createdAt,
|
|
300
|
+
dependencyTaskIds: dependencyTaskIdsByTask.get(task.id) ?? [],
|
|
301
|
+
id: task.id,
|
|
302
|
+
objective: task.objective,
|
|
303
|
+
revision: task.revision.toString(),
|
|
304
|
+
runId: task.runId,
|
|
305
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
306
|
+
state: task.state,
|
|
307
|
+
updatedAt: task.updatedAt,
|
|
308
|
+
workspaceId: task.workspaceId,
|
|
309
|
+
});
|
|
310
|
+
const readOrchestrationAggregateUnchecked = (database, runId) => {
|
|
311
|
+
const question = readQuestionRow(database, runId);
|
|
312
|
+
const dependencies = readDependencyTaskIdsByTask(database, runId);
|
|
313
|
+
return orchestrationAggregateSchema.parse({
|
|
314
|
+
attempt: attemptFromRow(readAttemptRow(database, runId)),
|
|
315
|
+
dispatch: dispatchFromRow(readDispatchRow(database, runId)),
|
|
316
|
+
mailboxes: readMailboxRows(database, runId).map(mailboxFromRow),
|
|
317
|
+
...(question === undefined ? {} : { question: questionFromRow(question) }),
|
|
318
|
+
run: runFromRow(readRunRow(database, runId)),
|
|
319
|
+
tasks: readTaskRows(database, runId).map((task) => taskFromRow(task, dependencies)),
|
|
320
|
+
});
|
|
321
|
+
};
|
|
322
|
+
export const readOrchestrationAggregate = (database, runId) => {
|
|
323
|
+
try {
|
|
324
|
+
return readOrchestrationAggregateUnchecked(database, runId);
|
|
325
|
+
}
|
|
326
|
+
catch (error) {
|
|
327
|
+
if (error instanceof NodeRuntimeError)
|
|
328
|
+
throw error;
|
|
329
|
+
throw makeNodeRuntimeError("storage_corrupt", "The persisted orchestration Run is invalid.");
|
|
330
|
+
}
|
|
331
|
+
};
|
|
332
|
+
const deliverySelect = `SELECT d.delivery_id AS id, d.mailbox_id AS mailboxId,
|
|
333
|
+
d.mailbox_sequence AS sequence, d.state, d.attempt_count AS attemptCount,
|
|
334
|
+
d.first_delivered_at AS firstDeliveredAt,
|
|
335
|
+
d.last_delivered_at AS lastDeliveredAt,
|
|
336
|
+
d.acknowledging_actor_id AS acknowledgingActorId,
|
|
337
|
+
d.acknowledged_at AS acknowledgedAt, d.created_at AS createdAt,
|
|
338
|
+
m.message_id AS messageId, m.run_id AS runId,
|
|
339
|
+
m.sender_kind AS senderKind, m.sender_run_id AS senderRunId,
|
|
340
|
+
m.sender_actor_id AS senderActorId,
|
|
341
|
+
m.recipient_kind AS recipientKind, m.recipient_id AS recipientId,
|
|
342
|
+
m.message_type AS messageType, m.subject, m.body,
|
|
343
|
+
m.question_id AS questionId, m.content_digest AS digest,
|
|
344
|
+
m.created_at AS messageCreatedAt
|
|
345
|
+
FROM orchestration_deliveries d
|
|
346
|
+
JOIN orchestration_messages m ON m.message_id = d.message_id`;
|
|
347
|
+
const deliveryMessageFromRow = (row) => ({
|
|
348
|
+
body: row.body,
|
|
349
|
+
createdAt: row.messageCreatedAt,
|
|
350
|
+
digest: row.digest,
|
|
351
|
+
id: row.messageId,
|
|
352
|
+
...(row.questionId === null ? {} : { questionId: row.questionId }),
|
|
353
|
+
recipient: { id: row.recipientId, kind: row.recipientKind },
|
|
354
|
+
runId: row.runId,
|
|
355
|
+
schemaVersion: ORCHESTRATION_MESSAGE_SCHEMA_VERSION,
|
|
356
|
+
sender: {
|
|
357
|
+
actorId: row.senderActorId,
|
|
358
|
+
kind: row.senderKind,
|
|
359
|
+
runId: row.senderRunId,
|
|
360
|
+
},
|
|
361
|
+
subject: row.subject,
|
|
362
|
+
type: row.messageType,
|
|
363
|
+
});
|
|
364
|
+
const deliveryFromRow = (row) => orchestrationDeliverySchema.parse({
|
|
365
|
+
...(row.acknowledgedAt === null
|
|
366
|
+
? {}
|
|
367
|
+
: { acknowledgedAt: row.acknowledgedAt }),
|
|
368
|
+
...(row.acknowledgingActorId === null
|
|
369
|
+
? {}
|
|
370
|
+
: { acknowledgingActorId: row.acknowledgingActorId }),
|
|
371
|
+
attemptCount: Number(row.attemptCount),
|
|
372
|
+
createdAt: row.createdAt,
|
|
373
|
+
...(row.firstDeliveredAt === null
|
|
374
|
+
? {}
|
|
375
|
+
: { firstDeliveredAt: row.firstDeliveredAt }),
|
|
376
|
+
id: row.id,
|
|
377
|
+
...(row.lastDeliveredAt === null
|
|
378
|
+
? {}
|
|
379
|
+
: { lastDeliveredAt: row.lastDeliveredAt }),
|
|
380
|
+
mailboxId: row.mailboxId,
|
|
381
|
+
message: deliveryMessageFromRow(row),
|
|
382
|
+
sequence: row.sequence.toString(),
|
|
383
|
+
state: row.state,
|
|
384
|
+
});
|
|
385
|
+
export const readOrchestrationDelivery = (database, deliveryId) => {
|
|
386
|
+
try {
|
|
387
|
+
const row = statementWithBigInts(database, `${deliverySelect} WHERE d.delivery_id = ?`).get(deliveryId);
|
|
388
|
+
if (row === undefined) {
|
|
389
|
+
throw makeNodeRuntimeError("resource_not_found", "The Delivery was not found.");
|
|
390
|
+
}
|
|
391
|
+
return deliveryFromRow(decodeDeliveryRow(row));
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
if (error instanceof NodeRuntimeError)
|
|
395
|
+
throw error;
|
|
396
|
+
throw makeNodeRuntimeError("storage_corrupt", "The persisted orchestration Delivery is invalid.");
|
|
397
|
+
}
|
|
398
|
+
};
|
|
399
|
+
const readMailboxForOwner = (database, runId, owner) => {
|
|
400
|
+
const row = statementWithBigInts(database, `SELECT mailbox_id AS id, run_id AS runId, owner_kind AS ownerKind,
|
|
401
|
+
owner_id AS ownerId, head_sequence AS headSequence,
|
|
402
|
+
delivery_count AS deliveryCount, content_bytes AS contentBytes,
|
|
403
|
+
revision, created_at AS createdAt, updated_at AS updatedAt
|
|
404
|
+
FROM orchestration_mailboxes
|
|
405
|
+
WHERE run_id = ? AND owner_kind = ? AND owner_id = ?`).get(runId, owner.kind, owner.id);
|
|
406
|
+
if (row === undefined) {
|
|
407
|
+
throw makeNodeRuntimeError("resource_not_found", "The scoped orchestration Mailbox was not found.");
|
|
408
|
+
}
|
|
409
|
+
return decodeMailboxRow(row);
|
|
410
|
+
};
|
|
411
|
+
export const requireCoordinator = (database, runId, coordinatorEpoch) => {
|
|
412
|
+
const run = readRunRow(database, runId);
|
|
413
|
+
if (run.coordinatorActorId !== LOCAL_USER_ACTOR_ID ||
|
|
414
|
+
run.coordinatorEpoch !== BigInt(coordinatorEpoch)) {
|
|
415
|
+
throw makeNodeRuntimeError("storage_conflict", "The Run coordinator epoch is no longer authoritative.", true);
|
|
416
|
+
}
|
|
417
|
+
return run;
|
|
418
|
+
};
|
|
419
|
+
export const requireDispatchScope = (database, scope) => {
|
|
420
|
+
const dispatch = readDispatchRow(database, scope.run.id);
|
|
421
|
+
if (dispatch.id !== scope.dispatchId ||
|
|
422
|
+
scope.run.revision !== BigInt(scope.expectedRunRevision) ||
|
|
423
|
+
dispatch.revision !== BigInt(scope.expectedDispatchRevision)) {
|
|
424
|
+
throw makeNodeRuntimeError("storage_conflict", "The Run or Dispatch revision changed before the mutation.", true);
|
|
425
|
+
}
|
|
426
|
+
return dispatch;
|
|
427
|
+
};
|
|
428
|
+
const updateAggregateRevision = (database, update) => {
|
|
429
|
+
database
|
|
430
|
+
.prepare(`INSERT INTO aggregate_revisions(aggregate_type, aggregate_id, revision)
|
|
431
|
+
VALUES (?, ?, ?)
|
|
432
|
+
ON CONFLICT(aggregate_type, aggregate_id)
|
|
433
|
+
DO UPDATE SET revision = excluded.revision`)
|
|
434
|
+
.run(update.aggregateType, update.aggregateId, update.revision);
|
|
435
|
+
};
|
|
436
|
+
export const requireOneChange = (result, message) => {
|
|
437
|
+
if (result.changes !== 1 && result.changes !== 1n) {
|
|
438
|
+
throw makeNodeRuntimeError("storage_conflict", message, true);
|
|
439
|
+
}
|
|
440
|
+
};
|
|
441
|
+
const requirePublicationCapacity = (mailbox, run, contentBytes) => {
|
|
442
|
+
if (mailbox.deliveryCount >= BigInt(MAX_ORCHESTRATION_DELIVERIES_PER_MAILBOX) ||
|
|
443
|
+
mailbox.contentBytes + BigInt(contentBytes) >
|
|
444
|
+
BigInt(MAX_ORCHESTRATION_MAILBOX_CONTENT_BYTES) ||
|
|
445
|
+
run.messageContentBytes + BigInt(contentBytes) >
|
|
446
|
+
BigInt(MAX_ORCHESTRATION_RUN_MESSAGE_CONTENT_BYTES)) {
|
|
447
|
+
throw makeNodeRuntimeError("mailbox_saturated", "The orchestration Mailbox durable quota is saturated.", true);
|
|
448
|
+
}
|
|
449
|
+
};
|
|
450
|
+
const publicationDigest = (input) => createHash("sha256")
|
|
451
|
+
.update(JSON.stringify([
|
|
452
|
+
ORCHESTRATION_MESSAGE_SCHEMA_VERSION,
|
|
453
|
+
input.runId,
|
|
454
|
+
input.owner.kind,
|
|
455
|
+
input.owner.id,
|
|
456
|
+
input.type,
|
|
457
|
+
input.subject,
|
|
458
|
+
input.body,
|
|
459
|
+
input.questionId ?? "",
|
|
460
|
+
]))
|
|
461
|
+
.digest("hex");
|
|
462
|
+
export const prepareOrchestrationPublication = (database, input, recordedAt) => {
|
|
463
|
+
const mailbox = readMailboxForOwner(database, input.runId, input.owner);
|
|
464
|
+
const run = readRunRow(database, input.runId);
|
|
465
|
+
const contentBytes = Buffer.byteLength(input.subject, "utf8") +
|
|
466
|
+
Buffer.byteLength(input.body, "utf8");
|
|
467
|
+
requirePublicationCapacity(mailbox, run, contentBytes);
|
|
468
|
+
return {
|
|
469
|
+
contentBytes,
|
|
470
|
+
deliveryId: input.deliveryId ?? id("delivery"),
|
|
471
|
+
digest: publicationDigest(input),
|
|
472
|
+
input,
|
|
473
|
+
mailbox,
|
|
474
|
+
messageId: input.messageId ?? id("message"),
|
|
475
|
+
nextMailboxRevision: advanceSignedSqliteInteger(mailbox.revision),
|
|
476
|
+
nextSequence: advanceSignedSqliteInteger(mailbox.headSequence),
|
|
477
|
+
recordedAt,
|
|
478
|
+
run,
|
|
479
|
+
};
|
|
480
|
+
};
|
|
481
|
+
const insertPublishedMessageSql = `INSERT INTO orchestration_messages(
|
|
482
|
+
message_id, run_id, sender_kind, sender_run_id, sender_actor_id,
|
|
483
|
+
recipient_kind, recipient_id, recipient_mailbox_id, message_type,
|
|
484
|
+
subject, body, question_id, content_bytes, content_digest, created_at
|
|
485
|
+
) VALUES (?, ?, 'run-coordinator', ?, 'actor_local_user', ?, ?, ?, ?, ?, ?,
|
|
486
|
+
CASE WHEN ? = '' THEN NULL ELSE ? END, ?, ?, ?)`;
|
|
487
|
+
const insertPublishedMessage = (database, publication) => {
|
|
488
|
+
const questionId = publication.input.questionId ?? "";
|
|
489
|
+
database
|
|
490
|
+
.prepare(insertPublishedMessageSql)
|
|
491
|
+
.run(publication.messageId, publication.input.runId, publication.input.runId, publication.input.owner.kind, publication.input.owner.id, publication.mailbox.id, publication.input.type, publication.input.subject, publication.input.body, questionId, questionId, publication.contentBytes, publication.digest, publication.recordedAt);
|
|
492
|
+
};
|
|
493
|
+
const insertPublishedDelivery = (database, publication) => {
|
|
494
|
+
database
|
|
495
|
+
.prepare(`INSERT INTO orchestration_deliveries(
|
|
496
|
+
delivery_id, mailbox_id, message_id, mailbox_sequence, state,
|
|
497
|
+
attempt_count, created_at
|
|
498
|
+
) VALUES (?, ?, ?, ?, 'pending', 0, ?)`)
|
|
499
|
+
.run(publication.deliveryId, publication.mailbox.id, publication.messageId, publication.nextSequence, publication.recordedAt);
|
|
500
|
+
};
|
|
501
|
+
const advancePublishedMailbox = (database, publication) => {
|
|
502
|
+
requireOneChange(database
|
|
503
|
+
.prepare(`UPDATE orchestration_mailboxes SET head_sequence = ?,
|
|
504
|
+
delivery_count = delivery_count + 1,
|
|
505
|
+
content_bytes = content_bytes + ?, revision = ?, updated_at = ?
|
|
506
|
+
WHERE mailbox_id = ? AND revision = ?`)
|
|
507
|
+
.run(publication.nextSequence, publication.contentBytes, publication.nextMailboxRevision, publication.recordedAt, publication.mailbox.id, publication.mailbox.revision), "The Mailbox changed before publication.");
|
|
508
|
+
updateAggregateRevision(database, {
|
|
509
|
+
aggregateId: publication.mailbox.id,
|
|
510
|
+
aggregateType: ORCHESTRATION_MAILBOX_AGGREGATE_TYPE,
|
|
511
|
+
revision: publication.nextMailboxRevision,
|
|
512
|
+
});
|
|
513
|
+
};
|
|
514
|
+
const chargePublishedRun = (database, publication) => {
|
|
515
|
+
requireOneChange(database
|
|
516
|
+
.prepare(`UPDATE orchestration_runs
|
|
517
|
+
SET message_content_bytes = message_content_bytes + ?
|
|
518
|
+
WHERE run_id = ? AND message_content_bytes = ?`)
|
|
519
|
+
.run(publication.contentBytes, publication.run.id, publication.run.messageContentBytes), "The Run content quota changed before publication.");
|
|
520
|
+
};
|
|
521
|
+
export const persistOrchestrationPublication = (database, publication) => {
|
|
522
|
+
insertPublishedMessage(database, publication);
|
|
523
|
+
insertPublishedDelivery(database, publication);
|
|
524
|
+
advancePublishedMailbox(database, publication);
|
|
525
|
+
chargePublishedRun(database, publication);
|
|
526
|
+
return publication.deliveryId;
|
|
527
|
+
};
|
|
528
|
+
export const publishMessage = (database, input, recordedAt) => {
|
|
529
|
+
const publication = prepareOrchestrationPublication(database, input, recordedAt);
|
|
530
|
+
return persistOrchestrationPublication(database, publication);
|
|
531
|
+
};
|
|
532
|
+
const readTerminalAuthority = (database, workspaceId, terminalId) => {
|
|
533
|
+
const row = statementWithBigInts(database, `SELECT t.workspace_id AS workspaceId,
|
|
534
|
+
t.workspace_revision AS workspaceRevision, t.platform,
|
|
535
|
+
t.unavailability_code AS code, t.state, t.revision
|
|
536
|
+
FROM terminals t JOIN workspaces w ON w.workspace_id = t.workspace_id
|
|
537
|
+
WHERE t.terminal_id = ? AND t.workspace_id = ?
|
|
538
|
+
AND w.state = 'ready' AND w.revision = t.workspace_revision
|
|
539
|
+
AND NOT EXISTS (
|
|
540
|
+
SELECT 1 FROM terminal_live_generations live
|
|
541
|
+
WHERE live.terminal_id = t.terminal_id
|
|
542
|
+
)`).get(terminalId, workspaceId);
|
|
543
|
+
if (row === undefined) {
|
|
544
|
+
throw makeNodeRuntimeError("storage_conflict", "The exact unavailable Terminal and Workspace identity is not authoritative.", true);
|
|
545
|
+
}
|
|
546
|
+
return decodeTerminalAuthorityRow(row);
|
|
547
|
+
};
|
|
548
|
+
export const requireTerminalAuthority = (database, workspaceId, terminalId) => {
|
|
549
|
+
const terminal = readTerminalAuthority(database, workspaceId, terminalId);
|
|
550
|
+
if (terminal.state !== "unavailable" || terminal.revision !== 1n) {
|
|
551
|
+
throw makeNodeRuntimeError("storage_conflict", "The Dispatch Terminal is not the unavailable candidate.", true);
|
|
552
|
+
}
|
|
553
|
+
return terminal;
|
|
554
|
+
};
|
|
555
|
+
export const readCommandPointer = (result) => {
|
|
556
|
+
const value = JSON.parse(result.resultJson);
|
|
557
|
+
if (typeof value !== "object" ||
|
|
558
|
+
value === null ||
|
|
559
|
+
!("runId" in value) ||
|
|
560
|
+
typeof value.runId !== "string" ||
|
|
561
|
+
("deliveryId" in value && typeof value.deliveryId !== "string")) {
|
|
562
|
+
throw makeNodeRuntimeError("storage_corrupt", "The persisted orchestration command pointer is invalid.");
|
|
563
|
+
}
|
|
564
|
+
const pointer = value;
|
|
565
|
+
return {
|
|
566
|
+
...(pointer.deliveryId === undefined
|
|
567
|
+
? {}
|
|
568
|
+
: { deliveryId: pointer.deliveryId }),
|
|
569
|
+
runId: pointer.runId,
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
export const commandBase = (input) => ({
|
|
573
|
+
actorId: input.actorId,
|
|
574
|
+
aggregateId: input.aggregateId,
|
|
575
|
+
aggregateType: input.aggregateType,
|
|
576
|
+
commandId: input.commandId,
|
|
577
|
+
eventPayloadJson: JSON.stringify(input.eventPayload),
|
|
578
|
+
eventType: input.eventType,
|
|
579
|
+
expectedRevision: input.expectedRevision,
|
|
580
|
+
method: input.method,
|
|
581
|
+
requestDigest: input.requestDigest,
|
|
582
|
+
resultJson: JSON.stringify(input.pointer),
|
|
583
|
+
targetId: input.aggregateId,
|
|
584
|
+
targetType: input.aggregateType,
|
|
585
|
+
});
|
|
586
|
+
const runCreateResultFromCommand = (database, commandId, result) => {
|
|
587
|
+
const pointer = readCommandPointer(result);
|
|
588
|
+
if (pointer.deliveryId === undefined) {
|
|
589
|
+
throw makeNodeRuntimeError("storage_corrupt", "The Run creation Delivery pointer is missing.");
|
|
590
|
+
}
|
|
591
|
+
return orchestrationRunCreateResultSchema.parse({
|
|
592
|
+
aggregate: readOrchestrationAggregate(database, pointer.runId),
|
|
593
|
+
delivery: result.duplicate ? "duplicate" : "new",
|
|
594
|
+
initialDelivery: readOrchestrationDelivery(database, pointer.deliveryId),
|
|
595
|
+
method: "run.create",
|
|
596
|
+
receipt: commandReceiptFromPersisted(commandId, result),
|
|
597
|
+
});
|
|
598
|
+
};
|
|
599
|
+
const requireTaskIdentity = (input, clientKey) => {
|
|
600
|
+
const taskId = input.taskIds.get(clientKey);
|
|
601
|
+
if (taskId === undefined) {
|
|
602
|
+
throw makeNodeRuntimeError("storage_corrupt", "The admitted Task identity is missing.");
|
|
603
|
+
}
|
|
604
|
+
return taskId;
|
|
605
|
+
};
|
|
606
|
+
const insertRunRecord = (input, rootTaskId, dispatchTaskId) => {
|
|
607
|
+
input.database
|
|
608
|
+
.prepare(`INSERT INTO orchestration_runs(
|
|
609
|
+
run_id, workspace_id, terminal_id, root_task_id, dispatch_task_id,
|
|
610
|
+
coordinator_actor_id, coordinator_epoch, state, revision,
|
|
611
|
+
message_content_bytes, created_at, updated_at
|
|
612
|
+
) VALUES (?, ?, ?, ?, ?, 'actor_local_user', 1, 'active', 1, 0, ?, ?)`)
|
|
613
|
+
.run(input.runId, input.parameters.workspaceId, input.parameters.terminalId, rootTaskId, dispatchTaskId, input.recordedAt, input.recordedAt);
|
|
614
|
+
};
|
|
615
|
+
const insertTaskRecords = (input) => {
|
|
616
|
+
input.parameters.graph.tasks.forEach((task) => {
|
|
617
|
+
input.database
|
|
618
|
+
.prepare(`INSERT INTO orchestration_tasks(
|
|
619
|
+
task_id, run_id, client_key, workspace_id, objective,
|
|
620
|
+
state, revision, created_at, updated_at
|
|
621
|
+
) VALUES (?, ?, ?, ?, ?, ?, 1, ?, ?)`)
|
|
622
|
+
.run(requireTaskIdentity(input, task.clientKey), input.runId, task.clientKey, input.parameters.workspaceId, task.objective, task.clientKey === input.parameters.graph.dispatchTaskKey
|
|
623
|
+
? "active"
|
|
624
|
+
: "pending", input.recordedAt, input.recordedAt);
|
|
625
|
+
});
|
|
626
|
+
};
|
|
627
|
+
const insertTaskDependencyRecords = (input) => {
|
|
628
|
+
input.parameters.graph.tasks.forEach((task) => {
|
|
629
|
+
task.dependsOn.forEach((dependencyKey, position) => {
|
|
630
|
+
input.database
|
|
631
|
+
.prepare(`INSERT INTO orchestration_task_dependencies(
|
|
632
|
+
run_id, task_id, dependency_task_id, position
|
|
633
|
+
) VALUES (?, ?, ?, ?)`)
|
|
634
|
+
.run(input.runId, requireTaskIdentity(input, task.clientKey), requireTaskIdentity(input, dependencyKey), position);
|
|
635
|
+
});
|
|
636
|
+
});
|
|
637
|
+
};
|
|
638
|
+
const insertAttemptRecord = (input, dispatchTaskId) => {
|
|
639
|
+
input.database
|
|
640
|
+
.prepare(`INSERT INTO orchestration_attempts(
|
|
641
|
+
attempt_id, run_id, task_id, ordinal, state, revision,
|
|
642
|
+
created_at, updated_at
|
|
643
|
+
) VALUES (?, ?, ?, 1, 'active', 1, ?, ?)`)
|
|
644
|
+
.run(input.attemptId, input.runId, dispatchTaskId, input.recordedAt, input.recordedAt);
|
|
645
|
+
};
|
|
646
|
+
const insertDispatchRecord = (input, dispatchTaskId) => {
|
|
647
|
+
input.database
|
|
648
|
+
.prepare(`INSERT INTO orchestration_dispatches(
|
|
649
|
+
dispatch_id, run_id, task_id, attempt_id, terminal_id,
|
|
650
|
+
state, revision, created_at, updated_at
|
|
651
|
+
) VALUES (?, ?, ?, ?, ?, 'active', 1, ?, ?)`)
|
|
652
|
+
.run(input.dispatchId, input.runId, dispatchTaskId, input.attemptId, input.parameters.terminalId, input.recordedAt, input.recordedAt);
|
|
653
|
+
};
|
|
654
|
+
const insertMailboxRecord = (input) => {
|
|
655
|
+
const isRun = input.ownerKind === "run";
|
|
656
|
+
input.database
|
|
657
|
+
.prepare(`INSERT INTO orchestration_mailboxes(
|
|
658
|
+
mailbox_id, run_id, owner_kind, owner_id, run_owner_id,
|
|
659
|
+
dispatch_owner_id, created_at, updated_at
|
|
660
|
+
) VALUES (?, ?, ?, ?,
|
|
661
|
+
CASE WHEN ? = 1 THEN ? ELSE NULL END,
|
|
662
|
+
CASE WHEN ? = 0 THEN ? ELSE NULL END, ?, ?)`)
|
|
663
|
+
.run(input.id, input.runId, input.ownerKind, input.ownerId, Number(isRun), input.ownerId, Number(isRun), input.ownerId, input.recordedAt, input.recordedAt);
|
|
664
|
+
updateAggregateRevision(input.database, {
|
|
665
|
+
aggregateId: input.id,
|
|
666
|
+
aggregateType: ORCHESTRATION_MAILBOX_AGGREGATE_TYPE,
|
|
667
|
+
revision: 1n,
|
|
668
|
+
});
|
|
669
|
+
};
|
|
670
|
+
const insertMailboxRecords = (input) => {
|
|
671
|
+
insertMailboxRecord({
|
|
672
|
+
database: input.database,
|
|
673
|
+
id: id("mailbox"),
|
|
674
|
+
ownerId: input.runId,
|
|
675
|
+
ownerKind: "run",
|
|
676
|
+
recordedAt: input.recordedAt,
|
|
677
|
+
runId: input.runId,
|
|
678
|
+
});
|
|
679
|
+
insertMailboxRecord({
|
|
680
|
+
database: input.database,
|
|
681
|
+
id: id("mailbox"),
|
|
682
|
+
ownerId: input.dispatchId,
|
|
683
|
+
ownerKind: "dispatch",
|
|
684
|
+
recordedAt: input.recordedAt,
|
|
685
|
+
runId: input.runId,
|
|
686
|
+
});
|
|
687
|
+
};
|
|
688
|
+
const insertRunRecords = (input) => {
|
|
689
|
+
requireTerminalAuthority(input.database, input.parameters.workspaceId, input.parameters.terminalId);
|
|
690
|
+
const rootTaskId = requireTaskIdentity(input, input.parameters.graph.rootTaskKey);
|
|
691
|
+
const dispatchTaskId = requireTaskIdentity(input, input.parameters.graph.dispatchTaskKey);
|
|
692
|
+
insertRunRecord(input, rootTaskId, dispatchTaskId);
|
|
693
|
+
insertTaskRecords(input);
|
|
694
|
+
insertTaskDependencyRecords(input);
|
|
695
|
+
insertAttemptRecord(input, dispatchTaskId);
|
|
696
|
+
insertDispatchRecord(input, dispatchTaskId);
|
|
697
|
+
insertMailboxRecords(input);
|
|
698
|
+
};
|
|
699
|
+
const makeRunCreation = (parameters) => ({
|
|
700
|
+
attemptId: id("attempt"),
|
|
701
|
+
dispatchId: id("dispatch"),
|
|
702
|
+
initialDeliveryId: id("delivery"),
|
|
703
|
+
runId: id("run"),
|
|
704
|
+
taskIds: new Map(parameters.graph.tasks.map((task) => [task.clientKey, id("task")])),
|
|
705
|
+
});
|
|
706
|
+
const makeRunCreateCommand = (input, parameters, creation) => commandBase({
|
|
707
|
+
actorId: input.actorId,
|
|
708
|
+
aggregateId: creation.runId,
|
|
709
|
+
aggregateType: ORCHESTRATION_RUN_AGGREGATE_TYPE,
|
|
710
|
+
commandId: parameters.commandId,
|
|
711
|
+
eventPayload: {
|
|
712
|
+
dispatchId: creation.dispatchId,
|
|
713
|
+
taskCount: parameters.graph.tasks.length,
|
|
714
|
+
terminalId: parameters.terminalId,
|
|
715
|
+
workspaceId: parameters.workspaceId,
|
|
716
|
+
},
|
|
717
|
+
eventType: "run.created",
|
|
718
|
+
expectedRevision: 0n,
|
|
719
|
+
method: "run.create",
|
|
720
|
+
pointer: {
|
|
721
|
+
deliveryId: creation.initialDeliveryId,
|
|
722
|
+
runId: creation.runId,
|
|
723
|
+
},
|
|
724
|
+
requestDigest: input.requestDigest,
|
|
725
|
+
});
|
|
726
|
+
const mutateRunCreation = (input) => {
|
|
727
|
+
insertRunRecords(input);
|
|
728
|
+
const dispatchTask = input.parameters.graph.tasks.find((task) => task.clientKey === input.parameters.graph.dispatchTaskKey);
|
|
729
|
+
if (dispatchTask === undefined) {
|
|
730
|
+
throw makeNodeRuntimeError("storage_corrupt", "The admitted Dispatch Task is missing.");
|
|
731
|
+
}
|
|
732
|
+
publishMessage(input.database, {
|
|
733
|
+
body: dispatchTask.objective,
|
|
734
|
+
deliveryId: input.initialDeliveryId,
|
|
735
|
+
owner: { id: input.dispatchId, kind: "dispatch" },
|
|
736
|
+
runId: input.runId,
|
|
737
|
+
subject: "Dispatch ready",
|
|
738
|
+
type: "dispatch",
|
|
739
|
+
}, input.recordedAt);
|
|
740
|
+
};
|
|
741
|
+
const commitRunCreation = (commit) => {
|
|
742
|
+
const creation = makeRunCreation(commit.parameters);
|
|
743
|
+
const mutationInput = { ...commit, ...creation };
|
|
744
|
+
const result = commitCommandWithMutation({
|
|
745
|
+
database: commit.database,
|
|
746
|
+
input: makeRunCreateCommand(commit.input, commit.parameters, creation),
|
|
747
|
+
mutate: () => {
|
|
748
|
+
mutateRunCreation(mutationInput);
|
|
749
|
+
readOrchestrationAggregate(commit.database, creation.runId);
|
|
750
|
+
},
|
|
751
|
+
recordedAt: commit.recordedAt,
|
|
752
|
+
});
|
|
753
|
+
return runCreateResultFromCommand(commit.database, commit.parameters.commandId, result);
|
|
754
|
+
};
|
|
755
|
+
export const createOrchestrationRun = (database, input, recordedAt) => {
|
|
756
|
+
requireLocalCoordinatorActor(input.actorId);
|
|
757
|
+
const parameters = orchestrationRunCreateParametersSchema.parse(input.parameters);
|
|
758
|
+
inspectOrchestrationRunCreateAdmission(parameters);
|
|
759
|
+
const existing = findPersistedCommand(database, {
|
|
760
|
+
actorId: input.actorId,
|
|
761
|
+
commandId: parameters.commandId,
|
|
762
|
+
method: "run.create",
|
|
763
|
+
requestDigest: input.requestDigest,
|
|
764
|
+
});
|
|
765
|
+
if (existing !== undefined) {
|
|
766
|
+
return runCreateResultFromCommand(database, parameters.commandId, existing);
|
|
767
|
+
}
|
|
768
|
+
return commitRunCreation({ database, input, parameters, recordedAt });
|
|
769
|
+
};
|
|
770
|
+
export const showOrchestrationRun = (database, runId) => orchestrationRunShowResultSchema.parse({
|
|
771
|
+
aggregate: readOrchestrationAggregate(database, runId),
|
|
772
|
+
method: "run.show",
|
|
773
|
+
});
|
|
774
|
+
const listedRunRowSchema = Schema.Struct({
|
|
775
|
+
...runRowSchema.fields,
|
|
776
|
+
sequence: Schema.BigInt,
|
|
777
|
+
});
|
|
778
|
+
const decodeListedRunRow = Schema.decodeUnknownSync(listedRunRowSchema);
|
|
779
|
+
const requireExistingWorkspace = (database, workspaceId) => {
|
|
780
|
+
const row = database
|
|
781
|
+
.prepare("SELECT workspace_id AS id FROM workspaces WHERE workspace_id = ?")
|
|
782
|
+
.get(workspaceId);
|
|
783
|
+
if (row === undefined) {
|
|
784
|
+
throw makeNodeRuntimeError("resource_not_found", "The workspace was not found.");
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
const encodedRunListResult = (items, nextCursor) => {
|
|
788
|
+
const result = orchestrationRunListResultSchema.parse({
|
|
789
|
+
items,
|
|
790
|
+
method: "run.list",
|
|
791
|
+
...(nextCursor === undefined ? {} : { nextCursor }),
|
|
792
|
+
});
|
|
793
|
+
if (Buffer.byteLength(JSON.stringify(result), "utf8") >
|
|
794
|
+
MAX_ORCHESTRATION_LIST_RESULT_BYTES) {
|
|
795
|
+
throw makeNodeRuntimeError("frame_too_large", "The orchestration Run list result exceeds the encoded bound.");
|
|
796
|
+
}
|
|
797
|
+
return result;
|
|
798
|
+
};
|
|
799
|
+
const readWorkspaceRunPage = (database, parameters) => statementWithBigInts(database, `SELECT sequence, run_id AS id, workspace_id AS workspaceId,
|
|
800
|
+
terminal_id AS terminalId, root_task_id AS rootTaskId,
|
|
801
|
+
dispatch_task_id AS dispatchTaskId,
|
|
802
|
+
coordinator_actor_id AS coordinatorActorId,
|
|
803
|
+
coordinator_epoch AS coordinatorEpoch, state, revision,
|
|
804
|
+
message_content_bytes AS messageContentBytes,
|
|
805
|
+
created_at AS createdAt, updated_at AS updatedAt
|
|
806
|
+
FROM orchestration_runs
|
|
807
|
+
WHERE workspace_id = ? AND sequence > ?
|
|
808
|
+
ORDER BY sequence LIMIT ?`)
|
|
809
|
+
.all(parameters.workspaceId, BigInt(parameters.afterCursor), parameters.limit + 1)
|
|
810
|
+
.map((row) => decodeListedRunRow(row));
|
|
811
|
+
export const listOrchestrationRuns = (database, rawParameters) => {
|
|
812
|
+
const parameters = orchestrationRunListParametersSchema.parse(rawParameters);
|
|
813
|
+
requireExistingWorkspace(database, parameters.workspaceId);
|
|
814
|
+
const rows = readWorkspaceRunPage(database, parameters);
|
|
815
|
+
const visible = rows.slice(0, parameters.limit);
|
|
816
|
+
const last = visible.at(-1);
|
|
817
|
+
return encodedRunListResult(visible.map(runFromRow), rows.length > parameters.limit && last !== undefined
|
|
818
|
+
? last.sequence.toString()
|
|
819
|
+
: undefined);
|
|
820
|
+
};
|
|
821
|
+
const listedTaskRowSchema = Schema.Struct({
|
|
822
|
+
clientKey: Schema.String,
|
|
823
|
+
createdAt: Schema.String,
|
|
824
|
+
id: Schema.String,
|
|
825
|
+
revision: Schema.BigInt,
|
|
826
|
+
runId: Schema.String,
|
|
827
|
+
sequence: Schema.BigInt,
|
|
828
|
+
state: Schema.String,
|
|
829
|
+
updatedAt: Schema.String,
|
|
830
|
+
workspaceId: Schema.String,
|
|
831
|
+
});
|
|
832
|
+
const decodeListedTaskRow = Schema.decodeUnknownSync(listedTaskRowSchema);
|
|
833
|
+
export const encodedOrchestrationTaskListResult = (input) => {
|
|
834
|
+
if (Buffer.byteLength(JSON.stringify(input), "utf8") >
|
|
835
|
+
MAX_ORCHESTRATION_TASK_LIST_RESULT_BYTES) {
|
|
836
|
+
throw makeNodeRuntimeError("frame_too_large", "The orchestration Task list result exceeds the encoded bound.");
|
|
837
|
+
}
|
|
838
|
+
const result = orchestrationTaskListResultSchema.parse(input);
|
|
839
|
+
if (Buffer.byteLength(JSON.stringify(result), "utf8") >
|
|
840
|
+
MAX_ORCHESTRATION_TASK_LIST_RESULT_BYTES) {
|
|
841
|
+
throw makeNodeRuntimeError("frame_too_large", "The orchestration Task list result exceeds the encoded bound.");
|
|
842
|
+
}
|
|
843
|
+
return result;
|
|
844
|
+
};
|
|
845
|
+
const readRunTaskPage = (database, parameters) => statementWithBigInts(database, `SELECT task_id AS id, run_id AS runId, client_key AS clientKey,
|
|
846
|
+
workspace_id AS workspaceId, state, revision,
|
|
847
|
+
created_at AS createdAt, updated_at AS updatedAt, sequence
|
|
848
|
+
FROM orchestration_tasks
|
|
849
|
+
WHERE run_id = ? AND sequence > ?
|
|
850
|
+
ORDER BY sequence
|
|
851
|
+
LIMIT ?`)
|
|
852
|
+
.all(parameters.runId, BigInt(parameters.afterCursor), parameters.limit + 1)
|
|
853
|
+
.map((row) => decodeListedTaskRow(row));
|
|
854
|
+
const readDependencyTaskIdsForTasks = (database, runId, taskIds) => {
|
|
855
|
+
if (taskIds.length === 0)
|
|
856
|
+
return new Map();
|
|
857
|
+
const placeholders = taskIds.map(() => "?").join(", ");
|
|
858
|
+
const rows = database
|
|
859
|
+
.prepare(`SELECT d.task_id AS taskId, d.dependency_task_id AS dependencyTaskId
|
|
860
|
+
FROM orchestration_task_dependencies d
|
|
861
|
+
WHERE d.run_id = ? AND d.task_id IN (${placeholders})
|
|
862
|
+
ORDER BY d.task_id, d.position`)
|
|
863
|
+
.all(runId, ...taskIds)
|
|
864
|
+
.map((row) => decodeTaskDependencyRow(row));
|
|
865
|
+
return rows.reduce((grouped, row) => {
|
|
866
|
+
const dependencyTaskIds = grouped.get(row.taskId) ?? [];
|
|
867
|
+
dependencyTaskIds.push(row.dependencyTaskId);
|
|
868
|
+
grouped.set(row.taskId, dependencyTaskIds);
|
|
869
|
+
return grouped;
|
|
870
|
+
}, new Map());
|
|
871
|
+
};
|
|
872
|
+
const taskSummaryFromRow = (task, dependencyTaskIdsByTask) => ({
|
|
873
|
+
clientKey: task.clientKey,
|
|
874
|
+
createdAt: task.createdAt,
|
|
875
|
+
dependencyTaskIds: dependencyTaskIdsByTask.get(task.id) ?? [],
|
|
876
|
+
id: task.id,
|
|
877
|
+
revision: task.revision.toString(),
|
|
878
|
+
runId: task.runId,
|
|
879
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
880
|
+
state: task.state,
|
|
881
|
+
updatedAt: task.updatedAt,
|
|
882
|
+
workspaceId: task.workspaceId,
|
|
883
|
+
});
|
|
884
|
+
export const listOrchestrationTasks = (database, rawParameters) => {
|
|
885
|
+
const parameters = orchestrationTaskListParametersSchema.parse(rawParameters);
|
|
886
|
+
readRunRow(database, parameters.runId);
|
|
887
|
+
const rows = readRunTaskPage(database, parameters);
|
|
888
|
+
const visible = rows.slice(0, parameters.limit);
|
|
889
|
+
const last = visible.at(-1);
|
|
890
|
+
const dependencies = readDependencyTaskIdsForTasks(database, parameters.runId, visible.map((item) => item.id));
|
|
891
|
+
return encodedOrchestrationTaskListResult({
|
|
892
|
+
items: visible.map((row) => taskSummaryFromRow(row, dependencies)),
|
|
893
|
+
method: "run.task.list",
|
|
894
|
+
runId: parameters.runId,
|
|
895
|
+
...(rows.length > parameters.limit && last !== undefined
|
|
896
|
+
? { nextCursor: last.sequence.toString() }
|
|
897
|
+
: {}),
|
|
898
|
+
});
|
|
899
|
+
};
|
|
900
|
+
const readRunTaskRow = (database, parameters) => {
|
|
901
|
+
const row = statementWithBigInts(database, `SELECT task_id AS id, run_id AS runId, client_key AS clientKey,
|
|
902
|
+
workspace_id AS workspaceId, objective, state, revision,
|
|
903
|
+
created_at AS createdAt, updated_at AS updatedAt
|
|
904
|
+
FROM orchestration_tasks
|
|
905
|
+
WHERE run_id = ? AND task_id = ?`).get(parameters.runId, parameters.taskId);
|
|
906
|
+
if (row === undefined) {
|
|
907
|
+
throw makeNodeRuntimeError("resource_not_found", "The orchestration Task was not found.");
|
|
908
|
+
}
|
|
909
|
+
return decodeTaskRow(row);
|
|
910
|
+
};
|
|
911
|
+
const taskFromShownRow = (task, dependencyTaskIds) => ({
|
|
912
|
+
clientKey: task.clientKey,
|
|
913
|
+
createdAt: task.createdAt,
|
|
914
|
+
dependencyTaskIds,
|
|
915
|
+
id: task.id,
|
|
916
|
+
objective: task.objective,
|
|
917
|
+
revision: task.revision.toString(),
|
|
918
|
+
runId: task.runId,
|
|
919
|
+
schemaVersion: ORCHESTRATION_SCHEMA_VERSION,
|
|
920
|
+
state: task.state,
|
|
921
|
+
updatedAt: task.updatedAt,
|
|
922
|
+
workspaceId: task.workspaceId,
|
|
923
|
+
});
|
|
924
|
+
export const encodedOrchestrationTaskShowResult = (input) => {
|
|
925
|
+
if (Buffer.byteLength(JSON.stringify(input), "utf8") >
|
|
926
|
+
MAX_ORCHESTRATION_TASK_SHOW_RESULT_BYTES) {
|
|
927
|
+
throw makeNodeRuntimeError("frame_too_large", "The orchestration Task show result exceeds the encoded bound.");
|
|
928
|
+
}
|
|
929
|
+
const result = orchestrationTaskShowResultSchema.parse(input);
|
|
930
|
+
if (Buffer.byteLength(JSON.stringify(result), "utf8") >
|
|
931
|
+
MAX_ORCHESTRATION_TASK_SHOW_RESULT_BYTES) {
|
|
932
|
+
throw makeNodeRuntimeError("frame_too_large", "The orchestration Task show result exceeds the encoded bound.");
|
|
933
|
+
}
|
|
934
|
+
return result;
|
|
935
|
+
};
|
|
936
|
+
export const showOrchestrationTask = (database, rawParameters) => {
|
|
937
|
+
const parameters = orchestrationTaskShowParametersSchema.parse(rawParameters);
|
|
938
|
+
readRunRow(database, parameters.runId);
|
|
939
|
+
const row = readRunTaskRow(database, parameters);
|
|
940
|
+
const dependencies = readDependencyTaskIdsForTasks(database, parameters.runId, [parameters.taskId]);
|
|
941
|
+
return encodedOrchestrationTaskShowResult({
|
|
942
|
+
method: "run.task.show",
|
|
943
|
+
runId: parameters.runId,
|
|
944
|
+
task: taskFromShownRow(row, dependencies.get(parameters.taskId) ?? []),
|
|
945
|
+
taskId: parameters.taskId,
|
|
946
|
+
});
|
|
947
|
+
};
|
|
948
|
+
const readDispatchShowRow = (database, runId) => {
|
|
949
|
+
const row = statementWithBigInts(database, `SELECT dispatch_id AS id, run_id AS runId, task_id AS taskId,
|
|
950
|
+
attempt_id AS attemptId, terminal_id AS terminalId, state,
|
|
951
|
+
failure_code AS failureCode, failure_platform AS failurePlatform,
|
|
952
|
+
revision, created_at AS createdAt, updated_at AS updatedAt
|
|
953
|
+
FROM orchestration_dispatches WHERE run_id = ?`).get(runId);
|
|
954
|
+
if (row === undefined) {
|
|
955
|
+
throw makeNodeRuntimeError("resource_not_found", "The orchestration Dispatch was not found.");
|
|
956
|
+
}
|
|
957
|
+
return decodeDispatchRow(row);
|
|
958
|
+
};
|
|
959
|
+
export const encodedOrchestrationDispatchShowResult = (input) => {
|
|
960
|
+
if (Buffer.byteLength(JSON.stringify(input), "utf8") >
|
|
961
|
+
MAX_ORCHESTRATION_DISPATCH_SHOW_RESULT_BYTES) {
|
|
962
|
+
throw makeNodeRuntimeError("frame_too_large", "The orchestration Dispatch show result exceeds the encoded bound.");
|
|
963
|
+
}
|
|
964
|
+
const result = orchestrationDispatchShowResultSchema.parse(input);
|
|
965
|
+
if (Buffer.byteLength(JSON.stringify(result), "utf8") >
|
|
966
|
+
MAX_ORCHESTRATION_DISPATCH_SHOW_RESULT_BYTES) {
|
|
967
|
+
throw makeNodeRuntimeError("frame_too_large", "The orchestration Dispatch show result exceeds the encoded bound.");
|
|
968
|
+
}
|
|
969
|
+
return result;
|
|
970
|
+
};
|
|
971
|
+
export const showOrchestrationDispatch = (database, rawParameters) => {
|
|
972
|
+
const parameters = orchestrationDispatchShowParametersSchema.parse(rawParameters);
|
|
973
|
+
readRunRow(database, parameters.runId);
|
|
974
|
+
return encodedOrchestrationDispatchShowResult({
|
|
975
|
+
dispatch: dispatchFromRow(readDispatchShowRow(database, parameters.runId)),
|
|
976
|
+
method: "run.dispatch.show",
|
|
977
|
+
runId: parameters.runId,
|
|
978
|
+
});
|
|
979
|
+
};
|
|
980
|
+
const readMailboxById = (database, mailboxId) => {
|
|
981
|
+
const row = statementWithBigInts(database, `SELECT mailbox_id AS id, run_id AS runId, owner_kind AS ownerKind,
|
|
982
|
+
owner_id AS ownerId, head_sequence AS headSequence,
|
|
983
|
+
delivery_count AS deliveryCount, content_bytes AS contentBytes,
|
|
984
|
+
revision, created_at AS createdAt, updated_at AS updatedAt
|
|
985
|
+
FROM orchestration_mailboxes WHERE mailbox_id = ?`).get(mailboxId);
|
|
986
|
+
if (row === undefined) {
|
|
987
|
+
throw makeNodeRuntimeError("resource_not_found", "The orchestration Mailbox was not found.");
|
|
988
|
+
}
|
|
989
|
+
return decodeMailboxRow(row);
|
|
990
|
+
};
|
|
991
|
+
const nextDeliveryRow = (row, recordedAt) => ({
|
|
992
|
+
...row,
|
|
993
|
+
attemptCount: row.attemptCount >= BigInt(MAX_ORCHESTRATION_DELIVERY_ATTEMPTS)
|
|
994
|
+
? BigInt(MAX_ORCHESTRATION_DELIVERY_ATTEMPTS)
|
|
995
|
+
: row.attemptCount + 1n,
|
|
996
|
+
firstDeliveredAt: row.firstDeliveredAt ?? recordedAt,
|
|
997
|
+
lastDeliveredAt: recordedAt,
|
|
998
|
+
});
|
|
999
|
+
const encodedInboxResult = (mailbox, rows) => orchestrationInboxCheckResultSchema.parse({
|
|
1000
|
+
items: rows.map(deliveryFromRow),
|
|
1001
|
+
mailbox: mailboxFromRow(mailbox),
|
|
1002
|
+
method: "run.inbox.check",
|
|
1003
|
+
});
|
|
1004
|
+
const chooseInboxDeliveries = (mailbox, rows, recordedAt) => rows.reduce((selection, row) => {
|
|
1005
|
+
if (selection.full)
|
|
1006
|
+
return selection;
|
|
1007
|
+
const next = nextDeliveryRow(row, recordedAt);
|
|
1008
|
+
const candidate = encodedInboxResult(mailbox, [
|
|
1009
|
+
...selection.chosen,
|
|
1010
|
+
next,
|
|
1011
|
+
]);
|
|
1012
|
+
const full = Buffer.byteLength(JSON.stringify(candidate), "utf8") >
|
|
1013
|
+
MAX_ORCHESTRATION_CHECK_RESULT_BYTES;
|
|
1014
|
+
return full
|
|
1015
|
+
? { chosen: selection.chosen, full }
|
|
1016
|
+
: { chosen: [...selection.chosen, next], full };
|
|
1017
|
+
}, { chosen: [], full: false }).chosen;
|
|
1018
|
+
const recordDeliveryChecks = (database, rows, recordedAt) => {
|
|
1019
|
+
rows.forEach((row) => {
|
|
1020
|
+
requireOneChange(database
|
|
1021
|
+
.prepare(`UPDATE orchestration_deliveries
|
|
1022
|
+
SET attempt_count = ?, first_delivered_at = COALESCE(first_delivered_at, ?),
|
|
1023
|
+
last_delivered_at = ?
|
|
1024
|
+
WHERE delivery_id = ? AND state = 'pending'`)
|
|
1025
|
+
.run(row.attemptCount, recordedAt, recordedAt, row.id), "The Delivery changed during inbox check.");
|
|
1026
|
+
});
|
|
1027
|
+
};
|
|
1028
|
+
const requireEncodedInboxBound = (result) => {
|
|
1029
|
+
if (Buffer.byteLength(JSON.stringify(result), "utf8") >
|
|
1030
|
+
MAX_ORCHESTRATION_CHECK_RESULT_BYTES) {
|
|
1031
|
+
throw makeNodeRuntimeError("storage_corrupt", "The bounded inbox check result exceeded its encoded ceiling.");
|
|
1032
|
+
}
|
|
1033
|
+
};
|
|
1034
|
+
const transactImmediate = (database, operation) => {
|
|
1035
|
+
database.exec("BEGIN IMMEDIATE");
|
|
1036
|
+
try {
|
|
1037
|
+
const result = operation();
|
|
1038
|
+
database.exec("COMMIT");
|
|
1039
|
+
return result;
|
|
1040
|
+
}
|
|
1041
|
+
catch (error) {
|
|
1042
|
+
database.exec("ROLLBACK");
|
|
1043
|
+
throw error;
|
|
1044
|
+
}
|
|
1045
|
+
};
|
|
1046
|
+
const readPendingDeliveryRows = (database, mailboxId, limit) => statementWithBigInts(database, `${deliverySelect}
|
|
1047
|
+
WHERE d.mailbox_id = ? AND d.state = 'pending'
|
|
1048
|
+
ORDER BY d.mailbox_sequence LIMIT ?`)
|
|
1049
|
+
.all(mailboxId, limit)
|
|
1050
|
+
.map((row) => decodeDeliveryRow(row));
|
|
1051
|
+
const checkOrchestrationInboxTransaction = (database, parameters, recordedAt) => {
|
|
1052
|
+
requireCoordinator(database, parameters.runId, parameters.coordinatorEpoch);
|
|
1053
|
+
const mailbox = readMailboxForOwner(database, parameters.runId, parameters.owner);
|
|
1054
|
+
const rows = readPendingDeliveryRows(database, mailbox.id, parameters.limit);
|
|
1055
|
+
const chosen = chooseInboxDeliveries(mailbox, rows, recordedAt);
|
|
1056
|
+
recordDeliveryChecks(database, chosen, recordedAt);
|
|
1057
|
+
const persisted = chosen.map((row) => readOrchestrationDelivery(database, row.id));
|
|
1058
|
+
const result = orchestrationInboxCheckResultSchema.parse({
|
|
1059
|
+
items: persisted,
|
|
1060
|
+
mailbox: mailboxFromRow(mailbox),
|
|
1061
|
+
method: "run.inbox.check",
|
|
1062
|
+
});
|
|
1063
|
+
requireEncodedInboxBound(result);
|
|
1064
|
+
return result;
|
|
1065
|
+
};
|
|
1066
|
+
export const checkOrchestrationInbox = (database, parameters, recordedAt) => transactImmediate(database, () => checkOrchestrationInboxTransaction(database, parameters, recordedAt));
|
|
1067
|
+
const inboxAckResultFromCommand = (database, commandId, result) => {
|
|
1068
|
+
const pointer = readCommandPointer(result);
|
|
1069
|
+
if (pointer.deliveryId === undefined) {
|
|
1070
|
+
throw makeNodeRuntimeError("storage_corrupt", "The inbox acknowledgement Delivery pointer is missing.");
|
|
1071
|
+
}
|
|
1072
|
+
const delivery = readOrchestrationDelivery(database, pointer.deliveryId);
|
|
1073
|
+
return orchestrationInboxAckResultSchema.parse({
|
|
1074
|
+
delivery,
|
|
1075
|
+
mailbox: mailboxFromRow(readMailboxById(database, delivery.mailboxId)),
|
|
1076
|
+
method: "run.inbox.ack",
|
|
1077
|
+
receipt: commandReceiptFromPersisted(commandId, result),
|
|
1078
|
+
});
|
|
1079
|
+
};
|
|
1080
|
+
const makeInboxAckCommand = (input, mailbox, sourceCommandId) => commandBase({
|
|
1081
|
+
actorId: input.actorId,
|
|
1082
|
+
aggregateId: mailbox.id,
|
|
1083
|
+
aggregateType: ORCHESTRATION_MAILBOX_AGGREGATE_TYPE,
|
|
1084
|
+
commandId: input.parameters.commandId,
|
|
1085
|
+
eventPayload: sourceCommandId === undefined
|
|
1086
|
+
? {
|
|
1087
|
+
deliveryId: input.parameters.deliveryId,
|
|
1088
|
+
owner: input.parameters.owner,
|
|
1089
|
+
runId: input.parameters.runId,
|
|
1090
|
+
}
|
|
1091
|
+
: { deliveryId: input.parameters.deliveryId, sourceCommandId },
|
|
1092
|
+
eventType: sourceCommandId === undefined
|
|
1093
|
+
? "delivery.acknowledged"
|
|
1094
|
+
: "delivery.acknowledgement-receipt",
|
|
1095
|
+
expectedRevision: BigInt(input.parameters.expectedMailboxRevision),
|
|
1096
|
+
method: "run.inbox.ack",
|
|
1097
|
+
pointer: {
|
|
1098
|
+
deliveryId: input.parameters.deliveryId,
|
|
1099
|
+
runId: input.parameters.runId,
|
|
1100
|
+
},
|
|
1101
|
+
requestDigest: input.requestDigest,
|
|
1102
|
+
});
|
|
1103
|
+
const readAckSourceCommandId = (database, deliveryId) => {
|
|
1104
|
+
const row = database
|
|
1105
|
+
.prepare(`SELECT acknowledgement_command_id AS commandId
|
|
1106
|
+
FROM orchestration_deliveries WHERE delivery_id = ?`)
|
|
1107
|
+
.get(deliveryId);
|
|
1108
|
+
return Schema.decodeUnknownSync(Schema.Struct({ commandId: Schema.String }))(row).commandId;
|
|
1109
|
+
};
|
|
1110
|
+
const requireAckMailbox = (database, input, mailboxId) => {
|
|
1111
|
+
requireCoordinator(database, input.parameters.runId, input.parameters.coordinatorEpoch);
|
|
1112
|
+
const mailbox = readMailboxForOwner(database, input.parameters.runId, input.parameters.owner);
|
|
1113
|
+
if (mailbox.id !== mailboxId ||
|
|
1114
|
+
mailbox.revision !== BigInt(input.parameters.expectedMailboxRevision)) {
|
|
1115
|
+
throw makeNodeRuntimeError("storage_conflict", "The Mailbox revision changed before acknowledgement.", true);
|
|
1116
|
+
}
|
|
1117
|
+
return mailbox;
|
|
1118
|
+
};
|
|
1119
|
+
const requireAckDelivery = (database, input, mailbox) => {
|
|
1120
|
+
const delivery = readOrchestrationDelivery(database, input.parameters.deliveryId);
|
|
1121
|
+
if (delivery.mailboxId !== mailbox.id) {
|
|
1122
|
+
throw makeNodeRuntimeError("resource_not_found", "The Delivery does not belong to the selected Mailbox.");
|
|
1123
|
+
}
|
|
1124
|
+
return delivery;
|
|
1125
|
+
};
|
|
1126
|
+
const validateAckReplay = (database, input, mailboxId) => {
|
|
1127
|
+
const mailbox = requireAckMailbox(database, input, mailboxId);
|
|
1128
|
+
const delivery = requireAckDelivery(database, input, mailbox);
|
|
1129
|
+
if (delivery.state !== "acknowledged" ||
|
|
1130
|
+
delivery.acknowledgingActorId !== LOCAL_USER_ACTOR_ID) {
|
|
1131
|
+
throw makeNodeRuntimeError("storage_conflict", "The acknowledged Delivery changed before receipt persistence.", true);
|
|
1132
|
+
}
|
|
1133
|
+
};
|
|
1134
|
+
const replayInboxAcknowledgement = (commit) => {
|
|
1135
|
+
const sourceCommandId = readAckSourceCommandId(commit.database, commit.input.parameters.deliveryId);
|
|
1136
|
+
const result = commitIdempotentCommandReceipt({
|
|
1137
|
+
database: commit.database,
|
|
1138
|
+
input: makeInboxAckCommand(commit.input, commit.mailbox, sourceCommandId),
|
|
1139
|
+
recordedAt: commit.recordedAt,
|
|
1140
|
+
sourceCommandId,
|
|
1141
|
+
sourceMethod: "run.inbox.ack",
|
|
1142
|
+
validate: () => {
|
|
1143
|
+
validateAckReplay(commit.database, commit.input, commit.mailbox.id);
|
|
1144
|
+
},
|
|
1145
|
+
});
|
|
1146
|
+
return inboxAckResultFromCommand(commit.database, commit.input.parameters.commandId, result);
|
|
1147
|
+
};
|
|
1148
|
+
const acknowledgePendingDelivery = (mutation, mailbox, delivery) => {
|
|
1149
|
+
if (delivery.state !== "pending")
|
|
1150
|
+
return;
|
|
1151
|
+
requireOneChange(mutation.database
|
|
1152
|
+
.prepare(`UPDATE orchestration_deliveries SET state = 'acknowledged',
|
|
1153
|
+
acknowledging_actor_id = 'actor_local_user',
|
|
1154
|
+
acknowledgement_command_id = ?, acknowledged_at = ?
|
|
1155
|
+
WHERE delivery_id = ? AND mailbox_id = ? AND state = 'pending'`)
|
|
1156
|
+
.run(mutation.input.parameters.commandId, mutation.recordedAt, delivery.id, mailbox.id), "The Delivery changed before acknowledgement.");
|
|
1157
|
+
};
|
|
1158
|
+
const requireDeliveryAckActor = (delivery) => {
|
|
1159
|
+
if (delivery.state === "acknowledged" &&
|
|
1160
|
+
delivery.acknowledgingActorId !== LOCAL_USER_ACTOR_ID) {
|
|
1161
|
+
throw makeNodeRuntimeError("storage_conflict", "The Delivery was acknowledged by a different actor.");
|
|
1162
|
+
}
|
|
1163
|
+
};
|
|
1164
|
+
const mutateInboxAcknowledgement = (mutation) => {
|
|
1165
|
+
const mailbox = requireAckMailbox(mutation.database, mutation.input, mutation.mailboxId);
|
|
1166
|
+
const delivery = requireAckDelivery(mutation.database, mutation.input, mailbox);
|
|
1167
|
+
requireDeliveryAckActor(delivery);
|
|
1168
|
+
const nextMailboxRevision = advanceSignedSqliteInteger(mailbox.revision);
|
|
1169
|
+
acknowledgePendingDelivery(mutation, mailbox, delivery);
|
|
1170
|
+
requireOneChange(mutation.database
|
|
1171
|
+
.prepare(`UPDATE orchestration_mailboxes SET revision = ?,
|
|
1172
|
+
updated_at = ? WHERE mailbox_id = ? AND revision = ?`)
|
|
1173
|
+
.run(nextMailboxRevision, mutation.recordedAt, mailbox.id, mailbox.revision), "The Mailbox changed before acknowledgement.");
|
|
1174
|
+
};
|
|
1175
|
+
const commitInboxAcknowledgement = (commit) => {
|
|
1176
|
+
const result = commitCommandWithMutation({
|
|
1177
|
+
database: commit.database,
|
|
1178
|
+
input: makeInboxAckCommand(commit.input, commit.mailbox),
|
|
1179
|
+
mutate: () => {
|
|
1180
|
+
mutateInboxAcknowledgement({
|
|
1181
|
+
database: commit.database,
|
|
1182
|
+
input: commit.input,
|
|
1183
|
+
mailboxId: commit.mailbox.id,
|
|
1184
|
+
recordedAt: commit.recordedAt,
|
|
1185
|
+
});
|
|
1186
|
+
},
|
|
1187
|
+
recordedAt: commit.recordedAt,
|
|
1188
|
+
});
|
|
1189
|
+
return inboxAckResultFromCommand(commit.database, commit.input.parameters.commandId, result);
|
|
1190
|
+
};
|
|
1191
|
+
const readInboxAckMailbox = (database, input) => {
|
|
1192
|
+
requireCoordinator(database, input.parameters.runId, input.parameters.coordinatorEpoch);
|
|
1193
|
+
return readMailboxForOwner(database, input.parameters.runId, input.parameters.owner);
|
|
1194
|
+
};
|
|
1195
|
+
export const acknowledgeOrchestrationDelivery = (database, input, recordedAt) => {
|
|
1196
|
+
requireLocalCoordinatorActor(input.actorId);
|
|
1197
|
+
const existing = findPersistedCommand(database, {
|
|
1198
|
+
actorId: input.actorId,
|
|
1199
|
+
commandId: input.parameters.commandId,
|
|
1200
|
+
method: "run.inbox.ack",
|
|
1201
|
+
requestDigest: input.requestDigest,
|
|
1202
|
+
});
|
|
1203
|
+
if (existing !== undefined) {
|
|
1204
|
+
return inboxAckResultFromCommand(database, input.parameters.commandId, existing);
|
|
1205
|
+
}
|
|
1206
|
+
const mailbox = readInboxAckMailbox(database, input);
|
|
1207
|
+
const delivery = requireAckDelivery(database, input, mailbox);
|
|
1208
|
+
const commit = { database, input, mailbox, recordedAt };
|
|
1209
|
+
return delivery.state === "acknowledged" &&
|
|
1210
|
+
delivery.acknowledgingActorId === LOCAL_USER_ACTOR_ID
|
|
1211
|
+
? replayInboxAcknowledgement(commit)
|
|
1212
|
+
: commitInboxAcknowledgement(commit);
|
|
1213
|
+
};
|
|
1214
|
+
//# sourceMappingURL=storage.js.map
|