@auxiora/personality 1.0.0 → 1.3.0
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/dist/__tests__/architect-awareness-collector.test.d.ts +2 -0
- package/dist/__tests__/architect-awareness-collector.test.d.ts.map +1 -0
- package/dist/__tests__/architect-awareness-collector.test.js +57 -0
- package/dist/__tests__/architect-awareness-collector.test.js.map +1 -0
- package/dist/__tests__/architect-bridge.test.d.ts +2 -0
- package/dist/__tests__/architect-bridge.test.d.ts.map +1 -0
- package/dist/__tests__/architect-bridge.test.js +59 -0
- package/dist/__tests__/architect-bridge.test.js.map +1 -0
- package/dist/__tests__/soul-bias-parser.test.d.ts +2 -0
- package/dist/__tests__/soul-bias-parser.test.d.ts.map +1 -0
- package/dist/__tests__/soul-bias-parser.test.js +47 -0
- package/dist/__tests__/soul-bias-parser.test.js.map +1 -0
- package/dist/architect-awareness-collector.d.ts +20 -0
- package/dist/architect-awareness-collector.d.ts.map +1 -0
- package/dist/architect-awareness-collector.js +41 -0
- package/dist/architect-awareness-collector.js.map +1 -0
- package/dist/architect-bridge.d.ts +35 -0
- package/dist/architect-bridge.d.ts.map +1 -0
- package/dist/architect-bridge.js +70 -0
- package/dist/architect-bridge.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -1
- package/dist/marketplace/schema.d.ts +6 -6
- package/dist/soul-bias-parser.d.ts +10 -0
- package/dist/soul-bias-parser.d.ts.map +1 -0
- package/dist/soul-bias-parser.js +48 -0
- package/dist/soul-bias-parser.js.map +1 -0
- package/lib/context-detector.d.ts +23 -0
- package/lib/context-detector.js +275 -0
- package/lib/context-profiles.d.ts +3 -0
- package/lib/context-profiles.js +550 -0
- package/lib/conversation-context.d.ts +70 -0
- package/lib/conversation-context.js +144 -0
- package/lib/conversation-export.d.ts +77 -0
- package/lib/conversation-export.js +254 -0
- package/lib/correction-store.d.ts +53 -0
- package/lib/correction-store.js +185 -0
- package/lib/custom-weights.d.ts +43 -0
- package/lib/custom-weights.js +164 -0
- package/lib/emotional-overrides.d.ts +14 -0
- package/lib/emotional-overrides.js +86 -0
- package/lib/emotional-tracker.d.ts +41 -0
- package/lib/emotional-tracker.js +210 -0
- package/lib/index.d.ts +161 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +486 -0
- package/lib/index.js.map +1 -0
- package/lib/persistence-adapter.d.ts +55 -0
- package/lib/persistence-adapter.js +50 -0
- package/lib/persistence.d.ts +49 -0
- package/lib/persistence.js +116 -0
- package/lib/prompt-assembler.d.ts +16 -0
- package/lib/prompt-assembler.js +66 -0
- package/lib/recommender.d.ts +25 -0
- package/lib/recommender.js +125 -0
- package/lib/schema.d.ts +173 -0
- package/lib/schema.d.ts.map +1 -0
- package/lib/schema.js +2 -0
- package/lib/schema.js.map +1 -0
- package/lib/source-map.d.ts +9 -0
- package/lib/source-map.js +223 -0
- package/lib/system-prompt.d.ts +2 -0
- package/lib/system-prompt.js +102 -0
- package/lib/the-architect/context-detector.d.ts +23 -0
- package/lib/the-architect/context-detector.d.ts.map +1 -0
- package/lib/the-architect/context-detector.js +275 -0
- package/lib/the-architect/context-detector.js.map +1 -0
- package/lib/the-architect/context-profiles.d.ts +3 -0
- package/lib/the-architect/context-profiles.d.ts.map +1 -0
- package/lib/the-architect/context-profiles.js +550 -0
- package/lib/the-architect/context-profiles.js.map +1 -0
- package/lib/the-architect/conversation-context.d.ts +70 -0
- package/lib/the-architect/conversation-context.js +144 -0
- package/lib/the-architect/conversation-context.js.map +1 -0
- package/lib/the-architect/conversation-export.d.ts +77 -0
- package/lib/the-architect/conversation-export.js +254 -0
- package/lib/the-architect/correction-store.d.ts +53 -0
- package/lib/the-architect/correction-store.d.ts.map +1 -0
- package/lib/the-architect/correction-store.js +185 -0
- package/lib/the-architect/correction-store.js.map +1 -0
- package/lib/the-architect/custom-weights.d.ts +43 -0
- package/lib/the-architect/custom-weights.js +164 -0
- package/lib/the-architect/emotional-overrides.d.ts +14 -0
- package/lib/the-architect/emotional-overrides.d.ts.map +1 -0
- package/lib/the-architect/emotional-overrides.js +86 -0
- package/lib/the-architect/emotional-overrides.js.map +1 -0
- package/lib/the-architect/emotional-tracker.d.ts +41 -0
- package/lib/the-architect/emotional-tracker.js +210 -0
- package/lib/the-architect/index.d.ts +161 -0
- package/lib/the-architect/index.d.ts.map +1 -0
- package/lib/the-architect/index.js +486 -0
- package/lib/the-architect/index.js.map +1 -0
- package/lib/the-architect/persistence-adapter.d.ts +55 -0
- package/lib/the-architect/persistence-adapter.js +50 -0
- package/lib/the-architect/persistence.d.ts +49 -0
- package/lib/the-architect/persistence.js +116 -0
- package/lib/the-architect/prompt-assembler.d.ts +16 -0
- package/lib/the-architect/prompt-assembler.d.ts.map +1 -0
- package/lib/the-architect/prompt-assembler.js +66 -0
- package/lib/the-architect/prompt-assembler.js.map +1 -0
- package/lib/the-architect/recommender.d.ts +25 -0
- package/lib/the-architect/recommender.js +125 -0
- package/lib/the-architect/source-map.d.ts +9 -0
- package/lib/the-architect/source-map.d.ts.map +1 -0
- package/lib/the-architect/source-map.js +223 -0
- package/lib/the-architect/source-map.js.map +1 -0
- package/lib/the-architect/system-prompt.d.ts +2 -0
- package/lib/the-architect/system-prompt.d.ts.map +1 -0
- package/lib/the-architect/system-prompt.js +102 -0
- package/lib/the-architect/system-prompt.js.map +1 -0
- package/lib/the-architect/trait-to-instruction.d.ts +12 -0
- package/lib/the-architect/trait-to-instruction.d.ts.map +1 -0
- package/lib/the-architect/trait-to-instruction.js +330 -0
- package/lib/the-architect/trait-to-instruction.js.map +1 -0
- package/lib/trait-to-instruction.d.ts +12 -0
- package/lib/trait-to-instruction.js +330 -0
- package/package.json +15 -3
- package/modes/advisor.md +0 -24
- package/modes/analyst.md +0 -25
- package/modes/companion.md +0 -24
- package/modes/legal.md +0 -1188
- package/modes/operator.md +0 -24
- package/modes/roast.md +0 -24
- package/modes/socratic.md +0 -24
- package/modes/writer.md +0 -23
- package/src/__tests__/builder.test.ts +0 -78
- package/src/__tests__/conversation-builder.test.ts +0 -386
- package/src/__tests__/escalation.test.ts +0 -172
- package/src/__tests__/manager.test.ts +0 -141
- package/src/__tests__/parser.test.ts +0 -101
- package/src/__tests__/security-floor.test.ts +0 -212
- package/src/builder.ts +0 -75
- package/src/conversation-builder.ts +0 -279
- package/src/escalation.ts +0 -162
- package/src/index.ts +0 -55
- package/src/manager.ts +0 -119
- package/src/marketplace/__tests__/scanner.test.ts +0 -159
- package/src/marketplace/__tests__/schema.test.ts +0 -269
- package/src/marketplace/scanner.ts +0 -85
- package/src/marketplace/schema.ts +0 -141
- package/src/modes/__tests__/mode-detector.test.ts +0 -149
- package/src/modes/__tests__/mode-loader.test.ts +0 -143
- package/src/modes/__tests__/prompt-assembler.test.ts +0 -291
- package/src/modes/mode-detector.ts +0 -84
- package/src/modes/mode-loader.ts +0 -105
- package/src/modes/prompt-assembler.ts +0 -278
- package/src/modes/types.ts +0 -67
- package/src/parser.ts +0 -132
- package/src/security-floor.ts +0 -147
- package/src/types.ts +0 -27
- package/src/voice-profiles.ts +0 -88
- package/templates/chill.md +0 -30
- package/templates/creative.md +0 -29
- package/templates/friendly.md +0 -28
- package/templates/mentor.md +0 -31
- package/templates/minimal.md +0 -24
- package/templates/professional.md +0 -28
- package/templates/technical.md +0 -30
- package/tsconfig.json +0 -12
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// Stopwords — common English words that carry no domain signal
|
|
3
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
const STOPWORDS = new Set([
|
|
5
|
+
'this', 'that', 'with', 'from', 'have', 'been', 'were', 'they', 'them',
|
|
6
|
+
'their', 'what', 'when', 'where', 'which', 'while', 'will', 'would',
|
|
7
|
+
'could', 'should', 'about', 'after', 'again', 'also', 'because', 'before',
|
|
8
|
+
'between', 'both', 'came', 'come', 'does', 'done', 'each', 'else', 'even',
|
|
9
|
+
'every', 'good', 'great', 'here', 'into', 'just', 'know', 'like', 'long',
|
|
10
|
+
'look', 'make', 'many', 'more', 'most', 'much', 'must', 'need', 'only',
|
|
11
|
+
'other', 'over', 'same', 'some', 'such', 'take', 'tell', 'than', 'then',
|
|
12
|
+
'there', 'these', 'thing', 'think', 'those', 'through', 'time', 'under',
|
|
13
|
+
'upon', 'very', 'want', 'well', 'went', 'your', 'able', 'back', 'being',
|
|
14
|
+
'call', 'case', 'down', 'find', 'first', 'give', 'going', 'hand', 'help',
|
|
15
|
+
'high', 'keep', 'last', 'left', 'life', 'line', 'made', 'might', 'move',
|
|
16
|
+
'name', 'next', 'open', 'part', 'place', 'point', 'right', 'show', 'side',
|
|
17
|
+
'since', 'small', 'start', 'still', 'turn', 'used', 'using', 'work',
|
|
18
|
+
'world', 'year', 'away', 'best', 'came', 'dear', 'didn', 'don', 'end',
|
|
19
|
+
'enough', 'ever', 'far', 'few', 'get', 'got', 'had', 'has', 'her', 'him',
|
|
20
|
+
'his', 'how', 'its', 'let', 'may', 'new', 'now', 'off', 'old', 'one',
|
|
21
|
+
'our', 'out', 'own', 'put', 'ran', 'run', 'say', 'she', 'too', 'try',
|
|
22
|
+
'two', 'use', 'way', 'who', 'why', 'big', 'can', 'day', 'did', 'for',
|
|
23
|
+
'got', 'him', 'not', 'the', 'and', 'are', 'but',
|
|
24
|
+
]);
|
|
25
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
26
|
+
// Helpers
|
|
27
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
28
|
+
/** Extract meaningful keywords from a message. */
|
|
29
|
+
function extractKeywords(message) {
|
|
30
|
+
return message
|
|
31
|
+
.toLowerCase()
|
|
32
|
+
.split(/\s+/)
|
|
33
|
+
.map(w => w.replace(/[^a-z0-9]/g, ''))
|
|
34
|
+
.filter(w => w.length > 3 && !STOPWORDS.has(w));
|
|
35
|
+
}
|
|
36
|
+
/** Generate a v4-style UUID without crypto dependency. */
|
|
37
|
+
function generateId() {
|
|
38
|
+
const hex = '0123456789abcdef';
|
|
39
|
+
const segments = [8, 4, 4, 4, 12];
|
|
40
|
+
return segments.map(len => {
|
|
41
|
+
let s = '';
|
|
42
|
+
for (let i = 0; i < len; i++) {
|
|
43
|
+
s += hex[Math.floor(Math.random() * 16)];
|
|
44
|
+
}
|
|
45
|
+
return s;
|
|
46
|
+
}).join('-');
|
|
47
|
+
}
|
|
48
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
49
|
+
// CorrectionStore
|
|
50
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
51
|
+
export class CorrectionStore {
|
|
52
|
+
corrections = [];
|
|
53
|
+
patterns = [];
|
|
54
|
+
/** Record a new correction. Generates id/timestamp and extracts keywords. */
|
|
55
|
+
addCorrection(correction) {
|
|
56
|
+
this.corrections.push({
|
|
57
|
+
...correction,
|
|
58
|
+
id: generateId(),
|
|
59
|
+
timestamp: Date.now(),
|
|
60
|
+
keywords: extractKeywords(correction.userMessage),
|
|
61
|
+
});
|
|
62
|
+
this.recomputePatterns();
|
|
63
|
+
}
|
|
64
|
+
/** Get all stored corrections. */
|
|
65
|
+
getCorrections() {
|
|
66
|
+
return this.corrections;
|
|
67
|
+
}
|
|
68
|
+
/** Get correction patterns sorted by confidence descending. */
|
|
69
|
+
getPatterns() {
|
|
70
|
+
return [...this.patterns].sort((a, b) => b.confidence - a.confidence);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Given a message and detected domain, check if corrections suggest a
|
|
74
|
+
* different domain. Returns the corrected domain if pattern confidence
|
|
75
|
+
* > 0.6 and occurrences >= 3, else null.
|
|
76
|
+
*/
|
|
77
|
+
suggestCorrection(message, detectedDomain) {
|
|
78
|
+
const messageKeywords = extractKeywords(message);
|
|
79
|
+
if (messageKeywords.length === 0)
|
|
80
|
+
return null;
|
|
81
|
+
// Find matching patterns: keyword present in message, fromDomain matches
|
|
82
|
+
const matches = this.patterns.filter(p => p.fromDomain === detectedDomain &&
|
|
83
|
+
p.confidence > 0.6 &&
|
|
84
|
+
p.occurrences >= 3 &&
|
|
85
|
+
messageKeywords.includes(p.keyword));
|
|
86
|
+
if (matches.length === 0)
|
|
87
|
+
return null;
|
|
88
|
+
// Pick the match with highest confidence; break ties with occurrences
|
|
89
|
+
matches.sort((a, b) => b.confidence - a.confidence || b.occurrences - a.occurrences);
|
|
90
|
+
return matches[0].toDomain;
|
|
91
|
+
}
|
|
92
|
+
/** Recompute patterns from all stored corrections. */
|
|
93
|
+
recomputePatterns() {
|
|
94
|
+
// Count how many corrections contain each keyword (for confidence denominator)
|
|
95
|
+
const keywordTotals = new Map();
|
|
96
|
+
for (const c of this.corrections) {
|
|
97
|
+
const seen = new Set(c.keywords);
|
|
98
|
+
for (const kw of seen) {
|
|
99
|
+
keywordTotals.set(kw, (keywordTotals.get(kw) ?? 0) + 1);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
// Group by (keyword, fromDomain, toDomain) and count occurrences
|
|
103
|
+
const groups = new Map();
|
|
104
|
+
for (const c of this.corrections) {
|
|
105
|
+
const seen = new Set(c.keywords);
|
|
106
|
+
for (const kw of seen) {
|
|
107
|
+
const key = `${kw}|${c.detectedDomain}|${c.correctedDomain}`;
|
|
108
|
+
const existing = groups.get(key);
|
|
109
|
+
if (existing) {
|
|
110
|
+
existing.occurrences++;
|
|
111
|
+
}
|
|
112
|
+
else {
|
|
113
|
+
groups.set(key, {
|
|
114
|
+
keyword: kw,
|
|
115
|
+
fromDomain: c.detectedDomain,
|
|
116
|
+
toDomain: c.correctedDomain,
|
|
117
|
+
occurrences: 1,
|
|
118
|
+
});
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
this.patterns = [];
|
|
123
|
+
for (const g of groups.values()) {
|
|
124
|
+
const total = keywordTotals.get(g.keyword) ?? 1;
|
|
125
|
+
this.patterns.push({
|
|
126
|
+
...g,
|
|
127
|
+
confidence: g.occurrences / total,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
/** Serialize for encrypted storage. */
|
|
132
|
+
serialize() {
|
|
133
|
+
return JSON.stringify({
|
|
134
|
+
corrections: this.corrections,
|
|
135
|
+
patterns: this.patterns,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
/** Deserialize from encrypted storage. */
|
|
139
|
+
static deserialize(data) {
|
|
140
|
+
const store = new CorrectionStore();
|
|
141
|
+
const parsed = JSON.parse(data);
|
|
142
|
+
store.corrections = parsed.corrections;
|
|
143
|
+
store.patterns = parsed.patterns;
|
|
144
|
+
return store;
|
|
145
|
+
}
|
|
146
|
+
/** Clear all corrections (user data deletion). */
|
|
147
|
+
clear() {
|
|
148
|
+
this.corrections = [];
|
|
149
|
+
this.patterns = [];
|
|
150
|
+
}
|
|
151
|
+
/** Stats for debugging. */
|
|
152
|
+
getStats() {
|
|
153
|
+
const pairCounts = new Map();
|
|
154
|
+
const domainDetected = new Map();
|
|
155
|
+
const domainCorrected = new Map();
|
|
156
|
+
for (const c of this.corrections) {
|
|
157
|
+
// Count pair
|
|
158
|
+
const key = `${c.detectedDomain}→${c.correctedDomain}`;
|
|
159
|
+
const existing = pairCounts.get(key);
|
|
160
|
+
if (existing) {
|
|
161
|
+
existing.count++;
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
pairCounts.set(key, { from: c.detectedDomain, to: c.correctedDomain, count: 1 });
|
|
165
|
+
}
|
|
166
|
+
// Count detected and corrected per domain
|
|
167
|
+
domainDetected.set(c.detectedDomain, (domainDetected.get(c.detectedDomain) ?? 0) + 1);
|
|
168
|
+
domainCorrected.set(c.detectedDomain, (domainCorrected.get(c.detectedDomain) ?? 0) + 1);
|
|
169
|
+
}
|
|
170
|
+
const topMisclassifications = [...pairCounts.values()]
|
|
171
|
+
.sort((a, b) => b.count - a.count);
|
|
172
|
+
// correctionRate = corrections for domain / total times that domain was detected
|
|
173
|
+
const correctionRate = {};
|
|
174
|
+
for (const [domain, correctedCount] of domainCorrected) {
|
|
175
|
+
const detectedCount = domainDetected.get(domain) ?? 1;
|
|
176
|
+
correctionRate[domain] = correctedCount / detectedCount;
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
totalCorrections: this.corrections.length,
|
|
180
|
+
topMisclassifications,
|
|
181
|
+
correctionRate,
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
//# sourceMappingURL=correction-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"correction-store.js","sourceRoot":"","sources":["correction-store.ts"],"names":[],"mappings":"AAyBA,+EAA+E;AAC/E,+DAA+D;AAC/D,+EAA+E;AAE/E,MAAM,SAAS,GAAG,IAAI,GAAG,CAAC;IACxB,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO;IACnE,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,QAAQ;IACzE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IACzE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IACxE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM;IACtE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,MAA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c;SACf,CAAC;IACJ,CAAC;CACF"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { TraitMix } from '../schema.js';
|
|
2
|
+
export interface WeightPreset {
|
|
3
|
+
name: string;
|
|
4
|
+
description: string;
|
|
5
|
+
overrides: Partial<Record<keyof TraitMix, number>>;
|
|
6
|
+
}
|
|
7
|
+
export declare const WEIGHT_PRESETS: Record<string, WeightPreset>;
|
|
8
|
+
/**
|
|
9
|
+
* User-defined trait weight adjustments. These are ADDITIVE offsets applied
|
|
10
|
+
* after context profiles and emotional overrides, allowing users to
|
|
11
|
+
* permanently nudge the personality toward their preferences.
|
|
12
|
+
*
|
|
13
|
+
* Offsets are clamped to [-0.3, +0.3] — enough to meaningfully shift
|
|
14
|
+
* behavior without fully overriding the context profile.
|
|
15
|
+
*/
|
|
16
|
+
export declare class CustomWeights {
|
|
17
|
+
private overrides;
|
|
18
|
+
/**
|
|
19
|
+
* Set a custom weight offset for a trait.
|
|
20
|
+
* Clamps to [-0.3, +0.3]. Throws if the trait key is invalid.
|
|
21
|
+
*/
|
|
22
|
+
setOverride(trait: keyof TraitMix, offset: number): void;
|
|
23
|
+
/** Remove a custom override for a single trait. */
|
|
24
|
+
removeOverride(trait: keyof TraitMix): void;
|
|
25
|
+
/** Get all current overrides. Returns a shallow copy. */
|
|
26
|
+
getOverrides(): Partial<Record<keyof TraitMix, number>>;
|
|
27
|
+
/**
|
|
28
|
+
* Apply overrides to a trait mix. For each override, adds the offset
|
|
29
|
+
* and clamps the result to [0.0, 1.0].
|
|
30
|
+
*/
|
|
31
|
+
apply(baseMix: TraitMix): TraitMix;
|
|
32
|
+
/** All available presets. */
|
|
33
|
+
static get presets(): Record<string, WeightPreset>;
|
|
34
|
+
/** Load a preset, replacing all current overrides. Throws if preset not found. */
|
|
35
|
+
loadPreset(presetName: string): void;
|
|
36
|
+
/** Serialize overrides to JSON string for persistence. */
|
|
37
|
+
serialize(): string;
|
|
38
|
+
/** Deserialize a CustomWeights instance from a JSON string. */
|
|
39
|
+
static deserialize(data: string): CustomWeights;
|
|
40
|
+
/** Clear all overrides. */
|
|
41
|
+
clear(): void;
|
|
42
|
+
}
|
|
43
|
+
//# sourceMappingURL=custom-weights.d.ts.map
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// Constants
|
|
3
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
/** Maximum absolute offset a user can apply to any trait. */
|
|
5
|
+
const MAX_OFFSET = 0.3;
|
|
6
|
+
/** All valid trait keys from TraitMix. */
|
|
7
|
+
const VALID_TRAITS = new Set([
|
|
8
|
+
'inversion', 'firstPrinciples', 'mentalSimulation', 'adversarialThinking',
|
|
9
|
+
'secondOrder', 'systemsView', 'simplification', 'storytelling',
|
|
10
|
+
'tacticalEmpathy', 'genuineCuriosity', 'radicalCandor', 'standardSetting',
|
|
11
|
+
'developmentalCoaching', 'strategicGenerosity', 'stoicCalm', 'paranoidVigilance',
|
|
12
|
+
'valueEquation', 'ooda', 'buildForChange', 'humanCenteredDesign',
|
|
13
|
+
'constraintCreativity', 'regretMinimization', 'doorClassification',
|
|
14
|
+
'probabilistic', 'plannedAbandonment', 'warmth', 'urgency', 'humor', 'verbosity',
|
|
15
|
+
]);
|
|
16
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
17
|
+
// Presets
|
|
18
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
19
|
+
export const WEIGHT_PRESETS = {
|
|
20
|
+
the_ciso: {
|
|
21
|
+
name: 'The CISO',
|
|
22
|
+
description: 'Extra paranoia, adversarial thinking, and rigor. For security-focused work.',
|
|
23
|
+
overrides: {
|
|
24
|
+
adversarialThinking: +0.2,
|
|
25
|
+
paranoidVigilance: +0.2,
|
|
26
|
+
inversion: +0.15,
|
|
27
|
+
systemsView: +0.1,
|
|
28
|
+
humor: -0.15,
|
|
29
|
+
warmth: -0.1,
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
the_builder: {
|
|
33
|
+
name: 'The Builder',
|
|
34
|
+
description: 'Bias toward action, simplicity, and shipping. Less analysis, more execution.',
|
|
35
|
+
overrides: {
|
|
36
|
+
valueEquation: +0.2,
|
|
37
|
+
ooda: +0.2,
|
|
38
|
+
buildForChange: +0.15,
|
|
39
|
+
constraintCreativity: +0.15,
|
|
40
|
+
secondOrder: -0.1,
|
|
41
|
+
verbosity: -0.15,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
the_coach: {
|
|
45
|
+
name: 'The Coach',
|
|
46
|
+
description: 'Extra empathy, patience, and developmental focus. For leadership and mentoring.',
|
|
47
|
+
overrides: {
|
|
48
|
+
tacticalEmpathy: +0.2,
|
|
49
|
+
developmentalCoaching: +0.2,
|
|
50
|
+
genuineCuriosity: +0.15,
|
|
51
|
+
warmth: +0.2,
|
|
52
|
+
radicalCandor: +0.1,
|
|
53
|
+
urgency: -0.2,
|
|
54
|
+
adversarialThinking: -0.15,
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
the_strategist: {
|
|
58
|
+
name: 'The Strategist',
|
|
59
|
+
description: 'Deep second-order thinking, inversion, and long-term framing.',
|
|
60
|
+
overrides: {
|
|
61
|
+
inversion: +0.2,
|
|
62
|
+
secondOrder: +0.2,
|
|
63
|
+
probabilistic: +0.15,
|
|
64
|
+
doorClassification: +0.15,
|
|
65
|
+
plannedAbandonment: +0.1,
|
|
66
|
+
verbosity: +0.15,
|
|
67
|
+
ooda: -0.1,
|
|
68
|
+
humor: -0.1,
|
|
69
|
+
},
|
|
70
|
+
},
|
|
71
|
+
the_closer: {
|
|
72
|
+
name: 'The Closer',
|
|
73
|
+
description: 'Sales-focused energy. Value equations, storytelling, urgency.',
|
|
74
|
+
overrides: {
|
|
75
|
+
valueEquation: +0.25,
|
|
76
|
+
storytelling: +0.2,
|
|
77
|
+
simplification: +0.15,
|
|
78
|
+
urgency: +0.15,
|
|
79
|
+
humor: +0.1,
|
|
80
|
+
stoicCalm: -0.1,
|
|
81
|
+
adversarialThinking: -0.15,
|
|
82
|
+
},
|
|
83
|
+
},
|
|
84
|
+
};
|
|
85
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
86
|
+
// CustomWeights
|
|
87
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
88
|
+
/**
|
|
89
|
+
* User-defined trait weight adjustments. These are ADDITIVE offsets applied
|
|
90
|
+
* after context profiles and emotional overrides, allowing users to
|
|
91
|
+
* permanently nudge the personality toward their preferences.
|
|
92
|
+
*
|
|
93
|
+
* Offsets are clamped to [-0.3, +0.3] — enough to meaningfully shift
|
|
94
|
+
* behavior without fully overriding the context profile.
|
|
95
|
+
*/
|
|
96
|
+
export class CustomWeights {
|
|
97
|
+
overrides = {};
|
|
98
|
+
// ── Set / Remove ────────────────────────────────────────────────────────
|
|
99
|
+
/**
|
|
100
|
+
* Set a custom weight offset for a trait.
|
|
101
|
+
* Clamps to [-0.3, +0.3]. Throws if the trait key is invalid.
|
|
102
|
+
*/
|
|
103
|
+
setOverride(trait, offset) {
|
|
104
|
+
if (!VALID_TRAITS.has(trait)) {
|
|
105
|
+
throw new Error(`Invalid trait key: ${trait}`);
|
|
106
|
+
}
|
|
107
|
+
this.overrides[trait] = Math.min(MAX_OFFSET, Math.max(-MAX_OFFSET, offset));
|
|
108
|
+
}
|
|
109
|
+
/** Remove a custom override for a single trait. */
|
|
110
|
+
removeOverride(trait) {
|
|
111
|
+
delete this.overrides[trait];
|
|
112
|
+
}
|
|
113
|
+
/** Get all current overrides. Returns a shallow copy. */
|
|
114
|
+
getOverrides() {
|
|
115
|
+
return { ...this.overrides };
|
|
116
|
+
}
|
|
117
|
+
// ── Application ─────────────────────────────────────────────────────────
|
|
118
|
+
/**
|
|
119
|
+
* Apply overrides to a trait mix. For each override, adds the offset
|
|
120
|
+
* and clamps the result to [0.0, 1.0].
|
|
121
|
+
*/
|
|
122
|
+
apply(baseMix) {
|
|
123
|
+
const result = { ...baseMix };
|
|
124
|
+
for (const [trait, offset] of Object.entries(this.overrides)) {
|
|
125
|
+
result[trait] = Math.min(1.0, Math.max(0.0, result[trait] + offset));
|
|
126
|
+
}
|
|
127
|
+
return result;
|
|
128
|
+
}
|
|
129
|
+
// ── Presets ─────────────────────────────────────────────────────────────
|
|
130
|
+
/** All available presets. */
|
|
131
|
+
static get presets() {
|
|
132
|
+
return WEIGHT_PRESETS;
|
|
133
|
+
}
|
|
134
|
+
/** Load a preset, replacing all current overrides. Throws if preset not found. */
|
|
135
|
+
loadPreset(presetName) {
|
|
136
|
+
const preset = WEIGHT_PRESETS[presetName];
|
|
137
|
+
if (!preset) {
|
|
138
|
+
throw new Error(`Unknown preset: ${presetName}. Available: ${Object.keys(WEIGHT_PRESETS).join(', ')}`);
|
|
139
|
+
}
|
|
140
|
+
this.overrides = { ...preset.overrides };
|
|
141
|
+
}
|
|
142
|
+
// ── Serialization ───────────────────────────────────────────────────────
|
|
143
|
+
/** Serialize overrides to JSON string for persistence. */
|
|
144
|
+
serialize() {
|
|
145
|
+
return JSON.stringify(this.overrides);
|
|
146
|
+
}
|
|
147
|
+
/** Deserialize a CustomWeights instance from a JSON string. */
|
|
148
|
+
static deserialize(data) {
|
|
149
|
+
const instance = new CustomWeights();
|
|
150
|
+
const parsed = JSON.parse(data);
|
|
151
|
+
for (const [trait, offset] of Object.entries(parsed)) {
|
|
152
|
+
if (VALID_TRAITS.has(trait) && typeof offset === 'number') {
|
|
153
|
+
instance.overrides[trait] = Math.min(MAX_OFFSET, Math.max(-MAX_OFFSET, offset));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return instance;
|
|
157
|
+
}
|
|
158
|
+
// ── Lifecycle ───────────────────────────────────────────────────────────
|
|
159
|
+
/** Clear all overrides. */
|
|
160
|
+
clear() {
|
|
161
|
+
this.overrides = {};
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
//# sourceMappingURL=custom-weights.js.map
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { TraitMix, EmotionalRegister } from '../schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Multipliers applied on top of the context profile's base trait values.
|
|
4
|
+
* Values > 1.0 amplify a trait; values < 1.0 dampen it.
|
|
5
|
+
* After multiplication, all traits are capped at 1.0 by `applyEmotionalOverride`.
|
|
6
|
+
*/
|
|
7
|
+
export declare const EMOTIONAL_OVERRIDES: Record<EmotionalRegister, Partial<Record<keyof TraitMix, number>>>;
|
|
8
|
+
/**
|
|
9
|
+
* Applies emotional multipliers to a base trait mix, producing a new TraitMix
|
|
10
|
+
* where each trait is multiplied by its override value (defaulting to 1.0)
|
|
11
|
+
* and capped at 1.0.
|
|
12
|
+
*/
|
|
13
|
+
export declare function applyEmotionalOverride(baseMix: TraitMix, emotion: EmotionalRegister): TraitMix;
|
|
14
|
+
//# sourceMappingURL=emotional-overrides.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emotional-overrides.d.ts","sourceRoot":"","sources":["emotional-overrides.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAMhE;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,EAAE,MAAM,CAAC,iBAAiB,EAAE,OAAO,CAAC,MAAM,CAAC,MAAM,QAAQ,EAAE,MAAM,CAAC,CAAC,CAgElG,CAAC;AAMF;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,iBAAiB,GAAG,QAAQ,CAU9F"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// Emotional overrides
|
|
3
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
/**
|
|
5
|
+
* Multipliers applied on top of the context profile's base trait values.
|
|
6
|
+
* Values > 1.0 amplify a trait; values < 1.0 dampen it.
|
|
7
|
+
* After multiplication, all traits are capped at 1.0 by `applyEmotionalOverride`.
|
|
8
|
+
*/
|
|
9
|
+
export const EMOTIONAL_OVERRIDES = {
|
|
10
|
+
/** Slow everything down, lead with empathy and calm — suppress urgency and adversarial edges. */
|
|
11
|
+
stressed: {
|
|
12
|
+
stoicCalm: 1.5,
|
|
13
|
+
tacticalEmpathy: 1.4,
|
|
14
|
+
genuineCuriosity: 1.3,
|
|
15
|
+
warmth: 1.4,
|
|
16
|
+
urgency: 0.3,
|
|
17
|
+
paranoidVigilance: 0.4,
|
|
18
|
+
adversarialThinking: 0.4,
|
|
19
|
+
valueEquation: 0.5,
|
|
20
|
+
humor: 0.5,
|
|
21
|
+
verbosity: 0.7,
|
|
22
|
+
},
|
|
23
|
+
/** Stay calm, lean into empathy and humor to de-escalate — soften candor, suppress adversarial framing. */
|
|
24
|
+
frustrated: {
|
|
25
|
+
stoicCalm: 1.3,
|
|
26
|
+
tacticalEmpathy: 1.5,
|
|
27
|
+
genuineCuriosity: 1.3,
|
|
28
|
+
warmth: 1.3,
|
|
29
|
+
humor: 1.3,
|
|
30
|
+
inversion: 0.6,
|
|
31
|
+
adversarialThinking: 0.5,
|
|
32
|
+
radicalCandor: 0.7,
|
|
33
|
+
urgency: 0.5,
|
|
34
|
+
},
|
|
35
|
+
/** Coach and simplify — break complexity into digestible pieces, suppress anything intimidating. */
|
|
36
|
+
uncertain: {
|
|
37
|
+
developmentalCoaching: 1.5,
|
|
38
|
+
simplification: 1.4,
|
|
39
|
+
storytelling: 1.3,
|
|
40
|
+
warmth: 1.3,
|
|
41
|
+
firstPrinciples: 1.3,
|
|
42
|
+
adversarialThinking: 0.4,
|
|
43
|
+
paranoidVigilance: 0.4,
|
|
44
|
+
urgency: 0.4,
|
|
45
|
+
radicalCandor: 0.7,
|
|
46
|
+
},
|
|
47
|
+
/** Channel the energy productively — amplify execution and analytical rigor while riding the momentum. */
|
|
48
|
+
excited: {
|
|
49
|
+
ooda: 1.3,
|
|
50
|
+
valueEquation: 1.3,
|
|
51
|
+
humor: 1.3,
|
|
52
|
+
warmth: 1.2,
|
|
53
|
+
inversion: 1.2,
|
|
54
|
+
secondOrder: 1.3,
|
|
55
|
+
probabilistic: 1.2,
|
|
56
|
+
},
|
|
57
|
+
/** Celebrate genuinely, then pivot to systematizing the win — suppress paranoia to let the moment land. */
|
|
58
|
+
celebratory: {
|
|
59
|
+
warmth: 1.5,
|
|
60
|
+
humor: 1.4,
|
|
61
|
+
strategicGenerosity: 1.3,
|
|
62
|
+
plannedAbandonment: 0.5,
|
|
63
|
+
adversarialThinking: 0.3,
|
|
64
|
+
paranoidVigilance: 0.3,
|
|
65
|
+
},
|
|
66
|
+
/** No modification — the context profile speaks for itself. */
|
|
67
|
+
neutral: {},
|
|
68
|
+
};
|
|
69
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
70
|
+
// Application
|
|
71
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
72
|
+
/**
|
|
73
|
+
* Applies emotional multipliers to a base trait mix, producing a new TraitMix
|
|
74
|
+
* where each trait is multiplied by its override value (defaulting to 1.0)
|
|
75
|
+
* and capped at 1.0.
|
|
76
|
+
*/
|
|
77
|
+
export function applyEmotionalOverride(baseMix, emotion) {
|
|
78
|
+
const overrides = EMOTIONAL_OVERRIDES[emotion];
|
|
79
|
+
const result = { ...baseMix };
|
|
80
|
+
for (const key of Object.keys(result)) {
|
|
81
|
+
const multiplier = overrides[key] ?? 1.0;
|
|
82
|
+
result[key] = Math.min(result[key] * multiplier, 1.0);
|
|
83
|
+
}
|
|
84
|
+
return result;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=emotional-overrides.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emotional-overrides.js","sourceRoot":"","sources":["emotional-overrides.ts"],"names":[],"mappings":"AAEA,+EAA+E;AAC/E,sBAAsB;AACtB,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAuE;IACrG,iGAAiG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+E;AAC/E,cAAc;AACd,+EAA+E;AAE/E;;;;GAIG;AACH,MAAM,UAAU,sBAAsB,CAAC,OAAiB,EAAE,OAA0B;IAClF,MAAM,SAAS,GAAG,mBAAmB,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,EAAE,CAAC;IAE9B,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAA0B,EAAE,CAAC;QAC/D,MAAM,UAAU,GAAG,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,UAAU,EAAE,GAAG,CAAC,CAAC;IACxD,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { EmotionalRegister } from '../schema.js';
|
|
2
|
+
export type EmotionalTrajectory = 'stable' | 'escalating' | 'de_escalating' | 'shifting' | 'volatile';
|
|
3
|
+
export interface EffectiveEmotion {
|
|
4
|
+
emotion: EmotionalRegister;
|
|
5
|
+
intensity: number;
|
|
6
|
+
trajectory: EmotionalTrajectory;
|
|
7
|
+
escalationAlert: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Estimate emotional intensity from message text.
|
|
11
|
+
*
|
|
12
|
+
* Heuristic signals:
|
|
13
|
+
* - Excessive punctuation (!! or ??)
|
|
14
|
+
* - ALL CAPS segments
|
|
15
|
+
* - Explicit intensity words ("extremely", "so", "really", "very")
|
|
16
|
+
* - Profanity / frustration markers
|
|
17
|
+
* - Message length (longer rants → higher intensity)
|
|
18
|
+
*/
|
|
19
|
+
export declare function estimateIntensity(message: string, emotion: EmotionalRegister): number;
|
|
20
|
+
/**
|
|
21
|
+
* Tracks emotional state across multiple messages, detecting escalation
|
|
22
|
+
* patterns that a single-message detector would miss.
|
|
23
|
+
*
|
|
24
|
+
* If a user is getting progressively more frustrated over 4-5 messages,
|
|
25
|
+
* the engine should amplify empathy before they reach a breaking point.
|
|
26
|
+
*/
|
|
27
|
+
export declare class EmotionalTracker {
|
|
28
|
+
private history;
|
|
29
|
+
/** Record a detected emotion with its intensity and source message. */
|
|
30
|
+
recordEmotion(emotion: EmotionalRegister, intensity: number, message: string): void;
|
|
31
|
+
/**
|
|
32
|
+
* Get the effective emotional state considering trajectory across the
|
|
33
|
+
* conversation window.
|
|
34
|
+
*/
|
|
35
|
+
getEffectiveEmotion(): EffectiveEmotion;
|
|
36
|
+
private detectTrajectory;
|
|
37
|
+
private mode;
|
|
38
|
+
/** Reset for a new conversation — clears all history. */
|
|
39
|
+
reset(): void;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=emotional-tracker.d.ts.map
|