@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,618 @@
1
+ /**
2
+ * @module types/accounts
3
+ * @description Deserialized on-chain account data interfaces.
4
+ *
5
+ * Every interface mirrors the corresponding Rust struct exactly.
6
+ * Anchor deserializes PDA accounts into these shapes.
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 { ToolHttpMethodKind, ToolCategoryKind } from "./enums";
15
+ import type { Capability, PricingTier, PluginRef, VolumeCurveBreakpoint } from "./common";
16
+
17
+ // ═══════════════════════════════════════════════════════════════════
18
+ // Agent
19
+ // ═══════════════════════════════════════════════════════════════════
20
+
21
+ /**
22
+ * @interface AgentAccountData
23
+ * @description Core agent identity PDA.
24
+ *
25
+ * Stores the agent's profile, reputation metrics, pricing tiers,
26
+ * capabilities, and active plugin references. This is the primary
27
+ * on-chain identity anchor for every registered agent.
28
+ *
29
+ * @category Types
30
+ * @since v0.1.0
31
+ * @see {@link AgentStatsData} for the lightweight hot-path metrics companion.
32
+ */
33
+ export interface AgentAccountData {
34
+ /** PDA bump seed. */
35
+ readonly bump: number;
36
+ /** Account schema version for migrations. */
37
+ readonly version: number;
38
+ /** Owner wallet that controls this agent. */
39
+ readonly wallet: PublicKey;
40
+ /** Human-readable agent name. */
41
+ readonly name: string;
42
+ /** Human-readable agent description. */
43
+ readonly description: string;
44
+ /** Off-chain agent identifier (e.g. DID or UUID). */
45
+ readonly agentId: string | null;
46
+ /** URI pointing to extended agent metadata (JSON). */
47
+ readonly agentUri: string | null;
48
+ /** x402 payment endpoint URL. */
49
+ readonly x402Endpoint: string | null;
50
+ /** Whether the agent is currently accepting calls. */
51
+ readonly isActive: boolean;
52
+ /** Unix timestamp of agent registration. */
53
+ readonly createdAt: BN;
54
+ /** Unix timestamp of the last profile update. */
55
+ readonly updatedAt: BN;
56
+ /** Computed reputation score (0–100). */
57
+ readonly reputationScore: number;
58
+ /** Total number of feedbacks received. */
59
+ readonly totalFeedbacks: number;
60
+ /** Raw sum of all feedback scores (used for averaging). */
61
+ readonly reputationSum: BN;
62
+ /** Lifetime calls served counter. */
63
+ readonly totalCallsServed: BN;
64
+ /** Average latency in milliseconds. */
65
+ readonly avgLatencyMs: number;
66
+ /** Uptime percentage (0–100). */
67
+ readonly uptimePercent: number;
68
+ /** Declared capabilities for discovery indexing. */
69
+ readonly capabilities: Capability[];
70
+ /** Active pricing tiers. */
71
+ readonly pricing: PricingTier[];
72
+ /** Supported protocol identifiers. */
73
+ readonly protocols: string[];
74
+ /** Currently enabled plugin references. */
75
+ readonly activePlugins: PluginRef[];
76
+ }
77
+
78
+ /**
79
+ * @interface AgentStatsData
80
+ * @description Lightweight hot-path metrics PDA for an agent.
81
+ *
82
+ * This account is separated from the main {@link AgentAccountData} to
83
+ * minimize the compute cost of frequent counter updates.
84
+ *
85
+ * @category Types
86
+ * @since v0.1.0
87
+ */
88
+ export interface AgentStatsData {
89
+ /** PDA bump seed. */
90
+ readonly bump: number;
91
+ /** Agent PDA this stats account tracks. */
92
+ readonly agent: PublicKey;
93
+ /** Owner wallet. */
94
+ readonly wallet: PublicKey;
95
+ /** Lifetime calls served counter. */
96
+ readonly totalCallsServed: BN;
97
+ /** Whether the agent is currently active. */
98
+ readonly isActive: boolean;
99
+ /** Unix timestamp of the last update. */
100
+ readonly updatedAt: BN;
101
+ }
102
+
103
+ // ═══════════════════════════════════════════════════════════════════
104
+ // Reputation
105
+ // ═══════════════════════════════════════════════════════════════════
106
+
107
+ /**
108
+ * @interface FeedbackAccountData
109
+ * @description Trustless reputation entry PDA.
110
+ *
111
+ * Each feedback is a unique PDA keyed by `[agent, reviewer]` preventing
112
+ * duplicate reviews. Scores contribute to the agent's aggregate reputation.
113
+ *
114
+ * @category Types
115
+ * @since v0.1.0
116
+ */
117
+ export interface FeedbackAccountData {
118
+ /** PDA bump seed. */
119
+ readonly bump: number;
120
+ /** Agent PDA this feedback targets. */
121
+ readonly agent: PublicKey;
122
+ /** Wallet of the reviewer who submitted the feedback. */
123
+ readonly reviewer: PublicKey;
124
+ /** Reputation score (1–100). */
125
+ readonly score: number;
126
+ /** Freeform tag / category for the feedback. */
127
+ readonly tag: string;
128
+ /** Optional SHA-256 hash of an off-chain comment. */
129
+ readonly commentHash: number[] | null; // [u8; 32]
130
+ /** Unix timestamp of creation. */
131
+ readonly createdAt: BN;
132
+ /** Unix timestamp of the last update. */
133
+ readonly updatedAt: BN;
134
+ /** Whether this feedback has been revoked by the reviewer. */
135
+ readonly isRevoked: boolean;
136
+ }
137
+
138
+ // ═══════════════════════════════════════════════════════════════════
139
+ // Discovery Indexes
140
+ // ═══════════════════════════════════════════════════════════════════
141
+
142
+ /**
143
+ * @interface CapabilityIndexData
144
+ * @description Scalable discovery index PDA keyed by capability hash.
145
+ *
146
+ * Enables consumers to look up all agents that declare a given capability.
147
+ * Supports pagination via `totalPages`.
148
+ *
149
+ * @category Types
150
+ * @since v0.1.0
151
+ */
152
+ export interface CapabilityIndexData {
153
+ readonly bump: number;
154
+ /** Human-readable capability identifier. */
155
+ readonly capabilityId: string;
156
+ /** SHA-256 hash of the capability ID used as PDA seed. */
157
+ readonly capabilityHash: number[]; // [u8; 32]
158
+ /** Agent PDAs that declare this capability. */
159
+ readonly agents: PublicKey[];
160
+ /** Total number of pages for this index. */
161
+ readonly totalPages: number;
162
+ /** Unix timestamp of the last index update. */
163
+ readonly lastUpdated: BN;
164
+ }
165
+
166
+ /**
167
+ * @interface ProtocolIndexData
168
+ * @description Scalable discovery index PDA keyed by protocol hash.
169
+ *
170
+ * Enables consumers to look up all agents that support a given protocol.
171
+ *
172
+ * @category Types
173
+ * @since v0.1.0
174
+ */
175
+ export interface ProtocolIndexData {
176
+ readonly bump: number;
177
+ /** Human-readable protocol identifier. */
178
+ readonly protocolId: string;
179
+ /** SHA-256 hash of the protocol ID used as PDA seed. */
180
+ readonly protocolHash: number[]; // [u8; 32]
181
+ /** Agent PDAs that support this protocol. */
182
+ readonly agents: PublicKey[];
183
+ /** Total number of pages for this index. */
184
+ readonly totalPages: number;
185
+ /** Unix timestamp of the last index update. */
186
+ readonly lastUpdated: BN;
187
+ }
188
+
189
+ /**
190
+ * @interface ToolCategoryIndexData
191
+ * @description Cross-agent tool discovery index PDA keyed by category.
192
+ *
193
+ * @category Types
194
+ * @since v0.1.0
195
+ */
196
+ export interface ToolCategoryIndexData {
197
+ readonly bump: number;
198
+ /** Numeric category discriminant. */
199
+ readonly category: number;
200
+ /** Tool descriptor PDAs in this category. */
201
+ readonly tools: PublicKey[];
202
+ /** Total number of pages for this index. */
203
+ readonly totalPages: number;
204
+ /** Unix timestamp of the last index update. */
205
+ readonly lastUpdated: BN;
206
+ }
207
+
208
+ // ═══════════════════════════════════════════════════════════════════
209
+ // Global Registry
210
+ // ═══════════════════════════════════════════════════════════════════
211
+
212
+ /**
213
+ * @interface GlobalRegistryData
214
+ * @description Network-wide statistics singleton PDA.
215
+ *
216
+ * A single instance exists per program deployment and aggregates global
217
+ * counters across all agents, feedbacks, tools, vaults, escrows, and attestations.
218
+ *
219
+ * @category Types
220
+ * @since v0.1.0
221
+ */
222
+ export interface GlobalRegistryData {
223
+ readonly bump: number;
224
+ /** Total number of registered agents. */
225
+ readonly totalAgents: BN;
226
+ /** Number of currently active agents. */
227
+ readonly activeAgents: BN;
228
+ /** Total feedbacks submitted network-wide. */
229
+ readonly totalFeedbacks: BN;
230
+ /** Distinct capability count. */
231
+ readonly totalCapabilities: number;
232
+ /** Distinct protocol count. */
233
+ readonly totalProtocols: number;
234
+ /** Unix timestamp of the last agent registration. */
235
+ readonly lastRegisteredAt: BN;
236
+ /** Unix timestamp of registry initialization. */
237
+ readonly initializedAt: BN;
238
+ /** Upgrade authority for the registry. */
239
+ readonly authority: PublicKey;
240
+ /** Total published tools. */
241
+ readonly totalTools: number;
242
+ /** Total memory vaults. */
243
+ readonly totalVaults: number;
244
+ /** Total escrow accounts. */
245
+ readonly totalEscrows: number;
246
+ /** Total attestations issued. */
247
+ readonly totalAttestations: number;
248
+ }
249
+
250
+ // ═══════════════════════════════════════════════════════════════════
251
+ // Memory Vault
252
+ // ═══════════════════════════════════════════════════════════════════
253
+
254
+ /**
255
+ * @interface MemoryVaultData
256
+ * @description Encrypted inscription vault PDA.
257
+ *
258
+ * Each agent may own one vault that stores NaCl-encrypted memory
259
+ * inscriptions across multiple sessions. The vault tracks a nonce
260
+ * for key rotation.
261
+ *
262
+ * @category Types
263
+ * @since v0.1.0
264
+ */
265
+ export interface MemoryVaultData {
266
+ readonly bump: number;
267
+ /** Agent PDA that owns this vault. */
268
+ readonly agent: PublicKey;
269
+ /** Wallet of the vault owner. */
270
+ readonly wallet: PublicKey;
271
+ /** Current encryption nonce seed (32 bytes). */
272
+ readonly vaultNonce: number[]; // [u8; 32]
273
+ /** Total sessions created inside this vault. */
274
+ readonly totalSessions: number;
275
+ /** Total inscriptions across all sessions. */
276
+ readonly totalInscriptions: BN;
277
+ /** Total bytes inscribed across all sessions. */
278
+ readonly totalBytesInscribed: BN;
279
+ /** Unix timestamp of vault creation. */
280
+ readonly createdAt: BN;
281
+ /** Protocol version this vault was created with. */
282
+ readonly protocolVersion: number;
283
+ /** Current nonce version (increments on rotation). */
284
+ readonly nonceVersion: number;
285
+ /** Unix timestamp of the last nonce rotation. */
286
+ readonly lastNonceRotation: BN;
287
+ }
288
+
289
+ /**
290
+ * @interface SessionLedgerData
291
+ * @description Compact session index PDA within a {@link MemoryVaultData}.
292
+ *
293
+ * Tracks inscription order, epoch segmentation, Merkle checkpointing,
294
+ * and the hash-chain tip for integrity verification.
295
+ *
296
+ * @category Types
297
+ * @since v0.1.0
298
+ */
299
+ export interface SessionLedgerData {
300
+ readonly bump: number;
301
+ /** Parent vault PDA. */
302
+ readonly vault: PublicKey;
303
+ /** SHA-256 session identifier. */
304
+ readonly sessionHash: number[]; // [u8; 32]
305
+ /** Next inscription sequence number. */
306
+ readonly sequenceCounter: number;
307
+ /** Total bytes inscribed in this session. */
308
+ readonly totalBytes: BN;
309
+ /** Current epoch index. */
310
+ readonly currentEpoch: number;
311
+ /** Total epochs created. */
312
+ readonly totalEpochs: number;
313
+ /** Unix timestamp of session creation. */
314
+ readonly createdAt: BN;
315
+ /** Unix timestamp of the last inscription. */
316
+ readonly lastInscribedAt: BN;
317
+ /** Whether the session has been closed. */
318
+ readonly isClosed: boolean;
319
+ /** Running Merkle root across all inscriptions. */
320
+ readonly merkleRoot: number[]; // [u8; 32]
321
+ /** Total checkpoints taken. */
322
+ readonly totalCheckpoints: number;
323
+ /** Hash of the latest inscription in the chain. */
324
+ readonly tipHash: number[]; // [u8; 32]
325
+ }
326
+
327
+ /**
328
+ * @interface EpochPageData
329
+ * @description Per-epoch scan target PDA within a session.
330
+ *
331
+ * Epochs partition inscriptions into bounded pages, enabling efficient
332
+ * range scans and garbage collection.
333
+ *
334
+ * @category Types
335
+ * @since v0.1.0
336
+ */
337
+ export interface EpochPageData {
338
+ readonly bump: number;
339
+ /** Parent session PDA. */
340
+ readonly session: PublicKey;
341
+ /** Zero-based epoch index. */
342
+ readonly epochIndex: number;
343
+ /** Sequence number of the first inscription in this epoch. */
344
+ readonly startSequence: number;
345
+ /** Number of inscriptions in this epoch. */
346
+ readonly inscriptionCount: number;
347
+ /** Total bytes across all inscriptions in this epoch. */
348
+ readonly totalBytes: number;
349
+ /** Unix timestamp of the first inscription. */
350
+ readonly firstTs: BN;
351
+ /** Unix timestamp of the last inscription. */
352
+ readonly lastTs: BN;
353
+ }
354
+
355
+ /**
356
+ * @interface VaultDelegateData
357
+ * @description Hot-wallet authorization PDA for vault operations.
358
+ *
359
+ * Allows a delegate wallet to perform permitted operations (inscribe,
360
+ * open/close sessions) on behalf of the vault owner until expiry.
361
+ *
362
+ * @category Types
363
+ * @since v0.1.0
364
+ * @see {@link DelegatePermission} for available permission bits.
365
+ */
366
+ export interface VaultDelegateData {
367
+ readonly bump: number;
368
+ /** Parent vault PDA. */
369
+ readonly vault: PublicKey;
370
+ /** Delegate wallet public key. */
371
+ readonly delegate: PublicKey;
372
+ /** Bitmask of granted permissions. */
373
+ readonly permissions: number;
374
+ /** Unix timestamp when the delegation expires. */
375
+ readonly expiresAt: BN;
376
+ /** Unix timestamp of delegation creation. */
377
+ readonly createdAt: BN;
378
+ }
379
+
380
+ /**
381
+ * @interface SessionCheckpointData
382
+ * @description Fast-sync snapshot PDA for a session.
383
+ *
384
+ * Checkpoints capture a Merkle root at a particular sequence point,
385
+ * enabling clients to verify session integrity without replaying
386
+ * every inscription.
387
+ *
388
+ * @category Types
389
+ * @since v0.1.0
390
+ */
391
+ export interface SessionCheckpointData {
392
+ readonly bump: number;
393
+ /** Parent session PDA. */
394
+ readonly session: PublicKey;
395
+ /** Zero-based checkpoint index. */
396
+ readonly checkpointIndex: number;
397
+ /** Merkle root at the checkpoint. */
398
+ readonly merkleRoot: number[]; // [u8; 32]
399
+ /** Sequence number at which the checkpoint was taken. */
400
+ readonly sequenceAt: number;
401
+ /** Epoch index at checkpoint time. */
402
+ readonly epochAt: number;
403
+ /** Cumulative bytes at checkpoint time. */
404
+ readonly totalBytesAt: BN;
405
+ /** Cumulative inscriptions at checkpoint time. */
406
+ readonly inscriptionsAt: BN;
407
+ /** Unix timestamp when the checkpoint was created. */
408
+ readonly createdAt: BN;
409
+ }
410
+
411
+ // ═══════════════════════════════════════════════════════════════════
412
+ // Tools
413
+ // ═══════════════════════════════════════════════════════════════════
414
+
415
+ /**
416
+ * @interface ToolDescriptorData
417
+ * @description On-chain tool schema registry PDA.
418
+ *
419
+ * Each published tool stores hashed metadata (description, input/output schemas)
420
+ * and tracks invocation count. Tools support versioning via `previousVersion`
421
+ * back-links.
422
+ *
423
+ * @category Types
424
+ * @since v0.1.0
425
+ * @see {@link ToolHttpMethod} for HTTP method variants.
426
+ * @see {@link ToolCategory} for category variants.
427
+ */
428
+ export interface ToolDescriptorData {
429
+ readonly bump: number;
430
+ /** Agent PDA that owns this tool. */
431
+ readonly agent: PublicKey;
432
+ /** SHA-256 hash of the tool name (PDA seed). */
433
+ readonly toolNameHash: number[]; // [u8; 32]
434
+ /** Human-readable tool name. */
435
+ readonly toolName: string;
436
+ /** SHA-256 hash of the protocol identifier. */
437
+ readonly protocolHash: number[]; // [u8; 32]
438
+ /** Schema version. */
439
+ readonly version: number;
440
+ /** SHA-256 hash of the tool description. */
441
+ readonly descriptionHash: number[]; // [u8; 32]
442
+ /** SHA-256 hash of the input JSON schema. */
443
+ readonly inputSchemaHash: number[]; // [u8; 32]
444
+ /** SHA-256 hash of the output JSON schema. */
445
+ readonly outputSchemaHash: number[]; // [u8; 32]
446
+ /** HTTP method exposed by this tool. */
447
+ readonly httpMethod: ToolHttpMethodKind;
448
+ /** Discovery category. */
449
+ readonly category: ToolCategoryKind;
450
+ /** Total number of parameters. */
451
+ readonly paramsCount: number;
452
+ /** Number of required parameters. */
453
+ readonly requiredParams: number;
454
+ /** Whether this tool is a compound (multi-step) operation. */
455
+ readonly isCompound: boolean;
456
+ /** Whether this tool is currently enabled. */
457
+ readonly isActive: boolean;
458
+ /** Lifetime invocation counter. */
459
+ readonly totalInvocations: BN;
460
+ /** Unix timestamp of creation. */
461
+ readonly createdAt: BN;
462
+ /** Unix timestamp of the last update. */
463
+ readonly updatedAt: BN;
464
+ /** PDA of the previous version (zero key if first version). */
465
+ readonly previousVersion: PublicKey;
466
+ }
467
+
468
+ // ═══════════════════════════════════════════════════════════════════
469
+ // Escrow
470
+ // ═══════════════════════════════════════════════════════════════════
471
+
472
+ /**
473
+ * @interface EscrowAccountData
474
+ * @description x402 pre-funded micropayment escrow PDA.
475
+ *
476
+ * An escrow is created by a consumer (depositor) for a specific agent.
477
+ * Calls are settled against the escrow balance either per-call or in
478
+ * batches, with optional volume-curve discounts.
479
+ *
480
+ * @category Types
481
+ * @since v0.1.0
482
+ * @see {@link VolumeCurveBreakpoint} for discount curve details.
483
+ */
484
+ export interface EscrowAccountData {
485
+ readonly bump: number;
486
+ /** Agent PDA this escrow is for. */
487
+ readonly agent: PublicKey;
488
+ /** Consumer wallet that funded the escrow. */
489
+ readonly depositor: PublicKey;
490
+ /** Agent's wallet that receives settlements. */
491
+ readonly agentWallet: PublicKey;
492
+ /** Current remaining balance (in token base units). */
493
+ readonly balance: BN;
494
+ /** Cumulative amount deposited. */
495
+ readonly totalDeposited: BN;
496
+ /** Cumulative amount settled to the agent. */
497
+ readonly totalSettled: BN;
498
+ /** Cumulative calls settled. */
499
+ readonly totalCallsSettled: BN;
500
+ /** Base price per call. */
501
+ readonly pricePerCall: BN;
502
+ /** Maximum number of calls this escrow funds. */
503
+ readonly maxCalls: BN;
504
+ /** Unix timestamp of escrow creation. */
505
+ readonly createdAt: BN;
506
+ /** Unix timestamp of the last settlement. */
507
+ readonly lastSettledAt: BN;
508
+ /** Unix timestamp when the escrow expires. */
509
+ readonly expiresAt: BN;
510
+ /** Volume discount breakpoints. */
511
+ readonly volumeCurve: VolumeCurveBreakpoint[];
512
+ /** Optional SPL token mint (null for native SOL). */
513
+ readonly tokenMint: PublicKey | null;
514
+ /** Decimal places for the token. */
515
+ readonly tokenDecimals: number;
516
+ }
517
+
518
+ // ═══════════════════════════════════════════════════════════════════
519
+ // Attestation
520
+ // ═══════════════════════════════════════════════════════════════════
521
+
522
+ /**
523
+ * @interface AgentAttestationData
524
+ * @description Web-of-trust attestation PDA.
525
+ *
526
+ * Attestations allow one agent or authority to vouch for another agent's
527
+ * identity, compliance, or capabilities. They support expiration and
528
+ * can be deactivated.
529
+ *
530
+ * @category Types
531
+ * @since v0.1.0
532
+ */
533
+ export interface AgentAttestationData {
534
+ readonly bump: number;
535
+ /** Agent PDA being attested. */
536
+ readonly agent: PublicKey;
537
+ /** Wallet of the attester. */
538
+ readonly attester: PublicKey;
539
+ /** Freeform attestation type (e.g. `"kyc"`, `"audit"`). */
540
+ readonly attestationType: string;
541
+ /** SHA-256 hash of off-chain attestation metadata. */
542
+ readonly metadataHash: number[]; // [u8; 32]
543
+ /** Whether the attestation is currently active. */
544
+ readonly isActive: boolean;
545
+ /** Unix timestamp when the attestation expires. */
546
+ readonly expiresAt: BN;
547
+ /** Unix timestamp of creation. */
548
+ readonly createdAt: BN;
549
+ /** Unix timestamp of the last update. */
550
+ readonly updatedAt: BN;
551
+ }
552
+
553
+ // ═══════════════════════════════════════════════════════════════════
554
+ // Memory Ledger
555
+ // ═══════════════════════════════════════════════════════════════════
556
+
557
+ /**
558
+ * @interface MemoryLedgerData
559
+ * @description Unified on-chain memory ledger PDA.
560
+ *
561
+ * Provides a ring-buffer based memory store with Merkle-root integrity,
562
+ * supporting sealed page archival and hash-chain verification.
563
+ *
564
+ * @category Types
565
+ * @since v0.1.0
566
+ * @see {@link LedgerPageData} for sealed archive pages.
567
+ */
568
+ export interface MemoryLedgerData {
569
+ readonly bump: number;
570
+ /** Parent session PDA. */
571
+ readonly session: PublicKey;
572
+ /** Authority that controls ledger writes. */
573
+ readonly authority: PublicKey;
574
+ /** Current number of entries in the ring buffer. */
575
+ readonly numEntries: number;
576
+ /** Running Merkle root across all entries. */
577
+ readonly merkleRoot: number[]; // [u8; 32]
578
+ /** Hash of the latest entry in the chain. */
579
+ readonly latestHash: number[]; // [u8; 32]
580
+ /** Total data size in bytes. */
581
+ readonly totalDataSize: BN;
582
+ /** Unix timestamp of ledger creation. */
583
+ readonly createdAt: BN;
584
+ /** Unix timestamp of the last update. */
585
+ readonly updatedAt: BN;
586
+ /** Number of sealed pages. */
587
+ readonly numPages: number;
588
+ /** Ring-buffer raw bytes. */
589
+ readonly ring: number[]; // Vec<u8>
590
+ }
591
+
592
+ /**
593
+ * @interface LedgerPageData
594
+ * @description Sealed archive page PDA (write-once, never-delete).
595
+ *
596
+ * When a ledger’s ring buffer is full, entries are sealed into
597
+ * immutable pages with a Merkle root snapshot for verifiability.
598
+ *
599
+ * @category Types
600
+ * @since v0.1.0
601
+ */
602
+ export interface LedgerPageData {
603
+ readonly bump: number;
604
+ /** Parent ledger PDA. */
605
+ readonly ledger: PublicKey;
606
+ /** Zero-based page index. */
607
+ readonly pageIndex: number;
608
+ /** Unix timestamp when the page was sealed. */
609
+ readonly sealedAt: BN;
610
+ /** Number of entries archived in this page. */
611
+ readonly entriesInPage: number;
612
+ /** Total data size of this page in bytes. */
613
+ readonly dataSize: number;
614
+ /** Merkle root at the time of sealing. */
615
+ readonly merkleRootAtSeal: number[]; // [u8; 32]
616
+ /** Raw archived data bytes. */
617
+ readonly data: number[]; // Vec<u8>
618
+ }