dive

package module
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2025 License: Apache-2.0 Imports: 15 Imported by: 0

README

Dive - The AI Toolkit for Go

Claude GPT-4 Groq Models Made by Stingrai Join our Discord community

Dive is an AI toolkit for Go that can be used to create specialized AI agents, automate workflows, and quickly integrate with the leading LLMs.

  • 🚀 Embed it in your Go apps
  • 🤖 Create specialized agents
  • 🪄 Define multi-step workflows
  • 🛠️ Arm agents with tools
  • ⚡ Stream responses in real-time

Dive includes both a CLI and a polished set of APIs for easy integration into existing Go applications. It comes batteries-included, but also has the modularity you need for extensive customization.

Project Status

Dive is shaping up nicely, but is still a young project.

  • Feedback is highly valued on concepts, APIs, and usability
  • Some breaking changes will happen as the API matures
  • Not yet recommended for production use

Join our Discord community to chat with the team and other users.

You can also use GitHub Discussions for questions, suggestions, or feedback.

We welcome your input! 🙌

Please leave a GitHub star if you're interested in the project!

Features

  • Agents: Chat or assign work to specialized agents with configurable reasoning
  • Supervisor Patterns: Create hierarchical agent systems with work delegation
  • Workflows: Define multi-step workflows for automation
  • Declarative Configuration: Define agents and workflows using YAML
  • Multiple LLMs: Switch between Anthropic, OpenAI, Groq, Ollama, and others
  • Extended Reasoning: Configure reasoning effort and budget for deep thinking
  • Model Context Protocol (MCP): Connect to MCP servers for external tool access
  • Advanced Model Settings: Fine-tune temperature, penalties, caching, and tool behavior
  • Tools: Give agents rich capabilities to interact with the world
  • Tool Annotations: Semantic hints about tool behavior (read-only, destructive, etc.)
  • Streaming: Stream agent and workflow events for realtime UI updates
  • CLI: Run workflows, chat with agents, and more
  • Thread Management: Persistent conversation threads with memory
  • Confirmation System: Built-in confirmation system for destructive operations
  • Scripting: Embed scripts in workflows for extensibility
  • Deep Research: Use multiple agents to perform deep research

Quick Start

Environment Setup

You will need some environment variables set to use the Dive CLI, both for the LLM provider and for any tools that you'd like your agents to use.

# LLM Provider API Keys
export ANTHROPIC_API_KEY="your-key-here"
export OPENAI_API_KEY="your-key-here"
export GROQ_API_KEY="your-key-here"

# Tool API Keys
export GOOGLE_SEARCH_API_KEY="your-key-here"
export GOOGLE_SEARCH_CX="your-key-here"
export FIRECRAWL_API_KEY="your-key-here"

Firecrawl is used to retrieve webpage content. Create an account with Firecrawl to get a free key to experiment with.

Generating a Google Custom Search key is also quite easy, assuming you have a Google Cloud account. See the Google Custom Search documentation.

Using the Library

To get started with Dive as a library, use go get:

go get github.com/diveagents/dive

Here's a quick example of creating a chat agent:

agent, err := agent.New(agent.Options{
    Name:         "Research Assistant",
    Instructions: "You are an enthusiastic and deeply curious researcher.",
    Model:        anthropic.New(),
})

// Start chatting with the agent
response, err := agent.CreateResponse(ctx, dive.WithInput("Hello there!"))
// Or stream the response
stream, err := agent.StreamResponse(ctx, dive.WithInput("Hello there!"))

Or use the Dive LLM interface directly:

model := anthropic.New()
response, err := model.Generate(
  context.Background(),
  llm.WithMessages(llm.NewUserTextMessage("Hello there!")),
  llm.WithMaxTokens(2048),
  llm.WithTemperature(0.7),
)
if err != nil {
  log.Fatal(err)
}
fmt.Println(response.Message.Text())

Using Workflows

Workflows offer a declarative approach to automating multi-step processes:

Name: Research
Description: Research a Topic

Config:
  LogLevel: debug
  DefaultProvider: anthropic
  DefaultModel: claude-sonnet-4-20250514
  ConfirmationMode: if-destructive

Agents:
  - Name: Research Assistant
    Backstory: You are an enthusiastic and deeply curious researcher.
    Tools:
      - web_search
      - fetch

Workflows:
  - Name: Research
    Inputs:
      - Name: topic
        Type: string
    Steps:
      - Name: Research the Topic
        Agent: Research Assistant
        Prompt:
          Text: "Research the following topic: ${inputs.topic}"
          Output: A three paragraph overview of the topic
          OutputFormat: markdown
        Store: overview
      - Name: Save the Research
        Action: Document.Write
        Parameters:
          Path: research/${inputs.topic}.md
          Content: ${overview}

Run a workflow using the Dive CLI:

dive run workflow.yaml --vars "topic=history of the internet"

Use the Dive CLI

For the moment, you'll need to build the CLI yourself:

git clone git@github.com:diveagents/dive.git
cd dive/cmd/dive
go install .

Available CLI commands include:

  • dive run /path/to/workflow.yaml: Run a workflow
  • dive chat --provider anthropic --model claude-sonnet-4-20250514: Chat with an agent
  • dive config check /path/to/workflow.yaml: Validate a Dive configuration

LLM Providers

Dive provides a unified interface for working with different LLM providers:

  • Anthropic (Claude Sonnet, Haiku, Opus)
  • OpenAI (GPT-4, o1, o3)
  • Groq (Llama, DeepSeek, Qwen)

Each provider implementation handles API communication, token counting, tool calling, and other details.

provider := anthropic.New(anthropic.WithModel("claude-sonnet-4-20250514"))

provider := openai.New(openai.WithModel("gpt-4o"))

provider := groq.New(groq.WithModel("deepseek-r1-distill-llama-70b"))

Model Context Protocol (MCP)

Dive supports the Model Context Protocol (MCP) for connecting to external tools and services:

response, err := anthropic.New().Generate(
    context.Background(),
    llm.WithMessages(llm.NewUserTextMessage("What are the open tickets?")),
    llm.WithMCPServers(
        llm.MCPServerConfig{
            Type:               "url",
            Name:               "linear",
            URL:                "https://mcp.linear.app/sse",
            AuthorizationToken: "your-token-here",
        },
    ),
)

MCP servers can also be configured in YAML workflows and agent definitions for declarative setup.

Verified Models

These are the models that have been verified to work in Dive:

Provider Model Tools Supported
Anthropic claude-sonnet-4-20250514 Yes
Anthropic claude-opus-4-20250514 Yes
Anthropic claude-3-7-sonnet-20250219 Yes
Anthropic claude-3-5-sonnet-20241022 Yes
Anthropic claude-3-5-haiku-20241022 Yes
Groq deepseek-r1-distill-llama-70b Yes
Groq llama-3.3-70b-versatile Yes
Groq qwen-2.5-32b Yes
OpenAI gpt-4o Yes
OpenAI gpt-4.5-preview Yes
OpenAI o1 Yes
OpenAI o1-mini No
OpenAI o3-mini Yes
Ollama llama3.2:* Yes
Ollama mistral:* No

Tool Use

Tools extend agent capabilities. Dive includes these built-in tools:

  • list_directory: List directory contents
  • read_file: Read content from files
  • write_file: Write content to files
  • text_editor: Advanced file editing with view, create, replace, and insert operations
  • web_search: Search the web using Google Custom Search or Kagi Search
  • fetch: Fetch and extract content from webpages using Firecrawl
  • command: Execute external commands
  • generate_image: Generate images using OpenAI's gpt-image-1

Tool Annotations

Dive's tool system includes rich annotations that provide hints about tool behavior:

type ToolAnnotations struct {
    Title           string      // Human-readable title
    ReadOnlyHint    bool        // Tool only reads, doesn't modify
    DestructiveHint bool        // Tool may make destructive changes
    IdempotentHint  bool        // Tool is safe to call multiple times
    OpenWorldHint   bool        // Tool accesses external resources
}

Custom Tools

Creating custom tools is straightforward using the TypedTool interface:

type SearchTool struct{}

func (t *SearchTool) Name() string { return "search" }
func (t *SearchTool) Description() string { return "Search for information" }
func (t *SearchTool) Schema() schema.Schema { /* define parameters */ }
func (t *SearchTool) Annotations() dive.ToolAnnotations { /* tool hints */ }
func (t *SearchTool) Call(ctx context.Context, input *SearchInput) (*dive.ToolResult, error) {
    // Tool implementation
}

// Use with ToolAdapter for type safety
tool := dive.ToolAdapter(searchTool)

Go interfaces are in-place to support swapping in different tool implementations while keeping the same workflows and usage. For example, Brave Search could be added as an alternative Web.Search tool backend.

Contributors

We're looking for contributors! Whether you're fixing bugs, adding features, improving documentation, or spreading the word, your help is appreciated.

Roadmap

  • ✅ Ollama support
  • ✅ MCP support
  • Docs site
  • Server mode
  • Documented approach for RAG
  • AWS Bedrock support
  • Google Cloud Vertex AI support
  • Workflow actions with Risor scripts
  • Voice interactions
  • Agent memory interface
  • Workflow persistence
  • Integrations (Slack, Google Drive, etc.)
  • Expanded CLI
  • Hugging Face support

FAQ

Is there a hosted or managed version available?

Not at this time. Dive is provided as an open-source framework that you can self-host and integrate into your own applications.

Who is Behind Dive?

Dive is developed by Stingrai.

Advanced Agent Features

Supervisor Patterns

Agents can be configured as supervisors to delegate work to other agents:

supervisor, err := agent.New(agent.Options{
    Name:         "Research Manager",
    Instructions: "You coordinate research tasks across multiple specialists.",
    IsSupervisor: true,
    Subordinates: []string{"Data Analyst", "Web Researcher"},
    Model:        anthropic.New(),
})

Supervisor agents automatically get an assign_work tool for delegating tasks.

Model Settings

Fine-tune LLM behavior with advanced model settings:

agent, err := agent.New(agent.Options{
    Name: "Assistant",
    ModelSettings: &agent.ModelSettings{
        Temperature:       ptr(0.7),
        ReasoningBudget:   ptr(50000),
        ReasoningEffort:   "high",
        MaxTokens:         4096,
        ParallelToolCalls: ptr(true),
        Caching:           ptr(true),
    },
    Model: anthropic.New(),
})

Thread Management

Agents support persistent conversation threads:

response, err := agent.CreateResponse(ctx,
    dive.WithThreadID("conversation-123"),
    dive.WithInput("Continue our discussion"),
)

Environment System

Dive uses an Environment to orchestrate agents and manage shared resources:

import "github.com/diveagents/dive/environment"

env := environment.New(environment.Options{
    Name: "Research Lab",
})

// Add multiple agents to the environment
researcher, _ := agent.New(agent.Options{
    Name:        "Researcher",
    Environment: env,
})

analyst, _ := agent.New(agent.Options{
    Name:        "Data Analyst",
    Environment: env,
})

// Agents can now reference each other and share resources

The Environment provides:

  • Agent Discovery: Agents can find and delegate to each other
  • Shared Document Repository: Common file system access
  • Thread Management: Persistent conversation storage
  • Confirmation System: Centralized user confirmation handling

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrStreamClosed = errors.New("stream is closed")
View Source
var ErrThreadNotFound = fmt.Errorf("thread not found")

Functions

func AgentNames

func AgentNames(agents []Agent) []string

func DateString

func DateString(t time.Time) string

func NewEventStream added in v0.0.4

func NewEventStream() (ResponseStream, EventPublisher)

NewEventStream returns a new event stream and a publisher for the stream.

func NewID added in v0.0.4

func NewID() string

NewID returns a new UUID

func RandomName

func RandomName() string

func ReadEventPayloads added in v0.0.4

func ReadEventPayloads[T any](ctx context.Context, stream ResponseStream) ([]T, error)

ReadEventPayloads waits for and returns all events with a payload of the specified type. It will return an error if the context is canceled or if an error event is received.

func ReadMessages added in v0.0.4

func ReadMessages(ctx context.Context, stream ResponseStream) ([]*llm.Message, error)

ReadMessages returns all messages generated in an interaction. This may include both assistant messages and tool result messages.

func TruncateText

func TruncateText(text string, maxWords int) string

Types

type Agent

type Agent interface {

	// Name of the Agent
	Name() string

	// IsSupervisor indicates whether the Agent can assign work to other Agents
	IsSupervisor() bool

	// SetEnvironment sets the runtime Environment to which this Agent belongs
	SetEnvironment(env Environment) error

	// CreateResponse creates a new Response from the Agent
	CreateResponse(ctx context.Context, opts ...Option) (*Response, error)

	// StreamResponse streams a new Response from the Agent
	StreamResponse(ctx context.Context, opts ...Option) (ResponseStream, error)
}

Agent represents an intelligent AI entity that can autonomously execute tasks, respond to chat messages, and process information. Agents can work with documents, generate responses using LLMs, and interact with users through natural language. They may have specialized capabilities depending on their implementation.

