// GENERATED by `harn dump-protocol-artifacts` - do not edit by hand.
// Source: Harn adapter schemas and Rust wire vocabulary.

// Package harnprotocol mirrors the host/integrator surface generated for
// TypeScript, Swift, and Python. Field names match the wire JSON; optional
// fields use pointer types or `omitempty` so encoding/json round-trips
// produce minimal envelopes equivalent to the Rust adapters.
package harnprotocol

import "encoding/json"

// ArtifactVersion pins the Harn release that generated this binding.
const ArtifactVersion = "0.8.104"

// HarnAgentEventMethod is the JSON-RPC method for `_harn/agentEvent` notifications.
const HarnAgentEventMethod = "_harn/agentEvent"

// HarnProviderCatalogMethod is the JSON-RPC method for Harn's provider catalog extension.
const HarnProviderCatalogMethod = "_harn/providerCatalog"

// ACPSchemaCompatibility is the upstream ACP schema version Harn tracks.
const ACPSchemaCompatibility = "agentclientprotocol/agent-client-protocol schema v0.12.2"

// A2AProtocolVersion is the A2A protocol version Harn implements.
const A2AProtocolVersion = "0.3.0"

// MCPProtocolVersion is the MCP protocol version Harn implements.
const MCPProtocolVersion = "2025-11-25"

// MCPStableProtocolVersion is the stable MCP protocol version Harn implements at runtime.
const MCPStableProtocolVersion = "2025-11-25"

// MCPDraftProtocolVersion is the opt-in MCP release-candidate profile identity.
const MCPDraftProtocolVersion = "DRAFT-2026-v1"

// MCPFinal2026ProtocolVersion is the scheduled final identity for the RC profile.
const MCPFinal2026ProtocolVersion = "2026-07-28"

// MCPJSONSchema202012Dialect is the JSON Schema dialect used by the MCP RC artifact profile.
const MCPJSONSchema202012Dialect = "https://json-schema.org/draft/2020-12/schema"

// MCPInputRequiredResultType is the resultType discriminator for multi round-trip requests.
const MCPInputRequiredResultType = "input_required"

// MCPUnsupportedProtocolVersionErrorMessage is the standard message for unsupported versions.
const MCPUnsupportedProtocolVersionErrorMessage = "Unsupported protocol version"

// MCPUnsupportedProtocolVersionErrorCode is the JSON-RPC server error for unsupported versions.
const MCPUnsupportedProtocolVersionErrorCode = -32004

// ACPAgentMethod is the typed alias for the ACPAgentMethods wire vocabulary.
type ACPAgentMethod = string

// ACPAgentMethods enumerates every wire value Harn currently emits for ACPAgentMethod.
var ACPAgentMethods = []ACPAgentMethod{
	"initialize",
	"session/inject",
	"session/new",
	"session/load",
	"session/replace_inject",
	"session/resume",
	"session/prompt",
	"session/revoke_inject",
	"session/truncate",
	"session/rollback",
	"session/redo",
	"session/remind",
	"session/pending_injections",
	"session/revoke_reminder",
	"session/cancel_tool_call",
	"session/close",
	"session/stop",
}

// ACPClientMethod is the typed alias for the ACPClientMethods wire vocabulary.
type ACPClientMethod = string

// ACPClientMethods enumerates every wire value Harn currently emits for ACPClientMethod.
var ACPClientMethods = []ACPClientMethod{
	"fs/read_text_file",
	"fs/write_text_file",
	"terminal/create",
	"terminal/kill",
	"session/request_permission",
}

// ACPAgentNotification is the typed alias for the ACPAgentNotifications wire vocabulary.
type ACPAgentNotification = string

// ACPAgentNotifications enumerates every wire value Harn currently emits for ACPAgentNotification.
var ACPAgentNotifications = []ACPAgentNotification{
	"session/message",
	"session/update",
	"terminal/output",
}

// ACPSessionUpdate is the typed alias for the ACPSessionUpdates wire vocabulary.
type ACPSessionUpdate = string

