Skip to main content

Crate zwire_host

Crate zwire_host 

Source
Expand description

zwire-host — one small self-contained binary that exposes the local machine to any app over a JSON message protocol.

Originally the Chrome native-messaging host for the zwire HUD, it is now a universal local endpoint: system stats, a namespaced key/value store, a filesystem crawler, subprocess exec, clipboard/notify/open, and multiplexed PTY terminals — reachable from a browser extension and from tmux, emacs, desktop apps, plugins, and any language.

§Transports

  • Native messaging (default): u32-length-prefixed JSON on stdio, for Chrome. Just run the binary with no recognised subcommand.
  • Socket daemon: zwire-host serve listens on a Unix socket speaking newline-delimited JSON — the lingua franca every tool already has.
  • Client: zwire-host call '{"cmd":"hostinfo"}' sends one request and prints the reply frames.

Both transports feed the same session::Session dispatcher, so every capability is reachable from every client.

Re-exports§

pub use proto::Framing;
pub use proto::Out;
pub use proto::Peer;
pub use session::caps;
pub use session::Session;

Modules§

api
High-level, in-process helpers for crates that embed this one as a library.
bus
A pub/sub event bus — the host as a coordination hub across apps.
exec
Subprocess execution.
fsops
Filesystem capability: read/write/list/stat/mkdir/rm.
hooks
Lifecycle scripting hooks, executed via the standalone stryke interpreter.
hostlog
Shared request/response log. Chrome spawns a SEPARATE native-messaging host process per sendNativeMessage (and one per persistent connectNative port), so no single process sees every command. To let the HUD “HOST” tab show ALL tx/rx to zwire-host regardless of which client/process handled it, every process appends a compact JSON line to one shared ring-capped file (~/.zwire/hostlog.jsonl). The HOST tab reads it back via the hostlog command. Streaming frames (sysinfo/pty/job output) are pushed with out.send directly rather than respond, so only real commands + their replies land here — not the high-frequency stream noise.
jobs
Background jobs — fire-and-forget long-running commands.
osops
OS-integration capabilities: open, clipboard, notify, hostinfo.
peer
Host-to-host peering — a mesh of zwire-host daemons.
procs
Process tools: list (ps), control (kill), and PATH lookup (which).
proto
Wire transport + small reply helpers, shared by every transport.
pty
Multiplexed PTY sessions.
session
The capability router shared by every transport.
store
Per-app persistent state under the OS application-data directory.
stryke_lsp
Bridge to the stryke language server (stryke --lsp) for the Hooks editor.
stryke_runner
Subprocess bridge to the stryke interpreter for lifecycle hook scripts.
sysmon
Live system-stats streamer.
theme_watch
Cross-process live theme sync.
transport
The three ways to reach the dispatcher.
watch
Streaming filesystem observers: fs_watch and fs_tail.

Constants§

VERSION
Crate version, surfaced in hello/hostinfo replies.

Functions§

default_socket
Where the socket daemon listens by default. $ZWIRE_HOST_SOCK overrides on every platform. Otherwise:
run
Entry point: interpret args (everything after argv[0]) and run the chosen transport. Any unrecognised first token falls through to native-messaging mode, because Chrome launches the host with extension-origin arguments we must ignore.