//go:build go1.22

// Code generated by scripts/gen-asyncapi-go. DO NOT EDIT.
// Source: contracts/asyncapi.yaml
//
// Regenerate with:
//   cd scripts/gen-asyncapi-go &&
//   go run . ../../contracts/asyncapi.yaml ../../pkg/api/generated/asyncapi_types.gen.go

package generated

import "time"

// Ensure time is used even if no date-time fields are present.
var _ = time.Time{}

// AgentSwitchedFrame — Server → client active agent changed.
type AgentSwitchedFrame struct {
	AgentId   *string `json:"agent_id,omitempty"`
	Message   *string `json:"message,omitempty"`
	SessionId string  `json:"session_id"`
	Type      string  `json:"type"`
}

// AttachSessionFrame — Client → server request to attach to an existing session. When `since` is provided, the server skips replay frames whose timestamp <= `since`, sending only frames the SPA has not yet seen. Omitting `since` requests a full replay (legacy behaviour).
type AttachSessionFrame struct {
	SessionId string `json:"session_id"`
	// ISO 8601 timestamp of the most recent frame the SPA has already processed. Server replays only frames with timestamp > this value. Used to keep reconnect replay traffic O(missed window) instead of O(full session history).
	Since *string `json:"since,omitempty"`
	Type  string  `json:"type"`
}

// AuthFrame — Client → server authentication frame.
type AuthFrame struct {
	// Bearer token from /api/v1/auth/login. Format is "omnipus_" + 64 hex chars.
	Token string `json:"token"`
	Type  string `json:"type"`
}

// CancelFrame — Client → server cancel in-progress turn.
type CancelFrame struct {
	SessionId string `json:"session_id"`
	Type      string `json:"type"`
}

// CancelStageFrame — Server → client cancel progress notification (B3). stage MUST be one of three values — SPA validates via isValidFrame() and drops invalid stages.
type CancelStageFrame struct {
	SessionId string `json:"session_id"`
	Stage     string `json:"stage"`
	Type      string `json:"type"`
}

// DevicePairingRequestFrame — Server → client device pairing request needs admin approval.
type DevicePairingRequestFrame struct {
	DeviceId    string  `json:"device_id"`
	DeviceName  *string `json:"device_name,omitempty"`
	Fingerprint *string `json:"fingerprint,omitempty"`
	PairingCode *string `json:"pairing_code,omitempty"`
	SessionId   *string `json:"session_id,omitempty"`
	Type        string  `json:"type"`
}

// DevicePairingResponseFrame — Client → server device pairing decision.
type DevicePairingResponseFrame struct {
	Decision string `json:"decision"`
	DeviceId string `json:"device_id"`
	Type     string `json:"type"`
}

// DoneFrame — Server → client turn complete.
type DoneFrame struct {
	SessionId string     `json:"session_id"`
	Stats     *DoneStats `json:"stats,omitempty"`
	Type      string     `json:"type"`
}

// DoneStats — Per-turn statistics in a done frame. additionalProperties are allowed for replay extras (frames_emitted, orphan_count, etc.).
type DoneStats struct {
	Cost                     *float64 `json:"cost,omitempty"`
	DuplicateToolCallIdCount *float64 `json:"duplicate_tool_call_id_count,omitempty"`
	DurationMs               *float64 `json:"duration_ms,omitempty"`
	FramesEmitted            *float64 `json:"frames_emitted,omitempty"`
	OrphanCount              *float64 `json:"orphan_count,omitempty"`
	ReplayError              *bool    `json:"replay_error,omitempty"`
	Tokens                   *float64 `json:"tokens,omitempty"`
	TokensDropped            *float64 `json:"tokens_dropped,omitempty"`
	TruncatedResultCount     *float64 `json:"truncated_result_count,omitempty"`
}

// ErrorFrame — Server → client error notification.
type ErrorFrame struct {
	Message   string  `json:"message"`
	SessionId *string `json:"session_id,omitempty"`
	Type      string  `json:"type"`
}

// ExecApprovalExpiredFrame — Server → client exec approval request timed out.
type ExecApprovalExpiredFrame struct {
	Id        string  `json:"id"`
	Message   *string `json:"message,omitempty"`
	SessionId string  `json:"session_id"`
	Type      string  `json:"type"`
}

