@probelabs/probe 0.6.0-rc199 → 0.6.0-rc201

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/delegate.js CHANGED
@@ -229,6 +229,9 @@ export async function delegate({
229
229
  console.error(`[DELEGATE] Using ProbeAgent SDK with code-researcher prompt`);
230
230
  }
231
231
  // Create a new ProbeAgent instance for the delegated task
232
+ // IMPORTANT: We pass both path and cwd set to the same value (workspace root)
233
+ // to prevent path doubling issues. The parent's navigation context should not
234
+ // affect the subagent's path resolution - subagents always work from workspace root.
232
235
  const subagent = new ProbeAgent({
233
236
  sessionId,
234
237
  promptType: 'code-researcher', // Clean prompt, not inherited from parent
@@ -238,7 +241,8 @@ export async function delegate({
238
241
  maxIterations: remainingIterations,
239
242
  debug,
240
243
  tracer,
241
- path, // Inherit from parent
244
+ path, // Workspace root (from delegateTool)
245
+ cwd: path, // Explicitly set cwd to workspace root to prevent path doubling
242
246
  provider, // Inherit from parent
243
247
  model, // Inherit from parent
244
248
  enableBash, // Inherit from parent
@@ -5,6 +5,7 @@
5
5
 
6
6
  import { z } from 'zod';
7
7
  import { resolve, isAbsolute } from 'path';
8
+ import { editSchema, createSchema } from './edit.js';
8
9
 
9
10
  // Common schemas for tool parameters (used for internal execution after XML parsing)
10
11
  export const searchSchema = z.object({
@@ -359,14 +360,16 @@ export function buildToolTagPattern(tools = DEFAULT_VALID_TOOLS) {
359
360
  * @returns {string[]} - Array of valid parameter names for this tool
360
361
  */
361
362
  function getValidParamsForTool(toolName) {
362
- // Map tool names to their schemas
363
+ // Map tool names to their schemas (supports both Zod and JSON Schema formats)
363
364
  const schemaMap = {
364
365
  search: searchSchema,
365
366
  query: querySchema,
366
367
  extract: extractSchema,
367
368
  delegate: delegateSchema,
368
369
  bash: bashSchema,
369
- attempt_completion: attemptCompletionSchema
370
+ attempt_completion: attemptCompletionSchema,
371
+ edit: editSchema,
372
+ create: createSchema
370
373
  };
371
374
 
372
375
  const schema = schemaMap[toolName];
@@ -382,10 +385,15 @@ function getValidParamsForTool(toolName) {
382
385
  }
383
386
 
384
387
  // Extract keys from Zod schema
385
- if (schema && schema._def && schema._def.shape) {
388
+ if (schema._def && schema._def.shape) {
386
389
  return Object.keys(schema._def.shape());
387
390
  }
388
391
 
392
+ // Extract keys from JSON Schema (used by edit and create tools)
393
+ if (schema.properties) {
394
+ return Object.keys(schema.properties);
395
+ }
396
+
389
397
  // Fallback: return empty array if we can't extract schema keys
390
398
  return [];
391
399
  }
@@ -295,9 +295,22 @@ export const delegateTool = (options = {}) => {
295
295
  throw new TypeError('model must be a string, null, or undefined');
296
296
  }
297
297
 
298
- // Use inherited path if not specified in AI call
299
- // Priority: explicit path > cwd > first allowedFolder
300
- const effectivePath = path || cwd || (allowedFolders && allowedFolders[0]);
298
+ // Determine the path to pass to the subagent
299
+ // NOTE: Delegation intentionally uses DIFFERENT priority than other tools.
300
+ //
301
+ // Other tools (search, extract, query, bash) use: cwd || allowedFolders[0]
302
+ // Delegation uses: path || allowedFolders[0] || cwd
303
+ //
304
+ // This is intentional because:
305
+ // - Other tools operate within the parent's navigation context (cwd is correct)
306
+ // - Subagents need a FRESH start from workspace root, not parent's navigation state
307
+ // - Using parent's cwd would cause "path doubling" (Issue #348) where paths like
308
+ // /workspace/project/src/internal/build/src/internal/build/file.go get constructed
309
+ //
310
+ // The workspace root (allowedFolders[0]) is the security boundary and correct base
311
+ // for subagent operations. Parent navigation context should not leak to subagents.
312
+ const workspaceRoot = allowedFolders && allowedFolders[0];
313
+ const effectivePath = path || workspaceRoot || cwd;
301
314
 
302
315
  if (debug) {
303
316
  console.error(`Executing delegate with task: "${task.substring(0, 100)}${task.length > 100 ? '...' : ''}"`);
@@ -305,7 +318,7 @@ export const delegateTool = (options = {}) => {
305
318
  console.error(`Parent session: ${parentSessionId}`);
306
319
  }
307
320
  if (effectivePath && effectivePath !== path) {
308
- console.error(`Using inherited path: ${effectivePath}`);
321
+ console.error(`Using workspace root: ${effectivePath} (cwd was: ${cwd || 'not set'})`);
309
322
  }
310
323
  }
311
324