type AutoApproveConfirmer added in v0.0.4

type AutoApproveConfirmer struct{}

AutoApproveConfirmer always approves confirmation requests.

func (*AutoApproveConfirmer) Confirm added in v0.0.4

type Chunk added in v0.0.3

type Chunk struct {
	Index      int      `json:"index"`
	Content    string   `json:"content"`
	Heading    string   `json:"heading,omitempty"`
	DocumentID string   `json:"document_id,omitempty"`
	Document   Document `json:"-"`
}

Chunk of a document. I'm not yet sure if this should have a pointer to a Document or if it should be referenced by name/id/path. :thinking:

type ConfirmationMode added in v0.0.4

type ConfirmationMode string
const (
	// ConfirmAlways requires confirmation for all operations
	ConfirmAlways ConfirmationMode = "always"

	// ConfirmIfNotReadOnly requires confirmation only for operations that are not read-only
	ConfirmIfNotReadOnly ConfirmationMode = "if-not-read-only"

	// ConfirmIfDestructive requires confirmation only for operations that may be destructive
	ConfirmIfDestructive ConfirmationMode = "if-destructive"

	// ConfirmNever requires no confirmation
	ConfirmNever ConfirmationMode = "never"
)

Confirmation modes

func (ConfirmationMode) IsValid added in v0.0.4

func (c ConfirmationMode) IsValid() bool

func (ConfirmationMode) String added in v0.0.4

func (c ConfirmationMode) String() string

type ConfirmationRequest added in v0.0.4

type ConfirmationRequest struct {
	Prompt  string      // Main prompt or question
	Details string      // Additional details or context (optional)
	Data    interface{} // Arbitrary data to display to the user (optional)
	Tool    Tool        // Tool that is requesting confirmation (optional)
}

ConfirmationRequest represents a request for user confirmation, with optional details and data.

type Confirmer added in v0.0.4

type Confirmer interface {
	// Confirm presents a request to the user and returns true if the user
	// confirms, false otherwise.
	Confirm(ctx context.Context, req ConfirmationRequest) (bool, error)
}

Confirmer abstracts user confirmation prompts.

func NewConfirmer added in v0.0.4

func NewConfirmer(mode string) (Confirmer, error)

NewConfirmer returns a Confirmer implementation based on the mode string. Supported modes: "auto", "deny"

type DenyAllConfirmer added in v0.0.4

type DenyAllConfirmer struct{}

DenyAllConfirmer always denies confirmation requests.

func (*DenyAllConfirmer) Confirm added in v0.0.4

type Document added in v0.0.3

type Document interface {
	ID() string
	Name() string
	Description() string
	Path() string
	Version() int
	Content() string
	ContentType() string
	Chunks() []*Chunk
	SetContent(content string) error
}

Document containing content that can be read or written to by an agent

type DocumentMetadata added in v0.0.3

type DocumentMetadata struct {
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Path        string `json:"path,omitempty"`
	Version     int    `json:"version,omitempty"`
	ContentType string `json:"content_type,omitempty"`
}

DocumentMetadata contains an overview of a document

type DocumentRef added in v0.0.3

type DocumentRef struct {
	Name string   `json:"name,omitempty"`
	Tags []string `json:"tags,omitempty"`
	Glob string   `json:"glob,omitempty"`
}

DocumentRef is used to point to one or more matching documents

type DocumentRepository added in v0.0.3

type DocumentRepository interface {

	// GetDocument returns a document by name
	GetDocument(ctx context.Context, name string) (Document, error)

	// ListDocuments lists documents
	ListDocuments(ctx context.Context, input *ListDocumentInput) (*ListDocumentOutput, error)

	// PutDocument puts a document
	PutDocument(ctx context.Context, doc Document) error

	// DeleteDocument deletes a document
	DeleteDocument(ctx context.Context, doc Document) error

	// Exists checks if a document exists by name
	Exists(ctx context.Context, name string) (bool, error)

	// RegisterDocument assigns a name to a document path
	RegisterDocument(ctx context.Context, name, path string) error
}

DocumentRepository provides read/write access to a set of documents. This could be backed by a local file system, a remote API, or a database.

type Environment

