mobile

package
v1.17.1 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2026 License: MIT Imports: 26 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

Package mobile implements Sidecar's bounded headless terminal service.

Index

Constants

View Source
const (
	AttachReady       = "ready"
	AttachCandidate   = "candidate"
	AttachUnavailable = "unavailable"
	AttachAmbiguous   = "ambiguous"
	AttachStale       = "stale"
	AttachUnknown     = "unknown"
	AttachUnsupported = "unsupported"
)

Variables

This section is empty.

Functions

func ComposeCatalog

func ComposeCatalog(query mobileproto.CatalogQuery, identity CatalogIdentity, observedAt time.Time, catalogHosts []mobileproto.CatalogHost, sources []CatalogSource, extraFailures []mobileproto.CatalogFailure) (mobileproto.CatalogSnapshot, error)

ComposeCatalog projects already-authorized owner snapshots through the same query, ordering and grouping rules as QueryCatalog. It performs no target resolution. Callers must obtain each snapshot from the current owning mobile service and remap its public host identity before calling it.

func FixtureIdentity added in v1.16.0

func FixtureIdentity(hub, owner, config, workspace, session, pane string) mobileproto.TargetIdentity

FixtureIdentity returns the real service's stable identity for a synthetic shell.

func FixtureWorkspaceIdentity added in v1.16.0

func FixtureWorkspaceIdentity(hub, owner, config, workspace, kind, session, pane string) mobileproto.TargetIdentity

FixtureWorkspaceIdentity supplies the same deterministic echo authority for shells and worktree terminal candidates, without changing legacy identities.

func IsCandidateSelector

func IsCandidateSelector(value string) bool

func QueryCatalog

func QueryCatalog(ctx context.Context, provider CatalogProvider, resolver Resolver, query mobileproto.CatalogQuery, identity CatalogIdentity) (mobileproto.CatalogSnapshot, error)

QueryCatalog collects and projects one bounded catalog snapshot. It is the common path for the JSON CLI and stdio protocol.

func ValidateCatalogQuery added in v1.16.0

func ValidateCatalogQuery(query mobileproto.CatalogQuery) error

ValidateCatalogQuery checks a query without collecting a catalog.

func WorkspaceCandidates

func WorkspaceCandidates(workspace workspaceinventory.Workspace, ownerHostID string) (string, []mobileproto.CatalogCandidate, error)

WorkspaceCandidates projects the current source-owned pane set into opaque, deterministic selectors. ExpectedTarget remains empty until the owning resolver revalidates the exact pane and terminal incarnation.

Types

type CandidateInspector

type CandidateInspector func(context.Context, string) (tty.HeadlessTargetIdentity, error)

type CaptureSubscription added in v1.16.0

type CaptureSubscription interface {
	RequestSnapshot()
	Close()
}

CaptureSubscription is the slice of tty.ControlSubscription an attachment drives.

type CatalogIdentity

type CatalogIdentity struct {
	HubID, OwnerHostID, OwnerConfigGeneration string
}

type CatalogInput

type CatalogInput struct {
	ObservedAt time.Time
	Hosts      []mobileproto.CatalogHost
	Projects   []CatalogProject
	// CandidateResolver authorizes selectors against this exact inventory
	// observation. It avoids rebuilding the global catalog for every candidate;
	// target open and every later operation still perform fresh source checks.
	CandidateResolver Resolver
	// Resolver authorizes ordinary managed-shell rows with request-scoped
	// discovery. Target open and every later operation still use the service's
	// fresh resolver. When nil, QueryCatalog uses its resolver argument.
	Resolver Resolver
}

type CatalogProject

type CatalogProject struct {
	Result workspaceinventory.ProjectResult
	Label  string
	Order  int
	Stale  bool
}

type CatalogProvider

type CatalogProvider func(context.Context) (CatalogInput, error)

type CatalogQuerier added in v1.16.0

CatalogQuerier projects already-authorized resource snapshots, for adapters that expose the same catalog through HTTP and the terminal protocol.

type CatalogSource

type CatalogSource struct {
	OwnerHostID string
	Snapshot    mobileproto.CatalogSnapshot
}

CatalogSource is one owning service's authoritative, unfiltered project snapshot after the hub has remapped its public identities. Source snapshots use project order so composition retains each owner's configured order.

type Config

type Config struct {
	EndObserver TerminalEndObserver
	Input       io.Reader
	Output      io.Writer
	Resolver    Resolver
	Revalidator TargetRevalidator
	// CaptureRevalidator uses independent read-only evidence after a capture
	// transport fails. Nil uses Revalidator.
	CaptureRevalidator                        TargetRevalidator
	Catalog                                   CatalogProvider
	CatalogQuery                              CatalogQuerier
	HistoryCapturer                           HistoryCapturer
	OwnerConfigGenerationProvider             OwnerConfigGenerationProvider
	HubID, OwnerHostID, OwnerConfigGeneration string
	Manager                                   *tty.ControlManager
	Terminal                                  TerminalBackend
}

