import { RuntimeAgentService, type McpConfigResult } from './runtime-agent.service.abstract.js'; import { SessionCommandHelper } from '../session/index.js'; import { type RuntimeType } from '../../constants.js'; /** * Claude Code specific runtime service implementation. * Handles Claude Code CLI initialization, detection, and interaction patterns. */ export declare class ClaudeRuntimeService extends RuntimeAgentService { constructor(sessionHelper: SessionCommandHelper, projectRoot: string); protected getRuntimeType(): RuntimeType; /** * Claude Code specific detection using slash command */ protected detectRuntimeSpecific(sessionName: string): Promise; /** * Fail fast when Crewly runs as root: Claude Code refuses * --dangerously-skip-permissions under root/sudo, which Crewly always * passes, so the agent would never launch and start-up would hang until * every timeout expired. IS_SANDBOX=1 is Claude's own "sandboxed" switch * that allows the flag as root (containers), so root is fine then. * * @throws RuntimeStartupBlockedError (reason `root_user`) when running as root */ assertCanLaunch(): void; /** * Refuse to launch Claude Code in a state it cannot start from (root), then * run the normal initialization script. * * @throws RuntimeStartupBlockedError when running as root without IS_SANDBOX=1 */ executeRuntimeInitScript(sessionName: string, targetPath?: string, runtimeFlags?: string[], promptFilePath?: string, agentName?: string, resumeSessionId?: string): Promise; /** * Classify terminal output that means Claude Code cannot become ready * without the user: the root refusal, the first-run theme picker, or a * shell that cannot find `claude`. * * @param output - Terminal output text * @returns The blocking error to throw, or null */ private detectStartupBlocked; /** * Detect the Claude Code workspace trust prompt in terminal output. * * Claude Code shows "Is this a project you trust?" on first launch * for untrusted workspaces. This blocks agent initialization. * * @param output - Terminal output text * @returns True if trust prompt is detected * @see https://github.com/stevehuang0115/crewly/issues/144 */ private isClaudeTrustPrompt; /** * Override waitForRuntimeReady to auto-accept workspace trust prompt (#144). * * Claude Code shows an interactive trust gate on first launch for * untrusted workspaces. Without auto-acceptance, the agent hangs * and enters a crash-restart loop. * * States the user must resolve (root refusal, first-run theme picker) are * detected before the ready patterns and fail fast. * * @throws RuntimeStartupBlockedError when start-up is blocked on the user */ waitForRuntimeReady(sessionName: string, timeout: number, checkInterval?: number): Promise; /** * Claude Code specific ready patterns */ protected getRuntimeReadyPatterns(): string[]; /** * Claude Code's sign-in screen shows a prompt-like box, so the login * instructions veto readiness until the user has authenticated. * * @returns Claude Code-specific "not ready" markers */ protected getNotReadyMarkers(): readonly string[]; /** * Claude Code specific exit patterns for runtime exit detection. * * Includes both clean exit patterns (e.g. "Claude Code exited") and * fatal error patterns that indicate the CLI is stuck in an unrecoverable * state (e.g. thinking block corruption). * * @returns Array of RegExp patterns that match runtime exit or fatal output */ protected getRuntimeExitPatterns(): RegExp[]; /** * Claude Code specific error patterns */ protected getRuntimeErrorPatterns(): string[]; /** * Check if Claude Code CLI is installed on the system */ checkClaudeInstallation(): Promise<{ installed: boolean; version?: string; message: string; }>; /** * Initialize Claude in an existing session (legacy compatibility) */ initializeClaudeInSession(sessionName: string): Promise<{ success: boolean; message?: string; error?: string; }>; /** * Enhanced Claude detection using slash command with detailed analysis * This is the legacy method that provides more detailed detection than the base detectRuntimeSpecific */ detectClaudeWithSlashCommand(sessionName: string, forceRefresh?: boolean): Promise; /** * Execute Claude initialization script (legacy compatibility) */ executeClaudeInitScript(sessionName: string, targetPath?: string): Promise; /** * Post-initialization hook for Claude Code. * Ensures MCP server configuration (e.g., playwright) is present in the project directory. * * @param sessionName - PTY session name * @param targetProjectPath - Optional target project path for MCP config. * Falls back to this.projectRoot if not provided. */ postInitialize(sessionName: string, targetProjectPath?: string, _additionalAllowlistPaths?: string[], browserAutomationOverride?: boolean): Promise; /** * Ensure Claude Code MCP server configuration exists in the project directory. * * Creates or merges `.mcp.json` with required MCP servers. * Delegates to the shared `ensureMcpConfig` in the base class. * * @param projectPath - Project directory where `.mcp.json` will be created * @returns Result of the MCP config operation */ ensureClaudeMcpConfig(projectPath: string, browserAutomationOverride?: boolean): Promise; } //# sourceMappingURL=claude-runtime.service.d.ts.map