import * as _xmtp_node_sdk from '@xmtp/node-sdk'; import { Client, EncryptedAttachment, RemoteAttachment, Attachment, Conversation, Dm, Group, DecodedMessage, Reply, Reaction, ReadReceipt, TransactionReference, WalletSendCalls, Actions, GroupUpdated, Intent, LeaveRequest, MultiRemoteAttachment, EnrichedReply, ClientOptions, NetworkOptions, StreamOptions, HexString, CreateDmOptions, CreateGroupOptions, LogLevel, Action, Identifier, Signer } from '@xmtp/node-sdk'; export * from '@xmtp/node-sdk'; import EventEmitter from 'node:events'; import { ContentCodec } from '@xmtp/content-type-primitives'; import { Hex, PrivateKeyAccount, WalletClient, Chain, Transport } from 'viem'; declare class ClientContext { #private; constructor({ client }: { client: Client; }); getClientAddress(): string | undefined; get client(): Client; } type AttachmentUploadCallback = (attachment: EncryptedAttachment) => Promise; /** * Downloads and decrypts a remote attachment. * * @param remoteAttachment - The remote attachment metadata containing the downloadd URL and encryption keys * @param agent - The agent instance used to lookup the necessary decoding codec * @returns A promise that resolves with the decrypted attachment */ declare function downloadRemoteAttachment(remoteAttachment: RemoteAttachment): Promise; /** * Creates a remote attachment object from an encrypted attachment and file URL. * * @param encryptedAttachment - The encrypted attachment containing encryption keys and metadata * @param fileUrl - The URL where the encrypted attachment can be downloaded * @returns A remote attachment object with all necessary metadata for retrieval and decryption */ declare function createRemoteAttachment(encryptedAttachment: EncryptedAttachment, fileUrl: string): RemoteAttachment; /** * Creates a remote attachment from a file by encrypting it and uploading it to a remote storage. * This is a convenience function that combines file processing, encryption, uploading, and * remote attachment creation into a single operation. * * @param unencryptedFile - The unencrypted file to process and upload * @param uploadCallback - A callback function that receives the encrypted attachment and returns the URL where it was uploaded * @returns A promise that resolves with a remote attachment containing all necessary metadata for retrieval and decryption */ declare function createRemoteAttachmentFromFile(unencryptedFile: File, uploadCallback: AttachmentUploadCallback): Promise; declare class ConversationContext extends ClientContext { #private; constructor({ conversation, client, }: { conversation: ConversationType; client: Client; }); isDm(): this is ConversationContext>; isGroup(): this is ConversationContext>; sendRemoteAttachment(unencryptedFile: File, uploadCallback: AttachmentUploadCallback): Promise; get conversation(): ConversationType; get isAllowed(): boolean; get isDenied(): boolean; get isUnknown(): boolean; } type DecodedMessageWithContent = DecodedMessage & { content: ContentTypes; }; declare const filter: { fromSelf: (message: DecodedMessage, client: Client) => boolean; hasContent: (message: DecodedMessage) => message is DecodedMessageWithContent; isDM: (conversation: Conversation) => conversation is Dm; isGroup: (conversation: Conversation) => conversation is Group; isGroupAdmin: (conversation: Conversation, message: DecodedMessage) => boolean; isGroupSuperAdmin: (conversation: Conversation, message: DecodedMessage) => boolean; usesCodec: (message: DecodedMessage, codecClass: new () => T) => message is DecodedMessageWithContent>; }; declare const f: { fromSelf: (message: DecodedMessage, client: Client) => boolean; hasContent: (message: DecodedMessage) => message is DecodedMessageWithContent; isDM: (conversation: Conversation) => conversation is Dm; isGroup: (conversation: Conversation) => conversation is Group; isGroupAdmin: (conversation: Conversation, message: DecodedMessage) => boolean; isGroupSuperAdmin: (conversation: Conversation, message: DecodedMessage) => boolean; usesCodec: (message: DecodedMessage, codecClass: new () => T) => message is DecodedMessageWithContent>; }; type MessageContextParams = Omit, "message"> & { message: DecodedMessageWithContent; }; declare class MessageContext extends ConversationContext { #private; constructor({ message, conversation, client, }: MessageContextParams); usesCodec(codecClass: new () => T): this is MessageContext>; isMarkdown(): this is MessageContext; isText(): this is MessageContext; isReply(): this is MessageContext; isReaction(): this is MessageContext; isReadReceipt(): this is MessageContext; isRemoteAttachment(): this is MessageContext; isTransactionReference(): this is MessageContext; isWalletSendCalls(): this is MessageContext; sendReaction(content: string, schema?: Reaction["schema"]): Promise; sendMarkdownReply(markdown: string): Promise; sendTextReply(text: string): Promise; getSenderAddress(): Promise; get message(): DecodedMessageWithContent; } type EventHandlerMap = { actions: [ctx: MessageContext]; attachment: [ctx: MessageContext]; conversation: [ctx: ConversationContext]; "group-update": [ctx: MessageContext]; dm: [ctx: ConversationContext>]; group: [ctx: ConversationContext>]; "inline-attachment": [ctx: MessageContext]; intent: [ctx: MessageContext]; "leave-request": [ctx: MessageContext]; markdown: [ctx: MessageContext]; message: [ctx: MessageContext]; "multi-attachment": [ ctx: MessageContext ]; reaction: [ctx: MessageContext]; "read-receipt": [ctx: MessageContext]; reply: [ctx: MessageContext]; start: [ctx: ClientContext]; stop: [ctx: ClientContext]; text: [ctx: MessageContext]; "transaction-reference": [ ctx: MessageContext ]; unhandledError: [error: Error]; unknownMessage: [ctx: MessageContext]; "wallet-send-calls": [ctx: MessageContext]; }; type EthAddress = HexString; type AgentBaseContext = { client: Client; conversation: Conversation; message: DecodedMessage; }; type AgentErrorContext = Partial> & { client: Client; }; type AgentOptions = { client: Client; }; type AgentMessageHandler = (ctx: MessageContext) => Promise | void; type AgentMiddleware = (ctx: MessageContext, next: () => Promise | void) => Promise; type AgentErrorMiddleware = (error: unknown, ctx: AgentErrorContext, next: (err?: unknown) => Promise | void) => Promise | void; type AgentCreateOptions = Omit & { codecs?: ContentCodecs; }; type AgentStreamingOptions = Omit; type StreamAllMessagesOptions = Parameters["conversations"]["streamAllMessages"]>[0]; type AgentErrorRegistrar = { use(...errorMiddleware: Array | AgentErrorMiddleware[]>): AgentErrorRegistrar; }; declare class Agent extends EventEmitter> { #private; constructor({ client }: AgentOptions); static create(signer: Parameters[0], options?: AgentCreateOptions): Promise>>; static createFromEnv(options?: AgentCreateOptions): Promise>>; get libxmtpVersion(): string | undefined; use(...middleware: Array | AgentMiddleware[]>): this; start(options?: AgentStreamingOptions): Promise; get client(): Client; get errors(): AgentErrorRegistrar; stop(): Promise; createDmWithAddress(address: EthAddress, options?: CreateDmOptions): Promise>; createGroupWithAddresses(addresses: EthAddress[], options?: CreateGroupOptions): Promise>; addMembersWithAddresses(group: Group, addresses: EthAddress[]): Promise; getConversationContext(conversationId: string): Promise | Group> | undefined>; get address(): string | undefined; } declare class AgentError extends Error { #private; constructor(code: number, message: string, cause?: unknown); get code(): number; } declare class AgentStreamingError extends AgentError { } declare const getValidLogLevels: () => LogLevel[]; declare const parseLogLevel: (rawLevel: string) => LogLevel | null; declare const logDetails: (agent: Agent) => Promise; /** * Returns a URL to test your agent on https://xmtp.chat/ (for development purposes only). * * @param client - Your XMTP client * @returns The URL to test your agent with */ declare const getTestUrl: (client: Client) => string; type InstallationInfo = { totalInstallations: number; installationId: string; mostRecentInstallationId: null | string; isMostRecent: boolean; }; declare const getInstallationInfo: (client: Client) => Promise; /** Content type supported by the "CommandRouter" */ type SupportedType = string; interface CommandRouterConfig { /** Command string to trigger help output (e.g., "/help") */ helpCommand?: `/${string}`; } declare class CommandRouter { #private; constructor(config?: CommandRouterConfig); get commandList(): string[]; command(command: string, handler: AgentMessageHandler): this; command(command: string, description: string, handler: AgentMessageHandler): this; default(handler: AgentMessageHandler): this; handle(ctx: MessageContext): Promise; middleware(): AgentMiddleware; } interface HealthReport { cpuPercent: number; eventLoopDelayMs: number; heapMB: number; heapPercent: number; heapLimitMB: number; totalMB: number; } interface PerformanceMonitorConfig { /** Interval in ms between health reports (default: 60000). Set to 0 to disable. */ healthReportInterval?: number; /** Threshold in ms for critical warning (default: 10000) */ criticalThresholdInterval?: number; /** Called when a message takes longer than the critical threshold to process. Defaults to logging a warning. */ onCriticalResponse?: (durationMs: number) => void; /** Called on each health report interval. Defaults to logging CPU and memory stats. */ onHealthReport?: (report: HealthReport) => void; /** Called after every message with the processing duration in ms. */ onResponse?: (durationMs: number) => void; /** Called when shutdown is invoked. Defaults to logging a message. */ onShutdown?: () => void; } /** * Middleware that measures message processing time and logs periodic * CPU / memory health reports. * * Register it as the first middleware so the timer wraps all downstream * middleware and handlers, giving you the total processing time independent * of other logic. */ declare class PerformanceMonitor { #private; constructor(config?: PerformanceMonitorConfig); shutdown(): void; middleware(): AgentMiddleware; } type ActionWizardCompleteHandler = (answers: Record, ctx: MessageContext) => Promise | void; type ActionWizardCancelHandler = (ctx: MessageContext) => Promise | void; type ActionWizardCancelOptions = { /** Custom label for the cancel button (default: "Cancel") */ label?: string; }; type ActionWizardOptions = { /** * When true, the wizard sends all steps via DM to the user. * Recommended when the user is expected to enter sensitive information * (e.g. API keys, passwords) to keep it out of group conversations. */ dm?: boolean; /** Enable a cancel button on each select step. Set to `true` for the default label, or pass options to customize. */ cancel?: boolean | ActionWizardCancelOptions; }; /** * Multi-step interactive wizard using XMTP actions and intents. * * Supports two step types: * - **select** — presents action buttons, the user responds by clicking one (triggers an intent) * - **text** — prompts the user for free-text input * * The wizard activates when a user sends `/{id}` (e.g. `/api-setup`). * Sending the command again while a session is active restarts the wizard from the first step. */ declare class ActionWizard { #private; constructor(id: string, options?: ActionWizardOptions); static sessionKey(conversationId: string, senderInboxId: string): string; static stepKey(wizardId: string, stepId: string): string; select(id: string, options: { description: string; actions: Action[]; }): this; text(id: string, options: { description: string; isMarkdown?: boolean; }): this; onComplete(handler: ActionWizardCompleteHandler): this; onCancel(handler: ActionWizardCancelHandler): this; start(ctx: MessageContext): Promise; isActive(conversationId: string, senderInboxId: string): boolean; middleware(): AgentMiddleware; } type User = { key: Hex; account: PrivateKeyAccount; wallet: WalletClient; }; declare const createUser: (key?: HexString, chain?: Chain) => User; declare const createIdentifier: (user: User) => Identifier; declare const createSigner: (user: User) => Signer; declare const createNameResolver: (apiKey?: string) => (name: string) => Promise; /** * Minimal ERC-20 ABI containing transfer, balanceOf, and decimals functions. * Can be used with viem's encodeFunctionData for custom ERC-20 interactions. * * @see https://eips.ethereum.org/EIPS/eip-20#methods */ declare const erc20Abi: readonly [{ readonly type: "function"; readonly name: "transfer"; readonly inputs: readonly [{ readonly name: "to"; readonly type: "address"; }, { readonly name: "amount"; readonly type: "uint256"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "bool"; }]; readonly stateMutability: "nonpayable"; }, { readonly type: "function"; readonly name: "balanceOf"; readonly inputs: readonly [{ readonly name: "account"; readonly type: "address"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "decimals"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "uint8"; }]; readonly stateMutability: "view"; }]; type CreateERC20TransferCallsOptions = { /** The viem Chain object (e.g., baseSepolia from "viem/chains"). */ chain: Chain; /** The ERC-20 token contract address (e.g., Base Token Contract List: https://basescan.org/tokens). */ tokenAddress: Hex; /** The sender's address. */ from: Hex; /** The recipient's address. */ to: Hex; /** The amount to transfer in the token's base units (e.g., 1_000_000 for 1 USDC). */ amount: bigint; /** Description that will be shown in the app with the transaction. */ description: string; }; type CreateNativeTransferCallsOptions = Omit; type GetERC20BalanceOptions = { /** The viem Chain object. */ chain: Chain; /** The ERC-20 token contract address. */ tokenAddress: Hex; /** The address to query the balance of. */ address: Hex; /** Optional custom viem transport. Defaults to http(). */ transport?: Transport; }; type GetERC20DecimalsOptions = { /** The viem Chain object. */ chain: Chain; /** The ERC-20 token contract address. */ tokenAddress: Hex; /** Optional custom viem transport. Defaults to http(). */ transport?: Transport; }; /** * Creates a WalletSendCalls payload for an ERC-20 token transfer. * * @param options - The transfer options * @returns A WalletSendCalls object ready to send */ declare function createERC20TransferCalls(options: CreateERC20TransferCallsOptions): WalletSendCalls; /** * Creates a WalletSendCalls payload for a native token transfer (ETH, MATIC, etc.). * * @param options - The transfer options * @returns A WalletSendCalls object ready to send */ declare function createNativeTransferCalls(options: CreateNativeTransferCallsOptions): WalletSendCalls; /** * Reads the ERC-20 token balance for a given address from the blockchain. * * @param options - The query options including chain, token address, and wallet address * @returns The token balance in base units as a bigint */ declare function getERC20Balance(options: GetERC20BalanceOptions): Promise; /** * Reads the number of decimals for an ERC-20 token from the blockchain. * * @param options - The query options including chain and token address * @returns The number of decimals (typically 6 or 18) */ declare function getERC20Decimals(options: GetERC20DecimalsOptions): Promise; export { ActionWizard, Agent, AgentError, AgentStreamingError, ClientContext, CommandRouter, ConversationContext, MessageContext, PerformanceMonitor, createERC20TransferCalls, createIdentifier, createNameResolver, createNativeTransferCalls, createRemoteAttachment, createRemoteAttachmentFromFile, createSigner, createUser, downloadRemoteAttachment, erc20Abi, f, filter, getERC20Balance, getERC20Decimals, getInstallationInfo, getTestUrl, getValidLogLevels, logDetails, parseLogLevel }; export type { ActionWizardCancelOptions, ActionWizardOptions, AgentBaseContext, AgentCreateOptions, AgentErrorContext, AgentErrorMiddleware, AgentErrorRegistrar, AgentMessageHandler, AgentMiddleware, AgentOptions, AgentStreamingOptions, AttachmentUploadCallback, CommandRouterConfig, CreateERC20TransferCallsOptions, CreateNativeTransferCallsOptions, DecodedMessageWithContent, GetERC20BalanceOptions, GetERC20DecimalsOptions, HealthReport, MessageContextParams, PerformanceMonitorConfig, StreamAllMessagesOptions, User };