Expand description
Agent protocol — shared types used by both the daemon (tsafe-agent)
and the client (tsafe-cli open_vault_via_agent).
§Security model
- The agent holds the vault password in memory, zeroized on drop.
- Access requires the session token plus a
requesting_pidclaim that matches the real peer PID on the IPC transport. - The daemon enforces the TTL chosen at
tsafe agent unlock; expired sessions reject new requests and clear their socket state on exit. - The named pipe is
\\.\pipe\tsafe-agent-{agent_pid}. - The
TSAFE_AGENT_SOCKenv var carries{pipe_name}::{session_token_hex}. - A state file (
agent.sockin the data dir) persists the sock address so processes that do not inheritTSAFE_AGENT_SOCK(e.g. VS Code background terminals) can still reach a running agent.
§Wire protocol
Request and response are newline-terminated JSON objects written over the named pipe. One request → one response per connection.
Structs§
- Agent
Session - Agent
Session Outcome - Cell
Record - Immutable record established on the first
Resolvefor a cell.
Enums§
- Agent
Request - Agent
Response - Agent
Session State - Cell
State - Lifecycle state of a tracked cell in the daemon’s in-memory cache.
- Cellos
Request - Requests sent by the CellOS broker over
TSAFE_SOCKET. - Cellos
Response - Responses from the daemon over
TSAFE_SOCKET.
Constants§
- ENV_
AGENT_ SOCK - Set by
tsafe agent unlockafter the user approves. Format:{pipe_name}::{session_token_hex} - ENV_
CELLOS_ SOCK - Path for the CellOS broker Unix socket. Overridden by
TSAFE_SOCKET.
Functions§
- agent_
sock_ path - Path to the agent socket state file.
Written by the daemon on startup; deleted on exit.
Allows processes that don’t inherit
TSAFE_AGENT_SOCKto find a running agent. - cellos_
socket_ path - Resolve the CellOS broker socket path:
$TSAFE_SOCKETor~/.tsafe/agent.sock. - clear_
agent_ sock - Delete the agent state file (called on daemon exit).
- format_
agent_ sock - Build the value to put in
TSAFE_AGENT_SOCK. - parse_
agent_ sock - Parse
TSAFE_AGENT_SOCKinto(pipe_name, session_token_hex). - ping_
agent - pipe_
name - read_
agent_ sock - Read the agent socket address from the state file. Returns
Noneif missing. - read_
agent_ sock_ env - request_
password_ from_ agent - send_
lock - write_
agent_ sock - Write the agent socket address to the state file so other processes can find it. File is restricted to owner-only on Unix (it contains the session token).