|
1 | 1 | package v2 |
2 | 2 |
|
3 | | -import ( |
4 | | - "errors" |
5 | | - "strings" |
6 | | -) |
7 | | - |
8 | 3 | // Config represents the entire configuration file |
9 | 4 | type Config struct { |
10 | 5 | Version string `json:"version,omitempty" yaml:"version,omitempty"` |
@@ -72,58 +67,30 @@ type PostEditConfig struct { |
72 | 67 |
|
73 | 68 | // Toolset represents a tool configuration |
74 | 69 | type Toolset struct { |
75 | | - Type string `json:"type,omitempty" yaml:"type,omitempty"` |
76 | | - Ref string `json:"ref,omitempty" yaml:"ref,omitempty"` |
77 | | - Config any `json:"config,omitempty" yaml:"config,omitempty"` |
78 | | - Command string `json:"command,omitempty" yaml:"command,omitempty"` |
79 | | - Remote Remote `json:"remote,omitempty" yaml:"remote,omitempty"` |
80 | | - Args []string `json:"args,omitempty" yaml:"args,omitempty"` |
81 | | - Tools []string `json:"tools,omitempty" yaml:"tools,omitempty"` |
82 | | - Env map[string]string `json:"env,omitempty" yaml:"env,omitempty"` |
83 | | - |
84 | | - // For the think tool |
85 | | - Shared bool `json:"shared,omitempty" yaml:"shared,omitempty"` |
86 | | - // For the memory tool |
87 | | - Path string `json:"path,omitempty" yaml:"path,omitempty"` |
| 70 | + Type string `json:"type,omitempty" yaml:"type,omitempty"` |
| 71 | + Tools []string `json:"tools,omitempty" yaml:"tools,omitempty"` |
88 | 72 |
|
89 | | - // For the script tool |
90 | | - Shell map[string]ScriptShellToolConfig `json:"shell,omitempty" yaml:"shell,omitempty"` |
| 73 | + // For the `mcp` tool |
| 74 | + Command string `json:"command,omitempty" yaml:"command,omitempty"` |
| 75 | + Args []string `json:"args,omitempty" yaml:"args,omitempty"` |
| 76 | + Ref string `json:"ref,omitempty" yaml:"ref,omitempty"` |
| 77 | + Remote Remote `json:"remote,omitempty" yaml:"remote,omitempty"` |
| 78 | + Config any `json:"config,omitempty" yaml:"config,omitempty"` |
91 | 79 |
|
92 | | - // For the filesystem tool - post-edit commands |
93 | | - PostEdit []PostEditConfig `json:"post_edit,omitempty" yaml:"post_edit,omitempty"` |
94 | | -} |
| 80 | + // For `shell`, `script` or `mcp` tools |
| 81 | + Env map[string]string `json:"env,omitempty" yaml:"env,omitempty"` |
95 | 82 |
|
96 | | -// Ensure that either Command, Remote or Ref is set, but not all empty |
97 | | -func (t *Toolset) validate() error { |
98 | | - if len(t.Shell) > 0 && t.Type != "script" { |
99 | | - return errors.New("shell can only be used with type 'script'") |
100 | | - } |
101 | | - if t.Type != "mcp" { |
102 | | - return nil |
103 | | - } |
| 83 | + // For the `todo` tool |
| 84 | + Shared bool `json:"shared,omitempty" yaml:"shared,omitempty"` |
104 | 85 |
|
105 | | - count := 0 |
106 | | - if t.Command != "" { |
107 | | - count++ |
108 | | - } |
109 | | - if t.Remote.URL != "" { |
110 | | - count++ |
111 | | - } |
112 | | - if t.Ref != "" { |
113 | | - count++ |
114 | | - } |
115 | | - if count == 0 { |
116 | | - return errors.New("either command, remote or ref must be set") |
117 | | - } |
118 | | - if count > 1 { |
119 | | - return errors.New("either command, remote or ref must be set, but only one of those") |
120 | | - } |
| 86 | + // For the `memory` tool |
| 87 | + Path string `json:"path,omitempty" yaml:"path,omitempty"` |
121 | 88 |
|
122 | | - if t.Ref != "" && !strings.Contains(t.Ref, "docker:") { |
123 | | - return errors.New("only docker refs are supported for MCP tools, e.g., 'docker:context7'") |
124 | | - } |
| 89 | + // For the `script` tool |
| 90 | + Shell map[string]ScriptShellToolConfig `json:"shell,omitempty" yaml:"shell,omitempty"` |
125 | 91 |
|
126 | | - return nil |
| 92 | + // For the `filesystem` tool - post-edit commands |
| 93 | + PostEdit []PostEditConfig `json:"post_edit,omitempty" yaml:"post_edit,omitempty"` |
127 | 94 | } |
128 | 95 |
|
129 | 96 | func (t *Toolset) UnmarshalYAML(unmarshal func(any) error) error { |
|
0 commit comments