@causyne/agent 1.20.17 → 1.20.19

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.
@@ -30,7 +30,10 @@ export type ReverseEngineeringAction =
30
30
  | 'trace'
31
31
  | 'status'
32
32
  | 'engine_tool'
33
- | 'list_tools';
33
+ | 'list_tools'
34
+ | 'decode_resources'
35
+ | 'search_classes'
36
+ | 'graph';
34
37
 
35
38
  export interface BinaryMitigations {
36
39
  pie?: boolean | undefined;
@@ -69,6 +72,7 @@ export interface ReverseEngineeringParams {
69
72
  script?: string | undefined;
70
73
  toolName?: string | undefined;
71
74
  toolArgs?: Record<string, unknown> | undefined;
75
+ query?: string | undefined;
72
76
  }
73
77
 
74
78
  // ─────────────────────────────────────────────────────────────────────────────
@@ -318,7 +322,7 @@ export const reverseEngineering = {
318
322
  properties: {
319
323
  action: {
320
324
  type: 'string',
321
- enum: ['inspect', 'decompile', 'unpack', 'deobfuscate', 'trace', 'status', 'engine_tool', 'list_tools'],
325
+ enum: ['inspect', 'decompile', 'unpack', 'deobfuscate', 'trace', 'status', 'engine_tool', 'list_tools', 'decode_resources', 'search_classes', 'graph'],
322
326
  description: 'Reverse engineering action to perform.'
323
327
  },
324
328
  filePath: {
@@ -366,6 +370,10 @@ export const reverseEngineering = {
366
370
  toolArgs: {
367
371
  type: 'object',
368
372
  description: 'Arguments payload for engine_tool.'
373
+ },
374
+ query: {
375
+ type: 'string',
376
+ description: 'Class, method, or string search query for reverse engineering.'
369
377
  }
370
378
  },
371
379
  required: ['action']
@@ -373,8 +381,29 @@ export const reverseEngineering = {
373
381
  },
374
382
 
375
383
  async execute(args: Record<string, unknown>, context: { workspaceDir?: string; sessionId?: string; signal?: AbortSignal } = {}): Promise<Record<string, unknown>> {
376
- const action = String(args['action'] || 'status') as ReverseEngineeringAction;
377
- const rawPath = typeof args['filePath'] === 'string' ? args['filePath'] : undefined;
384
+ const rawPath = typeof args['filePath'] === 'string' ? args['filePath']
385
+ : typeof args['file'] === 'string' ? args['file']
386
+ : typeof args['path'] === 'string' ? args['path']
387
+ : typeof args['apk'] === 'string' ? args['apk']
388
+ : typeof args['binary'] === 'string' ? args['binary']
389
+ : (typeof args['target'] === 'string' && args['action'] !== 'trace' ? args['target'] : undefined);
390
+
391
+ let rawAction = typeof args['action'] === 'string' ? args['action']
392
+ : typeof args['operation'] === 'string' ? args['operation']
393
+ : typeof args['mode'] === 'string' ? args['mode']
394
+ : '';
395
+
396
+ if (!rawAction && (typeof args['toolName'] === 'string' || typeof args['engineTool'] === 'string')) {
397
+ rawAction = 'engine_tool';
398
+ }
399
+
400
+ if (['analyze', 'info', 'check', 'probe', 'inspect_package'].includes(rawAction)) rawAction = 'inspect';
401
+ if (['disassemble', 'disasm'].includes(rawAction)) rawAction = 'decompile';
402
+ if (['decode_resources', 'resources', 'decode'].includes(rawAction)) rawAction = 'decode_resources';
403
+ if (['search_classes', 'classes'].includes(rawAction)) rawAction = 'search_classes';
404
+ if (['graph', 'application_graph'].includes(rawAction)) rawAction = 'graph';
405
+
406
+ const action = (rawAction || (rawPath ? 'inspect' : 'status')) as ReverseEngineeringAction;
378
407
  const outputDir = typeof args['outputDir'] === 'string' ? args['outputDir'] : undefined;
379
408
  const functionName = typeof args['functionName'] === 'string' ? args['functionName'] : undefined;
380
409
  const address = typeof args['address'] === 'string' ? args['address'] : undefined;
@@ -424,7 +453,8 @@ export const reverseEngineering = {
424
453
  'Electron ASAR pickle header inspection & extraction',
425
454
  'JavaScript sourcemap recovery and route harvesting',
426
455
  'Dynamic runtime tracing and API observation',
427
- 'Headless MCP engine with 229 specialized reverse engineering tools'
456
+ 'Headless MCP engine with 170+ specialized reverse engineering tools',
457
+ 'Android APK resource decoding, class hierarchy & graph projection'
428
458
  ]
429
459
  };
430
460
  }
@@ -442,7 +472,7 @@ export const reverseEngineering = {
442
472
 
443
473
  // ── ACTION: ENGINE_TOOL ───────────────────────────────────────────────
444
474
  if (action === 'engine_tool') {
445
- const toolName = typeof args['toolName'] === 'string' ? args['toolName'] : '';
475
+ const toolName = typeof args['toolName'] === 'string' ? args['toolName'] : typeof args['engineTool'] === 'string' ? args['engineTool'] : '';
446
476
  if (!toolName) {
447
477
  return { success: false, error: 'toolName parameter is required for action "engine_tool".' };
448
478
  }
@@ -465,7 +495,7 @@ export const reverseEngineering = {
465
495
  };
466
496
  }
467
497
 
468
- // Require filePath for inspect, decompile, unpack, deobfuscate
498
+ // Require filePath for inspect, decompile, unpack, deobfuscate, decode_resources, search_classes, graph
469
499
  if (!rawPath && action !== 'trace') {
470
500
  return { success: false, error: `Action "${action}" requires a valid "filePath" parameter.` };
471
501
  }
@@ -475,6 +505,56 @@ export const reverseEngineering = {
475
505
  return { success: false, error: `File not found: ${resolvedFile}` };
476
506
  }
477
507
 
508
+ // ── ACTION: DECODE_RESOURCES ──────────────────────────────────────────
509
+ if (action === 'decode_resources') {
510
+ const res = await sovereignReverseHarness.decodeAndroidResources(resolvedFile, outputDir, context.signal);
511
+ const textOutput = res.output || (res.structuredContent ? JSON.stringify(res.structuredContent, null, 2) : res.error || '');
512
+ const stored = outputStore.processToolOutput(sessionId, `${callId}_decode_resources`, textOutput);
513
+ return {
514
+ success: res.success,
515
+ action: 'decode_resources',
516
+ filePath: resolvedFile,
517
+ preview: stored.contentForModel,
518
+ isTruncated: stored.isTruncated,
519
+ diskPath: stored.diskPath,
520
+ error: res.error
521
+ };
522
+ }
523
+
524
+ // ── ACTION: SEARCH_CLASSES ───────────────────────────────────────────
525
+ if (action === 'search_classes') {
526
+ const query = String(args['query'] || '');
527
+ const res = await sovereignReverseHarness.searchAndroidClasses(resolvedFile, query, context.signal);
528
+ const textOutput = res.output || (res.structuredContent ? JSON.stringify(res.structuredContent, null, 2) : res.error || '');
529
+ const stored = outputStore.processToolOutput(sessionId, `${callId}_search_classes`, textOutput);
530
+ return {
531
+ success: res.success,
532
+ action: 'search_classes',
533
+ filePath: resolvedFile,
534
+ query,
535
+ preview: stored.contentForModel,
536
+ isTruncated: stored.isTruncated,
537
+ diskPath: stored.diskPath,
538
+ error: res.error
539
+ };
540
+ }
541
+
542
+ // ── ACTION: GRAPH ─────────────────────────────────────────────────────
543
+ if (action === 'graph') {
544
+ const res = await sovereignReverseHarness.projectAndroidGraph(resolvedFile, context.signal);
545
+ const textOutput = res.output || (res.structuredContent ? JSON.stringify(res.structuredContent, null, 2) : res.error || '');
546
+ const stored = outputStore.processToolOutput(sessionId, `${callId}_graph`, textOutput);
547
+ return {
548
+ success: res.success,
549
+ action: 'graph',
550
+ filePath: resolvedFile,
551
+ preview: stored.contentForModel,
552
+ isTruncated: stored.isTruncated,
553
+ diskPath: stored.diskPath,
554
+ error: res.error
555
+ };
556
+ }
557
+
478
558
  // ── ACTION: INSPECT ───────────────────────────────────────────────────
479
559
  if (action === 'inspect') {
480
560
  try {
@@ -515,9 +595,27 @@ export const reverseEngineering = {
515
595
  } else if (headerBuf[0] === 0x00 && headerBuf[1] === 0x61 && headerBuf[2] === 0x73 && headerBuf[3] === 0x6d) {
516
596
  result.format = 'WebAssembly';
517
597
  result.architecture = 'wasm32 / wasm64';
518
- } else if (headerBuf[0] === 0x50 && headerBuf[1] === 0x4b && headerBuf[2] === 0x03 && headerBuf[3] === 0x04) {
598
+ } else if (
599
+ (headerBuf[0] === 0x50 && headerBuf[1] === 0x4b && headerBuf[2] === 0x03 && headerBuf[3] === 0x04) ||
600
+ resolvedFile.toLowerCase().endsWith('.apk')
601
+ ) {
519
602
  result.format = 'APK/ZIP';
520
- result.fileType = 'Compressed Archive / Package';
603
+ result.fileType = 'Android Application Package (APK)';
604
+ try {
605
+ const unzipList = await execFileAsync('unzip', ['-l', resolvedFile], { timeout: 15000 });
606
+ const lines = unzipList.stdout.split('\n');
607
+ const dexFiles = lines.filter(l => l.includes('.dex')).map(l => l.trim().split(/\s+/).pop());
608
+ const hasManifest = lines.some(l => l.includes('AndroidManifest.xml'));
609
+ const nativeLibs = lines.filter(l => l.includes('lib/')).slice(0, 15).map(l => l.trim().split(/\s+/).pop());
610
+ result.metadata = {
611
+ dexFiles,
612
+ hasManifest,
613
+ totalEntries: lines.length,
614
+ sampleNativeLibraries: nativeLibs
615
+ };
616
+ } catch {
617
+ // unzip fallback
618
+ }
521
619
  } else {
522
620
  const asar = parseAsarHeader(headerBuf);
523
621
  if (asar) {