import type { ChatResult, LlmMessage, LlmUsage, LlmProvider, ToolDef, ToolChoice } from './provider-base.js'; export declare function isAbort(err: unknown): boolean; type StreamOpts = { system?: string; tools?: ToolDef[]; toolChoice?: ToolChoice; signal: AbortSignal; timeoutMs?: number; model?: string; temperature?: number; maxTokens?: number; onUsage: (u: LlmUsage) => void; onPartialText?: (delta: string, totalSoFar: string) => void; }; /** * v1.2.112 — consume `provider.chatStream()` and synthesize a * ChatResult. The key win over `provider.chat()`: when the AbortSignal * fires mid-stream, we return the partial text + completed tool_calls * accumulated so far instead of an empty result. Tool_calls are * accumulated by `index`; entries that lack a `name` at abort time are * dropped (a partial tool_call is too risky to dispatch). Reasoning * trace (DeepSeek `reasoning_content`) is concatenated and passed * through so downstream UI can still render it. * * If the provider's stream impl produces no tool_call deltas but the * model wanted tool_use, the helper logs a warn and returns whatever * text + finishReason it saw. Caller (agent-loop) should treat * `finishReason='tool_use' with empty toolCalls` as a degenerate case * (rare; only happens when streaming is enabled against a provider * that hasn't extended its _callApiStream). */ export declare function streamThenBuffer(provider: LlmProvider, history: LlmMessage[], opts: StreamOpts): Promise; /** v1.2.138 — wrapper around streamThenBuffer that auto-retries on * transient first-token errors. Existing caller invariants are * preserved: success returns the ChatResult, abort propagates as-is, * non-transient errors propagate as-is, exhausted retries throw the * last error. Only retries when streamThenBuffer's outer error path * fires AND the error matches a known transient pattern. The * v1.2.123 "partial>0 → length recovery" path inside * streamThenBuffer remains untouched — it returns a normal * ChatResult that we forward without retry. */ export declare function streamWithFirstTokenRetry(provider: LlmProvider, history: LlmMessage[], opts: StreamOpts): Promise; export {}; //# sourceMappingURL=agent-loop-stream.d.ts.map