forked from TicketSwap/phpstan-error-formatter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAgentDetector.php
More file actions
39 lines (32 loc) · 1.06 KB
/
Copy pathAgentDetector.php
File metadata and controls
39 lines (32 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
<?php
declare(strict_types=1);
namespace TicketSwap\PHPStanErrorFormatter;
// Copied from https://github.com/shipfastlabs/agent-detector/blob/main/src/AgentDetector.php
final class AgentDetector
{
public static function isAgent() : bool
{
$aiAgent = getenv('AI_AGENT');
if (is_string($aiAgent) && trim($aiAgent) !== '') {
return true;
}
$agentsWithEnvVars = [
'cursor' => ['CURSOR_AGENT'],
'gemini' => ['GEMINI_CLI'],
'codex' => ['CODEX_SANDBOX', 'CODEX_THREAD_ID'],
'augment-cli' => ['AUGMENT_AGENT'],
'opencode' => ['OPENCODE_CLIENT', 'OPENCODE'],
'amp' => ['AMP_CURRENT_THREAD_ID'],
'claude' => ['CLAUDECODE', 'CLAUDE_CODE'],
'replit' => ['REPL_ID'],
];
foreach ($agentsWithEnvVars as $envVars) {
foreach ($envVars as $envVar) {
if (getenv($envVar) !== false) {
return true;
}
}
}
return file_exists('/opt/.devin');
}
}