system

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2026 License: MIT Imports: 27 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.

README

system

github.com/webong/ext/res/system is the reusable local operating-system layer for extending graphical and textual shells. It observes hosts, processes, filesystems, web views, displays, windows, accessibility and permission state; it also supplies bounded native mechanisms such as surface capture and input, media capture/playback, volume snapshot/restore, local network-state observation, and process supervision.

The boundary is local mechanism, not read-only behavior. Consumers choose the target and own authorization, approval UI, remote protocols, routing, retention and product policy.

Package What it is
system (the module root) Host resource capacity and container state, native desktop, display/window, accessibility, permission-state, shell, filesystem and web view discovery; process inspection; bounded window or caller-selected driver capture and atomic input
system/audio Bounded, transport-free audio-device observation and caller-selected PCM16 capture/playback interfaces; native PulseAudio, WASAPI, and platform playback implementations select no device
system/clipboard Bounded, transport-free clipboard contracts, the Apple and Android native implementations shipped by the platform SDKs, and the Win32 backend for Go consumers
system/credential Portable credential-store adapter framing and the local CTX credential client; native stores remain product adapters
system/graph A generic, namespaced, directed graph store with transactions, in memory or in a file
system/media Bounded PCM16 and RIFF/WAVE framing; image sampling/change detection, crop, annotation and contact sheets; caller-supplied video frame sampling; recording options and stream contract
system/network Bounded, read-only local interface, assigned-address, route and resolver observation; opens no connection and supplies no remote service
system/service Portable per-user service definitions (launchd, systemd, Task Scheduler), non-overwriting publication, registration, start/stop and status through a caller-selected manager; no product identity, layout, port, or health protocol
system/share Bounded, transport-free share and keyboard-extension model: text, links, and attachment references; no extension registry, event schema, inbox, or application identity
system/supervisor Process supervision and recovery
system/volume Bounded local snapshot, restore, archive digest, and pinned private-directory creation/removal for a caller-selected volume or directory
ios/ (ExtSystem) Apple share-extension normalization and keyboard-extension editing helpers, surface/accessibility/permission APIs, macOS capture and input, Accessibility actions, typed Apple Events, ScreenCaptureKit and ReplayKit capture, and bounded PCM playback
android/ App-visible share-intent and InputMethodService helpers, surface/accessibility/permission APIs, MediaProjection capture, and bounded PCM playback
windows/ (Ext.System.Windows) Windows WASAPI endpoint discovery, capture, bounded PCM playback, and generation-checked Win32 clipboard access for .NET consumers

The graph store is domain-neutral: callers own their node and edge vocabulary, and the discovery code in the module root records what it finds through it. CTX and other consumers share this library rather than each implementing their own.

Product-specific provider discovery belongs in the owning adapter under adapters/<name>/. Calling Core Graphics, ScreenCaptureKit, AVFoundation, User32, GDI or WASAPI to implement a public system API is a platform implementation, not a product adapter.

The Apple and Android bindings live under ios/ and android/ and ship as the ExtSystem and io.github.webong.ext.system products in the native SDKs. The network package's native bindings live under network/ios and network/android and retain the ExtNetwork and io.github.webong.ext.network product names for source compatibility. Android observes app-visible surfaces, accessibility structure and permission state and exposes caller-consented MediaProjection capture and bounded PCM playback. Apple provides bounded playback and ReplayKit app capture, while macOS additionally provides desktop capture, audio and input. Accessibility text is opt-in and surface operations use opaque observed identities rather than exposing native handles.

No implementation prompts for permission, opens settings, selects a target, defines grants, shows approval UI, or provides remote routing. Those decisions remain with CTX, Cymonkey or another consumer.

The Go surface collector uses Core Graphics on macOS and User32 on Windows. The same Go API revalidates an observed window before capture or atomic input; Windows capture uses GDI and macOS capture uses the system Core Graphics symbol when the OS still provides it. Apple clients should prefer ExtSystem's ScreenCaptureKit implementation on macOS 14 and newer. Linux X11 builds dynamically inspect root geometry and visible windows without a link-time X11 dependency; monitor partitions are reported as partial. A Wayland-only session reports global surface observation as unsupported because the compositor does not expose that state to arbitrary clients.

The module was called res/graph until it was renamed to say what it is for. The generic store is now res/system/graph, the discovery package that lived in res/graph/system is now the module root, and res/system/supervisor is unchanged. See the migration table in module versioning.

See host discovery and the graph runtime decision record. The broader ownership and safety boundary is documented in the local system shell library.

Documentation

Overview

Package system projects CTX machine inventory, shell, and browser observations onto the public generic graph API. It owns the ext.system vocabulary; the base graph package remains product-neutral.

Index

Constants

