@herbertgao/pi-extensions 2026.11.2 → 2026.11.3

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 (51) hide show
  1. package/CHANGELOG.md +10 -0
  2. package/README.md +11 -11
  3. package/node_modules/@herbertgao/pi-cc-extensions/CHANGELOG.md +6 -0
  4. package/node_modules/@herbertgao/pi-cc-extensions/README.en.md +1 -1
  5. package/node_modules/@herbertgao/pi-cc-extensions/README.md +1 -1
  6. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/compact-mode.ts +109 -16
  7. package/node_modules/@herbertgao/pi-cc-extensions/extensions/renderer/tool/diff/write-execution.ts +5 -1
  8. package/node_modules/@herbertgao/pi-cc-extensions/package.json +4 -4
  9. package/node_modules/@herbertgao/pi-subagents/CHANGELOG.md +6 -0
  10. package/node_modules/@herbertgao/pi-subagents/README.md +12 -10
  11. package/node_modules/@herbertgao/pi-subagents/docs/rpc.md +1 -1
  12. package/node_modules/@herbertgao/pi-subagents/package.json +4 -4
  13. package/node_modules/@herbertgao/pi-subagents/src/agent-record-entry.ts +22 -6
  14. package/node_modules/@herbertgao/pi-subagents/src/index.ts +9 -4
  15. package/node_modules/@herbertgao/pi-subagents/src/ui/conversation-viewer.ts +167 -7
  16. package/node_modules/@herbertgao/pi-subagents/src/ui/viewer-keys.ts +8 -4
  17. package/node_modules/@narumitw/pi-btw/CHANGELOG.md +259 -0
  18. package/node_modules/@narumitw/pi-btw/package.json +6 -5
  19. package/node_modules/@narumitw/pi-caffeinate/CHANGELOG.md +70 -0
  20. package/node_modules/@narumitw/pi-caffeinate/package.json +5 -4
  21. package/node_modules/pi-commandcode-provider/CHANGELOG.md +21 -0
  22. package/node_modules/pi-commandcode-provider/README.md +18 -6
  23. package/node_modules/pi-commandcode-provider/index.ts +11 -5
  24. package/node_modules/pi-commandcode-provider/package.json +1 -1
  25. package/node_modules/pi-commandcode-provider/src/api-key.ts +26 -10
  26. package/node_modules/pi-commandcode-provider/src/auth-server.ts +33 -24
  27. package/node_modules/pi-commandcode-provider/src/commandcode-catalog.ts +2 -2
  28. package/node_modules/pi-commandcode-provider/src/converters.ts +3 -61
  29. package/node_modules/pi-commandcode-provider/src/core.ts +29 -4
  30. package/node_modules/pi-commandcode-provider/src/cost.ts +32 -12
  31. package/node_modules/pi-commandcode-provider/src/oauth.ts +40 -6
  32. package/node_modules/pi-commandcode-provider/src/pricing.ts +5 -3
  33. package/node_modules/pi-commandcode-provider/src/runtime.ts +14 -7
  34. package/node_modules/pi-commandcode-provider/src/transport.ts +6 -3
  35. package/node_modules/pi-web-access/CHANGELOG.md +22 -0
  36. package/node_modules/pi-web-access/README.md +31 -12
  37. package/node_modules/pi-web-access/curator-page.ts +5 -1
  38. package/node_modules/pi-web-access/curator-server.ts +2 -0
  39. package/node_modules/pi-web-access/dist/index.js +673 -308
  40. package/node_modules/pi-web-access/dist/mcp-cli.js +666 -309
  41. package/node_modules/pi-web-access/gemini-search.ts +12 -4
  42. package/node_modules/pi-web-access/github-api.ts +1 -1
  43. package/node_modules/pi-web-access/github-extract.ts +3 -2
  44. package/node_modules/pi-web-access/index.ts +7 -3
  45. package/node_modules/pi-web-access/mcp-tool-definitions.ts +1 -1
  46. package/node_modules/pi-web-access/outcrawl.ts +204 -0
  47. package/node_modules/pi-web-access/package.json +2 -2
  48. package/node_modules/pi-web-access/sofya.ts +201 -0
  49. package/node_modules/pi-web-access/utils.ts +16 -6
  50. package/node_modules/pi-web-access/web-tool-core.ts +4 -0
  51. package/package.json +9 -9
@@ -457,8 +457,8 @@ function redactProxyUrl(value) {
457
457
  if (parsed.password) parsed.password = "redacted";
458
458
  return parsed.toString();
459
459
  }
