@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,2 @@
1
+ /** Observe cancellation while awaiting work that cannot itself be cancelled (such as import()). */
2
+ export declare function awaitWithAbort<T>(operation: Promise<T>, signal?: AbortSignal): Promise<T>;
@@ -0,0 +1,33 @@
1
+ export interface ActivityEntry {
2
+ id: string;
3
+ type: "api" | "fetch";
4
+ startTime: number;
5
+ endTime?: number;
6
+ query?: string;
7
+ url?: string;
8
+ status: number | null;
9
+ error?: string;
10
+ }
11
+ export interface RateLimitInfo {
12
+ used: number;
13
+ max: number;
14
+ oldestTimestamp: number | null;
15
+ windowMs: number;
16
+ }
17
+ export declare class ActivityMonitor {
18
+ private entries;
19
+ private readonly maxEntries;
20
+ private listeners;
21
+ private rateLimitInfo;
22
+ private nextId;
23
+ logStart(partial: Omit<ActivityEntry, "id" | "startTime" | "status">): string;
24
+ logComplete(id: string, status: number): void;
25
+ logError(id: string, error: string): void;
26
+ getEntries(): readonly ActivityEntry[];
27
+ getRateLimitInfo(): RateLimitInfo;
28
+ updateRateLimit(info: RateLimitInfo): void;
29
+ onUpdate(callback: () => void): () => void;
30
+ clear(): void;
31
+ private notify;
32
+ }
33
+ export declare const activityMonitor: ActivityMonitor;
@@ -0,0 +1,7 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ interface AnySearchSearchOptions extends SearchOptions {
3
+ includeContent?: boolean;
4
+ }
5
+ export declare function isAnySearchAvailable(): boolean;
6
+ export declare function searchWithAnySearch(query: string, options?: AnySearchSearchOptions): Promise<SearchResponse>;
7
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type BrowserCookiePreset } from "./gemini-web-config.ts";
2
+ export type AuthFetchRequest = true | string;
3
+ export type AuthFetchCache = "session" | "off";
4
+ export interface AuthFetchProfile {
5
+ name: string;
6
+ hosts: string[];
7
+ browser?: BrowserCookiePreset;
8
+ chromeProfile?: string;
9
+ redirects: "same-origin";
10
+ cache: AuthFetchCache;
11
+ }
12
+ export declare function resolveAuthFetchProfile(request: AuthFetchRequest): AuthFetchProfile;
13
+ export declare function assertAuthFetchUrl(profile: AuthFetchProfile, rawUrl: string): URL;
14
+ export declare function authFetchRedirectGuard(profile: AuthFetchProfile, from: URL, to: URL): void;
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isBaizhiAvailable(): boolean;
3
+ export declare function searchWithBaizhi(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isBochaAvailable(): boolean;
3
+ export declare function searchWithBocha(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,35 @@
1
+ export interface BraveRateLimitBucket {
2
+ limit: number;
3
+ windowSeconds: number | null;
4
+ remaining: number;
5
+ resetSeconds: number;
6
+ }
7
+ export interface BraveRateLimitCoordinatorOptions {
8
+ now?: () => number;
9
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
10
+ safetyMarginMs?: number;
11
+ maxWaitMs?: number;
12
+ }
13
+ /** Parse Brave's parallel rate-limit bucket headers by list position. */
14
+ export declare function parseBraveRateLimitHeaders(headers: Headers): BraveRateLimitBucket[];
15
+ export declare function parseRetryAfterMs(headers: Headers, now?: number): number | null;
16
+ export declare function defaultSleep(ms: number, signal?: AbortSignal): Promise<void>;
17
+ export declare function formatWait(ms: number): string;
18
+ export declare class BraveRateLimitCoordinator {
19
+ private queue;
20
+ private blockedUntil;
21
+ private readonly now;
22
+ private readonly sleep;
23
+ private readonly safetyMarginMs;
24
+ private readonly maxWaitMs;
25
+ constructor(options?: BraveRateLimitCoordinatorOptions);
26
+ run<T>(operation: () => Promise<T>, signal?: AbortSignal): Promise<T>;
27
+ observe(headers: Headers): void;
28
+ retryDelay(headers: Headers): number | null;
29
+ recordRetryDelay(delayMs: number): void;
30
+ waitForRecordedCooldown(signal?: AbortSignal): Promise<void>;
31
+ waitForRetry(delayMs: number, signal?: AbortSignal): Promise<void>;
32
+ private blockFor;
33
+ private waitForAvailability;
34
+ private assertWaitIsBounded;
35
+ }
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isBraveAvailable(): boolean;
3
+ export declare function searchWithBrave(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,11 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ export interface BrightDataSsrfOptions {
3
+ allowRanges: string[];
4
+ trustEnvProxy: boolean;
5
+ }
6
+ export interface BrightDataExtractOptions extends Pick<ExtractOptions, "timeoutMs" | "lookup"> {
7
+ ssrf?: BrightDataSsrfOptions;
8
+ }
9
+ export declare function clearBrightDataUnlockerConfigCache(): void;
10
+ export declare function isBrightDataUnlockerAvailable(): boolean;
11
+ export declare function extractWithBrightDataUnlocker(url: string, signal?: AbortSignal, options?: BrightDataExtractOptions): Promise<ExtractedContent | null>;
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isCeramicAvailable(): boolean;
3
+ export declare function searchWithCeramic(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,44 @@
1
+ import { type BrowserCookiePreset } from "./gemini-web-config.ts";
2
+ export type CookieMap = Record<string, string>;
3
+ export type BrowserCookieAttemptStatus = "missing-database" | "missing-required-cookies" | "password-read-failed" | "decryption-failed" | "sqlite-unavailable" | "sqlite-query-failed" | "unsafe-profile" | "no-host-cookies";
4
+ export interface BrowserCookieAttemptDiagnostic {
5
+ browser: string;
6
+ profile: string;
7
+ status: BrowserCookieAttemptStatus;
8
+ }
9
+ export interface BrowserCookieDiagnosticDetails {
10
+ message: string;
11
+ attempts: BrowserCookieAttemptDiagnostic[];
12
+ }
13
+ export declare function getLastGoogleCookieDiagnostic(): string | null;
14
+ export declare function getLastBrowserCookieDiagnostic(): string | null;
15
+ export declare function getLastGoogleCookieDiagnosticDetails(): BrowserCookieDiagnosticDetails | null;
16
+ export declare function getGoogleCookies(options?: {
17
+ browser?: BrowserCookiePreset;
18
+ profile?: string;
19
+ requiredCookies?: string[];
20
+ }): Promise<{
21
+ cookies: CookieMap;
22
+ warnings: string[];
23
+ } | null>;
24
+ export declare function getBrowserCookiesForHosts(options: {
25
+ hosts: string[];
26
+ browser?: BrowserCookiePreset;
27
+ profile?: string;
28
+ requiredCookies?: string[];
29
+ cookieNames?: Iterable<string>;
30
+ requiredLabel?: string;
31
+ requestUrl?: URL;
32
+ }): Promise<{
33
+ cookies: CookieMap;
34
+ warnings: string[];
35
+ cookieHeader?: string;
36
+ } | null>;
37
+ export interface DetectedBrowser {
38
+ browser: BrowserCookiePreset;
39
+ name: string;
40
+ profiles: string[];
41
+ }
42
+ /** Browsers with a cookie database on this machine, for asking the user before any cookie is read.
43
+ * It only checks that profile folders and cookie files exist: no keychain, decryption, or file contents. */
44
+ export declare function detectBrowserProfiles(): DetectedBrowser[];
@@ -0,0 +1,4 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare const CLOUDFLARE_SEARCH_PROVIDERS: readonly ["ceramic", "exa", "linkup"];
3
+ export declare function isCloudflareSearchAvailable(): boolean;
4
+ export declare function searchWithCloudflare(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,10 @@
1
+ export type FindMode = "exact" | "case-insensitive" | "fuzzy";
2
+ export declare function findContent(text: string, queries: string[], mode: FindMode): {
3
+ text: string;
4
+ matchCount: number;
5
+ returnedMatches: number;
6
+ queryResults: Array<{
7
+ query: string;
8
+ matchCount: number;
9
+ }>;
10
+ };
@@ -0,0 +1,8 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import { type SsrfConfig } from "./ssrf-protection.ts";
3
+ export interface Crawl4aiExtractOptions extends Pick<ExtractOptions, "timeoutMs" | "lookup"> {
4
+ ssrf?: SsrfConfig;
5
+ }
6
+ export declare function clearCrawl4aiConfigCache(): void;
7
+ export declare function isCrawl4aiAvailable(): boolean;
8
+ export declare function extractWithCrawl4ai(url: string, signal?: AbortSignal, options?: Crawl4aiExtractOptions): Promise<ExtractedContent | null>;
@@ -0,0 +1,29 @@
1
+ export type CredentialFailureCategory = "invalid-source" | "command-failed" | "command-timeout" | "command-aborted" | "command-empty" | "command-invalid-output" | "command-output-too-large" | "environment-empty" | "oauth-credential-rejected";
2
+ export declare class CredentialResolutionError extends Error {
3
+ readonly provider: string;
4
+ readonly category: CredentialFailureCategory;
5
+ constructor(provider: string, category: CredentialFailureCategory);
6
+ }
7
+ export interface CredentialCommandResult {
8
+ stdout: string | Buffer;
9
+ }
10
+ export interface CredentialCommandOptions {
11
+ signal?: AbortSignal;
12
+ timeoutMs: number;
13
+ maxOutputBytes: number;
14
+ environment: Record<string, string>;
15
+ }
16
+ export type CredentialCommandRunner = (command: string, options: CredentialCommandOptions) => Promise<CredentialCommandResult>;
17
+ export interface CredentialOptions {
18
+ provider: string;
19
+ configuredValue?: unknown;
20
+ environmentValue?: unknown;
21
+ environment?: Record<string, string | undefined>;
22
+ signal?: AbortSignal;
23
+ runCommand?: CredentialCommandRunner;
24
+ }
25
+ export declare function redactCredential(text: string, credential: string | null | undefined): string;
26
+ /** Resolves bash on Windows in Pi's own `!command` order: Git Bash install locations, then bash.exe on PATH. */
27
+ export declare function findWindowsBash(environment: Record<string, string | undefined>, exists: (path: string) => boolean, findOnPath: () => Promise<string | null>): Promise<string | null>;
28
+ export declare function hasCredentialSource(options: CredentialOptions): boolean;
29
+ export declare function resolveCredential(options: CredentialOptions): Promise<string | null>;
@@ -0,0 +1,5 @@
1
+ import type { ProviderAvailability } from "./gemini-search.ts";
2
+ export declare function generateCuratorPage(queries: string[], sessionToken: string, timeout: number, availableProviders: ProviderAvailability, defaultProvider: string, searchProvider: string, summaryModels: Array<{
3
+ value: string;
4
+ label: string;
5
+ }>, defaultSummaryModel: string | null): string;
@@ -0,0 +1,10 @@
1
+ import type { ExtensionAPI } from "@earendil-works/pi-coding-agent";
2
+ export type WebSearchWorkflow = "none" | "summary-review" | "auto-summary";
3
+ export declare function resolveWebSearchWorkflow(input: unknown, hasUI: boolean): WebSearchWorkflow;
4
+ export declare class CuratorRunState {
5
+ private autoApproveRemaining;
6
+ approveRemainingSearches(): void;
7
+ reset(): void;
8
+ resolve(requestedWorkflow: unknown, configuredWorkflow: unknown, hasUI: boolean): WebSearchWorkflow;
9
+ }
10
+ export declare function registerCuratorRunLifecycle(pi: Pick<ExtensionAPI, "on">): CuratorRunState;
@@ -0,0 +1,72 @@
1
+ import http from "node:http";
2
+ import type { ProviderAvailability } from "./gemini-search.ts";
3
+ import type { SummaryMeta } from "./summary-review.ts";
4
+ export interface CuratorServerOptions {
5
+ queries: string[];
6
+ /** First index available to searches added while initial results are still streaming. */
7
+ initialResultIndexCapacity?: number;
8
+ sessionToken: string;
9
+ timeout: number;
10
+ availableProviders: ProviderAvailability;
11
+ defaultProvider: string;
12
+ searchProvider: string;
13
+ summaryModels: Array<{
14
+ value: string;
15
+ label: string;
16
+ }>;
17
+ defaultSummaryModel: string | null;
18
+ }
19
+ export interface CuratorSearchEntry {
20
+ answer: string;
21
+ results: Array<{
22
+ title: string;
23
+ url: string;
24
+ domain: string;
25
+ snippet?: string;
26
+ }>;
27
+ provider: string;
28
+ error?: string;
29
+ }
30
+ export interface IndexedCuratorSearchEntry extends CuratorSearchEntry {
31
+ queryIndex: number;
32
+ query: string;
33
+ }
34
+ export interface CuratorServerCallbacks {
35
+ onSubmit: (payload: {
36
+ selectedQueryIndices: number[];
37
+ summary?: string;
38
+ summaryMeta?: SummaryMeta;
39
+ rawResults?: boolean;
40
+ autoApproveRemainingSearches?: boolean;
41
+ }) => void;
42
+ onCancel: (reason: "user" | "timeout" | "stale") => void;
43
+ onProviderChange: (provider: string) => void;
44
+ onAddSearch: (query: string, provider?: string) => Promise<CuratorSearchEntry[]>;
45
+ onAddSearchResults: (entries: IndexedCuratorSearchEntry[]) => void;
46
+ onSummarize: (selectedQueryIndices: number[], signal: AbortSignal, model?: string, feedback?: string) => Promise<{
47
+ summary: string;
48
+ meta: SummaryMeta;
49
+ }>;
50
+ onRewriteQuery: (query: string, signal: AbortSignal) => Promise<string>;
51
+ }
52
+ export interface CuratorServerHandle {
53
+ server: http.Server;
54
+ url: string;
55
+ close: () => void;
56
+ pushResult: (queryIndex: number, data: CuratorSearchEntry & {
57
+ query?: string;
58
+ slotIndex?: number;
59
+ }) => void;
60
+ pushError: (queryIndex: number, error: string, provider?: string, meta?: {
61
+ query?: string;
62
+ slotIndex?: number;
63
+ }) => void;
64
+ searchesDone: () => void;
65
+ /** Reports browser connection state so a cancelled search can surface WHY it
66
+ * went stale (e.g. the browser never connected). */
67
+ getConnectionState: () => {
68
+ browserConnected: boolean;
69
+ lastHeartbeatAgeMs: number;
70
+ };
71
+ }
72
+ export declare function startCuratorServer(options: CuratorServerOptions, callbacks: CuratorServerCallbacks): Promise<CuratorServerHandle>;
@@ -0,0 +1,22 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export interface CustomSearchProviderConfig {
3
+ url: string;
4
+ method: "GET" | "POST";
5
+ apiKey?: string;
6
+ apiKeyHeader?: string;
7
+ apiKeyPrefix?: string;
8
+ apiKeyQuery?: string;
9
+ headers: Record<string, string>;
10
+ query: Record<string, string>;
11
+ body?: Record<string, unknown>;
12
+ results: string;
13
+ fields: {
14
+ title: string;
15
+ url: string;
16
+ snippet?: string;
17
+ };
18
+ }
19
+ /** Validates `customSearchProviders`; `reserved` holds names a custom provider may not take. */
20
+ export declare function parseCustomSearchProviders(value: unknown, reserved: readonly string[], configPath: string): Map<string, CustomSearchProviderConfig>;
21
+ export declare function isCustomSearchProviderAvailable(name: string, config: CustomSearchProviderConfig): boolean;
22
+ export declare function searchWithCustomProvider(name: string, config: CustomSearchProviderConfig, query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,20 @@
1
+ export type DataUriEncoding = "base64" | "percent-encoded";
2
+ export type DigestBasis = "decoded" | "encoded";
3
+ export interface DataUriOmission {
4
+ ordinal: number;
5
+ sourcePath: string;
6
+ mimeType: string;
7
+ encoding: DataUriEncoding;
8
+ encodedBytes: number;
9
+ decodedBytes: number | null;
10
+ decodeError?: string;
11
+ sha256: string;
12
+ digestBasis: DigestBasis;
13
+ retrieval: "not-retained";
14
+ }
15
+ /** Replace every recognized RFC 2397-style inline data URI in one string. */
16
+ export declare function sanitizeInlineDataUris(text: string, sourcePath: string): {
17
+ text: string;
18
+ omissions: DataUriOmission[];
19
+ };
20
+ /** Sanitize every string leaf in a JSON-compatible value with one ordinal sequence. */
@@ -0,0 +1,59 @@
1
+ export type DatalabMode = "fast" | "balanced" | "accurate";
2
+ export type DatalabProcessingLocation = "eu" | "us";
3
+ export declare const DATALAB_MODE_VALUES: Set<DatalabMode>;
4
+ export declare const DATALAB_LOCATION_VALUES: Set<DatalabProcessingLocation>;
5
+ export declare const DEFAULT_DATALAB_MODE: DatalabMode;
6
+ export declare const DEFAULT_PROCESSING_LOCATION: DatalabProcessingLocation;
7
+ export declare const DEFAULT_DATALAB_TIMEOUT_MS = 120000;
8
+ export declare function isDatalabApiAvailable(): boolean;
9
+ export declare function getDatalabApiKey(signal?: AbortSignal): Promise<string | null>;
10
+ export declare function getDatalabApiBase(): string;
11
+ /**
12
+ * Resolve the processing region. US storage and processing is the default;
13
+ * set `DATALAB_PROCESSING_LOCATION=eu` to use EU data residency at Datalab's
14
+ * documented 1.25× usage rate. Only `eu` and `us` are supported by the API.
15
+ * Config errors are thrown with a `Failed to parse` prefix so the
16
+ * extraction fallback chain treats them as fatal, mirroring how malformed
17
+ * web-search config is handled elsewhere.
18
+ */
19
+ export declare function getDatalabProcessingLocation(): DatalabProcessingLocation;
20
+ export declare function normalizeDatalabMode(value: unknown): DatalabMode;
21
+ export interface DatalabPDFExtractOptions {
22
+ maxPages: number;
23
+ title: string;
24
+ signal?: AbortSignal;
25
+ timeoutMs?: number;
26
+ mode?: DatalabMode;
27
+ processingLocation?: DatalabProcessingLocation;
28
+ }
29
+ export interface DatalabPDFExtractResult {
30
+ markdown: string;
31
+ pages: number;
32
+ parseQualityScore?: number;
33
+ }
34
+ /**
35
+ * Convert a PDF buffer to Markdown through the Datalab hosted API.
36
+ *
37
+ * Datalab converts documents with a dedicated extraction engine (Marker),
38
+ * which preserves tables, multi-column reading order, headings, and math
39
+ * where the local `unpdf` fallback only produces flattened text. Conversion
40
+ * is deterministic (no LLM transcription drift), and `accurate` mode handles
41
+ * scanned pages. Completed responses may include a `parse_quality_score` (0–5)
42
+ * for quality gating. Billing is per processed page; the free tier includes a
43
+ * monthly credit (see README) so light use costs nothing.
44
+ *
45
+ * The flow is:
46
+ * 1. request a presigned upload URL for the selected processing region,
47
+ * 2. PUT the PDF bytes directly to storage,
48
+ * 3. confirm the upload to obtain a `datalab://` reference,
49
+ * 4. submit the conversion with that reference, then
50
+ * 5. poll the returned `request_check_url` until `complete` or `failed`.
51
+ *
52
+ * The processing region is fixed at the upload step (US by default; set
53
+ * `DATALAB_PROCESSING_LOCATION=eu` for EU data residency). The convert step
54
+ * deliberately omits `processing_location` because the API rejects multipart form data that
55
+ * carries it; the server processes the file from the storage region it was
56
+ * uploaded to. The uploaded file is deleted best-effort after conversion.
57
+ * The caller's signal and a shared deadline bound the whole exchange.
58
+ */
59
+ export declare function extractPDFViaDatalab(buffer: ArrayBuffer, options: DatalabPDFExtractOptions): Promise<DatalabPDFExtractResult>;
@@ -0,0 +1,7 @@
1
+ export interface DeclaredWebLink {
2
+ url: string;
3
+ relations: string[];
4
+ type?: string;
5
+ }
6
+ export declare function discoverDeclaredWebLinks(document: Document | null, linkHeader: string | null, responseUrl: string): DeclaredWebLink[];
7
+ export declare function appendDeclaredWebLinks(content: string, links: DeclaredWebLink[]): string;
@@ -0,0 +1,13 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ interface DeepSeekSearchOptions extends SearchOptions {
4
+ includeContent?: boolean;
5
+ }
6
+ export declare function isDeepSeekAvailable(): boolean;
7
+ export declare function searchWithDeepSeek(query: string, options?: DeepSeekSearchOptions): Promise<SearchResponse>;
8
+ /**
9
+ * Fetch a single page through DeepSeek's Fetch API, which returns page content
10
+ * already converted to Markdown. Opt-in via `fetchRouting.providers`.
11
+ */
12
+ export declare function extractWithDeepSeek(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent | null>;
13
+ export {};
@@ -0,0 +1,3 @@
1
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
2
+ export declare function isDegoogAvailable(): boolean;
3
+ export declare function searchWithDegoog(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,9 @@
1
+ export declare function normalizeDomain(value: string): string | null;
2
+ /**
3
+ * Applies the shared include/exclude `domainFilter` to results from a provider
4
+ * that has no server-side equivalent, so a filter never returns off-domain
5
+ * results silently. Unparseable result URLs are dropped.
6
+ */
7
+ export declare function applyDomainFilter<T extends {
8
+ url: string;
9
+ }>(results: T[], domainFilter: readonly string[] | undefined): T[];
@@ -0,0 +1,52 @@
1
+ export declare class DuckDuckGoBotCheckError extends Error {
2
+ constructor(status: number);
3
+ }
4
+ export interface DuckDuckGoRateLimitOptions {
5
+ now?: () => number;
6
+ sleep?: (ms: number, signal?: AbortSignal) => Promise<void>;
7
+ minIntervalMs?: number;
8
+ /** At most `maxStarts` searches start in any `windowMs`. */
9
+ windowMs?: number;
10
+ maxStarts?: number;
11
+ cooldownMs?: number;
12
+ maxCooldownMs?: number;
13
+ /** Deadline per search, counted from when it is called. */
14
+ timeoutMs?: number;
15
+ /** File that shares the bot-check pause with other processes; unset keeps it in this process. */
16
+ statePath?: string;
17
+ }
18
+ export declare class DuckDuckGoRateLimit {
19
+ private queue;
20
+ /** Searches queued that have not started yet. */
21
+ private waiting;
22
+ /** Actual start times of the latest `maxStarts` searches, oldest first. */
23
+ private starts;
24
+ private cooldown;
25
+ private readonly now;
26
+ private readonly sleep;
27
+ private readonly minIntervalMs;
28
+ private readonly windowMs;
29
+ private readonly maxStarts;
30
+ private readonly cooldownMs;
31
+ private readonly maxCooldownMs;
32
+ private readonly timeoutMs;
33
+ private readonly statePath;
34
+ constructor(options?: DuckDuckGoRateLimitOptions);
35
+ /**
36
+ * Queues `operation` behind earlier searches and runs it with a signal that fires on the
37
+ * caller's abort or when the deadline passes. A search that cannot start before its
38
+ * deadline fails at once as rate limited, so routing moves on without waiting. A passed
39
+ * deadline rejects with a "timed out" error rather than an abort, so search routing
40
+ * treats it as a network failure and can fall back.
41
+ */
42
+ run<T>(operation: (signal: AbortSignal) => Promise<T>, callerSignal?: AbortSignal): Promise<T>;
43
+ /** Start time of the `count`th search from now, given the searches already started. */
44
+ private nextSlot;
45
+ /** Runs at the head of the queue, so spacing is measured from the previous search's actual start. */
46
+ private waitForSlot;
47
+ private busyError;
48
+ private throwIfBlocked;
49
+ private attempt;
50
+ private loadSharedCooldown;
51
+ private saveSharedCooldown;
52
+ }
@@ -0,0 +1,6 @@
1
+ import { type DuckDuckGoRateLimitOptions } from "./duckduckgo-rate-limit.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ /** Replace the request spacing and bot-check cooldown state (for tests); without `statePath` nothing is shared. */
4
+ export declare function resetDuckDuckGoRateLimit(options?: DuckDuckGoRateLimitOptions): void;
5
+ export declare function isDuckDuckGoAvailable(): boolean;
6
+ export declare function searchWithDuckDuckGo(query: string, options?: SearchOptions): Promise<SearchResponse>;
@@ -0,0 +1,22 @@
1
+ import { type Lookup } from "./ssrf-protection.ts";
2
+ export interface EndpointPDFExtractOptions {
3
+ maxPages: number;
4
+ signal?: AbortSignal;
5
+ timeoutMs?: number;
6
+ lookup?: Lookup;
7
+ }
8
+ export interface EndpointPDFExtractResult {
9
+ markdown: string;
10
+ pages?: number;
11
+ }
12
+ /**
13
+ * Null means the provider is not configured. Trailing slashes are stripped so the
14
+ * relative `jobs/<id>` poll URL resolves beside the parse path.
15
+ */
16
+ export declare function getEndpointUrl(): string | null;
17
+ export declare function isEndpointApiAvailable(): boolean;
18
+ /**
19
+ * POST the PDF as multipart `file`. A `{ markdown }` answer completes at once; a
20
+ * `{ job_id }` answer is polled at `jobs/{id}` until `done`, `error`, or the deadline.
21
+ */
22
+ export declare function extractPDFViaEndpoint(buffer: ArrayBuffer, options: EndpointPDFExtractOptions): Promise<EndpointPDFExtractResult>;
@@ -0,0 +1,17 @@
1
+ import type { ExtractedContent, ExtractOptions } from "./extract.ts";
2
+ import type { SearchOptions, SearchResponse } from "./perplexity.ts";
3
+ export interface ExaSearchOptions extends SearchOptions {
4
+ includeContent?: boolean;
5
+ objective?: string;
6
+ /** Restrict results to an Exa content category (e.g. "publication", "news", "company"). */
7
+ category?: string;
8
+ }
9
+ export declare function callExaMcp(toolName: string, args: Record<string, unknown>, signal?: AbortSignal): Promise<string>;
10
+ export declare function isExaAvailable(): boolean;
11
+ export declare function hasExaApiKey(): boolean;
12
+ export declare function searchWithExa(query: string, options?: ExaSearchOptions): Promise<SearchResponse>;
13
+ /**
14
+ * Read one page through Exa's /contents endpoint with the configured Exa key.
15
+ * Opt-in via `fetchRouting.providers`; returns null when Exa has no text for the page.
16
+ */
17
+ export declare function extractWithExa(url: string, signal?: AbortSignal, options?: Pick<ExtractOptions, "timeoutMs" | "lookup">): Promise<ExtractedContent | null>;
@@ -0,0 +1,70 @@
1
+ import type { BrowserCookieConsent } from "./gemini-web-config.ts";
2
+ import { type Lookup, type RedirectPolicy } from "./ssrf-protection.ts";
3
+ import { type AuthFetchProfile } from "./auth-fetch.ts";
4
+ export declare const FETCH_PROVIDERS: readonly ["http", "firecrawl", "crawl4ai", "jina", "tinyfish", "querit", "kagi", "ollama", "parallel", "parallel-mcp", "brightdata", "gemini", "deepseek", "exa", "tabstack"];
5
+ export type FetchProvider = typeof FETCH_PROVIDERS[number];
6
+ export { loadSsrfConfig } from "./ssrf-protection.ts";
7
+ export declare function loadSsrfAllowRanges(): string[];
8
+ /** Names of the search/fetch tools the caller has actually registered, so
9
+ * failure guidance never points at tools that do not exist in the session. */
10
+ export interface RegisteredToolNames {
11
+ webSearch?: string;
12
+ fetchContent?: string;
13
+ getSearchContent?: string;
14
+ }
15
+ export interface VideoFrame {
16
+ data: string;
17
+ mimeType: string;
18
+ timestamp: string;
19
+ }
20
+ export type FrameData = {
21
+ data: string;
22
+ mimeType: string;
23
+ };
24
+ export type FrameResult = FrameData | {
25
+ error: string;
26
+ };
27
+ export interface ExtractedContent {
28
+ url: string;
29
+ title: string;
30
+ content: string;
31
+ error: string | null;
32
+ thumbnail?: {
33
+ data: string;
34
+ mimeType: string;
35
+ };
36
+ frames?: VideoFrame[];
37
+ duration?: number;
38
+ mimeType?: string;
39
+ status?: number;
40
+ }
41
+ export interface ExtractOptions {
42
+ timeoutMs?: number;
43
+ forceClone?: boolean;
44
+ prompt?: string;
45
+ timestamp?: string;
46
+ frames?: number;
47
+ model?: string;
48
+ mode?: "readable" | "raw" | "answer" | "extract";
49
+ answerModel?: string;
50
+ authFetchProfile?: AuthFetchProfile;
51
+ toolNames?: RegisteredToolNames;
52
+ /** Optional HTTP(S) or SOCKS proxy URL; routed through the curl-backed transport. */
53
+ proxy?: string;
54
+ /** Reject direct image URLs with this error instead of decoding them with Pi's
55
+ * resizeImage. Hosts without the Pi runtime set it; Pi leaves it unset. */
56
+ rejectDirectImages?: string;
57
+ /** Custom DNS resolver used for SSRF validation. Primarily a test seam. */
58
+ lookup?: Lookup;
59
+ /** "same-origin" refuses cross-origin redirects and extraction paths whose redirect
60
+ * chain cannot be observed. fetchContent.redirects in config is a floor. */
61
+ redirects?: RedirectPolicy;
62
+ /** Lets video analysis ask the user to turn on browser cookie access for Gemini Web. */
63
+ browserCookieConsent?: BrowserCookieConsent;
64
+ }
65
+ /** Resolve the direct HTTP/Jina fetch budget, with a per-call override taking precedence. */
66
+ export declare function resolveFetchTimeoutMs(options?: Pick<ExtractOptions, "timeoutMs">): number;
67
+ export declare function extractContent(url: string, signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent>;
68
+ export declare function readPDFResponseBuffer(response: Response, maxSizeMB: number): Promise<ArrayBuffer>;
69
+ export declare function extractHeadingTitle(text: string): string | null;
70
+ export declare function fetchAllContent(urls: string[], signal?: AbortSignal, options?: ExtractOptions): Promise<ExtractedContent[]>;
@@ -0,0 +1,2 @@
1
+ export declare function isImageEnabled(): boolean;
2
+ export declare function canAttachImages(): boolean;