client

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2026 License: Apache-2.0 Imports: 33 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"
)
View Source
const (
	SSHHostname = "ssh.daemons.run"
	SSHPort     = "2222"
)
View Source
const (
	// LockProtocolLabel is the HPKE info string and the WebSocket subprotocol.
	LockProtocolLabel = "dr.workspace-lock.v1"
	// LockChallengeDomain prefixes the guest's challenge signature input.
	LockChallengeDomain = "dr.workspace-lock.challenge.v1"
	// LockDeviceDomain prefixes a device proof signature input.
	LockDeviceDomain = "dr.workspace-lock.device.v1"

	// LockFrameLimit is the pre-parse cap on every protocol frame.
	LockFrameLimit = 16384
	// LockEnvelopeLimit bounds the {type,frame} envelope carrying a frame.
	LockEnvelopeLimit = 32768
	// LockChallengeLifetime is the guest's hard challenge deadline.
	LockChallengeLifetimeMs int64 = 30000
	// LockGrantLifetimeMs is the eight-hour device grant deadline. There is no
	// sliding refresh: a grant is never extended, only replaced by a new unlock.
	LockGrantLifetimeMs int64 = 8 * 60 * 60 * 1000
)
View Source
const (
	// DefaultWorkspaceRoot is the confined guest workspace served by the access
	// relay (gateway/daemon/access-runtime-v1.mjs createAccessRelayHooks).
	DefaultWorkspaceRoot = "/home/dr-agent/workspace"
	// LegacyWorkspaceRoot is the unconfined root older guests still report in an
	// upload receipt path. It is accepted, never preferred.
	LegacyWorkspaceRoot = "/root/workspace"
	// DefaultUploadFolder is the workspace-relative folder upload writes into.
	DefaultUploadFolder = "uploads"
	// WorkspaceRootVariable overrides the accepted guest workspace root.
	WorkspaceRootVariable = "DAEMONS_WORKSPACE_ROOT"
	// UploadFolderVariable overrides the workspace-relative upload folder.
	UploadFolderVariable = "DAEMONS_UPLOAD_FOLDER"
)
View Source
const ExitRevisionConflict = 9

ExitRevisionConflict marks an expected-revision mismatch. It is deliberately distinct from denial (5) and from an unknown outcome (8): the request was understood and refused because the workspace moved on.

View Source
const (
	// FilesProtocolLabel is the admitted files working-transport subprotocol.
	FilesProtocolLabel = "dr.workspace-files.v1"
)
View Source
const LockActionUnlock = "lock.unlock"

LockActionUnlock is the engineer's own unlock. It is one of the lock-channel actions this Control Plane admits; every other action in the contract is minted through the same route and is refused until the platform carries it.

Variables

View Source
var AdmittedLockActions = []string{
	LockActionUnlock,
	"lock.organization.enroll",
	"lock.organization.recover",
	"lock.organization.rotate",
	"lock.organization.replace",
	"lock.handoff",
}

AdmittedLockActions are the lock-channel actions the platform mints today. An action outside this set is a version gap and says so, rather than reporting a denial the user could act on; an action inside it that is refused is a real denial and keeps the Control Plane's own status.

View Source
var ErrLockIdentityOnly = errs.New("lock_identity_probe", "The lock exchange ended after the guest identity was read.", 1)

ErrLockIdentityOnly ends an exchange after the guest's signed challenge, with no request frame sent. Pairing uses it: the user compares the offered identity before this client has committed anything to it.

Functions

func GroupLockRecoveryPhrase added in v0.1.1

func GroupLockRecoveryPhrase(phrase LockRecoveryPhrase) string

GroupLockRecoveryPhrase renders the phrase in the contract's sixteen groups of four. It is display formatting only; the stored and compared value is the bare 64 hex characters.

func IsAPIError

func IsAPIError(err error, code string) bool

func IsLockDeviceChallenge added in v0.1.1

func IsLockDeviceChallenge(payload []byte) bool

IsLockDeviceChallenge recognises the guest's proof request without trusting its content: the envelope itself is validated where the proof is signed.

func LocalPayloadUnavailable added in v0.1.1

func LocalPayloadUnavailable() error

LocalPayloadUnavailable keeps an unwired lifecycle caller from substituting an ordinary file upload. E7 must explicitly integrate PutLocalPayload and GetLocalPayloadReceipt before removing its pre-create guard.

