bug fixes, and performance improvements, and drawer

This commit is contained in:
Zoe
2026-09-27 18:44:51 -05:00
parent d48d8163a7
commit 2b9f8d64d7
52 changed files with 4913 additions and 778 deletions
+4 -2
View File
@@ -21,6 +21,7 @@ export const formatToolValue = (stored: StoredToolValue): string => {
};
export interface SearchSource {
sourceId?: string;
title: string;
url: string;
hostname: string;
@@ -41,7 +42,7 @@ export const readSearchWarnings = (value: unknown): { engine: string; reason: st
});
};
export const readSearchSources = (value: unknown): SearchSource[] | null => {
export const readSearchSources = (value: unknown, options: { deduplicate?: boolean } = {}): SearchSource[] | null => {
// Older tool calls stored the results array directly.
if (typeof value === "object" && value !== null && "results" in value) {
value = value.results;
@@ -65,11 +66,12 @@ export const readSearchSources = (value: unknown): SearchSource[] | null => {
continue;
}
url.hash = "";
if (seen.has(url.href)) {
if (options.deduplicate !== false && seen.has(url.href)) {
continue;
}
seen.add(url.href);
sources.push({
...("sourceId" in item && typeof item.sourceId === "string" ? { sourceId: item.sourceId } : {}),
title: "title" in item && typeof item.title === "string" ? item.title : url.hostname,
url: url.href,
hostname: url.hostname,