agenthat 0.0.1__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.
- agenthat-0.0.1/.gitignore +12 -0
- agenthat-0.0.1/PKG-INFO +56 -0
- agenthat-0.0.1/README.md +33 -0
- agenthat-0.0.1/pyproject.toml +49 -0
- agenthat-0.0.1/src/agenthat/__init__.py +91 -0
- agenthat-0.0.1/src/agenthat/cli.py +50 -0
agenthat-0.0.1/PKG-INFO
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: agenthat
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: AgentHat — Put a hat on your AI agent. Role permissions, tools, and sandbox limits for any AI agent.
|
|
5
|
+
Project-URL: Homepage, https://agenthat.dev
|
|
6
|
+
Project-URL: Repository, https://github.com/agenthat/agenthat
|
|
7
|
+
Project-URL: Issues, https://github.com/agenthat/agenthat/issues
|
|
8
|
+
Author-email: AgentHat <hello@agenthat.dev>
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: agent-permissions,agent-sandbox,agenthat,agents,ai-agents,cli,python,roles
|
|
11
|
+
Classifier: Development Status :: 3 - Alpha
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.15
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
|
|
24
|
+
# AgentHat
|
|
25
|
+
|
|
26
|
+
**Put a hat on your AI agent.**
|
|
27
|
+
|
|
28
|
+
We're not another AI agent — we're the hats your agents wear. Swap an agent's role and permissions (`fs`, `net`, `exec`) cleanly across tasks without giving every agent root.
|
|
29
|
+
|
|
30
|
+
## Install
|
|
31
|
+
|
|
32
|
+
```bash
|
|
33
|
+
pip install agenthat
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Python Usage
|
|
37
|
+
|
|
38
|
+
```python
|
|
39
|
+
from agenthat import AgentHatSession, Hat, wear_hat
|
|
40
|
+
|
|
41
|
+
hat = wear_hat(Hat(name="audit", role="Read-only audit"))
|
|
42
|
+
print(hat.to_dict())
|
|
43
|
+
|
|
44
|
+
session = AgentHatSession()
|
|
45
|
+
session.wear("audit")
|
|
46
|
+
session.drop()
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## CLI
|
|
50
|
+
|
|
51
|
+
```bash
|
|
52
|
+
agenthat --version
|
|
53
|
+
agenthat wear audit --role "Read-only code check"
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Homepage: [agenthat.dev](https://agenthat.dev) · GitHub: [github.com/agenthat/agenthat](https://github.com/agenthat/agenthat) · MIT License
|
agenthat-0.0.1/README.md
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# AgentHat
|
|
2
|
+
|
|
3
|
+
**Put a hat on your AI agent.**
|
|
4
|
+
|
|
5
|
+
We're not another AI agent — we're the hats your agents wear. Swap an agent's role and permissions (`fs`, `net`, `exec`) cleanly across tasks without giving every agent root.
|
|
6
|
+
|
|
7
|
+
## Install
|
|
8
|
+
|
|
9
|
+
```bash
|
|
10
|
+
pip install agenthat
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
## Python Usage
|
|
14
|
+
|
|
15
|
+
```python
|
|
16
|
+
from agenthat import AgentHatSession, Hat, wear_hat
|
|
17
|
+
|
|
18
|
+
hat = wear_hat(Hat(name="audit", role="Read-only audit"))
|
|
19
|
+
print(hat.to_dict())
|
|
20
|
+
|
|
21
|
+
session = AgentHatSession()
|
|
22
|
+
session.wear("audit")
|
|
23
|
+
session.drop()
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## CLI
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
agenthat --version
|
|
30
|
+
agenthat wear audit --role "Read-only code check"
|
|
31
|
+
```
|
|
32
|
+
|
|
33
|
+
Homepage: [agenthat.dev](https://agenthat.dev) · GitHub: [github.com/agenthat/agenthat](https://github.com/agenthat/agenthat) · MIT License
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling>=1.33.0"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "agenthat"
|
|
7
|
+
version = "0.0.1"
|
|
8
|
+
description = "AgentHat — Put a hat on your AI agent. Role permissions, tools, and sandbox limits for any AI agent."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.10"
|
|
11
|
+
license = { text = "MIT" }
|
|
12
|
+
authors = [{ name = "AgentHat", email = "hello@agenthat.dev" }]
|
|
13
|
+
keywords = [
|
|
14
|
+
"agenthat",
|
|
15
|
+
"ai-agents",
|
|
16
|
+
"agents",
|
|
17
|
+
"agent-permissions",
|
|
18
|
+
"agent-sandbox",
|
|
19
|
+
"roles",
|
|
20
|
+
"cli",
|
|
21
|
+
"python",
|
|
22
|
+
]
|
|
23
|
+
classifiers = [
|
|
24
|
+
"Development Status :: 3 - Alpha",
|
|
25
|
+
"Intended Audience :: Developers",
|
|
26
|
+
"License :: OSI Approved :: MIT License",
|
|
27
|
+
"Programming Language :: Python :: 3",
|
|
28
|
+
"Programming Language :: Python :: 3.10",
|
|
29
|
+
"Programming Language :: Python :: 3.11",
|
|
30
|
+
"Programming Language :: Python :: 3.12",
|
|
31
|
+
"Programming Language :: Python :: 3.13",
|
|
32
|
+
"Programming Language :: Python :: 3.14",
|
|
33
|
+
"Programming Language :: Python :: 3.15",
|
|
34
|
+
]
|
|
35
|
+
dependencies = []
|
|
36
|
+
|
|
37
|
+
[project.urls]
|
|
38
|
+
Homepage = "https://agenthat.dev"
|
|
39
|
+
Repository = "https://github.com/agenthat/agenthat"
|
|
40
|
+
Issues = "https://github.com/agenthat/agenthat/issues"
|
|
41
|
+
|
|
42
|
+
[project.scripts]
|
|
43
|
+
agenthat = "agenthat.cli:main"
|
|
44
|
+
|
|
45
|
+
[tool.hatch.build.targets.wheel]
|
|
46
|
+
packages = ["src/agenthat"]
|
|
47
|
+
|
|
48
|
+
[tool.hatch.build.targets.sdist]
|
|
49
|
+
include = ["src/", "README.md", "pyproject.toml"]
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
"""AgentHat — Put a hat on your AI agent."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from dataclasses import dataclass, field
|
|
6
|
+
from typing import Any, Literal
|
|
7
|
+
|
|
8
|
+
__version__ = "0.0.1"
|
|
9
|
+
|
|
10
|
+
FsPermission = Literal["none", "read-only", "scoped-write"]
|
|
11
|
+
NetPermission = Literal["offline", "allowlist", "open"]
|
|
12
|
+
ExecPermission = Literal["blocked", "allowlist"]
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@dataclass(frozen=True)
|
|
16
|
+
class HatPermissions:
|
|
17
|
+
"""Permission limits attached to an agent hat."""
|
|
18
|
+
|
|
19
|
+
fs: FsPermission = "read-only"
|
|
20
|
+
net: NetPermission = "offline"
|
|
21
|
+
exec: ExecPermission = "blocked"
|
|
22
|
+
|
|
23
|
+
def to_dict(self) -> dict[str, str]:
|
|
24
|
+
"""Serialize permissions to a plain dictionary."""
|
|
25
|
+
return {"fs": self.fs, "net": self.net, "exec": self.exec}
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
@dataclass(frozen=True)
|
|
29
|
+
class Hat:
|
|
30
|
+
"""Immutable hat configuration with normalized defaults."""
|
|
31
|
+
|
|
32
|
+
name: str
|
|
33
|
+
role: str = ""
|
|
34
|
+
permissions: HatPermissions = field(default_factory=HatPermissions)
|
|
35
|
+
|
|
36
|
+
def __post_init__(self) -> None:
|
|
37
|
+
cleaned = self.name.strip()
|
|
38
|
+
if not cleaned:
|
|
39
|
+
raise ValueError("Hat name is required")
|
|
40
|
+
object.__setattr__(self, "name", cleaned)
|
|
41
|
+
object.__setattr__(self, "role", self.role.strip())
|
|
42
|
+
|
|
43
|
+
def to_dict(self) -> dict[str, Any]:
|
|
44
|
+
"""Serialize the hat specification to a JSON-compatible dictionary."""
|
|
45
|
+
return {
|
|
46
|
+
"name": self.name,
|
|
47
|
+
"role": self.role,
|
|
48
|
+
"permissions": self.permissions.to_dict(),
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
class AgentHatSession:
|
|
53
|
+
"""Tracks and switches the active hat worn by an AI agent."""
|
|
54
|
+
|
|
55
|
+
def __init__(self) -> None:
|
|
56
|
+
self._active: Hat | None = None
|
|
57
|
+
|
|
58
|
+
def wear(self, hat: Hat | str, role: str = "") -> Hat:
|
|
59
|
+
"""Put a hat on the session."""
|
|
60
|
+
resolved = hat if isinstance(hat, Hat) else Hat(name=hat, role=role)
|
|
61
|
+
self._active = resolved
|
|
62
|
+
return resolved
|
|
63
|
+
|
|
64
|
+
def switch(self, hat: Hat | str, role: str = "") -> Hat:
|
|
65
|
+
"""Replace the active hat with a new hat."""
|
|
66
|
+
return self.wear(hat, role=role)
|
|
67
|
+
|
|
68
|
+
def drop(self) -> None:
|
|
69
|
+
"""Remove the active hat."""
|
|
70
|
+
self._active = None
|
|
71
|
+
|
|
72
|
+
def current(self) -> Hat | None:
|
|
73
|
+
"""Return the active hat or None if dropped."""
|
|
74
|
+
return self._active
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def wear_hat(hat: Hat | str, role: str = "") -> Hat:
|
|
78
|
+
"""Equip a hat and return the resolved Hat instance."""
|
|
79
|
+
return AgentHatSession().wear(hat, role=role)
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
__all__ = [
|
|
83
|
+
"__version__",
|
|
84
|
+
"FsPermission",
|
|
85
|
+
"NetPermission",
|
|
86
|
+
"ExecPermission",
|
|
87
|
+
"HatPermissions",
|
|
88
|
+
"Hat",
|
|
89
|
+
"AgentHatSession",
|
|
90
|
+
"wear_hat",
|
|
91
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
"""Minimal CLI for AgentHat."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import argparse
|
|
6
|
+
import json
|
|
7
|
+
import sys
|
|
8
|
+
from typing import Sequence
|
|
9
|
+
|
|
10
|
+
from . import __version__, wear_hat
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
14
|
+
"""Run the agenthat CLI entrypoint."""
|
|
15
|
+
parser = argparse.ArgumentParser(
|
|
16
|
+
prog="agenthat",
|
|
17
|
+
description=f"AgentHat v{__version__} — Put a hat on your AI agent",
|
|
18
|
+
)
|
|
19
|
+
parser.add_argument(
|
|
20
|
+
"-v",
|
|
21
|
+
"--version",
|
|
22
|
+
action="version",
|
|
23
|
+
version=__version__,
|
|
24
|
+
)
|
|
25
|
+
sub = parser.add_subparsers(dest="command")
|
|
26
|
+
|
|
27
|
+
wear_parser = sub.add_parser("wear", help="Put a hat on your AI agent")
|
|
28
|
+
wear_parser.add_argument("hat", help="Name of the hat to wear")
|
|
29
|
+
wear_parser.add_argument("--role", default="", help="Optional role summary")
|
|
30
|
+
wear_parser.add_argument("--json", action="store_true", help="Output JSON")
|
|
31
|
+
|
|
32
|
+
args = parser.parse_args(argv)
|
|
33
|
+
if args.command == "wear":
|
|
34
|
+
hat = wear_hat(args.hat, role=args.role)
|
|
35
|
+
if args.json:
|
|
36
|
+
print(json.dumps(hat.to_dict(), indent=2))
|
|
37
|
+
else:
|
|
38
|
+
print(f"Wearing hat: {hat.name}")
|
|
39
|
+
if hat.role:
|
|
40
|
+
print(f"Role: {hat.role}")
|
|
41
|
+
p = hat.permissions
|
|
42
|
+
print(f"Limits: fs={p.fs} net={p.net} exec={p.exec}")
|
|
43
|
+
return 0
|
|
44
|
+
|
|
45
|
+
parser.print_help()
|
|
46
|
+
return 0
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
if __name__ == "__main__":
|
|
50
|
+
raise SystemExit(main(sys.argv[1:]))
|