slatebox 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -3,15 +3,56 @@
3
3
  Run your own Slatebox with one command, on the machine of your choice:
4
4
 
5
5
  ```sh
6
- npx slatebox
6
+ npx slatebox install
7
7
  ```
8
8
 
9
- It asks a few short questions (Enter takes the default), shows a plan of
9
+ Pick a team address and sign in; Slatebox runs at `https://<name>.slatebox.team`
10
+ with no DNS, ports or certificates. Or choose your own domain, or this computer
11
+ only. It asks a few short questions (Enter takes the default), shows a plan of
10
12
  everything it will write, run and create, and installs once you say yes. Then
11
- it prints the address and how to set the admin password. `npx slatebox
12
- --dry-run` asks the same questions and prints the plan without changing
13
- anything. You need Node.js 22.13 or newer, and Docker (or Podman with its
14
- Docker compatibility on) on whatever runs Slatebox.
13
+ it prints the address and a one-time setup link: nobody can sign up until the
14
+ first admin exists, and the person who opens the link creates that account (the
15
+ server administrator and the owner of the first team). The link works once and
16
+ expires in 24 hours; `slatebox setup-link` prints a new one at a terminal and
17
+ ends the last. `npx slatebox --dry-run` asks the same questions and
18
+ prints the plan without changing anything. You need Node.js 22.13 or newer, and
19
+ Docker (or Podman with its Docker compatibility on) on whatever runs Slatebox.
20
+ Plain `npx slatebox` lists the commands.
21
+
22
+ ### A team address
23
+
24
+ ```sh
25
+ npx slatebox install --team-address acme --yes
26
+ ```
27
+
28
+ With `--yes` nothing is asked: what you did not give takes its default (this
29
+ computer, AI off until you add a model with `slatebox ai add`, no single
30
+ sign-on, daily backups, size small). The pinned image is downloaded first
31
+ (about 1 GB, once), so nothing is claimed for an image this computer cannot get.
32
+ `acme.slatebox.team` is claimed for your Slatebox account when you approve a
33
+ short code in your browser (like `gh auth login`). The container then connects
34
+ out to Cloudflare through a secure tunnel, which carries HTTPS and live
35
+ editing: nothing is opened on your machine or router, and the container starts
36
+ again when the machine does. Names are 3 to 32 characters (a-z, 0-9, hyphens).
37
+ An account holds up to 3. Your address is public; your slates are not.
38
+
39
+ The install keeps one credential for the address, on this computer only:
40
+ `~/.slatebox/installs/<name>/credentials.json` (mode 0600). It can fetch the
41
+ tunnel token again and give the address back, and nothing else.
42
+
43
+ ```sh
44
+ slatebox status # includes the address and the tunnel's connections
45
+ slatebox setup-link # a new one-time link for the first admin (ends the last one)
46
+ slatebox rename acme-boards # move to https://acme-boards.slatebox.team (sign-in)
47
+ slatebox address rotate # a new tunnel token; any copy of the old one stops working
48
+ slatebox address release # give the address back; Slatebox keeps running on this computer
49
+ slatebox uninstall # also gives the address back, unless --keep-address
50
+ ```
51
+
52
+ A released name is held for your account for 30 days. Slatebox Cloud releases
53
+ an address that never connected within 24 hours, and one unused for 90 days.
54
+ To leave the team address for your own domain, run
55
+ `npx slatebox install --domain boards.example.com`.
15
56
 
16
57
  Slatebox is one container: the app, the live collaboration relay, MongoDB and
17
58
  Keycloak for single sign-on (off until you turn it on). It is free, and single
@@ -19,8 +60,8 @@ sign-on is free.
19
60
 
20
61
  | Where | How |
21
62
  | --- | --- |
