handlers

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 11 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

This section is empty.

Variables

This section is empty.

Functions

func ListConversations

func ListConversations(reg ConversationLister) dispatch.Handler

ListConversations returns a dispatch.Handler that answers a list_conversations request with a conversations envelope. The handler reads the registry, projects each row to a protocol.ConversationSummary, sorts by LastUsedAt asc / ID asc (mirroring Registry.Save), and replies via Conn.Reply (which stamps id, ts, and in_reply_to).

func RegisterPushToken

func RegisterPushToken(reg *devices.Registry, registryPath string, logger *slog.Logger) dispatch.Handler

RegisterPushToken returns a dispatch.Handler that processes a register_push_token frame from the phone. reg is the devices registry; registryPath is the canonical on-disk path passed to Save; logger is the daemon's slog logger used for every branch's structured event.

SECURITY:

  • The push token (p.Token, dev.PushToken) is opaque infrastructure data (FCM/APNs registration id); not a secret on par with the device auth token. It is logged at INFO when a write happens (as a side-effect of the write event) and never as a field value at any level.
  • The Device.Name is logged on every authenticated branch. The unauth branch has no name to log; that is the only path without it.

Concurrency: the handler is stateless beyond the closure capture. reg's mutex serialises UpdatePushRegistration and Save independently; two concurrent calls for the same TokenHash interleave at the mutex boundary with documented last-writer-wins semantics.

func SendMessage

func SendMessage(w TurnWriter, logger *slog.Logger) dispatch.Handler

SendMessage returns a dispatch.Handler that processes a send_message frame from the phone. w is the per-conn write surface (the bootstrap session in production); logger is the daemon's slog logger used for every branch's structured event.

SECURITY:

  • payload.Text reaches the supervised claude child's stdin verbatim via TurnWriter. No transformation, no length cap beyond the transport's WS read ceiling (1 MiB; see internal/transport).
  • payload.Text is NEVER logged at any level. conversation_id and message_id (phone-supplied opaque ids) are logged on ack and unknown-conversation paths only.

Types

type ConversationLister

type ConversationLister interface {
	List(filter ...conversations.ListFilter) []conversations.Conversation
}

ConversationLister is the minimal surface this handler consumes from the conversations registry. *conversations.Registry satisfies it structurally; no adapter required. The variadic shape mirrors conversations.Registry.List exactly so structural matching holds.

type TurnWriter

type TurnWriter interface {
	Activate(ctx context.Context) error
	WriteUserTurn(conversationID string, payload []byte) error
}

TurnWriter is the minimal write-surface the send_message handler needs. *sessions.Session satisfies it via one-line passthroughs to Session.Activate and Supervisor.WriteUserTurn. The interface lives in this package so handlers/ stays free of internal/sessions and internal/supervisor imports.

Activate is called before WriteUserTurn so an idle-evicted bootstrap session lazily respawns claude on the next inbound message rather than dropping it silently (#396). On an already-active session Activate is a near-no-op (two non-blocking channel receives).

Jump to

Keyboard shortcuts

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