@oobe-protocol-labs/synapse-sap-sdk 0.1.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 (315) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +882 -0
  3. package/dist/cjs/constants/index.js +43 -0
  4. package/dist/cjs/constants/index.js.map +1 -0
  5. package/dist/cjs/constants/limits.js +161 -0
  6. package/dist/cjs/constants/limits.js.map +1 -0
  7. package/dist/cjs/constants/programs.js +78 -0
  8. package/dist/cjs/constants/programs.js.map +1 -0
  9. package/dist/cjs/constants/seeds.js +57 -0
  10. package/dist/cjs/constants/seeds.js.map +1 -0
  11. package/dist/cjs/core/client.js +391 -0
  12. package/dist/cjs/core/client.js.map +1 -0
  13. package/dist/cjs/core/connection.js +319 -0
  14. package/dist/cjs/core/connection.js.map +1 -0
  15. package/dist/cjs/core/index.js +24 -0
  16. package/dist/cjs/core/index.js.map +1 -0
  17. package/dist/cjs/errors/index.js +334 -0
  18. package/dist/cjs/errors/index.js.map +1 -0
  19. package/dist/cjs/events/index.js +136 -0
  20. package/dist/cjs/events/index.js.map +1 -0
  21. package/dist/cjs/idl/index.js +63 -0
  22. package/dist/cjs/idl/index.js.map +1 -0
  23. package/dist/cjs/idl/synapse_agent_sap.json +9710 -0
  24. package/dist/cjs/index.js +147 -0
  25. package/dist/cjs/index.js.map +1 -0
  26. package/dist/cjs/modules/agent.js +272 -0
  27. package/dist/cjs/modules/agent.js.map +1 -0
  28. package/dist/cjs/modules/attestation.js +147 -0
  29. package/dist/cjs/modules/attestation.js.map +1 -0
  30. package/dist/cjs/modules/base.js +128 -0
  31. package/dist/cjs/modules/base.js.map +1 -0
  32. package/dist/cjs/modules/escrow.js +246 -0
  33. package/dist/cjs/modules/escrow.js.map +1 -0
  34. package/dist/cjs/modules/feedback.js +166 -0
  35. package/dist/cjs/modules/feedback.js.map +1 -0
  36. package/dist/cjs/modules/index.js +35 -0
  37. package/dist/cjs/modules/index.js.map +1 -0
  38. package/dist/cjs/modules/indexing.js +375 -0
  39. package/dist/cjs/modules/indexing.js.map +1 -0
  40. package/dist/cjs/modules/ledger.js +234 -0
  41. package/dist/cjs/modules/ledger.js.map +1 -0
  42. package/dist/cjs/modules/tools.js +319 -0
  43. package/dist/cjs/modules/tools.js.map +1 -0
  44. package/dist/cjs/modules/vault.js +410 -0
  45. package/dist/cjs/modules/vault.js.map +1 -0
  46. package/dist/cjs/pda/index.js +377 -0
  47. package/dist/cjs/pda/index.js.map +1 -0
  48. package/dist/cjs/plugin/index.js +934 -0
  49. package/dist/cjs/plugin/index.js.map +1 -0
  50. package/dist/cjs/plugin/protocols.js +282 -0
  51. package/dist/cjs/plugin/protocols.js.map +1 -0
  52. package/dist/cjs/plugin/schemas.js +831 -0
  53. package/dist/cjs/plugin/schemas.js.map +1 -0
  54. package/dist/cjs/postgres/adapter.js +715 -0
  55. package/dist/cjs/postgres/adapter.js.map +1 -0
  56. package/dist/cjs/postgres/index.js +50 -0
  57. package/dist/cjs/postgres/index.js.map +1 -0
  58. package/dist/cjs/postgres/serializers.js +381 -0
  59. package/dist/cjs/postgres/serializers.js.map +1 -0
  60. package/dist/cjs/postgres/sync.js +221 -0
  61. package/dist/cjs/postgres/sync.js.map +1 -0
  62. package/dist/cjs/postgres/types.js +44 -0
  63. package/dist/cjs/postgres/types.js.map +1 -0
  64. package/dist/cjs/registries/builder.js +414 -0
  65. package/dist/cjs/registries/builder.js.map +1 -0
  66. package/dist/cjs/registries/discovery.js +362 -0
  67. package/dist/cjs/registries/discovery.js.map +1 -0
  68. package/dist/cjs/registries/index.js +51 -0
  69. package/dist/cjs/registries/index.js.map +1 -0
  70. package/dist/cjs/registries/session.js +433 -0
  71. package/dist/cjs/registries/session.js.map +1 -0
  72. package/dist/cjs/registries/x402.js +577 -0
  73. package/dist/cjs/registries/x402.js.map +1 -0
  74. package/dist/cjs/types/accounts.js +13 -0
  75. package/dist/cjs/types/accounts.js.map +1 -0
  76. package/dist/cjs/types/common.js +13 -0
  77. package/dist/cjs/types/common.js.map +1 -0
  78. package/dist/cjs/types/enums.js +174 -0
  79. package/dist/cjs/types/enums.js.map +1 -0
  80. package/dist/cjs/types/index.js +36 -0
  81. package/dist/cjs/types/index.js.map +1 -0
  82. package/dist/cjs/types/instructions.js +92 -0
  83. package/dist/cjs/types/instructions.js.map +1 -0
  84. package/dist/cjs/utils/hash.js +58 -0
  85. package/dist/cjs/utils/hash.js.map +1 -0
  86. package/dist/cjs/utils/index.js +27 -0
  87. package/dist/cjs/utils/index.js.map +1 -0
  88. package/dist/cjs/utils/serialization.js +105 -0
  89. package/dist/cjs/utils/serialization.js.map +1 -0
  90. package/dist/cjs/utils/validation.js +36 -0
  91. package/dist/cjs/utils/validation.js.map +1 -0
  92. package/dist/esm/constants/index.js +29 -0
  93. package/dist/esm/constants/index.js.map +1 -0
  94. package/dist/esm/constants/limits.js +158 -0
  95. package/dist/esm/constants/limits.js.map +1 -0
  96. package/dist/esm/constants/programs.js +75 -0
  97. package/dist/esm/constants/programs.js.map +1 -0
  98. package/dist/esm/constants/seeds.js +54 -0
  99. package/dist/esm/constants/seeds.js.map +1 -0
  100. package/dist/esm/core/client.js +384 -0
  101. package/dist/esm/core/client.js.map +1 -0
  102. package/dist/esm/core/connection.js +315 -0
  103. package/dist/esm/core/connection.js.map +1 -0
  104. package/dist/esm/core/index.js +19 -0
  105. package/dist/esm/core/index.js.map +1 -0
  106. package/dist/esm/errors/index.js +325 -0
  107. package/dist/esm/errors/index.js.map +1 -0
  108. package/dist/esm/events/index.js +132 -0
  109. package/dist/esm/events/index.js.map +1 -0
  110. package/dist/esm/idl/index.js +57 -0
  111. package/dist/esm/idl/index.js.map +1 -0
  112. package/dist/esm/idl/synapse_agent_sap.json +9710 -0
  113. package/dist/esm/index.js +70 -0
  114. package/dist/esm/index.js.map +1 -0
  115. package/dist/esm/modules/agent.js +268 -0
  116. package/dist/esm/modules/agent.js.map +1 -0
  117. package/dist/esm/modules/attestation.js +143 -0
  118. package/dist/esm/modules/attestation.js.map +1 -0
  119. package/dist/esm/modules/base.js +124 -0
  120. package/dist/esm/modules/base.js.map +1 -0
  121. package/dist/esm/modules/escrow.js +242 -0
  122. package/dist/esm/modules/escrow.js.map +1 -0
  123. package/dist/esm/modules/feedback.js +162 -0
  124. package/dist/esm/modules/feedback.js.map +1 -0
  125. package/dist/esm/modules/index.js +23 -0
  126. package/dist/esm/modules/index.js.map +1 -0
  127. package/dist/esm/modules/indexing.js +371 -0
  128. package/dist/esm/modules/indexing.js.map +1 -0
  129. package/dist/esm/modules/ledger.js +230 -0
  130. package/dist/esm/modules/ledger.js.map +1 -0
  131. package/dist/esm/modules/tools.js +315 -0
  132. package/dist/esm/modules/tools.js.map +1 -0
  133. package/dist/esm/modules/vault.js +406 -0
  134. package/dist/esm/modules/vault.js.map +1 -0
  135. package/dist/esm/pda/index.js +357 -0
  136. package/dist/esm/pda/index.js.map +1 -0
  137. package/dist/esm/plugin/index.js +927 -0
  138. package/dist/esm/plugin/index.js.map +1 -0
  139. package/dist/esm/plugin/protocols.js +279 -0
  140. package/dist/esm/plugin/protocols.js.map +1 -0
  141. package/dist/esm/plugin/schemas.js +828 -0
  142. package/dist/esm/plugin/schemas.js.map +1 -0
  143. package/dist/esm/postgres/adapter.js +678 -0
  144. package/dist/esm/postgres/adapter.js.map +1 -0
  145. package/dist/esm/postgres/index.js +27 -0
  146. package/dist/esm/postgres/index.js.map +1 -0
  147. package/dist/esm/postgres/serializers.js +362 -0
  148. package/dist/esm/postgres/serializers.js.map +1 -0
  149. package/dist/esm/postgres/sync.js +217 -0
  150. package/dist/esm/postgres/sync.js.map +1 -0
  151. package/dist/esm/postgres/types.js +41 -0
  152. package/dist/esm/postgres/types.js.map +1 -0
  153. package/dist/esm/registries/builder.js +410 -0
  154. package/dist/esm/registries/builder.js.map +1 -0
  155. package/dist/esm/registries/discovery.js +358 -0
  156. package/dist/esm/registries/discovery.js.map +1 -0
  157. package/dist/esm/registries/index.js +44 -0
  158. package/dist/esm/registries/index.js.map +1 -0
  159. package/dist/esm/registries/session.js +429 -0
  160. package/dist/esm/registries/session.js.map +1 -0
  161. package/dist/esm/registries/x402.js +573 -0
  162. package/dist/esm/registries/x402.js.map +1 -0
  163. package/dist/esm/types/accounts.js +12 -0
  164. package/dist/esm/types/accounts.js.map +1 -0
  165. package/dist/esm/types/common.js +12 -0
  166. package/dist/esm/types/common.js.map +1 -0
  167. package/dist/esm/types/enums.js +171 -0
  168. package/dist/esm/types/enums.js.map +1 -0
  169. package/dist/esm/types/index.js +25 -0
  170. package/dist/esm/types/index.js.map +1 -0
  171. package/dist/esm/types/instructions.js +89 -0
  172. package/dist/esm/types/instructions.js.map +1 -0
  173. package/dist/esm/utils/hash.js +53 -0
  174. package/dist/esm/utils/hash.js.map +1 -0
  175. package/dist/esm/utils/index.js +19 -0
  176. package/dist/esm/utils/index.js.map +1 -0
  177. package/dist/esm/utils/serialization.js +98 -0
  178. package/dist/esm/utils/serialization.js.map +1 -0
  179. package/dist/esm/utils/validation.js +33 -0
  180. package/dist/esm/utils/validation.js.map +1 -0
  181. package/dist/types/constants/index.d.ts +27 -0
  182. package/dist/types/constants/index.d.ts.map +1 -0
  183. package/dist/types/constants/limits.d.ts +149 -0
  184. package/dist/types/constants/limits.d.ts.map +1 -0
  185. package/dist/types/constants/programs.d.ts +69 -0
  186. package/dist/types/constants/programs.d.ts.map +1 -0
  187. package/dist/types/constants/seeds.d.ts +61 -0
  188. package/dist/types/constants/seeds.d.ts.map +1 -0
  189. package/dist/types/core/client.d.ts +323 -0
  190. package/dist/types/core/client.d.ts.map +1 -0
  191. package/dist/types/core/connection.d.ts +279 -0
  192. package/dist/types/core/connection.d.ts.map +1 -0
  193. package/dist/types/core/index.d.ts +20 -0
  194. package/dist/types/core/index.d.ts.map +1 -0
  195. package/dist/types/errors/index.d.ts +276 -0
  196. package/dist/types/errors/index.d.ts.map +1 -0
  197. package/dist/types/events/index.d.ts +248 -0
  198. package/dist/types/events/index.d.ts.map +1 -0
  199. package/dist/types/idl/index.d.ts +70 -0
  200. package/dist/types/idl/index.d.ts.map +1 -0
  201. package/dist/types/index.d.ts +68 -0
  202. package/dist/types/index.d.ts.map +1 -0
  203. package/dist/types/modules/agent.d.ts +166 -0
  204. package/dist/types/modules/agent.d.ts.map +1 -0
  205. package/dist/types/modules/attestation.d.ts +96 -0
  206. package/dist/types/modules/attestation.d.ts.map +1 -0
  207. package/dist/types/modules/base.d.ts +126 -0
  208. package/dist/types/modules/base.d.ts.map +1 -0
  209. package/dist/types/modules/escrow.d.ts +151 -0
  210. package/dist/types/modules/escrow.d.ts.map +1 -0
  211. package/dist/types/modules/feedback.d.ts +105 -0
  212. package/dist/types/modules/feedback.d.ts.map +1 -0
  213. package/dist/types/modules/index.d.ts +24 -0
  214. package/dist/types/modules/index.d.ts.map +1 -0
  215. package/dist/types/modules/indexing.d.ts +200 -0
  216. package/dist/types/modules/indexing.d.ts.map +1 -0
  217. package/dist/types/modules/ledger.d.ts +150 -0
  218. package/dist/types/modules/ledger.d.ts.map +1 -0
  219. package/dist/types/modules/tools.d.ts +182 -0
  220. package/dist/types/modules/tools.d.ts.map +1 -0
  221. package/dist/types/modules/vault.d.ts +240 -0
  222. package/dist/types/modules/vault.d.ts.map +1 -0
  223. package/dist/types/pda/index.d.ts +296 -0
  224. package/dist/types/pda/index.d.ts.map +1 -0
  225. package/dist/types/plugin/index.d.ts +171 -0
  226. package/dist/types/plugin/index.d.ts.map +1 -0
  227. package/dist/types/plugin/protocols.d.ts +152 -0
  228. package/dist/types/plugin/protocols.d.ts.map +1 -0
  229. package/dist/types/plugin/schemas.d.ts +823 -0
  230. package/dist/types/plugin/schemas.d.ts.map +1 -0
  231. package/dist/types/postgres/adapter.d.ts +355 -0
  232. package/dist/types/postgres/adapter.d.ts.map +1 -0
  233. package/dist/types/postgres/index.d.ts +24 -0
  234. package/dist/types/postgres/index.d.ts.map +1 -0
  235. package/dist/types/postgres/serializers.d.ts +30 -0
  236. package/dist/types/postgres/serializers.d.ts.map +1 -0
  237. package/dist/types/postgres/sync.d.ts +132 -0
  238. package/dist/types/postgres/sync.d.ts.map +1 -0
  239. package/dist/types/postgres/types.d.ts +167 -0
  240. package/dist/types/postgres/types.d.ts.map +1 -0
  241. package/dist/types/registries/builder.d.ts +340 -0
  242. package/dist/types/registries/builder.d.ts.map +1 -0
  243. package/dist/types/registries/discovery.d.ts +333 -0
  244. package/dist/types/registries/discovery.d.ts.map +1 -0
  245. package/dist/types/registries/index.d.ts +48 -0
  246. package/dist/types/registries/index.d.ts.map +1 -0
  247. package/dist/types/registries/session.d.ts +323 -0
  248. package/dist/types/registries/session.d.ts.map +1 -0
  249. package/dist/types/registries/x402.d.ts +463 -0
  250. package/dist/types/registries/x402.d.ts.map +1 -0
  251. package/dist/types/types/accounts.d.ts +565 -0
  252. package/dist/types/types/accounts.d.ts.map +1 -0
  253. package/dist/types/types/common.d.ts +166 -0
  254. package/dist/types/types/common.d.ts.map +1 -0
  255. package/dist/types/types/enums.d.ts +238 -0
  256. package/dist/types/types/enums.d.ts.map +1 -0
  257. package/dist/types/types/index.d.ts +28 -0
  258. package/dist/types/types/index.d.ts.map +1 -0
  259. package/dist/types/types/instructions.d.ts +366 -0
  260. package/dist/types/types/instructions.d.ts.map +1 -0
  261. package/dist/types/utils/hash.d.ts +48 -0
  262. package/dist/types/utils/hash.d.ts.map +1 -0
  263. package/dist/types/utils/index.d.ts +19 -0
  264. package/dist/types/utils/index.d.ts.map +1 -0
  265. package/dist/types/utils/serialization.d.ts +69 -0
  266. package/dist/types/utils/serialization.d.ts.map +1 -0
  267. package/dist/types/utils/validation.d.ts +29 -0
  268. package/dist/types/utils/validation.d.ts.map +1 -0
  269. package/package.json +178 -0
  270. package/src/constants/index.ts +44 -0
  271. package/src/constants/limits.ts +165 -0
  272. package/src/constants/programs.ts +83 -0
  273. package/src/constants/seeds.ts +66 -0
  274. package/src/core/client.ts +416 -0
  275. package/src/core/connection.ts +409 -0
  276. package/src/core/index.ts +20 -0
  277. package/src/errors/index.ts +346 -0
  278. package/src/events/index.ts +335 -0
  279. package/src/idl/index.ts +76 -0
  280. package/src/idl/synapse_agent_sap.json +9710 -0
  281. package/src/index.ts +253 -0
  282. package/src/modules/agent.ts +319 -0
  283. package/src/modules/attestation.ts +168 -0
  284. package/src/modules/base.ts +158 -0
  285. package/src/modules/escrow.ts +308 -0
  286. package/src/modules/feedback.ts +186 -0
  287. package/src/modules/index.ts +24 -0
  288. package/src/modules/indexing.ts +444 -0
  289. package/src/modules/ledger.ts +262 -0
  290. package/src/modules/tools.ts +411 -0
  291. package/src/modules/vault.ts +533 -0
  292. package/src/pda/index.ts +512 -0
  293. package/src/plugin/index.ts +1202 -0
  294. package/src/plugin/protocols.ts +404 -0
  295. package/src/plugin/schemas.ts +909 -0
  296. package/src/postgres/adapter.ts +904 -0
  297. package/src/postgres/index.ts +59 -0
  298. package/src/postgres/schema.sql +683 -0
  299. package/src/postgres/serializers.ts +485 -0
  300. package/src/postgres/sync.ts +254 -0
  301. package/src/postgres/types.ts +245 -0
  302. package/src/registries/builder.ts +607 -0
  303. package/src/registries/discovery.ts +572 -0
  304. package/src/registries/index.ts +77 -0
  305. package/src/registries/session.ts +613 -0
  306. package/src/registries/x402.ts +906 -0
  307. package/src/types/accounts.ts +618 -0
  308. package/src/types/common.ts +187 -0
  309. package/src/types/enums.ts +214 -0
  310. package/src/types/index.ts +92 -0
  311. package/src/types/instructions.ts +413 -0
  312. package/src/utils/hash.ts +57 -0
  313. package/src/utils/index.ts +19 -0
  314. package/src/utils/serialization.ts +98 -0
  315. package/src/utils/validation.ts +36 -0
