Documentation
¶
Overview ¶
Package message provides message and content block types for Claude conversations.
Index ¶
- Constants
- func AnnotateRawJSON(data map[string]any, raw []byte) map[string]any
- type APIRetryMessage
- type AssistantMessage
- type AssistantMessageError
- type AuditEnvelope
- type AuthStatusMessage
- type Base64Source
- type CompactBoundaryMessage
- type CompactMetadata
- type CompactPreservedSegment
- type ConnectorTextBlock
- type ContentBlock
- type ElicitationCompleteMessage
- type FilesPersistedFailure
- type FilesPersistedFile
- type FilesPersistedMessage
- type HookProgressMessage
- type HookResponseMessage
- type HookResponseOutcome
- type HookStartedMessage
- type InitMCPServerStatus
- type InitMessage
- type InitPluginInfo
- type InputDocumentBlock
- type InputImageBlock
- type LocalCommandOutputMessage
- type Message
- type ModelUsage
- type PermissionDenial
- type PostTurnSummaryMessage
- type PromptSuggestionMessage
- type RateLimitEvent
- type RateLimitInfo
- type RateLimitOverageDisabledReason
- type RateLimitStatus
- type RateLimitType
- type RawStreamEvent
- type ResultMessage
- type ResultSubtype
- type SessionState
- type SessionStateChangedMessage
- type StatusMessage
- type StatusState
- type StreamEvent
- type StreamingMessage
- type StreamingMessageContent
- type StreamingMessagePriority
- type StreamlinedTextMessage
- type StreamlinedToolUseSummaryMessage
- type StructuredOutputTracker
- type SystemMessage
- type TaskNotificationMessage
- type TaskNotificationStatus
- type TaskProgressMessage
- type TaskStartedMessage
- type TaskType
- type TaskUsage
- type TextBlock
- type ThinkingBlock
- type ToolProgressMessage
- type ToolReferenceBlock
- type ToolResultBlock
- type ToolUseBlock
- type ToolUseSummaryMessage
- type UnknownBlock
- type UnknownMessage
- type Usage
- type UserMessage
- type UserMessageContent
Constants ¶
const ( BlockTypeText = "text" BlockTypeImage = "image" BlockTypeDocument = "document" BlockTypeThinking = "thinking" BlockTypeToolUse = "tool_use" BlockTypeToolResult = "tool_result" BlockTypeToolRef = "tool_reference" BlockTypeConnector = "connector_text" )
Block type constants.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type APIRetryMessage ¶ added in v0.0.7
type APIRetryMessage struct {
SystemMessage
Attempt int `json:"attempt"`
MaxRetries int `json:"max_retries"`
RetryDelayMs int `json:"retry_delay_ms"`
ErrorStatus *int `json:"error_status,omitempty"`
Error AssistantMessageError `json:"error"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
APIRetryMessage reports an API retry event.
func (*APIRetryMessage) MessageType ¶ added in v0.0.7
func (m *APIRetryMessage) MessageType() string
MessageType implements the Message interface.
func (*APIRetryMessage) UnmarshalJSON ¶ added in v0.0.11
func (m *APIRetryMessage) UnmarshalJSON(data []byte) error
UnmarshalJSON accepts retry_delay_ms as either an integer or a fractional number. The Claude CLI started emitting fractional values (e.g. 611.6798389847949) in v2.1.x, which failed the default int-typed decode. Sub-millisecond precision is irrelevant for retry scheduling, so fractional values are truncated to int.
type AssistantMessage ¶
type AssistantMessage struct {
Type string `json:"type"`
Content []ContentBlock `json:"content"`
Model string `json:"model"`
ParentUUID *string `json:"parent_uuid,omitempty"`
ParentToolUseID *string `json:"parent_tool_use_id,omitempty"`
Error *AssistantMessageError `json:"error,omitempty"`
Usage map[string]any `json:"usage,omitempty"`
MessageID *string `json:"message_id,omitempty"`
StopReason *string `json:"stop_reason,omitempty"`
SessionID *string `json:"session_id,omitempty"`
UUID *string `json:"uuid,omitempty"`
Audit *AuditEnvelope `json:"-"`
}
AssistantMessage represents a message from Claude.
func (*AssistantMessage) MessageType ¶
func (m *AssistantMessage) MessageType() string
MessageType implements the Message interface.
type AssistantMessageError ¶
type AssistantMessageError string
AssistantMessageError represents error types from the assistant.
const ( // AssistantMessageErrorAuthFailed indicates authentication failure. AssistantMessageErrorAuthFailed AssistantMessageError = "authentication_failed" // AssistantMessageErrorBilling indicates a billing error. AssistantMessageErrorBilling AssistantMessageError = "billing_error" // AssistantMessageErrorRateLimit indicates rate limiting. AssistantMessageErrorRateLimit AssistantMessageError = "rate_limit" // AssistantMessageErrorInvalidReq indicates an invalid request. AssistantMessageErrorInvalidReq AssistantMessageError = "invalid_request" // AssistantMessageErrorServer indicates a server error. AssistantMessageErrorServer AssistantMessageError = "server_error" // AssistantMessageErrorMaxOutputTokens indicates output token exhaustion. AssistantMessageErrorMaxOutputTokens AssistantMessageError = "max_output_tokens" // AssistantMessageErrorUnknown indicates an unknown error. AssistantMessageErrorUnknown AssistantMessageError = "unknown" )
type AuditEnvelope ¶ added in v0.0.7
type AuditEnvelope struct {
EventType string `json:"event_type"`
Subtype string `json:"subtype,omitempty"`
Payload json.RawMessage `json:"payload"`
}
AuditEnvelope contains the provider-native event metadata and canonical payload captured at the SDK boundary.
func NewAuditEnvelope ¶ added in v0.0.7
func NewAuditEnvelope(eventType, subtype string, payload any) (*AuditEnvelope, error)
NewAuditEnvelope marshals a canonical payload into an audit envelope.
func (*AuditEnvelope) GetEventType ¶ added in v0.0.7
func (a *AuditEnvelope) GetEventType() string
func (*AuditEnvelope) GetPayload ¶ added in v0.0.7
func (a *AuditEnvelope) GetPayload() json.RawMessage
func (*AuditEnvelope) GetSubtype ¶ added in v0.0.7
func (a *AuditEnvelope) GetSubtype() string
type AuthStatusMessage ¶ added in v0.0.7
type AuthStatusMessage struct {
Type string `json:"type"`
IsAuthenticating bool `json:"isAuthenticating"`
Output []string `json:"output"`
Error *string `json:"error,omitempty"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Audit *AuditEnvelope `json:"-"`
}
AuthStatusMessage reports CLI authentication progress.
func (*AuthStatusMessage) MessageType ¶ added in v0.0.7
func (m *AuthStatusMessage) MessageType() string
MessageType implements the Message interface.
type Base64Source ¶ added in v0.0.5
type Base64Source struct {
Type string `json:"type"`
MediaType string `json:"media_type"`
Data string `json:"data"`
}
Base64Source contains inline base64 content for Claude CLI multimodal inputs.
type CompactBoundaryMessage ¶ added in v0.0.7
type CompactBoundaryMessage struct {
SystemMessage
CompactMetadata CompactMetadata `json:"compact_metadata"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
CompactBoundaryMessage reports conversation compaction boundaries.
func (*CompactBoundaryMessage) MessageType ¶ added in v0.0.7
func (m *CompactBoundaryMessage) MessageType() string
MessageType implements the Message interface.
type CompactMetadata ¶ added in v0.0.7
type CompactMetadata struct {
Trigger string `json:"trigger"`
PreTokens int `json:"pre_tokens"`
PreservedSegment *CompactPreservedSegment `json:"preserved_segment,omitempty"`
}
CompactMetadata captures compaction boundary metadata.
type CompactPreservedSegment ¶ added in v0.0.7
type CompactPreservedSegment struct {
HeadUUID string `json:"head_uuid"`
AnchorUUID string `json:"anchor_uuid"`
TailUUID string `json:"tail_uuid"`
}
CompactPreservedSegment identifies a preserved segment after compaction.
type ConnectorTextBlock ¶ added in v0.0.7
type ConnectorTextBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Raw map[string]any `json:"-"`
}
ConnectorTextBlock contains IDE/connector-synchronized text context. Raw preserves the full provider payload for round-tripping.
func (*ConnectorTextBlock) BlockType ¶ added in v0.0.7
func (b *ConnectorTextBlock) BlockType() string
BlockType implements the ContentBlock interface.
func (*ConnectorTextBlock) MarshalJSON ¶ added in v0.0.7
func (b *ConnectorTextBlock) MarshalJSON() ([]byte, error)
MarshalJSON preserves any original connector payload fields.
func (*ConnectorTextBlock) UnmarshalJSON ¶ added in v0.0.7
func (b *ConnectorTextBlock) UnmarshalJSON(data []byte) error
UnmarshalJSON preserves the raw connector payload while exposing text directly.
type ContentBlock ¶
type ContentBlock interface {
BlockType() string
}
ContentBlock represents a block of content within a message.
func UnmarshalContentBlock ¶
func UnmarshalContentBlock(data []byte) (ContentBlock, error)
UnmarshalContentBlock unmarshals a single content block from JSON.
type ElicitationCompleteMessage ¶ added in v0.0.7
type ElicitationCompleteMessage struct {
SystemMessage
MCPServerName string `json:"mcp_server_name"`
ElicitationID string `json:"elicitation_id"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
ElicitationCompleteMessage reports an MCP elicitation completion event.
func (*ElicitationCompleteMessage) MessageType ¶ added in v0.0.7
func (m *ElicitationCompleteMessage) MessageType() string
MessageType implements the Message interface.
type FilesPersistedFailure ¶ added in v0.0.7
FilesPersistedFailure describes a failed file persistence result.
type FilesPersistedFile ¶ added in v0.0.7
FilesPersistedFile describes a persisted file result.
type FilesPersistedMessage ¶ added in v0.0.7
type FilesPersistedMessage struct {
SystemMessage
Files []FilesPersistedFile `json:"files"`
Failed []FilesPersistedFailure `json:"failed"`
ProcessedAt string `json:"processed_at"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
FilesPersistedMessage reports persisted file IDs.
func (*FilesPersistedMessage) MessageType ¶ added in v0.0.7
func (m *FilesPersistedMessage) MessageType() string
MessageType implements the Message interface.
type HookProgressMessage ¶ added in v0.0.7
type HookProgressMessage struct {
SystemMessage
HookID string `json:"hook_id"`
HookName string `json:"hook_name"`
HookEvent string `json:"hook_event"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
Output string `json:"output"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
HookProgressMessage reports hook progress output.
func (*HookProgressMessage) MessageType ¶ added in v0.0.7
func (m *HookProgressMessage) MessageType() string
MessageType implements the Message interface.
type HookResponseMessage ¶ added in v0.0.7
type HookResponseMessage struct {
SystemMessage
HookID string `json:"hook_id"`
HookName string `json:"hook_name"`
HookEvent string `json:"hook_event"`
Output string `json:"output"`
Stdout string `json:"stdout"`
Stderr string `json:"stderr"`
ExitCode *int `json:"exit_code,omitempty"`
Outcome HookResponseOutcome `json:"outcome"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
HookResponseMessage reports the final result of an async hook.
func (*HookResponseMessage) MessageType ¶ added in v0.0.7
func (m *HookResponseMessage) MessageType() string
MessageType implements the Message interface.
type HookResponseOutcome ¶ added in v0.0.7
type HookResponseOutcome string
HookResponseOutcome identifies a hook's final outcome.
const ( // HookResponseOutcomeSuccess indicates hook success. HookResponseOutcomeSuccess HookResponseOutcome = "success" // HookResponseOutcomeError indicates hook failure. HookResponseOutcomeError HookResponseOutcome = "error" // HookResponseOutcomeCancelled indicates hook cancellation. HookResponseOutcomeCancelled HookResponseOutcome = "cancelled" )
type HookStartedMessage ¶ added in v0.0.7
type HookStartedMessage struct {
SystemMessage
HookID string `json:"hook_id"`
HookName string `json:"hook_name"`
HookEvent string `json:"hook_event"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
HookStartedMessage reports the start of an async hook.
func (*HookStartedMessage) MessageType ¶ added in v0.0.7
func (m *HookStartedMessage) MessageType() string
MessageType implements the Message interface.
type InitMCPServerStatus ¶ added in v0.0.7
InitMCPServerStatus describes one MCP server entry in the init system message.
type InitMessage ¶ added in v0.0.7
type InitMessage struct {
SystemMessage
Agents []string `json:"agents,omitempty"`
APIKeySource string `json:"apiKeySource"`
Betas []string `json:"betas,omitempty"`
ClaudeCodeVersion string `json:"claude_code_version"`
Cwd string `json:"cwd"`
Tools []string `json:"tools"`
MCPServers []InitMCPServerStatus `json:"mcp_servers"`
Model string `json:"model"`
PermissionMode string `json:"permissionMode"`
SlashCommands []string `json:"slash_commands"`
OutputStyle string `json:"output_style"`
Skills []string `json:"skills"`
Plugins []InitPluginInfo `json:"plugins"`
FastModeState *fastmode.State `json:"fast_mode_state,omitempty"`
ContextWindow *int `json:"-"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
InitMessage reports the typed init system message emitted by the CLI transcript.
func (*InitMessage) MessageType ¶ added in v0.0.7
func (m *InitMessage) MessageType() string
MessageType implements the Message interface.
type InitPluginInfo ¶ added in v0.0.7
type InitPluginInfo struct {
Name string `json:"name"`
Path string `json:"path"`
Source *string `json:"source,omitempty"`
}
InitPluginInfo describes one plugin entry in the init system message.
type InputDocumentBlock ¶ added in v0.0.5
type InputDocumentBlock struct {
Type string `json:"type"`
Source Base64Source `json:"source"`
}
InputDocumentBlock contains an inline PDF document input for multimodal prompts.
func (*InputDocumentBlock) BlockType ¶ added in v0.0.5
func (b *InputDocumentBlock) BlockType() string
BlockType implements the ContentBlock interface.
type InputImageBlock ¶ added in v0.0.5
type InputImageBlock struct {
Type string `json:"type"`
Source Base64Source `json:"source"`
}
InputImageBlock contains an inline image input for multimodal prompts.
func (*InputImageBlock) BlockType ¶ added in v0.0.5
func (b *InputImageBlock) BlockType() string
BlockType implements the ContentBlock interface.
type LocalCommandOutputMessage ¶ added in v0.0.7
type LocalCommandOutputMessage struct {
SystemMessage
Content string `json:"content"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
LocalCommandOutputMessage reports output from a local slash command.
func (*LocalCommandOutputMessage) MessageType ¶ added in v0.0.7
func (m *LocalCommandOutputMessage) MessageType() string
MessageType implements the Message interface.
type Message ¶
type Message interface {
MessageType() string
}
Message represents any message in the conversation. Use type assertion or type switch to determine the concrete type.
type ModelUsage ¶ added in v0.0.7
type ModelUsage struct {
InputTokens int `json:"inputTokens"`
OutputTokens int `json:"outputTokens"`
CacheReadInputTokens int `json:"cacheReadInputTokens"`
CacheCreationInputTokens int `json:"cacheCreationInputTokens"`
WebSearchRequests int `json:"webSearchRequests"`
CostUSD float64 `json:"costUSD"`
ContextWindow int `json:"contextWindow"`
MaxOutputTokens int `json:"maxOutputTokens"`
}
ModelUsage describes per-model token and cost usage for a terminal result.
type PermissionDenial ¶ added in v0.0.7
type PermissionDenial struct {
ToolName string `json:"tool_name"`
ToolUseID string `json:"tool_use_id"`
ToolInput map[string]any `json:"tool_input"`
}
PermissionDenial describes one denied tool attempt captured in the result.
type PostTurnSummaryMessage ¶ added in v0.0.7
type PostTurnSummaryMessage struct {
SystemMessage
SummarizesUUID string `json:"summarizes_uuid"`
StatusCategory string `json:"status_category"`
StatusDetail string `json:"status_detail"`
IsNoteworthy bool `json:"is_noteworthy"`
Title string `json:"title"`
Description string `json:"description"`
RecentAction string `json:"recent_action"`
NeedsAction string `json:"needs_action"`
ArtifactURLs []string `json:"artifact_urls"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
PostTurnSummaryMessage reports a background turn summary.
func (*PostTurnSummaryMessage) MessageType ¶ added in v0.0.7
func (m *PostTurnSummaryMessage) MessageType() string
MessageType implements the Message interface.
type PromptSuggestionMessage ¶ added in v0.0.7
type PromptSuggestionMessage struct {
Type string `json:"type"`
Suggestion string `json:"suggestion"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Audit *AuditEnvelope `json:"-"`
}
PromptSuggestionMessage reports a predicted next prompt.
func (*PromptSuggestionMessage) MessageType ¶ added in v0.0.7
func (m *PromptSuggestionMessage) MessageType() string
MessageType implements the Message interface.
type RateLimitEvent ¶ added in v0.0.6
type RateLimitEvent struct {
Type string `json:"type"`
RateLimitInfo RateLimitInfo `json:"rate_limit_info"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Audit *AuditEnvelope `json:"-"`
}
RateLimitEvent represents a rate limit event from the Claude CLI.
func (*RateLimitEvent) MessageType ¶ added in v0.0.6
func (m *RateLimitEvent) MessageType() string
MessageType implements the Message interface.
type RateLimitInfo ¶ added in v0.0.6
type RateLimitInfo struct {
Status RateLimitStatus `json:"status"`
ResetsAt *int64 `json:"resetsAt,omitempty"`
RateLimitType *RateLimitType `json:"rateLimitType,omitempty"`
Utilization *float64 `json:"utilization,omitempty"`
OverageStatus *RateLimitStatus `json:"overageStatus,omitempty"`
OverageResetsAt *int64 `json:"overageResetsAt,omitempty"`
OverageDisabledReason *RateLimitOverageDisabledReason `json:"overageDisabledReason,omitempty"`
IsUsingOverage *bool `json:"isUsingOverage,omitempty"`
SurpassedThreshold *float64 `json:"surpassedThreshold,omitempty"`
Raw map[string]any `json:"-"`
}
RateLimitInfo contains detailed information about a rate limit check.
type RateLimitOverageDisabledReason ¶ added in v0.0.7
type RateLimitOverageDisabledReason string
RateLimitOverageDisabledReason identifies why overage is disabled.
const ( RateLimitOverageDisabledReasonOverageNotProvisioned RateLimitOverageDisabledReason = "overage_not_provisioned" RateLimitOverageDisabledReasonOrgLevelDisabled RateLimitOverageDisabledReason = "org_level_disabled" RateLimitOverageDisabledReasonOrgLevelDisabledUntil RateLimitOverageDisabledReason = "org_level_disabled_until" RateLimitOverageDisabledReasonOutOfCredits RateLimitOverageDisabledReason = "out_of_credits" RateLimitOverageDisabledReasonSeatTierLevelDisabled RateLimitOverageDisabledReason = "seat_tier_level_disabled" RateLimitOverageDisabledReasonMemberLevelDisabled RateLimitOverageDisabledReason = "member_level_disabled" RateLimitOverageDisabledReasonSeatTierZeroCreditLimit RateLimitOverageDisabledReason = "seat_tier_zero_credit_limit" RateLimitOverageDisabledReasonGroupZeroCreditLimit RateLimitOverageDisabledReason = "group_zero_credit_limit" RateLimitOverageDisabledReasonMemberZeroCreditLimit RateLimitOverageDisabledReason = "member_zero_credit_limit" RateLimitOverageDisabledReasonOrgServiceLevelDisabled RateLimitOverageDisabledReason = "org_service_level_disabled" RateLimitOverageDisabledReasonOrgServiceZeroCreditLimit RateLimitOverageDisabledReason = "org_service_zero_credit_limit" RateLimitOverageDisabledReasonNoLimitsConfigured RateLimitOverageDisabledReason = "no_limits_configured" RateLimitOverageDisabledReasonUnknown RateLimitOverageDisabledReason = "unknown" )
type RateLimitStatus ¶ added in v0.0.6
type RateLimitStatus string
RateLimitStatus represents the status of a rate limit check.
const ( // RateLimitStatusAllowed indicates the request is within rate limits. RateLimitStatusAllowed RateLimitStatus = "allowed" // RateLimitStatusAllowedWarning indicates the request is allowed but approaching limits. RateLimitStatusAllowedWarning RateLimitStatus = "allowed_warning" // RateLimitStatusRejected indicates the request was rejected due to rate limits. RateLimitStatusRejected RateLimitStatus = "rejected" )
type RateLimitType ¶ added in v0.0.6
type RateLimitType string
RateLimitType represents the type of rate limit window.
const ( // RateLimitTypeFiveHour represents a 5-hour rate limit window. RateLimitTypeFiveHour RateLimitType = "five_hour" // RateLimitTypeSevenDay represents a 7-day rate limit window. RateLimitTypeSevenDay RateLimitType = "seven_day" // RateLimitTypeSevenDayOpus represents a 7-day rate limit for Opus models. RateLimitTypeSevenDayOpus RateLimitType = "seven_day_opus" // RateLimitTypeSevenDaySonnet represents a 7-day rate limit for Sonnet models. RateLimitTypeSevenDaySonnet RateLimitType = "seven_day_sonnet" // RateLimitTypeOverage represents an overage rate limit. RateLimitTypeOverage RateLimitType = "overage" )
type RawStreamEvent ¶ added in v0.0.7
RawStreamEvent preserves the provider-native Anthropic stream event payload.
type ResultMessage ¶
type ResultMessage struct {
Type string `json:"type"`
Subtype ResultSubtype `json:"subtype"`
DurationMs int `json:"duration_ms"`
DurationAPIMs int `json:"duration_api_ms"`
IsError bool `json:"is_error"`
NumTurns int `json:"num_turns"`
SessionID string `json:"session_id"`
StopReason *string `json:"stop_reason,omitempty"`
TotalCostUSD *float64 `json:"total_cost_usd,omitempty"`
Usage *Usage `json:"usage,omitempty"`
Result *string `json:"result,omitempty"`
StructuredOutput any `json:"structured_output,omitempty"`
ModelUsage map[string]ModelUsage `json:"modelUsage,omitempty"`
PermissionDenials []PermissionDenial `json:"permission_denials,omitempty"`
Errors []string `json:"errors,omitempty"`
FastModeState *fastmode.State `json:"fast_mode_state,omitempty"`
UUID *string `json:"uuid,omitempty"`
Audit *AuditEnvelope `json:"-"`
}
ResultMessage represents the final result of a query.
func (*ResultMessage) MessageType ¶
func (m *ResultMessage) MessageType() string
MessageType implements the Message interface.
type ResultSubtype ¶ added in v0.0.7
type ResultSubtype string
ResultSubtype identifies the terminal result reason.
const ( // ResultSubtypeSuccess indicates normal completion. ResultSubtypeSuccess ResultSubtype = "success" // ResultSubtypeErrorDuringExecution indicates a runtime execution error. ResultSubtypeErrorDuringExecution ResultSubtype = "error_during_execution" // ResultSubtypeErrorMaxTurns indicates the max-turn budget was exhausted. ResultSubtypeErrorMaxTurns ResultSubtype = "error_max_turns" // ResultSubtypeErrorMaxBudgetUSD indicates the USD budget was exhausted. ResultSubtypeErrorMaxBudgetUSD ResultSubtype = "error_max_budget_usd" // ResultSubtypeErrorMaxStructuredOutputRetries indicates structured output retries were exhausted. ResultSubtypeErrorMaxStructuredOutputRetries ResultSubtype = "error_max_structured_output_retries" )
type SessionState ¶ added in v0.0.7
type SessionState string
SessionState identifies the current live session state.
const ( // SessionStateIdle indicates the session is idle. SessionStateIdle SessionState = "idle" // SessionStateRunning indicates the session is running. SessionStateRunning SessionState = "running" // SessionStateRequiresAction indicates the session requires action. SessionStateRequiresAction SessionState = "requires_action" )
type SessionStateChangedMessage ¶ added in v0.0.7
type SessionStateChangedMessage struct {
SystemMessage
State SessionState `json:"state"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
SessionStateChangedMessage reports authoritative session state changes.
func (*SessionStateChangedMessage) MessageType ¶ added in v0.0.7
func (m *SessionStateChangedMessage) MessageType() string
MessageType implements the Message interface.
type StatusMessage ¶ added in v0.0.7
type StatusMessage struct {
SystemMessage
Status *StatusState `json:"status,omitempty"`
PermissionMode *string `json:"permissionMode,omitempty"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
}
StatusMessage reports session status changes.
func (*StatusMessage) MessageType ¶ added in v0.0.7
func (m *StatusMessage) MessageType() string
MessageType implements the Message interface.
type StatusState ¶ added in v0.0.7
type StatusState string
StatusState identifies a session status value.
const ( // StatusStateCompacting indicates the session is compacting. StatusStateCompacting StatusState = "compacting" )
type StreamEvent ¶
type StreamEvent struct {
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Event RawStreamEvent `json:"event"`
ParentUUID *string `json:"parent_uuid,omitempty"`
ParentToolUseID *string `json:"parent_tool_use_id,omitempty"`
Audit *AuditEnvelope `json:"-"`
}
StreamEvent represents a streaming event from the Claude API. ParentToolUseID preserves tool-branch context for partial assistant output.
func (*StreamEvent) MessageType ¶
func (m *StreamEvent) MessageType() string
MessageType implements the Message interface.
type StreamingMessage ¶
type StreamingMessage struct {
Type string `json:"type"` // "user"
Message StreamingMessageContent `json:"message"` // The message content
ParentToolUseID *string `json:"parent_tool_use_id,omitempty"` // Optional parent tool use ID
SessionID string `json:"session_id,omitempty"` // Optional session ID
Priority *StreamingMessagePriority `json:"priority,omitempty"` // Optional queue priority
}
StreamingMessage represents a message sent via stdin in streaming mode. This is used with --input-format stream-json to send messages to the CLI.
type StreamingMessageContent ¶
type StreamingMessageContent struct {
Role string `json:"role"` // "user"
Content UserMessageContent `json:"content"` // The user content
}
StreamingMessageContent represents the content of a streaming message.
type StreamingMessagePriority ¶ added in v0.0.7
type StreamingMessagePriority string
StreamingMessagePriority controls scheduling order for streamed user messages.
const ( // StreamingMessagePriorityNow executes immediately ahead of queued messages. StreamingMessagePriorityNow StreamingMessagePriority = "now" // StreamingMessagePriorityNext executes after the current turn and before notifications. StreamingMessagePriorityNext StreamingMessagePriority = "next" // StreamingMessagePriorityLater executes after higher-priority queued messages. StreamingMessagePriorityLater StreamingMessagePriority = "later" )
type StreamlinedTextMessage ¶ added in v0.0.7
type StreamlinedTextMessage struct {
Type string `json:"type"`
Text string `json:"text"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Audit *AuditEnvelope `json:"-"`
}
StreamlinedTextMessage reports text-only streamlined output.
func (*StreamlinedTextMessage) MessageType ¶ added in v0.0.7
func (m *StreamlinedTextMessage) MessageType() string
MessageType implements the Message interface.
type StreamlinedToolUseSummaryMessage ¶ added in v0.0.7
type StreamlinedToolUseSummaryMessage struct {
Type string `json:"type"`
ToolSummary string `json:"tool_summary"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Audit *AuditEnvelope `json:"-"`
}
StreamlinedToolUseSummaryMessage reports streamlined tool-use summaries.
func (*StreamlinedToolUseSummaryMessage) MessageType ¶ added in v0.0.7
func (m *StreamlinedToolUseSummaryMessage) MessageType() string
MessageType implements the Message interface.
type StructuredOutputTracker ¶ added in v0.0.2
type StructuredOutputTracker struct {
// contains filtered or unexported fields
}
StructuredOutputTracker captures StructuredOutput tool payloads so they can be promoted onto the final ResultMessage for compatibility with callers that expect structured output there.
func NewStructuredOutputTracker ¶ added in v0.0.2
func NewStructuredOutputTracker() *StructuredOutputTracker
NewStructuredOutputTracker creates a tracker for raw Claude CLI messages.
func (*StructuredOutputTracker) ObserveRaw ¶ added in v0.0.2
func (t *StructuredOutputTracker) ObserveRaw(raw map[string]any)
ObserveRaw records StructuredOutput tool invocations from raw assistant messages keyed by session ID.
func (*StructuredOutputTracker) PopulateResult ¶ added in v0.0.2
func (t *StructuredOutputTracker) PopulateResult(result *ResultMessage)
PopulateResult copies a tracked structured output payload onto a result message when the CLI emitted it through the StructuredOutput tool instead of directly on the result envelope.
type SystemMessage ¶
type SystemMessage struct {
Type string `json:"type"`
Subtype string `json:"subtype,omitempty"`
Data map[string]any `json:"data,omitempty"`
Audit *AuditEnvelope `json:"-"`
}
SystemMessage represents a system message.
func (*SystemMessage) MessageType ¶
func (m *SystemMessage) MessageType() string
MessageType implements the Message interface.
type TaskNotificationMessage ¶ added in v0.0.2
type TaskNotificationMessage struct {
SystemMessage
TaskID string `json:"task_id"`
Status TaskNotificationStatus `json:"status"`
OutputFile string `json:"output_file"`
Summary string `json:"summary"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
ParentUUID *string `json:"parent_uuid,omitempty"`
ToolUseID *string `json:"tool_use_id,omitempty"`
Usage *TaskUsage `json:"usage,omitempty"`
}
TaskNotificationMessage is emitted when a task completes, fails, or is stopped.
type TaskNotificationStatus ¶ added in v0.0.2
type TaskNotificationStatus string
TaskNotificationStatus represents the final status of a task.
const ( // TaskNotificationStatusCompleted indicates the task finished successfully. TaskNotificationStatusCompleted TaskNotificationStatus = "completed" // TaskNotificationStatusFailed indicates the task failed. TaskNotificationStatusFailed TaskNotificationStatus = "failed" // TaskNotificationStatusStopped indicates the task was stopped by control request. TaskNotificationStatusStopped TaskNotificationStatus = "stopped" )
type TaskProgressMessage ¶ added in v0.0.2
type TaskProgressMessage struct {
SystemMessage
TaskID string `json:"task_id"`
Description string `json:"description"`
Usage TaskUsage `json:"usage"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
ParentUUID *string `json:"parent_uuid,omitempty"`
ToolUseID *string `json:"tool_use_id,omitempty"`
LastToolName *string `json:"last_tool_name,omitempty"`
Summary *string `json:"summary,omitempty"`
}
TaskProgressMessage is emitted while a task is in progress.
type TaskStartedMessage ¶ added in v0.0.2
type TaskStartedMessage struct {
SystemMessage
TaskID string `json:"task_id"`
Description string `json:"description"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
ParentUUID *string `json:"parent_uuid,omitempty"`
ToolUseID *string `json:"tool_use_id,omitempty"`
TaskType *TaskType `json:"task_type,omitempty"`
WorkflowName *string `json:"workflow_name,omitempty"`
}
TaskStartedMessage is emitted when a task starts.
type TaskType ¶ added in v0.0.7
type TaskType string
TaskType identifies the runtime class of a task.
const ( TaskTypeLocalBash TaskType = "local_bash" TaskTypeLocalAgent TaskType = "local_agent" TaskTypeRemoteAgent TaskType = "remote_agent" TaskTypeInProcessTeammate TaskType = "in_process_teammate" TaskTypeLocalWorkflow TaskType = "local_workflow" TaskTypeMonitorMCP TaskType = "monitor_mcp" TaskTypeDream TaskType = "dream" )
type TaskUsage ¶ added in v0.0.2
type TaskUsage struct {
TotalTokens int `json:"total_tokens"`
ToolUses int `json:"tool_uses"`
DurationMs int `json:"duration_ms"`
}
TaskUsage contains task usage statistics from task progress events.
type ThinkingBlock ¶
type ThinkingBlock struct {
Type string `json:"type"`
Thinking string `json:"thinking"`
Signature string `json:"signature"`
}
ThinkingBlock contains Claude's thinking process.
func (*ThinkingBlock) BlockType ¶
func (b *ThinkingBlock) BlockType() string
BlockType implements the ContentBlock interface.
type ToolProgressMessage ¶ added in v0.0.7
type ToolProgressMessage struct {
Type string `json:"type"`
ToolUseID string `json:"tool_use_id"`
ToolName string `json:"tool_name"`
ParentUUID *string `json:"parent_uuid,omitempty"`
ParentToolUseID *string `json:"parent_tool_use_id,omitempty"`
ElapsedTimeSecs float64 `json:"elapsed_time_seconds"`
TaskID *string `json:"task_id,omitempty"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Audit *AuditEnvelope `json:"-"`
}
ToolProgressMessage reports long-running tool execution progress.
func (*ToolProgressMessage) MessageType ¶ added in v0.0.7
func (m *ToolProgressMessage) MessageType() string
MessageType implements the Message interface.
type ToolReferenceBlock ¶ added in v0.0.2
ToolReferenceBlock points to a deferred tool selected by Claude tool search.
func (*ToolReferenceBlock) BlockType ¶ added in v0.0.2
func (b *ToolReferenceBlock) BlockType() string
BlockType implements the ContentBlock interface.
type ToolResultBlock ¶
type ToolResultBlock struct {
Type string `json:"type"`
ToolUseID string `json:"tool_use_id"`
Content []ContentBlock `json:"content,omitempty"`
IsError bool `json:"is_error,omitempty"`
}
ToolResultBlock contains the result of a tool execution.
func (*ToolResultBlock) BlockType ¶
func (b *ToolResultBlock) BlockType() string
BlockType implements the ContentBlock interface.
func (*ToolResultBlock) UnmarshalJSON ¶
func (b *ToolResultBlock) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for ToolResultBlock. Claude CLI tool results may arrive as a plain string or structured blocks.
type ToolUseBlock ¶
type ToolUseBlock struct {
Type string `json:"type"`
ID string `json:"id"`
Name string `json:"name"`
Input map[string]any `json:"input"`
Category toolmeta.Category `json:"-"`
ConcurrencySafe bool `json:"-"`
InterruptBehavior toolmeta.InterruptBehavior `json:"-"`
}
ToolUseBlock represents Claude using a tool.
func (*ToolUseBlock) BlockType ¶
func (b *ToolUseBlock) BlockType() string
BlockType implements the ContentBlock interface.
type ToolUseSummaryMessage ¶ added in v0.0.7
type ToolUseSummaryMessage struct {
Type string `json:"type"`
Summary string `json:"summary"`
PrecedingToolUseIDs []string `json:"preceding_tool_use_ids"`
UUID string `json:"uuid"`
SessionID string `json:"session_id"`
Audit *AuditEnvelope `json:"-"`
}
ToolUseSummaryMessage reports a summarized tool-use event.
func (*ToolUseSummaryMessage) MessageType ¶ added in v0.0.7
func (m *ToolUseSummaryMessage) MessageType() string
MessageType implements the Message interface.
type UnknownBlock ¶ added in v0.0.2
UnknownBlock preserves unrecognized content block payloads without failing parsing.
func (*UnknownBlock) BlockType ¶ added in v0.0.2
func (b *UnknownBlock) BlockType() string
BlockType implements the ContentBlock interface.
func (*UnknownBlock) MarshalJSON ¶ added in v0.0.2
func (b *UnknownBlock) MarshalJSON() ([]byte, error)
MarshalJSON preserves the original block payload for round-tripping.
type UnknownMessage ¶ added in v0.0.7
type UnknownMessage struct {
Type string `json:"type"`
Data map[string]any `json:"data"`
Audit *AuditEnvelope `json:"-"`
}
UnknownMessage preserves unrecognized top-level message payloads.
func (*UnknownMessage) MessageType ¶ added in v0.0.7
func (m *UnknownMessage) MessageType() string
MessageType implements the Message interface.
type Usage ¶
type Usage struct {
InputTokens int `json:"input_tokens"`
OutputTokens int `json:"output_tokens"`
CachedInputTokens int `json:"cached_input_tokens"`
ReasoningOutputTokens int `json:"reasoning_output_tokens"`
}
Usage contains token usage information.
type UserMessage ¶
type UserMessage struct {
Type string `json:"type"`
Content UserMessageContent `json:"content"`
UUID *string `json:"uuid,omitempty"`
SessionID *string `json:"session_id,omitempty"`
ParentUUID *string `json:"parent_uuid,omitempty"`
ParentToolUseID *string `json:"parent_tool_use_id,omitempty"`
Priority *StreamingMessagePriority `json:"priority,omitempty"`
Timestamp *string `json:"timestamp,omitempty"`
IsReplay bool `json:"isReplay,omitempty"`
IsSynthetic bool `json:"isSynthetic,omitempty"`
ToolUseResult map[string]any `json:"tool_use_result,omitempty"`
Audit *AuditEnvelope `json:"-"`
}
UserMessage represents a message from the user.
func (*UserMessage) MessageType ¶
func (m *UserMessage) MessageType() string
MessageType implements the Message interface.
type UserMessageContent ¶
type UserMessageContent struct {
// contains filtered or unexported fields
}
UserMessageContent represents Claude CLI user message content. Top-level user prompts are emitted as plain strings, while structured responses can use content blocks.
func NewUserMessageContent ¶
func NewUserMessageContent(text string) UserMessageContent
NewUserMessageContent creates UserMessageContent from a string.
func NewUserMessageContentBlocks ¶
func NewUserMessageContentBlocks(blocks []ContentBlock) UserMessageContent
NewUserMessageContentBlocks creates UserMessageContent from blocks.
func (*UserMessageContent) Blocks ¶
func (c *UserMessageContent) Blocks() []ContentBlock
Blocks returns content as []ContentBlock (normalizes string to TextBlock).
func (*UserMessageContent) IsString ¶
func (c *UserMessageContent) IsString() bool
IsString returns true if content was originally a string.
func (UserMessageContent) MarshalJSON ¶
func (c UserMessageContent) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler. Outputs string if content is string, otherwise outputs array of blocks.
func (*UserMessageContent) String ¶
func (c *UserMessageContent) String() string
String returns the string content if it was originally a string, or empty string.
func (*UserMessageContent) UnmarshalJSON ¶
func (c *UserMessageContent) UnmarshalJSON(data []byte) error
UnmarshalJSON implements json.Unmarshaler for the Claude CLI content shapes.