Documentation
¶
Overview ¶
Package gomode defines Go Mode service discovery and voice token contracts.
A host serves the discovery manifest with NewHandler and owns its accounts, authorization, hosted frontend, product APIs, and MCP tool and resource semantics. This package stays cheap for manifest-only hosts: it never imports voicegateway, Go Mode packages never import host packages, and WebRTC, Opus, and model provider clients stay under voicegateway. voicegateway may import this package and oauth/oauthverify to verify tokens.
User and integration guides are at https://docs.gomode.dev.
Index ¶
- Constants
- Variables
- func EncodeServiceSigningPublicKey(k ed25519.PublicKey) (string, error)
- func IssueServiceScopedToken(c *ScopedTokenClaims, k ed25519.PrivateKey) (string, error)
- func NewHandler(settings *Settings) (http.Handler, error)
- func ParseServiceSigningPublicKey(s string) (ed25519.PublicKey, error)
- type ClientExtensions
- type ConversationContext
- type ConversationResultMeta
- type Display
- type DisplayColorSpace
- type DisplayShape
- type ErrorBody
- type ErrorResponse
- type LocationActivation
- type LocationWiFi
- type PhysicalPosition
- type ResourceDependency
- type ScopedTokenClaims
- type Settings
- type SkillActivation
- type SkillFrontmatter
- type SkillGoMode
- type SkillMCPServer
- type ToolGroup
- type VoiceGatewaySettings
- type WebShellSettings
Constants ¶
const ConversationContextMetaKey = "com.fghbuild.gomode/context"
ConversationContextMetaKey identifies private reconciliation on MCP results. It is transport metadata and must never be exposed as model tool output.
const DisplayExtension = "com.fghbuild.gomode/display"
DisplayExtension identifies the client capability extension that declares the display of the glasses connected to a Go Mode client.
A Go Mode client puts the Display settings object under this key in _meta["io.modelcontextprotocol/clientCapabilities"].extensions of every MCP request while glasses are connected, and omits the key otherwise. MCP declares client capabilities per request, so connecting or disconnecting glasses takes effect on the next request and a server must not carry a display over from an earlier request. The web client never sends it.
A server that fits its content to the display falls back to its display-less output when the key is absent or its value is malformed, including a DisplayShape or DisplayColorSpace value it does not know. Adding an optional field or an enumeration value is not breaking; any other change to the settings object takes the identifier "com.fghbuild.gomode/display-v2". The client, not the server, chooses Width and Height, and Validate sets no upper bound on them: a server bounds what it allocates from them, for example by drawing at most 1024 pixels a side and keeping the aspect ratio.
Example request metadata with a Halo connected:
"_meta": {
"io.modelcontextprotocol/clientCapabilities": {
"extensions": {
"com.fghbuild.gomode/display": {
"width": 256, "height": 256, "shape": "circle",
"colorSpace": "rgb", "bitsPerPixel": 4,
"imageTypes": ["image/png"]
}
}
}
}
Glasses content ¶
A tool draws on the declared display by adding glasses blocks to the content of its CallToolResult: content blocks whose annotations.audience is exactly ["user"]. A glasses block is a text block, or an image block of a MIME type in Display.ImageTypes whose image is at most Width by Height pixels. The client never gives the model a block whose audience is exactly ["user"], with or without glasses, so a tool returns its model-facing result in structuredContent or in other blocks beside its glasses blocks. In Go, mcp.GlassesText and mcp.GlassesImage build glasses blocks.
Of a result's glasses blocks, the client shows the last one that the connected display draws, in place of the voice transcript. It holds it through the assistant's reply until the user starts speaking again, as the client's speech recognition or the voice gateway's voice activity detection reports, then shows the transcript again; noise taken for speech also ends it. A later result's glasses block replaces it, and the end of the voice session clears it. It shows even when the user hides the transcript on the glasses.
The client lays text out. A text longer than one screen shows as a run of its wrapped lines above a marker such as "12/80" that counts the lines read. Screens advance on their own after their reading time and start again after the last, until the wearer's first swipe; from then on, each swipe of a temple or the ring on Even G2 scrolls one line. The client shows at most 65536 characters of a text. The client centres an image, scales one larger than the display down to fit, and picks its 2^BitsPerPixel levels or colours as ColorSpace defines.
const ModelContextMetaKey = "com.fghbuild.gomode/modelContext"
ModelContextMetaKey opts a resource descriptor into automatic conversation context. The value must be true; unmarked resources remain available only on demand.
const ScopedTokenAudience = "voice-gateway"
ScopedTokenAudience is the expected audience for service-issued gateway tokens.
Variables ¶
var SDKAPI = apispec.Config[string]{ Routes: []apispec.Route{ { Name: "getSettings", Doc: "Returns Go Mode service compatibility settings.", Method: "GET", Path: settingsPath, Category: "Settings", Resp: reflect.TypeFor[Settings](), }, }, SDKPackagePaths: map[string]struct{}{ reflect.TypeFor[Settings]().PkgPath(): {}, reflect.TypeFor[ErrorResponse]().PkgPath(): {}, }, ExtraSeeds: []reflect.Type{ reflect.TypeFor[ClientExtensions](), reflect.TypeFor[ConversationContext](), reflect.TypeFor[ConversationResultMeta](), reflect.TypeFor[ErrorResponse](), reflect.TypeFor[SkillFrontmatter](), }, DocumentExtraSeeds: true, KotlinPackage: "com.fghbuild.gomode.sdk.v1", APIDocTitle: "Go Mode Service Discovery API Reference", APIDocIntro: "Service-neutral JSON discovery manifest served publicly at `/.well-known/gomode.json` for Go Mode Android bootstrap. " + "Clients must only accept `apiVersion` values they explicitly support and must require `webShell.bridgeVersion` to match the native bridge they implement.", SpecialTypes: []apispec.SpecialType{ { Type: reflect.TypeFor[map[string]any](), TSType: "{ [key: string]: any /* json.RawMessage */}", KTType: "Map<String, JsonElement>", SwiftType: "[String: JSONValue]", DocType: "Record<string, JSONValue>", }, }, }
SDKAPI is the SDK generation specification for the Go Mode service discovery API.
Immutable
Functions ¶
func EncodeServiceSigningPublicKey ¶
EncodeServiceSigningPublicKey returns the importable form of an Ed25519 public key.
func IssueServiceScopedToken ¶
func IssueServiceScopedToken(c *ScopedTokenClaims, k ed25519.PrivateKey) (string, error)
IssueServiceScopedToken signs a short-lived service-scoped gateway token.
func NewHandler ¶
NewHandler returns a Go Mode service metadata HTTP handler.
Types ¶
type ClientExtensions ¶ added in v0.6.0
type ClientExtensions struct {
// Display is present while glasses are connected.
Display *Display `json:"com.fghbuild.gomode/display,omitempty"`
}
ClientExtensions holds the settings objects of the Go Mode client capability extensions, keyed as in ClientCapabilities.extensions. Clients encode it to build that map, so generated SDKs carry each extension identifier.
type ConversationContext ¶
type ConversationContext struct {
URI string `json:"uri"`
Epoch string `json:"epoch"`
Version int64 `json:"version"`
Dependencies []ResourceDependency `json:"dependencies"`
Content *string `json:"content,omitempty"`
}
ConversationContext orders one advertised model-context resource for one authenticated conversation. URI identifies the resource this update replaces. Only a read of that URI can establish a new epoch. Dependencies are private event routing, never model content. Content is the server-defined public resource text after a tool; resource reads omit it because their standard contents already carry the same text.
type ConversationResultMeta ¶
type ConversationResultMeta struct {
Context *ConversationContext `json:"com.fghbuild.gomode/context,omitempty"`
}
ConversationResultMeta carries an authorized resource update after a tool.
type Display ¶ added in v0.6.0
type Display struct {
// Width is the number of pixel columns. It is positive.
Width int `json:"width"`
// Height is the number of pixel rows. It is positive.
Height int `json:"height"`
// Shape is the visible area within the Width by Height pixels.
Shape DisplayShape `json:"shape"`
// ColorSpace is what a pixel value represents.
ColorSpace DisplayColorSpace `json:"colorSpace"`
// BitsPerPixel is the pixel depth, from 1 to 24: a pixel shows one of
// 2^BitsPerPixel luminance levels or colours, as ColorSpace defines.
BitsPerPixel int `json:"bitsPerPixel"`
// ImageTypes lists the MIME types of the glasses image blocks the client
// draws on this display, such as "image/png". It is empty when the client
// draws glasses text alone, as on Even Realities G2 with stock firmware.
ImageTypes []string `json:"imageTypes,omitempty"`
}
Display describes one connected display so a server can fit its content to it. It is the settings object of the com.fghbuild.gomode/display client capability extension, whose contract the Go constant DisplayExtension documents. Servers must ignore fields they do not know.
func (*Display) DrawsImages ¶ added in v0.6.0
DrawsImages reports whether the client draws glasses image blocks of mimeType on d.
type DisplayColorSpace ¶ added in v0.6.0
type DisplayColorSpace string
DisplayColorSpace is what a display's pixel values represent.
const ( // DisplayColorSpaceLuminance pixels are brightness levels that the device // shows in its single tint, such as green on Even Realities G2. DisplayColorSpaceLuminance DisplayColorSpace = "luminance" // DisplayColorSpaceRGB pixels are colours. Below 24 bits per pixel, the // client picks the 2^BitsPerPixel colours of each image from 24-bit RGB. DisplayColorSpaceRGB DisplayColorSpace = "rgb" )
Display colour spaces.
type DisplayShape ¶ added in v0.6.0
type DisplayShape string
DisplayShape is the visible area of a display.
const ( // DisplayShapeCircle shows the circle inscribed in the Width by Height // pixels; pixels outside it are not visible. DisplayShapeCircle DisplayShape = "circle" // DisplayShapeRectangle shows every pixel. DisplayShapeRectangle DisplayShape = "rectangle" )
Display shapes.
type ErrorResponse ¶
type ErrorResponse struct {
Error ErrorBody `json:"error"`
Details map[string]any `json:"details,omitempty"`
}
ErrorResponse is the standard JSON error envelope for Go Mode SDK clients.
type LocationActivation ¶
type LocationActivation struct {
WiFi LocationWiFi `json:"wifi,omitzero" yaml:"wifi,omitempty"`
PhysicalPosition PhysicalPosition `json:"physicalPosition,omitzero" yaml:"physicalPosition,omitempty"`
}
LocationActivation groups one location-based activation signal for a skill.
func (LocationActivation) IsZero ¶
func (l LocationActivation) IsZero() bool
IsZero reports whether the location activation has no trigger.
type LocationWiFi ¶
type LocationWiFi struct {
// SSIDs are Wi-Fi network names that can activate the skill.
SSIDs []string `json:"ssids,omitempty,omitzero" yaml:"ssids,omitempty"`
}
LocationWiFi matches any one of the configured Wi-Fi SSIDs.
func (LocationWiFi) IsZero ¶
func (w LocationWiFi) IsZero() bool
IsZero reports whether there are no Wi-Fi SSIDs.
type PhysicalPosition ¶
type PhysicalPosition struct {
// Name is a user-facing label for this physical position.
Name string `json:"name" yaml:"name"`
Latitude float64 `json:"latitude" yaml:"latitude"`
Longitude float64 `json:"longitude" yaml:"longitude"`
// RadiusMeters is the activation radius around the latitude and longitude.
RadiusMeters float64 `json:"radiusMeters" yaml:"radiusMeters"`
}
PhysicalPosition matches a named latitude and longitude within RadiusMeters.
func (PhysicalPosition) IsZero ¶
func (p PhysicalPosition) IsZero() bool
IsZero reports whether no physical position is configured.
type ResourceDependency ¶
type ResourceDependency struct {
URIs []string `json:"uris"`
Aspects []string `json:"aspects,omitempty"`
}
ResourceDependency routes host change-feed events without interpreting domain content. Each group contains at most 50 URIs. Empty aspects match any change.
type ScopedTokenClaims ¶
type ScopedTokenClaims struct {
ServiceKind string `json:"serviceKind"`
ServiceInstanceID string `json:"serviceInstanceID"`
BackendOrigin string `json:"backendOrigin"`
Subject string `json:"sub"`
Capabilities []string `json:"capabilities"`
Audience string `json:"aud"`
Expiry time.Time `json:"exp"`
}
ScopedTokenClaims are the service-issued claims required to create a voice session.
func VerifyServiceScopedToken ¶
func VerifyServiceScopedToken(token string, k ed25519.PublicKey, audience string) (*ScopedTokenClaims, error)
VerifyServiceScopedToken validates a service-scoped gateway token.
func (*ScopedTokenClaims) Validate ¶
func (c *ScopedTokenClaims) Validate(audience string) error
Validate returns an error if c cannot authorize a service-bound voice session.
type Settings ¶
type Settings struct {
Service string `json:"service"`
// ServiceVersion is the host product version. It is informational and does
// not participate in Go Mode compatibility checks.
ServiceVersion string `json:"serviceVersion,omitempty"`
// APIVersion is the Go Mode discovery schema version. A client must reject
// manifests with an API version it does not explicitly support.
APIVersion int `json:"apiVersion"`
WebShell WebShellSettings `json:"webShell"`
}
Settings is the service compatibility document consumed by Go Mode clients.
type SkillActivation ¶
type SkillActivation struct {
// Locations are local physical-location and Wi-Fi hints that make this skill
// an activation candidate.
Locations []LocationActivation `json:"locations,omitempty" yaml:"locations,omitempty"`
}
SkillActivation carries hints the shell matches against current context to decide when to load a skill. Matching is on-device: the service never receives the user's context or location just because a skill was considered.
func (SkillActivation) IsZero ¶
func (a SkillActivation) IsZero() bool
IsZero reports whether activation hints are absent for json omitzero.
type SkillFrontmatter ¶
type SkillFrontmatter struct {
Name string `json:"name" yaml:"name"`
Description string `json:"description" yaml:"description"`
GoMode SkillGoMode `json:"gomode" yaml:"gomode"`
}
SkillFrontmatter is the YAML frontmatter schema for a Go Mode SKILL.md file.
The Markdown body carries human and model instructions. The frontmatter carries machine-readable activation hints and the MCP tool allowlist that the native shell can register when the skill becomes active.
func (*SkillFrontmatter) Validate ¶
func (f *SkillFrontmatter) Validate() error
Validate returns an error if f is not a well-formed Go Mode skill frontmatter.
type SkillGoMode ¶
type SkillGoMode struct {
Activation SkillActivation `json:"activation,omitzero" yaml:"activation,omitempty"`
MCPServers []SkillMCPServer `json:"mcpServers" yaml:"mcpServers"`
}
SkillGoMode contains Go Mode-specific SKILL.md frontmatter fields.
type SkillMCPServer ¶
type SkillMCPServer struct {
Name string `json:"name" yaml:"name"`
Endpoint string `json:"endpoint" yaml:"endpoint"`
// ProtocolVersion is the MCP protocol version spoken by this endpoint.
ProtocolVersion string `json:"protocolVersion" yaml:"protocolVersion"`
AuthRequired bool `json:"authRequired" yaml:"authRequired"`
// Tools is the explicit allowlist of MCP tool names activated by the skill.
Tools []string `json:"tools" yaml:"tools"`
}
SkillMCPServer declares which tools from an MCP endpoint belong to one skill.
func (*SkillMCPServer) Validate ¶
func (s *SkillMCPServer) Validate() error
Validate returns an error if s is not a well-formed skill MCP server entry.
type ToolGroup ¶
type ToolGroup struct {
Name string `json:"name"`
Description string `json:"description,omitempty"`
Endpoint string `json:"endpoint"`
// ProtocolVersion is the MCP protocol version spoken by this group endpoint.
// The shell sends it on MCP requests so each group can be checked and
// upgraded independently during protocol migrations.
ProtocolVersion string `json:"protocolVersion"`
AuthRequired bool `json:"authRequired"`
// SkillURL points to the SKILL.md file whose frontmatter defines activation,
// instructions, and the MCP tool subset for this skill.
SkillURL string `json:"skillUrl,omitempty"`
}
ToolGroup describes a bootstrap MCP tool group advertised by the manifest.
A tool group is the compatibility manifest's compact view of a Go Mode skill. The authoritative context, activation hints, and tool subset live in the skill's SKILL.md frontmatter; the manifest stays small so clients can decide whether native features are compatible before loading skill files.
type VoiceGatewaySettings ¶
type VoiceGatewaySettings struct {
Required bool `json:"required"`
URL string `json:"url,omitempty"`
AuthRequired bool `json:"authRequired,omitempty"`
TokenEndpoint string `json:"tokenEndpoint,omitempty"`
}
VoiceGatewaySettings describes the preferred voice gateway for this service.
func (*VoiceGatewaySettings) Validate ¶
func (s *VoiceGatewaySettings) Validate() error
Validate returns an error if s is not a well-formed voice gateway manifest entry.
type WebShellSettings ¶
type WebShellSettings struct {
// BridgeVersion is the hosted-frontend/native bridge contract version. A
// shell must reject manifests whose bridge version differs from the bridge
// version implemented by that shell.
BridgeVersion int `json:"bridgeVersion"`
ToolGroups []ToolGroup `json:"toolGroups"`
VoiceGateway VoiceGatewaySettings `json:"voiceGateway"`
}
WebShellSettings describes the hosted frontend's native-shell contract.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package autoupdate installs newer stable GitHub releases over HTTPS and owns no host APIs.
|
Package autoupdate installs newer stable GitHub releases over HTTPS and owns no host APIs. |
|
cmd
|
|
|
voice-gateway
command
|
|
|
Package devicelogin pairs an unauthenticated browser with an explicitly approving signed-in user.
|
Package devicelogin pairs an unauthenticated browser with an explicitly approving signed-in user. |
|
Package httpserver provides shared HTTP request infrastructure.
|
Package httpserver provides shared HTTP request infrastructure. |
|
geoip
Package geoip provides IP origin and country allowlist enforcement.
|
Package geoip provides IP origin and country allowlist enforcement. |
|
geoip/data/v1
Package v1 defines version 1 of the on-disk named IP-origin cache.
|
Package v1 defines version 1 of the on-disk named IP-origin cache. |
|
ratelimit
Package ratelimit limits requests per key with token buckets and tells rejected clients when to retry.
|
Package ratelimit limits requests per key with token buckets and tells rejected clients when to retry. |
|
internal
|
|
|
cmd/android-voice-fixture
command
|
|
|
cmd/gen-sdk
command
Command gen-sdk generates versioned Go Mode protocol SDK packages.
|
Command gen-sdk generates versioned Go Mode protocol SDK packages. |
|
gatewayfrontend
Package gatewayfrontend serves the standalone voice test host.
|
Package gatewayfrontend serves the standalone voice test host. |
|
pairing
Package pairing implements device-code secrets and transitions independently of HTTP, storage, and credential issuance.
|
Package pairing implements device-code secrets and transitions independently of HTTP, storage, and credential issuance. |
|
rsatest
Package rsatest supplies public test fixtures for RSA signing and verification.
|
Package rsatest supplies public test fixtures for RSA signing and verification. |
|
voicetest
Package voicetest replays a voice gateway text session recorded from the real gateway.
|
Package voicetest replays a voice gateway text session recorded from the real gateway. |
|
Package mcp implements the Model Context Protocol HTTP endpoint, Skills extension, and SDK DTOs.
|
Package mcp implements the Model Context Protocol HTTP endpoint, Skills extension, and SDK DTOs. |
|
mcptest
Package mcptest provides shared test doubles for the mcp package's interfaces.
|
Package mcptest provides shared test doubles for the mcp package's interfaces. |
|
Package oauth is an OAuth 2.0 authorization server and client library.
|
Package oauth is an OAuth 2.0 authorization server and client library. |
|
oauthclient
Package oauthclient provides an OAuth 2.0 authorization-code client for third-party providers.
|
Package oauthclient provides an OAuth 2.0 authorization-code client for third-party providers. |
|
oauthserver
Package oauthserver is a generic OAuth 2.0 authorization server.
|
Package oauthserver is a generic OAuth 2.0 authorization server. |
|
oauthserver/data/v5
Package v5 defines version 5 of the persisted OAuth store.
|
Package v5 defines version 5 of the persisted OAuth store. |
|
api
Package api provides shared voice gateway API infrastructure.
|
Package api provides shared voice gateway API infrastructure. |
|
api/v1
Package v1 is the voice gateway contract published with Go Mode v0.3.0.
|
Package v1 is the voice gateway contract published with Go Mode v0.3.0. |
|
data/v1
Package v1 defines version 1 of the voice gateway config.toml and voice-choices.toml schemas.
|
Package v1 defines version 1 of the voice gateway config.toml and voice-choices.toml schemas. |
|
policy
Package policy owns voice instructions shared by gateways and bundled offline engines.
|
Package policy owns voice instructions shared by gateways and bundled offline engines. |
|
voicertc
Package voicertc implements WebRTC voice sessions through the voice gateway protocol.
|
Package voicertc implements WebRTC voice sessions through the voice gateway protocol. |
|
voicertc/data/v1
Package v1 defines version 1 of the persisted voice activity records, independent of the session protocol.
|
Package v1 defines version 1 of the persisted voice activity records, independent of the session protocol. |