daemonclient

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 19, 2026 License: AGPL-3.0 Imports: 21 Imported by: 0

Documentation

Overview

Package hubclient is the canonical Go client for talking to clankd's Hub HTTP API. The TUI, the clank CLI, and any external Go-based clients import this package.

The socket path and PID-file helpers (SocketPath, PIDPath, IsRunning) also live here and resolve to "hub.sock" / "hub.pid" inside ~/.clank.

API shape (per hub_host_refactor_code_review.md §7.7):

c.Host(hostname).Repos(ctx)
c.Host(hostname).Repo(gitRef).Branches(ctx)
c.Host(hostname).Repo(gitRef).Worktree(branch).Resolve(ctx)
c.Host(hostname).Repo(gitRef).Worktree(branch).Remove(ctx, force)
c.Host(hostname).Repo(gitRef).Worktree(branch).Merge(ctx, msg)
c.Backend(backend).Agents(ctx, projectDir)
c.Backend(backend).Models(ctx, projectDir)
c.Sessions().Create(ctx, req)
c.Sessions().List(ctx)
c.Sessions().Search(ctx, params)
c.Sessions().Subscribe(ctx)
c.Sessions().Discover(ctx, projectDir)
c.Session(id).Get(ctx)
c.Session(id).Messages(ctx)
c.Session(id).Send(ctx, opts)
c.Session(id).Abort(ctx) ... etc.

Decision: hub-level Backend(backend) is flat, not host-scoped, because the hub multiplexes hosts and picks the host internally for these queries. Decision: Session(id).Get(ctx) lives on the id-bound handle (not on Sessions()) for symmetry with all other id-bound ops.

Index

Constants

This section is empty.

Variables

View Source
var ErrGitHubUnknownFlow = errors.New("github: unknown flow id")

ErrGitHubUnknownFlow corresponds to the gateway's 404 unknown_flow.

View Source
var ErrNotPreviewable = errors.New("preview: project is not previewable")

ErrNotPreviewable is retained for compatibility with older hosts that returned no_preview before launch configuration setup was supported.

View Source
var ErrPreviewSetupRequired = errors.New("preview: launch setup is required")

ErrPreviewSetupRequired classifies a missing web launch configuration.

Functions

func EnsureFreshActiveRemote

func EnsureFreshActiveRemote(ctx context.Context) error

EnsureFreshActiveRemote refreshes the active remote's OAuth tokens when the access_token is within refreshGracePeriod of expiry and a refresh_token is available. No-op for static-bearer profiles, for profiles without an expires_at, or when the token is still fresh.

Returns cloud.ErrUnauthorized (wrapped) when the IdP rejects the refresh — callers should surface "run `clank login`". Returns other errors for transient failures (network, gateway 5xx); callers decide whether to abort or proceed with the stale token.

func IsRunning

func IsRunning() (bool, int, error)

IsRunning checks if clankd is already running by reading the PID file and verifying the process exists. Cleans up stale PID and socket files when the recorded process is gone.

func PIDPath

func PIDPath() (string, error)

PIDPath returns the PID file path for clankd.

func SocketPath

func SocketPath() (string, error)

SocketPath returns the Unix socket path for clankd's Hub API.

func WriteRemoteSession

func WriteRemoteSession(name string, s *cloud.Session) error

WriteRemoteSession persists an OAuth grant onto the named remote in preferences.json. Creates the remote entry if it's somehow missing (UpdatePreferences runs against the latest disk version which a concurrent edit could have changed since the caller loaded prefs).

Used by `clank login` after a fresh sign-in and by EnsureFreshActiveRemote after a successful refresh. Some IdPs rotate refresh tokens; the existing token is preserved when the response omits one (the spec allows that, RFC 6749 §6).

Types

type APIError

type APIError struct {
	StatusCode        int
	Code              string
	Message           string
	SetupPrompt       string
	ProjectConfigPath string
}

APIError is a structured error response from the daemon/gateway — the {code, error} JSON body every hostmux error path writes. Error() keeps the historical "daemon: <message>" shape; Code carries the machine-readable classification (e.g. "no_preview") for errors.As callers that need to branch on the kind rather than the prose.

