Documentation
¶
Index ¶
- Constants
- Variables
- type AgentConfig
- type AskQuestionEntry
- type AskQuestionInteractionSpec
- type AskQuestionOption
- type Audio
- type BaseAgentConfig
- type BaseMcpServerConfig
- type BaseMedia
- type BuiltinSlashCommandName
- type BuiltinTools
- type CapabilitiesConfig
- type ChatResponse
- func (r *ChatResponse) Cancel(ctx context.Context) error
- func (r *ChatResponse) Chunks() <-chan StreamChunk
- func (r *ChatResponse) StructuredOutput() (any, error)
- func (r *ChatResponse) Text() (string, error)
- func (r *ChatResponse) Thoughts() <-chan string
- func (r *ChatResponse) ToolCalls() <-chan ToolCall
- func (r *ChatResponse) UsageMetadata() *UsageMetadata
- type Connection
- type ConnectionStrategy
- type Content
- type ContentPrimitive
- type Conversation
- type ConversationFactory
- type CustomSystemInstructions
- type Document
- type FileChange
- type FileChangeKind
- type GeminiConfig
- type GenerationConfig
- type HookResult
- type HookRunner
- type Image
- type McpServerConfig
- type McpStdioServer
- type McpStreamableHttpServer
- type Media
- type ModelConfig
- type ModelEntry
- type QuestionHookResult
- type QuestionResponse
- type SlashCommand
- type Step
- type StepSource
- type StepStatus
- type StepTarget
- type StepType
- type StreamChunk
- type StringContent
- type SystemInstructionSection
- type SystemInstructions
- type TemplatedSystemInstructions
- type Text
- type ThinkingLevel
- type Thought
- type ToolCall
- type ToolResult
- type ToolRunner
- type TriggerDelivery
- type TriggerRunner
- type UsageMetadata
- type Video
Constants ¶
const ( DefaultModel = "gemini-3.5-flash" DefaultImageGenerationModel = "gemini-3.1-flash-image-preview" )
Variables ¶
var DefaultNewHookRunner func() HookRunner
var DefaultNewToolRunner func(tools []any) ToolRunner
var DefaultNewTriggerRunner func(trigs []any, conn any) TriggerRunner
var EnforcePolicies func(policies []any, mcpServers []McpServerConfig) any
Functions ¶
This section is empty.
Types ¶
type AgentConfig ¶
type AgentConfig interface {
CreateStrategy(toolRunner any, hookRunner any) (ConnectionStrategy, error)
GetBaseConfig() *BaseAgentConfig
}
AgentConfig represents the configuration interface for initializing a strategy.
type AskQuestionEntry ¶
type AskQuestionEntry struct {
Question string
Options []AskQuestionOption
IsMultiSelect bool
}
AskQuestionEntry a single question definition.
type AskQuestionInteractionSpec ¶
type AskQuestionInteractionSpec struct {
Questions []AskQuestionEntry
}
AskQuestionInteractionSpec the list of questions for a clarifying question flow.
type AskQuestionOption ¶
AskQuestionOption option for a multiple-choice question.
type BaseAgentConfig ¶
type BaseAgentConfig struct {
SystemInstructions SystemInstructions
Capabilities CapabilitiesConfig
Tools []any
Policies []any
Hooks []any
Triggers []any
McpServers []McpServerConfig
Workspaces []string
ConversationID *string
SaveDir *string
AppDataDir *string
ResponseSchema *string
SkillsPaths []string
}
BaseAgentConfig holds the fields shared across different connection strategies.
func (*BaseAgentConfig) GetBaseConfig ¶
func (b *BaseAgentConfig) GetBaseConfig() *BaseAgentConfig
GetBaseConfig returns the pointer to BaseAgentConfig.
type BaseMcpServerConfig ¶
BaseMcpServerConfig contains common configuration fields for all MCP servers.
func (BaseMcpServerConfig) GetName ¶
func (b BaseMcpServerConfig) GetName() string
GetName returns the name of the MCP server.
func (BaseMcpServerConfig) GetTimeoutSeconds ¶
func (b BaseMcpServerConfig) GetTimeoutSeconds() *int
GetTimeoutSeconds returns the timeout of the MCP server in seconds.
type BuiltinSlashCommandName ¶
type BuiltinSlashCommandName string
const (
SlashCommandPlan BuiltinSlashCommandName = "plan"
)
type BuiltinTools ¶
type BuiltinTools string
BuiltinTools identifiers for common connection-provided builtin tools.
const ( BuiltinListDir BuiltinTools = "list_directory" BuiltinSearchDir BuiltinTools = "search_directory" BuiltinFindFile BuiltinTools = "find_file" BuiltinViewFile BuiltinTools = "view_file" BuiltinCreateFile BuiltinTools = "create_file" BuiltinEditFile BuiltinTools = "edit_file" BuiltinRunCommand BuiltinTools = "run_command" BuiltinAskQuestion BuiltinTools = "ask_question" BuiltinStartSubagent BuiltinTools = "start_subagent" BuiltinGenerateImage BuiltinTools = "generate_image" BuiltinFinish BuiltinTools = "finish" )
func FileBuiltinTools ¶
func FileBuiltinTools() []BuiltinTools
func NondestructiveBuiltinTools ¶
func NondestructiveBuiltinTools() []BuiltinTools
func ReadOnlyBuiltinTools ¶
func ReadOnlyBuiltinTools() []BuiltinTools
type CapabilitiesConfig ¶
type CapabilitiesConfig struct {
EnableSubagents bool
EnabledTools []BuiltinTools
DisabledTools []BuiltinTools
CompactionThreshold *int
ImageModel string
FinishToolSchemaJSON *string
}
CapabilitiesConfig general agent capability configuration.
type ChatResponse ¶
type ChatResponse struct {
// contains filtered or unexported fields
}
ChatResponse wraps the real-time chunk stream from Agent.Chat.
func NewChatResponse ¶
func NewChatResponse(chunks chan StreamChunk, conv Conversation) *ChatResponse
func (*ChatResponse) Chunks ¶
func (r *ChatResponse) Chunks() <-chan StreamChunk
func (*ChatResponse) StructuredOutput ¶
func (r *ChatResponse) StructuredOutput() (any, error)
func (*ChatResponse) Text ¶
func (r *ChatResponse) Text() (string, error)
func (*ChatResponse) Thoughts ¶
func (r *ChatResponse) Thoughts() <-chan string
func (*ChatResponse) ToolCalls ¶
func (r *ChatResponse) ToolCalls() <-chan ToolCall
func (*ChatResponse) UsageMetadata ¶
func (r *ChatResponse) UsageMetadata() *UsageMetadata
type Connection ¶
type Connection interface {
IsIdle() bool
ConversationID() string
Send(ctx context.Context, prompt Content) error
ReceiveSteps(ctx context.Context) <-chan *Step
Disconnect(ctx context.Context) error
Cancel(ctx context.Context) error
Delete(ctx context.Context) error
SignalIdle(ctx context.Context) error
WaitForIdle(ctx context.Context) error
WaitForWakeup(ctx context.Context, timeout time.Duration) (bool, error)
SendToolResults(ctx context.Context, results []ToolResult) error
SendTriggerNotification(ctx context.Context, content string) error
}
Connection represents a live session with an agent backend.
type ConnectionStrategy ¶
type ConnectionStrategy interface {
Start(ctx context.Context) error
Connect() (Connection, error)
io.Closer
}
ConnectionStrategy manages starting the backend, connecting, and clean teardown.
type ContentPrimitive ¶
type ContentPrimitive interface {
// contains filtered or unexported methods
}
ContentPrimitive represents a single piece of user input.
type Conversation ¶
type Conversation interface {
History() []Step
LastResponse() string
TurnCount() int
CompactionIndices() []int
ClearHistory()
GetLastStructuredOutput() any
CumulativeUsage() UsageMetadata
TurnUsage() *UsageMetadata
Cancel(ctx context.Context) error
Chat(ctx context.Context, prompt Content) (*ChatResponse, error)
Connection() any
}
Conversation represents a stateful session with the agent.
type ConversationFactory ¶
type ConversationFactory func(conn any) Conversation
ConversationFactory is the factory function for creating conversations.
var NewConversation ConversationFactory
NewConversation is the registered factory to create conversations.
type CustomSystemInstructions ¶
type CustomSystemInstructions struct {
Text string
}
CustomSystemInstructions replaces the default system instructions entirely.
type FileChange ¶
type FileChange struct {
Kind FileChangeKind
Path string
}
FileChange a single filesystem event.
type FileChangeKind ¶
type FileChangeKind string
FileChangeKind represents the filesystem event type.
const ( FileChangeAdded FileChangeKind = "added" FileChangeModified FileChangeKind = "modified" FileChangeDeleted FileChangeKind = "deleted" )
type GeminiConfig ¶
type GeminiConfig struct {
APIKey *string
Vertex bool
Project *string
Location *string
Models ModelConfig
}
GeminiConfig is the configuration for the Gemini model backend.
type GenerationConfig ¶
type GenerationConfig struct {
ThinkingLevel *ThinkingLevel
}
GenerationConfig contains generation parameters for a model.
type HookResult ¶
HookResult represents the decision of a hook.
type HookRunner ¶
type HookRunner interface {
RegisterHook(hook any)
}
type McpServerConfig ¶
type McpServerConfig interface {
GetName() string
GetTimeoutSeconds() *int
// contains filtered or unexported methods
}
McpServerConfig represents an MCP server configuration (Stdio or Http).
type McpStdioServer ¶
type McpStdioServer struct {
BaseMcpServerConfig
Command string
Args []string
Env map[string]string
EnabledTools []string
DisabledTools []string
}
McpStdioServer is the configuration for an MCP server connected via stdio.
type McpStreamableHttpServer ¶
type McpStreamableHttpServer struct {
BaseMcpServerConfig
URL string
Headers map[string]string
TimeoutSeconds float64
SSEReadTimeout float64
TerminateOnClose bool
EnabledTools []string
DisabledTools []string
}
McpStreamableHttpServer is the configuration for an MCP server connected via Http/SSE.
type Media ¶
type Media interface {
ContentPrimitive
GetData() []byte
GetMimeType() string
GetDescription() string
}
type ModelConfig ¶
type ModelConfig struct {
Default ModelEntry
ImageGeneration ModelEntry
}
ModelConfig is the model selection for each capability.
func NewDefaultModelConfig ¶
func NewDefaultModelConfig() ModelConfig
type ModelEntry ¶
type ModelEntry struct {
Name string
APIKey *string
Generation GenerationConfig
}
ModelEntry is a model with optional auth and generation overrides.
type QuestionHookResult ¶
type QuestionHookResult struct {
Responses []QuestionResponse
Cancelled bool
}
QuestionHookResult contains the results of a question prompt session.
type QuestionResponse ¶
QuestionResponse represents an individual response to an AskQuestion question.
type SlashCommand ¶
type SlashCommand struct {
Name BuiltinSlashCommandName
}
type Step ¶
type Step struct {
ID string
StepIndex int
Type StepType
Source StepSource
Target StepTarget
Status StepStatus
Content string
ContentDelta string
Thinking string
ThinkingDelta string
ToolCalls []ToolCall
Error string
IsCompleteResponse *bool
StructuredOutput any
UsageMetadata *UsageMetadata
}
Step represents a single event in the agent trajectory.
type StepSource ¶
type StepSource string
StepSource represents the source that generated the step.
const ( StepSourceSystem StepSource = "SYSTEM" StepSourceUser StepSource = "USER" StepSourceModel StepSource = "MODEL" StepSourceUnknown StepSource = "UNKNOWN" )
type StepStatus ¶
type StepStatus string
StepStatus represents the status of a step.
const ( StepStatusActive StepStatus = "ACTIVE" StepStatusDone StepStatus = "DONE" StepStatusWaitingForUser StepStatus = "WAITING_FOR_USER" StepStatusError StepStatus = "ERROR" StepStatusCanceled StepStatus = "CANCELED" StepStatusUnknown StepStatus = "UNKNOWN" )
type StepTarget ¶
type StepTarget string
StepTarget represents the target interacting with the step.
const ( StepTargetUser StepTarget = "TARGET_USER" StepTargetEnvironment StepTarget = "TARGET_ENVIRONMENT" StepTargetUnspecified StepTarget = "TARGET_UNSPECIFIED" StepTargetUnknown StepTarget = "UNKNOWN" )
type StreamChunk ¶
type StreamChunk interface {
GetStepIndex() int
// contains filtered or unexported methods
}
StreamChunk is the interface for real-time semantic chunks.
type StringContent ¶
type StringContent string
type SystemInstructionSection ¶
SystemInstructionSection is a named section to append to the system instructions.
type SystemInstructions ¶
type SystemInstructions interface {
// contains filtered or unexported methods
}
SystemInstructions is the interface representing either CustomSystemInstructions or TemplatedSystemInstructions.
type TemplatedSystemInstructions ¶
type TemplatedSystemInstructions struct {
Identity string
Sections []SystemInstructionSection
}
TemplatedSystemInstructions overrides the agent identity and appends sections.
type ThinkingLevel ¶
type ThinkingLevel string
ThinkingLevel for Gemini models that support extended thinking.
const ( ThinkingMinimal ThinkingLevel = "minimal" ThinkingLow ThinkingLevel = "low" ThinkingMedium ThinkingLevel = "medium" ThinkingHigh ThinkingLevel = "high" )
type ToolCall ¶
type ToolCall struct {
Name string `json:"name"`
Args map[string]any `json:"args"`
ID *string `json:"id,omitempty"`
CanonicalPath *string `json:"canonical_path,omitempty"`
}
ToolCall represents a tool call.
func (ToolCall) GetStepIndex ¶
type ToolResult ¶
type ToolResult struct {
Name string `json:"name"`
ID *string `json:"id,omitempty"`
Result any `json:"result,omitempty"`
Error *string `json:"error,omitempty"`
Exception error `json:"-"`
}
ToolResult represents the result of a tool execution.
type ToolRunner ¶
type ToolRunner interface {
SetContext(ctx any)
}
type TriggerDelivery ¶
type TriggerDelivery string
TriggerDelivery controls how trigger messages are delivered.
const ( TriggerDeliverySendImmediately TriggerDelivery = "send_immediately" TriggerDeliveryWaitIdle TriggerDelivery = "wait_idle" )
type TriggerRunner ¶
Directories
¶
| Path | Synopsis |
|---|---|
|
connections
|
|
|
examples
|
|
|
custom_tools
command
|
|
|
hello_world
command
|
|
|
triggers_and_policies
command
|
|