Documentation
¶
Overview ¶
Package remoteaccess serves the mobile remote-control surface: an authenticated HTTP + WebSocket endpoint that speaks the same JSON-RPC protocol as the primary stdio client, minus a small method deny list (see denylist.go). See hub.go for how helper -> client traffic fans out to every connected surface.
Index ¶
- Constants
- func MethodAllowed(method string) bool
- func ReduceControlValue(params any, originalBytes, target int) any
- func StartDaemonControl(parent context.Context, dir, instance, version string, ...) (func(), error)
- type ControlEvent
- type ControlPoll
- type DispatchFunc
- type Hub
- func (h *Hub) NotifyAll(method string, params any)
- func (h *Hub) NotifyClient(originID string, method string, params any)
- func (h *Hub) NotifyOwnedAuthProgress(origin, agent string, params json.RawMessage)
- func (h *Hub) NotifyPrimary(ctx context.Context, method string, params any)
- func (h *Hub) RegisterRemote(id string, notify glsp.NotifyFunc, drop func()) func()
- func (h *Hub) RemoteCount() int
- func (h *Hub) SetPrimary(notify glsp.NotifyFunc)
- func (h *Hub) WrapNotify(originID string, orig glsp.NotifyFunc) glsp.NotifyFunc
- type Options
- type OwnedStreamRegistry
- func (r *OwnedStreamRegistry) Activate(origin, subscriptionID string) error
- func (r *OwnedStreamRegistry) EndpointContext(origin string) context.Context
- func (r *OwnedStreamRegistry) Stage(origin, requestID, subscriptionID string, worker OwnedStreamWorker) error
- func (r *OwnedStreamRegistry) StageV2(origin, requestID, subscriptionID string, worker OwnedStreamWorker, ...) error
- func (r *OwnedStreamRegistry) Stop(origin, subscriptionID string)
- func (r *OwnedStreamRegistry) SubscriptionContext(origin, id string) context.Context
- type OwnedStreamWorker
- type Server
- func (s *Server) AutoStartConfig() (enabled bool, bind string)
- func (s *Server) Close() error
- func (s *Server) ConfigureOwnedStreams(streams *OwnedStreamRegistry, capability methods.ConversationCapability) error
- func (s *Server) ConfirmPairing(pairingID, code string) error
- func (s *Server) CreatePairingCode() (methods.RemoteAccessPairingCode, error)
- func (s *Server) Disable() error
- func (s *Server) Enable(params methods.RemoteAccessEnableParams) (methods.RemoteAccessStatus, error)
- func (s *Server) RevokeDevice(deviceID string) error
- func (s *Server) ServeDaemon(ctx context.Context, socket, bind, ip string, port int, ...) error
- func (s *Server) ServeOwned(ctx context.Context, port int) error
- func (s *Server) SetAutoStart(autoStart bool, bind string) error
- func (s *Server) Status() methods.RemoteAccessStatus
- type SessionCursorInfo
- type SessionLog
- func (l *SessionLog) BeginTurn(agentServer, sessionID string)
- func (l *SessionLog) ControlCursor(agent, session string) string
- func (l *SessionLog) Cursor(agentServer, sessionID string) SessionCursorInfo
- func (l *SessionLog) CursorEpochCurrent(cursor string) bool
- func (l *SessionLog) EndTurn(agentServer, sessionID string)
- func (l *SessionLog) Poll(agent, session, cursor string) (ControlPoll, error)
- func (l *SessionLog) PollBetween(agent, session, cursor, end string) (ControlPoll, error)
- func (l *SessionLog) PollBetweenRedacted(agent, session, cursor, end string, redact func([]byte) []byte) (ControlPoll, error)
- func (l *SessionLog) ProcessEpoch() string
- func (l *SessionLog) Publish(agentServer, sessionID string, message map[string]any) int64
- func (l *SessionLog) TurnCursor(agent, session string) string
- type StageLease
Constants ¶
const ( DefaultPort = 8737 BindLoopback = "loopback" BindTailscale = "tailscale" BindAll = "all" )
const MaxOwnedSubscriptions = 256
MaxOwnedSubscriptions bounds idle workers as well as subscriptions awaiting activation.
const PrimaryOrigin = methods.PrimaryClientOrigin
PrimaryOrigin identifies the primary (stdio/TCP) client connection in the hub. Remote WebSocket connections get unique generated origin IDs.
const (
// SessionCookieName carries the remote session token.
SessionCookieName = "camber_remote_session"
)
Variables ¶
This section is empty.
Functions ¶
func MethodAllowed ¶
MethodAllowed reports whether remote clients may call the given method.
func ReduceControlValue ¶
ReduceControlValue returns a reduced copy of v whose encoding fits in target bytes where possible: bulky strings are truncated with a marker, media, _meta, rawInput, rawOutput and toolResponse payloads are omitted, and long arrays are cut. Short identifying fields survive. Object results carry _camber.truncated; control output uses this for oversized events and pending interactions alike.
func StartDaemonControl ¶
func StartDaemonControl(parent context.Context, dir, instance, version string, dispatch func(context.Context, json.RawMessage) (any, error)) (func(), error)
StartDaemonControl publishes the same private discovery and newline-framed protocol used by camber CLI. Only dispatch enters the writer, with the original caller token. Never expose this listener through the paired router.
Types ¶
type ControlEvent ¶
type ControlPoll ¶
type ControlPoll struct {
Events []ControlEvent `json:"events"`
Cursor string `json:"cursor"`
NextCursor string `json:"nextCursor"`
TurnActive bool `json:"turnActive"`
ResetRequired bool `json:"resetRequired"`
HasMore bool `json:"hasMore"`
// ReducedEvents counts events on this page that were size-reduced.
ReducedEvents int `json:"reducedEvents"`
// AgentTextReduced is true when an agent_message_chunk on this page was
// reduced, so its text may have been cut.
AgentTextReduced bool `json:"agentTextReduced"`
}
type DispatchFunc ¶
DispatchFunc routes a permitted remote request into the main handler. originID identifies the remote connection for fan-out dedup.
type Hub ¶
type Hub struct {
// contains filtered or unexported fields
}
Hub fans helper -> client notifications out to every live connection. The primary connection (desktop/IDE over stdio) is registered lazily from request contexts; remote WebSocket connections register on connect.
Handle wraps each request's Notify through the hub, so closures that capture a request context (acpproxy clients, acpnav notifications) reach all clients regardless of which connection triggered the work. Helper -> client requests stay on their originating connection; anything every surface must see travels as pushed state (nav didChange, approvals didChange) instead.
func (*Hub) NotifyClient ¶
NotifyClient delivers a notification to exactly one client (primary or remote), bypassing fan-out for endpoint-specific updates such as debug capture.
func (*Hub) NotifyOwnedAuthProgress ¶
func (h *Hub) NotifyOwnedAuthProgress(origin, agent string, params json.RawMessage)
NotifyOwnedAuthProgress sends only this request's ephemeral ACP login update to its authenticated paired connection.
func (*Hub) NotifyPrimary ¶
NotifyPrimary sends a notification to the primary connection only.
func (*Hub) RegisterRemote ¶
func (h *Hub) RegisterRemote(id string, notify glsp.NotifyFunc, drop func()) func()
RegisterRemote adds a live remote connection and returns an unregister function. drop is invoked (once) if the hub evicts the client for falling behind; it should close the underlying socket.
func (*Hub) RemoteCount ¶
func (*Hub) SetPrimary ¶
func (h *Hub) SetPrimary(notify glsp.NotifyFunc)
SetPrimary records the primary connection's raw notify function. Call this with the UNWRAPPED function before wrapping, or fan-out would loop.
func (*Hub) WrapNotify ¶
func (h *Hub) WrapNotify(originID string, orig glsp.NotifyFunc) glsp.NotifyFunc
WrapNotify returns a NotifyFunc that first notifies the originating connection, then relays the notification to every other live client.
type Options ¶
type Options struct {
TrashDataHome string
Daemon bool
InvalidateFileSearch func()
DetachTerminals func(string)
// StatePath is the JSON file paired-device state persists to.
StatePath string
// Dispatch routes permitted requests into the main handler.
Dispatch DispatchFunc
// IsConcurrentMethod mirrors the main server's request serialization.
IsConcurrentMethod func(method string) bool
// Hub fans helper->client traffic out to remote connections.
Hub *Hub
}
Options configures the remote access server at construction time.
type OwnedStreamRegistry ¶
type OwnedStreamRegistry struct {
// contains filtered or unexported fields
}
OwnedStreamRegistry tracks subscriptions scoped to authenticated sockets.
func NewOwnedStreamRegistry ¶
func NewOwnedStreamRegistry() *OwnedStreamRegistry
func (*OwnedStreamRegistry) Activate ¶
func (r *OwnedStreamRegistry) Activate(origin, subscriptionID string) error
Activate releases a replied v2 subscription. Repeating activation on a running subscription is harmless.
func (*OwnedStreamRegistry) EndpointContext ¶
func (r *OwnedStreamRegistry) EndpointContext(origin string) context.Context
func (*OwnedStreamRegistry) Stage ¶
func (r *OwnedStreamRegistry) Stage(origin, requestID, subscriptionID string, worker OwnedStreamWorker) error
Stage starts a standalone v1 worker after the subscribe reply is written.
func (*OwnedStreamRegistry) StageV2 ¶
func (r *OwnedStreamRegistry) StageV2(origin, requestID, subscriptionID string, worker OwnedStreamWorker, events ...methods.ConversationEventV2) error
StageV2 reserves a subscription until the reply is written and its origin activates it. requestID is the namespaced subscribe request ID.
func (*OwnedStreamRegistry) Stop ¶
func (r *OwnedStreamRegistry) Stop(origin, subscriptionID string)
Stop cancels the subscription and waits for any write already in progress.
func (*OwnedStreamRegistry) SubscriptionContext ¶
func (r *OwnedStreamRegistry) SubscriptionContext(origin, id string) context.Context
SubscriptionContext ends when this subscription generation is removed.
type OwnedStreamWorker ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the remote access HTTP/WebSocket server. It is constructed once with the handler and started/stopped via the camber/remoteAccess/* JSON-RPC methods (desktop settings UI owns the lifecycle).
func NewOwnedServer ¶
func NewOwnedServer(opts Options, streams *OwnedStreamRegistry, token, webOrigin string) (*Server, error)
func (*Server) AutoStartConfig ¶
AutoStartConfig reports the persisted auto-start preference.
func (*Server) ConfigureOwnedStreams ¶
func (s *Server) ConfigureOwnedStreams(streams *OwnedStreamRegistry, capability methods.ConversationCapability) error
ConfigureOwnedStreams enables the v2 transport for paired devices. Call during helper initialization, before starting the paired listener.
func (*Server) ConfirmPairing ¶
ConfirmPairing accepts a scanned phone after the desktop user types the confirmation code displayed on that phone.
func (*Server) CreatePairingCode ¶
func (s *Server) CreatePairingCode() (methods.RemoteAccessPairingCode, error)
CreatePairingCode mints a one-time code for the desktop pairing QR.
func (*Server) Enable ¶
func (s *Server) Enable(params methods.RemoteAccessEnableParams) (methods.RemoteAccessStatus, error)
Enable starts (or restarts) the listener according to params.
func (*Server) RevokeDevice ¶
RevokeDevice removes a paired device and closes its live connections.
func (*Server) ServeDaemon ¶
func (s *Server) ServeDaemon(ctx context.Context, socket, bind, ip string, port int, doctor func(context.Context) map[string]any) error
ServeDaemon exposes operator actions only on the profile's private Unix socket.
func (*Server) ServeOwned ¶
ServeOwned runs the loopback-only standalone surface until ctx is canceled.
func (*Server) SetAutoStart ¶
SetAutoStart persists whether (and on which interface) the server starts automatically on helper launch. It does not start or stop the server.
func (*Server) Status ¶
func (s *Server) Status() methods.RemoteAccessStatus
Status reports current server state for the desktop settings UI.
type SessionCursorInfo ¶
SessionCursorInfo describes a session's live-event stream position.
type SessionLog ¶
type SessionLog struct {
// contains filtered or unexported fields
}
SessionLog retains bounded CLI cursor records for this helper epoch.
func NewSessionLog ¶
func NewSessionLog() *SessionLog
func (*SessionLog) BeginTurn ¶
func (l *SessionLog) BeginTurn(agentServer, sessionID string)
func (*SessionLog) ControlCursor ¶
func (l *SessionLog) ControlCursor(agent, session string) string
ControlCursor captures a boundary before a newly launched turn emits output.
func (*SessionLog) Cursor ¶
func (l *SessionLog) Cursor(agentServer, sessionID string) SessionCursorInfo
Cursor reports the session's current stream position for stamping into a session/load response. It is a pure read: an unknown session reports seq 0 without gaining a slot (see peekLocked).
func (*SessionLog) CursorEpochCurrent ¶
func (l *SessionLog) CursorEpochCurrent(cursor string) bool
CursorEpochCurrent distinguishes process restarts from ordinary bounded event eviction without treating a long completed turn as interrupted.
func (*SessionLog) EndTurn ¶
func (l *SessionLog) EndTurn(agentServer, sessionID string)
func (*SessionLog) Poll ¶
func (l *SessionLog) Poll(agent, session, cursor string) (ControlPoll, error)
Poll reads the same stamped event stream used by every desktop surface. Cursors bind a position to one session and fail explicitly after eviction or helper restart; clients never silently miss text when a cursor expires.
func (*SessionLog) PollBetween ¶
func (l *SessionLog) PollBetween(agent, session, cursor, end string) (ControlPoll, error)
PollBetween bounds replay to an immutable completed turn when end is set.
func (*SessionLog) PollBetweenRedacted ¶
func (l *SessionLog) PollBetweenRedacted(agent, session, cursor, end string, redact func([]byte) []byte) (ControlPoll, error)
PollBetweenRedacted is PollBetween with redact applied to an oversized event's encoding before it is reduced. Reduction truncates strings, so redacting the page afterwards could miss a secret cut mid-way and leave its prefix behind. Events that fit are returned unchanged; the caller still redacts the page it emits.
func (*SessionLog) ProcessEpoch ¶
func (l *SessionLog) ProcessEpoch() string
ProcessEpoch identifies the helper lifetime that owns preparation work.
func (*SessionLog) Publish ¶
func (l *SessionLog) Publish(agentServer, sessionID string, message map[string]any) int64
func (*SessionLog) TurnCursor ¶
func (l *SessionLog) TurnCursor(agent, session string) string
TurnCursor captures the boundary before the latest UI- or CLI-started turn.
type StageLease ¶
type StageLease struct {
// contains filtered or unexported fields
}
StageLease tracks the first page only until activation. All operations use the registry lock, including the timer callback and read completions.
func NewStageLease ¶
func NewStageLease(ttl time.Duration, events []methods.ConversationEventV2, mu *sync.Mutex, expire func()) *StageLease
func (*StageLease) BeginReadLocked ¶
func (l *StageLease) BeginReadLocked(p methods.ConversationReadPayload) func()
BeginReadLocked grants one transfer interval to a matching advancing read. The completion belongs to this generation even if the peer reuses its ID.
func (*StageLease) StopLocked ¶
func (l *StageLease) StopLocked()
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package webui embeds the built mobile-remote UI bundle so camber-helper can serve it directly (a phone has no dev server to proxy through).
|
Package webui embeds the built mobile-remote UI bundle so camber-helper can serve it directly (a phone has no dev server to proxy through). |