host

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 40 Imported by: 1 module, 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 host implements presentation-host plugins. It contains no realtime server internals: relays and clients use only public wire endpoints.

Index

Constants

View Source
const (
	DefaultMaxArtifactBytes      int64 = 2 << 20
	DefaultMaxArtifactTotalBytes int64 = 16 << 20
	DefaultMaxArtifacts                = 64
)
View Source
const (
	DefaultMaxDownloadBytes      int64 = 8 << 20
	DefaultMaxDownloadTotalBytes int64 = 32 << 20
	DefaultMaxDownloads                = 64
)
View Source
const (

	// ManagementIdentityHeader is non-secret response evidence produced only
	// after the host has rebound and validated an upstream resource. Browser
	// clients require it before exposing a static or authoring result.
	ManagementIdentityHeader = "OpenRealtime-Management-Identity"
)

Variables

View Source
var (
	// ErrResourceStoreClosed means a withdrawn plugin service was retained by a
	// stale caller. No content is admitted or returned after this error.
	ErrResourceStoreClosed = errors.New("presentation resource store is closed")
	// ErrResourceStoreQuiescing means reconciliation has temporarily closed
	// mutation admission while capturing exact restorable state.
	ErrResourceStoreQuiescing = errors.New("presentation resource store is quiescing for state capture")
)

Functions

func DefaultEffectsCatalogDigest

func DefaultEffectsCatalogDigest() (string, error)

DefaultEffectsCatalogDigest returns the immutable catalog identity used by the shipped effect profile. Client profiles pin this value; profiles with custom tools instead use the digest from their exact EffectsFactory.

func HTTPHandler

func HTTPHandler(mounted *pluginruntime.Mounted, export string) (http.Handler, error)

HTTPHandler returns the exact handler deliberately exported by a mounted presentation-host profile.

Types

type Artifact

type Artifact struct {
	ID        string    `json:"id"`
	Title     string    `json:"title"`
	Path      string    `json:"path"`
	Digest    string    `json:"digest"`
	Bytes     int64     `json:"bytes"`
	Version   uint64    `json:"version"`
	UpdatedAt time.Time `json:"updated_at"`
}

Artifact is the payload-free reference a client can safely receive.

type ArtifactInput

type ArtifactInput struct {
	ID    string
	Title string
	HTML  string
}

ArtifactInput is model-authored markup admitted by an effect/tool provider. HTML is copied before Publish returns and is never exposed by store metadata.

type ArtifactStore

type ArtifactStore interface {
	Publish(context.Context, ArtifactInput) (Artifact, error)
	Lookup(id string) (Artifact, bool)
	List() []Artifact
	Stats() ResourceStoreStats
}

ArtifactStore is the typed host service used by an independently mounted effect provider. Serving and publication remain owned by this plugin scope.

type ArtifactStoreFactory

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

ArtifactStoreFactory owns one bounded artifact store and its exact route.

func NewArtifactStoreFactory

func NewArtifactStoreFactory() *ArtifactStoreFactory

func (*ArtifactStoreFactory) Descriptor

func (factory *ArtifactStoreFactory) Descriptor() plugin.Descriptor

func (*ArtifactStoreFactory) Mount

func (*ArtifactStoreFactory) PreMount

func (*ArtifactStoreFactory) ValidateConfig

func (factory *ArtifactStoreFactory) ValidateConfig(raw json.RawMessage) error

type BrowserShellFactory

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

BrowserShellFactory serves only the mechanics needed to load a locked client manifest. All visible product behavior comes from client plugins.

func NewBrowserShellFactory

func NewBrowserShellFactory(revision uint64, bootstrapDigest string) (*BrowserShellFactory, error)

func (*BrowserShellFactory) Descriptor

func (factory *BrowserShellFactory) Descriptor() plugin.Descriptor

func (*BrowserShellFactory) Mount

func (*BrowserShellFactory) PreMount

type CredentialFactory

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

