Skip to content

Commit 6f57d83

Browse files
igorcostaAutohand Evolve
andcommitted
Integrate opt-in Keenable search with validated responses and stable setup
Co-authored-by: Autohand Evolve <code-noreply@autohand.ai>
2 parents f1fe17a + dd18a54 commit 6f57d83

25 files changed

Lines changed: 303 additions & 24 deletions

‎CHANGELOG.md‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,14 @@
44

55
### Added
66

7+
- Choose Keenable in `/search`, onboarding or settings with your own API key. Search results use the selected provider, and keys remain masked in the terminal.
8+
9+
### Fixed
10+
11+
- OpenAI-compatible fine-tuned and proxy models can recover once when their API requires a different completion-token parameter.
12+
13+
### Added
14+
715
- Squad MCP now also manages agent profiles, abilities, extra project folders, skills, group chats, channel membership and scheduled routines.
816
- Squad is built in as an MCP connection. Select an agent in the running app with `/squad`, send it direct messages with `/message`, and read conversation history and delivery receipts. The connection also reads Squad artifacts and memories.
917

‎docs/config-reference.md‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3237,7 +3237,7 @@ To register the native stdio agent in Zed, JetBrains IDEs, JetBrains Air, or ano
32373237
| Flag | Description |
32383238
| ----------------------------- | ---------------------------------------------------------------------------------------------- |
32393239
| `--display-language <locale>` | Set display language (e.g., en, id, zh-cn, fr, de, ja) |
3240-
| `--search-engine <provider>` | Set web search provider (browser-profile, exa, google, brave, duckduckgo, parallel) |
3240+
| `--search-engine <provider>` | Set web search provider (browser-profile, exa, google, brave, duckduckgo, parallel, keenable) |
32413241
| `--cc, --context-compact` | Enable context compaction (default: on) |
32423242
| `--no-cc, --no-context-compact` | Disable context compaction |
32433243

@@ -3672,11 +3672,11 @@ Fantail ignores this setting; local sessions do not advertise it.
36723672

36733673
## Web search
36743674

3675-
`search.provider` accepts `autohand`, `browser-profile`, `exa`, `brave`, `parallel`, `google`, and `duckduckgo`. An explicit `--search-engine` wins over the saved setting in interactive, patch, automatic, RPC, and ACP modes.
3675+
`search.provider` accepts `autohand`, `browser-profile`, `exa`, `brave`, `parallel`, `keenable`, `google`, and `duckduckgo`. An explicit `--search-engine` wins over the saved setting in interactive, patch, automatic, RPC, and ACP modes.
36763676

36773677
When no provider is selected, a signed-in account with server-verified access uses Autohand Web Search. Verified Free accounts include 10 web searches a day, shared with Code Web for the same account and reset at 00:00 UTC. `/search` shows the remaining allowance. At the cap, the tool returns the upgrade link and reset time, and the CLI prints that notice once per session. Lite, Pro, Pro Plus, Max, Team, and Enterprise retain their included search access. Queries are limited to 1,024 characters, 10 results, and 30 native requests per account per minute. Access uses the selected Autohand account and existing account credentials; customers do not need Cloudflare credentials. A failed hosted search reports its status and does not change providers.
36783678

