@ours.network/install 1.2.1-nightly.9 → 2.0.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.
Files changed (67) hide show
  1. package/GATEWAY_SETUP.md +178 -0
  2. package/README.md +564 -11
  3. package/ROOTLESS_PODMAN_VALIDATION.md +210 -0
  4. package/assets/Dockerfile +18 -15
  5. package/assets/Dockerfile.gateway +5 -0
  6. package/assets/docker-compose.yaml +8 -1
  7. package/assets/fleet-settings.example.json +48 -0
  8. package/assets/gateway-entrypoint.sh +37 -0
  9. package/assets/release-lock.json +1263 -4538
  10. package/assets/release.json +32 -24
  11. package/assets/scripts/build/build-common.mjs +10 -1
  12. package/assets/scripts/build/build-sdk.mjs +6 -1
  13. package/assets/scripts/maintenance/build-context.mjs +1 -1
  14. package/assets/scripts/maintenance/daemon-owner.mjs +15 -0
  15. package/assets/scripts/maintenance/docker-layout-conversion.mjs +22 -7
  16. package/assets/scripts/maintenance/recover-notifications.mjs +36 -0
  17. package/assets/scripts/maintenance/release-graph.mjs +1 -1
  18. package/assets/scripts/maintenance/state-operation.mjs +76 -8
  19. package/assets/scripts/runtime/README.md +7 -0
  20. package/assets/scripts/runtime/client-setup.mjs +105 -20
  21. package/assets/scripts/runtime/daemon-client-prefix.mjs +115 -0
  22. package/assets/scripts/runtime/dependency-ready.mjs +13 -0
  23. package/assets/scripts/runtime/diagnostics.mjs +72 -0
  24. package/assets/scripts/runtime/entrypoint.sh +5 -1
  25. package/assets/scripts/runtime/health-messenger.mjs +7 -6
  26. package/assets/scripts/runtime/healthcheck.mjs +49 -15
  27. package/assets/scripts/runtime/notifications-gateway.mjs +90 -0
  28. package/assets/scripts/runtime/recover.mjs +202 -0
  29. package/assets/scripts/runtime/start-cowork.sh +5 -0
  30. package/assets/scripts/runtime/start-messenger.sh +29 -4
  31. package/assets/scripts/runtime/start-telegram.sh +5 -0
  32. package/assets/scripts/runtime/supervise.mjs +35 -0
  33. package/assets/sources.json +49 -33
  34. package/install.mjs +12 -2
  35. package/install.sh +5 -2
  36. package/lib/boot-readiness.mjs +96 -0
  37. package/lib/build-transition.mjs +16 -0
  38. package/lib/client-cli.mjs +12 -2
  39. package/lib/container-engine.mjs +127 -0
  40. package/lib/diagnostics.mjs +1 -0
  41. package/lib/docker-conversion-runtime.mjs +7 -4
  42. package/lib/docker-layout-installation.mjs +2 -1
  43. package/lib/docker-recovery.mjs +60 -0
  44. package/lib/docker-runtime-repair.mjs +49 -14
  45. package/lib/effects.mjs +462 -136
  46. package/lib/gateway-transition.mjs +87 -0
  47. package/lib/gateway.mjs +227 -0
  48. package/lib/legacy-migration.mjs +13 -2
  49. package/lib/orchestrate-uninstall.mjs +23 -6
  50. package/lib/orchestrate.mjs +282 -38
  51. package/lib/ownership.mjs +63 -0
  52. package/lib/plan.mjs +37 -11
  53. package/lib/podman-preflight.mjs +40 -0
  54. package/lib/product.mjs +69 -0
  55. package/lib/removal-plan.mjs +437 -0
  56. package/lib/removal.mjs +749 -0
  57. package/lib/security-versions.mjs +38 -0
  58. package/lib/server-onboarding.mjs +182 -16
  59. package/lib/server-ports.mjs +17 -0
  60. package/lib/setup-options.mjs +119 -29
  61. package/lib/setup.mjs +86 -15
  62. package/lib/target.mjs +24 -8
  63. package/lib/uninstall.mjs +2 -2
  64. package/lib/usage.mjs +35 -9
  65. package/lib/welcome.mjs +219 -0
  66. package/lib/workspace-setup.mjs +164 -0
  67. package/package.json +5 -3
