import type { ContentBlockParam } from '@anthropic-ai/sdk/resources'; import type { AgentConfig } from './types/config-types.js'; import type { ToolFailureClass } from './trace/types.js'; export interface ProviderSessionInfo { sessionId: string; model?: string; permissionMode?: string; cwd?: string; tools?: string[]; slashCommands?: string[]; skills?: string[]; plugins?: Array<{ name: string; path: string; }>; mcpServers?: Array<{ name: string; status: string; }>; apiKeySource?: string; version?: string; outputStyle?: string; } export interface ProviderUsage { inputTokens?: number; cachedInputTokens?: number; cacheCreationTokens?: number; outputTokens?: number; totalTokens?: number; contextWindowTokens?: number; totalCostUsd?: number; stopReason?: string | null; durationMs?: number; durationApiMs?: number; isError?: boolean; resultSubtype?: string; modelUsage?: Record; permissionDenials?: unknown[]; errors?: string[]; raw?: Record; } export interface ProviderProgress { taskId: string; description: string; summary?: string; lastToolName?: string; totalTokens: number; toolUses: number; durationMs: number; } export type ProviderEvent = { type: 'session.init'; info: ProviderSessionInfo; } | { type: 'session.status'; sessionId: string; status?: string | null; permissionMode?: string; } | { type: 'delta.text'; text: string; sessionId?: string; } | { type: 'delta.reasoning'; text: string; sessionId?: string; } | { type: 'assistant.message'; text: string; sessionId?: string; } | { type: 'notice'; text: string; kind: 'truncation' | 'refusal'; sessionId?: string; } | { type: 'tool.use.start'; toolUseId: string; toolName: string; toolInput: string; toolInputRaw?: string; toolInputCapture?: string; pending?: true; sessionId?: string; } | { type: 'tool.use'; summary: string; toolUseIds?: string[]; sessionId?: string; } | { type: 'tool.output'; toolUseId: string; content: string; isError?: boolean; truncated?: boolean; capturePath?: string; sessionId?: string; toolName?: string; batchIndex?: number; batchSize?: number; incomplete?: boolean; incompleteReason?: string; failureClass?: ToolFailureClass; durationMs?: number; exitCode?: number; } | { type: 'tool.activity'; activeCount: number; activeToolUseIds: string[]; sessionId?: string; } | { type: 'tool.diff'; toolUseId: string; diff: import('../utils/diff.js').DiffPayload; sessionId?: string; } | { type: 'turn.completed'; usage: ProviderUsage; sessionId?: string; } | { type: 'progress'; progress: ProviderProgress; sessionId?: string; } | { type: 'suggestion'; suggestion: string; sessionId?: string; } | { type: 'stream.retry'; sessionId?: string; } | { type: 'rate_limit'; sessionId: string; retryAfterMs?: number; status?: number; attempt?: number; } | { type: 'error'; error: Error; } | { type: 'paused'; reason: 'usage-limit'; resetsAt?: Date; accountId?: string; autoResume?: boolean; } | { type: 'resumed'; hotSwapped: boolean; accountId?: string; }; export interface ProviderUserTurn { content: string | ContentBlockParam[]; sessionId?: string; } export interface ProviderQueryArgs { prompt: AsyncIterable; config: AgentConfig; } export interface ProviderQuery extends AsyncIterable { interrupt(reason?: import('./abort-reason.js').ProviderAbortReason): Promise; setModel(model?: string): Promise; setPermissionMode(mode: string): Promise; supportedCommands(): Promise; supportedModels(): Promise; supportedAgents(): Promise; getContextUsage(): Promise; mcpServerStatus(): Promise; accountInfo(): Promise; rewindFiles(userMessageId: string, options?: { dryRun?: boolean; }): Promise; compact?(): Promise; listRewindTargets?(): RewindTarget[]; rewindConversation?(turnIndex: number): Promise; setCwd?(cwd: string): void; setSystemPrompt?(basePrompt: string | undefined): boolean; setBeforeNextRound?(cb: (() => string | undefined) | undefined): void; reauth?(): Promise<{ accountId: string; swapped: boolean; } | null>; close(): void | Promise; } export interface ProviderCommandInfo { name: string; description?: string; argumentHint?: string; whenToUse?: string; source?: 'builtin' | 'user' | 'project' | 'plugin' | 'imported' | 'command'; } export interface ProviderModelInfo { value: string; displayName?: string; description?: string; } export interface ProviderAgentInfo { name: string; description?: string; } export interface ProviderContextUsage { tools?: unknown[]; agents?: unknown[]; isAutoCompactEnabled?: boolean; apiUsage?: Record | null; [key: string]: unknown; } export interface ProviderMcpServerStatus { name: string; status: string; } export interface ProviderAccountInfo { email?: string; organization?: string; subscriptionType?: string; [key: string]: unknown; } export interface ProviderRewindResult { canRewind: boolean; error?: string; filesChanged?: string[]; insertions?: number; deletions?: number; } export interface ProviderCompactResult { compacted: boolean; reason?: string; messagesBefore: number; messagesAfter: number; tokensSavedEstimate?: number; microcompaction?: { blocksCleared: number; bytesReclaimed: number; }; } export interface RewindTarget { turnIndex: number; preview: string; } export interface ProviderRewindConversationResult { rewound: boolean; reason?: string; reloadText?: string; messagesBefore: number; messagesAfter: number; } export interface ProviderCompleteArgs { system: string; user: string; model?: string; maxTokens?: number; signal?: AbortSignal; apiKey?: string; baseUrl?: string; } export interface ModelProvider { readonly name: string; query(args: ProviderQueryArgs): ProviderQuery; complete?(args: ProviderCompleteArgs): Promise; close?(): void | Promise; }