import type { EventBus } from '../kernel/events.js'; /** * Long-running autonomous mission. A goal survives across sessions and * drives the EternalAutonomyEngine — every iteration of the engine * consults the goal to choose what to do next. * * Storage: `~/.wrongstack/projects//goal.json`. Persistent and * project-scoped on purpose: the goal belongs to the codebase, not the * REPL session. */ export interface JournalEntry { /** ISO timestamp of the iteration. */ at: string; /** Sequential iteration counter (1-based, monotonically increasing). */ iteration: number; /** Source that produced the action ('todo' | 'git' | 'brainstorm' | 'resume' | 'manual' | 'parallel' | 'deliverable'). */ source: 'todo' | 'git' | 'brainstorm' | 'resume' | 'manual' | 'parallel' | 'deliverable'; /** Short one-line description of what the iteration set out to do. */ task: string; /** Outcome status. */ status: 'success' | 'failure' | 'aborted' | 'skipped'; /** Optional free-form note (error message, summary, etc.). */ note?: string | undefined; /** Optional token usage delta for this iteration. */ tokens?: { input: number; output: number; } | undefined; /** Optional USD cost delta for this iteration (provider-estimated). */ costUsd?: number | undefined; } export interface GoalFile { version: 1; /** The raw mission statement as entered by the user. */ goal: string; /** * LLM-refined version of the goal — unambiguous, with concrete * deliverables and acceptance criteria. */ refinedGoal?: string | undefined; /** * Concrete, verifiable deliverables extracted from the refined goal. */ deliverables?: string[] | undefined; /** * Estimated completion 0-100. Updated by the engine after each * iteration. Null means "not yet assessed". */ progress?: number | undefined; /** Human-readable note explaining the current progress estimate. */ progressNote?: string | undefined; /** * Time-series of progress measurements for trend analysis. * Last 200 entries retained. Use `recordProgress()` to append. */ progressHistory?: ProgressSnapshot[] | undefined; /** * Computed trend from recent progress measurements. * 'accelerating' | 'steady' | 'stalling' | undefined. */ progressTrend?: 'accelerating' | 'steady' | 'stalling' | undefined; /** When the goal was first set or last replaced. */ setAt: string; /** Updated on every iteration completion. */ lastActivityAt: string; /** Total iterations the engine has run against this goal (cumulative). */ iterations: number; /** Engine lifecycle state — 'running' means another process owns this goal. */ engineState: 'idle' | 'running' | 'stopped'; /** Mission-level lifecycle. */ goalState?: 'active' | 'paused' | 'completed' | 'abandoned' | undefined; /** Goal-linked Kanban board id. Optional for pre-Kanban goal files. */ kanbanBoardId?: string | undefined; /** ISO timestamp recorded after Brain verifies that every deliverable is reached. */ reachedAt?: string | undefined; /** Durable human-readable reach verdict; currently the literal `goal reached`. */ reachedNote?: string | undefined; /** * Per-todo attempt counter. */ todoAttempts?: Record; /** Bounded ring buffer of recent iterations (newest last). */ journal: JournalEntry[]; } /** Cap on persisted journal entries — older entries are evicted FIFO. */ export declare const MAX_JOURNAL_ENTRIES = 500; /** * Resolve the goal file path for a given project root. * * SINGLE canonical location: the per-project directory that * `resolveWstackPaths()` uses for everything else (sessions, memory, specs) — * `~/.wrongstack/projects//goal.json`. This is the same path the `/goal` * slash command writes via `opts.paths.projectGoal`, so every reader/writer * (the eternal/parallel autonomy engines, the CLI autonomy commands, the TUI * F9 panel, and `/goal` itself) now agree on one file. * * Previously this returned a SEPARATE hash-based dir (`projects//`), which * disagreed with `/goal` and littered the home dir with thousands of stray * `/goal.json` directories that held nothing else. */ export declare function goalFilePath(projectRoot: string): string; export declare function loadGoal(filePath: string, events?: EventBus, warn?: (msg: string) => void): Promise; export declare function saveGoal(filePath: string, goal: GoalFile, events?: EventBus): Promise; /** * Atomically load, modify, and save a goal file under a file lock. * Prevents lost-update races when the autonomy engine and CLI /goal commands * write concurrently (both eternal and parallel engines may run simultaneously). * * `fn` receives the current GoalFile (or `null` if no goal exists yet) * and must return the updated GoalFile (or `null` to delete). */ export declare function updateGoal(filePath: string, fn: (current: GoalFile | null) => GoalFile | null, events?: EventBus): Promise; export declare function emptyGoal(goal: string): GoalFile; /** * Set progress estimate on a goal. Returns a new GoalFile. * Clamps progress to 0-100. */ export declare function setProgress(goal: GoalFile, progress: number, note?: string): GoalFile; /** * Append a journal entry, bumping iteration counters and trimming the * ring buffer. Returns a new GoalFile — does not mutate the argument. */ export declare function appendJournal(goal: GoalFile, entry: Omit): GoalFile; /** * Aggregate cumulative cost + tokens across all journal entries. */ export declare function summarizeUsage(goal: GoalFile): { totalCostUsd: number; totalInputTokens: number; totalOutputTokens: number; iterationsWithUsage: number; }; /** Format the goal + recent journal as a human-readable status block. */ export declare function formatGoal(goal: GoalFile, journalLimit?: number): string; /** A single progress measurement at a point in time. */ export interface ProgressSnapshot { at: string; progress: number; note?: string | undefined; } /** * Parse [PROGRESS: N%] from agent final text. * Supports formats: * [PROGRESS: 45%] * [PROGRESS: 45%] — 3/5 deliverables done * [progress: 100%] * Returns null if no match. */ export declare function parseProgressFromText(text: string): { progress: number; note?: string; } | null; /** * Record a progress measurement. Returns a new GoalFile with: * - progress + progressNote updated * - progressHistory appended (last 200 entries kept) * - progress trend computed (accelerating/steady/stalling) */ export declare function recordProgress(goal: GoalFile, progress: number, note?: string): GoalFile; /** Max progress history entries to retain. */ export declare const MAX_PROGRESS_HISTORY = 200; //# sourceMappingURL=goal-store.d.ts.map