/** * history-extractor.ts * * 3-pass Memory Agent history extraction utilities. * Pass 0: truth channels → build ground-truth project state (no LLM) * Pass 1: activity channels (hub + deliverable + reference) → extract decisions/tasks with full context * Pass 2: spoke channels → connect to hub projects */ import type { NormalizedItem, ChannelConfig } from '../connectors/framework/types.js'; export interface HubContextEntry { project: string; workUnit?: string; assignedTo?: string; status?: string; } export interface ClassifiedItems { truth: NormalizedItem[]; activity: NormalizedItem[]; spoke: NormalizedItem[]; } export interface ProjectTruth { projects: Record; }>; }>; } export interface EntityObservationDraft { id: string; observation_type: 'generic' | 'author' | 'channel'; entity_kind_hint: 'project' | 'person' | 'organization' | 'work_item' | null; surface_form: string; normalized_form: string; lang: string | null; script: string | null; context_summary: string | null; related_surface_forms: string[]; timestamp_observed: number | null; scope_kind: 'project' | 'channel' | 'user' | 'global'; scope_id: string | null; extractor_version: string; embedding_model_version: string | null; source_connector: string; source_raw_db_ref: string | null; source_raw_record_id: string; } export declare function buildEntityObservations(items: NormalizedItem[], options: { extractorVersion: string; embeddingModelVersion: string | null; rawDbRefForSource?: (source: string, item?: NormalizedItem) => string | null; }): EntityObservationDraft[]; /** * Classify NormalizedItems into truth, activity, and spoke groups based on channel configs. * Items with role 'ignore' or no matching config are dropped. * Activity items (hub + deliverable + reference) are sorted by timestamp ascending. * * @param items - Normalized items to classify * @param channelConfigs - Keyed by source (e.g. 'chatwork'), then by channel name */ export declare function classifyItemsByRole(items: NormalizedItem[], channelConfigs: Record>, defaultRole?: ChannelConfig['role']): ClassifiedItems; /** * Build ground-truth project state from truth-role items (Pass 0). * No LLM needed — directly parses structured data from kanban_card and spreadsheet_row items. * * @param truthItems - NormalizedItems with role=truth */ export declare function buildProjectTruth(truthItems: NormalizedItem[]): ProjectTruth; /** * Group items by "${source}:${channel}" key. */ export declare function groupByChannel(items: NormalizedItem[]): Map; /** * Build an LLM prompt for activity channel extraction (Pass 1). * Includes truth context as a header so the agent can identify changes relative to ground truth. * * @param activity - Activity NormalizedItems (hub + deliverable + reference) * @param truth - Ground-truth project state from Pass 0 */ export declare function buildActivityExtractionPrompt(activity: NormalizedItem[], truth: ProjectTruth): string; /** * Build an LLM prompt for spoke channel extraction (Pass 2). * Includes hub context so the agent can connect spoke messages to known projects. * Optionally includes project truth for richer context. * * @param items - Spoke NormalizedItems * @param hubContext - Active project context from Pass 1 * @param truth - Optional ground-truth project state for richer context */ export declare function buildSpokeExtractionPrompt(items: NormalizedItem[], hubContext: HubContextEntry[], truth?: ProjectTruth): string; //# sourceMappingURL=history-extractor.d.ts.map