3679-
Browser Profile is the local default. Connect Chromium through `/browser` or provide an available Chrome/Brave profile. Before launching the profile, Autohand checks its `SingletonLock`, including Chromium's symlink lock. With Chrome open, search uses the connected Chrome bridge first, then eligible Autohand Web Search, then one line directing you to `/search`. A locked profile with no fallback is not offered to the model. A closed profile keeps the existing browser search path. Exa, Brave, and Parallel require `search.exaApiKey`, `search.braveApiKey`, or `search.parallelApiKey`, respectively, or `EXA_API_KEY`, `BRAVE_SEARCH_API_KEY`, or `PARALLEL_API_KEY`. Onboarding never saves a keyed provider with a blank key. Google and DuckDuckGo can be selected explicitly; automated requests may receive CAPTCHA challenges.
3679+
Browser Profile is the local default. Connect Chromium through `/browser` or provide an available Chrome/Brave profile. Before launching the profile, Autohand checks its `SingletonLock`, including Chromium's symlink lock. With Chrome open, search uses the connected Chrome bridge first, then eligible Autohand Web Search, then one line directing you to `/search`. A locked profile with no fallback is not offered to the model. A closed profile keeps the existing browser search path. Exa, Brave, Parallel, and Keenable require `search.exaApiKey`, `search.braveApiKey`, `search.parallelApiKey`, or `search.keenableApiKey`, respectively, or `EXA_API_KEY`, `BRAVE_SEARCH_API_KEY`, `PARALLEL_API_KEY`, or `KEENABLE_API_KEY`. Onboarding never saves a keyed provider with a blank key. Google and DuckDuckGo can be selected explicitly; automated requests may receive CAPTCHA challenges.
36803680

36813681

36823682
Startup authentication validation updates only the credential it checked. If a settings command or another terminal changes the shared configuration while validation is pending, the validation result preserves the newer settings and login. Configuration writes use the same file lock and atomic replacement across JSON, YAML, and TOML files.

‎src/actions/web.ts‎

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
*/
99

1010
import * as https from 'https';
11+
import { z } from 'zod';
12+
import { resolveSearchApiKey } from '../search/providers.js';
1113
import * as http from 'http';
1214
import { existsSync, lstatSync, readdirSync } from 'fs';
1315
import { homedir } from 'node:os';
@@ -76,6 +78,7 @@ export interface SearchConfig {
7678
braveApiKey?: string;
7779
parallelApiKey?: string;
7880
exaApiKey?: string;
81+
keenableApiKey?: string;
7982
}
8083

8184
/** Global search configuration - set by the agent at startup */
@@ -110,6 +113,7 @@ export function configureSearchFromSettings(
110113
braveApiKey: settings.braveApiKey ?? process.env.BRAVE_SEARCH_API_KEY,
111114
parallelApiKey: settings.parallelApiKey ?? process.env.PARALLEL_API_KEY,
112115
exaApiKey: settings.exaApiKey ?? process.env.EXA_API_KEY,
116+
keenableApiKey: resolveSearchApiKey(settings.keenableApiKey, process.env.KEENABLE_API_KEY),
113117
});
114118
}
115119

