Documentation
¶
Overview ¶
Package runtime provides runtime helpers for generated llm-compiler programs. This file contains the app context and initialization helpers.
Package runtime provides output capture utilities for generated workflows.
Index ¶
- func EvalCondition(ctx interface{ ... }, condition string) bool
- func RenderTemplate(input string, vars map[string]string) (string, error)
- func SanitizeForShell(s string) string
- type App
- func (a *App) DumpContextsAndSignals() error
- func (a *App) LLM() *LLMRuntime
- func (a *App) LocalLlama() *LocalLlamaRuntime
- func (a *App) MakeSignal(key string) chan SignalMsg
- func (a *App) SaveContext(workflowName string, vars map[string]string)
- func (a *App) SendSignal(key, val string)
- func (a *App) SendSignalError(key, err string)
- func (a *App) Shell() *ShellRuntime
- func (a *App) WaitForSignal(key string, timeout int) (SignalMsg, error)
- type LLMRuntime
- type LocalLlamaRuntime
- type OutputCapture
- type RuntimeContext
- type ShellRuntime
- type SignalMsg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EvalCondition ¶
EvalCondition evaluates a simple condition like "{{var}} == 'hello'".
func SanitizeForShell ¶
SanitizeForShell prepares free-form text (like LLM output) to be safely placed inside a double-quoted shell argument. It performs a light sanitization: trims whitespace, collapses internal whitespace to single spaces, escapes double quotes, and removes NULs. This is intentionally conservative but avoids executing arbitrary multi-line commands when workflows embed LLM output into `sh -c`.
Types ¶
type App ¶
type App struct {
// Configuration
Config *config.Config
// Output files
FmtFile *os.File
LlamaFile *os.File
ExeDir string
// Saved terminal descriptors for restoration
SavedStdout *os.File
SavedStderr *os.File
// Signal coordination for cross-workflow step outputs
Signals map[string]chan SignalMsg
SignalsMu sync.Mutex
// Contexts for each workflow
Contexts map[string]map[string]string
ContextsMu sync.Mutex
// WaitGroup for workflow coordination
WG sync.WaitGroup
// contains filtered or unexported fields
}
App represents the application runtime with all required state
func (*App) DumpContextsAndSignals ¶
DumpContextsAndSignals dumps all contexts and signal values to a JSON file
func (*App) LLM ¶
func (a *App) LLM() *LLMRuntime
LLM returns the LLM runtime, creating it if needed
func (*App) LocalLlama ¶
func (a *App) LocalLlama() *LocalLlamaRuntime
LocalLlama returns the local llama runtime, creating it if needed Note: This should be called per-workflow as llama.cpp may not be thread-safe
func (*App) MakeSignal ¶
MakeSignal returns or creates a signal channel for the given key
func (*App) SaveContext ¶
SaveContext saves a workflow's context
func (*App) SendSignal ¶
SendSignal sends a value to a signal channel (non-blocking)
func (*App) SendSignalError ¶
SendSignalError sends an error to a signal channel (non-blocking)
func (*App) Shell ¶
func (a *App) Shell() *ShellRuntime
Shell returns the shell runtime, creating it if needed
type LLMRuntime ¶
type LLMRuntime struct {
// contains filtered or unexported fields
}
func NewLLMRuntime ¶
func NewLLMRuntime() *LLMRuntime
type LocalLlamaRuntime ¶
type LocalLlamaRuntime struct {
// contains filtered or unexported fields
}
LocalLlamaRuntime manages loaded models (cached) and generation.
func NewLocalLlamaRuntime ¶
func NewLocalLlamaRuntime() *LocalLlamaRuntime
func (*LocalLlamaRuntime) Close ¶
func (r *LocalLlamaRuntime) Close() error
Close releases resources held by the runtime, including worker clients.
type OutputCapture ¶
type OutputCapture struct {
// contains filtered or unexported fields
}
OutputCapture manages capturing stdout/stderr to files. It handles both Go-level and native (cgo) output redirection.
func NewOutputCapture ¶
func NewOutputCapture() *OutputCapture
NewOutputCapture creates a new output capture instance.
func (*OutputCapture) Start ¶
Start begins capturing output to files next to the executable. Returns the saved stdout for printing messages to terminal. If LLMC_NO_CAPTURE=1 is set, output capture is skipped.
func (*OutputCapture) Stop ¶
func (oc *OutputCapture) Stop()
Stop ends output capture and restores original stdout/stderr.
type RuntimeContext ¶
func NewRuntimeContext ¶
func NewRuntimeContext() *RuntimeContext
func (*RuntimeContext) Get ¶
func (c *RuntimeContext) Get(name string) string
func (*RuntimeContext) Set ¶
func (c *RuntimeContext) Set(name, value string)
type ShellRuntime ¶
type ShellRuntime struct{}
ShellRuntime runs shell commands from workflow steps
func NewShellRuntime ¶
func NewShellRuntime() *ShellRuntime