View Source
const (
	DesktopNative    = "desktop.native"
	DesktopX11       = "desktop.x11"
	DesktopWayland   = "desktop.wayland"
	DesktopContainer = "desktop.container"
	DesktopRecording = "desktop.recording"
)
View Source
const (
	// ContainerDetected, ContainerNone, and ContainerUnsupported are the only
	// container states. Unsupported means the platform exposes no safe local
	// signal, not that the process is outside a container.
	ContainerDetected    = "detected"
	ContainerNone        = "none"
	ContainerUnsupported = "unsupported"
)
View Source
const (
	PowerStateCharging    = "charging"
	PowerStateDischarging = "discharging"
	PowerStateCharged     = "charged"
	PowerStateUnknown     = "unknown"
)

PowerState values.

View Source
const Namespace = "ext.system"

Variables

View Source
var (
	// ErrSurfaceUnavailable means the native desktop cannot perform the
	// requested operation in the current session.
	ErrSurfaceUnavailable = errors.New("surface operation unavailable")
	// ErrSurfacePermission means the operating system has not granted the
	// calling process permission for the requested operation.
	ErrSurfacePermission = errors.New("surface operation permission is not granted")
	// ErrSurfaceStale means the observed process generation or window no longer
	// names the same native surface.
	ErrSurfaceStale = errors.New("surface reference is stale")
	// ErrSurfaceNotFocused means input could not be safely directed to the
	// selected surface without affecting another application.
	ErrSurfaceNotFocused = errors.New("surface is not focused")
)
View Source
var ErrDesktopUnavailable = errors.New("desktop operation unavailable")

ErrDesktopUnavailable means a selected desktop mechanism cannot perform the requested operation in the current session.

View Source
var ErrInvalidRecording = errors.New("invalid recording options")

ErrInvalidRecording reports malformed recording options.

Functions

func RecordDesktop added in v0.2.0

func RecordDesktop(ctx context.Context, driver DesktopDriver, options media.RecordingOptions) (media.Recording, error)

RecordDesktop starts a bounded recording through the selected driver.

func SafeOrigin

func SafeOrigin(raw string) (scheme, host string, ok bool)

SafeOrigin parses a navigation URL and returns only scheme and host.

func SendDesktopInput added in v0.2.0

func SendDesktopInput(ctx context.Context, driver DesktopDriver, input SurfaceInput, options InputOptions) error

SendDesktopInput sends one bounded operation through the selected driver. Drivers that only implement keyboard input must refuse pointer operations explicitly instead of emulating them.

func SendWindowInput added in v0.2.0

func SendWindowInput(ctx context.Context, target WindowInfo, input SurfaceInput, options InputOptions) error

SendWindowInput sends one bounded operation to a revalidated local window. It does not choose or activate the window, hold input across calls, implement an approval policy, or expose a remote protocol.

Types

type AccessibilityElement added in v0.2.0

type AccessibilityElement struct {
	ID             string         `json:"id"`
	ParentID       string         `json:"parent_id,omitempty"`
	PID            int            `json:"pid"`
	ProcessStartID string         `json:"process_start_id"`
	Role           string         `json:"role"`
	Identifier     string         `json:"identifier,omitempty"`
	Label          string         `json:"label,omitempty"`
	Value          string         `json:"value,omitempty"`
	Bounds         *SurfaceBounds `json:"bounds,omitempty"`
	Actions        []string       `json:"actions,omitempty"`
	Enabled        *bool          `json:"enabled,omitempty"`
	Focused        *bool          `json:"focused,omitempty"`
}

AccessibilityElement is a caller-visible node in the focused application's native accessibility tree. ID and ParentID are opaque snapshot identities; they are not native handles and cannot be used to invoke actions.

type AccessibilityOptions added in v0.2.0

type AccessibilityOptions struct {
	MaxElements int
	MaxDepth    int
	Timeout     time.Duration
	IncludeText bool
}

AccessibilityOptions bounds traversal. Text is omitted by default because labels and values may contain document or form contents. Zero bounds select 1024 elements, depth 16, and a five-second deadline.

type AccessibilitySnapshot added in v0.2.0

type AccessibilitySnapshot struct {
	Platform   string                 `json:"platform"`
	ObservedAt time.Time              `json:"observed_at"`
	Status     CollectionStatus       `json:"status"`
	Elements   []AccessibilityElement `json:"elements"`
}

AccessibilitySnapshot is a bounded, read-only observation of the focused local application's UI tree. It never contains native handles or an action endpoint. Status distinguishes an empty tree from denied or unsupported native observation.

func DiscoverAccessibility added in v0.2.0

func DiscoverAccessibility(ctx context.Context, options AccessibilityOptions) (AccessibilitySnapshot, error)

DiscoverAccessibility observes the focused local application's native UI structure. It does not request permission, mutate attributes, invoke actions, synthesize input, capture pixels, or communicate with another process over a transport.

type AdapterObservation

type AdapterObservation struct {
	Name, Runtime, Selector                          string
	DiscoveryStatus                                  string
	Surfaces, Capabilities, Supports                 []string
	BrowserShare                                     []string
	Trusted, ListSupported, ObserveSupported, Listed bool
	Contexts                                         []ContextObservation
	Resources                                        []ResourceObservation
	Relations                                        []RelationObservation
}

AdapterObservation describes an installed adapter and any contexts it listed. Listed means its discovery operation completed; it does not prove each configured remote endpoint is running or authorize its use.

