@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,141 @@
1
+ /**
2
+ * @module next
3
+ * @description Synapse Client SDK — Next.js integration helpers.
4
+ *
5
+ * Drop-in utilities for using the Synapse SDK in Next.js 13+ (App Router)
6
+ * with zero boilerplate for the most common patterns:
7
+ *
8
+ * - **`synapseResponse()`** — wraps `NextResponse.json()` with BigInt serialization
9
+ * - **`withSynapseError()`** — API Route error boundary / handler wrapper
10
+ * - **`createSynapseProvider()`** — HMR-safe SynapseClient singleton factory
11
+ * - **`createGatewayProvider()`** — HMR-safe AgentGateway singleton factory
12
+ *
13
+ * All exports are framework-independent at the type level: they work with
14
+ * any object that has `json()` and `status` — so they can be tested outside
15
+ * of a Next.js environment.
16
+ *
17
+ * @example API Route (App Router)
18
+ * ```ts
19
+ * // app/api/balance/route.ts
20
+ * import { synapseResponse, withSynapseError, createSynapseProvider } from '@oobe-protocol-labs/synapse-client-sdk/next';
21
+ * import { Pubkey } from '@oobe-protocol-labs/synapse-client-sdk';
22
+ *
23
+ * const getClient = createSynapseProvider({ endpoint: process.env.SYNAPSE_RPC! });
24
+ *
25
+ * export const GET = withSynapseError(async (req) => {
26
+ * const address = new URL(req.url).searchParams.get('address')!;
27
+ * const balance = await getClient().rpc.getBalance(Pubkey(address));
28
+ * return synapseResponse({ balance });
29
+ * });
30
+ * ```
31
+ *
32
+ * @since 1.2.2
33
+ */
34
+ import { type SingletonOptions } from '../utils/helpers';
35
+ import { SynapseClient, type SynapseClientConfig } from '../core/client';
36
+ /**
37
+ * @description Options for {@link synapseResponse}.
38
+ * @since 1.2.2
39
+ */
40
+ export interface SynapseResponseInit {
41
+ /** HTTP status code (default: 200). */
42
+ status?: number;
43
+ /** Extra headers to include. */
44
+ headers?: Record<string, string>;
45
+ }
46
+ /**
47
+ * @description Create a JSON `Response` with automatic BigInt serialization.
48
+ *
49
+ * Works with Next.js App Router, edge functions, or any Web-standard
50
+ * `Response` environment.
51
+ *
52
+ * @param data - Any value (may contain `BigInt`).
53
+ * @param init - Optional status code and headers.
54
+ * @returns A `Response` with `Content-Type: application/json`.
55
+ * @since 1.2.2
56
+ *
57
+ * @example
58
+ * ```ts
59
+ * return synapseResponse({ budget: 100_000n, status: 'ok' });
60
+ * // → Response { body: '{"budget":"100000","status":"ok"}', status: 200 }
61
+ * ```
62
+ */
63
+ export declare function synapseResponse(data: unknown, init?: SynapseResponseInit): Response;
64
+ /**
65
+ * @description Wrap a Next.js API Route handler with error handling.
66
+ *
67
+ * Catches thrown errors and returns a structured JSON error response
68
+ * with the appropriate status code. SDK errors include the error code.
69
+ *
70
+ * @param handler - Async handler function `(req) => Response`
71
+ * @returns Wrapped handler with the same signature
72
+ * @since 1.2.2
73
+ *
74
+ * @example
75
+ * ```ts
76
+ * export const GET = withSynapseError(async (req) => {
77
+ * // If this throws, caller gets { error: '...', code: '...' } with 500
78
+ * const data = await client.rpc.getBalance(Pubkey('...'));
79
+ * return synapseResponse({ data });
80
+ * });
81
+ * ```
82
+ */
83
+ export declare function withSynapseError<T extends Request = Request>(handler: (req: T, ...args: unknown[]) => Promise<Response>): (req: T, ...args: unknown[]) => Promise<Response>;
84
+ /**
85
+ * @description Create an HMR-safe SynapseClient singleton for Next.js.
86
+ *
87
+ * Uses {@link createSingleton} under the hood to store the instance
88
+ * on `globalThis`, surviving hot-module reloads in development.
89
+ *
90
+ * @param config - SynapseClient configuration
91
+ * @param opts - Optional singleton options (version for cache busting)
92
+ * @returns A zero-arg getter that returns the singleton client
93
+ * @since 1.2.2
94
+ *
95
+ * @example
96
+ * ```ts
97
+ * // lib/synapse.ts
98
+ * import { createSynapseProvider } from '@oobe-protocol-labs/synapse-client-sdk/next';
99
+ *
100
+ * export const getSynapseClient = createSynapseProvider({
101
+ * endpoint: process.env.SYNAPSE_RPC!,
102
+ * apiKey: process.env.SYNAPSE_API_KEY,
103
+ * });
104
+ *
105
+ * // Then in any route/server component:
106
+ * const client = getSynapseClient();
107
+ * ```
108
+ */
109
+ export declare function createSynapseProvider(config: SynapseClientConfig, opts?: SingletonOptions): () => SynapseClient;
110
+ /**
111
+ * @description Create an HMR-safe AgentGateway singleton for Next.js.
112
+ *
113
+ * Lazily imports `AgentGateway` to avoid pulling the full AI module
114
+ * into routes that don't need it.
115
+ *
116
+ * @param clientProvider - A getter that returns the SynapseClient (from {@link createSynapseProvider})
117
+ * @param configFactory - Function returning the GatewayConfig (evaluated once)
118
+ * @param opts - Optional singleton options
119
+ * @returns A zero-arg getter that returns the singleton gateway
120
+ * @since 1.2.2
121
+ *
122
+ * @example
123
+ * ```ts
124
+ * import { createSynapseProvider, createGatewayProvider } from '@oobe-protocol-labs/synapse-client-sdk/next';
125
+ * import { AgentId, DEFAULT_TIERS } from '@oobe-protocol-labs/synapse-client-sdk/ai';
126
+ *
127
+ * const getClient = createSynapseProvider({ endpoint: process.env.SYNAPSE_RPC! });
128
+ *
129
+ * export const getGateway = createGatewayProvider(getClient, () => ({
130
+ * identity: {
131
+ * id: AgentId('did:synapse:agent:my-agent'),
132
+ * name: 'My Agent',
133
+ * walletPubkey: process.env.AGENT_WALLET!,
134
+ * createdAt: Date.now(),
135
+ * },
136
+ * defaultTiers: DEFAULT_TIERS,
137
+ * }));
138
+ * ```
139
+ */
140
+ export declare function createGatewayProvider(clientProvider: () => SynapseClient, configFactory: () => import('../ai/gateway/types').GatewayConfig, opts?: SingletonOptions): () => import('../ai/gateway/index').AgentGateway;
141
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/next/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAGH,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,KAAK,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAMzE;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAClC,uCAAuC;IACvC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,gCAAgC;IAChC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CAClC;AAED;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,eAAe,CAC7B,IAAI,EAAE,OAAO,EACb,IAAI,GAAE,mBAAwB,GAC7B,QAAQ,CAUV;AAMD;;;;;;;;;;;;;;;;;;GAkBG;AACH,wBAAgB,gBAAgB,CAAC,CAAC,SAAS,OAAO,GAAG,OAAO,EAC1D,OAAO,EAAE,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,GACzD,CAAC,GAAG,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,QAAQ,CAAC,CAenD;AAMD;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAgB,qBAAqB,CACnC,MAAM,EAAE,mBAAmB,EAC3B,IAAI,CAAC,EAAE,gBAAgB,GACtB,MAAM,aAAa,CAMrB;AAMD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,qBAAqB,CACnC,cAAc,EAAE,MAAM,aAAa,EACnC,aAAa,EAAE,MAAM,OAAO,qBAAqB,EAAE,aAAa,EAChE,IAAI,CAAC,EAAE,gBAAgB,GACtB,MAAM,OAAO,qBAAqB,EAAE,YAAY,CAUlD"}
@@ -0,0 +1,171 @@
1
+ /**
2
+ * @module next
3
+ * @description Synapse Client SDK — Next.js integration helpers.
4
+ *
5
+ * Drop-in utilities for using the Synapse SDK in Next.js 13+ (App Router)
6
+ * with zero boilerplate for the most common patterns:
7
+ *
8
+ * - **`synapseResponse()`** — wraps `NextResponse.json()` with BigInt serialization
9
+ * - **`withSynapseError()`** — API Route error boundary / handler wrapper
10
+ * - **`createSynapseProvider()`** — HMR-safe SynapseClient singleton factory
11
+ * - **`createGatewayProvider()`** — HMR-safe AgentGateway singleton factory
12
+ *
13
+ * All exports are framework-independent at the type level: they work with
14
+ * any object that has `json()` and `status` — so they can be tested outside
15
+ * of a Next.js environment.
16
+ *
17
+ * @example API Route (App Router)
18
+ * ```ts
19
+ * // app/api/balance/route.ts
20
+ * import { synapseResponse, withSynapseError, createSynapseProvider } from '@oobe-protocol-labs/synapse-client-sdk/next';
21
+ * import { Pubkey } from '@oobe-protocol-labs/synapse-client-sdk';
22
+ *
23
+ * const getClient = createSynapseProvider({ endpoint: process.env.SYNAPSE_RPC! });
24
+ *
25
+ * export const GET = withSynapseError(async (req) => {
26
+ * const address = new URL(req.url).searchParams.get('address')!;
27
+ * const balance = await getClient().rpc.getBalance(Pubkey(address));
28
+ * return synapseResponse({ balance });
29
+ * });
30
+ * ```
31
+ *
32
+ * @since 1.2.2
33
+ */
34
+ import { toJsonSafe } from '../utils/helpers.js';
35
+ import { createSingleton } from '../utils/helpers.js';
36
+ import { SynapseClient } from '../core/client.js';
37
+ /**
38
+ * @description Create a JSON `Response` with automatic BigInt serialization.
39
+ *
40
+ * Works with Next.js App Router, edge functions, or any Web-standard
41
+ * `Response` environment.
42
+ *
43
+ * @param data - Any value (may contain `BigInt`).
44
+ * @param init - Optional status code and headers.
45
+ * @returns A `Response` with `Content-Type: application/json`.
46
+ * @since 1.2.2
47
+ *
48
+ * @example
49
+ * ```ts
50
+ * return synapseResponse({ budget: 100_000n, status: 'ok' });
51
+ * // → Response { body: '{"budget":"100000","status":"ok"}', status: 200 }
52
+ * ```
53
+ */
54
+ export function synapseResponse(data, init = {}) {
55
+ const safe = toJsonSafe(data);
56
+ const body = JSON.stringify(safe);
57
+ return new Response(body, {
58
+ status: init.status ?? 200,
59
+ headers: {
60
+ 'Content-Type': 'application/json',
61
+ ...init.headers,
62
+ },
63
+ });
64
+ }
65
+ /* ═══════════════════════════════════════════════════════════════
66
+ * withSynapseError — API Route error boundary
67
+ * ═══════════════════════════════════════════════════════════════ */
68
+ /**
69
+ * @description Wrap a Next.js API Route handler with error handling.
70
+ *
71
+ * Catches thrown errors and returns a structured JSON error response
72
+ * with the appropriate status code. SDK errors include the error code.
73
+ *
74
+ * @param handler - Async handler function `(req) => Response`
75
+ * @returns Wrapped handler with the same signature
76
+ * @since 1.2.2
77
+ *
78
+ * @example
79
+ * ```ts
80
+ * export const GET = withSynapseError(async (req) => {
81
+ * // If this throws, caller gets { error: '...', code: '...' } with 500
82
+ * const data = await client.rpc.getBalance(Pubkey('...'));
83
+ * return synapseResponse({ data });
84
+ * });
85
+ * ```
86
+ */
87
+ export function withSynapseError(handler) {
88
+ return async (req, ...args) => {
89
+ try {
90
+ return await handler(req, ...args);
91
+ }
92
+ catch (err) {
93
+ const message = err instanceof Error ? err.message : String(err);
94
+ const code = err.code ?? 'INTERNAL_ERROR';
95
+ const status = err.status ?? 500;
96
+ return synapseResponse({ error: message, code, timestamp: Date.now() }, { status });
97
+ }
98
+ };
99
+ }
100
+ /* ═══════════════════════════════════════════════════════════════
101
+ * createSynapseProvider — HMR-safe client singleton
102
+ * ═══════════════════════════════════════════════════════════════ */
103
+ /**
104
+ * @description Create an HMR-safe SynapseClient singleton for Next.js.
105
+ *
106
+ * Uses {@link createSingleton} under the hood to store the instance
107
+ * on `globalThis`, surviving hot-module reloads in development.
108
+ *
109
+ * @param config - SynapseClient configuration
110
+ * @param opts - Optional singleton options (version for cache busting)
111
+ * @returns A zero-arg getter that returns the singleton client
112
+ * @since 1.2.2
113
+ *
114
+ * @example
115
+ * ```ts
116
+ * // lib/synapse.ts
117
+ * import { createSynapseProvider } from '@oobe-protocol-labs/synapse-client-sdk/next';
118
+ *
119
+ * export const getSynapseClient = createSynapseProvider({
120
+ * endpoint: process.env.SYNAPSE_RPC!,
121
+ * apiKey: process.env.SYNAPSE_API_KEY,
122
+ * });
123
+ *
124
+ * // Then in any route/server component:
125
+ * const client = getSynapseClient();
126
+ * ```
127
+ */
128
+ export function createSynapseProvider(config, opts) {
129
+ return createSingleton('__synapse_client__', () => new SynapseClient(config), opts);
130
+ }
131
+ /* ═══════════════════════════════════════════════════════════════
132
+ * createGatewayProvider — HMR-safe gateway singleton
133
+ * ═══════════════════════════════════════════════════════════════ */
134
+ /**
135
+ * @description Create an HMR-safe AgentGateway singleton for Next.js.
136
+ *
137
+ * Lazily imports `AgentGateway` to avoid pulling the full AI module
138
+ * into routes that don't need it.
139
+ *
140
+ * @param clientProvider - A getter that returns the SynapseClient (from {@link createSynapseProvider})
141
+ * @param configFactory - Function returning the GatewayConfig (evaluated once)
142
+ * @param opts - Optional singleton options
143
+ * @returns A zero-arg getter that returns the singleton gateway
144
+ * @since 1.2.2
145
+ *
146
+ * @example
147
+ * ```ts
148
+ * import { createSynapseProvider, createGatewayProvider } from '@oobe-protocol-labs/synapse-client-sdk/next';
149
+ * import { AgentId, DEFAULT_TIERS } from '@oobe-protocol-labs/synapse-client-sdk/ai';
150
+ *
151
+ * const getClient = createSynapseProvider({ endpoint: process.env.SYNAPSE_RPC! });
152
+ *
153
+ * export const getGateway = createGatewayProvider(getClient, () => ({
154
+ * identity: {
155
+ * id: AgentId('did:synapse:agent:my-agent'),
156
+ * name: 'My Agent',
157
+ * walletPubkey: process.env.AGENT_WALLET!,
158
+ * createdAt: Date.now(),
159
+ * },
160
+ * defaultTiers: DEFAULT_TIERS,
161
+ * }));
162
+ * ```
163
+ */
164
+ export function createGatewayProvider(clientProvider, configFactory, opts) {
165
+ return createSingleton('__synapse_gateway__', () => {
166
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
167
+ const { AgentGateway } = require('../ai/gateway/index');
168
+ return new AgentGateway(clientProvider(), configFactory());
169
+ }, opts);
170
+ }
171
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/next/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,eAAe,EAAyB,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,aAAa,EAA4B,MAAM,gBAAgB,CAAC;AAiBzE;;;;;;;;;;;;;;;;GA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AoB,EACpB,GAAG,EAAE,CAAC,IAAI,aAAa,CAAC,MAAM,CAAC,EAC/B,IAAI,CACL,CAAC;AACJ,CAAC;AAED;;qEAEqE;AAErE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,MAAM,UAAU,qBAAqB,CACnC,cAAmC,EACnC,aAAgE,EAChE,IAAuB;IAEvB,OAAO,eAAe,CACpB,qBAAqB,EACrB,GAAG,EAAE;QACH,iEAAiE;QACjE,MAAM,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,qBAAqB,CAAyC,CAAC;QAChG,OAAO,IAAI,YAAY,CAAC,cAAc,EAAE,EAAE,aAAa,EAAE,CAAC,CAAC;IAC7D,CAAC,EACD,IAAI,CACL,CAAC;AACJ,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * SDK utility helpers — minimal, zero-dependency.
3
3
  *
4
4
  * Pure functions for common Solana value conversions, validation,
5
- * and async control flow.
5
+ * async control flow, BigInt serialization, and HMR-safe singletons.
6
6
  *
7
7
  * @module utils/helpers
8
8
  * @since 1.0.0
@@ -94,4 +94,82 @@ export declare function chunk<T>(arr: readonly T[], size: number): T[][];
94
94
  * ```
95
95
  */
96
96
  export declare function retry<T>(fn: () => Promise<T>, maxAttempts?: number, baseDelayMs?: number): Promise<T>;
97
+ /**
98
+ * Recursively convert `BigInt` values to `string` so the result is
99
+ * safe for `JSON.stringify()`.
100
+ *
101
+ * Useful in Next.js API Routes, Express handlers, or anywhere you
102
+ * need to serialize gateway / x402 objects that contain `BigInt`
103
+ * fields like `pricePerCall`, `maxBudget`, or `amountCharged`.
104
+ *
105
+ * @param obj - Any value (object, array, primitive, BigInt).
106
+ * @returns A deep clone with every `BigInt` replaced by its string
107
+ * representation.
108
+ * @since 1.2.2
109
+ *
110
+ * @example
111
+ * ```ts
112
+ * import { toJsonSafe } from '@oobe-protocol-labs/synapse-client-sdk/utils';
113
+ *
114
+ * return NextResponse.json(toJsonSafe({ budget: 100_000n, data }));
115
+ * ```
116
+ */
117
+ export declare function toJsonSafe(obj: unknown): unknown;
118
+ /**
119
+ * `JSON.stringify` replacer that converts `BigInt` → `string`.
120
+ *
121
+ * @example
122
+ * ```ts
123
+ * import { bigIntReplacer } from '@oobe-protocol-labs/synapse-client-sdk/utils';
124
+ *
125
+ * const json = JSON.stringify(data, bigIntReplacer);
126
+ * ```
127
+ *
128
+ * @since 1.2.2
129
+ */
130
+ export declare function bigIntReplacer(_key: string, value: unknown): unknown;
131
+ /**
132
+ * Options for {@link createSingleton}.
133
+ * @since 1.2.2
134
+ */
135
+ export interface SingletonOptions {
136
+ /**
137
+ * Bump this number to invalidate a cached instance (e.g. after
138
+ * changing the factory config). The old instance is replaced on
139
+ * the next call.
140
+ */
141
+ version?: number;
142
+ }
143
+ /**
144
+ * Create an HMR-safe singleton accessor.
145
+ *
146
+ * In Next.js (and other HMR-enabled environments) module scope is
147
+ * re-evaluated on every hot reload, destroying any `let` / `const`
148
+ * singleton. This helper stores the instance on `globalThis` so it
149
+ * survives reloads.
150
+ *
151
+ * @typeParam T - Type of the singleton instance.
152
+ * @param key - Unique global key (e.g. `'synapseClient'`).
153
+ * @param factory - Function that creates the instance.
154
+ * @param options - Optional version for cache invalidation.
155
+ * @returns A zero-arg getter that returns the singleton.
156
+ * @since 1.2.2
157
+ *
158
+ * @example
159
+ * ```ts
160
+ * import { createSingleton } from '@oobe-protocol-labs/synapse-client-sdk/utils';
161
+ * import { SynapseClient } from '@oobe-protocol-labs/synapse-client-sdk';
162
+ *
163
+ * export const getSynapseClient = createSingleton('synapseClient', () =>
164
+ * SynapseClient.fromEndpoint({ network: 'mainnet', region: 'US', apiKey: process.env.SYNAPSE_API_KEY! }),
165
+ * );
166
+ *
167
+ * // With version invalidation — bump to recreate:
168
+ * export const getGateway = createSingleton('agentGateway', () =>
169
+ * createAgentGateway(getSynapseClient(), config),
170
+ * { version: 4 },
171
+ * );
172
+ * ```
173
+ */
174
+ export declare function createSingleton<T>(key: string, factory: () => T, options?: SingletonOptions): () => T;
97
175
  //# sourceMappingURL=helpers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGtD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,QAAQ,GAAG,MAAM,KAAG,MACpC,CAAC;AAEzB;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,KAAK,MAAM,KAAG,QACT,CAAC;AAEpC;;;;;;;;GAQG;AACH,eAAO,MAAM,aAAa,GAAI,GAAG,MAAM,KAAG,CAAC,IAAI,MACN,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,GAAI,GAAG,MAAM,KAAG,OACJ,CAAC;AAE1C;;;;;;GAMG;AACH,eAAO,MAAM,KAAK,GAAI,IAAI,MAAM,KAAG,OAAO,CAAC,IAAI,CACV,CAAC;AAEtC;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,KAAK,CAAC,CAAC,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,GAAG,CAAC,EAAE,EAAE,CAM/D;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAsB,KAAK,CAAC,CAAC,EAC3B,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACpB,WAAW,SAAI,EACf,WAAW,SAAM,GAChB,OAAO,CAAC,CAAC,CAAC,CAWZ"}
1
+ {"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAGtD;;;;;;;;;;;GAWG;AACH,eAAO,MAAM,aAAa,GAAI,UAAU,QAAQ,G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function retry(fn, maxAttempts = 3, baseDelayMs = 500) {
104
104
  }
105
105
  throw lastErr;
106
106
  }
107
+ /* ═══════════════════════════════════════════════════════════════
108
+ * BigInt-safe JSON serialization
109
+ * ═══════════════════════════════════════════════════════════════ */
110
+ /**
111
+ * Recursively convert `BigInt` values to `string` so the result is
112
+ * safe for `JSON.stringify()`.
113
+ *
114
+ * Useful in Next.js API Routes, Express handlers, or anywhere you
115
+ * need to serialize gateway / x402 objects that contain `BigInt`
116
+ * fields like `pricePerCall`, `maxBudget`, or `amountCharged`.
117
+ *
118
+ * @param obj - Any value (object, array, primitive, BigInt).
119
+ * @returns A deep clone with every `BigInt` replaced by its string
120
+ * representation.
121
+ * @since 1.2.2
122
+ *
123
+ * @example
124
+ * ```ts
125
+ * import { toJsonSafe } from '@oobe-protocol-labs/synapse-client-sdk/utils';
126
+ *
127
+ * return NextResponse.json(toJsonSafe({ budget: 100_000n, data }));
128
+ * ```
129
+ */
130
+ export function toJsonSafe(obj) {
131
+ if (typeof obj === 'bigint')
132
+ return obj.toString();
133
+ if (obj === null || obj === undefined)
134
+ return obj;
135
+ if (Array.isArray(obj))
136
+ return obj.map(toJsonSafe);
137
+ if (obj instanceof Map) {
138
+ const out = {};
139
+ for (const [k, v] of obj)
140
+ out[String(k)] = toJsonSafe(v);
141
+ return out;
142
+ }
143
+ if (typeof obj === 'object') {
144
+ const out = {};
145
+ for (const [k, v] of Object.entries(obj)) {
146
+ out[k] = toJsonSafe(v);
147
+ }
148
+ return out;
149
+ }
150
+ return obj;
151
+ }
152
+ /**
153
+ * `JSON.stringify` replacer that converts `BigInt` → `string`.
154
+ *
155
+ * @example
156
+ * ```ts
157
+ * import { bigIntReplacer } from '@oobe-protocol-labs/synapse-client-sdk/utils';
158
+ *
159
+ * const json = JSON.stringify(data, bigIntReplacer);
160
+ * ```
161
+ *
162
+ * @since 1.2.2
163
+ */
164
+ export function bigIntReplacer(_key, value) {
165
+ return typeof value === 'bigint' ? value.toString() : value;
166
+ }
167
+ // Shared registry on globalThis — survives HMR reloads.
168
+ const _singletonRegistry = globalThis.__synapse_singletons ??= {};
169
+ /**
170
+ * Create an HMR-safe singleton accessor.
171
+ *
172
+ * In Next.js (and other HMR-enabled environments) module scope is
173
+ * re-evaluated on every hot reload, destroying any `let` / `const`
174
+ * singleton. This helper stores the instance on `globalThis` so it
175
+ * survives reloads.
176
+ *
177
+ * @typeParam T - Type of the singleton instance.
178
+ * @param key - Unique global key (e.g. `'synapseClient'`).
179
+ * @param factory - Function that creates the instance.
180
+ * @param options - Optional version for cache invalidation.
181
+ * @returns A zero-arg getter that returns the singleton.
182
+ * @since 1.2.2
183
+ *
184
+ * @example
185
+ * ```ts
186
+ * import { createSingleton } from '@oobe-protocol-labs/synapse-client-sdk/utils';
187
+ * import { SynapseClient } from '@oobe-protocol-labs/synapse-client-sdk';
188
+ *
189
+ * export const getSynapseClient = createSingleton('synapseClient', () =>
190
+ * SynapseClient.fromEndpoint({ network: 'mainnet', region: 'US', apiKey: process.env.SYNAPSE_API_KEY! }),
191
+ * );
192
+ *
193
+ * // With version invalidation — bump to recreate:
194
+ * export const getGateway = createSingleton('agentGateway', () =>
195
+ * createAgentGateway(getSynapseClient(), config),
196
+ * { version: 4 },
197
+ * );
198
+ * ```
199
+ */
200
+ export function createSingleton(key, factory, options) {
201
+ const versionKey = `${key}__v`;
202
+ return () => {
203
+ const versionMismatch = options?.version != null && _singletonRegistry[versionKey] !== options.version;
204
+ if (!_singletonRegistry[key] || versionMismatch) {
205
+ _singletonRegistry[key] = factory();
206
+ if (options?.version != null) {
207
+ _singletonRegistry[versionKey] = options.version;
208
+ }
209
+ }
210
+ return _singletonRegistry[key];
211
+ };
212
+ }
107
213
  //# sourceMappingURL=helpers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/utils/helpers.ts"],"names":[],"mappings":"AAUA,OAAO,EAAsB,QAAQ,IAAI,UAAU,EAAE,MAAM,eAAe,CAAC;AAE3E;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QACjF,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,IAAI,eAAe,EAAE,CAAC;YAChD,kBAAkB,CAAC,GAAG,CAAC,GAAG,OAAO,EAAE,CAAC;YACpC,IAAI,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,CAAC;gBAC7B,kBAAkB,CAAC,UAAU,CAAC,GAAG,OAAO,CAAC,OAAO,CAAC;YACnD,CAAC;QACH,CAAC;QACD,OAAO,kBAAkB,CAAC,GAAG,CAAM,CAAC;IACtC,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oobe-protocol-labs/synapse-client-sdk",
3
- "version": "1.2.1",
3
+ "version": "1.2.2",
4
4
  "description": "Synapse Client SDK -- Typed Solana RPC gateway with @solana/kit native types, 53 JSON-RPC methods, DAS, WebSocket, gRPC/Geyser parser, signers/wallets, and AI agent tooling (LangChain, x402) | Powered by oobeprotocol.ai (OOBE)",
5
5
  "main": "dist/cjs/index.js",
6
6
  "module": "dist/esm/index.js",
@@ -66,6 +66,11 @@
66
66
  "import": "./dist/esm/ai/lazy.js",
67
67
  "require": "./dist/cjs/ai/lazy.js"
68
68
  },
69
+ "./ai/persistence": {
70
+ "types": "./dist/esm/ai/persistence/index.d.ts",
71
+ "import": "./dist/esm/ai/persistence/index.js",
72
+ "require": "./dist/cjs/ai/persistence/index.js"
73
+ },
69
74
  "./kit": {
70
75
  "types": "./dist/esm/kit/index.d.ts",
71
76
  "import": "./dist/esm/kit/index.js",
@@ -155,6 +160,11 @@
155
160
  "types": "./dist/esm/context/index.d.ts",
156
161
  "import": "./dist/esm/context/index.js",
157
162
  "require": "./dist/cjs/context/index.js"
163
+ },
164
+ "./next": {
165
+ "types": "./dist/esm/next/index.d.ts",
166
+ "import": "./dist/esm/next/index.js",
167
+ "require": "./dist/cjs/next/index.js"
158
168
  }
159
169
  },
160
170
  "files": [
@@ -243,7 +253,9 @@
243
253
  "peerDependencies": {
244
254
  "@langchain/core": ">=0.3.0 <0.4.0",
245
255
  "typescript": ">=5.0.0",
246
- "zod": ">=3.23.0 || >=4.0.0"
256
+ "zod": ">=3.23.0 || >=4.0.0",
257
+ "ioredis": ">=5.0.0",
258
+ "pg": ">=8.0.0"
247
259
  },
248
260
  "peerDependenciesMeta": {
249
261
  "zod": {
@@ -251,6 +263,12 @@
251
263
  },
252
264
  "@langchain/core": {
253
265
  "optional": true
266
+ },
267
+ "ioredis": {
268
+ "optional": true
269
+ },
270
+ "pg": {
271
+ "optional": true
254
272
  }
255
273
  },
256
274
  "engines": {