@oobe-protocol-labs/synapse-sap-sdk 0.12.9 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (640) hide show
  1. package/dist/cjs/accounts/index.js +286 -0
  2. package/dist/cjs/accounts/index.js.map +1 -0
  3. package/dist/cjs/client.js +108 -0
  4. package/dist/cjs/client.js.map +1 -0
  5. package/dist/cjs/constants.js +59 -0
  6. package/dist/cjs/constants.js.map +1 -0
  7. package/dist/cjs/errors.js +250 -0
  8. package/dist/cjs/errors.js.map +1 -0
  9. package/dist/cjs/events/index.js +38 -130
  10. package/dist/cjs/events/index.js.map +1 -1
  11. package/dist/cjs/idlTypes.js +4 -0
  12. package/dist/cjs/idlTypes.js.map +1 -0
  13. package/dist/cjs/index.js +75 -241
  14. package/dist/cjs/index.js.map +1 -1
  15. package/dist/cjs/instructions/agent.js +89 -0
  16. package/dist/cjs/instructions/agent.js.map +1 -0
  17. package/dist/cjs/instructions/attestation.js +112 -0
  18. package/dist/cjs/instructions/attestation.js.map +1 -0
  19. package/dist/cjs/instructions/digest.js +28 -0
  20. package/dist/cjs/instructions/digest.js.map +1 -0
  21. package/dist/cjs/instructions/dispute.js +116 -0
  22. package/dist/cjs/instructions/dispute.js.map +1 -0
  23. package/dist/cjs/instructions/escrow.js +101 -0
  24. package/dist/cjs/instructions/escrow.js.map +1 -0
  25. package/dist/cjs/instructions/global.js +28 -0
  26. package/dist/cjs/instructions/global.js.map +1 -0
  27. package/dist/cjs/instructions/index.js +31 -0
  28. package/dist/cjs/instructions/index.js.map +1 -0
  29. package/dist/cjs/instructions/indexing.js +221 -0
  30. package/dist/cjs/instructions/indexing.js.map +1 -0
  31. package/dist/cjs/instructions/misc.js +73 -0
  32. package/dist/cjs/instructions/misc.js.map +1 -0
  33. package/dist/cjs/instructions/session.js +89 -0
  34. package/dist/cjs/instructions/session.js.map +1 -0
  35. package/dist/cjs/instructions/staking.js +132 -0
  36. package/dist/cjs/instructions/staking.js.map +1 -0
  37. package/dist/cjs/instructions/subscription.js +80 -0
  38. package/dist/cjs/instructions/subscription.js.map +1 -0
  39. package/dist/cjs/instructions/tools.js +109 -0
  40. package/dist/cjs/instructions/tools.js.map +1 -0
  41. package/dist/cjs/instructions/vault.js +106 -0
  42. package/dist/cjs/instructions/vault.js.map +1 -0
  43. package/dist/cjs/pdas/index.js +120 -0
  44. package/dist/cjs/pdas/index.js.map +1 -0
  45. package/dist/cjs/types.js +42 -0
  46. package/dist/cjs/types.js.map +1 -0
  47. package/dist/cjs/utils/index.js +29 -75
  48. package/dist/cjs/utils/index.js.map +1 -1
  49. package/dist/cjs/utils/validate.js +236 -0
  50. package/dist/cjs/utils/validate.js.map +1 -0
  51. package/dist/esm/accounts/index.d.ts +11 -0
  52. package/dist/esm/accounts/index.d.ts.map +1 -0
  53. package/dist/esm/accounts/index.js +273 -0
  54. package/dist/esm/accounts/index.js.map +1 -0
  55. package/dist/esm/client.d.ts +55 -0
  56. package/dist/esm/client.d.ts.map +1 -0
  57. package/dist/esm/client.js +70 -0
  58. package/dist/esm/client.js.map +1 -0
  59. package/dist/esm/constants.d.ts +52 -0
  60. package/dist/esm/constants.d.ts.map +1 -0
  61. package/dist/esm/constants.js +56 -0
  62. package/dist/esm/constants.js.map +1 -0
  63. package/dist/esm/errors.d.ts +111 -0
  64. package/dist/esm/errors.d.ts.map +1 -0
  65. package/dist/esm/errors.js +244 -0
  66. package/dist/esm/errors.js.map +1 -0
  67. package/dist/esm/events/index.d.ts +13 -0
  68. package/dist/esm/events/index.d.ts.map +1 -0
  69. package/dist/esm/events/index.js +36 -128
  70. package/dist/esm/events/index.js.map +1 -1
  71. package/dist/esm/idlTypes.d.ts +925 -0
  72. package/dist/esm/idlTypes.d.ts.map +1 -0
  73. package/dist/esm/idlTypes.js +3 -0
  74. package/dist/esm/idlTypes.js.map +1 -0
  75. package/dist/esm/index.d.ts +12 -0
  76. package/dist/esm/index.d.ts.map +1 -0
  77. package/dist/esm/index.js +15 -88
  78. package/dist/esm/index.js.map +1 -1
  79. package/dist/esm/instructions/agent.d.ts +71 -0
  80. package/dist/esm/instructions/agent.d.ts.map +1 -0
  81. package/dist/esm/instructions/agent.js +85 -0
  82. package/dist/esm/instructions/agent.js.map +1 -0
  83. package/dist/esm/instructions/attestation.d.ts +76 -0
  84. package/dist/esm/instructions/attestation.d.ts.map +1 -0
  85. package/dist/esm/instructions/attestation.js +108 -0
  86. package/dist/esm/instructions/attestation.js.map +1 -0
  87. package/dist/esm/instructions/digest.d.ts +20 -0
  88. package/dist/esm/instructions/digest.d.ts.map +1 -0
  89. package/dist/esm/instructions/digest.js +24 -0
  90. package/dist/esm/instructions/digest.js.map +1 -0
  91. package/dist/esm/instructions/dispute.d.ts +81 -0
  92. package/dist/esm/instructions/dispute.d.ts.map +1 -0
  93. package/dist/esm/instructions/dispute.js +112 -0
  94. package/dist/esm/instructions/dispute.js.map +1 -0
  95. package/dist/esm/instructions/escrow.d.ts +79 -0
  96. package/dist/esm/instructions/escrow.d.ts.map +1 -0
  97. package/dist/esm/instructions/escrow.js +97 -0
  98. package/dist/esm/instructions/escrow.js.map +1 -0
  99. package/dist/esm/instructions/global.d.ts +14 -0
  100. package/dist/esm/instructions/global.d.ts.map +1 -0
  101. package/dist/esm/instructions/global.js +24 -0
  102. package/dist/esm/instructions/global.js.map +1 -0
  103. package/dist/esm/instructions/index.d.ts +14 -0
  104. package/dist/esm/instructions/index.d.ts.map +1 -0
  105. package/dist/esm/instructions/index.js +15 -0
  106. package/dist/esm/instructions/index.js.map +1 -0
  107. package/dist/esm/instructions/indexing.d.ts +150 -0
  108. package/dist/esm/instructions/indexing.d.ts.map +1 -0
  109. package/dist/esm/instructions/indexing.js +217 -0
  110. package/dist/esm/instructions/indexing.js.map +1 -0
  111. package/dist/esm/instructions/memory.d.ts +8 -0
  112. package/dist/esm/instructions/memory.d.ts.map +1 -0
  113. package/dist/esm/instructions/memory.js +234 -0
  114. package/dist/esm/instructions/memory.js.map +1 -0
  115. package/dist/esm/instructions/misc.d.ts +50 -0
  116. package/dist/esm/instructions/misc.d.ts.map +1 -0
  117. package/dist/esm/instructions/misc.js +69 -0
  118. package/dist/esm/instructions/misc.js.map +1 -0
  119. package/dist/esm/instructions/session.d.ts +57 -0
  120. package/dist/esm/instructions/session.d.ts.map +1 -0
  121. package/dist/esm/instructions/session.js +85 -0
  122. package/dist/esm/instructions/session.js.map +1 -0
  123. package/dist/esm/instructions/staking.d.ts +85 -0
  124. package/dist/esm/instructions/staking.d.ts.map +1 -0
  125. package/dist/esm/instructions/staking.js +128 -0
  126. package/dist/esm/instructions/staking.js.map +1 -0
  127. package/dist/esm/instructions/subscription.d.ts +50 -0
  128. package/dist/esm/instructions/subscription.d.ts.map +1 -0
  129. package/dist/esm/instructions/subscription.js +76 -0
  130. package/dist/esm/instructions/subscription.js.map +1 -0
  131. package/dist/esm/instructions/tools.d.ts +88 -0
  132. package/dist/esm/instructions/tools.d.ts.map +1 -0
  133. package/dist/esm/instructions/tools.js +105 -0
  134. package/dist/esm/instructions/tools.js.map +1 -0
  135. package/dist/esm/instructions/vault.d.ts +84 -0
  136. package/dist/esm/instructions/vault.d.ts.map +1 -0
  137. package/dist/esm/instructions/vault.js +102 -0
  138. package/dist/esm/instructions/vault.js.map +1 -0
  139. package/dist/esm/pdas/index.d.ts +37 -0
  140. package/dist/esm/pdas/index.d.ts.map +1 -0
  141. package/dist/esm/pdas/index.js +101 -0
  142. package/dist/esm/pdas/index.js.map +1 -0
  143. package/dist/esm/types.d.ts +208 -0
  144. package/dist/esm/types.d.ts.map +1 -0
  145. package/dist/esm/types.js +39 -0
  146. package/dist/esm/types.js.map +1 -0
  147. package/dist/esm/utils/index.d.ts +4 -0
  148. package/dist/esm/utils/index.d.ts.map +1 -0
  149. package/dist/esm/utils/index.js +13 -29
  150. package/dist/esm/utils/index.js.map +1 -1
  151. package/dist/esm/utils/validate.d.ts +66 -0
  152. package/dist/esm/utils/validate.d.ts.map +1 -0
  153. package/dist/esm/utils/validate.js +221 -0
  154. package/dist/esm/utils/validate.js.map +1 -0
  155. package/package.json +59 -183
  156. package/LICENSE +0 -21
  157. package/README.md +0 -986
  158. package/dist/cjs/constants/addresses.js +0 -143
  159. package/dist/cjs/constants/addresses.js.map +0 -1
  160. package/dist/cjs/constants/index.js +0 -64
  161. package/dist/cjs/constants/index.js.map +0 -1
  162. package/dist/cjs/constants/limits.js +0 -161
  163. package/dist/cjs/constants/limits.js.map +0 -1
  164. package/dist/cjs/constants/network.js +0 -81
  165. package/dist/cjs/constants/network.js.map +0 -1
  166. package/dist/cjs/constants/payments.js +0 -137
  167. package/dist/cjs/constants/payments.js.map +0 -1
  168. package/dist/cjs/constants/programs.js +0 -78
  169. package/dist/cjs/constants/programs.js.map +0 -1
  170. package/dist/cjs/constants/seeds.js +0 -76
  171. package/dist/cjs/constants/seeds.js.map +0 -1
  172. package/dist/cjs/core/client.js +0 -546
  173. package/dist/cjs/core/client.js.map +0 -1
  174. package/dist/cjs/core/connection.js +0 -350
  175. package/dist/cjs/core/connection.js.map +0 -1
  176. package/dist/cjs/core/index.js +0 -25
  177. package/dist/cjs/core/index.js.map +0 -1
  178. package/dist/cjs/errors/index.js +0 -334
  179. package/dist/cjs/errors/index.js.map +0 -1
  180. package/dist/cjs/events/geyser.js +0 -295
  181. package/dist/cjs/events/geyser.js.map +0 -1
  182. package/dist/cjs/idl/index.js +0 -63
  183. package/dist/cjs/idl/index.js.map +0 -1
  184. package/dist/cjs/idl/synapse_agent_sap.json +0 -14595
  185. package/dist/cjs/modules/agent.js +0 -272
  186. package/dist/cjs/modules/agent.js.map +0 -1
  187. package/dist/cjs/modules/attestation.js +0 -147
  188. package/dist/cjs/modules/attestation.js.map +0 -1
  189. package/dist/cjs/modules/base.js +0 -128
  190. package/dist/cjs/modules/base.js.map +0 -1
  191. package/dist/cjs/modules/escrow-v2.js +0 -454
  192. package/dist/cjs/modules/escrow-v2.js.map +0 -1
  193. package/dist/cjs/modules/escrow.js +0 -300
  194. package/dist/cjs/modules/escrow.js.map +0 -1
  195. package/dist/cjs/modules/feedback.js +0 -166
  196. package/dist/cjs/modules/feedback.js.map +0 -1
  197. package/dist/cjs/modules/index.js +0 -43
  198. package/dist/cjs/modules/index.js.map +0 -1
  199. package/dist/cjs/modules/indexing.js +0 -375
  200. package/dist/cjs/modules/indexing.js.map +0 -1
  201. package/dist/cjs/modules/ledger.js +0 -234
  202. package/dist/cjs/modules/ledger.js.map +0 -1
  203. package/dist/cjs/modules/receipt.js +0 -148
  204. package/dist/cjs/modules/receipt.js.map +0 -1
  205. package/dist/cjs/modules/staking.js +0 -124
  206. package/dist/cjs/modules/staking.js.map +0 -1
  207. package/dist/cjs/modules/subscription.js +0 -96
  208. package/dist/cjs/modules/subscription.js.map +0 -1
  209. package/dist/cjs/modules/tools.js +0 -319
  210. package/dist/cjs/modules/tools.js.map +0 -1
  211. package/dist/cjs/modules/vault.js +0 -410
  212. package/dist/cjs/modules/vault.js.map +0 -1
  213. package/dist/cjs/parser/client.js +0 -146
  214. package/dist/cjs/parser/client.js.map +0 -1
  215. package/dist/cjs/parser/complete.js +0 -177
  216. package/dist/cjs/parser/complete.js.map +0 -1
  217. package/dist/cjs/parser/index.js +0 -57
  218. package/dist/cjs/parser/index.js.map +0 -1
  219. package/dist/cjs/parser/inner.js +0 -185
  220. package/dist/cjs/parser/inner.js.map +0 -1
  221. package/dist/cjs/parser/instructions.js +0 -114
  222. package/dist/cjs/parser/instructions.js.map +0 -1
  223. package/dist/cjs/parser/transaction.js +0 -153
  224. package/dist/cjs/parser/transaction.js.map +0 -1
  225. package/dist/cjs/parser/types.js +0 -14
  226. package/dist/cjs/parser/types.js.map +0 -1
  227. package/dist/cjs/pda/index.js +0 -672
  228. package/dist/cjs/pda/index.js.map +0 -1
  229. package/dist/cjs/plugin/index.js +0 -952
  230. package/dist/cjs/plugin/index.js.map +0 -1
  231. package/dist/cjs/plugin/protocols.js +0 -282
  232. package/dist/cjs/plugin/protocols.js.map +0 -1
  233. package/dist/cjs/plugin/schemas.js +0 -863
  234. package/dist/cjs/plugin/schemas.js.map +0 -1
  235. package/dist/cjs/postgres/adapter.js +0 -715
  236. package/dist/cjs/postgres/adapter.js.map +0 -1
  237. package/dist/cjs/postgres/index.js +0 -50
  238. package/dist/cjs/postgres/index.js.map +0 -1
  239. package/dist/cjs/postgres/serializers.js +0 -381
  240. package/dist/cjs/postgres/serializers.js.map +0 -1
  241. package/dist/cjs/postgres/sync.js +0 -289
  242. package/dist/cjs/postgres/sync.js.map +0 -1
  243. package/dist/cjs/postgres/types.js +0 -44
  244. package/dist/cjs/postgres/types.js.map +0 -1
  245. package/dist/cjs/registries/builder.js +0 -414
  246. package/dist/cjs/registries/builder.js.map +0 -1
  247. package/dist/cjs/registries/discovery.js +0 -362
  248. package/dist/cjs/registries/discovery.js.map +0 -1
  249. package/dist/cjs/registries/fairscale.js +0 -639
  250. package/dist/cjs/registries/fairscale.js.map +0 -1
  251. package/dist/cjs/registries/index.js +0 -58
  252. package/dist/cjs/registries/index.js.map +0 -1
  253. package/dist/cjs/registries/metaplex-bridge.js +0 -743
  254. package/dist/cjs/registries/metaplex-bridge.js.map +0 -1
  255. package/dist/cjs/registries/session.js +0 -433
  256. package/dist/cjs/registries/session.js.map +0 -1
  257. package/dist/cjs/registries/x402.js +0 -668
  258. package/dist/cjs/registries/x402.js.map +0 -1
  259. package/dist/cjs/types/accounts.js +0 -13
  260. package/dist/cjs/types/accounts.js.map +0 -1
  261. package/dist/cjs/types/common.js +0 -13
  262. package/dist/cjs/types/common.js.map +0 -1
  263. package/dist/cjs/types/endpoint.js +0 -15
  264. package/dist/cjs/types/endpoint.js.map +0 -1
  265. package/dist/cjs/types/enums.js +0 -269
  266. package/dist/cjs/types/enums.js.map +0 -1
  267. package/dist/cjs/types/index.js +0 -41
  268. package/dist/cjs/types/index.js.map +0 -1
  269. package/dist/cjs/types/instructions.js +0 -92
  270. package/dist/cjs/types/instructions.js.map +0 -1
  271. package/dist/cjs/utils/endpoint-validator.js +0 -232
  272. package/dist/cjs/utils/endpoint-validator.js.map +0 -1
  273. package/dist/cjs/utils/escrow-validation.js +0 -219
  274. package/dist/cjs/utils/escrow-validation.js.map +0 -1
  275. package/dist/cjs/utils/hash.js +0 -109
  276. package/dist/cjs/utils/hash.js.map +0 -1
  277. package/dist/cjs/utils/merchant-validator.js +0 -246
  278. package/dist/cjs/utils/merchant-validator.js.map +0 -1
  279. package/dist/cjs/utils/network-normalizer.js +0 -236
  280. package/dist/cjs/utils/network-normalizer.js.map +0 -1
  281. package/dist/cjs/utils/priority-fee.js +0 -215
  282. package/dist/cjs/utils/priority-fee.js.map +0 -1
  283. package/dist/cjs/utils/rpc-strategy.js +0 -239
  284. package/dist/cjs/utils/rpc-strategy.js.map +0 -1
  285. package/dist/cjs/utils/schemas.js +0 -331
  286. package/dist/cjs/utils/schemas.js.map +0 -1
  287. package/dist/cjs/utils/serialization.js +0 -105
  288. package/dist/cjs/utils/serialization.js.map +0 -1
  289. package/dist/cjs/utils/validation.js +0 -36
  290. package/dist/cjs/utils/validation.js.map +0 -1
  291. package/dist/cjs/utils/x402-direct.js +0 -231
  292. package/dist/cjs/utils/x402-direct.js.map +0 -1
  293. package/dist/esm/constants/addresses.js +0 -140
  294. package/dist/esm/constants/addresses.js.map +0 -1
  295. package/dist/esm/constants/index.js +0 -35
  296. package/dist/esm/constants/index.js.map +0 -1
  297. package/dist/esm/constants/limits.js +0 -158
  298. package/dist/esm/constants/limits.js.map +0 -1
  299. package/dist/esm/constants/network.js +0 -78
  300. package/dist/esm/constants/network.js.map +0 -1
  301. package/dist/esm/constants/payments.js +0 -131
  302. package/dist/esm/constants/payments.js.map +0 -1
  303. package/dist/esm/constants/programs.js +0 -75
  304. package/dist/esm/constants/programs.js.map +0 -1
  305. package/dist/esm/constants/seeds.js +0 -73
  306. package/dist/esm/constants/seeds.js.map +0 -1
  307. package/dist/esm/core/client.js +0 -539
  308. package/dist/esm/core/client.js.map +0 -1
  309. package/dist/esm/core/connection.js +0 -345
  310. package/dist/esm/core/connection.js.map +0 -1
  311. package/dist/esm/core/index.js +0 -19
  312. package/dist/esm/core/index.js.map +0 -1
  313. package/dist/esm/errors/index.js +0 -325
  314. package/dist/esm/errors/index.js.map +0 -1
  315. package/dist/esm/events/geyser.js +0 -258
  316. package/dist/esm/events/geyser.js.map +0 -1
  317. package/dist/esm/idl/index.js +0 -57
  318. package/dist/esm/idl/index.js.map +0 -1
  319. package/dist/esm/idl/synapse_agent_sap.json +0 -14595
  320. package/dist/esm/modules/agent.js +0 -268
  321. package/dist/esm/modules/agent.js.map +0 -1
  322. package/dist/esm/modules/attestation.js +0 -143
  323. package/dist/esm/modules/attestation.js.map +0 -1
  324. package/dist/esm/modules/base.js +0 -124
  325. package/dist/esm/modules/base.js.map +0 -1
  326. package/dist/esm/modules/escrow-v2.js +0 -450
  327. package/dist/esm/modules/escrow-v2.js.map +0 -1
  328. package/dist/esm/modules/escrow.js +0 -296
  329. package/dist/esm/modules/escrow.js.map +0 -1
  330. package/dist/esm/modules/feedback.js +0 -162
  331. package/dist/esm/modules/feedback.js.map +0 -1
  332. package/dist/esm/modules/index.js +0 -27
  333. package/dist/esm/modules/index.js.map +0 -1
  334. package/dist/esm/modules/indexing.js +0 -371
  335. package/dist/esm/modules/indexing.js.map +0 -1
  336. package/dist/esm/modules/ledger.js +0 -230
  337. package/dist/esm/modules/ledger.js.map +0 -1
  338. package/dist/esm/modules/receipt.js +0 -144
  339. package/dist/esm/modules/receipt.js.map +0 -1
  340. package/dist/esm/modules/staking.js +0 -120
  341. package/dist/esm/modules/staking.js.map +0 -1
  342. package/dist/esm/modules/subscription.js +0 -92
  343. package/dist/esm/modules/subscription.js.map +0 -1
  344. package/dist/esm/modules/tools.js +0 -315
  345. package/dist/esm/modules/tools.js.map +0 -1
  346. package/dist/esm/modules/vault.js +0 -406
  347. package/dist/esm/modules/vault.js.map +0 -1
  348. package/dist/esm/parser/client.js +0 -142
  349. package/dist/esm/parser/client.js.map +0 -1
  350. package/dist/esm/parser/complete.js +0 -173
  351. package/dist/esm/parser/complete.js.map +0 -1
  352. package/dist/esm/parser/index.js +0 -43
  353. package/dist/esm/parser/index.js.map +0 -1
  354. package/dist/esm/parser/inner.js +0 -180
  355. package/dist/esm/parser/inner.js.map +0 -1
  356. package/dist/esm/parser/instructions.js +0 -109
  357. package/dist/esm/parser/instructions.js.map +0 -1
  358. package/dist/esm/parser/transaction.js +0 -149
  359. package/dist/esm/parser/transaction.js.map +0 -1
  360. package/dist/esm/parser/types.js +0 -13
  361. package/dist/esm/parser/types.js.map +0 -1
  362. package/dist/esm/pda/index.js +0 -638
  363. package/dist/esm/pda/index.js.map +0 -1
  364. package/dist/esm/plugin/index.js +0 -945
  365. package/dist/esm/plugin/index.js.map +0 -1
  366. package/dist/esm/plugin/protocols.js +0 -279
  367. package/dist/esm/plugin/protocols.js.map +0 -1
  368. package/dist/esm/plugin/schemas.js +0 -860
  369. package/dist/esm/plugin/schemas.js.map +0 -1
  370. package/dist/esm/postgres/adapter.js +0 -678
  371. package/dist/esm/postgres/adapter.js.map +0 -1
  372. package/dist/esm/postgres/index.js +0 -27
  373. package/dist/esm/postgres/index.js.map +0 -1
  374. package/dist/esm/postgres/serializers.js +0 -362
  375. package/dist/esm/postgres/serializers.js.map +0 -1
  376. package/dist/esm/postgres/sync.js +0 -285
  377. package/dist/esm/postgres/sync.js.map +0 -1
  378. package/dist/esm/postgres/types.js +0 -41
  379. package/dist/esm/postgres/types.js.map +0 -1
  380. package/dist/esm/registries/builder.js +0 -410
  381. package/dist/esm/registries/builder.js.map +0 -1
  382. package/dist/esm/registries/discovery.js +0 -358
  383. package/dist/esm/registries/discovery.js.map +0 -1
  384. package/dist/esm/registries/fairscale.js +0 -633
  385. package/dist/esm/registries/fairscale.js.map +0 -1
  386. package/dist/esm/registries/index.js +0 -46
  387. package/dist/esm/registries/index.js.map +0 -1
  388. package/dist/esm/registries/metaplex-bridge.js +0 -706
  389. package/dist/esm/registries/metaplex-bridge.js.map +0 -1
  390. package/dist/esm/registries/session.js +0 -429
  391. package/dist/esm/registries/session.js.map +0 -1
  392. package/dist/esm/registries/x402.js +0 -664
  393. package/dist/esm/registries/x402.js.map +0 -1
  394. package/dist/esm/types/accounts.js +0 -12
  395. package/dist/esm/types/accounts.js.map +0 -1
  396. package/dist/esm/types/common.js +0 -12
  397. package/dist/esm/types/common.js.map +0 -1
  398. package/dist/esm/types/endpoint.js +0 -14
  399. package/dist/esm/types/endpoint.js.map +0 -1
  400. package/dist/esm/types/enums.js +0 -266
  401. package/dist/esm/types/enums.js.map +0 -1
  402. package/dist/esm/types/index.js +0 -25
  403. package/dist/esm/types/index.js.map +0 -1
  404. package/dist/esm/types/instructions.js +0 -89
  405. package/dist/esm/types/instructions.js.map +0 -1
  406. package/dist/esm/utils/endpoint-validator.js +0 -226
  407. package/dist/esm/utils/endpoint-validator.js.map +0 -1
  408. package/dist/esm/utils/escrow-validation.js +0 -212
  409. package/dist/esm/utils/escrow-validation.js.map +0 -1
  410. package/dist/esm/utils/hash.js +0 -103
  411. package/dist/esm/utils/hash.js.map +0 -1
  412. package/dist/esm/utils/merchant-validator.js +0 -241
  413. package/dist/esm/utils/merchant-validator.js.map +0 -1
  414. package/dist/esm/utils/network-normalizer.js +0 -229
  415. package/dist/esm/utils/network-normalizer.js.map +0 -1
  416. package/dist/esm/utils/priority-fee.js +0 -209
  417. package/dist/esm/utils/priority-fee.js.map +0 -1
  418. package/dist/esm/utils/rpc-strategy.js +0 -231
  419. package/dist/esm/utils/rpc-strategy.js.map +0 -1
  420. package/dist/esm/utils/schemas.js +0 -320
  421. package/dist/esm/utils/schemas.js.map +0 -1
  422. package/dist/esm/utils/serialization.js +0 -98
  423. package/dist/esm/utils/serialization.js.map +0 -1
  424. package/dist/esm/utils/validation.js +0 -33
  425. package/dist/esm/utils/validation.js.map +0 -1
  426. package/dist/esm/utils/x402-direct.js +0 -228
  427. package/dist/esm/utils/x402-direct.js.map +0 -1
  428. package/dist/types/constants/addresses.d.ts +0 -117
  429. package/dist/types/constants/addresses.d.ts.map +0 -1
  430. package/dist/types/constants/index.d.ts +0 -31
  431. package/dist/types/constants/index.d.ts.map +0 -1
  432. package/dist/types/constants/limits.d.ts +0 -149
  433. package/dist/types/constants/limits.d.ts.map +0 -1
  434. package/dist/types/constants/network.d.ts +0 -81
  435. package/dist/types/constants/network.d.ts.map +0 -1
  436. package/dist/types/constants/payments.d.ts +0 -121
  437. package/dist/types/constants/payments.d.ts.map +0 -1
  438. package/dist/types/constants/programs.d.ts +0 -69
  439. package/dist/types/constants/programs.d.ts.map +0 -1
  440. package/dist/types/constants/seeds.d.ts +0 -80
  441. package/dist/types/constants/seeds.d.ts.map +0 -1
  442. package/dist/types/core/client.d.ts +0 -452
  443. package/dist/types/core/client.d.ts.map +0 -1
  444. package/dist/types/core/connection.d.ts +0 -305
  445. package/dist/types/core/connection.d.ts.map +0 -1
  446. package/dist/types/core/index.d.ts +0 -20
  447. package/dist/types/core/index.d.ts.map +0 -1
  448. package/dist/types/errors/index.d.ts +0 -276
  449. package/dist/types/errors/index.d.ts.map +0 -1
  450. package/dist/types/events/geyser.d.ts +0 -150
  451. package/dist/types/events/geyser.d.ts.map +0 -1
  452. package/dist/types/events/index.d.ts +0 -248
  453. package/dist/types/events/index.d.ts.map +0 -1
  454. package/dist/types/idl/index.d.ts +0 -70
  455. package/dist/types/idl/index.d.ts.map +0 -1
  456. package/dist/types/index.d.ts +0 -85
  457. package/dist/types/index.d.ts.map +0 -1
  458. package/dist/types/modules/agent.d.ts +0 -166
  459. package/dist/types/modules/agent.d.ts.map +0 -1
  460. package/dist/types/modules/attestation.d.ts +0 -96
  461. package/dist/types/modules/attestation.d.ts.map +0 -1
  462. package/dist/types/modules/base.d.ts +0 -126
  463. package/dist/types/modules/base.d.ts.map +0 -1
  464. package/dist/types/modules/escrow-v2.d.ts +0 -100
  465. package/dist/types/modules/escrow-v2.d.ts.map +0 -1
  466. package/dist/types/modules/escrow.d.ts +0 -168
  467. package/dist/types/modules/escrow.d.ts.map +0 -1
  468. package/dist/types/modules/feedback.d.ts +0 -105
  469. package/dist/types/modules/feedback.d.ts.map +0 -1
  470. package/dist/types/modules/index.d.ts +0 -28
  471. package/dist/types/modules/index.d.ts.map +0 -1
  472. package/dist/types/modules/indexing.d.ts +0 -200
  473. package/dist/types/modules/indexing.d.ts.map +0 -1
  474. package/dist/types/modules/ledger.d.ts +0 -150
  475. package/dist/types/modules/ledger.d.ts.map +0 -1
  476. package/dist/types/modules/receipt.d.ts +0 -77
  477. package/dist/types/modules/receipt.d.ts.map +0 -1
  478. package/dist/types/modules/staking.d.ts +0 -51
  479. package/dist/types/modules/staking.d.ts.map +0 -1
  480. package/dist/types/modules/subscription.d.ts +0 -33
  481. package/dist/types/modules/subscription.d.ts.map +0 -1
  482. package/dist/types/modules/tools.d.ts +0 -182
  483. package/dist/types/modules/tools.d.ts.map +0 -1
  484. package/dist/types/modules/vault.d.ts +0 -240
  485. package/dist/types/modules/vault.d.ts.map +0 -1
  486. package/dist/types/parser/client.d.ts +0 -123
  487. package/dist/types/parser/client.d.ts.map +0 -1
  488. package/dist/types/parser/complete.d.ts +0 -90
  489. package/dist/types/parser/complete.d.ts.map +0 -1
  490. package/dist/types/parser/index.d.ts +0 -40
  491. package/dist/types/parser/index.d.ts.map +0 -1
  492. package/dist/types/parser/inner.d.ts +0 -114
  493. package/dist/types/parser/inner.d.ts.map +0 -1
  494. package/dist/types/parser/instructions.d.ts +0 -76
  495. package/dist/types/parser/instructions.d.ts.map +0 -1
  496. package/dist/types/parser/transaction.d.ts +0 -77
  497. package/dist/types/parser/transaction.d.ts.map +0 -1
  498. package/dist/types/parser/types.d.ts +0 -154
  499. package/dist/types/parser/types.d.ts.map +0 -1
  500. package/dist/types/pda/index.d.ts +0 -510
  501. package/dist/types/pda/index.d.ts.map +0 -1
  502. package/dist/types/plugin/index.d.ts +0 -171
  503. package/dist/types/plugin/index.d.ts.map +0 -1
  504. package/dist/types/plugin/protocols.d.ts +0 -152
  505. package/dist/types/plugin/protocols.d.ts.map +0 -1
  506. package/dist/types/plugin/schemas.d.ts +0 -829
  507. package/dist/types/plugin/schemas.d.ts.map +0 -1
  508. package/dist/types/postgres/adapter.d.ts +0 -355
  509. package/dist/types/postgres/adapter.d.ts.map +0 -1
  510. package/dist/types/postgres/index.d.ts +0 -24
  511. package/dist/types/postgres/index.d.ts.map +0 -1
  512. package/dist/types/postgres/serializers.d.ts +0 -30
  513. package/dist/types/postgres/serializers.d.ts.map +0 -1
  514. package/dist/types/postgres/sync.d.ts +0 -156
  515. package/dist/types/postgres/sync.d.ts.map +0 -1
  516. package/dist/types/postgres/types.d.ts +0 -167
  517. package/dist/types/postgres/types.d.ts.map +0 -1
  518. package/dist/types/registries/builder.d.ts +0 -340
  519. package/dist/types/registries/builder.d.ts.map +0 -1
  520. package/dist/types/registries/discovery.d.ts +0 -333
  521. package/dist/types/registries/discovery.d.ts.map +0 -1
  522. package/dist/types/registries/fairscale.d.ts +0 -680
  523. package/dist/types/registries/fairscale.d.ts.map +0 -1
  524. package/dist/types/registries/index.d.ts +0 -52
  525. package/dist/types/registries/index.d.ts.map +0 -1
  526. package/dist/types/registries/metaplex-bridge.d.ts +0 -488
  527. package/dist/types/registries/metaplex-bridge.d.ts.map +0 -1
  528. package/dist/types/registries/session.d.ts +0 -323
  529. package/dist/types/registries/session.d.ts.map +0 -1
  530. package/dist/types/registries/x402.d.ts +0 -530
  531. package/dist/types/registries/x402.d.ts.map +0 -1
  532. package/dist/types/types/accounts.d.ts +0 -765
  533. package/dist/types/types/accounts.d.ts.map +0 -1
  534. package/dist/types/types/common.d.ts +0 -166
  535. package/dist/types/types/common.d.ts.map +0 -1
  536. package/dist/types/types/endpoint.d.ts +0 -161
  537. package/dist/types/types/endpoint.d.ts.map +0 -1
  538. package/dist/types/types/enums.d.ts +0 -353
  539. package/dist/types/types/enums.d.ts.map +0 -1
  540. package/dist/types/types/index.d.ts +0 -29
  541. package/dist/types/types/index.d.ts.map +0 -1
  542. package/dist/types/types/instructions.d.ts +0 -400
  543. package/dist/types/types/instructions.d.ts.map +0 -1
  544. package/dist/types/utils/endpoint-validator.d.ts +0 -110
  545. package/dist/types/utils/endpoint-validator.d.ts.map +0 -1
  546. package/dist/types/utils/escrow-validation.d.ts +0 -145
  547. package/dist/types/utils/escrow-validation.d.ts.map +0 -1
  548. package/dist/types/utils/hash.d.ts +0 -75
  549. package/dist/types/utils/hash.d.ts.map +0 -1
  550. package/dist/types/utils/index.d.ts +0 -33
  551. package/dist/types/utils/index.d.ts.map +0 -1
  552. package/dist/types/utils/merchant-validator.d.ts +0 -176
  553. package/dist/types/utils/merchant-validator.d.ts.map +0 -1
  554. package/dist/types/utils/network-normalizer.d.ts +0 -120
  555. package/dist/types/utils/network-normalizer.d.ts.map +0 -1
  556. package/dist/types/utils/priority-fee.d.ts +0 -205
  557. package/dist/types/utils/priority-fee.d.ts.map +0 -1
  558. package/dist/types/utils/rpc-strategy.d.ts +0 -172
  559. package/dist/types/utils/rpc-strategy.d.ts.map +0 -1
  560. package/dist/types/utils/schemas.d.ts +0 -351
  561. package/dist/types/utils/schemas.d.ts.map +0 -1
  562. package/dist/types/utils/serialization.d.ts +0 -69
  563. package/dist/types/utils/serialization.d.ts.map +0 -1
  564. package/dist/types/utils/validation.d.ts +0 -29
  565. package/dist/types/utils/validation.d.ts.map +0 -1
  566. package/dist/types/utils/x402-direct.d.ts +0 -114
  567. package/dist/types/utils/x402-direct.d.ts.map +0 -1
  568. package/src/constants/addresses.ts +0 -162
  569. package/src/constants/index.ts +0 -69
  570. package/src/constants/limits.ts +0 -165
  571. package/src/constants/network.ts +0 -89
  572. package/src/constants/payments.ts +0 -145
  573. package/src/constants/programs.ts +0 -83
  574. package/src/constants/seeds.ts +0 -85
  575. package/src/core/client.ts +0 -583
  576. package/src/core/connection.ts +0 -461
  577. package/src/core/index.ts +0 -20
  578. package/src/errors/index.ts +0 -346
  579. package/src/events/geyser.ts +0 -384
  580. package/src/events/index.ts +0 -335
  581. package/src/events/yellowstone.d.ts +0 -7
  582. package/src/idl/index.ts +0 -76
  583. package/src/idl/synapse_agent_sap.json +0 -14595
  584. package/src/index.ts +0 -421
  585. package/src/modules/agent.ts +0 -319
  586. package/src/modules/attestation.ts +0 -168
  587. package/src/modules/base.ts +0 -158
  588. package/src/modules/escrow-v2.ts +0 -658
  589. package/src/modules/escrow.ts +0 -383
  590. package/src/modules/feedback.ts +0 -186
  591. package/src/modules/index.ts +0 -28
  592. package/src/modules/indexing.ts +0 -444
  593. package/src/modules/ledger.ts +0 -262
  594. package/src/modules/receipt.ts +0 -212
  595. package/src/modules/staking.ts +0 -157
  596. package/src/modules/subscription.ts +0 -147
  597. package/src/modules/tools.ts +0 -411
  598. package/src/modules/vault.ts +0 -533
  599. package/src/parser/client.ts +0 -211
  600. package/src/parser/complete.ts +0 -232
  601. package/src/parser/index.ts +0 -71
  602. package/src/parser/inner.ts +0 -255
  603. package/src/parser/instructions.ts +0 -135
  604. package/src/parser/transaction.ts +0 -200
  605. package/src/parser/types.ts +0 -182
  606. package/src/pda/index.ts +0 -919
  607. package/src/plugin/index.ts +0 -1224
  608. package/src/plugin/protocols.ts +0 -404
  609. package/src/plugin/schemas.ts +0 -941
  610. package/src/postgres/adapter.ts +0 -904
  611. package/src/postgres/index.ts +0 -59
  612. package/src/postgres/schema.sql +0 -683
  613. package/src/postgres/serializers.ts +0 -485
  614. package/src/postgres/sync.ts +0 -340
  615. package/src/postgres/types.ts +0 -245
  616. package/src/registries/builder.ts +0 -607
  617. package/src/registries/discovery.ts +0 -572
  618. package/src/registries/fairscale.ts +0 -1278
  619. package/src/registries/index.ts +0 -143
  620. package/src/registries/metaplex-bridge.ts +0 -1199
  621. package/src/registries/session.ts +0 -613
  622. package/src/registries/x402.ts +0 -1048
  623. package/src/types/accounts.ts +0 -858
  624. package/src/types/common.ts +0 -187
  625. package/src/types/endpoint.ts +0 -181
  626. package/src/types/enums.ts +0 -333
  627. package/src/types/index.ts +0 -121
  628. package/src/types/instructions.ts +0 -453
  629. package/src/utils/endpoint-validator.ts +0 -300
  630. package/src/utils/escrow-validation.ts +0 -301
  631. package/src/utils/hash.ts +0 -113
  632. package/src/utils/index.ts +0 -102
  633. package/src/utils/merchant-validator.ts +0 -359
  634. package/src/utils/network-normalizer.ts +0 -240
  635. package/src/utils/priority-fee.ts +0 -325
  636. package/src/utils/rpc-strategy.ts +0 -322
  637. package/src/utils/schemas.ts +0 -359
  638. package/src/utils/serialization.ts +0 -98
  639. package/src/utils/validation.ts +0 -36
  640. package/src/utils/x402-direct.ts +0 -370