type AliasObservation

type AliasObservation struct {
	Space, Name, Adapter, Selection string
	Metadata                        map[string]string
}

AliasObservation is a local user declaration that names one adapter context.

type ApplicationInfo

type ApplicationInfo struct {
	Name string `json:"name"`
	Path string `json:"path"`
}

ApplicationInfo identifies an application through OS packaging conventions. It does not assign product capabilities or infer an engine from a name.

type CaptureOptions added in v0.2.0

type CaptureOptions struct {
	MaxPixels int
	MaxBytes  int
	Timeout   time.Duration
}

CaptureOptions bounds native allocation and encoded output. Zero values select 16,777,216 pixels, 16 MiB, and a five-second deadline.

type CollectionStatus

type CollectionStatus struct {
	State      string     `json:"state"`
	Detail     string     `json:"detail,omitempty"`
	ObservedAt *time.Time `json:"observed_at,omitempty"`
}

CollectionStatus distinguishes an empty observation from inaccessible data. State is complete, partial, permission-denied, unsupported, exited, or unavailable. Detail is a diagnostic, never process arguments or environment contents.

type ContainerInfo added in v0.2.0

type ContainerInfo struct {
	Detected bool     `json:"detected"`
	State    string   `json:"state"`
	Evidence []string `json:"evidence"`
}

ContainerInfo reports whether this process runs inside a container and which local markers support that conclusion. Evidence is a sorted list of stable names, not file contents or environment values.

type ContextCandidate

type ContextCandidate struct {
	Adapter           string            `json:"adapter"`
	Runtime           string            `json:"runtime"`
	Selection         string            `json:"selection"`
	SelectionDigest   string            `json:"selection_digest"`
	SelectionRedacted bool              `json:"selection_redacted,omitempty"`
	Capabilities      []string          `json:"capabilities"`
	Supports          []string          `json:"supports,omitempty"`
	BrowserShare      map[string]string `json:"browser_share,omitempty"`
	ObservedAt        time.Time         `json:"observed_at"`
}

ContextCandidate is a graph observation, not authorization to run an adapter. Callers must still check trust and validate the native selection.

type ContextObservation

type ContextObservation struct {
	Selection    string            `json:"selection"`
	Capabilities []string          `json:"capabilities,omitempty"`
	Supports     []string          `json:"supports,omitempty"`
	BrowserShare map[string]string `json:"browser_share,omitempty"`
	Attributes   map[string]any    `json:"attributes,omitempty"`
}

ContextObservation is a native adapter selection with optional narrower capabilities and resource support, plus ordinary non-secret metadata.

type DesktopDriver added in v0.2.0

DesktopDriver is a caller-selected native desktop mechanism, such as the X11 or Wayland tool adapters. Operations are desktop-scoped because those tools cannot address an observed window; window-scoped capture and input remain in CaptureWindow and SendWindowInput.

It is an interface rather than a registry: the shared library never selects a driver by name or falls back to another one.

type DesktopEndpoint added in v0.2.0

type DesktopEndpoint struct {
	Available bool   `json:"available"`
	Reason    string `json:"reason,omitempty"`
}

DesktopEndpoint is evidence that a local desktop display endpoint is visible to this process. It never contains a socket path, credential, or remote host.

type DesktopInfo added in v0.2.0

type DesktopInfo struct {
	Platform      string          `json:"platform"`
	Interactive   bool            `json:"interactive"`
	Containerized bool            `json:"containerized"`
	Capabilities  []string        `json:"capabilities,omitempty"`
	X11           DesktopEndpoint `json:"x11"`
	Wayland       DesktopEndpoint `json:"wayland"`
	Recording     RecordingInfo   `json:"recording"`
	Reason        string          `json:"reason,omitempty"`
	ObservedAt    time.Time       `json:"observed_at"`
}

DesktopInfo is a point-in-time observation of the native desktop visible to the current process. It does not describe a remote display or authorize use.

func DiscoverDesktop added in v0.2.0

func DiscoverDesktop(ctx context.Context) (DesktopInfo, error)

DiscoverDesktop observes only the local native desktop and its recording prerequisites. It performs no network access and launches no process.

type DisplayInfo added in v0.2.0

type DisplayInfo struct {
	ID      string        `json:"id"`
	Bounds  SurfaceBounds `json:"bounds"`
	Scale   float64       `json:"scale,omitempty"`
	Primary bool          `json:"primary"`
}

DisplayInfo describes a display visible to the current process. ID is an opaque observation identity, not a native handle.

type FilesystemInfo

type FilesystemInfo struct {
	MountPoint  string           `json:"mount_point"`
	Source      string           `json:"source"`
	Type        string           `json:"type"`
	ReadOnly    bool             `json:"read_only"`
	Space       *FilesystemSpace `json:"space,omitempty"`
	Label       string           `json:"label,omitempty"`
	DriveKind   string           `json:"drive_kind,omitempty"`
	DetailError string           `json:"detail_error,omitempty"`
}

