Documentation
¶
Index ¶
- Variables
- func GeminiClaudeToolUseID(callID, name, argsRaw string) string
- func GetGJSONBytesNoCopy(data []byte, path string) gjson.Result
- func HasUnsupportedUnicodePropertyEscape(pattern string) bool
- func IsClaudeCodeAttributionSystemText(text string) bool
- func IsGeminiClaudeToolUseID(id string) bool
- func NormalizeClaudeToolInputSchema(schema []byte) []byte
- func ParseGJSONBytesNoCopy(data []byte) gjson.Result
- func SanitizeClaudeFunctionName(name string) string
- func SanitizeClaudeToolID(id string) string
- func StripClaudeCodeAttributionSystem(payload []byte) []byte
Constants ¶
This section is empty.
Variables ¶
var SchemaMapKeywords = [...]string{
"properties",
"$defs",
"definitions",
"patternProperties",
"dependentSchemas",
"dependencies",
}
SchemaMapKeywords lists JSON Schema keywords whose values are maps of subschemas.
var SchemaValueKeywords = [...]string{
"items",
"prefixItems",
"contains",
"additionalProperties",
"propertyNames",
"unevaluatedProperties",
"unevaluatedItems",
"additionalItems",
"contentSchema",
"anyOf",
"oneOf",
"allOf",
"not",
"if",
"then",
"else",
}
SchemaValueKeywords lists JSON Schema keywords with a single nested subschema or a slice of subschemas.
Functions ¶
func GeminiClaudeToolUseID ¶
GeminiClaudeToolUseID returns a stable Claude-facing ID for a provider-native Gemini function call. The opaque ID lets the executor recover the exact provider call from its replay ledger instead of trusting client-mutated args.
func GetGJSONBytesNoCopy ¶
GetGJSONBytesNoCopy returns a GJSON result that may reference data directly. Callers must not retain the result or mutate data while using it.
func HasUnsupportedUnicodePropertyEscape ¶
HasUnsupportedUnicodePropertyEscape reports whether a regular expression string contains a construct that strict upstream JSON Schema validators reject when they compile "pattern" values on the way to a provider.
Two constructs are known to fail, both of which Anthropic's own API accepts verbatim (it does not validate pattern values), so they only surface after the request is translated or forwarded:
- Unicode property escapes (\p{...} or \P{...}): Python's built-in re module, and validators relying on it, fail with "bad escape \p".
- The octal NUL escape (\0): validators that re-serialize or normalize the schema reject it with "is not a 'regex'", while the equivalent \x00 spelling is accepted. Claude Code's built-in Artifact tool emits \0 in its NUL guards (e.g. "^[^\0]*$" on the upload_asset file_paths item).
Dropping the attribute is safe: the client validates its own input locally, so removing an upstream-side pattern constraint does not make a call succeed that would otherwise have been rejected by the tool.
func IsClaudeCodeAttributionSystemText ¶
IsClaudeCodeAttributionSystemText reports whether text is the Claude Code attribution block that carries per-request billing and prompt fingerprint data.
func IsGeminiClaudeToolUseID ¶
IsGeminiClaudeToolUseID reports whether id belongs to the reserved Claude-facing Gemini provenance namespace.
func NormalizeClaudeToolInputSchema ¶
NormalizeClaudeToolInputSchema makes a JSON Schema compatible with Claude's requirement that a tool input schema is an object without root-level unions.
func ParseGJSONBytesNoCopy ¶
ParseGJSONBytesNoCopy parses data into a GJSON result that references data directly. gjson.ParseBytes copies the whole document, which is prohibitive for multi-megabyte payloads. Callers must not retain the result or mutate data while using it.
func SanitizeClaudeFunctionName ¶
SanitizeClaudeFunctionName ensures a function or tool name conforms to Claude's requirements: ^[a-zA-Z0-9_-]{1,64}$. Non-conforming characters (including dots and colons commonly emitted by MCP tools) are replaced with '_'.
func SanitizeClaudeToolID ¶
SanitizeClaudeToolID ensures the given id conforms to Claude's tool_use.id regex ^[a-zA-Z0-9_-]+$. Non-conforming characters are replaced with '_'; an empty result gets a generated fallback.
func StripClaudeCodeAttributionSystem ¶
StripClaudeCodeAttributionSystem removes Claude Code billing/CCH attribution blocks from a Messages body. Other system content is kept. Providers such as Kimi and Antigravity may treat this block as prompt text, so callers use this helper when the active policy has not explicitly opted into a full CLI profile.
Types ¶
This section is empty.