danteclient

package module
v0.1.3 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

View Source
var (
	ErrAuthorizationPending = errors.New("danteclient: authorization pending")
	ErrAuthorizationDenied  = errors.New("danteclient: authorization denied")
	ErrAuthorizationExpired = errors.New("danteclient: authorization expired")
)

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) PollPairing added in v0.1.3

func (c *Client) PollPairing(ctx context.Context, request PairingRequest) (Credentials, 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

func (*Client) StartPairing added in v0.1.3

func (c *Client) StartPairing(ctx context.Context) (PairingRequest, error)

StartPairing starts a browser-approved device authorization. Callers should open VerificationURL for the user, retain the full request server-side, and pass it to Manager.CompletePairing while it remains valid.

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) CompletePairing added in v0.1.3

func (m *Manager) CompletePairing(ctx context.Context, request PairingRequest) error

CompletePairing waits for browser approval, persists the resulting device credential, and starts the normal synchronization lifecycle.

func (*Manager) Connect

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

func (*Manager) Disconnect

func (m *Manager) Disconnect() error

func (*Manager) SetSyncInterval added in v0.1.1

func (m *Manager) SetSyncInterval(interval time.Duration)

func (*Manager) Start

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

func (*Manager) StartPairing added in v0.1.3

func (m *Manager) StartPairing(ctx context.Context) (PairingRequest, 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)
	AllowDegradedStart bool
}

type PairingRequest added in v0.1.3

type PairingRequest struct {
	DeviceCode      string
	UserCode        string        `json:"userCode"`
	VerificationURL string        `json:"verificationUrl"`
	ExpiresAt       time.Time     `json:"expiresAt"`
	PollInterval    time.Duration `json:"-"`
}

PairingRequest describes a browser-approved device authorization that is waiting for the user at VerificationURL. DeviceCode is an opaque polling secret and must never be rendered or sent to the browser.

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