UNPKG

@promptbook/node

Version:

Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action

48 lines (47 loc) 1.67 kB
/** * One parsed JSON event emitted by the Claude Code `--output-format stream-json` mode. */ export type ClaudeCodeOutputEvent = { readonly type?: string; readonly subtype?: string; readonly is_error?: boolean; readonly api_error_status?: number; readonly result?: string; readonly session_id?: string; readonly error?: string; readonly rate_limit_info?: { readonly status?: string; readonly resetsAt?: number; readonly rateLimitType?: string; }; readonly usage?: { readonly input_tokens?: number; readonly cache_creation_input_tokens?: number; readonly cache_read_input_tokens?: number; readonly output_tokens?: number; readonly server_tool_use?: { readonly web_search_requests?: number; readonly web_fetch_requests?: number; }; readonly service_tier?: string; readonly cache_creation?: { readonly ephemeral_1h_input_tokens?: number; readonly ephemeral_5m_input_tokens?: number; }; }; readonly total_cost_usd?: number; readonly message?: { readonly content?: ReadonlyArray<{ readonly type?: string; readonly text?: string; }>; }; }; /** * Parses all JSON lines from Claude Code output while ignoring shell prefixes and stack traces. */ export declare function parseClaudeCodeOutputEvents(output: string): readonly ClaudeCodeOutputEvent[]; /** * Finds the final Claude Code result event in a stream-json output blob. */ export declare function findClaudeCodeResultEvent(output: string): ClaudeCodeOutputEvent | undefined;