type Environment interface {

	// Name of the Environment
	Name() string

	// Agents returns the list of all Agents belonging to this Environment
	Agents() []Agent

	// AddAgent adds an Agent to this Environment
	AddAgent(agent Agent) error

	// GetAgent returns the Agent with the given name, if found
	GetAgent(name string) (Agent, error)

	// DocumentRepository returns the DocumentRepository for this Environment
	DocumentRepository() DocumentRepository

	// ThreadRepository returns the ThreadRepository for this Environment
	ThreadRepository() ThreadRepository

	// Confirmer returns the Confirmer for this Environment
	Confirmer() Confirmer
}

Environment is a container for running Agents and Workflows. Interactivity between Agents is generally scoped to a single Environment.

type EventCallback added in v0.0.4

type EventCallback func(ctx context.Context, event *ResponseEvent) error

EventCallback is a function that processes streaming events during response generation.

type EventPublisher added in v0.0.4

type EventPublisher interface {
	// Send sends an event to the stream
	Send(ctx context.Context, event *ResponseEvent) error

	// Close closes the publisher and the referenced stream. This signals to the
	// consumer that no more events will be sent.
	Close()
}

EventPublisher is an interface used to send events to an EventStream. These functions are safe to call concurrently.

type EventType added in v0.0.4

type EventType string

EventType is the type of event emitted by an Agent or Workflow.

const (
	EventTypeResponseCreated    EventType = "response.created"
	EventTypeResponseInProgress EventType = "response.in_progress"
	EventTypeResponseCompleted  EventType = "response.completed"
	EventTypeResponseFailed     EventType = "response.failed"
	EventTypeResponseToolCall   EventType = "response.tool_call"
	EventTypeResponseToolResult EventType = "response.tool_result"
	EventTypeResponseToolError  EventType = "response.tool_error"
	EventTypeLLMEvent           EventType = "llm.event"
	EventTypeError              EventType = "error"
)

func (EventType) String added in v0.0.4

func (t EventType) String() string

type ListDocumentInput added in v0.0.3

type ListDocumentInput struct {
	PathPrefix string
	Recursive  bool
}

ListDocumentInput specifies search criteria for documents in a document store

type ListDocumentOutput added in v0.0.3

type ListDocumentOutput struct {
	Items []Document
}

ListDocumentOutput is the output for listing documents

type Option added in v0.0.4

type Option func(*Options)

Option is a type signature for defining new LLM generation options.

func WithEventCallback added in v0.0.4

func WithEventCallback(callback EventCallback) Option

WithEventCallback specifies a callback function that will be invoked for each event generated during response creation.

func WithInput added in v0.0.4

func WithInput(input string) Option

WithInput specifies a simple text input string to be used in the generation. This is a convenience wrapper that creates a single user message.

func WithMessage added in v0.0.4

func WithMessage(message *llm.Message) Option

WithMessage specifies a single message to be used in the generation.

func WithMessages added in v0.0.4

func WithMessages(messages ...*llm.Message) Option

WithMessages specifies the messages to be used in the generation.

func WithThreadID

func WithThreadID(threadID string) Option

WithThreadID associates the given conversation thread ID with a generation. This appends the new messages to any previous messages belonging to this thread.

func WithUserID

func WithUserID(userID string) Option

WithUserID associates the given user ID with a generation, indicating what person is the speaker in the conversation.

type Options added in v0.0.4

type Options struct {
	ThreadID      string
	UserID        string
	Messages      []*llm.Message
	EventCallback EventCallback
}

Options contains configuration for LLM generations.

func (*Options) Apply added in v0.0.4

func (o *Options) Apply(opts []Option)

Apply invokes any supplied options. Used internally in Dive.

type OutputFormat

type OutputFormat string

OutputFormat defines the desired output format for a Task

const (
	OutputFormatText     OutputFormat = "text"
	OutputFormatMarkdown OutputFormat = "markdown"
	OutputFormatJSON     OutputFormat = "json"
)

type Property added in v0.0.4

type Property = schema.Property

Type aliases for easy access to LLM types

type Response added in v0.0.4

type Response struct {
	// ID is a unique identifier for this response
	ID string `json:"id,omitempty"`

	// Model represents the model that generated the response
	Model string `json:"model,omitempty"`

	// Items contains the individual response items including
	// messages, tool calls, and tool results.
	Items []*ResponseItem `json:"items,omitempty"`

	// Usage contains token usage information
	Usage *llm.Usage `json:"usage,omitempty"`

	// CreatedAt is the timestamp when this response was created
	CreatedAt time.Time `json:"created_at,omitempty"`

	// FinishedAt is the timestamp when this response was completed
	FinishedAt *time.Time `json:"finished_at,omitempty"`
}

