detectAgentID returns the current AI agent based on environment signals.
()
| 1268 | |
| 1269 | // detectAgentID returns the current AI agent based on environment signals. |
| 1270 | func detectAgentID() string { |
| 1271 | // Claude Code sets CLAUDE_CODE=1 |
| 1272 | if os.Getenv("CLAUDE_CODE") == "1" || os.Getenv("CLAUDE_CODE_ENTRYPOINT") != "" { |
| 1273 | return "claude-code" |
| 1274 | } |
| 1275 | // Codex sets CODEX=1 |
| 1276 | if os.Getenv("CODEX") == "1" { |
| 1277 | return "codex" |
| 1278 | } |
| 1279 | // Cursor sets CURSOR_SESSION_ID |
| 1280 | if os.Getenv("CURSOR_SESSION_ID") != "" { |
| 1281 | return "cursor" |
| 1282 | } |
| 1283 | return "unknown" |
| 1284 | } |
| 1285 | |
| 1286 | // sessionStartTime estimates when this session started from daemon events. |
| 1287 | func sessionStartTime(state *watch.State) time.Time { |
no outgoing calls
no test coverage detected