@@ -182,13 +186,15 @@ export function getSearchConfig(): SearchConfig {
182186
* - Exa is selected AND has an API key
183187
* - Brave is selected AND has an API key
184188
* - Parallel is selected AND has an API key
189+
* - Keenable is selected AND has an API key
185190
* - Google is selected (no key required, more reliable than DDG)
186191
*/
187192
export function isSearchConfigured(): boolean {
188193
const config = getSearchConfig();
189194
const braveKey = config.braveApiKey ?? process.env.BRAVE_SEARCH_API_KEY;
190195
const parallelKey = config.parallelApiKey ?? process.env.PARALLEL_API_KEY;
191196
const exaKey = config.exaApiKey ?? process.env.EXA_API_KEY;
197+
const keenableKey = resolveSearchApiKey(config.keenableApiKey, process.env.KEENABLE_API_KEY);
192198

193199
switch (config.provider) {
194200
case 'autohand':
@@ -204,6 +210,8 @@ export function isSearchConfigured(): boolean {
204210
return !!braveKey;
205211
case 'parallel':
206212
return !!parallelKey;
213+
case 'keenable':
214+
return !!keenableKey;
207215
case 'google':
208216
return true; // Google scraping doesn't need an API key
209217
case 'duckduckgo':
@@ -652,6 +660,7 @@ export async function webSearch(query: string, options: WebSearchOptions = {}):
652660
const braveApiKey = globalSearchConfig.braveApiKey ?? process.env.BRAVE_SEARCH_API_KEY;
653661
const parallelApiKey = globalSearchConfig.parallelApiKey ?? process.env.PARALLEL_API_KEY;
654662
const exaApiKey = globalSearchConfig.exaApiKey ?? process.env.EXA_API_KEY;
663+
const keenableApiKey = resolveSearchApiKey(globalSearchConfig.keenableApiKey, process.env.KEENABLE_API_KEY);
655664

656665
switch (provider) {
657666
case 'autohand':
@@ -692,6 +701,15 @@ export async function webSearch(query: string, options: WebSearchOptions = {}):
692701
}
693702
return parallelSearch(enhancedQuery, parallelApiKey, maxResults, options.signal);
694703

704+
case 'keenable':
705+
if (!keenableApiKey) {
706+
throw new Error(
707+
'Keenable Search requires an API key. Configure it with /search or set KEENABLE_API_KEY environment variable. ' +
708+
'Get an API key at: https://keenable.ai'
709+
);
710+
}
711+
return keenableSearch(enhancedQuery, keenableApiKey, maxResults, options.signal);
712+
695713
case 'google':
696714
return googleSearch(enhancedQuery, maxResults, options.signal);
697715

@@ -912,6 +930,59 @@ async function parallelSearch(
912930
return results;
913931
}
914932

933+
const keenableResponseSchema = z.object({ results: z.array(z.object({
934+
title: z.string().optional(), url: z.string().optional(), description: z.string().optional(), snippet: z.string().optional(),
935+
})) });
936+
937+
/**
938+
* Search using the Keenable Search API
939+
*/
940+
export async function keenableSearch(
941+
query: string,
942+
apiKey: string,
943+
maxResults: number,
944+
signal?: AbortSignal,
945+
): Promise<WebSearchResult[]> {
946+
const postData = JSON.stringify({ query, max_results: maxResults });
947+
const response = await simpleRequest('https://api.keenable.ai/v1/search', {
948+
method: 'POST',
949+
body: postData,
950+
timeout: 30000,
951+
maxLength: 500000,
952+
signal,
953+
headers: {
954+
'Content-Type': 'application/json',
955+
'Content-Length': String(Buffer.byteLength(postData)),
956+
'X-API-Key': apiKey,
957+
'X-Keenable-Title': 'Autohand Code CLI',
958+
},
959+
});
960+
if (response.statusCode && response.statusCode >= 400) {
961+
throw new Error(`Keenable API error: HTTP ${response.statusCode} - ${response.body}`);
962+
}
963+
964+
let payload: unknown;
965+
try {
966+
payload = JSON.parse(response.body);
967+
} catch (parseError) {
968+
throw new Error(`Failed to parse Keenable response: ${parseError instanceof Error ? parseError.message : String(parseError)}`);
969+
}
970+
const parsed = keenableResponseSchema.safeParse(payload);
971+
if (!parsed.success) throw new Error('Invalid Keenable search response');
972+
973+
const results: WebSearchResult[] = [];
974+
for (const result of parsed.data.results.slice(0, maxResults)) {
975+
if (!result.url) continue;
976+
results.push({
977+
title: result.title || result.url,
978+
url: result.url,
979+
// Prefer the short description; fall back to a truncated page excerpt.
980+
snippet: result.description || result.snippet?.slice(0, 500) || '',
981+
});
982+
}
983+
return results;
984+
}
985+
915986
/**
916987
* Search using Brave Search API
917988
*/

‎src/commands/search.ts‎

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import chalk from 'chalk';
77
import { showModal, showPassword, type ModalOption } from '../ui/ink/components/Modal.js';
88
import { configureSearch, configureSearchFromAccount, getSearchConfig } from '../actions/web.js';
99
import { saveConfig } from '../config.js';
10-
import { SEARCH_PROVIDER_OPTIONS } from '../search/providers.js';
10+
import { SEARCH_PROVIDER_OPTIONS, SEARCH_PROVIDERS, resolveSearchApiKey } from '../search/providers.js';
1111
import { ManagedWebSearch, managedSearchIdentity } from '../search/managedWebSearch.js';
1212
import type { LoadedConfig, SearchProvider } from '../types.js';
1313

@@ -30,10 +30,12 @@ export async function search(ctx: SearchContext): Promise<string | null> {
3030
const braveKeySet = !!(currentConfig.braveApiKey || process.env.BRAVE_SEARCH_API_KEY);
3131
const parallelKeySet = !!(currentConfig.parallelApiKey || process.env.PARALLEL_API_KEY);
3232
const exaKeySet = !!(currentConfig.exaApiKey || process.env.EXA_API_KEY);
33+
const keenableKeySet = !!resolveSearchApiKey(currentConfig.keenableApiKey, process.env.KEENABLE_API_KEY);
3334

3435
console.log(chalk.gray(`Brave API key: ${braveKeySet ? chalk.green('configured') : chalk.yellow('not set')}`));
3536
console.log(chalk.gray(`Parallel API key: ${parallelKeySet ? chalk.green('configured') : chalk.yellow('not set')}`));
3637
console.log(chalk.gray(`Exa API key: ${exaKeySet ? chalk.green('configured') : chalk.yellow('not set')}`));
38+
console.log(chalk.gray(`Keenable API key: ${keenableKeySet ? chalk.green('configured') : chalk.yellow('not set')}`));
3739
console.log();
3840

3941
// Provider selection
@@ -69,6 +71,7 @@ export async function search(ctx: SearchContext): Promise<string | null> {
6971
let braveApiKey = currentConfig.braveApiKey;
7072
let parallelApiKey = currentConfig.parallelApiKey;
7173
let exaApiKey = currentConfig.exaApiKey;
74+
let keenableApiKey = currentConfig.keenableApiKey;
7275

7376
if (provider === 'exa' && !exaKeySet) {
7477
console.log(chalk.gray('\nGet your Exa.ai API key at: https://exa.ai\n'));
@@ -115,12 +118,28 @@ export async function search(ctx: SearchContext): Promise<string | null> {
115118
}
116119
}
117120

121+
if (provider === 'keenable' && !keenableKeySet) {
122+
console.log(chalk.gray('\nGet your Keenable API key at: https://keenable.ai\n'));
123+
124+
const apiKey = await showPassword({
125+
title: 'Enter Keenable API key:'
126+
});
127+
128+
if (apiKey?.trim()) {
129+
keenableApiKey = apiKey.trim();
130+
} else {
131+
console.log(chalk.yellow('No API key entered. Keenable Search will not work without an API key.'));
132+
return null;
133+
}
134+
}
135+
118136
// Update runtime configuration
119137
configureSearch({
120138
provider,
121139
braveApiKey,
122140
parallelApiKey,
123141
exaApiKey,
142+
keenableApiKey,
124143
});
125144

126145
// Save to config file
@@ -130,6 +149,7 @@ export async function search(ctx: SearchContext): Promise<string | null> {
130149
braveApiKey,
131150
parallelApiKey,
132151
exaApiKey,
152+
keenableApiKey,
133153
};
134154
await saveConfig(config);
135155
await configureSearchFromAccount(config, provider);
@@ -172,6 +192,6 @@ export async function search(ctx: SearchContext): Promise<string | null> {
172192

173193
export const metadata = {
174194
command: '/search',
175-
description: 'configure web search provider (autohand, browser-profile, exa, google, brave, duckduckgo, parallel)',
195+
description: `configure web search provider (${SEARCH_PROVIDERS.join(', ')})`,
176196
implemented: true,
177197
};

‎src/commands/settings.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ export const SETTINGS_REGISTRY: SettingDef[] = [
250250
{ key: 'search.provider', labelKey: 'commands.settings.search.provider', descriptionKey: 'commands.settings.search.providerDesc', category: 'search', type: 'enum', enumValues: [...SEARCH_PROVIDERS], defaultValue: 'browser-profile' },
251251
{ key: 'search.braveApiKey', labelKey: 'commands.settings.search.braveApiKey', descriptionKey: 'commands.settings.search.braveApiKeyDesc', category: 'search', type: 'password' },
252252
{ key: 'search.parallelApiKey', labelKey: 'commands.settings.search.parallelApiKey', descriptionKey: 'commands.settings.search.parallelApiKeyDesc', category: 'search', type: 'password' },
253+
{ key: 'search.keenableApiKey', labelKey: 'commands.settings.search.keenableApiKey', descriptionKey: 'commands.settings.search.keenableApiKeyDesc', category: 'search', type: 'password' },
253254
{ key: 'search.exaApiKey', labelKey: 'commands.settings.search.exaApiKey', descriptionKey: 'commands.settings.search.exaApiKeyDesc', category: 'search', type: 'password' },
254255
];
255256

‎src/i18n/locales/cs.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@
275275
"braveApiKey": "Brave API klíč",
276276
"braveApiKeyDesc": "API klíč pro Brave Search",
277277
"parallelApiKey": "Parallel API klíč",
278-
"parallelApiKeyDesc": "API klíč pro Parallel.ai"
278+
"parallelApiKeyDesc": "API klíč pro Parallel.ai",
279+
"keenableApiKey": "Keenable API key",
280+
"keenableApiKeyDesc": "API key for Keenable"
279281
}
280282
},
281283
"status": {

‎src/i18n/locales/de.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@
275275
"braveApiKey": "Brave API-Schlüssel",
276276
"braveApiKeyDesc": "API-Schlüssel für Brave Search",
277277
"parallelApiKey": "Parallel API-Schlüssel",
278-
"parallelApiKeyDesc": "API-Schlüssel für Parallel.ai"
278+
"parallelApiKeyDesc": "API-Schlüssel für Parallel.ai",
279+
"keenableApiKey": "Keenable API key",
280+
"keenableApiKeyDesc": "API key for Keenable"
279281
}
280282
},
281283
"status": {

‎src/i18n/locales/en.json‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -351,6 +351,8 @@
351351
"braveApiKeyDesc": "API key for Brave Search",
352352
"parallelApiKey": "Parallel API key",
353353
"parallelApiKeyDesc": "API key for Parallel.ai",
354+
"keenableApiKey": "Keenable API key",
355+
"keenableApiKeyDesc": "API key for Keenable",
354356
"exaApiKey": "Exa API key",
355357
"exaApiKeyDesc": "API key for Exa.ai"
356358
}

‎src/i18n/locales/fr.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@
275275
"braveApiKey": "Clé API Brave",
276276
"braveApiKeyDesc": "Clé API pour Brave Search",
277277
"parallelApiKey": "Clé API Parallel",
278-
"parallelApiKeyDesc": "Clé API pour Parallel.ai"
278+
"parallelApiKeyDesc": "Clé API pour Parallel.ai",
279+
"keenableApiKey": "Keenable API key",
280+
"keenableApiKeyDesc": "API key for Keenable"
279281
}
280282
},
281283
"status": {

‎src/i18n/locales/hu.json‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,9 @@
275275
"braveApiKey": "Brave API kulcs",
276276
"braveApiKeyDesc": "API kulcs a Brave Searchhez",
277277
"parallelApiKey": "Parallel API kulcs",
278-
"parallelApiKeyDesc": "API kulcs a Parallel.ai-hoz"
278+
"parallelApiKeyDesc": "API kulcs a Parallel.ai-hoz",
279+
"keenableApiKey": "Keenable API key",
280+
"keenableApiKeyDesc": "API key for Keenable"
279281
}
280282
},
281283
"status": {

0 commit comments

Comments
 (0)