( ctx context.Context, conn workspacesdk.AgentConn, args AttachFileArgs, storeFile StoreFileFunc, )
| 46 | } |
| 47 | |
| 48 | func executeAttachFileTool( |
| 49 | ctx context.Context, |
| 50 | conn workspacesdk.AgentConn, |
| 51 | args AttachFileArgs, |
| 52 | storeFile StoreFileFunc, |
| 53 | ) (fantasy.ToolResponse, error) { |
| 54 | path := strings.TrimSpace(args.Path) |
| 55 | if path == "" { |
| 56 | return fantasy.NewTextErrorResponse("path is required (use an absolute path, e.g. /home/coder/build.log)"), nil |
| 57 | } |
| 58 | |
| 59 | attachment, size, err := storeWorkspaceAttachment( |
| 60 | ctx, |
| 61 | conn, |
| 62 | path, |
| 63 | strings.TrimSpace(args.Name), |
| 64 | storeFile, |
| 65 | ) |
| 66 | if err != nil { |
| 67 | return fantasy.NewTextErrorResponse(err.Error()), nil |
| 68 | } |
| 69 | |
| 70 | return WithAttachments(toolResponse(map[string]any{ |
| 71 | "ok": true, |
| 72 | "path": path, |
| 73 | "file_id": attachment.FileID.String(), |
| 74 | "name": attachment.Name, |
| 75 | "media_type": attachment.MediaType, |
| 76 | "size": size, |
| 77 | }), attachment), nil |
| 78 | } |
no test coverage detected