@@ -0,0 +1,202 @@
1
+ import { spawn } from 'node:child_process';
2
+ import { setTimeout as sleep } from 'node:timers/promises';
3
+ import { pathToFileURL } from 'node:url';
4
+ import { readdirSync, readFileSync } from 'node:fs';
5
+
6
+ // Exit status after the recovery budget is spent: the container stops and its
7
+ // restart policy, the only outer supervisor, starts a fresh one.
8
+ export const EXHAUSTED_EXIT_CODE = 75;
9
+ // Probe output is never logged; only these fixed classifications survive.
10
+ const PROBE_CLASSES = new Set(['liveness:unreachable', 'liveness:timeout', 'liveness:http',
11
+ 'readiness:timeout', 'readiness:auth', 'readiness:instance', 'readiness:capability', 'readiness:error']);
12
+ const probeClass = output => {
13
+ const match = /^OURS_PROBE ([a-z:]+)$/m.exec(output);
14
+ return match && PROBE_CLASSES.has(match[1]) ? match[1] : null;
15
+ };
16
+
17
+ // The container owns recovery; no Docker socket, host service or stored state is
18
+ // accessed. Every launch re-enters the locked, provenance-checking entrypoint.
19
+ export async function runRecovery({ command, health, dependency, graceMs = 90_000,
20
+ intervalMs = 5_000, probeTimeoutMs = 15_000,
21
+ killAfterMs = 20_000, retries = 3, failures = 3, healthyResetMs = 600_000,
22
+ maxBackoffMs = 300_000, ownerPidEnvironment, log = console.error }) {
23
+ let stopping = false, active;
24
+ const probes = new Set();
25
+ const controller = new AbortController();
26
+ const pause = ms => sleep(ms, undefined, { signal: controller.signal }).catch(() => {});
27
+ const processFields = id => {
28
+ try {
29
+ const stat = readFileSync(`/proc/${id}/stat`, 'utf8');
30
+ return stat.slice(stat.lastIndexOf(')') + 2).split(' ');
31
+ } catch { return null; }
32
+ };
33
+ const groups = child => {
34
+ if (!child?.pid) return [];
35
+ child.groups ??= new Set([child.pid]);
36
+ // Cowork's serve supervisor explicitly marks a detached worker with its
37
+ // owner PID. The marker survives owner death, unlike PPID ancestry. No
38
+ // unrelated process or unmarked group is selected, including Docker exec.
39
+ if (ownerPidEnvironment && !child.probe) for (const id of readdirSync('/proc')) {
40
+ if (!/^\d+$/.test(id)) continue;
41
+ try {
42
+ const env = readFileSync(`/proc/${id}/environ`, 'utf8').split('\0');
43
+ if (!env.includes(`${ownerPidEnvironment}=${child.pid}`)) continue;
44
+ const fields = processFields(id);
45
+ if (fields && !['Z', 'X'].includes(fields[0])) child.groups.add(Number(fields[2]));
46
+ } catch { /* foreign or exited process */ }
47
+ }
48
+ return [...child.groups].filter(pid => Number.isInteger(pid) && pid > 1 && pid !== process.pid);
49
+ };
50
+ const signalGroup = (child, signal, all = true) => {
51
+ const selected = all ? groups(child) : child?.pid ? [child.pid] : [];
52
+ for (const pid of selected) try { process.kill(-pid, signal); }
53
+ catch (error) { if (error.code !== 'ESRCH') throw error; }
54
+ };
55
+ const launch = (args, probe = false) => {
56
+ const child = spawn(args[0], args.slice(1), { detached: true,
57
+ stdio: probe ? ['ignore', 'pipe', 'ignore'] : 'inherit', env: { ...process.env, OURS_RECOVERY_CHILD: '1' } });
58
+ child.probe = probe;
59
+ child.done = new Promise(resolve => {
60
+ child.once('error', () => { child.spawnFailed = true; resolve(1); });
61
+ child.once('exit', (code) => resolve(code ?? 1));
62
+ });
63
+ return child;
64
+ };
65
+ const groupAlive = child => {
66
+ const selected = groups(child);
67
+ return readdirSync('/proc').some(id => {
68
+ if (!/^\d+$/.test(id)) return false;
69
+ const fields = processFields(id);
70
+ return fields && selected.includes(Number(fields[2])) && !['Z', 'X'].includes(fields[0]);
71
+ });
72
+ };
73
+ const terminate = async child => {
74
+ groups(child);
75
+ // Graceful shutdown reaches only the owning entrypoint; Cowork retains
76
+ // exclusive IPC control of its worker until the force-kill boundary.
77
+ signalGroup(child, 'SIGTERM', false);
78
+ let timer;
79
+ await Promise.race([child.done, new Promise(resolve => { timer = setTimeout(() => {
80
+ signalGroup(child, 'SIGKILL'); resolve();
81
+ }, killAfterMs); })]);
82
+ clearTimeout(timer);
83
+ // A leader may exit before a stubborn grandchild. Kill the remaining group
84
+ // even when child.done won the race, then await kernel lock release.
85
+ signalGroup(child, 'SIGKILL');
86
+ await child.done;
87
+ const deadline = Date.now() + killAfterMs;
88
+ while (groupAlive(child)) {
89
+ if (Date.now() >= deadline) throw new Error('Recovery refused: child process group did not stop');
90
+ await sleep(25);
91
+ }
92
+ };
93
+ // Resolves { ok, reason, ms }; reason is ok, timeout, spawn, an allowlisted
94
+ // class reported by the probe, or exit:<code>.
95
+ const probe = async args => {
96
+ const started = Date.now();
97
+ const child = launch(args, true);
98
+ probes.add(child);
99
+ let output = '', timer, timedOut = false;
100
+ child.stdout?.on('data', chunk => { if (output.length < 512) output += chunk.toString('utf8').slice(0, 512); });
101
+ const code = await Promise.race([child.done, new Promise(resolve => {
102
+ timer = setTimeout(() => { timedOut = true; signalGroup(child, 'SIGKILL'); resolve(1); }, probeTimeoutMs);
103
+ })]);
104
+ clearTimeout(timer);
105
+ await terminate(child);
106
+ child.stdout?.destroy();
107
+ probes.delete(child);
108
+ const ok = code === 0 && !timedOut;
109
+ const reason = ok ? 'ok' : timedOut ? 'timeout' : child.spawnFailed ? 'spawn' : probeClass(output) ?? `exit:${code}`;
110
+ return { ok, reason, ms: Date.now() - started };
111
+ };
112
+ const stop = () => { stopping = true; controller.abort(); signalGroup(active, 'SIGTERM', false); for (const child of probes) signalGroup(child, 'SIGKILL'); };
113
+ process.on('SIGTERM', stop); process.on('SIGINT', stop);
114
+ try {
115
+ let recoveries = 0;
116
+ while (!stopping) {
117
+ if (recoveries > retries) {
118
+ // Never strand a running container without its service: exit visibly
119
+ // and let the container restart policy apply its own backoff.
120
+ log(`OURS recovery exhausted (${retries} automatic attempts without ${Math.round(healthyResetMs / 1000)}s of continuous readiness); children stopped. Exiting with status ${EXHAUSTED_EXIT_CODE} for the container restart policy.`);
121
+ process.exitCode = EXHAUSTED_EXIT_CODE;
122
+ break;
123
+ }
124
+ // A dependency outage is a wait, not a local failure. Never spend a
125
+ // consumer's circuit on daemon boot order, restart or unavailability.
126
+ if (dependency) {
127
+ let waiting = false;
128
+ while (!stopping && !(await probe(dependency)).ok) {
129
+ if (!waiting) log('OURS waiting for the authenticated daemon; recovery budget retained');
130
+ waiting = true;
131
+ await pause(intervalMs);
132
+ }
133
+ }
134
+ if (stopping) break;
135
+ if (recoveries) log(`OURS recovery attempt ${recoveries}/${retries}`);
136
+ active = launch(command);
137
+ let exited = false, monitoring = true;
138
+ const generation = new AbortController();
139
+ const wait = ms => sleep(ms, undefined, { signal: generation.signal }).catch(() => {});
140
+ const cancel = () => generation.abort();
141
+ controller.signal.addEventListener('abort', cancel, { once: true });
142
+ active.done.then(() => { exited = true; generation.abort(); });
143
+ const watch = async () => {
144
+ await wait(graceMs);
145
+ let failed = 0, healthySince = null;
146
+ while (monitoring && !stopping && !exited) {
147
+ const result = await probe(health);
148
+ if (!monitoring || stopping || exited) break;
149
+ if (result.ok) {
150
+ failed = 0;
151
+ healthySince ??= Date.now();
152
+ // Only an unbroken readiness interval restores the budget; any
153
+ // failed or timed-out probe, including a dependency outage, restarts it.
154
+ if (recoveries && Date.now() - healthySince >= healthyResetMs) {
155
+ log(`OURS recovery budget restored after ${Math.round((Date.now() - healthySince) / 1000)}s of continuous readiness`);
156
+ recoveries = 0;
157
+ }
158
+ } else {
159
+ healthySince = null;
160
+ if (dependency && !(await probe(dependency)).ok) failed = 0;
161
+ else {
162
+ failed += 1;
163
+ log(`OURS health probe failed (${failed}/${failures}): ${result.reason} after ${result.ms}ms`);
164
+ }
165
+ }
166
+ if (failed >= failures) { log('OURS service health failed repeatedly; stopping children before recovery'); return; }
167
+ await wait(intervalMs);
168
+ }
169
+ };
170
+ const watching = watch();
171
+ await Promise.race([active.done, watching]);
172
+ monitoring = false; generation.abort();
173
+ await terminate(active);
174
+ await watching;
175
+ controller.signal.removeEventListener('abort', cancel);
176
+ active = undefined;
177
+ if (!stopping) {
178
+ if (!dependency || (await probe(dependency)).ok) recoveries++;
179
+ // Exponential backoff between attempts; a dependency outage keeps the base interval.
180
+ await pause(Math.min(maxBackoffMs, intervalMs * 2 ** Math.max(0, recoveries - 1)));
181
+ }
182
+ }
183
+ } finally {
184
+ if (active) await terminate(active);
185
+ process.off('SIGTERM', stop); process.off('SIGINT', stop);
186
+ }
187
+ }
188
+
189
+ if (process.argv[1] && import.meta.url === pathToFileURL(process.argv[1]).href) {
190
+ const service = process.argv[2], runtime = process.env.OURS_RUNTIME_ROOT ?? '/opt/ours';
191
+ const health = {
192
+ daemon: ['node', `${runtime}/docker/healthcheck.mjs`],
193
+ telegram: ['/bin/sh', `${runtime}/docker/health-telegram.sh`],
194
+ cowork: ['/bin/sh', `${runtime}/docker/health-cowork.sh`],
195
+ messenger: ['node', `${runtime}/docker/health-messenger.mjs`],
196
+ }[service];
197
+ if (!health) throw new Error('Unknown recovery service');
198
+ const entry = service === 'daemon' ? 'entrypoint.sh' : `start-${service}.sh`;
199
+ await runRecovery({ command: ['/bin/sh', '-e', `${runtime}/docker/${entry}`], health,
200
+ ...(service === 'cowork' ? { ownerPidEnvironment: 'OURS_COWORK_SUPERVISOR_PID' } : {}),
201
+ ...(service !== 'daemon' ? { dependency: ['node', `${runtime}/docker/dependency-ready.mjs`, service] } : {}) });
202
+ }
@@ -1,4 +1,9 @@
1
1
  #!/bin/sh
2
+ set -e
3
+ # Re-enter this entrypoint for every recovery, including its locks and checks.
4
+ if [ "${OURS_RECOVERY_CHILD:-}" != 1 ]; then
5
+ exec node "${OURS_RUNTIME_ROOT:-/opt/ours}/docker/recover.mjs" cowork
6
+ fi
2
7
  umask 077
3
8
  exec 3</var/lib/ours-cowork
4
9
  flock -n 3
@@ -1,6 +1,31 @@
1
1
  #!/bin/sh
2
+ # Re-enter this entrypoint for every recovery, including its locks and checks.
3
+ if [ "${OURS_RECOVERY_CHILD:-}" != 1 ]; then
4
+ exec node "${OURS_RUNTIME_ROOT:-/opt/ours}/docker/recover.mjs" messenger
5
+ fi
6
+ set -e
2
7
  umask 077
3
- exec 3</var/lib/ours-messenger
4
- flock -n 3
5
- node /opt/ours/docker/check-client.mjs messenger
6
- exec node /opt/ours/node_modules/@ours.network/messenger-server/dist/cli.js serve
8
+ runtime="${OURS_RUNTIME_ROOT:-/opt/ours}"
9
+ state="${OURS_MESSENGER_STATE_DIR:-/var/lib/ours-messenger}"
10
+ exec 3<"$state"
11
+ flock -n 3 || { echo "OURS Messenger state is in use by another writer" >&2; exit 1; }
12
+ node "$runtime/docker/check-client.mjs" messenger
13
+ messenger="[\"node\",\"$runtime/node_modules/@ours.network/messenger-server/dist/cli.js\",\"serve\"]"
14
+ # Notifications run beside Messenger when this runtime ships the service and
15
+ # its private configuration was prepared. Messenger's producer reaches it on loopback.
16
+ config="${OURS_NOTIFICATIONS_CONFIG:-}"
17
+ if [ -n "$config" ] && [ -f "$runtime/node_modules/@ours.network/notifications/package.json" ] && [ -f "$config" ]; then
18
+ notifications="$(dirname "$config")"
19
+ exec 4<"$notifications"
20
+ # Every writer of this state starts here and holds lock 4 for its lifetime;
21
+ # the kernel releases it when the process dies, even on SIGKILL. Holding it
22
+ # proves no other writer is alive, so a lock file left by an abrupt stop is stale.
23
+ flock -n 4 || { echo "OURS notification state is in use by another writer" >&2; exit 1; }
24
+ rm -f "$notifications/state.json.lock"
25
+ OURS_NOTIFICATIONS_ORIGIN="http://127.0.0.1:49677"
26
+ OURS_NOTIFICATIONS_PRODUCER_TOKEN="$(cat "${OURS_NOTIFICATIONS_PRODUCER_FILE:-/credentials/messenger/notifications-producer}")"
27
+ export OURS_NOTIFICATIONS_ORIGIN OURS_NOTIFICATIONS_PRODUCER_TOKEN
28
+ # Only Messenger receives its producer credential.
29
+ exec node "$runtime/docker/supervise.mjs" "[$messenger,[\"env\",\"-u\",\"OURS_NOTIFICATIONS_PRODUCER_TOKEN\",\"node\",\"$runtime/docker/notifications-gateway.mjs\"]]"
30
+ fi
31
+ exec node "$runtime/node_modules/@ours.network/messenger-server/dist/cli.js" serve
@@ -1,4 +1,9 @@
1
1
  #!/bin/sh
2
+ set -e
3
+ # Re-enter this entrypoint for every recovery, including its locks and checks.
4
+ if [ "${OURS_RECOVERY_CHILD:-}" != 1 ]; then
5
+ exec node "${OURS_RUNTIME_ROOT:-/opt/ours}/docker/recover.mjs" telegram
6
+ fi
2
7
  umask 077
3
8
  exec 3</var/lib/ours-telegram
4
9
  flock -n 3
@@ -0,0 +1,35 @@
1
+ import { spawn } from 'node:child_process';
2
+
3
+ /**
4
+ * Run the given commands as one unit: signals reach every child, and when any
5
+ * child exits (or cannot start) the others are stopped and the container exits
6
+ * with its status, so a failure is visible and recovers through the container's
7
+ * own restart. A child ignoring SIGTERM is killed after a bounded grace period,
8
+ * within Compose's stop grace period.
9
+ */
10
+ const commands = JSON.parse(process.argv[2] ?? '[]');
11
+ if (!Array.isArray(commands) || !commands.length || !commands.every(c => Array.isArray(c) && c.length && c.every(a => typeof a === 'string'))) {
12
+ console.error('usage: supervise.mjs JSON-ARRAY-OF-COMMANDS'); process.exit(2);
13
+ }
14
+ const killAfter = Number(process.env.OURS_SUPERVISE_KILL_AFTER_MS ?? 20_000);
15
+ let stopping = false, status = 0, remaining = commands.length;
16
+ const children = [];
17
+ const running = child => child.exitCode === null && child.signalCode === null && !child.failed;
18
+ const stop = signal => {
19
+ for (const child of children) if (running(child)) child.kill(signal);
20
+ if (signal !== 'SIGKILL') setTimeout(() => stop('SIGKILL'), killAfter);
21
+ };
22
+ const finished = (child, code, reason) => {
23
+ if (child.done) return;
24
+ child.done = true;
25
+ if (!stopping) { stopping = true; status = code; console.error(`Supervised process ${child.spawnfile} ${reason}; stopping the others`); stop('SIGTERM'); }
26
+ if (--remaining === 0) process.exit(status);
27
+ };
28
+ for (const signal of ['SIGTERM', 'SIGINT']) process.on(signal, () => { if (!stopping) { stopping = true; stop(signal); } });
29
+ // Inherited descriptors 3 and 4 are the state-directory locks; every child holds them too.
30
+ for (const [file, ...args] of commands) {
31
+ const child = spawn(file, args, { stdio: ['inherit', 'inherit', 'inherit', 'inherit', 'inherit'] });
32
+ children.push(child);
33
+ child.on('error', error => { child.failed = true; finished(child, 1, `could not start (${error.code ?? 'error'})`); });
34
+ child.on('exit', (code, signal) => finished(child, code ?? 1, `exited (${signal ?? code})`));
35
+ }
@@ -1,93 +1,109 @@
1
1
  {
2
2
  "release": {
3
3
  "schema": 1,
4
- "channel": "nightly",
5
- "installerVersion": "1.2.1-nightly.9",
4
+ "channel": "stable",
5
+ "installerVersion": "2.0.1",
6
6
  "packages": {
7
7
  "@ours.network/sdk": {
8
- "version": "3.8.1-nightly.4",
9
- "integrity": "sha512-h0euEcW9VDEhSHV5ubB1wC6KCXV89EqNCVf05F2kUx4SSvEwPNLPHtN9i21H6qlBEq3RHrHnsl1/uo1l51LCMA=="
8
+ "version": "5.0.0",
9
+ "integrity": "sha512-Ymt3L1cb6ND/iUIPYlO4+75cNeMBB4iTTnPwzOzpwVPoXDnHY+2ByMw4NdonR3iKuAlsPfFbdAcvhhyeFUWkiA=="
10
10
  },
11
11
  "@ours.network/cli": {
12
- "version": "2.8.1-nightly.2",
13
- "integrity": "sha512-YirjiR6/Xs1p2LKOLVtao74xLXCsxgHz3gwbKyZ4Qtd9w6MF+kS/OEOLKozmIjWJ5FoqUxgvnnaudl5vhaeUkA=="
12
+ "version": "4.0.0",
13
+ "integrity": "sha512-EGQQbIJDy2PCJ8neL7E9b0EcRXzm7VHZIO2gnznMGRiUCrQmbZX+zndWE76oGPW9pVKEa927zSXJZdZOTPU8KA=="
14
14
  },
15
15
  "@ours.network/tg-connector": {
16
- "version": "1.0.1-nightly.2",
17
- "integrity": "sha512-XTA2vXMLrXNq7PKVXHp8HluaMzTf2tx4kDy+EOu5sWwvfiP2f4qSCx+ESeebP//TNnSHfrNnGZZiCV0uVsO49g=="
16
+ "version": "2.0.0",
17
+ "integrity": "sha512-YF+ypgJPjt2Lr97jve3ISOMiioXtGrc1iVmhNUczCNb6IbQtho5qQ/sV3lZm65dpjliHtlQFMtbG7ShsM7Yswg=="
18
18
  },
19
19
  "@ours.network/cowork": {
20
- "version": "1.3.2-nightly.20260919.5e6e5fd",
21
- "integrity": "sha512-/3KEKXqriBsPiK8POyL/XgbP4ELsRs6quv0Q47cFCaesXAR4W44Q3NVs43brnj1AwMLroip0iXzqwlsJvpoaTw=="
20
+ "version": "2.0.0",
21
+ "integrity": "sha512-Y8dR4phd73Q3PXZdGh0yWMkFnI9BFp/s+FT1JenziY5G/Tv/62bGVMtruFfhrqF150rYHAj8v5NRy4w3qgPrjw=="
22
22
  },
23
23
  "@ours.network/messenger-server": {
24
- "version": "1.0.31-nightly.2",
25
- "integrity": "sha512-yWBFSzUwoKHfn7z//uesWmEzGOYFfgFsjBr7KXhGGAeXRvGbbbt1OHOg+ZPNhastXipxOrg+oeY94pQwJClxkA=="
24
+ "version": "2.0.0",
25
+ "integrity": "sha512-rRIeZeBxwXNGyZTNzSLZ9y/Wl61T3pmUFz6V71MicUjFM781x9bl7W7S3p694PRymAJU6x1lOFUpgQy46Bw5fg=="
26
+ },
27
+ "@ours.network/notifications": {
28
+ "version": "1.0.0",
29
+ "integrity": "sha512-wN2Aoj/7nzk4Rq2MjiquCr8yvb44WsHy+R1Qw/FRT1XN6Kes2RfWXI+uhmPPpxEjf9HY90COd/StAcszZW87Uw=="
26
30
  },
27
31
  "@ours.network/fleet": {
28
- "version": "1.2.0-nightly.2",
29
- "integrity": "sha512-vnTGjjl2ycd7FN4CKGblemFcq5/MWocTR0CQhGEbspYXRYiojGa3MRyLzJPOVJQbP0/zqIwSG5Vk9czMWHpjow=="
32
+ "version": "2.0.0",
33
+ "integrity": "sha512-JBL8P/ObjamR80i+xli5dHb+azWsLWVocm5mclttt6Zn6h0ZGHvjVoLPiAZq1nrPG9fJHhkmE1RaPKHvZhZ2xg=="
30
34
  },
31
35
  "@ours.network/mcp": {
32
- "version": "1.2.0-nightly.4",
33
- "integrity": "sha512-NcVDRmwOHx5zAwcIs6cMstSPyIEhl9f0mQNNsSbXYi+oGkamzdEPH02RHWrmoYCgvqiWjO8bhCqB43Mum8ozYg=="
36
+ "version": "2.0.0",
37
+ "integrity": "sha512-wyrSssiNNXoQ0Jh3pEMfmcWz1wKAXFs1dTqB9P5REZrtoFzYxKzWpzDcxZzpZpSK6VfFj1wlJAcXcn/+FsVKyw=="
34
38
  },
35
39
  "@ours.network/codex": {
36
- "version": "1.2.0-nightly.4",
37
- "integrity": "sha512-ZYzqWWcPv9snZH86AZxGfkT2lc9djIJuvBBWdDC7j7YJRjXVQfTVGNFtc5NoGesQYiiQFhiumSppMxfc3vHVDA=="
40
+ "version": "2.0.0",
41
+ "integrity": "sha512-OUbNbSE7fxfR2prU6CPIc2QtUTIGpQ95xRX3itd6Gd3QNQzZpL7VzDyLh1ekxXwLTcsMuIxjggWlQd/BjgV3wA=="
38
42
  },
39
43
  "@ours.network/claude-code": {
40
- "version": "1.2.0-nightly.4",
41
- "integrity": "sha512-JNDhTMtxO2Xm0NNL/5Kgra/ovr62mP0YFcuvYJRRA+SH6+2Ick8eegeSVmzU97HPLBCTi8DwNqfkUxcCQUpwXA=="
44
+ "version": "2.0.0",
45
+ "integrity": "sha512-aRrdBt8F5JNbGL3KNorzSamjqJVB3RiEmjATzY2q33T9dqh38dd1u2yIOvwQZaLxfh4+l/G0BX/WNGZUHsYKIQ=="
46
+ },
47
+ "@ours.network/daemon": {
48
+ "version": "5.0.0",
49
+ "integrity": "sha512-B/TYgk9onup1woVzlKk9cK0lnhPzmc9DWoPQvuJrrPhoYwmQVVd6brEUCcwYnSkO5gh7HBWZ9o+sA+tROoykjg=="
42
50
  }
43
51
  },
44
52
  "hostCli": {
45
53
  "@ours.network/sdk": {
46
- "version": "3.8.1-nightly.6",
47
- "integrity": "sha512-kNCR1/0X5sTKCDe1oaEvxXHBkRa0B4N3mosbYZAzY8mu0sTY+TKx2u0ltQ4PRZ50ZuwzhxNe7BVbphu9b/87xw=="
54
+ "version": "5.0.0",
55
+ "integrity": "sha512-Ymt3L1cb6ND/iUIPYlO4+75cNeMBB4iTTnPwzOzpwVPoXDnHY+2ByMw4NdonR3iKuAlsPfFbdAcvhhyeFUWkiA=="
48
56
  },
49
57
  "@ours.network/cli": {
50
- "version": "2.8.1-nightly.4",
51
- "integrity": "sha512-Lw9DVmY4vpAAm+ps8tD/eqJr4jwGSxGfpOtkvHvgjLzY442zM1od8/ZNyCV8d4YVxGOxuT72Fss9qgXnVR6bvQ=="
58
+ "version": "4.0.0",
59
+ "integrity": "sha512-EGQQbIJDy2PCJ8neL7E9b0EcRXzm7VHZIO2gnznMGRiUCrQmbZX+zndWE76oGPW9pVKEa927zSXJZdZOTPU8KA=="
52
60
  }
53
61
  }
54
62
  },
55
63
  "packages": {
56
64
  "@ours.network/sdk": {
57
65
  "type": "npm",
58
- "version": "3.8.1-nightly.4"
66
+ "version": "5.0.0"
59
67
  },
60
68
  "@ours.network/cli": {
61
69
  "type": "npm",
62
- "version": "2.8.1-nightly.2"
70
+ "version": "4.0.0"
63
71
  },
64
72
  "@ours.network/tg-connector": {
65
73
  "type": "npm",
66
- "version": "1.0.1-nightly.2"
74
+ "version": "2.0.0"
67
75
  },
68
76
  "@ours.network/cowork": {
69
77
  "type": "npm",
70
- "version": "1.3.2-nightly.20260919.5e6e5fd"
78
+ "version": "2.0.0"
71
79
  },
72
80
  "@ours.network/messenger-server": {
73
81
  "type": "npm",
74
- "version": "1.0.31-nightly.2"
82
+ "version": "2.0.0"
83
+ },
84
+ "@ours.network/notifications": {
85
+ "type": "npm",
86
+ "version": "1.0.0"
75
87
  },
76
88
  "@ours.network/fleet": {
77
89
  "type": "npm",
78
- "version": "1.2.0-nightly.2"
90
+ "version": "2.0.0"
79
91
  },
80
92
  "@ours.network/mcp": {
81
93
  "type": "npm",
82
- "version": "1.2.0-nightly.4"
94
+ "version": "2.0.0"
83
95
  },
84
96
  "@ours.network/codex": {
85
97
  "type": "npm",
86
- "version": "1.2.0-nightly.4"
98
+ "version": "2.0.0"
87
99
  },
88
100
  "@ours.network/claude-code": {
89
101
  "type": "npm",
90
- "version": "1.2.0-nightly.4"
102
+ "version": "2.0.0"
103
+ },
104
+ "@ours.network/daemon": {
105
+ "type": "npm",
106
+ "version": "5.0.0"
91
107
  }
92
108
  }
93
109
  }
