Overview
Two companion packages to the core SDK:@struktoai/mirage-server, a Fastify daemon that owns workspaces in-process and exposes them over HTTP (/v1/workspaces,/v1/jobs, …).@struktoai/mirage-cli, acommanderCLI that speaks to the daemon. Mirrors Python’smirageCLI 1:1.
mirage workspace create if none is running.
Install
@struktoai/mirage-server transitively (the CLI spawns the daemon from the server package’s installed bin/daemon.js).
Create a workspace
Write a YAML config:- Validates the YAML + interpolates
${VAR}env references (fails fast if any are missing). - Auto-spawns a daemon on
127.0.0.1:8765if none is reachable. - Sends
POST /v1/workspacesand prints the returned detail as JSON.
Run commands in a workspace
Workspace lifecycle
| Command | Purpose |
|---|---|
mirage workspace create <config.yaml> | Create; auto-spawns daemon if needed. |
mirage workspace list | List active workspaces. |
mirage workspace get <id> [--verbose] | Show one workspace’s detail. |
mirage workspace delete <id> | Stop and remove. |
mirage workspace clone <src> [--id NEW] [--at REF] | New workspace from the source; --at REF clones a past version, else the live state. |
mirage workspace snapshot <id> <out.tar> | Snapshot to tar. |
Versioning
Each workspace has a git-backed history kept by the daemon (under~/.mirage/repos/<id>; set MIRAGE_VERSION_ROOT to relocate). Same verbs and
semantics as the Python CLI.
| Command | Purpose |
|---|---|
mirage workspace commit <id> [-m MSG] [-b BRANCH] | Commit the live state as a version. |
mirage workspace log <id> [-b BRANCH] | List versions on a branch, newest first. |
mirage workspace diff <id> [a] [b] [-b BRANCH] | Changed paths (added/modified/deleted). |
mirage workspace branch <id> <name> [--from BRANCH] | Fork a branch at a branch’s current version. |
mirage workspace checkout <id> <ref> | Restore the live state in place to a version or branch. |
Sessions
Daemon lifecycle
Configuration
Precedence (highest first):MIRAGE_DAEMON_URLenv var, e.g.http://127.0.0.1:9000.MIRAGE_TOKENenv var, bearer token passed asAuthorization: Bearer <token>.~/.mirage/config.toml[daemon]table:
Python parity
The daemon speaks the same/v1/... protocol as Python’s mirage CLI. A Python CLI client can talk to a Node daemon and vice versa. The CLI subcommand tree matches Python’s mirage/cli/*.py file-for-file.
Where things live
| File | Purpose |
|---|---|
packages/server/src/app.ts | Fastify app factory. |
packages/server/src/routers/ | health / workspaces / sessions / execute / jobs. |
packages/server/src/bin/daemon.ts | mirage-daemon bin. |
packages/cli/src/main.ts | CLI program wiring. |
packages/cli/src/{workspace,session,execute,provision,job,daemon}.ts | Per-subcommand modules. |
packages/cli/src/client.ts | HTTP client + auto-spawn. |