/** * Core types for the Clawtomaton runtime */ import type { Address, Hash } from 'viem'; import type { BunkerConfig } from './bunker/types.js'; export interface ClawtomatonIdentity { /** Agent name */ name: string; /** Ethereum wallet address (agent's on-chain identity) */ address: Address; /** Private key (stored encrypted in state) */ privateKey: `0x${string}`; /** Clawncher API key (from registration) */ apiKey: string; /** Creator's wallet address (has audit rights) */ creatorAddress: Address; /** Genesis prompt — the seed instruction */ genesisPrompt: string; /** Token address once deployed */ tokenAddress?: Address; /** Token symbol */ tokenSymbol?: string; /** Deploy tx hash */ deployTxHash?: Hash; } export type SurvivalTier = 'normal' | 'low_compute' | 'critical' | 'dead'; export interface SurvivalState { tier: SurvivalTier; ethBalance: bigint; /** Accumulated fees available to claim (WETH) */ unclaimedFees: bigint; /** Total fees claimed lifetime */ totalFeesClaimed: bigint; /** Timestamp of last fee claim */ lastFeeClaim: number; /** Timestamp of last balance check */ lastBalanceCheck: number; } export declare const SURVIVAL_THRESHOLDS: { /** Above this: full capabilities */ readonly normal: bigint; /** Above this: reduced capabilities */ readonly low_compute: bigint; /** Above this: emergency mode */ readonly critical: bigint; }; /** * Get survival thresholds, with optional overrides from autonomy config. */ export declare function getSurvivalThresholds(autonomy?: AutonomyConfig): typeof SURVIVAL_THRESHOLDS; export interface AgentContext { identity: ClawtomatonIdentity; survival: SurvivalState; /** Current turn number */ turn: number; /** Conversation history (last N turns) */ history: ConversationTurn[]; /** SOUL.md content — self-authored identity */ soul: string; /** Available skills */ skills: SkillDefinition[]; /** Constitution text */ constitution: string; /** * State store for skills that need persistence (orders, etc). * Provided by the agent runtime — skills should NOT create their own. * Optional for backward compat with tests that build AgentContext manually. */ stateStore?: import('./state/index.js').StateStore; /** * XMTP client for encrypted messaging. * Provided by the agent runtime when XMTP is configured. * Optional — agents work without XMTP. */ xmtpClient?: import('./xmtp/client.js').XmtpClient; } export interface ConversationTurn { role: 'system' | 'assistant' | 'tool'; content: string; timestamp: number; /** Tool calls made this turn */ toolCalls?: ToolCall[]; /** Tool results received this turn */ toolResults?: ToolResult[]; } export interface ToolCall { id: string; skill: string; params: Record; } export interface ToolResult { callId: string; success: boolean; result: unknown; error?: string; /** Structured data for agent-side persistence (avoids regex-parsing freeform text). */ metadata?: Record; } export interface SkillDefinition { name: string; description: string; parameters: SkillParameter[]; execute: (params: Record, ctx: AgentContext) => Promise; } export interface SkillParameter { name: string; type: 'string' | 'number' | 'boolean' | 'address'; description: string; required: boolean; default?: unknown; } export interface HeartbeatTask { name: string; /** Interval in milliseconds */ intervalMs: number; /** Last execution timestamp */ lastRun: number; /** Whether task is enabled */ enabled: boolean; execute: (ctx: AgentContext) => Promise; } export interface ClawtomatonConfig { /** Inference provider */ inference: { provider: 'openrouter' | 'anthropic' | 'conway'; apiKey: string; model: string; /** Cheaper model for low_compute tier */ fallbackModel: string; }; /** Base RPC URL */ rpcUrl: string; /** State directory */ stateDir: string; /** Heartbeat interval in ms (normal tier) */ heartbeatIntervalMs: number; /** Max conversation history turns to keep in context */ maxHistoryTurns: number; /** Conway Terminal API key (optional — for domains, VMs) */ conwayApiKey?: string; /** MoltBunker deployment config (optional — for decentralized hosting) */ bunker?: BunkerConfig; /** XMTP encrypted messaging config (optional — for Base App / World App discovery) */ xmtp?: import('./xmtp/types.js').XmtpConfig; /** Autonomous earning config (optional — all features off by default) */ autonomy?: AutonomyConfig; } /** * Full autonomy configuration — controls every tunable behavior. * * Organized into groups: * - cost: Gas tracking, inference cost estimates * - heartbeat: Intervals, throttling, wake conditions * - survival: Tier thresholds, claim policy * - trading: Trade recording, risk defaults, order execution * - reserves: ETH/USDC reserve targets, idle capital detection * - yield: Wayfinder integration, LP deployment * - services: Paid XMTP services (Phase 3) * - agentLoop: Turns per run, tool calls per turn * * Every field is optional. Omit to use defaults. Set to `false` to disable. */ export interface AutonomyConfig { /** * Gas cost tracking — records tx receipts after every skill execution. * Default: true (when autonomy config is present) */ gasTracking?: boolean; /** * Estimated cost of one LLM inference call in wei. * Used for net P&L calculations. Adjust for your model/provider. * Default: 200000000000000 (0.0002 ETH ≈ $0.50) */ inferenceCostWei?: string; /** * Earning-adjusted heartbeat throttle. * When rolling net earnings are negative, heartbeat interval is multiplied. * Default: true (uses default tiers) */ earningThrottle?: boolean | { /** Rolling window for net earnings calculation in ms (default: 7 days) */ windowMs?: number; /** Loss tiers, checked from most severe to least. */ tiers?: Array<{ lossThresholdEth: number; multiplier: number; }>; }; /** * Analytics-driven heartbeat wake condition. * Wakes agent on strong signals from ClawnchAnalytics. * Default: false (opt-in) */ analyticsWake?: boolean | { /** Minimum interval between analytics checks in ms (default: 1 hour) */ intervalMs?: number; /** Which signals trigger a wake (default: ['strong_buy', 'strong_sell']) */ signals?: Array<'strong_buy' | 'buy' | 'neutral' | 'sell' | 'strong_sell'>; /** Number of blocks to scan for swap events (default: 10000, ~5.5h on Base) */ blocksToScan?: number; /** Candle interval for analysis (default: '15m') */ candleInterval?: '5m' | '15m' | '1h' | '4h' | '1d'; /** Minimum candles required (default: 50) */ minCandles?: number; }; /** * Minimum time between agent runs in ms, regardless of wake conditions. * The earning throttle multiplies this value when losing money. * Default: 300000 (5 minutes) */ minRunIntervalMs?: number; /** * How often to run a self-reflection cycle in ms. * Default: 86400000 (24 hours) */ reflectionIntervalMs?: number; /** * Override survival tier thresholds (in wei). * Controls which skills are available at each ETH balance level. */ survivalThresholds?: { /** ETH balance for full capabilities (default: 10000000000000000 = 0.01 ETH) */ normalWei?: string; /** ETH balance for reduced capabilities (default: 1000000000000000 = 0.001 ETH) */ lowComputeWei?: string; /** ETH balance for emergency mode (default: 100000000000000 = 0.0001 ETH) */ criticalWei?: string; }; /** * Fee claiming policy. */ claiming?: { /** * Minimum net profit in wei to justify claiming fees. * Claim cost = gas for 3 txs. Profit must exceed this + claim cost. * Default: 500000000000000 (0.0005 ETH ≈ $1.25) */ minProfitWei?: string; /** * Auto-suggest claiming when unclaimed WETH exceeds this amount in wei. * The agent still decides — this adds guidance to the prompt. * Default: disabled (null) */ suggestClaimAboveWei?: string; /** * Maximum hours between fee claims, even if not yet profitable. * Prevents fees from sitting unclaimed indefinitely during low-gas periods. * Default: disabled (null — only claim when profitable or survival-needed) */ maxHoursBetweenClaims?: number; }; /** * Automatic trade recording for swap executions. * Records buys/sells in the portfolio tracker when swap/uniswap_swap succeeds. * Default: true */ tradeRecording?: boolean; /** * Portfolio snapshot recording on each heartbeat wake. * Feeds performance history and drawdown tracking. * Default: true */ portfolioSnapshots?: boolean; /** * Default risk management parameters. * Applied when no risk config is stored yet. Agent can override via manage_orders. */ riskDefaults?: { /** Max % of portfolio for a single position (default: 25) */ maxPositionPct?: number; /** Max drawdown % before circuit breaker trips (default: 30) */ maxDrawdownPct?: number; /** Cooldown after failed execution in ms (default: 300000 = 5 min) */ failureCooldownMs?: number; /** Max order executions per hour (default: 10) */ maxExecutionsPerHour?: number; }; /** * Maximum ReAct turns per agent run before forcing stop. * Default: 20 */ maxTurnsPerRun?: number; /** * Maximum tool calls per single turn. * Default: 5 */ maxToolCallsPerTurn?: number; /** * How often to refresh survival + market data during a run (in turns). * Default: 5 */ survivalRefreshInterval?: number; /** * Reserve management — prompt-driven ETH/stablecoin reserve targets. * When enabled, the agent sees reserve status in its prompt and gets * suggestions to rebalance when reserves are low. * Default: disabled */ reserves?: { /** * Target ETH reserve in wei. The agent tries to maintain at least this much. * Below this, the prompt suggests converting other assets to ETH. * Tip: set to ~30 days of operational costs. */ targetEthWei?: string; /** * USDC token address on Base. * Default: 0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913 (Base USDC) */ usdcAddress?: string; /** * Target USDC reserve in human-readable units (e.g. "500" for $500). * When USDC balance drops below this and ETH is abundant, * the prompt suggests converting some ETH to USDC as a stablecoin hedge. * Default: disabled (null) */ targetUsdc?: string; /** * Operational cost estimate per day in ETH. * Used to calculate "days of runway" for reserve warnings. * Default: 0.01 ETH (gas + inference for ~48 calls/day) */ dailyCostEth?: number; }; /** * Idle capital detection and yield deployment. * When ETH balance exceeds operational reserve + this threshold, * the heartbeat suggests deploying surplus to yield via Wayfinder. * Default: disabled */ idleCapital?: { /** * ETH above (reserve + threshold) is considered idle. * Default: 0.05 ETH */ thresholdEth?: number; /** * Minimum yield APY to consider a pool worth deploying to. * Default: 2.0 (2%) */ minYieldApy?: number; /** * Protocols to consider for yield (Wayfinder pool filter). * Default: ['aave', 'moonwell', 'morpho'] */ protocols?: string[]; /** * Maximum % of idle capital to deploy in a single action. * Default: 50 */ maxDeployPct?: number; }; /** * Wayfinder Paths integration for cross-chain DeFi. * Requires WAYFINDER_API_KEY env var or explicit key here. */ wayfinder?: { /** API key (overrides WAYFINDER_API_KEY env var) */ apiKey?: string; /** Enable CLI tier (requires Python 3.12+). Default: false */ cliTier?: boolean; /** Chains to operate on. Default: ['base'] */ chains?: string[]; }; /** * Paid services via XMTP messaging. * Users pay ETH to the agent's wallet, then request services via XMTP. * Payment verification uses on-chain tx receipts. * Default: disabled */ paidServices?: { /** Enable the paid services skill. Default: false */ enabled?: boolean; /** * Service catalog with pricing in ETH. * The agent advertises these and verifies payment before executing. */ catalog?: Array<{ /** Service identifier (e.g. 'token_analysis') */ id: string; /** Human-readable name */ name: string; /** Description shown to users */ description: string; /** Price in ETH (e.g. '0.001') */ priceEth: string; /** Skill to execute after payment verification */ skill: string; /** Default params for the skill */ defaultParams?: Record; }>; /** * Payment verification window in ms. * How far back to search for a matching payment tx. * Default: 3600000 (1 hour) */ paymentWindowMs?: number; /** * Minimum payment confirmation blocks. * Default: 5 */ minConfirmations?: number; }; } export interface ActivationResult { burnTxHash: Hash; amountBurned: bigint; activatedAt: number; } /** 1,000,000 $CLAWNCH with 18 decimals */ export declare const CLAWTOMATON_ACTIVATION_COST: bigint; export declare const CLAWNCH_TOKEN_ADDRESS: Address; export declare const CLAWNCH_BURN_ADDRESS: Address; //# sourceMappingURL=types.d.ts.map