export interface PlanMdxFolder { "plan.mdx": string; "canvas.mdx"?: string; "prototype.mdx"?: string; ".plan-state.json"?: string; "assets/"?: Record; } export interface DesktopPlanFilesFolder { name: string; planId: string; title?: string; updatedAt?: string; } export type DesktopPlanFilesResult = | { ok: true; folder: DesktopPlanFilesFolder; files?: string[]; mdx?: PlanMdxFolder; controlResources?: Record; } | { ok: false; error: string; canceled?: boolean; folder?: DesktopPlanFilesFolder; }; export interface DesktopPlanFilesApi { getFolder(request: { planId: string }): Promise; chooseFolder(request: { planId: string; title?: string; }): Promise; writePlan(request: { planId: string; title?: string; mdx: PlanMdxFolder; }): Promise; readPlan(request: { planId: string }): Promise; clearFolder(request: { planId: string }): Promise; } declare global { interface Window { agentNativeDesktop?: { planFiles?: DesktopPlanFilesApi; }; } } export function getDesktopPlanFiles(): DesktopPlanFilesApi | null { if (typeof window === "undefined") return null; return window.agentNativeDesktop?.planFiles ?? null; }