Documentation
¶
Index ¶
- Constants
- Variables
- func DecryptFromJSON(key string, raw string) (string, error)
- func EncryptAsJSON(key string, plaintext string) (string, error)
- func EndpointFromDomain(domain string, protocol HubProtocol) string
- func EventMatchesContext(event Event, expected Context) bool
- func NewRequestID() string
- func NewSessionID() string
- func RequestIDFromContext(context Context) string
- func RichMediaFromData(data Data) map[string]any
- func RuntimeCryptoKey(raw string) []byte
- func SessionIDFromContext(context Context) string
- func StripSSML(text string) string
- type ActionOptions
- type BootstrapIdentityOptions
- type BootstrapIdentityResult
- type Client
- func (c *Client) Ask(ctx context.Context, text string, opts RequestOptions) (Reply, error)
- func (c *Client) Close(ctx context.Context) error
- func (c *Client) Connect(ctx context.Context) error
- func (c *Client) Conversation(opts ConversationOptions) Conversation
- func (c *Client) Emit(ctx context.Context, eventType string, data Data, eventContext Context) error
- func (c *Client) Healthcheck() TransportHealth
- func (c *Client) SendAction(ctx context.Context, payload string, opts ActionOptions) error
- func (c *Client) SendCode(ctx context.Context, value string, opts CodeOptions) error
- func (c *Client) SendUtterance(ctx context.Context, text string, opts RequestOptions) error
- type ClientContextOptions
- type ClientOptions
- type CodeOptions
- type Context
- type ControlPlane
- func (c *ControlPlane) CreateClient(ctx context.Context, payload map[string]any, idempotencyKey string) (map[string]any, error)
- func (c *ControlPlane) CreateClientIdentity(ctx context.Context, hub map[string]any, opts BootstrapIdentityOptions) (BootstrapIdentityResult, error)
- func (c *ControlPlane) CreateClientIdentityForHubID(ctx context.Context, hubID string, opts BootstrapIdentityOptions) (BootstrapIdentityResult, error)
- func (c *ControlPlane) GetHub(ctx context.Context, hubID string) (map[string]any, error)
- func (c *ControlPlane) ListHubs(ctx context.Context, limit int, cursor string, ownerID string) (map[string]any, error)
- func (c *ControlPlane) Login(ctx context.Context, email string, password string, scope string) (map[string]any, error)
- func (c *ControlPlane) RequireRuntimeProtocol(result BootstrapIdentityResult, protocol HubProtocol) (*SelectedHubEndpoint, error)
- type Conversation
- func (c Conversation) Ask(ctx context.Context, text string, opts RequestOptions) (Reply, error)
- func (c Conversation) SendAction(ctx context.Context, payload string, opts ActionOptions) error
- func (c Conversation) SendCode(ctx context.Context, value string, opts CodeOptions) error
- func (c Conversation) SendUtterance(ctx context.Context, text string, opts RequestOptions) error
- type ConversationOptions
- type Data
- type DisplayItem
- type Event
- func (e Event) DisplayItems(maxTextChars int) []DisplayItem
- func (e Event) DisplayText() string
- func (e Event) IsFailure() bool
- func (e Event) RequestID() string
- func (e Event) RichMedia() map[string]any
- func (e Event) SessionID() string
- func (e Event) Text() string
- func (e Event) Utterances() []string
- type HTTPTransport
- func (t *HTTPTransport) Authorization() string
- func (t *HTTPTransport) BaseURL() string
- func (t *HTTPTransport) Connect(ctx context.Context) error
- func (t *HTTPTransport) Disconnect(ctx context.Context) error
- func (t *HTTPTransport) EmitBus(ctx context.Context, eventType string, data Data, eventContext Context) error
- func (t *HTTPTransport) Healthcheck() TransportHealth
- func (t *HTTPTransport) IsHandshakeComplete() bool
- func (t *HTTPTransport) PollOnce(ctx context.Context) error
- type HiveMessage
- type HubDataPlaneEndpoints
- type HubProtocol
- type HubProtocolSettings
- type Identity
- type MqttBrokerCredentials
- type Reply
- type RequestOptions
- type SelectedHubEndpoint
- type TransportHealth
Constants ¶
View Source
const ( EventRecognizerLoopUtterance = "recognizer_loop:utterance" EventSpeak = "speak" EventUtteranceHandled = "ovos.utterance.handled" EventIntentFailure = "complete_intent_failure" EventPolicyDenied = "hive.policy.denied" DefaultUserAgent = "ThalovantGoSDK/0.2.2" )
View Source
const DefaultControlUserAgent = "ThalovantGoSDK/0.2.3"
Variables ¶
View Source
var ( ErrIdentity = errors.New("thalovant identity error") ErrConnection = errors.New("thalovant connection error") ErrTimeout = errors.New("thalovant timeout") ErrRuntime = errors.New("thalovant runtime error") ErrAPI = errors.New("thalovant api error") ErrProtocol = errors.New("thalovant unsupported protocol") )
View Source
var DefaultProtocolPreference = []HubProtocol{ProtocolHTTPS, ProtocolWSS, ProtocolMQTT}
Functions ¶
func EndpointFromDomain ¶ added in v0.2.1
func EndpointFromDomain(domain string, protocol HubProtocol) string
func EventMatchesContext ¶
func NewRequestID ¶
func NewRequestID() string
func NewSessionID ¶
func NewSessionID() string
func RequestIDFromContext ¶
func RichMediaFromData ¶
func RuntimeCryptoKey ¶
func SessionIDFromContext ¶
Types ¶
type ActionOptions ¶
type BootstrapIdentityOptions ¶ added in v0.2.2
type BootstrapIdentityResult ¶ added in v0.2.2
type BootstrapIdentityResult struct {
Identity Identity
Hub map[string]any
Client map[string]any
Endpoint *SelectedHubEndpoint
}
func (BootstrapIdentityResult) SelectedProtocol ¶ added in v0.2.2
func (r BootstrapIdentityResult) SelectedProtocol() HubProtocol
type Client ¶
type Client struct {
Identity Identity
Transport *HTTPTransport
}
func NewClientFromEnv ¶
func NewClientFromFile ¶
func NewClientWithOptions ¶ added in v0.2.2
func NewClientWithOptions(identity Identity, opts ClientOptions) (*Client, error)
func (*Client) Conversation ¶
func (c *Client) Conversation(opts ConversationOptions) Conversation
func (*Client) Healthcheck ¶
func (c *Client) Healthcheck() TransportHealth
func (*Client) SendAction ¶
func (*Client) SendUtterance ¶
type ClientContextOptions ¶
type ClientOptions ¶ added in v0.2.2
type ClientOptions struct {
Protocol HubProtocol
}
type CodeOptions ¶
type Context ¶
func BuildClientContext ¶
func BuildClientContext(base Context, opts ClientContextOptions) Context
func ContextWithCorrelation ¶
func MergeContext ¶
type ControlPlane ¶ added in v0.2.2
type ControlPlane struct {
APIURL string
AccessToken string
UserAgent string
HTTPClient *http.Client
}
func NewControlPlane ¶ added in v0.2.2
func NewControlPlane(apiURL string, accessToken string) *ControlPlane
func (*ControlPlane) CreateClient ¶ added in v0.2.2
func (*ControlPlane) CreateClientIdentity ¶ added in v0.2.2
func (c *ControlPlane) CreateClientIdentity(ctx context.Context, hub map[string]any, opts BootstrapIdentityOptions) (BootstrapIdentityResult, error)
func (*ControlPlane) CreateClientIdentityForHubID ¶ added in v0.2.2
func (c *ControlPlane) CreateClientIdentityForHubID(ctx context.Context, hubID string, opts BootstrapIdentityOptions) (BootstrapIdentityResult, error)
func (*ControlPlane) RequireRuntimeProtocol ¶ added in v0.2.2
func (c *ControlPlane) RequireRuntimeProtocol(result BootstrapIdentityResult, protocol HubProtocol) (*SelectedHubEndpoint, error)
type Conversation ¶
type Conversation struct {
Client *Client
Options ConversationOptions
}
func (Conversation) Ask ¶
func (c Conversation) Ask(ctx context.Context, text string, opts RequestOptions) (Reply, error)
func (Conversation) SendAction ¶
func (c Conversation) SendAction(ctx context.Context, payload string, opts ActionOptions) error
func (Conversation) SendCode ¶
func (c Conversation) SendCode(ctx context.Context, value string, opts CodeOptions) error
func (Conversation) SendUtterance ¶
func (c Conversation) SendUtterance(ctx context.Context, text string, opts RequestOptions) error
type ConversationOptions ¶
type Data ¶
func UtterancePayload ¶
type DisplayItem ¶
type DisplayItem struct {
Kind string
Text string
Data any
Title string
Payload string
URL string
Silent bool
}
func DisplayItemsFromEventData ¶
func DisplayItemsFromEventData(data Data, eventName string, maxTextChars int) []DisplayItem
type Event ¶
func (Event) DisplayItems ¶
func (e Event) DisplayItems(maxTextChars int) []DisplayItem
func (Event) DisplayText ¶
func (Event) Utterances ¶
type HTTPTransport ¶
type HTTPTransport struct {
Identity Identity
UserAgent string
PollInterval time.Duration
HTTPClient *http.Client
BusEvents chan Event
// contains filtered or unexported fields
}
func NewHTTPTransport ¶
func NewHTTPTransport(identity Identity) *HTTPTransport
func (*HTTPTransport) Authorization ¶
func (t *HTTPTransport) Authorization() string
func (*HTTPTransport) BaseURL ¶
func (t *HTTPTransport) BaseURL() string
func (*HTTPTransport) Disconnect ¶
func (t *HTTPTransport) Disconnect(ctx context.Context) error
func (*HTTPTransport) Healthcheck ¶
func (t *HTTPTransport) Healthcheck() TransportHealth
func (*HTTPTransport) IsHandshakeComplete ¶
func (t *HTTPTransport) IsHandshakeComplete() bool
type HiveMessage ¶
type HiveMessage struct {
MsgType string `json:"msg_type"`
Payload map[string]any `json:"payload"`
Metadata map[string]any `json:"metadata"`
Route []any `json:"route"`
Node any `json:"node"`
TargetSiteID any `json:"target_site_id"`
TargetPubKey any `json:"target_pubkey"`
SourcePeer any `json:"source_peer"`
}
type HubDataPlaneEndpoints ¶ added in v0.2.1
type HubDataPlaneEndpoints struct {
HTTPS string `json:"https,omitempty"`
WSS string `json:"wss,omitempty"`
MQTT string `json:"mqtt,omitempty"`
}
func DataPlaneEndpointsFromHub ¶ added in v0.2.1
func DataPlaneEndpointsFromHub(hub map[string]any) HubDataPlaneEndpoints
func DataPlaneEndpointsFromMap ¶ added in v0.2.1
func DataPlaneEndpointsFromMap(values map[string]any) HubDataPlaneEndpoints
func (HubDataPlaneEndpoints) EndpointFor ¶ added in v0.2.1
func (e HubDataPlaneEndpoints) EndpointFor(protocol HubProtocol) string
type HubProtocol ¶ added in v0.2.1
type HubProtocol string
const ( ProtocolWSS HubProtocol = "wss" ProtocolHTTPS HubProtocol = "https" ProtocolMQTT HubProtocol = "mqtt" )
type HubProtocolSettings ¶ added in v0.2.1
type HubProtocolSettings struct {
WSS bool `json:"wss"`
HTTP bool `json:"http"`
MQTT bool `json:"mqtt"`
}
func DefaultHubProtocolSettings ¶ added in v0.2.1
func DefaultHubProtocolSettings() HubProtocolSettings
func ProtocolSettingsFromMap ¶ added in v0.2.1
func ProtocolSettingsFromMap(values map[string]any) HubProtocolSettings
func (HubProtocolSettings) EnabledProtocols ¶ added in v0.2.1
func (s HubProtocolSettings) EnabledProtocols() []HubProtocol
func (HubProtocolSettings) IsEnabled ¶ added in v0.2.1
func (s HubProtocolSettings) IsEnabled(protocol HubProtocol) bool
func (HubProtocolSettings) SpecMap ¶ added in v0.2.1
func (s HubProtocolSettings) SpecMap() map[string]any
type Identity ¶
type Identity struct {
AccessKey string `json:"access_key"`
Password string `json:"password"`
CryptoKey string `json:"crypto_key,omitempty"`
SiteID string `json:"site_id"`
DefaultMaster string `json:"default_master"`
DefaultPort int `json:"default_port"`
DefaultPath string `json:"default_path,omitempty"`
PublicKey string `json:"public_key,omitempty"`
DataPlaneEndpoints HubDataPlaneEndpoints `json:"data_plane_endpoints,omitempty"`
Protocols HubProtocolSettings `json:"protocols,omitempty"`
MQTT *MqttBrokerCredentials `json:"mqtt,omitempty"`
}
func IdentityFromEnv ¶
func IdentityFromFile ¶
func (Identity) EnabledProtocols ¶ added in v0.2.1
func (i Identity) EnabledProtocols() []HubProtocol
func (Identity) EndpointBase ¶
func (Identity) EndpointFor ¶ added in v0.2.1
func (i Identity) EndpointFor(protocol HubProtocol) string
func (Identity) SupportsProtocol ¶ added in v0.2.1
func (i Identity) SupportsProtocol(protocol HubProtocol) bool
type MqttBrokerCredentials ¶ added in v0.2.3
type MqttBrokerCredentials struct {
Endpoint string `json:"endpoint"`
Username string `json:"username"`
Password string `json:"password"`
TopicPrefix string `json:"topic_prefix,omitempty"`
TLS bool `json:"tls"`
}
func MqttBrokerCredentialsFromMap ¶ added in v0.2.3
func MqttBrokerCredentialsFromMap(raw any) *MqttBrokerCredentials
type Reply ¶
type Reply struct {
Text string
Utterances []string
Handled bool
OK bool
SessionID string
RequestID string
Events []Event
FailureEvent *Event
}
func (Reply) DisplayItems ¶
func (r Reply) DisplayItems(maxTextChars int) []DisplayItem
func (Reply) DisplayText ¶
type RequestOptions ¶
type SelectedHubEndpoint ¶ added in v0.2.2
type SelectedHubEndpoint struct {
Protocol HubProtocol `json:"protocol"`
Endpoint string `json:"endpoint"`
}
func SelectDataPlaneEndpoint ¶ added in v0.2.2
func SelectDataPlaneEndpoint(endpoints HubDataPlaneEndpoints, protocols HubProtocolSettings, preferred []HubProtocol) *SelectedHubEndpoint
Click to show internal directories.
Click to hide internal directories.