import { type RlmDataContext } from "../autoresearch/data-context"; import { type EnsureAutoresearchBranchResult } from "../autoresearch/git"; import { type ParsedHarnessOutput } from "../autoresearch/harness"; import { AutoresearchRunsStore, type MetricDirection } from "../autoresearch/runs"; export type AutoresearchMode = "web" | "mixed" | "data"; export type AutoresearchIntakeKind = "handoff" | "cold"; export declare const AUTORESEARCH_MODES: Set; export declare const AUTORESEARCH_LEDGER_EVENT_KINDS: readonly ["mission_created", "mode_set", "run_logged", "verdict_issued", "critic_recorded", "mission_cleared"]; export type AutoresearchLedgerEventKind = (typeof AUTORESEARCH_LEDGER_EVENT_KINDS)[number]; /** The one mission artifact both intake entrypoints write. */ export interface AutoresearchMission { objective: string; mode: AutoresearchMode; deliverables: string[]; constraints: string[]; slug: string; intake: AutoresearchIntakeKind; createdAt: string; updatedAt: string; /** Absolute path of the deep-interview spec consumed by spec intake. */ specPath?: string; handedOffAt?: string; /** * Primary metric contract for the mission's harness. * * Optional: a mission that declares none keeps the historical default * (`metric`, lower-is-better). When declared it MUST reach the experiment * config -- otherwise a mission whose research contract is * higher-is-better silently optimizes the wrong direction. */ primaryMetric?: string; metricUnit?: string; metricDirection?: MetricDirection; } export interface AutoresearchPaths { dir: string; missionPath: string; ledgerPath: string; /** Quarantine root for retired missions: `/retired/./`. */ retiredRoot: string; } /** Append-only session ledger row. */ export interface AutoresearchLedgerEvent { eventId: string; event: AutoresearchLedgerEventKind; timestamp: string; [field: string]: unknown; } /** Optional per-mission critic pass receipt; evaluator is distinct from the mission agent. */ export interface AutoresearchCriticReceipt { criticId: string; status: Record; evidence: string[]; caveats: string[]; evaluator: string; recordedAt: string; } /** Structured mission verdict: status is open data, not a pinned enum — terminality is deliberately deferred. */ export interface AutoresearchVerdictReceipt { receiptId: string; status: Record; evidence: string[]; caveats: string[]; evaluator: string; issuedAt: string; criticReceipt?: AutoresearchCriticReceipt; } export interface AutoresearchCommandResult { status: number; stdout?: string; stderr?: string; intake?: AutoresearchIntakeKind; missionCreated?: boolean; } export interface AutoresearchReadReceipt { ok: true; exists: boolean; mission?: AutoresearchMission; ledger: AutoresearchLedgerEvent[]; paths: AutoresearchPaths; /** * GJC session id the mission state was read from. Callers deriving * session-scoped identity (notably the kernel owner id) MUST use this * instead of re-resolving, so every path agrees on one scope. */ sessionId: string; } export interface AutoresearchWriteReceipt { ok: true; mission: AutoresearchMission; missionPath: string; intake: AutoresearchIntakeKind; ledgerEvent?: AutoresearchLedgerEvent; } export interface AutoresearchClearReceipt { ok: true; cleared: boolean; missionPath: string; ledgerEvent: AutoresearchLedgerEvent; /** Where the retired mission's artifacts were quarantined, when one existed. */ retiredTo?: string; } export interface AutoresearchIntakeReceipt extends AutoresearchWriteReceipt { specPath: string; } export declare function getAutoresearchPaths(cwd: string, sessionId?: string | null): AutoresearchPaths; export declare function readAutoresearchMission(cwd: string, sessionId?: string | null): Promise; export declare function readAutoresearchLedger(cwd: string, sessionId?: string | null): Promise; /** read verb: current mission + append-only ledger snapshot. */ export declare function autoresearchRead(cwd: string, sessionId?: string | null): Promise; /** write verb: persist the mission after cold-intake clarification. Mode is required. */ export declare function autoresearchWrite(input: { cwd: string; objective: string; mode: AutoresearchMode; deliverables?: string[]; constraints?: string[]; slug: string; sessionId?: string | null; primaryMetric?: string; metricUnit?: string; metricDirection?: string; }): Promise; /** * clear verb: retire the entire mission working set and record the mission clear. * * Artifacts are QUARANTINED to `/retired/./`, never * deleted, so a completed mission's evidence stays auditable while the * successor mission starts from genuinely empty state. The `mission_cleared` row * is appended to the OUTGOING ledger before it is moved, so the retired ledger * is a complete record that ends with its own clear and the successor's ledger * starts empty rather than the clear silently vanishing from the audit trail. */ export declare function autoresearchClear(cwd: string, sessionId?: string | null): Promise; /** Spec intake (`intake --spec ` or bare `--spec`): read the spec, write the mission, ask zero questions. The persisted intake kind stays "handoff" (seeded by a deep-interview handoff). */ export declare function autoresearchIntake(input: { cwd: string; specPath: string; sessionId?: string | null; }): Promise; /** Record one experiment run in the ledger. */ export declare function autoresearchLogRun(input: { cwd: string; runId: string; status: string; description: string; metric?: number; slug?: string; sessionId?: string | null; }): Promise; /** Record the optional per-mission critic pass; its evaluator is distinct from the mission agent. */ export declare function autoresearchRecordCritic(input: { cwd: string; status: Record; evidence: string[]; caveats: string[]; evaluator: string; slug?: string; sessionId?: string | null; }): Promise; /** Issue the mission verdict; an optional critic receipt rides along with its own evaluator identity. */ export declare function autoresearchIssueVerdict(input: { cwd: string; status: Record; evidence: string[]; caveats: string[]; evaluator: string; criticReceipt?: AutoresearchCriticReceipt; slug?: string; sessionId?: string | null; }): Promise; export declare function runNativeAutoresearchCommand(args: string[], cwd?: string): Promise; /** * Rebuilt autoresearch capability surface. Each capability is reachable from * the runtime through a thin, mission-state-aware wrapper. All are read-only * with respect to the ledger — none append events; the verbs above remain the * only writers. */ /** 1. Branch isolation: ensure the worktree is on an `autoresearch/*` branch. */ export declare function autoresearchBranchIsolation(cwd: string, goal: string): Promise; /** 2. Harness contract: parse `METRIC`/`ASI` lines out of captured harness output. */ export declare function autoresearchHarnessOutput(output: string, primaryMetricName?: string): ParsedHarnessOutput; /** * 3. Durable run storage: open the session-scoped JSONL run store, seeding an * in-memory experiment config from the mission when none is persisted yet. */ export declare function autoresearchRunsStore(cwd: string, sessionId?: string | null): Promise; /** 4. TUI dashboard: render the run table (collapsed + expanded) from persisted state. */ export declare function autoresearchDashboardText(cwd: string, sessionId?: string | null, width?: number): Promise; export declare function autoresearchDataContext(cwd: string, dataFlag?: string, sessionId?: string | null): Promise; /** 8. Two-phase prompts: Phase 1 (harness setup) rendered from mission/branch state. */ export declare function autoresearchSetupPrompt(baseSystemPrompt: string, cwd: string, goal?: string, sessionId?: string | null): Promise; /** 8. Two-phase prompts: Phase 2 (iterate) rendered from the persisted experiment state. */ export declare function autoresearchIteratePrompt(baseSystemPrompt: string, cwd: string, sessionId?: string | null): Promise;