sentinel-agentos 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/LICENSE +0 -21
- package/README.md +0 -1797
- package/dist/adapters/evaluation-bridge.d.ts +0 -78
- package/dist/adapters/evaluation-bridge.d.ts.map +0 -1
- package/dist/adapters/evaluation-bridge.js +0 -273
- package/dist/adapters/evaluation-bridge.js.map +0 -1
- package/dist/adapters/memory-bridge.d.ts +0 -110
- package/dist/adapters/memory-bridge.d.ts.map +0 -1
- package/dist/adapters/memory-bridge.js +0 -316
- package/dist/adapters/memory-bridge.js.map +0 -1
- package/dist/adapters/migrate.d.ts +0 -2
- package/dist/adapters/migrate.d.ts.map +0 -1
- package/dist/adapters/migrate.js +0 -63
- package/dist/adapters/migrate.js.map +0 -1
- package/dist/api.d.ts +0 -151
- package/dist/api.d.ts.map +0 -1
- package/dist/api.js +0 -179
- package/dist/api.js.map +0 -1
- package/dist/cli.d.ts +0 -16
- package/dist/cli.d.ts.map +0 -1
- package/dist/cli.js +0 -350
- package/dist/cli.js.map +0 -1
- package/dist/core.d.ts +0 -156
- package/dist/core.d.ts.map +0 -1
- package/dist/core.js +0 -400
- package/dist/core.js.map +0 -1
- package/dist/dashboard.html +0 -175
- package/dist/evaluator/exec-evaluator.d.ts +0 -102
- package/dist/evaluator/exec-evaluator.d.ts.map +0 -1
- package/dist/evaluator/exec-evaluator.js +0 -266
- package/dist/evaluator/exec-evaluator.js.map +0 -1
- package/dist/evaluator/feedback.d.ts +0 -96
- package/dist/evaluator/feedback.d.ts.map +0 -1
- package/dist/evaluator/feedback.js +0 -419
- package/dist/evaluator/feedback.js.map +0 -1
- package/dist/evaluator/profiler.d.ts +0 -55
- package/dist/evaluator/profiler.d.ts.map +0 -1
- package/dist/evaluator/profiler.js +0 -130
- package/dist/evaluator/profiler.js.map +0 -1
- package/dist/guard/audit-log.d.ts +0 -47
- package/dist/guard/audit-log.d.ts.map +0 -1
- package/dist/guard/audit-log.js +0 -199
- package/dist/guard/audit-log.js.map +0 -1
- package/dist/guard/container-sandbox.d.ts +0 -25
- package/dist/guard/container-sandbox.d.ts.map +0 -1
- package/dist/guard/container-sandbox.js +0 -145
- package/dist/guard/container-sandbox.js.map +0 -1
- package/dist/guard/risk-gate.d.ts +0 -101
- package/dist/guard/risk-gate.d.ts.map +0 -1
- package/dist/guard/risk-gate.js +0 -200
- package/dist/guard/risk-gate.js.map +0 -1
- package/dist/guard/sandbox.d.ts +0 -112
- package/dist/guard/sandbox.d.ts.map +0 -1
- package/dist/guard/sandbox.js +0 -379
- package/dist/guard/sandbox.js.map +0 -1
- package/dist/guard/schema-gate.d.ts +0 -90
- package/dist/guard/schema-gate.d.ts.map +0 -1
- package/dist/guard/schema-gate.js +0 -452
- package/dist/guard/schema-gate.js.map +0 -1
- package/dist/guard/snapshot-verify.d.ts +0 -111
- package/dist/guard/snapshot-verify.d.ts.map +0 -1
- package/dist/guard/snapshot-verify.js +0 -571
- package/dist/guard/snapshot-verify.js.map +0 -1
- package/dist/index.d.ts +0 -28
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -59
- package/dist/index.js.map +0 -1
- package/dist/memory/episodic.d.ts +0 -76
- package/dist/memory/episodic.d.ts.map +0 -1
- package/dist/memory/episodic.js +0 -289
- package/dist/memory/episodic.js.map +0 -1
- package/dist/memory/semantic.d.ts +0 -68
- package/dist/memory/semantic.d.ts.map +0 -1
- package/dist/memory/semantic.js +0 -299
- package/dist/memory/semantic.js.map +0 -1
- package/dist/memory/working.d.ts +0 -53
- package/dist/memory/working.d.ts.map +0 -1
- package/dist/memory/working.js +0 -166
- package/dist/memory/working.js.map +0 -1
- package/dist/middleware/openclaw.d.ts +0 -45
- package/dist/middleware/openclaw.d.ts.map +0 -1
- package/dist/middleware/openclaw.js +0 -95
- package/dist/middleware/openclaw.js.map +0 -1
- package/dist/middleware/wrapper.d.ts +0 -54
- package/dist/middleware/wrapper.d.ts.map +0 -1
- package/dist/middleware/wrapper.js +0 -155
- package/dist/middleware/wrapper.js.map +0 -1
- package/dist/server.d.ts +0 -45
- package/dist/server.d.ts.map +0 -1
- package/dist/server.js +0 -256
- package/dist/server.js.map +0 -1
- package/dist/types/index.d.ts +0 -228
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/index.js +0 -23
- package/dist/types/index.js.map +0 -1
- package/scripts/sentinel-light.js +0 -234
|
@@ -1,419 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.ImplicitFeedbackEngine = void 0;
|
|
37
|
-
const crypto = __importStar(require("crypto"));
|
|
38
|
-
const fs = __importStar(require("fs"));
|
|
39
|
-
const path = __importStar(require("path"));
|
|
40
|
-
/**
|
|
41
|
-
* Generate a unique feedback ID.
|
|
42
|
-
*/
|
|
43
|
-
function generateFeedbackId() {
|
|
44
|
-
return `fb_${Date.now()}_${crypto.randomBytes(4).toString('hex')}`;
|
|
45
|
-
}
|
|
46
|
-
/**
|
|
47
|
-
* ImplicitFeedbackEngine — captures and interprets implicit user signals.
|
|
48
|
-
*
|
|
49
|
-
* Instead of relying on explicit "thumbs up/down", this engine
|
|
50
|
-
* detects subtle signals from user behavior to infer satisfaction.
|
|
51
|
-
*
|
|
52
|
-
* Two modes:
|
|
53
|
-
* - Manual: caller provides explicit signals via record()
|
|
54
|
-
* - Auto-detect: scans audit log to infer signals (results unused,
|
|
55
|
-
* results modified later, repeated same tool, verify failures)
|
|
56
|
-
*
|
|
57
|
-
* This is the key differentiator of AgentOS: it learns from
|
|
58
|
-
* what users DO, not just what they SAY.
|
|
59
|
-
*/
|
|
60
|
-
class ImplicitFeedbackEngine {
|
|
61
|
-
feedbackLog = [];
|
|
62
|
-
persistPath = null;
|
|
63
|
-
// Global audit log for cross-session auto-detection
|
|
64
|
-
globalAuditPath = null;
|
|
65
|
-
// Track which auto-detected signals we've already logged (dedup key)
|
|
66
|
-
detectedKeys = new Set();
|
|
67
|
-
/**
|
|
68
|
-
* Record an implicit feedback signal.
|
|
69
|
-
*/
|
|
70
|
-
record(signal, sessionId, operationId, confidence = 0.8, source = 'auto-detected') {
|
|
71
|
-
const strength = this.getSignalStrength(signal);
|
|
72
|
-
const feedback = {
|
|
73
|
-
id: generateFeedbackId(),
|
|
74
|
-
timestamp: Date.now(),
|
|
75
|
-
signal,
|
|
76
|
-
strength,
|
|
77
|
-
confidence,
|
|
78
|
-
sessionId,
|
|
79
|
-
operationId,
|
|
80
|
-
source,
|
|
81
|
-
};
|
|
82
|
-
this.feedbackLog.push(feedback);
|
|
83
|
-
this.persist();
|
|
84
|
-
return feedback;
|
|
85
|
-
}
|
|
86
|
-
// ══════════════════════════════════
|
|
87
|
-
// Auto-detect feedback from audit log
|
|
88
|
-
// ══════════════════════════════════
|
|
89
|
-
/**
|
|
90
|
-
* Scan the audit log and auto-detect implicit feedback signals.
|
|
91
|
-
*
|
|
92
|
-
* Detection rules (conservative — low confidence to avoid false positives):
|
|
93
|
-
* - verify FAIL or WARN → user_provided_correction (agent made mistakes)
|
|
94
|
-
* - same tool+params called within 60s → user_repeated_instruction (low confidence, noisy)
|
|
95
|
-
* - high risk operations that were retried and eventually passed → agent_self_corrected
|
|
96
|
-
*
|
|
97
|
-
* Note: auto-detected signals carry lower confidence than explicit user feedback.
|
|
98
|
-
* They serve as supplementary data, not primary quality indicators.
|
|
99
|
-
*
|
|
100
|
-
* @param entries Recent audit entries to analyze
|
|
101
|
-
* @param sessionId Session to attribute signals to
|
|
102
|
-
* @returns Number of signals auto-detected
|
|
103
|
-
*/
|
|
104
|
-
/**
|
|
105
|
-
* Enable persistence for feedbackLog and auto-detected signal keys.
|
|
106
|
-
*/
|
|
107
|
-
enablePersistence(workspaceRoot) {
|
|
108
|
-
const agentosDir = path.join(workspaceRoot, '.agentos');
|
|
109
|
-
if (!fs.existsSync(agentosDir)) {
|
|
110
|
-
fs.mkdirSync(agentosDir, { recursive: true });
|
|
111
|
-
}
|
|
112
|
-
this.persistPath = path.join(agentosDir, 'feedback.jsonl');
|
|
113
|
-
this.globalAuditPath = path.join(agentosDir, 'audit.jsonl');
|
|
114
|
-
this.load();
|
|
115
|
-
}
|
|
116
|
-
/** Persist the current feedbackLog and detectedKeys to disk. */
|
|
117
|
-
persist() {
|
|
118
|
-
if (!this.persistPath)
|
|
119
|
-
return;
|
|
120
|
-
try {
|
|
121
|
-
const snapshot = {
|
|
122
|
-
feedbackLog: this.feedbackLog,
|
|
123
|
-
detectedKeys: Array.from(this.detectedKeys),
|
|
124
|
-
updatedAt: Date.now(),
|
|
125
|
-
};
|
|
126
|
-
fs.writeFileSync(this.persistPath, JSON.stringify(snapshot) + '\n', 'utf-8');
|
|
127
|
-
}
|
|
128
|
-
catch {
|
|
129
|
-
// Non-critical, silently ignore persist failures
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
/** Load persisted feedback log from disk. */
|
|
133
|
-
load() {
|
|
134
|
-
if (!this.persistPath)
|
|
135
|
-
return;
|
|
136
|
-
try {
|
|
137
|
-
if (!fs.existsSync(this.persistPath))
|
|
138
|
-
return;
|
|
139
|
-
const content = fs.readFileSync(this.persistPath, 'utf-8').trim();
|
|
140
|
-
if (!content)
|
|
141
|
-
return;
|
|
142
|
-
const snapshot = JSON.parse(content);
|
|
143
|
-
if (Array.isArray(snapshot.feedbackLog)) {
|
|
144
|
-
this.feedbackLog = snapshot.feedbackLog;
|
|
145
|
-
// Remove stale signals older than 7 days to prevent unbounded growth
|
|
146
|
-
const cutoff = Date.now() - 7 * 24 * 60 * 60 * 1000;
|
|
147
|
-
this.feedbackLog = this.feedbackLog.filter((f) => f.timestamp >= cutoff);
|
|
148
|
-
}
|
|
149
|
-
if (Array.isArray(snapshot.detectedKeys)) {
|
|
150
|
-
this.detectedKeys = new Set(snapshot.detectedKeys);
|
|
151
|
-
}
|
|
152
|
-
}
|
|
153
|
-
catch {
|
|
154
|
-
// Corrupt file — start fresh
|
|
155
|
-
}
|
|
156
|
-
}
|
|
157
|
-
/**
|
|
158
|
-
* Cross-session auto-detect: scan the global audit.jsonl for signals
|
|
159
|
-
* from ALL sessions, not just the current one.
|
|
160
|
-
*/
|
|
161
|
-
autoDetectGlobal() {
|
|
162
|
-
if (!this.globalAuditPath)
|
|
163
|
-
return 0;
|
|
164
|
-
try {
|
|
165
|
-
if (!fs.existsSync(this.globalAuditPath))
|
|
166
|
-
return 0;
|
|
167
|
-
const content = fs.readFileSync(this.globalAuditPath, 'utf-8');
|
|
168
|
-
const lines = content.split('\n').filter((l) => l.trim());
|
|
169
|
-
const entries = lines.map((l) => JSON.parse(l));
|
|
170
|
-
return this.autoDetect(entries, '__global__');
|
|
171
|
-
}
|
|
172
|
-
catch {
|
|
173
|
-
return 0;
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
autoDetect(entries, sessionId) {
|
|
177
|
-
let detected = 0;
|
|
178
|
-
// Rule 1: Verify failures → agent made errors (confidence 0.7)
|
|
179
|
-
for (const entry of entries) {
|
|
180
|
-
if (entry.verifyGate.status !== 'PASS') {
|
|
181
|
-
const dedupKey = `verify-fail:${entry.id}`;
|
|
182
|
-
if (!this.detectedKeys.has(dedupKey)) {
|
|
183
|
-
this.detectedKeys.add(dedupKey);
|
|
184
|
-
this.record('user_provided_correction', sessionId, entry.id, 0.7, 'auto-audit-verify');
|
|
185
|
-
detected++;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
// Rule 2: Repeated same tool call within 60s → user had to repeat
|
|
190
|
-
// Low confidence (0.3) because some tools (read, exec) are legitimately called multiple times
|
|
191
|
-
for (let i = 0; i < entries.length; i++) {
|
|
192
|
-
for (let j = i + 1; j < entries.length; j++) {
|
|
193
|
-
const ei = entries[i];
|
|
194
|
-
const ej = entries[j];
|
|
195
|
-
if (!ei || !ej)
|
|
196
|
-
continue;
|
|
197
|
-
if (ei.toolName === ej.toolName &&
|
|
198
|
-
JSON.stringify(ei.toolParameters) === JSON.stringify(ej.toolParameters) &&
|
|
199
|
-
Math.abs(ei.completedAt - ej.startedAt) < 60_000) {
|
|
200
|
-
const dedupKey = `repeat:${ei.id}:${ej.id}`;
|
|
201
|
-
if (!this.detectedKeys.has(dedupKey)) {
|
|
202
|
-
this.detectedKeys.add(dedupKey);
|
|
203
|
-
this.record('user_repeated_instruction', sessionId, ej.id, 0.3, 'auto-audit-repeat');
|
|
204
|
-
detected++;
|
|
205
|
-
}
|
|
206
|
-
break;
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
// Rule 3: Agent self-corrected — only when retry eventually succeeded
|
|
211
|
-
// (NOT "high risk passed" — that's coincidence, not demonstrated skill)
|
|
212
|
-
// Detected by: same tool+params failed once, then passed later in the same session
|
|
213
|
-
const failures = new Set();
|
|
214
|
-
for (const entry of entries) {
|
|
215
|
-
if (entry.verifyGate.status !== 'PASS') {
|
|
216
|
-
failures.add(JSON.stringify({ t: entry.toolName, p: entry.toolParameters }));
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
for (const entry of entries) {
|
|
220
|
-
const key = JSON.stringify({ t: entry.toolName, p: entry.toolParameters });
|
|
221
|
-
if (entry.verifyGate.status === 'PASS' && failures.has(key)) {
|
|
222
|
-
const dedupKey = `self-corrected:${entry.id}`;
|
|
223
|
-
if (!this.detectedKeys.has(dedupKey)) {
|
|
224
|
-
this.detectedKeys.add(dedupKey);
|
|
225
|
-
this.record('agent_self_corrected', sessionId, entry.id, 0.5, 'auto-audit-self-corrected');
|
|
226
|
-
detected++;
|
|
227
|
-
}
|
|
228
|
-
failures.delete(key); // one signal per correction
|
|
229
|
-
}
|
|
230
|
-
}
|
|
231
|
-
return detected;
|
|
232
|
-
}
|
|
233
|
-
// ══════════════════════════════════
|
|
234
|
-
// User message analysis — detect correction signals from text
|
|
235
|
-
// ══════════════════════════════════
|
|
236
|
-
/**
|
|
237
|
-
* Analyze user messages to detect implicit correction/feedback signals.
|
|
238
|
-
*
|
|
239
|
-
* Chinese corrective patterns (high precision, low recall — only matches clear signals):
|
|
240
|
-
* - "不对"/"错了"/"不是这样" → user_provided_correction (confidence 0.8)
|
|
241
|
-
* - "漏了"/"缺了"/"没包括"/"遗漏" → user_provided_correction (confidence 0.75)
|
|
242
|
-
* - "你没"/"你怎么"/"你咋" + 负面动作(忘记/漏/没/不) → user_provided_correction (confidence 0.7)
|
|
243
|
-
* - "失忆"/"忘了"/"不记得" → user_provided_correction (confidence 0.85)
|
|
244
|
-
* - "重新"/"再查"/"再搜"/"再看看" → user_repeated_instruction (confidence 0.6)
|
|
245
|
-
* - "不对吧"/"没音信" → user_interrupted (confidence 0.5)
|
|
246
|
-
*
|
|
247
|
-
* English patterns:
|
|
248
|
-
* - "wrong"/"incorrect"/"not right" → user_provided_correction (confidence 0.7)
|
|
249
|
-
* - "missed"/"missing"/"forgot"/"incomplete" → user_provided_correction (confidence 0.7)
|
|
250
|
-
* - "redo"/"again"/"retry"/"try again" → user_repeated_instruction (confidence 0.5)
|
|
251
|
-
*
|
|
252
|
-
* Returns number of signals detected.
|
|
253
|
-
*/
|
|
254
|
-
detectFromUserMessages(messages, sessionId) {
|
|
255
|
-
let detected = 0;
|
|
256
|
-
const userMessages = messages.filter((m) => m.role === 'user');
|
|
257
|
-
for (const msg of userMessages) {
|
|
258
|
-
const text = msg.content.toLowerCase();
|
|
259
|
-
const dedupKey = `msg:${msg.ts ?? Date.now()}:${msg.content.substring(0, 40)}`;
|
|
260
|
-
if (this.detectedKeys.has(dedupKey))
|
|
261
|
-
continue;
|
|
262
|
-
// ── Chinese correction patterns ──
|
|
263
|
-
// Strong frustration: "失忆"/"忘了"/"不记得"
|
|
264
|
-
if (/失忆|忘了|(?:怎么|咋).{0,3}(?:忘|漏|没|不记得)/.test(msg.content)) {
|
|
265
|
-
this.detectedKeys.add(dedupKey);
|
|
266
|
-
this.record('user_provided_correction', sessionId, undefined, 0.85, 'auto-msg-correction-strong');
|
|
267
|
-
detected++;
|
|
268
|
-
continue;
|
|
269
|
-
}
|
|
270
|
-
// Direct negation: "不对"/"错了"/"不是这样" (not followed by "吗"/"吧" question)
|
|
271
|
-
if (/(?:不对|错了|不是这样)(?:[吗吧]|的[吗吧])?$/.test(msg.content) ||
|
|
272
|
-
/^(?:不对|错了|不是)!/.test(msg.content)) {
|
|
273
|
-
this.detectedKeys.add(dedupKey);
|
|
274
|
-
this.record('user_provided_correction', sessionId, undefined, 0.8, 'auto-msg-correction-direct');
|
|
275
|
-
detected++;
|
|
276
|
-
continue;
|
|
277
|
-
}
|
|
278
|
-
// Omission: "漏了"/"缺了"/"没包括"/"遗漏"
|
|
279
|
-
if (/漏了|缺了|没包括|遗漏|没统计|没算|少.了/.test(msg.content)) {
|
|
280
|
-
this.detectedKeys.add(dedupKey);
|
|
281
|
-
this.record('user_provided_correction', sessionId, undefined, 0.75, 'auto-msg-correction-omission');
|
|
282
|
-
detected++;
|
|
283
|
-
continue;
|
|
284
|
-
}
|
|
285
|
-
// Agent capability complaint: "你没"/"你怎么"/"你咋" + negative
|
|
286
|
-
if (/(?:你没|你怎么|你咋)(?:.{0,5})(?:听|做|查|看|写|记|算|说|回答|汇总|总结)/.test(msg.content)) {
|
|
287
|
-
this.detectedKeys.add(dedupKey);
|
|
288
|
-
this.record('user_provided_correction', sessionId, undefined, 0.7, 'auto-msg-correction-agent');
|
|
289
|
-
detected++;
|
|
290
|
-
continue;
|
|
291
|
-
}
|
|
292
|
-
// Repeat request: "重新"/"再查"/"再搜"/"再看看"/"再汇总"
|
|
293
|
-
if (/重新.{0,3}(?:做|查|搜|看|写|汇总|弄|搞|来)|再.{0,2}(?:查|搜|看|汇总|弄|搞|试)/.test(msg.content)) {
|
|
294
|
-
this.detectedKeys.add(dedupKey);
|
|
295
|
-
this.record('user_repeated_instruction', sessionId, undefined, 0.6, 'auto-msg-repeat-request');
|
|
296
|
-
detected++;
|
|
297
|
-
continue;
|
|
298
|
-
}
|
|
299
|
-
// Mild interruption: "没音信"/"不对吧"
|
|
300
|
-
if (/没音信|不对吧/.test(msg.content)) {
|
|
301
|
-
this.detectedKeys.add(dedupKey);
|
|
302
|
-
this.record('user_interrupted', sessionId, undefined, 0.5, 'auto-msg-interrupt');
|
|
303
|
-
detected++;
|
|
304
|
-
continue;
|
|
305
|
-
}
|
|
306
|
-
// ── English patterns ──
|
|
307
|
-
// Strong negation
|
|
308
|
-
if (/(?:that.?s|this is|you.?re|you are).{0,5}(?:wrong|incorrect|not right|not correct)/.test(text)) {
|
|
309
|
-
this.detectedKeys.add(dedupKey);
|
|
310
|
-
this.record('user_provided_correction', sessionId, undefined, 0.7, 'auto-msg-correction-en');
|
|
311
|
-
detected++;
|
|
312
|
-
continue;
|
|
313
|
-
}
|
|
314
|
-
// Omission
|
|
315
|
-
if (/(?:missed|missing|forgot|forgotten|incomplete|left out|didn.?t include)/.test(text)) {
|
|
316
|
-
this.detectedKeys.add(dedupKey);
|
|
317
|
-
this.record('user_provided_correction', sessionId, undefined, 0.7, 'auto-msg-omission-en');
|
|
318
|
-
detected++;
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
// Repeat
|
|
322
|
-
if (/(?:redo|do it again|try again|retry)/.test(text)) {
|
|
323
|
-
this.detectedKeys.add(dedupKey);
|
|
324
|
-
this.record('user_repeated_instruction', sessionId, undefined, 0.5, 'auto-msg-repeat-en');
|
|
325
|
-
detected++;
|
|
326
|
-
}
|
|
327
|
-
}
|
|
328
|
-
return detected;
|
|
329
|
-
}
|
|
330
|
-
// ══════════════════════════════════
|
|
331
|
-
getSignalStrength(signal) {
|
|
332
|
-
switch (signal) {
|
|
333
|
-
case 'user_deleted_code': return -0.8;
|
|
334
|
-
case 'user_interrupted': return -0.6;
|
|
335
|
-
case 'user_provided_correction': return -0.7;
|
|
336
|
-
case 'user_modified_output': return -0.5;
|
|
337
|
-
case 'user_repeated_instruction': return -0.15;
|
|
338
|
-
case 'user_ignored_result': return -0.4;
|
|
339
|
-
case 'user_silence_then_praise': return 0.2;
|
|
340
|
-
case 'user_immediate_continue': return 0.3;
|
|
341
|
-
case 'agent_self_corrected': return 0.3;
|
|
342
|
-
case 'user_explicit_approval': return 0.6;
|
|
343
|
-
case 'user_used_result': return 0.7;
|
|
344
|
-
case 'user_shared_output': return 0.8;
|
|
345
|
-
default: return 0;
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
getSatisfactionScore(sessionId, recentHours = 24) {
|
|
349
|
-
// If feedbackLog is empty, try auto-detecting from global audit log first
|
|
350
|
-
if (this.feedbackLog.length === 0 && this.globalAuditPath) {
|
|
351
|
-
this.autoDetectGlobal();
|
|
352
|
-
}
|
|
353
|
-
let relevant = this.feedbackLog;
|
|
354
|
-
if (sessionId) {
|
|
355
|
-
relevant = relevant.filter((f) => f.sessionId === sessionId);
|
|
356
|
-
}
|
|
357
|
-
const cutoff = Date.now() - recentHours * 60 * 60 * 1000;
|
|
358
|
-
relevant = relevant.filter((f) => f.timestamp >= cutoff);
|
|
359
|
-
// No signals: return neutral 0 (maps to 50/100 satisfaction) instead of 0
|
|
360
|
-
if (relevant.length === 0)
|
|
361
|
-
return 0;
|
|
362
|
-
let weightedSum = 0;
|
|
363
|
-
let totalWeight = 0;
|
|
364
|
-
for (const fb of relevant) {
|
|
365
|
-
const ageHours = (Date.now() - fb.timestamp) / (60 * 60 * 1000);
|
|
366
|
-
const recencyWeight = Math.max(0.1, 1 - ageHours / recentHours);
|
|
367
|
-
// Auto-detected signals get 0.5x weight discount to avoid polluting stats
|
|
368
|
-
const sourceWeight = fb.source.startsWith('auto-') ? 0.5 : 1.0;
|
|
369
|
-
const weight = fb.confidence * recencyWeight * sourceWeight;
|
|
370
|
-
weightedSum += fb.strength * weight;
|
|
371
|
-
totalWeight += weight;
|
|
372
|
-
}
|
|
373
|
-
return totalWeight > 0
|
|
374
|
-
? Math.round((weightedSum / totalWeight) * 100) / 100
|
|
375
|
-
: 0;
|
|
376
|
-
}
|
|
377
|
-
query(filter = {}) {
|
|
378
|
-
let results = this.feedbackLog;
|
|
379
|
-
if (filter.signal)
|
|
380
|
-
results = results.filter((f) => f.signal === filter.signal);
|
|
381
|
-
if (filter.sessionId)
|
|
382
|
-
results = results.filter((f) => f.sessionId === filter.sessionId);
|
|
383
|
-
if (filter.minStrength !== undefined)
|
|
384
|
-
results = results.filter((f) => f.strength >= filter.minStrength);
|
|
385
|
-
if (filter.maxStrength !== undefined)
|
|
386
|
-
results = results.filter((f) => f.strength <= filter.maxStrength);
|
|
387
|
-
if (filter.since !== undefined)
|
|
388
|
-
results = results.filter((f) => f.timestamp >= filter.since);
|
|
389
|
-
results.sort((a, b) => b.timestamp - a.timestamp);
|
|
390
|
-
return results.slice(0, filter.limit ?? 50);
|
|
391
|
-
}
|
|
392
|
-
stats() {
|
|
393
|
-
const positive = this.feedbackLog.filter((f) => f.strength > 0);
|
|
394
|
-
const negative = this.feedbackLog.filter((f) => f.strength < 0);
|
|
395
|
-
const avgStrength = this.feedbackLog.length > 0
|
|
396
|
-
? this.feedbackLog.reduce((s, f) => s + f.strength, 0) / this.feedbackLog.length
|
|
397
|
-
: 0;
|
|
398
|
-
const counts = new Map();
|
|
399
|
-
for (const fb of this.feedbackLog)
|
|
400
|
-
counts.set(fb.signal, (counts.get(fb.signal) || 0) + 1);
|
|
401
|
-
let mostCommon = null;
|
|
402
|
-
let maxCount = 0;
|
|
403
|
-
for (const [sig, count] of counts) {
|
|
404
|
-
if (count > maxCount) {
|
|
405
|
-
maxCount = count;
|
|
406
|
-
mostCommon = sig;
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
return {
|
|
410
|
-
totalSignals: this.feedbackLog.length,
|
|
411
|
-
positiveSignals: positive.length,
|
|
412
|
-
negativeSignals: negative.length,
|
|
413
|
-
averageStrength: Math.round(avgStrength * 100) / 100,
|
|
414
|
-
mostCommonSignal: mostCommon,
|
|
415
|
-
};
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
exports.ImplicitFeedbackEngine = ImplicitFeedbackEngine;
|
|
419
|
-
//# sourceMappingURL=feedback.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"feedback.js","sourceRoot":"","sources":["../../src/evaluator/feedback.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;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C,GAAG,GAAG;YACpD,gBAAgB,EAAE,UAAU;SAC7B,CAAC;IACJ,CAAC;CACF;AAjaD,wDAiaC"}
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import { PreExecMetrics, RuntimeMetrics, PostExecMetrics } from '../types';
|
|
2
|
-
import { ImplicitFeedbackEngine } from './feedback';
|
|
3
|
-
/**
|
|
4
|
-
* Agent quality profile — accumulated across all evaluations.
|
|
5
|
-
*/
|
|
6
|
-
export interface AgentProfile {
|
|
7
|
-
/** Overall quality score (0-100) */
|
|
8
|
-
overallScore: number;
|
|
9
|
-
/** Number of operations evaluated */
|
|
10
|
-
totalOps: number;
|
|
11
|
-
/** Score breakdown by metric category */
|
|
12
|
-
breakdown: {
|
|
13
|
-
preExec: number | null;
|
|
14
|
-
runtime: number | null;
|
|
15
|
-
postExec: number | null;
|
|
16
|
-
userSatisfaction: number;
|
|
17
|
-
};
|
|
18
|
-
/** Trend data */
|
|
19
|
-
trends: {
|
|
20
|
-
improving: boolean;
|
|
21
|
-
recentOps: number;
|
|
22
|
-
recentScore: number;
|
|
23
|
-
};
|
|
24
|
-
/** Areas needing attention */
|
|
25
|
-
warnings: string[];
|
|
26
|
-
/** Kudos for good patterns */
|
|
27
|
-
strengths: string[];
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* AgentProfiler — builds and maintains the agent's quality profile.
|
|
31
|
-
*
|
|
32
|
-
* Aggregates PreExec + Runtime + PostExec metrics and
|
|
33
|
-
* ImplicitFeedback to produce a composite quality score
|
|
34
|
-
* that improves over time through self-correction.
|
|
35
|
-
*/
|
|
36
|
-
export declare class AgentProfiler {
|
|
37
|
-
private feedbackEngine;
|
|
38
|
-
private preMetrics;
|
|
39
|
-
private runMetrics;
|
|
40
|
-
private postMetrics;
|
|
41
|
-
private sessionScores;
|
|
42
|
-
constructor(feedbackEngine: ImplicitFeedbackEngine);
|
|
43
|
-
/**
|
|
44
|
-
* Record a complete evaluation cycle for one tool call.
|
|
45
|
-
*/
|
|
46
|
-
recordCycle(sessionId: string, pre: PreExecMetrics, run: RuntimeMetrics, post: PostExecMetrics): void;
|
|
47
|
-
/** Clean up session scores to prevent memory leak */
|
|
48
|
-
clearSession(sessionId: string): void;
|
|
49
|
-
/**
|
|
50
|
-
* Build the current agent profile.
|
|
51
|
-
*/
|
|
52
|
-
getProfile(sessionId?: string): AgentProfile;
|
|
53
|
-
private average;
|
|
54
|
-
}
|
|
55
|
-
//# sourceMappingURL=profiler.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profiler.d.ts","sourceRoot":"","sources":["../../src/evaluator/profiler.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,cAAc,EACd,cAAc,EACd,eAAe,EAChB,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEpD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,oCAAoC;IACpC,YAAY,EAAE,MAAM,CAAC;IACrB,qCAAqC;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,yCAAyC;IACzC,SAAS,EAAE;QACT,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,OAAO,EAAE,MAAM,GAAG,IAAI,CAAC;QACvB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,gBAAgB,EAAE,MAAM,CAAC;KAC1B,CAAC;IACF,iBAAiB;IACjB,MAAM,EAAE;QACN,SAAS,EAAE,OAAO,CAAC;QACnB,SAAS,EAAE,MAAM,CAAC;QAClB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,8BAA8B;IAC9B,QAAQ,EAAE,MAAM,EAAE,CAAC;IACnB,8BAA8B;IAC9B,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED;;;;;;GAMG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,cAAc,CAAyB;IAE/C,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,UAAU,CAAwB;IAC1C,OAAO,CAAC,WAAW,CAAyB;IAC5C,OAAO,CAAC,aAAa,CAAoC;gBAE7C,cAAc,EAAE,sBAAsB;IAIlD;;OAEG;IACH,WAAW,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,EAAE,cAAc,EAAE,IAAI,EAAE,eAAe,GAAG,IAAI;IAcrG,qDAAqD;IACrD,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAIrC;;OAEG;IACH,UAAU,CAAC,SAAS,CAAC,EAAE,MAAM,GAAG,YAAY;IA2F5C,OAAO,CAAC,OAAO;CAKhB"}
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AgentProfiler = void 0;
|
|
4
|
-
/**
|
|
5
|
-
* AgentProfiler — builds and maintains the agent's quality profile.
|
|
6
|
-
*
|
|
7
|
-
* Aggregates PreExec + Runtime + PostExec metrics and
|
|
8
|
-
* ImplicitFeedback to produce a composite quality score
|
|
9
|
-
* that improves over time through self-correction.
|
|
10
|
-
*/
|
|
11
|
-
class AgentProfiler {
|
|
12
|
-
feedbackEngine;
|
|
13
|
-
preMetrics = [];
|
|
14
|
-
runMetrics = [];
|
|
15
|
-
postMetrics = [];
|
|
16
|
-
sessionScores = new Map();
|
|
17
|
-
constructor(feedbackEngine) {
|
|
18
|
-
this.feedbackEngine = feedbackEngine;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* Record a complete evaluation cycle for one tool call.
|
|
22
|
-
*/
|
|
23
|
-
recordCycle(sessionId, pre, run, post) {
|
|
24
|
-
// Ensure timestamp is set for trend filtering
|
|
25
|
-
if (!pre.timestamp)
|
|
26
|
-
pre.timestamp = Date.now();
|
|
27
|
-
if (!post.timestamp)
|
|
28
|
-
post.timestamp = Date.now();
|
|
29
|
-
this.preMetrics.push(pre);
|
|
30
|
-
this.runMetrics.push(run);
|
|
31
|
-
this.postMetrics.push(post);
|
|
32
|
-
// Track per-session scores
|
|
33
|
-
const sessionScores = this.sessionScores.get(sessionId) ?? [];
|
|
34
|
-
sessionScores.push(post.outcomeScore);
|
|
35
|
-
this.sessionScores.set(sessionId, sessionScores);
|
|
36
|
-
}
|
|
37
|
-
/** Clean up session scores to prevent memory leak */
|
|
38
|
-
clearSession(sessionId) {
|
|
39
|
-
this.sessionScores.delete(sessionId);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Build the current agent profile.
|
|
43
|
-
*/
|
|
44
|
-
getProfile(sessionId) {
|
|
45
|
-
const totalOps = this.preMetrics.length;
|
|
46
|
-
// Pre-exec scores
|
|
47
|
-
const preExecScore = this.average(this.preMetrics.map((m) => ((m.paramQuality.score + m.contextUtilization.score) / 2) * 100)) ?? 0;
|
|
48
|
-
// Runtime scores
|
|
49
|
-
const runtimeScore = this.average(this.runMetrics.map((m) => m.adaptiveScore * 100)) ?? 0;
|
|
50
|
-
// Post-exec scores
|
|
51
|
-
const postExecScore = this.average(this.postMetrics.map((m) => m.outcomeScore * 100)) ?? 0;
|
|
52
|
-
// User satisfaction
|
|
53
|
-
const satisfaction = this.feedbackEngine.getSatisfactionScore(sessionId);
|
|
54
|
-
const satisfactionScore = ((satisfaction + 1) / 2) * 100; // Map -1..1 to 0..100
|
|
55
|
-
// Overall: weighted — only include dimensions with data
|
|
56
|
-
let overallScore = 0;
|
|
57
|
-
let totalWeight = 0;
|
|
58
|
-
if (this.preMetrics.length > 0) {
|
|
59
|
-
overallScore += preExecScore * 0.2;
|
|
60
|
-
totalWeight += 0.2;
|
|
61
|
-
}
|
|
62
|
-
if (this.runMetrics.length > 0) {
|
|
63
|
-
overallScore += runtimeScore * 0.25;
|
|
64
|
-
totalWeight += 0.25;
|
|
65
|
-
}
|
|
66
|
-
if (this.postMetrics.length > 0) {
|
|
67
|
-
overallScore += postExecScore * 0.3;
|
|
68
|
-
totalWeight += 0.3;
|
|
69
|
-
}
|
|
70
|
-
overallScore += satisfactionScore * 0.25;
|
|
71
|
-
totalWeight += 0.25; // always include satisfaction
|
|
72
|
-
overallScore = totalWeight > 0 ? Math.round(overallScore / totalWeight) : 50;
|
|
73
|
-
// Recent trend
|
|
74
|
-
const recentCutoff = Date.now() - 24 * 60 * 60 * 1000;
|
|
75
|
-
const recentPre = this.preMetrics.filter((m) => m.timestamp >= recentCutoff);
|
|
76
|
-
const recentRun = this.runMetrics.slice(-recentPre.length);
|
|
77
|
-
const recentPost = this.postMetrics.slice(-recentPre.length);
|
|
78
|
-
const recentScore = recentPre.length > 0
|
|
79
|
-
? Math.round((this.average(recentPre.map((m) => (m.paramQuality.score + m.contextUtilization.score) / 2)) ?? 0) * 100 * 0.2 +
|
|
80
|
-
(this.average(recentRun.map((m) => m.adaptiveScore)) ?? 0) * 100 * 0.25 +
|
|
81
|
-
(this.average(recentPost.map((m) => m.outcomeScore)) ?? 0) * 100 * 0.3 +
|
|
82
|
-
satisfactionScore * 0.25)
|
|
83
|
-
: overallScore;
|
|
84
|
-
// Warnings and strengths
|
|
85
|
-
const warnings = [];
|
|
86
|
-
const strengths = [];
|
|
87
|
-
if (runtimeScore < 0.5) {
|
|
88
|
-
warnings.push('High retry rate — consider more planning before execution');
|
|
89
|
-
}
|
|
90
|
-
if (postExecScore < 0.5) {
|
|
91
|
-
warnings.push('Low verify pass rate — verify results before claiming success');
|
|
92
|
-
}
|
|
93
|
-
if (satisfaction < -0.3) {
|
|
94
|
-
warnings.push('User satisfaction declining — review recent sessions');
|
|
95
|
-
}
|
|
96
|
-
if (runtimeScore > 0.9) {
|
|
97
|
-
strengths.push('Excellent execution reliability');
|
|
98
|
-
}
|
|
99
|
-
if (postExecScore > 0.9) {
|
|
100
|
-
strengths.push('Verify gate passing consistently');
|
|
101
|
-
}
|
|
102
|
-
if (satisfaction > 0.5) {
|
|
103
|
-
strengths.push('Strong positive user feedback');
|
|
104
|
-
}
|
|
105
|
-
return {
|
|
106
|
-
overallScore: Number.isNaN(overallScore) ? 50 : overallScore, // 0-100, default 50 if no data
|
|
107
|
-
totalOps,
|
|
108
|
-
breakdown: {
|
|
109
|
-
preExec: totalOps > 0 ? Math.round(preExecScore * 100) / 100 : null,
|
|
110
|
-
runtime: totalOps > 0 ? Math.round(runtimeScore * 100) / 100 : null,
|
|
111
|
-
postExec: totalOps > 0 ? Math.round(postExecScore * 100) / 100 : null,
|
|
112
|
-
userSatisfaction: Math.round(satisfactionScore * 100) / 100,
|
|
113
|
-
},
|
|
114
|
-
trends: {
|
|
115
|
-
improving: recentScore > overallScore,
|
|
116
|
-
recentOps: recentPre.length,
|
|
117
|
-
recentScore: Math.round(recentScore) / 100,
|
|
118
|
-
},
|
|
119
|
-
warnings,
|
|
120
|
-
strengths,
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
average(values) {
|
|
124
|
-
return values.length > 0
|
|
125
|
-
? values.reduce((s, v) => s + v, 0) / values.length
|
|
126
|
-
: null;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
exports.AgentProfiler = AgentProfiler;
|
|
130
|
-
//# sourceMappingURL=profiler.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"profiler.js","sourceRoot":"","sources":["../../src/evaluator/profiler.ts"],"names":[],"mappings":";;;AAkCA;;;;;;GAMG;AACH,MAAa,aAAa;IAChB,cAAc,CAAyB;IAEvC,UAAU,GAAqB,EAAE,CAAC;IAClC,UAAU,GAAqB,EAAE,CAAC;IAClC,WAAW,GAAsB,EAAE,CAAC;IACpC,aAAa,GAA0B,IAAI,GAAG,EAAE,CAAC;IAEzD,YAAY,cAAsC;QAChD,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;IACvC,CAAC;IAED;;OAEG;IACH,WAAW,CAAC,SAAiB,EAAE,GAAmB,EAAE,GAAmB,EAAE,IAAqB;QAC5F,8CAA8C;QAC9C,IAAI,CAAC,GAAG,CAAC,SAAS;YAAE,GAAG,CAAC,SAAS,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