Files
archie/internal/agentexec/harness_adapters.go
T
sam bf33ec9535 refactor(agentrun): agent stage contract moves to the domain layer
internal/domain/workflow imported internal/agentexec for its protocol types,
pulling the AI runtime into every binary that touches workflow types. The
request, result and runner contract now live in internal/domain/agentrun;
agentexec keeps the runtime. The model catalog cache moves from servicekit
into modelcatalog and WaitForPeer into staterpc, so archie-state-store and
archie-messaging no longer link the AI runtime.
2026-10-04 01:33:00 +10:00

63 lines
2.1 KiB
Go

package agentexec
import (
"context"
"github.com/samcharles93/archie-core/internal/domain/agentrun"
)
// AdapterClaudeCode names the Claude Code stream-json output adapter.
const AdapterClaudeCode = "claude-code"
// Adapters for the other supported CLIs' JSON output streams.
const (
AdapterCodex = "codex"
AdapterPi = "pi"
AdapterOMP = "omp"
AdapterCopilot = "copilot"
)
// HarnessAdapter is what archie knows about one CLI: how to read its output
// stream and how to register archie's MCP server with it.
type HarnessAdapter struct {
NewOutput func() HarnessOutput
MCPConfig []string
}
var harnessAdapters = map[string]HarnessAdapter{
AdapterClaudeCode: {
NewOutput: func() HarnessOutput { return newClaudeCodeHarnessOutput() },
MCPConfig: []string{"--mcp-config", mcpConfigPlaceholder},
},
// Codex takes MCP servers only as inline -c overrides, and Pi and OMP
// read no MCP config file of this shape, so their stages serve no
// capture tools.
AdapterCodex: {NewOutput: func() HarnessOutput { return &codexHarnessOutput{} }},
AdapterPi: {NewOutput: func() HarnessOutput { return &piHarnessOutput{} }},
AdapterOMP: {NewOutput: func() HarnessOutput { return &piHarnessOutput{} }},
AdapterCopilot: {
NewOutput: func() HarnessOutput { return newCopilotHarnessOutput() },
MCPConfig: []string{"--additional-mcp-config", "@" + mcpConfigPlaceholder},
},
}
// LookupHarnessAdapter returns the named adapter. The empty name is a CLI
// with no adapter: it reports nothing and serves no capture tools.
func LookupHarnessAdapter(name string) (HarnessAdapter, bool) {
a, ok := harnessAdapters[name]
return a, ok
}
// HarnessStages runs every stage of a task on one harness: a Kit task's
// container is built from its harness, so no stage in it runs anywhere else.
type HarnessStages struct {
Runner agentrun.Runner
Spec agentrun.HarnessSpec
}
func (r HarnessStages) Run(ctx context.Context, workspace string, req agentrun.Request, report agentrun.ToolCallReporter) (agentrun.Result, error) {
spec := r.Spec
req.Harness = &spec
return r.Runner.Run(ctx, workspace, req, report)
}