{"version":3,"file":"attempt-entry.mjs","names":[],"sources":["../src/attempt-entry.ts"],"sourcesContent":["export const COMPACTION_ATTEMPT_CUSTOM_TYPE = 'live-compaction.attempt';\n\nexport type AppendEntry = (customType: string, data?: unknown) => void;\n\nexport type CompactionAttemptEntry = {\n\tschemaVersion: 1;\n\tattemptId: string;\n\ttimestamp: number;\n\tevent:\n\t\t| 'start'\n\t\t| 'request_rendered'\n\t\t| 'stream_recovered'\n\t\t| 'success'\n\t\t| 'preset_failed'\n\t\t| 'failed'\n\t\t| 'aborted';\n\tfocusInput?: string;\n\tfocusText?: string;\n\tpresetQuery?: string;\n\tmodel?: string;\n\tthinkingLevel?: string;\n\tpromptChars?: number;\n\trenderedPromptChars?: number;\n\tsystemPromptChars?: number;\n\trenderedPromptSha256?: string;\n\tsystemPromptSha256?: string;\n\trenderedPrompt?: string;\n\tsystemPrompt?: string;\n\tdiscardedMessages?: number;\n\tkeptTailMessages?: number;\n\ttaskStateChars?: number;\n\ttokensBefore?: number;\n\tfirstKeptEntryId?: string;\n\ttransport?: string;\n\tsummaryChars?: number;\n\terror?: unknown;\n\trecoveredChars?: number;\n};\n\nexport function appendCompactionAttemptEntry(\n\tappendEntry: AppendEntry | undefined,\n\tattemptId: string | undefined,\n\tentry: Omit<CompactionAttemptEntry, 'schemaVersion' | 'attemptId' | 'timestamp'>,\n): void {\n\tif (!appendEntry || !attemptId) return;\n\ttry {\n\t\tappendEntry(COMPACTION_ATTEMPT_CUSTOM_TYPE, {\n\t\t\tschemaVersion: 1,\n\t\t\tattemptId,\n\t\t\ttimestamp: Date.now(),\n\t\t\t...entry,\n\t\t} satisfies CompactionAttemptEntry);\n\t} catch {\n\t\t// Attempt entries are recovery/debug state. Never let them break compaction.\n\t}\n}\n"],"mappings":";AAAA,MAAa,iCAAiC;AAuC9C,SAAgB,6BACf,aACA,WACA,OACO;CACP,IAAI,CAAC,eAAe,CAAC,WAAW;CAChC,IAAI;EACH,YAAY,gCAAgC;GAC3C,eAAe;GACf;GACA,WAAW,KAAK,IAAI;GACpB,GAAG;EACJ,CAAkC;CACnC,QAAQ,CAER;AACD"}