@probelabs/probe 0.6.0-rc330 → 0.6.0-rc331

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/build/extract.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { exec, spawn } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath, buildCliArgs, escapeString } from './utils.js';
8
+ import { getBinaryPath, buildCliArgs, escapeString, getCleanEnv } from './utils.js';
9
9
  import { validateCwdPath } from './utils/path-validation.js';
10
10
 
11
11
  const execAsync = promisify(exec);
@@ -104,7 +104,7 @@ export async function extract(options) {
104
104
  const command = `${binaryPath} extract ${cliArgs.join(' ')}`;
105
105
 
106
106
  try {
107
- const { stdout, stderr } = await execAsync(command, { cwd });
107
+ const { stdout, stderr } = await execAsync(command, { cwd, env: getCleanEnv() });
108
108
 
109
109
  if (stderr) {
110
110
  console.error(`stderr: ${stderr}`);
@@ -126,7 +126,8 @@ function extractWithStdin(binaryPath, cliArgs, content, options, cwd) {
126
126
  return new Promise((resolve, reject) => {
127
127
  const childProcess = spawn(binaryPath, ['extract', ...cliArgs], {
128
128
  stdio: ['pipe', 'pipe', 'pipe'],
129
- cwd
129
+ cwd,
130
+ env: getCleanEnv()
130
131
  });
131
132
 
132
133
  let stdout = '';
package/build/grep.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { execFile } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath } from './utils.js';
8
+ import { getBinaryPath, getCleanEnv } from './utils.js';
9
9
 
10
10
  const execFileAsync = promisify(execFile);
11
11
 
@@ -131,7 +131,7 @@ export async function grep(options) {
131
131
  const { stdout, stderr } = await execFileAsync(binaryPath, cliArgs, {
132
132
  maxBuffer: 10 * 1024 * 1024, // 10MB buffer
133
133
  env: {
134
- ...process.env,
134
+ ...getCleanEnv(),
135
135
  // Disable colors in stderr for cleaner output
136
136
  NO_COLOR: '1'
137
137
  }
package/build/query.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { exec } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath, buildCliArgs, escapeString } from './utils.js';
8
+ import { getBinaryPath, buildCliArgs, escapeString, getCleanEnv } from './utils.js';
9
9
  import { validateCwdPath } from './utils/path-validation.js';
10
10
 
11
11
  const execAsync = promisify(exec);
@@ -84,7 +84,7 @@ export async function query(options) {
84
84
  const command = `${binaryPath} query ${cliArgs.join(' ')}`;
85
85
 
86
86
  try {
87
- const { stdout, stderr } = await execAsync(command, { cwd });
87
+ const { stdout, stderr } = await execAsync(command, { cwd, env: getCleanEnv() });
88
88
 
89
89
  if (stderr) {
90
90
  console.error(`stderr: ${stderr}`);
package/build/search.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { execFile } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath, buildCliArgs } from './utils.js';
8
+ import { getBinaryPath, buildCliArgs, getCleanEnv } from './utils.js';
9
9
  import { validateCwdPath } from './utils/path-validation.js';
10
10
  import { TimeoutError, categorizeError } from './utils/error-types.js';
11
11
 
@@ -164,6 +164,7 @@ export async function search(options) {
164
164
  // Execute with execFile (no shell, prevents command injection)
165
165
  const { stdout, stderr } = await execFileAsync(binaryPath, args, {
166
166
  cwd,
167
+ env: getCleanEnv(),
167
168
  timeout: options.timeout * 1000, // Convert seconds to milliseconds
168
169
  maxBuffer: 50 * 1024 * 1024 // 50MB buffer for large outputs
169
170
  });
package/build/symbols.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { spawn } from 'child_process';
7
- import { getBinaryPath, escapeString } from './utils.js';
7
+ import { getBinaryPath, escapeString, getCleanEnv } from './utils.js';
8
8
  import { validateCwdPath } from './utils/path-validation.js';
9
9
 
10
10
  /**
@@ -47,7 +47,8 @@ export async function symbols(options) {
47
47
  return new Promise((resolve, reject) => {
48
48
  const childProcess = spawn(binaryPath, args, {
49
49
  stdio: ['pipe', 'pipe', 'pipe'],
50
- cwd
50
+ cwd,
51
+ env: getCleanEnv()
51
52
  });
52
53
 
53
54
  let stdout = '';
package/build/utils.js CHANGED
@@ -122,6 +122,29 @@ export function buildCliArgs(options, flagMap) {
122
122
  return cliArgs;
123
123
  }
124
124
 
125
+ /**
126
+ * Build a minimal environment for spawning the probe binary.
127
+ * Prevents E2BIG when the host process accumulates a large process.env.
128
+ * @returns {Record<string, string>} - Clean environment with only essential vars
129
+ */
130
+ export function getCleanEnv() {
131
+ const keep = [
132
+ 'PATH', 'HOME', 'USER', 'SHELL', 'TERM', 'LANG', 'LC_ALL',
133
+ 'TMPDIR', 'TMP', 'TEMP',
134
+ 'SystemRoot', 'SYSTEMROOT', 'COMSPEC', // Windows
135
+ 'PROBE_PATH', 'PROBE_CONFIG_DIR', 'DEBUG',
136
+ 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY',
137
+ 'http_proxy', 'https_proxy', 'no_proxy',
138
+ ];
139
+ const env = {};
140
+ for (const key of keep) {
141
+ if (process.env[key] !== undefined) {
142
+ env[key] = process.env[key];
143
+ }
144
+ }
145
+ return env;
146
+ }
147
+
125
148
  /**
126
149
  * Escape a string for use in a command line
127
150
  * @param {string} str - String to escape
@@ -16503,6 +16503,7 @@ async function readResponseWithSizeLimit({
16503
16503
  } finally {
16504
16504
  try {
16505
16505
  await reader.cancel();
16506
+ } catch (e) {
16506
16507
  } finally {
16507
16508
  reader.releaseLock();
16508
16509
  }
@@ -17839,7 +17840,7 @@ var init_dist2 = __esm({
17839
17840
  "ETIMEDOUT",
17840
17841
  "EPIPE"
17841
17842
  ];
17842
- VERSION = true ? "4.0.41" : "0.0.0-test";
17843
+ VERSION = true ? "4.0.45" : "0.0.0-test";
17843
17844
  DEFAULT_SCHEMA_PREFIX = "JSON schema:";
17844
17845
  DEFAULT_SCHEMA_SUFFIX = "You MUST answer with a JSON object that matches the JSON schema above.";
17845
17846
  DEFAULT_GENERIC_SUFFIX = "You MUST answer with JSON.";
@@ -25286,7 +25287,7 @@ var init_dist3 = __esm({
25286
25287
  details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
25287
25288
  preview: external_exports.unknown().optional()
25288
25289
  });
25289
- VERSION2 = true ? "4.0.145" : "0.0.0-test";
25290
+ VERSION2 = true ? "4.0.153" : "0.0.0-test";
25290
25291
  bedrockRerankingResponseSchema = lazySchema(
25291
25292
  () => zodSchema(
25292
25293
  external_exports.object({
@@ -29113,6 +29114,40 @@ function buildCliArgs(options, flagMap) {
29113
29114
  }
29114
29115
  return cliArgs;
29115
29116
  }
29117
+ function getCleanEnv() {
29118
+ const keep = [
29119
+ "PATH",
29120
+ "HOME",
29121
+ "USER",
29122
+ "SHELL",
29123
+ "TERM",
29124
+ "LANG",
29125
+ "LC_ALL",
29126
+ "TMPDIR",
29127
+ "TMP",
29128
+ "TEMP",
29129
+ "SystemRoot",
29130
+ "SYSTEMROOT",
29131
+ "COMSPEC",
29132
+ // Windows
29133
+ "PROBE_PATH",
29134
+ "PROBE_CONFIG_DIR",
29135
+ "DEBUG",
29136
+ "HTTP_PROXY",
29137
+ "HTTPS_PROXY",
29138
+ "NO_PROXY",
29139
+ "http_proxy",
29140
+ "https_proxy",
29141
+ "no_proxy"
29142
+ ];
29143
+ const env = {};
29144
+ for (const key of keep) {
29145
+ if (process.env[key] !== void 0) {
29146
+ env[key] = process.env[key];
29147
+ }
29148
+ }
29149
+ return env;
29150
+ }
29116
29151
  function escapeString(str) {
29117
29152
  if (process.platform === "win32") {
29118
29153
  return `"${str.replace(/"/g, '\\"')}"`;
@@ -29547,6 +29582,7 @@ Search: query="${queries[0]}" path="${options.path}"`;
29547
29582
  try {
29548
29583
  const { stdout, stderr } = await execFileAsync(binaryPath, args, {
29549
29584
  cwd,
29585
+ env: getCleanEnv(),
29550
29586
  timeout: options.timeout * 1e3,
29551
29587
  // Convert seconds to milliseconds
29552
29588
  maxBuffer: 50 * 1024 * 1024
@@ -29677,7 +29713,7 @@ async function query(options) {
29677
29713
  }
29678
29714
  const command = `${binaryPath} query ${cliArgs.join(" ")}`;
29679
29715
  try {
29680
- const { stdout, stderr } = await execAsync(command, { cwd });
29716
+ const { stdout, stderr } = await execAsync(command, { cwd, env: getCleanEnv() });
29681
29717
  if (stderr) {
29682
29718
  console.error(`stderr: ${stderr}`);
29683
29719
  }
@@ -29771,7 +29807,7 @@ Extract:`;
29771
29807
  }
29772
29808
  const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
29773
29809
  try {
29774
- const { stdout, stderr } = await execAsync2(command, { cwd });
29810
+ const { stdout, stderr } = await execAsync2(command, { cwd, env: getCleanEnv() });
29775
29811
  if (stderr) {
29776
29812
  console.error(`stderr: ${stderr}`);
29777
29813
  }
@@ -29787,7 +29823,8 @@ function extractWithStdin(binaryPath, cliArgs, content, options, cwd) {
29787
29823
  return new Promise((resolve9, reject2) => {
29788
29824
  const childProcess = (0, import_child_process4.spawn)(binaryPath, ["extract", ...cliArgs], {
29789
29825
  stdio: ["pipe", "pipe", "pipe"],
29790
- cwd
29826
+ cwd,
29827
+ env: getCleanEnv()
29791
29828
  });
29792
29829
  let stdout = "";
29793
29830
  let stderr = "";
@@ -29914,7 +29951,8 @@ Symbols: files="${options.files.join(", ")}" cwd="${cwd}"`);
29914
29951
  return new Promise((resolve9, reject2) => {
29915
29952
  const childProcess = (0, import_child_process5.spawn)(binaryPath, args, {
29916
29953
  stdio: ["pipe", "pipe", "pipe"],
29917
- cwd
29954
+ cwd,
29955
+ env: getCleanEnv()
29918
29956
  });
29919
29957
  let stdout = "";
29920
29958
  let stderr = "";
@@ -89053,7 +89091,12 @@ var require_fast_uri = __commonJS({
89053
89091
  }
89054
89092
  function resolve9(baseURI, relativeURI, options) {
89055
89093
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
89056
- const resolved = resolveComponent(parse11(baseURI, schemelessOptions), parse11(relativeURI, schemelessOptions), schemelessOptions, true);
89094
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
89095
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
89096
+ if (baseMalformed || relativeMalformed) {
89097
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
89098
+ }
89099
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
89057
89100
  schemelessOptions.skipEscape = true;
89058
89101
  return serialize(resolved, schemelessOptions);
89059
89102
  }
@@ -89179,6 +89222,7 @@ var require_fast_uri = __commonJS({
89179
89222
  }
89180
89223
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
89181
89224
  var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
89225
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
89182
89226
  function getParseError(parsed, matches) {
89183
89227
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
89184
89228
  return 'URI path must start with "/" when authority is present.';
@@ -89213,6 +89257,20 @@ var require_fast_uri = __commonJS({
89213
89257
  parsed.error = "URI authority must not contain a literal backslash.";
89214
89258
  malformedAuthorityOrPort = true;
89215
89259
  }
89260
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
89261
+ if (introducerMatch !== null) {
89262
+ const region = introducerMatch[1];
89263
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
89264
+ if (normalizedRegion.length >= 2) {
89265
+ if (normalizedRegion.slice(0, 2) !== "//") {
89266
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
89267
+ malformedAuthorityOrPort = true;
89268
+ } else if (region.length !== normalizedRegion.length) {
89269
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
89270
+ malformedAuthorityOrPort = true;
89271
+ }
89272
+ }
89273
+ }
89216
89274
  const matches = uri.match(URI_PARSE);
89217
89275
  if (matches) {
89218
89276
  parsed.scheme = matches[1];
package/cjs/index.cjs CHANGED
@@ -1411,6 +1411,40 @@ function buildCliArgs(options, flagMap) {
1411
1411
  }
1412
1412
  return cliArgs;
1413
1413
  }
1414
+ function getCleanEnv() {
1415
+ const keep = [
1416
+ "PATH",
1417
+ "HOME",
1418
+ "USER",
1419
+ "SHELL",
1420
+ "TERM",
1421
+ "LANG",
1422
+ "LC_ALL",
1423
+ "TMPDIR",
1424
+ "TMP",
1425
+ "TEMP",
1426
+ "SystemRoot",
1427
+ "SYSTEMROOT",
1428
+ "COMSPEC",
1429
+ // Windows
1430
+ "PROBE_PATH",
1431
+ "PROBE_CONFIG_DIR",
1432
+ "DEBUG",
1433
+ "HTTP_PROXY",
1434
+ "HTTPS_PROXY",
1435
+ "NO_PROXY",
1436
+ "http_proxy",
1437
+ "https_proxy",
1438
+ "no_proxy"
1439
+ ];
1440
+ const env = {};
1441
+ for (const key of keep) {
1442
+ if (process.env[key] !== void 0) {
1443
+ env[key] = process.env[key];
1444
+ }
1445
+ }
1446
+ return env;
1447
+ }
1414
1448
  function escapeString(str) {
1415
1449
  if (process.platform === "win32") {
1416
1450
  return `"${str.replace(/"/g, '\\"')}"`;
@@ -1845,6 +1879,7 @@ Search: query="${queries[0]}" path="${options.path}"`;
1845
1879
  try {
1846
1880
  const { stdout, stderr } = await execFileAsync(binaryPath, args, {
1847
1881
  cwd,
1882
+ env: getCleanEnv(),
1848
1883
  timeout: options.timeout * 1e3,
1849
1884
  // Convert seconds to milliseconds
1850
1885
  maxBuffer: 50 * 1024 * 1024
@@ -1975,7 +2010,7 @@ async function query(options) {
1975
2010
  }
1976
2011
  const command = `${binaryPath} query ${cliArgs.join(" ")}`;
1977
2012
  try {
1978
- const { stdout, stderr } = await execAsync(command, { cwd });
2013
+ const { stdout, stderr } = await execAsync(command, { cwd, env: getCleanEnv() });
1979
2014
  if (stderr) {
1980
2015
  console.error(`stderr: ${stderr}`);
1981
2016
  }
@@ -2069,7 +2104,7 @@ Extract:`;
2069
2104
  }
2070
2105
  const command = `${binaryPath} extract ${cliArgs.join(" ")}`;
2071
2106
  try {
2072
- const { stdout, stderr } = await execAsync2(command, { cwd });
2107
+ const { stdout, stderr } = await execAsync2(command, { cwd, env: getCleanEnv() });
2073
2108
  if (stderr) {
2074
2109
  console.error(`stderr: ${stderr}`);
2075
2110
  }
@@ -2085,7 +2120,8 @@ function extractWithStdin(binaryPath, cliArgs, content, options, cwd) {
2085
2120
  return new Promise((resolve9, reject2) => {
2086
2121
  const childProcess = (0, import_child_process4.spawn)(binaryPath, ["extract", ...cliArgs], {
2087
2122
  stdio: ["pipe", "pipe", "pipe"],
2088
- cwd
2123
+ cwd,
2124
+ env: getCleanEnv()
2089
2125
  });
2090
2126
  let stdout = "";
2091
2127
  let stderr = "";
@@ -2212,7 +2248,8 @@ Symbols: files="${options.files.join(", ")}" cwd="${cwd}"`);
2212
2248
  return new Promise((resolve9, reject2) => {
2213
2249
  const childProcess = (0, import_child_process5.spawn)(binaryPath, args, {
2214
2250
  stdio: ["pipe", "pipe", "pipe"],
2215
- cwd
2251
+ cwd,
2252
+ env: getCleanEnv()
2216
2253
  });
2217
2254
  let stdout = "";
2218
2255
  let stderr = "";
@@ -2281,7 +2318,7 @@ async function grep(options) {
2281
2318
  maxBuffer: 10 * 1024 * 1024,
2282
2319
  // 10MB buffer
2283
2320
  env: {
2284
- ...process.env,
2321
+ ...getCleanEnv(),
2285
2322
  // Disable colors in stderr for cleaner output
2286
2323
  NO_COLOR: "1"
2287
2324
  }
@@ -18432,6 +18469,7 @@ async function readResponseWithSizeLimit({
18432
18469
  } finally {
18433
18470
  try {
18434
18471
  await reader.cancel();
18472
+ } catch (e) {
18435
18473
  } finally {
18436
18474
  reader.releaseLock();
18437
18475
  }
@@ -19768,7 +19806,7 @@ var init_dist2 = __esm({
19768
19806
  "ETIMEDOUT",
19769
19807
  "EPIPE"
19770
19808
  ];
19771
- VERSION = true ? "4.0.41" : "0.0.0-test";
19809
+ VERSION = true ? "4.0.45" : "0.0.0-test";
19772
19810
  DEFAULT_SCHEMA_PREFIX = "JSON schema:";
19773
19811
  DEFAULT_SCHEMA_SUFFIX = "You MUST answer with a JSON object that matches the JSON schema above.";
19774
19812
  DEFAULT_GENERIC_SUFFIX = "You MUST answer with JSON.";
@@ -27215,7 +27253,7 @@ var init_dist3 = __esm({
27215
27253
  details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
27216
27254
  preview: external_exports.unknown().optional()
27217
27255
  });
27218
- VERSION2 = true ? "4.0.145" : "0.0.0-test";
27256
+ VERSION2 = true ? "4.0.153" : "0.0.0-test";
27219
27257
  bedrockRerankingResponseSchema = lazySchema(
27220
27258
  () => zodSchema(
27221
27259
  external_exports.object({
@@ -73127,7 +73165,12 @@ var require_fast_uri = __commonJS({
73127
73165
  }
73128
73166
  function resolve9(baseURI, relativeURI, options) {
73129
73167
  const schemelessOptions = options ? Object.assign({ scheme: "null" }, options) : { scheme: "null" };
73130
- const resolved = resolveComponent(parse11(baseURI, schemelessOptions), parse11(relativeURI, schemelessOptions), schemelessOptions, true);
73168
+ const { parsed: baseParsed, malformedAuthorityOrPort: baseMalformed } = parseWithStatus(baseURI, schemelessOptions);
73169
+ const { parsed: relativeParsed, malformedAuthorityOrPort: relativeMalformed } = parseWithStatus(relativeURI, schemelessOptions);
73170
+ if (baseMalformed || relativeMalformed) {
73171
+ throw new Error(baseParsed.error || relativeParsed.error || "URI is malformed.");
73172
+ }
73173
+ const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
73131
73174
  schemelessOptions.skipEscape = true;
73132
73175
  return serialize(resolved, schemelessOptions);
73133
73176
  }
@@ -73253,6 +73296,7 @@ var require_fast_uri = __commonJS({
73253
73296
  }
73254
73297
  var URI_PARSE = /^(?:([^#/:?]+):)?(?:\/\/((?:([^#/?@]*)@)?(\[[^#/?\]]+\]|[^#/:?]*)(?::(\d*))?))?([^#?]*)(?:\?([^#]*))?(?:#((?:.|[\n\r])*))?/u;
73255
73298
  var AUTHORITY_PREFIX = /^(?:[^#/:?]+:)?\/\/([^/?#]*)/;
73299
+ var AUTHORITY_INTRODUCER_REGION = /^(?:[^#/:?]+:)?([/\\\t\n\r]*)/;
73256
73300
  function getParseError(parsed, matches) {
73257
73301
  if (matches[2] !== void 0 && parsed.path && parsed.path[0] !== "/") {
73258
73302
  return 'URI path must start with "/" when authority is present.';
@@ -73287,6 +73331,20 @@ var require_fast_uri = __commonJS({
73287
73331
  parsed.error = "URI authority must not contain a literal backslash.";
73288
73332
  malformedAuthorityOrPort = true;
73289
73333
  }
73334
+ const introducerMatch = uri.match(AUTHORITY_INTRODUCER_REGION);
73335
+ if (introducerMatch !== null) {
73336
+ const region = introducerMatch[1];
73337
+ const normalizedRegion = region.replace(/[\t\n\r]/g, "");
73338
+ if (normalizedRegion.length >= 2) {
73339
+ if (normalizedRegion.slice(0, 2) !== "//") {
73340
+ parsed.error = parsed.error || "URI authority must not contain a literal backslash.";
73341
+ malformedAuthorityOrPort = true;
73342
+ } else if (region.length !== normalizedRegion.length) {
73343
+ parsed.error = parsed.error || "URI authority introducer must not contain whitespace.";
73344
+ malformedAuthorityOrPort = true;
73345
+ }
73346
+ }
73347
+ }
73290
73348
  const matches = uri.match(URI_PARSE);
73291
73349
  if (matches) {
73292
73350
  parsed.scheme = matches[1];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@probelabs/probe",
3
- "version": "0.6.0-rc330",
3
+ "version": "0.6.0-rc331",
4
4
  "description": "Node.js wrapper for the probe code search tool",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
package/src/extract.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { exec, spawn } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath, buildCliArgs, escapeString } from './utils.js';
8
+ import { getBinaryPath, buildCliArgs, escapeString, getCleanEnv } from './utils.js';
9
9
  import { validateCwdPath } from './utils/path-validation.js';
10
10
 
11
11
  const execAsync = promisify(exec);
@@ -104,7 +104,7 @@ export async function extract(options) {
104
104
  const command = `${binaryPath} extract ${cliArgs.join(' ')}`;
105
105
 
106
106
  try {
107
- const { stdout, stderr } = await execAsync(command, { cwd });
107
+ const { stdout, stderr } = await execAsync(command, { cwd, env: getCleanEnv() });
108
108
 
109
109
  if (stderr) {
110
110
  console.error(`stderr: ${stderr}`);
@@ -126,7 +126,8 @@ function extractWithStdin(binaryPath, cliArgs, content, options, cwd) {
126
126
  return new Promise((resolve, reject) => {
127
127
  const childProcess = spawn(binaryPath, ['extract', ...cliArgs], {
128
128
  stdio: ['pipe', 'pipe', 'pipe'],
129
- cwd
129
+ cwd,
130
+ env: getCleanEnv()
130
131
  });
131
132
 
132
133
  let stdout = '';
package/src/grep.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { execFile } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath } from './utils.js';
8
+ import { getBinaryPath, getCleanEnv } from './utils.js';
9
9
 
10
10
  const execFileAsync = promisify(execFile);
11
11
 
@@ -131,7 +131,7 @@ export async function grep(options) {
131
131
  const { stdout, stderr } = await execFileAsync(binaryPath, cliArgs, {
132
132
  maxBuffer: 10 * 1024 * 1024, // 10MB buffer
133
133
  env: {
134
- ...process.env,
134
+ ...getCleanEnv(),
135
135
  // Disable colors in stderr for cleaner output
136
136
  NO_COLOR: '1'
137
137
  }
package/src/query.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { exec } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath, buildCliArgs, escapeString } from './utils.js';
8
+ import { getBinaryPath, buildCliArgs, escapeString, getCleanEnv } from './utils.js';
9
9
  import { validateCwdPath } from './utils/path-validation.js';
10
10
 
11
11
  const execAsync = promisify(exec);
@@ -84,7 +84,7 @@ export async function query(options) {
84
84
  const command = `${binaryPath} query ${cliArgs.join(' ')}`;
85
85
 
86
86
  try {
87
- const { stdout, stderr } = await execAsync(command, { cwd });
87
+ const { stdout, stderr } = await execAsync(command, { cwd, env: getCleanEnv() });
88
88
 
89
89
  if (stderr) {
90
90
  console.error(`stderr: ${stderr}`);
package/src/search.js CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  import { execFile } from 'child_process';
7
7
  import { promisify } from 'util';
8
- import { getBinaryPath, buildCliArgs } from './utils.js';
8
+ import { getBinaryPath, buildCliArgs, getCleanEnv } from './utils.js';
9
9
  import { validateCwdPath } from './utils/path-validation.js';
10
10
  import { TimeoutError, categorizeError } from './utils/error-types.js';
11
11
 
@@ -164,6 +164,7 @@ export async function search(options) {
164
164
  // Execute with execFile (no shell, prevents command injection)
165
165
  const { stdout, stderr } = await execFileAsync(binaryPath, args, {
166
166
  cwd,
167
+ env: getCleanEnv(),
167
168
  timeout: options.timeout * 1000, // Convert seconds to milliseconds
168
169
  maxBuffer: 50 * 1024 * 1024 // 50MB buffer for large outputs
169
170
  });
package/src/symbols.js CHANGED
@@ -4,7 +4,7 @@
4
4
  */
5
5
 
6
6
  import { spawn } from 'child_process';
7
- import { getBinaryPath, escapeString } from './utils.js';
7
+ import { getBinaryPath, escapeString, getCleanEnv } from './utils.js';
8
8
  import { validateCwdPath } from './utils/path-validation.js';
9
9
 
10
10
  /**
@@ -47,7 +47,8 @@ export async function symbols(options) {
47
47
  return new Promise((resolve, reject) => {
48
48
  const childProcess = spawn(binaryPath, args, {
49
49
  stdio: ['pipe', 'pipe', 'pipe'],
50
- cwd
50
+ cwd,
51
+ env: getCleanEnv()
51
52
  });
52
53
 
53
54
  let stdout = '';
package/src/utils.js CHANGED
@@ -122,6 +122,29 @@ export function buildCliArgs(options, flagMap) {
122
122
  return cliArgs;
123
123
  }
124
124
 
125
+ /**
126
+ * Build a minimal environment for spawning the probe binary.
127
+ * Prevents E2BIG when the host process accumulates a large process.env.
128
+ * @returns {Record<string, string>} - Clean environment with only essential vars
129
+ */
130
+ export function getCleanEnv() {
131
+ const keep = [
132
+ 'PATH', 'HOME', 'USER', 'SHELL', 'TERM', 'LANG', 'LC_ALL',
133
+ 'TMPDIR', 'TMP', 'TEMP',
134
+ 'SystemRoot', 'SYSTEMROOT', 'COMSPEC', // Windows
135
+ 'PROBE_PATH', 'PROBE_CONFIG_DIR', 'DEBUG',
136
+ 'HTTP_PROXY', 'HTTPS_PROXY', 'NO_PROXY',
137
+ 'http_proxy', 'https_proxy', 'no_proxy',
138
+ ];
139
+ const env = {};
140
+ for (const key of keep) {
141
+ if (process.env[key] !== undefined) {
142
+ env[key] = process.env[key];
143
+ }
144
+ }
145
+ return env;
146
+ }
147
+
125
148
  /**
126
149
  * Escape a string for use in a command line
127
150
  * @param {string} str - String to escape