executor

package
v0.1.0-alpha Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

claude.go builds the claude -p command for job execution. It embeds task-preamble.txt and summary-prompt.txt via //go:embed, constructs the full prompt (preamble + user prompt + optional summary injection), and assembles CLI flags (--model, --permission-mode bypassPermissions, --output-format json, --effort, --no-session-persistence). The prompt is passed via stdin to avoid OS argument length limits and process list exposure. BuildCommand returns an exec.Cmd ready to run, and BuildResult holds the combined prompt text along with the constructed command.

executor.go orchestrates the full lifecycle of a scheduled job execution. Run validates the working directory, creates a database log entry, sets up stdout/stderr capture files, applies a context timeout, builds and runs the claude command, determines the result status (success, failed, or timeout), parses JSON usage data from stdout, and updates the database log with the outcome. It also defines the claudeOutput struct for JSON parsing, the Result struct returned to callers, and the parseUsage helper.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BuildResult

type BuildResult struct {
	Cmd         *exec.Cmd
	SummaryPath string // non-empty if summary_enabled
}

BuildResult holds the constructed command and any metadata from the build process.

func BuildCommand

func BuildCommand(ctx context.Context, job *config.JobConfig) (*BuildResult, error)

BuildCommand constructs the `claude -p` command for a job.

type Result

type Result struct {
	ExitCode            int
	StdoutPath          string
	StderrPath          string
	SummaryPath         string // path to summary file (if summary_enabled)
	Output              string // claude's result text from JSON output
	Status              string
	ErrorMsg            string
	Duration            time.Duration
	CostUSD             float64
	InputTokens         int
	OutputTokens        int
	CacheReadTokens     int
	CacheCreationTokens int
}

Result captures the outcome of a job execution.

func Run

func Run(ctx context.Context, db *storage.DB, job *config.JobConfig, triggerType string) (*Result, error)

Run executes a job and logs the result to the database.

Jump to

Keyboard shortcuts

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