FilesystemInfo describes a mounted filesystem visible to this process. Space is nil when the OS cannot provide it. This is not a list of unmounted disks or a filesystem-driver catalog. Source never includes URL credentials.

func DiscoverFilesystems

func DiscoverFilesystems(ctx context.Context) ([]FilesystemInfo, error)

DiscoverFilesystems reads the native mount inventory and available space. It observes the caller's mount namespace and permissions, including when CTX itself runs inside a container. It does not traverse filesystem contents.

type FilesystemRequirement

type FilesystemRequirement struct {
	Select                string   `json:"select,omitempty"` // Mount point.
	Path                  string   `json:"path,omitempty"`   // Existing file/directory or a future output path.
	Types                 []string `json:"types,omitempty"`
	Writable              bool     `json:"writable,omitempty"`
	MinimumAvailableBytes uint64   `json:"minimum_available_bytes,omitempty"`
}

type FilesystemSpace

type FilesystemSpace struct {
	TotalBytes     uint64 `json:"total_bytes"`
	FreeBytes      uint64 `json:"free_bytes"`
	AvailableBytes uint64 `json:"available_bytes"`
}

FilesystemSpace is a point-in-time capacity observation, in bytes. Available space is what the calling user can allocate; it can differ from free space. On Windows, total space is also limited by any quota on the calling user.

type Graph

type Graph struct{ Store graph.Store }

func New

func New(store graph.Store) (*Graph, error)

New registers the CTX system vocabulary on any graph.Store. Other services may keep their own namespaces in the same store.

func Open

func Open(configHome string) (*Graph, error)

func (*Graph) Close

func (g *Graph) Close() error

func (*Graph) ObserveHost

func (g *Graph) ObserveHost(ctx context.Context, inventory HostInventory) error

ObserveHost reconciles host-owned records and their machine relationships. Adapter inventory, shell sessions, and other namespaces are preserved.

func (*Graph) ObserveInventory

func (g *Graph) ObserveInventory(ctx context.Context, adapters []AdapterObservation, aliases []AliasObservation) error

ObserveInventory replaces CTX's adapter inventory projection while leaving shell and web observations intact. It records only ordinary metadata and redacts context names that resemble paths, URLs, or opaque values.

func (*Graph) ObserveProcesses

func (g *Graph) ObserveProcesses(ctx context.Context, observation ProcessSnapshot) error

ObserveProcesses projects generic OS evidence. Complete enumeration removes missing process instances. Partial inventories retain unseen instances. A targeted observation only replaces that PID and its inspected resource kinds. Resource nodes retain their own timestamps across later identity-only scans.

func (*Graph) ObserveShell

func (g *Graph) ObserveShell(ctx context.Context, cwd, profile string, selections map[string]string) error

ObserveShell records the current shell session and its active directory. It never reads arbitrary environment values or shell history.

func (*Graph) ObserveWeb

func (g *Graph) ObserveWeb(ctx context.Context, provider, profile, scheme, host string) error

ObserveWeb records the current web origin after ctx open succeeds. URL paths, queries, fragments, and credentials are intentionally not persisted.

func (*Graph) PrepareHost

func (g *Graph) PrepareHost(ctx context.Context, requirements OperationRequirements, validateWebview WebviewValidator) (PreparedHost, error)

PrepareHost discovers current candidates, selects one for each requirement, and performs live checks. Ambiguous choices require an explicit selection. Webview preparation requires a validator from the consuming backend.

func (*Graph) ReadHost

func (g *Graph) ReadHost(ctx context.Context) (HostSnapshot, error)

ReadHost reads host observations without refreshing or probing the OS.

func (*Graph) ResolveHost

func (g *Graph) ResolveHost(ctx context.Context, requirements OperationRequirements) (HostCandidates, error)

ResolveHost refreshes stale requested categories and returns matching candidates. Webview candidates are installation evidence, not usable backends.

func (*Graph) ResolveInventory

func (g *Graph) ResolveInventory(ctx context.Context, runtimeName string) (Inventory, error)

ResolveInventory reads the CTX projection from the public graph. A blank runtime returns every context. Redacted selections remain in the graph for inspection but cannot be used as executable candidates.

func (*Graph) ScanHost

func (g *Graph) ScanHost(ctx context.Context) (HostInventory, error)

ScanHost refreshes all host inventories in the graph and returns the facts.

func (*Graph) ScanProcesses

func (g *Graph) ScanProcesses(ctx context.Context, options ProcessOptions) (ProcessSnapshot, error)

ScanProcesses discovers and reconciles the caller-visible process inventory.

type HostCandidates

type HostCandidates struct {
	Operation   string               `json:"operation"`
	Shells      []ShellInfo          `json:"shells,omitempty"`
	Filesystems []FilesystemInfo     `json:"filesystems,omitempty"`
	Webviews    []WebviewInfo        `json:"webviews,omitempty"`
	ObservedAt  map[string]time.Time `json:"observed_at"`
}

type HostInventory

