Documentation
¶
Index ¶
- Variables
- type Canceller
- type Cargo
- type Config
- type Constructor
- type LLMModel
- type LLMProvider
- type LoopControl
- type MCPClientConfig
- type MCPConfig
- type ModelCapability
- type MoonshotFetchConfig
- type MoonshotSearchConfig
- type Option
- func WithAPIKey(apiKey string) Option
- func WithArgs(args ...string) Option
- func WithAutoApprove() Option
- func WithBaseURL(baseURL string) Option
- func WithConfig(config *Config) Option
- func WithConfigFile(file string) Option
- func WithExecutable(executable string) Option
- func WithMCPConfig(config *MCPConfig) Option
- func WithMCPConfigFile(file string) Option
- func WithModel(model string) Option
- func WithSession(session string) Option
- func WithSkillsDir(dir string) Option
- func WithThinking(thinking bool) Option
- func WithTools(tools ...Tool) Option
- func WithWorkDir(dir string) Option
- type ProviderType
- type Responder
- type ResponderFunc
- type Services
- type Session
- type SingleTurn
- type Step
- type Tool
- type ToolOption
- type Turn
- type Usage
Constants ¶
This section is empty.
Variables ¶
var (
ErrTurnNotFound = errors.New("turn not found")
)
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
DefaultModel string `json:"default_model" toml:"default_model"`
Models map[string]LLMModel `json:"models" toml:"models"`
Providers map[string]LLMProvider `json:"providers" toml:"providers"`
LoopControl LoopControl `json:"loop_control" toml:"loop_control"`
Services Services `json:"services" toml:"services"`
MCP MCPConfig `json:"mcp" toml:"mcp"`
}
type Constructor ¶
type Constructor[T any, R any] interface { RPCRequest() (*R, error) Construct( ctx context.Context, id uint64, stdioTransport transport.Transport, errorPointer *atomic.Pointer[error], resultPointer *atomic.Pointer[R], wireProtocolVersion string, wireMessageChan <-chan wire.Message, wireRequestResponseChan chan<- wire.RequestResponse, exit func(error) error, ) *T }
type LLMModel ¶
type LLMModel struct {
Provider string `json:"provider" toml:"provider"`
Model string `json:"model" toml:"model"`
MaxContextSize int `json:"max_context_size" toml:"max_context_size"`
Capabilities map[ModelCapability]bool `json:"capabilities,omitempty" toml:"capabilities,omitempty"`
}
type LLMProvider ¶
type LLMProvider struct {
Type ProviderType `json:"type" toml:"type"`
BaseURL string `json:"base_url" toml:"base_url"`
APIKey string `json:"api_key" toml:"api_key"`
Env map[string]string `json:"env,omitempty" toml:"env,omitempty"`
CustomHeaders map[string]string `json:"custom_headers,omitempty" toml:"custom_headers,omitempty"`
}
type LoopControl ¶
type MCPClientConfig ¶
type MCPClientConfig struct {
ToolCallTimeoutMS int `json:"tool_call_timeout_ms" toml:"tool_call_timeout_ms"`
}
type MCPConfig ¶
type MCPConfig struct {
Client MCPClientConfig `json:"client" toml:"client"`
}
type ModelCapability ¶
type ModelCapability string
const ( ModelCapabilityImageIn ModelCapability = "image_in" ModelCapabilityVideoIn ModelCapability = "video_in" ModelCapabilityThinking ModelCapability = "thinking" )
type MoonshotFetchConfig ¶
type MoonshotSearchConfig ¶
type Option ¶
type Option func(*option)
func WithAPIKey ¶
func WithAutoApprove ¶
func WithAutoApprove() Option
func WithBaseURL ¶
func WithConfig ¶
func WithConfigFile ¶
func WithExecutable ¶
func WithMCPConfig ¶
func WithMCPConfigFile ¶
func WithSession ¶
func WithSkillsDir ¶
func WithThinking ¶
func WithWorkDir ¶
type ProviderType ¶
type ProviderType string
const ( ProviderTypeKimi ProviderType = "kimi" ProviderTypeOpenAILegacy ProviderType = "openai_legacy" ProviderTypeOpenAIResponses ProviderType = "openai_responses" ProviderTypeAnthropic ProviderType = "anthropic" ProviderTypeGoogleGenAI ProviderType = "google_genai" // for backward-compatibility, equals to `gemini` ProviderTypeGemini ProviderType = "gemini" ProviderTypeVertexAI ProviderType = "vertexai" )
type Responder ¶
func (*Responder) Event ¶
func (r *Responder) Event(event *wire.EventParams) (*wire.EventResult, error)
func (*Responder) Request ¶
func (r *Responder) Request(request *wire.RequestParams) (wire.RequestResult, error)
type ResponderFunc ¶
type ResponderFunc func(wire.RequestResponse) error
func (ResponderFunc) Respond ¶
func (f ResponderFunc) Respond(r wire.RequestResponse) error
type Services ¶
type Services struct {
MoonshotSearch *MoonshotSearchConfig `json:"moonshot_search,omitempty" toml:"moonshot_search,omitempty"`
MoonshotFetch *MoonshotFetchConfig `json:"moonshot_fetch,omitempty" toml:"moonshot_fetch,omitempty"`
}
type Session ¶
type Session struct {
SlashCommands []wire.SlashCommand
// contains filtered or unexported fields
}
func NewSession ¶
type SingleTurn ¶
type SingleTurn struct {
*Turn
// contains filtered or unexported fields
}
SingleTurn wraps a Turn and its associated Session for single-use scenarios. When Close or Cancel is called, it cancels the turn and closes the session.
func Prompt ¶
Prompt is a convenient function for single-turn prompts. Use SingleTurn.Close() (or Cancel()) to release resources when done.
func (*SingleTurn) Cancel ¶
func (st *SingleTurn) Cancel() error
Cancel cancels the turn and closes the session. It is equivalent to Close.
func (*SingleTurn) Close ¶
func (st *SingleTurn) Close() error
Close cancels the turn and closes the session.
type Tool ¶
type Tool struct {
// contains filtered or unexported fields
}
func CreateTool ¶
CreateTool creates a Tool from a function. The function must have signature func(T) (U, error) where T is a struct type. The result U can be: string (returned directly), fmt.Stringer (calls .String()), or any other type (JSON serialized).
type ToolOption ¶
type ToolOption func(*toolOption)
func WithDescription ¶
func WithDescription(description string) ToolOption
WithDescription sets the tool description.
func WithFieldDescription ¶
func WithFieldDescription(fieldName, description string) ToolOption
WithFieldDescription sets description for a struct field. The fieldName should be the Go struct field name (not the JSON name).
func WithName ¶
func WithName(name string) ToolOption
WithName sets the tool name (overrides auto-detected name from function).
func WithSchema ¶
func WithSchema(schema json.RawMessage) ToolOption
WithSchema sets the JSON schema directly, bypassing automatic schema generation from the parameter type. Use this when you need full control over the schema or when the automatic generation doesn't meet your needs.
type Turn ¶
type Turn struct {
Steps <-chan *Step
// contains filtered or unexported fields
}
func (*Turn) Result ¶
func (t *Turn) Result() wire.PromptResult
type Usage ¶
type Usage struct {
Context float64
Tokens wire.TokenUsage
}