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 ConversationContext
- type ConversationResultMeta
- 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 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[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 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 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. |
|
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. |