process

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 31 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

View Source
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 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
	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
}

func (Launch) Validate

func (launch Launch) Validate() error

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 New

func New(options Options) (*Service, error)

func (*Service) Close

func (s *Service) Close() error

func (*Service) CloseSession

func (s *Service) CloseSession(ctx context.Context, session protocol.SessionID) ([]protocol.ProcessInfo, error)

func (*Service) Execute

func (s *Service) Execute(ctx context.Context, launch Launch) (protocol.ProcessCompletion, error)

func (*Service) ExecutePromotable

func (s *Service) ExecutePromotable(ctx context.Context, launch Launch, promotion <-chan struct{}) (protocol.Output, error)

ExecutePromotable returns the original command result, or transfers that same running command to session ownership when the caller's guidance boundary opens. CompletionGate, when supplied, opens after the promoted receipt commits.

func (*Service) List

func (s *Service) List(session protocol.SessionID) []protocol.ProcessInfo

func (*Service) Page

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) Read

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) Start

func (s *Service) Start(launch Launch) (protocol.ProcessInfo, error)

func (*Service) Stop

func (*Service) StopAll

func (s *Service) StopAll(session protocol.SessionID) []protocol.ProcessInfo

func (*Service) StopTransient added in v0.2.4

func (s *Service) StopTransient(session protocol.SessionID)

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.

func (*Service) Write

func (s *Service) Write(session protocol.SessionID, id protocol.RequestID, input string, target *ControlTarget) (uint64, error)

type Stalled

type Stalled struct {
	Snapshot  protocol.ProcessSnapshot
	ElapsedMs uint64
	SilenceMs uint64
	// Byte totals cover output observed as of the snapshot.
	StdoutBytes *uint64
	StderrBytes *uint64
}

Stalled is one silent period of a still-running background command.

Jump to

Keyboard shortcuts

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