@abhishek944/pi-web-access 0.0.0-stage → 0.1.0

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.
Files changed (201) hide show
  1. package/ASTACK.md +23 -0
  2. package/CHANGELOG.md +1289 -0
  3. package/LICENSE +21 -0
  4. package/README.md +1215 -2
  5. package/SECURITY.md +5 -0
  6. package/abortable.ts +17 -0
  7. package/activity.ts +101 -0
  8. package/anysearch.ts +188 -0
  9. package/auth-fetch.ts +152 -0
  10. package/baizhi.ts +124 -0
  11. package/banner.png +0 -0
  12. package/bocha.ts +203 -0
  13. package/brave-rate-limit.ts +176 -0
  14. package/brave.ts +247 -0
  15. package/brightdata-unlocker.ts +272 -0
  16. package/ceramic.ts +220 -0
  17. package/chrome-cookies.ts +752 -0
  18. package/cloudflare-search.ts +237 -0
  19. package/content-find.ts +255 -0
  20. package/crawl4ai.ts +196 -0
  21. package/credential-source.ts +242 -0
  22. package/curator-page.ts +3607 -0
  23. package/curator-run.ts +45 -0
  24. package/curator-server.ts +761 -0
  25. package/custom-search.ts +226 -0
  26. package/data-uri-sanitize.ts +406 -0
  27. package/datalab-pdf-extract.ts +568 -0
  28. package/declared-web-links.ts +173 -0
  29. package/deepseek.ts +377 -0
  30. package/degoog.ts +323 -0
  31. package/dist/index.js +28286 -0
  32. package/dist/mcp-cli.js +29186 -0
  33. package/dist/pi-mcp.js +20855 -0
  34. package/dist/types/abortable.d.ts +2 -0
  35. package/dist/types/activity.d.ts +33 -0
  36. package/dist/types/anysearch.d.ts +7 -0
  37. package/dist/types/auth-fetch.d.ts +14 -0
  38. package/dist/types/baizhi.d.ts +3 -0
  39. package/dist/types/bocha.d.ts +3 -0
  40. package/dist/types/brave-rate-limit.d.ts +35 -0
  41. package/dist/types/brave.d.ts +3 -0
  42. package/dist/types/brightdata-unlocker.d.ts +11 -0
  43. package/dist/types/ceramic.d.ts +3 -0
  44. package/dist/types/chrome-cookies.d.ts +44 -0
  45. package/dist/types/cloudflare-search.d.ts +4 -0
  46. package/dist/types/content-find.d.ts +10 -0
  47. package/dist/types/crawl4ai.d.ts +8 -0
  48. package/dist/types/credential-source.d.ts +29 -0
  49. package/dist/types/curator-page.d.ts +5 -0
  50. package/dist/types/curator-run.d.ts +10 -0
  51. package/dist/types/curator-server.d.ts +72 -0
  52. package/dist/types/custom-search.d.ts +22 -0
  53. package/dist/types/data-uri-sanitize.d.ts +20 -0
  54. package/dist/types/datalab-pdf-extract.d.ts +59 -0
  55. package/dist/types/declared-web-links.d.ts +7 -0
  56. package/dist/types/deepseek.d.ts +13 -0
  57. package/dist/types/degoog.d.ts +3 -0
  58. package/dist/types/domain-filter-normalization.d.ts +9 -0
  59. package/dist/types/duckduckgo-rate-limit.d.ts +52 -0
  60. package/dist/types/duckduckgo.d.ts +6 -0
  61. package/dist/types/endpoint-pdf-extract.d.ts +22 -0
  62. package/dist/types/exa.d.ts +17 -0
  63. package/dist/types/extract.d.ts +70 -0
  64. package/dist/types/feature-config.d.ts +2 -0
  65. package/dist/types/fetch-params.d.ts +39 -0
  66. package/dist/types/field-extract.d.ts +37 -0
  67. package/dist/types/firecrawl.d.ts +18 -0
  68. package/dist/types/gemini-adc.d.ts +9 -0
  69. package/dist/types/gemini-api.d.ts +37 -0
  70. package/dist/types/gemini-pdf-extract.d.ts +8 -0
  71. package/dist/types/gemini-search.d.ts +76 -0
  72. package/dist/types/gemini-url-context.d.ts +3 -0
  73. package/dist/types/gemini-web-config.d.ts +25 -0
  74. package/dist/types/gemini-web.d.ts +31 -0
  75. package/dist/types/github-api.d.ts +6 -0
  76. package/dist/types/github-extract.d.ts +19 -0
  77. package/dist/types/github-issue-pr.d.ts +28 -0
  78. package/dist/types/index.d.ts +53 -0
  79. package/dist/types/jina-search.d.ts +7 -0
  80. package/dist/types/kagi.d.ts +14 -0
  81. package/dist/types/keenable.d.ts +3 -0
  82. package/dist/types/kimi-search.d.ts +4 -0
  83. package/dist/types/linkup.d.ts +5 -0
  84. package/dist/types/mcp-cli.d.ts +2 -0
  85. package/dist/types/mcp-server.d.ts +10 -0
  86. package/dist/types/mcp-tool-definitions.d.ts +16 -0
  87. package/dist/types/mistral-search.d.ts +3 -0
  88. package/dist/types/ninerouter.d.ts +3 -0
  89. package/dist/types/offtopic-judge.d.ts +26 -0
  90. package/dist/types/ollama.d.ts +14 -0
  91. package/dist/types/openai-search.d.ts +23 -0
  92. package/dist/types/page-query.d.ts +22 -0
  93. package/dist/types/parallel-mcp.d.ts +10 -0
  94. package/dist/types/parallel.d.ts +13 -0
  95. package/dist/types/pdf-extract.d.ts +44 -0
  96. package/dist/types/perplexity.d.ts +26 -0
  97. package/dist/types/pi-mcp.d.ts +56 -0
  98. package/dist/types/pi-session-results.d.ts +8 -0
  99. package/dist/types/querit.d.ts +9 -0
  100. package/dist/types/query-rewrite.d.ts +2 -0
  101. package/dist/types/render-search-error.d.ts +56 -0
  102. package/dist/types/retrieval-only.d.ts +78 -0
  103. package/dist/types/rsc-extract.d.ts +11 -0
  104. package/dist/types/search-answer-formatting.d.ts +7 -0
  105. package/dist/types/search-result-count-normalization.d.ts +1 -0
  106. package/dist/types/searchinfinity.d.ts +7 -0
  107. package/dist/types/searxng.d.ts +3 -0
  108. package/dist/types/source-check.d.ts +102 -0
  109. package/dist/types/ssrf-protection.d.ts +66 -0
  110. package/dist/types/storage.d.ts +69 -0
  111. package/dist/types/summary-model-scope.d.ts +33 -0
  112. package/dist/types/summary-review.d.ts +30 -0
  113. package/dist/types/tabstack.d.ts +5 -0
  114. package/dist/types/tavily.d.ts +7 -0
  115. package/dist/types/tinyfish.d.ts +10 -0
  116. package/dist/types/tool-activation.d.ts +7 -0
  117. package/dist/types/tool-arguments.d.ts +1 -0
  118. package/dist/types/upgrade-notice.d.ts +6 -0
  119. package/dist/types/utils.d.ts +55 -0
  120. package/dist/types/valyu.d.ts +5 -0
  121. package/dist/types/video-extract.d.ts +15 -0
  122. package/dist/types/web-tool-contract.d.ts +98 -0
  123. package/dist/types/web-tool-core.d.ts +227 -0
  124. package/dist/types/xai-search.d.ts +12 -0
  125. package/dist/types/you.d.ts +3 -0
  126. package/dist/types/youtube-extract.d.ts +29 -0
  127. package/dist/types/zai.d.ts +3 -0
  128. package/docs/pi-mcp.md +41 -0
  129. package/domain-filter-normalization.ts +44 -0
  130. package/duckduckgo-rate-limit.ts +205 -0
  131. package/duckduckgo.ts +123 -0
  132. package/endpoint-pdf-extract.ts +225 -0
  133. package/exa.ts +620 -0
  134. package/extract.ts +1721 -0
  135. package/feature-config.ts +29 -0
  136. package/fetch-params.ts +147 -0
  137. package/field-extract.ts +347 -0
  138. package/firecrawl.ts +476 -0
  139. package/gemini-adc.ts +345 -0
  140. package/gemini-api.ts +368 -0
  141. package/gemini-pdf-extract.ts +108 -0
  142. package/gemini-search.ts +1162 -0
  143. package/gemini-url-context.ts +128 -0
  144. package/gemini-web-config.ts +131 -0
  145. package/gemini-web.ts +527 -0
  146. package/github-api.ts +197 -0
  147. package/github-extract.ts +1064 -0
  148. package/github-issue-pr.ts +717 -0
  149. package/index.ts +2819 -0
  150. package/jina-search.ts +275 -0
  151. package/kagi.ts +257 -0
  152. package/keenable.ts +222 -0
  153. package/kimi-search.ts +209 -0
  154. package/linkup.ts +170 -0
  155. package/mcp-cli.ts +40 -0
  156. package/mcp-server.ts +84 -0
  157. package/mcp-tool-definitions.ts +143 -0
  158. package/mistral-search.ts +268 -0
  159. package/ninerouter.ts +92 -0
  160. package/offtopic-judge.ts +72 -0
  161. package/ollama.ts +237 -0
  162. package/openai-search.ts +855 -0
  163. package/package.json +108 -4
  164. package/page-query.ts +185 -0
  165. package/parallel-mcp.ts +255 -0
  166. package/parallel.ts +373 -0
  167. package/pdf-extract.ts +447 -0
  168. package/perplexity.ts +245 -0
  169. package/pi-mcp.ts +139 -0
  170. package/pi-session-results.ts +40 -0
  171. package/pi-web-fetch-demo.mp4 +0 -0
  172. package/promise-try.d.ts +7 -0
  173. package/querit.ts +394 -0
  174. package/query-rewrite.ts +84 -0
  175. package/render-search-error.ts +170 -0
  176. package/retrieval-only.ts +102 -0
  177. package/rsc-extract.ts +338 -0
  178. package/search-answer-formatting.ts +11 -0
  179. package/search-result-count-normalization.ts +4 -0
  180. package/searchinfinity.ts +246 -0
  181. package/searxng.ts +236 -0
  182. package/source-check.ts +269 -0
  183. package/ssrf-protection.ts +602 -0
  184. package/storage.ts +547 -0
  185. package/summary-model-scope.ts +72 -0
  186. package/summary-review.ts +476 -0
  187. package/tabstack.ts +289 -0
  188. package/tavily.ts +257 -0
  189. package/tinyfish.ts +373 -0
  190. package/tool-activation.ts +169 -0
  191. package/tool-arguments.ts +23 -0
  192. package/upgrade-notice.ts +47 -0
  193. package/utils.ts +693 -0
  194. package/valyu.ts +177 -0
  195. package/video-extract.ts +398 -0
  196. package/web-tool-contract.ts +93 -0
  197. package/web-tool-core.ts +1810 -0
  198. package/xai-search.ts +443 -0
  199. package/you.ts +165 -0
  200. package/youtube-extract.ts +336 -0
  201. package/zai.ts +161 -0