// ACPSessionUpdates enumerates every wire value Harn currently emits for ACPSessionUpdate.
var ACPSessionUpdates = []ACPSessionUpdate{
	"user_message",
	"user_message_chunk",
	"agent_message_chunk",
	"agent_thought_chunk",
	"tool_call",
	"tool_call_update",
	"plan",
	"available_commands_update",
	"current_mode_update",
	"config_option_update",
	"session_info_update",
	"session_redo",
	"session_rollback",
	"session_truncated",
	"artifact",
	"fs_watch",
	"handoff",
	"hitl_request",
	"hitl_resolved",
	"log",
	"progress",
	"reminder_emitted",
	"skill_activated",
	"skill_deactivated",
	"skill_narrow",
	"skill_scope_tools",
	"tool_search_query",
	"tool_search_result",
	"transcript_compacted",
	"transcript_projected",
	"worker_update",
}

// HarnACPSessionUpdateExtension is the typed alias for the HarnACPSessionUpdateExtensions wire vocabulary.
type HarnACPSessionUpdateExtension = string

// HarnACPSessionUpdateExtensions enumerates every wire value Harn currently emits for HarnACPSessionUpdateExtension.
var HarnACPSessionUpdateExtensions = []HarnACPSessionUpdateExtension{
	"artifact",
	"available_commands_update",
	"fs_watch",
	"handoff",
	"hitl_request",
	"hitl_resolved",
	"log",
	"progress",
	"reminder_emitted",
	"skill_activated",
	"skill_deactivated",
	"skill_narrow",
	"skill_scope_tools",
	"tool_search_query",
	"tool_search_result",
	"transcript_compacted",
	"transcript_projected",
	"worker_update",
}

// HarnAgentEventKind is the typed alias for the HarnAgentEventKinds wire vocabulary.
type HarnAgentEventKind = string

// HarnAgentEventKinds enumerates every wire value Harn currently emits for HarnAgentEventKind.
var HarnAgentEventKinds = []HarnAgentEventKind{
	"budget_circuit_breaker",
	"budget_exhausted",
	"composition_child_call",
	"composition_child_result",
	"composition_error",
	"composition_finish",
	"composition_start",
	"compass_routing_decision",
	"control_outcome",
	"daemon_watchdog_tripped",
	"feedback_injected",
	"iteration_end",
	"iteration_start",
	"judge_decision",
	"loop_control_decision",
	"loop_stuck",
	"mcp_auth_required",
	"mcp_catalog_changed",
	"mcp_notification",
	"progress_reported",
	"scope_classifier_verdict",
	"session_closed",
	"structural_validator_decision",
	"step_judge_decision",
	"tool_call_audit",
	"tool_format_override",
	"typed_checkpoint",
}

// ACPContentBlockType is the typed alias for the ACPContentBlockTypes wire vocabulary.
type ACPContentBlockType = string

// ACPContentBlockTypes enumerates every wire value Harn currently emits for ACPContentBlockType.
var ACPContentBlockTypes = []ACPContentBlockType{
	"text",
	"resource_link",
	"resource",
	"image",
	"audio",
}

// ACPToolKind is the typed alias for the ACPToolKinds wire vocabulary.
type ACPToolKind = string

// ACPToolKinds enumerates every wire value Harn currently emits for ACPToolKind.
var ACPToolKinds = []ACPToolKind{
	"read",
	"edit",
	"delete",
	"move",
	"search",
	"execute",
	"think",
	"fetch",
	"other",
}

// ACPToolCallStatus is the typed alias for the ACPToolCallStatuses wire vocabulary.
type ACPToolCallStatus = string

// ACPToolCallStatuses enumerates every wire value Harn currently emits for ACPToolCallStatus.
var ACPToolCallStatuses = []ACPToolCallStatus{
	"pending",
	"in_progress",
	"completed",
	"failed",
}

// HarnToolCallErrorCategory is the typed alias for the HarnToolCallErrorCategories wire vocabulary.
type HarnToolCallErrorCategory = string

// HarnToolCallErrorCategories enumerates every wire value Harn currently emits for HarnToolCallErrorCategory.
var HarnToolCallErrorCategories = []HarnToolCallErrorCategory{
	"schema_validation",
	"tool_error",
	"mcp_server_error",
	"host_bridge_error",
	"permission_denied",
	"rejected_loop",
	"parse_aborted",
	"timeout",
	"network",
	"cancelled",
	"unknown",
}

// HarnSideEffectLevel is the typed alias for the HarnSideEffectLevels wire vocabulary.
type HarnSideEffectLevel = string

