local-mcp 3.0.429 → 3.0.431

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/link.js ADDED
@@ -0,0 +1,265 @@
1
+ 'use strict'
2
+ // #125 (decisión «A» de Darío, 2026-10-28): una máquina instalada con npx se vincula a la cuenta de la
3
+ // persona con un código, como `gh auth login`. El binario del server pide el link con su propia llave
4
+ // y lo vuelve a llamar cada 5 s: mientras hay un link vivo, el binario consulta /account-link/code/status.
5
+ // Las dos rutas se firman con la llave raíz de la máquina, que Node no tiene (machine-link-url.v1,
6
+ // account-link-code.v1). Un solo subcomando, sin TTY y sin escribir nada (lmcp-mac#1451, lmcp-win#1224):
7
+ // link --json → {url, code, expires_at, local_required} | {linked: true, account}
8
+ // | {awaiting_local: true, account} | {error, account?} (error: exit ≠ 0)
9
+ // #128: con `local_required` (la raíz falla K2) la máquina aprueba además la confirmación web. lmcp-win#1273:
10
+ // la web encuentra la máquina sólo por el código, así que npm lo muestra igual que en el caso normal; después
11
+ // `link --json` contesta awaiting_local, el binario guarda pending_id y firma con `link --approve --json` o
12
+ // `link --deny --json`, sólo tras un «y» o una «n» explícitos acá. El {error: 'local_required'} de los
13
+ // binarios anteriores no trae código: sin él no hay nada que confirmar en la web, y npm lo dice.
14
+ // `account` es la pista enmascarada de la API (d***@gmail.com). A la telemetría va sólo el estado y una
15
+ // clase de error: nunca el código, el link ni la cuenta.
16
+ const { execFileSync } = require('child_process')
17
+ const readline = require('readline')
18
+
19
+ const RESUME = 'npx -y local-mcp@latest link'
20
+ const MY_LMCP = 'https://www.local-mcp.com/my-installs'
21
+ const ESPERA_MS = 120000
22
+ const CADA_MS = 5000 // account-link-code.v1: status «at most every 5 s»
23
+
24
+ function _execDefault(bin, timeout = 30000) {
25
+ return (args) => {
26
+ try {
27
+ // LMCP_NPM_VERSION, as index.js gives the stdio server: it is what reports the heartbeat as npm-wrapper.
28
+ const env = { ...process.env, LMCP_NPM_VERSION: require('./package.json').version || '' }
29
+ return { status: 0, stdout: execFileSync(bin, args, { timeout, env, stdio: ['ignore', 'pipe', 'pipe'], windowsHide: true }).toString() }
30
+ } catch (e) {
31
+ if (e.code === 'ENOENT' || e.code === 'EACCES') throw e
32
+ return { status: typeof e.status === 'number' ? e.status : 1, stdout: e.stdout ? e.stdout.toString() : '' }
33
+ }
34
+ }
35
+ }
36
+
37
+ // The answer typed in the terminal, or null: without a TTY (an agent) or past the deadline nobody answers.
38
+ function _askDefault(question, ms) {
39
+ if (!process.stdin.isTTY) return Promise.resolve(null)
40
+ return new Promise((resolve) => {
41
+ const rl = readline.createInterface({ input: process.stdin, output: process.stdout })
42
+ const t = setTimeout(() => { rl.close(); resolve(null) }, ms)
43
+ rl.question(question, (a) => { clearTimeout(t); rl.close(); resolve(a) })
44
+ })
45
+ }
46
+
47
+ function _leer(exec, args) {
48
+ let r
49
+ try { r = exec(args) } catch { return { error: 'no_binary' } }
50
+ let d = null
51
+ try { d = JSON.parse(String(r.stdout || '').trim()) } catch { /* abajo */ }
52
+ // lmcp-api#761 §5: a key from the table, or http_<status>; anything else is bad_output, never «error».
53
+ if (d && typeof d === 'object' && typeof d.error === 'string') return { error: /^[a-z0-9_]{1,40}$/.test(d.error) ? d.error : 'bad_output', account: d.account }
54
+ if (r.status !== 0) return { error: 'exit_' + r.status }
55
+ if (!d || typeof d !== 'object') return { error: 'bad_output' }
56
+ return d
57
+ }
58
+
59
+ const REPORT = 'hello@local-mcp.com'
60
+
61
+ // Signing in fixes none of these: there is nothing for the web to confirm, so the person reports it.
62
+ const SIN_ARREGLO_EN_LA_WEB = {
63
+ local_required: 'This computer needs a link code to confirm on the web, and LMCP did not give one',
64
+ }
65
+
66
+ // lmcp-api#761 §5 (decisión A, 2026-10-30): the text and what to do for each key `link --json` returns.
67
+ const SETUP_AGAIN = 'npx -y local-mcp@latest setup'
68
+ const RED = ['Could not reach LMCP.', `Check your internet connection and run: ${RESUME}`]
69
+ const TABLA = {
70
+ forwarding_off: ["Linking needs LMCP's cloud connection, which is turned off on this computer.", `Turn it on in LMCP's settings, then run: ${RESUME}`],
71
+ no_token: ['This computer has no LMCP connection yet.', `Run ${SETUP_AGAIN} again, then ${RESUME}. If it keeps happening, report it to ${REPORT}`],
72
+ network: RED,
73
+ no_answer: RED,
74
+ try_later: ['Too many attempts right now.', `Wait a few minutes and run: ${RESUME}`],
75
+ linking_off: ['Linking computers to an account is turned off right now.', `Try again later: ${RESUME}`],
76
+ bad_signature: ["This computer's clock is off.", `Set the date and time automatically, then run: ${RESUME}`],
77
+ not_linkable: ["This computer can't be linked to an account.", `Please report it to ${REPORT}`],
78
+ // lmcp-mac#1550: the binary cannot read this computer's token until the app is opened again.
79
+ open_lmcp_app: ['LMCP needs to be opened again on this computer.', `Quit LMCP, open it again, then run: ${RESUME}`],
80
+ // lmcp-win#1270: the device key could not be read, created or enrolled. A 5xx or a locked keychain pass, and
81
+ // link tries again from the start. npx may have no app, so the text does not name one.
82
+ no_key: ["Could not prepare this computer's key.", `Wait a few minutes and run: ${RESUME}. If it keeps happening, report it to ${REPORT}`],
83
+ }
84
+
85
+ function _falla(print, track) {
86
+ return (clase, texto) => {
87
+ const fila = TABLA[clase]
88
+ if (fila) {
89
+ print(`\n ⚠ ${fila[0]}`)
90
+ print(` ${fila[1]}`)
91
+ track('failed', clase)
92
+ return { state: 'failed', error: clase }
93
+ }
94
+ const propia = SIN_ARREGLO_EN_LA_WEB[clase]
95
+ print(`\n ⚠ ${texto || propia || 'Could not get a link code for this machine'} (${clase}).`)
96
+ if (propia) print(` Please report it to ${REPORT}, or run ${RESUME} again later.`)
97
+ else print(` Sign in or create your account in My LMCP — ${MY_LMCP} — then run: ${RESUME}`)
98
+ track('failed', clase)
99
+ return { state: 'failed', error: clase }
100
+ }
101
+ }
102
+
103
+ // The binary keeps the one-time id on these: the same command works again a bit later.
104
+ const REINTENTABLES = ['try_later', 'network', 'no_device_key']
105
+
106
+ // #128: sign the approval or the denial of a pending local link (the binary keeps pending_id). Used by
107
+ // the y/n question and by `npx -y local-mcp@latest link --approve|--deny`.
108
+ async function runDecision(modo, opts = {}) {
109
+ const print = opts.print || ((s) => console.log(s))
110
+ const track = opts.track || (() => {})
111
+ const falla = _falla(print, track)
112
+ const que = modo === 'approve' ? 'approve' : 'decline'
113
+ if (!opts.bin && !opts.exec) return falla('no_binary', `Could not ${que} the link on this computer`)
114
+ // #140: written out, so the scan of npm/test/servidor-minimo-138.test.js reads each command.
115
+ const r = _leer(opts.exec || _execDefault(opts.bin), modo === 'approve' ? ['link', '--approve', '--json'] : ['link', '--deny', '--json'])
116
+ if (REINTENTABLES.includes(r.error)) {
117
+ print(`\n ⚠ Could not ${que} the link on this computer yet (${r.error}).`)
118
+ print(` Try again: ${RESUME} --${modo}`)
119
+ track('failed', r.error)
120
+ return { state: 'retry', error: r.error }
121
+ }
122
+ if (r.error) return falla(r.error, `Could not ${que} the link on this computer`)
123
+ if (modo === 'approve' && r.linked === true) {
124
+ print(` ✓ Linked to ${r.account || 'your LMCP account'}.`)
125
+ track('linked')
126
+ return { state: 'linked', account: r.account || null }
127
+ }
128
+ if (modo === 'deny' && r.denied === true) {
129
+ print(' Not linked: you declined it on this computer.')
130
+ track('failed', 'denied')
131
+ return { state: 'denied' }
132
+ }
133
+ return falla('bad_output', `Could not ${que} the link on this computer`)
134
+ }
135
+
136
+ async function runLink(opts = {}) {
137
+ const print = opts.print || ((s) => console.log(s))
138
+ const track = opts.track || (() => {})
139
+ const sleep = opts.sleep || ((ms) => new Promise(r => setTimeout(r, ms)))
140
+ const now = opts.now || Date.now
141
+ const ask = opts.ask || _askDefault
142
+ const tty = opts.tty !== undefined ? opts.tty : !!process.stdin.isTTY
143
+ const falla = _falla(print, track)
144
+ if (!opts.bin && !opts.exec) return falla('no_binary')
145
+ const exec = opts.exec || _execDefault(opts.bin)
146
+
147
+ const pedido = _leer(exec, ['link', '--json'])
148
+ if (pedido.error === 'linked_elsewhere') {
149
+ // Neutral, without the account hint: whoever runs setup may not be the account's owner.
150
+ print('\n This computer is already linked to an LMCP account.')
151
+ track('failed', 'linked_elsewhere')
152
+ return { state: 'failed', error: 'linked_elsewhere' }
153
+ }
154
+ // local_lost (exit 1): the API gave out the one-time approval id and it got lost. Final, not «keep waiting».
155
+ const perdida = () => {
156
+ print(`\n ⚠ The approval request expired. Run ${RESUME} to start again.`)
157
+ track('failed', 'local_lost')
158
+ return { state: 'failed', error: 'local_lost' }
159
+ }
160
+ if (pedido.error === 'local_lost') return perdida()
161
+ if (pedido.error) return falla(pedido.error)
162
+ if (pedido.linked === true) {
163
+ print(`\n ✓ This machine is already linked to your LMCP account${pedido.account ? ' (' + pedido.account + ')' : ''}.`)
164
+ track('linked')
165
+ return { state: 'linked', account: pedido.account || null }
166
+ }
167
+ const local = pedido.local_required === true
168
+ const url = pedido.url, code = pedido.code
169
+ if (pedido.awaiting_local !== true) {
170
+ if (typeof url !== 'string' || typeof code !== 'string') return falla(local ? 'local_required' : 'bad_output')
171
+ print('\n Link this machine to your LMCP account:')
172
+ print(` Open ${url}`)
173
+ print(' (sign in or create your account there, then confirm)')
174
+ print(` Or enter the code ${code} in My LMCP — ${MY_LMCP}`)
175
+ if (local) {
176
+ print(' After you confirm on the web, this computer asks you to approve it here: that last step links it.')
177
+ print(' Waiting for the web confirmation…')
178
+ track('shown', 'local_required')
179
+ } else {
180
+ print(' Waiting for approval…')
181
+ track('shown')
182
+ }
183
+ }
184
+
185
+ const hasta = now() + (opts.timeoutMs || ESPERA_MS)
186
+ const vinculada = (e) => {
187
+ print(` ✓ Linked to ${e.account || 'your LMCP account'}.`)
188
+ track('linked')
189
+ return { state: 'linked', url, code, account: e.account || null }
190
+ }
191
+ let e = pedido.awaiting_local === true ? pedido : null
192
+ while (e || now() < hasta) {
193
+ if (!e) { await sleep(CADA_MS); e = _leer(exec, ['link', '--json']) }
194
+ if (e.linked === true) return vinculada(e)
195
+ if (e.error === 'local_lost') return perdida()
196
+ if (e.awaiting_local === true && !tty) {
197
+ // An agent ran setup: nobody can type y here. The person approves by hand, with the same binary.
198
+ const cmd = (modo) => `${RESUME} --${modo}`
199
+ print(` Confirm on the web, then approve linking to ${e.account || 'your LMCP account'} on this computer. In a terminal, run:`)
200
+ print(` ${cmd('approve')}`)
201
+ print(` or, to decline it:`)
202
+ print(` ${cmd('deny')}`)
203
+ track('timeout', 'awaiting_local')
204
+ return { state: 'awaiting_local', url, code }
205
+ }
206
+ if (e.awaiting_local === true) {
207
+ const resp = String(await ask(` Confirm on the web, then type y here to approve linking to ${e.account || 'your LMCP account'} [y/n]: `,
208
+ Math.max(hasta - now(), 0)) || '').trim().toLowerCase()
209
+ if (resp === 'y' || resp === 'yes' || resp === 'n' || resp === 'no') {
210
+ const d = await runDecision(resp[0] === 'y' ? 'approve' : 'deny', { exec, print, track })
211
+ // Retryable: the id is still in the binary. With time left, ask again (e stays the same answer).
212
+ if (d.state === 'retry' && now() < hasta) { await sleep(CADA_MS); continue }
213
+ return { ...d, url, code }
214
+ } else {
215
+ print(` Not approved on this computer. To approve it, run in a terminal: ${RESUME}`)
216
+ track('timeout', 'awaiting_local')
217
+ return { state: 'timeout', url, code }
218
+ }
219
+ }
220
+ // The link again (not approved yet), local_required or a failed check: keep waiting until the deadline.
221
+ e = null
222
+ }
223
+ print(` Not approved yet. When you have approved it, or for a new code, run: ${RESUME}`)
224
+ track('timeout')
225
+ return { state: 'timeout', url, code }
226
+ }
227
+
228
+ // lmcp-api#761 §1–2: before link, the binary registers the machine's relay token (without opening the
229
+ // tunnel) and beats once, so the key it enrols at link is bound to that token (bearer, never tofu) and
230
+ // first_seen exists. The binary keeps the token where it keeps its relay token: the answer never carries it.
231
+ // {"ok": true, "reused": bool} | {"ok": false, "code": "no_network|rate_limited|no_token|forwarding_off|open_lmcp_app"}
232
+ // Not fatal and silent: only telemetry here, because link retries it and prints the text, so a failure
233
+ // is not said twice. Any other answer (a binary without the subcommand, exit 2) is `unsupported`.
234
+ const CODIGO_DE_REGISTRO = { no_network: 'network', rate_limited: 'try_later', no_token: 'no_token', forwarding_off: 'forwarding_off', open_lmcp_app: 'open_lmcp_app' }
235
+
236
+ async function runRegister(opts = {}) {
237
+ const track = opts.track || (() => {})
238
+ if (!opts.bin && !opts.exec) return { state: 'unsupported' }
239
+ let d = null
240
+ try {
241
+ const r = (opts.exec || _execDefault(opts.bin, 60000))(['register', '--json'])
242
+ d = JSON.parse(String(r.stdout || '').trim())
243
+ } catch { return { state: 'unsupported' } }
244
+ if (d && d.ok === true) { track(d.reused === true ? 'reused' : 'ok'); return { state: 'registered', reused: d.reused === true } }
245
+ const clave = d && d.ok === false ? CODIGO_DE_REGISTRO[d.code] : undefined
246
+ if (!clave) return { state: 'unsupported' }
247
+ track('failed', clave)
248
+ return { state: 'failed', error: clave }
249
+ }
250
+
251
+ // `npx local-mcp link [--approve|--deny]`: the same binary and the same telemetry step as setup.
252
+ async function runLinkCommand(args = []) {
253
+ const setup = require('./setup')
254
+ const { CACHE_DIR } = require('./download')
255
+ const opts = {
256
+ bin: setup._findServerBinary(require('./bundled').bundledServerPath(), CACHE_DIR),
257
+ track: (status, error) => setup._trackSetupStep('account_link', status, '', error ? { error } : {}),
258
+ }
259
+ const modo = args.includes('--approve') ? 'approve' : args.includes('--deny') ? 'deny' : null
260
+ if (modo) return runDecision(modo, opts)
261
+ // lmcp-api#761 §2: link beats and registers too when it has to; the binary does it inside `link`.
262
+ return runLink(opts)
263
+ }
264
+
265
+ module.exports = { runLink, runLinkCommand, runDecision, runRegister, RESUME }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "local-mcp",
3
- "version": "3.0.429",
3
+ "version": "3.0.431",
4
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": {
@@ -15,6 +15,7 @@
15
15
  "download.js",
