providers

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CodexAccountResolverForLogin added in v0.5.0

func CodexAccountResolverForLogin(key string) openai.CodexAccountResolver

CodexAccountResolverForLogin returns the same per-request account resolver used by the runtime provider. Auxiliary Codex requests use this rather than independently selecting or parsing an OAuth login, which could mismatch the bearer selected by oauthLoginForProfile.

func DefaultTurnSessions added in v0.5.0

func DefaultTurnSessions(profile config.ProviderProfile, provider zeroruntime.Provider, options Options) zeroruntime.TurnSessionProvider

DefaultTurnSessions wraps an already-built provider in the DEFAULT (no-op) turn-session adapter with the profile's resolved capability projection. It is the non-optimized sibling of OptimizedTurnSessions for callers that still want capabilities populated — e.g. the mid-run model-switch fallback when the switched model is not eligible for the optimized session. Capability resolution failure degrades to an unknown (zero) projection rather than failing the wrap: the default session has no behavior that depends on capabilities, so a swap must never be blocked by a projection error.

func New

func New(profile config.ProviderProfile, options Options) (zeroruntime.Provider, error)

New creates a runtime provider for a resolved provider profile.

func NewTurnSessionProvider added in v0.5.0

func NewTurnSessionProvider(profile config.ProviderProfile, options Options) (zeroruntime.TurnSessionProvider, error)

NewTurnSessionProvider builds the default TurnSessionProvider for a resolved profile: it constructs the provider exactly as New does, then wraps it with a ProviderCapabilities projection computed from the same model-registry entry New already resolves. The default session's Stream is the provider's StreamCompletion, so runtime behavior is identical to using New directly.

func OptimizedTurnSessions added in v0.5.0

func OptimizedTurnSessions(profile config.ProviderProfile, provider zeroruntime.Provider, options Options) (zeroruntime.TurnSessionProvider, bool)

OptimizedTurnSessions returns the gated optimized TurnSessionProvider for an already-built provider, or (nil, false) when the gate is off or the profile is ineligible. Callers leave agent Options.TurnSessionProvider nil on false, so the loop's default wrap keeps today's behavior byte-identical.

Eligibility is deliberately narrow: the resolved provider kind must be official OpenAI (NOT openai-compatible gateways — the constructor merges the two, so this branches on the resolved kind explicitly), not the ChatGPT Codex catalog, and the provider value must be the concrete *openai.Provider (a fake, a Codex provider, or nil falls back to the default path safely). No base-URL check on top of the kind: prewarm and fingerprint telemetry are harmless against any host, and kind==openai mirrors the existing official-OpenAI precedent used for prompt_cache_key.

Types

type Options

type Options struct {
	UserAgent     string
	HTTPClient    *http.Client
	ModelRegistry *modelregistry.Registry
	// OAuthResolver, when set, lets the provider authenticate model calls with an
	// OAuth bearer token (preferred over the API key). nil => API-key auth only.
	// Applied to the OpenAI, Anthropic, and Google (Gemini) providers.
	OAuthResolver providerio.TokenResolver
	// OAuthLoginKey is the credential-store key OAuthResolver bound to (empty when
	// there is no OAuth login). It is the SAME selection the bearer resolver made,
	// resolved ONCE by the caller so the Codex chatgpt-account-id header reads its
	// account from the exact login that issued the bearer token — never a second,
	// independent lookup that could pick a different login (a backend-rejected
	// mismatch).
	OAuthLoginKey string
}

Options configures provider construction.

type RuntimeMetadata

type RuntimeMetadata struct {
	ProviderKind config.ProviderKind
	APIModel     string
}

RuntimeMetadata describes the provider identity and concrete API model used after Zero model aliases and provider-kind defaults are resolved.

func ResolveRuntimeMetadata

func ResolveRuntimeMetadata(profile config.ProviderProfile, options Options) (RuntimeMetadata, error)

ResolveRuntimeMetadata returns the provider kind and API model that New would use for a profile, without constructing a network client.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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