Documentation
¶
Index ¶
- Constants
- func ExtractFromFlagSettings(settings map[string]any) (map[string]string, error)
- func Fingerprint(forward map[string]string) string
- func LoadFile(path string) (map[string]string, error)
- func LooksProviderSpecific(modelID string) bool
- func NormalizeModelID(value string, cfg Config) (logical string, changed bool, unresolved bool)
- func ParseJSON(data []byte, source string) (map[string]string, error)
- func ParsePairs(pairs []string) (map[string]string, error)
- func ProviderSpecificModelArgs(args []string) []string
- func RewriteJSONLResponseBody(body []byte, ctx *Context) ([]byte, error)
- func RewriteJSONResponseBody(body []byte, ctx *Context) ([]byte, error)
- func RewriteResponse(resp *http.Response, ctx *Context) error
- func WrapSSEResponse(body io.ReadCloser, ctx *Context) io.ReadCloser
- type Config
- type Context
- type Normalization
- type ResolveOptions
Constants ¶
const ( ModeDisabled = "disabled" ModeRewrite = "rewrite" EnvAliasesFile = "CCWRAP_MODEL_ALIASES_FILE" EnvAliasesJSON = "CCWRAP_MODEL_ALIASES_JSON" )
const MaxRewriteBytes int64 = 32 * 1024 * 1024
Variables ¶
This section is empty.
Functions ¶
func ExtractFromFlagSettings ¶
func Fingerprint ¶
func LooksProviderSpecific ¶
LooksProviderSpecific reports whether modelID is shaped like a provider-routed id (Bedrock, Vertex, Azure-style deployments, ARNs) rather than a Claude logical id. It backs the strict-mode fail-closed gates (rewriteRequestObjectModel, validateHiddenModeModels), so it must err toward TRUE for provider shapes: a miss here lets an unaliased provider id sail to the gateway unrewritten. Marker scan runs BEFORE any canonical-shape exemption — Vertex ids ("claude-opus-4-8@20250115") start with "claude-" yet are provider-specific, and Bedrock ids carry an "anthropic." segment ("anthropic.claude-opus-4-8", "us.anthropic.claude-...-v1:0") with none of the path/ARN markers. Canonical ids ("claude-opus-4-8", bare aliases like "sonnet") contain no marker and fall through to false. Explicitly aliased ids are exempt upstream of this check (cfg.Forward is consulted first).
func NormalizeModelID ¶
func RewriteJSONResponseBody ¶
func WrapSSEResponse ¶
func WrapSSEResponse(body io.ReadCloser, ctx *Context) io.ReadCloser
Types ¶
type Config ¶
type Config struct {
Forward map[string]string
Strict bool
Source string
Fingerprint string
ProviderModelPassthrough bool
}
func (Config) LogicalForProvider ¶
type Context ¶
type Context struct {
Enabled bool
Rewritten bool
NormalizeResponse bool
LogicalModel string
UpstreamModel string
Reverse map[string]string
}
func RewriteJSONRequestBody ¶
type Normalization ¶
func NormalizeClaudeModelArgs ¶
func NormalizeClaudeModelArgs(args []string, cfg Config) (out []string, normalized []Normalization, unresolved []string)
type ResolveOptions ¶
type ResolveOptions struct {
ExplicitFile string
ExplicitFileContent []byte // if non-empty, used in place of LoadFile(ExplicitFile); takes normative precedence over reading from disk
ExplicitPairs []string
ParentEnv []string
EnvFileContent []byte // if non-empty, used in place of LoadFile(env-path); takes normative precedence over reading from disk
FlagSettings map[string]any
Strict bool
ProviderModelPassthrough bool
}