@xyo-network/sdk 8.1.1 → 9.0.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.
Files changed (233) hide show
  1. package/dist/neutral/account-custody.mjs +15 -3
  2. package/dist/neutral/account-custody.mjs.map +2 -2
  3. package/dist/neutral/api-location-diviner.mjs.map +2 -2
  4. package/dist/neutral/archivist-abstract.mjs +61 -12
  5. package/dist/neutral/archivist-abstract.mjs.map +3 -3
  6. package/dist/neutral/archivist-generic.mjs.map +2 -2
  7. package/dist/neutral/archivist-memory.mjs.map +2 -2
  8. package/dist/neutral/archivist-model.mjs.map +2 -2
  9. package/dist/neutral/archivist-view.mjs +6 -1
  10. package/dist/neutral/archivist-view.mjs.map +2 -2
  11. package/dist/neutral/archivist-wrapper.mjs +2 -0
  12. package/dist/neutral/archivist-wrapper.mjs.map +2 -2
  13. package/dist/neutral/boundwitness-loader.mjs.map +2 -2
  14. package/dist/neutral/bridge-abstract.mjs +7 -1
  15. package/dist/neutral/bridge-abstract.mjs.map +2 -2
  16. package/dist/neutral/bridge-http.mjs +9 -1
  17. package/dist/neutral/bridge-http.mjs.map +2 -2
  18. package/dist/neutral/bridge-model.mjs.map +2 -2
  19. package/dist/neutral/bridge-wrapper.mjs.map +2 -2
  20. package/dist/neutral/diviner-abstract.mjs +9 -2
  21. package/dist/neutral/diviner-abstract.mjs.map +2 -2
  22. package/dist/neutral/diviner-boundwitness.abstract.mjs.map +2 -2
  23. package/dist/neutral/diviner-boundwitness.memory.mjs.map +2 -2
  24. package/dist/neutral/diviner-boundwitness.mjs.map +2 -2
  25. package/dist/neutral/diviner-boundwitness.model.mjs.map +2 -2
  26. package/dist/neutral/diviner-identity.mjs.map +2 -2
  27. package/dist/neutral/diviner-model.mjs.map +2 -2
  28. package/dist/neutral/diviner-payload-generic.mjs.map +2 -2
  29. package/dist/neutral/diviner-payload-model.mjs.map +2 -2
  30. package/dist/neutral/diviner-wrapper.mjs +2 -0
  31. package/dist/neutral/diviner-wrapper.mjs.map +2 -2
  32. package/dist/neutral/manifest-wrapper.mjs.map +2 -2
  33. package/dist/neutral/module-abstract.mjs +37 -7
  34. package/dist/neutral/module-abstract.mjs.map +2 -2
  35. package/dist/neutral/module-factory-locator.mjs.map +2 -2
  36. package/dist/neutral/module-model.mjs +1 -0
  37. package/dist/neutral/module-model.mjs.map +2 -2
  38. package/dist/neutral/module-resolver.mjs +17 -3
  39. package/dist/neutral/module-resolver.mjs.map +2 -2
  40. package/dist/neutral/module-wrapper.mjs +5 -1
  41. package/dist/neutral/module-wrapper.mjs.map +2 -2
  42. package/dist/neutral/modules/account-custody/AccountCustody.d.ts.map +1 -1
  43. package/dist/neutral/modules/account-custody/AccountCustodyClient.d.ts.map +1 -1
  44. package/dist/neutral/modules/account-custody/clientExecution.d.ts.map +1 -1
  45. package/dist/neutral/modules/account-custody/clientModel.d.ts.map +1 -1
  46. package/dist/neutral/modules/account-custody/clientOwner.d.ts.map +1 -1
  47. package/dist/neutral/modules/account-custody/clientSignals.d.ts.map +1 -1
  48. package/dist/neutral/modules/account-custody/model.d.ts.map +1 -1
  49. package/dist/neutral/modules/account-custody/realmRegistry.d.ts.map +1 -1
  50. package/dist/neutral/modules/api-location-diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.d.ts.map +1 -1
  51. package/dist/neutral/modules/api-location-diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.d.ts.map +1 -1
  52. package/dist/neutral/modules/api-location-diviner/LocationDiviner/Queries/LocationQueryCreationRequest.d.ts.map +1 -1
  53. package/dist/neutral/modules/api-location-diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.d.ts.map +1 -1
  54. package/dist/neutral/modules/api-location-diviner/LocationDiviner/Witnesses/CurrentLocationWitness.d.ts.map +1 -1
  55. package/dist/neutral/modules/api-location-diviner/LocationDiviner/Witnesses/LocationWitness.d.ts.map +1 -1
  56. package/dist/neutral/modules/api-location-diviner/RemoteDivinerConfig.d.ts.map +1 -1
  57. package/dist/neutral/modules/archivist-abstract/AbstractArchivist.d.ts +1 -0
  58. package/dist/neutral/modules/archivist-abstract/AbstractArchivist.d.ts.map +1 -1
  59. package/dist/neutral/modules/archivist-abstract/InsertSequencer.d.ts +25 -0
  60. package/dist/neutral/modules/archivist-abstract/InsertSequencer.d.ts.map +1 -0
  61. package/dist/neutral/modules/archivist-generic/Archivist.d.ts.map +1 -1
  62. package/dist/neutral/modules/archivist-generic/Config.d.ts.map +1 -1
  63. package/dist/neutral/modules/archivist-memory/Archivist.d.ts.map +1 -1
  64. package/dist/neutral/modules/archivist-memory/Config.d.ts.map +1 -1
  65. package/dist/neutral/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
  66. package/dist/neutral/modules/archivist-model/ArchivistSnapshot.d.ts.map +1 -1
  67. package/dist/neutral/modules/archivist-model/ArchivistStats.d.ts.map +1 -1
  68. package/dist/neutral/modules/archivist-model/Config.d.ts.map +1 -1
  69. package/dist/neutral/modules/archivist-model/EventData.d.ts.map +1 -1
  70. package/dist/neutral/modules/archivist-model/EventModels/Deleted.d.ts.map +1 -1
  71. package/dist/neutral/modules/archivist-model/EventModels/Inserted.d.ts.map +1 -1
  72. package/dist/neutral/modules/archivist-model/Instance.d.ts.map +1 -1
  73. package/dist/neutral/modules/archivist-model/ModuleInstance.d.ts.map +1 -1
  74. package/dist/neutral/modules/archivist-model/PayloadArchivist.d.ts.map +1 -1
  75. package/dist/neutral/modules/archivist-model/Queries/All.d.ts.map +1 -1
  76. package/dist/neutral/modules/archivist-model/Queries/Clear.d.ts.map +1 -1
  77. package/dist/neutral/modules/archivist-model/Queries/Commit.d.ts.map +1 -1
  78. package/dist/neutral/modules/archivist-model/Queries/Delete.d.ts.map +1 -1
  79. package/dist/neutral/modules/archivist-model/Queries/Get.d.ts.map +1 -1
  80. package/dist/neutral/modules/archivist-model/Queries/Insert.d.ts.map +1 -1
  81. package/dist/neutral/modules/archivist-model/Queries/Next.d.ts.map +1 -1
  82. package/dist/neutral/modules/archivist-model/Queries/Snapshot.d.ts.map +1 -1
  83. package/dist/neutral/modules/archivist-model/Queries/index.d.ts.map +1 -1
  84. package/dist/neutral/modules/archivist-model/RawQueryFunctions.d.ts.map +1 -1
  85. package/dist/neutral/modules/archivist-model/lib/HydratedBoundWitness.d.ts.map +1 -1
  86. package/dist/neutral/modules/archivist-model/lib/getBoundWitness.d.ts.map +1 -1
  87. package/dist/neutral/modules/archivist-model/lib/hydrateBoundWitness.d.ts.map +1 -1
  88. package/dist/neutral/modules/archivist-model/typeChecks.d.ts.map +1 -1
  89. package/dist/neutral/modules/archivist-view/ViewArchivist.d.ts.map +1 -1
  90. package/dist/neutral/modules/archivist-wrapper/ArchivistWrapper.d.ts.map +1 -1
  91. package/dist/neutral/modules/boundwitness-loader/Loader.d.ts.map +1 -1
  92. package/dist/neutral/modules/bridge-abstract/AbstractBridge.d.ts.map +1 -1
  93. package/dist/neutral/modules/bridge-abstract/AbstractBridgeModuleResolver.d.ts.map +1 -1
  94. package/dist/neutral/modules/bridge-abstract/AbstractModuleProxy/AbstractModuleProxy.d.ts.map +1 -1
  95. package/dist/neutral/modules/bridge-abstract/AbstractModuleProxy/ModuleProxyResolver.d.ts.map +1 -1
  96. package/dist/neutral/modules/bridge-http/HttpBridge.d.ts.map +1 -1
  97. package/dist/neutral/modules/bridge-http/HttpBridgeConfig.d.ts.map +1 -1
  98. package/dist/neutral/modules/bridge-http/HttpBridgeModuleResolver.d.ts.map +1 -1
  99. package/dist/neutral/modules/bridge-http/ModuleProxy/ModuleProxy.d.ts.map +1 -1
  100. package/dist/neutral/modules/bridge-model/Config.d.ts.map +1 -1
  101. package/dist/neutral/modules/bridge-model/Events/Exposed.d.ts.map +1 -1
  102. package/dist/neutral/modules/bridge-model/Events/QueryFulfillFinished.d.ts.map +1 -1
  103. package/dist/neutral/modules/bridge-model/Events/QuerySendFinished.d.ts.map +1 -1
  104. package/dist/neutral/modules/bridge-model/Events/Unexposed.d.ts.map +1 -1
  105. package/dist/neutral/modules/bridge-model/Params.d.ts.map +1 -1
  106. package/dist/neutral/modules/bridge-model/Queries/Connect.d.ts.map +1 -1
  107. package/dist/neutral/modules/bridge-model/Queries/Disconnect.d.ts.map +1 -1
  108. package/dist/neutral/modules/bridge-model/Queries/Expose.d.ts.map +1 -1
  109. package/dist/neutral/modules/bridge-model/Queries/Unexpose.d.ts.map +1 -1
  110. package/dist/neutral/modules/bridge-model/typeChecks.d.ts.map +1 -1
  111. package/dist/neutral/modules/bridge-wrapper/BridgeWrapper.d.ts.map +1 -1
  112. package/dist/neutral/modules/diviner-abstract/AbstractDiviner.d.ts.map +1 -1
  113. package/dist/neutral/modules/diviner-boundwitness/Config.d.ts.map +1 -1
  114. package/dist/neutral/modules/diviner-boundwitness/Query.d.ts.map +1 -1
  115. package/dist/neutral/modules/diviner-boundwitness/applyBoundWitnessDivinerQueryPayload.d.ts.map +1 -1
  116. package/dist/neutral/modules/diviner-identity/IdentityDiviner.d.ts.map +1 -1
  117. package/dist/neutral/modules/diviner-model/Config.d.ts.map +1 -1
  118. package/dist/neutral/modules/diviner-model/DivinerQueryFunctions.d.ts.map +1 -1
  119. package/dist/neutral/modules/diviner-model/EventsModels/DivineEnd.d.ts.map +1 -1
  120. package/dist/neutral/modules/diviner-model/Payload.d.ts.map +1 -1
  121. package/dist/neutral/modules/diviner-model/Queries/Divine.d.ts.map +1 -1
  122. package/dist/neutral/modules/diviner-model/typeChecks.d.ts.map +1 -1
  123. package/dist/neutral/modules/diviner-payload-generic/Diviner.d.ts.map +1 -1
  124. package/dist/neutral/modules/diviner-payload-model/Config.d.ts.map +1 -1
  125. package/dist/neutral/modules/diviner-payload-model/Query.d.ts.map +1 -1
  126. package/dist/neutral/modules/diviner-wrapper/DivinerWrapper.d.ts.map +1 -1
  127. package/dist/neutral/modules/manifest-wrapper/Wrapper.d.ts.map +1 -1
  128. package/dist/neutral/modules/manifest-wrapper/WrapperEx.d.ts.map +1 -1
  129. package/dist/neutral/modules/module-abstract/AbstractModule.d.ts +10 -2
  130. package/dist/neutral/modules/module-abstract/AbstractModule.d.ts.map +1 -1
  131. package/dist/neutral/modules/module-abstract/AbstractModuleInstance.d.ts.map +1 -1
  132. package/dist/neutral/modules/module-abstract/Error.d.ts.map +1 -1
  133. package/dist/neutral/modules/module-abstract/LoggerModuleStatusReporter.d.ts.map +1 -1
  134. package/dist/neutral/modules/module-abstract/QueryValidator/ModuleConfigQueryValidator.d.ts.map +1 -1
  135. package/dist/neutral/modules/module-abstract/determineAccount.d.ts.map +1 -1
  136. package/dist/neutral/modules/module-factory-locator/standardCreatableFactories.d.ts.map +1 -1
  137. package/dist/neutral/modules/module-model/Config/Config.d.ts.map +1 -1
  138. package/dist/neutral/modules/module-model/CreatableModule/CreatableModule.d.ts.map +1 -1
  139. package/dist/neutral/modules/module-model/CreatableModule/ModuleFactory.d.ts.map +1 -1
  140. package/dist/neutral/modules/module-model/Labels/Labels.d.ts.map +1 -1
  141. package/dist/neutral/modules/module-model/ModuleFactoryLocatorInstance.d.ts.map +1 -1
  142. package/dist/neutral/modules/module-model/ModuleIdentifier.d.ts.map +1 -1
  143. package/dist/neutral/modules/module-model/ModuleQueryResult.d.ts.map +1 -1
  144. package/dist/neutral/modules/module-model/Payload/Address.d.ts.map +1 -1
  145. package/dist/neutral/modules/module-model/Payload/AddressPreviousHash.d.ts.map +1 -1
  146. package/dist/neutral/modules/module-model/Payload/Description.d.ts.map +1 -1
  147. package/dist/neutral/modules/module-model/Payload/ModuleState.d.ts.map +1 -1
  148. package/dist/neutral/modules/module-model/Queries/Manifest.d.ts.map +1 -1
  149. package/dist/neutral/modules/module-model/Queries/ModuleAddress/Query.d.ts.map +1 -1
  150. package/dist/neutral/modules/module-model/Queries/State.d.ts.map +1 -1
  151. package/dist/neutral/modules/module-model/Queries/Subscribe.d.ts.map +1 -1
  152. package/dist/neutral/modules/module-model/QueryableModule/IsQueryableModuleFactory.d.ts.map +1 -1
  153. package/dist/neutral/modules/module-model/QueryableModule/QueryableModule.d.ts.map +1 -1
  154. package/dist/neutral/modules/module-model/QueryableModule/QueryableModuleFields.d.ts.map +1 -1
  155. package/dist/neutral/modules/module-model/QueryableModule/QueryableModuleFunctions.d.ts.map +1 -1
  156. package/dist/neutral/modules/module-model/instance/Instance.d.ts.map +1 -1
  157. package/dist/neutral/modules/module-model/instance/ObjectFilter.d.ts.map +1 -1
  158. package/dist/neutral/modules/module-model/instance/ObjectResolver.d.ts.map +1 -1
  159. package/dist/neutral/modules/module-resolver/AbstractModuleResolver.d.ts.map +1 -1
  160. package/dist/neutral/modules/module-resolver/CompositeModuleResolver.d.ts.map +1 -1
  161. package/dist/neutral/modules/module-resolver/NameRegistrarTransformer.d.ts.map +1 -1
  162. package/dist/neutral/modules/module-resolver/ResolveHelper/ResolveHelper.d.ts.map +1 -1
  163. package/dist/neutral/modules/module-resolver/ResolveHelper/resolveAll.d.ts.map +1 -1
  164. package/dist/neutral/modules/module-resolver/ResolverEventEmitter.d.ts.map +1 -1
  165. package/dist/neutral/modules/module-resolver/SimpleModuleResolver.d.ts.map +1 -1
  166. package/dist/neutral/modules/module-wrapper/ModuleWrapper.d.ts +10 -2
  167. package/dist/neutral/modules/module-wrapper/ModuleWrapper.d.ts.map +1 -1
  168. package/dist/neutral/modules/node-abstract/AbstractNode.d.ts.map +1 -1
  169. package/dist/neutral/modules/node-memory/MemoryNode.d.ts.map +1 -1
  170. package/dist/neutral/modules/node-memory/NodeHelper/index.d.ts.map +1 -1
  171. package/dist/neutral/modules/node-model/ChildCertification.d.ts.map +1 -1
  172. package/dist/neutral/modules/node-model/Config.d.ts.map +1 -1
  173. package/dist/neutral/modules/node-model/Node.d.ts.map +1 -1
  174. package/dist/neutral/modules/node-model/Params.d.ts.map +1 -1
  175. package/dist/neutral/modules/node-model/Queries/Attach.d.ts.map +1 -1
  176. package/dist/neutral/modules/node-model/Queries/Attached.d.ts.map +1 -1
  177. package/dist/neutral/modules/node-model/Queries/Certify.d.ts.map +1 -1
  178. package/dist/neutral/modules/node-model/Queries/Detach.d.ts.map +1 -1
  179. package/dist/neutral/modules/node-model/Queries/Registered.d.ts.map +1 -1
  180. package/dist/neutral/modules/node-model/instance.d.ts.map +1 -1
  181. package/dist/neutral/modules/node-model/typeChecks.d.ts.map +1 -1
  182. package/dist/neutral/modules/node-view/ViewNode.d.ts.map +1 -1
  183. package/dist/neutral/modules/node-wrapper/NodeWrapper.d.ts.map +1 -1
  184. package/dist/neutral/modules/payloadset-plugin/Plugin.d.ts.map +1 -1
  185. package/dist/neutral/modules/payloadset-plugin/createPlugin.d.ts.map +1 -1
  186. package/dist/neutral/modules/sentinel-abstract/AbstractSentinel.d.ts.map +1 -1
  187. package/dist/neutral/modules/sentinel-memory/MemorySentinel.d.ts.map +1 -1
  188. package/dist/neutral/modules/sentinel-memory/SentinelRunner.d.ts.map +1 -1
  189. package/dist/neutral/modules/sentinel-model/Automation.d.ts +7 -1
  190. package/dist/neutral/modules/sentinel-model/Automation.d.ts.map +1 -1
  191. package/dist/neutral/modules/sentinel-model/Config.d.ts.map +1 -1
  192. package/dist/neutral/modules/sentinel-model/Queries/Report.d.ts.map +1 -1
  193. package/dist/neutral/modules/sentinel-model/ResolvedTask.d.ts.map +1 -1
  194. package/dist/neutral/modules/sentinel-model/Sentinel.d.ts.map +1 -1
  195. package/dist/neutral/modules/sentinel-model/typeChecks.d.ts.map +1 -1
  196. package/dist/neutral/modules/sentinel-wrapper/Wrapper.d.ts.map +1 -1
  197. package/dist/neutral/modules/witness-abstract/AbstractWitness.d.ts.map +1 -1
  198. package/dist/neutral/modules/witness-adhoc/Witness.d.ts.map +1 -1
  199. package/dist/neutral/modules/witness-model/Config.d.ts.map +1 -1
  200. package/dist/neutral/modules/witness-model/Queries/Observe.d.ts.map +1 -1
  201. package/dist/neutral/modules/witness-model/QueryFunctions.d.ts.map +1 -1
  202. package/dist/neutral/modules/witness-model/typeChecks.d.ts.map +1 -1
  203. package/dist/neutral/modules/witness-wrapper/WitnessWrapper.d.ts.map +1 -1
  204. package/dist/neutral/node-abstract.mjs +1 -0
  205. package/dist/neutral/node-abstract.mjs.map +2 -2
  206. package/dist/neutral/node-memory.mjs.map +2 -2
  207. package/dist/neutral/node-model.mjs.map +2 -2
  208. package/dist/neutral/node-view.mjs +5 -1
  209. package/dist/neutral/node-view.mjs.map +2 -2
  210. package/dist/neutral/node-wrapper.mjs +1 -0
  211. package/dist/neutral/node-wrapper.mjs.map +2 -2
  212. package/dist/neutral/payloadset-plugin.mjs.map +2 -2
  213. package/dist/neutral/sentinel-abstract.mjs +1 -0
  214. package/dist/neutral/sentinel-abstract.mjs.map +2 -2
  215. package/dist/neutral/sentinel-memory.mjs.map +2 -2
  216. package/dist/neutral/sentinel-model.mjs +7 -1
  217. package/dist/neutral/sentinel-model.mjs.map +2 -2
  218. package/dist/neutral/sentinel-wrapper.mjs +1 -0
  219. package/dist/neutral/sentinel-wrapper.mjs.map +2 -2
  220. package/dist/neutral/witness-abstract.mjs +1 -0
  221. package/dist/neutral/witness-abstract.mjs.map +2 -2
  222. package/dist/neutral/witness-adhoc.mjs.map +2 -2
  223. package/dist/neutral/witness-model.mjs.map +2 -2
  224. package/dist/neutral/witness-wrapper.mjs +1 -0
  225. package/dist/neutral/witness-wrapper.mjs.map +2 -2
  226. package/dist/node/modules/account-custody/clientExecution.d.ts.map +1 -1
  227. package/dist/node/modules/account-custody/clientSignals.d.ts.map +1 -1
  228. package/dist/node/modules/account-custody/realmRegistry.d.ts.map +1 -1
  229. package/dist/node/modules/archivist-abstract/InsertSequencer.d.ts +25 -0
  230. package/dist/node/modules/archivist-abstract/InsertSequencer.d.ts.map +1 -0
  231. package/dist/node/modules/archivist-memory/MemoryDriver.d.ts.map +1 -1
  232. package/dist/node/modules/module-abstract/determineAccount.d.ts.map +1 -1
  233. package/package.json +12 -12
