import { q as KodaXProviderCapabilityProfile, m as KodaXMessage, F as KodaXReasoningRequest, W as KodaXTokenUsage, g as KodaXContentBlock, f as KodaXCacheBoundary } from './types-chunks/types.d-B1uGoVTE.js';
export { K as KodaXAmaControllerDecision, a as KodaXAmaFanoutClass, b as KodaXAmaFanoutPolicy, c as KodaXAmaProfile, d as KodaXAmaTactic, e as KodaXAssuranceIntent, h as KodaXCustomProviderConfig, i as KodaXExecutionMode, j as KodaXExecutionPattern, k as KodaXHarnessProfile, l as KodaXImageBlock, n as KodaXModelDescriptor, o as KodaXMutationSurface, p as KodaXProtocolFamily, r as KodaXProviderConfig, s as KodaXProviderContextFidelity, t as KodaXProviderConversationSemantics, u as KodaXProviderEvidenceSupport, v as KodaXProviderLongRunningSupport, w as KodaXProviderMcpSupport, x as KodaXProviderMultimodalSupport, y as KodaXProviderSessionSupport, z as KodaXProviderStreamOptions, A as KodaXProviderToolCallingFidelity, B as KodaXProviderTransport, C as KodaXReasoningCapability, D as KodaXReasoningMode, E as KodaXReasoningOverride, G as KodaXRedactedThinkingBlock, H as KodaXReviewScale, I as KodaXRiskLevel, J as KodaXStreamResult, L as KodaXTaskActionability, M as KodaXTaskBudgetOverrides, N as KodaXTaskComplexity, O as KodaXTaskFamily, P as KodaXTaskRoutingDecision, Q as KodaXTaskType, R as KodaXTaskWorkIntent, S as KodaXTextBlock, T as KodaXThinkingBlock, U as KodaXThinkingBudgetMap, V as KodaXThinkingDepth, X as KodaXToolDefinition, Y as KodaXToolResultBlock, Z as KodaXToolResultContentItem, _ as KodaXToolResultImageItem, $ as KodaXToolResultTextItem, a0 as KodaXToolUseBlock } from './types-chunks/types.d-B1uGoVTE.js';
export { K as KODAX_DEFAULT_PROVIDER, a as KODAX_DEFAULT_THINKING_BUDGETS, b as KODAX_PROVIDERS, c as KODAX_PROVIDER_SNAPSHOTS, d as KODAX_REASONING_MODE_SEQUENCE, e as KODAX_REASONING_SAFETY_RESERVE, f as KodaXAnthropicCompatProvider, g as KodaXError, h as KodaXNetworkError, i as KodaXOpenAICompatProvider, j as KodaXProviderError, k as KodaXRateLimitError, l as KodaXToolCallIdError, P as ProviderName, m as buildReasoningOverrideKey, n as clampThinkingBudget, o as clearReasoningOverride, p as clearRuntimeModelProviders, q as createCustomProvider, r as getAvailableProviderNames, s as getCustomProvider, t as getCustomProviderList, u as getCustomProviderModels, v as getCustomProviderNames, w as getDefaultThinkingDepthForMode, x as getProvider, y as getProviderConfiguredCapabilityProfile, z as getProviderConfiguredReasoningCapability, A as getProviderList, B as getProviderModel, C as getProviderModels, D as getReasoningCapability, E as getRuntimeModelProvider, F as getRuntimeModelProviderNames, G as isCustomProviderName, H as isKnownProvider, I as isProviderConfigured, J as isProviderName, L as isReasoningEnabled, M as isRuntimeModelProviderName, N as loadReasoningOverride, O as mapDepthToOpenAIReasoningEffort, Q as normalizeReasoningRequest, R as reasoningCapabilityToOverride, S as reasoningOverrideToCapability, T as registerCustomProviders, U as registerModelProvider, V as resolveProvider, W as resolveThinkingBudget, X as saveReasoningOverride, Y as validateCustomProviderConfig } from './types-chunks/resolver.d-DX9au4NJ.js';
import { K as KodaXBaseProvider, a as CostTracker } from './types-chunks/cost-tracker.d-B6vMoLLF.js';
export { C as CostRate, D as DEFAULT_COST_RATES, b as KodaXOnRetryAfterCallback, c as KodaXRetryAfterEvent, P as ParseRetryAfterOptions, d as ProviderCostSummary, R as RetryAfterResult, e as RetryAfterSource, f as RetryRecord, S as SessionCostSummary, T as TokenUsageRecord, g as calculateCost, h as createCostTracker, i as extractHeadersFromError, j as formatCost, k as formatCostReport, l as getCostRate, m as getSummary, p as parseRetryAfter, r as recordRetry, n as recordUsage } from './types-chunks/cost-tracker.d-B6vMoLLF.js';
export { C as CapabilityKind, a as CapabilityProvider, b as CapabilityResult } from './types-chunks/capability.d-3C62G8Eq.js';
import '@anthropic-ai/sdk';
import 'openai';

