import { m as KodaXMessage } from './types.d-B1uGoVTE.js';

/**
 * @kodax-ai/agent Types
 *
 * 通用 Agent 类型定义
 */

type KodaXJsonPrimitive = string | number | boolean | null;
type KodaXJsonValue = KodaXJsonPrimitive | KodaXJsonValue[] | {
    [key: string]: KodaXJsonValue;
};
/**
 * Session error metadata - 会话错误元数据
 * Used for error recovery and session cleanup - 用于错误恢复和会话清理
 */
interface SessionErrorMetadata {
    /** Last error message - 最后的错误消息 */
    lastError?: string;
    /** Last error timestamp - 最后错误时间戳 */
    lastErrorTime?: number;
    /** Consecutive error count - 连续错误计数 */
    consecutiveErrors: number;
}
interface KodaXExtensionSessionRecord {
    id: string;
    extensionId: string;
    type: string;
    ts: number;
    data?: KodaXJsonValue;
    dedupeKey?: string;
}
type KodaXExtensionSessionState = Record<string, Record<string, KodaXJsonValue>>;
interface KodaXSessionEntryBase {
    id: string;
    parentId: string | null;
    timestamp: string;
}
interface KodaXSessionMessageEntry extends KodaXSessionEntryBase {
    type: 'message';
    message: KodaXMessage;
}
interface KodaXSessionCompactionEntry extends KodaXSessionEntryBase {
    type: 'compaction';
    summary: string;
    firstKeptEntryId?: string;
    tokensBefore?: number;
    tokensAfter?: number;
    artifactLedgerId?: string;
    reason?: string;
    details?: KodaXJsonValue;
    memorySeed?: KodaXCompactMemorySeed;
    /**
     * FEATURE_072: post-compact ledger summary + file-content messages that
     * are inlined after the compaction summary at slicer time
     * (`getSessionMessagesFromLineage`). Stored here so they leave the active
     * path automatically when a new compaction entry is appended.
     *
     * NOTE: attachments are emitted by the slicer, NOT by `getContextMessagesForEntry`
     * — preserving the latter's 1-to-1 contract that `entryMatchesContextMessage`
     * and FEATURE_073's future slicing both depend on.
     */
    postCompactAttachments?: readonly KodaXMessage[];
}
interface KodaXSessionBranchSummaryEntry extends KodaXSessionEntryBase {
    type: 'branch_summary';
    summary: string;
    fromId?: string;
    details?: KodaXJsonValue;
}
interface KodaXSessionLabelEntry extends KodaXSessionEntryBase {
    type: 'label';
    targetId: string;
    label?: string;
}
interface KodaXSessionArchiveMarkerEntry extends KodaXSessionEntryBase {
    type: 'archive_marker';
    /** Links to the corresponding batch in the .archive.jsonl sidecar file */
    archiveBatchId: string;
    /** Number of entries that were archived in this batch */
    archivedEntryCount: number;
    /** Brief summary of the archived content */
    summary: string;
}
type KodaXSessionEntry = KodaXSessionMessageEntry | KodaXSessionCompactionEntry | KodaXSessionBranchSummaryEntry | KodaXSessionLabelEntry | KodaXSessionArchiveMarkerEntry;
interface KodaXSessionArtifactLedgerEntry {
    id: string;
    kind: 'file_read' | 'file_modified' | 'file_created' | 'file_deleted' | 'path_scope' | 'search_scope' | 'command_scope' | 'check_result' | 'decision' | 'image_input' | 'tombstone';
    sourceTool?: string;
    action?: string;
    target: string;
    displayTarget?: string;
    summary?: string;
    sessionEntryId?: string;
    timestamp: string;
    metadata?: Record<string, KodaXJsonValue>;
}
interface KodaXCompactMemoryProgress {
    completed: string[];
    inProgress: string[];
    blockers: string[];
}
interface KodaXCompactMemorySeed {
    objective?: string;
    constraints: string[];
    progress: KodaXCompactMemoryProgress;
    keyDecisions: string[];
    nextSteps: string[];
    keyContext: string[];
    importantTargets: string[];
    tombstones: string[];
}
interface KodaXSessionLineage {
    version: 2;
    activeEntryId: string | null;
    entries: KodaXSessionEntry[];
}
interface KodaXSessionNavigationOptions {
    summarizeCurrentBranch?: boolean;
}
interface KodaXSessionTreeNode {
    entry: Exclude<KodaXSessionEntry, KodaXSessionLabelEntry>;
    children: KodaXSessionTreeNode[];
    label?: string;
    active: boolean;
}
type KodaXSessionScope = 'user' | 'managed-task-worker';
type KodaXSessionUiHistoryItemType = 'user' | 'assistant' | 'system' | 'thinking' | 'error' | 'event' | 'info' | 'hint';
interface KodaXSessionUiHistoryItem {
    type: KodaXSessionUiHistoryItemType;
    text: string;
    icon?: string;
    compactText?: string;
}
type KodaXSessionWorkspaceKind = 'detected' | 'managed';
interface KodaXSessionRuntimeInfo {
    canonicalRepoRoot?: string;
    workspaceRoot?: string;
    executionCwd?: string;
    branch?: string;
    workspaceKind?: KodaXSessionWorkspaceKind;
}
interface KodaXSessionData {
    messages: KodaXMessage[];
    title: string;
    gitRoot: string;
    runtimeInfo?: KodaXSessionRuntimeInfo;
    scope?: KodaXSessionScope;
    uiHistory?: KodaXSessionUiHistoryItem[];
    errorMetadata?: SessionErrorMetadata;
    extensionState?: KodaXExtensionSessionState;
    extensionRecords?: KodaXExtensionSessionRecord[];
    lineage?: KodaXSessionLineage;
    artifactLedger?: KodaXSessionArtifactLedgerEntry[];
}
interface KodaXSessionMeta {
    _type: 'meta';
    title: string;
    id: string;
    gitRoot: string;
    runtimeInfo?: KodaXSessionRuntimeInfo;
    createdAt: string;
    scope?: KodaXSessionScope;
    uiHistory?: KodaXSessionUiHistoryItem[];
    extensionState?: KodaXExtensionSessionState;
    extensionRecordCount?: number;
    artifactLedgerCount?: number;
    lineageVersion?: 2;
    activeEntryId?: string | null;
    lineageEntryCount?: number;
    activeMessageCount?: number;
    /** Error metadata for recovery - 错误元数据用于恢复 */
    errorMetadata?: SessionErrorMetadata;
}
/**
 * Extension-scoped persistence entry.
 *
 * Each entry belongs to a namespace (extensionId) and carries
 * a string key, a JSON-safe value, and an opaque version tag
 * used for optimistic concurrency control.
 */
interface KodaXExtensionStoreEntry {
    key: string;
    value: KodaXJsonValue;
    version: string;
    updatedAt: number;
}
/**
 * Extension persistence store interface (FEATURE_034 manual persistence).
 *
 * Implementations provide a durable key-value store scoped to a single
 * extension identity.  The store is independent of session lifecycle —
 * data survives across sessions and restarts.
 */
interface KodaXExtensionStore {
    /**
     * Read a single key.
     * Returns `undefined` when the key does not exist.
     */
    get(key: string): Promise<KodaXExtensionStoreEntry | undefined>;
    /**
     * Write a key-value pair.
     *
     * When `expectedVersion` is provided the write only succeeds when the
     * stored entry's version still matches (optimistic concurrency).
     * Returns the new entry on success, or `false` on version mismatch.
     */
    put(key: string, value: KodaXJsonValue, options?: {
        expectedVersion?: string;
    }): Promise<KodaXExtensionStoreEntry | false>;
    /**
     * Remove a key.
     * Returns `true` when the key existed and was removed.
     */
    delete(key: string): Promise<boolean>;
    /**
     * List all keys (optionally filtered by prefix).
     */
    list(options?: {
        prefix?: string;
    }): Promise<string[]>;
    /**
     * Clear all keys (optionally filtered by prefix).
     * Returns the number of entries removed.
     */
    clear(options?: {
        prefix?: string;
    }): Promise<number>;
}
interface KodaXSessionStorage {
    save(id: string, data: KodaXSessionData): Promise<void>;
    load(id: string): Promise<KodaXSessionData | null>;
    getLineage?(id: string): Promise<KodaXSessionLineage | null>;
    setActiveEntry?(id: string, selector: string, options?: KodaXSessionNavigationOptions): Promise<KodaXSessionData | null>;
    setLabel?(id: string, selector: string, label?: string): Promise<KodaXSessionData | null>;
    rewind?(id: string, selector?: string): Promise<KodaXSessionData | null>;
    fork?(id: string, selector?: string, options?: {
        sessionId?: string;
        title?: string;
    }): Promise<{
        sessionId: string;
        data: KodaXSessionData;
    } | null>;
    list?(gitRoot?: string): Promise<Array<{
        id: string;
        title: string;
        msgCount: number;
        runtimeInfo?: KodaXSessionRuntimeInfo;
    }>>;
    delete?(id: string): Promise<void>;
    deleteAll?(gitRoot?: string): Promise<void>;
}

export type { KodaXCompactMemoryProgress as K, SessionErrorMetadata as S, KodaXCompactMemorySeed as a, KodaXExtensionSessionRecord as b, KodaXExtensionSessionState as c, KodaXExtensionStore as d, KodaXExtensionStoreEntry as e, KodaXJsonValue as f, KodaXSessionArchiveMarkerEntry as g, KodaXSessionArtifactLedgerEntry as h, KodaXSessionBranchSummaryEntry as i, KodaXSessionCompactionEntry as j, KodaXSessionData as k, KodaXSessionEntry as l, KodaXSessionEntryBase as m, KodaXSessionLabelEntry as n, KodaXSessionLineage as o, KodaXSessionMessageEntry as p, KodaXSessionMeta as q, KodaXSessionNavigationOptions as r, KodaXSessionRuntimeInfo as s, KodaXSessionScope as t, KodaXSessionStorage as u, KodaXSessionTreeNode as v, KodaXSessionUiHistoryItem as w, KodaXSessionUiHistoryItemType as x, KodaXSessionWorkspaceKind as y };
