nexo-brain 7.12.10 → 7.12.14
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/.claude-plugin/plugin.json +1 -1
- package/README.md +1 -1
- package/bin/nexo-brain.js +76 -5
- package/package.json +1 -1
- package/src/auto_update.py +54 -6
- package/src/cli.py +35 -1
- package/src/client_sync.py +34 -6
- package/src/dashboard/app.py +81 -12
- package/src/desktop_bridge.py +10 -4
- package/src/hooks/pre-compact.sh +40 -9
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexo-brain",
|
|
3
|
-
"version": "7.12.
|
|
3
|
+
"version": "7.12.14",
|
|
4
4
|
"description": "Local cognitive runtime for Claude Code \u2014 persistent memory, overnight learning, doctor diagnostics, personal scripts, recovery-aware jobs, startup preflight, and optional dashboard/power helper.",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "NEXO Brain",
|
package/README.md
CHANGED
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
|
|
19
19
|
[Watch the overview video](https://nexo-brain.com/watch/) · [Watch on YouTube](https://www.youtube.com/watch?v=i2lkGhKyVqI) · [Open the infographic](https://nexo-brain.com/assets/nexo-brain-infographic-v5.png)
|
|
20
20
|
|
|
21
|
-
Version `7.12.
|
|
21
|
+
Version `7.12.14` is the current packaged-runtime line. Patch release — dashboard followup execution now respects the selected terminal client across macOS, Windows via WSL, and Linux instead of returning a macOS-only dead end. Result: operators can launch followups from the dashboard on every supported Brain host without hardcoding Claude-only or Mac-only assumptions.
|
|
22
22
|
|
|
23
23
|
Previously in `7.12.0`: minor release — adds `nexo support-snapshot` for generic local runtime diagnostics and completes the silent-reminder hardening on the live Protocol Enforcer path. The support collector emits one JSON bundle with version/platform metadata, runtime path presence, health-check output, and recent event/operation tails, while map-driven reminders (`nexo_startup`, `nexo_smart_startup`, `nexo_heartbeat`, `nexo_reminders`, `nexo_session_diary_*`, `nexo_stop`, `nexo_task_close`, compaction checkpoint prompts) now say explicitly that silence owns the entire reminder turn.
|
|
24
24
|
|
package/bin/nexo-brain.js
CHANGED
|
@@ -225,6 +225,50 @@ function run(cmd, opts = {}) {
|
|
|
225
225
|
}
|
|
226
226
|
}
|
|
227
227
|
|
|
228
|
+
function findBundledWheel(wheelsDir, prefix) {
|
|
229
|
+
try {
|
|
230
|
+
const normalizedPrefix = String(prefix || "").toLowerCase() + "-";
|
|
231
|
+
const matches = fs.readdirSync(wheelsDir)
|
|
232
|
+
.filter((name) => name.toLowerCase().startsWith(normalizedPrefix) && name.endsWith(".whl"))
|
|
233
|
+
.sort();
|
|
234
|
+
if (!matches.length) return "";
|
|
235
|
+
return path.join(wheelsDir, matches[matches.length - 1]);
|
|
236
|
+
} catch {
|
|
237
|
+
return "";
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function pythonHasPip(pythonBin) {
|
|
242
|
+
try {
|
|
243
|
+
const result = spawnSync(pythonBin, ["-m", "pip", "--version"], {
|
|
244
|
+
stdio: "ignore",
|
|
245
|
+
timeout: 15000,
|
|
246
|
+
});
|
|
247
|
+
return result.status === 0;
|
|
248
|
+
} catch {
|
|
249
|
+
return false;
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
function seedPipFromBundledWheels(venvPython, bundledWheelsDir) {
|
|
254
|
+
if (!fs.existsSync(venvPython) || !fs.existsSync(bundledWheelsDir)) return false;
|
|
255
|
+
if (pythonHasPip(venvPython)) return true;
|
|
256
|
+
const pipWheel = findBundledWheel(bundledWheelsDir, "pip");
|
|
257
|
+
if (!pipWheel) return false;
|
|
258
|
+
log(" Seeding pip into venv from bundled wheels...");
|
|
259
|
+
const result = spawnSync(venvPython, [
|
|
260
|
+
path.join(pipWheel, "pip"),
|
|
261
|
+
"install",
|
|
262
|
+
"--no-index",
|
|
263
|
+
"--find-links",
|
|
264
|
+
bundledWheelsDir,
|
|
265
|
+
"pip",
|
|
266
|
+
"setuptools",
|
|
267
|
+
"wheel",
|
|
268
|
+
], { stdio: "inherit", timeout: 120000 });
|
|
269
|
+
return result.status === 0 && pythonHasPip(venvPython);
|
|
270
|
+
}
|
|
271
|
+
|
|
228
272
|
function log(msg) {
|
|
229
273
|
console.log(` ${msg}`);
|
|
230
274
|
try {
|
|
@@ -360,7 +404,14 @@ function isOnboardingComplete(calibration) {
|
|
|
360
404
|
const meta = calibration.meta && typeof calibration.meta === "object" ? calibration.meta : {};
|
|
361
405
|
|
|
362
406
|
if (meta.onboarding_completed === true) {
|
|
363
|
-
|
|
407
|
+
// v7.12.11 — bug surfaced on Inma's smoke install 2026-05-03: Desktop
|
|
408
|
+
// bootstrap runs nexo-brain in --yes/--skip mode, which used to write
|
|
409
|
+
// `onboarding_completed: true` alongside the placeholder "Usuario"/"en"
|
|
410
|
+
// defaults. The Desktop wizard then never fired because this returned
|
|
411
|
+
// true on the very first launch. Treat a placeholder name as "marker is
|
|
412
|
+
// a lie, real onboarding never happened" so the renderer can still
|
|
413
|
+
// surface the wizard. Same guard applied to the legacy fallback below.
|
|
414
|
+
return nonEmptyString(name) && !isPlaceholderUserName(name) && nonEmptyString(language);
|
|
364
415
|
}
|
|
365
416
|
|
|
366
417
|
// Legacy fallback: v7.8/v7.9-era calibration files may not carry the
|
|
@@ -3440,8 +3491,16 @@ async function runSetup() {
|
|
|
3440
3491
|
execution_first: true,
|
|
3441
3492
|
},
|
|
3442
3493
|
meta: {
|
|
3443
|
-
onboarding_completed
|
|
3444
|
-
|
|
3494
|
+
// v7.12.11 — only mark onboarding_completed when the user actually
|
|
3495
|
+
// answered the prompts (interactive run, !useDefaults). The
|
|
3496
|
+
// Desktop bootstrap calls nexo-brain with `--yes/--skip` to set up
|
|
3497
|
+
// the runtime non-interactively; in that path the values are
|
|
3498
|
+
// placeholders ("Usuario" / "en" / "Nova") and the real wizard
|
|
3499
|
+
// lives in the renderer. Marking it complete here used to short-
|
|
3500
|
+
// circuit that wizard and leave new users staring at an empty chat
|
|
3501
|
+
// (Inma 2026-05-03 smoke install).
|
|
3502
|
+
onboarding_completed: !useDefaults,
|
|
3503
|
+
onboarding_completed_at: !useDefaults ? new Date().toISOString() : null,
|
|
3445
3504
|
},
|
|
3446
3505
|
auto_install: "ask", // updated later if user answers P11
|
|
3447
3506
|
calibrated_at: new Date().toISOString(),
|
|
@@ -3526,15 +3585,28 @@ async function runSetup() {
|
|
|
3526
3585
|
const venvPython = platform === "win32"
|
|
3527
3586
|
? path.join(venvPath, "Scripts", "python.exe")
|
|
3528
3587
|
: path.join(venvPath, "bin", "python3");
|
|
3588
|
+
const bundledWheelsDir = path.join(__dirname, "..", "python-wheels");
|
|
3529
3589
|
|
|
3530
3590
|
// Create venv if it doesn't exist
|
|
3531
3591
|
if (!fs.existsSync(venvPython)) {
|
|
3532
3592
|
log(" Creating Python virtual environment...");
|
|
3533
3593
|
const venvResult = spawnSync(python, ["-m", "venv", venvPath], { stdio: "inherit" });
|
|
3534
3594
|
if (venvResult.status !== 0) {
|
|
3535
|
-
|
|
3595
|
+
if (platform === "linux" && fs.existsSync(bundledWheelsDir)) {
|
|
3596
|
+
log(" Python venv could not seed pip; retrying offline without pip...");
|
|
3597
|
+
try { fs.rmSync(venvPath, { recursive: true, force: true }); } catch {}
|
|
3598
|
+
const bareVenv = spawnSync(python, ["-m", "venv", "--without-pip", venvPath], { stdio: "inherit" });
|
|
3599
|
+
if (bareVenv.status !== 0) {
|
|
3600
|
+
log("Failed to create venv. Trying pip install directly...");
|
|
3601
|
+
}
|
|
3602
|
+
} else {
|
|
3603
|
+
log("Failed to create venv. Trying pip install directly...");
|
|
3604
|
+
}
|
|
3536
3605
|
}
|
|
3537
3606
|
}
|
|
3607
|
+
if (fs.existsSync(venvPython) && !pythonHasPip(venvPython)) {
|
|
3608
|
+
seedPipFromBundledWheels(venvPython, bundledWheelsDir);
|
|
3609
|
+
}
|
|
3538
3610
|
|
|
3539
3611
|
// Use venv python if available, otherwise fall back to system python with --break-system-packages
|
|
3540
3612
|
const pipPython = fs.existsSync(venvPython) ? venvPython : python;
|
|
@@ -3542,7 +3614,6 @@ async function runSetup() {
|
|
|
3542
3614
|
// Detect bundled wheels in resources/python-wheels (offline-first). If
|
|
3543
3615
|
// present, pip uses --no-index --find-links to install without internet.
|
|
3544
3616
|
// Falls back to PyPI if bundle not found.
|
|
3545
|
-
const bundledWheelsDir = path.join(__dirname, "..", "python-wheels");
|
|
3546
3617
|
// v0.32.5 — el bundle empaca wheels manylinux (cp312 x86_64) porque
|
|
3547
3618
|
// en Win Brain corre dentro de WSL Ubuntu noble. En Mac, Brain corre
|
|
3548
3619
|
// nativo macOS y NO acepta esos wheels (ABI distinto). Si gateamos
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexo-brain",
|
|
3
|
-
"version": "7.12.
|
|
3
|
+
"version": "7.12.14",
|
|
4
4
|
"mcpName": "io.github.wazionapps/nexo",
|
|
5
5
|
"description": "NEXO Brain \u2014 Shared brain for AI agents. Persistent memory, semantic RAG, natural forgetting, metacognitive guard, trust scoring, 150+ MCP tools. Works with Claude Code, Codex, Claude Desktop & any MCP client. 100% local, free.",
|
|
6
6
|
"homepage": "https://nexo-brain.com",
|
package/src/auto_update.py
CHANGED
|
@@ -1233,11 +1233,9 @@ def _reload_launch_agents_after_bump() -> dict:
|
|
|
1233
1233
|
"errors": [{plist, stderr}],
|
|
1234
1234
|
}
|
|
1235
1235
|
|
|
1236
|
-
Linux
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
`nexo update` get the cron sync but not the per-timer restart yet).
|
|
1240
|
-
Captured as a TODO for the next round.
|
|
1236
|
+
Linux/WSL remains a no-op by default. Systemd user-unit reload can be
|
|
1237
|
+
enabled explicitly for development/runtime experiments, but public update
|
|
1238
|
+
paths must not restart host services unexpectedly.
|
|
1241
1239
|
"""
|
|
1242
1240
|
result: dict = {
|
|
1243
1241
|
"scanned": 0,
|
|
@@ -1247,8 +1245,58 @@ def _reload_launch_agents_after_bump() -> dict:
|
|
|
1247
1245
|
"platform": sys.platform,
|
|
1248
1246
|
}
|
|
1249
1247
|
|
|
1248
|
+
if sys.platform == "linux":
|
|
1249
|
+
if os.environ.get("NEXO_ENABLE_SYSTEMD_RELOAD_AFTER_BUMP") != "1":
|
|
1250
|
+
result["skipped_reason"] = "systemd-reload-disabled"
|
|
1251
|
+
return result
|
|
1252
|
+
|
|
1253
|
+
# Experimental Linux path: reload systemd user units so nexo-* timers
|
|
1254
|
+
# updated by auto-update pick up new ExecStart paths. Best-effort: a
|
|
1255
|
+
# missing systemd (Docker/CI/most WSL installs) just returns no-op.
|
|
1256
|
+
try:
|
|
1257
|
+
unit_dir = Path.home() / ".config" / "systemd" / "user"
|
|
1258
|
+
scanned_units = []
|
|
1259
|
+
if unit_dir.is_dir():
|
|
1260
|
+
scanned_units = sorted(
|
|
1261
|
+
[p for p in unit_dir.iterdir() if p.suffix in {".service", ".timer"} and p.name.startswith("nexo")]
|
|
1262
|
+
)
|
|
1263
|
+
result["scanned"] = len(scanned_units)
|
|
1264
|
+
if scanned_units:
|
|
1265
|
+
reload_proc = subprocess.run(
|
|
1266
|
+
["systemctl", "--user", "daemon-reload"],
|
|
1267
|
+
capture_output=True,
|
|
1268
|
+
text=True,
|
|
1269
|
+
timeout=15,
|
|
1270
|
+
)
|
|
1271
|
+
if reload_proc.returncode != 0:
|
|
1272
|
+
result["errors"].append({
|
|
1273
|
+
"unit": "daemon-reload",
|
|
1274
|
+
"stderr": (reload_proc.stderr or reload_proc.stdout or "").strip(),
|
|
1275
|
+
})
|
|
1276
|
+
else:
|
|
1277
|
+
for unit in scanned_units:
|
|
1278
|
+
restart = subprocess.run(
|
|
1279
|
+
["systemctl", "--user", "restart", unit.name],
|
|
1280
|
+
capture_output=True,
|
|
1281
|
+
text=True,
|
|
1282
|
+
timeout=15,
|
|
1283
|
+
)
|
|
1284
|
+
if restart.returncode == 0:
|
|
1285
|
+
result["reloaded"] += 1
|
|
1286
|
+
else:
|
|
1287
|
+
result["errors"].append({
|
|
1288
|
+
"unit": unit.name,
|
|
1289
|
+
"stderr": (restart.stderr or restart.stdout or "").strip(),
|
|
1290
|
+
})
|
|
1291
|
+
except FileNotFoundError:
|
|
1292
|
+
result["skipped_reason"] = "systemctl-not-available"
|
|
1293
|
+
except Exception as e:
|
|
1294
|
+
result["errors"].append({"unit": "*", "stderr": f"systemd reload failed: {e}"})
|
|
1295
|
+
return result
|
|
1296
|
+
|
|
1250
1297
|
if sys.platform != "darwin":
|
|
1251
|
-
#
|
|
1298
|
+
# Other platforms (win32 native — never reached because Brain runs
|
|
1299
|
+
# inside WSL Linux on Windows): nothing to reload.
|
|
1252
1300
|
return result
|
|
1253
1301
|
if _is_ephemeral_runtime_install():
|
|
1254
1302
|
result["skipped_reason"] = "ephemeral-runtime"
|
package/src/cli.py
CHANGED
|
@@ -1966,8 +1966,42 @@ def _service_control(service_name: str, action: str) -> int:
|
|
|
1966
1966
|
|
|
1967
1967
|
label = f"com.nexo.{service_name}"
|
|
1968
1968
|
|
|
1969
|
+
# v7.12.12 — Linux/WSL path uses systemd user units (`<service>.service`
|
|
1970
|
+
# in ~/.config/systemd/user/). Until 7.12.11 this stub printed
|
|
1971
|
+
# "supported only on macOS" and returned 1, leaving Linux operators
|
|
1972
|
+
# with no CLI to start/stop the brain — they had to learn systemctl
|
|
1973
|
+
# syntax themselves. Symmetric semantics: on=start, off=stop,
|
|
1974
|
+
# status=is-active. Names match the macOS labels with "nexo-" prefix.
|
|
1975
|
+
if plat.system() == "Linux":
|
|
1976
|
+
unit = f"nexo-{service_name}.service"
|
|
1977
|
+
if action == "status":
|
|
1978
|
+
result = subprocess.run(
|
|
1979
|
+
["systemctl", "--user", "is-active", unit],
|
|
1980
|
+
capture_output=True,
|
|
1981
|
+
text=True,
|
|
1982
|
+
)
|
|
1983
|
+
state = (result.stdout or "").strip() or "unknown"
|
|
1984
|
+
print(f"{service_name}: {'running' if state == 'active' else state}")
|
|
1985
|
+
return 0
|
|
1986
|
+
if action in ("on", "off"):
|
|
1987
|
+
verb = "start" if action == "on" else "stop"
|
|
1988
|
+
result = subprocess.run(
|
|
1989
|
+
["systemctl", "--user", verb, unit],
|
|
1990
|
+
capture_output=True,
|
|
1991
|
+
text=True,
|
|
1992
|
+
)
|
|
1993
|
+
if result.returncode == 0:
|
|
1994
|
+
print(f"{service_name}: {'started' if action == 'on' else 'stopped'}")
|
|
1995
|
+
return 0
|
|
1996
|
+
err = (result.stderr or result.stdout or "").strip()
|
|
1997
|
+
print(f"Failed to {verb} {service_name}: {err}", file=sys.stderr)
|
|
1998
|
+
print(f"Hint: install the unit at ~/.config/systemd/user/{unit}", file=sys.stderr)
|
|
1999
|
+
return 1
|
|
2000
|
+
print(f"Unknown action: {action}. Use on, off, or status.", file=sys.stderr)
|
|
2001
|
+
return 1
|
|
2002
|
+
|
|
1969
2003
|
if plat.system() != "Darwin":
|
|
1970
|
-
print(f"Service control
|
|
2004
|
+
print(f"Service control not supported on this platform: {plat.system()}", file=sys.stderr)
|
|
1971
2005
|
return 1
|
|
1972
2006
|
|
|
1973
2007
|
plist_path = Path.home() / "Library" / "LaunchAgents" / f"{label}.plist"
|
package/src/client_sync.py
CHANGED
|
@@ -396,15 +396,20 @@ def ensure_claude_code_installed(*, user_home: str | os.PathLike[str] | None = N
|
|
|
396
396
|
"attempts": attempts,
|
|
397
397
|
}
|
|
398
398
|
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
)
|
|
399
|
+
# v7.12.12 — try npm without sudo first on Linux. Hardcoding `sudo`
|
|
400
|
+
# used to make sense on stock Ubuntu where /usr/lib/node_modules is
|
|
401
|
+
# root-owned, but inside the WSL distro NEXO Desktop ships, the
|
|
402
|
+
# default global prefix is already `/home/<user>/.nexo/runtime/
|
|
403
|
+
# bootstrap/npm-global` (writable). A blind `sudo` there triggers a
|
|
404
|
+
# password prompt on a TTY the user cannot see, so the bootstrap
|
|
405
|
+
# appears stuck. Try unprivileged first; if it fails with EACCES
|
|
406
|
+
# (insufficient permissions), retry with sudo.
|
|
404
407
|
install_error = ""
|
|
408
|
+
install = None
|
|
409
|
+
base_cmd = ["npm", "install", "-g", CLAUDE_CODE_NPM_PACKAGE]
|
|
405
410
|
try:
|
|
406
411
|
install = subprocess.run(
|
|
407
|
-
|
|
412
|
+
base_cmd,
|
|
408
413
|
capture_output=True,
|
|
409
414
|
text=True,
|
|
410
415
|
timeout=180,
|
|
@@ -413,6 +418,29 @@ def ensure_claude_code_installed(*, user_home: str | os.PathLike[str] | None = N
|
|
|
413
418
|
if install.returncode != 0:
|
|
414
419
|
install_error = (install.stderr or install.stdout or "npm install failed").strip()
|
|
415
420
|
attempts.append(install_error)
|
|
421
|
+
permission_failure = (
|
|
422
|
+
"EACCES" in install_error
|
|
423
|
+
or "permission denied" in install_error.lower()
|
|
424
|
+
or "operation not permitted" in install_error.lower()
|
|
425
|
+
)
|
|
426
|
+
if permission_failure and sys.platform == "linux":
|
|
427
|
+
attempts.append("retrying with sudo (Linux EACCES fallback)")
|
|
428
|
+
try:
|
|
429
|
+
install = subprocess.run(
|
|
430
|
+
["sudo", "-n", "npm", "install", "-g", CLAUDE_CODE_NPM_PACKAGE],
|
|
431
|
+
capture_output=True,
|
|
432
|
+
text=True,
|
|
433
|
+
timeout=180,
|
|
434
|
+
env=env,
|
|
435
|
+
)
|
|
436
|
+
if install.returncode != 0:
|
|
437
|
+
install_error = (install.stderr or install.stdout or "sudo npm install failed").strip()
|
|
438
|
+
attempts.append(install_error)
|
|
439
|
+
else:
|
|
440
|
+
install_error = ""
|
|
441
|
+
except Exception as exc:
|
|
442
|
+
install_error = f"sudo npm install failed: {exc}"
|
|
443
|
+
attempts.append(install_error)
|
|
416
444
|
except Exception as exc:
|
|
417
445
|
install_error = f"npm install failed: {exc}"
|
|
418
446
|
attempts.append(install_error)
|
package/src/dashboard/app.py
CHANGED
|
@@ -1101,26 +1101,82 @@ async def api_ops_execute(fid: str):
|
|
|
1101
1101
|
if not row:
|
|
1102
1102
|
return JSONResponse({"error": f"Followup {fid} not found"}, status_code=404)
|
|
1103
1103
|
item = dict(row)
|
|
1104
|
-
if platform.system() != "Darwin":
|
|
1105
|
-
return JSONResponse(
|
|
1106
|
-
{"error": "This operation requires macOS (uses osascript to open Terminal)"},
|
|
1107
|
-
status_code=501,
|
|
1108
|
-
)
|
|
1109
1104
|
# Security: avoid interpolating user-controlled data into shell commands.
|
|
1110
|
-
# Write the followup ID to a temp file and pass a safe, fixed command
|
|
1105
|
+
# Write the followup ID to a temp file and pass a safe, fixed command.
|
|
1111
1106
|
import tempfile
|
|
1112
1107
|
tmp = tempfile.NamedTemporaryFile(mode="w", suffix=".txt", prefix="nexo-followup-", delete=False)
|
|
1113
1108
|
tmp.write(fid)
|
|
1114
1109
|
tmp.close()
|
|
1115
|
-
# The selected terminal client reads the followup ID from the temp file — no shell interpolation of description
|
|
1116
1110
|
try:
|
|
1111
|
+
# Use the selected terminal client from NEXO preferences (Claude Code or
|
|
1112
|
+
# Codex) instead of hardcoding a launcher in the dashboard.
|
|
1117
1113
|
_, shell_cmd = build_followup_terminal_shell_command(tmp.name)
|
|
1118
1114
|
except AgentRunnerError as exc:
|
|
1119
1115
|
return JSONResponse({"error": str(exc)}, status_code=503)
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1116
|
+
|
|
1117
|
+
system = platform.system()
|
|
1118
|
+
if system == "Darwin":
|
|
1119
|
+
# macOS: open Terminal.app via osascript (legacy path).
|
|
1120
|
+
escaped = shell_cmd.replace("\\", "\\\\").replace('"', '\\"')
|
|
1121
|
+
script = f'tell application "Terminal" to do script "{escaped}"'
|
|
1122
|
+
subprocess.Popen(["osascript", "-e", script])
|
|
1123
|
+
return {"success": True, "followup_id": fid, "platform": "darwin"}
|
|
1124
|
+
|
|
1125
|
+
# 7.12.14 — Windows / WSL parity. Until now this endpoint returned 501
|
|
1126
|
+
# on any non-Darwin host, leaving Win11 users without a way to launch
|
|
1127
|
+
# followups from the dashboard. We detect WSL via WSL_DISTRO_NAME /
|
|
1128
|
+
# /proc/sys/fs/binfmt_misc/WSLInterop and shell out through Win
|
|
1129
|
+
# interop (cmd.exe /c start ... wt.exe) so the user gets a real
|
|
1130
|
+
# Windows Terminal tab running `wsl.exe -d <distro> -- bash -lc "<cmd>"`
|
|
1131
|
+
# — matching the Mac UX of "click → terminal opens with claude waiting".
|
|
1132
|
+
is_wsl = bool(os.environ.get("WSL_DISTRO_NAME")) or os.path.exists(
|
|
1133
|
+
"/proc/sys/fs/binfmt_misc/WSLInterop"
|
|
1134
|
+
)
|
|
1135
|
+
if is_wsl:
|
|
1136
|
+
distro = os.environ.get("WSL_DISTRO_NAME") or "Ubuntu-24.04"
|
|
1137
|
+
# Quote the bash command for cmd.exe; cmd's start unwraps one level
|
|
1138
|
+
# so we double-escape inner double quotes.
|
|
1139
|
+
bash_cmd = shell_cmd.replace('"', '\\"')
|
|
1140
|
+
wsl_invoke = f'wsl.exe -d {distro} -- bash -lc "{bash_cmd}"'
|
|
1141
|
+
try:
|
|
1142
|
+
subprocess.Popen(
|
|
1143
|
+
["cmd.exe", "/c", "start", "", "wt.exe", "new-tab", "--", "cmd.exe", "/k", wsl_invoke],
|
|
1144
|
+
stdout=subprocess.DEVNULL,
|
|
1145
|
+
stderr=subprocess.DEVNULL,
|
|
1146
|
+
)
|
|
1147
|
+
except FileNotFoundError:
|
|
1148
|
+
return JSONResponse(
|
|
1149
|
+
{
|
|
1150
|
+
"error": "Could not launch Windows Terminal automatically.",
|
|
1151
|
+
"manual_command": wsl_invoke,
|
|
1152
|
+
"followup_id": fid,
|
|
1153
|
+
},
|
|
1154
|
+
status_code=503,
|
|
1155
|
+
)
|
|
1156
|
+
return {"success": True, "followup_id": fid, "platform": "wsl", "distro": distro}
|
|
1157
|
+
|
|
1158
|
+
# Pure Linux (no WSL): try common terminal emulators in order, then
|
|
1159
|
+
# fall back to returning the manual command. Best-effort because the
|
|
1160
|
+
# dashboard is primarily Mac + WSL.
|
|
1161
|
+
from shutil import which
|
|
1162
|
+
for emulator in ("x-terminal-emulator", "gnome-terminal", "konsole", "xterm"):
|
|
1163
|
+
if which(emulator):
|
|
1164
|
+
try:
|
|
1165
|
+
if emulator == "gnome-terminal":
|
|
1166
|
+
subprocess.Popen([emulator, "--", "bash", "-lc", shell_cmd])
|
|
1167
|
+
else:
|
|
1168
|
+
subprocess.Popen([emulator, "-e", shell_cmd])
|
|
1169
|
+
return {"success": True, "followup_id": fid, "platform": "linux", "emulator": emulator}
|
|
1170
|
+
except OSError:
|
|
1171
|
+
continue
|
|
1172
|
+
return JSONResponse(
|
|
1173
|
+
{
|
|
1174
|
+
"error": "No terminal emulator available to launch the followup automatically.",
|
|
1175
|
+
"manual_command": shell_cmd,
|
|
1176
|
+
"followup_id": fid,
|
|
1177
|
+
},
|
|
1178
|
+
status_code=503,
|
|
1179
|
+
)
|
|
1124
1180
|
|
|
1125
1181
|
|
|
1126
1182
|
# ---------------------------------------------------------------------------
|
|
@@ -1959,8 +2015,21 @@ def main():
|
|
|
1959
2015
|
webbrowser.open(f"http://localhost:{args.port}")
|
|
1960
2016
|
threading.Thread(target=_open, daemon=True).start()
|
|
1961
2017
|
|
|
2018
|
+
# v7.12.12 — bind 0.0.0.0 when running inside WSL so the Windows host
|
|
2019
|
+
# can reach the dashboard. WSL2 does auto port forwarding for 127.0.0.1
|
|
2020
|
+
# in most setups, but corporate networks and certain WSL versions break
|
|
2021
|
+
# the loopback bridge; binding all interfaces inside the guest closes
|
|
2022
|
+
# that gap with no security cost (the WSL guest is private to the
|
|
2023
|
+
# logged-in Windows user). On Mac/Linux native, keep 127.0.0.1.
|
|
2024
|
+
bind_host = "127.0.0.1"
|
|
2025
|
+
try:
|
|
2026
|
+
from src.windows_runtime import running_inside_wsl # type: ignore
|
|
2027
|
+
if running_inside_wsl():
|
|
2028
|
+
bind_host = "0.0.0.0"
|
|
2029
|
+
except Exception:
|
|
2030
|
+
pass
|
|
1962
2031
|
import uvicorn
|
|
1963
|
-
uvicorn.run(app, host=
|
|
2032
|
+
uvicorn.run(app, host=bind_host, port=args.port, log_level="info")
|
|
1964
2033
|
|
|
1965
2034
|
|
|
1966
2035
|
if __name__ == "__main__":
|
package/src/desktop_bridge.py
CHANGED
|
@@ -405,14 +405,20 @@ def _onboard_steps() -> list[dict]:
|
|
|
405
405
|
"id": "residence",
|
|
406
406
|
"prompt": {"es": "¿Dónde vives o trabajas habitualmente?", "en": "Where do you live or work most days?"},
|
|
407
407
|
"hint": {
|
|
408
|
-
"es": "
|
|
409
|
-
"en": "
|
|
408
|
+
"es": "Empieza a escribir y elige tu ciudad. Guardo coordenadas para clima, horarios, etc.",
|
|
409
|
+
"en": "Start typing and pick your city. We save coordinates for weather, schedules, and so on.",
|
|
410
410
|
},
|
|
411
|
-
|
|
411
|
+
# v7.12.13 — `city` triggers the geocoding autocomplete in the
|
|
412
|
+
# renderer (CityStep talks to Nominatim and writes a JSON
|
|
413
|
+
# payload with display, name, lat, lon, country). The weather
|
|
414
|
+
# widget and any future location-aware feature can then read
|
|
415
|
+
# real coordinates from profile.current_residence instead of
|
|
416
|
+
# a free-text label.
|
|
417
|
+
"type": "city",
|
|
412
418
|
"writes": "profile.current_residence",
|
|
413
419
|
"file": "profile.json",
|
|
414
420
|
"optional": True,
|
|
415
|
-
"validate": r"^.{0,
|
|
421
|
+
"validate": r"^.{0,2000}$",
|
|
416
422
|
},
|
|
417
423
|
{
|
|
418
424
|
"id": "role",
|
package/src/hooks/pre-compact.sh
CHANGED
|
@@ -230,24 +230,55 @@ conn.execute('''
|
|
|
230
230
|
''', (sid, decisions, pending, context_next, summary))
|
|
231
231
|
conn.commit()
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
conn.close()
|
|
234
|
+
" 2>/dev/null || true
|
|
235
|
+
|
|
236
|
+
# Layer 3: structured auto-flush is useful but non-critical. Keep it
|
|
237
|
+
# best-effort in the background so pre-compaction never blocks on heavy
|
|
238
|
+
# imports, vector backends, or ingestion latency after the emergency diary
|
|
239
|
+
# has already been committed.
|
|
240
|
+
(
|
|
241
|
+
NEXO_PRECOMPACT_SID="$TARGET_SID" \
|
|
242
|
+
NEXO_PRECOMPACT_LOG_FILE="$LOG_FILE" \
|
|
243
|
+
HOOK_DIR="$HOOK_DIR" \
|
|
244
|
+
python3 - <<'PY'
|
|
245
|
+
import os
|
|
246
|
+
import sqlite3
|
|
247
|
+
import sys
|
|
248
|
+
|
|
249
|
+
sid = os.environ.get("NEXO_PRECOMPACT_SID", "")
|
|
250
|
+
log_file = os.environ.get("NEXO_PRECOMPACT_LOG_FILE", "")
|
|
251
|
+
hook_dir = os.environ.get("HOOK_DIR", "")
|
|
252
|
+
if not sid or not hook_dir:
|
|
253
|
+
sys.exit(0)
|
|
254
|
+
|
|
255
|
+
sys.path.insert(0, os.path.abspath(os.path.join(hook_dir, "..")))
|
|
234
256
|
try:
|
|
235
|
-
import
|
|
236
|
-
|
|
257
|
+
import paths
|
|
258
|
+
|
|
259
|
+
task = ""
|
|
260
|
+
try:
|
|
261
|
+
conn = sqlite3.connect(str(paths.db_path()), timeout=3)
|
|
262
|
+
row = conn.execute("SELECT task FROM sessions WHERE sid = ? LIMIT 1", (sid,)).fetchone()
|
|
263
|
+
task = (row[0] if row else "") or ""
|
|
264
|
+
conn.close()
|
|
265
|
+
except Exception:
|
|
266
|
+
task = ""
|
|
267
|
+
|
|
237
268
|
import compaction_memory
|
|
269
|
+
|
|
238
270
|
compaction_memory.record_auto_flush(
|
|
239
271
|
session_id=sid,
|
|
240
272
|
task=task,
|
|
241
|
-
current_goal=
|
|
273
|
+
current_goal="",
|
|
242
274
|
log_file=log_file,
|
|
243
|
-
last_diary_ts=
|
|
244
|
-
source=
|
|
275
|
+
last_diary_ts="",
|
|
276
|
+
source="pre-compact-hook",
|
|
245
277
|
)
|
|
246
278
|
except Exception:
|
|
247
279
|
pass
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
" 2>/dev/null || true
|
|
280
|
+
PY
|
|
281
|
+
) >/dev/null 2>&1 &
|
|
251
282
|
fi
|
|
252
283
|
|
|
253
284
|
cat << HOOKEOF
|