space-data-module-sdk 0.8.27 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (121) hide show
  1. package/README.md +5 -4
  2. package/docs/assembly.js +0 -18
  3. package/docs/assets/ai-credits/ai-credits.js +116 -0
  4. package/docs/assets/sdn-chrome/sdn-chrome.css +434 -0
  5. package/docs/assets/sdn-chrome/sdn-chrome.js +236 -0
  6. package/docs/browser-wasmedge-isomorphic.html +29 -41
  7. package/docs/byo-wasm-quickstart.html +29 -41
  8. package/docs/conformance.html +29 -41
  9. package/docs/events-abi.html +29 -41
  10. package/docs/families/analytics.html +29 -41
  11. package/docs/families/attitude.html +29 -41
  12. package/docs/families/behavior.html +29 -41
  13. package/docs/families/breakup.html +29 -41
  14. package/docs/families/conjunction.html +29 -41
  15. package/docs/families/data-source.html +29 -41
  16. package/docs/families/effects.html +29 -41
  17. package/docs/families/environment.html +29 -41
  18. package/docs/families/estimation.html +29 -41
  19. package/docs/families/gnc.html +29 -41
  20. package/docs/families/maneuver.html +29 -41
  21. package/docs/families/obstruction.html +29 -41
  22. package/docs/families/propagator.html +29 -41
  23. package/docs/families/propulsion.html +29 -41
  24. package/docs/families/reentry.html +29 -41
  25. package/docs/families/rf.html +29 -41
  26. package/docs/families/scheduler.html +29 -41
  27. package/docs/families/sensor.html +29 -41
  28. package/docs/families/signature.html +29 -41
  29. package/docs/flatsql-host-contract.html +29 -41
  30. package/docs/flatsql-streaming-standard.html +29 -41
  31. package/docs/gpu-module-abi.html +29 -41
  32. package/docs/index.html +43 -47
  33. package/docs/isomorphic-pthreads.html +29 -41
  34. package/docs/isomorphic-sdn-runtime-plan.html +29 -41
  35. package/docs/language-runtime-matrix.html +29 -41
  36. package/docs/media/module-sdk-reel-poster.webp +0 -0
  37. package/docs/media/module-sdk-reel.mp4 +0 -0
  38. package/docs/media/module-sdk-reel.webm +0 -0
  39. package/docs/media/reel/reel.css +53 -0
  40. package/docs/media/reel/reel.js +272 -0
  41. package/docs/module-bundle-runtime-plan.html +29 -41
  42. package/docs/module-publication-standard.html +29 -41
  43. package/docs/node-red-default-node-parity.html +29 -41
  44. package/docs/protect-and-sign.html +29 -41
  45. package/docs/protocol-installation.html +29 -41
  46. package/docs/publication-submission.html +29 -41
  47. package/docs/secrets-capability.html +29 -41
  48. package/docs/styles.css +89 -157
  49. package/docs/testing-harness.html +29 -41
  50. package/docs/tri-runtime-parity-gate.html +29 -41
  51. package/docs/tri-runtime-parity.html +29 -41
  52. package/package.json +5 -3
  53. package/schemas/runtime/FlowNotice.fbs +39 -0
  54. package/schemas/runtime/HostOps.fbs +455 -0
  55. package/schemas/runtime/HttpRequest.fbs +25 -0
  56. package/schemas/runtime/HttpResponse.fbs +24 -0
  57. package/schemas/runtime/IngestRequest.fbs +61 -0
  58. package/schemas/runtime/IngestResult.fbs +23 -0
  59. package/schemas/runtime/ModuleConfig.fbs +41 -0
  60. package/schemas/runtime/RuntimeCommon.fbs +33 -0
  61. package/schemas/runtime/TimerTick.fbs +18 -0
  62. package/src/capabilities.js +3 -0
  63. package/src/compiler/compileModule.js +20 -2
  64. package/src/generated/runtime/aligned/HostOps_aligned.js +3913 -0
  65. package/src/generated/runtime/aligned/HostOps_aligned.ts +4605 -0
  66. package/src/generated/runtime/aligned/HostOps_enums.js +12 -0
  67. package/src/generated/runtime/aligned/HostOps_enums.ts +6 -0
  68. package/src/generated/runtime/cpp/FlowNotice_generated.h +367 -0
  69. package/src/generated/runtime/cpp/HostOps_aligned.h +3540 -0
  70. package/src/generated/runtime/cpp/HttpRequest_generated.h +317 -0
  71. package/src/generated/runtime/cpp/HttpResponse_generated.h +315 -0
  72. package/src/generated/runtime/cpp/IngestRequest_generated.h +829 -0
  73. package/src/generated/runtime/cpp/IngestResult_generated.h +319 -0
  74. package/src/generated/runtime/cpp/ModuleConfig_generated.h +604 -0
  75. package/src/generated/runtime/cpp/RuntimeCommon_generated.h +410 -0
  76. package/src/generated/runtime/cpp/TimerTick_generated.h +229 -0
  77. package/src/generated/runtime/sdn/runtime/ArchiveTarget.js +78 -0
  78. package/src/generated/runtime/sdn/runtime/ArchiveTarget.ts +104 -0
  79. package/src/generated/runtime/sdn/runtime/ConfigEntry.js +202 -0
  80. package/src/generated/runtime/sdn/runtime/ConfigEntry.ts +251 -0
  81. package/src/generated/runtime/sdn/runtime/ConfigTable.js +80 -0
  82. package/src/generated/runtime/sdn/runtime/ConfigTable.ts +97 -0
  83. package/src/generated/runtime/sdn/runtime/FlowNotice.js +196 -0
  84. package/src/generated/runtime/sdn/runtime/FlowNotice.ts +254 -0
  85. package/src/generated/runtime/sdn/runtime/Header.js +79 -0
  86. package/src/generated/runtime/sdn/runtime/Header.ts +100 -0
  87. package/src/generated/runtime/sdn/runtime/HttpRequest.js +216 -0
  88. package/src/generated/runtime/sdn/runtime/HttpRequest.ts +265 -0
  89. package/src/generated/runtime/sdn/runtime/HttpResponse.js +216 -0
  90. package/src/generated/runtime/sdn/runtime/HttpResponse.ts +267 -0
  91. package/src/generated/runtime/sdn/runtime/IngestRequest.js +121 -0
  92. package/src/generated/runtime/sdn/runtime/IngestRequest.ts +155 -0
  93. package/src/generated/runtime/sdn/runtime/IngestResult.js +184 -0
  94. package/src/generated/runtime/sdn/runtime/IngestResult.ts +235 -0
  95. package/src/generated/runtime/sdn/runtime/ModuleConfig.js +92 -0
  96. package/src/generated/runtime/sdn/runtime/ModuleConfig.ts +114 -0
  97. package/src/generated/runtime/sdn/runtime/Provenance.js +320 -0
  98. package/src/generated/runtime/sdn/runtime/Provenance.ts +405 -0
  99. package/src/generated/runtime/sdn/runtime/SourceTags.js +181 -0
  100. package/src/generated/runtime/sdn/runtime/SourceTags.ts +253 -0
  101. package/src/generated/runtime/sdn/runtime/TimerTick.js +119 -0
  102. package/src/generated/runtime/sdn/runtime/TimerTick.ts +148 -0
  103. package/src/generated/runtime/sdn/runtime/configValueKind.js +12 -0
  104. package/src/generated/runtime/sdn/runtime/configValueKind.ts +19 -0
  105. package/src/generated/runtime/sdn/runtime/flowNoticeKind.js +11 -0
  106. package/src/generated/runtime/sdn/runtime/flowNoticeKind.ts +34 -0
  107. package/src/generated/runtime/sdn/runtime/reconcileMode.js +9 -0
  108. package/src/generated/runtime/sdn/runtime/reconcileMode.ts +23 -0
  109. package/src/generated/runtime/sdn/runtime.js +16 -0
  110. package/src/generated/runtime/sdn/runtime.ts +17 -0
  111. package/src/host/abi.js +32 -6
  112. package/src/host/adapterOperations.js +79 -0
  113. package/src/host/browserHost.js +65 -2
  114. package/src/host/cpp/typedHostcall.hpp +252 -0
  115. package/src/host/hostWorkerBundleSources.js +3 -3
  116. package/src/host/nodeHost.js +50 -0
  117. package/src/host/typedDispatch.js +582 -0
  118. package/src/index.d.ts +25 -2
  119. package/src/invoke/codec.js +3 -2
  120. package/src/standards/runtimeContracts.js +596 -0
  121. package/src/standards/sharedCatalog.js +27 -0
