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.
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import type { AdapterContext, WebFetchProvider, WebSearchProvider } from "@rakazo/adapter-kit";
|
|
import { clampMaxChars, clampMaxResults } from "./web-limits.js";
|
|
|
|
export async function webSearchFromTool(
|
|
search: WebSearchProvider,
|
|
context: AdapterContext,
|
|
args: Record<string, unknown>,
|
|
) {
|
|
const query = String(args.query ?? "").trim();
|
|
if (!query) return { error: "query is required" };
|
|
try {
|
|
const results = await search.search(
|
|
{
|
|
query,
|
|
maxResults: clampMaxResults(args.maxResults),
|
|
signal: context.signal,
|
|
},
|
|
context,
|
|
);
|
|
return { results };
|
|
} catch (error) {
|
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
}
|
|
}
|
|
|
|
export async function webFetchFromTool(
|
|
fetchProvider: WebFetchProvider,
|
|
context: AdapterContext,
|
|
args: Record<string, unknown>,
|
|
) {
|
|
const url = String(args.url ?? "").trim();
|
|
if (!url) return { error: "url is required" };
|
|
try {
|
|
const result = await fetchProvider.fetch(
|
|
{
|
|
url,
|
|
maxChars: clampMaxChars(args.maxChars),
|
|
signal: context.signal,
|
|
},
|
|
context,
|
|
);
|
|
return result;
|
|
} catch (error) {
|
|
return { error: error instanceof Error ? error.message : String(error) };
|
|
}
|
|
}
|