type HostInventory struct {
	Shells        []ShellInfo            `json:"shells"`
	Filesystems   []FilesystemInfo       `json:"filesystems"`
	Webviews      []WebviewInfo          `json:"webviews"`
	Desktop       *DesktopInfo           `json:"desktop,omitempty"`
	Surfaces      *SurfaceSnapshot       `json:"surfaces,omitempty"`
	Accessibility *AccessibilitySnapshot `json:"accessibility,omitempty"`
	Permissions   *PermissionSnapshot    `json:"permissions,omitempty"`
	Resources     *ResourceInfo          `json:"resources,omitempty"`
	// contains filtered or unexported fields
}

HostInventory is discovered directly by the graph library, independently of adapters. Nil slices and pointers in ObserveHost preserve the corresponding inventory; non-nil empty slices remove previously observed entries of that kind.

func DiscoverHost

func DiscoverHost(ctx context.Context) (HostInventory, error)

DiscoverHost returns local host inventory without opening a graph store.

type HostRequirementError

type HostRequirementError struct {
	Operation string
	Kind      string
	Reason    string
	Cause     error
}

HostRequirementError identifies a failed operation requirement. Cause, when present, preserves OS, context, and backend errors for errors.Is/errors.As.

func (*HostRequirementError) Error

func (err *HostRequirementError) Error() string

func (*HostRequirementError) Unwrap

func (err *HostRequirementError) Unwrap() error

type HostSnapshot

type HostSnapshot struct {
	HostInventory
	ObservedAt map[string]time.Time `json:"observed_at"`
	// contains filtered or unexported fields
}

HostSnapshot is the typed graph view with separate freshness per category.

type InputOptions added in v0.2.0

type InputOptions struct {
	MaxTextRunes int
	Timeout      time.Duration
}

InputOptions bounds one atomic native input operation. Zero values select a 4096-rune text ceiling and a five-second deadline.

type Inventory

type Inventory struct {
	ObservedAt time.Time          `json:"observed_at"`
	Contexts   []ContextCandidate `json:"contexts"`
}

Inventory is the latest reconciled adapter view. ObservedAt is refreshed on every scan, even when the set of contexts is unchanged.

func (Inventory) Find

func (inventory Inventory) Find(adapter, selection string, capabilities ...string) (ContextCandidate, error)

Find returns a currently observed context with the requested capabilities.

func (Inventory) FreshWithin

func (inventory Inventory) FreshWithin(maxAge time.Duration) bool

type OperationRequirements

type OperationRequirements struct {
	Operation  string                 `json:"operation"`
	Shell      *ShellRequirement      `json:"shell,omitempty"`
	Filesystem *FilesystemRequirement `json:"filesystem,omitempty"`
	Webview    *WebviewRequirement    `json:"webview,omitempty"`
	MaxAge     time.Duration          `json:"-"`
}

OperationRequirements describes host resources needed by a caller. Non-nil requirements are conjunctive. Select pins a resource: failure never causes a different resource to be substituted. MaxAge defaults to five seconds; a negative value forces discovery. No adapter or backend is chosen by name.

type PermissionInfo added in v0.2.0

type PermissionInfo struct {
	State  string `json:"state"`
	Scope  string `json:"scope,omitempty"`
	Detail string `json:"detail,omitempty"`
}

PermissionInfo reports a native capability's current state without asking for access. State is ready, denied, not-determined, not-required, unsupported, or unavailable. Scope names the OS permission when one exists.

type PermissionSnapshot added in v0.2.0

type PermissionSnapshot struct {
	Platform        string         `json:"platform"`
	ObservedAt      time.Time      `json:"observed_at"`
	Accessibility   PermissionInfo `json:"accessibility"`
	ScreenRecording PermissionInfo `json:"screen_recording"`
}

PermissionSnapshot contains local OS permission state relevant to desktop observation. Discovery never opens settings or displays a native prompt.

func DiscoverPermissions added in v0.2.0

func DiscoverPermissions(ctx context.Context) (PermissionSnapshot, error)

DiscoverPermissions reads current local permission state without requesting access or changing OS settings.

type PowerInfo added in v0.2.1

type PowerInfo struct {
	State                string `json:"state"`      // charging, discharging, charged, unknown
	Percentage           int    `json:"percentage"` // 0-100
	TimeRemainingSeconds int64  `json:"time_remaining_seconds,omitempty"`
}

PowerInfo describes battery/power state. All fields are zero when the platform does not expose them.

type PreparedHost

type PreparedHost struct {
	Operation   string          `json:"operation"`
	Shell       *ShellInfo      `json:"shell,omitempty"`
	Filesystem  *FilesystemInfo `json:"filesystem,omitempty"`
	Webview     *WebviewInfo    `json:"webview,omitempty"`
	ValidatedAt time.Time       `json:"validated_at"`
}

PreparedHost contains one validated resource per requirement. This does not authorize execution, reserve capacity, or eliminate races with OS changes.

type ProcessInfo

