/**
 * Wire shapes for streamed model requests/events that cross the worker
 * boundary, plus structural guards. See shortcutXL/docs/migration/spec.md.
 */
export declare const ShortcutXLModelStreamEffortLevel: {
    readonly Low: "low";
    readonly Medium: "medium";
    readonly High: "high";
    readonly Max: "max";
};
export type ShortcutXLModelStreamEffortLevel = (typeof ShortcutXLModelStreamEffortLevel)[keyof typeof ShortcutXLModelStreamEffortLevel];
export declare const ShortcutXLModelStreamThinkingType: {
    readonly Adaptive: "adaptive";
    readonly Off: "off";
};
export type ShortcutXLModelStreamThinkingType = (typeof ShortcutXLModelStreamThinkingType)[keyof typeof ShortcutXLModelStreamThinkingType];
/**
 * Runtime operation labels forwarded as `X-LLM-Operation`.
 *
 * These are observability/billing categories, not endpoint names. Keep aligned
 * with shared `LLM_OPERATIONS` and backend `ALLOWED_LLM_OPERATIONS`.
 */
export declare const ShortcutXLLlmOperations: readonly ["chat", "compaction", "suggestions", "summarize", "file_naming", "formula_trace", "code_preview", "sentiment_analysis"];
export type ShortcutXLLlmOperation = (typeof ShortcutXLLlmOperations)[number];
export declare const ShortcutXLModelStreamMessageRole: {
    readonly Ai: "ai";
    readonly Human: "human";
    readonly System: "system";
    readonly Tool: "tool";
};
export type ShortcutXLModelStreamMessageRole = (typeof ShortcutXLModelStreamMessageRole)[keyof typeof ShortcutXLModelStreamMessageRole];
export declare const ShortcutXLAgentAssistantContentKind: {
    readonly Text: "text";
    readonly Thinking: "thinking";
    readonly ToolCall: "toolCall";
};
export type ShortcutXLAgentAssistantContentKind = (typeof ShortcutXLAgentAssistantContentKind)[keyof typeof ShortcutXLAgentAssistantContentKind];
export declare const ShortcutXLModelStreamStopReason: {
    readonly Aborted: "aborted";
    readonly Error: "error";
    readonly Length: "length";
    readonly Stop: "stop";
    readonly ToolUse: "toolUse";
};
export type ShortcutXLModelStreamStopReason = (typeof ShortcutXLModelStreamStopReason)[keyof typeof ShortcutXLModelStreamStopReason];
export declare const ShortcutXLModelStreamEventKind: {
    readonly Done: "done";
    readonly Error: "error";
    readonly Start: "start";
    readonly TextDelta: "textDelta";
    readonly TextEnd: "textEnd";
    readonly TextStart: "textStart";
    readonly ThinkingDelta: "thinkingDelta";
    readonly ThinkingEnd: "thinkingEnd";
    readonly ThinkingRedacted: "thinkingRedacted";
    readonly ThinkingStart: "thinkingStart";
    readonly ToolCallDelta: "toolCallDelta";
    readonly ToolCallEnd: "toolCallEnd";
    readonly ToolCallStart: "toolCallStart";
};
export type ShortcutXLModelStreamEventKind = (typeof ShortcutXLModelStreamEventKind)[keyof typeof ShortcutXLModelStreamEventKind];
export interface ShortcutXLAgentTextContent {
    readonly type: typeof ShortcutXLAgentAssistantContentKind.Text;
    readonly text: string;
}
export interface ShortcutXLAgentThinkingContent {
    readonly redacted: boolean;
    readonly thinking: string;
    readonly thinkingSignature: string;
    readonly type: typeof ShortcutXLAgentAssistantContentKind.Thinking;
}
export interface ShortcutXLAgentToolCallContent {
    readonly arguments: Record<string, unknown>;
    readonly id: string;
    readonly name: string;
    readonly type: typeof ShortcutXLAgentAssistantContentKind.ToolCall;
}
export type ShortcutXLAgentAssistantContent = ShortcutXLAgentTextContent | ShortcutXLAgentThinkingContent | ShortcutXLAgentToolCallContent;
export interface ShortcutXLAgentUsage {
    readonly cacheRead: number;
    readonly cacheWrite: number;
    readonly cost: {
        readonly cacheRead: number;
        readonly cacheWrite: number;
        readonly input: number;
        readonly output: number;
        readonly total: number;
    };
    /** Total input tokens, including cache read/write buckets when present. */
    readonly input: number;
    readonly output: number;
    readonly totalTokens: number;
}
/**
 * Stage of a stream-fetch failure surfaced by the runtime's `onFetchTrace`
 * hook. Distinguishes failure modes that aren't visible in the generic
 * recovery telemetry (which collapses everything into `server_error`).
 */
export declare const ShortcutXLModelStreamFetchStage: {
    /**
     * `fetch()` rejected before any `Response` was received — DNS failure,
     * CORS preflight failure, network unreachable, captive portal, WebView
     * cookie-isolation block. The opaque "Failed to fetch" / "Load failed".
     */
    readonly BeforeResponse: "before_response";
    /** Got a `Response` but `status` was outside 2xx. */
    readonly NonOkResponse: "non_ok_response";
    /** Response started but the SSE read failed or idle-timed out mid-stream. */
    readonly ResponseBody: "response_body";
};
export type ShortcutXLModelStreamFetchStage = (typeof ShortcutXLModelStreamFetchStage)[keyof typeof ShortcutXLModelStreamFetchStage];
/** Diagnostic payload emitted on every stream-fetch failure. */
export interface ShortcutXLModelStreamFetchTrace {
    readonly stage: ShortcutXLModelStreamFetchStage;
    readonly requestId: string;
    /** Origin-only stream endpoint, e.g. `https://api.shortcut.ai`; excludes path/query. */
    readonly requestOrigin?: string;
    /** UTF-8 byte length of the JSON request body. Body contents are never logged. */
    readonly requestBodyBytes?: number;
    /** Redacted request shape metadata for correlating failures without logging prompt content. */
    readonly model?: string;
    readonly effortLevel?: ShortcutXLModelStreamEffortLevel;
    readonly speed?: 'fast' | 'standard';
    readonly thinkingType?: ShortcutXLModelStreamThinkingType;
    readonly messageCount?: number;
    readonly toolCount?: number;
    readonly clientPlatform?: string;
    readonly fetchContext?: 'model_stream_worker';
    /** Header names only, never values. */
    readonly requestHeaderNames?: readonly string[];
    readonly hasAuthorizationHeader?: boolean;
    readonly hasSessionHeader?: boolean;
    readonly hasWorkspaceHeader?: boolean;
    /** 1-based stream attempt that failed. */
    readonly attempt: number;
    /** Maximum 1-based attempts allowed for this request. */
    readonly maxAttempts: number;
    /** True when the stream layer will retry this failure before surfacing it. */
    readonly willRetry: boolean;
    /** Delay before the next attempt. Present only when `willRetry` is true. */
    readonly retryDelayMs?: number;
    /** Wall-clock time from when the fetch (or body read) began to when it failed. */
    readonly timeToErrorMs: number;
    /** Raw response-body bytes read before the failure. Present for response-body traces. */
    readonly streamBytesReceived?: number;
    /** Parsed protocol events read before the failure. SSE comments are not counted. */
    readonly streamEventsReceived?: number;
    /** Time from response-body read start to first byte. Present after a byte is read. */
    readonly timeToFirstByteMs?: number;
    /** Time from response-body read start to first parsed protocol event. */
    readonly timeToFirstEventMs?: number;
    /** Time between the last body byte and the failure. Present after a byte is read. */
    readonly timeSinceLastByteMs?: number;
    /** Time between the last parsed protocol event and the failure. */
    readonly timeSinceLastEventMs?: number;
    /** `error.name` (e.g. `"TypeError"`, `"AbortError"`) — preserved verbatim. */
    readonly errorName?: string;
    readonly errorMessage: string;
    /** HTTP status — present only for `non_ok_response`. */
    readonly status?: number;
    /** True if the failure occurred while the abort signal was set. */
    readonly aborted: boolean;
    /** True if the request retried after a 401 refresh before failing. */
    readonly afterAuthRefresh: boolean;
}
export interface ShortcutXLModelStreamErrorDetails {
    readonly providerErrorType?: 'overloaded' | 'rate_limit' | 'unauthorized' | 'invalid_request' | 'internal' | 'network';
    readonly retryable?: boolean;
    readonly retryAfterMs?: number;
    readonly status?: number;
    /** Client-side transport stage when the browser fetch failed outside HTTP. */
    readonly transportFailureStage?: ShortcutXLModelStreamFetchStage;
}
export interface ShortcutXLAgentAssistantMessage {
    readonly api: string;
    readonly content: readonly ShortcutXLAgentAssistantContent[];
    readonly errorDetails?: ShortcutXLModelStreamErrorDetails;
    readonly errorMessage?: string;
    readonly model: string;
    readonly provider: string;
    readonly role: 'assistant';
    readonly stopReason: ShortcutXLModelStreamStopReason;
    readonly timestamp: number;
    readonly usage: ShortcutXLAgentUsage;
}
export interface ShortcutXLModelStreamToolCall {
    readonly arguments: string;
    readonly id: string;
    readonly name: string;
}
export interface ShortcutXLModelStreamMessage {
    readonly content: string;
    readonly role: ShortcutXLModelStreamMessageRole;
    readonly thinking?: string;
    readonly thinkingSignature?: string;
    readonly toolCallId?: string;
    readonly toolCalls?: readonly ShortcutXLModelStreamToolCall[];
}
export interface ShortcutXLModelStreamTool {
    readonly description: string;
    readonly name: string;
    readonly parameters: Record<string, unknown>;
}
export interface ShortcutXLModelStreamRequest {
    readonly agentMode?: string;
    readonly effortLevel?: ShortcutXLModelStreamEffortLevel;
    readonly fileAttachmentIds?: readonly string[];
    readonly initialFileId?: string;
    readonly interactionMode?: string;
    readonly llmOperation?: ShortcutXLLlmOperation;
    readonly maxTokens?: number;
    readonly messages: readonly ShortcutXLModelStreamMessage[];
    readonly model: string;
    readonly requestId: string;
    readonly userMessageId?: string;
    /**
     * Speed mode. Currently only `'fast'` is meaningful on Shortcut models
     * explicitly enabled for fast handling.
     * The proxy gates this server-side: `speed='fast'` for unsupported
     * models is silently dropped. See spec.md §7-A.
     */
    readonly speed?: 'fast' | 'standard';
    readonly thinkingType?: ShortcutXLModelStreamThinkingType;
    readonly tools?: readonly ShortcutXLModelStreamTool[];
}
interface ShortcutXLModelStreamEventBase<TKind extends ShortcutXLModelStreamEventKind> {
    readonly kind: TKind;
    readonly partial: ShortcutXLAgentAssistantMessage;
}
export type ShortcutXLModelStreamStartEvent = ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.Start>;
export interface ShortcutXLModelStreamTextStartEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.TextStart> {
    readonly contentIndex: number;
}
export interface ShortcutXLModelStreamTextDeltaEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.TextDelta> {
    readonly contentIndex: number;
    readonly delta: string;
}
export interface ShortcutXLModelStreamTextEndEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.TextEnd> {
    readonly contentIndex: number;
}
export interface ShortcutXLModelStreamThinkingStartEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.ThinkingStart> {
    readonly contentIndex: number;
}
export interface ShortcutXLModelStreamThinkingDeltaEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.ThinkingDelta> {
    readonly contentIndex: number;
    readonly delta: string;
}
export interface ShortcutXLModelStreamThinkingEndEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.ThinkingEnd> {
    readonly content: string;
    readonly contentIndex: number;
}
export interface ShortcutXLModelStreamThinkingRedactedEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.ThinkingRedacted> {
    readonly contentIndex: number;
}
export interface ShortcutXLModelStreamToolCallStartEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.ToolCallStart> {
    readonly contentIndex: number;
}
export interface ShortcutXLModelStreamToolCallDeltaEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.ToolCallDelta> {
    readonly contentIndex: number;
    readonly delta: string;
}
export interface ShortcutXLModelStreamToolCallEndEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.ToolCallEnd> {
    readonly contentIndex: number;
    readonly toolCall: ShortcutXLAgentToolCallContent;
}
export interface ShortcutXLModelStreamDoneEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.Done> {
    readonly message: ShortcutXLAgentAssistantMessage;
    readonly reason: typeof ShortcutXLModelStreamStopReason.Stop | typeof ShortcutXLModelStreamStopReason.ToolUse | typeof ShortcutXLModelStreamStopReason.Length;
}
export interface ShortcutXLModelStreamErrorEvent extends ShortcutXLModelStreamEventBase<typeof ShortcutXLModelStreamEventKind.Error> {
    readonly error: ShortcutXLAgentAssistantMessage;
    readonly reason: typeof ShortcutXLModelStreamStopReason.Aborted | typeof ShortcutXLModelStreamStopReason.Error;
}
export type ShortcutXLModelStreamEvent = ShortcutXLModelStreamDoneEvent | ShortcutXLModelStreamErrorEvent | ShortcutXLModelStreamStartEvent | ShortcutXLModelStreamTextDeltaEvent | ShortcutXLModelStreamTextEndEvent | ShortcutXLModelStreamTextStartEvent | ShortcutXLModelStreamThinkingDeltaEvent | ShortcutXLModelStreamThinkingEndEvent | ShortcutXLModelStreamThinkingRedactedEvent | ShortcutXLModelStreamThinkingStartEvent | ShortcutXLModelStreamToolCallDeltaEvent | ShortcutXLModelStreamToolCallEndEvent | ShortcutXLModelStreamToolCallStartEvent;
export declare function isShortcutXLModelStreamErrorDetails(value: unknown): value is ShortcutXLModelStreamErrorDetails;
/**
 * Default `ShortcutXLModelStreamErrorDetails` for a transport-level network
 * failure (fetch threw, connection dropped before HTTP response). Single
 * source of truth so callers don't hand-roll `{ providerErrorType: 'network',
 * retryable: true }` literals.
 */
