thirdparty

package
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2026 License: Apache-2.0 Imports: 10 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 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

Constants

This section is empty.

Variables

View Source
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 RegisterIfAbsent(reg *adapter.Registry, spec Spec, client *http.Client) bool

func RegisterOAuth

func RegisterOAuth(reg *adapter.Registry, client *http.Client, sink Sink, trigger Trigger) error

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

func RegisterPlugins(reg *adapter.Registry, client *http.Client) error

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

type Adapter struct {
	Client *http.Client
	// contains filtered or unexported fields
}

func New

func New(client *http.Client, spec Spec) *Adapter

func (*Adapter) Execute

func (a *Adapter) Execute(ctx context.Context, ex adapter.Execution) (*adapter.Result, error)

func (*Adapter) Operate

func (*Adapter) SharedClient

func (a *Adapter) SharedClient() *http.Client

ControlPlaneClient is a tiny helper for main.go to fetch the shared client.

type ControlPlaneSink

type ControlPlaneSink = oauthrefresh.ControlPlaneSink

type Sink

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

Trigger and Sink alias oauthrefresh interfaces for main.go wiring.

Jump to

Keyboard shortcuts

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