---
title: "sdk"
---

<!-- Code generated by gomarkdoc. DO NOT EDIT -->

# sdk

```go
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](<#constants>)
- [type Agent](<#Agent>)
  - [func NewAgent\(cfg Config\) \(\*Agent, error\)](<#NewAgent>)
- [type CompactionPrep](<#CompactionPrep>)
- [type CompactionResult](<#CompactionResult>)
- [type Config](<#Config>)
- [type Event](<#Event>)
- [type EventType](<#EventType>)
- [type Extension](<#Extension>)
- [type InputAction](<#InputAction>)
- [type InputResult](<#InputResult>)
- [type SessionEndReason](<#SessionEndReason>)
- [type SessionStartReason](<#SessionStartReason>)
- [type ThinkingLevel](<#ThinkingLevel>)
- [type Tool](<#Tool>)
  - [func DefaultTools\(\) \[\]Tool](<#DefaultTools>)
- [type ToolResult](<#ToolResult>)


## Constants

<a name="EventAgentStart"></a>

```go
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
)
```

<a name="Agent"></a>
## type Agent

Agent is the stateful conversation agent.

```go
type Agent = agent.Agent
```

<a name="NewAgent"></a>
### func NewAgent

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

NewAgent creates a new agent from the given configuration.

<a name="CompactionPrep"></a>
## type CompactionPrep

CompactionPrep describes the state passed to BeforeCompact.

```go
type CompactionPrep = agent.CompactionPrep
```

<a name="CompactionResult"></a>
## type CompactionResult

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

```go
type CompactionResult = agent.CompactionResult
```

<a name="Config"></a>
## type Config

Config holds the options for creating a new agent.

```go
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
}
```

<a name="Event"></a>
## type Event

Event is an agent lifecycle event emitted to subscribers.

```go
type Event = agent.Event
```

<a name="EventType"></a>
## type EventType

EventType identifies the kind of event.

```go
type EventType = agent.EventType
```

<a name="Extension"></a>
## type Extension

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

```go
type Extension = agent.Extension
```

<a name="InputAction"></a>
## type InputAction

InputAction controls how ModifyInput's result is applied.

```go
type InputAction = agent.InputAction
```

<a name="InputContinue"></a>

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

<a name="InputResult"></a>
## type InputResult

InputResult is returned by ModifyInput.

```go
type InputResult = agent.InputResult
```

<a name="SessionEndReason"></a>
## type SessionEndReason

SessionEndReason identifies why a session is ending.

```go
type SessionEndReason = agent.SessionEndReason
```

<a name="SessionEndReset"></a>

```go
const (
    SessionEndReset SessionEndReason = agent.SessionEndReset
)
```

<a name="SessionStartReason"></a>
## type SessionStartReason

SessionStartReason identifies why a session is starting.

```go
type SessionStartReason = agent.SessionStartReason
```

<a name="SessionStartNew"></a>

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

<a name="ThinkingLevel"></a>
## type ThinkingLevel

ThinkingLevel controls how much reasoning budget the model gets.

```go
type ThinkingLevel = types.ThinkingLevel
```

<a name="ThinkingOff"></a>

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

<a name="Tool"></a>
## type Tool

Tool is the universal tool interface.

```go
type Tool = tools.Tool
```

<a name="DefaultTools"></a>
### func DefaultTools

```go
func DefaultTools() []Tool
```

DefaultTools returns the full built\-in tool set.

<a name="ToolResult"></a>
## type ToolResult

ToolResult is the output of a tool execution.

```go
type ToolResult = tools.ToolResult
```

Generated by [gomarkdoc](<https://github.com/princjef/gomarkdoc>)
