hyperpocket 0.0.1__tar.gz

Sign up to get free protection for your applications and to get access to all the features.
Files changed (130) hide show
  1. hyperpocket-0.0.1/PKG-INFO +304 -0
  2. hyperpocket-0.0.1/README.md +274 -0
  3. hyperpocket-0.0.1/hyperpocket/__init__.py +7 -0
  4. hyperpocket-0.0.1/hyperpocket/auth/README.KR.md +309 -0
  5. hyperpocket-0.0.1/hyperpocket/auth/README.md +323 -0
  6. hyperpocket-0.0.1/hyperpocket/auth/__init__.py +24 -0
  7. hyperpocket-0.0.1/hyperpocket/auth/calendly/__init__.py +0 -0
  8. hyperpocket-0.0.1/hyperpocket/auth/calendly/context.py +13 -0
  9. hyperpocket-0.0.1/hyperpocket/auth/calendly/oauth2_context.py +25 -0
  10. hyperpocket-0.0.1/hyperpocket/auth/calendly/oauth2_handler.py +146 -0
  11. hyperpocket-0.0.1/hyperpocket/auth/calendly/oauth2_schema.py +16 -0
  12. hyperpocket-0.0.1/hyperpocket/auth/context.py +38 -0
  13. hyperpocket-0.0.1/hyperpocket/auth/github/__init__.py +0 -0
  14. hyperpocket-0.0.1/hyperpocket/auth/github/context.py +13 -0
  15. hyperpocket-0.0.1/hyperpocket/auth/github/oauth2_context.py +25 -0
  16. hyperpocket-0.0.1/hyperpocket/auth/github/oauth2_handler.py +143 -0
  17. hyperpocket-0.0.1/hyperpocket/auth/github/oauth2_schema.py +16 -0
  18. hyperpocket-0.0.1/hyperpocket/auth/github/token_context.py +12 -0
  19. hyperpocket-0.0.1/hyperpocket/auth/github/token_handler.py +79 -0
  20. hyperpocket-0.0.1/hyperpocket/auth/github/token_schema.py +9 -0
  21. hyperpocket-0.0.1/hyperpocket/auth/google/__init__.py +0 -0
  22. hyperpocket-0.0.1/hyperpocket/auth/google/context.py +15 -0
  23. hyperpocket-0.0.1/hyperpocket/auth/google/oauth2_context.py +31 -0
  24. hyperpocket-0.0.1/hyperpocket/auth/google/oauth2_handler.py +137 -0
  25. hyperpocket-0.0.1/hyperpocket/auth/google/oauth2_schema.py +18 -0
  26. hyperpocket-0.0.1/hyperpocket/auth/handler.py +171 -0
  27. hyperpocket-0.0.1/hyperpocket/auth/linear/__init__.py +0 -0
  28. hyperpocket-0.0.1/hyperpocket/auth/linear/context.py +15 -0
  29. hyperpocket-0.0.1/hyperpocket/auth/linear/token_context.py +15 -0
  30. hyperpocket-0.0.1/hyperpocket/auth/linear/token_handler.py +68 -0
  31. hyperpocket-0.0.1/hyperpocket/auth/linear/token_schema.py +9 -0
  32. hyperpocket-0.0.1/hyperpocket/auth/provider.py +16 -0
  33. hyperpocket-0.0.1/hyperpocket/auth/schema.py +19 -0
  34. hyperpocket-0.0.1/hyperpocket/auth/slack/__init__.py +0 -0
  35. hyperpocket-0.0.1/hyperpocket/auth/slack/context.py +15 -0
  36. hyperpocket-0.0.1/hyperpocket/auth/slack/oauth2_context.py +40 -0
  37. hyperpocket-0.0.1/hyperpocket/auth/slack/oauth2_handler.py +151 -0
  38. hyperpocket-0.0.1/hyperpocket/auth/slack/oauth2_schema.py +40 -0
  39. hyperpocket-0.0.1/hyperpocket/auth/slack/tests/__init__.py +0 -0
  40. hyperpocket-0.0.1/hyperpocket/auth/slack/tests/test_oauth2_handler.py +32 -0
  41. hyperpocket-0.0.1/hyperpocket/auth/slack/tests/test_token_handler.py +23 -0
  42. hyperpocket-0.0.1/hyperpocket/auth/slack/token_context.py +14 -0
  43. hyperpocket-0.0.1/hyperpocket/auth/slack/token_handler.py +64 -0
  44. hyperpocket-0.0.1/hyperpocket/auth/slack/token_schema.py +9 -0
  45. hyperpocket-0.0.1/hyperpocket/auth/tests/__init__.py +0 -0
  46. hyperpocket-0.0.1/hyperpocket/auth/tests/test_google_oauth2_handler.py +147 -0
  47. hyperpocket-0.0.1/hyperpocket/auth/tests/test_slack_oauth2_handler.py +147 -0
  48. hyperpocket-0.0.1/hyperpocket/auth/tests/test_slack_token_handler.py +66 -0
  49. hyperpocket-0.0.1/hyperpocket/cli/__init__.py +0 -0
  50. hyperpocket-0.0.1/hyperpocket/cli/__main__.py +12 -0
  51. hyperpocket-0.0.1/hyperpocket/cli/pull.py +18 -0
  52. hyperpocket-0.0.1/hyperpocket/cli/sync.py +17 -0
  53. hyperpocket-0.0.1/hyperpocket/config/__init__.py +9 -0
  54. hyperpocket-0.0.1/hyperpocket/config/auth.py +36 -0
  55. hyperpocket-0.0.1/hyperpocket/config/git.py +17 -0
  56. hyperpocket-0.0.1/hyperpocket/config/logger.py +81 -0
  57. hyperpocket-0.0.1/hyperpocket/config/session.py +35 -0
  58. hyperpocket-0.0.1/hyperpocket/config/settings.py +62 -0
  59. hyperpocket-0.0.1/hyperpocket/constants.py +0 -0
  60. hyperpocket-0.0.1/hyperpocket/curated_tools.py +10 -0
  61. hyperpocket-0.0.1/hyperpocket/external/__init__.py +7 -0
  62. hyperpocket-0.0.1/hyperpocket/external/github_client.py +19 -0
  63. hyperpocket-0.0.1/hyperpocket/futures/__init__.py +7 -0
  64. hyperpocket-0.0.1/hyperpocket/futures/futurestore.py +48 -0
  65. hyperpocket-0.0.1/hyperpocket/pocket_auth.py +344 -0
  66. hyperpocket-0.0.1/hyperpocket/pocket_main.py +351 -0
  67. hyperpocket-0.0.1/hyperpocket/prompts.py +15 -0
  68. hyperpocket-0.0.1/hyperpocket/repository/__init__.py +5 -0
  69. hyperpocket-0.0.1/hyperpocket/repository/lock.py +156 -0
  70. hyperpocket-0.0.1/hyperpocket/repository/lockfile.py +56 -0
  71. hyperpocket-0.0.1/hyperpocket/repository/repository.py +18 -0
  72. hyperpocket-0.0.1/hyperpocket/server/__init__.py +3 -0
  73. hyperpocket-0.0.1/hyperpocket/server/auth/__init__.py +15 -0
  74. hyperpocket-0.0.1/hyperpocket/server/auth/calendly.py +16 -0
  75. hyperpocket-0.0.1/hyperpocket/server/auth/github.py +25 -0
  76. hyperpocket-0.0.1/hyperpocket/server/auth/google.py +16 -0
  77. hyperpocket-0.0.1/hyperpocket/server/auth/linear.py +18 -0
  78. hyperpocket-0.0.1/hyperpocket/server/auth/slack.py +28 -0
  79. hyperpocket-0.0.1/hyperpocket/server/auth/token.py +51 -0
  80. hyperpocket-0.0.1/hyperpocket/server/proxy.py +63 -0
  81. hyperpocket-0.0.1/hyperpocket/server/server.py +178 -0
  82. hyperpocket-0.0.1/hyperpocket/server/tool/__init__.py +10 -0
  83. hyperpocket-0.0.1/hyperpocket/server/tool/dto/__init__.py +0 -0
  84. hyperpocket-0.0.1/hyperpocket/server/tool/dto/script.py +15 -0
  85. hyperpocket-0.0.1/hyperpocket/server/tool/wasm.py +31 -0
  86. hyperpocket-0.0.1/hyperpocket/session/README.KR.md +62 -0
  87. hyperpocket-0.0.1/hyperpocket/session/README.md +61 -0
  88. hyperpocket-0.0.1/hyperpocket/session/__init__.py +4 -0
  89. hyperpocket-0.0.1/hyperpocket/session/in_memory.py +76 -0
  90. hyperpocket-0.0.1/hyperpocket/session/interface.py +118 -0
  91. hyperpocket-0.0.1/hyperpocket/session/redis.py +126 -0
  92. hyperpocket-0.0.1/hyperpocket/session/tests/__init__.py +0 -0
  93. hyperpocket-0.0.1/hyperpocket/session/tests/test_in_memory.py +145 -0
  94. hyperpocket-0.0.1/hyperpocket/session/tests/test_redis.py +151 -0
  95. hyperpocket-0.0.1/hyperpocket/tests/__init__.py +0 -0
  96. hyperpocket-0.0.1/hyperpocket/tests/test_pocket.py +118 -0
  97. hyperpocket-0.0.1/hyperpocket/tests/test_pocket_auth.py +982 -0
  98. hyperpocket-0.0.1/hyperpocket/tool/README.KR.md +68 -0
  99. hyperpocket-0.0.1/hyperpocket/tool/README.md +75 -0
  100. hyperpocket-0.0.1/hyperpocket/tool/__init__.py +13 -0
  101. hyperpocket-0.0.1/hyperpocket/tool/builtins/__init__.py +0 -0
  102. hyperpocket-0.0.1/hyperpocket/tool/builtins/example/__init__.py +0 -0
  103. hyperpocket-0.0.1/hyperpocket/tool/builtins/example/add_tool.py +18 -0
  104. hyperpocket-0.0.1/hyperpocket/tool/function/README.KR.md +159 -0
  105. hyperpocket-0.0.1/hyperpocket/tool/function/README.md +169 -0
  106. hyperpocket-0.0.1/hyperpocket/tool/function/__init__.py +9 -0
  107. hyperpocket-0.0.1/hyperpocket/tool/function/annotation.py +30 -0
  108. hyperpocket-0.0.1/hyperpocket/tool/function/tool.py +87 -0
  109. hyperpocket-0.0.1/hyperpocket/tool/tests/__init__.py +0 -0
  110. hyperpocket-0.0.1/hyperpocket/tool/tests/test_function_tool.py +266 -0
  111. hyperpocket-0.0.1/hyperpocket/tool/tool.py +106 -0
  112. hyperpocket-0.0.1/hyperpocket/tool/wasm/README.KR.md +144 -0
  113. hyperpocket-0.0.1/hyperpocket/tool/wasm/README.md +144 -0
  114. hyperpocket-0.0.1/hyperpocket/tool/wasm/__init__.py +3 -0
  115. hyperpocket-0.0.1/hyperpocket/tool/wasm/browser.py +63 -0
  116. hyperpocket-0.0.1/hyperpocket/tool/wasm/invoker.py +41 -0
  117. hyperpocket-0.0.1/hyperpocket/tool/wasm/script.py +82 -0
  118. hyperpocket-0.0.1/hyperpocket/tool/wasm/templates/__init__.py +28 -0
  119. hyperpocket-0.0.1/hyperpocket/tool/wasm/templates/node.py +87 -0
  120. hyperpocket-0.0.1/hyperpocket/tool/wasm/templates/python.py +75 -0
  121. hyperpocket-0.0.1/hyperpocket/tool/wasm/tool.py +147 -0
  122. hyperpocket-0.0.1/hyperpocket/util/__init__.py +1 -0
  123. hyperpocket-0.0.1/hyperpocket/util/extract_func_param_desc_from_docstring.py +97 -0
  124. hyperpocket-0.0.1/hyperpocket/util/find_all_leaf_class_in_package.py +17 -0
  125. hyperpocket-0.0.1/hyperpocket/util/find_all_subclass_in_package.py +29 -0
  126. hyperpocket-0.0.1/hyperpocket/util/flatten_json_schema.py +45 -0
  127. hyperpocket-0.0.1/hyperpocket/util/function_to_model.py +46 -0
  128. hyperpocket-0.0.1/hyperpocket/util/get_objects_from_subpackage.py +28 -0
  129. hyperpocket-0.0.1/hyperpocket/util/json_schema_to_model.py +69 -0
  130. hyperpocket-0.0.1/pyproject.toml +40 -0
