provider

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 6 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package provider is the pure logic behind brokered claude runners: which gateway environment a model provider (anthropic, bedrock, vertex, foundry) needs in the agent pod, and how canonical model ids translate to the provider-specific ids the claude CLI's --model flag expects there.

Canonical ids ("anthropic/claude-sonnet-5") stay canonical everywhere controller-side — CRDs, allowlists, pricing; translation happens in-pod at agentrun's cliModel, fed by the PATCHY_MODEL_MAP this package renders. The per-provider derived defaults (Bedrock's region-prefixed ids, Vertex's bare ids) mean operators only write a model map for Foundry, whose deployment names cannot be derived, or to override a default.

Index

Constants

View Source
const (
	Anthropic = "anthropic"
	Bedrock   = "bedrock"
	Vertex    = "vertex"
	Foundry   = "foundry"
)

Provider names — the model APIs a brokered claude runner can front.

View Source
const BrokerTokenHeader = "X-Patchy-Broker-Token"

BrokerTokenHeader carries the agent pod's projected ServiceAccount token to the egress broker; the broker validates it via TokenReview and strips it before any byte is forwarded upstream. Defined here — the one package both the in-pod runtime and the broker import — so the two sides can never drift.

Variables

View Source
var GatewayEnvNames = []string{
	"ANTHROPIC_BASE_URL",
	"ANTHROPIC_BEDROCK_BASE_URL",
	"ANTHROPIC_VERTEX_BASE_URL",
	"ANTHROPIC_FOUNDRY_BASE_URL",
	"CLAUDE_CODE_USE_BEDROCK",
	"CLAUDE_CODE_USE_VERTEX",
	"CLAUDE_CODE_USE_FOUNDRY",
	"CLAUDE_CODE_SKIP_BEDROCK_AUTH",
	"CLAUDE_CODE_SKIP_VERTEX_AUTH",
	"CLAUDE_CODE_SKIP_FOUNDRY_AUTH",
	"CLAUDE_CODE_DISABLE_NONESSENTIAL_TRAFFIC",
	"ANTHROPIC_CUSTOM_HEADERS",
	"ANTHROPIC_VERTEX_PROJECT_ID",
	"CLOUD_ML_REGION",
	"AWS_REGION",
	"PATCHY_BROKER_TOKEN_FILE",
	"PATCHY_MODEL_MAP",
}

GatewayEnvNames are the agent-pod env names this package owns. internal/jobs reserves all of them so controller-global env can never shadow a gateway value, and ExtraEnv may not name them either.

Names lists the valid provider names, in display order.

Functions

func EffectiveModelMap

func EffectiveModelMap(c Config, models []model.Model) (map[string]string, error)

EffectiveModelMap resolves the canonical→CLI-id map the pod translates with: a derived default per registry model the claude harness can run, overridden by the operator's entries. Anthropic needs no translation (the registry already carries claude's ids) and foundry has no derivable defaults, so both return cfg.ModelMap exactly.

func Env

func Env(c Config, modelMap map[string]string) map[string]string

Env renders the agent-pod gateway environment for the provider: the base-URL override pointing the claude CLI at the broker's provider route, the skip-auth switches (the broker owns the credential), the provider's own context vars, the rendered model map, and the ExtraEnv passthrough. modelMap is the effective canonical→CLI-id map (EffectiveModelMap).

func FormatModelMap

func FormatModelMap(m map[string]string) string

FormatModelMap renders a model map as the PATCHY_MODEL_MAP wire form: comma-joined canonical=cliID pairs, sorted for determinism.

func ParseModelMap

func ParseModelMap(s string) (map[string]string, error)

ParseModelMap parses the PATCHY_MODEL_MAP wire form back into a map. It is the single codec both sides share; a malformed entry is an error, not a silently dropped translation.

func ValidateCoverage

func ValidateCoverage(c Config, models []model.Model, modelMap map[string]string, required []string) error

ValidateCoverage fails when a required canonical model (allowlist entries, stage defaults) that the claude harness would run has no entry in the effective map. Only foundry can under-cover — its map is entirely operator-written — but the check is provider-agnostic so a future gap surfaces at startup rather than mid-run.

Types

type Config

type Config struct {
	// Name is the provider: anthropic, bedrock, vertex, or foundry.
	Name string
	// BrokerURL is the egress broker's base URL; the per-provider route
	// (/anthropic, /bedrock, ...) is appended. Required always — brokered is
	// the only mode a claude runner has.
	BrokerURL string
	// Region is the provider region: required for bedrock (SigV4 scope and
	// the AWS_REGION the CLI sends) and vertex (CLOUD_ML_REGION).
	Region string
	// RegionPrefix overrides the Bedrock inference-profile prefix derived
	// from Region (us/eu/apac) for regions the derivation cannot cover.
	RegionPrefix string
	// ProjectID is the GCP project Vertex requests bill to; vertex only.
	ProjectID string
	// ModelMap maps canonical model ids to provider-specific CLI ids,
	// overriding the derived defaults. Foundry has no derivable defaults
	// (deployment names are operator-chosen), so there it is the whole map.
	ModelMap map[string]string
	// ExtraEnv is operator passthrough into the agent pod's gateway env.
	// Credential-named and patchy-owned keys are rejected.
	ExtraEnv map[string]string
}

Config describes one brokered claude runner's model provider.

func (Config) Validate

func (c Config) Validate() error

Validate rejects a config the gateway env cannot be built from.

Jump to

Keyboard shortcuts

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