local-mcp 3.0.420 → 3.0.424
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/bundled.js +40 -0
- package/download.js +91 -247
- package/index.js +141 -442
- package/launch-event.js +63 -12
- package/package.json +10 -4
- package/setup.js +59 -99
package/launch-event.js
CHANGED
|
@@ -12,23 +12,54 @@
|
|
|
12
12
|
// · escribir en stdout — es el protocolo;
|
|
13
13
|
// · demorar el arranque del server o una salida — sin reintentos, timeout corto, todo error
|
|
14
14
|
// tragado;
|
|
15
|
-
// · mandar algo que no sea uno de los
|
|
15
|
+
// · mandar algo que no sea uno de los campos del contrato, con valores de conjunto cerrado: ni
|
|
16
|
+
// el argumento, ni rutas, ni entorno, ni el mensaje de un error (#82: de un error sale su clase).
|
|
16
17
|
const { https } = require('./user-agent')
|
|
17
18
|
const cp = require('child_process')
|
|
18
19
|
const DESTINO = { hostname: 'office-mcp-production.up.railway.app', path: '/launch-event' }
|
|
19
20
|
const PLATAFORMAS = ['darwin', 'win32', 'linux', 'other']
|
|
20
|
-
const CLASES = ['none', 'stdio', 'unknown']
|
|
21
|
+
const CLASES = ['none', 'stdio', 'unknown', 'start', 'serve', 'server', 'run', 'mcp', '--stdio', 'other-word', 'other-flag']
|
|
21
22
|
const OUTCOMES = ['spawned', 'rejected-argument', 'unsupported-node', 'unsupported-platform',
|
|
22
23
|
'download-failed', 'spawn-failed', 'uninstalled', 'other']
|
|
24
|
+
// #82: por qué falló, como clase. Sólo acompaña a un outcome de falla, y sólo donde hay algo que
|
|
25
|
+
// clasificar (`download-failed`, `spawn-failed`, `other`); `checksum-mismatch` e `init-failed`
|
|
26
|
+
// son del contrato y este wrapper no los produce.
|
|
27
|
+
const RAZONES = ['network', 'timeout', 'http-status', 'checksum-mismatch', 'disk-write',
|
|
28
|
+
'permission-denied', 'binary-missing', 'early-exit', 'signal', 'uncaught-exception', 'init-failed', 'unknown']
|
|
29
|
+
const CAMINO = 'npm-wrapper' // launch_path: quién arrancó el server
|
|
30
|
+
// 3.0.423 (lmcp-api#548): qué binario encontró el lanzamiento. El wrapper lo fija con fuente() en
|
|
31
|
+
// cuanto lo sabe; antes de saberlo (desinstalado, argumento rechazado) el evento no lo lleva.
|
|
32
|
+
const FUENTES = ['bundled', 'app_embedded', 'missing_platform']
|
|
33
|
+
let fuenteBinario
|
|
34
|
+
function fuente (valor) { if (FUENTES.includes(valor)) fuenteBinario = valor }
|
|
23
35
|
const RE_VERSION = /^\d{1,3}\.\d{1,3}\.\d{1,5}$/
|
|
24
36
|
const RE_MAQUINA = /^[A-Za-z0-9._:{}-]{1,64}$/
|
|
25
37
|
const [TIMEOUT_MS, TOPE_MS] = [3000, 4000] // el pedido · la vida del proceso suelto
|
|
26
38
|
const TOPE_ID_MS = 2000 // Windows: cuánto puede esperar el `spawned` al id de hardware (#21)
|
|
27
39
|
|
|
28
|
-
// Del argumento sólo viaja su clase
|
|
40
|
+
// Del argumento sólo viaja su clase (#88): `stdio` y las formas que los clientes inventan se
|
|
41
|
+
// nombran (conjunto fijo); cualquier otra cosa es `other-flag` si empieza con `-` y `other-word`
|
|
42
|
+
// si no. El texto crudo no sale nunca. `unknown` queda en el conjunto por compatibilidad: ya no se emite.
|
|
43
|
+
const NOMBRADOS = ['stdio', 'start', 'serve', 'server', 'run', 'mcp', '--stdio']
|
|
29
44
|
function claseDeArgumento (cmd) {
|
|
30
45
|
if (cmd === undefined) return 'none'
|
|
31
|
-
|
|
46
|
+
if (NOMBRADOS.includes(cmd)) return cmd
|
|
47
|
+
return typeof cmd === 'string' && cmd.startsWith('-') ? 'other-flag' : 'other-word'
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// De un error sólo viaja su clase (#82). El mensaje se LEE acá —trae rutas y URLs— y no sale: lo
|
|
51
|
+
// que devuelve es siempre un valor de RAZONES. El orden importa: «EACCES … open <ruta>» es de
|
|
52
|
+
// permisos aunque la ruta diga otra cosa.
|
|
53
|
+
function razonDeError (err) {
|
|
54
|
+
let t = ''
|
|
55
|
+
try { t = `${(err && err.code) || ''} ${(err && err.message) || ''}` } catch {}
|
|
56
|
+
if (/\b(EACCES|EPERM)\b/.test(t)) return 'permission-denied'
|
|
57
|
+
if (/timeout|ETIMEDOUT/i.test(t)) return 'timeout'
|
|
58
|
+
if (/HTTP \d{3}|not yet available/.test(t)) return 'http-status'
|
|
59
|
+
if (/\b(ENOTFOUND|EAI_AGAIN|ECONNRESET|ECONNREFUSED|ENETUNREACH|EHOSTUNREACH|EPIPE)\b|socket hang up|CERT|ERR_TLS/.test(t)) return 'network'
|
|
60
|
+
if (/\b(ENOSPC|EROFS|EIO|EBUSY|EDQUOT)\b/.test(t)) return 'disk-write'
|
|
61
|
+
if (/\bENOENT\b|not found after extraction|no encontrado después de extraer|tar\.exe not found/.test(t)) return 'binary-missing'
|
|
62
|
+
return 'unknown'
|
|
32
63
|
}
|
|
33
64
|
|
|
34
65
|
// El heartbeat no tiene compuerta de consentimiento (ver #11). Este evento respeta además el
|
|
@@ -55,8 +86,13 @@ function cuerpo (outcome, clase, deps = {}) {
|
|
|
55
86
|
package_version: version,
|
|
56
87
|
platform: PLATAFORMAS.includes(plataforma) ? plataforma : 'other',
|
|
57
88
|
arg_class: clase,
|
|
58
|
-
outcome
|
|
89
|
+
outcome,
|
|
90
|
+
launch_path: CAMINO
|
|
59
91
|
}
|
|
92
|
+
// Una razón fuera del conjunto no viaja, y un `spawned` no lleva razón; el evento sale igual.
|
|
93
|
+
if (outcome !== 'spawned' && RAZONES.includes(deps.reason)) c.reason = deps.reason
|
|
94
|
+
const f = 'binarySource' in deps ? deps.binarySource : fuenteBinario
|
|
95
|
+
if (FUENTES.includes(f)) c.binary_source = f
|
|
60
96
|
const id = 'machineId' in deps ? deps.machineId : idDeMaquina()
|
|
61
97
|
if (typeof id === 'string' && RE_MAQUINA.test(id)) c.machine_id = id
|
|
62
98
|
return c
|
|
@@ -140,7 +176,7 @@ function idDeHardwareWindows (listo) {
|
|
|
140
176
|
// Una persona en una terminal (stdin TTY) no es un cliente de IA lanzando el server: no reporta.
|
|
141
177
|
let reportado = false
|
|
142
178
|
let pendiente = null
|
|
143
|
-
function reportar (outcome, clase, { enProceso = false } = {}) {
|
|
179
|
+
function reportar (outcome, clase, { enProceso = false, reason } = {}) {
|
|
144
180
|
if (reportado) return
|
|
145
181
|
reportado = true
|
|
146
182
|
try {
|
|
@@ -149,6 +185,15 @@ function reportar (outcome, clase, { enProceso = false } = {}) {
|
|
|
149
185
|
if (enProceso) {
|
|
150
186
|
const idEntorno = (process.env.LMCP_MACHINE_ID || '').trim()
|
|
151
187
|
if (process.platform === 'win32' && !idEntorno) {
|
|
188
|
+
// lmcp-npm#92: el orden de _getMachineId sin el probe. Con el id guardado del cliente, ése;
|
|
189
|
+
// sin guardado y sin token, ninguno. El hardware se pide sólo para lo que reporta un 3.0.420.
|
|
190
|
+
const dl = require('./download')
|
|
191
|
+
const guardado = dl._readStoredMachineId(dl.CACHE_DIR)
|
|
192
|
+
if (guardado || !dl._readCachedCloudToken(dl.CACHE_DIR)) {
|
|
193
|
+
const c = cuerpo(outcome, clase, { machineId: guardado })
|
|
194
|
+
if (c) enviar(c, { soltar: true })
|
|
195
|
+
return
|
|
196
|
+
}
|
|
152
197
|
pendiente = { outcome, clase }
|
|
153
198
|
idDeHardwareWindows((id) => {
|
|
154
199
|
if (!pendiente) return // ya salió por el proceso suelto
|
|
@@ -162,7 +207,7 @@ function reportar (outcome, clase, { enProceso = false } = {}) {
|
|
|
162
207
|
if (c) enviar(c, { soltar: true })
|
|
163
208
|
return
|
|
164
209
|
}
|
|
165
|
-
lanzarSuelto(outcome, clase)
|
|
210
|
+
lanzarSuelto(outcome, clase, reason)
|
|
166
211
|
} catch {}
|
|
167
212
|
}
|
|
168
213
|
|
|
@@ -170,8 +215,11 @@ function reportar (outcome, clase, { enProceso = false } = {}) {
|
|
|
170
215
|
// como reportado para que la red del `exit` tampoco lo mande como `other`.
|
|
171
216
|
function silenciar () { reportado = true }
|
|
172
217
|
|
|
173
|
-
function lanzarSuelto (outcome, clase) {
|
|
174
|
-
|
|
218
|
+
function lanzarSuelto (outcome, clase, reason) {
|
|
219
|
+
// La razón viaja como argumento sólo si es del conjunto: al proceso suelto no le llega texto libre.
|
|
220
|
+
// La fuente del binario va detrás, también sólo si es del conjunto (RAZONES y FUENTES no se cruzan).
|
|
221
|
+
const hijo = cp.spawn(process.execPath, [__filename, outcome, clase, ...(RAZONES.includes(reason) ? [reason] : []),
|
|
222
|
+
...(FUENTES.includes(fuenteBinario) ? [fuenteBinario] : [])],
|
|
175
223
|
{ detached: true, stdio: 'ignore', windowsHide: true })
|
|
176
224
|
hijo.on('error', () => {})
|
|
177
225
|
hijo.unref()
|
|
@@ -187,12 +235,15 @@ function soltarPendiente () {
|
|
|
187
235
|
try { lanzarSuelto(outcome, clase) } catch {}
|
|
188
236
|
}
|
|
189
237
|
|
|
190
|
-
// Como programa es el proceso suelto: `node launch-event.js <outcome> <clase
|
|
238
|
+
// Como programa es el proceso suelto: `node launch-event.js <outcome> <clase> [reason] [binary_source]`.
|
|
191
239
|
if (require.main === module) {
|
|
192
240
|
setTimeout(() => process.exit(0), TOPE_MS).unref()
|
|
193
|
-
const c = apagado() ? null : cuerpo(process.argv[2], process.argv[3]
|
|
241
|
+
const c = apagado() ? null : cuerpo(process.argv[2], process.argv[3], {
|
|
242
|
+
reason: process.argv.slice(4).find(a => RAZONES.includes(a)),
|
|
243
|
+
binarySource: process.argv.slice(4).find(a => FUENTES.includes(a))
|
|
244
|
+
})
|
|
194
245
|
if (c) enviar(c)
|
|
195
246
|
}
|
|
196
247
|
|
|
197
|
-
module.exports = { PLATAFORMAS, CLASES, OUTCOMES, RE_VERSION, RE_MAQUINA, TOPE_ID_MS, claseDeArgumento, apagado, cuerpo, reportar, silenciar, soltarPendiente,
|
|
248
|
+
module.exports = { PLATAFORMAS, CLASES, OUTCOMES, RAZONES, CAMINO, FUENTES, fuente, razonDeError, RE_VERSION, RE_MAQUINA, TOPE_ID_MS, claseDeArgumento, apagado, cuerpo, reportar, silenciar, soltarPendiente,
|
|
198
249
|
_idDeHardwareWindows: idDeHardwareWindows } // costura de test
|
package/package.json
CHANGED
|
@@ -1,18 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "local-mcp",
|
|
3
|
-
"version": "3.0.
|
|
4
|
-
"description": "Let ChatGPT, Claude, Cursor & any MCP client actually use your Mac or Windows PC — read & reply to email, manage your calendar, text over iMessage, find files, work with Teams, Slack & Office. Runs locally, no API keys
|
|
3
|
+
"version": "3.0.424",
|
|
4
|
+
"description": "Let ChatGPT, Claude, Cursor & any MCP client actually use your Mac or Windows PC — read & reply to email, manage your calendar, text over iMessage, find files, work with Teams, Slack, Notion & Office. Runs locally, no API keys.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"bin": {
|
|
7
7
|
"local-mcp": "index.js"
|
|
8
8
|
},
|
|
9
9
|
"scripts": {
|
|
10
10
|
"postinstall": "node postinstall.js",
|
|
11
|
-
"test": "node --test test/*.test.js"
|
|
11
|
+
"test": "node --require ./test/aislado.preload.js --test test/*.test.js"
|
|
12
12
|
},
|
|
13
13
|
"files": [
|
|
14
14
|
"index.js",
|
|
15
15
|
"download.js",
|
|
16
|
+
"bundled.js",
|
|
16
17
|
"setup.js",
|
|
17
18
|
"launch-event.js",
|
|
18
19
|
"user-agent.js",
|
|
@@ -23,9 +24,14 @@
|
|
|
23
24
|
"engines": {
|
|
24
25
|
"node": ">=20"
|
|
25
26
|
},
|
|
27
|
+
"optionalDependencies": {
|
|
28
|
+
"local-mcp-darwin-arm64": "3.0.424",
|
|
29
|
+
"local-mcp-darwin-x64": "3.0.424",
|
|
30
|
+
"local-mcp-windows-x64": "3.0.424",
|
|
31
|
+
"local-mcp-windows-arm64": "3.0.424"
|
|
32
|
+
},
|
|
26
33
|
"os": [
|
|
27
34
|
"darwin",
|
|
28
|
-
"linux",
|
|
29
35
|
"win32"
|
|
30
36
|
],
|
|
31
37
|
"keywords": [
|
package/setup.js
CHANGED
|
@@ -318,8 +318,8 @@ async function runSetup(opts = {}) {
|
|
|
318
318
|
process.exitCode = sinLinux.exitCode
|
|
319
319
|
return
|
|
320
320
|
}
|
|
321
|
-
// Cross-platform: macOS configures the Swift tray + embedded server; Windows
|
|
322
|
-
// go-server
|
|
321
|
+
// Cross-platform: macOS configures the Swift tray + embedded server; Windows installs the
|
|
322
|
+
// go-server from the npm platform package (bundled.js) and writes the MCP client config.
|
|
323
323
|
const forceAll = opts.all || process.argv.includes('--all')
|
|
324
324
|
const refArg = process.argv.find(a => a.startsWith('--ref='))
|
|
325
325
|
if (refArg) process.env.LMCP_REF = refArg.split('=')[1]
|
|
@@ -354,7 +354,6 @@ async function runSetup(opts = {}) {
|
|
|
354
354
|
console.error(` Fix: nvm alias default 22 && nvm uninstall ${process.version} (then relaunch Claude Desktop)\n`)
|
|
355
355
|
}
|
|
356
356
|
|
|
357
|
-
// Pre-download binary so first launch is instant
|
|
358
357
|
// All clients use a shell launcher that wraps npx (self-healing if binary is
|
|
359
358
|
// missing/broken, and surfaces telemetry + clear errors if Node is too old).
|
|
360
359
|
let npxAbsPath = _resolveNpxPath() // baked into the launcher script
|
|
@@ -362,88 +361,52 @@ async function runSetup(opts = {}) {
|
|
|
362
361
|
let stableArgs = NPX_ARGS
|
|
363
362
|
let binaryVersion = ''
|
|
364
363
|
// ADR-0004 phase 3 (darwin): if the notarized server is already embedded in
|
|
365
|
-
// LocalMCPTray.app,
|
|
366
|
-
// binary — the launcher (→ npx → index.js) prefers the embedded one anyway,
|
|
367
|
-
// and the ad-hoc copy is what resets Automation TCC. The tray is ensured later
|
|
368
|
-
// in setup; on a fresh install where the .app isn't present yet this is null
|
|
369
|
-
// and we keep the legacy pre-download as a fallback.
|
|
364
|
+
// LocalMCPTray.app, the launcher (→ npx → index.js) prefers it.
|
|
370
365
|
const _embeddedServer = process.platform === 'darwin'
|
|
371
|
-
?
|
|
372
|
-
path.join(os.homedir(), 'Applications', 'LocalMCPTray.app', 'Contents', 'MacOS', 'local-mcp-server'),
|
|
373
|
-
path.join('/Applications', 'LocalMCPTray.app', 'Contents', 'MacOS', 'local-mcp-server'),
|
|
374
|
-
].find(p => { try { return fs.statSync(p).isFile() } catch { return false } })
|
|
366
|
+
? download.trayAppPaths().map(app => path.join(app, 'Contents', 'MacOS', 'local-mcp-server')).find(p => { try { return fs.statSync(p).isFile() } catch { return false } })
|
|
375
367
|
: null
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
368
|
+
// 3.0.423: the server comes in npm's platform package (bundled.js). Nothing is downloaded and
|
|
369
|
+
// nothing is re-signed: the Mac binary keeps its Developer ID signature.
|
|
370
|
+
const _bundled = (() => { const p = require('./bundled').bundledServerPath(); try { return p && fs.statSync(p).isFile() ? p : null } catch { return null } })()
|
|
371
|
+
const { CACHE_DIR } = download
|
|
372
|
+
if (_embeddedServer) {
|
|
373
|
+
try {
|
|
374
|
+
binaryVersion = fs.readFileSync(
|
|
375
|
+
path.join(os.homedir(), '.local', 'share', 'local-mcp', 'tray', '.version'), 'utf8'
|
|
376
|
+
).trim()
|
|
377
|
+
} catch {}
|
|
378
|
+
process.stderr.write('✓ Using server embedded in the LMCP app\n\n')
|
|
379
|
+
} else if (_bundled) {
|
|
380
|
+
try { binaryVersion = fs.readFileSync(path.join(path.dirname(_bundled), 'VERSION'), 'utf8').trim() } catch {}
|
|
381
|
+
// Windows: the go-server's --configure-clients points every AI client at
|
|
382
|
+
// %LOCALAPPDATA%\local-mcp\bin\lmcp-server.exe (lmcp-win internal/aiclients ServerBinary), so
|
|
383
|
+
// setup — which the person asked for — puts the bundled binary there. A copy, not a download.
|
|
384
|
+
// The Mac clients go through the launcher → npx, which runs the bundled binary in place.
|
|
385
|
+
// With the LMCP app installed (lmcp-tray.exe in that folder) the app already put its server there
|
|
386
|
+
// and keeps it updated: setup leaves it alone.
|
|
387
|
+
if (_IS_WIN && !fs.existsSync(path.join(CACHE_DIR, 'lmcp-tray.exe'))) {
|
|
388
|
+
const dest = path.join(CACHE_DIR, 'lmcp-server.exe')
|
|
391
389
|
try {
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
const tmpPath = stablePath + '.tmp'
|
|
402
|
-
fs.copyFileSync(binPath, tmpPath)
|
|
403
|
-
fs.chmodSync(tmpPath, 0o755)
|
|
404
|
-
try { execFileSync('codesign', ['--force', '--sign', '-', '--identifier', 'com.local-mcp.server', tmpPath], { stdio: 'pipe' }) } catch {}
|
|
405
|
-
// curl route-3 installs the binary one level deeper:
|
|
406
|
-
// ~/.local/share/local-mcp/bin/local-mcp-server/local-mcp-server
|
|
407
|
-
// leaving stablePath itself as a DIRECTORY. fs.renameSync throws EISDIR
|
|
408
|
-
// silently, so the npm stable binary is never written and the old curl
|
|
409
|
-
// server stays running forever (LMC-158).
|
|
410
|
-
try {
|
|
411
|
-
const st = fs.statSync(stablePath)
|
|
412
|
-
if (st.isDirectory()) {
|
|
413
|
-
process.stderr.write(' Migrating from curl install: removing old versioned directory at stable path\n')
|
|
414
|
-
fs.rmSync(stablePath, { recursive: true, force: true })
|
|
415
|
-
}
|
|
416
|
-
} catch { /* stablePath doesn't exist — nothing to do */ }
|
|
417
|
-
fs.renameSync(tmpPath, stablePath)
|
|
418
|
-
}
|
|
419
|
-
// Write the actual binary version (from /runtime/latest), not the npm package
|
|
420
|
-
// version. npm and Swift binary versions can diverge (npm-only fixes bump npm
|
|
421
|
-
// without a Swift rebuild). Writing pkg.version here caused the tray to think
|
|
422
|
-
// a newer binary was on disk and restart-loop (LMC-TODO). Runs on every
|
|
423
|
-
// platform: index.js's readCachedVersion() reads .server-version off darwin too.
|
|
424
|
-
fs.writeFileSync(path.join(CACHE_DIR, '.server-version'), binaryVersion || '')
|
|
425
|
-
const settingsSrc = path.join(path.dirname(binPath), 'settings.html')
|
|
426
|
-
const settingsDst = path.join(CACHE_DIR, 'settings.html')
|
|
427
|
-
if (fs.existsSync(settingsSrc)) fs.copyFileSync(settingsSrc, settingsDst)
|
|
428
|
-
} catch {}
|
|
429
|
-
process.stderr.write('✓ Runtime ready\n\n')
|
|
390
|
+
fs.mkdirSync(CACHE_DIR, { recursive: true })
|
|
391
|
+
fs.copyFileSync(_bundled, dest + '.tmp')
|
|
392
|
+
fs.renameSync(dest + '.tmp', dest)
|
|
393
|
+
if (binaryVersion) fs.writeFileSync(path.join(CACHE_DIR, '.go-server-version'), binaryVersion)
|
|
394
|
+
process.stderr.write(`✓ LMCP server installed in ${CACHE_DIR}\n\n`)
|
|
395
|
+
} catch (e) {
|
|
396
|
+
try { fs.unlinkSync(dest + '.tmp') } catch {}
|
|
397
|
+
process.stderr.write(` (Could not install the LMCP server in ${CACHE_DIR}: ${e.message})\n\n`)
|
|
398
|
+
}
|
|
430
399
|
}
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
400
|
+
} else {
|
|
401
|
+
process.stderr.write(` (The LMCP server for ${process.platform}-${process.arch} is not in this package; run: npx -y local-mcp@latest setup)\n\n`)
|
|
402
|
+
}
|
|
403
|
+
// The launcher uses curl (no Node dependency) to send telemetry if Node is
|
|
404
|
+
// too old, then exec's npx. Claude Desktop runs this script instead of npx
|
|
405
|
+
// directly, so failures are visible in MCP logs AND in our backend events.
|
|
406
|
+
try {
|
|
435
407
|
const spec = _writeLaunchSpec(npxAbsPath, CACHE_DIR)
|
|
436
408
|
if (spec) { stableCommand = spec.command; stableArgs = spec.args }
|
|
437
|
-
} catch
|
|
438
|
-
process.stderr.write(` (Runtime download failed, will download on first run: ${err.message})\n\n`)
|
|
439
|
-
// Still try to write a launcher even if binary download failed — the version
|
|
440
|
-
// check + telemetry path is independent of the binary.
|
|
441
|
-
try {
|
|
442
|
-
const { CACHE_DIR } = require('./download')
|
|
443
|
-
const spec = _writeLaunchSpec(npxAbsPath, CACHE_DIR)
|
|
444
|
-
if (spec) { stableCommand = spec.command; stableArgs = spec.args }
|
|
445
|
-
} catch {}
|
|
446
|
-
}
|
|
409
|
+
} catch {}
|
|
447
410
|
// stableCommand is now the shell launcher script path. It wraps npx with a
|
|
448
411
|
// Node version check + curl telemetry before exec'ing. If launcher creation
|
|
449
412
|
// failed it falls back to plain 'npx'.
|
|
@@ -458,9 +421,8 @@ async function runSetup(opts = {}) {
|
|
|
458
421
|
// second JS-side client list. Linux has no runtime-native writer yet
|
|
459
422
|
// (§3.8): a generic message, no per-client guesswork, no files written.
|
|
460
423
|
if (process.platform === 'darwin' || _IS_WIN) {
|
|
461
|
-
const { CACHE_DIR } = require('./download')
|
|
462
424
|
const launcher = _launcherArgsForConfigureClients(process.platform, stableCommand, stableArgs)
|
|
463
|
-
clientsRun = runConfigureClients(_findServerBinary(_embeddedServer, CACHE_DIR), launcher.command, launcher.args)
|
|
425
|
+
clientsRun = runConfigureClients(_findServerBinary(_embeddedServer || _bundled, CACHE_DIR), launcher.command, launcher.args)
|
|
464
426
|
const clientes = (clientsRun.report && clientsRun.report.clients) || []
|
|
465
427
|
_trackSetupStep('detect', clientsRun.runtime === 'ok' ? 'ok' : clientsRun.runtime, '', {
|
|
466
428
|
clientsFound: clientes.filter(c => c.status !== 'not_installed').map(c => c.id),
|
|
@@ -540,7 +502,7 @@ async function runSetup(opts = {}) {
|
|
|
540
502
|
if (configured.length > 0) {
|
|
541
503
|
if (healthOk) {
|
|
542
504
|
console.log(`✅ LMCP configured for: ${configured.join(', ')}\n`)
|
|
543
|
-
console.log(' ✓ Server binary verified —
|
|
505
|
+
console.log(' ✓ Server binary verified — tools ready\n')
|
|
544
506
|
} else {
|
|
545
507
|
console.log(`⚠ LMCP configured for: ${configured.join(', ')}`)
|
|
546
508
|
console.log(' Server binary could not be verified — it may still work after restart.\n')
|
|
@@ -794,13 +756,17 @@ function _getRef() {
|
|
|
794
756
|
// The one thing download.js's version doesn't do is seed the macOS Keychain with the
|
|
795
757
|
// ioreg-derived id so the Swift tray reads the same value setup computed. That side
|
|
796
758
|
// effect stays here, gated to darwin, instead of moving into download.js: download's
|
|
797
|
-
// _getMachineId runs on every
|
|
759
|
+
// _getMachineId runs on every ensureTray()/... call (i.e. on every
|
|
798
760
|
// npx spawn), and a Keychain write there would be needless overhead on a hot path
|
|
799
761
|
// that setup.js — which only runs once at install time — doesn't share.
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
762
|
+
// `deps` es la costura de test (#84): sin ella un test pedía al Keychain REAL de quien lo corre
|
|
763
|
+
// que creara o pisara la identidad de la máquina. Producto: nadie la pasa, nada cambia.
|
|
764
|
+
function _getMachineId(deps = {}) {
|
|
765
|
+
const id = download._getMachineId(deps)
|
|
766
|
+
// #94: the id can come from a config.json something else wrote. Only a contract-shaped id is
|
|
767
|
+
// seeded, and through execFile with an argument array: no shell sees it.
|
|
768
|
+
if ((deps.platform ? deps.platform === 'darwin' : _IS_MAC) && require('./launch-event').RE_MAQUINA.test(id)) {
|
|
769
|
+
try { (deps.execFileImpl || execFileSync)('security', ['add-generic-password', '-s', 'com.local-mcp.machine-id', '-a', 'machine-id', '-w', id, '-U'], { stdio: 'pipe' }) } catch {}
|
|
804
770
|
}
|
|
805
771
|
return id
|
|
806
772
|
}
|
|
@@ -867,16 +833,7 @@ function _installRefDir(platform = process.platform, home = HOME, cacheDir = dow
|
|
|
867
833
|
// looks at config.json — so writing the token to cfgFile there left it registered under a
|
|
868
834
|
// key nothing could ever redeem (#1390 finding 2). getCacheDir() in the go-server resolves
|
|
869
835
|
// to the exact same directory as CACHE_DIR here (tunnel.go:1107-1113 vs. download.js:39-41).
|
|
870
|
-
|
|
871
|
-
return path.join(cacheDir, '.cloud-token')
|
|
872
|
-
}
|
|
873
|
-
|
|
874
|
-
function _readCachedCloudToken(cacheDir) {
|
|
875
|
-
try {
|
|
876
|
-
const tok = fs.readFileSync(_cloudTokenPath(cacheDir), 'utf8').trim()
|
|
877
|
-
return tok.startsWith('lmcp-') ? tok : ''
|
|
878
|
-
} catch { return '' }
|
|
879
|
-
}
|
|
836
|
+
const { _cloudTokenPath, _readCachedCloudToken } = download
|
|
880
837
|
|
|
881
838
|
function _writeCloudToken(cacheDir, token) {
|
|
882
839
|
fs.mkdirSync(cacheDir, { recursive: true })
|
|
@@ -894,6 +851,8 @@ async function _registerAnonToken() {
|
|
|
894
851
|
return new Promise((resolve) => {
|
|
895
852
|
const { https } = require('./user-agent')
|
|
896
853
|
const machineId = _getMachineId()
|
|
854
|
+
// lmcp-npm#92: no id, no registration. The binary mints its id and registers itself.
|
|
855
|
+
if (!machineId) return resolve('')
|
|
897
856
|
const payload = JSON.stringify({ machine_id: machineId })
|
|
898
857
|
const req = https.request({
|
|
899
858
|
host: BACKEND_HOST,
|
|
@@ -1100,7 +1059,8 @@ function _pingInstall(clients, method, email = '', binaryVersion = '') {
|
|
|
1100
1059
|
}
|
|
1101
1060
|
|
|
1102
1061
|
// Send initial heartbeat so the machine appears as "activated" immediately
|
|
1103
|
-
// Even if the user doesn't restart their AI client right away
|
|
1062
|
+
// Even if the user doesn't restart their AI client right away. Not without an id (#92).
|
|
1063
|
+
if (!machineId) return
|
|
1104
1064
|
const hb = JSON.stringify({
|
|
1105
1065
|
machine_id: machineId,
|
|
1106
1066
|
version: binaryVersion || pkg.version,
|
|
@@ -1199,6 +1159,6 @@ module.exports = {
|
|
|
1199
1159
|
_notSupportedOnPlatformResult,
|
|
1200
1160
|
_launcherSpawnSpec, _writeLaunchScript, _writeLaunchSpec,
|
|
1201
1161
|
_getMachineId, _healthCheckSpec, _localMcpConfigDir, _installRefDir,
|
|
1202
|
-
_cloudTokenPath, _readCachedCloudToken, _writeCloudToken, _registerAnonToken,
|
|
1162
|
+
_cloudTokenPath, _readCachedCloudToken, _writeCloudToken, _registerAnonToken, _pingInstall,
|
|
1203
1163
|
_autoLaunchClient, _fetchClientsCatalog,
|
|
1204
1164
|
}
|