@@ -40,6 +40,13 @@ import {
40
40
  nextCronOccurrence,
41
41
  parseCronExpression,
42
42
  } from "./cron.js";
43
+ import {
44
+ ADAPTER_CAPABILITIES,
45
+ ADAPTER_OPERATIONS,
46
+ callServiceAdapter,
47
+ normalizePluginConfig,
48
+ resolveServiceAdapters,
49
+ } from "./adapterOperations.js";
43
50
 
44
51
  const textEncoder = new TextEncoder();
45
52
  const textDecoder = new TextDecoder();
@@ -71,9 +78,12 @@ export const NodeHostSupportedCapabilities = Object.freeze([
71
78
  "crypto_kdf",
72
79
  "wallet_sign",
73
80
  "process_exec",
81
+ // served through the embedder's capability adapters (adapterOperations.js)
82
+ ...ADAPTER_CAPABILITIES,
74
83
  ]);
75
84
 
76
85
  export const NodeHostSupportedOperations = Object.freeze([
86
+ "plugin.getConfig",
77
87
  "clock.now",
78
88
  "clock.monotonicNow",
79
89
  "clock.nowIso",
@@ -132,6 +142,7 @@ export const NodeHostSupportedOperations = Object.freeze([
132
142
  "crypto.ed25519.publicKeyFromSeed",
133
143
  "crypto.ed25519.sign",
134
144
  "crypto.ed25519.verify",
145
+ ...Object.keys(ADAPTER_OPERATIONS),
135
146
  ]);
136
147
 
137
148
  function cloneValue(value) {
@@ -1544,6 +1555,8 @@ export class NodeHost {
1544
1555
  this._walletSignAdapter = capabilityAdapters.walletSign;
1545
1556
  this._protocolHandleAdapter = capabilityAdapters.protocolHandle;
1546
1557
  this._protocolDialAdapter = capabilityAdapters.protocolDial;
1558
+ this._serviceAdapters = resolveServiceAdapters(options);
1559
+ this._config = normalizePluginConfig(options.config);
1547
1560
  if (typeof this.fetch !== "function") {
1548
1561
  throw new TypeError(
1549
1562
  "A fetch implementation is required to create a Node host.",
@@ -1558,6 +1571,16 @@ export class NodeHost {
1558
1571
  ? createFileContextStore(options.contextFilePath)
1559
1572
  : createInMemoryContextStore();
1560
1573
 
1574
+ // The module's config (options.config), as the Go node's plugin.getConfig serves it: no capability needed.
1575
+ this.plugin = Object.freeze({
1576
+ getConfig: () => structuredClone(this._config),
1577
+ });
1578
+ // The node's identity, from the embedder's node adapter (values or functions): no capability needed.
1579
+ this.node = Object.freeze({
1580
+ peerId: () => this.serveAdapterOperation("node.peerId"),
1581
+ publicKey: () => this.serveAdapterOperation("node.publicKey"),
1582
+ });
1583
+
1561
1584
  this.clock = Object.freeze({
1562
1585
  now: () => this.#withCapability("clock", "clock.now", () => Date.now()),
1563
1586
  monotonicNow: () =>
@@ -1648,6 +1671,7 @@ export class NodeHost {
1648
1671
  method: requestOptions.method ?? "GET",
1649
1672
  headers: requestOptions.headers,
1650
1673
  body: normalizeRequestBody(requestOptions.body),
1674
+ redirect: requestOptions.redirect ?? "follow",
1651
1675
  signal: resolveSignals(requestOptions.signal, timeout.signal),
1652
1676
  });
1653
1677
  const responseType = normalizeResponseType(requestOptions.responseType);
@@ -2184,9 +2208,32 @@ export class NodeHost {
2184
2208
  return normalized;
2185
2209
  }
2186
2210
 
2211
+ /**
2212
+ * Serve one of the operations the embedder's capability adapters answer (ADAPTER_OPERATIONS: secrets, storage,
2213
+ * p2p, node): the capability check, then the adapter's method with the handler-shaped params. Synchronous when
2214
+ * the adapter answers synchronously.
2215
+ */
2216
+ serveAdapterOperation(operation, params = {}) {
2217
+ const served = ADAPTER_OPERATIONS[operation];
2218
+ if (!served) {
2219
+ throw new Error(`Unknown Node host operation "${operation}".`);
2220
+ }
2221
+ if (served.capability) {
2222
+ this.assertCapability(served.capability, operation);
2223
+ }
2224
+ return callServiceAdapter(
2225
+ this._serviceAdapters[served.adapter],
2226
+ served.adapter,
2227
+ served.method,
2228
+ params ?? {},
2229
+ );
2230
+ }
2231
+
2187
2232
  async invoke(operation, params = {}) {
2188
2233
  const normalized = assertNonEmptyString(operation, "Host operation");
2189
2234
  switch (normalized) {
2235
+ case "plugin.getConfig":
2236
+ return this.plugin.getConfig();
2190
2237
  case "host.runtimeTarget":
2191
2238
  return this.runtimeTarget;
2192
2239
  case "host.listCapabilities":
@@ -2342,6 +2389,9 @@ export class NodeHost {
2342
2389
  params.publicKey,
2343
2390
  );
2344
2391
  default:
2392
+ if (ADAPTER_OPERATIONS[normalized]) {
2393
+ return this.serveAdapterOperation(normalized, params);
2394
+ }
2345
2395
  throw new Error(`Unknown Node host operation "${normalized}".`);
2346
2396
  }
2347
2397
  }