cli
The xs CLI provides a collection of subcommands for interacting with a cross.stream store. See Topics for naming rules and wildcards.
Usage
Commands
serve– Provides an API to interact with a local storecat–catthe event streamappend– Append an event to the streamcas– Retrieve content from Content-Addressable Storagecas-post– Store content in Content-Addressable Storageremove– Remove an item from the streamlast– Get the most recent frame(s), optionally filtered by topicget– Get a frame by IDimport– Import a frame directly into the storeeval– Evaluate a Nushell script with store helper commands availableversion– Get the version of the servernu– Manage the embedded xs.nu modulescru128– Generate and manipulate SCRU128 IDs
serve
Start the supervisor process.
| Option | Description |
|---|---|
<path> | Path to the store |
--expose <LISTEN_ADDR> | Expose the API on an additional address ([HOST]:PORT, <PATH>, or iroh://) |
--fsync <POLICY> | When to fsync the journal: always, interval:<ms>, or never. Default interval:1000 |
--ttl-sweep <MS> | How often to sweep expired time: frames from disk. 0 disables the sweeper. Default 1000 |
--plugin <PATH> | Load a Nushell plugin binary (nu_plugin_*) for eval, actors, services, and actions. Repeatable. The plugin must be compatible with the embedded Nushell version |
Examples:
# Expose on TCP port
# Make plugin commands available to processors
# Expose via iroh for peer-to-peer QUIC connections
See the Exposing Streams reference for detailed networking options.
Fsync policy
Every append commits to the on-disk journal before it returns. A process
crash loses nothing in any mode. Only power loss or a kernel crash can lose
the part of the journal not yet fsynced, and recovery then yields a stable
prefix of the stream. --fsync decides when that fsync happens:
always: fsync after every append, before the append returns. Slowest. An append that has returned survives power loss. This was the only behaviour before the flag existed.interval:<ms>: fsync on a timer, and only when something was written since the last tick. Power loss can lose up to one interval of appends. The default isinterval:1000.never: no fsync. The OS decides when the journal reaches disk.
# Old behaviour: fsync on every append
cat
Stream frames from the store.
--addr aside, the flags are the read options; see that
page for what each does and how following, ordering, and the xs.threshold
boundary work.
| Option | Read option |
|---|---|
<addr> | Address to connect to ([HOST]:PORT, <PATH>, or iroh://...) |
--follow, -f | follow |
--pulse <ms>, -p <ms> | heartbeat interval for --follow |
--new, -n | new |
--after <id>, -a <id> | after |
--from <id> | from |
--limit <n> | limit |
--last <n> | last |
--topic <patterns>, -T | topic: exact, user.*, *, or a comma list / Nushell list |
--with-timestamp | with-timestamp |
--sse | Use Server-Sent Events format (output, not a read option) |
A follow that falls behind the live stream ends with an
xs.lagged frame: xs cat prints
it, then exits 1 with the reason on stderr. xs last --follow does the same.
Examples:
# Local store
# Remote TCP connection
# Peer-to-peer via iroh QUIC
See Exposing Streams reference for connection details.
append
Append an event to a topic.
| Option | Description |
|---|---|
<addr> | Address to connect to |
<topic> | Topic to append to |
--meta <json> | JSON metadata to include |
--ttl <ttl> | Time-to-live: forever, ephemeral, time:<ms>, last:<n> |
--with-timestamp | Include RFC3339 timestamp extracted from frame ID |
Example:
|
cas
Retrieve content from CAS.
| Option | Description |
|---|---|
<addr> | Address to connect to ([HOST]:PORT, <PATH>, or iroh://...) |
<hash> | Hash of the content to retrieve |
cas-post
Store content in CAS.
| Option | Description |
|---|---|
<addr> | Address to connect to |
Example:
|
remove
Remove a frame from the store.
| Option | Description |
|---|---|
<addr> | Address to connect to |
<id> | ID of the item to remove |
last
Get the most recent frame(s), optionally filtered by topic.
| Option | Description |
|---|---|
<addr> | Address to connect to |
[topic] | topic filter (optional): exact, user.*, *, or a comma list |
[count] | last: number of frames to return (default: 1) |
--follow, -f | follow |
--with-timestamp | with-timestamp |
Examples:
get
Retrieve a frame by ID.
| Option | Description |
|---|---|
<addr> | Address to connect to |
<id> | ID of the frame to get |
--with-timestamp | Include RFC3339 timestamp extracted from frame ID |
import
Import a frame dump from standard input.
| Option | Description |
|---|---|
<addr> | Address to connect to |
Example:
|
eval
Evaluate a Nushell script with store helper commands available.
| Option | Description |
|---|---|
<addr> | Address to connect to ([HOST]:PORT, <PATH>, or iroh://...) |
[file] | Script file to evaluate, or "-" to read from stdin |
-c, --commands <commands> | Evaluate script from command line |
The eval command runs a Nushell script with access to store helper commands like .cat, .append, .last, .get, .cas, and .remove.
Output format auto-detection:
ByteStream→ raw bytesListStreamof structured data → JSONL streamListStreamof primitives → JSONL streamListStreamof mixed types → JSONL stream- Single
Value(string/number) → raw text - Single structured
Value→ single JSON object PipelineData::Empty→ nothing
Examples:
# Simple expression
# Math expression
# JSON output
# Script from stdin
|
# Script from file
# Using store helpers
version
Get version information from the server.
| Option | Description |
|---|---|
<addr> | Address to connect to |
nu
Manage the embedded xs.nu module.
| Option | Description |
|---|---|
--install | Install xs.nu into your Nushell config |
--clean | Remove previously installed files |
--lib-path <PATH> | Explicit path for the xs.nu library file (requires --install) |
--autoload-path <PATH> | Explicit path for the xs-use.nu autoload stub (requires --install) |
Without options the command prints the module contents so it can be redirected or piped.
Example:
The xs.nu module provides Nushell-friendly convenience functions that wrap these CLI commands with pipeline support and environment awareness. The module automatically uses $env.XS_ADDR when connecting to remote stores.
See the xs.nu reference for detailed documentation of all available functions and the Exposing Streams reference for remote connection setup.
scru128
Generate and manipulate SCRU128 IDs. SCRU128 is a sortable, clock and random number-based unique identifier.
Generate a new ID
Generate a single SCRU128 ID:
Example:
# => 03d4q1qhbiv09ovtuhokw5yxv
unpack
Unpack a SCRU128 ID into its component fields:
| Option | Description |
|---|---|
<ID> | SCRU128 ID string, or - to read from stdin |
The output is a JSON object with the following fields:
timestamp- Unix timestamp as float (milliseconds precision)counter_hi- 24-bit high counter valuecounter_lo- 24-bit low counter valuenode- 32-bit entropy/node field as hex string
Examples:
# =>
# {
# "timestamp": 1693000000.123,
# "counter_hi": 1234,
# "counter_lo": 5678,
# "node": "abcd1234"
# }
|
pack
Pack component fields into a SCRU128 ID:
Reads a JSON object from stdin with the same format as unpack output.
Example:
|
# => 03d4q1qhbiv09ovtuhokw5yxv
Round-trip example:
| |