func NewAnonymousCredentialFactory

func NewAnonymousCredentialFactory() *CredentialFactory

func NewBearerCredentialFactory

func NewBearerCredentialFactory(token string) (*CredentialFactory, error)

func (*CredentialFactory) Descriptor

func (factory *CredentialFactory) Descriptor() plugin.Descriptor

func (*CredentialFactory) Mount

func (factory *CredentialFactory) Mount(ctx context.Context, mount pluginruntime.MountContext) error

func (*CredentialFactory) PreMount

type CredentialSource

type CredentialSource interface {
	Authorization(context.Context) (string, error)
}

CredentialSource supplies an authorization header only inside the host. A manifest, client module, or HTTP response never receives this service.

type DenyEffectAuthorityFactory

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

DenyEffectAuthorityFactory is the independently composable fail-closed authority provider. Development and production profiles may replace it with a verifier for server-minted receipts without replacing the effects route, declarations, stores, or client adapter.

func NewDenyEffectAuthorityFactory

func NewDenyEffectAuthorityFactory() *DenyEffectAuthorityFactory

func (*DenyEffectAuthorityFactory) Descriptor

func (factory *DenyEffectAuthorityFactory) Descriptor() plugin.Descriptor

func (*DenyEffectAuthorityFactory) Mount

func (*DenyEffectAuthorityFactory) PreMount

type Download

type Download struct {
	ID        string    `json:"id"`
	Filename  string    `json:"filename"`
	MediaType string    `json:"media_type"`
	Path      string    `json:"path"`
	Digest    string    `json:"digest"`
	Bytes     int64     `json:"bytes"`
	Version   uint64    `json:"version"`
	UpdatedAt time.Time `json:"updated_at"`
}

Download is the payload-free reference safe to expose to a client.

type DownloadInput

type DownloadInput struct {
	ID        string
	Filename  string
	MediaType string
	Content   []byte
}

DownloadInput is one generated file admitted by an effect/tool provider. Content is cloned before Publish returns; paths are deliberately absent.

type DownloadStore

type DownloadStore interface {
	Publish(context.Context, DownloadInput) (Download, error)
	Lookup(id string) (Download, bool)
	List() []Download
	Stats() ResourceStoreStats
}

DownloadStore is a bounded memory-backed publication service. It cannot read a filesystem path and its route always forces attachment disposition.

type DownloadStoreFactory

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

DownloadStoreFactory owns one bounded generated-file store and route.

func NewDownloadStoreFactory

func NewDownloadStoreFactory() *DownloadStoreFactory

func (*DownloadStoreFactory) Descriptor

func (factory *DownloadStoreFactory) Descriptor() plugin.Descriptor

func (*DownloadStoreFactory) Mount

func (*DownloadStoreFactory) PreMount

func (*DownloadStoreFactory) ValidateConfig

func (factory *DownloadStoreFactory) ValidateConfig(raw json.RawMessage) error

type EffectAuditRecord

type EffectAuditRecord struct {
	ScopeID           string               `json:"scope_id"`
	SessionID         string               `json:"session_id,omitempty"`
	CallID            string               `json:"call_id,omitempty"`
	Name              string               `json:"name,omitempty"`
	DeclarationDigest string               `json:"declaration_digest,omitempty"`
	Target            string               `json:"target,omitempty"`
	Confirmation      legacyaction.Confirm `json:"confirmation,omitempty"`
	Authorized        bool                 `json:"authorized"`
	Confirmed         bool                 `json:"confirmed"`
	Crossed           bool                 `json:"crossed"`
	Executed          bool                 `json:"executed"`
	Replayed          bool                 `json:"replayed"`
	ErrorCode         string               `json:"error_code,omitempty"`
	StartedAt         time.Time            `json:"started_at"`
	FinishedAt        time.Time            `json:"finished_at"`
}

EffectAuditRecord is a payload-free terminal record. It names the exact declaration and target but retains neither arguments, result content, authority evidence, nor confirmation nonce.