@@ -0,0 +1,187 @@
1
+ /**
2
+ * @module types/common
3
+ * @description Shared helper structs used across accounts and instructions.
4
+ *
5
+ * These types appear as nested fields in both on-chain account data
6
+ * and instruction argument DTOs.
7
+ *
8
+ * @category Types
9
+ * @since v0.1.0
10
+ */
11
+
12
+ import type { PublicKey } from "@solana/web3.js";
13
+ import type BN from "bn.js";
14
+ import type { PluginTypeKind, SettlementModeKind, TokenTypeKind } from "./enums";
15
+
16
+ // ═══════════════════════════════════════════════════════════════════
17
+ // Agent Capability
18
+ // ═══════════════════════════════════════════════════════════════════
19
+
20
+ /**
21
+ * @interface Capability
22
+ * @description Agent capability descriptor declaring what the agent can do.
23
+ *
24
+ * Capabilities use a namespaced identifier format (e.g. `"jupiter:swap"`).
25
+ * They are indexed on-chain via the `CapabilityIndex` PDA for scalable discovery.
26
+ *
27
+ * @category Types
28
+ * @since v0.1.0
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * const cap: Capability = {
33
+ * id: "jupiter:swap",
34
+ * description: "Token swap via Jupiter aggregator",
35
+ * protocolId: "jupiter",
36
+ * version: "1.0",
37
+ * };
38
+ * ```
39
+ */
40
+ export interface Capability {
41
+ /** Unique identifier (e.g. `"jupiter:swap"`). */
42
+ readonly id: string;
43
+ /** Human-readable description of the capability. */
44
+ readonly description: string | null;
45
+ /** Protocol namespace this capability belongs to. */
46
+ readonly protocolId: string | null;
47
+ /** Semantic version of the capability. */
48
+ readonly version: string | null;
49
+ }
50
+
51
+ // ═══════════════════════════════════════════════════════════════════
52
+ // Pricing
53
+ // ═══════════════════════════════════════════════════════════════════
54
+
55
+ /**
56
+ * @interface VolumeCurveBreakpoint
57
+ * @description A single breakpoint in a volume-based pricing curve.
58
+ *
59
+ * After a consumer exceeds `afterCalls` total invocations, the effective
60
+ * price drops to `pricePerCall`. Multiple breakpoints form a tiered
61
+ * discount schedule (ERC-8004–style).
62
+ *
63
+ * @category Types
64
+ * @since v0.1.0
65
+ *
66
+ * @example
67
+ * ```ts
68
+ * const curve: VolumeCurveBreakpoint[] = [
69
+ * { afterCalls: 100, pricePerCall: new BN(90_000) },
70
+ * { afterCalls: 500, pricePerCall: new BN(70_000) },
71
+ * ];
72
+ * ```
73
+ */
74
+ export interface VolumeCurveBreakpoint {
75
+ /** Number of cumulative calls after which this price tier activates. */
76
+ readonly afterCalls: number;
77
+ /** Price per call (in token base units) once `afterCalls` is exceeded. */
78
+ readonly pricePerCall: BN;
79
+ }
80
+
81
+ /**
82
+ * @interface PricingTier
83
+ * @description Full pricing tier for agent services, including rate limits,
84
+ * supported token, settlement mode, and optional volume discounts.
85
+ *
86
+ * Agents can expose multiple tiers (e.g. free, pro) each with independent
87
+ * rate-limiting and pricing parameters.
88
+ *
89
+ * @category Types
90
+ * @since v0.1.0
91
+ * @see {@link SettlementMode} for settlement strategies.
92
+ * @see {@link VolumeCurveBreakpoint} for volume-based discounts.
93
+ *
94
+ * @example
95
+ * ```ts
96
+ * import { TokenType, SettlementMode } from "@synapse-sap/sdk";
97
+ *
98
+ * const tier: PricingTier = {
99
+ * tierId: "pro",
100
+ * pricePerCall: new BN(100_000),
101
+ * minPricePerCall: null,
102
+ * maxPricePerCall: null,
103
+ * rateLimit: 60,
104
+ * maxCallsPerSession: 1000,
105
+ * burstLimit: 10,
106
+ * tokenType: TokenType.Usdc,
107
+ * tokenMint: USDC_MINT,
108
+ * tokenDecimals: 6,
109
+ * settlementMode: SettlementMode.Escrow,
110
+ * minEscrowDeposit: new BN(1_000_000),
111
+ * batchIntervalSec: null,
112
+ * volumeCurve: null,
113
+ * };
114
+ * ```
115
+ */
116
+ export interface PricingTier {
117
+ /** Unique identifier for this tier (e.g. `"free"`, `"pro"`). */
118
+ readonly tierId: string;
119
+ /** Default price per call in token base units. */
120
+ readonly pricePerCall: BN;
121
+ /** Floor price guard (optional). */
122
+ readonly minPricePerCall: BN | null;
123
+ /** Ceiling price guard (optional). */
124
+ readonly maxPricePerCall: BN | null;
125
+ /** Maximum calls per second allowed. */
126
+ readonly rateLimit: number;
127
+ /** Maximum calls allowed within a single session. */
128
+ readonly maxCallsPerSession: number;
129
+ /** Burst capacity above steady-state rate limit. */
130
+ readonly burstLimit: number | null;
131
+ /** Token type accepted for payment. */
132
+ readonly tokenType: TokenTypeKind;
133
+ /** SPL token mint address (required when `tokenType` is `Spl`). */
134
+ readonly tokenMint: PublicKey | null;
135
+ /** Decimal places for the token. */
136
+ readonly tokenDecimals: number | null;
137
+ /** Settlement strategy for this tier. */
138
+ readonly settlementMode: SettlementModeKind | null;
139
+ /** Minimum escrow deposit required (for escrow settlement). */
140
+ readonly minEscrowDeposit: BN | null;
141
+ /** Batch settlement interval in seconds (for batched settlement). */
142
+ readonly batchIntervalSec: number | null;
143
+ /** Optional volume discount breakpoints. */
144
+ readonly volumeCurve: VolumeCurveBreakpoint[] | null;
145
+ }
146
+
147
+ // ═══════════════════════════════════════════════════════════════════
148
+ // Plugin Reference
149
+ // ═══════════════════════════════════════════════════════════════════
150
+
151
+ /**
152
+ * @interface PluginRef
153
+ * @description Reference to an active plugin PDA attached to an agent.
154
+ *
155
+ * Stored in the agent's `activePlugins` array to track which extensions
156
+ * are currently enabled.
157
+ *
158
+ * @category Types
159
+ * @since v0.1.0
160
+ */
161
+ export interface PluginRef {
162
+ /** Discriminant identifying the plugin extension type. */
163
+ readonly pluginType: PluginTypeKind;
164
+ /** PDA address of the plugin account. */
165
+ readonly pda: PublicKey;
166
+ }
167
+
168
+ // ═══════════════════════════════════════════════════════════════════
169
+ // Settlement
170
+ // ═══════════════════════════════════════════════════════════════════
171
+
172
+ /**
173
+ * @interface Settlement
174
+ * @description Individual settlement entry used in batch settlement instructions.
175
+ *
176
+ * Each entry describes how many calls to settle for a given service, identified
177
+ * by its 32-byte hash.
178
+ *
179
+ * @category Types
180
+ * @since v0.1.0
181
+ */
182
+ export interface Settlement {
183
+ /** Number of calls to settle in this batch entry. */
184
+ readonly callsToSettle: BN;
185
+ /** SHA-256 hash identifying the service being settled. */
186
+ readonly serviceHash: number[]; // [u8; 32]
187
+ }
@@ -0,0 +1,214 @@
1
+ /**
2
+ * @module types/enums
3
+ * @description Anchor-compatible enum variant objects for SAP v2.
4
+ *
5
+ * Each enum mirrors the Rust discriminant format used by Anchor:
6
+ * `{ variant: {} }` — e.g. `{ sol: {} }` for `TokenType::Sol`.
7
+ *
8
+ * Use the `*Kind` types for function signatures.
9
+ *
10
+ * @category Types
11
+ * @since v0.1.0
12
+ * @see {@link https://solana.com/docs | Solana Docs}
13
+ */
14
+
15
+ // ═══════════════════════════════════════════════════════════════════
16
+ // Token Type
17
+ // ═══════════════════════════════════════════════════════════════════
18
+
19
+ /**
20
+ * @name TokenType
21
+ * @description Anchor-compatible enum variants for token types accepted by agent pricing and escrow.
22
+ *
23
+ * - `Sol` — Native SOL.
24
+ * - `Usdc` — USDC stablecoin.
25
+ * - `Spl` — Arbitrary SPL token (requires `tokenMint`).
26
+ *
27
+ * @category Types
28
+ * @since v0.1.0
29
+ *
30
+ * @example
31
+ * ```ts
32
+ * import { TokenType } from "@synapse-sap/sdk";
33
+ *
34
+ * const tier = { tokenType: TokenType.Sol };
35
+ * ```
36
+ */
37
+ export const TokenType = {
38
+ Sol: { sol: {} },
39
+ Usdc: { usdc: {} },
40
+ Spl: { spl: {} },
41
+ } as const;
42
+
43
+ /**
44
+ * @name TokenTypeKind
45
+ * @description Union of all {@link TokenType} variant shapes.
46
+ * Use this as the type for any parameter that accepts a token type discriminant.
47
+ */
48
+ export type TokenTypeKind = (typeof TokenType)[keyof typeof TokenType];
49
+
50
+ // ═══════════════════════════════════════════════════════════════════
51
+ // Plugin Type
52
+ // ═══════════════════════════════════════════════════════════════════
53
+
54
+ /**
55
+ * @name PluginType
56
+ * @description Anchor-compatible enum variants for plugin extension types.
57
+ *
58
+ * Plugins extend agent functionality and are feature-gated on-chain.
59
+ *
60
+ * - `Memory` — Encrypted memory / vault storage.
61
+ * - `Validation` — Custom validation logic.
62
+ * - `Delegation` — Hot-wallet delegation.
63
+ * - `Analytics` — Metrics & analytics.
64
+ * - `Governance` — DAO / governance participation.
65
+ * - `Custom` — User-defined plugin type.
66
+ *
67
+ * @category Types
68
+ * @since v0.1.0
69
+ *
70
+ * @example
71
+ * ```ts
72
+ * import { PluginType } from "@synapse-sap/sdk";
73
+ *
74
+ * const ref = { pluginType: PluginType.Memory, pda: vaultPda };
75
+ * ```
76
+ */
77
+ export const PluginType = {
78
+ Memory: { memory: {} },
79
+ Validation: { validation: {} },
80
+ Delegation: { delegation: {} },
81
+ Analytics: { analytics: {} },
82
+ Governance: { governance: {} },
83
+ Custom: { custom: {} },
84
+ } as const;
85
+
86
+ /**
87
+ * @name PluginTypeKind
88
+ * @description Union of all {@link PluginType} variant shapes.
89
+ */
90
+ export type PluginTypeKind = (typeof PluginType)[keyof typeof PluginType];
91
+
92
+ // ═══════════════════════════════════════════════════════════════════
93
+ // Settlement Mode
94
+ // ═══════════════════════════════════════════════════════════════════
95
+
96
+ /**
97
+ * @name SettlementMode
98
+ * @description Anchor-compatible enum variants for payment settlement strategies.
99
+ *
100
+ * - `Instant` — Pay-per-call, settled immediately on invocation.
101
+ * - `Escrow` — Pre-funded escrow account with per-call drawdown.
102
+ * - `Batched` — Aggregated settlement at fixed intervals.
103
+ * - `X402` — HTTP 402-based micropayment protocol settlement.
104
+ *
105
+ * @category Types
106
+ * @since v0.1.0
107
+ *
108
+ * @example
109
+ * ```ts
110
+ * import { SettlementMode } from "@synapse-sap/sdk";
111
+ *
112
+ * const tier = { settlementMode: SettlementMode.Escrow };
113
+ * ```
114
+ */
115
+ export const SettlementMode = {
116
+ Instant: { instant: {} },
117
+ Escrow: { escrow: {} },
118
+ Batched: { batched: {} },
119
+ X402: { x402: {} },
120
+ } as const;
121
+
122
+ /**
123
+ * @name SettlementModeKind
124
+ * @description Union of all {@link SettlementMode} variant shapes.
125
+ */
126
+ export type SettlementModeKind =
127
+ (typeof SettlementMode)[keyof typeof SettlementMode];
128
+
129
+ // ═══════════════════════════════════════════════════════════════════
130
+ // Tool HTTP Method
131
+ // ═══════════════════════════════════════════════════════════════════
132
+
133
+ /**
134
+ * @name ToolHttpMethod
135
+ * @description Anchor-compatible enum variants for the HTTP method exposed by a tool.
136
+ *
137
+ * - `Get` / `Post` / `Put` / `Delete` — Standard REST verbs.
138
+ * - `Compound` — Multi-step tool (calls several sub-operations).
139
+ *
140
+ * @category Types
141
+ * @since v0.1.0
142
+ *
143
+ * @example
144
+ * ```ts
145
+ * import { ToolHttpMethod } from "@synapse-sap/sdk";
146
+ *
147
+ * const args = { httpMethod: ToolHttpMethod.Post };
148
+ * ```
149
+ */
150
+ export const ToolHttpMethod = {
151
+ Get: { get: {} },
152
+ Post: { post: {} },
153
+ Put: { put: {} },
154
+ Delete: { delete: {} },
155
+ Compound: { compound: {} },
156
+ } as const;
157
+
158
+ /**
159
+ * @name ToolHttpMethodKind
160
+ * @description Union of all {@link ToolHttpMethod} variant shapes.
161
+ */
162
+ export type ToolHttpMethodKind =
163
+ (typeof ToolHttpMethod)[keyof typeof ToolHttpMethod];
164
+
165
+ // ═══════════════════════════════════════════════════════════════════
166
+ // Tool Category
167
+ // ═══════════════════════════════════════════════════════════════════
168
+
169
+ /**
170
+ * @name ToolCategory
171
+ * @description Anchor-compatible enum variants for classifying tools in the on-chain registry.
172
+ *
173
+ * Categories power cross-agent tool discovery via the `ToolCategoryIndex` PDA.
174
+ *
175
+ * - `Swap` — Token swap / DEX tools.
176
+ * - `Lend` — Lending protocol tools.
177
+ * - `Stake` — Staking / validator tools.
178
+ * - `Nft` — NFT minting / marketplace tools.
179
+ * - `Payment` — Payment & invoicing tools.
180
+ * - `Data` — Data feeds / oracles.
181
+ * - `Governance` — DAO & governance tools.
182
+ * - `Bridge` — Cross-chain bridge tools.
183
+ * - `Analytics` — On-chain analytics.
184
+ * - `Custom` — User-defined category.
185
+ *
186
+ * @category Types
187
+ * @since v0.1.0
188
+ *
189
+ * @example
190
+ * ```ts
191
+ * import { ToolCategory } from "@synapse-sap/sdk";
192
+ *
193
+ * const args = { category: ToolCategory.Swap };
194
+ * ```
195
+ */
196
+ export const ToolCategory = {
197
+ Swap: { swap: {} },
198
+ Lend: { lend: {} },
199
+ Stake: { stake: {} },
200
+ Nft: { nft: {} },
201
+ Payment: { payment: {} },
202
+ Data: { data: {} },
203
+ Governance: { governance: {} },
204
+ Bridge: { bridge: {} },
205
+ Analytics: { analytics: {} },
206
+ Custom: { custom: {} },
207
+ } as const;
208
+
209
+ /**
210
+ * @name ToolCategoryKind
211
+ * @description Union of all {@link ToolCategory} variant shapes.
212
+ */
213
+ export type ToolCategoryKind =
214
+ (typeof ToolCategory)[keyof typeof ToolCategory];
@@ -0,0 +1,92 @@
1
+ /**
2
+ * @module types
3
+ * @description Strongly-typed domain models for SAP v2.
4
+ *
5
+ * Every type mirrors the onchain Rust struct / enum exactly.
6
+ * Types are organized into four layers:
7
+ *
8
+ * - **enums** — Anchor-style enum variant objects (`TokenType`, `ToolCategory`, …)
9
+ * - **common** — Shared helper structs (`Capability`, `PricingTier`, `Settlement`, …)
10
+ * - **accounts** — Deserialized on-chain PDA account data (`AgentAccountData`, …)
11
+ * - **instructions** — Instruction argument DTOs + permission/schema helpers
12
+ *
13
+ * @category Types
14
+ * @since v0.1.0
15
+ *
16
+ * @example
17
+ * ```ts
18
+ * import type { AgentAccountData, RegisterAgentArgs } from "@synapse-sap/sdk/types";
19
+ * import { TokenType, SettlementMode } from "@synapse-sap/sdk/types";
20
+ * ```
21
+ */
22
+
23
+ // ── Enums ────────────────────────────────────────────
24
+ export {
25
+ TokenType,
26
+ PluginType,
27
+ SettlementMode,
28
+ ToolHttpMethod,
29
+ ToolCategory,
30
+ } from "./enums";
31
+
32
+ export type {
33
+ TokenTypeKind,
34
+ PluginTypeKind,
35
+ SettlementModeKind,
36
+ ToolHttpMethodKind,
37
+ ToolCategoryKind,
38
+ } from "./enums";
39
+
40
+ // ── Common Structs ───────────────────────────────────
41
+ export type {
42
+ Capability,
43
+ VolumeCurveBreakpoint,
44
+ PricingTier,
45
+ PluginRef,
46
+ Settlement,
47
+ } from "./common";
48
+
49
+ // ── Account Data ─────────────────────────────────────
50
+ export type {
51
+ AgentAccountData,
52
+ AgentStatsData,
53
+ FeedbackAccountData,
54
+ CapabilityIndexData,
55
+ ProtocolIndexData,
56
+ ToolCategoryIndexData,
57
+ GlobalRegistryData,
58
+ MemoryVaultData,
59
+ SessionLedgerData,
60
+ EpochPageData,
61
+ VaultDelegateData,
62
+ SessionCheckpointData,
63
+ ToolDescriptorData,
64
+ EscrowAccountData,
65
+ AgentAttestationData,
66
+ MemoryLedgerData,
67
+ LedgerPageData,
68
+ } from "./accounts";
69
+
70
+ // ── Instruction Args ─────────────────────────────────
71
+ export type {
72
+ RegisterAgentArgs,
73
+ UpdateAgentArgs,
74
+ GiveFeedbackArgs,
75
+ UpdateFeedbackArgs,
76
+ PublishToolArgs,
77
+ UpdateToolArgs,
78
+ InscribeToolSchemaArgs,
79
+ InscribeMemoryArgs,
80
+ CompactInscribeArgs,
81
+ CreateEscrowArgs,
82
+ CreateAttestationArgs,
83
+ DelegatePermissionBit,
84
+ SchemaTypeValue,
85
+ CompressionTypeValue,
86
+ } from "./instructions";
87
+
88
+ export {
89
+ DelegatePermission,
90
+ SchemaType,
91
+ CompressionType,
92
+ } from "./instructions";