@auxiora/personality 1.3.0 → 1.3.1
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/lib/custom-weights.d.ts +7 -1
- package/lib/custom-weights.js +17 -0
- package/lib/decision-log.d.ts +41 -0
- package/lib/decision-log.js +145 -0
- package/lib/feedback-store.d.ts +45 -0
- package/lib/feedback-store.js +152 -0
- package/lib/index.d.ts +48 -5
- package/lib/index.js +142 -8
- package/lib/persistence.d.ts +6 -0
- package/lib/persistence.js +9 -2
- package/lib/preference-history.d.ts +45 -0
- package/lib/preference-history.js +132 -0
- package/lib/schema.d.ts +4 -0
- package/lib/the-architect/custom-weights.d.ts +7 -1
- package/lib/the-architect/custom-weights.js +17 -0
- package/lib/the-architect/decision-log.d.ts +41 -0
- package/lib/the-architect/decision-log.d.ts.map +1 -0
- package/lib/the-architect/decision-log.js +145 -0
- package/lib/the-architect/decision-log.js.map +1 -0
- package/lib/the-architect/feedback-store.d.ts +45 -0
- package/lib/the-architect/feedback-store.d.ts.map +1 -0
- package/lib/the-architect/feedback-store.js +152 -0
- package/lib/the-architect/feedback-store.js.map +1 -0
- package/lib/the-architect/index.d.ts +43 -5
- package/lib/the-architect/index.js +128 -8
- package/lib/the-architect/persistence.d.ts +6 -0
- package/lib/the-architect/persistence.js +9 -2
- package/lib/the-architect/preference-history.d.ts +45 -0
- package/lib/the-architect/preference-history.d.ts.map +1 -0
- package/lib/the-architect/preference-history.js +132 -0
- package/lib/the-architect/preference-history.js.map +1 -0
- package/lib/user-model-synthesizer.d.ts +100 -0
- package/lib/user-model-synthesizer.js +224 -0
- package/package.json +4 -4
package/lib/custom-weights.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { TraitMix } from '../schema.js';
|
|
1
|
+
import type { TraitMix, ContextDomain } from '../schema.js';
|
|
2
|
+
import type { PreferenceHistory } from './preference-history.js';
|
|
2
3
|
export interface WeightPreset {
|
|
3
4
|
name: string;
|
|
4
5
|
description: string;
|
|
@@ -29,6 +30,11 @@ export declare class CustomWeights {
|
|
|
29
30
|
* and clamps the result to [0.0, 1.0].
|
|
30
31
|
*/
|
|
31
32
|
apply(baseMix: TraitMix): TraitMix;
|
|
33
|
+
/**
|
|
34
|
+
* Apply overrides using history-resolved offsets instead of raw last-write values.
|
|
35
|
+
* Falls back to standard apply() when no history entries exist for a trait.
|
|
36
|
+
*/
|
|
37
|
+
applyWithHistory(baseMix: TraitMix, currentDomain: ContextDomain | undefined, history: PreferenceHistory): TraitMix;
|
|
32
38
|
/** All available presets. */
|
|
33
39
|
static get presets(): Record<string, WeightPreset>;
|
|
34
40
|
/** Load a preset, replacing all current overrides. Throws if preset not found. */
|
package/lib/custom-weights.js
CHANGED
|
@@ -126,6 +126,23 @@ export class CustomWeights {
|
|
|
126
126
|
}
|
|
127
127
|
return result;
|
|
128
128
|
}
|
|
129
|
+
/**
|
|
130
|
+
* Apply overrides using history-resolved offsets instead of raw last-write values.
|
|
131
|
+
* Falls back to standard apply() when no history entries exist for a trait.
|
|
132
|
+
*/
|
|
133
|
+
applyWithHistory(baseMix, currentDomain, history) {
|
|
134
|
+
const result = { ...baseMix };
|
|
135
|
+
const rawOverrides = this.overrides;
|
|
136
|
+
// Collect all traits that have either raw overrides or history entries
|
|
137
|
+
const traits = new Set(Object.keys(rawOverrides));
|
|
138
|
+
for (const trait of traits) {
|
|
139
|
+
const historyOffset = history.getEffectiveOffset(trait, currentDomain ?? undefined);
|
|
140
|
+
// Use history-resolved offset if history has entries for this trait, otherwise fall back to raw
|
|
141
|
+
const offset = historyOffset !== 0 ? historyOffset : (rawOverrides[trait] ?? 0);
|
|
142
|
+
result[trait] = Math.min(1.0, Math.max(0.0, result[trait] + offset));
|
|
143
|
+
}
|
|
144
|
+
return result;
|
|
145
|
+
}
|
|
129
146
|
// ── Presets ─────────────────────────────────────────────────────────────
|
|
130
147
|
/** All available presets. */
|
|
131
148
|
static get presets() {
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { ContextDomain } from '../schema.js';
|
|
2
|
+
export type DecisionStatus = 'active' | 'revisit' | 'completed' | 'abandoned';
|
|
3
|
+
export interface Decision {
|
|
4
|
+
id: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
domain: ContextDomain;
|
|
7
|
+
summary: string;
|
|
8
|
+
context: string;
|
|
9
|
+
status: DecisionStatus;
|
|
10
|
+
followUpDate?: number;
|
|
11
|
+
outcome?: string;
|
|
12
|
+
tags: string[];
|
|
13
|
+
}
|
|
14
|
+
export interface DecisionQuery {
|
|
15
|
+
domain?: ContextDomain;
|
|
16
|
+
status?: DecisionStatus;
|
|
17
|
+
since?: number;
|
|
18
|
+
search?: string;
|
|
19
|
+
limit?: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class DecisionLog {
|
|
22
|
+
private decisions;
|
|
23
|
+
private maxDecisions;
|
|
24
|
+
/** Record a new decision. Auto-generates id, timestamp, and tags. */
|
|
25
|
+
addDecision(decision: Omit<Decision, 'id' | 'timestamp' | 'tags'>): Decision;
|
|
26
|
+
/** Update an existing decision's status or outcome. */
|
|
27
|
+
updateDecision(id: string, updates: Partial<Pick<Decision, 'status' | 'outcome' | 'followUpDate'>>): void;
|
|
28
|
+
/** Query decisions with filters. All filters are AND-combined. */
|
|
29
|
+
query(q: DecisionQuery): Decision[];
|
|
30
|
+
/** Get decisions due for follow-up (followUpDate <= now). */
|
|
31
|
+
getDueFollowUps(): Decision[];
|
|
32
|
+
/** Get recent decisions for a domain (for context in new conversations). */
|
|
33
|
+
getRecentForDomain(domain: ContextDomain, limit?: number): Decision[];
|
|
34
|
+
/** Serialize for encrypted storage. */
|
|
35
|
+
serialize(): string;
|
|
36
|
+
/** Deserialize from encrypted storage. */
|
|
37
|
+
static deserialize(data: string): DecisionLog;
|
|
38
|
+
/** Clear all decisions (user data deletion). */
|
|
39
|
+
clear(): void;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=decision-log.d.ts.map
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// Stopwords — common English words filtered from tag extraction
|
|
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 keyword tags from text. */
|
|
29
|
+
function extractTags(text) {
|
|
30
|
+
const words = text
|
|
31
|
+
.toLowerCase()
|
|
32
|
+
.split(/\s+/)
|
|
33
|
+
.map(w => w.replace(/[^a-z0-9]/g, ''))
|
|
34
|
+
.filter(w => w.length >= 4 && !STOPWORDS.has(w));
|
|
35
|
+
// Deduplicate while preserving order
|
|
36
|
+
return [...new Set(words)];
|
|
37
|
+
}
|
|
38
|
+
/** Generate a v4-style UUID without crypto dependency. */
|
|
39
|
+
function generateId() {
|
|
40
|
+
const hex = '0123456789abcdef';
|
|
41
|
+
const segments = [8, 4, 4, 4, 12];
|
|
42
|
+
return segments.map(len => {
|
|
43
|
+
let s = '';
|
|
44
|
+
for (let i = 0; i < len; i++) {
|
|
45
|
+
s += hex[Math.floor(Math.random() * 16)];
|
|
46
|
+
}
|
|
47
|
+
return s;
|
|
48
|
+
}).join('-');
|
|
49
|
+
}
|
|
50
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
51
|
+
// DecisionLog
|
|
52
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
53
|
+
export class DecisionLog {
|
|
54
|
+
decisions = [];
|
|
55
|
+
maxDecisions = 500;
|
|
56
|
+
/** Record a new decision. Auto-generates id, timestamp, and tags. */
|
|
57
|
+
addDecision(decision) {
|
|
58
|
+
const entry = {
|
|
59
|
+
...decision,
|
|
60
|
+
id: generateId(),
|
|
61
|
+
timestamp: Date.now(),
|
|
62
|
+
tags: extractTags(`${decision.summary} ${decision.context}`),
|
|
63
|
+
};
|
|
64
|
+
this.decisions.push(entry);
|
|
65
|
+
// Enforce capacity — drop oldest when over limit
|
|
66
|
+
if (this.decisions.length > this.maxDecisions) {
|
|
67
|
+
this.decisions = this.decisions.slice(this.decisions.length - this.maxDecisions);
|
|
68
|
+
}
|
|
69
|
+
return entry;
|
|
70
|
+
}
|
|
71
|
+
/** Update an existing decision's status or outcome. */
|
|
72
|
+
updateDecision(id, updates) {
|
|
73
|
+
const decision = this.decisions.find(d => d.id === id);
|
|
74
|
+
if (!decision) {
|
|
75
|
+
throw new Error(`Decision not found: ${id}`);
|
|
76
|
+
}
|
|
77
|
+
if (updates.status !== undefined)
|
|
78
|
+
decision.status = updates.status;
|
|
79
|
+
if (updates.outcome !== undefined)
|
|
80
|
+
decision.outcome = updates.outcome;
|
|
81
|
+
if (updates.followUpDate !== undefined)
|
|
82
|
+
decision.followUpDate = updates.followUpDate;
|
|
83
|
+
}
|
|
84
|
+
/** Query decisions with filters. All filters are AND-combined. */
|
|
85
|
+
query(q) {
|
|
86
|
+
let results = this.decisions.filter(d => {
|
|
87
|
+
if (q.domain !== undefined && d.domain !== q.domain)
|
|
88
|
+
return false;
|
|
89
|
+
if (q.status !== undefined && d.status !== q.status)
|
|
90
|
+
return false;
|
|
91
|
+
if (q.since !== undefined && d.timestamp < q.since)
|
|
92
|
+
return false;
|
|
93
|
+
if (q.search !== undefined) {
|
|
94
|
+
const needle = q.search.toLowerCase();
|
|
95
|
+
const haystack = `${d.summary} ${d.context} ${d.tags.join(' ')}`.toLowerCase();
|
|
96
|
+
if (!haystack.includes(needle))
|
|
97
|
+
return false;
|
|
98
|
+
}
|
|
99
|
+
return true;
|
|
100
|
+
});
|
|
101
|
+
// Sort by timestamp descending (most recent first)
|
|
102
|
+
results.sort((a, b) => b.timestamp - a.timestamp);
|
|
103
|
+
if (q.limit !== undefined && q.limit > 0) {
|
|
104
|
+
results = results.slice(0, q.limit);
|
|
105
|
+
}
|
|
106
|
+
return results;
|
|
107
|
+
}
|
|
108
|
+
/** Get decisions due for follow-up (followUpDate <= now). */
|
|
109
|
+
getDueFollowUps() {
|
|
110
|
+
const now = Date.now();
|
|
111
|
+
return this.decisions
|
|
112
|
+
.filter(d => d.followUpDate !== undefined && d.followUpDate <= now)
|
|
113
|
+
.sort((a, b) => b.timestamp - a.timestamp);
|
|
114
|
+
}
|
|
115
|
+
/** Get recent decisions for a domain (for context in new conversations). */
|
|
116
|
+
getRecentForDomain(domain, limit = 10) {
|
|
117
|
+
return this.decisions
|
|
118
|
+
.filter(d => d.domain === domain)
|
|
119
|
+
.sort((a, b) => b.timestamp - a.timestamp)
|
|
120
|
+
.slice(0, limit);
|
|
121
|
+
}
|
|
122
|
+
/** Serialize for encrypted storage. */
|
|
123
|
+
serialize() {
|
|
124
|
+
return JSON.stringify({ decisions: this.decisions });
|
|
125
|
+
}
|
|
126
|
+
/** Deserialize from encrypted storage. */
|
|
127
|
+
static deserialize(data) {
|
|
128
|
+
const log = new DecisionLog();
|
|
129
|
+
try {
|
|
130
|
+
const parsed = JSON.parse(data);
|
|
131
|
+
if (Array.isArray(parsed.decisions)) {
|
|
132
|
+
log.decisions = parsed.decisions;
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
catch {
|
|
136
|
+
// Corrupt data — return empty log
|
|
137
|
+
}
|
|
138
|
+
return log;
|
|
139
|
+
}
|
|
140
|
+
/** Clear all decisions (user data deletion). */
|
|
141
|
+
clear() {
|
|
142
|
+
this.decisions = [];
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=decision-log.js.map
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ContextDomain, TraitMix } from '../schema.js';
|
|
2
|
+
export type FeedbackRating = 'helpful' | 'off_target' | 'too_verbose' | 'too_brief' | 'wrong_tone';
|
|
3
|
+
export interface FeedbackEntry {
|
|
4
|
+
id: string;
|
|
5
|
+
timestamp: number;
|
|
6
|
+
domain: ContextDomain;
|
|
7
|
+
rating: FeedbackRating;
|
|
8
|
+
traitSnapshot: Partial<Record<keyof TraitMix, number>>;
|
|
9
|
+
note?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface FeedbackInsight {
|
|
12
|
+
/** Trait adjustments suggested by accumulated feedback. */
|
|
13
|
+
suggestedAdjustments: Partial<Record<keyof TraitMix, number>>;
|
|
14
|
+
/** Domains where responses consistently miss. */
|
|
15
|
+
weakDomains: ContextDomain[];
|
|
16
|
+
/** Overall satisfaction trend: improving, declining, or stable. */
|
|
17
|
+
trend: 'improving' | 'declining' | 'stable';
|
|
18
|
+
/** Total feedback count. */
|
|
19
|
+
totalFeedback: number;
|
|
20
|
+
}
|
|
21
|
+
export declare class FeedbackStore {
|
|
22
|
+
private entries;
|
|
23
|
+
private maxEntries;
|
|
24
|
+
/** Record feedback on a response. Auto-generates id and timestamp. */
|
|
25
|
+
addFeedback(entry: Omit<FeedbackEntry, 'id' | 'timestamp'>): void;
|
|
26
|
+
/**
|
|
27
|
+
* Analyze all feedback to produce actionable insights.
|
|
28
|
+
* - too_verbose feedback -> suggest lowering verbosity (negative adjustment)
|
|
29
|
+
* - too_brief feedback -> suggest raising verbosity (positive adjustment)
|
|
30
|
+
* - off_target in a domain -> flag as weak domain
|
|
31
|
+
* - wrong_tone -> suggest adjusting warmth up
|
|
32
|
+
*/
|
|
33
|
+
getInsights(): FeedbackInsight;
|
|
34
|
+
/** Get feedback for a specific domain. */
|
|
35
|
+
getForDomain(domain: ContextDomain): FeedbackEntry[];
|
|
36
|
+
/** Get the satisfaction trend over the last N entries. */
|
|
37
|
+
getRecentTrend(windowSize?: number): 'improving' | 'declining' | 'stable';
|
|
38
|
+
/** Serialize for encrypted storage. */
|
|
39
|
+
serialize(): string;
|
|
40
|
+
/** Deserialize from encrypted storage. */
|
|
41
|
+
static deserialize(data: string): FeedbackStore;
|
|
42
|
+
/** Clear all feedback (user data deletion). */
|
|
43
|
+
clear(): void;
|
|
44
|
+
}
|
|
45
|
+
//# sourceMappingURL=feedback-store.d.ts.map
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
2
|
+
// Helpers
|
|
3
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
4
|
+
/** Generate a v4-style UUID without crypto dependency. */
|
|
5
|
+
function generateId() {
|
|
6
|
+
const hex = '0123456789abcdef';
|
|
7
|
+
const segments = [8, 4, 4, 4, 12];
|
|
8
|
+
return segments.map(len => {
|
|
9
|
+
let s = '';
|
|
10
|
+
for (let i = 0; i < len; i++) {
|
|
11
|
+
s += hex[Math.floor(Math.random() * 16)];
|
|
12
|
+
}
|
|
13
|
+
return s;
|
|
14
|
+
}).join('-');
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Compute the helpful ratio for a slice of entries.
|
|
18
|
+
* Returns 0 if the slice is empty.
|
|
19
|
+
*/
|
|
20
|
+
function helpfulRatio(entries) {
|
|
21
|
+
if (entries.length === 0)
|
|
22
|
+
return 0;
|
|
23
|
+
const helpful = entries.filter(e => e.rating === 'helpful').length;
|
|
24
|
+
return helpful / entries.length;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Compare helpful ratios of first half vs second half.
|
|
28
|
+
* A difference > 0.10 in either direction triggers a trend change.
|
|
29
|
+
*/
|
|
30
|
+
function computeTrend(entries) {
|
|
31
|
+
if (entries.length < 2)
|
|
32
|
+
return 'stable';
|
|
33
|
+
const mid = Math.floor(entries.length / 2);
|
|
34
|
+
const firstHalf = entries.slice(0, mid);
|
|
35
|
+
const secondHalf = entries.slice(mid);
|
|
36
|
+
const firstRatio = helpfulRatio(firstHalf);
|
|
37
|
+
const secondRatio = helpfulRatio(secondHalf);
|
|
38
|
+
const diff = secondRatio - firstRatio;
|
|
39
|
+
if (diff > 0.10)
|
|
40
|
+
return 'improving';
|
|
41
|
+
if (diff < -0.10)
|
|
42
|
+
return 'declining';
|
|
43
|
+
return 'stable';
|
|
44
|
+
}
|
|
45
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
46
|
+
// FeedbackStore
|
|
47
|
+
// ────────────────────────────────────────────────────────────────────────────
|
|
48
|
+
export class FeedbackStore {
|
|
49
|
+
entries = [];
|
|
50
|
+
maxEntries = 500;
|
|
51
|
+
/** Record feedback on a response. Auto-generates id and timestamp. */
|
|
52
|
+
addFeedback(entry) {
|
|
53
|
+
this.entries.push({
|
|
54
|
+
...entry,
|
|
55
|
+
id: generateId(),
|
|
56
|
+
timestamp: Date.now(),
|
|
57
|
+
});
|
|
58
|
+
// Drop oldest entries when exceeding capacity
|
|
59
|
+
if (this.entries.length > this.maxEntries) {
|
|
60
|
+
this.entries = this.entries.slice(this.entries.length - this.maxEntries);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Analyze all feedback to produce actionable insights.
|
|
65
|
+
* - too_verbose feedback -> suggest lowering verbosity (negative adjustment)
|
|
66
|
+
* - too_brief feedback -> suggest raising verbosity (positive adjustment)
|
|
67
|
+
* - off_target in a domain -> flag as weak domain
|
|
68
|
+
* - wrong_tone -> suggest adjusting warmth up
|
|
69
|
+
*/
|
|
70
|
+
getInsights() {
|
|
71
|
+
const suggestedAdjustments = {};
|
|
72
|
+
const weakDomains = [];
|
|
73
|
+
// Count each rating type across all entries
|
|
74
|
+
let tooVerboseCount = 0;
|
|
75
|
+
let tooBriefCount = 0;
|
|
76
|
+
let wrongToneCount = 0;
|
|
77
|
+
// Count off_target per domain
|
|
78
|
+
const offTargetByDomain = new Map();
|
|
79
|
+
for (const entry of this.entries) {
|
|
80
|
+
switch (entry.rating) {
|
|
81
|
+
case 'too_verbose':
|
|
82
|
+
tooVerboseCount++;
|
|
83
|
+
break;
|
|
84
|
+
case 'too_brief':
|
|
85
|
+
tooBriefCount++;
|
|
86
|
+
break;
|
|
87
|
+
case 'wrong_tone':
|
|
88
|
+
wrongToneCount++;
|
|
89
|
+
break;
|
|
90
|
+
case 'off_target': {
|
|
91
|
+
const count = offTargetByDomain.get(entry.domain) ?? 0;
|
|
92
|
+
offTargetByDomain.set(entry.domain, count + 1);
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
// too_verbose (>= 5) -> lower verbosity, capped at -0.3
|
|
98
|
+
if (tooVerboseCount >= 5) {
|
|
99
|
+
const adj = -0.1 * tooVerboseCount;
|
|
100
|
+
suggestedAdjustments.verbosity = Math.max(adj, -0.3);
|
|
101
|
+
}
|
|
102
|
+
// too_brief (>= 5) -> raise verbosity, capped at +0.3
|
|
103
|
+
if (tooBriefCount >= 5) {
|
|
104
|
+
const adj = 0.1 * tooBriefCount;
|
|
105
|
+
suggestedAdjustments.verbosity = Math.min(adj, 0.3);
|
|
106
|
+
}
|
|
107
|
+
// wrong_tone (>= 5) -> adjust warmth up
|
|
108
|
+
if (wrongToneCount >= 5) {
|
|
109
|
+
suggestedAdjustments.warmth = 0.1;
|
|
110
|
+
}
|
|
111
|
+
// off_target in a domain (>= 3) -> weak domain
|
|
112
|
+
for (const [domain, count] of offTargetByDomain) {
|
|
113
|
+
if (count >= 3) {
|
|
114
|
+
weakDomains.push(domain);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
const trend = computeTrend(this.entries);
|
|
118
|
+
return {
|
|
119
|
+
suggestedAdjustments,
|
|
120
|
+
weakDomains,
|
|
121
|
+
trend,
|
|
122
|
+
totalFeedback: this.entries.length,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
/** Get feedback for a specific domain. */
|
|
126
|
+
getForDomain(domain) {
|
|
127
|
+
return this.entries.filter(e => e.domain === domain);
|
|
128
|
+
}
|
|
129
|
+
/** Get the satisfaction trend over the last N entries. */
|
|
130
|
+
getRecentTrend(windowSize = 20) {
|
|
131
|
+
const window = this.entries.slice(-windowSize);
|
|
132
|
+
return computeTrend(window);
|
|
133
|
+
}
|
|
134
|
+
/** Serialize for encrypted storage. */
|
|
135
|
+
serialize() {
|
|
136
|
+
return JSON.stringify({ entries: this.entries });
|
|
137
|
+
}
|
|
138
|
+
/** Deserialize from encrypted storage. */
|
|
139
|
+
static deserialize(data) {
|
|
140
|
+
const store = new FeedbackStore();
|
|
141
|
+
const parsed = JSON.parse(data);
|
|
142
|
+
if (Array.isArray(parsed.entries)) {
|
|
143
|
+
store.entries = parsed.entries;
|
|
144
|
+
}
|
|
145
|
+
return store;
|
|
146
|
+
}
|
|
147
|
+
/** Clear all feedback (user data deletion). */
|
|
148
|
+
clear() {
|
|
149
|
+
this.entries = [];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
//# sourceMappingURL=feedback-store.js.map
|
package/lib/index.d.ts
CHANGED
|
@@ -4,6 +4,9 @@ import type { ArchitectPreferences } from './persistence.js';
|
|
|
4
4
|
import type { EncryptedStorage } from './persistence-adapter.js';
|
|
5
5
|
import type { WeightPreset } from './custom-weights.js';
|
|
6
6
|
import type { ChatMessage, ExportedConversation } from './conversation-export.js';
|
|
7
|
+
import type { Decision, DecisionQuery } from './decision-log.js';
|
|
8
|
+
import type { FeedbackRating, FeedbackInsight } from './feedback-store.js';
|
|
9
|
+
import type { UserModel } from './user-model-synthesizer.js';
|
|
7
10
|
export type { TraitMix, TraitValue, TaskContext, TraitSource, ContextDomain, EmotionalRegister, ContextSignal, PromptOutput, } from '../schema.js';
|
|
8
11
|
export { ARCHITECT_BASE_PROMPT } from './system-prompt.js';
|
|
9
12
|
export { CONTEXT_PROFILES } from './context-profiles.js';
|
|
@@ -29,6 +32,14 @@ export type { ArchitectPreferences } from './persistence.js';
|
|
|
29
32
|
export type { EncryptedStorage } from './persistence-adapter.js';
|
|
30
33
|
export { InMemoryEncryptedStorage, VaultStorageAdapter } from './persistence-adapter.js';
|
|
31
34
|
export type { VaultLike } from './persistence-adapter.js';
|
|
35
|
+
export { PreferenceHistory } from './preference-history.js';
|
|
36
|
+
export type { PreferenceEntry, PreferenceConflict } from './preference-history.js';
|
|
37
|
+
export { DecisionLog } from './decision-log.js';
|
|
38
|
+
export type { Decision, DecisionQuery, DecisionStatus } from './decision-log.js';
|
|
39
|
+
export { FeedbackStore } from './feedback-store.js';
|
|
40
|
+
export type { FeedbackRating, FeedbackEntry, FeedbackInsight } from './feedback-store.js';
|
|
41
|
+
export { UserModelSynthesizer } from './user-model-synthesizer.js';
|
|
42
|
+
export type { UserModel, DomainProfile, CommunicationStyle, SatisfactionProfile, CorrectionSummary } from './user-model-synthesizer.js';
|
|
32
43
|
type Message = {
|
|
33
44
|
role: string;
|
|
34
45
|
content: string;
|
|
@@ -51,6 +62,9 @@ export declare class TheArchitect {
|
|
|
51
62
|
private conversationContext;
|
|
52
63
|
private emotionalTracker;
|
|
53
64
|
private customWeights;
|
|
65
|
+
private preferenceHistory;
|
|
66
|
+
private decisionLog;
|
|
67
|
+
private feedbackStore;
|
|
54
68
|
private persistence?;
|
|
55
69
|
private preferences?;
|
|
56
70
|
private initialized;
|
|
@@ -109,18 +123,47 @@ export declare class TheArchitect {
|
|
|
109
123
|
getConversationSummary(): import("./conversation-context.js").ConversationSummary;
|
|
110
124
|
/** Get the current emotional trajectory. */
|
|
111
125
|
getEmotionalState(): import("./emotional-tracker.js").EffectiveEmotion;
|
|
112
|
-
/** Set a custom trait weight offset.
|
|
113
|
-
setTraitOverride(trait: keyof TraitMix, offset: number): Promise<void>;
|
|
126
|
+
/** Set a custom trait weight offset. Records in preference history and persists. */
|
|
127
|
+
setTraitOverride(trait: keyof TraitMix, offset: number, source?: 'user' | 'preset' | 'feedback', reason?: string): Promise<void>;
|
|
114
128
|
/** Remove a custom trait weight override. */
|
|
115
129
|
removeTraitOverride(trait: keyof TraitMix): Promise<void>;
|
|
116
|
-
/** Load a preset weight configuration. */
|
|
130
|
+
/** Load a preset weight configuration. Records each override in preference history. */
|
|
117
131
|
loadPreset(presetName: string): Promise<void>;
|
|
118
132
|
/** Returns available weight presets. */
|
|
119
133
|
listPresets(): Record<string, WeightPreset>;
|
|
120
134
|
/** Returns current custom weight overrides. */
|
|
121
135
|
getActiveOverrides(): Partial<Record<keyof TraitMix, number>>;
|
|
122
|
-
/** Persist custom weights to encrypted storage. */
|
|
136
|
+
/** Persist custom weights and preference history to encrypted storage. */
|
|
123
137
|
private persistCustomWeights;
|
|
138
|
+
/** Get conflicts in preference history. */
|
|
139
|
+
getPreferenceConflicts(): import("./preference-history.js").PreferenceConflict[];
|
|
140
|
+
/** Get preference change history for a trait. */
|
|
141
|
+
getPreferenceHistory(trait: keyof TraitMix): import("./preference-history.js").PreferenceEntry[];
|
|
142
|
+
/** Record a decision for cross-session tracking. */
|
|
143
|
+
recordDecision(decision: Omit<Decision, 'id' | 'timestamp' | 'tags'>): Promise<Decision>;
|
|
144
|
+
/** Update a decision's status or outcome. */
|
|
145
|
+
updateDecision(id: string, updates: Partial<Pick<Decision, 'status' | 'outcome' | 'followUpDate'>>): Promise<void>;
|
|
146
|
+
/** Query decisions with filters. */
|
|
147
|
+
queryDecisions(q: DecisionQuery): Decision[];
|
|
148
|
+
/** Get decisions due for follow-up. */
|
|
149
|
+
getDueFollowUps(): Decision[];
|
|
150
|
+
/** Persist decision log to encrypted storage. */
|
|
151
|
+
private persistDecisionLog;
|
|
152
|
+
/** Record feedback on a response. */
|
|
153
|
+
recordFeedback(feedback: {
|
|
154
|
+
domain: ContextDomain;
|
|
155
|
+
rating: FeedbackRating;
|
|
156
|
+
traitSnapshot?: Partial<Record<keyof TraitMix, number>>;
|
|
157
|
+
note?: string;
|
|
158
|
+
}): Promise<void>;
|
|
159
|
+
/** Get actionable feedback insights. */
|
|
160
|
+
getFeedbackInsights(): FeedbackInsight;
|
|
161
|
+
/** Get satisfaction trend over recent feedback. */
|
|
162
|
+
getFeedbackTrend(windowSize?: number): 'improving' | 'declining' | 'stable';
|
|
163
|
+
/** Persist feedback store to encrypted storage. */
|
|
164
|
+
private persistFeedbackStore;
|
|
165
|
+
/** Synthesize a complete user model from all data stores. */
|
|
166
|
+
getUserModel(): UserModel;
|
|
124
167
|
/**
|
|
125
168
|
* Apply trajectory-based multipliers on top of standard emotional overrides.
|
|
126
169
|
* Caps all values at 1.0.
|
|
@@ -141,7 +184,7 @@ export declare class TheArchitect {
|
|
|
141
184
|
getPreferences(): Promise<ArchitectPreferences>;
|
|
142
185
|
/** Update a single preference and persist. */
|
|
143
186
|
updatePreference<K extends keyof ArchitectPreferences>(key: K, value: ArchitectPreferences[K]): Promise<void>;
|
|
144
|
-
/** Clear all persisted data: corrections, preferences, usage history. */
|
|
187
|
+
/** Clear all persisted data: corrections, preferences, usage history, and self-awareness stores. */
|
|
145
188
|
clearAllData(): Promise<void>;
|
|
146
189
|
/**
|
|
147
190
|
* Export a conversation with full personality engine metadata.
|