export declare function networkErrorDetails(transportFailureStage?: ShortcutXLModelStreamFetchStage): ShortcutXLModelStreamErrorDetails;
/** SSE `error` event payload shape (snake_case fields from the backend). */
export interface StreamErrorPayload {
    readonly provider_error_type?: unknown;
    readonly retryable?: unknown;
    readonly retry_after_ms?: unknown;
    readonly status?: unknown;
    readonly message?: unknown;
}
/**
 * Parse a snake_case SSE/HTTP error payload into the camelCase
 * `ShortcutXLModelStreamErrorDetails`. Returns `undefined` only when every
 * input field is absent; otherwise returns a (possibly partial) envelope.
 * `fallbackStatus` is stamped when the payload omits `status`.
 */
export declare function parseStreamErrorPayload(payload: StreamErrorPayload | undefined, fallbackStatus?: number): ShortcutXLModelStreamErrorDetails | undefined;
/**
 * Extract the structured error payload from an HTTP error body. The backend
 * wraps it as either `{detail: {error: {...}}}` (FastAPI HTTPException) or
 * `{error: {...}}` — both shapes are surfaced as the inner `error` record.
 */
export declare function extractStructuredHttpErrorPayload(value: unknown): StreamErrorPayload | undefined;
export declare function isShortcutXLAgentAssistantMessage(value: unknown): value is ShortcutXLAgentAssistantMessage;
export declare function isShortcutXLModelStreamRequest(value: unknown): value is ShortcutXLModelStreamRequest;
export declare function isShortcutXLModelStreamEvent(value: unknown): value is ShortcutXLModelStreamEvent;
export {};
//# sourceMappingURL=model-stream.d.ts.map