@ours.network/install 2.1.4 → 2.1.6

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
@@ -200,43 +200,16 @@ same SDK/CLI graph; installer publication and rollout are separate steps, see
200
200
  versions remain rejected within each selected graph. The same nightly set selects Cowork `1.3.4-nightly.20261019.b0d73c0`, Telegram `1.0.1-nightly.16`, Messenger `1.0.31-nightly.25`, Notifications `0.3.1-nightly.7`, and the MCP/Codex/Claude Code suite `1.2.0-nightly.18`. An explicit `--sources`
201
201
  override remains available for development.
202
202
 
203
- ## Migrate an existing global installation
203
+ ## Old installation layouts
204
204
 
205
- The wizard detects the old `~/.ours/config.json` and offers to keep its identities,
206
- messages, keys and settings in the new installation. It follows the configured
207
- state directory, including a custom location. An equivalent unattended preset is:
208
-
209
- ```sh
210
- ours-install all --mode docker --state-dir "$HOME/ours-docker" \
211
- --migrate-from "$HOME/.ours/config.json" --compatible --integrations codex
212
- ```
213
-
214
- Run the old daemon before the first migration so the installer can record and
215
- verify its identities. The new runtime is downloaded/built first. Then the old
216
- boot service and daemon stop, and the complete daemon state is copied while its
217
- writer lock is held. Docker migration imports that copy into its named storage
218
- volume. Existing Human/role names and CIDs must match before applications start;
219
- migration never creates a replacement Human.
220
-
221
- The original state/configuration remain unchanged. A private `legacy-backup`
222
- directory stores the original config/service definition, and
223
- `legacy-client/profile.json` is a prepared connection profile for the new server.
224
- Selected integrations are configured by the usual client setup. The global `ours` command is switched to a launcher for the managed installation
225
- only after verifying ownership of its existing npm entry; foreign or read-only
226
- commands are refused before migration. Ordinary `ours identity list` is checked
227
- after cutover. Lifecycle commands manage the new installation, and selection
228
- overrides cannot accidentally return to the old daemon. The old configuration is
229
- not reinterpreted as a client profile. Do not start the old state alongside the
230
- migrated daemon. Reinstalling the global CLI with npm can replace the launcher;
231
- repeat the same migration command to verify and repair that routing.
232
-
233
- Repeat the same command after an interruption. Once the destination has started,
234
- retries repair it in place instead of replacing it with an older source snapshot.
235
- The source is kept stopped after an activation failure to avoid diverging identity
236
- sessions. Migration requires local Linux/macOS (or WSL) with `node:sqlite` support,
237
- a verifiable old CLI/service, and a separate target directory. External PostgreSQL
238
- history or unsupported external MCP/token-delivery paths are refused before
239
- shutdown. Unrelated application data outside the daemon tree is not copied.
205
+ Migration from old installation layouts is no longer supported: neither an
206
+ unmanaged `~/.ours` daemon (`~/.ours/config.json`) nor a managed schema-1
207
+ installation is imported or converted. Setup never offers to bring such data
208
+ over; a leftover `~/.ours` is ignored and a fresh installation is created in its
209
+ own folder. `--migrate-from` is refused as unsupported, and a selected folder
210
+ holding a schema-1 or partially converted/imported record is refused before
211
+ anything is written. Existing data is never changed or deleted; install fresh
212
+ into a new folder.
240
213
 
241
214
  ## Selected network installations (2.0)
242
215
 
@@ -268,15 +241,25 @@ Assets resolve from the installed package, independently of the working director
268
241
  Package mode requires a patched Node.js release, npm and a working systemd user manager on
269
242
  Linux/WSL or a launchd GUI user domain on macOS. Source builds also require Git,
270
243
  Python 3, a C/C++ toolchain, make, and the selected repositories' own prerequisites.
271
- Docker mode requires a working Docker engine and Compose 2.35+; its build image
272
- contains the source-build prerequisites. No bind or Docker socket mounts are used.
244
+ Docker mode requires a working Docker engine and Compose 2.35+. A published installer
245
+ downloads prebuilt images instead of building them: `adaptframework/ours-runtime` and
246
+ `adaptframework/ours-maintenance` (linux/amd64; a `server` variant for the full workspace
247
+ and a `daemon` variant for plugin-only), pulled by the exact digests packed in
248
+ `assets/images.json` and checked against the installation's selected packages. The
249
+ gateway runs the digest-pinned upstream nginx image with its generated configuration
250
+ carried in Compose, so nothing is built for it. Images are built locally only for an
251
+ explicit custom/Git selection, an installation created by an earlier installer (until
252
+ `ours-install update`), a development checkout, or when `OURS_BUILD_LOCALLY=1` is set;
253
+ a download failure is reported (for Docker Hub's anonymous pull limit, run
254
+ `docker login`) rather than silently switching to a build. The build image contains
255
+ the source-build prerequisites. No bind or Docker socket mounts are used.
273
256
  Docker is recommended for macOS and Windows. Install and start Docker Desktop
