protocol

package
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 11, 2025 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CancellationParams

type CancellationParams struct {
	RequestID string `json:"requestId"`
	Reason    string `json:"reason,omitempty"`
}

CancellationParams represents parameters for a cancellation notification

type ClientCapabilities

type ClientCapabilities struct {
	Roots        *RootsCapability       `json:"roots,omitempty"`
	Sampling     *SamplingCapability    `json:"sampling,omitempty"`
	Experimental map[string]interface{} `json:"experimental,omitempty"`
}

ClientCapabilities describes the features supported by the client

type ClientInfo

type ClientInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

ClientInfo contains information about the client implementation

type CompletionArgument

type CompletionArgument struct {
	Name  string `json:"name"`
	Value string `json:"value"`
}

CompletionArgument represents the argument being completed

type CompletionReference

type CompletionReference struct {
	Type string `json:"type"` // "ref/prompt" or "ref/resource"
	Name string `json:"name,omitempty"`
	URI  string `json:"uri,omitempty"`
}

CompletionReference represents what is being completed

type CompletionResult

type CompletionResult struct {
	Values  []string `json:"values"`
	Total   *int     `json:"total,omitempty"`
	HasMore bool     `json:"hasMore"`
}

CompletionResult represents completion suggestions

type CreateMessageRequest

type CreateMessageRequest struct {
	Messages         []Message        `json:"messages"`
	ModelPreferences ModelPreferences `json:"modelPreferences,omitempty"`
	SystemPrompt     string           `json:"systemPrompt,omitempty"`
	MaxTokens        int              `json:"maxTokens,omitempty"`
}

CreateMessageRequest represents a request to create a message

type CreateMessageResponse

type CreateMessageResponse struct {
	Role       string         `json:"role"`
	Content    MessageContent `json:"content"`
	Model      string         `json:"model,omitempty"`
	StopReason string         `json:"stopReason,omitempty"`
}

CreateMessageResponse represents the response to a create message request

type Error

type Error struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Data    json.RawMessage `json:"data,omitempty"`
}

Error represents a JSON-RPC 2.0 error.

type InitializeParams

type InitializeParams struct {
	ProtocolVersion string             `json:"protocolVersion"`
	Capabilities    ClientCapabilities `json:"capabilities"`
	ClientInfo      ClientInfo         `json:"clientInfo"`
}

InitializeParams represents the parameters for an initialize request

type InitializeResult

type InitializeResult struct {
	ProtocolVersion string             `json:"protocolVersion"`
	Capabilities    ServerCapabilities `json:"capabilities"`
	ServerInfo      ServerInfo         `json:"serverInfo"`
}

InitializeResult represents the response to an initialize request

type LogMessage

type LogMessage struct {
	Level  string         `json:"level"`
	Logger string         `json:"logger,omitempty"`
	Data   map[string]any `json:"data,omitempty"`
}

LogMessage represents a log message notification

type LoggingCapability

type LoggingCapability struct{}

LoggingCapability describes logging capabilities

type Message

type Message struct {
	Role    string         `json:"role"` // "user" or "assistant"
	Content MessageContent `json:"content"`
	Model   string         `json:"model,omitempty"`
}

Message represents a message in a conversation

type MessageContent

type MessageContent struct {
	Type     string `json:"type"`           // "text" or "image"
	Text     string `json:"text,omitempty"` // For text content
	Data     string `json:"data,omitempty"` // Base64 encoded for image content
	MimeType string `json:"mimeType,omitempty"`
}

MessageContent represents different types of content in a message

type ModelHint

type ModelHint struct {
	Name string `json:"name"`
}

ModelHint represents a suggested model name

type ModelPreferences

type ModelPreferences struct {
	Hints                []ModelHint `json:"hints,omitempty"`
	CostPriority         float64     `json:"costPriority,omitempty"`
	SpeedPriority        float64     `json:"speedPriority,omitempty"`
	IntelligencePriority float64     `json:"intelligencePriority,omitempty"`
}

ModelPreferences represents preferences for model selection

type Notification

type Notification struct {
	JSONRPC string          `json:"jsonrpc"`
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Notification represents a JSON-RPC 2.0 notification.

type ProgressParams

type ProgressParams struct {
	ProgressToken string  `json:"progressToken"`
	Progress      float64 `json:"progress"`
	Total         float64 `json:"total,omitempty"`
}

ProgressParams represents parameters for a progress notification

type Prompt

type Prompt struct {
	Name        string           `json:"name"`
	Description string           `json:"description,omitempty"`
	Arguments   []PromptArgument `json:"arguments,omitempty"`
}

Prompt represents a prompt template

type PromptArgument

type PromptArgument struct {
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Required    bool   `json:"required"`
}

PromptArgument represents an argument for a prompt

type PromptContent

type PromptContent struct {
	Type     string           `json:"type"`           // "text", "image", or "resource"
	Text     string           `json:"text,omitempty"` // For text content
	Data     string           `json:"data,omitempty"` // Base64 encoded for image content
	MimeType string           `json:"mimeType,omitempty"`
	Resource *ResourceContent `json:"resource,omitempty"` // For resource content
}

PromptContent represents different types of content in a prompt message

type PromptMessage

type PromptMessage struct {
	Role    string        `json:"role"` // "user" or "assistant"
	Content PromptContent `json:"content"`
}

PromptMessage represents a message in a prompt

type PromptsCapability

type PromptsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

PromptsCapability describes prompt template capabilities

type Request

type Request struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"` // Can be a string or an int
	Method  string          `json:"method"`
	Params  json.RawMessage `json:"params,omitempty"`
}