Response represents the output from an Agent's response generation.

func (*Response) OutputText added in v0.0.4

func (r *Response) OutputText() string

OutputText returns the text content from the last message in the response. If there are no messages or no text content, returns an empty string.

func (*Response) ToolCallResults added in v0.0.4

func (r *Response) ToolCallResults() []*ToolCallResult

ToolCallResults returns all tool call results from the response.

type ResponseEvent added in v0.0.4

type ResponseEvent struct {
	// Type of the event
	Type EventType `json:"type"`

	// Error is set if this Event corresponds to an error
	Error error `json:"error,omitempty"`

	// Item contains the item for item events
	Item *ResponseItem `json:"item,omitempty"`

	// Response contains the complete response for response completed events
	Response *Response `json:"response,omitempty"`
}

ResponseEvent carries information about an event that occurred during a Dive LLM interaction.

type ResponseItem added in v0.0.4

type ResponseItem struct {
	// Type of the response item
	Type ResponseItemType `json:"type,omitempty"`

	// Event is set if the response item is an event
	Event *llm.Event `json:"event,omitempty"`

	// Message is set if the response item is a message
	Message *llm.Message `json:"message,omitempty"`

	// ToolCall is set if the response item is a tool call
	ToolCall *llm.ToolUseContent `json:"tool_call,omitempty"`

	// ToolCallResult is set if the response item is a tool call result
	ToolCallResult *ToolCallResult `json:"tool_call_result,omitempty"`

	// Usage contains token usage information, if applicable
	Usage *llm.Usage `json:"usage,omitempty"`
}

ResponseItem contains either a message, tool call, or tool result. Multiple items may be generated in response to a single prompt.

type ResponseItemType added in v0.0.4

type ResponseItemType string
const (
	ResponseItemTypeMessage        ResponseItemType = "message"
	ResponseItemTypeToolCall       ResponseItemType = "tool_call"
	ResponseItemTypeToolCallResult ResponseItemType = "tool_call_result"
)

type ResponseStream added in v0.0.4

type ResponseStream interface {
	// Next advances the stream to the next item
	Next(ctx context.Context) bool

	// Event returns the current event in the stream
	Event() *ResponseEvent

	// Err returns any error encountered while streaming
	Err() error

	// Close releases any resources associated with the stream
	Close() error
}

ResponseStream is a generic interface for streaming responses

type Schema added in v0.0.4

type Schema = schema.Schema

Type aliases for easy access to LLM types

type StepResult added in v0.0.4

type StepResult struct {
	// Content contains the raw output
	Content string

	// Format specifies how to interpret the content
	Format OutputFormat

	// Object holds parsed JSON output if applicable
	Object interface{}

	// Usage tracks LLM token usage
	Usage llm.Usage
}

StepResult holds the output of a completed task.

type StructuredResponse added in v0.0.4

type StructuredResponse struct {
	// contains filtered or unexported fields
}

StructuredResponse is an interpreted response from an Agent which may include status, thinking, and content.

func ParseStructuredResponse added in v0.0.4

func ParseStructuredResponse(text string) StructuredResponse

func (*StructuredResponse) Content added in v0.0.4

func (s *StructuredResponse) Content() string

func (*StructuredResponse) RawText added in v0.0.4

func (s *StructuredResponse) RawText() string

func (*StructuredResponse) Status added in v0.0.4

func (s *StructuredResponse) Status() TaskStatus

func (*StructuredResponse) StatusDescription added in v0.0.4

func (s *StructuredResponse) StatusDescription() string

func (*StructuredResponse) Thinking added in v0.0.4

func (s *StructuredResponse) Thinking() string

type Task

type Task struct {
	// contains filtered or unexported fields
}

func NewTask added in v0.0.4

func NewTask(opts TaskOptions) *Task

func (*Task) Name

func (t *Task) Name() string

func (*Task) Prompt

func (t *Task) Prompt() string

func (*Task) Timeout

func (t *Task) Timeout() time.Duration

type TaskOptions added in v0.0.4

type TaskOptions struct {
	Name    string
	Timeout time.Duration
	Prompt  string
}

type TaskStatus

type TaskStatus string

TaskStatus is used to convey the status of a Task that an Agent is working on