func (*APIError) Error

func (e *APIError) Error() string

type BackendClient

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

BackendClient is bound to a backend type. Backend selection on the wire is flat at the hub level — the hub picks the host internally.

func (*BackendClient) Agents

func (b *BackendClient) Agents(ctx context.Context, hostname string, ref agent.GitRef) ([]agent.AgentInfo, error)

Agents returns available agents for this backend, scoped to the (hostname, gitRef) tuple. Per §7.3, paths never cross the wire — the host resolves ref→workdir internally. The three discrete GitRef fields are sent verbatim so the hub mux can reconstruct the struct without canonical-form parsing.

func (*BackendClient) ConfigOptions

func (b *BackendClient) ConfigOptions(ctx context.Context, hostname string, ref agent.GitRef) ([]agent.ConfigOption, error)

ConfigOptions returns the agent's live advertised config options for this backend in ref's project, probed on demand by the host (one short-lived session). Slow by design — call it when a knob editor opens, behind a spinner, never on a hot path.

func (*BackendClient) Presets

func (b *BackendClient) Presets(ctx context.Context, hostname string) ([]presets.Preset, error)

Presets returns the host's agent presets for this backend — built-ins (provisioner-declared) first, then user-saved ones. The Default preset's config keys double as the create-time required keys, so compose flows start from it.

type BridgeBind

type BridgeBind struct {
	IP     string `json:"ip"`
	Reason string `json:"reason"`
	Err    string `json:"err,omitempty"`
}

BridgeBind is one address the bridge listener policy wanted, and how the bind went ("" = serving).

type BridgeClient

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

BridgeClient is the local-CLI handle for the daemon's laptop↔phone bridge (`clank pair`, `clank preview`'s QR building). Admin routes are unix-socket only — the daemon never mounts them on TCP.

func (*BridgeClient) PairComplete

func (b *BridgeClient) PairComplete(ctx context.Context, code string) (string, error)

PairComplete submits the code the laptop user typed, approving the matching pending attempt. Returns the paired device name; a code that matches no waiting phone surfaces as an error (the transport maps the 400 body's message).

func (*BridgeClient) PairPoll

func (b *BridgeClient) PairPoll(ctx context.Context) ([]string, error)

PairPoll leases the pairing window open (the CLI calls it each tick while showing the QR) and returns the device names of phones waiting for the laptop user to type their code.

func (*BridgeClient) RevokeAllDevices

func (b *BridgeClient) RevokeAllDevices(ctx context.Context) (*BridgeStatus, error)

RevokeAllDevices removes every approved phone. The host key stays — returning phones still recognize the laptop, they just re-pair.

func (*BridgeClient) RevokeDevice

func (b *BridgeClient) RevokeDevice(ctx context.Context, pubkey string) (*BridgeStatus, error)

RevokeDevice removes one approved phone by its public key.

func (*BridgeClient) Status

func (b *BridgeClient) Status(ctx context.Context) (*BridgeStatus, error)

Status fetches (and freshly re-discovers) the bridge state.

func (*BridgeClient) TrustNetwork

func (b *BridgeClient) TrustNetwork(ctx context.Context, fingerprint, label string) (*BridgeStatus, error)

TrustNetwork records LAN consent for the fingerprinted network and re-binds accordingly.

type BridgeDevice

type BridgeDevice struct {
	PubKey   string     `json:"pubkey"`
	Name     string     `json:"name"`
	AddedAt  time.Time  `json:"added_at"`
	LastSeen *time.Time `json:"last_seen,omitempty"`
}

BridgeDevice is one approved phone in the daemon's registry.

type BridgeNetwork

type BridgeNetwork struct {
	Fingerprint string `json:"fingerprint,omitempty"`
	Label       string `json:"label,omitempty"`
}

BridgeNetwork identifies the current LAN for per-network trust.

type BridgeStatus

type BridgeStatus struct {
	Port           int            `json:"port"`
	Binds          []BridgeBind   `json:"binds"`
	Tailnet        *BridgeTailnet `json:"tailnet,omitempty"`
	LANIP          string         `json:"lan_ip,omitempty"`
	Network        BridgeNetwork  `json:"network"`
	NetworkTrusted bool           `json:"network_trusted"`
	HostKey        string         `json:"host_key"`
	Devices        []BridgeDevice `json:"devices"`
	URLs           []string       `json:"urls"`
	// Most recent authenticated connection this daemon run — the CLI
	// waits on this to clear the QR and name the phone.
	LastDevice      string     `json:"last_device,omitempty"`
	LastConnectedAt *time.Time `json:"last_connected_at,omitempty"`
}

BridgeStatus is the admin status payload — all public: HostKey is the laptop's identity public key (the QR's hk param), Devices the approved registry, URLs the phone-reachable base URLs, best-first, empty when nothing beyond loopback is bound — the CLI's cue to run the trust-LAN prompt.

