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

Function executeSandboxRuntimeReadFile

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

Source from the content-addressed store, hash-verified

307}
308
309func executeSandboxRuntimeReadFile(ctx context.Context, args map[string]interface{}) (*ToolResult, error) {
310 path, ok := args["path"].(string)
311 if !ok || strings.TrimSpace(path) == "" {
312 return nil, fmt.Errorf("missing path argument")
313 }
314 path, err := normalizeSandboxWorkspacePath(path)
315 if err != nil {
316 return nil, err
317 }
318 session, err := runtimeSessionForContext(ctx)
319 if err != nil {
320 return nil, err
321 }
322 rt, err := getSandboxRuntime()
323 if err != nil {
324 return nil, err
325 }
326 data, err := rt.ReadFile(ctx, session, path, int64(parseIntValue(args["max_bytes"], 0)))
327 if err != nil {
328 return nil, err
329 }
330 if len(data) == 0 {
331 return &ToolResult{Output: "(Empty file)", ExitCode: 0}, nil
332 }
333 return &ToolResult{Output: paginateReadFileContent(string(data), args), ExitCode: 0}, nil
334}
335
336func executeSandboxRuntimeWriteFile(ctx context.Context, args map[string]interface{}) (*ToolResult, error) {
337 return executeSandboxRuntimeWriteFileWithPathNormalizer(ctx, args, normalizeSandboxRuntimePath)

Callers 2

ExecuteToolWithResultFunction · 0.85
ExecuteToolStreamFunction · 0.85

Calls 7

runtimeSessionForContextFunction · 0.85
getSandboxRuntimeFunction · 0.85
parseIntValueFunction · 0.85
paginateReadFileContentFunction · 0.85
ErrorfMethod · 0.80
ReadFileMethod · 0.65

Tested by

no test coverage detected