import type { StorageProvider } from '../storage/storage-provider.js'; export type MemoryClass = 'TRANSIENT' | 'LOCAL' | 'DECISION' | 'POLICY' | 'COPILOT_MEMORY' | 'FORBIDDEN'; export type MemoryLoadGuidance = 'ALWAYS' | 'ON-DEMAND' | 'ARCHIVE' | 'NEVER'; export interface MemoryGovernanceConfig { version: 1; defaultProvider: 'local' | 'hostInjectedCopilotAdapter' | 'copilot'; promptOnlyFallback: true; externalProviders: { hostInjectedCopilotAdapter: { enabled: boolean; requireApproval: boolean; }; }; policy: { rejectForbidden: true; rejectTransientDurableWrites: true; auditContent: false; auditMaxBytes: number; auditMaxArchives: number; }; } export interface MemoryClassification { class: MemoryClass; allowed: boolean; reason: string; destination: 'none' | 'local' | 'decision-inbox' | 'policy-inbox' | 'external-semantic'; loadGuidance: MemoryLoadGuidance; } export interface MemoryWriteRequest { content: string; title?: string; author?: string; requestedClass?: MemoryClass; approved?: boolean; metadata?: Record; } export interface MemoryWriteResult { stored: boolean; id?: string; classification: MemoryClassification; path?: string; } export interface MemorySearchResult { id: string; class: MemoryClass; loadGuidance: MemoryLoadGuidance; title: string; path: string; snippet: string; provider?: string; score?: number; } export interface MemoryAuditRecord { timestamp: string; action: 'classify' | 'write' | 'reject' | 'promote' | 'delete' | 'search' | 'configure' | 'provider-error'; id?: string; class?: MemoryClass; title?: string; path?: string; reason?: string; actor?: string; provider?: string; } export interface CopilotMemoryProviderWriteRequest { content: string; title: string; author?: string; metadata?: Record; classification: MemoryClassification; } export interface CopilotMemoryProviderWriteResult { id: string; path?: string; } export interface CopilotMemoryProviderSearchResult { id: string; title: string; snippet: string; path?: string; } export interface MemoryProviderSearchResult extends CopilotMemoryProviderSearchResult { class: MemoryClass; loadGuidance: MemoryLoadGuidance; score?: number; } export interface CopilotMemoryProviderClient { write(request: CopilotMemoryProviderWriteRequest): Promise; search(query: string): Promise; delete(id: string): Promise; } export interface MemoryProviderStatus { id: string; name: string; available: boolean; reason?: string; } /** * Generic external memory provider contract. * * Implementations receive only pre-classified, non-forbidden, non-transient * memory. The {@link LocalMemoryStore} enforces governance before routing * to any registered provider. */ export interface MemoryProvider { readonly id: string; readonly name: string; /** Memory classes this provider is designed to store and retrieve. */ readonly supportedClasses: ReadonlyArray; status(): Promise; write(request: CopilotMemoryProviderWriteRequest): Promise; search(query: string): Promise; delete(id: string): Promise; } /** * MemPalace — in-memory test double for an external spatial memory provider. * * Models a "memory palace" (method of loci) where memories are stored at * named loci. In production this would be replaced by a real spatial/external * memory service. Set `metadata.locus` on a write request to tag the * destination locus; defaults to `'default'`. * * Accepts: LOCAL, DECISION, POLICY. * Never receives FORBIDDEN, TRANSIENT, or COPILOT_MEMORY (filtered upstream). */ export declare class MemPalaceMemoryProvider implements MemoryProvider { private readonly maxEntries; readonly id = "mempalace"; readonly name = "MemPalace"; readonly supportedClasses: ReadonlyArray; private readonly loci; constructor(maxEntries?: number); status(): Promise; write(request: CopilotMemoryProviderWriteRequest): Promise; search(query: string): Promise; delete(id: string): Promise; /** Number of stored loci entries — for test introspection only. */ get size(): number; } /** * IndexServer — in-memory test double for a governed knowledge/instruction catalog. * * Models a server-side index of stable instructions and reference knowledge. * In production this would be replaced by a real embedding-search or BM25 index. * Set `metadata.topic` on a write request to tag the catalog entry; defaults to * the memory class (lowercased). * * Accepts: LOCAL, DECISION, POLICY. * Never receives FORBIDDEN, TRANSIENT, or COPILOT_MEMORY (filtered upstream). */ export declare class IndexServerMemoryProvider implements MemoryProvider { private readonly maxEntries; readonly id = "indexserver"; readonly name = "IndexServer"; readonly supportedClasses: ReadonlyArray; private readonly catalog; constructor(maxEntries?: number); status(): Promise; write(request: CopilotMemoryProviderWriteRequest): Promise; search(query: string): Promise; delete(id: string): Promise; /** Number of catalog entries — for test introspection only. */ get size(): number; } export interface LocalMemoryStoreOptions { rootKind?: 'project' | 'squad'; hostInjectedCopilotAdapterClient?: CopilotMemoryProviderClient; /** @deprecated Use hostInjectedCopilotAdapterClient. */ copilotMemoryClient?: CopilotMemoryProviderClient; /** * Optional additional external memory providers. * Each provider receives writes/searches for its supported memory classes * AFTER governance classification. FORBIDDEN and TRANSIENT content never * reaches these providers. Results are merged with local search results. */ registeredProviders?: MemoryProvider[]; } export declare const REAL_COPILOT_UNAVAILABLE_REASON = "Real Copilot Memory API unavailable: no concrete callable API was found in installed @github/copilot SDK/tooling. Squad will not fake provider=copilot; use hostInjectedCopilotAdapter only when a host supplies a client."; export declare class HostInjectedCopilotMemoryAdapter { private readonly client?; constructor(client?: CopilotMemoryProviderClient | undefined); isAvailable(): boolean; write(request: CopilotMemoryProviderWriteRequest): Promise; search(query: string): Promise; delete(id: string): Promise; private requireClient; } export declare function ensureMemoryGovernanceDefaults(storage: StorageProvider, projectRoot: string): Promise; export declare class LocalMemoryStore { private readonly storage; private readonly squadDir; private readonly copilotProvider; private readonly registeredProviders; /** * Async mutex tail for index read-modify-write operations. * Each caller enqueues behind the current tail so concurrent writes * are serialized without OS-level file locking. */ private indexLockTail; constructor(storage: StorageProvider, rootDir: string, options?: LocalMemoryStoreOptions); /** * Serialize all index read-modify-write operations. * * All callers that do readIndex() → mutate → writeIndex() must go through * this method so concurrent writes within the same store instance cannot * interleave and lose entries. The critical section is purely async * (no thread blocking), so this is safe in Node.js single-thread land. */ private withIndexLock; classify(request: Pick, options?: { audit?: boolean; actor?: string; title?: string; }): Promise; write(request: MemoryWriteRequest): Promise; search(query: string): Promise; promote(id: string, targetClass: Exclude, actor?: string): Promise; delete(id: string, actor?: string): Promise; providerStatus(): Promise<{ defaultProvider: MemoryGovernanceConfig['defaultProvider']; realCopilotMemory: { available: false; configured: boolean; reason: string; }; hostInjectedCopilotAdapter: MemoryGovernanceConfig['externalProviders']['hostInjectedCopilotAdapter'] & { clientAvailable: boolean; configured: boolean; }; registeredProviders: MemoryProviderStatus[]; }>; configureHostInjectedCopilotAdapter(options: { enabled: boolean; requireApproval?: boolean; defaultProvider?: Exclude; actor?: string; }): Promise; configureCopilotProvider(options: { enabled: boolean; adapter?: 'host' | 'hostInjectedCopilotAdapter'; requireApproval?: boolean; defaultProvider?: MemoryGovernanceConfig['defaultProvider']; actor?: string; }): Promise; auditLog(): Promise; private ensureInitialized; private readConfig; private readIndex; /** * Best-effort backup of a corrupt index file. * Writes the raw content to a `.corrupt` path alongside the index. * Failure to write the backup is suppressed so callers see the original error. */ private backupCorruptIndex; private writeIndex; private audit; private rotateAuditIfNeeded; private destinationPath; private renderMemoryFile; private absoluteFromEntryPath; private updateMemoryFileMetadata; } //# sourceMappingURL=index.d.ts.map