@oobe-protocol-labs/synapse-client-sdk 1.2.0 → 1.2.2

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 (624) hide show
  1. package/CHANGELOG.md +117 -0
  2. package/dist/cjs/ai/gateway/index.d.ts +86 -5
  3. package/dist/cjs/ai/gateway/index.d.ts.map +1 -1
  4. package/dist/cjs/ai/gateway/index.js +278 -40
  5. package/dist/cjs/ai/gateway/index.js.map +1 -1
  6. package/dist/cjs/ai/gateway/registry.d.ts +223 -0
  7. package/dist/cjs/ai/gateway/registry.d.ts.map +1 -0
  8. package/dist/cjs/ai/gateway/registry.js +290 -0
  9. package/dist/cjs/ai/gateway/registry.js.map +1 -0
  10. package/dist/cjs/ai/gateway/types.d.ts +107 -1
  11. package/dist/cjs/ai/gateway/types.d.ts.map +1 -1
  12. package/dist/cjs/ai/gateway/x402/index.d.ts +2 -4
  13. package/dist/cjs/ai/gateway/x402/index.d.ts.map +1 -1
  14. package/dist/cjs/ai/gateway/x402/index.js +2 -1
  15. package/dist/cjs/ai/gateway/x402/index.js.map +1 -1
  16. package/dist/cjs/ai/gateway/x402/registry.d.ts +131 -1
  17. package/dist/cjs/ai/gateway/x402/registry.d.ts.map +1 -1
  18. package/dist/cjs/ai/gateway/x402/registry.js +229 -1
  19. package/dist/cjs/ai/gateway/x402/registry.js.map +1 -1
  20. package/dist/cjs/ai/index.d.ts +2 -1
  21. package/dist/cjs/ai/index.d.ts.map +1 -1
  22. package/dist/cjs/ai/index.js +21 -2
  23. package/dist/cjs/ai/index.js.map +1 -1
  24. package/dist/cjs/ai/persistence/helpers.d.ts +83 -0
  25. package/dist/cjs/ai/persistence/helpers.d.ts.map +1 -0
  26. package/dist/cjs/ai/persistence/helpers.js +193 -0
  27. package/dist/cjs/ai/persistence/helpers.js.map +1 -0
  28. package/dist/cjs/ai/persistence/index.d.ts +91 -0
  29. package/dist/cjs/ai/persistence/index.d.ts.map +1 -0
  30. package/dist/cjs/ai/persistence/index.js +109 -0
  31. package/dist/cjs/ai/persistence/index.js.map +1 -0
  32. package/dist/cjs/ai/persistence/memory.d.ts +71 -0
  33. package/dist/cjs/ai/persistence/memory.d.ts.map +1 -0
  34. package/dist/cjs/ai/persistence/memory.js +192 -0
  35. package/dist/cjs/ai/persistence/memory.js.map +1 -0
  36. package/dist/cjs/ai/persistence/postgresql.d.ts +119 -0
  37. package/dist/cjs/ai/persistence/postgresql.d.ts.map +1 -0
  38. package/dist/cjs/ai/persistence/postgresql.js +310 -0
  39. package/dist/cjs/ai/persistence/postgresql.js.map +1 -0
  40. package/dist/cjs/ai/persistence/redis.d.ts +84 -0
  41. package/dist/cjs/ai/persistence/redis.d.ts.map +1 -0
  42. package/dist/cjs/ai/persistence/redis.js +241 -0
  43. package/dist/cjs/ai/persistence/redis.js.map +1 -0
  44. package/dist/cjs/ai/persistence/types.d.ts +267 -0
  45. package/dist/cjs/ai/persistence/types.d.ts.map +1 -0
  46. package/dist/cjs/ai/persistence/types.js +40 -0
  47. package/dist/cjs/ai/persistence/types.js.map +1 -0
  48. package/dist/cjs/ai/tools/protocols/metaplex/tools.d.ts.map +1 -1
  49. package/dist/cjs/ai/tools/protocols/metaplex/tools.js +13 -19
  50. package/dist/cjs/ai/tools/protocols/metaplex/tools.js.map +1 -1
  51. package/dist/cjs/core/client.d.ts +16 -0
  52. package/dist/cjs/core/client.d.ts.map +1 -1
  53. package/dist/cjs/core/client.js +18 -0
  54. package/dist/cjs/core/client.js.map +1 -1
  55. package/dist/cjs/core/transport.d.ts +1 -1
  56. package/dist/cjs/core/transport.d.ts.map +1 -1
  57. package/dist/cjs/core/transport.js.map +1 -1
  58. package/dist/cjs/core/types.d.ts +5 -1
  59. package/dist/cjs/core/types.d.ts.map +1 -1
  60. package/dist/cjs/das/methods/get-asset-batch.js +1 -1
  61. package/dist/cjs/das/methods/get-asset-batch.js.map +1 -1
  62. package/dist/cjs/das/methods/get-asset-proof-batch.js +1 -1
  63. package/dist/cjs/das/methods/get-asset-proof-batch.js.map +1 -1
  64. package/dist/cjs/das/methods/get-asset-proof.js +1 -1
  65. package/dist/cjs/das/methods/get-asset-proof.js.map +1 -1
  66. package/dist/cjs/das/methods/get-asset.js +1 -1
  67. package/dist/cjs/das/methods/get-asset.js.map +1 -1
  68. package/dist/cjs/das/methods/get-assets-by-authority.js +1 -1
  69. package/dist/cjs/das/methods/get-assets-by-authority.js.map +1 -1
  70. package/dist/cjs/das/methods/get-assets-by-creator.js +1 -1
  71. package/dist/cjs/das/methods/get-assets-by-creator.js.map +1 -1
  72. package/dist/cjs/das/methods/get-assets-by-group.js +1 -1
  73. package/dist/cjs/das/methods/get-assets-by-group.js.map +1 -1
  74. package/dist/cjs/das/methods/get-assets-by-owner.js +1 -1
  75. package/dist/cjs/das/methods/get-assets-by-owner.js.map +1 -1
  76. package/dist/cjs/das/methods/get-signatures-for-asset.js +1 -1
  77. package/dist/cjs/das/methods/get-signatures-for-asset.js.map +1 -1
  78. package/dist/cjs/das/methods/get-token-accounts.js +1 -1
  79. package/dist/cjs/das/methods/get-token-accounts.js.map +1 -1
  80. package/dist/cjs/das/methods/search-assets.js +1 -1
  81. package/dist/cjs/das/methods/search-assets.js.map +1 -1
  82. package/dist/cjs/next/index.d.ts +141 -0
  83. package/dist/cjs/next/index.d.ts.map +1 -0
  84. package/dist/cjs/next/index.js +177 -0
  85. package/dist/cjs/next/index.js.map +1 -0
  86. package/dist/cjs/utils/helpers.d.ts +79 -1
  87. package/dist/cjs/utils/helpers.d.ts.map +1 -1
  88. package/dist/cjs/utils/helpers.js +109 -0
  89. package/dist/cjs/utils/helpers.js.map +1 -1
  90. package/dist/docs/assets/navigation.js +1 -1
  91. package/dist/docs/assets/search.js +1 -1
  92. package/dist/docs/classes/AccountReader.html +18 -18
  93. package/dist/docs/classes/AccountsClient.html +10 -10
  94. package/dist/docs/classes/AsyncProviderError.html +4 -4
  95. package/dist/docs/classes/CircularDependencyError.html +4 -4
  96. package/dist/docs/classes/DasClient.html +13 -13
  97. package/dist/docs/classes/GeyserParser.html +17 -17
  98. package/dist/docs/classes/GrpcTransport.html +6 -6
  99. package/dist/docs/classes/HttpTransport.html +5 -5
  100. package/dist/docs/classes/InstructionWriter.html +11 -11
  101. package/dist/docs/classes/MemoryGuard.html +9 -9
  102. package/dist/docs/classes/NetworkError.html +5 -5
  103. package/dist/docs/classes/RefRegistry.html +11 -11
  104. package/dist/docs/classes/RefReleasedError.html +4 -4
  105. package/dist/docs/classes/RpcMethodNotFoundError.html +4 -4
  106. package/dist/docs/classes/ServiceNotFoundError.html +4 -4
  107. package/dist/docs/classes/ServiceRef.html +13 -13
  108. package/dist/docs/classes/SolanaRpc.html +55 -55
  109. package/dist/docs/classes/SynapseClient.html +25 -15
  110. package/dist/docs/classes/SynapseContext.html +27 -27
  111. package/dist/docs/classes/SynapseError.html +4 -4
  112. package/dist/docs/classes/TimeoutError.html +4 -4
  113. package/dist/docs/classes/UpstreamError.html +6 -6
  114. package/dist/docs/classes/WeakServiceRef.html +4 -4
  115. package/dist/docs/classes/WsClient.html +10 -10
  116. package/dist/docs/enums/SynapseNetwork.html +2 -2
  117. package/dist/docs/enums/SynapseRegion.html +2 -2
  118. package/dist/docs/enums/TokenExtensionType.html +2 -2
  119. package/dist/docs/functions/Epoch-1.html +1 -1
  120. package/dist/docs/functions/Lamports-2.html +1 -1
  121. package/dist/docs/functions/Pubkey-1.html +1 -1
  122. package/dist/docs/functions/Sig.html +1 -1
  123. package/dist/docs/functions/Slot-1.html +1 -1
  124. package/dist/docs/functions/UnixTs.html +1 -1
  125. package/dist/docs/functions/autoSelectRegion.html +1 -1
  126. package/dist/docs/functions/autoWire.html +1 -1
  127. package/dist/docs/functions/base58Encode.html +1 -1
  128. package/dist/docs/functions/base64ToBytes.html +1 -1
  129. package/dist/docs/functions/bigIntReplacer.html +6 -0
  130. package/dist/docs/functions/chunk.html +1 -1
  131. package/dist/docs/functions/computeBalanceChanges.html +1 -1
  132. package/dist/docs/functions/computeTokenBalanceChanges.html +1 -1
  133. package/dist/docs/functions/createBareContext.html +1 -1
  134. package/dist/docs/functions/createBinding.html +1 -1
  135. package/dist/docs/functions/createBoundHook.html +1 -1
  136. package/dist/docs/functions/createReactAdapter.html +1 -1
  137. package/dist/docs/functions/createRefHook.html +1 -1
  138. package/dist/docs/functions/createServerMiddleware.html +1 -1
  139. package/dist/docs/functions/createServiceHook.html +1 -1
  140. package/dist/docs/functions/createSingleton.html +15 -0
  141. package/dist/docs/functions/createSynapse.html +1 -1
  142. package/dist/docs/functions/createSynapseContext.html +1 -1
  143. package/dist/docs/functions/createToken.html +1 -1
  144. package/dist/docs/functions/decodeBase58.html +1 -1
  145. package/dist/docs/functions/decodeLookupTable.html +1 -1
  146. package/dist/docs/functions/decodeMint.html +1 -1
  147. package/dist/docs/functions/decodeMultisig.html +1 -1
  148. package/dist/docs/functions/decodeNonceAccount.html +1 -1
  149. package/dist/docs/functions/decodeStakeAccount.html +1 -1
  150. package/dist/docs/functions/decodeToken2022Account.html +1 -1
  151. package/dist/docs/functions/decodeToken2022Mint.html +1 -1
  152. package/dist/docs/functions/decodeTokenAccount.html +1 -1
  153. package/dist/docs/functions/encodeBase58.html +1 -1
  154. package/dist/docs/functions/fetchLookupTable.html +1 -1
  155. package/dist/docs/functions/fetchMint.html +1 -1
  156. package/dist/docs/functions/fetchNonceAccount.html +1 -1
  157. package/dist/docs/functions/fetchStakeAccount.html +1 -1
  158. package/dist/docs/functions/fetchTokenAccount.html +1 -1
  159. package/dist/docs/functions/fetchTokenAccountsByOwner.html +1 -1
  160. package/dist/docs/functions/fromKitAddress.html +1 -1
  161. package/dist/docs/functions/getAccountInfo.html +1 -1
  162. package/dist/docs/functions/getAsset.html +1 -1
  163. package/dist/docs/functions/getAssetBatch.html +1 -1
  164. package/dist/docs/functions/getAssetProof.html +1 -1
  165. package/dist/docs/functions/getAssetProofBatch.html +1 -1
  166. package/dist/docs/functions/getAssetsByAuthority.html +1 -1
  167. package/dist/docs/functions/getAssetsByCreator.html +1 -1
  168. package/dist/docs/functions/getAssetsByGroup.html +1 -1
  169. package/dist/docs/functions/getAssetsByOwner.html +1 -1
  170. package/dist/docs/functions/getBalance.html +1 -1
  171. package/dist/docs/functions/getBlock.html +1 -1
  172. package/dist/docs/functions/getBlockCommitment.html +1 -1
  173. package/dist/docs/functions/getBlockHeight.html +1 -1
  174. package/dist/docs/functions/getBlockProduction.html +1 -1
  175. package/dist/docs/functions/getBlockTime.html +1 -1
  176. package/dist/docs/functions/getBlocks.html +1 -1
  177. package/dist/docs/functions/getBlocksWithLimit.html +1 -1
  178. package/dist/docs/functions/getClusterNodes.html +1 -1
  179. package/dist/docs/functions/getContext.html +1 -1
  180. package/dist/docs/functions/getDecodedAccount.html +1 -1
  181. package/dist/docs/functions/getDecodedAccounts.html +1 -1
  182. package/dist/docs/functions/getEnvironment.html +1 -1
  183. package/dist/docs/functions/getEpochInfo.html +1 -1
  184. package/dist/docs/functions/getEpochSchedule.html +1 -1
  185. package/dist/docs/functions/getFeeForMessage.html +1 -1
  186. package/dist/docs/functions/getFirstAvailableBlock.html +1 -1
  187. package/dist/docs/functions/getGenesisHash.html +1 -1
  188. package/dist/docs/functions/getHealth.html +1 -1
  189. package/dist/docs/functions/getHighestSnapshotSlot.html +1 -1
  190. package/dist/docs/functions/getIdentity.html +1 -1
  191. package/dist/docs/functions/getInflationGovernor.html +1 -1
  192. package/dist/docs/functions/getInflationRate.html +1 -1
  193. package/dist/docs/functions/getInflationReward.html +1 -1
  194. package/dist/docs/functions/getLargestAccounts.html +1 -1
  195. package/dist/docs/functions/getLatestBlockhash.html +1 -1
  196. package/dist/docs/functions/getLeaderSchedule.html +1 -1
  197. package/dist/docs/functions/getMaxRetransmitSlot.html +1 -1
  198. package/dist/docs/functions/getMaxShredInsertSlot.html +1 -1
  199. package/dist/docs/functions/getMinimumBalanceForRentExemption.html +1 -1
  200. package/dist/docs/functions/getMultipleAccounts.html +1 -1
  201. package/dist/docs/functions/getProgramAccounts.html +1 -1
  202. package/dist/docs/functions/getProgramCategory.html +1 -1
  203. package/dist/docs/functions/getRecentPerformanceSamples.html +1 -1
  204. package/dist/docs/functions/getRecentPrioritizationFees.html +1 -1
  205. package/dist/docs/functions/getSignatureStatuses.html +1 -1
  206. package/dist/docs/functions/getSignaturesForAddress.html +1 -1
  207. package/dist/docs/functions/getSignaturesForAsset.html +1 -1
  208. package/dist/docs/functions/getSlot.html +1 -1
  209. package/dist/docs/functions/getSlotLeader.html +1 -1
  210. package/dist/docs/functions/getSlotLeaders.html +1 -1
  211. package/dist/docs/functions/getStakeActivation.html +1 -1
  212. package/dist/docs/functions/getStakeMinimumDelegation.html +1 -1
  213. package/dist/docs/functions/getSupply.html +1 -1
  214. package/dist/docs/functions/getTokenAccountBalance.html +1 -1
  215. package/dist/docs/functions/getTokenAccounts.html +1 -1
  216. package/dist/docs/functions/getTokenAccountsByDelegate.html +1 -1
  217. package/dist/docs/functions/getTokenAccountsByOwner.html +1 -1
  218. package/dist/docs/functions/getTokenLargestAccounts.html +1 -1
  219. package/dist/docs/functions/getTokenSupply.html +1 -1
  220. package/dist/docs/functions/getTransaction.html +1 -1
  221. package/dist/docs/functions/getTransactionCount.html +1 -1
  222. package/dist/docs/functions/getVersion.html +1 -1
  223. package/dist/docs/functions/getVoteAccounts.html +1 -1
  224. package/dist/docs/functions/isBlockhashValid.html +1 -1
  225. package/dist/docs/functions/isBrowser.html +1 -1
  226. package/dist/docs/functions/isDisposable.html +1 -1
  227. package/dist/docs/functions/isProgramInCategory.html +1 -1
  228. package/dist/docs/functions/isServer.html +1 -1
  229. package/dist/docs/functions/isValidPubkey.html +1 -1
  230. package/dist/docs/functions/isValidSignature.html +1 -1
  231. package/dist/docs/functions/lamportsToSol.html +1 -1
  232. package/dist/docs/functions/listEndpoints.html +1 -1
  233. package/dist/docs/functions/listNetworks.html +1 -1
  234. package/dist/docs/functions/listRegions.html +1 -1
  235. package/dist/docs/functions/minimumLedgerSlot.html +1 -1
  236. package/dist/docs/functions/parseAccountUpdate.html +1 -1
  237. package/dist/docs/functions/parseBlockMeta.html +1 -1
  238. package/dist/docs/functions/parseEntry.html +1 -1
  239. package/dist/docs/functions/parseGeyserUpdate.html +1 -1
  240. package/dist/docs/functions/parseSlotUpdate.html +1 -1
  241. package/dist/docs/functions/parseTimestamp.html +1 -1
  242. package/dist/docs/functions/parseTransaction.html +1 -1
  243. package/dist/docs/functions/probeLatency.html +1 -1
  244. package/dist/docs/functions/rawBufferToBase58.html +1 -1
  245. package/dist/docs/functions/rawBufferToBase64.html +1 -1
  246. package/dist/docs/functions/rawBufferToBytes.html +1 -1
  247. package/dist/docs/functions/rawBufferToHex.html +1 -1
  248. package/dist/docs/functions/readonly.html +1 -1
  249. package/dist/docs/functions/readonlySigner.html +1 -1
  250. package/dist/docs/functions/requestAirdrop.html +1 -1
  251. package/dist/docs/functions/resolveEndpoint.html +1 -1
  252. package/dist/docs/functions/resolveProgram.html +1 -1
  253. package/dist/docs/functions/resolveProgramBatch.html +1 -1
  254. package/dist/docs/functions/retry.html +1 -1
  255. package/dist/docs/functions/searchAssets.html +1 -1
  256. package/dist/docs/functions/sendTransaction.html +1 -1
  257. package/dist/docs/functions/setGlobalContext.html +1 -1
  258. package/dist/docs/functions/simulateTransaction.html +1 -1
  259. package/dist/docs/functions/sleep.html +1 -1
  260. package/dist/docs/functions/solToLamports.html +1 -1
  261. package/dist/docs/functions/toClientConfig.html +1 -1
  262. package/dist/docs/functions/toJsonSafe.html +13 -0
  263. package/dist/docs/functions/toKitAddress.html +1 -1
  264. package/dist/docs/functions/toKitInstruction.html +1 -1
  265. package/dist/docs/functions/toKitLamports.html +1 -1
  266. package/dist/docs/functions/toKitSignatureString.html +1 -1
  267. package/dist/docs/functions/tryGetContext.html +1 -1
  268. package/dist/docs/functions/tryUseService.html +1 -1
  269. package/dist/docs/functions/useBoundServices.html +1 -1
  270. package/dist/docs/functions/useService.html +1 -1
  271. package/dist/docs/functions/useSharedRef.html +1 -1
  272. package/dist/docs/functions/withRef.html +1 -1
  273. package/dist/docs/functions/withRefAsync.html +1 -1
  274. package/dist/docs/functions/writable.html +1 -1
  275. package/dist/docs/functions/writableSigner.html +1 -1
  276. package/dist/docs/interfaces/AccountInfo.html +7 -7
  277. package/dist/docs/interfaces/AccountMeta.html +4 -4
  278. package/dist/docs/interfaces/AccountNotification.html +2 -2
  279. package/dist/docs/interfaces/AccountSubParams.html +2 -2
  280. package/dist/docs/interfaces/AddMemoParams.html +5 -5
  281. package/dist/docs/interfaces/AdvanceNonceParams.html +3 -3
  282. package/dist/docs/interfaces/AliasProvider.html +2 -2
  283. package/dist/docs/interfaces/AllocateParams.html +3 -3
  284. package/dist/docs/interfaces/ApproveCheckedParams.html +9 -9
  285. package/dist/docs/interfaces/ApproveParams.html +7 -7
  286. package/dist/docs/interfaces/AssetSignatureInfo.html +2 -2
  287. package/dist/docs/interfaces/AssetSignaturesPage.html +2 -2
  288. package/dist/docs/interfaces/AssignParams.html +3 -3
  289. package/dist/docs/interfaces/AsyncFactoryProvider.html +2 -2
  290. package/dist/docs/interfaces/AuthorizeNonceParams.html +4 -4
  291. package/dist/docs/interfaces/BalanceChange.html +6 -6
  292. package/dist/docs/interfaces/BlockProduction.html +3 -3
  293. package/dist/docs/interfaces/BlockResult.html +2 -2
  294. package/dist/docs/interfaces/BlockReward.html +2 -2
  295. package/dist/docs/interfaces/BlockhashResult.html +2 -2
  296. package/dist/docs/interfaces/BurnCheckedParams.html +8 -8
  297. package/dist/docs/interfaces/BurnParams.html +7 -7
  298. package/dist/docs/interfaces/CallOptions.html +6 -6
  299. package/dist/docs/interfaces/ClassProvider.html +2 -2
  300. package/dist/docs/interfaces/CloseAccountParams.html +6 -6
  301. package/dist/docs/interfaces/ConfirmedTransaction.html +6 -6
  302. package/dist/docs/interfaces/ContactInfo.html +2 -2
  303. package/dist/docs/interfaces/ContextAdapter.html +5 -5
  304. package/dist/docs/interfaces/ContextEvents.html +6 -6
  305. package/dist/docs/interfaces/ContextModule.html +3 -3
  306. package/dist/docs/interfaces/CreateATAParams.html +6 -6
  307. package/dist/docs/interfaces/CreateAccountParams.html +6 -6
  308. package/dist/docs/interfaces/CreateAccountWithSeedParams.html +8 -8
  309. package/dist/docs/interfaces/CreateSynapseContextOpts.html +4 -4
  310. package/dist/docs/interfaces/DasAsset.html +2 -2
  311. package/dist/docs/interfaces/DasAssetProof.html +2 -2
  312. package/dist/docs/interfaces/DasAuthority.html +2 -2
  313. package/dist/docs/interfaces/DasCompression.html +2 -2
  314. package/dist/docs/interfaces/DasContent.html +2 -2
  315. package/dist/docs/interfaces/DasCreator.html +2 -2
  316. package/dist/docs/interfaces/DasFile.html +2 -2
  317. package/dist/docs/interfaces/DasGrouping.html +2 -2
  318. package/dist/docs/interfaces/DasOpts.html +2 -2
  319. package/dist/docs/interfaces/DasOwnership.html +2 -2
  320. package/dist/docs/interfaces/DasPage.html +2 -2
  321. package/dist/docs/interfaces/DasRoyalty.html +2 -2
  322. package/dist/docs/interfaces/DasSearchParams.html +2 -2
  323. package/dist/docs/interfaces/DasSupply.html +2 -2
  324. package/dist/docs/interfaces/DataSlice.html +3 -3
  325. package/dist/docs/interfaces/DecodedAccountResult.html +4 -4
  326. package/dist/docs/interfaces/DecodedLookupTable.html +8 -8
  327. package/dist/docs/interfaces/DecodedMint.html +6 -6
  328. package/dist/docs/interfaces/DecodedMultisig.html +5 -5
  329. package/dist/docs/interfaces/DecodedNonceAccount.html +6 -6
  330. package/dist/docs/interfaces/DecodedStakeAccount.html +2 -2
  331. package/dist/docs/interfaces/DecodedToken2022Account.html +9 -9
  332. package/dist/docs/interfaces/DecodedToken2022Mint.html +6 -6
  333. package/dist/docs/interfaces/DecodedTokenAccount.html +9 -9
  334. package/dist/docs/interfaces/DefaultAccountStateExt.html +2 -2
  335. package/dist/docs/interfaces/Disposable.html +2 -2
  336. package/dist/docs/interfaces/EndpointConnectConfig.html +5 -5
  337. package/dist/docs/interfaces/EpochInfo.html +7 -7
  338. package/dist/docs/interfaces/EpochSchedule.html +2 -2
  339. package/dist/docs/interfaces/FactoryProvider.html +2 -2
  340. package/dist/docs/interfaces/FetchedMint.html +6 -6
  341. package/dist/docs/interfaces/FetchedTokenAccount.html +6 -6
  342. package/dist/docs/interfaces/FreezeThawParams.html +6 -6
  343. package/dist/docs/interfaces/GetAccountInfoOpts.html +6 -6
  344. package/dist/docs/interfaces/GetAssetsByAuthorityParams.html +2 -2
  345. package/dist/docs/interfaces/GetAssetsByCreatorParams.html +2 -2
  346. package/dist/docs/interfaces/GetAssetsByGroupParams.html +2 -2
  347. package/dist/docs/interfaces/GetAssetsByOwnerParams.html +2 -2
  348. package/dist/docs/interfaces/GetBlockOpts.html +6 -6
  349. package/dist/docs/interfaces/GetBlockProductionOpts.html +6 -6
  350. package/dist/docs/interfaces/GetMultipleAccountsOpts.html +6 -6
  351. package/dist/docs/interfaces/GetProgramAccountsOpts.html +6 -6
  352. package/dist/docs/interfaces/GetSignatureStatusesOpts.html +6 -6
  353. package/dist/docs/interfaces/GetSignaturesOpts.html +7 -7
  354. package/dist/docs/interfaces/GetTokenAccountsParams.html +2 -2
  355. package/dist/docs/interfaces/GetTransactionOpts.html +6 -6
  356. package/dist/docs/interfaces/GeyserParserConfig.html +6 -6
  357. package/dist/docs/interfaces/GeyserParserEvents.html +9 -9
  358. package/dist/docs/interfaces/GeyserParserStats.html +2 -2
  359. package/dist/docs/interfaces/GrpcCallOptions.html +2 -2
  360. package/dist/docs/interfaces/GrpcTransportConfig.html +6 -6
  361. package/dist/docs/interfaces/ImmutableOwnerExt.html +2 -2
  362. package/dist/docs/interfaces/InflationGovernor.html +2 -2
  363. package/dist/docs/interfaces/InflationRate.html +2 -2
  364. package/dist/docs/interfaces/InflationReward.html +2 -2
  365. package/dist/docs/interfaces/InitializeAccountParams.html +5 -5
  366. package/dist/docs/interfaces/InitializeMintParams.html +6 -6
  367. package/dist/docs/interfaces/InitializeNonceParams.html +3 -3
  368. package/dist/docs/interfaces/InterestBearingConfigExt.html +2 -2
  369. package/dist/docs/interfaces/LatencyProbeResult.html +2 -2
  370. package/dist/docs/interfaces/LeakReport.html +5 -5
  371. package/dist/docs/interfaces/LogsNotification.html +2 -2
  372. package/dist/docs/interfaces/LogsSubParams.html +2 -2
  373. package/dist/docs/interfaces/MemoTransferExt.html +2 -2
  374. package/dist/docs/interfaces/MemoryGuardConfig.html +4 -4
  375. package/dist/docs/interfaces/MetadataPointerExt.html +2 -2
  376. package/dist/docs/interfaces/MintCloseAuthorityExt.html +2 -2
  377. package/dist/docs/interfaces/MintToCheckedParams.html +8 -8
  378. package/dist/docs/interfaces/MintToParams.html +7 -7
  379. package/dist/docs/interfaces/NonTransferableExt.html +2 -2
  380. package/dist/docs/interfaces/PaginationOpts.html +2 -2
  381. package/dist/docs/interfaces/ParsedAccountUpdate.html +16 -16
  382. package/dist/docs/interfaces/ParsedBlockMeta.html +2 -2
  383. package/dist/docs/interfaces/ParsedEntry.html +2 -2
  384. package/dist/docs/interfaces/ParsedInstruction.html +9 -9
  385. package/dist/docs/interfaces/ParsedSlotUpdate.html +3 -3
  386. package/dist/docs/interfaces/ParsedTransaction.html +19 -19
  387. package/dist/docs/interfaces/PerfSample.html +2 -2
  388. package/dist/docs/interfaces/PermanentDelegateExt.html +2 -2
  389. package/dist/docs/interfaces/ProgramAccount.html +2 -2
  390. package/dist/docs/interfaces/ProgramNotification.html +2 -2
  391. package/dist/docs/interfaces/ProgramSubParams.html +2 -2
  392. package/dist/docs/interfaces/ProgramsBundle.html +33 -33
  393. package/dist/docs/interfaces/RawAccountInfo.html +2 -2
  394. package/dist/docs/interfaces/RawBlockMeta.html +2 -2
  395. package/dist/docs/interfaces/RawBuffer.html +2 -2
  396. package/dist/docs/interfaces/RawCompiledInstruction.html +2 -2
  397. package/dist/docs/interfaces/RawEntry.html +2 -2
  398. package/dist/docs/interfaces/RawGeyserUpdate.html +2 -2
  399. package/dist/docs/interfaces/RawInnerInstruction.html +2 -2
  400. package/dist/docs/interfaces/RawSlotInfo.html +2 -2
  401. package/dist/docs/interfaces/RawTimestamp.html +2 -2
  402. package/dist/docs/interfaces/RawTokenBalance.html +2 -2
  403. package/dist/docs/interfaces/RawTransactionInfo.html +2 -2
  404. package/dist/docs/interfaces/ReactAdapterConfig.html +2 -2
  405. package/dist/docs/interfaces/RecoverNestedParams.html +7 -7
  406. package/dist/docs/interfaces/RefRegistryConfig.html +2 -2
  407. package/dist/docs/interfaces/RefStats.html +7 -7
  408. package/dist/docs/interfaces/RequestHeapFrameParams.html +2 -2
  409. package/dist/docs/interfaces/ResolveMiddleware.html +1 -1
  410. package/dist/docs/interfaces/RevokeParams.html +5 -5
  411. package/dist/docs/interfaces/RootNotification.html +2 -2
  412. package/dist/docs/interfaces/RootSubParams.html +1 -1
  413. package/dist/docs/interfaces/RpcContext.html +2 -2
  414. package/dist/docs/interfaces/RpcError.html +4 -4
  415. package/dist/docs/interfaces/RpcRequest.html +4 -2
  416. package/dist/docs/interfaces/RpcResponse.html +2 -2
  417. package/dist/docs/interfaces/SendTransactionOpts.html +6 -6
  418. package/dist/docs/interfaces/ServerAdapterConfig.html +3 -3
  419. package/dist/docs/interfaces/ServiceBinding.html +6 -6
  420. package/dist/docs/interfaces/ServiceRegistration.html +3 -3
  421. package/dist/docs/interfaces/ServiceResolver.html +6 -6
  422. package/dist/docs/interfaces/ServiceToken.html +4 -4
  423. package/dist/docs/interfaces/SetComputeUnitLimitParams.html +2 -2
  424. package/dist/docs/interfaces/SetComputeUnitPriceParams.html +2 -2
  425. package/dist/docs/interfaces/SetLoadedAccountsDataSizeLimitParams.html +2 -2
  426. package/dist/docs/interfaces/SignatureInfo.html +7 -7
  427. package/dist/docs/interfaces/SignatureNotification.html +2 -2
  428. package/dist/docs/interfaces/SignatureStatus.html +5 -5
  429. package/dist/docs/interfaces/SignatureSubParams.html +2 -2
  430. package/dist/docs/interfaces/SignaturesForAssetParams.html +2 -2
  431. package/dist/docs/interfaces/SimulateResult.html +2 -2
  432. package/dist/docs/interfaces/SimulateTransactionOpts.html +7 -7
  433. package/dist/docs/interfaces/SingletonOptions.html +7 -0
  434. package/dist/docs/interfaces/SlotNotification.html +2 -2
  435. package/dist/docs/interfaces/SlotSubParams.html +1 -1
  436. package/dist/docs/interfaces/SortOpts.html +2 -2
  437. package/dist/docs/interfaces/StakeAuthorized.html +2 -2
  438. package/dist/docs/interfaces/StakeDelegation.html +3 -3
  439. package/dist/docs/interfaces/StakeLockup.html +4 -4
  440. package/dist/docs/interfaces/StakeMeta.html +2 -2
  441. package/dist/docs/interfaces/Supply.html +5 -5
  442. package/dist/docs/interfaces/SynapseClientConfig.html +9 -9
  443. package/dist/docs/interfaces/SynapseClientLike.html +2 -2
  444. package/dist/docs/interfaces/SynapseEndpoint.html +7 -7
  445. package/dist/docs/interfaces/SyncNativeParams.html +3 -3
  446. package/dist/docs/interfaces/SystemTransferParams.html +4 -4
  447. package/dist/docs/interfaces/TokenAccount.html +3 -3
  448. package/dist/docs/interfaces/TokenAccountsByOwnerResult.html +2 -2
  449. package/dist/docs/interfaces/TokenAmount.html +5 -5
  450. package/dist/docs/interfaces/TokenBalanceChange.html +2 -2
  451. package/dist/docs/interfaces/TokenTransferParams.html +7 -7
  452. package/dist/docs/interfaces/TransactionInstruction.html +4 -4
  453. package/dist/docs/interfaces/TransactionMeta.html +11 -11
  454. package/dist/docs/interfaces/TransferCheckedParams.html +9 -9
  455. package/dist/docs/interfaces/TransferFeeAmount.html +2 -2
  456. package/dist/docs/interfaces/TransferFeeConfig.html +2 -2
  457. package/dist/docs/interfaces/TransportConfig.html +7 -7
  458. package/dist/docs/interfaces/UnknownExtension.html +2 -2
  459. package/dist/docs/interfaces/ValueProvider.html +2 -2
  460. package/dist/docs/interfaces/VoteAccount.html +9 -9
  461. package/dist/docs/interfaces/VoteAccountsResult.html +3 -3
  462. package/dist/docs/interfaces/WithdrawNonceParams.html +5 -5
  463. package/dist/docs/interfaces/WsConfig.html +6 -6
  464. package/dist/docs/media/CHANGELOG.md +117 -0
  465. package/dist/docs/modules.html +4 -0
  466. package/dist/docs/types/AccountFetchOpts.html +1 -1
  467. package/dist/docs/types/AccountFilter.html +1 -1
  468. package/dist/docs/types/Base58.html +1 -1
  469. package/dist/docs/types/Brand.html +1 -1
  470. package/dist/docs/types/Commitment.html +1 -1
  471. package/dist/docs/types/DasSortBy.html +1 -1
  472. package/dist/docs/types/DasSortDirection.html +1 -1
  473. package/dist/docs/types/DataSizeFilter.html +1 -1
  474. package/dist/docs/types/DecodedExtension.html +1 -1
  475. package/dist/docs/types/Encoding.html +1 -1
  476. package/dist/docs/types/Epoch.html +1 -1
  477. package/dist/docs/types/Lamports.html +1 -1
  478. package/dist/docs/types/LogsFilter.html +1 -1
  479. package/dist/docs/types/MemcmpFilter.html +1 -1
  480. package/dist/docs/types/NonceState.html +1 -1
  481. package/dist/docs/types/ParsedGeyserUpdate.html +1 -1
  482. package/dist/docs/types/Pubkey.html +1 -1
  483. package/dist/docs/types/RuntimeEnv.html +1 -1
  484. package/dist/docs/types/ServiceLifecycle.html +1 -1
  485. package/dist/docs/types/ServiceProvider.html +1 -1
  486. package/dist/docs/types/Signature.html +1 -1
  487. package/dist/docs/types/Slot.html +1 -1
  488. package/dist/docs/types/StakeAccountType.html +1 -1
  489. package/dist/docs/types/SubscriptionId.html +1 -1
  490. package/dist/docs/types/TokenAccountState.html +1 -1
  491. package/dist/docs/types/TransactionDetail.html +1 -1
  492. package/dist/docs/types/UnaryMethod.html +1 -1
  493. package/dist/docs/types/UnixTimestamp.html +1 -1
  494. package/dist/docs/types/WsNotification.html +1 -1
  495. package/dist/docs/variables/ASSOCIATED_TOKEN_PROGRAM.html +1 -1
  496. package/dist/docs/variables/AssociatedToken.html +4 -4
  497. package/dist/docs/variables/COMPUTE_BUDGET_PROGRAM.html +1 -1
  498. package/dist/docs/variables/ComputeBudget.html +5 -5
  499. package/dist/docs/variables/JUPITER_PROGRAMS.html +1 -1
  500. package/dist/docs/variables/KNOWN_PROGRAMS.html +1 -1
  501. package/dist/docs/variables/KNOWN_PROGRAMS_COUNT.html +1 -1
  502. package/dist/docs/variables/LOOKUP_TABLE_HEADER_SIZE.html +1 -1
  503. package/dist/docs/variables/LOOKUP_TABLE_PROGRAM_ID.html +1 -1
  504. package/dist/docs/variables/MARINADE_PROGRAMS.html +1 -1
  505. package/dist/docs/variables/MAX_MULTISIG_SIGNERS.html +1 -1
  506. package/dist/docs/variables/MEMO_PROGRAM_V1.html +1 -1
  507. package/dist/docs/variables/MEMO_PROGRAM_V2.html +1 -1
  508. package/dist/docs/variables/METAPLEX_PROGRAMS.html +1 -1
  509. package/dist/docs/variables/METEORA_PROGRAMS.html +1 -1
  510. package/dist/docs/variables/MINT_SIZE.html +1 -1
  511. package/dist/docs/variables/MULTISIG_SIZE.html +1 -1
  512. package/dist/docs/variables/Memo.html +2 -2
  513. package/dist/docs/variables/NONCE_ACCOUNT_SIZE.html +1 -1
  514. package/dist/docs/variables/ORCA_PROGRAMS.html +1 -1
  515. package/dist/docs/variables/OTHER_PROGRAMS.html +1 -1
  516. package/dist/docs/variables/RAYDIUM_PROGRAMS.html +1 -1
  517. package/dist/docs/variables/SDK_USER_AGENT.html +1 -1
  518. package/dist/docs/variables/SPL_PROGRAMS.html +1 -1
  519. package/dist/docs/variables/STAKE_PROGRAM_ID.html +1 -1
  520. package/dist/docs/variables/SYNAPSE_DEVNET_EU.html +1 -1
  521. package/dist/docs/variables/SYNAPSE_DEVNET_US.html +1 -1
  522. package/dist/docs/variables/SYNAPSE_ENDPOINTS.html +1 -1
  523. package/dist/docs/variables/SYNAPSE_MAINNET_EU.html +1 -1
  524. package/dist/docs/variables/SYNAPSE_MAINNET_US.html +1 -1
  525. package/dist/docs/variables/SYSTEM_PROGRAM.html +1 -1
  526. package/dist/docs/variables/SYSTEM_PROGRAMS.html +1 -1
  527. package/dist/docs/variables/SYSTEM_PROGRAM_ID.html +1 -1
  528. package/dist/docs/variables/SplToken.html +16 -16
  529. package/dist/docs/variables/SystemProgram.html +10 -10
  530. package/dist/docs/variables/TOKEN_2022_PROGRAM.html +1 -1
  531. package/dist/docs/variables/TOKEN_2022_PROGRAM_ID.html +1 -1
  532. package/dist/docs/variables/TOKEN_ACCOUNT_SIZE.html +1 -1
  533. package/dist/docs/variables/TOKEN_PROGRAM.html +1 -1
  534. package/dist/docs/variables/TOKEN_PROGRAM_ID.html +1 -1
  535. package/dist/docs/variables/Tokens.html +1 -1
  536. package/dist/esm/ai/gateway/index.d.ts +86 -5
  537. package/dist/esm/ai/gateway/index.d.ts.map +1 -1
  538. package/dist/esm/ai/gateway/index.js +275 -39
  539. package/dist/esm/ai/gateway/index.js.map +1 -1
  540. package/dist/esm/ai/gateway/registry.d.ts +223 -0
  541. package/dist/esm/ai/gateway/registry.d.ts.map +1 -0
  542. package/dist/esm/ai/gateway/registry.js +285 -0
  543. package/dist/esm/ai/gateway/registry.js.map +1 -0
  544. package/dist/esm/ai/gateway/types.d.ts +107 -1
  545. package/dist/esm/ai/gateway/types.d.ts.map +1 -1
  546. package/dist/esm/ai/gateway/x402/index.d.ts +2 -4
  547. package/dist/esm/ai/gateway/x402/index.d.ts.map +1 -1
  548. package/dist/esm/ai/gateway/x402/index.js +2 -3
  549. package/dist/esm/ai/gateway/x402/index.js.map +1 -1
  550. package/dist/esm/ai/gateway/x402/registry.d.ts +131 -1
  551. package/dist/esm/ai/gateway/x402/registry.d.ts.map +1 -1
  552. package/dist/esm/ai/gateway/x402/registry.js +227 -0
  553. package/dist/esm/ai/gateway/x402/registry.js.map +1 -1
  554. package/dist/esm/ai/index.d.ts +2 -1
  555. package/dist/esm/ai/index.d.ts.map +1 -1
  556. package/dist/esm/ai/index.js +13 -1
  557. package/dist/esm/ai/index.js.map +1 -1
  558. package/dist/esm/ai/persistence/helpers.d.ts +83 -0
  559. package/dist/esm/ai/persistence/helpers.d.ts.map +1 -0
  560. package/dist/esm/ai/persistence/helpers.js +183 -0
  561. package/dist/esm/ai/persistence/helpers.js.map +1 -0
  562. package/dist/esm/ai/persistence/index.d.ts +91 -0
  563. package/dist/esm/ai/persistence/index.d.ts.map +1 -0
  564. package/dist/esm/ai/persistence/index.js +94 -0
  565. package/dist/esm/ai/persistence/index.js.map +1 -0
  566. package/dist/esm/ai/persistence/memory.d.ts +71 -0
  567. package/dist/esm/ai/persistence/memory.d.ts.map +1 -0
  568. package/dist/esm/ai/persistence/memory.js +188 -0
  569. package/dist/esm/ai/persistence/memory.js.map +1 -0
  570. package/dist/esm/ai/persistence/postgresql.d.ts +119 -0
  571. package/dist/esm/ai/persistence/postgresql.d.ts.map +1 -0
  572. package/dist/esm/ai/persistence/postgresql.js +306 -0
  573. package/dist/esm/ai/persistence/postgresql.js.map +1 -0
  574. package/dist/esm/ai/persistence/redis.d.ts +84 -0
  575. package/dist/esm/ai/persistence/redis.d.ts.map +1 -0
  576. package/dist/esm/ai/persistence/redis.js +237 -0
  577. package/dist/esm/ai/persistence/redis.js.map +1 -0
  578. package/dist/esm/ai/persistence/types.d.ts +267 -0
  579. package/dist/esm/ai/persistence/types.d.ts.map +1 -0
  580. package/dist/esm/ai/persistence/types.js +36 -0
  581. package/dist/esm/ai/persistence/types.js.map +1 -0
  582. package/dist/esm/ai/tools/protocols/metaplex/tools.d.ts.map +1 -1
  583. package/dist/esm/ai/tools/protocols/metaplex/tools.js +13 -19
  584. package/dist/esm/ai/tools/protocols/metaplex/tools.js.map +1 -1
  585. package/dist/esm/core/client.d.ts +16 -0
  586. package/dist/esm/core/client.d.ts.map +1 -1
  587. package/dist/esm/core/client.js +18 -0
  588. package/dist/esm/core/client.js.map +1 -1
  589. package/dist/esm/core/transport.d.ts +1 -1
  590. package/dist/esm/core/transport.d.ts.map +1 -1
  591. package/dist/esm/core/transport.js.map +1 -1
  592. package/dist/esm/core/types.d.ts +5 -1
  593. package/dist/esm/core/types.d.ts.map +1 -1
  594. package/dist/esm/das/methods/get-asset-batch.js +1 -1
  595. package/dist/esm/das/methods/get-asset-batch.js.map +1 -1
  596. package/dist/esm/das/methods/get-asset-proof-batch.js +1 -1
  597. package/dist/esm/das/methods/get-asset-proof-batch.js.map +1 -1
  598. package/dist/esm/das/methods/get-asset-proof.js +1 -1
  599. package/dist/esm/das/methods/get-asset-proof.js.map +1 -1
  600. package/dist/esm/das/methods/get-asset.js +1 -1
  601. package/dist/esm/das/methods/get-asset.js.map +1 -1
  602. package/dist/esm/das/methods/get-assets-by-authority.js +1 -1
  603. package/dist/esm/das/methods/get-assets-by-authority.js.map +1 -1
  604. package/dist/esm/das/methods/get-assets-by-creator.js +1 -1
  605. package/dist/esm/das/methods/get-assets-by-creator.js.map +1 -1
  606. package/dist/esm/das/methods/get-assets-by-group.js +1 -1
  607. package/dist/esm/das/methods/get-assets-by-group.js.map +1 -1
  608. package/dist/esm/das/methods/get-assets-by-owner.js +1 -1
  609. package/dist/esm/das/methods/get-assets-by-owner.js.map +1 -1
  610. package/dist/esm/das/methods/get-signatures-for-asset.js +1 -1
  611. package/dist/esm/das/methods/get-signatures-for-asset.js.map +1 -1
  612. package/dist/esm/das/methods/get-token-accounts.js +1 -1
  613. package/dist/esm/das/methods/get-token-accounts.js.map +1 -1
  614. package/dist/esm/das/methods/search-assets.js +1 -1
  615. package/dist/esm/das/methods/search-assets.js.map +1 -1
  616. package/dist/esm/next/index.d.ts +141 -0
  617. package/dist/esm/next/index.d.ts.map +1 -0
  618. package/dist/esm/next/index.js +171 -0
  619. package/dist/esm/next/index.js.map +1 -0
  620. package/dist/esm/utils/helpers.d.ts +79 -1
  621. package/dist/esm/utils/helpers.d.ts.map +1 -1
  622. package/dist/esm/utils/helpers.js +106 -0
  623. package/dist/esm/utils/helpers.js.map +1 -1
  624. package/package.json +20 -2