@@ -1,945 +0,0 @@
1
- /**
2
- * @module plugin
3
- * @description SynapsePlugin adapter for SAP v2.
4
- *
5
- * Exposes 52 tools across 8 on-chain protocol domains as a drop-in
6
- * `SynapsePlugin` for `SynapseAgentKit`:
7
- *
8
- * ```ts
9
- * import { SynapseAgentKit } from '@oobe-protocol-labs/synapse-client-sdk/ai/plugins';
10
- * import { createSAPPlugin } from '@synapse-sap/sdk/plugin';
11
- *
12
- * const sapPlugin = createSAPPlugin({ provider });
13
- * const kit = new SynapseAgentKit({ rpcUrl })
14
- * .use(sapPlugin);
15
- *
16
- * const tools = kit.getTools(); // → StructuredTool[] (LangChain)
17
- * ```
18
- *
19
- * Architecture:
20
- * 1. Schemas (Zod) → runtime validation + LLM-friendly descriptions
21
- * 2. Protocols → 8 domain method registries (agent, feedback, …)
22
- * 3. Executor → dispatches tool calls to SapClient module methods
23
- * 4. Serialization → PublicKey↔string, BN↔string bridging
24
- *
25
- * @category Plugin
26
- * @since v0.1.0
27
- */
28
- import { PublicKey } from "@solana/web3.js";
29
- import BN from "bn.js";
30
- import { SapClient } from "../core/client";
31
- import { SAP_PROTOCOLS, } from "./protocols";
32
- import { deriveAgent, deriveVault, deriveSession, deriveLedger } from "../pda";
33
- import { hashToArray, sha256 } from "../utils";
34
- // ═══════════════════════════════════════════════════════════════════
35
- // Version
36
- // ═══════════════════════════════════════════════════════════════════
37
- /**
38
- * Current SAP plugin version string.
39
- *
40
- * @name SAP_PLUGIN_VERSION
41
- * @description Semver version embedded in the plugin’s {@link PluginMeta}.
42
- * @internal
43
- * @since v0.1.0
44
- */
45
- const SAP_PLUGIN_VERSION = "0.1.0";
46
- // ═══════════════════════════════════════════════════════════════════
47
- // Serialization Helpers
48
- // ═══════════════════════════════════════════════════════════════════
49
- /**
50
- * Convert a base58 string to PublicKey.
51
- *
52
- * @name toPubkey
53
- * @description Returns `undefined` for nullish input, otherwise wraps
54
- * the base58 string in a Solana `PublicKey`.
55
- * @param value - Base58-encoded public key or nullish
56
- * @returns A `PublicKey` instance, or `undefined`
57
- * @internal
58
- * @since v0.1.0
59
- */
60
- function toPubkey(value) {
61
- return value ? new PublicKey(value) : undefined;
62
- }
63
- /**
64
- * Convert a string amount to BN.
65
- *
66
- * @name toBN
67
- * @description Returns `undefined` for nullish input, otherwise parses
68
- * the string as a `BN` (big number) instance.
69
- * @param value - Numeric string or nullish
70
- * @returns A `BN` instance, or `undefined`
71
- * @internal
72
- * @since v0.1.0
73
- */
74
- function toBN(value) {
75
- return value ? new BN(value) : undefined;
76
- }
77
- /**
78
- * Convert a hex string to a Node.js Buffer.
79
- *
80
- * @name hexToBuffer
81
- * @description Used for encrypted data payloads before sending to
82
- * on-chain instructions.
83
- * @param hex - Hex-encoded string
84
- * @returns Buffer of decoded bytes
85
- * @internal
86
- * @since v0.1.0
87
- */
88
- function hexToBuffer(hex) {
89
- return Buffer.from(hex, "hex");
90
- }
91
- /**
92
- * Convert a hex string to Uint8Array for PDA seed derivation.
93
- *
94
- * @name hexToBytes
95
- * @description Wraps `Buffer.from(hex, 'hex')` into a `Uint8Array`
96
- * suitable for Solana PDA seed arrays.
97
- * @param hex - Hex-encoded string
98
- * @returns Uint8Array of decoded bytes
99
- * @internal
100
- * @since v0.1.0
101
- */
102
- function hexToBytes(hex) {
103
- return new Uint8Array(Buffer.from(hex, "hex"));
104
- }
105
- /**
106
- * Map token type strings to Anchor enum variant objects.
107
- *
108
- * @name toTokenType
109
- * @description Converts `"sol"`, `"usdc"`, or `"spl"` to the
110
- * corresponding Anchor enum variant. Defaults to `{ sol: {} }`.
111
- * @param s - Token type string
112
- * @returns Anchor-compatible enum variant object
113
- * @internal
114
- * @since v0.1.0
115
- */
116
- function toTokenType(s) {
117
- const map = {
118
- sol: { sol: {} },
119
- usdc: { usdc: {} },
120
- spl: { spl: {} },
121
- };
122
- return map[s] ?? { sol: {} };
123
- }
124
- /**
125
- * Map settlement mode strings to Anchor enum variant objects.
126
- *
127
- * @name toSettlementMode
128
- * @description Converts `"instant"`, `"escrow"`, `"batched"`, or `"x402"`
129
- * to the corresponding Anchor enum variant. Returns `null` for nullish input.
130
- * @param s - Settlement mode string or nullish
131
- * @returns Anchor-compatible enum variant object, or `null`
132
- * @internal
133
- * @since v0.1.0
134
- */
135
- function toSettlementMode(s) {
136
- if (!s)
137
- return null;
138
- const map = {
139
- instant: { instant: {} },
140
- escrow: { escrow: {} },
141
- batched: { batched: {} },
142
- x402: { x402: {} },
143
- };
144
- return map[s] ?? null;
145
- }
146
- /**
147
- * Map HTTP method strings to numeric enum values.
148
- *
149
- * @name toHttpMethodNum
150
- * @description Converts lowercase method names (`"get"`, `"post"`, etc.)
151
- * to their on-chain numeric representation. Defaults to `0` (GET).
152
- * @param s - HTTP method string
153
- * @returns Numeric enum value
154
- * @internal
155
- * @since v0.1.0
156
- */
157
- function toHttpMethodNum(s) {
158
- const map = {
159
- get: 0,
160
- post: 1,
161
- put: 2,
162
- delete: 3,
163
- compound: 4,
164
- };
165
- return map[s] ?? 0;
166
- }
167
- /**
168
- * Map category strings to numeric enum values.
169
- *
170
- * @name toCategoryNum
171
- * @description Converts category names (`"swap"`, `"lend"`, etc.)
172
- * to their on-chain numeric representation. Defaults to `9` (custom).
173
- * @param s - Category string
174
- * @returns Numeric enum value
175
- * @internal
176
- * @since v0.1.0
177
- */
178
- function toCategoryNum(s) {
179
- const map = {
180
- swap: 0,
181
- lend: 1,
182
- stake: 2,
183
- nft: 3,
184
- payment: 4,
185
- data: 5,
186
- governance: 6,
187
- bridge: 7,
188
- analytics: 8,
189
- custom: 9,
190
- };
191
- return map[s] ?? 9;
192
- }
193
- /**
194
- * Map schema type strings to numeric enum values.
195
- *
196
- * @name toSchemaTypeNum
197
- * @description Converts `"input"`, `"output"`, or `"description"`
198
- * to their on-chain numeric representation. Defaults to `0` (input).
199
- * @param s - Schema type string
200
- * @returns Numeric enum value
201
- * @internal
202
- * @since v0.1.0
203
- */
204
- function toSchemaTypeNum(s) {
205
- const map = { input: 0, output: 1, description: 2 };
206
- return map[s] ?? 0;
207
- }
208
- /**
209
- * Map compression type strings to numeric enum values.
210
- *
211
- * @name toCompressionNum
212
- * @description Converts `"none"`, `"deflate"`, `"gzip"`, or `"brotli"`
213
- * to their on-chain numeric representation. Defaults to `0` (none).
214
- * @param s - Compression type string
215
- * @returns Numeric enum value
216
- * @internal
217
- * @since v0.1.0
218
- */
219
- function toCompressionNum(s) {
220
- const map = {
221
- none: 0,
222
- deflate: 1,
223
- gzip: 2,
224
- brotli: 3,
225
- };
226
- return map[s] ?? 0;
227
- }
228
- /**
229
- * Convert a JSON-serialized pricing tier from plugin input
230
- * into the SDK’s PricingTier shape with BN/PublicKey/enum conversions.
231
- *
232
- * @name toPricingTier
233
- * @description Transforms raw JSON input (string amounts, string enums)
234
- * into the native Anchor-compatible shape with `BN`, `PublicKey`,
235
- * and enum variant objects.
236
- * @param raw - Raw pricing tier object from Zod-validated plugin input
237
- * @returns Anchor-compatible PricingTier object
238
- * @internal
239
- * @since v0.1.0
240
- */
241
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
242
- function toPricingTier(raw) {
243
- return {
244
- tierId: raw.tierId,
245
- pricePerCall: new BN(raw.pricePerCall),
246
- minPricePerCall: toBN(raw.minPricePerCall) ?? null,
247
- maxPricePerCall: toBN(raw.maxPricePerCall) ?? null,
248
- rateLimit: raw.rateLimit,
249
- maxCallsPerSession: raw.maxCallsPerSession,
250
- burstLimit: raw.burstLimit ?? null,
251
- tokenType: toTokenType(raw.tokenType),
252
- tokenMint: toPubkey(raw.tokenMint) ?? null,
253
- tokenDecimals: raw.tokenDecimals ?? null,
254
- settlementMode: toSettlementMode(raw.settlementMode),
255
- minEscrowDeposit: toBN(raw.minEscrowDeposit) ?? null,
256
- batchIntervalSec: raw.batchIntervalSec ?? null,
257
- volumeCurve: raw.volumeCurve
258
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
259
- ? raw.volumeCurve.map((v) => ({
260
- afterCalls: v.afterCalls,
261
- pricePerCall: new BN(v.pricePerCall),
262
- }))
263
- : null,
264
- };
265
- }
266
- /**
267
- * Serialize an on-chain account object to a JSON-safe shape.
268
- *
269
- * @name serializeAccount
270
- * @description Recursively converts `PublicKey` → base58 string,
271
- * `BN` → decimal string, and nested objects/arrays. Used to
272
- * return tool output that is JSON-serializable for LLMs.
273
- * @param obj - Raw account data record from Anchor deserialization
274
- * @returns JSON-safe record with all Solana types converted to strings
275
- * @internal
276
- * @since v0.1.0
277
- */
278
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
279
- function serializeAccount(obj) {
280
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
281
- const result = {};
282
- for (const [key, value] of Object.entries(obj)) {
283
- if (value === null || value === undefined) {
284
- result[key] = null;
285
- }
286
- else if (value instanceof PublicKey) {
287
- result[key] = value.toBase58();
288
- }
289
- else if (BN.isBN(value)) {
290
- result[key] = value.toString();
291
- }
292
- else if (Array.isArray(value)) {
293
- result[key] = value.map((item) => {
294
- if (item instanceof PublicKey)
295
- return item.toBase58();
296
- if (BN.isBN(item))
297
- return item.toString();
298
- if (typeof item === "object" && item !== null)
299
- return serializeAccount(item);
300
- return item;
301
- });
302
- }
303
- else if (typeof value === "object") {
304
- result[key] = serializeAccount(value);
305
- }
306
- else {
307
- result[key] = value;
308
- }
309
- }
310
- return result;
311
- }
312
- // ═══════════════════════════════════════════════════════════════════
313
- // Executor Builder
314
- // ═══════════════════════════════════════════════════════════════════
315
- /**
316
- * Build the executor function that dispatches incoming tool calls
317
- * to the appropriate SapClient module method.
318
- *
319
- * @name buildExecutor
320
- * @description Creates a closure over a `SapClient` instance that routes
321
- * each incoming `ProtocolMethod` to the correct per-protocol dispatcher
322
- * based on `method.protocol`.
323
- * @param client - Initialized SapClient for the configured provider
324
- * @returns Async executor function `(method, input) => Promise<unknown>`
325
- * @internal
326
- * @since v0.1.0
327
- */
328
- function buildExecutor(client) {
329
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
330
- return async (method, raw) => {
331
- switch (method.protocol) {
332
- // ────────────────────── Agent ──────────────────────
333
- case "sap-agent":
334
- return executeAgent(client, method.name, raw);
335
- // ────────────────────── Feedback ───────────────────
336
- case "sap-feedback":
337
- return executeFeedback(client, method.name, raw);
338
- // ────────────────────── Attestation ────────────────
339
- case "sap-attestation":
340
- return executeAttestation(client, method.name, raw);
341
- // ────────────────────── Escrow ─────────────────────
342
- case "sap-escrow":
343
- return executeEscrow(client, method.name, raw);
344
- // ────────────────────── Tools ──────────────────────
345
- case "sap-tools":
346
- return executeTools(client, method.name, raw);
347
- // ────────────────────── Vault ──────────────────────
348
- case "sap-vault":
349
- return executeVault(client, method.name, raw);
350
- // ────────────────────── Indexing ───────────────────
351
- case "sap-indexing":
352
- return executeIndexing(client, method.name, raw);
353
- // ────────────────────── Ledger ─────────────────────
354
- case "sap-ledger":
355
- return executeLedger(client, method.name, raw);
356
- default:
357
- throw new Error(`Unknown SAP protocol: ${method.protocol}`);
358
- }
359
- };
360
- }
361
- // ═══════════════════════════════════════════════════════════════════
362
- // Per-Protocol Dispatchers
363
- // ═══════════════════════════════════════════════════════════════════
364
- /**
365
- * Dispatch tool calls for the **sap-agent** protocol.
366
- *
367
- * @name executeAgent
368
- * @description Routes agent-domain method names to `client.agent.*` calls,
369
- * handling argument conversion and account serialization.
370
- * @param client - SapClient instance
371
- * @param name - Method name (e.g. `"registerAgent"`)
372
- * @param input - Zod-validated input from the LLM tool call
373
- * @returns Transaction signature or serialized account data
374
- * @internal
375
- * @since v0.1.0
376
- */
377
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
378
- async function executeAgent(client, name, input) {
379
- switch (name) {
380
- case "registerAgent": {
381
- const args = {
382
- name: input.name,
383
- description: input.description,
384
- capabilities: input.capabilities,
385
- pricing: (input.pricing ?? []).map(toPricingTier),
386
- protocols: input.protocols ?? [],
387
- agentId: input.agentId ?? null,
388
- agentUri: input.agentUri ?? null,
389
- x402Endpoint: input.x402Endpoint ?? null,
390
- };
391
- const tx = await client.agent.register(args);
392
- return { txSignature: tx };
393
- }
394
- case "updateAgent": {
395
- const args = {
396
- name: input.name ?? null,
397
- description: input.description ?? null,
398
- capabilities: input.capabilities ?? null,
399
- pricing: input.pricing ? input.pricing.map(toPricingTier) : null,
400
- protocols: input.protocols ?? null,
401
- agentId: input.agentId ?? null,
402
- agentUri: input.agentUri ?? null,
403
- x402Endpoint: input.x402Endpoint ?? null,
404
- };
405
- const tx = await client.agent.update(args);
406
- return { txSignature: tx };
407
- }
408
- case "deactivateAgent": {
409
- const tx = await client.agent.deactivate();
410
- return { txSignature: tx };
411
- }
412
- case "reactivateAgent": {
413
- const tx = await client.agent.reactivate();
414
- return { txSignature: tx };
415
- }
416
- case "reportCalls": {
417
- const tx = await client.agent.reportCalls(input.callsServed);
418
- return { txSignature: tx };
419
- }
420
- case "updateReputation": {
421
- const tx = await client.agent.updateReputation(input.avgLatencyMs, input.uptimePercent);
422
- return { txSignature: tx };
423
- }
424
- case "fetchAgent": {
425
- const wallet = toPubkey(input.wallet);
426
- const data = await client.agent.fetch(wallet);
427
- return serializeAccount(data);
428
- }
429
- case "fetchGlobalRegistry": {
430
- const data = await client.agent.fetchGlobalRegistry();
431
- return serializeAccount(data);
432
- }
433
- default:
434
- throw new Error(`Unknown sap-agent method: ${name}`);
435
- }
436
- }
437
- /**
438
- * Dispatch tool calls for the **sap-feedback** protocol.
439
- *
440
- * @name executeFeedback
441
- * @description Routes feedback-domain method names to `client.feedback.*` calls.
442
- * @param client - SapClient instance
443
- * @param name - Method name (e.g. `"giveFeedback"`)
444
- * @param input - Zod-validated input from the LLM tool call
445
- * @returns Transaction signature or serialized account data
446
- * @internal
447
- * @since v0.1.0
448
- */
449
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
450
- async function executeFeedback(client, name, input) {
451
- switch (name) {
452
- case "giveFeedback": {
453
- const agentWallet = new PublicKey(input.agentWallet);
454
- const args = {
455
- score: input.score,
456
- tag: input.tag,
457
- commentHash: input.commentHash ?? null,
458
- };
459
- const tx = await client.feedback.give(agentWallet, args);
460
- return { txSignature: tx };
461
- }
462
- case "updateFeedback": {
463
- const agentWallet = new PublicKey(input.agentWallet);
464
- const args = {
465
- newScore: input.newScore,
466
- newTag: input.newTag ?? null,
467
- commentHash: input.commentHash ?? null,
468
- };
469
- const tx = await client.feedback.update(agentWallet, args);
470
- return { txSignature: tx };
471
- }
472
- case "revokeFeedback": {
473
- const tx = await client.feedback.revoke(new PublicKey(input.agentWallet));
474
- return { txSignature: tx };
475
- }
476
- case "fetchFeedback": {
477
- const [agentPda] = deriveAgent(new PublicKey(input.agentWallet));
478
- const reviewer = toPubkey(input.reviewer);
479
- const data = await client.feedback.fetch(agentPda, reviewer);
480
- return serializeAccount(data);
481
- }
482
- default:
483
- throw new Error(`Unknown sap-feedback method: ${name}`);
484
- }
485
- }
486
- /**
487
- * Dispatch tool calls for the **sap-attestation** protocol.
488
- *
489
- * @name executeAttestation
490
- * @description Routes attestation-domain method names to `client.attestation.*` calls.
491
- * @param client - SapClient instance
492
- * @param name - Method name (e.g. `"createAttestation"`)
493
- * @param input - Zod-validated input from the LLM tool call
494
- * @returns Transaction signature or serialized account data
495
- * @internal
496
- * @since v0.1.0
497
- */
498
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
499
- async function executeAttestation(client, name, input) {
500
- switch (name) {
501
- case "createAttestation": {
502
- const args = {
503
- attestationType: input.attestationType,
504
- metadataHash: input.metadataHash,
505
- expiresAt: new BN(input.expiresAt),
506
- };
507
- const tx = await client.attestation.create(new PublicKey(input.agentWallet), args);
508
- return { txSignature: tx };
509
- }
510
- case "revokeAttestation": {
511
- const tx = await client.attestation.revoke(new PublicKey(input.agentWallet));
512
- return { txSignature: tx };
513
- }
514
- case "fetchAttestation": {
515
- const [agentPda] = deriveAgent(new PublicKey(input.agentWallet));
516
- const attester = toPubkey(input.attester);
517
- const data = await client.attestation.fetch(agentPda, attester);
518
- return serializeAccount(data);
519
- }
520
- default:
521
- throw new Error(`Unknown sap-attestation method: ${name}`);
522
- }
523
- }
524
- /**
525
- * Dispatch tool calls for the **sap-escrow** protocol.
526
- *
527
- * @name executeEscrow
528
- * @description Routes escrow-domain method names to `client.escrow.*` calls,
529
- * including BN conversion for amounts and volume curves.
530
- * @param client - SapClient instance
531
- * @param name - Method name (e.g. `"createEscrow"`)
532
- * @param input - Zod-validated input from the LLM tool call
533
- * @returns Transaction signature or serialized account data
534
- * @internal
535
- * @since v0.1.0
536
- */
537
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
538
- async function executeEscrow(client, name, input) {
539
- switch (name) {
540
- case "createEscrow": {
541
- const args = {
542
- pricePerCall: new BN(input.pricePerCall),
543
- maxCalls: new BN(input.maxCalls),
544
- initialDeposit: new BN(input.initialDeposit),
545
- expiresAt: new BN(input.expiresAt),
546
- volumeCurve: (input.volumeCurve ?? []).map(
547
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
548
- (v) => ({
549
- afterCalls: v.afterCalls,
550
- pricePerCall: new BN(v.pricePerCall),
551
- })),
552
- tokenMint: toPubkey(input.tokenMint) ?? null,
553
- tokenDecimals: input.tokenDecimals ?? 9,
554
- };
555
- const tx = await client.escrow.create(new PublicKey(input.agentWallet), args);
556
- return { txSignature: tx };
557
- }
558
- case "depositEscrow": {
559
- const tx = await client.escrow.deposit(new PublicKey(input.agentWallet), new BN(input.amount));
560
- return { txSignature: tx };
561
- }
562
- case "settleEscrow": {
563
- // Build settle options from optional priority fee fields
564
- const settleOpts = (input.priorityFeeMicroLamports || input.computeUnits || input.skipPreflight)
565
- ? {
566
- priorityFeeMicroLamports: input.priorityFeeMicroLamports ?? undefined,
567
- computeUnits: input.computeUnits ?? undefined,
568
- skipPreflight: input.skipPreflight ?? undefined,
569
- }
570
- : undefined;
571
- const tx = await client.escrow.settle(new PublicKey(input.depositorWallet), new BN(input.callsToSettle), input.serviceHash, [], settleOpts);
572
- return { txSignature: tx };
573
- }
574
- case "withdrawEscrow": {
575
- const tx = await client.escrow.withdraw(new PublicKey(input.agentWallet), new BN(input.amount));
576
- return { txSignature: tx };
577
- }
578
- case "batchSettle": {
579
- const settlements = input.settlements.map(
580
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
581
- (s) => ({
582
- callsToSettle: new BN(s.callsToSettle),
583
- serviceHash: s.serviceHash,
584
- }));
585
- // Build settle options from optional priority fee fields
586
- const batchOpts = (input.priorityFeeMicroLamports || input.computeUnits || input.skipPreflight)
587
- ? {
588
- priorityFeeMicroLamports: input.priorityFeeMicroLamports ?? undefined,
589
- computeUnits: input.computeUnits ?? undefined,
590
- skipPreflight: input.skipPreflight ?? undefined,
591
- }
592
- : undefined;
593
- const tx = await client.escrow.settleBatch(new PublicKey(input.depositorWallet), settlements,
594
- // batchRoot omitted \u2192 SDK auto-derives sha256(s_0 || ... || s_N)
595
- undefined, [], batchOpts);
596
- return { txSignature: tx };
597
- }
598
- case "fetchEscrow": {
599
- const [agentPda] = deriveAgent(new PublicKey(input.agentWallet));
600
- const depositor = toPubkey(input.depositor);
601
- const data = await client.escrow.fetch(agentPda, depositor);
602
- return serializeAccount(data);
603
- }
604
- default:
605
- throw new Error(`Unknown sap-escrow method: ${name}`);
606
- }
607
- }
608
- /**
609
- * Dispatch tool calls for the **sap-tools** protocol.
610
- *
611
- * @name executeTools
612
- * @description Routes tools-domain method names to `client.tools.*` calls,
613
- * handling schema hashing and enum conversions.
614
- * @param client - SapClient instance
615
- * @param name - Method name (e.g. `"publishToolByName"`)
616
- * @param input - Zod-validated input from the LLM tool call
617
- * @returns Transaction signature or serialized account data
618
- * @internal
619
- * @since v0.1.0
620
- */
621
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
622
- async function executeTools(client, name, input) {
623
- switch (name) {
624
- case "publishToolByName": {
625
- const tx = await client.tools.publishByName(input.toolName, input.protocolId, input.description, input.inputSchema, input.outputSchema, toHttpMethodNum(input.httpMethod), toCategoryNum(input.category), input.paramsCount, input.requiredParams, input.isCompound ?? false);
626
- return { txSignature: tx };
627
- }
628
- case "inscribeToolSchema": {
629
- const args = {
630
- schemaType: toSchemaTypeNum(input.schemaType),
631
- schemaData: Buffer.from(input.schemaData, "utf-8"),
632
- schemaHash: hashToArray(sha256(input.schemaData)),
633
- compression: toCompressionNum(input.compression ?? "none"),
634
- };
635
- const tx = await client.tools.inscribeSchema(input.toolName, args);
636
- return { txSignature: tx };
637
- }
638
- case "updateTool": {
639
- const args = {
640
- descriptionHash: null,
641
- inputSchemaHash: null,
642
- outputSchemaHash: null,
643
- httpMethod: input.httpMethod != null ? toHttpMethodNum(input.httpMethod) : null,
644
- category: input.category != null ? toCategoryNum(input.category) : null,
645
- paramsCount: input.paramsCount ?? null,
646
- requiredParams: input.requiredParams ?? null,
647
- };
648
- const tx = await client.tools.update(input.toolName, args);
649
- return { txSignature: tx };
650
- }
651
- case "deactivateTool": {
652
- const tx = await client.tools.deactivate(input.toolName);
653
- return { txSignature: tx };
654
- }
655
- case "reactivateTool": {
656
- const tx = await client.tools.reactivate(input.toolName);
657
- return { txSignature: tx };
658
- }
659
- case "reportInvocations": {
660
- const tx = await client.tools.reportInvocations(input.toolName, input.invocations);
661
- return { txSignature: tx };
662
- }
663
- case "fetchTool": {
664
- const [agentPda] = deriveAgent(new PublicKey(input.agentWallet));
665
- const data = await client.tools.fetch(agentPda, input.toolName);
666
- return serializeAccount(data);
667
- }
668
- default:
669
- throw new Error(`Unknown sap-tools method: ${name}`);
670
- }
671
- }
672
- /**
673
- * Dispatch tool calls for the **sap-vault** protocol.
674
- *
675
- * @name executeVault
676
- * @description Routes vault-domain method names to `client.vault.*` calls,
677
- * handling hex-to-bytes conversion and PDA derivation for sessions.
678
- * @param client - SapClient instance
679
- * @param name - Method name (e.g. `"initVault"`)
680
- * @param input - Zod-validated input from the LLM tool call
681
- * @returns Transaction signature or serialized account data
682
- * @internal
683
- * @since v0.1.0
684
- */
685
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
686
- async function executeVault(client, name, input) {
687
- switch (name) {
688
- case "initVault": {
689
- const tx = await client.vault.initVault(input.vaultNonce);
690
- return { txSignature: tx };
691
- }
692
- case "openSession": {
693
- const tx = await client.vault.openSession(input.sessionHash);
694
- return { txSignature: tx };
695
- }
696
- case "inscribeMemory": {
697
- const args = {
698
- sequence: input.sequence,
699
- encryptedData: hexToBuffer(input.encryptedData),
700
- nonce: input.nonce,
701
- contentHash: input.contentHash,
702
- totalFragments: input.totalFragments ?? 1,
703
- fragmentIndex: input.fragmentIndex ?? 0,
704
- compression: input.compression ?? 0,
705
- epochIndex: input.epochIndex ?? 0,
706
- };
707
- const tx = await client.vault.inscribe(args);
708
- return { txSignature: tx };
709
- }
710
- case "closeSession": {
711
- const [agentPda] = deriveAgent(client.walletPubkey);
712
- const [vaultPda] = deriveVault(agentPda);
713
- const sessionHashBytes = hexToBytes(input.sessionHash);
714
- const [sessionPda] = deriveSession(vaultPda, sessionHashBytes);
715
- const tx = await client.vault.closeSession(vaultPda, sessionPda);
716
- return { txSignature: tx };
717
- }
718
- case "closeVault": {
719
- const tx = await client.vault.closeVault();
720
- return { txSignature: tx };
721
- }
722
- case "rotateNonce": {
723
- const tx = await client.vault.rotateNonce(input.newNonce);
724
- return { txSignature: tx };
725
- }
726
- case "addDelegate": {
727
- const tx = await client.vault.addDelegate(new PublicKey(input.delegatePubkey), input.permissions, BigInt(input.expiresAt));
728
- return { txSignature: tx };
729
- }
730
- case "revokeDelegate": {
731
- const tx = await client.vault.revokeDelegate(new PublicKey(input.delegatePubkey));
732
- return { txSignature: tx };
733
- }
734
- case "fetchVault": {
735
- const wallet = toPubkey(input.agentWallet) ?? client.walletPubkey;
736
- const [agentPda] = deriveAgent(wallet);
737
- const data = await client.vault.fetchVault(agentPda);
738
- return serializeAccount(data);
739
- }
740
- case "fetchSession": {
741
- const wallet = new PublicKey(input.agentWallet);
742
- const [agentPda] = deriveAgent(wallet);
743
- const [vaultPda] = deriveVault(agentPda);
744
- const sessionHashBytes = hexToBytes(input.sessionHash);
745
- const data = await client.vault.fetchSession(vaultPda, sessionHashBytes);
746
- return serializeAccount(data);
747
- }
748
- default:
749
- throw new Error(`Unknown sap-vault method: ${name}`);
750
- }
751
- }
752
- /**
753
- * Dispatch tool calls for the **sap-indexing** protocol.
754
- *
755
- * @name executeIndexing
756
- * @description Routes indexing-domain method names to `client.indexing.*` calls
757
- * for capability and protocol index management.
758
- * @param client - SapClient instance
759
- * @param name - Method name (e.g. `"initCapabilityIndex"`)
760
- * @param input - Zod-validated input from the LLM tool call
761
- * @returns Transaction signature or serialized account data
762
- * @internal
763
- * @since v0.1.0
764
- */
765
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
766
- async function executeIndexing(client, name, input) {
767
- switch (name) {
768
- case "initCapabilityIndex": {
769
- const tx = await client.indexing.initCapabilityIndex(input.capabilityId);
770
- return { txSignature: tx };
771
- }
772
- case "addToCapabilityIndex": {
773
- const tx = await client.indexing.addToCapabilityIndex(input.capabilityId);
774
- return { txSignature: tx };
775
- }
776
- case "removeFromCapabilityIndex": {
777
- const tx = await client.indexing.removeFromCapabilityIndex(input.capabilityId);
778
- return { txSignature: tx };
779
- }
780
- case "initProtocolIndex": {
781
- const tx = await client.indexing.initProtocolIndex(input.protocolId);
782
- return { txSignature: tx };
783
- }
784
- case "addToProtocolIndex": {
785
- const tx = await client.indexing.addToProtocolIndex(input.protocolId);
786
- return { txSignature: tx };
787
- }
788
- case "removeFromProtocolIndex": {
789
- const tx = await client.indexing.removeFromProtocolIndex(input.protocolId);
790
- return { txSignature: tx };
791
- }
792
- case "fetchCapabilityIndex": {
793
- const data = await client.indexing.fetchCapabilityIndex(input.capabilityId);
794
- return serializeAccount(data);
795
- }
796
- case "fetchProtocolIndex": {
797
- const data = await client.indexing.fetchProtocolIndex(input.protocolId);
798
- return serializeAccount(data);
799
- }
800
- default:
801
- throw new Error(`Unknown sap-indexing method: ${name}`);
802
- }
803
- }
804
- /**
805
- * Dispatch tool calls for the **sap-ledger** protocol.
806
- *
807
- * @name executeLedger
808
- * @description Routes ledger-domain method names to `client.ledger.*` calls,
809
- * deriving session PDAs from hex-encoded session hashes.
810
- * @param client - SapClient instance
811
- * @param name - Method name (e.g. `"initLedger"`)
812
- * @param input - Zod-validated input from the LLM tool call
813
- * @returns Transaction signature or serialized account data
814
- * @internal
815
- * @since v0.1.0
816
- */
817
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
818
- async function executeLedger(client, name, input) {
819
- const resolveSessionPda = (sessionHash, agentWallet) => {
820
- const wallet = toPubkey(agentWallet) ?? client.walletPubkey;
821
- const [agentPda] = deriveAgent(wallet);
822
- const [vaultPda] = deriveVault(agentPda);
823
- const sessionHashBytes = hexToBytes(sessionHash);
824
- const [sessionPda] = deriveSession(vaultPda, sessionHashBytes);
825
- return sessionPda;
826
- };
827
- switch (name) {
828
- case "initLedger": {
829
- const sessionPda = resolveSessionPda(input.sessionHash, input.agentWallet);
830
- const tx = await client.ledger.init(sessionPda);
831
- return { txSignature: tx };
832
- }
833
- case "writeLedger": {
834
- const sessionPda = resolveSessionPda(input.sessionHash, input.agentWallet);
835
- const data = hexToBuffer(input.data);
836
- const tx = await client.ledger.write(sessionPda, data, input.contentHash);
837
- return { txSignature: tx };
838
- }
839
- case "sealLedger": {
840
- const sessionPda = resolveSessionPda(input.sessionHash, input.agentWallet);
841
- const tx = await client.ledger.seal(sessionPda);
842
- return { txSignature: tx };
843
- }
844
- case "closeLedger": {
845
- const sessionPda = resolveSessionPda(input.sessionHash, input.agentWallet);
846
- const tx = await client.ledger.close(sessionPda);
847
- return { txSignature: tx };
848
- }
849
- case "fetchLedger": {
850
- const sessionPda = resolveSessionPda(input.sessionHash, input.agentWallet);
851
- const data = await client.ledger.fetchLedger(sessionPda);
852
- return serializeAccount(data);
853
- }
854
- case "fetchLedgerPage": {
855
- const sessionPda = resolveSessionPda(input.sessionHash, input.agentWallet);
856
- const [ledgerPda] = deriveLedger(sessionPda);
857
- const data = await client.ledger.fetchPage(ledgerPda, input.pageIndex);
858
- return serializeAccount(data);
859
- }
860
- default:
861
- throw new Error(`Unknown sap-ledger method: ${name}`);
862
- }
863
- }
864
- // ═══════════════════════════════════════════════════════════════════
865
- // Plugin Factory
866
- // ═══════════════════════════════════════════════════════════════════
867
- /**
868
- * Create a SynapsePlugin for SAP v2.
869
- *
870
- * @name createSAPPlugin
871
- * @description Factory function that returns a fully configured
872
- * {@link SynapsePlugin} exposing 52 tools across 8 on-chain
873
- * protocol domains. The plugin can be installed into a
874
- * `SynapseAgentKit` instance or used standalone.
875
- * @param config - Plugin configuration with Anchor provider and optional program ID
876
- * @returns A configured {@link SynapsePlugin} instance
877
- * @category Plugin
878
- * @since v0.1.0
879
- *
880
- * @example
881
- * ```ts
882
- * import { createSAPPlugin } from '@synapse-sap/sdk/plugin';
883
- *
884
- * const sapPlugin = createSAPPlugin({ provider });
885
- *
886
- * // Use with SynapseAgentKit:
887
- * kit.use(sapPlugin);
888
- *
889
- * // Or standalone:
890
- * const executor = sapPlugin.install({ client, config: {} }).executor;
891
- * await executor(someMethod, someInput);
892
- * ```
893
- */
894
- export function createSAPPlugin(config) {
895
- return {
896
- meta: {
897
- id: "sap",
898
- name: "SAP v2 — Synapse Agent Protocol",
899
- version: SAP_PLUGIN_VERSION,
900
- description: "On-chain agent identity, reputation, tool registry, encrypted memory vault, x402 escrow, attestation, discovery indexes, and unified memory ledger on Solana",
901
- tags: [
902
- "solana",
903
- "agent",
904
- "identity",
905
- "reputation",
906
- "x402",
907
- "escrow",
908
- "vault",
909
- "memory",
910
- "tools",
911
- "attestation",
912
- "erc-8004",
913
- ],
914
- },
915
- protocols: SAP_PROTOCOLS,
916
- install(_context) {
917
- const client = SapClient.from(config.provider, config.programId);
918
- const executor = buildExecutor(client);
919
- return { executor };
920
- },
921
- };
922
- }
923
- /**
924
- * Pre-built plugin object for static use patterns.
925
- *
926
- * @name SAPPlugin
927
- * @description Convenience namespace exposing a `configure` method
928
- * that delegates to {@link createSAPPlugin}. Useful for concise
929
- * one-liner instantiation.
930
- * @category Plugin
931
- * @since v0.1.0
932
- *
933
- * @example
934
- * ```ts
935
- * import { SAPPlugin } from '@synapse-sap/sdk/plugin';
936
- *
937
- * const plugin = SAPPlugin.configure({ provider });
938
- * kit.use(plugin);
939
- * ```
940
- */
941
- export const SAPPlugin = {
942
- /** Create a configured SynapsePlugin from an AnchorProvider. */
943
- configure: createSAPPlugin,
944
- };
945
- //# sourceMappingURL=index.js.map