const (
	TaskStatusQueued    TaskStatus = "queued"
	TaskStatusActive    TaskStatus = "active"
	TaskStatusPaused    TaskStatus = "paused"
	TaskStatusCompleted TaskStatus = "completed"
	TaskStatusBlocked   TaskStatus = "blocked"
	TaskStatusError     TaskStatus = "error"
	TaskStatusUnknown   TaskStatus = ""
)

type TerminalConfirmer added in v0.0.4

type TerminalConfirmer struct {
	// contains filtered or unexported fields
}

func NewTerminalConfirmer added in v0.0.4

func NewTerminalConfirmer(opts TerminalConfirmerOptions) *TerminalConfirmer

func (*TerminalConfirmer) Confirm added in v0.0.4

func (*TerminalConfirmer) ShouldConfirm added in v0.0.4

func (c *TerminalConfirmer) ShouldConfirm(req ConfirmationRequest) bool

ShouldConfirm determines if confirmation is needed based on the confirmer's mode and the request

type TerminalConfirmerOptions added in v0.0.4

type TerminalConfirmerOptions struct {
	Mode ConfirmationMode
}

type TextDocument added in v0.0.3

type TextDocument struct {
	// contains filtered or unexported fields
}

TextDocument implements the Document interface

func NewTextDocument added in v0.0.3

func NewTextDocument(opts TextDocumentOptions) *TextDocument

NewTextDocument returns a new TextDocument with the given options and content

func (*TextDocument) Chunks added in v0.0.3

func (d *TextDocument) Chunks() []*Chunk

func (*TextDocument) Content added in v0.0.3

func (d *TextDocument) Content() string

func (*TextDocument) ContentType added in v0.0.3

func (d *TextDocument) ContentType() string

func (*TextDocument) Description added in v0.0.3

func (d *TextDocument) Description() string

func (*TextDocument) ID added in v0.0.3

func (d *TextDocument) ID() string

func (*TextDocument) IncrementVersion added in v0.0.3

func (d *TextDocument) IncrementVersion()

func (*TextDocument) Name added in v0.0.3

func (d *TextDocument) Name() string

func (*TextDocument) Path added in v0.0.3

func (d *TextDocument) Path() string

func (*TextDocument) SetContent added in v0.0.3

func (d *TextDocument) SetContent(content string) error

func (*TextDocument) SetName added in v0.0.3

func (d *TextDocument) SetName(name string)

func (*TextDocument) SetPath added in v0.0.3

func (d *TextDocument) SetPath(path string)

func (*TextDocument) Version added in v0.0.3

func (d *TextDocument) Version() int

type TextDocumentOptions added in v0.0.3

type TextDocumentOptions struct {
	ID          string `json:"id,omitempty"`
	Name        string `json:"name,omitempty"`
	Description string `json:"description,omitempty"`
	Path        string `json:"path,omitempty"`
	Version     int    `json:"version,omitempty"`
	Content     string `json:"content,omitempty"`
	ContentType string `json:"content_type,omitempty"`
}

TextDocumentOptions are used to initialize a TextDocument

type Thread added in v0.0.3

type Thread struct {
	ID        string         `json:"id"`
	UserID    string         `json:"user_id"`
	CreatedAt time.Time      `json:"created_at"`
	UpdatedAt time.Time      `json:"updated_at"`
	Messages  []*llm.Message `json:"messages"`
}

Thread represents a conversation thread

type ThreadRepository added in v0.0.3

type ThreadRepository interface {

	// PutThread creates or updates a thread
	PutThread(ctx context.Context, thread *Thread) error

	// GetThread retrieves a thread by ID
	GetThread(ctx context.Context, id string) (*Thread, error)

	// DeleteThread deletes a thread by ID
	DeleteThread(ctx context.Context, id string) error
}

ThreadRepository is an interface for storing and retrieving conversation threads

type Tool added in v0.0.4

type Tool interface {
	// Name of the tool.
	Name() string

	// Description of the tool.
	Description() string

	// Schema describes the parameters used to call the tool.
	Schema() *schema.Schema

	// Annotations returns optional properties that describe tool behavior.
	Annotations() *ToolAnnotations

	// Call is the function that is called to use the tool.
	Call(ctx context.Context, input any) (*ToolResult, error)
}

Tool is an interface for a tool that can be called by an LLM.

type ToolAnnotations added in v0.0.4

