@auxiora/personality 1.3.0 → 1.10.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.js +42 -0
- package/dist/__tests__/architect-awareness-collector.test.js.map +1 -1
- package/dist/architect-awareness-collector.d.ts +6 -0
- package/dist/architect-awareness-collector.d.ts.map +1 -1
- package/dist/architect-awareness-collector.js +16 -0
- package/dist/architect-awareness-collector.js.map +1 -1
- package/dist/architect-bridge.d.ts +4 -0
- package/dist/architect-bridge.d.ts.map +1 -1
- package/dist/architect-bridge.js +9 -2
- package/dist/architect-bridge.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- 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 +33 -160
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +31 -483
- package/lib/index.js.map +1 -1
- 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 +6 -0
- package/lib/schema.d.ts.map +1 -1
- package/lib/system-prompt.js +11 -1
- package/lib/the-architect/context-detector.js.map +1 -1
- package/lib/the-architect/conversation-context.d.ts.map +1 -0
- package/lib/the-architect/conversation-export.d.ts.map +1 -0
- package/lib/the-architect/conversation-export.js.map +1 -0
- package/lib/the-architect/custom-weights.d.ts +7 -1
- package/lib/the-architect/custom-weights.d.ts.map +1 -0
- package/lib/the-architect/custom-weights.js +17 -0
- package/lib/the-architect/custom-weights.js.map +1 -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/emotional-tracker.d.ts.map +1 -0
- package/lib/the-architect/emotional-tracker.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 +48 -5
- package/lib/the-architect/index.d.ts.map +1 -1
- package/lib/the-architect/index.js +142 -8
- package/lib/the-architect/index.js.map +1 -1
- package/lib/the-architect/persistence-adapter.d.ts.map +1 -0
- package/lib/the-architect/persistence-adapter.js.map +1 -0
- package/lib/the-architect/persistence.d.ts +6 -0
- package/lib/the-architect/persistence.d.ts.map +1 -0
- package/lib/the-architect/persistence.js +9 -2
- package/lib/the-architect/persistence.js.map +1 -0
- 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/the-architect/recommender.d.ts.map +1 -0
- package/lib/the-architect/recommender.js.map +1 -0
- package/lib/the-architect/system-prompt.d.ts.map +1 -1
- package/lib/the-architect/system-prompt.js +11 -1
- package/lib/the-architect/system-prompt.js.map +1 -1
- package/lib/the-architect/user-model-synthesizer.d.ts +100 -0
- package/lib/the-architect/user-model-synthesizer.d.ts.map +1 -0
- package/lib/the-architect/user-model-synthesizer.js +224 -0
- package/lib/the-architect/user-model-synthesizer.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
|
@@ -53,5 +53,47 @@ describe('ArchitectAwarenessCollector', () => {
|
|
|
53
53
|
expect(collector.name).toBe('architect-bridge');
|
|
54
54
|
expect(collector.enabled).toBe(true);
|
|
55
55
|
});
|
|
56
|
+
it('collects tool context signals when tools were used', async () => {
|
|
57
|
+
const collector = new ArchitectAwarenessCollector();
|
|
58
|
+
collector.updateOutput({
|
|
59
|
+
detectedContext: { domain: 'general', emotionalRegister: 'neutral', stakes: 'moderate', complexity: 'moderate' },
|
|
60
|
+
});
|
|
61
|
+
collector.updateToolContext([
|
|
62
|
+
{ name: 'web_search', success: true },
|
|
63
|
+
{ name: 'code_interpreter', success: false },
|
|
64
|
+
]);
|
|
65
|
+
const signals = await collector.collect(ctx());
|
|
66
|
+
const toolSignal = signals.find(s => s.dimension === 'architect-tools');
|
|
67
|
+
expect(toolSignal).toBeDefined();
|
|
68
|
+
expect(toolSignal.text).toContain('web_search');
|
|
69
|
+
expect(toolSignal.text).toContain('code_interpreter');
|
|
70
|
+
expect(toolSignal.data).toEqual({
|
|
71
|
+
tools: ['web_search', 'code_interpreter'],
|
|
72
|
+
successCount: 1,
|
|
73
|
+
failureCount: 1,
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
it('omits tool signal when no tools were used', async () => {
|
|
77
|
+
const collector = new ArchitectAwarenessCollector();
|
|
78
|
+
collector.updateOutput({
|
|
79
|
+
detectedContext: { domain: 'general', emotionalRegister: 'neutral', stakes: 'moderate', complexity: 'moderate' },
|
|
80
|
+
});
|
|
81
|
+
const signals = await collector.collect(ctx());
|
|
82
|
+
const toolSignal = signals.find(s => s.dimension === 'architect-tools');
|
|
83
|
+
expect(toolSignal).toBeUndefined();
|
|
84
|
+
});
|
|
85
|
+
it('resets tool usages after collection', async () => {
|
|
86
|
+
const collector = new ArchitectAwarenessCollector();
|
|
87
|
+
collector.updateOutput({
|
|
88
|
+
detectedContext: { domain: 'general', emotionalRegister: 'neutral', stakes: 'moderate', complexity: 'moderate' },
|
|
89
|
+
});
|
|
90
|
+
collector.updateToolContext([{ name: 'web_search', success: true }]);
|
|
91
|
+
// First collect — has tool signal
|
|
92
|
+
const first = await collector.collect(ctx());
|
|
93
|
+
expect(first.find(s => s.dimension === 'architect-tools')).toBeDefined();
|
|
94
|
+
// Second collect — no tool signal (reset after first collect)
|
|
95
|
+
const second = await collector.collect(ctx());
|
|
96
|
+
expect(second.find(s => s.dimension === 'architect-tools')).toBeUndefined();
|
|
97
|
+
});
|
|
56
98
|
});
|
|
57
99
|
//# sourceMappingURL=architect-awareness-collector.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect-awareness-collector.test.js","sourceRoot":"","sources":["../../src/__tests__/architect-awareness-collector.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,2BAA2B,EAAE,MAAM,qCAAqC,CAAC;AAGlF,SAAS,GAAG;IACV,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,EAAE,cAAc,EAAE,EAAE,EAAE,CAAC;AACrG,CAAC;AAED,QAAQ,CAAC,6BAA6B,EAAE,GAAG,EAAE;IAC3C,EAAE,CAAC,kDAAkD,EAAE,KAAK,IAAI,EAAE;QAChE,MAAM,SAAS,GAAG,IAAI,2BAA2B,EAAE,CAAC;QACpD,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC/C,MAAM,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sDAAsD,EAAE,KAAK,IAAI,EAAE;QACpE,MAAM,SAAS,GAAG,IAAI,2BAA2B,EAAE,CAAC;QACpD,SAAS,CAAC,YAAY,CAAC;YACrB,eAAe,EAAE,EAAE,MAAM,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,mBAAmB,EAAE,IAAI,EAAE;YAC/I,mBAAmB,EAAE,QAAQ;SAC9B,CAAC,CAAC;QACH,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,OAAO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AAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,iBAAiB,CAAC,CAAC;QACxE,MAAM,CAAC,UAAU,CAAC,CAAC,aAAa,EAAE,CAAC;IACrC,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qCAAqC,EAAE,KAAK,IAAI,EAAE;QACnD,MAAM,SAAS,GAAG,IAAI,2BAA2B,EAAE,CAAC;QACpD,SAAS,CAAC,YAAY,CAAC;YACrB,eAAe,EAAE,EAAE,MAAM,EAAE,SAAS,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,UAAU,EAAE;SACjH,CAAC,CAAC;QACH,SAAS,CAAC,iBAAiB,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAErE,kCAAkC;QAClC,MAAM,KAAK,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC7C,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,iBAAiB,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;QAEzE,8DAA8D;QAC9D,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC;QAC9C,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,KAAK,iBAAiB,CAAC,CAAC,CAAC,aAAa,EAAE,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import type { SignalCollector, AwarenessSignal, CollectionContext } from '@auxiora/self-awareness';
|
|
2
|
+
export interface ToolUsage {
|
|
3
|
+
name: string;
|
|
4
|
+
success: boolean;
|
|
5
|
+
}
|
|
2
6
|
export interface ArchitectSnapshot {
|
|
3
7
|
detectedContext: {
|
|
4
8
|
domain: string;
|
|
@@ -14,7 +18,9 @@ export declare class ArchitectAwarenessCollector implements SignalCollector {
|
|
|
14
18
|
readonly name = "architect-bridge";
|
|
15
19
|
enabled: boolean;
|
|
16
20
|
private latest;
|
|
21
|
+
private toolUsages;
|
|
17
22
|
updateOutput(snapshot: ArchitectSnapshot): void;
|
|
23
|
+
updateToolContext(tools: ToolUsage[]): void;
|
|
18
24
|
collect(_context: CollectionContext): Promise<AwarenessSignal[]>;
|
|
19
25
|
}
|
|
20
26
|
//# sourceMappingURL=architect-awareness-collector.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect-awareness-collector.d.ts","sourceRoot":"","sources":["../src/architect-awareness-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEnG,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,CAAC;QACf,iBAAiB,EAAE,MAAM,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,qBAAa,2BAA4B,YAAW,eAAe;IACjE,QAAQ,CAAC,IAAI,sBAAsB;IACnC,OAAO,UAAQ;IAEf,OAAO,CAAC,MAAM,CAAkC;
|
|
1
|
+
{"version":3,"file":"architect-awareness-collector.d.ts","sourceRoot":"","sources":["../src/architect-awareness-collector.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAEnG,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,iBAAiB;IAChC,eAAe,EAAE;QACf,MAAM,EAAE,MAAM,CAAC;QACf,iBAAiB,EAAE,MAAM,CAAC;QAC1B,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,mBAAmB,CAAC,EAAE,MAAM,CAAC;KAC9B,CAAC;IACF,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B;AAED,qBAAa,2BAA4B,YAAW,eAAe;IACjE,QAAQ,CAAC,IAAI,sBAAsB;IACnC,OAAO,UAAQ;IAEf,OAAO,CAAC,MAAM,CAAkC;IAChD,OAAO,CAAC,UAAU,CAAmB;IAErC,YAAY,CAAC,QAAQ,EAAE,iBAAiB,GAAG,IAAI;IAI/C,iBAAiB,CAAC,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI;IAIrC,OAAO,CAAC,QAAQ,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,EAAE,CAAC;CAgDvE"}
|
|
@@ -2,9 +2,13 @@ export class ArchitectAwarenessCollector {
|
|
|
2
2
|
name = 'architect-bridge';
|
|
3
3
|
enabled = true;
|
|
4
4
|
latest = null;
|
|
5
|
+
toolUsages = [];
|
|
5
6
|
updateOutput(snapshot) {
|
|
6
7
|
this.latest = snapshot;
|
|
7
8
|
}
|
|
9
|
+
updateToolContext(tools) {
|
|
10
|
+
this.toolUsages = tools;
|
|
11
|
+
}
|
|
8
12
|
async collect(_context) {
|
|
9
13
|
if (!this.latest)
|
|
10
14
|
return [];
|
|
@@ -35,6 +39,18 @@ export class ArchitectAwarenessCollector {
|
|
|
35
39
|
data: { escalation: true, domain: detectedContext.domain },
|
|
36
40
|
});
|
|
37
41
|
}
|
|
42
|
+
if (this.toolUsages.length > 0) {
|
|
43
|
+
const names = this.toolUsages.map(t => t.name);
|
|
44
|
+
const successCount = this.toolUsages.filter(t => t.success).length;
|
|
45
|
+
const failureCount = this.toolUsages.length - successCount;
|
|
46
|
+
signals.push({
|
|
47
|
+
dimension: 'architect-tools',
|
|
48
|
+
priority: 0.4,
|
|
49
|
+
text: `Tools used: ${names.join(', ')} (${successCount} succeeded, ${failureCount} failed)`,
|
|
50
|
+
data: { tools: names, successCount, failureCount },
|
|
51
|
+
});
|
|
52
|
+
this.toolUsages = []; // Reset after collection
|
|
53
|
+
}
|
|
38
54
|
return signals;
|
|
39
55
|
}
|
|
40
56
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect-awareness-collector.js","sourceRoot":"","sources":["../src/architect-awareness-collector.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"architect-awareness-collector.js","sourceRoot":"","sources":["../src/architect-awareness-collector.ts"],"names":[],"mappings":"AAmBA,MAAM,OAAO,2BAA2B;IAC7B,IAAI,GAAG,kBAAkB,CAAC;IACnC,OAAO,GAAG,IAAI,CAAC;IAEP,MAAM,GAA6B,IAAI,CAAC;IACxC,UAAU,GAAgB,EAAE,CAAC;IAErC,YAAY,CAAC,QAA2B;QACtC,IAAI,CAAC,MAAM,GAAG,QAAQ,CAAC;IACzB,CAAC;IAED,iBAAiB,CAAC,KAAkB;QAClC,IAAI,CAAC,UAAU,GAAG,KAAK,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAA2B;QACvC,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,EAAE,CAAC;QAC5B,MAAM,OAAO,GAAsB,EAAE,CAAC;QACtC,MAAM,EAAE,eAAe,EAAE,mBAAmB,EAAE,eAAe,EAAE,GAAG,IAAI,CAAC,MAAM,CAAC;QAE9E,IAAI,eAAe,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;YACzC,MAAM,IAAI,GAAG,eAAe,CAAC,mBAAmB,CAAC;YACjD,OAAO,CAAC,IAAI,CAAC;gBACX,SAAS,EAAE,mBAAmB;gBAC9B,QAAQ,EA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AAC,MAAM,CAAC;YACnE,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,MAAM,GAAG,YAAY,CAAC;YAC3D,OAAO,CAAC,IAAI,CAAC;gBACX,SAAS,EAAE,iBAAiB;gBAC5B,QAAQ,EAAE,GAAG;gBACb,IAAI,EAAE,eAAe,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,YAAY,eAAe,YAAY,UAAU;gBAC3F,IAAI,EAAE,EAAE,KAAK,EAAE,KAAK,EAAE,YAAY,EAAE,YAAY,EAAE;aACnD,CAAC,CAAC;YACH,IAAI,CAAC,UAAU,GAAG,EAAE,CAAC,CAAC,yBAAyB;QACjD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect-bridge.d.ts","sourceRoot":"","sources":["../src/architect-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEzG,MAAM,WAAW,aAAa;IAC5B,sBAAsB,IAAI;QAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"architect-bridge.d.ts","sourceRoot":"","sources":["../src/architect-bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEzG,MAAM,WAAW,aAAa;IAC5B,sBAAsB,IAAI;QAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC;IACzE,qBAAqB,CAAC,CAAC,KAAK,EAAE;QAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,GAAG,IAAI,CAAC;CACrF;AAED,MAAM,WAAW,SAAS;IACxB,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC;IACrC,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/C,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,YAAY,CAAC,EAAE,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,CAAC,iBAAiB,CAAC,KAAK,IAAI,CAAC;CACvF;AAED;;;;;;GAMG;AACH,qBAAa,eAAe;IAIxB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,kBAAkB;IACnC,OAAO,CAAC,QAAQ,CAAC,KAAK;IACtB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAN1B,OAAO,CAAC,aAAa,CAAqB;gBAGvB,SAAS,EAAE,aAAa,EACxB,kBAAkB,EAAE,2BAA2B,EAC/C,KAAK,EAAE,SAAS,EAChB,OAAO,GAAE,aAAkB;IAG9C,8FAA8F;IAC9F,WAAW,CAAC,eAAe,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,mBAAmB,EAAE,MAAM,GAAG,SAAS,EAAE,eAAe,EAAE,OAAO,GAAG,SAAS,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI;IA8B1J,OAAO,CAAC,YAAY;IAiBpB,OAAO,CAAC,YAAY;CAarB"}
|
package/dist/architect-bridge.js
CHANGED
|
@@ -46,10 +46,17 @@ export class ArchitectBridge {
|
|
|
46
46
|
return;
|
|
47
47
|
this.restoredChats.add(chatId);
|
|
48
48
|
try {
|
|
49
|
-
this.vault.get(`architect:chat:${chatId}`);
|
|
49
|
+
const stored = this.vault.get(`architect:chat:${chatId}`);
|
|
50
|
+
if (stored && this.architect.loadConversationState) {
|
|
51
|
+
const parsed = JSON.parse(stored);
|
|
52
|
+
this.architect.loadConversationState({
|
|
53
|
+
theme: parsed.theme ?? null,
|
|
54
|
+
messageCount: parsed.messageCount ?? 0,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
50
57
|
}
|
|
51
58
|
catch {
|
|
52
|
-
// Vault locked or
|
|
59
|
+
// Vault locked, missing, or corrupt — proceed with fresh state
|
|
53
60
|
}
|
|
54
61
|
}
|
|
55
62
|
persistState(chatId) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"architect-bridge.js","sourceRoot":"","sources":["../src/architect-bridge.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"architect-bridge.js","sourceRoot":"","sources":["../src/architect-bridge.ts"],"names":[],"mappings":"AAiBA;;;;;;GAMG;AACH,MAAM,OAAO,eAAe;IAIP;IACA;IACA;IACA;IANX,aAAa,GAAG,IAAI,GAAG,EAAU,CAAC;IAE1C,YACmB,SAAwB,EACxB,kBAA+C,EAC/C,KAAgB,EAChB,UAAyB,EAAE;QAH3B,cAAS,GAAT,SAAS,CAAe;QACxB,uBAAkB,GAAlB,kBAAkB,CAA6B;QAC/C,UAAK,GAAL,KAAK,CAAW;QAChB,YAAO,GAAP,OAAO,CAAoB;IAC3C,CAAC;IAEJ,8FAA8F;IAC9F,WAAW,CAAC,eAAwC,EAAE,mBAAuC,EAAE,eAAoC,EAAE,MAAc;QACjJ,uDAAuD;QACvD,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAE1B,6BAA6B;QAC7B,MAAM,QAAQ,GAAsB;YAClC,eAAe,EAAE;gBACf,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,IAAI,SAAS,CAAC;gBACnD,iBAAiB,EAAE,MAAM,CAAC,eAAe,CAAC,iBAAiB,IAAI,SAAS,CAAC;gBACzE,MAAM,EAAE,MAAM,CAAC,eAAe,CAAC,MAAM,IAAI,UAAU,CAAC;gBACpD,UAAU,EAAE,MAAM,CAAC,eAAe,CAAC,UAAU,IAAI,U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,CAAC,sBAAsB,EAAE,CAAC;YACxD,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC;gBAC3B,KAAK,EAAE,OAAO,CAAC,KAAK;gBACpB,YAAY,EAAE,OAAO,CAAC,YAAY;gBAClC,WAAW,EAAE,IAAI,CAAC,GAAG,EAAE;aACxB,CAAC,CAAC;YACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,kBAAkB,MAAM,EAAE,EAAE,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,CAAC,CAAC;QACpE,CAAC;QAAC,MAAM,CAAC;YACP,kCAAkC;QACpC,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export type { ScanViolation, ScanResult } from './marketplace/scanner.js';
|
|
|
19
19
|
export { validatePersonalityConfig, PersonalityConfigSchema, FORBIDDEN_FIELD_NAMES, FORBIDDEN_FIELD_PATTERNS, } from './marketplace/schema.js';
|
|
20
20
|
export type { ValidationResult } from './marketplace/schema.js';
|
|
21
21
|
export { ArchitectAwarenessCollector } from './architect-awareness-collector.js';
|
|
22
|
-
export type { ArchitectSnapshot } from './architect-awareness-collector.js';
|
|
22
|
+
export type { ArchitectSnapshot, ToolUsage } from './architect-awareness-collector.js';
|
|
23
23
|
export { parseSoulBiases } from './soul-bias-parser.js';
|
|
24
24
|
export { ArchitectBridge } from './architect-bridge.js';
|
|
25
25
|
export type { ArchitectLike, VaultLike, BridgeOptions } from './architect-bridge.js';
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAChF,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;A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AAO,EACL,sBAAsB,EACtB,iBAAiB,EACjB,eAAe,EACf,mBAAmB,EACnB,gBAAgB,GACjB,MAAM,iBAAiB,CAAC;AACzB,YAAY,EACV,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,eAAe,EACf,oBAAoB,GACrB,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC7F,YAAY,EAAE,aAAa,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE1E,OAAO,EACL,yBAAyB,EACzB,uBAAuB,EACvB,qBAAqB,EACrB,wBAAwB,GACzB,MAAM,yBAAyB,CAAC;AACjC,YAAY,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAEhE,OAAO,EAAE,2BAA2B,EAAE,MAAM,oCAAoC,CAAC;AACjF,YAAY,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AAEvF,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC"}
|
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
|