acpmock

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 26, 2026 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const FixtureVersion = 2
View Source
const ProviderName = "acpmock"

ProviderName is the auth-free local provider used by fixture-backed ACP mocks.

Variables

This section is empty.

Functions

func BuildCommand

func BuildCommand(driverPath string, fixturePath string, fixtureAgent string, diagnosticsPath string) string

BuildCommand renders the test-only ACP driver command string stored in AGENT.md.

func DefaultDriverPath

func DefaultDriverPath() (string, error)

DefaultDriverPath resolves or builds the test-only ACP mock driver binary.

func ProviderConfig

func ProviderConfig(command ...string) aghconfig.ProviderConfig

ProviderConfig returns the local auth-free provider config for ACP mock agents.

func RequireDriver

func RequireDriver(t testing.TB) string

RequireDriver resolves the ACP mock driver binary or fails the current test.

Types

type AgentFixture

type AgentFixture struct {
	Name          string                       `json:"name"`
	Provider      string                       `json:"provider"`
	Model         string                       `json:"model,omitempty"`
	Permissions   string                       `json:"permissions,omitempty"`
	Prompt        string                       `json:"prompt,omitempty"`
	ConfigOptions []SessionConfigOptionFixture `json:"config_options,omitempty"`
	Turns         []TurnFixture                `json:"turns"`
}

AgentFixture describes one named ACP mock agent inside a fixture file.

func (AgentFixture) SelectTurn

func (a AgentFixture) SelectTurn(prompt string, occurrence int, meta ...acp.PromptMeta) (TurnFixture, error)

SelectTurn returns the first turn that matches the supplied prompt occurrence.

func (AgentFixture) Validate

func (a AgentFixture) Validate(path string) error

Validate ensures the agent fixture is usable.

type DiagnosticsRecord

type DiagnosticsRecord struct {
	AgentName      string             `json:"agent_name"`
	SessionID      string             `json:"session_id"`
	LifecycleEvent string             `json:"lifecycle_event,omitempty"`
	MCPServers     []acpsdk.McpServer `json:"mcp_servers,omitempty"`
	PromptIndex    int                `json:"prompt_index"`
	Prompt         string             `json:"prompt"`
	PromptMeta     acp.PromptMeta     `json:"prompt_meta"`
	TurnName       string             `json:"turn_name,omitempty"`
	Match          TurnMatch          `json:"match"`
	Steps          []DiagnosticsStep  `json:"steps"`
}

DiagnosticsRecord captures one prompt execution emitted by the ACP mock driver.

func PromptDiagnostics

func PromptDiagnostics(records []DiagnosticsRecord) []DiagnosticsRecord

PromptDiagnostics returns diagnostics emitted for prompt execution turns only.

func ReadDiagnostics

func ReadDiagnostics(path string) ([]DiagnosticsRecord, error)

ReadDiagnostics decodes newline-delimited diagnostics written by the mock driver.

type DiagnosticsStep

type DiagnosticsStep struct {
	Kind         StepKind            `json:"kind"`
	Text         string              `json:"text,omitempty"`
	ToolCallID   string              `json:"tool_call_id,omitempty"`
	Decision     string              `json:"decision,omitempty"`
	Command      string              `json:"command,omitempty"`
	Args         []string            `json:"args,omitempty"`
	ExitCode     *int                `json:"exit_code,omitempty"`
	Output       string              `json:"output,omitempty"`
	Error        string              `json:"error,omitempty"`
	DriverAction DriverControlAction `json:"driver_action,omitempty"`
}

DiagnosticsStep captures one executed fixture step with any observed runtime outputs.

type DriverControlAction

type DriverControlAction string

DriverControlAction identifies one supported driver fault injection action.

const (
	DriverControlDisconnect       DriverControlAction = "disconnect"
	DriverControlWriteRawJSONRPC  DriverControlAction = "write_raw_jsonrpc"
	DriverControlBlockUntilCancel DriverControlAction = "block_until_cancel"
)

type DriverControlStep

type DriverControlStep struct {
	Action     DriverControlAction `json:"action"`
	RawJSONRPC string              `json:"raw_jsonrpc,omitempty"`
	Async      bool                `json:"async,omitempty"`
	DelayMS    int                 `json:"delay_ms,omitempty"`
}

DriverControlStep injects driver-level protocol or lifecycle faults.

func (DriverControlStep) Validate

func (d DriverControlStep) Validate(path string) error

Validate ensures the driver-control payload is internally consistent.

type Fixture

type Fixture struct {
	Version int            `json:"version"`
	Agents  []AgentFixture `json:"agents"`
}

Fixture describes one deterministic multi-agent ACP mock scenario.

func LoadFixture

func LoadFixture(path string) (Fixture, error)

LoadFixture parses and validates one fixture file.

func ParseFixture

func ParseFixture(data []byte) (Fixture, error)

ParseFixture decodes and validates fixture JSON.

func (Fixture) Agent

func (f Fixture) Agent(name string) (AgentFixture, error)

Agent returns one named fixture agent.

func (Fixture) Validate

func (f Fixture) Validate() error

Validate ensures the fixture can drive deterministic ACP scenarios.

type RegisterOptions

type RegisterOptions struct {
	FixturePath     string
	FixtureAgent    string
	AgentName       string
	ProviderName    string
	DriverPath      string
	DiagnosticsPath string
}

RegisterOptions describes one temporary fixture-backed AGENT.md registration.

type Registration

type Registration struct {
	AgentName       string
	FixtureAgent    string
	FixturePath     string
	DriverPath      string
	DiagnosticsPath string
	AgentDefPath    string
	Command         string
	Provider        string
	Model           string
	Permissions     string
}