@@ -0,0 +1,44 @@
1
+ /**
2
+ * PDF Content Extractor
3
+ *
4
+ * Converts PDFs to Markdown. The `auto` provider chain runs Datalab
5
+ * (deterministic, layout-aware) first, then Gemini API, with unpdf as the
6
+ * deterministic local fallback; the chain can also be pinned with
7
+ * `pdf.provider`.
8
+ */
9
+ import { type DatalabMode } from "./datalab-pdf-extract.ts";
10
+ export interface PDFExtractResult {
11
+ title: string;
12
+ /** The same Markdown written to outputPath. */
13
+ content: string;
14
+ outputPath: string;
15
+ }
16
+ export interface PDFExtractOptions {
17
+ maxPages?: number;
18
+ outputDir?: string;
19
+ filename?: string;
20
+ signal?: AbortSignal;
21
+ geminiTimeoutMs?: number;
22
+ }
23
+ export type PDFProvider = "auto" | "endpoint" | "gemini" | "datalab" | "unpdf";
24
+ export declare const PDF_PROVIDER_VALUES: Set<PDFProvider>;
25
+ export interface PDFConfig {
26
+ enabled: boolean;
27
+ maxSizeMB: number;
28
+ maxPages: number;
29
+ provider: PDFProvider;
30
+ datalabMode: DatalabMode;
31
+ datalabTimeoutMs: number;
32
+ }
33
+ export declare const DEFAULT_PDF_MAX_SIZE_MB = 20;
34
+ export declare const MAX_PDF_MAX_SIZE_MB = 50;
35
+ export declare const MAX_DATALAB_TIMEOUT_MS = 300000;
36
+ export declare function loadPDFConfig(): PDFConfig;
37
+ /**
38
+ * Extract text from a PDF buffer and save it to a Markdown file.
39
+ */
40
+ export declare function extractPDFToMarkdown(buffer: ArrayBuffer, url: string, options?: PDFExtractOptions): Promise<PDFExtractResult>;
41
+ /**
42
+ * Check if URL or content-type indicates a PDF
43
+ */
44
+ export declare function isPDF(url: string, contentType?: string): boolean;
@@ -0,0 +1,26 @@
1
+ import type { ExtractedContent } from "./extract.ts";
2
+ export interface SearchResult {
3
+ title: string;
4
+ url: string;
5
+ snippet: string;
6
+ /** "generated" when the snippet is text from the provider's own answer around a citation, not text from the page. */
7
+ snippetSource?: "generated";
8
+ }
9
+ export interface SearchResponse {
10
+ answer: string;
11
+ results: SearchResult[];
12
+ inlineContent?: ExtractedContent[];
13
+ }
14
+ export interface SearchOptions {
15
+ model?: string;
16
+ numResults?: number;
17
+ recencyFilter?: "day" | "week" | "month" | "year";
18
+ domainFilter?: string[];
19
+ signal?: AbortSignal;
20
+ }
21
+ export declare function isPerplexityAvailable(): boolean;
22
+ export declare function searchWithPerplexity(query: string, options?: SearchOptions): Promise<SearchResponse>;
23
+ /** Asks Sonar for a prose answer. The Search API returns only ranked pages, so prompts that need prose use this. */
24
+ export declare function askPerplexity(prompt: string, options?: {
25
+ signal?: AbortSignal;
26
+ }): Promise<string>;
@@ -0,0 +1,56 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { WebToolCore } from "./web-tool-contract.ts";
3
+ import { type McpServerInfo } from "./mcp-server.ts";
4
+ export type { McpServerInfo } from "./mcp-server.ts";
5
+ export type { WebToolCore, WebToolResult } from "./web-tool-contract.ts";
6
+ export interface PiWebToolCore extends WebToolCore {
7
+ readonly enabledToolNames: readonly string[];
8
+ /** Abort and settle pending calls, unsubscribe, then release this session's results. */
9
+ close(): Promise<void>;
10
+ }
11
+ /** The embedded entry admits Pi-authenticated search providers, but keeps all MCP input checks. */
12
+ export declare function createMcpServer(core: PiWebToolCore, info: McpServerInfo, enabledTools?: readonly string[]): import("@modelcontextprotocol/sdk/server").Server<{
13
+ method: string;
14
+ params?: {
15
+ [x: string]: unknown;
16
+ _meta?: {
17
+ [x: string]: unknown;
18
+ progressToken?: string | number | undefined;
19
+ "io.modelcontextprotocol/related-task"?: {
20
+ taskId: string;
21
+ } | undefined;
22
+ } | undefined;
23
+ } | undefined;
24
+ }, {
25
+ method: string;
26
+ params?: {
27
+ [x: string]: unknown;
28
+ _meta?: {
29
+ [x: string]: unknown;
30
+ progressToken?: string | number | undefined;
31
+ "io.modelcontextprotocol/related-task"?: {
32
+ taskId: string;
33
+ } | undefined;
34
+ } | undefined;
35
+ } | undefined;
36
+ }, {
37
+ [x: string]: unknown;
38
+ _meta?: {
39
+ [x: string]: unknown;
40
+ progressToken?: string | number | undefined;
41
+ "io.modelcontextprotocol/related-task"?: {
42
+ taskId: string;
43
+ } | undefined;
44
+ } | undefined;
45
+ }>;
46
+ /**
47
+ * Bind once from session_start to the actual context Pi supplied. Its live getters,
48
+ * model registry and auth owner remain intact; this does not recreate or copy them.
49
+ * A replacement runtime needs a new core. The host must await close on shutdown.
50
+ * Searches send the query, not the session transcript. No curator, summaries,
51
+ * background turns or page-answer model calls are installed by this adapter.
52
+ */
53
+ export declare function createPiWebToolCore({ pi, context }: {
54
+ pi: Pick<ExtensionAPI, "appendEntry" | "on">;
55
+ context: ExtensionContext;
56
+ }): PiWebToolCore;
@@ -0,0 +1,8 @@
1
+ import type { ExtensionAPI, ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import { type StoredSearchData } from "./storage.ts";
3
+ export declare function createPiSessionResults(pi: Pick<ExtensionAPI, "appendEntry">): {
4
+ ownedResults: Set<string>;
5
+ publish(data: StoredSearchData): void;
6
+ start(ctx: ExtensionContext): void;
7
+ close: () => void;
8
+ };
@@ -0,0 +1,9 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ interface QueritSearchOptions extends SearchOptions {
4
+ includeContent?: boolean;
5
+ }
6
+ export declare function isQueritAvailable(): boolean;
7
+ export declare function searchWithQuerit(query: string, options?: QueritSearchOptions): Promise<SearchResponse>;
8
+ export declare function extractWithQuerit(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent | null>;
9
+ export {};
@@ -0,0 +1,2 @@
1
+ import { type SummaryGenerationContext } from "./summary-review.ts";
2
+ export declare function rewriteSearchQuery(query: string, ctx: SummaryGenerationContext, signal: AbortSignal, modelSelector?: string): Promise<string>;
@@ -0,0 +1,56 @@
1
+ /**
2
+ * Pure, dependency-free renderer for web_search error / cancel results.
3
+ *
4
+ * WHY THIS EXISTS: the upstream web_search `renderResult` (index.ts) early-returns
5
+ * a SINGLE line on the error/cancel path, before the collapsed/expanded branch.
6
+ * That makes Ctrl+O (app.tools.expand) flip `expanded` with zero visible effect —
7
+ * a dead-end with no diagnostics. It also discards the partial search results
8
+ * gathered before the cancel, so even an expandable view would have nothing to show.
9
+ *
10
+ * This module is the single source of truth for the error/cancel render PLAN
11
+ * (plain strings, no theme/ANSI), so it is unit-testable without pi's runtime
12
+ * (@mariozechner/pi-tui Text/Box). index.ts.renderResult delegates to it and only
13
+ * applies theme colors + creates Text/Box components.
14
+ *
15
+ * Contract for callers:
16
+ * const plan = buildSearchErrorPlan(details);
17
+ * if (plan === null) ... // not an error/cancel result; use the normal renderer
18
+ * // collapsed: [statusLine, ...plan.collapsed, plan.expandHint].filter(Boolean)
19
+ * // expanded: plan.expanded
20
+ */
21
+ export interface CancelledQueryDetail {
22
+ query: string;
23
+ provider: string | null;
24
+ error: string | null;
25
+ resultCount: number;
26
+ }
27
+ export interface SearchErrorDetails {
28
+ /** The headline error/cancel message, e.g. "Search curation cancelled (stale)." */
29
+ error?: string;
30
+ cancelled?: boolean;
31
+ cancelReason?: string;
32
+ /** Did the curator browser page ever establish a connection? */
33
+ browserConnected?: boolean;
34
+ /** Age (ms) of the last curator heartbeat at cancel time, if known. */
35
+ lastHeartbeatAgeMs?: number | null;
36
+ /** Total queries the user requested. */
37
+ queryCount?: number;
38
+ /** Partial per-query results gathered before the cancel/error. */
39
+ cancelledQueries?: CancelledQueryDetail[];
40
+ /** Arbitrary extra diagnostic lines (e.g. URLs, response id) for non-cancel errors
41
+ * like fetch_content / get_search_content. Shown in the expanded view. */
42
+ extraLines?: string[];
43
+ }
44
+ export interface SearchErrorPlan {
45
+ /** Full diagnostic block, shown when expanded (Ctrl+O). */
46
+ expanded: string[];
47
+ /** Short preview lines, shown under the headline when collapsed. */
48
+ collapsed: string[];
49
+ /** The "... (N more lines, ctrl+o to expand)" hint, or null if nothing is hidden. */
50
+ expandHint: string | null;
51
+ }
52
+ /**
53
+ * Build the error/cancel render plan. Returns null when `details` carries no
54
+ * error/cancel signal (so the caller falls through to the normal success renderer).
55
+ */
56
+ export declare function buildSearchErrorPlan(details: SearchErrorDetails | undefined | null): SearchErrorPlan | null;
@@ -0,0 +1,78 @@
1
+ /** Ends the web_search and fetch_content descriptions while the policy is on, so a host can read the policy back. */
2
+ export declare const RETRIEVAL_ONLY_DESCRIPTION_SUFFIX = " Retrieval-only: no model calls.";
3
+ export interface RetrievalOnlyPolicy {
4
+ enabled: boolean;
5
+ /** Says how the policy was turned on, for error messages. */
6
+ source?: string;
7
+ }
8
+ export declare const SEARCH_PROVIDER_KINDS: {
9
+ readonly openai: "model";
10
+ readonly gemini: "model";
11
+ readonly xai: "model";
12
+ readonly mistral: "model";
13
+ readonly tabstack: "model";
14
+ readonly brave: "retrieval";
15
+ readonly parallel: "retrieval";
16
+ readonly "parallel-mcp": "retrieval";
17
+ readonly tinyfish: "retrieval";
18
+ readonly searchinfinity: "retrieval";
19
+ readonly querit: "retrieval";
20
+ readonly tavily: "retrieval";
21
+ readonly you: "retrieval";
22
+ readonly firecrawl: "retrieval";
23
+ readonly jina: "retrieval";
24
+ readonly searxng: "retrieval";
25
+ readonly degoog: "retrieval";
26
+ readonly duckduckgo: "retrieval";
27
+ readonly perplexity: "retrieval";
28
+ readonly kimi: "retrieval";
29
+ readonly exa: "retrieval";
30
+ readonly kagi: "retrieval";
31
+ readonly ollama: "retrieval";
32
+ readonly anysearch: "retrieval";
33
+ readonly valyu: "retrieval";
34
+ readonly bocha: "retrieval";
35
+ readonly baizhi: "retrieval";
36
+ readonly zai: "retrieval";
37
+ readonly keenable: "retrieval";
38
+ readonly ceramic: "retrieval";
39
+ readonly deepseek: "retrieval";
40
+ readonly linkup: "retrieval";
41
+ readonly ninerouter: "retrieval";
42
+ readonly cloudflare: "retrieval";
43
+ };
44
+ export declare const FETCH_PROVIDER_KINDS: {
45
+ readonly gemini: "model";
46
+ readonly http: "retrieval";
47
+ readonly firecrawl: "retrieval";
48
+ readonly crawl4ai: "retrieval";
49
+ readonly jina: "retrieval";
50
+ readonly tinyfish: "retrieval";
51
+ readonly querit: "retrieval";
52
+ readonly kagi: "retrieval";
53
+ readonly ollama: "retrieval";
54
+ readonly parallel: "retrieval";
55
+ readonly "parallel-mcp": "retrieval";
56
+ readonly brightdata: "retrieval";
57
+ readonly deepseek: "retrieval";
58
+ readonly exa: "retrieval";
59
+ readonly tabstack: "retrieval";
60
+ };
61
+ export declare const PDF_PROVIDER_KINDS: {
62
+ readonly gemini: "model";
63
+ readonly endpoint: "retrieval";
64
+ readonly datalab: "retrieval";
65
+ readonly unpdf: "retrieval";
66
+ };
67
+ /** Custom providers are not in the table and count as retrieval: they are the operator's responsibility. */
68
+ export declare function isModelSearchProvider(provider: string): boolean;
69
+ /**
70
+ * One policy per process: the first successful read fixes it, as tool definitions are fixed at load.
71
+ * Pi init and the MCP core pass the config they already parsed; other first readers parse the file and
72
+ * throw on an unparseable one without caching. A config edited after load takes effect on restart.
73
+ */
74
+ export declare function getRetrievalOnlyPolicy(config?: {
75
+ retrievalOnly?: unknown;
76
+ }): RetrievalOnlyPolicy;
77
+ export declare function retrievalOnlyError(route: string, policy?: RetrievalOnlyPolicy): Error;
78
+ export declare function retrievalOnlyExhaustedError(routeKind: string, skipped: readonly string[], policy?: RetrievalOnlyPolicy): Error;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * RSC Content Extractor
3
+ *
4
+ * Extracts readable content from Next.js React Server Components (RSC) flight payloads.
5
+ * RSC pages embed content as JSON in <script>self.__next_f.push([...])</script> tags.
6
+ */
7
+ export interface RSCExtractResult {
8
+ title: string;
9
+ content: string;
10
+ }
11
+ export declare function extractRSCContent(html: string): RSCExtractResult | null;
@@ -0,0 +1,7 @@
1
+ interface AnswerResult {
2
+ title: string;
3
+ url: string;
4
+ snippet: string;
5
+ }
6
+ export declare function formatSearchResultsAsAnswer(results: readonly AnswerResult[]): string;
7
+ export {};
@@ -0,0 +1 @@
1
+ export declare function normalizeSearchResultCount(value: number | undefined): number;
@@ -0,0 +1,7 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ interface SearchinfinitySearchOptions extends SearchOptions {
3
+ includeContent?: boolean;
4
+ }
5
+ export declare function isSearchinfinityAvailable(): boolean;
6
+ export declare function searchWithSearchinfinity(query: string, options?: SearchinfinitySearchOptions): Promise<SearchResponse>;
7
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isSearXNGAvailable(): boolean;
3
+ export declare function searchWithSearXNG(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,102 @@
1
+ import type { SearchResult } from "./perplexity.ts";
2
+ import type { ExtractedContent } from "./extract.ts";
3
+ export type SourceQuality = "official_docs" | "vendor_docs" | "repo_issue" | "blog" | "forum" | "news" | "unknown";
4
+ export type ClaimStatus = "supported" | "contradicted" | "unclear" | "missing-evidence";
5
+ export type RecencyFilter = "day" | "week" | "month" | "year";
6
+ export interface ResearchSource {
7
+ rank: number;
8
+ url: string;
9
+ title: string;
10
+ snippet?: string;
11
+ /** "generated" when the snippet is the search provider's own answer text around a citation, not page text. */
12
+ snippet_source?: "generated";
13
+ fetch_timestamp?: number;
14
+ content_hash?: string;
15
+ quality: SourceQuality;
16
+ fetched?: boolean;
17
+ fetch_error?: string;
18
+ }
19
+ export interface ResearchPassage {
20
+ passage_id: string;
21
+ source_url: string;
22
+ source_rank: number;
23
+ text: string;
24
+ extraction_span?: {
25
+ start: number;
26
+ end: number;
27
+ };
28
+ content_hash?: string;
29
+ /** "provider_summary" marks text written by the search provider (for example OpenAI or xAI answer text), not quoted from the page. */
30
+ origin?: "provider_summary";
31
+ }
32
+ export interface ClaimAssessment {
33
+ claim: string;
34
+ status: ClaimStatus;
35
+ supporting_passages: string[];
36
+ contradicting_passages: string[];
37
+ rationale: string;
38
+ confidence: number;
39
+ }
40
+ export interface ResearchArtifact {
41
+ id: string;
42
+ type: "research";
43
+ timestamp: number;
44
+ query: string;
45
+ sources: ResearchSource[];
46
+ passages: ResearchPassage[];
47
+ claims?: ClaimAssessment[];
48
+ provider?: string;
49
+ summary?: string;
50
+ content_hash?: string;
51
+ filters?: {
52
+ recency?: RecencyFilter;
53
+ domain_include?: string[];
54
+ domain_exclude?: string[];
55
+ };
56
+ errors?: Array<{
57
+ query: string;
58
+ error: string;
59
+ }>;
60
+ }
61
+ export interface ResearchSearchRequest {
62
+ query: string;
63
+ numResults: number;
64
+ recencyFilter?: RecencyFilter;
65
+ domainFilter?: string[];
66
+ }
67
+ export interface ResearchSearchResult {
68
+ url: string;
69
+ title: string;
70
+ snippet: string;
71
+ rank: number;
72
+ }
73
+ export interface ResearchSearchResponse {
74
+ provider: string;
75
+ results: ResearchSearchResult[];
76
+ summary?: string;
77
+ }
78
+ export interface ResearchProvider {
79
+ name: string;
80
+ search(req: ResearchSearchRequest): Promise<ResearchSearchResponse>;
81
+ }
82
+ export declare function classifySource(url: string): SourceQuality;
83
+ export declare function hashContent(text: string): string;
84
+ export declare function buildPassages(sources: ResearchSource[], fetched?: ExtractedContent[], claim?: string): ResearchPassage[];
85
+ export declare function assessClaim(claim: string, passages: ResearchPassage[]): ClaimAssessment;
86
+ interface RankedSearchResult extends SearchResult {
87
+ rank?: number;
88
+ }
89
+ export interface BuildArtifactInput {
90
+ query: string;
91
+ provider?: string;
92
+ summary?: string;
93
+ results: RankedSearchResult[];
94
+ fetched?: ExtractedContent[];
95
+ recency?: RecencyFilter;
96
+ domainFilter?: string[];
97
+ }
98
+ export declare function buildResearchArtifact(input: BuildArtifactInput): ResearchArtifact;
99
+ export declare function withClaimAssessment(artifact: ResearchArtifact, claims: string[]): ResearchArtifact;
100
+ export declare function storeResearchArtifact(artifact: ResearchArtifact): void;
101
+ export declare function getResearchArtifact(id: string): ResearchArtifact | null;
102
+ export {};
@@ -0,0 +1,66 @@
1
+ export type LookupAddress = {
2
+ address: string;
3
+ family: number;
4
+ };
5
+ export type Lookup = (hostname: string) => Promise<LookupAddress[]>;
6
+ type Fetch = typeof fetch;
7
+ export interface SsrfConfig {
8
+ allowRanges: string[];
9
+ trustEnvProxy: boolean;
10
+ }
11
+ export interface DomainPolicy {
12
+ allow: string[];
13
+ deny: string[];
14
+ }
15
+ export type RedirectPolicy = "same-origin";
16
+ export declare function loadFetchContentRedirectPolicy(): RedirectPolicy | undefined;
17
+ export declare function loadFetchContentUserAgent(): string;
18
+ /** fetchContent.userAgent when it is set, without the default. */
19
+ export declare function loadConfiguredFetchContentUserAgent(): string | undefined;
20
+ /** fetchContent.curl as an executable plus leading arguments, or null to use Node's fetch. */
21
+ export declare function loadFetchContentCurl(): string[] | null;
22
+ export declare function loadFetchContentDomainPolicy(): DomainPolicy;
23
+ export declare function loadSsrfConfig(): SsrfConfig;
24
+ interface ValidationOptions {
25
+ lookup?: Lookup;
26
+ /** Optional hostname policy for fetch_content target URLs. */
27
+ domainPolicy?: DomainPolicy;
28
+ /**
29
+ * CIDR ranges (e.g. "198.18.0.0/15") to exempt from the SSRF guard.
30
+ * Useful when a host runs a TUN/fake-IP proxy (Surge, Clash, Mihomo, ...)
31
+ * that resolves public domains into a reserved range. Entries are validated
32
+ * strictly; an invalid entry throws so misconfiguration is not silent.
33
+ */
34
+ allowRanges?: string[];
35
+ /**
36
+ * When true, let the proxy carrying the request resolve hostnames instead of
37
+ * performing local DNS lookups: an HTTP(S) proxy from the environment, or the
38
+ * `proxy` configured in web-search.json. A different per-call proxy never
39
+ * qualifies. Literal IPs and localhost remain blocked, and NO_PROXY hosts still
40
+ * use the local SSRF preflight. This does not configure proxy transport.
41
+ */
42
+ trustEnvProxy?: boolean;
43
+ /** Proxy pinned on the request via `__proxy`; defaults to the scoped proxy, like the transport. */
44
+ proxy?: string;
45
+ /** Allow loopback URLs for explicit provider base endpoints, not fetched targets. */
46
+ allowLoopback?: boolean;
47
+ }
48
+ interface RedirectRequestInitArgs {
49
+ from: URL;
50
+ to: URL;
51
+ init: RequestInit;
52
+ response: Response;
53
+ }
54
+ interface FetchRemoteOptions extends ValidationOptions {
55
+ fetch?: Fetch;
56
+ maxRedirects?: number;
57
+ onRedirect?: (args: RedirectRequestInitArgs) => RequestInit;
58
+ /** "same-origin" refuses any redirect that leaves the original URL's origin. */
59
+ redirects?: RedirectPolicy;
60
+ }
61
+ export declare function validateRemoteUrl(rawUrl: string | URL, options?: ValidationOptions): Promise<URL>;
62
+ export declare function fetchRemoteUrl(url: string | URL, init?: RequestInit, options?: FetchRemoteOptions): Promise<Response>;
63
+ /** The env proxy validateRemoteUrl trusts to resolve this URL instead of checking DNS locally, or null.
64
+ * A fetch that skipped the local check because of it must connect through it. */
65
+ export declare function trustedEnvProxyFor(url: URL, trustEnvProxy: boolean): string | null;
66
+ export {};
@@ -0,0 +1,69 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { ExtractedContent } from "./extract.ts";
3
+ import type { SearchResult } from "./perplexity.ts";
4
+ declare const FETCH_CACHE_VERSION = 1;
5
+ interface FetchCacheLimits {
6
+ maxEntries: number;
7
+ maxBytes: number;
8
+ }
9
+ export interface QueryResultData {
10
+ query: string;
11
+ answer: string;
12
+ results: SearchResult[];
13
+ error: string | null;
14
+ provider?: string;
15
+ providers?: string[];
16
+ }
17
+ interface FetchCacheRef {
18
+ version: typeof FETCH_CACHE_VERSION;
19
+ key: string;
20
+ storedAt: number;
21
+ }
22
+ interface StoredFetchUrlMetadata {
23
+ url: string;
24
+ title: string;
25
+ error: string | null;
26
+ contentLength: number;
27
+ mimeType?: string;
28
+ status?: number;
29
+ duration?: number;
30
+ }
31
+ export interface StoredSearchData {
32
+ id: string;
33
+ type: "search" | "fetch" | "research";
34
+ timestamp: number;
35
+ queries?: QueryResultData[];
36
+ urls?: ExtractedContent[];
37
+ artifact?: unknown;
38
+ fetchCache?: FetchCacheRef;
39
+ urlMetadata?: StoredFetchUrlMetadata[];
40
+ fetchCacheError?: string;
41
+ }
42
+ export declare function generateId(): string;
43
+ export declare function getFetchCacheDir(): string;
44
+ export declare function pruneExpiredFetchCache(now?: number, requestedLimits?: Partial<FetchCacheLimits>): void;
45
+ export declare function storeResult(id: string, data: StoredSearchData): void;
46
+ export declare function storeFetchedContentResult(id: string, data: StoredSearchData & {
47
+ type: "fetch";
48
+ urls: ExtractedContent[];
49
+ }): StoredSearchData;
50
+ export declare function getResult(id: string): StoredSearchData | null;
51
+ export declare function getAllResults(): StoredSearchData[];
52
+ export declare function deleteResult(id: string): boolean;
53
+ export declare function clearResults(): void;
54
+ /** Record that one more live session holds each of these results. */
55
+ export declare function holdResults(ids: Iterable<string>): void;
56
+ /** Release one session's hold on each result, and drop a result from memory once no live
57
+ * session holds it. Unlike deleteResult, the fetch cache files stay: the session journal
58
+ * still references them, and a later restore reads them back. */
59
+ export declare function releaseResults(ids: Iterable<string>): void;
60
+ /** Delete a result for one session that holds it. Other live sessions holding the same
61
+ * result keep it and its fetch cache file; the last holder deletes both. */
62
+ export declare function deleteHeldResult(id: string): void;
63
+ export declare function restoreFromSession(ctx: ExtensionContext): void;
64
+ /** Add one session's stored results to memory, leaving other sessions' results in place,
65
+ * and return the results it loaded. A host that runs several sessions at once (one extension
66
+ * instance per session) restores each with this, holds their ids with holdResults, and
67
+ * releases them with releaseResults. */
68
+ export declare function loadSessionResults(ctx: ExtensionContext): StoredSearchData[];
69
+ export {};
@@ -0,0 +1,33 @@
1
+ export type SummaryThinkingLevel = "off" | "minimal" | "low" | "medium" | "high" | "xhigh" | "max";
2
+ export interface ModelLike {
3
+ provider: string;
4
+ id: string;
5
+ }
6
+ export interface ModelRegistryLike<T extends ModelLike = ModelLike> {
7
+ find(provider: string, id: string): T | undefined;
8
+ getAvailable(): readonly T[];
9
+ }
10
+ /**
11
+ * Resolve a model through its native provider or a provider that routes that model ID.
12
+ *
13
+ * The direct registry fallback preserves explicit/native model resolution when a
14
+ * provider's availability snapshot does not include the configured model. Callers
15
+ * continue to apply their existing enabled-model and authentication checks.
16
+ */
17
+ export declare function findModelWithProviderRouting<T extends ModelLike>(registry: ModelRegistryLike<T>, provider: string, id: string): T | undefined;
18
+ /**
19
+ * Pi resolves `--models` and `enabledModels` against the available catalogue and exposes the
20
+ * result as `ctx.scopedModels`; an empty scope means every available model is allowed.
21
+ */
22
+ export declare function isModelInScope(model: ModelLike, scopedModels: ReadonlyArray<{
23
+ model: ModelLike;
24
+ }>): boolean;
25
+ /**
26
+ * Parse `current[:level]` or `provider/model-id[:level]`; `current` names the active Pi session model and
27
+ * resolves to undefined when there is none. Throws for any other value.
28
+ */
29
+ export declare function resolveHelperModelSelector(value: string, label: string, currentModel?: ModelLike): {
30
+ provider: string;
31
+ id: string;
32
+ thinkingLevel?: SummaryThinkingLevel;
33
+ } | undefined;
@@ -0,0 +1,30 @@
1
+ import type { ModelThinkingLevel } from "@earendil-works/pi-ai";
2
+ import type { complete, Api, Model } from "@earendil-works/pi-ai/compat";
3
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
4
+ import { type SummaryThinkingLevel } from "./summary-model-scope.ts";
5
+ import type { QueryResultData } from "./storage.ts";
6
+ type CompleteFunction = typeof complete;
7
+ export declare const SUMMARY_GENERATION_DEADLINE_MS = 30000;
8
+ export interface SummaryMeta {
9
+ model: string | null;
10
+ durationMs: number;
11
+ tokenEstimate: number;
12
+ fallbackUsed: boolean;
13
+ fallbackReason?: string;
14
+ phase?: "summary-model" | "deterministic-fallback";
15
+ edited?: boolean;
16
+ }
17
+ export type SummaryGenerationContext = Pick<ExtensionContext, "model" | "modelRegistry" | "sessionManager" | "scopedModels">;
18
+ export declare function buildSummaryPrompt(results: QueryResultData[], feedback?: string, instructions?: string): string;
19
+ export declare function buildDeterministicSummary(results: QueryResultData[]): {
20
+ summary: string;
21
+ meta: SummaryMeta;
22
+ };
23
+ export declare function resolveThinkingLevel(model: Model<Api>, requested?: SummaryThinkingLevel): Promise<ModelThinkingLevel | undefined>;
24
+ export declare function generateSummaryDraft(results: QueryResultData[], ctx: SummaryGenerationContext, signal?: AbortSignal, modelOverride?: string, feedback?: string, completeFn?: CompleteFunction, deadlineMs?: number, instructions?: string, options?: {
25
+ preferredFallback?: boolean;
26
+ }): Promise<{
27
+ summary: string;
28
+ meta: SummaryMeta;
29
+ }>;
30
+ export {};
@@ -0,0 +1,5 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ export declare function isTabstackAvailable(): boolean;
4
+ export declare function searchWithTabstack(query: string, options?: SearchOptions): Promise<SearchResponse>;
5
+ export declare function extractWithTabstack(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent | null>;
@@ -0,0 +1,7 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ interface TavilySearchOptions extends SearchOptions {
3
+ includeContent?: boolean;
4
+ }
5
+ export declare function isTavilyAvailable(): boolean;
6
+ export declare function searchWithTavily(query: string, options?: TavilySearchOptions): Promise<SearchResponse>;
7
+ export {};
@@ -0,0 +1,10 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ interface TinyFishSearchOptions extends SearchOptions {
4
+ includeContent?: boolean;
5
+ }
6
+ export declare function clearTinyFishConfigCache(): void;
7
+ export declare function isTinyFishAvailable(): boolean;
8
+ export declare function searchWithTinyFish(query: string, options?: TinyFishSearchOptions): Promise<SearchResponse>;
9
+ export declare function extractWithTinyFish(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent | null>;
10
+ export {};