@aikyroon/installer-core 1.1.13 → 1.1.15
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/dist/api.d.ts.map +1 -1
- package/dist/api.js +5 -0
- package/dist/api.js.map +1 -1
- package/dist/cli.js +21 -5
- package/dist/cli.js.map +1 -1
- package/dist/doctor.d.ts +25 -3
- package/dist/doctor.d.ts.map +1 -1
- package/dist/doctor.js +448 -61
- package/dist/doctor.js.map +1 -1
- package/dist/doctorChecks.d.ts +37 -0
- package/dist/doctorChecks.d.ts.map +1 -0
- package/dist/doctorChecks.js +459 -0
- package/dist/doctorChecks.js.map +1 -0
- package/dist/errors.d.ts +2 -0
- package/dist/errors.d.ts.map +1 -1
- package/dist/errors.js +2 -0
- package/dist/errors.js.map +1 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -1
- package/dist/index.js.map +1 -1
- package/dist/install.d.ts +6 -0
- package/dist/install.d.ts.map +1 -1
- package/dist/install.js +9 -0
- package/dist/install.js.map +1 -1
- package/dist/machine.d.ts +14 -0
- package/dist/machine.d.ts.map +1 -0
- package/dist/machine.js +275 -0
- package/dist/machine.js.map +1 -0
- package/dist/prereqs.d.ts +2 -0
- package/dist/prereqs.d.ts.map +1 -1
- package/dist/prereqs.js +1 -1
- package/dist/prereqs.js.map +1 -1
- package/dist/requirements.d.ts +22 -0
- package/dist/requirements.d.ts.map +1 -0
- package/dist/requirements.js +44 -0
- package/dist/requirements.js.map +1 -0
- package/dist/shortcuts.d.ts +26 -5
- package/dist/shortcuts.d.ts.map +1 -1
- package/dist/shortcuts.js +151 -7
- package/dist/shortcuts.js.map +1 -1
- package/dist/types.d.ts +102 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/uninstall.js +8 -0
- package/dist/uninstall.js.map +1 -1
- package/package.json +1 -1
package/dist/doctor.js
CHANGED
|
@@ -3,7 +3,10 @@ import { execa } from 'execa';
|
|
|
3
3
|
import fs from 'fs-extra';
|
|
4
4
|
import { getLatestVersionInfo } from './api.js';
|
|
5
5
|
import { DEFAULT_CHANNEL, defaultApiUrl, defaultInstallRoot, normalizeApiUrl, stripTrailingSep, } from './config.js';
|
|
6
|
+
import { checkArchitecture, checkDisk, checkHardware, checkLinuxUi, checkMacAppDiagnostics, checkNode, checkOsMinimum, checkWebView2, checkWritable, preflightChecks, } from './doctorChecks.js';
|
|
6
7
|
import { describeCache } from './downloadsCache.js';
|
|
8
|
+
import { EXIT, InstallError } from './errors.js';
|
|
9
|
+
import { collectMachineProfile } from './machine.js';
|
|
7
10
|
import { findBundleProblems, hasValidMacSignature, launchAgentPath, LEGACY_WORKER_AGENT_LABEL, WORKER_AGENT_LABEL, } from './macos.js';
|
|
8
11
|
import { readInstalledVersion } from './manifest.js';
|
|
9
12
|
import { detectPlatform, resolveComponent } from './platform.js';
|
|
@@ -11,14 +14,71 @@ import { hasClaudeCli, hasWebkitGtk } from './prereqs.js';
|
|
|
11
14
|
import { anyProcessHoldingDir } from './processes.js';
|
|
12
15
|
import { compareSemver } from './selfUpdate.js';
|
|
13
16
|
import * as log from './logger.js';
|
|
14
|
-
/**
|
|
17
|
+
/**
|
|
18
|
+
* Diagnóstico + pré-voo: identifica a máquina, checa a instalação existente e
|
|
19
|
+
* responde se ela está apta a receber/rodar a versão publicada de cada
|
|
20
|
+
* componente — com o MOTIVO e a correção quando não está.
|
|
21
|
+
*
|
|
22
|
+
* Nunca lança por causa de uma checagem: devolve o relatório. Quem decide o
|
|
23
|
+
* código de saída é o chamador (`verdict === 'blocked'` → `EXIT.NOT_READY`).
|
|
24
|
+
*/
|
|
15
25
|
export async function doctor(options) {
|
|
16
26
|
const platform = detectPlatform();
|
|
17
27
|
const apiUrl = normalizeApiUrl(options.apiUrl ?? defaultApiUrl());
|
|
18
28
|
const installRoot = stripTrailingSep(options.installRoot ?? defaultInstallRoot(platform));
|
|
29
|
+
// Modo JSON: o stdout precisa conter APENAS o JSON. O logger escreve no
|
|
30
|
+
// console por `console.*`; silenciamos durante a coleta (o arquivo de log
|
|
31
|
+
// continua recebendo tudo) e restauramos antes de imprimir o relatório.
|
|
32
|
+
const restoreConsole = options.json ? muteConsole() : null;
|
|
33
|
+
let report;
|
|
34
|
+
try {
|
|
35
|
+
report = await collect(options, platform, apiUrl, installRoot);
|
|
36
|
+
}
|
|
37
|
+
finally {
|
|
38
|
+
restoreConsole?.();
|
|
39
|
+
}
|
|
40
|
+
if (options.out) {
|
|
41
|
+
const target = path.resolve(options.out);
|
|
42
|
+
await fs.ensureDir(path.dirname(target));
|
|
43
|
+
await fs.writeJson(target, report, { spaces: 2 });
|
|
44
|
+
if (!options.json)
|
|
45
|
+
log.info(`Relatório JSON gravado em: ${target}`);
|
|
46
|
+
}
|
|
47
|
+
if (options.json)
|
|
48
|
+
process.stdout.write(`${JSON.stringify(report, null, 2)}\n`);
|
|
49
|
+
return report;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Pré-voo de `install`/`update`/`repair`: só as checagens locais que impedem a
|
|
53
|
+
* instalação ou a execução. Lança `InstallError` (`EXIT.NOT_READY`) com os
|
|
54
|
+
* motivos quando há bloqueio — ANTES de qualquer download ou parada de processo.
|
|
55
|
+
*/
|
|
56
|
+
export function runPreflight(platform, components, installRoot) {
|
|
57
|
+
const machine = collectMachineProfile(platform, installRoot);
|
|
58
|
+
const results = preflightChecks(platform, machine, components, installRoot);
|
|
59
|
+
for (const result of results) {
|
|
60
|
+
if (result.severity === 'warn')
|
|
61
|
+
log.warn(result.message + (result.fix ? ` ${result.fix}` : ''));
|
|
62
|
+
}
|
|
63
|
+
const blocks = results.filter((r) => r.severity === 'block');
|
|
64
|
+
if (blocks.length === 0)
|
|
65
|
+
return;
|
|
66
|
+
throw new InstallError('Esta máquina não está apta para a instalação:\n' +
|
|
67
|
+
blocks.map((b) => ` - ${b.message}${b.fix ? `\n Como resolver: ${b.fix}` : ''}`).join('\n'), {
|
|
68
|
+
exitCode: EXIT.NOT_READY,
|
|
69
|
+
step: 'Pré-voo',
|
|
70
|
+
hint: "Rode 'doctor' para o diagnóstico completo. Para instalar mesmo assim (por sua conta e risco), " +
|
|
71
|
+
'repita o comando com --skip-preflight.',
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
// ---------------------------------------------------------------------------
|
|
75
|
+
// Coleta
|
|
76
|
+
// ---------------------------------------------------------------------------
|
|
77
|
+
async function collect(options, platform, apiUrl, installRoot) {
|
|
19
78
|
// O `doctor` é o comando que o cliente roda para mandar evidência ao suporte —
|
|
20
79
|
// o relatório precisa existir em arquivo, não só no console.
|
|
21
80
|
log.openFileLog(installRoot, 'doctor');
|
|
81
|
+
const machine = collectMachineProfile(platform, installRoot);
|
|
22
82
|
log.banner('Kyroon Doctor', [
|
|
23
83
|
`Platform : ${platform.slug}${platform.osVersion ? ` (${platform.osVersion})` : ''}` +
|
|
24
84
|
`${platform.translated ? ' — Node x64 sob Rosetta (binários arm64 selecionados)' : ''}`,
|
|
@@ -26,22 +86,67 @@ export async function doctor(options) {
|
|
|
26
86
|
`InstallRoot : ${installRoot}`,
|
|
27
87
|
`Log : ${log.fileLogPath() ?? '(console apenas)'}`,
|
|
28
88
|
]);
|
|
89
|
+
const checks = [];
|
|
90
|
+
/** Registra a checagem e a imprime conforme a severidade. */
|
|
91
|
+
const add = (result) => {
|
|
92
|
+
checks.push(result);
|
|
93
|
+
const text = result.fix && result.severity !== 'pass' ? `${result.message} → ${result.fix}` : result.message;
|
|
94
|
+
if (result.severity === 'pass')
|
|
95
|
+
log.success(text);
|
|
96
|
+
else if (result.severity === 'warn')
|
|
97
|
+
log.warn(text);
|
|
98
|
+
else
|
|
99
|
+
log.error(text);
|
|
100
|
+
};
|
|
101
|
+
// ── Máquina ───────────────────────────────────────────────────────────────
|
|
102
|
+
log.step('Máquina');
|
|
103
|
+
log.info(`SO : ${machine.osName} ${machine.osVersion}`.trimEnd() + ` (kernel ${machine.kernel})`);
|
|
104
|
+
if (machine.libc)
|
|
105
|
+
log.info(`libc : ${machine.libc.kind} ${machine.libc.version}`.trimEnd());
|
|
106
|
+
log.info(`Arquit. : hardware ${machine.hardwareArch} · Node ${machine.processArch} → pacotes ${machine.platformSlug}`);
|
|
107
|
+
log.info(`CPU : ${machine.cpuModel || '(desconhecida)'} · ${machine.cpuCount} núcleo(s)`);
|
|
108
|
+
log.info(`Memória : ${log.formatBytes(machine.memoryTotalBytes)}`);
|
|
109
|
+
if (machine.model)
|
|
110
|
+
log.info(`Modelo : ${machine.model}`);
|
|
111
|
+
if (machine.cpuFeatures) {
|
|
112
|
+
log.info(`CPU ext. : AVX ${machine.cpuFeatures.avx ? 'sim' : 'NÃO'} · AVX2 ${machine.cpuFeatures.avx2 ? 'sim' : 'NÃO'}`);
|
|
113
|
+
}
|
|
114
|
+
for (const gpu of machine.gpus ?? [])
|
|
115
|
+
log.info(`Vídeo : ${gpu.name} · Metal ${gpu.metal ? 'sim' : 'NÃO'}`);
|
|
116
|
+
if (machine.proxy)
|
|
117
|
+
log.info(`Proxy : ${machine.proxy}`);
|
|
118
|
+
for (const result of checkHardware(machine, options.components))
|
|
119
|
+
add(result);
|
|
120
|
+
for (const result of checkArchitecture(platform, machine))
|
|
121
|
+
add(result);
|
|
122
|
+
add(checkNode(machine));
|
|
123
|
+
add(checkWritable(installRoot));
|
|
124
|
+
// ── CLI ───────────────────────────────────────────────────────────────────
|
|
29
125
|
// A PRIMEIRA pergunta do suporte hoje é "qual versão da CLI?": uma CLI antiga
|
|
30
126
|
// (<= installer-core 1.1.3) apagava a pasta do componente antes de extrair e
|
|
31
127
|
// deixava a instalação mutilada. O relatório tem de responder isso sozinho.
|
|
32
128
|
log.step('CLI (pacote npm)');
|
|
129
|
+
let latestCli = null;
|
|
33
130
|
if (options.cliVersion && options.npmPackage) {
|
|
34
131
|
log.info(`${options.npmPackage} v${options.cliVersion}`);
|
|
35
|
-
|
|
36
|
-
if (!
|
|
37
|
-
|
|
132
|
+
latestCli = await latestNpmVersion(options.npmPackage);
|
|
133
|
+
if (!latestCli) {
|
|
134
|
+
add({
|
|
135
|
+
id: 'cli.version',
|
|
136
|
+
severity: 'warn',
|
|
137
|
+
message: 'Não foi possível consultar a versão publicada no npm (sem rede/registry?).',
|
|
138
|
+
});
|
|
38
139
|
}
|
|
39
|
-
else if (compareSemver(
|
|
40
|
-
|
|
41
|
-
|
|
140
|
+
else if (compareSemver(latestCli, options.cliVersion) > 0) {
|
|
141
|
+
add({
|
|
142
|
+
id: 'cli.version',
|
|
143
|
+
severity: 'warn',
|
|
144
|
+
message: `CLI DESATUALIZADA: v${options.cliVersion} instalada, v${latestCli} publicada.`,
|
|
145
|
+
fix: `Rode: npm install -g ${options.npmPackage}@latest`,
|
|
146
|
+
});
|
|
42
147
|
}
|
|
43
148
|
else {
|
|
44
|
-
|
|
149
|
+
add({ id: 'cli.version', severity: 'pass', message: `CLI na versão mais recente (v${latestCli}).` });
|
|
45
150
|
}
|
|
46
151
|
}
|
|
47
152
|
else {
|
|
@@ -53,43 +158,105 @@ export async function doctor(options) {
|
|
|
53
158
|
if (!(await fs.pathExists(dir)))
|
|
54
159
|
continue;
|
|
55
160
|
if (await anyProcessHoldingDir(platform, dir)) {
|
|
56
|
-
|
|
161
|
+
add({
|
|
162
|
+
id: 'process.holding',
|
|
163
|
+
component: name,
|
|
164
|
+
severity: 'warn',
|
|
165
|
+
message: `${name}: há processo em execução dentro de ${dir}.`,
|
|
166
|
+
fix: 'Feche antes de atualizar (o instalador também tenta encerrar).',
|
|
167
|
+
});
|
|
57
168
|
}
|
|
58
169
|
else {
|
|
59
|
-
|
|
170
|
+
add({ id: 'process.holding', component: name, severity: 'pass', message: `${name}: nenhum processo segurando ${dir}.` });
|
|
60
171
|
}
|
|
61
172
|
}
|
|
62
|
-
|
|
173
|
+
// ── Version API + requisitos do pacote publicado ──────────────────────────
|
|
174
|
+
log.step('Version API e requisitos da versão publicada');
|
|
175
|
+
const latestByComponent = new Map();
|
|
176
|
+
const unreachable = new Set();
|
|
177
|
+
const downloadHosts = new Set();
|
|
178
|
+
let packageBytes = 0;
|
|
179
|
+
let allSizesKnown = true;
|
|
63
180
|
for (const name of options.components) {
|
|
64
181
|
const spec = resolveComponent(name, platform);
|
|
65
182
|
if (!spec) {
|
|
66
|
-
|
|
183
|
+
add({
|
|
184
|
+
id: 'component.distribution',
|
|
185
|
+
component: name,
|
|
186
|
+
severity: 'block',
|
|
187
|
+
message: `${name}: não é distribuído para ${platform.slug}.`,
|
|
188
|
+
});
|
|
67
189
|
continue;
|
|
68
190
|
}
|
|
191
|
+
let apiMinOs;
|
|
69
192
|
try {
|
|
70
|
-
// Consulta no canal em que a máquina
|
|
71
|
-
// relatório precisa comparar contra o beta,
|
|
72
|
-
// (ou "em dia") olhando para a timeline errada.
|
|
73
|
-
const channel =
|
|
193
|
+
// Consulta no canal em que a máquina ESTÁ (ou no pedido por --channel):
|
|
194
|
+
// num componente em beta, o relatório precisa comparar contra o beta,
|
|
195
|
+
// senão diria "desatualizado" (ou "em dia") olhando para a timeline errada.
|
|
196
|
+
const channel = options.channel ??
|
|
197
|
+
(await readInstalledVersion(path.join(installRoot, name)))?.channel ??
|
|
198
|
+
DEFAULT_CHANNEL;
|
|
74
199
|
const info = await getLatestVersionInfo(apiUrl, spec.fileType, channel);
|
|
75
|
-
|
|
76
|
-
|
|
200
|
+
latestByComponent.set(name, info.versionBuild);
|
|
201
|
+
apiMinOs = info.minOsVersion;
|
|
202
|
+
if (info.sizeBytes)
|
|
203
|
+
packageBytes += info.sizeBytes;
|
|
204
|
+
else
|
|
205
|
+
allSizesKnown = false;
|
|
206
|
+
try {
|
|
207
|
+
downloadHosts.add(new URL(info.pathUrl).origin);
|
|
208
|
+
}
|
|
209
|
+
catch {
|
|
210
|
+
/* pathUrl relativo/inválido: sem host a testar */
|
|
211
|
+
}
|
|
212
|
+
add({
|
|
213
|
+
id: 'api.version',
|
|
214
|
+
component: name,
|
|
215
|
+
severity: 'pass',
|
|
216
|
+
message: `${spec.display}: latest v${info.versionBuild} (fileType=${spec.fileType}, canal=${info.channel})`,
|
|
217
|
+
});
|
|
77
218
|
if (info.channel !== channel) {
|
|
78
|
-
|
|
79
|
-
|
|
219
|
+
add({
|
|
220
|
+
id: 'api.channel',
|
|
221
|
+
component: name,
|
|
222
|
+
severity: 'warn',
|
|
223
|
+
message: `${spec.display}: canal '${channel}' pedido, mas não há release desse canal publicada — ` +
|
|
224
|
+
`a API respondeu com '${info.channel}'.`,
|
|
225
|
+
});
|
|
80
226
|
}
|
|
81
227
|
}
|
|
82
228
|
catch (err) {
|
|
83
229
|
const message = `${spec.display}: ${err instanceof Error ? err.message : String(err)}`;
|
|
84
230
|
if (options.optionalComponents?.includes(name)) {
|
|
85
|
-
|
|
231
|
+
// Opcional sem release: o install o pula, então ele não torna o veredito
|
|
232
|
+
// indeterminado nem entra na conta de disco.
|
|
233
|
+
add({
|
|
234
|
+
id: 'api.version',
|
|
235
|
+
component: name,
|
|
236
|
+
severity: 'warn',
|
|
237
|
+
message: `${message} — componente opcional: o install/update o pula até haver release publicada.`,
|
|
238
|
+
});
|
|
86
239
|
}
|
|
87
240
|
else {
|
|
88
|
-
|
|
241
|
+
unreachable.add(name);
|
|
242
|
+
allSizesKnown = false;
|
|
243
|
+
add({
|
|
244
|
+
id: 'api.version',
|
|
245
|
+
component: name,
|
|
246
|
+
severity: 'warn',
|
|
247
|
+
message,
|
|
248
|
+
fix: 'Sem a Version API não dá para instalar nem confirmar a aptidão — verifique rede/proxy/firewall.',
|
|
249
|
+
});
|
|
89
250
|
}
|
|
90
251
|
}
|
|
252
|
+
add(checkOsMinimum(name, machine, apiMinOs));
|
|
91
253
|
}
|
|
254
|
+
for (const origin of downloadHosts)
|
|
255
|
+
add(await checkDownloadHost(origin));
|
|
256
|
+
add(checkDisk(machine, installRoot, allSizesKnown ? packageBytes : undefined));
|
|
257
|
+
// ── Instalação existente ──────────────────────────────────────────────────
|
|
92
258
|
log.step('Installed components');
|
|
259
|
+
const installedByComponent = new Map();
|
|
93
260
|
let incomplete = 0;
|
|
94
261
|
for (const name of options.components) {
|
|
95
262
|
const dir = path.join(installRoot, name);
|
|
@@ -100,38 +267,81 @@ export async function doctor(options) {
|
|
|
100
267
|
const manifest = await readInstalledVersion(dir);
|
|
101
268
|
if (!manifest) {
|
|
102
269
|
incomplete += 1;
|
|
103
|
-
|
|
270
|
+
add({
|
|
271
|
+
id: 'install.manifest',
|
|
272
|
+
component: name,
|
|
273
|
+
severity: 'warn',
|
|
274
|
+
message: `${name}: pasta existe mas installed-version.json está ausente (${dir})`,
|
|
275
|
+
fix: "Execute 'repair'.",
|
|
276
|
+
});
|
|
104
277
|
}
|
|
105
278
|
else if (manifest.status === 'installing') {
|
|
106
279
|
// O manifesto marcado como 'installing' é a única pista de que uma troca
|
|
107
280
|
// de arquivos morreu no meio. Sem esse aviso, a máquina parece saudável.
|
|
108
281
|
incomplete += 1;
|
|
109
|
-
|
|
110
|
-
|
|
282
|
+
add({
|
|
283
|
+
id: 'install.manifest',
|
|
284
|
+
component: name,
|
|
285
|
+
severity: 'warn',
|
|
286
|
+
message: `${name}: INSTALAÇÃO INCOMPLETA — uma atualização para a v${manifest.versionBuild} foi ` +
|
|
287
|
+
`interrompida${manifest.previousVersionBuild ? ` (versão anterior: v${manifest.previousVersionBuild})` : ''}.`,
|
|
288
|
+
fix: "Execute 'repair'.",
|
|
289
|
+
});
|
|
111
290
|
}
|
|
112
291
|
else {
|
|
113
|
-
|
|
114
|
-
|
|
292
|
+
installedByComponent.set(name, manifest.versionBuild);
|
|
293
|
+
add({
|
|
294
|
+
id: 'install.manifest',
|
|
295
|
+
component: name,
|
|
296
|
+
severity: 'pass',
|
|
297
|
+
message: `${name}: installed v${manifest.versionBuild} [canal ${manifest.channel ?? DEFAULT_CHANNEL}] (${dir})`,
|
|
298
|
+
});
|
|
299
|
+
}
|
|
300
|
+
// Pacote de outra plataforma (ex.: osx-x64 migrado para um Mac arm64 pelo
|
|
301
|
+
// Assistente de Migração): roda emulado ou nem roda, e o Updater continua
|
|
302
|
+
// baixando o FileType errado.
|
|
303
|
+
if (manifest?.platformSlug && manifest.platformSlug !== platform.slug) {
|
|
304
|
+
add({
|
|
305
|
+
id: 'install.platform',
|
|
306
|
+
component: name,
|
|
307
|
+
severity: 'warn',
|
|
308
|
+
message: `${name}: o pacote instalado é ${manifest.platformSlug}, mas esta máquina é ${platform.slug}.`,
|
|
309
|
+
fix: "Execute 'repair' para instalar o pacote da plataforma correta.",
|
|
310
|
+
});
|
|
115
311
|
}
|
|
116
312
|
const binary = path.join(dir, manifest?.binaryName ?? '');
|
|
117
313
|
if (manifest?.binaryName && !(await fs.pathExists(binary))) {
|
|
118
314
|
incomplete += 1;
|
|
119
|
-
|
|
315
|
+
add({
|
|
316
|
+
id: 'install.integrity',
|
|
317
|
+
component: name,
|
|
318
|
+
severity: 'warn',
|
|
319
|
+
message: `${name}: executável ausente (${binary}) — os arquivos do componente estão incompletos.`,
|
|
320
|
+
fix: "Execute 'repair'.",
|
|
321
|
+
});
|
|
120
322
|
}
|
|
121
|
-
else if (manifest?.binaryName &&
|
|
122
|
-
platform.os === 'osx' &&
|
|
123
|
-
binary.endsWith('.app') &&
|
|
124
|
-
(await findBundleProblems(binary)).length > 0) {
|
|
323
|
+
else if (manifest?.binaryName && platform.os === 'osx' && binary.endsWith('.app')) {
|
|
125
324
|
// Link de framework ausente (extração parcial): o app morre ao carregar
|
|
126
325
|
// as bibliotecas mesmo com um selo que passe na verificação.
|
|
127
|
-
incomplete += 1;
|
|
128
326
|
const problems = await findBundleProblems(binary);
|
|
129
|
-
|
|
327
|
+
if (problems.length > 0) {
|
|
328
|
+
incomplete += 1;
|
|
329
|
+
add({
|
|
330
|
+
id: 'install.integrity',
|
|
331
|
+
component: name,
|
|
332
|
+
severity: 'warn',
|
|
333
|
+
message: `${name}: bundle incompleto em ${binary} — ${problems.slice(0, 3).join('; ')}`,
|
|
334
|
+
fix: "Execute 'repair'.",
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
else if (!(await hasValidMacSignature(binary))) {
|
|
338
|
+
incomplete += 1;
|
|
339
|
+
add(invalidSignature(name, binary));
|
|
340
|
+
}
|
|
130
341
|
}
|
|
131
342
|
else if (manifest?.binaryName && platform.os === 'osx' && !(await hasValidMacSignature(binary))) {
|
|
132
|
-
// No Apple Silicon, Mach-O sem assinatura = "Killed: 9" ao abrir.
|
|
133
343
|
incomplete += 1;
|
|
134
|
-
|
|
344
|
+
add(invalidSignature(name, binary));
|
|
135
345
|
}
|
|
136
346
|
}
|
|
137
347
|
if (incomplete > 0) {
|
|
@@ -139,6 +349,13 @@ export async function doctor(options) {
|
|
|
139
349
|
'instalação dos componentes afetados.');
|
|
140
350
|
}
|
|
141
351
|
if (platform.os === 'osx') {
|
|
352
|
+
log.step('Evidências do Kyroon App (logs e relatórios de falha)');
|
|
353
|
+
const appInstalled = await fs.pathExists(path.join(installRoot, 'app'));
|
|
354
|
+
const evidence = checkMacAppDiagnostics(appInstalled);
|
|
355
|
+
if (evidence.length === 0)
|
|
356
|
+
log.info('nenhuma (App não instalado e sem relatórios de falha).');
|
|
357
|
+
for (const result of evidence)
|
|
358
|
+
add(result);
|
|
142
359
|
log.step('LaunchAgent do Worker (início no login)');
|
|
143
360
|
if (await fs.pathExists(launchAgentPath(WORKER_AGENT_LABEL))) {
|
|
144
361
|
log.success(`${launchAgentPath(WORKER_AGENT_LABEL)} presente.`);
|
|
@@ -147,8 +364,13 @@ export async function doctor(options) {
|
|
|
147
364
|
log.info(`${WORKER_AGENT_LABEL} ausente (o Worker não sobe sozinho no login).`);
|
|
148
365
|
}
|
|
149
366
|
if (await fs.pathExists(launchAgentPath(LEGACY_WORKER_AGENT_LABEL))) {
|
|
150
|
-
|
|
151
|
-
|
|
367
|
+
add({
|
|
368
|
+
id: 'macos.launchagent',
|
|
369
|
+
component: 'worker',
|
|
370
|
+
severity: 'warn',
|
|
371
|
+
message: `LaunchAgent legado ${LEGACY_WORKER_AGENT_LABEL} presente — o Worker pode subir duas vezes.`,
|
|
372
|
+
fix: "Rode 'repair' para migrá-lo.",
|
|
373
|
+
});
|
|
152
374
|
}
|
|
153
375
|
}
|
|
154
376
|
log.step('Cache de downloads');
|
|
@@ -158,37 +380,189 @@ export async function doctor(options) {
|
|
|
158
380
|
else
|
|
159
381
|
for (const line of cache)
|
|
160
382
|
log.info(line);
|
|
161
|
-
|
|
383
|
+
// ── Dependências de sistema ───────────────────────────────────────────────
|
|
384
|
+
if (options.components.includes('worker')) {
|
|
385
|
+
log.step('Python launcher (Worker JSONL hooks)');
|
|
386
|
+
add(await checkPython(platform));
|
|
387
|
+
}
|
|
388
|
+
if (platform.os === 'linux') {
|
|
389
|
+
if (options.components.includes('app') || options.components.includes('terminal')) {
|
|
390
|
+
log.step('Linux: WebKitGTK, libsecret e sessão gráfica');
|
|
391
|
+
if (options.components.includes('app')) {
|
|
392
|
+
add((await hasWebkitGtk())
|
|
393
|
+
? {
|
|
394
|
+
id: 'linux.webkitgtk',
|
|
395
|
+
component: 'app',
|
|
396
|
+
severity: 'pass',
|
|
397
|
+
message: 'libwebkit2gtk-4.0.so.37 OK (soname que o kyroon_app linka).',
|
|
398
|
+
}
|
|
399
|
+
: {
|
|
400
|
+
id: 'linux.webkitgtk',
|
|
401
|
+
component: 'app',
|
|
402
|
+
severity: 'warn',
|
|
403
|
+
message: 'libwebkit2gtk-4.0.so.37 não resolve — o Kyroon App pode não abrir.',
|
|
404
|
+
fix: 'Rode `install`/`repair` (instala automaticamente: 4.0-37 em distros antigas, ' +
|
|
405
|
+
'4.1-0 + symlink de compat em distros novas como Ubuntu 24.04+).',
|
|
406
|
+
});
|
|
407
|
+
}
|
|
408
|
+
for (const result of await checkLinuxUi(options.components))
|
|
409
|
+
add(result);
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
if (platform.os === 'win' && options.components.includes('app')) {
|
|
413
|
+
log.step('Windows: WebView2 Runtime (WebView do Kyroon App)');
|
|
414
|
+
add(await checkWebView2());
|
|
415
|
+
}
|
|
416
|
+
if (options.components.includes('worker')) {
|
|
417
|
+
log.step('Claude Code CLI (execução de tasks pelo Worker)');
|
|
418
|
+
if (await hasClaudeCli()) {
|
|
419
|
+
const res = await execa('claude', ['--version'], { reject: false });
|
|
420
|
+
add({
|
|
421
|
+
id: 'worker.claude',
|
|
422
|
+
component: 'worker',
|
|
423
|
+
severity: 'pass',
|
|
424
|
+
message: `claude OK${res.exitCode === 0 ? `: ${(res.stdout || '').trim()}` : ''}`,
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
add({
|
|
429
|
+
id: 'worker.claude',
|
|
430
|
+
component: 'worker',
|
|
431
|
+
severity: 'warn',
|
|
432
|
+
message: 'claude não encontrado — o Worker não consegue executar tasks.',
|
|
433
|
+
fix: 'Instale com: npm install -g @anthropic-ai/claude-code ' +
|
|
434
|
+
'(ou rode `install`/`repair`, que instala automaticamente).',
|
|
435
|
+
});
|
|
436
|
+
}
|
|
437
|
+
}
|
|
438
|
+
// ── Veredito ──────────────────────────────────────────────────────────────
|
|
439
|
+
const components = options.components.map((name) => ({
|
|
440
|
+
name,
|
|
441
|
+
verdict: verdictFor(checks.filter((c) => c.component === undefined || c.component === name), unreachable.has(name)),
|
|
442
|
+
...(latestByComponent.has(name) ? { latestVersion: latestByComponent.get(name) } : {}),
|
|
443
|
+
...(installedByComponent.has(name) ? { installedVersion: installedByComponent.get(name) } : {}),
|
|
444
|
+
}));
|
|
445
|
+
const verdict = verdictFor(checks, unreachable.size > 0);
|
|
446
|
+
log.step('Veredito');
|
|
447
|
+
for (const component of components) {
|
|
448
|
+
const versions = (component.installedVersion ? `instalada v${component.installedVersion}` : 'não instalado') +
|
|
449
|
+
(component.latestVersion ? ` · publicada v${component.latestVersion}` : '');
|
|
450
|
+
const line = `${component.name.padEnd(8)} ${VERDICT_LABEL[component.verdict]} (${versions})`;
|
|
451
|
+
if (component.verdict === 'ready')
|
|
452
|
+
log.success(line);
|
|
453
|
+
else if (component.verdict === 'blocked')
|
|
454
|
+
log.error(line);
|
|
455
|
+
else
|
|
456
|
+
log.warn(line);
|
|
457
|
+
}
|
|
458
|
+
const blocks = checks.filter((c) => c.severity === 'block');
|
|
459
|
+
if (blocks.length > 0) {
|
|
460
|
+
log.error(`MÁQUINA BLOQUEADA — ${blocks.length} motivo(s):`);
|
|
461
|
+
for (const block of blocks) {
|
|
462
|
+
log.error(` - ${block.message}`);
|
|
463
|
+
if (block.fix)
|
|
464
|
+
log.info(` Como resolver: ${block.fix}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
else if (verdict === 'undetermined') {
|
|
468
|
+
log.warn('Veredito INDETERMINADO: a Version API não respondeu para ao menos um componente.');
|
|
469
|
+
}
|
|
470
|
+
else if (verdict === 'ready_with_warnings') {
|
|
471
|
+
log.success(`Máquina APTA, com ${checks.filter((c) => c.severity === 'warn').length} aviso(s) acima.`);
|
|
472
|
+
}
|
|
473
|
+
else {
|
|
474
|
+
log.success('Máquina APTA para instalar/atualizar o Kyroon.');
|
|
475
|
+
}
|
|
476
|
+
if (log.fileLogPath())
|
|
477
|
+
log.info(`Envie este arquivo ao suporte: ${log.fileLogPath()}`);
|
|
478
|
+
return {
|
|
479
|
+
schemaVersion: 1,
|
|
480
|
+
generatedAt: new Date().toISOString(),
|
|
481
|
+
cli: { package: options.npmPackage ?? null, version: options.cliVersion ?? null, latest: latestCli },
|
|
482
|
+
machine,
|
|
483
|
+
apiUrl,
|
|
484
|
+
installRoot,
|
|
485
|
+
components,
|
|
486
|
+
checks,
|
|
487
|
+
verdict,
|
|
488
|
+
logFile: log.fileLogPath(),
|
|
489
|
+
};
|
|
490
|
+
}
|
|
491
|
+
const VERDICT_LABEL = {
|
|
492
|
+
ready: 'APTA',
|
|
493
|
+
ready_with_warnings: 'APTA COM AVISOS',
|
|
494
|
+
blocked: 'BLOQUEADA',
|
|
495
|
+
undetermined: 'INDETERMINADA',
|
|
496
|
+
};
|
|
497
|
+
/** Bloqueio vence tudo; sem a API não há como afirmar aptidão; depois, avisos. */
|
|
498
|
+
function verdictFor(checks, apiUnreachable) {
|
|
499
|
+
if (checks.some((c) => c.severity === 'block'))
|
|
500
|
+
return 'blocked';
|
|
501
|
+
if (apiUnreachable)
|
|
502
|
+
return 'undetermined';
|
|
503
|
+
if (checks.some((c) => c.severity === 'warn'))
|
|
504
|
+
return 'ready_with_warnings';
|
|
505
|
+
return 'ready';
|
|
506
|
+
}
|
|
507
|
+
function invalidSignature(name, binary) {
|
|
508
|
+
// No Apple Silicon, Mach-O sem assinatura = "Killed: 9" ao abrir.
|
|
509
|
+
return {
|
|
510
|
+
id: 'install.signature',
|
|
511
|
+
component: name,
|
|
512
|
+
severity: 'warn',
|
|
513
|
+
message: `${name}: assinatura de código inválida em ${binary} — o macOS pode encerrar o processo.`,
|
|
514
|
+
fix: "Execute 'repair'.",
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
async function checkPython(platform) {
|
|
162
518
|
const pyCmd = platform.os === 'win' ? 'py' : 'python3';
|
|
163
519
|
const pyArgs = platform.os === 'win' ? ['-3', '--version'] : ['--version'];
|
|
164
520
|
try {
|
|
165
521
|
const res = await execa(pyCmd, pyArgs, { reject: false });
|
|
166
|
-
if (res.exitCode === 0)
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
522
|
+
if (res.exitCode === 0) {
|
|
523
|
+
return {
|
|
524
|
+
id: 'worker.python',
|
|
525
|
+
component: 'worker',
|
|
526
|
+
severity: 'pass',
|
|
527
|
+
message: `${pyCmd} OK: ${(res.stdout || res.stderr).trim()}`,
|
|
528
|
+
};
|
|
529
|
+
}
|
|
530
|
+
return {
|
|
531
|
+
id: 'worker.python',
|
|
532
|
+
component: 'worker',
|
|
533
|
+
severity: 'warn',
|
|
534
|
+
message: `${pyCmd} not resolving — hooks may fail (NoHookActivityTimeout).`,
|
|
535
|
+
fix: 'Instale o Python 3 (ou rode `install`/`repair`).',
|
|
536
|
+
};
|
|
170
537
|
}
|
|
171
538
|
catch {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
log.warn('libwebkit2gtk-4.0.so.37 não resolve — o Kyroon App pode não abrir. ' +
|
|
180
|
-
'Rode `install`/`repair` (instala automaticamente: 4.0-37 em distros antigas, ' +
|
|
181
|
-
'4.1-0 + symlink de compat em distros novas como Ubuntu 24.04+).');
|
|
182
|
-
}
|
|
539
|
+
return {
|
|
540
|
+
id: 'worker.python',
|
|
541
|
+
component: 'worker',
|
|
542
|
+
severity: 'warn',
|
|
543
|
+
message: `${pyCmd} not found — install Python 3 for the Worker JSONL hooks.`,
|
|
544
|
+
fix: 'Instale o Python 3 (ou rode `install`/`repair`).',
|
|
545
|
+
};
|
|
183
546
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
547
|
+
}
|
|
548
|
+
/**
|
|
549
|
+
* O download vem de outro host que não a API (storage). Qualquer resposta HTTP
|
|
550
|
+
* prova que o host é alcançável — só erro de rede (DNS, TLS, timeout, proxy)
|
|
551
|
+
* conta como problema.
|
|
552
|
+
*/
|
|
553
|
+
async function checkDownloadHost(origin) {
|
|
554
|
+
try {
|
|
555
|
+
const { default: axios } = await import('axios');
|
|
556
|
+
await axios.head(origin, { timeout: 8_000, validateStatus: () => true, maxRedirects: 0 });
|
|
557
|
+
return { id: 'network.download', severity: 'pass', message: `Host de download alcançável: ${origin}` };
|
|
188
558
|
}
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
'
|
|
559
|
+
catch (err) {
|
|
560
|
+
return {
|
|
561
|
+
id: 'network.download',
|
|
562
|
+
severity: 'warn',
|
|
563
|
+
message: `Host de download inacessível: ${origin} (${err instanceof Error ? err.message : String(err)}).`,
|
|
564
|
+
fix: 'Libere esse endereço no proxy/firewall — é de onde os pacotes são baixados.',
|
|
565
|
+
};
|
|
192
566
|
}
|
|
193
567
|
}
|
|
194
568
|
/** Versão publicada da CLI no registry npm. `null` sem rede — nunca lança. */
|
|
@@ -203,4 +577,17 @@ async function latestNpmVersion(npmPackage) {
|
|
|
203
577
|
return null;
|
|
204
578
|
}
|
|
205
579
|
}
|
|
580
|
+
/** Silencia `console.*` (modo --json) e devolve a função que restaura. */
|
|
581
|
+
function muteConsole() {
|
|
582
|
+
const original = { log: console.log, warn: console.warn, error: console.error };
|
|
583
|
+
const noop = () => { };
|
|
584
|
+
console.log = noop;
|
|
585
|
+
console.warn = noop;
|
|
586
|
+
console.error = noop;
|
|
587
|
+
return () => {
|
|
588
|
+
console.log = original.log;
|
|
589
|
+
console.warn = original.warn;
|
|
590
|
+
console.error = original.error;
|
|
591
|
+
};
|
|
592
|
+
}
|
|
206
593
|
//# sourceMappingURL=doctor.js.map
|