type EffectAuthority

type EffectAuthority interface {
	Authorize(context.Context, EffectAuthorityRequest) (EffectAuthorityDecision, error)
}

EffectAuthority validates a server/deployment authority receipt. Effects cannot mount without an exact provider service; the shipped deny provider is the fail-closed choice, including for non-mutating tools.

type EffectAuthorityDecision

type EffectAuthorityDecision struct {
	SessionID         string
	CallID            string
	Name              string
	ArgumentsDigest   string
	DeclarationDigest string
	Target            string
}

EffectAuthorityDecision is the verifier's exact receipt. Every field is compared with the host-owned admission. A broad boolean is intentionally insufficient: an approval for one declaration or target cannot bless another call.

type EffectAuthorityFunc

func (EffectAuthorityFunc) Authorize

type EffectAuthorityRequest

type EffectAuthorityRequest struct {
	ScopeID           string
	SessionID         string
	CallID            string
	Name              string
	ArgumentsDigest   string
	DeclarationDigest string
	Target            string
	Evidence          string
}

EffectAuthorityRequest is passed only to the deployment-supplied verifier. Evidence is opaque and bounded; it is never echoed, logged, retained in an audit record, or handed to the executor.

type EffectCall

type EffectCall struct {
	ScopeID           string
	SessionID         string
	CallID            string
	Name              string
	Arguments         json.RawMessage
	ArgumentsDigest   string
	DeclarationDigest string
	Target            string
}

EffectCall is the canonical call handed to an executor or target fence. Arguments have already passed strict JSON and the declaration's JSON Schema. AuthorityEvidence never crosses this boundary.

type EffectChannel

type EffectChannel string

EffectChannel is presentation metadata selected by the enforcing provider. A client may render channels differently, but it cannot select one for a call or infer one from a tool name.

const (
	EffectChannelTool     EffectChannel = "tool"
	EffectChannelComputer EffectChannel = "computer"
	EffectChannelArtifact EffectChannel = "artifact"
	EffectChannelDownload EffectChannel = "download"
)

type EffectDeclaration

type EffectDeclaration struct {
	Name           string               `json:"name"`
	Description    string               `json:"description"`
	Parameters     json.RawMessage      `json:"parameters"`
	Confirm        legacyaction.Confirm `json:"host_confirmation"`
	SessionConfirm legacyaction.Confirm `json:"session_confirmation"`
	Target         string               `json:"target,omitempty"`
	Mutating       bool                 `json:"mutating"`
	Channel        EffectChannel        `json:"channel"`
	Digest         string               `json:"digest"`
}

EffectDeclaration is the immutable, payload-free definition advertised by the host. Confirm is enforced here; SessionConfirm is always "never" because the local host, rather than the remote model service, owns the person's confirmation exchange.

type EffectExecutor

type EffectExecutor interface {
	Execute(context.Context, EffectCall) (EffectResult, error)
}

EffectExecutor performs one admitted effect. Implementations must honor the supplied context and be idempotent by CallID as a second line of defence; the host also serialises and caches one result for each admitted call ID.

type EffectExecutorFunc

type EffectExecutorFunc func(context.Context, EffectCall) (EffectResult, error)

func (EffectExecutorFunc) Execute

func (function EffectExecutorFunc) Execute(ctx context.Context, call EffectCall) (EffectResult, error)

type EffectPolicy

type EffectPolicy func(EffectTargetRequest) bool

EffectPolicy may admit a declaration whose confirmation mode is "policy". Nil is deliberately equivalent to no admission, so the client is asked.

type EffectReceiptAuthorityFactory

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

EffectReceiptAuthorityFactory is the descriptor-visible host verifier for server-issued client-effect receipts. EffectsFactory consumes only the EffectAuthorityContract, so deployments can replace this verifier without replacing declarations, routes, stores, confirmation, or executors.

func NewEffectReceiptAuthorityFactory