type BridgeTailnet

type BridgeTailnet struct {
	IP      string `json:"ip"`
	DNSName string `json:"dns_name,omitempty"`
}

BridgeTailnet mirrors the daemon's tailnet discovery.

type Client

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

Client communicates with clankd's Hub API over either a Unix socket (local) or TCP+bearer (remote). Wire protocol is identical; only transport and auth differ.

func NewClient

func NewClient(sockPath string) *Client

NewClient connects to a local clankd via Unix socket. Use NewTCPClient for remote. No overall Timeout — long-poll/SSE rely on caller ctx.

func NewDefaultClient

func NewDefaultClient() (*Client, error)

NewDefaultClient returns the laptop's local Unix-socket client. The laptop is the single source of transport — `clank` talks only to the local daemon, which proxies per-session ops to the active remote when worktree ownership demands it. Use NewLocalClient for daemon-control commands (it's the same thing today, kept distinct for callers that want to be explicit about "no remote routing").

func NewLocalClient

func NewLocalClient() (*Client, error)

NewLocalClient returns a Unix-socket client for the local clankd. Use for daemon-control (start/stop/status) and any direct local access.

func NewRemoteClient

func NewRemoteClient() (*Client, error)

NewRemoteClient returns a TCP client targeting the active remote's gateway_url with its access_token as the bearer, for flows that talk to the remote gateway directly rather than through the local daemon.

Returns an error when no active remote is configured — surfaces a clear setup message rather than silently falling back to a transport that would fail later.

func NewTCPClient

func NewTCPClient(baseURL, authToken string) *Client

NewTCPClient creates a client that talks to a remote clankd over TCP. baseURL must be the externally-reachable gateway URL (no trailing slash); authToken is sent as `Authorization: Bearer <token>` on every request. The gateway's Authenticator (HS256 JWT, OIDC, or opt-in static bearer) verifies it.

func (*Client) Backend

func (c *Client) Backend(backend agent.BackendType) *BackendClient

Backend returns a handle for the named backend.

func (*Client) Bridge

func (c *Client) Bridge() *BridgeClient

Bridge returns the bridge admin handle.

func (*Client) GitHubConnectCancel

func (c *Client) GitHubConnectCancel(ctx context.Context, flowID string) error

GitHubConnectCancel signals the host to abort an in-flight flow. No-op for a flow that's already terminal.

func (*Client) GitHubConnectStart

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

GitHubConnectStart kicks off the device flow on the host. Cancels any prior in-flight flow first (single-slot registry on the host).

func (*Client) GitHubConnectStatus

func (c *Client) GitHubConnectStatus(ctx context.Context, flowID string) (GitHubDeviceFlowStatus, error)

GitHubConnectStatus polls one flow. ErrGitHubUnknownFlow when the id doesn't match the host's active slot.

func (*Client) GitHubCreatePR

func (c *Client) GitHubCreatePR(ctx context.Context, worktreeID string, req GitHubCreatePRRequest) (GitHubCreatePRResponse, error)

GitHubCreatePR pushes the worktree's branch and opens a PR. Returns a typed *GitHubPRAlreadyExistsError when a PR for the head branch already exists, with the existing URL extracted from the 409 body.

func (*Client) GitHubDisconnect

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

GitHubDisconnect removes the host's stored GitHub credentials. Idempotent — missing credentials is not an error.

func (*Client) GitHubPullRequestInspect

