thinkpool-pair 0.7.72 → 0.7.73

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/launcher.mjs CHANGED
@@ -13,6 +13,7 @@
13
13
  import os from 'node:os'
14
14
  import fs from 'node:fs'
15
15
  import path from 'node:path'
16
+ import { execSync } from 'node:child_process'
16
17
 
17
18
  const HOME = os.homedir()
18
19
  const CFG_DIR = path.join(HOME, '.thinkpool-pair')
@@ -48,6 +49,18 @@ function serviceFile(room) {
48
49
  return path.join(startup, `thinkpool-pair-${room || 'account'}.cmd`)
49
50
  }
50
51
 
52
+ // Ground truth for the header: is the service actually LOADED, not just a plist on disk?
53
+ // `launchctl load` can silently no-op, leaving a plist that never loads — file-existence
54
+ // would report "installed" while the bridge is off (the 2026-06-26 bug). Query the manager.
55
+ function serviceLoaded(room) {
56
+ const label = room ? `io.thinkpool.pair.${room.toLowerCase()}` : 'io.thinkpool.pair.account'
57
+ try {
58
+ if (process.platform === 'darwin') { execSync(`launchctl print gui/$(id -u)/${label}`, { stdio: 'ignore' }); return true }
59
+ if (process.platform === 'linux') { execSync(`systemctl --user is-active --quiet ${label}.service`); return true }
60
+ return fs.existsSync(serviceFile(room)) // Windows: no daemon, file presence is the only proxy
61
+ } catch { return false }
62
+ }
63
+
51
64
  export function detectState() {
52
65
  const auth = readJson(path.join(CFG_DIR, 'auth.json'))
53
66
  const provider = readJson(path.join(CFG_DIR, 'provider.json'))
@@ -60,7 +73,7 @@ export function detectState() {
60
73
  provider: isCustom ? `Custom (${provider.baseUrl || 'endpoint'})` : 'Anthropic (default)',
61
74
  providerModel: isCustom ? (provider.model || null) : null,
62
75
  agents: KNOWN_AGENTS.filter(a => onPath(a.cmd)),
63
- accountSvc: fs.existsSync(serviceFile(null)),
76
+ accountSvc: serviceLoaded(null),
64
77
  cwd: process.cwd(),
65
78
  }
66
79
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "thinkpool-pair",
3
- "version": "0.7.72",
3
+ "version": "0.7.73",
4
4
  "description": "Share a local coding-agent CLI (Claude Code, Codex, Gemini, Aider, …) into a ThinkPool Code room, live.",
5
5
  "type": "module",
6
6
  "bin": {
package/service.mjs CHANGED
@@ -79,7 +79,13 @@ export function buildArtifact(platform, { room = null, cmdArgs = [], autoUpdate
79
79
  <key>StandardErrorPath</key><string>${xml(log)}</string>
80
80
  <key>EnvironmentVariables</key><dict><key>PATH</key><string>${xml(process.env.PATH || '')}</string>${autoUpdate ? '<key>THINKPOOL_PAIR_AUTOUPDATE</key><string>1</string>' : ''}</dict>
81
81
  </dict></plist>\n`
82
- return { file, content, logDir, post: [`launchctl unload "${file}" 2>/dev/null; launchctl load "${file}"`], note: 'Loaded as a LaunchAgent — starts at login, restarts on crash.' }
82
+ // Modern bootstrap/enable, NOT the deprecated `launchctl load`. On current macOS
83
+ // (Darwin 24/25) `load` silently no-ops for a GUI LaunchAgent — the plist lands on
84
+ // disk but never loads, so the bridge is "installed" yet off (the 2026-06-26 bug).
85
+ // bootout first (idempotent clean reinstall), enable to clear any stale `disabled`
86
+ // override left by a prior bootout (the account-storm cleanup), then bootstrap = load.
87
+ const dom = `gui/$(id -u)`
88
+ return { file, content, logDir, post: [`launchctl bootout ${dom}/${label(room)} 2>/dev/null; launchctl enable ${dom}/${label(room)}; launchctl bootstrap ${dom} "${file}"`], note: 'Loaded as a LaunchAgent — starts at login, restarts on crash.' }
83
89
  }
84
90
 
85
91
  if (platform === 'linux') {
@@ -173,18 +179,34 @@ export function restartService(room) {
173
179
  }
174
180
  }
175
181
 
176
- // Is a boot-persistent service already installed? (artifact file present.)
177
- // room falsy → checks the ACCOUNT service. Lets the main run skip the offer +
178
- // avoid starting a second bridge that would race the service.
182
+ // Ground truth: is the OS service manager ACTUALLY running our service right now?
183
+ // A leftover plist/unit on disk does NOT mean it's loaded — `launchctl load` can
184
+ // silently no-op (the 2026-06-26 "says installed but it's off" bug), and a unit can
185
+ // be left disabled. Ask the manager, don't trust file presence. room falsy → account.
186
+ export function serviceActive(room) {
187
+ const plat = process.platform
188
+ const id = label(room)
189
+ try {
190
+ if (plat === 'darwin') { execSync(`launchctl print gui/$(id -u)/${id}`, { stdio: 'ignore' }); return true }
191
+ if (plat === 'linux') { execSync(`systemctl --user is-active --quiet ${id}.service`); return true }
192
+ // Windows has no managed daemon — the Startup-folder script's presence is the only proxy.
193
+ return fs.existsSync(buildArtifact(plat, { room }).file)
194
+ } catch { return false }
195
+ }
196
+
197
+ // Is a boot-persistent service installed AND loaded? room falsy → the ACCOUNT service.
198
+ // Lets the main run skip the offer + avoid starting a second bridge that races the
199
+ // service. Reflects launchd/systemd reality, not just file existence (so a plist that
200
+ // failed to load reads as not-installed → the menu re-offers install, which self-heals).
179
201
  export function isServiceInstalled(room) {
180
- try { return fs.existsSync(buildArtifact(process.platform, { room }).file) } catch { return false }
202
+ return serviceActive(room)
181
203
  }
182
204
 
183
205
  export function uninstallService(room) {
184
206
  const plat = process.platform
185
207
  let a
186
208
  try { a = buildArtifact(plat, { room }) } catch (e) { process.stderr.write(` ⚠ ${e.message}\n`); return }
187
- if (plat === 'darwin') { try { execSync(`launchctl unload "${a.file}" 2>/dev/null`) } catch { /* noop */ } }
209
+ if (plat === 'darwin') { try { execSync(`launchctl bootout gui/$(id -u)/${label(room)} 2>/dev/null`) } catch { /* noop */ } }
188
210
  if (plat === 'linux') { try { execSync(`systemctl --user disable --now ${label(room)}.service 2>/dev/null`) } catch { /* noop */ } }
189
211
  try { fs.rmSync(a.file, { force: true }); process.stderr.write(` ◆ removed ${a.file}\n`) } catch (e) { process.stderr.write(` ⚠ ${e.message}\n`) }
190
212
  }