detect-agent-sync
v0.1.0
Published
Synchronous AI agent environment detection via environment variables.
Maintainers
Readme
detect-agent-sync
Synchronously detect whether the current process is running inside an AI agent or automated coding environment.
Install
npm install detect-agent-syncUsage
const detectAgent = require("detect-agent-sync");
const agent = detectAgent();
if (agent) {
console.log(`Running in ${agent}`);
} else {
console.log("No agent detected");
}API
Function detectAgent([envVars]) returns the detected agent name as a string, or undefined if no supported agent environment is found.
envVars is an optional object of environment variables to inspect. If omitted, the function uses process.env.
Below are agents (and strings) that can be detected, in order of detection:
- Custom agents via environment variable
AI_AGENT - Antigravity (
antigravity) - Augment (
augment) - Claude Code (
claude-code) - Cline (
cline) - Codex (
codex) - Cursor (
cursor) - Devin (
devin) - Gemini (
gemini) - GitHub Copilot (
github-copilot) - Goose (
goose) - Junie (
junie) - Kiro (
kiro) - OpenClaw (
openclaw) - OpenCode (
opencode) - Pi (
pi) - Replit (
replit)
