@mysten-incubation/devstack 0.1.1 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -3
- package/dashboard-ui/assets/grpc-a4usE3Nk.js +3 -0
- package/dashboard-ui/assets/index-B82Bh84P.css +1 -0
- package/dashboard-ui/assets/index-CRYJ4pru.js +1277 -0
- package/dashboard-ui/index.html +2 -2
- package/dist/api/define-capabilities.d.mts +1 -20
- package/dist/api/define-capabilities.mjs +15 -22
- package/dist/api/define-capabilities.mjs.map +1 -1
- package/dist/api/define-devstack-with.d.mts +7 -1
- package/dist/api/define-devstack-with.mjs.map +1 -1
- package/dist/api/define-devstack.mjs.map +1 -1
- package/dist/api/define-plugin.d.mts +2 -1
- package/dist/api/inference-network.d.mts +31 -17
- package/dist/api/inference-network.mjs +40 -43
- package/dist/api/inference-network.mjs.map +1 -1
- package/dist/api/load-config.mjs +88 -0
- package/dist/api/load-config.mjs.map +1 -0
- package/dist/api/mode-narrowed-factory.d.mts +1 -1
- package/dist/api/mode-narrowed-factory.mjs.map +1 -1
- package/dist/api/run-stack-internal.mjs +202 -0
- package/dist/api/run-stack-internal.mjs.map +1 -0
- package/dist/api/run-stack.d.mts +82 -31
- package/dist/api/run-stack.mjs +22 -141
- package/dist/api/run-stack.mjs.map +1 -1
- package/dist/build-integrations/dapp-kit/index.d.mts +61 -0
- package/dist/build-integrations/dapp-kit/index.mjs +58 -0
- package/dist/build-integrations/dapp-kit/index.mjs.map +1 -0
- package/dist/build-integrations/playwright/config.d.mts +1 -30
- package/dist/build-integrations/playwright/config.mjs +1 -27
- package/dist/build-integrations/playwright/config.mjs.map +1 -1
- package/dist/build-integrations/playwright/errors.d.mts +4 -7
- package/dist/build-integrations/playwright/errors.mjs.map +1 -1
- package/dist/build-integrations/playwright/global-setup.d.mts +42 -71
- package/dist/build-integrations/playwright/global-setup.mjs +142 -218
- package/dist/build-integrations/playwright/global-setup.mjs.map +1 -1
- package/dist/build-integrations/playwright/index.d.mts +2 -2
- package/dist/build-integrations/playwright/index.mjs +2 -2
- package/dist/build-integrations/playwright/stack-context.d.mts +3 -1
- package/dist/build-integrations/playwright/stack-context.mjs +4 -2
- package/dist/build-integrations/playwright/stack-context.mjs.map +1 -1
- package/dist/build-integrations/playwright/wallet-context.mjs +44 -19
- package/dist/build-integrations/playwright/wallet-context.mjs.map +1 -1
- package/dist/build-integrations/runtime/cold-start-url.mjs.map +1 -1
- package/dist/build-integrations/runtime/conventional-routes.mjs.map +1 -1
- package/dist/build-integrations/runtime/dapp-kit-slot.mjs.map +1 -1
- package/dist/build-integrations/runtime/discover.d.mts +6 -4
- package/dist/build-integrations/runtime/discover.mjs +15 -4
- package/dist/build-integrations/runtime/discover.mjs.map +1 -1
- package/dist/build-integrations/runtime/endpoint-registry.mjs.map +1 -1
- package/dist/build-integrations/runtime/errors.mjs.map +1 -1
- package/dist/build-integrations/runtime/read-stack-context.mjs +3 -3
- package/dist/build-integrations/runtime/read-stack-context.mjs.map +1 -1
- package/dist/build-integrations/runtime/resolve-discovery-env.d.mts +23 -7
- package/dist/build-integrations/runtime/resolve-discovery-env.mjs +25 -12
- package/dist/build-integrations/runtime/resolve-discovery-env.mjs.map +1 -1
- package/dist/build-integrations/runtime/stack-context.d.mts +2 -2
- package/dist/build-integrations/vite/index.d.mts +84 -19
- package/dist/build-integrations/vite/index.mjs +203 -28
- package/dist/build-integrations/vite/index.mjs.map +1 -1
- package/dist/build-integrations/vitest/config.d.mts +20 -2
- package/dist/build-integrations/vitest/config.mjs +16 -4
- package/dist/build-integrations/vitest/config.mjs.map +1 -1
- package/dist/build-integrations/vitest/env.d.mts +18 -10
- package/dist/build-integrations/vitest/env.mjs +11 -10
- package/dist/build-integrations/vitest/env.mjs.map +1 -1
- package/dist/build-integrations/vitest/errors.d.mts +7 -11
- package/dist/build-integrations/vitest/errors.mjs +3 -4
- package/dist/build-integrations/vitest/errors.mjs.map +1 -1
- package/dist/build-integrations/vitest/global-setup.d.mts +35 -0
- package/dist/build-integrations/vitest/global-setup.mjs +156 -0
- package/dist/build-integrations/vitest/global-setup.mjs.map +1 -0
- package/dist/build-integrations/vitest/index.d.mts +3 -2
- package/dist/build-integrations/vitest/index.mjs +3 -2
- package/dist/build-integrations/vitest/setup.mjs +2 -2
- package/dist/build-integrations/vitest/setup.mjs.map +1 -1
- package/dist/build-integrations/vitest/stack-context.d.mts +5 -3
- package/dist/build-integrations/vitest/stack-context.mjs +3 -2
- package/dist/build-integrations/vitest/stack-context.mjs.map +1 -1
- package/dist/cli/bail.mjs.map +1 -1
- package/dist/cli/doctor-probes.mjs +1 -3
- package/dist/cli/doctor-probes.mjs.map +1 -1
- package/dist/cli/main.d.mts +23 -1
- package/dist/cli/main.mjs +63 -8
- package/dist/cli/main.mjs.map +1 -1
- package/dist/cli/prune-direct.mjs.map +1 -1
- package/dist/cli/snapshot-reader.mjs.map +1 -1
- package/dist/cli/up-lifecycle.mjs.map +1 -1
- package/dist/cli/wirings/apply.mjs +28 -21
- package/dist/cli/wirings/apply.mjs.map +1 -1
- package/dist/cli/wirings/codegen.mjs +108 -0
- package/dist/cli/wirings/codegen.mjs.map +1 -0
- package/dist/cli/wirings/config-loader.mjs +12 -62
- package/dist/cli/wirings/config-loader.mjs.map +1 -1
- package/dist/cli/wirings/dump-ids.mjs +86 -0
- package/dist/cli/wirings/dump-ids.mjs.map +1 -0
- package/dist/cli/wirings/engine-command.mjs +1 -1
- package/dist/cli/wirings/engine-command.mjs.map +1 -1
- package/dist/cli/wirings/identity.mjs +2 -2
- package/dist/cli/wirings/identity.mjs.map +1 -1
- package/dist/cli/wirings/provide-file-system.mjs.map +1 -1
- package/dist/cli/wirings/read-devstack-version.mjs +17 -0
- package/dist/cli/wirings/read-devstack-version.mjs.map +1 -0
- package/dist/cli/wirings/snapshot.mjs +27 -34
- package/dist/cli/wirings/snapshot.mjs.map +1 -1
- package/dist/cli/wirings/up-ipc.mjs +147 -0
- package/dist/cli/wirings/up-ipc.mjs.map +1 -0
- package/dist/cli/wirings/up.mjs +218 -198
- package/dist/cli/wirings/up.mjs.map +1 -1
- package/dist/cli/wirings/wipe.mjs +1 -1
- package/dist/cli/wirings/wipe.mjs.map +1 -1
- package/dist/contracts/chain-probe.d.mts +1 -1
- package/dist/contracts/chain-probe.mjs +1 -1
- package/dist/contracts/chain-probe.mjs.map +1 -1
- package/dist/contracts/codegenable.d.mts +60 -6
- package/dist/contracts/codegenable.mjs +28 -0
- package/dist/contracts/codegenable.mjs.map +1 -0
- package/dist/contracts/config-bindings.mjs +162 -0
- package/dist/contracts/config-bindings.mjs.map +1 -0
- package/dist/contracts/container-runtime.d.mts +23 -17
- package/dist/contracts/plugin-expander.mjs.map +1 -1
- package/dist/contracts/snapshotable.d.mts +5 -7
- package/dist/contracts/wallet-protocol.d.mts +2 -5
- package/dist/contracts/wallet-protocol.mjs +2 -5
- package/dist/contracts/wallet-protocol.mjs.map +1 -1
- package/dist/index.d.mts +21 -26
- package/dist/index.mjs +8 -9
- package/dist/orchestrators/boot.d.mts +28 -0
- package/dist/orchestrators/boot.mjs +440 -0
- package/dist/orchestrators/boot.mjs.map +1 -0
- package/dist/orchestrators/codegen/bindings.d.mts +13 -1
- package/dist/orchestrators/codegen/bindings.mjs +23 -9
- package/dist/orchestrators/codegen/bindings.mjs.map +1 -1
- package/dist/orchestrators/codegen/config-runtime.mjs +208 -0
- package/dist/orchestrators/codegen/config-runtime.mjs.map +1 -0
- package/dist/orchestrators/codegen/emit.mjs +1 -1
- package/dist/orchestrators/codegen/emit.mjs.map +1 -1
- package/dist/orchestrators/codegen/errors.mjs +21 -1
- package/dist/orchestrators/codegen/errors.mjs.map +1 -1
- package/dist/orchestrators/codegen/format.mjs +2 -0
- package/dist/orchestrators/codegen/format.mjs.map +1 -1
- package/dist/orchestrators/codegen/gitignore.mjs +30 -11
- package/dist/orchestrators/codegen/gitignore.mjs.map +1 -1
- package/dist/orchestrators/codegen/id-config.mjs +107 -0
- package/dist/orchestrators/codegen/id-config.mjs.map +1 -0
- package/dist/orchestrators/codegen/output-location.mjs +23 -32
- package/dist/orchestrators/codegen/output-location.mjs.map +1 -1
- package/dist/orchestrators/codegen/paths.mjs +8 -1
- package/dist/orchestrators/codegen/paths.mjs.map +1 -1
- package/dist/orchestrators/codegen/permissions.mjs.map +1 -1
- package/dist/orchestrators/codegen/service.mjs +286 -58
- package/dist/orchestrators/codegen/service.mjs.map +1 -1
- package/dist/orchestrators/layers.mjs +31 -0
- package/dist/orchestrators/layers.mjs.map +1 -0
- package/dist/orchestrators/lifecycle-prune/errors.mjs.map +1 -1
- package/dist/orchestrators/lifecycle-prune/index.mjs +8 -10
- package/dist/orchestrators/lifecycle-prune/index.mjs.map +1 -1
- package/dist/orchestrators/network-options.d.mts +52 -0
- package/dist/orchestrators/network-options.mjs +43 -0
- package/dist/orchestrators/network-options.mjs.map +1 -0
- package/dist/orchestrators/router/cleanup.mjs.map +1 -1
- package/dist/orchestrators/router/cors.mjs.map +1 -1
- package/dist/orchestrators/router/entrypoints.mjs.map +1 -1
- package/dist/orchestrators/router/errors.mjs.map +1 -1
- package/dist/orchestrators/router/file-provider.mjs.map +1 -1
- package/dist/orchestrators/router/hostname.mjs.map +1 -1
- package/dist/orchestrators/router/profile.mjs +1 -1
- package/dist/orchestrators/router/profile.mjs.map +1 -1
- package/dist/orchestrators/router/service.d.mts +2 -2
- package/dist/orchestrators/router/service.mjs +12 -27
- package/dist/orchestrators/router/service.mjs.map +1 -1
- package/dist/orchestrators/router/traefik-container.mjs +1 -1
- package/dist/orchestrators/router/traefik-container.mjs.map +1 -1
- package/dist/orchestrators/snapshot/capture.mjs +171 -195
- package/dist/orchestrators/snapshot/capture.mjs.map +1 -1
- package/dist/orchestrators/snapshot/descriptor.d.mts +1 -1
- package/dist/orchestrators/snapshot/descriptor.mjs +53 -11
- package/dist/orchestrators/snapshot/descriptor.mjs.map +1 -1
- package/dist/orchestrators/snapshot/identity-guard.mjs +3 -5
- package/dist/orchestrators/snapshot/identity-guard.mjs.map +1 -1
- package/dist/orchestrators/snapshot/image-bundle-tags.mjs +32 -101
- package/dist/orchestrators/snapshot/image-bundle-tags.mjs.map +1 -1
- package/dist/orchestrators/snapshot/index.mjs +1 -4
- package/dist/orchestrators/snapshot/integrity.mjs.map +1 -1
- package/dist/orchestrators/snapshot/interrupted-restore.mjs +116 -0
- package/dist/orchestrators/snapshot/interrupted-restore.mjs.map +1 -0
- package/dist/orchestrators/snapshot/phase-error.mjs.map +1 -1
- package/dist/orchestrators/snapshot/prune.mjs +40 -31
- package/dist/orchestrators/snapshot/prune.mjs.map +1 -1
- package/dist/orchestrators/snapshot/restore.mjs +221 -196
- package/dist/orchestrators/snapshot/restore.mjs.map +1 -1
- package/dist/orchestrators/snapshot/service.mjs +72 -62
- package/dist/orchestrators/snapshot/service.mjs.map +1 -1
- package/dist/orchestrators/snapshot/wipe.mjs +67 -56
- package/dist/orchestrators/snapshot/wipe.mjs.map +1 -1
- package/dist/plugins/account/codegen.mjs +3 -0
- package/dist/plugins/account/codegen.mjs.map +1 -1
- package/dist/plugins/account/errors.d.mts +2 -2
- package/dist/plugins/account/errors.mjs +1 -4
- package/dist/plugins/account/errors.mjs.map +1 -1
- package/dist/plugins/account/funding.mjs +3 -27
- package/dist/plugins/account/funding.mjs.map +1 -1
- package/dist/plugins/account/index.d.mts +3 -8
- package/dist/plugins/account/index.mjs +71 -35
- package/dist/plugins/account/index.mjs.map +1 -1
- package/dist/plugins/account/keypair.d.mts +8 -7
- package/dist/plugins/account/keypair.mjs +5 -18
- package/dist/plugins/account/keypair.mjs.map +1 -1
- package/dist/plugins/account/lease.mjs.map +1 -1
- package/dist/plugins/account/registry.d.mts +1 -46
- package/dist/plugins/account/registry.mjs.map +1 -1
- package/dist/plugins/account/service.d.mts +43 -34
- package/dist/plugins/account/service.mjs +9 -54
- package/dist/plugins/account/service.mjs.map +1 -1
- package/dist/plugins/account/snapshot.mjs.map +1 -1
- package/dist/plugins/account/variants/ephemeral.mjs.map +1 -1
- package/dist/plugins/account/variants/impersonate.mjs.map +1 -1
- package/dist/plugins/account/variants/signer.mjs.map +1 -1
- package/dist/plugins/action/discriminator.mjs.map +1 -1
- package/dist/plugins/action/errors.mjs +1 -4
- package/dist/plugins/action/errors.mjs.map +1 -1
- package/dist/plugins/action/execute.mjs +3 -4
- package/dist/plugins/action/execute.mjs.map +1 -1
- package/dist/plugins/action/index.d.mts +2 -2
- package/dist/plugins/action/index.mjs +7 -11
- package/dist/plugins/action/index.mjs.map +1 -1
- package/dist/plugins/action/service.d.mts +5 -7
- package/dist/plugins/action/service.mjs +2 -16
- package/dist/plugins/action/service.mjs.map +1 -1
- package/dist/plugins/coin/address-resolution.mjs.map +1 -1
- package/dist/plugins/coin/codegen.mjs +97 -16
- package/dist/plugins/coin/codegen.mjs.map +1 -1
- package/dist/plugins/coin/discovery.mjs.map +1 -1
- package/dist/plugins/coin/errors.mjs +1 -4
- package/dist/plugins/coin/errors.mjs.map +1 -1
- package/dist/plugins/coin/index.d.mts +4 -34
- package/dist/plugins/coin/index.mjs +47 -28
- package/dist/plugins/coin/index.mjs.map +1 -1
- package/dist/plugins/coin/metadata.d.mts +1 -0
- package/dist/plugins/coin/metadata.mjs +8 -9
- package/dist/plugins/coin/metadata.mjs.map +1 -1
- package/dist/plugins/coin/mint.mjs +7 -21
- package/dist/plugins/coin/mint.mjs.map +1 -1
- package/dist/plugins/coin/registry.mjs +33 -20
- package/dist/plugins/coin/registry.mjs.map +1 -1
- package/dist/plugins/coin/service.d.mts +1 -1
- package/dist/plugins/coin/service.mjs +1 -8
- package/dist/plugins/coin/service.mjs.map +1 -1
- package/dist/plugins/coin/snapshot.mjs.map +1 -1
- package/dist/plugins/coin/type-strings.mjs.map +1 -1
- package/dist/plugins/dashboard/domain.mjs +106 -167
- package/dist/plugins/dashboard/domain.mjs.map +1 -1
- package/dist/plugins/dashboard/index.mjs +13 -13
- package/dist/plugins/dashboard/index.mjs.map +1 -1
- package/dist/plugins/dashboard/origin-policy.mjs +3 -3
- package/dist/plugins/dashboard/origin-policy.mjs.map +1 -1
- package/dist/plugins/dashboard/routable.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/builder.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/enums.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/root.mjs +23 -44
- package/dist/plugins/dashboard/schema/root.mjs.map +1 -1
- package/dist/plugins/dashboard/schema/types.mjs +37 -91
- package/dist/plugins/dashboard/schema/types.mjs.map +1 -1
- package/dist/plugins/dashboard/schema.mjs.map +1 -1
- package/dist/plugins/dashboard/server.mjs.map +1 -1
- package/dist/plugins/deepbook/codegen.d.mts +12 -11
- package/dist/plugins/deepbook/codegen.mjs +108 -11
- package/dist/plugins/deepbook/codegen.mjs.map +1 -1
- package/dist/plugins/deepbook/deploy.mjs +7 -14
- package/dist/plugins/deepbook/deploy.mjs.map +1 -1
- package/dist/plugins/deepbook/errors.mjs +4 -2
- package/dist/plugins/deepbook/errors.mjs.map +1 -1
- package/dist/plugins/deepbook/faucet-strategy.mjs +4 -10
- package/dist/plugins/deepbook/faucet-strategy.mjs.map +1 -1
- package/dist/plugins/deepbook/hash.mjs.map +1 -1
- package/dist/plugins/deepbook/index.d.mts +38 -34
- package/dist/plugins/deepbook/index.mjs +133 -64
- package/dist/plugins/deepbook/index.mjs.map +1 -1
- package/dist/plugins/deepbook/plugin-key.mjs.map +1 -1
- package/dist/plugins/deepbook/pyth/index.mjs +4 -8
- package/dist/plugins/deepbook/pyth/index.mjs.map +1 -1
- package/dist/plugins/deepbook/snapshot.mjs +0 -1
- package/dist/plugins/deepbook/snapshot.mjs.map +1 -1
- package/dist/plugins/deepbook/type-strings.mjs.map +1 -1
- package/dist/plugins/deepbook/types.d.mts +2 -1
- package/dist/plugins/deepbook/types.mjs.map +1 -1
- package/dist/plugins/faucet/dispatcher.d.mts +3 -3
- package/dist/plugins/faucet/dispatcher.mjs.map +1 -1
- package/dist/plugins/faucet/errors.mjs.map +1 -1
- package/dist/plugins/faucet/http.mjs +2 -10
- package/dist/plugins/faucet/http.mjs.map +1 -1
- package/dist/plugins/faucet/index.mjs +0 -1
- package/dist/plugins/faucet/index.mjs.map +1 -1
- package/dist/plugins/host-service/errors.d.mts +1 -3
- package/dist/plugins/host-service/errors.mjs +1 -2
- package/dist/plugins/host-service/errors.mjs.map +1 -1
- package/dist/plugins/host-service/index.d.mts +1 -2
- package/dist/plugins/host-service/index.mjs +11 -11
- package/dist/plugins/host-service/index.mjs.map +1 -1
- package/dist/plugins/host-service/routable.mjs.map +1 -1
- package/dist/plugins/host-service/service.mjs +13 -13
- package/dist/plugins/host-service/service.mjs.map +1 -1
- package/dist/plugins/internal/acquire-on-chain-artifact.mjs.map +1 -1
- package/dist/plugins/internal/codegen-helpers.mjs +2 -0
- package/dist/plugins/internal/codegen-helpers.mjs.map +1 -1
- package/dist/plugins/internal/funding-failure-error.mjs.map +1 -1
- package/dist/plugins/{postgres → internal/postgres-sidecar}/connection.mjs +1 -1
- package/dist/plugins/internal/postgres-sidecar/connection.mjs.map +1 -0
- package/dist/plugins/{postgres → internal/postgres-sidecar}/db-ensure.mjs +30 -16
- package/dist/plugins/internal/postgres-sidecar/db-ensure.mjs.map +1 -0
- package/dist/plugins/internal/postgres-sidecar/errors.mjs +21 -0
- package/dist/plugins/internal/postgres-sidecar/errors.mjs.map +1 -0
- package/dist/{substrate/runtime/scoped-multimap → plugins/internal/postgres-sidecar}/index.mjs +1 -0
- package/dist/plugins/internal/postgres-sidecar/service.mjs +121 -0
- package/dist/plugins/internal/postgres-sidecar/service.mjs.map +1 -0
- package/dist/plugins/package/build.mjs +2 -2
- package/dist/plugins/package/build.mjs.map +1 -1
- package/dist/plugins/package/codegen.d.mts +7 -14
- package/dist/plugins/package/codegen.mjs +187 -59
- package/dist/plugins/package/codegen.mjs.map +1 -1
- package/dist/plugins/package/dep-resolution.mjs +51 -3
- package/dist/plugins/package/dep-resolution.mjs.map +1 -1
- package/dist/plugins/package/errors.mjs +1 -4
- package/dist/plugins/package/errors.mjs.map +1 -1
- package/dist/plugins/package/git-source.d.mts +18 -0
- package/dist/plugins/package/git-source.mjs +119 -0
- package/dist/plugins/package/git-source.mjs.map +1 -0
- package/dist/plugins/package/index.d.mts +28 -19
- package/dist/plugins/package/index.mjs +107 -32
- package/dist/plugins/package/index.mjs.map +1 -1
- package/dist/plugins/package/mode-known.mjs +2 -2
- package/dist/plugins/package/mode-known.mjs.map +1 -1
- package/dist/plugins/package/mode-local.mjs +18 -35
- package/dist/plugins/package/mode-local.mjs.map +1 -1
- package/dist/plugins/package/publish-executor.mjs +13 -8
- package/dist/plugins/package/publish-executor.mjs.map +1 -1
- package/dist/plugins/package/publish-output.d.mts +1 -11
- package/dist/plugins/package/publish-output.mjs +1 -9
- package/dist/plugins/package/publish-output.mjs.map +1 -1
- package/dist/plugins/package/registry.d.mts +1 -1
- package/dist/plugins/package/registry.mjs +26 -14
- package/dist/plugins/package/registry.mjs.map +1 -1
- package/dist/plugins/package/service.mjs.map +1 -1
- package/dist/plugins/package/snapshot.mjs.map +1 -1
- package/dist/plugins/router-entrypoints.mjs +1 -3
- package/dist/plugins/router-entrypoints.mjs.map +1 -1
- package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs +1 -2
- package/dist/plugins/seal/bootstrap-assets/cargo-image.mjs.map +1 -1
- package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs +1 -6
- package/dist/plugins/seal/bootstrap-assets/source-fetch.mjs.map +1 -1
- package/dist/plugins/seal/codegen.d.mts +1 -5
- package/dist/plugins/seal/codegen.mjs +83 -12
- package/dist/plugins/seal/codegen.mjs.map +1 -1
- package/dist/plugins/seal/config-render.mjs +2 -6
- package/dist/plugins/seal/config-render.mjs.map +1 -1
- package/dist/plugins/seal/deploy.mjs +18 -29
- package/dist/plugins/seal/deploy.mjs.map +1 -1
- package/dist/plugins/seal/errors.d.mts +4 -5
- package/dist/plugins/seal/errors.mjs +1 -8
- package/dist/plugins/seal/errors.mjs.map +1 -1
- package/dist/plugins/seal/index.d.mts +7 -28
- package/dist/plugins/seal/index.mjs +69 -47
- package/dist/plugins/seal/index.mjs.map +1 -1
- package/dist/plugins/seal/key-manager.mjs.map +1 -1
- package/dist/plugins/seal/key-server.mjs +1 -6
- package/dist/plugins/seal/key-server.mjs.map +1 -1
- package/dist/plugins/seal/keygen.mjs +2 -3
- package/dist/plugins/seal/keygen.mjs.map +1 -1
- package/dist/plugins/seal/mode/fork-known.mjs.map +1 -1
- package/dist/plugins/seal/mode/live.mjs +1 -1
- package/dist/plugins/seal/mode/live.mjs.map +1 -1
- package/dist/plugins/seal/mode/local-keygen.mjs +4 -10
- package/dist/plugins/seal/mode/local-keygen.mjs.map +1 -1
- package/dist/plugins/seal/plugin-key.mjs.map +1 -1
- package/dist/plugins/seal/registry-publish.mjs.map +1 -1
- package/dist/plugins/seal/routable.mjs.map +1 -1
- package/dist/plugins/seal/service.mjs.map +1 -1
- package/dist/plugins/seal/snapshot.mjs +1 -2
- package/dist/plugins/seal/snapshot.mjs.map +1 -1
- package/dist/plugins/sui/auto-tick.mjs +5 -5
- package/dist/plugins/sui/auto-tick.mjs.map +1 -1
- package/dist/plugins/sui/chain-build-container.mjs +2 -2
- package/dist/plugins/sui/chain-build-container.mjs.map +1 -1
- package/dist/plugins/sui/chain-probe.mjs +4 -4
- package/dist/plugins/sui/chain-probe.mjs.map +1 -1
- package/dist/plugins/sui/codegen.d.mts +9 -7
- package/dist/plugins/sui/codegen.mjs +49 -46
- package/dist/plugins/sui/codegen.mjs.map +1 -1
- package/dist/plugins/sui/errors.d.mts +1 -1
- package/dist/plugins/sui/errors.mjs +1 -9
- package/dist/plugins/sui/errors.mjs.map +1 -1
- package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.d.mts +1 -1
- package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/index.mjs +3 -7
- package/dist/plugins/sui/exec/index.mjs.map +1 -0
- package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.mjs +1 -1
- package/dist/plugins/sui/exec/sign-and-dispatch.mjs.map +1 -0
- package/dist/plugins/sui/fork-faucet-strategy.mjs +2 -6
- package/dist/plugins/sui/fork-faucet-strategy.mjs.map +1 -1
- package/dist/plugins/sui/fork-orchestration.mjs +13 -23
- package/dist/plugins/sui/fork-orchestration.mjs.map +1 -1
- package/dist/plugins/sui/fork-transaction.mjs.map +1 -1
- package/dist/plugins/sui/index.d.mts +34 -83
- package/dist/plugins/sui/index.mjs +200 -68
- package/dist/plugins/sui/index.mjs.map +1 -1
- package/dist/{substrate/runtime/sui-ledger → plugins/sui/ledger}/object-ref.mjs +1 -1
- package/dist/plugins/sui/ledger/object-ref.mjs.map +1 -0
- package/dist/plugins/sui/local-faucet-strategy.mjs +1 -5
- package/dist/plugins/sui/local-faucet-strategy.mjs.map +1 -1
- package/dist/plugins/sui/log-attrs.mjs +11 -0
- package/dist/plugins/sui/log-attrs.mjs.map +1 -0
- package/dist/plugins/sui/mode/external.mjs +4 -12
- package/dist/plugins/sui/mode/external.mjs.map +1 -1
- package/dist/plugins/sui/mode/fork.mjs +19 -16
- package/dist/plugins/sui/mode/fork.mjs.map +1 -1
- package/dist/plugins/sui/mode/live.mjs +4 -17
- package/dist/plugins/sui/mode/live.mjs.map +1 -1
- package/dist/plugins/sui/mode/local.d.mts +1 -0
- package/dist/plugins/sui/mode/local.mjs +203 -61
- package/dist/plugins/sui/mode/local.mjs.map +1 -1
- package/dist/plugins/sui/mode/shared-boot.mjs +18 -23
- package/dist/plugins/sui/mode/shared-boot.mjs.map +1 -1
- package/dist/plugins/sui/mode/shared.d.mts +6 -7
- package/dist/plugins/sui/mode/shared.mjs.map +1 -1
- package/dist/plugins/sui/mode/spec.d.mts +23 -6
- package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.mjs +28 -30
- package/dist/plugins/sui/move/index.mjs.map +1 -0
- package/dist/plugins/sui/move-summary-runner.mjs +8 -4
- package/dist/plugins/sui/move-summary-runner.mjs.map +1 -1
- package/dist/{substrate/network.d.mts → plugins/sui/network-config.d.mts} +11 -10
- package/dist/plugins/sui/network-resolver.d.mts +6 -6
- package/dist/plugins/sui/routable.mjs.map +1 -1
- package/dist/plugins/sui/service.mjs +10 -6
- package/dist/plugins/sui/service.mjs.map +1 -1
- package/dist/plugins/sui/snapshot.mjs +10 -5
- package/dist/plugins/sui/snapshot.mjs.map +1 -1
- package/dist/plugins/wallet/codegen.d.mts +8 -6
- package/dist/plugins/wallet/codegen.mjs +4 -10
- package/dist/plugins/wallet/codegen.mjs.map +1 -1
- package/dist/plugins/wallet/errors.mjs +1 -4
- package/dist/plugins/wallet/errors.mjs.map +1 -1
- package/dist/plugins/wallet/index.d.mts +3 -6
- package/dist/plugins/wallet/index.mjs +16 -21
- package/dist/plugins/wallet/index.mjs.map +1 -1
- package/dist/plugins/wallet/origin-policy.mjs +3 -3
- package/dist/plugins/wallet/origin-policy.mjs.map +1 -1
- package/dist/plugins/wallet/pairing.mjs +6 -24
- package/dist/plugins/wallet/pairing.mjs.map +1 -1
- package/dist/plugins/wallet/protocol.mjs.map +1 -1
- package/dist/plugins/wallet/routable.mjs.map +1 -1
- package/dist/plugins/wallet/server.mjs +17 -24
- package/dist/plugins/wallet/server.mjs.map +1 -1
- package/dist/plugins/wallet/service.d.mts +2 -2
- package/dist/plugins/wallet/service.mjs +4 -15
- package/dist/plugins/wallet/service.mjs.map +1 -1
- package/dist/plugins/wallet/snapshot.mjs.map +1 -1
- package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs +1 -5
- package/dist/plugins/walrus/bootstrap-assets/cargo-image.mjs.map +1 -1
- package/dist/plugins/walrus/codegen.d.mts +2 -13
- package/dist/plugins/walrus/codegen.mjs +93 -28
- package/dist/plugins/walrus/codegen.mjs.map +1 -1
- package/dist/plugins/walrus/deploy-paths.mjs +2 -3
- package/dist/plugins/walrus/deploy-paths.mjs.map +1 -1
- package/dist/plugins/walrus/deploy.mjs +26 -19
- package/dist/plugins/walrus/deploy.mjs.map +1 -1
- package/dist/plugins/walrus/errors.mjs +1 -8
- package/dist/plugins/walrus/errors.mjs.map +1 -1
- package/dist/plugins/walrus/faucet-strategy.mjs +15 -1
- package/dist/plugins/walrus/faucet-strategy.mjs.map +1 -1
- package/dist/plugins/walrus/index.d.mts +13 -44
- package/dist/plugins/walrus/index.mjs +119 -122
- package/dist/plugins/walrus/index.mjs.map +1 -1
- package/dist/plugins/walrus/mode/known-deploy.mjs +6 -6
- package/dist/plugins/walrus/mode/known-deploy.mjs.map +1 -1
- package/dist/plugins/walrus/mode/local-cluster.d.mts +2 -2
- package/dist/plugins/walrus/mode/local-cluster.mjs +2 -10
- package/dist/plugins/walrus/mode/local-cluster.mjs.map +1 -1
- package/dist/plugins/walrus/plugin-key.mjs.map +1 -1
- package/dist/plugins/walrus/registry-publish.mjs.map +1 -1
- package/dist/plugins/walrus/routable.mjs.map +1 -1
- package/dist/plugins/walrus/service.mjs.map +1 -1
- package/dist/plugins/walrus/snapshot.mjs +3 -3
- package/dist/plugins/walrus/snapshot.mjs.map +1 -1
- package/dist/plugins/walrus/storage-nodes.mjs +53 -14
- package/dist/plugins/walrus/storage-nodes.mjs.map +1 -1
- package/dist/plugins/walrus/wal-swap.mjs +4 -8
- package/dist/plugins/walrus/wal-swap.mjs.map +1 -1
- package/dist/primitives/artifact-publisher.mjs.map +1 -1
- package/dist/primitives/cache.d.mts +1 -1
- package/dist/runtime/docker/client.mjs +47 -3
- package/dist/runtime/docker/client.mjs.map +1 -1
- package/dist/runtime/docker/container.mjs +37 -57
- package/dist/runtime/docker/container.mjs.map +1 -1
- package/dist/runtime/docker/errors.mjs.map +1 -1
- package/dist/runtime/docker/exec.mjs +2 -2
- package/dist/runtime/docker/exec.mjs.map +1 -1
- package/dist/runtime/docker/image.mjs +10 -11
- package/dist/runtime/docker/image.mjs.map +1 -1
- package/dist/runtime/docker/index.mjs +0 -1
- package/dist/runtime/docker/inspect-and-decode.mjs.map +1 -1
- package/dist/runtime/docker/inventory.mjs +9 -9
- package/dist/runtime/docker/inventory.mjs.map +1 -1
- package/dist/runtime/docker/labels.mjs +12 -1
- package/dist/runtime/docker/labels.mjs.map +1 -1
- package/dist/runtime/docker/network.mjs +6 -6
- package/dist/runtime/docker/network.mjs.map +1 -1
- package/dist/runtime/docker/render-run-args.mjs.map +1 -1
- package/dist/runtime/docker/service.mjs +31 -45
- package/dist/runtime/docker/service.mjs.map +1 -1
- package/dist/runtime/docker/sweep.mjs +14 -64
- package/dist/runtime/docker/sweep.mjs.map +1 -1
- package/dist/runtime/docker/volume.mjs +1 -1
- package/dist/runtime/docker/volume.mjs.map +1 -1
- package/dist/runtime/docker/wrap.mjs +14 -2
- package/dist/runtime/docker/wrap.mjs.map +1 -1
- package/dist/substrate/brand.d.mts +2 -5
- package/dist/substrate/brand.mjs +3 -2
- package/dist/substrate/brand.mjs.map +1 -1
- package/dist/substrate/cross-process.mjs +2 -16
- package/dist/substrate/cross-process.mjs.map +1 -1
- package/dist/substrate/event-time.mjs +0 -2
- package/dist/substrate/event-time.mjs.map +1 -1
- package/dist/substrate/events.d.mts +46 -16
- package/dist/substrate/identity.d.mts +11 -5
- package/dist/substrate/manifest.d.mts +33 -26
- package/dist/substrate/manifest.mjs +8 -3
- package/dist/substrate/manifest.mjs.map +1 -1
- package/dist/substrate/options.d.mts +33 -4
- package/dist/substrate/plugin-ctx.d.mts +70 -0
- package/dist/substrate/plugin-ctx.mjs +66 -0
- package/dist/substrate/plugin-ctx.mjs.map +1 -0
- package/dist/substrate/plugin.d.mts +46 -38
- package/dist/substrate/plugin.mjs +13 -9
- package/dist/substrate/plugin.mjs.map +1 -1
- package/dist/substrate/projection.d.mts +1 -1
- package/dist/substrate/runtime/atomic-write.mjs +3 -4
- package/dist/substrate/runtime/atomic-write.mjs.map +1 -1
- package/dist/substrate/runtime/cache/schema.mjs.map +1 -1
- package/dist/substrate/runtime/cache/service.mjs +50 -20
- package/dist/substrate/runtime/cache/service.mjs.map +1 -1
- package/dist/substrate/runtime/config-validation.mjs.map +1 -1
- package/dist/substrate/runtime/control-plane/domain.mjs +34 -12
- package/dist/substrate/runtime/control-plane/domain.mjs.map +1 -1
- package/dist/substrate/runtime/control-plane/service.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/channel.mjs +14 -17
- package/dist/substrate/runtime/cross-process/command-channel/channel.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/file-channel.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/protocol.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/command-channel/runtime-control-lock.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/index.mjs +0 -2
- package/dist/substrate/runtime/cross-process/live-clock.mjs +1 -1
- package/dist/substrate/runtime/cross-process/live-clock.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/liveness.mjs +11 -18
- package/dist/substrate/runtime/cross-process/liveness.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs +2 -2
- package/dist/substrate/runtime/cross-process/reclaim-stale-file.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/roster.mjs +17 -127
- package/dist/substrate/runtime/cross-process/roster.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/self-pid.mjs.map +1 -1
- package/dist/substrate/runtime/cross-process/stack-lock.mjs +29 -28
- package/dist/substrate/runtime/cross-process/stack-lock.mjs.map +1 -1
- package/dist/substrate/runtime/current-plugin.mjs.map +1 -1
- package/dist/substrate/runtime/errors.mjs +1 -13
- package/dist/substrate/runtime/errors.mjs.map +1 -1
- package/dist/substrate/runtime/format-unknown-error.mjs.map +1 -1
- package/dist/substrate/runtime/host-bind-mount-owner.mjs.map +1 -1
- package/dist/substrate/runtime/host-gateway.mjs.map +1 -1
- package/dist/substrate/runtime/host-tree-tar/index.mjs +15 -163
- package/dist/substrate/runtime/host-tree-tar/index.mjs.map +1 -1
- package/dist/substrate/runtime/http-probe.d.mts +1 -3
- package/dist/substrate/runtime/http-probe.mjs.map +1 -1
- package/dist/substrate/runtime/index.mjs +1 -6
- package/dist/substrate/runtime/lease-broker/service.mjs +5 -23
- package/dist/substrate/runtime/lease-broker/service.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/dep-graph.mjs +3 -3
- package/dist/substrate/runtime/lifecycle/dep-graph.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/graph-input-id.d.mts +1 -0
- package/dist/substrate/runtime/lifecycle/graph-input-id.mjs +133 -0
- package/dist/substrate/runtime/lifecycle/graph-input-id.mjs.map +1 -0
- package/dist/substrate/runtime/lifecycle/index.mjs +2 -2
- package/dist/substrate/runtime/lifecycle/plugin-registry.d.mts +1 -1
- package/dist/substrate/runtime/lifecycle/plugin-registry.mjs +22 -1
- package/dist/substrate/runtime/lifecycle/plugin-registry.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/ready-gate.mjs +2 -15
- package/dist/substrate/runtime/lifecycle/ready-gate.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/selective-restart.mjs +29 -25
- package/dist/substrate/runtime/lifecycle/selective-restart.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/signals.mjs +1 -1
- package/dist/substrate/runtime/lifecycle/signals.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/state-machine.mjs.map +1 -1
- package/dist/substrate/runtime/lifecycle/watch-attribution.d.mts +1 -1
- package/dist/substrate/runtime/lifecycle/watch-attribution.mjs +0 -1
- package/dist/substrate/runtime/lifecycle/watch-attribution.mjs.map +1 -1
- package/dist/substrate/runtime/managed-container.d.mts +5 -1
- package/dist/substrate/runtime/managed-container.mjs +8 -10
- package/dist/substrate/runtime/managed-container.mjs.map +1 -1
- package/dist/substrate/runtime/manifest/manifest.mjs +8 -30
- package/dist/substrate/runtime/manifest/manifest.mjs.map +1 -1
- package/dist/substrate/runtime/mode-errors.d.mts +1 -2
- package/dist/substrate/runtime/mode-errors.mjs.map +1 -1
- package/dist/substrate/runtime/observability/cascade-formatter.mjs +1 -11
- package/dist/substrate/runtime/observability/cascade-formatter.mjs.map +1 -1
- package/dist/substrate/runtime/observability/ignore-with-log.mjs.map +1 -1
- package/dist/substrate/runtime/observability/index.d.mts +1 -1
- package/dist/substrate/runtime/observability/index.mjs +4 -6
- package/dist/substrate/runtime/observability/log-attrs.mjs +46 -0
- package/dist/substrate/runtime/observability/log-attrs.mjs.map +1 -0
- package/dist/substrate/runtime/observability/log-store.mjs.map +1 -1
- package/dist/substrate/runtime/observability/logger.mjs +3 -3
- package/dist/substrate/runtime/observability/logger.mjs.map +1 -1
- package/dist/substrate/runtime/observability/output-truncate.mjs.map +1 -1
- package/dist/substrate/runtime/observability/pretty-error.mjs.map +1 -1
- package/dist/substrate/runtime/observability/process-lines.mjs.map +1 -1
- package/dist/substrate/runtime/observability/redaction.mjs.map +1 -1
- package/dist/substrate/runtime/observability/subprocess-capture.mjs +2 -2
- package/dist/substrate/runtime/observability/subprocess-capture.mjs.map +1 -1
- package/dist/substrate/runtime/passthrough-or-wrap.mjs.map +1 -1
- package/dist/substrate/runtime/paths.mjs +27 -9
- package/dist/substrate/runtime/paths.mjs.map +1 -1
- package/dist/substrate/runtime/phase-preserving-produce.mjs.map +1 -1
- package/dist/substrate/runtime/port-broker/service.mjs +10 -27
- package/dist/substrate/runtime/port-broker/service.mjs.map +1 -1
- package/dist/substrate/runtime/post-acquire-tasks.mjs.map +1 -1
- package/dist/substrate/runtime/probes.d.mts +2 -3
- package/dist/substrate/runtime/probes.mjs.map +1 -1
- package/dist/substrate/runtime/process-supervisor.mjs.map +1 -1
- package/dist/substrate/runtime/projection/operational-endpoints.mjs.map +1 -1
- package/dist/substrate/runtime/projection/state-ref.mjs.map +1 -1
- package/dist/substrate/runtime/projection/update.mjs +87 -11
- package/dist/substrate/runtime/projection/update.mjs.map +1 -1
- package/dist/substrate/runtime/random-suffix.mjs.map +1 -1
- package/dist/substrate/runtime/reconcile/fs-plan.mjs +146 -0
- package/dist/substrate/runtime/reconcile/fs-plan.mjs.map +1 -0
- package/dist/substrate/runtime/reconcile/graph.mjs +19 -0
- package/dist/substrate/runtime/reconcile/graph.mjs.map +1 -0
- package/dist/substrate/runtime/reconcile/index.mjs +5 -0
- package/dist/substrate/runtime/reconcile/label.mjs +41 -0
- package/dist/substrate/runtime/reconcile/label.mjs.map +1 -0
- package/dist/substrate/runtime/reconcile/spec.mjs +15 -0
- package/dist/substrate/runtime/reconcile/spec.mjs.map +1 -0
- package/dist/substrate/runtime/retry-policy.d.mts +2 -3
- package/dist/substrate/runtime/retry-policy.mjs.map +1 -1
- package/dist/substrate/runtime/routed-url.mjs.map +1 -1
- package/dist/substrate/runtime/runtime-decode.mjs.map +1 -1
- package/dist/substrate/runtime/scoped-http-server.mjs.map +1 -1
- package/dist/substrate/runtime/stage-and-swap/index.mjs +49 -12
- package/dist/substrate/runtime/stage-and-swap/index.mjs.map +1 -1
- package/dist/substrate/runtime/strategy-registry/chain-keyed-strategy-for.mjs.map +1 -1
- package/dist/substrate/runtime/strategy-registry/chain-probe-for.mjs.map +1 -1
- package/dist/substrate/runtime/strategy-registry/service.mjs +29 -17
- package/dist/substrate/runtime/strategy-registry/service.mjs.map +1 -1
- package/dist/substrate/runtime/subnet-broker.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/acquire-node.mjs +188 -56
- package/dist/substrate/runtime/supervisor/acquire-node.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/background-tasks.mjs +79 -65
- package/dist/substrate/runtime/supervisor/background-tasks.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/command-loop.mjs +82 -23
- package/dist/substrate/runtime/supervisor/command-loop.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs +16 -0
- package/dist/substrate/runtime/supervisor/contribution-dispatcher.mjs.map +1 -0
- package/dist/substrate/runtime/supervisor/errors.mjs +11 -2
- package/dist/substrate/runtime/supervisor/errors.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/index.mjs +2 -0
- package/dist/substrate/runtime/supervisor/shutdown.mjs +6 -6
- package/dist/substrate/runtime/supervisor/shutdown.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs +60 -70
- package/dist/substrate/runtime/supervisor/start-supervisor.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/state.d.mts +1 -1
- package/dist/substrate/runtime/supervisor/state.mjs +1 -1
- package/dist/substrate/runtime/supervisor/state.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/teardown.mjs +10 -9
- package/dist/substrate/runtime/supervisor/teardown.mjs.map +1 -1
- package/dist/substrate/runtime/supervisor/wiring.mjs +6 -20
- package/dist/substrate/runtime/supervisor/wiring.mjs.map +1 -1
- package/dist/substrate/runtime/tar/reader.mjs +216 -0
- package/dist/substrate/runtime/tar/reader.mjs.map +1 -0
- package/dist/substrate/runtime/typed-env.mjs.map +1 -1
- package/dist/substrate/versioned-doc-schema.mjs.map +1 -1
- package/dist/substrate/versioned-doc-sync.mjs +5 -5
- package/dist/substrate/versioned-doc-sync.mjs.map +1 -1
- package/dist/surfaces/cli/command-tree.mjs +49 -7
- package/dist/surfaces/cli/command-tree.mjs.map +1 -1
- package/dist/surfaces/cli/commands/config.mjs +1 -1
- package/dist/surfaces/cli/commands/config.mjs.map +1 -1
- package/dist/surfaces/cli/commands/confirm-node.mjs.map +1 -1
- package/dist/surfaces/cli/commands/confirm.mjs.map +1 -1
- package/dist/surfaces/cli/commands/doctor.mjs +1 -1
- package/dist/surfaces/cli/commands/doctor.mjs.map +1 -1
- package/dist/surfaces/cli/commands/prune-picker-entry.mjs.map +1 -1
- package/dist/surfaces/cli/commands/prune-picker.mjs.map +1 -1
- package/dist/surfaces/cli/commands/prune.mjs +1 -1
- package/dist/surfaces/cli/commands/prune.mjs.map +1 -1
- package/dist/surfaces/cli/commands/snapshot.mjs +1 -1
- package/dist/surfaces/cli/commands/snapshot.mjs.map +1 -1
- package/dist/surfaces/cli/commands/status.mjs +1 -1
- package/dist/surfaces/cli/commands/status.mjs.map +1 -1
- package/dist/surfaces/cli/commands/supervisor-presence.mjs.map +1 -1
- package/dist/surfaces/cli/commands/wipe.mjs +3 -4
- package/dist/surfaces/cli/commands/wipe.mjs.map +1 -1
- package/dist/surfaces/cli/envelope.mjs.map +1 -1
- package/dist/surfaces/cli/errors.mjs.map +1 -1
- package/dist/surfaces/cli/flags.mjs.map +1 -1
- package/dist/surfaces/cli/index.mjs +45 -14
- package/dist/surfaces/cli/index.mjs.map +1 -1
- package/dist/surfaces/cli/output.mjs.map +1 -1
- package/dist/surfaces/cli/sysexits.mjs.map +1 -1
- package/dist/surfaces/tui/app.mjs +0 -21
- package/dist/surfaces/tui/app.mjs.map +1 -1
- package/dist/surfaces/tui/dashboard.mjs +0 -48
- package/dist/surfaces/tui/dashboard.mjs.map +1 -1
- package/dist/surfaces/tui/display-derivation.mjs +80 -16
- package/dist/surfaces/tui/display-derivation.mjs.map +1 -1
- package/dist/surfaces/tui/errors.mjs.map +1 -1
- package/dist/surfaces/tui/event-log.mjs +0 -9
- package/dist/surfaces/tui/event-log.mjs.map +1 -1
- package/dist/surfaces/tui/heartbeat.mjs.map +1 -1
- package/dist/surfaces/tui/index.mjs +2 -2
- package/dist/surfaces/tui/index.mjs.map +1 -1
- package/dist/surfaces/tui/input.mjs.map +1 -1
- package/dist/surfaces/tui/mode-detect.mjs.map +1 -1
- package/dist/surfaces/tui/mount-ink.mjs.map +1 -1
- package/dist/surfaces/tui/plain-renderer.mjs +26 -19
- package/dist/surfaces/tui/plain-renderer.mjs.map +1 -1
- package/dist/surfaces/tui/resource-table.mjs +8 -10
- package/dist/surfaces/tui/resource-table.mjs.map +1 -1
- package/images/postgres/Dockerfile +0 -1
- package/images/sui/Dockerfile +27 -54
- package/images/sui/entrypoint.sh +17 -179
- package/package.json +23 -15
- package/dashboard-ui/assets/index-Bmi1UtAg.js +0 -1356
- package/dashboard-ui/assets/index-D5EShVt4.js +0 -3
- package/dashboard-ui/assets/index-Deml9drg.css +0 -1
- package/dist/api/plugin-errors.d.mts +0 -7
- package/dist/api/plugin-errors.mjs +0 -10
- package/dist/api/plugin-errors.mjs.map +0 -1
- package/dist/cli/wirings/build-verb-layers.mjs +0 -42
- package/dist/cli/wirings/build-verb-layers.mjs.map +0 -1
- package/dist/contracts/capability-decl.d.mts +0 -40
- package/dist/orchestrators/built-in-plugin-layers.mjs +0 -54
- package/dist/orchestrators/built-in-plugin-layers.mjs.map +0 -1
- package/dist/orchestrators/run.mjs +0 -91
- package/dist/orchestrators/run.mjs.map +0 -1
- package/dist/orchestrators/runtime-composition.d.mts +0 -10
- package/dist/orchestrators/runtime-composition.mjs +0 -252
- package/dist/orchestrators/runtime-composition.mjs.map +0 -1
- package/dist/orchestrators/snapshot/capture-command.d.mts +0 -1
- package/dist/orchestrators/snapshot/capture-command.mjs +0 -25
- package/dist/orchestrators/snapshot/capture-command.mjs.map +0 -1
- package/dist/orchestrators/snapshot/pending-marker.mjs +0 -99
- package/dist/orchestrators/snapshot/pending-marker.mjs.map +0 -1
- package/dist/orchestrators/snapshot/recover-pending.mjs +0 -223
- package/dist/orchestrators/snapshot/recover-pending.mjs.map +0 -1
- package/dist/orchestrators/snapshot/state-document.d.mts +0 -1
- package/dist/orchestrators/snapshot/state-document.mjs +0 -58
- package/dist/orchestrators/snapshot/state-document.mjs.map +0 -1
- package/dist/plugins/account/spans.mjs +0 -16
- package/dist/plugins/account/spans.mjs.map +0 -1
- package/dist/plugins/account/variants/env.mjs +0 -24
- package/dist/plugins/account/variants/env.mjs.map +0 -1
- package/dist/plugins/account/variants/inline.mjs +0 -13
- package/dist/plugins/account/variants/inline.mjs.map +0 -1
- package/dist/plugins/account/variants/keystore.mjs +0 -91
- package/dist/plugins/account/variants/keystore.mjs.map +0 -1
- package/dist/plugins/action/spans.mjs +0 -11
- package/dist/plugins/action/spans.mjs.map +0 -1
- package/dist/plugins/coin/spans.mjs +0 -20
- package/dist/plugins/coin/spans.mjs.map +0 -1
- package/dist/plugins/deepbook/spans.mjs +0 -18
- package/dist/plugins/deepbook/spans.mjs.map +0 -1
- package/dist/plugins/faucet/spans.mjs +0 -12
- package/dist/plugins/faucet/spans.mjs.map +0 -1
- package/dist/plugins/package/spans.mjs +0 -14
- package/dist/plugins/package/spans.mjs.map +0 -1
- package/dist/plugins/postgres/codegen.mjs +0 -42
- package/dist/plugins/postgres/codegen.mjs.map +0 -1
- package/dist/plugins/postgres/connection.d.mts +0 -33
- package/dist/plugins/postgres/connection.mjs.map +0 -1
- package/dist/plugins/postgres/db-ensure.mjs.map +0 -1
- package/dist/plugins/postgres/errors.d.mts +0 -60
- package/dist/plugins/postgres/errors.mjs +0 -29
- package/dist/plugins/postgres/errors.mjs.map +0 -1
- package/dist/plugins/postgres/index.d.mts +0 -37
- package/dist/plugins/postgres/index.mjs +0 -68
- package/dist/plugins/postgres/index.mjs.map +0 -1
- package/dist/plugins/postgres/routable.mjs +0 -33
- package/dist/plugins/postgres/routable.mjs.map +0 -1
- package/dist/plugins/postgres/service.d.mts +0 -50
- package/dist/plugins/postgres/service.mjs +0 -179
- package/dist/plugins/postgres/service.mjs.map +0 -1
- package/dist/plugins/postgres/snapshot.mjs +0 -32
- package/dist/plugins/postgres/snapshot.mjs.map +0 -1
- package/dist/plugins/postgres/spans.mjs +0 -11
- package/dist/plugins/postgres/spans.mjs.map +0 -1
- package/dist/plugins/seal/spans.mjs +0 -18
- package/dist/plugins/seal/spans.mjs.map +0 -1
- package/dist/plugins/sui/spans.mjs +0 -17
- package/dist/plugins/sui/spans.mjs.map +0 -1
- package/dist/plugins/wallet/spans.mjs +0 -22
- package/dist/plugins/wallet/spans.mjs.map +0 -1
- package/dist/plugins/walrus/registry-publish.d.mts +0 -24
- package/dist/plugins/walrus/spans.mjs +0 -18
- package/dist/plugins/walrus/spans.mjs.map +0 -1
- package/dist/runtime/docker/logs.d.mts +0 -1
- package/dist/runtime/docker/logs.mjs +0 -34
- package/dist/runtime/docker/logs.mjs.map +0 -1
- package/dist/substrate/runtime/artifact-publisher/index.mjs +0 -86
- package/dist/substrate/runtime/artifact-publisher/index.mjs.map +0 -1
- package/dist/substrate/runtime/capability-sinks/index.d.mts +0 -1
- package/dist/substrate/runtime/capability-sinks/index.mjs +0 -3
- package/dist/substrate/runtime/capability-sinks/layer.d.mts +0 -1
- package/dist/substrate/runtime/capability-sinks/layer.mjs +0 -31
- package/dist/substrate/runtime/capability-sinks/layer.mjs.map +0 -1
- package/dist/substrate/runtime/capability-sinks/service.d.mts +0 -95
- package/dist/substrate/runtime/capability-sinks/service.mjs +0 -69
- package/dist/substrate/runtime/capability-sinks/service.mjs.map +0 -1
- package/dist/substrate/runtime/cross-process/lock.d.mts +0 -1
- package/dist/substrate/runtime/cross-process/lock.mjs +0 -23
- package/dist/substrate/runtime/cross-process/lock.mjs.map +0 -1
- package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs +0 -113
- package/dist/substrate/runtime/cross-process/snapshot-reservation.mjs.map +0 -1
- package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs +0 -31
- package/dist/substrate/runtime/lifecycle/lifecycle-fact.mjs.map +0 -1
- package/dist/substrate/runtime/observability/formatter-registry.d.mts +0 -1
- package/dist/substrate/runtime/observability/formatter-registry.mjs +0 -48
- package/dist/substrate/runtime/observability/formatter-registry.mjs.map +0 -1
- package/dist/substrate/runtime/observability/span-store.d.mts +0 -1
- package/dist/substrate/runtime/observability/span-store.mjs +0 -110
- package/dist/substrate/runtime/observability/span-store.mjs.map +0 -1
- package/dist/substrate/runtime/observability/spans.d.mts +0 -1
- package/dist/substrate/runtime/observability/spans.mjs +0 -87
- package/dist/substrate/runtime/observability/spans.mjs.map +0 -1
- package/dist/substrate/runtime/projection/index.mjs +0 -4
- package/dist/substrate/runtime/projection/persisted.mjs +0 -213
- package/dist/substrate/runtime/projection/persisted.mjs.map +0 -1
- package/dist/substrate/runtime/scoped-multimap/service.mjs +0 -52
- package/dist/substrate/runtime/scoped-multimap/service.mjs.map +0 -1
- package/dist/substrate/runtime/scoped-ref-map/index.mjs +0 -2
- package/dist/substrate/runtime/scoped-ref-map/service.mjs +0 -83
- package/dist/substrate/runtime/scoped-ref-map/service.mjs.map +0 -1
- package/dist/substrate/runtime/state-store/index.mjs +0 -3
- package/dist/substrate/runtime/state-store/schema.d.mts +0 -1
- package/dist/substrate/runtime/state-store/schema.mjs +0 -41
- package/dist/substrate/runtime/state-store/schema.mjs.map +0 -1
- package/dist/substrate/runtime/state-store/service.d.mts +0 -1
- package/dist/substrate/runtime/state-store/service.mjs +0 -145
- package/dist/substrate/runtime/state-store/service.mjs.map +0 -1
- package/dist/substrate/runtime/sui-execute/index.mjs.map +0 -1
- package/dist/substrate/runtime/sui-execute/sign-and-dispatch.mjs.map +0 -1
- package/dist/substrate/runtime/sui-ledger/object-ref.mjs.map +0 -1
- package/dist/substrate/runtime/sui-move-build/index.mjs.map +0 -1
- package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs +0 -151
- package/dist/substrate/runtime/supervisor/dispatch-contributions.mjs.map +0 -1
- package/dist/substrate/state-store.d.mts +0 -1
- /package/dist/orchestrators/{snapshot/pending-marker.d.mts → codegen/id-config.d.mts} +0 -0
- /package/dist/orchestrators/snapshot/{recover-pending.d.mts → interrupted-restore.d.mts} +0 -0
- /package/dist/{substrate/runtime/sui-execute → plugins/sui/exec}/sign-and-dispatch.d.mts +0 -0
- /package/dist/plugins/{postgres/snapshot.d.mts → sui/ledger/object-ref.d.mts} +0 -0
- /package/dist/{substrate/runtime/sui-move-build → plugins/sui/move}/index.d.mts +0 -0
- /package/dist/substrate/runtime/{state-store/index.d.mts → reconcile/graph.d.mts} +0 -0
- /package/dist/substrate/runtime/{cross-process/snapshot-reservation.d.mts → supervisor/contribution-dispatcher.d.mts} +0 -0
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import { StackPathsService } from "../paths.mjs";
|
|
2
|
-
import { StateStoreError } from "../errors.mjs";
|
|
3
|
-
import { atomicWriteJson } from "../atomic-write.mjs";
|
|
4
|
-
import { decodeJsonText } from "../runtime-decode.mjs";
|
|
5
|
-
import { StateDocument, emptyDocument } from "./schema.mjs";
|
|
6
|
-
import { CrossProcessLock } from "../cross-process/lock.mjs";
|
|
7
|
-
import { Context, Effect, FileSystem, Layer, Ref } from "effect";
|
|
8
|
-
//#region src/substrate/runtime/state-store/service.ts
|
|
9
|
-
/**
|
|
10
|
-
* The substrate-internal state-store service. The
|
|
11
|
-
* `StateStore` interface re-exported from `substrate/state-store.ts`
|
|
12
|
-
* is the user-facing shape; this is the wired-up implementation.
|
|
13
|
-
*/
|
|
14
|
-
var StateStoreService = class extends Context.Service()("@devstack/substrate/StateStore") {};
|
|
15
|
-
/**
|
|
16
|
-
* Parse `StateKey<V>` (`<pluginKey>/<suffix>`) into its two parts.
|
|
17
|
-
* The key invariant from `substrate/state-store.ts`'s
|
|
18
|
-
* `defineStateKey` is the single `/` separator; we cope with
|
|
19
|
-
* suffix-contains-slash by splitting on the FIRST `/`.
|
|
20
|
-
*/
|
|
21
|
-
const splitKey = (key) => {
|
|
22
|
-
const i = key.indexOf("/");
|
|
23
|
-
if (i < 0) return {
|
|
24
|
-
plugin: "__malformed__",
|
|
25
|
-
suffix: key
|
|
26
|
-
};
|
|
27
|
-
return {
|
|
28
|
-
plugin: key.slice(0, i),
|
|
29
|
-
suffix: key.slice(i + 1)
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
/** Read+decode the document. Missing file → empty document. */
|
|
33
|
-
const readDocument = Effect.gen(function* () {
|
|
34
|
-
const fs = yield* FileSystem.FileSystem;
|
|
35
|
-
const paths = yield* StackPathsService;
|
|
36
|
-
if (!(yield* fs.exists(paths.stateFile).pipe(Effect.catch((cause) => Effect.fail(new StateStoreError({
|
|
37
|
-
reason: "io-failed",
|
|
38
|
-
detail: `failed to stat state file: ${paths.stateFile}`,
|
|
39
|
-
cause
|
|
40
|
-
})))))) return emptyDocument;
|
|
41
|
-
return yield* decodeJsonText(StateDocument, yield* fs.readFileString(paths.stateFile).pipe(Effect.catch((cause) => Effect.fail(new StateStoreError({
|
|
42
|
-
reason: "io-failed",
|
|
43
|
-
detail: `failed to read state file: ${paths.stateFile}`,
|
|
44
|
-
cause
|
|
45
|
-
})))), {
|
|
46
|
-
source: paths.stateFile,
|
|
47
|
-
mkError: (issue) => new StateStoreError({
|
|
48
|
-
reason: "corruption",
|
|
49
|
-
detail: issue.message === "failed to parse JSON" ? `state file is not valid JSON: ${paths.stateFile}` : `state file failed schema decode: ${paths.stateFile}`,
|
|
50
|
-
cause: issue.cause
|
|
51
|
-
})
|
|
52
|
-
});
|
|
53
|
-
}).pipe(Effect.withSpan("substrate.stateStore.read"));
|
|
54
|
-
/** Write+encode the document atomically. */
|
|
55
|
-
const writeDocument = (doc) => Effect.gen(function* () {
|
|
56
|
-
const paths = yield* StackPathsService;
|
|
57
|
-
yield* atomicWriteJson(paths.stateFile, StateDocument, doc).pipe(Effect.catch((cause) => Effect.fail(new StateStoreError({
|
|
58
|
-
reason: "io-failed",
|
|
59
|
-
detail: `atomic write failed: ${paths.stateFile}`,
|
|
60
|
-
cause
|
|
61
|
-
}))));
|
|
62
|
-
}).pipe(Effect.withSpan("substrate.stateStore.write"));
|
|
63
|
-
Layer.effect(StateStoreService, Effect.gen(function* () {
|
|
64
|
-
const lock = yield* CrossProcessLock;
|
|
65
|
-
const fs = yield* FileSystem.FileSystem;
|
|
66
|
-
const paths = yield* StackPathsService;
|
|
67
|
-
const provideEnv = (effect) => effect.pipe(Effect.provideService(FileSystem.FileSystem, fs), Effect.provideService(StackPathsService, paths));
|
|
68
|
-
const initial = yield* provideEnv(readDocument);
|
|
69
|
-
const cache = yield* Ref.make(initial);
|
|
70
|
-
const get = (key) => Effect.gen(function* () {
|
|
71
|
-
const doc = yield* Ref.get(cache);
|
|
72
|
-
const { plugin, suffix } = splitKey(key);
|
|
73
|
-
const entry = doc.plugins[plugin]?.[suffix];
|
|
74
|
-
if (!entry) return null;
|
|
75
|
-
if (entry.state === "tombstone") return null;
|
|
76
|
-
return entry.value;
|
|
77
|
-
});
|
|
78
|
-
const mapLockErrors = (eff) => eff.pipe(Effect.catchTags({
|
|
79
|
-
StackLockTimeoutError: (e) => Effect.fail(new StateStoreError({
|
|
80
|
-
reason: "lock-contention",
|
|
81
|
-
detail: `state-store write blocked: peer holds ${e.path} (waited ${e.waitedMillis}ms)`,
|
|
82
|
-
cause: e
|
|
83
|
-
})),
|
|
84
|
-
StackLockIoError: (e) => Effect.fail(new StateStoreError({
|
|
85
|
-
reason: "io-failed",
|
|
86
|
-
detail: `state-store lock IO error on ${e.path}`,
|
|
87
|
-
cause: e.cause
|
|
88
|
-
}))
|
|
89
|
-
}));
|
|
90
|
-
const set = (key, value) => mapLockErrors(lock.withLock(provideEnv(Effect.uninterruptible(Effect.gen(function* () {
|
|
91
|
-
const fresh = yield* readDocument;
|
|
92
|
-
const { plugin, suffix } = splitKey(key);
|
|
93
|
-
const next = {
|
|
94
|
-
version: 1,
|
|
95
|
-
plugins: {
|
|
96
|
-
...fresh.plugins,
|
|
97
|
-
[plugin]: {
|
|
98
|
-
...fresh.plugins[plugin],
|
|
99
|
-
[suffix]: {
|
|
100
|
-
state: "present",
|
|
101
|
-
value,
|
|
102
|
-
updatedAt: Date.now()
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
};
|
|
107
|
-
yield* writeDocument(next);
|
|
108
|
-
yield* Ref.set(cache, next);
|
|
109
|
-
})))));
|
|
110
|
-
const del = (key) => mapLockErrors(lock.withLock(provideEnv(Effect.uninterruptible(Effect.gen(function* () {
|
|
111
|
-
const fresh = yield* readDocument;
|
|
112
|
-
const { plugin, suffix } = splitKey(key);
|
|
113
|
-
const next = {
|
|
114
|
-
version: 1,
|
|
115
|
-
plugins: {
|
|
116
|
-
...fresh.plugins,
|
|
117
|
-
[plugin]: {
|
|
118
|
-
...fresh.plugins[plugin],
|
|
119
|
-
[suffix]: {
|
|
120
|
-
state: "tombstone",
|
|
121
|
-
value: null,
|
|
122
|
-
updatedAt: Date.now()
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
}
|
|
126
|
-
};
|
|
127
|
-
yield* writeDocument(next);
|
|
128
|
-
yield* Ref.set(cache, next);
|
|
129
|
-
})))));
|
|
130
|
-
const listUnder = (prefix) => Effect.gen(function* () {
|
|
131
|
-
const ns = (yield* Ref.get(cache)).plugins[prefix];
|
|
132
|
-
if (!ns) return [];
|
|
133
|
-
return Object.entries(ns).filter(([, entry]) => entry.state === "present").map(([suffix]) => `${prefix}/${suffix}`);
|
|
134
|
-
});
|
|
135
|
-
return StateStoreService.of({
|
|
136
|
-
get,
|
|
137
|
-
set,
|
|
138
|
-
delete: del,
|
|
139
|
-
listUnder
|
|
140
|
-
});
|
|
141
|
-
}));
|
|
142
|
-
//#endregion
|
|
143
|
-
export { StateStoreService };
|
|
144
|
-
|
|
145
|
-
//# sourceMappingURL=service.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"service.mjs","names":[],"sources":["../../../../src/substrate/runtime/state-store/service.ts"],"sourcesContent":["// State-store implementation.\n//\n// Per-stack JSON file at `<runtime-root>/stacks/<stack>/state.json`.\n// Plugin-keyed namespacing; tombstone-vs-missing distinction;\n// atomic-write on every mutation; cross-process safety via the\n// injected lock.\n//\n// Tombstones:\n// - `get` on a tombstoned key returns `null` (same as missing) —\n// the type-level contract is \"absent\". The on-disk distinction\n// is preserved so snapshot/restore round-trips correctly\n// classify a deletion (tombstone) vs a never-written key\n// (missing). Inspectors can `peek` to see the discriminator;\n// normal plugin code never needs it.\n// - `delete` writes a tombstone (rather than deleting the field).\n// Two reasons:\n// (a) Snapshot equality is now precise — \"removed since\n// snapshot\" survives the round-trip.\n// (b) An interrupted writer never silently resurrects a\n// previously-deleted key (the present-record stays\n// tombstone-shaped until set() runs again).\n// - `wipe()` (full plugin namespace removal) IS a hard remove;\n// tombstones are field-grain, namespace-grain wipe is route-\n// grain.\n\nimport { Context, Effect, FileSystem, Layer, Ref } from 'effect';\n\nimport type { PluginKey } from '../../brand.ts';\nimport type { StateKey, StateStore } from '../../state-store.ts';\nimport { atomicWriteJson } from '../atomic-write.ts';\nimport { CrossProcessLock } from '../cross-process/lock.ts';\nimport type { StackLockIoError, StackLockTimeoutError } from '../cross-process/stack-lock.ts';\nimport { StateStoreError } from '../errors.ts';\nimport { StackPathsService } from '../paths.ts';\nimport { decodeJsonText } from '../runtime-decode.ts';\nimport { emptyDocument, StateDocument, type StateEntry } from './schema.ts';\n\n/**\n * The substrate-internal state-store service. The\n * `StateStore` interface re-exported from `substrate/state-store.ts`\n * is the user-facing shape; this is the wired-up implementation.\n */\nexport class StateStoreService extends Context.Service<StateStoreService, StateStore>()(\n\t'@devstack/substrate/StateStore',\n) {}\n\n/**\n * Parse `StateKey<V>` (`<pluginKey>/<suffix>`) into its two parts.\n * The key invariant from `substrate/state-store.ts`'s\n * `defineStateKey` is the single `/` separator; we cope with\n * suffix-contains-slash by splitting on the FIRST `/`.\n */\nconst splitKey = (key: string): { readonly plugin: string; readonly suffix: string } => {\n\tconst i = key.indexOf('/');\n\t// A key without `/` is programmer error (`defineStateKey`\n\t// always produces one). Fall back gracefully so we don't\n\t// hard-crash on a misuse — store the whole string under a\n\t// `__malformed__` namespace, surfaced on listUnder for the\n\t// authoring plugin to notice in dev.\n\tif (i < 0) return { plugin: '__malformed__', suffix: key };\n\treturn { plugin: key.slice(0, i), suffix: key.slice(i + 1) };\n};\n\n/** Read+decode the document. Missing file → empty document. */\nconst readDocument: Effect.Effect<\n\tStateDocument,\n\tStateStoreError,\n\tFileSystem.FileSystem | StackPathsService\n> = Effect.gen(function* () {\n\tconst fs = yield* FileSystem.FileSystem;\n\tconst paths = yield* StackPathsService;\n\tconst exists = yield* fs.exists(paths.stateFile).pipe(\n\t\tEffect.catch((cause) =>\n\t\t\tEffect.fail(\n\t\t\t\tnew StateStoreError({\n\t\t\t\t\treason: 'io-failed',\n\t\t\t\t\tdetail: `failed to stat state file: ${paths.stateFile}`,\n\t\t\t\t\tcause,\n\t\t\t\t}),\n\t\t\t),\n\t\t),\n\t);\n\tif (!exists) return emptyDocument;\n\tconst text = yield* fs.readFileString(paths.stateFile).pipe(\n\t\tEffect.catch((cause) =>\n\t\t\tEffect.fail(\n\t\t\t\tnew StateStoreError({\n\t\t\t\t\treason: 'io-failed',\n\t\t\t\t\tdetail: `failed to read state file: ${paths.stateFile}`,\n\t\t\t\t\tcause,\n\t\t\t\t}),\n\t\t\t),\n\t\t),\n\t);\n\treturn yield* decodeJsonText(StateDocument, text, {\n\t\tsource: paths.stateFile,\n\t\tmkError: (issue) =>\n\t\t\tnew StateStoreError({\n\t\t\t\treason: 'corruption',\n\t\t\t\tdetail:\n\t\t\t\t\tissue.message === 'failed to parse JSON'\n\t\t\t\t\t\t? `state file is not valid JSON: ${paths.stateFile}`\n\t\t\t\t\t\t: `state file failed schema decode: ${paths.stateFile}`,\n\t\t\t\tcause: issue.cause,\n\t\t\t}),\n\t});\n}).pipe(Effect.withSpan('substrate.stateStore.read'));\n\n/** Write+encode the document atomically. */\nconst writeDocument = (\n\tdoc: StateDocument,\n): Effect.Effect<void, StateStoreError, FileSystem.FileSystem | StackPathsService> =>\n\tEffect.gen(function* () {\n\t\tconst paths = yield* StackPathsService;\n\t\tyield* atomicWriteJson(paths.stateFile, StateDocument, doc).pipe(\n\t\t\tEffect.catch((cause) =>\n\t\t\t\tEffect.fail(\n\t\t\t\t\tnew StateStoreError({\n\t\t\t\t\t\treason: 'io-failed',\n\t\t\t\t\t\tdetail: `atomic write failed: ${paths.stateFile}`,\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t),\n\t\t);\n\t}).pipe(Effect.withSpan('substrate.stateStore.write'));\n\n/**\n * The state-store Layer. Caches the document in a process-local\n * `Ref` so reads after the first don't touch disk; every mutation\n * runs under the cross-process lock so foreign processes don't\n * trample our changes mid-flight.\n *\n * Cache semantics: the in-process `Ref` is the truth for in-process\n * readers; it is invalidated by re-reading inside the locked\n * mutation. This deliberately does NOT poll the file — if another\n * process writes between our reads, we'll observe the change on the\n * next `withLock` r-m-w (re-read inside the critical section).\n * Plugins that need \"see foreign writes\" must invoke `refresh`\n * (exposed for the supervisor / watch dispatcher).\n */\nexport const layerStateStore: Layer.Layer<\n\tStateStoreService,\n\tStateStoreError,\n\tFileSystem.FileSystem | StackPathsService | CrossProcessLock\n> = Layer.effect(\n\tStateStoreService,\n\tEffect.gen(function* () {\n\t\tconst lock = yield* CrossProcessLock;\n\t\tconst fs = yield* FileSystem.FileSystem;\n\t\tconst paths = yield* StackPathsService;\n\t\t// `readDocument` / `writeDocument` declare `FileSystem |\n\t\t// StackPathsService` requirements; we discharge both from the\n\t\t// Layer-level closure so the per-method Effects are `R = never`,\n\t\t// matching the `StateStore` contract.\n\t\tconst provideEnv = <A, E>(\n\t\t\teffect: Effect.Effect<A, E, FileSystem.FileSystem | StackPathsService>,\n\t\t): Effect.Effect<A, E> =>\n\t\t\teffect.pipe(\n\t\t\t\tEffect.provideService(FileSystem.FileSystem, fs),\n\t\t\t\tEffect.provideService(StackPathsService, paths),\n\t\t\t);\n\t\t// Prime the cache with the on-disk document. If decoding\n\t\t// fails at boot, we fail the Layer — the supervisor must\n\t\t// surface the corruption to the user (not silently re-init).\n\t\tconst initial = yield* provideEnv(readDocument);\n\t\tconst cache = yield* Ref.make(initial);\n\n\t\tconst get: StateStore['get'] = <V>(key: StateKey<V>) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst doc = yield* Ref.get(cache);\n\t\t\t\tconst { plugin, suffix } = splitKey(key);\n\t\t\t\tconst entry: StateEntry | undefined = doc.plugins[plugin]?.[suffix];\n\t\t\t\tif (!entry) return null;\n\t\t\t\tif (entry.state === 'tombstone') return null;\n\t\t\t\treturn entry.value as V;\n\t\t\t});\n\n\t\t// Map the lock's typed acquire failures onto our `lock-contention`\n\t\t// reason on `StateStoreError`. The `StateStore` contract already\n\t\t// advertises that mutation methods surface this reason — caller\n\t\t// recovery is the same shape as any other write failure (retry on\n\t\t// the next user action; surface in the supervisor cascade).\n\t\tconst mapLockErrors = <A, R>(\n\t\t\teff: Effect.Effect<A, StateStoreError | StackLockTimeoutError | StackLockIoError, R>,\n\t\t): Effect.Effect<A, StateStoreError, R> =>\n\t\t\teff.pipe(\n\t\t\t\tEffect.catchTags({\n\t\t\t\t\tStackLockTimeoutError: (e) =>\n\t\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\t\tnew StateStoreError({\n\t\t\t\t\t\t\t\treason: 'lock-contention',\n\t\t\t\t\t\t\t\tdetail: `state-store write blocked: peer holds ${e.path} (waited ${e.waitedMillis}ms)`,\n\t\t\t\t\t\t\t\tcause: e,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\tStackLockIoError: (e) =>\n\t\t\t\t\t\tEffect.fail(\n\t\t\t\t\t\t\tnew StateStoreError({\n\t\t\t\t\t\t\t\treason: 'io-failed',\n\t\t\t\t\t\t\t\tdetail: `state-store lock IO error on ${e.path}`,\n\t\t\t\t\t\t\t\tcause: e.cause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t}),\n\t\t\t);\n\n\t\tconst set: StateStore['set'] = <V>(key: StateKey<V>, value: V) =>\n\t\t\tmapLockErrors(\n\t\t\t\tlock.withLock(\n\t\t\t\t\tprovideEnv(\n\t\t\t\t\t\t// Uninterruptible: an interrupt landing between the\n\t\t\t\t\t\t// disk write and the cache update would leave the\n\t\t\t\t\t\t// in-process cache stale vs disk. The section is\n\t\t\t\t\t\t// short and already serialized by `withLock`, so\n\t\t\t\t\t\t// masking interruption here costs nothing and keeps\n\t\t\t\t\t\t// cache/disk coherent.\n\t\t\t\t\t\tEffect.uninterruptible(\n\t\t\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\t\t\t// Re-read INSIDE the lock so we don't clobber\n\t\t\t\t\t\t\t\t// foreign writes that landed since our prime.\n\t\t\t\t\t\t\t\tconst fresh = yield* readDocument;\n\t\t\t\t\t\t\t\tconst { plugin, suffix } = splitKey(key);\n\t\t\t\t\t\t\t\tconst next: StateDocument = {\n\t\t\t\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t\t\t\t...fresh.plugins,\n\t\t\t\t\t\t\t\t\t\t[plugin]: {\n\t\t\t\t\t\t\t\t\t\t\t...fresh.plugins[plugin],\n\t\t\t\t\t\t\t\t\t\t\t[suffix]: {\n\t\t\t\t\t\t\t\t\t\t\t\tstate: 'present',\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: value as unknown,\n\t\t\t\t\t\t\t\t\t\t\t\tupdatedAt: Date.now(),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tyield* writeDocument(next);\n\t\t\t\t\t\t\t\tyield* Ref.set(cache, next);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\tconst del: StateStore['delete'] = <V>(key: StateKey<V>) =>\n\t\t\tmapLockErrors(\n\t\t\t\tlock.withLock(\n\t\t\t\t\tprovideEnv(\n\t\t\t\t\t\t// Uninterruptible for the same cache/disk coherence\n\t\t\t\t\t\t// reason as `set` — see the note there.\n\t\t\t\t\t\tEffect.uninterruptible(\n\t\t\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\t\t\tconst fresh = yield* readDocument;\n\t\t\t\t\t\t\t\tconst { plugin, suffix } = splitKey(key);\n\t\t\t\t\t\t\t\t// Tombstone-write — preserves the\n\t\t\t\t\t\t\t\t// \"deleted-since\" record across snapshots.\n\t\t\t\t\t\t\t\tconst next: StateDocument = {\n\t\t\t\t\t\t\t\t\tversion: 1,\n\t\t\t\t\t\t\t\t\tplugins: {\n\t\t\t\t\t\t\t\t\t\t...fresh.plugins,\n\t\t\t\t\t\t\t\t\t\t[plugin]: {\n\t\t\t\t\t\t\t\t\t\t\t...fresh.plugins[plugin],\n\t\t\t\t\t\t\t\t\t\t\t[suffix]: {\n\t\t\t\t\t\t\t\t\t\t\t\tstate: 'tombstone',\n\t\t\t\t\t\t\t\t\t\t\t\tvalue: null,\n\t\t\t\t\t\t\t\t\t\t\t\tupdatedAt: Date.now(),\n\t\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t\t},\n\t\t\t\t\t\t\t\t};\n\t\t\t\t\t\t\t\tyield* writeDocument(next);\n\t\t\t\t\t\t\t\tyield* Ref.set(cache, next);\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t),\n\t\t\t\t\t),\n\t\t\t\t),\n\t\t\t);\n\n\t\tconst listUnder: StateStore['listUnder'] = (prefix: PluginKey) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst doc = yield* Ref.get(cache);\n\t\t\t\tconst ns = doc.plugins[prefix];\n\t\t\t\tif (!ns) return [];\n\t\t\t\t// Skip tombstones from `listUnder` — they're\n\t\t\t\t// internally observable via `peek` but the public\n\t\t\t\t// \"what keys are present?\" view hides them.\n\t\t\t\treturn Object.entries(ns)\n\t\t\t\t\t.filter(([, entry]) => entry.state === 'present')\n\t\t\t\t\t.map(([suffix]) => `${prefix}/${suffix}`);\n\t\t\t});\n\n\t\treturn StateStoreService.of({\n\t\t\tget,\n\t\t\tset,\n\t\t\tdelete: del,\n\t\t\tlistUnder,\n\t\t});\n\t}),\n);\n"],"mappings":";;;;;;;;;;;;;AA0CA,IAAa,oBAAb,cAAuC,QAAQ,SAAwC,CACtF,iCACA,CAAC;;;;;;;AAQF,MAAM,YAAY,QAAsE;CACvF,MAAM,IAAI,IAAI,QAAQ,IAAI;AAM1B,KAAI,IAAI,EAAG,QAAO;EAAE,QAAQ;EAAiB,QAAQ;EAAK;AAC1D,QAAO;EAAE,QAAQ,IAAI,MAAM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AS,IAAI;EAGxC,MAAM,OAAsB;GAC3B,SAAS;GACT,SAAS;IACR,GAAG,MAAM;KACR,SAAS;KACT,GAAG,MAAM,QAAQ;MAChB,SAAS;MACT,OAAO;MACP,OAAO;MACP,WAAW,KAAK,KAAK;MACrB;KACD;IACD;GACD;AACD,SAAO,cAAc,KAAK;AAC1B,SAAO,IAAI,IAAI,OAAO,KAAK;GAC1B,CACF,CACD,CACD,CACD;CAEF,MAAM,aAAsC,WAC3C,OAAO,IAAI,aAAa;EAEvB,MAAM,MAAK,OADQ,IAAI,IAAI,MAAM,EAClB,QAAQ;AACvB,MAAI,CAAC,GAAI,QAAO,EAAE;AAIlB,SAAO,OAAO,QAAQ,GAAG,CACvB,QAAQ,GAAG,WAAW,MAAM,UAAU,UAAU,CAChD,KAAK,CAAC,YAAY,GAAG,OAAO,GAAG,SAAS;GACzC;AAEH,QAAO,kBAAkB,GAAG;EAC3B;EACA;EACA,QAAQ;EACR;EACA,CAAC;EACD,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/substrate/runtime/sui-execute/index.ts"],"sourcesContent":["// sui-execute — substrate helper for the Sui-SDK transaction\n// roundtrip.\n//\n// ARCHITECTURE NOTE — substrate-name-awareness escape hatch:\n//\n// This module is the ONE blessed substrate-side Sui-aware module.\n// The substrate is otherwise strictly name-blind (see ARCHITECTURE.md\n// §\"Substrate name-blindness\"), but the \"build → sign → execute →\n// wait → project\" roundtrip is duplicated verbatim across\n// `plugins/package/publish-executor.ts` and `plugins/action/execute.ts`\n// — ~80% identical line-for-line — and the same shape is needed for\n// `seal` (deploy + key-server registration), `coin.mint`, `action`,\n// and `deepbook` (publish + pool creation).\n//\n// Lifting the dispatch here gives every Sui-tx plugin one well-tested\n// surface and surfaces the SDK-envelope shape decisions (`include:\n// { effects, objectTypes }`, `$kind` projection, `FailedTransaction`\n// detection) ONCE.\n//\n// Boundary discipline:\n//\n// - This module is L1-adjacent: it lives under `substrate/runtime/`\n// but consumes opaque shapes (`unknown` SDK client; opaque\n// signer closure). It does NOT import from `plugins/sui/*` or\n// `@mysten/sui/*` — the caller passes in the resolved SDK ref\n// and the signer; the substrate just orchestrates the roundtrip.\n// - The return shape (`ExecutedReceipt`) is name-blind: a flat\n// digest + a uniform `objectChanges` array. Callers map to their\n// domain shape (PublishReceipt, ActionReceipt, MintReceipt, …).\n// - Transport / protocol failures (serialize, sign, execute, no-digest,\n// wait-for-finality) route through `SuiExecuteError` whose `phase`\n// discriminates the failing step. Callers map to their plugin's\n// phase taxonomy in their produce body's `mapError` closure.\n// - On-chain `FailedTransaction` is a RETURN-CHANNEL variant of\n// `SuiExecuteResult`, NOT an error — mirrors `account.signAndExecute`\n// and STYLE_GUIDE §2's return-channel discriminated-union rule.\n// Callers dispatch on `$kind` after the call.\n\nimport { Effect, Schema, Scope } from 'effect';\nimport type { ClientWithCoreApi } from '@mysten/sui/client';\n\nimport { formatUnknownError } from '../format-unknown-error.ts';\n\n// ---------------------------------------------------------------------------\n// Errors — substrate-style Schema.TaggedErrorClass\n// ---------------------------------------------------------------------------\n\n/** Tagged failure during one step of the Sui-tx roundtrip. `phase`\n * discriminates which step failed so callers can map to their\n * plugin's phase taxonomy (publish-tx, sign, parse, …) without\n * losing the original cause.\n *\n * On-chain `FailedTransaction` is NOT a phase here — it surfaces as\n * the `$kind: 'FailedTransaction'` variant of `SuiExecuteResult`\n * (return channel). Only transport / protocol failures live in this\n * taxonomy. See STYLE_GUIDE §2. */\nexport class SuiExecuteError extends Schema.TaggedErrorClass<SuiExecuteError>()('SuiExecuteError', {\n\tphase: Schema.Literals(['serialize', 'sign', 'execute', 'no-digest', 'wait-for-finality']),\n\tsignerName: Schema.String,\n\tsignerAddress: Schema.String,\n\tmessage: Schema.String,\n\t/** Echoed digest when the SDK returned one but a later step\n\t * failed — surfaces in cause-walker output. */\n\tdigest: Schema.optional(Schema.String),\n\tcause: Schema.optional(Schema.Defect),\n}) {}\n\n// ---------------------------------------------------------------------------\n// Inputs / outputs — opaque at the substrate boundary\n// ---------------------------------------------------------------------------\n\n/** The SDK client this helper drives. Accepts any `ClientWithCoreApi`\n * (the published cross-transport surface from `@mysten/sui/client`).\n * `executeSuiTx` calls `client.core.executeTransaction` /\n * `client.core.waitForTransaction` per STYLE_GUIDE §16. */\nexport type SuiExecuteClient = ClientWithCoreApi;\n\n/** Serialised transaction-build callback. Returns the BCS bytes ready\n * for signing. The caller owns the `Transaction` construction — the\n * substrate does not import `@mysten/sui/transactions` — and resolves\n * it via `Transaction.build({ client })`. */\nexport type SerializedTxBuilder = () => Promise<Uint8Array>;\n\nexport interface TransactionSignerScope<SignError = unknown> {\n\treadonly signTransaction: (\n\t\ttx: Uint8Array,\n\t) => Effect.Effect<{ readonly bytes: string; readonly signature: string }, SignError>;\n}\n\n/** Resolved signer — narrow slice of `AccountValue`. */\nexport interface ResolvedSigner {\n\treadonly name: string;\n\treadonly address: string;\n\treadonly signTransaction: (\n\t\ttx: Uint8Array,\n\t) => Effect.Effect<{ readonly bytes: string; readonly signature: string }, unknown>;\n\treadonly withTransactionSigner: <A, E, R>(\n\t\tbody: (signer: TransactionSignerScope) => Effect.Effect<A, E, R>,\n\t) => Effect.Effect<A, E, R>;\n}\n\n/** Flat per-object change record. Mirrors the union of fields that\n * `PublishObjectChange` (package) and `ActionObjectChange` (action)\n * expose so callers can pick whichever subset they surface. */\nexport interface ExecutedObjectChange {\n\treadonly objectId: string;\n\treadonly objectType?: string;\n\treadonly outputState?: string;\n\treadonly idOperation?: string;\n}\n\n/** Result of one successful execute round. Callers map this to their\n * domain shape (PublishReceipt, ActionReceipt, MintReceipt, …). */\nexport interface ExecutedReceipt {\n\treadonly digest: string;\n\treadonly objectChanges: ReadonlyArray<ExecutedObjectChange>;\n}\n\n/** On-chain failure projection. The transaction was delivered +\n * executed by the validator but the on-chain execution failed.\n * Carries the digest (for log correlation) plus the validator's\n * stringified error when one was attached. `executionError` is\n * omitted when the SDK returns no message (STYLE_GUIDE §5: no\n * sentinel placeholders at resolved-value surfaces). An envelope\n * without a digest fails at projection with\n * `SuiExecuteError(phase: 'no-digest')`.\n *\n * This is the single source of truth for the on-chain-failure shape\n * across the devstack: `account.SignAndExecuteResult`'s\n * `FailedTransaction` variant carries it directly; every plugin that\n * renders one of these failures into a user-facing error message goes\n * through `formatExecutedFailure` (below). */\nexport interface ExecutedFailure {\n\treadonly digest: string;\n\treadonly executionError?: string;\n}\n\n/** Render the canonical \"digest + executionError-or-noted-absent\" tail\n * used by every plugin's `FailedTransaction` surface. Pure projection;\n * does not throw.\n *\n * Used at the call site as e.g.\n * `\\`seal publish ... ${formatExecutedFailure(result.FailedTransaction)}\\``.\n * Centralising the wording means future tweaks propagate uniformly\n * across the seal / coin / walrus / deepbook / action / package\n * surfaces. */\nexport const formatExecutedFailure = (failure: ExecutedFailure): string =>\n\tfailure.executionError !== undefined\n\t\t? `at ${failure.digest}: ${failure.executionError}`\n\t\t: `at ${failure.digest} (no validator error attached)`;\n\n/** Outcome of `executeSuiTx`. Mirrors the SDK's discriminated\n * `SuiClientTypes.TransactionResult` shape — on-chain failures are a\n * RETURN VALUE (callers dispatch on `$kind`), NOT an error. Only\n * transport / protocol failures (sign refused, RPC unreachable,\n * finality wait broke, no digest) surface through `SuiExecuteError`.\n * See STYLE_GUIDE §2 for the return-channel discipline this matches. */\nexport type SuiExecuteResult =\n\t| { readonly $kind: 'Transaction'; readonly Transaction: ExecutedReceipt }\n\t| { readonly $kind: 'FailedTransaction'; readonly FailedTransaction: ExecutedFailure };\n\n// ---------------------------------------------------------------------------\n// SDK envelope projection (matches publish-executor + action.execute)\n// ---------------------------------------------------------------------------\n\ninterface RawExecuteEnvelope {\n\treadonly $kind?: 'Transaction' | 'FailedTransaction';\n\treadonly Transaction?: {\n\t\treadonly digest?: string;\n\t\treadonly effects?: {\n\t\t\treadonly changedObjects?: ReadonlyArray<{\n\t\t\t\treadonly objectId?: string;\n\t\t\t\treadonly outputState?: string;\n\t\t\t\treadonly idOperation?: string;\n\t\t\t}>;\n\t\t};\n\t\treadonly objectTypes?: Readonly<Record<string, string>>;\n\t};\n\treadonly FailedTransaction?: {\n\t\treadonly digest?: string;\n\t\treadonly status?: { readonly error?: string };\n\t};\n}\n\n/** Pull the digest out of a raw `executeTransaction` envelope without\n * committing to success vs on-chain failure. `FailedTransaction`\n * carries its digest under a sibling key, so callers that only need\n * the digest (impersonate / one-shot dispatch paths that don't run\n * the full `executeSuiTx` projection) read it through this projector\n * rather than re-deriving the `$kind`-branching shape inline.\n * Returns `undefined` for a malformed envelope; callers decide\n * whether a missing digest is a failure. */\nexport const extractExecuteDigest = (raw: unknown): string | undefined => {\n\tconst env = raw as RawExecuteEnvelope;\n\treturn env.$kind === 'FailedTransaction'\n\t\t? env.FailedTransaction?.digest\n\t\t: env.Transaction?.digest;\n};\n\n// ---------------------------------------------------------------------------\n// The helper\n// ---------------------------------------------------------------------------\n\n/** Drive the serialize → sign → execute → wait → project pipeline.\n *\n * The caller passes:\n * - `client`: an opaque SDK client exposing `executeTransaction` +\n * `waitForTransaction` (matches the cast in both existing\n * duplicates).\n * - `signer`: a `ResolvedSigner` slice with an account-owned\n * transaction scope. The build/sign/execute/wait pipeline runs\n * inside that scope so gas/object-version resolution cannot race\n * another transaction from the same address.\n * - `build`: a closure returning the serialised tx bytes (the\n * caller constructed the `Transaction` and resolved gas via\n * `tx.build({ client })`).\n * - `awaitFinality`: opt-out for the `waitForTransaction` step.\n * Defaults to `true`. Some callers (action ready-probe) need it;\n * others (mode-local publish ready probe path) wait separately\n * via `getObject` polling and can pass `false`.\n *\n * Returns a `SuiExecuteResult` discriminated union — callers dispatch\n * on `$kind` to distinguish on-chain success (`'Transaction'`) from\n * on-chain rejection (`'FailedTransaction'`). Transport / protocol\n * failures (serialize, sign, execute, no-digest, wait-for-finality)\n * surface as `SuiExecuteError` with a `phase` discriminator the\n * caller maps to its plugin's phase taxonomy.\n */\nexport const executeSuiTx = (params: {\n\treadonly client: SuiExecuteClient;\n\treadonly signer: ResolvedSigner;\n\treadonly build: SerializedTxBuilder;\n\treadonly awaitFinality?: boolean;\n}): Effect.Effect<SuiExecuteResult, SuiExecuteError, Scope.Scope> =>\n\tparams.signer\n\t\t.withTransactionSigner((lockedSigner) =>\n\t\t\tEffect.gen(function* () {\n\t\t\t\tconst { client, signer, build } = params;\n\t\t\t\tconst awaitFinality = params.awaitFinality ?? true;\n\n\t\t\t\t// 1. Serialise the transaction. Failures inside the build\n\t\t\t\t// closure (e.g. `Transaction.build({ client })` rejection)\n\t\t\t\t// surface as `phase: 'serialize'` so callers can attribute\n\t\t\t\t// them at the call site.\n\t\t\t\tconst txBytes = yield* Effect.tryPromise({\n\t\t\t\t\ttry: () => build(),\n\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\tnew SuiExecuteError({\n\t\t\t\t\t\t\tphase: 'serialize',\n\t\t\t\t\t\t\tsignerName: signer.name,\n\t\t\t\t\t\t\tsignerAddress: signer.address,\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`Transaction.build failed for signer '${signer.name}' ` +\n\t\t\t\t\t\t\t\t`(address=${signer.address}): ` +\n\t\t\t\t\t\t\t\tformatUnknownError(cause),\n\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t}),\n\t\t\t\t});\n\n\t\t\t\t// 2. Sign with the resolved signer. The signer's own typed\n\t\t\t\t// error surfaces in `cause`; we collapse to `phase: 'sign'`\n\t\t\t\t// so the cascade-formatter can walk the cause chain.\n\t\t\t\tconst signed = yield* lockedSigner.signTransaction(txBytes).pipe(\n\t\t\t\t\tEffect.mapError(\n\t\t\t\t\t\t(cause) =>\n\t\t\t\t\t\t\tnew SuiExecuteError({\n\t\t\t\t\t\t\t\tphase: 'sign',\n\t\t\t\t\t\t\t\tsignerName: signer.name,\n\t\t\t\t\t\t\t\tsignerAddress: signer.address,\n\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t`signer.signTransaction failed for '${signer.name}' ` +\n\t\t\t\t\t\t\t\t\t`(address=${signer.address}).`,\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t),\n\t\t\t\t);\n\n\t\t\t\t// 3. Execute via the SDK. We always request `effects: true` and\n\t\t\t\t// `objectTypes: true` because every existing caller needs\n\t\t\t\t// `changedObjects` + types to project to its domain shape.\n\t\t\t\tconst raw = yield* Effect.tryPromise({\n\t\t\t\t\ttry: () =>\n\t\t\t\t\t\tclient.core.executeTransaction({\n\t\t\t\t\t\t\ttransaction: txBytes,\n\t\t\t\t\t\t\tsignatures: [signed.signature],\n\t\t\t\t\t\t\tinclude: { effects: true, objectTypes: true },\n\t\t\t\t\t\t}),\n\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\tnew SuiExecuteError({\n\t\t\t\t\t\t\tphase: 'execute',\n\t\t\t\t\t\t\tsignerName: signer.name,\n\t\t\t\t\t\t\tsignerAddress: signer.address,\n\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t`executeTransaction rejected for signer '${signer.name}': ` +\n\t\t\t\t\t\t\t\tformatUnknownError(cause),\n\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t}),\n\t\t\t\t});\n\n\t\t\t\t// 4. Project the envelope. `$kind === 'FailedTransaction'`\n\t\t\t\t// surfaces as a return-channel variant — on-chain\n\t\t\t\t// rejection is a normal outcome, NOT a transport failure\n\t\t\t\t// (STYLE_GUIDE §2). Callers dispatch on `$kind` and map\n\t\t\t\t// to their plugin's on-chain-failure shape.\n\t\t\t\tconst env = raw as RawExecuteEnvelope;\n\t\t\t\tif (env.$kind === 'FailedTransaction') {\n\t\t\t\t\tconst failedDigest = env.FailedTransaction?.digest;\n\t\t\t\t\tif (failedDigest === undefined) {\n\t\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\t\tnew SuiExecuteError({\n\t\t\t\t\t\t\t\tphase: 'no-digest',\n\t\t\t\t\t\t\t\tsignerName: signer.name,\n\t\t\t\t\t\t\t\tsignerAddress: signer.address,\n\t\t\t\t\t\t\t\tmessage:\n\t\t\t\t\t\t\t\t\t`executeTransaction returned FailedTransaction with no digest. ` +\n\t\t\t\t\t\t\t\t\t`Raw=${JSON.stringify(raw).slice(0, 300)}`,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t);\n\t\t\t\t\t}\n\t\t\t\t\tif (awaitFinality) {\n\t\t\t\t\t\tyield* Effect.tryPromise({\n\t\t\t\t\t\t\ttry: () => client.core.waitForTransaction({ digest: failedDigest }),\n\t\t\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\t\t\tnew SuiExecuteError({\n\t\t\t\t\t\t\t\t\tphase: 'wait-for-finality',\n\t\t\t\t\t\t\t\t\tsignerName: signer.name,\n\t\t\t\t\t\t\t\t\tsignerAddress: signer.address,\n\t\t\t\t\t\t\t\t\tdigest: failedDigest,\n\t\t\t\t\t\t\t\t\tmessage: `waitForTransaction(${failedDigest}) failed.`,\n\t\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t\t}),\n\t\t\t\t\t\t});\n\t\t\t\t\t}\n\t\t\t\t\tconst executionError = env.FailedTransaction?.status?.error;\n\t\t\t\t\treturn {\n\t\t\t\t\t\t$kind: 'FailedTransaction',\n\t\t\t\t\t\tFailedTransaction: {\n\t\t\t\t\t\t\tdigest: failedDigest,\n\t\t\t\t\t\t\t...(executionError !== undefined ? { executionError } : {}),\n\t\t\t\t\t\t},\n\t\t\t\t\t} satisfies SuiExecuteResult;\n\t\t\t\t}\n\t\t\t\tconst txOk = env.Transaction;\n\t\t\t\tif (txOk?.digest === undefined) {\n\t\t\t\t\treturn yield* Effect.fail(\n\t\t\t\t\t\tnew SuiExecuteError({\n\t\t\t\t\t\t\tphase: 'no-digest',\n\t\t\t\t\t\t\tsignerName: signer.name,\n\t\t\t\t\t\t\tsignerAddress: signer.address,\n\t\t\t\t\t\t\tmessage: `executeTransaction returned no digest. Raw=${JSON.stringify(raw).slice(0, 300)}`,\n\t\t\t\t\t\t}),\n\t\t\t\t\t);\n\t\t\t\t}\n\n\t\t\t\t// 5. Wait for finality (opt-out — some callers wait separately).\n\t\t\t\tif (awaitFinality) {\n\t\t\t\t\tyield* Effect.tryPromise({\n\t\t\t\t\t\ttry: () => client.core.waitForTransaction({ digest: txOk.digest! }),\n\t\t\t\t\t\tcatch: (cause) =>\n\t\t\t\t\t\t\tnew SuiExecuteError({\n\t\t\t\t\t\t\t\tphase: 'wait-for-finality',\n\t\t\t\t\t\t\t\tsignerName: signer.name,\n\t\t\t\t\t\t\t\tsignerAddress: signer.address,\n\t\t\t\t\t\t\t\tdigest: txOk.digest,\n\t\t\t\t\t\t\t\tmessage: `waitForTransaction(${txOk.digest}) failed.`,\n\t\t\t\t\t\t\t\tcause,\n\t\t\t\t\t\t\t}),\n\t\t\t\t\t});\n\t\t\t\t}\n\n\t\t\t\t// 6. Project changedObjects flat. Callers pick which entries\n\t\t\t\t// they care about (published / created / mutated / by-type\n\t\t\t\t// substring).\n\t\t\t\tconst objectTypes = txOk.objectTypes ?? {};\n\t\t\t\tconst objectChanges: Array<ExecutedObjectChange> = [];\n\t\t\t\tfor (const ch of txOk.effects?.changedObjects ?? []) {\n\t\t\t\t\tif (typeof ch.objectId !== 'string') continue;\n\t\t\t\t\tconst objectType = objectTypes[ch.objectId];\n\t\t\t\t\tconst entry: { -readonly [K in keyof ExecutedObjectChange]: ExecutedObjectChange[K] } = {\n\t\t\t\t\t\tobjectId: ch.objectId,\n\t\t\t\t\t};\n\t\t\t\t\tif (objectType !== undefined) entry.objectType = objectType;\n\t\t\t\t\tif (ch.outputState !== undefined) entry.outputState = ch.outputState;\n\t\t\t\t\tif (ch.idOperation !== undefined) entry.idOperation = ch.idOperation;\n\t\t\t\t\tobjectChanges.push(entry);\n\t\t\t\t}\n\n\t\t\t\treturn {\n\t\t\t\t\t$kind: 'Transaction',\n\t\t\t\t\tTransaction: { digest: txOk.digest, objectChanges },\n\t\t\t\t} satisfies SuiExecuteResult;\n\t\t\t}),\n\t\t)\n\t\t.pipe(\n\t\t\tEffect.withSpan('substrate.sui-execute', {\n\t\t\t\tattributes: {\n\t\t\t\t\t'sui-execute.signer': params.signer.name,\n\t\t\t\t\t'sui-execute.address': params.signer.address,\n\t\t\t\t},\n\t\t\t}),\n\t\t);\n\n/** Decode a possibly URI-encoded SDK error message. The Sui SDK\n * emits `decodeURIComponent`-able strings for some error paths\n * (notably stale-object-version reports). Falls back to the raw\n * message on decode failure. */\nconst decodeMessage = (message: string): string => {\n\ttry {\n\t\treturn decodeURIComponent(message);\n\t} catch {\n\t\treturn message;\n\t}\n};\n\n/** Typed predicate for the SDK's \"stale object version\" transient\n * failure — the Move VM refuses a transaction that references an\n * object reference older than the current chain version. Consumers\n * retry with fresh refs; pair with `STALE_OBJECT_VERSION_RETRY_PROFILE`\n * from `retry-policy.ts`. Detection sniffs the SDK message because the\n * underlying gRPC error class doesn't expose a structured discriminator\n * for this case. */\nexport const isSuiStaleObjectVersionError = (err: SuiExecuteError): boolean => {\n\tconst message = decodeMessage(err.message);\n\treturn (\n\t\tmessage.includes('needs to be rebuilt because object') && message.includes('current version')\n\t);\n};\n\n// ---------------------------------------------------------------------------\n// Sibling helpers\n// ---------------------------------------------------------------------------\n\nexport {\n\tsignAndDispatch,\n\ttype SignAndDispatchResult,\n\ttype SignAndDispatchSigner,\n\ttype TransactionSignerSource,\n} from './sign-and-dispatch.ts';\n"],"mappings":";;;;;;;;;;;;;AAwDA,IAAa,kBAAb,cAAqC,OAAO,kBAAmC,CAAC,mBAAmB;CAClG,OAAO,OAAO,SAAS;EAAC;EAAa;EAAQ;EAAW;EAAa;EAAoB,CAAC;CAC1F,YAAY,OAAO;CACnB,eAAe,OAAO;CACtB,SAAS,OAAO;;;CAGhB,QAAQ,OAAO,SAAS,OAAO,OAAO;CACtC,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CAAC,CAAC;;;;;;;;;;AAiFH,MAAa,yBAAyB,YACrC,QAAQ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AAa,SAAU;EACrC,MAAM,aAAa,YAAY,GAAG;EAClC,MAAM,QAAkF,EACvF,UAAU,GAAG,UACb;AACD,MAAI,eAAe,KAAA,EAAW,OAAM,aAAa;AACjD,MAAI,GAAG,gBAAgB,KAAA,EAAW,OAAM,cAAc,GAAG;AACzD,MAAI,GAAG,gBAAgB,KAAA,EAAW,OAAM,cAAc,GAAG;AACzD,gBAAc,KAAK,MAAM;;AAG1B,QAAO;EACN,OAAO;EACP,aAAa;GAAE,QAAQ,KAAK;GAAQ;GAAe;EACnD;EACA,CACF,CACA,KACA,OAAO,SAAS,yBAAyB,EACxC,YAAY;CACX,sBAAsB,OAAO,OAAO;CACpC,uBAAuB,OAAO,OAAO;CACrC,EACD,CAAC,CACF;;;;;AAMH,MAAM,iBAAiB,YAA4B;AAClD,KAAI;AACH,SAAO,mBAAmB,QAAQ;SAC3B;AACP,SAAO;;;;;;;;;;AAWT,MAAa,gCAAgC,QAAkC;CAC9E,MAAM,UAAU,cAAc,IAAI,QAAQ;AAC1C,QACC,QAAQ,SAAS,qCAAqC,IAAI,QAAQ,SAAS,kBAAkB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"sign-and-dispatch.mjs","names":[],"sources":["../../../../src/substrate/runtime/sui-execute/sign-and-dispatch.ts"],"sourcesContent":["// signAndDispatch — boilerplate compactor for the\n// `withTransactionSigner → buildTxBytes → signAndExecute → $kind\n// dispatch` pattern that recurs across every Sui-tx plugin\n// (`package.publish`, `action.execute`, `coin.mint`, `walrus.fundWal`,\n// `deepbook.fundDeep`, and any future user-authored signer plugin).\n//\n// Distinct from `executeSuiTx` (sibling in this directory):\n// - `executeSuiTx` drives `core.executeTransaction` directly via the\n// raw SDK client + an opaque resolved signer. It splits sign and\n// execute and projects the SDK envelope itself.\n// - `signAndDispatch` consumes the Account plugin's higher-level\n// `signAndExecute` surface (which fuses sign + execute + finality\n// wait + projection into one Effect) and just compacts the\n// surrounding boilerplate.\n//\n// Both helpers coexist: plugins that publish through the Account bus\n// (the majority) use `signAndDispatch`; lower-level callers that drive\n// the SDK client directly use `executeSuiTx`.\n//\n// Boundary discipline (matches the sui-execute escape-hatch in this\n// directory): this module is L1-adjacent — it consumes opaque shapes\n// (an `AccountValue`-like contract surface and the `SignAndExecuteResult`\n// union) but does NOT import from `plugins/*` or `@mysten/sui/*`. The\n// caller owns the transaction build, the error mapping, and the\n// dispatch bodies.\n//\n// On-chain `FailedTransaction` is a RETURN-CHANNEL outcome (caller\n// dispatches on `$kind` via the `onFailed` callback), NOT an error —\n// matches STYLE_GUIDE §2 and the upstream `SignAndExecuteResult` shape.\n\nimport { Effect } from 'effect';\n\nimport type { ExecutedFailure, ExecutedReceipt } from './index.ts';\n\n// ---------------------------------------------------------------------------\n// Resolved-signer shape — narrow slice of `AccountValue`\n// ---------------------------------------------------------------------------\n\n/** The SDK-shaped result of `lockedSigner.signAndExecute`. Mirrors the\n * Account plugin's `SignAndExecuteResult` union; redeclared here so\n * the substrate helper does not import from `plugins/account/*`. The\n * Account plugin's projection uses the substrate `ExecutedFailure`\n * shape already (single source of truth in `sui-execute/index.ts`).\n * Generic over the success transaction shape because the Account\n * plugin's `TxResult` widens `ExecutedReceipt` with `effects` /\n * `balanceChanges` fields that not every caller needs to surface. */\nexport type SignAndDispatchResult<TxOk extends { readonly digest: string } = ExecutedReceipt> =\n\t| { readonly $kind: 'Transaction'; readonly Transaction: TxOk }\n\t| { readonly $kind: 'FailedTransaction'; readonly FailedTransaction: ExecutedFailure };\n\n/** Locked-signer slice handed to the caller's tx-build closure. Narrow\n * view of `AccountTransactionSigner` — the substrate-side contract\n * doesn't reach into the Account plugin's surface. Generic over the\n * signer's sign-side error (typically `AccountSignError`) and the\n * success transaction shape. */\nexport interface SignAndDispatchSigner<SignError, TxOk extends { readonly digest: string }> {\n\treadonly signAndExecute: (\n\t\ttx: Uint8Array,\n\t) => Effect.Effect<SignAndDispatchResult<TxOk>, SignError>;\n}\n\n/** Outer signer-source surface required by `signAndDispatch` — anything\n * that exposes a `withTransactionSigner` scope. The substrate helper\n * only reaches `withTransactionSigner`, so plugins composing custom\n * signing surfaces can satisfy the slice without dragging in any\n * particular publisher's full contract. */\nexport interface TransactionSignerSource<SignError, TxOk extends { readonly digest: string }> {\n\treadonly withTransactionSigner: <A, E, R>(\n\t\tbody: (signer: SignAndDispatchSigner<SignError, TxOk>) => Effect.Effect<A, E, R>,\n\t) => Effect.Effect<A, E, R>;\n}\n\n// ---------------------------------------------------------------------------\n// The helper\n// ---------------------------------------------------------------------------\n\n/** Run `withTransactionSigner( buildTxBytes → signAndExecute → mapSignError →\n * dispatch on $kind )`. The caller owns:\n *\n * - `buildTxBytes`: an Effect returning the serialised `Uint8Array`,\n * run INSIDE the signer scope. Failures inside this effect\n * propagate verbatim — the caller maps `Transaction.build` /\n * impersonation-build errors to its plugin domain there.\n * - `mapSignError`: projects the signer's typed sign error\n * (`AccountSignError` for the Account bus) into the caller's\n * domain error before dispatch. Without this projection\n * `mapSignError` and the dispatch callbacks would need to share\n * the same error channel, which forces every caller into a tagged\n * domain error anyway.\n * - `onFailed`: dispatch for the `FailedTransaction` variant.\n * Typically `Effect.fail(domainError(formatExecutedFailure(...)))`.\n * - `onSuccess`: dispatch for the `Transaction` variant — projects\n * the SDK-shaped tx result to the caller's receipt shape.\n *\n * Returns the union of the dispatch callbacks' types so callers do\n * not have to wrap the call in a redundant `Effect.gen`. */\nexport const signAndDispatch = <\n\tA,\n\tBuildError,\n\tBuildEnv,\n\tSignError,\n\tDomainError,\n\tOnFailedError,\n\tOnFailedEnv,\n\tOnSuccessError,\n\tOnSuccessEnv,\n\tTxOk extends { readonly digest: string } = ExecutedReceipt,\n>(args: {\n\treadonly signerSource: TransactionSignerSource<SignError, TxOk>;\n\treadonly buildTxBytes: (\n\t\tsigner: SignAndDispatchSigner<SignError, TxOk>,\n\t) => Effect.Effect<Uint8Array, BuildError, BuildEnv>;\n\treadonly mapSignError: (cause: SignError) => DomainError;\n\treadonly onFailed: (failure: ExecutedFailure) => Effect.Effect<A, OnFailedError, OnFailedEnv>;\n\treadonly onSuccess: (ok: TxOk) => Effect.Effect<A, OnSuccessError, OnSuccessEnv>;\n}): Effect.Effect<\n\tA,\n\tBuildError | DomainError | OnFailedError | OnSuccessError,\n\tBuildEnv | OnFailedEnv | OnSuccessEnv\n> =>\n\targs.signerSource.withTransactionSigner((lockedSigner) =>\n\t\tEffect.gen(function* () {\n\t\t\tconst txBytes = yield* args.buildTxBytes(lockedSigner);\n\t\t\tconst result = yield* lockedSigner\n\t\t\t\t.signAndExecute(txBytes)\n\t\t\t\t.pipe(Effect.mapError(args.mapSignError));\n\t\t\tif (result.$kind === 'FailedTransaction') {\n\t\t\t\treturn yield* args.onFailed(result.FailedTransaction);\n\t\t\t}\n\t\t\treturn yield* args.onSuccess(result.Transaction);\n\t\t}),\n\t);\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAgGA,MAAa,mBAWX,SAaD,KAAK,aAAa,uBAAuB,iBACxC,OAAO,IAAI,aAAa;CACvB,MAAM,UAAU,OAAO,KAAK,aAAa,aAAa;CACtD,MAAM,SAAS,OAAO,aACpB,eAAe,QAAQ,CACvB,KAAK,OAAO,SAAS,KAAK,aAAa,CAAC;AAC1C,KAAI,OAAO,UAAU,oBACpB,QAAO,OAAO,KAAK,SAAS,OAAO,kBAAkB;AAEtD,QAAO,OAAO,KAAK,UAAU,OAAO,YAAY;EAC/C,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"object-ref.mjs","names":[],"sources":["../../../../src/substrate/runtime/sui-ledger/object-ref.ts"],"sourcesContent":["// substrate/runtime/sui-ledger — `ledgerService.getObject` workaround.\n//\n// `SuiSdkShim.core.getObject` returns the simplified `core`-surface\n// projection (no version/digest) per `@mysten/sui`'s `ClientWithCoreApi`\n// shape. The gRPC ledger service provides the BCS-encoded object\n// envelope WITH version + digest under a `readMask` projection — see\n// `@mysten/sui/docs/clients/grpc.md` § Ledger service.\n//\n// The cast `sdk.client as unknown as {ledgerService: {…}}` is the\n// sanctioned escape hatch — `ClientWithCoreApi` doesn't structurally\n// overlap with the gRPC `{ledgerService}` shape, so a direct cast fails.\n// Folded into one substrate-side helper so every plugin that needs an\n// up-to-date `{objectId, version, digest}` ObjectRef goes through the\n// same projection (and the same `unknown`-cast escape hatch) rather\n// than re-deriving it.\n//\n// NOTE: not exported from the public barrel — this is an internal\n// substrate primitive used by plugins, not a published API.\n//\n// Sibling of `substrate/runtime/sui-execute/` — same opacity discipline\n// (no `@mysten/sui/client` type import; the opaque `SuiSdkShim` carries\n// the client through).\n\nimport type { SuiSdkShim } from '../../../plugins/sui/index.ts';\n\n/** Shape of the gRPC ledger-service projection we need. Hand-written\n * because the public `ClientWithCoreApi` surface doesn't include the\n * ledger service. */\ninterface LedgerObjectClient {\n\treadonly ledgerService: {\n\t\treadonly getObject: (args: {\n\t\t\treadonly objectId: string;\n\t\t\treadonly readMask?: { readonly paths: ReadonlyArray<string> };\n\t\t}) => Promise<{\n\t\t\treadonly response?: {\n\t\t\t\treadonly object?: {\n\t\t\t\t\treadonly objectId?: string;\n\t\t\t\t\treadonly version?: string | number | bigint;\n\t\t\t\t\treadonly digest?: string;\n\t\t\t\t};\n\t\t\t};\n\t\t}>;\n\t};\n}\n\n/** Re-cast a `SuiSdkShim` as the gRPC ledger-service client. The\n * `unknown` hop is required because `ClientWithCoreApi` doesn't\n * structurally overlap with `{ledgerService: …}`. */\nconst ledgerObjectClient = (sdk: SuiSdkShim): LedgerObjectClient =>\n\tsdk.client as unknown as LedgerObjectClient;\n\n/** Up-to-date `{objectId, version, digest}` ObjectRef for `objectId`,\n * fetched through the gRPC ledger service.\n *\n * Throws if the response envelope is missing any of `objectId` /\n * `version` / `digest` — e.g. when the object was deleted or never\n * existed. The error message includes the requested object id so\n * call-site context surfaces in plugin error traces. */\nexport const currentLedgerObjectRef = async (\n\tsdk: SuiSdkShim,\n\tobjectId: string,\n): Promise<{\n\treadonly objectId: string;\n\treadonly version: string;\n\treadonly digest: string;\n}> => {\n\tconst raw = await ledgerObjectClient(sdk).ledgerService.getObject({\n\t\tobjectId,\n\t\treadMask: { paths: ['object_id', 'version', 'digest'] },\n\t});\n\tconst object = raw.response?.object;\n\tif (\n\t\tobject === undefined ||\n\t\tobject.objectId === undefined ||\n\t\tobject.version === undefined ||\n\t\tobject.digest === undefined\n\t) {\n\t\tthrow new Error(\n\t\t\t`currentLedgerObjectRef: object '${objectId}' was not found (response missing one of objectId/version/digest).`,\n\t\t);\n\t}\n\treturn {\n\t\tobjectId: object.objectId,\n\t\tversion: object.version.toString(),\n\t\tdigest: object.digest,\n\t};\n};\n"],"mappings":";;;;AAgDA,MAAM,sBAAsB,QAC3B,IAAI;;;;;;;;AASL,MAAa,yBAAyB,OACrC,KACA,aAKK;CAKL,MAAM,UAAS,MAJG,mBAAmB,IAAI,CAAC,cAAc,UAAU;EACjE;EACA,UAAU,EAAE,OAAO;GAAC;GAAa;GAAW;GAAS,EAAE;EACvD,CAAC,EACiB,UAAU;AAC7B,KACC,WAAW,KAAA,KACX,OAAO,aAAa,KAAA,KACpB,OAAO,YAAY,KAAA,KACnB,OAAO,WAAW,KAAA,EAElB,OAAM,IAAI,MACT,mCAAmC,SAAS,oEAC5C;AAEF,QAAO;EACN,UAAU,OAAO;EACjB,SAAS,OAAO,QAAQ,UAAU;EAClC,QAAQ,OAAO;EACf"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/substrate/runtime/sui-move-build/index.ts"],"sourcesContent":["// sui-move-build — shared Sui Move build helpers.\n//\n// ARCHITECTURE NOTE — substrate-name-awareness escape hatch:\n//\n// Like `sui-execute/`, this is an L1-adjacent Sui-aware helper. It owns\n// the mechanical \"scrub Move.lock → run sui move build → parse bytecode\"\n// path so Move-publishing plugins do not import each other's internals.\n// Listed as a documented exception in `ARCHITECTURE.md` §\"Substrate\n// name-blindness\" alongside `sui-execute/`. Rationale + alternative-\n// rejection are recorded there; new substrate-side Sui-aware exceptions\n// need explicit justification in that section before landing.\n\nimport { createHash } from 'node:crypto';\nimport { cp, lstat, mkdir, mkdtemp, readFile, readdir, rm, writeFile } from 'node:fs/promises';\nimport { homedir, tmpdir } from 'node:os';\nimport { basename, join, relative, resolve, sep } from 'node:path';\n\nimport { Effect, Schema, type Scope } from 'effect';\n\nimport type {\n\tContainerBuildContext,\n\tContainerRuntime,\n\tExecResult,\n\tImageRef,\n} from '../../../contracts/container-runtime.ts';\nimport { contentHash, type ChainId, type ContentHash } from '../../brand.ts';\nimport { mintRandomSuffix } from '../random-suffix.ts';\nimport { decodeJsonTextSync } from '../runtime-decode.ts';\n\nexport type MoveBuildPhase = 'hash' | 'scrub' | 'build' | 'parse';\n\nexport const DEFAULT_SUI_CLI_VERSION = 'devnet-v1.71.0';\n\nexport const suiCliImageBuildContext = (\n\tversion = DEFAULT_SUI_CLI_VERSION,\n): ContainerBuildContext => ({\n\tcontextPath: new URL('../../../../images/', import.meta.url).pathname,\n\tdockerfile: 'sui/Dockerfile',\n\tfingerprintPaths: ['sui/Dockerfile', 'sui/entrypoint.sh', '_shared/signal-forward.sh'],\n\tbuildArgs: { SUI_VERSION: version },\n});\n\nexport class MoveBuildError extends Schema.TaggedErrorClass<MoveBuildError>()('MoveBuildError', {\n\tphase: Schema.Literals(['hash', 'scrub', 'build', 'parse']),\n\tsourcePath: Schema.String,\n\tpackageName: Schema.String,\n\tmessage: Schema.String,\n\tcause: Schema.optional(Schema.Defect),\n}) {}\n\nconst moveBuildError = (\n\tphase: MoveBuildPhase,\n\tparts: {\n\t\treadonly sourcePath: string;\n\t\treadonly packageName: string;\n\t\treadonly message: string;\n\t\treadonly cause?: unknown;\n\t},\n): MoveBuildError =>\n\tnew MoveBuildError({\n\t\tphase,\n\t\tsourcePath: parts.sourcePath,\n\t\tpackageName: parts.packageName,\n\t\tmessage: parts.message,\n\t\t...(parts.cause !== undefined ? { cause: parts.cause } : {}),\n\t});\n\nexport interface MoveBuildContainer {\n\treadonly runBuild: (hostPackagePath: string) => Effect.Effect<ExecResult, unknown, Scope.Scope>;\n}\n\nexport interface BuildInputs {\n\treadonly sourcePath: string;\n\treadonly packageName: string;\n\treadonly chainId: ChainId | string;\n\treadonly buildContainer?: MoveBuildContainer;\n\treadonly runtime?: ContainerRuntime;\n\treadonly buildImage?: ImageRef;\n}\n\nexport interface BuildOutput {\n\treadonly modules: ReadonlyArray<Uint8Array>;\n\treadonly dependencies: ReadonlyArray<string>;\n}\n\nexport const stripPinnedSections = (source: string): string => {\n\tconst lines = source.split('\\n');\n\tconst out: Array<string> = [];\n\tlet skipping = false;\n\tfor (const line of lines) {\n\t\tconst trimmed = line.trimStart();\n\t\tif (trimmed.startsWith('[')) {\n\t\t\tconst header = trimmed.replace(/\\s+/g, '');\n\t\t\tif (header.startsWith('[pinned.') || header === '[env]' || header.startsWith('[env.')) {\n\t\t\t\tskipping = true;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tskipping = false;\n\t\t}\n\t\tif (!skipping) out.push(line);\n\t}\n\tif (skipping && source.endsWith('\\n') && out.at(-1) === '') out.push('');\n\treturn out.join('\\n');\n};\n\nexport const CONTAINER_SCRUB_AWK_SCRIPT = [\n\t'/^\\\\[pinned\\\\./ || /^\\\\[env(\\\\.|\\\\])/ { skip=1; next }',\n\t'/^\\\\[/ && !/^\\\\[pinned\\\\./ && !/^\\\\[env(\\\\.|\\\\])/ { skip=0 }',\n\t'!skip { print }',\n].join('\\n');\n\nexport const containerScrubShellScript = (workspaceRoot: string, moveHomeRoot: string): string => {\n\tconst lines = CONTAINER_SCRUB_AWK_SCRIPT.split('\\n')\n\t\t.map((l) => `'${l}'`)\n\t\t.join(' ');\n\tconst stage = `printf '%s\\\\n%s\\\\n%s\\\\n' ${lines} > /tmp/scrub-move-lock.awk`;\n\tconst findPkg =\n\t\t`find ${workspaceRoot} -type f -name Move.lock ` +\n\t\t`-not -path '*/node_modules/*' -not -path '*/.git/*' ` +\n\t\t`-exec gawk -i inplace -f /tmp/scrub-move-lock.awk {} ';'`;\n\tconst findCache =\n\t\t`[ -d ${moveHomeRoot}/git ] && find ${moveHomeRoot}/git -type f -name Move.lock ` +\n\t\t`-not -path '*/.git/*' ` +\n\t\t`-exec gawk -i inplace -f /tmp/scrub-move-lock.awk {} ';' || true`;\n\treturn [stage, findPkg, findCache].join('; ');\n};\n\nexport interface MoveBuildInput {\n\treadonly packagePath: string;\n\treadonly rpcUrl: string;\n\treadonly faucetUrl?: string;\n}\n\nexport interface MoveBuildOutput {\n\treadonly exitCode: number;\n\treadonly stdoutJson: string;\n\treadonly stderr: string;\n}\n\nexport const shellQuote = (s: string): string => `'${s.replaceAll(\"'\", \"'\\\\''\")}'`;\n\nexport const extractTrailingJson = (text: string): string => {\n\tconst trimmed = text.trim();\n\tif (trimmed.startsWith('{')) return trimmed;\n\tconst idx = trimmed.lastIndexOf('{');\n\tif (idx === -1) return trimmed;\n\treturn trimmed.slice(idx);\n};\n\nexport const containerInnerScript = (pkgName: string): string => {\n\t// Copy the WHOLE mounted tree into an in-container scratch dir and scrub +\n\t// build the package THERE, never `/workspace/<pkg>` directly. `/workspace`\n\t// is a bind mount of the developer's real source tree (the per-app build\n\t// container in `chain-build-container.ts` mounts the app dir as-is), and the\n\t// scrub's `gawk -i inplace` rewrite of Move.lock would corrupt their\n\t// checked-in pinned deps if run against the mount.\n\t//\n\t// Two reasons we copy `/workspace/.` (the whole tree) rather than only\n\t// `/workspace/<pkgName>`:\n\t// 1. NESTED PACKAGES. `pkgName` is the package path RELATIVE to the\n\t// bind-mounted app dir (e.g. `packages/demo`), so it can contain a\n\t// slash. Copying only `/workspace/<pkgName>` into\n\t// `/tmp/move-build-$$/<pkgName>` would need the intermediate\n\t// `packages/` dir to exist first — it doesn't, and `set -e` would\n\t// abort the build before `sui move build` ran.\n\t// 2. SIBLING LOCAL DEPS. A package can reference siblings via\n\t// `{ local = \"../token\" }`. A scoped copy of only the package subtree\n\t// drops those, failing the build with \"Invalid directory at ../…\".\n\t// Copying the whole tree both materialises the nested path AND carries the\n\t// sibling `../` deps. The mount itself is never rewritten (mirrors\n\t// `containerInnerScriptOneShot`, whose host-side staging tree is the disposable\n\t// copy there; here the in-container copy is the disposable one).\n\t//\n\t// `$$` (the shell PID) scopes the scratch dir per exec so concurrent\n\t// builds of the same package don't share a tree.\n\tconst quotedPkg = shellQuote(pkgName);\n\tconst scratchRoot = '/tmp/move-build-$$';\n\tconst scratchPkg = `${scratchRoot}/${quotedPkg}`;\n\tconst stage = `rm -rf ${scratchRoot} && mkdir -p ${scratchRoot} && cp -a /workspace/. ${scratchRoot}/`;\n\t// Scrub the whole scratch tree AND the mounted Move git cache. The cache\n\t// (`/root/.move/git`) is process-shared mutable state we legitimately want\n\t// scrubbed so a stale pin can't leak into the build; the scratch tree is the\n\t// disposable copy, so scrubbing all of it (package + staged siblings) is safe.\n\tconst scrub = containerScrubShellScript(scratchRoot, '/root/.move');\n\tconst build =\n\t\t`sui move build --path ${scratchPkg} ` +\n\t\t`-e testnet --no-tree-shaking --dump-bytecode-as-base64 ` +\n\t\t`--with-unpublished-dependencies`;\n\tconst cleanup = `rm -rf ${scratchRoot}`;\n\treturn [\n\t\t'set -e',\n\t\tstage,\n\t\tscrub,\n\t\t'set +e',\n\t\tbuild,\n\t\t'status=$?',\n\t\t'set -e',\n\t\tscrub,\n\t\tcleanup,\n\t\t'exit \"$status\"',\n\t].join('; ');\n};\n\n/** One-shot-path inner script. Mirrors {@link containerInnerScript} — both copy\n * the WHOLE `/workspace` tree into an in-container scratch dir and scrub + build\n * THERE, never the mount in place. The difference is only WHAT is mounted at\n * `/workspace`: the exec path bind-mounts the developer's real app dir (so the\n * whole-tree copy naturally carries nested packages + sibling `../` deps),\n * whereas the one-shot path mounts a disposable host-side staging copy whose\n * transitive local deps were pre-staged (see `stageLocalMoveDeps`). Copying only\n * `/workspace/<pkg>` would drop sibling local dependencies\n * (`{ local = \"../token\" }`), failing the build with \"Invalid directory at ../…\". */\nexport const containerInnerScriptOneShot = (pkgName: string): string => {\n\tconst quotedPkg = shellQuote(pkgName);\n\tconst scratchRoot = '/tmp/move-build-$$';\n\tconst scratchPkg = `${scratchRoot}/${quotedPkg}`;\n\t// Copy the WHOLE staging mount (package + its staged local `../` deps) into\n\t// an in-container scratch tree and scrub + build THERE — never the mounted\n\t// host staging dir. Building in the mount leaves root-owned `build/` +\n\t// scrubbed Move.lock files behind that the (non-root) host can't remove,\n\t// failing scope cleanup with EACCES. Copying ALL of /workspace (like\n\t// containerInnerScript) keeps sibling local deps like `{ local = \"../token\" }`\n\t// present in the scratch tree.\n\tconst stage = `rm -rf ${scratchRoot} && mkdir -p ${scratchRoot} && cp -a /workspace/. ${scratchRoot}/`;\n\tconst scrub = containerScrubShellScript(scratchRoot, '/root/.move');\n\tconst build =\n\t\t`sui move build --path ${scratchPkg} ` +\n\t\t`-e testnet --no-tree-shaking --dump-bytecode-as-base64 ` +\n\t\t`--with-unpublished-dependencies`;\n\tconst cleanup = `rm -rf ${scratchRoot}`;\n\treturn [\n\t\t'set -e',\n\t\tstage,\n\t\tscrub,\n\t\t'set +e',\n\t\tbuild,\n\t\t'status=$?',\n\t\t'set -e',\n\t\tscrub,\n\t\tcleanup,\n\t\t'exit \"$status\"',\n\t].join('; ');\n};\n\nconst isHashedFile = (name: string): boolean =>\n\tname === 'Move.toml' || name === 'Move.lock' || name.endsWith('.move');\n\nconst isSkippedDir = (name: string): boolean =>\n\tname === 'build' || name === 'node_modules' || name === '.git' || name.startsWith('.');\n\nconst collectHashedSources = async (root: string): Promise<ReadonlyArray<string>> => {\n\tconst out: Array<string> = [];\n\tconst walk = async (dir: string): Promise<void> => {\n\t\tlet entries: ReadonlyArray<{\n\t\t\treadonly name: string;\n\t\t\treadonly isDirectory: () => boolean;\n\t\t\treadonly isFile: () => boolean;\n\t\t}> = [];\n\t\ttry {\n\t\t\tentries = await readdir(dir, { withFileTypes: true });\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tif (isSkippedDir(entry.name)) continue;\n\t\t\t\tawait walk(join(dir, entry.name));\n\t\t\t} else if (entry.isFile() && isHashedFile(entry.name)) {\n\t\t\t\tconst abs = join(dir, entry.name);\n\t\t\t\ttry {\n\t\t\t\t\tconst stat = await lstat(abs);\n\t\t\t\t\tif (stat.isFile() && !stat.isSymbolicLink()) out.push(abs);\n\t\t\t\t} catch {\n\t\t\t\t\t// vanished / unreadable — skip\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\tawait walk(root);\n\treturn out;\n};\n\nexport const hashMoveSources = (sourcePath: string): Effect.Effect<ContentHash, MoveBuildError> =>\n\tEffect.tryPromise({\n\t\ttry: async (): Promise<ContentHash> => {\n\t\t\tconst files = await collectHashedSources(sourcePath);\n\t\t\tconst sorted = [...files].sort((a, b) =>\n\t\t\t\trelative(sourcePath, a).localeCompare(relative(sourcePath, b)),\n\t\t\t);\n\t\t\tconst hasher = createHash('sha256');\n\t\t\tfor (const abs of sorted) {\n\t\t\t\tconst rel = relative(sourcePath, abs);\n\t\t\t\tconst raw = await readFile(abs, 'utf8');\n\t\t\t\tconst normalised = basename(abs) === 'Move.lock' ? stripPinnedSections(raw) : raw;\n\t\t\t\thasher.update(rel);\n\t\t\t\thasher.update('\\0');\n\t\t\t\thasher.update(normalised);\n\t\t\t\thasher.update('\\0');\n\t\t\t}\n\t\t\treturn contentHash(hasher.digest('hex'));\n\t\t},\n\t\tcatch: (cause): MoveBuildError =>\n\t\t\tmoveBuildError('hash', {\n\t\t\t\tsourcePath,\n\t\t\t\tpackageName: sourcePath,\n\t\t\t\tmessage: `source-tree hash failed: ${String((cause as Error)?.message ?? cause)}`,\n\t\t\t\tcause,\n\t\t\t}),\n\t});\n\nconst expandHome = (p: string): string =>\n\tp.startsWith('~/') ? join(homedir(), p.slice(2)) : p === '~' ? homedir() : p;\n\nconst findMoveLockFiles = async (root: string): Promise<ReadonlyArray<string>> => {\n\tconst out: Array<string> = [];\n\tconst walk = async (dir: string): Promise<void> => {\n\t\tlet entries: ReadonlyArray<{\n\t\t\treadonly name: string;\n\t\t\treadonly isDirectory: () => boolean;\n\t\t\treadonly isFile: () => boolean;\n\t\t}> = [];\n\t\ttry {\n\t\t\tentries = await readdir(dir, { withFileTypes: true });\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tfor (const entry of entries) {\n\t\t\tif (entry.name === 'node_modules' || entry.name === '.git' || entry.name === 'build') {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tconst child = join(dir, entry.name);\n\t\t\tif (entry.isDirectory()) {\n\t\t\t\tawait walk(child);\n\t\t\t} else if (entry.isFile() && entry.name === 'Move.lock') {\n\t\t\t\ttry {\n\t\t\t\t\tconst stat = await lstat(child);\n\t\t\t\t\tif (stat.isFile() && !stat.isSymbolicLink()) out.push(child);\n\t\t\t\t} catch {\n\t\t\t\t\t// unreadable / vanished — skip\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t};\n\tawait walk(root);\n\treturn out;\n};\n\nconst scrubOneLockFile = async (path: string): Promise<void> => {\n\tconst original = await readFile(path, 'utf8');\n\tconst scrubbed = stripPinnedSections(original);\n\tif (scrubbed === original) return;\n\tawait writeFile(path, scrubbed, 'utf8');\n};\n\nconst scrubCachedLockFiles = async (root: string): Promise<void> => {\n\tconst cachedLocks = await findMoveLockFiles(root);\n\tfor (const f of cachedLocks) {\n\t\ttry {\n\t\t\tawait scrubOneLockFile(f);\n\t\t} catch {\n\t\t\t// The Docker build scrubs the mounted Move cache again from inside the container.\n\t\t}\n\t}\n};\n\n// Scrub ONLY the shared Move git cache (`~/.move/git`), never the caller's\n// source tree. The package's own Move.lock is scrubbed inside the container on\n// a disposable copy (see `containerInnerScript`), so rewriting the developer's\n// checked-in Move.lock here would corrupt their pinned deps for no benefit. The\n// cache is process-shared mutable state, so scrubbing it host-side keeps a stale\n// pin from leaking into the build.\nexport const scrubLocksHost = (\n\tsourcePath: string,\n\tmoveHomeRoot: string,\n): Effect.Effect<void, MoveBuildError, Scope.Scope> =>\n\tEffect.tryPromise({\n\t\ttry: async () => {\n\t\t\tconst moveHome = expandHome(moveHomeRoot);\n\t\t\tconst gitCache = join(moveHome, 'git');\n\t\t\ttry {\n\t\t\t\tawait lstat(gitCache);\n\t\t\t} catch {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tawait scrubCachedLockFiles(gitCache);\n\t\t},\n\t\tcatch: (cause): MoveBuildError =>\n\t\t\tmoveBuildError('scrub', {\n\t\t\t\tsourcePath,\n\t\t\t\tpackageName: sourcePath,\n\t\t\t\tmessage: `scrub host locks failed (root=${moveHomeRoot})`,\n\t\t\t\tcause,\n\t\t\t}),\n\t});\n\nconst SuiBuildJsonSchema = Schema.Struct({\n\tmodules: Schema.Array(Schema.String),\n\tdependencies: Schema.Array(Schema.String),\n});\n\nconst decodeBase64Module = (s: string): Uint8Array =>\n\tUint8Array.from(globalThis.Buffer.from(s, 'base64'));\n\nexport const parseBuildOutput = (\n\tstdout: string,\n\tsourcePath: string,\n\tpackageName: string,\n): Effect.Effect<BuildOutput, MoveBuildError> =>\n\tEffect.try({\n\t\ttry: (): BuildOutput => {\n\t\t\tconst trimmed = extractTrailingJson(stdout);\n\t\t\tconst parsed = decodeJsonTextSync(SuiBuildJsonSchema, trimmed, {\n\t\t\t\tsource: 'sui move build stdout',\n\t\t\t\tmessage: 'unexpected sui move build JSON shape',\n\t\t\t\tmkError: (issue) => new Error(issue.message, { cause: issue.cause }),\n\t\t\t});\n\t\t\tconst modules = parsed.modules.map((m) => decodeBase64Module(m));\n\t\t\tconst dependencies = parsed.dependencies;\n\t\t\treturn { modules, dependencies };\n\t\t},\n\t\tcatch: (cause): MoveBuildError =>\n\t\t\tmoveBuildError('parse', {\n\t\t\t\tsourcePath,\n\t\t\t\tpackageName,\n\t\t\t\tmessage: `failed to parse sui move build output: ${String((cause as Error)?.message ?? cause)}`,\n\t\t\t\tcause,\n\t\t\t}),\n\t});\n\nconst promoteNonZero = (\n\top: 'docker exec' | 'docker run --rm',\n\tresult: ExecResult,\n\tsourcePath: string,\n\tpackageName: string,\n): MoveBuildError =>\n\tmoveBuildError('build', {\n\t\tsourcePath,\n\t\tpackageName,\n\t\tmessage:\n\t\t\t`${op} sui move build exited ${result.exitCode} for package \"${packageName}\".\\n` +\n\t\t\t`stderr: ${result.stderr || '(empty)'}\\n` +\n\t\t\t`stdout (tail): ${result.stdout.slice(-400) || '(empty)'}`,\n\t});\n\nconst ensureMoveHomeMountSource = (\n\tmoveHome: string,\n\tsourcePath: string,\n\tpackageName: string,\n): Effect.Effect<void, MoveBuildError> =>\n\tEffect.tryPromise({\n\t\ttry: () => mkdir(moveHome, { recursive: true }),\n\t\tcatch: (cause): MoveBuildError =>\n\t\t\tmoveBuildError('build', {\n\t\t\t\tsourcePath,\n\t\t\t\tpackageName,\n\t\t\t\tmessage: `failed to create Move cache mount source \"${moveHome}\"`,\n\t\t\t\tcause,\n\t\t\t}),\n\t}).pipe(Effect.asVoid);\n\nconst buildViaContainerExec = (\n\tinputs: BuildInputs,\n\tbc: MoveBuildContainer,\n): Effect.Effect<BuildOutput, MoveBuildError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst result = yield* bc.runBuild(inputs.sourcePath).pipe(\n\t\t\tEffect.mapError(\n\t\t\t\t(err): MoveBuildError =>\n\t\t\t\t\tmoveBuildError('build', {\n\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\tmessage: `buildContainer.runBuild failed: ${String(\n\t\t\t\t\t\t\t(err as { cause?: { message?: string } })?.cause?.message ?? err,\n\t\t\t\t\t\t)}`,\n\t\t\t\t\t\tcause: err,\n\t\t\t\t\t}),\n\t\t\t),\n\t\t);\n\t\tif (result.exitCode !== 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tpromoteNonZero('docker exec', result, inputs.sourcePath, inputs.packageName),\n\t\t\t);\n\t\t}\n\t\treturn yield* parseBuildOutput(result.stdout, inputs.sourcePath, inputs.packageName);\n\t}).pipe(Effect.withSpan('sui-move-build.via-exec'));\n\n/** `{ local = \"../path\" }` dependency paths, harvested from a Move.toml. */\nconst LOCAL_MOVE_DEP_RE = /\\blocal\\s*=\\s*\"([^\"]+)\"/g;\n\n/** Copy a package's transitive local-path Move dependencies into a staging\n * tree, preserving each dep's path RELATIVE to the staged package so\n * references like `{ local = \"../token\" }` resolve. Without this, a scoped\n * copy of only the package fails `sui move build` / `sui move summary` with\n * \"Invalid directory at ../…\". Throws if a dep resolves outside `stagingRoot`\n * (the single-mount layout can't represent it). Promise-based so the build\n * (`MoveBuildError`) and summary (`CodegenBindingsFailed`) call sites can\n * wrap it in their own error type. */\nexport const copyLocalMoveDeps = async (\n\tpackageSrc: string,\n\tstagedPackage: string,\n\tstagingRoot: string,\n): Promise<void> => {\n\tconst staged = new Set<string>([packageSrc]);\n\tconst walk = async (srcDir: string, stagedDir: string): Promise<void> => {\n\t\tlet toml: string;\n\t\ttry {\n\t\t\ttoml = await readFile(join(srcDir, 'Move.toml'), 'utf8');\n\t\t} catch {\n\t\t\treturn;\n\t\t}\n\t\tfor (const match of toml.matchAll(LOCAL_MOVE_DEP_RE)) {\n\t\t\tconst rel = match[1]!;\n\t\t\tconst depSrc = resolve(srcDir, rel);\n\t\t\tconst depStaged = resolve(stagedDir, rel);\n\t\t\tif (depStaged !== stagingRoot && !depStaged.startsWith(stagingRoot + sep)) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`local Move dependency \"${rel}\" of \"${basename(srcDir)}\" resolves outside the ` +\n\t\t\t\t\t\t`staging root; vendor it under the package tree so it can be staged.`,\n\t\t\t\t);\n\t\t\t}\n\t\t\tif (staged.has(depSrc)) {\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tstaged.add(depSrc);\n\t\t\tawait cp(depSrc, depStaged, { recursive: true });\n\t\t\tawait walk(depSrc, depStaged);\n\t\t}\n\t};\n\tawait walk(packageSrc, stagedPackage);\n};\n\n/** Build-path wrapper around {@link copyLocalMoveDeps}. */\nexport const stageLocalMoveDeps = (\n\tpackageSrc: string,\n\tstagedPackage: string,\n\tstagingRoot: string,\n\tinputs: BuildInputs,\n): Effect.Effect<void, MoveBuildError> =>\n\tEffect.tryPromise({\n\t\ttry: () => copyLocalMoveDeps(packageSrc, stagedPackage, stagingRoot),\n\t\tcatch: (cause): MoveBuildError =>\n\t\t\tmoveBuildError('scrub', {\n\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\tmessage: 'failed to stage local Move dependencies for the one-shot build',\n\t\t\t\tcause,\n\t\t\t}),\n\t});\n\nconst buildViaOneShot = (\n\tinputs: BuildInputs,\n\truntime: ContainerRuntime,\n\timage: ImageRef,\n): Effect.Effect<BuildOutput, MoveBuildError, Scope.Scope> =>\n\tEffect.gen(function* () {\n\t\tconst pkgName = basename(inputs.sourcePath);\n\t\tconst inner = containerInnerScriptOneShot(pkgName);\n\t\tconst moveHome = join(homedir(), '.move');\n\t\tyield* ensureMoveHomeMountSource(moveHome, inputs.sourcePath, inputs.packageName);\n\n\t\t// Stage a scoped copy of the package and mount THAT, never the user's\n\t\t// source tree. The container scrub (`gawk -i inplace`) rewrites Move.lock\n\t\t// in place; pointing it at the developer's checked-in tree corrupts their\n\t\t// pinned deps. The staging dir is scope-bound (acquireRelease removes it on\n\t\t// scope close) and carries a random suffix so two concurrent builds of the\n\t\t// same package don't share a tree. We keep the `/workspace/<pkgName>` layout\n\t\t// so `containerInnerScript(pkgName)` and the mounted Move cache stay unchanged.\n\t\tconst stagingRoot = yield* Effect.acquireRelease(\n\t\t\tEffect.tryPromise({\n\t\t\t\ttry: () => mkdtemp(join(tmpdir(), `move-build-${mintRandomSuffix(12)}-`)),\n\t\t\t\tcatch: (cause): MoveBuildError =>\n\t\t\t\t\tmoveBuildError('scrub', {\n\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\tmessage: 'failed to create staging dir for Move build copy',\n\t\t\t\t\t\tcause,\n\t\t\t\t\t}),\n\t\t\t}),\n\t\t\t(dir) => Effect.promise(() => rm(dir, { recursive: true, force: true })),\n\t\t);\n\t\tconst stagedPackage = join(stagingRoot, pkgName);\n\t\tyield* Effect.tryPromise({\n\t\t\ttry: () => cp(inputs.sourcePath, stagedPackage, { recursive: true }),\n\t\t\tcatch: (cause): MoveBuildError =>\n\t\t\t\tmoveBuildError('scrub', {\n\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\tmessage: `failed to stage package copy for Move build (staging=${stagedPackage})`,\n\t\t\t\t\tcause,\n\t\t\t\t}),\n\t\t});\n\t\t// Bring the package's transitive local `../` deps into the staging tree\n\t\t// so the in-place one-shot build resolves them (the scoped copy alone\n\t\t// would omit siblings like `{ local = \"../token\" }`).\n\t\tyield* stageLocalMoveDeps(inputs.sourcePath, stagedPackage, stagingRoot, inputs);\n\n\t\tconst result = yield* runtime\n\t\t\t.runOneShot({\n\t\t\t\timage,\n\t\t\t\tentrypoint: 'sh',\n\t\t\t\targv: ['-c', inner],\n\t\t\t\tmounts: [\n\t\t\t\t\t{ source: stagingRoot, target: '/workspace' },\n\t\t\t\t\t{ source: moveHome, target: '/root/.move' },\n\t\t\t\t],\n\t\t\t\ttimeoutMillis: 5 * 60_000,\n\t\t\t})\n\t\t\t.pipe(\n\t\t\t\tEffect.mapError(\n\t\t\t\t\t(err): MoveBuildError =>\n\t\t\t\t\t\tmoveBuildError('build', {\n\t\t\t\t\t\t\tsourcePath: inputs.sourcePath,\n\t\t\t\t\t\t\tpackageName: inputs.packageName,\n\t\t\t\t\t\t\tmessage: `runtime.runOneShot failed: ${err.reason}: ${err.detail}`,\n\t\t\t\t\t\t\tcause: err,\n\t\t\t\t\t\t}),\n\t\t\t\t),\n\t\t\t);\n\t\tif (result.exitCode !== 0) {\n\t\t\treturn yield* Effect.fail(\n\t\t\t\tpromoteNonZero('docker run --rm', result, inputs.sourcePath, inputs.packageName),\n\t\t\t);\n\t\t}\n\t\treturn yield* parseBuildOutput(result.stdout, inputs.sourcePath, inputs.packageName);\n\t}).pipe(Effect.withSpan('sui-move-build.via-one-shot'));\n\nexport const runMoveBuild = (\n\tinputs: BuildInputs,\n): Effect.Effect<BuildOutput, MoveBuildError, Scope.Scope> => {\n\tif (inputs.buildContainer !== undefined) {\n\t\treturn buildViaContainerExec(inputs, inputs.buildContainer);\n\t}\n\tif (inputs.runtime !== undefined && inputs.buildImage !== undefined) {\n\t\treturn buildViaOneShot(inputs, inputs.runtime, inputs.buildImage);\n\t}\n\treturn Effect.fail(\n\t\tmoveBuildError('build', {\n\t\t\tsourcePath: inputs.sourcePath,\n\t\t\tpackageName: inputs.packageName,\n\t\t\tmessage:\n\t\t\t\t'runMoveBuild: no build container and no fresh-container runtime/image — ' +\n\t\t\t\t'host `sui` CLI path is not available without a routed ChildProcessSpawner',\n\t\t}),\n\t);\n};\n"],"mappings":";;;;;;;;;AA+BA,MAAa,0BAA0B;AAEvC,MAAa,2BACZ,UAAU,6BACkB;CAC5B,aAAa,IAAI,IAAI,uBAAuB,OAAO,KAAK,IAAI,CAAC;CAC7D,YAAY;CACZ,kBAAkB;EAAC;EAAkB;EAAqB;EAA4B;CACtF,WAAW,EAAE,aAAa,SAAS;CACnC;AAED,IAAa,iBAAb,cAAoC,OAAO,kBAAkC,CAAC,kBAAkB;CAC/F,OAAO,OAAO,SAAS;EAAC;EAAQ;EAAS;EAAS;EAAQ,CAAC;CAC3D,YAAY,OAAO;CACnB,aAAa,OAAO;CACpB,SAAS,OAAO;CAChB,OAAO,OAAO,SAAS,OAAO,OAAO;CACrC,CAAC,CAAC;AAEH,MAAM,kBACL,OACA,UAOA,IAAI,eAAe;CAClB;CACA,YAAY,MAAM;CAClB,aAAa,MAAM;CACnB,SAAS,MAAM;CACf,GAAI,M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CAAC;AAIF,QAAO,mBAAmB,OAAO,YAAY,eAAe,aAAa,OAAO;CAEhF,MAAM,SAAS,OAAO,QACpB,WAAW;EACX;EACA,YAAY;EACZ,MAAM,CAAC,MAAM,MAAM;EACnB,QAAQ,CACP;GAAE,QAAQ;GAAa,QAAQ;GAAc,EAC7C;GAAE,QAAQ;GAAU,QAAQ;GAAe,CAC3C;EACD,eAAe,IAAI;EACnB,CAAC,CACD,KACA,OAAO,UACL,QACA,eAAe,SAAS;EACvB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,SAAS,8BAA8B,IAAI,OAAO,IAAI,IAAI;EAC1D,OAAO;EACP,CAAC,CACH,CACD;AACF,KAAI,OAAO,aAAa,EACvB,QAAO,OAAO,OAAO,KACpB,eAAe,mBAAmB,QAAQ,OAAO,YAAY,OAAO,YAAY,CAChF;AAEF,QAAO,OAAO,iBAAiB,OAAO,QAAQ,OAAO,YAAY,OAAO,YAAY;EACnF,CAAC,KAAK,OAAO,SAAS,8BAA8B,CAAC;AAExD,MAAa,gBACZ,WAC6D;AAC7D,KAAI,OAAO,mBAAmB,KAAA,EAC7B,QAAO,sBAAsB,QAAQ,OAAO,eAAe;AAE5D,KAAI,OAAO,YAAY,KAAA,KAAa,OAAO,eAAe,KAAA,EACzD,QAAO,gBAAgB,QAAQ,OAAO,SAAS,OAAO,WAAW;AAElE,QAAO,OAAO,KACb,eAAe,SAAS;EACvB,YAAY,OAAO;EACnB,aAAa,OAAO;EACpB,SACC;EAED,CAAC,CACF"}
|
|
@@ -1,151 +0,0 @@
|
|
|
1
|
-
import { withPluginSpan } from "../observability/spans.mjs";
|
|
2
|
-
import "../capability-sinks/index.mjs";
|
|
3
|
-
import { CapabilityFactoryFailed } from "./errors.mjs";
|
|
4
|
-
import "../observability/index.mjs";
|
|
5
|
-
import { StrategyRegistryService } from "../strategy-registry/service.mjs";
|
|
6
|
-
import { OptionalService, noopStrategyRegistry, publish } from "./wiring.mjs";
|
|
7
|
-
import { Cause, Effect, Scope } from "effect";
|
|
8
|
-
//#region src/substrate/runtime/supervisor/dispatch-contributions.ts
|
|
9
|
-
const strategyRegistryAccess = OptionalService(StrategyRegistryService);
|
|
10
|
-
/**
|
|
11
|
-
* Render the underlying cause of a `ContributionSinkFailed` to a single
|
|
12
|
-
* human string for the operator-facing warning log.
|
|
13
|
-
*
|
|
14
|
-
* `ContributionSinkFailed.cause` is `unknown` — the failing sink may
|
|
15
|
-
* reject with an Effect `Cause`, a tagged domain error (e.g.
|
|
16
|
-
* `RouterBootFailed`, which carries the spec-mismatch `detail`), a plain
|
|
17
|
-
* `Error`, or an arbitrary value. The original wrapper only logged its
|
|
18
|
-
* own generic `err.message` ("capability sink 'routable' failed") and
|
|
19
|
-
* DROPPED this cause, so an operator saw a healthy-looking stack with
|
|
20
|
-
* dead RPC/wallet routing and no way to learn why. This recovers the
|
|
21
|
-
* real detail across all of those shapes:
|
|
22
|
-
* - `Cause` → `Cause.pretty` (full failure tree).
|
|
23
|
-
* - `Error` → `.stack ?? .message` (keeps the tag + detail; a
|
|
24
|
-
* `TaggedError`'s `toString()` includes `_tag` and its fields).
|
|
25
|
-
* - anything else → `JSON.stringify`, falling back to `String` when
|
|
26
|
-
* the value is not serializable (cyclic / BigInt).
|
|
27
|
-
*/
|
|
28
|
-
const formatCause = (cause) => {
|
|
29
|
-
if (Cause.isCause(cause)) return Cause.pretty(cause);
|
|
30
|
-
if (cause instanceof Error) return cause.stack ?? cause.message;
|
|
31
|
-
if (typeof cause === "string") return cause;
|
|
32
|
-
try {
|
|
33
|
-
return JSON.stringify(cause) ?? String(cause);
|
|
34
|
-
} catch {
|
|
35
|
-
return String(cause);
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
/**
|
|
39
|
-
* Best-effort discriminator for the wrapped cause — the failing sink
|
|
40
|
-
* error's `_tag` (e.g. `RouterBootFailed`) when present. Feeds the
|
|
41
|
-
* additive optional `causeType` on the `dispatchFailed` event so a
|
|
42
|
-
* renderer/log consumer can route on the failure category without
|
|
43
|
-
* parsing the message. Returns `undefined` for untagged causes so the
|
|
44
|
-
* field is simply omitted.
|
|
45
|
-
*/
|
|
46
|
-
const causeTagOf = (cause) => {
|
|
47
|
-
if (typeof cause === "object" && cause !== null && "_tag" in cause && typeof cause._tag === "string") return cause._tag;
|
|
48
|
-
};
|
|
49
|
-
/**
|
|
50
|
-
* Resolve a plugin's `capabilities` field to a concrete decl tuple.
|
|
51
|
-
*
|
|
52
|
-
* Two accepted shapes (see `Plugin.capabilities` for the
|
|
53
|
-
* authoring-side contract):
|
|
54
|
-
*
|
|
55
|
-
* (a) Static — a plain `ReadonlyArray<CapabilityDecl>`. Returned
|
|
56
|
-
* as-is.
|
|
57
|
-
*
|
|
58
|
-
* (b) Dynamic — a `CapabilitiesFactory<…>` function. Invoked with
|
|
59
|
-
* the resolved plugin value + the acquire context built from
|
|
60
|
-
* the supervisor's identity + runtime root. The function is
|
|
61
|
-
* called once per acquire (post-success); the returned tuple
|
|
62
|
-
* flows into `dispatchContributions` like a static one.
|
|
63
|
-
*
|
|
64
|
-
* The dynamic seam exists so plugins' snapshot subtrees, codegen
|
|
65
|
-
* bindings, routable URLs, strategy contributions, etc. can stamp
|
|
66
|
-
* the REAL chain id / package id / network alias produced by their
|
|
67
|
-
* acquire body, instead of the factory-time placeholder strings the
|
|
68
|
-
* static form forces.
|
|
69
|
-
*
|
|
70
|
-
* The substrate stays generic: this resolver doesn't know any
|
|
71
|
-
* service name; the discrimination is purely structural
|
|
72
|
-
* (`typeof === 'function'`).
|
|
73
|
-
*/
|
|
74
|
-
const resolveCapabilities = (pluginKey, field, resolved, acquireContext) => {
|
|
75
|
-
if (field === void 0) return Effect.succeed([]);
|
|
76
|
-
if (typeof field === "function") return Effect.try({
|
|
77
|
-
try: () => field(resolved, acquireContext),
|
|
78
|
-
catch: (cause) => new CapabilityFactoryFailed({
|
|
79
|
-
pluginKey,
|
|
80
|
-
message: `capability factory failed for ${pluginKey}`,
|
|
81
|
-
cause
|
|
82
|
-
})
|
|
83
|
-
});
|
|
84
|
-
return Effect.succeed(field);
|
|
85
|
-
};
|
|
86
|
-
/**
|
|
87
|
-
* Walk a plugin's `capabilities` tuple + `errorContributions` after a
|
|
88
|
-
* successful acquire, route every contribution through the
|
|
89
|
-
* substrate-owned `CapabilitySinksService`. The plugin's scope is
|
|
90
|
-
* provided so each sink's `addFinalizer` lands on the plugin's scope —
|
|
91
|
-
* registrations reap on selective-restart / shutdown.
|
|
92
|
-
*
|
|
93
|
-
* The supervisor stays kind-blind: it builds the contribution union
|
|
94
|
-
* (`{source: 'capability'|'error', ...}`) and the dispatch happens
|
|
95
|
-
* inside the service. Unknown kinds are downgraded to no-ops here so
|
|
96
|
-
* the substrate-open-by-default contract holds — plugin authors can
|
|
97
|
-
* emit a custom-kind decl that is observed only by the orchestrators
|
|
98
|
-
* that registered the matching sink.
|
|
99
|
-
*
|
|
100
|
-
* Sink failures (`ContributionSinkFailed`) are routed through a
|
|
101
|
-
* separate `engine.orchestrator.dispatchFailed` event so the plugin
|
|
102
|
-
* remains ready and the orchestrator's broken sink is the visible
|
|
103
|
-
* fault (backlog #39).
|
|
104
|
-
*/
|
|
105
|
-
const dispatchContributions = (pluginKey, capabilities, errorContributions, pluginRole, identity, pluginContext, pluginScope, sinks, ref, hub) => Effect.gen(function* () {
|
|
106
|
-
const strategyRegistry = strategyRegistryAccess.read(pluginContext, noopStrategyRegistry);
|
|
107
|
-
const harvestCtx = {
|
|
108
|
-
pluginKey,
|
|
109
|
-
identity,
|
|
110
|
-
publish: (event) => publish(ref, hub, event),
|
|
111
|
-
registerStrategy: (decl) => strategyRegistry.register(decl.capabilityKey, decl.strategy, {
|
|
112
|
-
autoMounted: decl.autoMounted,
|
|
113
|
-
...decl.priority === void 0 ? {} : { priority: decl.priority }
|
|
114
|
-
})
|
|
115
|
-
};
|
|
116
|
-
const items = [...capabilities.map((decl) => ({
|
|
117
|
-
source: "capability",
|
|
118
|
-
decl
|
|
119
|
-
})), ...errorContributions.map((contribution) => ({
|
|
120
|
-
source: "error",
|
|
121
|
-
contribution
|
|
122
|
-
}))];
|
|
123
|
-
for (const item of items) {
|
|
124
|
-
const dispatch = sinks.dispatch(item, harvestCtx).pipe(Effect.catchTags({
|
|
125
|
-
UnknownContributionKind: () => Effect.void,
|
|
126
|
-
ContributionSinkFailed: (err) => Effect.gen(function* () {
|
|
127
|
-
const causeType = causeTagOf(err.cause);
|
|
128
|
-
yield* publish(ref, hub, {
|
|
129
|
-
tag: "engine.orchestrator.dispatchFailed",
|
|
130
|
-
pluginKey,
|
|
131
|
-
kind: err.kind,
|
|
132
|
-
message: err.message,
|
|
133
|
-
...causeType === void 0 ? {} : { causeType },
|
|
134
|
-
at: Date.now()
|
|
135
|
-
});
|
|
136
|
-
yield* Effect.logWarning(`capability sink '${err.kind}' failed for plugin '${pluginKey}': ${formatCause(err.cause)}`);
|
|
137
|
-
})
|
|
138
|
-
}));
|
|
139
|
-
yield* Scope.provide(dispatch, pluginScope);
|
|
140
|
-
}
|
|
141
|
-
}).pipe(withPluginSpan("lifecycle.supervisor.dispatchContributions", {
|
|
142
|
-
app: identity.app,
|
|
143
|
-
stack: identity.stack,
|
|
144
|
-
network: identity.chain,
|
|
145
|
-
pluginKey,
|
|
146
|
-
role: pluginRole
|
|
147
|
-
}));
|
|
148
|
-
//#endregion
|
|
149
|
-
export { dispatchContributions, resolveCapabilities };
|
|
150
|
-
|
|
151
|
-
//# sourceMappingURL=dispatch-contributions.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"dispatch-contributions.mjs","names":[],"sources":["../../../../src/substrate/runtime/supervisor/dispatch-contributions.ts"],"sourcesContent":["// Supervisor capability-dispatch path.\n//\n// Walks a plugin's `capabilities` tuple + `errorContributions` after a\n// successful acquire and routes each item through the substrate-owned\n// `CapabilitySinksService`.\n//\n// Bug-fix history (backlog #39): the original implementation only\n// caught `UnknownContributionKind` from `sinks.dispatch()`. The error\n// channel also yields `ContributionSinkFailed` (a registered sink\n// rejected while handling a known kind — router/codegen collisions,\n// upstream IO faults). The wrapping `Effect.exit` at the acquire-node\n// callsite then projected the failure through `registry.markFailed`,\n// attributing the orchestrator's bug to the plugin.\n//\n// Fix: catch BOTH tags here and route them DIFFERENTLY.\n// - `UnknownContributionKind` → no-op (substrate-open-by-default;\n// the plugin emitted a contribution shape no sink claims).\n// - `ContributionSinkFailed` → publish the typed\n// `engine.orchestrator.dispatchFailed` event + log a warning; the\n// plugin stays ready.\n\nimport { Cause, Context, Effect, Queue, Scope, SubscriptionRef } from 'effect';\n\nimport type { CapabilityDecl } from '../../../contracts/capability-decl.ts';\nimport type { StrategyContributorDecl } from '../../../contracts/strategy-contributor.ts';\nimport type { PluginKey } from '../../brand.ts';\nimport type { EngineEvent } from '../../events.ts';\nimport type { Identity } from '../../identity.ts';\nimport type { PluginRole } from '../../lifecycle.ts';\nimport type { AcquireContext, PluginErrorContribution } from '../../plugin.ts';\nimport type { SubscribableState } from '../../projection.ts';\nimport {\n\ttype AnyContribution,\n\ttype CapabilitySinksShape,\n\ttype HarvestContext,\n} from '../capability-sinks/index.ts';\nimport { withPluginSpan } from '../observability/index.ts';\nimport { StrategyRegistryService } from '../strategy-registry/service.ts';\nimport { CapabilityFactoryFailed } from './errors.ts';\nimport { noopStrategyRegistry, OptionalService, publish } from './wiring.ts';\n\nconst strategyRegistryAccess = OptionalService(StrategyRegistryService);\n\n/**\n * Render the underlying cause of a `ContributionSinkFailed` to a single\n * human string for the operator-facing warning log.\n *\n * `ContributionSinkFailed.cause` is `unknown` — the failing sink may\n * reject with an Effect `Cause`, a tagged domain error (e.g.\n * `RouterBootFailed`, which carries the spec-mismatch `detail`), a plain\n * `Error`, or an arbitrary value. The original wrapper only logged its\n * own generic `err.message` (\"capability sink 'routable' failed\") and\n * DROPPED this cause, so an operator saw a healthy-looking stack with\n * dead RPC/wallet routing and no way to learn why. This recovers the\n * real detail across all of those shapes:\n * - `Cause` → `Cause.pretty` (full failure tree).\n * - `Error` → `.stack ?? .message` (keeps the tag + detail; a\n * `TaggedError`'s `toString()` includes `_tag` and its fields).\n * - anything else → `JSON.stringify`, falling back to `String` when\n * the value is not serializable (cyclic / BigInt).\n */\nconst formatCause = (cause: unknown): string => {\n\tif (Cause.isCause(cause)) return Cause.pretty(cause);\n\tif (cause instanceof Error) return cause.stack ?? cause.message;\n\tif (typeof cause === 'string') return cause;\n\ttry {\n\t\treturn JSON.stringify(cause) ?? String(cause);\n\t} catch {\n\t\treturn String(cause);\n\t}\n};\n\n/**\n * Best-effort discriminator for the wrapped cause — the failing sink\n * error's `_tag` (e.g. `RouterBootFailed`) when present. Feeds the\n * additive optional `causeType` on the `dispatchFailed` event so a\n * renderer/log consumer can route on the failure category without\n * parsing the message. Returns `undefined` for untagged causes so the\n * field is simply omitted.\n */\nconst causeTagOf = (cause: unknown): string | undefined => {\n\tif (\n\t\ttypeof cause === 'object' &&\n\t\tcause !== null &&\n\t\t'_tag' in cause &&\n\t\ttypeof (cause as { _tag: unknown })._tag === 'string'\n\t) {\n\t\treturn (cause as { _tag: string })._tag;\n\t}\n\treturn undefined;\n};\n\n/**\n * Resolve a plugin's `capabilities` field to a concrete decl tuple.\n *\n * Two accepted shapes (see `Plugin.capabilities` for the\n * authoring-side contract):\n *\n * (a) Static — a plain `ReadonlyArray<CapabilityDecl>`. Returned\n * as-is.\n *\n * (b) Dynamic — a `CapabilitiesFactory<…>` function. Invoked with\n * the resolved plugin value + the acquire context built from\n * the supervisor's identity + runtime root. The function is\n * called once per acquire (post-success); the returned tuple\n * flows into `dispatchContributions` like a static one.\n *\n * The dynamic seam exists so plugins' snapshot subtrees, codegen\n * bindings, routable URLs, strategy contributions, etc. can stamp\n * the REAL chain id / package id / network alias produced by their\n * acquire body, instead of the factory-time placeholder strings the\n * static form forces.\n *\n * The substrate stays generic: this resolver doesn't know any\n * service name; the discrimination is purely structural\n * (`typeof === 'function'`).\n */\nexport const resolveCapabilities = (\n\tpluginKey: PluginKey,\n\tfield:\n\t\t| ReadonlyArray<CapabilityDecl>\n\t\t| ((resolved: unknown, ctx: AcquireContext) => ReadonlyArray<CapabilityDecl>)\n\t\t| undefined,\n\tresolved: unknown,\n\tacquireContext: AcquireContext,\n): Effect.Effect<ReadonlyArray<CapabilityDecl>, CapabilityFactoryFailed> => {\n\tif (field === undefined) return Effect.succeed([]);\n\tif (typeof field === 'function') {\n\t\treturn Effect.try({\n\t\t\ttry: () => field(resolved, acquireContext),\n\t\t\tcatch: (cause) =>\n\t\t\t\tnew CapabilityFactoryFailed({\n\t\t\t\t\tpluginKey,\n\t\t\t\t\tmessage: `capability factory failed for ${pluginKey}`,\n\t\t\t\t\tcause,\n\t\t\t\t}),\n\t\t});\n\t}\n\treturn Effect.succeed(field);\n};\n\n/**\n * Walk a plugin's `capabilities` tuple + `errorContributions` after a\n * successful acquire, route every contribution through the\n * substrate-owned `CapabilitySinksService`. The plugin's scope is\n * provided so each sink's `addFinalizer` lands on the plugin's scope —\n * registrations reap on selective-restart / shutdown.\n *\n * The supervisor stays kind-blind: it builds the contribution union\n * (`{source: 'capability'|'error', ...}`) and the dispatch happens\n * inside the service. Unknown kinds are downgraded to no-ops here so\n * the substrate-open-by-default contract holds — plugin authors can\n * emit a custom-kind decl that is observed only by the orchestrators\n * that registered the matching sink.\n *\n * Sink failures (`ContributionSinkFailed`) are routed through a\n * separate `engine.orchestrator.dispatchFailed` event so the plugin\n * remains ready and the orchestrator's broken sink is the visible\n * fault (backlog #39).\n */\nexport const dispatchContributions = (\n\tpluginKey: PluginKey,\n\tcapabilities: ReadonlyArray<CapabilityDecl>,\n\terrorContributions: ReadonlyArray<PluginErrorContribution>,\n\tpluginRole: PluginRole,\n\tidentity: Identity,\n\tpluginContext: Context.Context<never>,\n\tpluginScope: Scope.Scope,\n\tsinks: CapabilitySinksShape,\n\tref: SubscriptionRef.SubscriptionRef<SubscribableState>,\n\thub: Queue.Enqueue<EngineEvent>,\n): Effect.Effect<void, never, never> =>\n\tEffect.gen(function* () {\n\t\tconst strategyRegistry = strategyRegistryAccess.read(pluginContext, noopStrategyRegistry);\n\t\tconst harvestCtx: HarvestContext = {\n\t\t\tpluginKey,\n\t\t\tidentity,\n\t\t\tpublish: (event) => publish(ref, hub, event),\n\t\t\tregisterStrategy: (decl: StrategyContributorDecl<string, unknown>) =>\n\t\t\t\tstrategyRegistry.register(decl.capabilityKey, decl.strategy, {\n\t\t\t\t\tautoMounted: decl.autoMounted,\n\t\t\t\t\t...(decl.priority === undefined ? {} : { priority: decl.priority }),\n\t\t\t\t}),\n\t\t};\n\n\t\tconst items: ReadonlyArray<AnyContribution> = [\n\t\t\t...capabilities.map<AnyContribution>((decl) => ({\n\t\t\t\tsource: 'capability',\n\t\t\t\tdecl,\n\t\t\t})),\n\t\t\t...errorContributions.map<AnyContribution>((contribution) => ({\n\t\t\t\tsource: 'error',\n\t\t\t\tcontribution,\n\t\t\t})),\n\t\t];\n\n\t\tfor (const item of items) {\n\t\t\tconst dispatch = sinks.dispatch(item, harvestCtx).pipe(\n\t\t\t\tEffect.catchTags({\n\t\t\t\t\tUnknownContributionKind: () => Effect.void,\n\t\t\t\t\tContributionSinkFailed: (err) =>\n\t\t\t\t\t\tEffect.gen(function* () {\n\t\t\t\t\t\t\t// Orchestrator-fault path: surface the typed event so\n\t\t\t\t\t\t\t// renderers + log consumers see WHICH sink failed\n\t\t\t\t\t\t\t// without misattributing to the plugin. The plugin's\n\t\t\t\t\t\t\t// lifecycle state is untouched; the markFailed path\n\t\t\t\t\t\t\t// in `acquireNode` is NOT taken for this branch.\n\t\t\t\t\t\t\t//\n\t\t\t\t\t\t\t// The underlying cause MUST travel with the warning:\n\t\t\t\t\t\t\t// a non-fatal sink (e.g. `routable`) leaves the plugin\n\t\t\t\t\t\t\t// `ready`, so without the cause an operator sees a\n\t\t\t\t\t\t\t// healthy-looking stack with dead RPC/wallet routing\n\t\t\t\t\t\t\t// and no diagnosis. `err.cause` holds the real domain\n\t\t\t\t\t\t\t// error (e.g. `RouterBootFailed` + its spec-mismatch\n\t\t\t\t\t\t\t// `detail`); we stringify it for the log and lift its\n\t\t\t\t\t\t\t// `_tag` onto the event's additive `causeType`.\n\t\t\t\t\t\t\tconst causeType = causeTagOf(err.cause);\n\t\t\t\t\t\t\tyield* publish(ref, hub, {\n\t\t\t\t\t\t\t\ttag: 'engine.orchestrator.dispatchFailed',\n\t\t\t\t\t\t\t\tpluginKey,\n\t\t\t\t\t\t\t\tkind: err.kind,\n\t\t\t\t\t\t\t\tmessage: err.message,\n\t\t\t\t\t\t\t\t...(causeType === undefined ? {} : { causeType }),\n\t\t\t\t\t\t\t\tat: Date.now(),\n\t\t\t\t\t\t\t});\n\t\t\t\t\t\t\tyield* Effect.logWarning(\n\t\t\t\t\t\t\t\t`capability sink '${err.kind}' failed for plugin '${pluginKey}': ${formatCause(err.cause)}`,\n\t\t\t\t\t\t\t);\n\t\t\t\t\t\t}),\n\t\t\t\t}),\n\t\t\t);\n\t\t\tyield* Scope.provide(dispatch, pluginScope);\n\t\t}\n\t}).pipe(\n\t\twithPluginSpan('lifecycle.supervisor.dispatchContributions', {\n\t\t\tapp: identity.app,\n\t\t\tstack: identity.stack,\n\t\t\tnetwork: identity.chain,\n\t\t\tpluginKey,\n\t\t\trole: pluginRole,\n\t\t}),\n\t);\n"],"mappings":";;;;;;;;AAyCA,MAAM,yBAAyB,gBAAgB,wBAAwB;;;;;;;;;;;;;;;;;;;AAoBvE,MAAM,eAAe,UAA2B;AAC/C,KAAI,MAAM,QAAQ,MAAM,CAAE,QAAO,MAAM,OAAO,MAAM;AACpD,KAAI,iBAAiB,MAAO,QAAO,MAAM,SAAS,MAAM;AACxD,KAAI,OAAO,UAAU,SAAU,QAAO;AACtC,KAAI;AACH,SAAO,KAAK,UAAU,MAAM,IAAI,OAAO,MAAM;SACtC;AACP,SAAO,OAAO,MAAM;;;;;;;;;;;AAYtB,MAAM,cAAc,UAAuC;AAC1D,KACC,OAAO,UAAU,YACjB,UAAU,QACV,UAAU,SACV,OAAQ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EAAE,GAAG,EAAE,WAAW;KAChD,IAAI,KAAK,KAAK;KACd,CAAC;AACF,WAAO,OAAO,WACb,oBAAoB,IAAI,KAAK,uBAAuB,UAAU,KAAK,YAAY,IAAI,MAAM,GACzF;KACA;GACH,CAAC,CACF;AACD,SAAO,MAAM,QAAQ,UAAU,YAAY;;EAE3C,CAAC,KACF,eAAe,8CAA8C;CAC5D,KAAK,SAAS;CACd,OAAO,SAAS;CAChB,SAAS,SAAS;CAClB;CACA,MAAM;CACN,CAAC,CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import { Effect } from "effect";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|