UNPKG

@bitte-ai/types

Version:
1 lines 34.3 kB
{"version":3,"sources":["../src/index.ts"],"names":["Operation"],"mappings":";AA8BO,IAAM,SAAY,GAAA;AAAA,EACvB,GAAK,EAAA,KAAA;AAAA,EACL,IAAM,EAAA,MAAA;AAAA,EACN,GAAK,EAAA;AACP;AAsvCY,IAAA,SAAA,qBAAAA,UAAL,KAAA;AACL,EAAAA,WAAA,MAAO,CAAA,GAAA,MAAA;AACP,EAAAA,WAAA,OAAQ,CAAA,GAAA,OAAA;AACR,EAAAA,WAAA,SAAU,CAAA,GAAA,SAAA;AAHA,EAAAA,OAAAA,UAAAA;AAAA,CAAA,EAAA,SAAA,IAAA,EAAA","file":"index.mjs","sourcesContent":["import type { Transaction as SuiTransaction } from '@mysten/sui/transactions';\nimport type {\n FinalExecutionOutcome,\n FunctionCallAction,\n Transaction,\n Wallet,\n} from '@near-wallet-selector/core';\nimport type { WalletContextState } from '@suiet/wallet-kit';\nimport type {\n Message as AIMessage,\n ChatRequestOptions,\n CreateMessage,\n UIMessage,\n} from 'ai';\nimport type BN from 'bn.js';\nimport type { Account } from 'near-api-js';\nimport type { OpenAPIV3 } from 'openapi-types';\nimport type { ComponentType } from 'react';\nimport type { Transaction as EVMTransaction, Hash, Hex, Signature } from 'viem';\nimport type { Config } from 'wagmi';\nimport type {\n SendTransactionMutate,\n SignMessageMutate,\n SignTypedDataMutate,\n SwitchChainMutate,\n} from 'wagmi/query';\nimport type { EthSendTransactionRequest, SignRequest } from './evm';\n\nexport * from './evm';\n\nexport const ChainType = {\n EVM: 'evm',\n NEAR: 'near',\n SUI: 'sui',\n} as const;\n\nexport type ChainType = (typeof ChainType)[keyof typeof ChainType];\n\n// Core Types\nexport type BitteMetadata = Record<string, unknown>;\n\nexport type JSONValue =\n | string\n | number\n | boolean\n | null\n | { [key: string]: JSONValue }\n | JSONValue[];\n\n// Tool Types\nexport type FunctionDefinition = {\n name: string;\n description: string;\n parameters: Record<string, unknown>;\n};\n\nexport type PluginToolSpec = {\n id: string;\n agentId: string;\n type: 'function';\n function: FunctionDefinition;\n execution: ExecutionDefinition;\n verified: boolean;\n};\n\nexport type ExecutionDefinition = {\n baseUrl: string;\n path: string;\n httpMethod: string;\n};\n\nexport type FunctionTool = {\n type: 'function';\n function: FunctionDefinition;\n};\n\nexport type CoreTool = unknown;\nexport type AssistantTool = unknown;\nexport type BitteToolSpec = PluginToolSpec | FunctionTool;\n\n// Rename to BitteCoreTool to avoid confusion with primitives.BitteTool\nexport type BitteCoreTool<\n TArgs = Record<string, JSONValue>,\n TResult = unknown,\n> = {\n toolSpec: FunctionTool;\n execute?: BitteToolExecutor<TArgs, TResult>;\n chainIds?: string[];\n};\n\nexport type BitteToolExecutor<\n TArgs = Record<string, JSONValue>,\n TResult = unknown,\n> = (\n args: TArgs,\n metadata?: BitteMetadata,\n) => Promise<BitteToolResult<TResult>>;\n\n// For backward compatibility\n\nexport type BitteToolResult<TResult = unknown> =\n | { data: TResult; error?: never; prompt?: string }\n | { data?: never; error: string };\n\nexport type BitteToolWarning = {\n message: string;\n final: boolean;\n};\n\n// Agent Types\nexport type BittePrimitiveRef = {\n type: string;\n};\n\nexport type BitteAgentConfig = {\n id: string;\n name: string;\n accountId?: string | null;\n description: string;\n instructions: string;\n verified: boolean;\n tools?: BitteToolSpec[];\n image?: string | null;\n repo?: string | null;\n categories?: string[];\n chainIds?: number[];\n primitives?: string[];\n};\n\nexport type BitteAgent = Omit<BitteAgentConfig, 'tools'> & {\n toolSpecs?: FunctionTool[];\n tools?: Record<string, CoreTool>;\n};\n\nexport type BitteAgentBase = {\n name: string;\n description: string;\n instructions: string;\n tools?: BitteToolSpec[];\n image?: string;\n chainIds?: number[];\n categories?: string[];\n repo?: string;\n};\n\nexport type AgentMetadata = {\n evmAddress?: string;\n accountId?: string;\n network: string;\n localAgent?: LocalAgentSpec;\n agentId: string;\n};\n\nexport type LocalAgentSpec = {\n pluginId: string;\n accountId: string;\n spec: BitteOpenAPISpec;\n};\n\nexport type BitteOpenAPISpec = OpenAPIV3.Document & {\n 'x-mb': {\n 'account-id'?: string;\n assistant?: Pick<\n BitteAssistantConfig,\n 'name' | 'description' | 'instructions' | 'tools' | 'image'\n > & {\n tools?: (AssistantTool | BittePrimitiveRef)[];\n };\n };\n};\n\nexport type BitteAssistantConfig = {\n id: string;\n name: string;\n accountId: string;\n description: string;\n instructions: string;\n verified: boolean;\n tools?: BitteToolSpec[];\n image?: string;\n};\n\nexport type BitteAssistant = Omit<BitteAssistantConfig, 'tools'> & {\n toolSpecs?: FunctionTool[];\n tools?: Record<string, CoreTool>;\n};\n\n// BitteAI configuration\nexport interface BitteAIOptions {\n apiKey?: string;\n baseUrl?: string;\n timeout?: number;\n}\n\n// These types are imported from external packages but defined here temporarily\n// We're using Record<string, unknown> instead of any to satisfy the linter\nexport interface NearTransaction {\n signerId: string;\n receiverId: string;\n actions: unknown[];\n}\n\nexport interface EVMWalletAdapter {\n sendTransaction: SendTransactionMutate<Config, unknown>;\n // Signing methods for different types of sign requests\n signMessage?: SignMessageMutate<unknown>;\n signTypedData?: SignTypedDataMutate<unknown>;\n switchChain: SwitchChainMutate<Config, unknown>;\n address: string | `0x${string}` | undefined;\n chainId?: number;\n hash?: Hash | string | `0x${string}` | undefined;\n signature?: Signature;\n authorization?: string | `0x${string}`;\n}\n\nexport interface CardanoSignRequest {\n transactionBytes: string;\n partialSign?: boolean;\n}\n\nexport interface CardanoWalletAdapter {\n signTx?: (unsignedTx: string, partialSign?: boolean) => Promise<string>;\n submitTx?: (signedTx: string) => Promise<string>;\n address?: string;\n}\n\n// This enum is used both as a type and a runtime value in the chat package\nexport type AssistantsMode = 'default' | 'debug';\n\nexport interface ToolInvocation {\n toolName: string;\n toolCallId: string;\n state: 'result' | 'running' | 'error';\n args: Record<string, JSONValue> & {\n message?: string;\n nonce?: string;\n recipient?: string;\n callbackUrl?: string;\n };\n result?: {\n data?:\n | {\n transactions?: unknown[];\n warnings?: string[];\n suiTransactionBytes?: unknown;\n evmSignRequest?: unknown;\n url?: string;\n // Chart properties\n title?: string;\n description?: string;\n chartConfig?: unknown;\n chartData?: unknown;\n metricData?: unknown;\n metricLabels?: unknown;\n dataFormat?: string;\n chartType?: string;\n }\n | JSONValue;\n error?: string;\n };\n}\n\nexport interface MessagePart {\n type: 'tool-invocation' | string;\n toolInvocation?: ToolInvocation;\n}\n\nexport type SmartAction = {\n id: string;\n agentId: string;\n message: string;\n creator: string;\n createdAt: number;\n};\n\nexport type SmartActionMessage = {\n id?: string;\n agentId?: string;\n content: string;\n role: ExtendedMessageRole;\n parts?: UIMessage['parts'];\n};\n\n// Extend the Message type to include data role from ai package\nexport type ExtendedMessageRole =\n | 'user'\n | 'assistant'\n | 'system'\n | 'function'\n | 'data'\n | 'tool';\n\nexport type SmartActionAiMessage = Omit<Message, 'role'> & {\n id?: string;\n agentId?: string;\n agentImage?: string;\n agentName?: string;\n parts?: MessagePart[];\n role: ExtendedMessageRole;\n};\n\nexport type SmartActionChat = SmartAction & {\n messages: SmartActionMessage[];\n};\n\nexport type SaveSmartAction = {\n agentId: string;\n creator: string;\n message: string;\n};\n\nexport type SaveSmartActionMessages = {\n id: string;\n agentId: string;\n creator: string;\n messages: SmartActionMessage[];\n};\n\n// Base token information\nexport interface BaseTokenInfo {\n name: string;\n symbol: string;\n decimals: number;\n icon?: string; // generate-evm-transaction.ts (CowSwap)\n tokenIcon?: string; // get-portfolio.ts\n contractAddress?: string;\n}\n\n// Token metadata with additional properties\nexport interface TokenMeta extends BaseTokenInfo {\n isSpam?: boolean;\n}\n\n// Token info with balance/value information\nexport interface TokenInfo extends BaseTokenInfo {\n amount: string;\n usdValue: number;\n}\n// Base definition for swap data\nexport interface SwapFTData {\n network: {\n name: string;\n icon: string;\n };\n type: 'swap';\n fee: string;\n tokenIn: TokenInfo;\n tokenOut: TokenInfo;\n}\n\n// Transfer data using the TokenInfo interface\nexport interface TransferFTData {\n network: {\n name: string;\n icon: string;\n };\n type: 'transfer-ft';\n sender: string;\n receiver: string;\n token: TokenInfo; // Reuse TokenInfo instead of duplicating fields\n}\n\nexport interface TransferResponse {\n data: TransferFTData;\n evmSignRequest: EthSendTransactionRequest;\n type: 'transfer-ft';\n}\n\nexport interface SwapResponse {\n data: SwapFTData;\n evmSignRequest: EthSendTransactionRequest;\n type: 'swap';\n}\n\n// Primitive: get-portfolio.ts\nexport interface PriceChange {\n day: number;\n week: number;\n month: number;\n}\n\nexport type EVMTransactionAction = FunctionCallAction | TransferAction;\n\nexport interface NearTransferAction {\n type: 'Transfer';\n params: {\n deposit: string;\n };\n}\n\nexport type AccountEVMTransaction = Omit<EVMTransaction, 'actions'> & {\n actions: Array<FunctionCallAction | TransferAction>;\n};\n\nexport interface PriceData {\n day: [number, number][];\n week: [number, number][];\n month: [number, number][];\n}\n\nexport interface TokenBalances {\n balance: number;\n usdBalance: number;\n price?: number;\n}\n\nexport interface BaseAsset {\n symbol: string;\n usdValue: number;\n chains: string[];\n icon: string | null;\n balances: TokenBalances;\n meta: TokenMeta;\n}\n\nexport interface EnhancedAsset extends BaseAsset {\n priceChanges?: PriceChange;\n priceData?: PriceData;\n volume24h: number;\n marketcap: number;\n}\n\nexport interface WalletAgentContext {\n portfolioValue: number;\n chainsWithGas: string[];\n significantAssets: BaseAsset[];\n actionableSummary: string;\n}\n\nexport interface PortfolioResponse extends WalletAgentContext {\n significantAssets: EnhancedAsset[];\n}\n\nexport interface TransferFtResult {\n EVMTransactions: AccountEVMTransaction[];\n warnings?: string[];\n}\n\nexport interface GenerateEVMTransactionParams {\n EVMTransactions: AccountEVMTransaction[];\n network?: 'mainnet' | 'testnet';\n}\n\nexport type TransferFtParams = {\n signerId: string;\n receiverId: string;\n tokenIdentifier: string;\n amount: string;\n network?: 'mainnet' | 'testnet';\n};\n\n// Define specific props types for each tool\nexport type PortfolioComponentProps = {\n data: PortfolioResponse;\n sendPrompt?: SendPromptFunction;\n};\n\nexport type TransferToolProps = {\n data: TransferFTData;\n sendPrompt?: SendPromptFunction;\n};\n\nexport type SwapComponentDataProps = {\n data: SwapFTData;\n sendPrompt?: SendPromptFunction;\n};\n\n// Base tool interfaces - updated for better type consistency\nexport interface BaseTool<T = unknown> {\n name: string;\n component: React.ComponentType<T>;\n}\n\n// BitteTool wrapper that's consistent across the codebase\nexport interface BitteTool<T = unknown> extends BaseTool<T> {\n // Additional properties specific to Bitte tools can be added here\n}\n\nexport interface TransferTool extends BitteTool<TransferToolProps> {\n name: 'transfer-ft';\n}\n\nexport interface PortfolioTool extends BitteTool<PortfolioComponentProps> {\n name: 'portfolio';\n}\n\nexport interface SwapTool extends BitteTool<SwapComponentDataProps> {\n name: 'swap';\n}\n\n// Primitive: generate-evm-EVMTransaction.ts\nexport interface GenerateImageResponse {\n url: string;\n hash: string;\n}\n\n// Primitive: sign-message.ts\nexport interface SignMessageParams {\n message: string;\n callbackUrl: string;\n recipient: string;\n nonce: string;\n}\n\nexport interface SignMessageResult {\n accountId: string;\n publicKey: string;\n signature: string;\n message: string;\n nonce: string;\n recipient: string;\n callbackUrl: string;\n state: string;\n}\n\n// Convert enum to string literal type\nexport type BittePrimitiveName =\n | 'transfer-ft'\n | 'generate-EVMTransaction'\n | 'submit-query'\n | 'generate-image'\n | 'getSwapEVMTransactions'\n | 'getTokenMetadata'\n | 'generate-evm-tx'\n | 'generate-sui-tx'\n | 'render-chart'\n | 'sign-message'\n | 'get-portfolio'\n | 'aftermath-sui-swap'\n | 'get-sui-balances'\n | 'sui-lst';\n\n// ----------------- Transaction Action Types -----------------\nexport interface TransferAction {\n type: 'Transfer';\n params: Record<string, unknown>;\n}\n\nexport interface NearFunctionCallAction {\n type: 'FunctionCall';\n params: {\n methodName: string;\n args: Record<string, JSONValue>;\n deposit?: string;\n gas?: string;\n };\n}\n// ----------------- Widget Chat Props -----------------\nexport interface WidgetChatProps {\n widgetWelcomePrompts?: WelcomeQuestionAction;\n customTriggerButton?: React.ReactElement;\n triggerButtonStyles?: {\n backgroundColor?: string;\n logoColor?: string;\n };\n}\n\n// ----------------- Message Type -----------------\nexport interface Message {\n id: string;\n role: ExtendedMessageRole;\n content: string;\n}\n\n// ----------------- Chat Component Types -----------------\nexport type ChatComponentColors = {\n generalBackground?: string;\n messageBackground?: string;\n textColor?: string;\n buttonColor?: string;\n borderColor?: string;\n};\n\nexport type SendPromptFunction = (prompt: string) => Promise<void> | void;\n\n/* Custom Components */\nexport interface MessageGroupComponentProps {\n message: SmartActionAiMessage;\n isUser: boolean;\n userName: string;\n children: React.ReactNode;\n style: {\n backgroundColor: string;\n borderColor: string;\n textColor: string;\n };\n uniqueKey: string;\n showBorder?: boolean;\n}\n\nexport interface ChatContainerComponentProps {\n children: React.ReactNode;\n style?: {\n backgroundColor?: string;\n borderColor?: string;\n };\n}\n\nexport interface InputContainerProps {\n children: React.ReactNode;\n style?: {\n backgroundColor?: string;\n borderColor?: string;\n };\n}\n\nexport interface LoadingIndicatorComponentProps {\n textColor?: string;\n}\n\nexport interface SendButtonComponentProps {\n input: string;\n isLoading: boolean;\n buttonColor?: string;\n textColor?: string;\n onClick?: () => void;\n}\n\n// ----------------- Transaction Component Types -----------------\nexport interface TransactionButtonProps {\n onClick: ButtonHandler;\n disabled?: boolean;\n isLoading?: boolean;\n label?: string;\n}\n\n// Container props\nexport interface TransactionContainerProps {\n children: React.ReactNode;\n style: {\n backgroundColor: string;\n borderColor: string;\n textColor: string;\n };\n}\n\n// Custom components interface\nexport interface CustomTransactionComponents {\n Container?: React.ComponentType<TransactionContainerProps>;\n ApproveButton?: React.ComponentType<TransactionButtonProps>;\n DeclineButton?: React.ComponentType<TransactionButtonProps>;\n}\n\n// ----------------- Chat Configuration -----------------\nexport interface WelcomeQuestionAction {\n title?: string;\n description?: string;\n questions?: string[];\n actions?: string[];\n}\n\n// Add this new type for welcome configuration\nexport type WelcomeComponentConfig =\n | { type: 'component'; component: JSX.Element }\n | {\n type: 'account-overview';\n info: Partial<WelcomeQuestionAction>;\n data: PortfolioResponse;\n };\n\nexport interface BitteAiChatOptions {\n agentName?: string;\n agentImage?: string;\n chatId?: string;\n prompt?: string;\n localAgent?: {\n pluginId: string;\n accountId: string;\n spec: BitteOpenAPISpec;\n };\n mcpServerUrl?: string;\n placeholderText?: string;\n colors?: ChatComponentColors;\n customComponents?: {\n welcomeMessageComponent?: WelcomeComponentConfig;\n mobileInputExtraButton?: JSX.Element;\n messageContainer?: ComponentType<MessageGroupComponentProps>;\n chatContainer?: ComponentType<ChatContainerComponentProps>;\n inputContainer?: ComponentType<InputContainerProps>;\n sendButtonComponent?: ComponentType<SendButtonComponentProps>;\n loadingIndicator?: ComponentType<LoadingIndicatorComponentProps>;\n };\n hideToolCall?: boolean;\n}\n\n// Common props for custom tool components - support exact types from primitives\nexport interface CustomToolComponentProps {\n data:\n | PortfolioResponse\n | TransferResponse\n | SwapResponse\n | Record<string, JSONValue>;\n type: ToolName;\n}\n\n// Define custom tool component\nexport interface ReactToolComponent {\n name: string;\n component: React.ComponentType<CustomToolComponentProps>;\n}\n\n// Update CustomToolComponent type to align with BitteTool from primitives.ts\nexport type CustomToolComponent =\n | PortfolioTool\n | TransferTool\n | SwapTool\n | ReactToolComponent;\n\nexport type ToolName = 'get-portfolio' | 'transfer-ft' | 'swap';\n\nexport interface ToolConfigMap {\n 'get-portfolio': {\n component: React.ComponentType<PortfolioComponentProps>;\n getToolData: (data: unknown) => PortfolioResponse;\n };\n 'transfer-ft': {\n component: React.ComponentType<TransferToolProps>;\n getToolData: (data: unknown) => TransferFTData;\n };\n swap: {\n component: React.ComponentType<SwapComponentDataProps>;\n getToolData: (data: unknown) => SwapFTData;\n };\n}\n\n// ----------------- Account Types -----------------\nexport interface AccountContextType {\n wallet?: Wallet;\n account?: Account;\n accountId: string | null;\n nearWalletId: string | undefined;\n evmWallet?: EVMWalletAdapter;\n evmAddress?: string;\n chainId?: number;\n suiWallet?: WalletContextState;\n suiAddress?: string;\n cardanoWallet?: CardanoWalletAdapter;\n cardanoAddress?: string;\n}\n\nexport type WalletOptions = {\n near?: {\n wallet?: Wallet; // From near-wallet-selector\n account?: Account; // From near-api-js\n accountId: string;\n nearWalletId: string | undefined;\n };\n evm?: EVMWalletAdapter; // Interface matching wagmi hook outputs\n sui?: {\n wallet?: WalletContextState; // From @suiet/wallet-kit\n };\n cardano?: CardanoWalletAdapter; // From @meshsdk/react\n};\n\nexport interface BitteAiChatProps {\n options?: BitteAiChatOptions;\n agentId: string;\n wallet: WalletOptions;\n apiUrl: string;\n historyApiUrl?: string;\n apiKey?: string;\n messages?: Message[];\n customToolComponents?: CustomToolComponent[];\n onChatLoaded?: () => void;\n onMessageReceived?: (message: Message) => void;\n widget?: WidgetChatProps;\n isWidgetChat?: boolean;\n format?: 'markdown' | 'plaintext';\n}\n\nexport interface UnifiedChatContentProps extends BitteAiChatProps {\n urlChatId?: string;\n isWidgetChat?: boolean;\n}\n\nexport interface ChatRequestBody {\n id?: string;\n config?: {\n mode?: string;\n agentId?: string;\n model?: string;\n mcpServerUrl?: string;\n format?: 'markdown' | 'plaintext';\n };\n accountId?: string;\n network?: string;\n evmAddress?: Hex;\n suiAddress?: string;\n nearWalletId?: string;\n chainId?: number;\n localAgent?: {\n pluginId: string;\n accountId: string;\n spec: BitteOpenAPISpec;\n };\n}\n\nexport type BitteAiChat = (props: BitteAiChatProps) => JSX.Element;\n\nexport interface BaseInfo {\n name: string;\n icon: string;\n}\n\n// Rename to avoid collision with the other TokenInfo interface\nexport interface BaseTokenData extends BaseInfo {\n amount: string;\n usdValue: number;\n}\n\nexport type TokenTransactionData<T extends 'swap' | 'transfer-ft'> = {\n network: BaseInfo;\n txnData: NearTransaction | SignRequest | SuiTransaction;\n} & (T extends 'swap'\n ? {\n type: 'swap';\n tokenIn: BaseTokenData;\n tokenOut: BaseTokenData;\n }\n : {\n type: 'transfer-ft';\n sender: string;\n receiver: string;\n token: BaseTokenData;\n });\n\nexport type SwapFTDataResponse = TokenTransactionData<'swap'>;\nexport type TransferFTDataResponse = TokenTransactionData<'transfer-ft'>;\n\n// Common styling interface\nexport interface CommonStyleProps {\n textColor: string;\n messageBackgroundColor: string;\n borderColor: string;\n}\n\n// Transaction components interface\nexport interface TransactionComponentProps {\n customTxContainer?: React.ComponentType<TransactionContainerProps>;\n customApproveTxButton?: React.ComponentType<TransactionButtonProps>;\n customDeclineTxButton?: React.ComponentType<TransactionButtonProps>;\n}\n\nexport interface ReviewSignMessageProps\n extends CommonStyleProps,\n TransactionComponentProps {\n message: string;\n recipient?: string;\n nonce?: string;\n callbackUrl?: string;\n chatId: string | undefined;\n toolCallId: string;\n addToolResult: (result: BitteToolResult<SignMessageResult>) => void;\n}\n\n// Use generic type for the result\nexport interface TransactionResultProps<\n T = {\n evm?: { txHash?: string; chainId: number };\n near?: { receipts?: { transaction: { hash: string } }[] };\n sui?: { digest?: string };\n },\n> {\n result: T;\n accountId: string;\n textColor: string;\n}\n\n// ----------------- Input Component Types -----------------\nexport interface SmartActionsInputProps {\n input: string;\n isLoading: boolean;\n agentName?: string;\n handleChange: (e: React.ChangeEvent<HTMLTextAreaElement>) => void;\n handleSubmit: (e: React.FormEvent<HTMLFormElement>) => void;\n buttonColor: string;\n borderColor: string;\n textColor: string;\n backgroundColor: string;\n mobileInputExtraButton?: React.JSX.Element;\n customSendButtonComponent?: React.ComponentType<SendButtonComponentProps>;\n placeholderText?: string;\n}\n\nexport type AIMessageLike = AIMessage | CreateMessage;\nexport type MessageAppend = (\n message: AIMessageLike,\n chatRequestOptions?: ChatRequestOptions,\n) => Promise<string | null | undefined>;\n\n// ----------------- Message Display Types -----------------\nexport interface MessageGroupProps\n extends CommonStyleProps,\n TransactionComponentProps {\n chatId: string | undefined;\n groupKey: string;\n messages: Message[];\n accountId: string;\n creator?: string;\n isLoading?: boolean;\n agentImage?: string;\n agentName?: string;\n evmAdapter?: EVMWalletAdapter;\n account?: Account;\n wallet?: Wallet;\n addToolResult: (params: {\n toolCallId: string;\n result: BitteToolResult<unknown>;\n }) => void;\n append: MessageAppend;\n customMessageContainer?: React.ComponentType<MessageGroupComponentProps>;\n customToolComponents?: CustomToolComponent[];\n showBorder?: boolean;\n hideToolCall?: boolean;\n}\n\nexport type TransactionListComponentProps = {\n accountId: string;\n operation?: TransactionOperation;\n transaction: NearTransaction[];\n modifiedUrl: string;\n showDetails: boolean;\n showTxnDetail: boolean;\n setShowTxnDetail: (showTxnDetail: boolean) => void;\n costs: Cost[];\n gasPrice: string;\n borderColor: string;\n};\n\n// Generic component props for actions\nexport interface ActionComponentProps<T> {\n data: T;\n onApprove?: ButtonHandler;\n onExplain?: ButtonHandler;\n onFunctionCall?: ButtonHandler;\n sendPrompt?: SendPromptFunction;\n}\n\nexport interface SwapComponentProps extends ActionComponentProps<SwapFTData> {}\n\nexport interface TransferComponentProps\n extends ActionComponentProps<TransferFTData> {}\n\nexport interface NetworkInfo {\n name: string;\n icon: string | React.ReactNode;\n}\n\nexport interface NetworkBadgeProps {\n network: NetworkInfo;\n iconOverride?: string;\n}\n\nexport interface WelcomeListProps {\n items: string[];\n label: string;\n bgColor: string;\n onItemClick: (item: string) => void;\n}\n\n// Generic type for button action handlers\nexport type ButtonHandler = () => void;\n\n// Common button options\nexport interface ButtonOptions {\n label?: string;\n show?: boolean;\n handler?: ButtonHandler;\n}\n\n// Common transaction data props\nexport interface TransactionDataProps {\n transactions?: NearTransaction[];\n evmData?: SignRequest;\n suiTransaction?: SuiTransaction;\n suiTransactionBytes?: string;\n messageId?: string;\n append?: MessageAppend;\n // biome-ignore lint/suspicious/noExplicitAny: External API type\n txnData?: any; // Data to show in the code block\n}\n\nexport interface ActionHandlers {\n onFunctionCall?: ButtonHandler;\n onExplain?: ButtonHandler;\n onApprove?: ButtonHandler;\n}\n\nexport interface ActionVisibility {\n showFunctionCall?: boolean;\n showExplain?: boolean;\n showApprove?: boolean;\n}\n\nexport interface ActionLabels {\n functionCall?: string;\n explain?: string;\n approve?: string;\n}\n\nexport interface ActionButtonsProps extends TransactionDataProps {\n handlers: ActionHandlers;\n actions?: ActionVisibility;\n labels?: ActionLabels;\n}\n\ninterface TransactionReceipt {\n transaction: {\n hash: string;\n };\n [key: string]: unknown;\n}\n\nexport interface TransactionResult {\n near?: {\n receipts: TransactionReceipt[];\n transactions: NearTransaction[];\n encodedTxn?: string;\n };\n sui?: {\n digest: string;\n effects: string;\n };\n evm?: {\n txHash: string;\n chainId: number;\n };\n}\n\nexport type MessageLike =\n | Message\n | Omit<Message, 'id'>\n | {\n id?: string;\n role: string;\n content: string;\n createdAt: Date | string;\n [key: string]: unknown;\n };\n\n// Message append function type that accepts more generic message types\nexport type MessageAppendFunction = (\n message: MessageLike,\n) => Promise<string | null | undefined>;\n\nexport type TransactionApprovalOptions = {\n messageId?: string;\n append?: MessageAppend;\n};\n\nexport type TransactionStatus = 'success' | 'fail' | 'pending';\n\nexport interface TransactionState {\n isLoading: boolean;\n errorMsg: string;\n result: TransactionResult | null;\n txHash?: string;\n txDigest?: string;\n}\n\n// Define action types\nexport type TransactionStateAction =\n | { type: 'SET_LOADING'; payload: boolean }\n | { type: 'SET_ERROR'; payload: string }\n | { type: 'SET_RESULT'; payload: TransactionResult }\n | { type: 'SET_TX_HASH'; payload: string }\n | { type: 'SET_TX_DIGEST'; payload: string }\n | { type: 'RESET_ERROR' };\n\nexport type ToolInvocationManagerProps = {\n message: SmartActionAiMessage;\n chatId: string;\n creator?: string;\n isLoading?: boolean;\n borderColor?: string;\n messageBackgroundColor?: string;\n textColor?: string;\n addToolResult: (params: {\n toolCallId: string;\n result: BitteToolResult<unknown>;\n }) => void;\n append: MessageAppend;\n customTxContainer?: React.ComponentType<TransactionContainerProps>;\n customApproveTxButton?: React.ComponentType<TransactionButtonProps>;\n customDeclineTxButton?: React.ComponentType<TransactionButtonProps>;\n customToolComponents?: CustomToolComponent[];\n uniqueKey: string;\n};\n\nexport type MessageContentProps = {\n message: SmartActionAiMessage;\n borderColor?: string;\n append: MessageAppend;\n customToolComponents?: (CustomToolComponent | ReactToolComponent)[];\n};\n\nexport type ToolInvocationRendererProps = {\n toolName: string;\n toolCallId: string;\n state: string;\n result: BitteToolResult<PortfolioResponse | TransferFTData | SwapFTData>;\n borderColor?: string;\n customToolComponents?: (CustomToolComponent | ReactToolComponent)[];\n append: MessageAppend;\n};\n\nexport interface AccountCreationData {\n devicePublicKey: string;\n accountId: string;\n isCreated: boolean;\n txnHash?: string;\n}\n\nexport interface SuccessInfo {\n near: {\n receipts: FinalExecutionOutcome[];\n transactions: Transaction[];\n encodedTxn?: string;\n };\n sui?: {\n digest: string;\n effects: string;\n };\n cardano?: {\n txHash: string;\n };\n}\n\nexport interface UseTransactionProps {\n account?: Account;\n wallet?: Wallet;\n evmWallet?: EVMWalletAdapter;\n suiWallet?: WalletContextState;\n cardanoWallet?: CardanoWalletAdapter;\n}\n\nexport interface HandleTxnOptions {\n transactions?: Transaction[];\n evmData?: SignRequest;\n suiTransaction?: SuiTransaction;\n cardanoData?: CardanoSignRequest;\n}\n\ntype ActionObject = {\n send: () => Promise<void>;\n show: () => void;\n try: () => void;\n};\n\nexport type Arguments = {\n autotransfer?: boolean;\n account_id?: string;\n msg?: string;\n token_id?: string;\n metadata?: Metadata | string;\n num_to_mint?: number;\n owner_id?: string;\n royalty_args?: string | number | null;\n split_owners?: string | number | null;\n token_ids_to_mint?: string | number | null;\n receiver_id?: string;\n token_ids?: string[];\n methodName?: string;\n amount?: string | number;\n memo?: string | null;\n nft_contract_id?: string | null;\n title?: string;\n tokenImg?: string;\n};\n\ntype Metadata = {\n media: string;\n reference: string;\n title?: string;\n description?: string;\n};\n\nexport type TransactionListProps = {\n transaction: Transaction[];\n operation?: TransactionOperation;\n actions?: ActionObject;\n modifiedUrl: string;\n showDetails: boolean;\n showTxnDetail: boolean;\n setShowTxnDetail: (showTxnDetail: boolean) => void;\n};\n\nexport type TxnDetailWrapperProps = {\n accountId: string;\n transaction: Transaction[];\n modifiedUrl: string;\n showDetails: boolean;\n showTxnDetail: boolean;\n costs: Cost[];\n gasPrice: string;\n};\n\nexport type TransactionDetailProps = {\n transaction: Transaction;\n showDetails: boolean;\n modifiedUrl: string;\n gas: string | number;\n deposit: string | number;\n};\n\nexport type FlattenTransactionResults = {\n hash: string;\n sender: string;\n receiver: string;\n txn: Transaction[];\n type: string;\n};\n\nexport type ActionCosts =\n | 'CreateAccount'\n | 'Transfer'\n | 'Stake'\n | 'AddFullAccessKey'\n | 'DeleteKey';\n\nexport interface NearTransactionState {\n sponsor?: string;\n isLoading: boolean;\n exportLoading: boolean;\n migrationError: string | null;\n migrationLoading: boolean;\n results: FinalExecutionOutcome[] | null;\n error?: { message: string };\n}\n\nexport type SendTransactionParams = {\n data?: TransactionDetails;\n operation?: TransactionOperation;\n account?: Account;\n disableLoading?: boolean;\n disableSuccess?: boolean;\n};\n\nexport type NearTransactionParams = {\n transactions: Transaction[];\n account: Account;\n};\n\nexport type SendTransactionFunction = (\n args?: SendTransactionParams,\n) => Promise<SuccessInfo | undefined>;\n\n//FIX ME: IMPROVE TYPES\n/* type SponsoringInfo = {\n sponsorId: string;\n paymasterId: string;\n cost: string;\n fee: string;\n};\nexport type TransactionOperationResult =\n | { error: string }\n | { operation: \"near\" | \"credits\" | \"relay\" }\n | ({ operation: \"sponsor\" } & SponsoringInfo); */\n\nexport type TransactionOperation = {\n operation: Operation;\n sponsorId?: string;\n paymasterId?: string;\n cost?: string;\n fee?: string;\n};\n\nexport interface UrlData {\n successUrl?: string;\n callbackUrl?: string;\n}\n\nexport interface TransactionDetails {\n transactions: Transaction[];\n isDrop?: boolean;\n evmData?: SignRequest;\n}\n\nexport interface TransactionProps {\n operation?: TransactionOperation;\n accountData?: AccountCreationData;\n transactionData?: TransactionDetails;\n urlData?: UrlData;\n agentId?: string;\n}\n\nexport interface TransactionPageProps extends TransactionProps {\n referer: string | null;\n}\n\nexport interface SendTransactionData {\n operation: TransactionOperation;\n account: Account;\n details: TransactionDetails;\n urlData?: UrlData;\n}\n\nexport interface TransactionErrorProps {\n error: string;\n transactions: Transaction[];\n accountId: string;\n urlData?: UrlData;\n}\n\nexport enum Operation {\n NEAR = 'near',\n RELAY = 'relay',\n SPONSOR = 'sponsor',\n}\n\nexport interface Cost {\n deposit: BN;\n gas: BN;\n}\n\n// Define NearReceipt type for transaction results\nexport interface NearReceipt {\n transaction: {\n hash: string;\n };\n [key: string]: unknown;\n}\nexport interface GenerateSuiTxParams {\n transactionBytes?: string;\n recipientAddress?: string;\n senderAddress?: string;\n amountInSui?: number;\n network?: 'mainnet' | 'testnet' | 'devnet';\n}\n\nexport interface GenerateSuiTxResult {\n suiTransactionBytes: string;\n}\n\n// Primitive: get-sui-balances.ts\nexport interface SuiBalancesParams {\n address: string;\n}\n\nexport interface SuiObject {\n objectId: string;\n version: string;\n digest: string;\n type: string;\n owner: {\n AddressOwner: string;\n };\n content: {\n dataType: string;\n type: string;\n hasPublicTransfer: boolean;\n fields: {\n balance: string;\n id: {\n id: string;\n };\n };\n };\n}\n\nexport interface SuiCoin {\n coinType: string;\n coinObjectCount: number;\n totalBalance: string;\n lockedBalance: {\n epochId: number;\n number: string;\n };\n}\n\nexport interface SuiBalance {\n coinType: string;\n balance: string;\n name: string;\n symbol: string;\n iconUrl: string;\n decimals: number;\n usdValue: number;\n}\n\nexport interface SuiBalancesResult {\n balances: SuiBalance[];\n totalUsdValue: number;\n}\n\n// Primitive: sui-lst.ts\nexport interface SuiLstParams {\n address: string;\n amount: string;\n validator: string;\n operation: 'stake' | 'unstake';\n}\n\nexport interface SuiLstResult {\n suiTransactionBytes: string;\n}\n\n// Primitive: aftermath-sui-swap.ts\nexport interface AftermathSwapParams {\n fromCoin: string;\n toCoin: string;\n amount: number;\n slippage?: number;\n address: string;\n}\n\nexport interface AftermathSwapResult {\n suiTransactionBytes: string;\n}\n"]}