Documentation
¶
Overview ¶
tools 包定义 Leros 的最小 Tool 抽象。
当前阶段只提供基础接口和 agent 运行时注入的上下文信息。
Index ¶
- func ContextWithToolContext(ctx context.Context, toolCtx ToolContext) context.Context
- func DecodeInput(input json.RawMessage) (map[string]any, error)
- func JSONInput(value any) json.RawMessage
- func JSONString(value interface{}) (string, error)
- type BaseTool
- type Property
- type Registry
- type Schema
- type Tool
- type ToolContext
- type ToolMetadata
- type Validator
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ContextWithToolContext ¶
func ContextWithToolContext(ctx context.Context, toolCtx ToolContext) context.Context
ContextWithToolContext stores run-scoped tool context on a context.Context.
func DecodeInput ¶ added in v0.1.17
func DecodeInput(input json.RawMessage) (map[string]any, error)
DecodeInput decodes a tool JSON object for an implementation's internal use.
func JSONInput ¶ added in v0.1.17
func JSONInput(value any) json.RawMessage
JSONInput encodes a typed value at a tool protocol boundary.
func JSONString ¶
JSONString encodes structured tool output as the string payload returned to the model.
Types ¶
type BaseTool ¶
type BaseTool struct {
// contains filtered or unexported fields
}
BaseTool stores the LLM-facing metadata shared by concrete tools.
func NewBaseTool ¶
NewBaseTool creates a reusable metadata base for a concrete tool.
func (BaseTool) Description ¶
Description returns the LLM-facing tool description.
func (BaseTool) InputSchema ¶
InputSchema returns the tool argument schema.
type Property ¶
type Property struct {
Type string `json:"type"`
Description string `json:"description,omitempty"`
Enum []string `json:"enum,omitempty"`
Items *Property `json:"items,omitempty"`
}
Property describes a single field inside a tool schema.
type Registry ¶
type Registry struct {
// contains filtered or unexported fields
}
Registry 提供最小 Tool 注册与获取能力。
func (*Registry) AvailableToolNames ¶ added in v0.1.5
AvailableToolNames filters the given names to those registered.
type Schema ¶
type Schema struct {
Type string `json:"type"`
Required []string `json:"required,omitempty"`
Properties map[string]*Property `json:"properties,omitempty"`
}
Schema describes tool input or output in a provider-agnostic shape.
type Tool ¶
type Tool interface {
Name() string
Description() string
InputSchema() Schema
Execute(ctx context.Context, input json.RawMessage) (string, error)
}
Tool 是 Leros 的最小工具接口。
type ToolContext ¶
type ToolContext struct {
// RunID 是本次 agent 运行的唯一标识。
RunID string
// TraceID 是跨服务关联的分布式追踪标识。
TraceID string
// AssistantPublicID 是执行本次运行的助手public_id。
AssistantPublicID string
// UserID 是发起本次运行的人类用户标识。
UserID string
// AccountID 是租户或组织账号标识。
AccountID string
// Channel 是接收请求的交互渠道(如 "github"、"slack")。
Channel string
// ConversationID 是本次运行所属的会话标识。
ConversationID string
// ExternalID 是外部渠道中的发起者标识。
ExternalID string
// WorkNodeID 是执行本次运行时的工作节点标识。
WorkNodeID string
// WorkDir 是本次运行隔离工作区的绝对路径。
WorkDir string
// Metadata carries typed workspace data needed by business tools.
Metadata ToolMetadata
}
ToolContext 携带 agent runtime 注入的 run 级身份与会话元数据。
func RequireToolContext ¶
func RequireToolContext(ctx context.Context) (ToolContext, error)
RequireToolContext returns run-scoped tool context or an error when it is missing.
func ToolContextFrom ¶
func ToolContextFrom(ctx context.Context) (ToolContext, bool)
ToolContextFrom returns run-scoped tool context stored on ctx.
type ToolMetadata ¶ added in v0.1.17
type ToolMetadata struct {
RepoDir string
ArtifactManifestPath string
// SkillDir is the explicit per-run Skill catalog root. Tools must not fall
// back to the worker-wide directory when this is set.
SkillDir string
}
ToolMetadata contains optional run-scoped data shared with business tools.
type Validator ¶
type Validator interface {
Validate(input json.RawMessage) error
}
Validator is implemented by tools that perform local input validation before execution.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package artifact_declare provides a tool for declaring project artifacts produced during a task execution.
|
Package artifact_declare provides a tool for declaring project artifacts produced during a task execution. |
|
Package memory exposes Leros built-in memory as a runtime tool.
|
Package memory exposes Leros built-in memory as a runtime tool. |
|
Package nodetools provides worker-local tools for operating an assistant node.
|
Package nodetools provides worker-local tools for operating an assistant node. |
|
Package skillmanage exposes SkillStore mutations as a runtime tool.
|
Package skillmanage exposes SkillStore mutations as a runtime tool. |
|
Package skilluse provides the runtime tool for loading Leros skill documents.
|
Package skilluse provides the runtime tool for loading Leros skill documents. |
|
Package todo exposes the run-scoped runtime todo list as a Leros tool.
|
Package todo exposes the run-scoped runtime todo list as a Leros tool. |