import type { SessionKey } from "@yanlinglabs/winter-agent-sdk"; import type { SharedSessionStore } from "../store/wiring.js"; export interface CarriedArtifact { /** The file's path relative to the working copy's `projects/` (`//tool-results/x.txt`). */ path: string; /** The absolute path in the working copy. */ source: string; projectKey: string; /** The session dir the file belongs to; absent for a per-project file beside the session dirs. */ sessionId?: string; } export interface ArtifactCarryReport { copied: CarriedArtifact[]; identical: CarriedArtifact[]; /** Never overwritten: the destination differs, or cannot be written without passing a link. */ conflicts: Array; /** Never carried: a link (or a special file) in the working copy, or a `*.jsonl` the reconcile does not pick up. */ skipped: Array; } /** * Carries every non-transcript file under `/projects/` into `/projects/` (same relative * path). Never throws for a single file's trouble — each is reported; a failure to list the root reads * as nothing to carry. */ export declare function carryBackSessionArtifacts(root: string, storeHome: string): ArtifactCarryReport; /** The projection of a subagent's metadata on which the working copy's and the store's copies are compared (the fields claude's live mirror sends). */ export declare function mirroredMetadataFields(metadata: Record): Record; export interface MetadataRepairReport { /** Appended to the store as `{ type: "agent_metadata", …parsed }` — the store had none. */ repaired: CarriedArtifact[]; /** The store already held exactly this metadata. */ identical: CarriedArtifact[]; /** Never appended, with why (the store's own metadata is never overwritten). */ skipped: Array; } /** * Repairs the store's copy of a subagent transcript's or a journal's metadata from the working copy. * * CLAUDE'S IMPORT turns the `.meta.json` beside EVERY `subagents/**.jsonl` — journals included — into an * `{ type: "agent_metadata", …parsed }` entry on that key, and its * resume materializer writes it back beside the file. The mirror carries an agent's metadata live, but a * journal is never mirrored, and a failed metadata batch leaves an agent without it; so after the * transcripts are reconciled, each one that came back level (`eligible`) has its `.meta.json` repaired * the same way: * * the store has none → appended, then re-read to confirm; * * the store holds the same — compared on the fields claude's live mirror sends * (`mirroredMetadataFields`), since the local file carries more → left; * * the store holds a DIFFERENT one → never overwritten, reported skipped; * * unreadable, not a JSON object, or carrying a `type` of its own other than `agent_metadata` (claude * would let it replace the entry's type and write it into the transcript) → reported skipped. * Only a REGULAR file is read: a link (or a special file) is the carry-back's to report, never followed. */ export declare function repairTranscriptMetadata(root: string, shared: Pick, eligible?: (key: SessionKey) => boolean): Promise;