process

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 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

This section is empty.

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

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
	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, receives each silent period of a running background
	// command once; output starts the next period.
	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) 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) 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) 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) error

func (*Service) Write

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

type Stalled

type Stalled struct {
	Snapshot  protocol.ProcessSnapshot
	ElapsedMs 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