22
- | This computer | `npx slatebox` (the default). Picks a free port from 7070 and prints the address. |
23
- | A Linux server | `npx slatebox install ssh root@203.0.113.5 --domain boards.example.com`. With a domain, HTTPS certificates are obtained and renewed automatically (point DNS at the server, open ports 80 and 443); without one, `http://<server>:7070`. Docker is installed only if you add `--install-docker`. |
63
+ | This computer | `npx slatebox install` (the default). A team address, your own domain, or `--local` for `http://localhost` on a free port from 7070. Daily backups run from cron on Linux and from a launchd agent on a Mac (no permission prompt; a backup missed while the Mac sleeps runs when it wakes). |
64
+ | A Linux server | `npx slatebox install ssh root@203.0.113.5 --team-address acme`, or `--domain boards.example.com`. With a domain, HTTPS certificates are obtained and renewed automatically (point DNS at the server, open ports 80 and 443); without one, `http://<server>:7070`. Docker is installed only if you add `--install-docker`. |
24
65
  | Kubernetes | `npx slatebox install k8s --route ingress --domain boards.example.com --tls-issuer ClusterIssuer/letsencrypt`. Uses kubectl and your current context (a context whose name looks like production must be named with `--k8s-context`). One StatefulSet with a volume, a Service, an optional Ingress or Gateway API HTTPRoute, a Secret, and a backups sidecar. |
25
66
  | Files only | `npx slatebox install export --format compose\|manifests\|helm --out ./slatebox-deploy` for GitOps. Nothing is applied. |
26
67
 
