(options ReadFileOptions)
| 19 | } |
| 20 | |
| 21 | func ReadFile(options ReadFileOptions) fantasy.AgentTool { |
| 22 | return fantasy.NewAgentTool( |
| 23 | "read_file", |
| 24 | "Read a file from the workspace. Returns line-numbered content. "+ |
| 25 | "The offset parameter is a 1-based line number (default: 1). "+ |
| 26 | "The limit parameter is the number of lines to return (default: 2000). "+ |
| 27 | "For large files, use offset and limit to paginate.", |
| 28 | func(ctx context.Context, args ReadFileArgs, _ fantasy.ToolCall) (fantasy.ToolResponse, error) { |
| 29 | if options.GetWorkspaceConn == nil { |
| 30 | return fantasy.NewTextErrorResponse("workspace connection resolver is not configured"), nil |
| 31 | } |
| 32 | conn, err := options.GetWorkspaceConn(ctx) |
| 33 | if err != nil { |
| 34 | return fantasy.NewTextErrorResponse(err.Error()), nil |
| 35 | } |
| 36 | return executeReadFileTool(ctx, conn, args) |
| 37 | }, |
| 38 | ) |
| 39 | } |
| 40 | |
| 41 | func executeReadFileTool( |
| 42 | ctx context.Context, |
no test coverage detected