@@ -167,8 +167,16 @@ function prepareExecution(state, execution, signal) {
167
167
  }
168
168
  };
169
169
  try {
170
- nativeCall(nativeAddListener, local, ["abort", aborted, { once: true }]);
171
- if (signal !== void 0) nativeCall(nativeAddListener, signal, ["abort", abort, { once: true }]);
170
+ nativeCall(nativeAddListener, local, [
171
+ "abort",
172
+ aborted,
173
+ { once: true }
174
+ ]);
175
+ if (signal !== void 0) nativeCall(nativeAddListener, signal, [
176
+ "abort",
177
+ abort,
178
+ { once: true }
179
+ ]);
172
180
  if (signal !== void 0 && isSignalAborted(signal)) abort();
173
181
  } catch {
174
182
  cleanup();
@@ -302,7 +310,11 @@ function clientSignalAborted(signal) {
302
310
  return result;
303
311
  }
304
312
  function listenClientSignal(signal, listener) {
305
- nativeCall2(addListener, signal, ["abort", listener, { once: true }]);
313
+ nativeCall2(addListener, signal, [
314
+ "abort",
315
+ listener,
316
+ { once: true }
317
+ ]);
306
318
  }
307
319
  function removeClientSignal(signal, listener) {
308
320
  try {
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modules/account-custody/error.ts", "../../src/modules/account-custody/realmRegistry.ts", "../../src/modules/account-custody/AccountCustody.ts", "../../src/modules/account-custody/clientState.ts", "../../src/modules/account-custody/clientSignals.ts", "../../src/modules/account-custody/clientExecution.ts", "../../src/modules/account-custody/clientOwner.ts", "../../src/modules/account-custody/AccountCustodyClient.ts"],
4
- "sourcesContent": ["import type { AccountCustodyErrorCode } from './model.ts'\n\n/** Classified failure with no private native exception, key material or request contents. */\nexport class AccountCustodyError extends Error {\n readonly code: AccountCustodyErrorCode\n override name = 'AccountCustodyError'\n\n constructor(code: AccountCustodyErrorCode) {\n super(`Account custody: ${code}`)\n this.code = code\n }\n}\n", "import { AccountCustodyError } from './error.ts'\n\ninterface RealmRegistry {\n readonly version: 1\n reserve(this: void, key: string, fence: object): boolean\n}\n\nfunction realmRegistry(): RealmRegistry {\n const key = Symbol.for('network.xyo.sdk.account-custody.in-realm.v1')\n const existing: unknown = Reflect.get(globalThis, key)\n if (existing === undefined) {\n const reservations = new Set<string>()\n const registry: RealmRegistry = Object.freeze({\n version: 1,\n reserve(key: string, _fence: object): boolean {\n if (reservations.has(key)) return false\n reservations.add(key)\n return true\n },\n })\n Object.defineProperty(globalThis, key, {\n value: registry, configurable: false, writable: false,\n })\n return registry\n }\n if (typeof existing !== 'object' || existing === null || !Object.isFrozen(existing)\n || !('version' in existing) || existing.version !== 1 || !('reserve' in existing)\n || typeof existing.reserve !== 'function') throw new AccountCustodyError('stopped')\n return existing as RealmRegistry\n}\n\n// One permanent address reservation shared by legacy/scoped modes and module copies.\nconst registry = realmRegistry()\n\nexport function reserveInRealmAccount(address: string, fence: object = Object.freeze({})): boolean {\n return registry.reserve(address.toLowerCase(), fence)\n}\n", "import type { AccountInstance } from '@xyo-network/sdk-protocol'\n\nimport { AccountCustodyError } from './error.ts'\nimport { reserveInRealmAccount } from './realmRegistry.ts'\n\nexport { AccountCustodyError } from './error.ts'\n\nimport type {\n AccountCustody,\n AccountCustodyAssurance,\n AccountCustodyExecuteOptions,\n AccountCustodyLimits,\n AccountCustodyOperationControl,\n AccountCustodyOptions,\n AccountCustodyOwner,\n AccountCustodyStatus,\n InRealmAccountCustodyOwnerOptions,\n} from './model.ts'\n\ninterface RealmFence {\n active?: AbortController\n executions: Set<Execution>\n isStopped: boolean\n reservation: object\n tail: Promise<void>\n}\n\ninterface OwnerState {\n account: AccountInstance\n fence: RealmFence\n limits: AccountCustodyLimits\n reservation: object\n}\n\ninterface Execution {\n controller: AbortController\n hasCompleted: boolean\n hasStarted: boolean\n}\n\ninterface ExecutionObserver<Result> {\n result: Promise<Result>\n cleanup(this: void): void\n reject(this: void, error: unknown): void\n resolve(this: void, result: Result): void\n}\n\n// Native intrinsics ignore caller-owned getters and shadowed event methods.\nfunction intrinsic(prototype: object, property: string, member: 'get' | 'value'): unknown {\n const descriptor: unknown = Object.getOwnPropertyDescriptor(prototype, property)\n return typeof descriptor !== 'object' || descriptor === null ? undefined : (descriptor as Record<string, unknown>)[member]\n}\n\nconst nativeAbortedGetter = intrinsic(AbortSignal.prototype, 'aborted', 'get')\nconst nativeAddListener = intrinsic(EventTarget.prototype, 'addEventListener', 'value')\nconst nativeRemoveListener = intrinsic(EventTarget.prototype, 'removeEventListener', 'value')\n\nfunction nativeCall(method: unknown, receiver: object, args: unknown[]): unknown {\n if (typeof method !== 'function') throw new AccountCustodyError('invalid-request')\n return Reflect.apply(method, receiver, args)\n}\n\nfunction isSignalAborted(signal: AbortSignal): boolean {\n const result = nativeCall(nativeAbortedGetter, signal, [])\n if (typeof result !== 'boolean') throw new AccountCustodyError('invalid-request')\n return result\n}\n\nfunction captureSignal(options: AccountCustodyExecuteOptions): AbortSignal | undefined {\n try {\n const signal = options.signal\n if (signal !== undefined) isSignalAborted(signal)\n return signal\n } catch {\n throw new AccountCustodyError('invalid-request')\n }\n}\n\nconst owners = new WeakMap<AccountCustodyOwner, OwnerState>()\nconst assurance: AccountCustodyAssurance = Object.freeze({\n profile: 'in-realm-exclusive-v1',\n scope: 'participating instances and module copies in one globalThis realm',\n physicalKeyIsolation: 'unqualified',\n crossHostOwnership: 'unqualified',\n})\n\n/**\n * Trusted provisioner entry. A live-state declaration is not cryptographic proof\n * of a never-used key, restart recovery, physical isolation or cross-host custody.\n * Unknown state reserves a stopped owner, and reservations never reset in this realm.\n */\nexport function createInRealmAccountCustodyOwner(options: InRealmAccountCustodyOwnerOptions): AccountCustodyOwner {\n const limits = finiteLimits(options.limits)\n const address = options.account.address\n const key = address.toLowerCase()\n const reservation = Object.freeze({})\n const fence: RealmFence = {\n executions: new Set(),\n reservation,\n isStopped: options.nativeState !== 'established-live',\n tail: Promise.resolve(),\n }\n if (!reserveInRealmAccount(key, fence)) throw new AccountCustodyError('account-reserved')\n const owner: AccountCustodyOwner = Object.freeze({\n address, assurance, limits,\n })\n owners.set(owner, {\n account: options.account, fence, limits, reservation,\n })\n return owner\n}\n\nfunction finiteLimits(selected: AccountCustodyLimits | undefined): AccountCustodyLimits {\n const maxQueuedOperations = selected?.maxQueuedOperations ?? 8\n const maxOperationMilliseconds = selected?.maxOperationMilliseconds ?? 30_000\n if (!Number.isSafeInteger(maxQueuedOperations) || maxQueuedOperations < 0 || maxQueuedOperations > 1024\n || !Number.isSafeInteger(maxOperationMilliseconds) || maxOperationMilliseconds <= 0 || maxOperationMilliseconds > 2_147_483_647) {\n throw new AccountCustodyError('invalid-limits')\n }\n return Object.freeze({ maxQueuedOperations, maxOperationMilliseconds })\n}\n\nfunction stopOwner(state: OwnerState): void {\n if (state.fence.isStopped) return\n state.fence.isStopped = true\n for (const execution of state.fence.executions) execution.controller.abort()\n}\n\nfunction assertReady(state: OwnerState, owner: AccountCustodyOwner): void {\n if (!state.fence.isStopped && state.fence.reservation === state.reservation && state.account.address === owner.address) return\n stopOwner(state)\n throw new AccountCustodyError('stopped')\n}\n\nfunction operationControl(state: OwnerState, execution: Execution, deadline: number): AccountCustodyOperationControl {\n return Object.freeze({\n signal: execution.controller.signal,\n assertActive(): void {\n assertWithinDeadline(deadline)\n if (execution.controller.signal.aborted || state.fence.isStopped) throw new AccountCustodyError('uncertain-operation')\n },\n })\n}\n\nfunction assertWithinDeadline(deadline: number): void {\n if (performance.now() >= deadline) throw new AccountCustodyError('uncertain-operation')\n}\n\nasync function perform<Request, Result>(\n state: OwnerState,\n options: AccountCustodyOptions<Request, Result>,\n execution: Execution,\n request: Request,\n): Promise<Result> {\n if (execution.controller.signal.aborted) throw new AccountCustodyError('cancelled-before-operation')\n assertReady(state, options.owner)\n execution.hasStarted = true\n state.fence.active = execution.controller\n const deadline = performance.now() + state.limits.maxOperationMilliseconds\n const timer = setTimeout(() => execution.controller.abort(), state.limits.maxOperationMilliseconds)\n try {\n const control = operationControl(state, execution, deadline)\n const operation = options.createOperation(state.account, control)\n const result = await operation(request)\n const cloned = structuredClone(result)\n assertWithinDeadline(deadline)\n control.assertActive()\n execution.hasCompleted = true\n return cloned\n } catch {\n stopOwner(state)\n throw new AccountCustodyError('uncertain-operation')\n } finally {\n clearTimeout(timer)\n if (state.fence.active === execution.controller) state.fence.active = undefined\n }\n}\n\nfunction prepareExecution<Result>(\n state: OwnerState,\n execution: Execution,\n signal: AbortSignal | undefined,\n): ExecutionObserver<Result> {\n const deferred = Promise.withResolvers<Result>()\n const local = execution.controller.signal\n const abort = () => execution.controller.abort()\n const aborted = () => {\n if (execution.hasCompleted) return\n if (execution.hasStarted) stopOwner(state)\n const code = execution.hasStarted ? 'uncertain-operation' : state.fence.isStopped ? 'stopped' : 'cancelled-before-operation'\n deferred.reject(new AccountCustodyError(code))\n }\n const cleanup = () => {\n try {\n if (signal !== undefined) nativeCall(nativeRemoveListener, signal, ['abort', abort])\n nativeCall(nativeRemoveListener, local, ['abort', aborted])\n } catch {\n // Cleanup cannot expose native diagnostics or orphan an unhandled rejection.\n }\n }\n try {\n nativeCall(nativeAddListener, local, ['abort', aborted, { once: true }])\n if (signal !== undefined) nativeCall(nativeAddListener, signal, ['abort', abort, { once: true }])\n if (signal !== undefined && isSignalAborted(signal)) abort()\n } catch {\n cleanup()\n throw new AccountCustodyError('invalid-request')\n }\n return {\n result: deferred.promise, resolve: deferred.resolve, reject: deferred.reject, cleanup,\n }\n}\n\nasync function settleExecution<Result>(\n pending: Promise<Result>,\n resolve: (result: Result) => void,\n reject: (error: unknown) => void,\n cleanup: () => void,\n): Promise<void> {\n try {\n resolve(await pending)\n } catch (error) {\n reject(error)\n } finally {\n cleanup()\n }\n}\n\nasync function afterQueue<Request, Result>(\n before: Promise<void>,\n state: OwnerState,\n options: AccountCustodyOptions<Request, Result>,\n execution: Execution,\n request: Request,\n): Promise<Result> {\n try {\n await before\n return await perform(state, options, execution, request)\n } finally {\n state.fence.executions.delete(execution)\n }\n}\n\nasync function drainPending(pending: Promise<unknown>): Promise<void> {\n try {\n await pending\n } catch {\n // Failure is delivered to its caller and does not break queue draining.\n }\n}\n\n/**\n * Wraps a trusted, fixed operation builder. The complete native operation is\n * serialized across all contexts sharing the owner; only content is caller input.\n */\nexport function createAccountCustody<Request, Result>(options: AccountCustodyOptions<Request, Result>): AccountCustody<Request, Result> {\n const state = owners.get(options.owner)\n if (state === undefined) throw new AccountCustodyError('unissued-owner')\n const binding = Object.freeze({ address: options.binding.address, domain: options.binding.domain })\n if (binding.address !== options.owner.address || binding.domain.length === 0) throw new AccountCustodyError('binding-mismatch')\n // Capture immutable composition; later host/caller option mutation cannot retarget work.\n const captured: AccountCustodyOptions<Request, Result> = {\n owner: options.owner, binding, createOperation: options.createOperation, snapshot: options.snapshot,\n }\n return Object.freeze({\n assurance,\n binding,\n get outstandingOperations(): number {\n return state.fence.executions.size\n },\n get status(): AccountCustodyStatus {\n return state.fence.isStopped ? 'stopped' : state.fence.active === undefined ? 'ready' : 'running'\n },\n async execute(request: Request, executionOptions: AccountCustodyExecuteOptions = {}): Promise<Result> {\n assertReady(state, captured.owner)\n if (state.fence.executions.size >= state.limits.maxQueuedOperations + 1) throw new AccountCustodyError('capacity-exhausted')\n const signal = captureSignal(executionOptions)\n if (signal !== undefined && isSignalAborted(signal)) throw new AccountCustodyError('cancelled-before-operation')\n let original: Request\n try {\n original = structuredClone(captured.snapshot(request))\n } catch {\n throw new AccountCustodyError('invalid-request')\n }\n const execution: Execution = {\n controller: new AbortController(), hasCompleted: false, hasStarted: false,\n }\n const observer = prepareExecution<Result>(state, execution, signal)\n state.fence.executions.add(execution)\n const pending = afterQueue(state.fence.tail, state, captured, execution, original)\n state.fence.tail = drainPending(pending)\n void settleExecution(pending, observer.resolve, observer.reject, observer.cleanup)\n return await observer.result\n },\n stop(): void {\n stopOwner(state)\n },\n async drain(): Promise<void> {\n await state.fence.tail\n },\n })\n}\n", "import type { AccountInstance, XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { AccountCustodyClientErrorCode } from './clientModel.ts'\nimport type { AccountCustodyLimits } from './model.ts'\n\nexport interface ClientExecution {\n controller: AbortController\n hasCompleted: boolean\n hasStarted: boolean\n}\n\nexport interface ClientState {\n closed: boolean\n executions: Set<ClientExecution>\n tail: Promise<void>\n}\n\nexport interface ClientOwnerState {\n account: AccountInstance\n address: XyoAddress\n current?: ClientState\n executions: Set<ClientExecution>\n limits: AccountCustodyLimits\n stopped: boolean\n tail: Promise<void>\n}\n\nexport class AccountCustodyClientError extends Error {\n readonly code: AccountCustodyClientErrorCode\n override name = 'AccountCustodyClientError'\n\n constructor(code: AccountCustodyClientErrorCode) {\n super(`Account custody client: ${code}`)\n this.code = code\n }\n}\n\nexport function stopClientOwner(state: ClientOwnerState): void {\n state.stopped = true\n for (const execution of state.executions) execution.controller.abort()\n}\n\nexport function assertClientOwnerReady(state: ClientOwnerState): void {\n try {\n if (!state.stopped && state.account.address === state.address) return\n } catch {\n // Trusted account failure cannot expose private diagnostics or establish state.\n }\n stopClientOwner(state)\n throw new AccountCustodyClientError('stopped')\n}\n\nexport async function settleClientTail(pending: Promise<unknown>): Promise<void> {\n try {\n await pending\n } catch {\n // The operation caller observes failure; this promise retains genuine settlement.\n }\n}\n", "import { AccountCustodyClientError } from './clientState.ts'\n\nfunction intrinsic(prototype: object, property: string, member: 'get' | 'value'): unknown {\n const descriptor: unknown = Object.getOwnPropertyDescriptor(prototype, property)\n return typeof descriptor !== 'object' || descriptor === null ? undefined : (descriptor as Record<string, unknown>)[member]\n}\nconst abortedGetter = intrinsic(AbortSignal.prototype, 'aborted', 'get')\nconst addListener = intrinsic(EventTarget.prototype, 'addEventListener', 'value')\nconst removeListener = intrinsic(EventTarget.prototype, 'removeEventListener', 'value')\n\nfunction nativeCall(method: unknown, receiver: object, args: unknown[]): unknown {\n if (typeof method !== 'function') throw new AccountCustodyClientError('invalid-request')\n return Reflect.apply(method, receiver, args)\n}\n\nexport function clientSignalAborted(signal: AbortSignal): boolean {\n const result = nativeCall(abortedGetter, signal, [])\n if (typeof result !== 'boolean') throw new AccountCustodyClientError('invalid-request')\n return result\n}\n\nexport function listenClientSignal(signal: AbortSignal, listener: () => void): void {\n nativeCall(addListener, signal, ['abort', listener, { once: true }])\n}\n\nexport function removeClientSignal(signal: AbortSignal, listener: () => void): void {\n try {\n nativeCall(removeListener, signal, ['abort', listener])\n } catch {\n // Cleanup cannot leak native diagnostics; actual callback settlement owns capacity.\n }\n}\n", "import type { AccountCustodyClientOptions } from './clientModel.ts'\nimport {\n clientSignalAborted, listenClientSignal, removeClientSignal,\n} from './clientSignals.ts'\nimport {\n AccountCustodyClientError, assertClientOwnerReady, type ClientExecution, type ClientOwnerState, type ClientState, stopClientOwner,\n} from './clientState.ts'\nimport type { AccountCustodyOperationControl } from './model.ts'\n\nfunction operationControl(owner: ClientOwnerState, execution: ClientExecution, deadline: number): AccountCustodyOperationControl {\n return Object.freeze({\n signal: execution.controller.signal,\n assertActive() {\n assertClientOwnerReady(owner)\n if (performance.now() >= deadline || execution.controller.signal.aborted || owner.stopped)\n throw new AccountCustodyClientError('uncertain-operation')\n },\n })\n}\n\nasync function perform<Request, Result>(\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n execution: ClientExecution,\n request: Request,\n): Promise<Result> {\n if (client.closed || execution.controller.signal.aborted) throw new AccountCustodyClientError('cancelled-before-operation')\n assertClientOwnerReady(owner)\n execution.hasStarted = true\n const deadline = performance.now() + owner.limits.maxOperationMilliseconds\n const timer = setTimeout(() => execution.controller.abort(), owner.limits.maxOperationMilliseconds)\n try {\n const control = operationControl(owner, execution, deadline)\n const result = structuredClone(await options.createOperation(owner.account, control)(request))\n control.assertActive()\n execution.hasCompleted = true\n return result\n } catch {\n stopClientOwner(owner)\n throw new AccountCustodyClientError('uncertain-operation')\n } finally {\n clearTimeout(timer)\n }\n}\n\nexport async function afterClientQueue<Request, Result>(\n before: Promise<void>,\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n execution: ClientExecution,\n request: Request,\n): Promise<Result> {\n try {\n await before\n return await perform(owner, client, options, execution, request)\n } finally {\n owner.executions.delete(execution)\n client.executions.delete(execution)\n }\n}\n\nexport function observeClientExecution<Result>(owner: ClientOwnerState, execution: ClientExecution, caller?: AbortSignal) {\n const deferred = Promise.withResolvers<Result>()\n const local = execution.controller.signal\n const abort = () => execution.controller.abort()\n const aborted = () => {\n if (execution.hasCompleted) return\n if (execution.hasStarted) stopClientOwner(owner)\n deferred.reject(new AccountCustodyClientError(execution.hasStarted ? 'uncertain-operation' : owner.stopped ? 'stopped' : 'cancelled-before-operation'))\n }\n const cleanup = () => {\n removeClientSignal(local, aborted)\n if (caller !== undefined) removeClientSignal(caller, abort)\n }\n try {\n listenClientSignal(local, aborted)\n if (caller !== undefined) listenClientSignal(caller, abort)\n if (caller !== undefined && clientSignalAborted(caller)) abort()\n } catch {\n cleanup()\n throw new AccountCustodyClientError('invalid-request')\n }\n return {\n result: deferred.promise, resolve: deferred.resolve, reject: deferred.reject, cleanup,\n }\n}\n\nexport async function settleClientExecution<Result>(pending: Promise<Result>, observer: ReturnType<typeof observeClientExecution<Result>>): Promise<void> {\n try {\n observer.resolve(await pending)\n } catch (error) {\n observer.reject(error)\n } finally {\n observer.cleanup()\n }\n}\n", "import type {\n AccountCustodyClientAssurance, AccountCustodyClientOwner, InRealmAccountCustodyClientOwnerOptions,\n} from './clientModel.ts'\nimport {\n AccountCustodyClientError, type ClientOwnerState, stopClientOwner,\n} from './clientState.ts'\nimport type { AccountCustodyLimits } from './model.ts'\nimport { reserveInRealmAccount } from './realmRegistry.ts'\n\nexport const scopedClientAssurance: AccountCustodyClientAssurance = Object.freeze({\n profile: 'in-realm-exclusive-scoped-client-v1',\n scope: 'participating instances and module copies in one globalThis realm',\n physicalKeyIsolation: 'unqualified',\n crossHostOwnership: 'unqualified',\n})\nconst owners = new WeakMap<AccountCustodyClientOwner, ClientOwnerState>()\n\nfunction finiteLimits(selected?: AccountCustodyLimits): AccountCustodyLimits {\n const maxQueuedOperations = selected?.maxQueuedOperations ?? 8\n const maxOperationMilliseconds = selected?.maxOperationMilliseconds ?? 30_000\n if (!Number.isSafeInteger(maxQueuedOperations) || maxQueuedOperations < 0 || maxQueuedOperations > 1024\n || !Number.isSafeInteger(maxOperationMilliseconds) || maxOperationMilliseconds <= 0 || maxOperationMilliseconds > 2_147_483_647)\n throw new AccountCustodyClientError('invalid-limits')\n return Object.freeze({ maxQueuedOperations, maxOperationMilliseconds })\n}\n\n/** Resident owner with no restoration/remint. Shares legacy's permanent account reservation. */\nexport function createInRealmAccountCustodyClientOwner(options: InRealmAccountCustodyClientOwnerOptions): AccountCustodyClientOwner {\n const limits = finiteLimits(options.limits)\n const account = options.account\n const address = account.address\n if (!reserveInRealmAccount(address)) throw new AccountCustodyClientError('account-reserved')\n const state: ClientOwnerState = {\n account, address, limits, stopped: options.nativeState !== 'established-live', executions: new Set(), tail: Promise.resolve(),\n }\n const owner: AccountCustodyClientOwner = Object.freeze({\n address,\n limits,\n assurance: scopedClientAssurance,\n get outstandingOperations() { return state.executions.size },\n get status() { return state.stopped ? 'stopped' : state.executions.size > 0 ? 'running' : 'ready' },\n drain: async () => { await state.tail },\n stop: () => { stopClientOwner(state) },\n })\n owners.set(owner, state)\n return owner\n}\n\nexport function getClientOwnerState(owner: AccountCustodyClientOwner): ClientOwnerState {\n const state = owners.get(owner)\n if (state === undefined) throw new AccountCustodyClientError('unissued-owner')\n return state\n}\n", "import {\n afterClientQueue, observeClientExecution, settleClientExecution,\n} from './clientExecution.ts'\nimport type { AccountCustodyClient, AccountCustodyClientOptions } from './clientModel.ts'\nimport { getClientOwnerState, scopedClientAssurance } from './clientOwner.ts'\nimport { clientSignalAborted } from './clientSignals.ts'\nimport {\n AccountCustodyClientError, assertClientOwnerReady, type ClientExecution, type ClientOwnerState, type ClientState, settleClientTail,\n} from './clientState.ts'\nimport type { AccountCustodyExecuteOptions } from './model.ts'\n\nfunction captureSignal(options: AccountCustodyExecuteOptions): AbortSignal | undefined {\n try {\n const signal = options.signal\n if (signal !== undefined) clientSignalAborted(signal)\n return signal\n } catch {\n throw new AccountCustodyClientError('invalid-request')\n }\n}\n\nfunction claimClient(owner: ClientOwnerState): ClientState {\n assertClientOwnerReady(owner)\n if (owner.current !== undefined && !owner.current.closed) throw new AccountCustodyClientError('client-active')\n if (owner.executions.size > 0 || (owner.current?.executions.size ?? 0) > 0) throw new AccountCustodyClientError('client-not-drained')\n const client: ClientState = {\n closed: false, executions: new Set(), tail: Promise.resolve(),\n }\n owner.current = client\n return client\n}\n\nfunction closeClient(client: ClientState): void {\n client.closed = true\n for (const execution of client.executions) {\n if (!execution.hasStarted) execution.controller.abort()\n }\n}\n\nasync function execute<Request, Result>(\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n request: Request,\n executeOptions: AccountCustodyExecuteOptions,\n): Promise<Result> {\n if (client.closed) throw new AccountCustodyClientError('stopped')\n assertClientOwnerReady(owner)\n if (owner.executions.size >= owner.limits.maxQueuedOperations + 1) throw new AccountCustodyClientError('capacity-exhausted')\n const signal = captureSignal(executeOptions)\n if (signal !== undefined && clientSignalAborted(signal)) throw new AccountCustodyClientError('cancelled-before-operation')\n let original: Request\n try {\n original = structuredClone(options.snapshot(request))\n } catch {\n throw new AccountCustodyClientError('invalid-request')\n }\n // Snapshot/getters may reenter public lifecycle methods; recheck actual admission.\n if (client.closed || owner.current !== client) throw new AccountCustodyClientError('stopped')\n assertClientOwnerReady(owner)\n if (owner.executions.size >= owner.limits.maxQueuedOperations + 1) throw new AccountCustodyClientError('capacity-exhausted')\n const execution: ClientExecution = {\n controller: new AbortController(), hasCompleted: false, hasStarted: false,\n }\n const observer = observeClientExecution<Result>(owner, execution, signal)\n owner.executions.add(execution)\n client.executions.add(execution)\n const pending = afterClientQueue(owner.tail, owner, client, options, execution, original)\n owner.tail = client.tail = settleClientTail(pending)\n void settleClientExecution(pending, observer)\n return await observer.result\n}\n\n/** Trusted issuer creates a single fenced client; clean close preserves its resident owner. */\nexport function createAccountCustodyClient<Request, Result>(input: AccountCustodyClientOptions<Request, Result>): AccountCustodyClient<Request, Result> {\n const ownerRef = input.owner\n const owner = getClientOwnerState(ownerRef)\n const bindingRef = input.binding\n const binding = Object.freeze({ address: bindingRef.address, domain: bindingRef.domain })\n if (binding.address !== owner.address || typeof binding.domain !== 'string' || binding.domain.length === 0)\n throw new AccountCustodyClientError('binding-mismatch')\n const options = Object.freeze({\n owner: ownerRef, binding, snapshot: input.snapshot, createOperation: input.createOperation,\n })\n if (typeof options.snapshot !== 'function' || typeof options.createOperation !== 'function') throw new AccountCustodyClientError('invalid-request')\n const client = claimClient(owner)\n return Object.freeze({\n binding,\n assurance: scopedClientAssurance,\n get outstandingOperations() { return client.executions.size },\n get status() { return client.closed || owner.stopped ? 'stopped' : client.executions.size > 0 ? 'running' : 'ready' },\n execute: async (request: Request, executeOptions: AccountCustodyExecuteOptions = {}) => await execute(owner, client, options, request, executeOptions),\n stop: () => { closeClient(client) },\n drain: async () => { await client.tail },\n })\n}\n"],
5
- "mappings": ";AAGO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACpC;AAAA,EACA,OAAO;AAAA,EAEhB,YAAY,MAA+B;AACzC,UAAM,oBAAoB,IAAI,EAAE;AAChC,SAAK,OAAO;AAAA,EACd;AACF;;;ACJA,SAAS,gBAA+B;AACtC,QAAM,MAAM,uBAAO,IAAI,6CAA6C;AACpE,QAAM,WAAoB,QAAQ,IAAI,YAAY,GAAG;AACrD,MAAI,aAAa,QAAW;AAC1B,UAAM,eAAe,oBAAI,IAAY;AACrC,UAAMA,YAA0B,OAAO,OAAO;AAAA,MAC5C,SAAS;AAAA,MACT,QAAQC,MAAa,QAAyB;AAC5C,YAAI,aAAa,IAAIA,IAAG,EAAG,QAAO;AAClC,qBAAa,IAAIA,IAAG;AACpB,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AACD,WAAO,eAAe,YAAY,KAAK;AAAA,MACrC,OAAOD;AAAA,MAAU,cAAc;AAAA,MAAO,UAAU;AAAA,IAClD,CAAC;AACD,WAAOA;AAAA,EACT;AACA,MAAI,OAAO,aAAa,YAAY,aAAa,QAAQ,CAAC,OAAO,SAAS,QAAQ,KA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AAiB,MAAM;AAAA,EAC7E,CAAC;AACD,MAAI,OAAO,QAAQ,aAAa,cAAc,OAAO,QAAQ,oBAAoB,WAAY,OAAM,IAAI,0BAA0B,iBAAiB;AAClJ,QAAM,SAAS,YAAY,KAAK;AAChC,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,WAAW;AAAA,IACX,IAAI,wBAAwB;AAAE,aAAO,OAAO,WAAW;AAAA,IAAK;AAAA,IAC5D,IAAI,SAAS;AAAE,aAAO,OAAO,UAAU,MAAM,UAAU,YAAY,OAAO,WAAW,OAAO,IAAI,YAAY;AAAA,IAAQ;AAAA,IACpH,SAAS,OAAO,SAAkB,iBAA+C,CAAC,MAAM,MAAM,QAAQ,OAAO,QAAQ,SAAS,SAAS,cAAc;AAAA,IACrJ,MAAM,MAAM;AAAE,kBAAY,MAAM;AAAA,IAAE;AAAA,IAClC,OAAO,YAAY;AAAE,YAAM,OAAO;AAAA,IAAK;AAAA,EACzC,CAAC;AACH;",
4
+ "sourcesContent": ["import type { AccountCustodyErrorCode } from './model.ts'\n\n/** Classified failure with no private native exception, key material or request contents. */\nexport class AccountCustodyError extends Error {\n readonly code: AccountCustodyErrorCode\n override name = 'AccountCustodyError'\n\n constructor(code: AccountCustodyErrorCode) {\n super(`Account custody: ${code}`)\n this.code = code\n }\n}\n", "import { AccountCustodyError } from './error.ts'\n\ninterface RealmRegistry {\n readonly version: 1\n reserve(this: void, key: string, fence: object): boolean\n}\n\nfunction realmRegistry(): RealmRegistry {\n const key = Symbol.for('network.xyo.sdk.account-custody.in-realm.v1')\n const existing: unknown = Reflect.get(globalThis, key)\n if (existing === undefined) {\n const reservations = new Set<string>()\n const registry: RealmRegistry = Object.freeze({\n version: 1,\n reserve(key: string, _fence: object): boolean {\n if (reservations.has(key)) return false\n reservations.add(key)\n return true\n },\n })\n Object.defineProperty(globalThis, key, {\n value: registry,\n configurable: false,\n writable: false,\n })\n return registry\n }\n if (typeof existing !== 'object' || existing === null || !Object.isFrozen(existing)\n || !('version' in existing) || existing.version !== 1 || !('reserve' in existing)\n || typeof existing.reserve !== 'function') throw new AccountCustodyError('stopped')\n return existing as RealmRegistry\n}\n\n// One permanent address reservation shared by legacy/scoped modes and module copies.\nconst registry = realmRegistry()\n\nexport function reserveInRealmAccount(address: string, fence: object = Object.freeze({})): boolean {\n return registry.reserve(address.toLowerCase(), fence)\n}\n", "import type { AccountInstance } from '@xyo-network/sdk-protocol'\n\nimport { AccountCustodyError } from './error.ts'\nimport { reserveInRealmAccount } from './realmRegistry.ts'\n\nexport { AccountCustodyError } from './error.ts'\n\nimport type {\n AccountCustody,\n AccountCustodyAssurance,\n AccountCustodyExecuteOptions,\n AccountCustodyLimits,\n AccountCustodyOperationControl,\n AccountCustodyOptions,\n AccountCustodyOwner,\n AccountCustodyStatus,\n InRealmAccountCustodyOwnerOptions,\n} from './model.ts'\n\ninterface RealmFence {\n active?: AbortController\n executions: Set<Execution>\n isStopped: boolean\n reservation: object\n tail: Promise<void>\n}\n\ninterface OwnerState {\n account: AccountInstance\n fence: RealmFence\n limits: AccountCustodyLimits\n reservation: object\n}\n\ninterface Execution {\n controller: AbortController\n hasCompleted: boolean\n hasStarted: boolean\n}\n\ninterface ExecutionObserver<Result> {\n result: Promise<Result>\n cleanup(this: void): void\n reject(this: void, error: unknown): void\n resolve(this: void, result: Result): void\n}\n\n// Native intrinsics ignore caller-owned getters and shadowed event methods.\nfunction intrinsic(prototype: object, property: string, member: 'get' | 'value'): unknown {\n const descriptor: unknown = Object.getOwnPropertyDescriptor(prototype, property)\n return typeof descriptor !== 'object' || descriptor === null ? undefined : (descriptor as Record<string, unknown>)[member]\n}\n\nconst nativeAbortedGetter = intrinsic(AbortSignal.prototype, 'aborted', 'get')\nconst nativeAddListener = intrinsic(EventTarget.prototype, 'addEventListener', 'value')\nconst nativeRemoveListener = intrinsic(EventTarget.prototype, 'removeEventListener', 'value')\n\nfunction nativeCall(method: unknown, receiver: object, args: unknown[]): unknown {\n if (typeof method !== 'function') throw new AccountCustodyError('invalid-request')\n return Reflect.apply(method, receiver, args)\n}\n\nfunction isSignalAborted(signal: AbortSignal): boolean {\n const result = nativeCall(nativeAbortedGetter, signal, [])\n if (typeof result !== 'boolean') throw new AccountCustodyError('invalid-request')\n return result\n}\n\nfunction captureSignal(options: AccountCustodyExecuteOptions): AbortSignal | undefined {\n try {\n const signal = options.signal\n if (signal !== undefined) isSignalAborted(signal)\n return signal\n } catch {\n throw new AccountCustodyError('invalid-request')\n }\n}\n\nconst owners = new WeakMap<AccountCustodyOwner, OwnerState>()\nconst assurance: AccountCustodyAssurance = Object.freeze({\n profile: 'in-realm-exclusive-v1',\n scope: 'participating instances and module copies in one globalThis realm',\n physicalKeyIsolation: 'unqualified',\n crossHostOwnership: 'unqualified',\n})\n\n/**\n * Trusted provisioner entry. A live-state declaration is not cryptographic proof\n * of a never-used key, restart recovery, physical isolation or cross-host custody.\n * Unknown state reserves a stopped owner, and reservations never reset in this realm.\n */\nexport function createInRealmAccountCustodyOwner(options: InRealmAccountCustodyOwnerOptions): AccountCustodyOwner {\n const limits = finiteLimits(options.limits)\n const address = options.account.address\n const key = address.toLowerCase()\n const reservation = Object.freeze({})\n const fence: RealmFence = {\n executions: new Set(),\n reservation,\n isStopped: options.nativeState !== 'established-live',\n tail: Promise.resolve(),\n }\n if (!reserveInRealmAccount(key, fence)) throw new AccountCustodyError('account-reserved')\n const owner: AccountCustodyOwner = Object.freeze({\n address,\n assurance,\n limits,\n })\n owners.set(owner, {\n account: options.account,\n fence,\n limits,\n reservation,\n })\n return owner\n}\n\nfunction finiteLimits(selected: AccountCustodyLimits | undefined): AccountCustodyLimits {\n const maxQueuedOperations = selected?.maxQueuedOperations ?? 8\n const maxOperationMilliseconds = selected?.maxOperationMilliseconds ?? 30_000\n if (!Number.isSafeInteger(maxQueuedOperations) || maxQueuedOperations < 0 || maxQueuedOperations > 1024\n || !Number.isSafeInteger(maxOperationMilliseconds) || maxOperationMilliseconds <= 0 || maxOperationMilliseconds > 2_147_483_647) {\n throw new AccountCustodyError('invalid-limits')\n }\n return Object.freeze({ maxQueuedOperations, maxOperationMilliseconds })\n}\n\nfunction stopOwner(state: OwnerState): void {\n if (state.fence.isStopped) return\n state.fence.isStopped = true\n for (const execution of state.fence.executions) execution.controller.abort()\n}\n\nfunction assertReady(state: OwnerState, owner: AccountCustodyOwner): void {\n if (!state.fence.isStopped && state.fence.reservation === state.reservation && state.account.address === owner.address) return\n stopOwner(state)\n throw new AccountCustodyError('stopped')\n}\n\nfunction operationControl(state: OwnerState, execution: Execution, deadline: number): AccountCustodyOperationControl {\n return Object.freeze({\n signal: execution.controller.signal,\n assertActive(): void {\n assertWithinDeadline(deadline)\n if (execution.controller.signal.aborted || state.fence.isStopped) throw new AccountCustodyError('uncertain-operation')\n },\n })\n}\n\nfunction assertWithinDeadline(deadline: number): void {\n if (performance.now() >= deadline) throw new AccountCustodyError('uncertain-operation')\n}\n\nasync function perform<Request, Result>(\n state: OwnerState,\n options: AccountCustodyOptions<Request, Result>,\n execution: Execution,\n request: Request,\n): Promise<Result> {\n if (execution.controller.signal.aborted) throw new AccountCustodyError('cancelled-before-operation')\n assertReady(state, options.owner)\n execution.hasStarted = true\n state.fence.active = execution.controller\n const deadline = performance.now() + state.limits.maxOperationMilliseconds\n const timer = setTimeout(() => execution.controller.abort(), state.limits.maxOperationMilliseconds)\n try {\n const control = operationControl(state, execution, deadline)\n const operation = options.createOperation(state.account, control)\n const result = await operation(request)\n const cloned = structuredClone(result)\n assertWithinDeadline(deadline)\n control.assertActive()\n execution.hasCompleted = true\n return cloned\n } catch {\n stopOwner(state)\n throw new AccountCustodyError('uncertain-operation')\n } finally {\n clearTimeout(timer)\n if (state.fence.active === execution.controller) state.fence.active = undefined\n }\n}\n\nfunction prepareExecution<Result>(\n state: OwnerState,\n execution: Execution,\n signal: AbortSignal | undefined,\n): ExecutionObserver<Result> {\n const deferred = Promise.withResolvers<Result>()\n const local = execution.controller.signal\n const abort = () => execution.controller.abort()\n const aborted = () => {\n if (execution.hasCompleted) return\n if (execution.hasStarted) stopOwner(state)\n const code = execution.hasStarted ? 'uncertain-operation' : state.fence.isStopped ? 'stopped' : 'cancelled-before-operation'\n deferred.reject(new AccountCustodyError(code))\n }\n const cleanup = () => {\n try {\n if (signal !== undefined) nativeCall(nativeRemoveListener, signal, ['abort', abort])\n nativeCall(nativeRemoveListener, local, ['abort', aborted])\n } catch {\n // Cleanup cannot expose native diagnostics or orphan an unhandled rejection.\n }\n }\n try {\n nativeCall(nativeAddListener, local, [\n 'abort',\n aborted,\n { once: true },\n ])\n if (signal !== undefined) nativeCall(nativeAddListener, signal, [\n 'abort',\n abort,\n { once: true },\n ])\n if (signal !== undefined && isSignalAborted(signal)) abort()\n } catch {\n cleanup()\n throw new AccountCustodyError('invalid-request')\n }\n return {\n result: deferred.promise,\n resolve: deferred.resolve,\n reject: deferred.reject,\n cleanup,\n }\n}\n\nasync function settleExecution<Result>(\n pending: Promise<Result>,\n resolve: (result: Result) => void,\n reject: (error: unknown) => void,\n cleanup: () => void,\n): Promise<void> {\n try {\n resolve(await pending)\n } catch (error) {\n reject(error)\n } finally {\n cleanup()\n }\n}\n\nasync function afterQueue<Request, Result>(\n before: Promise<void>,\n state: OwnerState,\n options: AccountCustodyOptions<Request, Result>,\n execution: Execution,\n request: Request,\n): Promise<Result> {\n try {\n await before\n return await perform(state, options, execution, request)\n } finally {\n state.fence.executions.delete(execution)\n }\n}\n\nasync function drainPending(pending: Promise<unknown>): Promise<void> {\n try {\n await pending\n } catch {\n // Failure is delivered to its caller and does not break queue draining.\n }\n}\n\n/**\n * Wraps a trusted, fixed operation builder. The complete native operation is\n * serialized across all contexts sharing the owner; only content is caller input.\n */\nexport function createAccountCustody<Request, Result>(options: AccountCustodyOptions<Request, Result>): AccountCustody<Request, Result> {\n const state = owners.get(options.owner)\n if (state === undefined) throw new AccountCustodyError('unissued-owner')\n const binding = Object.freeze({ address: options.binding.address, domain: options.binding.domain })\n if (binding.address !== options.owner.address || binding.domain.length === 0) throw new AccountCustodyError('binding-mismatch')\n // Capture immutable composition; later host/caller option mutation cannot retarget work.\n const captured: AccountCustodyOptions<Request, Result> = {\n owner: options.owner,\n binding,\n createOperation: options.createOperation,\n snapshot: options.snapshot,\n }\n return Object.freeze({\n assurance,\n binding,\n get outstandingOperations(): number {\n return state.fence.executions.size\n },\n get status(): AccountCustodyStatus {\n return state.fence.isStopped ? 'stopped' : state.fence.active === undefined ? 'ready' : 'running'\n },\n async execute(request: Request, executionOptions: AccountCustodyExecuteOptions = {}): Promise<Result> {\n assertReady(state, captured.owner)\n if (state.fence.executions.size >= state.limits.maxQueuedOperations + 1) throw new AccountCustodyError('capacity-exhausted')\n const signal = captureSignal(executionOptions)\n if (signal !== undefined && isSignalAborted(signal)) throw new AccountCustodyError('cancelled-before-operation')\n let original: Request\n try {\n original = structuredClone(captured.snapshot(request))\n } catch {\n throw new AccountCustodyError('invalid-request')\n }\n const execution: Execution = {\n controller: new AbortController(),\n hasCompleted: false,\n hasStarted: false,\n }\n const observer = prepareExecution<Result>(state, execution, signal)\n state.fence.executions.add(execution)\n const pending = afterQueue(state.fence.tail, state, captured, execution, original)\n state.fence.tail = drainPending(pending)\n void settleExecution(pending, observer.resolve, observer.reject, observer.cleanup)\n return await observer.result\n },\n stop(): void {\n stopOwner(state)\n },\n async drain(): Promise<void> {\n await state.fence.tail\n },\n })\n}\n", "import type { AccountInstance, XyoAddress } from '@xyo-network/sdk-protocol'\n\nimport type { AccountCustodyClientErrorCode } from './clientModel.ts'\nimport type { AccountCustodyLimits } from './model.ts'\n\nexport interface ClientExecution {\n controller: AbortController\n hasCompleted: boolean\n hasStarted: boolean\n}\n\nexport interface ClientState {\n closed: boolean\n executions: Set<ClientExecution>\n tail: Promise<void>\n}\n\nexport interface ClientOwnerState {\n account: AccountInstance\n address: XyoAddress\n current?: ClientState\n executions: Set<ClientExecution>\n limits: AccountCustodyLimits\n stopped: boolean\n tail: Promise<void>\n}\n\nexport class AccountCustodyClientError extends Error {\n readonly code: AccountCustodyClientErrorCode\n override name = 'AccountCustodyClientError'\n\n constructor(code: AccountCustodyClientErrorCode) {\n super(`Account custody client: ${code}`)\n this.code = code\n }\n}\n\nexport function stopClientOwner(state: ClientOwnerState): void {\n state.stopped = true\n for (const execution of state.executions) execution.controller.abort()\n}\n\nexport function assertClientOwnerReady(state: ClientOwnerState): void {\n try {\n if (!state.stopped && state.account.address === state.address) return\n } catch {\n // Trusted account failure cannot expose private diagnostics or establish state.\n }\n stopClientOwner(state)\n throw new AccountCustodyClientError('stopped')\n}\n\nexport async function settleClientTail(pending: Promise<unknown>): Promise<void> {\n try {\n await pending\n } catch {\n // The operation caller observes failure; this promise retains genuine settlement.\n }\n}\n", "import { AccountCustodyClientError } from './clientState.ts'\n\nfunction intrinsic(prototype: object, property: string, member: 'get' | 'value'): unknown {\n const descriptor: unknown = Object.getOwnPropertyDescriptor(prototype, property)\n return typeof descriptor !== 'object' || descriptor === null ? undefined : (descriptor as Record<string, unknown>)[member]\n}\nconst abortedGetter = intrinsic(AbortSignal.prototype, 'aborted', 'get')\nconst addListener = intrinsic(EventTarget.prototype, 'addEventListener', 'value')\nconst removeListener = intrinsic(EventTarget.prototype, 'removeEventListener', 'value')\n\nfunction nativeCall(method: unknown, receiver: object, args: unknown[]): unknown {\n if (typeof method !== 'function') throw new AccountCustodyClientError('invalid-request')\n return Reflect.apply(method, receiver, args)\n}\n\nexport function clientSignalAborted(signal: AbortSignal): boolean {\n const result = nativeCall(abortedGetter, signal, [])\n if (typeof result !== 'boolean') throw new AccountCustodyClientError('invalid-request')\n return result\n}\n\nexport function listenClientSignal(signal: AbortSignal, listener: () => void): void {\n nativeCall(addListener, signal, [\n 'abort',\n listener,\n { once: true },\n ])\n}\n\nexport function removeClientSignal(signal: AbortSignal, listener: () => void): void {\n try {\n nativeCall(removeListener, signal, ['abort', listener])\n } catch {\n // Cleanup cannot leak native diagnostics; actual callback settlement owns capacity.\n }\n}\n", "import type { AccountCustodyClientOptions } from './clientModel.ts'\nimport {\n clientSignalAborted,\n listenClientSignal,\n removeClientSignal,\n} from './clientSignals.ts'\nimport {\n AccountCustodyClientError,\n assertClientOwnerReady,\n type ClientExecution,\n type ClientOwnerState,\n type ClientState,\n stopClientOwner,\n} from './clientState.ts'\nimport type { AccountCustodyOperationControl } from './model.ts'\n\nfunction operationControl(owner: ClientOwnerState, execution: ClientExecution, deadline: number): AccountCustodyOperationControl {\n return Object.freeze({\n signal: execution.controller.signal,\n assertActive() {\n assertClientOwnerReady(owner)\n if (performance.now() >= deadline || execution.controller.signal.aborted || owner.stopped)\n throw new AccountCustodyClientError('uncertain-operation')\n },\n })\n}\n\nasync function perform<Request, Result>(\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n execution: ClientExecution,\n request: Request,\n): Promise<Result> {\n if (client.closed || execution.controller.signal.aborted) throw new AccountCustodyClientError('cancelled-before-operation')\n assertClientOwnerReady(owner)\n execution.hasStarted = true\n const deadline = performance.now() + owner.limits.maxOperationMilliseconds\n const timer = setTimeout(() => execution.controller.abort(), owner.limits.maxOperationMilliseconds)\n try {\n const control = operationControl(owner, execution, deadline)\n const result = structuredClone(await options.createOperation(owner.account, control)(request))\n control.assertActive()\n execution.hasCompleted = true\n return result\n } catch {\n stopClientOwner(owner)\n throw new AccountCustodyClientError('uncertain-operation')\n } finally {\n clearTimeout(timer)\n }\n}\n\nexport async function afterClientQueue<Request, Result>(\n before: Promise<void>,\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n execution: ClientExecution,\n request: Request,\n): Promise<Result> {\n try {\n await before\n return await perform(owner, client, options, execution, request)\n } finally {\n owner.executions.delete(execution)\n client.executions.delete(execution)\n }\n}\n\nexport function observeClientExecution<Result>(owner: ClientOwnerState, execution: ClientExecution, caller?: AbortSignal) {\n const deferred = Promise.withResolvers<Result>()\n const local = execution.controller.signal\n const abort = () => execution.controller.abort()\n const aborted = () => {\n if (execution.hasCompleted) return\n if (execution.hasStarted) stopClientOwner(owner)\n deferred.reject(new AccountCustodyClientError(execution.hasStarted ? 'uncertain-operation' : owner.stopped ? 'stopped' : 'cancelled-before-operation'))\n }\n const cleanup = () => {\n removeClientSignal(local, aborted)\n if (caller !== undefined) removeClientSignal(caller, abort)\n }\n try {\n listenClientSignal(local, aborted)\n if (caller !== undefined) listenClientSignal(caller, abort)\n if (caller !== undefined && clientSignalAborted(caller)) abort()\n } catch {\n cleanup()\n throw new AccountCustodyClientError('invalid-request')\n }\n return {\n result: deferred.promise,\n resolve: deferred.resolve,\n reject: deferred.reject,\n cleanup,\n }\n}\n\nexport async function settleClientExecution<Result>(pending: Promise<Result>, observer: ReturnType<typeof observeClientExecution<Result>>): Promise<void> {\n try {\n observer.resolve(await pending)\n } catch (error) {\n observer.reject(error)\n } finally {\n observer.cleanup()\n }\n}\n", "import type {\n AccountCustodyClientAssurance,\n AccountCustodyClientOwner,\n InRealmAccountCustodyClientOwnerOptions,\n} from './clientModel.ts'\nimport {\n AccountCustodyClientError,\n type ClientOwnerState,\n stopClientOwner,\n} from './clientState.ts'\nimport type { AccountCustodyLimits } from './model.ts'\nimport { reserveInRealmAccount } from './realmRegistry.ts'\n\nexport const scopedClientAssurance: AccountCustodyClientAssurance = Object.freeze({\n profile: 'in-realm-exclusive-scoped-client-v1',\n scope: 'participating instances and module copies in one globalThis realm',\n physicalKeyIsolation: 'unqualified',\n crossHostOwnership: 'unqualified',\n})\nconst owners = new WeakMap<AccountCustodyClientOwner, ClientOwnerState>()\n\nfunction finiteLimits(selected?: AccountCustodyLimits): AccountCustodyLimits {\n const maxQueuedOperations = selected?.maxQueuedOperations ?? 8\n const maxOperationMilliseconds = selected?.maxOperationMilliseconds ?? 30_000\n if (!Number.isSafeInteger(maxQueuedOperations) || maxQueuedOperations < 0 || maxQueuedOperations > 1024\n || !Number.isSafeInteger(maxOperationMilliseconds) || maxOperationMilliseconds <= 0 || maxOperationMilliseconds > 2_147_483_647)\n throw new AccountCustodyClientError('invalid-limits')\n return Object.freeze({ maxQueuedOperations, maxOperationMilliseconds })\n}\n\n/** Resident owner with no restoration/remint. Shares legacy's permanent account reservation. */\nexport function createInRealmAccountCustodyClientOwner(options: InRealmAccountCustodyClientOwnerOptions): AccountCustodyClientOwner {\n const limits = finiteLimits(options.limits)\n const account = options.account\n const address = account.address\n if (!reserveInRealmAccount(address)) throw new AccountCustodyClientError('account-reserved')\n const state: ClientOwnerState = {\n account,\n address,\n limits,\n stopped: options.nativeState !== 'established-live',\n executions: new Set(),\n tail: Promise.resolve(),\n }\n const owner: AccountCustodyClientOwner = Object.freeze({\n address,\n limits,\n assurance: scopedClientAssurance,\n get outstandingOperations() { return state.executions.size },\n get status() { return state.stopped ? 'stopped' : state.executions.size > 0 ? 'running' : 'ready' },\n drain: async () => { await state.tail },\n stop: () => { stopClientOwner(state) },\n })\n owners.set(owner, state)\n return owner\n}\n\nexport function getClientOwnerState(owner: AccountCustodyClientOwner): ClientOwnerState {\n const state = owners.get(owner)\n if (state === undefined) throw new AccountCustodyClientError('unissued-owner')\n return state\n}\n", "import {\n afterClientQueue,\n observeClientExecution,\n settleClientExecution,\n} from './clientExecution.ts'\nimport type { AccountCustodyClient, AccountCustodyClientOptions } from './clientModel.ts'\nimport { getClientOwnerState, scopedClientAssurance } from './clientOwner.ts'\nimport { clientSignalAborted } from './clientSignals.ts'\nimport {\n AccountCustodyClientError,\n assertClientOwnerReady,\n type ClientExecution,\n type ClientOwnerState,\n type ClientState,\n settleClientTail,\n} from './clientState.ts'\nimport type { AccountCustodyExecuteOptions } from './model.ts'\n\nfunction captureSignal(options: AccountCustodyExecuteOptions): AbortSignal | undefined {\n try {\n const signal = options.signal\n if (signal !== undefined) clientSignalAborted(signal)\n return signal\n } catch {\n throw new AccountCustodyClientError('invalid-request')\n }\n}\n\nfunction claimClient(owner: ClientOwnerState): ClientState {\n assertClientOwnerReady(owner)\n if (owner.current !== undefined && !owner.current.closed) throw new AccountCustodyClientError('client-active')\n if (owner.executions.size > 0 || (owner.current?.executions.size ?? 0) > 0) throw new AccountCustodyClientError('client-not-drained')\n const client: ClientState = {\n closed: false,\n executions: new Set(),\n tail: Promise.resolve(),\n }\n owner.current = client\n return client\n}\n\nfunction closeClient(client: ClientState): void {\n client.closed = true\n for (const execution of client.executions) {\n if (!execution.hasStarted) execution.controller.abort()\n }\n}\n\nasync function execute<Request, Result>(\n owner: ClientOwnerState,\n client: ClientState,\n options: AccountCustodyClientOptions<Request, Result>,\n request: Request,\n executeOptions: AccountCustodyExecuteOptions,\n): Promise<Result> {\n if (client.closed) throw new AccountCustodyClientError('stopped')\n assertClientOwnerReady(owner)\n if (owner.executions.size >= owner.limits.maxQueuedOperations + 1) throw new AccountCustodyClientError('capacity-exhausted')\n const signal = captureSignal(executeOptions)\n if (signal !== undefined && clientSignalAborted(signal)) throw new AccountCustodyClientError('cancelled-before-operation')\n let original: Request\n try {\n original = structuredClone(options.snapshot(request))\n } catch {\n throw new AccountCustodyClientError('invalid-request')\n }\n // Snapshot/getters may reenter public lifecycle methods; recheck actual admission.\n if (client.closed || owner.current !== client) throw new AccountCustodyClientError('stopped')\n assertClientOwnerReady(owner)\n if (owner.executions.size >= owner.limits.maxQueuedOperations + 1) throw new AccountCustodyClientError('capacity-exhausted')\n const execution: ClientExecution = {\n controller: new AbortController(),\n hasCompleted: false,\n hasStarted: false,\n }\n const observer = observeClientExecution<Result>(owner, execution, signal)\n owner.executions.add(execution)\n client.executions.add(execution)\n const pending = afterClientQueue(owner.tail, owner, client, options, execution, original)\n owner.tail = client.tail = settleClientTail(pending)\n void settleClientExecution(pending, observer)\n return await observer.result\n}\n\n/** Trusted issuer creates a single fenced client; clean close preserves its resident owner. */\nexport function createAccountCustodyClient<Request, Result>(input: AccountCustodyClientOptions<Request, Result>): AccountCustodyClient<Request, Result> {\n const ownerRef = input.owner\n const owner = getClientOwnerState(ownerRef)\n const bindingRef = input.binding\n const binding = Object.freeze({ address: bindingRef.address, domain: bindingRef.domain })\n if (binding.address !== owner.address || typeof binding.domain !== 'string' || binding.domain.length === 0)\n throw new AccountCustodyClientError('binding-mismatch')\n const options = Object.freeze({\n owner: ownerRef,\n binding,\n snapshot: input.snapshot,\n createOperation: input.createOperation,\n })\n if (typeof options.snapshot !== 'function' || typeof options.createOperation !== 'function') throw new AccountCustodyClientError('invalid-request')\n const client = claimClient(owner)\n return Object.freeze({\n binding,\n assurance: scopedClientAssurance,\n get outstandingOperations() { return client.executions.size },\n get status() { return client.closed || owner.stopped ? 'stopped' : client.executions.size > 0 ? 'running' : 'ready' },\n execute: async (request: Request, executeOptions: AccountCustodyExecuteOptions = {}) => await execute(owner, client, options, request, executeOptions),\n stop: () => { closeClient(client) },\n drain: async () => { await client.tail },\n })\n}\n"],
5
+ "mappings": ";AAGO,IAAM,sBAAN,cAAkC,MAAM;AAAA,EACpC;AAAA,EACA,OAAO;AAAA,EAEhB,YAAY,MAA+B;AACzC,UAAM,oBAAoB,IAAI,EAAE;AAChC,SAAK,OAAO;AAAA,EACd;AACF;;;ACJA,SAAS,gBAA+B;AACtC,QAAM,MAAM,uBAAO,IAAI,6CAA6C;AACpE,QAAM,WAAoB,QAAQ,IAAI,YAAY,GAAG;AACrD,MAAI,aAAa,QAAW;AAC1B,UAAM,eAAe,oBAAI,IAAY;AACrC,UAAMA,YAA0B,OAAO,OAAO;AAAA,MAC5C,SAAS;AAAA,MACT,QAAQC,MAAa,QAAyB;AAC5C,YAAI,aAAa,IAAIA,IAAG,EAAG,QAAO;AAClC,qBAAa,IAAIA,IAAG;AACpB,eAAO;AAAA,MACT;AAAA,IACF,CAAC;AACD,WAAO,eAAe,YAAY,KAAK;AAAA,MACrC,OAAOD;AAAA,MACP,cAAc;AAAA,MACd,UAAU;AAAA,IACZ,CAAC;AACD,WAAOA;AAAA,EACT;AACA,MAAI,OAAO,aAAa,YAAY,aAAa,QAAQ,CAAC,OAAO,SAAS,QAAQ,KAC7E,EAAE,aAAa,aAAa,SAAS,YAAY,KAAK,EAAE,aA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CAAC;AACD,MAAI,OAAO,QAAQ,aAAa,cAAc,OAAO,QAAQ,oBAAoB,WAAY,OAAM,IAAI,0BAA0B,iBAAiB;AAClJ,QAAM,SAAS,YAAY,KAAK;AAChC,SAAO,OAAO,OAAO;AAAA,IACnB;AAAA,IACA,WAAW;AAAA,IACX,IAAI,wBAAwB;AAAE,aAAO,OAAO,WAAW;AAAA,IAAK;AAAA,IAC5D,IAAI,SAAS;AAAE,aAAO,OAAO,UAAU,MAAM,UAAU,YAAY,OAAO,WAAW,OAAO,IAAI,YAAY;AAAA,IAAQ;AAAA,IACpH,SAAS,OAAO,SAAkB,iBAA+C,CAAC,MAAM,MAAM,QAAQ,OAAO,QAAQ,SAAS,SAAS,cAAc;AAAA,IACrJ,MAAM,MAAM;AAAE,kBAAY,MAAM;AAAA,IAAE;AAAA,IAClC,OAAO,YAAY;AAAE,YAAM,OAAO;AAAA,IAAK;AAAA,EACzC,CAAC;AACH;",
6
6
  "names": ["registry", "key", "intrinsic", "nativeCall", "operationControl", "perform", "owners", "finiteLimits", "captureSignal"]
7
7
  }
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/modules/api-location-diviner/LocationDiviner/LocationDivinerApi.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationHeatmapQuery/LocationHeatmapQuery.ts", "../../src/modules/api-location-diviner/LocationDiviner/Witnesses/CurrentLocationWitness.ts", "../../src/modules/api-location-diviner/LocationDiviner/Witnesses/LocationWitness.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationQuadkeyHeatmapQuery/LocationQuadkeyHeatmapQuery.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationQuerySchema.ts", "../../src/modules/api-location-diviner/LocationDiviner/Queries/LocationTimeRangeQuery/LocationTimeRangeQuery.ts", "../../src/modules/api-location-diviner/RemoteDivinerConfig.ts", "../../src/modules/api-location-diviner/RemoteDivinerError.ts"],
4
- "sourcesContent": ["import { assertEx, fetchJsonClient } from '@ariestools/sdk'\n\nimport type { GetLocationQueryResponse } from './models.ts'\nimport type { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries/index.ts'\n\ninterface LocationDivinerApiConfig {\n apiDomain: string\n}\n\ninterface JsonDataEnvelope<T> {\n data?: T\n}\n\nclass LocationDivinerApi {\n config: LocationDivinerApiConfig\n constructor(config: LocationDivinerApiConfig) {\n this.config = config\n }\n\n async getLocationQuery(hash: string): Promise<GetLocationQueryResponse> {\n const response = await fetchJsonClient.get<JsonDataEnvelope<GetLocationQueryResponse>>(`${this.config.apiDomain}/location/query/${hash}`)\n return assertEx(response.data?.data, () => 'LocationDivinerApi.getLocationQuery: missing response data')\n }\n\n async postLocationQuery(request: SupportedLocationQueryCreationRequest): Promise<LocationQueryCreationResponse> {\n const response = await fetchJsonClient.post<JsonDataEnvelope<LocationQueryCreationResponse>>(`${this.config.apiDomain}/location/query`, { ...request })\n return assertEx(response.data?.data, () => 'LocationDivinerApi.postLocationQuery: missing response data')\n }\n}\n\nexport { LocationDivinerApi }\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationHeatmapQuerySchema: 'network.xyo.location.heatmap.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.query', true)\nexport type LocationHeatmapQuerySchema = typeof LocationHeatmapQuerySchema\n\nexport const LocationHeatmapAnswerSchema: 'network.xyo.location.heatmap.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.answer', true)\nexport type LocationHeatmapAnswerSchema = typeof LocationHeatmapAnswerSchema\n\nexport const LocationHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationHeatmapQuery = z.infer<typeof LocationHeatmapQueryZod>\n\nexport const isLocationHeatmapQuery: ReturnType<typeof zodIsFactory<LocationHeatmapQuery>> = zodIsFactory(LocationHeatmapQueryZod)\nexport const asLocationHeatmapQuery: ReturnType<typeof zodAsFactory<LocationHeatmapQuery>> = zodAsFactory(LocationHeatmapQueryZod, 'asLocationHeatmapQuery')\nexport const toLocationHeatmapQuery: ReturnType<typeof zodToFactory<LocationHeatmapQuery>> = zodToFactory(LocationHeatmapQueryZod, 'toLocationHeatmapQuery')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const CurrentLocationWitnessSchema: 'co.coinapp.currentlocationwitness' & {\n readonly __schema: true\n} = asSchema('co.coinapp.currentlocationwitness', true)\nexport type CurrentLocationWitnessSchema = typeof CurrentLocationWitnessSchema\n\nexport const CurrentLocationWitnessPayloadZod: z.ZodMiniObject<{\n altitudeMeters: z.ZodMiniNumber<number>\n directionDegrees: z.ZodMiniNumber<number>\n latitude: z.ZodMiniNumber<number>\n longitude: z.ZodMiniNumber<number>\n quadkey: z.ZodMiniString<string>\n schema: z.ZodMiniLiteral<CurrentLocationWitnessSchema>\n speedKph: z.ZodMiniNumber<number>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(CurrentLocationWitnessSchema), {\n altitudeMeters: z.number(),\n directionDegrees: z.number(),\n latitude: z.number(),\n longitude: z.number(),\n quadkey: z.string(),\n speedKph: z.number(),\n})\n\nexport type CurrentLocationWitnessPayload = z.infer<typeof CurrentLocationWitnessPayloadZod>\n\nexport const isCurrentLocationWitnessPayload: ReturnType<typeof zodIsFactory<CurrentLocationWitnessPayload>>\n = zodIsFactory(CurrentLocationWitnessPayloadZod)\nexport const asCurrentLocationWitnessPayload: ReturnType<typeof zodAsFactory<CurrentLocationWitnessPayload>>\n = zodAsFactory(CurrentLocationWitnessPayloadZod, 'asCurrentLocationWitnessPayload')\nexport const toCurrentLocationWitnessPayload: ReturnType<typeof zodToFactory<CurrentLocationWitnessPayload>>\n = zodToFactory(CurrentLocationWitnessPayloadZod, 'toCurrentLocationWitnessPayload')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const LocationWitnessSchema: 'network.xyo.location' & {\n readonly __schema: true\n} = asSchema('network.xyo.location', true)\nexport type LocationWitnessSchema = typeof LocationWitnessSchema\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport const LocationWitnessPayloadZod: z.ZodMiniObject<{\n currentLocation: z.ZodMiniCustom<CurrentLocation, CurrentLocation>\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(LocationWitnessSchema), { currentLocation: z.custom<CurrentLocation>() })\n\nexport type LocationWitnessPayload = z.infer<typeof LocationWitnessPayloadZod>\n\nexport const isLocationWitnessPayload: ReturnType<typeof zodIsFactory<LocationWitnessPayload>> = zodIsFactory(LocationWitnessPayloadZod)\nexport const asLocationWitnessPayload: ReturnType<typeof zodAsFactory<LocationWitnessPayload>> = zodAsFactory(LocationWitnessPayloadZod, 'asLocationWitnessPayload')\nexport const toLocationWitnessPayload: ReturnType<typeof zodToFactory<LocationWitnessPayload>> = zodToFactory(LocationWitnessPayloadZod, 'toLocationWitnessPayload')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationQuadkeyHeatmapQuerySchema: 'network.xyo.location.heatmap.quadkey.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.query', true)\nexport type LocationQuadkeyHeatmapQuerySchema = typeof LocationQuadkeyHeatmapQuerySchema\n\nexport const LocationQuadkeyHeatmapAnswerSchema: 'network.xyo.location.heatmap.quadkey.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.answer', true)\nexport type LocationQuadkeyHeatmapAnswerSchema = typeof LocationQuadkeyHeatmapAnswerSchema\n\nexport const LocationQuadkeyHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationQuadkeyHeatmapQuery = z.infer<typeof LocationQuadkeyHeatmapQueryZod>\n\nexport const isLocationQuadkeyHeatmapQuery: ReturnType<typeof zodIsFactory<LocationQuadkeyHeatmapQuery>>\n = zodIsFactory(LocationQuadkeyHeatmapQueryZod)\nexport const asLocationQuadkeyHeatmapQuery: ReturnType<typeof zodAsFactory<LocationQuadkeyHeatmapQuery>>\n = zodAsFactory(LocationQuadkeyHeatmapQueryZod, 'asLocationQuadkeyHeatmapQuery')\nexport const toLocationQuadkeyHeatmapQuery: ReturnType<typeof zodToFactory<LocationQuadkeyHeatmapQuery>>\n = zodToFactory(LocationQuadkeyHeatmapQueryZod, 'toLocationQuadkeyHeatmapQuery')\n", "import type { Schema } from '@xyo-network/sdk-protocol'\n\nimport type { LocationHeatmapQuerySchema } from './LocationHeatmapQuery/index.ts'\nimport type { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.ts'\nimport type { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.ts'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<string, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: Schema): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema]\n}\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationTimeRangeQuerySchema: 'network.xyo.location.range.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.query', true)\nexport type LocationTimeRangeQuerySchema = typeof LocationTimeRangeQuerySchema\n\nexport const LocationTimeRangeAnswerSchema: 'network.xyo.location.range.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.answer', true)\nexport type LocationTimeRangeAnswerSchema = typeof LocationTimeRangeAnswerSchema\n\nexport const LocationTimeRangeQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n // TODO: Bounding rectangle, etc.\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationTimeRangeQuery = z.infer<typeof LocationTimeRangeQueryZod>\n\nexport const isLocationTimeRangeQuery: ReturnType<typeof zodIsFactory<LocationTimeRangeQuery>> = zodIsFactory(LocationTimeRangeQueryZod)\nexport const asLocationTimeRangeQuery: ReturnType<typeof zodAsFactory<LocationTimeRangeQuery>> = zodAsFactory(LocationTimeRangeQueryZod, 'asLocationTimeRangeQuery')\nexport const toLocationTimeRangeQuery: ReturnType<typeof zodToFactory<LocationTimeRangeQuery>> = zodToFactory(LocationTimeRangeQueryZod, 'toLocationTimeRangeQuery')\n", "import {\n zodAsFactory, zodIsFactory, zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { DivinerConfigZod } from '#diviner-model'\n\nexport const RemoteDivinerConfigSchema: 'network.xyo.diviner.remote.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.remote.config', true)\nexport type RemoteDivinerConfigSchema = typeof RemoteDivinerConfigSchema\n\nexport const RemoteDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n archive: z.ZodMiniOptional<z.ZodMiniString<string>>\n schema: z.ZodMiniLiteral<RemoteDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n archive: z.optional(z.string()),\n schema: z.literal(RemoteDivinerConfigSchema),\n})\n\nexport type RemoteDivinerConfig = z.infer<typeof RemoteDivinerConfigZod>\n\nexport const isRemoteDivinerConfig: ReturnType<typeof zodIsFactory<RemoteDivinerConfig>> = zodIsFactory(RemoteDivinerConfigZod)\nexport const asRemoteDivinerConfig: ReturnType<typeof zodAsFactory<RemoteDivinerConfig>> = zodAsFactory(RemoteDivinerConfigZod, 'asRemoteDivinerConfig')\nexport const toRemoteDivinerConfig: ReturnType<typeof zodToFactory<RemoteDivinerConfig>> = zodToFactory(RemoteDivinerConfigZod, 'toRemoteDivinerConfig')\n", "import { isString } from '@ariestools/sdk'\n\nexport class RemoteDivinerError extends Error {\n isRemoteDivinerError = true\n constructor(action: string, error: Error['cause'], message?: string) {\n const messageString = isString(message) ? ` (${message})` : ''\n super(`Remote Diviner [${action}] failed${messageString}`, { cause: error })\n }\n\n static isRemoteDivinerError(error: unknown): RemoteDivinerError | undefined {\n return (error as Rem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WAAW,aAAa,IAAI,EAAE,OAAO,MAAM,CAAC;AAAA,EAC7E;AAAA,EAEA,OAAO,qBAAqB,OAAgD;AAC1E,WAAQ,MAA6B,uBAAwB,QAA+B;AAAA,EAC9F;AACF;",
4
+ "sourcesContent": ["import { assertEx, fetchJsonClient } from '@ariestools/sdk'\n\nimport type { GetLocationQueryResponse } from './models.ts'\nimport type { LocationQueryCreationResponse, SupportedLocationQueryCreationRequest } from './Queries/index.ts'\n\ninterface LocationDivinerApiConfig {\n apiDomain: string\n}\n\ninterface JsonDataEnvelope<T> {\n data?: T\n}\n\nclass LocationDivinerApi {\n config: LocationDivinerApiConfig\n constructor(config: LocationDivinerApiConfig) {\n this.config = config\n }\n\n async getLocationQuery(hash: string): Promise<GetLocationQueryResponse> {\n const response = await fetchJsonClient.get<JsonDataEnvelope<GetLocationQueryResponse>>(`${this.config.apiDomain}/location/query/${hash}`)\n return assertEx(response.data?.data, () => 'LocationDivinerApi.getLocationQuery: missing response data')\n }\n\n async postLocationQuery(request: SupportedLocationQueryCreationRequest): Promise<LocationQueryCreationResponse> {\n const response = await fetchJsonClient.post<JsonDataEnvelope<LocationQueryCreationResponse>>(`${this.config.apiDomain}/location/query`, { ...request })\n return assertEx(response.data?.data, () => 'LocationDivinerApi.postLocationQuery: missing response data')\n }\n}\n\nexport { LocationDivinerApi }\n", "import {\n zodAsFactory,\n zodIsFactory,\n zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationHeatmapQuerySchema: 'network.xyo.location.heatmap.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.query', true)\nexport type LocationHeatmapQuerySchema = typeof LocationHeatmapQuerySchema\n\nexport const LocationHeatmapAnswerSchema: 'network.xyo.location.heatmap.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.answer', true)\nexport type LocationHeatmapAnswerSchema = typeof LocationHeatmapAnswerSchema\n\nexport const LocationHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationHeatmapQuery = z.infer<typeof LocationHeatmapQueryZod>\n\nexport const isLocationHeatmapQuery: ReturnType<typeof zodIsFactory<LocationHeatmapQuery>> = zodIsFactory(LocationHeatmapQueryZod)\nexport const asLocationHeatmapQuery: ReturnType<typeof zodAsFactory<LocationHeatmapQuery>> = zodAsFactory(LocationHeatmapQueryZod, 'asLocationHeatmapQuery')\nexport const toLocationHeatmapQuery: ReturnType<typeof zodToFactory<LocationHeatmapQuery>> = zodToFactory(LocationHeatmapQueryZod, 'toLocationHeatmapQuery')\n", "import {\n zodAsFactory,\n zodIsFactory,\n zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const CurrentLocationWitnessSchema: 'co.coinapp.currentlocationwitness' & {\n readonly __schema: true\n} = asSchema('co.coinapp.currentlocationwitness', true)\nexport type CurrentLocationWitnessSchema = typeof CurrentLocationWitnessSchema\n\nexport const CurrentLocationWitnessPayloadZod: z.ZodMiniObject<{\n altitudeMeters: z.ZodMiniNumber<number>\n directionDegrees: z.ZodMiniNumber<number>\n latitude: z.ZodMiniNumber<number>\n longitude: z.ZodMiniNumber<number>\n quadkey: z.ZodMiniString<string>\n schema: z.ZodMiniLiteral<CurrentLocationWitnessSchema>\n speedKph: z.ZodMiniNumber<number>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(CurrentLocationWitnessSchema), {\n altitudeMeters: z.number(),\n directionDegrees: z.number(),\n latitude: z.number(),\n longitude: z.number(),\n quadkey: z.string(),\n speedKph: z.number(),\n})\n\nexport type CurrentLocationWitnessPayload = z.infer<typeof CurrentLocationWitnessPayloadZod>\n\nexport const isCurrentLocationWitnessPayload: ReturnType<typeof zodIsFactory<CurrentLocationWitnessPayload>>\n = zodIsFactory(CurrentLocationWitnessPayloadZod)\nexport const asCurrentLocationWitnessPayload: ReturnType<typeof zodAsFactory<CurrentLocationWitnessPayload>>\n = zodAsFactory(CurrentLocationWitnessPayloadZod, 'asCurrentLocationWitnessPayload')\nexport const toCurrentLocationWitnessPayload: ReturnType<typeof zodToFactory<CurrentLocationWitnessPayload>>\n = zodToFactory(CurrentLocationWitnessPayloadZod, 'toCurrentLocationWitnessPayload')\n", "import {\n zodAsFactory,\n zodIsFactory,\n zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema, PayloadZodOfSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nexport const LocationWitnessSchema: 'network.xyo.location' & {\n readonly __schema: true\n} = asSchema('network.xyo.location', true)\nexport type LocationWitnessSchema = typeof LocationWitnessSchema\n\nexport interface Coordinates {\n accuracy: number | null\n altitude: number | null\n altitudeAccuracy: number | null\n heading: number | null\n latitude: number\n longitude: number\n speed: number | null\n}\nexport interface CurrentLocation {\n coords: Coordinates\n timestamp: number\n}\n\nexport const LocationWitnessPayloadZod: z.ZodMiniObject<{\n currentLocation: z.ZodMiniCustom<CurrentLocation, CurrentLocation>\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n}, z.core.$strip> = z.extend(PayloadZodOfSchema(LocationWitnessSchema), { currentLocation: z.custom<CurrentLocation>() })\n\nexport type LocationWitnessPayload = z.infer<typeof LocationWitnessPayloadZod>\n\nexport const isLocationWitnessPayload: ReturnType<typeof zodIsFactory<LocationWitnessPayload>> = zodIsFactory(LocationWitnessPayloadZod)\nexport const asLocationWitnessPayload: ReturnType<typeof zodAsFactory<LocationWitnessPayload>> = zodAsFactory(LocationWitnessPayloadZod, 'asLocationWitnessPayload')\nexport const toLocationWitnessPayload: ReturnType<typeof zodToFactory<LocationWitnessPayload>> = zodToFactory(LocationWitnessPayloadZod, 'toLocationWitnessPayload')\n", "import {\n zodAsFactory,\n zodIsFactory,\n zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationQuadkeyHeatmapQuerySchema: 'network.xyo.location.heatmap.quadkey.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.query', true)\nexport type LocationQuadkeyHeatmapQuerySchema = typeof LocationQuadkeyHeatmapQuerySchema\n\nexport const LocationQuadkeyHeatmapAnswerSchema: 'network.xyo.location.heatmap.quadkey.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.heatmap.quadkey.answer', true)\nexport type LocationQuadkeyHeatmapAnswerSchema = typeof LocationQuadkeyHeatmapAnswerSchema\n\nexport const LocationQuadkeyHeatmapQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationQuadkeyHeatmapQuery = z.infer<typeof LocationQuadkeyHeatmapQueryZod>\n\nexport const isLocationQuadkeyHeatmapQuery: ReturnType<typeof zodIsFactory<LocationQuadkeyHeatmapQuery>>\n = zodIsFactory(LocationQuadkeyHeatmapQueryZod)\nexport const asLocationQuadkeyHeatmapQuery: ReturnType<typeof zodAsFactory<LocationQuadkeyHeatmapQuery>>\n = zodAsFactory(LocationQuadkeyHeatmapQueryZod, 'asLocationQuadkeyHeatmapQuery')\nexport const toLocationQuadkeyHeatmapQuery: ReturnType<typeof zodToFactory<LocationQuadkeyHeatmapQuery>>\n = zodToFactory(LocationQuadkeyHeatmapQueryZod, 'toLocationQuadkeyHeatmapQuery')\n", "import type { Schema } from '@xyo-network/sdk-protocol'\n\nimport type { LocationHeatmapQuerySchema } from './LocationHeatmapQuery/index.ts'\nimport type { LocationQuadkeyHeatmapQuerySchema } from './LocationQuadkeyHeatmapQuery/index.ts'\nimport type { LocationTimeRangeQuerySchema } from './LocationTimeRangeQuery/index.ts'\n\nexport type LocationQuerySchema = LocationQuadkeyHeatmapQuerySchema | LocationHeatmapQuerySchema | LocationTimeRangeQuerySchema\n\nconst locationQuerySchemas: Record<string, true> = {\n 'network.xyo.location.heatmap.quadkey.query': true,\n 'network.xyo.location.heatmap.query': true,\n 'network.xyo.location.range.query': true,\n}\n\nexport const isSupportedLocationQuerySchema = (schema: Schema): schema is LocationQuerySchema => {\n return locationQuerySchemas[schema as LocationQuerySchema]\n}\n", "import {\n zodAsFactory,\n zodIsFactory,\n zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { LocationWitnessSchema } from '../../Witnesses/index.ts'\n\nexport const LocationTimeRangeQuerySchema: 'network.xyo.location.range.query' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.query', true)\nexport type LocationTimeRangeQuerySchema = typeof LocationTimeRangeQuerySchema\n\nexport const LocationTimeRangeAnswerSchema: 'network.xyo.location.range.answer' & {\n readonly __schema: true\n} = asSchema('network.xyo.location.range.answer', true)\nexport type LocationTimeRangeAnswerSchema = typeof LocationTimeRangeAnswerSchema\n\nexport const LocationTimeRangeQueryZod: z.ZodMiniObject<{\n schema: z.ZodMiniLiteral<LocationWitnessSchema>\n startTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n stopTime: z.ZodMiniOptional<z.ZodMiniString<string>>\n}, z.core.$strip> = z.object({\n schema: z.literal(LocationWitnessSchema),\n startTime: z.optional(z.string()),\n // TODO: Bounding rectangle, etc.\n stopTime: z.optional(z.string()),\n})\n\nexport type LocationTimeRangeQuery = z.infer<typeof LocationTimeRangeQueryZod>\n\nexport const isLocationTimeRangeQuery: ReturnType<typeof zodIsFactory<LocationTimeRangeQuery>> = zodIsFactory(LocationTimeRangeQueryZod)\nexport const asLocationTimeRangeQuery: ReturnType<typeof zodAsFactory<LocationTimeRangeQuery>> = zodAsFactory(LocationTimeRangeQueryZod, 'asLocationTimeRangeQuery')\nexport const toLocationTimeRangeQuery: ReturnType<typeof zodToFactory<LocationTimeRangeQuery>> = zodToFactory(LocationTimeRangeQueryZod, 'toLocationTimeRangeQuery')\n", "import {\n zodAsFactory,\n zodIsFactory,\n zodToFactory,\n} from '@ariestools/sdk'\nimport { asSchema } from '@xyo-network/sdk-protocol'\nimport * as z from 'zod/mini'\n\nimport { DivinerConfigZod } from '#diviner-model'\n\nexport const RemoteDivinerConfigSchema: 'network.xyo.diviner.remote.config' & {\n readonly __schema: true\n} = asSchema('network.xyo.diviner.remote.config', true)\nexport type RemoteDivinerConfigSchema = typeof RemoteDivinerConfigSchema\n\nexport const RemoteDivinerConfigZod: z.ZodMiniObject<\n Omit<(typeof DivinerConfigZod)['shape'], 'schema'> & {\n archive: z.ZodMiniOptional<z.ZodMiniString<string>>\n schema: z.ZodMiniLiteral<RemoteDivinerConfigSchema>\n },\n z.core.$strip\n> = z.extend(DivinerConfigZod, {\n archive: z.optional(z.string()),\n schema: z.literal(RemoteDivinerConfigSchema),\n})\n\nexport type RemoteDivinerConfig = z.infer<typeof RemoteDivinerConfigZod>\n\nexport const isRemoteDivinerConfig: ReturnType<typeof zodIsFactory<RemoteDivinerConfig>> = zodIsFactory(RemoteDivinerConfigZod)\nexport const asRemoteDivinerConfig: ReturnType<typeof zodAsFactory<RemoteDivinerConfig>> = zodAsFactory(RemoteDivinerConfigZod, 'asRemoteDivinerConfig')\nexport const toRemoteDivinerConfig: ReturnType<typeof zodToFactory<RemoteDivinerConfig>> = zodToFactory(RemoteDivinerConfigZod, 'toRemoteDivinerConfig')\n", "import { isString } from '@ariestools/sdk'\n\nexport class RemoteDivinerError extends Error {\n isRemoteDivinerError = true\n constructor(action: string, error: Error['cause'], message?: string) {\n const messageString = isString(message) ? ` (${message})` : ''\n super(`Remote Diviner [${action}] failed${messageString}`, { cause: error })\n }\n\n static isRemoteDivinerError(error: unknown): RemoteDivinerError | undefined {\n return (error as RemoteDivinerError).isRemoteDivinerError ? (error as RemoteDivinerError) : undefined\n }\n}\n"],
5
+ "mappings": ";AAAA,SAAS,UAAU,uBAAuB;AAa1C,IAAM,qBAAN,MAAyB;AAAA,EACvB;AAAA,EACA,YAAY,QAAkC;AAC5C,SAAK,SAAS;AAAA,EAChB;AAAA,EAEA,MAAM,iBAAiB,MAAiD;AACtE,UAAM,WAAW,MAAM,gBAAgB,IAAgD,GAAG,KAAK,OAAO,SAAS,mBAAmB,IAAI,EAAE;AACxI,WAAO,SAAS,SAAS,MAAM,MAAM,MAAM,4DAA4D;AAAA,EACzG;AAAA,EAEA,MAAM,kBAAkB,SAAwF;AAC9G,UAAM,WAAW,MAAM,gBAAgB,KAAsD,GAAG,KAAK,OAAO,SAAS,mBAAmB,EAAE,GAAG,QAAQ,CAAC;AACtJ,WAAO,SAAS,SAAS,MAAM,MAAM,MAAM,6DAA6D;AAAA,EAC1G;AACF;;;AC5BA;AAAA,EACE,gBAAAA;AAAA,EACA,gBAAAC;AAAA,EACA,gBAAAC;AAAA,OACK;AACP,SAAS,YAAAC,iBAAgB;AACzB,YAAYC,QAAO;;;ACNnB;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU,0BAA0B;AAC7C,YAAY,OAAO;AAEZ,IAAM,+BAET,SAAS,qCAAqC,IAAI;AAG/C,IAAM,mCAQS,SAAO,mBAAmB,4BAA4B,GAAG;AAAA,EAC7E,gBAAkB,SAAO;AAAA,EACzB,kBAAoB,SAAO;AAAA,EAC3B,UAAY,SAAO;AAAA,EACnB,WAAa,SAAO;AAAA,EACpB,SAAW,SAAO;AAAA,EAClB,UAAY,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B;AAElB,IAAM,qBAAN,cAAiC,MAAM;AAAA,EAC5C,uBAAuB;AAAA,EACvB,YAAY,QAAgB,OAAuB,SAAkB;AACnE,UAAM,gBAAgB,SAAS,OAAO,IAAI,KAAK,OAAO,MAAM;AAC5D,UAAM,mBAAmB,MAAM,WAAW,aAAa,IAAI,EAAE,OAAO,MAAM,CAAC;AAAA,EAC7E;AAAA,EAEA,OAAO,qBAAqB,OAAgD;AAC1E,WAAQ,MAA6B,uBAAwB,QAA+B;AAAA,EAC9F;AACF;",
6
6
  "names": ["zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "PayloadZodOfSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z", "asSchema", "zodIsFactory", "zodAsFactory", "zodToFactory", "zodAsFactory", "zodIsFactory", "zodToFactory", "asSchema", "z"]
7
7
  }
@@ -24,6 +24,46 @@ import {
24
24
  import { AbstractModuleInstance } from "#module-abstract";
25
25
  import { duplicateModules } from "#module-model";
26
26
 
27
+ // src/modules/archivist-abstract/InsertSequencer.ts
28
+ import { SequenceConstants, SequenceParser } from "@xyo-network/sdk-protocol";
29
+ import { Mutex } from "async-mutex";
30
+ var INDEXES_PER_EPOCH = 2 ** (SequenceConstants.nonceIndexBytes * 8);
31
+ var InsertSequencer = class {
32
+ epoch = 0;
33
+ index = 0;
34
+ mutex = new Mutex();
35
+ /** Sequence a batch in input order and write it before the next batch is sequenced. */
36
+ async write(payloads, write) {
37
+ return await this.mutex.runExclusive(async () => await write(this.sequence(payloads)));
38
+ }
39
+ /**
40
+ * Reserve consecutive slots that sort after every slot reserved before. The
41
+ * epoch is the wall clock. Within one millisecond, or while the clock is
42
+ * behind the last epoch used, the nonce index keeps counting instead of
43
+ * restarting, so the hash tail never decides the order of two inserts.
44
+ */
45
+ reserve(count) {
46
+ const now = Date.now();
47
+ if (now > this.epoch) {
48
+ this.epoch = now;
49
+ this.index = 0;
50
+ } else if (this.index + count > INDEXES_PER_EPOCH) {
51
+ this.epoch += 1;
52
+ this.index = 0;
53
+ }
54
+ const index = this.index;
55
+ this.index += count;
56
+ return { epoch: this.epoch, index };
57
+ }
58
+ sequence(payloads) {
59
+ const { epoch, index } = this.reserve(payloads.length);
60
+ return payloads.map((payload, offset) => ({
61
+ ...payload,
62
+ _sequence: SequenceParser.from(epoch, payload._hash, index + offset).localSequence
63
+ }));
64
+ }
65
+ };
66
+
27
67
  // src/modules/archivist-abstract/StorageClassLabel.ts
28
68
  var StorageClassLabel = "network.xyo.storage.class";
29
69
 
@@ -36,6 +76,7 @@ var AbstractArchivist = class _AbstractArchivist extends AbstractModuleInstance
36
76
  // override this if a specialized archivist should have a different default next limit
37
77
  static defaultNextLimitSetting = 100;
38
78
  _getCache;
79
+ _insertSequencer = new InsertSequencer();
39
80
  _parentArchivists;
40
81
  _payloadCountGauge;
41
82
  _payloadCountMeter;
@@ -227,6 +268,7 @@ var AbstractArchivist = class _AbstractArchivist extends AbstractModuleInstance
227
268
  }
228
269
  }, { timeBudgetLimit: this.timeBudget });
229
270
  }
