bug fixes, and performance improvements, and drawer
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user