agentr 0.1.3__tar.gz → 0.1.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.
- {agentr-0.1.3 → agentr-0.1.4}/.gitignore +14 -14
- {agentr-0.1.3 → agentr-0.1.4}/.python-version +1 -1
- agentr-0.1.4/PKG-INFO +156 -0
- agentr-0.1.4/README.md +144 -0
- {agentr-0.1.3 → agentr-0.1.4}/pyproject.toml +23 -23
- agentr-0.1.4/src/agentr/__init__.py +2 -0
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/application.py +56 -56
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/applications/github/app.py +55 -51
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/applications/google_calendar/app.py +73 -73
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/applications/google_mail/app.py +67 -67
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/applications/reddit/app.py +29 -29
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/applications/resend/app.py +43 -43
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/applications/tavily/app.py +57 -57
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/applications/zenquotes/app.py +20 -20
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/cli.py +75 -58
- agentr-0.1.4/src/agentr/exceptions.py +5 -0
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/integration.py +98 -91
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/server.py +105 -105
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/store.py +70 -70
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/test.py +37 -37
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/utils/openapi.py +184 -184
- {agentr-0.1.3 → agentr-0.1.4}/uv.lock +7 -7
- agentr-0.1.3/PKG-INFO +0 -10
- agentr-0.1.3/README.md +0 -0
- agentr-0.1.3/src/agentr/__init__.py +0 -2
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/py.typed +0 -0
- {agentr-0.1.3 → agentr-0.1.4}/src/agentr/utils/bridge.py +0 -0
@@ -1,14 +1,14 @@
|
|
1
|
-
# Python-generated files
|
2
|
-
__pycache__/
|
3
|
-
*.py[oc]
|
4
|
-
build/
|
5
|
-
dist/
|
6
|
-
wheels/
|
7
|
-
*.egg-info
|
8
|
-
|
9
|
-
# Virtual environments
|
10
|
-
.venv
|
11
|
-
|
12
|
-
# Environment variables
|
13
|
-
.env
|
14
|
-
.env.local
|
1
|
+
# Python-generated files
|
2
|
+
__pycache__/
|
3
|
+
*.py[oc]
|
4
|
+
build/
|
5
|
+
dist/
|
6
|
+
wheels/
|
7
|
+
*.egg-info
|
8
|
+
|
9
|
+
# Virtual environments
|
10
|
+
.venv
|
11
|
+
|
12
|
+
# Environment variables
|
13
|
+
.env
|
14
|
+
.env.local
|
@@ -1 +1 @@
|
|
1
|
-
3.13
|
1
|
+
3.13
|
agentr-0.1.4/PKG-INFO
ADDED
@@ -0,0 +1,156 @@
|
|
1
|
+
Metadata-Version: 2.4
|
2
|
+
Name: agentr
|
3
|
+
Version: 0.1.4
|
4
|
+
Summary: Add your description here
|
5
|
+
Author-email: Manoj Bajaj <manojbajaj95@gmail.com>
|
6
|
+
Requires-Python: >=3.11
|
7
|
+
Requires-Dist: loguru>=0.7.3
|
8
|
+
Requires-Dist: mcp>=1.5.0
|
9
|
+
Requires-Dist: pyyaml>=6.0.2
|
10
|
+
Requires-Dist: typer>=0.15.2
|
11
|
+
Description-Content-Type: text/markdown
|
12
|
+
|
13
|
+
# AgentR
|
14
|
+
|
15
|
+
AgentR is a Python framework for building powerful agent applications with integrated third-party services. It provides a clean abstraction for incorporating various API services as "applications" into your agent workflow.
|
16
|
+
|
17
|
+
## 🌟 Features
|
18
|
+
|
19
|
+
- **Simplified API Integration**: Connect to services like GitHub, Google Calendar, Gmail, Reddit, Tavily, and more with minimal code
|
20
|
+
- **Authentication Handling**: Built-in support for API keys and OAuth-based authentication flows
|
21
|
+
- **Extensible Architecture**: Easily build and add new app integrations with minimal boilerplate
|
22
|
+
- **MCP (Model Context Protocol) Integration**: Seamlessly works with MCP server architecture
|
23
|
+
- **Credential Management**: Flexible storage options for API credentials with memory and environment-based implementations
|
24
|
+
|
25
|
+
## 🔧 Installation
|
26
|
+
|
27
|
+
Install AgentR using pip:
|
28
|
+
|
29
|
+
```bash
|
30
|
+
pip install agentr
|
31
|
+
```
|
32
|
+
|
33
|
+
## 🚀 Quick Start
|
34
|
+
|
35
|
+
### 1. Get an API Key
|
36
|
+
Before using AgentR with services that require authorization (like GitHub, Gmail, etc.), you'll need an AgentR API key:
|
37
|
+
|
38
|
+
Visit https://agentr.dev to create an account
|
39
|
+
Generate an API key from your dashboard
|
40
|
+
Set it as an environment variable or include it directly in your code:
|
41
|
+
|
42
|
+
```bash
|
43
|
+
export AGENTR_API_KEY="your_api_key_here"
|
44
|
+
```
|
45
|
+
|
46
|
+
### 2. Create a basic server
|
47
|
+
|
48
|
+
```bash
|
49
|
+
from agentr.server import TestServer
|
50
|
+
|
51
|
+
# Define your applications list
|
52
|
+
apps_list = [
|
53
|
+
{
|
54
|
+
"name": "tavily",
|
55
|
+
"integration": {
|
56
|
+
"name": "tavily_api_key",
|
57
|
+
"type": "api_key",
|
58
|
+
"store": {
|
59
|
+
"type": "environment",
|
60
|
+
}
|
61
|
+
},
|
62
|
+
},
|
63
|
+
{
|
64
|
+
"name": "zenquotes",
|
65
|
+
"integration": None
|
66
|
+
},
|
67
|
+
{
|
68
|
+
"name": "github",
|
69
|
+
"integration": {
|
70
|
+
"name": "github",
|
71
|
+
"type": "agentr",
|
72
|
+
}
|
73
|
+
}
|
74
|
+
]
|
75
|
+
|
76
|
+
# Create a server with these applications
|
77
|
+
server = TestServer(name="My Agent Server", description="A server for my agent apps", apps_list=apps_list)
|
78
|
+
|
79
|
+
# Run the server
|
80
|
+
if __name__ == "__main__":
|
81
|
+
server.run()
|
82
|
+
```
|
83
|
+
|
84
|
+
## 🧩 Available Applications
|
85
|
+
AgentR comes with several pre-built applications:
|
86
|
+
|
87
|
+
| Application | Description | Authentication Type |
|
88
|
+
|-------------|-------------|---------------------|
|
89
|
+
| GitHub | Star repositories and more | OAuth (AgentR) |
|
90
|
+
| Google Calendar | Retrieve calendar events | OAuth (AgentR) |
|
91
|
+
| Gmail | Send emails | OAuth (AgentR) |
|
92
|
+
| Reddit | Access Reddit data | OAuth (AgentR) |
|
93
|
+
| Resend | Send emails via Resend API | API Key |
|
94
|
+
| Tavily | Web search capabilities | API Key |
|
95
|
+
| ZenQuotes | Get inspirational quotes | None |
|
96
|
+
|
97
|
+
> **Note**: More applications are coming soon! Stay tuned for updates to our application catalog.
|
98
|
+
|
99
|
+
## 🔐 Integration Types
|
100
|
+
AgentR supports two primary integration types:
|
101
|
+
|
102
|
+
### 1. API Key Integration
|
103
|
+
For services that authenticate via API keys:
|
104
|
+
```python
|
105
|
+
{
|
106
|
+
"name": "service_name",
|
107
|
+
"integration": {
|
108
|
+
"name": "service_api_key",
|
109
|
+
"type": "api_key",
|
110
|
+
"store": {
|
111
|
+
"type": "environment", # or "memory"
|
112
|
+
}
|
113
|
+
}
|
114
|
+
}
|
115
|
+
```
|
116
|
+
|
117
|
+
### 2. OAuth Integration (via AgentR)
|
118
|
+
For services requiring OAuth flow:
|
119
|
+
```python
|
120
|
+
{
|
121
|
+
"name": "service_name",
|
122
|
+
"integration": {
|
123
|
+
"name": "service_name",
|
124
|
+
"type": "agentr"
|
125
|
+
}
|
126
|
+
}
|
127
|
+
```
|
128
|
+
When using OAuth integrations, users will be directed to authenticate with the service provider through a secure flow managed by AgentR.
|
129
|
+
|
130
|
+
## 🤖 CLI Usage
|
131
|
+
AgentR includes a command-line interface for common operations:
|
132
|
+
|
133
|
+
```bash
|
134
|
+
# Get version information
|
135
|
+
agentr version
|
136
|
+
|
137
|
+
# Generate API client from OpenAPI schema
|
138
|
+
agentr generate --schema path/to/openapi.yaml
|
139
|
+
|
140
|
+
# Run the test server
|
141
|
+
agentr run
|
142
|
+
|
143
|
+
# Install AgentR for specific applications
|
144
|
+
agentr install claude
|
145
|
+
```
|
146
|
+
|
147
|
+
## 📋 Requirements
|
148
|
+
|
149
|
+
- Python 3.11+
|
150
|
+
- Dependencies (automatically installed):
|
151
|
+
- loguru >= 0.7.3
|
152
|
+
- mcp >= 1.5.0
|
153
|
+
- pyyaml >= 6.0.2
|
154
|
+
- typer >= 0.15.2
|
155
|
+
|
156
|
+
|
agentr-0.1.4/README.md
ADDED
@@ -0,0 +1,144 @@
|
|
1
|
+
# AgentR
|
2
|
+
|
3
|
+
AgentR is a Python framework for building powerful agent applications with integrated third-party services. It provides a clean abstraction for incorporating various API services as "applications" into your agent workflow.
|
4
|
+
|
5
|
+
## 🌟 Features
|
6
|
+
|
7
|
+
- **Simplified API Integration**: Connect to services like GitHub, Google Calendar, Gmail, Reddit, Tavily, and more with minimal code
|
8
|
+
- **Authentication Handling**: Built-in support for API keys and OAuth-based authentication flows
|
9
|
+
- **Extensible Architecture**: Easily build and add new app integrations with minimal boilerplate
|
10
|
+
- **MCP (Model Context Protocol) Integration**: Seamlessly works with MCP server architecture
|
11
|
+
- **Credential Management**: Flexible storage options for API credentials with memory and environment-based implementations
|
12
|
+
|
13
|
+
## 🔧 Installation
|
14
|
+
|
15
|
+
Install AgentR using pip:
|
16
|
+
|
17
|
+
```bash
|
18
|
+
pip install agentr
|
19
|
+
```
|
20
|
+
|
21
|
+
## 🚀 Quick Start
|
22
|
+
|
23
|
+
### 1. Get an API Key
|
24
|
+
Before using AgentR with services that require authorization (like GitHub, Gmail, etc.), you'll need an AgentR API key:
|
25
|
+
|
26
|
+
Visit https://agentr.dev to create an account
|
27
|
+
Generate an API key from your dashboard
|
28
|
+
Set it as an environment variable or include it directly in your code:
|
29
|
+
|
30
|
+
```bash
|
31
|
+
export AGENTR_API_KEY="your_api_key_here"
|
32
|
+
```
|
33
|
+
|
34
|
+
### 2. Create a basic server
|
35
|
+
|
36
|
+
```bash
|
37
|
+
from agentr.server import TestServer
|
38
|
+
|
39
|
+
# Define your applications list
|
40
|
+
apps_list = [
|
41
|
+
{
|
42
|
+
"name": "tavily",
|
43
|
+
"integration": {
|
44
|
+
"name": "tavily_api_key",
|
45
|
+
"type": "api_key",
|
46
|
+
"store": {
|
47
|
+
"type": "environment",
|
48
|
+
}
|
49
|
+
},
|
50
|
+
},
|
51
|
+
{
|
52
|
+
"name": "zenquotes",
|
53
|
+
"integration": None
|
54
|
+
},
|
55
|
+
{
|
56
|
+
"name": "github",
|
57
|
+
"integration": {
|
58
|
+
"name": "github",
|
59
|
+
"type": "agentr",
|
60
|
+
}
|
61
|
+
}
|
62
|
+
]
|
63
|
+
|
64
|
+
# Create a server with these applications
|
65
|
+
server = TestServer(name="My Agent Server", description="A server for my agent apps", apps_list=apps_list)
|
66
|
+
|
67
|
+
# Run the server
|
68
|
+
if __name__ == "__main__":
|
69
|
+
server.run()
|
70
|
+
```
|
71
|
+
|
72
|
+
## 🧩 Available Applications
|
73
|
+
AgentR comes with several pre-built applications:
|
74
|
+
|
75
|
+
| Application | Description | Authentication Type |
|
76
|
+
|-------------|-------------|---------------------|
|
77
|
+
| GitHub | Star repositories and more | OAuth (AgentR) |
|
78
|
+
| Google Calendar | Retrieve calendar events | OAuth (AgentR) |
|
79
|
+
| Gmail | Send emails | OAuth (AgentR) |
|
80
|
+
| Reddit | Access Reddit data | OAuth (AgentR) |
|
81
|
+
| Resend | Send emails via Resend API | API Key |
|
82
|
+
| Tavily | Web search capabilities | API Key |
|
83
|
+
| ZenQuotes | Get inspirational quotes | None |
|
84
|
+
|
85
|
+
> **Note**: More applications are coming soon! Stay tuned for updates to our application catalog.
|
86
|
+
|
87
|
+
## 🔐 Integration Types
|
88
|
+
AgentR supports two primary integration types:
|
89
|
+
|
90
|
+
### 1. API Key Integration
|
91
|
+
For services that authenticate via API keys:
|
92
|
+
```python
|
93
|
+
{
|
94
|
+
"name": "service_name",
|
95
|
+
"integration": {
|
96
|
+
"name": "service_api_key",
|
97
|
+
"type": "api_key",
|
98
|
+
"store": {
|
99
|
+
"type": "environment", # or "memory"
|
100
|
+
}
|
101
|
+
}
|
102
|
+
}
|
103
|
+
```
|
104
|
+
|
105
|
+
### 2. OAuth Integration (via AgentR)
|
106
|
+
For services requiring OAuth flow:
|
107
|
+
```python
|
108
|
+
{
|
109
|
+
"name": "service_name",
|
110
|
+
"integration": {
|
111
|
+
"name": "service_name",
|
112
|
+
"type": "agentr"
|
113
|
+
}
|
114
|
+
}
|
115
|
+
```
|
116
|
+
When using OAuth integrations, users will be directed to authenticate with the service provider through a secure flow managed by AgentR.
|
117
|
+
|
118
|
+
## 🤖 CLI Usage
|
119
|
+
AgentR includes a command-line interface for common operations:
|
120
|
+
|
121
|
+
```bash
|
122
|
+
# Get version information
|
123
|
+
agentr version
|
124
|
+
|
125
|
+
# Generate API client from OpenAPI schema
|
126
|
+
agentr generate --schema path/to/openapi.yaml
|
127
|
+
|
128
|
+
# Run the test server
|
129
|
+
agentr run
|
130
|
+
|
131
|
+
# Install AgentR for specific applications
|
132
|
+
agentr install claude
|
133
|
+
```
|
134
|
+
|
135
|
+
## 📋 Requirements
|
136
|
+
|
137
|
+
- Python 3.11+
|
138
|
+
- Dependencies (automatically installed):
|
139
|
+
- loguru >= 0.7.3
|
140
|
+
- mcp >= 1.5.0
|
141
|
+
- pyyaml >= 6.0.2
|
142
|
+
- typer >= 0.15.2
|
143
|
+
|
144
|
+
|
@@ -1,23 +1,23 @@
|
|
1
|
-
[project]
|
2
|
-
name = "agentr"
|
3
|
-
version = "0.1.
|
4
|
-
description = "Add your description here"
|
5
|
-
readme = "README.md"
|
6
|
-
authors = [
|
7
|
-
{ name = "Manoj Bajaj", email = "manojbajaj95@gmail.com" }
|
8
|
-
]
|
9
|
-
requires-python = ">=3.11"
|
10
|
-
dependencies = [
|
11
|
-
"loguru>=0.7.3",
|
12
|
-
"mcp>=1.5.0",
|
13
|
-
"pyyaml>=6.0.2",
|
14
|
-
"typer>=0.15.2",
|
15
|
-
]
|
16
|
-
|
17
|
-
[project.scripts]
|
18
|
-
agentr = "agentr.cli:app"
|
19
|
-
|
20
|
-
|
21
|
-
[build-system]
|
22
|
-
requires = ["hatchling"]
|
23
|
-
build-backend = "hatchling.build"
|
1
|
+
[project]
|
2
|
+
name = "agentr"
|
3
|
+
version = "0.1.4"
|
4
|
+
description = "Add your description here"
|
5
|
+
readme = "README.md"
|
6
|
+
authors = [
|
7
|
+
{ name = "Manoj Bajaj", email = "manojbajaj95@gmail.com" }
|
8
|
+
]
|
9
|
+
requires-python = ">=3.11"
|
10
|
+
dependencies = [
|
11
|
+
"loguru>=0.7.3",
|
12
|
+
"mcp>=1.5.0",
|
13
|
+
"pyyaml>=6.0.2",
|
14
|
+
"typer>=0.15.2",
|
15
|
+
]
|
16
|
+
|
17
|
+
[project.scripts]
|
18
|
+
agentr = "agentr.cli:app"
|
19
|
+
|
20
|
+
|
21
|
+
[build-system]
|
22
|
+
requires = ["hatchling"]
|
23
|
+
build-backend = "hatchling.build"
|
@@ -1,57 +1,57 @@
|
|
1
|
-
from abc import ABC, abstractmethod
|
2
|
-
from agentr.integration import Integration
|
3
|
-
import httpx
|
4
|
-
|
5
|
-
class Application(ABC):
|
6
|
-
"""
|
7
|
-
Application is collection of tools that can be used by an agent.
|
8
|
-
"""
|
9
|
-
def __init__(self, name: str, **kwargs):
|
10
|
-
self.name = name
|
11
|
-
|
12
|
-
@abstractmethod
|
13
|
-
def list_tools(self):
|
14
|
-
pass
|
15
|
-
|
16
|
-
|
17
|
-
class APIApplication(Application):
|
18
|
-
"""
|
19
|
-
APIApplication is an application that uses an API to interact with the world.
|
20
|
-
"""
|
21
|
-
def __init__(self, name: str, integration: Integration = None, **kwargs):
|
22
|
-
super().__init__(name, **kwargs)
|
23
|
-
self.integration = integration
|
24
|
-
|
25
|
-
def _get_headers(self):
|
26
|
-
return {}
|
27
|
-
|
28
|
-
def _get(self, url, params=None):
|
29
|
-
headers = self._get_headers()
|
30
|
-
response = httpx.get(url, headers=headers, params=params)
|
31
|
-
response.raise_for_status()
|
32
|
-
return response
|
33
|
-
|
34
|
-
def _post(self, url, data):
|
35
|
-
headers = self._get_headers()
|
36
|
-
response = httpx.post(url, headers=headers, json=data)
|
37
|
-
response.raise_for_status()
|
38
|
-
return response
|
39
|
-
|
40
|
-
def _put(self, url, data):
|
41
|
-
headers = self._get_headers()
|
42
|
-
response = httpx.put(url, headers=headers, json=data)
|
43
|
-
response.raise_for_status()
|
44
|
-
return response
|
45
|
-
|
46
|
-
def _delete(self, url):
|
47
|
-
headers = self._get_headers()
|
48
|
-
response = httpx.delete(url, headers=headers)
|
49
|
-
response.raise_for_status()
|
50
|
-
return response
|
51
|
-
|
52
|
-
def validate(self):
|
53
|
-
pass
|
54
|
-
|
55
|
-
@abstractmethod
|
56
|
-
def list_tools(self):
|
1
|
+
from abc import ABC, abstractmethod
|
2
|
+
from agentr.integration import Integration
|
3
|
+
import httpx
|
4
|
+
|
5
|
+
class Application(ABC):
|
6
|
+
"""
|
7
|
+
Application is collection of tools that can be used by an agent.
|
8
|
+
"""
|
9
|
+
def __init__(self, name: str, **kwargs):
|
10
|
+
self.name = name
|
11
|
+
|
12
|
+
@abstractmethod
|
13
|
+
def list_tools(self):
|
14
|
+
pass
|
15
|
+
|
16
|
+
|
17
|
+
class APIApplication(Application):
|
18
|
+
"""
|
19
|
+
APIApplication is an application that uses an API to interact with the world.
|
20
|
+
"""
|
21
|
+
def __init__(self, name: str, integration: Integration = None, **kwargs):
|
22
|
+
super().__init__(name, **kwargs)
|
23
|
+
self.integration = integration
|
24
|
+
|
25
|
+
def _get_headers(self):
|
26
|
+
return {}
|
27
|
+
|
28
|
+
def _get(self, url, params=None):
|
29
|
+
headers = self._get_headers()
|
30
|
+
response = httpx.get(url, headers=headers, params=params)
|
31
|
+
response.raise_for_status()
|
32
|
+
return response
|
33
|
+
|
34
|
+
def _post(self, url, data):
|
35
|
+
headers = self._get_headers()
|
36
|
+
response = httpx.post(url, headers=headers, json=data)
|
37
|
+
response.raise_for_status()
|
38
|
+
return response
|
39
|
+
|
40
|
+
def _put(self, url, data):
|
41
|
+
headers = self._get_headers()
|
42
|
+
response = httpx.put(url, headers=headers, json=data)
|
43
|
+
response.raise_for_status()
|
44
|
+
return response
|
45
|
+
|
46
|
+
def _delete(self, url):
|
47
|
+
headers = self._get_headers()
|
48
|
+
response = httpx.delete(url, headers=headers)
|
49
|
+
response.raise_for_status()
|
50
|
+
return response
|
51
|
+
|
52
|
+
def validate(self):
|
53
|
+
pass
|
54
|
+
|
55
|
+
@abstractmethod
|
56
|
+
def list_tools(self):
|
57
57
|
pass
|
@@ -1,52 +1,56 @@
|
|
1
|
-
from agentr.integration import Integration
|
2
|
-
from agentr.application import APIApplication
|
3
|
-
from loguru import logger
|
4
|
-
|
5
|
-
|
6
|
-
class GithubApp(APIApplication):
|
7
|
-
def __init__(self, integration: Integration) -> None:
|
8
|
-
super().__init__(name="github", integration=integration)
|
9
|
-
|
10
|
-
def _get_headers(self):
|
11
|
-
if not self.integration:
|
12
|
-
raise ValueError("Integration not configured")
|
13
|
-
credentials = self.integration.get_credentials()
|
14
|
-
if not credentials:
|
15
|
-
logger.warning("No credentials found")
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
"
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
return
|
49
|
-
|
50
|
-
|
51
|
-
|
1
|
+
from agentr.integration import Integration
|
2
|
+
from agentr.application import APIApplication
|
3
|
+
from loguru import logger
|
4
|
+
from agentr.exceptions import NotAuthorizedError
|
5
|
+
|
6
|
+
class GithubApp(APIApplication):
|
7
|
+
def __init__(self, integration: Integration) -> None:
|
8
|
+
super().__init__(name="github", integration=integration)
|
9
|
+
|
10
|
+
def _get_headers(self):
|
11
|
+
if not self.integration:
|
12
|
+
raise ValueError("Integration not configured")
|
13
|
+
credentials = self.integration.get_credentials()
|
14
|
+
if not credentials:
|
15
|
+
logger.warning("No credentials found")
|
16
|
+
action = self.integration.authorize()
|
17
|
+
raise NotAuthorizedError(action)
|
18
|
+
if "headers" in credentials:
|
19
|
+
return credentials["headers"]
|
20
|
+
return {
|
21
|
+
"Authorization": f"Bearer {credentials['access_token']}",
|
22
|
+
"Accept": "application/vnd.github.v3+json"
|
23
|
+
}
|
24
|
+
|
25
|
+
|
26
|
+
def star_repository(self, repo_full_name: str) -> str:
|
27
|
+
"""Star a GitHub repository
|
28
|
+
|
29
|
+
Args:
|
30
|
+
repo_full_name: The full name of the repository (e.g. 'owner/repo')
|
31
|
+
|
32
|
+
Returns:
|
33
|
+
|
34
|
+
A confirmation message
|
35
|
+
"""
|
36
|
+
try:
|
37
|
+
url = f"https://api.github.com/user/starred/{repo_full_name}"
|
38
|
+
response = self._put(url, data={})
|
39
|
+
|
40
|
+
if response.status_code == 204:
|
41
|
+
return f"Successfully starred repository {repo_full_name}"
|
42
|
+
elif response.status_code == 404:
|
43
|
+
return f"Repository {repo_full_name} not found"
|
44
|
+
else:
|
45
|
+
logger.error(response.text)
|
46
|
+
return f"Error starring repository: {response.text}"
|
47
|
+
except NotAuthorizedError as e:
|
48
|
+
return e.message
|
49
|
+
except Exception as e:
|
50
|
+
logger.error(e)
|
51
|
+
raise e
|
52
|
+
|
53
|
+
|
54
|
+
|
55
|
+
def list_tools(self):
|
52
56
|
return [self.star_repository]
|