@@ -0,0 +1,304 @@
1
+ Metadata-Version: 2.1
2
+ Name: hyperpocket
3
+ Version: 0.0.1
4
+ Summary: Building AI agent with hyperpocket tool in a flash
5
+ Home-page: https://vessl-ai.github.io/hyperpocket
6
+ Author: VESSL AI Devs
7
+ Author-email: dev@vessl.ai
8
+ Requires-Python: >=3.11,<4.0
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Dist: click (>=8.1.7,<9.0.0)
14
+ Requires-Dist: dynaconf (>=3.2.6,<4.0.0)
15
+ Requires-Dist: fastapi (>=0.115.5,<0.116.0)
16
+ Requires-Dist: gitpython (>=3.1.43,<4.0.0)
17
+ Requires-Dist: httpx (>=0.28.0,<0.29.0)
18
+ Requires-Dist: jinja2 (>=3.1.4,<4.0.0)
19
+ Requires-Dist: multiprocess (>=0.70.17,<0.71.0)
20
+ Requires-Dist: playwright (>=1.49.0,<2.0.0)
21
+ Requires-Dist: pydantic (>=2.10.2,<3.0.0)
22
+ Requires-Dist: pygithub (>=2.5.0,<3.0.0)
23
+ Requires-Dist: python-multipart (>=0.0.19,<0.0.20)
24
+ Requires-Dist: redis (>=5.2.1,<6.0.0)
25
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
26
+ Requires-Dist: toml (>=0.10.2,<0.11.0)
27
+ Requires-Dist: uvicorn (>=0.32.1,<0.33.0)
28
+ Project-URL: Repository, https://github.com/vessl-ai/hyperpocket
29
+ Description-Content-Type: text/markdown
30
+
31
+ # Pocket 👛
32
+
33
+ Pocket is where tools belong. Power your agent up with a pocket of tools. 👛
34
+
35
+ <figure>
36
+ <img src="image.png" alt="4d-pocket" width="200"/>
37
+ <figcaption>© Doraemon</figcaption>
38
+ </figure>
39
+
40
+ ## Introduction
41
+
42
+ Pocket is a tool that allows you to easily use tool and auth for agents on your machine.
43
+
44
+ **_Start fast._** Just install Pocket and use it. We know you don't have time to authenticate to our server.
45
+
46
+ **_Go securely._** Not like others, you are the only one who knows your secret tokens. We do NOT. All of your secret
47
+ tokens belong to your infrastructure, not ours.
48
+
49
+ **_Power up with public tools._** Without worries for tool integration, use others' tools just with copy-and-paste the
50
+ link to the tool. Your tool will run on isolated environment based on WebAssembly technology, and you don't have to deal
51
+ with the dependency spaghetti.
52
+
53
+ **_Battery Included_** You can use popular tools and authentication providers out-of-the-box.
54
+
55
+ <figure>
56
+ <img src="pocket1.png" alt="pocket-flow" width="400"/>
57
+ <figcaption></figcaption>
58
+ </figure>
59
+
60
+ ## Installation
61
+
62
+ 1. install pocket
63
+
64
+ ```bash
65
+ pip install pocket
66
+ ```
67
+
68
+ 2. install playwright
69
+
70
+ ```bash
71
+ playwright install
72
+ ```
73
+
74
+ ## Usage
75
+
76
+ Supported agent frameworks
77
+
78
+ - [x] Langgraph [link](https://www.langchain.com/langgraph)
79
+ - [x] Langchain [link](https://www.langchain.com/)
80
+ - [x] Llamaindex [link](https://www.llamaindex.ai/)
81
+
82
+ Or just use LLM API Clients out of the box.
83
+
84
+ - [x] OpenAI [link](https://openai.com/)
85
+ - [x] Anthropic [link](https://www.anthropic.com/)
86
+
87
+ ### Using out-of-the-box tools
88
+
89
+ ```python
90
+ from langchain_openai import ChatOpenAI
91
+
92
+ import hyperpocket as pk
93
+ import hyperpocket.curated_tools
94
+ from pocket_langchain import PocketLangchain
95
+
96
+ pklc = PocketLangchain(
97
+ tools=[
98
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
99
+ *pk.curated_tools.LINEAR,
100
+ "https://github.com/my-org/some-awesome-tool",
101
+ ]
102
+ )
103
+ tools = pklc.get_tools()
104
+
105
+ llm = ChatOpenAI()
106
+ llm_tool_binding = llm.bind_tools(tools)
107
+ llm_tool_binding.invoke(...)
108
+ ```
109
+
110
+ ### Using out-of-the-box auth for various tools
111
+
112
+ There are two kinds of auth process, one is using system auth(developer api key) and the other is using end user auth.
113
+
114
+ Pocket provides way to use end user auth easily.
115
+ (Of course, you can also just set your STRIPE_API_KEY when using Stripe API related tools)
116
+
117
+ - Supported methods
118
+
119
+ - [x] OAuth
120
+ - [x] Token
121
+ - [ ] Basic Auth (Username, Password)
122
+
123
+ - Supported OAuth Providers
124
+ - [x] Google
125
+ - [x] GitHub
126
+ - [x] Slack
127
+ - [x] Linear
128
+ - [ ] Facebook
129
+ - [ ] X (Previously Twitter)
130
+ - [ ] LinkedIn
131
+ - [ ] Discord
132
+ - [ ] Zoom
133
+ - [ ] Microsoft
134
+ - [ ] Spotify
135
+ - [ ] Twitch
136
+
137
+ You can manage your auths in request-wise level. (e.g. you can use different auths for different requests)
138
+
139
+ ```python
140
+ from langchain_openai import ChatOpenAI
141
+ from langgraph.graph import StateGraph, START, MessagesState
142
+ from langgraph.prebuilt import tools_condition
143
+
144
+ import hyperpocket as pk
145
+ import hyperpocket.curated_tools
146
+ from pocket_langgraph import PocketLanggraph
147
+
148
+ pklg = PocketLanggraph(
149
+ tools=[
150
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
151
+ *pk.curated_tools.LINEAR,
152
+ "https://github.com/my-org/some-awesome-tool",
153
+ ],
154
+ )
155
+ llm = ChatOpenAI()
156
+
157
+ # Langgraph
158
+ pk_tool_node = pklg.get_tool_node()
159
+ llm_tool_binding = llm.bind_tools(pklg.get_tools())
160
+
161
+ # ...
162
+
163
+ graph_builder = StateGraph(MessagesState)
164
+
165
+ graph_builder.add_node('llm', llm)
166
+ graph_builder.add_node('tools', pk_tool_node)
167
+ graph_builder.add_edge(START, llm)
168
+ graph_builder.add_conditional_edges("llm", tools_condition)
169
+ graph_builder.add_edge(pk_tool_node, llm)
170
+
171
+ # ...
172
+
173
+ graph_builder.compile()
174
+
175
+ ```
176
+
177
+ ```python
178
+ from llama_index.core.agent import FunctionCallingAgent
179
+ from llama_index.llms.openai import OpenAI
180
+ from pocket_llamaindex import PocketLlamaindex
181
+
182
+ from hyperpocket.config import secret
183
+ from hyperpocket.tool import from_git
184
+
185
+ llm = OpenAI(api_key=secret["OPENAI_API_KEY"])
186
+ pocket = PocketLlamaindex(
187
+ tools=[
188
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/slack-get-message"),
189
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/slack-post-message"),
190
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/linear-get-issues"),
191
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/google-get-calendar-events"),
192
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/google-get-calendar-list"),
193
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/google-insert-calendar-events"),
194
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/github-pr-list"),
195
+ ]
196
+ )
197
+ tools = pocket.get_tools()
198
+
199
+ agent = FunctionCallingAgent.from_tools(tools=tools, llm=llm)
200
+ ```
201
+
202
+ ### Specifying auth methods for tool type
203
+
204
+ Some resources support multiple auth methods. Your end user should be able to select between those methods.
205
+
206
+ ```text
207
+ Human: List my slack messages in 'general' channel
208
+
209
+ 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?
210
+
211
+ Human: I'll go with OAuth
212
+
213
+ Assistance: You need chat:read, channel:history scopes to list messages. Do you confirm?
214
+
215
+ Human: OK.
216
+
217
+ Assistance: Please proceed to the following url and finish authentication. After that, let me know.
218
+ > https://slack.com/authorize?clientId=xxx&scope=chat:read,channel:history&redirect_url=xxx
219
+
220
+ Human: I'm done. (if necessary)
221
+
222
+ Assistance: I've checked you finished your auth. Let me search messages in slack channel 'general'.
223
+
224
+ Assistance: Here are the recent 10 messages.
225
+ (...)
226
+
227
+
228
+ ```
229
+
230
+ ### Config
231
+
232
+ Running `pocket config init` will create your config file in `$HOME/.pocket/settings.toml`
233
+
234
+ The `settings.toml` looks as follows.
235
+
236
+ TODO: Add `secrets.toml`.
237
+
238
+ ```toml
239
+ log_level = "debug"
240
+ internal_server_port = "8000" # optional, default is 8000
241
+ public_hostname = "localhost" # optional, default is localhost
242
+ public_server_protocol = "https" # optional, default is https
243
+ public_server_port = "8001" # optional, default is 8001
244
+ enable_local_callback_proxy = "true" # optional, default is true, can be turned off when running in production behind TLS termination
245
+ callback_url_rewrite_prefix = "proxy" # optional, default is proxy, auth callback url prefix
246
+
247
+ [session]
248
+ session_type = "redis" # optional, default is in-memory
249
+ [session.redis]
250
+ host = "localhost"
251
+ port = 6379
252
+ db = 0
253
+
254
+ [git]
255
+ [git.github]
256
+ github_token = "<Your github PAT>" # optional, your github personal access token
257
+ app_id = "<Your github app id>" # optional, your github app id
258
+ app_installation_id = "<Your github app installation id>" # optional, your github app installation id
259
+ app_private_key = "<Your github app private key>" # optional, your github app private key
260
+
261
+ [auth]
262
+ [auth.slack] # add your slack app's client id and secret for slack auth
263
+ client_id = "" # your slack client id
264
+ client_secret = "" # your slack client secret
265
+
266
+ [auth.github] # add your github app's client id and secret for github auth
267
+ client_id = "" # your github client id
268
+ client_secret = "" # your github client secret
269
+ ```
270
+
271
+ #### How to integrate github OAuth app
272
+
273
+ 1. Follow the github documentation to create a new OAuth
274
+ app. https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app
275
+
276
+ - While creating your github OAuth app, configuring your app's `Authorization callback URL` is different for your
277
+ development environment and production environment.
278
+ - For development environment, you can use `http://localhost:8000/auth/github/callback`
279
+ - **Note**: Default port for pocket dev server is `8000`. If you are using a different port, make sure to
280
+ replace `8000` with your actual port number.
281
+ - For production environment, you can use `https://yourdomain.com/auth/github/callback`
282
+ - **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.
283
+
284
+ #### How to integrate SLACK OAuth app
285
+
286
+ 1. Follow the slack documentation to create a new Oauth APP. https://api.slack.com/quickstart
287
+
288
+ 2. Setting Redirect URLs, Scopes at OAuth & Permissions tap in slack APP page
289
+
290
+ - Redirect URLs :
291
+ `{public_server_protocol}://{public_hostname}:[{public_server_port}]/{callback_url_rewrite_prefix}/auth/slack/oauth2/callback`
292
+ - Scopes : What you want to request to user.
293
+ - Recommended scopes :
294
+ - channels:history,
295
+ - channels:read,
296
+ - chat:write,
297
+ - groups:history,
298
+ - groups:read,
299
+ - im:history,
300
+ - mpim:history,
301
+ - reactions:read,
302
+ - reactions:write,
303
+
304
+ 3. Set your Slack APP Client ID / Client Secret in `$HOME/.pocket/settings.toml`
@@ -0,0 +1,274 @@
1
+ # Pocket 👛
2
+
3
+ Pocket is where tools belong. Power your agent up with a pocket of tools. 👛
4
+
5
+ <figure>
6
+ <img src="image.png" alt="4d-pocket" width="200"/>
7
+ <figcaption>© Doraemon</figcaption>
8
+ </figure>
9
+
10
+ ## Introduction
11
+
12
+ Pocket is a tool that allows you to easily use tool and auth for agents on your machine.
13
+
14
+ **_Start fast._** Just install Pocket and use it. We know you don't have time to authenticate to our server.
15
+
16
+ **_Go securely._** Not like others, you are the only one who knows your secret tokens. We do NOT. All of your secret
17
+ tokens belong to your infrastructure, not ours.
18
+
19
+ **_Power up with public tools._** Without worries for tool integration, use others' tools just with copy-and-paste the
20
+ link to the tool. Your tool will run on isolated environment based on WebAssembly technology, and you don't have to deal
21
+ with the dependency spaghetti.
22
+
23
+ **_Battery Included_** You can use popular tools and authentication providers out-of-the-box.
24
+
25
+ <figure>
26
+ <img src="pocket1.png" alt="pocket-flow" width="400"/>
27
+ <figcaption></figcaption>
28
+ </figure>
29
+
30
+ ## Installation
31
+
32
+ 1. install pocket
33
+
34
+ ```bash
35
+ pip install pocket
36
+ ```
37
+
38
+ 2. install playwright
39
+
40
+ ```bash
41
+ playwright install
42
+ ```
43
+
44
+ ## Usage
45
+
46
+ Supported agent frameworks
47
+
48
+ - [x] Langgraph [link](https://www.langchain.com/langgraph)
49
+ - [x] Langchain [link](https://www.langchain.com/)
50
+ - [x] Llamaindex [link](https://www.llamaindex.ai/)
51
+
52
+ Or just use LLM API Clients out of the box.
53
+
54
+ - [x] OpenAI [link](https://openai.com/)
55
+ - [x] Anthropic [link](https://www.anthropic.com/)
56
+
57
+ ### Using out-of-the-box tools
58
+
59
+ ```python
60
+ from langchain_openai import ChatOpenAI
61
+
62
+ import hyperpocket as pk
63
+ import hyperpocket.curated_tools
64
+ from pocket_langchain import PocketLangchain
65
+
66
+ pklc = PocketLangchain(
67
+ tools=[
68
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
69
+ *pk.curated_tools.LINEAR,
70
+ "https://github.com/my-org/some-awesome-tool",
71
+ ]
72
+ )
73
+ tools = pklc.get_tools()
74
+
75
+ llm = ChatOpenAI()
76
+ llm_tool_binding = llm.bind_tools(tools)
77
+ llm_tool_binding.invoke(...)
78
+ ```
79
+
80
+ ### Using out-of-the-box auth for various tools
81
+
82
+ There are two kinds of auth process, one is using system auth(developer api key) and the other is using end user auth.
83
+
84
+ Pocket provides way to use end user auth easily.
85
+ (Of course, you can also just set your STRIPE_API_KEY when using Stripe API related tools)
86
+
87
+ - Supported methods
88
+
89
+ - [x] OAuth
90
+ - [x] Token
91
+ - [ ] Basic Auth (Username, Password)
92
+
93
+ - Supported OAuth Providers
94
+ - [x] Google
95
+ - [x] GitHub
96
+ - [x] Slack
97
+ - [x] Linear
98
+ - [ ] Facebook
99
+ - [ ] X (Previously Twitter)
100
+ - [ ] LinkedIn
101
+ - [ ] Discord
102
+ - [ ] Zoom
103
+ - [ ] Microsoft
104
+ - [ ] Spotify
105
+ - [ ] Twitch
106
+
107
+ You can manage your auths in request-wise level. (e.g. you can use different auths for different requests)
108
+
109
+ ```python
110
+ from langchain_openai import ChatOpenAI
111
+ from langgraph.graph import StateGraph, START, MessagesState
112
+ from langgraph.prebuilt import tools_condition
113
+
114
+ import hyperpocket as pk
115
+ import hyperpocket.curated_tools
116
+ from pocket_langgraph import PocketLanggraph
117
+
118
+ pklg = PocketLanggraph(
119
+ tools=[
120
+ *pk.curated_tools.SLACK, # SLACK = [slack_get_message, slack_post_message, ..]
121
+ *pk.curated_tools.LINEAR,
122
+ "https://github.com/my-org/some-awesome-tool",
123
+ ],
124
+ )
125
+ llm = ChatOpenAI()
126
+
127
+ # Langgraph
128
+ pk_tool_node = pklg.get_tool_node()
129
+ llm_tool_binding = llm.bind_tools(pklg.get_tools())
130
+
131
+ # ...
132
+
133
+ graph_builder = StateGraph(MessagesState)
134
+
135
+ graph_builder.add_node('llm', llm)
136
+ graph_builder.add_node('tools', pk_tool_node)
137
+ graph_builder.add_edge(START, llm)
138
+ graph_builder.add_conditional_edges("llm", tools_condition)
139
+ graph_builder.add_edge(pk_tool_node, llm)
140
+
141
+ # ...
142
+
143
+ graph_builder.compile()
144
+
145
+ ```
146
+
147
+ ```python
148
+ from llama_index.core.agent import FunctionCallingAgent
149
+ from llama_index.llms.openai import OpenAI
150
+ from pocket_llamaindex import PocketLlamaindex
151
+
152
+ from hyperpocket.config import secret
153
+ from hyperpocket.tool import from_git
154
+
155
+ llm = OpenAI(api_key=secret["OPENAI_API_KEY"])
156
+ pocket = PocketLlamaindex(
157
+ tools=[
158
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/slack-get-message"),
159
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/slack-post-message"),
160
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/linear-get-issues"),
161
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/google-get-calendar-events"),
162
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/google-get-calendar-list"),
163
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/google-insert-calendar-events"),
164
+ from_git("https://github.com/vessl-ai/tool-calling", "main", "examples/github-pr-list"),
165
+ ]
166
+ )
167
+ tools = pocket.get_tools()
168
+
169
+ agent = FunctionCallingAgent.from_tools(tools=tools, llm=llm)
170
+ ```
171
+
172
+ ### Specifying auth methods for tool type
173
+
174
+ Some resources support multiple auth methods. Your end user should be able to select between those methods.
175
+
176
+ ```text
177
+ Human: List my slack messages in 'general' channel
178
+
179
+ 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?
180
+
181
+ Human: I'll go with OAuth
182
+
183
+ Assistance: You need chat:read, channel:history scopes to list messages. Do you confirm?
184
+
185
+ Human: OK.
186
+
187
+ Assistance: Please proceed to the following url and finish authentication. After that, let me know.
188
+ > https://slack.com/authorize?clientId=xxx&scope=chat:read,channel:history&redirect_url=xxx
189
+
190
+ Human: I'm done. (if necessary)
191
+
192
+ Assistance: I've checked you finished your auth. Let me search messages in slack channel 'general'.
193
+
194
+ Assistance: Here are the recent 10 messages.
195
+ (...)
196
+
197
+
198
+ ```
199
+
200
+ ### Config
201
+
202
+ Running `pocket config init` will create your config file in `$HOME/.pocket/settings.toml`
203
+
204
+ The `settings.toml` looks as follows.
205
+
206
+ TODO: Add `secrets.toml`.
207
+
208
+ ```toml
209
+ log_level = "debug"
210
+ internal_server_port = "8000" # optional, default is 8000
211
+ public_hostname = "localhost" # optional, default is localhost
212
+ public_server_protocol = "https" # optional, default is https
213
+ public_server_port = "8001" # optional, default is 8001
214
+ enable_local_callback_proxy = "true" # optional, default is true, can be turned off when running in production behind TLS termination
215
+ callback_url_rewrite_prefix = "proxy" # optional, default is proxy, auth callback url prefix
216
+
217
+ [session]
218
+ session_type = "redis" # optional, default is in-memory
219
+ [session.redis]
220
+ host = "localhost"
221
+ port = 6379
222
+ db = 0
223
+
224
+ [git]
225
+ [git.github]
226
+ github_token = "<Your github PAT>" # optional, your github personal access token
227
+ app_id = "<Your github app id>" # optional, your github app id
228
+ app_installation_id = "<Your github app installation id>" # optional, your github app installation id
229
+ app_private_key = "<Your github app private key>" # optional, your github app private key
230
+
231
+ [auth]
232
+ [auth.slack] # add your slack app's client id and secret for slack auth
233
+ client_id = "" # your slack client id
234
+ client_secret = "" # your slack client secret
235
+
236
+ [auth.github] # add your github app's client id and secret for github auth
237
+ client_id = "" # your github client id
238
+ client_secret = "" # your github client secret
239
+ ```
240
+
241
+ #### How to integrate github OAuth app
242
+
243
+ 1. Follow the github documentation to create a new OAuth
244
+ app. https://docs.github.com/en/apps/oauth-apps/building-oauth-apps/creating-an-oauth-app
245
+
246
+ - While creating your github OAuth app, configuring your app's `Authorization callback URL` is different for your
247
+ development environment and production environment.
248
+ - For development environment, you can use `http://localhost:8000/auth/github/callback`
249
+ - **Note**: Default port for pocket dev server is `8000`. If you are using a different port, make sure to
250
+ replace `8000` with your actual port number.
251
+ - For production environment, you can use `https://yourdomain.com/auth/github/callback`
252
+ - **Note**: Make sure to replace `yourdomain.com` with your actual domain name that this app will be hosted on.
253
+
254
+ #### How to integrate SLACK OAuth app
255
+
256
+ 1. Follow the slack documentation to create a new Oauth APP. https://api.slack.com/quickstart
257
+
258
+ 2. Setting Redirect URLs, Scopes at OAuth & Permissions tap in slack APP page
259
+
260
+ - Redirect URLs :
261
+ `{public_server_protocol}://{public_hostname}:[{public_server_port}]/{callback_url_rewrite_prefix}/auth/slack/oauth2/callback`
262
+ - Scopes : What you want to request to user.
263
+ - Recommended scopes :
264
+ - channels:history,
265
+ - channels:read,
266
+ - chat:write,
267
+ - groups:history,
268
+ - groups:read,
269
+ - im:history,
270
+ - mpim:history,
271
+ - reactions:read,
272
+ - reactions:write,
273
+
274
+ 3. Set your Slack APP Client ID / Client Secret in `$HOME/.pocket/settings.toml`
@@ -0,0 +1,7 @@
1
+ from hyperpocket.pocket_main import Pocket
2
+ from hyperpocket.pocket_auth import PocketAuth
3
+
4
+ __all__ = [
5
+ 'Pocket',
6
+ 'PocketAuth',
7
+ ]