/** * Agent Session Memory — ~/.careervivid/memory.md * * Architecture * ════════════ * The memory file has TWO layers: * * ┌─────────────────────────────────────────────────────────────────┐ * │ LAYER 1 — Knowledge Base (🔒 persisted forever, never deleted) │ * │ Structured sections extracted across ALL sessions: │ * │ • Career Goals & Preferences │ * │ • Resume State (active IDs, versions, tailoring history) │ * │ • Job Pipeline (tracked companies, statuses, decisions) │ * │ • Skills & Experience Context │ * │ • Interview Prep Context │ * │ • Cover Letter History │ * └─────────────────────────────────────────────────────────────────┘ * ┌─────────────────────────────────────────────────────────────────┐ * │ LAYER 2 — Recent Session Log (rolling, auto-compacted) │ * │ Last N sessions with full context of what was done. │ * │ When compaction fires, sessions are merged into the │ * │ Knowledge Base above (not discarded). │ * └─────────────────────────────────────────────────────────────────┘ * * Compaction strategy * ─────────────────── * When total file size > MAX_CHARS: * 1. Parse the knowledge base sections * 2. Merge each older session's facts INTO the knowledge base (upsert) * 3. Drop sessions older than KEEP_SESSIONS, keeping the most recent N * 4. Optionally call the LLM (via CV proxy) to produce a true distillation * if an api key is available — this is the "smart" path * 5. Write the compacted file back * * System prompt injection * ─────────────────────── * Only injects the knowledge base + last 2 sessions (≤ PROMPT_INJECT_CHARS). * The agent always sees what matters, never sees everything. * * Public API * ────────── * loadMemory() → raw file string * buildMemoryBlock() → string for system prompt injection * saveSessionMemory(opts) → append + compact * buildSessionSummary(opts) → build summary string from session data * MEMORY_SECTION → static system-prompt header */ export interface SessionHighlight { tool: string; args: string; outcome: string; } export interface KnowledgeBase { /** e.g. ["harness engineering", "AI-first companies", "solutions engineering"] */ careerGoals: string[]; /** Preferred role titles */ targetRoles: string[]; /** Preferred companies / sectors */ targetCompanies: string[]; /** Active resume ID and title */ activeResume: { id: string; title: string; lastUpdated: string; } | null; /** All known resume IDs */ resumeHistory: Array<{ id: string; title: string; }>; /** Job pipeline entries worth remembering */ jobPipeline: Array<{ company: string; role: string; status: string; note?: string; }>; /** Cover letters generated */ coverLetters: Array<{ company: string; role: string; savedId?: string; }>; /** Interview prep done */ interviewPrep: Array<{ company: string; role: string; topics: string[]; }>; /** Skills the user has mentioned or had added */ skills: string[]; /** Misc facts (work auth, location, salary expectation, etc.) */ facts: Record; /** Last updated ISO timestamp */ updatedAt: string; } export declare function loadMemory(): string; /** * Build the system-prompt memory block. * * Design principle: O(1) token cost regardless of pipeline size. * - 10 jobs → same output size as 1,000 jobs * - Full details always come from tool calls (tracker_list_jobs, etc.) * - This block is context/orientation, not a data dump * * Typical output: ~250–400 chars (~65–100 tokens) * Hard ceiling: 1,200 chars (~300 tokens) — never exceeded by realistic data */ export declare function buildMemoryBlock(): string; /** * Static system-prompt section instructing the agent how to use memory. * Imported by instructions.ts. */ export declare const MEMORY_SECTION: string; export interface SessionSummaryInput { turns: number; mutations: number; highlights: SessionHighlight[]; mode: string; model: string; careerGoals?: string[]; targetRoles?: string[]; targetCompanies?: string[]; skills?: string[]; activeResumeId?: string; activeResumeTitle?: string; jobActions?: Array<{ company: string; role: string; status: string; note?: string; }>; coverLetters?: Array<{ company: string; role: string; savedId?: string; }>; interviewPrep?: Array<{ company: string; role: string; topics: string[]; }>; facts?: Record; summary?: string; } /** * Build a rich session entry block. * Returns a markdown string with embedded JSON metadata for later parsing. */ export declare function buildSessionSummary(opts: SessionSummaryInput): string; /** * Append a session summary to the memory file, merge into KB, compact if needed. */ export declare function saveSessionMemory(opts: SessionSummaryInput): void; export interface CodingSessionData { /** Absolute path of the working directory when the session ended */ cwd: string; /** ISO timestamp of when the session was saved */ savedAt: string; /** Persona mode ("coding", "resume", etc.) */ mode: string; /** Human-readable summary of what happened in the session */ summary: string; /** Files the agent wrote or patched during the session */ filesChanged: string[]; /** Short description of the last thing that was built/created */ lastBuilt: string; /** Git branch active during the session (empty if no git repo) */ branch: string; } /** * Load the last coding session from ~/.careervivid/coding-session.md. * Returns null if the file does not exist or cannot be parsed. * Intentionally synchronous — called at startup before the agent loop. */ export declare function loadCodingSession(): CodingSessionData | null; /** * Save the current coding session to ~/.careervivid/coding-session.md. * Overwrites the previous entry — only the most recent session is kept here. * Full history is preserved in memory.md via saveSessionMemory(). */ export declare function saveCodingSession(data: CodingSessionData): void; //# sourceMappingURL=memory.d.ts.map