// HarnSideEffectLevels enumerates every wire value Harn currently emits for HarnSideEffectLevel.
var HarnSideEffectLevels = []HarnSideEffectLevel{
	"none",
	"read_only",
	"workspace_write",
	"process_exec",
	"network",
}

// HarnWorkerStatus is the typed alias for the HarnWorkerStatuses wire vocabulary.
type HarnWorkerStatus = string

// HarnWorkerStatuses enumerates every wire value Harn currently emits for HarnWorkerStatus.
var HarnWorkerStatuses = []HarnWorkerStatus{
	"running",
	"progressed",
	"awaiting_input",
	"suspended",
	"completed",
	"failed",
	"stopped",
	"cancelled",
}

// ToolCallReceiptStatus is the typed alias for the ToolCallReceiptStatuses wire vocabulary.
type ToolCallReceiptStatus = string

// ToolCallReceiptStatuses enumerates every wire value Harn currently emits for ToolCallReceiptStatus.
var ToolCallReceiptStatuses = []ToolCallReceiptStatus{
	"ok",
	"schema_violation",
	"consent_denied",
	"timeout",
	"error",
}

// ToolCallReceiptExecutor is the typed alias for the ToolCallReceiptExecutors wire vocabulary.
type ToolCallReceiptExecutor = string

// ToolCallReceiptExecutors enumerates every wire value Harn currently emits for ToolCallReceiptExecutor.
var ToolCallReceiptExecutors = []ToolCallReceiptExecutor{
	"harn",
	"host_bridge",
	"mcp_server",
	"provider_native",
}

// A2ATaskState is the typed alias for the A2ATaskStates wire vocabulary.
type A2ATaskState = string

// A2ATaskStates enumerates every wire value Harn currently emits for A2ATaskState.
var A2ATaskStates = []A2ATaskState{
	"submitted",
	"working",
	"completed",
	"failed",
	"canceled",
	"cancelled",
	"input-required",
	"rejected",
	"auth-required",
}

// A2ATaskEventType is the typed alias for the A2ATaskEventTypes wire vocabulary.
type A2ATaskEventType = string

// A2ATaskEventTypes enumerates every wire value Harn currently emits for A2ATaskEventType.
var A2ATaskEventTypes = []A2ATaskEventType{
	"status",
	"message",
	"worker_update",
}

// MCPProtocolVersionValue is the typed alias for the MCPProtocolVersions wire vocabulary.
type MCPProtocolVersionValue = string

// MCPProtocolVersions enumerates every wire value Harn currently emits for MCPProtocolVersionValue.
var MCPProtocolVersions = []MCPProtocolVersionValue{
	"DRAFT-2026-v1",
	"2025-11-25",
}

// MCPMethod is the typed alias for the MCPMethods wire vocabulary.
type MCPMethod = string

// MCPMethods enumerates every wire value Harn currently emits for MCPMethod.
var MCPMethods = []MCPMethod{
	"server/discover",
	"initialize",
	"tools/list",
	"tools/call",
	"resources/list",
	"resources/read",
	"resources/templates/list",
	"prompts/list",
	"prompts/get",
	"completion/complete",
	"logging/setLevel",
	"sampling/createMessage",
	"elicitation/create",
	"notifications/initialized",
	"notifications/message",
}

// MCPCacheScope is the typed alias for the MCPCacheScopes wire vocabulary.
type MCPCacheScope = string

// MCPCacheScopes enumerates every wire value Harn currently emits for MCPCacheScope.
var MCPCacheScopes = []MCPCacheScope{
	"private",
	"public",
}

// MCPResultType is the typed alias for the MCPResultTypes wire vocabulary.
type MCPResultType = string

// MCPResultTypes enumerates every wire value Harn currently emits for MCPResultType.
var MCPResultTypes = []MCPResultType{
	"complete",
	"input_required",
}

// MCPLoggingLevel is the typed alias for the MCPLoggingLevels wire vocabulary.
type MCPLoggingLevel = string

// MCPLoggingLevels enumerates every wire value Harn currently emits for MCPLoggingLevel.
var MCPLoggingLevels = []MCPLoggingLevel{
	"debug",
	"info",
	"notice",
	"warning",
	"error",
	"critical",
	"alert",
	"emergency",
}

// HarnToolLifecycleExtensionFields enumerates the wire values Harn currently emits.
var HarnToolLifecycleExtensionFields = []string{
	"audit",
	"durationMs",
	"error",
	"errorCategory",
	"executionDurationMs",
	"executor",
	"parsing",
	"rawInputPartial",
}

