@herbertgao/pi-extensions 2026.10.17 → 2026.10.19
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -7
- package/THIRD_PARTY_NOTICES.md +0 -1
- package/node_modules/@dietrichgebert/ponytail/.qoder-plugin/plugin.json +1 -1
- package/node_modules/@dietrichgebert/ponytail/hooks/band/metrics.ts +5 -11
- package/node_modules/@dietrichgebert/ponytail/hooks/band/register.tsx +69 -46
- package/node_modules/@dietrichgebert/ponytail/hooks/band/types.d.ts +0 -1
- package/node_modules/@dietrichgebert/ponytail/hooks/claude-codex-hooks.json +3 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/copilot-hooks.json +2 -2
- package/node_modules/@dietrichgebert/ponytail/hooks/cursor-hooks.json +2 -2
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-activate.js +4 -3
- package/node_modules/@dietrichgebert/ponytail/hooks/ponytail-map.js +4 -1
- package/node_modules/@dietrichgebert/ponytail/package.json +1 -1
- package/node_modules/@narumitw/pi-btw/README.md +3 -1
- package/node_modules/@narumitw/pi-btw/dist/index.ts +26 -5
- package/node_modules/@narumitw/pi-btw/dist/index.ts.map +2 -2
- package/node_modules/@narumitw/pi-btw/docs/core-alignment.md +40 -0
- package/node_modules/@narumitw/pi-btw/docs/workflows.md +3 -0
- package/node_modules/@narumitw/pi-btw/package.json +1 -1
- package/node_modules/@narumitw/pi-btw/src/btw.ts +31 -5
- package/node_modules/@narumitw/pi-btw/src/fullscreen-ui.ts +13 -0
- package/node_modules/pi-lens/CHANGELOG.md +83 -0
- package/node_modules/pi-lens/README.md +5 -1
- package/node_modules/pi-lens/dist/{chunk-JL6CXUMW.js → chunk-24BILSZW.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-S67UJDGQ.js → chunk-2TF6RXWB.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-ARD426WI.js → chunk-3F6BMY53.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-5ZR3APIM.js → chunk-3FRLWYBG.js} +26 -26
- package/node_modules/pi-lens/dist/{chunk-T7FTXGS3.js → chunk-3K2F6UDZ.js} +30 -30
- package/node_modules/pi-lens/dist/{chunk-HK6JVFZC.js → chunk-3YY7IXIL.js} +2 -2
- package/node_modules/pi-lens/dist/chunk-46TNM7XZ.js +88 -0
- package/node_modules/pi-lens/dist/{chunk-4AVZ3TG7.js → chunk-4L36HG27.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-PO45POGF.js → chunk-4LM3VAZH.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-UN4TEBWN.js → chunk-4LOE5R5P.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-KLQVC3XC.js → chunk-4YHYPW2G.js} +30 -7
- package/node_modules/pi-lens/dist/{chunk-W5LGKNET.js → chunk-4ZYJHQMB.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-W2V54OCL.js → chunk-6IR3ZYIB.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-FJIVKLPH.js → chunk-72OKUXSD.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-7RQXA5GG.js → chunk-75GAYVNO.js} +10 -9
- package/node_modules/pi-lens/dist/{chunk-V3APN3DY.js → chunk-7E2563GA.js} +12 -12
- package/node_modules/pi-lens/dist/{chunk-4WX4CTUE.js → chunk-7GLOLOSH.js} +25 -25
- package/node_modules/pi-lens/dist/{chunk-BWYQUPOS.js → chunk-ABPKUVA4.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-IPDG45G5.js → chunk-AKUUMGD5.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-Q6D6VMI4.js → chunk-ASUXV767.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-BM5GS6ZH.js → chunk-AWDSEDER.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-MA77RSFN.js → chunk-BZARLRJW.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-EVDGNG4F.js → chunk-CB4WHS4H.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-FA5LDARD.js → chunk-CCV2EU7T.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-U6OC3QEM.js → chunk-CE6VMBCB.js} +15 -15
- package/node_modules/pi-lens/dist/{chunk-AMXIUN2R.js → chunk-CPSR3AVL.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-SXGD4ANG.js → chunk-CTADOKYM.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-63RIVFQI.js → chunk-DH5JPM3K.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-MT6BVNFW.js → chunk-DPGEAHZT.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-4PCQCU47.js → chunk-DQZFQSR5.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-BHUWL2Y3.js → chunk-E7HJ56Y7.js} +5 -5
- package/node_modules/pi-lens/dist/{chunk-DQXSPYRI.js → chunk-EAOK7MIZ.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-2RLWJO5K.js → chunk-EKWX4WD3.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-WIZWZR4C.js → chunk-F7K5IBZG.js} +30 -28
- package/node_modules/pi-lens/dist/{chunk-VQH24FIP.js → chunk-FB5SCCPT.js} +9 -9
- package/node_modules/pi-lens/dist/{chunk-GZE7WOI4.js → chunk-FZKFVUEC.js} +438 -140
- package/node_modules/pi-lens/dist/{chunk-TIYGSODX.js → chunk-H7OR7DFZ.js} +15 -13
- package/node_modules/pi-lens/dist/{chunk-CJYKEW2L.js → chunk-HO6LWE2E.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-YSBHPOY6.js → chunk-HR3OJ3TH.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-CFRQMBGP.js → chunk-HWDAVBFU.js} +14 -14
- package/node_modules/pi-lens/dist/{chunk-2X4VLOCC.js → chunk-JJ2RRESP.js} +8 -5
- package/node_modules/pi-lens/dist/{chunk-YBSONGSZ.js → chunk-JMEKXFOL.js} +24 -24
- package/node_modules/pi-lens/dist/{chunk-MKVZQUEG.js → chunk-KDX35VXP.js} +69 -13
- package/node_modules/pi-lens/dist/{chunk-75SY4F24.js → chunk-KKCK636N.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-OLAWH5UQ.js → chunk-KPPJTH44.js} +2 -1
- package/node_modules/pi-lens/dist/{chunk-5APMQ2IJ.js → chunk-KW5JQPO5.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-SCIUNBPF.js → chunk-L3CMBQMH.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-GAACZY6R.js → chunk-L5JYIU47.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-2DDDCJDL.js → chunk-LBLBAFG3.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-NNKXDXXS.js → chunk-LLS45EWB.js} +8 -0
- package/node_modules/pi-lens/dist/{chunk-WQOIR3QY.js → chunk-LS3QJRUB.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-XCUHKYCQ.js → chunk-LSC3VADM.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-GMTFDAOK.js → chunk-LUBPZN36.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-DMSLNKF7.js → chunk-LV4UMYVH.js} +19 -19
- package/node_modules/pi-lens/dist/{chunk-XAIT2YGS.js → chunk-MB6PXBUA.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-AE37FEGH.js → chunk-MNJIXFX4.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-OJLTLYHB.js → chunk-MPKRJBPK.js} +30 -10
- package/node_modules/pi-lens/dist/{chunk-QGSTQH4D.js → chunk-N5WSK2K7.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-Z7IGUAXL.js → chunk-NA7SEXHE.js} +10 -6
- package/node_modules/pi-lens/dist/{chunk-UHGF5UT5.js → chunk-O4BJFESU.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-UCGQT677.js → chunk-OE5ZBP7F.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-KSR7RGQY.js → chunk-OXOI55RU.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-NDMCVUYK.js → chunk-PR6PO3ES.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-NIU2IPC5.js → chunk-PUZ3E2J4.js} +3 -3
- package/node_modules/pi-lens/dist/{chunk-2DMLM3ZO.js → chunk-QHSNL7B2.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-ZYNI26MI.js → chunk-QOE342SU.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-3WEPUD2V.js → chunk-R5MOQM2H.js} +98 -31
- package/node_modules/pi-lens/dist/{chunk-PPIBVH4R.js → chunk-RC2Z6K47.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-LEJOJDXL.js → chunk-RORGS5II.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-K2YGBXOA.js → chunk-RQS4QQSD.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-XQCSWV2G.js → chunk-RRV3FNNM.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-GTAI2J6U.js → chunk-SHLDT3OI.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-VPBIMOAQ.js → chunk-SNDXCFRS.js} +11 -9
- package/node_modules/pi-lens/dist/{chunk-Q4FCYCRE.js → chunk-T7A2HK2B.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-MN7MHUXQ.js → chunk-U5HPROLA.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-ZUUI3ZSA.js → chunk-U6VN4NVL.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-W5R5SABV.js → chunk-U7BD2QL7.js} +6 -6
- package/node_modules/pi-lens/dist/{chunk-P4QNXS6I.js → chunk-UF7RTZSO.js} +8 -8
- package/node_modules/pi-lens/dist/{chunk-A3YNG5KP.js → chunk-URCQWAQ4.js} +11 -11
- package/node_modules/pi-lens/dist/{chunk-FFL3A2VP.js → chunk-VUZWQ7UG.js} +4 -4
- package/node_modules/pi-lens/dist/{chunk-YRD4ISED.js → chunk-W4WP2ERB.js} +10 -10
- package/node_modules/pi-lens/dist/{chunk-OOU2WZZE.js → chunk-WDBICWH3.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-BI5LAQ3Y.js → chunk-WGRJOXED.js} +114 -148
- package/node_modules/pi-lens/dist/{chunk-ZQ6NZZTB.js → chunk-WME2OQST.js} +33 -0
- package/node_modules/pi-lens/dist/{chunk-DC4CFXM5.js → chunk-XT2HTCJ5.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-SJJYRZB4.js → chunk-Y7F7IEE3.js} +55 -23
- package/node_modules/pi-lens/dist/{chunk-2F47TQOA.js → chunk-YES5CACN.js} +29 -29
- package/node_modules/pi-lens/dist/{chunk-H7HTEQUZ.js → chunk-YHC2O2WO.js} +7 -7
- package/node_modules/pi-lens/dist/{chunk-Q3UZHW6N.js → chunk-YVHBNSME.js} +6 -10
- package/node_modules/pi-lens/dist/{chunk-3MYEA7QD.js → chunk-ZE3KXHS7.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-VG5JS5SW.js → chunk-ZGSJDWQU.js} +2 -2
- package/node_modules/pi-lens/dist/{chunk-5CV5ITZF.js → chunk-ZJTT47IG.js} +1 -1
- package/node_modules/pi-lens/dist/{chunk-Q4EMRFNA.js → chunk-ZMAUPOMG.js} +24 -24
- package/node_modules/pi-lens/dist/index.js +1925 -944
- package/node_modules/pi-lens/dist/mcp/analyze-cli.js +6 -6
- package/node_modules/pi-lens/dist/mcp/cli.js +30 -30
- package/node_modules/pi-lens/dist/mcp/server.js +707 -455
- package/node_modules/pi-lens/dist/mcp/worker.js +48 -48
- package/node_modules/pi-lens/dist/probes/installer.js +13 -13
- package/node_modules/pi-lens/docs/agent-tools.md +11 -3
- package/node_modules/pi-lens/docs/defect-shapes.md +15 -1
- package/node_modules/pi-lens/docs/dependencies.md +1 -0
- package/node_modules/pi-lens/docs/environment-variables.md +14 -0
- package/node_modules/pi-lens/docs/features.md +11 -1
- package/node_modules/pi-lens/docs/globalconfig.md +12 -1
- package/node_modules/pi-lens/docs/invariants/git-guard-host.md +34 -0
- package/node_modules/pi-lens/docs/invariants/lsp-trust-exec.md +6 -0
- package/node_modules/pi-lens/docs/invariants/session-telemetry.md +42 -2
- package/node_modules/pi-lens/docs/lsp-capability-matrix.md +89 -45
- package/node_modules/pi-lens/docs/lsp-idle-eviction.md +3 -5
- package/node_modules/pi-lens/docs/pi-lens-fixer.md +8 -1
- package/node_modules/pi-lens/docs/pi-lens-merge-policy.md +7 -4
- package/node_modules/pi-lens/docs/pi-lens-subagent.md +7 -4
- package/node_modules/pi-lens/docs/schema/pi-lens-config-v1.json +23 -0
- package/node_modules/pi-lens/docs/servercapabilities.md +1 -1
- package/node_modules/pi-lens/docs/settings.md +5 -0
- package/node_modules/pi-lens/docs/usage.md +5 -0
- package/node_modules/pi-lens/package.json +1 -1
- package/node_modules/pi-web-access/CHANGELOG.md +32 -1
- package/node_modules/pi-web-access/README.md +53 -15
- package/node_modules/pi-web-access/cloudflare-search.ts +237 -0
- package/node_modules/pi-web-access/curator-page.ts +12 -1
- package/node_modules/pi-web-access/curator-server.ts +3 -0
- package/node_modules/pi-web-access/dist/index.js +9450 -8642
- package/node_modules/pi-web-access/dist/mcp-cli.js +16742 -15954
- package/node_modules/pi-web-access/exa.ts +94 -20
- package/node_modules/pi-web-access/extract.ts +61 -9
- package/node_modules/pi-web-access/gemini-search.ts +17 -7
- package/node_modules/pi-web-access/index.ts +6 -0
- package/node_modules/pi-web-access/mcp-tool-definitions.ts +50 -34
- package/node_modules/pi-web-access/openai-search.ts +3 -1
- package/node_modules/pi-web-access/package.json +3 -2
- package/node_modules/pi-web-access/page-query.ts +13 -3
- package/node_modules/pi-web-access/pdf-extract.ts +1 -5
- package/node_modules/pi-web-access/perplexity.ts +2 -0
- package/node_modules/pi-web-access/searchapi.ts +202 -0
- package/node_modules/pi-web-access/source-check.ts +7 -0
- package/node_modules/pi-web-access/ssrf-protection.ts +25 -1
- package/node_modules/pi-web-access/summary-review.ts +21 -10
- package/node_modules/pi-web-access/tabstack.ts +289 -0
- package/node_modules/pi-web-access/utils.ts +79 -16
- package/node_modules/pi-web-access/web-tool-core.ts +10 -1
- package/node_modules/pi-web-access/xai-search.ts +3 -1
- package/package.json +5 -8
- package/node_modules/@tifan/pi-inline-skills/README.md +0 -41
- package/node_modules/@tifan/pi-inline-skills/package.json +0 -44
- package/node_modules/@tifan/pi-inline-skills/src/index.ts +0 -646
- package/node_modules/pi-lens/dist/chunk-G2B7F6ZU.js +0 -88
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { activityMonitor } from "./activity.ts";
|
|
3
|
+
import { hasCredentialSource, redactCredential, resolveCredential } from "./credential-source.ts";
|
|
4
|
+
import type { ExtractedContent, ExtractOptions } from "./extract.ts";
|
|
5
|
+
import type { SearchOptions, SearchResponse } from "./perplexity.ts";
|
|
6
|
+
import { getWebSearchConfigPath, resolveProviderApiUrl, fetchWithCredentialRedirects } from "./utils.ts";
|
|
7
|
+
|
|
8
|
+
const TABSTACK_RESEARCH_URL = "https://api.tabstack.ai/v1/research";
|
|
9
|
+
const TABSTACK_EXTRACT_URL = "https://api.tabstack.ai/v1/extract/markdown";
|
|
10
|
+
const CONFIG_PATH = getWebSearchConfigPath();
|
|
11
|
+
const RESEARCH_MODES = ["fast", "balanced"] as const;
|
|
12
|
+
type TabstackResearchMode = typeof RESEARCH_MODES[number];
|
|
13
|
+
// Fast research usually answers in seconds; balanced runs several iterations and can take minutes.
|
|
14
|
+
const RESEARCH_TIMEOUT_MS: Record<TabstackResearchMode, number> = { fast: 120_000, balanced: 300_000 };
|
|
15
|
+
const EXTRACT_TIMEOUT_MS = 90_000;
|
|
16
|
+
|
|
17
|
+
interface WebSearchConfig {
|
|
18
|
+
tabstackBaseUrl?: unknown;
|
|
19
|
+
tabstackApiKey?: unknown;
|
|
20
|
+
tabstackResearchMode?: unknown;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
interface TabstackCitedPage {
|
|
24
|
+
id?: string;
|
|
25
|
+
url?: string;
|
|
26
|
+
title?: string | null;
|
|
27
|
+
summary?: string | null;
|
|
28
|
+
claims?: string[];
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
interface TabstackResearchComplete {
|
|
32
|
+
report?: string;
|
|
33
|
+
metadata?: { citedPages?: TabstackCitedPage[] };
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
interface TabstackResearchError {
|
|
37
|
+
message?: string;
|
|
38
|
+
error?: { message?: string; name?: string };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface TabstackExtractResponse {
|
|
42
|
+
url?: string;
|
|
43
|
+
content?: string;
|
|
44
|
+
metadata?: { title?: string | null } | null;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
let cachedConfig: WebSearchConfig | null = null;
|
|
48
|
+
|
|
49
|
+
function loadConfig(): WebSearchConfig {
|
|
50
|
+
if (cachedConfig) return cachedConfig;
|
|
51
|
+
if (!existsSync(CONFIG_PATH)) {
|
|
52
|
+
cachedConfig = {};
|
|
53
|
+
return cachedConfig;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let parsed: unknown;
|
|
57
|
+
try {
|
|
58
|
+
parsed = JSON.parse(readFileSync(CONFIG_PATH, "utf-8"));
|
|
59
|
+
} catch {
|
|
60
|
+
// JSON parse errors can quote credentials from the config file.
|
|
61
|
+
throw new Error(`Failed to parse ${CONFIG_PATH}: expected valid JSON`);
|
|
62
|
+
}
|
|
63
|
+
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
|
|
64
|
+
throw new Error(`Invalid config in ${CONFIG_PATH}: expected a JSON object`);
|
|
65
|
+
}
|
|
66
|
+
cachedConfig = parsed as WebSearchConfig;
|
|
67
|
+
return cachedConfig;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async function getApiKey(signal?: AbortSignal): Promise<string> {
|
|
71
|
+
const key = await resolveCredential({
|
|
72
|
+
provider: "Tabstack",
|
|
73
|
+
configuredValue: loadConfig().tabstackApiKey,
|
|
74
|
+
environmentValue: process.env.TABSTACK_API_KEY,
|
|
75
|
+
signal,
|
|
76
|
+
});
|
|
77
|
+
if (!key) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
"Tabstack API key not found. Either:\n" +
|
|
80
|
+
` 1. Create ${CONFIG_PATH} with { "tabstackApiKey": "your-key" }\n` +
|
|
81
|
+
" 2. Set TABSTACK_API_KEY environment variable\n" +
|
|
82
|
+
"Get a key at https://console.tabstack.ai",
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
return key;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export function isTabstackAvailable(): boolean {
|
|
89
|
+
return hasCredentialSource({
|
|
90
|
+
provider: "Tabstack",
|
|
91
|
+
configuredValue: loadConfig().tabstackApiKey,
|
|
92
|
+
environmentValue: process.env.TABSTACK_API_KEY,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function getResearchMode(): TabstackResearchMode {
|
|
97
|
+
const value = loadConfig().tabstackResearchMode;
|
|
98
|
+
if (value === undefined) return "fast";
|
|
99
|
+
if (typeof value !== "string" || !RESEARCH_MODES.includes(value as TabstackResearchMode)) {
|
|
100
|
+
throw new Error(`tabstackResearchMode in ${CONFIG_PATH} must be one of: ${RESEARCH_MODES.join(", ")}`);
|
|
101
|
+
}
|
|
102
|
+
return value as TabstackResearchMode;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function errorMessage(err: unknown): string {
|
|
106
|
+
return err instanceof Error ? err.message : String(err);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function requestSignal(signal: AbortSignal | undefined, timeoutMs: number): AbortSignal {
|
|
110
|
+
const timeout = AbortSignal.timeout(timeoutMs);
|
|
111
|
+
return signal ? AbortSignal.any([signal, timeout]) : timeout;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
async function tabstackRequest(
|
|
115
|
+
label: "Research" | "Extract",
|
|
116
|
+
url: string,
|
|
117
|
+
apiKey: string,
|
|
118
|
+
body: Record<string, unknown>,
|
|
119
|
+
accept: string,
|
|
120
|
+
timeoutMs: number,
|
|
121
|
+
signal?: AbortSignal,
|
|
122
|
+
): Promise<string> {
|
|
123
|
+
try {
|
|
124
|
+
const response = await fetchWithCredentialRedirects(resolveProviderApiUrl("tabstack", url, loadConfig().tabstackBaseUrl), {
|
|
125
|
+
method: "POST",
|
|
126
|
+
headers: {
|
|
127
|
+
Authorization: `Bearer ${apiKey}`,
|
|
128
|
+
Accept: accept,
|
|
129
|
+
"Content-Type": "application/json",
|
|
130
|
+
},
|
|
131
|
+
body: JSON.stringify(body),
|
|
132
|
+
signal: requestSignal(signal, timeoutMs),
|
|
133
|
+
}, ["Authorization"]);
|
|
134
|
+
// Research streams until the report is written, so the deadline also covers the body read.
|
|
135
|
+
const raw = await response.text();
|
|
136
|
+
if (!response.ok) {
|
|
137
|
+
throw new Error(`Tabstack ${label} API error ${response.status}: ${redactCredential(raw, apiKey).slice(0, 300)}`);
|
|
138
|
+
}
|
|
139
|
+
return raw;
|
|
140
|
+
} catch (err) {
|
|
141
|
+
const message = errorMessage(err);
|
|
142
|
+
const isRequestAbort = err instanceof Error
|
|
143
|
+
? err.name === "AbortError" || err.name === "TimeoutError" || /abort|timeout/i.test(message)
|
|
144
|
+
: /abort|timeout/i.test(message);
|
|
145
|
+
if (!signal?.aborted && isRequestAbort && !message.startsWith(`Tabstack ${label} API error`)) {
|
|
146
|
+
const timeoutError = new Error(`Tabstack ${label} API request timed out after ${Math.ceil(timeoutMs / 1_000)} seconds`);
|
|
147
|
+
timeoutError.name = "TimeoutError";
|
|
148
|
+
throw timeoutError;
|
|
149
|
+
}
|
|
150
|
+
const redactedMessage = redactCredential(message, apiKey);
|
|
151
|
+
if (redactedMessage === message) throw err;
|
|
152
|
+
const redactedError = new Error(redactedMessage);
|
|
153
|
+
if (err instanceof Error) redactedError.name = err.name;
|
|
154
|
+
throw redactedError;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
function parseEventStream(raw: string): Array<{ event: string; data: unknown }> {
|
|
159
|
+
const events: Array<{ event: string; data: unknown }> = [];
|
|
160
|
+
for (const block of raw.replace(/\r\n?/g, "\n").split(/\n\n+/)) {
|
|
161
|
+
let event = "message";
|
|
162
|
+
const data: string[] = [];
|
|
163
|
+
for (const line of block.split("\n")) {
|
|
164
|
+
if (line.startsWith("event:")) event = line.slice(6).trim();
|
|
165
|
+
else if (line.startsWith("data:")) data.push(line.slice(5).replace(/^ /, ""));
|
|
166
|
+
}
|
|
167
|
+
if (data.length === 0) continue;
|
|
168
|
+
try {
|
|
169
|
+
events.push({ event, data: JSON.parse(data.join("\n")) });
|
|
170
|
+
} catch {
|
|
171
|
+
// A malformed frame is skipped; a missing complete event is reported as an invalid response below.
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return events;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
function researchErrorMessage(data: TabstackResearchError): string {
|
|
178
|
+
const nested = typeof data.error?.message === "string" ? data.error.message.trim() : "";
|
|
179
|
+
const message = typeof data.message === "string" ? data.message.trim() : "";
|
|
180
|
+
return nested || message || "unknown error";
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
function mapCitedPages(pages: TabstackCitedPage[] | undefined): SearchResponse["results"] {
|
|
184
|
+
if (!Array.isArray(pages)) return [];
|
|
185
|
+
const results: SearchResponse["results"] = [];
|
|
186
|
+
for (const page of pages) {
|
|
187
|
+
if (!page || typeof page.url !== "string" || page.url.trim().length === 0) continue;
|
|
188
|
+
const url = page.url.trim();
|
|
189
|
+
const claims = Array.isArray(page.claims) ? page.claims.filter((claim) => typeof claim === "string" && claim.trim()) : [];
|
|
190
|
+
results.push({
|
|
191
|
+
title: typeof page.title === "string" && page.title.trim() ? page.title.trim() : url,
|
|
192
|
+
url,
|
|
193
|
+
snippet: (typeof page.summary === "string" && page.summary.trim() ? page.summary : claims.join(" ")).replace(/\s+/g, " ").trim(),
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
return results;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
export async function searchWithTabstack(query: string, options: SearchOptions = {}): Promise<SearchResponse> {
|
|
200
|
+
const mode = getResearchMode();
|
|
201
|
+
const apiKey = await getApiKey(options.signal);
|
|
202
|
+
const activityId = activityMonitor.logStart({ type: "api", query });
|
|
203
|
+
try {
|
|
204
|
+
// Research has no domain, recency, or result-count parameters, so only the query and mode are sent.
|
|
205
|
+
// Every cited page is kept because the report cites them as [1], [2], ... in this order.
|
|
206
|
+
const raw = await tabstackRequest(
|
|
207
|
+
"Research",
|
|
208
|
+
TABSTACK_RESEARCH_URL,
|
|
209
|
+
apiKey,
|
|
210
|
+
{ query, mode },
|
|
211
|
+
"text/event-stream",
|
|
212
|
+
RESEARCH_TIMEOUT_MS[mode],
|
|
213
|
+
options.signal,
|
|
214
|
+
);
|
|
215
|
+
const events = parseEventStream(raw);
|
|
216
|
+
const failure = events.find((item) => item.event === "error");
|
|
217
|
+
if (failure) {
|
|
218
|
+
throw new Error(`Tabstack Research API returned error: ${researchErrorMessage(failure.data as TabstackResearchError)}`);
|
|
219
|
+
}
|
|
220
|
+
const complete = events.find((item) => item.event === "complete")?.data as TabstackResearchComplete | undefined;
|
|
221
|
+
if (!complete || typeof complete !== "object" || typeof complete.report !== "string") {
|
|
222
|
+
throw new Error("Tabstack Research API returned an invalid response: no complete event with a report");
|
|
223
|
+
}
|
|
224
|
+
const response: SearchResponse = {
|
|
225
|
+
answer: complete.report.trim(),
|
|
226
|
+
results: mapCitedPages(complete.metadata?.citedPages),
|
|
227
|
+
};
|
|
228
|
+
activityMonitor.logComplete(activityId, 200);
|
|
229
|
+
return response;
|
|
230
|
+
} catch (err) {
|
|
231
|
+
const message = errorMessage(err);
|
|
232
|
+
const redactedMessage = redactCredential(message, apiKey);
|
|
233
|
+
if (options.signal?.aborted) activityMonitor.logComplete(activityId, 0);
|
|
234
|
+
else activityMonitor.logError(activityId, redactedMessage);
|
|
235
|
+
if (redactedMessage === message) throw err;
|
|
236
|
+
const redactedError = new Error(redactedMessage);
|
|
237
|
+
if (err instanceof Error) redactedError.name = err.name;
|
|
238
|
+
throw redactedError;
|
|
239
|
+
}
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
function normalizeTimeoutMs(value: number | undefined): number {
|
|
243
|
+
if (typeof value !== "number" || !Number.isFinite(value)) return EXTRACT_TIMEOUT_MS;
|
|
244
|
+
return Math.max(1, Math.floor(value));
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
export async function extractWithTabstack(
|
|
248
|
+
url: string,
|
|
249
|
+
signal?: AbortSignal,
|
|
250
|
+
options: ExtractOptions = {},
|
|
251
|
+
): Promise<ExtractedContent | null> {
|
|
252
|
+
const apiKey = await getApiKey(signal);
|
|
253
|
+
const activityId = activityMonitor.logStart({ type: "fetch", url });
|
|
254
|
+
try {
|
|
255
|
+
// metadata: true returns the title separately instead of as YAML front matter in the content.
|
|
256
|
+
const raw = await tabstackRequest(
|
|
257
|
+
"Extract",
|
|
258
|
+
TABSTACK_EXTRACT_URL,
|
|
259
|
+
apiKey,
|
|
260
|
+
{ url, metadata: true },
|
|
261
|
+
"application/json",
|
|
262
|
+
normalizeTimeoutMs(options.timeoutMs),
|
|
263
|
+
signal,
|
|
264
|
+
);
|
|
265
|
+
let data: TabstackExtractResponse;
|
|
266
|
+
try {
|
|
267
|
+
data = JSON.parse(raw) as TabstackExtractResponse;
|
|
268
|
+
} catch (err) {
|
|
269
|
+
throw new Error(`Tabstack Extract API returned invalid JSON: ${errorMessage(err)}`);
|
|
270
|
+
}
|
|
271
|
+
if (!data || typeof data !== "object" || typeof data.content !== "string") {
|
|
272
|
+
throw new Error("Tabstack Extract API returned an unexpected response shape");
|
|
273
|
+
}
|
|
274
|
+
activityMonitor.logComplete(activityId, 200);
|
|
275
|
+
const content = data.content.trim();
|
|
276
|
+
if (!content) return null;
|
|
277
|
+
const title = data.metadata && typeof data.metadata.title === "string" ? data.metadata.title.trim() : "";
|
|
278
|
+
return { url, title, content, error: null };
|
|
279
|
+
} catch (err) {
|
|
280
|
+
const message = errorMessage(err);
|
|
281
|
+
const redactedMessage = redactCredential(message, apiKey);
|
|
282
|
+
if (signal?.aborted) activityMonitor.logComplete(activityId, 0);
|
|
283
|
+
else activityMonitor.logError(activityId, redactedMessage);
|
|
284
|
+
if (redactedMessage === message) throw err;
|
|
285
|
+
const redactedError = new Error(redactedMessage);
|
|
286
|
+
if (err instanceof Error) redactedError.name = err.name;
|
|
287
|
+
throw redactedError;
|
|
288
|
+
}
|
|
289
|
+
}
|
|
@@ -111,8 +111,9 @@ export function resolveApiBaseUrl(options: ApiBaseUrlOptions): string {
|
|
|
111
111
|
}
|
|
112
112
|
|
|
113
113
|
// Other tools commonly set the bare OLLAMA_BASE_URL (a local Ollama server) and DEEPSEEK_BASE_URL
|
|
114
|
-
// (an OpenAI-compatible root ending in /v1),
|
|
115
|
-
|
|
114
|
+
// (an OpenAI-compatible root ending in /v1), and the Tabstack SDKs read TABSTACK_BASE_URL as a /v1 root,
|
|
115
|
+
// so these providers read PI_-prefixed names instead.
|
|
116
|
+
const PI_PREFIXED_ENVIRONMENT_STEMS = new Set(["ollama", "deepseek", "tabstack"]);
|
|
116
117
|
|
|
117
118
|
/** Resolve a provider's API root without dropping its endpoint path or a gateway prefix. */
|
|
118
119
|
export function resolveProviderApiUrl(configStem: string, defaultUrl: string, configuredValue: unknown): string {
|
|
@@ -266,7 +267,11 @@ export function mapFfmpegError(err: unknown): string {
|
|
|
266
267
|
return snippet ? `ffmpeg failed: ${snippet}` : "ffmpeg failed";
|
|
267
268
|
}
|
|
268
269
|
|
|
269
|
-
|
|
270
|
+
// Pi can load this module several times in one process (extension reloads use fresh module
|
|
271
|
+
// instances), while the fetch wrapper below is process-global. Every instance must therefore write
|
|
272
|
+
// the proxy context into the one store the installed wrapper reads.
|
|
273
|
+
const sharedProxyState = globalThis as { [key: symbol]: AsyncLocalStorage<string | null> | undefined };
|
|
274
|
+
const proxyStorage = sharedProxyState[Symbol.for("pi-web-access.proxyStorage")] ??= new AsyncLocalStorage<string | null>();
|
|
270
275
|
|
|
271
276
|
export function normalizeProxyUrl(value: unknown, source: string): string | null {
|
|
272
277
|
if (value === undefined || value === null) return null;
|
|
@@ -369,13 +374,17 @@ export interface ProxiedRequestInit extends RequestInit {
|
|
|
369
374
|
|
|
370
375
|
interface ProxiedFetch {
|
|
371
376
|
(input: RequestInfo | URL, init?: ProxiedRequestInit): Promise<Response>;
|
|
377
|
+
__piWebAccessSharedProxyFetch?: boolean;
|
|
378
|
+
/** Marker set by versions before the shared store. */
|
|
372
379
|
__piWebAccessProxyFetch?: boolean;
|
|
373
380
|
}
|
|
374
381
|
|
|
375
382
|
/** Wraps globalThis.fetch so every http(s) call routes through curl while a proxy is active. Idempotent. */
|
|
376
383
|
export function installGlobalProxyFetch(): void {
|
|
377
384
|
const current = globalThis.fetch as ProxiedFetch;
|
|
378
|
-
|
|
385
|
+
// Wrappers from versions before the shared store read their own module's context, so they are
|
|
386
|
+
// wrapped again rather than trusted; this wrapper passes direct calls through to them unchanged.
|
|
387
|
+
if (typeof current !== "function" || current.__piWebAccessSharedProxyFetch === true) return;
|
|
379
388
|
const nativeFetch = current;
|
|
380
389
|
const wrapped: ProxiedFetch = (async (input: RequestInfo | URL, init?: ProxiedRequestInit) => {
|
|
381
390
|
// Prefer caller-attached __proxy (survives pLimit context loss) over AsyncLocalStorage.
|
|
@@ -399,12 +408,40 @@ export function installGlobalProxyFetch(): void {
|
|
|
399
408
|
).arrayBuffer());
|
|
400
409
|
init = { ...init, method: request.method, headers: request.headers, body, signal: request.signal, redirect: request.redirect };
|
|
401
410
|
}
|
|
402
|
-
return fetchViaCurl(url, init ?? {}, proxy);
|
|
411
|
+
return fetchViaCurl(url, init ?? {}, { command: ["curl"], proxy });
|
|
403
412
|
});
|
|
404
|
-
wrapped.
|
|
413
|
+
wrapped.__piWebAccessSharedProxyFetch = true;
|
|
414
|
+
// On top of a pre-fix wrapper, also carry its marker so that copy stops wrapping again.
|
|
415
|
+
if (current.__piWebAccessProxyFetch === true) wrapped.__piWebAccessProxyFetch = true;
|
|
405
416
|
globalThis.fetch = wrapped;
|
|
406
417
|
}
|
|
407
418
|
|
|
419
|
+
/** A fetch for the extension's own page requests that runs the `fetchContent.curl` command instead of
|
|
420
|
+
* Node's fetch. It uses a proxy the way the proxy transport does: a per-call `__proxy` wins, `""`
|
|
421
|
+
* connects directly, and loopback and NO_PROXY hosts are never proxied. With no proxy decision,
|
|
422
|
+
* `envProxy` names the env proxy the SSRF check trusted for the URL. Callers pass a URL. */
|
|
423
|
+
export function createCurlFetch(
|
|
424
|
+
command: readonly string[],
|
|
425
|
+
{ maxBytes, envProxy }: { maxBytes: number; envProxy: (url: URL) => string | null },
|
|
426
|
+
): typeof fetch {
|
|
427
|
+
return async (input: RequestInfo | URL, init?: ProxiedRequestInit) => {
|
|
428
|
+
const url = new URL(input instanceof Request ? input.url : input);
|
|
429
|
+
let proxy: string | null;
|
|
430
|
+
if (init?.__proxy !== undefined || hasScopedProxyDecision()) {
|
|
431
|
+
const chosen = init?.__proxy ?? getActiveProxy();
|
|
432
|
+
proxy = chosen && !isProxyBypassedUrl(url) ? chosen : null;
|
|
433
|
+
} else {
|
|
434
|
+
proxy = envProxy(url);
|
|
435
|
+
}
|
|
436
|
+
return fetchViaCurl(url, init ?? {}, {
|
|
437
|
+
command,
|
|
438
|
+
proxy,
|
|
439
|
+
maxBytes,
|
|
440
|
+
notFound: `fetchContent.curl command not found: ${command[0]}`,
|
|
441
|
+
});
|
|
442
|
+
};
|
|
443
|
+
}
|
|
444
|
+
|
|
408
445
|
// GET bodies are decoded by --compressed, so their length/encoding headers no longer match.
|
|
409
446
|
// HEAD has no body, and its Content-Length is usually why the caller asked.
|
|
410
447
|
function parseHeaderDump(dump: string, keepLengthHeaders: boolean): { status: number; statusText: string; headers: Array<[string, string]> } {
|
|
@@ -434,11 +471,22 @@ function parseHeaderDump(dump: string, keepLengthHeaders: boolean): { status: nu
|
|
|
434
471
|
|
|
435
472
|
class CurlTransportError extends Error {}
|
|
436
473
|
|
|
437
|
-
|
|
474
|
+
interface CurlTransport {
|
|
475
|
+
/** Executable and any leading arguments, e.g. ["curl"] or ["curl-impersonate", "--impersonate", "chrome146"]. */
|
|
476
|
+
command: readonly string[];
|
|
477
|
+
/** Proxy passed with -x, or null to connect directly. */
|
|
478
|
+
proxy: string | null;
|
|
479
|
+
/** Error message when the executable is missing; defaults to the proxy transport's message. */
|
|
480
|
+
notFound?: string;
|
|
481
|
+
/** Largest body to download; curl stops a bigger one instead of saving all of it. */
|
|
482
|
+
maxBytes?: number;
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
async function fetchViaCurl(url: URL, init: RequestInit, transport: CurlTransport): Promise<Response> {
|
|
438
486
|
let current = url;
|
|
439
487
|
let currentInit = init;
|
|
440
488
|
for (let redirects = 0; ; redirects++) {
|
|
441
|
-
const response = await fetchViaCurlOnce(current, currentInit,
|
|
489
|
+
const response = await fetchViaCurlOnce(current, currentInit, transport);
|
|
442
490
|
const location = response.headers.get("location");
|
|
443
491
|
if (!location || ![301, 302, 303, 307, 308].includes(response.status)) {
|
|
444
492
|
if (redirects > 0) Object.defineProperty(response, "redirected", { value: true, configurable: true });
|
|
@@ -471,7 +519,7 @@ async function fetchViaCurl(url: URL, init: RequestInit, proxyUrl: string): Prom
|
|
|
471
519
|
}
|
|
472
520
|
}
|
|
473
521
|
|
|
474
|
-
async function fetchViaCurlOnce(url: URL, init: RequestInit,
|
|
522
|
+
async function fetchViaCurlOnce(url: URL, init: RequestInit, { command, proxy, notFound, maxBytes }: CurlTransport): Promise<Response> {
|
|
475
523
|
const method = (init.method ?? "GET").toUpperCase();
|
|
476
524
|
const headers = new Headers(init.headers);
|
|
477
525
|
|
|
@@ -484,8 +532,15 @@ async function fetchViaCurlOnce(url: URL, init: RequestInit, proxyUrl: string):
|
|
|
484
532
|
"--silent",
|
|
485
533
|
"--show-error",
|
|
486
534
|
"--compressed",
|
|
535
|
+
// The caller checks each redirect, so curl must not follow one, even with -L in the command or ~/.curlrc.
|
|
536
|
+
"--no-location",
|
|
537
|
+
// URLs are validated as written, so curl must send [ ] { } literally instead of expanding them into other URLs.
|
|
538
|
+
"--globoff",
|
|
487
539
|
"--connect-timeout", "20",
|
|
488
|
-
|
|
540
|
+
// An empty proxy also stops curl from using proxy environment variables, which Node's fetch ignores.
|
|
541
|
+
"-x", proxy ?? "",
|
|
542
|
+
// The caller already chose the proxy; curl must not send a host direct because of its own NO_PROXY reading.
|
|
543
|
+
...(proxy ? ["--noproxy", ""] : []),
|
|
489
544
|
"-D", headerFile,
|
|
490
545
|
"--output", bodyFile,
|
|
491
546
|
"--write-out", "%{json}",
|
|
@@ -493,6 +548,7 @@ async function fetchViaCurlOnce(url: URL, init: RequestInit, proxyUrl: string):
|
|
|
493
548
|
|
|
494
549
|
if (method === "HEAD") args.push("--head");
|
|
495
550
|
else if (method !== "GET") args.push("-X", method);
|
|
551
|
+
if (maxBytes !== undefined) args.push("--max-filesize", String(maxBytes));
|
|
496
552
|
|
|
497
553
|
for (const [name, value] of headers.entries()) {
|
|
498
554
|
if (value === "") continue;
|
|
@@ -525,7 +581,7 @@ async function fetchViaCurlOnce(url: URL, init: RequestInit, proxyUrl: string):
|
|
|
525
581
|
reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
526
582
|
return;
|
|
527
583
|
}
|
|
528
|
-
const child = spawn(
|
|
584
|
+
const child = spawn(command[0], [...command.slice(1), ...args], { windowsHide: true });
|
|
529
585
|
let out = "";
|
|
530
586
|
let stderr = "";
|
|
531
587
|
const onAbort = () => { try { child.kill(); } catch {} };
|
|
@@ -537,14 +593,19 @@ async function fetchViaCurlOnce(url: URL, init: RequestInit, proxyUrl: string):
|
|
|
537
593
|
child.once("error", (err: NodeJS.ErrnoException) => {
|
|
538
594
|
signal?.removeEventListener("abort", onAbort);
|
|
539
595
|
reject(new CurlTransportError(err.code === "ENOENT"
|
|
540
|
-
? "curl executable not found on PATH; proxy transport requires curl"
|
|
541
|
-
:
|
|
596
|
+
? notFound ?? "curl executable not found on PATH; proxy transport requires curl"
|
|
597
|
+
: `${command[0]} failed to start: ${err.message}`));
|
|
542
598
|
});
|
|
543
599
|
child.once("close", (code) => {
|
|
544
600
|
signal?.removeEventListener("abort", onAbort);
|
|
545
601
|
if (signal?.aborted) return reject(new DOMException("The operation was aborted.", "AbortError"));
|
|
546
|
-
|
|
547
|
-
|
|
602
|
+
// A failed transfer can still write headers, part of the body and the write-out JSON.
|
|
603
|
+
// Exit 63 is --max-filesize; report it like the size limit of a Node fetch.
|
|
604
|
+
if (code === 63 && maxBytes !== undefined) {
|
|
605
|
+
return reject(new CurlTransportError(`Response too large (over ${Math.round(maxBytes / 1024 / 1024)}MB)`));
|
|
606
|
+
}
|
|
607
|
+
if (code !== 0) {
|
|
608
|
+
return reject(new CurlTransportError(`${command[0]} exited with code ${code ?? "unknown"}${proxy ? ` via ${redactProxyUrl(proxy)}` : ""}${stderr.trim() ? `: ${stderr.trim()}` : ""}`));
|
|
548
609
|
}
|
|
549
610
|
resolve(out);
|
|
550
611
|
});
|
|
@@ -567,7 +628,9 @@ async function fetchViaCurlOnce(url: URL, init: RequestInit, proxyUrl: string):
|
|
|
567
628
|
|
|
568
629
|
const { status, statusText, headers: responseHeaders } = parseHeaderDump(dump, method === "HEAD");
|
|
569
630
|
if (status === 0) {
|
|
570
|
-
throw new Error(
|
|
631
|
+
throw new Error(proxy
|
|
632
|
+
? `Proxy fetch to ${url.toString()} via ${redactProxyUrl(proxy)} returned no HTTP status`
|
|
633
|
+
: `${command[0]} fetch to ${url.toString()} returned no HTTP status`);
|
|
571
634
|
}
|
|
572
635
|
|
|
573
636
|
let finalUrl = url.toString();
|
|
@@ -72,6 +72,14 @@ export interface WebSearchConfig {
|
|
|
72
72
|
ninerouterBaseUrl?: unknown;
|
|
73
73
|
ninerouterApiKey?: unknown;
|
|
74
74
|
ninerouterProvider?: unknown;
|
|
75
|
+
cloudflareAccountId?: unknown;
|
|
76
|
+
cloudflareGatewayId?: unknown;
|
|
77
|
+
cloudflareSearchProvider?: unknown;
|
|
78
|
+
searchapiApiKey?: unknown;
|
|
79
|
+
searchapiBaseUrl?: unknown;
|
|
80
|
+
tabstackBaseUrl?: unknown;
|
|
81
|
+
tabstackApiKey?: unknown;
|
|
82
|
+
tabstackResearchMode?: unknown;
|
|
75
83
|
deepseekApiKey?: unknown;
|
|
76
84
|
degoogBaseUrl?: unknown;
|
|
77
85
|
degoogApiKey?: unknown;
|
|
@@ -430,7 +438,8 @@ function formatSourceCheckResult(artifact: ResearchArtifact, getSearchContentToo
|
|
|
430
438
|
if (text.length > budget) omitted++;
|
|
431
439
|
else {
|
|
432
440
|
budget -= text.length;
|
|
433
|
-
|
|
441
|
+
const label = passage.origin === "provider_summary" ? " [provider summary, not page text]" : "";
|
|
442
|
+
lines.push(` - ${passage.passage_id}${label}: ${text}`);
|
|
434
443
|
}
|
|
435
444
|
}
|
|
436
445
|
}
|
|
@@ -256,7 +256,7 @@ function buildInput(query: string, options: SearchOptions, tools: readonly XaiSe
|
|
|
256
256
|
return `${lines.join(" ")}\n\n${query}`;
|
|
257
257
|
}
|
|
258
258
|
|
|
259
|
-
function addResult(results: SearchResult[], seen: Set<string>, url: unknown, title: unknown, snippet = ""): void {
|
|
259
|
+
function addResult(results: SearchResult[], seen: Set<string>, url: unknown, title: unknown, snippet = "", generated = false): void {
|
|
260
260
|
if (typeof url !== "string" || url.trim().length === 0) return;
|
|
261
261
|
if (seen.has(url)) return;
|
|
262
262
|
seen.add(url);
|
|
@@ -264,6 +264,7 @@ function addResult(results: SearchResult[], seen: Set<string>, url: unknown, tit
|
|
|
264
264
|
title: typeof title === "string" && title.trim().length > 0 ? title : url,
|
|
265
265
|
url,
|
|
266
266
|
snippet,
|
|
267
|
+
...(generated && snippet ? { snippetSource: "generated" as const } : {}),
|
|
267
268
|
});
|
|
268
269
|
}
|
|
269
270
|
|
|
@@ -334,6 +335,7 @@ function extractSearchResults(output: unknown[], citations: unknown, numResults:
|
|
|
334
335
|
(annotation as { url?: unknown }).url,
|
|
335
336
|
(annotation as { title?: unknown }).title,
|
|
336
337
|
extractSnippetAround(text, (annotation as { start_index?: unknown }).start_index, (annotation as { end_index?: unknown }).end_index),
|
|
338
|
+
true,
|
|
337
339
|
);
|
|
338
340
|
}
|
|
339
341
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@herbertgao/pi-extensions",
|
|
3
|
-
"version": "2026.10.
|
|
3
|
+
"version": "2026.10.19",
|
|
4
4
|
"description": "Aggregate installer for HerbertGao-maintained Pi extensions.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"extensions",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@ast-grep/cli": "0.51.0",
|
|
39
39
|
"@ast-grep/napi": "^0.51.0",
|
|
40
|
-
"@dietrichgebert/ponytail": "5.3.
|
|
40
|
+
"@dietrichgebert/ponytail": "5.3.3",
|
|
41
41
|
"@herbertgao/pi-agency": "0.1.2",
|
|
42
42
|
"@herbertgao/pi-bark": "0.2.1",
|
|
43
43
|
"@herbertgao/pi-cc-extensions": "1.0.12-local.1",
|
|
@@ -49,14 +49,13 @@
|
|
|
49
49
|
"@modelcontextprotocol/sdk": "^1.32.1",
|
|
50
50
|
"@mozilla/readability": "^0.6.0",
|
|
51
51
|
"@napi-rs/keyring": "^2.1.0",
|
|
52
|
-
"@narumitw/pi-btw": "0.63.
|
|
52
|
+
"@narumitw/pi-btw": "0.63.3",
|
|
53
53
|
"@narumitw/pi-caffeinate": "0.49.13",
|
|
54
54
|
"@narumitw/pi-tui-kit": "^0.68.0",
|
|
55
55
|
"@pi-plugins/fast-mode": "0.1.14",
|
|
56
56
|
"@shikijs/cli": "^4.0.2",
|
|
57
57
|
"@tifan/pi-copy-response": "0.2.7",
|
|
58
58
|
"@tifan/pi-handoff": "2.2.2",
|
|
59
|
-
"@tifan/pi-inline-skills": "1.0.7",
|
|
60
59
|
"@tifan/pi-mermaid-open": "0.2.2",
|
|
61
60
|
"@tifan/pi-preferred-thinking": "1.0.2",
|
|
62
61
|
"@tifan/pi-recap": "0.4.8",
|
|
@@ -73,11 +72,11 @@
|
|
|
73
72
|
"nanoid": "^5.0.0",
|
|
74
73
|
"p-limit": "^6.1.0",
|
|
75
74
|
"pi-antigravity": "0.11.0",
|
|
76
|
-
"pi-lens": "4.4.
|
|
75
|
+
"pi-lens": "4.4.7",
|
|
77
76
|
"pi-next-cue": "1.0.8",
|
|
78
77
|
"pi-provider-qoder": "0.6.6",
|
|
79
78
|
"pi-typesafe": "0.13.1",
|
|
80
|
-
"pi-web-access": "0.
|
|
79
|
+
"pi-web-access": "0.46.0",
|
|
81
80
|
"pidusage": "^4.0.1",
|
|
82
81
|
"promise.try": "^2.0.1",
|
|
83
82
|
"turndown": "^7.2.0",
|
|
@@ -113,7 +112,6 @@
|
|
|
113
112
|
"@pi-plugins/fast-mode",
|
|
114
113
|
"@tifan/pi-copy-response",
|
|
115
114
|
"@tifan/pi-handoff",
|
|
116
|
-
"@tifan/pi-inline-skills",
|
|
117
115
|
"@tifan/pi-mermaid-open",
|
|
118
116
|
"@tifan/pi-preferred-thinking",
|
|
119
117
|
"@tifan/pi-recap",
|
|
@@ -137,7 +135,6 @@
|
|
|
137
135
|
"./node_modules/@tifan/pi-copy-response/src/index.ts",
|
|
138
136
|
"./node_modules/@tifan/pi-handoff/src/index.ts",
|
|
139
137
|
"./node_modules/@tifan/pi-handoff/src/session-query.ts",
|
|
140
|
-
"./node_modules/@tifan/pi-inline-skills/src/index.ts",
|
|
141
138
|
"./node_modules/@tifan/pi-mermaid-open/src/index.ts",
|
|
142
139
|
"./node_modules/@tifan/pi-preferred-thinking/src/index.ts",
|
|
143
140
|
"./node_modules/@tifan/pi-recap/src/index.ts",
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
# @tifan/pi-inline-skills
|
|
2
|
-
|
|
3
|
-
Load skills from inside a pi prompt.
|
|
4
|
-
|
|
5
|
-
Type `/` and part of a skill name, pick a skill, then keep writing. On submit, the prompt stays unchanged and the matching skill content is loaded for that turn.
|
|
6
|
-
|
|
7
|
-

|
|
8
|
-
|
|
9
|
-
## Install
|
|
10
|
-
|
|
11
|
-
```bash
|
|
12
|
-
pi install npm:@tifan/pi-inline-skills
|
|
13
|
-
```
|
|
14
|
-
|
|
15
|
-
## Usage
|
|
16
|
-
|
|
17
|
-
```text
|
|
18
|
-
let's /tdd this and /review when done
|
|
19
|
-
```
|
|
20
|
-
|
|
21
|
-
This loads `tdd` and `review` behind the scenes. Slash tokens stay in the visible prompt, so rewinding and editing previous prompts is easy.
|
|
22
|
-
|
|
23
|
-
Notes:
|
|
24
|
-
|
|
25
|
-
- Already-loaded skills are not injected again on the same session branch.
|
|
26
|
-
- Skills with `disable-model-invocation: true` work because this extension reads skill files directly.
|
|
27
|
-
- A registered pi command wins at the start of a prompt. Otherwise, a starting token like `/tdd` is treated as an inline skill.
|
|
28
|
-
|
|
29
|
-
## Commands
|
|
30
|
-
|
|
31
|
-
- `/loaded-skills`: List skills loaded in the current session.
|
|
32
|
-
|
|
33
|
-

|
|
34
|
-
|
|
35
|
-
## Release notes
|
|
36
|
-
|
|
37
|
-
See [CHANGELOG.md](https://github.com/tifandotme/pi-extensions/blob/master/packages/pi-inline-skills/CHANGELOG.md)
|
|
38
|
-
|
|
39
|
-
## License
|
|
40
|
-
|
|
41
|
-
[MIT](https://github.com/tifandotme/pi-extensions/blob/master/LICENSE)
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@tifan/pi-inline-skills",
|
|
3
|
-
"version": "1.0.7",
|
|
4
|
-
"description": "Inline /skill autocomplete in the pi editor.",
|
|
5
|
-
"keywords": [
|
|
6
|
-
"autocomplete",
|
|
7
|
-
"pi",
|
|
8
|
-
"pi-extension",
|
|
9
|
-
"pi-package",
|
|
10
|
-
"skills"
|
|
11
|
-
],
|
|
12
|
-
"homepage": "https://github.com/tifandotme/pi-extensions/tree/master/packages/pi-inline-skills#readme",
|
|
13
|
-
"bugs": "https://github.com/tifandotme/pi-extensions/issues",
|
|
14
|
-
"license": "MIT",
|
|
15
|
-
"author": "Tifan Dwi Avianto <hi@tifan.me>",
|
|
16
|
-
"repository": {
|
|
17
|
-
"type": "git",
|
|
18
|
-
"url": "git+https://github.com/tifandotme/pi-extensions.git",
|
|
19
|
-
"directory": "packages/pi-inline-skills"
|
|
20
|
-
},
|
|
21
|
-
"files": [
|
|
22
|
-
"src/**/*.ts",
|
|
23
|
-
"!src/**/*.test.ts",
|
|
24
|
-
"README.md",
|
|
25
|
-
"LICENSE"
|
|
26
|
-
],
|
|
27
|
-
"type": "module",
|
|
28
|
-
"publishConfig": {
|
|
29
|
-
"access": "public",
|
|
30
|
-
"provenance": true
|
|
31
|
-
},
|
|
32
|
-
"scripts": {
|
|
33
|
-
"test": "node --experimental-strip-types --test src/index.test.ts"
|
|
34
|
-
},
|
|
35
|
-
"engines": {
|
|
36
|
-
"node": ">=20"
|
|
37
|
-
},
|
|
38
|
-
"pi": {
|
|
39
|
-
"extensions": [
|
|
40
|
-
"./src/index.ts"
|
|
41
|
-
],
|
|
42
|
-
"image": "https://raw.githubusercontent.com/tifandotme/pi-extensions/refs/heads/master/packages/pi-inline-skills/assets/skills-selector-triggered-inline.webp"
|
|
43
|
-
}
|
|
44
|
-
}
|