@browsercash/chase 1.1.0 → 1.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -159,6 +159,9 @@ async function commandAutomate(task, flags) {
159
159
  if (flags.captcha) {
160
160
  body.browserOptions = { ...(body.browserOptions || {}), captchaSolver: true };
161
161
  }
162
+ if (flags['max-turns']) {
163
+ body.maxTurns = parseInt(flags['max-turns'], 10);
164
+ }
162
165
  let taskId = null;
163
166
  let result = null;
164
167
  await streamRequest('/automate/stream', body, (type, data) => {
@@ -219,6 +222,12 @@ async function commandGenerate(task, flags) {
219
222
  if (flags.country) {
220
223
  body.browserOptions = { ...(body.browserOptions || {}), country: flags.country };
221
224
  }
225
+ if (flags['max-iterations']) {
226
+ body.maxIterations = parseInt(flags['max-iterations'], 10);
227
+ }
228
+ if (flags['max-turns']) {
229
+ body.maxTurns = parseInt(flags['max-turns'], 10);
230
+ }
222
231
  let taskId = null;
223
232
  let result = null;
224
233
  await streamRequest('/generate/stream', body, (type, data) => {
@@ -435,12 +444,14 @@ EXAMPLES:
435
444
  chase task task-xyz789
436
445
 
437
446
  OPTIONS:
438
- --country <code> Use a browser from specific country (e.g., US, DE, JP)
439
- --adblock Enable ad-blocking
440
- --captcha Enable CAPTCHA solving
441
- --quiet Reduce output verbosity
442
- --skip-test Skip script testing (generate only)
443
- --help Show this help message
447
+ --country <code> Use a browser from specific country (e.g., US, DE, JP)
448
+ --adblock Enable ad-blocking
449
+ --captcha Enable CAPTCHA solving
450
+ --max-turns <n> Max Claude turns (automate: default 30, generate fix: capped at 15)
451
+ --max-iterations <n> Max fix iterations for generate (default: 5)
452
+ --quiet Reduce output verbosity
453
+ --skip-test Skip script testing (generate only)
454
+ --help Show this help message
444
455
 
445
456
  ENVIRONMENT:
446
457
  BROWSER_CASH_API_KEY Your Browser.cash API key (required)
@@ -176,7 +176,9 @@ async function askClaudeToFix(originalTask, scriptContent, errorOutput, failedLi
176
176
  }
177
177
  };
178
178
  // Call Claude to fix the script - allow Bash so it can inspect the DOM
179
- const shellCmd = `cat "${promptFile}" | claude -p --model ${config.model} --max-turns 5 --allowedTools "Bash" --output-format stream-json --verbose`;
179
+ // Use maxTurns from config (default 30) for fix attempts, capped at 15 to avoid excessive costs
180
+ const fixTurns = Math.min(config.maxTurns, 15);
181
+ const shellCmd = `cat "${promptFile}" | claude -p --model ${config.model} --max-turns ${fixTurns} --allowedTools "Bash" --output-format stream-json --verbose`;
180
182
  const claude = spawn('bash', ['-c', shellCmd], {
181
183
  env: { ...process.env, CDP_URL: config.cdpUrl },
182
184
  stdio: ['ignore', 'pipe', 'pipe'],
package/dist/server.js CHANGED
@@ -568,11 +568,13 @@ server.post('/generate/stream', {
568
568
  },
569
569
  },
570
570
  skipTest: { type: 'boolean', default: false },
571
+ maxIterations: { type: 'integer', minimum: 1, maximum: 20 },
572
+ maxTurns: { type: 'integer', minimum: 1, maximum: 30 },
571
573
  },
572
574
  },
573
575
  },
574
576
  }, async (request, reply) => {
575
- const { task, browserCashApiKey, cdpUrl, browserOptions, skipTest } = request.body;
577
+ const { task, browserCashApiKey, cdpUrl, browserOptions, skipTest, maxIterations, maxTurns } = request.body;
576
578
  // Validate that either browserCashApiKey or cdpUrl is provided
577
579
  if (!browserCashApiKey && !cdpUrl) {
578
580
  reply.raw.writeHead(400, { 'Content-Type': 'application/json' });
@@ -658,11 +660,20 @@ server.post('/generate/stream', {
658
660
  cdpUrl: effectiveCdpUrl,
659
661
  taskDescription: task,
660
662
  });
663
+ // Override settings if provided in request
664
+ if (maxIterations) {
665
+ config.maxFixIterations = maxIterations;
666
+ }
667
+ if (maxTurns) {
668
+ config.maxTurns = Math.min(maxTurns, 30); // Cap at 30 for safety
669
+ }
661
670
  sendEvent('start', {
662
671
  taskId,
663
672
  task,
664
673
  model: config.model,
665
674
  skipTest,
675
+ maxIterations: config.maxFixIterations,
676
+ maxTurns: config.maxTurns,
666
677
  browserSessionId: browserSession?.sessionId,
667
678
  });
668
679
  // Run streaming script generation
@@ -796,11 +807,12 @@ server.post('/automate/stream', {
796
807
  captchaSolver: { type: 'boolean' },
797
808
  },
798
809
  },
810
+ maxTurns: { type: 'integer', minimum: 1, maximum: 100 },
799
811
  },
800
812
  },
801
813
  },
802
814
  }, async (request, reply) => {
803
- const { task, browserCashApiKey, cdpUrl, browserOptions } = request.body;
815
+ const { task, browserCashApiKey, cdpUrl, browserOptions, maxTurns } = request.body;
804
816
  // Validate that either browserCashApiKey or cdpUrl is provided
805
817
  if (!browserCashApiKey && !cdpUrl) {
806
818
  reply.raw.writeHead(400, { 'Content-Type': 'application/json' });
@@ -886,6 +898,10 @@ server.post('/automate/stream', {
886
898
  cdpUrl: effectiveCdpUrl,
887
899
  taskDescription: task,
888
900
  });
901
+ // Override maxTurns if provided in request
902
+ if (maxTurns) {
903
+ config.maxTurns = maxTurns;
904
+ }
889
905
  sendEvent('start', {
890
906
  taskId,
891
907
  task,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@browsercash/chase",
3
- "version": "1.1.0",
3
+ "version": "1.3.0",
4
4
  "description": "AI-powered browser automation - extract data from any website with natural language",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",