/** * Context assembly engine. * Builds tailored context packages for agent tasks within token budgets. * Uses weighted multi-signal scoring: recency, relevance, confidence, warning boost. */ import { type SearchEngine } from "../embeddings/search.js"; import type { GraphEngine } from "./graph.js"; import type { PlanningBridge } from "./planning-bridge.js"; import type { AssembledContext, SummarizeResult, TwiningConfig, WhatChangedResult } from "../utils/types.js"; import type { IAgentStore, IBlackboardStore, IDecisionStore, IHandoffStore } from "../storage/interfaces.js"; export declare class ContextAssembler { private readonly blackboardStore; private readonly decisionStore; private readonly searchEngine; private readonly config; private readonly graphEngine; private readonly planningBridge; private readonly handoffStore; private readonly agentStore; /** In-memory log of last assembly time per agent (not persisted across restarts). */ private readonly assemblyLog; /** * Exact self-authorship signal (field D12): the ids BlackboardEngine * posted in this process. A timestamp-vs-process-start heuristic mislabels * CONCURRENT sessions sharing the store (the coordination case the lane * exists for), and agent_id is a role label, not an identity. Unset (e.g. * dashboard-constructed assemblers) means nothing is ever marked. */ private sessionPostIds; /** Wire the posting session's entry-id set (server.ts). */ setSessionPostIds(ids: ReadonlySet): void; constructor(blackboardStore: IBlackboardStore, decisionStore: IDecisionStore, searchEngine: SearchEngine | null, config: TwiningConfig, graphEngine?: GraphEngine | null, planningBridge?: PlanningBridge | null, handoffStore?: IHandoffStore | null, agentStore?: IAgentStore | null); /** Check if an agent has called assemble() recently (in this session). */ hasRecentAssembly(agentId: string): boolean; /** * Build tailored context for a specific task within a token budget. * Implements spec section 4.3 (twining_assemble). */ assemble(task: string, scope: string, maxTokens?: number, agentId?: string): Promise; /** * Assemble context and include a status summary inline. * Combines assemble + summarize into one call (P5.1). */ assembleWithStatus(task: string, scope: string, maxTokens?: number, agentId?: string): Promise<{ context: AssembledContext; status_summary: string; }>; /** * Format assembled context as structured markdown for LLM consumption. * Produces imperative sentences and numbered lists instead of raw JSON. */ static formatForLLM(ctx: AssembledContext, statusSummary?: string): string; /** * High-level summary of project or scope state. * Implements spec section 4.3 (twining_summarize). */ summarize(scope?: string): Promise; /** * Report changes since a given point in time. * Implements spec section 4.3 (twining_what_changed). */ whatChanged(since: string, scope?: string): Promise; /** * Compute graph connectivity boost for decisions (spec §5.5). * Decisions whose affected_files/symbols have more graph relations * to the scope get a higher boost (0.0 to 1.0). */ private computeGraphReachability; /** * Populate related_entities from the knowledge graph. * Finds entities matching the scope and gets their immediate neighbors. * Never throws — graph errors are silently caught to avoid breaking context assembly. */ private getRelatedEntities; /** Compute recency score using exponential decay. */ private recencyScore; /** Convert decision confidence to a numeric score. */ private confidenceScore; /** * Compute scope proximity: how close is a decision's scope to the task scope. * Exact match or child scope = 1.0, parent (1 level) = 0.7, grandparent+ = 0.4. */ static scopeProximity(taskScope: string, decisionScope: string): number; } //# sourceMappingURL=context-assembler.d.ts.map