16
16
  "bundled.js",
17
17
  "setup.js",
18
+ "link.js",
18
19
  "launch-event.js",
19
20
  "user-agent.js",
20
21
  "unconfigure.js",
@@ -25,10 +26,10 @@
25
26
  "node": ">=20"
26
27
  },
27
28
  "optionalDependencies": {
28
- "local-mcp-darwin-arm64": "3.0.429",
29
- "local-mcp-darwin-x64": "3.0.429",
30
- "local-mcp-windows-x64": "3.0.429",
31
- "local-mcp-windows-arm64": "3.0.429"
29
+ "local-mcp-darwin-arm64": "3.0.431",
30
+ "local-mcp-darwin-x64": "3.0.431",
31
+ "local-mcp-windows-x64": "3.0.431",
32
+ "local-mcp-windows-arm64": "3.0.431"
32
33
  },
33
34
  "os": [
34
35
  "darwin",
package/setup.js CHANGED
@@ -13,7 +13,7 @@ const path = require('path')
13
13
  const os = require('os')
14
14
  const { execSync, execFileSync } = require('child_process')
15
15
  const download = require('./download')
16
- const { runLink } = require('./link')
16
+ const { runLink, runRegister } = require('./link')
17
17
 
18
18
  const HOME = os.homedir()
19
19
  const NPX_COMMAND = 'npx'
@@ -478,6 +478,13 @@ async function runSetup(opts = {}) {
478
478
  const healthOk = _runHealthCheck(_findServerBinary(_embeddedServer || _bundled, CACHE_DIR))
479
479
  _trackSetupStep('binary_health', healthOk ? 'ok' : 'failed', '', {})
480
480
 
481
+ // lmcp-api#761 §1–2: the binary registers this installation's relay token (no tunnel) and beats once,
482
+ // before the link: the key it enrols is bound to that token, and first_seen exists.
483
+ await runRegister({
484
+ bin: _findServerBinary(_embeddedServer || _bundled, CACHE_DIR),
485
+ track: (status, error) => _trackSetupStep('relay_register', status, '', error ? { error } : {}),
486
+ })
487
+
481
488
  // #125 (decisión «A»): the machine links to the person's account with a code, printed for them and
482
489
  // for the agent running the setup; it waits up to ~2 min for the approval on the web.
483
490
  const accountLink = await runLink({
@@ -583,42 +590,12 @@ async function runSetup(opts = {}) {
583
590
  const trayPermissions = _IS_MAC ? (clientsRun ? await _fetchTrayPermissions() : null) : 'not_applicable'
584
591
  // npx also downloads no proxies and launches no client (#112).
585
592
 
586
- // Anon-first cloud relay activation (replaces the interactive email prompt
587
- // removed 2026-04-19). Register an anonymous tunnel token keyed on
588
- // machine_id so cloud relay comes online immediately. Non-fatal on failure — the install still
589
- // succeeds and the server can retry at startup.
590
- // Provisioning is ALWAYS anonymous — same change made in install.sh (#1083); setup never
591
- // takes an email (#120). A skipped registration fails silently: the relay never comes up.
592
- {
593
- try {
594
- // On darwin the token lives in config.json, read by the Swift tray. Off darwin
595
- // the go-server reads ONLY CACHE_DIR/.cloud-token (#1390 finding 2) — check and
596
- // write there instead, so this doesn't mint a second, unredeemable token under
597
- // the same (now-correct, per finding 1) machine_id the go-server would otherwise
598
- // register for itself on first run.
599
- const cfg = (_safeReadConfig(cfgFile)).data || {}
600
- const cfgToken = (cfg.cloud_token && typeof cfg.cloud_token === 'string'
601
- && cfg.cloud_token.startsWith('lmcp-')) ? cfg.cloud_token : ''
602
- const existing = _IS_MAC ? cfgToken : (cfgToken || _readCachedCloudToken(download.CACHE_DIR))
603
- let token = existing
604
- if (!token) {
605
- token = await _registerAnonToken()
606
- if (token) {
607
- if (_IS_MAC) {
608
- const cfg2 = (_safeReadConfig(cfgFile)).data || {}
609
- cfg2.cloud_token = token
610
- _atomicWriteConfig(cfgFile, cfg2)
611
- } else {
612
- _writeCloudToken(download.CACHE_DIR, token)
613
- }
614
- console.log(' ✓ Cloud relay activated (anonymous)')
615
- }
616
- }
617
- } catch { /* non-fatal */ }
618
-
619
- // #120: the account is created or signed in on the web; nothing here takes an email. #125: the
620
- // machine's link to it was printed above (runLink).
621
- }
593
+ // lmcp-npm#141, lmcp-api#761: Node registers no relay token and writes none. The binary does it
594
+ // (runRegister above, `register --json`), without opening the tunnel, and keeps it where it keeps its
595
+ // relay token; the tunnel only comes up after approval. A token that already exists is kept: setup
596
+ // neither reads it to replace it nor deletes it.
597
+ // #120: the account is created or signed in on the web; nothing here takes an email. #125: the
598
+ // machine's link to it was printed above (runLink).
622
599
 
623
600
  // LMCP_METHOD lets install.sh pass 'curl' so we can distinguish it from
624
601
  // a direct 'npx local-mcp setup' invocation in the analytics.
@@ -744,61 +721,8 @@ function _installRefDir(platform = process.platform, home = HOME, cacheDir = dow
744
721
  return cacheDir
745
722
  }
746
723
 
747
- // On darwin the anon cloud_token is persisted in config.json (cfgFile), which the Swift
748
- // tray already reads. Off darwin, the go-server reads it EXCLUSIVELY from
749
- // getCacheDir()/.cloud-token as a plain trimmed string (tunnel.go:454,513-523) — it never
750
- // looks at config.json — so writing the token to cfgFile there left it registered under a
751
- // key nothing could ever redeem (#1390 finding 2). getCacheDir() in the go-server resolves
752
- // to the exact same directory as CACHE_DIR here (tunnel.go:1107-1113 vs. download.js:39-41).
753
724
  const { _cloudTokenPath, _readCachedCloudToken } = download
754
725
 
755
- function _writeCloudToken(cacheDir, token) {
756
- fs.mkdirSync(cacheDir, { recursive: true })
757
- // 0o600 matches tokenFileMode in tunnel.go — best-effort on Windows, where POSIX bits
758
- // are largely ignored, but real restriction on Linux.
759
- fs.writeFileSync(_cloudTokenPath(cacheDir), token, { mode: 0o600 })
760
- }
761
-
762
- /// Claim an anonymous tunnel token via /tunnel/register-anon so cloud relay
763
- /// activates without asking for an email (2026-04-19 anon-first rollout). The
764
- /// token is keyed on the Mac's machine_id (IOPlatformUUID, shared via Keychain
765
- /// with the Swift daemon). Returns the token string or '' on failure — callers
766
- /// treat failure as non-fatal.
767
- async function _registerAnonToken() {
768
- return new Promise((resolve) => {
769
- const { https } = require('./user-agent')
770
- const machineId = _getMachineId()
771
- // lmcp-npm#92: no id, no registration. The binary mints its id and registers itself.
772
- if (!machineId) return resolve('')
773
- const payload = JSON.stringify({ machine_id: machineId })
774
- const req = https.request({
775
- host: BACKEND_HOST,
776
- port: 443,
777
- method: 'POST',
778
- path: '/tunnel/register-anon',
779
- headers: {
780
- 'Content-Type': 'application/json',
781
- 'Content-Length': Buffer.byteLength(payload),
782
- },
783
- timeout: 8000,
784
- }, (res) => {
785
- let buf = ''
786
- res.on('data', (chunk) => { buf += chunk })
787
- res.on('end', () => {
788
- try {
789
- const obj = JSON.parse(buf)
790
- const tok = (obj && typeof obj.token === 'string') ? obj.token : ''
791
- resolve(tok.startsWith('lmcp-') ? tok : '')
792
- } catch { resolve('') }
793
- })
794
- })
795
- req.on('error', () => resolve(''))
796
- req.on('timeout', () => { try { req.destroy() } catch {} resolve('') })
797
- req.write(payload)
798
- req.end()
799
- })
800
- }
801
-
802
726
  /**
803
727
  * Detects and removes the legacy com.local-mcp.server LaunchAgent left behind
804
728
  * by older curl installs. In the current architecture the tray app's
@@ -1028,6 +952,6 @@ module.exports = {
1028
952
  _notSupportedOnPlatformResult,
1029
953
  _launcherSpawnSpec, _writeLaunchScript, _writeLaunchSpec,
1030
954
  _getMachineId, _healthCheckSpec, _localMcpConfigDir, _installRefDir,
1031
- _cloudTokenPath, _readCachedCloudToken, _writeCloudToken, _registerAnonToken, _pingInstall,
955
+ _cloudTokenPath, _readCachedCloudToken, _pingInstall,
1032
956
  _fetchClientsCatalog, _trackSetupStep,
1033
957
  }