any

module
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 19, 2026 License: MIT

README

Any

  • local-first, e2e encrypted multiplayer database with HTTP interface
  • sync engine on top of any-sync, which has been battle-tested on our infra for many years and millions of spaces and passed a security audit by Cure53.
  • mongo query language support, including aggregation framework via any-store
  • full-text search, semantic search with HNSW/ivfsq index types, hybrid search.
  • local vector embedding via llama.cpp.

Any runs a local server on each user's device. Applications connect to it through a localhost HTTP API to store data, run queries, and subscribe to changes. Devices sync through end-to-end encrypted peer-to-peer (P2P) connections.

Its companion runtime, anyrt, lets programs and agents live in the same database as the data they work with. The agent harness is designed for long-lived sessions, with persistent memory and direct access to the database's structured data. any-rt compliments any with:

  • isolated CPython programs on top of Wasmtime with deterministic traces and fuel control
  • CRON-like triggers, event subscriptions

Reads and writes to local data work offline. When devices reconnect, their changes merge automatically using CRDTs. Devices exchange changes directly or through sync nodes, which store and relay encrypted content without being able to read it.

This repository packages the database server and CLI as one any binary. The agent runtime runs alongside the server, acting as a client.

The database, search, identity, and sync are built in. You choose the models and control your data and agent memory.

What you can build

Any is a general-purpose database -- it doesn't constrain which applications can be built on top of it.

However, some of the features are way easier to build on top of Any.

One of the strongest of such features is multiplayer collaboration. It is quite hard to solve the problem of [agentic] concurrent write consistency due to the central transaction architecture of databases: concurrent actors rewrite each other's data without history.

We give convenient tooling to organize conflict-free data access with CRDT eventual consistency guarantees, a changes history API and a safe model of mutating object properties in collaborative environments.

We have support for custom CRDT types (via any-sync-sdk) and some complex CRDT implementations, such as block-based editor and chat with distributed counters support -- i.e. we provide collaborative block-based editor and local-first, encrypted p2p chat primitives out of the box.

One of the examples of apps which shows editor, chat and collaborative features is any-ui -- modern agentic knowledge-base tool.

[!WARNING] Developer preview. Use a separate account for experiments. APIs and data formats can change without migration; do not use an account containing data you cannot afford to lose.

Quickstart

This example builds from source and creates a notebook in a dedicated data directory. It uses local embeddings.

You need Git, Go 1.26.2 or newer, make, curl, and jq. For release packages and platform-specific prerequisites, see Installation.

1. Build
git clone https://github.com/anyproto/any.git
cd any
make build

The binary is written to bin/any. This build includes the local embedder and attempts to fetch the llama.cpp libraries it needs. If that download fails, retry with make llamacpp. A plain go install github.com/anyproto/any/cmd/any@latest has no local embedder: it does full-text search, and vector search once index.openai.* names an online provider. See Installation.

2. Create an account and start the server

Unless configured otherwise, the server joins the production any-sync network. To use a different network, choose it before starting the account and use a separate data directory. See Networks.

From the repository directory:

export ANY_DATA_DIR="$HOME/.any-demo"
export ANY_INDEX_EMBEDDER=local

./bin/any init
./bin/any run

init creates an account in the new data directory and prints its recovery phrase. Save it: restoring on another device requires that phrase. Repeating init in this directory keeps the existing account and lists it instead.

Wait for LISTENING 127.0.0.1:7001, then leave the server running. The local embedding model downloads separately on first use of a fresh model cache; you can create and query data while it downloads.

3. Create a document

In a second terminal, create a space—a collection of objects shared with the same members—and a page inside it:

API=http://127.0.0.1:7001/v1

SPACE=$(curl -fsS "$API/spaces" \
  -H 'Content-Type: application/json' \
  -d '{"name":"Notebook"}' | jq -er '.id')

OBJECT=$(curl -fsS "$API/spaces/$SPACE/objects" \
  -H 'Content-Type: application/json' \
  -d '{"type":"page","initialProperties":{"any":{"name":"Reading list"}}}' \
  | jq -er '.objectId')

printf 'Created page: %s\n' "$OBJECT"

The page type gives the object an editor document. any.name is its title.

4. Query and subscribe

In that same terminal, query the pages in your space:

curl -fsS "$API/spaces/$SPACE/objects/query" \
  -H 'Content-Type: application/json' \
  -d '{"filter":{"any.type":"page"},"sort":["-modifiedAt"],"limit":20}' | jq

The response's records array includes your Reading list page. To keep that query live, open the matching subscription:

curl -fsSN "$API/spaces/$SPACE/objects/query/subscribe" \
  -H 'Content-Type: application/json' \
  -d '{"filter":{"any.type":"page"},"sort":["-modifiedAt"],"limit":20}'

The stream sends ready, then a snapshot of the current records, followed by changes as the results change. Ctrl-C closes the subscription. To stop the server, press Ctrl-C in the first terminal.

Continue with the objects tutorial to work with objects and add your own properties.

Embedding modes

The quickstart explicitly selects local. The server's built-in default is auto, which is the local model until an index.openai.apiKey is configured; configuration files or environment variables can override it.

Mode Where embedding inputs go
local A local llama.cpp worker. Model files may be downloaded, but document text and queries are embedded on the device.
auto The local model alone with no index.openai.apiKey; with one, the configured online endpoint first and the local model as fallback. A build without the local embedder needs that key to embed at all.
none No embeddings; full-text search remains available.

See Embedders for model settings, Ollama, and other compatible providers.

