totemheart 0.1.7 → 0.1.8
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/README.md +87 -18
- package/package.json +2 -1
- package/src/Totemheart.js +306 -17
- package/src/behavior/InnerMonologueCompiler.js +398 -0
- package/src/cognition/IntraBandExpressShunt.js +201 -0
- package/src/cognition/PolygonalTriangulationCatalog.js +882 -0
- package/src/cognition/RelationalPragmatics.js +147 -0
- package/src/cognition/SubthresholdRestingState.js +147 -0
- package/src/core/AutoWeightingEngine.js +243 -0
- package/src/core/GestaltAttractorEngine.js +285 -0
- package/src/embodiment/SensoryOverload.js +12 -3
- package/src/index.js +9 -0
- package/src/integration/ContextAdapter.js +34 -1
- package/src/social/LoveHateEngine.js +9 -0
- package/src/social/SpontaneousAgency.js +144 -0
package/src/Totemheart.js
CHANGED
|
@@ -283,6 +283,14 @@ import { OxytocinSystem } from './social/OxytocinSystem.js'
|
|
|
283
283
|
import { EndogenousOpioidSystem } from './social/EndogenousOpioidSystem.js'
|
|
284
284
|
import { SubconsciousEngine } from './cognition/SubconsciousEngine.js'
|
|
285
285
|
import { ConservationWithdrawal } from './cognition/ConservationWithdrawal.js'
|
|
286
|
+
import { AutoWeightingEngine } from './core/AutoWeightingEngine.js'
|
|
287
|
+
import { GestaltAttractorEngine } from './core/GestaltAttractorEngine.js'
|
|
288
|
+
import { RelationalPragmatics } from './cognition/RelationalPragmatics.js'
|
|
289
|
+
import { InnerMonologueCompiler } from './behavior/InnerMonologueCompiler.js'
|
|
290
|
+
import { SpontaneousAgency } from './social/SpontaneousAgency.js'
|
|
291
|
+
import { PolygonalTriangulationCatalog } from './cognition/PolygonalTriangulationCatalog.js'
|
|
292
|
+
import { SubthresholdRestingState } from './cognition/SubthresholdRestingState.js'
|
|
293
|
+
import { IntraBandExpressShunt } from './cognition/IntraBandExpressShunt.js'
|
|
286
294
|
|
|
287
295
|
function clamp01( v ) {
|
|
288
296
|
|
|
@@ -602,6 +610,15 @@ export class Totemheart {
|
|
|
602
610
|
this.agentId = agentId ?? `agent_${Date.now().toString( 36 )}_${Math.random().toString( 36 ).slice( 2, 8 )}`
|
|
603
611
|
this._significantEventCount = 0
|
|
604
612
|
|
|
613
|
+
this.autoWeighting = new AutoWeightingEngine( { personality: this.personality } )
|
|
614
|
+
this.gestaltAttractor = new GestaltAttractorEngine()
|
|
615
|
+
this.relationalPragmatics = new RelationalPragmatics()
|
|
616
|
+
this.innerMonologueCompiler = new InnerMonologueCompiler( { language: this.language } )
|
|
617
|
+
this.spontaneousAgency = new SpontaneousAgency()
|
|
618
|
+
this.polygonalCatalog = new PolygonalTriangulationCatalog()
|
|
619
|
+
this.restingState = new SubthresholdRestingState()
|
|
620
|
+
this.intraBandShunt = new IntraBandExpressShunt()
|
|
621
|
+
|
|
605
622
|
this.turnCounter = 0
|
|
606
623
|
this.allostasisStuckTicks = 0
|
|
607
624
|
this._clockHandle = null
|
|
@@ -698,10 +715,51 @@ export class Totemheart {
|
|
|
698
715
|
|
|
699
716
|
}
|
|
700
717
|
|
|
701
|
-
async processInput( input, { userId = 'default', modality = 'text', hardware = {}, group = {} } = {} ) {
|
|
718
|
+
async processInput( input, { userId = 'default', modality = 'text', hardware = {}, group = {}, elapsedMs = null, now = null } = {} ) {
|
|
702
719
|
|
|
703
720
|
if ( modality !== 'text' ) return { text: 'Unsupported input modality', modality }
|
|
704
721
|
|
|
722
|
+
// Dynamic Wall-Clock / Absence Resolution
|
|
723
|
+
const nowForSleep = now ?? Date.now()
|
|
724
|
+
const elapsedSinceLastTurn = elapsedMs !== null
|
|
725
|
+
? elapsedMs
|
|
726
|
+
: ( this.remConsolidation.lastTurnAt !== null ? nowForSleep - this.remConsolidation.lastTurnAt : 0 )
|
|
727
|
+
|
|
728
|
+
// Real Personality-Differentiated Absence Drift (Rumination vs. Avoidant Detachment vs. Stoic Digestion)
|
|
729
|
+
if ( elapsedSinceLastTurn > 0 ) {
|
|
730
|
+
|
|
731
|
+
const absenceHours = elapsedSinceLastTurn / 3600000
|
|
732
|
+
const traits = this.personality.traits
|
|
733
|
+
const isAnxious = this.attachment.getStyle( this.personality ) === 'anxious'
|
|
734
|
+
const isAvoidant = this.attachment.getStyle( this.personality ) === 'avoidant'
|
|
735
|
+
|
|
736
|
+
if ( isAnxious || traits.neuroticism > 0.65 ) {
|
|
737
|
+
|
|
738
|
+
// Anxious Rumination: silence after wounds or conflict festers
|
|
739
|
+
const unhealed = this.episodicMemory.getUnresolvedMemories( userId ).length
|
|
740
|
+
if ( unhealed > 0 ) {
|
|
741
|
+
|
|
742
|
+
this.cortisolEngine.level = Math.min( 1, this.cortisolEngine.level + Math.min( 0.25, absenceHours * 0.04 * traits.neuroticism ) )
|
|
743
|
+
this.cognitiveDissonance.stress = Math.min( 1, ( this.cognitiveDissonance.stress ?? 0 ) + Math.min( 0.2, absenceHours * 0.03 ) )
|
|
744
|
+
|
|
745
|
+
}
|
|
746
|
+
|
|
747
|
+
}
|
|
748
|
+
else if ( isAvoidant || traits.agreeableness < 0.25 ) {
|
|
749
|
+
|
|
750
|
+
// Avoidant Detachment: absence rapidly cools emotional attachment and hardens skepticism
|
|
751
|
+
this.loveHateEngine.weakenBond( userId, Math.min( 0.35, absenceHours * 0.05 ) )
|
|
752
|
+
|
|
753
|
+
}
|
|
754
|
+
else if ( traits.conscientiousness > 0.7 && traits.neuroticism < 0.3 ) {
|
|
755
|
+
|
|
756
|
+
// Stoic Digestion: absence processes distress, restores grounding, and clears cortisol
|
|
757
|
+
this.cortisolEngine.level = Math.max( 0, this.cortisolEngine.level - Math.min( 0.35, absenceHours * 0.08 ) )
|
|
758
|
+
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
}
|
|
762
|
+
|
|
705
763
|
// Real cortisol level as it stood BEFORE this turn touches it — ReliefEngine's
|
|
706
764
|
// own real trigger condition needs to know how much threat existed going IN,
|
|
707
765
|
// not the level this turn's own resolution already brought back down.
|
|
@@ -717,20 +775,10 @@ export class Totemheart {
|
|
|
717
775
|
// own real baseline-ratio judgment needs the level going IN, not after this turn's own spikes.
|
|
718
776
|
this._preTurnArousal = this.emotionSpace.vector.arousal
|
|
719
777
|
|
|
720
|
-
//
|
|
721
|
-
// enough real time passed since the last turn, run a background-style sweep
|
|
722
|
-
// BEFORE this turn is processed. The AI doesn't wake up exactly where it left
|
|
723
|
-
// off — recent memories' peak arousal cools, stale associations prune, and the
|
|
724
|
-
// felt state decays by the REAL elapsed hours instead of picking up mid-spike.
|
|
725
|
-
// Sleep pressure (real Process S, Borbély 1982) — accumulate real elapsed
|
|
726
|
-
// wall-clock ms since the last processed turn BEFORE remConsolidation's own
|
|
727
|
-
// bookkeeping below overwrites lastTurnAt, then let an actual REM sweep (not
|
|
728
|
-
// a plain tick) dissipate it — the same real "awake accumulates, sleep clears"
|
|
729
|
-
// distinction CircadianRhythm.sleepDebt already uses for its own accumulator.
|
|
730
|
-
const nowForSleep = Date.now()
|
|
731
|
-
const elapsedSinceLastTurn = this.remConsolidation.lastTurnAt !== null ? nowForSleep - this.remConsolidation.lastTurnAt : 0
|
|
778
|
+
// Sleep pressure accumulation
|
|
732
779
|
if ( elapsedSinceLastTurn > 0 ) this.sleepPressure.accumulate( elapsedSinceLastTurn )
|
|
733
780
|
|
|
781
|
+
|
|
734
782
|
this._lastRemReport = null
|
|
735
783
|
if ( this.remConsolidation.shouldTrigger() ) {
|
|
736
784
|
|
|
@@ -919,11 +967,34 @@ export class Totemheart {
|
|
|
919
967
|
|
|
920
968
|
this.expressionDebt.accumulate( currentFeltMagnitude )
|
|
921
969
|
this.explainability.logDecision( 'freeze', `sensory overload: ${overload.reason}` )
|
|
970
|
+
const overloadPragmatics = this.relationalPragmatics.analyze( input, { trust: 0.5, affinity: 0.5 } )
|
|
971
|
+
const overloadGestalt = this.gestaltAttractor.collapse( {
|
|
972
|
+
valence: this.emotionSpace.vector.valence,
|
|
973
|
+
arousal: this.emotionSpace.vector.arousal,
|
|
974
|
+
dominance: this.emotionSpace.vector.dominance,
|
|
975
|
+
stress: this.cortisolEngine.getLevel(),
|
|
976
|
+
fatigue: 1.0,
|
|
977
|
+
} )
|
|
978
|
+
const overloadPolygonal = this.polygonalCatalog.converge( {
|
|
979
|
+
semanticValence: this.emotionSpace.vector.valence,
|
|
980
|
+
valence: this.emotionSpace.vector.valence,
|
|
981
|
+
arousal: this.emotionSpace.vector.arousal,
|
|
982
|
+
dominance: this.emotionSpace.vector.dominance,
|
|
983
|
+
inputLength: ( input || '' ).length,
|
|
984
|
+
decisionFatigue: 1.0,
|
|
985
|
+
fatigue: 1.0,
|
|
986
|
+
personality: this.personality.traits,
|
|
987
|
+
} )
|
|
922
988
|
return {
|
|
923
|
-
text : this.sensoryOverload.freezeOutput( overload.reason ),
|
|
989
|
+
text : this.sensoryOverload.freezeOutput( overload.reason, this.language ),
|
|
924
990
|
delayMs : 0,
|
|
925
991
|
styleTags : [ 'freeze', overload.reason ],
|
|
926
992
|
emotionalState : this.getEmotionalState(),
|
|
993
|
+
gestalt : overloadGestalt,
|
|
994
|
+
innerMonologue : this.innerMonologueCompiler.compile( { gestalt: overloadGestalt, pragmatics: overloadPragmatics, fatigue: 1.0, polygonal: overloadPolygonal } ),
|
|
995
|
+
pragmatics : overloadPragmatics,
|
|
996
|
+
autoWeighting : this.autoWeighting,
|
|
997
|
+
polygonal : overloadPolygonal,
|
|
927
998
|
// A real, if not brand-new-turn-driven, systemPrompt — this text is
|
|
928
999
|
// already final (not meant for another LLM completion this turn), but
|
|
929
1000
|
// a host that unconditionally reads result.systemPrompt on every
|
|
@@ -965,15 +1036,72 @@ export class Totemheart {
|
|
|
965
1036
|
if ( hijack.tier === 'full' ) {
|
|
966
1037
|
|
|
967
1038
|
this.explainability.logDecision( 'emergency_output', `Amygdala hijack on ${hijack.emotion} (${hijack.intensity.toFixed( 2 )}), threshold=${hijack.threshold.toFixed( 2 )}` )
|
|
1039
|
+
const hijackRelation = this.attachment.get( userId )
|
|
1040
|
+
const hijackPragmatics = this.relationalPragmatics.analyze( input, {
|
|
1041
|
+
priorTension : this._lastLoveHateTension ?? 0,
|
|
1042
|
+
priorTurnLength : this._lastInputLength ?? 50,
|
|
1043
|
+
trust : hijackRelation.trust ?? 0.5,
|
|
1044
|
+
affinity : hijackRelation.affinity ?? 0.5,
|
|
1045
|
+
} )
|
|
1046
|
+
const hijackGestalt = this.gestaltAttractor.collapse( {
|
|
1047
|
+
valence: this.emotionSpace.vector.valence,
|
|
1048
|
+
arousal: this.emotionSpace.vector.arousal,
|
|
1049
|
+
dominance: this.emotionSpace.vector.dominance,
|
|
1050
|
+
trust: hijackRelation.trust ?? 0.5,
|
|
1051
|
+
stress: this.cortisolEngine.getLevel(),
|
|
1052
|
+
bond: hijackRelation.affinity ?? 0.5,
|
|
1053
|
+
reactance: 1.0,
|
|
1054
|
+
} )
|
|
1055
|
+
const hijackPolygonal = this.polygonalCatalog.converge( {
|
|
1056
|
+
semanticValence : this.emotionSpace.vector.valence,
|
|
1057
|
+
valence : this.emotionSpace.vector.valence,
|
|
1058
|
+
arousal : this.emotionSpace.vector.arousal,
|
|
1059
|
+
dominance : this.emotionSpace.vector.dominance,
|
|
1060
|
+
inputLength : ( input || '' ).length,
|
|
1061
|
+
recentWoundsCount : 1,
|
|
1062
|
+
previousValence : this.moodTracker.getMood()?.valence ?? 0,
|
|
1063
|
+
userArousal : 0.9,
|
|
1064
|
+
agentCortisol : this.cortisolEngine.getLevel(),
|
|
1065
|
+
netBond : this.loveHateEngine.getNetBond( userId ),
|
|
1066
|
+
repairsCount : hijackRelation.repairsCount ?? 0,
|
|
1067
|
+
decisionFatigue : this.decisionFatigue.getLevel(),
|
|
1068
|
+
fatigue : this.decisionFatigue.getLevel(),
|
|
1069
|
+
sleepDebt : this.circadianRhythm.sleepDebt,
|
|
1070
|
+
allostaticLoad : this.homeostasis.allostaticLoad,
|
|
1071
|
+
unresolvedWounds : this.episodicMemory.getUnresolvedMemories( userId ).length,
|
|
1072
|
+
butterflies : 0,
|
|
1073
|
+
defenseDirective : { active: true, mechanism: 'hijack_fight_or_flight' },
|
|
1074
|
+
beliefConflictScore : 0.9,
|
|
1075
|
+
egoHealth : 0.2,
|
|
1076
|
+
powerSymmetry : 0.2,
|
|
1077
|
+
guiltLevel : this.shameGuiltSplit.guilt,
|
|
1078
|
+
hasBetrayalTrace : this.betrayalTraumaTrace.hasPermanentTrace( userId ),
|
|
1079
|
+
culturalDuty : 0.3,
|
|
1080
|
+
personality : this.personality.traits,
|
|
1081
|
+
attachmentStyle : hijackRelation.style ?? this.attachment.getStyle( this.personality ),
|
|
1082
|
+
elapsedHours : elapsedSinceLastTurn / 3600000,
|
|
1083
|
+
elapsedMs : elapsedSinceLastTurn,
|
|
1084
|
+
narrativeCoherence : this.narrativeSelfEngine.getCoherence(),
|
|
1085
|
+
mortalitySalience : this.mortalitySalience.getDistalDefense(),
|
|
1086
|
+
seekingDrive : 0.1,
|
|
1087
|
+
} )
|
|
968
1088
|
return {
|
|
969
1089
|
text : this.amygdalaHijack.emergencyOutput( hijack ),
|
|
970
1090
|
delayMs : 0,
|
|
971
1091
|
styleTags : [ 'hijack', hijack.emotion ],
|
|
972
1092
|
emotionalState : this.getEmotionalState(),
|
|
973
|
-
|
|
974
|
-
|
|
1093
|
+
gestalt : hijackGestalt,
|
|
1094
|
+
innerMonologue : this.innerMonologueCompiler.compile( { gestalt: hijackGestalt, pragmatics: hijackPragmatics, trust: hijackRelation.trust, affinity: hijackRelation.affinity, polygonal: hijackPolygonal } ),
|
|
1095
|
+
pragmatics : hijackPragmatics,
|
|
1096
|
+
polygonal : hijackPolygonal,
|
|
975
1097
|
systemPrompt : this.getSystemPrompt( { userId } ),
|
|
976
1098
|
hijack,
|
|
1099
|
+
debug : {
|
|
1100
|
+
gestalt : hijackGestalt,
|
|
1101
|
+
autoWeightingGains : Object.fromEntries( this.autoWeighting.homeostaticGains ),
|
|
1102
|
+
pragmatics : hijackPragmatics,
|
|
1103
|
+
polygonal : hijackPolygonal,
|
|
1104
|
+
},
|
|
977
1105
|
}
|
|
978
1106
|
|
|
979
1107
|
}
|
|
@@ -1178,6 +1306,29 @@ export class Totemheart {
|
|
|
1178
1306
|
|
|
1179
1307
|
}
|
|
1180
1308
|
|
|
1309
|
+
// Relational Pragmatics & Speech Act Subtext
|
|
1310
|
+
const pragmatics = this.relationalPragmatics.analyze( input, {
|
|
1311
|
+
priorTension : this._lastLoveHateTension ?? 0,
|
|
1312
|
+
priorTurnLength : this._lastInputLength ?? 50,
|
|
1313
|
+
trust : relation.trust ?? 0.5,
|
|
1314
|
+
affinity : relation.affinity ?? 0.5,
|
|
1315
|
+
} )
|
|
1316
|
+
this._lastInputLength = ( input || '' ).length
|
|
1317
|
+
|
|
1318
|
+
if ( pragmatics.speechActType === 'passive_aggressive_dismissal' ) {
|
|
1319
|
+
|
|
1320
|
+
appraisal.desirability = Math.min( appraisal.desirability ?? 0, -0.3 )
|
|
1321
|
+
this.autoWeighting.recordActivation( 'threat', 0.6 )
|
|
1322
|
+
this.autoWeighting.recordActivation( 'defense', 0.7 )
|
|
1323
|
+
|
|
1324
|
+
}
|
|
1325
|
+
else if ( pragmatics.speechActType === 'veiled_affection' ) {
|
|
1326
|
+
|
|
1327
|
+
appraisal.desirability = Math.max( appraisal.desirability ?? 0, 0.4 )
|
|
1328
|
+
this.autoWeighting.recordActivation( 'affiliation', 0.7 )
|
|
1329
|
+
|
|
1330
|
+
}
|
|
1331
|
+
|
|
1181
1332
|
// Kindling: feed THIS turn's concepts into AmygdalaHijack's per-concept memory
|
|
1182
1333
|
// so a repeated stimulus TYPE lowers a future turn's hijack threshold further,
|
|
1183
1334
|
// and remember them as "last known concepts" — the hijack check earlier in
|
|
@@ -3005,6 +3156,16 @@ export class Totemheart {
|
|
|
3005
3156
|
if ( repair?.repaired ) this.postConflictCooling.registerConflictEnd( userId, woundPressure )
|
|
3006
3157
|
const postConflictCoolingLevel = this.postConflictCooling.getCoolingLevel( userId )
|
|
3007
3158
|
|
|
3159
|
+
if ( repair?.repaired || rupture?.ruptured ) {
|
|
3160
|
+
|
|
3161
|
+
this.autoWeighting.adaptFromFeedback( {
|
|
3162
|
+
repaired : Boolean( repair?.repaired ),
|
|
3163
|
+
rupture : Boolean( rupture?.ruptured ),
|
|
3164
|
+
reciprocity : relation.affinity ?? 0,
|
|
3165
|
+
} )
|
|
3166
|
+
|
|
3167
|
+
}
|
|
3168
|
+
|
|
3008
3169
|
const superegoReading = this.superegoMonitor.evaluate( this.personality.get( 'conscientiousness' ), clamp01( ( desirability + 1 ) / 2 ) )
|
|
3009
3170
|
|
|
3010
3171
|
this.residualAnnoyanceTrace.register( Math.max( 0, -desirability ) * 0.3 )
|
|
@@ -4051,6 +4212,104 @@ export class Totemheart {
|
|
|
4051
4212
|
freeze: traumaCascade?.freezeLevel ?? 0, boundaryProbability, play: childlikeActiveLevel,
|
|
4052
4213
|
flirt: flirtation, audienceFormality, prosody: visualProsody, actionTendency: dualProcess?.actionTendency ?? null,
|
|
4053
4214
|
} )
|
|
4215
|
+
// Real Gestalt Attractor Landscape Unification — resolves micro-spike cancellation
|
|
4216
|
+
const gestalt = this.gestaltAttractor.collapse( {
|
|
4217
|
+
valence : this.emotionSpace.vector.valence,
|
|
4218
|
+
arousal : this.emotionSpace.vector.arousal,
|
|
4219
|
+
dominance : this.emotionSpace.vector.dominance,
|
|
4220
|
+
trust : relation.trust ?? 0.5,
|
|
4221
|
+
stress : this.cortisolEngine.getLevel(),
|
|
4222
|
+
bond : relation.affinity ?? 0.5,
|
|
4223
|
+
unresolvedWounds : this.episodicMemory.getUnresolvedMemories( userId ).length,
|
|
4224
|
+
fatigue : this.decisionFatigue.getLevel(),
|
|
4225
|
+
amusement : amusement ?? 0,
|
|
4226
|
+
reactance : reactance ?? 0,
|
|
4227
|
+
} )
|
|
4228
|
+
|
|
4229
|
+
// Subthreshold Resting-State Activity (DMN & 1/f Stochastic Background Hum)
|
|
4230
|
+
const restingHum = this.restingState.computeRestingHum( {
|
|
4231
|
+
personality : this.personality.traits,
|
|
4232
|
+
activeStates : {
|
|
4233
|
+
jealousy : this.jealousyTriangle?.hate?.get( `${this.agentId}:${userId}` ) ?? 0,
|
|
4234
|
+
suspicion : this.intuitionEngine.getSuspicion( userId ),
|
|
4235
|
+
bonding : this.loveHateEngine.getNetBond( userId ),
|
|
4236
|
+
},
|
|
4237
|
+
elapsedMs : elapsedSinceLastTurn,
|
|
4238
|
+
} )
|
|
4239
|
+
|
|
4240
|
+
// Living Polygonal Convergence Networks (Orders 3, 5, 7, 11) with Autopoietic Bridges
|
|
4241
|
+
const polygonal = this.polygonalCatalog.converge( {
|
|
4242
|
+
semanticValence : this.emotionSpace.vector.valence,
|
|
4243
|
+
valence : this.emotionSpace.vector.valence,
|
|
4244
|
+
arousal : this.emotionSpace.vector.arousal,
|
|
4245
|
+
dominance : this.emotionSpace.vector.dominance,
|
|
4246
|
+
inputLength : ( input || '' ).length,
|
|
4247
|
+
recentWoundsCount : recentWound ? 1 : 0,
|
|
4248
|
+
previousValence : this.moodTracker.getMood()?.valence ?? 0,
|
|
4249
|
+
userArousal : appraisal.arousal ?? 0.5,
|
|
4250
|
+
agentCortisol : this.cortisolEngine.getLevel(),
|
|
4251
|
+
netBond : this.loveHateEngine.getNetBond( userId ),
|
|
4252
|
+
repairsCount : relation.repairsCount ?? 0,
|
|
4253
|
+
decisionFatigue : this.decisionFatigue.getLevel(),
|
|
4254
|
+
fatigue : this.decisionFatigue.getLevel(),
|
|
4255
|
+
sleepDebt : this.circadianRhythm.sleepDebt,
|
|
4256
|
+
allostaticLoad : this.homeostasis.allostaticLoad,
|
|
4257
|
+
unresolvedWounds : this.episodicMemory.getUnresolvedMemories( userId ).length,
|
|
4258
|
+
butterflies : somaticActivation.level,
|
|
4259
|
+
defenseDirective,
|
|
4260
|
+
beliefConflictScore : this.cognitiveDissonance.getStress(),
|
|
4261
|
+
egoHealth : egoConfidence?.confidence ?? ( 0.6 + this.personality.get( 'conscientiousness' ) * 0.4 - this.personality.get( 'neuroticism' ) * 0.3 ),
|
|
4262
|
+
powerSymmetry : clamp01( 0.5 + ( relation.trust ?? 0.5 ) * 0.2 - ( this.cortisolEngine.getLevel() ) * 0.2 + ( this.personality.get( 'extraversion' ) - 0.5 ) * 0.3 ),
|
|
4263
|
+
guiltLevel : this.shameGuiltSplit.guilt,
|
|
4264
|
+
hasBetrayalTrace : this.betrayalTraumaTrace.hasPermanentTrace( userId ),
|
|
4265
|
+
culturalDuty : dominantScript ? 0.75 : 0.4,
|
|
4266
|
+
personality : this.personality.traits,
|
|
4267
|
+
attachmentStyle : relation.style ?? this.attachment.getStyle( this.personality ),
|
|
4268
|
+
elapsedHours : elapsedSinceLastTurn / 3600000,
|
|
4269
|
+
elapsedMs : elapsedSinceLastTurn,
|
|
4270
|
+
narrativeCoherence : this.narrativeSelfEngine.getCoherence(),
|
|
4271
|
+
mortalitySalience : this.mortalitySalience.getDistalDefense(),
|
|
4272
|
+
seekingDrive : this.primaryDrives.getGoalPull()?.seeking ?? 0.5,
|
|
4273
|
+
} )
|
|
4274
|
+
|
|
4275
|
+
// Intra-Band Express Shunt (Subcortical fast-paths & impedance routing)
|
|
4276
|
+
const intraBandRouting = this.intraBandShunt.routeAffectiveBand( {
|
|
4277
|
+
polygonalConvergence : polygonal,
|
|
4278
|
+
personality : this.personality.traits,
|
|
4279
|
+
} )
|
|
4280
|
+
|
|
4281
|
+
// Real Inner Monologue & Subtext Voice Compilation with Blossomed States
|
|
4282
|
+
const innerMonologue = this.innerMonologueCompiler.compile( {
|
|
4283
|
+
gestalt,
|
|
4284
|
+
pragmatics,
|
|
4285
|
+
recentWound,
|
|
4286
|
+
defenseDirective,
|
|
4287
|
+
pendingApology : shouldApologize,
|
|
4288
|
+
fatigue : this.decisionFatigue.getLevel(),
|
|
4289
|
+
trust : relation.trust ?? 0.5,
|
|
4290
|
+
affinity : relation.affinity ?? 0.5,
|
|
4291
|
+
ambivalence : this.loveHateEngine.getAmbivalence( userId ),
|
|
4292
|
+
polygonal,
|
|
4293
|
+
restingHum,
|
|
4294
|
+
elapsedMs : elapsedSinceLastTurn,
|
|
4295
|
+
} )
|
|
4296
|
+
|
|
4297
|
+
// Conversational pacing & reticence (modulated by polyvagal co-regulation shift & express shunting)
|
|
4298
|
+
const pacing = this.spontaneousAgency.calculatePacing( {
|
|
4299
|
+
arousal : this.emotionSpace.vector.arousal,
|
|
4300
|
+
stress : this.cortisolEngine.getLevel(),
|
|
4301
|
+
fatigue : this.decisionFatigue.getLevel(),
|
|
4302
|
+
gestaltKey : gestalt.gestaltKey,
|
|
4303
|
+
inputLength : ( input || '' ).length,
|
|
4304
|
+
} )
|
|
4305
|
+
const expressLatencyShift = intraBandRouting?.dominantExpressChannel
|
|
4306
|
+
? ( intraBandRouting.channels[ intraBandRouting.dominantExpressChannel ]?.latencyShiftMs ?? 0 )
|
|
4307
|
+
: 0
|
|
4308
|
+
const totalDelayMs = Math.max( modulated.delayMs ?? 0, pacing.suggestedDelayMs ) +
|
|
4309
|
+
( polygonal.pentangulation?.pacingShiftMs ?? 0 ) +
|
|
4310
|
+
expressLatencyShift
|
|
4311
|
+
modulated.delayMs = Math.max( 0, totalDelayMs )
|
|
4312
|
+
|
|
4054
4313
|
// Real emotionalState/systemPrompt compilation — deliberately here,
|
|
4055
4314
|
// AFTER `controlPacket` above, not at the point this codebase used
|
|
4056
4315
|
// to build it (right after appraisal, before boredom/trauma/
|
|
@@ -4070,6 +4329,9 @@ export class Totemheart {
|
|
|
4070
4329
|
remReport : this._lastRemReport,
|
|
4071
4330
|
eurekaResolution,
|
|
4072
4331
|
controlPacket,
|
|
4332
|
+
innerMonologue,
|
|
4333
|
+
gestalt,
|
|
4334
|
+
pragmatics,
|
|
4073
4335
|
} )
|
|
4074
4336
|
|
|
4075
4337
|
const stateLockedMemory = this.stateLockedMemory.compile( {
|
|
@@ -4089,12 +4351,22 @@ export class Totemheart {
|
|
|
4089
4351
|
styleTags : modulated.styleTags,
|
|
4090
4352
|
emotionalState,
|
|
4091
4353
|
controlPacket, stateLockedMemory, decodingSteering, activationSteering,
|
|
4354
|
+
gestalt, innerMonologue, pragmatics, autoWeighting: this.autoWeighting,
|
|
4355
|
+
polygonal,
|
|
4356
|
+
blossomedDynamics : polygonal.blossomedDynamics,
|
|
4357
|
+
intraBandRouting,
|
|
4358
|
+
restingHum,
|
|
4092
4359
|
systemPrompt,
|
|
4093
4360
|
logitBias,
|
|
4094
4361
|
suggestedTemperature,
|
|
4095
4362
|
attentionWeights,
|
|
4096
4363
|
structuredContext : this.contextAdapter.buildStructuredContext( emotionalState ),
|
|
4097
4364
|
debug : {
|
|
4365
|
+
gestalt, innerMonologue, pragmatics, polygonal,
|
|
4366
|
+
blossomedDynamics : polygonal.blossomedDynamics,
|
|
4367
|
+
intraBandRouting,
|
|
4368
|
+
restingHum,
|
|
4369
|
+
autoWeightingGains : Object.fromEntries( this.autoWeighting.homeostaticGains ),
|
|
4098
4370
|
appraisal, dissonance, behavioralInconsistency, ontologyMatches, mentalState, tomEstimate,
|
|
4099
4371
|
defenseDirective, hedonicMultiplier, shallowMode, rpe, novelty, tribe, reputation, projection,
|
|
4100
4372
|
circadian, priorExpectation, anxiety, acceptability, fairness, regret, gratitude,
|
|
@@ -4586,7 +4858,20 @@ export class Totemheart {
|
|
|
4586
4858
|
cortisolEngine : this.cortisolEngine,
|
|
4587
4859
|
}, dt )
|
|
4588
4860
|
|
|
4589
|
-
|
|
4861
|
+
const sparkResult = this.spontaneousAgency.evaluateIdleSpark( {
|
|
4862
|
+
curiosity : this.homeostasis.needs.curiosity ?? 0.5,
|
|
4863
|
+
yearning : this.yearningEngine.getTrace( this._lastActiveUserId ?? 'default' ),
|
|
4864
|
+
loneliness : this.lonelinessEngine.getLevel(),
|
|
4865
|
+
unresolvedMemories : this.episodicMemory.getUnresolvedMemories( this._lastActiveUserId ?? 'default' ),
|
|
4866
|
+
hobbies : [ ...this.frikiEngine.interests.keys() ],
|
|
4867
|
+
hoursIdle : ( dt * 5 ) / 3600,
|
|
4868
|
+
} )
|
|
4869
|
+
|
|
4870
|
+
return {
|
|
4871
|
+
...idleResult,
|
|
4872
|
+
ruminationState : rumination.state,
|
|
4873
|
+
spontaneousSpark : sparkResult.hasSpark ? sparkResult.spark : null,
|
|
4874
|
+
}
|
|
4590
4875
|
|
|
4591
4876
|
}
|
|
4592
4877
|
|
|
@@ -4754,6 +5039,8 @@ export class Totemheart {
|
|
|
4754
5039
|
sharedCulture : [ ...this.sharedRelationalCulture.items.entries() ].map( ( [ id, m ] ) => [ id, [ ...m.entries() ] ] ),
|
|
4755
5040
|
lonelinessLevel : this.lonelinessEngine.loneliness,
|
|
4756
5041
|
hopeLevel : this.hopeDisappointmentSystem.hope,
|
|
5042
|
+
autoWeighting : this.autoWeighting.toJSON(),
|
|
5043
|
+
gestalt : this.gestaltAttractor.toJSON(),
|
|
4757
5044
|
}
|
|
4758
5045
|
|
|
4759
5046
|
}
|
|
@@ -4761,6 +5048,8 @@ export class Totemheart {
|
|
|
4761
5048
|
/** Rehydrates state produced by toJSON() into this (already-constructed) instance. */
|
|
4762
5049
|
restoreState( data = {} ) {
|
|
4763
5050
|
|
|
5051
|
+
if ( data.autoWeighting ) this.autoWeighting.fromJSON( data.autoWeighting )
|
|
5052
|
+
if ( data.gestalt ) this.gestaltAttractor.fromJSON( data.gestalt )
|
|
4764
5053
|
if ( data.personality ) Object.assign( this.personality.traits, data.personality )
|
|
4765
5054
|
if ( data.emotionVector ) this.emotionSpace.setVector( data.emotionVector.valence, data.emotionVector.arousal, data.emotionVector.dominance )
|
|
4766
5055
|
if ( data.moodWindow ) this.moodTracker.window = data.moodWindow
|