browser

package
v0.1.0-p8a.2 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2026 License: MIT Imports: 36 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultFileStoreRecords = 512
	DefaultFileStoreBytes   = 8 * 1024 * 1024
)
View Source
const (
	ReadinessReady       = "ready"
	ReadinessConfigured  = "configured"
	ReadinessBusy        = "busy"
	ReadinessDegraded    = "degraded"
	ReadinessUnavailable = "unavailable"

	CompatibilityUnchecked    = "unchecked"
	CompatibilityCompatible   = "compatible"
	CompatibilityIncompatible = "incompatible"
)
View Source
const (
	MaxIdentifierBytes    = 128
	MaxSafeFailureBytes   = 256
	MaxTerminalBytes      = 320 * 1024
	MaxURLBytes           = 2048
	MaxElementNameBytes   = 512
	MaxDialogMessageBytes = 2048
	MaxScrollAmount       = 5
)
View Source
const (
	ScreenshotDeliveryPending        = "pending"
	ScreenshotDeliveryAlreadyClaimed = "already_claimed"
)

Variables

View Source
var (
	ErrStoreFull   = errors.New("browser state store is full")
	ErrStoreOwned  = errors.New("browser state store is owned by another process")
	ErrStoreClosed = errors.New("browser state store is closed")
)
View Source
var (
	ErrBusy                 = errors.New("browser profile is busy")
	ErrConflict             = errors.New("browser state conflicts with durable state")
	ErrDenied               = errors.New("browser authority denied")
	ErrDriverIncompatible   = errors.New("browser driver is incompatible")
	ErrDriverRejected       = errors.New("browser driver rejected the operation")
	ErrInvalid              = errors.New("invalid browser state")
	ErrNotFound             = errors.New("browser state not found")
	ErrApprovalRequired     = errors.New("browser action requires approval")
	ErrSnapshotInvalidation = errors.New("browser snapshot invalidation failed")
	ErrStale                = errors.New("browser state revision is stale")
	ErrWorkerUnavailable    = errors.New("browser worker is unavailable")
	ErrWorkerLost           = fmt.Errorf("%w: terminal worker loss", ErrWorkerUnavailable)
)

Functions

func OpaqueAgentID

func OpaqueAgentID(agentID string) string

OpaqueAgentID maps a validated configuration alias onto the non-reversible identity used in broker ownership records and authorization checks.

func PlaywrightDownloadAvailable

func PlaywrightDownloadAvailable(root *config.Config) bool

PlaywrightDownloadAvailable reports whether the configured private driver can deny native disk downloads and expose the scoped Chromium stream boundary.

func PlaywrightHandoffAvailable

func PlaywrightHandoffAvailable(root *config.Config) bool

PlaywrightHandoffAvailable reports whether the managed driver owns a headed local browser window. Handoff does not expose a remote endpoint or admit a headless/browser-extension configuration.

Types

type Action

type Action struct {
	Kind           ActionKind `json:"kind"`
	URL            string     `json:"url,omitempty"`
	Ref            string     `json:"ref,omitempty"`
	Target         string     `json:"target,omitempty"`
	Value          string     `json:"value,omitempty"`
	Key            string     `json:"key,omitempty"`
	Direction      string     `json:"direction,omitempty"`
	Amount         int        `json:"amount,omitempty"`
	Decision       string     `json:"decision,omitempty"`
	PromptProvided bool       `json:"prompt_provided,omitempty"`
	ArtifactRef    string     `json:"artifact_ref,omitempty"`
	Deliver        bool       `json:"deliver,omitempty"`
}

func (Action) Validate

func (action Action) Validate(maxTextBytes int) error

type ActionKind

type ActionKind string
const (
	ActionNavigate ActionKind = "navigate"
	ActionClick    ActionKind = "click"
	ActionFill     ActionKind = "fill"
	ActionSelect   ActionKind = "select"
	ActionPress    ActionKind = "press"
	ActionScroll   ActionKind = "scroll"
	ActionDialog   ActionKind = "dialog"
	ActionUpload   ActionKind = "upload"
	ActionDownload ActionKind = "download"
)

