agent

package
v0.1.0-alpha.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 20, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Agent

type Agent interface {
	// Run drives the agent for a single user turn.
	Run(ctx context.Context, prompt string) (string, error)

	// Continue resumes an iter-limit-paused run without appending a new
	// user message.
	Continue(ctx context.Context) (string, error)

	// Session returns a snapshot of the conversation state.
	Session() SessionInfo

	// Logger exposes the agent's structured logger.
	Logger() *slog.Logger

	// Model returns the model id the agent is currently bound to.
	Model() string

	// AgentID returns the agent's unique identifier.
	AgentID() string

	// MaxIterations / SetMaxIterations exposes the loop cap.
	MaxIterations() int
	SetMaxIterations(int)

	// SwitchLLM rebuilds the agent's LLM client with a new (provider, model)
	// pair and clears the conversation history.
	SwitchLLM(provider constant.LLMProvider, model constant.Model) error

	// SwitchProfile reconstructs the agent under a new persona.
	SwitchProfile(name string) error

	// ProfileName returns the active persona's wire identity.
	ProfileName() string

	// ListMainProfiles enumerates the personas available for switching.
	ListMainProfiles() []ProfileChoice

	// Effort returns the current effort level name ("low"|"medium"|"high"|"ultra").
	Effort() string

	// SetEffort updates the effort level at runtime.
	SetEffort(level string) error

	// Skills returns the merged catalog of user-installed skills.
	Skills() []Skill

	// Compact forces an immediate compaction of the current session.
	Compact(ctx context.Context, kind string) error

	// PermissionModeName returns the agent's current permission stance
	// as a string ("default", "accept_edits", "plan", "bypass", "auto").
	PermissionModeName() string

	// CyclePermissionMode advances the mode in Shift+Tab order and
	// returns the new mode name.
	CyclePermissionMode() string

	// RespondPermission delivers the user's approval/denial back to
	// the blocked tool goroutine.
	RespondPermission(id string, decision PermissionDecision) error

	// RespondQuestion delivers the user's answers back to the blocked
	// AskUserQuestion tool goroutine.
	RespondQuestion(id string, resp QuestionResponse) error
}

Agent is the public API for creating and driving an evva agent programmatically. It is implemented by a wrapper around the internal agent.

func New

func New(cfg Config) (Agent, error)

New constructs an Agent ready to call Run. It loads the app config and memory files from the current working directory, builds a full-kit Main profile, and wires up a non-interactive permission broker.

Set API keys via environment variables (ANTHROPIC_API_KEY, OPENAI_API_KEY, DEEPSEEK_API_KEY) or evva-config.yml.

type Config

type Config struct {
	// Provider is the LLM provider name: "anthropic", "openai", "deepseek", "ollama".
	Provider string
	// Model is the model id, e.g. "claude-sonnet-4-6". When empty, the
	// provider's cheapest model is used.
	Model string
	// MaxIters overrides the default loop iteration cap. Zero means use the
	// default (from evva-config.yml or 10).
	MaxIters int
	// PermissionMode sets the initial permission stance: "default", "bypass",
	// "accept_edits", "plan". Empty means "bypass" (all tool calls auto-approved).
	PermissionMode string
}

Config is the public constructor input for creating an agent. Provider and Model are the only required fields.

type PermissionDecision

type PermissionDecision struct {
	Behavior string // "allow" | "deny"
	Reason   string
	AddRule  *PermissionRuleSeed
}

PermissionDecision is the payload returned through Agent.RespondPermission.

type PermissionRuleSeed

type PermissionRuleSeed struct {
	ToolName string
	Content  string // empty means tool-wide
}

PermissionRuleSeed is the minimum info needed to construct a session-scope allow rule.

type ProfileChoice

type ProfileChoice struct {
	Name      string
	WhenToUse string
}

ProfileChoice is one row in the /profile picker.

type QuestionAnnotation

type QuestionAnnotation struct {
	Notes   string
	Preview string
}

QuestionAnnotation captures the preview content (if any) of the option the user selected, plus any free-text notes they added.

type QuestionResponse

type QuestionResponse struct {
	Answers     map[string]string
	Annotations map[string]QuestionAnnotation
}

QuestionResponse is the payload returned through Agent.RespondQuestion.

type SessionInfo

type SessionInfo struct {
	MessageCount    int
	InputTokens     int
	OutputTokens    int
	LastInputTokens int
}

SessionInfo is a snapshot of the agent's conversation state (message count and cumulative token usage). External callers get a point-in-time copy.

type Skill

type Skill struct {
	Name        string
	Description string
}

Skill is the UI-facing view of a user-installed skill.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL