app

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Jun 1, 2026 License: MIT Imports: 9 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func AssemblePromptForTest

func AssemblePromptForTest(constitution string, skills map[string]*skill.Skill, skillNames []string, task string) (string, string)

AssemblePromptForTest exposes assemblePrompt for golden tests in internal/benchmark.

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
}

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

func New(cfg Config) (*Runner, error)

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

func (r *Runner) Doctor(ctx context.Context) (result.DoctorResult, error)

Doctor implements AgentRunner. It checks Ollama connectivity, model availability, agent registry state, and skill directory structure.

func (*Runner) GetConstitution

func (r *Runner) GetConstitution(_ context.Context, agentID string) (Constitution, error)

GetConstitution implements AgentRunner. It resolves the constitution for agentID and returns it with provenance metadata.

func (*Runner) GetSpec

func (r *Runner) GetSpec(_ context.Context, agentID string) (*agent.Spec, error)

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

func (r *Runner) ListAgents(_ context.Context) ([]agent.Summary, error)

ListAgents implements AgentRunner.

func (*Runner) Run

func (r *Runner) Run(ctx context.Context, req RunRequest) (result.RunResult, error)

Run implements AgentRunner end-to-end:

  1. Resolve the agent spec by ID.
  2. Validate that at least one skill is requested.
  3. Validate each requested skill against the agent's allowed_skills.
  4. Load the constitution (via constitution_path, inline body, or legacy path).
  5. Load each skill's full SKILL.md content.
  6. Assemble the Ollama prompt with progressive disclosure.
  7. Enforce the per-agent context budget (warn if exceeded).
  8. Apply the agent's latency_budget_ms as a context deadline if none is set.
  9. Call Ollama.
  10. Return a normalized RunResult with usage and provenance metadata.

Jump to

Keyboard shortcuts

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