func (c *Client) GitHubPullRequestInspect(ctx context.Context, locator GitHubPullRequestLocator) (GitHubPullRequestInspection, error)

GitHubPullRequestInspect resolves the code identity without cloning it.

func (*Client) GitHubPullRequestLaunch

func (c *Client) GitHubPullRequestLaunch(ctx context.Context, req GitHubPullRequestLaunchRequest) (host.CreateWorktreeResult, error)

GitHubPullRequestLaunch fetches and checks out the approved revision.

func (*Client) GitHubStatus

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

GitHubStatus fetches the host's GitHub-connect status.

func (*Client) Host

func (c *Client) Host(hostname string) *HostClient

Host returns a handle for the named host.

func (*Client) Ping

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

Ping checks if clankd is reachable.

func (*Client) PingInfo

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

PingInfo returns detailed daemon status.

func (*Client) Preview

func (c *Client) Preview(worktreeID string) *PreviewClient

Preview returns a handle bound to a worktree's dev-server preview.

func (*Client) Session

func (c *Client) Session(id string) *SessionClient

Session returns a handle for the given session id.

func (*Client) Sessions

func (c *Client) Sessions() *SessionsClient

Sessions returns the collection-level sessions handle.

func (*Client) SignPreviewToken

func (c *Client) SignPreviewToken(ctx context.Context, token string, ttl time.Duration) (PreviewSignedURL, error)

SignPreviewToken authorizes a browser that cannot attach the CLI's bearer token.

func (*Client) SoftwareManifest

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

SoftwareManifest calls clank-host's GET /software-manifest (proxied through whichever daemon this client targets) and returns the manifest of versions for every relevant CLI tool installed on that host. Today only opencode is populated; the shape is forward-compatible for claude / clank-host / etc.

Retries up to softwareManifestRetries times with exponential backoff when the underlying call fails with a gateway-side 5xx that looks like a cold sprite (502/503/504 / "host unavailable"). Other errors propagate immediately.

Cached aggressively on the server side, so this is effectively free after the first invocation per clank-host process lifetime. See agent.GetSoftwareManifest's docstring for the freshness contract.

func (*Client) Status

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

Status returns clankd status including all managed sessions.

type GitHubCreatePRRequest

type GitHubCreatePRRequest struct {
	Title string `json:"title"`
	Body  string `json:"body"`
	Base  string `json:"base"`
	Draft bool   `json:"draft"`
}

GitHubCreatePRRequest is the body of POST /v1/worktrees/{id}/pr. All fields except Draft are required (host enforces this).

type GitHubCreatePRResponse

type GitHubCreatePRResponse struct {
	PRNumber   int    `json:"pr_number"`
	PRURL      string `json:"pr_url"`
	HeadBranch string `json:"head_branch"`
	BaseBranch string `json:"base_branch"`
	HeadSHA    string `json:"head_sha"`
}

GitHubCreatePRResponse is the 201 body of the PR creation route.

type GitHubDeviceFlowStart

type GitHubDeviceFlowStart struct {
	FlowID                  string    `json:"flow_id"`
	UserCode                string    `json:"user_code"`
	VerificationURI         string    `json:"verification_uri"`
	VerificationURIComplete string    `json:"verification_uri_complete"`
	ExpiresAt               time.Time `json:"expires_at"`
	Interval                int       `json:"interval"`
}

GitHubDeviceFlowStart mirrors github.DeviceFlowStart.

type GitHubDeviceFlowState

type GitHubDeviceFlowState string

GitHubDeviceFlowState matches github.DeviceFlowState.

const (
	GitHubFlowPending  GitHubDeviceFlowState = "pending"
	GitHubFlowSuccess  GitHubDeviceFlowState = "success"
	GitHubFlowDenied   GitHubDeviceFlowState = "denied"
	GitHubFlowExpired  GitHubDeviceFlowState = "expired"
	GitHubFlowError    GitHubDeviceFlowState = "error"
	GitHubFlowCanceled GitHubDeviceFlowState = "canceled"
)

type GitHubDeviceFlowStatus

type GitHubDeviceFlowStatus struct {
	State       GitHubDeviceFlowState `json:"state"`
	Error       string                `json:"error,omitempty"`
	GitHubLogin string                `json:"github_login,omitempty"`
}

