agentdispatch

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// AgentCodex is the Codex dispatch target and caller marker value.
	AgentCodex = "codex"
	// AgentClaude is the Claude dispatch target and caller marker value.
	AgentClaude = "claude"
	// AgentAntigravity is the Antigravity dispatch target and caller marker value.
	AgentAntigravity = "antigravity"
	// AgentRandom is the resolver value that selects an eligible target at random.
	AgentRandom = "random"
)
View Source
const (
	// ExitUsage is the stable dispatch usage/resolution failure exit code.
	ExitUsage = 64
	// ExitConfig is the stable dispatch configuration/state failure exit code.
	ExitConfig = 65
	// ExitUnavailable is the stable dispatch target-unavailable exit code.
	ExitUnavailable = 69
	// ExitTargetFailure is the stable dispatch target/adapter failure exit code.
	ExitTargetFailure = 70
	// ExitNested is the stable dispatch nested-call failure exit code.
	ExitNested = 75
	// ExitSigint is the stable dispatch SIGINT exit code.
	ExitSigint = 130
	// ExitSigterm is the stable dispatch SIGTERM exit code.
	ExitSigterm = 143
)
View Source
const AntigravityPrintTimeout = "24h"

AntigravityPrintTimeout is the print-mode timeout used for dispatch. The value and required space-separated flag form come from the 2026-05-22 local `agy --help` and print-mode probe recorded in .agent-layer/tmp/agent-dispatch-design.md.

View Source
const AntigravityPromptMaxBytes = 100 * 1024

AntigravityPromptMaxBytes caps the prompt size for the Antigravity adapter. agy --print accepts the prompt only as an argv element (no stdin/file path exists today), which is subject to the OS ARG_MAX limit (~128 KB Linux / ~256 KB macOS). 100 KB is well below both caps and leaves headroom for the other argv elements; oversize prompts fail fast with ExitUsage rather than surfacing as an opaque execve failure.

View Source
const MaxStdinPromptBytes = 10 * 1024 * 1024

MaxStdinPromptBytes caps stdin reads when resolving the dispatch prompt so a runaway producer cannot exhaust process memory. 10 MiB is well above any realistic agent prompt and below typical container memory budgets.

Variables

This section is empty.

Functions

func BuildChildPrompt

func BuildChildPrompt(project *config.ProjectConfig, target string, prompt string, skill string) ([]byte, error)

BuildChildPrompt validates the optional skill and returns exact target-native prompt bytes for the selected target.

func ResolvePrompt

func ResolvePrompt(args []string, stdin io.Reader, readStdin bool) (string, error)

ResolvePrompt returns the caller prompt. Positional args win over piped stdin.

func Run

func Run(opts RunOptions) error

Run executes one Agent Dispatch target according to the v1 dispatch contract.

func WriteOptions

func WriteOptions(req OptionsRequest) error

WriteOptions renders options as JSON or human-readable text.

Types

type CallerInfo

type CallerInfo struct {
	Known bool   `json:"known"`
	Agent string `json:"agent,omitempty"`
}

CallerInfo describes env-only dispatch caller detection.

type CommandFactory

type CommandFactory func(name string, args ...string) *exec.Cmd

CommandFactory creates a command for a target adapter.

type ExitError

type ExitError struct {
	Code    int
	Message string
	Err     error
}

ExitError carries a dispatch-owned exit category and the message already written or intended for stderr by the CLI wrapper.

func (*ExitError) Error

func (e *ExitError) Error() string

Error returns the user-facing dispatch error text.

func (*ExitError) Unwrap

func (e *ExitError) Unwrap() error

Unwrap returns the wrapped lower-level error.

type FieldOption

type FieldOption struct {
	OverrideSupported bool     `json:"override_supported"`
	Configured        string   `json:"configured"`
	Suggestions       []string `json:"suggestions"`
	AllowCustom       bool     `json:"allow_custom"`
}

FieldOption describes dispatch override metadata for one target field.

type OptionsRequest

type OptionsRequest struct {
	Root     string
	Env      []string
	Stdout   io.Writer
	JSON     bool
	LookPath func(string) (string, error)
}

OptionsRequest configures an Agent Dispatch options response.

type OptionsResponse

type OptionsResponse struct {
	Caller  CallerInfo     `json:"caller"`
	Random  RandomInfo     `json:"random"`
	Targets []TargetOption `json:"targets"`
}

OptionsResponse is the stable v1 machine-readable Agent Dispatch options shape.

func BuildOptions

func BuildOptions(req OptionsRequest) (*OptionsResponse, error)

BuildOptions loads strict project config and builds the v1 options response.

type RandomChooser

type RandomChooser func([]string) (string, error)

RandomChooser selects one target from an already-built random pool.

type RandomInfo

type RandomInfo struct {
	Pool           []string `json:"pool"`
	ExcludesCaller bool     `json:"excludes_caller"`
	Empty          bool     `json:"empty"`
}

RandomInfo describes the current random-selection pool.

type RunOptions

type RunOptions struct {
	Root            string
	Agent           string
	Model           string
	ReasoningEffort string
	Skill           string
	PromptArgs      []string
	Stdin           io.Reader
	ReadStdin       bool
	Stdout          io.Writer
	Stderr          io.Writer
	Env             []string
	Quiet           bool
	LookPath        func(string) (string, error)
	NewCommand      CommandFactory
	ChooseRandom    RandomChooser
}

RunOptions configures a single dispatch run.

type StreamingOption

type StreamingOption struct {
	AnswerText string `json:"answer_text"`
	Progress   string `json:"progress"`
}

StreamingOption describes target output streaming capability.

type TargetOption

type TargetOption struct {
	Agent                 string          `json:"agent"`
	Enabled               bool            `json:"enabled"`
	Installed             bool            `json:"installed"`
	DispatchCapable       bool            `json:"dispatch_capable"`
	RandomEligible        bool            `json:"random_eligible"`
	RandomExclusionReason *string         `json:"random_exclusion_reason"`
	Streaming             StreamingOption `json:"streaming"`
	Model                 FieldOption     `json:"model"`
	ReasoningEffort       FieldOption     `json:"reasoning_effort"`
	UnavailableReasons    []string        `json:"unavailable_reasons"`
}

TargetOption describes one dispatch target in the options response.

Jump to

Keyboard shortcuts

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