danteclient

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 13 Imported by: 0

README

Dante client for Go

dante-client-go is the shared client-side implementation of Dante platform device registration for LocalAI organization applications.

It supports both application clients and service processes:

  • redeeming one-use pairing keys;
  • securely persisting device credentials;
  • retrieving explicitly assigned LocalAI instances;
  • reporting service endpoints, models, and capabilities;
  • retrieving service user assignments and introspecting client tokens;
  • connection status, periodic synchronization, retry, and disconnect.

The platform never connects to service-advertised endpoints. Services initiate registration, reporting, access synchronization, and token introspection.

client, err := danteclient.New(danteclient.ClientOptions{
    PlatformURL: "https://auth.example.com",
    DeviceName:  "workstation",
    ClientType:  "dante-desktop",
    Kind:        danteclient.DeviceKindClient,
})
if err != nil { /* handle */ }

manager, err := danteclient.NewManager(danteclient.ManagerOptions{
    Client: client,
    Store:  danteclient.FileStore{Path: credentialPath},
})
if err != nil { /* handle */ }

err = manager.Connect(ctx, pairingKey)

Applications should use an operating-system keychain implementation of CredentialStore when one is available. FileStore uses atomic replacement, 0700 parent directories, and 0600 files for headless services.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(opts ClientOptions) (*Client, error)

func (*Client) Credentials

func (c *Client) Credentials() Credentials

func (*Client) FetchConfig

func (c *Client) FetchConfig(ctx context.Context) (DeviceConfig, error)

func (*Client) FetchServiceAccess

func (c *Client) FetchServiceAccess(ctx context.Context) (ServiceAccess, error)

func (*Client) Heartbeat

func (c *Client) Heartbeat(ctx context.Context) error

func (*Client) Introspect

func (c *Client) Introspect(ctx context.Context, token string) (Introspection, error)

func (*Client) RedeemKey

func (c *Client) RedeemKey(ctx context.Context, key string) (Credentials, error)

func (*Client) ReportInstance

func (c *Client) ReportInstance(ctx context.Context, report InstanceReport) (ReportResult, error)

func (*Client) SetCredentials

func (c *Client) SetCredentials(creds Credentials) error

type ClientOptions

type ClientOptions struct {
	PlatformURL string
	DeviceName  string
	ClientType  string
	Kind        DeviceKind
	HTTPClient  *http.Client
}

type ConnectionState

type ConnectionState string
const (
	StateDisconnected ConnectionState = "disconnected"
	StateConnecting   ConnectionState = "connecting"
	StateConnected    ConnectionState = "connected"
	StateDegraded     ConnectionState = "degraded"
)

type CredentialStore

type CredentialStore interface {
	Load() (Credentials, error)
	Save(Credentials) error
	Delete() error
}

type Credentials

type Credentials struct {
	PlatformURL string `json:"platformUrl"`
	DeviceID    string `json:"deviceId"`
	DeviceToken string `json:"deviceToken"`
}

type Device

type Device struct {
	ID         string     `json:"id"`
	Name       string     `json:"name"`
	Kind       DeviceKind `json:"kind"`
	ClientType string     `json:"clientType"`
}

type DeviceConfig

type DeviceConfig struct {
	User      User       `json:"user"`
	Device    Device     `json:"device"`
	Instances []Instance `json:"instances"`
	MCP       *MCPConfig `json:"mcp,omitempty"`
}

type DeviceKind

type DeviceKind string
const (
	DeviceKindClient  DeviceKind = "client"
	DeviceKindService DeviceKind = "service"
)

type Endpoint

type Endpoint struct {
	URL      string `json:"url"`
	Label    string `json:"label,omitempty"`
	Scope    string `json:"scope,omitempty"`
	Priority int    `json:"priority,omitempty"`
}

type FileStore

type FileStore struct{ Path string }

func (FileStore) Delete

func (s FileStore) Delete() error

func (FileStore) Load

func (s FileStore) Load() (Credentials, error)

func (FileStore) Save

func (s FileStore) Save(creds Credentials) error

type HTTPError

type HTTPError struct {
	StatusCode int
	Code       string
}

func (*HTTPError) Error

func (e *HTTPError) Error() string

type Instance

type Instance struct {
	ID        string     `json:"id"`
	Name      string     `json:"name"`
	Kind      string     `json:"kind"`
	BaseURL   string     `json:"baseUrl"`
	Endpoints []Endpoint `json:"endpoints,omitempty"`
	Models    []string   `json:"models"`
	Healthy   bool       `json:"healthy"`
	Primary   bool       `json:"primary"`
}

type InstanceReport

type InstanceReport struct {
	Name         string     `json:"name"`
	Endpoints    []Endpoint `json:"endpoints"`
	Models       []string   `json:"models"`
	Version      string     `json:"version,omitempty"`
	Capabilities []string   `json:"capabilities,omitempty"`
}

type Introspection

type Introspection struct {
	Active   bool    `json:"active"`
	User     *User   `json:"user,omitempty"`
	Device   *Device `json:"device,omitempty"`
	Revision int64   `json:"revision"`
}

type MCPConfig

type MCPConfig struct {
	Dante *MCPEndpoint `json:"dante,omitempty"`
}

type MCPEndpoint

type MCPEndpoint struct {
	URL    string   `json:"url"`
	Scopes []string `json:"scopes,omitempty"`
	Token  string   `json:"token,omitempty"`
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

func NewManager

func NewManager(opts ManagerOptions) (*Manager, error)

func (*Manager) Connect

func (m *Manager) Connect(ctx context.Context, pairingKey string) error

func (*Manager) Disconnect

func (m *Manager) Disconnect() error

func (*Manager) Start

func (m *Manager) Start(ctx context.Context) error

func (*Manager) Status

func (m *Manager) Status() Status

func (*Manager) Sync

func (m *Manager) Sync(ctx context.Context) error

type ManagerOptions

type ManagerOptions struct {
	Client       *Client
	Store        CredentialStore
	Sync         SyncFunc
	SyncInterval time.Duration
	OnStatus     func(Status)
}

type ReportResult

type ReportResult struct {
	InstanceID            string `json:"instanceId"`
	ReportIntervalSeconds int    `json:"reportIntervalSeconds"`
	Revision              int64  `json:"revision"`
}

type ServiceAccess

type ServiceAccess struct {
	Revision int64  `json:"revision"`
	Users    []User `json:"users"`
}

type Status

type Status struct {
	State       ConnectionState `json:"state"`
	DeviceID    string          `json:"deviceId,omitempty"`
	LastContact time.Time       `json:"lastContact,omitempty"`
	LastError   string          `json:"lastError,omitempty"`
}

type SyncFunc

type SyncFunc func(context.Context, *Client) error

type User

type User struct {
	ID      string `json:"id"`
	Email   string `json:"email"`
	Name    string `json:"name"`
	Enabled bool   `json:"enabled,omitempty"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL