weft-loom-server

module
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: BSD-3-Clause

README

weft-loom-server

weft-loom-server

Collaborative editor + sandboxed compile, openweft-native. One server hosts multi-user editing for any language CodeMirror has a lang pack for (LaTeX, Markdown, Go, C++, Python, Rust, JS, …) and dispatches compile jobs to ephemeral microVMs via weft-agent. Auth via dex.

Conceptually : Overleaf, but generic + microVM-native instead of Docker, + openweft SSO.

Features

Editing
  • WYSIWYG, source, and split modes ; toggle live
  • vim / emacs keymaps (CodeMirror 6 keymap packs)
  • Track changes : per-author insert/delete decorations, accept/reject
  • Inline comments anchored on selection ranges (Yjs-backed)
  • @-mentions in comments — server fans out an email if SMTP is wired
  • Format painter : copy character/paragraph attributes, paint elsewhere
  • LaTeX symbol palette (search Unicode + LaTeX names)
  • Bibliography style picker (.bst file from refs/ ; live preview)
  • Snippets : per-project user-defined LaTeX abbreviations
  • Outline panel : section/subsection tree, click-to-jump
  • Save indicator : pending / saving / saved / error states
Collaboration
  • Yjs CRDT realtime sync over a y-websocket relay
  • Presence cursors with per-user colour + name
  • Project sharing with roles : editor, commenter, viewer
  • Public read-only links (revocable token URL, no login required)
  • Email notifications on @-mention in comments (SMTP, async)
Bibliography
  • Zotero sync : userID + API key in Settings, one-click pull to refs.bib
  • DOI import : paste a DOI in BibPanel, server resolves and appends
  • arXiv search : query, pick, append BibTeX entry
  • .bst style picker influences the live PDF preview
Project lifecycle
  • Templates gallery (LaTeX article, Beamer, Markdown book, Go module, …)
  • Clone via git : HTTPS URL → working copy with weft-loom sidecars
  • Rename project (✎ button in ProjectSwitcher ; sidecars travel)
  • Export / import .zip (round-trips a project including .weft-loom/)
Build
  • Compile cancel : SSE-aware kill switch on the running job
  • Compiler selection : per-project engine (pdflatex / xelatex / lualatex / …)
  • Live PDF preview pane with page thumbnails
  • SyncTeX forward (source → PDF) and inverse (PDF click → source line)

Status (v0.14+)

  • ✅ y-websocket relay (in-memory rooms, broadcast fan-out, slow-peer drop)
  • ✅ Project file store (LocalStore or Postgres metadata + shared block volume)
  • ✅ Compile orchestration via ephemeral microVMs (weft-agent dispatch ; QEMU dev backend)
  • ✅ HTTP / WebSocket / SSE server (cobra CLI, slog→NATS via weft-slognats)
  • ✅ Auth abstraction (StaticVerifier for dev ; dex / OIDC for prod)
  • ✅ huma-typed API — OpenAPI 3.1 spec at /api/openapi, interactive docs at /api/docs (auto-generated from Go handler annotations)
  • ✅ Svelte 5 + daisyUI 5 + Tailwind 4 frontend — full editor : tree, tabs, PDF preview, terminals, LSP, git, history, sharing dialogs
  • ✅ Typed TS client — task gen-api regenerates from huma spec

Architecture

Browser
  ├─ CodeMirror 6 (lang packs per language)
  ├─ Yjs (CRDT)
  └─ y-codemirror.next + y-websocket
        │ WebSocket (binary y-protocol)
        ▼
weft-loom-server (Go, CGO=0, pure-Go)
  ├─ ywebsocket.Hub : in-memory rooms, broadcast relay
  ├─ project.Store : LocalStore (FS) or Postgres+block volume
  ├─ compile.Service : gRPC/NATS → weft-agent → ephemeral microVM
  ├─ workspace.Backend : QEMU (dev) / microVM via weft-agent (prod)
  ├─ auth.Verifier : OIDC bearer verification (dex JWKS)
  ├─ history.Store : per-project edit timeline + restore
  ├─ email.Sender : SMTP, fires on @-mention notifications
  └─ http.ServeMux : huma-typed routes + SPA + y-websocket
Why a relay (and not a server-side CRDT)
  • the y-protocols wire format is binary + versioned ; a relay is forward-compatible with new protocol versions for free
  • a server-side Go Yjs impl is a several-thousand-line project on its own
  • relay-only is the deployment mode the upstream y-websocket server uses too
  • persistence (snapshot CRDT state to disk every N minutes) bolts on as a separate concern