type ToolAnnotations struct {
	Title           string         `json:"title,omitempty"`
	ReadOnlyHint    bool           `json:"readOnlyHint,omitempty"`
	DestructiveHint bool           `json:"destructiveHint,omitempty"`
	IdempotentHint  bool           `json:"idempotentHint,omitempty"`
	OpenWorldHint   bool           `json:"openWorldHint,omitempty"`
	Extra           map[string]any `json:"extra,omitempty"`
}

func (*ToolAnnotations) MarshalJSON added in v0.0.4

func (a *ToolAnnotations) MarshalJSON() ([]byte, error)

func (*ToolAnnotations) UnmarshalJSON added in v0.0.4

func (a *ToolAnnotations) UnmarshalJSON(data []byte) error

type ToolCallResult added in v0.0.4

type ToolCallResult struct {
	ID     string
	Name   string
	Input  any
	Result *ToolResult
	Error  error
}

ToolCallResult is a tool call that has been made. This is used to understand what calls have happened during an LLM interaction.

type ToolResult added in v0.0.4

type ToolResult struct {
	Content []*ToolResultContent `json:"content"`
	IsError bool                 `json:"isError,omitempty"`
}

ToolResult is the output from a tool call.

func NewToolResult added in v0.0.4

func NewToolResult(content ...*ToolResultContent) *ToolResult

NewToolResult creates a new ToolResult with the given content.

func NewToolResultError added in v0.0.4

func NewToolResultError(text string) *ToolResult

NewToolResultError creates a new ToolResult containing an error message.

func NewToolResultText added in v0.0.4

func NewToolResultText(text string) *ToolResult

NewToolResultText creates a new ToolResult with the given text content.

type ToolResultContent added in v0.0.4

type ToolResultContent struct {
	Type        ToolResultContentType `json:"type"`
	Text        string                `json:"text,omitempty"`
	Data        string                `json:"data,omitempty"`
	MimeType    string                `json:"mimeType,omitempty"`
	Annotations map[string]any        `json:"annotations,omitempty"`
}

type ToolResultContentType added in v0.0.4

type ToolResultContentType string
const (
	ToolResultContentTypeText  ToolResultContentType = "text"
	ToolResultContentTypeImage ToolResultContentType = "image"
	ToolResultContentTypeAudio ToolResultContentType = "audio"
)

func (ToolResultContentType) String added in v0.0.4

func (t ToolResultContentType) String() string

type TypedTool added in v0.0.4

type TypedTool[T any] interface {
	// Name of the tool.
	Name() string

	// Description of the tool.
	Description() string

	// Schema describes the parameters used to call the tool.
	Schema() *schema.Schema

	// Annotations returns optional properties that describe tool behavior.
	Annotations() *ToolAnnotations

	// Call is the function that is called to use the tool.
	Call(ctx context.Context, input T) (*ToolResult, error)
}

TypedTool is a tool that can be called with a specific type of input.

type TypedToolAdapter added in v0.0.4

type TypedToolAdapter[T any] struct {
	// contains filtered or unexported fields
}

TypedToolAdapter is an adapter that allows a TypedTool to be used as a regular Tool. Specifically the Call method accepts `input any` and then internally unmarshals the input to the correct type and passes it to the TypedTool.

func ToolAdapter added in v0.0.4

func ToolAdapter[T any](tool TypedTool[T]) *TypedToolAdapter[T]

ToolAdapter creates a new TypedToolAdapter for the given tool.

func (*TypedToolAdapter[T]) Annotations added in v0.0.4

func (t *TypedToolAdapter[T]) Annotations() *ToolAnnotations

func (*TypedToolAdapter[T]) Call added in v0.0.4

func (t *TypedToolAdapter[T]) Call(ctx context.Context, input any) (*ToolResult, error)

func (*TypedToolAdapter[T]) Description added in v0.0.4

func (t *TypedToolAdapter[T]) Description() string

func (*TypedToolAdapter[T]) Name added in v0.0.4

func (t *TypedToolAdapter[T]) Name() string

func (*TypedToolAdapter[T]) Schema added in v0.0.4

func (t *TypedToolAdapter[T]) Schema() *schema.Schema

func (*TypedToolAdapter[T]) ToolConfiguration added in v0.0.5

func (t *TypedToolAdapter[T]) ToolConfiguration(providerName string) map[string]any

func (*TypedToolAdapter[T]) Unwrap added in v0.0.4

func (t *TypedToolAdapter[T]) Unwrap() TypedTool[T]

Unwrap returns the underlying TypedTool.

Jump to

Keyboard shortcuts

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