cross.stream / docs
GitHub Discord

cli

The xs CLI provides a collection of subcommands for interacting with a cross.stream store. See Topics for naming rules and wildcards.

Usage

xs <COMMAND> [OPTIONS]

Commands

serve

Start the supervisor process.

xs serve <path> [--expose <LISTEN_ADDR>] [--fsync <POLICY>] [--ttl-sweep <MS>] [--plugin <PATH>]...
OptionDescription
<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
xs serve ./store --expose 127.0.0.1:8080

# Make plugin commands available to processors
xs serve ./store --plugin /path/to/nu_plugin_query

# Expose via iroh for peer-to-peer QUIC connections  
xs serve ./store --expose iroh://

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:

# Old behaviour: fsync on every append
xs serve ./store --fsync always

cat

Stream frames from the store.

xs cat <addr> [options]

--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.

OptionRead option
<addr>Address to connect to ([HOST]:PORT, <PATH>, or iroh://...)
--follow, -ffollow
--pulse <ms>, -p <ms>heartbeat interval for --follow
--new, -nnew
--after <id>, -a <id>after
--from <id>from
--limit <n>limit
--last <n>last
--topic <patterns>, -Ttopic: exact, user.*, *, or a comma list / Nushell list
--with-timestampwith-timestamp
--sseUse 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
xs cat ./store --follow

# Remote TCP connection
xs cat :3021 --follow

# Peer-to-peer via iroh QUIC
xs cat iroh://nodeac4lrf7r5hyq...crjpx6ajinb2hi4d --follow

See Exposing Streams reference for connection details.

append

Append an event to a topic.

xs append <addr> <topic> [options]
OptionDescription
<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-timestampInclude RFC3339 timestamp extracted from frame ID

Example:

echo "hello" | xs append ./store chat --meta '{"user":"bob"}'

cas

Retrieve content from CAS.

xs cas <addr> <hash>
OptionDescription
<addr>Address to connect to ([HOST]:PORT, <PATH>, or iroh://...)
<hash>Hash of the content to retrieve

cas-post

Store content in CAS.

xs cas-post <addr>
OptionDescription
<addr>Address to connect to

Example:

echo "content" | xs cas-post ./store

remove

Remove a frame from the store.

xs remove <addr> <id>
OptionDescription
<addr>Address to connect to
<id>ID of the item to remove

last

Get the most recent frame(s), optionally filtered by topic.

xs last <addr> [topic] [count] [--follow]
OptionDescription
<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, -ffollow
--with-timestampwith-timestamp

Examples:

xs last ./store note           # last frame for topic "note"
xs last ./store                # last frame across all topics
xs last ./store note 5         # last 5 frames for topic "note"
xs last ./store 10             # last 10 frames across all topics
xs last ./store "user.*"       # last frame matching wildcard

get

Retrieve a frame by ID.

xs get <addr> <id>
OptionDescription
<addr>Address to connect to
<id>ID of the frame to get
--with-timestampInclude RFC3339 timestamp extracted from frame ID

import

Import a frame dump from standard input.

xs import <addr>
OptionDescription
<addr>Address to connect to

Example:

cat dump.jsonl | xs import ./store

eval

Evaluate a Nushell script with store helper commands available.

xs eval <addr> [file] [-c, --commands <commands>]
OptionDescription
<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:

Examples:

# Simple expression
xs eval ./store -c '"hello world"'

# Math expression
xs eval ./store -c '2 + 3'

# JSON output
xs eval ./store -c '{name: "test", value: 42}'

# Script from stdin
echo '"from stdin"' | xs eval ./store -

# Script from file
xs eval ./store script.nu

# Using store helpers
xs eval ./store -c '"my note" | .append note'
xs eval ./store -c '.last note'
xs eval ./store -c '.cat --topic note'

version

Get version information from the server.

xs version <addr>
OptionDescription
<addr>Address to connect to

nu

Manage the embedded xs.nu module.

xs nu [--install] [--clean] [--lib-path <PATH>] [--autoload-path <PATH>]
OptionDescription
--installInstall xs.nu into your Nushell config
--cleanRemove 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:

xs nu --install

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.

xs scru128 [COMMAND]

Generate a new ID

Generate a single SCRU128 ID:

xs scru128

Example:

xs scru128
# => 03d4q1qhbiv09ovtuhokw5yxv

unpack

Unpack a SCRU128 ID into its component fields:

xs scru128 unpack <ID>
OptionDescription
<ID>SCRU128 ID string, or - to read from stdin

The output is a JSON object with the following fields:

Examples:

xs scru128 unpack 03d4q1qhbiv09ovtuhokw5yxv
# =>
# {
#   "timestamp": 1693000000.123,
#   "counter_hi": 1234,
#   "counter_lo": 5678,
#   "node": "abcd1234"
# }

echo "03d4q1qhbiv09ovtuhokw5yxv" | xs scru128 unpack -

pack

Pack component fields into a SCRU128 ID:

xs scru128 pack

Reads a JSON object from stdin with the same format as unpack output.

Example:

echo '{"timestamp":1693000000.123,"counter_hi":1234,"counter_lo":5678,"node":"abcd1234"}' | xs scru128 pack
# => 03d4q1qhbiv09ovtuhokw5yxv

Round-trip example:

xs scru128 | xs scru128 unpack | xs scru128 pack