@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.
- package/LICENSE +21 -0
- package/README.md +882 -0
- package/dist/cjs/constants/index.js +43 -0
- package/dist/cjs/constants/index.js.map +1 -0
- package/dist/cjs/constants/limits.js +161 -0
- package/dist/cjs/constants/limits.js.map +1 -0
- package/dist/cjs/constants/programs.js +78 -0
- package/dist/cjs/constants/programs.js.map +1 -0
- package/dist/cjs/constants/seeds.js +57 -0
- package/dist/cjs/constants/seeds.js.map +1 -0
- package/dist/cjs/core/client.js +391 -0
- package/dist/cjs/core/client.js.map +1 -0
- package/dist/cjs/core/connection.js +319 -0
- package/dist/cjs/core/connection.js.map +1 -0
- package/dist/cjs/core/index.js +24 -0
- package/dist/cjs/core/index.js.map +1 -0
- package/dist/cjs/errors/index.js +334 -0
- package/dist/cjs/errors/index.js.map +1 -0
- package/dist/cjs/events/index.js +136 -0
- package/dist/cjs/events/index.js.map +1 -0
- package/dist/cjs/idl/index.js +63 -0
- package/dist/cjs/idl/index.js.map +1 -0
- package/dist/cjs/idl/synapse_agent_sap.json +9710 -0
- package/dist/cjs/index.js +147 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/modules/agent.js +272 -0
- package/dist/cjs/modules/agent.js.map +1 -0
- package/dist/cjs/modules/attestation.js +147 -0
- package/dist/cjs/modules/attestation.js.map +1 -0
- package/dist/cjs/modules/base.js +128 -0
- package/dist/cjs/modules/base.js.map +1 -0
- package/dist/cjs/modules/escrow.js +246 -0
- package/dist/cjs/modules/escrow.js.map +1 -0
- package/dist/cjs/modules/feedback.js +166 -0
- package/dist/cjs/modules/feedback.js.map +1 -0
- package/dist/cjs/modules/index.js +35 -0
- package/dist/cjs/modules/index.js.map +1 -0
- package/dist/cjs/modules/indexing.js +375 -0
- package/dist/cjs/modules/indexing.js.map +1 -0
- package/dist/cjs/modules/ledger.js +234 -0
- package/dist/cjs/modules/ledger.js.map +1 -0
- package/dist/cjs/modules/tools.js +319 -0
- package/dist/cjs/modules/tools.js.map +1 -0
- package/dist/cjs/modules/vault.js +410 -0
- package/dist/cjs/modules/vault.js.map +1 -0
- package/dist/cjs/pda/index.js +377 -0
- package/dist/cjs/pda/index.js.map +1 -0
- package/dist/cjs/plugin/index.js +934 -0
- package/dist/cjs/plugin/index.js.map +1 -0
- package/dist/cjs/plugin/protocols.js +282 -0
- package/dist/cjs/plugin/protocols.js.map +1 -0
- package/dist/cjs/plugin/schemas.js +831 -0
- package/dist/cjs/plugin/schemas.js.map +1 -0
- package/dist/cjs/postgres/adapter.js +715 -0
- package/dist/cjs/postgres/adapter.js.map +1 -0
- package/dist/cjs/postgres/index.js +50 -0
- package/dist/cjs/postgres/index.js.map +1 -0
- package/dist/cjs/postgres/serializers.js +381 -0
- package/dist/cjs/postgres/serializers.js.map +1 -0
- package/dist/cjs/postgres/sync.js +221 -0
- package/dist/cjs/postgres/sync.js.map +1 -0
- package/dist/cjs/postgres/types.js +44 -0
- package/dist/cjs/postgres/types.js.map +1 -0
- package/dist/cjs/registries/builder.js +414 -0
- package/dist/cjs/registries/builder.js.map +1 -0
- package/dist/cjs/registries/discovery.js +362 -0
- package/dist/cjs/registries/discovery.js.map +1 -0
- package/dist/cjs/registries/index.js +51 -0
- package/dist/cjs/registries/index.js.map +1 -0
- package/dist/cjs/registries/session.js +433 -0
- package/dist/cjs/registries/session.js.map +1 -0
- package/dist/cjs/registries/x402.js +577 -0
- package/dist/cjs/registries/x402.js.map +1 -0
- package/dist/cjs/types/accounts.js +13 -0
- package/dist/cjs/types/accounts.js.map +1 -0
- package/dist/cjs/types/common.js +13 -0
- package/dist/cjs/types/common.js.map +1 -0
- package/dist/cjs/types/enums.js +174 -0
- package/dist/cjs/types/enums.js.map +1 -0
- package/dist/cjs/types/index.js +36 -0
- package/dist/cjs/types/index.js.map +1 -0
- package/dist/cjs/types/instructions.js +92 -0
- package/dist/cjs/types/instructions.js.map +1 -0
- package/dist/cjs/utils/hash.js +58 -0
- package/dist/cjs/utils/hash.js.map +1 -0
- package/dist/cjs/utils/index.js +27 -0
- package/dist/cjs/utils/index.js.map +1 -0
- package/dist/cjs/utils/serialization.js +105 -0
- package/dist/cjs/utils/serialization.js.map +1 -0
- package/dist/cjs/utils/validation.js +36 -0
- package/dist/cjs/utils/validation.js.map +1 -0
- package/dist/esm/constants/index.js +29 -0
- package/dist/esm/constants/index.js.map +1 -0
- package/dist/esm/constants/limits.js +158 -0
- package/dist/esm/constants/limits.js.map +1 -0
- package/dist/esm/constants/programs.js +75 -0
- package/dist/esm/constants/programs.js.map +1 -0
- package/dist/esm/constants/seeds.js +54 -0
- package/dist/esm/constants/seeds.js.map +1 -0
- package/dist/esm/core/client.js +384 -0
- package/dist/esm/core/client.js.map +1 -0
- package/dist/esm/core/connection.js +315 -0
- package/dist/esm/core/connection.js.map +1 -0
- package/dist/esm/core/index.js +19 -0
- package/dist/esm/core/index.js.map +1 -0
- package/dist/esm/errors/index.js +325 -0
- package/dist/esm/errors/index.js.map +1 -0
- package/dist/esm/events/index.js +132 -0
- package/dist/esm/events/index.js.map +1 -0
- package/dist/esm/idl/index.js +57 -0
- package/dist/esm/idl/index.js.map +1 -0
- package/dist/esm/idl/synapse_agent_sap.json +9710 -0
- package/dist/esm/index.js +70 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/modules/agent.js +268 -0
- package/dist/esm/modules/agent.js.map +1 -0
- package/dist/esm/modules/attestation.js +143 -0
- package/dist/esm/modules/attestation.js.map +1 -0
- package/dist/esm/modules/base.js +124 -0
- package/dist/esm/modules/base.js.map +1 -0
- package/dist/esm/modules/escrow.js +242 -0
- package/dist/esm/modules/escrow.js.map +1 -0
- package/dist/esm/modules/feedback.js +162 -0
- package/dist/esm/modules/feedback.js.map +1 -0
- package/dist/esm/modules/index.js +23 -0
- package/dist/esm/modules/index.js.map +1 -0
- package/dist/esm/modules/indexing.js +371 -0
- package/dist/esm/modules/indexing.js.map +1 -0
- package/dist/esm/modules/ledger.js +230 -0
- package/dist/esm/modules/ledger.js.map +1 -0
- package/dist/esm/modules/tools.js +315 -0
- package/dist/esm/modules/tools.js.map +1 -0
- package/dist/esm/modules/vault.js +406 -0
- package/dist/esm/modules/vault.js.map +1 -0
- package/dist/esm/pda/index.js +357 -0
- package/dist/esm/pda/index.js.map +1 -0
- package/dist/esm/plugin/index.js +927 -0
- package/dist/esm/plugin/index.js.map +1 -0
- package/dist/esm/plugin/protocols.js +279 -0
- package/dist/esm/plugin/protocols.js.map +1 -0
- package/dist/esm/plugin/schemas.js +828 -0
- package/dist/esm/plugin/schemas.js.map +1 -0
- package/dist/esm/postgres/adapter.js +678 -0
- package/dist/esm/postgres/adapter.js.map +1 -0
- package/dist/esm/postgres/index.js +27 -0
- package/dist/esm/postgres/index.js.map +1 -0
- package/dist/esm/postgres/serializers.js +362 -0
- package/dist/esm/postgres/serializers.js.map +1 -0
- package/dist/esm/postgres/sync.js +217 -0
- package/dist/esm/postgres/sync.js.map +1 -0
- package/dist/esm/postgres/types.js +41 -0
- package/dist/esm/postgres/types.js.map +1 -0
- package/dist/esm/registries/builder.js +410 -0
- package/dist/esm/registries/builder.js.map +1 -0
- package/dist/esm/registries/discovery.js +358 -0
- package/dist/esm/registries/discovery.js.map +1 -0
- package/dist/esm/registries/index.js +44 -0
- package/dist/esm/registries/index.js.map +1 -0
- package/dist/esm/registries/session.js +429 -0
- package/dist/esm/registries/session.js.map +1 -0
- package/dist/esm/registries/x402.js +573 -0
- package/dist/esm/registries/x402.js.map +1 -0
- package/dist/esm/types/accounts.js +12 -0
- package/dist/esm/types/accounts.js.map +1 -0
- package/dist/esm/types/common.js +12 -0
- package/dist/esm/types/common.js.map +1 -0
- package/dist/esm/types/enums.js +171 -0
- package/dist/esm/types/enums.js.map +1 -0
- package/dist/esm/types/index.js +25 -0
- package/dist/esm/types/index.js.map +1 -0
- package/dist/esm/types/instructions.js +89 -0
- package/dist/esm/types/instructions.js.map +1 -0
- package/dist/esm/utils/hash.js +53 -0
- package/dist/esm/utils/hash.js.map +1 -0
- package/dist/esm/utils/index.js +19 -0
- package/dist/esm/utils/index.js.map +1 -0
- package/dist/esm/utils/serialization.js +98 -0
- package/dist/esm/utils/serialization.js.map +1 -0
- package/dist/esm/utils/validation.js +33 -0
- package/dist/esm/utils/validation.js.map +1 -0
- package/dist/types/constants/index.d.ts +27 -0
- package/dist/types/constants/index.d.ts.map +1 -0
- package/dist/types/constants/limits.d.ts +149 -0
- package/dist/types/constants/limits.d.ts.map +1 -0
- package/dist/types/constants/programs.d.ts +69 -0
- package/dist/types/constants/programs.d.ts.map +1 -0
- package/dist/types/constants/seeds.d.ts +61 -0
- package/dist/types/constants/seeds.d.ts.map +1 -0
- package/dist/types/core/client.d.ts +323 -0
- package/dist/types/core/client.d.ts.map +1 -0
- package/dist/types/core/connection.d.ts +279 -0
- package/dist/types/core/connection.d.ts.map +1 -0
- package/dist/types/core/index.d.ts +20 -0
- package/dist/types/core/index.d.ts.map +1 -0
- package/dist/types/errors/index.d.ts +276 -0
- package/dist/types/errors/index.d.ts.map +1 -0
- package/dist/types/events/index.d.ts +248 -0
- package/dist/types/events/index.d.ts.map +1 -0
- package/dist/types/idl/index.d.ts +70 -0
- package/dist/types/idl/index.d.ts.map +1 -0
- package/dist/types/index.d.ts +68 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/modules/agent.d.ts +166 -0
- package/dist/types/modules/agent.d.ts.map +1 -0
- package/dist/types/modules/attestation.d.ts +96 -0
- package/dist/types/modules/attestation.d.ts.map +1 -0
- package/dist/types/modules/base.d.ts +126 -0
- package/dist/types/modules/base.d.ts.map +1 -0
- package/dist/types/modules/escrow.d.ts +151 -0
- package/dist/types/modules/escrow.d.ts.map +1 -0
- package/dist/types/modules/feedback.d.ts +105 -0
- package/dist/types/modules/feedback.d.ts.map +1 -0
- package/dist/types/modules/index.d.ts +24 -0
- package/dist/types/modules/index.d.ts.map +1 -0
- package/dist/types/modules/indexing.d.ts +200 -0
- package/dist/types/modules/indexing.d.ts.map +1 -0
- package/dist/types/modules/ledger.d.ts +150 -0
- package/dist/types/modules/ledger.d.ts.map +1 -0
- package/dist/types/modules/tools.d.ts +182 -0
- package/dist/types/modules/tools.d.ts.map +1 -0
- package/dist/types/modules/vault.d.ts +240 -0
- package/dist/types/modules/vault.d.ts.map +1 -0
- package/dist/types/pda/index.d.ts +296 -0
- package/dist/types/pda/index.d.ts.map +1 -0
- package/dist/types/plugin/index.d.ts +171 -0
- package/dist/types/plugin/index.d.ts.map +1 -0
- package/dist/types/plugin/protocols.d.ts +152 -0
- package/dist/types/plugin/protocols.d.ts.map +1 -0
- package/dist/types/plugin/schemas.d.ts +823 -0
- package/dist/types/plugin/schemas.d.ts.map +1 -0
- package/dist/types/postgres/adapter.d.ts +355 -0
- package/dist/types/postgres/adapter.d.ts.map +1 -0
- package/dist/types/postgres/index.d.ts +24 -0
- package/dist/types/postgres/index.d.ts.map +1 -0
- package/dist/types/postgres/serializers.d.ts +30 -0
- package/dist/types/postgres/serializers.d.ts.map +1 -0
- package/dist/types/postgres/sync.d.ts +132 -0
- package/dist/types/postgres/sync.d.ts.map +1 -0
- package/dist/types/postgres/types.d.ts +167 -0
- package/dist/types/postgres/types.d.ts.map +1 -0
- package/dist/types/registries/builder.d.ts +340 -0
- package/dist/types/registries/builder.d.ts.map +1 -0
- package/dist/types/registries/discovery.d.ts +333 -0
- package/dist/types/registries/discovery.d.ts.map +1 -0
- package/dist/types/registries/index.d.ts +48 -0
- package/dist/types/registries/index.d.ts.map +1 -0
- package/dist/types/registries/session.d.ts +323 -0
- package/dist/types/registries/session.d.ts.map +1 -0
- package/dist/types/registries/x402.d.ts +463 -0
- package/dist/types/registries/x402.d.ts.map +1 -0
- package/dist/types/types/accounts.d.ts +565 -0
- package/dist/types/types/accounts.d.ts.map +1 -0
- package/dist/types/types/common.d.ts +166 -0
- package/dist/types/types/common.d.ts.map +1 -0
- package/dist/types/types/enums.d.ts +238 -0
- package/dist/types/types/enums.d.ts.map +1 -0
- package/dist/types/types/index.d.ts +28 -0
- package/dist/types/types/index.d.ts.map +1 -0
- package/dist/types/types/instructions.d.ts +366 -0
- package/dist/types/types/instructions.d.ts.map +1 -0
- package/dist/types/utils/hash.d.ts +48 -0
- package/dist/types/utils/hash.d.ts.map +1 -0
- package/dist/types/utils/index.d.ts +19 -0
- package/dist/types/utils/index.d.ts.map +1 -0
- package/dist/types/utils/serialization.d.ts +69 -0
- package/dist/types/utils/serialization.d.ts.map +1 -0
- package/dist/types/utils/validation.d.ts +29 -0
- package/dist/types/utils/validation.d.ts.map +1 -0
- package/package.json +178 -0
- package/src/constants/index.ts +44 -0
- package/src/constants/limits.ts +165 -0
- package/src/constants/programs.ts +83 -0
- package/src/constants/seeds.ts +66 -0
- package/src/core/client.ts +416 -0
- package/src/core/connection.ts +409 -0
- package/src/core/index.ts +20 -0
- package/src/errors/index.ts +346 -0
- package/src/events/index.ts +335 -0
- package/src/idl/index.ts +76 -0
- package/src/idl/synapse_agent_sap.json +9710 -0
- package/src/index.ts +253 -0
- package/src/modules/agent.ts +319 -0
- package/src/modules/attestation.ts +168 -0
- package/src/modules/base.ts +158 -0
- package/src/modules/escrow.ts +308 -0
- package/src/modules/feedback.ts +186 -0
- package/src/modules/index.ts +24 -0
- package/src/modules/indexing.ts +444 -0
- package/src/modules/ledger.ts +262 -0
- package/src/modules/tools.ts +411 -0
- package/src/modules/vault.ts +533 -0
- package/src/pda/index.ts +512 -0
- package/src/plugin/index.ts +1202 -0
- package/src/plugin/protocols.ts +404 -0
- package/src/plugin/schemas.ts +909 -0
- package/src/postgres/adapter.ts +904 -0
- package/src/postgres/index.ts +59 -0
- package/src/postgres/schema.sql +683 -0
- package/src/postgres/serializers.ts +485 -0
- package/src/postgres/sync.ts +254 -0
- package/src/postgres/types.ts +245 -0
- package/src/registries/builder.ts +607 -0
- package/src/registries/discovery.ts +572 -0
- package/src/registries/index.ts +77 -0
- package/src/registries/session.ts +613 -0
- package/src/registries/x402.ts +906 -0
- package/src/types/accounts.ts +618 -0
- package/src/types/common.ts +187 -0
- package/src/types/enums.ts +214 -0
- package/src/types/index.ts +92 -0
- package/src/types/instructions.ts +413 -0
- package/src/utils/hash.ts +57 -0
- package/src/utils/index.ts +19 -0
- package/src/utils/serialization.ts +98 -0
- package/src/utils/validation.ts +36 -0
|
@@ -0,0 +1,909 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module plugin/schemas
|
|
3
|
+
* @description Zod schemas for every SAP v2 plugin tool.
|
|
4
|
+
*
|
|
5
|
+
* Each schema is an `{ input, output }` pair that drives:
|
|
6
|
+
* 1. Runtime validation (LLM → tool call)
|
|
7
|
+
* 2. LangChain StructuredTool generation
|
|
8
|
+
* 3. MCP/Vercel AI tool descriptors
|
|
9
|
+
*
|
|
10
|
+
* Conventions:
|
|
11
|
+
* - Solana public keys → `z.string().describe('Base58 public key …')`
|
|
12
|
+
* - BN/bigint amounts → `z.string().describe('Amount in lamports …')`
|
|
13
|
+
* - Hashes ([u8;32]) → `z.array(z.number()).length(32)`
|
|
14
|
+
* - Tool outputs always include `txSignature` for write ops
|
|
15
|
+
*
|
|
16
|
+
* @category Plugin
|
|
17
|
+
* @since v0.1.0
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
import { z } from "zod";
|
|
21
|
+
|
|
22
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
23
|
+
// Shared Primitives
|
|
24
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
25
|
+
|
|
26
|
+
/** Base58-encoded Solana public key (32–44 chars). */
|
|
27
|
+
const pubkey = z
|
|
28
|
+
.string()
|
|
29
|
+
.min(32)
|
|
30
|
+
.max(44)
|
|
31
|
+
.describe("Solana public key (base58)");
|
|
32
|
+
|
|
33
|
+
/** Base58-encoded transaction signature. */
|
|
34
|
+
const txSig = z.string().describe("Transaction signature (base58)");
|
|
35
|
+
/** 32-byte SHA-256 hash represented as a fixed-length integer array. */
|
|
36
|
+
const hash32 = z.array(z.number().int().min(0).max(255)).length(32);
|
|
37
|
+
/** Token amount in the smallest unit, serialized as a string for BN safety. */
|
|
38
|
+
const lamports = z.string().describe("Amount in smallest token unit (string)");
|
|
39
|
+
/** Optional public key (nullable). */
|
|
40
|
+
const optPubkey = pubkey.nullish();
|
|
41
|
+
|
|
42
|
+
/** Standard write-operation output containing the transaction signature. */
|
|
43
|
+
const writeOutput = z.object({ txSignature: txSig });
|
|
44
|
+
|
|
45
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
46
|
+
// Nested Sub-schemas
|
|
47
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
48
|
+
|
|
49
|
+
/** Reusable schema for an agent capability entry. */
|
|
50
|
+
const capabilitySchema = z.object({
|
|
51
|
+
id: z.string().describe("Capability identifier (e.g. 'jupiter:swap')"),
|
|
52
|
+
description: z.string().nullish().describe("Human-readable description"),
|
|
53
|
+
protocolId: z.string().nullish().describe("Protocol namespace"),
|
|
54
|
+
version: z.string().nullish().describe("Semver version"),
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
/** Reusable schema for a volume curve breakpoint (tiered pricing). */
|
|
58
|
+
const volumeBreakpointSchema = z.object({
|
|
59
|
+
afterCalls: z.number().int().describe("Call threshold for this tier"),
|
|
60
|
+
pricePerCall: lamports.describe("Price per call after threshold"),
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/** Reusable schema for a pricing tier with token, settlement, and volume curve config. */
|
|
64
|
+
const pricingTierSchema = z.object({
|
|
65
|
+
tierId: z.string().describe("Pricing tier ID (e.g. 'standard')"),
|
|
66
|
+
pricePerCall: lamports,
|
|
67
|
+
minPricePerCall: lamports.nullish().describe("Price floor"),
|
|
68
|
+
maxPricePerCall: lamports.nullish().describe("Price ceiling"),
|
|
69
|
+
rateLimit: z.number().int().describe("Calls per second"),
|
|
70
|
+
maxCallsPerSession: z.number().int().describe("0 = unlimited"),
|
|
71
|
+
burstLimit: z.number().int().nullish(),
|
|
72
|
+
tokenType: z
|
|
73
|
+
.enum(["sol", "usdc", "spl"])
|
|
74
|
+
.describe("Payment token type"),
|
|
75
|
+
tokenMint: optPubkey.describe("SPL token mint address (when tokenType=spl)"),
|
|
76
|
+
tokenDecimals: z.number().int().nullish(),
|
|
77
|
+
settlementMode: z
|
|
78
|
+
.enum(["instant", "escrow", "batched", "x402"])
|
|
79
|
+
.nullish()
|
|
80
|
+
.describe("Settlement mode"),
|
|
81
|
+
minEscrowDeposit: lamports.nullish(),
|
|
82
|
+
batchIntervalSec: z.number().int().nullish(),
|
|
83
|
+
volumeCurve: z.array(volumeBreakpointSchema).nullish(),
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
/** Reusable schema for a settlement entry (calls + service hash). */
|
|
87
|
+
const settlementSchema = z.object({
|
|
88
|
+
callsToSettle: z.string().describe("Number of calls to settle"),
|
|
89
|
+
serviceHash: hash32.describe("SHA-256 hash of the service rendered"),
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
93
|
+
// Agent Schemas
|
|
94
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Zod input/output schemas for the **sap-agent** protocol (8 tools).
|
|
98
|
+
*
|
|
99
|
+
* @name agentSchemas
|
|
100
|
+
* @description Covers agent registration, updates, activation lifecycle,
|
|
101
|
+
* call reporting, reputation metrics, and on-chain data fetching.
|
|
102
|
+
* @category Plugin
|
|
103
|
+
* @since v0.1.0
|
|
104
|
+
*/
|
|
105
|
+
export const agentSchemas = {
|
|
106
|
+
registerAgent: {
|
|
107
|
+
input: z.object({
|
|
108
|
+
name: z.string().max(64).describe("Agent display name (max 64 chars)"),
|
|
109
|
+
description: z
|
|
110
|
+
.string()
|
|
111
|
+
.max(512)
|
|
112
|
+
.describe("Agent description (max 512 chars)"),
|
|
113
|
+
capabilities: z
|
|
114
|
+
.array(capabilitySchema)
|
|
115
|
+
.describe("List of capabilities this agent offers"),
|
|
116
|
+
pricing: z
|
|
117
|
+
.array(pricingTierSchema)
|
|
118
|
+
.describe("Pricing tiers for agent services"),
|
|
119
|
+
protocols: z
|
|
120
|
+
.array(z.string())
|
|
121
|
+
.describe("Protocol IDs this agent supports"),
|
|
122
|
+
agentId: z.string().nullish().describe("Optional DID-style agent ID"),
|
|
123
|
+
agentUri: z
|
|
124
|
+
.string()
|
|
125
|
+
.url()
|
|
126
|
+
.nullish()
|
|
127
|
+
.describe("Optional agent metadata URI"),
|
|
128
|
+
x402Endpoint: z
|
|
129
|
+
.string()
|
|
130
|
+
.url()
|
|
131
|
+
.nullish()
|
|
132
|
+
.describe("x402 payment endpoint URL"),
|
|
133
|
+
}),
|
|
134
|
+
output: writeOutput,
|
|
135
|
+
},
|
|
136
|
+
|
|
137
|
+
updateAgent: {
|
|
138
|
+
input: z.object({
|
|
139
|
+
name: z.string().max(64).nullish(),
|
|
140
|
+
description: z.string().max(512).nullish(),
|
|
141
|
+
capabilities: z.array(capabilitySchema).nullish(),
|
|
142
|
+
pricing: z.array(pricingTierSchema).nullish(),
|
|
143
|
+
protocols: z.array(z.string()).nullish(),
|
|
144
|
+
agentId: z.string().nullish(),
|
|
145
|
+
agentUri: z.string().url().nullish(),
|
|
146
|
+
x402Endpoint: z.string().url().nullish(),
|
|
147
|
+
}),
|
|
148
|
+
output: writeOutput,
|
|
149
|
+
},
|
|
150
|
+
|
|
151
|
+
deactivateAgent: {
|
|
152
|
+
input: z.object({}),
|
|
153
|
+
output: writeOutput,
|
|
154
|
+
},
|
|
155
|
+
|
|
156
|
+
reactivateAgent: {
|
|
157
|
+
input: z.object({}),
|
|
158
|
+
output: writeOutput,
|
|
159
|
+
},
|
|
160
|
+
|
|
161
|
+
reportCalls: {
|
|
162
|
+
input: z.object({
|
|
163
|
+
callsServed: z.number().int().positive().describe("Number of calls served"),
|
|
164
|
+
}),
|
|
165
|
+
output: writeOutput,
|
|
166
|
+
},
|
|
167
|
+
|
|
168
|
+
updateReputation: {
|
|
169
|
+
input: z.object({
|
|
170
|
+
avgLatencyMs: z.number().int().min(0).describe("Average latency in ms"),
|
|
171
|
+
uptimePercent: z
|
|
172
|
+
.number()
|
|
173
|
+
.int()
|
|
174
|
+
.min(0)
|
|
175
|
+
.max(100)
|
|
176
|
+
.describe("Uptime percentage (0-100)"),
|
|
177
|
+
}),
|
|
178
|
+
output: writeOutput,
|
|
179
|
+
},
|
|
180
|
+
|
|
181
|
+
fetchAgent: {
|
|
182
|
+
input: z.object({
|
|
183
|
+
wallet: pubkey.nullish().describe("Agent wallet (defaults to caller)"),
|
|
184
|
+
}),
|
|
185
|
+
output: z.object({
|
|
186
|
+
name: z.string(),
|
|
187
|
+
description: z.string(),
|
|
188
|
+
isActive: z.boolean(),
|
|
189
|
+
reputationScore: z.number(),
|
|
190
|
+
totalCallsServed: z.string(),
|
|
191
|
+
totalFeedbacks: z.number(),
|
|
192
|
+
avgLatencyMs: z.number(),
|
|
193
|
+
uptimePercent: z.number(),
|
|
194
|
+
wallet: pubkey,
|
|
195
|
+
agentId: z.string().nullish(),
|
|
196
|
+
x402Endpoint: z.string().nullish(),
|
|
197
|
+
capabilities: z.array(capabilitySchema),
|
|
198
|
+
pricing: z.array(pricingTierSchema),
|
|
199
|
+
protocols: z.array(z.string()),
|
|
200
|
+
}),
|
|
201
|
+
},
|
|
202
|
+
|
|
203
|
+
fetchGlobalRegistry: {
|
|
204
|
+
input: z.object({}),
|
|
205
|
+
output: z.object({
|
|
206
|
+
totalAgents: z.string(),
|
|
207
|
+
activeAgents: z.string(),
|
|
208
|
+
totalFeedbacks: z.string(),
|
|
209
|
+
totalCapabilities: z.number(),
|
|
210
|
+
totalProtocols: z.number(),
|
|
211
|
+
totalTools: z.number(),
|
|
212
|
+
totalVaults: z.number(),
|
|
213
|
+
totalEscrows: z.number(),
|
|
214
|
+
totalAttestations: z.number(),
|
|
215
|
+
authority: pubkey,
|
|
216
|
+
}),
|
|
217
|
+
},
|
|
218
|
+
} as const;
|
|
219
|
+
|
|
220
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
221
|
+
// Feedback Schemas
|
|
222
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
223
|
+
|
|
224
|
+
/**
|
|
225
|
+
* Zod input/output schemas for the **sap-feedback** protocol (4 tools).
|
|
226
|
+
*
|
|
227
|
+
* @name feedbackSchemas
|
|
228
|
+
* @description Covers giving, updating, revoking, and fetching on-chain
|
|
229
|
+
* feedback entries tied to agent identity PDAs.
|
|
230
|
+
* @category Plugin
|
|
231
|
+
* @since v0.1.0
|
|
232
|
+
*/
|
|
233
|
+
export const feedbackSchemas = {
|
|
234
|
+
giveFeedback: {
|
|
235
|
+
input: z.object({
|
|
236
|
+
agentWallet: pubkey.describe("Wallet of the agent to review"),
|
|
237
|
+
score: z
|
|
238
|
+
.number()
|
|
239
|
+
.int()
|
|
240
|
+
.min(1)
|
|
241
|
+
.max(5)
|
|
242
|
+
.describe("Feedback score (1-5)"),
|
|
243
|
+
tag: z
|
|
244
|
+
.string()
|
|
245
|
+
.max(32)
|
|
246
|
+
.describe("Short tag (e.g. 'reliable', 'fast', 'accurate')"),
|
|
247
|
+
commentHash: hash32
|
|
248
|
+
.nullish()
|
|
249
|
+
.describe("Optional SHA-256 hash of off-chain comment"),
|
|
250
|
+
}),
|
|
251
|
+
output: writeOutput,
|
|
252
|
+
},
|
|
253
|
+
|
|
254
|
+
updateFeedback: {
|
|
255
|
+
input: z.object({
|
|
256
|
+
agentWallet: pubkey.describe("Wallet of the reviewed agent"),
|
|
257
|
+
newScore: z.number().int().min(1).max(5).describe("Updated score (1-5)"),
|
|
258
|
+
newTag: z.string().max(32).nullish().describe("Updated tag"),
|
|
259
|
+
commentHash: hash32.nullish(),
|
|
260
|
+
}),
|
|
261
|
+
output: writeOutput,
|
|
262
|
+
},
|
|
263
|
+
|
|
264
|
+
revokeFeedback: {
|
|
265
|
+
input: z.object({
|
|
266
|
+
agentWallet: pubkey.describe("Wallet of the reviewed agent"),
|
|
267
|
+
}),
|
|
268
|
+
output: writeOutput,
|
|
269
|
+
},
|
|
270
|
+
|
|
271
|
+
fetchFeedback: {
|
|
272
|
+
input: z.object({
|
|
273
|
+
agentWallet: pubkey.describe("Wallet of the reviewed agent"),
|
|
274
|
+
reviewer: pubkey.nullish().describe("Reviewer wallet (defaults to caller)"),
|
|
275
|
+
}),
|
|
276
|
+
output: z.object({
|
|
277
|
+
agent: pubkey,
|
|
278
|
+
reviewer: pubkey,
|
|
279
|
+
score: z.number(),
|
|
280
|
+
tag: z.string(),
|
|
281
|
+
isRevoked: z.boolean(),
|
|
282
|
+
createdAt: z.string(),
|
|
283
|
+
updatedAt: z.string(),
|
|
284
|
+
}),
|
|
285
|
+
},
|
|
286
|
+
} as const;
|
|
287
|
+
|
|
288
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
289
|
+
// Attestation Schemas
|
|
290
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
291
|
+
|
|
292
|
+
/**
|
|
293
|
+
* Zod input/output schemas for the **sap-attestation** protocol (3 tools).
|
|
294
|
+
*
|
|
295
|
+
* @name attestationSchemas
|
|
296
|
+
* @description Covers creating, revoking, and fetching on-chain attestations
|
|
297
|
+
* between agents in the SAP Web of Trust.
|
|
298
|
+
* @category Plugin
|
|
299
|
+
* @since v0.1.0
|
|
300
|
+
*/
|
|
301
|
+
export const attestationSchemas = {
|
|
302
|
+
createAttestation: {
|
|
303
|
+
input: z.object({
|
|
304
|
+
agentWallet: pubkey.describe("Wallet of the agent to attest"),
|
|
305
|
+
attestationType: z
|
|
306
|
+
.string()
|
|
307
|
+
.max(32)
|
|
308
|
+
.describe(
|
|
309
|
+
"Type of attestation (e.g. 'identity', 'capability', 'compliance')"
|
|
310
|
+
),
|
|
311
|
+
metadataHash: hash32.describe(
|
|
312
|
+
"SHA-256 hash of attestation metadata"
|
|
313
|
+
),
|
|
314
|
+
expiresAt: z
|
|
315
|
+
.string()
|
|
316
|
+
.describe("Unix timestamp (seconds) when attestation expires"),
|
|
317
|
+
}),
|
|
318
|
+
output: writeOutput,
|
|
319
|
+
},
|
|
320
|
+
|
|
321
|
+
revokeAttestation: {
|
|
322
|
+
input: z.object({
|
|
323
|
+
agentWallet: pubkey.describe("Wallet of the attested agent"),
|
|
324
|
+
}),
|
|
325
|
+
output: writeOutput,
|
|
326
|
+
},
|
|
327
|
+
|
|
328
|
+
fetchAttestation: {
|
|
329
|
+
input: z.object({
|
|
330
|
+
agentWallet: pubkey.describe("Wallet of the attested agent"),
|
|
331
|
+
attester: pubkey
|
|
332
|
+
.nullish()
|
|
333
|
+
.describe("Attester wallet (defaults to caller)"),
|
|
334
|
+
}),
|
|
335
|
+
output: z.object({
|
|
336
|
+
agent: pubkey,
|
|
337
|
+
attester: pubkey,
|
|
338
|
+
attestationType: z.string(),
|
|
339
|
+
isActive: z.boolean(),
|
|
340
|
+
expiresAt: z.string(),
|
|
341
|
+
createdAt: z.string(),
|
|
342
|
+
}),
|
|
343
|
+
},
|
|
344
|
+
} as const;
|
|
345
|
+
|
|
346
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
347
|
+
// Escrow Schemas
|
|
348
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
349
|
+
|
|
350
|
+
/**
|
|
351
|
+
* Zod input/output schemas for the **sap-escrow** protocol (6 tools).
|
|
352
|
+
*
|
|
353
|
+
* @name escrowSchemas
|
|
354
|
+
* @description Covers escrow creation, deposits, settlement (single and batch),
|
|
355
|
+
* withdrawal, and account data fetching for x402 micropayments.
|
|
356
|
+
* @category Plugin
|
|
357
|
+
* @since v0.1.0
|
|
358
|
+
*/
|
|
359
|
+
export const escrowSchemas = {
|
|
360
|
+
createEscrow: {
|
|
361
|
+
input: z.object({
|
|
362
|
+
agentWallet: pubkey.describe("Agent wallet to deposit escrow for"),
|
|
363
|
+
pricePerCall: lamports.describe("Base price per call"),
|
|
364
|
+
maxCalls: z.string().describe("Maximum calls allowed"),
|
|
365
|
+
initialDeposit: lamports.describe("Initial deposit amount"),
|
|
366
|
+
expiresAt: z.string().describe("Expiry timestamp (unix seconds)"),
|
|
367
|
+
volumeCurve: z.array(volumeBreakpointSchema).default([]),
|
|
368
|
+
tokenMint: optPubkey.describe(
|
|
369
|
+
"SPL token mint (null = native SOL)"
|
|
370
|
+
),
|
|
371
|
+
tokenDecimals: z
|
|
372
|
+
.number()
|
|
373
|
+
.int()
|
|
374
|
+
.default(9)
|
|
375
|
+
.describe("Token decimals (9=SOL, 6=USDC)"),
|
|
376
|
+
}),
|
|
377
|
+
output: writeOutput,
|
|
378
|
+
},
|
|
379
|
+
|
|
380
|
+
depositEscrow: {
|
|
381
|
+
input: z.object({
|
|
382
|
+
agentWallet: pubkey.describe("Agent wallet of the escrow"),
|
|
383
|
+
amount: lamports.describe("Additional deposit amount"),
|
|
384
|
+
}),
|
|
385
|
+
output: writeOutput,
|
|
386
|
+
},
|
|
387
|
+
|
|
388
|
+
settleEscrow: {
|
|
389
|
+
input: z.object({
|
|
390
|
+
depositorWallet: pubkey.describe("Depositor (client) wallet"),
|
|
391
|
+
callsToSettle: z.string().describe("Number of calls to settle"),
|
|
392
|
+
serviceHash: hash32.describe("SHA-256 hash of the service rendered"),
|
|
393
|
+
}),
|
|
394
|
+
output: writeOutput,
|
|
395
|
+
},
|
|
396
|
+
|
|
397
|
+
withdrawEscrow: {
|
|
398
|
+
input: z.object({
|
|
399
|
+
agentWallet: pubkey.describe("Agent wallet of the escrow"),
|
|
400
|
+
amount: lamports.describe("Amount to withdraw"),
|
|
401
|
+
}),
|
|
402
|
+
output: writeOutput,
|
|
403
|
+
},
|
|
404
|
+
|
|
405
|
+
batchSettle: {
|
|
406
|
+
input: z.object({
|
|
407
|
+
depositorWallet: pubkey.describe("Depositor (client) wallet"),
|
|
408
|
+
settlements: z
|
|
409
|
+
.array(settlementSchema)
|
|
410
|
+
.min(1)
|
|
411
|
+
.max(10)
|
|
412
|
+
.describe("Up to 10 settlement entries"),
|
|
413
|
+
}),
|
|
414
|
+
output: writeOutput,
|
|
415
|
+
},
|
|
416
|
+
|
|
417
|
+
fetchEscrow: {
|
|
418
|
+
input: z.object({
|
|
419
|
+
agentWallet: pubkey.describe("Agent wallet"),
|
|
420
|
+
depositor: pubkey.nullish().describe("Depositor wallet (defaults to caller)"),
|
|
421
|
+
}),
|
|
422
|
+
output: z.object({
|
|
423
|
+
agent: pubkey,
|
|
424
|
+
depositor: pubkey,
|
|
425
|
+
agentWallet: pubkey,
|
|
426
|
+
balance: z.string(),
|
|
427
|
+
totalDeposited: z.string(),
|
|
428
|
+
totalSettled: z.string(),
|
|
429
|
+
totalCallsSettled: z.string(),
|
|
430
|
+
pricePerCall: z.string(),
|
|
431
|
+
maxCalls: z.string(),
|
|
432
|
+
expiresAt: z.string(),
|
|
433
|
+
tokenDecimals: z.number(),
|
|
434
|
+
tokenMint: z.string().nullish(),
|
|
435
|
+
}),
|
|
436
|
+
},
|
|
437
|
+
} as const;
|
|
438
|
+
|
|
439
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
440
|
+
// Tools Schemas
|
|
441
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
442
|
+
|
|
443
|
+
/**
|
|
444
|
+
* Zod input/output schemas for the **sap-tools** protocol (7 tools).
|
|
445
|
+
*
|
|
446
|
+
* @name toolsSchemas
|
|
447
|
+
* @description Covers tool publishing, schema inscription, updates,
|
|
448
|
+
* activation lifecycle, invocation reporting, and descriptor fetching.
|
|
449
|
+
* @category Plugin
|
|
450
|
+
* @since v0.1.0
|
|
451
|
+
*/
|
|
452
|
+
export const toolsSchemas = {
|
|
453
|
+
publishToolByName: {
|
|
454
|
+
input: z.object({
|
|
455
|
+
toolName: z.string().max(64).describe("Tool name (e.g. 'swap')"),
|
|
456
|
+
protocolId: z.string().describe("Protocol ID (e.g. 'jupiter')"),
|
|
457
|
+
description: z
|
|
458
|
+
.string()
|
|
459
|
+
.max(256)
|
|
460
|
+
.describe("Tool description for LLM consumption"),
|
|
461
|
+
inputSchema: z
|
|
462
|
+
.string()
|
|
463
|
+
.describe("JSON schema string for tool input"),
|
|
464
|
+
outputSchema: z
|
|
465
|
+
.string()
|
|
466
|
+
.describe("JSON schema string for tool output"),
|
|
467
|
+
httpMethod: z
|
|
468
|
+
.enum(["get", "post", "put", "delete", "compound"])
|
|
469
|
+
.describe("HTTP method"),
|
|
470
|
+
category: z
|
|
471
|
+
.enum([
|
|
472
|
+
"swap",
|
|
473
|
+
"lend",
|
|
474
|
+
"stake",
|
|
475
|
+
"nft",
|
|
476
|
+
"payment",
|
|
477
|
+
"data",
|
|
478
|
+
"governance",
|
|
479
|
+
"bridge",
|
|
480
|
+
"analytics",
|
|
481
|
+
"custom",
|
|
482
|
+
])
|
|
483
|
+
.describe("Tool category for discovery"),
|
|
484
|
+
paramsCount: z.number().int().describe("Total parameter count"),
|
|
485
|
+
requiredParams: z.number().int().describe("Required parameter count"),
|
|
486
|
+
isCompound: z
|
|
487
|
+
.boolean()
|
|
488
|
+
.default(false)
|
|
489
|
+
.describe("Whether tool chains multiple actions"),
|
|
490
|
+
}),
|
|
491
|
+
output: writeOutput,
|
|
492
|
+
},
|
|
493
|
+
|
|
494
|
+
inscribeToolSchema: {
|
|
495
|
+
input: z.object({
|
|
496
|
+
toolName: z.string().describe("Tool name"),
|
|
497
|
+
schemaType: z
|
|
498
|
+
.enum(["input", "output", "description"])
|
|
499
|
+
.describe("Schema type to inscribe"),
|
|
500
|
+
schemaData: z.string().describe("Schema content (JSON string)"),
|
|
501
|
+
compression: z
|
|
502
|
+
.enum(["none", "deflate", "gzip", "brotli"])
|
|
503
|
+
.default("none")
|
|
504
|
+
.describe("Compression algorithm"),
|
|
505
|
+
}),
|
|
506
|
+
output: writeOutput,
|
|
507
|
+
},
|
|
508
|
+
|
|
509
|
+
updateTool: {
|
|
510
|
+
input: z.object({
|
|
511
|
+
toolName: z.string().describe("Tool name to update"),
|
|
512
|
+
httpMethod: z
|
|
513
|
+
.enum(["get", "post", "put", "delete", "compound"])
|
|
514
|
+
.nullish(),
|
|
515
|
+
category: z
|
|
516
|
+
.enum([
|
|
517
|
+
"swap",
|
|
518
|
+
"lend",
|
|
519
|
+
"stake",
|
|
520
|
+
"nft",
|
|
521
|
+
"payment",
|
|
522
|
+
"data",
|
|
523
|
+
"governance",
|
|
524
|
+
"bridge",
|
|
525
|
+
"analytics",
|
|
526
|
+
"custom",
|
|
527
|
+
])
|
|
528
|
+
.nullish(),
|
|
529
|
+
paramsCount: z.number().int().nullish(),
|
|
530
|
+
requiredParams: z.number().int().nullish(),
|
|
531
|
+
}),
|
|
532
|
+
output: writeOutput,
|
|
533
|
+
},
|
|
534
|
+
|
|
535
|
+
deactivateTool: {
|
|
536
|
+
input: z.object({
|
|
537
|
+
toolName: z.string().describe("Tool name to deactivate"),
|
|
538
|
+
}),
|
|
539
|
+
output: writeOutput,
|
|
540
|
+
},
|
|
541
|
+
|
|
542
|
+
reactivateTool: {
|
|
543
|
+
input: z.object({
|
|
544
|
+
toolName: z.string().describe("Tool name to reactivate"),
|
|
545
|
+
}),
|
|
546
|
+
output: writeOutput,
|
|
547
|
+
},
|
|
548
|
+
|
|
549
|
+
reportInvocations: {
|
|
550
|
+
input: z.object({
|
|
551
|
+
toolName: z.string().describe("Tool name"),
|
|
552
|
+
invocations: z
|
|
553
|
+
.number()
|
|
554
|
+
.int()
|
|
555
|
+
.positive()
|
|
556
|
+
.describe("Number of invocations to report"),
|
|
557
|
+
}),
|
|
558
|
+
output: writeOutput,
|
|
559
|
+
},
|
|
560
|
+
|
|
561
|
+
fetchTool: {
|
|
562
|
+
input: z.object({
|
|
563
|
+
agentWallet: pubkey.describe("Agent wallet that published the tool"),
|
|
564
|
+
toolName: z.string().describe("Tool name"),
|
|
565
|
+
}),
|
|
566
|
+
output: z.object({
|
|
567
|
+
toolName: z.string(),
|
|
568
|
+
version: z.number(),
|
|
569
|
+
isActive: z.boolean(),
|
|
570
|
+
totalInvocations: z.string(),
|
|
571
|
+
paramsCount: z.number(),
|
|
572
|
+
requiredParams: z.number(),
|
|
573
|
+
isCompound: z.boolean(),
|
|
574
|
+
agent: pubkey,
|
|
575
|
+
createdAt: z.string(),
|
|
576
|
+
updatedAt: z.string(),
|
|
577
|
+
}),
|
|
578
|
+
},
|
|
579
|
+
} as const;
|
|
580
|
+
|
|
581
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
582
|
+
// Vault Schemas
|
|
583
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Zod input/output schemas for the **sap-vault** protocol (10 tools).
|
|
587
|
+
*
|
|
588
|
+
* @name vaultSchemas
|
|
589
|
+
* @description Covers vault initialization, session management, encrypted
|
|
590
|
+
* memory inscription, nonce rotation, delegate authorization, and
|
|
591
|
+
* vault/session data fetching.
|
|
592
|
+
* @category Plugin
|
|
593
|
+
* @since v0.1.0
|
|
594
|
+
*/
|
|
595
|
+
export const vaultSchemas = {
|
|
596
|
+
initVault: {
|
|
597
|
+
input: z.object({
|
|
598
|
+
vaultNonce: hash32.describe(
|
|
599
|
+
"32-byte encryption nonce for vault initialization"
|
|
600
|
+
),
|
|
601
|
+
}),
|
|
602
|
+
output: writeOutput,
|
|
603
|
+
},
|
|
604
|
+
|
|
605
|
+
openSession: {
|
|
606
|
+
input: z.object({
|
|
607
|
+
sessionHash: hash32.describe(
|
|
608
|
+
"32-byte session identifier hash"
|
|
609
|
+
),
|
|
610
|
+
}),
|
|
611
|
+
output: writeOutput,
|
|
612
|
+
},
|
|
613
|
+
|
|
614
|
+
inscribeMemory: {
|
|
615
|
+
input: z.object({
|
|
616
|
+
sessionHash: z
|
|
617
|
+
.string()
|
|
618
|
+
.describe("Hex-encoded session hash for PDA derivation"),
|
|
619
|
+
sequence: z.number().int().describe("Sequence number within session"),
|
|
620
|
+
encryptedData: z
|
|
621
|
+
.string()
|
|
622
|
+
.describe("Hex-encoded encrypted payload"),
|
|
623
|
+
nonce: z
|
|
624
|
+
.array(z.number().int().min(0).max(255))
|
|
625
|
+
.length(12)
|
|
626
|
+
.describe("12-byte AES-GCM nonce"),
|
|
627
|
+
contentHash: hash32.describe("SHA-256 of plaintext content"),
|
|
628
|
+
totalFragments: z
|
|
629
|
+
.number()
|
|
630
|
+
.int()
|
|
631
|
+
.min(1)
|
|
632
|
+
.default(1)
|
|
633
|
+
.describe("Total fragments (1 = single)"),
|
|
634
|
+
fragmentIndex: z.number().int().default(0).describe("Fragment index"),
|
|
635
|
+
compression: z
|
|
636
|
+
.number()
|
|
637
|
+
.int()
|
|
638
|
+
.default(0)
|
|
639
|
+
.describe("Compression type (0=none, 1=deflate, 2=gzip, 3=brotli)"),
|
|
640
|
+
epochIndex: z.number().int().default(0).describe("Epoch page index"),
|
|
641
|
+
}),
|
|
642
|
+
output: writeOutput,
|
|
643
|
+
},
|
|
644
|
+
|
|
645
|
+
closeSession: {
|
|
646
|
+
input: z.object({
|
|
647
|
+
sessionHash: z
|
|
648
|
+
.string()
|
|
649
|
+
.describe("Hex-encoded session hash for PDA derivation"),
|
|
650
|
+
}),
|
|
651
|
+
output: writeOutput,
|
|
652
|
+
},
|
|
653
|
+
|
|
654
|
+
closeVault: {
|
|
655
|
+
input: z.object({}),
|
|
656
|
+
output: writeOutput,
|
|
657
|
+
},
|
|
658
|
+
|
|
659
|
+
rotateNonce: {
|
|
660
|
+
input: z.object({
|
|
661
|
+
newNonce: hash32.describe("New 32-byte encryption nonce"),
|
|
662
|
+
}),
|
|
663
|
+
output: writeOutput,
|
|
664
|
+
},
|
|
665
|
+
|
|
666
|
+
addDelegate: {
|
|
667
|
+
input: z.object({
|
|
668
|
+
delegatePubkey: pubkey.describe("Wallet to authorize as delegate"),
|
|
669
|
+
permissions: z
|
|
670
|
+
.number()
|
|
671
|
+
.int()
|
|
672
|
+
.min(1)
|
|
673
|
+
.max(7)
|
|
674
|
+
.describe(
|
|
675
|
+
"Permission bitmask (1=inscribe, 2=closeSession, 4=openSession, 7=all)"
|
|
676
|
+
),
|
|
677
|
+
expiresAt: z
|
|
678
|
+
.string()
|
|
679
|
+
.describe("Delegation expiry (unix timestamp seconds)"),
|
|
680
|
+
}),
|
|
681
|
+
output: writeOutput,
|
|
682
|
+
},
|
|
683
|
+
|
|
684
|
+
revokeDelegate: {
|
|
685
|
+
input: z.object({
|
|
686
|
+
delegatePubkey: pubkey.describe("Delegate wallet to revoke"),
|
|
687
|
+
}),
|
|
688
|
+
output: writeOutput,
|
|
689
|
+
},
|
|
690
|
+
|
|
691
|
+
fetchVault: {
|
|
692
|
+
input: z.object({
|
|
693
|
+
agentWallet: pubkey
|
|
694
|
+
.nullish()
|
|
695
|
+
.describe("Agent wallet (defaults to caller)"),
|
|
696
|
+
}),
|
|
697
|
+
output: z.object({
|
|
698
|
+
agent: pubkey,
|
|
699
|
+
wallet: pubkey,
|
|
700
|
+
totalSessions: z.number(),
|
|
701
|
+
totalInscriptions: z.string(),
|
|
702
|
+
totalBytesInscribed: z.string(),
|
|
703
|
+
protocolVersion: z.number(),
|
|
704
|
+
nonceVersion: z.number(),
|
|
705
|
+
createdAt: z.string(),
|
|
706
|
+
}),
|
|
707
|
+
},
|
|
708
|
+
|
|
709
|
+
fetchSession: {
|
|
710
|
+
input: z.object({
|
|
711
|
+
agentWallet: pubkey.describe("Agent wallet"),
|
|
712
|
+
sessionHash: z
|
|
713
|
+
.string()
|
|
714
|
+
.describe("Hex-encoded session hash"),
|
|
715
|
+
}),
|
|
716
|
+
output: z.object({
|
|
717
|
+
vault: pubkey,
|
|
718
|
+
sequenceCounter: z.number(),
|
|
719
|
+
totalBytes: z.string(),
|
|
720
|
+
currentEpoch: z.number(),
|
|
721
|
+
totalEpochs: z.number(),
|
|
722
|
+
isClosed: z.boolean(),
|
|
723
|
+
createdAt: z.string(),
|
|
724
|
+
lastInscribedAt: z.string(),
|
|
725
|
+
}),
|
|
726
|
+
},
|
|
727
|
+
} as const;
|
|
728
|
+
|
|
729
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
730
|
+
// Indexing Schemas
|
|
731
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
732
|
+
|
|
733
|
+
/**
|
|
734
|
+
* Zod input/output schemas for the **sap-indexing** protocol (8 tools).
|
|
735
|
+
*
|
|
736
|
+
* @name indexingSchemas
|
|
737
|
+
* @description Covers capability and protocol index creation, agent
|
|
738
|
+
* registration/removal within indexes, and index data fetching.
|
|
739
|
+
* @category Plugin
|
|
740
|
+
* @since v0.1.0
|
|
741
|
+
*/
|
|
742
|
+
export const indexingSchemas = {
|
|
743
|
+
initCapabilityIndex: {
|
|
744
|
+
input: z.object({
|
|
745
|
+
capabilityId: z
|
|
746
|
+
.string()
|
|
747
|
+
.describe("Capability ID to index (e.g. 'jupiter:swap')"),
|
|
748
|
+
}),
|
|
749
|
+
output: writeOutput,
|
|
750
|
+
},
|
|
751
|
+
|
|
752
|
+
addToCapabilityIndex: {
|
|
753
|
+
input: z.object({
|
|
754
|
+
capabilityId: z.string().describe("Capability ID"),
|
|
755
|
+
}),
|
|
756
|
+
output: writeOutput,
|
|
757
|
+
},
|
|
758
|
+
|
|
759
|
+
removeFromCapabilityIndex: {
|
|
760
|
+
input: z.object({
|
|
761
|
+
capabilityId: z.string().describe("Capability ID"),
|
|
762
|
+
}),
|
|
763
|
+
output: writeOutput,
|
|
764
|
+
},
|
|
765
|
+
|
|
766
|
+
initProtocolIndex: {
|
|
767
|
+
input: z.object({
|
|
768
|
+
protocolId: z
|
|
769
|
+
.string()
|
|
770
|
+
.describe("Protocol ID to index (e.g. 'jupiter')"),
|
|
771
|
+
}),
|
|
772
|
+
output: writeOutput,
|
|
773
|
+
},
|
|
774
|
+
|
|
775
|
+
addToProtocolIndex: {
|
|
776
|
+
input: z.object({
|
|
777
|
+
protocolId: z.string().describe("Protocol ID"),
|
|
778
|
+
}),
|
|
779
|
+
output: writeOutput,
|
|
780
|
+
},
|
|
781
|
+
|
|
782
|
+
removeFromProtocolIndex: {
|
|
783
|
+
input: z.object({
|
|
784
|
+
protocolId: z.string().describe("Protocol ID"),
|
|
785
|
+
}),
|
|
786
|
+
output: writeOutput,
|
|
787
|
+
},
|
|
788
|
+
|
|
789
|
+
fetchCapabilityIndex: {
|
|
790
|
+
input: z.object({
|
|
791
|
+
capabilityId: z.string().describe("Capability ID to look up"),
|
|
792
|
+
}),
|
|
793
|
+
output: z.object({
|
|
794
|
+
capabilityId: z.string(),
|
|
795
|
+
agents: z.array(pubkey).describe("Agents registered for this capability"),
|
|
796
|
+
totalPages: z.number(),
|
|
797
|
+
lastUpdated: z.string(),
|
|
798
|
+
}),
|
|
799
|
+
},
|
|
800
|
+
|
|
801
|
+
fetchProtocolIndex: {
|
|
802
|
+
input: z.object({
|
|
803
|
+
protocolId: z.string().describe("Protocol ID to look up"),
|
|
804
|
+
}),
|
|
805
|
+
output: z.object({
|
|
806
|
+
protocolId: z.string(),
|
|
807
|
+
agents: z.array(pubkey).describe("Agents registered for this protocol"),
|
|
808
|
+
totalPages: z.number(),
|
|
809
|
+
lastUpdated: z.string(),
|
|
810
|
+
}),
|
|
811
|
+
},
|
|
812
|
+
} as const;
|
|
813
|
+
|
|
814
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
815
|
+
// Ledger Schemas
|
|
816
|
+
// ═══════════════════════════════════════════════════════════════════
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Zod input/output schemas for the **sap-ledger** protocol (6 tools).
|
|
820
|
+
*
|
|
821
|
+
* @name ledgerSchemas
|
|
822
|
+
* @description Covers ledger initialization, ring-buffer writes, sealing
|
|
823
|
+
* to permanent pages, ledger closure, and metadata/page fetching.
|
|
824
|
+
* @category Plugin
|
|
825
|
+
* @since v0.1.0
|
|
826
|
+
*/
|
|
827
|
+
export const ledgerSchemas = {
|
|
828
|
+
initLedger: {
|
|
829
|
+
input: z.object({
|
|
830
|
+
sessionHash: z
|
|
831
|
+
.string()
|
|
832
|
+
.describe("Hex-encoded session hash (the session must exist)"),
|
|
833
|
+
agentWallet: pubkey
|
|
834
|
+
.nullish()
|
|
835
|
+
.describe("Agent wallet (defaults to caller)"),
|
|
836
|
+
}),
|
|
837
|
+
output: writeOutput,
|
|
838
|
+
},
|
|
839
|
+
|
|
840
|
+
writeLedger: {
|
|
841
|
+
input: z.object({
|
|
842
|
+
sessionHash: z.string().describe("Hex-encoded session hash"),
|
|
843
|
+
agentWallet: pubkey
|
|
844
|
+
.nullish()
|
|
845
|
+
.describe("Agent wallet (defaults to caller)"),
|
|
846
|
+
data: z
|
|
847
|
+
.string()
|
|
848
|
+
.describe("Hex-encoded data to write to ring buffer"),
|
|
849
|
+
contentHash: hash32.describe("SHA-256 of the plaintext data"),
|
|
850
|
+
}),
|
|
851
|
+
output: writeOutput,
|
|
852
|
+
},
|
|
853
|
+
|
|
854
|
+
sealLedger: {
|
|
855
|
+
input: z.object({
|
|
856
|
+
sessionHash: z.string().describe("Hex-encoded session hash"),
|
|
857
|
+
agentWallet: pubkey
|
|
858
|
+
.nullish()
|
|
859
|
+
.describe("Agent wallet (defaults to caller)"),
|
|
860
|
+
}),
|
|
861
|
+
output: writeOutput,
|
|
862
|
+
},
|
|
863
|
+
|
|
864
|
+
closeLedger: {
|
|
865
|
+
input: z.object({
|
|
866
|
+
sessionHash: z.string().describe("Hex-encoded session hash"),
|
|
867
|
+
agentWallet: pubkey
|
|
868
|
+
.nullish()
|
|
869
|
+
.describe("Agent wallet (defaults to caller)"),
|
|
870
|
+
}),
|
|
871
|
+
output: writeOutput,
|
|
872
|
+
},
|
|
873
|
+
|
|
874
|
+
fetchLedger: {
|
|
875
|
+
input: z.object({
|
|
876
|
+
sessionHash: z.string().describe("Hex-encoded session hash"),
|
|
877
|
+
agentWallet: pubkey
|
|
878
|
+
.nullish()
|
|
879
|
+
.describe("Agent wallet (defaults to caller)"),
|
|
880
|
+
}),
|
|
881
|
+
output: z.object({
|
|
882
|
+
session: pubkey,
|
|
883
|
+
authority: pubkey,
|
|
884
|
+
numEntries: z.number(),
|
|
885
|
+
totalDataSize: z.string(),
|
|
886
|
+
numPages: z.number(),
|
|
887
|
+
createdAt: z.string(),
|
|
888
|
+
updatedAt: z.string(),
|
|
889
|
+
}),
|
|
890
|
+
},
|
|
891
|
+
|
|
892
|
+
fetchLedgerPage: {
|
|
893
|
+
input: z.object({
|
|
894
|
+
sessionHash: z.string().describe("Hex-encoded session hash"),
|
|
895
|
+
agentWallet: pubkey
|
|
896
|
+
.nullish()
|
|
897
|
+
.describe("Agent wallet (defaults to caller)"),
|
|
898
|
+
pageIndex: z.number().int().describe("Page index"),
|
|
899
|
+
}),
|
|
900
|
+
output: z.object({
|
|
901
|
+
ledger: pubkey,
|
|
902
|
+
pageIndex: z.number(),
|
|
903
|
+
sealedAt: z.string(),
|
|
904
|
+
entriesInPage: z.number(),
|
|
905
|
+
dataSize: z.number(),
|
|
906
|
+
data: z.array(z.number()).describe("Raw page data bytes"),
|
|
907
|
+
}),
|
|
908
|
+
},
|
|
909
|
+
} as const;
|