grok-agent 0.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (141) hide show
  1. package/CHANGELOG.md +113 -0
  2. package/LICENSE +190 -0
  3. package/README.md +449 -0
  4. package/bin/grok-cli.js +26 -0
  5. package/dist/agent.d.ts +4 -0
  6. package/dist/agent.d.ts.map +1 -0
  7. package/dist/agent.js +898 -0
  8. package/dist/agent.js.map +1 -0
  9. package/dist/approvals.d.ts +4 -0
  10. package/dist/approvals.d.ts.map +1 -0
  11. package/dist/approvals.js +90 -0
  12. package/dist/approvals.js.map +1 -0
  13. package/dist/batch-api.d.ts +11 -0
  14. package/dist/batch-api.d.ts.map +1 -0
  15. package/dist/batch-api.js +101 -0
  16. package/dist/batch-api.js.map +1 -0
  17. package/dist/cli-errors.d.ts +6 -0
  18. package/dist/cli-errors.d.ts.map +1 -0
  19. package/dist/cli-errors.js +80 -0
  20. package/dist/cli-errors.js.map +1 -0
  21. package/dist/client.d.ts +6 -0
  22. package/dist/client.d.ts.map +1 -0
  23. package/dist/client.js +41 -0
  24. package/dist/client.js.map +1 -0
  25. package/dist/collections-api.d.ts +11 -0
  26. package/dist/collections-api.d.ts.map +1 -0
  27. package/dist/collections-api.js +144 -0
  28. package/dist/collections-api.js.map +1 -0
  29. package/dist/compaction.d.ts +11 -0
  30. package/dist/compaction.d.ts.map +1 -0
  31. package/dist/compaction.js +94 -0
  32. package/dist/compaction.js.map +1 -0
  33. package/dist/config.d.ts +12 -0
  34. package/dist/config.d.ts.map +1 -0
  35. package/dist/config.js +142 -0
  36. package/dist/config.js.map +1 -0
  37. package/dist/diff.d.ts +5 -0
  38. package/dist/diff.d.ts.map +1 -0
  39. package/dist/diff.js +80 -0
  40. package/dist/diff.js.map +1 -0
  41. package/dist/hooks.d.ts +11 -0
  42. package/dist/hooks.d.ts.map +1 -0
  43. package/dist/hooks.js +30 -0
  44. package/dist/hooks.js.map +1 -0
  45. package/dist/image.d.ts +8 -0
  46. package/dist/image.d.ts.map +1 -0
  47. package/dist/image.js +58 -0
  48. package/dist/image.js.map +1 -0
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.d.ts.map +1 -0
  51. package/dist/index.js +1264 -0
  52. package/dist/index.js.map +1 -0
  53. package/dist/json-output.d.ts +27 -0
  54. package/dist/json-output.d.ts.map +1 -0
  55. package/dist/json-output.js +62 -0
  56. package/dist/json-output.js.map +1 -0
  57. package/dist/notifications.d.ts +6 -0
  58. package/dist/notifications.d.ts.map +1 -0
  59. package/dist/notifications.js +25 -0
  60. package/dist/notifications.js.map +1 -0
  61. package/dist/project-context.d.ts +6 -0
  62. package/dist/project-context.d.ts.map +1 -0
  63. package/dist/project-context.js +34 -0
  64. package/dist/project-context.js.map +1 -0
  65. package/dist/response-utils.d.ts +10 -0
  66. package/dist/response-utils.d.ts.map +1 -0
  67. package/dist/response-utils.js +123 -0
  68. package/dist/response-utils.js.map +1 -0
  69. package/dist/server-tools.d.ts +7 -0
  70. package/dist/server-tools.d.ts.map +1 -0
  71. package/dist/server-tools.js +205 -0
  72. package/dist/server-tools.js.map +1 -0
  73. package/dist/session.d.ts +46 -0
  74. package/dist/session.d.ts.map +1 -0
  75. package/dist/session.js +305 -0
  76. package/dist/session.js.map +1 -0
  77. package/dist/stream.d.ts +22 -0
  78. package/dist/stream.d.ts.map +1 -0
  79. package/dist/stream.js +102 -0
  80. package/dist/stream.js.map +1 -0
  81. package/dist/system-prompt.d.ts +3 -0
  82. package/dist/system-prompt.d.ts.map +1 -0
  83. package/dist/system-prompt.js +64 -0
  84. package/dist/system-prompt.js.map +1 -0
  85. package/dist/tools/bash.d.ts +8 -0
  86. package/dist/tools/bash.d.ts.map +1 -0
  87. package/dist/tools/bash.js +49 -0
  88. package/dist/tools/bash.js.map +1 -0
  89. package/dist/tools/definitions.d.ts +3 -0
  90. package/dist/tools/definitions.d.ts.map +1 -0
  91. package/dist/tools/definitions.js +190 -0
  92. package/dist/tools/definitions.js.map +1 -0
  93. package/dist/tools/edit-file.d.ts +10 -0
  94. package/dist/tools/edit-file.d.ts.map +1 -0
  95. package/dist/tools/edit-file.js +73 -0
  96. package/dist/tools/edit-file.js.map +1 -0
  97. package/dist/tools/glob.d.ts +7 -0
  98. package/dist/tools/glob.d.ts.map +1 -0
  99. package/dist/tools/glob.js +44 -0
  100. package/dist/tools/glob.js.map +1 -0
  101. package/dist/tools/grep.d.ts +10 -0
  102. package/dist/tools/grep.d.ts.map +1 -0
  103. package/dist/tools/grep.js +102 -0
  104. package/dist/tools/grep.js.map +1 -0
  105. package/dist/tools/index.d.ts +10 -0
  106. package/dist/tools/index.d.ts.map +1 -0
  107. package/dist/tools/index.js +41 -0
  108. package/dist/tools/index.js.map +1 -0
  109. package/dist/tools/list-dir.d.ts +7 -0
  110. package/dist/tools/list-dir.d.ts.map +1 -0
  111. package/dist/tools/list-dir.js +68 -0
  112. package/dist/tools/list-dir.js.map +1 -0
  113. package/dist/tools/policy.d.ts +4 -0
  114. package/dist/tools/policy.d.ts.map +1 -0
  115. package/dist/tools/policy.js +36 -0
  116. package/dist/tools/policy.js.map +1 -0
  117. package/dist/tools/read-file.d.ts +8 -0
  118. package/dist/tools/read-file.d.ts.map +1 -0
  119. package/dist/tools/read-file.js +45 -0
  120. package/dist/tools/read-file.js.map +1 -0
  121. package/dist/tools/write-file.d.ts +7 -0
  122. package/dist/tools/write-file.d.ts.map +1 -0
  123. package/dist/tools/write-file.js +35 -0
  124. package/dist/tools/write-file.js.map +1 -0
  125. package/dist/truncation.d.ts +13 -0
  126. package/dist/truncation.d.ts.map +1 -0
  127. package/dist/truncation.js +55 -0
  128. package/dist/truncation.js.map +1 -0
  129. package/dist/types.d.ts +159 -0
  130. package/dist/types.d.ts.map +1 -0
  131. package/dist/types.js +2 -0
  132. package/dist/types.js.map +1 -0
  133. package/dist/usage.d.ts +17 -0
  134. package/dist/usage.d.ts.map +1 -0
  135. package/dist/usage.js +80 -0
  136. package/dist/usage.js.map +1 -0
  137. package/dist/voice-api.d.ts +16 -0
  138. package/dist/voice-api.d.ts.map +1 -0
  139. package/dist/voice-api.js +84 -0
  140. package/dist/voice-api.js.map +1 -0
  141. package/package.json +64 -0
