返回 html-video
grok.ts
根目录 / packages / runtime / src / defs / grok.ts
1 import type { AgentDef } from '../types.js';
2
3 /**
4 * Grok Build def (`grok`, by xAI — x.ai/cli; OD labels it "Grok Build (xAI)").
5 *
6 * This is xAI's OFFICIAL CLI, not the community `superagent-ai/grok-cli`.
7 * Confirmed locally against grok 0.1.212 (`grok --help`, 2026-06-04):
8 * -p, --single <PROMPT> "Single-turn prompt. Prints the response to
9 * stdout and exits" ← exactly our headless path
10 * --output-format <fmt> [default: plain] (plain | json | streaming-json)
11 * -v, --version
12 * Prompt is an argv value of `-p` (no stdin pipe option), so it goes into
13 * buildArgs and promptViaStdin stays off — same shape as hermes/aider.
14 *
15 * Default output is plain text, which the studio extractor reads for the
16 * fenced ```html``` block.
17 *
18 * Note: Grok Build is early beta and gated behind SuperGrok / X Premium+ —
19 * detection finds the bin, but an un-signed-in user gets an OAuth prompt on
20 * first run (surfaced in chat).
21 */
22 export const grok: AgentDef = {
23 id: 'grok',
24 name: 'Grok Build (xAI)',
25 bin: 'grok',
26 versionArgs: ['--version'],
27 buildArgs(prompt, _ctx) {
28 // -p/--single: single-turn headless; prompt is the argv value.
29 return ['-p', prompt];
30 },
31 streamFormat: 'plain',
32 installUrl: 'https://x.ai/cli',
33 };
34
34 lines TYPESCRIPT