func LockChangeBody added in v0.1.1

func LockChangeBody(current, next LockSecret) (map[string]any, error)

LockChangeBody rotates the PIN. Both factors travel inside one sealed frame.

func LockConfirmBody added in v0.1.1

func LockConfirmBody(setupUUID, nonce string, phrase LockRecoveryPhrase) (map[string]any, error)

LockConfirmBody proves the client saved the phrase the guest displayed once.

func LockDenied added in v0.1.1

func LockDenied() error

LockDenied is the single bounded outcome this package reports. Detailed authentication outcomes stay inside the encrypted response; nothing here distinguishes a wrong PIN from a forged challenge to a network observer or to a log file.

func LockDeviceRequired added in v0.1.1

func LockDeviceRequired() error

LockDeviceRequired is the working-transport refusal when a protected workspace challenges a device that has no live grant.

func LockHandoffBody added in v0.1.1

func LockHandoffBody(secret LockSecret, phrase string, scope *LockHandoffScope, challenge LockChallenge) (map[string]any, error)

LockHandoffBody approves a reassignment with the engineer's own factor. Every scope field comes from the Control Plane's view of the operation that exists, never from the user, so the guest and the client bind the same reassignment.

func LockLockBody added in v0.1.1

func LockLockBody(device LockDeviceKey, sessionUUID string, challenge LockChallenge, secret LockSecret) (map[string]any, error)

LockLockBody relocks. Either a live device signature or a fresh PIN is accepted; the guest decides which it requires.

func LockRecoverBody added in v0.1.1

func LockRecoverBody(phrase LockRecoveryPhrase, next LockSecret) (map[string]any, error)

LockRecoverBody consumes the engineer recovery phrase and stages a new PIN.

func LockReplacementBody added in v0.1.1

func LockReplacementBody(secret LockSecret, phrase, confirmationNonce string, pending *LockReplacementPending) (map[string]any, error)

LockReplacementBody authorizes the Owner's pending organization key replacement. The rotation identity comes from the Control Plane and the confirmation code from the Owner directly, so both parties must agree before the guest accepts the engineer's factor.

func LockSetupBody added in v0.1.1

func LockSetupBody(secret LockSecret) (map[string]any, error)

LockSetupBody begins enrollment. The guest generates the recovery phrase; the client never chooses or transports it.

func LockStatusBody added in v0.1.1

func LockStatusBody(device LockDeviceKey, sessionUUID string, challenge LockChallenge) (map[string]any, error)

LockStatusBody asks for enrollment and lock state. It carries no secret; the device signature inside the sealed frame is the only authority it presents.

func LockUnlockBody added in v0.1.1

func LockUnlockBody(secret LockSecret) (map[string]any, error)

LockUnlockBody is the encrypted body of lock.unlock.

func NewLockOperationID added in v0.1.1

func NewLockOperationID() string

NewLockOperationID mints the operation identity that binds a lock exchange end to end: the ticket, the signed challenge, the sealed body and the response all carry it, and a rotation's confirm step reuses it.

func NewUploadOperationID added in v0.1.1

func NewUploadOperationID() string

NewUploadOperationID mints the operation identity a caller must persist before an upload, so an ambiguous outcome stays resolvable by receipt.

func NormalizeBaseURL

func NormalizeBaseURL(value string) (string, error)

func ReadLockDecisionResult added in v0.1.1

func ReadLockDecisionResult(result map[string]any, action string) error

ReadLockDecisionResult validates a decision response before the caller reports anything. A sealed refusal is a refusal: `denied` never reads as success, and an outcome the guest did not name is treated as one.

func ReadLockStatusResult added in v0.1.1

func ReadLockStatusResult(result map[string]any) map[string]any

ReadLockStatusResult reduces the guest's status reply to the bounded fields the CLI may show. It never surfaces a verifier, a hash, a phrase or another device's identifiers, and an unrecognised shape reports unknown rather than guessing.

func RejectGatewayRedirect added in v0.1.1

func RejectGatewayRedirect(_ *http.Request, _ []*http.Request) error

func SignLockDeviceProof added in v0.1.1

func SignLockDeviceProof(device LockDeviceKey, sessionUUID string, challenge LockChallenge) (map[string]any, error)

SignLockDeviceProof signs an already verified challenge with the device key.

func ValidRepositoryBranch added in v0.1.1

func ValidRepositoryBranch(branch string) bool

