bashrun

package
v0.107.21 Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KeyEnter = "\r"
	KeyEsc   = "\x1b"
	KeyTab   = "\t"
	KeyBS    = "\x7f"
	KeyUp    = "\x1b[A"
	KeyDown  = "\x1b[B"
	KeyRight = "\x1b[C"
	KeyLeft  = "\x1b[D"
)

Variables

View Source
var ChildMarkers = []string{"K_BRAIN=1", "K_BRAIN=1"}
View Source
var SecretEnvVars = []string{"K_BRAIN_BACKEND_TOKEN", "K_BRAIN_COMPUTER_TOKEN"}

SecretEnvVars are credentials handed to K-brain processes by their parent. They authenticate callers of the backend API (or of the computer helper) and must never reach commands the agent runs.

Functions

func Command added in v0.107.6

func Command(ctx context.Context, shell, command string) (*exec.Cmd, error)

Command shares quoting, encoding and exit status handling across process tools.

func DefaultShell

func DefaultShell() string

func KeyBytes

func KeyBytes(name string) string

func KillAll

func KillAll()

func ResolveShell added in v0.107.6

func ResolveShell(ctx context.Context, shell string) string

ResolveShell keeps explicit per-tool selection ahead of the session and platform default.

func ScrubEnv added in v0.107.13

func ScrubEnv(env []string) []string

ScrubEnv returns env without SecretEnvVars entries.

func SetMarkers

func SetMarkers(sessionID, model string)

func ShellName added in v0.107.6

func ShellName(shell string) string

func Spill

func Spill(output string) string

func UnsetSecretEnv added in v0.107.13

func UnsetSecretEnv()

UnsetSecretEnv removes SecretEnvVars from this process's environment, so every child started afterwards inherits an environment without them. Call it once the values have been read.

func WithShell

func WithShell(ctx context.Context, shell string) context.Context

func WithWorkingDir added in v0.103.0

func WithWorkingDir(ctx context.Context, dir string) context.Context

func WorkingDir added in v0.103.0

func WorkingDir(ctx context.Context) string

Types

type Options

type Options struct {
	Command string

	Dir string

	Shell string

	Timeout time.Duration

	Interactive bool

	InactivityTimeout time.Duration

	OnOutput func(chunk string)

	// OnUpdate receives a bounded tail snapshot when output changes.
	OnUpdate func(outputTail string)

	OnAwaitInput func(secLeft int)

	Keys <-chan []byte

	Env []string

	Sandbox *sandbox.Policy
}

type Result

type Result struct {
	Output      string
	OutputFile  string
	OutputBytes int64

	Exit string

	// ExitCode is the status the command exited with, 0 included; nil when it
	// did not start, timed out, was cancelled or was killed by a signal.
	ExitCode *int

	TimedOut bool

	Killed bool

	Interactive bool
}

func Run

func Run(ctx context.Context, opts Options) Result

Jump to

Keyboard shortcuts

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