@ours.network/install 1.2.1-nightly.6 → 1.2.1-nightly.61
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/GATEWAY_SETUP.md +178 -0
- package/README.md +573 -9
- package/ROOTLESS_PODMAN_VALIDATION.md +210 -0
- package/assets/Dockerfile +15 -12
- package/assets/Dockerfile.gateway +5 -0
- package/assets/docker-compose.yaml +8 -1
- package/assets/fleet-settings.example.json +48 -0
- package/assets/gateway-entrypoint.sh +37 -0
- package/assets/release-lock.json +1221 -4516
- package/assets/release.json +37 -19
- package/assets/scripts/build/build-common.mjs +10 -1
- package/assets/scripts/build/build-sdk.mjs +6 -1
- package/assets/scripts/maintenance/build-context.mjs +1 -1
- package/assets/scripts/maintenance/daemon-owner.mjs +15 -0
- package/assets/scripts/maintenance/docker-layout-conversion.mjs +22 -7
- package/assets/scripts/maintenance/recover-notifications.mjs +36 -0
- package/assets/scripts/maintenance/release-graph.mjs +18 -1
- package/assets/scripts/maintenance/state-operation.mjs +76 -8
- package/assets/scripts/runtime/README.md +7 -0
- package/assets/scripts/runtime/client-setup.mjs +105 -20
- package/assets/scripts/runtime/daemon-client-prefix.mjs +115 -0
- package/assets/scripts/runtime/dependency-ready.mjs +13 -0
- package/assets/scripts/runtime/diagnostics.mjs +72 -0
- package/assets/scripts/runtime/entrypoint.sh +5 -1
- package/assets/scripts/runtime/health-messenger.mjs +7 -6
- package/assets/scripts/runtime/healthcheck.mjs +49 -15
- package/assets/scripts/runtime/notifications-gateway.mjs +90 -0
- package/assets/scripts/runtime/recover.mjs +202 -0
- package/assets/scripts/runtime/start-cowork.sh +5 -0
- package/assets/scripts/runtime/start-messenger.sh +29 -4
- package/assets/scripts/runtime/start-telegram.sh +5 -0
- package/assets/scripts/runtime/supervise.mjs +35 -0
- package/assets/sources.json +54 -28
- package/install.mjs +7 -2
- package/lib/boot-readiness.mjs +96 -0
- package/lib/build-transition.mjs +16 -0
- package/lib/client-cli.mjs +127 -0
- package/lib/container-engine.mjs +127 -0
- package/lib/diagnostics.mjs +1 -0
- package/lib/docker-conversion-runtime.mjs +7 -4
- package/lib/docker-layout-installation.mjs +2 -1
- package/lib/docker-recovery.mjs +60 -0
- package/lib/docker-runtime-repair.mjs +49 -14
- package/lib/effects.mjs +482 -140
- package/lib/gateway-transition.mjs +87 -0
- package/lib/gateway.mjs +227 -0
- package/lib/legacy-migration.mjs +13 -2
- package/lib/orchestrate-uninstall.mjs +23 -6
- package/lib/orchestrate.mjs +335 -44
- package/lib/ownership.mjs +63 -0
- package/lib/plan.mjs +37 -11
- package/lib/podman-preflight.mjs +40 -0
- package/lib/product.mjs +69 -0
- package/lib/removal-plan.mjs +437 -0
- package/lib/removal.mjs +749 -0
- package/lib/server-onboarding.mjs +182 -16
- package/lib/server-ports.mjs +17 -0
- package/lib/setup-options.mjs +119 -29
- package/lib/setup.mjs +93 -22
- package/lib/target.mjs +24 -8
- package/lib/uninstall.mjs +2 -2
- package/lib/usage.mjs +35 -9
- package/lib/welcome.mjs +219 -0
- package/lib/workspace-setup.mjs +154 -0
- package/package.json +4 -2
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
+
}
|
package/assets/sources.json
CHANGED
|
@@ -2,82 +2,108 @@
|
|
|
2
2
|
"release": {
|
|
3
3
|
"schema": 1,
|
|
4
4
|
"channel": "nightly",
|
|
5
|
-
"installerVersion": "1.2.1-nightly.
|
|
5
|
+
"installerVersion": "1.2.1-nightly.61",
|
|
6
6
|
"packages": {
|
|
7
7
|
"@ours.network/sdk": {
|
|
8
|
-
"version": "
|
|
9
|
-
"integrity": "sha512-
|
|
8
|
+
"version": "4.1.1-nightly.4",
|
|
9
|
+
"integrity": "sha512-kTWkRd38YCQmPbgQ7LxvgVEe20de9m80L1wnrgddZ+rnQkjD8NQ314yimnGd/4UH83ucv6M4GE6Z8KKHPvN2Rw=="
|
|
10
10
|
},
|
|
11
11
|
"@ours.network/cli": {
|
|
12
|
-
"version": "
|
|
13
|
-
"integrity": "sha512-
|
|
12
|
+
"version": "3.1.1-nightly.4",
|
|
13
|
+
"integrity": "sha512-pwsVYMd6k99/8IW8cMI4rGRcL9kMnFwJbur8dXnThBevm91WeAdloSCPdc6oeAK0inyC01Gbxp1P3sQFNxfOXQ=="
|
|
14
14
|
},
|
|
15
15
|
"@ours.network/tg-connector": {
|
|
16
|
-
"version": "1.0.1-nightly.
|
|
17
|
-
"integrity": "sha512
|
|
16
|
+
"version": "1.0.1-nightly.16",
|
|
17
|
+
"integrity": "sha512-8GqFZeW1qcuXd8ZLSbxQ3Gl4ju1Eez3EEh9Pua85xYg3lQdIopQYkV2SVamIeMKdV/+CccszkTvXJrkWD1mV/w=="
|
|
18
18
|
},
|
|
19
19
|
"@ours.network/cowork": {
|
|
20
|
-
"version": "1.3.
|
|
21
|
-
"integrity": "sha512-
|
|
20
|
+
"version": "1.3.4-nightly.20261019.b0d73c0",
|
|
21
|
+
"integrity": "sha512-Jfi4xMjxyVhJ6W8D253nrXZm3Jy51X4enk0+Wk5gZf1noW0ea73fBNEPANTq62CBfP9vum3Bf2LttEUKi/vZeA=="
|
|
22
22
|
},
|
|
23
23
|
"@ours.network/messenger-server": {
|
|
24
|
-
"version": "1.0.31-nightly.
|
|
25
|
-
"integrity": "sha512-
|
|
24
|
+
"version": "1.0.31-nightly.25",
|
|
25
|
+
"integrity": "sha512-TX4yBhlCiSUQ+Q3aIYLbIXjAEWbvxPc7rXQEoaU7hQoxq95AL0wJL8xoBV/VYOirDXwPhBG3fzctchEheLELYA=="
|
|
26
|
+
},
|
|
27
|
+
"@ours.network/notifications": {
|
|
28
|
+
"version": "0.3.1-nightly.7",
|
|
29
|
+
"integrity": "sha512-oE6f1P1/QkX+oGuZGiw0dtpeg2sLsh93SvPyshexuFlOr3/5SbR07G8QmTqCRJbQ04h2QB/YlFFlRRgu9iHlCQ=="
|
|
26
30
|
},
|
|
27
31
|
"@ours.network/fleet": {
|
|
28
|
-
"version": "1.2.0-nightly.
|
|
29
|
-
"integrity": "sha512-
|
|
32
|
+
"version": "1.2.0-nightly.80",
|
|
33
|
+
"integrity": "sha512-GuuzhMO+yYsa6+jTcy+dQbz15TWxFSV8jUmQCi8VvZBZYm7DJ/hypc/kyP9yNdVdrv702FnnZsX3LvWWMdEjEw=="
|
|
30
34
|
},
|
|
31
35
|
"@ours.network/mcp": {
|
|
32
|
-
"version": "1.2.0-nightly.
|
|
33
|
-
"integrity": "sha512-
|
|
36
|
+
"version": "1.2.0-nightly.18",
|
|
37
|
+
"integrity": "sha512-phJ8rYiEB+G/1U9ZufeIn38yw6i+b/448SHXVNxreDy4ruhJJcPuVnqj1OeCsFy1n84H/p1uJNszVJsGmG/jlQ=="
|
|
34
38
|
},
|
|
35
39
|
"@ours.network/codex": {
|
|
36
|
-
"version": "1.2.0-nightly.
|
|
37
|
-
"integrity": "sha512-
|
|
40
|
+
"version": "1.2.0-nightly.18",
|
|
41
|
+
"integrity": "sha512-48TkTxJe487EMsqxCPsiLnC9KGApOaCi8XENLli1IevCUPMUvvQ4amxaBI36Pd5cA6WG15ZtxIu+PENYMcvi9A=="
|
|
38
42
|
},
|
|
39
43
|
"@ours.network/claude-code": {
|
|
40
|
-
"version": "1.2.0-nightly.
|
|
41
|
-
"integrity": "sha512
|
|
44
|
+
"version": "1.2.0-nightly.18",
|
|
45
|
+
"integrity": "sha512-/KuhoBlVuQVFLkCRIWU/UyDc5X+Xz7BvuPpDrZkD1A0/buOpK5OpkKVr2uQx/V+Byr1yevZHTdkQ7SBhhgdUKg=="
|
|
46
|
+
},
|
|
47
|
+
"@ours.network/daemon": {
|
|
48
|
+
"version": "4.1.1-nightly.4",
|
|
49
|
+
"integrity": "sha512-PP4ynhx7rcwPccoMOB3giipHSynkNmJeObwY1nsg2Dlb/TiiyyFL+ACwbRtqH9MFcb4zanj+iHrLN3uT59+Nsw=="
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"hostCli": {
|
|
53
|
+
"@ours.network/sdk": {
|
|
54
|
+
"version": "4.1.1-nightly.4",
|
|
55
|
+
"integrity": "sha512-kTWkRd38YCQmPbgQ7LxvgVEe20de9m80L1wnrgddZ+rnQkjD8NQ314yimnGd/4UH83ucv6M4GE6Z8KKHPvN2Rw=="
|
|
56
|
+
},
|
|
57
|
+
"@ours.network/cli": {
|
|
58
|
+
"version": "3.1.1-nightly.4",
|
|
59
|
+
"integrity": "sha512-pwsVYMd6k99/8IW8cMI4rGRcL9kMnFwJbur8dXnThBevm91WeAdloSCPdc6oeAK0inyC01Gbxp1P3sQFNxfOXQ=="
|
|
42
60
|
}
|
|
43
61
|
}
|
|
44
62
|
},
|
|
45
63
|
"packages": {
|
|
46
64
|
"@ours.network/sdk": {
|
|
47
65
|
"type": "npm",
|
|
48
|
-
"version": "
|
|
66
|
+
"version": "4.1.1-nightly.4"
|
|
49
67
|
},
|
|
50
68
|
"@ours.network/cli": {
|
|
51
69
|
"type": "npm",
|
|
52
|
-
"version": "
|
|
70
|
+
"version": "3.1.1-nightly.4"
|
|
53
71
|
},
|
|
54
72
|
"@ours.network/tg-connector": {
|
|
55
73
|
"type": "npm",
|
|
56
|
-
"version": "1.0.1-nightly.
|
|
74
|
+
"version": "1.0.1-nightly.16"
|
|
57
75
|
},
|
|
58
76
|
"@ours.network/cowork": {
|
|
59
77
|
"type": "npm",
|
|
60
|
-
"version": "1.3.
|
|
78
|
+
"version": "1.3.4-nightly.20261019.b0d73c0"
|
|
61
79
|
},
|
|
62
80
|
"@ours.network/messenger-server": {
|
|
63
81
|
"type": "npm",
|
|
64
|
-
"version": "1.0.31-nightly.
|
|
82
|
+
"version": "1.0.31-nightly.25"
|
|
83
|
+
},
|
|
84
|
+
"@ours.network/notifications": {
|
|
85
|
+
"type": "npm",
|
|
86
|
+
"version": "0.3.1-nightly.7"
|
|
65
87
|
},
|
|
66
88
|
"@ours.network/fleet": {
|
|
67
89
|
"type": "npm",
|
|
68
|
-
"version": "1.2.0-nightly.
|
|
90
|
+
"version": "1.2.0-nightly.80"
|
|
69
91
|
},
|
|
70
92
|
"@ours.network/mcp": {
|
|
71
93
|
"type": "npm",
|
|
72
|
-
"version": "1.2.0-nightly.
|
|
94
|
+
"version": "1.2.0-nightly.18"
|
|
73
95
|
},
|
|
74
96
|
"@ours.network/codex": {
|
|
75
97
|
"type": "npm",
|
|
76
|
-
"version": "1.2.0-nightly.
|
|
98
|
+
"version": "1.2.0-nightly.18"
|
|
77
99
|
},
|
|
78
100
|
"@ours.network/claude-code": {
|
|
79
101
|
"type": "npm",
|
|
80
|
-
"version": "1.2.0-nightly.
|
|
102
|
+
"version": "1.2.0-nightly.18"
|
|
103
|
+
},
|
|
104
|
+
"@ours.network/daemon": {
|
|
105
|
+
"type": "npm",
|
|
106
|
+
"version": "4.1.1-nightly.4"
|
|
81
107
|
}
|
|
82
108
|
}
|
|
83
109
|
}
|
package/install.mjs
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
import { readFileSync } from 'node:fs';
|
|
4
4
|
|
|
5
5
|
import { realEffects } from './lib/effects.mjs';
|
|
6
|
+
import { installerFailure } from './lib/diagnostics.mjs';
|
|
7
|
+
import { runWorkspaceSetup } from './lib/workspace-setup.mjs';
|
|
6
8
|
import { runSetup } from './lib/setup.mjs';
|
|
7
9
|
import { closeSync, makeWriter, openTty } from './lib/ui.mjs';
|
|
8
10
|
|
|
@@ -10,7 +12,10 @@ const version = JSON.parse(readFileSync(new URL('./package.json', import.meta.ur
|
|
|
10
12
|
const ttyFd = openTty();
|
|
11
13
|
|
|
12
14
|
try {
|
|
13
|
-
const
|
|
15
|
+
const args=process.argv.slice(2);
|
|
16
|
+
const workspace=args.some(v=>v==='--setup-workspace' || v.startsWith('--setup-workspace=') || v==='--setup-workspace-file' || v.startsWith('--setup-workspace-file='));
|
|
17
|
+
const execute=workspace ? (args,effects)=>runWorkspaceSetup(args,effects,runSetup) : runSetup;
|
|
18
|
+
const code = await execute(args, realEffects({
|
|
14
19
|
write: makeWriter(ttyFd),
|
|
15
20
|
ttyFd,
|
|
16
21
|
env: process.env,
|
|
@@ -18,7 +23,7 @@ try {
|
|
|
18
23
|
}));
|
|
19
24
|
process.exitCode = code;
|
|
20
25
|
} catch (error) {
|
|
21
|
-
process.stderr.write(`ours-install: ${
|
|
26
|
+
process.stderr.write(`ours-install: ${installerFailure(error)}\n`);
|
|
22
27
|
process.exitCode = 1;
|
|
23
28
|
} finally {
|
|
24
29
|
if (ttyFd != null) {
|
|
@@ -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
|
+
}
|
package/lib/build-transition.mjs
CHANGED
|
@@ -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');
|