fix: unblock unattended research workflows
This commit is contained in:
@@ -3,11 +3,13 @@ import { dirname, resolve } from "node:path";
|
||||
import { getFeynmanHome } from "../config/paths.js";
|
||||
|
||||
export type PiWebSearchProvider = "auto" | "perplexity" | "exa" | "gemini";
|
||||
export type PiWebSearchWorkflow = "none" | "summary-review";
|
||||
|
||||
export type PiWebAccessConfig = Record<string, unknown> & {
|
||||
route?: PiWebSearchProvider;
|
||||
provider?: PiWebSearchProvider;
|
||||
searchProvider?: PiWebSearchProvider;
|
||||
workflow?: PiWebSearchWorkflow;
|
||||
perplexityApiKey?: string;
|
||||
exaApiKey?: string;
|
||||
geminiApiKey?: string;
|
||||
@@ -18,6 +20,7 @@ export type PiWebAccessStatus = {
|
||||
configPath: string;
|
||||
searchProvider: PiWebSearchProvider;
|
||||
requestProvider: PiWebSearchProvider;
|
||||
workflow: PiWebSearchWorkflow;
|
||||
perplexityConfigured: boolean;
|
||||
exaConfigured: boolean;
|
||||
geminiApiConfigured: boolean;
|
||||
@@ -35,6 +38,10 @@ function normalizeProvider(value: unknown): PiWebSearchProvider | undefined {
|
||||
return value === "auto" || value === "perplexity" || value === "exa" || value === "gemini" ? value : undefined;
|
||||
}
|
||||
|
||||
function normalizeWorkflow(value: unknown): PiWebSearchWorkflow | undefined {
|
||||
return value === "none" || value === "summary-review" ? value : undefined;
|
||||
}
|
||||
|
||||
function normalizeNonEmptyString(value: unknown): string | undefined {
|
||||
return typeof value === "string" && value.trim().length > 0 ? value.trim() : undefined;
|
||||
}
|
||||
@@ -102,6 +109,7 @@ export function getPiWebAccessStatus(
|
||||
const searchProvider =
|
||||
normalizeProvider(config.searchProvider) ?? normalizeProvider(config.route) ?? normalizeProvider(config.provider) ?? "auto";
|
||||
const requestProvider = normalizeProvider(config.provider) ?? normalizeProvider(config.route) ?? searchProvider;
|
||||
const workflow = normalizeWorkflow(config.workflow) ?? "none";
|
||||
const perplexityConfigured = Boolean(normalizeNonEmptyString(config.perplexityApiKey));
|
||||
const exaConfigured = Boolean(normalizeNonEmptyString(config.exaApiKey));
|
||||
const geminiApiConfigured = Boolean(normalizeNonEmptyString(config.geminiApiKey));
|
||||
@@ -112,6 +120,7 @@ export function getPiWebAccessStatus(
|
||||
configPath,
|
||||
searchProvider,
|
||||
requestProvider,
|
||||
workflow,
|
||||
perplexityConfigured,
|
||||
exaConfigured,
|
||||
geminiApiConfigured,
|
||||
@@ -128,6 +137,7 @@ export function formatPiWebAccessDoctorLines(
|
||||
"web access: pi-web-access",
|
||||
` search route: ${status.routeLabel}`,
|
||||
` request route: ${status.requestProvider}`,
|
||||
` search workflow: ${status.workflow}`,
|
||||
` perplexity api: ${status.perplexityConfigured ? "configured" : "not configured"}`,
|
||||
` exa api: ${status.exaConfigured ? "configured" : "not configured"}`,
|
||||
` gemini api: ${status.geminiApiConfigured ? "configured" : "not configured"}`,
|
||||
|
||||
@@ -18,6 +18,7 @@ export function printSearchStatus(): void {
|
||||
printInfo("Managed by: pi-web-access");
|
||||
printInfo(`Search route: ${status.routeLabel}`);
|
||||
printInfo(`Request route: ${status.requestProvider}`);
|
||||
printInfo(`Search workflow: ${status.workflow}`);
|
||||
printInfo(`Perplexity API configured: ${status.perplexityConfigured ? "yes" : "no"}`);
|
||||
printInfo(`Exa API configured: ${status.exaConfigured ? "yes" : "no"}`);
|
||||
printInfo(`Gemini API configured: ${status.geminiApiConfigured ? "yes" : "no"}`);
|
||||
@@ -36,6 +37,7 @@ export function setSearchProvider(provider: PiWebSearchProvider, apiKey?: string
|
||||
const updates: Partial<Record<keyof PiWebAccessConfig, unknown>> = {
|
||||
provider,
|
||||
searchProvider: provider,
|
||||
workflow: "none",
|
||||
route: undefined,
|
||||
};
|
||||
const apiKeyField = PROVIDER_API_KEY_FIELDS[provider];
|
||||
@@ -50,7 +52,7 @@ export function setSearchProvider(provider: PiWebSearchProvider, apiKey?: string
|
||||
}
|
||||
|
||||
export function clearSearchConfig(): void {
|
||||
savePiWebAccessConfig({ provider: undefined, searchProvider: undefined, route: undefined });
|
||||
savePiWebAccessConfig({ provider: undefined, searchProvider: undefined, route: undefined, workflow: "none" });
|
||||
|
||||
const status = getPiWebAccessStatus();
|
||||
console.log(`Web search provider reset to ${status.routeLabel}.`);
|
||||
|
||||
Reference in New Issue
Block a user