safentic 1.0.3__tar.gz → 1.0.4__tar.gz

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.
Files changed (27) hide show
  1. {safentic-1.0.3/safentic.egg-info → safentic-1.0.4}/PKG-INFO +1 -1
  2. {safentic-1.0.3 → safentic-1.0.4}/safentic/__init__.py +1 -1
  3. {safentic-1.0.3 → safentic-1.0.4}/safentic/layer.py +16 -10
  4. {safentic-1.0.3 → safentic-1.0.4/safentic.egg-info}/PKG-INFO +1 -1
  5. {safentic-1.0.3 → safentic-1.0.4}/setup.py +1 -1
  6. {safentic-1.0.3 → safentic-1.0.4}/MANIFEST.in +0 -0
  7. {safentic-1.0.3 → safentic-1.0.4}/README.md +0 -0
  8. {safentic-1.0.3 → safentic-1.0.4}/requirements.txt +0 -0
  9. {safentic-1.0.3 → safentic-1.0.4}/safentic/LICENSE.txt +0 -0
  10. {safentic-1.0.3 → safentic-1.0.4}/safentic/config.py +0 -0
  11. {safentic-1.0.3 → safentic-1.0.4}/safentic/engine.py +0 -0
  12. {safentic-1.0.3 → safentic-1.0.4}/safentic/helper/__init__.py +0 -0
  13. {safentic-1.0.3 → safentic-1.0.4}/safentic/helper/auth.py +0 -0
  14. {safentic-1.0.3 → safentic-1.0.4}/safentic/logger/__init__.py +0 -0
  15. {safentic-1.0.3 → safentic-1.0.4}/safentic/logger/audit.py +0 -0
  16. {safentic-1.0.3 → safentic-1.0.4}/safentic/policies/.gitkeep +0 -0
  17. {safentic-1.0.3 → safentic-1.0.4}/safentic/policies/__init__.py +0 -0
  18. {safentic-1.0.3 → safentic-1.0.4}/safentic/policies/example_policy.txt +0 -0
  19. {safentic-1.0.3 → safentic-1.0.4}/safentic/policies/policy.yaml +0 -0
  20. {safentic-1.0.3 → safentic-1.0.4}/safentic/policy.py +0 -0
  21. {safentic-1.0.3 → safentic-1.0.4}/safentic/verifiers/__init__.py +0 -0
  22. {safentic-1.0.3 → safentic-1.0.4}/safentic/verifiers/sentence_verifier.py +0 -0
  23. {safentic-1.0.3 → safentic-1.0.4}/safentic.egg-info/SOURCES.txt +0 -0
  24. {safentic-1.0.3 → safentic-1.0.4}/safentic.egg-info/dependency_links.txt +0 -0
  25. {safentic-1.0.3 → safentic-1.0.4}/safentic.egg-info/requires.txt +0 -0
  26. {safentic-1.0.3 → safentic-1.0.4}/safentic.egg-info/top_level.txt +0 -0
  27. {safentic-1.0.3 → safentic-1.0.4}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: safentic
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: Safentic SDK for behavior analysis
5
5
  Home-page: https://safentic.com
6
6
  Author: Safentic
@@ -5,4 +5,4 @@ __all__ = [
5
5
  "SafenticError",
6
6
  ]
7
7
 
8
- __version__ = "1.0.3"
8
+ __version__ = "1.0.4"
@@ -6,23 +6,30 @@ class SafenticError(Exception):
6
6
  """Raised when Safentic blocks an action."""
7
7
  pass
8
8
 
9
+ class InvalidAPIKeyError(Exception):
10
+ """Raised when an invalid API key is used."""
11
+ pass
9
12
 
10
- class SafetyLayer():
13
+ class SafetyLayer:
11
14
  """
12
15
  Safentic runtime enforcement wrapper for agent actions.
13
- First, insert your api key, then run an action.
14
- Example:
15
- safety.protect("send_email", {"body": "..."})
16
- # Raises SafenticError if blocked
16
+ Requires a valid API key to function.
17
17
  """
18
18
 
19
- def __init__(self, api_key="", agent_id="", enforcer: PolicyEnforcer = None, raise_on_block: bool = True):
19
+ def __init__(self, api_key: str = "", agent_id: str = "", enforcer: PolicyEnforcer = None, raise_on_block: bool = True):
20
+ if not api_key:
21
+ raise InvalidAPIKeyError("Missing API key")
22
+
23
+ validation_response = validate_api_key(api_key)
24
+ if not validation_response or validation_response.get("status") != "valid":
25
+ raise InvalidAPIKeyError("Invalid or unauthorized API key")
26
+
27
+ self.api_key = api_key
20
28
  self.agent_id = agent_id
21
29
  self.raise_on_block = raise_on_block
22
30
  self.logger = AuditLogger()
23
31
 
24
32
  self.enforcer = enforcer or PolicyEnforcer()
25
- self.api_key = validate_api_key(api_key)
26
33
  self.enforcer.reset(agent_id)
27
34
 
28
35
  def protect(self, tool_name: str, tool_args: dict) -> dict:
@@ -30,7 +37,7 @@ class SafetyLayer():
30
37
  Checks whether a tool action is allowed.
31
38
  Raises SafenticError if blocked (default), or returns result if raise_on_block=False.
32
39
  """
33
-
40
+
34
41
  result = self.enforcer.enforce(self.agent_id, tool_name, tool_args)
35
42
 
36
43
  # Log structured event
@@ -41,10 +48,9 @@ class SafetyLayer():
41
48
  reason=result["reason"] if not result["allowed"] else None
42
49
  )
43
50
 
44
- # Raise or return based on outcome and config
45
51
  if not result["allowed"]:
46
52
  if self.raise_on_block:
47
53
  raise SafenticError(result["reason"])
48
54
  return result
49
55
 
50
- return result
56
+ return result
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: safentic
3
- Version: 1.0.3
3
+ Version: 1.0.4
4
4
  Summary: Safentic SDK for behavior analysis
5
5
  Home-page: https://safentic.com
6
6
  Author: Safentic
@@ -2,7 +2,7 @@ from setuptools import setup, find_packages
2
2
 
3
3
  setup(
4
4
  name="safentic",
5
- version="1.0.3",
5
+ version="1.0.4",
6
6
  packages=find_packages(),
7
7
  install_requires=[
8
8
  "requests",
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes