· ENPT-BR
Grok Build for Alembic · Integration mechanics

AgentProvider: command, stdin, parser

Walk the clean-room TypeScript seam from prompt to parsed Factory result.

Primary source
Pinned headless mode guide

Pinned upstream commit: b189869b7755d2b482969acf6c92da3ecfeffd36

The Simple layer stands alone; open Technical for exact contracts and edge cases.
You will be able to
  • Read the AgentProvider contract as a narrow waist.
  • Explain why prompts travel through `/dev/stdin`.
  • Distinguish provider options from production model routing.
1

The big idea


The provider has two jobs. Before launch, it turns Factory options into a safe Grok command and sends the prompt through standard input. During the run, it translates each JSONL line into Alembic's small event vocabulary. Everything else—sandbox launch, timeout, accumulation, and result return—stays with Factory.

Think of it like… The provider is an electrical plug adapter: it changes the shape at the boundary without rebuilding either appliance or wall. It breaks because the adapter also validates unsupported session behavior and translates a live event stream.

`buildPrintCommand` returns a shell command plus optional stdin. The prompt never enters argv, avoiding shell interpretation and per-argument size limits. The model and enum-like flags are shell-escaped. Factory's public AFK `run()` path requests permission bypass; containment remains the SandboxProvider's job.

The provider always disables Grok's built-in web search so Alembic research stays on the Bright Data CLI. Optional effort and environment map to the CLI; the fixed production roster remains unchanged. In the AFK run path, approval bypass is requested by the Orchestrator and containment comes from SandboxProvider.

Evidence: Pinned headless mode guide

Factory runAgentProvideroptionsshellEscapecommand Safe: shell-escape model/flags and place the prompt in stdin.
Walk the clean-room TypeScript seam from prompt to parsed Factory result.
2

Compare the boundaries


Safe
Safe: shell-escape model/flags and place the prompt in stdin.
Risky
Risky: interpolate user prompt into a shell command string.
SurfaceUpstreamAlembicVerdict
Prompt transportCould be inline argv`--prompt-file /dev/stdin`STDIN
PermissionsCLI supports approval modesAFK run requests bypass; sandbox containsLAYERED
RoutingProvider can be constructedFixed roster unchangedSEPARATE

The provider always disables Grok's built-in web search so Alembic research stays on the Bright Data CLI. Optional effort and environment map to the CLI; the fixed production roster remains unchanged. In the AFK run path, approval bypass is requested by the Orchestrator and containment comes from SandboxProvider.

3

Real code and commands


packages/factory/src/GrokAgentProvider.ts
return {
  command: `grok --prompt-file /dev/stdin \
--output-format streaming-json --model ${shellEscape(model)} \
--disable-web-search`,
  stdin: prompt,
};
How to reach it
sed -n '1,170p' packages/factory/src/GrokAgentProvider.ts
rg -n "export.*grok|GrokOptions" packages/factory/src/index.ts

Evidence: RESOURCES.md

4

Visual atlas


inputproofFactory run
Trace the boundary: Factory run.
surfaceseamownerAgentProvider
Locate the owner: AgentProvider.
claimwithout gateevidenceat boundaryvsoptions
Compare claim and evidence: options.
learnexecuteverifyshellEscape
Read the sequence: shellEscape.
complete?yes / nocommand
Find the decision gate: command.
inputproof/dev/stdin
Trace the boundary: /dev/stdin.
surfaceseamownerprompt
Locate the owner: prompt.
claimwithout gateevidenceat boundaryvsgrok
Compare claim and evidence: grok.
learnexecuteverifyJSONL
Read the sequence: JSONL.
complete?yes / noparser
Find the decision gate: parser.
inputproofevents
Trace the boundary: events.
surfaceseamownerOrchestrator
Locate the owner: Orchestrator.
claimwithout gateevidenceat boundaryvsaccumulator
Compare claim and evidence: accumulator.
learnexecuteverifyresult
Read the sequence: result.
5

Practice and feedback


Predict before revealing

The prompt contains quotes and shell syntax. Which field should carry it?

`PrintCommand.stdin`; the command contains only escaped provider options.

Retrieval cards

Retrieval cardsPrintCommandClick or press Enter to flip
PrintCommandCommand string plus optional stdin content.
Retrieval cardsshellEscapeClick or press Enter to flip
shellEscapeQuotes boundary values before shell execution.
Retrieval cardscaptureSessionsClick or press Enter to flip
captureSessionsFalse for this phase-one provider.
Retrieval cardsOpt-inClick or press Enter to flip
Opt-inA caller must explicitly choose `factory.grok()`.
The provider has two jobs. Before launch, it turns Factory options into a safe Grok command and sends the prompt through standard input. During the run, it translates each JSONL line into Alembic's small event vocabulary. Everything else—sandbox launch, timeout, accumulation, and result return—stays with Factory.
`buildPrintCommand` returns a shell command plus optional stdin. The prompt never enters argv, avoiding shell interpretation and per-argument size limits. The model and enum-like flags are shell-escaped. Factory's public AFK `run()` path requests permission bypass; containment remains the SandboxProvider's job.

Build the command safely

Choose an option set and inspect what changes—and what stays out of argv.

Verdict

Four-slide summary

PrintCommand

Command string plus optional stdin content.

shellEscape

Quotes boundary values before shell execution.

captureSessions

False for this phase-one provider.

Opt-in

A caller must explicitly choose `factory.grok()`.

Check your model

Spaced review

What should never be interpolated into the command?

The prompt belongs in stdin; boundary option values are escaped in the command.
6

Sources and next move


Ask your teacher to challenge a verdict, replay an event, or review a future unit against the same proof discipline.