totemheart 0.1.1 → 0.1.3
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 +26 -14
- package/package.json +64 -63
- package/src/Totemheart.js +297 -5
- package/src/cognition/AnticipatoryAffect.js +58 -0
- package/src/cognition/EgoDepletionBudget.js +81 -0
- package/src/cognition/MotivationalConflict.js +62 -0
- package/src/cognition/ValueHierarchy.js +77 -0
- package/src/core/CommitmentDevice.js +74 -0
- package/src/core/MoralInjury.js +61 -0
- package/src/core/OpponentProcess.js +56 -0
- package/src/embodiment/InteroceptivePredictionError.js +47 -0
- package/src/neurochemistry/ArousalKalmanFilter.js +10 -1
- package/src/neurochemistry/CircadianRhythm.js +21 -0
- package/src/neurochemistry/DopaminergicEngine.js +15 -3
- package/src/neurochemistry/SleepPressure.js +74 -0
- package/src/neurochemistry/SubjectiveTimeEngine.js +54 -0
- package/src/social/Attachment.js +21 -0
- package/src/social/ForgettingCurve.js +16 -1
- package/src/social/GriefEngine.js +105 -0
- package/src/social/IdentityThreatMonitor.js +53 -0
- package/src/social/JealousyTriangle.js +52 -0
- package/src/social/NostalgiaEngine.js +68 -0
- package/src/social/PainSocialOverlap.js +46 -0
- package/src/social/RepairProtocol.js +90 -0
- package/src/social/ShameGuiltSplit.js +74 -0
- package/src/social/SocialBaselineTheory.js +37 -0
- package/src/version.js +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Totemheart
|
|
2
2
|
|
|
3
|
-

|
|
3
|
+

