import type { NonNullableUsage } from './common.js'; /** Native delegates behavior to CLI defaults; custom applies partial SDK overrides. */ export type MemoryMode = 'native' | 'custom'; export type MemoryRootAccess = 'read' | 'read-write'; export type MemoryRoot = { /** Stable caller-defined identifier used in prompts, initialization, and generation results. */ id: string; /** Directory path on the machine running qodercli. */ path: string; /** Root access granted to memory agents. Defaults to "read-write". */ access?: MemoryRootAccess; /** Relative index path inside this root. Omit when every file, including MEMORY.md, is content. */ indexFile?: string; }; export type MemoryGenerationGateInput = { /** Current CLI session identifier. */ sessionId: string; /** Current model request identifier, when available. */ requestId?: string; /** Current logical turn request-set identifier, when available. */ requestSetId?: string; /** One-based SDK memory TurnComplete sequence number. */ turnIndex: number; /** Current CLI working directory. */ cwd: string; /** User prompt for the completed turn. */ prompt: string; /** Final assistant response for the completed turn. */ response: string; }; export type MemoryGenerationGateResult = { /** True starts generation; false emits a skipped result. */ run: boolean; /** Optional product-readable decision reason. */ reason?: string; }; export type SerializableMemoryGenerationOptions = { /** Defaults to true. */ enabled?: boolean; roots?: MemoryRoot[]; prompt?: string; turnComplete?: { /** Defaults to true when generation is enabled. */ enabled?: boolean; /** SDK process callback identifier used by the CLI control protocol. */ shouldGenerateCallbackId?: string; /** Callback timeout in milliseconds. */ timeoutMs?: number; /** Error/timeout result mapping for the product gate. */ onGateError?: 'skip' | 'report_failed'; }; }; export type MemoryConsumptionFile = { /** Stable caller-defined identifier used as the injected section name and in results. */ id: string; /** File path on the machine running qodercli. */ path: string; /** Defaults to false. A read failure aborts only when this is true and failureMode is "fail_query". */ required?: boolean; }; export type SerializableMemoryConsumptionOptions = { /** Defaults to true. */ enabled?: boolean; files?: MemoryConsumptionFile[]; maxTokens?: number; overflow?: 'truncate' | 'fail_query'; failureMode?: 'best_effort' | 'fail_query'; }; type SerializableMemoryConfigBase = { /** Marks this memory configuration as originating from the Agent SDK. */ requester: 'sdk'; /** Query-level PROJECT-scope override. Omit to use the SDK native default (`true`). */ projectScope?: boolean; /** Query-level USER-scope override. Omit to use the SDK native default (`true`). */ userScope?: boolean; }; export type SerializableMemoryConfig = SerializableMemoryConfigBase & ({ mode: 'native'; generation?: never; consumption?: never; } | { mode: 'custom'; generation?: SerializableMemoryGenerationOptions; consumption?: SerializableMemoryConsumptionOptions; }); export type EffectiveMemoryConfig = { enabled: boolean; requester: 'sdk'; mode?: MemoryMode; generationEnabled: boolean; turnCompleteEnabled: boolean; consumptionEnabled: boolean; roots: Array<{ id: string; access: MemoryRootAccess; }>; }; export type MemoryGenerationFailedFile = { rootId: string; path: string; error?: string; }; export type MemoryGenerationResult = { /** saved means every written file succeeded; partial means at least one file succeeded and one failed. */ status: 'saved' | 'partial' | 'no_change' | 'skipped' | 'failed'; attemptId: string; /** Human-readable diagnostic detail. */ reason?: string; origin: 'main_session' | 'turn_complete' | 'dream'; sourceRequestIds?: string[]; modelRequestIds?: string[]; writtenFiles: Array<{ rootId: string; path: string; }>; /** Files that were not written successfully after the attempt completed. */ failedFiles: MemoryGenerationFailedFile[]; /** True when a native or explicitly declared custom index file changed. */ indexUpdated?: boolean; /** True when at least one non-index memory content file changed. */ contentUpdated?: boolean; durationMs: number; usage?: NonNullableUsage; /** Missing server-side credits remain undefined; callers must not infer them. */ credits?: number; }; export type MemoryConsumptionResult = { status: 'success' | 'partial' | 'failed'; files: Array<{ id: string; path: string; status: 'loaded' | 'missing' | 'failed' | 'truncated'; /** Human-readable diagnostic detail. */ error?: string; }>; }; export {};