Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FormatAgentMessage ¶
FormatAgentMessage parses a JSON line from the agent's stdout and returns a human-readable message to send to the channel. Returns empty string for messages that should not be forwarded (status messages, tool results, etc.).
Types ¶
type ExecFunc ¶
ExecFunc matches exec.CommandContext. It is a type alias (not a defined type) so callers' own named exec-override types stay assignable without conversion.
type Options ¶
type Options struct {
// BinaryPath is the infer binary to spawn; defaults to os.Args[0] when empty.
BinaryPath string
// Exec overrides command construction (tests); defaults to exec.CommandContext.
Exec ExecFunc
SessionID string
Prompt string
Model string
Files []string
RequireApproval bool
Remote bool
Heartbeat bool
// ResultFile, when set, passes --result-file so the agent writes its final
// assistant message to a JSON file on exit (used by detached/tmux runs).
ResultFile string
// ExtraEnv is appended to os.Environ() for the subprocess (e.g. depth guard).
ExtraEnv []string
// OnLine is called for each non-empty raw stdout line. Approval-request
// lines handled internally (see Approval) are not passed to OnLine.
OnLine func(line []byte)
// Approval, when set and RequireApproval is true, resolves a tool approval
// request into a response that is written back to the agent's stdin. It
// blocks until the decision is made.
Approval func(ipc.ApprovalRequest) ipc.ApprovalResponse
}
Options configures a single `infer headless` subprocess run.
type Result ¶
type Result struct {
// FinalAssistant is the last non-empty assistant message content seen on
// stdout - the harvested "answer" of the run.
FinalAssistant string
// Stderr is the last plain line of standard error, the run's own error when
// it failed. The JSON log lines before it went to this process's log.
Stderr string
}
Result is the outcome of a subprocess run.
func Run ¶
Run spawns `infer headless ...`, streams stdout line-by-line, optionally brokers tool approval over stdin, and returns the harvested final assistant message. The run logs JSON to stderr, collected into this process's log as it runs. The returned error is the subprocess setup/exit error. Callers format their own user-facing messages from it.