()
| 181 | } |
| 182 | |
| 183 | func GetWriteTextFileToolDefinition() uctypes.ToolDefinition { |
| 184 | return uctypes.ToolDefinition{ |
| 185 | Name: "write_text_file", |
| 186 | DisplayName: "Write Text File", |
| 187 | Description: "Write a text file to the filesystem. Will create or overwrite the file. Maximum file size: 100KB.", |
| 188 | ToolLogName: "gen:writefile", |
| 189 | Strict: true, |
| 190 | InputSchema: map[string]any{ |
| 191 | "type": "object", |
| 192 | "properties": map[string]any{ |
| 193 | "filename": map[string]any{ |
| 194 | "type": "string", |
| 195 | "description": "Absolute path to the file to write. Supports '~' for the user's home directory. Relative paths are not supported.", |
| 196 | }, |
| 197 | "contents": map[string]any{ |
| 198 | "type": "string", |
| 199 | "description": "The contents to write to the file", |
| 200 | }, |
| 201 | }, |
| 202 | "required": []string{"filename", "contents"}, |
| 203 | "additionalProperties": false, |
| 204 | }, |
| 205 | ToolCallDesc: func(input any, output any, toolUseData *uctypes.UIMessageDataToolUse) string { |
| 206 | params, err := parseWriteTextFileInput(input) |
| 207 | if err != nil { |
| 208 | return fmt.Sprintf("error parsing input: %v", err) |
| 209 | } |
| 210 | return fmt.Sprintf("writing %q", params.Filename) |
| 211 | }, |
| 212 | ToolAnyCallback: writeTextFileCallback, |
| 213 | ToolApproval: func(input any) string { |
| 214 | return uctypes.ApprovalNeedsApproval |
| 215 | }, |
| 216 | ToolVerifyInput: verifyWriteTextFileInput, |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | type editTextFileParams struct { |
| 221 | Filename string `json:"filename"` |
no test coverage detected