type ProcessInfo struct {
	PID         int                         `json:"pid"`
	ParentPID   int                         `json:"parent_pid"`
	Name        string                      `json:"name"`
	StartID     string                      `json:"start_id,omitempty"`
	Executable  string                      `json:"executable,omitempty"`
	Owner       string                      `json:"owner,omitempty"`
	Application *ApplicationInfo            `json:"application,omitempty"`
	Usage       *ProcessUsage               `json:"usage,omitempty"`
	Coverage    map[string]CollectionStatus `json:"coverage"`
	Resources   []ProcessResource           `json:"resources,omitempty"`
	// contains filtered or unexported fields
}

ProcessInfo identifies a process instance using PID and an OS start identity. StartID is opaque and platform-specific. Empty StartID means identity could not be established; such entries are returned but never projected as stable nodes.

type ProcessOptions

type ProcessOptions struct {
	MaxProcesses int
	MaxResources int
	Timeout      time.Duration
}

ProcessOptions bounds returned records and collection time. Zero values select 4096 processes, 1024 resources per category, and a ten-second deadline. Detailed resource inspection is opt-in through InspectProcess.

type ProcessResource

type ProcessResource struct {
	Kind          string `json:"kind"`
	Path          string `json:"path,omitempty"`
	Descriptor    string `json:"descriptor,omitempty"`
	Protocol      string `json:"protocol,omitempty"`
	LocalAddress  string `json:"local_address,omitempty"`
	RemoteAddress string `json:"remote_address,omitempty"`
	Endpoint      string `json:"endpoint,omitempty"`
	State         string `json:"state,omitempty"`
}

ProcessResource is OS evidence. A socket does not imply an automation API. Endpoint preserves an OS-rendered address when its roles cannot be established. Descriptors are process-local observations, not reusable handles.

type ProcessSnapshot

type ProcessSnapshot struct {
	HostID      string           `json:"host_id"`
	Scope       string           `json:"scope"`
	ObservedAt  time.Time        `json:"observed_at"`
	Enumeration CollectionStatus `json:"enumeration"`
	Processes   []ProcessInfo    `json:"processes"`
}

ProcessSnapshot is a non-atomic, point-in-time OS observation. Scope is all or process; only complete all-process enumeration permits removing absent PIDs. HostID includes the boot/namespace identity so records cannot cross reboots.

func DiscoverProcesses

func DiscoverProcesses(ctx context.Context, options ProcessOptions) (ProcessSnapshot, error)

DiscoverProcesses collects identities without scanning every process's files. Processes hidden by the OS are outside this caller-visible inventory.

func InspectProcess

func InspectProcess(ctx context.Context, pid int, options ProcessOptions) (ProcessSnapshot, error)

InspectProcess inspects one process and checks its identity again afterwards. Resources collected during exit or PID reuse are discarded, never reassigned.

type ProcessUsage

type ProcessUsage struct {
	ResidentBytes *uint64  `json:"resident_bytes,omitempty"`
	VirtualBytes  *uint64  `json:"virtual_bytes,omitempty"`
	CPUSeconds    *float64 `json:"cpu_seconds,omitempty"`
	Threads       *uint32  `json:"threads,omitempty"`
}

type RecordingInfo added in v0.2.0

type RecordingInfo struct {
	Status           string    `json:"status"`
	EncoderAvailable bool      `json:"encoder_available"`
	CaptureAvailable bool      `json:"capture_available"`
	Permission       string    `json:"permission"`
	Formats          []string  `json:"formats,omitempty"`
	Message          string    `json:"message,omitempty"`
	CheckedAt        time.Time `json:"checked_at"`
}

RecordingInfo describes local recording prerequisites. Permission is an identifier for the embedding application to interpret; discovery never opens settings, requests permission, or starts a capture.

type RelationObservation

type RelationObservation struct{ From, To, Kind string }

RelationObservation connects two resources reported by the same adapter.

type ResourceInfo added in v0.2.0

type ResourceInfo struct {
	OS                  string           `json:"os"`
	Architecture        string           `json:"architecture"`
	ObservedAt          time.Time        `json:"observed_at"`
	LogicalCPUs         int              `json:"logical_cpus"`
	CPUCapacity         float64          `json:"cpu_capacity"`
	CPUStatus           CollectionStatus `json:"cpu_status"`
	MemoryBytes         uint64           `json:"memory_bytes"`
	MemoryCapacityBytes uint64           `json:"memory_capacity_bytes"`
	MemoryStatus        CollectionStatus `json:"memory_status"`
	Storage             []StorageInfo    `json:"storage,omitempty"`
	Power               *PowerInfo       `json:"power,omitempty"`
	Container           ContainerInfo    `json:"container"`
	Uptime              *time.Duration   `json:"uptime,omitempty"`
	BootTime            *time.Time       `json:"boot_time,omitempty"`
	UptimeStatus        CollectionStatus `json:"uptime_status"`
}

ResourceInfo is a point-in-time observation of the local machine's computing resources. Container-adjusted values never guess: a field whose native source is unavailable carries a non-complete status instead of the host value.

It is local host state only. Network shape stays in res/system/network and is never duplicated here.

func DiscoverResources added in v0.2.0

func DiscoverResources(ctx context.Context) (ResourceInfo, error)

