diff --git a/backend/internal/pkg/antigravity/claude_types.go b/backend/internal/pkg/antigravity/claude_types.go index 7f86dac3..25228e66 100644 --- a/backend/internal/pkg/antigravity/claude_types.go +++ b/backend/internal/pkg/antigravity/claude_types.go @@ -40,7 +40,7 @@ type ClaudeMetadata struct { type ClaudeTool struct { Name string `json:"name"` Description string `json:"description,omitempty"` - InputSchema map[string]interface{} `json:"input_schema"` + InputSchema map[string]any `json:"input_schema"` } // SystemBlock system prompt 数组形式的元素 @@ -60,7 +60,7 @@ type ContentBlock struct { // tool_use ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` - Input interface{} `json:"input,omitempty"` + Input any `json:"input,omitempty"` // tool_result ToolUseID string `json:"tool_use_id,omitempty"` Content json.RawMessage `json:"content,omitempty"` @@ -102,7 +102,7 @@ type ClaudeContentItem struct { // tool_use ID string `json:"id,omitempty"` Name string `json:"name,omitempty"` - Input interface{} `json:"input,omitempty"` + Input any `json:"input,omitempty"` } // ClaudeUsage Claude 用量统计 diff --git a/backend/internal/pkg/antigravity/gemini_types.go b/backend/internal/pkg/antigravity/gemini_types.go index 2800e0ee..b81e17df 100644 --- a/backend/internal/pkg/antigravity/gemini_types.go +++ b/backend/internal/pkg/antigravity/gemini_types.go @@ -48,14 +48,14 @@ type GeminiInlineData struct { // GeminiFunctionCall Gemini 函数调用 type GeminiFunctionCall struct { Name string `json:"name"` - Args interface{} `json:"args,omitempty"` + Args any `json:"args,omitempty"` ID string `json:"id,omitempty"` } // GeminiFunctionResponse Gemini 函数响应 type GeminiFunctionResponse struct { Name string `json:"name"` - Response map[string]interface{} `json:"response"` + Response map[string]any `json:"response"` ID string `json:"id,omitempty"` } @@ -85,7 +85,7 @@ type GeminiToolDeclaration struct { type GeminiFunctionDecl struct { Name string `json:"name"` Description string `json:"description,omitempty"` - Parameters map[string]interface{} `json:"parameters,omitempty"` + Parameters map[string]any `json:"parameters,omitempty"` } // GeminiGoogleSearch Gemini Google 搜索工具 diff --git a/backend/internal/pkg/antigravity/request_transformer.go b/backend/internal/pkg/antigravity/request_transformer.go index f72deb10..2ff0ec02 100644 --- a/backend/internal/pkg/antigravity/request_transformer.go +++ b/backend/internal/pkg/antigravity/request_transformer.go @@ -256,7 +256,7 @@ func buildParts(content json.RawMessage, toolIDToName map[string]string, allowDu parts = append(parts, GeminiPart{ FunctionResponse: &GeminiFunctionResponse{ Name: funcName, - Response: map[string]interface{}{ + Response: map[string]any{ "result": resultContent, }, ID: block.ToolUseID, @@ -290,7 +290,7 @@ func parseToolResultContent(content json.RawMessage, isError bool) string { } // 尝试解析为数组 - var arr []map[string]interface{} + var arr []map[string]any if err := json.Unmarshal(content, &arr); err == nil { var texts []string for _, item := range arr { @@ -400,12 +400,12 @@ func buildTools(tools []ClaudeTool) []GeminiToolDeclaration { // cleanJSONSchema 清理 JSON Schema,移除 Antigravity/Gemini 不支持的字段 // 参考 proxycast 的实现,确保 schema 符合 JSON Schema draft 2020-12 -func cleanJSONSchema(schema map[string]interface{}) map[string]interface{} { +func cleanJSONSchema(schema map[string]any) map[string]any { if schema == nil { return nil } cleaned := cleanSchemaValue(schema) - result, ok := cleaned.(map[string]interface{}) + result, ok := cleaned.(map[string]any) if !ok { return nil } @@ -417,13 +417,13 @@ func cleanJSONSchema(schema map[string]interface{}) map[string]interface{} { // 确保有 properties 字段(默认空对象) if _, hasProps := result["properties"]; !hasProps { - result["properties"] = make(map[string]interface{}) + result["properties"] = make(map[string]any) } // 验证 required 中的字段都存在于 properties 中 - if required, ok := result["required"].([]interface{}); ok { - if props, ok := result["properties"].(map[string]interface{}); ok { - validRequired := make([]interface{}, 0, len(required)) + if required, ok := result["required"].([]any); ok { + if props, ok := result["properties"].(map[string]any); ok { + validRequired := make([]any, 0, len(required)) for _, r := range required { if reqName, ok := r.(string); ok { if _, exists := props[reqName]; exists { @@ -471,10 +471,10 @@ var excludedSchemaKeys = map[string]bool{ } // cleanSchemaValue 递归清理 schema 值 -func cleanSchemaValue(value interface{}) interface{} { +func cleanSchemaValue(value any) any { switch v := value.(type) { - case map[string]interface{}: - result := make(map[string]interface{}) + case map[string]any: + result := make(map[string]any) for k, val := range v { // 跳过不支持的字段 if excludedSchemaKeys[k] { @@ -492,9 +492,9 @@ func cleanSchemaValue(value interface{}) interface{} { } return result - case []interface{}: + case []any: // 递归处理数组中的每个元素 - cleaned := make([]interface{}, 0, len(v)) + cleaned := make([]any, 0, len(v)) for _, item := range v { cleaned = append(cleaned, cleanSchemaValue(item)) } @@ -506,11 +506,11 @@ func cleanSchemaValue(value interface{}) interface{} { } // cleanTypeValue 处理 type 字段,转换为大写 -func cleanTypeValue(value interface{}) interface{} { +func cleanTypeValue(value any) any { switch v := value.(type) { case string: return strings.ToUpper(v) - case []interface{}: + case []any: // 联合类型 ["string", "null"] -> 取第一个非 null 类型 for _, t := range v { if ts, ok := t.(string); ok && ts != "null" {