grok

package
v0.2.0-rc2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 12 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package grok is the Grok Build adapter. Its argv, decoder, session lookup and reviewer evidence moved here from internal/git and internal/jobs with no behaviour change (criterion 1); the field names and values are the ones verified against Grok Build 1.0.40 (2026-09-22).

Index

Constants

View Source
const MinVersion = "1.0.40"

MinVersion is the version the stream decoder was verified against.

Variables

This section is empty.

Functions

func LatestSession

func LatestSession(home, cwd string) (id string, ok bool)

LatestSession returns the newest session for cwd that has a chat history, which is what `grok -c` would continue. ok is false when there is none, including when Grok's layout has moved: Resume then fails closed.

func SessionsDir

func SessionsDir(home, cwd string) (string, error)

SessionsDir is where Grok Build keeps the sessions for one cwd: <home>/sessions/<url-escaped absolute cwd>/<uuid>/ (verified on 1.0.40).

func TextPayload

func TextPayload(raw []byte) string

TextPayload is the operator-visible body of a text event. Grok 1.0.40 sends `data`. Older shapes use text, then message, then content. Each key is read on its own so a sibling that is not a string (content:[] or text:1) does not drop a string sitting next to it. Absent, null, non-string, and empty values are skipped. No string payload logs nothing.

func ToolDenied

func ToolDenied(events [][]byte) (string, bool)

ToolDenied is Denied without the adapter.

Types

type Adapter

type Adapter struct {
	// contains filtered or unexported fields
}

Adapter is Grok Build.

func New

func New(cfg Config) *Adapter

New returns the grok adapter.

func (*Adapter) Bin

func (a *Adapter) Bin() string

func (*Adapter) Command

func (a *Adapter) Command(t aa.Task) (aa.Command, error)

Command builds the implementer or reviewer argv. The implementer argv is identical across iterations except for -c / -r and the prompt, so the sandbox and turn budget cannot drift.

func (*Adapter) CredentialEnv

func (a *Adapter) CredentialEnv() []string

func (*Adapter) Denied

func (a *Adapter) Denied(events [][]byte, _ aa.End) (string, bool)

Denied reports a permission-gate refusal. Grok ends the run cancelled and puts "User cancelled the execution for tool `<name>`" in the tool_call_update content, which is an array, so the raw event is scanned.

func (*Adapter) FilterStderr

func (a *Adapter) FilterStderr(line string) string

FilterStderr forwards grok's stderr unchanged.

func (*Adapter) LogSource

func (a *Adapter) LogSource() string

func (*Adapter) MinVersion

func (a *Adapter) MinVersion() string

func (*Adapter) Name

func (a *Adapter) Name() aa.Name

func (*Adapter) NewDecoder

func (a *Adapter) NewDecoder() aa.Decoder

NewDecoder returns grok's streaming-json decoder.

func (*Adapter) Prepare

func (a *Adapter) Prepare(aa.Task) error

Prepare is a no-op: the job-scoped sandbox profile is written and byte-checked by the jobs package, which owns the Simulator lease.

func (*Adapter) Ready

func (a *Adapter) Ready(context.Context, aa.Task) error

Ready keeps today's behaviour: grok's login is `grok login` by the owner, and a signed-out run fails at run time.

func (*Adapter) ResumeID

func (a *Adapter) ResumeID(handoff, _ string) (string, bool)

ResumeID ignores the stored id: grok resumes what `grok -c` would continue, the newest session for the handoff cwd.

func (*Adapter) ResumesByID

func (a *Adapter) ResumesByID() bool

func (*Adapter) ReviewEvidence

func (a *Adapter) ReviewEvidence(events [][]byte, worktrees []string) bool

ReviewEvidence reports whether the stream shows a completed git diff of one of worktrees. read_file and grep do not count.

func (*Adapter) SupportsSimulator

func (a *Adapter) SupportsSimulator() bool

func (*Adapter) VersionArgs

func (a *Adapter) VersionArgs() []string

type Config

type Config struct {
	// Bin is the resolved grok binary ("" when not installed).
	Bin string
	// Home is grok's state dir ($GROK_HOME or ~/.grok), where sessions live.
	Home string
}

Config is what the caller resolved from its environment.

type Decoder

type Decoder struct{}

Decoder decodes Grok Build's streaming-json (ACP session updates).

func (Decoder) Decode

func (Decoder) Decode(line []byte) []aa.Event

Decode maps one stdout line. Non-JSON is kept as an ordinary log line (an older CLI, or a fake bin that echoes argv).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL