import { CompareOp, Plan } from "./plan-types.mjs"; //#region extensions/crypto/src/services/plan-compiler.d.ts interface IntentTrigger { type: 'immediate' | 'at_time' | 'every' | 'when_condition'; /** ISO 8601 time for 'at_time'. */ time?: string; /** Interval string for 'every' (e.g., '4h', '30m', '1d'). */ interval?: string; /** Max runs for recurring triggers. */ maxRuns?: number; /** Condition fields for 'when_condition'. */ token?: string; op?: 'gt' | 'gte' | 'lt' | 'lte' | 'eq' | 'neq'; value?: number; /** Compound condition: AND/OR multiple conditions. */ logic?: 'and' | 'or'; conditions?: IntentTrigger[]; /** Expiry for condition watches (e.g., '24h', '7d'). */ expires?: string; } /** Step type discriminator — 'action' is the default for backward compatibility. */ type IntentStepType = 'action' | 'parallel' | 'wait' | 'loop'; interface IntentStep { /** * Step type. Defaults to 'action' if omitted (backward compatible). * - 'action' — call a tool (swap, transfer, bridge, etc.) * - 'parallel' — run nested steps concurrently * - 'wait' — pause until a condition or duration * - 'loop' — repeat nested steps with exit condition */ type?: IntentStepType; /** The action to perform (required when type is 'action' or omitted). */ action?: 'swap' | 'transfer' | 'bridge' | 'check_price' | 'check_balance' | 'set_order' | 'approve' | 'launch' | 'claim' | 'custom'; tokenIn?: string; tokenOut?: string; amount?: string; amountPct?: number; slippageBps?: number; chainId?: number; to?: string; token?: string; toChain?: number; fromChain?: number; orderType?: string; triggerPrice?: number; tool?: string; params?: Record; /** If provided, makes this step conditional. */ condition?: { token?: string; field?: 'price' | 'balance' | 'gas_price'; op: CompareOp; value: number; }; /** If true, require user confirmation before this step. */ confirm?: boolean; /** Failure policy for this step. */ onFailure?: 'abort' | 'skip' | 'retry'; retryCount?: number; /** Delay between retries in ms. Default: 5000. */ retryDelayMs?: number; /** Backoff multiplier for exponential retry delay. Default: 2. */ backoffMultiplier?: number; /** Fallback steps to execute if this step fails after all retries. */ onError?: IntentStep[]; /** Label override. */ label?: string; /** Assign a ref name to this step's output so downstream steps can reference it. */ outputRef?: string; /** Map param names to "refName.path" strings referencing prior step outputs. */ inputRefs?: Record; /** Nested steps for 'parallel' and 'loop' types. */ steps?: IntentStep[]; /** Whether to continue if some parallel steps fail (default false). */ allowPartialFailure?: boolean; /** Duration string for 'wait' type (e.g., "30s", "5m", "1h"). */ duration?: string; /** ISO 8601 time to wait until. */ untilTime?: string; /** Condition to wait for (same format as step condition). */ until?: { token?: string; field?: 'price' | 'balance' | 'gas_price'; op: CompareOp; value: number; }; /** Max wait time for condition waits (e.g., "24h"). Default: 24h. */ maxWait?: string; /** Poll interval for condition waits (e.g., "1m"). Default: 1m. */ pollInterval?: string; /** Exit condition for 'loop' type. */ exitWhen?: { token?: string; field?: 'price' | 'balance' | 'gas_price'; op: CompareOp; value: number; }; /** Max iterations for 'loop' type (default 10). */ maxIterations?: number; /** Delay between loop iterations (e.g., "5s"). */ delayBetween?: string; } interface Intent { /** Human-readable name for the plan. */ name?: string; /** The original natural language request. */ naturalLanguage: string; /** When to start execution. */ trigger?: IntentTrigger; /** Steps to execute (in order). */ steps: IntentStep[]; /** Tags for organization. */ tags?: string[]; } declare class PlanCompiler { private idCounter; /** Maps outputRef names to generated node IDs for step_output resolution. */ private outputRefToId; /** * Compile an intent into a Plan IR. * Throws CompilationError on invalid intents. */ compile(intent: Intent, userId: string): Plan; private compileTrigger; private buildPriceCondition; private compileNode; private compileAction; private compileParallel; private compileWait; private compileLoop; private buildStepCondition; private compileFailurePolicy; /** Compile onError fallback steps into a PlanNode sub-tree. */ private compileOnError; private nextId; private inferName; } declare class CompilationError extends Error { constructor(message: string); } /** * Parse human-readable intervals to milliseconds. * Supports: 30s, 5m, 4h, 1d, 2w */ declare function parseIntervalToMs(input: string): number; //#endregion export { CompilationError, Intent, IntentStep, IntentStepType, IntentTrigger, PlanCompiler, parseIntervalToMs }; //# sourceMappingURL=plan-compiler.d.mts.map