update pi
This commit is contained in:
@@ -211,12 +211,12 @@ function updateWidget(ctx: ExtensionContext): void {
|
||||
(resetMs > 0 ? theme.fg("dim", ` (resets in ${resetSec}s)`) : ""),
|
||||
);
|
||||
|
||||
ctx.ui.setWidget("web-activity", new Text(lines.join("\n"), 0, 0));
|
||||
ctx.ui.setWidget("web-activity", lines);
|
||||
}
|
||||
|
||||
function formatEntryLine(
|
||||
entry: ActivityEntry,
|
||||
theme: { fg: (color: string, text: string) => string },
|
||||
theme: ExtensionContext["ui"]["theme"],
|
||||
): string {
|
||||
const typeStr = entry.type === "api" ? "API" : "GET";
|
||||
const target =
|
||||
@@ -550,7 +550,7 @@ export default function (pi: ExtensionAPI) {
|
||||
} else {
|
||||
widgetUnsubscribe?.();
|
||||
widgetUnsubscribe = null;
|
||||
ctx.ui.setWidget("web-activity", null);
|
||||
ctx.ui.setWidget("web-activity", undefined);
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -598,7 +598,7 @@ export default function (pi: ExtensionAPI) {
|
||||
})),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params, signal, onUpdate, ctx) {
|
||||
async execute(_toolCallId, params, signal, onUpdate, ctx): Promise<any> {
|
||||
const queryList = params.queries ?? (params.query ? [params.query] : []);
|
||||
const isMultiQuery = queryList.length > 1;
|
||||
const shouldCurate = params.curate !== false && ctx?.hasUI !== false;
|
||||
@@ -613,7 +613,10 @@ export default function (pi: ExtensionAPI) {
|
||||
if (shouldCurate) {
|
||||
closeCurator();
|
||||
|
||||
const { promise, resolve: resolvePromise } = Promise.withResolvers<unknown>();
|
||||
let resolvePromise!: (value: unknown) => void;
|
||||
const promise = new Promise<unknown>((resolve) => {
|
||||
resolvePromise = resolve;
|
||||
});
|
||||
const includeContent = params.includeContent ?? false;
|
||||
const searchResults = new Map<number, QueryResultData>();
|
||||
const allUrls: string[] = [];
|
||||
@@ -637,7 +640,7 @@ export default function (pi: ExtensionAPI) {
|
||||
queryList,
|
||||
includeContent,
|
||||
numResults: params.numResults,
|
||||
recencyFilter: params.recencyFilter,
|
||||
recencyFilter: params.recencyFilter as "day" | "week" | "month" | "year" | undefined,
|
||||
domainFilter: params.domainFilter,
|
||||
availableProviders,
|
||||
defaultProvider,
|
||||
@@ -684,7 +687,7 @@ export default function (pi: ExtensionAPI) {
|
||||
const { answer, results } = await search(queryList[qi], {
|
||||
provider: defaultProvider as SearchProvider | undefined,
|
||||
numResults: params.numResults,
|
||||
recencyFilter: params.recencyFilter,
|
||||
recencyFilter: params.recencyFilter as "day" | "week" | "month" | "year" | undefined,
|
||||
domainFilter: params.domainFilter,
|
||||
signal,
|
||||
});
|
||||
@@ -754,7 +757,7 @@ export default function (pi: ExtensionAPI) {
|
||||
text = `${searchResults.size} searches (${totalSources} sources) · ${curateLabel} to review · sending in ${remaining}s`;
|
||||
}
|
||||
return {
|
||||
content: [{ type: "text", text }],
|
||||
content: [{ type: "text" as const, text }],
|
||||
details: {
|
||||
phase: "curate-window",
|
||||
searchCount: searchResults.size,
|
||||
@@ -824,7 +827,7 @@ export default function (pi: ExtensionAPI) {
|
||||
const { answer, results } = await search(query, {
|
||||
provider: resolvedProvider as SearchProvider | undefined,
|
||||
numResults: params.numResults,
|
||||
recencyFilter: params.recencyFilter,
|
||||
recencyFilter: params.recencyFilter as "day" | "week" | "month" | "year" | undefined,
|
||||
domainFilter: params.domainFilter,
|
||||
signal,
|
||||
});
|
||||
@@ -1117,7 +1120,10 @@ export default function (pi: ExtensionAPI) {
|
||||
`Use get_search_content({ responseId: "${responseId}", urlIndex: 0 }) for full content.`;
|
||||
}
|
||||
|
||||
const content: Array<{ type: string; text?: string; data?: string; mimeType?: string }> = [];
|
||||
const content: Array<
|
||||
| { type: "image"; data: string; mimeType: string }
|
||||
| { type: "text"; text: string }
|
||||
> = [];
|
||||
if (result.frames?.length) {
|
||||
for (const frame of result.frames) {
|
||||
content.push({ type: "image", data: frame.data, mimeType: frame.mimeType });
|
||||
@@ -1290,7 +1296,7 @@ export default function (pi: ExtensionAPI) {
|
||||
urlIndex: Type.Optional(Type.Number({ description: "Get content for URL at index" })),
|
||||
}),
|
||||
|
||||
async execute(_toolCallId, params) {
|
||||
async execute(_toolCallId, params, _signal, _onUpdate, _ctx): Promise<any> {
|
||||
const data = getResult(params.responseId);
|
||||
if (!data) {
|
||||
return {
|
||||
@@ -1477,7 +1483,7 @@ export default function (pi: ExtensionAPI) {
|
||||
pi.sendMessage({
|
||||
customType: "web-search-results",
|
||||
content: [{ type: "text", text }],
|
||||
display: "tool",
|
||||
display: true,
|
||||
details: { queryCount: results.length, totalResults: urls.length },
|
||||
}, { triggerTurn: true, deliverAs: "followUp" });
|
||||
}
|
||||
|
||||
@@ -42,9 +42,10 @@ export async function extractPDFToMarkdown(
|
||||
|
||||
const pdf = await getDocumentProxy(new Uint8Array(buffer));
|
||||
const metadata = await pdf.getMetadata();
|
||||
const info = (metadata.info ?? {}) as Record<string, unknown>;
|
||||
|
||||
// Extract title from metadata or URL
|
||||
const metaTitle = metadata.info?.Title as string | undefined;
|
||||
const metaTitle = typeof info.Title === "string" ? info.Title : undefined;
|
||||
const urlTitle = extractTitleFromURL(url);
|
||||
const title = metaTitle?.trim() || urlTitle;
|
||||
|
||||
@@ -79,8 +80,9 @@ export async function extractPDFToMarkdown(
|
||||
lines.push("");
|
||||
lines.push(`> Source: ${url}`);
|
||||
lines.push(`> Pages: ${pdf.numPages}${truncated ? ` (extracted first ${pagesToExtract})` : ""}`);
|
||||
if (metadata.info?.Author) {
|
||||
lines.push(`> Author: ${metadata.info.Author}`);
|
||||
const author = typeof info.Author === "string" ? info.Author : undefined;
|
||||
if (author) {
|
||||
lines.push(`> Author: ${author}`);
|
||||
}
|
||||
lines.push("");
|
||||
lines.push("---");
|
||||
|
||||
@@ -245,8 +245,8 @@ export async function condenseSearchResults(
|
||||
const model = ctx.modelRegistry.find(provider, modelId);
|
||||
if (!model) return null;
|
||||
|
||||
const apiKey = await ctx.modelRegistry.getApiKey(model);
|
||||
if (!apiKey) return null;
|
||||
const auth = await ctx.modelRegistry.getApiKeyAndHeaders(model);
|
||||
if (!auth.ok) return null;
|
||||
|
||||
const queryData = [...results.entries()]
|
||||
.sort((a, b) => a[0] - b[0])
|
||||
@@ -281,7 +281,8 @@ export async function condenseSearchResults(
|
||||
: timeoutSignal;
|
||||
|
||||
const response = await complete(model, aiContext, {
|
||||
apiKey,
|
||||
apiKey: auth.apiKey,
|
||||
headers: auth.headers,
|
||||
signal: combinedSignal,
|
||||
max_tokens: MAX_TOKENS,
|
||||
} as any);
|
||||
|
||||
Reference in New Issue
Block a user