repositories / pi-ext

pi-ext

bugabingas pi extensions

owned by admin

Lazy-loaded web fetch/search/map/image implementation modules at tool execution; import fell 69% Win32 and 78% WSL, 105 tests passed

4681aaedd4d2351d260e3de601a8dd4d059c4ffc

Oliver Krylow <o.krylow@isp-insoft.de> ·

SSH signature · not checked

Browse filesCompare with HEAD

Result: {"status":"keep","web_import_ms":68,"elapsed_s":144.4,"win32_start_reload_ms":7793.001,"win32_extension_tax_ms":4240.619,"win32_startup_ms":6189.694,"win32_reload_ms":1603.307,"wsl_start_reload_ms":1646.981,"wsl_extension_tax_ms":760.764,"wsl_web_import_ms":26}

Changed files (1)

extensions/web/index.ts

Modified
37 37 DEFAULT_TIMEOUT_MS,
38 38 type SearchResult,
39 39 } from "./constants.js";
40 -import { extractMainContent } from "./extract.js";
41 -import { fetchUrlStream } from "./fetch.js";
42 -import { filterLineMatches } from "./line-match.js";
43 -import { discoverSiteMap } from "./map.js";
44 -import { minimaxUnderstandImage } from "./minimax.js";
45 -import { runPandoc, runPandocFile } from "./pandoc.js";
46 -import { searchWeb } from "./search.js";
47 40 import { checkToolAvailability, spawnToText, TOOL_HINTS } from "./spawn.js";
48 41 import {
49 42 createMarkers,
50 43 type SpotlightMarkers,
51 44 wrapUntrusted,
52 45 } from "./spotlight.js";
53 -import { saveJsonResult } from "./store.js";
55 47 // ── Shared formatters ────────────────────────────────────────────────────
258 250 const dir = await createTempDir("pi-web-");
259 251 const tmpPath = join(dir, `input.${fromFormat}`);
260 252 await writeFile(tmpPath, data);
253 + const { runPandocFile } = await import("./pandoc.js");
261 254 const text = await runPandocFile(tmpPath, fromFormat, "plain");
262 255 return { text, tmpPath };
605 598 const hint = await checkToolAvailability("pandoc", TOOL_HINTS.pandoc);
606 599 if (hint) throw new Error(hint);
601 + const [{ extractMainContent }, { runPandoc }] = await Promise.all([
602 + import("./extract.js"),
603 + import("./pandoc.js"),
604 + ]);
608 605 const extracted = extractMainContent(body.toString("utf-8"));
609 606 let md: string;
1046 1043 let contentType: string;
1047 1044 let finalUrl = params.url;
1046 + const { fetchUrlStream } = await import("./fetch.js");
1049 1047 const result = await fetchUrlStream(params.url, onProgress, signal, {
1050 1048 maxBytes: params.maxBytes,
1051 1049 timeoutMs: params.timeout,
1091 1089 headerLine,
1093 1091 const fullOutput = processed.output;
1092 + const [{ saveJsonResult }, { filterLineMatches }] = await Promise.all([
1093 + import("./store.js"),
1094 + import("./line-match.js"),
1095 + ]);
1094 1096 const stored = await saveJsonResult("web", ctx?.cwd ?? process.cwd(), {
1095 1097 url: params.url,
1096 1098 finalUrl,
1238 1240 details: {},
1243 + const [{ discoverSiteMap }, { saveJsonResult }] = await Promise.all([
1244 + import("./map.js"),
1245 + import("./store.js"),
1246 + ]);
1241 1247 const map = await discoverSiteMap(
1242 1248 params.url,
1243 1249 { maxUrls: params.maxUrls, maxSitemaps: params.maxSitemaps },
1386 1392 details: {},
1395 + const { searchWeb } = await import("./search.js");
1389 1396 const { results, source } = await searchWeb({
1390 1397 query: params.query,
1568 + const { minimaxUnderstandImage } = await import("./minimax.js");
1561 1569 const content = await minimaxUnderstandImage(
1562 1570 prompt,
1563 1571 image_source,