Documentation
¶
Index ¶
- Constants
- Variables
- type Agent
- type Message
- type Model
- type ModelFunc
- type Option
- func WithDependencies(pkgs ...string) Option
- func WithFunc(name string, fn any) Option
- func WithLanguage(lang string) Option
- func WithLogger(fn func(string, ...any)) Option
- func WithMaxRetries(n int) Option
- func WithMaxTurns(n int) Option
- func WithModel(m Model) Option
- func WithPermissions(p Permissions) Option
- func WithPostCondition(expr string) Option
- func WithRunner(r codeact.Runner) Option
- func WithSystemPrompt(prompt string) Option
- type PermissionState
- type Permissions
- type Result
Constants ¶
const ( RoleUser = "user" RoleAssistant = "assistant" )
Role constants for Message.
Variables ¶
var ( ErrNoModel = errors.New("conjure: model is required") ErrMaxRetries = errors.New("conjure: max retries exceeded") ErrMaxTurns = errors.New("conjure: max turns exceeded") )
Sentinel errors.
Functions ¶
This section is empty.
Types ¶
type Agent ¶
type Agent struct {
// contains filtered or unexported fields
}
Agent is a CodeAgent instance that generates and executes code via an LLM.
func (*Agent) ResetConversation ¶
func (a *Agent) ResetConversation()
ResetConversation clears the conversation history. This does not reset the runtime state (variables in JS/Python).
type Option ¶
type Option func(*config)
Option configures an Agent.
func WithDependencies ¶
WithDependencies declares npm/pip packages available to generated code.
func WithFunc ¶
WithFunc registers a Go function that LLM-generated code can call. The function signature is inferred at init time using the configured language.
func WithLanguage ¶
WithLanguage sets the code generation language ("javascript" or "python").
func WithLogger ¶
WithLogger sets a log function for debug output.
func WithMaxRetries ¶
WithMaxRetries sets the maximum consecutive retry count on code execution failure.
func WithMaxTurns ¶
WithMaxTurns sets the absolute upper limit on LLM call turns.
func WithPermissions ¶
func WithPermissions(p Permissions) Option
WithPermissions sets sandbox permissions for JS code execution.
func WithPostCondition ¶
WithPostCondition adds a post-condition expression to validate the result.
func WithRunner ¶
WithRunner supplies a pre-built codeact Runner. When set, WithLanguage/WithPermissions/WithDependencies are ignored.
func WithSystemPrompt ¶
WithSystemPrompt appends additional instructions to the system prompt.
type PermissionState ¶
type PermissionState int
PermissionState controls whether a permission is granted or denied.
const ( PermGranted PermissionState = iota PermDenied )
type Permissions ¶
type Permissions struct {
Read PermissionState
Write PermissionState
Net PermissionState
Env PermissionState
Run PermissionState
ReadPaths []string
WritePaths []string
NetHosts []string
EnvVars []string
RunCmds []string
}
Permissions controls sandbox capabilities for JS code execution. Ignored when language is Python.
type Result ¶
type Result struct {
Value string // Final result value (JSON string)
Logs []string // Captured console.log / print output
Code string // The last code that was executed
Turns int // Number of LLM call turns taken
// contains filtered or unexported fields
}
Result holds the outcome of a CodeAgent execution.