MCPcopy Create free account
hub / github.com/53AI/53AIHub / executeListFiles

Function executeListFiles

api/service/tools/executor.go:1201–1237  ·  view source on GitHub ↗
(ctx context.Context, args map[string]interface{})

Source from the content-addressed store, hash-verified

1199}
1200
1201func executeListFiles(ctx context.Context, args map[string]interface{}) (*ToolResult, error) {
1202 path := "."
1203 if v, exists := args["path"]; exists {
1204 if p, ok := v.(string); ok && strings.TrimSpace(p) != "" {
1205 path = p
1206 }
1207 }
1208 if normalized, err := normalizeSandboxRelativePath(path); err == nil {
1209 path = normalized
1210 } else {
1211 return nil, err
1212 }
1213 req := sandboxclient.FileListRequest{
1214 Path: path,
1215 SessionID: resolveSandboxSessionID(ctx, args),
1216 Cwd: resolveSandboxCWD(ctx, args),
1217 Recursive: parseBoolValue(args["recursive"]),
1218 MaxEntries: parseIntValue(args["max_entries"], 200),
1219 }
1220 if files, err := buildSkillFilesForSandbox(ctx); err != nil {
1221 logger.Warnf(ctx, "Failed to build skill files for list_files: %v", err)
1222 } else if len(files) > 0 {
1223 req.Files = files
1224 }
1225 if err := ensureSandboxSessionSeeded(ctx, req.SessionID, req.Cwd); err != nil {
1226 return nil, err
1227 }
1228 resp, err := getSandboxClient().ListFiles(ctx, req)
1229 if err != nil {
1230 return nil, wrapSandboxServiceError(err)
1231 }
1232
1233 if len(resp.Entries) == 0 {
1234 return &ToolResult{Output: "(No files found)", ExitCode: 0}, nil
1235 }
1236 return &ToolResult{Output: strings.Join(resp.Entries, "\n"), ExitCode: 0}, nil
1237}
1238
1239func ParseToolArguments(argStr string) (map[string]interface{}, error) {
1240 var args map[string]interface{}

Callers 2

ExecuteToolWithResultFunction · 0.85
ExecuteToolStreamFunction · 0.85

Calls 11

resolveSandboxSessionIDFunction · 0.85
resolveSandboxCWDFunction · 0.85
parseBoolValueFunction · 0.85
parseIntValueFunction · 0.85
getSandboxClientFunction · 0.85
wrapSandboxServiceErrorFunction · 0.85
WarnfMethod · 0.80
ListFilesMethod · 0.65

Tested by

no test coverage detected