Documentation
¶
Overview ¶
Package protocol defines the public, exact bsbctl plugin protocol 1.0 application contract.
Index ¶
- Constants
- func DecodeStrict(raw json.RawMessage, target any) error
- func ValidateEmptyParams(raw json.RawMessage) error
- func ValidateExecutionModes(modes []ExecutionMode) error
- func ValidateJSONObject(name string, raw json.RawMessage, optional bool) error
- func ValidatePackagePath(value string) error
- type AnimationElement
- type AssetRef
- type AudioCue
- type BusyTimerPresentation
- type Button
- type ButtonAction
- type ButtonInput
- type Channel
- type CheckpointRequest
- type CompleteSessionRequest
- type CountdownElement
- type CountdownShowHours
- type Display
- type Disposition
- type DomainError
- type Element
- type EncoderInput
- type ErrorData
- type ErrorKind
- type ExecutionMode
- type HealthResult
- type ImageElement
- type Impact
- type InitializeRequest
- type InitializeResult
- type Instance
- type InstanceRef
- type LogLevel
- type LogNotification
- type Marquee
- type MetricNotification
- type Observation
- type ObservationRef
- type OperationDescriptor
- type OperationKind
- type OperationRequest
- type OperationResult
- type PublishRequest
- type RectangleElement
- type ReplaceInstancesRequest
- type Scene
- type SessionEndRequest
- type SessionExecutionRequest
- type SessionInput
- type SessionInputDisposition
- type SessionInputRequest
- type SessionInputResult
- type SessionStartRequest
- type SessionTrigger
- type SessionTriggerKind
- type TextElement
- type WithdrawRequest
Constants ¶
const ( Version = "1.0" MaxMessageBytes = 1 << 20 MaxJSONObjectBytes = 64 << 10 MaxConfigObjectBytes = MaxJSONObjectBytes MaxCheckpointObjectBytes = MaxJSONObjectBytes MaxOperationObjectBytes = MaxJSONObjectBytes MaxSessionInputBytes = 16 << 10 MaxSceneElements = 64 MaxTextBytes = 512 MaxBusyTimerDuration = 24 * time.Hour )
Protocol and payload limits are part of the exact v1 wire contract.
Variables ¶
This section is empty.
Functions ¶
func DecodeStrict ¶
func DecodeStrict(raw json.RawMessage, target any) error
DecodeStrict decodes exactly one unambiguous JSON value and rejects unknown fields.
func ValidateEmptyParams ¶
func ValidateEmptyParams(raw json.RawMessage) error
ValidateEmptyParams permits omitted params or one empty JSON object.
func ValidateExecutionModes ¶
func ValidateExecutionModes(modes []ExecutionMode) error
ValidateExecutionModes rejects empty, duplicate, or unsupported execution modes.
func ValidateJSONObject ¶
func ValidateJSONObject(name string, raw json.RawMessage, optional bool) error
ValidateJSONObject requires one bounded JSON object, or permits an omitted value when optional is true.
func ValidatePackagePath ¶
ValidatePackagePath validates one canonical package-relative asset source.
Types ¶
type AnimationElement ¶
AnimationElement renders one animation asset.
type AssetRef ¶
type AssetRef struct {
PackagePath string `json:"package_path,omitempty"`
StockName string `json:"stock_name,omitempty"`
}
AssetRef names either one authenticated package asset or one firmware stock asset.
type AudioCue ¶
type AudioCue struct {
ID string `json:"id"`
Asset AssetRef `json:"asset"`
ExpiresAt time.Time `json:"expires_at"`
}
AudioCue requests one expiring best-effort firmware stock sound.
type BusyTimerPresentation ¶
type BusyTimerPresentation struct {
Theme string `json:"theme"`
}
BusyTimerPresentation requests a firmware-native BUSY timer theme.
type ButtonAction ¶
type ButtonAction string
ButtonAction distinguishes a physical press from a release.
const ( ButtonPress ButtonAction = "press" ButtonRelease ButtonAction = "release" )
type ButtonInput ¶
type ButtonInput struct {
Button Button `json:"button"`
Action ButtonAction `json:"action"`
}
ButtonInput describes one button transition.
type Channel ¶
type Channel struct {
ID string `json:"id"`
}
Channel declares one observation channel exported by a plugin.
type CheckpointRequest ¶
type CheckpointRequest struct {
Instance InstanceRef `json:"instance"`
Data json.RawMessage `json:"data"`
}
CheckpointRequest replaces the generation-scoped durable plugin checkpoint.
func (CheckpointRequest) Validate ¶
func (request CheckpointRequest) Validate() error
Validate checks the target and bounded checkpoint object.
type CompleteSessionRequest ¶
type CompleteSessionRequest struct {
Instance InstanceRef `json:"instance"`
SessionToken string `json:"session_token"`
}
CompleteSessionRequest asks core to finish one exact session.
func (CompleteSessionRequest) Validate ¶
func (request CompleteSessionRequest) Validate() error
Validate checks the exact instance and session token.
type CountdownElement ¶
type CountdownElement struct {
EndsAtUnixSeconds int64 `json:"ends_at_unix_seconds"`
ShowHours CountdownShowHours `json:"show_hours"`
Color string `json:"color"`
Align string `json:"align,omitempty"`
}
CountdownElement renders a future Unix-second deadline.
type CountdownShowHours ¶
type CountdownShowHours string
CountdownShowHours controls when a countdown renders its hour field.
const ( CountdownShowHoursWhenNonZero CountdownShowHours = "when_non_zero" CountdownShowHoursAlways CountdownShowHours = "always" )
type Disposition ¶
type Disposition string
Disposition describes the observation lifecycle and whether user action is available.
const ( DispositionSnapshot Disposition = "snapshot" DispositionNotable Disposition = "notable" DispositionActionable Disposition = "actionable" DispositionResolved Disposition = "resolved" )
type DomainError ¶
type DomainError struct {
// contains filtered or unexported fields
}
DomainError preserves a private local cause while exposing only a stable kind.
func NewDomainError ¶
func NewDomainError(kind ErrorKind, cause error) *DomainError
NewDomainError constructs a typed domain error with an optional private cause.
func (*DomainError) Data ¶
func (err *DomainError) Data() ErrorData
Data returns the complete safe wire representation.
func (*DomainError) Error ¶
func (err *DomainError) Error() string
func (*DomainError) Kind ¶
func (err *DomainError) Kind() ErrorKind
Kind returns the safe public classification.
func (*DomainError) Unwrap ¶
func (err *DomainError) Unwrap() error
type Element ¶
type Element struct {
ID string `json:"id"`
Display Display `json:"display"`
X int `json:"x,omitzero"`
Y int `json:"y,omitzero"`
Text *TextElement `json:"text,omitempty"`
Image *ImageElement `json:"image,omitempty"`
Animation *AnimationElement `json:"animation,omitempty"`
Rectangle *RectangleElement `json:"rectangle,omitempty"`
Countdown *CountdownElement `json:"countdown,omitempty"`
}
Element places exactly one supported presentation payload on one display.
type EncoderInput ¶
type EncoderInput struct {
Delta int32 `json:"delta"`
}
EncoderInput carries one nonzero encoder delta.
type ErrorData ¶
type ErrorData struct {
Kind ErrorKind `json:"kind"`
}
ErrorData is the complete safe wire payload for a domain error.
type ErrorKind ¶
type ErrorKind string
ErrorKind is the stable safe classification carried by a bsbctl domain error.
const ( DomainErrorCode = -32000 ErrorInvalidArgument ErrorKind = "invalid_argument" ErrorNotReady ErrorKind = "not_ready" ErrorGenerationConflict ErrorKind = "generation_conflict" ErrorSessionNotActive ErrorKind = "session_not_active" ErrorSessionCanceled ErrorKind = "session_canceled" ErrorSessionGenerationMismatch ErrorKind = "session_generation_mismatch" )
Domain error codes and kinds are the only private errors accepted by protocol v1.
func DecodeRemoteError ¶
DecodeRemoteError validates the only server-domain error and the standard JSON-RPC errors accepted by protocol v1.
type ExecutionMode ¶
type ExecutionMode string
ExecutionMode controls whether the daemon keeps a plugin resident or starts it for a session.
const ( ExecutionModeResident ExecutionMode = "resident" ExecutionModeInteractive ExecutionMode = "interactive" )
type HealthResult ¶
type HealthResult struct {
Healthy bool `json:"healthy"`
ObservedAt time.Time `json:"observed_at"`
}
HealthResult reports plugin health at one required UTC observation time.
func (HealthResult) Validate ¶
func (result HealthResult) Validate() error
Validate requires a nonzero UTC observation time.
type ImageElement ¶
type ImageElement struct {
Asset AssetRef `json:"asset"`
}
ImageElement renders one image asset.
type Impact ¶
type Impact string
Impact carries domain severity without selecting global attention policy.
type InitializeRequest ¶
type InitializeRequest struct {
CoreVersion string `json:"core_version"`
PluginID string `json:"plugin_id"`
PluginVersion string `json:"plugin_version"`
ProtocolVersion string `json:"protocol_version"`
}
InitializeRequest carries the daemon and exact protocol identity.
func (InitializeRequest) Validate ¶
func (request InitializeRequest) Validate() error
Validate requires the exact protocol version and complete peer identity.
type InitializeResult ¶
type InitializeResult struct {
PluginID string `json:"plugin_id"`
PluginVersion string `json:"plugin_version"`
ProtocolVersion string `json:"protocol_version"`
ExecutionModes []ExecutionMode `json:"execution_modes"`
Channels []Channel `json:"channels"`
Operations []OperationDescriptor `json:"operations,omitempty"`
}
InitializeResult declares the immutable plugin contract for this process.
func (InitializeResult) Validate ¶
func (result InitializeResult) Validate() error
Validate checks the immutable plugin identity and declared capabilities.
type Instance ¶
type Instance struct {
ID string `json:"id"`
Generation uint64 `json:"generation"`
Config json.RawMessage `json:"config"`
Secrets map[string]string `json:"secrets,omitempty"`
Checkpoint json.RawMessage `json:"checkpoint,omitempty"`
}
Instance contains the complete plugin-owned state for one app generation.
func (Instance) Ref ¶
func (instance Instance) Ref() InstanceRef
Ref returns the generation-scoped reference for the instance.
type InstanceRef ¶
InstanceRef identifies one exact generation of an app instance.
func (InstanceRef) Validate ¶
func (ref InstanceRef) Validate() error
Validate checks the instance identity and nonzero generation.
type LogNotification ¶
type LogNotification struct {
Level LogLevel `json:"level"`
Event string `json:"event"`
Instance InstanceRef `json:"instance,omitzero"`
Message string `json:"message,omitempty"`
Fields map[string]string `json:"fields,omitempty"`
}
LogNotification emits one bounded structured and redacted plugin event.
func (LogNotification) Validate ¶
func (notification LogNotification) Validate() error
Validate checks the level, event identity, optional instance, and bounded fields.
type Marquee ¶
type Marquee struct {
PixelsPerMinute uint32 `json:"pixels_per_minute"`
StartDelayMilliseconds uint32 `json:"start_delay_milliseconds,omitzero"`
RepeatDelayMilliseconds uint32 `json:"repeat_delay_milliseconds,omitzero"`
}
Marquee defines firmware-native horizontal scrolling in pixels and milliseconds.
type MetricNotification ¶
type MetricNotification struct {
Instance InstanceRef `json:"instance,omitzero"`
Name string `json:"name"`
Value float64 `json:"value"`
Unit string `json:"unit,omitempty"`
}
MetricNotification emits one finite, bounded diagnostic metric.
func (*MetricNotification) UnmarshalJSON ¶
func (notification *MetricNotification) UnmarshalJSON(data []byte) error
UnmarshalJSON strictly decodes a metric and requires an explicit value.
func (MetricNotification) Validate ¶
func (notification MetricNotification) Validate() error
Validate checks metric identity, optional instance, unit, and finite value.
type Observation ¶
type Observation struct {
Instance InstanceRef `json:"instance"`
Channel string `json:"channel"`
Key string `json:"key"`
Revision uint64 `json:"revision"`
Disposition Disposition `json:"disposition"`
Impact Impact `json:"impact"`
ReasonCode string `json:"reason_code"`
ObservedAt time.Time `json:"observed_at"`
UpdatedAt time.Time `json:"updated_at"`
ValidUntil time.Time `json:"valid_until,omitzero"`
Scene *Scene `json:"scene,omitempty"`
BusyTimer *BusyTimerPresentation `json:"busy_timer,omitempty"`
Audio *AudioCue `json:"audio,omitempty"`
}
Observation is plugin-owned domain state submitted to the core attention arbiter.
type ObservationRef ¶
type ObservationRef struct {
Channel string `json:"channel"`
Key string `json:"key"`
Revision uint64 `json:"revision"`
}
ObservationRef binds a session to one exact observation revision.
type OperationDescriptor ¶
type OperationDescriptor struct {
ID string `json:"id"`
Kind OperationKind `json:"kind"`
}
OperationDescriptor declares one bounded operation supported by a plugin.
func (OperationDescriptor) Validate ¶
func (descriptor OperationDescriptor) Validate() error
Validate checks the operation identifier and kind.
type OperationKind ¶
type OperationKind string
OperationKind distinguishes read-only queries from state-changing commands.
const ( OperationQuery OperationKind = "query" OperationCommand OperationKind = "command" )
type OperationRequest ¶
type OperationRequest struct {
Instance InstanceRef `json:"instance"`
Operation string `json:"operation"`
Payload json.RawMessage `json:"payload,omitempty"`
}
OperationRequest invokes a declared query or command for one instance generation.
func (OperationRequest) Validate ¶
func (request OperationRequest) Validate() error
Validate checks the target, operation identifier, and bounded payload.
type OperationResult ¶
type OperationResult struct {
Payload json.RawMessage `json:"payload"`
}
OperationResult carries one required bounded JSON object.
func (OperationResult) Validate ¶
func (result OperationResult) Validate() error
Validate requires one bounded JSON object.
type PublishRequest ¶
type PublishRequest struct {
Observation Observation `json:"observation"`
}
PublishRequest submits one validated observation to core.
type RectangleElement ¶
type RectangleElement struct {
Width int `json:"width"`
Height int `json:"height"`
Color string `json:"color"`
}
RectangleElement renders a positive-size solid rectangle.
type ReplaceInstancesRequest ¶
type ReplaceInstancesRequest struct {
Instances []Instance `json:"instances"`
}
ReplaceInstancesRequest supplies the complete desired instance set atomically.
func (ReplaceInstancesRequest) Validate ¶
func (request ReplaceInstancesRequest) Validate() error
Validate checks every desired instance and rejects duplicate IDs.
type Scene ¶
type Scene struct {
Elements []Element `json:"elements"`
}
Scene is a complete bounded presentation for both device displays.
type SessionEndRequest ¶
type SessionEndRequest struct {
Instance InstanceRef `json:"instance"`
SessionToken string `json:"session_token"`
}
SessionEndRequest closes one exact core-owned session.
func (SessionEndRequest) Validate ¶
func (request SessionEndRequest) Validate() error
Validate checks the exact instance and session token.
type SessionExecutionRequest ¶
type SessionExecutionRequest struct {
Instance InstanceRef `json:"instance"`
SessionToken string `json:"session_token"`
}
SessionExecutionRequest asks core for the final permission to perform one irreversible action for an exact foreground session.
func (SessionExecutionRequest) Validate ¶
func (request SessionExecutionRequest) Validate() error
Validate checks the exact instance and session token.
type SessionInput ¶
type SessionInput struct {
Button *ButtonInput `json:"button,omitempty"`
Encoder *EncoderInput `json:"encoder,omitempty"`
}
SessionInput contains exactly one button or encoder event.
func (SessionInput) Validate ¶
func (input SessionInput) Validate() error
Validate requires exactly one supported button or encoder event.
type SessionInputDisposition ¶
type SessionInputDisposition string
SessionInputDisposition reports whether a plugin handled one routed input.
const ( SessionInputConsumed SessionInputDisposition = "consumed" SessionInputNotConsumed SessionInputDisposition = "not_consumed" )
type SessionInputRequest ¶
type SessionInputRequest struct {
Sequence uint64 `json:"sequence"`
OccurredAt time.Time `json:"occurred_at"`
Instance InstanceRef `json:"instance"`
SessionToken string `json:"session_token"`
Input SessionInput `json:"input"`
}
SessionInputRequest delivers one acknowledged physical input event to a bound session.
func (SessionInputRequest) Validate ¶
func (request SessionInputRequest) Validate() error
Validate checks sequence, UTC time, session identity, and input payload.
type SessionInputResult ¶
type SessionInputResult struct {
Disposition SessionInputDisposition `json:"disposition"`
}
SessionInputResult is the strict response to plugin.session.input.
func (SessionInputResult) Validate ¶
func (result SessionInputResult) Validate() error
Validate accepts exactly the two input dispositions owned by protocol v1.
type SessionStartRequest ¶
type SessionStartRequest struct {
Instance InstanceRef `json:"instance"`
Action string `json:"action"`
Payload json.RawMessage `json:"payload,omitempty"`
SessionToken string `json:"session_token"`
Trigger *SessionTrigger `json:"trigger,omitempty"`
}
SessionStartRequest opens a generation-scoped interactive session.
func (SessionStartRequest) Validate ¶
func (request SessionStartRequest) Validate() error
Validate checks the session identity, action, payload, and optional trigger.
type SessionTrigger ¶
type SessionTrigger struct {
Kind SessionTriggerKind `json:"kind"`
Observation *ObservationRef `json:"observation,omitempty"`
}
SessionTrigger describes the launcher or observation that opened a session.
type SessionTriggerKind ¶
type SessionTriggerKind string
SessionTriggerKind identifies why core opened an interactive session.
const ( SessionTriggerLauncher SessionTriggerKind = "launcher" SessionTriggerObservation SessionTriggerKind = "observation" )
type TextElement ¶
type TextElement struct {
Value string `json:"value"`
Font string `json:"font,omitempty"`
Color string `json:"color,omitempty"`
Align string `json:"align,omitempty"`
Width int `json:"width,omitzero"`
Marquee *Marquee `json:"marquee,omitempty"`
}
TextElement renders bounded text with optional alignment and marquee behavior.
type WithdrawRequest ¶
type WithdrawRequest struct {
Instance InstanceRef `json:"instance"`
Channel string `json:"channel"`
Key string `json:"key"`
}
WithdrawRequest removes one exact instance, channel, and key observation.
func (WithdrawRequest) Validate ¶
func (request WithdrawRequest) Validate() error
Validate checks the exact observation identity to withdraw.