274
257
  on those hosts; on Linux, install Docker Engine and the Compose plugin. If Docker
275
258
  is unavailable, the installer explains how to install/start it or use
276
259
  `server install --mode packages --state-dir <new-empty-directory>` instead.
277
260
  Native Windows installations require WSL with a working systemd user manager.
278
261
  The installer never switches an existing installation's mode automatically.
279
- Server installation shows each stage before it starts, streams Docker builds and
262
+ Server installation shows each stage before it starts, streams image downloads or builds and
280
263
  native package acquisition, and reports completion only after service readiness.
281
264
  If a Docker service fails, the error includes its last 50 log lines (bounded in
282
265
  size) and a command to inspect the logs. A failed daemon prevents consumers from
@@ -304,8 +287,8 @@ Fresh Docker preparation leaves daemon state containing only its selected config
304
287
  Only after owning `access-init` succeeds are daemon provenance and MCP profile
305
288
  files materialized, so fresh setup never needs an inferred migration.
306
289
  Initial setup calls owning CLI `access-init`, then `access-issue --replace` for
307
- managed credential destinations. Explicit legacy migration adds `--migrate` to
308
- `server install`; migration is never inferred. Global replacement stops consumers
290
+ managed credential destinations. Explicit daemon credential migration adds
291
+ `--migrate` to `server install`; it is never inferred. Global replacement stops consumers
309
292
  and the daemon, calls `access-replace` once, repairs managed credential delivery,
310
293
  and restarts only previously running services. If delivery/startup fails after
311
294
  replacement, the new master remains authoritative and setup is reported incomplete.
@@ -643,10 +626,7 @@ ours-install server install --mode docker --container-engine podman \
643
626
  and standalone Compose provider, plus the UID/GID mapping fingerprint. Records without `containerEngine` continue to
644
627
  use Docker. Package/client installs reject the engine option. Existing records
645
628
  cannot change engines through a flag or ambient connection change; automatic
646
- Docker-to-Podman data migration is not provided. Legacy local-daemon migration
647
- (`--migrate-from`) to Podman is also unsupported and is refused before source
648
- shutdown or managed CLI publication, including migration retries. Use a fresh
649
- Podman installation, or migrate the legacy daemon with Docker/packages.
629
+ Docker-to-Podman data migration is not provided; use a fresh Podman installation.
650
630
 
651
631
  Podman uses its native build command, with the same resolved Compose build
652
632
  context, target, architecture, arguments and secret references, followed by
@@ -844,7 +824,7 @@ restart policy overlay also covers retained Compose files. Reconciliation update
844
824
  only this project's recorded long-running containers and does not start or
845
825
  recreate a deliberately stopped container. `server start` can reconcile policies
846
826
  but does not retrofit health supervision into an old image: run install/update.
847
- Backup, migration and update still stop writers before maintenance, and a failed
827
+ Backup, restore and update still stop writers before maintenance, and a failed
848
828
  maintenance operation keeps them stopped. `server uninstall` (also `ours-uninstall --state-dir PATH` for a managed
849
829
  schema-2 installation) stops and removes managed services, retaining volumes,
850
830
  identity and credentials. It refuses unfinished transitions and data purge.
package/assets/Dockerfile CHANGED
@@ -24,7 +24,6 @@ COPY --chmod=644 scripts/runtime/check-client.mjs /opt/ours/docker/check-client.
24
24
  COPY --chmod=644 scripts/runtime/check-start.mjs /opt/ours/docker/check-start.mjs
25
25
  COPY --chmod=644 scripts/runtime/client-setup.mjs scripts/runtime/notification-config.mjs /opt/ours/docker/
26
26
  COPY --chmod=644 scripts/runtime/diagnostics.mjs /opt/ours/docker/diagnostics.mjs
27
- COPY --chmod=644 scripts/runtime/legacy-import.mjs /opt/ours/docker/legacy-import.mjs
28
27
  COPY --chmod=644 scripts/runtime/entrypoint.sh /opt/ours/docker/entrypoint.sh
29
28
  COPY --chmod=644 scripts/runtime/healthcheck.mjs /opt/ours/docker/healthcheck.mjs
30
29
  COPY --chmod=644 scripts/runtime/start-telegram.sh scripts/runtime/health-telegram.sh scripts/runtime/start-cowork.sh scripts/runtime/health-cowork.sh scripts/runtime/start-messenger.sh scripts/runtime/health-messenger.mjs scripts/runtime/notifications-gateway.mjs scripts/runtime/supervise.mjs scripts/runtime/recover.mjs scripts/runtime/dependency-ready.mjs /opt/ours/docker/
@@ -184,26 +184,6 @@ services:
184
184
  start_period: 30s
185
185
  retries: 12
186
186
 
187
- legacy-import:
188
- profiles: [maintenance]
189
- build:
190
- <<: *source-build
191
- target: maintenance
192
- platform: linux/amd64
193
- image: "${OURS_MAINTENANCE_IMAGE:-ours-compose-2-maintenance:local}"
194
- user: "0:0"
195
- network_mode: none
196
- read_only: true
197
- cap_drop: [ALL]
198
- cap_add: [CHOWN, DAC_OVERRIDE]
199
- security_opt: [no-new-privileges:true]
200
- entrypoint: [node, /opt/ours/docker/legacy-import.mjs]
201
- environment:
202
- OURS_UID: "${OURS_UID:-1000}"
203
- OURS_GID: "${OURS_GID:-1000}"
204
- volumes:
205
- - {type: volume, source: server-storage, target: /storage, volume: {nocopy: true}}
206
-
207
187
  state-operation:
208
188
  profiles: [maintenance]
209
189
  build:
@@ -30,7 +30,9 @@ if [ -z "$resolvers" ]; then echo 'Gateway: no valid runtime DNS nameserver' >&2
30
30
  umask 077
31
31
  config=$(mktemp /tmp/ours-nginx.XXXXXX)
32
32
  trap 'rm -f "$config"' EXIT HUP INT TERM
33
- sed "s/@@OURS_RESOLVERS@@/$resolvers/g" "${OURS_NGINX_TEMPLATE:-/etc/nginx/ours.conf.template}" > "$config"
33
+ # Compose passes the generated template in the environment; a file remains for fixtures.
34
+ if [ -n "${OURS_GATEWAY_TEMPLATE:-}" ]; then printf '%s' "$OURS_GATEWAY_TEMPLATE"; else cat "${OURS_NGINX_TEMPLATE:-/etc/nginx/ours.conf.template}"; fi \
35
+ | sed "s/@@OURS_RESOLVERS@@/$resolvers/g" > "$config"
34
36
  nginx -t -c "$config"
35
37
  # nginx opens the config before the shell exits; exec leaves this file in tmpfs.
36
38
  trap - EXIT HUP INT TERM
@@ -0,0 +1,39 @@
1
+ {
2
+ "schema": 1,
3
+ "channel": "stable",
4
+ "installerVersion": "2.1.6",
5
+ "commit": "a65e9bf2e50a6e0211bdda41be5460760dd87f9b",
6
+ "platform": "linux/amd64",
7
+ "variants": {
8
+ "server": {
9
+ "policySha256": "666953aac3f12ae425c699fd45e0825a7a896fbf8643c7936b06eba7648a9a2a",
10
+ "runtime": {
11
+ "repository": "docker.io/adaptframework/ours-runtime",
12
+ "index": "sha256:67a7a91e0b72275cbcc68a6c92d029fa00a13fbf53a9f18a7461f2ee2d4fde8f",
13
+ "manifest": "sha256:c758b9a2092d33e4aefa21117d1eec68f6115dea9f9d0f32a4e58cd0afb07004",
14
+ "config": "sha256:3715f88a117d909529e1431910e3d39a2371bb1ab92fc161908b0ab145113bbc"
15
+ },
16
+ "maintenance": {
17
+ "repository": "docker.io/adaptframework/ours-maintenance",
18
+ "index": "sha256:1f5a97e1ce5ee8149fb7547e261c8bffaf9e0d45ac27c45cb3e4d48b0df088bd",
19
+ "manifest": "sha256:fd54cd2e333df18ce2bdc6a24e2a2dde10b6e16a8a8205ba4f425bacb2a58094",
20
+ "config": "sha256:116e3d4885ddaddbe5d480df96cc1d41843446ef87394d67084e0657ce386edf"
21
+ }
22
+ },
23
+ "daemon": {
24
+ "policySha256": "d09e46aa9908f95b6bd0f28f555f22b12819b86033f2c1d0f95098e4d19ac1bb",
25
+ "runtime": {
26
+ "repository": "docker.io/adaptframework/ours-runtime",
27
+ "index": "sha256:920d03bab76d2722d0f91c04a0162f9494a9b734855a857f208f5c97f7243693",
28
+ "manifest": "sha256:425f14b42138d2664757172b31aa86b7d07b717e8065d7134596e53eb40a6e1c",
29
+ "config": "sha256:e74ecca100db6730359a1abb21da927cba6dbece86f4a9c1e771671109192339"
30
+ },
31
+ "maintenance": {
32
+ "repository": "docker.io/adaptframework/ours-maintenance",
33
+ "index": "sha256:54d0f414dd46b5b7039bde797aecbd7dca5a44b43a39d0fe2278d8400492d65c",
34
+ "manifest": "sha256:0a29b80c3c8c90cd9895e1e2fda510020738e7d0353610de657155eb43777191",
35
+ "config": "sha256:9db4fbaba42009d33bfa62fafc337a11f19ba68c1b2e8a6cb6c2720039034797"
36
+ }
37
+ }
38
+ }
39
+ }
@@ -582,9 +582,9 @@
582
582
  }
