executor

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package executor runs prompts against Hydra Heads. Two strategies: CLI (subprocess) and HTTP (OpenAI-compatible REST).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Supports

func Supports(h provider.Head) bool

Supports reports whether Hydra can execute a discovered head today.

func SupportsHTTP

func SupportsHTTP(h provider.Head) bool

SupportsHTTP reports whether Hydra can execute the head over HTTP today.

func Unroutable added in v1.1.0

func Unroutable(h provider.Head) string

Unroutable explains why a discovered head cannot be dispatched to, or returns "" when it can.

This is the primary check and Supports delegates to it, so a surface that lists heads and a surface that routes to them cannot disagree. They did: `hyctl probe` advertised the PATH-discovered Ollama binary while `hyctl dispatch --local` refused and told the user to go look at `hyctl probe` (#248). Discovery finding a head and Hydra being able to drive it are different questions, and only one function should answer the second.

Types

type AgyExecutor

type AgyExecutor struct{}

AgyExecutor invokes `agy --print` with model selection via settings.json swap. Ports all logic from dispatch/agy.sh natively in Go.

func (*AgyExecutor) Execute

func (e *AgyExecutor) Execute(ctx context.Context, req Request) (*Response, error)

type AuthRequiredError

type AuthRequiredError struct {
	ModelFlag string
	Pool      string
	AuthURL   string
}

AuthRequiredError is returned when agy signals that authentication is needed.

func (*AuthRequiredError) Error

func (e *AuthRequiredError) Error() string

type CLIExecutor

type CLIExecutor struct{}

CLIExecutor runs a prompt via a subprocess CLI tool.

func (*CLIExecutor) Execute

func (e *CLIExecutor) Execute(ctx context.Context, req Request) (*Response, error)

type Executor

type Executor interface {
	Execute(ctx context.Context, req Request) (*Response, error)
}

Executor runs a prompt and returns a response.

func For

func For(h provider.Head) Executor

For selects the correct Executor for a given Head.

  • registry source (agy tiers): AgyExecutor → native (execs the `agy` binary)
  • ollama source: OllamaExecutor → native /api/generate
  • env source / port source / explicit endpoint: HTTPExecutor → per-provider REST
  • everything else: CLIExecutor → subprocess

env-key heads (Source=="env") carry no Executable — they are API providers (anthropic, openai, groq, …). HTTPExecutor.Execute dispatches on Head.Provider and already has an adapter for each, so env heads route to HTTP, not CLI.

type HTTPExecutor

type HTTPExecutor struct {
	// contains filtered or unexported fields
}

HTTPExecutor runs prompts against HTTP-based providers.

func (*HTTPExecutor) Execute

func (e *HTTPExecutor) Execute(ctx context.Context, req Request) (*Response, error)

type OllamaExecutor

type OllamaExecutor struct {
	// contains filtered or unexported fields
}

OllamaExecutor calls the Ollama native /api/generate endpoint. Before dispatching it health-checks the server and attempts auto-start. Ports dispatch/ollama.sh natively in Go.

func (*OllamaExecutor) Execute

func (e *OllamaExecutor) Execute(ctx context.Context, req Request) (*Response, error)

type Request

type Request struct {
	Prompt    string
	Head      provider.Head
	MaxTokens int    // 0 = provider default
	System    string // optional system prompt
}

Request is everything needed to execute a prompt against a Head.

type Response

type Response struct {
	Output       string
	InputTokens  int
	OutputTokens int
	Duration     time.Duration
	Model        string
	Truncated    bool // true when output exceeded the accumulator cap

	// TokensEstimated is true when InputTokens/OutputTokens were derived by
	// Hydra (e.g. agy's char/4 heuristic) rather than reported by the provider.
	// HTTP and Ollama executors parse real usage and leave this false; the agy
	// executor sets it true. Consumers must not present estimated tokens as
	// measured spend.
	TokensEstimated bool
}

Response is the result of a successful execution.

Jump to

Keyboard shortcuts

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