evOo-local/packages/adapters/src/web-provider-factory.ts
cynarAI 6c7eed7580 Initial clean evOo-local from f00577b
Fresh history cut from cynarAI/evoo antigravity-handoff/project-timeline
(Voice First + project timeline). Brand docs/titles as evOo; keep @rakazo/*
packages as tech debt. Excludes node_modules, caches, secrets, voice blobs.
2026-09-20 17:15:16 +02:00

35 lines
1.2 KiB
TypeScript

import type { WebProvider } from "@rakazo/adapter-kit";
import { FakeWebProvider } from "./fake-web.js";
import { KeylessHttpWebProvider } from "./keyless-http-web.js";
/**
* Resolve the deployment web provider.
*
* Pi 0.84 does not expose a provider-neutral callable native-search API we can
* compose without vendor branches at the tool layer. Default is keyless HTTP so
* core runs with no hosted search vendor. Inject a custom adapter (or set
* WEB_PROVIDER=fake in tests) without changing builtin tool names.
*/
export function resolveWebProviderKind(source: NodeJS.ProcessEnv = process.env): string {
const raw = source.WEB_PROVIDER?.trim().toLowerCase();
if (!raw || raw === "keyless" || raw === "keyless-http") return "keyless-http";
if (raw === "fake") return "fake";
return raw;
}
export function createWebProvider(
kind: string = resolveWebProviderKind(),
options?: ConstructorParameters<typeof KeylessHttpWebProvider>[0],
): WebProvider {
switch (kind) {
case "fake":
return new FakeWebProvider();
case "keyless-http":
case "keyless":
case "":
return new KeylessHttpWebProvider(options);
default:
throw new Error(`Unknown web provider "${kind}"`);
}
}