Documentation
¶
Overview ¶
Package sdk implements the authenticated Stream Dock Manager/Stream Deck protocol v1
Index ¶
- Constants
- Variables
- func ConnectWithInfo(parent context.Context, address, token string, h Handler, info HostInfo) error
- func DeferAction(ctx context.Context) func(error)
- func FrameCapabilities(value Capabilities) (string, error)
- func ImageDataURI(mediaType string, data []byte) (string, error)
- func NetworkPayload() (sent, received uint64)
- func OpenActionDeepLink(event Event) (url string, matched bool, err error)
- func OpenActionSettingsRequested(event Event) bool
- func OperationID() string
- func Run(ctx context.Context, args []string, h Handler) error
- func ShouldLogAction(e Event) bool
- func TrackConn(connection net.Conn) net.Conn
- type ActionCapability
- type ActionLogging
- type AdditiveDial
- type Capabilities
- type Client
- func (c *Client) Alert(ctx context.Context, binding string) error
- func (c *Client) CurrentPluginTheme() *PluginTheme
- func (c *Client) DesktopInput(ctx context.Context, binding string, value any) error
- func (c *Client) Dispatch(ctx context.Context, handler Handler, event Event)
- func (c *Client) Display(ctx context.Context, binding, title, image string, state int, layout string, ...) error
- func (c *Client) DynamicItems(ctx context.Context, value any) error
- func (c *Client) Feedback(ctx context.Context, binding string, value any) error
- func (c *Client) FeedbackLayout(ctx context.Context, binding, layout string) error
- func (c *Client) GetGlobalSettings(ctx context.Context) error
- func (c *Client) GetPluginTheme(ctx context.Context) (*PluginTheme, error)
- func (c *Client) GetSettings(ctx context.Context, binding string) error
- func (c *Client) GlobalSettings(ctx context.Context, value any) error
- func (c *Client) Host() HostInfo
- func (c *Client) Image(ctx context.Context, binding, image string) error
- func (c *Client) Log(ctx context.Context, message string) error
- func (c *Client) LogStream(ctx context.Context, stream LogStream, message string) error
- func (c *Client) OK(ctx context.Context, binding string) error
- func (c *Client) ObserveControl(e Event) bool
- func (c *Client) OpenURL(ctx context.Context, address string) error
- func (c *Client) Request(ctx context.Context, protocol, method string, payload any) (json.RawMessage, error)
- func (c *Client) Send(ctx context.Context, e Event) error
- func (c *Client) SetLogRedactor(redact func(string) string)
- func (c *Client) SetNetworkDebug(enabled bool)
- func (c *Client) Settings(ctx context.Context, binding string, value any) error
- func (c *Client) State(ctx context.Context, binding string, state int) error
- func (c *Client) Stderr(ctx context.Context) io.Writer
- func (c *Client) Stdout(ctx context.Context) io.Writer
- func (c *Client) SubscribeTelemetry(ctx context.Context, topics []string) error
- func (c *Client) Supports(capability string) bool
- func (c *Client) SupportsThemeRPC() bool
- func (c *Client) Title(ctx context.Context, binding, text string) error
- func (c *Client) ToInspector(ctx context.Context, binding, action string, value any) error
- type Event
- type Handler
- type HostInfo
- type HostStore
- func (s *HostStore) Commit(ctx context.Context, version StorageVersion, operation string, ...) (StorageReceipt, error)
- func (s *HostStore) Get(ctx context.Context, key string) (StorageValue, error)
- func (s *HostStore) ListKeys(ctx context.Context, cursor string) (StorageKeys, error)
- func (s *HostStore) Receipt(ctx context.Context, generation, operation string) (StorageReceipt, error)
- type LogStream
- type Measurement
- type OpenActionDeviceInfo
- type OpenActionDeviceOutput
- type OpenActionDeviceProvider
- func (p *OpenActionDeviceProvider) Deregister(device string) (map[string]any, error)
- func (p *OpenActionDeviceProvider) DeviceEvent(event, device string) (map[string]any, error)
- func (p *OpenActionDeviceProvider) EncoderChange(device string, position uint8, ticks int16) (map[string]any, error)
- func (p *OpenActionDeviceProvider) EncoderDown(device string, position uint8) (map[string]any, error)
- func (p *OpenActionDeviceProvider) EncoderUp(device string, position uint8) (map[string]any, error)
- func (p *OpenActionDeviceProvider) KeyDown(device string, position uint8) (map[string]any, error)
- func (p *OpenActionDeviceProvider) KeyUp(device string, position uint8) (map[string]any, error)
- func (p *OpenActionDeviceProvider) ParseOutput(data []byte) (OpenActionDeviceOutput, error)
- func (p *OpenActionDeviceProvider) Press(event, device string, position uint8) (map[string]any, error)
- func (p *OpenActionDeviceProvider) Register(info OpenActionDeviceInfo) (map[string]any, error)
- func (p *OpenActionDeviceProvider) RerenderImages(device string) (map[string]any, error)
- func (p *OpenActionDeviceProvider) TouchscreenPress(device string, position uint8, x, y uint16, hold bool) (map[string]any, error)
- type Payload
- type PluginTheme
- type PortableSettings
- type ProbePool
- type RPCError
- type Scheduler
- type SettingsResult
- type StorageKeys
- type StorageMutation
- type StorageReceipt
- type StorageValue
- type StorageVersion
- type Surface
- type TelemetrySnapshot
- type ThemeColors
- type ThemeMedia
- type ThemeWallpaper
- type ThemedAsset
- type UnsupportedFeatureError
Constants ¶
const ContractVersion = 1
const DescriptorLimit = 64 << 10
const DescriptorPrefix = "SDMCAP1:"
const DescriptorSuffix = ":ENDSDMCAP1"
const MaxInputBytes = 8 * MaxMessageBytes
MaxInputBytes charges encoded envelopes until dispatch (or dial batching) releases them. The socket reader may additionally hold one bounded envelope
const MaxInputItems = 128
const MaxLogBytes = MaxMessageBytes
const MaxMessageBytes = 1 << 20
MaxMessageBytes bounds the complete UTF-8 JSON envelope in protocol v1, including legacy hosts
const MaxOutputBytes = 8 * MaxMessageBytes
const MaxPortableImageBytes = 512 * 1024
MaxPortableImageBytes leaves room for the base64 image and protocol envelope
const MaximumStorageMessage = 512 << 10
const MaximumStorageValue = 256 << 10
const OpenActionDidReceiveDeepLink = "didReceiveDeepLink"
const OpenActionShowSettingsInterface = "showSettingsInterface"
OpenAction events are opt-in; no UI or URL is opened by these helpers
const RPCRequestEvent = "streamDockManagerRpcRequest"
const RPCResponseEvent = "streamDockManagerRpcResponse"
const SettingsProtocol = "plugin-settings-rpc-v1"
const StorageProtocol = "plugin-storage-v1"
const ThemeEvent = "didReceivePluginTheme"
const ThemeProtocol = "plugin-theme-v1"
Variables ¶
var CompiledDescriptor string
CompiledDescriptor is injected from the same Definition that generates the manifest. It remains referenced by registration, including stripped builds
Functions ¶
func ConnectWithInfo ¶
ConnectWithInfo negotiates optional extensions from explicit host metadata
func DeferAction ¶
DeferAction ties asynchronous work to the current tracked input. Call the returned function exactly when that work finishes. The SDK reports success only after the handler and every deferred operation have succeeded
func FrameCapabilities ¶
func FrameCapabilities(value Capabilities) (string, error)
Encode the capability descriptor in its framed wire format
func ImageDataURI ¶
ImageDataURI encodes caller-provided PNG or SVG bytes for portable setImage messages. It never reads files or URLs, changes paths, or grants permissions It does not decode or sanitize images: only pass trusted image bytes. The ordinary outgoing message limit still applies to the complete message
func NetworkPayload ¶
func NetworkPayload() (sent, received uint64)
NetworkPayload excludes SDK loopback, TLS/TCP overhead, DNS, subprocesses, and library-owned transports (including speedtest-go)
func OpenActionDeepLink ¶
OpenActionDeepLink returns the untrusted, opaque payload URL, not a decoded command. The caller must validate routing/content before taking any action
func OpenActionSettingsRequested ¶
OpenActionSettingsRequested recognizes OpenDeck's payload-free request Set HasSettingsInterface in the manifest only if your handler supplies a UI
func OperationID ¶
func OperationID() string
OperationID is independent of the authentication token and may be retained for explicit reconciliation. Reuse it only for the identical logical mutation
func ShouldLogAction ¶
Select action events worth recording in plugin logs
Types ¶
type ActionCapability ¶
type ActionCapability struct {
Refresh *polling.RefreshPolicy `json:"refresh,omitempty"`
ParameterFields []string `json:"parameter_fields,omitempty"`
FeedbackLayout string `json:"feedback_layout,omitempty"`
ControlTypes []string `json:"control_types,omitempty"`
AdditiveDial bool `json:"additive_dial,omitempty"`
Settings string `json:"settings,omitempty"`
Icon ThemedAsset `json:"icon"`
States []ThemedAsset `json:"states"`
}
type ActionLogging ¶
ActionLogging optionally selects the input events that execute a plugin action Receipts remain independent of logging; release-based actions can opt in here
type AdditiveDial ¶
AdditiveDial opts in only actions whose rotation operation is additive
type Capabilities ¶
type Capabilities struct {
MinimumManager string `json:"minimum_manager,omitempty"`
RequiredCapabilities []string `json:"required_capabilities,omitempty"`
Version int `json:"version"`
ID string `json:"id"`
PluginVersion string `json:"plugin_version"`
ThemeProtocol int `json:"theme_protocol"`
SettingsProtocol int `json:"settings_protocol"`
InputProtocol int `json:"input_protocol"`
PluginSettings string `json:"plugin_settings,omitempty"`
Icon ThemedAsset `json:"icon"`
Actions map[string]ActionCapability `json:"actions"`
}
func RuntimeCapabilities ¶
func RuntimeCapabilities() (*Capabilities, error)
Decode the descriptor embedded at build time
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewLocalClient ¶
NewLocalClient supplies the same bounded, capability-gated writer without a socket. The caller owns draining the returned events (for simulations/tests)
func (*Client) CurrentPluginTheme ¶
func (c *Client) CurrentPluginTheme() *PluginTheme
Read the cached plugin theme
func (*Client) DesktopInput ¶
Request negotiated desktop input for a binding
func (*Client) Dispatch ¶
Dispatch runs one event through the same completion/error machinery as Run It belongs to the caller's serialized loop; testkit uses it for offline replay
func (*Client) Display ¶
func (c *Client) Display(ctx context.Context, binding, title, image string, state int, layout string, feedback any) error
Display sends standard vendor display commands; Manager-only extensions remain negotiated
func (*Client) DynamicItems ¶
Send dynamic inspector choice data
func (*Client) FeedbackLayout ¶
Select a binding feedback layout
func (*Client) GetGlobalSettings ¶
Request the current plugin-global settings
func (*Client) GetPluginTheme ¶
func (c *Client) GetPluginTheme(ctx context.Context) (*PluginTheme, error)
Fetch the current theme through negotiated RPC
func (*Client) GetSettings ¶
Request the current binding settings
func (*Client) GlobalSettings ¶
Replace plugin-global portable settings
func (*Client) ObserveControl ¶
ObserveControl is called by the transport before ordinary event admission True means an RPC response was consumed; base settings notifications always remain available to the normal event loop. It never invokes plugin callbacks
func (*Client) Request ¶
func (c *Client) Request(ctx context.Context, protocol, method string, payload any) (json.RawMessage, error)
Request performs a bounded, capability-negotiated Manager RPC. Cancellation or timeout after enqueue is indeterminate; it never retries through another route
func (*Client) SetLogRedactor ¶
SetLogRedactor installs a snapshot-based sanitizer. It is applied before framing; writers never echo RPC messages to the process console
func (*Client) SetNetworkDebug ¶
SetNetworkDebug is normally driven by Manager's per-plugin log preferences Diagnostic traffic uses the independent bounded log queue, never stdout echo
func (*Client) SubscribeTelemetry ¶
Subscribe to the requested host telemetry topics
func (*Client) SupportsThemeRPC ¶
Check whether the host supports theme RPC
type Event ¶
type Event struct {
Event string `json:"event"`
ID string `json:"id,omitempty"`
Action string `json:"action,omitempty"`
Context string `json:"context,omitempty"`
Device string `json:"device,omitempty"`
UUID string `json:"uuid,omitempty"`
Payload json.RawMessage `json:"payload,omitempty"`
Surface *Surface `json:"streamDockManager,omitempty"`
DeviceInfo json.RawMessage `json:"deviceInfo,omitempty"`
Raw json.RawMessage `json:"-"`
ProtocolID string `json:"protocol_id,omitempty"`
RequestID string `json:"request_id,omitempty"`
Method string `json:"method,omitempty"`
Result json.RawMessage `json:"result,omitempty"`
Error *RPCError `json:"error,omitempty"`
// contains filtered or unexported fields
}
func (*Event) UnmarshalJSON ¶
UnmarshalJSON retains the complete event for forward-compatible extensions
type HostInfo ¶
type HostInfo struct {
Raw map[string]json.RawMessage
Manager struct {
Version string `json:"version"`
ContractVersion int `json:"contract_version"`
Capabilities []string `json:"capabilities"`
RunID string `json:"run_id"`
DebugNetwork bool `json:"debug_network"`
} `json:"streamDockManager"`
}
HostInfo retains the host's raw fields so newer metadata remains available
func ParseHostInfo ¶
Decode and validate the host registration metadata
type HostStore ¶
type HostStore struct {
// contains filtered or unexported fields
}
func NewHostStore ¶
Create a namespace-scoped negotiated host store
func (*HostStore) Commit ¶
func (s *HostStore) Commit(ctx context.Context, version StorageVersion, operation string, mutations []StorageMutation) (StorageReceipt, error)
Commit validated mutations against an expected storage version
type Measurement ¶
type OpenActionDeviceInfo ¶
type OpenActionDeviceOutput ¶
type OpenActionDeviceOutput struct {
Event string `json:"event"`
Device string `json:"device"`
Controller *string `json:"controller"`
Position *uint8 `json:"position"`
Image *string `json:"image"`
Brightness *uint8 `json:"brightness"`
}
OpenActionDeviceOutput is a provider command, not an action-plugin setImage A setImage with nil Controller/Position/Image requests clearing the screen Image is opaque; callers must validate/decode it before hardware use
type OpenActionDeviceProvider ¶
type OpenActionDeviceProvider struct {
// contains filtered or unexported fields
}
OpenActionDeviceProvider builds OpenDeck-specific wire envelopes. It neither grants a namespace nor sends messages or accesses hardware. Declare the same two-character DeviceNamespace in the manifest and use only on an opted-in host Wire reference: nekename/OpenDeck commit 3ddecc1ce8952a423916cf066724356267b97410
func NewOpenActionDeviceProvider ¶
func NewOpenActionDeviceProvider(namespace string) (*OpenActionDeviceProvider, error)
Create a device provider with a validated namespace
func (*OpenActionDeviceProvider) Deregister ¶
func (p *OpenActionDeviceProvider) Deregister(device string) (map[string]any, error)
Build a device removal envelope
func (*OpenActionDeviceProvider) DeviceEvent ¶
func (p *OpenActionDeviceProvider) DeviceEvent(event, device string) (map[string]any, error)
Build a namespace-checked device lifecycle envelope
func (*OpenActionDeviceProvider) EncoderChange ¶
func (p *OpenActionDeviceProvider) EncoderChange(device string, position uint8, ticks int16) (map[string]any, error)
Build an encoder rotation envelope
func (*OpenActionDeviceProvider) EncoderDown ¶
func (p *OpenActionDeviceProvider) EncoderDown(device string, position uint8) (map[string]any, error)
Build an encoder-down event for the selected position
func (*OpenActionDeviceProvider) ParseOutput ¶
func (p *OpenActionDeviceProvider) ParseOutput(data []byte) (OpenActionDeviceOutput, error)
Decode bounded host output addressed to this provider
func (*OpenActionDeviceProvider) Press ¶
func (p *OpenActionDeviceProvider) Press(event, device string, position uint8) (map[string]any, error)
Build a key or encoder press envelope
func (*OpenActionDeviceProvider) Register ¶
func (p *OpenActionDeviceProvider) Register(info OpenActionDeviceInfo) (map[string]any, error)
Build a provider registration envelope
func (*OpenActionDeviceProvider) RerenderImages ¶
func (p *OpenActionDeviceProvider) RerenderImages(device string) (map[string]any, error)
Request the host to resend device images
func (*OpenActionDeviceProvider) TouchscreenPress ¶
func (p *OpenActionDeviceProvider) TouchscreenPress(device string, position uint8, x, y uint16, hold bool) (map[string]any, error)
Build a touchscreen press envelope
type PluginTheme ¶
type PluginTheme struct {
Version int `json:"version"`
Resolved string `json:"resolved"`
Revision uint64 `json:"revision"`
Theme ThemeColors `json:"theme"`
}
type PortableSettings ¶
type PortableSettings struct {
// contains filtered or unexported fields
}
PortableSettings uses the same action/global object on every host. Its base writes report only "sent"; reads report observed state, never a commit receipt
func NewPortableSettings ¶
func NewPortableSettings(client *Client, scope, address string) (*PortableSettings, error)
Create a portable settings accessor for an explicit scope
func (*PortableSettings) Read ¶
func (s *PortableSettings) Read(ctx context.Context) (SettingsResult, error)
Read portable settings through the selected host contract
func (*PortableSettings) Replace ¶
func (s *PortableSettings) Replace(ctx context.Context, value map[string]any) (SettingsResult, error)
Replace portable settings with a cloned object
func (*PortableSettings) Update ¶
func (s *PortableSettings) Update(ctx context.Context, changes map[string]any) (SettingsResult, error)
Update serializes read/merge/write within this facade only, not across other plugin/inspector writers. Explicit null remains a value, not a deletion marker
type ProbePool ¶
type ProbePool struct {
// contains filtered or unexported fields
}
func NewProbePool ¶
func NewProbePool() *ProbePool
Workers and their queue are allocated only when the first probe is submitted
type Scheduler ¶
Scheduler explicitly enables timed polling. Handlers without Scheduler never poll A zero deadline suspends idle polling until an event or wake Methods run on the handler event loop and must not block
type SettingsResult ¶
type StorageKeys ¶
type StorageKeys struct {
StorageVersion
Keys []string `json:"keys"`
Cursor string `json:"cursor,omitempty"`
}
type StorageMutation ¶
type StorageReceipt ¶
type StorageReceipt struct {
StorageVersion
OperationID string `json:"operation_id"`
Committed bool `json:"committed"`
Found bool `json:"found,omitempty"`
}
type StorageValue ¶
type StorageValue struct {
StorageVersion
Found bool `json:"found"`
Value json.RawMessage `json:"value,omitempty"`
}
type StorageVersion ¶
type Surface ¶
type Surface struct {
RequestID string `json:"request_id,omitempty"`
ControlID string `json:"control_id"`
Width int `json:"width"`
Height int `json:"height"`
FeedbackTarget string `json:"feedback_target"`
Touch *struct {
X int `json:"x"`
Y int `json:"y"`
Phase string `json:"phase"`
} `json:"touch,omitempty"`
}
type TelemetrySnapshot ¶
type TelemetrySnapshot struct {
AudioObserver bool `json:"audio_observer"`
CPU Measurement `json:"cpu"`
Memory Measurement `json:"memory"`
Network Measurement `json:"network"`
Disks map[string]Measurement `json:"disks"`
AudioVolume Measurement `json:"audio_volume"`
AudioMuted Measurement `json:"audio_muted"`
}
func (*TelemetrySnapshot) UnmarshalJSON ¶
func (s *TelemetrySnapshot) UnmarshalJSON(data []byte) error
Decode a validated telemetry snapshot
type ThemeColors ¶
type ThemeMedia ¶
type ThemeWallpaper ¶
type ThemeWallpaper struct {
SVG string
Media *ThemeMedia
}
func (*ThemeWallpaper) UnmarshalJSON ¶
func (w *ThemeWallpaper) UnmarshalJSON(data []byte) error
Decode a bounded wallpaper description
type ThemedAsset ¶
type UnsupportedFeatureError ¶
type UnsupportedFeatureError struct{ Feature string }
func (*UnsupportedFeatureError) Error ¶
func (e *UnsupportedFeatureError) Error() string
Describe the unsupported host feature
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package authoring owns the shared plugin lifecycle; it imports no feature implementation
|
Package authoring owns the shared plugin lifecycle; it imports no feature implementation |
|
Package cache provides owner-serialized caches with deterministic LRU eviction Values are caller-owned immutable snapshots.
|
Package cache provides owner-serialized caches with deterministic LRU eviction Values are caller-owned immutable snapshots. |
|
Package connectedws supplies the bounded, tracked transport for external service connections.
|
Package connectedws supplies the bounded, tracked transport for external service connections. |
|
Package connectors adapts independent integrations to the SDK lifecycle It contains no feature imports, so executables retain dependency isolation
|
Package connectors adapts independent integrations to the SDK lifecycle It contains no feature imports, so executables retain dependency isolation |
|
Package discovery coordinates read-only inspector work on an owner event loop Start uses a bounded executor supplied by the caller; Complete and Expire run on the loop.
|
Package discovery coordinates read-only inspector work on an owner event loop Start uses a bounded executor supplied by the caller; Complete and Expire run on the loop. |
|
Package displaybench measures the real engine/SDK display path on loopback It deliberately imports no official plugin or operating-system action adapter
|
Package displaybench measures the real engine/SDK display path on loopback It deliberately imports no official plugin or operating-system action adapter |
|
examples
|
|
|
advanced
command
SPDX-License-Identifier: MIT
|
SPDX-License-Identifier: MIT |
|
benchmark
command
A bounded in-process authoring workload, separate from loopback/hardware measurements
|
A bounded in-process authoring workload, separate from loopback/hardware measurements |
|
Package httptrack optionally tracks transferred HTTP payload for SDK reporting
|
Package httptrack optionally tracks transferred HTTP payload for SDK reporting |
|
Package inspectors contains the SDK's packaged, local inspector helpers
|
Package inspectors contains the SDK's packaged, local inspector helpers |
|
internal
|
|
|
benchmarkclock
Package benchmarkclock measures benchmark intervals without changing runtime timers or the system timer resolution
|
Package benchmarkclock measures benchmark intervals without changing runtime timers or the system timer resolution |
|
netdebug
Package netdebug connects optional transport diagnostics to the SDK log queue without adding HTTP dependencies to plugins that do not use HTTP
|
Package netdebug connects optional transport diagnostics to the SDK log queue without adding HTTP dependencies to plugins that do not use HTTP |
|
payload
Package payload shares process-local payload accounting without importing HTTP
|
Package payload shares process-local payload accounting without importing HTTP |
|
statefile
Package statefile bounds state reads before JSON decoding, including files that grow after they are opened.
|
Package statefile bounds state reads before JSON decoding, including files that grow after they are opened. |
|
Package managedstate persists JSON records through an explicitly selected SDK backend.
|
Package managedstate persists JSON records through an explicitly selected SDK backend. |
|
Package operations tracks external outcomes without executing or retrying work Serialize calls on the owner loop or with a caller-held mutex.
|
Package operations tracks external outcomes without executing or retrying work Serialize calls on the owner loop or with a caller-held mutex. |
|
Package packaging audits runtime dependencies and local resource closure
|
Package packaging audits runtime dependencies and local resource closure |
|
Package requests shares in-flight JSON reads without coupling consumer cancellation It never retries a write.
|
Package requests shares in-flight JSON reads without coupling consumer cancellation It never retries a write. |
|
Package settings validates declarative inspector fields without losing extensions
|
Package settings validates declarative inspector fields without losing extensions |
|
Package storage persists plugin-owned state.
|
Package storage persists plugin-owned state. |
|
Package testkit runs real SDK handlers without sockets or a Manager checkout
|
Package testkit runs real SDK handlers without sockets or a Manager checkout |
|
peers
Package testutil provides disposable protocol peers; it never connects to a user's accounts, local services or VPN tools
|
Package testutil provides disposable protocol peers; it never connects to a user's accounts, local services or VPN tools |
|
Package thumbnail provides bounded standard-library image decoding and sampling
|
Package thumbnail provides bounded standard-library image decoding and sampling |