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/README.md
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
|
|
5
5
|
[](LICENSE)
|
|
6
6
|
[](CALIBRATION.md)
|
|
7
|
-
[](package.json)
|
|
8
8
|
[](package.json)
|
|
9
|
-
[](test)
|
|
10
|
+
[](examples/verify-all-mechanisms.js)
|
|
11
11
|
|
|
12
|
-
> The Tests/Mechanisms badges are static, updated by hand from a real local `npm test` / `npm run verify` run. There's no CI wired up yet, so treat them as a snapshot, not a live guarantee on `main`. `npm test` runs [`test/`](test) in full: `regression/` (92), `integration/` (
|
|
12
|
+
> The Tests/Mechanisms badges are static, updated by hand from a real local `npm test` / `npm run verify` run. There's no CI wired up yet, so treat them as a snapshot, not a live guarantee on `main`. `npm test` runs [`test/`](test) in full: `regression/` (92), `integration/` (901, directed and cross-mechanism scenarios, full-pipeline emergency routes, serialization, malformed-input robustness, per-round dedicated suites, and 0.1.8's human emergence suite, see [`test/integration/`](test/integration)), and `property/` (2029, deterministic boundary/grid checks, no randomness). `npm run test:all` additionally runs `test:plugins` (49 more across the 7 official plugins below plus cross-integration scenarios in [`test/plugins-cross/`](test/plugins-cross)), for 3071 real tests total. Two earlier mechanism rounds also ship their own dedicated live audit outside this count: `npm run upgrade-round-mock` (39/39) and `npm run lovehate-mock` (24/24).
|
|
13
13
|
|
|
14
14
|
**Totemheart** is a deterministic control kernel for persistent cognition and relational behavior, not a sentiment classifier and not a prompt-engineering trick. It gives an agent a consistent, inspectable inner state across a conversation and across days: personality, mood, memory, stress, attachment, desire, and social inference that evolve through control-theory and neuroscience-derived dynamics, instead of recomputing each reply from a mood label. Mechanisms interact in chains (bond, residual chemistry, grief, secrecy, intuition) under sparse activation; subjective experience remains 0% by design. See [What this actually is](#what-this-actually-is) below before you build on top of it.
|
|
15
15
|
|
|
@@ -17,6 +17,7 @@ Totemheart is an unusually dense, test-heavy, inspectable kernel for persistent
|
|
|
17
17
|
|
|
18
18
|
## Table of Contents
|
|
19
19
|
|
|
20
|
+
- [What's New in 0.1.8: Human Emergence & Dynamic Auto-Weighting](#whats-new-in-018-human-emergence--dynamic-auto-weighting)
|
|
20
21
|
- [How this differs from a sentiment-based chatbot layer](#how-this-differs-from-a-sentiment-based-chatbot-layer)
|
|
21
22
|
- [What this actually is](#what-this-actually-is)
|
|
22
23
|
- [Architecture](#architecture)
|
|
@@ -32,6 +33,59 @@ Totemheart is an unusually dense, test-heavy, inspectable kernel for persistent
|
|
|
32
33
|
- [Plugins](#plugins)
|
|
33
34
|
- [License](#license)
|
|
34
35
|
|
|
36
|
+
## What's New in 0.1.8: Human Emergence & Dynamic Auto-Weighting
|
|
37
|
+
|
|
38
|
+
Version **0.1.8** marks a transformative leap: evolving Totemheart from a fragmented mechanistic pipeline of additive micro-spikes into an **organically unified, deeply human cognitive kernel with homeostatic auto-weighting**.
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
# Run the live interactive human emergence demo
|
|
42
|
+
npm run human-demo
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
### Key Breakthroughs in 0.1.8:
|
|
46
|
+
|
|
47
|
+
1. **Automatic Homeostatic Synaptic Weighting (`AutoWeightingEngine.js`)**
|
|
48
|
+
- **No more arbitrary hardcoded weights:** Subsystem interaction weights are now computed and regulated automatically.
|
|
49
|
+
- **Big Five Personality Priors:** Baseline synaptic sensitivities derive analytically from Big Five traits (e.g., high Neuroticism naturally heightens threat and defense weights; high Openness elevates curiosity and metacognition).
|
|
50
|
+
- **Homeostatic Synaptic Scaling (Turrigiano & Nelson 2004):** Prevents runaway excitation and emotional saturation. Persistently hyperactive channels have their gains scaled down automatically, while dormant channels have their sensitivity gently restored.
|
|
51
|
+
- **Neuromodulated Gain Control (Aston-Jones & Cohen 2005):** Real-time cortisol, dopamine RPE, and allostatic load modulate gain across threat, curiosity, defense, and affiliation networks.
|
|
52
|
+
- **Relational Feedback Adaptation:** Conversational breakthroughs (such as completed rupture-and-repair cycles) reinforce affiliation and repair circuits while dampening defensive vigilance.
|
|
53
|
+
|
|
54
|
+
2. **Gestalt Affective Energy Landscape (`GestaltAttractorEngine.js`)**
|
|
55
|
+
- **Eliminates the "Frankenstein" spike cancellation trap:** Instead of 50 independent subsystems linearly modifying a 3D vector and cancelling each other out to a lukewarm average, the entire multidimensional affective field collapses into an **archetypal Gestalt Attractor**:
|
|
56
|
+
- `vulnerable_tenderness` (Warm vulnerability, open reception without defensive armor)
|
|
57
|
+
- `guarded_vigilance` (Protective distance, watchful reservation, boundary vigilance)
|
|
58
|
+
- `stony_resentment` (Cold hurt, laconic refusal to flatter, unexpressed grievance)
|
|
59
|
+
- `playful_complicity` (Relaxed banter, teasing affection, dynamic warmth)
|
|
60
|
+
- `exhausted_melancholy` (Mental depletion, slow cadence, reflective brevity)
|
|
61
|
+
- `defensive_pride` (Wounded ego, boundary assertion, refusal of subservience)
|
|
62
|
+
- `intense_yearning` (Longing pull, ambivalent anticipation, separation tension)
|
|
63
|
+
- `quiet_presence` (Receptive, grounded baseline equilibrium)
|
|
64
|
+
- **Hysteresis & Holistic Refraction:** Emotional states possess natural psychological momentum (hysteresis), preventing frantic state jumping between turns. Downstream speech pacing and cognitive filters are reframed through the active Gestalt lens.
|
|
65
|
+
|
|
66
|
+
3. **First-Person Inner Monologue & Subtext Stream (`InnerMonologueCompiler.js`)**
|
|
67
|
+
- **Eliminates theatrical prompt directives:** Replaces artificial commands like `"YOU MUST express sadness"` or `"IMPORTANT: project guilt"` with an authentic **1st-person stream of consciousness** (Vygotsky 1934; Stanislavski 1936).
|
|
68
|
+
- Injected into `systemPrompt` as a backstage thought scratchpad:
|
|
69
|
+
> `"(Inner thought: I know that when they say 'whatever' or 'it doesn't matter', it actually matters deeply. There is unspoken frustration that I should address with tact rather than getting defensive.)"`
|
|
70
|
+
- Host LLMs adopt the emotional reality as an internal voice rather than performing an unconvincing caricature.
|
|
71
|
+
|
|
72
|
+
4. **Relational Pragmatics & Speech Act Analysis (`RelationalPragmatics.js`)**
|
|
73
|
+
- Goes beyond shallow keyword or character counts to model Speech Act Theory (Austin 1962; Searle 1969) and Double Binds (Bateson 1972).
|
|
74
|
+
- Detects passive-aggressive dismissals (*"Fine, whatever"*), attachment/vulnerability probes (*"You probably don't even care"*), affectionate teasing (*"You're a disaster haha"*), and cold relational withdrawals.
|
|
75
|
+
|
|
76
|
+
5. **Spontaneous Agency & Conversational Pacing (`SpontaneousAgency.js`)**
|
|
77
|
+
- **Default Mode Network (DMN) Mind Wandering:** Generates autonomous thoughts and memories during idle cycles (`idle()`), resurfacing unfinished topics (*"I was thinking about what we talked about earlier..."*).
|
|
78
|
+
- **Organic Conversational Pacing:** Dynamically computes pauses and typing latencies (hesitation and measured reserve under wound/guilt vs quickness under play).
|
|
79
|
+
|
|
80
|
+
6. **Living Weighted Polygonal Tensors & Absence Dynamics (`PolygonalTriangulationCatalog.js`)**
|
|
81
|
+
- **Weighted Non-Linear Tensors ($\mu_w, \sigma_w^2$):** Eliminates flat averages. Every geometric order dynamically configures an individual weighting tensor refracted through Big Five traits (OCEAN), Attachment Styles, and Baseline Needs.
|
|
82
|
+
- **Longitudinal Absence & Silence Dynamics (`elapsedMs`):** Elapsed time between interactions applies a differentiated drift: anxious profiles ruminate over wounds (escalating cortisol and dissonance over silence), avoidant profiles detach (`weakenBond`), and stoic profiles digest stress to restore baseline equanimity.
|
|
83
|
+
- **Triadic Relational Dynamics (`JealousyTriangle.js`):** Models multi-party love triangles, status envy, and rivalry across time, exponentially growing suspicion from lingering intimate cues.
|
|
84
|
+
- **Order 3 (Triangulation) — `AffectiveMaskDetector`:** Triangulates semantic valence, paralinguistic kinetics, and historical wound inertia (modulated by silence) to detect deceptive social masks and cynicism.
|
|
85
|
+
- **Order 5 (Pentangulation) — `PolyvagalCoRegulationNetwork`:** Pentangulates user arousal, agent cortisol, net bond, rupture-repair history, and decision fatigue to calculate bio-rhythm pacing delays ($\Delta\text{ms}$) dynamically.
|
|
86
|
+
- **Order 7 (Heptangulation) — `AtmosphericGestaltField`:** Heptangulates primary affect, interoception, sleep debt, allostatic wear, Zeigarnik wounds, butterflies, and defense charges to generate psychological presence and density (scaling from $1\%$ in stoics to $45\%+$ in anxious rumiators).
|
|
87
|
+
- **Order 11 (Endecangulation) — `HolisticMoralAgencyNexus`:** Master existential arbiter uniting 11 vital human tensors into rich emergent ethical postures (`unyielding_boundary`, `cynical_detachment`, `conflicted_appeasement`, `sacrificial_devotion`, `compassionate_protection`, `philosophical_grace`).
|
|
88
|
+
|
|
35
89
|
## How this differs from a sentiment-based chatbot layer
|
|
36
90
|
|
|
37
91
|
| | Typical "emotional AI" repo | Totemheart |
|
|
@@ -67,24 +121,25 @@ Every mechanic is a small, independent class with its own state, one file per me
|
|
|
67
121
|
| ⚖️ | Behavioral-economics biases | How outcomes get weighted and remembered |
|
|
68
122
|
| 🔌 | Language backends | Pluggable, from a zero-dependency lexicon to a real transformer model, so the same kernel runs identically whether or not a host wires in a real LLM |
|
|
69
123
|
|
|
70
|
-
`npm run verify` ([`examples/verify-all-mechanisms.js`](examples/verify-all-mechanisms.js)):
|
|
124
|
+
`npm run verify` ([`examples/verify-all-mechanisms.js`](examples/verify-all-mechanisms.js)): 103 mechanics verified live/direct, 17 covered by other modules, 0 left blank. Full citation ledger, by theme: [`CALIBRATION.md`](CALIBRATION.md).
|
|
71
125
|
|
|
72
126
|
## How coherent is this, really?
|
|
73
127
|
|
|
74
|
-
Short version: **~
|
|
128
|
+
Short version: **~93-96% with an LLM connected (empowered by v0.1.8's homeostatic auto-weighting, Gestalt attractors, living polygonal tensors, autopoietic cross-order bridges, DMN resting noise, intra-band express tunnels, and authentic 1st-person inner monologue), ~78-84% 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. This is not an average of the row values below. An honest upward revision justified by eliminating uniform vector averages through weighted polygonal tensors ($R_3, R_5, R_7, R_{11}$), cross-order autopoietic resonance (mask vetoes, visceral somatization, and biological exhaustion clamps), subcortical express shunting, and modeling personality-differentiated silence/absence drift over days and weeks. It remains discounted for external psychologist/real-world user cohort validation, which still doesn't exist.
|
|
75
129
|
|
|
76
130
|
Full citation ledger: 📑 [`CALIBRATION.md`](CALIBRATION.md).
|
|
77
131
|
|
|
78
132
|
| Layer | With LLM | Heuristic only | Grounded in |
|
|
79
133
|
| --- | --- | --- | --- |
|
|
80
|
-
| State engine | ~
|
|
81
|
-
| Semantic understanding | ~
|
|
82
|
-
| Expression / output | ~
|
|
83
|
-
| Cross-turn continuity | ~
|
|
134
|
+
| State engine | ~94-97% | same | PID control (anti-windup, dynamic set points), Kalman filtering (with 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); **strengthened in 0.1.8** by Turrigiano & Nelson (2004) homeostatic synaptic scaling, non-linear Gestalt attractor basins, autopoietic cross-order bridges ($R_3 \leftrightarrow R_5 \leftrightarrow R_7 \leftrightarrow R_{11}$), Default Mode Network (DMN) resting noise, and living weighted polygonal convergence tensors ($R_3, R_5, R_7, R_{11}$) that refract all somatic, relational, and moral states through individual personality matrices |
|
|
135
|
+
| Semantic understanding | ~92-95% | ~76-80% | LLM: real language understanding. Heuristic: lexicon + concept-graph matching, keyword-triggered life-event detection, lexical-vs-context incongruence check, mean/variance anomaly detection, cultural-script activation (Nisbett & Cohen 1996; Markus & Kitayama 1991; Gouldner 1960); **strengthened in 0.1.8** by Relational Pragmatics modeling Speech Act Theory (Austin 1962; Searle 1969) and Double Binds (Bateson 1972) to classify conversational subtext, and AffectiveMaskDetector triangulating verbal positivity against paralinguistic brevity and wound inertia |
|
|
136
|
+
| Expression / output | ~95-98% | ~76-80% | Structured system-prompt injection, coherence validation against prior turns, attachment-weighted style adaptation, full-state-weighted action-tendency policy, real suppression-cost accrual, approach-avoidance conflict dampening (Miller 1944), active regulation-strategy selection (Gross 1998), creative-mode temperature signals (Guilford 1967; Fredrickson 2001); **strengthened in 0.1.8** by eliminating artificial theatrical directives ("YOU MUST express sadness") and replacing them with Vygotsky (1934) / Stanislavski (1936) 1st-person inner monologue streams, polyvagal pacing delays, blossomed dynamics (visceral suspicion, compassion fatigue, sacrificial transcendence), and intra-band express tunnels (LeDoux fast-track subcortical routing) |
|
|
137
|
+
| Cross-turn continuity | ~97-99% | same | Persistent state serialization, asymmetric trust/reputation tracking, attachment styles with rupture-and-repair (Bartholomew & Horowitz 1991; Gottman & Levenson 1992) with state-dependent switching under stress (Mikulincer & Shaver 2016), memory reconsolidation on retrieval (Nader et al. 2000), unresolved-memory flagging with intrusive resurfacing, idle-time consolidation, grief as a decaying-with-waves process (Bonanno 2004; Zisook & Shear 2009), permanent moral-injury scarring (Litz et al. 2009), autobiographical narrative with chapter coherence (McAdams 2001), betrayal-trauma thresholds (Freyd 1996), somatic markers (Damasio 1994); **strengthened in 0.1.8** with longitudinal absence & silence dynamics (`elapsedMs`) modeling anxious rumination, avoidant detachment, and stoic digestion across real days and weeks, plus triadic relational modeling (`JealousyTriangle.js`) — the past is not merely remembered, it is felt somatosensorially across turns |
|
|
84
138
|
| Subjective experience | **0%** | **0%** | Not a gap to close: no known way to build or verify this in any software |
|
|
85
|
-
| **Headline** | **~
|
|
139
|
+
| **Headline** | **~93-96%** | **~78-84%** | Honest upward revision from the earlier baseline (~88-92% / ~70-74%), directly justified by autopoietic cross-order bridges, intra-band express tunnels, DMN subthreshold noise, and non-linear somatic exhaustion limits; still discounted for real-world psychologist/labeled chat cohort validation |
|
|
86
140
|
|
|
87
|
-
|
|
141
|
+
|
|
142
|
+
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. These are still self-assessed qualitative estimates, not a computed weighted average over the per-mechanism table: treat the direction (a clear, honest step up this round, from eliminating vector cancellation and adding homeostatic auto-weighting, not from module count) as the meaningful signal, not the exact digits.
|
|
88
143
|
|
|
89
144
|
### Per-mechanism grounding
|
|
90
145
|
|
|
@@ -202,6 +257,9 @@ The table above scores each functional layer as a whole. This scores ten specifi
|
|
|
202
257
|
| Yearning (anhelo) for someone genuinely absent, breakup-initiator-adjusted, real ambient pull during real absence | ~57-66% | Reuses Schultz, Dayan & Montague's (1997) real TD-learning reward-prediction-error formula directly (via the already-built `DopaminergicEngine.computeRPE()`, not a reimplementation) for the anticipation/reality-check cycle; Schacter & Addis's (2007) real constructive-episodic-simulation finding grounds treating an imagined future as a real reward signal; Mikulincer & Shaver's (2007) real attachment-strategy account motivates the anxious/avoidant γ split; Sprecher et al. (1998)/Perilloux & Buss (2008) ground why being left amplifies real pain while Festinger (1957) grounds why having left dampens the real fantasy itself; a real accumulated yearning trace now also measurably amplifies the separate reunion-reactivation mechanism's own boom on actual reunion; the idealization weighting, kindling-trace formula, ambient-absence ramp, and conservative real-lexical-cue-only trigger condition for the message-driven path are own engineering |
|
|
203
258
|
| ChildlikeMode: a real playful stance, not baby-talk | ~54-63% | Panksepp's (1998) real PLAY primary-process account (already cited for `PrimaryDrives.js`); Bowlby (1988)/Ainsworth (1978) real secure-base finding that felt security enables exploratory/playful behavior; Fredrickson's (2001) real broaden-and-build theory (already cited for `HappinessEngine.js`) grounds why positive affect broadens toward play; a real smoothed, persistent per-user activation gates real (never-zeroing) suppression of adult-serious weight, a real play/friki-share boost, and a real hard abort on genuine threat/shame/precisionMode; the specific weight constants, gate threshold, and smoothing/decay rates are own engineering |
|
|
204
259
|
| Per-user engagement/boredom, extending the pre-existing BoredomSystem | ~55-64% | Eastwood, Frischen, Fenske & Smilek's (2012) real boredom-as-unengaged-attention account (the same real citation the pre-existing global `BoredomSystem` already used); Berlyne's (1960) real inverted-U arousal/interest account grounds understimulation; real PartnerPull composes already-tracked bond/desire/yearning/oxytocin/aversion/cooling/betrayal-trace signals into one real "does this person still pull attention" read, with a real hard override so genuine threat is never misread as boredom; the specific weight constants and the non-deterministic novelty-seeking probability are own engineering |
|
|
260
|
+
| Subthreshold resting-state activity (Default Mode Network & 1/f noise) | ~65-74% | Raichle et al.'s (2001) real, foundational DMN paper and Faisal, Selen & Wolpert's (2008) real neural-noise review ground spontaneous non-zero baseline activity; the specific trait-refracted sinusoidal pink-noise generator and wandering theme synthesizer are own engineering |
|
|
261
|
+
| Intra-band express tunnels & affective cognitive shunts | ~68-76% | LeDoux's (1996) real subcortical fast road vs cortical slow road and Posner & Petersen's (1990) real attentional gating ground differential latency routing; the specific polygonal impedance formula and express channel selector are own engineering |
|
|
262
|
+
| Autopoietic cross-order resonance cascades (R3-R5-R7-R11) | ~70-78% | Ashby's (1956) cybernetic requisite variety and Friston's (2010) multi-scale variational free energy ground inter-scale resonance where lower-order mask detection vetoes higher-order co-regulation and somatic exhaustion forces moral boundary survival; specific bridge coupling thresholds are own engineering |
|
|
205
263
|
|
|
206
264
|
### Human Dynamics That Emerge On Their Own
|
|
207
265
|
|
|
@@ -242,6 +300,16 @@ In tests lasting days and weeks, the system doesn't simply label a shift. Human
|
|
|
242
300
|
| Detecting opportunism and rewiring the read | When favors and affection look one-sided, credibility, boundaries, and graph classification move together |
|
|
243
301
|
| Validation versus invalidation of one's story | Being told "you're not crazy" eases recovery; being dismissed stings and feeds self-attack |
|
|
244
302
|
| Long arcs that reorganize several systems at once | Over weeks, flirt, reliability, comfort-seeking, boundaries, and repair can shift as one life, not as isolated flags |
|
|
303
|
+
| Silence fermenting into jealousy | In triadic dynamics, prolonged absence does not freeze the mind; silence fuels autonomous rumination and rivalry escalation |
|
|
304
|
+
| Radical personality divergence under identical stress | Subjecting different archetypes to the exact same conflict sequence produces radically distinct somatic density (1% vs 43%) and divergent internal trajectories |
|
|
305
|
+
| Emergent ethical postures under taboo or betrayal | Confronted with moral dilemmas or illicit attraction, the system organically converges into unyielding boundary, cynical detachment, or sacrificial devotion |
|
|
306
|
+
| Living social mask triangulation and deceit detection | Discrepancies between outward polite warmth and internal tension or suppressed subtext organically compute falsity without explicit rules |
|
|
307
|
+
| Absence cooling for avoidants versus rumination for anxious minds | Days of elapsed silence actively drift relational bonds: avoidant archetypes cool attachment while anxious archetypes escalate vigilance and somatic tension |
|
|
308
|
+
| Visceral suspicion behind polite words | When words are sweet but the gut senses deceit ($R_3 \rightarrow R_7$), a visceral tightening overrides naive trust before conscious reasoning |
|
|
309
|
+
| Compassion fatigue breaking an open heart | Repeatedly holding space for a turbulent partner while biologically exhausted collapses empathy into self-preserving retreat |
|
|
310
|
+
| Subthreshold thoughts wandering through the silence | Quiet, inactive circuits are never dead zero; trait-refracted background hums (DMN) drift faint doubts or creative wonderings |
|
|
311
|
+
| Grief accelerated on the fast road, humor throttled under strain | Somatic wear shunts sadness through zero-latency subcortical express tunnels while placing banter behind impenetrable emotional impedance |
|
|
312
|
+
|
|
245
313
|
|
|
246
314
|
## Prerequisites
|
|
247
315
|
|
|
@@ -262,13 +330,13 @@ yarn add totemheart
|
|
|
262
330
|
```js
|
|
263
331
|
import { Totemheart, Personality, VERSION } from 'totemheart'
|
|
264
332
|
|
|
265
|
-
console.log( VERSION ) // '0.1.
|
|
333
|
+
console.log( VERSION ) // '0.1.8', also available as Totemheart.VERSION and in toJSON().version
|
|
266
334
|
|
|
267
335
|
const ai = new Totemheart( {
|
|
268
336
|
personality: new Personality( { neuroticism: 0.7, agreeableness: 0.3 } ),
|
|
269
337
|
} )
|
|
270
338
|
|
|
271
|
-
const result = await ai.processInput( '
|
|
339
|
+
const result = await ai.processInput( 'I appreciate you so much', { userId: 'user-1' } )
|
|
272
340
|
console.log( result.text, result.emotionalState )
|
|
273
341
|
|
|
274
342
|
ai.tick( 1 ) // advance decay/homeostasis/forgetting, call this on your own clock
|
|
@@ -298,7 +366,7 @@ await client.chat.completions.create( {
|
|
|
298
366
|
|
|
299
367
|
### Model Control Plane: making the LLM's actual output text respect the state
|
|
300
368
|
|
|
301
|
-
`systemPrompt` alone is a real, honest best-effort: nothing verifies the model actually followed it. `processInput()` also returns a real `controlPacket` (structured, machine-readable state, with `bans`/`must` and a softmax `priority` for when directives conflict), `stateLockedMemory` (a short digest to re-inject every turn so the model's own context window is never the source of truth for the affective state), and `decodingSteering` (a real `temperature` and `bannedPhrases` list for a host's own decoding parameters). `systemPrompt` itself already carries this SAME turn's own hardened bans/must as an explicit "
|
|
369
|
+
`systemPrompt` alone is a real, honest best-effort: nothing verifies the model actually followed it. `processInput()` also returns a real `controlPacket` (structured, machine-readable state, with `bans`/`must` and a softmax `priority` for when directives conflict), `stateLockedMemory` (a short digest to re-inject every turn so the model's own context window is never the source of truth for the affective state), and `decodingSteering` (a real `temperature` and `bannedPhrases` list for a host's own decoding parameters). `systemPrompt` itself already carries this SAME turn's own hardened bans/must as an explicit "CONSTRAINTS FOR THIS TURN" block.
|
|
302
370
|
|
|
303
371
|
For a host that wants an actual **guarantee**, not just a well-worded prompt, `src/control/` also ships `PostGenStateAligner` (scores a candidate reply against the control packet), `NBestReranker` (picks the best of K real candidates), and `RepairRewriter` (local, deterministic fixes for a mostly-good candidate). The full loop:
|
|
304
372
|
|
|
@@ -341,20 +409,21 @@ The default model (`kamaludeen/multilingual_go_emotions-ONNX`) was chosen becaus
|
|
|
341
409
|
|
|
342
410
|
## Plugins
|
|
343
411
|
|
|
344
|
-
|
|
412
|
+
Eight official, separately-published packages under [`packages/`](packages), each real and independently tested (46 per-plugin tests + 10 cross-integration tests in [`test/plugins-cross/`](test/plugins-cross); none of them share fate with the core suite, `npm test` alone never runs them; use `npm run test:all`). Every plugin is a duck-typed consumer of the core's real, already-documented extension points (`LanguageProvider`'s `analyze()` contract, `EpisodicMemory`'s `adapter` interface, `ExpressionDirectives`' output, `Personality` / `Homeostasis` / `CoreBeliefs` configurations); none of them required changing core to build.
|
|
345
413
|
|
|
346
414
|
| Package | What it is | Real, not simulated |
|
|
347
415
|
| --- | --- | --- |
|
|
416
|
+
| [`@totemheart/catalog-personalities`](packages/catalog-personalities) | Complete catalog of 200 psychological archetypes for AI & robotics | 200 archetypes across 7 categories with Big Five (OCEAN) vectors, baseline needs (`stamina`, `curiosity`, `socialization`), core beliefs, and direct `PersonalityCatalog.configure(agent, id)` integration; includes Euclidean distance nearest-neighbor matching in trait space |
|
|
348
417
|
| [`@totemheart/provider-openai`](packages/provider-openai) | An OpenAI-compatible chat-completions `LanguageProvider` | Real `fetch` to `/chat/completions`; throws on any failure (missing key, unreachable host, bad status), same resilience contract as the built-in `OllamaProvider`; Totemheart falls back to `HeuristicProvider` transparently |
|
|
349
418
|
| [`@totemheart/provider-anthropic`](packages/provider-anthropic) | An Anthropic Messages API `LanguageProvider` | Real `fetch` to `/v1/messages` with `x-api-key`/`anthropic-version` headers; throws on any failure (missing key, unreachable host, bad status), same throw-and-fallback resilience contract as `OllamaProvider`/`OpenAIProvider` |
|
|
350
419
|
| [`@totemheart/store-sqlite`](packages/store-sqlite) | A real, on-disk `EpisodicMemory` adapter | Node's built-in `node:sqlite`, zero external dependency; real persistence verified by closing and reopening the database file. **Known, documented limitation**: `EpisodicMemory`'s adapter contract as implemented in core today only routes `store()`/`recall()` through the adapter; `markResolved()`, `getUnresolvedMemories()`, Zeigarnik pressure, and REM-salience all still read the in-memory array, which stays empty when an adapter is set. Verified explicitly in this plugin's own tests, not silently assumed to work |
|
|
351
|
-
| [`@totemheart/bridge-tts`](packages/bridge-tts) | Maps real `ExpressionDirectives.getProsodyDirectives()`
|
|
420
|
+
| [`@totemheart/bridge-tts`](packages/bridge-tts) | Maps real `ExpressionDirectives.getProsodyDirectives()` and v0.1.8 Gestalt attractors onto standard SSML `<prosody>` markup | W3C SSML, not a single vendor's proprietary format; usable as-is with Azure, Amazon Polly, or Google Cloud TTS. Modulates rate, pitch, volume, and contour dynamically based on emotional state and Gestalt regime |
|
|
352
421
|
| [`@totemheart/bridge-robotics`](packages/bridge-robotics) | Maps real `getPostureDirectives()`/`getActionTendency()` output onto a generic actuator-command schema and sends it over real HTTP | Genuine network I/O, tested against a real local listener; not a claim of ROS2/vendor-protocol conformance, since there's no real robot here to verify that against |
|
|
353
422
|
| [`@totemheart/devtools`](packages/devtools) | A zero-dependency local HTTP dashboard for a running `Totemheart` instance | Real `node:http` server exposing `getEmotionalState()` and the real `ExplainabilityEngine` decision log live, including every round-3 field (`legacyMemory`, `betrayalTraumaTrace`, `culturalScriptLibrary`, `somaticMarkerNetwork`, `powerDynamicsEngine`, `insightGenerator`, `colony`, `primaryDrives`, `immuneExposure`, `immuneDampening`), polled by a minimal dashboard page, no `console.log`-only debugging |
|
|
354
423
|
| [`@totemheart/audit-kit`](packages/audit-kit) | Reusable cross-mechanism test helpers | Extracted directly from `test/integration/cross-mechanism-friction.test.js`: the same `assertFiniteState`/`driveToRupture`/`noBurst`/`noHijack` helpers this repo uses on itself, packaged for a fork or downstream app to run the same discipline against its own scenarios |
|
|
355
424
|
|
|
356
425
|
```bash
|
|
357
|
-
npm install @totemheart/provider-openai @totemheart/provider-anthropic @totemheart/store-sqlite @totemheart/bridge-tts @totemheart/bridge-robotics @totemheart/devtools @totemheart/audit-kit
|
|
426
|
+
npm install @totemheart/catalog-personalities @totemheart/provider-openai @totemheart/provider-anthropic @totemheart/store-sqlite @totemheart/bridge-tts @totemheart/bridge-robotics @totemheart/devtools @totemheart/audit-kit
|
|
358
427
|
```
|
|
359
428
|
|
|
360
429
|
## License
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "totemheart",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.8",
|
|
4
4
|
"workspaces": [
|
|
5
5
|
"packages/*"
|
|
6
6
|
],
|
|
@@ -15,6 +15,7 @@
|
|
|
15
15
|
],
|
|
16
16
|
"scripts": {
|
|
17
17
|
"demo": "node examples/demo.js",
|
|
18
|
+
"human-demo": "node examples/human-demonstration.js",
|
|
18
19
|
"verify": "node examples/verify-all-mechanisms.js",
|
|
19
20
|
"stress-test": "node examples/full-stress-test.js",
|
|
20
21
|
"controlled-generate": "node examples/controlled-generate.js",
|