personal memory agent
0
fork

Configure Feed

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

Merge branch 'hopper-yzlqzjta'

+68
+68
think/dream.py
··· 17 17 from pathlib import Path 18 18 19 19 from think.callosum import CallosumConnection 20 + from think.cluster import cluster_segments 20 21 from think.cortex_client import cortex_request, get_agent_end_state, wait_for_agents 21 22 from think.facets import get_active_facets, get_enabled_facets, get_facets 22 23 from think.muse import get_muse_configs, get_output_path ··· 586 587 ) 587 588 parser.add_argument("--force", action="store_true", help="Overwrite existing files") 588 589 parser.add_argument( 590 + "--segments", 591 + action="store_true", 592 + help="Re-process all segments for the day (incompatible with --segment, --run, --facet)", 593 + ) 594 + parser.add_argument( 589 595 "--run", 590 596 metavar="NAME", 591 597 help="Run a single prompt by name (e.g., 'activity', 'timeline')", ··· 615 621 if args.facet and not args.run: 616 622 parser.error("--facet requires --run") 617 623 624 + if args.segments and (args.segment or args.run or args.facet): 625 + parser.error("--segments is incompatible with --segment, --run, and --facet") 626 + 618 627 # Start callosum connection 619 628 _callosum = CallosumConnection() 620 629 _callosum.start() ··· 630 639 facet=args.facet, 631 640 ) 632 641 sys.exit(0 if success else 1) 642 + 643 + # Handle batch segment re-processing mode 644 + if args.segments: 645 + if not check_callosum_available(): 646 + logging.warning("Callosum socket not found - prompts may fail to spawn") 647 + 648 + segments = cluster_segments(day) 649 + if not segments: 650 + logging.info(f"No segments found for {day}") 651 + sys.exit(0) 652 + 653 + total = len(segments) 654 + logging.info(f"Processing {total} segments for {day}") 655 + emit("segments_started", day=day, count=total) 656 + 657 + batch_start = time.time() 658 + batch_success = 0 659 + batch_failed = 0 660 + 661 + for i, seg in enumerate(segments, 1): 662 + seg_key = seg["key"] 663 + logging.info( 664 + f"Processing segment {i}/{total}: {seg_key} ({seg['start']}-{seg['end']})" 665 + ) 666 + try: 667 + success, failed = run_prompts_by_priority( 668 + day=day, 669 + segment=seg_key, 670 + force=args.force, 671 + verbose=args.verbose, 672 + ) 673 + batch_success += success 674 + batch_failed += failed 675 + except Exception: 676 + logging.exception(f"Segment {seg_key} failed with exception") 677 + batch_failed += 1 678 + 679 + duration_ms = int((time.time() - batch_start) * 1000) 680 + logging.info( 681 + f"All segments completed in {duration_ms}ms: " 682 + f"{batch_success} succeeded, {batch_failed} failed across {total} segments" 683 + ) 684 + emit( 685 + "segments_completed", 686 + day=day, 687 + count=total, 688 + success=batch_success, 689 + failed=batch_failed, 690 + duration_ms=duration_ms, 691 + ) 692 + 693 + if args.force: 694 + day_log(day, f"dream --segments --force failed={batch_failed}") 695 + else: 696 + day_log(day, f"dream --segments failed={batch_failed}") 697 + 698 + if batch_failed > 0: 699 + sys.exit(1) 700 + sys.exit(0) 633 701 634 702 # Check callosum availability 635 703 if not check_callosum_available():