Expand description
Compatibility re-export for the internal runtime crate.
New daemon, CLI, and TUI code should depend on the
mermaid-runtime crate boundary. The mermaid_cli::runtime module is
retained so existing call sites and downstream code do not need a
flag-day import rewrite.
Re-exports§
pub use client::*;
Modules§
Structs§
- Action
Request - Approval
Record - Approval
Replay Result - Approvals
Repo - Checkpoint
File - Checkpoint
Manifest - Checkpoint
Record - Checkpoints
Repo - Compaction
Record - Compactions
Repo - Message
Record - Messages
Repo - NewApproval
- NewCheckpoint
- NewCompaction
- NewMessage
- NewPlugin
Install - NewProcess
- NewProvider
Probe - NewSession
- NewTask
- NewTool
Run - Pairing
Token Record - Pairing
Tokens Repo - Plugin
Capability Preview - A summary of what a plugin declares it will do, shown before install/enable.
These are advisory disclosures for informed consent, not an enforced sandbox
(see
PluginManifest::capabilities). - Plugin
Install Record - Plugin
Manifest - Plugins
Repo - Policy
Engine - Policy
Override - Process
Record - Processes
Repo - Provider
Probe Record - Provider
Probes Repo - Runtime
Store - SQLite-backed durable runtime state.
- Session
Record - Sessions
Repo - Task
Record - Task
Timeline Event - Tasks
Repo - Tool
RunRecord - Tool
Runs Repo
Enums§
- Open
Intent - What kind of access an
open_beneathcall needs. - Policy
Decision - Policy
Override Decision - Process
Status - Risk
Class - Safety
Mode - Task
Priority - Task
Status - Durable task state. A task is the daemon-level work unit; a chat transcript is just one artifact linked to it.
- Tool
Category
Constants§
- 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 0opts out for long-lived automation.
Functions§
- approve_
and_ replay - 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 localmermaid pairCLI deliberately does not call this — its--ttl-days 0“never expires” opt-out is an owner-only choice with no privilege boundary (#65). - create_
checkpoint - create_
checkpoint_ for_ task - create_
dir_ all_ beneath - Confined
mkdir -pfor aroot-relative directory path: creates each missing component beneathroot, refusing to descend through a symlink that escapes (#77). On Linux:mkdirat+openat2(RESOLVE_BENEATH)per component; otherwise thecontain_within_canonical+std::fsfallback. - daemon_
socket_ path - data_
dir - deny_
approval - gc_
old_ checkpoint_ dirs - Best-effort GC of on-disk checkpoint directories older than
retention_days(#130): removescheckpoints/<id>/whose mtime is past the window so the tree can’t grow without bound, while keeping recent (still-restorable) checkpoints. Returns the count removed; never fails the caller (a bad entry is skipped). - generate_
pairing_ token - hash_
pairing_ token - install_
plugin_ from_ path - is_
destructive_ command - Defense-in-depth pre-check for the
execute_commandpath: callable before the policy engine to short-circuit obviously destructive commands. Splits the command into the segmentssh -cwould run and reportstrueif any segment is a destructive operation (contains_destructive_pattern), a raw network listener / reverse-shell primitive (nc -l,socat …-listen:…), or a remote download piped straight into a shell (curl … | sh). Tokenized and segment-aware — not a substring match — so spacing, case, quoting, flag bundling, and chaining can’t trivially evade it (#114). Over-blocking is the safe direction; the authoritative boundary is still deny-by-default + the policy engine, which this mirrors without changing its semantics. - open_
beneath - Open
root-relativerelforintentwithout ever traversing out ofroot— closing the check-then-write TOCTOU where an intermediate directory is swapped for a symlink after a lexical path check but before the operation (#77). The returnedFileis bound to the exact inode the confinement resolved, so subsequent reads/writes can’t be redirected. - pairing_
expiry_ from_ now - RFC3339 expiry
ttl_daysfrom now, orNonewhenttl_days <= 0(never expires). Shared by the daemonpaircommand and the local CLI so both honor the same TTL semantics. - plugin_
capability_ preview - remove_
file_ beneath - Confined unlink of a
root-relative file (#77): opens the parent underRESOLVE_BENEATHandunlinkats the leaf, so a swapped-in symlink parent can’t redirect the delete outsideroot. - request_
daemon_ json - request_
daemon_ text - restore_
checkpoint - run_
plugin_ hooks - snapshot_
field_ from_ daemon - try_
exclusive_ lock - Acquire an exclusive, auto-released advisory lock on
path— a process singleton guard for the daemon (#131). Returns the heldFileon success (keep it alive to hold the lock), orNoneif another process already holds it.flockreleases automatically when the file is dropped OR the process exits/crashes, so a dead holder never wedges the lock the way anO_EXCLpidfile would. Holding it across the socket probe → unlink → bind closes that TOCTOU: two daemons can’t both decide a stale socket is theirs to rebind. - validate_
plugin_ manifest - write_
atomic - Write
bytestopathatomically: temp file in the same directory →sync_all→ rename over the destination. The rename is atomic on the same filesystem (and replaces an existing target on both Unix and Windows). - write_
atomic_ beneath - Atomically write
bytestoroot-relativerelwithout ever traversing out ofroot. The temp file is created andrenameat-swapped beneath the same confined directory fd as the destination (Linuxopenat2(RESOLVE_BENEATH)), so a parent dir swapped for an escaping symlink after a path check can’t redirect the write (#77), AND a crash/kill/disk-full mid-write leaves the previous file intact instead of a truncated one —open_beneath+WriteTruncategives the first guarantee but not the second. Falls back tocontain_within_canonical+ by-pathcrate::write_atomicon non-Linux / pre-openat2kernels (the same best-effort posture as the other helpers). - write_
plugin_ lockfile