sdk

import "github.com/goppydae/sharur/sdk"

Package sdk provides the public Go SDK for embedding sharur agents in your own applications.

Example:

ag, err := sdk.NewAgent(sdk.Config{
    Model:    "llama3",
    Provider: "ollama",
    Tools:    sdk.DefaultTools(),
})
if err != nil {
    panic(err)
}

ag.Subscribe(func(e sdk.Event) {
    if e.Type == sdk.EventTextDelta {
        fmt.Print(e.Content)
    }
})

if err := ag.Prompt(context.Background(), "What files are in this directory?"); err != nil {
    panic(err)
}
<-ag.Idle()

Index

Constants

const (
    EventAgentStart   = agent.EventAgentStart
    EventTurnStart    = agent.EventTurnStart
    EventMessageStart = agent.EventMessageStart
    EventTextDelta    = agent.EventTextDelta
    EventToolCall     = agent.EventToolCall
    EventMessageEnd   = agent.EventMessageEnd
    EventAgentEnd     = agent.EventAgentEnd
    EventError        = agent.EventError
    EventAbort        = agent.EventAbort
)

type Agent

Agent is the stateful conversation agent.

type Agent = agent.Agent

func NewAgent

func NewAgent(cfg Config) (*Agent, error)

NewAgent creates a new agent from the given configuration.

type CompactionPrep

CompactionPrep describes the state passed to BeforeCompact.

type CompactionPrep = agent.CompactionPrep

type CompactionResult

CompactionResult can be returned by BeforeCompact to provide a custom summary.

type CompactionResult = agent.CompactionResult

type Config

Config holds the options for creating a new agent.

type Config struct {
    // Provider selects the LLM backend: "ollama" (default), "openai", or "anthropic".
    Provider string

    // Model is the model name to use (e.g. "llama3", "gpt-4o", "claude-sonnet-4-6").
    Model string

    // OllamaURL overrides the Ollama base URL (default: http://localhost:11434).
    OllamaURL string

    // OpenAIURL overrides the OpenAI-compatible base URL.
    OpenAIURL string

    // OpenAIKey is the API key for OpenAI or any compatible provider.
    OpenAIKey string

    // AnthropicKey is the Anthropic API key.
    AnthropicKey string

    // SystemPrompt sets the agent's system prompt.
    SystemPrompt string

    // ThinkingLevel controls reasoning depth.
    ThinkingLevel ThinkingLevel

    // MaxTokens caps the response length (0 = provider default).
    MaxTokens int

    // DryRun mode prevents tools from performing destructive actions.
    DryRun bool

    // Tools registers additional tools beyond the builtins.
    // Pass tools.Read{}, tools.Write{}, tools.Bash{}, etc.
    Tools []Tool

    // Extensions registers active extensions (gRPC plugins or Skills).
    Extensions []Extension
}

type Event

Event is an agent lifecycle event emitted to subscribers.

type Event = agent.Event

type EventType

EventType identifies the kind of event.

type EventType = agent.EventType

type Extension

Extension is the interface for agent extensions (gRPC plugins, skills, etc.).

type Extension = agent.Extension

type InputAction

InputAction controls how ModifyInput’s result is applied.

type InputAction = agent.InputAction

const (
    InputContinue  InputAction = agent.InputContinue
    InputTransform InputAction = agent.InputTransform
    InputHandled   InputAction = agent.InputHandled
)

type InputResult

InputResult is returned by ModifyInput.

type InputResult = agent.InputResult

type SessionEndReason

SessionEndReason identifies why a session is ending.

type SessionEndReason = agent.SessionEndReason

const (
    SessionEndReset SessionEndReason = agent.SessionEndReset
)

type SessionStartReason

SessionStartReason identifies why a session is starting.

type SessionStartReason = agent.SessionStartReason

const (
    SessionStartNew    SessionStartReason = agent.SessionStartNew
    SessionStartResume SessionStartReason = agent.SessionStartResume
)

type ThinkingLevel

ThinkingLevel controls how much reasoning budget the model gets.

type ThinkingLevel = types.ThinkingLevel

const (
    ThinkingOff    ThinkingLevel = types.ThinkingOff
    ThinkingLow    ThinkingLevel = types.ThinkingLow
    ThinkingMedium ThinkingLevel = types.ThinkingMedium
    ThinkingHigh   ThinkingLevel = types.ThinkingHigh
)

type Tool

Tool is the universal tool interface.

type Tool = tools.Tool

func DefaultTools

func DefaultTools() []Tool

DefaultTools returns the full built-in tool set.

type ToolResult

ToolResult is the output of a tool execution.

type ToolResult = tools.ToolResult

Generated by gomarkdoc