@clawtrial/courtroom 2.0.2 → 2.0.5
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/openclaw.plugin.json +1 -1
- package/package.json +1 -1
- package/src/plugin.js +14 -6
package/openclaw.plugin.json
CHANGED
package/package.json
CHANGED
package/src/plugin.js
CHANGED
|
@@ -30,7 +30,7 @@ const { logger, setLogDir } = require('./debug');
|
|
|
30
30
|
const DEFAULT_CONFIG = {
|
|
31
31
|
enabled: true,
|
|
32
32
|
detection: {
|
|
33
|
-
minMessages:
|
|
33
|
+
minMessages: 3,
|
|
34
34
|
cooldownMinutes: 30,
|
|
35
35
|
maxCasesPerDay: 3,
|
|
36
36
|
confidenceThreshold: 0.6
|
|
@@ -157,13 +157,21 @@ class CourtroomRuntime {
|
|
|
157
157
|
// Check if we should evaluate
|
|
158
158
|
const now = Date.now();
|
|
159
159
|
const cooldownMs = (this.config.get('detection.cooldownMinutes') || 30) * 60 * 1000;
|
|
160
|
-
const minMessages = this.config.get('detection.minMessages') ||
|
|
160
|
+
const minMessages = this.config.get('detection.minMessages') || 3;
|
|
161
161
|
const userMessages = this.messageBuffer.filter(m => m.role === 'user');
|
|
162
162
|
|
|
163
|
+
logger.info('PLUGIN', `Buffered ${userMessages.length}/${minMessages} user messages`);
|
|
164
|
+
|
|
163
165
|
if (userMessages.length < minMessages) return null;
|
|
164
|
-
if (now - this.lastEvaluation < cooldownMs)
|
|
166
|
+
if (now - this.lastEvaluation < cooldownMs) {
|
|
167
|
+
logger.info('PLUGIN', `Skipping evaluation (on cooldown)`);
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
165
170
|
if (this.pendingHearing) return null;
|
|
166
|
-
if (this._isDailyLimitReached())
|
|
171
|
+
if (this._isDailyLimitReached()) {
|
|
172
|
+
logger.info('PLUGIN', `Skipping evaluation (daily limit reached)`);
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
167
175
|
|
|
168
176
|
// Run detection
|
|
169
177
|
try {
|
|
@@ -336,14 +344,14 @@ function register(api) {
|
|
|
336
344
|
// -------------------------------------------------------------------------
|
|
337
345
|
// Hook: before_prompt_build — analyse messages + inject context
|
|
338
346
|
// -------------------------------------------------------------------------
|
|
339
|
-
api.on('before_prompt_build', async (
|
|
347
|
+
api.on('before_prompt_build', async (event, _ctx) => {
|
|
340
348
|
if (!runtime.initialized || !runtime.enabled) return {};
|
|
341
349
|
|
|
342
350
|
const result = {};
|
|
343
351
|
|
|
344
352
|
try {
|
|
345
353
|
// Run offense detection against current messages
|
|
346
|
-
const messages =
|
|
354
|
+
const messages = event.messages || [];
|
|
347
355
|
const verdictContext = await runtime.onMessages(messages);
|
|
348
356
|
|
|
349
357
|
// Collect any context to append
|