Request represents a JSON-RPC 2.0 request.

type RequestMetadata

type RequestMetadata struct {
	ProgressToken string `json:"progressToken,omitempty"`
}

RequestMetadata represents common metadata that can be included in requests

type Resource

type Resource struct {
	URI         string `json:"uri"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	MimeType    string `json:"mimeType,omitempty"`
}

Resource represents a resource exposed by the server

type ResourceContent

type ResourceContent struct {
	URI      string `json:"uri"`
	MimeType string `json:"mimeType,omitempty"`
	Text     string `json:"text,omitempty"`
	Blob     string `json:"blob,omitempty"` // Base64 encoded
}

ResourceContent represents the content of a resource

type ResourceTemplate

type ResourceTemplate struct {
	URITemplate string `json:"uriTemplate"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	MimeType    string `json:"mimeType,omitempty"`
}

ResourceTemplate represents a parameterized resource template

type ResourcesCapability

type ResourcesCapability struct {
	Subscribe   bool `json:"subscribe,omitempty"`
	ListChanged bool `json:"listChanged,omitempty"`
}

ResourcesCapability describes resource capabilities

type Response

type Response struct {
	JSONRPC string          `json:"jsonrpc"`
	ID      json.RawMessage `json:"id"` // Can be a string or an int
	Result  json.RawMessage `json:"result,omitempty"`
	Error   *Error          `json:"error,omitempty"`
}

Response represents a JSON-RPC 2.0 response.

type Root

type Root struct {
	URI  string `json:"uri"` // Must be a file:// URI
	Name string `json:"name,omitempty"`
}

Root represents a filesystem root exposed by the client

type RootsCapability

type RootsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

RootsCapability describes filesystem root capabilities

type SamplingCapability

type SamplingCapability struct{}

SamplingCapability describes LLM sampling capabilities

type ServerCapabilities

type ServerCapabilities struct {
	Prompts      *PromptsCapability     `json:"prompts,omitempty"`
	Resources    *ResourcesCapability   `json:"resources,omitempty"`
	Tools        *ToolsCapability       `json:"tools,omitempty"`
	Logging      *LoggingCapability     `json:"logging,omitempty"`
	Experimental map[string]interface{} `json:"experimental,omitempty"`
}

ServerCapabilities describes the features supported by the server

type ServerInfo

type ServerInfo struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

ServerInfo contains information about the server implementation

type Tool

type Tool struct {
	Name        string          `json:"name"`
	Description string          `json:"description"`
	InputSchema json.RawMessage `json:"inputSchema"`
}

type ToolContent

type ToolContent struct {
	Type     string           `json:"type"`           // "text", "image", or "resource"
	Text     string           `json:"text,omitempty"` // For text content
	Data     string           `json:"data,omitempty"` // Base64 encoded for image content
	MimeType string           `json:"mimeType,omitempty"`
	Resource *ResourceContent `json:"resource,omitempty"` // For resource content
}

ToolContent represents different types of content in a tool result

func MustNewJSONContent

func MustNewJSONContent(data interface{}) ToolContent

MustNewJSONContent creates a new ToolContent with JSON-serialized data Panics if marshaling fails

func NewImageContent

func NewImageContent(base64Data, mimeType string) ToolContent

NewImageContent creates a new ToolContent with base64-encoded image data

func NewJSONContent

func NewJSONContent(data interface{}) (ToolContent, error)

NewJSONContent creates a new ToolContent with JSON-serialized data

func NewResourceContent

func NewResourceContent(resource *ResourceContent) ToolContent

NewResourceContent creates a new ToolContent with resource data

func NewTextContent

func NewTextContent(text string) ToolContent

NewTextContent creates a new ToolContent with text type

type ToolResult

type ToolResult struct {
	Content []ToolContent `json:"content"`
	IsError bool          `json:"isError"`
}

ToolResult represents the result of a tool invocation

func NewErrorToolResult

func NewErrorToolResult(content ...ToolContent) *ToolResult

NewErrorToolResult creates a new ToolResult marked as error with the given content

func NewToolResult

func NewToolResult(opts ...ToolResultOption) *ToolResult

NewToolResult creates a new ToolResult with the given options

type ToolResultOption

type ToolResultOption func(*ToolResult)

ToolResultOption is a function that modifies a ToolResult

func WithContent

func WithContent(content ToolContent) ToolResultOption

WithContent adds raw ToolContent to the ToolResult

func WithError

func WithError(errorMsg string) ToolResultOption

WithError marks the ToolResult as an error and optionally adds an error message

func WithImage

func WithImage(base64Data, mimeType string) ToolResultOption

WithImage adds an image content to the ToolResult

func WithJSON

func WithJSON(data interface{}) ToolResultOption

WithJSON adds JSON-serialized content to the ToolResult If marshaling fails, it adds an error message instead

func WithResource

func WithResource(resource *ResourceContent) ToolResultOption

WithResource adds a resource content to the ToolResult

func WithText

func WithText(text string) ToolResultOption

WithText adds a text content to the ToolResult

type ToolsCapability

type ToolsCapability struct {
	ListChanged bool `json:"listChanged,omitempty"`
}

ToolsCapability describes tool capabilities

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL