agent-uplink 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.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Huw
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-uplink
3
+ Version: 0.0.1
4
+ Summary: Claude Sandbox
5
+ Author: Huw
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Huw
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/hoo29/agent-uplink
29
+ Requires-Python: >=3.9
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Provides-Extra: tests
33
+ Requires-Dist: pytest; extra == "tests"
34
+ Provides-Extra: build
35
+ Requires-Dist: build; extra == "build"
36
+ Dynamic: license-file
37
+
38
+ # agent-uplink
@@ -0,0 +1 @@
1
+ # agent-uplink
File without changes
@@ -0,0 +1,115 @@
1
+ import argparse
2
+ import logging
3
+ import signal
4
+ import json
5
+ import os
6
+ import uuid
7
+
8
+
9
+ from pathlib import Path
10
+
11
+ from .utils import SESSION_DIRS, create_aws_profile_file_contents, get_free_port, run_command, run_command_background, shutdown_handler
12
+
13
+
14
+ LOGGER = logging.getLogger("agent-uplink")
15
+
16
+
17
+ def get_bedrock_aws_profile_name() -> str:
18
+ with open(f"{Path.home()}/.claude/settings.json", "r", encoding="utf8") as f:
19
+ settings = json.loads(f.read())
20
+ name = settings.get("env", {}).get("AWS_PROFILE")
21
+ if not name:
22
+ raise RuntimeError("AWS_PROFILE not found in claude settings env")
23
+ return name
24
+
25
+
26
+ def _main(socket_dir, mitm_dir):
27
+ parser = argparse.ArgumentParser(
28
+ description="Trust is a weakness", formatter_class=argparse.ArgumentDefaultsHelpFormatter)
29
+ parser.add_argument("-a", "--aws-profiles", type=str, nargs="*",
30
+ action="extend", default=[],
31
+ help="AWS profiles to provide credentials for")
32
+ parser.add_argument("-m", "--mitmproxy-image", type=str,
33
+ default="mitmproxy/mitmproxy")
34
+ parser.add_argument("-c", "--claude-image", type=str,
35
+ default="why")
36
+ args = parser.parse_args()
37
+ logging.basicConfig(level=logging.DEBUG, format="%(message)s")
38
+ LOGGER.info("hi")
39
+
40
+ bedrock_aws_profile_name = get_bedrock_aws_profile_name()
41
+ aws_profile_names = args.aws_profiles
42
+ aws_profile_names.append(bedrock_aws_profile_name)
43
+ aws_profile_file_contents = create_aws_profile_file_contents(
44
+ aws_profile_names)
45
+
46
+ free_port = get_free_port()
47
+
48
+ socket_path = socket_dir / "uplink.sock"
49
+ run_command_background(
50
+ f"socat UNIX-LISTEN:{socket_path},fork,mode=666 TCP:127.0.0.1:{free_port}")
51
+
52
+ mitmproxy_image = args.mitmproxy_image
53
+ mitm_container_command = " ".join([
54
+ "docker run",
55
+ "--cap-add=DAC_OVERRIDE",
56
+ "--cap-add=SETGID",
57
+ "--cap-add=SETUID",
58
+ "--cap-drop=ALL",
59
+ "--cpus 1",
60
+ "--ipc private",
61
+ "--memory=0.5g",
62
+ "--pids-limit 100",
63
+ "--read-only",
64
+ "--rm",
65
+ "--security-opt no-new-privileges",
66
+ f"-v {mitm_dir}:/home/mitmproxy/.mitmproxy",
67
+ f"-p {free_port}:8080",
68
+ mitmproxy_image,
69
+ "mitmdump",
70
+ ])
71
+ run_command_background(mitm_container_command)
72
+
73
+ claude_image = args.claude_image
74
+ claude_container_command = " ".join([
75
+ "docker run",
76
+ "--cap-drop=ALL",
77
+ "--cpus 1",
78
+ "--ipc private",
79
+ "--memory=0.5g",
80
+ "--network none",
81
+ "--pids-limit 100",
82
+ "--read-only",
83
+ "--rm",
84
+ "--security-opt no-new-privileges",
85
+ "--tmpfs /tmp:rw,noexec,nosuid,size=200m",
86
+ "-it",
87
+ f"-v {socket_path}:/mounts/socket/uplink.sock",
88
+ f"-v {mitm_dir}:/mounts/certs:ro",
89
+ claude_image,
90
+ ])
91
+ run_command(claude_container_command, interactive=True)
92
+
93
+ idk = 1
94
+
95
+
96
+ def main():
97
+ script_dir = Path.home() / ".agent_uplink" / uuid.uuid4().hex
98
+ SESSION_DIRS.append(script_dir)
99
+ socket_dir = script_dir / "sockets"
100
+ mitm_dir = script_dir / "mitm"
101
+ for dir in [socket_dir, mitm_dir]:
102
+ os.makedirs(dir, exist_ok=True)
103
+
104
+ signal.signal(signal.SIGINT, shutdown_handler)
105
+ signal.signal(signal.SIGTERM, shutdown_handler)
106
+ try:
107
+ _main(socket_dir, mitm_dir)
108
+ except Exception:
109
+ LOGGER.fatal("oh no", exc_info=True)
110
+ finally:
111
+ shutdown_handler(None, None)
112
+
113
+
114
+ if __name__ == "__main__":
115
+ main()
@@ -0,0 +1,38 @@
1
+ Metadata-Version: 2.4
2
+ Name: agent-uplink
3
+ Version: 0.0.1
4
+ Summary: Claude Sandbox
5
+ Author: Huw
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Huw
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/hoo29/agent-uplink
29
+ Requires-Python: >=3.9
30
+ Description-Content-Type: text/markdown
31
+ License-File: LICENSE
32
+ Provides-Extra: tests
33
+ Requires-Dist: pytest; extra == "tests"
34
+ Provides-Extra: build
35
+ Requires-Dist: build; extra == "build"
36
+ Dynamic: license-file
37
+
38
+ # agent-uplink
@@ -0,0 +1,11 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ agent_uplink/__init__.py
5
+ agent_uplink/__main__.py
6
+ agent_uplink.egg-info/PKG-INFO
7
+ agent_uplink.egg-info/SOURCES.txt
8
+ agent_uplink.egg-info/dependency_links.txt
9
+ agent_uplink.egg-info/entry_points.txt
10
+ agent_uplink.egg-info/requires.txt
11
+ agent_uplink.egg-info/top_level.txt
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ agent-uplink = agent_uplink.__main__:main
@@ -0,0 +1,6 @@
1
+
2
+ [build]
3
+ build
4
+
5
+ [tests]
6
+ pytest
@@ -0,0 +1 @@
1
+ agent_uplink
@@ -0,0 +1,27 @@
1
+ [build-system]
2
+ requires = ["setuptools>=61.0.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "agent-uplink"
7
+ version = "0.0.1"
8
+ description = "Claude Sandbox"
9
+ readme = "README.md"
10
+ authors = [{ name = "Huw" }]
11
+ license = { file = "LICENSE" }
12
+
13
+ dependencies = []
14
+ requires-python = ">=3.9"
15
+
16
+ [project.urls]
17
+ Homepage = "https://github.com/hoo29/agent-uplink"
18
+
19
+ [project.scripts]
20
+ agent-uplink = "agent_uplink.__main__:main"
21
+
22
+ [project.optional-dependencies]
23
+ tests = ["pytest"]
24
+ build = ["build"]
25
+
26
+ [tool.setuptools]
27
+ packages = ["agent_uplink"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+