slatebox 0.2.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
@@ -25,6 +25,10 @@ Plain `npx slatebox` lists the commands.
25
25
  npx slatebox install --team-address acme --yes
26
26
  ```
27
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.
28
32
  `acme.slatebox.team` is claimed for your Slatebox account when you approve a
29
33
  short code in your browser (like `gh auth login`). The container then connects
30
34
  out to Cloudflare through a secure tunnel, which carries HTTPS and live
@@ -56,7 +60,7 @@ sign-on is free.
56
60
 
57
61
  | Where | How |
58
62
  | --- | --- |
59
- | This computer | `npx slatebox install` (the default). A team address, your own domain, or `--local` for `http://localhost` on a free port from 7070. |
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). |
60
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`. |
61
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. |
62
66
  | Files only | `npx slatebox install export --format compose\|manifests\|helm --out ./slatebox-deploy` for GitOps. Nothing is applied. |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "slatebox",
3
- "version": "0.2.0",
3
+ "version": "0.2.1",
4
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",
@@ -41,6 +41,6 @@
41
41
  "node": ">=22.13"
42
42
  },
43
43
  "dependencies": {
44
- "slatebox-mcp": "0.4.0"
44
+ "slatebox-mcp": "0.4.1"
45
45
  }
46
46
  }
@@ -50,8 +50,8 @@ you what it still needs. Follow these steps exactly.
50
50
  4. **Show the plan to the person and get an explicit yes.** It lists every
51
51
  file, command, object and port, and where the secrets are kept.
52
52
  With a team address the short form is
53
- \`npx slatebox install --team-address <name> --yes\` (add \`--ai none\` or the
54
- providers the person chose). Exit 3 with \`id: "address-unavailable"\` lists free
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
55
  \`suggestions\`: ask the person to pick one.
56
56
  5. **Install**: \`npx -y slatebox@latest install --answers slatebox.yaml --yes --json\`.
57
57
  For a team address a \`sign-in\` event carries \`verificationUri\` and \`userCode\`:
package/src/answers.mjs CHANGED
@@ -199,7 +199,7 @@ export const QUESTIONS = {
199
199
  'ai.mode': {
200
200
  question: 'AI for drafts and the canvas assistant. Slatebox works with any provider, and none is chosen for you.',
201
201
  choices: AI_CHOICES,
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>)',
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)',
203
203
  },
204
204
  }
205
205
 
@@ -276,7 +276,7 @@ function httpUrl(value) {
276
276
  /**
277
277
  * Fill in defaults and check everything.
278
278
  * @param {object} partial from collect()
279
- * @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
280
280
  * @returns {{answers: object, missing: object[], errors: {field: string, message: string}[]}}
281
281
  */
282
282
  export function resolveAnswers(partial, ctx = {}) {
@@ -395,9 +395,12 @@ export function resolveAnswers(partial, ctx = {}) {
395
395
  if (a.adminEmail && !EMAIL.test(a.adminEmail)) err('adminEmail', 'an email address')
396
396
  if (!a.adminEmail && (a.target === 'ssh' || a.target === 'k8s')) missing.push(question('adminEmail'))
397
397
 
398
- // --- 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.
399
400
  const ai = p.ai || {}
400
- 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) {
401
404
  missing.push(question('ai.mode'))
402
405
  a.ai = { mode: null }
403
406
  } else if (ai.mode === 'none') {
package/src/cli.mjs CHANGED
@@ -3,7 +3,7 @@
3
3
  // (exec, describe and the MCP server, from the slatebox-mcp package, in this same process).
4
4
  // main() takes its streams and environment as arguments and returns the exit code, so tests run
5
5
  // it in process.
6
- import { existsSync, readdirSync, readFileSync, rmSync } from 'node:fs'
6
+ import { existsSync, readdirSync, readFileSync, rmdirSync, rmSync } from 'node:fs'
7
7
  import { join } from 'node:path'
8
8
  import { parseArgs } from 'node:util'
9
9
  import { AGENT_PROMPT } from './agent-prompt.mjs'
@@ -69,8 +69,12 @@ export const HELP = `slatebox ${PKG.version}: run your own Slatebox, and work wi
69
69
  npx slatebox install asks where your team opens it (a free team address at
70
70
  https://<name>.slatebox.team, your own domain, or this
71
71
  computer only), shows a plan, installs
72
- npx slatebox install --team-address acme --yes the same without questions (you still sign
73
- in once in your browser to claim the address)
72
+ npx slatebox install --team-address acme --yes the same without questions: anything not
73
+ given takes its default (this computer, no admin email,
74
+ AI off: add a model later with slatebox ai add, no SSO,
75
+ daily backups, size small, no mail). You still approve one
76
+ code in your browser to claim the address (opened for you
77
+ at a terminal)
74
78
  npx slatebox install --domain boards.example.com your own domain (Caddy HTTPS, or --url and your proxy)
75
79
  npx slatebox --dry-run the questions and the plan only; nothing changes
76
80
  npx slatebox agent-prompt instructions for a coding agent to do it for you
@@ -91,7 +95,9 @@ then --answers, then the environment. Consent never comes from the environment:
91
95
  --listen <ip> this computer only: 127.0.0.1 (default) or 0.0.0.0 for every interface
92
96
  --admin-email <email>
93
97
  --ai none | --ai-provider "kind=<openai|anthropic|deepinfra|openrouter|groq|together|mistral|ollama|lmstudio|openai-compatible>,model=<m>,url=<endpoint>,key=env:<VAR>"
94
- (repeat for several, then --ai-default <id>; there is no default provider)
98
+ (repeat for several, then --ai-default <id>; there is no default provider:
99
+ without --yes it is asked, or exit 3 with nobody to ask; with --yes and
100
+ no AI answer, AI is off: add a model later with slatebox ai add)
95
101
  --sso --sso-only --sso-admin open|closed
96
102
  --backups default|<dir>|s3://bucket/prefix|off --backup-schedule "0 3 * * *" --backup-keep 14
97
103
  --size small|team|large --mail-url-from env:<VAR> --mail-from "Slatebox <b@example.com>"
@@ -118,7 +124,9 @@ a name is claimed, moved or reconnected. SLATEBOX_CLOUD_URL or --cloud-url point
118
124
  Slatebox Cloud. The install credential stays in
119
125
  ~/.slatebox/installs/<name>/credentials.json (mode 0600).
120
126
 