/**
 * KodaX AI Constants
 *
 * AI 层常量配置 - Provider 模块共享的常量
 */
declare const KODAX_MAX_TOKENS = 32768;
/**
 * Capped default output token budget for long-output-prone providers
 * (e.g. zhipu-coding). Providers using this value request a modest budget
 * on every turn so generation finishes well under server-side kill
 * windows (Zhipu reportedly terminates streams around 8 minutes). If
 * the model hits `stop_reason: max_tokens` at this cap, the agent loop
 * escalates the same turn once to `KODAX_ESCALATED_MAX_OUTPUT_TOKENS`
 * (see `coding/src/agent.ts` max_tokens handler).
 */
declare const KODAX_CAPPED_MAX_OUTPUT_TOKENS = 32000;
/**
 * One-shot escalated budget used by the agent loop when a capped turn
 * returns `stop_reason: max_tokens`. The next stream call in the same
 * logical turn is issued with this value. Set once per turn via the
 * provider's public `setMaxOutputTokensOverride`; auto-cleared on the
 * next successful response in `base.ts withRateLimit`.
 */
declare const KODAX_ESCALATED_MAX_OUTPUT_TOKENS = 64000;
declare const KODAX_API_MIN_INTERVAL = 0.5;

interface NormalizedKodaXProviderCapabilityProfile extends KodaXProviderCapabilityProfile {
    contextFidelity: NonNullable<KodaXProviderCapabilityProfile['contextFidelity']>;
    toolCallingFidelity: NonNullable<KodaXProviderCapabilityProfile['toolCallingFidelity']>;
    sessionSupport: NonNullable<KodaXProviderCapabilityProfile['sessionSupport']>;
    longRunningSupport: NonNullable<KodaXProviderCapabilityProfile['longRunningSupport']>;
    multimodalSupport: NonNullable<KodaXProviderCapabilityProfile['multimodalSupport']>;
    evidenceSupport: NonNullable<KodaXProviderCapabilityProfile['evidenceSupport']>;
}
declare function normalizeCapabilityProfile(profile: KodaXProviderCapabilityProfile): NormalizedKodaXProviderCapabilityProfile;

declare function getCodexCliDefaultModel(): string;
declare function getGeminiCliDefaultModel(): string;
declare function getCodexCliKnownModels(): string[];
declare function getGeminiCliKnownModels(): string[];

/**
 * Shared parser for streamed tool_use input across all provider transports.
 *
 * Why this exists: when a provider hits `stop_reason: max_tokens`
 * (Anthropic) or `finish_reason: length` (OpenAI-compat) during a
 * tool_use turn, the accumulated `arguments` / `input_json_delta`
 * buffer is truncated mid-JSON. Two compat paths previously diverged:
 *
 *   - anthropic.ts: strict → partial-json salvage → {}
 *   - openai.ts:    strict → {} (lost the partial work)
 *
 * Centralising in one helper means the OpenAI path (deepseek-v4,
 * pay-as-you-go kimi/qwen/zhipu, plus any custom provider extending
 * KodaXOpenAICompatProvider) gets the same recovery as Anthropic-compat.
 *
 * Salvage strategy verified by deepseek-v4 bench (flash + pro, 6
 * truncation runs at 800-8000 max_tokens): all real-world truncations
 * land mid-string in the largest field with clean byte boundaries (no
 * mid-multibyte, no mid-`\uXXXX` escape, no lone backslash). partial-json
 * recovers a usable Record in 100% of observed cases.
 */