|
|
4
4
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](CALIBRATION.md)
|
|
7
|
-
[](package.json)
|
|
8
8
|
[](package.json)
|
|
9
|
-
[](test)
|
|
10
10
|
[](examples/verify-all-mechanisms.js)
|
|
11
11
|
|
|
12
|
-
> The Tests/Mechanisms badges above are static, last updated by hand from a real local `npm test` / `npm run verify` run. There's no CI wired yet to keep them live, so treat them as a snapshot, not a guarantee they still pass on `main`. Two later mechanism rounds (the 10 dynamics upgrades and `LoveHateEngine`) each ship their own dedicated live audit instead of being folded into the `verify` script above: `npm run upgrade-round-mock` (39/39) and `npm run lovehate-mock` (24/24).
|
|
12
|
+
> The Tests/Mechanisms badges above are static, last updated by hand from a real local `npm test` / `npm run verify` run. There's no CI wired yet to keep them live, so treat them as a snapshot, not a guarantee they still pass on `main`. Two later mechanism rounds (the 10 dynamics upgrades and `LoveHateEngine`) each ship their own dedicated live audit instead of being folded into the `verify` script above: `npm run upgrade-round-mock` (39/39) and `npm run lovehate-mock` (24/24). `npm test` runs [`test/`](test) in full: `regression/` (92, bug-fix guards and basic sanity), `integration/` (245, directed multi-mechanism scenarios, full-pipeline emergency routes crossed through real consecutive turns, exhaustive field-by-field serialization, malformed/hostile-input robustness, concurrent `processInput()` calls, real `OllamaProvider` unreachable-host fallback, non-ES/EN language input, the 18 new relational-friction mechanisms individually, and 8 cross-mechanism scenarios stacking several of them in the same turns — see [`test/integration/cross-mechanism-friction.test.js`](test/integration/cross-mechanism-friction.test.js)), and `property/` (2029, deterministic parameter-grid checks over exact boundaries, combined-extreme OCEAN personality corners, and long-horizon saturation limits including 5000-turn memory/mood-window boundedness — no randomness, same result every run).
|
|
13
13
|
|
|
14
14
|
**Totemheart** is a deterministic control kernel for persistent cognition, not a sentiment classifier and not a prompt-engineering trick. It gives an AI a *consistent inner life* across a conversation: personality, mood, memory, stress, and social dynamics that persist and evolve through real control-theory and neuroscience-derived math, instead of every reply being computed from scratch off a mood label. See [What this actually is](#what-this-actually-is) below before you build on top of it.
|
|
15
15
|
|
|
@@ -45,7 +45,8 @@ Personality, homeostatic needs, and the PAD (valence/arousal/dominance) state en
|
|
|
45
45
|
| --- | --- | --- | --- | --- |
|
|
46
46
|
| Personality | CoreBeliefs | Homeostasis | EmotionSpace | MicroEmotions |
|
|
47
47
|
| MoodTracker | DecayEngine | HedonicAdaptation | WornPathCache | PipelineResilience |
|
|
48
|
-
| AffectEMA | TriggerSentinel | HebbianPlasticity | | |
|
|
48
|
+
| AffectEMA | TriggerSentinel | HebbianPlasticity | CommitmentDevice | MoralInjury |
|
|
49
|
+
| OpponentProcess | | | | |
|
|
49
50
|
|
|
50
51
|
### 🧩 `cognition/`
|
|
51
52
|
|
|
@@ -57,7 +58,8 @@ Appraisal and interpretation: how an input gets read, doubted, reframed, or filt
|
|
|
57
58
|
| SituationalContext | NoveltyDetector | BayesianExpectation | ControllabilityEstimate | FuzzyNormativeCheck |
|
|
58
59
|
| Sensitization | Reappraisal | LoadScheduler | SemanticSimilarity | TopicSatiation |
|
|
59
60
|
| Intuition | LogicEngine | LifeEventCatalog | AppraisalAgreement | VisualProsody |
|
|
60
|
-
| SarcasmDetector | RefractoryPeriod | RemConsolidation | | |
|
|
61
|
+
| SarcasmDetector | RefractoryPeriod | RemConsolidation | AnticipatoryAffect | MotivationalConflict |
|
|
62
|
+
| EgoDepletionBudget | ValueHierarchy | | | |
|
|
61
63
|
|
|
62
64
|
### 🤝 `social/`
|
|
63
65
|
|
|
@@ -69,6 +71,8 @@ Modeling the other person: trust, reputation, theory of mind, relationship memor
|
|
|
69
71
|
| Attachment | GuiltEngine | TribalCategorization | ReputationEngine | EgoProjection |
|
|
70
72
|
| BystanderEffect | SelfModel | MonteCarloToM | FairnessMonitor | CounterfactualComparison |
|
|
71
73
|
| GratitudeEngine | StatusEnvy | EgoConfidence | UncannyValleyDetector | LoveHateEngine |
|
|
74
|
+
| GriefEngine | ShameGuiltSplit | RepairProtocol | JealousyTriangle | NostalgiaEngine |
|
|
75
|
+
| PainSocialOverlap | IdentityThreatMonitor | SocialBaselineTheory | | |
|
|
72
76
|
|
|
73
77
|
### 🎭 `behavior/`
|
|
74
78
|
|
|
@@ -85,7 +89,8 @@ Reward, stress, and circadian dynamics driving arousal and motivation over time.
|
|
|
85
89
|
|
|
86
90
|
| | | | | |
|
|
87
91
|
| --- | --- | --- | --- | --- |
|
|
88
|
-
| DopaminergicEngine | CortisolEngine | CircadianRhythm | ArousalKalmanFilter | |
|
|
92
|
+
| DopaminergicEngine | CortisolEngine | CircadianRhythm | ArousalKalmanFilter | SubjectiveTimeEngine |
|
|
93
|
+
| SleepPressure | | | | |
|
|
89
94
|
|
|
90
95
|
### 🫀 `embodiment/`
|
|
91
96
|
|
|
@@ -93,7 +98,7 @@ Interoception: real math on internal signals standing in for a body Totemheart d
|
|
|
93
98
|
|
|
94
99
|
| | | | | |
|
|
95
100
|
| --- | --- | --- | --- | --- |
|
|
96
|
-
| HardwareInteroception | SensoryOverload | InteroceptiveSignals | | |
|
|
101
|
+
| HardwareInteroception | SensoryOverload | InteroceptiveSignals | InteroceptivePredictionError | |
|
|
97
102
|
|
|
98
103
|
### ⚖️ `economics/`
|
|
99
104
|
|
|
@@ -126,14 +131,14 @@ Pluggable language backends, from a zero-dependency lexicon to a real transforme
|
|
|
126
131
|
|
|
127
132
|
## How coherent is this, really?
|
|
128
133
|
|
|
129
|
-
Short version: **~
|
|
134
|
+
Short version: **~80-83% with an LLM connected, ~64-68% running standalone on the zero-dependency heuristic path, 0% subjective experience, by design and permanently.** Self-assessed, qualitative estimates of how much of each layer is grounded in real theory/technique vs. own engineering judgment. The headline is not an average of the row values below: it carries an additional discount for integrated-system validation that doesn't exist yet. The +1pt over the previous round reflects the 18 relational-friction mechanisms added in 0.1.3, most of them drawing on real, well-cited, well-matched literature (Miller 1944's actual approach-avoidance model, Litz et al. 2009's actual coinage of "moral injury", Borbély 1982's actual Process S equation implemented near-literally) rather than looser analogies — see the new rows below and `CALIBRATION.md`'s "Relational friction, grief, and moral psychology" section for the full list. Full citation ledger: [`CALIBRATION.md`](CALIBRATION.md).
|
|
130
135
|
|
|
131
136
|
| Layer | With LLM | Heuristic only | Grounded in |
|
|
132
137
|
| --- | --- | --- | --- |
|
|
133
|
-
| State engine | ~
|
|
138
|
+
| State engine | ~83-86% | same | PID control (anti-windup, dynamic set points), Kalman filtering (now with real interoception-informed measurement noise), allostatic load (McEwen & Stellar 1993), prospect-theory loss aversion, TD reward-prediction-error with eligibility traces (Sutton & Barto), wanting/liking dissociation (Berridge & Robinson 1998) with allostatic-load-driven anhedonia, circumplex/PAD affect space with momentum/hysteresis, Holmes & Rahe life-event severity, the two-process sleep-pressure model (Borbély 1982), the opponent-process a/b dynamic (Solomon & Corbit 1974) |
|
|
134
139
|
| Semantic understanding | ~85-88% | ~68-73% | LLM: real language understanding. Heuristic: lexicon + concept-graph matching, keyword-triggered life-event detection, lexical-vs-context incongruence check, mean/variance anomaly detection, confidence-weighted routing between logical and affective reads |
|
|
135
|
-
| Expression / output | ~91-94% | ~64-70% | Structured system-prompt injection, coherence validation against prior turns, attachment-weighted style adaptation, a full-state-weighted action-tendency policy, real suppression-cost accrual, cognitive-load-derived output metadata |
|
|
136
|
-
| Cross-turn continuity | ~
|
|
140
|
+
| Expression / output | ~91-94% | ~64-70% | Structured system-prompt injection, coherence validation against prior turns, attachment-weighted style adaptation, a full-state-weighted action-tendency policy, real suppression-cost accrual, cognitive-load-derived output metadata, a real approach-avoidance conflict dampening expression confidence (Miller 1944) |
|
|
141
|
+
| Cross-turn continuity | ~93-96% | same | Persistent state serialization, asymmetric trust/reputation tracking, attachment styles with rupture-and-repair (Bartholomew & Horowitz 1991; Gottman & Levenson 1992) now with state-dependent style switching under stress (Mikulincer & Shaver 2016), memory reconsolidation on retrieval (Nader et al. 2000), unresolved-memory flagging with intrusive resurfacing, idle-time-based consolidation, long-horizon memory decay with similarity-triggered reactivation and bittersweet nostalgic reconsolidation (Walker, Skowronski & Thompson 2003), grief as a real decaying-with-waves process (Bonanno 2004; Zisook & Shear 2009), and permanent moral-injury scarring distinct from ordinary dissonance (Litz et al. 2009) |
|
|
137
142
|
| Subjective experience | **0%** | **0%** | Not a gap to close: no known way to build or verify this in any software |
|
|
138
143
|
|
|
139
144
|
The headline stays below the row average because none of these numbers include validation against psychologist judges, regression against real labeled chat data, or real-user testing of whether the integrated pipeline reads as coherent. See `CALIBRATION.md` for what hasn't been empirically validated.
|
|
@@ -154,8 +159,15 @@ The table above scores each functional layer as a whole. This scores ten specifi
|
|
|
154
159
|
| Attachment styles + rupture-and-repair | ~50-58% | Bartholomew & Horowitz's (1991) four-category model and the Gottman/Levenson rupture-and-repair literature are real; mapping OCEAN traits onto attachment-style buckets is our own engineering choice, explicitly not a validated psychometric equivalence |
|
|
155
160
|
| Vaillant defense hierarchy | ~55-63% | Vaillant's (1977) mature/neurotic/immature taxonomy is real, established clinical theory; the ego-health/cortisol-weighted tier-shifting mechanism that picks among them each turn is own design |
|
|
156
161
|
| `LoveHateEngine` dual-valence bond field | ~38-46% | The individual pieces it reuses (diminishing-returns accumulation, kindling, asymmetric decay, rupture-and-repair) each draw on real cited work; the specific coupled two-accumulator update equations are our own engineering design end to end, not a reproduction of any published relational model |
|
|
162
|
+
| Approach-avoidance conflict (`MotivationalConflict`) | ~68-75% | Miller's (1944) real gradient-conflict model, implemented close to literally (two exponential gradients, steeper avoidance decay, a real crossover/vacillation zone) — the specific decay constants and the expression-confidence dampening it feeds are own tuning |
|
|
163
|
+
| Two-process sleep pressure (`SleepPressure`) | ~72-80% | Borbély's (1982) Process S equation implemented directly (saturating exponential rise, exponential fall during a real "sleep" event); the specific rise/fall time constants are own engineering estimates, not measured circadian data |
|
|
164
|
+
| Opponent-process after-effect (`OpponentProcess`) | ~65-72% | Solomon & Corbit's (1974) a-process/b-process structure (habituating peak, growing-and-lengthening undershoot with repetition) implemented as its literal qualitative shape; the specific growth-rate constants are own tuning |
|
|
165
|
+
| Grief as a decaying-with-waves process (`GriefEngine`) | ~45-52% | The general shape (long-tailed, non-monotonic, punctuated by real intrusive waves) draws on real bereavement research (Bonanno 2004; Zisook & Shear 2009) that explicitly rejects a fixed-stage model — deliberately NOT modeling Kübler-Ross stages, since that theory lacks the empirical support the shape below draws on instead; the power-law exponent and wave-rate constants are own design |
|
|
166
|
+
| Shame/guilt split (`ShameGuiltSplit`) | ~60-68% | Tangney & Dearing's (2002) real, well-established distinction (identity-level vs. behavior-level, differing persistence); which real Totemheart signals feed each accumulator and the specific decay-rate ratio are own engineering |
|
|
167
|
+
| Moral injury / identity threat (`MoralInjury`, `IdentityThreatMonitor`) | ~55-63% | Litz et al.'s (2009) actual coinage and definition of "moral injury" as distinct from ordinary guilt, and Steele's (1988) self-affirmation/identity-threat theory, both real and well-matched to what's built; the permanence mechanism and severity-threshold/cascade-multiplier math are own design |
|
|
168
|
+
| Dynamic value conflict (`ValueHierarchy`) | ~50-58% | Schwartz's (1992) real, cross-culturally validated basic-values structure supplies the value set and the general "competing values create real tension" framing; the specific EMA nudge rule and conflict-scoring formula are own engineering, not a computational model Schwartz specified |
|
|
157
169
|
|
|
158
|
-
Every mechanism in this table passed a dedicated live audit: `npm run exhaustive-audit` (25/25) for the first five, `npm run upgrade-round-mock` (39/39) and `npm run lovehate-mock` (24/24) for the
|
|
170
|
+
Every mechanism in this table passed a dedicated live audit: `npm run exhaustive-audit` (25/25) for the first five, `npm run upgrade-round-mock` (39/39) and `npm run lovehate-mock` (24/24) for the LoveHateEngine-and-earlier rows, and [`test/integration/human-friction-mechanisms.test.js`](test/integration/human-friction-mechanisms.test.js) (60/60 directed per-mechanism tests) plus [`test/integration/cross-mechanism-friction.test.js`](test/integration/cross-mechanism-friction.test.js) (8/8 deliberate cross-mechanism scenarios — jealousy colliding with an in-progress repair, three independent dissonance sources stacked on one turn, grief/conflict/depletion together over 25 turns, sleep-pressure/REM/forgetting-curve across a real time gap, a full 18-mechanism soup round-tripped through serialization and still producing coherent output, and more) for the 8 rows added in 0.1.3 — confirming the code does what its own formulas claim, both in isolation and stacked together. That's internal consistency, not psychological validation, and the percentages above already price that distinction in.
|
|
159
171
|
|
|
160
172
|
## Prerequisites
|
|
161
173
|
|
|
@@ -176,7 +188,7 @@ yarn add totemheart
|
|
|
176
188
|
```js
|
|
177
189
|
import { Totemheart, Personality, VERSION } from 'totemheart'
|
|
178
190
|
|
|
179
|
-
console.log( VERSION ) // '0.1.
|
|
191
|
+
console.log( VERSION ) // '0.1.3', also available as Totemheart.VERSION and in toJSON().version
|
|
180
192
|
|
|
181
193
|
const ai = new Totemheart( {
|
|
182
194
|
personality: new Personality( { neuroticism: 0.7, agreeableness: 0.3 } ),
|
package/package.json
CHANGED
|
@@ -1,64 +1,65 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
}
|
|
2
|
+
"name": "totemheart",
|
|
3
|
+
"version": "0.1.3",
|
|
4
|
+
"description": "Totemheart is a modular emotional-simulation engine for AI: personality, mood, neurochemical dynamics, cognitive biases and social mechanics wired into a single pipeline that drives emotionally coherent, stateful behavior over a conversation.",
|
|
5
|
+
"main": "src/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"engines": {
|
|
8
|
+
"node": ">=18"
|
|
9
|
+
},
|
|
10
|
+
"files": [
|
|
11
|
+
"src"
|
|
12
|
+
],
|
|
13
|
+
"scripts": {
|
|
14
|
+
"demo": "node examples/demo.js",
|
|
15
|
+
"verify": "node examples/verify-all-mechanisms.js",
|
|
16
|
+
"stress-test": "node examples/full-stress-test.js",
|
|
17
|
+
"personality-mock": "node examples/personality-mock.js",
|
|
18
|
+
"rem-mock": "node examples/rem-conversation-mock.js",
|
|
19
|
+
"exhaustive-audit": "node examples/exhaustive-audit-mock.js",
|
|
20
|
+
"upgrade-round-mock": "node examples/upgrade-round-mock.js",
|
|
21
|
+
"lovehate-mock": "node examples/lovehate-mock.js",
|
|
22
|
+
"test": "node --test test/regression/*.test.js test/integration/*.test.js test/property/*.test.js"
|
|
23
|
+
},
|
|
24
|
+
"keywords": [
|
|
25
|
+
"totemheart",
|
|
26
|
+
"library",
|
|
27
|
+
"web",
|
|
28
|
+
"intelligence",
|
|
29
|
+
"ia",
|
|
30
|
+
"emotion-engine",
|
|
31
|
+
"personality",
|
|
32
|
+
"robotic",
|
|
33
|
+
"framework"
|
|
34
|
+
],
|
|
35
|
+
"author": "Alejo Malia <alejomalia@gmail.com>",
|
|
36
|
+
"license": "MIT",
|
|
37
|
+
"publishConfig": {
|
|
38
|
+
"access": "public",
|
|
39
|
+
"registry": "https://registry.npmjs.org/"
|
|
40
|
+
},
|
|
41
|
+
"packageManager": "pnpm@9.7.0",
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@typescript-eslint/eslint-plugin": "8.2.0",
|
|
44
|
+
"@typescript-eslint/parser": "8.2.0",
|
|
45
|
+
"eslint": "8.57.0",
|
|
46
|
+
"eslint-plugin-align-assignments": "1.1.2",
|
|
47
|
+
"eslint-plugin-align-import": "1.0.0",
|
|
48
|
+
"eslint-plugin-canonical": "5.0.0",
|
|
49
|
+
"eslint-plugin-html": "7.1.0",
|
|
50
|
+
"eslint-plugin-import": "2.29.1",
|
|
51
|
+
"eslint-plugin-jsdoc": "46.10.1",
|
|
52
|
+
"eslint-plugin-json": "3.1.0",
|
|
53
|
+
"eslint-plugin-jsonc": "2.13.0",
|
|
54
|
+
"eslint-plugin-markdownlint": "0.5.0",
|
|
55
|
+
"eslint-plugin-package-json": "0.12.2",
|
|
56
|
+
"eslint-plugin-promise": "6.1.1",
|
|
57
|
+
"eslint-plugin-yaml": "0.5.0",
|
|
58
|
+
"typescript": "5.6.2",
|
|
59
|
+
"vite": "5.4.4"
|
|
60
|
+
},
|
|
61
|
+
"extra": {
|
|
62
|
+
"id": "totemheart",
|
|
63
|
+
"productName": "Totemheart"
|
|
64
|
+
}
|
|
65
|
+
}
|