Server runtime for the Canvas project
! Use the dev branch for now
On every iteration(refactor) of this project, I actually loose(as in - BREAK -) functionality!
We already had tab management implemented(great showcase for the bitmap-based context tree index), with named sessions and working browser extensions. I decided to slightly refactor the context? or workspace manager? don't even remember(git history would show) - 6 months later we still have no working runtime and using AI actually makes things worse!
(as we are now in an attention-based economy(creds for coining the term for me to @TechLead, I'll rant about it in some "coding-canvas" live stream session @idnc.streams soon))
Sooo
New approach: "Do The Simplest Thing That Could Possibly Work(tm)"
- No federation support
- No remote workspaces*
- Contexts bound to the canvas-server instance
Sorry Universe for the delay..
$ git clone https://github.com/canvas-ai/canvas-server /path/to/canvas-server
$ cd /path/to/canvas-server
$ npm run update-submodules
$ npm install
$ npm run dev # or
$ npm run start
$ git clone https://github.com/canvas-ai/canvas-server /path/to/canvas-server
$ cd /path/to/canvas-server
$ CANVAS_SERVER_HOME=~/.canvas docker-compose up --build
# or, to ensure you are running the latest and greatest
# $ docker-compose build --no-cache
# $ docker-compose up --force-recreate
# Cleanup
$ docker-compose down --rmi all
Supported ENV vars with their defaults:
# Runtime variables (user | standalone)
CANVAS_SERVER_MODE: ${CANVAS_SERVER_MODE:-"standalone"}
# Canvas server dirs
NODE_ENV: ${NODE_ENV:-development}
CANVAS_SERVER_HOME: ${CANVAS_SERVER_HOME:-/opt/canvas-server/server}
CANVAS_USER_HOME: ${CANVAS_USER_HOME:-/opt/canvas-server/users}
CANVAS_ADMIN_EMAIL: ${CANVAS_ADMIN_EMAIL:-admin@canvas.local}
CANVAS_ADMIN_PASSWORD: ${CANVAS_ADMIN_PASSWORD:-$(openssl rand -base64 16)}
CANVAS_ADMIN_RESET: ${CANVAS_ADMIN_RESET:-false}
CANVAS_DISABLE_API: ${CANVAS_DISABLE_API:-false}
CANVAS_API_PORT: ${CANVAS_API_PORT:-8001}
CANVAS_API_HOST: ${CANVAS_API_HOST:-0.0.0.0}
CANVAS_JWT_SECRET: ${CANVAS_JWT_SECRET:-$(openssl rand -base64 16)}
CANVAS_JWT_TOKEN_EXPIRY: ${CANVAS_JWT_TOKEN_EXPIRY:-7d}
# Canvas USER dirs for single-user mode
# See env.js for more info
- Rename example-*.json to *.json and amend as needed
- Configuration files can be split into multiple files adhering to the original JSON structure
- config/data.json maybe be split into config/data.backends.json, config/data.sources.json etc
When the Canvas server starts for the first time, it can automatically create an initial admin user if no users exist in the database. This is controlled by environment variables:
- Set
CANVAS_ADMIN_EMAIL
to the desired admin email (defaults to '[email protected]') - Set
CANVAS_ADMIN_PASSWORD
to the desired admin password (required if admin creation is enabled)
Example:
# In .env file or environment variables
[email protected]
CANVAS_ADMIN_PASSWORD=securepassword
CANVAS_ADMIN_RESET=false # Reset admin pass
$ cd /path/to/canvas-server
# Stop the canvas server
$ npm run stop # or npm run pm2:stop
$ rm -rf ./node_modules # Ensure we have a clean slate
# Fetch the latest version of canvas-server from Github
$ git pull origin main # or dev if you are feeling adventurous
$ npm run update-submodules
$ npm install
$ npm start # or npm run pm2:start
# Copy the .env.example file
$ cp /path/to/canvas-server/src/ui/.env.example /path/to/canvas-server/src/ui/.env
# Edit as needed, for a local setup you'd want to use your machines hostname or FQDN(if resolvable) or its local IP
# Rebuild the web ui
$ npm run build
# Restart the server
build-portable-image.sh
: Builds a Docker image for the Canvas Server with a portable configuration.
install-ubuntu.sh
: Installs and sets up the Canvas Server on an Ubuntu system. It installs Node.js, clones the Canvas Server repository, and sets up the service.
update-git.sh
: Script updates the Canvas Server by pulling the latest changes from the git repository and restarting the service.
update-submodules.sh
: Pushes git submodule changes to a remote git repository
Canvas Server supports two types of authentication:
- JWT Token Authentication: Used for web UI login and normal user sessions, see
- API Token Authentication: Used for programmatic access (CLI, Electron, browser extensions, curl-based scripts)
- Canvas Server API Reference - Complete REST API and WebSocket documentation