Documentation
¶
Overview ¶
Package cwtypes contains the shared type definitions used by both pkg/cliwrap (the public API) and internal/controller. Placing them in a leaf package avoids an import cycle.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidSpec = errors.New("cliwrap: invalid spec")
ErrInvalidSpec is the sentinel that SpecValidationError.Is maps to.
var ErrPTYUnsupportedByAgent = errors.New("cliwrap: agent does not support PTY mode")
ErrPTYUnsupportedByAgent is returned by Controller.Start when the agent's capability reply does not include the "pty" feature and Spec.PTY is set. Defined here (leaf package) so internal/controller can return it without importing pkg/cliwrap and creating an import cycle.
Functions ¶
func ApplyPTYDefaults ¶ added in v0.3.0
ApplyPTYDefaults fills in zero-valued fields of c with sensible defaults. It is a no-op when c is nil.
Types ¶
type ExceedAction ¶
type ExceedAction int
ExceedAction is the action taken when a resource limit is breached.
const ( ExceedWarn ExceedAction = iota ExceedThrottle ExceedKill )
type FileRotationOptions ¶
type FileRotationOptions = LogOptions
FileRotationOptions is an alias kept for backward compatibility.
type LogChunk ¶ added in v0.2.0
LogChunk is one chunk of streamed log data delivered to a follow-mode watcher.
Data is a SHARED byte slice — the producer copies it once and fans the same slice out to every matching subscriber. Receivers MUST NOT mutate Data (no in-place sort, no append that grows in place, no lowercase conversion, etc.), because any mutation would corrupt the slice for other concurrent subscribers. A receiver that needs to modify the bytes must make its own copy first.
This type lives in cwtypes (rather than pkg/cliwrap) so internal/mgmt can refer to it without creating an import cycle with pkg/cliwrap. pkg/cliwrap re-exports it as a type alias.
type LogOptions ¶
type LogOptions struct {
RingBufferBytes int
RotationDir string
RotationMaxSize int64
RotationMaxFiles int
PreserveWALOnShutdown bool
}
LogOptions controls per-process log storage.
type PTYConfig ¶ added in v0.3.0
type PTYConfig struct {
InitialCols uint16 `yaml:"initial_cols"`
InitialRows uint16 `yaml:"initial_rows"`
Echo bool `yaml:"echo"`
}
PTYConfig holds pseudo-terminal configuration for a managed process.
type ResourceLimits ¶
type ResourceLimits struct {
MaxRSS uint64 // bytes
MaxCPUPercent float64 // 0-100
OnExceed ExceedAction
}
ResourceLimits express per-process resource caps.
type RestartPolicy ¶
type RestartPolicy int
RestartPolicy decides what happens after a child exits.
const ( RestartNever RestartPolicy = iota RestartOnFailure RestartAlways )
type SandboxSpec ¶
SandboxSpec selects a sandbox provider and its configuration.
type Spec ¶
type Spec struct {
ID string
Name string
Command string
Args []string
Env map[string]string
WorkDir string
Restart RestartPolicy
MaxRestarts int
RestartBackoff time.Duration
StopTimeout time.Duration
Stdin StdinMode
Sandbox *SandboxSpec
Resources ResourceLimits
LogOptions LogOptions
PTY *PTYConfig `yaml:"pty,omitempty"`
// Persistent makes the agent + child outlive the host process. When true,
// the agent self-daemonizes at spawn time and accepts reattach via a
// UNIX socket at WithPersistentDir/<ID>/sock.
//
// Default false: foreground-mode session, identical to historical behavior.
Persistent bool `yaml:"persistent,omitempty"`
// RingBufferSize is the in-memory PTY output buffer size in bytes,
// used to redraw the current screen state on reattach. Only meaningful
// when Persistent=true. Zero means "use default 256 KiB at agent startup".
RingBufferSize int `yaml:"ring_buffer_size,omitempty"`
}
Spec is the immutable description of a managed process.
type SpecValidationError ¶
SpecValidationError describes a field-level validation failure.
func (*SpecValidationError) Error ¶
func (e *SpecValidationError) Error() string
func (*SpecValidationError) Is ¶
func (e *SpecValidationError) Is(target error) bool