/** * StartupBriefingService — the knowledge part of an agent's registration * prompt (#1345). * * Registration already injects "what am I on the hook for" (active work) * and the session memory (last summary, memory context, today's log). This * module adds what was missing, in one size-capped section: * * 1. the project's wiki: the one-line index (trimmed) and the most * recently changed topic pages (title + summary); * 2. the agent's lessons from the last `LESSONS_DAYS` days: its role * knowledge plus its own entries in the project and global vault logs; * 3. open owner threads the agent is part of, from the owner-thread * sentinel (an unanswered owner message, a standing promise, an open * approval card). * * All reads are plain files or in-memory state; no LLM, no retrieval * ranking. The whole section is capped at `MAX_CHARS`; when over budget * the index is trimmed first, then recent pages, then lessons — owner * threads are never cut. * * @module services/memory/startup-briefing.service */ import { type IAgentMemoryService } from './agent-memory.service.js'; import { WikiIndexService } from '../wiki/wiki-index.service.js'; import { WikiRecentService } from '../wiki/wiki-recent.service.js'; import { type OwnerThreadEntry } from '../messaging/owner-thread-sentinel.service.js'; /** Input to {@link StartupBriefingService.build}. */ export interface StartupBriefingInput { sessionName: string; role: string; projectPath: string; } /** Narrow surfaces the service reads (overridable in tests). */ export interface StartupBriefingDeps { agentMemory?: IAgentMemoryService; index?: WikiIndexService; recent?: WikiRecentService; /** Owner-thread entries (default: the live sentinel's `list()`). */ listOwnerThreads?: () => OwnerThreadEntry[]; /** Global vault path (default `/global-wiki`). */ globalVaultPath?: string; /** Clock (tests). */ now?: () => number; } /** * Builds the `## Your Project Knowledge` section. Stateless singleton. */ export declare class StartupBriefingService { private static instance; private readonly logger; private readonly agentMemory; private readonly index; private readonly recent; private readonly listOwnerThreads; private readonly globalVaultPath; private readonly nowFn; constructor(deps?: StartupBriefingDeps); static getInstance(): StartupBriefingService; /** Test-only reset. */ static _resetForTesting(): void; /** * Build the section. Returns '' when there is nothing to say (no vault, * no lessons, no threads), so the caller can skip it. * * @param input - Agent session, role and project * @returns Markdown section capped at `STARTUP_BRIEFING_CONSTANTS.MAX_CHARS`, or '' * * @example * ```typescript * const md = await StartupBriefingService.getInstance().build({ sessionName, role, projectPath }); * if (md) prompt += `\n\n---\n\n${md}`; * ``` */ build(input: StartupBriefingInput): Promise; /** * Drop content until the whole section fits `MAX_CHARS`: the index is * trimmed first (it is the cheapest to re-fetch with `wiki-query`), then * recent pages, then lessons. Owner threads are never cut. */ private fitToBudget; /** * `### Project wiki index` — one line per page, capped. */ private renderIndex; /** * `### Recently changed pages` — the most recently modified topic pages * with their title and summary. */ private renderRecentPages; /** * The agent's own recent entries in the project and global vault logs, * split into work records (#1349) and lessons. */ private ownLogEntries; /** * `### Your recent work (last N days)` — the agent's last work records, * one line each: what it did, for whom, how it ended. */ private renderRecentWork; /** * `### Your lessons (last N days)` — role knowledge and the agent's own * vault log entries, newest first, deduped, capped. */ private renderLessons; /** * `### Owner threads waiting on you` — threads where the owner's latest * message is unanswered, a promise of yours is standing, or a card is open. */ private renderOwnerThreads; private age; private clip; } //# sourceMappingURL=startup-briefing.service.d.ts.map