/** * Sub-agent transcript archiving (SubagentStop hook). * * Claude Code purges `~/.claude/projects` transcripts after a retention window, * so the Agent Insights history would silently evaporate. When a sub-agent * finishes, the hook copies its raw transcript (gzipped) plus meta into a * project-local archive the CLI can read long after the source is gone: * * /.claude/grimoire/sessions/// * agent-.jsonl.gz * agent-.meta.json * * Everything here is fail-silent (same contract as writeLog): hooks must never * throw, block, or emit stderr. */ import type { SubagentHookInput } from './types.js'; /** * Claude Code encodes the project cwd by replacing `/` and `.` with `-`. * Duplicated from packages/cli/src/transcripts.ts — the packages share no code. */ export declare function encodeProjectDirName(cwd: string): string; /** * Locates the sub-agent transcript pair for a finished run. * Prefers the directory of the main `transcript_path`; falls back to the * encoded-cwd convention under the projects root. Null when not found. */ export declare function locateSubagentTranscript(input: SubagentHookInput, projectsRoot?: string): { jsonl: string; meta: string; } | null; /** * Extracts runtime-invoked skills from a Claude Code transcript. Malformed * lines and unknown shapes are ignored: hooks must never fail on transcript * schema drift. */ export declare function extractActivatedSkills(jsonlText: string): string[]; /** * True when the transcript contains an assistant Edit/Write/MultiEdit tool * use. Shares extractActivatedSkills' tolerance: malformed lines are ignored. */ export declare function transcriptHasEdits(jsonlText: string): boolean; /** * Resolves a finished run's agent type. The SubagentStop hook payload does NOT * carry `agent_type` (it comes through empty), so the authoritative source is * the sibling `meta.json`. Falls back to any `agent_type` on the payload for * callers that still supply one. Null when the type can't be determined. */ export declare function resolveAgentType(input: SubagentHookInput, projectsRoot?: string): string | null; /** * Prunes one agent type's archive down to `retain` runs (oldest gz mtime first). * Races with parallel SubagentStop hooks are benign: a missing file is success. */ export declare function pruneAgentArchive(agentTypeDir: string, retain: number): void; /** * Archives a finished sub-agent run into the project-local sessions store. * Returns whether a transcript was archived. Never throws. */ export declare function archiveSubagentRun(input: SubagentHookInput, projectDir: string, projectsRoot?: string): boolean; //# sourceMappingURL=archive.d.ts.map