Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
陈曦
sub2api
Commits
312cc00d
Commit
312cc00d
authored
Dec 31, 2025
by
shaw
Browse files
Merge branch 'IanShaw027/main'
parents
2270a54f
8e55ee0e
Changes
3
Show whitespace changes
Inline
Side-by-side
backend/internal/pkg/antigravity/claude_types.go
View file @
312cc00d
...
...
@@ -37,8 +37,19 @@ type ClaudeMetadata struct {
}
// ClaudeTool Claude 工具定义
// 支持两种格式:
// 1. 标准格式: { "name": "...", "description": "...", "input_schema": {...} }
// 2. Custom 格式 (MCP): { "type": "custom", "name": "...", "custom": { "description": "...", "input_schema": {...} } }
type
ClaudeTool
struct
{
Type
string
`json:"type,omitempty"`
// "custom" 或空(标准格式)
Name
string
`json:"name"`
Description
string
`json:"description,omitempty"`
// 标准格式使用
InputSchema
map
[
string
]
any
`json:"input_schema,omitempty"`
// 标准格式使用
Custom
*
CustomToolSpec
`json:"custom,omitempty"`
// custom 格式使用
}
// CustomToolSpec MCP custom 工具规格
type
CustomToolSpec
struct
{
Description
string
`json:"description,omitempty"`
InputSchema
map
[
string
]
any
`json:"input_schema"`
}
...
...
backend/internal/pkg/antigravity/request_transformer.go
View file @
312cc00d
...
...
@@ -3,6 +3,7 @@ package antigravity
import
(
"encoding/json"
"fmt"
"log"
"strings"
"github.com/google/uuid"
...
...
@@ -205,6 +206,13 @@ func buildParts(content json.RawMessage, toolIDToName map[string]string, allowDu
// 保留原有 signature(Claude 模型需要有效的 signature)
if
block
.
Signature
!=
""
{
part
.
ThoughtSignature
=
block
.
Signature
}
else
if
!
allowDummyThought
{
// Claude 模型需要有效 signature,跳过无 signature 的 thinking block
log
.
Printf
(
"Warning: skipping thinking block without signature for Claude model"
)
continue
}
else
{
// Gemini 模型使用 dummy signature
part
.
ThoughtSignature
=
dummyThoughtSignature
}
parts
=
append
(
parts
,
part
)
...
...
@@ -379,12 +387,40 @@ func buildTools(tools []ClaudeTool) []GeminiToolDeclaration {
// 普通工具
var
funcDecls
[]
GeminiFunctionDecl
for
_
,
tool
:=
range
tools
{
// 跳过无效工具名称
if
tool
.
Name
==
""
{
log
.
Printf
(
"Warning: skipping tool with empty name"
)
continue
}
var
description
string
var
inputSchema
map
[
string
]
any
// 检查是否为 custom 类型工具 (MCP)
if
tool
.
Type
==
"custom"
&&
tool
.
Custom
!=
nil
{
// Custom 格式: 从 custom 字段获取 description 和 input_schema
description
=
tool
.
Custom
.
Description
inputSchema
=
tool
.
Custom
.
InputSchema
}
else
{
// 标准格式: 从顶层字段获取
description
=
tool
.
Description
inputSchema
=
tool
.
InputSchema
}
// 清理 JSON Schema
params
:=
cleanJSONSchema
(
tool
.
InputSchema
)
params
:=
cleanJSONSchema
(
inputSchema
)
// 为 nil schema 提供默认值
if
params
==
nil
{
params
=
map
[
string
]
any
{
"type"
:
"OBJECT"
,
"properties"
:
map
[
string
]
any
{},
}
}
funcDecls
=
append
(
funcDecls
,
GeminiFunctionDecl
{
Name
:
tool
.
Name
,
Description
:
tool
.
D
escription
,
Description
:
d
escription
,
Parameters
:
params
,
})
}
...
...
backend/internal/service/gemini_messages_compat_service.go
View file @
312cc00d
...
...
@@ -2245,12 +2245,40 @@ func convertClaudeToolsToGeminiTools(tools any) []any {
if
!
ok
{
continue
}
name
,
_
:=
tm
[
"name"
]
.
(
string
)
desc
,
_
:=
tm
[
"description"
]
.
(
string
)
params
:=
tm
[
"input_schema"
]
var
name
,
desc
string
var
params
any
// 检查是否为 custom 类型工具 (MCP)
toolType
,
_
:=
tm
[
"type"
]
.
(
string
)
if
toolType
==
"custom"
{
// Custom 格式: 从 custom 字段获取 description 和 input_schema
custom
,
ok
:=
tm
[
"custom"
]
.
(
map
[
string
]
any
)
if
!
ok
{
continue
}
name
,
_
=
tm
[
"name"
]
.
(
string
)
desc
,
_
=
custom
[
"description"
]
.
(
string
)
params
=
custom
[
"input_schema"
]
}
else
{
// 标准格式: 从顶层字段获取
name
,
_
=
tm
[
"name"
]
.
(
string
)
desc
,
_
=
tm
[
"description"
]
.
(
string
)
params
=
tm
[
"input_schema"
]
}
if
name
==
""
{
continue
}
// 为 nil params 提供默认值
if
params
==
nil
{
params
=
map
[
string
]
any
{
"type"
:
"object"
,
"properties"
:
map
[
string
]
any
{},
}
}
funcDecls
=
append
(
funcDecls
,
map
[
string
]
any
{
"name"
:
name
,
"description"
:
desc
,
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment