(s string)
| 1095 | } |
| 1096 | |
| 1097 | func parseToolCallLine(s string) parsedResponse { |
| 1098 | parenIdx := strings.Index(s, "(") |
| 1099 | if parenIdx < 0 { |
| 1100 | toolName := strings.TrimSpace(s) |
| 1101 | if toolName != "" { |
| 1102 | return parsedResponse{ |
| 1103 | toolCall: &ToolCall{ |
| 1104 | Name: toolName, |
| 1105 | Params: make(map[string]interface{}), |
| 1106 | }, |
| 1107 | } |
| 1108 | } |
| 1109 | return parsedResponse{text: s} |
| 1110 | } |
| 1111 | |
| 1112 | toolName := strings.TrimSpace(s[:parenIdx]) |
| 1113 | |
| 1114 | closeIdx := strings.LastIndex(s, ")") |
| 1115 | if closeIdx <= parenIdx { |
| 1116 | closeIdx = len(s) |
| 1117 | } |
| 1118 | paramsStr := s[parenIdx+1 : closeIdx] |
| 1119 | |
| 1120 | params := parseParams(paramsStr) |
| 1121 | |
| 1122 | return parsedResponse{ |
| 1123 | toolCall: &ToolCall{ |
| 1124 | Name: toolName, |
| 1125 | Params: params, |
| 1126 | }, |
| 1127 | } |
| 1128 | } |
| 1129 | |
| 1130 | func parseParams(s string) map[string]interface{} { |
| 1131 | s = strings.TrimSpace(s) |
no test coverage detected