func (ActionKind) Valid

func (kind ActionKind) Valid() bool

type ActionWorker

type ActionWorker interface {
	Worker
	Observe(context.Context) (DriverObservation, error)
	Resolve(context.Context, string) (DriverElement, string, error)
	Execute(context.Context, DriverAction) error
	CatalogRevision() string
}

type ApprovalBinding

type ApprovalBinding struct {
	PreparedActionID string `json:"prepared_action_id"`
	ActionHash       string `json:"action_hash"`
	PolicyRevision   string `json:"policy_revision"`
	ExpiresAt        int64  `json:"expires_at"`
}

type Broker

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

func NewBroker

func NewBroker(rootConfig *config.Config, store Store, factory WorkerFactory) (*Broker, error)

func (*Broker) CaptureScreenshot

func (broker *Broker) CaptureScreenshot(
	ctx context.Context,
	request ScreenshotRequest,
) (ScreenshotCapture, error)

CaptureScreenshot captures one PNG only for the exact fresh observation owned by the caller. Artifact persistence and routed delivery remain gateway responsibilities outside the broker.

func (*Broker) Close

func (broker *Broker) Close(ctx context.Context, owner Owner, sessionID string) (Session, error)

func (*Broker) ExecuteAction

func (broker *Broker) ExecuteAction(
	ctx context.Context,
	owner Owner,
	preparedID string,
	approval *ApprovalBinding,
) (Invocation, error)

func (*Broker) ExecuteActionWithDownloadSink

func (broker *Broker) ExecuteActionWithDownloadSink(
	ctx context.Context,
	owner Owner,
	preparedID string,
	approval *ApprovalBinding,
	sink DownloadSink,
) (Invocation, error)

func (*Broker) ExecutePrepared

func (broker *Broker) ExecutePrepared(
	ctx context.Context,
	owner Owner,
	invocationID string,
	actionHash string,
	execute InvocationExecutor,
) (Invocation, error)

ExecutePrepared durably accepts one prepared invocation before dispatch. Existing terminal records are returned idempotently; an existing accepted record becomes unknown and is never dispatched again.

func (*Broker) Handoff

func (broker *Broker) Handoff(ctx context.Context, owner Owner, sessionID string) (Session, error)

Handoff durably removes agent authority before enabling local human input. The controller lease is bounded by the prepared-action window and the session lifetime. No view credential crosses this broker boundary.

func (*Broker) Observe

func (broker *Broker) Observe(ctx context.Context, owner Owner, sessionID, tabID string) (Observation, error)

func (*Broker) Open

func (broker *Broker) Open(ctx context.Context, request OpenRequest) (Session, error)

func (*Broker) PassiveReadiness

func (broker *Broker) PassiveReadiness(
	ctx context.Context,
	targetName string,
	profileName string,
) (PassiveReadiness, error)

PassiveReadiness reports configured and last-observed driver readiness plus durable profile lease state. It does not call Worker.Status, start or close a worker, reconcile state, renew activity, or resolve an artifact reference.

func (*Broker) PassiveTargetDiagnostics

func (broker *Broker) PassiveTargetDiagnostics(
	ctx context.Context,
	targetName string,
	profileNames []string,
) ([]ActionKind, map[string]PassiveReadiness, error)

PassiveTargetDiagnostics combines one immutable factory snapshot with the broker's durable profile lease projection.

func (*Broker) PrepareAction

func (broker *Broker) PrepareAction(ctx context.Context, request PrepareActionRequest) (Preparation, error)

func (*Broker) PreparedAction

func (broker *Broker) PreparedAction(ctx context.Context, owner Owner, id string) (PreparedAction, error)

func (*Broker) ProfileAvailability

func (broker *Broker) ProfileAvailability(
	ctx context.Context,
	targetName string,
	profileName string,
) (ProfileAvailability, error)

ProfileAvailability reports whether a configured profile can accept a new session without starting a worker, reconciling state, or renewing activity.

func (*Broker) Recover

