99 "os"
1010 "os/exec"
1111 "path/filepath"
12+ "reflect"
1213 "regexp"
1314 "slices"
1415 "strings"
@@ -99,6 +100,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
99100 },
100101 Required : []string {"path" },
101102 },
103+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
102104 },
103105 Handler : t .handleCreateDirectory ,
104106 },
@@ -124,6 +126,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
124126 },
125127 Required : []string {"path" },
126128 },
129+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [* TreeNode ]()),
127130 },
128131 Handler : t .handleDirectoryTree ,
129132 },
@@ -162,6 +165,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
162165 },
163166 Required : []string {"path" , "edits" },
164167 },
168+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
165169 },
166170 Handler : t .handleEditFile ,
167171 },
@@ -183,6 +187,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
183187 },
184188 Required : []string {"path" },
185189 },
190+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [FileInfo ]()),
186191 },
187192 Handler : t .handleGetFileInfo ,
188193 },
@@ -194,6 +199,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
194199 ReadOnlyHint : & []bool {true }[0 ],
195200 Title : "List Allowed Directories" ,
196201 },
202+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [[]string ]()),
197203 },
198204 Handler : t .handleListAllowedDirectories ,
199205 },
@@ -222,6 +228,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
222228 },
223229 Required : []string {"path" , "reason" },
224230 },
231+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
225232 },
226233 Handler : t .handleAddAllowedDirectory ,
227234 },
@@ -243,6 +250,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
243250 },
244251 Required : []string {"path" },
245252 },
253+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
246254 },
247255 Handler : t .handleListDirectory ,
248256 },
@@ -264,6 +272,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
264272 },
265273 Required : []string {"path" },
266274 },
275+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
267276 },
268277 Handler : t .handleListDirectoryWithSizes ,
269278 },
@@ -288,6 +297,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
288297 },
289298 Required : []string {"source" , "destination" },
290299 },
300+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
291301 },
292302 Handler : t .handleMoveFile ,
293303 },
@@ -309,6 +319,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
309319 },
310320 Required : []string {"path" },
311321 },
322+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
312323 },
313324 Handler : t .handleReadFile ,
314325 },
@@ -337,6 +348,8 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
337348 },
338349 Required : []string {"paths" },
339350 },
351+ // TODO(dga): depends on the json param
352+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
340353 },
341354 Handler : t .handleReadMultipleFiles ,
342355 },
@@ -369,6 +382,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
369382 },
370383 Required : []string {"path" , "pattern" },
371384 },
385+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
372386 },
373387 Handler : t .handleSearchFiles ,
374388 },
@@ -405,6 +419,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
405419 },
406420 Required : []string {"path" , "query" },
407421 },
422+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
408423 },
409424 Handler : t .handleSearchFilesContent ,
410425 },
@@ -429,6 +444,7 @@ func (t *FilesystemTool) Tools(context.Context) ([]tools.Tool, error) {
429444 },
430445 Required : []string {"path" , "content" },
431446 },
447+ OutputSchema : tools .ToOutputSchemaSchema (reflect .TypeFor [string ]()),
432448 },
433449 Handler : t .handleWriteFile ,
434450 },
@@ -640,6 +656,14 @@ func (t *FilesystemTool) handleEditFile(ctx context.Context, toolCall tools.Tool
640656 return & tools.ToolCallResult {Output : fmt .Sprintf ("File edited successfully. Changes:\n %s" , strings .Join (changes , "\n " ))}, nil
641657}
642658
659+ type FileInfo struct {
660+ Name string `json:"name"`
661+ Size int64 `json:"size"`
662+ Mode string `json:"mode"`
663+ ModTime string `json:"modTime"`
664+ IsDir bool `json:"isDir"`
665+ }
666+
643667func (t * FilesystemTool ) handleGetFileInfo (_ context.Context , toolCall tools.ToolCall ) (* tools.ToolCallResult , error ) {
644668 var args struct {
645669 Path string `json:"path"`
@@ -657,12 +681,12 @@ func (t *FilesystemTool) handleGetFileInfo(_ context.Context, toolCall tools.Too
657681 return & tools.ToolCallResult {Output : fmt .Sprintf ("Error getting file info: %s" , err )}, nil
658682 }
659683
660- fileInfo := map [ string ] any {
661- "name" : info .Name (),
662- "size" : info .Size (),
663- "mode" : info .Mode ().String (),
664- "modTime" : info .ModTime ().Format (time .RFC3339 ),
665- "isDir" : info .IsDir (),
684+ fileInfo := FileInfo {
685+ Name : info .Name (),
686+ Size : info .Size (),
687+ Mode : info .Mode ().String (),
688+ ModTime : info .ModTime ().Format (time .RFC3339 ),
689+ IsDir : info .IsDir (),
666690 }
667691
668692 result , err := json .MarshalIndent (fileInfo , "" , " " )
0 commit comments