Skip to main content

Module daemon

Module daemon 

Source

Constants§

DAEMON_TOKEN_ENV
DEFAULT_PAIRING_TTL_DAYS
Default lifetime for a freshly minted pairing token. Tokens expire so a leaked or forgotten token can’t be replayed indefinitely; --ttl-days 0 opts out for long-lived automation.

Functions§

clamp_pairing_ttl_days
Clamp a client-supplied pairing TTL so a daemon socket caller can’t mint a never-expiring token by sending ttl_days <= 0: non-positive input becomes the default TTL, positive values pass through. The local mermaid pair CLI deliberately does not call this — its --ttl-days 0 “never expires” opt-out is an owner-only choice with no privilege boundary (#65).
daemon_socket_path
generate_pairing_token
hash_pairing_token
pairing_expiry_from_now
RFC3339 expiry ttl_days from now, or None when ttl_days <= 0 (never expires). Shared by the daemon pair command and the local CLI so both honor the same TTL semantics.
pipe_name_for_sid
Name of the per-user daemon control pipe for sid. Namespaced by the user’s SID so two users on one machine get distinct pipes (the analog of the unix socket living in a per-user data dir) — the ACL from pipe_sddl then enforces that separation, rather than merely naming it.
pipe_sddl
SDDL for the daemon pipe’s DACL: protected (P, no inherited ACEs), granting GA (generic all) to SY (LocalSystem) and to the owning user’s SID — and to no one else, since a DACL denies anything it doesn’t grant. This is the named-pipe analog of the 0600 unix socket + uid peer check (#66). Remote access is separately refused via PIPE_REJECT_REMOTE_CLIENTS on the server, not the DACL.
request_daemon_json
request_daemon_text
snapshot_field_from_daemon
subscribe_daemon_lines
Open a STREAMING daemon connection: send one JSON line, return a line-iterator over the responses. Used by subscribe_task, whose connection stays open (ack line, then NDJSON events until the terminal result) — request_daemon_json reads exactly one line and closes. auth.token is injected from MERMAID_DAEMON_TOKEN like the one-shot path.