@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,39 @@
1
+ export interface FetchContentParams {
2
+ url?: unknown;
3
+ urls?: unknown;
4
+ forceClone?: unknown;
5
+ prompt?: unknown;
6
+ timestamp?: unknown;
7
+ frames?: unknown;
8
+ model?: unknown;
9
+ mode?: unknown;
10
+ answerModel?: unknown;
11
+ fields?: unknown;
12
+ auth?: unknown;
13
+ proxy?: unknown;
14
+ redirects?: unknown;
15
+ }
16
+ export interface NormalizedFetchContentParams {
17
+ urlList: string[];
18
+ /** Parameter-level validation problems collected during normalization
19
+ * instead of throwing, so callers can report them together with their own
20
+ * checks in a single round-trip. */
21
+ problems: string[];
22
+ options: {
23
+ forceClone?: boolean;
24
+ prompt?: string;
25
+ timestamp?: string;
26
+ frames?: number;
27
+ model?: string;
28
+ mode?: "readable" | "raw" | "answer" | "extract";
29
+ answerModel?: string;
30
+ auth?: true | string;
31
+ proxy?: string;
32
+ redirects?: "same-origin";
33
+ };
34
+ }
35
+ /** Lists the parameter names that actually arrived, for error diagnostics:
36
+ * dropped tool-call arguments (provider issue) show up as missing keys here,
37
+ * malformed ones as present keys with unusable values. */
38
+ export declare function describeReceivedParams(params: FetchContentParams): string;
39
+ export declare function normalizeFetchContentParams(params: FetchContentParams): NormalizedFetchContentParams;
@@ -0,0 +1,37 @@
1
+ import type { JsonValue } from "@earendil-works/pi-ai";
2
+ import type { ModelRegistry } from "@earendil-works/pi-coding-agent";
3
+ type ItemType = "text" | "number" | "date";
4
+ interface FieldSpec {
5
+ type: "text" | "number" | "date" | "time" | "datetime" | "duration" | "list";
6
+ integer?: true;
7
+ unit?: string;
8
+ items?: ItemType;
9
+ instructions?: string;
10
+ }
11
+ export type FieldResult = {
12
+ status: "extracted";
13
+ value: JsonValue;
14
+ confidence: number;
15
+ line?: string;
16
+ } | {
17
+ status: "uncertain";
18
+ guess: JsonValue;
19
+ confidence?: number;
20
+ line?: string;
21
+ notFound?: true;
22
+ } | {
23
+ status: "null";
24
+ };
25
+ export type PageExtraction = {
26
+ fields: Record<string, FieldResult>;
27
+ cut: boolean;
28
+ } | {
29
+ error: string;
30
+ };
31
+ export declare function parseExtractFields(fields: unknown): Record<string, FieldSpec>;
32
+ /** Provider failures, including Cloudflare not being set up in Pi, become `{ error }`; a caller abort is rethrown. */
33
+ export declare function extractPageFields(page: string, fields: Record<string, FieldSpec>, context: {
34
+ modelRegistry?: Pick<ModelRegistry, "getProviderAuth">;
35
+ }, signal?: AbortSignal, referenceDate?: string): Promise<PageExtraction>;
36
+ export declare function formatPageExtraction(extraction: PageExtraction): string;
37
+ export {};
@@ -0,0 +1,18 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ export interface FirecrawlSsrfOptions {
4
+ allowRanges: string[];
5
+ trustEnvProxy: boolean;
6
+ }
7
+ export interface FirecrawlExtractOptions extends Pick<ExtractOptions, "timeoutMs" | "lookup"> {
8
+ ssrf?: FirecrawlSsrfOptions;
9
+ }
10
+ interface FirecrawlSearchOptions extends SearchOptions, Pick<ExtractOptions, "timeoutMs" | "lookup"> {
11
+ includeContent?: boolean;
12
+ ssrf?: FirecrawlSsrfOptions;
13
+ }
14
+ export declare function clearFirecrawlConfigCache(): void;
15
+ export declare function isFirecrawlAvailable(): boolean;
16
+ export declare function searchWithFirecrawl(query: string, options?: FirecrawlSearchOptions): Promise<SearchResponse>;
17
+ export declare function extractWithFirecrawl(url: string, signal?: AbortSignal, options?: FirecrawlExtractOptions): Promise<ExtractedContent | null>;
18
+ export {};
@@ -0,0 +1,9 @@
1
+ export declare function isAdcAuthSelected(): boolean;
2
+ export declare function getAdcProject(): string | null;
3
+ export declare function getAdcLocation(): string | null;
4
+ export declare function getVertexApiBase(project: string, location: string): string;
5
+ export declare function isVertexHost(origin: string): boolean;
6
+ export declare function clearAdcTokenCache(): void;
7
+ export declare function getAdcAccessToken(signal?: AbortSignal): Promise<string>;
8
+ export declare function isGeminiAdcAvailable(): boolean;
9
+ export declare function redactAdcToken(text: string): string;
@@ -0,0 +1,37 @@
1
+ export declare const API_BASE = "https://generativelanguage.googleapis.com/v1beta";
2
+ export declare const DEFAULT_MODEL = "gemini-3.6-flash";
3
+ export declare function getApiKey(signal?: AbortSignal): Promise<string | null>;
4
+ export declare function getApiHost(): string;
5
+ export declare function getVersionedApiBase(): string;
6
+ export declare function getUploadBase(): string;
7
+ /**
8
+ * Re-point a provider-returned URL at the configured API host (gateway), keeping
9
+ * path and query. No-op when host is unset (already the Google origin).
10
+ */
11
+ export declare function rewriteUploadUrlOrigin(url: string): string;
12
+ export declare function getCloudflareApiKey(): string | null;
13
+ export declare function isGatewayConfigured(): boolean;
14
+ export declare function buildAuthHeaders(apiKey?: string | null, cloudflareApiKey?: string | null): Record<string, string>;
15
+ export declare function redactGeminiApiResponse(response: Response, text: string, apiKey?: string | null, adcToken?: string | null): string;
16
+ export declare function fetchGeminiApi(url: string | URL, init?: RequestInit, apiKey?: string | null): Promise<Response>;
17
+ export declare function isGeminiApiAvailable(): boolean;
18
+ /**
19
+ * Whether the Gemini Files-API paths (YouTube and local video analysis) can
20
+ * authenticate. These use the Gemini Files API and metadata endpoints, which do
21
+ * not support ADC, so they still require an API key or a Cloudflare gateway.
22
+ */
23
+ export declare function isGeminiApiAvailableWithVideo(): boolean;
24
+ export interface GeminiApiOptions {
25
+ apiKey?: string;
26
+ model?: string;
27
+ mimeType?: string;
28
+ signal?: AbortSignal;
29
+ timeoutMs?: number;
30
+ }
31
+ export interface GeminiGenerateContentResult {
32
+ text: string;
33
+ finishReason?: string;
34
+ blockReason?: string;
35
+ }
36
+ export declare function queryGeminiApiWithInlineData(prompt: string, data: string, mimeType: string, options?: GeminiApiOptions): Promise<GeminiGenerateContentResult>;
37
+ export declare function queryGeminiApiWithVideo(prompt: string, videoUri: string, options?: GeminiApiOptions): Promise<string>;
@@ -0,0 +1,8 @@
1
+ export interface GeminiPDFExtractOptions {
2
+ pages?: number;
3
+ maxPages: number;
4
+ title: string;
5
+ signal?: AbortSignal;
6
+ timeoutMs?: number;
7
+ }
8
+ export declare function extractPDFViaGemini(buffer: ArrayBuffer, options: GeminiPDFExtractOptions): Promise<string>;
@@ -0,0 +1,76 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { BrowserCookieConsent } from "./gemini-web-config.ts";
3
+ import { type SearchResponse, type SearchOptions } from "./perplexity.ts";
4
+ import { type OffTopicJudgeModel } from "./offtopic-judge.ts";
5
+ export declare const RESOLVED_SEARCH_PROVIDERS: readonly ["openai", "brave", "parallel", "parallel-mcp", "tinyfish", "searchinfinity", "querit", "tavily", "you", "firecrawl", "jina", "searxng", "degoog", "duckduckgo", "perplexity", "gemini", "kimi", "exa", "kagi", "ollama", "anysearch", "xai", "mistral", "valyu", "bocha", "baizhi", "zai", "keenable", "ceramic", "deepseek", "linkup", "ninerouter", "cloudflare", "tabstack"];
6
+ export declare const REMOVED_SEARCH_PROVIDERS: readonly ["serper", "serpapi", "serply", "searchapi", "serpbase", "autom", "cloro", "xcrawl", "serpdive", "search1api", "outcrawl", "sofya", "specstream", "brightdata"];
7
+ export type BuiltinSearchProvider = typeof RESOLVED_SEARCH_PROVIDERS[number];
8
+ /** A provider name defined under customSearchProviders in web-search.json. */
9
+ export type CustomSearchProvider = string & {
10
+ readonly customSearchProvider: true;
11
+ };
12
+ export type ResolvedSearchProvider = BuiltinSearchProvider | CustomSearchProvider;
13
+ export type SearchProvider = "auto" | "all" | ResolvedSearchProvider;
14
+ export type SearchProviderSelection = SearchProvider | ResolvedSearchProvider[];
15
+ /** `customProviders` lists the allowed custom providers that have a credential source, in config order. */
16
+ export type ProviderAvailability = {
17
+ all: boolean;
18
+ customProviders?: string[];
19
+ } & Record<BuiltinSearchProvider, boolean>;
20
+ export type SearchProviderErrorKind = "transient" | "quota" | "network" | "credential" | "config" | "auth" | "invalid-request" | "invalid-response" | "unsupported" | "aborted" | "unknown";
21
+ export interface SearchRoutingConfig {
22
+ providers: ResolvedSearchProvider[];
23
+ useCurrentModel?: boolean;
24
+ fallbackOn: Array<typeof VALID_ROUTING_KINDS[number]>;
25
+ /** Total budget for one routed search across every candidate, in milliseconds. */
26
+ timeoutMs?: number;
27
+ /** Classifier that judges the "off-topic" fallback; required when fallbackOn lists it. */
28
+ offTopicModel?: OffTopicJudgeModel;
29
+ }
30
+ export declare class SearchProviderError extends Error {
31
+ readonly provider: ResolvedSearchProvider;
32
+ readonly kind: SearchProviderErrorKind;
33
+ readonly status?: number;
34
+ readonly causeError: unknown;
35
+ constructor(provider: ResolvedSearchProvider, kind: SearchProviderErrorKind, message: string, status: number | undefined, cause: unknown);
36
+ }
37
+ export interface ProviderSearchResponse extends SearchResponse {
38
+ provider: ResolvedSearchProvider;
39
+ }
40
+ export interface ProviderSearchFailure {
41
+ provider: ResolvedSearchProvider;
42
+ error: string;
43
+ }
44
+ export interface AttributedSearchResponse extends SearchResponse {
45
+ provider: ResolvedSearchProvider | "all";
46
+ providerResponses?: ProviderSearchResponse[];
47
+ providerErrors?: ProviderSearchFailure[];
48
+ }
49
+ export declare const ALL_SEARCH_PROVIDERS: BuiltinSearchProvider[];
50
+ declare const VALID_ROUTING_KINDS: readonly ["transient", "quota", "network", "invalid-response", "unsupported", "empty", "domain-miss", "off-topic"];
51
+ export declare function getConfiguredSearchRouting(): SearchRoutingConfig | undefined;
52
+ export declare function removedSearchProviderMessage(name: string): string | undefined;
53
+ export declare function assertSearchProviderSelectionAllowed(selection: SearchProviderSelection, label?: string, allowedProviders?: ResolvedSearchProvider[] | undefined): void;
54
+ export declare function getAllowedSearchProviders(): readonly ResolvedSearchProvider[];
55
+ export declare function getCustomSearchProviderNames(): string[];
56
+ export declare function getAvailableCustomSearchProviders(): string[];
57
+ export declare function normalizeSearchProviderSelection(value: unknown, label?: string, customProviders?: ReadonlyMap<string, unknown>): SearchProviderSelection;
58
+ /** Strict parser for tool-call `provider` arguments; config values keep the lenient normalizer. */
59
+ export declare function parseProviderArgument(value: unknown): SearchProviderSelection | undefined;
60
+ /** Validate the original arguments, before config can supply an implicit provider. */
61
+ export declare function validateSearchModelOverride(provider: unknown, model: unknown): string | undefined;
62
+ export interface FullSearchOptions extends SearchOptions {
63
+ provider?: SearchProviderSelection;
64
+ /** The caller already substituted the configured default for an omitted or "auto" provider. */
65
+ providerFromConfig?: boolean;
66
+ includeContent?: boolean;
67
+ extensionContext?: ExtensionContext;
68
+ /** Lets an explicit Gemini search ask the user to turn on browser cookie access. */
69
+ browserCookieConsent?: BrowserCookieConsent;
70
+ /** Forwarded to providers that understand them (category: Exa; objective: Exa, Parallel); ignored elsewhere. */
71
+ category?: string;
72
+ objective?: string;
73
+ }
74
+ export declare function providerLabel(provider: ResolvedSearchProvider): string;
75
+ export declare function search(query: string, options?: FullSearchOptions): Promise<AttributedSearchResponse>;
76
+ export {};
@@ -0,0 +1,3 @@
1
+ import { type ExtractedContent } from "./extract.ts";
2
+ export declare function extractWithUrlContext(url: string, signal?: AbortSignal): Promise<ExtractedContent | null>;
3
+ export declare function extractWithGeminiWeb(url: string, signal?: AbortSignal): Promise<ExtractedContent | null>;
@@ -0,0 +1,25 @@
1
+ declare const BROWSER_COOKIE_PRESETS: readonly ["helium", "ardia", "chrome", "brave", "arc", "chromium", "edge"];
2
+ export type BrowserCookiePreset = typeof BROWSER_COOKIE_PRESETS[number];
3
+ export interface BrowserCookieSelection {
4
+ browser?: BrowserCookiePreset;
5
+ profile?: string;
6
+ }
7
+ /** How a tool call can get browser cookie access turned on. */
8
+ export interface BrowserCookieConsent {
9
+ /** Asks the user; resolves true once access is on, false on a no or when signal aborts. Absent without a UI. */
10
+ ask?: (signal?: AbortSignal) => Promise<boolean>;
11
+ /** Pi command that turns access on or off; absent outside Pi. */
12
+ command?: string;
13
+ }
14
+ export declare function normalizeChromeProfile(value: unknown): string | undefined;
15
+ export declare function parseBrowserCookiePreset(value: unknown, label: string): BrowserCookiePreset;
16
+ export declare function getBrowserCookieSelectionFromConfig(): BrowserCookieSelection;
17
+ /** The browser a session grant chose, otherwise the configured selection. */
18
+ export declare function getBrowserCookieSelection(): BrowserCookieSelection;
19
+ /** Turns browser cookie access on until the process exits, without saving anything. */
20
+ export declare function grantBrowserCookieAccessForSession(selection: BrowserCookieSelection): void;
21
+ export declare function revokeBrowserCookieAccessForSession(): void;
22
+ /** Call after writing web-search.json so the next read sees the new browser selection. */
23
+ export declare function clearGeminiWebConfigCache(): void;
24
+ export declare function isBrowserCookieAccessAllowed(): boolean;
25
+ export {};
@@ -0,0 +1,31 @@
1
+ import { type BrowserCookieDiagnosticDetails, type CookieMap } from "./chrome-cookies.ts";
2
+ import { type BrowserCookieConsent } from "./gemini-web-config.ts";
3
+ export declare const DEFAULT_GEMINI_WEB_MODEL = "gemini-3.1-pro";
4
+ export declare function setGeminiFetchOverrideForTests(fetchImpl: typeof fetch | null): void;
5
+ export declare const GEMINI_MAX_HEADER_SIZE: number;
6
+ export declare function createGeminiFetch(undiciImpl: typeof import("undici")): typeof fetch;
7
+ export declare function resolveGeminiFetch(): Promise<typeof fetch>;
8
+ export interface GeminiWebOptions {
9
+ youtubeUrl?: string;
10
+ model?: string;
11
+ files?: GeminiWebFile[];
12
+ signal?: AbortSignal;
13
+ timeoutMs?: number;
14
+ }
15
+ export interface GeminiWebFile {
16
+ path: string;
17
+ mimeType: string;
18
+ }
19
+ export declare function isGeminiWebAvailable(chromeProfile?: string): Promise<CookieMap | null>;
20
+ export declare function getGeminiWebAvailabilityDiagnostic(): string | null;
21
+ /** Tells the agent how the user can let Gemini Web use the Google login from their browser.
22
+ * Lines after the first start with indent. */
23
+ export declare function browserCookieAccessHint(consent?: BrowserCookieConsent, indent?: string): string;
24
+ /** browserCookieAccessHint in one line, for lists of setup options. */
25
+ export declare function browserCookieAccessHintLine(): string;
26
+ /** For routes where Gemini Web is the only way left: asks the user when cookie access is off.
27
+ * True when access is now on and the caller should try Gemini Web again. */
28
+ export declare function requestBrowserCookieAccess(consent: BrowserCookieConsent | undefined, signal: AbortSignal | undefined): Promise<boolean>;
29
+ export declare function getGeminiWebAvailabilityDiagnosticDetails(): BrowserCookieDiagnosticDetails | null;
30
+ export declare function getActiveGoogleEmail(cookies: CookieMap): Promise<string | null>;
31
+ export declare function queryWithCookies(prompt: string, cookieMap: CookieMap, options?: GeminiWebOptions): Promise<string>;
@@ -0,0 +1,6 @@
1
+ import type { ExtractedContent } from "./extract.ts";
2
+ import type { GitHubUrlInfo } from "./github-extract.ts";
3
+ export declare function checkGhAvailable(signal?: AbortSignal): Promise<boolean>;
4
+ export declare function showGhHint(): void;
5
+ export declare function checkRepoSize(owner: string, repo: string): Promise<number | null>;
6
+ export declare function fetchViaApi(url: string, owner: string, repo: string, info: GitHubUrlInfo, sizeNote?: string): Promise<ExtractedContent | null>;
@@ -0,0 +1,19 @@
1
+ import type { ExtractedContent } from "./extract.ts";
2
+ export interface GitHubUrlInfo {
3
+ owner: string;
4
+ repo: string;
5
+ ref?: string;
6
+ refIsFullSha: boolean;
7
+ path?: string;
8
+ type: "root" | "blob" | "tree";
9
+ }
10
+ export declare function parseGitHubUrl(url: string): GitHubUrlInfo | null;
11
+ export declare function extractGitHub(url: string, signal?: AbortSignal, forceClone?: boolean): Promise<ExtractedContent | null>;
12
+ /** Mark the clones these URLs name as used now. A session that restores results from history
13
+ * (its own, or one it was forked from) holds their clone paths without fetching them again. */
14
+ export declare function touchClones(urls: Iterable<string>): void;
15
+ /** Remove finished clones no fetch has returned since `time`. A host that runs several
16
+ * sessions at once passes when its oldest live session started: no live session can have
17
+ * been given those paths, so they are reclaimed while sessions keep overlapping. */
18
+ export declare function releaseClonesUnusedSince(time: number): void;
19
+ export declare function clearCloneCache(): void;
@@ -0,0 +1,28 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ type Kind = "pull" | "issue";
3
+ export interface GitHubIssuePrUrlInfo {
4
+ owner: string;
5
+ repo: string;
6
+ kind: Kind;
7
+ number: number;
8
+ anchor?: string;
9
+ }
10
+ interface RenderData {
11
+ url: string;
12
+ owner: string;
13
+ repo: string;
14
+ kind: Kind;
15
+ number: number;
16
+ anchor?: string;
17
+ view: Record<string, unknown>;
18
+ reviewThreads: Record<string, unknown>[];
19
+ reviewThreadsBounded?: boolean;
20
+ reviewThreadsUnavailable?: boolean;
21
+ fallbackNotes: string[];
22
+ /** Retrieval tool the hints may name: unset means the default name, null means retrieval is not registered. */
23
+ retrievalTool?: string | null;
24
+ }
25
+ export declare function parseGitHubIssuePrUrl(url: string): GitHubIssuePrUrlInfo | null;
26
+ export declare function renderGitHubPrIssue(data: RenderData): ExtractedContent;
27
+ export declare function extractGitHubIssuePr(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent | null>;
28
+ export {};
@@ -0,0 +1,53 @@
1
+ import type { AgentToolResult, ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ import type { ExtractedContent } from "./extract.ts";
3
+ import { type ProviderAvailability, type SearchProvider, type SearchProviderSelection } from "./gemini-search.ts";
4
+ export type { ProviderAvailability } from "./gemini-search.ts";
5
+ import { type QueryResultData } from "./storage.ts";
6
+ import { type SummaryGenerationContext } from "./summary-review.ts";
7
+ import { isOpenAISubscriptionModelSelected } from "./openai-search.ts";
8
+ type CuratorWorkflow = "summary-review";
9
+ export type CuratorProvider = SearchProvider;
10
+ export declare function getSummaryGenerationDeadlineMs(): number;
11
+ export declare function getSummaryInstructions(): string | undefined;
12
+ export declare function resolveCuratorDefaultProvider(provider: SearchProviderSelection, available: ProviderAvailability, ctx?: Parameters<typeof isOpenAISubscriptionModelSelected>[0], options?: Pick<PendingCurate, "numResults" | "recencyFilter">): SearchProvider;
13
+ interface PendingCurate {
14
+ phase: "searching" | "curating";
15
+ workflow: CuratorWorkflow;
16
+ summaryContext: SummaryGenerationContext;
17
+ searchResults: Map<number, QueryResultData>;
18
+ resultSlots: Map<number, number>;
19
+ allInlineContent: ExtractedContent[];
20
+ queryList: string[];
21
+ includeContent: boolean;
22
+ numResults?: number;
23
+ recencyFilter?: "day" | "week" | "month" | "year";
24
+ domainFilter?: string[];
25
+ category?: string;
26
+ objective?: string;
27
+ availableProviders: ProviderAvailability;
28
+ defaultProvider: SearchProvider;
29
+ searchProvider: SearchProviderSelection;
30
+ configDefaultProvider?: SearchProviderSelection;
31
+ summaryModels: Array<{
32
+ value: string;
33
+ label: string;
34
+ }>;
35
+ defaultSummaryModel: string | null;
36
+ timeoutSeconds: number;
37
+ proxy?: string;
38
+ curatorUrl?: string;
39
+ onUpdate: ((update: {
40
+ content: Array<{
41
+ type: string;
42
+ text: string;
43
+ }>;
44
+ details?: Record<string, unknown>;
45
+ }) => void) | undefined;
46
+ signal: AbortSignal | undefined;
47
+ abortSearches: () => void;
48
+ finish: (value: AgentToolResult<Record<string, unknown>>) => void;
49
+ cancel: (reason?: "user" | "stale") => void;
50
+ browserPromise?: Promise<void>;
51
+ browserOpenError?: string;
52
+ }
53
+ export default function (pi: ExtensionAPI): void;
@@ -0,0 +1,7 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ interface JinaSearchOptions extends SearchOptions {
3
+ includeContent?: boolean;
4
+ }
5
+ export declare function isJinaSearchAvailable(): boolean;
6
+ export declare function searchWithJina(query: string, options?: JinaSearchOptions): Promise<SearchResponse>;
7
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ import { type SsrfConfig } from "./ssrf-protection.ts";
4
+ interface KagiSearchOptions extends SearchOptions {
5
+ includeContent?: boolean;
6
+ }
7
+ export interface KagiExtractOptions extends Pick<ExtractOptions, "timeoutMs" | "lookup"> {
8
+ ssrf?: SsrfConfig;
9
+ }
10
+ export declare function isKagiAvailable(): boolean;
11
+ export declare function searchWithKagi(query: string, options?: KagiSearchOptions): Promise<SearchResponse>;
12
+ export declare function isKagiExtractAvailable(): boolean;
13
+ export declare function extractWithKagi(url: string, signal?: AbortSignal, options?: KagiExtractOptions): Promise<ExtractedContent | null>;
14
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isKeenableAvailable(): boolean;
3
+ export declare function searchWithKeenable(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,4 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ export declare function isKimiSearchAvailable(ctx?: ExtensionContext): Promise<boolean>;
4
+ export declare function searchWithKimi(query: string, options?: SearchOptions, ctx?: ExtensionContext): Promise<SearchResponse>;
@@ -0,0 +1,5 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isLinkupAvailable(): boolean;
3
+ export declare function searchWithLinkup(query: string, options?: SearchOptions & {
4
+ includeContent?: boolean;
5
+ }): Promise<SearchResponse>;
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ export {};
@@ -0,0 +1,10 @@
1
+ import { Server } from "@modelcontextprotocol/sdk/server/index.js";
2
+ import type { WebToolCore } from "./web-tool-contract.ts";
3
+ export interface McpServerInfo {
4
+ name: string;
5
+ version: string;
6
+ }
7
+ /** Serves enabledTools (default: all four). Only a host with a live Pi context may enable piContext. */
8
+ export declare function createMcpServer(core: WebToolCore, info: McpServerInfo, enabledTools?: readonly string[], options?: {
9
+ piContext?: boolean;
10
+ }): Server;
@@ -0,0 +1,16 @@
1
+ import { type TSchema } from "typebox";
2
+ export interface McpToolDefinition {
3
+ name: string;
4
+ description: string;
5
+ inputSchema: TSchema;
6
+ annotations: {
7
+ readOnlyHint: boolean;
8
+ destructiveHint?: boolean;
9
+ openWorldHint: boolean;
10
+ };
11
+ }
12
+ export declare const MCP_TOOL_DEFINITIONS: readonly McpToolDefinition[];
13
+ /** Returns human-readable validation problems; an empty array means the arguments are valid. */
14
+ export declare function validateMcpToolArguments(tool: McpToolDefinition, args: unknown, { piContext }?: {
15
+ piContext?: boolean;
16
+ }): string[];
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isMistralAvailable(): boolean;
3
+ export declare function searchWithMistral(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isNineRouterAvailable(): boolean;
3
+ export declare function searchWithNineRouter(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,26 @@
1
+ import type { ModelRegistry } from "@earendil-works/pi-coding-agent";
2
+ declare const LABELS: readonly ["addresses", "off_topic"];
3
+ type Label = typeof LABELS[number];
4
+ /** The only Pi classifier references accepted, each with its measured off_topic threshold (docs/offtopic-judge.md). */
5
+ export declare const OFFTOPIC_JUDGE_MODELS: {
6
+ readonly "cloudflare-workers-ai/@cf/cloudflare/clef": 0.85;
7
+ readonly "typesafe/jev-latest": 0.85;
8
+ readonly "cloudflare-workers-ai/typesafe/jev-1.14.0": 0.85;
9
+ };
10
+ export type OffTopicJudgeModel = keyof typeof OFFTOPIC_JUDGE_MODELS;
11
+ export type OffTopicResult = {
12
+ title: string;
13
+ url: string;
14
+ snippet: string;
15
+ };
16
+ export type OffTopicJudgment = {
17
+ probabilities: Record<Label, number>;
18
+ } | {
19
+ error: string;
20
+ };
21
+ /** Returns the model's probabilities for "addresses" and "off_topic"; every model failure is an error, a caller abort is rethrown. */
22
+ export declare function judgeOffTopic(model: OffTopicJudgeModel, query: string, response: {
23
+ answer: string;
24
+ results: OffTopicResult[];
25
+ }, modelRegistry: Pick<ModelRegistry, "findOfType" | "classify">, signal?: AbortSignal): Promise<OffTopicJudgment>;
26
+ export {};
@@ -0,0 +1,14 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ import { type SsrfConfig } from "./ssrf-protection.ts";
4
+ interface OllamaSearchOptions extends SearchOptions {
5
+ includeContent?: boolean;
6
+ }
7
+ export interface OllamaExtractOptions extends Pick<ExtractOptions, "timeoutMs" | "lookup"> {
8
+ ssrf?: SsrfConfig;
9
+ }
10
+ export declare function isOllamaAvailable(): boolean;
11
+ export declare function searchWithOllama(query: string, options?: OllamaSearchOptions): Promise<SearchResponse>;
12
+ export declare function isOllamaFetchAvailable(): boolean;
13
+ export declare function extractWithOllama(url: string, signal?: AbortSignal, options?: OllamaExtractOptions): Promise<ExtractedContent | null>;
14
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ type ProviderHeaders = Record<string, string | null>;
4
+ export declare class OpenAIAlphaSearchUnsupportedError extends Error {
5
+ }
6
+ interface OpenAIAuth {
7
+ provider: string;
8
+ apiKey: string;
9
+ model: string;
10
+ headers: ProviderHeaders;
11
+ responsesUrl: string;
12
+ useCodexEndpoint?: boolean;
13
+ useProviderBaseUrl?: boolean;
14
+ }
15
+ export declare function isOpenAISubscriptionModelSelected(ctx?: Pick<ExtensionContext, "model"> & {
16
+ modelRegistry?: Pick<ExtensionContext["modelRegistry"], "isUsingOAuth">;
17
+ }): boolean;
18
+ export declare function isCurrentModelHostedSearchEligible(ctx?: Pick<ExtensionContext, "model">): boolean;
19
+ export declare function resolveOpenAIAuth(ctx?: ExtensionContext, signal?: AbortSignal, model?: string): Promise<OpenAIAuth | undefined>;
20
+ export declare function isOpenAISearchAvailable(ctx?: ExtensionContext): Promise<boolean>;
21
+ export declare function searchWithOpenAI(query: string, options?: SearchOptions, ctx?: ExtensionContext): Promise<SearchResponse>;
22
+ export declare function searchWithCurrentModelOpenAI(query: string, options?: SearchOptions, ctx?: ExtensionContext): Promise<SearchResponse>;
23
+ export {};
@@ -0,0 +1,22 @@
1
+ import type { Usage } from "@earendil-works/pi-ai/compat";
2
+ import type { ExtensionContext } from "@earendil-works/pi-coding-agent";
3
+ export interface PageAnswer {
4
+ text: string;
5
+ model: string;
6
+ inputChars: number;
7
+ originalInputChars: number;
8
+ truncated: boolean;
9
+ /** The answer call's usage, for the tool result's `usage` (Pi's usage accounting). */
10
+ usage: Usage;
11
+ }
12
+ export declare function answerFromPage(input: {
13
+ question: string;
14
+ pageText: string;
15
+ sourceUrl: string;
16
+ model?: string;
17
+ images?: Array<{
18
+ data: string;
19
+ mimeType: string;
20
+ label?: string;
21
+ }>;
22
+ }, ctx: ExtensionContext, signal?: AbortSignal): Promise<PageAnswer>;
@@ -0,0 +1,10 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ interface ParallelMcpSearchOptions extends SearchOptions {
4
+ includeContent?: boolean;
5
+ objective?: string;
6
+ }
7
+ export declare function isParallelMcpAvailable(): boolean;
8
+ export declare function searchWithParallelMcp(query: string, options?: ParallelMcpSearchOptions): Promise<SearchResponse>;
9
+ export declare function extractWithParallelMcp(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent | null>;
10
+ export {};
@@ -0,0 +1,13 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ interface ParallelSearchOptions extends SearchOptions {
4
+ includeContent?: boolean;
5
+ objective?: string;
6
+ }
7
+ export declare function clearParallelConfigCache(): void;
8
+ export declare function resolveParallelApiKey(signal?: AbortSignal): Promise<string | null>;
9
+ export declare function hasParallelApiKey(): boolean;
10
+ export declare function isParallelAvailable(): boolean;
11
+ export declare function searchWithParallel(query: string, options?: ParallelSearchOptions): Promise<SearchResponse>;
12
+ export declare function extractWithParallel(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent | null>;
13
+ export {};