func (broker *Broker) Recover(ctx context.Context, verifiers ...DownloadRecoveryVerifier) error

Recover reconciles state after a gateway restart. B1 workers are in-process, so continuity cannot be proven: live sessions become lost and accepted operations become unknown without dispatch, except typed downloads whose exact committed P2 artifact can still complete without replay.

func (*Broker) RecoverAcceptedDownload

func (broker *Broker) RecoverAcceptedDownload(
	ctx context.Context, owner Owner, preparedID string, terminal json.RawMessage,
) (Invocation, error)

func (*Broker) RecoverableDownloadPreparation

func (broker *Broker) RecoverableDownloadPreparation(
	ctx context.Context, request PrepareActionRequest,
) (Preparation, bool, error)

func (*Broker) ReleaseHandoff

func (broker *Broker) ReleaseHandoff(ctx context.Context, owner Owner, sessionID string) (Session, error)

ReleaseHandoff records the authenticated local operator's release and ends the worker's human-control mode. Agent authority remains paused until a separate Resume call.

func (*Broker) Resume

func (broker *Broker) Resume(ctx context.Context, owner Owner, sessionID string) (Session, error)

Resume restores agent authority only after routed human release has already revoked local input. It rotates controller generation and requires a fresh observation.

func (*Broker) Shutdown

func (broker *Broker) Shutdown(ctx context.Context) error

Shutdown closes every live browser session before the gateway releases the durable store. It is intentionally separate from Recover: a clean gateway stop proves that no worker survived, while restart recovery handles the opposite case after an unclean exit.

func (*Broker) Status

func (broker *Broker) Status(ctx context.Context, owner Owner, sessionID string) (Session, error)

func (*Broker) Sweep

func (broker *Broker) Sweep(ctx context.Context) error

Sweep expires sessions without treating a status check as activity.

func (*Broker) Touch

func (broker *Broker) Touch(ctx context.Context, owner Owner, sessionID string) (Session, error)

Touch records activity after an admitted observe or action. Status and discovery deliberately do not renew the idle deadline.

type ControllerState

type ControllerState string
const (
	ControllerAgent         ControllerState = "agent"
	ControllerHumanPending  ControllerState = "human_pending"
	ControllerHuman         ControllerState = "human"
	ControllerResumePending ControllerState = "resume_pending"
)

func (ControllerState) Valid

func (state ControllerState) Valid() bool

type DialogObservation

type DialogObservation struct {
	Type    string `json:"type"`
	Message string `json:"message"`
}

type DownloadArtifact

type DownloadArtifact struct {
	Ref           string              `json:"ref"`
	Kind          string              `json:"kind"`
	ContentType   string              `json:"content_type"`
	Filename      string              `json:"filename"`
	Size          int64               `json:"size"`
	SHA256        string              `json:"sha256"`
	ExpiresAt     int64               `json:"expires_at"`
	SessionID     string              `json:"browser_session_id"`
	TabID         string              `json:"tab_id"`
	Generation    uint64              `json:"snapshot_generation"`
	Truncated     bool                `json:"truncated"`
	Deliver       bool                `json:"-"`
	DeliveryState string              `json:"-"`
	MediaRef      string              `json:"-"`
	Recovery      *ScreenshotRecovery `json:"-"`
}

type DownloadDeliveryRequest

type DownloadDeliveryRequest struct {
	Owner                               Owner
	RequestID, SessionID, Ref, MediaRef string
	Recovery                            *ScreenshotRecovery
}

type DownloadRecoveryVerifier

type DownloadRecoveryVerifier func(context.Context, PreparedAction) (bool, error)

DownloadRecoveryVerifier proves that the exact retained artifact for an accepted download was committed outside the browser ledger before restart.

type DriverAction

type DriverAction struct {
	Kind           DriverActionKind
	URL            string
	Target         string
	Element        string
	Value          string
	Key            string
	Direction      string
	Amount         int
	Accept         bool
	PromptProvided bool
	ArtifactSHA256 string
	ArtifactBytes  int64
}

type DriverActionKind

type DriverActionKind string
const (
	DriverNavigate       DriverActionKind = "navigate"
	DriverClick          DriverActionKind = "click"
	DriverFill           DriverActionKind = "fill"
	DriverSelect         DriverActionKind = "select"
	DriverPress          DriverActionKind = "press"
	DriverScroll         DriverActionKind = "scroll"
	DriverDialog         DriverActionKind = "dialog"
	DriverUpload         DriverActionKind = "upload"
	DriverDownloadAction DriverActionKind = "download"
)

type DriverDownload

type DriverDownload struct {
	Path, Filename, ContentType, SHA256 string
	Size                                int64
}

type DriverElement

type DriverElement struct {
	Target string
	Role   string
	Name   string
}

type DriverObservation

type DriverObservation struct {
	URL           string
	Origin        string
	Title         string
	Snapshot      string
	Elements      []DriverElement
	PendingDialog *DialogObservation
	Truncated     bool
}

type DriverReadiness

type DriverReadiness struct {
	Status        string `json:"status"`
	Driver        string `json:"driver"`
	Browser       string `json:"browser"`
	Proxy         string `json:"proxy"`
	Compatibility string `json:"compatibility"`
	Code          string `json:"code,omitempty"`
	Action        string `json:"action,omitempty"`
}

DriverReadiness is a bounded, path-free snapshot supplied by a worker factory. Reading it must not start a driver, probe a browser, or mutate the factory's last-observed compatibility state.

type DriverScreenshot

type DriverScreenshot struct {
	Data        []byte
	ContentType string
}

type Effect

type Effect string
const (
	EffectRead           Effect = "read"
	EffectNavigation     Effect = "navigation"
	EffectLocalEdit      Effect = "local_edit"
	EffectExternalCommit Effect = "external_commit"
	EffectUnknown        Effect = "unknown"
)

func (Effect) Valid

func (effect Effect) Valid() bool

type FileStore

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

FileStore is the gateway's bounded durable browser state boundary. One gateway process owns the document at a time; every mutation is an atomic owner-only replacement.

func NewFileStore

func NewFileStore(path string, maxRecords, maxBytes int) (*FileStore, error)

func (*FileStore) Close

func (store *FileStore) Close()

func (*FileStore) CreateInvocation

func (store *FileStore) CreateInvocation(_ context.Context, invocation Invocation) error

func (*FileStore) CreatePreparation

func (store *FileStore) CreatePreparation(
	_ context.Context,
	prepared PreparedAction,
	invocation Invocation,
) error

func (*FileStore) CreateSession

func (store *FileStore) CreateSession(_ context.Context, session Session) error

func (*FileStore) GetInvocation

func (store *FileStore) GetInvocation(_ context.Context, id string) (Invocation, error)

func (*FileStore) GetPreparedAction

func (store *FileStore) GetPreparedAction(_ context.Context, id string) (PreparedAction, error)

func (*FileStore) GetSession

func (store *FileStore) GetSession(_ context.Context, id string) (Session, error)

func (*FileStore) ListInvocations

func (store *FileStore) ListInvocations(_ context.Context, sessionID string) ([]Invocation, error)

func (*FileStore) ListSessions

func (store *FileStore) ListSessions(_ context.Context) ([]Session, error)

func (*FileStore) PruneInvocations

func (store *FileStore) PruneInvocations(_ context.Context, completedBefore int64) error

func (*FileStore) PrunePreparedActions

func (store *FileStore) PrunePreparedActions(_ context.Context, expiredBefore int64) error

func (*FileStore) UpdateInvocation

func (store *FileStore) UpdateInvocation(_ context.Context, expected uint64, next Invocation) error

func (*FileStore) UpdateSession

func (store *FileStore) UpdateSession(_ context.Context, expected uint64, next Session) error

type HumanControllerWorker

type HumanControllerWorker interface {
	Worker
	BeginHumanControl(context.Context) error
	EndHumanControl(context.Context) error
}

type Invocation

