@oobe-protocol-labs/synapse-client-sdk 1.2.1 → 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 (564) hide show
  1. package/CHANGELOG.md +74 -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/core/client.d.ts +16 -0
  49. package/dist/cjs/core/client.d.ts.map +1 -1
  50. package/dist/cjs/core/client.js +18 -0
  51. package/dist/cjs/core/client.js.map +1 -1
  52. package/dist/cjs/next/index.d.ts +141 -0
  53. package/dist/cjs/next/index.d.ts.map +1 -0
  54. package/dist/cjs/next/index.js +177 -0
  55. package/dist/cjs/next/index.js.map +1 -0
  56. package/dist/cjs/utils/helpers.d.ts +79 -1
  57. package/dist/cjs/utils/helpers.d.ts.map +1 -1
  58. package/dist/cjs/utils/helpers.js +109 -0
  59. package/dist/cjs/utils/helpers.js.map +1 -1
  60. package/dist/docs/assets/navigation.js +1 -1
  61. package/dist/docs/assets/search.js +1 -1
  62. package/dist/docs/classes/AccountReader.html +18 -18
  63. package/dist/docs/classes/AccountsClient.html +10 -10
  64. package/dist/docs/classes/AsyncProviderError.html +4 -4
  65. package/dist/docs/classes/CircularDependencyError.html +4 -4
  66. package/dist/docs/classes/DasClient.html +13 -13
  67. package/dist/docs/classes/GeyserParser.html +17 -17
  68. package/dist/docs/classes/GrpcTransport.html +6 -6
  69. package/dist/docs/classes/HttpTransport.html +4 -4
  70. package/dist/docs/classes/InstructionWriter.html +11 -11
  71. package/dist/docs/classes/MemoryGuard.html +9 -9
  72. package/dist/docs/classes/NetworkError.html +5 -5
  73. package/dist/docs/classes/RefRegistry.html +11 -11
  74. package/dist/docs/classes/RefReleasedError.html +4 -4
  75. package/dist/docs/classes/RpcMethodNotFoundError.html +4 -4
  76. package/dist/docs/classes/ServiceNotFoundError.html +4 -4
  77. package/dist/docs/classes/ServiceRef.html +13 -13
  78. package/dist/docs/classes/SolanaRpc.html +55 -55
  79. package/dist/docs/classes/SynapseClient.html +25 -15
  80. package/dist/docs/classes/SynapseContext.html +27 -27
  81. package/dist/docs/classes/SynapseError.html +4 -4
  82. package/dist/docs/classes/TimeoutError.html +4 -4
  83. package/dist/docs/classes/UpstreamError.html +6 -6
  84. package/dist/docs/classes/WeakServiceRef.html +4 -4
  85. package/dist/docs/classes/WsClient.html +10 -10
  86. package/dist/docs/enums/SynapseNetwork.html +2 -2
  87. package/dist/docs/enums/SynapseRegion.html +2 -2
  88. package/dist/docs/enums/TokenExtensionType.html +2 -2
  89. package/dist/docs/functions/Epoch-1.html +1 -1
  90. package/dist/docs/functions/Lamports-2.html +1 -1
  91. package/dist/docs/functions/Pubkey-1.html +1 -1
  92. package/dist/docs/functions/Sig.html +1 -1
  93. package/dist/docs/functions/Slot-1.html +1 -1
  94. package/dist/docs/functions/UnixTs.html +1 -1
  95. package/dist/docs/functions/autoSelectRegion.html +1 -1
  96. package/dist/docs/functions/autoWire.html +1 -1
  97. package/dist/docs/functions/base58Encode.html +1 -1
  98. package/dist/docs/functions/base64ToBytes.html +1 -1
  99. package/dist/docs/functions/bigIntReplacer.html +6 -0
  100. package/dist/docs/functions/chunk.html +1 -1
  101. package/dist/docs/functions/computeBalanceChanges.html +1 -1
  102. package/dist/docs/functions/computeTokenBalanceChanges.html +1 -1
  103. package/dist/docs/functions/createBareContext.html +1 -1
  104. package/dist/docs/functions/createBinding.html +1 -1
  105. package/dist/docs/functions/createBoundHook.html +1 -1
  106. package/dist/docs/functions/createReactAdapter.html +1 -1
  107. package/dist/docs/functions/createRefHook.html +1 -1
  108. package/dist/docs/functions/createServerMiddleware.html +1 -1
  109. package/dist/docs/functions/createServiceHook.html +1 -1
  110. package/dist/docs/functions/createSingleton.html +15 -0
  111. package/dist/docs/functions/createSynapse.html +1 -1
  112. package/dist/docs/functions/createSynapseContext.html +1 -1
  113. package/dist/docs/functions/createToken.html +1 -1
  114. package/dist/docs/functions/decodeBase58.html +1 -1
  115. package/dist/docs/functions/decodeLookupTable.html +1 -1
  116. package/dist/docs/functions/decodeMint.html +1 -1
  117. package/dist/docs/functions/decodeMultisig.html +1 -1
  118. package/dist/docs/functions/decodeNonceAccount.html +1 -1
  119. package/dist/docs/functions/decodeStakeAccount.html +1 -1
  120. package/dist/docs/functions/decodeToken2022Account.html +1 -1
  121. package/dist/docs/functions/decodeToken2022Mint.html +1 -1
  122. package/dist/docs/functions/decodeTokenAccount.html +1 -1
  123. package/dist/docs/functions/encodeBase58.html +1 -1
  124. package/dist/docs/functions/fetchLookupTable.html +1 -1
  125. package/dist/docs/functions/fetchMint.html +1 -1
  126. package/dist/docs/functions/fetchNonceAccount.html +1 -1
  127. package/dist/docs/functions/fetchStakeAccount.html +1 -1
  128. package/dist/docs/functions/fetchTokenAccount.html +1 -1
  129. package/dist/docs/functions/fetchTokenAccountsByOwner.html +1 -1
  130. package/dist/docs/functions/fromKitAddress.html +1 -1
  131. package/dist/docs/functions/getAccountInfo.html +1 -1
  132. package/dist/docs/functions/getAsset.html +1 -1
  133. package/dist/docs/functions/getAssetBatch.html +1 -1
  134. package/dist/docs/functions/getAssetProof.html +1 -1
  135. package/dist/docs/functions/getAssetProofBatch.html +1 -1
  136. package/dist/docs/functions/getAssetsByAuthority.html +1 -1
  137. package/dist/docs/functions/getAssetsByCreator.html +1 -1
  138. package/dist/docs/functions/getAssetsByGroup.html +1 -1
  139. package/dist/docs/functions/getAssetsByOwner.html +1 -1
  140. package/dist/docs/functions/getBalance.html +1 -1
  141. package/dist/docs/functions/getBlock.html +1 -1
  142. package/dist/docs/functions/getBlockCommitment.html +1 -1
  143. package/dist/docs/functions/getBlockHeight.html +1 -1
  144. package/dist/docs/functions/getBlockProduction.html +1 -1
  145. package/dist/docs/functions/getBlockTime.html +1 -1
  146. package/dist/docs/functions/getBlocks.html +1 -1
  147. package/dist/docs/functions/getBlocksWithLimit.html +1 -1
  148. package/dist/docs/functions/getClusterNodes.html +1 -1
  149. package/dist/docs/functions/getContext.html +1 -1
  150. package/dist/docs/functions/getDecodedAccount.html +1 -1
  151. package/dist/docs/functions/getDecodedAccounts.html +1 -1
  152. package/dist/docs/functions/getEnvironment.html +1 -1
  153. package/dist/docs/functions/getEpochInfo.html +1 -1
  154. package/dist/docs/functions/getEpochSchedule.html +1 -1
  155. package/dist/docs/functions/getFeeForMessage.html +1 -1
  156. package/dist/docs/functions/getFirstAvailableBlock.html +1 -1
  157. package/dist/docs/functions/getGenesisHash.html +1 -1
  158. package/dist/docs/functions/getHealth.html +1 -1
  159. package/dist/docs/functions/getHighestSnapshotSlot.html +1 -1
  160. package/dist/docs/functions/getIdentity.html +1 -1
  161. package/dist/docs/functions/getInflationGovernor.html +1 -1
  162. package/dist/docs/functions/getInflationRate.html +1 -1
  163. package/dist/docs/functions/getInflationReward.html +1 -1
  164. package/dist/docs/functions/getLargestAccounts.html +1 -1
  165. package/dist/docs/functions/getLatestBlockhash.html +1 -1
  166. package/dist/docs/functions/getLeaderSchedule.html +1 -1
  167. package/dist/docs/functions/getMaxRetransmitSlot.html +1 -1
  168. package/dist/docs/functions/getMaxShredInsertSlot.html +1 -1
  169. package/dist/docs/functions/getMinimumBalanceForRentExemption.html +1 -1
  170. package/dist/docs/functions/getMultipleAccounts.html +1 -1
  171. package/dist/docs/functions/getProgramAccounts.html +1 -1
  172. package/dist/docs/functions/getProgramCategory.html +1 -1
  173. package/dist/docs/functions/getRecentPerformanceSamples.html +1 -1
  174. package/dist/docs/functions/getRecentPrioritizationFees.html +1 -1
  175. package/dist/docs/functions/getSignatureStatuses.html +1 -1
  176. package/dist/docs/functions/getSignaturesForAddress.html +1 -1
  177. package/dist/docs/functions/getSignaturesForAsset.html +1 -1
  178. package/dist/docs/functions/getSlot.html +1 -1
  179. package/dist/docs/functions/getSlotLeader.html +1 -1
  180. package/dist/docs/functions/getSlotLeaders.html +1 -1
  181. package/dist/docs/functions/getStakeActivation.html +1 -1
  182. package/dist/docs/functions/getStakeMinimumDelegation.html +1 -1
  183. package/dist/docs/functions/getSupply.html +1 -1
  184. package/dist/docs/functions/getTokenAccountBalance.html +1 -1
  185. package/dist/docs/functions/getTokenAccounts.html +1 -1
  186. package/dist/docs/functions/getTokenAccountsByDelegate.html +1 -1
  187. package/dist/docs/functions/getTokenAccountsByOwner.html +1 -1
  188. package/dist/docs/functions/getTokenLargestAccounts.html +1 -1
  189. package/dist/docs/functions/getTokenSupply.html +1 -1
  190. package/dist/docs/functions/getTransaction.html +1 -1
  191. package/dist/docs/functions/getTransactionCount.html +1 -1
  192. package/dist/docs/functions/getVersion.html +1 -1
  193. package/dist/docs/functions/getVoteAccounts.html +1 -1
  194. package/dist/docs/functions/isBlockhashValid.html +1 -1
  195. package/dist/docs/functions/isBrowser.html +1 -1
  196. package/dist/docs/functions/isDisposable.html +1 -1
  197. package/dist/docs/functions/isProgramInCategory.html +1 -1
  198. package/dist/docs/functions/isServer.html +1 -1
  199. package/dist/docs/functions/isValidPubkey.html +1 -1
  200. package/dist/docs/functions/isValidSignature.html +1 -1
  201. package/dist/docs/functions/lamportsToSol.html +1 -1
  202. package/dist/docs/functions/listEndpoints.html +1 -1
  203. package/dist/docs/functions/listNetworks.html +1 -1
  204. package/dist/docs/functions/listRegions.html +1 -1
  205. package/dist/docs/functions/minimumLedgerSlot.html +1 -1
  206. package/dist/docs/functions/parseAccountUpdate.html +1 -1
  207. package/dist/docs/functions/parseBlockMeta.html +1 -1
  208. package/dist/docs/functions/parseEntry.html +1 -1
  209. package/dist/docs/functions/parseGeyserUpdate.html +1 -1
  210. package/dist/docs/functions/parseSlotUpdate.html +1 -1
  211. package/dist/docs/functions/parseTimestamp.html +1 -1
  212. package/dist/docs/functions/parseTransaction.html +1 -1
  213. package/dist/docs/functions/probeLatency.html +1 -1
  214. package/dist/docs/functions/rawBufferToBase58.html +1 -1
  215. package/dist/docs/functions/rawBufferToBase64.html +1 -1
  216. package/dist/docs/functions/rawBufferToBytes.html +1 -1
  217. package/dist/docs/functions/rawBufferToHex.html +1 -1
  218. package/dist/docs/functions/readonly.html +1 -1
  219. package/dist/docs/functions/readonlySigner.html +1 -1
  220. package/dist/docs/functions/requestAirdrop.html +1 -1
  221. package/dist/docs/functions/resolveEndpoint.html +1 -1
  222. package/dist/docs/functions/resolveProgram.html +1 -1
  223. package/dist/docs/functions/resolveProgramBatch.html +1 -1
  224. package/dist/docs/functions/retry.html +1 -1
  225. package/dist/docs/functions/searchAssets.html +1 -1
  226. package/dist/docs/functions/sendTransaction.html +1 -1
  227. package/dist/docs/functions/setGlobalContext.html +1 -1
  228. package/dist/docs/functions/simulateTransaction.html +1 -1
  229. package/dist/docs/functions/sleep.html +1 -1
  230. package/dist/docs/functions/solToLamports.html +1 -1
  231. package/dist/docs/functions/toClientConfig.html +1 -1
  232. package/dist/docs/functions/toJsonSafe.html +13 -0
  233. package/dist/docs/functions/toKitAddress.html +1 -1
  234. package/dist/docs/functions/toKitInstruction.html +1 -1
  235. package/dist/docs/functions/toKitLamports.html +1 -1
  236. package/dist/docs/functions/toKitSignatureString.html +1 -1
  237. package/dist/docs/functions/tryGetContext.html +1 -1
  238. package/dist/docs/functions/tryUseService.html +1 -1
  239. package/dist/docs/functions/useBoundServices.html +1 -1
  240. package/dist/docs/functions/useService.html +1 -1
  241. package/dist/docs/functions/useSharedRef.html +1 -1
  242. package/dist/docs/functions/withRef.html +1 -1
  243. package/dist/docs/functions/withRefAsync.html +1 -1
  244. package/dist/docs/functions/writable.html +1 -1
  245. package/dist/docs/functions/writableSigner.html +1 -1
  246. package/dist/docs/interfaces/AccountInfo.html +7 -7
  247. package/dist/docs/interfaces/AccountMeta.html +4 -4
  248. package/dist/docs/interfaces/AccountNotification.html +2 -2
  249. package/dist/docs/interfaces/AccountSubParams.html +2 -2
  250. package/dist/docs/interfaces/AddMemoParams.html +5 -5
  251. package/dist/docs/interfaces/AdvanceNonceParams.html +3 -3
  252. package/dist/docs/interfaces/AliasProvider.html +2 -2
  253. package/dist/docs/interfaces/AllocateParams.html +3 -3
  254. package/dist/docs/interfaces/ApproveCheckedParams.html +9 -9
  255. package/dist/docs/interfaces/ApproveParams.html +7 -7
  256. package/dist/docs/interfaces/AssetSignatureInfo.html +2 -2
  257. package/dist/docs/interfaces/AssetSignaturesPage.html +2 -2
  258. package/dist/docs/interfaces/AssignParams.html +3 -3
  259. package/dist/docs/interfaces/AsyncFactoryProvider.html +2 -2
  260. package/dist/docs/interfaces/AuthorizeNonceParams.html +4 -4
  261. package/dist/docs/interfaces/BalanceChange.html +6 -6
  262. package/dist/docs/interfaces/BlockProduction.html +3 -3
  263. package/dist/docs/interfaces/BlockResult.html +2 -2
  264. package/dist/docs/interfaces/BlockReward.html +2 -2
  265. package/dist/docs/interfaces/BlockhashResult.html +2 -2
  266. package/dist/docs/interfaces/BurnCheckedParams.html +8 -8
  267. package/dist/docs/interfaces/BurnParams.html +7 -7
  268. package/dist/docs/interfaces/CallOptions.html +6 -6
  269. package/dist/docs/interfaces/ClassProvider.html +2 -2
  270. package/dist/docs/interfaces/CloseAccountParams.html +6 -6
  271. package/dist/docs/interfaces/ConfirmedTransaction.html +6 -6
  272. package/dist/docs/interfaces/ContactInfo.html +2 -2
  273. package/dist/docs/interfaces/ContextAdapter.html +5 -5
  274. package/dist/docs/interfaces/ContextEvents.html +6 -6
  275. package/dist/docs/interfaces/ContextModule.html +3 -3
  276. package/dist/docs/interfaces/CreateATAParams.html +6 -6
  277. package/dist/docs/interfaces/CreateAccountParams.html +6 -6
  278. package/dist/docs/interfaces/CreateAccountWithSeedParams.html +8 -8
  279. package/dist/docs/interfaces/CreateSynapseContextOpts.html +4 -4
  280. package/dist/docs/interfaces/DasAsset.html +2 -2
  281. package/dist/docs/interfaces/DasAssetProof.html +2 -2
  282. package/dist/docs/interfaces/DasAuthority.html +2 -2
  283. package/dist/docs/interfaces/DasCompression.html +2 -2
  284. package/dist/docs/interfaces/DasContent.html +2 -2
  285. package/dist/docs/interfaces/DasCreator.html +2 -2
  286. package/dist/docs/interfaces/DasFile.html +2 -2
  287. package/dist/docs/interfaces/DasGrouping.html +2 -2
  288. package/dist/docs/interfaces/DasOpts.html +2 -2
  289. package/dist/docs/interfaces/DasOwnership.html +2 -2
  290. package/dist/docs/interfaces/DasPage.html +2 -2
  291. package/dist/docs/interfaces/DasRoyalty.html +2 -2
  292. package/dist/docs/interfaces/DasSearchParams.html +2 -2
  293. package/dist/docs/interfaces/DasSupply.html +2 -2
  294. package/dist/docs/interfaces/DataSlice.html +3 -3
  295. package/dist/docs/interfaces/DecodedAccountResult.html +4 -4
  296. package/dist/docs/interfaces/DecodedLookupTable.html +8 -8
  297. package/dist/docs/interfaces/DecodedMint.html +6 -6
  298. package/dist/docs/interfaces/DecodedMultisig.html +5 -5
  299. package/dist/docs/interfaces/DecodedNonceAccount.html +6 -6
  300. package/dist/docs/interfaces/DecodedStakeAccount.html +2 -2
  301. package/dist/docs/interfaces/DecodedToken2022Account.html +9 -9
  302. package/dist/docs/interfaces/DecodedToken2022Mint.html +6 -6
  303. package/dist/docs/interfaces/DecodedTokenAccount.html +9 -9
  304. package/dist/docs/interfaces/DefaultAccountStateExt.html +2 -2
  305. package/dist/docs/interfaces/Disposable.html +2 -2
  306. package/dist/docs/interfaces/EndpointConnectConfig.html +5 -5
  307. package/dist/docs/interfaces/EpochInfo.html +7 -7
  308. package/dist/docs/interfaces/EpochSchedule.html +2 -2
  309. package/dist/docs/interfaces/FactoryProvider.html +2 -2
  310. package/dist/docs/interfaces/FetchedMint.html +6 -6
  311. package/dist/docs/interfaces/FetchedTokenAccount.html +6 -6
  312. package/dist/docs/interfaces/FreezeThawParams.html +6 -6
  313. package/dist/docs/interfaces/GetAccountInfoOpts.html +6 -6
  314. package/dist/docs/interfaces/GetAssetsByAuthorityParams.html +2 -2
  315. package/dist/docs/interfaces/GetAssetsByCreatorParams.html +2 -2
  316. package/dist/docs/interfaces/GetAssetsByGroupParams.html +2 -2
  317. package/dist/docs/interfaces/GetAssetsByOwnerParams.html +2 -2
  318. package/dist/docs/interfaces/GetBlockOpts.html +6 -6
  319. package/dist/docs/interfaces/GetBlockProductionOpts.html +6 -6
  320. package/dist/docs/interfaces/GetMultipleAccountsOpts.html +6 -6
  321. package/dist/docs/interfaces/GetProgramAccountsOpts.html +6 -6
  322. package/dist/docs/interfaces/GetSignatureStatusesOpts.html +6 -6
  323. package/dist/docs/interfaces/GetSignaturesOpts.html +7 -7
  324. package/dist/docs/interfaces/GetTokenAccountsParams.html +2 -2
  325. package/dist/docs/interfaces/GetTransactionOpts.html +6 -6
  326. package/dist/docs/interfaces/GeyserParserConfig.html +6 -6
  327. package/dist/docs/interfaces/GeyserParserEvents.html +9 -9
  328. package/dist/docs/interfaces/GeyserParserStats.html +2 -2
  329. package/dist/docs/interfaces/GrpcCallOptions.html +2 -2
  330. package/dist/docs/interfaces/GrpcTransportConfig.html +6 -6
  331. package/dist/docs/interfaces/ImmutableOwnerExt.html +2 -2
  332. package/dist/docs/interfaces/InflationGovernor.html +2 -2
  333. package/dist/docs/interfaces/InflationRate.html +2 -2
  334. package/dist/docs/interfaces/InflationReward.html +2 -2
  335. package/dist/docs/interfaces/InitializeAccountParams.html +5 -5
  336. package/dist/docs/interfaces/InitializeMintParams.html +6 -6
  337. package/dist/docs/interfaces/InitializeNonceParams.html +3 -3
  338. package/dist/docs/interfaces/InterestBearingConfigExt.html +2 -2
  339. package/dist/docs/interfaces/LatencyProbeResult.html +2 -2
  340. package/dist/docs/interfaces/LeakReport.html +5 -5
  341. package/dist/docs/interfaces/LogsNotification.html +2 -2
  342. package/dist/docs/interfaces/LogsSubParams.html +2 -2
  343. package/dist/docs/interfaces/MemoTransferExt.html +2 -2
  344. package/dist/docs/interfaces/MemoryGuardConfig.html +4 -4
  345. package/dist/docs/interfaces/MetadataPointerExt.html +2 -2
  346. package/dist/docs/interfaces/MintCloseAuthorityExt.html +2 -2
  347. package/dist/docs/interfaces/MintToCheckedParams.html +8 -8
  348. package/dist/docs/interfaces/MintToParams.html +7 -7
  349. package/dist/docs/interfaces/NonTransferableExt.html +2 -2
  350. package/dist/docs/interfaces/PaginationOpts.html +2 -2
  351. package/dist/docs/interfaces/ParsedAccountUpdate.html +16 -16
  352. package/dist/docs/interfaces/ParsedBlockMeta.html +2 -2
  353. package/dist/docs/interfaces/ParsedEntry.html +2 -2
  354. package/dist/docs/interfaces/ParsedInstruction.html +9 -9
  355. package/dist/docs/interfaces/ParsedSlotUpdate.html +3 -3
  356. package/dist/docs/interfaces/ParsedTransaction.html +19 -19
  357. package/dist/docs/interfaces/PerfSample.html +2 -2
  358. package/dist/docs/interfaces/PermanentDelegateExt.html +2 -2
  359. package/dist/docs/interfaces/ProgramAccount.html +2 -2
  360. package/dist/docs/interfaces/ProgramNotification.html +2 -2
  361. package/dist/docs/interfaces/ProgramSubParams.html +2 -2
  362. package/dist/docs/interfaces/ProgramsBundle.html +33 -33
  363. package/dist/docs/interfaces/RawAccountInfo.html +2 -2
  364. package/dist/docs/interfaces/RawBlockMeta.html +2 -2
  365. package/dist/docs/interfaces/RawBuffer.html +2 -2
  366. package/dist/docs/interfaces/RawCompiledInstruction.html +2 -2
  367. package/dist/docs/interfaces/RawEntry.html +2 -2
  368. package/dist/docs/interfaces/RawGeyserUpdate.html +2 -2
  369. package/dist/docs/interfaces/RawInnerInstruction.html +2 -2
  370. package/dist/docs/interfaces/RawSlotInfo.html +2 -2
  371. package/dist/docs/interfaces/RawTimestamp.html +2 -2
  372. package/dist/docs/interfaces/RawTokenBalance.html +2 -2
  373. package/dist/docs/interfaces/RawTransactionInfo.html +2 -2
  374. package/dist/docs/interfaces/ReactAdapterConfig.html +2 -2
  375. package/dist/docs/interfaces/RecoverNestedParams.html +7 -7
  376. package/dist/docs/interfaces/RefRegistryConfig.html +2 -2
  377. package/dist/docs/interfaces/RefStats.html +7 -7
  378. package/dist/docs/interfaces/RequestHeapFrameParams.html +2 -2
  379. package/dist/docs/interfaces/ResolveMiddleware.html +1 -1
  380. package/dist/docs/interfaces/RevokeParams.html +5 -5
  381. package/dist/docs/interfaces/RootNotification.html +2 -2
  382. package/dist/docs/interfaces/RootSubParams.html +1 -1
  383. package/dist/docs/interfaces/RpcContext.html +2 -2
  384. package/dist/docs/interfaces/RpcError.html +4 -4
  385. package/dist/docs/interfaces/RpcRequest.html +3 -3
  386. package/dist/docs/interfaces/RpcResponse.html +2 -2
  387. package/dist/docs/interfaces/SendTransactionOpts.html +6 -6
  388. package/dist/docs/interfaces/ServerAdapterConfig.html +3 -3
  389. package/dist/docs/interfaces/ServiceBinding.html +6 -6
  390. package/dist/docs/interfaces/ServiceRegistration.html +3 -3
  391. package/dist/docs/interfaces/ServiceResolver.html +6 -6
  392. package/dist/docs/interfaces/ServiceToken.html +4 -4
  393. package/dist/docs/interfaces/SetComputeUnitLimitParams.html +2 -2
  394. package/dist/docs/interfaces/SetComputeUnitPriceParams.html +2 -2
  395. package/dist/docs/interfaces/SetLoadedAccountsDataSizeLimitParams.html +2 -2
  396. package/dist/docs/interfaces/SignatureInfo.html +7 -7
  397. package/dist/docs/interfaces/SignatureNotification.html +2 -2
  398. package/dist/docs/interfaces/SignatureStatus.html +5 -5
  399. package/dist/docs/interfaces/SignatureSubParams.html +2 -2
  400. package/dist/docs/interfaces/SignaturesForAssetParams.html +2 -2
  401. package/dist/docs/interfaces/SimulateResult.html +2 -2
  402. package/dist/docs/interfaces/SimulateTransactionOpts.html +7 -7
  403. package/dist/docs/interfaces/SingletonOptions.html +7 -0
  404. package/dist/docs/interfaces/SlotNotification.html +2 -2
  405. package/dist/docs/interfaces/SlotSubParams.html +1 -1
  406. package/dist/docs/interfaces/SortOpts.html +2 -2
  407. package/dist/docs/interfaces/StakeAuthorized.html +2 -2
  408. package/dist/docs/interfaces/StakeDelegation.html +3 -3
  409. package/dist/docs/interfaces/StakeLockup.html +4 -4
  410. package/dist/docs/interfaces/StakeMeta.html +2 -2
  411. package/dist/docs/interfaces/Supply.html +5 -5
  412. package/dist/docs/interfaces/SynapseClientConfig.html +9 -9
  413. package/dist/docs/interfaces/SynapseClientLike.html +2 -2
  414. package/dist/docs/interfaces/SynapseEndpoint.html +7 -7
  415. package/dist/docs/interfaces/SyncNativeParams.html +3 -3
  416. package/dist/docs/interfaces/SystemTransferParams.html +4 -4
  417. package/dist/docs/interfaces/TokenAccount.html +3 -3
  418. package/dist/docs/interfaces/TokenAccountsByOwnerResult.html +2 -2
  419. package/dist/docs/interfaces/TokenAmount.html +5 -5
  420. package/dist/docs/interfaces/TokenBalanceChange.html +2 -2
  421. package/dist/docs/interfaces/TokenTransferParams.html +7 -7
  422. package/dist/docs/interfaces/TransactionInstruction.html +4 -4
  423. package/dist/docs/interfaces/TransactionMeta.html +11 -11
  424. package/dist/docs/interfaces/TransferCheckedParams.html +9 -9
  425. package/dist/docs/interfaces/TransferFeeAmount.html +2 -2
  426. package/dist/docs/interfaces/TransferFeeConfig.html +2 -2
  427. package/dist/docs/interfaces/TransportConfig.html +7 -7
  428. package/dist/docs/interfaces/UnknownExtension.html +2 -2
  429. package/dist/docs/interfaces/ValueProvider.html +2 -2
  430. package/dist/docs/interfaces/VoteAccount.html +9 -9
  431. package/dist/docs/interfaces/VoteAccountsResult.html +3 -3
  432. package/dist/docs/interfaces/WithdrawNonceParams.html +5 -5
  433. package/dist/docs/interfaces/WsConfig.html +6 -6
  434. package/dist/docs/media/CHANGELOG.md +74 -0
  435. package/dist/docs/modules.html +4 -0
  436. package/dist/docs/types/AccountFetchOpts.html +1 -1
  437. package/dist/docs/types/AccountFilter.html +1 -1
  438. package/dist/docs/types/Base58.html +1 -1
  439. package/dist/docs/types/Brand.html +1 -1
  440. package/dist/docs/types/Commitment.html +1 -1
  441. package/dist/docs/types/DasSortBy.html +1 -1
  442. package/dist/docs/types/DasSortDirection.html +1 -1
  443. package/dist/docs/types/DataSizeFilter.html +1 -1
  444. package/dist/docs/types/DecodedExtension.html +1 -1
  445. package/dist/docs/types/Encoding.html +1 -1
  446. package/dist/docs/types/Epoch.html +1 -1
  447. package/dist/docs/types/Lamports.html +1 -1
  448. package/dist/docs/types/LogsFilter.html +1 -1
  449. package/dist/docs/types/MemcmpFilter.html +1 -1
  450. package/dist/docs/types/NonceState.html +1 -1
  451. package/dist/docs/types/ParsedGeyserUpdate.html +1 -1
  452. package/dist/docs/types/Pubkey.html +1 -1
  453. package/dist/docs/types/RuntimeEnv.html +1 -1
  454. package/dist/docs/types/ServiceLifecycle.html +1 -1
  455. package/dist/docs/types/ServiceProvider.html +1 -1
  456. package/dist/docs/types/Signature.html +1 -1
  457. package/dist/docs/types/Slot.html +1 -1
  458. package/dist/docs/types/StakeAccountType.html +1 -1
  459. package/dist/docs/types/SubscriptionId.html +1 -1
  460. package/dist/docs/types/TokenAccountState.html +1 -1
  461. package/dist/docs/types/TransactionDetail.html +1 -1
  462. package/dist/docs/types/UnaryMethod.html +1 -1
  463. package/dist/docs/types/UnixTimestamp.html +1 -1
  464. package/dist/docs/types/WsNotification.html +1 -1
  465. package/dist/docs/variables/ASSOCIATED_TOKEN_PROGRAM.html +1 -1
  466. package/dist/docs/variables/AssociatedToken.html +4 -4
  467. package/dist/docs/variables/COMPUTE_BUDGET_PROGRAM.html +1 -1
  468. package/dist/docs/variables/ComputeBudget.html +5 -5
  469. package/dist/docs/variables/JUPITER_PROGRAMS.html +1 -1
  470. package/dist/docs/variables/KNOWN_PROGRAMS.html +1 -1
  471. package/dist/docs/variables/KNOWN_PROGRAMS_COUNT.html +1 -1
  472. package/dist/docs/variables/LOOKUP_TABLE_HEADER_SIZE.html +1 -1
  473. package/dist/docs/variables/LOOKUP_TABLE_PROGRAM_ID.html +1 -1
  474. package/dist/docs/variables/MARINADE_PROGRAMS.html +1 -1
  475. package/dist/docs/variables/MAX_MULTISIG_SIGNERS.html +1 -1
  476. package/dist/docs/variables/MEMO_PROGRAM_V1.html +1 -1
  477. package/dist/docs/variables/MEMO_PROGRAM_V2.html +1 -1
  478. package/dist/docs/variables/METAPLEX_PROGRAMS.html +1 -1
  479. package/dist/docs/variables/METEORA_PROGRAMS.html +1 -1
  480. package/dist/docs/variables/MINT_SIZE.html +1 -1
  481. package/dist/docs/variables/MULTISIG_SIZE.html +1 -1
  482. package/dist/docs/variables/Memo.html +2 -2
  483. package/dist/docs/variables/NONCE_ACCOUNT_SIZE.html +1 -1
  484. package/dist/docs/variables/ORCA_PROGRAMS.html +1 -1
  485. package/dist/docs/variables/OTHER_PROGRAMS.html +1 -1
  486. package/dist/docs/variables/RAYDIUM_PROGRAMS.html +1 -1
  487. package/dist/docs/variables/SDK_USER_AGENT.html +1 -1
  488. package/dist/docs/variables/SPL_PROGRAMS.html +1 -1
  489. package/dist/docs/variables/STAKE_PROGRAM_ID.html +1 -1
  490. package/dist/docs/variables/SYNAPSE_DEVNET_EU.html +1 -1
  491. package/dist/docs/variables/SYNAPSE_DEVNET_US.html +1 -1
  492. package/dist/docs/variables/SYNAPSE_ENDPOINTS.html +1 -1
  493. package/dist/docs/variables/SYNAPSE_MAINNET_EU.html +1 -1
  494. package/dist/docs/variables/SYNAPSE_MAINNET_US.html +1 -1
  495. package/dist/docs/variables/SYSTEM_PROGRAM.html +1 -1
  496. package/dist/docs/variables/SYSTEM_PROGRAMS.html +1 -1
  497. package/dist/docs/variables/SYSTEM_PROGRAM_ID.html +1 -1
  498. package/dist/docs/variables/SplToken.html +16 -16
  499. package/dist/docs/variables/SystemProgram.html +10 -10
  500. package/dist/docs/variables/TOKEN_2022_PROGRAM.html +1 -1
  501. package/dist/docs/variables/TOKEN_2022_PROGRAM_ID.html +1 -1
  502. package/dist/docs/variables/TOKEN_ACCOUNT_SIZE.html +1 -1
  503. package/dist/docs/variables/TOKEN_PROGRAM.html +1 -1
  504. package/dist/docs/variables/TOKEN_PROGRAM_ID.html +1 -1
  505. package/dist/docs/variables/Tokens.html +1 -1
  506. package/dist/esm/ai/gateway/index.d.ts +86 -5
  507. package/dist/esm/ai/gateway/index.d.ts.map +1 -1
  508. package/dist/esm/ai/gateway/index.js +275 -39
  509. package/dist/esm/ai/gateway/index.js.map +1 -1
  510. package/dist/esm/ai/gateway/registry.d.ts +223 -0
  511. package/dist/esm/ai/gateway/registry.d.ts.map +1 -0
  512. package/dist/esm/ai/gateway/registry.js +285 -0
  513. package/dist/esm/ai/gateway/registry.js.map +1 -0
  514. package/dist/esm/ai/gateway/types.d.ts +107 -1
  515. package/dist/esm/ai/gateway/types.d.ts.map +1 -1
  516. package/dist/esm/ai/gateway/x402/index.d.ts +2 -4
  517. package/dist/esm/ai/gateway/x402/index.d.ts.map +1 -1
  518. package/dist/esm/ai/gateway/x402/index.js +2 -3
  519. package/dist/esm/ai/gateway/x402/index.js.map +1 -1
  520. package/dist/esm/ai/gateway/x402/registry.d.ts +131 -1
  521. package/dist/esm/ai/gateway/x402/registry.d.ts.map +1 -1
  522. package/dist/esm/ai/gateway/x402/registry.js +227 -0
  523. package/dist/esm/ai/gateway/x402/registry.js.map +1 -1
  524. package/dist/esm/ai/index.d.ts +2 -1
  525. package/dist/esm/ai/index.d.ts.map +1 -1
  526. package/dist/esm/ai/index.js +13 -1
  527. package/dist/esm/ai/index.js.map +1 -1
  528. package/dist/esm/ai/persistence/helpers.d.ts +83 -0
  529. package/dist/esm/ai/persistence/helpers.d.ts.map +1 -0
  530. package/dist/esm/ai/persistence/helpers.js +183 -0
  531. package/dist/esm/ai/persistence/helpers.js.map +1 -0
  532. package/dist/esm/ai/persistence/index.d.ts +91 -0
  533. package/dist/esm/ai/persistence/index.d.ts.map +1 -0
  534. package/dist/esm/ai/persistence/index.js +94 -0
  535. package/dist/esm/ai/persistence/index.js.map +1 -0
  536. package/dist/esm/ai/persistence/memory.d.ts +71 -0
  537. package/dist/esm/ai/persistence/memory.d.ts.map +1 -0
  538. package/dist/esm/ai/persistence/memory.js +188 -0
  539. package/dist/esm/ai/persistence/memory.js.map +1 -0
  540. package/dist/esm/ai/persistence/postgresql.d.ts +119 -0
  541. package/dist/esm/ai/persistence/postgresql.d.ts.map +1 -0
  542. package/dist/esm/ai/persistence/postgresql.js +306 -0
  543. package/dist/esm/ai/persistence/postgresql.js.map +1 -0
  544. package/dist/esm/ai/persistence/redis.d.ts +84 -0
  545. package/dist/esm/ai/persistence/redis.d.ts.map +1 -0
  546. package/dist/esm/ai/persistence/redis.js +237 -0
  547. package/dist/esm/ai/persistence/redis.js.map +1 -0
  548. package/dist/esm/ai/persistence/types.d.ts +267 -0
  549. package/dist/esm/ai/persistence/types.d.ts.map +1 -0
  550. package/dist/esm/ai/persistence/types.js +36 -0
  551. package/dist/esm/ai/persistence/types.js.map +1 -0
  552. package/dist/esm/core/client.d.ts +16 -0
  553. package/dist/esm/core/client.d.ts.map +1 -1
  554. package/dist/esm/core/client.js +18 -0
  555. package/dist/esm/core/client.js.map +1 -1
  556. package/dist/esm/next/index.d.ts +141 -0
  557. package/dist/esm/next/index.d.ts.map +1 -0
  558. package/dist/esm/next/index.js +171 -0
  559. package/dist/esm/next/index.js.map +1 -0
  560. package/dist/esm/utils/helpers.d.ts +79 -1
  561. package/dist/esm/utils/helpers.d.ts.map +1 -1
  562. package/dist/esm/utils/helpers.js +106 -0
  563. package/dist/esm/utils/helpers.js.map +1 -1
  564. package/package.json +20 -2
