@ours.network/install 1.2.1-nightly.2 → 1.2.1-nightly.21
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 +337 -12
- package/ROOTLESS_PODMAN_VALIDATION.md +210 -0
- package/assets/Dockerfile +16 -12
- package/assets/Dockerfile.gateway +5 -0
- package/assets/docker-compose.yaml +21 -1
- package/assets/fleet-settings.example.json +48 -0
- package/assets/gateway-entrypoint.sh +37 -0
- package/assets/release-lock.json +1111 -4265
- package/assets/release.json +33 -19
- package/assets/scripts/build/build-common.mjs +1 -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 +7 -3
- package/assets/scripts/maintenance/release-graph.mjs +18 -1
- package/assets/scripts/maintenance/state-operation.mjs +4 -2
- package/assets/scripts/runtime/client-setup.mjs +3 -3
- package/assets/scripts/runtime/entrypoint.sh +1 -1
- package/assets/scripts/runtime/legacy-import.mjs +103 -0
- package/assets/sources.json +46 -28
- package/install.mjs +5 -1
- package/lib/build-transition.mjs +1 -0
- package/lib/client-cli.mjs +127 -0
- package/lib/container-engine.mjs +127 -0
- package/lib/docker-conversion-runtime.mjs +3 -2
- package/lib/docker-layout-installation.mjs +2 -1
- package/lib/docker-runtime-repair.mjs +152 -0
- package/lib/effects.mjs +276 -126
- package/lib/gateway-transition.mjs +87 -0
- package/lib/gateway.mjs +142 -0
- package/lib/legacy-migration.mjs +213 -0
- package/lib/legacy-state.mjs +205 -0
- package/lib/managed-cli.mjs +164 -0
- package/lib/orchestrate.mjs +114 -38
- package/lib/plan.mjs +22 -9
- package/lib/podman-preflight.mjs +40 -0
- package/lib/prompt.mjs +113 -119
- package/lib/server-onboarding.mjs +63 -16
- package/lib/setup-options.mjs +137 -35
- package/lib/setup.mjs +30 -16
- package/lib/target.mjs +24 -8
- package/lib/uninstall.mjs +2 -2
- package/lib/usage.mjs +9 -4
- package/lib/workspace-setup.mjs +83 -0
- package/package.json +4 -2
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
/** Replace only the verified, user-owned npm CLI entry after managed cutover. */
|
|
2
|
+
import { accessSync, constants, existsSync, lstatSync, mkdirSync, readFileSync, readlinkSync, realpathSync, renameSync, rmSync, writeFileSync, chmodSync } from 'node:fs';
|
|
3
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
5
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
6
|
+
|
|
7
|
+
const marker = '// ours-managed-cli-v1 ';
|
|
8
|
+
const backupName = 'managed-cli-original.json';
|
|
9
|
+
const sha = bytes => createHash('sha256').update(bytes).digest('hex');
|
|
10
|
+
const uid = () => process.getuid();
|
|
11
|
+
function absolute(path) {
|
|
12
|
+
if (typeof path !== 'string' || !isAbsolute(path) || resolve(path) !== path || /[\r\n\0]/.test(path)) throw new Error('Managed CLI requires normalized absolute paths');
|
|
13
|
+
return path;
|
|
14
|
+
}
|
|
15
|
+
function owned(path, { directory = false, writable = false } = {}) {
|
|
16
|
+
const stat = lstatSync(path);
|
|
17
|
+
if (stat.uid !== uid() || (directory ? !stat.isDirectory() : (!stat.isFile() || stat.nlink !== 1)) || (stat.mode & 0o022)) throw new Error(`Managed CLI refuses foreign or unsafe ownership: ${path}`);
|
|
18
|
+
if (directory && realpathSync(path) !== path) throw new Error('Managed CLI directory must be canonical');
|
|
19
|
+
if (writable) {
|
|
20
|
+
if (!(stat.mode & 0o200)) throw new Error(`Managed CLI path is read-only: ${path}`);
|
|
21
|
+
accessSync(path, constants.W_OK | (directory ? constants.X_OK : 0));
|
|
22
|
+
}
|
|
23
|
+
return stat;
|
|
24
|
+
}
|
|
25
|
+
function snapshot(path) {
|
|
26
|
+
const stat = lstatSync(path);
|
|
27
|
+
if (stat.uid !== uid() || (!stat.isSymbolicLink() && (!stat.isFile() || stat.nlink !== 1))) throw new Error('Managed CLI entry is not an owned file or symlink');
|
|
28
|
+
if (!stat.isSymbolicLink() && (stat.mode & 0o022)) throw new Error('Managed CLI entry is writable by another user');
|
|
29
|
+
return { kind: stat.isSymbolicLink() ? 'symlink' : 'file', dev: stat.dev, ino: stat.ino, uid: stat.uid, mode: stat.mode & 0o7777,
|
|
30
|
+
size: stat.size, mtimeMs: stat.mtimeMs, ...(stat.isSymbolicLink() ? { link: readlinkSync(path), resolved: realpathSync(path) } : {}), digest: sha(readFileSync(path)) };
|
|
31
|
+
}
|
|
32
|
+
function readBackup(targetRoot) {
|
|
33
|
+
const path = join(targetRoot, 'legacy-backup', backupName);
|
|
34
|
+
owned(dirname(path), { directory: true }); owned(path);
|
|
35
|
+
const value = JSON.parse(readFileSync(path, 'utf8'));
|
|
36
|
+
if (value.schema !== 1 || value.targetRoot !== targetRoot || !value.original || typeof value.originalProgram !== 'string') throw new Error('Invalid managed CLI backup');
|
|
37
|
+
return value;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export function buildManagedCli(recordPath, installerPath) {
|
|
41
|
+
absolute(recordPath); absolute(installerPath);
|
|
42
|
+
const binding = { schema: 1, targetRoot: dirname(recordPath), recordPath, installerPath };
|
|
43
|
+
return `#!/usr/bin/env node
|
|
44
|
+
${marker}${JSON.stringify(binding)}
|
|
45
|
+
'use strict';
|
|
46
|
+
const fs = require('node:fs');
|
|
47
|
+
const path = require('node:path');
|
|
48
|
+
const { spawnSync } = require('node:child_process');
|
|
49
|
+
const binding = ${JSON.stringify(binding)};
|
|
50
|
+
function fail(message) { console.error('ours: ' + message); process.exit(2); }
|
|
51
|
+
const args = process.argv.slice(2);
|
|
52
|
+
if (args.some(arg => /^(?:--config|--state-dir|--port|--daemon-id|--daemon-url|--endpoint|--credential-path)(?:=|$)/.test(arg))) fail('This command belongs to the managed installation. Use ours-install to select or manage another installation.');
|
|
53
|
+
let record;
|
|
54
|
+
try {
|
|
55
|
+
const stat = fs.lstatSync(binding.recordPath);
|
|
56
|
+
if (!stat.isFile() || stat.nlink !== 1 || stat.uid !== process.getuid() || (stat.mode & 0o077) || fs.realpathSync(binding.recordPath) !== binding.recordPath) throw new Error('unsafe record');
|
|
57
|
+
record = JSON.parse(fs.readFileSync(binding.recordPath, 'utf8'));
|
|
58
|
+
} catch { fail('The managed installation record is missing or unsafe; repair it with ours-install.'); }
|
|
59
|
+
if (record.schema !== 2 || record.root !== binding.targetRoot || !['packages', 'docker'].includes(record.mode)
|
|
60
|
+
|| typeof record.instanceId !== 'string' || !/^[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12}$/.test(record.instanceId)
|
|
61
|
+
|| !Number.isInteger(record.port) || record.port < 1 || record.port > 65535
|
|
62
|
+
|| record.workDir !== path.join(record.root, 'runtime') || record.configPath !== path.join(record.root, 'storage/state/daemon/config.json')
|
|
63
|
+
|| (record.mode === 'docker' && (typeof record.project !== 'string' || !/^[a-z0-9][a-z0-9_-]*$/.test(record.project)))) fail('The managed installation selection is invalid.');
|
|
64
|
+
const env = { ...process.env };
|
|
65
|
+
for (const key of Object.keys(env)) if (key.startsWith('OURS_')) delete env[key];
|
|
66
|
+
const lifecycle = args[0] === 'daemon' && ['start', 'stop', 'restart', 'status'].includes(args[1]);
|
|
67
|
+
const version = args[0] === 'version' || args[0] === '--version' || args[0] === '-V';
|
|
68
|
+
let command, commandArgs;
|
|
69
|
+
if (lifecycle) {
|
|
70
|
+
if (args.slice(2).some(arg => arg !== '--json') || (args[1] !== 'status' && args.includes('--json'))) fail('Use ours-install server for lifecycle options; --json is supported for status only.');
|
|
71
|
+
command = process.execPath;
|
|
72
|
+
commandArgs = [binding.installerPath, 'server', args[1], '--state-dir', record.root];
|
|
73
|
+
} else {
|
|
74
|
+
if (args[0] === 'daemon') fail('Use ours-install server to manage this installation and its services.');
|
|
75
|
+
if (args[0] === 'config' && args[1] !== 'show') fail('Use ours-install server to manage configuration and credentials.');
|
|
76
|
+
if (record.mode === 'docker') {
|
|
77
|
+
command = 'docker';
|
|
78
|
+
commandArgs = ['exec', '-i', record.project + '-daemon-1', 'node', '/opt/ours/node_modules/@ours.network/cli/dist/cli.js', ...args];
|
|
79
|
+
if (!version) commandArgs.push('--config', '/var/lib/ours/config.json', '--state-dir', '/var/lib/ours');
|
|
80
|
+
} else {
|
|
81
|
+
command = path.join(record.workDir, 'node_modules/.bin/ours');
|
|
82
|
+
commandArgs = [...args];
|
|
83
|
+
if (!version) commandArgs.push('--config', record.configPath, '--state-dir', path.join(record.root, 'storage/state/daemon'));
|
|
84
|
+
Object.assign(env, { OURS_CONFIG: record.configPath, OURS_STATE_DIR: path.join(record.root, 'storage/state/daemon'), OURS_PORT: String(record.port), OURS_DAEMON_ID: record.instanceId });
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
const result = spawnSync(command, commandArgs, { stdio: 'inherit', env });
|
|
88
|
+
if (result.error) fail('Could not start the managed command: ' + result.error.message);
|
|
89
|
+
if (result.signal) { process.kill(process.pid, result.signal); process.exit(1); }
|
|
90
|
+
process.exit(result.status ?? 1);
|
|
91
|
+
`;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export async function inspectManagedCli(effects, targetRoot) {
|
|
95
|
+
if (!['linux', 'darwin'].includes(effects.platform?.platform ?? process.platform) || typeof process.getuid !== 'function') throw new Error('Managed CLI cutover supports Linux/macOS only');
|
|
96
|
+
absolute(targetRoot);
|
|
97
|
+
const output = async args => {
|
|
98
|
+
const result = await effects.run(args[0], args.slice(1));
|
|
99
|
+
if (result.code !== undefined && result.code !== 0) throw new Error('Cannot determine the existing global CLI selection');
|
|
100
|
+
return absolute(result.stdout.trim());
|
|
101
|
+
};
|
|
102
|
+
const npmRoot = await output(['npm', 'root', '--global']);
|
|
103
|
+
const prefix = await output(['npm', 'prefix', '--global']);
|
|
104
|
+
const binPath = join(prefix, 'bin', 'ours');
|
|
105
|
+
const selected = await output(['which', 'ours']);
|
|
106
|
+
if (selected !== binPath) throw new Error('PATH selects another ours command; select the verified npm global bin before migration');
|
|
107
|
+
owned(dirname(binPath), { directory: true, writable: true });
|
|
108
|
+
const packageRoot = realpathSync(join(npmRoot, '@ours.network/cli'));
|
|
109
|
+
const packagePath = join(packageRoot, 'package.json'); owned(packagePath);
|
|
110
|
+
const pkg = JSON.parse(readFileSync(packagePath, 'utf8'));
|
|
111
|
+
if (pkg.name !== '@ours.network/cli' || typeof pkg.bin?.ours !== 'string') throw new Error('Global package does not declare the expected ours CLI');
|
|
112
|
+
const originalProgram = realpathSync(resolve(packageRoot, pkg.bin.ours));
|
|
113
|
+
if (!originalProgram.startsWith(packageRoot + '/')) throw new Error('Global CLI bin escapes its package');
|
|
114
|
+
owned(originalProgram); accessSync(originalProgram, constants.R_OK | constants.X_OK);
|
|
115
|
+
const before = snapshot(binPath);
|
|
116
|
+
let installed = false;
|
|
117
|
+
let installerPath = fileURLToPath(new URL('../install.mjs', import.meta.url));
|
|
118
|
+
if (before.kind === 'symlink') {
|
|
119
|
+
if (before.resolved !== originalProgram) throw new Error('Global ours symlink does not target the verified npm CLI');
|
|
120
|
+
} else {
|
|
121
|
+
const contents = readFileSync(binPath, 'utf8');
|
|
122
|
+
const line = contents.split('\n')[1];
|
|
123
|
+
if (!line?.startsWith(marker)) throw new Error('Refusing to replace an unknown ours executable');
|
|
124
|
+
const binding = JSON.parse(line.slice(marker.length));
|
|
125
|
+
if (binding.schema !== 1 || binding.targetRoot !== targetRoot || binding.recordPath !== join(targetRoot, 'installation.json')) throw new Error('Managed CLI belongs to another installation');
|
|
126
|
+
installerPath = absolute(binding.installerPath);
|
|
127
|
+
if (contents !== buildManagedCli(binding.recordPath, installerPath)) throw new Error('Managed CLI launcher was modified');
|
|
128
|
+
const backup = readBackup(targetRoot);
|
|
129
|
+
if (backup.binPath !== binPath || backup.originalProgram !== originalProgram) throw new Error('Managed CLI backup selects another original executable');
|
|
130
|
+
installed = true;
|
|
131
|
+
}
|
|
132
|
+
return { schema: 1, targetRoot, binPath, originalProgram, installerPath, before, installed };
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export async function installManagedCli(record, cliPlan, effects, { rename = renameSync } = {}) {
|
|
136
|
+
if (record.root !== cliPlan.targetRoot) throw new Error('Managed CLI target changed after inspection');
|
|
137
|
+
const fresh = await inspectManagedCli(effects, record.root);
|
|
138
|
+
if (fresh.binPath !== cliPlan.binPath || fresh.originalProgram !== cliPlan.originalProgram || JSON.stringify(fresh.before) !== JSON.stringify(cliPlan.before)) throw new Error('Global CLI changed after inspection; cutover refused');
|
|
139
|
+
const installerPath = absolute(cliPlan.installerPath);
|
|
140
|
+
owned(installerPath);
|
|
141
|
+
if (realpathSync(installerPath) !== installerPath) throw new Error('Managed installer path must be canonical');
|
|
142
|
+
if (fresh.installed && fresh.installerPath !== installerPath) throw new Error('Managed installer selection changed after inspection');
|
|
143
|
+
if (fresh.installed) return { binPath: fresh.binPath, originalProgram: fresh.originalProgram, changed: false };
|
|
144
|
+
owned(record.root, { directory: true });
|
|
145
|
+
const backupDir = join(record.root, 'legacy-backup');
|
|
146
|
+
if (!existsSync(backupDir)) mkdirSync(backupDir, { mode: 0o700 });
|
|
147
|
+
const backupStat = owned(backupDir, { directory: true });
|
|
148
|
+
if (backupStat.mode & 0o077) throw new Error('CLI backup directory must be private');
|
|
149
|
+
const backupPath = join(backupDir, backupName);
|
|
150
|
+
const backup = { schema: 1, targetRoot: record.root, binPath: fresh.binPath, originalProgram: fresh.originalProgram,
|
|
151
|
+
original: fresh.before, ...(fresh.before.kind === 'file' ? { bytes: readFileSync(fresh.binPath).toString('base64') } : {}) };
|
|
152
|
+
if (existsSync(backupPath)) {
|
|
153
|
+
const original = readBackup(record.root);
|
|
154
|
+
if (original.binPath !== backup.binPath || original.originalProgram !== backup.originalProgram) throw new Error('Existing CLI backup differs from the selected original');
|
|
155
|
+
} else writeFileSync(backupPath, JSON.stringify(backup, null, 2) + '\n', { flag: 'wx', mode: 0o600 });
|
|
156
|
+
const contents = buildManagedCli(join(record.root, 'installation.json'), installerPath);
|
|
157
|
+
const temporary = join(dirname(fresh.binPath), `.ours-managed-${randomUUID()}`);
|
|
158
|
+
try {
|
|
159
|
+
writeFileSync(temporary, contents, { flag: 'wx', mode: 0o700 }); chmodSync(temporary, 0o755);
|
|
160
|
+
if (JSON.stringify(snapshot(fresh.binPath)) !== JSON.stringify(fresh.before)) throw new Error('Global CLI changed during cutover');
|
|
161
|
+
rename(temporary, fresh.binPath);
|
|
162
|
+
} finally { rmSync(temporary, { force: true }); }
|
|
163
|
+
return { binPath: fresh.binPath, originalProgram: fresh.originalProgram, changed: true };
|
|
164
|
+
}
|
package/lib/orchestrate.mjs
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import { validateGatewayClientProfile } from './target.mjs';
|
|
2
|
+
import { enableGateway } from './gateway-transition.mjs';
|
|
3
|
+
import { executeLegacyMigration } from './legacy-migration.mjs';
|
|
1
4
|
// ours-install v3 — the orchestrator.
|
|
2
5
|
//
|
|
3
6
|
// This is the part that cannot be pure: it walks the flow, renders the screens
|
|
@@ -25,7 +28,7 @@
|
|
|
25
28
|
|
|
26
29
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
27
30
|
import { parseNetworkArgs, validateHostProfile, parseInstallArgs, resolveTarget, resolveProfileSelection, profileEnv, InstallUsageError } from './target.mjs';
|
|
28
|
-
import { selectSourcePackages, validateInstallation, SERVER_SERVICES, planDaemonConfig, planServiceInstall, serviceInstallCommand } from './plan.mjs';
|
|
31
|
+
import { clientPackageNames, selectSourcePackages, validateInstallation, SERVER_SERVICES, planDaemonConfig, planServiceInstall, serviceInstallCommand } from './plan.mjs';
|
|
29
32
|
import {
|
|
30
33
|
COMPONENTS,
|
|
31
34
|
planComponentSelection, planMcpAttachment, planTgAttachment, planCoworkAttachment,
|
|
@@ -85,6 +88,41 @@ async function perform(effects, dryRun, label, thunk) {
|
|
|
85
88
|
|
|
86
89
|
const reason = (error) => (error instanceof Error ? error.message : String(error));
|
|
87
90
|
|
|
91
|
+
function clientDiagnostic(error) {
|
|
92
|
+
return reason(error)
|
|
93
|
+
.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g, '')
|
|
94
|
+
.replace(/\bBearer\s+[^\s,;]+/gi, 'Bearer [redacted]')
|
|
95
|
+
.replace(/((?:api[_-]?key|api[_-]?token|access[_-]?token|refresh[_-]?token|token|password|secret|authorization|credential)\s*["']?\s*[:=]\s*["']?)[^\s"',;]+/gi, '$1[redacted]')
|
|
96
|
+
.replace(/(https?:\/\/)[^\s/@]+:[^\s/@]+@/gi, '$1[redacted]@')
|
|
97
|
+
.replace(/[\x00-\x1f\x7f]/g, ' ').slice(0, 700);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function clientRetry(effects, imported, integrations) {
|
|
101
|
+
effects.out(info(`Saved server connection: ${imported.configPath}.`));
|
|
102
|
+
if (integrations.includes('fleet') && !imported.settings.fleetSettingsPath) {
|
|
103
|
+
effects.out(info('Saved profile and settings retained. Run ours-install, choose Connect to an existing server, and reuse the saved profile to finish the interactive Fleet configuration.'));
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const args = ['client', 'install', '--config', imported.configPath, '--integrations', integrations.join(',') || 'none', '--sources', imported.settings.sourcesPath];
|
|
107
|
+
if (imported.settings.fleetSettingsPath) args.push('--fleet-settings', imported.settings.fleetSettingsPath);
|
|
108
|
+
const command = `ours-install client install ${args.slice(2).map((value, i) => i % 2 === 0 ? value : shellQuote(value)).join(' ')}`;
|
|
109
|
+
effects.out(info(`Saved profile and settings retained; re-run ${command}`));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function explainClientFailure(effects, name, row) {
|
|
113
|
+
const label = { codex: 'Codex', 'claude-code': 'Claude Code', fleet: 'Fleet' }[name];
|
|
114
|
+
const command = name === 'claude-code' ? 'claude' : name;
|
|
115
|
+
if (row?.note === 'not installed') {
|
|
116
|
+
effects.out(warn(`${label}: executable not found on PATH. Install ${label} or make its executable available in this shell, then check ${command} --version before retrying.`));
|
|
117
|
+
} else if (row?.manual) {
|
|
118
|
+
effects.out(warn(`${label}: cannot register the plugin automatically — ${clientDiagnostic(row.note)}. Use the real executable (check ${command} --version), or register the displayed local marketplace manually.`));
|
|
119
|
+
} else {
|
|
120
|
+
effects.out(warn(`${label}: ${row?.failedStep ?? 'integration setup'} failed. ${clientDiagnostic(row?.detail ?? row?.note ?? 'The integration did not report successful completion. Review the messages above.')} Fix the reported command error before retrying.`));
|
|
121
|
+
if (row?.failedCommand) effects.out(info(`Failed command: ${row.failedCommand.map(shellQuote).join(' ')}`));
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
|
|
88
126
|
function semverMajor(version) {
|
|
89
127
|
const match = /^(?:[~^<>= ]*)(\d+)\./.exec(String(version ?? '').trim());
|
|
90
128
|
return match ? Number(match[1]) : null;
|
|
@@ -109,6 +147,7 @@ function incompatibleUpgrade(target, cliDependencies) {
|
|
|
109
147
|
async function prepareIncompatibleUpgrade(args, effects, target, cliPkg, mismatch) {
|
|
110
148
|
const dir = target.stateDir;
|
|
111
149
|
const configPath = join(dir, 'config.json');
|
|
150
|
+
const owner = effects.readJson(join(dir, 'ours-cli-daemon.json'))?.owner === '@ours.network/daemon' ? ['ours-daemon'] : ['ours', 'daemon'];
|
|
112
151
|
if (mismatch.unknown) {
|
|
113
152
|
effects.out(warn(`ours: cannot verify whether ${cliPkg} can restore daemon v${mismatch.runningVersion}. Nothing was changed.`));
|
|
114
153
|
effects.out(info('Check npm registry access and re-run; compatibility checks fail closed.'));
|
|
@@ -152,13 +191,13 @@ async function prepareIncompatibleUpgrade(args, effects, target, cliPkg, mismatc
|
|
|
152
191
|
}
|
|
153
192
|
|
|
154
193
|
await perform(effects, false, 'stop the incompatible daemon', () => effects.run(
|
|
155
|
-
|
|
194
|
+
owner[0], [...owner.slice(1), 'stop', '--state-dir', dir, '--config', configPath], { stream: true },
|
|
156
195
|
));
|
|
157
196
|
try {
|
|
158
197
|
await perform(effects, false, `back up complete daemon state to ${backupPath}`, () => effects.copyDir(dir, backupPath));
|
|
159
198
|
} catch (error) {
|
|
160
199
|
try {
|
|
161
|
-
await effects.run(
|
|
200
|
+
await effects.run(owner[0], [...owner.slice(1), 'start', '--state-dir', dir, '--config', configPath], { stream: true });
|
|
162
201
|
effects.out(ok('backup failed, but the old daemon was started again'));
|
|
163
202
|
} catch {
|
|
164
203
|
effects.out(warn(`backup failed and the old daemon did not restart; its state is still untouched at ${dir}`));
|
|
@@ -167,11 +206,11 @@ async function prepareIncompatibleUpgrade(args, effects, target, cliPkg, mismatc
|
|
|
167
206
|
}
|
|
168
207
|
try {
|
|
169
208
|
await perform(effects, false, 'remove the incompatible daemon boot service', () => effects.run(
|
|
170
|
-
|
|
209
|
+
owner[0], [...owner.slice(1), 'uninstall-service', '--yes', '--state-dir', dir, '--config', configPath], { stream: true },
|
|
171
210
|
));
|
|
172
211
|
} catch (error) {
|
|
173
212
|
try {
|
|
174
|
-
await effects.run(
|
|
213
|
+
await effects.run(owner[0], [...owner.slice(1), 'start', '--state-dir', dir, '--config', configPath], { stream: true });
|
|
175
214
|
effects.out(ok(`service removal failed, but the old daemon was started again; backup retained at ${backupPath}`));
|
|
176
215
|
} catch {
|
|
177
216
|
effects.out(warn(`service removal failed and the old daemon did not restart; state remains at ${dir} and the backup is at ${backupPath}`));
|
|
@@ -192,11 +231,11 @@ async function prepareIncompatibleUpgrade(args, effects, target, cliPkg, mismatc
|
|
|
192
231
|
* rather than one harness. So a failure here is one honest line plus whatever
|
|
193
232
|
* the caller wants to say about retrying, and the walk continues.
|
|
194
233
|
*/
|
|
195
|
-
async function attempt(effects, dryRun, label, thunk) {
|
|
234
|
+
async function attempt(effects, dryRun, label, thunk, formatReason = reason) {
|
|
196
235
|
try {
|
|
197
236
|
return { ok: true, ...(await perform(effects, dryRun, label, thunk)) };
|
|
198
237
|
} catch (error) {
|
|
199
|
-
effects.out(warn(`${label} — did not complete: ${
|
|
238
|
+
effects.out(warn(`${label} — did not complete: ${formatReason(error)}`));
|
|
200
239
|
return { ok: false, error };
|
|
201
240
|
}
|
|
202
241
|
}
|
|
@@ -332,14 +371,13 @@ export async function runDaemonPhase(args, effects, exactSuite = null) {
|
|
|
332
371
|
const mcpPkg = exactSuite?.packages?.mcp
|
|
333
372
|
? `@ours.network/mcp@${exactSuite.packages.mcp}`
|
|
334
373
|
: componentSpec(componentByKey('mcp'), args.channel);
|
|
335
|
-
//
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
const cliPkg = '@ours.network/cli';
|
|
374
|
+
// Inspect the runtime package SDK compatibility before replacing the owner.
|
|
375
|
+
const cliPkg = args.channel === 'nightly' ? '@ours.network/cli@nightly' : '@ours.network/cli';
|
|
376
|
+
const daemonPkg = args.channel === 'nightly' ? '@ours.network/daemon@nightly' : '@ours.network/daemon';
|
|
339
377
|
if (!creating && target.daemonVersion) {
|
|
340
|
-
const mismatch = incompatibleUpgrade(target, effects.packageDependencies(
|
|
378
|
+
const mismatch = incompatibleUpgrade(target, effects.packageDependencies(daemonPkg));
|
|
341
379
|
if (mismatch) {
|
|
342
|
-
const prepared = await prepareIncompatibleUpgrade(args, effects, target,
|
|
380
|
+
const prepared = await prepareIncompatibleUpgrade(args, effects, target, daemonPkg, mismatch);
|
|
343
381
|
if (prepared.refused) return { target, refused: prepared.refused, steps };
|
|
344
382
|
creating = prepared.purged === true;
|
|
345
383
|
target.backupPath = prepared.backupPath;
|
|
@@ -348,6 +386,18 @@ export async function runDaemonPhase(args, effects, exactSuite = null) {
|
|
|
348
386
|
}
|
|
349
387
|
await perform(effects, args.dryRun, `MCP server installed (npm i -g ${mcpPkg})`, () => effects.run('npm', ['i', '-g', mcpPkg]));
|
|
350
388
|
steps.push({ id: 'mcp-package', changed: true, packageRefresh: true });
|
|
389
|
+
await perform(effects, args.dryRun, 'daemon runtime installed', () => effects.run('npm', ['i', '-g', daemonPkg]));
|
|
390
|
+
// A retained global unit still points into the old CLI package. Rewrite and
|
|
391
|
+
// activate that owned unit before npm replaces its executable with thin CLI.
|
|
392
|
+
let migratedService;
|
|
393
|
+
if (!creating) {
|
|
394
|
+
const retained = planServiceInstall({ stateDir: dir, home: effects.home, readText: effects.readText, platform: effects.platform?.platform });
|
|
395
|
+
if (retained.unitPath && effects.readText(retained.unitPath) !== null) {
|
|
396
|
+
try { migratedService = await runServicePhase(args, effects, dir, target.port); }
|
|
397
|
+
catch (error) { await recoverDaemon(args, effects, dir, join(dir, 'config.json'), target.port); throw error; }
|
|
398
|
+
if (migratedService.refused) return { target, refused: migratedService.refused, steps };
|
|
399
|
+
}
|
|
400
|
+
}
|
|
351
401
|
await perform(effects, args.dryRun, `ours CLI installed (npm i -g ${cliPkg})`, () => effects.run('npm', ['i', '-g', cliPkg]));
|
|
352
402
|
steps.push({ id: 'cli', changed: true, packageRefresh: true });
|
|
353
403
|
|
|
@@ -382,14 +432,14 @@ export async function runDaemonPhase(args, effects, exactSuite = null) {
|
|
|
382
432
|
|
|
383
433
|
try {
|
|
384
434
|
if (creating) {
|
|
385
|
-
await perform(effects, args.dryRun, `start the daemon on port ${target.port}`, () => effects.run('ours', [
|
|
435
|
+
await perform(effects, args.dryRun, `start the daemon on port ${target.port}`, () => effects.run('ours-daemon', [ 'start', '--config', configPath], { stream: true }));
|
|
386
436
|
steps.push({ id: 'start', changed: true });
|
|
387
437
|
} else {
|
|
388
|
-
await perform(effects, args.dryRun, `restart the daemon on port ${target.port}`, () => effects.run('ours', [
|
|
438
|
+
await perform(effects, args.dryRun, `restart the daemon on port ${target.port}`, () => effects.run('ours-daemon', [ 'restart', '--config', configPath], { stream: true }));
|
|
389
439
|
steps.push({ id: 'restart', changed: true });
|
|
390
440
|
}
|
|
391
441
|
|
|
392
|
-
const service = await runServicePhase(args, effects, dir, target.port);
|
|
442
|
+
const service = migratedService ?? await runServicePhase(args, effects, dir, target.port);
|
|
393
443
|
if (service.unsupported) serviceUnsupported = service.unsupported;
|
|
394
444
|
if (service.refused) {
|
|
395
445
|
// A REFUSAL IS A FAILURE TO REACH THE STATE, not a special case. An unknown
|
|
@@ -419,7 +469,7 @@ export async function runDaemonPhase(args, effects, exactSuite = null) {
|
|
|
419
469
|
effects.out(recovery.recovered
|
|
420
470
|
? ok('your daemon is running again — nothing was committed, and the service is unchanged')
|
|
421
471
|
: warn('and the daemon did NOT come back up — start it yourself before anything else: '
|
|
422
|
-
+ `ours
|
|
472
|
+
+ `ours-daemon start --config ${configPath}`));
|
|
423
473
|
}
|
|
424
474
|
throw error;
|
|
425
475
|
}
|
|
@@ -442,7 +492,7 @@ export async function runDaemonPhase(args, effects, exactSuite = null) {
|
|
|
442
492
|
async function recoverDaemon(args, effects, dir, configPath, port) {
|
|
443
493
|
if (args.dryRun) return null;
|
|
444
494
|
try {
|
|
445
|
-
await effects.run('ours', [
|
|
495
|
+
await effects.run('ours-daemon', [ 'start', '--config', configPath]);
|
|
446
496
|
return { recovered: true };
|
|
447
497
|
} catch (recoveryError) {
|
|
448
498
|
return { recovered: false, reason: reason(recoveryError) };
|
|
@@ -793,7 +843,7 @@ export async function runIdentityPhase(args, effects, { target, mcpReady }) {
|
|
|
793
843
|
}
|
|
794
844
|
if (/not running|not reachable|ECONNREFUSED|connect/i.test(text)) {
|
|
795
845
|
effects.out(warn("The daemon isn't reachable yet — couldn't create your human identity."));
|
|
796
|
-
effects.out(info(`Fix: run 'ours
|
|
846
|
+
effects.out(info(`Fix: run 'ours-daemon start --config ${env.OURS_CONFIG}', then 'ours identity create-root --config ${env.OURS_CONFIG} --name "${name}"'.`));
|
|
797
847
|
return { key: 'identity', label: 'Human identity', state: 'failed', note: 'daemon not reachable' };
|
|
798
848
|
}
|
|
799
849
|
effects.out(warn(`Couldn't create your human identity: ${text.split('\n')[0]}`));
|
|
@@ -816,6 +866,9 @@ export async function runIdentityPhase(args, effects, { target, mcpReady }) {
|
|
|
816
866
|
export async function runHarnessPhase(args, effects, { target, isDefaultStateDir, exactSuite = null }) {
|
|
817
867
|
effects.out(heading('Harness plugins'));
|
|
818
868
|
const detected = (await effects.detectHarnesses()).filter(h => !args.clientIntegrations || args.clientIntegrations.includes(h.name));
|
|
869
|
+
for (const name of args.clientIntegrations ?? []) {
|
|
870
|
+
if (name !== 'fleet' && !detected.some(h => h.name === name)) detected.push({ name, status: 'absent' });
|
|
871
|
+
}
|
|
819
872
|
for (const h of detected) {
|
|
820
873
|
if (h.status === 'ok') effects.out(ok(`'${h.command ?? h.name}' → ${h.detail ?? 'real program'} (its plugin can be installed)`));
|
|
821
874
|
else if (h.status === 'alias') effects.out(warn(`'${h.command ?? h.name}' → ${h.detail} (I won't call it — manual steps below)`));
|
|
@@ -825,7 +878,7 @@ export async function runHarnessPhase(args, effects, { target, isDefaultStateDir
|
|
|
825
878
|
if (detected.every((h) => h.status === 'absent')) {
|
|
826
879
|
effects.out(info('No Claude Code, Codex or Hermes found — install one and re-run to wire it up.'));
|
|
827
880
|
effects.out(info('Your daemon is unaffected; nothing else in this run depends on a harness.'));
|
|
828
|
-
return [];
|
|
881
|
+
return args.clientIntegrations ? detected.map(h => ({ key: h.name, state: 'skipped', note: 'not installed' })) : [];
|
|
829
882
|
}
|
|
830
883
|
|
|
831
884
|
const plans = planHarnessPlugins({
|
|
@@ -850,7 +903,7 @@ export async function runHarnessPhase(args, effects, { target, isDefaultStateDir
|
|
|
850
903
|
if (plan.action === 'manual' && exactSuite?.localPackages?.[plan.name]) {
|
|
851
904
|
const root = await effects.prepareClientMarketplace(plan.name, exactSuite.localPackages[plan.name]);
|
|
852
905
|
effects.out(warn(`${plan.label} requires manual registration of exact local marketplace ${root}; ${target.managed ? 'the saved client default is retained' : `keep OURS_CONFIG=${target.configPath}`}.`));
|
|
853
|
-
rows.push({ ...row, state: 'failed', note:
|
|
906
|
+
rows.push({ ...row, state: 'failed', note: plan.reason, manual: true });
|
|
854
907
|
continue;
|
|
855
908
|
}
|
|
856
909
|
if (plan.action === 'manual') {
|
|
@@ -872,7 +925,7 @@ export async function runHarnessPhase(args, effects, { target, isDefaultStateDir
|
|
|
872
925
|
effects.out(warn(`${plan.label} — ${plan.reason}; install it yourself with:`));
|
|
873
926
|
for (const step of manual) effects.out(info(` ${step}`));
|
|
874
927
|
if (plan.envLine) effects.out(info(`Before later native launches, set: ${plan.envLine}`));
|
|
875
|
-
rows.push({ ...row, state: 'skipped', note: plan.reason });
|
|
928
|
+
rows.push({ ...row, state: 'skipped', note: plan.reason, manual: true });
|
|
876
929
|
continue;
|
|
877
930
|
}
|
|
878
931
|
|
|
@@ -883,13 +936,16 @@ export async function runHarnessPhase(args, effects, { target, isDefaultStateDir
|
|
|
883
936
|
const steps = plan.name === 'codex'
|
|
884
937
|
? [['codex', 'plugin', 'marketplace', 'add', registration], ['codex', 'plugin', 'add', 'ours@ours-codex-marketplace']]
|
|
885
938
|
: [['claude', 'plugin', 'marketplace', 'add', registration], ['claude', 'plugin', await effects.hasClaudePlugin() ? 'update' : 'install', 'ours@ours.network']];
|
|
886
|
-
let
|
|
939
|
+
let failure = null;
|
|
887
940
|
for (const step of steps) {
|
|
888
|
-
const outcome = await attempt(effects, false, step.join(' '), () => effects.run(step[0], step.slice(1), { env: profileEnv(target) }));
|
|
889
|
-
if (!outcome.ok) {
|
|
941
|
+
const outcome = await attempt(effects, false, step.join(' '), () => effects.run(step[0], step.slice(1), { env: profileEnv(target) }), clientDiagnostic);
|
|
942
|
+
if (!outcome.ok) {
|
|
943
|
+
failure = { failedCommand: step, failedStep: step[2] === 'marketplace' ? `Register ${plan.label} marketplace` : `Install ${plan.label} plugin`, detail: clientDiagnostic(outcome.error) };
|
|
944
|
+
break;
|
|
945
|
+
}
|
|
890
946
|
}
|
|
891
947
|
effects.out(info(target.managed ? `Native ${plan.name} launches use the saved client default.` : `Native ${plan.name} launches must retain OURS_CONFIG=${target.configPath}.`));
|
|
892
|
-
rows.push({ ...row, state:
|
|
948
|
+
rows.push({ ...row, state: failure ? 'failed' : 'installed', ...(failure ?? {}) });
|
|
893
949
|
continue;
|
|
894
950
|
}
|
|
895
951
|
|
|
@@ -1250,7 +1306,9 @@ export async function runInstall(argv, effects) {
|
|
|
1250
1306
|
|
|
1251
1307
|
export async function runServerCommand(args, effects) {
|
|
1252
1308
|
if (args.operation === 'status') return executeServerCommand(args, effects);
|
|
1253
|
-
return effects.withInstallationLock(args.stateDir, () =>
|
|
1309
|
+
return effects.withInstallationLock(args.stateDir, () => args.migrateFrom
|
|
1310
|
+
? executeLegacyMigration(args, effects, executeServerCommand)
|
|
1311
|
+
: executeServerCommand(args, effects));
|
|
1254
1312
|
}
|
|
1255
1313
|
|
|
1256
1314
|
async function executeServerCommand(args, effects) {
|
|
@@ -1259,15 +1317,22 @@ async function executeServerCommand(args, effects) {
|
|
|
1259
1317
|
const existing = record !== null;
|
|
1260
1318
|
if (existing) {
|
|
1261
1319
|
record = validateInstallation(record, args.stateDir);
|
|
1320
|
+
if (args.containerEngine && args.containerEngine !== (record.containerEngine ?? 'docker')) throw new Error('Conflicting container engine; explicit migration is required');
|
|
1262
1321
|
if (args.mode && args.mode !== record.mode) throw new Error('Conflicting runtime mode; retained installation was not changed');
|
|
1263
1322
|
if (args.operation !== 'update' && args.sources && (record.sourcePolicyHash
|
|
1264
1323
|
? effects.sourcePolicyHash(args.sources) !== record.sourcePolicyHash
|
|
1265
1324
|
: effects.readText(args.sources) !== effects.readText(record.sourcesPath))) throw new Error('Conflicting source selection; use explicit server update');
|
|
1266
1325
|
} else {
|
|
1267
1326
|
if (args.operation !== 'install' || !args.mode) throw new Error('First server install requires --mode');
|
|
1268
|
-
record = effects.newInstallation(args.stateDir, args.mode);
|
|
1327
|
+
record = effects.newInstallation(args.stateDir, args.mode, args);
|
|
1269
1328
|
for (const key of ['port', 'coworkPort', 'messengerPort']) if (args[key] !== undefined) record[key] = args[key];
|
|
1270
1329
|
}
|
|
1330
|
+
if (effects.readJson(join(record.root, 'gateway-transition.json')) && args.operation !== 'gateway-enable' && args.operation !== 'status') throw new Error('Interrupted gateway migration; run server gateway-enable before other changes');
|
|
1331
|
+
if (args.serverUrl && args.operation === 'install') {
|
|
1332
|
+
if (!record.gateway) throw new Error('Use server gateway-enable to migrate an existing Docker installation');
|
|
1333
|
+
if (existing && record.gateway.serverUrl !== args.serverUrl) throw new Error('Conflicting gateway server URL');
|
|
1334
|
+
record.gateway = { ...record.gateway, serverUrl: args.serverUrl };
|
|
1335
|
+
}
|
|
1271
1336
|
if (record.layoutConversion && !['install', 'start', 'stop', 'status'].includes(args.operation)) {
|
|
1272
1337
|
throw new Error('Layout conversion is incomplete; resume with server install or server start before changing state or authority');
|
|
1273
1338
|
}
|
|
@@ -1334,7 +1399,10 @@ async function executeServerCommand(args, effects) {
|
|
|
1334
1399
|
} else {
|
|
1335
1400
|
await installStage('Service startup', 'Start the daemon and selected services, then check readiness.', () => effects.serverLifecycle(record, 'start'));
|
|
1336
1401
|
}
|
|
1402
|
+
if (record.gateway) await effects.verifyGateway(record);
|
|
1337
1403
|
if (showInstallProgress) effects.out(progress(installStageCount, installStageCount, 'Installation complete', 'The selected services are ready.'));
|
|
1404
|
+
} else if (args.operation === 'gateway-enable') {
|
|
1405
|
+
await enableGateway(record, args, effects);
|
|
1338
1406
|
} else if (['backup', 'restore', 'reset'].includes(args.operation)) {
|
|
1339
1407
|
await effects.serverMaintenance(record, args);
|
|
1340
1408
|
} else if (['update', 'rebuild'].includes(args.operation)) {
|
|
@@ -1366,6 +1434,7 @@ async function executeServerCommand(args, effects) {
|
|
|
1366
1434
|
layoutConversion: record.schema === 1 ? 'preparation-pending' : 'activation-pending',
|
|
1367
1435
|
} : {}),
|
|
1368
1436
|
}));
|
|
1437
|
+
if (args.operation === 'status') return EXIT_OK;
|
|
1369
1438
|
}
|
|
1370
1439
|
effects.out(ok(`Server ${args.operation} completed for ${record.root}`));
|
|
1371
1440
|
return EXIT_OK;
|
|
@@ -1381,22 +1450,21 @@ export async function runClientCommand(command, effects) {
|
|
|
1381
1450
|
configPath = managedPath;
|
|
1382
1451
|
}
|
|
1383
1452
|
let profile;
|
|
1384
|
-
if (configPath) profile =
|
|
1453
|
+
if (configPath) profile = validateGatewayClientProfile(effects.readProfile(configPath));
|
|
1385
1454
|
else if (!command.preset && effects.interactive) {
|
|
1386
|
-
const endpoint = await effects.askLine('Server HTTP endpoint: ', 'http://127.0.0.1:3050');
|
|
1455
|
+
const endpoint = await effects.askLine('Server HTTP or HTTPS endpoint: ', 'http://127.0.0.1:3050');
|
|
1387
1456
|
const credentialPath = await effects.askLine('Private issued-token file: ', '');
|
|
1388
1457
|
if (!credentialPath) throw new InstallUsageError('Client setup requires an issued-token file');
|
|
1389
1458
|
profile = await effects.discoverClientProfile(endpoint, credentialPath);
|
|
1390
1459
|
}
|
|
1391
1460
|
if (!profile) throw new InstallUsageError('client install requires a complete network profile; supply --config or use the interactive client setup');
|
|
1392
|
-
if (saved &&
|
|
1461
|
+
if (saved && saved.expectedInstanceId !== profile.expectedInstanceId)
|
|
1393
1462
|
throw new InstallUsageError('Managed client already selects another server; existing default was not changed');
|
|
1394
1463
|
for (const name of ['OURS_API_TOKEN', 'OURS_PORT', 'OURS_STATE_DIR', 'OURS_DAEMON_ID']) {
|
|
1395
1464
|
if (effects.env[name]?.trim()) throw new InstallUsageError(`${name} conflicts with client profile selection`);
|
|
1396
1465
|
}
|
|
1397
1466
|
effects.out(info(`Selected server ${profile.endpoint} (instance ${profile.expectedInstanceId}).`));
|
|
1398
1467
|
await effects.verifyHostProfile(configPath || profile);
|
|
1399
|
-
await effects.verifyPackagedMcp(configPath || profile);
|
|
1400
1468
|
const settings = saved?.installer ?? (configPath ? effects.readJson(configPath)?.installer : undefined);
|
|
1401
1469
|
const settingsBase = saved ? dirname(managedPath) : configPath ? dirname(configPath) : process.cwd();
|
|
1402
1470
|
let integrations = command.integrations ?? settings?.integrations;
|
|
@@ -1404,13 +1472,13 @@ export async function runClientCommand(command, effects) {
|
|
|
1404
1472
|
integrations = [];
|
|
1405
1473
|
for (const name of ['codex', 'claude-code', 'fleet']) if (await effects.ask(`Install ${name}?`, name !== 'fleet')) integrations.push(name);
|
|
1406
1474
|
}
|
|
1407
|
-
if (!Array.isArray(integrations) ||
|
|
1475
|
+
if (!Array.isArray(integrations) || integrations.some(name => !['codex', 'claude-code', 'fleet'].includes(name)) || new Set(integrations).size !== integrations.length) throw new InstallUsageError('installer.integrations must be an array of codex, claude-code and/or fleet; use an empty array for CLI only');
|
|
1408
1476
|
let fleetSettingsPath = command.preset ? command.fleetSettingsPath : settings?.fleetSettingsPath;
|
|
1409
1477
|
if (command.nonInteractive && integrations.includes('fleet') && !fleetSettingsPath) throw new InstallUsageError('Fleet in CLI mode requires --fleet-settings; no interactive wizard will be opened');
|
|
1410
1478
|
if (fleetSettingsPath !== undefined && (typeof fleetSettingsPath !== 'string' || !fleetSettingsPath))
|
|
1411
1479
|
throw new InstallUsageError('installer.fleetSettingsPath must be a non-empty path when supplied');
|
|
1412
1480
|
if (fleetSettingsPath) fleetSettingsPath = resolve(settingsBase, fleetSettingsPath);
|
|
1413
|
-
const selectedClients =
|
|
1481
|
+
const selectedClients = clientPackageNames(integrations);
|
|
1414
1482
|
let sourcesPath = settings?.sourcesPath;
|
|
1415
1483
|
let resolvedSources;
|
|
1416
1484
|
if (command.sourcePolicy) {
|
|
@@ -1423,30 +1491,38 @@ export async function runClientCommand(command, effects) {
|
|
|
1423
1491
|
resolvedSources = await effects.resolveSourcePolicy(policy, 'client', selectedClients);
|
|
1424
1492
|
}
|
|
1425
1493
|
effects.out(progress(0, 4, 'Client configuration', 'Prepare the selected integrations and private connection profile.'));
|
|
1494
|
+
if (profile.serverUrl && integrations.includes('fleet')) await effects.qualifyGatewayClient({ profile, sourcesPath, sources: resolvedSources, integrations, refresh: !!command.preset });
|
|
1426
1495
|
const imported = effects.importClientProfile({ profile, sourcesPath, sources: resolvedSources, integrations, fleetSettingsPath, refresh: !!command.preset });
|
|
1496
|
+
let phase = 'Validate saved server connection';
|
|
1427
1497
|
try {
|
|
1428
1498
|
await effects.verifyHostProfile(imported.configPath);
|
|
1429
1499
|
effects.out(progress(1, 4, 'Client packages', 'Acquire and verify the selected client package versions.'));
|
|
1500
|
+
phase = 'Acquire client packages';
|
|
1430
1501
|
const exactSuite = await effects.acquireClientPackages(imported.configPath, imported.settings.sourcesPath, integrations, { refresh: !!command.preset });
|
|
1431
1502
|
const args = { assumeYes: true, dryRun: false, channel: 'latest', clientIntegrations: integrations,
|
|
1432
1503
|
acquiredFleet: exactSuite.fleetBin, fleetSettingsPath: imported.settings.fleetSettingsPath };
|
|
1433
1504
|
const target = { mode: 'host-profile', managed: true, configPath: imported.configPath, profile: imported.profile, endpoint: imported.profile.endpoint };
|
|
1434
1505
|
effects.out(progress(2, 4, 'Client integrations', 'Register the selected agent integrations.'));
|
|
1506
|
+
phase = 'Register client integrations';
|
|
1435
1507
|
const summary = await runHarnessPhase(args, effects, { target, isDefaultStateDir: false, exactSuite });
|
|
1436
1508
|
if (integrations.includes('fleet')) {
|
|
1437
1509
|
effects.out(progress(3, 4, 'Fleet configuration', 'Apply prepared settings or open the selected Fleet wizard.'));
|
|
1510
|
+
phase = 'Configure Fleet';
|
|
1438
1511
|
summary.push(await runFleetPhase(args, effects, { target, isDefaultStateDir: false }));
|
|
1439
1512
|
}
|
|
1440
1513
|
const incomplete = integrations.filter(name => !summary.some(row => row.key === name && row.state === 'installed'));
|
|
1441
1514
|
if (effects.env.OURS_CONFIG && resolve(effects.env.OURS_CONFIG) !== imported.configPath)
|
|
1442
1515
|
effects.out(warn('This shell has an explicit OURS_CONFIG override. Unset it for new clients to use the saved default; installer did not edit your shell.'));
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1516
|
+
if (incomplete.length) {
|
|
1517
|
+
effects.out(warn(`Client setup incomplete (${incomplete.join(', ')}). The selected client integrations need attention:`));
|
|
1518
|
+
for (const name of incomplete) explainClientFailure(effects, name, summary.find(row => row.key === name));
|
|
1519
|
+
clientRetry(effects, imported, integrations);
|
|
1520
|
+
} else effects.out(ok(`Client setup complete. New clients discover ${imported.configPath}; no OURS_CONFIG export is required.`));
|
|
1446
1521
|
if (!incomplete.length) effects.out(progress(4, 4, 'Client setup complete', 'All selected integrations are configured.'));
|
|
1447
1522
|
return incomplete.length ? EXIT_REFUSED : EXIT_OK;
|
|
1448
1523
|
} catch (error) {
|
|
1449
|
-
effects.out(warn(`Client setup incomplete: ${
|
|
1524
|
+
effects.out(warn(`Client setup incomplete: ${phase} failed — ${clientDiagnostic(error)}. Fix this error before retrying.`));
|
|
1525
|
+
clientRetry(effects, imported, integrations);
|
|
1450
1526
|
return EXIT_REFUSED;
|
|
1451
1527
|
}
|
|
1452
1528
|
}
|