nexo-brain 7.9.21 → 7.9.22
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 +3 -1
- package/package.json +1 -1
- package/src/cli.py +25 -0
- package/src/lifecycle_events.py +132 -0
- package/src/plugins/lifecycle_events.py +26 -0
- package/src/runtime_versioning.py +1 -0
- package/tool-enforcement-map.json +13 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexo-brain",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.22",
|
|
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,9 @@
|
|
|
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.9.
|
|
21
|
+
Version `7.9.22` is the current packaged-runtime line. Patch release over `7.9.21`: Desktop lifecycle shutdowns now have an emergency Brain-side fallback diary path, so close/archive/app-exit can preserve title, goal, session ids, and transcript tail even when the live agent does not answer the injected diary prompt before shutdown.
|
|
22
|
+
|
|
23
|
+
Previously in `7.9.21`: LaunchAgent reload/repair now handles macOS already-loaded races by booting out jobs with modern launchctl forms, falling back to legacy load, and treating an already-loaded job as healthy only when it points at the expected plist.
|
|
22
24
|
|
|
23
25
|
Previously in `7.9.20`: packaged update/doctor repair now finds `runtime/crons/sync.py`, LaunchAgent PATH includes the managed Claude runtime installed under `~/.nexo/runtime/bootstrap/npm-global/bin`, root runtime backfill includes `claude_cli.py`, and Immune no longer treats the legacy optional `~/.claude-mem/claude-mem.db` as a required database.
|
|
24
26
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nexo-brain",
|
|
3
|
-
"version": "7.9.
|
|
3
|
+
"version": "7.9.22",
|
|
4
4
|
"mcpName": "io.github.wazionapps/nexo",
|
|
5
5
|
"description": "NEXO Brain — 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/cli.py
CHANGED
|
@@ -3232,6 +3232,14 @@ def main():
|
|
|
3232
3232
|
lwait_p.add_argument("--timeout-ms", type=int, default=45_000)
|
|
3233
3233
|
lwait_p.add_argument("--poll-ms", type=int, default=500)
|
|
3234
3234
|
|
|
3235
|
+
lfallback_diary_p = lifecycle_sub.add_parser(
|
|
3236
|
+
"write-fallback-diary",
|
|
3237
|
+
help="v7.9.22: write emergency diary evidence for a lifecycle event",
|
|
3238
|
+
)
|
|
3239
|
+
lfallback_diary_p.add_argument("--event-id", required=True)
|
|
3240
|
+
lfallback_diary_p.add_argument("--reason", default="")
|
|
3241
|
+
lfallback_diary_p.add_argument("--source", default="desktop-lifecycle-fallback")
|
|
3242
|
+
|
|
3235
3243
|
lwait_stop_p = lifecycle_sub.add_parser(
|
|
3236
3244
|
"wait-for-stop",
|
|
3237
3245
|
help="v7.9.10: wait until the linked NEXO session is no longer active",
|
|
@@ -3547,6 +3555,23 @@ def main():
|
|
|
3547
3555
|
if status == "retryable_error":
|
|
3548
3556
|
return 2
|
|
3549
3557
|
return 3
|
|
3558
|
+
if args.lifecycle_command == "write-fallback-diary":
|
|
3559
|
+
out = _lifecycle_plugin.handle_nexo_lifecycle_write_fallback_diary(
|
|
3560
|
+
event_id=args.event_id,
|
|
3561
|
+
reason=args.reason or "",
|
|
3562
|
+
source=args.source or "desktop-lifecycle-fallback",
|
|
3563
|
+
)
|
|
3564
|
+
print(out)
|
|
3565
|
+
try:
|
|
3566
|
+
parsed = _json.loads(out)
|
|
3567
|
+
status = str(parsed.get("status", ""))
|
|
3568
|
+
except Exception:
|
|
3569
|
+
status = ""
|
|
3570
|
+
if status in ("ok", "processed", "already_processed"):
|
|
3571
|
+
return 0
|
|
3572
|
+
if status == "retryable_error":
|
|
3573
|
+
return 2
|
|
3574
|
+
return 3
|
|
3550
3575
|
if args.lifecycle_command == "wait-for-stop":
|
|
3551
3576
|
out = _lifecycle_plugin.handle_nexo_lifecycle_wait_for_stop(
|
|
3552
3577
|
event_id=args.event_id,
|
package/src/lifecycle_events.py
CHANGED
|
@@ -260,6 +260,138 @@ def _session_diary_since(conn, session_id: str, dispatched_at: Optional[str], ac
|
|
|
260
260
|
return _session_diary_evidence(conn, session_id, dispatched_at, actions_json) is not None
|
|
261
261
|
|
|
262
262
|
|
|
263
|
+
def _preferred_diary_session_id(conn, session_id: str) -> str:
|
|
264
|
+
"""Return the best session id to store fallback diary evidence under."""
|
|
265
|
+
raw = str(session_id or "").strip()
|
|
266
|
+
candidates = _session_diary_session_ids(conn, raw)
|
|
267
|
+
for sid in candidates:
|
|
268
|
+
if str(sid or "").startswith("nexo-"):
|
|
269
|
+
return str(sid)
|
|
270
|
+
return candidates[0] if candidates else raw
|
|
271
|
+
|
|
272
|
+
|
|
273
|
+
def _payload_lines(payload: Dict[str, Any]) -> List[str]:
|
|
274
|
+
lines: List[str] = []
|
|
275
|
+
if not isinstance(payload, dict):
|
|
276
|
+
return lines
|
|
277
|
+
for raw in payload.get("transcript_tail") or []:
|
|
278
|
+
text = str(raw or "").strip()
|
|
279
|
+
if text:
|
|
280
|
+
lines.append(text)
|
|
281
|
+
if not lines:
|
|
282
|
+
user = str(payload.get("last_user_message") or payload.get("latest_user_text") or "").strip()
|
|
283
|
+
assistant = str(payload.get("last_assistant_message") or payload.get("latest_assistant_text") or "").strip()
|
|
284
|
+
if user:
|
|
285
|
+
lines.append(f"user: {user}")
|
|
286
|
+
if assistant:
|
|
287
|
+
lines.append(f"assistant: {assistant}")
|
|
288
|
+
return lines[-12:]
|
|
289
|
+
|
|
290
|
+
|
|
291
|
+
def write_fallback_diary_for_lifecycle_event(
|
|
292
|
+
event_id: str,
|
|
293
|
+
reason: str = "",
|
|
294
|
+
source: str = "desktop-lifecycle-fallback",
|
|
295
|
+
) -> Dict[str, Any]:
|
|
296
|
+
"""Write minimum durable diary evidence when live-agent injection fails.
|
|
297
|
+
|
|
298
|
+
This is the safety net for Desktop close/archive/app-exit. The preferred
|
|
299
|
+
path remains an agent-authored ``nexo_session_diary_write``. If the agent is
|
|
300
|
+
busy or stdin never produces a response, Desktop can call this command so
|
|
301
|
+
session continuity still has a concrete ``session_diary`` row instead of
|
|
302
|
+
silently losing the last context.
|
|
303
|
+
"""
|
|
304
|
+
if not event_id:
|
|
305
|
+
return {"status": "rejected", "reason": "missing-event-id"}
|
|
306
|
+
|
|
307
|
+
conn = get_db()
|
|
308
|
+
row = conn.execute(
|
|
309
|
+
"SELECT action, conversation_id, session_id, reason, payload_snapshot, "
|
|
310
|
+
"canonical_dispatched_at, canonical_actions_json "
|
|
311
|
+
"FROM lifecycle_events WHERE event_id = ?",
|
|
312
|
+
(str(event_id),),
|
|
313
|
+
).fetchone()
|
|
314
|
+
if row is None:
|
|
315
|
+
return {"status": "rejected", "reason": "unknown-event-id", "event_id": event_id}
|
|
316
|
+
|
|
317
|
+
action = str(row[0] or "")
|
|
318
|
+
conversation_id = str(row[1] or "")
|
|
319
|
+
session_id = str(row[2] or "")
|
|
320
|
+
lifecycle_reason = str(row[3] or "")
|
|
321
|
+
dispatched_at = row[5]
|
|
322
|
+
actions_json = row[6]
|
|
323
|
+
if action not in _DIARY_TRIGGERING:
|
|
324
|
+
return {"status": "processed", "event_id": event_id, "diary_required": False}
|
|
325
|
+
if not session_id:
|
|
326
|
+
return {"status": "rejected", "reason": "missing-session-id", "event_id": event_id}
|
|
327
|
+
|
|
328
|
+
existing = _session_diary_evidence(conn, session_id, dispatched_at, actions_json)
|
|
329
|
+
if existing is not None:
|
|
330
|
+
return {
|
|
331
|
+
"status": "ok",
|
|
332
|
+
"event_id": event_id,
|
|
333
|
+
"fallback_written": False,
|
|
334
|
+
"diary_confirmed": True,
|
|
335
|
+
**existing,
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
try:
|
|
339
|
+
payload = json.loads(row[4] or "{}")
|
|
340
|
+
if not isinstance(payload, dict):
|
|
341
|
+
payload = {}
|
|
342
|
+
except Exception:
|
|
343
|
+
payload = {}
|
|
344
|
+
|
|
345
|
+
title = str(payload.get("title") or conversation_id or event_id).strip()
|
|
346
|
+
transcript_lines = _payload_lines(payload)
|
|
347
|
+
technical_reason = str(reason or lifecycle_reason or "fallback-diary").strip()
|
|
348
|
+
diary_session_id = _preferred_diary_session_id(conn, session_id)
|
|
349
|
+
summary = (
|
|
350
|
+
"Diario automatico de emergencia generado por NEXO Desktop al cerrar "
|
|
351
|
+
f"'{title}'. No se confirmo un diario escrito por el agente vivo, asi "
|
|
352
|
+
"que se preserva el snapshot disponible para continuidad."
|
|
353
|
+
)
|
|
354
|
+
decisions = (
|
|
355
|
+
f"Accion de ciclo de vida: {action}. Evento: {event_id}. "
|
|
356
|
+
f"Motivo tecnico: {technical_reason}."
|
|
357
|
+
)
|
|
358
|
+
pending = str(payload.get("current_goal") or payload.get("last_user_message") or "").strip()
|
|
359
|
+
if not pending:
|
|
360
|
+
pending = "Revisar la conversacion al reabrir y continuar desde el snapshot preservado."
|
|
361
|
+
context_next_parts = [
|
|
362
|
+
f"conversation_id={conversation_id}",
|
|
363
|
+
f"session_id={session_id}",
|
|
364
|
+
]
|
|
365
|
+
if transcript_lines:
|
|
366
|
+
context_next_parts.append("Transcript tail:\n" + "\n".join(transcript_lines))
|
|
367
|
+
context_next = "\n".join(context_next_parts)[:8000]
|
|
368
|
+
|
|
369
|
+
from db import write_session_diary
|
|
370
|
+
|
|
371
|
+
diary = write_session_diary(
|
|
372
|
+
diary_session_id,
|
|
373
|
+
decisions=decisions,
|
|
374
|
+
summary=summary,
|
|
375
|
+
discarded="",
|
|
376
|
+
pending=pending,
|
|
377
|
+
context_next=context_next,
|
|
378
|
+
mental_state="Fallback automatico: el agente vivo no confirmo el cierre dentro del timeout.",
|
|
379
|
+
domain="nexo-desktop",
|
|
380
|
+
user_signals="Cierre/archivo de conversacion; preservar informacion antes de salir.",
|
|
381
|
+
self_critique="El cierre no debe depender exclusivamente de que el agente responda a tiempo.",
|
|
382
|
+
source=source or "desktop-lifecycle-fallback",
|
|
383
|
+
)
|
|
384
|
+
return {
|
|
385
|
+
"status": "ok",
|
|
386
|
+
"event_id": event_id,
|
|
387
|
+
"fallback_written": True,
|
|
388
|
+
"diary_confirmed": True,
|
|
389
|
+
"session_diary_id": diary.get("id"),
|
|
390
|
+
"diary_session_id": diary_session_id,
|
|
391
|
+
"source": source or "desktop-lifecycle-fallback",
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
|
|
263
395
|
def _session_stop_state(conn, session_id: str) -> Dict[str, Any]:
|
|
264
396
|
"""Return whether the lifecycle session can be verified as fully stopped."""
|
|
265
397
|
raw = str(session_id or "").strip()
|
|
@@ -168,6 +168,27 @@ def handle_nexo_lifecycle_wait_for_diary(
|
|
|
168
168
|
return json.dumps(ack, ensure_ascii=False)
|
|
169
169
|
|
|
170
170
|
|
|
171
|
+
def handle_nexo_lifecycle_write_fallback_diary(
|
|
172
|
+
event_id: str,
|
|
173
|
+
reason: str = "",
|
|
174
|
+
source: str = "desktop-lifecycle-fallback",
|
|
175
|
+
) -> str:
|
|
176
|
+
"""Write emergency diary evidence for a lifecycle event."""
|
|
177
|
+
try:
|
|
178
|
+
ack = lifecycle_events.write_fallback_diary_for_lifecycle_event(
|
|
179
|
+
event_id=str(event_id or ""),
|
|
180
|
+
reason=str(reason or ""),
|
|
181
|
+
source=str(source or "desktop-lifecycle-fallback"),
|
|
182
|
+
)
|
|
183
|
+
except Exception as exc:
|
|
184
|
+
return json.dumps({
|
|
185
|
+
"status": "retryable_error",
|
|
186
|
+
"reason": f"{type(exc).__name__}: {exc}",
|
|
187
|
+
"handler_threw": True,
|
|
188
|
+
}, ensure_ascii=False)
|
|
189
|
+
return json.dumps(ack, ensure_ascii=False)
|
|
190
|
+
|
|
191
|
+
|
|
171
192
|
def handle_nexo_lifecycle_wait_for_stop(
|
|
172
193
|
event_id: str,
|
|
173
194
|
timeout_ms: int = 10_000,
|
|
@@ -231,6 +252,11 @@ TOOLS = [
|
|
|
231
252
|
"nexo_lifecycle_wait_for_diary",
|
|
232
253
|
"Wait for concrete session_diary evidence for a canonical lifecycle event before Desktop stops the session.",
|
|
233
254
|
),
|
|
255
|
+
(
|
|
256
|
+
handle_nexo_lifecycle_write_fallback_diary,
|
|
257
|
+
"nexo_lifecycle_write_fallback_diary",
|
|
258
|
+
"Write emergency session_diary evidence when Desktop cannot get a live agent-authored close diary.",
|
|
259
|
+
),
|
|
234
260
|
(
|
|
235
261
|
handle_nexo_lifecycle_wait_for_stop,
|
|
236
262
|
"nexo_lifecycle_wait_for_stop",
|
|
@@ -34,6 +34,7 @@ RESTART_ALLOWLIST = {
|
|
|
34
34
|
"nexo_lifecycle_status",
|
|
35
35
|
"nexo_lifecycle_complete_canonical",
|
|
36
36
|
"nexo_lifecycle_wait_for_diary",
|
|
37
|
+
"nexo_lifecycle_write_fallback_diary",
|
|
37
38
|
"nexo_continuity_snapshot_read",
|
|
38
39
|
"nexo_continuity_resume_bundle",
|
|
39
40
|
"nexo_continuity_audit",
|
|
@@ -1983,6 +1983,19 @@
|
|
|
1983
1983
|
},
|
|
1984
1984
|
"triggers_after": []
|
|
1985
1985
|
},
|
|
1986
|
+
"nexo_lifecycle_write_fallback_diary": {
|
|
1987
|
+
"description": "Write a Brain-side fallback session_diary for a Desktop lifecycle event when live diary injection cannot complete.",
|
|
1988
|
+
"category": "lifecycle",
|
|
1989
|
+
"source": "plugin:lifecycle_events",
|
|
1990
|
+
"requires": [],
|
|
1991
|
+
"provides": [],
|
|
1992
|
+
"internal_calls": [],
|
|
1993
|
+
"enforcement": {
|
|
1994
|
+
"level": "none",
|
|
1995
|
+
"rules": []
|
|
1996
|
+
},
|
|
1997
|
+
"triggers_after": []
|
|
1998
|
+
},
|
|
1986
1999
|
"nexo_lifecycle_stop_nexo_session": {
|
|
1987
2000
|
"description": "Best-effort explicit stop of a NEXO SID for Desktop lifecycle cleanup.",
|
|
1988
2001
|
"category": "lifecycle",
|