forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAgentDetector.php
More file actions
62 lines (46 loc) · 1.15 KB
/
AgentDetector.php
File metadata and controls
62 lines (46 loc) · 1.15 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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php declare(strict_types = 1);
namespace PHPStan\Internal;
use function file_exists;
use function getenv;
use function is_string;
use function trim;
final class AgentDetector
{
public static function isRunningInAgent(): bool
{
// Copyright (c) Pushpak Chhajed pushpak1300@gmail.com
// from https://github.com/shipfastlabs/agent-detector/blob/98766473b2dfe183b0c2605ceb04e587a78d1872/src/AgentDetector.php
$aiAgent = getenv('AI_AGENT');
if (is_string($aiAgent) && trim($aiAgent) !== '') {
return true;
}
if (getenv('CURSOR_TRACE_ID') !== false) {
return true;
}
if (getenv('CURSOR_AGENT') !== false) {
return true;
}
if (getenv('GEMINI_CLI') !== false) {
return true;
}
if (getenv('CODEX_SANDBOX') !== false) {
return true;
}
if (getenv('AUGMENT_AGENT') !== false) {
return true;
}
if (getenv('OPENCODE_CLIENT') !== false || getenv('OPENCODE') !== false) {
return true;
}
if (getenv('CLAUDECODE') !== false || getenv('CLAUDE_CODE') !== false) {
return true;
}
if (getenv('REPL_ID') !== false) {
return true;
}
if (@file_exists('/opt/.devin')) {
return true;
}
return false;
}
}