工具组合
  
工具集组合、过滤和技能编排 孔径堆栈 人工智能工具生态系统。
安装
go get github.com/jonwraymond/toolcompose@latest包裹
快速开始
工具集组成
import (
"github.com/jonwraymond/toolcompose/set"
"github.com/jonwraymond/toolfoundation/adapter"
)
// Create toolset from registry with filters and policy
ts, err := set.NewBuilder("my-toolset").
FromRegistry(registry).
WithNamespace("github").
WithFilter(set.TagsAll("read")).
WithPolicy(set.DenyTags("dangerous")).
Build()
// Export to protocol format
exposure := set.NewExposure(ts, adapter.NewMCPAdapter())
tools, err := exposure.Export()技能执行
import "github.com/jonwraymond/toolcompose/skill"
// Define a skill
s := skill.Skill{
Name: "create-issue",
Steps: []skill.Step{
{ID: "search", ToolID: "github:search", Inputs: map[string]any{"q": "bug"}},
{ID: "create", ToolID: "github:create-issue", Inputs: map[string]any{"title": "Fix bug"}},
},
}
// Plan and execute
planner := skill.NewPlanner()
plan, err := planner.Plan(s)
results, err := skill.Execute(ctx, plan, myRunner)特性
- 工具集组成:从注册表或工具切片构建筛选的工具集
- 过滤器链:使用AND语义组合过滤器
- 内置过滤器:命名空间、标记、作用域和自定义谓词
- 政策体系:使用DenyByDefault或AllowByDefault的允许/拒绝列表
- 协议暴露:导出为MCP、OpenAI或Anthropic格式
- 功能警告:检测转换过程中架构功能的丢失
- 技能规划:验证和规划多步骤工具序列
- 防护系统:最大步数、允许的工具ID和自定义防护装置
- 确定执行:可重复的测试结果
- 线程安全:工具集对并发读取是安全的
线程安全
| 类型 | 线程安全 | 注释 |
|---|---|---|
Toolset | 是 | 并发读取安全 |
Builder | 否 | 在单个goroutine中使用 |
Exposure | 是 | 施工后安全 |
Planner | 是 | 无状态,可以安全共享 |
Plan | 是 | 创建后不可变 |
文档
例子
go run ./examples/basic
go run ./examples/filter
go run ./examples/skill相关套餐
toolcompose是ApertureStack生态系统的一部分:
toolfoundation Core types, adapters, model definitions
│
v
tooldiscovery Search, indexing, semantic discovery
│
v
toolexec Execution, runtime isolation, backends
│
v
toolcompose Composition, filtering, skill orchestration (this package)许可证
MIT许可证-请参阅 许可证
