/** * Plain-text / markdown session formatting for `/dump` and `/advisor dump raw`. * * Renders a prelude (system prompt, model/thinking config, tool inventory) * followed by the message history as per-message markdown headings: `## User`, * `## Assistant` (with `` blocks and `### Tool Call: ` + YAML * args), `### Tool Result: `, and the execution/summary sections. * `/dump all` renders each persisted subagent as its own `# Subagent: ` document. */ import type { AgentMessage, ThinkingLevel } from "@oh-my-pi/pi-agent-core"; import type { Model, ToolExample } from "@oh-my-pi/pi-ai"; /** Minimal tool shape for dump output (matches AgentTool fields used by formatSessionDumpText). */ export interface SessionDumpToolInfo { name: string; description: string; parameters: unknown; examples?: readonly ToolExample[]; } /** Runtime state of a subagent that is still live in this process when `/dump all` runs. */ export interface SessionDumpLiveState { /** Registry status at capture time (`running`, `idle`, …). */ status: string; /** Wall-clock time the snapshot was taken (ms since epoch). */ capturedAt: number; /** Last registry heartbeat (tool call, intent, status change). */ lastActivity: number; /** Latest activity gist shown in the agent roster. */ activity?: string; /** An agent turn is active: a model request, tool execution, or the work between them. */ busy: boolean; /** Partial assistant message still streaming; not yet in the persisted transcript. */ streamMessage?: AgentMessage | null; /** Tool calls dispatched but not yet finished, as `name (id)`. */ pendingToolCalls: readonly string[]; } /** A persisted subagent transcript rendered as its own `/dump all` document. */ export interface SessionDumpSubagent { /** Slash-joined agent path relative to the main session, e.g. "Explore/Helper". */ key: string; messages: readonly AgentMessage[]; /** Persisted default-role model string ("provider/id"). */ model?: string; thinkingLevel?: string; /** The subagent was explicitly killed before finishing. */ aborted?: boolean; /** Present when the subagent is still live in this process. */ live?: SessionDumpLiveState; } export interface FormatSessionDumpTextOptions { messages: readonly AgentMessage[]; systemPrompt?: readonly string[] | null; model?: Model | null; thinkingLevel?: ThinkingLevel | string | null; tools?: readonly SessionDumpToolInfo[]; inlineToolDescriptors?: boolean; } /** * Format messages and session metadata as markdown/plain text (same as * AgentSession.formatSessionAsText / /dump). */ export declare function formatSessionDumpText(options: FormatSessionDumpTextOptions): string; /** * Format one persisted subagent transcript. Subagent system prompts and tool * inventories are not persisted, so the header carries only model, thinking * level, whether the agent was killed, and — for agents still live in this * process — their runtime state plus the unpersisted in-flight turn. */ export declare function formatSubagentDumpText(subagent: SessionDumpSubagent): string; /** Result of writing a `/dump all` or `/dump anon` zip (see `AgentSession.dumpSessionArchiveToTmpDir`). */ export interface SessionDumpArchive { path: string; /** Archive member names in write order. */ files: string[]; subagentCount: number; /** Why subagent discovery failed; the main dump is archived regardless. */ subagentError?: string; /** Members are anonymized session JSONL (`/dump anon`), not raw transcripts. */ anonymized?: boolean; /** `[member, count]` for transcripts whose malformed JSONL records were skipped. */ malformed?: ReadonlyArray; /** Subagent transcripts skipped because no session header could be read. */ unreadable?: readonly string[]; } /** Lines describing a `/dump all` archive: path, members, and any subagent discovery failure. */ export declare function formatDumpArchiveReport(archive: SessionDumpArchive): string[];