Documentation
¶
Overview ¶
Agent-level presets: the coding agents themselves (as opposed to raw providers). Env-driven agents reuse the provider presets via wrap; config-file agents (opencode, omp) get generated snippets plus a running proxy, because their endpoint lives in a config file, not the environment.
Package harness maps AI coding harnesses to their provider base-URL environment variables and default upstreams, so `squoze harness <name>` wires any of them through the proxy with zero guesswork.
The subtle part each preset encodes: upstream defaults are chosen so that ReverseProxy path-joining produces correct endpoints (e.g. Fireworks wants /inference/v1/chat/completions — so its default carries no trailing /v1; clients add it).
Automatic config wiring for config-file agents. Every write is preceded by a one-time backup (<file>.squoze-bak) and can be reverted with Unwire*, which restores that backup.
Honest limitation: opencode.jsonc files containing comments are NOT auto-edited (strict JSON only) — the caller falls back to printing the snippet for a manual paste.
Index ¶
- Constants
- Variables
- func AgentNames() []string
- func Names() []string
- func OMPModelsPath(home string) string
- func OMPSnippet(providerID, addr, apiKeyEnv string) string
- func OpenCodeConfigPath(home string) (string, bool)
- func OpenCodeProviderIDs(home string) []string
- func OpenCodeSnippet(providerID, addr string) string
- func UnwireOMP(home string) (string, bool, error)
- func UnwireOpenCode(home string) (string, bool, error)
- func WireOMP(home, providerID, addr, apiKeyEnv string) (string, bool, error)
- func WireOpenCode(home, providerID, addr string) (string, bool, error)
- type Agent
- type Preset
- type WiredProvider
Constants ¶
const UpstreamHeader = "X-Squoze-Upstream"
UpstreamHeader is the request header carrying a per-request original provider URL (multi-provider transparent routing). The proxy consumes it and strips it before egress.
Variables ¶
var CatalogDefaults = map[string]string{
"anthropic": "https://api.anthropic.com",
"openai": "https://api.openai.com/v1",
"google": "https://generativelanguage.googleapis.com/v1beta",
"openrouter": "https://openrouter.ai/api/v1",
"groq": "https://api.groq.com/openai/v1",
"mistral": "https://api.mistral.ai/v1",
"xai": "https://api.x.ai/v1",
"deepseek": "https://api.deepseek.com",
"fireworks": "https://api.fireworks.ai/inference/v1",
"together": "https://api.together.xyz/v1",
}
CatalogDefaults maps well-known opencode catalog provider IDs to their original API roots. Providers WITHOUT an explicit baseURL in the user's config use these as the capture source for the routing header (source of truth: models.dev catalog; extend as needed).
Functions ¶
func OMPModelsPath ¶
OMPModelsPath is the canonical omp custom-provider file.
func OMPSnippet ¶
OMPSnippet renders the ~/.omp/agent/models.yml override-only entry that reroutes an existing catalog provider through the local proxy. An entry without `models` patches the built-in provider in place; apiKey accepts an env-var NAME, so the real key never lands in the file. disableStrictTools matches Anthropic-compatible endpoints that reject strict tool-schema markers.
func OpenCodeConfigPath ¶
OpenCodeConfigPath returns the active global opencode config path and whether it already exists. Prefers .json over .jsonc (see package docs).
func OpenCodeProviderIDs ¶
OpenCodeProviderIDs lists provider IDs present in the home config, so the CLI can wire the one the user actually uses (not just "anthropic").
func OpenCodeSnippet ¶
OpenCodeSnippet renders the opencode.json override that points an existing built-in provider through the local squoze proxy. Overriding a built-in provider (instead of adding a custom @ai-sdk/openai-compatible one) avoids the known options-drop bug (anomalyco/opencode#5674).
func UnwireOpenCode ¶
UnwireOpenCode restores the pre-wire backup of the opencode config.
func WireOMP ¶
WireOMP writes an override-only entry routing providerID through the local proxy, merging into any existing models.yml via yaml.Node so comments and formatting survive. apiKeyEnv names an env var so the real key never lands in the file.
func WireOpenCode ¶
WireOpenCode points providerID's built-in provider entry at addr inside the home directory's opencode config. Creates the file when missing. The original baseURL's path suffix (e.g. "/v1", "/api") is preserved — only the host:port is redirected. Returns the path and whether changed.
Types ¶
type Agent ¶
type Agent struct {
Name string
Aliases []string
// Preset is the provider preset used for env injection / defaults.
// Empty for config-file agents that wire themselves.
Preset string
// Launch is the typical command that starts the agent.
Launch string
// Kind selects the wiring strategy: env agents get base-URL injection,
// config agents get their config file patched automatically.
Kind string // "env" | "opencode" | "omp"
}
Agent describes one supported coding agent.
func LookupAgent ¶
LookupAgent resolves an agent by name or alias.
type Preset ¶
type Preset struct {
Name string // canonical name used on the command line
Aliases []string // accepted alternative names
BaseURLEnvs []string // env vars the harness reads for the endpoint
DefaultUpstream string // provider root when --upstream is omitted
}
Preset describes one supported harness/provider family.
type WiredProvider ¶
type WiredProvider struct {
ID string
Addr string // "localhost:PORT" the agent now points at
Original string // real provider URL the proxy must forward to
}
WiredProvider is one provider wired by WireOpenCodeAll.
func WireOpenCodeAll ¶
func WireOpenCodeAll(home string, portBase int) (path string, wired []WiredProvider, skipped map[string]string, err error)
WireOpenCodeAll wires EVERY provider the agent can use: those present in the config plus the well-known catalog set (CatalogDefaults). Each wired provider gets its OWN local port with a static upstream — custom @ai-sdk/openai-compatible providers drop options.headers (opencode#5674), so header-based routing is not reliable for them; dedicated ports work for every provider kind. portBase is the first port; subsequent providers get portBase+1, +2, ... Unknown providers without a baseURL and not in the table are reported in skipped.