import { type QueuedMessage } from "./managers/messageQueue.js"; import { SlashCommand, CustomSlashCommand, AgentOptions } from "./types/index.js"; import type { Message, McpServerStatus, GatewayConfig, ModelConfig, Usage, PermissionMode, ForegroundTask } from "./types/index.js"; import type { WorktreeSession } from "./utils/worktreeSession.js"; export declare class Agent { private messageManager; private aiManager; private bangManager; private backgroundTaskManager; private logger?; private toolManager; private mcpManager; private lspManager; private permissionManager; private planManager; private subagentManager; private forkedAgentManager; private slashCommandManager; private pluginManager; private skillManager; private cronManager; private goalManager; private hookManager; private reversionManager; private messageQueue; private dispatchPromise; private memoryRuleManager; private liveConfigManager; private taskManager; private foregroundTaskManager; private container; private configurationService; private workdir; private systemPrompt?; private stream; private sessionStartTime; private options; getGatewayConfig(): GatewayConfig; getModelConfig(): ModelConfig; getMaxInputTokens(): number; getLanguage(): string | undefined; /** * Set the active model for the agent session * @param model - The ID of the model to use */ setModel(model: string): void; /** * Get all configured models from settings.json and defaults * @returns Array of model IDs */ getConfiguredModels(): string[]; /** * Agent constructor - handles configuration resolution and validation * * IMPORTANT: This constructor is private. Use Agent.create() instead for proper * async initialization. Keep this constructor's signature exactly the same as * Agent.create() to maintain API consistency. * * @param options - Configuration options for the Agent instance */ private constructor(); get sessionId(): string; get messages(): Message[]; get usages(): Usage[]; get sessionFilePath(): string; get latestTotalTokens(): number; /** Get working directory */ get workingDirectory(): string; /** * Set the working directory * @param newCwd - The new working directory */ setWorkdir(newCwd: string): void; /** * Set this session's worktree session state (used by CLI -w startup to inject the * session created before the agent existed). Delegates to AIManager so the state is * stored in this agent's own DI container. */ setWorktreeSession(session: WorktreeSession | null): void; /** Get project memory content */ get projectMemory(): string; /** Get user memory content */ get userMemory(): string; /** Get combined memory content (project + user + modular rules) */ getCombinedMemory(): Promise; /** Get AI loading status */ get isLoading(): boolean; /** Get message compaction status */ get isCompacting(): boolean; /** Get bash command execution status */ get isCommandRunning(): boolean; /** Get queued user-facing messages (excludes background notifications) */ get queuedMessages(): QueuedMessage[]; /** Get goal status string */ get goalStatus(): string; /** Check if a goal is active */ get isGoalActive(): boolean; /** * Remove a queued message by index * @param index - The index of the message to remove * @returns true if the message was removed, false if the index was out of bounds */ removeQueuedMessage(index: number): boolean; /** * Recall the last editable queued message (for inline editing) * @returns The recalled message, or null if no editable message exists */ recallQueuedMessage(): QueuedMessage | null; /** * Remove a queued message by its ID * @param id - The ID of the message to remove * @returns true if the message was removed, false if not found */ removeQueuedMessageById(id: string): boolean; /** * Update a queued message's content by its ID (does not change queue order) * @param id - The ID of the message to update * @param patch - The fields to update * @returns true if the message was updated, false if not found */ updateQueuedMessageById(id: string, patch: { content?: string; images?: Array<{ path: string; mimeType: string; }>; type?: "message" | "bang"; }): boolean; /** * Unified dispatch trigger — checks state machine before processing. * Handles user messages, bang commands, and background task notifications * through a single serialized path. Called from onMessageEnqueued, * onLoadingChange(false), and onCommandRunningChange(false). */ private tryDispatch; /** * Process the next queued item when the agent becomes idle. * Handles three item types: user messages, bang commands, and notifications. */ private processQueuedMessage; /** Get background bash shell output */ getBackgroundShellOutput(id: string, filter?: string): { stdout: string; stderr: string; status: string; outputPath?: string; type: string; exitCode?: number; } | null; /** Kill background bash shell */ killBackgroundShell(id: string): boolean; /** Get background task output */ getBackgroundTaskOutput(id: string, filter?: string): { stdout: string; stderr: string; status: string; outputPath?: string; type: string; exitCode?: number; } | null; /** Stop background task */ stopBackgroundTask(id: string): boolean; /** Get all workflow runs */ getWorkflowRuns(): Promise; /** Get a specific workflow run by ID */ getWorkflowRun(runId: string): import("./workflow/types.js").WorkflowRun | undefined; /** Stop a workflow run */ stopWorkflowRun(runId: string): void; /** * Static async factory method for creating Agent instances * * IMPORTANT: Keep this method's signature exactly the same as the constructor * to maintain consistency and avoid confusion for users of the API. * * @param options - Same AgentOptions interface used by constructor * @returns Promise - Fully initialized Agent instance */ /** * Create a new Agent instance with async initialization * * This is the recommended way to create Agent instances. The constructor is private * to ensure proper async initialization of all components. * * @param options - Configuration options for the Agent instance * @param options.apiKey - API key for the AI service (or set WAVE_API_KEY env var) * @param options.baseURL - Base URL for the AI service (or set WAVE_BASE_URL env var) * @param options.defaultHeaders - Optional HTTP headers to pass to the AI service * @param options.fetchOptions - Optional fetch options to pass to the AI service * @param options.fetch - Optional custom fetch implementation * @param options.callbacks - Optional callbacks for various Agent events * @param options.restoreSessionId - Optional session ID to restore from * @param options.continueLastSession - Whether to continue the last session automatically * @param options.logger - Optional custom logger implementation * @param options.messages - Optional initial messages for testing convenience * @param options.workdir - Working directory (defaults to process.cwd()) * @param options.systemPrompt - Optional custom system prompt * @param options.mcpServers - Optional MCP server configs to connect at startup * @returns Promise that resolves to initialized Agent instance * * @example * ```typescript * // Basic usage * const agent = await Agent.create({ * apiKey: 'your-api-key', * baseURL: 'https://api.example.com' * }); * ``` */ static create(options: AgentOptions): Promise; /** * Resolve and validate configuration from constructor args, environment variables, * and loaded settings.json. * * This is called during initialization after settings.json has been loaded. */ private resolveAndValidateConfig; /** Private initialization method, handles async initialization logic */ private initialize; /** * Restore a session by ID, switching to the target session without destroying the Agent instance * @param sessionId - The ID of the session to restore */ restoreSession(sessionId: string): Promise; abortAIMessage(): void; /** Execute bash command (bang command) */ bang(command: string): Promise; clearMessages(): Promise; /** * Compact conversation history to reduce context usage * @param customInstructions - Optional custom instructions for compaction */ compact(customInstructions?: string): Promise; /** * Set an autonomous goal for the session * @param condition - The goal condition to achieve */ setGoal(condition: string): Promise; /** * Clear the current autonomous goal */ clearGoal(): Promise; /** * Show the current goal status */ showGoalStatus(): Promise; /** Unified interrupt method, interrupts both AI messages and command execution */ abortMessage(): void; /** Interrupt bash command execution */ abortBashCommand(): void; /** Interrupt slash command execution */ abortSlashCommand(): void; /** * Register a foreground task that can be backgrounded */ registerForegroundTask(task: ForegroundTask): void; /** * Unregister a foreground task */ unregisterForegroundTask(id: string): void; /** * Background the current foreground task */ backgroundCurrentTask(): Promise; /** * Trigger WorktreeRemove hook before agent destruction. * Called from CLI exit dialog when user chooses to remove the worktree. * Non-blocking: errors logged but don't prevent removal. */ triggerWorktreeRemoveHook(worktreePath: string): Promise; /** Destroy managers, clean up resources */ destroy(): Promise; /** * Trigger the rewind UI callback */ triggerShowRewind(): void; /** * Ask a side question without tool use * @param question - The side question to ask * @returns Promise that resolves to the AI's answer */ askBtw(question: string): Promise; /** * Send a message to the AI agent with optional images * * @param content - The text content of the message to send * @param images - Optional array of images to include with the message * @param images[].path - File path to the image or base64 encoded image data * @param images[].mimeType - MIME type of the image (e.g., 'image/png', 'image/jpeg') * @returns Promise that resolves when the message has been processed * * @example * ```typescript * // Send a text message * await agent.sendMessage("Hello, how are you?"); * * // Send a message with images using file paths * await agent.sendMessage("What do you see in these images?", [ * { path: "/path/to/image.png", mimeType: "image/png" }, * { path: "/path/to/photo.jpg", mimeType: "image/jpeg" } * ]); * * // Send a message with base64 encoded image * await agent.sendMessage("Analyze this image", [ * { path: "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAA...", mimeType: "image/png" } * ]); * ``` */ sendMessage(content: string, images?: Array<{ path: string; mimeType: string; }>): Promise; /** Get all MCP server status */ getMcpServers(): McpServerStatus[]; /** Connect MCP server */ connectMcpServer(serverName: string): Promise; /** Disconnect MCP server */ disconnectMcpServer(serverName: string): Promise; /** Get all available slash commands */ getSlashCommands(): SlashCommand[]; /** Check if slash command exists */ hasSlashCommand(commandId: string): boolean; /** Reload custom commands */ reloadCustomCommands(): Promise; /** Get custom command details */ getCustomCommand(commandId: string): CustomSlashCommand | undefined; /** Get all custom commands */ getCustomCommands(): CustomSlashCommand[]; /** * Register a custom slash command */ registerSlashCommand(command: SlashCommand): void; /** * Get the current permission mode */ getPermissionMode(): PermissionMode; /** * Get the names of tools currently visible to the AI model (filtered by * permission mode, denied rules, etc.) */ getAvailableToolNames(): string[]; /** * Set the permission mode * @param mode - The new permission mode */ setPermissionMode(mode: PermissionMode): void; /** * Truncate history to a specific index and revert file changes. * @param index - The index of the user message to truncate to. */ truncateHistory(index: number): Promise; /** * Get the full message thread including parent sessions */ getFullMessageThread(): Promise<{ messages: Message[]; sessionIds: string[]; }>; /** * Get the current plan file path (for testing and UI) */ getPlanFilePath(): string | undefined; /** * Get all currently allowed rules (user-defined and default) */ getAllowedRules(): string[]; /** * Get only user-defined allowed rules */ getUserAllowedRules(): string[]; /** * Check permission for a tool call (for testing) */ checkPermission(context: import("./types/permissions.js").ToolPermissionContext): Promise; /** * Add a persistent permission rule * @param rule - The rule to add (e.g., "Bash(ls)") */ addPermissionRule(rule: string): Promise; /** * Get subagent instance by ID * @param subagentId - The ID of the subagent instance * @returns The subagent instance or null if not found */ getSubagentInstance(subagentId: string): import("./managers/subagentManager.js").SubagentInstance | null; /** * Get the current task list ID */ get taskListId(): string; /** * Check if there are any running background tasks or active subagents */ get hasRunningBackgroundWork(): boolean; }