package/install.mjs CHANGED
@@ -2,15 +2,25 @@
2
2
 
3
3
  import { readFileSync } from 'node:fs';
4
4
 
5
+ import { isSecureNodeVersion, nodeVersionError } from './lib/security-versions.mjs';
5
6
  import { realEffects } from './lib/effects.mjs';
7
+ import { installerFailure } from './lib/diagnostics.mjs';
8
+ import { runWorkspaceSetup } from './lib/workspace-setup.mjs';
6
9
  import { runSetup } from './lib/setup.mjs';
7
10
  import { closeSync, makeWriter, openTty } from './lib/ui.mjs';
8
11
 
12
+ if (!isSecureNodeVersion(process.versions.node)) {
13
+ process.stderr.write(`${nodeVersionError(process.versions.node)}\n`);
14
+ process.exit(1);
15
+ }
9
16
  const version = JSON.parse(readFileSync(new URL('./package.json', import.meta.url), 'utf8')).version;
10
17
  const ttyFd = openTty();
11
18
 
12
19
  try {
13
- const code = await runSetup(process.argv.slice(2), realEffects({
20
+ const args=process.argv.slice(2);
21
+ const workspace=args.some(v=>v==='--setup-workspace' || v.startsWith('--setup-workspace=') || v==='--setup-workspace-file' || v.startsWith('--setup-workspace-file='));
22
+ const execute=workspace ? (args,effects)=>runWorkspaceSetup(args,effects,runSetup) : runSetup;
23
+ const code = await execute(args, realEffects({
14
24
  write: makeWriter(ttyFd),
15
25
  ttyFd,
16
26
  env: process.env,
@@ -18,7 +28,7 @@ try {
18
28
  }));
19
29
  process.exitCode = code;
20
30
  } catch (error) {
21
- process.stderr.write(`ours-install: ${error instanceof Error ? error.message : String(error)}\n`);
31
+ process.stderr.write(`ours-install: ${installerFailure(error)}\n`);
22
32
  process.exitCode = 1;
23
33
  } finally {
24
34
  if (ttyFd != null) {
package/install.sh CHANGED
@@ -41,13 +41,13 @@ PKG="${OURS_INSTALL_PKG:-@ours.network/install}"
41
41
  NPM_BIN="${OURS_NPM:-npm}"
42
42
 
43
43
  # --- 1) Node.js + npm check + friendly guidance ------------------------------------------------
44
- # The installer needs Node.js ≥ 22 (and npm to fetch the command). If missing, don't fail
44
+ # The installer needs a patched Node.js 22, 24 or 26 release (and npm to fetch the command). If missing, don't fail
45
45
  # cryptically: explain what Node is and how to get it for this OS, point at nodejs.org, and exit
46
46
  # cleanly (0) so a piped run ends gracefully rather than with a scary non-zero error.
47
47
  if ! command -v node >/dev/null 2>&1 || ! command -v "$NPM_BIN" >/dev/null 2>&1; then
48
48
  os="$(uname -s 2>/dev/null || echo unknown)"
49
49
  printf '\n'
50
- say "ours needs Node.js (version 22 or newer, which includes npm) — it isn't installed yet."
50
+ say "ours needs Node.js (a patched 22.23.4+, 24.22.1+ or 26.12.1+ release, which includes npm) — it isn't installed yet."
51
51
  say "Node.js is a common, free runtime; here's how to get it:"
52
52
  case "$os" in
53
53
  Darwin)
@@ -65,6 +65,9 @@ if ! command -v node >/dev/null 2>&1 || ! command -v "$NPM_BIN" >/dev/null 2>&1;
65
65
  exit 0
66
66
  fi
67
67
 
68
+ # Refuse unpatched Node.js before anything runs (floors: lib/security-versions.mjs).
69
+ node -e 'const f={22:[23,4],24:[22,1],26:[12,1]},m=/^(\d+)\.(\d+)\.(\d+)$/.exec(process.versions.node),v=m&&m.slice(1).map(Number),p=v&&f[v[0]];if(!p||v[1]<p[0]||(v[1]===p[0]&&v[2]<p[1])){console.error("Node.js "+process.versions.node+" is not permitted. Ours requires a patched supported Node.js release: 22.23.4+, 24.22.1+, 26.12.1+ within those release lines; prerelease, end-of-life and unreviewed release lines are refused. Earlier patch levels are affected by CVE-2026-111497 (Brotli decompression out-of-bounds write): https://nodejs.org/en/blog/vulnerability/october-2026-security-releases Update Node.js from https://nodejs.org/en/download or your package manager, then retry.");process.exit(1)}' || exit 1
70
+
68
71
  # --- 2) DEV / LOCAL path: run the sibling install.mjs directly ---------------------------------
69
72
  # From a clone (or an explicit OURS_INSTALLER_MJS), skip npm entirely and run the local installer.
70
73
  MJS=""
@@ -0,0 +1,96 @@
1
+ import { warn } from './ui.mjs';
2
+
3
+ const NO_AUTOSTART = 'ours components that depend on Docker will not start automatically after a reboot until Docker is started';
4
+ const OPTIONAL = 'The installer does not change this for you.';
5
+
6
+ /** Persistent unit-file state only: `is-active`/a reachable Engine says nothing about the next boot. */
7
+ async function unitFileState(effects, scope) {
8
+ // `is-enabled` reads unit files offline, so it answers even where systemd is not the init
9
+ // system and its answer decides nothing. /run/systemd/system is sd_booted(3)'s own test.
10
+ if (!effects.exists('/run/systemd/system')) return 'unavailable';
11
+ try {
12
+ if (scope.length) await effects.run('systemctl', [...scope, 'show-environment']); // a user manager must be running
13
+ // 1 = disabled/masked, 4 = no such unit (older systemd reports that as 1 with empty output).
14
+ const state = (await effects.run('systemctl', [...scope, 'is-enabled', 'docker.service'], { allowCodes: [1, 4] })).stdout.trim().split('\n')[0];
15
+ if (state === 'enabled') return 'enabled';
16
+ // enabled-runtime lives in /run and is gone after the reboot it is supposed to cover.
17
+ if (state === 'disabled' || state === 'enabled-runtime') return 'disabled';
18
+ if (state === 'masked' || state === 'masked-runtime') return 'masked';
19
+ if (state === '' || state === 'not-found') return 'unavailable';
20
+ return 'unknown';
21
+ } catch { return 'unavailable'; } // no systemctl, or the host/session is not running systemd
22
+ }
23
+
24
+ /** Diagnose availability separately from boot enablement. Never alter host services. */
25
+ export async function reportBootReadiness(effects, record) {
26
+ const platform = effects.platform.platform;
27
+ if (record.mode === 'packages') {
28
+ if (platform === 'linux') {
29
+ try {
30
+ const linger = await effects.run('loginctl', ['show-user', String(process.getuid()), '--property=Linger', '--value']);
31
+ if (linger.stdout.trim() !== 'yes') throw new Error('linger disabled');
32
+ effects.out('Native user-service boot requires enabled package-owned units; user linger is enabled.');
33
+ } catch { effects.out('Native user services require a login session; pre-login host boot is not verified. Ask the operator to enable user linger.'); }
34
+ } else effects.out('Native launchd services start in the macOS GUI login session; pre-login boot and hung-process recovery are not supplied.');
35
+ return;
36
+ }
37
+ if (record.mode !== 'docker' || (record.containerEngine ?? 'docker') !== 'docker') return;
38
+ if (platform !== 'linux') {
39
+ effects.out('Container recovery requires Docker Desktop to start at sign-in. Enable its startup setting; this installer does not arrange pre-login host boot on this platform.');
40
+ return;
41
+ }
42
+ let endpoint, rootless;
43
+ try {
44
+ const context = JSON.parse((await effects.run('docker', ['context', 'inspect'])).stdout);
45
+ // The CLI runs with this same environment and reports the endpoint it resolved from
46
+ // DOCKER_HOST/DOCKER_CONTEXT; their precedence differs between its documentation and releases.
47
+ endpoint = context[0]?.Endpoints?.docker?.Host;
48
+ if (!endpoint?.startsWith('unix://') || endpoint.includes('/.docker/desktop/')) {
49
+ effects.out('Container recovery requires the selected remote/Desktop Docker Engine to start independently; local systemd boot cannot be verified for this context.');
50
+ return;
51
+ }
52
+ const info = JSON.parse((await effects.run('docker', ['info', '--format', '{{json .SecurityOptions}}'])).stdout);
53
+ rootless = info.some(option => option.startsWith('name=rootless'));
54
+ } catch {
55
+ effects.out(warn(`Docker's start-at-boot setting could not be checked because the selected Docker Engine did not answer. If Docker is not set to start at boot, ${NO_AUTOSTART}.`));
56
+ return;
57
+ }
58
+ const sockets = rootless ? [`unix:///run/user/${process.getuid()}/docker.sock`] : ['unix:///var/run/docker.sock', 'unix:///run/docker.sock'];
59
+ if (!sockets.includes(endpoint)) {
60
+ effects.out('The selected custom Docker socket is reachable, but its boot service binding is unverified; enable and verify the service owning that Engine.');
61
+ return;
62
+ }
63
+ const scope = rootless ? ['--user'] : [];
64
+ const enable = `${rootless ? '' : 'sudo '}systemctl ${rootless ? '--user ' : ''}enable docker.service`;
65
+ const state = await unitFileState(effects, scope);
66
+ if (state === 'unavailable') {
67
+ // WSL with Docker Desktop integration, snap, OpenRC/runit and similar: a systemctl command would be wrong here.
68
+ effects.out(warn(`Docker is running now, but no running systemd${rootless ? ' user' : ''} manager with a docker.service was found, so its start-at-boot setting cannot be checked. If Docker is not set to start at boot, ${NO_AUTOSTART}. To start them automatically, enable start-at-boot in whatever manages this Docker Engine (Docker Desktop, snap, or your init system). ${OPTIONAL}`));
69
+ return;
70
+ }
71
+ if (state === 'unknown') {
72
+ effects.out(warn(`Docker is running now, but its systemd${rootless ? ' user' : ''} docker.service is neither plainly enabled nor disabled, so start at boot is not verified. If Docker does not start at boot, ${NO_AUTOSTART}. Check it with: systemctl ${rootless ? '--user ' : ''}status docker.service`));
73
+ return;
74
+ }
75
+ if (state === 'masked') {
76
+ effects.out(warn(`Docker is running now, but its systemd${rootless ? ' user' : ''} docker.service is masked, so it cannot start at boot: ${NO_AUTOSTART}. An administrator masked it deliberately; it must be unmasked before it can be enabled. ${OPTIONAL}`));
77
+ return;
78
+ }
79
+ if (state === 'disabled') {
80
+ effects.out(warn(`Docker is running now, but it is not enabled to start at boot: ${NO_AUTOSTART}. If you want them to start automatically, run: ${enable}${rootless ? ` (and, for startup before you log in, sudo loginctl enable-linger ${effects.username()})` : ''}. ${OPTIONAL}`));
81
+ return;
82
+ }
83
+ if (rootless) {
84
+ let linger = '';
85
+ try { linger = (await effects.run('loginctl', ['show-user', String(process.getuid()), '--property=Linger', '--value'])).stdout.trim(); } catch {}
86
+ if (linger === 'no') {
87
+ effects.out(warn(`Rootless Docker's user service is enabled, but user linger is off, so Docker starts only when you log in: ours components that depend on Docker will not start automatically after a reboot until then. If you want them to start at boot, run: sudo loginctl enable-linger ${effects.username()}. ${OPTIONAL}`));
88
+ return;
89
+ }
90
+ if (linger !== 'yes') {
91
+ effects.out(warn(`Rootless Docker's user service is enabled, but user linger could not be checked. If linger is off, Docker starts only when you log in and ours components that depend on Docker will not start automatically after a reboot until then. Check it with: loginctl show-user ${effects.username()} --property=Linger`));
92
+ return;
93
+ }
94
+ }
95
+ effects.out(`Docker boot service is enabled${rootless ? ' with user linger' : ''}; managed containers recover when that Engine starts.`);
96
+ }
@@ -19,6 +19,7 @@ export async function serverBuildTransition(record, args, effects) {
19
19
  effects.writeJson(path, JSON.stringify(record, null, 2) + '\n');
20
20
  };
21
21
  let transition = record.buildTransition;
22
+ const resuming = !!transition;
22
23
  if (!transition) {
23
24
  const candidate = await stage('Prepare the updated runtime', () => effects.prepareServerBuild(record, args));
24
25
  try {
@@ -41,18 +42,33 @@ export async function serverBuildTransition(record, args, effects) {
41
42
  // A failed readiness check can leave some new services running. Every retry
42
43
  // excludes those writers again and retains the original requested running set.
43
44
  await stage('Stop services before updating stored state', () => effects.retireServerBuildRuntime(record));
45
+ const recover = resuming && record.mode === 'docker' && transition.operation === 'update' && transition.compatible;
46
+ if (recover && transition.phase === 'prepared'
47
+ && await stage('Verify and recover retained Notifications provenance', () => effects.recoverServerBuildNotifications(record, candidate, 'prepared'))) {
48
+ transition = { ...transition, phase: 'state-updated' };
49
+ save(transition);
50
+ }
44
51
  if (transition.phase === 'prepared') {
45
52
  await stage('Update stored state while retaining identities and credentials', () => effects.updateServerBuildState(record, candidate, transition.compatible, transition.operation));
46
53
  transition = { ...transition, phase: 'state-updated' };
47
54
  save(transition);
48
55
  }
56
+ // Old installers omitted Notifications from the already completed state
57
+ // operation. The shipped helper validates both retained generations before
58
+ // repairing that one domain; the candidate and all lifecycle guards remain.
59
+ if (recover) {
60
+ await stage('Verify and recover retained Notifications provenance', () => effects.recoverServerBuildNotifications(record, candidate, transition.phase));
61
+ }
49
62
  if (transition.phase === 'state-updated') {
50
63
  await stage('Activate the prepared runtime', () => effects.publishServerBuild(record, candidate));
51
64
  transition = { ...transition, phase: 'runtime-activated' };
52
65
  save(transition);
53
66
  }
54
67
  await stage('Verify retained state and identities', () => effects.validateServerBuildState(record));
68
+ // Repeatable: an updated runtime may need volume state it introduced, such as notification credentials.
69
+ if (record.gateway) await stage('Prepare stored state for the updated runtime', () => effects.prepareServerVolumes(record));
55
70
  await stage('Restore previously running services and check readiness', () => effects.serverLifecycle(record, 'start', runningServices));
71
+ if (record.gateway && ['daemon', 'cowork', 'gateway'].every(name => runningServices.includes(name))) await stage('Verify authenticated gateway management', () => effects.verifyGateway(record));
56
72
  const completed = { ...record, sourcePolicyHash: candidate.sourcePolicyHash };
57
73
  delete completed.buildTransition;
58
74
  effects.writeJson(path, JSON.stringify(completed, null, 2) + '\n');