exec

package
v0.98.3 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package exec provides shared workspace-bound terminal and code execution. It must not import pkg/capability (capability/core and agent tools call into this package).

Index

Constants

View Source
const (
	// DefaultTimeout limits run_terminal and run_code when unset.
	DefaultTimeout = 60 * time.Second
	// MaxCodeBytes rejects run_code source above this size.
	MaxCodeBytes = 256 << 10
	// DefaultMaxOutput truncates combined output beyond this byte count.
	DefaultMaxOutput = 8192
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// Workspace is the absolute workspace root.
	Workspace string
	// Env performs filesystem and process operations; nil uses env.Default().
	Env env.ExecutionEnv
	// Timeout limits execution; zero uses DefaultTimeout.
	Timeout time.Duration
	// MaxOutput truncates Output; zero uses DefaultMaxOutput.
	MaxOutput int
}

Config bounds execution to a workspace root and an ExecutionEnv (OS or sandbox).

func (Config) ResolveWorkDir

func (c Config) ResolveWorkDir(workdir string) (string, error)

ResolveWorkDir returns an absolute directory under Workspace for relative workdir. Empty workdir uses the workspace root. Absolute workdir outside the root is rejected.

type Result

type Result struct {
	Stdout   string
	Stderr   string
	ExitCode int
	Output   string
}

Result holds process output from a terminal or code run.

func RunCode

func RunCode(ctx context.Context, cfg Config, language, code, filename, workdir string) (Result, error)

RunCode writes source under .flowbot-run and invokes a language interpreter.

func RunTerminal

func RunTerminal(ctx context.Context, cfg Config, command, workdir string) (Result, error)

RunTerminal executes a shell command in the workspace (optional relative workdir).

Jump to

Keyboard shortcuts

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