GitHubDeviceFlowStatus is the polled state of a connect flow.

type GitHubPRAlreadyExistsError

type GitHubPRAlreadyExistsError struct {
	ExistingURL string
	Message     string
}

GitHubPRAlreadyExistsError carries the existing-PR URL the gateway returns alongside the 409 branch_already_has_pr response so the CLI can render it as a "View existing PR" link.

func (*GitHubPRAlreadyExistsError) Error

type GitHubPullRequestInspection

type GitHubPullRequestInspection struct {
	GitHubPullRequestLocator
	Title      string `json:"title"`
	HTMLURL    string `json:"html_url"`
	HeadOwner  string `json:"head_owner"`
	HeadRepo   string `json:"head_repo"`
	HeadBranch string `json:"head_branch"`
	HeadSHA    string `json:"head_sha"`
	BaseBranch string `json:"base_branch"`
	Author     string `json:"author"`
	IsPrivate  bool   `json:"is_private"`
}

GitHubPullRequestInspection is the exact revision shown for approval.

type GitHubPullRequestLaunchRequest

type GitHubPullRequestLaunchRequest struct {
	GitHubPullRequestLocator
	ExpectedHeadSHA string `json:"expected_head_sha"`
}

GitHubPullRequestLaunchRequest binds launch to the revision the user approved.

type GitHubPullRequestLocator

type GitHubPullRequestLocator struct {
	Owner  string `json:"owner"`
	Repo   string `json:"repo"`
	Number int    `json:"number"`
}

GitHubPullRequestLocator is the validated identity of a GitHub PR.

type GitHubStatus

type GitHubStatus struct {
	Available   bool      `json:"available"`
	Connected   bool      `json:"connected"`
	GitHubLogin string    `json:"github_login,omitempty"`
	Scopes      []string  `json:"scopes,omitempty"`
	InstalledAt time.Time `json:"installed_at,omitzero"`
}

GitHubStatus mirrors github.Status — see internal/host/github/manager.go.

type HostClient

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

HostClient is the hub-side handle for one host. Bound to a hostname.

Per §7 of the hub-host refactor the host plane no longer keeps a repo registry; identity on the wire is `(host, GitRef, branch)` and ref is always sent in the request body. The methods on HostClient are flat — there is no Repo/Worktree builder chain because the host itself has no per-repo handle to bind to.

func (*HostClient) AuthFlowStatus

func (h *HostClient) AuthFlowStatus(ctx context.Context, providerID, flowID string) (agent.DeviceFlowStatus, error)

AuthFlowStatus returns the current state of an in-progress flow (device or api-key — the endpoint is flow-type-agnostic). Pure read.

func (*HostClient) CancelAuthFlow

func (h *HostClient) CancelAuthFlow(ctx context.Context, providerID, flowID string) error

CancelAuthFlow signals the host to abort an in-progress flow. Idempotent for already-finished flows.

func (*HostClient) DeleteAuthCredential

func (h *HostClient) DeleteAuthCredential(ctx context.Context, providerID string) error

DeleteAuthCredential logs the user out of providerID on this host and triggers an OpenCode restart so the change takes effect.

func (*HostClient) Hostname

func (h *HostClient) Hostname() string

Hostname returns the hostname this handle is bound to.

func (*HostClient) ListAuthProviders

func (h *HostClient) ListAuthProviders(ctx context.Context, backend agent.BackendType) ([]agent.ProviderAuthInfo, error)

ListAuthProviders returns the auth-capable providers on this host plus their current connection state. backend, if non-empty, filters to providers consumed by that agent CLI (opencode | claude-code).

func (*HostClient) ListBranches

func (h *HostClient) ListBranches(ctx context.Context, ref agent.GitRef) ([]host.BranchInfo, error)

ListBranches returns the branches/worktrees for the given repo. The branch on ref is ignored — the response enumerates all branches.

func (*HostClient) MergeBranch

func (h *HostClient) MergeBranch(ctx context.Context, ref agent.GitRef, branch, commitMessage string) (host.MergeResult, error)

MergeBranch merges branch into the repo's default branch using commitMessage.

