/** * Shared agent interface for WorkOS wizards * Uses Claude Agent SDK directly with WorkOS MCP server */ import type { InstallerOptions } from '../utils/types.js'; import type { InstallerEventEmitter } from './events.js'; import { type CredentialProxyHandle } from './credential-proxy.js'; import type { SDKMessage, Options as AgentSDKOptions, PermissionResult } from '@anthropic-ai/claude-agent-sdk'; export declare const AgentSignals: { /** Signal emitted when the agent reports progress to the user */ readonly STATUS: "[STATUS]"; /** Signal emitted when the agent cannot access the WorkOS MCP server */ readonly ERROR_MCP_MISSING: "[ERROR-MCP-MISSING]"; /** Signal emitted when the agent cannot access the setup resource */ readonly ERROR_RESOURCE_MISSING: "[ERROR-RESOURCE-MISSING]"; }; export type AgentSignal = (typeof AgentSignals)[keyof typeof AgentSignals]; /** * Error types that can be returned from agent execution. * These correspond to the error signals that the agent emits. */ export declare enum AgentErrorType { /** Agent could not access the WorkOS MCP server */ MCP_MISSING = "INSTALLER_MCP_MISSING", /** Agent could not access the setup resource */ RESOURCE_MISSING = "INSTALLER_RESOURCE_MISSING", /** Agent execution failed (API error, auth error, etc.) */ EXECUTION_ERROR = "INSTALLER_EXECUTION_ERROR", /** AI service is unavailable (API 500, outage, etc.) */ SERVICE_UNAVAILABLE = "INSTALLER_SERVICE_UNAVAILABLE" } export type AgentConfig = { workingDirectory: string; workOSApiKey: string; workOSApiHost: string; }; export interface RetryConfig { /** Max correction attempts after initial run. Default: 2 */ maxRetries: number; /** Run between agent turns. Return null if passed, or error prompt if failed. */ validateAndFormat: (workingDirectory: string) => Promise; } /** * Configuration object for running the agent. * Built by initializeAgent (production) or constructed directly (evals). */ export type AgentRunConfig = { workingDirectory: string; mcpServers: AgentSDKOptions['mcpServers']; model: string; allowedTools: string[]; sdkEnv: Record; }; /** * Permission hook that allows only safe commands. * - Package manager install commands * - Build/typecheck/lint commands for verification * - Piping to tail/head for output limiting is allowed * - Stderr redirection (2>&1) is allowed */ export declare function installerCanUseTool(toolName: string, input: Record): PermissionResult; /** * Initialize agent configuration for the LLM gateway */ export declare function initializeAgent(config: AgentConfig, options: InstallerOptions): Promise; /** * Execute an agent with the provided prompt and options * Handles the full lifecycle via event emissions - adapters handle UI rendering. * * @returns An object containing any error detected in the agent's output */ export declare function runAgent(agentConfig: AgentRunConfig, prompt: string, options: InstallerOptions, config?: { spinnerMessage?: string; successMessage?: string; errorMessage?: string; }, emitter?: InstallerEventEmitter, retryConfig?: RetryConfig, onMessage?: (message: SDKMessage) => void): Promise<{ error?: AgentErrorType; errorMessage?: string; retryCount?: number; }>; /** * Get the active proxy handle (for testing/debugging). */ export declare function getActiveProxyHandle(): CredentialProxyHandle | null;