// ExecApprovalRequestFrame — Server → client exec approval needed. The `command` field carries the tool name for display. Optional `tool` and `params` carry structured tool call information.
type ExecApprovalRequestFrame struct {
	// Tool name used as primary display string in the approval modal.
	Command       string  `json:"command"`
	Id            string  `json:"id"`
	MatchedPolicy *string `json:"matched_policy,omitempty"`
	// Human-readable approval request message.
	Message *string `json:"message,omitempty"`
	// Tool invocation arguments. May be absent for parameter-less tools.
	Params    map[string]any `json:"params,omitempty"`
	SessionId string         `json:"session_id"`
	// Structured tool name (same value as command).
	Tool       *string `json:"tool,omitempty"`
	Type       string  `json:"type"`
	WorkingDir *string `json:"working_dir,omitempty"`
}

// ExecApprovalResponseAckFrame — Server → client exec approval response acknowledged.
type ExecApprovalResponseAckFrame struct {
	Id        *string `json:"id,omitempty"`
	SessionId *string `json:"session_id,omitempty"`
	Type      string  `json:"type"`
}

// ExecApprovalResponseFrame — Client → server exec approval decision.
type ExecApprovalResponseFrame struct {
	Decision string `json:"decision"`
	Id       string `json:"id"`
	Type     string `json:"type"`
}

// MarshalErrorResult — Sentinel for tool results that failed json.Marshal.
type MarshalErrorResult struct {
	MarshalError string `json:"_marshal_error"`
}

// MediaFrame — Server → client media attachments. parts MUST be a non-empty array (never null) — nil-safety contract to prevent parts.map() crash.
type MediaFrame struct {
	Parts     []MediaPart `json:"parts"`
	SessionId string      `json:"session_id"`
	Type      string      `json:"type"`
}

// MediaPart — One media attachment.
type MediaPart struct {
	Caption     *string `json:"caption,omitempty"`
	ContentType string  `json:"content_type"`
	Filename    string  `json:"filename"`
	Type        string  `json:"type"`
	Url         string  `json:"url"`
}

// MessageFrame — Client → server user chat message. Omit session_id to start a new session; include to continue an existing one.
type MessageFrame struct {
	AgentId *string `json:"agent_id,omitempty"`
	Content string  `json:"content"`
	// Optional media:// refs for files the user attached to this message (e.g. images uploaded via POST /api/v1/upload). The server threads each ref into the LLM content array as a multimodal content block so the agent can see the attachment. Empty or omitted for text-only messages.
	Media     []string `json:"media,omitempty"`
	SessionId *string  `json:"session_id,omitempty"`
	Type      string   `json:"type"`
}

// PingFrame — Client → server heartbeat.
type PingFrame struct {
	Type string `json:"type"`
}

// PongFrame — Server → client heartbeat acknowledgement. Emitted in response to every client PingFrame so the SPA's "any frame received recently" liveness check observes a server frame during idle and does not force-close after 60 s of silence.
type PongFrame struct {
	Type string `json:"type"`
}

// RateLimitFrame — Server → client rate limit applied (SEC-26).
type RateLimitFrame struct {
	AgentId           *string `json:"agent_id,omitempty"`
	PolicyRule        string  `json:"policy_rule"`
	Resource          string  `json:"resource"`
	RetryAfterSeconds float64 `json:"retry_after_seconds"`
	Scope             string  `json:"scope"`
	SessionId         string  `json:"session_id"`
	Tool              *string `json:"tool,omitempty"`
	Type              string  `json:"type"`
}

// ReplayMessageFrame — Server → client replayed transcript entry.
type ReplayMessageFrame struct {
	AgentId   *string `json:"agent_id,omitempty"`
	Content   string  `json:"content"`
	Id        *string `json:"id,omitempty"`
	Role      string  `json:"role"`
	SessionId string  `json:"session_id"`
	Timestamp *string `json:"timestamp,omitempty"`
	Type      string  `json:"type"`
}

// ReplayWarningFrame — Server → client duplicate tool_call_ids detected.
type ReplayWarningFrame struct {
	Message   string              `json:"message"`
	SessionId string              `json:"session_id"`
	Stats     *ReplayWarningStats `json:"stats,omitempty"`
	Type      string              `json:"type"`
}

// ReplayWarningStats — Diagnostic counters in a ReplayWarningFrame.
type ReplayWarningStats struct {
	DuplicateToolCallIdCount *int `json:"duplicate_tool_call_id_count,omitempty"`
}

// SessionCloseAckFrame — Server → client session close acknowledged.
type SessionCloseAckFrame struct {
	Id        *string `json:"id,omitempty"`
	SessionId string  `json:"session_id"`
	Type      string  `json:"type"`
}

// SessionCloseFrame — Client → server explicit session close request.
type SessionCloseFrame struct {
	SessionId string `json:"session_id"`
	Type      string `json:"type"`
}

// SessionStartedFrame — Server → client new session minted.
type SessionStartedFrame struct {
	AgentId   *string `json:"agent_id,omitempty"`
	SessionId string  `json:"session_id"`
	Type      string  `json:"type"`
}

// SessionStateFrame — Server → client reconnect approval snapshot (FR-052, FR-073, FR-081). pending_approvals MUST be an array (never null). Backend coerces nil → []. SPA calls pending_approvals.map() — null crashes at render time.
type SessionStateFrame struct {
	EmittedAt string `json:"emitted_at"`
	// Always array, never null. Capped at 1000.
	PendingApprovals []SessionStatePendingApproval `json:"pending_approvals"`
	Type             string                        `json:"type"`
	UserId           string                        `json:"user_id"`
}

// SessionStatePendingApproval — One pending approval entry in a SessionStateFrame.
type SessionStatePendingApproval struct {
	AgentId     string `json:"agent_id"`
	ApprovalId  string `json:"approval_id"`
	ExpiresInMs int    `json:"expires_in_ms"`
	SessionId   string `json:"session_id"`
	ToolName    string `json:"tool_name"`
}

// SubagentEndFrame — Server → client subagent span closed (FR-H-004). status MUST be one of the five allowed values — the SPA drops frames with invalid status (W4-6).
type SubagentEndFrame struct {
	AgentId      *string `json:"agent_id,omitempty"`
	DurationMs   *int    `json:"duration_ms,omitempty"`
	FinalResult  *string `json:"final_result,omitempty"`
	Message      *string `json:"message,omitempty"`
	ParentCallId *string `json:"parent_call_id,omitempty"`
	Reason       *string `json:"reason,omitempty"`
	SessionId    string  `json:"session_id"`
	SpanId       string  `json:"span_id"`
	Status       string  `json:"status"`
	Type         string  `json:"type"`
}

// SubagentStartFrame — Server → client subagent span opened (FR-H-004).
type SubagentStartFrame struct {
	AgentId      *string `json:"agent_id,omitempty"`
	ParentCallId string  `json:"parent_call_id"`
	SessionId    string  `json:"session_id"`
	SpanId       string  `json:"span_id"`
	TaskLabel    string  `json:"task_label"`
	Type         string  `json:"type"`
}

// SystemOverloadFrame — Server → client system at capacity (FR-016, MAJ-009).
type SystemOverloadFrame struct {
	Message   *string `json:"message,omitempty"`
	SessionId string  `json:"session_id"`
	Type      string  `json:"type"`
}

// TaskStatusChangedFrame — Server → client task status updated.
type TaskStatusChangedFrame struct {
	AgentId   *string `json:"agent_id,omitempty"`
	SessionId string  `json:"session_id"`
	Status    string  `json:"status"`
	TaskId    string  `json:"task_id"`
	Type      string  `json:"type"`
}

// TokenFrame — Server → client partial LLM response token.
type TokenFrame struct {
	Content   string `json:"content"`
	SessionId string `json:"session_id"`
	Type      string `json:"type"`
}

// ToolApprovalRequiredFrame — Server → client tool approval needed (FR-011, FR-082). CRITICAL: args MUST be object (never null). Backend coerces nil → {}. SPA calls Object.keys(args) — null crashes at render time (Ava-chat bug).
type ToolApprovalRequiredFrame struct {
	AgentId    string `json:"agent_id"`
	ApprovalId string `json:"approval_id"`
	// Tool invocation arguments. Always object, never null. Required + object type so the Phase 4 contract test catches any nil regression.
	Args        map[string]any `json:"args"`
	ExpiresInMs int            `json:"expires_in_ms"`
	SessionId   string         `json:"session_id"`
	ToolCallId  string         `json:"tool_call_id"`
	ToolName    string         `json:"tool_name"`
	TurnId      string         `json:"turn_id"`
	Type        string         `json:"type"`
}

// ToolCallResultFrame — Server → client tool execution completed.
type ToolCallResultFrame struct {
	AgentId      *string `json:"agent_id,omitempty"`
	CallId       string  `json:"call_id"`
	DurationMs   *int    `json:"duration_ms,omitempty"`
	Error        *string `json:"error,omitempty"`
	ParentCallId *string `json:"parent_call_id,omitempty"`
	// Tool return value. Any JSON type or null (null is the contract for error frames). Sentinels TruncatedResult, MarshalErrorResult, and ToolResultRef are alternative shapes.
	Result    any    `json:"result"`
	SessionId string `json:"session_id"`
	Status    string `json:"status"`
	Tool      string `json:"tool"`
	Type      string `json:"type"`
}

// ToolCallStartFrame — Server → client tool execution started. params MUST be object (never null) — nil-safety contract to prevent Object.keys(params) crash.
type ToolCallStartFrame struct {
	AgentId *string `json:"agent_id,omitempty"`
	CallId  string  `json:"call_id"`
	// Tool arguments. Always object, never null.
	Params       map[string]any `json:"params"`
	ParentCallId *string        `json:"parent_call_id,omitempty"`
	SessionId    string         `json:"session_id"`
	Tool         string         `json:"tool"`
	Type         string         `json:"type"`
}

// ToolResultRef — Sentinel for tool results > 50 KiB but <= 1 MiB whose full body is preserved server-side. SPA fetches via GET /api/v1/tool-results/{ref}.
type ToolResultRef struct {
	IsRef             bool   `json:"_ref"`
	OriginalSizeBytes int    `json:"original_size_bytes"`
	Preview           string `json:"preview"`
	Ref               string `json:"ref"`
}

// TruncatedResult — Sentinel for tool results exceeding 1 MiB (FR-I-011).
type TruncatedResult struct {
	Truncated         bool   `json:"_truncated"`
	OriginalSizeBytes int    `json:"original_size_bytes"`
	Preview           string `json:"preview"`
}

// WsFrameType — Enum of all WebSocket frame type discriminator strings.
type WsFrameType string

// Defines values for WsFrameType.
const (
	WsFrameTypeAuth                    WsFrameType = "auth"
	WsFrameTypeMessage                 WsFrameType = "message"
	WsFrameTypeCancel                  WsFrameType = "cancel"
	WsFrameTypeExecApprovalResponse    WsFrameType = "exec_approval_response"
	WsFrameTypePing                    WsFrameType = "ping"
	WsFrameTypeAttachSession           WsFrameType = "attach_session"
	WsFrameTypeDevicePairingResponse   WsFrameType = "device_pairing_response"
	WsFrameTypeSessionClose            WsFrameType = "session_close"
	WsFrameTypeSessionStarted          WsFrameType = "session_started"
	WsFrameTypeToken                   WsFrameType = "token"
	WsFrameTypeDone                    WsFrameType = "done"
	WsFrameTypeError                   WsFrameType = "error"
	WsFrameTypeToolCallStart           WsFrameType = "tool_call_start"
	WsFrameTypeToolCallResult          WsFrameType = "tool_call_result"
	WsFrameTypeSubagentStart           WsFrameType = "subagent_start"
	WsFrameTypeSubagentEnd             WsFrameType = "subagent_end"
	WsFrameTypeExecApprovalRequest     WsFrameType = "exec_approval_request"
	WsFrameTypeExecApprovalExpired     WsFrameType = "exec_approval_expired"
	WsFrameTypeTaskStatusChanged       WsFrameType = "task_status_changed"
	WsFrameTypeReplayMessage           WsFrameType = "replay_message"
	WsFrameTypeRateLimit               WsFrameType = "rate_limit"
	WsFrameTypeMedia                   WsFrameType = "media"
	WsFrameTypeAgentSwitched           WsFrameType = "agent_switched"
	WsFrameTypeToolApprovalRequired    WsFrameType = "tool_approval_required"
	WsFrameTypeSessionState            WsFrameType = "session_state"
	WsFrameTypeSystemOverload          WsFrameType = "system_overload"
	WsFrameTypeReplayWarning           WsFrameType = "replay_warning"
	WsFrameTypeCancelStage             WsFrameType = "cancel_stage"
	WsFrameTypePong                    WsFrameType = "pong"
	WsFrameTypeSessionCloseAck         WsFrameType = "session_close_ack"
	WsFrameTypeExecApprovalResponseAck WsFrameType = "exec_approval_response_ack"
	WsFrameTypeDevicePairingRequest    WsFrameType = "device_pairing_request"
)
