export interface QwenMessage { content?: Array<{ type: string; text?: string; }>; } export interface QwenEvent { /** 'user' frames carry qwen's own tool results (tool_result blocks). */ type?: 'system' | 'assistant' | 'user' | 'result'; subtype?: string; session_id?: string; message?: QwenMessage; /** Confirmed live (issue #182): on `result` events, usage is TOP-LEVEL * and flat, NOT nested under `message.usage.tokens` as the public docs * suggest. `assistant` events don't carry a top-level `usage` at all in * observed output. */ usage?: { input_tokens?: number; output_tokens?: number; }; error?: { message?: string; } | string; } /** * One parsed qwen stream-json event, normalized for incremental streaming. * - 'assistant': rawText is one whole assistant message (fences intact) for * end-of-turn tool-call parsing; text is the fence-stripped prose, * present only when non-empty. * May also carry `toolUses` (the same message's tool_use blocks). * - 'native': qwen's own tool calls (assistant tool_use blocks) or * results (user tool_result blocks) with no text alongside. Read from * qwen-code's headless adapter (Claude-compatible stream-json), not a * live run — no qwen install here. * - 'tool': liveness only — the spawn-time yield. * - 'meta': any other event that only carries a session id. */ export interface QwenStreamEvent { kind: 'assistant' | 'native' | 'tool' | 'meta'; text?: string; rawText?: string; toolName?: string; toolUses?: Array<{ id: string; name: string; input: unknown; }>; toolResults?: Array<{ id: string; output: unknown; isError: boolean; }>; sessionId?: string; } export interface TurnOutcome { sessionId?: string; exitCode: number; stderrTail: string; timedOut: boolean; /** True when the process was killed by STARTUP_GRACE_MS with no output — * likely stuck on a first-run interactive prompt headless mode can't answer. */ hangSuspected: boolean; inputTokens: number; outputTokens: number; error?: string; } /** * Normalize one parsed qwen wire event into a QwenStreamEvent (or null for * events that carry nothing new). Usage/error facts are written into * `outcome` since they apply to the whole turn, not to a single event. */ export declare function handleQwenEvent(ev: QwenEvent, outcome: Pick): QwenStreamEvent | null; /** Pure stream-json parser — exported for unit testing against fixture lines * built from Qwen Code's documented event schema (qwen-runner.test.ts). * Built on the same handleQwenEvent() the live streaming path uses. */ export declare function parseQwenEvents(lines: string[]): { texts: string[]; rawTexts: string[]; sessionId?: string; inputTokens: number; outputTokens: number; error?: string; }; //# sourceMappingURL=qwen-runner-parse.d.ts.map