agenthat 0.0.1__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.
agenthat/__init__.py ADDED
@@ -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
+ ]
agenthat/cli.py ADDED
@@ -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:]))
@@ -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
@@ -0,0 +1,6 @@
1
+ agenthat/__init__.py,sha256=cowWuvjbCG295vKzJ5e9zzX6fmaaP2_O_oKQg27BDRQ,2561
2
+ agenthat/cli.py,sha256=4Foi-eVqHtZwWXWugOJuwwa7HS8kHPGFQmz3o9SPkCw,1437
3
+ agenthat-0.0.1.dist-info/METADATA,sha256=dzORIKBDsmZ0z7QanwUiFjenpF23GJdS41dd74sjQfw,1766
4
+ agenthat-0.0.1.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
5
+ agenthat-0.0.1.dist-info/entry_points.txt,sha256=FfTtGiyF4-qihHZ2YHkvYZx7rqu45hb77HmlEBj-RQY,47
6
+ agenthat-0.0.1.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.33.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agenthat = agenthat.cli:main