personal memory agent
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add action logging to speakers and agents apps

Speakers app (facet-scoped):
- voiceprint_save: when saving voiceprint to existing entity
- entity_voiceprint_create: when creating entity with voiceprint

Agents app (journal-level):
- agent_create/agent_update: when creating or updating agent definitions
- insight_create/insight_update: when creating or updating insight definitions
- insight_toggle: when toggling insight enabled/disabled state

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>

+69 -1
+39 -1
apps/agents/routes.py
··· 9 9 10 10 from flask import Blueprint, jsonify, request 11 11 12 + from apps.utils import log_app_action 12 13 from convey import state 13 14 14 15 agents_bp = Blueprint( ··· 432 433 item_name = item_type[ 433 434 :-1 434 435 ].title() # 'agents' -> 'Agent', 'insights' -> 'Insight' 435 - return {"success": True, "message": f"{item_name} {action} successfully"}, 200 436 + return { 437 + "success": True, 438 + "message": f"{item_name} {action} successfully", 439 + "is_new": is_new, 440 + }, 200 436 441 except Exception as e: 437 442 return {"error": str(e)}, 500 438 443 ··· 448 453 return jsonify({"error": "Invalid fields for agent update"}), 400 449 454 450 455 response, status = _update_item("agents", agent_id, data) 456 + 457 + # Log successful agent create/update (journal-level since agents are global) 458 + if status == 200 and response.get("success"): 459 + action = "agent_create" if response.get("is_new") else "agent_update" 460 + log_app_action( 461 + app="agents", 462 + facet=None, 463 + action=action, 464 + params={"agent_id": agent_id, "title": data.get("title", "")}, 465 + ) 466 + 451 467 return jsonify(response), status 452 468 453 469 ··· 539 555 json.dump(insight_config, f, indent=4) 540 556 541 557 response, status = _update_item("insights", insight_id, data) 558 + 559 + # Log successful insight create/update (journal-level since insights are global) 560 + if status == 200 and response.get("success"): 561 + action = "insight_create" if response.get("is_new") else "insight_update" 562 + log_app_action( 563 + app="agents", 564 + facet=None, 565 + action=action, 566 + params={"insight_id": insight_id, "title": data.get("title", "")}, 567 + ) 568 + 542 569 return jsonify(response), status 543 570 544 571 ··· 564 591 # Write back to file 565 592 with open(json_path, "w", encoding="utf-8") as f: 566 593 json.dump(insight_config, f, indent=4) 594 + 595 + # Log the toggle (journal-level since insights are global) 596 + log_app_action( 597 + app="agents", 598 + facet=None, 599 + action="insight_toggle", 600 + params={ 601 + "insight_id": insight_id, 602 + "disabled": insight_config["disabled"], 603 + }, 604 + ) 567 605 568 606 return jsonify({"success": True, "disabled": insight_config["disabled"]}) 569 607 except Exception as e:
+30
apps/speakers/routes.py
··· 24 24 url_for, 25 25 ) 26 26 27 + from apps.utils import log_app_action 27 28 from convey import state 28 29 from convey.utils import DATE_RE, error_response, format_date, success_response 29 30 from think.entities import ( ··· 379 380 # Save voiceprint 380 381 try: 381 382 emb_path = _save_voiceprint_to_entity(facet, entity_name, day, segment_key, emb) 383 + 384 + # Log action (facet-scoped since voiceprints are tied to entities) 385 + log_app_action( 386 + app="speakers", 387 + facet=facet, 388 + action="voiceprint_save", 389 + params={ 390 + "entity_name": entity_name, 391 + "day": day, 392 + "segment_key": segment_key, 393 + "speaker_label": speaker_label, 394 + }, 395 + ) 396 + 382 397 return success_response({"path": str(emb_path)}) 383 398 except Exception as e: 384 399 logger.exception("Failed to save voiceprint for %s", entity_name) ··· 435 450 # Save voiceprint 436 451 try: 437 452 emb_path = _save_voiceprint_to_entity(facet, entity_name, day, segment_key, emb) 453 + 454 + # Log action (facet-scoped since entities are facet-scoped) 455 + log_app_action( 456 + app="speakers", 457 + facet=facet, 458 + action="entity_voiceprint_create", 459 + params={ 460 + "entity_name": entity_name, 461 + "entity_type": entity_type, 462 + "day": day, 463 + "segment_key": segment_key, 464 + "speaker_label": speaker_label, 465 + }, 466 + ) 467 + 438 468 return success_response( 439 469 {"entity": new_entity, "voiceprint_path": str(emb_path)} 440 470 )