agentcheck-sdk 1.0.0 → 1.0.1

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/safety.js CHANGED
@@ -26,13 +26,13 @@ class BudgetTracker {
26
26
  if (this.dailyCountLimit && (this.dailyCounts[dayKey] || 0) >= this.dailyCountLimit) {
27
27
  return { allowed: false, reason: `Daily action count limit reached (${this.dailyCountLimit})` };
28
28
  }
29
- if (this.dailyLimit && amount > 0) {
29
+ if (this.dailyLimit !== undefined && amount > 0) {
30
30
  const projected = (this.dailyTotals[dayKey] || 0) + amount;
31
31
  if (projected > this.dailyLimit) {
32
32
  return { allowed: false, reason: `Daily budget exceeded: ${projected} > ${this.dailyLimit}` };
33
33
  }
34
34
  }
35
- if (this.monthlyLimit && amount > 0) {
35
+ if (this.monthlyLimit !== undefined && amount > 0) {
36
36
  const projected = (this.monthlyTotals[monthKey] || 0) + amount;
37
37
  if (projected > this.monthlyLimit) {
38
38
  return { allowed: false, reason: `Monthly budget exceeded: ${projected} > ${this.monthlyLimit}` };
@@ -41,6 +41,8 @@ class BudgetTracker {
41
41
  return { allowed: true, reason: "Within budget" };
42
42
  }
43
43
  recordUsage(action, amount = 0) {
44
+ if (amount < 0)
45
+ return; // Prevent budget gaming via negative amounts
44
46
  const dayKey = new Date().toISOString().slice(0, 10);
45
47
  const monthKey = dayKey.slice(0, 7);
46
48
  this.dailyTotals[dayKey] = (this.dailyTotals[dayKey] || 0) + amount;
@@ -34,8 +34,8 @@ class ScopeEngine {
34
34
  if (scope.denied?.includes(action)) {
35
35
  return { allowed: false, reason: `Action '${action}' is in denied list` };
36
36
  }
37
- // Allowed list
38
- if (scope.allowed?.length && !scope.allowed.includes(action)) {
37
+ // Allowed list (empty array = nothing allowed, undefined = no whitelist)
38
+ if (scope.allowed !== undefined && !scope.allowed.includes(action)) {
39
39
  return { allowed: false, reason: `Action '${action}' not in allowed list: ${scope.allowed.join(", ")}` };
40
40
  }
41
41
  // Amount limits
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agentcheck-sdk",
3
- "version": "1.0.0",
3
+ "version": "1.0.1",
4
4
  "description": "Record what your AI agent is allowed to do",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",