/** * SDKMessage — JSONL line format the CLI emits to stdout. * * Source of truth is `../protocol/`. This file is a thin re-export * shim so existing SDK consumer imports (`'./types/messages.js'` paths) * keep working. */ import type { SDKMessage as ProtocolSDKMessage, SDKStatusMessage as ProtocolSDKStatusMessage, SDKSystemMessage as ProtocolSDKSystemMessage, SDKUserMessage as ProtocolSDKUserMessage, SDKUserMessageReplay as ProtocolSDKUserMessageReplay } from '../protocol/index.js'; import type { MessageParam, UUID } from './common.js'; import type { PermissionMode } from './permissions.js'; import type { SessionKey } from '../session/session-store.js'; export type { SDKAssistantMessage, SDKResultSuccess, SDKResultError, SDKResultMessage, SDKPartialAssistantMessage, SDKCompactBoundaryMessage, SDKAPIRetryMessage, SDKModelQueueStatusMessage, SDKControlRequestProgressMessage, SDKHookStartedMessage, SDKHookProgressMessage, SDKHookResponseMessage, SDKTaskNotificationMessage, SDKTaskStartedMessage, SDKTaskProgressMessage, SDKTaskUpdatedMessage, SDKBackgroundTasksChangedMessage, SDKSessionStateChangedMessage, SDKSessionTitleChangedMessage, SDKFilesPersistedEvent, SDKElicitationCompleteMessage, SDKPromptSuggestionMessage, SDKCloudAgentEventMessage, SDKMemoryGenerationMessage, SDKMemoryConsumptionMessage, SDKPermissionDenial, SDKToolNonExecutionKind, SDKToolResultMeta, } from '../protocol/index.js'; export type SDKUserMessage = { type: 'user'; message: MessageParam; parent_tool_use_id: string | null; custom_context?: Record; isSynthetic?: boolean; tool_use_result?: unknown; /** CLI-stamped display metadata for tool results that did not execute. */ tool_result_meta?: import('../protocol/index.js').SDKToolResultMeta[]; /** * Delivery priority. `next` is the default; `now` interrupts the active * turn, while `later` waits for the session to become idle. */ priority?: 'now' | 'next' | 'later'; /** * When false, do not start an assistant turn while the session is idle. * Delivery still follows `priority`: `next` can inject at a safe boundary, * `later` waits for idle, and `now` interrupts the active turn. */ shouldQuery?: boolean; timestamp?: string; uuid?: UUID; session_id?: string; }; export type SDKUserMessageReplay = SDKUserMessage & { uuid: UUID; session_id: string; isReplay: true; }; export type SDKSystemInitMessage = ProtocolSDKSystemMessage & { permissionMode: PermissionMode; }; export type SDKStatusMessage = ProtocolSDKStatusMessage & { permissionMode?: PermissionMode; }; export type SDKPermissionDeniedMessage = { type: 'system'; subtype: 'permission_denied'; tool_name: string; tool_use_id: string; agent_id?: string; decision_reason_type?: string; decision_reason?: string; message: string; uuid: string; session_id: string; }; export type SDKMirrorErrorMessage = { type: 'system'; subtype: 'mirror_error'; error: string; key: SessionKey; uuid: string; session_id: string; }; export type SDKMessage = Exclude | SDKUserMessage | SDKUserMessageReplay | SDKSystemInitMessage | SDKStatusMessage | SDKPermissionDeniedMessage | SDKMirrorErrorMessage; export type SDKSystemMessage = Extract; export type SDKSystemMessageSubtype = SDKSystemMessage['subtype']; export type SDKSystemMessageBySubtype = { [Message in SDKSystemMessage as Message['subtype']]: Message; };