@iservu-inc/adf-cli 0.14.1 → 0.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -5,6 +5,17 @@ All notable changes to `@iservu-inc/adf-cli` will be documented in this file.
5
5
  The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
6
  and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
7
 
8
+ ## [0.14.2] - 2026-01-12
9
+
10
+ ### 🐛 Fix - Google Gemini API Validation
11
+
12
+ **Patch Release:** Fixed a bug where valid Google API keys were sometimes reported as invalid.
13
+
14
+ #### Fixed
15
+ - 🔧 **Improved Validation** - Switched Google API key validation to use the official SDK's `countTokens` method instead of a manual REST API call.
16
+ - 🔧 **URL Encoding** - Added `encodeURIComponent` to the API key in model fetching requests to handle special characters.
17
+ - 🔧 **Better Error Messaging** - Clearer error descriptions when a Google key fails validation.
18
+
8
19
  ## [0.14.1] - 2026-01-12
9
20
 
10
21
  ### 🚀 Integration - Project Context Synthesis in core CLI
@@ -215,20 +215,19 @@ async function validateAPIKeyWithProvider(provider, apiKey) {
215
215
  break;
216
216
 
217
217
  case 'google':
218
- const fetchGoogle = require('node-fetch');
219
- // Validate by fetching models list (validates key and shows available models)
220
- const googleResponse = await fetchGoogle(
221
- `https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`
222
- );
223
-
224
- if (!googleResponse.ok) {
225
- const errorText = await googleResponse.text();
226
- throw new Error(`HTTP ${googleResponse.status}: ${errorText || googleResponse.statusText}`);
227
- }
228
-
229
- const googleData = await googleResponse.json();
230
- if (!googleData.models || !Array.isArray(googleData.models) || googleData.models.length === 0) {
231
- throw new Error('No models available for this API key');
218
+ try {
219
+ const { GoogleGenerativeAI } = require('@google/generative-ai');
220
+ const genAI = new GoogleGenerativeAI(apiKey);
221
+ // Use gemini-1.5-flash as it's the most available model for validation
222
+ const model = genAI.getGenerativeModel({ model: 'gemini-1.5-flash' });
223
+ // countTokens is a metadata call that validates the API key without incurring costs
224
+ await model.countTokens("connectivity test");
225
+ } catch (error) {
226
+ // If SDK fails, provide a clearer error message
227
+ if (error.message.includes('API_KEY_INVALID') || error.message.includes('API key not found')) {
228
+ throw new Error('Invalid Google API key. Please check your key at https://aistudio.google.com/app/apikey');
229
+ }
230
+ throw error;
232
231
  }
233
232
  break;
234
233
 
@@ -332,7 +331,7 @@ async function fetchAvailableModels(provider, apiKey) {
332
331
 
333
332
  // Use Google's REST API to list available models
334
333
  const response = await fetch(
335
- `https://generativelanguage.googleapis.com/v1beta/models?key=${apiKey}`
334
+ `https://generativelanguage.googleapis.com/v1beta/models?key=${encodeURIComponent(apiKey)}`
336
335
  );
337
336
 
338
337
  if (!response.ok) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iservu-inc/adf-cli",
3
- "version": "0.14.1",
3
+ "version": "0.14.2",
4
4
  "description": "CLI tool for AgentDevFramework - AI-assisted development framework with multi-provider AI support",
5
5
  "main": "index.js",
6
6
  "bin": {