@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.
@@ -2,7 +2,7 @@
2
2
  "id": "courtroom",
3
3
  "name": "ClawTrial Courtroom",
4
4
  "description": "Autonomous behavioral oversight plugin for OpenClaw",
5
- "version": "2.0.2",
5
+ "version": "2.0.5",
6
6
  "author": "ClawTrial",
7
7
  "main": "src/plugin.js",
8
8
  "engines": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawtrial/courtroom",
3
- "version": "2.0.2",
3
+ "version": "2.0.5",
4
4
  "description": "AI Courtroom - Autonomous behavioral oversight plugin for OpenClaw",
5
5
  "main": "src/plugin.js",
6
6
  "openclaw": {
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: 5,
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') || 5;
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) return null;
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()) return null;
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 (_event, ctx) => {
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 = ctx.messages || [];
354
+ const messages = event.messages || [];
347
355
  const verdictContext = await runtime.onMessages(messages);
348
356
 
349
357
  // Collect any context to append