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 DownstreamMCPClient
- type RunRequest
- type Runner
- func (r *Runner) CatalogSnapshot() extensions.CatalogSnapshot
- 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) RequiresWorkspace(agentID string) (bool, error)
- func (r *Runner) Run(ctx context.Context, req RunRequest) (result.RunResult, error)
- func (r *Runner) SkillsFS() fs.FS
- type Workspace
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 {
// BundleFS contains agents/, skills/, and constitutions/. Production callers
// use Prism's embedded bundle; tests and development overrides may supply one.
BundleFS fs.FS
// Bundle metadata is stamped onto every result and event.
BundleVersion string
BundleDigest string
BundleMode string
// WorkspaceFS is visible only to repository-aware runtime plugins.
WorkspaceFS fs.FS
WorkspaceLabel string
GitHubToken string
// 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
// ConstitutionFS supplies sibling support files for an AgentDir override.
// When unset, constitutions resolve from the effective bundle. Both
// execution and get_constitution use this filesystem.
ConstitutionFS fs.FS
// 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
// ExtensionsStateDir enables managed-extension catalog composition.
ExtensionsStateDir string
// ExtensionSnapshot can be precomputed by callers; when nil New composes one.
ExtensionSnapshot *extensions.CatalogSnapshot
// MCPAccess controls per-agent downstream MCP visibility and authorization.
MCPAccess extensions.MCPAccessState
MCPAccessConfigured bool
// Graphify is the explicit, workspace-bound Graphify capability
// configuration. It is intentionally independent of MCPAccess.
Graphify graphify.Config
// RuntimeTarget describes the effective process runtime. Model may be empty
// when the process has no global model override.
RuntimeTarget extensions.RuntimeTarget
}
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 DownstreamMCPClient interface {
Servers() []downstreammcp.Server
ListTools(context.Context, string, downstreammcp.ListToolsOptions) (downstreammcp.ListToolsResult, error)
CallTool(context.Context, string, string, map[string]any) (downstreammcp.CallResult, error)
}
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
// SkillResources explicitly attaches bounded text resources in
// <skill>:<path> form for runtimes that cannot make tool calls.
SkillResources []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
// Workspace selects repository evidence for this invocation. It is optional
// for agents that do not use repository-aware plugins.
Workspace Workspace
// Optional graph provenance fields.
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 ¶
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) CatalogSnapshot ¶ added in v0.1.22
func (r *Runner) CatalogSnapshot() extensions.CatalogSnapshot
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) RequiresWorkspace ¶ added in v0.1.21
RequiresWorkspace reports whether an agent declares a repository-scoped runtime plugin. MCP adapters use it to avoid asking hosts for roots when the selected specialist does not need repository access.
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 model 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 the configured model runtime.
- Return a normalized RunResult with usage and provenance metadata.