import type { AgentContextCandidate, AgentContextOutcomeStatus } from './types.js'; export interface AgentContextRequest { readonly task: string; readonly projectId?: string; readonly path?: string; readonly operation?: string; readonly phase?: string; readonly sessionId?: string; readonly charBudget?: number; readonly language?: 'zh-CN' | 'en'; } export interface AgentContextManifestItem { readonly id: string; readonly expansionId: string; readonly owner: string; readonly memoryType: AgentContextCandidate['memoryType']; readonly state: AgentContextCandidate['state']; readonly title: string; readonly summary: string; readonly sourceType: string; readonly whyApplied: string; } export interface AgentContextApplicationRecord { readonly applicationId: string; readonly candidateId: string; readonly candidateDigest: string; readonly owner: string; readonly scope: 'user' | 'project'; readonly projectId?: string; readonly memoryType: AgentContextCandidate['memoryType']; /** Immutable display snapshot so an application stays explainable after its source changes. */ readonly candidateState?: AgentContextCandidate['state']; readonly candidateTitle?: string; readonly candidateSummary?: string; readonly episodeId: string; readonly sessionId?: string; readonly task: string; readonly path?: string; readonly operation?: string; readonly phase?: string; readonly whyApplied: string; readonly delivery: 'full' | 'manifest'; readonly appliedAt: string; readonly appliedEventDispatchedAt?: string; readonly outcome?: AgentContextOutcomeStatus; readonly outcomeRevision?: number; readonly outcomeEvents?: readonly AgentContextOutcomeEvent[]; } export interface AgentContextOutcomeEvent { readonly revision: number; readonly status: AgentContextOutcomeStatus; readonly previousStatus?: AgentContextOutcomeStatus; readonly occurredAt: string; readonly dispatchedAt?: string; readonly evidence?: AgentContextOutcomeEvidence; } /** Host-reported adoption evidence; a passing task alone does not establish use. */ export interface AgentContextOutcomeEvidence { readonly decision: string; readonly verification: { readonly command: string; readonly success: boolean; }; } export interface AgentContextOutcomeUpdate { readonly changed: boolean; readonly previousOutcome?: AgentContextOutcomeStatus; readonly record: AgentContextApplicationRecord; } export interface AgentContextApplicationStore { list(candidateId?: string): Promise; append(record: AgentContextApplicationRecord): Promise; setOutcome(applicationId: string, outcome: AgentContextOutcomeStatus, expectedProjectId?: string, evidence?: AgentContextOutcomeEvidence): Promise; markAppliedEventDispatched(applicationId: string, dispatchedAt?: string): Promise; markOutcomeEventDispatched(applicationId: string, revision: number, dispatchedAt?: string): Promise; } export interface AgentContextApplicationStorage { read(): Promise; write(value: unknown): Promise; withLock?(operation: () => Promise): Promise; } export declare class MemoryAgentContextApplicationStore implements AgentContextApplicationStore { private records; list(candidateId?: string): Promise; append(record: AgentContextApplicationRecord): Promise; setOutcome(applicationId: string, outcome: AgentContextOutcomeStatus, expectedProjectId?: string, evidence?: AgentContextOutcomeEvidence): Promise; markAppliedEventDispatched(applicationId: string, dispatchedAt?: string): Promise; markOutcomeEventDispatched(applicationId: string, revision: number, dispatchedAt?: string): Promise; } export declare class StorageAgentContextApplicationStore implements AgentContextApplicationStore { private readonly storage; private queue; constructor(storage: AgentContextApplicationStorage); list(candidateId?: string): Promise; append(record: AgentContextApplicationRecord): Promise; setOutcome(applicationId: string, outcome: AgentContextOutcomeStatus, expectedProjectId?: string, evidence?: AgentContextOutcomeEvidence): Promise; markAppliedEventDispatched(applicationId: string, dispatchedAt?: string): Promise; markOutcomeEventDispatched(applicationId: string, revision: number, dispatchedAt?: string): Promise; private read; private serialized; } export interface AgentContextSelection { readonly episodeId: string; readonly coreMemory: readonly AgentContextCandidate[]; readonly activePolicies: readonly AgentContextCandidate[]; readonly manifest: readonly AgentContextManifestItem[]; readonly applications: readonly AgentContextApplicationRecord[]; readonly text: string; readonly expandHint: string; } export interface AgentContextExpansion { readonly id: string; readonly title: string; readonly content: string; readonly whyApplied: string; readonly sources: AgentContextCandidate['sources']; readonly verification: AgentContextCandidate['verification']; } export interface ContextDirectorOptions { readonly applications?: AgentContextApplicationStore; readonly now?: () => Date; readonly defaultCharBudget?: number; } export declare class ContextDirector { private readonly applications; private readonly now; private readonly defaultCharBudget; private readonly delivered; constructor(options?: ContextDirectorOptions); select(values: readonly AgentContextCandidate[], request: AgentContextRequest): Promise; expand(values: readonly AgentContextCandidate[], id: string, request: AgentContextRequest): AgentContextExpansion | null; recordOutcome(applicationId: string, outcome: AgentContextOutcomeStatus, expectedProjectId?: string, evidence?: AgentContextOutcomeEvidence): Promise; applicationHistory(candidateId?: string): Promise; private score; } export declare function renderAgentContext(coreMemory: readonly AgentContextCandidate[], activePolicies: readonly AgentContextCandidate[], manifest: readonly AgentContextManifestItem[], expandHint: string, applications?: readonly AgentContextApplicationRecord[], includeUsageHint?: boolean): string; export declare function whyCandidateApplied(candidate: AgentContextCandidate, request: AgentContextRequest, history?: readonly AgentContextApplicationRecord[]): string; export declare function contextExpansionId(owner: string, candidateId: string): string; export declare function parseContextExpansionId(value: string): { readonly owner: string; readonly candidateId: string; } | null; export declare function contextOutcomeTargetIds(unitIds: readonly string[] | undefined, owner: string): string[]; //# sourceMappingURL=context-director.d.ts.map