Types

type AccessTicket added in v0.1.1

type AccessTicket struct {
	Data struct {
		Ticket      string             `json:"ticket"`
		Version     int                `json:"ticket_version"`
		ExpiresIn   WireInt            `json:"expires_in"`
		Method      string             `json:"method"`
		GatewayPath string             `json:"gateway_path"`
		Protocol    string             `json:"websocket_protocol"`
		Target      LocalPayloadTarget `json:"target"`
	} `json:"data"`
	Meta map[string]any `json:"meta"`
}

type Account

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

type BulkEnvelope added in v0.1.1

type BulkEnvelope struct {
	Data struct {
		Outcomes []BulkOutcome `json:"outcomes"`
	} `json:"data"`
	Meta map[string]any  `json:"meta"`
	Raw  json.RawMessage `json:"-"`
}

type BulkOutcome added in v0.1.1

type BulkOutcome struct {
	DaemonID    string  `json:"daemon_id"`
	OperationID *string `json:"operation_id"`
	Status      string  `json:"status"`
	Code        *string `json:"code"`
}

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) AccessContent added in v0.1.1

func (c *Client) AccessContent(ctx context.Context, daemonID, operationID, action string, source io.Reader, destination io.Writer) error

AccessContent obtains one v2 ticket, then streams once to the fixed edge path.

func (*Client) AccessRepositoryPrepare added in v0.1.1

func (c *Client) AccessRepositoryPrepare(ctx context.Context, daemonID, repositoryID, operationID string, source io.Reader, destination io.Writer) error

AccessRepositoryPrepare binds a repository resource without putting branch selectors in central metadata. It performs one guest request, never a retry.

func (*Client) AddSSHKey added in v0.1.1

func (c *Client) AddSSHKey(ctx context.Context, daemon, key, idem string) (OperationEnvelope, error)

func (*Client) BulkDaemons added in v0.1.1

func (c *Client) BulkDaemons(ctx context.Context, action string, ids []string, key string) (BulkEnvelope, 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) DisableSSH added in v0.1.1

func (c *Client) DisableSSH(ctx context.Context, daemon, idem string) (OperationEnvelope, error)

func (*Client) DownloadFile added in v0.1.1

func (c *Client) DownloadFile(ctx context.Context, daemonID, workspacePath string, destination io.Writer) error

DownloadFile keeps the path in the guest stream and copies bytes with bounded memory.

func (*Client) ExchangeWorkspaceLock added in v0.1.1

func (c *Client) ExchangeWorkspaceLock(ctx context.Context, daemonID, operationID, action string, prepare LockPreparer) (map[string]any, error)

ExchangeWorkspaceLock runs the finite three-message lock exchange: the guest's signed challenge, one sealed request, one sealed response. It cannot select a command, a file or a port, and it is the only exception admitted while a workspace is locked.

func (*Client) GatewayHTTPClient added in v0.1.1

func (c *Client) GatewayHTTPClient() *http.Client

GatewayHTTPClient preserves configured TLS trust but never cookies, redirects, or a global response timeout for a lease-governed stream.

func (*Client) GatewayURL added in v0.1.1

func (c *Client) GatewayURL() string

func (*Client) GetLocalPayloadReceipt added in v0.1.1

func (c *Client) GetLocalPayloadReceipt(ctx context.Context, daemonID, operationID string) (LocalPayloadReceipt, error)

GetLocalPayloadReceipt obtains fresh authority after an ambiguous upload.

func (*Client) GetUploadReceipt added in v0.1.1

func (c *Client) GetUploadReceipt(ctx context.Context, daemonID, operationID string) (UploadReceipt, error)

GetUploadReceipt obtains fresh read authority, never retries or recovers a write.

func (*Client) LifecycleDaemon

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

func (*Client) LifecycleDaemonWithOptions added in v0.1.1

func (c *Client) LifecycleDaemonWithOptions(ctx context.Context, daemonID, action, etag, idempotencyKey string, body map[string]any) (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) ListRepositoryPushes added in v0.1.1

func (c *Client) ListRepositoryPushes(ctx context.Context, daemonID, cursor string) (RepositoryPushList, error)

ListRepositoryPushes reads one bounded metadata page. It never requests local summaries, credentials or an approval operation.

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) LockExchanges added in v0.1.1

func (c *Client) LockExchanges(ctx context.Context, daemonID string) (LockExchangeView, error)

LockExchanges reads what this actor may open. It authorizes nothing: the guest still refuses any scope that does not match its own pending record.

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) MintAccessTicket added in v0.1.1

func (c *Client) MintAccessTicket(ctx context.Context, daemonID, operationID, action string) (AccessTicket, error)

MintAccessTicket sends only public identifiers and a closed action name.

func (*Client) MintLockTicket added in v0.1.1

func (c *Client) MintLockTicket(ctx context.Context, daemonID, operationID, action string) (LockTicket, error)

MintLockTicket admits one lock exchange. The action is closed and the options carry only the protocol version.

func (*Client) MintTicket

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

func (*Client) MutateOperation added in v0.1.1

func (c *Client) MutateOperation(ctx context.Context, id, action, key string) (OperationEnvelope, 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) PutLocalPayload added in v0.1.1

func (c *Client) PutLocalPayload(ctx context.Context, daemonID, operationID string, source io.Reader) (LocalPayloadReceipt, error)

PutLocalPayload streams the E4 envelope once. An interrupted upload must be resolved with LocalPayloadReceipt, not replayed as a file upload or CP mutation.

func (*Client) ReadWorkspaceLockIdentity added in v0.1.1

func (c *Client) ReadWorkspaceLockIdentity(ctx context.Context, daemonID, operationID string, nowMs int64) (LockChallenge, error)

ReadWorkspaceLockIdentity opens a lock channel only far enough to read and structurally validate the guest's signed challenge. No secret, no device key and no request frame leave this process.

func (*Client) RelayContent added in v0.1.1

func (c *Client) RelayContent(ctx context.Context, gateway, ticket string, source io.Reader, destination io.Writer) error

RelayContent transfers directly to the admitted gateway, not the control-plane API. The caller supplies a fresh single-use ticket and owns the input stream. An uncertain write is never retried; recover through a fresh receipt ticket.

func (*Client) RemoveSSHKey added in v0.1.1

func (c *Client) RemoveSSHKey(ctx context.Context, daemon, key, idem string) (OperationEnvelope, error)

func (*Client) RenameDaemon added in v0.1.1

func (c *Client) RenameDaemon(ctx context.Context, daemonID, name, etag, key string) (DaemonEnvelope, error)

func (*Client) RequestRepositoryPush added in v0.1.1

func (c *Client) RequestRepositoryPush(ctx context.Context, daemonID, repositoryID, branch string) (RepositoryPushPrepared, error)

RequestRepositoryPush sends selectors only to the guest and never retries. A malformed acknowledgement may follow successful publication, so it is ambiguous.

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) SSH added in v0.1.1

func (c *Client) SSH(ctx context.Context, daemon string) (SSHEnvelope, error)

func (*Client) SSHTicket added in v0.1.1

func (c *Client) SSHTicket(ctx context.Context, daemon string) (SSHTicket, error)

func (*Client) SetWorkingProof added in v0.1.1

func (c *Client) SetWorkingProof(proof WorkingProof)

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)

func (*Client) UploadOperation added in v0.1.1

func (c *Client) UploadOperation(ctx context.Context, daemonID, operationID string, paths WorkspacePaths, filename string, file *os.File) (UploadResponse, error)

UploadOperation streams one file under a caller-supplied operation identity. The identity is deliberately an input: the caller records it locally before the request so an interrupted transfer can be resolved without replaying it.

func (*Client) UploadRecoverable added in v0.1.1

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

UploadRecoverable reports whether this Control Plane serves uploads through workspace access, where an operation identity makes an ambiguous outcome resolvable by receipt. Callers stage an identity only when it is true.

func (*Client) ValidateGatewayURL added in v0.1.1

func (c *Client) ValidateGatewayURL(value string) error