type Invocation struct {
	ID               string            `json:"id"`
	PreparedActionID string            `json:"prepared_action_id,omitempty"`
	SessionID        string            `json:"session_id"`
	Owner            Owner             `json:"owner"`
	ActionHash       string            `json:"action_hash"`
	Effect           Effect            `json:"effect"`
	State            InvocationState   `json:"state"`
	Revision         uint64            `json:"revision"`
	CreatedAt        int64             `json:"created_at"`
	UpdatedAt        int64             `json:"updated_at"`
	ExpiresAt        int64             `json:"expires_at"`
	AcceptedAt       int64             `json:"accepted_at,omitempty"`
	CompletedAt      int64             `json:"completed_at,omitempty"`
	TerminalResult   json.RawMessage   `json:"terminal_result,omitempty"`
	SafeFailure      string            `json:"safe_failure,omitempty"`
	Download         *DownloadArtifact `json:"-"`
}

func (Invocation) Validate

func (invocation Invocation) Validate() error

type InvocationExecutor

type InvocationExecutor func(context.Context) (json.RawMessage, error)

InvocationExecutor crosses the driver acceptance boundary exactly once. It must stop driver work and return when its context is done; a caller must not add retries below this callback.

type InvocationState

type InvocationState string
const (
	InvocationPrepared  InvocationState = "prepared"
	InvocationAccepted  InvocationState = "accepted"
	InvocationSucceeded InvocationState = "succeeded"
	InvocationFailed    InvocationState = "failed"
	InvocationUnknown   InvocationState = "unknown"
	InvocationCanceled  InvocationState = "canceled"
)

func (InvocationState) Terminal

func (state InvocationState) Terminal() bool

func (InvocationState) Valid

func (state InvocationState) Valid() bool

type MemoryStore

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

func NewMemoryStore

func NewMemoryStore() *MemoryStore

func (*MemoryStore) CreateInvocation

func (store *MemoryStore) CreateInvocation(_ context.Context, invocation Invocation) error

func (*MemoryStore) CreatePreparation

func (store *MemoryStore) CreatePreparation(
	_ context.Context,
	prepared PreparedAction,
	invocation Invocation,
) error

func (*MemoryStore) CreateSession

func (store *MemoryStore) CreateSession(_ context.Context, session Session) error

func (*MemoryStore) GetInvocation

func (store *MemoryStore) GetInvocation(_ context.Context, id string) (Invocation, error)

func (*MemoryStore) GetPreparedAction

func (store *MemoryStore) GetPreparedAction(_ context.Context, id string) (PreparedAction, error)

func (*MemoryStore) GetSession

func (store *MemoryStore) GetSession(_ context.Context, id string) (Session, error)

func (*MemoryStore) ListInvocations

func (store *MemoryStore) ListInvocations(_ context.Context, sessionID string) ([]Invocation, error)

func (*MemoryStore) ListSessions

func (store *MemoryStore) ListSessions(_ context.Context) ([]Session, error)

func (*MemoryStore) PruneInvocations

func (store *MemoryStore) PruneInvocations(_ context.Context, completedBefore int64) error

func (*MemoryStore) PrunePreparedActions

func (store *MemoryStore) PrunePreparedActions(_ context.Context, expiredBefore int64) error

func (*MemoryStore) UpdateInvocation

func (store *MemoryStore) UpdateInvocation(_ context.Context, expected uint64, next Invocation) error

func (*MemoryStore) UpdateSession

func (store *MemoryStore) UpdateSession(_ context.Context, expected uint64, next Session) error
type NavigationCheckedActionWorker interface {
	NavigationIdentityWorker
	ExecuteAfterNavigationCheck(context.Context, string, DriverAction) error
}

NavigationCheckedActionWorker performs one final private navigation check immediately before issuing a fixed typed action. The check is the authority linearization point; the native input operation that follows is not atomic with it.

type NavigationIdentityWorker interface {
	ActionWorker
	NavigationIdentity(context.Context) (string, error)
}

NavigationIdentityWorker exposes a driver-owned, monotonic identity for the current main-frame navigation state. The identity is private runtime state: callers use it to reject document and same-document transitions that reproduce the same observable snapshot.

type Observation

type Observation struct {
	SessionID          string             `json:"browser_session_id"`
	TabID              string             `json:"tab_id"`
	SnapshotID         string             `json:"snapshot_id"`
	SnapshotGeneration uint64             `json:"snapshot_generation"`
	URL                string             `json:"url"`
	Origin             string             `json:"origin"`
	Title              string             `json:"title,omitempty"`
	Snapshot           string             `json:"snapshot"`
	PendingDialog      *DialogObservation `json:"pending_dialog,omitempty"`
	Truncated          bool               `json:"truncated"`
}

type OpenRequest

type OpenRequest struct {
	Owner   Owner
	Target  string
	Profile string
}

type Owner

type Owner struct {
	ActorID     string `json:"actor_id"`
	AgentID     string `json:"agent_id"`
	SessionKey  string `json:"session_key"`
	ExecutionID string `json:"execution_id"`
}

func (Owner) Equal

func (owner Owner) Equal(other Owner) bool

func (Owner) Validate

func (owner Owner) Validate() error

type PassiveReadiness

type PassiveReadiness struct {
	Status        string              `json:"status"`
	Broker        string              `json:"broker"`
	Worker        string              `json:"worker"`
	Driver        string              `json:"driver"`
	Browser       string              `json:"browser"`
	Proxy         string              `json:"proxy"`
	Compatibility string              `json:"compatibility"`
	Profile       ProfileAvailability `json:"profile"`
	Code          string              `json:"code,omitempty"`
	Action        string              `json:"action,omitempty"`
	Passive       bool                `json:"passive"`
}

PassiveReadiness combines the factory snapshot with the broker's durable profile lease projection. It contains enums and operator guidance only.

type PlaywrightManagedHostConfig

type PlaywrightManagedHostConfig struct {
	Target        string
	Profile       string
	ProfileConfig config.BrowserProfileConfig
	ServerConfig  config.MCPServerConfig
}

PlaywrightManagedHostConfig binds the existing private Playwright adapter to an execution host. It is intentionally driver-facing rather than model-facing: callers must derive every field from trusted local policy.

type PlaywrightWorkerFactory

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

func NewPlaywrightManagedHostFactory

func NewPlaywrightManagedHostFactory(
	host PlaywrightManagedHostConfig,
) (*PlaywrightWorkerFactory, error)

NewPlaywrightManagedHostFactory reuses the B1 Playwright worker on another trusted host. Its driver configuration is companion-local and must never be projected into a capability catalog or model-visible result.

func NewPlaywrightWorkerFactory

func NewPlaywrightWorkerFactory(rootConfig *config.Config) (*PlaywrightWorkerFactory, error)

func (*PlaywrightWorkerFactory) Open

func (*PlaywrightWorkerFactory) PassiveReadiness

func (factory *PlaywrightWorkerFactory) PassiveReadiness() DriverReadiness

PassiveReadiness reads configuration, executable availability, and the compatibility outcome cached by prior real opens. It never starts npx or a browser and never probes an active worker.

type Preparation

type Preparation struct {
	Action           PreparedAction
	Approval         ApprovalBinding
	RequiresApproval bool
}

type PrepareActionRequest

type PrepareActionRequest struct {
	Owner              Owner
	RequestID          string
	SessionID          string
	TabID              string
	SnapshotID         string
	SnapshotGeneration uint64
	Action             Action
	Upload             *UploadBinding
}

type PreparedAction

