Documentation
¶
Index ¶
- Constants
- Variables
- func BuildBaseEnv(openbeeURL string) []string
- func BuildRunEnv(baseEnv, extraEnv []string, apiKey string) []string
- func Register(name string, f Factory)
- func ScanJSONLines(r io.Reader, fn func(line string) bool)
- func SkillHintPrefix(role Role) string
- func WorkerPersona(name, description, memory string) string
- type CmdProcess
- type EngineAdapter
- type EngineConfig
- type Factory
- type Output
- type OutputType
- type PrepareOptions
- type Process
- type Registry
- type Role
- type RunOptions
Constants ¶
const ( // SystemRulesFile is the legacy rules file that Claude's Prepare hook cleans up. SystemRulesFile = ".openbee.md" // ImportLine is the legacy reference line that Claude's Prepare hook removes from CLAUDE.md. ImportLine = "@" + SystemRulesFile )
const ( EngineClaude = "claude" EngineCodex = "codex" EnginePi = "pi" )
Engine name constants used for registration and configuration.
Variables ¶
var DefaultRegistry = NewRegistry()
DefaultRegistry is the process-wide registry populated by engine init() functions.
var ErrUnknownEngine = fmt.Errorf("unknown engine")
ErrUnknownEngine is returned when New is called with an unregistered engine name.
Functions ¶
func BuildBaseEnv ¶
BuildBaseEnv constructs the base environment for engine subprocesses. It prepends the current executable's directory to PATH and appends OPENBEE_URL.
func BuildRunEnv ¶ added in v0.0.24
BuildRunEnv assembles the final env slice for a subprocess run.
func ScanJSONLines ¶
ScanJSONLines reads r line by line and calls fn for each line that starts with '{'. fn returns true to keep scanning or false to stop early.
func SkillHintPrefix ¶
SkillHintPrefix returns the skill invocation hint prepended to the first message of a new session.
func WorkerPersona ¶
WorkerPersona returns the persona-only content injected into new worker session prompts.
Types ¶
type CmdProcess ¶
type CmdProcess struct {
// contains filtered or unexported fields
}
CmdProcess implements Process for an os/exec.Cmd.
func NewCmdProcess ¶
func NewCmdProcess(cmd *exec.Cmd) *CmdProcess
NewCmdProcess wraps an exec.Cmd as a Process.
func (*CmdProcess) PID ¶
func (p *CmdProcess) PID() int
func (*CmdProcess) Stop ¶
func (p *CmdProcess) Stop() error
type EngineAdapter ¶
type EngineAdapter interface {
// Prepare is an engine-specific initialisation hook called before each Run.
// It must be idempotent. Claude uses it to clean up legacy config files;
// other engines return nil.
Prepare(workDir string, opts PrepareOptions) error
// Run executes a task and returns a process handle and an event channel.
// The channel is closed after the process exits.
Run(ctx context.Context, workDir, prompt string,
opts RunOptions, logPath string) (Process, <-chan Output, error)
// ExtractResult parses the engine-specific log file and returns the final
// result string, or "" if none found.
ExtractResult(logPath string) string
}
EngineAdapter is the complete plugin contract for an AI engine. Implementations must be safe for concurrent use.
func New ¶
func New(name string, cfg EngineConfig) (EngineAdapter, error)
New constructs an engine from the DefaultRegistry.
type EngineConfig ¶
type EngineConfig struct {
// OpenbeeURL is the openbee server base URL injected for MCP connectivity.
OpenbeeURL string
// Raw holds engine-specific configuration (parsed from config.yaml).
Raw map[string]any
}
EngineConfig holds the configuration passed to a Factory when constructing an engine.
type Factory ¶
type Factory func(cfg EngineConfig) (EngineAdapter, error)
Factory creates an EngineAdapter from the supplied config.
type Output ¶
type Output struct {
Type OutputType `json:"type"`
Content string `json:"content"`
}
Output is a single lifecycle event.
type OutputType ¶
type OutputType string
OutputType classifies a lifecycle event from a running process.
const ( OutputDone OutputType = "done" OutputError OutputType = "error" )
type PrepareOptions ¶
type PrepareOptions struct {
Role Role
}
PrepareOptions carries parameters for the engine-specific Prepare hook. Add future fields here without changing the Prepare method signature.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry maps engine names to their factories.
func (*Registry) New ¶
func (r *Registry) New(name string, cfg EngineConfig) (EngineAdapter, error)
New constructs the engine registered under name.