/** * Encode a workspace path the way Claude Code names its `~/.claude/projects/` * folders: every `:`, `\`, `/` becomes `-`, and runs of dashes are collapsed. * Note: Claude **keeps the leading dash** that comes from a leading slash on * POSIX paths (e.g. `/home/x/foo` → `-home-x-foo`), so we don't strip `^-`. * Trailing dashes are dropped. */ export declare function claudeProjectFolder(workspacePath: string): string; /** * Compute the `~/.claude/projects/` directory for a workspace, * regardless of whether it already exists. Used when restoring an agent * backup into a new folder: the destination's session traces must land in * the project dir that Claude will look up for that folder. */ export declare function getClaudeProjectDir(workspacePath: string): string; export declare function listClaudeSessionFiles(workspacePath: string): Array<{ name: string; mtime: number; full: string; }>; export declare function listClaudeSessions(workspacePath: string): Array<{ id: string; mtime: number; }>; export declare function findLatestClaudeSession(workspacePath: string): string | undefined; /** * Set the display NAME shown for a Claude session in the `claude --resume` * picker. This Claude version has no dedicated title field — the picker label is * the `display` value in ~/.claude/history.jsonl keyed by sessionId. We APPEND a * fresh entry (never rewrite existing lines, so history can't be corrupted); the * picker surfaces the latest display for the session. */ /** Read the display NAME shown for a claude session in the --resume picker * (latest `display` for this sessionId in ~/.claude/history.jsonl). */ export declare function getClaudeSessionDisplay(sessionId: string): string | undefined; export declare function setClaudeSessionName(sessionId: string, name: string, cwd: string): void; export interface ClaudeGlobalSession { id: string; name: string; cwd: string; updated: number; file: string; msgs: number; } /** ALL claude sessions across every ~/.claude/projects folder (newest first). * Mirrors the app's sessionManager.discover(): skip `agent-` transcripts, * derive cwd from the transcript's own `cwd` (folder-name decode fallback). */ export declare function listAllClaudeSessions(): ClaudeGlobalSession[]; export interface TranscriptMsg { role: 'user' | 'assistant' | 'system' | 'tool'; text: string; ts?: number; } /** * Read a claude session transcript (by id, or an explicit `file`) into a * normalized message array. Reuses the same parse shape the app uses: type * user/assistant/system with tool_use/tool_result rendering. Reads only the * tail of huge transcripts. Returns at most `limit` messages. [] on any miss. */ export declare function readClaudeTranscript(id: string, file?: string, limit?: number): TranscriptMsg[]; export declare function getClaudeSessionCursor(workspacePath: string): number; export interface ClaudeSessionState { /** True if a definitive turn-end was detected. */ hasEndTurn: boolean; /** Human-readable label for the tool currently running, if any. */ activeToolStatus?: string; /** True if a bash_progress or mcp_progress record was seen. */ hasProgress: boolean; /** Set when a rate_limit error is found — contains the raw message text. */ rateLimitMessage?: string; } export declare function parseClaudeStateSince(workspacePath: string, fromByte: number): ClaudeSessionState; /** @deprecated Use parseClaudeStateSince instead. */ export declare function hasClaudeEndTurnSince(workspacePath: string, fromByte: number): boolean; export declare function readClaudeOutputSince(workspacePath: string, fromByte: number): string; /** Build the shell command string for the claude-cli provider. */ export declare function buildClaudeCliCommand(agentProfileFile: string, messageFile: string, sessionId?: string, includeProfile?: boolean, model?: string): string; /** * Run a tiny probe prompt via Node exec to obtain a claude-cli session ID * before the main prompt runs. Extracts "session_id" from --output-format json output. */ export declare function probeClaudeSession(cwd: string, log: (msg: string) => void): Promise; /** * Run `/compact` on an existing Claude session to summarise conversation * history and free up context window space. Used after Claude returns * `prompt is too long: N tokens > MAX maximum` (HTTP 400). Resolves on exit * (success or failure — caller decides what to do). */ export declare function runClaudeCompact(sessionId: string, cwd: string, log: (msg: string) => void): Promise; /** * Run `/clear` on an existing Claude session to wipe the conversation history * and start fresh. Used when autocompact is thrashing (context refills to * limit immediately after compact). Resolves on exit. */ export declare function runClaudeClear(sessionId: string, cwd: string, log: (msg: string) => void): Promise;