Documentation
¶
Overview ¶
Package goose implements agent.Adapter against Block's `goose` CLI (the `goose run` non-interactive subcommand). It mirrors agent/droid; the agent package itself stays import-free of harness specifics.
Capabilities().NativeSchema is FALSE: goose's native typed-output path (recipe final_output) is ignored by the claude-code provider. The adapter runs `goose run -q --output-format stream-json --no-session`, concatenates the assistant text deltas, parses a JSON object out of the reassembled final text into a map, and the engine re-validates it against output_schema (engine/schema.go ValidateOutputMap). This is the spec §4.2 layer-2 path (conformance Bucket 15).
Gate independence is structural: every Launch passes --no-session and never a resume/name/session-id/path/fork/interactive flag; ValidateConfig rejects the corresponding with-keys.
Index ¶
- Constants
- Variables
- type Adapter
- func (*Adapter) Capabilities() agent.Caps
- func (a *Adapter) Launch(ctx context.Context, handle container.Handle, inv agent.AgentInvocation) (<-chan agent.AgentEvent, <-chan agent.AgentOutcome, error)
- func (*Adapter) Ref() string
- func (*Adapter) RequiredEnv() []string
- func (a *Adapter) ValidateConfig(with ir.RawConfig) error
- func (a *Adapter) Version(ctx context.Context, handle container.Handle) (string, error)
- type ErrMissingAPIKey
- type ErrRuntimeNotFound
- type ErrSessionReuseAttempted
- type ErrStreamParse
- type ErrUnexpectedExit
- type Option
Constants ¶
const AdapterRef = "block/goose"
AdapterRef must match the workflow `uses:` literal byte-for-byte.
Variables ¶
var DefaultEnvAllowlist = []string{"GOOSE_PROVIDER", "GOOSE_MODEL", "ANTHROPIC_API_KEY", "OPENAI_API_KEY"}
DefaultEnvAllowlist — env names the goose adapter reads. Single source of truth for the CLI --agent-env default and resume's implicit allowlist. The forced opsec knobs (GOOSE_MODE, GOOSE_DISABLE_KEYRING, GOOSE_TELEMETRY_ENABLED, XDG_*) are INJECTED by Launch, not allowlisted. ANTHROPIC_API_KEY overlaps claude's allowlist → defaultAgentEnv dedups (see cli/agent_registry.go).
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter is the agent.Adapter implementation for Block goose. One Adapter per CLI invocation; multiple Launch calls per Adapter; all state read-only after construction (no session state crosses Launch boundaries).
func (*Adapter) Capabilities ¶
Capabilities returns Caps{NativeSchema: false} — goose structures output via the layer-2 path; the engine validates conformance.
func (*Adapter) Launch ¶
func (a *Adapter) Launch(ctx context.Context, handle container.Handle, inv agent.AgentInvocation) (<-chan agent.AgentEvent, <-chan agent.AgentOutcome, error)
Launch runs `goose run -q --output-format stream-json --no-session ...` inside handle via the streaming Backend.Exec. goose's stream-json emits NDJSON flushed LIVE: "message" deltas (assistant text, incremental), then a terminal "complete" or "error". Launch scans those lines and emits ONE AgentEvent per line as it arrives (the realtime tap renders these live), accumulating assistant text deltas into finalText for the output layer-2 path. γ contract: returns IMMEDIATELY with both channels open; events closes BEFORE outcome (defer LIFO); never reuses a session.
func (*Adapter) RequiredEnv ¶
RequiredEnv implements agent.CredentialNamer. Returns the CREDENTIAL env var names goose authenticates with (provider-alternatives). The provider itself is selected by with:provider or the GOOSE_PROVIDER env var (F34: with: provider takes precedence — see resolveProvider); GOOSE_PROVIDER and GOOSE_MODEL are config selectors (not credentials) and are intentionally excluded here. Both names are defined in DefaultEnvAllowlist.
func (*Adapter) ValidateConfig ¶
ValidateConfig enforces goose's with-schema (droid's 5-step order: session-reject → unknown-key → required-prompt → per-key types → provider-conditional auth). Deterministic (sorted keys); runs twice per node.
type ErrMissingAPIKey ¶
ErrMissingAPIKey — ValidateConfig's provider-conditional gate (anthropic/openai) when the resolved provider (with:provider, or else the GOOSE_PROVIDER env — see resolveProvider; F34 gives with:provider precedence) needs a credential that is absent from the adapter env. Provider names which provider resolved so the message doesn't blame GOOSE_PROVIDER when a with:provider was the one that actually selected it.
func (*ErrMissingAPIKey) Error ¶
func (e *ErrMissingAPIKey) Error() string
type ErrRuntimeNotFound ¶
ErrRuntimeNotFound — Version failed.
func (*ErrRuntimeNotFound) Error ¶
func (e *ErrRuntimeNotFound) Error() string
func (*ErrRuntimeNotFound) Unwrap ¶
func (e *ErrRuntimeNotFound) Unwrap() error
type ErrSessionReuseAttempted ¶
type ErrSessionReuseAttempted struct{ Key string }
ErrSessionReuseAttempted — a with-key that would re-use a goose session.
func (*ErrSessionReuseAttempted) Error ¶
func (e *ErrSessionReuseAttempted) Error() string
type ErrStreamParse ¶
ErrStreamParse backs the parse unit tests; Launch tolerates a stray non-JSON line.
func (*ErrStreamParse) Error ¶
func (e *ErrStreamParse) Error() string
func (*ErrStreamParse) Unwrap ¶
func (e *ErrStreamParse) Unwrap() error
type ErrUnexpectedExit ¶
ErrUnexpectedExit is sent (bare) when goose exited with no usable result. Output is the captured STDOUT tail — goose writes diagnostics to stdout; stderr is always empty. The engine default branch maps it to retryable_failure.
func (*ErrUnexpectedExit) Error ¶
func (e *ErrUnexpectedExit) Error() string
type Option ¶
type Option func(*Adapter)
Option configures the Adapter at construction time (functional-options).
func WithBackend ¶
WithBackend supplies the container.Backend used by Version and Launch.
func WithEnv ¶
WithEnv supplies the env-var allowlist forwarded into each `goose run` exec environment. Copied into agent.SecretEnv (redacts under fmt verbs; json:"-" so secrets never reach the state log). Empty map permitted.
func WithPricing ¶
WithPricing injects the pricing.Table used to derive a USD cost from token usage. Tests pass a self-contained fixture table; production leaves it unset so New defaults it to pricing.Default() (embedded rates ⊕ $AWF_PRICING_FILE).