Compare commits

..
4 Commits
Author SHA1 Message Date
David Mokos d2f8b90f53 adds Grok Bot environment detection (#21)
Grok Bot sets CURSOR_AGENT alongside SAND_BOX_BOOT_ID and SAND_BOX_STORE_ID, so it is matched before Cursor. Session ids still come from CURSOR_CONVERSATION_ID.
2026-10-24 03:10:00 -07:00
David Mokos e308d262b1 adds Factory Droid detection (#20) 2026-09-24 04:58:40 -07:00
David Mokos 09f4c420ad adds Grok environment detection (#19) 2026-08-24 23:30:14 +02:00
David Mokos 9205525ad4 adds Muse Code environment detection (#18) 2026-08-17 18:02:47 +02:00
6 changed files with 137 additions and 4 deletions

No files matched your search

+8 -1
View File
@@ -41,15 +41,21 @@ Officially supported coding agents:
| [Codex](https://developers.openai.com/codex/) | `codex` | ✅ |
| [Cursor](https://cursor.com/) | `cursor` | ✅ |
| [Devin](https://devin.ai/) | `devin` | 🚫 |
| [Factory Droid](https://docs.factory.ai/droid-cli/overview) | `droid` | 🚫 |
| [Gemini CLI](https://github.com/google-gemini/gemini-cli) | `gemini` | 🚫 |
| [GitHub Copilot CLI](https://github.com/github/copilot-cli) | `copilot` | ✅ |
| [Grok](https://x.ai/build) | `grok` | ✅ |
| [Grok Bot](https://x.ai/bot) | `grok-bot` | ✅ |
| [Kilo Code](https://kilocode.ai/) | `kilocode` | ✅ |
| [Kiro](https://kiro.dev/) | `kiro` | ✅ |
| [Muse Code][muse-code] | `muse` | 🚫 |
| [OpenCode](https://opencode.ai/) | `opencode` | 🚫 |
| [Pi](https://github.com/badlogic/pi-mono) | `pi` | 🚫 |
| [Replit](https://replit.com/) | `replit` | ✅ |
| [Rork](https://rork.com/) | `rork` | 🚫 |
[muse-code]: https://developer.meta.com/ai/products/muse-code/
Detection is data-driven: the exact environment variables and process
patterns for each agent live in [`src/agents.ts`](src/agents.ts).
@@ -98,7 +104,8 @@ A string containing the agent's session identifier, normalized from
agent-specific environment variables such as `CODEX_THREAD_ID`,
`CURSOR_CONVERSATION_ID`, `CLAUDE_CODE_SESSION_ID`,
`ANTIGRAVITY_TRAJECTORY_ID`, `KIRO_SESSION_ID`, `KILO_RUN_ID`, and
`COPILOT_AGENT_SESSION_ID`, and `REPLIT_SESSION`. Omitted when the agent doesn't expose one
`COPILOT_AGENT_SESSION_ID`, `REPLIT_SESSION`, and `GROK_SESSION_ID`.
Omitted when the agent doesn't expose one
(see the Session ID column in the support table above).
### `isRunningFromAgent([options])`
+2 -2
View File
@@ -1,12 +1,12 @@
{
"name": "agent-cli-detector",
"version": "0.1.5",
"version": "0.1.8",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "agent-cli-detector",
"version": "0.1.5",
"version": "0.1.8",
"license": "MIT",
"bin": {
"agent-cli-detector": "dist/cli.js"
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "agent-cli-detector",
"version": "0.1.5",
"version": "0.1.8",
"description": "Detect whether a JavaScript CLI is running inside a coding agent.",
"type": "module",
"sideEffects": false,
+28
View File
@@ -12,6 +12,15 @@ export const defaultAgents = [
process: [{ pattern: /^codex$/i }],
sessionEnv: ["CODEX_THREAD_ID"]
},
{
id: "grok-bot",
name: "Grok Bot",
env: [
{ name: "SAND_BOX_BOOT_ID" },
{ name: "SAND_BOX_STORE_ID" }
],
sessionEnv: ["CURSOR_CONVERSATION_ID"]
},
{
id: "cursor",
name: "Cursor",
@@ -46,12 +55,26 @@ export const defaultAgents = [
name: "Devin",
process: [{ pattern: /devin/i }]
},
{
id: "droid",
name: "Factory Droid",
env: [{ name: "FACTORY_ENV", value: "production" }]
},
{
id: "gemini",
name: "Gemini CLI",
env: [{ name: "GEMINI_CLI", value: "1" }],
process: [{ pattern: /^gemini$/i }]
},
{
id: "grok",
name: "Grok",
env: [
{ name: "GROK_AGENT", value: "1" },
{ name: "GROK_SESSION_ID" }
],
sessionEnv: ["GROK_SESSION_ID"]
},
{
id: "antigravity",
name: "Antigravity",
@@ -94,6 +117,11 @@ export const defaultAgents = [
process: [{ pattern: /kiro/i }],
sessionEnv: ["KIRO_SESSION_ID"]
},
{
id: "muse",
name: "Muse Code",
env: [{ name: "MUSE_RELEASE_INFO" }]
},
{
id: "cline",
name: "Cline",
+4
View File
@@ -6,10 +6,14 @@ export type AgentId =
| "copilot"
| "cursor"
| "devin"
| "droid"
| "gemini"
| "grok"
| "grok-bot"
| "kiro"
| "kilocode"
| "claude-code"
| "muse"
| "opencode"
| "pi"
| "replit"
+94
View File
@@ -64,6 +64,83 @@ test("detects replit and normalizes its session id", () => {
});
});
test("detects grok and normalizes its session id", () => {
const result = detectAgent({
env: {
GROK_AGENT: "1",
GROK_SESSION_ID: "01a035a8-166c-7771-8e5e-f67e0dd98c83"
}
});
assert.equal(result.detected, true);
assert.deepEqual(result.agent, {
id: "grok",
name: "Grok",
sessionId: "01a035a8-166c-7771-8e5e-f67e0dd98c83"
});
});
test("detects Grok Bot from SAND_BOX_BOOT_ID and normalizes the conversation id", () => {
const result = detectAgent({
env: {
CURSOR_AGENT: "1",
CURSOR_CONVERSATION_ID: "conversation-123",
SAND_BOX_BOOT_ID: "boot-456"
}
});
assert.equal(result.detected, true);
assert.deepEqual(result.agent, {
id: "grok-bot",
name: "Grok Bot",
sessionId: "conversation-123"
});
});
test("detects cursor from CURSOR_AGENT without Grok Bot signals", () => {
const result = detectAgent({
env: {
CURSOR_AGENT: "1",
CURSOR_CONVERSATION_ID: "conversation-123"
}
});
assert.equal(result.detected, true);
assert.deepEqual(result.agent, {
id: "cursor",
name: "Cursor",
sessionId: "conversation-123"
});
});
test("detects Grok Bot from SAND_BOX_STORE_ID alone", () => {
const result = detectAgent({
env: {
SAND_BOX_STORE_ID: "store-789"
}
});
assert.equal(result.detected, true);
assert.deepEqual(result.agent, {
id: "grok-bot",
name: "Grok Bot"
});
});
test("detects Factory Droid from FACTORY_ENV", () => {
const result = detectAgent({
env: {
FACTORY_ENV: "production"
}
});
assert.equal(result.detected, true);
assert.deepEqual(result.agent, {
id: "droid",
name: "Factory Droid"
});
});
test("detects rork from RORK_API_URL", () => {
const result = detectAgent({
env: {
@@ -78,6 +155,23 @@ test("detects rork from RORK_API_URL", () => {
});
});
test("detects Muse Code from MUSE_RELEASE_INFO", () => {
const result = detectAgent({
env: {
MUSE_RELEASE_INFO: JSON.stringify({
channel: "muse-stable",
version: "0.1.0-R708.1"
})
}
});
assert.equal(result.detected, true);
assert.deepEqual(result.agent, {
id: "muse",
name: "Muse Code"
});
});
test("detects bolt from any known environment variable", () => {
for (const envName of ["BOLT_ENV", "BOLT_ORIGIN", "BOLT_SERVER_URL"]) {
const result = detectAgent({