File tree Expand file tree Collapse file tree 1 file changed +62
-0
lines changed
Expand file tree Collapse file tree 1 file changed +62
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php declare (strict_types = 1 );
2+
3+ namespace PHPStan \Internal ;
4+
5+ use function file_exists ;
6+ use function getenv ;
7+ use function is_string ;
8+ use function trim ;
9+
10+ final class AgentDetector
11+ {
12+
13+ public static function isRunningInAgent (): bool
14+ {
15+ // Copyright (c) Pushpak Chhajed pushpak1300@gmail.com
16+ // from https://github.com/shipfastlabs/agent-detector/blob/98766473b2dfe183b0c2605ceb04e587a78d1872/src/AgentDetector.php
17+
18+ $ aiAgent = getenv ('AI_AGENT ' );
19+ if (is_string ($ aiAgent ) && trim ($ aiAgent ) !== '' ) {
20+ return true ;
21+ }
22+
23+ if (getenv ('CURSOR_TRACE_ID ' ) !== false ) {
24+ return true ;
25+ }
26+
27+ if (getenv ('CURSOR_AGENT ' ) !== false ) {
28+ return true ;
29+ }
30+
31+ if (getenv ('GEMINI_CLI ' ) !== false ) {
32+ return true ;
33+ }
34+
35+ if (getenv ('CODEX_SANDBOX ' ) !== false ) {
36+ return true ;
37+ }
38+
39+ if (getenv ('AUGMENT_AGENT ' ) !== false ) {
40+ return true ;
41+ }
42+
43+ if (getenv ('OPENCODE_CLIENT ' ) !== false || getenv ('OPENCODE ' ) !== false ) {
44+ return true ;
45+ }
46+
47+ if (getenv ('CLAUDECODE ' ) !== false || getenv ('CLAUDE_CODE ' ) !== false ) {
48+ return true ;
49+ }
50+
51+ if (getenv ('REPL_ID ' ) !== false ) {
52+ return true ;
53+ }
54+
55+ if (file_exists ('/opt/.devin ' )) {
56+ return true ;
57+ }
58+
59+ return false ;
60+ }
61+
62+ }
You can’t perform that action at this time.
0 commit comments