Documentation
¶
Overview ¶
Package thirdparty hosts lightweight OpenAI-compatible provider adapters for subscription (OAuth/cookie) and free-tier accounts: Cursor, GitHub Copilot, Kimi, OpenCode Free, Felo, Qoder. They reuse the generic oauthrefresh.Manager for single-flight OAuth token refresh and forward provider quota headers (X-Provider-Quota-* / codex-style credits) to the gateway quota tracker via the standard result headers.
Index ¶
- Variables
- func RegisterIfAbsent(reg *adapter.Registry, spec Spec, client *http.Client) bool
- func RegisterOAuth(reg *adapter.Registry, client *http.Client, sink Sink, trigger Trigger) error
- func RegisterPlugins(reg *adapter.Registry, client *http.Client) error
- func RegisterWithAuth(reg *adapter.Registry, spec Spec, client *http.Client, ...) error
- type Adapter
- type ControlPlaneSink
- type Sink
- type Spec
- type Trigger
Constants ¶
This section is empty.
Variables ¶
var ( CursorSpec = Spec{ Name: "cursor", DefaultBaseURL: "https://api2.cursor.sh", Headers: map[string]string{ "User-Agent": "cursor/1.0.0 (official CLI)", "X-Cursor-Client": "cursor-cli", "X-Origin": "cursor", "X-Requested-With": "XMLHttpRequest", }, SupportsOAuth: true, } CopilotSpec = Spec{ Name: "copilot", DefaultBaseURL: "https://api.githubcopilot.com", Headers: map[string]string{ "User-Agent": "GitHubCopilot-CLI/0.1.0", "X-GitHub-Copilot-CLI": "1", }, SupportsOAuth: true, } KimiSpec = Spec{ Name: "kimi", DefaultBaseURL: "https://api.moonshot.cn/v1", Headers: map[string]string{ "User-Agent": "kimi-code/1.0.0 (official CLI)", "X-Kimi-CLI": "1", }, SupportsOAuth: true, FreeByDefault: true, } OpenCodeSpec = Spec{ Name: "opencode", DefaultBaseURL: "https://opencode.ai/v1", Headers: map[string]string{ "User-Agent": "opencode/1.0.0 (official CLI)", }, FreeByDefault: true, } FeloSpec = Spec{ Name: "felo", DefaultBaseURL: "https://api.felo.ai/v1", Headers: map[string]string{ "User-Agent": "felo/1.0.0 (official CLI)", }, FreeByDefault: true, } QoderSpec = Spec{ Name: "qoder", DefaultBaseURL: "https://api.qoder.ai/v1", Headers: map[string]string{ "User-Agent": "qoder/1.0.0 (official CLI)", }, FreeByDefault: true, } )
Provider specs — subscription/free OpenAI-compatible accounts. Base URLs are defaults users can override per-account in config; free endpoints change over time (9Router notes "subject to change"), so the config base_url always wins.
Functions ¶
func RegisterIfAbsent ¶
func RegisterOAuth ¶
RegisterOAuth registers OAuth-capable thirdparty adapters (cursor, copilot, kimi) with token refresh. Idempotent: replaces in-memory adapters when a control-plane sink is available.
func RegisterPlugins ¶
RegisterPlugins registers all thirdparty providers into a fresh registry.
func RegisterWithAuth ¶
func RegisterWithAuth(reg *adapter.Registry, spec Spec, client *http.Client, sink oauthrefresh.CredentialSink, trigger oauthrefresh.SnapshotRefreshTrigger) error
RegisterWithAuth attaches OAuth refresh (control-plane sink + snapshot trigger) to an OAuth-capable provider.
Types ¶
type Adapter ¶
func (*Adapter) SharedClient ¶
ControlPlaneClient is a tiny helper for main.go to fetch the shared client.
type ControlPlaneSink ¶
type ControlPlaneSink = oauthrefresh.ControlPlaneSink
type Sink ¶
type Sink = oauthrefresh.CredentialSink
type Spec ¶
type Spec struct {
// Name is the registered adapter name (openai-compatible style).
Name string
// DefaultBaseURL is used when account.BaseURL is empty.
DefaultBaseURL string
// Headers applied to every request (subscription spoof / family hints).
Headers map[string]string
// SupportsOAuth enables token refresh for Kind=oauth via oauthrefresh.
SupportsOAuth bool
// FreeByDefault marks providers whose credential may be Kind=free.
FreeByDefault bool
}
type Trigger ¶
type Trigger = oauthrefresh.SnapshotRefreshTrigger
Trigger and Sink alias oauthrefresh interfaces for main.go wiring.