Documentation
¶
Overview ¶
Package engine is the high-level entrypoint for embedding the rakit agent: it wires the LLM client, tool registry, skills, plugins, MCP, and the agent manager behind one constructor. Hosts that need finer control can construct the underlying packages directly — the engine is a convenience, not a gate.
Index ¶
- Variables
- type Engine
- func (e *Engine) Bus() *events.Bus
- func (e *Engine) Compact(sessionID string) error
- func (e *Engine) HasProvider() bool
- func (e *Engine) Home() string
- func (e *Engine) LLM() *llm.LLMClient
- func (e *Engine) MCP() *mcp.Manager
- func (e *Engine) MCPStatus() []mcp.ServerConfig
- func (e *Engine) Manager() *agent.Manager
- func (e *Engine) Memory() *memory.Manager
- func (e *Engine) ModelInfo() (string, string)
- func (e *Engine) Plugins() *plugins.Manager
- func (e *Engine) Profiles() []llm.ProviderProfile
- func (e *Engine) ReasoningEffort(effort string)
- func (e *Engine) RegisterMCPTools()
- func (e *Engine) Run(ctx context.Context, prompt string) (string, error)
- func (e *Engine) RunIn(ctx context.Context, sessionID, prompt string, mentionedPaths ...string) (string, error)
- func (e *Engine) SetModel(fullID string) bool
- func (e *Engine) SkillManager() *skills.Manager
- func (e *Engine) Skills() []skills.Skill
- func (e *Engine) Tools() *tools.Registry
- func (e *Engine) UsageSummary() map[string]any
- func (e *Engine) Workspace() string
- type Options
Constants ¶
This section is empty.
Variables ¶
var ErrNoProvider = errors.New("no LLM provider configured: run `rakit import`, set an API key env var (e.g. OPENAI_API_KEY), or add a profile under the home dir")
ErrNoProvider is returned by Run when no provider profile or environment API key is available.
Functions ¶
This section is empty.
Types ¶
type Engine ¶
type Engine struct {
// contains filtered or unexported fields
}
Engine is a wired, ready-to-use agent runtime.
func New ¶
New assembles the engine. It returns an error only when the workspace or home cannot be resolved; LLM configuration problems surface on first use.
func (*Engine) Compact ¶ added in v0.2.0
Compact summarizes a session's history in place to free context window.
func (*Engine) HasProvider ¶
HasProvider reports whether any LLM provider is usable: an active profile with a key (or a local base URL), or any enabled profile.
func (*Engine) LLM ¶ added in v0.2.0
LLM returns the engine's LLM client (provider profiles, active model, chat APIs).
func (*Engine) MCP ¶ added in v0.2.0
MCP returns the engine's MCP manager (server config, connect/disconnect, connected tools).
func (*Engine) MCPStatus ¶ added in v0.2.0
func (e *Engine) MCPStatus() []mcp.ServerConfig
MCPStatus lists configured MCP servers with their connection status.
func (*Engine) Manager ¶
Manager exposes the agent manager for full control (sessions, approvals, subagents, schedules).
func (*Engine) Profiles ¶ added in v0.2.0
func (e *Engine) Profiles() []llm.ProviderProfile
Profiles lists the configured provider profiles.
func (*Engine) ReasoningEffort ¶ added in v0.2.0
ReasoningEffort sets the thinking-effort hint sent to providers that support it ("low", "medium", "high"; "" clears it).
func (*Engine) RegisterMCPTools ¶
func (e *Engine) RegisterMCPTools()
RegisterMCPTools connects nothing but registers whatever tools the MCP manager reports as connected into the engine's tool registry.
func (*Engine) Run ¶
Run executes one headless turn in a throwaway session and returns the assistant's final text. Mutating tool calls are auto-approved only when Options.Yolo was set; otherwise they are declined so the turn can end.
func (*Engine) RunIn ¶
func (e *Engine) RunIn(ctx context.Context, sessionID, prompt string, mentionedPaths ...string) (string, error)
RunIn executes one turn inside an existing session (REPLs, resume flows) and returns the assistant's final text. Optional mentioned paths are @-mention files whose contents get inlined for the model.
func (*Engine) SetModel ¶ added in v0.2.0
SetModel switches the active provider/model by full id ("provider/model"). Reports whether a matching profile was found.
func (*Engine) SkillManager ¶ added in v0.2.0
SkillManager returns the engine's skills manager (Skills lists the discovered skills).
func (*Engine) Tools ¶ added in v0.2.0
Tools returns the engine's tool registry; hosts register app-specific tools and MCP tools into it.
func (*Engine) UsageSummary ¶ added in v0.2.0
UsageSummary aggregates token usage across sessions, providers, and models.
type Options ¶
type Options struct {
// Home is the engine's storage root. Empty means $RAKIT_HOME, else
// ~/.rakit. Provider profiles, MCP servers, plugins, sessions, and skills
// all live under it.
Home string
// Workspace is the folder the agent operates on. Empty means the current
// process working directory.
Workspace string
// Model selects the initial model as "provider/model" (for example
// "openai/gpt-4o"). Empty uses the client's active profile.
Model string
// Yolo auto-approves every tool call. Only for trusted, sandboxed use.
Yolo bool
// Bus lets a host supply its own event bus (subscribe before New returns
// to catch everything). A new bus is created when nil.
Bus *events.Bus
// Term optionally supplies persistent shells (PTY-backed). nil makes the
// bash tool run one-shot subprocesses.
Term agent.ShellManager
// ConnectMCP connects configured MCP servers at startup and registers
// their tools. Off by default: hosts usually want lazy or custom wiring.
ConnectMCP bool
// Optional pre-built components. When nil (the normal case) the engine
// constructs its own from Home; hosts that need custom construction —
// a desktop app sharing its own tool registry or search index, a server
// with its own LLM profile store — supply them and the engine adopts
// them as-is. See CONTRACT.md.
LLMClient *llm.LLMClient
Tools *tools.Registry
Skills *skills.Manager
Plugins *plugins.Manager
MCP *mcp.Manager
Memory *memory.Manager
}
Options configures a new Engine.