@probelabs/probe 0.6.0-rc221 → 0.6.0-rc223

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.
@@ -287,6 +287,18 @@ export class ACPToolManager {
287
287
  allow_tests: {
288
288
  type: 'boolean',
289
289
  description: 'Include test files in results (default: true)'
290
+ },
291
+ exact: {
292
+ type: 'boolean',
293
+ description: 'Default (false) enables stemming and keyword splitting for exploratory search. Set true for precise symbol lookup where the query matches only the exact term. Use true when you know the exact symbol name.'
294
+ },
295
+ session: {
296
+ type: 'string',
297
+ description: 'Session ID for result caching and pagination. Pass the session ID from a previous search to get additional results (next page). Results already shown in a session are automatically excluded.'
298
+ },
299
+ nextPage: {
300
+ type: 'boolean',
301
+ description: 'Set to true when requesting the next page of results. Requires passing the same session ID from the previous search output.'
290
302
  }
291
303
  },
292
304
  required: ['query']
@@ -3748,7 +3748,7 @@ var init_grep = __esm({
3748
3748
  import { randomUUID } from "crypto";
3749
3749
  async function delegate({
3750
3750
  task,
3751
- timeout = 300,
3751
+ timeout = DEFAULT_DELEGATE_TIMEOUT,
3752
3752
  debug = false,
3753
3753
  currentIteration = 0,
3754
3754
  maxIterations = 30,
@@ -3926,7 +3926,7 @@ async function delegate({
3926
3926
  throw new Error(`Delegation failed: ${error.message}`);
3927
3927
  }
3928
3928
  }
3929
- var DelegationManager, defaultDelegationManager;
3929
+ var DelegationManager, defaultDelegationManager, DEFAULT_DELEGATE_TIMEOUT;
3930
3930
  var init_delegate = __esm({
3931
3931
  "src/delegate.js"() {
3932
3932
  "use strict";
@@ -4063,9 +4063,12 @@ var init_delegate = __esm({
4063
4063
  }
4064
4064
  /**
4065
4065
  * Process the wait queue - grant slot to next waiting delegation
4066
+ * Uses setImmediate to avoid blocking the event loop when resolving promises.
4066
4067
  * @private
4067
4068
  */
4068
4069
  _processQueue(debug = false) {
4070
+ const toResolve = [];
4071
+ const toReject = [];
4069
4072
  while (this.waitQueue.length > 0 && this.globalActive < this.maxConcurrent) {
4070
4073
  const next = this.waitQueue.shift();
4071
4074
  if (!next) break;
@@ -4077,7 +4080,7 @@ var init_delegate = __esm({
4077
4080
  if (debug) {
4078
4081
  console.error(`[DelegationManager] Session limit (${this.maxPerSession}) reached for queued item, rejecting`);
4079
4082
  }
4080
- reject2(new Error(`Maximum delegations per session (${this.maxPerSession}) reached for session ${parentSessionId}`));
4083
+ toReject.push({ reject: reject2, error: new Error(`Maximum delegations per session (${this.maxPerSession}) reached for session ${parentSessionId}`) });
4081
4084
  continue;
4082
4085
  }
4083
4086
  }
@@ -4086,7 +4089,17 @@ var init_delegate = __esm({
4086
4089
  const waitTime = Date.now() - queuedAt;
4087
4090
  console.error(`[DelegationManager] Granted slot from queue (waited ${waitTime}ms). Active: ${this.globalActive}/${this.maxConcurrent}`);
4088
4091
  }
4089
- resolve8(true);
4092
+ toResolve.push(resolve8);
4093
+ }
4094
+ if (toResolve.length > 0 || toReject.length > 0) {
4095
+ setImmediate(() => {
4096
+ for (const resolve8 of toResolve) {
4097
+ resolve8(true);
4098
+ }
4099
+ for (const { reject: reject2, error } of toReject) {
4100
+ reject2(error);
4101
+ }
4102
+ });
4090
4103
  }
4091
4104
  }
4092
4105
  /**
@@ -4135,6 +4148,7 @@ var init_delegate = __esm({
4135
4148
  }
4136
4149
  };
4137
4150
  defaultDelegationManager = new DelegationManager();
4151
+ DEFAULT_DELEGATE_TIMEOUT = parseInt(process.env.DELEGATE_TIMEOUT, 10) || 300;
4138
4152
  }
4139
4153
  });
4140
4154
 
@@ -9715,7 +9729,10 @@ var init_common = __esm({
9715
9729
  init_taskTool();
9716
9730
  searchSchema = external_exports.object({
9717
9731
  query: external_exports.string().describe("Search query with Elasticsearch syntax. Use quotes for exact matches, AND/OR for boolean logic, - for negation."),
9718
- path: external_exports.string().optional().default(".").describe('Path to search in. For dependencies use "go:github.com/owner/repo", "js:package_name", or "rust:cargo_name" etc.')
9732
+ path: external_exports.string().optional().default(".").describe('Path to search in. For dependencies use "go:github.com/owner/repo", "js:package_name", or "rust:cargo_name" etc.'),
9733
+ exact: external_exports.boolean().optional().default(false).describe('Default (false) enables stemming and keyword splitting for exploratory search - "getUserData" matches "get", "user", "data", etc. Set true for precise symbol lookup where "getUserData" matches only "getUserData". Use true when you know the exact symbol name.'),
9734
+ session: external_exports.string().optional().describe("Session ID for result caching and pagination. Pass the session ID from a previous search to get additional results (next page). Results already shown in a session are automatically excluded. Omit for a fresh search."),
9735
+ nextPage: external_exports.boolean().optional().default(false).describe("Set to true when requesting the next page of results. Requires passing the same session ID from the previous search output.")
9719
9736
  });
9720
9737
  querySchema = external_exports.object({
9721
9738
  pattern: external_exports.string().describe("AST pattern to search for. Use $NAME for variable names, $$$PARAMS for parameter lists, etc."),
@@ -9814,6 +9831,9 @@ You need to focus on main keywords when constructing the query, and always use e
9814
9831
  Parameters:
9815
9832
  - query: (required) Search query. Free-form questions are accepted, but for best results prefer Elasticsearch-style syntax with quotes for exact matches ("functionName"), AND/OR for boolean logic, - for negation, + for important terms.
9816
9833
  - path: (optional, default: '.') Path to search in. All dependencies located in /dep folder, under language sub folders, like this: "/dep/go/github.com/owner/repo", "/dep/js/package_name", or "/dep/rust/cargo_name" etc.
9834
+ - exact: (optional, default: false) Set to true for precise symbol lookup without stemming/tokenization. Use when you know the exact symbol name (e.g., "getUserData" matches only "getUserData", not "get", "user", "data").
9835
+ - session: (optional) Session ID for pagination. Pass the session ID returned from a previous search to get the next page of results. Results already shown are automatically excluded.
9836
+ - nextPage: (optional, default: false) Set to true when requesting the next page of results. Requires passing the same session ID from the previous search.
9817
9837
 
9818
9838
  **Workflow:** Always start with search, then use extract for detailed context when needed.
9819
9839
 
@@ -10220,7 +10240,7 @@ var init_vercel = __esm({
10220
10240
  name: "search",
10221
10241
  description: searchDelegate ? `${searchDescription} (delegates code search to a subagent and returns extracted code blocks)` : searchDescription,
10222
10242
  inputSchema: searchSchema,
10223
- execute: async ({ query: searchQuery, path: path9, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
10243
+ execute: async ({ query: searchQuery, path: path9, allow_tests, exact, maxTokens: paramMaxTokens, language, session, nextPage }) => {
10224
10244
  const effectiveMaxTokens = paramMaxTokens || maxTokens;
10225
10245
  let searchPaths;
10226
10246
  if (path9) {
@@ -10239,8 +10259,10 @@ var init_vercel = __esm({
10239
10259
  exact,
10240
10260
  json: false,
10241
10261
  maxTokens: effectiveMaxTokens,
10242
- session: sessionId,
10243
- // Pass session ID if provided
10262
+ session: session || sessionId,
10263
+ // Use explicit session param, or fall back to options sessionId
10264
+ nextPage,
10265
+ // Pass nextPage parameter for pagination
10244
10266
  language
10245
10267
  // Pass language parameter if provided
10246
10268
  };
package/build/delegate.js CHANGED
@@ -194,9 +194,14 @@ class DelegationManager {
194
194
 
195
195
  /**
196
196
  * Process the wait queue - grant slot to next waiting delegation
197
+ * Uses setImmediate to avoid blocking the event loop when resolving promises.
197
198
  * @private
198
199
  */
199
200
  _processQueue(debug = false) {
201
+ // Collect callbacks to invoke after the loop to avoid blocking the event loop
202
+ const toResolve = [];
203
+ const toReject = [];
204
+
200
205
  // Process queue items one at a time when slots are available
201
206
  // Items are only removed when they can be granted or must be rejected
202
207
  while (this.waitQueue.length > 0 && this.globalActive < this.maxConcurrent) {
@@ -216,7 +221,7 @@ class DelegationManager {
216
221
  if (debug) {
217
222
  console.error(`[DelegationManager] Session limit (${this.maxPerSession}) reached for queued item, rejecting`);
218
223
  }
219
- reject(new Error(`Maximum delegations per session (${this.maxPerSession}) reached for session ${parentSessionId}`));
224
+ toReject.push({ reject, error: new Error(`Maximum delegations per session (${this.maxPerSession}) reached for session ${parentSessionId}`) });
220
225
  // Continue to process next item in queue
221
226
  continue;
222
227
  }
@@ -230,7 +235,21 @@ class DelegationManager {
230
235
  console.error(`[DelegationManager] Granted slot from queue (waited ${waitTime}ms). Active: ${this.globalActive}/${this.maxConcurrent}`);
231
236
  }
232
237
 
233
- resolve(true);
238
+ toResolve.push(resolve);
239
+ }
240
+
241
+ // Defer promise resolutions/rejections to next tick to avoid blocking the event loop.
242
+ // This is critical: synchronous resolve()/reject() calls in a tight loop can saturate
243
+ // the microtask queue and prevent other async operations from proceeding.
244
+ if (toResolve.length > 0 || toReject.length > 0) {
245
+ setImmediate(() => {
246
+ for (const resolve of toResolve) {
247
+ resolve(true);
248
+ }
249
+ for (const { reject, error } of toReject) {
250
+ reject(error);
251
+ }
252
+ });
234
253
  }
235
254
  }
236
255
 
@@ -293,6 +312,9 @@ const defaultDelegationManager = new DelegationManager();
293
312
  // Export the class for per-instance usage
294
313
  export { DelegationManager };
295
314
 
315
+ // Default delegation timeout from environment variable or 300 seconds (5 minutes)
316
+ const DEFAULT_DELEGATE_TIMEOUT = parseInt(process.env.DELEGATE_TIMEOUT, 10) || 300;
317
+
296
318
  /**
297
319
  * Delegate a big distinct task to a probe subagent (used automatically by AI agents)
298
320
  *
@@ -309,7 +331,7 @@ export { DelegationManager };
309
331
  *
310
332
  * @param {Object} options - Delegate options
311
333
  * @param {string} options.task - A complete, self-contained task for the subagent. Should be specific and focused on one area of expertise.
312
- * @param {number} [options.timeout=300] - Timeout in seconds (default: 5 minutes)
334
+ * @param {number} [options.timeout] - Timeout in seconds (default: DELEGATE_TIMEOUT env var or 300)
313
335
  * @param {boolean} [options.debug=false] - Enable debug logging
314
336
  * @param {number} [options.currentIteration=0] - Current tool iteration count from parent agent
315
337
  * @param {number} [options.maxIterations=30] - Maximum tool iterations allowed
@@ -335,7 +357,7 @@ export { DelegationManager };
335
357
  */
336
358
  export async function delegate({
337
359
  task,
338
- timeout = 300,
360
+ timeout = DEFAULT_DELEGATE_TIMEOUT,
339
361
  debug = false,
340
362
  currentIteration = 0,
341
363
  maxIterations = 30,
@@ -11,7 +11,10 @@ import { taskSchema } from '../agent/tasks/taskTool.js';
11
11
  // Common schemas for tool parameters (used for internal execution after XML parsing)
12
12
  export const searchSchema = z.object({
13
13
  query: z.string().describe('Search query with Elasticsearch syntax. Use quotes for exact matches, AND/OR for boolean logic, - for negation.'),
14
- path: z.string().optional().default('.').describe('Path to search in. For dependencies use "go:github.com/owner/repo", "js:package_name", or "rust:cargo_name" etc.')
14
+ path: z.string().optional().default('.').describe('Path to search in. For dependencies use "go:github.com/owner/repo", "js:package_name", or "rust:cargo_name" etc.'),
15
+ exact: z.boolean().optional().default(false).describe('Default (false) enables stemming and keyword splitting for exploratory search - "getUserData" matches "get", "user", "data", etc. Set true for precise symbol lookup where "getUserData" matches only "getUserData". Use true when you know the exact symbol name.'),
16
+ session: z.string().optional().describe('Session ID for result caching and pagination. Pass the session ID from a previous search to get additional results (next page). Results already shown in a session are automatically excluded. Omit for a fresh search.'),
17
+ nextPage: z.boolean().optional().default(false).describe('Set to true when requesting the next page of results. Requires passing the same session ID from the previous search output.')
15
18
  });
16
19
 
17
20
  export const querySchema = z.object({
@@ -130,6 +133,9 @@ You need to focus on main keywords when constructing the query, and always use e
130
133
  Parameters:
131
134
  - query: (required) Search query. Free-form questions are accepted, but for best results prefer Elasticsearch-style syntax with quotes for exact matches ("functionName"), AND/OR for boolean logic, - for negation, + for important terms.
132
135
  - path: (optional, default: '.') Path to search in. All dependencies located in /dep folder, under language sub folders, like this: "/dep/go/github.com/owner/repo", "/dep/js/package_name", or "/dep/rust/cargo_name" etc.
136
+ - exact: (optional, default: false) Set to true for precise symbol lookup without stemming/tokenization. Use when you know the exact symbol name (e.g., "getUserData" matches only "getUserData", not "get", "user", "data").
137
+ - session: (optional) Session ID for pagination. Pass the session ID returned from a previous search to get the next page of results. Results already shown are automatically excluded.
138
+ - nextPage: (optional, default: false) Set to true when requesting the next page of results. Requires passing the same session ID from the previous search.
133
139
 
134
140
  **Workflow:** Always start with search, then use extract for detailed context when needed.
135
141
 
@@ -16,7 +16,7 @@ export function createSearchTool(options = {}) {
16
16
  name: 'search',
17
17
  description: searchDescription,
18
18
  schema: searchSchema,
19
- func: async ({ query: searchQuery, path, allow_tests, exact, maxResults, maxTokens = 20000, language }) => {
19
+ func: async ({ query: searchQuery, path, allow_tests, exact, maxResults, maxTokens = 20000, language, session, nextPage }) => {
20
20
  try {
21
21
  const results = await search({
22
22
  query: searchQuery,
@@ -27,7 +27,9 @@ export function createSearchTool(options = {}) {
27
27
  json: false,
28
28
  maxResults,
29
29
  maxTokens,
30
- language
30
+ language,
31
+ session,
32
+ nextPage
31
33
  });
32
34
 
33
35
  return results;
@@ -169,7 +169,7 @@ export const searchTool = (options = {}) => {
169
169
  ? `${searchDescription} (delegates code search to a subagent and returns extracted code blocks)`
170
170
  : searchDescription,
171
171
  inputSchema: searchSchema,
172
- execute: async ({ query: searchQuery, path, allow_tests, exact, maxTokens: paramMaxTokens, language }) => {
172
+ execute: async ({ query: searchQuery, path, allow_tests, exact, maxTokens: paramMaxTokens, language, session, nextPage }) => {
173
173
  // Use parameter maxTokens if provided, otherwise use the default
174
174
  const effectiveMaxTokens = paramMaxTokens || maxTokens;
175
175
 
@@ -195,7 +195,8 @@ export const searchTool = (options = {}) => {
195
195
  exact,
196
196
  json: false,
197
197
  maxTokens: effectiveMaxTokens,
198
- session: sessionId, // Pass session ID if provided
198
+ session: session || sessionId, // Use explicit session param, or fall back to options sessionId
199
+ nextPage, // Pass nextPage parameter for pagination
199
200
  language // Pass language parameter if provided
200
201
  };
201
202