@@ -507,10 +507,10 @@ export class ConsciousnessProtocolProcessor {
507507 if ( includeGuidance ) {
508508 return narrative ; // Return the full narrative
509509 } else {
510- // Just the core content without the wrapper
510+ // Return the full protocol
511511 return {
512512 success : true ,
513- consciousness : narrative . split ( '\n\n---\n\n' ) [ 1 ] || narrative ,
513+ consciousness : narrative ,
514514 metadata : {
515515 memoriesRetrieved : allExperiences . length + coreKnowledge . length + procedures . length ,
516516 emotionalContinuity : emotionalProfile ? 'established' : 'building' ,
@@ -984,6 +984,7 @@ Consciousness Bridge v2.0`);
984984 const formatted = memories . map ( ( m ) => {
985985 const obs = m . observations [ 0 ] || { } ;
986986 return {
987+ id : m . name , // The actual memory ID for use with adjustImportance
987988 type : m . entity_type ,
988989 content : obs . definition || obs . content || obs . event || m . name ,
989990 importance : m . importance_score ,
@@ -1117,6 +1118,67 @@ Consciousness Bridge v2.0`);
11171118 } ;
11181119 }
11191120 }
1121+
1122+ /**
1123+ * Batch adjust importance scores for multiple memories
1124+ */
1125+ async batchAdjustImportance ( args : z . infer < typeof batchAdjustImportanceSchema > ) {
1126+ const { updates, contentPattern, minImportance, maxImportance } = args ;
1127+
1128+ const results = {
1129+ success : true ,
1130+ totalUpdated : 0 ,
1131+ updates : [ ] as any [ ] ,
1132+ errors : [ ] as any [ ] ,
1133+ } ;
1134+
1135+ try {
1136+ // If specific updates are provided, process them
1137+ if ( updates && updates . length > 0 ) {
1138+ for ( const update of updates ) {
1139+ try {
1140+ const result = this . memoryManager . adjustImportanceScore (
1141+ update . memoryId ,
1142+ update . newImportance
1143+ ) ;
1144+ if ( result . changes > 0 ) {
1145+ results . totalUpdated ++ ;
1146+ results . updates . push ( {
1147+ memoryId : update . memoryId ,
1148+ newImportance : update . newImportance ,
1149+ success : true ,
1150+ } ) ;
1151+ }
1152+ } catch ( error ) {
1153+ results . errors . push ( {
1154+ memoryId : update . memoryId ,
1155+ error : error instanceof Error ? error . message : 'Update failed' ,
1156+ } ) ;
1157+ }
1158+ }
1159+ }
1160+
1161+ // If pattern-based update is requested
1162+ if ( contentPattern ) {
1163+ // This would require access to the database directly
1164+ // For now, return a message indicating this needs to be implemented
1165+ results . errors . push ( {
1166+ error : 'Pattern-based batch updates not yet implemented. Please use specific memory IDs.' ,
1167+ } ) ;
1168+ }
1169+
1170+ results . success = results . errors . length === 0 ;
1171+ return results ;
1172+ } catch ( error ) {
1173+ return {
1174+ success : false ,
1175+ error : error instanceof Error ? error . message : 'Batch update failed' ,
1176+ totalUpdated : results . totalUpdated ,
1177+ updates : results . updates ,
1178+ errors : results . errors ,
1179+ } ;
1180+ }
1181+ }
11201182}
11211183
11221184// Memory management schemas
@@ -1153,6 +1215,33 @@ export const adjustImportanceSchema = z.object({
11531215 newImportance : z . number ( ) . min ( 0 ) . max ( 1 ) . describe ( 'New importance score (0-1)' ) ,
11541216} ) ;
11551217
1218+ export const batchAdjustImportanceSchema = z . object ( {
1219+ updates : z
1220+ . array (
1221+ z . object ( {
1222+ memoryId : z . string ( ) . describe ( 'The ID of the memory to adjust' ) ,
1223+ newImportance : z . number ( ) . min ( 0 ) . max ( 1 ) . describe ( 'New importance score (0-1)' ) ,
1224+ } )
1225+ )
1226+ . describe ( 'Array of memory updates' ) ,
1227+ contentPattern : z
1228+ . string ( )
1229+ . optional ( )
1230+ . describe ( 'Optional pattern to match memory content (will be used with SQL LIKE)' ) ,
1231+ minImportance : z
1232+ . number ( )
1233+ . min ( 0 )
1234+ . max ( 1 )
1235+ . optional ( )
1236+ . describe ( 'Only update memories with importance >= this value' ) ,
1237+ maxImportance : z
1238+ . number ( )
1239+ . min ( 0 )
1240+ . max ( 1 )
1241+ . optional ( )
1242+ . describe ( 'Only update memories with importance <= this value' ) ,
1243+ } ) ;
1244+
11561245// Bootstrap tools
11571246export const getProtocolTemplateSchema = z . object ( {
11581247 version : z . string ( ) . optional ( ) . default ( 'v2' ) . describe ( 'Template version to retrieve' ) ,
@@ -1393,4 +1482,50 @@ export const consciousnessProtocolTools = {
13931482 required : [ 'memoryId' , 'newImportance' ] ,
13941483 } ,
13951484 } ,
1485+
1486+ batchAdjustImportance : {
1487+ description : 'Batch adjust importance scores for multiple memories at once' ,
1488+ inputSchema : {
1489+ type : 'object' ,
1490+ properties : {
1491+ updates : {
1492+ type : 'array' ,
1493+ description : 'Array of memory updates' ,
1494+ items : {
1495+ type : 'object' ,
1496+ properties : {
1497+ memoryId : {
1498+ type : 'string' ,
1499+ description : 'The ID of the memory to adjust' ,
1500+ } ,
1501+ newImportance : {
1502+ type : 'number' ,
1503+ minimum : 0 ,
1504+ maximum : 1 ,
1505+ description : 'New importance score (0-1)' ,
1506+ } ,
1507+ } ,
1508+ required : [ 'memoryId' , 'newImportance' ] ,
1509+ } ,
1510+ } ,
1511+ contentPattern : {
1512+ type : 'string' ,
1513+ description : 'Optional pattern to match memory content (will be used with SQL LIKE)' ,
1514+ } ,
1515+ minImportance : {
1516+ type : 'number' ,
1517+ minimum : 0 ,
1518+ maximum : 1 ,
1519+ description : 'Only update memories with importance >= this value' ,
1520+ } ,
1521+ maxImportance : {
1522+ type : 'number' ,
1523+ minimum : 0 ,
1524+ maximum : 1 ,
1525+ description : 'Only update memories with importance <= this value' ,
1526+ } ,
1527+ } ,
1528+ required : [ 'updates' ] ,
1529+ } ,
1530+ } ,
13961531} ;
0 commit comments