@rubytech/create-maxy-lite 0.1.14 → 0.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/lib/paths.mjs CHANGED
@@ -183,7 +183,14 @@ export function launcherScript({
183
183
  port = PATHS.webchatPort,
184
184
  distro = PATHS.distro,
185
185
  } = {}) {
186
- const inner = `cd ${webchatDir} && ${webchatRunEnv({ vaultGuest, port })} exec node server.mjs`
186
+ // Kill any prior relay before starting so `maxy-lite` always runs the freshly
187
+ // installed server.mjs, never a stale process still holding the port (which made
188
+ // a new build appear to "have no effect"). The relay writes its pid to
189
+ // <vault>/.maxy-lite/relay.pid; kill via the bash builtin (no external tools),
190
+ // and a best-effort pkill catches a relay started before pid-file support. The
191
+ // relay's own EADDRINUSE handler makes any remaining conflict loud.
192
+ const killPrior = `P=$(cat ${vaultGuest}/.maxy-lite/relay.pid 2>/dev/null); [ -n "$P" ] && kill "$P" 2>/dev/null; pkill -f "node server.mjs" 2>/dev/null; sleep 1`
193
+ const inner = `${killPrior}; cd ${webchatDir} && ${webchatRunEnv({ vaultGuest, port })} exec node server.mjs`
187
194
  return `#!${prefix}/bin/bash
188
195
  # maxy-lite launcher — starts the on-device web chat relay.
189
196
  # Enters the glibc Ubuntu layer with the shared-storage vault bound in, then runs
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rubytech/create-maxy-lite",
3
- "version": "0.1.14",
3
+ "version": "0.1.15",
4
4
  "description": "Install maxy-lite on an Android phone: orchestrates proot-distro Ubuntu, glibc Node, claude, the web-chat relay, the vault and its bind-mount — run via npx in bare Termux.",
5
5
  "type": "module",
6
6
  "engines": {
@@ -34,6 +34,7 @@ const CLAUDE_BIN = process.env.LITE_CLAUDE_BIN || 'claude'
34
34
  const PROJECTS_DIR = path.join(os.homedir(), '.claude', 'projects')
35
35
  const STATE_DIR = process.env.LITE_STATE_DIR || path.join(AGENT_HOME, '.maxy-lite')
36
36
  const SESSION_FILE = path.join(STATE_DIR, 'session-id')
37
+ const PID_FILE = path.join(STATE_DIR, 'relay.pid') // so the launcher can kill a prior relay before starting a fresh one
37
38
  const TAIL_MS = 250 // JSONL poll interval
38
39
  const QUIET_MS = 1500 // silence that ends a turn for op=done
39
40
  const NO_REPLY_MS = 8000 // a turn with NO transcript growth this long = swallowed; surface why
@@ -261,6 +262,22 @@ wss.on('connection', (ws) => {
261
262
  })
262
263
  })
263
264
 
265
+ // A stale relay still holding the port is the usual cause of "new build installed
266
+ // but old code serving". Make it loud instead of a silent stale-serve.
267
+ server.on('error', (e) => {
268
+ log('listen-error', { code: e.code, port: PORT })
269
+ process.exit(1)
270
+ })
264
271
  server.listen(PORT, '127.0.0.1', () => {
272
+ // Record our pid so the next launch can kill this relay and take over cleanly,
273
+ // and emit a build marker: op=relay-start proves THIS server.mjs (not a stale
274
+ // one) is the live process.
275
+ try {
276
+ fs.mkdirSync(STATE_DIR, { recursive: true })
277
+ fs.writeFileSync(PID_FILE, String(process.pid))
278
+ } catch {
279
+ /* pid file is best-effort */
280
+ }
281
+ log('relay-start', { pid: process.pid, port: PORT })
265
282
  log('listening', { port: PORT, sessionId, home: AGENT_HOME })
266
283
  })