aboutsummaryrefslogtreecommitdiff
path: root/src/domains/search
diff options
context:
space:
mode:
Diffstat (limited to 'src/domains/search')
-rw-r--r--src/domains/search/web-search.ts12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/domains/search/web-search.ts b/src/domains/search/web-search.ts
index e5d343d..41a0f36 100644
--- a/src/domains/search/web-search.ts
+++ b/src/domains/search/web-search.ts
@@ -9,6 +9,7 @@ import {
openIsolatedTab,
waitForIsolatedLoad,
} from "../isolated-tab";
+import { renderExpandableText } from "../render";
import { buildSerpExtractionExpr } from "./extract";
import { classifySerp, parseGoogleSerp, type SearchResult, type SerpExtraction } from "./google-serp";
@@ -81,13 +82,19 @@ export const webSearchTool = defineBrowserTool({
});
}
- const truncated = await applyTruncation(formatResults(args.query, results), "search");
+ const body = formatResults(args.query, results);
+ const truncated = await applyTruncation(body, "search");
return ok({
text: truncated.text,
details: {
results,
engine: "google",
query: args.query,
+ render: {
+ summary: `${results.length} result(s) · google · "${args.query}"`,
+ body,
+ ...(truncated.fullOutputPath !== undefined ? { fullOutputPath: truncated.fullOutputPath } : {}),
+ },
...(truncated.fullOutputPath !== undefined ? { fullOutputPath: truncated.fullOutputPath } : {}),
},
});
@@ -95,6 +102,9 @@ export const webSearchTool = defineBrowserTool({
await closeIsolatedTab(client, tab);
}
},
+ renderResult(result, expanded, theme) {
+ return renderExpandableText("web_search", result, expanded, theme);
+ },
});
const safeParse = (text: string): unknown => {