app

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Jul 15, 2026 License: MIT Imports: 32 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 {
	// RootFS is the resolved fs.FS for the project root. When set it takes
	// priority over RootDir. Set by the CLI via rootresolver after resolving
	// the --root flag (local path or remote GitHub URL).
	RootFS fs.FS
	// RootLabel is the human-readable root descriptor for display (e.g.
	// "https://github.com/owner/repo" or "/local/path"). Used in doctor output.
	RootLabel string
	// RootDir is the local project root. Used when RootFS is nil. Kept for
	// backward compatibility with tests that create on-disk fixtures.
	RootDir string
	// AgentDir is a local path override for the agents directory.
	// When set it overrides the agents/ sub-FS derived from RootFS/RootDir.
	AgentDir string
	// SkillsDir is a local path override for the skills directory.
	// When set it overrides the skills/ sub-FS derived from RootFS/RootDir.
	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
	// DownstreamMCP is an optional client for configured MCP servers that
	// specialists can inspect and call through bounded Prism bridge tools.
	DownstreamMCP DownstreamMCPClient
	// ModelRuntime is an optional provider-neutral runtime used for all
	// specialist model calls. When nil, Prism builds an Ollama-backed
	// runtime targeting OllamaHost.
	ModelRuntime llmruntime.ModelRuntime
	// EventSink receives one stable RunEvent after each Run call. Defaults to a
	// no-op sink so OSS behavior is unchanged when observability is not enabled.
	EventSink observe.Sink
	// PolicyEngine is optional. When set, requests are checked before evidence
	// collection and model execution.
	PolicyEngine *internalpolicy.Engine
}

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 DownstreamMCPClient added in v0.1.14

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
	// Metadata is optional caller context used by team dashboards and reports.
	Metadata observe.Metadata
	// Optional provenance fields for observability.
	BundleID      string
	BundleVersion string
	GraphID       string
	GraphNodeID   string
}

RunRequest is the input to Runner.Run.

type Runner

type Runner struct {
	// contains filtered or unexported fields
}

Runner implements AgentRunner on top of a provider-neutral ModelRuntime.

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 model 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 the configured model runtime.
  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