{"version":3,"file":"types.mjs","names":[],"sources":["../src/types.ts"],"sourcesContent":["import type {\n\tApi,\n\tAssistantMessageEventStream,\n\tContext,\n\tcompleteSimple,\n\tModel,\n\tSimpleStreamOptions,\n\tstreamSimple as streamSimpleDefault,\n} from '@earendil-works/pi-ai';\nimport type { convertToLlm, ExtensionUIContext } from '@earendil-works/pi-coding-agent';\nimport type { AppendEntry } from '@live-compaction/attempt-entry';\nimport type {\n\tloadEffectiveBranchSummaryPromptContract,\n\tloadEffectiveCompactionPromptContract,\n\tloadEffectiveConfig,\n\tPresetConfig,\n\tresolveLiveCompactionPaths,\n\tThinkingLevel,\n} from '@live-compaction/config';\nimport type { collectFilesTouched } from '@live-compaction/files-touched';\nimport type { loadCompactionTemplate } from '@live-compaction/template';\n\nexport type NotifyLevel = 'info' | 'warning' | 'error';\n\n/**\n * Wrap a HookContext's UI so calls silently no-op if ctx goes stale\n * after a reload or session replacement mid-compaction.\n */\nexport function safeUI(ctx: HookContext): HookContext['ui'] {\n\tconst wrap = <T extends (...args: never[]) => unknown>(fn: T): T =>\n\t\t((...args: Parameters<T>) => {\n\t\t\ttry {\n\t\t\t\treturn fn(...args);\n\t\t\t} catch {\n\t\t\t\t// ctx stale after reload/session replacement — swallow\n\t\t\t}\n\t\t}) as T;\n\treturn {\n\t\tnotify: wrap(ctx.ui.notify),\n\t\tsetStatus: wrap(ctx.ui.setStatus),\n\t\tsetWidget: wrap(ctx.ui.setWidget),\n\t\tsetWorkingMessage: wrap(ctx.ui.setWorkingMessage),\n\t};\n}\n\nexport type ReasoningLevel = Exclude<ThinkingLevel, 'off'>;\nexport type PreparedMessages = Parameters<typeof convertToLlm>[0];\nexport type StreamSimple = (\n\tmodel: Model<Api>,\n\tcontext: Context,\n\toptions?: SimpleStreamOptions,\n) => AssistantMessageEventStream;\n\nexport interface ParsedCompactInstructions {\n\tusesPresetDirective: boolean;\n\tpresetQuery?: string;\n\tfocusText?: string;\n}\n\nexport interface ResolvedSummarizer {\n\tmodel: Model<Api>;\n\tapiKey?: string;\n\theaders?: Record<string, string>;\n\treasoningLevel?: ThinkingLevel;\n\tstreamSimple?: StreamSimple;\n}\n\nexport interface LiveCompactionDetails {\n\tmodel: string;\n\tthinkingLevel?: ThinkingLevel;\n\tfocusInput?: string;\n\tfocusText?: string;\n\tpresetQuery?: string;\n\tattemptId?: string;\n\ttransport?: string;\n}\n\nexport interface PresetMatchResult {\n\tkind: 'matched' | 'ambiguous' | 'unmatched';\n\tname?: string;\n\tpreset?: PresetConfig;\n}\n\nexport type HookContext = {\n\thasUI: boolean;\n\tui: Pick<ExtensionUIContext, 'notify' | 'setStatus' | 'setWidget' | 'setWorkingMessage'>;\n\tmodel?: Model<Api>;\n\tcwd?: string | null;\n\tmodelRegistry: {\n\t\tgetAll(): Model<Api>[];\n\t\tgetApiKeyAndHeaders(\n\t\t\tmodel: Model<Api>,\n\t\t): Promise<\n\t\t\t{ ok: true; apiKey?: string; headers?: Record<string, string> } | { ok: false; error: string }\n\t\t>;\n\t};\n};\n\nexport type SummaryProgress = {\n\tstart(modelLabel: string, tokensBefore: number): void;\n\tupdate(text: string): void;\n\tfinish(): void;\n\tfail(message: string): void;\n};\n\nexport type RunDeps = {\n\tcomplete: typeof completeSimple;\n\tstreamSimple: typeof streamSimpleDefault;\n\tcollectFilesTouched: typeof collectFilesTouched;\n\tloadConfig: typeof loadEffectiveConfig;\n\tloadCompactionPrompt: typeof loadEffectiveCompactionPromptContract;\n\tloadBranchSummaryPrompt: typeof loadEffectiveBranchSummaryPromptContract;\n\tloadCompactionTemplate: typeof loadCompactionTemplate;\n\tresolvePaths: typeof resolveLiveCompactionPaths;\n\tfetchTaskState?: () => Promise<string | undefined> | string | undefined;\n\tappendEntry?: AppendEntry;\n\tmakeProgress?: (ctx: HookContext) => SummaryProgress | undefined;\n};\n"],"mappings":";;;;;AA4BA,SAAgB,OAAO,KAAqC;CAC3D,MAAM,QAAiD,SACpD,GAAG,SAAwB;EAC5B,IAAI;GACH,OAAO,GAAG,GAAG,IAAI;EAClB,QAAQ,CAER;CACD;CACD,OAAO;EACN,QAAQ,KAAK,IAAI,GAAG,MAAM;EAC1B,WAAW,KAAK,IAAI,GAAG,SAAS;EAChC,WAAW,KAAK,IAAI,GAAG,SAAS;EAChC,mBAAmB,KAAK,IAAI,GAAG,iBAAiB;CACjD;AACD"}