Files
Agent-System-Core/tools.go
weichen 6bdc4f2ada Add Hidden to ToolDesc for reserved tool capabilities
Why: the fs tool family (proposal 2026-09-30-file-preview-and-reserved-
capabilities) is implemented but must stay invisible to models and tool
listings until a runtime gate opens it.

Evidence: new bool field with json omitempty; no golden samples carry it;
go test ./... green.

Impact: registries can mark gated tools; servers and runners filter on
it (backend PR in the same task).

Refs: task feature/file-preview-caps.
2026-09-30 17:13:15 +00:00

53 lines
2.1 KiB
Go
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package core
import "encoding/json"
// 工具契约(4.8):内置、声明式 HTTP、插件工具统一走 ToolProvider 形态。
// Parameters 是 JSON Schema(draft-07 子集即可),调用参数按其校验。
type SourceKind string
const (
SourceBuiltin SourceKind = "builtin"
SourcePlugin SourceKind = "plugin"
SourceUser SourceKind = "user"
)
type ToolDesc struct {
Name string `json:"name"`
Description string `json:"description"`
Parameters json.RawMessage `json:"parameters,omitempty"`
Source SourceKind `json:"source"`
PluginID string `json:"pluginId,omitempty"`
HTTP *HTTPToolSpec `json:"http,omitempty"` // 声明式 HTTP 工具(无代码)
// Hidden 预留能力形态:默认不对模型与 /api/tools 列表可见,须运行时开关
// (如 runtime.fsTools)或管理动作开启后可用(提案 2026-09-30-file-preview-and-reserved-capabilities)。
Hidden bool `json:"hidden,omitempty"`
}
// HTTPToolSpec:无代码自定义工具(4.8)。模板变量 {{param.x}} 从调用参数注入。
type HTTPToolSpec struct {
Method string `json:"method"`
URL string `json:"url"`
Headers map[string]string `json:"headers,omitempty"`
BodyTemplate string `json:"bodyTemplate,omitempty"` // JSON 模板
AuthRef string `json:"authRef,omitempty"` // 设置中的密钥引用(settings key)
TimeoutMs int `json:"timeoutMs,omitempty"`
// ResultPath 从响应 JSON 中裁剪(jq 点路径);空取整个响应。
ResultPath string `json:"resultPath,omitempty"`
}
type ToolCallRequest struct {
CallID string `json:"callId"`
Name string `json:"name"`
Arguments json.RawMessage `json:"arguments,omitempty"`
}
type ToolCallResult struct {
CallID string `json:"callId"`
Status string `json:"status"` // ok | error
Output string `json:"output,omitempty"`
Truncated bool `json:"truncated,omitempty"`
Artifact *Artifact `json:"artifact,omitempty"` // 超长转工件
}