@better_openclaw/betterclaw 2.0.1 → 2.0.2

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@better_openclaw/betterclaw",
3
- "version": "2.0.1",
3
+ "version": "2.0.2",
4
4
  "description": "Intelligent event filtering, context tracking, and proactive triggers for BetterClaw",
5
5
  "license": "AGPL-3.0-only",
6
6
  "repository": {
package/src/filter.ts CHANGED
@@ -1,21 +1,15 @@
1
1
  import type { DeviceContext, DeviceEvent, FilterDecision } from "./types.js";
2
2
 
3
- // Cooldowns in seconds
4
- const DEDUP_COOLDOWN: Record<string, number> = {
5
- "default.battery-low": 3600,
6
- "default.battery-critical": 1800,
7
- "default.daily-health": 82800, // 23 hours
8
- "default.geofence": 300,
9
- };
10
-
11
- const DEFAULT_COOLDOWN = 1800; // 30 minutes
12
-
13
3
  export class RulesEngine {
14
4
  private lastFired: Map<string, number> = new Map();
15
5
  private pushBudget: number;
6
+ private cooldowns: Record<string, number>;
7
+ private defaultCooldown: number;
16
8
 
17
- constructor(pushBudget: number = 10) {
9
+ constructor(pushBudget: number = 10, cooldowns: Record<string, number> = {}, defaultCooldown: number = 1800) {
18
10
  this.pushBudget = pushBudget;
11
+ this.cooldowns = cooldowns;
12
+ this.defaultCooldown = defaultCooldown;
19
13
  }
20
14
 
21
15
  evaluate(event: DeviceEvent, context: DeviceContext, budgetOverride?: number): FilterDecision {
@@ -26,7 +20,7 @@ export class RulesEngine {
26
20
 
27
21
  // Dedup check
28
22
  const lastFiredAt = this.lastFired.get(event.subscriptionId);
29
- const cooldown = DEDUP_COOLDOWN[event.subscriptionId] ?? DEFAULT_COOLDOWN;
23
+ const cooldown = this.cooldowns[event.subscriptionId] ?? this.defaultCooldown;
30
24
  if (lastFiredAt && event.firedAt - lastFiredAt < cooldown) {
31
25
  return {
32
26
  action: "drop",
package/src/index.ts CHANGED
@@ -16,6 +16,13 @@ import * as path from "node:path";
16
16
 
17
17
  export type { PluginConfig } from "./types.js";
18
18
 
19
+ const DEFAULT_COOLDOWNS: Record<string, number> = {
20
+ "default.battery-low": 3600,
21
+ "default.battery-critical": 1800,
22
+ "default.daily-health": 82800,
23
+ "default.geofence": 300,
24
+ };
25
+
19
26
  const DEFAULT_CONFIG: PluginConfig = {
20
27
  triageModel: "openai/gpt-4o-mini",
21
28
  triageApiBase: undefined,
@@ -23,6 +30,8 @@ const DEFAULT_CONFIG: PluginConfig = {
23
30
  patternWindowDays: 14,
24
31
  proactiveEnabled: true,
25
32
  analysisHour: 5,
33
+ deduplicationCooldowns: DEFAULT_COOLDOWNS,
34
+ defaultCooldown: 1800,
26
35
  };
27
36
 
28
37
  function resolveConfig(raw: Record<string, unknown> | undefined): PluginConfig {
@@ -34,6 +43,13 @@ function resolveConfig(raw: Record<string, unknown> | undefined): PluginConfig {
34
43
  patternWindowDays: typeof cfg.patternWindowDays === "number" && cfg.patternWindowDays > 0 ? cfg.patternWindowDays : 14,
35
44
  proactiveEnabled: typeof cfg.proactiveEnabled === "boolean" ? cfg.proactiveEnabled : true,
36
45
  analysisHour: typeof cfg.analysisHour === "number" ? Math.max(0, Math.min(23, cfg.analysisHour)) : 5,
46
+ deduplicationCooldowns: {
47
+ ...DEFAULT_COOLDOWNS,
48
+ ...(typeof cfg.deduplicationCooldowns === "object" && cfg.deduplicationCooldowns !== null
49
+ ? cfg.deduplicationCooldowns as Record<string, number>
50
+ : {}),
51
+ },
52
+ defaultCooldown: typeof cfg.defaultCooldown === "number" && cfg.defaultCooldown > 0 ? cfg.defaultCooldown : 1800,
37
53
  };
38
54
  }
39
55
 
@@ -52,7 +68,7 @@ export default {
52
68
 
53
69
  // Event log, rules engine, reaction tracker
54
70
  const eventLog = new EventLog(stateDir);
55
- const rules = new RulesEngine(config.pushBudgetPerDay);
71
+ const rules = new RulesEngine(config.pushBudgetPerDay, config.deduplicationCooldowns, config.defaultCooldown);
56
72
  const reactionTracker = new ReactionTracker(stateDir);
57
73
 
58
74
  // Pipeline dependencies
package/src/types.ts CHANGED
@@ -127,6 +127,8 @@ export interface PluginConfig {
127
127
  patternWindowDays: number;
128
128
  proactiveEnabled: boolean;
129
129
  analysisHour: number;
130
+ deduplicationCooldowns: Record<string, number>;
131
+ defaultCooldown: number;
130
132
  }
131
133
 
132
134
  // Triage profile produced by daily learning agent