func (*HostClient) RemoveWorktree

func (h *HostClient) RemoveWorktree(ctx context.Context, ref agent.GitRef, branch string, force bool) error

RemoveWorktree deletes the worktree for branch. force forwards to git.

func (*HostClient) ResolveWorktree

func (h *HostClient) ResolveWorktree(ctx context.Context, ref agent.GitRef, branch string) (host.WorktreeInfo, error)

ResolveWorktree creates (or reuses) the worktree for branch and returns its info.

func (*HostClient) StartAuthDeviceFlow

func (h *HostClient) StartAuthDeviceFlow(ctx context.Context, providerID string) (agent.DeviceFlowStart, error)

StartAuthDeviceFlow kicks off device-flow auth for providerID and returns the user-facing fields the TUI shows (URL, user_code) plus a flow_id for subsequent status polls.

func (*HostClient) StartAuthOAuthCodeFlow

func (h *HostClient) StartAuthOAuthCodeFlow(ctx context.Context, providerID string) (agent.DeviceFlowStart, error)

StartAuthOAuthCodeFlow kicks off an oauth-code flow (PTY-relayed `claude setup-token`) for providerID. Returns the verification URL the CLI prints + a flow_id for the subsequent SubmitAuthCode call.

func (*HostClient) SubmitAuthAPIKey

func (h *HostClient) SubmitAuthAPIKey(ctx context.Context, providerID, key string, metadata map[string]string) (agent.DeviceFlowStart, error)

SubmitAuthAPIKey stores an API key (and provider-specific metadata fields like Azure resourceName or Cloudflare accountId) for providerID on this host and returns a flow_id the caller polls until the OpenCode restart completes. metadata may be nil for providers that need only a key.

func (*HostClient) SubmitAuthCode

func (h *HostClient) SubmitAuthCode(ctx context.Context, providerID, flowID, code string) error

SubmitAuthCode hands the host the code the user copied from the IdP's redirect page. The host writes it into setup-token's stdin and persists the resulting long-lived token. Synchronous.

type PingResponse

type PingResponse struct {
	Status  string `json:"status"`
	PID     int    `json:"pid"`
	Uptime  string `json:"uptime"`
	Version string `json:"version"`
}

PingResponse is the response from /ping.

type PreviewClient

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

PreviewClient is the worktree-scoped handle for the Expo/Metro dev-server preview lifecycle. Routes proxy through the gateway to the owning host.

func (*PreviewClient) Logs

func (p *PreviewClient) Logs(ctx context.Context) ([]byte, error)

Logs returns the dev server's captured stdout/stderr tail (text/plain, ANSI-stripped host-side; empty when nothing is running). Raw request — the shared do() helper assumes JSON bodies.

func (*PreviewClient) Named

func (p *PreviewClient) Named(name string) *PreviewClient

Named returns a handle scoped to one configured preview name.

func (*PreviewClient) Start

func (p *PreviewClient) Start(ctx context.Context) (*PreviewStatus, error)

Start spawns (or returns the existing) dev server for the preview key — a managed worktree ID or a folder slug (host.LocalRepoSlug); the host resolves both. Idempotent on the host side.

func (*PreviewClient) Status

func (p *PreviewClient) Status(ctx context.Context) (*PreviewStatus, error)

Status returns availability + running state without spawning.

func (*PreviewClient) Stop

func (p *PreviewClient) Stop(ctx context.Context) error

Stop terminates the worktree's dev server. Idempotent: a 404 not_running is surfaced as an error by the transport, so callers that want naive idempotency should ignore it.

type PreviewSetupRequiredError

type PreviewSetupRequiredError struct {
	Message           string
	SetupPrompt       string
	ProjectConfigPath string
}

PreviewSetupRequiredError carries the connected-agent setup task and output path returned by a current host.

func (*PreviewSetupRequiredError) Error

func (e *PreviewSetupRequiredError) Error() string

func (*PreviewSetupRequiredError) Unwrap

func (e *PreviewSetupRequiredError) Unwrap() error

type PreviewSignedURL

type PreviewSignedURL struct {
	SignedURL string    `json:"signed_url"`
	ExpiresAt time.Time `json:"expires_at"`
}