583
583
  },
584
584
  "node_modules/@babel/runtime": {
585
- "version": "7.29.13",
586
- "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.13.tgz",
587
- "integrity": "sha512-v+oN26xP4YIlQsbQ/CbTH1WG5m/l/DjKKZNy/Kp3f/AFvbgt7Em/D0FeMM3O2hX0YzeN2M16W8lOpyhIkfCBcQ==",
585
+ "version": "7.29.14",
586
+ "resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.29.14.tgz",
587
+ "integrity": "sha512-Y5tqevQaUAZhhj82BpYMNC1ssvLQTVAfwKdm8iy8qwmhvC2/CpcAu8OC+QEtjM7pMk7knx83u1Qj8gzkicyelw==",
588
588
  "license": "MIT",
589
589
  "optional": true,
590
590
  "peer": true,
@@ -766,9 +766,9 @@
766
766
  }
767
767
  },
768
768
  "node_modules/@hono/node-server": {
769
- "version": "2.1.6",
770
- "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.6.tgz",
771
- "integrity": "sha512-p/KH9MnfNcsm3sR6x4lNgm5j+QN4Et8srKredl9DZfXiyZ1UQ3aQ2YVpFLbqktYN5JI+DB+VZFKM2PqE5hLKjQ==",
769
+ "version": "2.1.7",
770
+ "resolved": "https://registry.npmjs.org/@hono/node-server/-/node-server-2.1.7.tgz",
771
+ "integrity": "sha512-Wr0E6S+v2Bw9FkpGNP5BQ5QbJvclUa06UVehd65WFZe6XeJwbrKQQ5wPDevc0IC+QyzbO7v3Llh5uo45IZcSnA==",
772
772
  "license": "MIT",
773
773
  "engines": {
774
774
  "node": ">=20"
@@ -1732,9 +1732,9 @@
1732
1732
  "license": "MIT"
1733
1733
  },
1734
1734
  "node_modules/encodeurl": {
1735
- "version": "2.0.1",
1736
- "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.1.tgz",
1737
- "integrity": "sha512-Ev/hIyePLZtpL98x562lvPtenrUfGr0lfaf44HFZ+hDEwso7ccV9QAZrEVLg0hxNAzygaAFxy2dYaAKKM0G06A==",
1735
+ "version": "2.0.2",
1736
+ "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-2.0.2.tgz",
1737
+ "integrity": "sha512-ddmxiyS6ETq/v5/+mdA4fykK7JgEmqcShrGmQFTaKf5o43tL8XLuMzNLLsspuIC3/qGupS7Ci2TF+feJRkYY0w==",
1738
1738
  "license": "MIT",
1739
1739
  "engines": {
1740
1740
  "node": ">= 0.8"
@@ -2213,9 +2213,9 @@
2213
2213
  "license": "MIT"
2214
2214
  },
2215
2215
  "node_modules/hono": {
2216
- "version": "4.13.17",
2217
- "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.17.tgz",
2218
- "integrity": "sha512-vZIcbkvjOR5hHRWERbGkr8fGfF0GGM1ooYkuH448iO3b2AdVEr3AXZSw4Z3Kn+1L5z0CVoVeyV29VGYmFh05kQ==",
2216
+ "version": "4.13.18",
2217
+ "resolved": "https://registry.npmjs.org/hono/-/hono-4.13.18.tgz",
2218
+ "integrity": "sha512-H9q/E1XizaWstJxUW881dmLxEj+t/TrGGnyxINkm4+sK0qUwsMtFdo2BWI9Vs3cIS19MU6b6iCijoUoEf4f3DA==",
2219
2219
  "license": "MIT",
2220
2220
  "engines": {
2221
2221
  "node": ">=16.9.0"
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "schema": 1,
3
3
  "channel": "stable",
4
- "installerVersion": "2.1.4",
4
+ "installerVersion": "2.1.6",
5
5
  "packages": {
6
6
  "@ours.network/sdk": {
7
7
  "version": "5.2.0",
@@ -14,16 +14,14 @@ Backup and restore support the full server or an addressed daemon, Telegram,
14
14
  Cowork or Messenger domain. Daemon archives include MCP preferences. Daemon
15
15
  restore/reset replaces both trees together and preserves other component data
16
16
  and current credentials. Addressed reset requires `--confirm`; full-server reset
17
- is not supported. Managed legacy installations convert to the shared layout
18
- through the installer before ordinary startup; plain script calls are not a
19
- substitute for that coordinated conversion.
17
+ is not supported. Old (schema-1) installation layouts are not converted.
20
18
 
21
19
  | File | Responsibility |
22
20
  |---|---|
23
21
  | `state-operation.mjs` | Validates the selected state, stages replacements and invokes owning package commands to retain current authority |
24
22
  | `state-archive.mjs` | Creates, validates and extracts format-1 archives, preserving private permissions and timestamps |
25
23
  | `state-native.mjs` | Provides the existing OS file-lock and atomic directory operations through Koffi |
26
- | `docker-layout-conversion.mjs` | Stages, validates and publishes the managed legacy Docker state layout under installer coordination |
24
+ | `docker-layout-conversion.mjs` | Validates stopped Docker server state offline after an update (the name is the entrypoint retained images already ship) |
27
25
 
28
26
  Archives are stored in `storage/backups`, outside `storage/state` but on the same
29
27
  storage volume. Removing that volume removes its backups too. Restore creates a
@@ -1,23 +1,19 @@
1
- /** Stopped legacy Docker volumes mapped into the shared server-state archive layout. */
1
+ /** Offline validation of stopped Docker server state; the file name is the retained image entrypoint. */
2
2
  import * as fs from 'node:fs';
3
- import { dirname, join, resolve } from 'node:path';
3
+ import { join, resolve } from 'node:path';
4
4
  import { execFileSync } from 'node:child_process';
5
5
  import { pathToFileURL } from 'node:url';
6
- import { copyPrivateTree, scanSource, createArchive, validateArchive } from './state-archive.mjs';
7
- import { publishNoReplace } from './state-native.mjs';
8
-
9
- import { daemonOwner } from './daemon-owner.mjs';
6
+ import { scanSource } from './state-archive.mjs';
7
+ import { recordNames, readBuildRecords, validateBuildRecordSet } from './build-context.mjs';
10
8
 
11
9
  const COMPONENTS = ['daemon', 'telegram', 'cowork', 'messenger'];
12
- import { recordNames, readBuildRecords, validateBuildRecordSet } from './build-context.mjs';
13
10
  const DAEMON_STATE = '/var/lib/ours';
14
11
  const MCP_STATE = '/var/lib/ours-mcp';
15
- const LEGACY_MCP_CHILD = '.mcp';
16
12
 
17
13
  function privateBytes(path, ownership) {
18
14
  const stat = fs.lstatSync(path);
19
15
  if (!stat.isFile() || stat.uid !== ownership.uid || stat.gid !== ownership.gid || (stat.mode & 0o7777) !== 0o600) {
20
- throw new Error(`Unsafe Docker conversion source file: ${path}`);
16
+ throw new Error(`Unsafe Docker state file: ${path}`);
21
17
  }
22
18
  return fs.readFileSync(path);
23
19
  }
@@ -25,7 +21,7 @@ function privateBytes(path, ownership) {
25
21
  function objectAt(path, ownership) {
26
22
  const value = JSON.parse(privateBytes(path, ownership));
27
23
  if (!value || Array.isArray(value) || typeof value !== 'object') {
28
- throw new Error('Docker conversion configuration must be an object');
24
+ throw new Error('Docker state configuration must be an object');
29
25
  }
30
26
  return value;
31
27
  }
@@ -34,73 +30,10 @@ function validateProfile(profile, instanceId) {
34
30
  if (profile?.endpoint !== 'http://127.0.0.1:3050'
35
31
  || profile.expectedInstanceId !== instanceId
36
32
  || profile.credentialPath !== join(DAEMON_STATE, 'daemon-token')) {
37
- throw new Error('MCP profile does not select this Docker source');
38
- }
39
- }
40
-
41
- /** Source mounts and writer exclusion are selected and held by the installer. */
42
- export async function stageDockerLayout(source, staging, options) {
43
- if (resolve(source) !== source || fs.realpathSync(source) !== source
44
- || source === dirname(source) || resolve(staging) !== staging
45
- || fs.realpathSync(dirname(staging)) !== dirname(staging)
46
- || staging === source || staging.startsWith(source + '/') || source.startsWith(staging + '/')) {
47
- throw new Error('Docker staging must be canonical and outside the source tree');
48
- }
49
- const daemon = join(source, 'daemon', 'data');
50
- const config = objectAt(join(daemon, 'config.json'), options);
51
- if (config.stateDir !== DAEMON_STATE || config.port !== 3050) {
52
- throw new Error('Daemon authority source differs from the selected Docker layout');
53
- }
54
- if (config.networkMcp?.applicationConfigPath !== join(DAEMON_STATE, LEGACY_MCP_CHILD, 'config.json')) {
55
- throw new Error('MCP configuration selects an external or conflicting source');
56
- }
57
- validateProfile(config.networkMcp.profile, options.instanceId);
58
- validateProfile(objectAt(join(daemon, LEGACY_MCP_CHILD, 'profile.json'), options), options.instanceId);
59
- validateBuildRecordSet(options.provenance);
60
- for (const name of recordNames(options.provenance)) {
61
- if (!Buffer.isBuffer(options.provenance?.[name])) throw new Error('Selected build provenance is required');
62
- }
63
-
64
- fs.mkdirSync(staging, { mode: 0o700 });
65
- try {
66
- for (const component of COMPONENTS) {
67
- const data = join(source, component, 'data');
68
- const marker = join(data, '.ours-provenance');
69
- if (fs.readdirSync(marker).sort().join() !== recordNames(options.provenance).sort().join()) {
70
- throw new Error(`Incomplete source ${component} provenance`);
71
- }
72
- for (const name of recordNames(options.provenance)) {
73
- if (!privateBytes(join(marker, name), options).equals(options.provenance[name])) {
74
- throw new Error(`Source ${component} differs from the selected build`);
75
- }
76
- }
77
- copyPrivateTree(data, join(staging, component), options);
78
- }
79
- fs.renameSync(join(staging, 'daemon', LEGACY_MCP_CHILD), join(staging, 'mcp'));
80
- fs.mkdirSync(join(staging, 'credentials'), { mode: 0o700 });
81
- for (const component of COMPONENTS.filter(name => name !== 'daemon')) {
82
- const bytes = privateBytes(join(source, `${component}-credential`, 'daemon-token'), options);
83
- if (!bytes.length) throw new Error('Current managed credential is empty');
84
- const destination = join(staging, 'credentials', component);
85
- fs.mkdirSync(destination, { mode: 0o700 });
86
- fs.writeFileSync(join(destination, 'daemon-token'), bytes, { mode: 0o600, flag: 'wx' });
87
- }
88
- scanSource(staging, options);
89
- } catch (error) {
90
- fs.rmSync(staging, { recursive: true, force: true });
91
- throw error;
33
+ throw new Error('MCP profile does not select this Docker installation');
92
34
  }
93
35
  }
94
36
 
95
- /** Bind only after the original payload has been archived and validated. */
96
- export function bindDockerLayout(staging, options) {
97
- const configPath = join(staging, 'daemon', 'config.json');
98
- const config = objectAt(configPath, options);
99
- validateProfile(config.networkMcp?.profile, options.instanceId);
100
- config.networkMcp.applicationConfigPath = join(MCP_STATE, 'config.json');
101
- fs.writeFileSync(configPath, JSON.stringify(config, null, 2) + '\n');
102
- }
103
-
104
37
  /** The installation's applications: all four, or the daemon alone for collaboration tools. */
105
38
  export function selectedComponents(env = process.env) {
106
39
  const raw = env.OURS_SERVER_APPLICATIONS;
@@ -119,7 +52,7 @@ export function validateDockerLayout(tree, options) {
119
52
  if (fs.readdirSync(join(tree, component, '.ours-provenance')).sort().join() !== recordNames(options.provenance).sort().join()) throw new Error('Mixed component provenance');
120
53
  for (const name of recordNames(options.provenance)) {
121
54
  if (!privateBytes(join(tree, component, '.ours-provenance', name), options).equals(options.provenance[name])) {
122
- throw new Error(`Converted ${component} differs from the selected build`);
55
+ throw new Error(`Stored ${component} differs from the selected build`);
123
56
  }
124
57
  }
125
58
  const config = join(tree, component, 'config.json');
@@ -134,103 +67,23 @@ export function validateDockerLayout(tree, options) {
134
67
  || (daemon.networkMcp !== undefined && (daemon.networkMcp?.applicationConfigPath !== join(MCP_STATE, 'config.json')
135
68
  || JSON.stringify(daemon.networkMcp?.profile) !== JSON.stringify(profile)))
136
69
  || (components.includes('cowork') && objectAt(join(tree, 'cowork/config.json'), options).stateDir !== '/var/lib/ours-cowork')) {
137
- throw new Error('Converted Docker deployment configuration is inconsistent');
70
+ throw new Error('Docker deployment configuration is inconsistent');
138
71
  }
139
72
  if (fs.existsSync(join(tree, 'mcp/config.json'))) objectAt(join(tree, 'mcp/config.json'), options);
140
73
  for (const path of ['daemon/daemon-token', ...components.filter(name => name !== 'daemon').map(name => `credentials/${name}/daemon-token`)]) {
141
- if (!privateBytes(join(tree, path), options).length) throw new Error('Converted managed credential is empty');
74
+ if (!privateBytes(join(tree, path), options).length) throw new Error('Managed credential is empty');
142
75
  }
143
76
  }
144
77
 
145
- /** Requires a schema-1 pending record reserving this volume and excluded writers. */
146
- export async function prepareDockerLayout(source, storage, label, options) {
147
- if (!/^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/.test(label)) throw new Error('Invalid conversion backup label');
148
- if (resolve(storage) !== storage || fs.realpathSync(storage) !== storage
149
- || resolve(source) !== source || fs.realpathSync(source) !== source
150
- || storage === source || storage.startsWith(source + '/') || source.startsWith(storage + '/')) {
151
- throw new Error('Conversion storage must be canonical and outside the source');
152
- }
153
- const privateDirectory = path => {
154
- const stat = fs.lstatSync(path);
155
- if (!stat.isDirectory() || stat.uid !== options.uid || stat.gid !== options.gid
156
- || (stat.mode & 0o7777) !== 0o700) throw new Error(`Unsafe conversion directory: ${path}`);
157
- };
158
- privateDirectory(storage);
159
- const maintenance = join(storage, '.maintenance');
160
- const backups = join(storage, 'backups');
161
- for (const path of [maintenance, backups]) {
162
- if (!fs.existsSync(path)) fs.mkdirSync(path, { mode: 0o700 });
163
- privateDirectory(path);
164
- }
165
- const staging = join(maintenance, 'layout-conversion');
166
- const target = join(storage, 'state');
167
- const removeOwnedTree = path => {
168
- if (!fs.existsSync(path)) return;
169
- scanSource(path, options);
170
- fs.rmSync(path, { recursive: true });
171
- };
172
- removeOwnedTree(staging);
173
- try {
174
- await stageDockerLayout(source, staging, options);
175
- const archiveOptions = { ...options, domain: 'server' };
176
- const backup = join(backups, label);
177
- if (fs.existsSync(backup)) await validateArchive(backup, archiveOptions);
178
- else await createArchive(staging, backup, archiveOptions);
179
- // The source remains mounted at its original runtime path for SDK selection.
180
- execFileSync(options.cli, ['config', 'access-retain', '--config', options.configPath,
181
- '--target-state-dir', join(staging, 'daemon'), '--json'], { stdio: ['ignore', 'pipe', 'pipe'] });
182
- bindDockerLayout(staging, options);
183
- validateDockerLayout(staging, options);
184
- removeOwnedTree(target);
185
- publishNoReplace(staging, target);
186
- } finally {
187
- removeOwnedTree(staging);
188
- }
189
- }
190
-
191
- /** Remove only retired working data; volume-root archives remain untouched. */
192
- export function cleanupDockerSource(source, options) {
193
- const empty = [];
194
- const aliases = [...COMPONENTS, ...COMPONENTS.filter(name => name !== 'daemon').map(name => `${name}-credential`)];
195
- for (const alias of aliases) {
196
- const root = join(source, alias);
197
- if (!fs.existsSync(root)) continue;
198
- const stat = fs.lstatSync(root);
199
- if (!stat.isDirectory() || stat.uid !== options.uid || stat.gid !== options.gid
200
- || (stat.mode & 0o7777) !== 0o700) throw new Error(`Unsafe retired volume root: ${alias}`);
201
- const credential = alias.endsWith('-credential');
202
- const path = join(root, credential ? 'daemon-token' : 'data');
203
- if (fs.existsSync(path)) {
204
- if (credential) { privateBytes(path, options); fs.unlinkSync(path); }
205
- else { scanSource(path, options); fs.rmSync(path, { recursive: true }); }
206
- }
207
- if (fs.readdirSync(root).length === 0) empty.push(alias);
208
- }
209
- return empty;
210
- }
211
-
212
78
  /** Internal one-shot container entrypoint; the installer owns writer exclusion. */
213
79
  export async function runDockerLayoutCommand(argv, env = process.env) {
214
- const [operation, label] = argv;
215
- if (!((operation === 'prepare' && argv.length === 2)
216
- || (['validate', 'cleanup'].includes(operation) && argv.length === 1))) {
217
- throw new Error('usage: prepare BACKUP_LABEL | validate | cleanup');
218
- }
219
- const storage = env.OURS_STATE_ROOT || '/storage';
220
- const source = env.OURS_CONVERSION_SOURCE || '/source';
221
- const build = env.OURS_BUILD_ROOT || '/opt/ours';
80
+ if (argv.length !== 1 || argv[0] !== 'validate') throw new Error('usage: validate');
222
81
  const options = {
223
82
  uid: process.getuid(), gid: process.getgid(), instanceId: env.OURS_DAEMON_ID,
224
- cli: daemonOwner({ OURS_DAEMON_BIN_DIR: '/opt/ours/node_modules/.bin', ...env }),
225
- configPath: env.OURS_DAEMON_CONFIG || '/var/lib/ours/config.json',
226
- provenance: readBuildRecords(build),
83
+ provenance: readBuildRecords(env.OURS_BUILD_ROOT || '/opt/ours'),
227
84
  components: selectedComponents(env),
228
85
  };
229
- if (!options.uid || !options.gid) throw new Error('Conversion requires a non-root owner');
230
- if (operation === 'cleanup') {
231
- console.log(JSON.stringify({ emptyVolumes: cleanupDockerSource(source, options) }));
232
- return;
233
- }
86
+ if (!options.uid || !options.gid) throw new Error('Validation requires a non-root owner');
234
87
  if (options.components.includes('cowork')) try {
235
88
  execFileSync(env.OURS_COWORK_CLI_PATH || '/opt/ours/node_modules/.bin/ours-cowork', ['--json', 'prepare-backup'], {
236
89
  env: { ...env, OURS_COWORK_CONFIG: env.OURS_COWORK_CONFIG || '/var/lib/ours-cowork/config.json',
@@ -238,16 +91,15 @@ export async function runDockerLayoutCommand(argv, env = process.env) {
238
91
  stdio: ['ignore', 'pipe', 'pipe'],
239
92
  });
240
93
  } catch {
241
- throw new Error('Cowork preparation failed; Docker conversion was not continued');
94
+ throw new Error('Cowork preparation failed; Docker validation was not continued');
242
95
  }
243
- if (operation === 'prepare') await prepareDockerLayout(source, storage, label, options);
244
- else validateDockerLayout(join(storage, 'state'), options);
96
+ validateDockerLayout(join(env.OURS_STATE_ROOT || '/storage', 'state'), options);
245
97
  }
246
98
 
247
99
  if (process.argv[1] && import.meta.url === pathToFileURL(resolve(process.argv[1])).href) {
248
100
  runDockerLayoutCommand(process.argv.slice(2)).catch(error => {
249
101
  // Owner process errors may contain private output; keep it out of installer logs.
250
- console.error(error?.status !== undefined ? 'Owner command failed during Docker conversion' : error.message);
102
+ console.error(error?.status !== undefined ? 'Owner command failed during Docker validation' : error.message);
251
103
  process.exitCode = 1;
252
104
  });
253
105
  }
@@ -2,7 +2,7 @@
2
2
  "release": {
3
3
  "schema": 1,
4
4
  "channel": "stable",
5
- "installerVersion": "2.1.4",
5
+ "installerVersion": "2.1.6",
6
6
  "packages": {
7
7
  "@ours.network/sdk": {
8
8
  "version": "5.2.0",
@@ -0,0 +1,28 @@
1
+ /** The Docker build context: one definition shared by host installs and release CI. */
2
+ import { chmodSync, cpSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
3
+ import { join } from 'node:path';
4
+ import { fileURLToPath } from 'node:url';
5
+
6
+ export const INSTALLER_ASSETS = fileURLToPath(new URL('../assets/', import.meta.url));
7
+
8
+ /** Copy the shipped assets; the caller supplies the selection as sources.json. */
9
+ export function copyDockerAssets(workDir) {
10
+ cpSync(INSTALLER_ASSETS, workDir, { recursive: true, errorOnExist: true, force: false });
11
+ chmodSync(workDir, 0o700);
12
+ // Release descriptors are distribution metadata, never part of image content.
13
+ rmSync(join(workDir, 'images.json'), { force: true });
14
+ rmSync(join(workDir, 'sources.json'));
15
+ }
16
+
17
+ /** The installer owns the maintenance tools' dependencies in both installation modes. */
18
+ export function writeMaintenancePackage(workDir) {
19
+ const { dependencies } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8'));
20
+ writeFileSync(join(workDir, 'scripts/maintenance/package.json'), JSON.stringify({ private: true, type: 'module', dependencies }, null, 2) + '\n', { mode: 0o600 });
21
+ }
22
+
23
+ /** A complete context for one role's selection, as a host would build it. */
24
+ export function stageDockerContext(workDir, policy) {
25
+ copyDockerAssets(workDir);
26
+ writeFileSync(join(workDir, 'sources.json'), policy, { mode: 0o600, flag: 'wx' });
27
+ writeMaintenancePackage(workDir);
28
+ }