/**
 * WikiBookkeepTriggerService — periodic vault scan that fires a
 * notification to ORC when bookkeeping is due.
 *
 * Per Steve's 2026-05-22 design point #5: "还要时不时让 agent 针对自己的
 * vault 进行 bookkeeping (可以根据存入的 md 数量来 trigger), 譬如过去
 * N 天超过 X 个 md, 然后总结一下."
 *
 * Mechanism:
 *   - every `intervalMs` (default 30 min) tick
 *   - discover known vaults (project + team + global) by walking known
 *     filesystem roots for SCHEMA.md
 *   - call `WikiBookkeepService.generate` for each
 *   - if `report.shouldFire`, invoke the caller-injected `fireFn` (in
 *     production: enqueue a `[BOOKKEEP] vault=…` message to ORC)
 *   - debounce per-vault so we don't spam — only refire after
 *     `debounceMs` (default 6 h)
 *
 * The service intentionally does NOT do the consolidation itself — it
 * notifies the agent, which then runs `wiki-bookkeep` + `wiki-ingest`
 * (per the orchestrator system prompt rule).
 *
 * @module services/wiki/wiki-bookkeep-trigger.service
 */
import { WikiBookkeepService, WikiBookkeepReport } from './wiki-bookkeep.service.js';
export type WikiBookkeepFireFn = (vaultPath: string, report: WikiBookkeepReport) => Promise<void> | void;
export interface WikiBookkeepTriggerOptions {
    /** Interval between scans, ms. Default 30 minutes. */
    intervalMs?: number;
    /** Minimum gap between fires for the same vault, ms. Default 6 hours. */
    debounceMs?: number;
    /** Caller-injected notifier. Production wires this to enqueue a message to ORC. */
    fireFn: WikiBookkeepFireFn;
    /** Optional override of the discovery roots (tests). */
    discoverRoots?: () => Promise<string[]>;
    /** Optional override of the bookkeep service (tests). */
    bookkeepService?: WikiBookkeepService;
    /**
     * Where to persist per-vault baseline + debounce state. Defaults to
     * `~/.crewly/wiki-bookkeep-trigger-state.json`. Pass `null` to disable
     * persistence (tests) so the trigger keeps state in-memory only.
     */
    statePath?: string | null;
}
/**
 * Discover absolute vault paths by walking the well-known Crewly roots:
 *   - `<env CREWLY_PROJECT_VAULT_PATH>` (single explicit override)
 *   - `<process.cwd>/.crewly/wiki` (current project vault — the OSS's own dir)
 *   - `~/.crewly/projects.json` → every registered project's `.crewly/wiki`
 *     (Closie, Flopost, CE, etc. — each team manages a project, and that
 *      project gets its own vault per v2.1 spec §1)
 *   - `~/.crewly/teams/<uuid>/wiki` (every team vault)
 *   - `~/.crewly/global-wiki` (ORC cross-project vault, if present)
 *
 * A path is only included if `SCHEMA.md` exists inside it.
 */
export declare function discoverWikiVaults(): Promise<string[]>;
/**
 * Periodic vault-bookkeep trigger. Start at boot, stop at shutdown.
 */
export declare class WikiBookkeepTriggerService {
    private static instance;
    private readonly logger;
    private readonly intervalMs;
    private readonly debounceMs;
    private readonly fireFn;
    private readonly discoverRoots;
    private readonly bookkeepService;
    private timer;
    /** vaultPath → persisted baseline + last-fired state. */
    private readonly state;
    /** Per-vault locks so two overlapping ticks don't double-fire. */
    private inflight;
    private readonly statePath;
    private stateLoaded;
    constructor(opts: WikiBookkeepTriggerOptions);
    /**
     * Load per-vault baseline + debounce state from disk (once). Without this,
     * the in-memory ledger resets on every backend restart, so the next tick
     * re-fires for every eligible vault — the "noise burst after a restart".
     */
    private loadStateFromDisk;
    /** Persist the per-vault state map (best-effort; failures are logged, not thrown). */
    private saveStateToDisk;
    static getInstance(): WikiBookkeepTriggerService | null;
    /** Wire the production singleton. Pass null to detach (tests / shutdown). */
    static setInstance(next: WikiBookkeepTriggerService | null): void;
    /** Begin scanning. Idempotent. */
    start(): void;
    /** Stop scanning. Safe to call multiple times. */
    stop(): void;
    /**
     * Run one scan pass. Public for test + the manual
     * `/api/wiki/bookkeep/trigger-now` endpoint.
     */
    tick(): Promise<{
        scanned: string[];
        fired: string[];
        skippedByDebounce: string[];
        quietVaults: string[];
    }>;
    /**
     * Test affordance: clear the in-memory baseline + debounce ledger. Leaves
     * `stateLoaded` set so a subsequent `tick()` does NOT reload persisted state
     * (which would undo the clear).
     */
    _resetDebounceForTesting(): void;
}
//# sourceMappingURL=wiki-bookkeep-trigger.service.d.ts.map