BuildReadArguments constructs the arguments map for a file-read tool invocation.
(sess *Session, toolName, filePath string)
| 194 | |
| 195 | // BuildReadArguments constructs the arguments map for a file-read tool invocation. |
| 196 | func BuildReadArguments(sess *Session, toolName, filePath string) map[string]any { |
| 197 | if sess == nil { |
| 198 | return map[string]any{"file_path": filePath} |
| 199 | } |
| 200 | |
| 201 | schema := findToolSchema(sess, toolName) |
| 202 | if schema != nil { |
| 203 | if props, ok := schema["properties"].(map[string]any); ok { |
| 204 | for _, key := range []string{"file_path", "path", "file", "filename"} { |
| 205 | if _, exists := props[key]; exists { |
| 206 | return map[string]any{key: filePath} |
| 207 | } |
| 208 | } |
| 209 | // Fall back to first string property. |
| 210 | for key, propRaw := range props { |
| 211 | if prop, ok := propRaw.(map[string]any); ok { |
| 212 | if t, _ := prop["type"].(string); t == "string" { |
| 213 | return map[string]any{key: filePath} |
| 214 | } |
| 215 | } |
| 216 | } |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | return map[string]any{"file_path": filePath} |
| 221 | } |
| 222 | |
| 223 | // BuildWriteArguments constructs the arguments map for a file-write tool invocation. |
| 224 | func BuildWriteArguments(sess *Session, toolName, filePath, content string) map[string]any { |