coding-agent-adapters 0.7.2 → 0.7.4
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 +41 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -8
- package/dist/index.d.ts +4 -8
- package/dist/index.js +41 -16
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { BaseCLIAdapter, SpawnConfig, AutoResponseRule, LoginDetection, BlockingPromptDetection, ParsedOutput } from 'pty-manager';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Shared types for coding-agent-adapters
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Supported adapter types
|
|
8
|
-
*/
|
|
9
|
-
type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
|
|
10
|
-
|
|
11
3
|
/**
|
|
12
4
|
* Approval Presets
|
|
13
5
|
*
|
|
@@ -63,6 +55,10 @@ declare function getPresetDefinition(preset: ApprovalPreset): PresetDefinition;
|
|
|
63
55
|
* for AI coding agents.
|
|
64
56
|
*/
|
|
65
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Supported adapter types
|
|
60
|
+
*/
|
|
61
|
+
type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
|
|
66
62
|
/**
|
|
67
63
|
* Credentials that can be passed via SpawnConfig.adapterConfig
|
|
68
64
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,5 @@
|
|
|
1
1
|
import { BaseCLIAdapter, SpawnConfig, AutoResponseRule, LoginDetection, BlockingPromptDetection, ParsedOutput } from 'pty-manager';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* Shared types for coding-agent-adapters
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* Supported adapter types
|
|
8
|
-
*/
|
|
9
|
-
type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
|
|
10
|
-
|
|
11
3
|
/**
|
|
12
4
|
* Approval Presets
|
|
13
5
|
*
|
|
@@ -63,6 +55,10 @@ declare function getPresetDefinition(preset: ApprovalPreset): PresetDefinition;
|
|
|
63
55
|
* for AI coding agents.
|
|
64
56
|
*/
|
|
65
57
|
|
|
58
|
+
/**
|
|
59
|
+
* Supported adapter types
|
|
60
|
+
*/
|
|
61
|
+
type AdapterType = 'claude' | 'gemini' | 'codex' | 'aider';
|
|
66
62
|
/**
|
|
67
63
|
* Credentials that can be passed via SpawnConfig.adapterConfig
|
|
68
64
|
*/
|
package/dist/index.js
CHANGED
|
@@ -654,12 +654,18 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
654
654
|
}
|
|
655
655
|
getArgs(config) {
|
|
656
656
|
const args = [];
|
|
657
|
+
const adapterConfig = config.adapterConfig;
|
|
657
658
|
if (!this.isInteractive(config)) {
|
|
658
659
|
args.push("--print");
|
|
659
660
|
if (config.workdir) {
|
|
660
661
|
args.push("--cwd", config.workdir);
|
|
661
662
|
}
|
|
662
663
|
}
|
|
664
|
+
if (adapterConfig?.resume) {
|
|
665
|
+
args.push("--resume", adapterConfig.resume);
|
|
666
|
+
} else if (adapterConfig?.continue) {
|
|
667
|
+
args.push("--continue");
|
|
668
|
+
}
|
|
663
669
|
const approvalConfig = this.getApprovalConfig(config);
|
|
664
670
|
if (approvalConfig) {
|
|
665
671
|
args.push(...approvalConfig.cliFlags);
|
|
@@ -704,9 +710,6 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
704
710
|
* Detect blocking prompts specific to Claude Code CLI
|
|
705
711
|
*/
|
|
706
712
|
detectBlockingPrompt(output) {
|
|
707
|
-
if (this.detectReady(output)) {
|
|
708
|
-
return { detected: false };
|
|
709
|
-
}
|
|
710
713
|
const stripped = this.stripAnsi(output);
|
|
711
714
|
const loginDetection = this.detectLogin(output);
|
|
712
715
|
if (loginDetection.required) {
|
|
@@ -767,6 +770,9 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
767
770
|
instructions: "Claude Code requesting file access permission"
|
|
768
771
|
};
|
|
769
772
|
}
|
|
773
|
+
if (this.detectReady(output)) {
|
|
774
|
+
return { detected: false };
|
|
775
|
+
}
|
|
770
776
|
return super.detectBlockingPrompt(output);
|
|
771
777
|
}
|
|
772
778
|
/**
|
|
@@ -800,6 +806,11 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
800
806
|
*/
|
|
801
807
|
detectTaskComplete(output) {
|
|
802
808
|
const stripped = this.stripAnsi(output);
|
|
809
|
+
if (!stripped.trim()) return false;
|
|
810
|
+
if (this.detectLoading(stripped)) return false;
|
|
811
|
+
if (/trust.*directory|do you want to|needs? your permission/i.test(stripped)) {
|
|
812
|
+
return false;
|
|
813
|
+
}
|
|
803
814
|
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);
|
|
804
815
|
const tail = stripped.slice(-300);
|
|
805
816
|
const hasIdlePrompt = /❯/.test(tail);
|
|
@@ -813,14 +824,16 @@ var ClaudeAdapter = class extends BaseCodingAdapter {
|
|
|
813
824
|
}
|
|
814
825
|
detectReady(output) {
|
|
815
826
|
const stripped = this.stripAnsi(output);
|
|
827
|
+
if (!stripped.trim()) return false;
|
|
828
|
+
if (this.detectLoading(stripped)) return false;
|
|
816
829
|
if (/trust.*directory|do you want to|needs? your permission/i.test(stripped)) {
|
|
817
830
|
return false;
|
|
818
831
|
}
|
|
819
832
|
const tail = stripped.slice(-300);
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
833
|
+
const hasConversationalReadyText = stripped.includes("How can I help") || stripped.includes("What would you like");
|
|
834
|
+
const hasLegacyPrompt = /claude>/i.test(tail);
|
|
835
|
+
const hasShortcutsHint = stripped.includes("for shortcuts");
|
|
836
|
+
return hasConversationalReadyText || hasLegacyPrompt || hasShortcutsHint;
|
|
824
837
|
}
|
|
825
838
|
parseOutput(output) {
|
|
826
839
|
const stripped = this.stripAnsi(output);
|
|
@@ -1338,22 +1351,26 @@ var CodexAdapter = class extends BaseCodingAdapter {
|
|
|
1338
1351
|
}
|
|
1339
1352
|
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)) {
|
|
1340
1353
|
const codeMatch = stripped.match(/code[:\s]+([A-Z0-9-]+)/i);
|
|
1354
|
+
const deviceCode = codeMatch ? codeMatch[1] : void 0;
|
|
1341
1355
|
const urlMatch = stripped.match(/https?:\/\/[^\s]+/);
|
|
1342
1356
|
return {
|
|
1343
1357
|
required: true,
|
|
1344
1358
|
type: "device_code",
|
|
1345
1359
|
url: urlMatch ? urlMatch[0] : void 0,
|
|
1346
|
-
|
|
1360
|
+
deviceCode,
|
|
1361
|
+
instructions: deviceCode ? `Enter code ${deviceCode} at the URL` : "Device code authentication in progress \u2014 complete in browser"
|
|
1347
1362
|
};
|
|
1348
1363
|
}
|
|
1349
1364
|
if (stripped.includes("device code") || stripped.includes("Enter the code")) {
|
|
1350
1365
|
const codeMatch = stripped.match(/code[:\s]+([A-Z0-9-]+)/i);
|
|
1366
|
+
const deviceCode = codeMatch ? codeMatch[1] : void 0;
|
|
1351
1367
|
const urlMatch = stripped.match(/https?:\/\/[^\s]+/);
|
|
1352
1368
|
return {
|
|
1353
1369
|
required: true,
|
|
1354
1370
|
type: "device_code",
|
|
1355
1371
|
url: urlMatch ? urlMatch[0] : void 0,
|
|
1356
|
-
|
|
1372
|
+
deviceCode,
|
|
1373
|
+
instructions: deviceCode ? `Enter code ${deviceCode} at the URL` : "Device code authentication required"
|
|
1357
1374
|
};
|
|
1358
1375
|
}
|
|
1359
1376
|
return { required: false };
|
|
@@ -1467,27 +1484,35 @@ var CodexAdapter = class extends BaseCodingAdapter {
|
|
|
1467
1484
|
*/
|
|
1468
1485
|
detectTaskComplete(output) {
|
|
1469
1486
|
const stripped = this.stripAnsi(output);
|
|
1487
|
+
if (!stripped.trim()) return false;
|
|
1488
|
+
if (this.detectLoading(stripped)) return false;
|
|
1470
1489
|
const hasWorkedFor = /Worked\s+for\s+\d+(?:h\s+\d{2}m\s+\d{2}s|m\s+\d{2}s|s)/.test(stripped);
|
|
1471
|
-
const
|
|
1472
|
-
|
|
1490
|
+
const hasComposerPrompt = /›\s+Ask\s+Codex\s+to\s+do\s+anything/.test(stripped) || /^\s*›\s*(?!\d+\.)\S.*$/m.test(stripped);
|
|
1491
|
+
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);
|
|
1492
|
+
if (hasWorkedFor && (hasComposerPrompt || hasIdleFooterHints)) {
|
|
1473
1493
|
return true;
|
|
1474
1494
|
}
|
|
1475
|
-
if (
|
|
1495
|
+
if (hasComposerPrompt) {
|
|
1476
1496
|
return true;
|
|
1477
1497
|
}
|
|
1478
|
-
if (hasWorkedFor &&
|
|
1498
|
+
if (hasWorkedFor && hasIdleFooterHints) {
|
|
1479
1499
|
return true;
|
|
1480
1500
|
}
|
|
1481
1501
|
return false;
|
|
1482
1502
|
}
|
|
1483
1503
|
detectReady(output) {
|
|
1484
1504
|
const stripped = this.stripAnsi(output);
|
|
1505
|
+
if (!stripped.trim()) return false;
|
|
1506
|
+
if (this.detectLoading(stripped)) return false;
|
|
1507
|
+
const tail = stripped.slice(-1200);
|
|
1508
|
+
const hasComposerPrompt = /^\s*›\s*(?!\d+\.)\S.*$/m.test(tail) || /›\s+Ask\s+Codex\s+to\s+do\s+anything/.test(tail);
|
|
1509
|
+
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);
|
|
1510
|
+
if (hasComposerPrompt || hasComposerFooter) {
|
|
1511
|
+
return true;
|
|
1512
|
+
}
|
|
1485
1513
|
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)) {
|
|
1486
1514
|
return false;
|
|
1487
1515
|
}
|
|
1488
|
-
if (/›\s+/m.test(stripped)) {
|
|
1489
|
-
return true;
|
|
1490
|
-
}
|
|
1491
1516
|
if (/explain this codebase|summarize recent commits|find and fix a bug/i.test(stripped)) {
|
|
1492
1517
|
return true;
|
|
1493
1518
|
}
|