import { type ContextEvidenceRef, type ContextItem, type ContextMemoryRef, type MemoryScope } from "./context-item.ts"; export type MemoryProviderSource = "pi_native" | "custom_local" | "external_provider" | "transcript_recall"; export type MemoryDurability = "ephemeral" | "working" | "durable"; export type MemoryItemKind = "user_preference" | "project_rule_candidate" | "design_decision" | "architecture_concept" | "procedure" | "fact" | "debugging_finding" | "invalidated_assumption" | "reference"; export interface MemoryProviderCapabilities { search: boolean; fetch: boolean; write: boolean; delete: boolean; shortTerm: boolean; longTerm: boolean; graph: boolean; citations: boolean; scopes: MemoryScope[]; /** True when queries stay on the local machine and do not leave Pi/user-controlled storage. */ localOnly: boolean; } export interface MemoryRef extends ContextMemoryRef { } export type MemoryEvidenceRef = ContextEvidenceRef | { type: "external"; id: string; providerId?: string; uri?: string; description?: string; }; export interface MemorySearchRequest { query: string; scope?: MemoryScope; kinds?: MemoryItemKind[]; maxResults: number; activeGoalId?: string; pathScope?: string[]; } export interface MemoryItem { id: string; providerId: string; source: MemoryProviderSource; kind: MemoryItemKind; scope: MemoryScope; durability: MemoryDurability; title?: string; summary: string; /** Optional full content. It is not prompt-included by default; callers must fetch/budget explicitly. */ content?: string; refs: MemoryRef[]; evidenceRefs: MemoryEvidenceRef[]; confidence?: "low" | "medium" | "high"; timestamp?: string; expiresAt?: string; conflict?: string; stale?: boolean; } export interface MemorySearchResult { item: MemoryItem; score: number; reason: string; } export interface MemoryProvider { id: string; label: string; source: MemoryProviderSource; capabilities: MemoryProviderCapabilities; search(request: MemorySearchRequest): Promise; fetch(ref: MemoryRef): Promise; proposeWrite?(request: MemoryWriteRequest): Promise; write?(approved: ApprovedMemoryWrite): Promise; } export interface MemoryWriteRequest { providerId: string; scope: MemoryScope; kind: MemoryItemKind; title?: string; summary: string; content?: string; evidenceRefs: MemoryEvidenceRef[]; sensitivity: "normal" | "private" | "secret"; reason: string; } export interface MemoryWritePreview { request: MemoryWriteRequest; wouldCreateRef?: MemoryRef; requiresApproval: boolean; rejectionReasons: MemoryPolicyRejectionReason[]; } export interface ApprovedMemoryWrite { request: MemoryWriteRequest; approvalId: string; approvedAt: string; approvedBy: "user" | "policy"; } export interface MemoryWriteResult { ref: MemoryRef; created: boolean; message: string; } export type MemoryPolicyRejectionReason = "provider_disabled" | "provider_not_searchable" | "provider_not_fetchable" | "provider_not_writable" | "provider_scope_unsupported" | "policy_scope_blocked" | "external_egress_blocked" | "query_payload_disabled" | "query_too_large" | "secret_like_query" | "secret_write_rejected" | "missing_evidence" | "durable_write_requires_approval" | "external_write_requires_approval" | "missing_approval"; export interface MemoryEgressPolicy { enabled: boolean; allowedScopes: MemoryScope[]; allowExternalEgress: boolean; allowQueryText: boolean; maxOutboundChars: number; redactSecretLikeText: boolean; } export declare const DEFAULT_EXTERNAL_MEMORY_EGRESS_POLICY: MemoryEgressPolicy; export declare const DEFAULT_LOCAL_MEMORY_EGRESS_POLICY: MemoryEgressPolicy; export declare function hasSecretLikeMemoryText(text: string): boolean; export declare function validateMemorySearchRequest(provider: Pick, policy: MemoryEgressPolicy, request: MemorySearchRequest): MemoryPolicyRejectionReason[]; export declare function previewMemoryWrite(provider: Pick, policy: MemoryEgressPolicy, request: MemoryWriteRequest): MemoryWritePreview; export declare function validateApprovedMemoryWrite(provider: Pick, policy: MemoryEgressPolicy, approved: ApprovedMemoryWrite): MemoryPolicyRejectionReason[]; export declare function sourceLabelForMemoryItem(item: MemoryItem): string; export declare function memorySearchResultToContextItem(result: MemorySearchResult, createdAtTurn: number): ContextItem; //# sourceMappingURL=memory-provider-contract.d.ts.map