/**
 * Wiki REST Controller
 *
 * Exposes the LLM-wiki ingest/query operations over HTTP so the bash
 * skills (`wiki-ingest`, `wiki-query`) and in-process subscribers
 * (`WikiChatSubscriberService`) all funnel through the same code path.
 *
 * @module controllers/wiki/wiki.controller
 */
import type { Request, Response, NextFunction } from 'express';
/**
 * POST /api/wiki/ingest
 *
 * Write a single source into a vault's `llm-curated/log.md` (or other
 * non-frozen target). The handler enforces request validation; per-call
 * routing / frozen-path / size limits live in `WikiIngestService`.
 *
 * Request body:
 *   {
 *     vaultPath: string,
 *     sourceType: WikiSourceType,
 *     sourceRef: string,
 *     sourceBody: string,
 *     callerSession?: string,
 *     targetRelativePath?: string
 *   }
 *
 * Response:
 *   200 { success: true,  result: WikiIngestOutcome (ok=true variant) }
 *   400 { success: false, error: string, outcome?: WikiIngestOutcome }
 *   422 { success: false, error: 'frozen_path', outcome: WikiIngestOutcome }
 */
export declare function ingest(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/query
 *
 * Build the system-context payload for a single-vault read. The skill /
 * caller's runtime concatenates this with its per-LLM task-instruction
 * prompt (`config/skills/<role>/wiki-query/prompts/<runtime>.md`) before
 * the actual LLM call.
 *
 * Request body:
 *   {
 *     vaultPath: string,
 *     query: string,
 *     topK?: number,
 *     recentLogEntries?: number
 *   }
 *
 * Response:
 *   200 { success: true,  result: { context: WikiQuerySystemContext } }
 *   400 { success: false, error: string, outcome?: failure }
 *   404 { success: false, error: 'schema_missing', outcome }
 */
export declare function queryVault(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/queue
 *
 * Enqueue a candidate item. Agents call this when a turn produces
 * content worth saving to the wiki. The `reason` is REQUIRED — the
 * agent has to justify why this is wiki-worthy (audit trail + helps
 * the processor decide where it goes).
 */
export declare function queueAdd(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/queue?vaultPath=…&status=…&queuedBy=…&limit=…
 */
export declare function queueList(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/queue/:id/claim
 *   body: { claimedBy: string }
 */
export declare function queueClaim(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/queue/:id/process
 *   body: { ingested: boolean, pagesWritten?: string[], targetPath?: string, summary?: string }
 *
 * Cascade audit (2026-05-26 — Karpathy 10-15-pages-per-source rule):
 *   The response includes `cascadeAudit: { pageCount, classification }` so
 *   callers can self-assess whether they did the cascade work. Single-page
 *   ingests (i.e. just the primary write, no cross-link, no related-page
 *   update) emit a `warn`-level audit log so we can later quantify how
 *   often agents skip cascade — the wiki's compounding value lives in
 *   cascade touches, not in the primary write.
 *
 * Classification:
 *   - `single`     — 1 page written. Likely a missed cascade. Audited (warn).
 *   - `light`      — 2 pages. Acceptable for routine learnings.
 *   - `cascading`  — 3+ pages. Karpathy-shaped: load-bearing content with cross-refs.
 */
export declare function queueProcess(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/queue/:id/skip
 *   body: { skipReason: string }
 */
export declare function queueSkip(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/queue/claim-next
 *   body: { claimedBy: string, vaultPath?: string, offset?: number, topK?: number, recentLogEntries?: number }
 *
 * Claims the next pending item AND returns the vault context the
 * agent's LLM should classify against. The agent then picks a target
 * page, calls /wiki/ingest, and commits via /queue/:id/process.
 */
export declare function queueClaimNext(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/bookkeep
 *   body: { vaultPath: string, windowDays?: number, threshold?: number }
 */
export declare function bookkeep(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/vaults
 *
 * Returns the list of all known vaults (project + team + global) with
 * stats so the UI can render a sidebar. Discovery uses the same logic
 * the bookkeep trigger uses.
 */
export declare function listVaults(_req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/tree?vaultPath=...
 *
 * Walks the vault directory and returns the file tree. Frozen folders
 * are marked so the UI can render them differently. SCHEMA.md is
 * surfaced as a top-level file.
 */
export declare function getVaultTree(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/page?vaultPath=...&relativePath=...
 *
 * Returns the raw markdown content of a single page. The relativePath
 * is validated to ensure it doesn't escape the vault directory.
 */
export declare function getPage(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/search?vaultPath=…&q=…
 *
 * Full-text search across the vault. Walks every `.md` file, matches
 * case-insensitive substrings, returns up to `WIKI_SEARCH_MAX_RESULTS`
 * hits with line-number snippets.
 */
export declare function searchVault(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/search-all?q=…
 *
 * Search EVERY vault and return one merged BM25-ranked list. Each hit carries
 * its owning vaultPath + vaultLabel so the UI can show where it lives and jump
 * to it. IDF is computed over the combined corpus for cross-vault comparability.
 */
export declare function searchAllVaults(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/sop-catalog?vaultPath=…
 *
 * List the SOP catalog (`config/sops/`), annotated with whether the given team
 * (resolved from its vault path) has each entry installed.
 */
export declare function listSopCatalog(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/sop-catalog/install   { vaultPath, sopPath }
 *
 * Copy a catalog SOP into the team's installed store. Idempotent.
 */
export declare function installSop(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/sop-catalog/uninstall   { vaultPath, sopPath }
 *
 * Remove a SOP from the team's installed store (catalog original untouched).
 * Idempotent.
 */
export declare function uninstallSop(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/overlay-page   { vaultPath, relativePath, content }
 *
 * Create or overwrite an owner-authored page in a per-team overlay folder
 * (`team-norm/` or `sop/`). Only overlay folders are writable here — the rest
 * of the vault is agent-curated / schema-frozen, so a relativePath that does
 * not resolve to an overlay source is rejected. Used by the wiki editor for
 * owner-authored team norms and custom SOPs.
 */
export declare function writeOverlayPage(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * DELETE /api/wiki/overlay-page   { vaultPath, relativePath }
 *
 * Delete an owner-authored overlay page (team norm / custom SOP) and prune any
 * emptied parent dirs. Idempotent. Only overlay folders are eligible.
 */
export declare function deleteOverlayPage(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/backlinks?vaultPath=…&relativePath=…
 *
 * For the target page, find every other page in the vault whose markdown
 * contains a `[[wikilink]]` that resolves to it. Used by the UI's right
 * sidebar.
 */
export declare function getBacklinks(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/migrate/scan
 *
 * Dry-run preview of a migration from the legacy `.crewly/knowledge/`
 * stores (+ optional agent memory.json copies) into the v2.1 vault.
 *
 * Body: `{ projectRoot: string, includeAgentMemory?: boolean }`
 */
export declare function migrateScan(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/migrate/apply
 *
 * Execute the migration: bootstrap missing vaults, write proposed pages,
 * persist manifest. Legacy files are never deleted.
 *
 * Body: `{ projectRoot: string, includeAgentMemory?: boolean, confirm: true }`
 * `confirm: true` is mandatory — guards against accidental triggering.
 */
export declare function migrateApply(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/cleanup/scan
 *
 * Dry-run: walk the vault's `llm-curated/` tree and return a list of
 * pages flagged by the cleanup rules (low confidence, agent memory
 * dump, per-agent cap). No filesystem mutation.
 *
 * Body: `{ vaultPath: string, rules?: { minConfidence?, dropAgentMemoryDumps?, maxPerAgent? } }`
 */
export declare function cleanupScan(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/cleanup/apply
 *
 * Execute the cleanup: delete the listed pages, archive their bodies
 * to `.wiki-cleanup-archive.json`, and invalidate matching migrate
 * manifest entries so the same source can't re-import the page.
 *
 * Body: `{ vaultPath: string, pages: string[], confirm: true }`
 *   - `pages`: explicit relative paths to delete (caller has already
 *     decided which scan candidates to act on)
 *   - `confirm: true` is mandatory — guards against accidental triggering.
 */
export declare function cleanupApply(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/migrate/oss-sops
 *
 * Migrate OSS-distributed SOPs (`config/sops`, `config/domain-sops`,
 * `config/templates/pro-sops/norms`) into the global vault's
 * `llm-curated/sops/` tree so `wiki-query` can find them.
 *
 * Body: `{ crewlySourceRoot?: string, confirm?: true }`
 *   - When `confirm: true` is set, writes files (apply). Otherwise dry-run.
 *   - Default crewlySourceRoot = process.cwd() (works when OSS runs from its own source).
 */
export declare function migrateOssSops(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/reflect/trigger-now
 *
 * Fire ONE WikiReflectTrigger tick on demand. Used for verification —
 * confirms the trigger emits `[REFLECT-WIKI]` messages to the right
 * channel without waiting for the scheduled interval to elapse.
 *
 * Production cadence remains the scheduled scan.
 */
export declare function reflectTriggerNow(_req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/recent?vaultPath=…&limit=…
 *
 * Returns the most-recently-modified `.md` pages in the vault. Powers
 * the "What's new" widget in the page-pane empty state.
 */
export declare function getRecent(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/lint
 *
 * Run a deterministic validation pass over the vault. Reports frozen-path
 * violations, dangling wikilinks, orphan pages, stale claims, and
 * restructure proposals. The service does not modify the vault — the
 * agent reads the report and decides next actions.
 */
export declare function lintVault(req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * POST /api/wiki/bookkeep/trigger-now
 *
 * Force one tick of the bookkeep trigger NOW. Used for manual testing
 * (curl, the chat UI, an admin button) — production cadence is the
 * automatic interval scan, but operators sometimes want to invoke it
 * synchronously to verify wiring or to clear a backlog.
 */
export declare function bookkeepTriggerNow(_req: Request, res: Response, next: NextFunction): Promise<void>;
/**
 * GET /api/wiki/queue/stats?vaultPath=…
 */
export declare function queueStats(req: Request, res: Response, next: NextFunction): Promise<void>;
//# sourceMappingURL=wiki.controller.d.ts.map