/**
 * Resource heal engine — close the gap between what DotAgents repos DEFINE and
 * what is actually present/valid in each installed agent home.
 *
 * Powers two callers:
 *   - `agents sync` — the one fixer, via the post-reconcile repair pass
 *     (`lib/reconcile-and-repair.ts`, run at the tail of every sync). Mode
 *     'full': fills missing, overwrites drifted content, and refreshes stale
 *     plugins even when the baseline is unknown (the user asked to sync).
 *   - the routines daemon's periodic safety check — Mode 'safe': fixes only the
 *     unambiguous gaps (missing resources, Claude-invalid plugin manifests, and
 *     provably-unmodified stale plugins). Drift and risky refreshes are reported,
 *     never clobbered.
 *
 * Built on the LIVE-home diff (`diffVersionResources`) — NOT the staleness
 * manifest. `isStale()` only compares the last-synced manifest against the
 * sources, so home-side rot (a deleted, corrupted, or Claude-rejected file in a
 * version home whose source never changed) is invisible to it and to the sync
 * fast-guard. The diff reads the actual home, so heal catches exactly that class
 * of drift — the kind that silently broke the `code` plugin on a non-default
 * Claude version.
 *
 * Heal FILLS and FIXES; it never deletes. Orphan/extra removal stays the job of
 * `agents prune cleanup`, so a heal pass can never lose work.
 */
import type { AgentId } from './types.js';
import { type DoctorKind, type DiffStatus } from './doctor-diff.js';
export interface HealedResource {
    kind: DoctorKind;
    name: string;
    /** Why it was healed: 'missing' (filled) or 'diff' (overwritten / re-pushed). */
    was: DiffStatus;
}
export interface SkippedResource {
    kind: DoctorKind;
    name: string;
    /** 'drift': hand-edited content left untouched in 'safe' mode.
     *  'unreconcilable': heal wrote it but the diff still flags it — a source/home
     *  asymmetry the writer can't satisfy (e.g. a hook sidecar the installer omits),
     *  surfaced honestly instead of "fixed" on every pass. */
    reason: 'drift' | 'unreconcilable';
}
export interface VersionHealResult {
    agent: AgentId;
    version: string;
    healed: HealedResource[];
    skipped: SkippedResource[];
}
export interface ManifestRepairResult {
    plugin: string;
    /** Bare-name fields stripped from the source plugin.json (e.g. ["skills"]). */
    droppedFields: string[];
}
export interface PluginRefreshResult {
    plugin: string;
    from: string;
    to: string;
}
export interface PluginRefreshSkip {
    plugin: string;
    from: string;
    upstream: string;
    /** 'modified': central diverged from baseline. 'no-baseline': pre-tracking install. */
    reason: 'modified' | 'no-baseline';
}
export interface HealResult {
    versions: VersionHealResult[];
    repairedManifests: ManifestRepairResult[];
    refreshedPlugins: PluginRefreshResult[];
    skippedPlugins: PluginRefreshSkip[];
}
export interface HealOptions {
    /** 'full' (doctor --fix): fix drift + refresh unknown-baseline plugins.
     *  'safe' (daemon): missing + invalid-manifest + unmodified refresh only. */
    mode: 'full' | 'safe';
    /** Resolution cwd. Defaults to the home dir so no project layer is ever
     *  resolved — heal targets the GLOBAL install, never a project. Tests override. */
    cwd?: string;
    /** Scope to one agent; omit to heal every installed agent. */
    agent?: AgentId;
    /** Scope to specific versions of `agent`; omit for all installed versions. */
    versions?: string[];
    /** Compute the plan without writing anything. */
    dryRun?: boolean;
}
/** True when a heal pass made (or would make) any change at all. */
export declare function healChangedAnything(r: HealResult): boolean;
/** One-line summary of a heal pass for daemon logs. */
export declare function summarizeHeal(r: HealResult): string;
/**
 * Fire a branded desktop notification when a background heal did something
 * noteworthy. Routed through the MenubarHelper companion (notify-desktop.ts) so
 * it carries the agents-cli mark; clicking opens the runs folder
 * (~/.agents/.history/runs, via the `routines:list` action the companion
 * understands). Best-effort — a missing
 * notifier or no display is swallowed. Silent when the pass auto-fixed everything
 * and nothing needs the operator (no point pinging them for routine self-healing).
 */
export declare function notifyHeal(r: HealResult): void;
/**
 * Strip Claude-invalid bare-name `skills`/`commands` fields from every central
 * plugin's SOURCE plugin.json. Unambiguously safe (Claude auto-discovers both
 * from their directories) and the precondition for those plugins loading at all.
 */
export declare function repairCentralPluginManifests(dryRun?: boolean): ManifestRepairResult[];
/**
 * Run a heal pass. Repairs the central plugin layer once (manifest + stale
 * refresh), then reconciles every targeted (agent, version) home against its
 * live diff. Returns a full account of what changed (or would, under dryRun).
 */
export declare function heal(opts: HealOptions): Promise<HealResult>;
