oneshot

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Oct 14, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package oneshot is the non-interactive entry point: read one prompt, run one agent turn, print the final answer to stdout, exit. The TUI is great for working sessions; oneshot is what scripts and CI pipelines call.

Output convention:

  • stdout: the model's *content* tokens (the answer)
  • stderr: reasoning tokens, tool-call status, errors

That way `yottacode run "summarize x" > out.md` produces a clean file with reasoning visible only on the terminal.

Index

Constants

View Source
const (
	// ExitReasonOK means the turn reached a final tool-free assistant answer.
	ExitReasonOK = "ok"
	// ExitReasonError means the turn returned a process-failing error.
	ExitReasonError = "error"
	// ExitReasonIterCap means the turn exhausted its iteration budget.
	ExitReasonIterCap = "iter_cap"
)

Variables

This section is empty.

Functions

func Run

func Run(ctx context.Context, opts cli.ChatOptions, prompt string) error

Run drives a single non-interactive turn and returns when the assistant produces a tool-free reply (or hits an error / iter cap). The session is saved like any other for later /resume.

Types

type RunResult added in v0.5.0

type RunResult struct {
	Content    string            `json:"content"`
	ToolCalls  []ToolCallSummary `json:"tool_calls"`
	Usage      adapter.Usage     `json:"usage"`
	ExitReason string            `json:"exit_reason"`
	Error      *string           `json:"error"`
	SessionID  string            `json:"session_id"`
}

RunResult is the primary stdout contract for `yottacode run --format json`. Error is a pointer so successful runs encode an explicit JSON null value.

type RunStatus added in v0.5.0

type RunStatus struct {
	Status       string                   `json:"status"`
	Error        string                   `json:"error,omitempty"`
	Iterations   int                      `json:"iterations"`
	Tools        map[string]ToolRunStatus `json:"tools,omitempty"`
	ChangedFiles []string                 `json:"changed_files,omitempty"`
}

RunStatus is the machine-readable receipt emitted by `yottacode run --json`. Stdout still carries only the final assistant response; this envelope belongs on stderr so shell pipelines and CI can parse metadata independently.

type StreamOptions added in v0.5.0

type StreamOptions struct {
	JSONStatus bool
	Format     string
	SessionID  string
}

StreamOptions carries script-facing output switches for the oneshot event drain. Keep this small: `run` stdout is deliberately stable, while stderr can grow metadata needed by integrations.

type ToolCallSummary added in v0.5.0

type ToolCallSummary struct {
	Name    string `json:"name"`
	Summary string `json:"summary"`
}

ToolCallSummary is the stable, intentionally small record exposed to scripts. Summary reuses the same bounded, human-safe preview shown in text-mode status.

type ToolRunStatus added in v0.5.0

type ToolRunStatus struct {
	Count   int `json:"count"`
	Errored int `json:"errored,omitempty"`
}

ToolRunStatus summarizes one tool's execution count for the JSON status envelope. Errored counts tool-level errors already surfaced to the model.

Jump to

Keyboard shortcuts

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