coding-agent-adapters 0.7.3 → 0.7.5

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/index.cjs CHANGED
@@ -611,6 +611,15 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
611
611
  description: "Decline anonymous usage data",
612
612
  safe: true
613
613
  },
614
+ {
615
+ pattern: /how is claude doing this session\?\s*\(optional\)|1:\s*bad\s+2:\s*fine\s+3:\s*good\s+0:\s*dismiss/i,
616
+ type: "config",
617
+ response: "0",
618
+ responseType: "text",
619
+ description: "Dismiss optional Claude session survey",
620
+ safe: true,
621
+ once: true
622
+ },
614
623
  {
615
624
  pattern: /continue without.*\[y\/n\]/i,
616
625
  type: "config",
@@ -656,12 +665,18 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
656
665
  }
657
666
  getArgs(config) {
658
667
  const args = [];
668
+ const adapterConfig = config.adapterConfig;
659
669
  if (!this.isInteractive(config)) {
660
670
  args.push("--print");
661
671
  if (config.workdir) {
662
672
  args.push("--cwd", config.workdir);
663
673
  }
664
674
  }
675
+ if (adapterConfig?.resume) {
676
+ args.push("--resume", adapterConfig.resume);
677
+ } else if (adapterConfig?.continue) {
678
+ args.push("--continue");
679
+ }
665
680
  const approvalConfig = this.getApprovalConfig(config);
666
681
  if (approvalConfig) {
667
682
  args.push(...approvalConfig.cliFlags);
@@ -706,9 +721,6 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
706
721
  * Detect blocking prompts specific to Claude Code CLI
707
722
  */
708
723
  detectBlockingPrompt(output) {
709
- if (this.detectReady(output)) {
710
- return { detected: false };
711
- }
712
724
  const stripped = this.stripAnsi(output);
713
725
  const loginDetection = this.detectLogin(output);
714
726
  if (loginDetection.required) {
@@ -721,6 +733,39 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
721
733
  instructions: loginDetection.instructions
722
734
  };
723
735
  }
736
+ if (/how is claude doing this session\?\s*\(optional\)|1:\s*bad\s+2:\s*fine\s+3:\s*good\s+0:\s*dismiss/i.test(stripped)) {
737
+ return {
738
+ detected: true,
739
+ type: "config",
740
+ prompt: "Claude session survey",
741
+ options: ["1", "2", "3", "0"],
742
+ suggestedResponse: "0",
743
+ canAutoRespond: true,
744
+ instructions: "Optional survey prompt; reply 0 to dismiss"
745
+ };
746
+ }
747
+ if (/enter\/tab\/space to toggle.*esc to cancel|enter to confirm.*esc to cancel|esc to close/i.test(stripped)) {
748
+ return {
749
+ detected: true,
750
+ type: "config",
751
+ prompt: "Claude dialog awaiting navigation",
752
+ options: ["keys:enter", "keys:esc", "keys:down,enter"],
753
+ suggestedResponse: "keys:esc",
754
+ canAutoRespond: false,
755
+ instructions: "Use Enter/Esc or arrow keys to navigate this dialog"
756
+ };
757
+ }
758
+ if (/\/agents\b|\/chrome\b|\/config\b|\/tasks\b|\/skills\b|\/remote-env\b|press .* to navigate .* enter .* esc/i.test(stripped)) {
759
+ return {
760
+ detected: true,
761
+ type: "config",
762
+ prompt: "Claude menu navigation required",
763
+ options: ["keys:esc", "keys:enter", "keys:down,enter"],
764
+ suggestedResponse: "keys:esc",
765
+ canAutoRespond: false,
766
+ instructions: "Claude is showing an interactive menu; use arrow keys + Enter or Esc"
767
+ };
768
+ }
724
769
  if (/Do you want to|wants? (your )?permission|needs your permission/i.test(stripped)) {
725
770
  return {
726
771
  detected: true,
@@ -769,6 +814,9 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
769
814
  instructions: "Claude Code requesting file access permission"
770
815
  };
771
816
  }
817
+ if (this.detectReady(output)) {
818
+ return { detected: false };
819
+ }
772
820
  return super.detectBlockingPrompt(output);
773
821
  }
774
822
  /**
@@ -802,6 +850,10 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
802
850
  */
803
851
  detectTaskComplete(output) {
804
852
  const stripped = this.stripAnsi(output);
853
+ if (!stripped.trim()) return false;
854
+ if (/trust.*directory|do you want to|needs? your permission/i.test(stripped)) {
855
+ return false;
856
+ }
805
857
  const hasDuration = /[A-Z][A-Za-z' -]{2,40}\s+for\s+\d+(?:h\s+\d{1,2}m\s+\d{1,2}s|m\s+\d{1,2}s|s)/.test(stripped);
806
858
  const tail = stripped.slice(-300);
807
859
  const hasIdlePrompt = /❯/.test(tail);
@@ -815,14 +867,15 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
815
867
  }
816
868
  detectReady(output) {
817
869
  const stripped = this.stripAnsi(output);
870
+ if (!stripped.trim()) return false;
818
871
  if (/trust.*directory|do you want to|needs? your permission/i.test(stripped)) {
819
872
  return false;
820
873
  }
821
874
  const tail = stripped.slice(-300);
822
- return stripped.includes("How can I help") || stripped.includes("What would you like") || // v2.1+ shows "for shortcuts" hint when ready
823
- stripped.includes("for shortcuts") || // Match "claude> " or similar specific prompts, not bare ">"
824
- /claude>/i.test(tail) || // v2.1+ uses ❯ as the input prompt
825
- /❯/.test(tail);
875
+ const hasConversationalReadyText = stripped.includes("How can I help") || stripped.includes("What would you like");
876
+ const hasLegacyPrompt = /claude>/i.test(tail);
877
+ const hasShortcutsHint = stripped.includes("for shortcuts");
878
+ return hasConversationalReadyText || hasLegacyPrompt || hasShortcutsHint;
826
879
  }
827
880
  parseOutput(output) {
828
881
  const stripped = this.stripAnsi(output);
@@ -1340,22 +1393,26 @@ var CodexAdapter = class extends BaseCodingAdapter {
1340
1393
  }
1341
1394
  if (/preparing.?device.?code.?login/i.test(stripped) || /open.?this.?link.?in.?your.?browser/i.test(stripped) || /enter.?this.?one-time.?code/i.test(stripped)) {
1342
1395
  const codeMatch = stripped.match(/code[:\s]+([A-Z0-9-]+)/i);
1396
+ const deviceCode = codeMatch ? codeMatch[1] : void 0;
1343
1397
  const urlMatch = stripped.match(/https?:\/\/[^\s]+/);
1344
1398
  return {
1345
1399
  required: true,
1346
1400
  type: "device_code",
1347
1401
  url: urlMatch ? urlMatch[0] : void 0,
1348
- instructions: codeMatch ? `Enter code ${codeMatch[1]} at the URL` : "Device code authentication in progress \u2014 complete in browser"
1402
+ deviceCode,
1403
+ instructions: deviceCode ? `Enter code ${deviceCode} at the URL` : "Device code authentication in progress \u2014 complete in browser"
1349
1404
  };
1350
1405
  }
1351
1406
  if (stripped.includes("device code") || stripped.includes("Enter the code")) {
1352
1407
  const codeMatch = stripped.match(/code[:\s]+([A-Z0-9-]+)/i);
1408
+ const deviceCode = codeMatch ? codeMatch[1] : void 0;
1353
1409
  const urlMatch = stripped.match(/https?:\/\/[^\s]+/);
1354
1410
  return {
1355
1411
  required: true,
1356
1412
  type: "device_code",
1357
1413
  url: urlMatch ? urlMatch[0] : void 0,
1358
- instructions: codeMatch ? `Enter code ${codeMatch[1]} at the URL` : "Device code authentication required"
1414
+ deviceCode,
1415
+ instructions: deviceCode ? `Enter code ${deviceCode} at the URL` : "Device code authentication required"
1359
1416
  };
1360
1417
  }
1361
1418
  return { required: false };
@@ -1469,27 +1526,33 @@ var CodexAdapter = class extends BaseCodingAdapter {
1469
1526
  */
1470
1527
  detectTaskComplete(output) {
1471
1528
  const stripped = this.stripAnsi(output);
1529
+ if (!stripped.trim()) return false;
1472
1530
  const hasWorkedFor = /Worked\s+for\s+\d+(?:h\s+\d{2}m\s+\d{2}s|m\s+\d{2}s|s)/.test(stripped);
1473
- const hasReadyPrompt = /›\s+Ask\s+Codex\s+to\s+do\s+anything/.test(stripped);
1474
- if (hasWorkedFor && hasReadyPrompt) {
1531
+ const hasComposerPrompt = /›\s+Ask\s+Codex\s+to\s+do\s+anything/.test(stripped) || /^\s*›\s*(?!\d+\.)\S.*$/m.test(stripped);
1532
+ const hasIdleFooterHints = /\?\s+for\s+shortcuts/i.test(stripped) || /context\s+left/i.test(stripped) || /tab\s+to\s+queue\s+message/i.test(stripped);
1533
+ if (hasWorkedFor && (hasComposerPrompt || hasIdleFooterHints)) {
1475
1534
  return true;
1476
1535
  }
1477
- if (hasReadyPrompt) {
1536
+ if (hasComposerPrompt) {
1478
1537
  return true;
1479
1538
  }
1480
- if (hasWorkedFor && /›\s+/m.test(stripped)) {
1539
+ if (hasWorkedFor && hasIdleFooterHints) {
1481
1540
  return true;
1482
1541
  }
1483
1542
  return false;
1484
1543
  }
1485
1544
  detectReady(output) {
1486
1545
  const stripped = this.stripAnsi(output);
1546
+ if (!stripped.trim()) return false;
1547
+ const tail = stripped.slice(-1200);
1548
+ const hasComposerPrompt = /^\s*›\s*(?!\d+\.)\S.*$/m.test(tail) || /›\s+Ask\s+Codex\s+to\s+do\s+anything/.test(tail);
1549
+ const hasComposerFooter = /\?\s+for\s+shortcuts/i.test(tail) || /context\s+left/i.test(tail) || /tab\s+to\s+queue\s+message/i.test(tail) || /shift\s*\+\s*enter\s+for\s+newline/i.test(tail);
1550
+ if (hasComposerPrompt || hasComposerFooter) {
1551
+ return true;
1552
+ }
1487
1553
  if (/do.?you.?trust.?the.?contents/i.test(stripped) || /sign.?in.?with.?chatgpt/i.test(stripped) || /update.?available/i.test(stripped) || /enable.?full.?access/i.test(stripped) || /choose.?working.?directory/i.test(stripped)) {
1488
1554
  return false;
1489
1555
  }
1490
- if (/›\s+/m.test(stripped)) {
1491
- return true;
1492
- }
1493
1556
  if (/explain this codebase|summarize recent commits|find and fix a bug/i.test(stripped)) {
1494
1557
  return true;
1495
1558
  }