/**
 * Parse a tool_use input buffer with three-stage recovery.
 *
 * Stages:
 *   1. strict `JSON.parse` — fast path for the 99% complete case.
 *   2. `partial-json` salvage — closes open strings/brackets and
 *      returns whatever prefix was parseable. Lets the agent loop
 *      surface concrete partial work (e.g. half a `write` payload)
 *      to the model on the next turn instead of pretending the call
 *      had no input.
 *   3. empty `{}` — last-resort fallback for total garbage.
 *
 * Always returns a plain object so the caller can construct a valid
 * `KodaXToolUseBlock` without further type guards.
 */
declare function parseToolInputWithSalvage(raw: string | undefined | null): Record<string, unknown>;

/**
 * sideQuery — independent one-shot LLM invocation.
 *
 * Used by features that need a clean LLM call outside the main agent loop.
 * The auto mode classifier (FEATURE_092) is the first consumer; future
 * users include compaction, title generation, and SA mutation reflection.
 *
 * Constraints (deliberate):
 *   - tools=[] hardcoded — sideQuery is single-turn, no tool loop
 *   - text-only output — tool_use blocks from the model produce stopReason='error'
 *   - independent timeout (default 30s; classifier overrides to ~8s)
 *   - independent cost bucket via querySource (mapped to TokenUsageRecord.role)
 *
 * Failure handling: never throws. Timeout, abort, provider error, and
 * unexpected tool_use all produce a result with stopReason='timeout' /
 * 'aborted' / 'error' so callers implement their own degradation.
 */

type SideQueryStopReason = 'end_turn' | 'max_tokens' | 'timeout' | 'aborted' | 'error';
interface SideQueryRequest {
    readonly provider: KodaXBaseProvider;
    readonly model: string;
    readonly system: string;
    readonly messages: readonly KodaXMessage[];
    readonly reasoning?: KodaXReasoningRequest;
    readonly timeoutMs?: number;
    readonly abortSignal?: AbortSignal;
    readonly querySource: string;
    readonly costTracker?: CostTracker;
}
interface SideQueryResult {
    readonly text: string;
    readonly usage: KodaXTokenUsage;
    readonly costTracker?: CostTracker;
    readonly stopReason: SideQueryStopReason;
    readonly error?: Error;
}
declare function sideQuery(req: SideQueryRequest): Promise<SideQueryResult>;

/**
 * KodaX Cache Control — FEATURE_116 (v0.7.37)
 *
 * Helpers for inserting and lowering `KodaXCacheBoundary` markers across
 * the prompt assembly path. The two halves of the contract:
 *
 *   producer side  — `insertCacheBoundary(blocks, hint)` appends a
 *                    boundary to the end of any stable prefix (system
 *                    prompt blocks, role prompt blocks, …).
 *   consumer side  — `lowerCacheBoundaries(blocks, mode)` is called by
 *                    a provider base class right before serialisation:
 *                      - `attach`: write `cache_control` onto the block
 *                        immediately before each boundary, then drop the
 *                        boundaries (Anthropic-compat path).
 *                      - `strip`:  drop the boundaries with no further
 *                        action (OpenAI-compat / ACP CLI bridge path).
 *
 * The boundary marker is purely client-side and MUST be removed before
 * a request is sent over the wire. Provider subclasses do nothing —
 * lowering happens once per base class in `KodaXAnthropicCompatProvider`,
 * `KodaXOpenAICompatProvider`, and `KodaXAcpProvider`.
 */

