@@ -53,6 +53,7 @@ import registerDebug from "debug";
5353
5454import { handleInstacartAction } from "./instacart/actionHandler.mjs" ;
5555import * as website from "website-memory" ;
56+ import { createGraphologyPersistenceManager } from "./knowledge/utils/graphologyPersistence.mjs" ;
5657import { handleKnowledgeAction } from "./knowledge/actions/knowledgeActionRouter.mjs" ;
5758import { ExtractKnowledgeHandler } from "./knowledge/extractKnowledgeCommand.mjs" ;
5859import {
@@ -655,7 +656,6 @@ async function processBrowserAgentMessage(
655656 case "getTopicMetrics" :
656657 case "getTopicTimelines" :
657658 case "getViewportBasedNeighborhood" :
658- case "testMergeTopicHierarchies" :
659659 case "mergeTopicHierarchies" :
660660 case "discoverRelatedKnowledge" :
661661 case "getTopicDetails" :
@@ -792,6 +792,10 @@ async function initializeWebsiteIndex(
792792 websiteIndexes [ 0 ] . path ,
793793 "index" ,
794794 ) ;
795+
796+ // Initialize JSON storage alongside SQLite
797+ await initializeGraphologyStorage ( context , websiteIndexes [ 0 ] . path ) ;
798+
795799 debug (
796800 `Loaded website index with ${ context . agentContext . websiteCollection ?. messages . length || 0 } websites` ,
797801 ) ;
@@ -848,6 +852,12 @@ async function initializeWebsiteIndex(
848852 sizeOnDisk : 0 ,
849853 } ;
850854
855+ // Initialize JSON storage and perform migration if needed
856+ await initializeGraphologyStorage (
857+ context ,
858+ indexPath ,
859+ ) ;
860+
851861 debug (
852862 `Loaded existing website collection with ${ websiteCollection . messages . length } websites from ${ indexPath } ` ,
853863 ) ;
@@ -891,6 +901,9 @@ async function initializeWebsiteIndex(
891901 sizeOnDisk : 0 ,
892902 } ;
893903
904+ // Initialize JSON storage for new index
905+ await initializeGraphologyStorage ( context , indexPath ) ;
906+
894907 debug (
895908 `Index will be created at ${ indexPath } when first page is indexed` ,
896909 ) ;
@@ -918,6 +931,40 @@ async function initializeWebsiteIndex(
918931 }
919932}
920933
934+ /**
935+ * Initialize Graphology storage for pure Graphology architecture
936+ */
937+ async function initializeGraphologyStorage (
938+ context : SessionContext < BrowserActionContext > ,
939+ indexPath : string ,
940+ ) : Promise < void > {
941+ try {
942+ debug ( "Initializing Graphology storage" ) ;
943+
944+ // Create storage path for Graphology files
945+ const graphologyStoragePath = path . join ( indexPath , "storage" ) ;
946+
947+ // Create Graphology persistence manager
948+ const persistenceManager = createGraphologyPersistenceManager (
949+ graphologyStoragePath ,
950+ ) ;
951+
952+ // Store reference in context for later use (maintaining compatibility)
953+ if ( ! context . agentContext . graphJsonStorage ) {
954+ context . agentContext . graphJsonStorage = {
955+ manager : persistenceManager ,
956+ lastEntityGraphUpdate : null ,
957+ lastTopicGraphUpdate : null ,
958+ } ;
959+ }
960+
961+ debug ( "Graphology storage initialization complete" ) ;
962+ } catch ( error ) {
963+ debug ( `Error initializing Graphology storage: ${ error } ` ) ;
964+ // Don't throw - this should not break the main initialization
965+ }
966+ }
967+
921968async function getSessionFolderPath (
922969 context : SessionContext < BrowserActionContext > ,
923970) {
0 commit comments