Documentation
¶
Index ¶
- Variables
- func SteeringSignal(ctx context.Context) <-chan struct{}
- type Checkpoint
- type CompactResponse
- type CompactionErrorPolicy
- type Compactor
- type ContentPart
- type ContentPartKind
- type Engine
- func (e *Engine) Checkpoint() (Checkpoint, error)
- func (e *Engine) ClearGoal()
- func (e *Engine) ClearSteering() [][]ContentPart
- func (e *Engine) Compact(ctx context.Context, sink EventSink) error
- func (e *Engine) CompleteGoal() error
- func (e *Engine) Goal() (GoalState, bool)
- func (e *Engine) Reset() error
- func (e *Engine) RestoreCheckpoint(checkpoint Checkpoint) error
- func (e *Engine) Run(ctx context.Context, userText string, sink EventSink) (RunResult, error)
- func (e *Engine) RunContent(ctx context.Context, content []ContentPart, sink EventSink) (RunResult, error)
- func (e *Engine) SetFastMode(enabled bool)
- func (e *Engine) SetGoal(objective string) error
- func (e *Engine) SetSessionID(sessionID string)
- func (e *Engine) SetThinkingLevel(level ThinkingLevel) error
- func (e *Engine) Steer(content []ContentPart) bool
- type Event
- type EventKind
- type EventSink
- type GenerationRetryPolicy
- type GoalState
- type Image
- type InboxBatch
- type InboxSource
- type Input
- type InputKind
- type JSONSchema
- type Options
- type Provider
- type Request
- type Response
- type RunResult
- type Settings
- type StreamObserver
- type TextSink
- type ThinkingLevel
- type ThinkingLevelMap
- type ToolCall
- type ToolCallSink
- type ToolCallSnapshot
- type ToolDefinition
- type ToolDiffLine
- type ToolDiffLineKind
- type ToolPresentation
- type ToolPresenter
- type ToolResult
- type ToolUpdateSink
- type Toolbox
- type Usage
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrNoGoal = errors.New("agent: no goal is set") ErrGoalAlreadyComplete = errors.New("agent: goal is already complete") )
Functions ¶
func SteeringSignal ¶
Types ¶
type Checkpoint ¶
type Checkpoint struct {
// contains filtered or unexported fields
}
func (Checkpoint) Initialized ¶
func (checkpoint Checkpoint) Initialized() bool
func (Checkpoint) MarshalJSON ¶
func (checkpoint Checkpoint) MarshalJSON() ([]byte, error)
func (*Checkpoint) UnmarshalJSON ¶
func (checkpoint *Checkpoint) UnmarshalJSON(encoded []byte) error
type CompactResponse ¶
type CompactionErrorPolicy ¶
CompactionErrorPolicy decides whether a failed generation should be retried after compacting its request.
type ContentPart ¶
type ContentPart struct {
Kind ContentPartKind `json:"kind"`
Text string `json:"text,omitempty"`
Image *Image `json:"image,omitempty"`
}
type ContentPartKind ¶
type ContentPartKind string
const ( ContentPartText ContentPartKind = "text" ContentPartImage ContentPartKind = "image" )
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
func (*Engine) Checkpoint ¶
func (e *Engine) Checkpoint() (Checkpoint, error)
func (*Engine) ClearSteering ¶
func (e *Engine) ClearSteering() [][]ContentPart
func (*Engine) CompleteGoal ¶
func (*Engine) RestoreCheckpoint ¶
func (e *Engine) RestoreCheckpoint(checkpoint Checkpoint) error
func (*Engine) RunContent ¶
func (*Engine) SetFastMode ¶
func (*Engine) SetSessionID ¶
func (*Engine) SetThinkingLevel ¶
func (e *Engine) SetThinkingLevel(level ThinkingLevel) error
func (*Engine) Steer ¶
func (e *Engine) Steer(content []ContentPart) bool
type Event ¶
type Event struct {
Kind EventKind
Text string
Content []ContentPart
Call ToolCall
Presentation ToolPresentation
Result ToolResult
Usage Usage
Attempt int
Checkpoint *Checkpoint
}
type EventKind ¶
type EventKind string
const ( EventAssistantText EventKind = "assistant_text" EventAssistantReasoning EventKind = "assistant_reasoning" EventCompactionStart EventKind = "compaction_start" EventCompactionEnd EventKind = "compaction_end" EventContextUsage EventKind = "context_usage" EventGenerationRetry EventKind = "generation_retry" EventCheckpoint EventKind = "checkpoint" EventSteering EventKind = "steering" EventGoalContinuation EventKind = "goal_continuation" EventToolStart EventKind = "tool_start" EventToolUpdate EventKind = "tool_update" EventToolExecute EventKind = "tool_execute" EventToolEnd EventKind = "tool_end" )
type GenerationRetryPolicy ¶
type GenerationRetryPolicy interface {
RetryGeneration(err error, failedAttempts int) (time.Duration, bool)
}
GenerationRetryPolicy decides whether a failed generation attempt should be retried. failedAttempts includes the attempt that returned err.
type InboxBatch ¶
type InboxSource ¶
type InboxSource interface {
SnapshotInbox() InboxBatch
AcknowledgeInbox(InboxBatch) error
InboxEmpty() bool
}
type Input ¶
type Input struct {
Kind InputKind `json:"kind"`
Text string `json:"text"`
Content []ContentPart `json:"content,omitempty"`
CallID string `json:"call_id"`
Tool string `json:"tool"`
IsError bool `json:"is_error"`
}
func NewInboxInput ¶
func NewTextInput ¶
func NewToolResultInput ¶
func NewToolResultInput(result ToolResult) Input
func NewUserInput ¶
func NewUserInput(parts ...ContentPart) Input
type JSONSchema ¶
type JSONSchema struct {
Type any `json:"type,omitempty"`
Description string `json:"description,omitempty"`
Properties map[string]JSONSchema `json:"properties,omitempty"`
Required []string `json:"required,omitempty"`
AdditionalProperties *bool `json:"additionalProperties,omitempty"`
Items *JSONSchema `json:"items,omitempty"`
AnyOf []JSONSchema `json:"anyOf,omitempty"`
}
func (JSONSchema) MarshalJSON ¶
func (schema JSONSchema) MarshalJSON() ([]byte, error)
type Request ¶
type Request struct {
SessionID string
Model string
ThinkingLevel ThinkingLevel
FastMode bool
Instructions string
Inputs []Input
Tools []ToolDefinition
State []byte
}
type Settings ¶
type Settings struct {
// contains filtered or unexported fields
}
func NewSettings ¶
func NewSettings(thinkingLevel ThinkingLevel, fastMode bool) *Settings
func (*Settings) SetFastMode ¶
func (*Settings) SetThinkingLevel ¶
func (settings *Settings) SetThinkingLevel(level ThinkingLevel) error
func (*Settings) Snapshot ¶
func (settings *Settings) Snapshot() (ThinkingLevel, bool)
type StreamObserver ¶
type StreamObserver struct {
Text TextSink
Reasoning TextSink
ToolCall ToolCallSink
}
StreamObserver callbacks may be called concurrently while Generate is running. Returning an error stops delivery and terminates generation.
type ThinkingLevel ¶
type ThinkingLevel string
const ( ThinkingOff ThinkingLevel = "off" ThinkingMinimal ThinkingLevel = "minimal" ThinkingLow ThinkingLevel = "low" ThinkingMedium ThinkingLevel = "medium" ThinkingHigh ThinkingLevel = "high" ThinkingXHigh ThinkingLevel = "xhigh" ThinkingMax ThinkingLevel = "max" DefaultThinkingLevel = ThinkingMedium )
func ClampThinkingLevel ¶
func ClampThinkingLevel(level ThinkingLevel, supported []ThinkingLevel) ThinkingLevel
func ParseThinkingLevel ¶
func ParseThinkingLevel(value string) (ThinkingLevel, error)
func ThinkingLevels ¶
func ThinkingLevels() []ThinkingLevel
func (ThinkingLevel) Valid ¶
func (level ThinkingLevel) Valid() bool
type ThinkingLevelMap ¶
type ThinkingLevelMap map[ThinkingLevel]string
func (ThinkingLevelMap) Clamp ¶
func (levels ThinkingLevelMap) Clamp(level ThinkingLevel) ThinkingLevel
func (ThinkingLevelMap) SupportedLevels ¶
func (levels ThinkingLevelMap) SupportedLevels() []ThinkingLevel
type ToolCallSink ¶
type ToolCallSink func(ToolCallSnapshot) error
type ToolCallSnapshot ¶
type ToolDefinition ¶
type ToolDefinition struct {
Name string
Description string
Parameters JSONSchema
}
type ToolDiffLine ¶
type ToolDiffLine struct {
Kind ToolDiffLineKind `json:"kind"`
OldLine int `json:"old_line"`
NewLine int `json:"new_line"`
Text string `json:"text"`
}
type ToolDiffLineKind ¶
type ToolDiffLineKind uint8
const ( ToolDiffLineContext ToolDiffLineKind = 0 ToolDiffLineAdded ToolDiffLineKind = 1 ToolDiffLineRemoved ToolDiffLineKind = 2 ToolDiffLineOmitted ToolDiffLineKind = 3 )
Values are persisted in terminal checkpoints and must remain stable.
type ToolPresentation ¶
type ToolPresentation struct {
Title string `json:"title"`
Arguments string `json:"arguments"`
Lines []string `json:"lines"`
LinesTruncated bool `json:"lines_truncated"`
Diff []ToolDiffLine `json:"diff"`
Markdown bool `json:"markdown"`
Outcome string `json:"outcome"`
TailLines int `json:"tail_lines"`
Elapsed time.Duration `json:"elapsed"`
Timeout time.Duration `json:"timeout"`
}
func (ToolPresentation) Clone ¶
func (presentation ToolPresentation) Clone() ToolPresentation
func (ToolPresentation) Equal ¶
func (presentation ToolPresentation) Equal(other ToolPresentation) bool
type ToolPresenter ¶
type ToolPresenter interface {
Presentation(ToolCallSnapshot) ToolPresentation
}
type ToolUpdateSink ¶
type ToolUpdateSink interface {
Update(ToolPresentation) error
// SetFinal replaces the presentation attached to the tool-end event and ignores later updates.
SetFinal(ToolPresentation)
}
ToolUpdateSink may be called concurrently before Execute returns.
type Toolbox ¶
type Toolbox interface {
Definitions() []ToolDefinition
// Execute may be called concurrently for calls from the same provider response.
Execute(ctx context.Context, call ToolCall, updates ToolUpdateSink) (ToolResult, error)
}
Click to show internal directories.
Click to hide internal directories.