/**
 * Block shape Anthropic accepts where a `cache_control` field can be
 * legally attached. Used in `lowerCacheBoundaries` mode `'attach'` to
 * mark the preceding block as a cache prefix.
 */
interface KodaXAnthropicCacheableBlock {
    type: string;
    cache_control?: {
        type: 'ephemeral';
    };
    [key: string]: unknown;
}
type KodaXCacheLowerMode = 'attach' | 'strip';
/**
 * Append a cache-boundary marker to a block array. Idempotent: if the
 * last block is already a boundary with the same hint, the array is
 * returned unchanged (avoids accidental double-marking when the same
 * stable prefix is composed twice).
 */
declare function insertCacheBoundary<T extends KodaXContentBlock>(blocks: readonly T[], hint?: KodaXCacheBoundary['hint']): readonly (T | KodaXCacheBoundary)[];
/**
 * Type-guard. Cheap to call repeatedly during lowering.
 *
 * Structural narrowing rather than just `type === 'cache-boundary'`:
 * the block must carry no fields beyond `type` and the optional `hint`.
 * This prevents an external wire payload that happens to carry
 * `type: 'cache-boundary'` plus other fields (a coincidental name
 * collision) from being silently stripped during lowering.
 */
declare function isCacheBoundary(block: unknown): block is KodaXCacheBoundary;
/**
 * Provider-base-class entry point. Walks the block array once.
 *
 * - `mode === 'attach'`:  for each boundary, set
 *   `cache_control: { type: 'ephemeral' }` on the immediately preceding
 *   non-boundary block, then drop the boundary itself. If a boundary is
 *   the first block (no predecessor) it is silently dropped — there is
 *   nothing to attach to. If multiple boundaries land back-to-back, only
 *   the predecessor of the *first* one in the run is marked (the others
 *   collapse, since they would all attach to the same predecessor).
 *
 * - `mode === 'strip'`:  drop every boundary. No `cache_control` is
 *   added. Used by adapters whose wire format does not expose a
 *   client-side cache marker (OpenAI-compat, ACP CLI bridge).
 *
 * Always returns a NEW array (never mutates input — the caller may hold
 * references to the original payload for diagnostics).
 */
declare function lowerCacheBoundaries<T extends KodaXAnthropicCacheableBlock>(blocks: readonly (T | KodaXCacheBoundary)[], mode: KodaXCacheLowerMode): T[];
/**
 * Drop every cache boundary from a block array without attaching any
 * cache marker. Convenience wrapper for `lowerCacheBoundaries(blocks, 'strip')`
 * for callers that only need the strip behaviour.
 *
 * Generic bound is intentionally loose (`{ type: string }`) so the helper
 * is callable both at the KodaX-internal level (KodaXContentBlock arrays)
 * and at the provider-wire level (Anthropic-compat / OpenAI-compat block
 * shapes that include extra wire fields).
 */
declare function stripCacheBoundaries<T extends {
    type: string;
}>(blocks: readonly (T | KodaXCacheBoundary)[]): T[];

export { CostTracker, KODAX_API_MIN_INTERVAL, KODAX_CAPPED_MAX_OUTPUT_TOKENS, KODAX_ESCALATED_MAX_OUTPUT_TOKENS, KODAX_MAX_TOKENS, KodaXBaseProvider, KodaXCacheBoundary, KodaXContentBlock, KodaXMessage, KodaXProviderCapabilityProfile, KodaXReasoningRequest, KodaXTokenUsage, getCodexCliDefaultModel, getCodexCliKnownModels, getGeminiCliDefaultModel, getGeminiCliKnownModels, insertCacheBoundary, isCacheBoundary, lowerCacheBoundaries, normalizeCapabilityProfile, parseToolInputWithSalvage, sideQuery, stripCacheBoundaries };
export type { KodaXAnthropicCacheableBlock, KodaXCacheLowerMode, SideQueryRequest, SideQueryResult, SideQueryStopReason };
