remove stale web access override

This commit is contained in:
Advait Paliwal
2026-04-10 10:20:31 -07:00
parent 5b9362918e
commit 4137a29507
13 changed files with 115 additions and 3627 deletions

View File

@@ -1,6 +1,18 @@
import { getPiWebAccessStatus } from "../pi/web-access.js";
import {
getPiWebAccessStatus,
savePiWebAccessConfig,
type PiWebAccessConfig,
type PiWebSearchProvider,
} from "../pi/web-access.js";
import { printInfo } from "../ui/terminal.js";
const SEARCH_PROVIDERS: PiWebSearchProvider[] = ["auto", "perplexity", "exa", "gemini"];
const PROVIDER_API_KEY_FIELDS: Partial<Record<PiWebSearchProvider, keyof PiWebAccessConfig>> = {
perplexity: "perplexityApiKey",
exa: "exaApiKey",
gemini: "geminiApiKey",
};
export function printSearchStatus(): void {
const status = getPiWebAccessStatus();
printInfo("Managed by: pi-web-access");
@@ -12,3 +24,35 @@ export function printSearchStatus(): void {
printInfo(`Browser profile: ${status.chromeProfile ?? "default Chromium profile"}`);
printInfo(`Config path: ${status.configPath}`);
}
export function setSearchProvider(provider: PiWebSearchProvider, apiKey?: string): void {
if (!SEARCH_PROVIDERS.includes(provider)) {
throw new Error(`Usage: feynman search set <${SEARCH_PROVIDERS.join("|")}> [api-key]`);
}
if (apiKey !== undefined && provider === "auto") {
throw new Error("The auto provider does not use an API key. Usage: feynman search set auto");
}
const updates: Partial<Record<keyof PiWebAccessConfig, unknown>> = {
provider,
searchProvider: provider,
route: undefined,
};
const apiKeyField = PROVIDER_API_KEY_FIELDS[provider];
if (apiKeyField && apiKey !== undefined) {
updates[apiKeyField] = apiKey;
}
savePiWebAccessConfig(updates);
const status = getPiWebAccessStatus();
console.log(`Web search provider set to ${status.routeLabel}.`);
console.log(`Config path: ${status.configPath}`);
}
export function clearSearchConfig(): void {
savePiWebAccessConfig({ provider: undefined, searchProvider: undefined, route: undefined });
const status = getPiWebAccessStatus();
console.log(`Web search provider reset to ${status.routeLabel}.`);
console.log(`Config path: ${status.configPath}`);
}