MCPcopy
hub / github.com/wavetermdev/waveterm / GetReadDirToolDefinition

Function GetReadDirToolDefinition

pkg/aiusechat/tools_readdir.go:123–173  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

121}
122
123func GetReadDirToolDefinition() uctypes.ToolDefinition {
124 return uctypes.ToolDefinition{
125 Name: "read_dir",
126 DisplayName: "Read Directory",
127 Description: "Read a directory from the filesystem and list its contents. Returns information about files and subdirectories including names, types, sizes, permissions, and modification times.",
128 ToolLogName: "gen:readdir",
129 Strict: false,
130 InputSchema: map[string]any{
131 "type": "object",
132 "properties": map[string]any{
133 "path": map[string]any{
134 "type": "string",
135 "description": "Absolute path to the directory to read. Supports '~' for the user's home directory. Relative paths are not supported.",
136 },
137 "max_entries": map[string]any{
138 "type": "integer",
139 "minimum": 1,
140 "maximum": 10000,
141 "default": 500,
142 "description": "Maximum number of entries to return. Defaults to 500, max 10000.",
143 },
144 },
145 "required": []string{"path"},
146 "additionalProperties": false,
147 },
148 ToolCallDesc: func(input any, output any, toolUseData *uctypes.UIMessageDataToolUse) string {
149 parsed, err := parseReadDirInput(input)
150 if err != nil {
151 return fmt.Sprintf("error parsing input: %v", err)
152 }
153
154 readFullDir := false
155 if output != nil {
156 if outputMap, ok := output.(map[string]any); ok {
157 _, wasTruncated := outputMap["truncated"]
158 readFullDir = !wasTruncated
159 }
160 }
161
162 if readFullDir {
163 return fmt.Sprintf("reading directory %q (entire directory)", parsed.Path)
164 }
165 return fmt.Sprintf("reading directory %q (max_entries: %d)", parsed.Path, *parsed.MaxEntries)
166 },
167 ToolAnyCallback: readDirCallback,
168 ToolApproval: func(input any) string {
169 return uctypes.ApprovalNeedsApproval
170 },
171 ToolVerifyInput: verifyReadDirInput,
172 }
173}

Callers 2

GenerateTabStateAndToolsFunction · 0.85

Calls 1

parseReadDirInputFunction · 0.85

Tested by 1