460
- function loadConfiguredProxy() {
461
- let configured;
460
+ function loadProxyConfig() {
461
+ let config = {};
462
462
  const path = getWebSearchConfigPath();
463
463
  if (existsSync2(path)) {
464
464
  let raw;
@@ -468,19 +468,28 @@ function loadConfiguredProxy() {
468
468
  const message = err instanceof Error ? err.message : String(err);
469
469
  throw new Error(`Failed to load proxy config from ${path}: ${message}`);
470
470
  }
471
- if (raw && typeof raw === "object" && !Array.isArray(raw)) configured = raw.proxy;
471
+ if (raw && typeof raw === "object" && !Array.isArray(raw)) config = raw;
472
472
  }
473
- if (configured === void 0) return null;
474
- return normalizeProxyUrl(configured, `proxy in ${getWebSearchConfigPath()}`);
473
+ if (config.lockProxy !== void 0 && typeof config.lockProxy !== "boolean") throw new Error(`lockProxy in ${path} must be true or false`);
474
+ const locked = config.lockProxy === true;
475
+ const proxy = config.proxy === void 0 ? null : normalizeProxyUrl(config.proxy, `proxy in ${path}`);
476
+ if (locked && proxy === null) throw new Error(`lockProxy is set in ${path} but no proxy is configured there; set proxy or remove lockProxy`);
477
+ return { proxy, locked };
478
+ }
479
+ function loadConfiguredProxy() {
480
+ return loadProxyConfig().proxy;
475
481
  }
476
482
  function runWithProxy(proxy, fn) {
483
+ const { proxy: configured, locked } = loadProxyConfig();
477
484
  if (proxy === void 0) {
478
- const configured = loadConfiguredProxy();
479
485
  if (configured === null) return fn();
480
486
  installGlobalProxyFetch();
481
487
  return proxyStorage.run(configured, fn);
482
488
  }
483
489
  const normalized = normalizeProxyUrl(proxy, "proxy");
490
+ if (locked && normalized !== configured) {
491
+ throw new Error(`proxy argument rejected: lockProxy is set in ${getWebSearchConfigPath()}; omit proxy to use the configured proxy`);
492
+ }
484
493
  if (normalized !== null) installGlobalProxyFetch();
485
494
  return proxyStorage.run(normalized, fn);
486
495
  }
@@ -5694,45 +5703,45 @@ var init_ollama = __esm({
5694
5703
  });
5695
5704
 
5696
5705
  // deepseek.ts
5697
- import { existsSync as existsSync45, readFileSync as readFileSync45 } from "node:fs";
5698
- function loadConfig40() {
5699
- if (cachedConfig38) return cachedConfig38;
5700
- if (!existsSync45(CONFIG_PATH42)) {
5701
- cachedConfig38 = {};
5702
- return cachedConfig38;
5706
+ import { existsSync as existsSync47, readFileSync as readFileSync47 } from "node:fs";
5707
+ function loadConfig42() {
5708
+ if (cachedConfig40) return cachedConfig40;
5709
+ if (!existsSync47(CONFIG_PATH44)) {
5710
+ cachedConfig40 = {};
5711
+ return cachedConfig40;
5703
5712
  }
5704
- const raw = readFileSync45(CONFIG_PATH42, "utf-8");
5713
+ const raw = readFileSync47(CONFIG_PATH44, "utf-8");
5705
5714
  let parsed;
5706
5715
  try {
5707
5716
  parsed = JSON.parse(raw);
5708
5717
  } catch (err) {
5709
5718
  const message = err instanceof Error ? err.message : String(err);
5710
- throw new Error(`Failed to parse ${CONFIG_PATH42}: ${message}`);
5719
+ throw new Error(`Failed to parse ${CONFIG_PATH44}: ${message}`);
5711
5720
  }
5712
5721
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
5713
- throw new Error(`Invalid config in ${CONFIG_PATH42}: expected a JSON object`);
5722
+ throw new Error(`Invalid config in ${CONFIG_PATH44}: expected a JSON object`);
5714
5723
  }
5715
- cachedConfig38 = parsed;
5716
- return cachedConfig38;
5724
+ cachedConfig40 = parsed;
5725
+ return cachedConfig40;
5717
5726
  }
5718
- async function requireApiKey16(signal) {
5727
+ async function requireApiKey18(signal) {
5719
5728
  const apiKey = await resolveCredential({
5720
5729
  provider: "DeepSeek",
5721
- configuredValue: loadConfig40().deepseekApiKey,
5730
+ configuredValue: loadConfig42().deepseekApiKey,
5722
5731
  environmentValue: process.env.DEEPSEEK_API_KEY,
5723
5732
  signal
5724
5733
  });
5725
5734
  if (!apiKey) {
5726
5735
  throw new Error(
5727
5736
  `DeepSeek API key not found. Either:
5728
- 1. Create ${CONFIG_PATH42} with { "deepseekApiKey": "your-key" }
5737
+ 1. Create ${CONFIG_PATH44} with { "deepseekApiKey": "your-key" }
5729
5738
  2. Set DEEPSEEK_API_KEY environment variable
5730
5739
  Get a key at https://platform.deepseek.com/api_keys`
5731
5740
  );
5732
5741
  }
5733
5742
  return apiKey;
5734
5743
  }
5735
- function buildQuery10(query, options) {
5744
+ function buildQuery11(query, options) {
5736
5745
  const include = [];
5737
5746
  const exclude = [];
5738
5747
  for (const raw of options.domainFilter ?? []) {
@@ -5758,7 +5767,7 @@ function buildQuery10(query, options) {
5758
5767
  function text6(value) {
5759
5768
  return typeof value === "string" ? value.replace(/\s+/g, " ").trim() : "";
5760
5769
  }
5761
- function errorMessage28(err) {
5770
+ function errorMessage30(err) {
5762
5771
  return err instanceof Error ? err.message : String(err);
5763
5772
  }
5764
5773
  function unescapeMarkdownSegment(segment) {
@@ -5811,7 +5820,7 @@ function isUnusableDeepSeekPage(title, content) {
5811
5820
  if (heading !== "" && ERROR_TITLE.test(heading)) return true;
5812
5821
  return ERROR_TITLE.test(text6(title)) && /\b(?:404|page not found|not found)\b/i.test(content.slice(0, 200));
5813
5822
  }
5814
- function parseResponse13(value) {
5823
+ function parseResponse15(value) {
5815
5824
  const results = value && typeof value === "object" && !Array.isArray(value) ? value.results : void 0;
5816
5825
  if (!Array.isArray(results)) throw new Error("DeepSeek returned invalid response: expected a results array");
5817
5826
  return results;
@@ -5826,18 +5835,18 @@ function describeError3(body) {
5826
5835
  return body;
5827
5836
  }
5828
5837
  function isDeepSeekAvailable() {
5829
- return hasCredentialSource({ provider: "DeepSeek", configuredValue: loadConfig40().deepseekApiKey, environmentValue: process.env.DEEPSEEK_API_KEY });
5838
+ return hasCredentialSource({ provider: "DeepSeek", configuredValue: loadConfig42().deepseekApiKey, environmentValue: process.env.DEEPSEEK_API_KEY });
5830
5839
  }
5831
5840
  async function searchWithDeepSeek(query, options = {}) {
5832
- const builtQuery = buildQuery10(query, options);
5833
- const apiKey = await requireApiKey16(options.signal);
5841
+ const builtQuery = buildQuery11(query, options);
5842
+ const apiKey = await requireApiKey18(options.signal);
5834
5843
  const numResults = normalizeSearchResultCount(options.numResults);
5835
5844
  const activityId = activityMonitor.logStart({ type: "api", query });
5836
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS35);
5845
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS37);
5837
5846
  let response;
5838
5847
  let entries;
5839
5848
  try {
5840
- response = await fetchWithCredentialRedirects(resolveProviderApiUrl("deepseek", DEEPSEEK_SEARCH_URL, loadConfig40().deepseekBaseUrl), {
5849
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("deepseek", DEEPSEEK_SEARCH_URL, loadConfig42().deepseekBaseUrl), {
5841
5850
  method: "POST",
5842
5851
  headers: {
5843
5852
  Accept: "application/json",
@@ -5856,24 +5865,24 @@ async function searchWithDeepSeek(query, options = {}) {
5856
5865
  rawData = await response.json();
5857
5866
  } catch (err) {
5858
5867
  if (err instanceof Error && err.name === "TimeoutError") throw err;
5859
- throw new Error(`DeepSeek returned invalid JSON: ${errorMessage28(err)}`);
5868
+ throw new Error(`DeepSeek returned invalid JSON: ${errorMessage30(err)}`);
5860
5869
  }
5861
- entries = parseResponse13(rawData);
5870
+ entries = parseResponse15(rawData);
5862
5871
  } catch (err) {
5863
5872
  if (options.signal?.aborted) {
5864
5873
  activityMonitor.logComplete(activityId, 0);
5865
5874
  throw new Error("Aborted");
5866
5875
  }
5867
- const message = errorMessage28(err);
5876
+ const message = errorMessage30(err);
5868
5877
  const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
5869
- const outgoing = providerTimeout ? new Error(`DeepSeek request timed out after ${Math.round(SEARCH_TIMEOUT_MS35 / 1e3)}s`) : (() => {
5878
+ const outgoing = providerTimeout ? new Error(`DeepSeek request timed out after ${Math.round(SEARCH_TIMEOUT_MS37 / 1e3)}s`) : (() => {
5870
5879
  const redactedMessage = redactCredential(message, apiKey);
5871
5880
  if (redactedMessage === message && err instanceof Error) return err;
5872
5881
  const redactedError = new Error(redactedMessage);
5873
5882
  if (err instanceof Error) redactedError.name = err.name;
5874
5883
  return redactedError;
5875
5884
  })();
5876
- activityMonitor.logError(activityId, redactCredential(errorMessage28(outgoing), apiKey));
5885
+ activityMonitor.logError(activityId, redactCredential(errorMessage30(outgoing), apiKey));
5877
5886
  throw outgoing;
5878
5887
  }
5879
5888
  activityMonitor.logComplete(activityId, response.status);
@@ -5910,7 +5919,7 @@ async function searchWithDeepSeek(query, options = {}) {
5910
5919
  return searchResponse;
5911
5920
  }
5912
5921
  async function extractWithDeepSeek(url, signal, options = {}) {
5913
- const apiKey = await requireApiKey16(signal);
5922
+ const apiKey = await requireApiKey18(signal);
5914
5923
  const activityId = activityMonitor.logStart({ type: "fetch", url });
5915
5924
  const timeoutMs = options.timeoutMs ?? FETCH_TIMEOUT_MS2;
5916
5925
  const timeoutSignal = AbortSignal.timeout(timeoutMs);
@@ -5922,7 +5931,7 @@ async function extractWithDeepSeek(url, signal, options = {}) {
5922
5931
  domainPolicy: loadFetchContentDomainPolicy(),
5923
5932
  ...options.lookup ? { lookup: options.lookup } : {}
5924
5933
  });
5925
- const response = await fetchWithCredentialRedirects(resolveProviderApiUrl("deepseek", DEEPSEEK_FETCH_URL, loadConfig40().deepseekBaseUrl), {
5934
+ const response = await fetchWithCredentialRedirects(resolveProviderApiUrl("deepseek", DEEPSEEK_FETCH_URL, loadConfig42().deepseekBaseUrl), {
5926
5935
  method: "POST",
5927
5936
  headers: {
5928
5937
  Accept: "application/json",
@@ -5941,7 +5950,7 @@ async function extractWithDeepSeek(url, signal, options = {}) {
5941
5950
  rawData = await response.json();
5942
5951
  } catch (err) {
5943
5952
  if (err instanceof Error && err.name === "TimeoutError") throw err;
5944
- throw new Error(`DeepSeek Fetch returned invalid JSON: ${errorMessage28(err)}`);
5953
+ throw new Error(`DeepSeek Fetch returned invalid JSON: ${errorMessage30(err)}`);
5945
5954
  }
5946
5955
  if (!rawData || typeof rawData !== "object" || Array.isArray(rawData)) {
5947
5956
  throw new Error("DeepSeek Fetch returned an unexpected response shape");
@@ -5961,7 +5970,7 @@ async function extractWithDeepSeek(url, signal, options = {}) {
5961
5970
  error: null
5962
5971
  };
5963
5972
  } catch (err) {
5964
- const message = errorMessage28(err);
5973
+ const message = errorMessage30(err);
5965
5974
  if (signal?.aborted) {
5966
5975
  activityMonitor.logComplete(activityId, 0);
5967
5976
  throw new Error("Aborted");
@@ -5977,7 +5986,7 @@ async function extractWithDeepSeek(url, signal, options = {}) {
5977
5986
  throw redactedError;
5978
5987
  }
5979
5988
  }
5980
- var DEEPSEEK_SEARCH_URL, DEEPSEEK_FETCH_URL, CONFIG_PATH42, SEARCH_TIMEOUT_MS35, FETCH_TIMEOUT_MS2, MAX_QUERY_CHARS2, MAX_SNIPPET_CHARS6, RECENCY_DAYS2, cachedConfig38, ERROR_TITLE;
5989
+ var DEEPSEEK_SEARCH_URL, DEEPSEEK_FETCH_URL, CONFIG_PATH44, SEARCH_TIMEOUT_MS37, FETCH_TIMEOUT_MS2, MAX_QUERY_CHARS2, MAX_SNIPPET_CHARS6, RECENCY_DAYS2, cachedConfig40, ERROR_TITLE;
5981
5990
  var init_deepseek = __esm({
5982
5991
  "deepseek.ts"() {
5983
5992
  init_activity();
@@ -5989,8 +5998,8 @@ var init_deepseek = __esm({
5989
5998
  init_utils();
5990
5999
  DEEPSEEK_SEARCH_URL = "https://api.deepseek.com/v1/tools/search";
5991
6000
  DEEPSEEK_FETCH_URL = "https://api.deepseek.com/v1/tools/fetch";
5992
- CONFIG_PATH42 = getWebSearchConfigPath();
5993
- SEARCH_TIMEOUT_MS35 = 3e4;
6001
+ CONFIG_PATH44 = getWebSearchConfigPath();
6002
+ SEARCH_TIMEOUT_MS37 = 3e4;
5994
6003
  FETCH_TIMEOUT_MS2 = 6e4;
5995
6004
  MAX_QUERY_CHARS2 = 128;
5996
6005
  MAX_SNIPPET_CHARS6 = 800;
@@ -6000,13 +6009,13 @@ var init_deepseek = __esm({
6000
6009
  month: 30,
6001
6010
  year: 365
6002
6011
  };
6003
- cachedConfig38 = null;
6012
+ cachedConfig40 = null;
6004
6013
  ERROR_TITLE = /^(?:404\b|page not found\b|not found\b)/i;
6005
6014
  }
6006
6015
  });
6007
6016
 
6008
6017
  // auth-fetch.ts
6009
- import { existsSync as existsSync48, readFileSync as readFileSync48 } from "node:fs";
6018
+ import { existsSync as existsSync50, readFileSync as readFileSync50 } from "node:fs";
6010
6019
  function resolveAuthFetchProfile(request) {
6011
6020
  const profiles = loadAuthFetchProfiles();
6012
6021
  if (profiles.length === 0) {
@@ -6044,8 +6053,8 @@ function authFetchRedirectGuard(profile, from, to) {
6044
6053
  }
6045
6054
  }
6046
6055
  function loadAuthFetchProfiles() {
6047
- if (!existsSync48(WEB_SEARCH_CONFIG_PATH2)) return [];
6048
- const raw = readFileSync48(WEB_SEARCH_CONFIG_PATH2, "utf-8");
6056
+ if (!existsSync50(WEB_SEARCH_CONFIG_PATH2)) return [];
6057
+ const raw = readFileSync50(WEB_SEARCH_CONFIG_PATH2, "utf-8");
6049
6058
  let parsed;
6050
6059
  try {
6051
6060
  const value = JSON.parse(raw);
@@ -6445,20 +6454,20 @@ var init_rsc_extract = __esm({
6445
6454
  });
6446
6455
 
6447
6456
  // datalab-pdf-extract.ts
6448
- import { existsSync as existsSync49, readFileSync as readFileSync50 } from "node:fs";
6449
- function loadConfig42() {
6450
- if (cachedConfig40) return cachedConfig40;
6451
- if (!existsSync49(CONFIG_PATH45)) {
6452
- cachedConfig40 = {};
6453
- return cachedConfig40;
6457
+ import { existsSync as existsSync51, readFileSync as readFileSync52 } from "node:fs";
6458
+ function loadConfig44() {
6459
+ if (cachedConfig42) return cachedConfig42;
6460
+ if (!existsSync51(CONFIG_PATH47)) {
6461
+ cachedConfig42 = {};
6462
+ return cachedConfig42;
6454
6463
  }
6455
- const rawText = readFileSync50(CONFIG_PATH45, "utf-8");
6464
+ const rawText = readFileSync52(CONFIG_PATH47, "utf-8");
6456
6465
  try {
6457
- cachedConfig40 = JSON.parse(rawText);
6458
- return cachedConfig40;
6466
+ cachedConfig42 = JSON.parse(rawText);
6467
+ return cachedConfig42;
6459
6468
  } catch (err) {
6460
6469
  const message = err instanceof Error ? err.message : String(err);
6461
- throw new Error(`Failed to parse ${CONFIG_PATH45}: ${message}`);
6470
+ throw new Error(`Failed to parse ${CONFIG_PATH47}: ${message}`);
6462
6471
  }
6463
6472
  }
6464
6473
  function normalizeString(value) {
@@ -6473,14 +6482,14 @@ function normalizeFileId(value) {
6473
6482
  function isDatalabApiAvailable() {
6474
6483
  return hasCredentialSource({
6475
6484
  provider: "Datalab",
6476
- configuredValue: loadConfig42().datalabApiKey,
6485
+ configuredValue: loadConfig44().datalabApiKey,
6477
6486
  environmentValue: process.env.DATALAB_API_KEY
6478
6487
  });
6479
6488
  }
6480
6489
  async function getDatalabApiKey(signal) {
6481
6490
  return resolveCredential({
6482
6491
  provider: "Datalab",
6483
- configuredValue: loadConfig42().datalabApiKey,
6492
+ configuredValue: loadConfig44().datalabApiKey,
6484
6493
  environmentValue: process.env.DATALAB_API_KEY,
6485
6494
  signal
6486
6495
  });
@@ -6805,7 +6814,7 @@ async function readResponseText(response) {
6805
6814
  function datalabFilename(title) {
6806
6815
  return title.toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "").slice(0, 60) || "document";
6807
6816
  }
6808
- var DEFAULT_API_HOST2, API_PREFIX, DEFAULT_TIMEOUT_MS2, DEFAULT_POLL_INTERVAL_MS, MAX_RESPONSE_BYTES, MAX_ERROR_BODY_BYTES, CLEANUP_TIMEOUT_MS, CONFIG_PATH45, DATALAB_MODE_VALUES, DATALAB_LOCATION_VALUES, DEFAULT_DATALAB_MODE, DEFAULT_PROCESSING_LOCATION, DEFAULT_DATALAB_TIMEOUT_MS, cachedConfig40;
6817
+ var DEFAULT_API_HOST2, API_PREFIX, DEFAULT_TIMEOUT_MS2, DEFAULT_POLL_INTERVAL_MS, MAX_RESPONSE_BYTES, MAX_ERROR_BODY_BYTES, CLEANUP_TIMEOUT_MS, CONFIG_PATH47, DATALAB_MODE_VALUES, DATALAB_LOCATION_VALUES, DEFAULT_DATALAB_MODE, DEFAULT_PROCESSING_LOCATION, DEFAULT_DATALAB_TIMEOUT_MS, cachedConfig42;
6809
6818
  var init_datalab_pdf_extract = __esm({
6810
6819
  "datalab-pdf-extract.ts"() {
6811
6820
  init_credential_source();
@@ -6817,7 +6826,7 @@ var init_datalab_pdf_extract = __esm({
6817
6826
  MAX_RESPONSE_BYTES = 4 * 1024 * 1024;
6818
6827
  MAX_ERROR_BODY_BYTES = 300;
6819
6828
  CLEANUP_TIMEOUT_MS = 5e3;
6820
- CONFIG_PATH45 = getWebSearchConfigPath();
6829
+ CONFIG_PATH47 = getWebSearchConfigPath();
6821
6830
  DATALAB_MODE_VALUES = /* @__PURE__ */ new Set([
6822
6831
  "fast",
6823
6832
  "balanced",
@@ -6830,21 +6839,21 @@ var init_datalab_pdf_extract = __esm({
6830
6839
  DEFAULT_DATALAB_MODE = "balanced";
6831
6840
  DEFAULT_PROCESSING_LOCATION = "us";
6832
6841
  DEFAULT_DATALAB_TIMEOUT_MS = DEFAULT_TIMEOUT_MS2;
6833
- cachedConfig40 = null;
6842
+ cachedConfig42 = null;
6834
6843
  }
6835
6844
  });
6836
6845
 
6837
6846
  // endpoint-pdf-extract.ts
6838
- import { existsSync as existsSync50, readFileSync as readFileSync51 } from "node:fs";
6847
+ import { existsSync as existsSync52, readFileSync as readFileSync53 } from "node:fs";
6839
6848
  import { setTimeout as sleep2 } from "node:timers/promises";
6840
6849
  function pdfSection() {
6841
- if (!existsSync50(CONFIG_PATH46)) return {};
6850
+ if (!existsSync52(CONFIG_PATH48)) return {};
6842
6851
  let parsed;
6843
6852
  try {
6844
- parsed = JSON.parse(readFileSync51(CONFIG_PATH46, "utf-8"));
6853
+ parsed = JSON.parse(readFileSync53(CONFIG_PATH48, "utf-8"));
6845
6854
  } catch (err) {
6846
6855
  const message = err instanceof Error ? err.message : String(err);
6847
- throw new Error(`Failed to parse ${CONFIG_PATH46}: ${message}`);
6856
+ throw new Error(`Failed to parse ${CONFIG_PATH48}: ${message}`);
6848
6857
  }
6849
6858
  const pdf = parsed?.pdf;
6850
6859
  return pdf && typeof pdf === "object" ? pdf : {};
@@ -6996,7 +7005,7 @@ async function extractPDFViaEndpoint(buffer, options) {
6996
7005
  }
6997
7006
  throw new Error("PDF parser endpoint job timed out");
6998
7007
  }
6999
- var DEFAULT_TIMEOUT_MS3, MAX_POLL_INTERVAL_MS, MAX_RESPONSE_BYTES2, MAX_ERROR_BODY_BYTES2, CONFIG_PATH46;
7008
+ var DEFAULT_TIMEOUT_MS3, MAX_POLL_INTERVAL_MS, MAX_RESPONSE_BYTES2, MAX_ERROR_BODY_BYTES2, CONFIG_PATH48;
7000
7009
  var init_endpoint_pdf_extract = __esm({
7001
7010
  "endpoint-pdf-extract.ts"() {
7002
7011
  init_ssrf_protection();
@@ -7005,7 +7014,7 @@ var init_endpoint_pdf_extract = __esm({
7005
7014
  MAX_POLL_INTERVAL_MS = 3e3;
7006
7015
  MAX_RESPONSE_BYTES2 = 4 * 1024 * 1024;
7007
7016
  MAX_ERROR_BODY_BYTES2 = 300;
7008
- CONFIG_PATH46 = getWebSearchConfigPath();
7017
+ CONFIG_PATH48 = getWebSearchConfigPath();
7009
7018
  }
7010
7019
  });
7011
7020
 
@@ -7095,12 +7104,12 @@ var init_gemini_pdf_extract = __esm({
7095
7104
  });
7096
7105
 
7097
7106
  // pdf-extract.ts
7098
- import { existsSync as existsSync51, readFileSync as readFileSync52 } from "node:fs";
7107
+ import { existsSync as existsSync53, readFileSync as readFileSync54 } from "node:fs";
7099
7108
  import { writeFile as writeFile2, mkdir } from "node:fs/promises";
7100
7109
  import { join as join5, basename as basename2 } from "node:path";
7101
7110
  import { tmpdir as tmpdir3 } from "node:os";
7102
7111
  function loadPDFConfig() {
7103
- if (!existsSync51(CONFIG_PATH47)) {
7112
+ if (!existsSync53(CONFIG_PATH49)) {
7104
7113
  return {
7105
7114
  enabled: true,
7106
7115
  maxSizeMB: DEFAULT_PDF_MAX_SIZE_MB,
@@ -7110,13 +7119,13 @@ function loadPDFConfig() {
7110
7119
  datalabTimeoutMs: DEFAULT_DATALAB_TIMEOUT_MS
7111
7120
  };
7112
7121
  }
7113
- const rawText = readFileSync52(CONFIG_PATH47, "utf-8");
7122
+ const rawText = readFileSync54(CONFIG_PATH49, "utf-8");
7114
7123
  let raw;
7115
7124
  try {
7116
7125
  raw = JSON.parse(rawText);
7117
7126
  } catch (err) {
7118
7127
  const message = err instanceof Error ? err.message : String(err);
7119
- throw new Error(`Failed to parse ${CONFIG_PATH47}: ${message}`);
7128
+ throw new Error(`Failed to parse ${CONFIG_PATH49}: ${message}`);
7120
7129
  }
7121
7130
  const root = raw && typeof raw === "object" ? raw : {};
7122
7131
  const pdf = root.pdf && typeof root.pdf === "object" ? root.pdf : {};
@@ -7350,7 +7359,7 @@ function isPDF(url, contentType) {
7350
7359
  return false;
7351
7360
  }
7352
7361
  }
7353
- var PDF_PROVIDER_VALUES, DEFAULT_PDF_MAX_SIZE_MB, MAX_PDF_MAX_SIZE_MB, MAX_DATALAB_TIMEOUT_MS, DEFAULT_MAX_PAGES, DEFAULT_OUTPUT_DIR, CONFIG_PATH47, PAGE_MARKER_PATTERN2;
7362
+ var PDF_PROVIDER_VALUES, DEFAULT_PDF_MAX_SIZE_MB, MAX_PDF_MAX_SIZE_MB, MAX_DATALAB_TIMEOUT_MS, DEFAULT_MAX_PAGES, DEFAULT_OUTPUT_DIR, CONFIG_PATH49, PAGE_MARKER_PATTERN2;
7354
7363
  var init_pdf_extract = __esm({
7355
7364
  "pdf-extract.ts"() {
7356
7365
  init_credential_source();
@@ -7371,7 +7380,7 @@ var init_pdf_extract = __esm({
7371
7380
  MAX_DATALAB_TIMEOUT_MS = 3e5;
7372
7381
  DEFAULT_MAX_PAGES = 100;
7373
7382
  DEFAULT_OUTPUT_DIR = join5(tmpdir3(), "pi-web-pdf");
7374
- CONFIG_PATH47 = getWebSearchConfigPath();
7383
+ CONFIG_PATH49 = getWebSearchConfigPath();
7375
7384
  PAGE_MARKER_PATTERN2 = /^<!-- Page (\d+) -->$/gm;
7376
7385
  }
7377
7386
  });
@@ -7459,7 +7468,9 @@ async function fetchReadmeViaApi(owner, repo, ref) {
7459
7468
  }
7460
7469
  try {
7461
7470
  const decoded = Buffer.from(stdout.trim(), "base64").toString("utf-8");
7462
- resolve2(decoded.length > 8192 ? decoded.slice(0, 8192) + "\n\n[README truncated at 8K chars]" : decoded);
7471
+ resolve2(decoded.length > MAX_INLINE_FILE_CHARS ? `${decoded.slice(0, MAX_INLINE_FILE_CHARS)}
7472
+
7473
+ [README truncated at 100K chars]` : decoded);
7463
7474
  } catch {
7464
7475
  resolve2(null);
7465
7476
  }
@@ -7549,11 +7560,12 @@ var init_github_api = __esm({
7549
7560
  });
7550
7561
 
7551
7562
  // github-extract.ts
7552
- import { chmodSync, closeSync as closeSync2, constants as fsConstants, existsSync as existsSync52, lstatSync as lstatSync2, mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync2, openSync as openSync2, readFileSync as readFileSync53, readSync, readdirSync as readdirSync3, realpathSync as realpathSync2, rmSync as rmSync2, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
7563
+ import { chmodSync, closeSync as closeSync2, constants as fsConstants, existsSync as existsSync54, lstatSync as lstatSync2, mkdirSync as mkdirSync2, mkdtempSync as mkdtempSync2, openSync as openSync2, readFileSync as readFileSync55, readSync, readdirSync as readdirSync3, realpathSync as realpathSync2, rmSync as rmSync2, statSync as statSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "node:fs";
7553
7564
  import { lstat as lstatAsync, open as openAsync, opendir as opendirAsync, readFile as readFileAsync, realpath as realpathAsync, rm as rmAsync } from "node:fs/promises";
7554
7565
  import { execFile as execFile4, spawn as spawn2 } from "node:child_process";
7555
7566
  import { createHash as createHash2 } from "node:crypto";
7556
7567
  import { basename as basename3, dirname, extname, join as join6, resolve as resolvePath, sep as pathSep } from "node:path";
7568
+ import { tmpdir as tmpdir4 } from "node:os";
7557
7569
  function normalizeEnabled(value, fallback) {
7558
7570
  return typeof value === "boolean" ? value : fallback;
7559
7571
  }
@@ -7578,33 +7590,33 @@ function normalizeClonePath(value, fallback) {
7578
7590
  return expandPath(normalized);
7579
7591
  }
7580
7592
  function loadGitHubConfig() {
7581
- if (cachedConfig41) return cachedConfig41;
7593
+ if (cachedConfig43) return cachedConfig43;
7582
7594
  const defaults2 = {
7583
7595
  enabled: true,
7584
7596
  maxRepoSizeMB: 350,
7585
7597
  cloneTimeoutSeconds: 30,
7586
- clonePath: "/tmp/pi-github-repos"
7598
+ clonePath: join6(tmpdir4(), "pi-github-repos")
7587
7599
  };
7588
- if (!existsSync52(CONFIG_PATH48)) {
7589
- cachedConfig41 = defaults2;
7590
- return cachedConfig41;
7600
+ if (!existsSync54(CONFIG_PATH50)) {
7601
+ cachedConfig43 = defaults2;
7602
+ return cachedConfig43;
7591
7603
  }
7592
- const rawText = readFileSync53(CONFIG_PATH48, "utf-8");
7604
+ const rawText = readFileSync55(CONFIG_PATH50, "utf-8");
7593
7605
  let raw;
7594
7606
  try {
7595
7607
  raw = JSON.parse(rawText);
7596
7608
  } catch (err) {
7597
7609
  const message = err instanceof Error ? err.message : String(err);
7598
- throw new Error(`Failed to parse ${CONFIG_PATH48}: ${message}`);
7610
+ throw new Error(`Failed to parse ${CONFIG_PATH50}: ${message}`);
7599
7611
  }
7600
7612
  const gc = raw.githubClone ?? {};
7601
- cachedConfig41 = {
7613
+ cachedConfig43 = {
7602
7614
  enabled: normalizeEnabled(gc.enabled, defaults2.enabled),
7603
7615
  maxRepoSizeMB: normalizePositiveNumber(gc.maxRepoSizeMB, defaults2.maxRepoSizeMB),
7604
7616
  cloneTimeoutSeconds: normalizePositiveNumber(gc.cloneTimeoutSeconds, defaults2.cloneTimeoutSeconds),
7605
7617
  clonePath: normalizeClonePath(gc.clonePath, defaults2.clonePath)
7606
7618
  };
7607
- return cachedConfig41;
7619
+ return cachedConfig43;
7608
7620
  }
7609
7621
  function parseGitHubUrl(url) {
7610
7622
  let parsed;
@@ -7655,7 +7667,7 @@ function cacheKey(owner, repo, ref) {
7655
7667
  }
7656
7668
  function readLinuxBootId() {
7657
7669
  try {
7658
- const bootId = readFileSync53("/proc/sys/kernel/random/boot_id", "utf-8").trim();
7670
+ const bootId = readFileSync55("/proc/sys/kernel/random/boot_id", "utf-8").trim();
7659
7671
  return bootId.length > 0 ? bootId : null;
7660
7672
  } catch {
7661
7673
  return null;
@@ -7680,7 +7692,7 @@ function parseLinuxProcessInfo(stat) {
7680
7692
  }
7681
7693
  function readLinuxProcessInfo(pid) {
7682
7694
  try {
7683
- return parseLinuxProcessInfo(readFileSync53(`/proc/${pid}/stat`, "utf-8"));
7695
+ return parseLinuxProcessInfo(readFileSync55(`/proc/${pid}/stat`, "utf-8"));
7684
7696
  } catch (err) {
7685
7697
  if (err && typeof err === "object" && "code" in err && err.code === "ENOENT") {
7686
7698
  return { state: "", startTime: null, dead: true };
@@ -8018,7 +8030,7 @@ function resolveWithinRepo(rootPath, relativePath) {
8018
8030
  const rootPrefix = normalizedRoot.endsWith(pathSep) ? normalizedRoot : normalizedRoot + pathSep;
8019
8031
  if (!candidate.startsWith(rootPrefix)) return null;
8020
8032
  }
8021
- if (!existsSync52(candidate)) return candidate;
8033
+ if (!existsSync54(candidate)) return candidate;
8022
8034
  try {
8023
8035
  const realRoot = realpathSync2(normalizedRoot);
8024
8036
  const realCandidate = realpathSync2(candidate);
@@ -8031,7 +8043,7 @@ function resolveWithinRepo(rootPath, relativePath) {
8031
8043
  }
8032
8044
  function readTextFile(path) {
8033
8045
  try {
8034
- return readFileSync53(path, "utf-8");
8046
+ return readFileSync55(path, "utf-8");
8035
8047
  } catch {
8036
8048
  return null;
8037
8049
  }
@@ -8114,10 +8126,12 @@ function readReadme(localPath) {
8114
8126
  const candidates = ["README.md", "readme.md", "README", "README.txt", "README.rst"];
8115
8127
  for (const name of candidates) {
8116
8128
  const readmePath = join6(localPath, name);
8117
- if (existsSync52(readmePath)) {
8129
+ if (existsSync54(readmePath)) {
8118
8130
  try {
8119
- const content = readFileSync53(readmePath, "utf-8");
8120
- return content.length > 8192 ? content.slice(0, 8192) + "\n\n[README truncated at 8K chars]" : content;
8131
+ const content = readFileSync55(readmePath, "utf-8");
8132
+ return content.length > MAX_INLINE_FILE_CHARS2 ? `${content.slice(0, MAX_INLINE_FILE_CHARS2)}
8133
+
8134
+ [README truncated at 100K chars. Full file: ${readmePath}]` : content;
8121
8135
  } catch {
8122
8136
  continue;
8123
8137
  }
@@ -8145,7 +8159,7 @@ function generateContent(localPath, info) {
8145
8159
  if (info.type === "tree") {
8146
8160
  const dirPath = info.path || "";
8147
8161
  const fullDirPath = resolveWithinRepo(localPath, dirPath);
8148
- if (!fullDirPath || !existsSync52(fullDirPath)) {
8162
+ if (!fullDirPath || !existsSync54(fullDirPath)) {
8149
8163
  lines.push(`Path \`${dirPath}\` not found in clone. Showing repository root instead.`);
8150
8164
  lines.push("");
8151
8165
  lines.push("## Structure");
@@ -8161,7 +8175,7 @@ function generateContent(localPath, info) {
8161
8175
  if (info.type === "blob") {
8162
8176
  const filePath = info.path || "";
8163
8177
  const fullFilePath = resolveWithinRepo(localPath, filePath);
8164
- if (!fullFilePath || !existsSync52(fullFilePath)) {
8178
+ if (!fullFilePath || !existsSync54(fullFilePath)) {
8165
8179
  lines.push(`Path \`${filePath}\` not found in clone. Showing repository root instead.`);
8166
8180
  lines.push("");
8167
8181
  lines.push("## Structure");
@@ -8323,13 +8337,13 @@ async function extractGitHub(url, signal, forceClone) {
8323
8337
  const title = info.path ? `${owner}/${repo} - ${info.path}` : `${owner}/${repo}`;
8324
8338
  return { url, title, content, error: null };
8325
8339
  }
8326
- var CONFIG_PATH48, BINARY_EXTENSIONS, NOISE_DIRS, MAX_INLINE_FILE_CHARS2, MAX_TREE_ENTRIES2, CLONE_RUNTIME_OWNER_FILENAME, CLONE_RUNTIME_OWNER_VERSION, MAX_CLONE_RUNTIME_OWNER_BYTES, cloneCache, startedCloneRuntimeCleanups, cachedConfig41, cloneRuntime, NON_CODE_SEGMENTS, PROCESS_KILL_GRACE_MS;
8340
+ var CONFIG_PATH50, BINARY_EXTENSIONS, NOISE_DIRS, MAX_INLINE_FILE_CHARS2, MAX_TREE_ENTRIES2, CLONE_RUNTIME_OWNER_FILENAME, CLONE_RUNTIME_OWNER_VERSION, MAX_CLONE_RUNTIME_OWNER_BYTES, cloneCache, startedCloneRuntimeCleanups, cachedConfig43, cloneRuntime, NON_CODE_SEGMENTS, PROCESS_KILL_GRACE_MS;
8327
8341
  var init_github_extract = __esm({
8328
8342
  "github-extract.ts"() {
8329
8343
  init_activity();
8330
8344
  init_github_api();
8331
8345
  init_utils();
8332
- CONFIG_PATH48 = getWebSearchConfigPath();
8346
+ CONFIG_PATH50 = getWebSearchConfigPath();
8333
8347
  BINARY_EXTENSIONS = /* @__PURE__ */ new Set([
8334
8348
  ".png",
8335
8349
  ".jpg",
@@ -8417,7 +8431,7 @@ var init_github_extract = __esm({
8417
8431
  MAX_CLONE_RUNTIME_OWNER_BYTES = 1024;
8418
8432
  cloneCache = /* @__PURE__ */ new Map();
8419
8433
  startedCloneRuntimeCleanups = /* @__PURE__ */ new Set();
8420
- cachedConfig41 = null;
8434
+ cachedConfig43 = null;
8421
8435
  cloneRuntime = null;
8422
8436
  NON_CODE_SEGMENTS = /* @__PURE__ */ new Set([
8423
8437
  "issues",
@@ -8456,29 +8470,29 @@ var init_github_extract = __esm({
8456
8470
 
8457
8471
  // github-issue-pr.ts
8458
8472
  import { execFile as execFile5 } from "node:child_process";
8459
- import { existsSync as existsSync53, readFileSync as readFileSync54 } from "node:fs";
8460
- function loadConfig43() {
8461
- if (cachedConfig42) return cachedConfig42;
8473
+ import { existsSync as existsSync55, readFileSync as readFileSync56 } from "node:fs";
8474
+ function loadConfig45() {
8475
+ if (cachedConfig44) return cachedConfig44;
8462
8476
  const defaults2 = { enabled: true };
8463
- if (!existsSync53(CONFIG_PATH49)) {
8464
- cachedConfig42 = defaults2;
8465
- return cachedConfig42;
8477
+ if (!existsSync55(CONFIG_PATH51)) {
8478
+ cachedConfig44 = defaults2;
8479
+ return cachedConfig44;
8466
8480
  }
8467
8481
  let parsed;
8468
8482
  try {
8469
- parsed = JSON.parse(readFileSync54(CONFIG_PATH49, "utf-8"));
8483
+ parsed = JSON.parse(readFileSync56(CONFIG_PATH51, "utf-8"));
8470
8484
  } catch (err) {
8471
8485
  const message = err instanceof Error ? err.message : String(err);
8472
- throw new Error(`Failed to parse ${CONFIG_PATH49}: ${message}`);
8486
+ throw new Error(`Failed to parse ${CONFIG_PATH51}: ${message}`);
8473
8487
  }
8474
8488
  const root = parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : {};
8475
8489
  const value = root.githubPrIssue;
8476
8490
  if (value !== void 0 && (typeof value !== "object" || value === null || Array.isArray(value))) {
8477
- throw new Error(`githubPrIssue in ${CONFIG_PATH49} must be an object`);
8491
+ throw new Error(`githubPrIssue in ${CONFIG_PATH51} must be an object`);
8478
8492
  }
8479
8493
  const enabled = typeof value?.enabled === "boolean" ? value.enabled : true;
8480
- cachedConfig42 = { enabled };
8481
- return cachedConfig42;
8494
+ cachedConfig44 = { enabled };
8495
+ return cachedConfig44;
8482
8496
  }
8483
8497
  function validOwner(owner) {
8484
8498
  return /^[A-Za-z0-9](?:[A-Za-z0-9-]{0,37}[A-Za-z0-9])?$/.test(owner) && !owner.includes("--");
@@ -8486,11 +8500,11 @@ function validOwner(owner) {
8486
8500
  function validRepo(repo) {
8487
8501
  return /^[A-Za-z0-9._-]{1,100}$/.test(repo) && repo !== "." && repo !== "..";
8488
8502
  }
8489
- function errorMessage31(err) {
8503
+ function errorMessage33(err) {
8490
8504
  return err instanceof Error ? err.message : String(err);
8491
8505
  }
8492
8506
  function isAbortError3(err) {
8493
- return errorMessage31(err).toLowerCase().includes("abort");
8507
+ return errorMessage33(err).toLowerCase().includes("abort");
8494
8508
  }
8495
8509
  function parseGitHubIssuePrUrl(url) {
8496
8510
  let parsed;
@@ -8726,7 +8740,7 @@ async function restFallback(url, info, options, signal) {
8726
8740
  return { data: { url, owner: info.owner, repo: info.repo, kind: info.kind, number: info.number, anchor: info.anchor, view, reviewThreads, fallbackNotes: notes } };
8727
8741
  } catch (err) {
8728
8742
  if (signal?.aborted || isAbortError3(err)) return { url, title: "", content: "", error: "Aborted" };
8729
- const message = errorMessage31(err);
8743
+ const message = errorMessage33(err);
8730
8744
  return { url, title: `${info.owner}/${info.repo}#${info.number}`, content: message, error: `GitHub REST fallback failed: ${message}` };
8731
8745
  }
8732
8746
  }
@@ -9024,7 +9038,7 @@ function renderGitHubPrIssue(data) {
9024
9038
  async function extractGitHubIssuePr(url, signal, options) {
9025
9039
  const info = parseGitHubIssuePrUrl(url);
9026
9040
  if (!info) return null;
9027
- if (!loadConfig43().enabled) return null;
9041
+ if (!loadConfig45().enabled) return null;
9028
9042
  if (signal?.aborted) return { url, title: "", content: "", error: "Aborted" };
9029
9043
  const retrievalTool = options?.toolNames ? options.toolNames.getSearchContent ?? null : void 0;
9030
9044
  const ghAvailable2 = await checkGhAvailable(signal);
@@ -9048,13 +9062,13 @@ async function extractGitHubIssuePr(url, signal, options) {
9048
9062
  if ("data" in fallback) return renderGitHubPrIssue({ ...fallback.data, retrievalTool });
9049
9063
  return fallback;
9050
9064
  }
9051
- var CONFIG_PATH49, GH_TIMEOUT_MS, GH_TOTAL_TIMEOUT_MS, MAX_DOC_CHARS, BODY_INLINE_CHARS, COMMENT_INLINE_CHARS, MAX_INLINE_COMMENTS, MAX_INLINE_REVIEWS, MAX_INLINE_CHECKS, MAX_INLINE_FILES, MAX_INLINE_COMMITS, MAX_INLINE_REVIEW_THREADS, REST_HEADERS, PR_SUBPATHS, PR_FIELDS, PR_CORE_FIELDS, ISSUE_FIELDS, ISSUE_CORE_FIELDS, cachedConfig42;
9065
+ var CONFIG_PATH51, GH_TIMEOUT_MS, GH_TOTAL_TIMEOUT_MS, MAX_DOC_CHARS, BODY_INLINE_CHARS, COMMENT_INLINE_CHARS, MAX_INLINE_COMMENTS, MAX_INLINE_REVIEWS, MAX_INLINE_CHECKS, MAX_INLINE_FILES, MAX_INLINE_COMMITS, MAX_INLINE_REVIEW_THREADS, REST_HEADERS, PR_SUBPATHS, PR_FIELDS, PR_CORE_FIELDS, ISSUE_FIELDS, ISSUE_CORE_FIELDS, cachedConfig44;
9052
9066
  var init_github_issue_pr = __esm({
9053
9067
  "github-issue-pr.ts"() {
9054
9068
  init_github_api();
9055
9069
  init_ssrf_protection();
9056
9070
  init_utils();
9057
- CONFIG_PATH49 = getWebSearchConfigPath();
9071
+ CONFIG_PATH51 = getWebSearchConfigPath();
9058
9072
  GH_TIMEOUT_MS = 1e4;
9059
9073
  GH_TOTAL_TIMEOUT_MS = 2e4;
9060
9074
  MAX_DOC_CHARS = 15e4;
@@ -9135,20 +9149,20 @@ var init_github_issue_pr = __esm({
9135
9149
  "url"
9136
9150
  ];
9137
9151
  ISSUE_CORE_FIELDS = ["title", "number", "state", "author", "createdAt", "closedAt", "labels", "assignees", "milestone", "comments", "body", "url"];
9138
- cachedConfig42 = null;
9152
+ cachedConfig44 = null;
9139
9153
  }
9140
9154
  });
9141
9155
 
9142
9156
  // feature-config.ts
9143
- import { existsSync as existsSync54, readFileSync as readFileSync55 } from "node:fs";
9157
+ import { existsSync as existsSync56, readFileSync as readFileSync57 } from "node:fs";
9144
9158
  function loadFeatureConfig() {
9145
- if (!existsSync54(CONFIG_PATH50)) return {};
9159
+ if (!existsSync56(CONFIG_PATH52)) return {};
9146
9160
  try {
9147
- const raw = JSON.parse(readFileSync55(CONFIG_PATH50, "utf-8"));
9161
+ const raw = JSON.parse(readFileSync57(CONFIG_PATH52, "utf-8"));
9148
9162
  return raw && typeof raw === "object" ? raw : {};
9149
9163
  } catch (err) {
9150
9164
  const message = err instanceof Error ? err.message : String(err);
9151
- throw new Error(`Failed to parse ${CONFIG_PATH50}: ${message}`);
9165
+ throw new Error(`Failed to parse ${CONFIG_PATH52}: ${message}`);
9152
9166
  }
9153
9167
  }
9154
9168
  function isImageEnabled() {
@@ -9161,25 +9175,25 @@ function canAttachImages() {
9161
9175
  return false;
9162
9176
  }
9163
9177
  }
9164
- var CONFIG_PATH50;
9178
+ var CONFIG_PATH52;
9165
9179
  var init_feature_config = __esm({
9166
9180
  "feature-config.ts"() {
9167
9181
  init_utils();
9168
- CONFIG_PATH50 = getWebSearchConfigPath();
9182
+ CONFIG_PATH52 = getWebSearchConfigPath();
9169
9183
  }
9170
9184
  });
9171
9185
 
9172
9186
  // youtube-extract.ts
9173
9187
  import { execFileSync } from "node:child_process";
9174
- import { existsSync as existsSync55, readFileSync as readFileSync56 } from "node:fs";
9175
- function errorMessage32(err) {
9188
+ import { existsSync as existsSync57, readFileSync as readFileSync58 } from "node:fs";
9189
+ function errorMessage34(err) {
9176
9190
  return err instanceof Error ? err.message : String(err);
9177
9191
  }
9178
9192
  function shouldRethrow(err) {
9179
- return errorMessage32(err).startsWith("Failed to parse ");
9193
+ return errorMessage34(err).startsWith("Failed to parse ");
9180
9194
  }
9181
9195
  function addAttemptError(errors, label, err) {
9182
- const message = errorMessage32(err).replace(/\s+/g, " ").trim();
9196
+ const message = errorMessage34(err).replace(/\s+/g, " ").trim();
9183
9197
  if (message) errors.push(`${label}: ${message}`);
9184
9198
  }
9185
9199
  function normalizePreferredModel(value, fallback) {
@@ -9191,25 +9205,25 @@ function normalizeEnabled2(value, fallback) {
9191
9205
  return typeof value === "boolean" ? value : fallback;
9192
9206
  }
9193
9207
  function loadYouTubeConfig() {
9194
- if (cachedConfig43) return cachedConfig43;
9195
- if (!existsSync55(CONFIG_PATH51)) {
9196
- cachedConfig43 = { ...defaults };
9197
- return cachedConfig43;
9208
+ if (cachedConfig45) return cachedConfig45;
9209
+ if (!existsSync57(CONFIG_PATH53)) {
9210
+ cachedConfig45 = { ...defaults };
9211
+ return cachedConfig45;
9198
9212
  }
9199
- const rawText = readFileSync56(CONFIG_PATH51, "utf-8");
9213
+ const rawText = readFileSync58(CONFIG_PATH53, "utf-8");
9200
9214
  let raw;
9201
9215
  try {
9202
9216
  raw = JSON.parse(rawText);
9203
9217
  } catch (err) {
9204
9218
  const message = err instanceof Error ? err.message : String(err);
9205
- throw new Error(`Failed to parse ${CONFIG_PATH51}: ${message}`);
9219
+ throw new Error(`Failed to parse ${CONFIG_PATH53}: ${message}`);
9206
9220
  }
9207
9221
  const yt = raw.youtube ?? {};
9208
- cachedConfig43 = {
9222
+ cachedConfig45 = {
9209
9223
  enabled: normalizeEnabled2(yt.enabled, defaults.enabled),
9210
9224
  preferredModel: normalizePreferredModel(yt.preferredModel, defaults.preferredModel)
9211
9225
  };
9212
- return cachedConfig43;
9226
+ return cachedConfig45;
9213
9227
  }
9214
9228
  function isYouTubeURL(url) {
9215
9229
  try {
@@ -9401,7 +9415,7 @@ ${answer}
9401
9415
  return null;
9402
9416
  }
9403
9417
  }
9404
- var CONFIG_PATH51, YOUTUBE_PROMPT, YOUTUBE_REGEX, defaults, cachedConfig43;
9418
+ var CONFIG_PATH53, YOUTUBE_PROMPT, YOUTUBE_REGEX, defaults, cachedConfig45;
9405
9419
  var init_youtube_extract = __esm({
9406
9420
  "youtube-extract.ts"() {
9407
9421
  init_activity();
@@ -9411,7 +9425,7 @@ var init_youtube_extract = __esm({
9411
9425
  init_perplexity();
9412
9426
  init_extract();
9413
9427
  init_utils();
9414
- CONFIG_PATH51 = getWebSearchConfigPath();
9428
+ CONFIG_PATH53 = getWebSearchConfigPath();
9415
9429
  YOUTUBE_PROMPT = `Extract the complete content of this YouTube video. Include:
9416
9430
  1. Video title, channel name, and duration
9417
9431
  2. A brief summary (2-3 sentences)
@@ -9421,7 +9435,7 @@ var init_youtube_extract = __esm({
9421
9435
  Format as markdown.`;
9422
9436
  YOUTUBE_REGEX = /(?:(?:www\.|m\.)?youtube\.com\/(?:watch\?.*v=|shorts\/|live\/|embed\/|v\/)|youtu\.be\/)([a-zA-Z0-9_-]{11})/;
9423
9437
  defaults = { enabled: true, preferredModel: "gemini-3.6-flash" };
9424
- cachedConfig43 = null;
9438
+ cachedConfig45 = null;
9425
9439
  }
9426
9440
  });
9427
9441
 
@@ -9523,26 +9537,26 @@ URL: `;
9523
9537
  });
9524
9538
 
9525
9539
  // crawl4ai.ts
9526
- import { existsSync as existsSync56, readFileSync as readFileSync57 } from "node:fs";
9527
- function loadConfig44() {
9528
- if (cachedConfig44) return cachedConfig44;
9529
- if (!existsSync56(CONFIG_PATH52)) {
9530
- cachedConfig44 = {};
9531
- return cachedConfig44;
9540
+ import { existsSync as existsSync58, readFileSync as readFileSync59 } from "node:fs";
9541
+ function loadConfig46() {
9542
+ if (cachedConfig46) return cachedConfig46;
9543
+ if (!existsSync58(CONFIG_PATH54)) {
9544
+ cachedConfig46 = {};
9545
+ return cachedConfig46;
9532
9546
  }
9533
- const raw = readFileSync57(CONFIG_PATH52, "utf8");
9547
+ const raw = readFileSync59(CONFIG_PATH54, "utf8");
9534
9548
  let parsed;
9535
9549
  try {
9536
9550
  parsed = JSON.parse(raw);
9537
9551
  } catch (err) {
9538
9552
  const message = err instanceof Error ? err.message : String(err);
9539
- throw new Error(`Failed to parse ${CONFIG_PATH52}: ${message}`);
9553
+ throw new Error(`Failed to parse ${CONFIG_PATH54}: ${message}`);
9540
9554
  }
9541
9555
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
9542
- throw new Error(`Invalid config in ${CONFIG_PATH52}: expected a JSON object`);
9556
+ throw new Error(`Invalid config in ${CONFIG_PATH54}: expected a JSON object`);
9543
9557
  }
9544
- cachedConfig44 = parsed;
9545
- return cachedConfig44;
9558
+ cachedConfig46 = parsed;
9559
+ return cachedConfig46;
9546
9560
  }
9547
9561
  function normalizeBaseUrl5(value) {
9548
9562
  if (typeof value !== "string") return null;
@@ -9552,13 +9566,13 @@ function normalizeBaseUrl5(value) {
9552
9566
  try {
9553
9567
  parsed = new URL(trimmed);
9554
9568
  } catch {
9555
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH52}: expected an HTTP or HTTPS URL`);
9569
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH54}: expected an HTTP or HTTPS URL`);
9556
9570
  }
9557
9571
  if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
9558
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH52}: expected an HTTP or HTTPS URL`);
9572
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH54}: expected an HTTP or HTTPS URL`);
9559
9573
  }
9560
9574
  if (parsed.username || parsed.password) {
9561
- throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH52}: URL credentials are not allowed`);
9575
+ throw new Error(`Invalid Crawl4AI base URL in ${CONFIG_PATH54}: URL credentials are not allowed`);
9562
9576
  }
9563
9577
  parsed.pathname = parsed.pathname.replace(/\/+$/, "");
9564
9578
  parsed.search = "";
@@ -9566,14 +9580,14 @@ function normalizeBaseUrl5(value) {
9566
9580
  return parsed.toString().replace(/\/+$/, "");
9567
9581
  }
9568
9582
  function getBaseUrl4() {
9569
- return normalizeBaseUrl5(process.env.CRAWL4AI_BASE_URL) ?? normalizeBaseUrl5(loadConfig44().crawl4aiBaseUrl);
9583
+ return normalizeBaseUrl5(process.env.CRAWL4AI_BASE_URL) ?? normalizeBaseUrl5(loadConfig46().crawl4aiBaseUrl);
9570
9584
  }
9571
9585
  function requireBaseUrl4() {
9572
9586
  const baseUrl = getBaseUrl4();
9573
9587
  if (!baseUrl) {
9574
9588
  throw new Error(
9575
9589
  `Crawl4AI base URL not configured. Either:
9576
- 1. Set crawl4aiBaseUrl in ${CONFIG_PATH52}
9590
+ 1. Set crawl4aiBaseUrl in ${CONFIG_PATH54}
9577
9591
  2. Set CRAWL4AI_BASE_URL environment variable`
9578
9592
  );
9579
9593
  }
@@ -9582,7 +9596,7 @@ function requireBaseUrl4() {
9582
9596
  async function getApiToken(signal) {
9583
9597
  return resolveCredential({
9584
9598
  provider: "Crawl4AI",
9585
- configuredValue: loadConfig44().crawl4aiApiToken,
9599
+ configuredValue: loadConfig46().crawl4aiApiToken,
9586
9600
  environmentValue: process.env.CRAWL4AI_API_TOKEN,
9587
9601
  signal
9588
9602
  });
@@ -9591,7 +9605,7 @@ function requestSignal14(timeoutMs, signal) {
9591
9605
  const timeout = AbortSignal.timeout(timeoutMs);
9592
9606
  return signal ? AbortSignal.any([timeout, signal]) : timeout;
9593
9607
  }
9594
- function errorMessage33(err) {
9608
+ function errorMessage35(err) {
9595
9609
  return err instanceof Error ? err.message : String(err);
9596
9610
  }
9597
9611
  function isAbortException(err) {
@@ -9668,49 +9682,49 @@ async function extractWithCrawl4ai(url, signal, options) {
9668
9682
  return { url, title: firstHeadingTitle(content), content, error: null };
9669
9683
  } catch (err) {
9670
9684
  if (signal?.aborted || isAbortException(err)) activityMonitor.logComplete(activityId, 0);
9671
- else activityMonitor.logError(activityId, errorMessage33(err));
9685
+ else activityMonitor.logError(activityId, errorMessage35(err));
9672
9686
  throw err;
9673
9687
  }
9674
9688
  }
9675
- var CONFIG_PATH52, EXTRACT_TIMEOUT_MS3, MARKDOWN_FILTER, cachedConfig44;
9689
+ var CONFIG_PATH54, EXTRACT_TIMEOUT_MS3, MARKDOWN_FILTER, cachedConfig46;
9676
9690
  var init_crawl4ai = __esm({
9677
9691
  "crawl4ai.ts"() {
9678
9692
  init_activity();
9679
9693
  init_credential_source();
9680
9694
  init_ssrf_protection();
9681
9695
  init_utils();
9682
- CONFIG_PATH52 = getWebSearchConfigPath();
9696
+ CONFIG_PATH54 = getWebSearchConfigPath();
9683
9697
  EXTRACT_TIMEOUT_MS3 = 6e4;
9684
9698
  MARKDOWN_FILTER = "fit";
9685
- cachedConfig44 = null;
9699
+ cachedConfig46 = null;
9686
9700
  }
9687
9701
  });
9688
9702
 
9689
9703
  // brightdata-unlocker.ts
9690
- import { existsSync as existsSync57, readFileSync as readFileSync58 } from "node:fs";
9704
+ import { existsSync as existsSync59, readFileSync as readFileSync60 } from "node:fs";
9691
9705
  function parseFailureDetail(err) {
9692
9706
  const message = err instanceof Error ? err.message : String(err);
9693
9707
  const position = message.match(/at position \d+(?: \(line \d+ column \d+\))?/);
9694
9708
  return position ? `invalid JSON ${position[0]}` : "invalid JSON";
9695
9709
  }
9696
- function loadConfig45() {
9697
- if (cachedConfig45) return cachedConfig45;
9698
- if (!existsSync57(CONFIG_PATH53)) {
9699
- cachedConfig45 = {};
9700
- return cachedConfig45;
9710
+ function loadConfig47() {
9711
+ if (cachedConfig47) return cachedConfig47;
9712
+ if (!existsSync59(CONFIG_PATH55)) {
9713
+ cachedConfig47 = {};
9714
+ return cachedConfig47;
9701
9715
  }
9702
- const raw = readFileSync58(CONFIG_PATH53, "utf8");
9716
+ const raw = readFileSync60(CONFIG_PATH55, "utf8");
9703
9717
  let parsed;
9704
9718
  try {
9705
9719
  parsed = JSON.parse(raw);
9706
9720
  } catch (err) {
9707
- throw new Error(`Failed to parse ${CONFIG_PATH53}: ${parseFailureDetail(err)}`);
9721
+ throw new Error(`Failed to parse ${CONFIG_PATH55}: ${parseFailureDetail(err)}`);
9708
9722
  }
9709
9723
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
9710
- throw new Error(`Invalid config in ${CONFIG_PATH53}: expected a JSON object`);
9724
+ throw new Error(`Invalid config in ${CONFIG_PATH55}: expected a JSON object`);
9711
9725
  }
9712
- cachedConfig45 = parsed;
9713
- return cachedConfig45;
9726
+ cachedConfig47 = parsed;
9727
+ return cachedConfig47;
9714
9728
  }
9715
9729
  function normalizeZone2(value) {
9716
9730
  if (typeof value !== "string") return null;
@@ -9721,8 +9735,8 @@ function normalizeZone2(value) {
9721
9735
  function zoneSetting() {
9722
9736
  const fromEnv = process.env.BRIGHTDATA_UNLOCKER_ZONE;
9723
9737
  if (typeof fromEnv === "string" && fromEnv.trim()) return { raw: fromEnv.trim(), label: "BRIGHTDATA_UNLOCKER_ZONE" };
9724
- const configured = loadConfig45().brightdataUnlockerZone;
9725
- if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${CONFIG_PATH53}` };
9738
+ const configured = loadConfig47().brightdataUnlockerZone;
9739
+ if (typeof configured === "string" && configured.trim()) return { raw: configured.trim(), label: `brightdataUnlockerZone in ${CONFIG_PATH55}` };
9726
9740
  return null;
9727
9741
  }
9728
9742
  function getZone() {
@@ -9740,22 +9754,22 @@ function requireZone() {
9740
9754
  }
9741
9755
  throw new Error(
9742
9756
  `Bright Data Web Unlocker zone not configured. Either:
9743
- 1. Set brightdataUnlockerZone in ${CONFIG_PATH53}
9757
+ 1. Set brightdataUnlockerZone in ${CONFIG_PATH55}
9744
9758
  2. Set BRIGHTDATA_UNLOCKER_ZONE environment variable
9745
9759
  The zone must be of type "unblocker"; a SERP zone will not serve Web Unlocker requests.`
9746
9760
  );
9747
9761
  }
9748
- async function getApiKey29(signal) {
9762
+ async function getApiKey31(signal) {
9749
9763
  const apiKey = await resolveCredential({
9750
9764
  provider: "Bright Data",
9751
- configuredValue: loadConfig45().brightdataApiKey,
9765
+ configuredValue: loadConfig47().brightdataApiKey,
9752
9766
  environmentValue: process.env.BRIGHTDATA_API_KEY,
9753
9767
  signal
9754
9768
  });
9755
9769
  if (!apiKey) {
9756
9770
  throw new Error(
9757
9771
  `Bright Data API key not found. Either:
9758
- 1. Create ${CONFIG_PATH53} with { "brightdataApiKey": "your-key" }
9772
+ 1. Create ${CONFIG_PATH55} with { "brightdataApiKey": "your-key" }
9759
9773
  2. Set BRIGHTDATA_API_KEY environment variable
9760
9774
  Get a key at https://brightdata.com/cp/setting/users`
9761
9775
  );
@@ -9766,11 +9780,11 @@ function requestSignal15(timeoutMs, signal) {
9766
9780
  const timeout = AbortSignal.timeout(timeoutMs);
9767
9781
  return signal ? AbortSignal.any([timeout, signal]) : timeout;
9768
9782
  }
9769
- function errorMessage34(err) {
9783
+ function errorMessage36(err) {
9770
9784
  return err instanceof Error ? err.message : String(err);
9771
9785
  }
9772
9786
  function isAbortError4(err) {
9773
- return errorMessage34(err).toLowerCase().includes("abort");
9787
+ return errorMessage36(err).toLowerCase().includes("abort");
9774
9788
  }
9775
9789
  function ssrfOptions3(options) {
9776
9790
  return {
@@ -9812,14 +9826,14 @@ function unlockerBody(url, zone) {
9812
9826
  };
9813
9827
  }
9814
9828
  async function brightDataRequest(url, zone, signal, options) {
9815
- const apiKey = await getApiKey29(signal);
9829
+ const apiKey = await getApiKey31(signal);
9816
9830
  const headers = {
9817
9831
  "Content-Type": "application/json",
9818
9832
  Authorization: `Bearer ${apiKey}`
9819
9833
  };
9820
9834
  const activityId = activityMonitor.logStart({ type: "fetch", url });
9821
9835
  try {
9822
- const response = await fetchBrightDataApi(resolveProviderApiUrl("brightdata", BRIGHTDATA_REQUEST_URL, loadConfig45().brightdataBaseUrl), {
9836
+ const response = await fetchBrightDataApi(resolveProviderApiUrl("brightdata", BRIGHTDATA_REQUEST_URL, loadConfig47().brightdataBaseUrl), {
9823
9837
  method: "POST",
9824
9838
  headers,
9825
9839
  body: JSON.stringify(unlockerBody(url, zone)),
@@ -9833,7 +9847,7 @@ async function brightDataRequest(url, zone, signal, options) {
9833
9847
  activityMonitor.logComplete(activityId, response.status);
9834
9848
  return text7;
9835
9849
  } catch (err) {
9836
- const message = errorMessage34(err);
9850
+ const message = errorMessage36(err);
9837
9851
  const redactedMessage = redactCredential(message, apiKey);
9838
9852
  if (isAbortError4(err)) activityMonitor.logComplete(activityId, 0);
9839
9853
  else activityMonitor.logError(activityId, redactedMessage);
@@ -9852,7 +9866,7 @@ function isBrightDataUnlockerAvailable() {
9852
9866
  if (getZone() === null) return false;
9853
9867
  return hasCredentialSource({
9854
9868
  provider: "Bright Data",
9855
- configuredValue: loadConfig45().brightdataApiKey,
9869
+ configuredValue: loadConfig47().brightdataApiKey,
9856
9870
  environmentValue: process.env.BRIGHTDATA_API_KEY
9857
9871
  });
9858
9872
  }
@@ -9864,26 +9878,26 @@ async function extractWithBrightDataUnlocker(url, signal, options) {
9864
9878
  if (!content) return null;
9865
9879
  return { url, title: headingTitle(content), content, error: null };
9866
9880
  }
9867
- var CONFIG_PATH53, BRIGHTDATA_REQUEST_URL, EXTRACT_TIMEOUT_MS4, DEFAULT_MAX_REDIRECTS3, REDIRECT_STATUSES3, ZONE_PATTERN2, cachedConfig45;
9881
+ var CONFIG_PATH55, BRIGHTDATA_REQUEST_URL, EXTRACT_TIMEOUT_MS4, DEFAULT_MAX_REDIRECTS3, REDIRECT_STATUSES3, ZONE_PATTERN2, cachedConfig47;
9868
9882
  var init_brightdata_unlocker = __esm({
9869
9883
  "brightdata-unlocker.ts"() {
9870
9884
  init_activity();
9871
9885
  init_credential_source();
9872
9886
  init_ssrf_protection();
9873
9887
  init_utils();
9874
- CONFIG_PATH53 = getWebSearchConfigPath();
9888
+ CONFIG_PATH55 = getWebSearchConfigPath();
9875
9889
  BRIGHTDATA_REQUEST_URL = "https://api.brightdata.com/request";
9876
9890
  EXTRACT_TIMEOUT_MS4 = 6e4;
9877
9891
  DEFAULT_MAX_REDIRECTS3 = 5;
9878
9892
  REDIRECT_STATUSES3 = /* @__PURE__ */ new Set([301, 302, 303, 307, 308]);
9879
9893
  ZONE_PATTERN2 = /^[a-z0-9_-]+$/i;
9880
- cachedConfig45 = null;
9894
+ cachedConfig47 = null;
9881
9895
  }
9882
9896
  });
9883
9897
 
9884
9898
  // video-extract.ts
9885
9899
  import { execFileSync as execFileSync2 } from "node:child_process";
9886
- import { existsSync as existsSync58, readFileSync as readFileSync59, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
9900
+ import { existsSync as existsSync60, readFileSync as readFileSync61, readdirSync as readdirSync4, statSync as statSync3 } from "node:fs";
9887
9901
  import { readFile as readFile2 } from "node:fs/promises";
9888
9902
  import { resolve, extname as extname2, basename as basename4, join as join7, dirname as dirname2 } from "node:path";
9889
9903
  function shouldRethrow3(err) {
@@ -9904,17 +9918,17 @@ function normalizeMaxSizeMB(value, fallback) {
9904
9918
  }
9905
9919
  function loadVideoConfig() {
9906
9920
  if (cachedVideoConfig) return cachedVideoConfig;
9907
- if (!existsSync58(CONFIG_PATH54)) {
9921
+ if (!existsSync60(CONFIG_PATH56)) {
9908
9922
  cachedVideoConfig = { ...VIDEO_CONFIG_DEFAULTS };
9909
9923
  return cachedVideoConfig;
9910
9924
  }
9911
- const rawText = readFileSync59(CONFIG_PATH54, "utf-8");
9925
+ const rawText = readFileSync61(CONFIG_PATH56, "utf-8");
9912
9926
  let raw;
9913
9927
  try {
9914
9928
  raw = JSON.parse(rawText);
9915
9929
  } catch (err) {
9916
9930
  const message = err instanceof Error ? err.message : String(err);
9917
- throw new Error(`Failed to parse ${CONFIG_PATH54}: ${message}`);
9931
+ throw new Error(`Failed to parse ${CONFIG_PATH56}: ${message}`);
9918
9932
  }
9919
9933
  const v = raw.video ?? {};
9920
9934
  cachedVideoConfig = {
@@ -9960,10 +9974,10 @@ function isVideoFile(input) {
9960
9974
  }
9961
9975
  function resolveFilePath(filePath) {
9962
9976
  const absolutePath = resolve(filePath);
9963
- if (existsSync58(absolutePath)) return absolutePath;
9977
+ if (existsSync60(absolutePath)) return absolutePath;
9964
9978
  const dir = dirname2(absolutePath);
9965
9979
  const base = basename4(absolutePath);
9966
- if (!existsSync58(dir)) return null;
9980
+ if (!existsSync60(dir)) return null;
9967
9981
  try {
9968
9982
  const normalizedBase = normalizeSpaces(base);
9969
9983
  const match = readdirSync4(dir).find((f) => normalizeSpaces(f) === normalizedBase);
@@ -10162,7 +10176,7 @@ function deleteGeminiFile(fileName, apiKey) {
10162
10176
  function extractVideoTitle(text7, filePath) {
10163
10177
  return extractHeadingTitle(text7) ?? basename4(filePath, extname2(filePath));
10164
10178
  }
10165
- var CONFIG_PATH54, DEFAULT_VIDEO_PROMPT, VIDEO_EXTENSIONS, VIDEO_CONFIG_DEFAULTS, cachedVideoConfig;
10179
+ var CONFIG_PATH56, DEFAULT_VIDEO_PROMPT, VIDEO_EXTENSIONS, VIDEO_CONFIG_DEFAULTS, cachedVideoConfig;
10166
10180
  var init_video_extract = __esm({
10167
10181
  "video-extract.ts"() {
10168
10182
  init_activity();
@@ -10171,7 +10185,7 @@ var init_video_extract = __esm({
10171
10185
  init_gemini_api();
10172
10186
  init_extract();
10173
10187
  init_utils();
10174
- CONFIG_PATH54 = getWebSearchConfigPath();
10188
+ CONFIG_PATH56 = getWebSearchConfigPath();
10175
10189
  DEFAULT_VIDEO_PROMPT = `Extract the complete content of this video. Include:
10176
10190
  1. Video title (infer from content if not explicit), duration
10177
10191
  2. A brief summary (2-3 sentences)
@@ -10656,13 +10670,13 @@ __export(extract_exports, {
10656
10670
  readPDFResponseBuffer: () => readPDFResponseBuffer,
10657
10671
  resolveFetchTimeoutMs: () => resolveFetchTimeoutMs
10658
10672
  });
10659
- import { existsSync as existsSync59, readFileSync as readFileSync60 } from "node:fs";
10673
+ import { existsSync as existsSync61, readFileSync as readFileSync62 } from "node:fs";
10660
10674
  import pLimit from "p-limit";
10661
10675
  function loadFetchTimeoutMs() {
10662
- if (!existsSync59(WEB_SEARCH_CONFIG_PATH3)) return DEFAULT_TIMEOUT_MS5;
10676
+ if (!existsSync61(WEB_SEARCH_CONFIG_PATH3)) return DEFAULT_TIMEOUT_MS5;
10663
10677
  let raw;
10664
10678
  try {
10665
- raw = JSON.parse(readFileSync60(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
10679
+ raw = JSON.parse(readFileSync62(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
10666
10680
  } catch (err) {
10667
10681
  const message = err instanceof Error ? err.message : String(err);
10668
10682
  throw new Error(`Failed to parse ${WEB_SEARCH_CONFIG_PATH3}: ${message}`);
@@ -10717,21 +10731,21 @@ async function extractWithDefuddle(text7, url) {
10717
10731
  }
10718
10732
  const result = await resultPromise;
10719
10733
  if (processingError !== void 0) {
10720
- throw new Error(`Defuddle failed to process document: ${errorMessage35(processingError)}`);
10734
+ throw new Error(`Defuddle failed to process document: ${errorMessage37(processingError)}`);
10721
10735
  }
10722
10736
  return typeof result.content === "string" ? { title: result.title, content: result.content } : null;
10723
10737
  }
10724
10738
  function loadSsrfAllowRanges() {
10725
10739
  return loadSsrfConfig().allowRanges;
10726
10740
  }
10727
- function errorMessage35(err) {
10741
+ function errorMessage37(err) {
10728
10742
  return err instanceof Error ? err.message : String(err);
10729
10743
  }
10730
10744
  function isConfigParseError(err) {
10731
- return errorMessage35(err).startsWith("Failed to parse ");
10745
+ return errorMessage37(err).startsWith("Failed to parse ");
10732
10746
  }
10733
10747
  function isAbortError5(err) {
10734
- return errorMessage35(err).toLowerCase().includes("abort");
10748
+ return errorMessage37(err).toLowerCase().includes("abort");
10735
10749
  }
10736
10750
  function isAbortException2(err) {
10737
10751
  return err instanceof DOMException && (err.name === "AbortError" || err.name === "TimeoutError");
@@ -10746,7 +10760,7 @@ function imageGateError() {
10746
10760
  try {
10747
10761
  return isImageEnabled() ? null : "Image fetching is disabled by image.enabled";
10748
10762
  } catch (err) {
10749
- return errorMessage35(err);
10763
+ return errorMessage37(err);
10750
10764
  }
10751
10765
  }
10752
10766
  function redirectPolicyRouteRefusal(url, path) {
@@ -10801,12 +10815,12 @@ async function fetchAuthenticatedRemoteUrl(url, init, validationOptions, profile
10801
10815
  throw new Error(`Too many redirects fetching ${current.toString()}`);
10802
10816
  }
10803
10817
  function loadFetchRouting() {
10804
- if (!existsSync59(WEB_SEARCH_CONFIG_PATH3)) {
10818
+ if (!existsSync61(WEB_SEARCH_CONFIG_PATH3)) {
10805
10819
  return { providers: DEFAULT_FETCH_PROVIDER_ORDER, allowRemoteHostedProviders: false };
10806
10820
  }
10807
10821
  let raw;
10808
10822
  try {
10809
- const parsed = JSON.parse(readFileSync60(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
10823
+ const parsed = JSON.parse(readFileSync62(WEB_SEARCH_CONFIG_PATH3, "utf-8"));
10810
10824
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
10811
10825
  throw new Error("expected a JSON object");
10812
10826
  }
@@ -10997,7 +11011,7 @@ function safeVideoInfo(url) {
10997
11011
  const info = isVideoFile(url);
10998
11012
  return info ? { status: "video", info } : { status: "not-video" };
10999
11013
  } catch (err) {
11000
- return { status: "invalid", error: errorMessage35(err) };
11014
+ return { status: "invalid", error: errorMessage37(err) };
11001
11015
  }
11002
11016
  }
11003
11017
  async function extractContent(url, signal, options) {
@@ -11008,7 +11022,7 @@ async function extractContent(url, signal, options) {
11008
11022
  try {
11009
11023
  redirectPolicy = options?.redirects ?? loadFetchContentRedirectPolicy();
11010
11024
  } catch (err) {
11011
- return { url, title: "", content: "", error: errorMessage35(err) };
11025
+ return { url, title: "", content: "", error: errorMessage37(err) };
11012
11026
  }
11013
11027
  let remoteUrl = null;
11014
11028
  try {
@@ -11030,14 +11044,14 @@ async function extractContent(url, signal, options) {
11030
11044
  ...options?.lookup ? { lookup: options.lookup } : {}
11031
11045
  });
11032
11046
  } catch (err) {
11033
- return { url, title: "", content: "", error: errorMessage35(err) };
11047
+ return { url, title: "", content: "", error: errorMessage37(err) };
11034
11048
  }
11035
11049
  }
11036
11050
  if (options?.authFetchProfile || options?.mode === "raw") {
11037
11051
  try {
11038
11052
  return await extractViaHttp(url, resolveFetchTimeoutMs(options), signal, options);
11039
11053
  } catch (err) {
11040
- return { url, title: "", content: "", error: errorMessage35(err) };
11054
+ return { url, title: "", content: "", error: errorMessage37(err) };
11041
11055
  }
11042
11056
  }
11043
11057
  if (redirectPolicy) {
@@ -11180,20 +11194,20 @@ async function extractContent(url, signal, options) {
11180
11194
  2. Set GEMINI_API_KEY in ${WEB_SEARCH_CONFIG_PATH3}` };
11181
11195
  } catch (err) {
11182
11196
  if (isAbortError5(err)) return abortedResult(url);
11183
- return { url, title: "", content: "", error: errorMessage35(err) };
11197
+ return { url, title: "", content: "", error: errorMessage37(err) };
11184
11198
  }
11185
11199
  }
11186
11200
  try {
11187
11201
  if (!remoteUrl) new URL(url);
11188
11202
  } catch (err) {
11189
- return { url, title: "", content: "", error: errorMessage35(err) };
11203
+ return { url, title: "", content: "", error: errorMessage37(err) };
11190
11204
  }
11191
11205
  try {
11192
11206
  const ghIssuePrResult = await extractGitHubIssuePr(url, signal, options);
11193
11207
  if (ghIssuePrResult) return ghIssuePrResult;
11194
11208
  if (signal?.aborted) return abortedResult(url);
11195
11209
  } catch (err) {
11196
- const message = errorMessage35(err);
11210
+ const message = errorMessage37(err);
11197
11211
  if (isAbortError5(err)) return abortedResult(url);
11198
11212
  if (isConfigParseError(err)) {
11199
11213
  return { url, title: "", content: "", error: message };
@@ -11204,7 +11218,7 @@ async function extractContent(url, signal, options) {
11204
11218
  if (ghResult) return ghResult;
11205
11219
  if (signal?.aborted) return abortedResult(url);
11206
11220
  } catch (err) {
11207
- const message = errorMessage35(err);
11221
+ const message = errorMessage37(err);
11208
11222
  if (isAbortError5(err)) return abortedResult(url);
11209
11223
  if (isConfigParseError(err)) {
11210
11224
  return { url, title: "", content: "", error: message };
@@ -11215,7 +11229,7 @@ async function extractContent(url, signal, options) {
11215
11229
  try {
11216
11230
  youtubeEnabled = isYouTubeEnabled();
11217
11231
  } catch (err) {
11218
- return { url, title: "", content: "", error: errorMessage35(err) };
11232
+ return { url, title: "", content: "", error: errorMessage37(err) };
11219
11233
  }
11220
11234
  if (ytInfo.isYouTube && youtubeEnabled) {
11221
11235
  try {
@@ -11223,7 +11237,7 @@ async function extractContent(url, signal, options) {
11223
11237
  if (ytResult) return ytResult;
11224
11238
  if (signal?.aborted) return abortedResult(url);
11225
11239
  } catch (err) {
11226
- const message = errorMessage35(err);
11240
+ const message = errorMessage37(err);
11227
11241
  if (isAbortError5(err)) return abortedResult(url);
11228
11242
  return { url, title: "", content: "", error: message };
11229
11243
  }
@@ -11239,13 +11253,13 @@ async function extractContent(url, signal, options) {
11239
11253
  try {
11240
11254
  fetchTimeoutMs = resolveFetchTimeoutMs(options);
11241
11255
  } catch (err) {
11242
- return { url, title: "", content: "", error: errorMessage35(err) };
11256
+ return { url, title: "", content: "", error: errorMessage37(err) };
11243
11257
  }
11244
11258
  let fetchRouting;
11245
11259
  try {
11246
11260
  fetchRouting = loadFetchRouting();
11247
11261
  } catch (err) {
11248
- return { url, title: "", content: "", error: errorMessage35(err) };
11262
+ return { url, title: "", content: "", error: errorMessage37(err) };
11249
11263
  }
11250
11264
  if (redirectPolicy && !fetchRouting.providers.includes("http")) {
11251
11265
  return redirectPolicyRouteRefusal(url, fetchRouting.providers[0]);
@@ -11314,7 +11328,7 @@ async function extractContent(url, signal, options) {
11314
11328
  }
11315
11329
  } catch (err) {
11316
11330
  if (isAbortError5(err)) return abortedResult(url);
11317
- firecrawlError = errorMessage35(err);
11331
+ firecrawlError = errorMessage37(err);
11318
11332
  if (isConfigParseError(err)) return parseErrorResult(firecrawlError);
11319
11333
  }
11320
11334
  continue;
@@ -11332,7 +11346,7 @@ async function extractContent(url, signal, options) {
11332
11346
  }
11333
11347
  } catch (err) {
11334
11348
  if (signal?.aborted || isAbortException2(err)) return abortedResult(url);
11335
- crawl4aiError = errorMessage35(err);
11349
+ crawl4aiError = errorMessage37(err);
11336
11350
  if (isConfigParseError(err)) return parseErrorResult(crawl4aiError);
11337
11351
  }
11338
11352
  continue;
@@ -11350,7 +11364,7 @@ async function extractContent(url, signal, options) {
11350
11364
  }
11351
11365
  } catch (err) {
11352
11366
  if (isAbortError5(err)) return abortedResult(url);
11353
- tinyfishError = errorMessage35(err);
11367
+ tinyfishError = errorMessage37(err);
11354
11368
  if (isConfigParseError(err)) return parseErrorResult(tinyfishError);
11355
11369
  }
11356
11370
  continue;
@@ -11363,7 +11377,7 @@ async function extractContent(url, signal, options) {
11363
11377
  }
11364
11378
  } catch (err) {
11365
11379
  if (isAbortError5(err)) return abortedResult(url);
11366
- search1apiError = errorMessage35(err);
11380
+ search1apiError = errorMessage37(err);
11367
11381
  if (isConfigParseError(err)) return parseErrorResult(search1apiError);
11368
11382
  }
11369
11383
  continue;
@@ -11376,7 +11390,7 @@ async function extractContent(url, signal, options) {
11376
11390
  }
11377
11391
  } catch (err) {
11378
11392
  if (isAbortError5(err)) return abortedResult(url);
11379
- queritError = errorMessage35(err);
11393
+ queritError = errorMessage37(err);
11380
11394
  if (isConfigParseError(err)) return parseErrorResult(queritError);
11381
11395
  }
11382
11396
  continue;
@@ -11389,7 +11403,7 @@ async function extractContent(url, signal, options) {
11389
11403
  }
11390
11404
  } catch (err) {
11391
11405
  if (isAbortError5(err)) return abortedResult(url);
11392
- tabstackError = errorMessage35(err);
11406
+ tabstackError = errorMessage37(err);
11393
11407
  if (isConfigParseError(err)) return parseErrorResult(tabstackError);
11394
11408
  }
11395
11409
  continue;
@@ -11407,7 +11421,7 @@ async function extractContent(url, signal, options) {
11407
11421
  }
11408
11422
  } catch (err) {
11409
11423
  if (isAbortError5(err)) return abortedResult(url);
11410
- kagiError = errorMessage35(err);
11424
+ kagiError = errorMessage37(err);
11411
11425
  if (isConfigParseError(err)) return parseErrorResult(kagiError);
11412
11426
  }
11413
11427
  continue;
@@ -11425,7 +11439,7 @@ async function extractContent(url, signal, options) {
11425
11439
  }
11426
11440
  } catch (err) {
11427
11441
  if (isAbortError5(err)) return abortedResult(url);
11428
- ollamaError = errorMessage35(err);
11442
+ ollamaError = errorMessage37(err);
11429
11443
  if (isConfigParseError(err)) return parseErrorResult(ollamaError);
11430
11444
  }
11431
11445
  continue;
@@ -11438,7 +11452,7 @@ async function extractContent(url, signal, options) {
11438
11452
  }
11439
11453
  } catch (err) {
11440
11454
  if (isAbortError5(err)) return abortedResult(url);
11441
- parallelError = errorMessage35(err);
11455
+ parallelError = errorMessage37(err);
11442
11456
  if (isConfigParseError(err)) return parseErrorResult(parallelError);
11443
11457
  }
11444
11458
  continue;
@@ -11449,7 +11463,7 @@ async function extractContent(url, signal, options) {
11449
11463
  if (parallelMcpResult) return withDeclaredLinks(parallelMcpResult);
11450
11464
  } catch (err) {
11451
11465
  if (isAbortError5(err)) return abortedResult(url);
11452
- parallelMcpError = errorMessage35(err);
11466
+ parallelMcpError = errorMessage37(err);
11453
11467
  if (isConfigParseError(err)) return parseErrorResult(parallelMcpError);
11454
11468
  }
11455
11469
  continue;
@@ -11467,7 +11481,7 @@ async function extractContent(url, signal, options) {
11467
11481
  }
11468
11482
  } catch (err) {
11469
11483
  if (isAbortError5(err)) return abortedResult(url);
11470
- brightdataError = errorMessage35(err);
11484
+ brightdataError = errorMessage37(err);
11471
11485
  if (isConfigParseError(err)) return parseErrorResult(brightdataError);
11472
11486
  }
11473
11487
  continue;
@@ -11479,7 +11493,7 @@ async function extractContent(url, signal, options) {
11479
11493
  } catch (err) {
11480
11494
  if (isAbortError5(err)) return abortedResult(url);
11481
11495
  if (err instanceof CredentialResolutionError || isConfigParseError(err)) {
11482
- return parseErrorResult(errorMessage35(err));
11496
+ return parseErrorResult(errorMessage37(err));
11483
11497
  }
11484
11498
  }
11485
11499
  if (geminiResult) return withDeclaredLinks(geminiResult);
@@ -11495,7 +11509,7 @@ async function extractContent(url, signal, options) {
11495
11509
  }
11496
11510
  } catch (err) {
11497
11511
  if (isAbortError5(err)) return abortedResult(url);
11498
- deepseekError = errorMessage35(err);
11512
+ deepseekError = errorMessage37(err);
11499
11513
  if (isConfigParseError(err)) return parseErrorResult(deepseekError);
11500
11514
  }
11501
11515
  continue;
@@ -11511,7 +11525,7 @@ async function extractContent(url, signal, options) {
11511
11525
  }
11512
11526
  } catch (err) {
11513
11527
  if (isAbortError5(err)) return abortedResult(url);
11514
- exaError = errorMessage35(err);
11528
+ exaError = errorMessage37(err);
11515
11529
  if (isConfigParseError(err)) return parseErrorResult(exaError);
11516
11530
  }
11517
11531
  continue;
@@ -11752,7 +11766,7 @@ async function extractViaHttp(url, timeoutMs, signal, options, preferMarkdown =
11752
11766
  status: response.status
11753
11767
  };
11754
11768
  } catch (err) {
11755
- const message = errorMessage35(err);
11769
+ const message = errorMessage37(err);
11756
11770
  activityMonitor.logError(activityId, message);
11757
11771
  return { url, title: "", content: "", error: message, mimeType, status: response.status };
11758
11772
  }
@@ -12030,8 +12044,8 @@ import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js"
12030
12044
  // package.json
12031
12045
  var package_default = {
12032
12046
  name: "pi-web-access",
12033
- version: "0.46.0",
12034
- description: "Web search, URL fetching, GitHub repo cloning, PDF extraction, YouTube video understanding, and local video analysis for Pi coding agent. Supports OpenAI, Brave, Parallel, TinyFish, Search1API, Searchinfinity, Querit, Tavily, Firecrawl, Crawl4AI, Jina, SERPdive, Kagi, Ollama, AnySearch, Bright Data SERP, SerpBase, SerpApi, Serply, SearchApi, You.com, SearXNG, degoog, Exa, Perplexity, Gemini, Kimi, Mistral, and Tabstack.",
12047
+ version: "0.47.0",
12048
+ description: "Web search, URL fetching, GitHub repo cloning, PDF extraction, YouTube video understanding, and local video analysis for Pi coding agent. Supports OpenAI, Brave, Parallel, TinyFish, Search1API, Searchinfinity, Querit, Tavily, Firecrawl, Crawl4AI, Jina, SERPdive, Kagi, Ollama, AnySearch, Bright Data SERP, SerpBase, SerpApi, Serply, SearchApi, Outcrawl, Sofya, You.com, SearXNG, degoog, Exa, Perplexity, Gemini, Kimi, Mistral, and Tabstack.",
12035
12049
  type: "module",
12036
12050
  bin: {
12037
12051
  "pi-web-access-mcp": "dist/mcp-cli.js"
@@ -20602,7 +20616,7 @@ __export(value_exports, {
20602
20616
  });
20603
20617
 
20604
20618
  // gemini-search.ts
20605
- import { existsSync as existsSync47, readFileSync as readFileSync47 } from "node:fs";
20619
+ import { existsSync as existsSync49, readFileSync as readFileSync49 } from "node:fs";
20606
20620
 
20607
20621
  // abortable.ts
20608
20622
  async function awaitWithAbort(operation, signal) {
@@ -26491,6 +26505,343 @@ async function searchWithSearchApi(query, options = {}) {
26491
26505
  return { answer: formatSearchResultsAsAnswer(results), results };
26492
26506
  }
26493
26507
 
26508
+ // outcrawl.ts
26509
+ init_activity();
26510
+ init_domain_filter_normalization();
26511
+ init_search_answer_formatting();
26512
+ init_search_result_count_normalization();
26513
+ init_credential_source();
26514
+ init_utils();
26515
+ import { existsSync as existsSync45, readFileSync as readFileSync45 } from "node:fs";
26516
+ var OUTCRAWL_SEARCH_URL = "https://api.outcrawl.ai/v1/search";
26517
+ var CONFIG_PATH42 = getWebSearchConfigPath();
26518
+ var SEARCH_TIMEOUT_MS35 = 6e4;
26519
+ var MAX_REQUEST_RESULTS4 = 20;
26520
+ var cachedConfig38 = null;
26521
+ function loadConfig40() {
26522
+ if (cachedConfig38) return cachedConfig38;
26523
+ if (!existsSync45(CONFIG_PATH42)) {
26524
+ cachedConfig38 = {};
26525
+ return cachedConfig38;
26526
+ }
26527
+ const raw = readFileSync45(CONFIG_PATH42, "utf-8");
26528
+ let parsed;
26529
+ try {
26530
+ parsed = JSON.parse(raw);
26531
+ } catch (err) {
26532
+ const message = err instanceof Error ? err.message : String(err);
26533
+ throw new Error(`Failed to parse ${CONFIG_PATH42}: ${message}`);
26534
+ }
26535
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
26536
+ throw new Error(`Invalid config in ${CONFIG_PATH42}: expected a JSON object`);
26537
+ }
26538
+ cachedConfig38 = parsed;
26539
+ return cachedConfig38;
26540
+ }
26541
+ async function getApiKey28(signal) {
26542
+ return resolveCredential({
26543
+ provider: "Outcrawl",
26544
+ configuredValue: loadConfig40().outcrawlApiKey,
26545
+ environmentValue: process.env.OUTCRAWL_API_KEY,
26546
+ signal
26547
+ });
26548
+ }
26549
+ async function requireApiKey16(signal) {
26550
+ const apiKey = await getApiKey28(signal);
26551
+ if (!apiKey) {
26552
+ throw new Error(
26553
+ `Outcrawl API key not found. Either:
26554
+ 1. Create ${CONFIG_PATH42} with { "outcrawlApiKey": "your-key" }
26555
+ 2. Set OUTCRAWL_API_KEY environment variable
26556
+ Get a key at https://outcrawl.ai`
26557
+ );
26558
+ }
26559
+ return apiKey;
26560
+ }
26561
+ function parseDomainFilter13(domainFilter) {
26562
+ const filters = { include: [], exclude: [] };
26563
+ for (const raw of domainFilter ?? []) {
26564
+ const domain = normalizeDomain(raw);
26565
+ if (!domain) continue;
26566
+ const target = raw.trim().startsWith("-") ? filters.exclude : filters.include;
26567
+ if (!target.includes(domain)) target.push(domain);
26568
+ }
26569
+ return filters;
26570
+ }
26571
+ function passesDomainFilters13(url, filters) {
26572
+ if (filters.include.length === 0 && filters.exclude.length === 0) return true;
26573
+ const hostname2 = url.hostname.toLowerCase();
26574
+ const matches = (domain) => hostname2 === domain || hostname2.endsWith(`.${domain}`);
26575
+ if (filters.exclude.some(matches)) return false;
26576
+ return filters.include.length === 0 || filters.include.some(matches);
26577
+ }
26578
+ function buildQuery10(query, filters) {
26579
+ const parts = [query];
26580
+ if (filters.include.length === 1) parts.push(`site:${filters.include[0]}`);
26581
+ if (filters.include.length > 1) parts.push(`(${filters.include.map((domain) => `site:${domain}`).join(" OR ")})`);
26582
+ for (const domain of filters.exclude) parts.push(`-site:${domain}`);
26583
+ return parts.join(" ");
26584
+ }
26585
+ function errorMessage28(err) {
26586
+ return err instanceof Error ? err.message : String(err);
26587
+ }
26588
+ function invalidResponse16(message) {
26589
+ return new Error(`Outcrawl returned invalid response: ${message}`);
26590
+ }
26591
+ function parseResponse13(value) {
26592
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw invalidResponse16("expected an object envelope");
26593
+ const envelope = value;
26594
+ if (typeof envelope.error === "string" && envelope.error.trim()) throw invalidResponse16(envelope.error.trim());
26595
+ if (!Array.isArray(envelope.hits)) throw invalidResponse16("expected hits array");
26596
+ return envelope.hits;
26597
+ }
26598
+ function isOutcrawlAvailable() {
26599
+ return hasCredentialSource({ provider: "Outcrawl", configuredValue: loadConfig40().outcrawlApiKey, environmentValue: process.env.OUTCRAWL_API_KEY });
26600
+ }
26601
+ async function searchWithOutcrawl(query, options = {}) {
26602
+ const apiKey = await requireApiKey16(options.signal);
26603
+ const numResults = normalizeSearchResultCount(options.numResults);
26604
+ const filters = parseDomainFilter13(options.domainFilter);
26605
+ const hasDomainClauses = filters.include.length > 0 || filters.exclude.length > 0;
26606
+ const body = {
26607
+ query: buildQuery10(query, filters),
26608
+ limit: hasDomainClauses ? Math.min(MAX_REQUEST_RESULTS4, numResults + 5) : numResults
26609
+ };
26610
+ const activityId = activityMonitor.logStart({ type: "api", query });
26611
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS35);
26612
+ let response;
26613
+ let entries;
26614
+ try {
26615
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("outcrawl", OUTCRAWL_SEARCH_URL, loadConfig40().outcrawlBaseUrl), {
26616
+ method: "POST",
26617
+ headers: {
26618
+ Accept: "application/json",
26619
+ Authorization: `Bearer ${apiKey}`,
26620
+ "Content-Type": "application/json",
26621
+ "User-Agent": "pi-web-access"
26622
+ },
26623
+ body: JSON.stringify(body),
26624
+ signal: options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal
26625
+ }, ["Authorization"]);
26626
+ if (!response.ok) {
26627
+ const errorText = await response.text();
26628
+ throw new Error(`Outcrawl error ${response.status}: ${redactCredential(errorText, apiKey).slice(0, 300)}`);
26629
+ }
26630
+ let rawData;
26631
+ try {
26632
+ rawData = await response.json();
26633
+ } catch (err) {
26634
+ if (!(err instanceof SyntaxError)) throw err;
26635
+ throw new Error(`Outcrawl returned invalid JSON: ${errorMessage28(err)}`);
26636
+ }
26637
+ entries = parseResponse13(rawData);
26638
+ } catch (err) {
26639
+ if (options.signal?.aborted) {
26640
+ activityMonitor.logComplete(activityId, 0);
26641
+ throw new Error("Aborted");
26642
+ }
26643
+ const message = errorMessage28(err);
26644
+ const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
26645
+ const outgoing = providerTimeout ? new Error(`Outcrawl request timed out after ${Math.round(SEARCH_TIMEOUT_MS35 / 1e3)}s`) : (() => {
26646
+ const redactedMessage = redactCredential(message, apiKey);
26647
+ if (redactedMessage === message && err instanceof Error) return err;
26648
+ const redactedError = new Error(redactedMessage);
26649
+ if (err instanceof Error) redactedError.name = err.name;
26650
+ return redactedError;
26651
+ })();
26652
+ activityMonitor.logError(activityId, redactCredential(errorMessage28(outgoing), apiKey));
26653
+ throw outgoing;
26654
+ }
26655
+ activityMonitor.logComplete(activityId, response.status);
26656
+ const results = [];
26657
+ for (const entry of entries) {
26658
+ if (!entry || typeof entry !== "object") continue;
26659
+ if (typeof entry.url !== "string" || !entry.url) continue;
26660
+ let resultUrl;
26661
+ try {
26662
+ resultUrl = new URL(entry.url);
26663
+ } catch {
26664
+ continue;
26665
+ }
26666
+ if (resultUrl.protocol !== "http:" && resultUrl.protocol !== "https:") continue;
26667
+ if (!passesDomainFilters13(resultUrl, filters)) continue;
26668
+ results.push({
26669
+ title: typeof entry.title === "string" && entry.title.trim() ? entry.title.trim() : `Source ${results.length + 1}`,
26670
+ url: resultUrl.href,
26671
+ snippet: typeof entry.snippet === "string" ? entry.snippet : ""
26672
+ });
26673
+ if (results.length >= numResults) break;
26674
+ }
26675
+ return { answer: formatSearchResultsAsAnswer(results), results };
26676
+ }
26677
+
26678
+ // sofya.ts
26679
+ init_activity();
26680
+ init_domain_filter_normalization();
26681
+ init_search_answer_formatting();
26682
+ init_search_result_count_normalization();
26683
+ init_credential_source();
26684
+ init_utils();
26685
+ import { existsSync as existsSync46, readFileSync as readFileSync46 } from "node:fs";
26686
+ var SOFYA_SEARCH_URL = "https://sofya.co/v1/search";
26687
+ var CONFIG_PATH43 = getWebSearchConfigPath();
26688
+ var SEARCH_TIMEOUT_MS36 = 6e4;
26689
+ var MAX_REQUEST_RESULTS5 = 20;
26690
+ var MAX_DOMAIN_FILTERS = 10;
26691
+ var cachedConfig39 = null;
26692
+ function loadConfig41() {
26693
+ if (cachedConfig39) return cachedConfig39;
26694
+ if (!existsSync46(CONFIG_PATH43)) {
26695
+ cachedConfig39 = {};
26696
+ return cachedConfig39;
26697
+ }
26698
+ const raw = readFileSync46(CONFIG_PATH43, "utf-8");
26699
+ let parsed;
26700
+ try {
26701
+ parsed = JSON.parse(raw);
26702
+ } catch (err) {
26703
+ const message = err instanceof Error ? err.message : String(err);
26704
+ throw new Error(`Failed to parse ${CONFIG_PATH43}: ${message}`);
26705
+ }
26706
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
26707
+ throw new Error(`Invalid config in ${CONFIG_PATH43}: expected a JSON object`);
26708
+ }
26709
+ cachedConfig39 = parsed;
26710
+ return cachedConfig39;
26711
+ }
26712
+ async function getApiKey29(signal) {
26713
+ return resolveCredential({
26714
+ provider: "Sofya",
26715
+ configuredValue: loadConfig41().sofyaApiKey,
26716
+ environmentValue: process.env.SOFYA_API_KEY,
26717
+ signal
26718
+ });
26719
+ }
26720
+ async function requireApiKey17(signal) {
26721
+ const apiKey = await getApiKey29(signal);
26722
+ if (!apiKey) {
26723
+ throw new Error(
26724
+ `Sofya API key not found. Either:
26725
+ 1. Create ${CONFIG_PATH43} with { "sofyaApiKey": "your-key" }
26726
+ 2. Set SOFYA_API_KEY environment variable
26727
+ Get a key at https://sofya.co/dashboard`
26728
+ );
26729
+ }
26730
+ return apiKey;
26731
+ }
26732
+ function parseDomainFilter14(domainFilter) {
26733
+ const filters = { include: [], exclude: [] };
26734
+ for (const raw of domainFilter ?? []) {
26735
+ const domain = normalizeDomain(raw);
26736
+ if (!domain) continue;
26737
+ const target = raw.trim().startsWith("-") ? filters.exclude : filters.include;
26738
+ if (!target.includes(domain)) target.push(domain);
26739
+ }
26740
+ return filters;
26741
+ }
26742
+ function passesDomainFilters14(url, filters) {
26743
+ if (filters.include.length === 0 && filters.exclude.length === 0) return true;
26744
+ const hostname2 = url.hostname.toLowerCase();
26745
+ const matches = (domain) => hostname2 === domain || hostname2.endsWith(`.${domain}`);
26746
+ if (filters.exclude.some(matches)) return false;
26747
+ return filters.include.length === 0 || filters.include.some(matches);
26748
+ }
26749
+ function errorMessage29(err) {
26750
+ return err instanceof Error ? err.message : String(err);
26751
+ }
26752
+ function invalidResponse17(message) {
26753
+ return new Error(`Sofya returned invalid response: ${message}`);
26754
+ }
26755
+ function parseResponse14(value) {
26756
+ if (!value || typeof value !== "object" || Array.isArray(value)) throw invalidResponse17("expected an object envelope");
26757
+ const envelope = value;
26758
+ if (typeof envelope.detail === "string" && envelope.detail.trim()) throw invalidResponse17(envelope.detail.trim());
26759
+ if (!Array.isArray(envelope.results)) throw invalidResponse17("expected results array");
26760
+ return envelope.results;
26761
+ }
26762
+ function isSofyaAvailable() {
26763
+ return hasCredentialSource({ provider: "Sofya", configuredValue: loadConfig41().sofyaApiKey, environmentValue: process.env.SOFYA_API_KEY });
26764
+ }
26765
+ async function searchWithSofya(query, options = {}) {
26766
+ const apiKey = await requireApiKey17(options.signal);
26767
+ const numResults = normalizeSearchResultCount(options.numResults);
26768
+ const filters = parseDomainFilter14(options.domainFilter);
26769
+ const body = {
26770
+ query,
26771
+ search_depth: "snippets",
26772
+ max_results: Math.min(MAX_REQUEST_RESULTS5, numResults)
26773
+ };
26774
+ if (filters.include.length > 0) body.include_domains = filters.include.slice(0, MAX_DOMAIN_FILTERS);
26775
+ if (filters.exclude.length > 0) body.exclude_domains = filters.exclude.slice(0, MAX_DOMAIN_FILTERS);
26776
+ if (options.recencyFilter) body.freshness = options.recencyFilter;
26777
+ const activityId = activityMonitor.logStart({ type: "api", query });
26778
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS36);
26779
+ let response;
26780
+ let entries;
26781
+ try {
26782
+ response = await fetchWithCredentialRedirects(resolveProviderApiUrl("sofya", SOFYA_SEARCH_URL, loadConfig41().sofyaBaseUrl), {
26783
+ method: "POST",
26784
+ headers: {
26785
+ Accept: "application/json",
26786
+ Authorization: `Bearer ${apiKey}`,
26787
+ "Content-Type": "application/json",
26788
+ "User-Agent": "pi-web-access"
26789
+ },
26790
+ body: JSON.stringify(body),
26791
+ signal: options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal
26792
+ }, ["Authorization"]);
26793
+ if (!response.ok) {
26794
+ const errorText = await response.text();
26795
+ throw new Error(`Sofya error ${response.status}: ${redactCredential(errorText, apiKey).slice(0, 300)}`);
26796
+ }
26797
+ let rawData;
26798
+ try {
26799
+ rawData = await response.json();
26800
+ } catch (err) {
26801
+ if (!(err instanceof SyntaxError)) throw err;
26802
+ throw new Error(`Sofya returned invalid JSON: ${errorMessage29(err)}`);
26803
+ }
26804
+ entries = parseResponse14(rawData);
26805
+ } catch (err) {
26806
+ if (options.signal?.aborted) {
26807
+ activityMonitor.logComplete(activityId, 0);
26808
+ throw new Error("Aborted");
26809
+ }
26810
+ const message = errorMessage29(err);
26811
+ const providerTimeout = timeoutSignal.aborted || err instanceof Error && err.name === "TimeoutError";
26812
+ const outgoing = providerTimeout ? new Error(`Sofya request timed out after ${Math.round(SEARCH_TIMEOUT_MS36 / 1e3)}s`) : (() => {
26813
+ const redactedMessage = redactCredential(message, apiKey);
26814
+ if (redactedMessage === message && err instanceof Error) return err;
26815
+ const redactedError = new Error(redactedMessage);
26816
+ if (err instanceof Error) redactedError.name = err.name;
26817
+ return redactedError;
26818
+ })();
26819
+ activityMonitor.logError(activityId, redactCredential(errorMessage29(outgoing), apiKey));
26820
+ throw outgoing;
26821
+ }
26822
+ activityMonitor.logComplete(activityId, response.status);
26823
+ const results = [];
26824
+ for (const entry of entries) {
26825
+ if (!entry || typeof entry !== "object") continue;
26826
+ if (typeof entry.url !== "string" || !entry.url) continue;
26827
+ let resultUrl;
26828
+ try {
26829
+ resultUrl = new URL(entry.url);
26830
+ } catch {
26831
+ continue;
26832
+ }
26833
+ if (resultUrl.protocol !== "http:" && resultUrl.protocol !== "https:") continue;
26834
+ if (!passesDomainFilters14(resultUrl, filters)) continue;
26835
+ results.push({
26836
+ title: typeof entry.title === "string" && entry.title.trim() ? entry.title.trim() : `Source ${results.length + 1}`,
26837
+ url: resultUrl.href,
26838
+ snippet: typeof entry.content === "string" && entry.content ? entry.content : typeof entry.description === "string" ? entry.description : ""
26839
+ });
26840
+ if (results.length >= numResults) break;
26841
+ }
26842
+ return { answer: formatSearchResultsAsAnswer(results), results };
26843
+ }
26844
+
26494
26845
  // gemini-search.ts
26495
26846
  init_deepseek();
26496
26847
 
@@ -26503,7 +26854,7 @@ init_search_result_count_normalization();
26503
26854
  import { randomUUID as randomUUID2 } from "node:crypto";
26504
26855
  var KIMI_SEARCH_URL = "https://api.kimi.com/coding/v1/search";
26505
26856
  var KIMI_PROVIDERS = ["kimi-coding", "kimi-code"];
26506
- var SEARCH_TIMEOUT_MS36 = 3e4;
26857
+ var SEARCH_TIMEOUT_MS38 = 3e4;
26507
26858
  function buildRequestHeaders(auth) {
26508
26859
  const headers = new Headers();
26509
26860
  for (const [name, value] of Object.entries(auth.headers)) {
@@ -26618,7 +26969,7 @@ async function searchWithKimi(query, options = {}, ctx) {
26618
26969
  throw new Error("Kimi Code web search unavailable. Run /login kimi-coding to authenticate a Kimi Code Plan account.");
26619
26970
  }
26620
26971
  const activityId = activityMonitor.logStart({ type: "api", query });
26621
- const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS36);
26972
+ const timeoutSignal = AbortSignal.timeout(SEARCH_TIMEOUT_MS38);
26622
26973
  const requestSignal16 = options.signal ? AbortSignal.any([timeoutSignal, options.signal]) : timeoutSignal;
26623
26974
  try {
26624
26975
  const response = await fetch(KIMI_SEARCH_URL, {
@@ -26670,45 +27021,45 @@ init_activity();
26670
27021
  init_domain_filter_normalization();
26671
27022
  init_credential_source();
26672
27023
  init_utils();
26673
- import { existsSync as existsSync46, readFileSync as readFileSync46 } from "node:fs";
27024
+ import { existsSync as existsSync48, readFileSync as readFileSync48 } from "node:fs";
26674
27025
  var MISTRAL_CONVERSATIONS_URL = "https://api.mistral.ai/v1/conversations";
26675
- var CONFIG_PATH43 = getWebSearchConfigPath();
26676
- var SEARCH_TIMEOUT_MS37 = 6e4;
27026
+ var CONFIG_PATH45 = getWebSearchConfigPath();
27027
+ var SEARCH_TIMEOUT_MS39 = 6e4;
26677
27028
  var DEFAULT_SEARCH_MODEL = "mistral-small-latest";
26678
27029
  var DEFAULT_SEARCH_TOOL = "web_search";
26679
27030
  var MAX_RESULTS2 = 20;
26680
- var cachedConfig39 = null;
26681
- function loadConfig41() {
26682
- if (cachedConfig39) return cachedConfig39;
26683
- if (!existsSync46(CONFIG_PATH43)) {
26684
- cachedConfig39 = {};
26685
- return cachedConfig39;
27031
+ var cachedConfig41 = null;
27032
+ function loadConfig43() {
27033
+ if (cachedConfig41) return cachedConfig41;
27034
+ if (!existsSync48(CONFIG_PATH45)) {
27035
+ cachedConfig41 = {};
27036
+ return cachedConfig41;
26686
27037
  }
26687
- const raw = readFileSync46(CONFIG_PATH43, "utf-8");
27038
+ const raw = readFileSync48(CONFIG_PATH45, "utf-8");
26688
27039
  let parsed;
26689
27040
  try {
26690
27041
  parsed = JSON.parse(raw);
26691
27042
  } catch (err) {
26692
27043
  const message = err instanceof Error ? err.message : String(err);
26693
- throw new Error(`Failed to parse ${CONFIG_PATH43}: ${message}`);
27044
+ throw new Error(`Failed to parse ${CONFIG_PATH45}: ${message}`);
26694
27045
  }
26695
27046
  if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) {
26696
- throw new Error(`Invalid config in ${CONFIG_PATH43}: expected a JSON object`);
27047
+ throw new Error(`Invalid config in ${CONFIG_PATH45}: expected a JSON object`);
26697
27048
  }
26698
- cachedConfig39 = parsed;
26699
- return cachedConfig39;
27049
+ cachedConfig41 = parsed;
27050
+ return cachedConfig41;
26700
27051
  }
26701
27052
  function resolveSearchModel(value) {
26702
27053
  if (value === void 0) return DEFAULT_SEARCH_MODEL;
26703
27054
  if (typeof value !== "string" || value.trim().length === 0) {
26704
- throw new Error(`mistralSearchModel in ${CONFIG_PATH43} must be a non-empty string`);
27055
+ throw new Error(`mistralSearchModel in ${CONFIG_PATH45} must be a non-empty string`);
26705
27056
  }
26706
27057
  return value.trim();
26707
27058
  }
26708
27059
  function resolveSearchTool(value) {
26709
27060
  if (value === void 0) return DEFAULT_SEARCH_TOOL;
26710
27061
  if (value !== "web_search" && value !== "web_search_premium") {
26711
- throw new Error(`mistralSearchTool in ${CONFIG_PATH43} must be either web_search or web_search_premium`);
27062
+ throw new Error(`mistralSearchTool in ${CONFIG_PATH45} must be either web_search or web_search_premium`);
26712
27063
  }
26713
27064
  return value;
26714
27065
  }
@@ -26726,7 +27077,7 @@ function parseDomainFilters(domainFilter) {
26726
27077
  }
26727
27078
  return filters;
26728
27079
  }
26729
- function passesDomainFilters13(url, filters) {
27080
+ function passesDomainFilters15(url, filters) {
26730
27081
  if (filters.include.length === 0 && filters.exclude.length === 0) return true;
26731
27082
  const hostname2 = new URL(url).hostname.toLowerCase();
26732
27083
  const matches = (domain) => hostname2 === domain || hostname2.endsWith(`.${domain}`);
@@ -26766,18 +27117,18 @@ function buildSearchPrompt(query, options, numResults) {
26766
27117
 
26767
27118
  ${query}` : query;
26768
27119
  }
26769
- function errorMessage29(err) {
27120
+ function errorMessage31(err) {
26770
27121
  return err instanceof Error ? err.message : String(err);
26771
27122
  }
26772
- function invalidResponse16(message) {
27123
+ function invalidResponse18(message) {
26773
27124
  return new Error(`Mistral API returned invalid response: ${message}`);
26774
27125
  }
26775
27126
  function parseConversationResponse(value, options, numResults) {
26776
27127
  if (!value || typeof value !== "object" || Array.isArray(value)) {
26777
- throw invalidResponse16("expected an object envelope");
27128
+ throw invalidResponse18("expected an object envelope");
26778
27129
  }
26779
27130
  const outputs = value.outputs;
26780
- if (!Array.isArray(outputs)) throw invalidResponse16("outputs must be an array");
27131
+ if (!Array.isArray(outputs)) throw invalidResponse18("outputs must be an array");
26781
27132
  const answerParts = [];
26782
27133
  const results = [];
26783
27134
  const seenUrls = /* @__PURE__ */ new Set();
@@ -26801,7 +27152,7 @@ function parseConversationResponse(value, options, numResults) {
26801
27152
  }
26802
27153
  if (part.type !== "tool_reference" || results.length >= numResults) continue;
26803
27154
  const url = normalizeResultUrl2(part.url);
26804
- if (!url || !passesDomainFilters13(url, domainFilters2) || seenUrls.has(url)) continue;
27155
+ if (!url || !passesDomainFilters15(url, domainFilters2) || seenUrls.has(url)) continue;
26805
27156
  seenUrls.add(url);
26806
27157
  const title = typeof part.title === "string" && part.title.trim() ? part.title.trim() : url;
26807
27158
  const snippet = typeof part.description === "string" ? part.description : "";
@@ -26809,20 +27160,20 @@ function parseConversationResponse(value, options, numResults) {
26809
27160
  }
26810
27161
  }
26811
27162
  const answer = answerParts.join("\n").trim();
26812
- if (!answer && results.length === 0) throw invalidResponse16("no answer or sources");
27163
+ if (!answer && results.length === 0) throw invalidResponse18("no answer or sources");
26813
27164
  return { answer, results };
26814
27165
  }
26815
- async function getApiKey28(signal) {
27166
+ async function getApiKey30(signal) {
26816
27167
  const apiKey = await resolveCredential({
26817
27168
  provider: "Mistral",
26818
- configuredValue: loadConfig41().mistralApiKey,
27169
+ configuredValue: loadConfig43().mistralApiKey,
26819
27170
  environmentValue: process.env.MISTRAL_API_KEY,
26820
27171
  signal
26821
27172
  });
26822
27173
  if (!apiKey) {
26823
27174
  throw new Error(
26824
27175
  `Mistral API key not found. Either:
26825
- 1. Create ${CONFIG_PATH43} with { "mistralApiKey": "your-key" }
27176
+ 1. Create ${CONFIG_PATH45} with { "mistralApiKey": "your-key" }
26826
27177
  2. Set MISTRAL_API_KEY environment variable
26827
27178
  Get a key at https://console.mistral.ai/api-keys`
26828
27179
  );
@@ -26831,7 +27182,7 @@ Get a key at https://console.mistral.ai/api-keys`
26831
27182
  }
26832
27183
  function isMistralAvailable() {
26833
27184
  try {
26834
- const config = loadConfig41();
27185
+ const config = loadConfig43();
26835
27186
  resolveSearchModel(config.mistralSearchModel);
26836
27187
  resolveSearchTool(config.mistralSearchTool);
26837
27188
  return hasCredentialSource({
@@ -26844,15 +27195,15 @@ function isMistralAvailable() {
26844
27195
  }
26845
27196
  }
26846
27197
  async function searchWithMistral(query, options = {}) {
26847
- const config = loadConfig41();
27198
+ const config = loadConfig43();
26848
27199
  const model = options.model ?? resolveSearchModel(config.mistralSearchModel);
26849
27200
  const tool = resolveSearchTool(config.mistralSearchTool);
26850
27201
  const numResults = normalizeCount4(options.numResults);
26851
- const apiKey = await getApiKey28(options.signal);
26852
- const requestSignal16 = options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS37), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS37);
27202
+ const apiKey = await getApiKey30(options.signal);
27203
+ const requestSignal16 = options.signal ? AbortSignal.any([AbortSignal.timeout(SEARCH_TIMEOUT_MS39), options.signal]) : AbortSignal.timeout(SEARCH_TIMEOUT_MS39);
26853
27204
  const activityId = activityMonitor.logStart({ type: "api", query });
26854
27205
  try {
26855
- const response = await fetchWithCredentialRedirects(resolveProviderApiUrl("mistralSearch", MISTRAL_CONVERSATIONS_URL, loadConfig41().mistralSearchBaseUrl), {
27206
+ const response = await fetchWithCredentialRedirects(resolveProviderApiUrl("mistralSearch", MISTRAL_CONVERSATIONS_URL, loadConfig43().mistralSearchBaseUrl), {
26856
27207
  method: "POST",
26857
27208
  headers: {
26858
27209
  Authorization: `Bearer ${apiKey}`,
@@ -26874,13 +27225,13 @@ async function searchWithMistral(query, options = {}) {
26874
27225
  try {
26875
27226
  parsed = await response.json();
26876
27227
  } catch (err) {
26877
- throw new Error(`Mistral API returned invalid JSON: ${errorMessage29(err)}`);
27228
+ throw new Error(`Mistral API returned invalid JSON: ${errorMessage31(err)}`);
26878
27229
  }
26879
27230
  const result = parseConversationResponse(parsed, options, numResults);
26880
27231
  activityMonitor.logComplete(activityId, response.status);
26881
27232
  return result;
26882
27233
  } catch (err) {
26883
- const message = errorMessage29(err);
27234
+ const message = errorMessage31(err);
26884
27235
  const redactedMessage = redactCredential(message, apiKey);
26885
27236
  if (redactedMessage.toLowerCase().includes("abort")) {
26886
27237
  activityMonitor.logComplete(activityId, 0);
@@ -26896,7 +27247,7 @@ async function searchWithMistral(query, options = {}) {
26896
27247
 
26897
27248
  // gemini-search.ts
26898
27249
  init_utils();
26899
- var RESOLVED_SEARCH_PROVIDERS = ["openai", "brave", "parallel", "parallel-mcp", "tinyfish", "search1api", "searchinfinity", "querit", "tavily", "you", "firecrawl", "jina", "searxng", "degoog", "duckduckgo", "perplexity", "gemini", "kimi", "exa", "serpdive", "kagi", "ollama", "anysearch", "xai", "mistral", "brightdata", "serpbase", "serpapi", "serper", "serply", "valyu", "bocha", "xcrawl", "baizhi", "zai", "keenable", "ceramic", "deepseek", "linkup", "ninerouter", "cloudflare", "searchapi", "tabstack"];
27250
+ var RESOLVED_SEARCH_PROVIDERS = ["openai", "brave", "parallel", "parallel-mcp", "tinyfish", "search1api", "searchinfinity", "querit", "tavily", "you", "firecrawl", "jina", "searxng", "degoog", "duckduckgo", "perplexity", "gemini", "kimi", "exa", "serpdive", "kagi", "ollama", "anysearch", "xai", "mistral", "brightdata", "serpbase", "serpapi", "serper", "serply", "valyu", "bocha", "xcrawl", "baizhi", "zai", "keenable", "ceramic", "deepseek", "linkup", "ninerouter", "cloudflare", "searchapi", "outcrawl", "sofya", "tabstack"];
26900
27251
  var SEARCH_PROVIDERS = ["auto", "all", ...RESOLVED_SEARCH_PROVIDERS];
26901
27252
  var SearchProviderError = class extends Error {
26902
27253
  provider;
@@ -26912,7 +27263,7 @@ var SearchProviderError = class extends Error {
26912
27263
  this.causeError = cause;
26913
27264
  }
26914
27265
  };
26915
- var CONFIG_PATH44 = getWebSearchConfigPath();
27266
+ var CONFIG_PATH46 = getWebSearchConfigPath();
26916
27267
  var DEFAULT_SEARCH_MODEL2 = "gemini-3.6-flash";
26917
27268
  var ALL_SEARCH_PROVIDERS = ["searxng", "openai", "exa", "brave", "parallel", "tinyfish", "search1api", "searchinfinity", "querit", "tavily", "firecrawl", "jina", "serpdive", "kagi", "ollama", "perplexity", "gemini", "bocha"];
26918
27269
  var VALID_ROUTING_KINDS = ["transient", "quota", "network", "invalid-response", "unsupported", "empty", "domain-miss", "off-topic"];
@@ -26920,11 +27271,11 @@ var MAX_ROUTING_TIMEOUT_MS = 6e5;
26920
27271
  var cachedSearchConfig = null;
26921
27272
  function getSearchConfig() {
26922
27273
  if (cachedSearchConfig) return cachedSearchConfig;
26923
- if (!existsSync47(CONFIG_PATH44)) {
27274
+ if (!existsSync49(CONFIG_PATH46)) {
26924
27275
  cachedSearchConfig = { searchProvider: "auto", searchProviderConfigured: false };
26925
27276
  return cachedSearchConfig;
26926
27277
  }
26927
- const rawText = readFileSync47(CONFIG_PATH44, "utf-8");
27278
+ const rawText = readFileSync49(CONFIG_PATH46, "utf-8");
26928
27279
  let raw;
26929
27280
  try {
26930
27281
  const parsed = JSON.parse(rawText);
@@ -26934,25 +27285,25 @@ function getSearchConfig() {
26934
27285
  raw = parsed;
26935
27286
  } catch (err) {
26936
27287
  const message = err instanceof Error ? err.message : String(err);
26937
- throw new Error(`Failed to parse ${CONFIG_PATH44}: ${message}`);
27288
+ throw new Error(`Failed to parse ${CONFIG_PATH46}: ${message}`);
26938
27289
  }
26939
27290
  const searchModel = normalizeSearchModel(raw.searchModel);
26940
27291
  const webSearch = raw.webSearch;
26941
27292
  if (webSearch !== void 0 && (!webSearch || typeof webSearch !== "object" || Array.isArray(webSearch))) {
26942
- throw new Error(`webSearch in ${CONFIG_PATH44} must be an object`);
27293
+ throw new Error(`webSearch in ${CONFIG_PATH46} must be an object`);
26943
27294
  }
26944
- const allowedProviders = webSearch && Object.hasOwn(webSearch, "allowedProviders") ? normalizeResolvedProviderList(webSearch.allowedProviders, `webSearch.allowedProviders in ${CONFIG_PATH44}`) : void 0;
27295
+ const allowedProviders = webSearch && Object.hasOwn(webSearch, "allowedProviders") ? normalizeResolvedProviderList(webSearch.allowedProviders, `webSearch.allowedProviders in ${CONFIG_PATH46}`) : void 0;
26945
27296
  const searchProviderConfigured = Object.hasOwn(raw, "searchProvider") || Object.hasOwn(raw, "provider");
26946
- const searchProvider2 = normalizeSearchProviderSelection(raw.searchProvider ?? raw.provider, `provider in ${CONFIG_PATH44}`);
27297
+ const searchProvider2 = normalizeSearchProviderSelection(raw.searchProvider ?? raw.provider, `provider in ${CONFIG_PATH46}`);
26947
27298
  const searchRouting = Object.hasOwn(raw, "searchRouting") ? normalizeSearchRouting(raw.searchRouting) : void 0;
26948
27299
  if (allowedProviders) {
26949
27300
  if (Object.hasOwn(raw, "searchProvider")) {
26950
- assertSearchProviderSelectionAllowed(normalizeSearchProviderSelection(raw.searchProvider), `searchProvider in ${CONFIG_PATH44}`, allowedProviders);
27301
+ assertSearchProviderSelectionAllowed(normalizeSearchProviderSelection(raw.searchProvider), `searchProvider in ${CONFIG_PATH46}`, allowedProviders);
26951
27302
  }
26952
27303
  if (Object.hasOwn(raw, "provider")) {
26953
- assertSearchProviderSelectionAllowed(normalizeSearchProviderSelection(raw.provider), `provider in ${CONFIG_PATH44}`, allowedProviders);
27304
+ assertSearchProviderSelectionAllowed(normalizeSearchProviderSelection(raw.provider), `provider in ${CONFIG_PATH46}`, allowedProviders);
26954
27305
  }
26955
- if (searchRouting) assertSearchProviderSelectionAllowed(searchRouting.providers, `searchRouting.providers in ${CONFIG_PATH44}`, allowedProviders);
27306
+ if (searchRouting) assertSearchProviderSelectionAllowed(searchRouting.providers, `searchRouting.providers in ${CONFIG_PATH46}`, allowedProviders);
26956
27307
  }
26957
27308
  cachedSearchConfig = {
26958
27309
  searchProvider: searchProvider2,
@@ -26965,21 +27316,21 @@ function getSearchConfig() {
26965
27316
  }
26966
27317
  function normalizeSearchRouting(value) {
26967
27318
  if (!value || typeof value !== "object" || Array.isArray(value)) {
26968
- throw new Error(`searchRouting in ${CONFIG_PATH44} must be an object`);
27319
+ throw new Error(`searchRouting in ${CONFIG_PATH46} must be an object`);
26969
27320
  }
26970
27321
  const raw = value;
26971
- const providers = normalizeResolvedProviderList(raw.providers, `searchRouting.providers in ${CONFIG_PATH44}`);
27322
+ const providers = normalizeResolvedProviderList(raw.providers, `searchRouting.providers in ${CONFIG_PATH46}`);
26972
27323
  const useCurrentModel = raw.useCurrentModel;
26973
27324
  if (useCurrentModel !== void 0 && typeof useCurrentModel !== "boolean") {
26974
- throw new Error(`searchRouting.useCurrentModel in ${CONFIG_PATH44} must be a boolean`);
27325
+ throw new Error(`searchRouting.useCurrentModel in ${CONFIG_PATH46} must be a boolean`);
26975
27326
  }
26976
27327
  if (!Array.isArray(raw.fallbackOn) || raw.fallbackOn.length === 0) {
26977
- throw new Error(`searchRouting.fallbackOn in ${CONFIG_PATH44} must be a non-empty array`);
27328
+ throw new Error(`searchRouting.fallbackOn in ${CONFIG_PATH46} must be a non-empty array`);
26978
27329
  }
26979
27330
  const fallbackOn = [];
26980
27331
  for (const kind of raw.fallbackOn) {
26981
27332
  if (typeof kind !== "string" || !VALID_ROUTING_KINDS.includes(kind)) {
26982
- throw new Error(`searchRouting.fallbackOn in ${CONFIG_PATH44} may only contain transient, quota, network, invalid-response, unsupported, empty, domain-miss, or off-topic`);
27333
+ throw new Error(`searchRouting.fallbackOn in ${CONFIG_PATH46} may only contain transient, quota, network, invalid-response, unsupported, empty, domain-miss, or off-topic`);
26983
27334
  }
26984
27335
  if (!fallbackOn.includes(kind)) {
26985
27336
  fallbackOn.push(kind);
@@ -26987,14 +27338,14 @@ function normalizeSearchRouting(value) {
26987
27338
  }
26988
27339
  const timeoutMs = raw.timeoutMs;
26989
27340
  if (timeoutMs !== void 0 && (typeof timeoutMs !== "number" || !Number.isInteger(timeoutMs) || timeoutMs < 1 || timeoutMs > MAX_ROUTING_TIMEOUT_MS)) {
26990
- throw new Error(`searchRouting.timeoutMs in ${CONFIG_PATH44} must be an integer from 1 through ${MAX_ROUTING_TIMEOUT_MS}`);
27341
+ throw new Error(`searchRouting.timeoutMs in ${CONFIG_PATH46} must be an integer from 1 through ${MAX_ROUTING_TIMEOUT_MS}`);
26991
27342
  }
26992
27343
  const offTopicModel = raw.offTopicModel;
26993
27344
  if (offTopicModel !== void 0 && (typeof offTopicModel !== "string" || !Object.hasOwn(OFFTOPIC_JUDGE_MODELS, offTopicModel))) {
26994
- throw new Error(`searchRouting.offTopicModel in ${CONFIG_PATH44} must be one of ${Object.keys(OFFTOPIC_JUDGE_MODELS).join(", ")}`);
27345
+ throw new Error(`searchRouting.offTopicModel in ${CONFIG_PATH46} must be one of ${Object.keys(OFFTOPIC_JUDGE_MODELS).join(", ")}`);
26995
27346
  }
26996
27347
  if (fallbackOn.includes("off-topic") && offTopicModel === void 0) {
26997
- throw new Error(`searchRouting.fallbackOn in ${CONFIG_PATH44} lists off-topic, which needs searchRouting.offTopicModel`);
27348
+ throw new Error(`searchRouting.fallbackOn in ${CONFIG_PATH46} lists off-topic, which needs searchRouting.offTopicModel`);
26998
27349
  }
26999
27350
  return {
27000
27351
  providers,
@@ -27087,11 +27438,11 @@ function validateSearchModelOverride(provider, model) {
27087
27438
  assertSearchProviderSelectionAllowed(selected, "Requested provider");
27088
27439
  return model.trim();
27089
27440
  }
27090
- function errorMessage30(err) {
27441
+ function errorMessage32(err) {
27091
27442
  return err instanceof Error ? err.message : String(err);
27092
27443
  }
27093
27444
  function isAbortError2(err) {
27094
- return errorMessage30(err).toLowerCase().includes("abort");
27445
+ return errorMessage32(err).toLowerCase().includes("abort");
27095
27446
  }
27096
27447
  async function tryOpenAIInAuto(query, options, fallbackErrors, take) {
27097
27448
  try {
@@ -27101,7 +27452,7 @@ async function tryOpenAIInAuto(query, options, fallbackErrors, take) {
27101
27452
  }
27102
27453
  } catch (err) {
27103
27454
  if (isAbortError2(err)) throw err;
27104
- fallbackErrors.push(`OpenAI: ${errorMessage30(err)}`);
27455
+ fallbackErrors.push(`OpenAI: ${errorMessage32(err)}`);
27105
27456
  }
27106
27457
  return null;
27107
27458
  }
@@ -27117,7 +27468,7 @@ async function searchWithGemini(query, options, strictErrors) {
27117
27468
  if (apiResult) return apiResult;
27118
27469
  } catch (err) {
27119
27470
  if (err instanceof CredentialResolutionError || isAbortError2(err)) throw err;
27120
- errors.push(`Gemini API: ${errorMessage30(err)}`);
27471
+ errors.push(`Gemini API: ${errorMessage32(err)}`);
27121
27472
  }
27122
27473
  try {
27123
27474
  const webResult = await searchWithGeminiWeb(query, options);
@@ -27126,7 +27477,7 @@ async function searchWithGemini(query, options, strictErrors) {
27126
27477
  if (diagnostic) errors.push(`Gemini Web: ${diagnostic}`);
27127
27478
  } catch (err) {
27128
27479
  if (isAbortError2(err)) throw err;
27129
- errors.push(`Gemini Web: ${errorMessage30(err)}`);
27480
+ errors.push(`Gemini Web: ${errorMessage32(err)}`);
27130
27481
  }
27131
27482
  if (strictErrors && errors.length > 0) {
27132
27483
  throw new Error(`Gemini search failed:
@@ -27141,7 +27492,7 @@ function providerErrorStatus(message) {
27141
27492
  }
27142
27493
  function classifyProviderError(provider, err) {
27143
27494
  if (err instanceof SearchProviderError) return err;
27144
- const message = errorMessage30(err);
27495
+ const message = errorMessage32(err);
27145
27496
  const lower = message.toLowerCase();
27146
27497
  const status = providerErrorStatus(message);
27147
27498
  const openAIStreamError = provider === "openai" && lower.includes("openai api stream error");
@@ -27223,6 +27574,8 @@ async function searchWithResolvedProvider(provider, query, options, useCurrentMo
27223
27574
  if (provider === "ninerouter") return { ...await searchWithNineRouter(query, options), provider };
27224
27575
  if (provider === "cloudflare") return { ...await searchWithCloudflare(query, options), provider };
27225
27576
  if (provider === "searchapi") return { ...await searchWithSearchApi(query, options), provider };
27577
+ if (provider === "outcrawl") return { ...await searchWithOutcrawl(query, options), provider };
27578
+ if (provider === "sofya") return { ...await searchWithSofya(query, options), provider };
27226
27579
  if (provider === "deepseek") return { ...await searchWithDeepSeek(query, options), provider };
27227
27580
  if (provider === "xcrawl") return { ...await searchWithXCrawl(query, options), provider };
27228
27581
  if (provider === "perplexity") return { ...await searchWithPerplexity(query, options), provider };
@@ -27235,7 +27588,7 @@ async function searchWithResolvedProvider(provider, query, options, useCurrentMo
27235
27588
  if (result) return { ...result, provider };
27236
27589
  throw new Error(
27237
27590
  `Gemini search unavailable. Either:
27238
- 1. Configure geminiApiKey in ${CONFIG_PATH44} or set GEMINI_API_KEY
27591
+ 1. Configure geminiApiKey in ${CONFIG_PATH46} or set GEMINI_API_KEY
27239
27592
  2. Set GOOGLE_GEMINI_BASE_URL + CLOUDFLARE_API_KEY for Cloudflare AI Gateway routing
27240
27593
  3. Set geminiAuth to "adc" in web-search.json with a Google Cloud ADC + project/location
27241
27594
  4. Sign into gemini.google.com in a supported Chromium-based browser`
@@ -27280,6 +27633,8 @@ async function isResolvedProviderAvailable(provider, options, useCurrentModel =
27280
27633
  if (provider === "ninerouter") return isNineRouterAvailable();
27281
27634
  if (provider === "cloudflare") return isCloudflareSearchAvailable();
27282
27635
  if (provider === "searchapi") return isSearchApiAvailable();
27636
+ if (provider === "outcrawl") return isOutcrawlAvailable();
27637
+ if (provider === "sofya") return isSofyaAvailable();
27283
27638
  if (provider === "deepseek") return isDeepSeekAvailable();
27284
27639
  if (provider === "xcrawl") return isXcrawlAvailable();
27285
27640
  if (provider === "perplexity") return isPerplexityAvailable();
@@ -27332,6 +27687,8 @@ function providerLabel(provider) {
27332
27687
  if (provider === "ninerouter") return "9router";
27333
27688
  if (provider === "cloudflare") return "Cloudflare";
27334
27689
  if (provider === "searchapi") return "SearchApi";
27690
+ if (provider === "outcrawl") return "Outcrawl";
27691
+ if (provider === "sofya") return "Sofya";
27335
27692
  if (provider === "deepseek") return "DeepSeek";
27336
27693
  return provider.charAt(0).toUpperCase() + provider.slice(1);
27337
27694
  }
@@ -27348,7 +27705,7 @@ async function searchWithProviders(query, options, selectedProviders, routing) {
27348
27705
  available: provider === "gemini" ? isGeminiApiAvailable() : await isResolvedProviderAvailable(provider, options)
27349
27706
  })))).filter((entry) => entry.available).map((entry) => entry.provider);
27350
27707
  if (providers.length === 0) {
27351
- throw new Error('No configured search provider available for provider "all". Parallel MCP, degoog, DuckDuckGo, Kimi, AnySearch, xAI, Mistral, Bright Data, SerpBase, SerpApi, Serper, Serply, You.com, Valyu, Baizhi, Z.ai, XCrawl, Keenable, Ceramic, DeepSeek, Linkup, 9router, Cloudflare, SearchApi, and Tabstack are excluded.');
27708
+ throw new Error('No configured search provider available for provider "all". Parallel MCP, degoog, DuckDuckGo, Kimi, AnySearch, xAI, Mistral, Bright Data, SerpBase, SerpApi, Serper, Serply, You.com, Valyu, Baizhi, Z.ai, XCrawl, Keenable, Ceramic, DeepSeek, Linkup, 9router, Cloudflare, SearchApi, Outcrawl, Sofya, and Tabstack are excluded.');
27352
27709
  }
27353
27710
  const settled = await Promise.allSettled(
27354
27711
  providers.map((provider) => selectedProviders ? searchWithResolvedProvider(provider, query, options) : searchWithAllProvider(provider, query, options))
@@ -27361,7 +27718,7 @@ async function searchWithProviders(query, options, selectedProviders, routing) {
27361
27718
  if (outcome.status === "fulfilled") {
27362
27719
  successes.push(outcome.value);
27363
27720
  } else {
27364
- failures.push({ provider: providers[index], error: errorMessage30(outcome.reason) });
27721
+ failures.push({ provider: providers[index], error: errorMessage32(outcome.reason) });
27365
27722
  }
27366
27723
  }
27367
27724
  if (successes.length === 0) {
@@ -27378,7 +27735,7 @@ async function searchWithProviders(query, options, selectedProviders, routing) {
27378
27735
  } catch (err) {
27379
27736
  if (isAbortError2(err)) throw err;
27380
27737
  throw new Error(`${failureMessage}
27381
- ${errorMessage30(err)}`);
27738
+ ${errorMessage32(err)}`);
27382
27739
  }
27383
27740
  }
27384
27741
  const results = [];
@@ -27478,7 +27835,7 @@ async function searchWithConfiguredRouting(query, callerOptions, routing) {
27478
27835
  break;
27479
27836
  }
27480
27837
  const classified = classifyProviderError(provider, err);
27481
- diagnostics.push(`${provider} [${classified.kind}]: ${errorMessage30(err)}`);
27838
+ diagnostics.push(`${provider} [${classified.kind}]: ${errorMessage32(err)}`);
27482
27839
  if (!routing.fallbackOn.includes(classified.kind)) {
27483
27840
  throw classified;
27484
27841
  }
@@ -27518,7 +27875,7 @@ async function search(query, options = {}) {
27518
27875
  return take(await searchWithResolvedProvider(provider2, query, options), provider2);
27519
27876
  } catch (err) {
27520
27877
  if (isAbortError2(err)) throw err;
27521
- fallbackErrors.push(`${providerLabel(provider2)}: ${errorMessage30(err)}`);
27878
+ fallbackErrors.push(`${providerLabel(provider2)}: ${errorMessage32(err)}`);
27522
27879
  return null;
27523
27880
  }
27524
27881
  };
@@ -27536,7 +27893,7 @@ async function search(query, options = {}) {
27536
27893
  if (response) return response;
27537
27894
  } catch (err) {
27538
27895
  if (err instanceof CredentialResolutionError || isAbortError2(err)) throw err;
27539
- fallbackErrors.push(`Exa: ${errorMessage30(err)}`);
27896
+ fallbackErrors.push(`Exa: ${errorMessage32(err)}`);
27540
27897
  }
27541
27898
  }
27542
27899
  if (allowed.has("openai") && !triedOpenAI) {
@@ -27552,7 +27909,7 @@ async function search(query, options = {}) {
27552
27909
  if (response) return response;
27553
27910
  } catch (err) {
27554
27911
  if (isAbortError2(err)) throw err;
27555
- fallbackErrors.push(`Gemini: ${errorMessage30(err)}`);
27912
+ fallbackErrors.push(`Gemini: ${errorMessage32(err)}`);
27556
27913
  }
27557
27914
  if (firstEmpty) return firstEmpty;
27558
27915
  if (fallbackErrors.length > 0) {
@@ -27562,11 +27919,11 @@ async function search(query, options = {}) {
27562
27919
  throw new Error(
27563
27920
  `No search provider available. Either:
27564
27921
  1. Use /login to sign in with a Codex subscription for OpenAI web search
27565
- 2. Set openaiApiKey, braveApiKey, parallelApiKey, tinyfishApiKey, search1apiApiKey, searchinfinityApiKey, queritApiKey, tavilyApiKey, firecrawlBaseUrl, jinaApiKey, serpdiveApiKey, kagiApiKey, ollamaApiKey, searxngBaseUrl, perplexityApiKey, exaApiKey, geminiApiKey, bochaApiKey, or cloudflareApiKey in ${CONFIG_PATH44}
27922
+ 2. Set openaiApiKey, braveApiKey, parallelApiKey, tinyfishApiKey, search1apiApiKey, searchinfinityApiKey, queritApiKey, tavilyApiKey, firecrawlBaseUrl, jinaApiKey, serpdiveApiKey, kagiApiKey, ollamaApiKey, searxngBaseUrl, perplexityApiKey, exaApiKey, geminiApiKey, bochaApiKey, or cloudflareApiKey in ${CONFIG_PATH46}
27566
27923
  3. Set OPENAI_API_KEY, BRAVE_API_KEY, PARALLEL_API_KEY, TINYFISH_API_KEY, SEARCH1API_KEY, SEARCHINFINITY_API_KEY, QUERIT_API_KEY, TAVILY_API_KEY, FIRECRAWL_BASE_URL, JINA_API_KEY, SERPDIVE_API_KEY, KAGI_API_KEY, BOCHA_API_KEY, OLLAMA_API_KEY, SEARXNG_BASE_URL, EXA_API_KEY, PERPLEXITY_API_KEY, GEMINI_API_KEY, or CLOUDFLARE_API_KEY env vars
27567
27924
  4. Set GOOGLE_GEMINI_BASE_URL with CLOUDFLARE_API_KEY for Cloudflare AI Gateway routing
27568
27925
  5. Sign into gemini.google.com in a supported Chromium-based browser
27569
- 6. Explicitly select provider: "anysearch" for anonymous AnySearch, "xcrawl" for XCrawl, "xai" for Grok, "mistral" for Mistral Conversations web search, "brightdata" with brightdataSerpZone for paid Bright Data SERP, "serpbase", "serpapi", "serper", or "serply" for Google SERP, "you" for You.com, "zai" for Z.ai GLM Coding Plan search, "valyu" for research search, "keenable" for keyless Keenable search, "ceramic" for Ceramic search, "deepseek" for DeepSeek search, "linkup" for Linkup search, "ninerouter" for a 9router gateway, "cloudflare" for the Cloudflare Web Search API, "searchapi" for SearchApi Google search, or "tabstack" for Tabstack Research`
27926
+ 6. Explicitly select provider: "anysearch" for anonymous AnySearch, "xcrawl" for XCrawl, "xai" for Grok, "mistral" for Mistral Conversations web search, "brightdata" with brightdataSerpZone for paid Bright Data SERP, "serpbase", "serpapi", "serper", or "serply" for Google SERP, "you" for You.com, "zai" for Z.ai GLM Coding Plan search, "valyu" for research search, "keenable" for keyless Keenable search, "ceramic" for Ceramic search, "deepseek" for DeepSeek search, "linkup" for Linkup search, "ninerouter" for a 9router gateway, "cloudflare" for the Cloudflare Web Search API, "searchapi" for SearchApi Google search, "outcrawl" for Outcrawl search, "sofya" for Sofya search, or "tabstack" for Tabstack Research`
27570
27927
  );
27571
27928
  }
27572
27929
  async function searchWithGeminiApi(query, options = {}) {
@@ -27727,7 +28084,7 @@ function providerProblem(value) {
27727
28084
  var recencySchema = stringEnum(["day", "week", "month", "year"]);
27728
28085
  var domainFilterSchema = typebox_exports.Array(typebox_exports.String(), { description: "Prefix - to exclude" });
27729
28086
  var numResultsSchema = typebox_exports.Integer({ minimum: 1, maximum: 20, description: "Default 5" });
27730
- var proxySchema = typebox_exports.String({ description: 'http(s) or socks proxy URL; "" forces direct' });
28087
+ var proxySchema = typebox_exports.String({ description: 'Proxy URL; omit by default; "" forces direct' });
27731
28088
  var fetchingAnnotations = { readOnlyHint: false, destructiveHint: false, openWorldHint: true };
27732
28089
  var MCP_TOOL_DEFINITIONS = [
27733
28090
  {
@@ -27851,7 +28208,7 @@ function createMcpServer(core2, info, enabledTools) {
27851
28208
  }
27852
28209
 
27853
28210
  // web-tool-core.ts
27854
- import { existsSync as existsSync60, readFileSync as readFileSync61 } from "node:fs";
28211
+ import { existsSync as existsSync62, readFileSync as readFileSync63 } from "node:fs";
27855
28212
  import pLimit2 from "p-limit";
27856
28213
 
27857
28214
  // fetch-params.ts
@@ -28445,7 +28802,7 @@ function formatPageExtraction(extraction) {
28445
28802
  init_utils();
28446
28803
 
28447
28804
  // storage.ts
28448
- import { closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync as readFileSync49, readdirSync as readdirSync2, renameSync, unlinkSync, writeFileSync } from "node:fs";
28805
+ import { closeSync, constants, fchmodSync, fstatSync, fsyncSync, lstatSync, mkdirSync, openSync, readFileSync as readFileSync51, readdirSync as readdirSync2, renameSync, unlinkSync, writeFileSync } from "node:fs";
28449
28806
  init_utils();
28450
28807
  import { join as join4 } from "node:path";
28451
28808
  var CACHE_TTL_MS = 60 * 60 * 1e3;
@@ -28606,7 +28963,7 @@ function readCachedFetchData(data) {
28606
28963
  const opened = openRegularFile(path);
28607
28964
  fd = opened.fd;
28608
28965
  enforceMode(fd, 384);
28609
- const parsed = JSON.parse(readFileSync49(fd, "utf8"));
28966
+ const parsed = JSON.parse(readFileSync51(fd, "utf8"));
28610
28967
  if (!isValidStoredData(parsed) || parsed.type !== "fetch" || parsed.id !== data.id || !isInlineFetchData(parsed)) {
28611
28968
  return unavailableFetchData(data, "Cached fetched content is invalid");
28612
28969
  }
@@ -28846,9 +29203,9 @@ function parseConfigRoot(raw) {
28846
29203
  }
28847
29204
  return parsed;
28848
29205
  }
28849
- function loadConfig46() {
28850
- if (!existsSync60(WEB_SEARCH_CONFIG_PATH4)) return {};
28851
- return parseConfigRoot(readFileSync61(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
29206
+ function loadConfig48() {
29207
+ if (!existsSync62(WEB_SEARCH_CONFIG_PATH4)) return {};
29208
+ return parseConfigRoot(readFileSync63(WEB_SEARCH_CONFIG_PATH4, "utf-8"));
28852
29209
  }
28853
29210
  var DEFAULT_TOOL_NAMES = {
28854
29211
  webSearch: "web_search",
@@ -28903,7 +29260,7 @@ function resolveRequestedProvider(requested) {
28903
29260
  assertSearchProviderSelectionAllowed(normalizedRequested, "Requested provider");
28904
29261
  return normalizedRequested;
28905
29262
  }
28906
- const config = loadConfig46();
29263
+ const config = loadConfig48();
28907
29264
  const provider = normalizeProviderInput(config.searchProvider ?? config.provider, `provider in ${WEB_SEARCH_CONFIG_PATH4}`) ?? "auto";
28908
29265
  assertSearchProviderSelectionAllowed(provider, `configured provider in ${WEB_SEARCH_CONFIG_PATH4}`);
28909
29266
  return provider;
@@ -28966,7 +29323,7 @@ function isAbortError6(err) {
28966
29323
  var DEFAULT_MAX_INLINE_CONTENT_CHARS = 3e4;
28967
29324
  var MIN_INLINE_CONTENT_CHARS = 1e3;
28968
29325
  var MAX_INLINE_CONTENT_CHARS = 2e5;
28969
- function getMaxInlineContentChars(config = loadConfig46()) {
29326
+ function getMaxInlineContentChars(config = loadConfig48()) {
28970
29327
  const value = config.maxInlineContentChars;
28971
29328
  if (typeof value !== "number" || !Number.isFinite(value) || !Number.isInteger(value) || value < MIN_INLINE_CONTENT_CHARS) {
28972
29329
  return DEFAULT_MAX_INLINE_CONTENT_CHARS;
@@ -30080,7 +30437,7 @@ function standaloneFetchRejection(params, fetchModes) {
30080
30437
  return void 0;
30081
30438
  }
30082
30439
  function createStandaloneWebToolCore() {
30083
- const config = loadConfig46();
30440
+ const config = loadConfig48();
30084
30441
  const settings2 = {
30085
30442
  toolNames: { ...DEFAULT_TOOL_NAMES },
30086
30443
  enabledTools: {