hyperpocket 0.2.1__py3-none-any.whl → 0.3.0__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.
- hyperpocket/auth/reddit/oauth2_handler.py +1 -1
- hyperpocket/auth/slack/oauth2_handler.py +1 -1
- hyperpocket/cli/__main__.py +4 -2
- hyperpocket/cli/auth_oauth2.py +90 -0
- hyperpocket/cli/{auth.py → auth_token.py} +32 -25
- hyperpocket/cli/codegen/auth/__init__.py +8 -1
- hyperpocket/cli/codegen/auth/auth_oauth2_context_template.py +38 -0
- hyperpocket/cli/codegen/auth/auth_oauth2_handler_template.py +158 -0
- hyperpocket/cli/codegen/auth/auth_oauth2_schema_template.py +20 -0
- hyperpocket/cli/codegen/auth/server_auth_template.py +34 -3
- hyperpocket/pocket_core.py +58 -32
- hyperpocket/pocket_main.py +1 -1
- hyperpocket-0.3.0.dist-info/METADATA +377 -0
- {hyperpocket-0.2.1.dist-info → hyperpocket-0.3.0.dist-info}/RECORD +16 -12
- hyperpocket-0.2.1.dist-info/METADATA +0 -326
- {hyperpocket-0.2.1.dist-info → hyperpocket-0.3.0.dist-info}/WHEEL +0 -0
- {hyperpocket-0.2.1.dist-info → hyperpocket-0.3.0.dist-info}/entry_points.txt +0 -0
@@ -1,326 +0,0 @@
|
|
1
|
-
Metadata-Version: 2.4
|
2
|
-
Name: hyperpocket
|
3
|
-
Version: 0.2.1
|
4
|
-
Summary: Building AI agent with hyperpocket tool in a flash
|
5
|
-
Project-URL: Homepage, https://vessl-ai.github.io/hyperpocket
|
6
|
-
Project-URL: Repository, https://github.com/vessl-ai/hyperpocket
|
7
|
-
Author-email: Hyperpocket Team <hyperpocket@vessl.ai>
|
8
|
-
Requires-Python: >=3.10
|
9
|
-
Requires-Dist: click>=8.1.7
|
10
|
-
Requires-Dist: dynaconf>=3.2.6
|
11
|
-
Requires-Dist: fastapi>=0.115.5
|
12
|
-
Requires-Dist: gitpython>=3.1.43
|
13
|
-
Requires-Dist: httpx==0.27
|
14
|
-
Requires-Dist: jinja2>=3.1.4
|
15
|
-
Requires-Dist: multiprocess>=0.70.17
|
16
|
-
Requires-Dist: playwright>=1.49.0
|
17
|
-
Requires-Dist: pydantic>=2.10.2
|
18
|
-
Requires-Dist: pygithub>=2.5.0
|
19
|
-
Requires-Dist: python-multipart>=0.0.19
|
20
|
-
Requires-Dist: redis>=5.2.1
|
21
|
-
Requires-Dist: requests>=2.32.3
|
22
|
-
Requires-Dist: toml>=0.10.2
|
23
|
-
Requires-Dist: uvicorn>=0.32.1
|
24
|
-
Description-Content-Type: text/markdown
|
25
|
-
|
26
|
-
<p align="center">
|
27
|
-
<img src="../../logo.png" alt="hyperpocket" width="570"/>
|
28
|
-
</p>
|
29
|
-
|
30
|
-
# Hyperpocket 👛
|
31
|
-
|
32
|
-
Hyperpocket is where tools belong. Power your agent up with a pocket of tools. 👛
|
33
|
-
|
34
|
-
|
35
|
-
## Introduction
|
36
|
-
|
37
|
-
Hyperpocket is a tool that allows you to easily use tool and auth for agents on your machine.
|
38
|
-
|
39
|
-
**_Start fast._** Just install Hyperpocket and use it. We know you don't have time to authenticate to our server.
|
40
|
-
|
41
|
-
**_Go securely._** Not like others, you are the only one who knows your secret tokens. We do NOT. All of your secret
|
42
|
-
tokens belong to your infrastructure, not ours.
|
43
|
-
|
44
|
-
**_Power up with public tools._** Without worries for tool integration, use others' tools just with copy-and-paste the
|
45
|
-
link to the tool. Your tool will run on isolated environment based on WebAssembly technology, and you don't have to deal
|
46
|
-
with the dependency spaghetti.
|
47
|
-
|
48
|
-
**_Battery Included_** You can use popular tools and authentication providers out-of-the-box.
|
49
|
-
|
50
|
-
## Installation
|
51
|
-
|
52
|
-
1. install hyperpocket
|
53
|
-
|
54
|
-
```bash
|
55
|
-
pip install hyperpocket
|
56
|
-
```
|
57
|
-
|
58
|
-
2. install playwright
|
59
|
-
|
60
|
-
```bash
|
61
|
-
playwright install
|
62
|
-
```
|
63
|
-
|
64
|
-
## Usage
|
65
|
-
|
66
|
-
Supported agent frameworks
|
67
|
-
|
68
|
-
- [x] Langgraph [link](https://www.langchain.com/langgraph)
|
69
|
-
- [x] Langchain [link](https://www.langchain.com/)
|
70
|
-
- [x] Llamaindex [link](https://www.llamaindex.ai/)
|
71
|
-
|
72
|
-
Or just use LLM API Clients out of the box.
|
73
|
-
|
74
|
-
- [x] OpenAI [link](https://openai.com/)
|
75
|
-
- [x] Anthropic [link](https://www.anthropic.com/)
|
76
|
-
|
77
|
-
### Using out-of-the-box tools
|
78
|
-
|
79
|
-
```python
|
80
|
-
|
81
|
-
from langchain_openai import ChatOpenAI
|
82
|
-
|
83
|
-
from hyperpocket_langchain import PocketLangchain
|
84
|
-
|
85
|
-
pklc = PocketLangchain(
|
86
|
-
tools=[
|
87
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
|
88
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
|
89
|
-
]
|
90
|
-
)
|
91
|
-
tools = pklc.get_tools()
|
92
|
-
|
93
|
-
llm = ChatOpenAI()
|
94
|
-
llm_tool_binding = llm.bind_tools(tools)
|
95
|
-
llm_tool_binding.invoke(...)
|
96
|
-
```
|
97
|
-
|
98
|
-
### Using out-of-the-box auth for various tools
|
99
|
-
|
100
|
-
There are two kinds of auth process, one is using system auth(developer api key) and the other is using end user auth.
|
101
|
-
|
102
|
-
Hyperpocket provides way to use end user auth easily.
|
103
|
-
(Of course, you can also just set your STRIPE_API_KEY when using Stripe API related tools)
|
104
|
-
|
105
|
-
- Supported methods
|
106
|
-
|
107
|
-
- [x] OAuth
|
108
|
-
- [x] Token
|
109
|
-
- [ ] Basic Auth (Username, Password)
|
110
|
-
|
111
|
-
- Supported OAuth Providers
|
112
|
-
- [x] Google
|
113
|
-
- [x] GitHub
|
114
|
-
- [x] Slack
|
115
|
-
- [x] Linear
|
116
|
-
- [ ] Facebook
|
117
|
-
- [ ] X (Previously Twitter)
|
118
|
-
- [ ] LinkedIn
|
119
|
-
- [ ] Discord
|
120
|
-
- [ ] Zoom
|
121
|
-
- [ ] Microsoft
|
122
|
-
- [ ] Spotify
|
123
|
-
- [ ] Twitch
|
124
|
-
|
125
|
-
You can manage your auths in request-wise level. (e.g. you can use different auths for different requests)
|
126
|
-
|
127
|
-
```python
|
128
|
-
|
129
|
-
from langchain_openai import ChatOpenAI
|
130
|
-
from langgraph.graph import StateGraph, START, MessagesState
|
131
|
-
from langgraph.prebuilt import tools_condition
|
132
|
-
|
133
|
-
from hyperpocket_langgraph import PocketLanggraph
|
134
|
-
|
135
|
-
pklg = PocketLanggraph(
|
136
|
-
tools=[
|
137
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
|
138
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
|
139
|
-
],
|
140
|
-
)
|
141
|
-
llm = ChatOpenAI()
|
142
|
-
|
143
|
-
# Langgraph
|
144
|
-
pk_tool_node = pklg.get_tool_node()
|
145
|
-
llm_tool_binding = llm.bind_tools(pklg.get_tools())
|
146
|
-
|
147
|
-
# ...
|
148
|
-
|
149
|
-
graph_builder = StateGraph(MessagesState)
|
150
|
-
|
151
|
-
graph_builder.add_node('llm', llm)
|
152
|
-
graph_builder.add_node('tools', pk_tool_node)
|
153
|
-
graph_builder.add_edge(START, llm)
|
154
|
-
graph_builder.add_conditional_edges("llm", tools_condition)
|
155
|
-
graph_builder.add_edge(pk_tool_node, llm)
|
156
|
-
|
157
|
-
# ...
|
158
|
-
|
159
|
-
graph_builder.compile()
|
160
|
-
|
161
|
-
```
|
162
|
-
|
163
|
-
```python
|
164
|
-
import os
|
165
|
-
|
166
|
-
from llama_index.core.agent import FunctionCallingAgent
|
167
|
-
from llama_index.llms.openai import OpenAI
|
168
|
-
|
169
|
-
from hyperpocket.config import secret
|
170
|
-
from hyperpocket_llamaindex import PocketLlamaindex
|
171
|
-
|
172
|
-
llm = OpenAI(api_key=os.getenv("OPENAI_API_KEY"))
|
173
|
-
pocket = PocketLlamaindex(
|
174
|
-
tools=[
|
175
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/get-message",
|
176
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/slack/post-message",
|
177
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/linear/get-issues",
|
178
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/google/get-calendar-events",
|
179
|
-
"https://github.com/vessl-ai/hyperpocket/tree/main/tools/google/get-calendar-list",
|
180
|
-
]
|
181
|
-
)
|
182
|
-
tools = pocket.get_tools()
|
183
|
-
|
184
|
-
agent = FunctionCallingAgent.from_tools(tools=tools, llm=llm)
|
185
|
-
```
|
186
|
-
|
187
|
-
### Specifying auth methods for tool type
|
188
|
-
|
189
|
-
Some resources support multiple auth methods. Your end user should be able to select between those methods.
|
190
|
-
|
191
|
-
```text
|
192
|
-
Human: List my slack messages in 'general' channel
|
193
|
-
|
194
|
-
Assistance: To access your slack messages, you need authentication. Slack api provides 1) bot token auth 2) OAuth auth. Which do you want to proceed?
|
195
|
-
|
196
|
-
Human: I'll go with OAuth
|
197
|
-
|
198
|
-
Assistance: You need chat:read, channel:history scopes to list messages. Do you confirm?
|
199
|
-
|
200
|
-
Human: OK.
|
201
|
-
|
202
|
-
Assistance: Please proceed to the following url and finish authentication. After that, let me know.
|
203
|
-
> https://slack.com/authorize?clientId=xxx&scope=chat:read,channel:history&redirect_url=xxx
|
204
|
-
|
205
|
-
Human: I'm done. (if necessary)
|
206
|
-
|
207
|
-
Assistance: I've checked you finished your auth. Let me search messages in slack channel 'general'.
|
208
|
-
|
209
|
-
Assistance: Here are the recent 10 messages.
|
210
|
-
(...)
|
211
|
-
|
212
|
-
|
213
|
-
```
|
214
|
-
|
215
|
-
### Config
|
216
|
-
|
217
|
-
The `settings.toml` looks as follows.
|
218
|
-
|
219
|
-
```toml
|
220
|
-
log_level = "debug"
|
221
|
-
internal_server_port = "8000" # optional, default is 8000
|
222
|
-
public_hostname = "localhost" # optional, default is localhost
|
223
|
-
public_server_protocol = "https" # optional, default is https
|
224
|
-
public_server_port = "8001" # optional, default is 8001
|
225
|
-
enable_local_callback_proxy = "true" # optional, default is true, can be turned off when running in production behind TLS termination
|
226
|
-
callback_url_rewrite_prefix = "proxy" # optional, default is proxy, auth callback url prefix
|
227
|
-
|
228
|
-
[session]
|
229
|
-
session_type = "redis" # optional, default is in-memory
|
230
|
-
[session.redis]
|
231
|
-
host = "localhost"
|
232
|
-
port = 6379
|
233
|
-
db = 0
|
234
|
-
|
235
|
-
[git]
|
236
|
-
[git.github]
|
237
|
-
github_token = "<Your github PAT>" # optional, your github personal access token
|
238
|
-
app_id = "<Your github app id>" # optional, your github app id
|
239
|
-
app_installation_id = "<Your github app installation id>" # optional, your github app installation id
|
240
|
-
app_private_key = "<Your github app private key>" # optional, your github app private key
|
241
|
-
|
242
|
-
[auth]
|
243
|
-
[auth.slack] # add your slack app's client id and secret for slack auth
|
244
|
-
client_id = "" # your slack client id
|
245
|
-
client_secret = "" # your slack client secret
|
246
|
-
|
247
|
-
[auth.github] # add your github app's client id and secret for github auth
|
248
|
-
client_id = "" # your github client id
|
249
|
-
client_secret = "" # your github client secret
|
250
|
-
```
|
251
|
-
|
252
|
-
#### How to integrate github OAuth app
|
253
|
-
|
254
|
-
1. Follow the github documentation to create a new OAuth
|
255
|
-
app. https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app
|
256
|
-
|
257
|
-
- While creating your github OAuth app, configuring your app's `Authorization callback URL` is different for your
|
258
|
-
development environment and production environment.
|
259
|
-
- For development environment, you can use `http://localhost:8000/auth/github/callback`
|
260
|
-
- **Note**: Default port for hyperpocket dev server is `8000`. If you are using a different port, make sure to
|
261
|
-
replace `8000` with your actual port number.
|
262
|
-
- For production environment, you can use `https://yourdomain.com/auth/github/callback`
|
263
|
-
- **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.
|
264
|
-
|
265
|
-
#### How to integrate SLACK OAuth app
|
266
|
-
|
267
|
-
1. Follow the slack documentation to create a new Oauth APP. https://api.slack.com/quickstart
|
268
|
-
|
269
|
-
2. Setting Redirect URLs, Scopes at OAuth & Permissions tap in slack APP page
|
270
|
-
|
271
|
-
- Redirect URLs :
|
272
|
-
`{public_server_protocol}://{public_hostname}:[{public_server_port}]/{callback_url_rewrite_prefix}/auth/slack/oauth2/callback`
|
273
|
-
- Scopes : What you want to request to user.
|
274
|
-
- Recommended scopes :
|
275
|
-
- channels:history,
|
276
|
-
- channels:read,
|
277
|
-
- chat:write,
|
278
|
-
- groups:history,
|
279
|
-
- groups:read,
|
280
|
-
- im:history,
|
281
|
-
- mpim:history,
|
282
|
-
- reactions:read,
|
283
|
-
- reactions:write,
|
284
|
-
|
285
|
-
3. Set your Slack APP Client ID / Client Secret in `$HOME/.pocket/settings.toml`
|
286
|
-
|
287
|
-
#### How to start adding a new token auth
|
288
|
-
|
289
|
-
1. Generate boilerplate codes for token-based auth services ?
|
290
|
-
|
291
|
-
```
|
292
|
-
# service_name should be lowercase including underscore
|
293
|
-
poetry run hyperpocket devtool create-token-auth-template {service_name}
|
294
|
-
```
|
295
|
-
|
296
|
-
It will generate boilerplate code lines for a new token-based auth service
|
297
|
-
|
298
|
-
2. Extend AuthProvider enum to add your new auth provider.
|
299
|
-
|
300
|
-
```python
|
301
|
-
class AuthProvider(Enum):
|
302
|
-
SERVICE = 'service'
|
303
|
-
```
|
304
|
-
|
305
|
-
3. Specify auth provider for tools
|
306
|
-
|
307
|
-
1) github repo or local
|
308
|
-
|
309
|
-
```toml
|
310
|
-
[auth]
|
311
|
-
auth_provider = "{service_name}"
|
312
|
-
auth_handler = "{service_name}-token"
|
313
|
-
scopes = []
|
314
|
-
```
|
315
|
-
|
316
|
-
2. function_tool
|
317
|
-
|
318
|
-
```python
|
319
|
-
@function_tool(
|
320
|
-
auth_provider=AuthProvider.SERVICE
|
321
|
-
)
|
322
|
-
def my_function(**kwargs):
|
323
|
-
```
|
324
|
-
|
325
|
-
## Special thanks
|
326
|
-
- [tott](https://x.com/tott____) for drawing the cute possum in a pocket.
|
File without changes
|
File without changes
|