wrap

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2026 License: Apache-2.0 Imports: 14 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 wrap implements `squoze wrap CMD`: run an agent command with its provider base URLs pointed at an in-process squoze proxy. The agent needs zero configuration — env injection is the whole trick.

Index

Constants

This section is empty.

Variables

View Source
var BaseURLEnvs = []string{
	"ANTHROPIC_BASE_URL",
	"OPENAI_BASE_URL",
	"OPENAI_API_BASE",
}

BaseURLEnvs lists the environment variables agents commonly honor for provider endpoints. Setting all of them covers Claude Code, OpenAI SDKs, Codex and most OpenAI-compatible clients.

Functions

func EnvVars

func EnvVars(addr string) []string

EnvVars returns KEY=VALUE entries pointing at addr.

func ExitCode added in v0.1.2

func ExitCode(err error) int

ExitCode extracts the child exit code from a Run error (0 when none).

func Run

func Run(ctx context.Context, opts Options) error

Run starts the proxy (single upstream or a per-provider listener farm), launches the command with injected environment, streams stdio, and waits. Returns the command's exit error (if any).

Types

type ExitError added in v0.1.2

type ExitError struct{ Code int }

ExitError carries the child's exit code through Run's error return so callers can re-exit with the same code (after running their own cleanup).

func (*ExitError) Error added in v0.1.2

func (e *ExitError) Error() string

type Options

type Options struct {
	Command     []string // argv of the agent to run (required)
	Upstream    *url.URL // real provider base URL (required)
	OriginsDir  string   // "" = memory-only originals
	ListenAddr  string   // default "127.0.0.1:0" (ephemeral)
	LogFile     string   // "" = no request log; else append JSONL per request
	BaseURLEnvs []string // override the injected endpoint env names (harness presets)
	Stdin       io.Reader
	Stdout      io.Writer
	Stderr      io.Writer
	OnExit      func() // runs after the child exits, before Run returns
	// Upstreams enables multi-provider mode: one local listener per entry
	// (addr → real provider URL). Overrides Upstream; used by `sq <agent>`
	// so every wired provider keeps its own port and original endpoint.
	Upstreams map[string]string
}

Options configures one wrap session.

Jump to

Keyboard shortcuts

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