121
- Global: --yes (after a person approved the plan) --json (NDJSON events on stdout)
127
+ Global: --yes (after a person approved the plan; asks nothing, takes the defaults for what is
128
+ not given; answers with no default, such as --host or a server's --admin-email, are
129
+ still exit 3) --json (NDJSON events on stdout)
122
130
  --agent auto|yes|no --debug --health-timeout <seconds> (default 600)
123
131
 
124
132
  Exit codes: 0 done or nothing to change; 2 bad flags or answers; 3 an answer or a
@@ -183,7 +191,7 @@ async function slateCommand(argv, io) {
183
191
  }
184
192
  if (argv[0] === 'mcp') {
185
193
  if (argv.includes('--help') || argv.includes('-h')) {
186
- io.stdout.write('Usage: slatebox mcp [--base-url ORIGIN] [--typed-tools on|off] [--http [--port N]]\nThe same as slatebox-mcp: SLATEBOX_API_TOKEN is your personal access token.\n')
194
+ io.stdout.write(commands.mcpHelp ? commands.mcpHelp('slatebox mcp') : 'Usage: slatebox mcp [--base-url ORIGIN] [--typed-tools on|off] [--http [--port N]]\nThe same as slatebox-mcp: SLATEBOX_API_TOKEN is your personal access token.\n')
187
195
  return 0
188
196
  }
189
197
  try {
@@ -279,8 +287,10 @@ export async function main(argv, io = {}) {
279
287
  cliFlags: parsed.values, platform: io.platform, cwd: io.cwd,
280
288
  openBrowser: io.openBrowser, sleep: io.sleep, deviceLabel: io.deviceLabel, spawn: io.spawn,
281
289
  teamHealthAttempts: io.teamHealthAttempts, teamHealthDelay: io.teamHealthDelay,
290
+ uid: io.uid, schedulerTimeout: io.schedulerTimeout,
282
291
  }
283
292
  if (interactive) ctx.prompt = createPrompt({ input: io.stdin, output: io.stderr })
293
+
284
294
  ctx.emitPlan = plan => {
285
295
  out.event({ event: 'plan', ...plan })
286
296
  const text = formatPlan(plan)
@@ -363,14 +373,15 @@ async function prepareAnswers(ctx, flags, positionals) {
363
373
  const name = cliFlags.name || file?.name || flags.name || 'slatebox'
364
374
  const record = readRecord(ctx.home, name)
365
375
  let partial = collect({ record, env: ctx.env, file, flags: cliFlags })
366
- if (ctx.interactive) {
376
+ // --yes asks nothing: what is not given takes its default (resolveAnswers with { yes }).
377
+ if (ctx.interactive && !ctx.yes) {
367
378
  const kube = await ctx.run('kubectl', ['config', 'current-context']).catch(() => null)
368
379
  ctx.currentContext = kube?.code === 0 ? kube.stdout.trim() : null
369
380
  ctx.freePort = partial.address?.port ?? await defaultLocalPort()
370
381
  partial = await interview(ctx, partial)
371
382
  }
372
383
  const freePort = (partial.target ?? 'local') === 'local' && partial.address?.port === undefined && !partial.address?.url ? await defaultLocalPort() : undefined
373
- const { answers, missing, errors } = resolveAnswers(partial, { freePort, cwd: ctx.cwd, home: ctx.env.HOME })
384
+ const { answers, missing, errors } = resolveAnswers(partial, { freePort, cwd: ctx.cwd, home: ctx.env.HOME, yes: ctx.yes })
374
385
  if (errors.length) throw new InstallError(EXIT.USAGE, `Some answers are not valid: ${errors.map(error => error.field).join(', ')}.`, { fields: errors })
375
386
  if (missing.length) throw new InstallError(EXIT.NEEDS_INPUT, `Some answers are needed: ${missing.map(item => item.field).join(', ')}.`, { missing })
376
387
  return { answers, record, explicitContext: Boolean(cliFlags['k8s-context'] || file?.k8s?.context || record?.k8s?.context) }
@@ -382,10 +393,14 @@ async function applyTarget(ctx, answers, options) {
382
393
  return applyDocker(ctx, answers, { ...options, archive: ctx.flags['image-archive'] })
383
394
  }
384
395
 
396
+ function runningLines(ctx, done) {
397
+ return ['', `Slatebox is running at ${done.address}`, ...setupLines(ctx, done.name)]
398
+ }
399
+
385
400
  function closing(ctx, done) {
386
401
  if (done.nothingToChange) return [`Nothing to change: ${done.name} is running at ${done.address}.${done.teamAddress ? ' (slatebox upgrade gets a newer image.)' : ''}`, ...setupLines(ctx, done.name)]
387
402
  if (done.target === 'export') return [`Wrote ${done.files.length} files to ${done.dir}. Nothing was applied.`]
388
- const lines = ['', `Slatebox is running at ${done.address}`, ...setupLines(ctx, done.name)]
403
+ const lines = ctx.announced ? [] : runningLines(ctx, done)
389
404
  if (done.teamAddress) {
390
405
  lines.push('', `On this computer it also answers at ${done.localAddress}.`,
391
406
  '', `Keep a copy of ${installDir(ctx.home, done.name)}/ (keys and the team-address credential).`)
@@ -450,6 +465,16 @@ async function dispatch(ctx, positionals, flags) {
450
465
  case 'install': {
451
466
  const { answers, record, explicitContext } = await prepareAnswers(ctx, flags, positionals)
452
467
  const planOnly = command === 'plan' || Boolean(flags['dry-run'])
468
+ // The address and setup link, printed the moment the install is healthy (before the backup
469
+ // schedule), and not again at the end.
470
+ ctx.announce = healthy => {
471
+ if (ctx.announced || healthy.target === 'export') return
472
+ ctx.announced = true
473
+ for (const line of runningLines(ctx, healthy)) {
474
+ if (typeof line === 'string') ctx.out.say(line)
475
+ else ctx.stderr.write(`${line.terminal}\n`)
476
+ }
477
+ }
453
478
  const done = await applyTarget(ctx, answers, { record, planOnly, explicitContext })
454
479
  if (done.planned) {
455
480
  ctx.out.event({ event: 'done', planned: true, name: answers.name, target: answers.target })
@@ -534,7 +559,11 @@ async function dispatch(ctx, positionals, flags) {
534
559
  const dir = installDir(ctx.home, record.name)
535
560
  if (keepCredential) {
536
561
  for (const entry of existsSync(dir) ? readdirSync(dir) : []) if (entry !== CREDENTIALS_FILE) rmSync(join(dir, entry), { recursive: true, force: true })
537
- } else rmSync(dir, { recursive: true, force: true })
562
+ } else {
563
+ rmSync(dir, { recursive: true, force: true })
564
+ // The installs folder goes too once nothing else is in it.
565
+ try { rmdirSync(join(ctx.home, 'installs')) } catch { /* another install, or files of someone else's */ }
566
+ }
538
567
  } else {
539
568
  writeRecord(ctx.home, { ...record, ...(released?.released ? { address: localAddress(record) } : {}), state: 'uninstalled' })
540
569
  }
package/src/cloud.mjs CHANGED
@@ -117,7 +117,7 @@ export function cloudClient(ctx, base) {
117
117
  const code = typeof error === 'string' ? error : error?.code
118
118
  const message = typeof error === 'string' ? data?.error_description : error?.message
119
119
  const retryAfter = Number(response.headers?.get?.('retry-after')) || undefined
120
- throw new CloudError(response.status, code, message, { retryAfter, suggestions: data?.suggestions || error?.suggestions, notice: error?.notice })
120
+ throw new CloudError(response.status, code, message, { retryAfter, suggestions: data?.suggestions || error?.suggestions, notice: error?.notice, reason: typeof error?.reason === 'string' ? error.reason : undefined })
121
121
  }
122
122
 
123
123
  const api = path => `/api/v1/team-addresses${path}`
@@ -184,7 +184,11 @@ export async function signIn(ctx, cloud, { purpose = 'claim a team address', sco
184
184
  if (ctx.interactive) {
185
185
  lines.push(` (The code expires in ${minutes} minutes.)`)
186
186
  ctx.stderr.write(`${lines.join('\n')}\n`)
187
- if (await ctx.prompt.confirm('Open it in your browser now?', { default: true })) (ctx.openBrowser || openBrowser)(complete || page, ctx.platform)
187
+ // --yes asks nothing: the page is opened for the person, as Enter at the question would.
188
+ if (ctx.yes) {
189
+ ctx.stderr.write(' Opening it in your browser.\n')
190
+ ;(ctx.openBrowser || openBrowser)(complete || page, ctx.platform)
191
+ } else if (await ctx.prompt.confirm('Open it in your browser now?', { default: true })) (ctx.openBrowser || openBrowser)(complete || page, ctx.platform)
188
192
  } else {
189
193
  lines.push(` (The code expires in ${minutes} minutes. Approve it in a browser where you are signed in to Slatebox.)`)
190
194
  ctx.stderr.write(`${lines.join('\n')}\n`)
package/src/image.mjs CHANGED
@@ -17,6 +17,25 @@ export const PINNED_TAG = '0.2.1'
17
17
  export const PINNED_DIGEST = 'sha256:208d4bfc460ed2feedc435ccc22231177929e8885ab5f856933c67e6831ca5b5'
18
18
  export const DEFAULT_IMAGE = PINNED_DIGEST ? `${DEFAULT_REPOSITORY}@${PINNED_DIGEST}` : `${DEFAULT_REPOSITORY}:${PINNED_TAG}`
19
19
 
20
+ // What the pinned image accepts: its own `slatebox settings --json` (self-host/rootfs/opt/slatebox/
21
+ // lib/settings.mjs at the revision it was built from). A plan for the pinned image on a machine
22
+ // that has not pulled it yet is then the real plan (a team address, several AI providers), not a
23
+ // guess from an older image. The image is still probed after it is pulled, and that answer wins.
24
+ export const PINNED_CAPABILITIES = Object.freeze({
25
+ settings: Object.freeze([
26
+ 'SLATEBOX_URL', 'SLATEBOX_HTTPS', 'SLATEBOX_ACME_CA', 'SLATEBOX_MAIL_URL', 'SLATEBOX_MAIL_FROM',
27
+ 'SLATEBOX_AI_KEY', 'SLATEBOX_AI_URL', 'SLATEBOX_AI_MODEL', 'SLATEBOX_AI_CONFIG',
28
+ 'SLATEBOX_AI_PROVIDERS', 'SLATEBOX_AI_DEFAULT', 'SLATEBOX_AI_OWN_PROVIDERS', 'SLATEBOX_AI_PRIVATE_ENDPOINTS',
29
+ 'SLATEBOX_SETTINGS', 'SLATEBOX_SSO', 'SLATEBOX_SSO_ONLY', 'SLATEBOX_SSO_ADMIN', 'SLATEBOX_KEY_ENCRYPTION_KEY',
30
+ 'SLATEBOX_TUNNEL_TOKEN', 'SLATEBOX_LICENSE', 'SLATEBOX_LICENSE_FILE', 'MONGO_URL', 'MONGO_OPLOG_URL',
31
+ ]),
32
+ commands: Object.freeze(['backup', 'restore', 'password-link', 'setup-link', 'health', 'version', 'sso', 'ai', 'settings', 'tunnel']),
33
+ source: 'pinned',
34
+ })
35
+
36
+ /** Is this reference the image this release pins (by digest, or by its tag while unpinned)? */
37
+ export const isPinnedImage = ref => Boolean(ref) && (ref === DEFAULT_IMAGE || (PINNED_DIGEST !== null && ref === `${DEFAULT_REPOSITORY}@${PINNED_DIGEST}`))
38
+
20
39
  /** Does this reference name a registry (so a digest reference can be pulled elsewhere)? */
21
40
  export function hasRegistry(ref) {
22
41
  const first = ref.split('/')[0]
@@ -46,7 +65,18 @@ export function pinImage(wanted, info) {
46
65
  return { ref: wanted, pinned, id, created: info.Created, labels: info.Config?.Labels || {}, architecture: info.Architecture || null }
47
66
  }
48
67
 
68
+ // What docker pull says when this machine cannot reach the registry at all.
69
+ const OFFLINE = /no such host|dial tcp|i\/o timeout|network is unreachable|connection refused|TLS handshake timeout|temporary failure in name resolution|could not resolve|server misbehaving|Client\.Timeout/i
70
+
49
71
  function unavailable(wanted, why) {
72
+ const registry = hasRegistry(wanted) ? wanted.split('/')[0] : 'Docker Hub'
73
+ if (OFFLINE.test(why || '')) {
74
+ return new InstallError(EXIT.PRECONDITION,
75
+ `The image ${wanted} could not be downloaded: this computer cannot reach ${registry} (${why}). Nothing was changed. ` +
76
+ 'Check the internet connection (and any proxy or firewall), then run the same command again.' +
77
+ (wanted.startsWith(DEFAULT_REPOSITORY) ? ' To install a local build instead, give --image <name> or --image-archive <file.tar>.' : ''),
78
+ { image: wanted, offline: true })
79
+ }
50
80
  return new InstallError(EXIT.PRECONDITION,
51
81
  `The image ${wanted} is not available: ${why}\n` +
52
82
  (wanted.startsWith(DEFAULT_REPOSITORY) ? 'The public image needs no login: check that this machine can reach ghcr.io (or that the --to version exists), then try again. To install a local build instead, give --image <name> or --image-archive <file.tar>.' : 'Check the name, or log in to its registry with docker login.'),
@@ -98,8 +128,7 @@ export async function resolveImage(docker, { ref, archive, loadArchive, step })
98
128
  }
99
129
  let info = await inspectImage(docker, wanted)
100
130
  if (!info) {
101
- step('image', 'start', `Pulling ${wanted}`)
102
- const pulled = await docker(['pull', wanted], { timeout: 60 * 60_000 })
131
+ const pulled = await pullWithProgress(docker, wanted, step)
103
132
  if (pulled.code !== 0) throw unavailable(wanted, pulled.stderr.trim().split('\n').pop())
104
133
  info = await inspectImage(docker, wanted)
105
134
  if (!info) throw new InstallError(EXIT.PRECONDITION, `The image ${wanted} was pulled but cannot be inspected.`)
@@ -107,6 +136,27 @@ export async function resolveImage(docker, { ref, archive, loadArchive, step })
107
136
  return pinImage(wanted, info)
108
137
  }
109
138
 
139
+ /**
140
+ * docker pull, saying so first and then every so often while it runs (the first pull of the
141
+ * one-container image is about 1 GB), so a long download never looks like a hang.
142
+ */
143
+ export async function pullWithProgress(docker, ref, step, { every = 15_000 } = {}) {
144
+ step('image', 'start', `Downloading ${ref} (about 1 GB the first time; later installs and upgrades fetch only what changed)`)
145
+ const started = Date.now()
146
+ const timer = setInterval(() => step('image', 'start', `Still downloading the image (${Math.round((Date.now() - started) / 1000)}s so far)`), every)
147
+ timer.unref?.()
148
+ try {
149
+ const pulled = await docker(['pull', ref], { timeout: 60 * 60_000 })
150
+ if (pulled.code === 0) step('image', 'ok', `Downloaded the image in ${Math.max(1, Math.round((Date.now() - started) / 1000))}s`)
151
+ return pulled
152
+ } finally {
153
+ clearInterval(timer)
154
+ }
155
+ }
156
+
157
+ /** What an image is known to accept before it is on this machine: the pinned image's own list, else the oldest image's. */
158
+ export const knownCapabilities = ref => (isPinnedImage(ref || DEFAULT_IMAGE) ? PINNED_CAPABILITIES : FALLBACK_CAPABILITIES)
159
+
110
160
  /** What the image accepts, read from the image (no network, nothing kept). */
111
161
  export async function probeImage(docker, image) {
112
162
  const base = ['run', '--rm', '--network', 'none']
@@ -2,22 +2,30 @@
2
2
  // show and to keep in a ConfigMap or slatebox.env) and secret references
3
3
  // (secrets, resolved only when the secrets file or Secret is written).
4
4
  // Settings the image does not list are left out with a warning, or refused
5
- // when the person asked for what they turn on.
5
+ // when the person asked for what they turn on. Before the image is on the
6
+ // machine (a plan, or the moment before the yes), what it accepts is only
7
+ // known, not read from it: with { deferred: true } a setting outside that list
8
+ // is noted in `unchecked` instead of refused, and the run checks again once the
9
+ // image is pulled and probed, before anything is claimed or written.
6
10
  import { EXIT, InstallError } from '../errors.mjs'
7
11
  import { aiEnv } from '../ai/settings-adapter.mjs'
8
12
 
9
13
  /**
10
14
  * @param {object} answers resolved answers
11
15
  * @param {{settings: string[]}} caps what the image accepts
12
- * @returns {{env: Record<string,string>, secrets: Record<string,string>, warnings: string[], notes: string[], hostGateway: boolean}}
16
+ * @param {{deferred?: boolean}} [options] deferred: the image is not read yet; refuse nothing, list what is unchecked
17
+ * @returns {{env: Record<string,string>, secrets: Record<string,string>, warnings: string[], notes: string[], hostGateway: boolean, unchecked: string[]}}
13
18
  */
14
- export function settingsFor(answers, caps) {
19
+ export function settingsFor(answers, caps, { deferred = false } = {}) {
15
20
  const known = new Set(caps?.settings || [])
16
21
  const env = {}
17
22
  const secrets = {}
18
23
  const warnings = []
19
24
  const notes = []
25
+ const unchecked = []
20
26
  const require = (name, what) => {
27
+ if (known.has(name)) return
28
+ if (deferred) { if (!unchecked.includes(what)) unchecked.push(what); return }
21
29
  if (!known.has(name)) throw new InstallError(EXIT.PRECONDITION, `This Slatebox image does not support ${what} (it does not accept ${name}). Use a newer image, or leave ${what} off.`)
22
30
  }
23
31
  const k8s = answers.target === 'k8s' || Boolean(answers.k8s)
@@ -63,5 +71,5 @@ export function settingsFor(answers, caps) {
63
71
  if (answers.address.team) secrets.SLATEBOX_TUNNEL_TOKEN = 'tunnel'
64
72
  if (answers.mail?.urlFrom) secrets.SLATEBOX_MAIL_URL = answers.mail.urlFrom
65
73
 
66
- return { env, secrets, warnings, notes, hostGateway: ai.hostGateway }
74
+ return { env, secrets, warnings, notes, hostGateway: ai.hostGateway, unchecked }
67
75
  }
@@ -24,17 +24,21 @@ function client(ctx, base) {
24
24
  return ctx.cloud
25
25
  }
26
26
 
27
- /** A team address that cannot be had: the same answer for taken, reserved and blocked names. */
28
- function unavailable(name, suggestions = []) {
27
+ /**
28
+ * A team address that cannot be had: the same answer for taken and blocked names. A reserved name
29
+ * (Slatebox's own: www, admin, test, e2e-...) says so, in Slatebox Cloud's words.
30
+ */
31
+ function unavailable(name, suggestions = [], { reason, message } = {}) {
29
32
  const free = suggestions?.length ? `\n Free right now: ${suggestions.join(', ')}` : ''
30
- return new InstallError(EXIT.NEEDS_INPUT, `${teamHost(name)} isn't available.${free}\n Choose another: --team-address <name>`, { id: 'address-unavailable', field: 'address.team', suggestions: suggestions || [] })
33
+ const why = reason === 'reserved' ? (message && /reserved/i.test(message) ? message.replace(/\s*Choose another name\.?$/, '') : `${teamHost(name)} is reserved for Slatebox itself.`) : `${teamHost(name)} isn't available.`
34
+ return new InstallError(EXIT.NEEDS_INPUT, `${why}${free}\n Choose another: --team-address <name>`, { id: 'address-unavailable', field: 'address.team', suggestions: suggestions || [], ...(reason ? { reason } : {}) })
31
35
  }
32
36
 
33
37
  function cloudFailure(error, name) {
34
38
  if (error instanceof InstallError) return error
35
39
  if (!(error instanceof CloudError)) return error
36
40
  switch (error.code) {
37
- case 'unavailable': return unavailable(name, error.suggestions)
41
+ case 'unavailable': return unavailable(name, error.suggestions, { reason: error.reason, message: error.message })
38
42
  case 'invalid_name': return new InstallError(EXIT.USAGE, `"${name}" is not a team address: ${TEAM_ADDRESS_RULE}.`, { field: 'address.team' })
39
43
  case 'limit_reached': return new InstallError(EXIT.PRECONDITION, `Your Slatebox account already has the most team addresses it may hold, or claimed too many today. ${error.message} Release one you no longer use (slatebox address release on that install), or use your own domain: --domain boards.example.com`, { id: 'address-limit' })
40
44
  case 'rate_limited': return new InstallError(EXIT.PRECONDITION, `Slatebox Cloud asks you to wait${error.retryAfter ? ` ${error.retryAfter} seconds` : ''} before trying again. Nothing was changed.`, { id: 'rate-limited', retryAfter: error.retryAfter })
@@ -3,11 +3,12 @@
3
3
  //
4
4
  // preflight -> image -> plan -> confirm -> secrets -> files -> start -> health
5
5
  // -> (rollback on failure) -> first account -> backup schedule -> record
6
- import { existsSync, readdirSync } from 'node:fs'
6
+ import { existsSync, mkdirSync, readdirSync, readFileSync, rmSync, writeFileSync } from 'node:fs'
7
+ import { homedir } from 'node:os'
7
8
  import { join } from 'node:path'
8
9
  import { EXIT, InstallError } from '../errors.mjs'
9
10
  import { firstAdmin, makeSetupLink, setupState, stillWaiting } from '../setup-link.mjs'
10
- import { checkArch, checkCpu, DEFAULT_IMAGE, FALLBACK_CAPABILITIES, inspectImage, normalArch, pinImage, probeImage, refreshTag, resolveImage } from '../image.mjs'
11
+ import { checkArch, checkCpu, DEFAULT_IMAGE, FALLBACK_CAPABILITIES, inspectImage, isPinnedImage, knownCapabilities, normalArch, pinImage, probeImage, refreshTag, resolveImage } from '../image.mjs'
11
12
  import { emptyPlan } from '../plan.mjs'
12
13
  import { installDir, recordText, writeRecord } from '../record.mjs'
13
14
  import { COMPOSE_FILE, hostPort, ports, renderCompose, SECRETS_FILE, SETTINGS_FILE } from '../render/compose.mjs'
@@ -254,14 +255,14 @@ async function startAndCheck(ctx, host, answers) {
254
255
 
255
256
  // ------------------------------------------------------------------ backups
256
257
 
257
- function backupScript(host, answers, facts) {
258
+ function backupScript(ctx, host, answers, facts) {
258
259
  const to = answers.backups.to
259
260
  const s3 = to.startsWith('s3://')
260
261
  const dir = backupsDir(host, answers)
261
262
  const bucket = `${to.replace(/\/$/, '')}/`
262
263
  return `#!/bin/sh
263
264
  # Written by the slatebox installer: one backup of the Slatebox "${answers.name}",
264
- # keeping the last ${answers.backups.keep}. Run by ${host.kind === 'ssh' ? 'a systemd timer or cron' : 'cron'}; safe to run by hand.
265
+ # keeping the last ${answers.backups.keep}. Run by ${host.kind === 'ssh' ? 'a systemd timer or cron' : usesLaunchd(ctx, host, answers) ? 'a launchd agent' : 'cron'}; safe to run by hand.
265
266
  set -u
266
267
  umask 077
267
268
  docker=${shq(facts.docker_path || 'docker')}
@@ -286,10 +287,113 @@ ls -1t "$dir"/slatebox-*.gz 2>/dev/null | tail -n +${answers.backups.keep + 1} |
286
287
 
287
288
  const MARK = name => `# slatebox-installer:${name}`
288
289
 
290
+ // Every scheduler command gets this long. On macOS `crontab -` can wait for a permission prompt
291
+ // that a terminal never shows; nothing the installer runs after "healthy" may hang on it.
292
+ export const SCHEDULER_TIMEOUT_MS = 30_000
293
+
294
+ /** Why a scheduler command failed, in words: never an empty reason. */
295
+ function schedulerFailure(command, result, ctx) {
296
+ if (result.code === 124) {
297
+ const mac = (ctx.platform || process.platform) === 'darwin'
298
+ return `${command} did not finish within ${(ctx.schedulerTimeout ?? SCHEDULER_TIMEOUT_MS) / 1000}s and was stopped${mac ? ' (macOS may be waiting for permission for your terminal to change the crontab)' : ''}`
299
+ }
300
+ if (result.code === 127) return `${command} is not installed on this computer`
301
+ const said = lastLine(result.stderr) || lastLine(result.stdout)
302
+ return `${command} exited with code ${result.code}${said ? `: ${said}` : ' without saying why'}`
303
+ }
304
+
305
+ const schedulerRun = (ctx, cmd, args, options = {}) => ctx.run(cmd, args, { ...options, timeout: ctx.schedulerTimeout ?? SCHEDULER_TIMEOUT_MS })
306
+
307
+ // ---- macOS: a launchd agent, not cron. It needs no permission prompt (cron's crontab does, and can
308
+ // block on it), and a run missed while the Mac sleeps happens when it wakes.
309
+ export const launchAgentLabel = name => `com.slatebox.${name}.backup`
310
+ export const launchAgentPath = (ctx, name) => join(ctx.env?.HOME || homedir(), 'Library', 'LaunchAgents', `${launchAgentLabel(name)}.plist`)
311
+
312
+ /** A cron schedule launchd can say (each field * or one number), as StartCalendarInterval keys; else null. */
313
+ export function launchdInterval(schedule) {
314
+ const fields = String(schedule || '').trim().split(/\s+/)
315
+ if (fields.length !== 5) return null
316
+ const keys = ['Minute', 'Hour', 'Day', 'Month', 'Weekday']
317
+ const out = {}
318
+ for (const [i, field] of fields.entries()) {
319
+ if (field === '*') continue
320
+ if (!/^\d{1,2}$/.test(field)) return null
321
+ out[keys[i]] = Number(field)
322
+ }
323
+ return 'Minute' in out ? out : null
324
+ }
325
+
326
+ const xml = text => String(text).replace(/&/g, '&amp;').replace(/</g, '&lt;').replace(/>/g, '&gt;')
327
+
328
+ export function launchAgentText(label, script, log, interval) {
329
+ const calendar = Object.entries(interval).map(([key, value]) => ` <key>${key}</key><integer>${value}</integer>`).join('\n')
330
+ return `<?xml version="1.0" encoding="UTF-8"?>
331
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
332
+ <!-- Written by the slatebox installer: the backup schedule of a Slatebox on this Mac. -->
333
+ <plist version="1.0">
334
+ <dict>
335
+ <key>Label</key><string>${xml(label)}</string>
336
+ <key>ProgramArguments</key>
337
+ <array><string>/bin/sh</string><string>${xml(script)}</string></array>
338
+ <key>StartCalendarInterval</key>
339
+ <dict>
340
+ ${calendar}
341
+ </dict>
342
+ <key>StandardOutPath</key><string>${xml(log)}</string>
343
+ <key>StandardErrorPath</key><string>${xml(log)}</string>
344
+ </dict>
345
+ </plist>
346
+ `
347
+ }
348
+
349
+ /** Backups on this Mac go to launchd when the schedule fits it (a daily one always does). */
350
+ export const usesLaunchd = (ctx, host, answers) =>
351
+ host.kind === 'local' && (ctx.platform || process.platform) === 'darwin' && Boolean(launchdInterval(answers.backups.schedule))
352
+
353
+ /** Take the installer's own cron line out, if there is one (an install from before launchd). Never writes a crontab otherwise. */
354
+ async function removeCronLine(ctx, name) {
355
+ const listed = await schedulerRun(ctx, 'crontab', ['-l'])
356
+ if (listed.code !== 0 || !listed.stdout.split('\n').some(line => line.endsWith(MARK(name)))) return false
357
+ const others = listed.stdout.split('\n').filter(line => !line.endsWith(MARK(name)))
358
+ while (others.length && others.at(-1) === '') others.pop()
359
+ const written = await schedulerRun(ctx, 'crontab', ['-'], { input: others.length ? `${others.join('\n')}\n` : '' })
360
+ if (written.code !== 0) throw new Error(schedulerFailure('crontab', written, ctx))
361
+ return true
362
+ }
363
+
364
+ async function scheduleLaunchd(ctx, host, answers) {
365
+ const label = launchAgentLabel(answers.name)
366
+ const path = launchAgentPath(ctx, answers.name)
367
+ const domain = `gui/${ctx.uid ?? process.getuid?.() ?? 501}`
368
+ const existing = existsSync(path) ? readFileSync(path, 'utf8') : null
369
+ if (answers.backups.to === 'off') {
370
+ if (existing !== null) {
371
+ await schedulerRun(ctx, 'launchctl', ['bootout', `${domain}/${label}`])
372
+ rmSync(path, { force: true })
373
+ }
374
+ const cron = await removeCronLine(ctx, answers.name).catch(() => false)
375
+ return existing !== null || cron ? 'removed' : 'unchanged'
376
+ }
377
+ const text = launchAgentText(label, join(host.dir, BACKUP_SCRIPT), join(host.dir, 'backup.log'), launchdInterval(answers.backups.schedule))
378
+ const cron = await removeCronLine(ctx, answers.name).catch(() => false)
379
+ if (existing === text && !cron) return 'unchanged'
380
+ mkdirSync(join(path, '..'), { recursive: true })
381
+ writeFileSync(path, text, { mode: 0o644 })
382
+ // Load it again so a changed schedule takes effect; "not loaded" from bootout is fine.
383
+ await schedulerRun(ctx, 'launchctl', ['bootout', `${domain}/${label}`])
384
+ const loaded = await schedulerRun(ctx, 'launchctl', ['bootstrap', domain, path])
385
+ if (loaded.code !== 0) throw new Error(schedulerFailure('launchctl bootstrap', loaded, ctx))
386
+ return `a launchd agent (${label}; a run missed while the Mac sleeps happens when it wakes)`
387
+ }
388
+
289
389
  async function scheduleBackups(ctx, host, answers, facts) {
290
390
  const script = join(host.dir, BACKUP_SCRIPT)
391
+ if (host.kind === 'local' && (ctx.platform || process.platform) === 'darwin' && (answers.backups.to === 'off' || usesLaunchd(ctx, host, answers))) {
392
+ return scheduleLaunchd(ctx, host, answers)
393
+ }
291
394
  if (host.kind === 'local') {
292
- const listed = await ctx.run('crontab', ['-l'])
395
+ const listed = await schedulerRun(ctx, 'crontab', ['-l'])
396
+ if (listed.code === 124) throw new Error(schedulerFailure('crontab -l', listed, ctx))
293
397
  const current = listed.code === 0 ? listed.stdout : ''
294
398
  const lines = current.split('\n')
295
399
  const ours = lines.filter(line => line.endsWith(MARK(answers.name)))
@@ -299,8 +403,8 @@ async function scheduleBackups(ctx, host, answers, facts) {
299
403
  const others = lines.filter(line => !line.endsWith(MARK(answers.name)))
300
404
  while (others.length && others.at(-1) === '') others.pop()
301
405
  const next = [...others, ...want].length ? `${[...others, ...want].join('\n')}\n` : ''
302
- const written = await ctx.run('crontab', ['-'], { input: next })
303
- if (written.code !== 0) throw new Error(`crontab: ${lastLine(written.stderr)}`)
406
+ const written = await schedulerRun(ctx, 'crontab', ['-'], { input: next })
407
+ if (written.code !== 0) throw new Error(schedulerFailure('crontab', written, ctx))
304
408
  return answers.backups.to === 'off' ? 'removed' : 'cron'
305
409
  }
306
410
  const unit = `slatebox-${answers.name}-backup`
@@ -353,11 +457,14 @@ async function applyOn(ctx, host, answers, { record, planOnly = false, imageRef,
353
457
 
354
458
  // The image. Before a yes, only what is already on the host is looked at:
355
459
  // nothing is pulled or loaded (an upgrade fetches its tag first, because
356
- // whether it is newer is the question the plan answers).
460
+ // whether it is newer is the question the plan answers). An image that is not
461
+ // here yet is planned with what it is known to accept (this release's pinned
462
+ // image: its own list), and nothing is refused on a guess: after the yes it is
463
+ // pulled and probed first, and only then checked, before any claim or file.
357
464
  const dockerMissing = host.kind === 'ssh' && facts.needsDocker
358
465
  const wanted = imageRef || answers.image || DEFAULT_IMAGE
359
466
  let image = { ref: wanted, pinned: wanted, id: null }
360
- let caps = FALLBACK_CAPABILITIES
467
+ let caps = archive ? FALLBACK_CAPABILITIES : knownCapabilities(wanted)
361
468
  let imageReady = false
362
469
  const ready = async () => {
363
470
  caps = await probeImage(host.docker, image.id)
@@ -377,11 +484,11 @@ async function applyOn(ctx, host, answers, { record, planOnly = false, imageRef,
377
484
  const stored = { ...parseEnvFile(existing.files[KEPT_FILE] || ''), ...parseEnvFile(existing.files[SECRETS_FILE] || '') }
378
485
  let settings, composeText, settingsText, scriptText, secretsText, generated, kept
379
486
  const render = async () => {
380
- settings = settingsFor(answers, caps)
487
+ settings = settingsFor(answers, caps, { deferred: !imageReady })
381
488
  guardKey(ctx, host, answers, stored, settings.secrets, existing)
382
489
  composeText = renderCompose(answers, { image: image.pinned, hostGateway: settings.hostGateway })
383
490
  settingsText = envFileText(settings.env, `Settings for the Slatebox "${answers.name}", written by the slatebox installer. No secrets.`)
384
- scriptText = answers.backups.to === 'off' ? null : backupScript(host, answers, facts)
491
+ scriptText = answers.backups.to === 'off' ? null : backupScript(ctx, host, answers, facts)
385
492
  // The key encryption key is made once and then kept; referenced keys are read now. Before
386
493
  // the plan is approved, a team address that is still to be claimed has no token: the plan
387
494
  // shows a stand-in, and nothing is written until the claim has brought the real one.
@@ -423,7 +530,8 @@ async function applyOn(ctx, host, answers, { record, planOnly = false, imageRef,
423
530
  }
424
531
  if (!imageReady) {
425
532
  plan.commands.push(archive ? `docker load < ${archive} (on ${host.where}, after you confirm)` : `docker pull ${wanted} (on ${host.where}, after you confirm)`)
426
- plan.notes.push(`${archive ? `The image is loaded from ${archive}` : `${wanted} is not on ${host.where} yet: it is pulled`} after you confirm, and checked before anything starts. Until then the plan assumes the current image's settings.`)
533
+ plan.notes.push(`${archive ? `The image is loaded from ${archive}` : `${wanted} is not on ${host.where} yet: it is downloaded`} after you confirm, and checked before anything is claimed, written or started. ${isPinnedImage(wanted) && !archive ? 'The plan uses the settings this release\'s image accepts.' : 'Until then the plan assumes the current image\'s settings.'}`)
534
+ if (settings.unchecked.length) plan.notes.push(`Checked once the image is here: that it supports ${settings.unchecked.join(', ')}.`)
427
535
  }
428
536
  if (!nothing) {
429
537
  plan.files.push(
@@ -437,14 +545,20 @@ async function applyOn(ctx, host, answers, { record, planOnly = false, imageRef,
437
545
  plan.warnings.push(`The container is not running, so no backup can be taken before the ${imageChanged ? 'upgrade' : 'change'}: if it fails there is no copy to roll the data back to. Take one yourself first if you have an older backup to restore from (slatebox restore <file>).`)
438
546
  }
439
547
  plan.commands.push(`docker compose -p ${answers.name} up -d --wait`, `docker exec ${answers.name} slatebox health --deep`)
440
- if (scriptText) plan.commands.push(host.kind === 'local' ? `crontab: ${answers.backups.schedule} ${join(host.dir, BACKUP_SCRIPT)}` : `systemd timer (or /etc/cron.d) slatebox-${answers.name}-backup`)
548
+ if (scriptText) {
549
+ if (usesLaunchd(ctx, host, answers)) {
550
+ plan.files.push({ path: launchAgentPath(ctx, answers.name), note: `the launchd agent that runs ${BACKUP_SCRIPT} (${answers.backups.schedule})` })
551
+ plan.commands.push(`launchctl bootstrap gui/<you> ${launchAgentPath(ctx, answers.name)}`)
552
+ } else plan.commands.push(host.kind === 'local' ? `crontab: ${answers.backups.schedule} ${join(host.dir, BACKUP_SCRIPT)}` : `systemd timer (or /etc/cron.d) slatebox-${answers.name}-backup`)
553
+ }
441
554
  if (answers.address.port === null) plan.notes.push(`HTTPS: Slatebox gets and renews a certificate for ${new URL(answers.address.url).hostname} itself; point its DNS here and open ports 80 and 443.`)
442
555
  else if (answers.address.url.startsWith('http:') && host.kind === 'ssh') plan.warnings.push('Plain HTTP: anyone on the network path can read what people type. Give --domain for HTTPS.')
443
556
  if (host.kind === 'local' && answers.address.port !== null && ['0.0.0.0', '::'].includes(answers.address.listen)) {
444
557
  plan.warnings.push(`Published on every network interface (--listen ${answers.address.listen}) over plain HTTP: anyone who can reach this computer can open the first-account page, and Docker's port rules bypass firewalls such as ufw.`)
445
558
  }
446
559
  if (host.kind === 'local' && scriptText) {
447
- if ((ctx.platform || process.platform) === 'darwin') plan.notes.push('Backups run from cron, which skips a run while this computer sleeps; `slatebox status` says when the last backup is late.')
560
+ if (usesLaunchd(ctx, host, answers)) plan.notes.push('Backups run from a launchd agent (no permission prompt); a run missed while this Mac sleeps happens when it wakes. `slatebox status` says when the last backup is late.')
561
+ else if ((ctx.platform || process.platform) === 'darwin') plan.notes.push('Backups run from cron, which skips a run while this computer sleeps; `slatebox status` says when the last backup is late.')
448
562
  if (ctx.env.WSL_DISTRO_NAME) plan.warnings.push('WSL usually has no cron daemon running: start it (sudo service cron start) or scheduled backups will not run.')
449
563
  }
450
564
  if (host.kind === 'ssh' && (facts.ufw === 'active' || facts.firewalld === 'running')) {
@@ -476,11 +590,8 @@ async function applyOn(ctx, host, answers, { record, planOnly = false, imageRef,
476
590
  if (installed.code !== 0 || check.code !== 0) throw new InstallError(EXIT.PRECONDITION, `Docker could not be installed or started on ${host.where}: ${lastLine(installed.stderr || check.stderr)}`)
477
591
  out.step('docker', 'ok', `Docker ${check.stdout.trim()} on ${host.where}`)
478
592
  }
479
- if (team && !ctx.tunnelToken && !stored[TUNNEL_TOKEN]) {
480
- // The claim is kept if anything after this fails: the next run reuses it.
481
- await ensureTeamAddress(ctx, answers, team, stored)
482
- await render()
483
- }
593
+ // The image first: nobody claims a name, and nothing is written, for an image that cannot be
594
+ // had (offline) or that does not support what was asked for (render() refuses it now).
484
595
  if (!imageReady) {
485
596
  image = await resolveImage(host.docker, { ref: imageRef || answers.image, archive, loadArchive: host.loadArchive, step: out.step.bind(out) })
486
597
  await ready()
@@ -492,6 +603,11 @@ async function applyOn(ctx, host, answers, { record, planOnly = false, imageRef,
492
603
  return done(ctx, host, answers, image, { nothing: true })
493
604
  }
494
605
  }
606
+ if (team && !ctx.tunnelToken && !stored[TUNNEL_TOKEN]) {
607
+ // The claim is kept if anything after this fails: the next run reuses it.
608
+ await ensureTeamAddress(ctx, answers, team, stored)
609
+ await render()
610
+ }
495
611
 
496
612
  // Before an upgrade, a backup the rollback can restore.
497
613
  let preUpgrade = null
@@ -524,6 +640,9 @@ async function applyOn(ctx, host, answers, { record, planOnly = false, imageRef,
524
640
  const inImage = args => host.docker(['exec', answers.name, SLATEBOX, ...args])
525
641
  const linked = caps.commands.includes('setup-link') && await firstAdmin(ctx, inImage)
526
642
  if (!linked && fresh) await firstAccount(ctx, host, answers, caps)
643
+ // The address and the setup link are what the person waits for: they are printed now, before
644
+ // the backup schedule, which only ever warns (and gives up after a timeout) if it cannot be set.
645
+ ctx.announce?.(done(ctx, host, answers, image, { generated, fresh }))
527
646
  if (scriptText || previous[BACKUP_SCRIPT]) {
528
647
  try {
529
648
  const how = await scheduleBackups(ctx, host, answers, facts)
@@ -5,7 +5,7 @@
5
5
  import { existsSync, mkdirSync, writeFileSync } from 'node:fs'
6
6
  import { dirname, join, resolve } from 'node:path'
7
7
  import { EXIT, InstallError } from '../errors.mjs'
8
- import { DEFAULT_IMAGE, FALLBACK_CAPABILITIES, probeImage } from '../image.mjs'
8
+ import { DEFAULT_IMAGE, FALLBACK_CAPABILITIES, isPinnedImage, PINNED_CAPABILITIES, probeImage } from '../image.mjs'
9
9
  import { emptyPlan } from '../plan.mjs'
10
10
  import { renderCompose, SECRETS_FILE, SETTINGS_FILE } from '../render/compose.mjs'
11
11
  import { renderHelmChart } from '../render/helm.mjs'
@@ -27,6 +27,8 @@ export async function exportFiles(ctx, answers, { planOnly = false } = {}) {
27
27
  let caps = FALLBACK_CAPABILITIES
28
28
  if (image.local) {
29
29
  try { caps = await probeImage((args, o) => ctx.run('docker', args, o), image.id) } catch { warnings.push('The image did not list its settings; the current image\'s settings were assumed.') }
30
+ } else if (isPinnedImage(image.ref)) {
31
+ caps = PINNED_CAPABILITIES
30
32
  } else {
31
33
  warnings.push(`${image.ref} is not on this computer, so the files assume the current image's settings and are not pinned to a digest.`)
32
34
  }
@@ -6,7 +6,7 @@ import { mkdirSync, rmSync } from 'node:fs'
6
6
  import { join } from 'node:path'
7
7
  import { EXIT, InstallError } from '../errors.mjs'
8
8
  import { collect, resolveAnswers } from '../answers.mjs'
9
- import { checkArch, DEFAULT_IMAGE, FALLBACK_CAPABILITIES, hasRegistry, isTag, probeImage } from '../image.mjs'
9
+ import { checkArch, DEFAULT_IMAGE, FALLBACK_CAPABILITIES, hasRegistry, isPinnedImage, isTag, PINNED_CAPABILITIES, probeImage } from '../image.mjs'
10
10
  import { emptyPlan } from '../plan.mjs'
11
11
  import { installDir, recordText, writeRecord } from '../record.mjs'
12
12
  import { MANAGER, names, renderK8s, renderSecret } from '../render/k8s.mjs'
@@ -126,6 +126,8 @@ async function capabilities(ctx, image, warnings) {
126
126
  if (image.local) {
127
127
  try { return await probeImage((args, o) => ctx.run('docker', args, o), image.id || image.ref) } catch { /* fall through */ }
128
128
  }
129
+ // This release's own image: what it accepts is known without pulling it here (the cluster pulls it).
130
+ if (isPinnedImage(image.ref)) return PINNED_CAPABILITIES
129
131
  warnings.push(`The image was not on this computer, so its settings could not be read from it; the installer assumed the settings of the current image (pull ${image.ref} first to check).`)
130
132
  return FALLBACK_CAPABILITIES
131
133
  }