import type { AccountInfo, AgentInfo, ApiKeySource, McpServerStatus, ModelInfo, PermissionMode, SDKControlGetContextUsageResponse, SDKStatus } from './sdk-types.js'; import type { ContentBlockParam } from '@anthropic-ai/sdk/resources'; import type { AgentModelInput } from './model-types.js'; import type { InputStreamRef } from './permission-types.js'; import type { Message, MessageChunk, ResponseMetadata, SendMessageOptions, StructuredMessageOptions } from './message-types.js'; import type { ProviderCommandInfo, ProviderCompactResult, ProviderQuery, ProviderRewindConversationResult, RewindTarget } from '../provider.js'; import type { HookRegistry } from '../hooks.js'; import type { ZodType } from 'zod'; export type SessionState = 'idle' | 'processing' | 'streaming' | 'compacting' | 'closed'; export interface SessionIdentity { sessionId?: string; configuredSessionId?: string; resume?: string; resumeSessionAt?: string; continue?: boolean; forkSession?: boolean; persistSession: boolean; } export interface SessionMetadata { sessionId?: string; model?: string; permissionMode?: PermissionMode; cwd?: string; tools?: string[]; slashCommands?: string[]; skills?: string[]; plugins?: Array<{ name: string; path: string; }>; mcpServers?: Array<{ name: string; status: string; }>; apiKeySource?: ApiKeySource; claudeCodeVersion?: string; outputStyle?: string; status?: SDKStatus; } export interface PanelSpec { kind: string; title?: string; body: string | string[]; } export type OutputEvent = { type: 'message'; message: Message; } | { type: 'chunk'; chunk: MessageChunk; } | { type: 'error'; error: Error; } | { type: 'done'; metadata?: ResponseMetadata; } | { type: 'progress'; progress: ProgressEvent; } | { type: 'suggestion'; suggestion: string; } | { type: 'stream_retry'; } | { type: 'rate_limit'; retryAfterMs?: number; } | { type: 'panel'; spec: PanelSpec; } | { type: 'notice'; text: string; kind: 'truncation' | 'refusal'; } | { type: 'tool-activity'; activeCount: number; activeToolUseIds: string[]; } | { type: 'paused'; reason: 'usage-limit'; resetsAt?: Date; accountId?: string; autoResume?: boolean; } | { type: 'resumed'; hotSwapped: boolean; accountId?: string; } | { type: 'subagent_lifecycle'; subagentId: string; status: 'started' | 'succeeded' | 'failed' | 'cancelled'; model?: string; agentType?: string; durationMs?: number; totalCostUsd?: number; outputBytes?: number; errorClass?: string; errorMessage?: string; promptHead?: string; turnCount?: number; stopReason?: string; parentToolUseId?: string; } | { type: 'background_job'; jobId: string; status: 'started' | 'completed' | 'failed' | 'cancelled' | 'delivered'; label?: string; } | { type: 'plan_mode'; mode: 'plan' | 'implement' | 'default'; }; export interface ProgressEvent { taskId: string; description: string; summary?: string; lastToolName?: string; totalTokens: number; toolUses: number; durationMs: number; } export interface SubagentProgressMeta { subagentId: string; parentId?: string; agentType?: string; } export type SubagentProgressSink = (event: OutputEvent, meta: SubagentProgressMeta) => void; export interface RewindFilesResult { canRewind: boolean; error?: string; filesChanged?: string[]; insertions?: number; deletions?: number; } export interface IAgentSession { readonly state: SessionState; readonly sessionId?: string; readonly cwd?: string; readonly hookRegistry?: HookRegistry; sendMessage(content: string, options?: SendMessageOptions): Promise; sendMessageStream(content: string | ContentBlockParam[]): AsyncIterable; sendMessageStructured?(content: string, schema: ZodType, options?: StructuredMessageOptions): Promise; interrupt(): Promise; setBeforeNextRound?(cb: (() => string | undefined) | undefined): void; reset(): Promise; readonly abortSignal: AbortSignal; abort(reason: string): void; setModel(model?: AgentModelInput): Promise; setPermissionMode(mode: PermissionMode): Promise; takePendingPlanExitSeed(): Promise<{ message: string; mode: PermissionMode; } | undefined>; waitForInitialization(): Promise; getSessionIdentity(): SessionIdentity; getSessionMetadata(): SessionMetadata; getQuery(): ProviderQuery; getLastResponseMetadata(): ResponseMetadata | null; getOutputStream(): AsyncIterable; getHistory?(): readonly Message[]; getInputStreamRef(): Pick; 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; close(): Promise; }