Why microVMs (and not Docker)
  • openweft policy : every compute is a microVM (~180 ms cold boot, full kernel isolation)
  • per-language images (weft-loom-texlive, weft-loom-golang, weft-loom-cpp, …) pulled by weft-agent like any other openweft driver/HA image
  • compile job = mount project files RO + scratch overlay, run command, stream stdout/stderr, ship artifact

API documentation

The server exposes its full surface as an OpenAPI 3.1 document, auto- generated by huma from the Go handler annotations — there is no separate spec file to keep in sync.

  • GET /api/openapi — raw JSON spec
  • GET /api/docs — interactive viewer (Stoplight Elements)

Use the docs page to discover and try every endpoint (projects, files, sharing, public-share, snippets, history, bib, git, compile, admin). The TS client (web/src/lib/api.gen.ts) is regenerated from this same spec via task gen-api.

Quick start

Dev (single binary, embedded NATS)
cat > config.dev.hcl <<EOF
listen       = ":8080"
storage_root = "./tmp-projects"
EOF
WEFT_LOOM_NATS_ALLOW_NOAUTH=1 go run ./cmd/weft-loom serve --config ./config.dev.hcl

The embedded NATS broker requires authorization: give loom-server an nkey user seed by reference (WEFT_LOOM_NATS_NKEY_SEED_FROM=<ref>), or, for development only, set WEFT_LOOM_NATS_ALLOW_NOAUTH=1 (logged as an error at start-up). See the admin guide.

Open http://localhost:8080. Two browser tabs on the same project = collab editing. The SPA is embedded via //go:embed ; no Vite proxy needed when using the prod-built binary.

For frontend hot-reload :

cd web && npm install && npm run dev   # Vite on :5173, proxies to :8080
Docker Compose
services:
  loom:
    image: ghcr.io/openweft/weft-loom-server:latest
    ports: ["8080:8080"]
    environment:
      WEFT_LOOM_STORAGE_ROOT: /var/lib/weft-loom
      WEFT_NATS_URL:          nats://nats:4222
      WEFT_LOOM_NATS_NKEY_SEED_FROM:   file:/run/secrets/loom_nkey_seed
      WEFT_LOOM_NATS_CALLOUT_SEED_FROM: file:/run/secrets/loom_callout_seed
      WEFT_LOOM_SMTP_HOST:    smtp.example.org
      WEFT_LOOM_SMTP_PORT:    "587"
      WEFT_LOOM_SMTP_USER:    notify@example.org
      WEFT_LOOM_SMTP_PASS_FROM: file:/run/secrets/smtp_pass
      WEFT_LOOM_SMTP_FROM:    "weft-loom <notify@example.org>"
    volumes:
      - loom-data:/var/lib/weft-loom
    secrets: [loom_nkey_seed, loom_callout_seed]
    depends_on: [nats]

  nats:                       # holds public keys only; see openweft/weft-nats
    image: ghcr.io/openweft/weft-nats:v2.12.15
    volumes:
      - nats-data:/data
    secrets:
      - source: weft_nats_keys
        target: /etc/weft-nats/keys.conf

secrets:
  loom_nkey_seed:    { file: ./secrets/loom.seed }     # mode 0600
  loom_callout_seed: { file: ./secrets/callout.seed }  # mode 0600
  weft_nats_keys:    { file: ./secrets/keys.conf }

volumes:
  loom-data:
  nats-data:

The external broker has no anonymous user. loom-server connects with its nkey and answers the broker's auth callout, so each workspace VM gets its own credential limited to its own subjects. The two seeds are generated once (nk -gen user, nk -gen account); setup in the weft-nats README.

systemd
[Unit]
Description=weft-loom-server
After=network-online.target nats.service
Wants=network-online.target

[Service]
Type=simple
ExecStart=/usr/local/bin/weft-loom serve --config /etc/weft-loom/config.hcl
Environment=WEFT_LOOM_STORAGE_ROOT=/var/lib/weft-loom
Environment=WEFT_NATS_URL=nats://127.0.0.1:4222
Environment=WEFT_LOOM_NATS_NKEY_SEED_FROM=systemd-creds:loom-nkey-seed
Environment=WEFT_LOOM_NATS_CALLOUT_SEED_FROM=systemd-creds:loom-callout-seed
LoadCredentialEncrypted=loom-nkey-seed
LoadCredentialEncrypted=loom-callout-seed
EnvironmentFile=-/etc/weft-loom/smtp.env
Restart=on-failure
User=weft-loom