package/README.md ADDED
@@ -0,0 +1,449 @@
1
+ # grok-agent
2
+
3
+ A coding assistant CLI powered by xAI's Grok models.
4
+
5
+ `grok-agent` gives you an agentic assistant in your terminal that can chat, inspect and edit code, run shell commands, search a repo, attach files/images, use xAI server-side tools, and keep JSONL-backed session history.
6
+
7
+ ## Features
8
+
9
+ - Exec mode: `grok-agent "fix the bug in utils.ts"`
10
+ - Interactive REPL: `grok-agent`
11
+ - Pipe mode: `git diff | grok-agent "review this patch"`
12
+ - Local tools: `bash`, `read_file`, `write_file`, `edit_file`, `glob`, `grep`, `list_directory`
13
+ - Session persistence with resume, fork, archive, rename, rollback, and compaction
14
+ - Ephemeral mode for no-history runs
15
+ - JSONL output mode for automation
16
+ - xAI server-side tools: web search, X search, code execution, file search, and MCP
17
+ - Search filters for domains, X handles, date ranges, and media understanding
18
+ - Collection management backed by xAI's management API
19
+ - Review mode for uncommitted diffs, branches, and commits
20
+ - Sandbox modes and per-tool approval overrides
21
+ - Batch API helpers and realtime client-secret creation
22
+ - Image inputs and file attachments
23
+ - Image generation, video generation, TTS voice listing, and streaming TTS
24
+ - Structured JSON output with `--json-schema`
25
+ - Token usage display, citations, approvals, hooks, and notifications
26
+
27
+ ## Quickstart
28
+
29
+ ```bash
30
+ # Prerequisites: Node.js >= 20 and an xAI API key
31
+
32
+ git clone https://github.com/baba20o/grok-agent.git
33
+ cd grok-agent
34
+ npm install
35
+ npm run build
36
+ npm link
37
+
38
+ export XAI_API_KEY=your_key_here
39
+ grok-agent doctor
40
+ grok-agent "what does this project do?"
41
+ ```
42
+
43
+ You can also place `XAI_API_KEY` in a local `.env` file. The CLI loads `.env` from:
44
+
45
+ - the current directory
46
+ - the parent directory
47
+ - `~/.grok-agent/.env`
48
+
49
+ ## Usage
50
+
51
+ ```text
52
+ grok-agent [options] [command] [prompt...]
53
+ ```
54
+
55
+ Key options:
56
+
57
+ - `-m, --model <model>`: use any specific model id
58
+ - `--fast`, `--reasoning`, `--non-reasoning`, `--code`, `--research`: model shortcuts
59
+ - `--max-turns <n>`: cap agent turns
60
+ - `--cwd <dir>`: change working directory
61
+ - `-r, --resume <id>`: resume a saved session
62
+ - `--fork <id>`: copy a session into a new one
63
+ - `-n, --name <name>`: assign a name to the session
64
+ - `--ephemeral`: run without saving session state
65
+ - `-o, --output <file>`: write final message to a file
66
+ - `--approve`, `--deny-writes`, `--yolo`: approval policy
67
+ - `--sandbox <mode>`: `read-only`, `workspace-write`, or `danger-full-access`
68
+ - `--plan`: ask the model to plan before execution
69
+ - `--json`: machine-readable JSONL events on stdout
70
+ - `--json-schema <schema>`: require structured output
71
+ - `--color <mode>`: set color output mode (`auto`, `always`, `never`)
72
+ - `--web-search`, `--x-search`, `--code-execution`: enable xAI server-side tools
73
+ - `--allow-domain`, `--exclude-domain`, `--search-images`: web search controls
74
+ - `--x-allow`, `--x-exclude`, `--x-from`, `--x-to`, `--x-images`, `--x-videos`: X search controls
75
+ - `--collection <id>` and `--file-search-mode <mode>`: enable file search over xAI collections
76
+ - `--include-tool-outputs`, `--show-server-tool-usage`: expose server-side tool output and usage
77
+ - `--mcp <urls...>`: connect remote MCP servers
78
+ - `--mcp-allow <label=tool1,tool2>`: restrict MCP tools per server
79
+ - `--mcp-desc <label=description>`: attach MCP server descriptions
80
+ - `--image <paths...>`: attach images
81
+ - `--attach <files...>`: upload files
82
+ - `--show-reasoning`, `--show-usage`, `--show-diffs`, `--no-diffs`, `--no-citations`, `--no-tools`
83
+ - `-v, --verbose`: output detailed tool calls
84
+ - `--notify`: desktop notification on completion
85
+ - `--responses-api`: force the Responses API
86
+ - `--defer`: fire-and-forget deferred completion
87
+
88
+ Full help:
89
+
90
+ ```bash
91
+ grok-agent --help
92
+ ```
93
+
94
+ ## Commands
95
+
96
+ | Command | Description |
97
+ |---|---|
98
+ | `models` | List models or inspect a specific model |
99
+ | `sessions` | List, show, archive, rename, rollback, compact, delete, or clear saved sessions |
100
+ | `review` | Run Grok in code review mode for local changes, branches, or commits |
101
+ | `generate-image` / `imagine` | Generate images |
102
+ | `generate-video` / `video` | Generate video |
103
+ | `speak` / `tts` | Convert text to speech |
104
+ | `tts-voices` | List currently available TTS voices |
105
+ | `collections` | Manage xAI document collections and their documents |
106
+ | `batch` | Create, inspect, cancel, and feed Batch API jobs |
107
+ | `realtime` | Create ephemeral realtime client secrets |
108
+ | `doctor` | Validate setup, API key, and session storage |
109
+ | `tokenize` | Count tokens for text |
110
+ | `config` | Show config or create a default config file |
111
+
112
+ Examples:
113
+
114
+ ```bash
115
+ grok-agent models ls
116
+ grok-agent models info grok-4-1-fast-reasoning
117
+
118
+ grok-agent sessions list
119
+ grok-agent sessions show <id>
120
+ grok-agent sessions archive <id>
121
+ grok-agent sessions rename <id> "new name"
122
+ grok-agent sessions rollback <id> --turns 2
123
+ grok-agent sessions compact <id>
124
+ grok-agent sessions delete <id>
125
+
126
+ grok-agent review --base origin/main
127
+ grok-agent review --commit HEAD~1
128
+
129
+ grok-agent config --init
130
+ grok-agent config
131
+ ```
132
+
133
+ ## Model Selection
134
+
135
+ You can change models in three ways:
136
+
137
+ 1. One-off on the command line:
138
+
139
+ ```bash
140
+ grok-agent -m grok-4-1-fast-reasoning "summarize this repo"
141
+ grok-agent --code "fix the TypeScript errors"
142
+ grok-agent --reasoning "design a migration plan"
143
+ ```
144
+
145
+ 2. Via environment:
146
+
147
+ ```bash
148
+ export GROK_MODEL=grok-code-fast-1
149
+ ```
150
+
151
+ 3. Via config file:
152
+
153
+ ```json
154
+ {
155
+ "model": "grok-code-fast-1"
156
+ }
157
+ ```
158
+
159
+ Selection precedence is:
160
+
161
+ `CLI flag` > `config.json` > `GROK_MODEL` > built-in default
162
+
163
+ Current built-in aliases:
164
+
165
+ | Flag | Model |
166
+ |---|---|
167
+ | `--fast` | `grok-4-1-fast-reasoning` |
168
+ | `--reasoning` | `grok-4.20-0309-reasoning` |
169
+ | `--non-reasoning` | `grok-4.20-0309-non-reasoning` |
170
+ | `--code` | `grok-code-fast-1` |
171
+ | `--research` | `grok-4.20-multi-agent-0309` |
172
+
173
+ To see what your API key can actually use:
174
+
175
+ ```bash
176
+ grok-agent models ls
177
+ ```
178
+
179
+ ## Examples
180
+
181
+ ### Coding
182
+
183
+ ```bash
184
+ grok-agent "fix the failing tests in src/utils.ts"
185
+ grok-agent --code "refactor this module to use async/await"
186
+ grok-agent --reasoning "design a caching layer for the API"
187
+ grok-agent --plan "add a config migration for the new schema"
188
+ ```
189
+
190
+ ### Interactive
191
+
192
+ ```bash
193
+ grok-agent
194
+ grok-agent --ephemeral
195
+ grok-agent -r <session-id>
196
+ ```
197
+
198
+ ### Research
199
+
200
+ ```bash
201
+ grok-agent --research "compare React Server Components vs Astro Islands"
202
+ grok-agent --web-search "what changed in Node.js 22"
203
+ grok-agent --x-search "what are developers saying about Bun"
204
+ grok-agent --web-search --allow-domain docs.x.ai --search-images "summarize the docs homepage"
205
+ grok-agent --x-search --x-allow xai --x-from 2026-03-01 --x-to 2026-03-29 "recent Grok platform updates"
206
+ grok-agent --collection engineering-handbook "find the deploy checklist"
207
+ ```
208
+
209
+ ### Images and Files
210
+
211
+ ```bash
212
+ grok-agent --image screenshot.png "what is wrong with this UI?"
213
+ grok-agent --attach spec.pdf "implement the auth flow from this spec"
214
+ grok-agent --attach data.csv "summarize the anomalies in this dataset"
215
+ ```
216
+
217
+ ### Generation
218
+
219
+ ```bash
220
+ grok-agent imagine "a minimalist logo for a CLI tool"
221
+ grok-agent imagine --pro "photorealistic laptop on a desk"
222
+ grok-agent video --duration 8 --aspect 16:9 "a futuristic terminal UI"
223
+ grok-agent tts --voice eve "Build completed successfully."
224
+ grok-agent tts --stream --codec mp3 --voice leo "Streaming speech sample"
225
+ grok-agent tts-voices
226
+ ```
227
+
228
+ ### MCP
229
+
230
+ ```bash
231
+ grok-agent --mcp https://mcp.deepwiki.com/mcp "explain this repository"
232
+ grok-agent --mcp wiki=https://mcp.deepwiki.com/mcp --mcp custom=https://my-tools.example/mcp "research task"
233
+ grok-agent --mcp wiki=https://mcp.deepwiki.com/mcp --mcp-allow wiki=search,read_page --mcp-desc wiki="Team wiki" "find release notes"
234
+ ```
235
+
236
+ ### Structured Output and JSON Mode
237
+
238
+ ```bash
239
+ grok-agent --json-schema '{"type":"object","properties":{"files":{"type":"array","items":{"type":"string"}}}}' \
240
+ "list the source files touched by session persistence"
241
+
242
+ grok-agent --json --ephemeral "say hi in one short sentence"
243
+ ```
244
+
245
+ ### Collections
246
+
247
+ ```bash
248
+ grok-agent collections list
249
+ grok-agent collections create "Engineering Docs"
250
+ grok-agent collections upload col_123 handbook.pdf
251
+ grok-agent collections search col_123 "on-call rotation policy"
252
+ grok-agent --collection col_123 "summarize the deployment runbook"
253
+ ```
254
+
255
+ Collection management requires `XAI_MANAGEMENT_API_KEY`.
256
+
257
+ ### Batch + Realtime
258
+
259
+ ```bash
260
+ grok-agent batch list --limit 20
261
+ grok-agent batch create nightly-evals
262
+ grok-agent batch add-chat batch_123 "summarize this issue thread"
263
+ grok-agent batch results batch_123 --limit 10
264
+ grok-agent realtime secret --seconds 600
265
+ ```
266
+
267
+ ### Tokenization
268
+
269
+ ```bash
270
+ grok-agent tokenize "fix the bug in approvals.ts"
271
+ grok-agent tokenize -m grok-code-fast-1 "class User { constructor() {} }"
272
+ ```
273
+
274
+ ## Sessions
275
+
276
+ Sessions are stored as JSONL files under:
277
+
278
+ - `GROK_SESSION_DIR/sessions`
279
+ - or `~/.grok-agent/sessions` by default
280
+
281
+ Useful commands:
282
+
283
+ ```bash
284
+ grok-agent sessions list
285
+ grok-agent sessions list --all
286
+ grok-agent sessions show <id>
287
+ grok-agent -r <id> "follow-up question"
288
+ grok-agent --fork <id> "continue on a new branch of thought"
289
+ grok-agent sessions archive <id>
290
+ grok-agent sessions unarchive <id>
291
+ grok-agent sessions rename <id> "better title"
292
+ grok-agent sessions rollback <id> --turns 1
293
+ grok-agent sessions compact <id>
294
+ grok-agent sessions clear
295
+ ```
296
+
297
+ If you do not want any session state written, use:
298
+
299
+ ```bash
300
+ grok-agent --ephemeral "one-off task"
301
+ ```
302
+
303
+ ## Configuration
304
+
305
+ Create a starter config file:
306
+
307
+ ```bash
308
+ grok-agent config --init
309
+ ```
310
+
311
+ That writes `config.json` under your session dir (`GROK_SESSION_DIR` or `~/.grok-agent`).
312
+
313
+ Supported config fields currently include:
314
+
315
+ ```json
316
+ {
317
+ "model": "grok-4-1-fast-reasoning",
318
+ "approval_policy": "always-approve",
319
+ "sandbox_mode": "workspace-write",
320
+ "show_usage": false,
321
+ "show_diffs": true,
322
+ "show_citations": true,
323
+ "show_server_tool_usage": false,
324
+ "include_tool_outputs": false,
325
+ "notify": false,
326
+ "max_turns": 50,
327
+ "management_api_key": "",
328
+ "management_base_url": "https://management-api.x.ai/v1",
329
+ "mcp_servers": [
330
+ {
331
+ "label": "wiki",
332
+ "url": "https://mcp.deepwiki.com/mcp",
333
+ "description": "Team wiki",
334
+ "allowedTools": ["search", "read_page"]
335
+ }
336
+ ],
337
+ "tool_approvals": {
338
+ "defaultMode": "ask",
339
+ "tools": {
340
+ "bash": "allow",
341
+ "write_file": "deny"
342
+ }
343
+ },
344
+ "server_tools": [
345
+ {
346
+ "type": "web_search",
347
+ "filters": {
348
+ "allowedDomains": ["docs.x.ai"]
349
+ },
350
+ "includeSources": true
351
+ },
352
+ {
353
+ "type": "file_search",
354
+ "collectionIds": ["col_123"],
355
+ "retrievalMode": "hybrid",
356
+ "includeResults": true
357
+ }
358
+ ],
359
+ "hooks": {
360
+ "pre-tool": ["echo pre"],
361
+ "post-tool": ["echo post"]
362
+ }
363
+ }
364
+ ```
365
+
366
+ Environment variables:
367
+
368
+ | Variable | Description | Default |
369
+ |---|---|---|
370
+ | `XAI_API_KEY` | xAI API key | required |
371
+ | `XAI_MANAGEMENT_API_KEY` | xAI management API key for collections | unset |
372
+ | `XAI_BASE_URL` | API base URL | `https://api.x.ai/v1` |
373
+ | `XAI_MANAGEMENT_BASE_URL` | management API base URL | `https://management-api.x.ai/v1` |
374
+ | `GROK_MODEL` | default model | `grok-4-1-fast-reasoning` |
375
+ | `GROK_SESSION_DIR` | base dir for sessions and config | `~/.grok-agent` |
376
+ | `GROK_SANDBOX_MODE` | default sandbox mode | `danger-full-access` |
377
+
378
+ ## Tools
379
+
380
+ ### Local Tools
381
+
382
+ | Tool | Description |
383
+ |---|---|
384
+ | `bash` | Run shell commands |
385
+ | `read_file` | Read file contents |
386
+ | `write_file` | Create or overwrite files |
387
+ | `edit_file` | Exact find-and-replace edits |
388
+ | `glob` | Find files by glob |
389
+ | `grep` | Search file contents by regex |
390
+ | `list_directory` | List directory contents |
391
+
392
+ ### xAI Server-Side Tools
393
+
394
+ | Tool | CLI support |
395
+ |---|---|
396
+ | Web Search | `--web-search`, `--allow-domain`, `--exclude-domain`, `--search-images` |
397
+ | X Search | `--x-search`, `--x-allow`, `--x-exclude`, `--x-from`, `--x-to`, `--x-images`, `--x-videos` |
398
+ | Code Execution | `--code-execution` |
399
+ | File Search | `--collection <id>`, `--file-search-mode <mode>` |
400
+ | Remote MCP | `--mcp <url>`, `--mcp-allow`, `--mcp-desc` |
401
+
402
+ ## Development
403
+
404
+ ```bash
405
+ npm run lint
406
+ npm run build
407
+ npm test
408
+ ```
409
+
410
+ Source layout:
411
+
412
+ ```text
413
+ src/
414
+ ├── index.ts CLI entry and subcommands
415
+ ├── agent.ts Agent loop and interactive mode
416
+ ├── client.ts xAI client wrapper
417
+ ├── cli-errors.ts Shared CLI/network/session error formatting
418
+ ├── config.ts Config and .env loading
419
+ ├── server-tools.ts Typed server-tool normalization and serialization
420
+ ├── session.ts JSONL session persistence
421
+ ├── json-output.ts JSONL event output
422
+ ├── approvals.ts Approval policy checks
423
+ ├── hooks.ts Hook execution
424
+ ├── compaction.ts Conversation compaction
425
+ ├── truncation.ts Tool output truncation and token estimation
426
+ ├── system-prompt.ts Dynamic system prompt
427
+ ├── collections-api.ts xAI collections management helpers
428
+ ├── batch-api.ts Batch API helpers
429
+ ├── voice-api.ts TTS and realtime helpers
430
+ ├── project-context.ts Optional repo context loading
431
+ ├── image.ts Image input helpers
432
+ ├── notifications.ts Desktop notification support
433
+ ├── usage.ts Usage accounting
434
+ └── tools/
435
+ ├── index.ts
436
+ ├── definitions.ts
437
+ ├── bash.ts
438
+ ├── read-file.ts
439
+ ├── write-file.ts
440
+ ├── edit-file.ts
441
+ ├── glob.ts
442
+ ├── grep.ts
443
+ ├── list-dir.ts
444
+ └── policy.ts
445
+ ```
446
+
447
+ ## License
448
+
449
+ Apache-2.0
@@ -0,0 +1,26 @@
1
+ #!/usr/bin/env node
2
+
3
+ // Entry point — delegates to compiled TypeScript or tsx in development
4
+ import { pathToFileURL, fileURLToPath } from "node:url";
5
+ import { dirname, join } from "node:path";
6
+ import { existsSync } from "node:fs";
7
+
8
+ const __dirname = dirname(fileURLToPath(import.meta.url));
9
+ const distEntry = join(__dirname, "..", "dist", "index.js");
10
+ const srcEntry = join(__dirname, "..", "src", "index.ts");
11
+
12
+ if (existsSync(distEntry)) {
13
+ // Production: run compiled JS — use file:// URL for Windows compatibility
14
+ await import(pathToFileURL(distEntry).href);
15
+ } else {
16
+ // Development: run via tsx
17
+ const { execFileSync } = await import("node:child_process");
18
+ try {
19
+ execFileSync("npx", ["tsx", srcEntry, ...process.argv.slice(2)], {
20
+ stdio: "inherit",
21
+ cwd: process.cwd(),
22
+ });
23
+ } catch (err) {
24
+ process.exit(err.status || 1);
25
+ }
26
+ }
@@ -0,0 +1,4 @@
1
+ import type { GrokConfig, AgentOptions } from "./types.js";
2
+ export declare function runAgent(config: GrokConfig, prompt: string, options: AgentOptions): Promise<string>;
3
+ export declare function runInteractive(config: GrokConfig, options: AgentOptions): Promise<void>;
4
+ //# sourceMappingURL=agent.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"agent.d.ts","sourceRoot":"","sources":["../src/agent.ts"],"names":[],"mappings":"AA+CA,OAAO,KAAK,EACV,UAAU,EAGV,YAAY,EAKb,MAAM,YAAY,CAAC;AAqgBpB,wBAAsB,QAAQ,CAC5B,MAAM,EAAE,UAAU,EAClB,MAAM,EAAE,MAAM,EACd,OAAO,EAAE,YAAY,GACpB,OAAO,CAAC,MAAM,CAAC,CA0FjB;AAED,wBAAsB,cAAc,CAAC,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAqS7F"}