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
- func FindExecutable() (string, error)
- func Home() (string, error)
- type Catalog
- type CatalogCapabilities
- type CatalogMode
- type ConfigChange
- type Gateway
- func (g *Gateway) BaseURL() string
- func (g *Gateway) Close()
- func (g *Gateway) Models() []Model
- func (g *Gateway) OwnRuntime(close func())
- func (g *Gateway) RefreshMetadata(configured provider.Provider, persist func([]Model) error) error
- func (g *Gateway) RefreshProvidersMetadata(providers []provider.Provider, persist func([]Model) error) error
- func (g *Gateway) ReplaceProviders(bindings []RuntimeBinding, persist func([]Model) error) error
- func (g *Gateway) Start()
- func (g *Gateway) Token() string
- type Model
- type Options
- type Overlay
- func (o *Overlay) Apply(ctx context.Context) error
- func (o *Overlay) ApplyModelSelection(ctx context.Context, previous *Overlay) error
- func (o *Overlay) PlanModelSelection(models []Model) (*Overlay, error)
- func (o *Overlay) RefreshCatalog(models []Model) error
- func (o *Overlay) ReplaceCatalog(models []Model) error
- func (o *Overlay) Restore(ctx context.Context) error
- type Route
- type RuntimeBinding
Constants ¶
const IndependentProviderID = "ccl_proxy"
Variables ¶
This section is empty.
Functions ¶
func FindExecutable ¶
Types ¶
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) OwnRuntime ¶ added in v1.7.20
func (g *Gateway) OwnRuntime(close func())
func (*Gateway) RefreshMetadata ¶ added in v1.7.19
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.
type Model ¶
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 ¶
Plan writes only the proxy-owned catalog, never the user's configuration. The lifecycle manager journals Changes before Apply touches config.toml.
func (*Overlay) ApplyModelSelection ¶ added in v1.7.20
func (*Overlay) PlanModelSelection ¶ added in v1.7.20
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
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
ReplaceCatalog changes the complete CCL model set while preserving all native rows and unknown native fields from the current catalog file.
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.