271
+ // eslint-disable-next-line unicorn/prefer-options-parameter -- stable query API: optional query options precede the positional account signer
230
272
  async nextQuery(options, account) {
231
273
  this._noOverride("nextQuery");
232
274
  const queryPayload = { schema: ArchivistNextQuerySchema, ...options };
@@ -346,7 +388,11 @@ var AbstractArchivist = class _AbstractArchivist extends AbstractModuleInstance
346
388
  for (const payload of [...fromGet, ...parentFoundPayloads]) cache?.set(payload._hash, payload);
347
389
  }
348
390
  return PayloadBuilder.omitPrivateStorageMeta(
349
- [...fromCache, ...fromGet, ...parentFoundPayloads].toSorted(PayloadBuilder.compareStorageMeta)
391
+ [
392
+ ...fromCache,
393
+ ...fromGet,
394
+ ...parentFoundPayloads
395
+ ].toSorted(PayloadBuilder.compareStorageMeta)
350
396
  );
351
397
  }
352
398
  insertHandler(_payloads) {
@@ -370,18 +416,20 @@ var AbstractArchivist = class _AbstractArchivist extends AbstractModuleInstance
370
416
  const emitEvents = config?.emitEvents ?? true;
371
417
  const writeToParents = config?.writeToParents ?? true;
372
418
  await this.validateInsertPayloads(sanitizedPayloads);
373
- const withStorageMeta = await PayloadBuilder.addStorageMeta(sanitizedPayloads);
374
- const hashes = [...new Set(withStorageMeta.map((payload) => payload._hash))];
375
- const { existingPayloads, insertedPayloads } = await this.withStorageMutation(async () => {
376
- const existingPayloads2 = await this.getExistingLocalPayloads(hashes);
377
- await this.repairExistingPayloads(existingPayloads2);
378
- const existingHashes = new Set(existingPayloads2.map((payload) => payload._hash));
379
- const payloadsToInsert = withStorageMeta.filter((payload) => {
380
- if (existingHashes.has(payload._hash)) return false;
381
- existingHashes.add(payload._hash);
382
- return true;
419
+ const withHashMeta = await PayloadBuilder.addHashMeta(sanitizedPayloads);
420
+ const hashes = [...new Set(withHashMeta.map((payload) => payload._hash))];
421
+ const { existingPayloads, insertedPayloads } = await this._insertSequencer.write(withHashMeta, async (withStorageMeta) => {
422
+ return await this.withStorageMutation(async () => {
423
+ const existingPayloads2 = await this.getExistingLocalPayloads(hashes);
424
+ await this.repairExistingPayloads(existingPayloads2);
425
+ const existingHashes = new Set(existingPayloads2.map((payload) => payload._hash));
426
+ const payloadsToInsert = withStorageMeta.filter((payload) => {
427
+ if (existingHashes.has(payload._hash)) return false;
428
+ existingHashes.add(payload._hash);
429
+ return true;
430
+ });
431
+ return { existingPayloads: existingPayloads2, insertedPayloads: await this.insertHandler(payloadsToInsert) };
383
432
  });
384
- return { existingPayloads: existingPayloads2, insertedPayloads: await this.insertHandler(payloadsToInsert) };
385
433
  });
386
434
  if (writeToParents) {
387
435
  await this.writeToParents([...existingPayloads, ...insertedPayloads]);
@@ -401,6 +449,7 @@ var AbstractArchivist = class _AbstractArchivist extends AbstractModuleInstance
401
449
  nextHandler(_options) {
402
450
  throw new Error(NOT_IMPLEMENTED);
403
451
  }
452
+ // eslint-disable-next-line unicorn/prefer-options-parameter -- archivist override point: distinct next-options and insert-config bags
404
453
  async nextWithConfig(options, _config) {
405
454
  const foundPayloads = await this.nextHandler(options);
406
455
  return PayloadBuilder.omitPrivateStorageMeta(foundPayloads);