@@ -85,12 +126,13 @@ With `--json`, stdout is one JSON event per line (`plan`, `step`, `done`,
85
126
 
86
127
  ```sh
87
128
  slatebox status # address, health, version, AI, SSO, last backup
129
+ slatebox logs [-f] [--service tunnel] # the container's log, every line redacted
88
130
  slatebox upgrade # back up, upgrade, check health, roll back (with the backup) on failure
89
131
  slatebox backup [--to ./backups] # a complete backup now
90
132
  slatebox restore slatebox-backup.gz
91
133
  slatebox secrets path # where SLATEBOX_KEY_ENCRYPTION_KEY and your keys are kept
92
134
  slatebox secrets reveal SLATEBOX_KEY_ENCRYPTION_KEY # to a terminal only, never with --json
93
- slatebox uninstall # keeps data; --delete-data --confirm <name> removes it
135
+ slatebox uninstall # keeps data; --delete-data --confirm <name> removes it (alias: remove)
94
136
  slatebox installs # every install this computer made (--name picks one)
95
137
  ```
96
138
 
@@ -101,6 +143,42 @@ computer, `/opt/slatebox/secrets.env` (root, 0600) on a server, or the Secret
101
143
  it the AI keys people saved cannot be read after a restore. Re-running the
102
144
  installer never makes a new one.
103
145
 
146
+ ## Move your team to Slatebox Cloud, or back
147
+
148
+ ```sh
149
+ npx slatebox migrate --to cloud # your own server's team → Slatebox Cloud
150
+ npx slatebox import --from cloud # your Slatebox Cloud team → your own server
151
+ npx slatebox install --from cloud # a new server, then the steps to bring your Cloud team over
152
+ npx slatebox export --out acme.sbxteam --passphrase prompt # a team export file
153
+ npx slatebox import acme.sbxteam --to cloud --passphrase prompt
154
+ ```
155
+
156
+ The command exports everything your team owns from one side (you need to be a team admin
157
+ there), and moves it to the other side, where you own your team or are in no team yet. It
158
+ moves slates and boards, smart components, versions, comments, presentations, files, the
159
+ brand kit, and library items (sent to the other side's review queue). People arrive as
160
+ placeholders. Once the move is live you are asked once, "Send invitations to the N other
161
+ members now?" (yes by default; `--invite` / `--no-invite` answer ahead; a script invites
162
+ nobody without `--invite`). Later: `npx slatebox migrate invite <move id> --to cloud`. Someone
163
+ who already has an account on the other side accepts an invitation to join there. Passwords,
164
+ keys, access tokens and connected agents never move.
165
+
166
+ You see the report before anything is visible on the other side, and nothing goes live until
167
+ you confirm. The team stays where it was until you remove it there.
168
+
169
+ - **Your own server:** its address is `--from`/`--to <url>`, `SLATEBOX_BASE_URL`, or the install
170
+ this computer made (`--name`). Its access token is `SLATEBOX_API_TOKEN` (make one in Profile →
171
+ Developer with "Export everything my team owns" and "Move a team here"). At a terminal you are
172
+ asked for it, with hidden input.
173
+ - **Slatebox Cloud:** you sign in with a code in your browser (the page says "Move your team";
174
+ the sign-in works for the move only, for an hour), or set `SLATEBOX_CLOUD_TOKEN`.
175
+ - **The archive** is encrypted with a passphrase made for this move, in `~/.slatebox/moves/`
176
+ (mode 0600). Once the move is live you are asked whether to delete it (no by default; the
177
+ command to delete it is printed). `--delete-archive` deletes it, `--keep-archive` keeps it,
178
+ without asking.
179
+ - An older server than the archive stops the move with "update that server"; the archive is kept.
180
+ - `--replace-waiting` discards a move that is already waiting on the other side.
181
+
104
182
  ## Safety
105
183
 
106
184
  - A plan is always shown first. On a server or a cluster nothing changes
@@ -126,14 +204,17 @@ installer never makes a new one.
126
204
  command lines (`ps` can read those); they travel on standard input or in
127
205
  0600 files.
128
206
  - Re-running with the same answers changes nothing.
129
- - Nothing phones home. The installer contacts the image registry, and only
130
- with your consent get.docker.com; Slatebox itself contacts the certificate
131
- authority when you give a domain, and the AI endpoints you configure.
207
+ - Nothing phones home. The installer contacts the image registry, Slatebox
208
+ Cloud only when you ask for a team address, and only with your consent
209
+ get.docker.com; Slatebox itself contacts Cloudflare's tunnel when it has a
210
+ team address, the certificate authority when you give a domain, and the AI
211
+ endpoints you configure.
132
212
 
133
213
  ## Which image
134
214
 
135
215
  Each release of this package installs one public image,
136
- `ghcr.io/slatebox/slatebox`, by its digest (this release: `0.1.0`). It needs
216
+ `ghcr.io/slatebox/slatebox`, by its digest (this release: `0.2.1`, which adds
217
+ the team-address tunnel, the setup link and team moves). It needs
137
218
  no registry login. To install a local build instead, give `--image <name>`
138
219
  (or `--image-archive slatebox.tar` for a server).
139
220
 
@@ -148,5 +229,8 @@ address answers.
148
229
 
149
230
  ## Slates
150
231
 
151
- `slatebox exec` and `slatebox describe` (scripts against a Slatebox) come from
152
- the slatebox-mcp package; this command fetches it the first time you use one.
232
+ `slatebox exec`, `slatebox describe` and `slatebox mcp` (scripts and agents
233
+ against any Slatebox) come from the slatebox-mcp package, which this package
234
+ installs with it. If you installed slatebox-mcp 0.3 globally, which also named
235
+ a `slatebox` command, replace it with:
236
+ `npm rm -g slatebox-mcp && npm i -g slatebox slatebox-mcp`.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "slatebox",
3
- "version": "0.1.0",
4
- "description": "Install your own Slatebox with one command: npx slatebox. Runs on the machine of your choice (Docker on this computer, a server over SSH, Kubernetes, or files only), asks a few questions, shows a plan, and starts the one-container Slatebox.",
3
+ "version": "0.2.1",
4
+ "description": "Run your own Slatebox with one command: npx slatebox install. Gives it a free team address (https://<name>.slatebox.team) with no DNS, ports or certificates, or uses your own domain; installs on Docker here, a server over SSH, Kubernetes, or writes the files. Also runs agent scripts against any Slatebox (slatebox exec).",
5
5
  "keywords": [
6
6
  "slatebox",
7
7
  "self-host",
@@ -39,5 +39,8 @@
39
39
  },
40
40
  "engines": {
41
41
  "node": ">=22.13"
42
+ },
43
+ "dependencies": {
44
+ "slatebox-mcp": "0.4.1"
42
45
  }
43
46
  }
@@ -9,7 +9,9 @@ you what it still needs. Follow these steps exactly.
9
9
  1. **Ask the person** (do not guess):
10
10
  - Where: this computer (Docker), a Linux server over SSH (user@host), or
11
11
  Kubernetes (which kube context and namespace). Or only write the files.
12
- - The address: a domain name for HTTPS, or a port.
12
+ - The address: a free team address (https://<name>.slatebox.team: no DNS,
13
+ ports or certificates; the person signs in once in their browser to claim
14
+ it), a domain name for HTTPS, or a port.
13
15
  - The admin email (required for a server or a cluster).
14
16
  - AI: none for now, or which providers. Slatebox works with any provider and
15
17
  has no default: OpenAI, Anthropic, DeepInfra, OpenRouter, Groq, Together,
@@ -31,6 +33,7 @@ you what it still needs. Follow these steps exactly.
31
33
  default: local
32
34
  sso: { enabled: false }
33
35
  # ssh: { host: 203.0.113.5, user: root } with target: ssh
36
+ # address: { team: acme } a team address, https://acme.slatebox.team
34
37
  # address: { domain: boards.example.com } for HTTPS on a server or a cluster route
35
38
  # k8s: { context: my-cluster, namespace: slatebox, route: ingress, ingressClass: nginx, tlsIssuer: { kind: ClusterIssuer, name: letsencrypt } }
36
39
  \`\`\`
@@ -46,10 +49,22 @@ you what it still needs. Follow these steps exactly.
46
49
  checking, and never export SLATEBOX_INSTALL_YES (it is ignored).
47
50
  4. **Show the plan to the person and get an explicit yes.** It lists every
48
51
  file, command, object and port, and where the secrets are kept.
52
+ With a team address the short form is
53
+ \`npx slatebox install --team-address <name> --yes\` (add the providers the
54
+ person chose; with --yes and no AI answer, AI is off). Exit 3 with \`id: "address-unavailable"\` lists free
55
+ \`suggestions\`: ask the person to pick one.
49
56
  5. **Install**: \`npx -y slatebox@latest install --answers slatebox.yaml --yes --json\`.
57
+ For a team address a \`sign-in\` event carries \`verificationUri\` and \`userCode\`:
58
+ show both to the person and ask them to approve it in their browser; the
59
+ command waits. Never approve it yourself.
50
60
  Report \`done.address\` from the last line. Do not print or copy any secret;
51
61
  the output never contains one. Tell the person where the key encryption key
52
62
  is stored (\`done.secretsFile\`) and that they must back it up themselves.
63
+ Nobody can sign up until the first admin exists. Tell the person to run
64
+ \`slatebox setup-link\` in their own terminal: it prints a one-time link
65
+ (24 hours, single use) that creates the first account, the server
66
+ administrator. Never run it yourself or ask for the link: it is as good as
67
+ an admin password.
53
68
  6. **If it fails**: exit 5 means the change was rolled back and the previous
54
69
  state is running; exit 6 means a person must act: show them
55
70
  \`error.commands\` and stop.
@@ -59,6 +74,6 @@ you what it still needs. Follow these steps exactly.
59
74
  asked for their data to be deleted.
60
75
 
61
76
  Nothing the installer runs sends data anywhere except pulling the image (and,
62
- with consent, installing Docker from get.docker.com, and the certificate
63
- authority when a domain is given).
77
+ with consent, installing Docker from get.docker.com, the certificate authority
78
+ when a domain is given, and Slatebox Cloud when a team address is asked for).
64
79
  `
package/src/answers.mjs CHANGED
@@ -5,6 +5,7 @@
5
5
  import { isAbsolute, join, normalize, resolve as resolvePath } from 'node:path'
6
6
  import { isRef, looksLikeKey } from './secrets.mjs'
7
7
  import { normalizeProvider, PROVIDER_KINDS } from './ai/settings-adapter.mjs'
8
+ import { teamAddressProblem, teamUrl } from './cloud.mjs'
8
9
 
9
10
  export const TARGETS = ['local', 'ssh', 'k8s', 'export']
10
11
  export const SIZES = Object.freeze({
@@ -24,10 +25,10 @@ export const ANSWER_FLAGS = {
24
25
  'mail-url-from': 'string', 'mail-from': 'string', backups: 'string', 'backup-schedule': 'string', 'backup-keep': 'string',
25
26
  size: 'string', 'k8s-context': 'string', namespace: 'string', route: 'string', 'ingress-class': 'string',
26
27
  'gateway-ref': 'string', 'tls-issuer': 'string', 'storage-class': 'string', format: 'string', out: 'string',
27
- image: 'string', name: 'string', 'acme-ca': 'string', settings: 'string',
28
+ image: 'string', name: 'string', 'acme-ca': 'string', settings: 'string', 'team-address': 'string', local: 'boolean',
28
29
  }
29
30
  // Global flags that also have an environment form.
30
- const GLOBAL_ENV_FLAGS = { answers: 'string', json: 'boolean', agent: 'string', 'image-archive': 'string', home: 'string', debug: 'boolean', 'health-timeout': 'string' }
31
+ const GLOBAL_ENV_FLAGS = { answers: 'string', json: 'boolean', agent: 'string', 'image-archive': 'string', home: 'string', debug: 'boolean', 'health-timeout': 'string', 'cloud-url': 'string' }
31
32
 
32
33
  const isObject = value => value && typeof value === 'object' && !Array.isArray(value)
33
34
 
@@ -110,6 +111,12 @@ export function answersFromFlags(flags) {
110
111
  set('ssh.options', flags['ssh-option'])
111
112
  set('address.url', flags.url)
112
113
  set('address.domain', flags.domain)
114
+ set('address.team', flags['team-address'])
115
+ // One address at a time: a flag for one kind replaces what an earlier install had of the others.
116
+ if (flags['team-address']) { set('address.url', flags.url ?? null); set('address.domain', flags.domain ?? null) }
117
+ if (flags.domain || flags.url) set('address.team', flags['team-address'] ?? null)
118
+ // --local: this computer only, and no team address even if an earlier install had one.
119
+ if (flags.local) { set('address.team', null); set('address.url', null); set('address.domain', null) }
113
120
  set('address.listen', flags.listen)
114
121
  if (flags.port !== undefined) set('address.port', Number(flags.port))
115
122
  set('adminEmail', flags['admin-email'])
@@ -188,11 +195,11 @@ export const QUESTIONS = {
188
195
  flag: '--target',
189
196
  },
190
197
  'ssh.host': { question: 'Server (user@host or a name from ~/.ssh/config)', flag: '--host' },
191
- adminEmail: { question: 'Admin email (the first account, and the HTTPS certificate contact)', flag: '--admin-email' },
198
+ adminEmail: { question: 'Admin email (the HTTPS certificate contact; the first account comes from the setup link)', flag: '--admin-email' },
192
199
  'ai.mode': {
193
200
  question: 'AI for drafts and the canvas assistant. Slatebox works with any provider, and none is chosen for you.',
194
201
  choices: AI_CHOICES,
195
- flag: '--ai none | --ai-provider kind=<openai|anthropic|deepinfra|openrouter|groq|together|mistral|ollama|lmstudio|openai-compatible>,model=<model>,url=<endpoint>,key=env:<VAR> (repeat for several, then --ai-default <id>)',
202
+ flag: '--ai none | --ai-provider kind=<openai|anthropic|deepinfra|openrouter|groq|together|mistral|ollama|lmstudio|openai-compatible>,model=<model>,url=<endpoint>,key=env:<VAR> (repeat for several, then --ai-default <id>); with --yes and no AI answer, AI is off (slatebox ai add later)',
196
203
  },
197
204
  }
198
205
 
@@ -269,7 +276,7 @@ function httpUrl(value) {
269
276
  /**
270
277
  * Fill in defaults and check everything.
271
278
  * @param {object} partial from collect()
272
- * @param {{freePort?: number}} ctx
279
+ * @param {{freePort?: number, yes?: boolean}} ctx yes: the run asks nothing (--yes), so an answer that has a default takes it
273
280
  * @returns {{answers: object, missing: object[], errors: {field: string, message: string}[]}}
274
281
  */
275
282
  export function resolveAnswers(partial, ctx = {}) {
@@ -329,14 +336,31 @@ export function resolveAnswers(partial, ctx = {}) {
329
336
  const k8s = a.target === 'k8s' || Boolean(a.k8s)
330
337
  if (given.domain && given.url) err('address.url', 'give a domain or a URL, not both')
331
338
  let url = given.domain ? `https://${given.domain}` : given.url
332
- if (k8s) {
339
+ // A team address: https://<name>.slatebox.team through an outbound tunnel from the container.
340
+ // Nothing is published beyond 127.0.0.1 and Slatebox's own HTTPS stays off.
341
+ const team = given.team ?? null
342
+ if (team !== null) {
343
+ const problem = teamAddressProblem(team)
344
+ if (problem) err('address.team', problem)
345
+ if (given.domain || (given.url && given.url !== teamUrl(team))) err('address.team', 'give a team address, a domain or a URL, not more than one')
346
+ if (a.target === 'export') err('address.team', 'a team address is claimed when Slatebox is installed; for files only use --domain, or install with --target local, ssh or k8s')
347
+ if (k8s && a.k8s.route !== 'none') err('address.team', 'a team address needs no route: leave --route out (traffic arrives through the tunnel)')
348
+ if (!problem) url = teamUrl(team)
349
+ }
350
+ if (team !== null && !k8s) {
351
+ const port = given.port ?? (a.target === 'local' ? (ctx.freePort ?? DEFAULT_PORT) : DEFAULT_PORT)
352
+ if (!Number.isInteger(port) || port < 1 || port > 65535) err('address.port', 'a port number')
353
+ const listen = given.listen ?? '127.0.0.1'
354
+ if (!['127.0.0.1', '::1'].includes(listen)) err('address.listen', 'with a team address Slatebox is published on 127.0.0.1 only (traffic arrives through the tunnel)')
355
+ a.address = { url: url ?? null, port, listen, team }
356
+ } else if (k8s) {
333
357
  if (a.k8s.route === 'none') {
334
358
  url ??= `http://localhost:${DEFAULT_PORT}`
335
359
  } else if (!url || !httpUrl(url) || httpUrl(url).protocol !== 'https:') {
336
360
  err('address.url', `a route (${a.k8s.route}) needs the host name people will use, given as --domain`)
337
361
  url = null
338
362
  }
339
- a.address = { url }
363
+ a.address = team !== null ? { url, team } : { url }
340
364
  } else {
341
365
  let port = given.port
342
366
  if (url && httpUrl(url)?.protocol === 'https:') {
@@ -371,9 +395,12 @@ export function resolveAnswers(partial, ctx = {}) {
371
395
  if (a.adminEmail && !EMAIL.test(a.adminEmail)) err('adminEmail', 'an email address')
372
396
  if (!a.adminEmail && (a.target === 'ssh' || a.target === 'k8s')) missing.push(question('adminEmail'))
373
397
 
374
- // --- AI: never a default
398
+ // --- AI: never a default provider. Unanswered with --yes, AI is off (add one later with
399
+ // `slatebox ai add`); unanswered without it, it is asked, or exit 3 with nobody to ask.
375
400
  const ai = p.ai || {}
376
- if (ai.mode === undefined || ai.mode === null) {
401
+ if ((ai.mode === undefined || ai.mode === null) && ctx.yes && !ai.providers?.length) {
402
+ a.ai = { mode: 'none' }
403
+ } else if (ai.mode === undefined || ai.mode === null) {
377
404
  missing.push(question('ai.mode'))
378
405
  a.ai = { mode: null }
379
406
  } else if (ai.mode === 'none') {