space-data-module-sdk 0.8.3 → 0.8.5
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 +117 -20
- package/bin/space-data-module.js +263 -0
- package/docs/.nojekyll +1 -0
- package/docs/AGENTS.md +34 -0
- package/docs/architecture.svg +141 -0
- package/docs/browser-wasmedge-isomorphic.md +179 -0
- package/docs/flatsql-streaming-standard.md +341 -0
- package/docs/gpu-module-abi.md +193 -0
- package/docs/index.html +125 -0
- package/docs/isomorphic-pthreads.md +188 -0
- package/docs/isomorphic-sdn-runtime-plan.md +167 -0
- package/docs/language-runtime-matrix.md +82 -0
- package/docs/manifest-structure.svg +114 -0
- package/docs/module-bundle-runtime-plan.md +19 -0
- package/docs/module-lifecycle.svg +70 -0
- package/docs/module-publication-standard.md +540 -0
- package/docs/node-red-default-node-parity.md +88 -0
- package/docs/protocol-installation.md +196 -0
- package/docs/secrets-capability.md +152 -0
- package/docs/styles.css +288 -0
- package/docs/testing-harness.md +408 -0
- package/docs/tri-runtime-parity.md +132 -0
- package/docs/wallet-callback.html +2 -0
- package/package.json +26 -6
- package/schemas/HttpRequestAbi.fbs +41 -0
- package/schemas/HttpResponseAbi.fbs +36 -0
- package/schemas/PluginManifest.fbs +2 -1
- package/src/AGENTS.md +1 -1
- package/src/app/codec.js +548 -0
- package/src/app/index.js +6 -0
- package/src/browser.js +5 -0
- package/src/bundle/constants.js +1 -0
- package/src/bundle/index.js +15 -0
- package/src/bundle/sigdomain.js +179 -0
- package/src/bundle/signing.js +767 -0
- package/src/bundle/wasm.js +3 -2
- package/src/capabilities.js +3 -0
- package/src/compat/index.js +7 -0
- package/src/compat/sdnLegacy.js +449 -0
- package/src/compiler/compileModule.js +556 -55
- package/src/compiler/flatcSupport.js +41 -27
- package/src/compiler/index.d.ts +2 -0
- package/src/compiler/index.js +18 -0
- package/src/compiler/invokeGlue.js +1212 -183
- package/src/compiler/pthreadArtifactGuard.js +910 -0
- package/src/compiler/sdnShimGenerator.js +323 -0
- package/src/compiler/wasiThreadsToolchain.js +150 -0
- package/src/compliance/index.js +11 -1
- package/src/compliance/legacyWildcardPorts.js +228 -0
- package/src/compliance/pluginCompliance.js +1000 -96
- package/src/field-stream/index.d.ts +31 -0
- package/src/field-stream/index.js +119 -0
- package/src/flow/dependencyStreamBridge.js +234 -0
- package/src/flow/flatsqlLinkShim.js +304 -0
- package/src/flow/flowCodec.js +107 -0
- package/src/flow/flowCompiler.js +2900 -0
- package/src/flow/flowRuntimeHost.js +877 -0
- package/src/flow/index.d.ts +117 -0
- package/src/flow/index.js +31 -0
- package/src/flow/isomorphicFlowHost.js +384 -0
- package/src/flow/jsFlowRuntime.js +275 -0
- package/src/flow/normalize.js +294 -0
- package/src/flow/runtime-src/flow_runtime.cpp +1699 -0
- package/src/flow/vendor/sdn-flow/MethodRegistry.js +400 -0
- package/src/flow/vendor/sdn-flow/constants.js +39 -0
- package/src/flow/vendor/sdn-flow/index.js +29 -0
- package/src/flow/vendor/sdn-flow/normalize.js +506 -0
- package/src/flow/vendor/sdn-flow/wasmCompatibility.js +189 -0
- package/src/generated/http/cpp/HttpRequestAbi_generated.h +285 -0
- package/src/generated/http/cpp/HttpResponseAbi_generated.h +192 -0
- package/src/generated/http/sdn/http/http-header.js +53 -0
- package/src/generated/http/sdn/http/http-header.ts +67 -0
- package/src/generated/http/sdn/http/http-request.js +132 -0
- package/src/generated/http/sdn/http/http-request.ts +179 -0
- package/src/generated/http/sdn/http/http-response.js +144 -0
- package/src/generated/http/sdn/http/http-response.ts +168 -0
- package/src/generated/http/sdn/http.js +11 -0
- package/src/generated/http/sdn/http.ts +4 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts +12 -0
- package/src/generated/orbpro/flow/backpressure-policy.d.ts.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.js +17 -0
- package/src/generated/orbpro/flow/backpressure-policy.js.map +1 -0
- package/src/generated/orbpro/flow/backpressure-policy.ts +15 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts +142 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js +304 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.js.map +1 -0
- package/src/generated/orbpro/flow/flow-bundle-manifest.ts +399 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts +113 -0
- package/src/generated/orbpro/flow/flow-edge.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.js +221 -0
- package/src/generated/orbpro/flow/flow-edge.js.map +1 -0
- package/src/generated/orbpro/flow/flow-edge.ts +292 -0
- package/src/generated/orbpro/flow/flow-node.d.ts +80 -0
- package/src/generated/orbpro/flow/flow-node.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-node.js +158 -0
- package/src/generated/orbpro/flow/flow-node.js.map +1 -0
- package/src/generated/orbpro/flow/flow-node.ts +202 -0
- package/src/generated/orbpro/flow/flow-program.d.ts +164 -0
- package/src/generated/orbpro/flow/flow-program.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-program.js +350 -0
- package/src/generated/orbpro/flow/flow-program.js.map +1 -0
- package/src/generated/orbpro/flow/flow-program.ts +477 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts +108 -0
- package/src/generated/orbpro/flow/flow-trigger.d.ts.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.js +207 -0
- package/src/generated/orbpro/flow/flow-trigger.js.map +1 -0
- package/src/generated/orbpro/flow/flow-trigger.ts +276 -0
- package/src/generated/orbpro/flow/node-kind.d.ts +13 -0
- package/src/generated/orbpro/flow/node-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/node-kind.js +16 -0
- package/src/generated/orbpro/flow/node-kind.js.map +1 -0
- package/src/generated/orbpro/{invoke.ts → flow/node-kind.ts} +12 -2
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts +52 -0
- package/src/generated/orbpro/flow/plugin-version-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js +85 -0
- package/src/generated/orbpro/flow/plugin-version-binding.js.map +1 -0
- package/src/generated/orbpro/flow/plugin-version-binding.ts +121 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts +70 -0
- package/src/generated/orbpro/flow/schema-hash-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js +143 -0
- package/src/generated/orbpro/flow/schema-hash-binding.js.map +1 -0
- package/src/generated/orbpro/flow/schema-hash-binding.ts +189 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts +71 -0
- package/src/generated/orbpro/flow/trigger-binding.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.js +142 -0
- package/src/generated/orbpro/flow/trigger-binding.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-binding.ts +181 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts +14 -0
- package/src/generated/orbpro/flow/trigger-kind.d.ts.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.js +17 -0
- package/src/generated/orbpro/flow/trigger-kind.js.map +1 -0
- package/src/generated/orbpro/flow/trigger-kind.ts +17 -0
- package/src/generated/orbpro/flow.d.ts +21 -0
- package/src/generated/orbpro/flow.d.ts.map +1 -0
- package/src/generated/orbpro/flow.js +23 -0
- package/src/generated/orbpro/flow.js.map +1 -0
- package/src/generated/orbpro/flow.ts +24 -0
- package/src/generated/orbpro/manifest/capability-kind.d.ts +2 -1
- package/src/generated/orbpro/manifest/capability-kind.js +1 -0
- package/src/generated/orbpro/manifest/capability-kind.ts +1 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.d.ts +93 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.js +160 -0
- package/src/generated/orbpro/plugin/stream-invoke-request.ts +211 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.d.ts +99 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.js +175 -0
- package/src/generated/orbpro/plugin/stream-invoke-response.ts +226 -0
- package/src/generated/orbpro/plugin.js +8 -0
- package/src/generated/orbpro/stream.d.ts +12 -0
- package/src/generated/orbpro/stream.js +14 -0
- package/src/generated/orbpro/stream.ts +15 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts +52 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.js +106 -0
- package/src/generated/spacedatastandards/plg/EntryFunction.ts +162 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts +90 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.js +189 -0
- package/src/generated/spacedatastandards/plg/FlatBufferTypeRef.ts +270 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts +492 -0
- package/src/generated/spacedatastandards/plg/PLG.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLG.js +1139 -0
- package/src/generated/spacedatastandards/plg/PLG.ts +1600 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts +63 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.js +138 -0
- package/src/generated/spacedatastandards/plg/PLGAcceptedTypeSet.ts +189 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.js +104 -0
- package/src/generated/spacedatastandards/plg/PLGBuildArtifact.ts +151 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts +68 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.js +124 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdge.ts +184 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts +58 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.js +126 -0
- package/src/generated/spacedatastandards/plg/PLGFlowEdgeContract.ts +161 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.js +164 -0
- package/src/generated/spacedatastandards/plg/PLGFlowNode.ts +244 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts +55 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.js +105 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTrigger.ts +162 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.js +83 -0
- package/src/generated/spacedatastandards/plg/PLGFlowTriggerBinding.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts +36 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.js +90 -0
- package/src/generated/spacedatastandards/plg/PLGHostCapability.ts +127 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts +53 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.js +153 -0
- package/src/generated/spacedatastandards/plg/PLGMethodManifest.ts +210 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts +70 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.js +149 -0
- package/src/generated/spacedatastandards/plg/PLGPortManifest.ts +212 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts +73 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.js +199 -0
- package/src/generated/spacedatastandards/plg/PLGProtocolSpec.ts +292 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts +40 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.js +103 -0
- package/src/generated/spacedatastandards/plg/PLGTimerSpec.ts +148 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts +41 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginCapability.js +82 -0
- package/src/generated/spacedatastandards/plg/{plugin-capability.ts → PluginCapability.ts} +55 -18
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts +42 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.js +80 -0
- package/src/generated/spacedatastandards/plg/PluginDependency.ts +124 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts +85 -0
- package/src/generated/spacedatastandards/plg/TAB.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/TAB.js +173 -0
- package/src/generated/spacedatastandards/plg/TAB.ts +228 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferMutability.ts +23 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.js +20 -0
- package/src/generated/spacedatastandards/plg/bufferOwnership.ts +23 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts +20 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.js +22 -0
- package/src/generated/spacedatastandards/plg/drainBehavior.ts +25 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts +10 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.js +12 -0
- package/src/generated/spacedatastandards/plg/flowEdgeRoutePolicy.ts +13 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts +51 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.js +53 -0
- package/src/generated/spacedatastandards/plg/hostCapabilityKind.ts +55 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts +15 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.js +17 -0
- package/src/generated/spacedatastandards/plg/invokeSurfaceKind.ts +19 -0
- package/src/generated/spacedatastandards/plg/main.d.ts +29 -0
- package/src/generated/spacedatastandards/plg/main.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/main.js +30 -0
- package/src/generated/spacedatastandards/plg/main.ts +32 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts +17 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.js +19 -0
- package/src/generated/spacedatastandards/plg/payloadWireFormat.ts +21 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts +82 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.js +84 -0
- package/src/generated/spacedatastandards/plg/pluginCategory.ts +103 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/publicationState.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/publicationState.js +20 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts +18 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.d.ts.map +1 -0
- package/src/generated/spacedatastandards/plg/purchaseTier.js +20 -0
- package/src/host/AGENTS.md +2 -2
- package/src/host/abi.js +53 -66
- package/src/host/browserHost.js +355 -8
- package/src/host/cpp/keyslotClient.hpp +231 -0
- package/src/host/cpp/secretsClient.hpp +583 -0
- package/src/host/hostcallWire.js +183 -0
- package/src/host/index.js +2 -0
- package/src/host/isomorphicLoader.js +44 -7
- package/src/host/nodeHost.js +227 -8
- package/src/host/sabHostcallChannel.js +206 -0
- package/src/host/timerDriver.js +203 -0
- package/src/host/wasiShim.js +41 -1
- package/src/host/wasiThreadBrowserWorker.mjs +48 -0
- package/src/host/wasiThreadHost.js +393 -0
- package/src/host/wasiThreadWorker.mjs +32 -0
- package/src/host/wasiThreadWorkerRuntime.js +93 -0
- package/src/http/index.js +339 -0
- package/src/index.d.ts +716 -10
- package/src/index.js +4 -0
- package/src/invoke/codec.js +1202 -128
- package/src/invoke/index.js +5 -1
- package/src/licensing/index.d.ts +2 -0
- package/src/licensing/index.js +2 -0
- package/src/licensing/records.js +287 -8
- package/src/manifest/codec.js +62 -14
- package/src/manifest/index.js +2 -0
- package/src/manifest/legacyToPlg.js +164 -25
- package/src/manifest/normalize.js +1 -0
- package/src/manifest/plgCodec.js +1303 -62
- package/src/manifest/typeRefs.js +162 -24
- package/src/runtime/compiledRuntimeAbi.js +47 -0
- package/src/runtime/compiledRuntimeAbi.json +33 -0
- package/src/runtime/index.d.ts +32 -0
- package/src/runtime/index.js +1 -0
- package/src/runtime-host/index.js +3 -0
- package/src/runtime-host/methodRegistry.js +55 -0
- package/src/standards/index.js +200 -56
- package/src/standards/sharedCatalog.js +16 -0
- package/src/testing/browserModuleHarness.js +604 -31
- package/src/testing/docker/wasmedge-parity.Dockerfile +39 -0
- package/src/testing/index.d.ts +151 -0
- package/src/testing/index.js +21 -0
- package/src/testing/native/wasmedge_emscripten_pthread_runner.c +25 -1
- package/src/testing/parityBrowserRunner.js +138 -0
- package/src/testing/parityHarness.js +616 -0
- package/src/testing/parityLanes.js +537 -0
- package/src/testing/processInvoke.js +29 -21
- package/src/testing/streamInvokeCodec.js +10 -175
- package/src/testing/wasmedgePin.json +6 -0
- package/src/testing/workerModuleHarness.js +242 -0
- package/src/testing/workerModuleHarnessWorker.js +176 -0
- package/src/transport/index.js +3 -0
- package/src/transport/pki.js +299 -11
- package/src/transport/records.js +16 -7
- package/src/utils/ecdsaDer.js +106 -0
- package/src/utils/wasmCrypto.js +0 -43
- package/templates/gpu-module/README.md +48 -0
- package/templates/gpu-module/include/space_data_gpu_abi.h +122 -0
- package/templates/gpu-module/manifest.json +84 -0
- package/schemas/PluginInvokeRequest.fbs +0 -18
- package/schemas/PluginInvokeResponse.fbs +0 -30
- package/schemas/spacedatastandards/PLG.fbs +0 -191
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts +0 -51
- package/src/generated/orbpro/invoke/plugin-invoke-request.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.js +0 -131
- package/src/generated/orbpro/invoke/plugin-invoke-request.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-request.ts +0 -173
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts +0 -76
- package/src/generated/orbpro/invoke/plugin-invoke-response.d.ts.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.js +0 -184
- package/src/generated/orbpro/invoke/plugin-invoke-response.js.map +0 -1
- package/src/generated/orbpro/invoke/plugin-invoke-response.ts +0 -243
- package/src/generated/orbpro/invoke.d.ts +0 -3
- package/src/generated/orbpro/invoke.js +0 -5
- package/src/generated/spacedatastandards/plg/entry-function.js +0 -86
- package/src/generated/spacedatastandards/plg/entry-function.ts +0 -119
- package/src/generated/spacedatastandards/plg/index.js +0 -16
- package/src/generated/spacedatastandards/plg/index.ts +0 -11
- package/src/generated/spacedatastandards/plg/plg.js +0 -657
- package/src/generated/spacedatastandards/plg/plg.ts +0 -924
- package/src/generated/spacedatastandards/plg/plugin-capability.js +0 -66
- package/src/generated/spacedatastandards/plg/plugin-category.js +0 -15
- package/src/generated/spacedatastandards/plg/plugin-category.ts +0 -53
- package/src/generated/spacedatastandards/plg/plugin-dependency.js +0 -63
- package/src/generated/spacedatastandards/plg/plugin-dependency.ts +0 -86
- package/src/generated/spacedatastandards/plg/publication-state.js +0 -9
- package/src/generated/spacedatastandards/plg/purchase-tier.js +0 -9
- /package/src/generated/spacedatastandards/plg/{publication-state.ts → publicationState.ts} +0 -0
- /package/src/generated/spacedatastandards/plg/{purchase-tier.ts → purchaseTier.ts} +0 -0
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
export {
|
|
2
|
+
FLOW_INVALID_INDEX,
|
|
3
|
+
createFlowRuntimeHost,
|
|
4
|
+
createIsomorphicFlowRuntimeHost,
|
|
5
|
+
} from "../index.js";
|
|
6
|
+
|
|
7
|
+
export type {
|
|
8
|
+
FlowDependencyDescriptor,
|
|
9
|
+
FlowDrainOptions,
|
|
10
|
+
FlowDrainResult,
|
|
11
|
+
FlowEdgeDescriptor,
|
|
12
|
+
FlowEngineBodyReference,
|
|
13
|
+
FlowFrameData,
|
|
14
|
+
FlowFrameMutability,
|
|
15
|
+
FlowFrameOwnership,
|
|
16
|
+
FlowHandler,
|
|
17
|
+
FlowHandlerInvocation,
|
|
18
|
+
FlowHandlerMap,
|
|
19
|
+
FlowHandlerResult,
|
|
20
|
+
FlowIngressState,
|
|
21
|
+
FlowNodeDispatchDescriptor,
|
|
22
|
+
FlowNodeState,
|
|
23
|
+
FlowOutputFrame,
|
|
24
|
+
FlowRoutingState,
|
|
25
|
+
FlowRuntimeHost,
|
|
26
|
+
FlowRuntimeHostOptions,
|
|
27
|
+
FlowTriggerFrameOptions,
|
|
28
|
+
IsomorphicFlowChildOptions,
|
|
29
|
+
IsomorphicFlowChildRecord,
|
|
30
|
+
IsomorphicFlowDrainOptions,
|
|
31
|
+
IsomorphicFlowRuntimeHost,
|
|
32
|
+
IsomorphicFlowRuntimeHostOptions,
|
|
33
|
+
ModuleSignatureVerificationPolicy,
|
|
34
|
+
} from "../index.js";
|
|
35
|
+
|
|
36
|
+
export interface JavaScriptFlowRuntimeOptions {
|
|
37
|
+
registry?: {
|
|
38
|
+
getMethod(pluginId: string, methodId: string): unknown;
|
|
39
|
+
invoke(request: Record<string, unknown>): Promise<Record<string, unknown>>;
|
|
40
|
+
} | null;
|
|
41
|
+
maxInvocationsPerDrain?: number;
|
|
42
|
+
onSinkOutput?: (context: Record<string, unknown>) => unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export class FlowRuntime {
|
|
46
|
+
constructor(options?: JavaScriptFlowRuntimeOptions);
|
|
47
|
+
loadProgram<T = unknown>(program: T): T;
|
|
48
|
+
getProgram(): unknown;
|
|
49
|
+
inspectQueues(): Record<string, Record<string, number>>;
|
|
50
|
+
enqueueTriggerFrames(
|
|
51
|
+
triggerId: string,
|
|
52
|
+
frames: Array<Record<string, unknown>>,
|
|
53
|
+
): void;
|
|
54
|
+
enqueueNodeFrames(
|
|
55
|
+
nodeId: string,
|
|
56
|
+
portId: string,
|
|
57
|
+
frames: Array<Record<string, unknown>>,
|
|
58
|
+
backpressurePolicy?: string,
|
|
59
|
+
queueDepth?: number,
|
|
60
|
+
): void;
|
|
61
|
+
isIdle(): boolean;
|
|
62
|
+
drain(options?: {
|
|
63
|
+
maxInvocationsPerDrain?: number;
|
|
64
|
+
outputStreamCap?: number;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
invocations: number;
|
|
67
|
+
idle: boolean;
|
|
68
|
+
queues: Record<string, Record<string, number>>;
|
|
69
|
+
}>;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export function decodeFlowProgram(
|
|
73
|
+
data: Uint8Array | ArrayBuffer | ArrayBufferView,
|
|
74
|
+
): unknown;
|
|
75
|
+
export function encodeFlowProgram(program: unknown): Uint8Array;
|
|
76
|
+
export function decodePluginManifestPman(
|
|
77
|
+
data: Uint8Array | ArrayBuffer | ArrayBufferView,
|
|
78
|
+
): unknown;
|
|
79
|
+
export function encodePluginManifestPman(manifest: unknown): Uint8Array;
|
|
80
|
+
export function decodeStreamInvokeRequest(
|
|
81
|
+
data: Uint8Array | ArrayBuffer | ArrayBufferView,
|
|
82
|
+
): unknown;
|
|
83
|
+
export function encodeStreamInvokeRequest(request: unknown): Uint8Array;
|
|
84
|
+
export function decodeStreamInvokeResponse(
|
|
85
|
+
data: Uint8Array | ArrayBuffer | ArrayBufferView,
|
|
86
|
+
): unknown;
|
|
87
|
+
export function encodeStreamInvokeResponse(response: unknown): Uint8Array;
|
|
88
|
+
|
|
89
|
+
export function createDependencyStreamBridge(options?: {
|
|
90
|
+
drainPolicy?: string | number;
|
|
91
|
+
releaseOutputs?: boolean;
|
|
92
|
+
}): (request?: Record<string, unknown>) => Record<string, unknown>;
|
|
93
|
+
|
|
94
|
+
export const FLATSQL_LINK_SHIM_WASM: Uint8Array;
|
|
95
|
+
export const FLATSQL_ENGINE_IMPORT_MODULE: string;
|
|
96
|
+
export const FLATSQL_LINK_IMPORT_MODULE: string;
|
|
97
|
+
export const ENGINE_BODY_REF_TOKEN_MAGIC: bigint;
|
|
98
|
+
export const ENGINE_REF_ENTRY_SIZE: number;
|
|
99
|
+
export function buildFlatsqlLinkShimWasm(): Uint8Array;
|
|
100
|
+
export function instantiateFlatsqlLinkShim(
|
|
101
|
+
engineExports: WebAssembly.Exports & { memory: WebAssembly.Memory },
|
|
102
|
+
): Promise<WebAssembly.Instance>;
|
|
103
|
+
export function isEngineBodyRefToken(
|
|
104
|
+
token: bigint | number | string,
|
|
105
|
+
): boolean;
|
|
106
|
+
export function readEngineRefEntry(
|
|
107
|
+
view: DataView,
|
|
108
|
+
base: number,
|
|
109
|
+
): {
|
|
110
|
+
token: bigint;
|
|
111
|
+
generation: bigint;
|
|
112
|
+
fnv1a64: bigint;
|
|
113
|
+
enginePtr: number;
|
|
114
|
+
size: number;
|
|
115
|
+
frames: number;
|
|
116
|
+
used: number;
|
|
117
|
+
};
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// Flow-tier barrel: the compiled-artifact wasm host (Go-parity ABI), the
|
|
2
|
+
// pure-JS FlowProgram interpreter, the flow/StreamInvoke/PMAN codecs, and the
|
|
3
|
+
// dependency stream bridge. normalize.js and vendor/ are internal.
|
|
4
|
+
export { FLOW_INVALID_INDEX, createFlowRuntimeHost } from "./flowRuntimeHost.js";
|
|
5
|
+
export { createIsomorphicFlowRuntimeHost } from "./isomorphicFlowHost.js";
|
|
6
|
+
export { FlowRuntime } from "./jsFlowRuntime.js";
|
|
7
|
+
export {
|
|
8
|
+
decodeFlowProgram,
|
|
9
|
+
encodeFlowProgram,
|
|
10
|
+
decodePluginManifestPman,
|
|
11
|
+
encodePluginManifestPman,
|
|
12
|
+
decodeStreamInvokeRequest,
|
|
13
|
+
encodeStreamInvokeRequest,
|
|
14
|
+
decodeStreamInvokeResponse,
|
|
15
|
+
encodeStreamInvokeResponse,
|
|
16
|
+
} from "./flowCodec.js";
|
|
17
|
+
export { createDependencyStreamBridge } from "./dependencyStreamBridge.js";
|
|
18
|
+
export {
|
|
19
|
+
FLATSQL_LINK_SHIM_WASM,
|
|
20
|
+
FLATSQL_ENGINE_IMPORT_MODULE,
|
|
21
|
+
FLATSQL_LINK_IMPORT_MODULE,
|
|
22
|
+
ENGINE_BODY_REF_TOKEN_MAGIC,
|
|
23
|
+
ENGINE_REF_ENTRY_SIZE,
|
|
24
|
+
buildFlatsqlLinkShimWasm,
|
|
25
|
+
instantiateFlatsqlLinkShim,
|
|
26
|
+
isEngineBodyRefToken,
|
|
27
|
+
readEngineRefEntry,
|
|
28
|
+
} from "./flatsqlLinkShim.js";
|
|
29
|
+
// The flow compiler (flow check/compile) is node-only (emception + fs) and
|
|
30
|
+
// ships on the dedicated "./flow/compiler" subpath to keep this barrel
|
|
31
|
+
// browser-safe.
|
|
@@ -0,0 +1,384 @@
|
|
|
1
|
+
import { SDS_MANIFEST_SECTION_NAME } from "../bundle/constants.js";
|
|
2
|
+
import {
|
|
3
|
+
resolveModuleSignaturePolicy,
|
|
4
|
+
verifyModuleArtifact,
|
|
5
|
+
} from "../bundle/signing.js";
|
|
6
|
+
import { getWasmCustomSections } from "../bundle/wasm.js";
|
|
7
|
+
import { decodePlgManifest } from "../manifest/plgCodec.js";
|
|
8
|
+
import { createBrowserModuleHarness } from "../testing/browserModuleHarness.js";
|
|
9
|
+
import { extractPublicationRecordCollection } from "../transport/records.js";
|
|
10
|
+
import { sha256Bytes } from "../utils/crypto.js";
|
|
11
|
+
import { bytesToHex } from "../utils/encoding.js";
|
|
12
|
+
import { createFlowRuntimeHost } from "./flowRuntimeHost.js";
|
|
13
|
+
|
|
14
|
+
function exactArtifactBytes(source) {
|
|
15
|
+
if (source instanceof Uint8Array) return source;
|
|
16
|
+
if (source instanceof ArrayBuffer) return new Uint8Array(source);
|
|
17
|
+
if (ArrayBuffer.isView(source)) {
|
|
18
|
+
return new Uint8Array(source.buffer, source.byteOffset, source.byteLength);
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(source)) return new Uint8Array(source);
|
|
21
|
+
throw new TypeError(
|
|
22
|
+
"Isomorphic artifacts and PLG byte vectors must be exact Uint8Array-compatible bytes.",
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function normalizePluginId(value) {
|
|
27
|
+
const pluginId = String(value ?? "").trim();
|
|
28
|
+
if (!pluginId) throw new TypeError("Isomorphic child pluginId is required.");
|
|
29
|
+
return pluginId;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function normalizeNodeId(value) {
|
|
33
|
+
const nodeId = String(value ?? "").trim();
|
|
34
|
+
if (!nodeId) throw new TypeError("Isomorphic flow nodeId is required.");
|
|
35
|
+
return nodeId;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function decodeCanonicalPlg(bytes, description) {
|
|
39
|
+
try {
|
|
40
|
+
return decodePlgManifest(bytes);
|
|
41
|
+
} catch (error) {
|
|
42
|
+
throw new Error(
|
|
43
|
+
`${description} is not a decodable canonical PLG manifest: ${error?.message ?? error}`,
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function embeddedFlowManifest(artifactBytes) {
|
|
49
|
+
const publication = extractPublicationRecordCollection(artifactBytes);
|
|
50
|
+
for (const entry of publication?.mbl?.entries ?? []) {
|
|
51
|
+
if (
|
|
52
|
+
entry?.entryId === "manifest" ||
|
|
53
|
+
entry?.sectionName === SDS_MANIFEST_SECTION_NAME
|
|
54
|
+
) {
|
|
55
|
+
return decodeCanonicalPlg(
|
|
56
|
+
exactArtifactBytes(entry.payload),
|
|
57
|
+
"Signed flow bundle manifest",
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const portableBytes = publication?.payloadBytes ?? artifactBytes;
|
|
63
|
+
const sections = getWasmCustomSections(
|
|
64
|
+
portableBytes,
|
|
65
|
+
SDS_MANIFEST_SECTION_NAME,
|
|
66
|
+
);
|
|
67
|
+
if (sections.length === 0) {
|
|
68
|
+
throw new Error(
|
|
69
|
+
`Isomorphic flow artifact embeds no ${SDS_MANIFEST_SECTION_NAME} PLG manifest.`,
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return decodeCanonicalPlg(sections[0], "Embedded flow manifest");
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function flowManifestNodes(manifest) {
|
|
76
|
+
const nodes = new Map();
|
|
77
|
+
for (const node of manifest?.flowNodes ?? []) {
|
|
78
|
+
const nodeId = normalizeNodeId(node?.nodeId);
|
|
79
|
+
if (nodes.has(nodeId)) {
|
|
80
|
+
throw new Error(`Flow PLG declares duplicate node "${nodeId}".`);
|
|
81
|
+
}
|
|
82
|
+
nodes.set(nodeId, {
|
|
83
|
+
nodeId,
|
|
84
|
+
pluginId: normalizePluginId(node?.pluginId),
|
|
85
|
+
config:
|
|
86
|
+
node?.config === undefined || node?.config === null
|
|
87
|
+
? new Uint8Array(0)
|
|
88
|
+
: exactArtifactBytes(node.config).slice(),
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
return nodes;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function canonicalConfigInput(manifest, methodId, nodeId) {
|
|
95
|
+
const method = (manifest?.methods ?? []).find(
|
|
96
|
+
(candidate) => candidate?.methodId === methodId,
|
|
97
|
+
);
|
|
98
|
+
const port = (method?.inputPorts ?? []).find(
|
|
99
|
+
(candidate) => candidate?.portId === "config",
|
|
100
|
+
);
|
|
101
|
+
if (!port) {
|
|
102
|
+
throw new Error(
|
|
103
|
+
`Isomorphic node "${nodeId}" has signed CONFIG bytes, but child method "${methodId}" declares no generic config input port.`,
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
const canonicalType = (port.acceptedTypeSets ?? [])
|
|
107
|
+
.flatMap((typeSet) => typeSet?.allowedTypes ?? [])
|
|
108
|
+
.find((typeRef) => {
|
|
109
|
+
const wireFormat = String(typeRef?.wireFormat ?? "flatbuffer")
|
|
110
|
+
.trim()
|
|
111
|
+
.toLowerCase()
|
|
112
|
+
.replace(/_/g, "-");
|
|
113
|
+
return wireFormat === "flatbuffer";
|
|
114
|
+
});
|
|
115
|
+
if (!canonicalType) {
|
|
116
|
+
throw new Error(
|
|
117
|
+
`Isomorphic node "${nodeId}" config input has no canonical FlatBuffer representation.`,
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
return {
|
|
121
|
+
portId: port.portId,
|
|
122
|
+
typeRef: { ...canonicalType, wireFormat: "flatbuffer" },
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
function childEmbeddedManifest(harness, nodeId) {
|
|
127
|
+
const manifestBytes = harness.readManifest();
|
|
128
|
+
if (manifestBytes) {
|
|
129
|
+
return decodeCanonicalPlg(
|
|
130
|
+
manifestBytes,
|
|
131
|
+
`Isomorphic node "${nodeId}" child manifest`,
|
|
132
|
+
);
|
|
133
|
+
}
|
|
134
|
+
throw new Error(
|
|
135
|
+
`Isomorphic node "${nodeId}" has signed CONFIG bytes, but its child artifact exposes no PLG manifest.`,
|
|
136
|
+
);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function configRequestFrame(configInput, config) {
|
|
140
|
+
return {
|
|
141
|
+
portId: configInput.portId,
|
|
142
|
+
typeRef: configInput.typeRef,
|
|
143
|
+
wireFormat: "flatbuffer",
|
|
144
|
+
payload: config.slice(),
|
|
145
|
+
ownership: "host-owned",
|
|
146
|
+
mutability: "immutable",
|
|
147
|
+
};
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function frameU32(value, label) {
|
|
151
|
+
const numeric = Number(value ?? 0);
|
|
152
|
+
if (!Number.isSafeInteger(numeric) || numeric < 0 || numeric > 0xffffffff) {
|
|
153
|
+
throw new RangeError(`${label} must fit an unsigned 32-bit integer.`);
|
|
154
|
+
}
|
|
155
|
+
return numeric;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function childRequestFrame(frame) {
|
|
159
|
+
if (frame?.wireFormat === "aligned-binary") {
|
|
160
|
+
throw new Error(
|
|
161
|
+
"Separate isomorphic child instances require canonical FlatBuffer fallback; aligned frames need a proven shared arena.",
|
|
162
|
+
);
|
|
163
|
+
}
|
|
164
|
+
return {
|
|
165
|
+
portId: frame.portId,
|
|
166
|
+
typeRef: frame.typeRef,
|
|
167
|
+
payload: frame.bytes,
|
|
168
|
+
streamId: frameU32(frame.streamId, "Input streamId"),
|
|
169
|
+
sequence: frameU32(frame.sequence, "Input sequence"),
|
|
170
|
+
endOfStream: frame.endOfStream,
|
|
171
|
+
frameId: frame.frameId,
|
|
172
|
+
ownership: "host-owned",
|
|
173
|
+
mutability: "immutable",
|
|
174
|
+
};
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function flowOutputFrame(frame) {
|
|
178
|
+
const wireFormat = frame?.typeRef?.wireFormat ?? frame?.wireFormat ?? "flatbuffer";
|
|
179
|
+
if (wireFormat === "aligned-binary") {
|
|
180
|
+
throw new Error(
|
|
181
|
+
"Separate isomorphic child instances must emit canonical FlatBuffer fallback unless a shared arena is proven.",
|
|
182
|
+
);
|
|
183
|
+
}
|
|
184
|
+
return {
|
|
185
|
+
portId: frame.portId,
|
|
186
|
+
typeRef: frame.typeRef,
|
|
187
|
+
bytes: frame.payload,
|
|
188
|
+
wireFormat,
|
|
189
|
+
streamId: frameU32(frame.streamId, "Output streamId"),
|
|
190
|
+
sequence: frameU32(frame.sequence, "Output sequence"),
|
|
191
|
+
endOfStream: frame.endOfStream,
|
|
192
|
+
frameId: frame.frameId,
|
|
193
|
+
ownership: "host-owned",
|
|
194
|
+
mutability: "immutable",
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/**
|
|
199
|
+
* Instantiate one compiled flow runtime plus one exact hash-bound signed child
|
|
200
|
+
* instance per isomorphic graph node. Artifact verification remains keyed by
|
|
201
|
+
* plugin dependency while instance state, signed opaque CONFIG, and dispatch
|
|
202
|
+
* remain keyed by nodeId. The adapter converts generic PIV/TAB frame envelopes
|
|
203
|
+
* without inspecting application schemas.
|
|
204
|
+
*/
|
|
205
|
+
export async function createIsomorphicFlowRuntimeHost(options = {}) {
|
|
206
|
+
if (options.wasmModule !== undefined && options.wasmModule !== null) {
|
|
207
|
+
throw new TypeError(
|
|
208
|
+
"Isomorphic flow hosting rejects a precompiled WebAssembly.Module because it cannot prove that module matches the signed parent PLG artifact bytes.",
|
|
209
|
+
);
|
|
210
|
+
}
|
|
211
|
+
const parentArtifactBytes = exactArtifactBytes(
|
|
212
|
+
options.wasmSource ?? options.wasmBytes,
|
|
213
|
+
);
|
|
214
|
+
const parentSignaturePolicy = resolveModuleSignaturePolicy(options);
|
|
215
|
+
if (parentSignaturePolicy) {
|
|
216
|
+
await verifyModuleArtifact(parentArtifactBytes, parentSignaturePolicy);
|
|
217
|
+
}
|
|
218
|
+
const manifestNodes = flowManifestNodes(
|
|
219
|
+
embeddedFlowManifest(parentArtifactBytes),
|
|
220
|
+
);
|
|
221
|
+
const parent = await createFlowRuntimeHost({
|
|
222
|
+
wasmSource: parentArtifactBytes,
|
|
223
|
+
args: options.args,
|
|
224
|
+
env: options.env,
|
|
225
|
+
logOutput: options.logOutput,
|
|
226
|
+
extraImports: options.extraImports,
|
|
227
|
+
legacyHostImportCompat: options.legacyHostImportCompat,
|
|
228
|
+
engineLink: options.engineLink,
|
|
229
|
+
});
|
|
230
|
+
const declared = new Map();
|
|
231
|
+
for (let index = 0; index < parent.dependencyCount; index += 1) {
|
|
232
|
+
const descriptor = parent.getDependencyDescriptor(index);
|
|
233
|
+
if (declared.has(descriptor.pluginId)) {
|
|
234
|
+
throw new Error(`Flow declares duplicate dependency "${descriptor.pluginId}".`);
|
|
235
|
+
}
|
|
236
|
+
declared.set(descriptor.pluginId, descriptor);
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
const childArtifacts = new Map();
|
|
240
|
+
for (const child of options.children ?? []) {
|
|
241
|
+
const pluginId = normalizePluginId(child?.pluginId);
|
|
242
|
+
if (childArtifacts.has(pluginId)) {
|
|
243
|
+
throw new Error(`Isomorphic child "${pluginId}" is supplied more than once.`);
|
|
244
|
+
}
|
|
245
|
+
const descriptor = declared.get(pluginId);
|
|
246
|
+
if (!descriptor || !descriptor.sha256) {
|
|
247
|
+
throw new Error(
|
|
248
|
+
`Isomorphic child "${pluginId}" is not bound by a parent dependency SHA-256 descriptor.`,
|
|
249
|
+
);
|
|
250
|
+
}
|
|
251
|
+
const artifactBytes = exactArtifactBytes(child.wasmSource);
|
|
252
|
+
const sha256 = bytesToHex(await sha256Bytes(artifactBytes));
|
|
253
|
+
if (sha256 !== descriptor.sha256) {
|
|
254
|
+
throw new Error(
|
|
255
|
+
`Isomorphic child "${pluginId}" hash mismatch: expected ${descriptor.sha256}, received ${sha256}.`,
|
|
256
|
+
);
|
|
257
|
+
}
|
|
258
|
+
childArtifacts.set(pluginId, {
|
|
259
|
+
child,
|
|
260
|
+
pluginId,
|
|
261
|
+
sha256,
|
|
262
|
+
descriptor,
|
|
263
|
+
artifactBytes,
|
|
264
|
+
});
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
const childRecords = new Map();
|
|
268
|
+
const handlers = {};
|
|
269
|
+
const reservedHandlerKeys = new Set();
|
|
270
|
+
try {
|
|
271
|
+
for (let index = 0; index < parent.nodeCount; index += 1) {
|
|
272
|
+
const node = parent.getNodeDispatchDescriptor(index);
|
|
273
|
+
if (node.dispatchModel !== "isomorphic") continue;
|
|
274
|
+
const nodeId = normalizeNodeId(node.nodeId);
|
|
275
|
+
const artifact = childArtifacts.get(node.pluginId);
|
|
276
|
+
if (!artifact) {
|
|
277
|
+
throw new Error(
|
|
278
|
+
`Flow is missing exact isomorphic child artifact "${node.pluginId}" for node "${node.nodeId}".`,
|
|
279
|
+
);
|
|
280
|
+
}
|
|
281
|
+
if (childRecords.has(nodeId)) {
|
|
282
|
+
throw new Error(`Flow declares duplicate isomorphic node "${nodeId}".`);
|
|
283
|
+
}
|
|
284
|
+
const signedNode = manifestNodes.get(nodeId);
|
|
285
|
+
if (!signedNode || signedNode.pluginId !== node.pluginId) {
|
|
286
|
+
throw new Error(
|
|
287
|
+
`Runtime node "${nodeId}" does not match the signed parent PLG node declaration.`,
|
|
288
|
+
);
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
const { child, artifactBytes, descriptor, pluginId, sha256 } = artifact;
|
|
292
|
+
const harness = await createBrowserModuleHarness({
|
|
293
|
+
wasmSource: artifactBytes,
|
|
294
|
+
manifest: child.manifest,
|
|
295
|
+
surface: child.surface ?? "direct",
|
|
296
|
+
verifySignature: child.verifySignature,
|
|
297
|
+
host: child.host,
|
|
298
|
+
hostcallDispatch: child.hostcallDispatch,
|
|
299
|
+
imports: child.imports,
|
|
300
|
+
});
|
|
301
|
+
const config = signedNode.config.slice();
|
|
302
|
+
let configInput = null;
|
|
303
|
+
try {
|
|
304
|
+
configInput =
|
|
305
|
+
config.length > 0
|
|
306
|
+
? canonicalConfigInput(
|
|
307
|
+
childEmbeddedManifest(harness, nodeId),
|
|
308
|
+
node.methodId,
|
|
309
|
+
nodeId,
|
|
310
|
+
)
|
|
311
|
+
: null;
|
|
312
|
+
} catch (error) {
|
|
313
|
+
harness.destroy();
|
|
314
|
+
throw error;
|
|
315
|
+
}
|
|
316
|
+
const record = {
|
|
317
|
+
nodeId,
|
|
318
|
+
pluginId,
|
|
319
|
+
sha256,
|
|
320
|
+
descriptor,
|
|
321
|
+
config: config.slice(),
|
|
322
|
+
configInputPortId: configInput?.portId ?? null,
|
|
323
|
+
harness,
|
|
324
|
+
};
|
|
325
|
+
childRecords.set(nodeId, record);
|
|
326
|
+
handlers[nodeId] = async ({ methodId, frames }) => {
|
|
327
|
+
if (
|
|
328
|
+
configInput &&
|
|
329
|
+
frames.some((frame) => frame?.portId === configInput.portId)
|
|
330
|
+
) {
|
|
331
|
+
throw new Error(
|
|
332
|
+
`Isomorphic node "${nodeId}" invocation cannot override its signed CONFIG input.`,
|
|
333
|
+
);
|
|
334
|
+
}
|
|
335
|
+
const inputs = frames.map(childRequestFrame);
|
|
336
|
+
if (configInput) {
|
|
337
|
+
inputs.unshift(configRequestFrame(configInput, config));
|
|
338
|
+
}
|
|
339
|
+
const response = await harness.invoke({ methodId, inputs });
|
|
340
|
+
return {
|
|
341
|
+
statusCode: response.statusCode,
|
|
342
|
+
yielded: response.yielded,
|
|
343
|
+
backlogRemaining: response.backlogRemaining,
|
|
344
|
+
outputs: response.outputs.map(flowOutputFrame),
|
|
345
|
+
errorCode: response.errorCode,
|
|
346
|
+
errorMessage: response.errorMessage,
|
|
347
|
+
};
|
|
348
|
+
};
|
|
349
|
+
reservedHandlerKeys.add(`${pluginId}:${node.methodId}`);
|
|
350
|
+
if (descriptor.dependencyId) {
|
|
351
|
+
reservedHandlerKeys.add(descriptor.dependencyId);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
} catch (error) {
|
|
355
|
+
for (const record of childRecords.values()) record.harness.destroy();
|
|
356
|
+
throw error;
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return {
|
|
360
|
+
...parent,
|
|
361
|
+
parent,
|
|
362
|
+
children: childRecords,
|
|
363
|
+
async drain(drainOptions = {}) {
|
|
364
|
+
const customHandlers = drainOptions.handlers ?? {};
|
|
365
|
+
for (const key of reservedHandlerKeys) {
|
|
366
|
+
if (Object.prototype.hasOwnProperty.call(customHandlers, key)) {
|
|
367
|
+
throw new Error(
|
|
368
|
+
`Custom handler "${key}" cannot override node-scoped isomorphic dispatch.`,
|
|
369
|
+
);
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
return parent.drain(
|
|
373
|
+
{ ...customHandlers, ...handlers },
|
|
374
|
+
{
|
|
375
|
+
...drainOptions,
|
|
376
|
+
handlers: undefined,
|
|
377
|
+
},
|
|
378
|
+
);
|
|
379
|
+
},
|
|
380
|
+
destroy() {
|
|
381
|
+
for (const record of childRecords.values()) record.harness.destroy();
|
|
382
|
+
},
|
|
383
|
+
};
|
|
384
|
+
}
|