type EchoTerminal added in v1.16.0

type EchoTerminal struct {
	// contains filtered or unexported fields
}

EchoTerminal is a deterministic terminal adapter. It echoes bytes, never launches a process, and lets Service own every protocol decision.

func (*EchoTerminal) Geometry added in v1.16.0

func (e *EchoTerminal) Geometry(expected tty.HeadlessTargetIdentity, owner string) (LeaseGeometry, error)

Geometry must not claim: read-only holder polling uses this constructor too.

func (*EchoTerminal) Subscribe added in v1.16.0

type HistoryCapturer

type HistoryCapturer func(target string, start, end, maxBytes int) (tty.CaptureRange, error)

type LeaseGeometry added in v1.16.0

type LeaseGeometry interface {
	ClaimResize(width, height int) error
	SetHolderLabel(kind, label string) error
	Presence(focused, visible bool, idle time.Duration, width, height int, force bool) (bool, error)
	ClaimInput(data []byte, width, height int, paste bool) error
	Paste(data []byte) error
	Holder() (kind, label string, err error)
	Resize(width, height int) error
	Heartbeat() error
	SendLiteral(data []byte) error
	ExpirePresence() (bool, error)
	Release() error
}

LeaseGeometry is the slice of tty.HeadlessGeometry an attachment drives.

type OwnerConfigGenerationProvider

type OwnerConfigGenerationProvider func(context.Context) (string, error)

type ResolveError

type ResolveError struct{ Code, Message string }

func (*ResolveError) Error

func (e *ResolveError) Error() string

type ResolvedTarget

type ResolvedTarget struct {
	WorkspaceID, WorkspaceKind, ProjectRoot, Session, Pane, DisplayName string
	Selector, SourceGeneration, SourceProjectKey, SourceWorkspacePath   string
	ServerPID                                                           int
	SessionID, SessionCreated, DurableSessionCreated                    string
	Width, Height, PaneCount                                            int
}

func FixtureTarget added in v1.16.0

func FixtureTarget(identity mobileproto.TargetIdentity) ResolvedTarget

FixtureTarget supplies a synthetic identity produced by the real resolver's wire mapping; it has no authority over a machine's tmux server.

func ResolveCatalogCandidate

func ResolveCatalogCandidate(ctx context.Context, input CatalogInput, ownerHostID, selector string, inspect CandidateInspector) (ResolvedTarget, error)

ResolveCatalogCandidate re-enumerates the complete current source set and matches one deterministic selector. It never falls back to a residual Workspace PaneID/TmuxName or to another same-named pane.

func RevalidateCatalogCandidate

func RevalidateCatalogCandidate(ctx context.Context, previous ResolvedTarget, ownerHostID string, source CandidateWorkspaceProvider, inspect CandidateInspector) (ResolvedTarget, error)

RevalidateCatalogCandidate checks a bound worktree source before and after exact-pane inspection. The provider is intentionally narrower than a full catalog refresh: it needs only current configured-project membership, one worktree inventory and the current tmux pane list.

type Resolver

type Resolver func(context.Context, string) (ResolvedTarget, error)

func FixtureResolver added in v1.16.0

func FixtureResolver(targets map[string]mobileproto.TargetIdentity) Resolver

FixtureResolver only resolves catalog-supplied selectors and exact identities.

type Service

type Service struct {
	// contains filtered or unexported fields
}

func New

func New(config Config) (*Service, error)

func (*Service) Run

func (s *Service) Run(ctx context.Context) error

func (*Service) TransportDone added in v1.17.0

func (s *Service) TransportDone() <-chan struct{}

TransportDone closes independently of request handling or backend teardown. A process runner can bound its lifetime after stdin EOF or an output failure, including when an in-flight backend call does not honor cancellation.

type TargetRevalidator

type TargetRevalidator func(context.Context, ResolvedTarget) (ResolvedTarget, error)

type TerminalBackend added in v1.16.0

type TerminalBackend interface {
	Subscribe(tty.ControlRequest) (CaptureSubscription, error)
	Geometry(tty.HeadlessTargetIdentity, string) (LeaseGeometry, error)
}

TerminalBackend is the capture/geometry seam for live and fixture terminals. Geometry constructs a read-only handle; ownership changes only through the LeaseGeometry operations, after the service has supplied negotiated labels.

type TerminalEnd added in v1.17.0

type TerminalEnd struct{ ExitStatus *int }

TerminalEnd is positive owner evidence that the pane process has exited. An unavailable/replaced server is not an end; its shells remain restorable.

type TerminalEndObserver added in v1.17.0

type TerminalEndObserver func(context.Context, ResolvedTarget) (*TerminalEnd, error)

Jump to

Keyboard shortcuts

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