mirror of
https://github.com/router-for-me/CLIProxyAPI.git
synced 2026-11-26 20:03:32 +08:00
- Add "uniqueItems" to the stripIncompatiblePatternsFromJSON fast-path guard and remove schema-level uniqueItems keys in stripIncompatiblePatterns while preserving literal properties.uniqueItems fields and non-schema user data. - Update NormalizeCodexToolSchemas documentation and add regression tests across tool-schema, helps, and Codex HTTP and WebSocket executors. Closes: #7690
42 lines
1.8 KiB
Go
42 lines
1.8 KiB
Go
package helps
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/MoeForge/moego/ojson"
|
|
toolschema "github.com/router-for-me/CLIProxyAPI/v8/internal/client/codex/tool-schema"
|
|
)
|
|
|
|
// IsCodexUserAgent reports whether headers contain a User-Agent indicating a Codex client.
|
|
func IsCodexUserAgent(headers http.Header) bool {
|
|
return toolschema.IsCodexUserAgent(headers)
|
|
}
|
|
|
|
// NormalizeCodexToolIntegerTypes normalizes specified tool parameter declarations
|
|
// from number to integer for Codex clients across supported tool formats.
|
|
func NormalizeCodexToolIntegerTypes(body []byte, headers http.Header) []byte {
|
|
return toolschema.NormalizeCodexToolIntegerTypes(body, headers)
|
|
}
|
|
|
|
// NormalizeCodexToolIntegerTypesDoc normalizes specified tool parameter declarations
|
|
// from number to integer for Codex clients directly on doc in place.
|
|
func NormalizeCodexToolIntegerTypesDoc(doc *ojson.Doc, headers http.Header) bool {
|
|
return toolschema.NormalizeCodexToolIntegerTypesDoc(doc, headers)
|
|
}
|
|
|
|
// NormalizeCodexToolSchemas inspects function tools in a Codex request payload
|
|
// and simplifies pure constant union combinations (e.g. large oneOf branch sets
|
|
// representing enums with descriptions, as emitted by MCP servers) into semantically
|
|
// equivalent enum lists, and sanitizes unsupported schema keywords and patterns.
|
|
// It does not normalize tool integer types because upstream OpenAI Codex models
|
|
// strictly validate reserved tool schemas (e.g. collaboration.wait_agent).
|
|
func NormalizeCodexToolSchemas(body []byte) []byte {
|
|
return toolschema.NormalizeCodexToolSchemas(body)
|
|
}
|
|
|
|
// NormalizeCodexToolSchemasDoc inspects function tools in doc and simplifies
|
|
// pure constant union combinations and sanitizes unsupported schema keywords and patterns in place.
|
|
func NormalizeCodexToolSchemasDoc(doc *ojson.Doc) bool {
|
|
return toolschema.NormalizeCodexToolSchemasDoc(doc)
|
|
}
|