func NewEffectReceiptAuthorityFactory(
	provider effectauthority.EffectReceiptVerifierProvider,
) (*EffectReceiptAuthorityFactory, error)

NewEffectReceiptAuthorityFactory locks one lifecycle-aware verifier behind an independently selectable plugin descriptor. The provider identity is non-secret and is checked again for every receipt to reject live drift.

func (*EffectReceiptAuthorityFactory) Descriptor

func (factory *EffectReceiptAuthorityFactory) Descriptor() plugin.Descriptor

func (*EffectReceiptAuthorityFactory) Mount

type EffectResult

type EffectResult struct {
	Output   string
	Artifact *Artifact
	Download *Download
}

EffectResult is a bounded result. Artifact and download references contain metadata only; their model-authored bytes stay in the independently scoped stores and routes.

type EffectTargetFence

type EffectTargetFence interface {
	Admit(context.Context, EffectTargetRequest) error
}

EffectTargetFence validates that arguments remain inside the declaration's fixed target immediately before the call enters idempotent dispatch.

func ExactArgumentTargetFence

func ExactArgumentTargetFence(field string) (EffectTargetFence, error)

ExactArgumentTargetFence creates the common fixed-target fence. The named JSON argument must be a string exactly equal to the immutable declaration target. It is deliberately strict rather than accepting aliases.

type EffectTargetFenceFunc

type EffectTargetFenceFunc func(context.Context, EffectTargetRequest) error

func (EffectTargetFenceFunc) Admit

func (function EffectTargetFenceFunc) Admit(ctx context.Context, request EffectTargetRequest) error

type EffectTargetRequest

type EffectTargetRequest struct {
	Declaration EffectDeclaration
	Call        EffectCall
}

EffectTargetRequest carries the provider-owned target and validated call. No target field exists in the wire call outside the declared arguments.

type EffectTool

type EffectTool struct {
	Declaration         EffectDeclaration
	Executor            EffectExecutor
	TargetFence         EffectTargetFence
	PermissionResource  string
	PermissionOperation string
}

EffectTool binds one immutable declaration to an implementation and an exact permission resource. PermissionOperation defaults to "execute". A non-empty target requires an explicit fence.

type Effects

type Effects interface {
	Declarations() []EffectDeclaration
	Stats() EffectsStats
	Audit() []EffectAuditRecord
}

Effects is the read-only host service. Execution remains reachable only through the scoped route so another plugin cannot bypass admission by obtaining the service interface.

type EffectsFactory

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

EffectsFactory mounts the exact effect catalog, bounded socket, and read-only discovery service. Its descriptor contains a digest of the declaration catalog and one permission ceiling for every effect resource.

func NewEffectsFactory

func NewEffectsFactory(options EffectsOptions) (*EffectsFactory, error)

func (*EffectsFactory) CatalogDigest

func (factory *EffectsFactory) CatalogDigest() string

func (*EffectsFactory) DeclarationsDocument

func (factory *EffectsFactory) DeclarationsDocument() []byte

func (*EffectsFactory) Descriptor

func (factory *EffectsFactory) Descriptor() plugin.Descriptor

func (*EffectsFactory) Mount

func (factory *EffectsFactory) Mount(ctx context.Context, mount pluginruntime.MountContext) error

func (*EffectsFactory) PreMount

func (*EffectsFactory) ValidateConfig

func (factory *EffectsFactory) ValidateConfig(raw json.RawMessage) error

type EffectsOptions

type EffectsOptions struct {
	Policy EffectPolicy
	Tools  []EffectTool
}

EffectsOptions are trusted implementation bindings, not client- or profile-supplied JSON values.

type EffectsStats

type EffectsStats struct {
	ActiveSessions uint64 `json:"active_sessions"`
	InFlight       uint64 `json:"in_flight"`
	Calls          uint64 `json:"calls"`
	Results        uint64 `json:"results"`
	Authorized     uint64 `json:"authorized"`
	Executed       uint64 `json:"executed"`
	Replayed       uint64 `json:"replayed"`
	Refused        uint64 `json:"refused"`
	Closed         bool   `json:"closed"`
}