@@ -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,UAA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,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"}
@@ -0,0 +1,192 @@
1
+ "use strict";
2
+ /**
3
+ * @module ai/persistence/memory
4
+ * @description In-memory persistence store for Synapse AI gateway data.
5
+ *
6
+ * Ideal for testing, local development, and single-process deployments
7
+ * where external database infrastructure is unnecessary.
8
+ *
9
+ * Features:
10
+ * - TTL support on generic key-value entries
11
+ * - Optional max-entries eviction (FIFO)
12
+ * - Full {@link PersistenceStore} API
13
+ * - Drop-in `PersistenceAdapter` for {@link AgentRegistry}
14
+ *
15
+ * @since 1.2.2
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { MemoryStore } from '@oobe-protocol-labs/synapse-client-sdk/ai';
20
+ *
21
+ * const store = new MemoryStore();
22
+ * await store.connect();
23
+ *
24
+ * await store.saveAgent(gateway.snapshot());
25
+ * const snap = await store.loadAgent('agent-1');
26
+ * ```
27
+ */
28
+ Object.defineProperty(exports, "__esModule", { value: true });
29
+ exports.MemoryStore = void 0;
30
+ const helpers_1 = require("./helpers");
31
+ /**
32
+ * @description In-memory implementation of {@link PersistenceStore}.
33
+ *
34
+ * Data is stored in `Map` instances and does **not** survive process restarts.
35
+ * TTL is checked lazily on read (no background timers).
36
+ *
37
+ * @since 1.2.2
38
+ */
39
+ class MemoryStore {
40
+ name = 'memory';
41
+ maxEntries;
42
+ /* ── Storage maps ──────────────────────────────────────── */
43
+ kv = new Map();
44
+ agents = new Map();
45
+ sessions = new Map(); // key = agentId:sessionId
46
+ receipts = new Map(); // key = agentId
47
+ metrics = new Map(); // key = agentId:metricKey
48
+ constructor(config = {}) {
49
+ this.maxEntries = config.maxEntries ?? 0;
50
+ }
51
+ /* ── Lifecycle ─────────────────────────────────────────── */
52
+ async connect() { }
53
+ async disconnect() { }
54
+ async ping() { return true; }
55
+ /* ── Generic KV ────────────────────────────────────────── */
56
+ async get(key) {
57
+ const entry = this.kv.get(key);
58
+ if (!entry)
59
+ return null;
60
+ if (entry.expiresAt && Date.now() > entry.expiresAt) {
61
+ this.kv.delete(key);
62
+ return null;
63
+ }
64
+ return (0, helpers_1.deserialize)(entry.json);
65
+ }
66
+ async set(key, value, opts) {
67
+ this.enforceEviction();
68
+ const entry = { json: (0, helpers_1.serialize)(value) };
69
+ if (opts?.ttl && opts.ttl > 0) {
70
+ entry.expiresAt = Date.now() + opts.ttl * 1000;
71
+ }
72
+ this.kv.set(key, entry);
73
+ }
74
+ async del(key) {
75
+ return this.kv.delete(key);
76
+ }
77
+ async has(key) {
78
+ const entry = this.kv.get(key);
79
+ if (!entry)
80
+ return false;
81
+ if (entry.expiresAt && Date.now() > entry.expiresAt) {
82
+ this.kv.delete(key);
83
+ return false;
84
+ }
85
+ return true;
86
+ }
87
+ /* ── Agents ────────────────────────────────────────────── */
88
+ async saveAgent(snapshot) {
89
+ this.agents.set(snapshot.agentId, snapshot);
90
+ }
91
+ async loadAgent(agentId) {
92
+ return this.agents.get(agentId) ?? null;
93
+ }
94
+ async deleteAgent(agentId) {
95
+ return this.agents.delete(agentId);
96
+ }
97
+ async listAgents() {
98
+ return [...this.agents.keys()];
99
+ }
100
+ /* ── Sessions ──────────────────────────────────────────── */
101
+ async saveSession(record) {
102
+ this.sessions.set(`${record.agentId}:${record.id}`, record);
103
+ }
104
+ async loadSession(agentId, sessionId) {
105
+ return this.sessions.get(`${agentId}:${sessionId}`) ?? null;
106
+ }
107
+ async deleteSessions(agentId) {
108
+ const prefix = `${agentId}:`;
109
+ let count = 0;
110
+ for (const key of this.sessions.keys()) {
111
+ if (key.startsWith(prefix)) {
112
+ this.sessions.delete(key);
113
+ count++;
114
+ }
115
+ }
116
+ return count;
117
+ }
118
+ async listSessions(agentId, opts = {}) {
119
+ const prefix = `${agentId}:`;
120
+ let results = [];
121
+ for (const [key, rec] of this.sessions) {
122
+ if (key.startsWith(prefix)) {
123
+ if (opts.status && rec.status !== opts.status)
124
+ continue;
125
+ results.push(rec);
126
+ }
127
+ }
128
+ // Sort by createdAt descending
129
+ results.sort((a, b) => b.createdAt - a.createdAt);
130
+ const offset = opts.offset ?? 0;
131
+ const limit = opts.limit ?? results.length;
132
+ return results.slice(offset, offset + limit);
133
+ }
134
+ /* ── Receipts ──────────────────────────────────────────── */
135
+ async saveReceipt(record) {
136
+ const list = this.receipts.get(record.agentId) ?? [];
137
+ list.push(record);
138
+ this.receipts.set(record.agentId, list);
139
+ }
140
+ async listReceipts(agentId, opts = {}) {
141
+ const list = this.receipts.get(agentId) ?? [];
142
+ // Sort by settledAt descending (most recent first)
143
+ const sorted = [...list].sort((a, b) => b.settledAt - a.settledAt);
144
+ const offset = opts.offset ?? 0;
145
+ const limit = opts.limit ?? sorted.length;
146
+ return sorted.slice(offset, offset + limit);
147
+ }
148
+ /* ── Metrics ───────────────────────────────────────────── */
149
+ async recordMetric(agentId, key, value, labels) {
150
+ const mk = `${agentId}:${key}`;
151
+ const list = this.metrics.get(mk) ?? [];
152
+ list.push({ timestamp: Date.now(), value, labels });
153
+ this.metrics.set(mk, list);
154
+ }
155
+ async queryMetrics(agentId, key, opts = {}) {
156
+ const mk = `${agentId}:${key}`;
157
+ let points = this.metrics.get(mk) ?? [];
158
+ if (opts.from != null)
159
+ points = points.filter(p => p.timestamp >= opts.from);
160
+ if (opts.to != null)
161
+ points = points.filter(p => p.timestamp <= opts.to);
162
+ // Most recent first
163
+ points = [...points].sort((a, b) => b.timestamp - a.timestamp);
164
+ if (opts.limit != null)
165
+ points = points.slice(0, opts.limit);
166
+ return points;
167
+ }
168
+ /* ── PersistenceAdapter compat ─────────────────────────── */
169
+ async save(agentId, snapshot) {
170
+ return this.saveAgent(snapshot);
171
+ }
172
+ async load(agentId) {
173
+ return this.loadAgent(agentId);
174
+ }
175
+ async delete(agentId) {
176
+ this.agents.delete(agentId);
177
+ }
178
+ async keys() {
179
+ return this.listAgents();
180
+ }
181
+ /* ── Internals ─────────────────────────────────────────── */
182
+ enforceEviction() {
183
+ if (this.maxEntries > 0 && this.kv.size >= this.maxEntries) {
184
+ // FIFO: remove the oldest key
185
+ const firstKey = this.kv.keys().next().value;
186
+ if (firstKey)
187
+ this.kv.delete(firstKey);
188
+ }
189
+ }
190
+ }
191
+ exports.MemoryStore = MemoryStore;
192
+ //# sourceMappingURL=memory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"memory.js","sourceRoot":"","sources":["../../../../src/ai/persistence/memory.ts"],"names":[],"mappings":";AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;;;AAaH,uCAAmD;AAQnD;;;;;;;GAOG;AACH,MAAa,WAAW;IACb,IAAI,GAAG,QAAQ,CAAC;IAER,UAAU,CAAS;IAEpC,8DAA8D;IAC7C,EAAE,GAAS,IAAI,GAAG,EAAmB,CAAC;IACtC,MAAM,GAAK,IAAI,GAAG,EAA2B,CAAC;IAC9C,QAAQ,GAAG,IAAI,GAAG,EAAyB,CAAC,CAAK,0BAA0B;IAC3E,QAAQ,GAAG,IAAI,GAAG,EAA2B,CAAC,CAAG,gBAAgB;IACjE,OAAO,GAAI,IAAI,GAAG,EAAyB,CAAC,CAAK,0BAA0B;IAE5F,YAAY,SAA4B,EAAE;QACx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AAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,UAAU,EAAE,CAAC;IAC3B,CAAC;IAED,8DAA8D;IAEtD,eAAe;QACrB,IAAI,IAAI,CAAC,UAAU,GAAG,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,IAAI,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC;YAC3D,8BAA8B;YAC9B,MAAM,QAAQ,GAAG,IAAI,CAAC,EAAE,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAe,CAAC;YACvD,IAAI,QAAQ;gBAAE,IAAI,CAAC,EAAE,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzC,CAAC;IACH,CAAC;CACF;AA7LD,kCA6LC"}
@@ -0,0 +1,119 @@
1
+ /**
2
+ * @module ai/persistence/postgresql
3
+ * @description PostgreSQL persistence adapter for Synapse AI gateway data.
4
+ *
5
+ * Stores agent snapshots, sessions, receipts, and metric time-series in
6
+ * PostgreSQL using JSONB columns, with automatic schema migration on
7
+ * first `connect()`.
8
+ *
9
+ * Bring your own client — the adapter works with any library that satisfies
10
+ * the {@link PgLike} interface:
11
+ * - **pg** (`new Pool()` or `new Client()`)
12
+ * - **@vercel/postgres** (`createPool()`)
13
+ * - **@neondatabase/serverless** (`neon()`)
14
+ *
15
+ * @since 1.2.2
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * import { Pool } from 'pg';
20
+ * import { PostgresPersistence } from '@oobe-protocol-labs/synapse-client-sdk/ai';
21
+ *
22
+ * const pool = new Pool({ connectionString: process.env.DATABASE_URL });
23
+ * const store = new PostgresPersistence({ client: pool });
24
+ * await store.connect(); // runs migrations
25
+ *
26
+ * await store.saveAgent(gateway.snapshot());
27
+ * const receipts = await store.listReceipts('agent-1', { limit: 50 });
28
+ *
29
+ * // Drop-in for AgentRegistry:
30
+ * const registry = new AgentRegistry({ persistence: store });
31
+ * ```
32
+ */
33
+ import type { PersistenceStore, PostgresStoreConfig, SetOptions, ListOptions, MetricQueryOpts, SessionRecord, ReceiptRecord, MetricPoint } from './types';
34
+ import type { GatewaySnapshot } from '../gateway/types';
35
+ /**
36
+ * @description PostgreSQL implementation of {@link PersistenceStore}.
37
+ *
38
+ * Table layout (default prefix `synapse`):
39
+ * ```
40
+ * synapse_agents (agent_id PK, snapshot JSONB)
41
+ * synapse_sessions (agent_id + id PK, state JSONB, status)
42
+ * synapse_receipts (id PK, agent_id, receipt JSONB)
43
+ * synapse_metrics (id BIGSERIAL, agent_id, metric_key, value, labels, recorded_at)
44
+ * synapse_kv (key PK, value JSONB, expires_at)
45
+ * synapse_schema_version (version PK, applied_at)
46
+ * ```
47
+ *
48
+ * @since 1.2.2
49
+ */
50
+ export declare class PostgresPersistence implements PersistenceStore {
51
+ readonly name = "postgresql";
52
+ private readonly client;
53
+ private readonly prefix;
54
+ private readonly autoMigrate;
55
+ private migrated;
56
+ constructor(config: PostgresStoreConfig);
57
+ connect(): Promise<void>;
58
+ disconnect(): Promise<void>;
59
+ ping(): Promise<boolean>;
60
+ /**
61
+ * @description Run schema migrations.
62
+ *
63
+ * Called automatically on `connect()` if `autoMigrate` is `true` (default).
64
+ * Safe to call multiple times — all DDL uses `IF NOT EXISTS`.
65
+ *
66
+ * @since 1.2.2
67
+ */
68
+ migrate(): Promise<void>;
69
+ private t;
70
+ get<T = unknown>(key: string): Promise<T | null>;
71
+ set(key: string, value: unknown, opts?: SetOptions): Promise<void>;
72
+ del(key: string): Promise<boolean>;
73
+ has(key: string): Promise<boolean>;
74
+ saveAgent(snapshot: GatewaySnapshot): Promise<void>;
75
+ loadAgent(agentId: string): Promise<GatewaySnapshot | null>;
76
+ deleteAgent(agentId: string): Promise<boolean>;
77
+ listAgents(): Promise<string[]>;
78
+ saveSession(record: SessionRecord): Promise<void>;
79
+ loadSession(agentId: string, sessionId: string): Promise<SessionRecord | null>;
80
+ deleteSessions(agentId: string): Promise<number>;
81
+ listSessions(agentId: string, opts?: ListOptions): Promise<SessionRecord[]>;
82
+ saveReceipt(record: ReceiptRecord): Promise<void>;
83
+ listReceipts(agentId: string, opts?: ListOptions): Promise<ReceiptRecord[]>;
84
+ recordMetric(agentId: string, key: string, value: number, labels?: Record<string, string>): Promise<void>;
85
+ queryMetrics(agentId: string, key: string, opts?: MetricQueryOpts): Promise<MetricPoint[]>;
86
+ /**
87
+ * @description Delete expired KV entries and old metric data.
88
+ *
89
+ * Call periodically (e.g. via a cron job) to reclaim storage.
90
+ *
91
+ * @param {object} [opts] - Cleanup options
92
+ * @param {number} [opts.metricsOlderThanDays=90] - Delete metrics older than N days
93
+ * @returns {Promise<{ kvDeleted: number; metricsDeleted: number }>}
94
+ * @since 1.2.2
95
+ */
96
+ cleanup(opts?: {
97
+ metricsOlderThanDays?: number;
98
+ }): Promise<{
99
+ kvDeleted: number;
100
+ metricsDeleted: number;
101
+ }>;
102
+ /**
103
+ * @description Get the currently applied schema version.
104
+ * @returns {Promise<number>} Schema version, or `0` if not yet migrated.
105
+ * @since 1.2.2
106
+ */
107
+ getSchemaVersion(): Promise<number>;
108
+ /**
109
+ * @description Get row counts for all tables (useful for monitoring).
110
+ * @returns {Promise<Record<string, number>>} Table name → row count
111
+ * @since 1.2.2
112
+ */
113
+ getTableStats(): Promise<Record<string, number>>;
114
+ save(agentId: string, snapshot: GatewaySnapshot): Promise<void>;
115
+ load(agentId: string): Promise<GatewaySnapshot | null>;
116
+ delete(agentId: string): Promise<void>;
117
+ keys(): Promise<string[]>;
118
+ }
119
+ //# sourceMappingURL=postgresql.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"postgresql.d.ts","sourceRoot":"","sources":["../../../../src/ai/persistence/postgresql.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,mBAAmB,EAEnB,UAAU,EACV,WAAW,EACX,eAAe,EACf,aAAa,EACb,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