@@ -0,0 +1,83 @@
1
+ /**
2
+ * @module ai/persistence/helpers
3
+ * @description Serialization utilities, key builders, and PostgreSQL schema
4
+ * for the Synapse AI persistence layer.
5
+ *
6
+ * @since 1.2.2
7
+ */
8
+ /**
9
+ * Serialize a value to a JSON string, converting `BigInt` to strings.
10
+ *
11
+ * @param value - Any value (may contain `BigInt`, `Map`, nested objects).
12
+ * @returns JSON string safe for storage.
13
+ * @since 1.2.2
14
+ */
15
+ export declare function serialize(value: unknown): string;
16
+ /**
17
+ * Deserialize a JSON string back to a typed value.
18
+ *
19
+ * @typeParam T - Expected return type.
20
+ * @param json - JSON string from the store.
21
+ * @returns Parsed value.
22
+ * @since 1.2.2
23
+ */
24
+ export declare function deserialize<T = unknown>(json: string): T;
25
+ /**
26
+ * Build a namespaced Redis key from segments.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * buildKey('synapse', 'agent', 'did:agent:1');
31
+ * // → 'synapse:agent:did:agent:1'
32
+ * ```
33
+ *
34
+ * @param parts - Key segments joined by `:`.
35
+ * @returns Colon-delimited key string.
36
+ * @since 1.2.2
37
+ */
38
+ export declare function buildKey(...parts: string[]): string;
39
+ /**
40
+ * Strip a prefix from a Redis key and return the remaining segments.
41
+ *
42
+ * @param prefix - The prefix to strip (e.g. `'synapse'`).
43
+ * @param key - Full key (e.g. `'synapse:agent:id1'`).
44
+ * @returns Remaining segments after the prefix (e.g. `['agent', 'id1']`).
45
+ * @since 1.2.2
46
+ */
47
+ export declare function parseKey(prefix: string, key: string): string[];
48
+ /**
49
+ * Extract the agent ID from a namespaced Redis key.
50
+ *
51
+ * @param prefix - Key prefix (e.g. `'synapse'`).
52
+ * @param key - Full key (e.g. `'synapse:agent:my-agent'`).
53
+ * @returns The agent ID segment, or the full key if pattern doesn't match.
54
+ * @since 1.2.2
55
+ */
56
+ export declare function extractAgentId(prefix: string, key: string): string;
57
+ /** Current schema version. Bump when adding migrations. */
58
+ export declare const SCHEMA_VERSION = 1;
59
+ /**
60
+ * Generate the full PostgreSQL DDL for a given table prefix.
61
+ *
62
+ * Creates tables:
63
+ * - `{prefix}_agents` — agent snapshots (JSONB)
64
+ * - `{prefix}_sessions` — session records (JSONB)
65
+ * - `{prefix}_receipts` — payment receipts (JSONB)
66
+ * - `{prefix}_metrics` — time-series metric points
67
+ * - `{prefix}_kv` — generic key-value store
68
+ * - `{prefix}_schema_version` — migration tracking
69
+ *
70
+ * @param prefix - Table name prefix (default: `'synapse'`).
71
+ * @returns SQL DDL string ready for `client.query()`.
72
+ * @since 1.2.2
73
+ */
74
+ export declare function buildSchema(prefix?: string): string;
75
+ /**
76
+ * SQL to clean up expired rows from the KV table.
77
+ *
78
+ * @param prefix - Table name prefix.
79
+ * @returns DELETE statement string.
80
+ * @since 1.2.2
81
+ */
82
+ export declare function buildKvCleanupSql(prefix?: string): string;
83
+ //# sourceMappingURL=helpers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../../src/ai/persistence/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAQH;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAEhD;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,CAAC,GAAG,OAAO,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,CAExD;AAMD;;;;;;;;;;;;GAYG;AACH,wBAAgB,QAAQ,CAAC,GAAG,KAAK,EAAE,MAAM,EAAE,GAAG,MAAM,CAEnD;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAG9D;AAED;;;;;;;GAOG;AACH,wBAAgB,cAAc,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM,CAIlE;AAMD,2DAA2D;AAC3D,eAAO,MAAM,cAAc,IAAI,CAAC;AAEhC;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,WAAW,CAAC,MAAM,GAAE,MAAkB,GAAG,MAAM,CA2E9D;AAED;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,GAAE,MAAkB,GAAG,MAAM,CAEpE"}
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ /**
3
+ * @module ai/persistence/helpers
4
+ * @description Serialization utilities, key builders, and PostgreSQL schema
5
+ * for the Synapse AI persistence layer.
6
+ *
7
+ * @since 1.2.2
8
+ */
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.SCHEMA_VERSION = void 0;
11
+ exports.serialize = serialize;
12
+ exports.deserialize = deserialize;
13
+ exports.buildKey = buildKey;
14
+ exports.parseKey = parseKey;
15
+ exports.extractAgentId = extractAgentId;
16
+ exports.buildSchema = buildSchema;
17
+ exports.buildKvCleanupSql = buildKvCleanupSql;
18
+ const helpers_1 = require("../../utils/helpers");
19
+ /* ═══════════════════════════════════════════════════════════════
20
+ * Serialization
21
+ * ═══════════════════════════════════════════════════════════════ */
22
+ /**
23
+ * Serialize a value to a JSON string, converting `BigInt` to strings.
24
+ *
25
+ * @param value - Any value (may contain `BigInt`, `Map`, nested objects).
26
+ * @returns JSON string safe for storage.
27
+ * @since 1.2.2
28
+ */
29
+ function serialize(value) {
30
+ return JSON.stringify((0, helpers_1.toJsonSafe)(value));
31
+ }
32
+ /**
33
+ * Deserialize a JSON string back to a typed value.
34
+ *
35
+ * @typeParam T - Expected return type.
36
+ * @param json - JSON string from the store.
37
+ * @returns Parsed value.
38
+ * @since 1.2.2
39
+ */
40
+ function deserialize(json) {
41
+ return JSON.parse(json);
42
+ }
43
+ /* ═══════════════════════════════════════════════════════════════
44
+ * Redis key builders
45
+ * ═══════════════════════════════════════════════════════════════ */
46
+ /**
47
+ * Build a namespaced Redis key from segments.
48
+ *
49
+ * @example
50
+ * ```ts
51
+ * buildKey('synapse', 'agent', 'did:agent:1');
52
+ * // → 'synapse:agent:did:agent:1'
53
+ * ```
54
+ *
55
+ * @param parts - Key segments joined by `:`.
56
+ * @returns Colon-delimited key string.
57
+ * @since 1.2.2
58
+ */
59
+ function buildKey(...parts) {
60
+ return parts.join(':');
61
+ }
62
+ /**
63
+ * Strip a prefix from a Redis key and return the remaining segments.
64
+ *
65
+ * @param prefix - The prefix to strip (e.g. `'synapse'`).
66
+ * @param key - Full key (e.g. `'synapse:agent:id1'`).
67
+ * @returns Remaining segments after the prefix (e.g. `['agent', 'id1']`).
68
+ * @since 1.2.2
69
+ */
70
+ function parseKey(prefix, key) {
71
+ const stripped = key.startsWith(prefix + ':') ? key.slice(prefix.length + 1) : key;
72
+ return stripped.split(':');
73
+ }
74
+ /**
75
+ * Extract the agent ID from a namespaced Redis key.
76
+ *
77
+ * @param prefix - Key prefix (e.g. `'synapse'`).
78
+ * @param key - Full key (e.g. `'synapse:agent:my-agent'`).
79
+ * @returns The agent ID segment, or the full key if pattern doesn't match.
80
+ * @since 1.2.2
81
+ */
82
+ function extractAgentId(prefix, key) {
83
+ const parts = parseKey(prefix, key);
84
+ // Keys are: agent:{id}, session:{agentId}:{sessionId}, etc.
85
+ return parts.length >= 2 ? parts[1] : key;
86
+ }
87
+ /* ═══════════════════════════════════════════════════════════════
88
+ * PostgreSQL schema
89
+ * ═══════════════════════════════════════════════════════════════ */
90
+ /** Current schema version. Bump when adding migrations. */
91
+ exports.SCHEMA_VERSION = 1;
92
+ /**
93
+ * Generate the full PostgreSQL DDL for a given table prefix.
94
+ *
95
+ * Creates tables:
96
+ * - `{prefix}_agents` — agent snapshots (JSONB)
97
+ * - `{prefix}_sessions` — session records (JSONB)
98
+ * - `{prefix}_receipts` — payment receipts (JSONB)
99
+ * - `{prefix}_metrics` — time-series metric points
100
+ * - `{prefix}_kv` — generic key-value store
101
+ * - `{prefix}_schema_version` — migration tracking
102
+ *
103
+ * @param prefix - Table name prefix (default: `'synapse'`).
104
+ * @returns SQL DDL string ready for `client.query()`.
105
+ * @since 1.2.2
106
+ */
107
+ function buildSchema(prefix = 'synapse') {
108
+ const p = prefix;
109
+ return `
110
+ -- ═══════════════════════════════════════════════════════════════
111
+ -- Synapse AI Persistence — Schema v${exports.SCHEMA_VERSION}
112
+ -- Prefix: ${p}
113
+ -- ═══════════════════════════════════════════════════════════════
114
+
115
+ -- Agent snapshots
116
+ CREATE TABLE IF NOT EXISTS ${p}_agents (
117
+ agent_id TEXT PRIMARY KEY,
118
+ snapshot JSONB NOT NULL,
119
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
120
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
121
+ );
122
+
123
+ -- Session records
124
+ CREATE TABLE IF NOT EXISTS ${p}_sessions (
125
+ id TEXT NOT NULL,
126
+ agent_id TEXT NOT NULL,
127
+ state JSONB NOT NULL,
128
+ status TEXT NOT NULL DEFAULT 'active',
129
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
130
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
131
+ PRIMARY KEY (agent_id, id)
132
+ );
133
+ CREATE INDEX IF NOT EXISTS idx_${p}_sessions_agent
134
+ ON ${p}_sessions (agent_id);
135
+ CREATE INDEX IF NOT EXISTS idx_${p}_sessions_status
136
+ ON ${p}_sessions (status);
137
+
138
+ -- Payment receipts
139
+ CREATE TABLE IF NOT EXISTS ${p}_receipts (
140
+ id TEXT PRIMARY KEY,
141
+ agent_id TEXT NOT NULL,
142
+ session_id TEXT,
143
+ receipt JSONB NOT NULL,
144
+ amount_charged TEXT NOT NULL DEFAULT '0',
145
+ settled_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
146
+ );
147
+ CREATE INDEX IF NOT EXISTS idx_${p}_receipts_agent
148
+ ON ${p}_receipts (agent_id);
149
+ CREATE INDEX IF NOT EXISTS idx_${p}_receipts_settled
150
+ ON ${p}_receipts (settled_at DESC);
151
+
152
+ -- Metric time-series
153
+ CREATE TABLE IF NOT EXISTS ${p}_metrics (
154
+ id BIGSERIAL PRIMARY KEY,
155
+ agent_id TEXT NOT NULL,
156
+ metric_key TEXT NOT NULL,
157
+ value DOUBLE PRECISION NOT NULL,
158
+ labels JSONB DEFAULT '{}',
159
+ recorded_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
160
+ );
161
+ CREATE INDEX IF NOT EXISTS idx_${p}_metrics_agent_key
162
+ ON ${p}_metrics (agent_id, metric_key);
163
+ CREATE INDEX IF NOT EXISTS idx_${p}_metrics_time
164
+ ON ${p}_metrics (recorded_at DESC);
165
+
166
+ -- Generic key-value store
167
+ CREATE TABLE IF NOT EXISTS ${p}_kv (
168
+ key TEXT PRIMARY KEY,
169
+ value JSONB NOT NULL,
170
+ expires_at TIMESTAMPTZ,
171
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
172
+ );
173
+
174
+ -- Schema version tracking
175
+ CREATE TABLE IF NOT EXISTS ${p}_schema_version (
176
+ version INTEGER PRIMARY KEY,
177
+ applied_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
178
+ );
179
+ INSERT INTO ${p}_schema_version (version) VALUES (${exports.SCHEMA_VERSION})
180
+ ON CONFLICT (version) DO NOTHING;
181
+ `.trim();
182
+ }
183
+ /**
184
+ * SQL to clean up expired rows from the KV table.
185
+ *
186
+ * @param prefix - Table name prefix.
187
+ * @returns DELETE statement string.
188
+ * @since 1.2.2
189
+ */
190
+ function buildKvCleanupSql(prefix = 'synapse') {
191
+ return `DELETE FROM ${prefix}_kv WHERE expires_at IS NOT NULL AND expires_at < NOW()`;
192
+ }
193
+ //# sourceMappingURL=helpers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../src/ai/persistence/helpers.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;AAeH,8BAEC;AAUD,kCAEC;AAmBD,4BAEC;AAUD,4BAGC;AAUD,wCAIC;AAwBD,kCA2EC;AASD,8CAEC;AAzLD,iDAAiD;AAEjD;;qEAEqE;AAErE;;;;;;GAMG;AACH,SAAgB,SAAS,CAAC,KAAc;IACtC,OAAO,IAAI,CAAC,SAAS,CAAC,IAAA,oBAAU,EAAC,KAAK,CAAC,CAAC,CAAC;AAC3C,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,WAAW,CAAc,IAAY;IACnD,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAM,CAAC;AAC/B,CAAC;AAED;;qEAEqE;AAErE;;;;;;;;;;;;GAYG;AACH,SAAgB,QAAQ,CAAC,GAAG,KAAe;IACzC,OAAO,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AACzB,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,QAAQ,CAAC,MAAc,EAAE,GAAW;IAClD,MAAM,QAAQ,GAAG,GAAG,CAAC,UAAU,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;IACnF,OAAO,QAAQ,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;AAC7B,CAAC;AAED;;;;;;;GAOG;AACH,SAAgB,cAAc,CAAC,MAAc,EAAE,GAAW;IACxD,MAAM,KAAK,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACpC,4DAA4D;IAC5D,OAAO,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC;AAC5C,CAAC;AAED;;qEAEqE;AAErE,2DAA2D;AAC9C,QAAA,cAAc,GAAG,CAAC,CAAC;AAEhC;;;;;;;;;;;;;;GAcG;AACH,SAAgB,WAAW,CAAC,SAAiB,SAAS;IACpD,MAAM,CAAC,GAAG,MAAM,CAAC;IACjB,OAAO;;uCAE8B,sBAAc;cACvC,CAAC;;;;6BAIc,CAAC;;;;;;;;6BAQD,CAAC;;;;;;;;;iCASG,CAAC;OAC3B,CAAC;iCACyB,CAAC;OAC3B,CAAC;;;6BAGqB,CAAC;;;;;;;;iCAQG,CAAC;OAC3B,CAAC;iCACyB,CAAC;OAC3B,CAAC;;;6BAGqB,CAAC;;;;;;;;iCAQG,CAAC;OAC3B,CAAC;iCACyB,CAAC;OAC3B,CAAC;;;6BAGqB,CAAC;;;;;;;;6BAQD,CAAC;;;;cAIhB,CAAC,qCAAqC,sBAAc;;CAEjE,CAAC,IAAI,EAAE,CAAC;AACT,CAAC;AAED;;;;;;GAMG;AACH,SAAgB,iBAAiB,CAAC,SAAiB,SAAS;IAC1D,OAAO,eAAe,MAAM,yDAAyD,CAAC;AACxF,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * @module ai/persistence
3
+ * @description Synapse AI Persistence Layer — Redis, PostgreSQL, and in-memory
4
+ * adapters for long-term storage of agent snapshots, sessions, receipts,
5
+ * and metrics.
6
+ *
7
+ * ## Architecture
8
+ *
9
+ * All adapters implement the universal {@link PersistenceStore} interface
10
+ * **and** the `PersistenceAdapter` interface from {@link AgentRegistry},
11
+ * so they work everywhere:
12
+ *
13
+ * ```ts
14
+ * // As a standalone store
15
+ * const store = new RedisPersistence({ client: redis });
16
+ * await store.saveAgent(snapshot);
17
+ *
18
+ * // As AgentRegistry backend
19
+ * const registry = new AgentRegistry({ persistence: store });
20
+ * ```
21
+ *
22
+ * ## Adapters
23
+ *
24
+ * | Adapter | Backing store | Best for |
25
+ * |---|---|---|
26
+ * | {@link MemoryStore} | In-process `Map` | Testing, dev, CLI tools |
27
+ * | {@link RedisPersistence} | Redis / Valkey | Sessions, caching, pub/sub |
28
+ * | {@link PostgresPersistence} | PostgreSQL | Analytics, receipts, audit |
29
+ *
30
+ * ## Dependency injection
31
+ *
32
+ * Redis and PostgreSQL adapters accept a pre-configured client instance
33
+ * via their constructor config. No runtime dependencies are bundled —
34
+ * install `ioredis` or `pg` as needed.
35
+ *
36
+ * @example Redis quick start
37
+ * ```ts
38
+ * import Redis from 'ioredis';
39
+ * import { RedisPersistence } from '@oobe-protocol-labs/synapse-client-sdk/ai';
40
+ *
41
+ * const redis = new Redis(process.env.REDIS_URL);
42
+ * const store = new RedisPersistence({ client: redis, defaultTtl: 3600 });
43
+ * await store.connect();
44
+ *
45
+ * await store.saveAgent(gateway.snapshot());
46
+ * await store.saveSession(sessionRecord);
47
+ * await store.recordMetric('agent-1', 'calls', 42);
48
+ * ```
49
+ *
50
+ * @example PostgreSQL quick start
51
+ * ```ts
52
+ * import { Pool } from 'pg';
53
+ * import { PostgresPersistence } from '@oobe-protocol-labs/synapse-client-sdk/ai';
54
+ *
55
+ * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
56
+ * const store = new PostgresPersistence({ client: pool });
57
+ * await store.connect(); // auto-creates tables
58
+ *
59
+ * await store.saveAgent(gateway.snapshot());
60
+ * const receipts = await store.listReceipts('agent-1', { limit: 50 });
61
+ * const stats = await store.getTableStats();
62
+ * ```
63
+ *
64
+ * @example Dual-store pattern (Redis cache + PostgreSQL archive)
65
+ * ```ts
66
+ * import Redis from 'ioredis';
67
+ * import { Pool } from 'pg';
68
+ * import { RedisPersistence, PostgresPersistence } from '@oobe-protocol-labs/synapse-client-sdk/ai';
69
+ *
70
+ * const cache = new RedisPersistence({ client: new Redis(), defaultTtl: 300 });
71
+ * const archive = new PostgresPersistence({ client: new Pool() });
72
+ * await Promise.all([cache.connect(), archive.connect()]);
73
+ *
74
+ * // Write to both, read from cache first
75
+ * async function saveAgent(snapshot) {
76
+ * await Promise.all([cache.saveAgent(snapshot), archive.saveAgent(snapshot)]);
77
+ * }
78
+ *
79
+ * async function loadAgent(id) {
80
+ * return (await cache.loadAgent(id)) ?? archive.loadAgent(id);
81
+ * }
82
+ * ```
83
+ *
84
+ * @since 1.2.2
85
+ */
86
+ export { PersistenceError, type PersistenceStore, type RedisLike, type PgLike, type SessionRecord, type ReceiptRecord, type MetricPoint, type SetOptions, type ListOptions, type MetricQueryOpts, type StoreConfig, type RedisStoreConfig, type PostgresStoreConfig, type MemoryStoreConfig, } from './types';
87
+ export { serialize, deserialize, buildKey, parseKey, extractAgentId, buildSchema, buildKvCleanupSql, SCHEMA_VERSION, } from './helpers';
88
+ export { MemoryStore } from './memory';
89
+ export { RedisPersistence } from './redis';
90
+ export { PostgresPersistence } from './postgresql';
91
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/ai/persistence/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;AAGH,OAAO,EACL,gBAAgB,EAChB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,MAAM,EACX,KAAK,aAAa,EAClB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,mBAAmB,EACxB,KAAK,iBAAiB,GACvB,MAAM,SAAS,CAAC;AAGjB,OAAO,EACL,SAAS,EACT,WAAW,EACX,QAAQ,EACR,QAAQ,EACR,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,cAAc,GACf,MAAM,WAAW,CAAC;AAGnB,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAC3C,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,109 @@
1
+ "use strict";
2
+ /**
3
+ * @module ai/persistence
4
+ * @description Synapse AI Persistence Layer — Redis, PostgreSQL, and in-memory
5
+ * adapters for long-term storage of agent snapshots, sessions, receipts,
6
+ * and metrics.
7
+ *
8
+ * ## Architecture
9
+ *
10
+ * All adapters implement the universal {@link PersistenceStore} interface
11
+ * **and** the `PersistenceAdapter` interface from {@link AgentRegistry},
12
+ * so they work everywhere:
13
+ *
14
+ * ```ts
15
+ * // As a standalone store
16
+ * const store = new RedisPersistence({ client: redis });
17
+ * await store.saveAgent(snapshot);
18
+ *
19
+ * // As AgentRegistry backend
20
+ * const registry = new AgentRegistry({ persistence: store });
21
+ * ```
22
+ *
23
+ * ## Adapters
24
+ *
25
+ * | Adapter | Backing store | Best for |
26
+ * |---|---|---|
27
+ * | {@link MemoryStore} | In-process `Map` | Testing, dev, CLI tools |
28
+ * | {@link RedisPersistence} | Redis / Valkey | Sessions, caching, pub/sub |
29
+ * | {@link PostgresPersistence} | PostgreSQL | Analytics, receipts, audit |
30
+ *
31
+ * ## Dependency injection
32
+ *
33
+ * Redis and PostgreSQL adapters accept a pre-configured client instance
34
+ * via their constructor config. No runtime dependencies are bundled —
35
+ * install `ioredis` or `pg` as needed.
36
+ *
37
+ * @example Redis quick start
38
+ * ```ts
39
+ * import Redis from 'ioredis';
40
+ * import { RedisPersistence } from '@oobe-protocol-labs/synapse-client-sdk/ai';
41
+ *
42
+ * const redis = new Redis(process.env.REDIS_URL);
43
+ * const store = new RedisPersistence({ client: redis, defaultTtl: 3600 });
44
+ * await store.connect();
45
+ *
46
+ * await store.saveAgent(gateway.snapshot());
47
+ * await store.saveSession(sessionRecord);
48
+ * await store.recordMetric('agent-1', 'calls', 42);
49
+ * ```
50
+ *
51
+ * @example PostgreSQL quick start
52
+ * ```ts
53
+ * import { Pool } from 'pg';
54
+ * import { PostgresPersistence } from '@oobe-protocol-labs/synapse-client-sdk/ai';
55
+ *
56
+ * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
57
+ * const store = new PostgresPersistence({ client: pool });
58
+ * await store.connect(); // auto-creates tables
59
+ *
60
+ * await store.saveAgent(gateway.snapshot());
61
+ * const receipts = await store.listReceipts('agent-1', { limit: 50 });
62
+ * const stats = await store.getTableStats();
63
+ * ```
64
+ *
65
+ * @example Dual-store pattern (Redis cache + PostgreSQL archive)
66
+ * ```ts
67
+ * import Redis from 'ioredis';
68
+ * import { Pool } from 'pg';
69
+ * import { RedisPersistence, PostgresPersistence } from '@oobe-protocol-labs/synapse-client-sdk/ai';
70
+ *
71
+ * const cache = new RedisPersistence({ client: new Redis(), defaultTtl: 300 });
72
+ * const archive = new PostgresPersistence({ client: new Pool() });
73
+ * await Promise.all([cache.connect(), archive.connect()]);
74
+ *
75
+ * // Write to both, read from cache first
76
+ * async function saveAgent(snapshot) {
77
+ * await Promise.all([cache.saveAgent(snapshot), archive.saveAgent(snapshot)]);
78
+ * }
79
+ *
80
+ * async function loadAgent(id) {
81
+ * return (await cache.loadAgent(id)) ?? archive.loadAgent(id);
82
+ * }
83
+ * ```
84
+ *
85
+ * @since 1.2.2
86
+ */
87
+ Object.defineProperty(exports, "__esModule", { value: true });
88
+ exports.PostgresPersistence = exports.RedisPersistence = exports.MemoryStore = exports.SCHEMA_VERSION = exports.buildKvCleanupSql = exports.buildSchema = exports.extractAgentId = exports.parseKey = exports.buildKey = exports.deserialize = exports.serialize = exports.PersistenceError = void 0;
89
+ /* ── Types ───────────────────────────────────────────────────── */
90
+ var types_1 = require("./types");
91
+ Object.defineProperty(exports, "PersistenceError", { enumerable: true, get: function () { return types_1.PersistenceError; } });
92
+ /* ── Helpers ─────────────────────────────────────────────────── */
93
+ var helpers_1 = require("./helpers");
94
+ Object.defineProperty(exports, "serialize", { enumerable: true, get: function () { return helpers_1.serialize; } });
95
+ Object.defineProperty(exports, "deserialize", { enumerable: true, get: function () { return helpers_1.deserialize; } });
96
+ Object.defineProperty(exports, "buildKey", { enumerable: true, get: function () { return helpers_1.buildKey; } });
97
+ Object.defineProperty(exports, "parseKey", { enumerable: true, get: function () { return helpers_1.parseKey; } });
98
+ Object.defineProperty(exports, "extractAgentId", { enumerable: true, get: function () { return helpers_1.extractAgentId; } });
99
+ Object.defineProperty(exports, "buildSchema", { enumerable: true, get: function () { return helpers_1.buildSchema; } });
100
+ Object.defineProperty(exports, "buildKvCleanupSql", { enumerable: true, get: function () { return helpers_1.buildKvCleanupSql; } });
101
+ Object.defineProperty(exports, "SCHEMA_VERSION", { enumerable: true, get: function () { return helpers_1.SCHEMA_VERSION; } });
102
+ /* ── Adapters ────────────────────────────────────────────────── */
103
+ var memory_1 = require("./memory");
104
+ Object.defineProperty(exports, "MemoryStore", { enumerable: true, get: function () { return memory_1.MemoryStore; } });
105
+ var redis_1 = require("./redis");
106
+ Object.defineProperty(exports, "RedisPersistence", { enumerable: true, get: function () { return redis_1.RedisPersistence; } });
107
+ var postgresql_1 = require("./postgresql");
108
+ Object.defineProperty(exports, "PostgresPersistence", { enumerable: true, get: function () { return postgresql_1.PostgresPersistence; } });
109
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/ai/persistence/index.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoFG;;;AAEH,oEAAoE;AACpE,iCAeiB;AAdf,yGAAA,gBAAgB,OAAA;AAgBlB,oEAAoE;AACpE,qCASmB;AARjB,oGAAA,SAAS,OAAA;AACT,sGAAA,WAAW,OAAA;AACX,mGAAA,QAAQ,OAAA;AACR,mGAAA,QAAQ,OAAA;AACR,yGAAA,cAAc,OAAA;AACd,sGAAA,WAAW,OAAA;AACX,4GAAA,iBAAiB,OAAA;AACjB,yGAAA,cAAc,OAAA;AAGhB,oEAAoE;AACpE,mCAAuC;AAA9B,qGAAA,WAAW,OAAA;AACpB,iCAA2C;AAAlC,yGAAA,gBAAgB,OAAA;AACzB,2CAAmD;AAA1C,iHAAA,mBAAmB,OAAA"}
@@ -0,0 +1,71 @@
1
+ /**
2
+ * @module ai/persistence/memory
3
+ * @description In-memory persistence store for Synapse AI gateway data.
4
+ *
5
+ * Ideal for testing, local development, and single-process deployments
6
+ * where external database infrastructure is unnecessary.
7
+ *
8
+ * Features:
9
+ * - TTL support on generic key-value entries
10
+ * - Optional max-entries eviction (FIFO)
11
+ * - Full {@link PersistenceStore} API
12
+ * - Drop-in `PersistenceAdapter` for {@link AgentRegistry}
13
+ *
14
+ * @since 1.2.2
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import { MemoryStore } from '@oobe-protocol-labs/synapse-client-sdk/ai';
19
+ *
20
+ * const store = new MemoryStore();
21
+ * await store.connect();
22
+ *
23
+ * await store.saveAgent(gateway.snapshot());
24
+ * const snap = await store.loadAgent('agent-1');
25
+ * ```
26
+ */
27
+ import type { PersistenceStore, MemoryStoreConfig, SetOptions, ListOptions, MetricQueryOpts, SessionRecord, ReceiptRecord, MetricPoint } from './types';
28
+ import type { GatewaySnapshot } from '../gateway/types';
29
+ /**
30
+ * @description In-memory implementation of {@link PersistenceStore}.
31
+ *
32
+ * Data is stored in `Map` instances and does **not** survive process restarts.
33
+ * TTL is checked lazily on read (no background timers).
34
+ *
35
+ * @since 1.2.2
36
+ */
37
+ export declare class MemoryStore implements PersistenceStore {
38
+ readonly name = "memory";
39
+ private readonly maxEntries;
40
+ private readonly kv;
41
+ private readonly agents;
42
+ private readonly sessions;
43
+ private readonly receipts;
44
+ private readonly metrics;
45
+ constructor(config?: MemoryStoreConfig);
46
+ connect(): Promise<void>;
47
+ disconnect(): Promise<void>;
48
+ ping(): Promise<boolean>;
49
+ get<T = unknown>(key: string): Promise<T | null>;
50
+ set(key: string, value: unknown, opts?: SetOptions): Promise<void>;
51
+ del(key: string): Promise<boolean>;
52
+ has(key: string): Promise<boolean>;
53
+ saveAgent(snapshot: GatewaySnapshot): Promise<void>;
54
+ loadAgent(agentId: string): Promise<GatewaySnapshot | null>;
55
+ deleteAgent(agentId: string): Promise<boolean>;
56
+ listAgents(): Promise<string[]>;
57
+ saveSession(record: SessionRecord): Promise<void>;
58
+ loadSession(agentId: string, sessionId: string): Promise<SessionRecord | null>;
59
+ deleteSessions(agentId: string): Promise<number>;
60
+ listSessions(agentId: string, opts?: ListOptions): Promise<SessionRecord[]>;
61
+ saveReceipt(record: ReceiptRecord): Promise<void>;
62
+ listReceipts(agentId: string, opts?: ListOptions): Promise<ReceiptRecord[]>;
63
+ recordMetric(agentId: string, key: string, value: number, labels?: Record<string, string>): Promise<void>;
64
+ queryMetrics(agentId: string, key: string, opts?: MetricQueryOpts): Promise<MetricPoint[]>;
65
+ save(agentId: string, snapshot: GatewaySnapshot): Promise<void>;
66
+ load(agentId: string): Promise<GatewaySnapshot | null>;
67
+ delete(agentId: string): Promise<void>;
68
+ keys(): Promise<string[]>;
69
+ private enforceEviction;
70
+ }
71
+ //# sourceMappingURL=memory.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.d.ts","sourceRoot":"","sources":["../../../../src/ai/persistence/memory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,WAAW,EACX,eAAe,EACf,aAAa,EACb,aAAa,EACb,WAAW,EACZ,MAAM,SAAS,CAAC;AACjB,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AASxD;;;;;;;GAOG;AACH,qBAAa,WAAY,YAAW,gBAAgB;IAClD,QAAQ,CAAC,IAAI,YAAY;IAEzB,OAAO,CAAC,QAAQ,CAAC,UAAU,CAAS;IAGpC,OAAO,CAAC,QAAQ,CAAC,EAAE,CAAoC;IACvD,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAwC;IAC/D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAoC;IAC7D,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAsC;IAC/D,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAqC;gBAEjD,MAAM,GAAE,iBAAsB;IAMpC,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IACxB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC;IAC3B,IAAI,IAAI,OAAO,CAAC,OAAO,CAAC;IAIxB,GAAG,CAAC,CAAC,GAAG,OAAO,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAUhD,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,UAAU,GAAG,OAAO,CAAC,IAAI,CAAC;IASlE,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAIlC,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAYlC,SAAS,CAAC,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAInD,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAI3D,WAAW,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAI9C,UAAU,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAM/B,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAIjD,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,GAAG,IAAI,CAAC;IAI9E,cAAc,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAYhD,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAkB/E,WAAW,CAAC,MAAM,EAAE,aAAa,GAAG,OAAO,CAAC,IAAI,CAAC;IAMjD,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,IAAI,GAAE,WAAgB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAW/E,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAC9B,OAAO,CAAC,IAAI,CAAC;IAOV,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,GAAG,EAAE,MAAM,EACX,IAAI,GAAE,eAAoB,GACzB,OAAO,CAAC,WAAW,EAAE,CAAC;IAgBnB,IAAI,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IAI/D,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC;IAItD,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAM/B,OAAO,CAAC,eAAe;CAOxB"}