EffectsStats is bounded operational evidence for the mounted provider.

type EndpointDirectoryConfig

type EndpointDirectoryConfig struct {
	Endpoints     []presentation.Endpoint `json:"endpoints"`
	Model         string                  `json:"model,omitempty"`
	DialTimeoutMS int64                   `json:"dial_timeout_ms,omitempty"`
	ReadLimit     int64                   `json:"read_limit_bytes,omitempty"`
}

EndpointDirectoryConfig is the strict deployment value accepted by NewEndpointDirectoryFactory. Every endpoint is explicit; websocket shortcut and same-origin fields are rejected as unknown JSON.

type EndpointTarget

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

EndpointTarget is the immutable endpoint-directory service published to host plugins. Its fields are private so a consumer cannot mutate the mounted directory or claim a different target identity. Accessors return snapshots.

func (EndpointTarget) DialTimeout

func (target EndpointTarget) DialTimeout() time.Duration

func (EndpointTarget) Directory

func (target EndpointTarget) Directory() presentation.EndpointDirectory

func (EndpointTarget) Endpoint

func (target EndpointTarget) Endpoint(
	name presentation.EndpointName, protocol string,
) (presentation.Endpoint, error)

func (EndpointTarget) Fingerprint

func (target EndpointTarget) Fingerprint() string

func (EndpointTarget) Model

func (target EndpointTarget) Model() string

func (EndpointTarget) ReadLimit

func (target EndpointTarget) ReadLimit() int64

type ListenerFactory

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

func NewLoopbackListenerFactory

func NewLoopbackListenerFactory() *ListenerFactory

func (*ListenerFactory) Descriptor

func (factory *ListenerFactory) Descriptor() plugin.Descriptor

func (*ListenerFactory) Mount

func (*ListenerFactory) PreMount

func (*ListenerFactory) ValidateConfig

func (factory *ListenerFactory) ValidateConfig(raw json.RawMessage) error

type ListenerInfo

type ListenerInfo struct {
	Network string `json:"network"`
	Address string `json:"address"`
	URL     string `json:"url"`
}

type ManagementRelayFactory

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

ManagementRelayFactory exposes only explicitly selected management API families. Session reads forward the short-lived capability negotiated by that session. Static catalog and authoring calls forward a separately supplied operator capability; the relay never mints one and never adds the deployment credential used by the realtime relay.

func NewManagementRelayFactory

func NewManagementRelayFactory(client *http.Client, logger *slog.Logger) *ManagementRelayFactory

func (*ManagementRelayFactory) Descriptor

func (factory *ManagementRelayFactory) Descriptor() plugin.Descriptor

func (*ManagementRelayFactory) Mount

func (*ManagementRelayFactory) PreMount

type ManifestFactory

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

func NewManifestFactory

func NewManifestFactory(manifest presentation.ClientManifest) (*ManifestFactory, error)

func (*ManifestFactory) Descriptor

func (factory *ManifestFactory) Descriptor() plugin.Descriptor

func (*ManifestFactory) Mount

func (*ManifestFactory) PreMount

type ModuleCatalog

type ModuleCatalog interface {
	Modules() []ServedModule
	Has(digest string) bool
}

ModuleCatalog exposes only immutable identities and same-origin paths.

type ModuleSource

type ModuleSource struct {
	Name      string
	MediaType string
	Content   []byte
}

ModuleSource is one immutable browser resource bundled by a module-store implementation. Content is copied during construction.

type ModuleStoreFactory

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

func NewModuleStoreFactory

func NewModuleStoreFactory(revision uint64, sources []ModuleSource) (*ModuleStoreFactory, error)

func (*ModuleStoreFactory) Descriptor

func (factory *ModuleStoreFactory) Descriptor() plugin.Descriptor

func (*ModuleStoreFactory) Mount

func (*ModuleStoreFactory) PreMount

type ResourceStoreLimits

type ResourceStoreLimits struct {
	MaxEntries    int   `json:"max_entries"`
	MaxItemBytes  int64 `json:"max_item_bytes"`
	MaxTotalBytes int64 `json:"max_total_bytes"`
}

ResourceStoreLimits are the effective, fully bounded retention limits of one artifact or download provider. They are configuration, not mutable client input.

type ResourceStoreStats

type ResourceStoreStats struct {
	Limits    ResourceStoreLimits `json:"limits"`
	Entries   int                 `json:"entries"`
	Bytes     int64               `json:"bytes"`
	Evictions uint64              `json:"evictions"`
	Closed    bool                `json:"closed"`
}

ResourceStoreStats are a payload-free snapshot suitable for health and inspection surfaces. Bytes counts only retained model-authored content.

type Route

type Route = httpservice.Route

Route is one standard-library HTTP mux pattern and handler. Patterns carry their method (for example, "GET /client/v1/manifest") so method admission is owned by the provider rather than a shared catch-all.

type RouteRegistry

type RouteRegistry = httpservice.Registry

RouteRegistry is the typed extension point consumed by host route plugins. Registration is atomic and returns an idempotent disposer.

type RouterFactory

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

RouterFactory supplies the shared host route registry and exported handler. It does not listen on a socket; listener placement is a separate plugin or application deployment concern.

func NewRouterFactory

func NewRouterFactory() *RouterFactory

func (*RouterFactory) Descriptor

func (factory *RouterFactory) Descriptor() plugin.Descriptor

func (*RouterFactory) Mount

func (factory *RouterFactory) Mount(ctx context.Context, mount pluginruntime.MountContext) error

func (*RouterFactory) PreMount

type ServedModule

type ServedModule struct {
	Asset plugin.Asset `json:"asset"`
	Path  string       `json:"path"`
}

ServedModule is the public, payload-free module catalog row.

type TargetFactory

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

func NewEndpointDirectoryFactory

func NewEndpointDirectoryFactory() *TargetFactory

NewEndpointDirectoryFactory constructs the strict production target. Its configuration must carry a closed explicit endpoint list.

func (*TargetFactory) Descriptor

func (factory *TargetFactory) Descriptor() plugin.Descriptor

func (*TargetFactory) Mount

func (factory *TargetFactory) Mount(ctx context.Context, mount pluginruntime.MountContext) error

func (*TargetFactory) PreMount

func (*TargetFactory) ValidateConfig

func (factory *TargetFactory) ValidateConfig(raw json.RawMessage) error

type WebRTCRelayFactory

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

WebRTCRelayFactory forwards browser SDP offers over HTTP while leaving the negotiated media and data paths directly between client and adapter.

func NewWebRTCRelayFactory

func NewWebRTCRelayFactory(client *http.Client, logger *slog.Logger) *WebRTCRelayFactory

func (*WebRTCRelayFactory) Descriptor

func (factory *WebRTCRelayFactory) Descriptor() plugin.Descriptor

func (*WebRTCRelayFactory) Mount

func (factory *WebRTCRelayFactory) Mount(
	_ context.Context, mount pluginruntime.MountContext,
) error

func (*WebRTCRelayFactory) PreMount

type WebSocketRelayFactory

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

WebSocketRelayFactory provides the optional credential-holding public-wire relay at /client/v1/realtime. The relay never interprets successful protocol events and cannot access an in-process gateway.

func NewWebSocketRelayFactory

func NewWebSocketRelayFactory(logger *slog.Logger) *WebSocketRelayFactory

func (*WebSocketRelayFactory) Descriptor

func (factory *WebSocketRelayFactory) Descriptor() plugin.Descriptor

func (*WebSocketRelayFactory) Mount

func (*WebSocketRelayFactory) PreMount

Jump to

Keyboard shortcuts

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