// HarnContentExtensionFields enumerates the wire values Harn currently emits.
var HarnContentExtensionFields = []string{
	"visible_delta",
	"visible_text",
}

// A2AMethods enumerates the wire values Harn currently emits.
var A2AMethods = []string{
	"message/send",
	"message/stream",
	"tasks/get",
	"tasks/cancel",
	"tasks/resubscribe",
	"tasks/pushNotificationConfig/set",
	"tasks/pushNotificationConfig/get",
	"tasks/pushNotificationConfig/list",
	"tasks/pushNotificationConfig/delete",
	"agent/getAuthenticatedExtendedCard",
}

// MCPRequiredMetadataKeys enumerates the wire values Harn currently emits.
var MCPRequiredMetadataKeys = []string{
	"io.modelcontextprotocol/protocolVersion",
	"io.modelcontextprotocol/clientInfo",
	"io.modelcontextprotocol/clientCapabilities",
}

// MCPMetadataKeys enumerates the wire values Harn currently emits.
var MCPMetadataKeys = []string{
	"io.modelcontextprotocol/protocolVersion",
	"io.modelcontextprotocol/clientInfo",
	"io.modelcontextprotocol/clientCapabilities",
	"io.modelcontextprotocol/logLevel",
	"progressToken",
	"traceparent",
	"tracestate",
	"baggage",
}

// MCPStandardHTTPHeaders enumerates the wire values Harn currently emits.
var MCPStandardHTTPHeaders = []string{
	"MCP-Protocol-Version",
	"Mcp-Method",
	"Mcp-Name",
}

// MCPCacheResultFields enumerates the wire values Harn currently emits.
var MCPCacheResultFields = []string{
	"ttlMs",
	"cacheScope",
}

// JSONValue is the Go counterpart of the TypeScript ACPValue / Python JsonValue
// type. Concrete fields generally use json.RawMessage so callers can defer
// decoding to their own dataclasses.
type JSONValue = json.RawMessage

// JSONObject mirrors `Record<string, JsonValue>`.
type JSONObject = map[string]json.RawMessage

// JSONRPCID encodes a JSON-RPC id, which may be an integer, a string, or null.
// Use NewJSONRPCIDInt / NewJSONRPCIDString to construct, or NullJSONRPCID for
// the null variant.
type JSONRPCID struct {
	raw     json.RawMessage
	present bool
}

// NewJSONRPCIDInt builds a JSON-RPC id from an integer.
func NewJSONRPCIDInt(value int64) JSONRPCID {
	bytes, _ := json.Marshal(value)
	return JSONRPCID{raw: bytes, present: true}
}

// NewJSONRPCIDString builds a JSON-RPC id from a string.
func NewJSONRPCIDString(value string) JSONRPCID {
	bytes, _ := json.Marshal(value)
	return JSONRPCID{raw: bytes, present: true}
}

// NullJSONRPCID returns a JSON-RPC id explicitly encoded as null.
func NullJSONRPCID() JSONRPCID {
	return JSONRPCID{raw: json.RawMessage("null"), present: true}
}

// IsPresent reports whether the id field was present on the wire.
func (id JSONRPCID) IsPresent() bool { return id.present }

// MarshalJSON implements json.Marshaler.
func (id JSONRPCID) MarshalJSON() ([]byte, error) {
	if !id.present {
		return []byte("null"), nil
	}
	return id.raw, nil
}

// UnmarshalJSON implements json.Unmarshaler.
func (id *JSONRPCID) UnmarshalJSON(data []byte) error {
	id.raw = append(id.raw[:0], data...)
	id.present = true
	return nil
}

// Raw exposes the encoded bytes for callers that need to inspect the variant.
func (id JSONRPCID) Raw() json.RawMessage { return id.raw }

// ACPRequest is a JSON-RPC request envelope.
type ACPRequest struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      JSONRPCID       `json:"id"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

// ACPError is the JSON-RPC error sub-envelope.
type ACPError struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

// ACPResponse is a JSON-RPC response envelope.
type ACPResponse struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      JSONRPCID       `json:"id"`
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *ACPError       `json:"error,omitempty"`
}

// ACPNotification is a JSON-RPC notification envelope.
type ACPNotification struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

// HarnExtensionMeta is the canonical envelope for `_meta.harn` payloads.
type HarnExtensionMeta struct {
	Harn JSONObject `json:"harn,omitempty"`
}

// ACPContentBlock is one element inside a session update or message content array.
type ACPContentBlock struct {
	Type string             `json:"type"`
	Text *string            `json:"text,omitempty"`
	Meta *HarnExtensionMeta `json:"_meta,omitempty"`
}

// HarnToolLifecycleMeta is the Harn-specific tool-call lifecycle metadata
// living under `_meta.harn` on tool_call / tool_call_update notifications.
type HarnToolLifecycleMeta struct {
	Audit               json.RawMessage `json:"audit,omitempty"`
	DurationMs          *float64        `json:"durationMs,omitempty"`
	Error               *string         `json:"error,omitempty"`
	ErrorCategory       *string         `json:"errorCategory,omitempty"`
	ExecutionDurationMs *float64        `json:"executionDurationMs,omitempty"`
	Executor            json.RawMessage `json:"executor,omitempty"`
	Parsing             *bool           `json:"parsing,omitempty"`
	RawInputPartial     *string         `json:"rawInputPartial,omitempty"`
}

// ToolCallReceipt is the typed, privacy-preserving receipt emitted for an
// audited tool call.
type ToolCallReceipt struct {
	SchemaVersion int                      `json:"schema_version"`
	SessionID     string                   `json:"session_id"`
	RunID         *string                  `json:"run_id"`
	ToolCallID    string                   `json:"tool_call_id"`
	ToolName      string                   `json:"tool_name"`
	Iteration     uint64                   `json:"iteration"`
	TurnIndex     *uint64                  `json:"turn_index"`
	EmitOrder     uint64                   `json:"emit_order"`
	Reason        *string                  `json:"reason"`
	Kind          *string                  `json:"kind"`
	Executor      *ToolCallReceiptExecutor `json:"executor"`
	Status        ToolCallReceiptStatus    `json:"status"`
	ErrorCategory *string                  `json:"error_category"`
	DurationMs    uint64                   `json:"duration_ms"`
	ArgsHash      string                   `json:"args_hash"`
	ResultHash    *string                  `json:"result_hash"`
	Audit         json.RawMessage          `json:"audit"`
	EmittedAt     string                   `json:"emitted_at"`
	Model         *string                  `json:"model"`
	Provider      *string                  `json:"provider"`
}

// ACPToolCall is the `tool_call` session update.
type ACPToolCall struct {
	SessionUpdate string             `json:"sessionUpdate"`
	ToolCallID    string             `json:"toolCallId"`
	Title         string             `json:"title"`
	Kind          *string            `json:"kind,omitempty"`
	Status        *string            `json:"status,omitempty"`
	Content       []ACPContentBlock  `json:"content,omitempty"`
	Locations     []json.RawMessage  `json:"locations,omitempty"`
	RawInput      json.RawMessage    `json:"rawInput,omitempty"`
	RawOutput     json.RawMessage    `json:"rawOutput,omitempty"`
	Meta          *HarnExtensionMeta `json:"_meta,omitempty"`
}

// ACPToolCallUpdate is the `tool_call_update` session update.
type ACPToolCallUpdate struct {
	SessionUpdate string             `json:"sessionUpdate"`
	ToolCallID    string             `json:"toolCallId"`
	Title         *string            `json:"title,omitempty"`
	Kind          *string            `json:"kind,omitempty"`
	Status        *string            `json:"status,omitempty"`
	Content       []ACPContentBlock  `json:"content,omitempty"`
	Locations     []json.RawMessage  `json:"locations,omitempty"`
	RawInput      json.RawMessage    `json:"rawInput,omitempty"`
	RawOutput     json.RawMessage    `json:"rawOutput,omitempty"`
	Meta          *HarnExtensionMeta `json:"_meta,omitempty"`
}

// ACPSessionUpdateEnvelope is the discriminated `update` payload carried inside
// an ACP `session/update` notification. Only fields relevant to a given
// `sessionUpdate` discriminator will be populated; the rest stay zero-value
// and are stripped via `omitempty` on serialization.
type ACPSessionUpdateEnvelope struct {
	SessionUpdate    string             `json:"sessionUpdate"`
	Content          json.RawMessage    `json:"content,omitempty"`
	MessageID        *string            `json:"messageId,omitempty"`
	Entries          []json.RawMessage  `json:"entries,omitempty"`
	KeptTurnCount    *int               `json:"keptTurnCount,omitempty"`
	RemovedTurnCount *int               `json:"removedTurnCount,omitempty"`
	NewTipTurnID     *string            `json:"newTipTurnId,omitempty"`
	Reason           *string            `json:"reason,omitempty"`
	ToolCallID       *string            `json:"toolCallId,omitempty"`
	Title            *string            `json:"title,omitempty"`
	Kind             *string            `json:"kind,omitempty"`
	Status           *string            `json:"status,omitempty"`
	RawInput         json.RawMessage    `json:"rawInput,omitempty"`
	RawOutput        json.RawMessage    `json:"rawOutput,omitempty"`
	Meta             *HarnExtensionMeta `json:"_meta,omitempty"`
}

// ACPSessionUpdateParams is the params payload of `session/update`.
type ACPSessionUpdateParams struct {
	SessionID string                   `json:"sessionId"`
	Update    ACPSessionUpdateEnvelope `json:"update"`
}

// ACPSessionUpdateNotification is the full `session/update` envelope.
type ACPSessionUpdateNotification struct {
	JSONRPC string                 `json:"jsonrpc"`
	Method  string                 `json:"method"`
	Params  ACPSessionUpdateParams `json:"params"`
}

// HarnAgentEventNotification is the `_harn/agentEvent` envelope.
type HarnAgentEventNotification struct {
	JSONRPC string     `json:"jsonrpc"`
	Method  string     `json:"method"`
	Params  JSONObject `json:"params"`
}

// HarnToolArgSchema describes the static slice of a Harn tool's argument shape.
type HarnToolArgSchema struct {
	PathParams []string          `json:"path_params"`
	ArgAliases map[string]string `json:"arg_aliases"`
	Required   []string          `json:"required"`
}

// HarnToolAnnotations describes Harn-side metadata for a tool.
type HarnToolAnnotations struct {
	Kind            string              `json:"kind"`
	SideEffectLevel string              `json:"side_effect_level"`
	ArgSchema       HarnToolArgSchema   `json:"arg_schema"`
	Capabilities    map[string][]string `json:"capabilities"`
	EmitsArtifacts  bool                `json:"emits_artifacts"`
	ResultReaders   []string            `json:"result_readers"`
	InlineResult    bool                `json:"inline_result"`
}

// A2AMessage is one message inside an A2A task history.
type A2AMessage struct {
	ID    string            `json:"id"`
	Role  string            `json:"role"`
	Parts []json.RawMessage `json:"parts"`
}

// A2ATaskStatus is the status block on an A2A task.
type A2ATaskStatus struct {
	State     string      `json:"state"`
	Message   *A2AMessage `json:"message,omitempty"`
	Timestamp *string     `json:"timestamp,omitempty"`
}

// A2ATask is the canonical A2A task envelope.
type A2ATask struct {
	ID        string            `json:"id"`
	ContextID *string           `json:"contextId,omitempty"`
	Status    A2ATaskStatus     `json:"status"`
	History   []A2AMessage      `json:"history,omitempty"`
	Artifacts []json.RawMessage `json:"artifacts,omitempty"`
	Metadata  JSONObject        `json:"metadata,omitempty"`
}

// MCPJSONSchema202012 is the JSON Schema dialect surface used by the MCP RC
// tool input/output schema profile.
type MCPJSONSchema202012 = JSONObject

// MCPImplementation describes an MCP client or server implementation.
type MCPImplementation struct {
	Name        string  `json:"name"`
	Version     string  `json:"version"`
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
	WebsiteURL  *string `json:"websiteUrl,omitempty"`
}

// MCPRequestMeta is the per-request metadata required by the MCP RC profile.
type MCPRequestMeta struct {
	ProtocolVersion    string            `json:"io.modelcontextprotocol/protocolVersion"`
	ClientInfo         MCPImplementation `json:"io.modelcontextprotocol/clientInfo"`
	ClientCapabilities JSONObject        `json:"io.modelcontextprotocol/clientCapabilities"`
	LogLevel           *MCPLoggingLevel  `json:"io.modelcontextprotocol/logLevel,omitempty"`
	ProgressToken      json.RawMessage   `json:"progressToken,omitempty"`
	Traceparent        *string           `json:"traceparent,omitempty"`
	Tracestate         *string           `json:"tracestate,omitempty"`
	Baggage            *string           `json:"baggage,omitempty"`
}

// MCPHTTPHeaders names the HTTP headers used by the MCP RC Streamable HTTP profile.
type MCPHTTPHeaders struct {
	ProtocolVersion string  `json:"MCP-Protocol-Version"`
	Method          string  `json:"Mcp-Method"`
	Name            *string `json:"Mcp-Name,omitempty"`
}

// MCPCacheHints captures the RC ttlMs/cacheScope cache fields.
type MCPCacheHints struct {
	TTLMS      uint64        `json:"ttlMs"`
	CacheScope MCPCacheScope `json:"cacheScope"`
}

// MCPDiscoverResult is the result returned by server/discover.
type MCPDiscoverResult struct {
	ResultType        MCPResultType     `json:"resultType"`
	SupportedVersions []string          `json:"supportedVersions"`
	Capabilities      JSONObject        `json:"capabilities"`
	ServerInfo        MCPImplementation `json:"serverInfo"`
	Instructions      *string           `json:"instructions,omitempty"`
	Meta              JSONObject        `json:"_meta,omitempty"`
}

// MCPInputRequiredResult carries server-to-client requests for multi round-trip calls.
type MCPInputRequiredResult struct {
	ResultType    MCPResultType `json:"resultType"`
	InputRequests JSONObject    `json:"inputRequests,omitempty"`
	RequestState  *string       `json:"requestState,omitempty"`
	Meta          JSONObject    `json:"_meta,omitempty"`
}

// MCPUnsupportedProtocolVersionErrorData is the typed data payload for -32004.
type MCPUnsupportedProtocolVersionErrorData struct {
	Requested string   `json:"requested"`
	Supported []string `json:"supported"`
}

// MCPUnsupportedProtocolVersionError is the JSON-RPC error response shape for
// an unsupported MCP protocol version.
type MCPUnsupportedProtocolVersionError struct {
	JSONRPC string    `json:"jsonrpc"`
	ID      JSONRPCID `json:"id,omitempty"`
	Error   ACPError  `json:"error"`
}

// MCPTool is the MCP `tools/list` entry.
type MCPTool struct {
	Name         string              `json:"name"`
	Title        *string             `json:"title,omitempty"`
	Description  *string             `json:"description,omitempty"`
	InputSchema  MCPJSONSchema202012 `json:"inputSchema"`
	OutputSchema MCPJSONSchema202012 `json:"outputSchema,omitempty"`
	Annotations  JSONObject          `json:"annotations,omitempty"`
}

// MCPResource is the MCP `resources/list` entry.
type MCPResource struct {
	URI         string  `json:"uri"`
	Name        string  `json:"name"`
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
	MimeType    *string `json:"mimeType,omitempty"`
}

// MCPResourceTemplate is the MCP `resources/templates/list` entry.
type MCPResourceTemplate struct {
	URITemplate string  `json:"uriTemplate"`
	Name        string  `json:"name"`
	Title       *string `json:"title,omitempty"`
	Description *string `json:"description,omitempty"`
	MimeType    *string `json:"mimeType,omitempty"`
}

// MCPPrompt is the MCP `prompts/list` entry.
type MCPPrompt struct {
	Name        string       `json:"name"`
	Title       *string      `json:"title,omitempty"`
	Description *string      `json:"description,omitempty"`
	Arguments   []JSONObject `json:"arguments,omitempty"`
}

// IsRequest reports whether a decoded JSON-RPC envelope is a request.
func IsRequest(envelope map[string]json.RawMessage) bool {
	_, hasID := envelope["id"]
	_, hasMethod := envelope["method"]
	return hasID && hasMethod
}

// IsResponse reports whether a decoded JSON-RPC envelope is a response.
func IsResponse(envelope map[string]json.RawMessage) bool {
	_, hasID := envelope["id"]
	_, hasMethod := envelope["method"]
	return hasID && !hasMethod
}

// IsNotification reports whether a decoded JSON-RPC envelope is a notification.
func IsNotification(envelope map[string]json.RawMessage) bool {
	_, hasID := envelope["id"]
	_, hasMethod := envelope["method"]
	return !hasID && hasMethod
}
