/** * @module plugin/magicblock * @description MagicBlock SynapsePlugin — exposes 20 tools across 3 * protocol domains as a drop-in `SynapsePlugin` for `SynapseAgentKit`. * * ```ts * import { SynapseAgentKit } from '@oobe-protocol-labs/synapse-client-sdk/ai/plugins'; * import { createMagicBlockPlugin } from '@synapse-sap/sdk/plugin/magicblock'; * * const mbPlugin = createMagicBlockPlugin(); * const kit = new SynapseAgentKit({ rpcUrl }).use(mbPlugin); * * const tools = kit.getTools(); // → StructuredTool[] (LangChain) * ``` * * Architecture (mirrors the SAP plugin structure): * 1. Schemas (Zod) → runtime validation + LLM-friendly descriptions * 2. Protocols → 3 domain method registries (router, payments, vrf) * 3. Client → stateless HTTP client for ER Router + Private Payment API * 4. Executor → dispatches tool calls to MagicBlockClient methods * 5. Pay-per-call → optional SAP escrow/x402 settlement integration * * @category Plugin * @since v0.1.0 */ import type { SynapsePlugin } from "../index"; import { PricingTier } from "./pricing"; /** * Optional pay-per-call settlement hook. * * When provided, the executor calls `settle()` after each successful * tool invocation. The hook receives the tool name, protocol, pricing * tier, and price in USDC base units — enough context to settle a * SAP escrow or x402 payment without a second lookup. * * @interface PayPerCallHook * @category Plugin * @since v0.1.0 */ export interface PayPerCallHook { /** * Called after a tool execution succeeds. * * @param ctx - Settlement context with tool name, protocol, tier, and price * @returns Settlement receipt or void */ readonly settle: (ctx: { readonly toolName: string; readonly protocol: string; readonly tier: PricingTier; /** Price in USDC base units (6 decimals). 10_000 = $0.01, 50_000 = $0.05. */ readonly priceBaseUnits: bigint; }) => Promise; } /** * Configuration for the MagicBlock plugin. * * @interface MagicBlockPluginConfig * @category Plugin * @since v0.1.0 */ export interface MagicBlockPluginConfig { /** * Optional pay-per-call hook for SAP escrow / x402 settlement. * * When provided, the executor calls `hook.settle(toolName, protocol)` * after each successful tool invocation. The hook handles the * SAP-specific settlement logic (escrow settle, x402 headers, etc.). */ readonly payPerCall?: PayPerCallHook; } /** * Create a SynapsePlugin for MagicBlock. * * @name createMagicBlockPlugin * @description Factory function that returns a fully configured * {@link SynapsePlugin} exposing 20 tools across 3 protocol domains * (ER Router, Private Payments, VRF). The plugin can be installed * into a `SynapseAgentKit` instance alongside the SAP plugin. * * When `config.payPerCall` is provided, each successful tool * invocation triggers `hook.settle(toolName, protocol)` for SAP * escrow or x402 settlement. Settlement errors are caught and * logged — they never mask a successful tool result. * @param config - Optional plugin configuration with pay-per-call hook * @returns A configured {@link SynapsePlugin} instance * @category Plugin * @since v0.1.0 * * @example * ```ts * import { createMagicBlockPlugin } from '@synapse-sap/sdk/plugin/magicblock'; * * // Standalone (no pay-per-call): * const mbPlugin = createMagicBlockPlugin(); * * // With SAP escrow settlement: * const mbPlugin = createMagicBlockPlugin({ * payPerCall: { * settle: async (toolName, protocol) => { * await sapClient.escrow.settle(depositorWallet, nonce, 1, serviceHash); * }, * }, * }); * * kit.use(mbPlugin); * ``` */ export declare function createMagicBlockPlugin(config?: MagicBlockPluginConfig): SynapsePlugin; /** * Pre-built plugin object for static use patterns. * * @name MagicBlockPlugin * @description Convenience namespace exposing a `configure` method * that delegates to {@link createMagicBlockPlugin}. Mirrors the * `SAPPlugin` pattern from the SAP plugin. * @category Plugin * @since v0.1.0 * * @example * ```ts * import { MagicBlockPlugin } from '@synapse-sap/sdk/plugin/magicblock'; * * const plugin = MagicBlockPlugin.configure(); * kit.use(plugin); * ``` */ export declare const MagicBlockPlugin: { /** Create a configured MagicBlock SynapsePlugin. */ readonly configure: typeof createMagicBlockPlugin; }; export { MagicBlockClient, MagicBlockApiError } from "./client"; export type { ErRoute, DelegationStatus, DelegationRecord, AccountInfoResponse, AccountInfoValue, BlockhashResponse, SignatureStatus, UnsignedTransactionResponse, BalanceResponse, SwapQuoteResponse, SwapTransactionResponse, } from "./client"; export { MAGICBLOCK_PROTOCOLS } from "./protocols"; export type { PluginProtocol, ProtocolMethod } from "./protocols"; export { routerSchemas, paymentsSchemas, vrfSchemas, } from "./schemas"; export { PricingTier, TOOL_PRICING, PRICING_TABLE, getPriceForTool, getTierForTool, formatPrice, READ_PRICE_USDC, WRITE_PRICE_USDC, USDC_DECIMALS, } from "./pricing"; export type { PricingEntry } from "./pricing"; //# sourceMappingURL=index.d.ts.map