hostmux

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: 26 Imported by: 0

Documentation

Overview

Package hostmux exposes a *host.Service over HTTP. It is consumed by `cmd/clank-host` (which serves it on a Unix socket) and by tests that want to exercise the wire format.

The Hub never imports this package directly; it goes through internal/host/client (hostclient) which has both an in-process adapter (calls *host.Service methods) and an HTTP adapter (calls these handlers). The wire endpoints are designed to be the only contract between Hub and Host.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DiscoverRequest

type DiscoverRequest struct {
	Backend agent.BackendType `json:"backend"`
	SeedDir string            `json:"seed_dir"`
}

HOST

type ForkRequest

type ForkRequest struct {
	MessageID string `json:"message_id"`
}

ForkRequest is the body for POST /sessions/{id}/fork.

type Mux

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

Mux wraps a *host.Service with an http.Handler.

func New

func New(svc *host.Service, lg *log.Logger) *Mux

New constructs a Mux. log may be nil.

func (*Mux) Handler

func (m *Mux) Handler() http.Handler

Handler returns an http.Handler with all routes registered. When an auth token is configured via SetAuthToken, the entire handler is wrapped in the requireBearer middleware so every endpoint is gated uniformly. The access log wraps outermost so rejected (401) requests are visible too.

func (*Mux) SetAuthToken

func (m *Mux) SetAuthToken(token string)

SetAuthToken configures the bearer-token middleware. When non-empty, every request must carry "Authorization: Bearer <token>" or the handler returns 401. When empty (the default), no auth is enforced — that's the laptop-local single-user mode where a Unix socket or loopback TCP listener is the only access boundary.

Must be called before Handler() so the wrap is applied; calling after has no effect on the already-built handler.

type PermissionReplyRequest

type PermissionReplyRequest struct {
	Allow bool `json:"allow"`
	// Message is the reason forwarded to the model when Allow is false (e.g.
	// plan-review comments). Ignored when Allow is true.
	Message string `json:"message,omitempty"`
}

PermissionReplyRequest is the body for POST /sessions/{id}/permissions/{permID}/reply.

type SessionSnapshot

type SessionSnapshot struct {
	SessionID  string              `json:"session_id"`
	ExternalID string              `json:"external_id"`
	Status     agent.SessionStatus `json:"status"`
	ServerURL  string              `json:"server_url,omitempty"`
}

SessionSnapshot is the runtime-fields shape returned by endpoints where the caller already has the full SessionInfo. ServerURL is populated for backends that expose an HTTP server (OpenCode only).

Jump to

Keyboard shortcuts

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