Skip to content
Merged

Sync #122

Show file tree
Hide file tree
Changes from 61 commits
Commits
Show all changes
63 commits
Select commit Hold shift + click to select a range
7af3844
Updated web submodule reference
idncsk Jun 22, 2025
8bdcf3b
submodule update
idncsk Jun 24, 2025
101c66c
Updated browser submodule reference
idncsk Jun 24, 2025
60956f2
sync
idncsk Jun 24, 2025
e72716a
smallish update to the client context
idncsk Jun 24, 2025
23a29d0
Updated web submodule reference
idncsk Jul 8, 2025
2ec1202
finally some time to code..refactor commit v1
idncsk Jul 12, 2025
4e3e7f0
finally some time to code..refactor commit v1.1
idncsk Jul 12, 2025
02976d1
Updated web submodule reference
idncsk Jul 12, 2025
a0e82c5
finally some time to code..refactor commit v1.2
idncsk Jul 12, 2025
afe0568
Cosmetics
idncsk Jul 12, 2025
293d0bd
Updated web submodule reference
idncsk Jul 12, 2025
7c73daf
Updated browser submodule reference
idncsk Jul 12, 2025
cb0dc55
Updated web submodule reference
idncsk Jul 12, 2025
c86e528
finally some time to code..refactor commit v2.0
idncsk Jul 12, 2025
7e71c0b
finally some time to code..refactor commit v2.1
idncsk Jul 12, 2025
db1d0cc
finally some time to code..refactor commit v2.2
idncsk Jul 13, 2025
198faa9
Updated browser submodule reference
idncsk Jul 13, 2025
c22822d
Updated web submodule reference
idncsk Jul 13, 2025
f10b3bb
early morning sync
idncsk Jul 13, 2025
1398290
Updated cli submodule reference
idncsk Jul 13, 2025
7ecb93c
sync
idncsk Jul 13, 2025
e8e7161
Updated cli submodule reference
idncsk Jul 13, 2025
23749ae
auth service connection fix
idncsk Jul 13, 2025
023f857
make userid lowercase again
idncsk Jul 14, 2025
9e2a9a1
Pre-refactor sync
idncsk Jul 16, 2025
f908c24
Updated cli submodule reference
idncsk Jul 16, 2025
a600798
Updated cli submodule reference
idncsk Jul 16, 2025
843f7f2
Refactor sync
idncsk Jul 16, 2025
1437ccb
API Design revert + update!
idncsk Jul 16, 2025
03b2945
Updated cli submodule reference
idncsk Jul 16, 2025
c92e4db
Updated cli submodule reference
idncsk Jul 16, 2025
acea50f
Updated cli submodule reference
idncsk Jul 16, 2025
5df7596
setContextUrl qf v2
idncsk Jul 16, 2025
1f8fa75
ContextManager qf
idncsk Jul 16, 2025
3477532
cosmetics
idncsk Jul 16, 2025
3aeacd9
submodule update
idncsk Jul 16, 2025
ed78144
Updated browser submodule reference
idncsk Jul 16, 2025
d4cc95a
Updated browser submodule reference
idncsk Jul 16, 2025
7a055c6
Updated cli submodule reference
idncsk Jul 17, 2025
b30441c
Updated cli submodule reference
idncsk Jul 17, 2025
e07857b
browser extension vibe-rewrite test v1
idncsk Jul 19, 2025
9c66caf
Updated browser submodule reference
idncsk Jul 19, 2025
2388d3c
browser extension vibe-rewrite test v1.1
idncsk Jul 19, 2025
bc4e719
browser extension vibe-rewrite test v1.2
idncsk Jul 19, 2025
ea08b53
browser extension vibe-rewrite test v1.3
idncsk Jul 19, 2025
e9cb16b
submodule update
idncsk Jul 19, 2025
db29fbc
submodule update
idncsk Jul 19, 2025
2495afd
browser extension vibe-rewrite test v1.4
idncsk Jul 19, 2025
674baf6
browser extension vibe-rewrite test v1.5
idncsk Jul 19, 2025
46438b0
Cleanup
idncsk Jul 19, 2025
0a93617
Updated browser submodule reference
idncsk Jul 19, 2025
0c5dd64
Updated browser submodule reference
idncsk Jul 19, 2025
0b60877
Rename browser submodule from src/ui/browser to src/ui/browser-extension
idncsk Jul 19, 2025
c03f72e
Updated web submodule reference
idncsk Jul 19, 2025
ddc3f69
Updated web submodule reference
idncsk Jul 19, 2025
5a97d3a
Updated browser-extension submodule reference
idncsk Jul 20, 2025
2201076
small svc update
idncsk Jul 20, 2025
286de27
Updated web submodule reference
idncsk Jul 20, 2025
30054d0
Updated web submodule reference
idncsk Jul 20, 2025
fe0a865
Updated web submodule reference
idncsk Jul 20, 2025
dc96774
regexp qf + submodule update
idncsk Jul 25, 2025
b6d20a3
submodule update
idncsk Jul 25, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .cursor/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
FROM node:20-bullseye

