onceonly-sdk 2.0.2__py3-none-any.whl → 3.0.0__py3-none-any.whl

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.
onceonly/models.py CHANGED
@@ -1,7 +1,7 @@
1
1
  from __future__ import annotations
2
2
 
3
- from dataclasses import dataclass
4
- from typing import Any, Dict, Optional
3
+ from dataclasses import dataclass, field
4
+ from typing import Any, Dict, Optional, List, Literal
5
5
 
6
6
 
7
7
  @dataclass(frozen=True)
@@ -16,12 +16,63 @@ class CheckLockResult:
16
16
  raw: Dict[str, Any]
17
17
 
18
18
  def should_proceed(self) -> bool:
19
- """
20
- Helper for agents/tools:
21
- - True => proceed with the expensive/side-effect operation
22
- - False => treat as duplicate (or blocked)
23
- """
24
19
  return bool(self.locked) and not bool(self.duplicate)
25
20
 
26
21
  def is_duplicate(self) -> bool:
27
22
  return bool(self.duplicate)
23
+
24
+
25
+ # ---------------------------
26
+ # Agent Governance (Policies)
27
+ # ---------------------------
28
+
29
+ @dataclass(frozen=True)
30
+ class Policy:
31
+ agent_id: str
32
+ policy: Dict[str, Any] = field(default_factory=dict)
33
+ max_actions_per_hour: Optional[int] = None
34
+ max_spend_usd_per_day: Optional[float] = None
35
+ allowed_tools: Optional[List[str]] = None
36
+ blocked_tools: Optional[List[str]] = None
37
+ max_calls_per_tool: Optional[Dict[str, int]] = None
38
+ pricing_rules: Optional[List[Dict[str, Any]]] = None
39
+ raw: Optional[Dict[str, Any]] = None
40
+
41
+
42
+ @dataclass(frozen=True)
43
+ class AgentStatus:
44
+ agent_id: str
45
+ is_enabled: bool
46
+ disabled_reason: Optional[str] = None
47
+ disabled_at: Optional[str] = None
48
+ raw: Optional[Dict[str, Any]] = None
49
+
50
+ @property
51
+ def enabled(self) -> bool:
52
+ return bool(self.is_enabled)
53
+
54
+
55
+ @dataclass(frozen=True)
56
+ class AgentLogItem:
57
+ ts: Any
58
+ agent_id: str
59
+ tool: Optional[str] = None
60
+ allowed: bool = True
61
+ decision: Optional[str] = None
62
+ policy_reason: Optional[str] = None
63
+ reason: str = ""
64
+ args_hash: Optional[str] = None
65
+ risk_level: Optional[str] = None
66
+ spend_usd: float = 0.0
67
+ raw: Optional[Dict[str, Any]] = None
68
+
69
+
70
+ @dataclass(frozen=True)
71
+ class AgentMetrics:
72
+ agent_id: str
73
+ period: Literal["hour", "day", "week"]
74
+ total_actions: int
75
+ blocked_actions: int
76
+ total_spend_usd: float
77
+ top_tools: List[Dict[str, Any]]
78
+ raw: Optional[Dict[str, Any]] = None
onceonly/version.py CHANGED
@@ -1 +1 @@
1
- __version__ = "2.0.2"
1
+ __version__ = "3.0.0"