DiscoverResources observes the local machine's CPU, memory, container state, storage, power/battery, and uptime. It reads local files and system counters only: no command is launched, no network is contacted, and no identity or protocol is attached.

type ResourceObservation

type ResourceObservation struct {
	ID, Kind, Context string
	Attributes        map[string]any
}

ResourceObservation identifies a resource in one observed context. ID is adapter-local; the graph stores a digest rather than the raw identifier.

type ShellInfo

type ShellInfo struct {
	Name              string   `json:"name"`
	Path              string   `json:"path"`
	ResolvedPath      string   `json:"resolved_path"`
	ConfiguredDefault bool     `json:"configured_default"`
	Sources           []string `json:"sources"`
}

ShellInfo describes an executable available to this host user. Discovery checks paths and permissions without launching the executable. The configured default is an environment declaration, not proof of the current process.

func DiscoverShells

func DiscoverShells(ctx context.Context) ([]ShellInfo, error)

DiscoverShells finds registered shells, standard shell executable names on PATH, platform shell locations, and a configured SHELL/ComSpec executable. Registered and configured paths can identify shells with arbitrary names.

type ShellRequirement

type ShellRequirement struct {
	Name       string  `json:"name,omitempty"`
	Select     string  `json:"select,omitempty"` // Executable name or path.
	SearchPath *string `json:"-"`                // Optional effective PATH, without changing the process environment.
}

type StorageInfo added in v0.2.1

type StorageInfo struct {
	Device         string `json:"device"`
	MountPoint     string `json:"mount_point"`
	TotalBytes     uint64 `json:"total_bytes"`
	AvailableBytes uint64 `json:"available_bytes"`
	Type           string `json:"type,omitempty"`
	ReadOnly       bool   `json:"read_only,omitempty"`
}

StorageInfo describes one mounted storage volume visible to the process.

type SurfaceBounds added in v0.2.0

type SurfaceBounds struct {
	X      int `json:"x"`
	Y      int `json:"y"`
	Width  int `json:"width"`
	Height int `json:"height"`
}

SurfaceBounds is a rectangle in the snapshot's coordinate space. Width and height are always positive. Coordinates may be negative on multi-display desktops.

type SurfaceCapture added in v0.2.0

type SurfaceCapture struct {
	Format     string    `json:"format"`
	Width      int       `json:"width"`
	Height     int       `json:"height"`
	Data       []byte    `json:"data"`
	CapturedAt time.Time `json:"captured_at"`
}

SurfaceCapture is an encoded image captured from one observed window. Data contains the image bytes directly; transport encodings belong to callers.

func CaptureDesktop added in v0.2.0

func CaptureDesktop(ctx context.Context, driver DesktopDriver, options CaptureOptions) (SurfaceCapture, error)

CaptureDesktop captures the caller's desktop through an explicitly selected driver. Bounds and result validation are the same as CaptureWindow.

func CaptureWindow added in v0.2.0

func CaptureWindow(ctx context.Context, target WindowInfo, options CaptureOptions) (SurfaceCapture, error)

CaptureWindow captures a currently observed window after revalidating its opaque ID and process generation. It never prompts for permission, selects a target, persists the image, or applies caller policy.

type SurfaceInput added in v0.2.0

type SurfaceInput struct {
	Kind      SurfaceInputKind `json:"kind"`
	Point     SurfacePoint     `json:"point,omitempty"`
	End       SurfacePoint     `json:"end,omitempty"`
	Button    string           `json:"button,omitempty"`
	DeltaX    int              `json:"delta_x,omitempty"`
	DeltaY    int              `json:"delta_y,omitempty"`
	Text      string           `json:"text,omitempty"`
	Key       string           `json:"key,omitempty"`
	Modifiers []string         `json:"modifiers,omitempty"`
}

SurfaceInput describes one atomic operation. Point is used by pointer operations, End by drag, DeltaX/DeltaY by scroll, Text by keyboard-text, and Key/Modifiers by keyboard-key.

type SurfaceInputKind added in v0.2.0

type SurfaceInputKind string

SurfaceInputKind identifies one bounded, atomic native input operation.

const (
	SurfaceInputMove   SurfaceInputKind = "pointer-move"
	SurfaceInputClick  SurfaceInputKind = "pointer-click"
	SurfaceInputDrag   SurfaceInputKind = "pointer-drag"
	SurfaceInputScroll SurfaceInputKind = "pointer-scroll"
	SurfaceInputText   SurfaceInputKind = "keyboard-text"
	SurfaceInputKey    SurfaceInputKind = "keyboard-key"
)

type SurfaceOptions added in v0.2.0

type SurfaceOptions struct {
	MaxDisplays int
	MaxWindows  int
	Timeout     time.Duration
}

SurfaceOptions bounds returned metadata and collection time. Zero values select 64 displays, 4096 windows, and a five-second deadline.

type SurfacePoint added in v0.2.0

type SurfacePoint struct {
	X int `json:"x"`
	Y int `json:"y"`
}

SurfacePoint uses window-local coordinates in the current window bounds.

type SurfaceSnapshot added in v0.2.0

