tools.go

  1package proto
  2
  3// ToolResponseType represents the type of tool response.
  4type ToolResponseType string
  5
  6const (
  7	ToolResponseTypeText  ToolResponseType = "text"
  8	ToolResponseTypeImage ToolResponseType = "image"
  9)
 10
 11// ToolResponse represents a response from a tool.
 12type ToolResponse struct {
 13	Type     ToolResponseType `json:"type"`
 14	Content  string           `json:"content"`
 15	Metadata string           `json:"metadata,omitempty"`
 16	IsError  bool             `json:"is_error"`
 17}
 18
 19const BashToolName = "bash"
 20
 21// BashParams represents the parameters for the bash tool.
 22type BashParams struct {
 23	Command string `json:"command"`
 24	Timeout int    `json:"timeout"`
 25}
 26
 27// BashPermissionsParams represents the permission parameters for the bash tool.
 28type BashPermissionsParams struct {
 29	Command string `json:"command"`
 30	Timeout int    `json:"timeout"`
 31}
 32
 33// BashResponseMetadata represents the metadata for a bash tool response.
 34type BashResponseMetadata struct {
 35	StartTime        int64  `json:"start_time"`
 36	EndTime          int64  `json:"end_time"`
 37	Output           string `json:"output"`
 38	WorkingDirectory string `json:"working_directory"`
 39}
 40
 41// DiagnosticsParams represents the parameters for the diagnostics tool.
 42type DiagnosticsParams struct {
 43	FilePath string `json:"file_path"`
 44}
 45
 46const DownloadToolName = "download"
 47
 48// DownloadParams represents the parameters for the download tool.
 49type DownloadParams struct {
 50	URL      string `json:"url"`
 51	FilePath string `json:"file_path"`
 52	Timeout  int    `json:"timeout,omitempty"`
 53}
 54
 55// DownloadPermissionsParams represents the permission parameters for the download tool.
 56type DownloadPermissionsParams struct {
 57	URL      string `json:"url"`
 58	FilePath string `json:"file_path"`
 59	Timeout  int    `json:"timeout,omitempty"`
 60}
 61
 62const EditToolName = "edit"
 63
 64// EditParams represents the parameters for the edit tool.
 65type EditParams struct {
 66	FilePath   string `json:"file_path"`
 67	OldString  string `json:"old_string"`
 68	NewString  string `json:"new_string"`
 69	ReplaceAll bool   `json:"replace_all,omitempty"`
 70}
 71
 72// EditPermissionsParams represents the permission parameters for the edit tool.
 73type EditPermissionsParams struct {
 74	FilePath   string `json:"file_path"`
 75	OldContent string `json:"old_content,omitempty"`
 76	NewContent string `json:"new_content,omitempty"`
 77}
 78
 79// EditResponseMetadata represents the metadata for an edit tool response.
 80type EditResponseMetadata struct {
 81	Additions  int    `json:"additions"`
 82	Removals   int    `json:"removals"`
 83	OldContent string `json:"old_content,omitempty"`
 84	NewContent string `json:"new_content,omitempty"`
 85}
 86
 87const FetchToolName = "fetch"
 88
 89// FetchParams represents the parameters for the fetch tool.
 90type FetchParams struct {
 91	URL     string `json:"url"`
 92	Format  string `json:"format"`
 93	Timeout int    `json:"timeout,omitempty"`
 94}
 95
 96// FetchPermissionsParams represents the permission parameters for the fetch tool.
 97type FetchPermissionsParams struct {
 98	URL     string `json:"url"`
 99	Format  string `json:"format"`
100	Timeout int    `json:"timeout,omitempty"`
101}
102
103const GlobToolName = "glob"
104
105// GlobParams represents the parameters for the glob tool.
106type GlobParams struct {
107	Pattern string `json:"pattern"`
108	Path    string `json:"path"`
109}
110
111// GlobResponseMetadata represents the metadata for a glob tool response.
112type GlobResponseMetadata struct {
113	NumberOfFiles int  `json:"number_of_files"`
114	Truncated     bool `json:"truncated"`
115}
116
117const GrepToolName = "grep"
118
119// GrepParams represents the parameters for the grep tool.
120type GrepParams struct {
121	Pattern     string `json:"pattern"`
122	Path        string `json:"path"`
123	Include     string `json:"include"`
124	LiteralText bool   `json:"literal_text"`
125}
126
127// GrepResponseMetadata represents the metadata for a grep tool response.
128type GrepResponseMetadata struct {
129	NumberOfMatches int  `json:"number_of_matches"`
130	Truncated       bool `json:"truncated"`
131}
132
133const LSToolName = "ls"
134
135// LSParams represents the parameters for the ls tool.
136type LSParams struct {
137	Path   string   `json:"path"`
138	Ignore []string `json:"ignore"`
139}
140
141// LSPermissionsParams represents the permission parameters for the ls tool.
142type LSPermissionsParams struct {
143	Path   string   `json:"path"`
144	Ignore []string `json:"ignore"`
145}
146
147// TreeNode represents a node in a directory tree.
148type TreeNode struct {
149	Name     string      `json:"name"`
150	Path     string      `json:"path"`
151	Type     string      `json:"type"`
152	Children []*TreeNode `json:"children,omitempty"`
153}
154
155// LSResponseMetadata represents the metadata for an ls tool response.
156type LSResponseMetadata struct {
157	NumberOfFiles int  `json:"number_of_files"`
158	Truncated     bool `json:"truncated"`
159}
160
161const MultiEditToolName = "multiedit"
162
163// MultiEditOperation represents a single edit operation in a multi-edit.
164type MultiEditOperation struct {
165	OldString  string `json:"old_string"`
166	NewString  string `json:"new_string"`
167	ReplaceAll bool   `json:"replace_all,omitempty"`
168}
169
170// MultiEditParams represents the parameters for the multi-edit tool.
171type MultiEditParams struct {
172	FilePath string               `json:"file_path"`
173	Edits    []MultiEditOperation `json:"edits"`
174}
175
176// MultiEditPermissionsParams represents the permission parameters for the multi-edit tool.
177type MultiEditPermissionsParams struct {
178	FilePath   string `json:"file_path"`
179	OldContent string `json:"old_content,omitempty"`
180	NewContent string `json:"new_content,omitempty"`
181}
182
183// MultiEditResponseMetadata represents the metadata for a multi-edit tool response.
184type MultiEditResponseMetadata struct {
185	Additions    int    `json:"additions"`
186	Removals     int    `json:"removals"`
187	OldContent   string `json:"old_content,omitempty"`
188	NewContent   string `json:"new_content,omitempty"`
189	EditsApplied int    `json:"edits_applied"`
190}
191
192const SourcegraphToolName = "sourcegraph"
193
194// SourcegraphParams represents the parameters for the sourcegraph tool.
195type SourcegraphParams struct {
196	Query         string `json:"query"`
197	Count         int    `json:"count,omitempty"`
198	ContextWindow int    `json:"context_window,omitempty"`
199	Timeout       int    `json:"timeout,omitempty"`
200}
201
202// SourcegraphResponseMetadata represents the metadata for a sourcegraph tool response.
203type SourcegraphResponseMetadata struct {
204	NumberOfMatches int  `json:"number_of_matches"`
205	Truncated       bool `json:"truncated"`
206}
207
208const ViewToolName = "view"
209
210// ViewParams represents the parameters for the view tool.
211type ViewParams struct {
212	FilePath string `json:"file_path"`
213	Offset   int    `json:"offset"`
214	Limit    int    `json:"limit"`
215}
216
217// ViewPermissionsParams represents the permission parameters for the view tool.
218type ViewPermissionsParams struct {
219	FilePath string `json:"file_path"`
220	Offset   int    `json:"offset"`
221	Limit    int    `json:"limit"`
222}
223
224// ViewResponseMetadata represents the metadata for a view tool response.
225type ViewResponseMetadata struct {
226	FilePath string `json:"file_path"`
227	Content  string `json:"content"`
228}
229
230const WriteToolName = "write"
231
232// WriteParams represents the parameters for the write tool.
233type WriteParams struct {
234	FilePath string `json:"file_path"`
235	Content  string `json:"content"`
236}
237
238// WritePermissionsParams represents the permission parameters for the write tool.
239type WritePermissionsParams struct {
240	FilePath   string `json:"file_path"`
241	OldContent string `json:"old_content,omitempty"`
242	NewContent string `json:"new_content,omitempty"`
243}
244
245// WriteResponseMetadata represents the metadata for a write tool response.
246type WriteResponseMetadata struct {
247	Diff      string `json:"diff"`
248	Additions int    `json:"additions"`
249	Removals  int    `json:"removals"`
250}