Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ Officially supported coding agents:
| [Devin](https://devin.ai/) | `devin` | 🚫 |
| [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` | ✅ |
| [Kilo Code](https://kilocode.ai/) | `kilocode` | ✅ |
| [Kiro](https://kiro.dev/) | `kiro` | ✅ |
| [Muse Code][muse-code] | `muse` | 🚫 |
Expand Down Expand Up @@ -101,7 +102,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])`
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "agent-cli-detector",
"version": "0.1.6",
"version": "0.1.7",
"description": "Detect whether a JavaScript CLI is running inside a coding agent.",
"type": "module",
"sideEffects": false,
Expand Down
9 changes: 9 additions & 0 deletions src/agents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,15 @@ export const defaultAgents = [
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",
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type AgentId =
| "cursor"
| "devin"
| "gemini"
| "grok"
| "kiro"
| "kilocode"
| "claude-code"
Expand Down
16 changes: 16 additions & 0 deletions test/detector.test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,22 @@ 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 rork from RORK_API_URL", () => {
const result = detectAgent({
env: {
Expand Down
Loading