type SurfaceSnapshot struct {
	Platform        string           `json:"platform"`
	CoordinateSpace string           `json:"coordinate_space"`
	ObservedAt      time.Time        `json:"observed_at"`
	Displays        []DisplayInfo    `json:"displays"`
	Windows         []WindowInfo     `json:"windows"`
	DisplayStatus   CollectionStatus `json:"display_status"`
	WindowStatus    CollectionStatus `json:"window_status"`
}

SurfaceSnapshot is a bounded, non-atomic observation of local displays and windows. Separate statuses distinguish an empty desktop from unavailable or truncated native data.

func DiscoverSurfaces added in v0.2.0

func DiscoverSurfaces(ctx context.Context, options SurfaceOptions) (SurfaceSnapshot, error)

DiscoverSurfaces observes local display geometry and caller-visible windows. It does not request permission, capture pixels, read window titles, expose native handles, synthesize input, or contact a remote service.

type WebviewInfo

type WebviewInfo struct {
	Name         string `json:"name"`
	Engine       string `json:"engine"`
	API          string `json:"api"`
	Version      string `json:"version,omitempty"`
	ABIVersion   string `json:"abi_version,omitempty"`
	Architecture string `json:"architecture,omitempty"`
	Location     string `json:"location"`
	ResolvedPath string `json:"resolved_path,omitempty"`
	Scope        string `json:"scope"`
	Source       string `json:"source"`
	DetailError  string `json:"detail_error,omitempty"`
}

WebviewInfo describes evidence of a shared web rendering runtime. Discovery does not load the runtime or establish that a particular app can use it. Location is a framework/library path or a Windows registry location. Version is the runtime version; ABIVersion is a library API/ABI generation, not the underlying WebKit or Chromium version.

func DiscoverWebviews

func DiscoverWebviews(ctx context.Context) ([]WebviewInfo, error)

DiscoverWebviews inventories host webview runtimes without launching a browser, reading app profiles, or depending on installed CTX adapters.

type WebviewRequirement

type WebviewRequirement struct {
	Select       string `json:"select,omitempty"` // Discovery location.
	Engine       string `json:"engine,omitempty"`
	API          string `json:"api,omitempty"`
	ABIVersion   string `json:"abi_version,omitempty"`
	Version      string `json:"version,omitempty"` // Exact runtime version, when known.
	Architecture string `json:"architecture,omitempty"`
}

type WebviewValidator

type WebviewValidator func(context.Context, WebviewInfo) error

WebviewValidator belongs to the embedding backend. It must establish that this backend can use the selected runtime, including its ABI and dependencies.

type WindowInfo added in v0.2.0

type WindowInfo struct {
	ID             string        `json:"id"`
	PID            int           `json:"pid"`
	ProcessStartID string        `json:"process_start_id"`
	Bounds         SurfaceBounds `json:"bounds"`
	OnScreen       bool          `json:"on_screen"`
}

WindowInfo describes an on-screen top-level window. It intentionally omits titles, application names, native handles, pixels, and input endpoints. ProcessStartID binds PID to a process generation when the OS exposes one.

Directories

Path Synopsis
Package audio defines bounded, transport-free audio device observation and caller-selected capture or playback.
Package audio defines bounded, transport-free audio device observation and caller-selected capture or playback.
Package clipboard defines bounded, transport-free access to a native system clipboard.
Package clipboard defines bounded, transport-free access to a native system clipboard.
credential
adapterkit
Package adapterkit implements the portable process framing for credential store adapters.
Package adapterkit implements the portable process framing for credential store adapters.
client
Package client reads credentials through CTX's installed adapter protocol.
Package client reads credentials through CTX's installed adapter protocol.
examples
consumer-shaped command
This consumer-owned example uses consumer-shaped names to demonstrate that CTX accepts arbitrary namespaces and leaves semantic validation to the consumer.
This consumer-owned example uses consumer-shaped names to demonstrate that CTX accepts arbitrary namespaces and leaves semantic validation to the consumer.
Package graph provides a generic, namespaced, directed graph store.
Package graph provides a generic, namespaced, directed graph store.
Package media provides bounded, transport-free media primitives shared by local system capture and playback implementations.
Package media provides bounded, transport-free media primitives shared by local system capture and playback implementations.
Package network observes the local network stack.
Package network observes the local network stack.
Package service defines portable per-user OS service definitions and their registration lifecycle.
Package service defines portable per-user OS service definitions and their registration lifecycle.
Package share defines the bounded, transport-free model that mobile share and keyboard extensions use to hand text, links, and attachment references to their containing application.
Package share defines the bounded, transport-free model that mobile share and keyboard extensions use to hand text, links, and attachment references to their containing application.
Package supervisor runs generic local component processes and projects their observed lifecycle into a graph.
Package supervisor runs generic local component processes and projects their observed lifecycle into a graph.
Package volume provides bounded snapshot and restore mechanics for a caller-selected local volume or directory.
Package volume provides bounded snapshot and restore mechanics for a caller-selected local volume or directory.

Jump to

Keyboard shortcuts

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