Package com.databricks.jdbc.common.util
Class AgentDetector
- java.lang.Object
-
- com.databricks.jdbc.common.util.AgentDetector
-
public class AgentDetector extends Object
Detects whether the JDBC driver is being invoked by an AI coding agent by checking for well-known environment variables that agents set in their spawned shell processes.Detection only succeeds when exactly one agent environment variable is present, to avoid ambiguous attribution when multiple agent environments overlap.
Adding a new agent requires only a new constant and a new entry in
KNOWN_AGENTS.References for each environment variable:
- ANTIGRAVITY_AGENT: Closed source. Google Antigravity sets this variable.
- CLAUDECODE: https://github.com/anthropics/claude-code (sets CLAUDECODE=1)
- CLINE_ACTIVE: https://github.com/cline/cline (shipped in v3.24.0)
- CODEX_CI: https://github.com/openai/codex (part of UNIFIED_EXEC_ENV array in codex-rs)
- CURSOR_AGENT: Closed source. Referenced in a gist by johnlindquist.
- GEMINI_CLI: https://google-gemini.github.io/gemini-cli/docs/tools/shell.html (sets GEMINI_CLI=1)
- OPENCODE: https://github.com/opencode-ai/opencode (sets OPENCODE=1)
-
-
Field Summary
Fields Modifier and Type Field Description static StringANTIGRAVITYstatic StringCLAUDE_CODEstatic StringCLINEstatic StringCODEXstatic StringCURSORstatic StringGEMINI_CLIstatic StringOPEN_CODE
-
Constructor Summary
Constructors Constructor Description AgentDetector()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<String>detect()Detects which AI coding agent (if any) is driving the current process.
-
-
-
Field Detail
-
ANTIGRAVITY
public static final String ANTIGRAVITY
- See Also:
- Constant Field Values
-
CLAUDE_CODE
public static final String CLAUDE_CODE
- See Also:
- Constant Field Values
-
CLINE
public static final String CLINE
- See Also:
- Constant Field Values
-
CODEX
public static final String CODEX
- See Also:
- Constant Field Values
-
CURSOR
public static final String CURSOR
- See Also:
- Constant Field Values
-
GEMINI_CLI
public static final String GEMINI_CLI
- See Also:
- Constant Field Values
-
OPEN_CODE
public static final String OPEN_CODE
- See Also:
- Constant Field Values
-
-