type PreparedAction struct {
	ID                   string `json:"id"`
	RequestID            string `json:"request_id"`
	SessionID            string `json:"session_id"`
	Owner                Owner  `json:"owner"`
	Target               string `json:"target"`
	Profile              string `json:"profile"`
	ControllerGeneration uint64 `json:"controller_generation"`
	TabID                string `json:"tab_id"`
	SnapshotID           string `json:"snapshot_id"`
	SnapshotGeneration   uint64 `json:"snapshot_generation"`
	CurrentOrigin        string `json:"current_origin"`
	DestinationOrigin    string `json:"destination_origin,omitempty"`
	Action               Action `json:"action"`
	InputDigest          string `json:"input_digest,omitempty"`
	InputBytes           int    `json:"input_bytes,omitempty"`
	ArtifactSHA256       string `json:"artifact_sha256,omitempty"`
	ArtifactBytes        int64  `json:"artifact_bytes,omitempty"`
	ArtifactFilename     string `json:"artifact_filename,omitempty"`
	ArtifactContentType  string `json:"artifact_content_type,omitempty"`
	ElementRole          string `json:"element_role,omitempty"`
	ElementName          string `json:"element_name,omitempty"`
	DialogType           string `json:"dialog_type,omitempty"`
	DialogMessage        string `json:"dialog_message,omitempty"`
	Effect               Effect `json:"effect"`
	DryRun               bool   `json:"dry_run"`
	PolicyRevision       string `json:"policy_revision"`
	CatalogRevision      string `json:"catalog_revision"`
	ActionHash           string `json:"action_hash"`
	CreatedAt            int64  `json:"created_at"`
	ExpiresAt            int64  `json:"expires_at"`
}

PreparedAction is the immutable durable authority that approval binds. It deliberately omits the driver-local element target; that target remains in the live worker slot and is usable only while the bound snapshot is fresh.

func (PreparedAction) Validate

func (prepared PreparedAction) Validate(maxTextBytes int) error

type PreparedActionWorker

type PreparedActionWorker interface {
	ActionWorker
	SupportsPreparedAction(ActionKind) bool
	ExecutePrepared(context.Context, WorkerPreparedAction) error
}

PreparedActionWorker receives the gateway-owned durable authority for one accepted action and must revalidate live driver state before dispatch. Remote workers use it to bind a typed node invocation; local driver workers continue to implement ActionWorker only.

type ProfileAvailability

type ProfileAvailability struct {
	Status string
	Reason string
}

type ScreenshotArtifact

type ScreenshotArtifact struct {
	Ref                string              `json:"ref"`
	Kind               string              `json:"kind"`
	ContentType        string              `json:"content_type"`
	Filename           string              `json:"filename"`
	Size               int64               `json:"size"`
	SHA256             string              `json:"sha256"`
	ExpiresAt          int64               `json:"expires_at"`
	SessionID          string              `json:"browser_session_id"`
	TabID              string              `json:"tab_id"`
	SnapshotID         string              `json:"snapshot_id"`
	SnapshotGeneration uint64              `json:"snapshot_generation"`
	Truncated          bool                `json:"truncated"`
	DeliveryState      string              `json:"-"`
	MediaRef           string              `json:"-"`
	Recovery           *ScreenshotRecovery `json:"-"`
}

type ScreenshotCapture

type ScreenshotCapture struct {
	SessionID          string
	Target             string
	Profile            string
	PolicyRevision     string
	TabID              string
	SnapshotID         string
	SnapshotGeneration uint64
	Data               []byte
	ContentType        string
}

type ScreenshotDeliveryRequest

type ScreenshotDeliveryRequest struct {
	Owner     Owner
	RequestID string
	SessionID string
	Ref       string
	MediaRef  string
	Recovery  *ScreenshotRecovery
}

type ScreenshotRecovery

type ScreenshotRecovery struct {
	WorkspaceID string
	AgentID     string
	ActorID     string
	RouteID     string
	SessionID   string
	ToolCallID  string
}

type ScreenshotRequest

type ScreenshotRequest struct {
	Owner              Owner
	RequestID          string
	SessionID          string
	TabID              string
	SnapshotID         string
	SnapshotGeneration uint64
}

type ScreenshotWorker

type ScreenshotWorker interface {
	ActionWorker
	CaptureScreenshot(context.Context, int) (DriverScreenshot, error)
}

type Session

type Session struct {
	ID                   string          `json:"id"`
	Owner                Owner           `json:"owner"`
	Target               string          `json:"target"`
	Profile              string          `json:"profile"`
	State                SessionState    `json:"state"`
	DryRun               bool            `json:"dry_run"`
	PolicyRevision       string          `json:"policy_revision"`
	ControllerGeneration uint64          `json:"controller_generation"`
	Controller           ControllerState `json:"controller"`
	ControllerExpiresAt  int64           `json:"controller_expires_at,omitempty"`
	TabID                string          `json:"tab_id"`
	SnapshotID           string          `json:"snapshot_id,omitempty"`
	SnapshotGeneration   uint64          `json:"snapshot_generation"`
	SnapshotOrigin       string          `json:"snapshot_origin,omitempty"`
	Revision             uint64          `json:"revision"`
	CreatedAt            int64           `json:"created_at"`
	UpdatedAt            int64           `json:"updated_at"`
	LastActivityAt       int64           `json:"last_activity_at"`
	ExpiresAt            int64           `json:"expires_at"`
	SafeFailure          string          `json:"safe_failure,omitempty"`
}

func (Session) EffectiveController

func (session Session) EffectiveController() ControllerState

func (Session) Validate

func (session Session) Validate() error

type SessionState

type SessionState string
const (
	SessionOpening SessionState = "opening"
	SessionReady   SessionState = "ready"
	SessionClosing SessionState = "closing"
	SessionClosed  SessionState = "closed"
	SessionExpired SessionState = "expired"
	SessionLost    SessionState = "lost"
)

func (SessionState) Terminal

func (state SessionState) Terminal() bool

func (SessionState) Valid

func (state SessionState) Valid() bool

type Store

type Store interface {
	CreateSession(context.Context, Session) error
	GetSession(context.Context, string) (Session, error)
	ListSessions(context.Context) ([]Session, error)
	UpdateSession(context.Context, uint64, Session) error
	CreatePreparation(context.Context, PreparedAction, Invocation) error
	GetPreparedAction(context.Context, string) (PreparedAction, error)
	CreateInvocation(context.Context, Invocation) error
	GetInvocation(context.Context, string) (Invocation, error)
	ListInvocations(context.Context, string) ([]Invocation, error)
	UpdateInvocation(context.Context, uint64, Invocation) error
	PruneInvocations(context.Context, int64) error
	PrunePreparedActions(context.Context, int64) error
}

Store is the broker's durable compare-and-swap boundary. The memory implementation supports foundation tests; a file-backed store lands with lifecycle and restart recovery.

type TargetDiagnostics

type TargetDiagnostics struct {
	Actions  []ActionKind
	Profiles map[string]DriverReadiness
}

TargetDiagnostics is one immutable worker-factory capability snapshot for a target and its configured profiles.

type TransferWorker

type TransferWorker interface {
	ActionWorker
	Upload(context.Context, DriverAction) error
	Download(context.Context, DriverAction, int64) (DriverDownload, error)
}

type UploadBinding

type UploadBinding struct {
	Ref, SHA256, Filename, ContentType, Path string
	Size                                     int64
}

type Worker

type Worker interface {
	Status(context.Context) (WorkerStatus, error)
	Close(context.Context) error
}

type WorkerFactory

type WorkerFactory interface {
	Open(context.Context, WorkerOpenRequest) (WorkerOpenResult, error)
}

type WorkerOpenRequest

type WorkerOpenRequest struct {
	SessionID string
	Owner     Owner
	Target    string
	Profile   string
	DryRun    bool
	Limits    config.BrowserLimitsConfig
}

type WorkerOpenResult

type WorkerOpenResult struct {
	Owner Worker
}

WorkerOpenResult transfers exactly one lifecycle owner to the broker. Owner is admitted as a worker only when Open succeeds; after a failed startup it is retained solely so cleanup can be retried.

type WorkerPreparedAction

type WorkerPreparedAction struct {
	InvocationID string
	Prepared     PreparedAction
	DriverAction DriverAction
}

type WorkerStatus

type WorkerStatus string
const (
	WorkerReady WorkerStatus = "ready"
	WorkerLost  WorkerStatus = "lost"
)

Jump to

Keyboard shortcuts

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