launch

package
v0.14.14 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Overview

Package launch starts a short-lived Vekil proxy and runs an agent CLI against it.

Index

Constants

View Source
const ClaudeAutoModeClassifierModel = "claude-sonnet-5"

ClaudeAutoModeClassifierModel is the model Claude Code's auto mode uses to approve actions. Claude Code refuses Opus 5.5, Sonnet 5.5 and Opus 5 for that role, so a pinned launch keeps Claude Code's Sonnet 5 default.

View Source
const PolicyModelOwner = "vekil-policy"

PolicyModelOwner is the /v1/models owner for policy-routing public IDs.

Variables

View Source
var ErrBinaryNotFound = errors.New("agent binary not found")

ErrBinaryNotFound marks an agent executable lookup failure.

Functions

func AuxiliaryModels added in v0.14.14

func AuxiliaryModels(adapter Adapter) []string

AuxiliaryModels returns the models adapter's agent calls beside the pinned model. A launch proxy admits them only through providers already in scope.

Types

type Adapter

type Adapter interface {
	Name() string
	Prepare(PrepareInput) (PreparedProcess, error)
}

Adapter prepares one supported agent CLI for a Vekil-backed launch.

type ClaudeAdapter

type ClaudeAdapter struct{}

ClaudeAdapter prepares Claude Code to use Vekil's Anthropic-compatible surface without modifying the user's Claude settings.

func (ClaudeAdapter) Name

func (ClaudeAdapter) Name() string

func (ClaudeAdapter) Prepare

func (ClaudeAdapter) Prepare(input PrepareInput) (PreparedProcess, error)

type CodexAdapter

type CodexAdapter struct{}

CodexAdapter prepares OpenAI Codex CLI to use Vekil's Responses API.

func (CodexAdapter) Name

func (CodexAdapter) Name() string

func (CodexAdapter) Prepare

func (CodexAdapter) Prepare(input PrepareInput) (PreparedProcess, error)

type CopilotAdapter

type CopilotAdapter struct{}

CopilotAdapter prepares GitHub Copilot CLI to use Vekil as a BYOK provider.

func (CopilotAdapter) Name

func (CopilotAdapter) Name() string

func (CopilotAdapter) Prepare

type ModelCapabilities

type ModelCapabilities struct {
	Family   string                  `json:"family,omitempty"`
	Limits   ModelCapabilityLimits   `json:"limits,omitempty"`
	Supports ModelCapabilitySupports `json:"supports,omitempty"`
}

ModelCapabilities contains the bounded model metadata launchers can use to configure client-side context, output, reasoning, and tool behavior.

type ModelCapabilityLimits

type ModelCapabilityLimits struct {
	MaxContextWindowTokens int64 `json:"max_context_window_tokens,omitempty"`
	MaxPromptTokens        int64 `json:"max_prompt_tokens,omitempty"`
	MaxPrompt              int64 `json:"max_prompt,omitempty"`
	MaxInputTokens         int64 `json:"max_input_tokens,omitempty"`
	ContextWindow          int64 `json:"context_window,omitempty"`
	ContextWindowTokens    int64 `json:"context_window_tokens,omitempty"`
	MaxOutputTokens        int64 `json:"max_output_tokens,omitempty"`
}

ModelCapabilityLimits contains advertised token limits.

type ModelCapabilitySupports

type ModelCapabilitySupports struct {
	ReasoningEffort   []string `json:"reasoning_effort,omitempty"`
	ParallelToolCalls bool     `json:"parallel_tool_calls,omitempty"`
	Vision            bool     `json:"vision,omitempty"`
}

ModelCapabilitySupports contains advertised client-relevant features.

type ModelInfo

type ModelInfo struct {
	ID                               string            `json:"id"`
	Name                             string            `json:"name,omitempty"`
	OwnedBy                          string            `json:"owned_by,omitempty"`
	SupportedEndpoints               []string          `json:"supported_endpoints,omitempty"`
	Capabilities                     ModelCapabilities `json:"capabilities,omitempty"`
	ContextWindow                    *int64            `json:"context_window,omitempty"`
	MaxContextWindow                 *int64            `json:"max_context_window,omitempty"`
	EffectiveContextWindowPercentage int64             `json:"effective_context_window_percent,omitempty"`
}

ModelInfo is the launcher-relevant subset of one /v1/models entry.

type Options

type Options struct {
	Model            string
	Binary           string
	LocalToken       string
	ForwardedArgs    []string
	StartupTimeout   time.Duration
	ShutdownTimeout  time.Duration
	ChildStopTimeout time.Duration
	SensitiveEnv     []string
	Environment      []string
	Stdin            io.Reader
	Stdout           io.Writer
	Stderr           io.Writer
	LogPath          string
	DryRunBaseURL    string
	DryRunModel      *ModelInfo
	Signals          <-chan os.Signal
	DryRun           bool
	NoSummary        bool
}

Options configures one launcher run.

type PrepareInput

type PrepareInput struct {
	BaseURL       string
	Model         ModelInfo
	Binary        string
	ForwardedArgs []string
	LocalToken    string
	SensitiveEnv  []string
	Environment   []string
	NoProxy       string
	// WebSearchMCPURL is the launch proxy's web search MCP endpoint, set only
	// when the proxy confirmed the tool is available.
	WebSearchMCPURL string
	// CopilotAbsent is set when the launch proxy confirmed that no Copilot
	// provider serves the session.
	CopilotAbsent bool
	// RoutesLikeModel reports whether a Messages request naming alias reaches
	// the selected model. It is nil when no live proxy can answer.
	RoutesLikeModel func(alias string) bool
	DryRun          bool
}

PrepareInput contains the resolved values an agent adapter needs to construct its child process. BaseURL is the root Vekil URL without a trailing slash. Model is zero-valued when selection is delegated to the agent CLI.

type PreparedProcess

type PreparedProcess struct {
	Path       string
	Args       []string
	EnvSet     map[string]string
	EnvUnset   []string
	Unresolved []string
	Cleanup    func() error
}

PreparedProcess is an agent-specific process plan. EnvSet and EnvUnset are applied over a sanitized copy of the parent environment immediately before the child is started.

type Proxy

type Proxy interface {
	Start(context.Context) error
	Addr() string
	Done() <-chan error
	Stop(context.Context) error
}

Proxy is the lifecycle surface the launcher needs from a ready-capable Vekil server. Start must return only after startup authentication and dynamic model validation have completed.

type Result

type Result struct {
	ExitCode int
	BaseURL  string
	Model    ModelInfo
}

Result is the completed launcher outcome. A non-zero child exit is represented by ExitCode rather than an error so callers can preserve the agent's status. Model is zero-valued when the agent CLI selected its own model.

func Run

func Run(parent context.Context, proxy Proxy, adapter Adapter, opts Options) (result Result, returnErr error)

Run starts proxy, validates a requested model when one is provided, prepares the agent process, supervises it, prints a session summary, and tears everything down. An empty model delegates selection to the agent CLI.

Jump to

Keyboard shortcuts

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