[Install]
WantedBy=multi-user.target

See docs/USER_GUIDE.md and docs/ADMIN_GUIDE.md for feature-by-feature walkthroughs and the full env var reference.

Configuration

Minimal HCL (see config.example.hcl for the annotated full sample) :

listen       = ":8080"
storage_root = "/var/lib/weft-loom"

oidc {
  issuer    = "https://dex.weft.svc/"
  client_id = "weft-loom"
}

compile {
  timeout = "5m"
}

# Optional : path to weft-agent's socket. Empty = compile stub.
weft_agent_socket = "/run/weft-agent.sock"

Most runtime knobs (SMTP, NATS, workspace backend, LSP overrides) are env vars — see docs/ADMIN_GUIDE.md.

Secrets (WEFT_CUBEFS_SECRET_KEY, WEFT_CUBEFS_ACCESS_KEY, ANTHROPIC_API_KEY, WEFT_LOOM_SMTP_PASS) are taken by reference: set <VAR>_FROM=systemd-creds:<name> (or keychain:, keepassxc:, file:) instead of the plaintext variable, which is deprecated and warns on stderr.

License

BSD 3-Clause — see LICENSE.

Directories

Path Synopsis
cmd
fake-lsp command
fake-lsp is a deterministic LSP-like subprocess used by tests/lsp-bridge integration tests.
fake-lsp is a deterministic LSP-like subprocess used by tests/lsp-bridge integration tests.
weft-loom command
Command weft-loom is the Sovereign Collaborative Edition server.
Command weft-loom is the Sovereign Collaborative Edition server.
internal
auth
Package auth bridges OIDC (dex) bearers to a typed Identity passed through req.Context.
Package auth bridges OIDC (dex) bearers to a typed Identity passed through req.Context.
compile
Package compile orchestrates ephemeral compile jobs.
Package compile orchestrates ephemeral compile jobs.
config
Package config parses weft-loom's HCL configuration file.
Package config parses weft-loom's HCL configuration file.
devagent
Package devagent is the in-process mock of weft-microvm-agent we run inside loom-server when no real workspace VM is reachable.
Package devagent is the in-process mock of weft-microvm-agent we run inside loom-server when no real workspace VM is reachable.
email
Package email delivers user-facing notifications over SMTP.
Package email delivers user-facing notifications over SMTP.
eventbus
Package eventbus is loom-server's in-memory observability fan-out.
Package eventbus is loom-server's in-memory observability fan-out.
history
Package history persists per-file text-snapshot timelines so users can scrub back through edits + restore prior versions.
Package history persists per-file text-snapshot timelines so users can scrub back through edits + restore prior versions.
lintchktex
Package lintchktex shells out to the standalone `chktex` binary to surface strict LaTeX style diagnostics on top of what texlab already reports through the LSP bridge.
Package lintchktex shells out to the standalone `chktex` binary to surface strict LaTeX style diagnostics on top of what texlab already reports through the LSP bridge.
lsp
Package lsp bridges a WebSocket carrying JSON-RPC LSP messages to a language-server subprocess's stdio.
Package lsp bridges a WebSocket carrying JSON-RPC LSP messages to a language-server subprocess's stdio.
natsbroker
Package natsbroker is the embedded NATS server loom-server boots when WEFT_NATS_URL isn't externally provided (single-binary deployments; the workspace VM's agent dials back into the host).
Package natsbroker is the embedded NATS server loom-server boots when WEFT_NATS_URL isn't externally provided (single-binary deployments; the workspace VM's agent dials back into the host).
project
Package project owns project-file storage.
Package project owns project-file storage.
secretenv
Package secretenv lets a secret that used to be an environment variable be given by reference instead.
Package secretenv lets a secret that used to be an environment variable be given by reference instead.
synctex
Package synctex parses TeX's synctex.gz output and answers the two queries the editor needs :
Package synctex parses TeX's synctex.gz output and answers the two queries the editor needs :
web
Package web embeds the built SPA bundle under dist/.
Package web embeds the built SPA bundle under dist/.
workspace
Package workspace owns the per-user microVM that the loom-server shells + compile jobs run in.
Package workspace owns the per-user microVM that the loom-server shells + compile jobs run in.
tools
dump-openapi command
Command dump-openapi writes the live OpenAPI 3.1 spec to stdout.
Command dump-openapi writes the live OpenAPI 3.1 spec to stdout.

Jump to

Keyboard shortcuts

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