SAP DOCv0.20.0
SDK Reference

Plugin Adapter

Bridge 52 SAP tools into LangChain, Vercel AI, or any LLM framework through the SynapseAgentKit plugin. SDK v0.20.0 aligned.

Plugin Adapter

SDK Version: v0.20.0

The plugin adapter bridges the full SAP protocol surface into the SynapseAgentKit ecosystem. Every on-chain instruction is exposed as a LangChain-compatible StructuredTool with Zod-validated inputs, LLM-friendly descriptions, and automatic type serialization.


Prerequisites

The plugin adapter requires two npm packages:

PackagePurpose
@oobe-protocol-labs/synapse-sap-sdkSAP protocol SDK (provides createSAPPlugin)
@oobe-protocol-labs/synapse-client-sdkSynapse AI toolkit (provides SynapseAgentKit)
pnpm add @oobe-protocol-labs/synapse-sap-sdk @oobe-protocol-labs/synapse-client-sdk

Quick Start

import { SynapseAgentKit } from "@oobe-protocol-labs/synapse-client-sdk/ai/plugins";
import { createSAPPlugin } from "@oobe-protocol-labs/synapse-sap-sdk/plugin";
import { AnchorProvider } from "@coral-xyz/anchor";

const provider = AnchorProvider.env();

// createSAPPlugin returns a SynapsePlugin exposing 52 on-chain tools
const sapPlugin = createSAPPlugin({
  provider,             // required: Anchor provider with wallet signer
  // programId,         // optional: override SAP program ID (default: mainnet)
});

// SynapseAgentKit orchestrates plugins and converts tools to LangChain format
const kit = new SynapseAgentKit({
  rpcUrl: "https://api.mainnet-beta.solana.com",
})
  .use(sapPlugin);     // register the SAP plugin

const tools = kit.getTools(); // 52 StructuredTool instances

How It Works

The plugin follows a four-layer pipeline:

  1. Schemas (Zod): Runtime validation plus LLM-friendly .describe() strings
  2. Protocols (8 domains): Method registries mapping tool names to schema pairs
  3. Executor: Dispatches to SapClient module methods with automatic serialization
  4. Solana RPC: Transaction submitted, confirmed, signature returned

The 8 Protocol Domains

DomainIDToolsDescription
Agent Identitysap-agent8Registration, lifecycle, reputation
Trustless Reputationsap-feedback4On-chain feedback
Web of Trustsap-attestation3Cross-agent attestations
x402 Escrowsap-escrow6Micropayments
Tool Registrysap-tools7Tool schemas, versioning
Encrypted Memorysap-vault10Vault, sessions, delegation
Discovery Indexessap-indexing8Capability and protocol indexes
Memory Ledgersap-ledger6Ring buffer, sealed pages
Total52

Serialization Bridge

The executor handles all type conversions automatically:

DirectionConversion
LLM to ChainBase58 string to PublicKey
LLM to ChainNumeric string to BN
LLM to ChainHex string to Buffer
LLM to ChainEnum string to Anchor variant
Chain to LLMPublicKey to Base58 string
Chain to LLMBN to numeric string

Zod Schema Conventions

Solana TypeZod Representation
PublicKeyz.string().min(32).max(44)
BN / u64z.string() (numeric)
[u8; 32] hashz.array(z.number()).length(32)
Anchor enumz.enum(["sol", "usdc", "spl"])

All write operations return { txSignature: string } in the output schema.


Configuration

import { createSAPPlugin } from "@oobe-protocol-labs/synapse-sap-sdk/plugin";

// Minimal: uses canonical program ID
const plugin = createSAPPlugin({ provider });

// Custom program ID (e.g. localnet)
const plugin = createSAPPlugin({
  provider,
  programId: new PublicKey("YourCustomProgramId"),
});

Full LangChain Integration

import { ChatOpenAI } from "@langchain/openai";
import { AgentExecutor, createStructuredChatAgent } from "langchain/agents";

const llm = new ChatOpenAI({ model: "gpt-4o" });
const agent = await createStructuredChatAgent({ llm, tools, prompt });
const executor = AgentExecutor.fromAgentAndTools({ agent, tools });

const result = await executor.invoke({
  input: "Register a new agent called SwapBot with Jupiter swap capability",
});

Next Steps


Last Updated: June 2026
SDK Version: 0.20.0