ValidateGatewayURL binds a ticket destination to the configured control-plane authority. Tickets remain opaque and are never placed in a URL. SSH tickets may use the DNS-only host ssh.daemons.run:2222; content relay stays on the API host.

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:"-"`
	Size      string `json:"size,omitempty"`
	Variant   string `json:"variant,omitempty"`
	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"`
		UserCode        string  `json:"user_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 LocalPayloadReceipt added in v0.1.1

type LocalPayloadReceipt struct {
	LocalPayloadTarget
	PayloadID   string  `json:"payload_id"`
	OperationID string  `json:"operation_id"`
	Revision    int64   `json:"revision"`
	Phase       string  `json:"phase"`
	ErrorCode   *string `json:"error_code"`
}

type LocalPayloadTarget added in v0.1.1

type LocalPayloadTarget struct {
	OrganizationID       string `json:"organization_id"`
	WorkspaceID          string `json:"workspace_id"`
	RuntimeGeneration    int64  `json:"runtime_generation"`
	AssignmentGeneration int64  `json:"assignment_generation"`
}

type LockChallenge added in v0.1.1

type LockChallenge struct {
	Canonical string

	ChallengeUUID    string
	OrganizationUUID string
	WorkspaceUUID    string
	BootUUID         string
	LeaseUUID        string
	OperationUUID    string
	ActorSubjectUUID string
	MembershipUUID   string
	ResourceUUID     string

	AssignmentGeneration    int64
	LockEpoch               int64
	CredentialRevision      int64
	AuthorityEpoch          int64
	PolicyRevision          int64
	OrganizationKeyRevision int64
	HoldRevision            int64

	Action    string
	ExpiresAt int64

	IdentityPublicKey  string
	RecipientPublicKey string
	// contains filtered or unexported fields
}

LockChallenge is the verified guest challenge. Its Canonical field is the exact bytes the guest signed and the exact AAD for the sealed request.

func ParseLockChallenge added in v0.1.1

func ParseLockChallenge(text string) (LockChallenge, []byte, error)

ParseLockChallenge validates the signed envelope's shape without trusting its contents. The signature is checked by VerifyLockChallenge.

func VerifyLockChallenge added in v0.1.1

func VerifyLockChallenge(text string, options VerifyLockChallengeOptions) (LockChallenge, error)

VerifyLockChallenge proves the challenge came from the pinned guest and binds every authority field the caller already knows before any secret is prepared for it.

func (LockChallenge) IdentityPin added in v0.1.1

func (c LockChallenge) IdentityPin() string

IdentityPin is the SHA-256 of the raw 65-byte SEC1 identity public key, in lowercase hex. It is public material: it is the value a client pins.

type LockDeviceAuthority added in v0.1.1

type LockDeviceAuthority struct {
	Device               LockDeviceKey
	SessionUUID          string
	IdentityPin          string
	OrganizationUUID     string
	WorkspaceUUID        string
	BootUUID             string
	ActorSubjectUUID     string
	MembershipUUID       string
	AssignmentGeneration int64
	LockEpoch            int64
	CredentialRevision   int64
	ExpiresAtMs          int64
}

LockDeviceAuthority is a live grant a working transport may prove with. It is built from the stored grant, never from a challenge: a guest cannot supply the device key it will be compared against.

func (LockDeviceAuthority) Live added in v0.1.1

func (a LockDeviceAuthority) Live(nowMs int64) bool

Live reports whether the eight-hour deadline still holds. It is checked again immediately before every signature, not only when the grant is loaded.

func (LockDeviceAuthority) Prove added in v0.1.1

func (a LockDeviceAuthority) Prove(frame, action, resourceUUID string, nowMs int64) (map[string]any, error)

Prove verifies a working-transport challenge against this grant and returns the exactly-three-field proof. Every authority field the guest signed must equal the one the grant was issued under: a new boot, a new lock epoch, a changed credential revision or a different assignment all fail closed.

func (LockDeviceAuthority) RespondToLockDeviceChallenge added in v0.1.1

func (a LockDeviceAuthority) RespondToLockDeviceChallenge(envelopeText, action, resourceUUID string, nowMs int64) (string, error)

RespondToLockDeviceChallenge turns the gateway's lock_device_challenge envelope into the lock_device_proof envelope a working transport sends back. The proof carries no device public key: the guest compares the signature against the key it already holds for this session.

func (LockDeviceAuthority) Scope added in v0.1.1

func (a LockDeviceAuthority) Scope(action, resourceUUID string) LockScope

Scope describes what this authority may be asked to prove for one action.

type LockDeviceKey added in v0.1.1

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

LockDeviceKey is a client-held P-256 signing key. It is the device: a cookie, a hostname or a user agent is not.

func LockDeviceKeyFromScalar added in v0.1.1

func LockDeviceKeyFromScalar(scalar []byte) (LockDeviceKey, error)

LockDeviceKeyFromScalar rebuilds a stored device key. The scalar is the only private value the CLI persists, and only for the grant's lifetime.

func NewLockDeviceKey added in v0.1.1

func NewLockDeviceKey() (LockDeviceKey, error)

NewLockDeviceKey generates a fresh device key from the system CSPRNG.

func (LockDeviceKey) PublicKey added in v0.1.1

func (k LockDeviceKey) PublicKey() string

PublicKey is the uncompressed SEC1 point, unpadded base64url.

func (LockDeviceKey) Scalar added in v0.1.1

func (k LockDeviceKey) Scalar() []byte

Scalar returns the private scalar for the device cache. Callers must not log it, print it or send it anywhere.

func (LockDeviceKey) Valid added in v0.1.1

func (k LockDeviceKey) Valid() bool

Valid reports whether this key can sign.

type LockDeviceProof added in v0.1.1

type LockDeviceProof struct {
	ChallengeUUID     string `json:"challenge_uuid"`
	DeviceSessionUUID string `json:"device_session_uuid"`
	Signature         string `json:"signature"`
}

LockDeviceProof is exactly the three fields the guest accepts. Nothing else travels: no device public key a guest could be tricked into adopting.

type LockExchange added in v0.1.1

type LockExchange struct {
	Challenge LockChallenge
	Frame     string
	// contains filtered or unexported fields
}

LockExchange is one sealed request and the exactly-one response it may open.

func SealLockRequest added in v0.1.1

func SealLockRequest(challenge LockChallenge, device LockDeviceKey, body map[string]any) (*LockExchange, error)

SealLockRequest encrypts one request to the verified guest. body carries the action-specific fields; operation_uuid, action and device_public_key are supplied here so a caller cannot accidentally unbind them from the challenge.

func (*LockExchange) Open added in v0.1.1

func (e *LockExchange) Open(text string) (map[string]any, error)

Open decrypts the guest's single response. A second call is refused: the AEAD nonce is used exactly once and a duplicate reply is never opened.

type LockExchangeView added in v0.1.1

type LockExchangeView struct {
	Data struct {
		Version       int    `json:"version"`
		WorkspaceUUID string `json:"workspace_uuid"`
		Lock          struct {
			State      string  `json:"state"`
			ObservedAt *string `json:"observed_at"`
			Revision   *int64  `json:"revision"`
		} `json:"lock"`
		Actor struct {
			IsOwner    bool `json:"is_owner"`
			IsAssignee bool `json:"is_assignee"`
		} `json:"actor"`
		Handoff     *LockHandoffScope       `json:"handoff"`
		Replacement *LockReplacementPending `json:"replacement"`
	} `json:"data"`
	Meta map[string]any `json:"meta"`
}

LockExchangeView is the Control Plane's read-only description of the lock exchanges this actor may open. It carries bindings the client must reproduce exactly, never a secret: the Owner's confirmation nonce is deliberately absent, because the Owner gives it to the engineer directly.

type LockHandoffScope added in v0.1.1

type LockHandoffScope struct {
	OperationUUID           string  `json:"operation_uuid"`
	SuccessorMembershipUUID *string `json:"successor_membership_uuid"`
	OldAssignmentGeneration int64   `json:"old_assignment_generation"`
	NewAssignmentGeneration int64   `json:"new_assignment_generation"`
	OldPlacementGeneration  int64   `json:"old_placement_generation"`
	NewPlacementGeneration  int64   `json:"new_placement_generation"`
	PreserveData            bool    `json:"preserve_data"`
	ApprovalRecorded        bool    `json:"approval_recorded"`
}

LockHandoffScope is the reassignment the engineer would be approving. Every field is signed into the guest request, so a scope the platform did not issue cannot be substituted for one it did.

type LockPreparer added in v0.1.1

type LockPreparer func(challengeFrame string) (*LockExchange, error)

LockPreparer receives the guest's signed challenge frame and returns the sealed request. Verification, pinning and the secret all live inside it: this transport never sees a plaintext.

type LockRecoveryPhrase added in v0.1.1

type LockRecoveryPhrase string

LockRecoveryPhrase is the 64 hex character engineer phrase. Hyphens and ASCII spaces are removed on entry; every other malformed input is refused.

func NormalizeLockRecoveryPhrase added in v0.1.1

func NormalizeLockRecoveryPhrase(value string) (LockRecoveryPhrase, error)

NormalizeLockRecoveryPhrase strips the display grouping only.

type LockReplacementPending added in v0.1.1

type LockReplacementPending struct {
	RotationUUID            string `json:"rotation_uuid"`
	ExpectedKeyRevision     int64  `json:"expected_key_revision"`
	NewKeyRevision          int64  `json:"new_key_revision"`
	ConfirmationNonceNeeded bool   `json:"confirmation_nonce_required"`
}

LockReplacementPending names the organization key replacement waiting on this engineer. The confirmation nonce is not here and never will be.

type LockRotationResult added in v0.1.1

type LockRotationResult struct {
	SetupUUID         string
	ConfirmationNonce string
	Phrase            LockRecoveryPhrase
}

LockRotationResult is the guest's pending setup, change or recover step. The phrase is guest-generated and is displayed exactly once.

func ReadLockRotationResult added in v0.1.1

func ReadLockRotationResult(result map[string]any) (LockRotationResult, error)

ReadLockRotationResult validates the pending rotation the guest staged. It deliberately requires the exact field set: a response that carried anything else is refused rather than partially believed.

type LockScope added in v0.1.1

type LockScope struct {
	OrganizationUUID     string
	WorkspaceUUID        string
	AssignmentGeneration int64
	Action               string
	ResourceUUID         string
}

LockScope is what the caller already believes about this workspace. Every field present is compared to the challenge before the pin is even consulted.

type LockSecret added in v0.1.1

type LockSecret string

LockSecret is a PIN held only in memory. It is never written to disk, never placed in a flag or environment variable and never echoed.

func (LockSecret) Valid added in v0.1.1

func (s LockSecret) Valid() bool

Valid reports whether the secret matches the frozen four-or-six ASCII digit policy, including leading zeroes. No trimming, padding or Unicode digit conversion happens anywhere in this package.

type LockTicket added in v0.1.1

type LockTicket struct {
	Data struct {
		Ticket      string  `json:"ticket"`
		Version     int     `json:"ticket_version"`
		ExpiresIn   WireInt `json:"expires_in"`
		Method      string  `json:"method"`
		GatewayPath string  `json:"gateway_path"`
		Protocol    string  `json:"websocket_protocol"`
	} `json:"data"`
	Meta map[string]any `json:"meta"`
}

LockTicket is the Control Plane's lock admission response.

type LockUnlockResult added in v0.1.1

type LockUnlockResult struct {
	Outcome           string
	DeviceSessionUUID string
	ExpiresAtMs       int64
	Reason            string
}

LockUnlockResult is the bounded outcome of lock.unlock.

func ReadLockUnlockResult added in v0.1.1

func ReadLockUnlockResult(result map[string]any, nowMs int64) (LockUnlockResult, error)

ReadLockUnlockResult validates the guest's response shape and its expiry bound. An eight-hour deadline is a maximum, never a renewal.

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 {
	UUID       string  `json:"uuid,omitempty"`
	State      string  `json:"state,omitempty"`
	Phase      string  `json:"phase,omitempty"`
	DaemonID   string  `json:"daemon_id,omitempty"`
	ReasonCode *string `json:"reason_code,omitempty"`
	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"`
}

