// Code generated by internal/schemagen. DO NOT EDIT.

package schema

import (
	"encoding/json"
	"fmt"
)

// Optional annotations for the client. The client can use annotations to inform how objects are used or displayed
// Annotations represents a [schema] type.
type Annotations struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta         Meta     `json:"_meta,omitempty"`
	Audience     []*Role  `json:"audience,omitempty"`
	LastModified *string  `json:"lastModified,omitempty"`
	Priority     *float64 `json:"priority,omitempty"`
}

// Audio provided to or from an LLM
// AudioContent represents a [schema] type.
type AudioContent struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta        Meta         `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Data        string       `json:"data"`
	MimeType    string       `json:"mimeType"`
}

// Binary resource contents
// BlobResourceContents represents a [schema] type.
type BlobResourceContents struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta     Meta    `json:"_meta,omitempty"`
	Blob     string  `json:"blob"`
	MimeType *string `json:"mimeType,omitempty"`
	Uri      string  `json:"uri"`
}

// Content blocks represent displayable information in the Agent Client Protocol.
// They provide a structured way to handle various types of user-facing content—whether
// it's text from language models, images for analysis, or embedded resources for context.
// Content blocks appear in:
// - User prompts sent via `session/prompt`
// - Language model output streamed through `session/update` notifications
// - Progress updates and results from tool calls
// This structure is compatible with the Model Context Protocol (MCP), enabling
// agents to seamlessly forward content from MCP tool outputs without transformation.
// See protocol docs: [Content](https://agentclientprotocol.com/protocol/content)
// TypeContentBlockKind defines the values for TypeContentBlockKind.
type TypeContentBlockKind string

const (
	TypeContentBlockKindAudio         TypeContentBlockKind = "audio"
	TypeContentBlockKindImage         TypeContentBlockKind = "image"
	TypeContentBlockKindResource      TypeContentBlockKind = "resource"
	TypeContentBlockKindResource_link TypeContentBlockKind = "resource_link"
	TypeContentBlockKindText          TypeContentBlockKind = "text"
)

// ContentBlock is a discriminated union.
type ContentBlock struct {
	Type          TypeContentBlockKind `json:"type"`
	Text          *TextContent         `json:"-"`
	Image         *ImageContent        `json:"-"`
	Audio         *AudioContent        `json:"-"`
	Resource_link *ResourceLink        `json:"-"`
	Resource      *EmbeddedResource    `json:"-"`
}

func (u ContentBlock) MarshalJSON() ([]byte, error) {
	switch u.Type {
	case TypeContentBlockKindAudio:
		return marshalWith(u.Audio, "type", "audio")
	case TypeContentBlockKindImage:
		return marshalWith(u.Image, "type", "image")
	case TypeContentBlockKindResource:
		return marshalWith(u.Resource, "type", "resource")
	case TypeContentBlockKindResource_link:
		return marshalWith(u.Resource_link, "type", "resource_link")
	case TypeContentBlockKindText:
		return marshalWith(u.Text, "type", "text")
	default:
		return json.Marshal(map[string]TypeContentBlockKind{"type": u.Type})
	}
}

func (u *ContentBlock) UnmarshalJSON(data []byte) error {
	var raw map[string]json.RawMessage
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	discrim, ok := raw["type"]
	if !ok {
		return fmt.Errorf("missing type field")
	}
	var dv string
	if err := json.Unmarshal(discrim, &dv); err != nil {
		return err
	}
	u.Type = TypeContentBlockKind(dv)
	switch u.Type {
	case TypeContentBlockKindAudio:
		u.Audio = &AudioContent{}
		return json.Unmarshal(data, u.Audio)
	case TypeContentBlockKindImage:
		u.Image = &ImageContent{}
		return json.Unmarshal(data, u.Image)
	case TypeContentBlockKindResource:
		u.Resource = &EmbeddedResource{}
		return json.Unmarshal(data, u.Resource)
	case TypeContentBlockKindResource_link:
		u.Resource_link = &ResourceLink{}
		return json.Unmarshal(data, u.Resource_link)
	case TypeContentBlockKindText:
		u.Text = &TextContent{}
		return json.Unmarshal(data, u.Text)
	default:
		return nil
	}
}

// The contents of a resource, embedded into a prompt or tool call result
// EmbeddedResource represents a [schema] type.
type EmbeddedResource struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta        Meta                      `json:"_meta,omitempty"`
	Annotations *Annotations              `json:"annotations,omitempty"`
	Resource    *EmbeddedResourceResource `json:"resource"`
}

// Resource content that can be embedded in a message
// TypeEmbeddedResourceResourceKind defines the values for TypeEmbeddedResourceResourceKind.
type TypeEmbeddedResourceResourceKind string

const (
	TypeEmbeddedResourceResourceKindBlobResourceContents TypeEmbeddedResourceResourceKind = "blobresourcecontents"
	TypeEmbeddedResourceResourceKindTextResourceContents TypeEmbeddedResourceResourceKind = "textresourcecontents"
)

// EmbeddedResourceResource is a discriminated union.
type EmbeddedResourceResource struct {
	Type                 TypeEmbeddedResourceResourceKind `json:"type"`
	TextResourceContents *TextResourceContents            `json:"-"`
	BlobResourceContents *BlobResourceContents            `json:"-"`
}

func (u EmbeddedResourceResource) MarshalJSON() ([]byte, error) {
	switch u.Type {
	case TypeEmbeddedResourceResourceKindBlobResourceContents:
		return marshalWith(u.BlobResourceContents, "type", "blobresourcecontents")
	case TypeEmbeddedResourceResourceKindTextResourceContents:
		return marshalWith(u.TextResourceContents, "type", "textresourcecontents")
	default:
		return json.Marshal(map[string]TypeEmbeddedResourceResourceKind{"type": u.Type})
	}
}

func (u *EmbeddedResourceResource) UnmarshalJSON(data []byte) error {
	var raw map[string]json.RawMessage
	if err := json.Unmarshal(data, &raw); err != nil {
		return err
	}
	discrim, ok := raw["type"]
	if !ok {
		return fmt.Errorf("missing type field")
	}
	var dv string
	if err := json.Unmarshal(discrim, &dv); err != nil {
		return err
	}
	u.Type = TypeEmbeddedResourceResourceKind(dv)
	switch u.Type {
	case TypeEmbeddedResourceResourceKindBlobResourceContents:
		u.BlobResourceContents = &BlobResourceContents{}
		return json.Unmarshal(data, u.BlobResourceContents)
	case TypeEmbeddedResourceResourceKindTextResourceContents:
		u.TextResourceContents = &TextResourceContents{}
		return json.Unmarshal(data, u.TextResourceContents)
	default:
		return nil
	}
}

// An image provided to or from an LLM
// ImageContent represents a [schema] type.
type ImageContent struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta        Meta         `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Data        string       `json:"data"`
	MimeType    string       `json:"mimeType"`
	Uri         *string      `json:"uri,omitempty"`
}

// A resource that the server is capable of reading, included in a prompt or tool call result
// ResourceLink represents a [schema] type.
type ResourceLink struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta        Meta         `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Description *string      `json:"description,omitempty"`
	MimeType    *string      `json:"mimeType,omitempty"`
	Name        string       `json:"name"`
	Size        *int         `json:"size,omitempty"`
	Title       *string      `json:"title,omitempty"`
	Uri         string       `json:"uri"`
}

// Text provided to or from an LLM
// TextContent represents a [schema] type.
type TextContent struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta        Meta         `json:"_meta,omitempty"`
	Annotations *Annotations `json:"annotations,omitempty"`
	Text        string       `json:"text"`
}

// Text-based resource contents
// TextResourceContents represents a [schema] type.
type TextResourceContents struct {
	// The _meta property is reserved by ACP to allow clients and agents to attach additional
	Meta     Meta    `json:"_meta,omitempty"`
	MimeType *string `json:"mimeType,omitempty"`
	Text     string  `json:"text"`
	Uri      string  `json:"uri"`
}