# Install system dependencies for LMDB and development tools
RUN apt-get update && apt-get install -y \
build-essential \
python3 \
python3-pip \
git \
curl \
wget \
vim \
nano \
htop \
tree \
jq \
liblmdb-dev \
pkg-config \
&& rm -rf /var/lib/apt/lists/*

# Install global Node.js development tools
RUN npm install -g \
nodemon \
pm2 \
typescript \
ts-node \
eslint \
prettier

# Create a non-root user for development
RUN useradd -m -s /bin/bash ubuntu && \
usermod -aG sudo ubuntu && \
echo 'ubuntu ALL=(ALL) NOPASSWD:ALL' >> /etc/sudoers

# Set up the working directory
USER ubuntu
WORKDIR /home/ubuntu

# Set environment variables
ENV NODE_ENV=development
ENV PATH="/home/ubuntu/.local/bin:${PATH}"

# Create common directories
RUN mkdir -p /home/ubuntu/.npm-global && \
mkdir -p /home/ubuntu/.cache && \
mkdir -p /home/ubuntu/workspace

# Configure npm to use the global directory
RUN npm config set prefix '/home/ubuntu/.npm-global'
ENV PATH="/home/ubuntu/.npm-global/bin:${PATH}"

# Set the default shell to bash
SHELL ["/bin/bash", "-c"]
6 changes: 6 additions & 0 deletions .cursor/environment.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"build": {
"context": ".",
"dockerfile": "Dockerfile"
}
}
100 changes: 100 additions & 0 deletions .cursor/prompts/20250715-160300.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
# Resource address schema refactor

We are implementing a common resource address schema for canvas: [user.name]@[remote-or-remote-alias]:[resource][optional path]
This schema is to be used on all canvas-server clients(cli, electron ui, whatever rust/go or python based canvas roles the user decides to run locally)

Examples:
userfoo@canvas.local:workspace1
userbar@canvas.remote:context-foo
userbaz@work.tld:workspace-baz/shell/bash # Dotfile reference when called with canvas dot
userbas@workmachine:workspace-baf/foo/bar/baf # When called with canvas context

We'll use a common configuration store for all our client applications, by default in
~/.canvas/config

Minimal acceptable protection:
- file permissions (chmod 600) and perhaps ~/.canvas/credentials.json separate from config for easier secrets handling but we are in MVP territory so not sure about spliting it off yet/as-of-now
- For future, we can support OS keyrings.

Local configuration should use the following files/schemas:
```
/remotes.json
{
"user@remote-shortname":{
url: https://full-canvs-server-url:port/
apiBase: /rest/v2
description: optional description
auth:
"method": "token|password|oauth2|oidc",
"tokenType": "jwt",
"token": "..."
},
lastSynced: timestamp-of-last-full-sync
}
}
/contexts.json
{
"user@remote-shortname:context_id": {
url
...context object we get from remote canvas-server api when listing contexts/updating/creating individual contexts
lastSynced: timestamp-of-last-sync
}
}

/workspaces.json
{
"user@remote-shortname:workspace_id": {
...workspace object we get from remote canvas-server api when listing workspaces/updating/creating individual workspaces
lastSynced: timestamp-of-last-sync
}
}
/session-cli.json
{
boundRemote: user.name@remote-shortname
defaultWorkspace: user@remote-shortname:workspace_id, optional
boundContext: user@remote-shortname:context_id, optional
boundAt: timestamp
}
```

Every canvas-server instance holds a index of all its local users, contexts, workspaces but to
- a) not overengineer our MVP
- b) not overcomplicate the UX

we'll treat canvas-servers / remotes as with git or ssh.

Every Context and every Workspace can also be accessed using a dedicated api-token(you can share your workspace with other users by creating a api token(ro or rw) for said workspace or context - not sure where to store that information, probably in workspaces.json worksapce.auth.type? and if auth.type is token we use workspace token to access that workspace

Whenever canvas cli does any changes related to the context(mostly changing its URL) or workspace(changing its parameters) - we get a full object back, we should therefore update our local index right away
`$ canvas context bind user@remote:context-id`
`$ canvas context set workspace-id://some/context/path`
Returns a context object which we can save

The following commands should be implemented in our main bun/node based CLI:
```
canvas remote add user@remote-shortname url --token <optional token, otherwise we ask for a password>
canvas remote list | ls
canvas remote remove user@remote-shortname
canvas remote sync user@remote-shortname
canvas remote ping user@remote-shortname
canvas remote bind user@remote-shortname # To select a remote as default, we should write ~/.canvas/session.json
canvas remote login user@remote-shortname # JWT
canvas remote logout user@remote-shortname # JWT
remote rename old new
remote show user@remote # Dump remote details
```
On login, we should call
```
GET apiBase/workspaces
GET apiBase/contexts
```

Then update our local indexes
This should also be triggered with the sync command above

Indexes needs to be updated on a per-resource basis, not just by overwriting the whole file but by selectively updating the resource

So
Guess lets devise a plan to update the canvas-server backend and canvas-cli and start working

- Model: claude-4-sonnet MAX
3 changes: 1 addition & 2 deletions .cursorrules
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,7 @@ Context layers filter different data based on where they are placed within the c
- We use ES6 vanilla JavaScript and may use TypeScript in the future
- We use bash and powershell for scripting
- We use Node.js v20 LTS for the server runtime
- We use LMDB for the main server db backend `/server/db`)
- We use Canvas-SynapsD for user workspace databases and as the default JSON document store
- We use LMDB-based canvas-synapsd databases as the default JSON document store for user workspaces
- User data paths:
- `/users/john.doe@email.com/universe/` is the default workspace directory for user data
- `/users/john.doe@email.com/sample-workspace` is the example workspace directory for user
Expand Down
4 changes: 2 additions & 2 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
[submodule "src/ui/shell"]
path = src/ui/shell
url = https://github.com/canvas-ai/canvas-shell.git
[submodule "src/ui/browser"]
path = src/ui/browser
[submodule "src/ui/browser-extension"]
path = src/ui/browser-extension
url = https://github.com/canvas-ai/canvas-browser-extensions.git
[submodule "src/services/synapsd"]
path = src/services/synapsd
Expand Down
99 changes: 20 additions & 79 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,17 @@ 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!
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..

## Installation
Expand All @@ -22,8 +27,9 @@ Sorry Universe for the delay..
```bash
$ git clone https://github.com/canvas-ai/canvas-server /path/to/canvas-server
$ cd /path/to/canvas-server
$ npm install # or yarn install
$ npm run start # or yarn start
$ npm install
$ npm run dev # or
$ npm run start
```

## Docker
Expand Down Expand Up @@ -55,8 +61,8 @@ 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}
JWT_SECRET: ${JWT_SECRET:-$(openssl rand -base64 16)}
TOKEN_EXPIRY: ${TOKEN_EXPIRY:-7d}
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
Expand Down Expand Up @@ -98,7 +104,7 @@ $ npm install
$ npm start # or npm run pm2:start
```

## Make Canavas Server WebUI available remotely
## Make Canvas Server WebUI available remotely

```bash
# Copy the .env.example file
Expand All @@ -111,79 +117,10 @@ $ npm run build

## Scripts

### build-portable-image.sh

This script builds a Docker image for the Canvas Server with a portable configuration.

#### Usage

```bash
$ ./scripts/build-portable-image.sh [-n image_name] [-t image_tag] [-f dockerfile] [-c config_dir]
```

#### Options

- `-n`: Image name (default: canvas-server)
- `-t`: Image tag (default: portable)
- `-f`: Dockerfile to use (default: Dockerfile)
- `-c`: Config directory to copy (default: ./config)

### install-docker.sh

This script installs Docker and Docker Compose on an Ubuntu system. It checks if Docker and Docker Compose are already installed, and if not, installs them.

#### Usage

```bash
$ ./scripts/install-docker.sh
```

### install-ubuntu.sh

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

#### Usage

```bash
$ ./scripts/install-ubuntu.sh [-r canvas_root] [-u canvas_user] [-g canvas_group] [-b canvas_repo_branch] [-n nodejs_version] [-e web_admin_email] [-f web_fqdn]
```

#### Options

- `-r`: Canvas root directory (default: /opt/canvas-server)
- `-u`: Canvas user (default: canvas)
- `-g`: Canvas group (default: www-data)
- `-b`: Canvas repository branch (default: dev)
- `-n`: Node.js version (default: 20)
- `-e`: Web admin email (default: $(hostname)@cnvs.ai)
- `-f`: Web FQDN (default: my.cnvs.ai)

### update-docker.sh

This script updates Docker containers for the Canvas Server.

#### Usage

```bash
$ ./scripts/update-docker.sh [-r canvas_root] [-f docker_compose_file] [-b target_branch] [-l log_file]
```

#### Options

- `-r`: Canvas root directory (default: /opt/canvas-server)
- `-f`: Docker Compose file (default: docker-compose.yml)
- `-b`: Target branch for git pull (default: main)
- `-l`: Log file (default: /var/log/canvas-docker-update.log)

### update-git.sh

This script updates the Canvas Server by pulling the latest changes from the git repository and restarting the service.

#### Usage

```bash
$ ./scripts/update-git.sh
```
`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

## Authentication

Expand All @@ -194,6 +131,10 @@ Canvas Server supports two types of authentication:

## References

### API Documentation

- [Canvas Server API Reference](docs/API.md) - Complete REST API and WebSocket documentation

### DB / Index

- https://www.npmjs.com/package/lmdb
Expand Down
4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ services:
CANVAS_DISABLE_API: ${CANVAS_DISABLE_API:-false}
CANVAS_API_PORT: ${CANVAS_API_PORT:-8001}
CANVAS_API_HOST: ${CANVAS_API_HOST:-0.0.0.0}
JWT_SECRET: ${JWT_SECRET:-$(openssl rand -base64 16)}
TOKEN_EXPIRY: ${TOKEN_EXPIRY:-7d}
CANVAS_JWT_SECRET: ${CANVAS_JWT_SECRET:-$(openssl rand -base64 16)}
CANVAS_JWT_TOKEN_EXPIRY: ${CANVAS_JWT_TOKEN_EXPIRY:-7d}
volumes:
- ${CANVAS_SERVER_HOME:-./server}:/opt/canvas-server/server
- ${CANVAS_USER_HOME:-./users}:/opt/canvas-server/users
Loading