func (*Operation) UnmarshalJSON added in v0.1.1

func (operation *Operation) UnmarshalJSON(raw []byte) error

UnmarshalJSON accepts both the lifecycle projection and older task operations. Raw envelopes retain the exact wire document for JSON output.

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 RepositoryPush added in v0.1.1

type RepositoryPush struct {
	RequestUUID         string  `json:"request_uuid"`
	AssignedSubjectUUID string  `json:"assigned_subject_uuid"`
	RepositoryUUID      string  `json:"repository_uuid"`
	PolicyRevisionUUID  string  `json:"policy_revision_uuid"`
	State               string  `json:"state"`
	Version             int64   `json:"version"`
	StatsStatus         string  `json:"stats_status"`
	CommitCount         *int64  `json:"commit_count"`
	FilesChanged        *int64  `json:"files_changed"`
	Insertions          *int64  `json:"insertions"`
	Deletions           *int64  `json:"deletions"`
	RequestedAt         string  `json:"requested_at"`
	ExpiresAt           string  `json:"expires_at"`
	DecidedAt           *string `json:"decided_at"`
	ApprovedUntil       *string `json:"approved_until"`
	ConsumedAt          *string `json:"consumed_at"`
	CompletedAt         *string `json:"completed_at"`
	OutcomeCode         *string `json:"outcome_code"`
}