Data and access

  • Local API: the server binds to loopback and does not authenticate callers. Local processes can access the API as the active account.
  • Account storage: standalone mode stores the recovery phrase and device key in wallet.key. Set ANY_WALLET_PASSKEY before initializing an account to encrypt its wallet; supply the same passkey when starting the server.
  • Second devices: restore from the recovery phrase with ./bin/any init --mnemonic-stdin. Do not copy wallet.key: that also copies the device identity and interferes with sync.
  • Data location: the example uses ~/.any-demo/; the normal default is ~/.any/. Treat the directory as private account data.

See Server lifecycle for account modes and storage, and Configuration for file, environment, and flag precedence.

Documentation

The server builds on any-sync-sdk. For programs and agents, see the separate anyrt runtime, which can run alongside this server or inside the Any desktop application.

License

Any is open source under the MIT license (LICENSE). You can use, modify and distribute it in personal and commercial applications, provided you retain the copyright and license notice. Third-party dependencies and models retain their respective licenses.

Directories

Path Synopsis
Package anyuri builds and parses any:// URIs — the canonical string convention for referencing anything inside any: an object, a dataset record, an identity (mention), a space, a property value, a file.
Package anyuri builds and parses any:// URIs — the canonical string convention for referencing anything inside any: an object, a dataset record, an identity (mention), a space, a property value, a file.
cmd
any command
anydocs command
Command anydocs renders the website/ markdown tree into a static HTML site.
Command anydocs renders the website/ markdown tree into a static HTML site.
internal
api
bin
Package bin registers the built-in `bin` collection: the marker of an object moved to the bin.
Package bin registers the built-in `bin` collection: the marker of an object moved to the bin.
bundles
Package bundles wires the HTTP bundles surface onto the SDK's per-space bundles registry (any-sync-sdk docs/bundles.md).
Package bundles wires the HTTP bundles surface onto the SDK's per-space bundles registry (any-sync-sdk docs/bundles.md).
catalog
Package catalog loads and validates the usecase catalog embedded in the binary (catalog.yml): the server's well-known bundles, grouped into usecases a client sets up with one call, dependencies included.
Package catalog loads and validates the usecase catalog embedded in the binary (catalog.yml): the server's well-known bundles, grouped into usecases a client sets up with one call, dependencies included.
catalog/cmd/catalog-validate command
catalog-validate checks the usecase catalog embedded in the binary and any candidate files given as arguments, printing one line per problem (`<source>: <path>: <code>: <message>`) and exiting 1 on any.
catalog-validate checks the usecase catalog embedded in the binary and any candidate files given as arguments, printing one line per problem (`<source>: <path>: <code>: <message>`) and exiting 1 on any.
chat
Package chat defines the built-in `chat` type — a CRDT-backed stream of messages stored as one record per message on a per-object `chat_messages` dataset.
Package chat defines the built-in `chat` type — a CRDT-backed stream of messages stored as one record per message on a per-object `chat_messages` dataset.
cli
dataview
Package dataview registers the built-in `dataview` type — saved views over a set of objects, in two levels: a dataview object hosts many DATAVIEWS, each with its own VIEWS.
Package dataview registers the built-in `dataview` type — saved views over a set of objects, in two levels: a dataview object hosts many DATAVIEWS, each with its own VIEWS.
editor
Package blocks defines the built-in `editor_blocks` dataset and its per-record CRDT handler.
Package blocks defines the built-in `editor_blocks` dataset and its per-record CRDT handler.
embedded
Package embedded is the shared, build-tag-free lifecycle core for embedding the `any` HTTP server inside a host process.
Package embedded is the shared, build-tag-free lifecycle core for embedding the `any` HTTP server inside a host process.
index
Package index defines the consumer-side chunker contract: the bridge between the SDK's per-space change feed and the search indexer (internal/indexer).
Package index defines the consumer-side chunker contract: the bridge between the SDK's per-space change feed and the search indexer (internal/indexer).
indexer
Package indexer is the phase-2 consumer of the chunker contract in internal/index (docs/13-index.md): a background service that keeps a local any-store database with a BM25 full-text index and an IVF-SQ vector index per space, fed from the SDK's per-space change feed (Space.Changes()), and a hybrid (RRF) search over both.
Package indexer is the phase-2 consumer of the chunker contract in internal/index (docs/13-index.md): a background service that keeps a local any-store database with a BM25 full-text index and an IVF-SQ vector index per space, fed from the SDK's per-space change feed (Space.Changes()), and a hybrid (RRF) search over both.
localstore
Package localstore is the naming, existence and tag fence for the server's device-local any-store collections (task-local-store.md).
Package localstore is the naming, existence and tag fence for the server's device-local any-store collections (task-local-store.md).
markdown
Package markdown is the lossless markdown import/export surface over the editor_blocks dataset (internal/editor).
Package markdown is the lossless markdown import/export surface over the editor_blocks dataset (internal/editor).
miniapp
Package miniapp registers the built-in `miniapp` collection: the marker an object carries to run an installed bundle.
Package miniapp registers the built-in `miniapp` collection: the marker an object carries to run an installed bundle.
page
Package page registers the built-in `page` type: the plain document.
Package page registers the built-in `page` type: the plain document.
push
Package push runs the account's client side of push notifications: device-token persistence + registration with the push node, the subscription sync loop (desired-topic reconcile → SubscribeAll full replace), and a buffered notify queue so HTTP handlers never block on the push server.
Package push runs the account's client side of push notifications: device-token persistence + registration with the push node, the subscription sync loop (desired-topic reconcile → SubscribeAll full replace), and a buffered notify queue so HTTP handlers never block on the push server.
server
Package server implements the HTTP/JSON API for any-sync-sdk.
Package server implements the HTTP/JSON API for any-sync-sdk.
mobile
ios command
Package main is the C-archive surface that embeds the `any` engine in an iOS app.
Package main is the C-archive surface that embeds the `any` engine in an iOS app.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL