import type { AttachmentsRecord } from "../../attachments/store.js";
import type { LanguageModelV2ToolResultOutput } from "@ai-sdk/provider";
import type { AiMode } from "@superblocksteam/library-shared/types";
import type { ModelMessage, LanguageModelUsage, AssistantModelMessage } from "ai";
export type { AttachmentsRecord };
/**
 * Globally unique identifier for a conversation context.
 */
export type ContextId = {
    /** Application identifier */
    appId: string;
    /** User identifier */
    userId: string;
    /** Context name */
    name: string;
};
/**
 * Summary for compacted tool calls.
 */
export interface CompactionSummary {
    /** Summary of the tool input (optional, only for large inputs) */
    input?: string;
    /** Summary of the tool output (required) */
    output: string;
    /** If true, this tool result should be protected from compaction (e.g., system skill reads) */
    protected?: boolean;
}
/**
 * Threshold for compacting tool call inputs.
 * Inputs larger than this (in characters) will be summarized or truncated.
 */
export declare const INPUT_COMPACTION_THRESHOLD_CHARS = 100;
export interface SuperblocksMetadata {
    /** True token count from LLM (set for assistant messages). */
    tokenCount?: number;
    /** Total input tokens used at the time of this assistant turn (cumulative context size). */
    cumulativeInputTokens?: number;
    timestamp: number;
    isSummary?: boolean;
    /** Tool summaries keyed by toolCallId. On assistant messages: input summaries. On tool messages: output summaries. */
    toolSummaries?: Record<string, string>;
    /** True if this tool message was summarized during phase 1 compaction. */
    summarized?: boolean;
    /** Protected tool results keyed by toolCallId. True means the result should not be compacted. */
    protected?: Record<string, boolean>;
}
export type StoredMessage = ModelMessage & {
    _superblocks?: SuperblocksMetadata;
};
export interface TokenUsage {
    input: number;
    output: number;
    cacheRead: number;
}
export interface CompactionResult {
    messages: StoredMessage[];
    phase1Applied: boolean;
    phase2Applied: boolean;
    tokensSaved: number;
}
export type CompactionPhase = "phase1" | "phase2";
/** Snapshot of the current mode state, used to rebuild context after compaction. */
export interface ModeState {
    mode: AiMode;
    planApproved?: boolean;
}
export interface CompactionCallbacks {
    onCompactionStart?: (phase: CompactionPhase, messageId: string) => void;
    onCompactionComplete?: (phase: CompactionPhase, messageId: string) => void;
}
/**
 * Serialized V2 context state for persistence.
 * Contains the version marker to distinguish from V1 records.
 */
export interface ContextRecordV2 {
    /** Version marker to distinguish from V1 records */
    version: 2;
    /** Conversation messages */
    messages: StoredMessage[];
    /** User-uploaded attachments (images, PDFs, text files) */
    attachments?: AttachmentsRecord;
}
export declare const PROVIDER_CACHE_MAX_BREAKPOINTS = 4;
export declare const PROVIDER_CACHE_MIN_CACHEABLE_TOKENS = 1024;
export declare const CACHE_BREAKPOINT_PROVIDER_OPTIONS: {
    bedrock: {
        cachePoint: {
            type: string;
        };
    };
    anthropic: {
        cacheControl: {
            type: string;
        };
    };
};
export interface CachingConfig {
    maxBreakpoints: number;
    minCacheableTokens: number;
}
/**
 * Normalizes a tool result output to ensure it conforms to LanguageModelV2ToolResultOutput.
 * This prevents validation errors when passing messages to the AI SDK.
 */
export declare function normalizeToolResultOutput(output: unknown): LanguageModelV2ToolResultOutput;
/**
 * Normalizes tool messages to ensure all tool results have valid output formats.
 */
export declare function normalizeToolMessage(msg: ModelMessage): ModelMessage;
/**
 * Normalizes provider options on reasoning blocks to work across both
 * Anthropic (Vertex) and Bedrock providers.
 */
export declare function normalizeReasoningProviderOptions(msg: AssistantModelMessage): void;
/**
 * Repairs broken tool calls in assistant messages.
 *
 * - Ensures tool-call inputs are valid objects (not null, undefined, or arrays)
 * - Removes tool-call parts without corresponding tool-result in the next message
 *
 * This prevents errors from LLM providers like:
 * - Bedrock: "messages.X.content.Y.tool_use.input: Input should be a valid dictionary"
 * - Vertex: "tool_use ids were found without tool_result blocks immediately after"
 */
export declare function repairBrokenToolCalls(msg: ModelMessage, index: number, messages: ModelMessage[]): ModelMessage;
export declare function stripUndefinedFromToolOutputs(msg: ModelMessage): ModelMessage;
export declare function toSdkMessages(messages: StoredMessage[]): ModelMessage[];
export declare function toStoredMessage(msg: ModelMessage, metadata?: Partial<SuperblocksMetadata>): StoredMessage;
export declare function extractTokenUsage(usage: LanguageModelUsage): TokenUsage;
//# sourceMappingURL=types.d.ts.map