client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 21 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	APIVersion     = 1
	DefaultBaseURL = "https://daemons.run/api/v1"
)

Variables

This section is empty.

Functions

func IsAPIError

func IsAPIError(err error, code string) bool

func NormalizeBaseURL

func NormalizeBaseURL(value string) (string, error)

Types

type Account

type Account struct {
	ID      string `json:"id"`
	Email   string `json:"email"`
	Enabled bool   `json:"control_plane_api_enabled"`
}

type Capability

type Capability struct {
	Name         string   `json:"name"`
	Enabled      bool     `json:"enabled"`
	Reason       *string  `json:"reason"`
	Dependencies []string `json:"dependencies"`
}

type CapabilityList

type CapabilityList struct {
	Data []Capability    `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type Client

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

func New

func New(baseURL, token string, options ...Option) (*Client, error)

func (*Client) CancelTask

func (c *Client) CancelTask(ctx context.Context, daemonID, taskID, idempotencyKey string) (TaskEnvelope, error)

func (*Client) Capabilities

func (c *Client) Capabilities(ctx context.Context) (CapabilityList, error)

func (*Client) CreateDeviceAuthorization

func (c *Client) CreateDeviceAuthorization(ctx context.Context, scopes []string, lifetime string) (DeviceAuthorization, error)

func (*Client) CreateTask

func (c *Client) CreateTask(ctx context.Context, daemonID string, task TaskRequest, idempotencyKey string) (TaskEnvelope, error)

func (*Client) DestroyDaemon

func (c *Client) DestroyDaemon(ctx context.Context, daemonID, etag, idempotencyKey string) (OperationEnvelope, error)

DestroyDaemon sends the conditional delete. The caller supplies the ETag captured from ShowDaemon; an empty ETag sends no If-Match and lets the server reject the unconditional request.

func (*Client) LifecycleDaemon

func (c *Client) LifecycleDaemon(ctx context.Context, daemonID, action, idempotencyKey string) (OperationEnvelope, error)

func (*Client) ListDaemons

func (c *Client) ListDaemons(ctx context.Context) (DaemonList, error)

func (*Client) ListFiles

func (c *Client) ListFiles(ctx context.Context, daemonID, workspacePath, cursor string, limit int) (FileList, error)

ListFiles reads one page of a workspace directory listing. The cursor is opaque and comes from the previous page's meta.next_cursor.

func (*Client) ListLogs

func (c *Client) ListLogs(ctx context.Context, daemonID, source, level, cursor string, limit int) (LogList, error)

ListLogs reads one bounded, server-redacted log snapshot. The source is validated by the caller against the closed set the server accepts.

func (*Client) ListOperations

func (c *Client) ListOperations(ctx context.Context, limit int) (OperationList, error)

func (*Client) ListServers

func (c *Client) ListServers(ctx context.Context) (ServerList, error)

func (*Client) ListTasks

func (c *Client) ListTasks(ctx context.Context, daemonID string, limit int) (TaskList, error)

func (*Client) Logout

func (c *Client) Logout(ctx context.Context, idempotencyKey string) error

func (*Client) Me

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

func (*Client) MintTicket

func (c *Client) MintTicket(ctx context.Context, daemonID, session string, cols, rows int) (Ticket, error)

func (*Client) PollDeviceAuthorization

func (c *Client) PollDeviceAuthorization(ctx context.Context, code string) (DeviceAuthorizationStatus, error)

func (*Client) Preflight

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

func (*Client) ResolveDaemon

func (c *Client) ResolveDaemon(ctx context.Context, value string) (Daemon, error)

func (*Client) ResolveServer

func (c *Client) ResolveServer(ctx context.Context, value string) (Server, error)

ResolveServer accepts a server UUID or exact name. Names are matched exactly against the account's server list; there is no prefix matching.

func (*Client) ShowDaemon

func (c *Client) ShowDaemon(ctx context.Context, daemonID string) (DaemonEnvelope, error)

func (*Client) ShowOperation

func (c *Client) ShowOperation(ctx context.Context, operationID string) (OperationEnvelope, error)

func (*Client) ShowServer

func (c *Client) ShowServer(ctx context.Context, serverID string) (ServerEnvelope, error)

func (*Client) ShowTask

func (c *Client) ShowTask(ctx context.Context, daemonID, taskID string) (TaskEnvelope, error)

func (*Client) SpawnDaemon

func (c *Client) SpawnDaemon(ctx context.Context, spawn SpawnRequest, idempotencyKey string) (DaemonSpawnEnvelope, error)

func (*Client) Upload

func (c *Client) Upload(ctx context.Context, daemonID, filename string, file *os.File) (UploadResponse, error)

type Daemon

type Daemon struct {
	ID           string `json:"id"`
	Name         string `json:"name"`
	Status       string `json:"status"`
	PrimaryAgent string `json:"primary_agent"`
	Server       struct {
		ID     string `json:"id"`
		Name   string `json:"name"`
		Status string `json:"status"`
	} `json:"server"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type DaemonEnvelope

type DaemonEnvelope struct {
	Data Daemon          `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
	ETag string          `json:"-"`
}

type DaemonList

type DaemonList struct {
	Data []Daemon        `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type DaemonSpawnEnvelope

type DaemonSpawnEnvelope struct {
	Data Daemon `json:"data"`
	Meta struct {
		Operation Operation `json:"operation"`
	} `json:"meta"`
	Raw json.RawMessage `json:"-"`
}

DaemonSpawnEnvelope is the 202 document returned by POST /daemons: the new daemon plus the spawn Operation carried in meta.

type DeviceAuthorization

type DeviceAuthorization struct {
	Data struct {
		DeviceCode      string  `json:"device_code"`
		VerificationURL string  `json:"verification_url"`
		ExpiresAt       string  `json:"expires_at"`
		IntervalSeconds WireInt `json:"interval_seconds"`
	} `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type DeviceAuthorizationStatus

type DeviceAuthorizationStatus struct {
	Data struct {
		Status      string `json:"status"`
		AccessToken string `json:"access_token"`
		TokenType   string `json:"token_type"`
	} `json:"data"`
	Meta map[string]any `json:"meta"`
}

type FileEntry

type FileEntry struct {
	Name  string  `json:"name"`
	Type  string  `json:"type"`
	Size  WireInt `json:"size"`
	MTime WireInt `json:"mtime"`
}

type FileList

type FileList struct {
	Data []FileEntry `json:"data"`
	Meta struct {
		NextCursor *string `json:"next_cursor"`
	} `json:"meta"`
	Raw json.RawMessage `json:"-"`
}

type LogLine

type LogLine struct {
	Timestamp *string `json:"timestamp"`
	Level     string  `json:"level"`
	Source    string  `json:"source"`
	Message   string  `json:"message"`
}

type LogList

type LogList struct {
	Data []LogLine `json:"data"`
	Meta struct {
		NextCursor *string `json:"next_cursor"`
	} `json:"meta"`
	Raw json.RawMessage `json:"-"`
}

type Me

type Me struct {
	Data struct {
		Account Account   `json:"account"`
		Token   TokenInfo `json:"token"`
	} `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type Operation

type Operation struct {
	ID       string `json:"id"`
	Type     string `json:"type"`
	Status   string `json:"status"`
	Resource *struct {
		Type string `json:"type"`
		ID   string `json:"id"`
	} `json:"resource"`
	Result    map[string]any `json:"result"`
	ErrorCode *string        `json:"error_code"`
	Retryable bool           `json:"retryable"`
	CreatedAt string         `json:"created_at"`
	UpdatedAt string         `json:"updated_at"`
}

type OperationEnvelope

type OperationEnvelope struct {
	Data       Operation       `json:"data"`
	Meta       map[string]any  `json:"meta"`
	Raw        json.RawMessage `json:"-"`
	RetryAfter string          `json:"-"`
}

type OperationList

type OperationList struct {
	Data []Operation     `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type Option

type Option func(*Client)

func WithHTTPClient

func WithHTTPClient(httpClient *http.Client) Option

func WithRequestID

func WithRequestID(requestID string) Option

func WithVersion

func WithVersion(version string) Option

func WithWarningSink

func WithWarningSink(sink func(string)) Option

type Server

type Server struct {
	ID       string `json:"id"`
	Name     string `json:"name"`
	Status   string `json:"status"`
	Region   string `json:"region"`
	Capacity struct {
		Cores             WireInt `json:"cores"`
		MemoryGB          WireInt `json:"memory_gb"`
		DiskGB            WireInt `json:"disk_gb"`
		DaemonCount       WireInt `json:"daemon_count"`
		EligibleForDaemon bool    `json:"eligible_for_daemon"`
	} `json:"capacity"`
	CreatedAt string `json:"created_at"`
	UpdatedAt string `json:"updated_at"`
}

type ServerEnvelope

type ServerEnvelope struct {
	Data Server          `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type ServerList

type ServerList struct {
	Data []Server        `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type SpawnRequest

type SpawnRequest struct {
	ServerID     string
	Name         string
	PrimaryAgent string
	DiskQuotaGB  int
}

type Task

type Task struct {
	ID                string         `json:"id"`
	DaemonID          string         `json:"daemon_id"`
	Agent             string         `json:"agent"`
	Model             *string        `json:"model"`
	PermissionMode    string         `json:"permission_mode"`
	WorkingDirectory  string         `json:"working_directory"`
	TimeoutSeconds    WireInt        `json:"timeout_seconds"`
	Status            string         `json:"status"`
	Result            map[string]any `json:"result"`
	ErrorCode         *string        `json:"error_code"`
	CancelRequestedAt *string        `json:"cancel_requested_at"`
	StartedAt         *string        `json:"started_at"`
	FinishedAt        *string        `json:"finished_at"`
	CreatedAt         string         `json:"created_at"`
	UpdatedAt         string         `json:"updated_at"`
}

Task is the Control Plane task resource returned by the nested /daemons/{daemon}/tasks routes. Tasks are always addressed through their parent daemon; there is no top-level task route.

type TaskEnvelope

type TaskEnvelope struct {
	Data Task            `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type TaskList

type TaskList struct {
	Data []Task          `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type TaskRequest

type TaskRequest struct {
	Prompt           string
	Agent            string
	Model            string
	PermissionMode   string
	WorkingDirectory string
	TimeoutSeconds   int
}

TaskRequest carries the fields POST /tasks accepts. Only Prompt is required; empty optional fields are omitted so the server applies its own defaults (primary agent, /workspace, yolo, default timeout).

type Ticket

type Ticket struct {
	Data struct {
		GatewayURL string   `json:"gateway_url"`
		Ticket     string   `json:"ticket"`
		ExpiresIn  WireInt  `json:"expires_in"`
		Protocol   WireInt  `json:"terminal_protocol"`
		Features   []string `json:"features"`
	} `json:"data"`
	Meta map[string]any `json:"meta"`
}

type TokenInfo

type TokenInfo struct {
	ID           string         `json:"id"`
	Name         string         `json:"name"`
	Scopes       []string       `json:"scopes"`
	Restrictions map[string]any `json:"restrictions"`
	ExpiresAt    string         `json:"expires_at"`
}

type UploadResponse

type UploadResponse struct {
	OK   bool   `json:"ok"`
	Path string `json:"path"`
}

type WireInt

type WireInt int64

WireInt is an integer-valued API number. Laravel models may serialize a decimal-backed value as either 4, 4.0, or "4.00", so response structs use this type at every numeric resource field while still rejecting fractions.

func (*WireInt) UnmarshalJSON

func (value *WireInt) UnmarshalJSON(raw []byte) error

Jump to

Keyboard shortcuts

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