agentaudit 3.9.9 → 3.9.10

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 (2) hide show
  1. package/cli.mjs +21 -0
  2. package/package.json +1 -1
package/cli.mjs CHANGED
@@ -1381,6 +1381,7 @@ async function auditRepo(url) {
1381
1381
  ].join('\n');
1382
1382
 
1383
1383
  let report = null;
1384
+ let _lastLlmText = '';
1384
1385
 
1385
1386
  try {
1386
1387
  if (anthropicKey) {
@@ -1400,7 +1401,14 @@ async function auditRepo(url) {
1400
1401
  signal: AbortSignal.timeout(120_000),
1401
1402
  });
1402
1403
  const data = await res.json();
1404
+ if (data.error) {
1405
+ console.log(` ${c.red}failed${c.reset}`);
1406
+ console.log(` ${c.red}API error: ${data.error.message || JSON.stringify(data.error)}${c.reset}`);
1407
+ try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch {}
1408
+ return null;
1409
+ }
1403
1410
  const text = data.content?.[0]?.text || '';
1411
+ _lastLlmText = text;
1404
1412
  report = extractJSON(text);
1405
1413
  } else if (openaiKey) {
1406
1414
  const res = await fetch('https://api.openai.com/v1/chat/completions', {
@@ -1420,7 +1428,14 @@ async function auditRepo(url) {
1420
1428
  signal: AbortSignal.timeout(120_000),
1421
1429
  });
1422
1430
  const data = await res.json();
1431
+ if (data.error) {
1432
+ console.log(` ${c.red}failed${c.reset}`);
1433
+ console.log(` ${c.red}API error: ${data.error.message || JSON.stringify(data.error)}${c.reset}`);
1434
+ try { fs.rmSync(tmpDir, { recursive: true, force: true }); } catch {}
1435
+ return null;
1436
+ }
1423
1437
  const text = data.choices?.[0]?.message?.content || '';
1438
+ _lastLlmText = text;
1424
1439
  report = extractJSON(text);
1425
1440
  }
1426
1441
 
@@ -1437,6 +1452,12 @@ async function auditRepo(url) {
1437
1452
 
1438
1453
  if (!report) {
1439
1454
  console.log(` ${c.red}Could not parse LLM response as JSON${c.reset}`);
1455
+ console.log(` ${c.dim}Hint: run with --debug to see the raw LLM response${c.reset}`);
1456
+ if (process.argv.includes('--debug')) {
1457
+ console.log(` ${c.dim}--- Raw LLM response (first 2000 chars) ---${c.reset}`);
1458
+ console.log((typeof _lastLlmText === 'string' ? _lastLlmText : '(empty)').slice(0, 2000));
1459
+ console.log(` ${c.dim}--- end ---${c.reset}`);
1460
+ }
1440
1461
  return null;
1441
1462
  }
1442
1463
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentaudit",
3
- "version": "3.9.9",
3
+ "version": "3.9.10",
4
4
  "description": "Security scanner for AI packages — MCP server + CLI",
5
5
  "type": "module",
6
6
  "bin": {