type RepositoryPushList added in v0.1.1

type RepositoryPushList struct {
	Data       []RepositoryPush `json:"data"`
	NextCursor *string          `json:"next_cursor"`
	Raw        json.RawMessage  `json:"-"`
}

type RepositoryPushPrepared added in v0.1.1

type RepositoryPushPrepared struct {
	RequestUUID string `json:"request_uuid"`
	State       string `json:"state"`
}

type SSHAccess added in v0.1.1

type SSHAccess struct {
	Enabled            bool     `json:"enabled"`
	Reconciled         bool     `json:"reconciled"`
	HostKey            string   `json:"host_key"`
	HostKeyFingerprint string   `json:"host_key_fingerprint"`
	Keys               []SSHKey `json:"keys"`
}

SSHAccess is deliberately a public-only export. It never contains a ticket or private key material.

type SSHEnvelope added in v0.1.1

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

type SSHKey added in v0.1.1

type SSHKey struct {
	ID          string `json:"id"`
	Fingerprint string `json:"fingerprint"`
	PublicKey   string `json:"public_key"`
}

type SSHTicket added in v0.1.1

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

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
	Size            string
	Variant         string
	Source          string
	AssignedUserID  string
	CreationTeamID  string
	TeamID          string
	AcceptedOfferID string
}

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 a workspace-local task resource. V2 task queries transfer directly through the admitted gateway; only legacy servers use the nested API routes.

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 UploadReceipt added in v0.1.1

type UploadReceipt struct {
	Status string `json:"status"`
	Path   string `json:"path,omitempty"`
	Bytes  int64  `json:"bytes,omitempty"`
	SHA256 string `json:"sha256,omitempty"`
}

type UploadResponse

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

type VerifyLockChallengeOptions added in v0.1.1

type VerifyLockChallengeOptions struct {
	IdentityPin string
	Scope       LockScope
	NowMs       int64
}

VerifyLockChallengeOptions carries what the caller must already know. No implicit pairing happens here: an empty IdentityPin is refused, and the caller decides separately whether a first, disclosed bootstrap is allowed.

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

type WorkingProof added in v0.1.1

type WorkingProof func(action string) (func(envelope string) (string, error), error)

WorkingProof returns the callback that answers one guest lock_device_challenge for a working-transport action. It is nil when this device holds no grant.

type WorkspacePaths added in v0.1.1

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

WorkspacePaths carries the guest-side layout the CLI is willing to accept. Nothing here is sent to the Control Plane: it only decides which local input is safe to turn into a selector and which returned path may be printed.

func DefaultWorkspacePaths added in v0.1.1

func DefaultWorkspacePaths() WorkspacePaths

DefaultWorkspacePaths prefers the confined root and still accepts the legacy one so an older guest's receipt path is not rejected as unsafe.

func NewWorkspacePaths added in v0.1.1

func NewWorkspacePaths(environment map[string]string) (WorkspacePaths, error)

NewWorkspacePaths reads the optional overrides. An explicit root replaces the accepted set entirely, so a deployment cannot silently keep the legacy root.

func (WorkspacePaths) Normalize added in v0.1.1

func (p WorkspacePaths) Normalize(value string) (string, error)

Normalize accepts the relative API form and any accepted absolute root, and returns the relative workspace path the guest expects.

func (WorkspacePaths) Root added in v0.1.1

func (p WorkspacePaths) Root() string

Root is the workspace root the CLI prefers when it has to name one.

func (WorkspacePaths) Roots added in v0.1.1

func (p WorkspacePaths) Roots() []string

Roots lists every accepted absolute root, preferred first.

func (WorkspacePaths) SafeUploadPath added in v0.1.1

func (p WorkspacePaths) SafeUploadPath(value string) bool

SafeUploadPath checks a path the guest returned. It must be clean, absolute below an accepted root, and inside the configured upload folder.

func (WorkspacePaths) UploadFolder added in v0.1.1

func (p WorkspacePaths) UploadFolder() string

UploadFolder is the workspace-relative folder, without a trailing separator.

func (WorkspacePaths) UploadSelector added in v0.1.1

func (p WorkspacePaths) UploadSelector(filename string) (string, error)

UploadSelector builds the single guest selector path for an upload. The server requires a basename, so a filename carrying a separator is refused locally and never sent.

Jump to

Keyboard shortcuts

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