PreviewSignedURL is a short-lived owner-only browser URL.

type PreviewStatus

type PreviewStatus struct {
	Available         bool   `json:"available"`
	SetupRequired     bool   `json:"setup_required"`
	SetupPrompt       string `json:"setup_prompt"`
	ProjectConfigPath string `json:"project_config_path"`
	Kind              string `json:"kind"`
	ServiceName       string `json:"service_name"`
	State             string `json:"state"`
	LastError         string `json:"last_err"`
	Port              int    `json:"port"`
	URL               string `json:"url"`
	Token             string `json:"token"`
}

PreviewStatus is the dev-server state returned by Start/Status. Port is the dev server's listen port — populated even on the laptop path, where the gateway-minted public URL/Token fields stay empty. Kind mirrors preview.Kind ("expo" | "web") and tells `clank preview` which client flow to run (QR + phone vs browser overlay proxy).

type SessionClient

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

SessionClient is bound to a session ID. All id-scoped session operations live here, including Get (which materialises the handle into the underlying SessionInfo).

func (*SessionClient) Abort

func (s *SessionClient) Abort(ctx context.Context) error

Abort interrupts the running session.

func (*SessionClient) Delete

func (s *SessionClient) Delete(ctx context.Context) error

Delete stops and removes the session.

func (*SessionClient) Fork

func (s *SessionClient) Fork(ctx context.Context, messageID string) (*agent.SessionInfo, error)

Fork forks the session from messageID. Empty messageID forks the entire session (from start).

func (*SessionClient) Get

Get returns the SessionInfo for this session.

func (*SessionClient) ID

func (s *SessionClient) ID() string

ID returns the bound session id.

func (*SessionClient) MarkRead

func (s *SessionClient) MarkRead(ctx context.Context) error

MarkRead marks the session as read.

func (*SessionClient) Messages

func (s *SessionClient) Messages(ctx context.Context) ([]agent.MessageData, error)

Messages returns the full message history for this session.

func (*SessionClient) PendingPermissions

func (s *SessionClient) PendingPermissions(ctx context.Context) ([]agent.PermissionData, error)

PendingPermissions returns all pending permissions for the session.

func (*SessionClient) ReplyPermission

func (s *SessionClient) ReplyPermission(ctx context.Context, permissionID string, allow bool, denyMessage string) error

ReplyPermission replies to a permission request. denyMessage is the reason forwarded to the model when allow is false (empty for a default).

func (*SessionClient) Send

Send sends a follow-up message to the running session.

func (*SessionClient) SetDraft

func (s *SessionClient) SetDraft(ctx context.Context, draft string) error

SetDraft sets or clears the draft text for the session.

func (*SessionClient) SetVisibility

func (s *SessionClient) SetVisibility(ctx context.Context, visibility agent.SessionVisibility) error

SetVisibility sets the visibility state of the session.

func (*SessionClient) ToggleFollowUp

func (s *SessionClient) ToggleFollowUp(ctx context.Context) (bool, error)

ToggleFollowUp toggles the follow-up flag and returns the new state.

type SessionsClient

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

SessionsClient is the collection-level handle for sessions.

func (*SessionsClient) Create

Create asks clankd to create and start a new agent session.

func (*SessionsClient) Discover

func (s *SessionsClient) Discover(ctx context.Context, backend agent.BackendType, seedDir string) error

Discover asks clankd to discover and register historical sessions for the given backend and seed directory.

func (*SessionsClient) List

List returns all managed sessions.

func (*SessionsClient) Search

Search searches session metadata. See agent.SearchParams for the query semantics.

func (*SessionsClient) Subscribe

func (s *SessionsClient) Subscribe(ctx context.Context) (<-chan agent.Event, error)

Subscribe opens an SSE stream and delivers events to the returned channel. The channel closes when the context is cancelled or the connection drops.

type StatusResponse

type StatusResponse struct {
	PID      int                 `json:"pid"`
	Uptime   string              `json:"uptime"`
	Sessions []agent.SessionInfo `json:"sessions"`
}

StatusResponse is the response from /status.

Jump to

Keyboard shortcuts

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