diff --git a/internal/runtime/executor/antigravity_executor.go b/internal/runtime/executor/antigravity_executor.go index a667a4d9..f83ba789 100644 --- a/internal/runtime/executor/antigravity_executor.go +++ b/internal/runtime/executor/antigravity_executor.go @@ -17,6 +17,7 @@ import ( "github.com/google/uuid" "github.com/router-for-me/CLIProxyAPI/v6/internal/config" "github.com/router-for-me/CLIProxyAPI/v6/internal/registry" + "github.com/router-for-me/CLIProxyAPI/v6/internal/util" cliproxyauth "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/auth" cliproxyexecutor "github.com/router-for-me/CLIProxyAPI/v6/sdk/cliproxy/executor" sdktranslator "github.com/router-for-me/CLIProxyAPI/v6/sdk/translator" @@ -510,6 +511,24 @@ func (e *AntigravityExecutor) buildRequest(ctx context.Context, auth *cliproxyau payload = geminiToAntigravity(modelName, payload) payload, _ = sjson.SetBytes(payload, "model", alias2ModelName(modelName)) + + if strings.Contains(modelName, "claude") { + strJSON := string(payload) + paths := make([]string, 0) + util.Walk(gjson.ParseBytes(payload), "", "parametersJsonSchema", &paths) + for _, p := range paths { + strJSON, _ = util.RenameKey(strJSON, p, p[:len(p)-len("parametersJsonSchema")]+"parameters") + } + + strJSON = util.DeleteKey(strJSON, "$schema") + strJSON = util.DeleteKey(strJSON, "maxItems") + strJSON = util.DeleteKey(strJSON, "minItems") + strJSON = util.DeleteKey(strJSON, "minLength") + strJSON = util.DeleteKey(strJSON, "maxLength") + + payload = []byte(strJSON) + } + httpReq, errReq := http.NewRequestWithContext(ctx, http.MethodPost, requestURL.String(), bytes.NewReader(payload)) if errReq != nil { return nil, errReq diff --git a/internal/util/translator.go b/internal/util/translator.go index 40274aca..5a4bb7e8 100644 --- a/internal/util/translator.go +++ b/internal/util/translator.go @@ -79,6 +79,15 @@ func RenameKey(jsonStr, oldKeyPath, newKeyPath string) (string, error) { return finalJson, nil } +func DeleteKey(jsonStr, keyName string) string { + paths := make([]string, 0) + Walk(gjson.Parse(jsonStr), "", keyName, &paths) + for _, p := range paths { + jsonStr, _ = sjson.Delete(jsonStr, p) + } + return jsonStr +} + // FixJSON converts non-standard JSON that uses single quotes for strings into // RFC 8259-compliant JSON by converting those single-quoted strings to // double-quoted strings with proper escaping.