Documentation
¶
Overview ¶
Adapted from sailry-code 67ae9fa0. See third_party_licenses/sailry-code-terminal.md.
Portions adapted from ADK-Rust 675c02b6c0df6d632b953a06a5a12d1f814b7780. Copyright 2026 Zavora Technologies Ltd.; Apache-2.0. See third_party_licenses/adk-LICENSE.
Package process owns execution-Node command lifetime and bounded output.
Index ¶
- Constants
- Variables
- func CaptureWorkspaceBoundary(root string) (string, error)
- func SandboxSupported() bool
- type ControlTarget
- type Environment
- type Finished
- type Launch
- type Options
- type Service
- func (s *Service) Close() error
- func (s *Service) CloseSession(ctx context.Context, session protocol.SessionID) ([]protocol.ProcessInfo, error)
- func (s *Service) Execute(ctx context.Context, launch Launch) (protocol.ProcessCompletion, error)
- func (s *Service) ExecutePromotable(ctx context.Context, launch Launch, promotion <-chan struct{}) (output protocol.Output, timedOut bool, err error)
- func (s *Service) List(session protocol.SessionID) []protocol.ProcessInfo
- func (s *Service) Page(session protocol.SessionID, id protocol.RequestID, ...) (protocol.ProcessOutputOutputPage, error)
- func (s *Service) Preview(session protocol.SessionID, id protocol.RequestID, head bool) (map[string]any, error)
- func (s *Service) Read(session protocol.SessionID, id protocol.RequestID) (protocol.ProcessSnapshot, error)
- func (s *Service) ReconcileFinished(ctx context.Context, session protocol.SessionID, id protocol.RequestID)
- func (s *Service) SandboxTerminal(root string, command, environment []string) ([]string, []string, func(), error)
- func (s *Service) SandboxedControl(session protocol.SessionID, id protocol.RequestID) *ControlTarget
- func (s *Service) Start(launch Launch) (protocol.ProcessInfo, error)
- func (s *Service) Stop(session protocol.SessionID, id protocol.RequestID, target *ControlTarget) (protocol.ProcessSnapshot, error)
- func (s *Service) StopAll(session protocol.SessionID) []protocol.ProcessInfo
- func (s *Service) StopTransient(session protocol.SessionID)
- func (s *Service) Subscribe(session protocol.SessionID) (<-chan []protocol.ProcessInfo, func())
- func (s *Service) Wait(ctx context.Context, session protocol.SessionID, id protocol.RequestID, ...) (protocol.ProcessWait, error)
- func (s *Service) Write(session protocol.SessionID, id protocol.RequestID, input string, ...) (uint64, error)
- type Stalled
Constants ¶
const StallWindow = 15 * time.Minute
StallWindow is how long a running background command may stay silent before its session is asked to decide about it.
Variables ¶
var ErrCompletionNotRegistered = errors.New("background command was not registered before execution")
ErrCompletionNotRegistered means the completion has no admitted record.
var ErrCompletionStorageFull = errors.New("command completion storage is full")
ErrCompletionStorageFull marks a refused completion write that needs space before it can be attempted again.
Functions ¶
func CaptureWorkspaceBoundary ¶
CaptureWorkspaceBoundary protects existing child checkouts without creating them.
func SandboxSupported ¶
func SandboxSupported() bool
SandboxSupported reports whether the compiled platform has a workspace sandbox. A missing sandbox launcher still fails execution without broadening access.
Types ¶
type ControlTarget ¶ added in v0.2.4
type ControlTarget struct {
// contains filtered or unexported fields
}
ControlTarget binds implicit sandbox consent to one live process.
type Environment ¶
type Environment struct {
// contains filtered or unexported fields
}
Environment freezes the Node's startup shell environment, outside tools.
func CaptureEnvironment ¶
func CaptureEnvironment(ctx context.Context) Environment
CaptureEnvironment runs the source's bounded login capture once at Node start. Tool calls reuse this snapshot and never rerun a user's shell profiles.
func NewEnvironment ¶
func NewEnvironment(values []string) Environment
NewEnvironment never starts a shell, so deterministic tests can use fixtures.
func (Environment) Shell ¶
func (environment Environment) Shell() string
func (Environment) TerminalValues ¶
func (environment Environment) TerminalValues() []string
type Finished ¶
type Finished struct {
Snapshot protocol.ProcessSnapshot
ElapsedMs *uint64
Explicit bool
// Byte totals are present when comparable to the captured UTF-8 text.
StdoutBytes *uint64
StderrBytes *uint64
}
Finished is persisted by the existing Node writer before completion publishes.
type Launch ¶
type Launch struct {
ID protocol.RequestID
Session protocol.SessionID
Turn protocol.TurnID
Worktree protocol.WorktreeID
Root string
Profile string
Command string
Stdin string // Foreground input, written verbatim and followed by EOF.
Access protocol.ProcessAccess
// ReadOnly confines a sandboxed command's workspace root to read-only while
// keeping its private temporary scratch directory writable.
ReadOnly bool
Cwd string
TimeoutMs uint64
Pty bool
Background bool
FollowUp bool // Report background progress for this launch, including after promotion.
// Service keeps a background command running through a user stop.
Service bool
Scratch string
Inputs string
Environment map[string]string
Release func()
CompletionGate <-chan struct{}
// contains filtered or unexported fields
}
type Options ¶
type Options struct {
Context context.Context
Profile string
Environment Environment
Now func() time.Time
After func(time.Duration) <-chan time.Time
Finished func(context.Context, Finished) error
// Stalled, when set, records prolonged silence for a follow-up command.
// A successful report ends observation for that command; after an error
// the command is checked again once another window passes.
Stalled func(context.Context, Stalled) error
Changed func(protocol.WorktreeID)
CaptureManaged func(string) (string, error)
// Working, when set, brackets every running command.
Working func() func()
Run func(context.Context, Launch, func(protocol.ProcessOutputOutputStream, []byte), <-chan []byte) (protocol.ProcessCompletion, error)
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) CloseSession ¶
func (*Service) ExecutePromotable ¶
func (s *Service) ExecutePromotable(ctx context.Context, launch Launch, promotion <-chan struct{}) (output protocol.Output, timedOut bool, err error)
ExecutePromotable returns the original command result, or transfers that same running command to session ownership when the caller's guidance boundary opens or its timeout elapses. timedOut reports that the timeout was reached: with command_started the command moved to the session; with command_result background capacity was full and the command was stopped. CompletionGate, when supplied, opens after the promoted receipt commits.
func (*Service) Preview ¶
func (s *Service) Preview(session protocol.SessionID, id protocol.RequestID, head bool) (map[string]any, error)
Preview freezes bounded model metadata without changing the command capture. Head is requested only for background snapshots, whose captures own the tail.
func (*Service) ReconcileFinished ¶ added in v0.2.4
func (s *Service) ReconcileFinished(ctx context.Context, session protocol.SessionID, id protocol.RequestID)
ReconcileFinished retries a known-uncommitted completion when the command is inspected. The process has already ended; only its original evidence is written, once per inspection while storage refuses it.
func (*Service) SandboxTerminal ¶
func (s *Service) SandboxTerminal(root string, command, environment []string) ([]string, []string, func(), error)
SandboxTerminal wraps a workspace terminal's program in the command sandbox. The returned variables follow the terminal's own environment, and release removes the private state once the terminal has ended.
func (*Service) SandboxedControl ¶ added in v0.2.4
func (s *Service) SandboxedControl(session protocol.SessionID, id protocol.RequestID) *ControlTarget
SandboxedControl returns evidence for automatic consent at the tool boundary.
func (*Service) Stop ¶
func (s *Service) Stop(session protocol.SessionID, id protocol.RequestID, target *ControlTarget) (protocol.ProcessSnapshot, error)
func (*Service) StopAll ¶
func (s *Service) StopAll(session protocol.SessionID) []protocol.ProcessInfo
func (*Service) StopTransient ¶ added in v0.2.4
StopTransient stops a session's active background commands, promoted ones included, except those launched as services. Foreground commands follow their caller's cancellation.
func (*Service) Subscribe ¶
func (s *Service) Subscribe(session protocol.SessionID) (<-chan []protocol.ProcessInfo, func())
func (*Service) Wait ¶
func (s *Service) Wait(ctx context.Context, session protocol.SessionID, id protocol.RequestID, waitMs uint64, until string) (protocol.ProcessWait, error)
Wait blocks a read until new output, a match of until, the command's exit or the bounded deadline, and reports which one ended it. until requires a positive wait; a zero wait returns no outcome.
Source Files
¶
- account_linux.go
- account_unix.go
- encoding_unix.go
- environment.go
- environment_unix.go
- group_linux.go
- groups_linux.go
- groups_unix.go
- native.go
- native_unix.go
- output.go
- preview.go
- retained.go
- sandbox.go
- sandbox_linux.go
- sandbox_repositories.go
- sandbox_support.go
- sandbox_terminal_linux.go
- sandbox_toolchain_state.go
- service.go
- services.go
- types.go
- workspace_boundary.go