codex

package
v1.7.20 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2026 License: MIT Imports: 39 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 codex connects Codex clients to CCL providers without moving native Codex or Claude credentials. The desktop picker and routing allow-list are deliberately separate: only names owned by CCL can reach a CCL runtime.

Index

Constants

View Source
const IndependentProviderID = "ccl_proxy"

Variables

This section is empty.

Functions

func FindExecutable

func FindExecutable() (string, error)

func Home

func Home() (string, error)

Types

type Catalog

type Catalog struct {
	Models []Model `json:"models"`
}

func MergeCatalog

func MergeCatalog(native Catalog, custom []Model) (Catalog, error)

func ParseCatalog

func ParseCatalog(data []byte) (Catalog, error)

type CatalogCapabilities added in v1.7.20

type CatalogCapabilities struct {
	SupportsRemoteFetch bool `json:"supports_remote_fetch"`
	SupportsLiveReload  bool `json:"supports_live_reload"`
}

CatalogCapabilities reports CCL's supported client contract for the selected source. A false live-reload value means there is no verified guarantee; it does not assert that Codex has no background refresh mechanism.

type CatalogMode added in v1.7.20

type CatalogMode string

CatalogMode chooses how Codex obtains catalog data. It does not describe whether a running client or its Desktop picker reloads that data. The zero value is unspecified for command inheritance and defaults to local.

const (
	CatalogLocal  CatalogMode = "local"
	CatalogRemote CatalogMode = "remote"
)

func ParseCatalogMode added in v1.7.20

func ParseCatalogMode(value string) (CatalogMode, error)

func (CatalogMode) Capabilities added in v1.7.20

func (mode CatalogMode) Capabilities() CatalogCapabilities

func (CatalogMode) Effective added in v1.7.20

func (mode CatalogMode) Effective() CatalogMode

type ConfigChange

type ConfigChange struct {
	Scope   []string `json:"scope,omitempty"`
	Key     string   `json:"key"`
	Before  *string  `json:"before"`
	Applied *string  `json:"applied"`
	// PreviousApplied covers the journal-before-config window of a live model
	// selection update, so crash recovery can restore either owned value.
	PreviousApplied *string `json:"previous_applied,omitempty"`
}

type Gateway

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

func New

func New(ctx context.Context, runtime *oauthproxy.Runtime, configured provider.Provider, options Options) (*Gateway, error)

New initially borrows the runtime. OwnRuntime/ReplaceProviders transfer lifecycle cleanup to request-leased generations while the listener stays put.

func (*Gateway) BaseURL

func (g *Gateway) BaseURL() string

func (*Gateway) Close

func (g *Gateway) Close()

func (*Gateway) Models

func (g *Gateway) Models() []Model

func (*Gateway) OwnRuntime added in v1.7.20

func (g *Gateway) OwnRuntime(close func())

func (*Gateway) RefreshMetadata added in v1.7.19

func (g *Gateway) RefreshMetadata(configured provider.Provider, persist func([]Model) error) error

RefreshMetadata changes client catalog settings only. Routes, authentication, the runtime and conversation history remain owned by the existing session. Persist the new catalog before publishing it to concurrent HTTP readers.

func (*Gateway) RefreshProvidersMetadata added in v1.7.20

func (g *Gateway) RefreshProvidersMetadata(providers []provider.Provider, persist func([]Model) error) error

RefreshProvidersMetadata keeps each route bound to its existing account.

func (*Gateway) ReplaceProviders added in v1.7.20

func (g *Gateway) ReplaceProviders(bindings []RuntimeBinding, persist func([]Model) error) error

ReplaceProviders atomically publishes a complete route set after persistence. In-flight requests lease the previous immutable snapshot until their bodies (including streaming responses) finish. Port, token and histories stay put.

func (*Gateway) Start added in v1.7.20

func (g *Gateway) Start()

func (*Gateway) Token

func (g *Gateway) Token() string

type Model

type Model map[string]any

Model preserves Codex's catalog fields, including fields introduced by newer clients. Native entries are never reconstructed from a /v1/models list.

type Options

type Options struct {
	// DeferredStart lets the daemon finish its catalog/configuration plan before
	// serving clients reconnecting to a reused port.
	DeferredStart bool
	// CatalogRemote is opt-in for custom providers; native OpenAI only accepts
	// catalog URLs on allowed ChatGPT hosts. Local JSON remains the default.
	CatalogMode CatalogMode
	// Independent selects a custom provider with its own loopback credential,
	// rather than sharing OpenAI's provider/account state in the desktop app.
	Independent bool
	Desktop     bool
	// ListenAddress preserves the desktop endpoint across daemon replacement.
	// It may only name an explicit IPv4 loopback port; empty chooses a free one.
	ListenAddress string
	// Native upstream overrides are for local integration fixtures. Commands
	// never populate them from client requests or environment variables.
	OpenAIURL  string
	ChatGPTURL string
}

type Overlay

type Overlay struct {
	RemoteCatalog bool           `json:"remote_catalog,omitempty"`
	Path          string         `json:"path"`
	CatalogPath   string         `json:"catalog_path"`
	BaseURL       string         `json:"base_url"`
	Changes       []ConfigChange `json:"changes"`
	ProviderBlock string         `json:"provider_block,omitempty"`
}

func Plan

func Plan(ctx context.Context, g *Gateway, directory string) (*Overlay, error)

Plan writes only the proxy-owned catalog, never the user's configuration. The lifecycle manager journals Changes before Apply touches config.toml.

func (*Overlay) Apply

func (o *Overlay) Apply(ctx context.Context) error

func (*Overlay) ApplyModelSelection added in v1.7.20

func (o *Overlay) ApplyModelSelection(ctx context.Context, previous *Overlay) error

func (*Overlay) PlanModelSelection added in v1.7.20

func (o *Overlay) PlanModelSelection(models []Model) (*Overlay, error)

PlanModelSelection replaces an owned independent-mode default only when its route was removed. A user-edited selection is preserved. The new journal can recover a crash before or after ApplyModelSelection changes config.toml.

func (*Overlay) RefreshCatalog added in v1.7.19

func (o *Overlay) RefreshCatalog(models []Model) error

RefreshCatalog updates only CCL-owned metadata in the existing file. It never rewrites config.toml, rotates independent credentials, or reconstructs native entries. The catalog path and overlay's restoration journal stay unchanged.

func (*Overlay) ReplaceCatalog added in v1.7.20

func (o *Overlay) ReplaceCatalog(models []Model) error

ReplaceCatalog changes the complete CCL model set while preserving all native rows and unknown native fields from the current catalog file.

func (*Overlay) Restore

func (o *Overlay) Restore(ctx context.Context) error

type Route

type Route struct {
	Provider        string
	Alias           string
	Model           string
	NativeResponses bool
	ThinkingBudget  bool
	MaxOutputTokens int
}

type RuntimeBinding added in v1.7.20

type RuntimeBinding struct {
	Provider provider.Provider
	Runtime  *oauthproxy.Runtime
	Close    func()
}

RuntimeBinding gives each provider an explicit account/runtime owner. The gateway takes ownership of Close only after a successful publication.

Jump to

Keyboard shortcuts

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