import type { SDKToolResultMeta } from '../protocol/messages.js'; export type SDKSessionInfo = { /** Unique session identifier (UUID). */ sessionId: string; /** Display title: custom title, auto summary, or first prompt. */ summary: string; /** Last modified time in ms since epoch. */ lastModified: number; /** File size in bytes. Only populated for local JSONL storage. */ fileSize?: number; /** Session title from a user rename or an AI-generated title. */ customTitle?: string; /** First meaningful user prompt in the session. */ firstPrompt?: string; /** Git branch recorded in the transcript. */ gitBranch?: string; /** Working directory for the session. */ cwd?: string; /** User-set session tag. */ tag?: string; /** Creation time in ms since epoch, from the first entry's timestamp. */ createdAt?: number; }; export type SessionMessage = { type: 'user' | 'assistant' | 'system'; uuid: string; session_id: string; message: unknown; parent_tool_use_id: string | null; /** * Agent ID of the subagent that spawned this subagent. Null for main-session * messages, depth-one subagents, and transcripts without this metadata. */ parent_agent_id: string | null; /** Present when qodercli persisted an Assistant synthesized from an API failure. */ isApiErrorMessage?: true; /** CLI-stamped display metadata for tool results that did not execute. */ tool_result_meta?: SDKToolResultMeta[]; /** * Structured tool result persisted by qodercli alongside a user * `tool_result` message. When one transcript entry contains multiple * `tool_result` blocks, this is an array aligned with those blocks by index. */ tool_use_result?: unknown; /** * ISO 8601 timestamp of when this transcript entry was written to the * jsonl file. Mirrors the on-disk `timestamp` field. Optional because * legacy sessions or synthetic entries may not carry it. * * Consumers like QoderWork rely on this field to project the original * conversation creation time into their UI / DB; without it they fall * back to the current wall-clock time, which makes restored history * appear to have been created "now". */ timestamp?: string; /** * Present on `system` entries (e.g. `'compact_boundary'`). Consumers can * key off this to render dividers / summary cards instead of regular * conversation bubbles. */ subtype?: string; /** * Mirrors the on-disk `compactMetadata` for `compact_boundary` entries. * Includes the trigger (manual/auto), token counts, and any preserved * segment pointers needed for graph reconstruction. */ compact_metadata?: { trigger?: 'manual' | 'auto'; pre_tokens?: number; post_tokens?: number; messages_summarized?: number; duration_ms?: number; preserved_segment?: { head_uuid: string; anchor_uuid: string; tail_uuid: string; }; }; }; type SessionStoreOptions = { sessionStore?: SessionStore; }; export type ListSessionsOptions = SessionStoreOptions & { dir?: string; limit?: number; offset?: number; includeWorktrees?: boolean; }; export type GetSessionInfoOptions = SessionStoreOptions & { dir?: string; }; export type GetSessionMessagesOptions = SessionStoreOptions & { dir?: string; limit?: number; offset?: number; /** * Include `system` entries in the result (compact boundaries, informational * notices). Defaults to false — only user/assistant are returned. */ includeSystemMessages?: boolean; }; export type GetSubagentMessagesOptions = SessionStoreOptions & { dir?: string; limit?: number; offset?: number; }; export type ListSubagentsOptions = SessionStoreOptions & { dir?: string; }; export type SessionMutationOptions = SessionStoreOptions & { dir?: string; }; export type ForkSessionOptions = SessionMutationOptions & { /** Slice transcript up to this message UUID (inclusive). */ upToMessageId?: string; /** Custom title for the fork. */ title?: string; }; export type ForkSessionResult = { sessionId: string; }; export type RewindFilesResult = { canRewind: boolean; error?: string; filesChanged?: string[]; insertions?: number; deletions?: number; }; /** Which parts of a local CLI session should be rewound. */ export type RewindScope = 'conversation' | 'files' | 'both'; /** Outcome of a full session rewind request. */ export type RewindStatus = 'ready' | 'success' | 'partial' | 'rejected'; export type RewindFileFailure = { path: string; error: string; }; /** * Result returned by {@link Query.rewind}. * * `ready` is only returned for a successful dry run. `partial` means the * conversation branch was rewound but one or more files could not be * restored; callers should surface the failures before submitting a new * edited input. */ export type RewindResult = { status: RewindStatus; targetUserMessageId: string; scope: RewindScope; retainedLeafId?: string | null; removedMessageIds?: string[]; filesChanged?: string[]; insertions?: number; deletions?: number; failedFiles?: RewindFileFailure[]; error?: string; }; import type { SessionStore } from '../session/session-store.js'; export {};