Documentation
¶
Overview ¶
Package app provides the shared AgentRunner used by both the CLI and MCP adapters. Neither adapter should duplicate the agent-resolution, prompt assembly, or result-normalization logic; all of that lives here.
Index ¶
- func AssemblePromptForTest(constitution string, skills map[string]*skill.Skill, skillNames []string, ...) (string, string)
- type AgentRunner
- type Config
- type Constitution
- type RunRequest
- type Runner
- func (r *Runner) Doctor(ctx context.Context) (result.DoctorResult, error)
- func (r *Runner) GetConstitution(_ context.Context, agentID string) (Constitution, error)
- func (r *Runner) GetSpec(_ context.Context, agentID string) (*agent.Spec, error)
- func (r *Runner) ListAgents(_ context.Context) ([]agent.Summary, error)
- func (r *Runner) Run(ctx context.Context, req RunRequest) (result.RunResult, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type AgentRunner ¶
type AgentRunner interface {
// ListAgents returns lightweight summaries for every registered agent.
ListAgents(ctx context.Context) ([]agent.Summary, error)
// Run executes one agent invocation end-to-end and returns a normalized
// result envelope with enough metadata for the orchestrator to judge
// usefulness.
Run(ctx context.Context, req RunRequest) (result.RunResult, error)
// GetConstitution returns the resolved constitution text and its source for
// a given agent ID. Useful for auditing and MCP get_constitution calls.
GetConstitution(ctx context.Context, agentID string) (Constitution, error)
// Doctor reports Ollama connectivity, registry state, and skill layout.
Doctor(ctx context.Context) (result.DoctorResult, error)
}
AgentRunner is the service interface consumed by both the CLI and MCP adapters. Any adapter that satisfies this interface can be tested in isolation without a live Ollama instance.
type Config ¶
type Config struct {
// RootDir is the repository or project root used to resolve relative paths
// such as constitution_path values in agent specs.
RootDir string
// AgentDir is the directory that contains *.md agent spec files.
// Defaults to <RootDir>/agents if empty.
AgentDir string
// SkillsDir is the directory that contains per-skill subdirectories.
// Defaults to <RootDir>/skills if empty.
SkillsDir string
// OllamaHost is the base URL of the local Ollama server.
// Defaults to http://127.0.0.1:11434 if empty.
OllamaHost string
// RuntimePlugins is the optional registry of native plugins exposed to agents.
// Defaults to the built-in registry.
RuntimePlugins *plugins.Registry
}
Config holds runtime configuration for a Runner.
type Constitution ¶
type Constitution struct {
AgentID string `json:"agent_id"`
// Source is one of "path", "body", or "legacy".
Source string `json:"source"`
// Path is set when Source is "path" or "legacy".
Path string `json:"path,omitempty"`
Text string `json:"text"`
}
Constitution holds the resolved constitution text and provenance.
type RunRequest ¶
type RunRequest struct {
// AgentID identifies the specialist to invoke.
AgentID string
// Task is the task text supplied by the orchestrator (from --input, --stdin,
// or the MCP tool call payload).
Task string
// SkillNames is the required list of skill IDs to attach.
// Each must be present in the agent's allowed_skills list.
SkillNames []string
// Format controls the rendered output: "json" (default) or "markdown".
Format string
}
RunRequest is the input to Runner.Run.
type Runner ¶
type Runner struct {
// contains filtered or unexported fields
}
Runner implements AgentRunner using a local Ollama server.
func New ¶
New creates a Runner from cfg, loads all agent specs, and returns. It fails fast if the agent directory cannot be read or any spec is invalid.
func (*Runner) Doctor ¶
Doctor implements AgentRunner. It checks Ollama connectivity, model availability, agent registry state, and skill directory structure.
func (*Runner) GetConstitution ¶
GetConstitution implements AgentRunner. It resolves the constitution for agentID and returns it with provenance metadata.
func (*Runner) GetSpec ¶
GetSpec returns the full parsed Spec for agentID. This is a convenience method for CLI commands that need more detail than the Summary returned by ListAgents.
func (*Runner) ListAgents ¶
ListAgents implements AgentRunner.
func (*Runner) Run ¶
Run implements AgentRunner end-to-end:
- Resolve the agent spec by ID.
- Validate that at least one skill is requested.
- Validate each requested skill against the agent's allowed_skills.
- Load the constitution (via constitution_path, inline body, or legacy path).
- Load each skill's full SKILL.md content.
- Assemble the Ollama prompt with progressive disclosure.
- Enforce the per-agent context budget (warn if exceeded).
- Apply the agent's latency_budget_ms as a context deadline if none is set.
- Call Ollama.
- Return a normalized RunResult with usage and provenance metadata.