Registration captures one temporary mock-agent definition written into AGH home.

func Register

func Register(homePaths aghconfig.HomePaths, opts RegisterOptions) (Registration, error)

Register writes one temporary fixture-backed AGENT.md file into the supplied AGH home.

type SessionConfigOptionFixture

type SessionConfigOptionFixture struct {
	ID      string                            `json:"id"`
	Name    string                            `json:"name"`
	Current string                            `json:"current"`
	Values  []SessionConfigOptionValueFixture `json:"values"`
}

SessionConfigOptionFixture describes one deterministic ACP session config select option.

func (SessionConfigOptionFixture) Validate

func (o SessionConfigOptionFixture) Validate(path string) error

Validate ensures one session config option is deterministic and selectable.

type SessionConfigOptionValueFixture

type SessionConfigOptionValueFixture struct {
	Value string `json:"value"`
	Label string `json:"label,omitempty"`
}

SessionConfigOptionValueFixture describes one selectable ACP config option value.

type Step

type Step struct {
	Kind StepKind `json:"kind"`

	Text   string   `json:"text,omitempty"`
	Chunks []string `json:"chunks,omitempty"`

	ToolCallID  string          `json:"tool_call_id,omitempty"`
	Title       string          `json:"title,omitempty"`
	ToolKind    string          `json:"tool_kind,omitempty"`
	Path        string          `json:"path,omitempty"`
	Status      string          `json:"status,omitempty"`
	ContentText string          `json:"content_text,omitempty"`
	RawInput    json.RawMessage `json:"raw_input,omitempty"`
	RawOutput   json.RawMessage `json:"raw_output,omitempty"`

	ExpectDecision string `json:"expect_decision,omitempty"`
	EmitDecision   bool   `json:"emit_decision,omitempty"`
	EmitText       string `json:"emit_text,omitempty"`

	Command              string             `json:"command,omitempty"`
	Args                 []string           `json:"args,omitempty"`
	Cwd                  string             `json:"cwd,omitempty"`
	ExpectExitCode       *int               `json:"expect_exit_code,omitempty"`
	ExpectOutputContains string             `json:"expect_output_contains,omitempty"`
	ExpectErrorContains  string             `json:"expect_error_contains,omitempty"`
	EmitOutput           bool               `json:"emit_output,omitempty"`
	DriverControl        *DriverControlStep `json:"driver_control,omitempty"`
}

Step describes one deterministic ACP action emitted or executed by the driver.

func (Step) Validate

func (s Step) Validate(path string) error

Validate ensures the step kind and payload are internally consistent.

type StepKind

type StepKind string
const (
	StepKindAssistant     StepKind = "assistant"
	StepKindThought       StepKind = "thought"
	StepKindToolCall      StepKind = "tool_call"
	StepKindPermission    StepKind = "permission"
	StepKindSandbox       StepKind = "sandbox_exec"
	StepKindBridgeContent StepKind = "bridge_response"
	StepKindDriverControl StepKind = "driver_control"
)

type TurnFixture

type TurnFixture struct {
	Name       string    `json:"name,omitempty"`
	Match      TurnMatch `json:"match"`
	Steps      []Step    `json:"steps"`
	StopReason string    `json:"stop_reason,omitempty"`
}

TurnFixture describes one deterministic prompt turn for an agent.

func (TurnFixture) Validate

func (t TurnFixture) Validate(path string) error

Validate ensures the turn fixture is usable.

type TurnMatch

type TurnMatch struct {
	TurnSource string            `json:"turn_source,omitempty"`
	UserText   string            `json:"user_text,omitempty"`
	Occurrence int               `json:"occurrence,omitempty"`
	Network    *TurnMatchNetwork `json:"network,omitempty"`
}

TurnMatch routes a prompt to a turn fixture using exact stable fields only.

func (TurnMatch) Normalize

func (m TurnMatch) Normalize() TurnMatch

Normalize returns a trimmed copy of the turn matcher.

func (TurnMatch) Validate

func (m TurnMatch) Validate(path string) error

Validate ensures the turn match contains only supported exact selectors.

type TurnMatchNetwork

type TurnMatchNetwork struct {
	MessageID   string `json:"message_id,omitempty"`
	Kind        string `json:"kind,omitempty"`
	Channel     string `json:"channel,omitempty"`
	Surface     string `json:"surface,omitempty"`
	ThreadID    string `json:"thread_id,omitempty"`
	DirectID    string `json:"direct_id,omitempty"`
	From        string `json:"from,omitempty"`
	To          string `json:"to,omitempty"`
	WorkID      string `json:"work_id,omitempty"`
	ReplyTo     string `json:"reply_to,omitempty"`
	TraceID     string `json:"trace_id,omitempty"`
	CausationID string `json:"causation_id,omitempty"`
	Trust       string `json:"trust,omitempty"`
}

TurnMatchNetwork captures exact AGH network envelope field matching.

func (TurnMatchNetwork) IsZero

func (m TurnMatchNetwork) IsZero() bool

IsZero reports whether the network matcher carries any fields.

func (TurnMatchNetwork) Normalize

func (m TurnMatchNetwork) Normalize() TurnMatchNetwork

Normalize returns a trimmed copy of the network matcher.

func (TurnMatchNetwork) Validate

func (m TurnMatchNetwork) Validate(path string) error

Validate ensures only exact-match network selectors are configured.

Directories

Path Synopsis
cmd
acpmock-driver command

Jump to

Keyboard shortcuts

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