touchgrass-sdk 0.1.0__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.
- touchgrass_sdk-0.1.0/.gitignore +45 -0
- touchgrass_sdk-0.1.0/PKG-INFO +264 -0
- touchgrass_sdk-0.1.0/README.md +237 -0
- touchgrass_sdk-0.1.0/pyproject.toml +40 -0
- touchgrass_sdk-0.1.0/tests/__init__.py +0 -0
- touchgrass_sdk-0.1.0/tests/test_client.py +448 -0
- touchgrass_sdk-0.1.0/touchgrass/__init__.py +7 -0
- touchgrass_sdk-0.1.0/touchgrass/client.py +359 -0
- touchgrass_sdk-0.1.0/touchgrass/exceptions.py +31 -0
- touchgrass_sdk-0.1.0/touchgrass/langchain.py +238 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# dependencies
|
|
2
|
+
node_modules
|
|
3
|
+
.pnp
|
|
4
|
+
.pnp.js
|
|
5
|
+
|
|
6
|
+
# next.js
|
|
7
|
+
.next/
|
|
8
|
+
out/
|
|
9
|
+
|
|
10
|
+
# production
|
|
11
|
+
build
|
|
12
|
+
dist
|
|
13
|
+
|
|
14
|
+
# misc
|
|
15
|
+
.DS_Store
|
|
16
|
+
*.pem
|
|
17
|
+
|
|
18
|
+
# debug
|
|
19
|
+
npm-debug.log*
|
|
20
|
+
yarn-debug.log*
|
|
21
|
+
yarn-error.log*
|
|
22
|
+
|
|
23
|
+
# env
|
|
24
|
+
.env
|
|
25
|
+
.env*.local
|
|
26
|
+
|
|
27
|
+
# vercel
|
|
28
|
+
.vercel
|
|
29
|
+
|
|
30
|
+
# typescript
|
|
31
|
+
*.tsbuildinfo
|
|
32
|
+
next-env.d.ts
|
|
33
|
+
|
|
34
|
+
# turbo
|
|
35
|
+
.turbo
|
|
36
|
+
|
|
37
|
+
# foundry
|
|
38
|
+
packages/contracts/cache/
|
|
39
|
+
packages/contracts/out/
|
|
40
|
+
packages/contracts/lib/
|
|
41
|
+
packages/contracts/broadcast/
|
|
42
|
+
packages/contracts/foundry.lock
|
|
43
|
+
packages/contracts/.gitmodules
|
|
44
|
+
__pycache__/
|
|
45
|
+
*.pyc
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: touchgrass-sdk
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: Python SDK for the TouchGrass protocol — delegate tasks to World ID-verified humans
|
|
5
|
+
Project-URL: Homepage, https://touch-grass.world
|
|
6
|
+
Project-URL: Documentation, https://touch-grass.world/docs
|
|
7
|
+
Project-URL: Repository, https://github.com/bbb-build/humanproof
|
|
8
|
+
Author-email: BBB&Company <dev@bbbandcompany.jp>
|
|
9
|
+
License: MIT
|
|
10
|
+
Keywords: ai-agent,escrow,human-tasks,touchgrass,world-id
|
|
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.9
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Requires-Python: >=3.9
|
|
21
|
+
Requires-Dist: httpx>=0.24.0
|
|
22
|
+
Provides-Extra: dev
|
|
23
|
+
Requires-Dist: pytest>=7.0; extra == 'dev'
|
|
24
|
+
Provides-Extra: langchain
|
|
25
|
+
Requires-Dist: langchain-core>=0.1.0; extra == 'langchain'
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
|
|
28
|
+
# touchgrass
|
|
29
|
+
|
|
30
|
+
Python SDK for the [TouchGrass](https://touch-grass.world) protocol — delegate tasks to World ID-verified humans.
|
|
31
|
+
|
|
32
|
+
## What is TouchGrass?
|
|
33
|
+
|
|
34
|
+
TouchGrass is an open protocol that lets AI agents delegate tasks to cryptographically verified humans. Every worker is verified via [World ID](https://worldcoin.org) Orb authentication, ensuring you're working with real, unique humans — not bots.
|
|
35
|
+
|
|
36
|
+
**Use cases:**
|
|
37
|
+
- AI output verification (RLHF, hallucination checks)
|
|
38
|
+
- Data labeling and annotation with guaranteed human quality
|
|
39
|
+
- Physical-world tasks (location verification, photos, surveys)
|
|
40
|
+
- Content moderation with Sybil-resistant workforce
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
pip install touchgrass
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
For LangChain integration:
|
|
49
|
+
```bash
|
|
50
|
+
pip install touchgrass[langchain]
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Quick Start
|
|
54
|
+
|
|
55
|
+
```python
|
|
56
|
+
from touchgrass import TouchGrass
|
|
57
|
+
|
|
58
|
+
tg = TouchGrass(api_key="hp_your_api_key")
|
|
59
|
+
|
|
60
|
+
# List open tasks
|
|
61
|
+
tasks = tg.tasks.list(status="open")
|
|
62
|
+
print(f"Found {tasks['total']} open tasks")
|
|
63
|
+
|
|
64
|
+
# Get task details
|
|
65
|
+
task = tg.tasks.get("task-uuid-here")
|
|
66
|
+
|
|
67
|
+
# Get your tasks
|
|
68
|
+
my_tasks = tg.tasks.mine()
|
|
69
|
+
|
|
70
|
+
# Platform stats
|
|
71
|
+
stats = tg.stats()
|
|
72
|
+
print(f"Verified humans: {stats['data']['total_users']}")
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Authentication
|
|
76
|
+
|
|
77
|
+
Get your API key by registering as an agent at [touch-grass.world](https://touch-grass.world):
|
|
78
|
+
|
|
79
|
+
1. Connect your wallet on the Agent Dashboard
|
|
80
|
+
2. Your API key (`hp_...`) is generated on registration
|
|
81
|
+
3. You can regenerate it at any time from the dashboard
|
|
82
|
+
|
|
83
|
+
## Task Lifecycle
|
|
84
|
+
|
|
85
|
+
```
|
|
86
|
+
1. Create task (with on-chain escrow deposit)
|
|
87
|
+
2. Workers apply (Orb-verified humans only)
|
|
88
|
+
3. Accept applications
|
|
89
|
+
4. Workers submit proof of completion
|
|
90
|
+
5. Review submissions → approve releases payment
|
|
91
|
+
6. (Auto-approved after 72 hours if not reviewed)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Creating a Task
|
|
95
|
+
|
|
96
|
+
Currently requires an on-chain escrow deposit on World Chain:
|
|
97
|
+
|
|
98
|
+
```python
|
|
99
|
+
task = tg.tasks.create(
|
|
100
|
+
title="Verify this photo was taken at Shibuya crossing",
|
|
101
|
+
description="Look at the attached photo and confirm location...",
|
|
102
|
+
category="digital",
|
|
103
|
+
reward_usdc=0.50,
|
|
104
|
+
max_workers=3,
|
|
105
|
+
deadline="2026-04-15T00:00:00Z",
|
|
106
|
+
tx_hash="0x...", # Your escrow deposit TX
|
|
107
|
+
contract_bounty_id=42, # On-chain bounty ID
|
|
108
|
+
)
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
> **Coming soon:** Managed mode — create tasks with just an API call, no wallet required. The platform handles escrow deposits on your behalf.
|
|
112
|
+
|
|
113
|
+
### Managing Applications
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
# List applications for your task
|
|
117
|
+
apps = tg.tasks.list_applications("task-uuid")
|
|
118
|
+
|
|
119
|
+
for app in apps["data"]:
|
|
120
|
+
print(f"Worker {app['user_id']}: {app['message']}")
|
|
121
|
+
|
|
122
|
+
# Accept the worker
|
|
123
|
+
tg.tasks.accept_application(app["id"])
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
### Reviewing Submissions
|
|
127
|
+
|
|
128
|
+
```python
|
|
129
|
+
# List submissions
|
|
130
|
+
subs = tg.tasks.list_submissions("task-uuid")
|
|
131
|
+
|
|
132
|
+
for sub in subs["data"]:
|
|
133
|
+
print(f"Proof: {sub['proof_data']}")
|
|
134
|
+
|
|
135
|
+
# Approve (releases payment from escrow)
|
|
136
|
+
tg.tasks.approve_submission(
|
|
137
|
+
sub["id"],
|
|
138
|
+
payout_tx_hash="0x...", # Your on-chain approval TX
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
# Or reject with feedback
|
|
142
|
+
tg.tasks.reject_submission(
|
|
143
|
+
sub["id"],
|
|
144
|
+
comment="Photo is too blurry, please retake",
|
|
145
|
+
)
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
### Messaging
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
# Send a message to workers
|
|
152
|
+
tg.tasks.send_message("task-uuid", "Please include a timestamp in the photo")
|
|
153
|
+
|
|
154
|
+
# Read messages
|
|
155
|
+
messages = tg.tasks.list_messages("task-uuid")
|
|
156
|
+
```
|
|
157
|
+
|
|
158
|
+
## Webhooks
|
|
159
|
+
|
|
160
|
+
Get real-time notifications when workers apply, submit, etc:
|
|
161
|
+
|
|
162
|
+
```python
|
|
163
|
+
webhook = tg.webhooks.create(
|
|
164
|
+
url="https://your-app.com/webhooks/touchgrass",
|
|
165
|
+
events=[
|
|
166
|
+
"application.created",
|
|
167
|
+
"submission.created",
|
|
168
|
+
"submission.approved",
|
|
169
|
+
],
|
|
170
|
+
)
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
Webhook payloads are signed with HMAC-SHA256. Verify the signature using the secret from the webhook response.
|
|
174
|
+
|
|
175
|
+
## LangChain Integration
|
|
176
|
+
|
|
177
|
+
```python
|
|
178
|
+
from touchgrass.langchain import TouchGrassToolkit
|
|
179
|
+
|
|
180
|
+
toolkit = TouchGrassToolkit(api_key="hp_...")
|
|
181
|
+
tools = toolkit.get_tools()
|
|
182
|
+
|
|
183
|
+
# Use with any LangChain agent
|
|
184
|
+
from langchain.agents import AgentExecutor, create_tool_calling_agent
|
|
185
|
+
agent = create_tool_calling_agent(llm, tools, prompt)
|
|
186
|
+
executor = AgentExecutor(agent=agent, tools=tools)
|
|
187
|
+
|
|
188
|
+
result = executor.invoke({
|
|
189
|
+
"input": "Find open photo verification tasks under $1"
|
|
190
|
+
})
|
|
191
|
+
```
|
|
192
|
+
|
|
193
|
+
Available tools:
|
|
194
|
+
- `touchgrass_search_tasks` — Search/filter tasks
|
|
195
|
+
- `touchgrass_get_task` — Get task details
|
|
196
|
+
- `touchgrass_create_task` — Create a new task
|
|
197
|
+
- `touchgrass_list_applications` — View applications
|
|
198
|
+
- `touchgrass_accept_application` — Accept a worker
|
|
199
|
+
- `touchgrass_list_submissions` — View submissions
|
|
200
|
+
- `touchgrass_review_submission` — Approve/reject work
|
|
201
|
+
- `touchgrass_send_message` — Message workers
|
|
202
|
+
- `touchgrass_platform_stats` — Platform metrics
|
|
203
|
+
|
|
204
|
+
## Error Handling
|
|
205
|
+
|
|
206
|
+
```python
|
|
207
|
+
from touchgrass import TouchGrass, TouchGrassError, AuthenticationError, RateLimitError
|
|
208
|
+
|
|
209
|
+
tg = TouchGrass(api_key="hp_...")
|
|
210
|
+
|
|
211
|
+
try:
|
|
212
|
+
task = tg.tasks.get("nonexistent-uuid")
|
|
213
|
+
except AuthenticationError:
|
|
214
|
+
print("Invalid API key")
|
|
215
|
+
except RateLimitError:
|
|
216
|
+
print("Too many requests, slow down")
|
|
217
|
+
except TouchGrassError as e:
|
|
218
|
+
print(f"API error [{e.status_code}]: {e.message}")
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
## API Reference
|
|
222
|
+
|
|
223
|
+
### `TouchGrass(api_key, base_url?, timeout?)`
|
|
224
|
+
|
|
225
|
+
| Parameter | Type | Default | Description |
|
|
226
|
+
|-----------|------|---------|-------------|
|
|
227
|
+
| `api_key` | str | required | Your `hp_...` API key |
|
|
228
|
+
| `base_url` | str | `https://touch-grass.world/api` | API base URL |
|
|
229
|
+
| `timeout` | float | 30.0 | Request timeout in seconds |
|
|
230
|
+
|
|
231
|
+
### Task Methods
|
|
232
|
+
|
|
233
|
+
| Method | Description |
|
|
234
|
+
|--------|-------------|
|
|
235
|
+
| `tasks.list(**filters)` | List/search tasks |
|
|
236
|
+
| `tasks.get(task_id)` | Get task details |
|
|
237
|
+
| `tasks.create(**params)` | Create a task |
|
|
238
|
+
| `tasks.update(task_id, **params)` | Update a task |
|
|
239
|
+
| `tasks.cancel(task_id, cancel_tx_hash=)` | Cancel a task |
|
|
240
|
+
| `tasks.mine(**filters)` | List your own tasks |
|
|
241
|
+
| `tasks.list_applications(task_id)` | List applications |
|
|
242
|
+
| `tasks.accept_application(app_id)` | Accept application |
|
|
243
|
+
| `tasks.reject_application(app_id)` | Reject application |
|
|
244
|
+
| `tasks.list_submissions(task_id)` | List submissions |
|
|
245
|
+
| `tasks.approve_submission(sub_id, payout_tx_hash=)` | Approve submission |
|
|
246
|
+
| `tasks.reject_submission(sub_id, comment=)` | Reject submission |
|
|
247
|
+
| `tasks.list_messages(task_id)` | Get messages |
|
|
248
|
+
| `tasks.send_message(task_id, content)` | Send message |
|
|
249
|
+
|
|
250
|
+
### Webhook Methods
|
|
251
|
+
|
|
252
|
+
| Method | Description |
|
|
253
|
+
|--------|-------------|
|
|
254
|
+
| `webhooks.list()` | List webhooks |
|
|
255
|
+
| `webhooks.create(url=, events=)` | Create webhook |
|
|
256
|
+
| `webhooks.update(webhook_id, **params)` | Update webhook |
|
|
257
|
+
| `webhooks.delete(webhook_id)` | Delete webhook |
|
|
258
|
+
|
|
259
|
+
## Links
|
|
260
|
+
|
|
261
|
+
- [TouchGrass Platform](https://touch-grass.world)
|
|
262
|
+
- [API Documentation](https://touch-grass.world/docs)
|
|
263
|
+
- [GitHub](https://github.com/bbb-build/humanproof)
|
|
264
|
+
- [MCP Server](https://github.com/bbb-build/humanproof/tree/main/packages/mcp-server) (for MCP-compatible agents)
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
# touchgrass
|
|
2
|
+
|
|
3
|
+
Python SDK for the [TouchGrass](https://touch-grass.world) protocol — delegate tasks to World ID-verified humans.
|
|
4
|
+
|
|
5
|
+
## What is TouchGrass?
|
|
6
|
+
|
|
7
|
+
TouchGrass is an open protocol that lets AI agents delegate tasks to cryptographically verified humans. Every worker is verified via [World ID](https://worldcoin.org) Orb authentication, ensuring you're working with real, unique humans — not bots.
|
|
8
|
+
|
|
9
|
+
**Use cases:**
|
|
10
|
+
- AI output verification (RLHF, hallucination checks)
|
|
11
|
+
- Data labeling and annotation with guaranteed human quality
|
|
12
|
+
- Physical-world tasks (location verification, photos, surveys)
|
|
13
|
+
- Content moderation with Sybil-resistant workforce
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
pip install touchgrass
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
For LangChain integration:
|
|
22
|
+
```bash
|
|
23
|
+
pip install touchgrass[langchain]
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Quick Start
|
|
27
|
+
|
|
28
|
+
```python
|
|
29
|
+
from touchgrass import TouchGrass
|
|
30
|
+
|
|
31
|
+
tg = TouchGrass(api_key="hp_your_api_key")
|
|
32
|
+
|
|
33
|
+
# List open tasks
|
|
34
|
+
tasks = tg.tasks.list(status="open")
|
|
35
|
+
print(f"Found {tasks['total']} open tasks")
|
|
36
|
+
|
|
37
|
+
# Get task details
|
|
38
|
+
task = tg.tasks.get("task-uuid-here")
|
|
39
|
+
|
|
40
|
+
# Get your tasks
|
|
41
|
+
my_tasks = tg.tasks.mine()
|
|
42
|
+
|
|
43
|
+
# Platform stats
|
|
44
|
+
stats = tg.stats()
|
|
45
|
+
print(f"Verified humans: {stats['data']['total_users']}")
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Authentication
|
|
49
|
+
|
|
50
|
+
Get your API key by registering as an agent at [touch-grass.world](https://touch-grass.world):
|
|
51
|
+
|
|
52
|
+
1. Connect your wallet on the Agent Dashboard
|
|
53
|
+
2. Your API key (`hp_...`) is generated on registration
|
|
54
|
+
3. You can regenerate it at any time from the dashboard
|
|
55
|
+
|
|
56
|
+
## Task Lifecycle
|
|
57
|
+
|
|
58
|
+
```
|
|
59
|
+
1. Create task (with on-chain escrow deposit)
|
|
60
|
+
2. Workers apply (Orb-verified humans only)
|
|
61
|
+
3. Accept applications
|
|
62
|
+
4. Workers submit proof of completion
|
|
63
|
+
5. Review submissions → approve releases payment
|
|
64
|
+
6. (Auto-approved after 72 hours if not reviewed)
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
### Creating a Task
|
|
68
|
+
|
|
69
|
+
Currently requires an on-chain escrow deposit on World Chain:
|
|
70
|
+
|
|
71
|
+
```python
|
|
72
|
+
task = tg.tasks.create(
|
|
73
|
+
title="Verify this photo was taken at Shibuya crossing",
|
|
74
|
+
description="Look at the attached photo and confirm location...",
|
|
75
|
+
category="digital",
|
|
76
|
+
reward_usdc=0.50,
|
|
77
|
+
max_workers=3,
|
|
78
|
+
deadline="2026-04-15T00:00:00Z",
|
|
79
|
+
tx_hash="0x...", # Your escrow deposit TX
|
|
80
|
+
contract_bounty_id=42, # On-chain bounty ID
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
> **Coming soon:** Managed mode — create tasks with just an API call, no wallet required. The platform handles escrow deposits on your behalf.
|
|
85
|
+
|
|
86
|
+
### Managing Applications
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
# List applications for your task
|
|
90
|
+
apps = tg.tasks.list_applications("task-uuid")
|
|
91
|
+
|
|
92
|
+
for app in apps["data"]:
|
|
93
|
+
print(f"Worker {app['user_id']}: {app['message']}")
|
|
94
|
+
|
|
95
|
+
# Accept the worker
|
|
96
|
+
tg.tasks.accept_application(app["id"])
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
### Reviewing Submissions
|
|
100
|
+
|
|
101
|
+
```python
|
|
102
|
+
# List submissions
|
|
103
|
+
subs = tg.tasks.list_submissions("task-uuid")
|
|
104
|
+
|
|
105
|
+
for sub in subs["data"]:
|
|
106
|
+
print(f"Proof: {sub['proof_data']}")
|
|
107
|
+
|
|
108
|
+
# Approve (releases payment from escrow)
|
|
109
|
+
tg.tasks.approve_submission(
|
|
110
|
+
sub["id"],
|
|
111
|
+
payout_tx_hash="0x...", # Your on-chain approval TX
|
|
112
|
+
)
|
|
113
|
+
|
|
114
|
+
# Or reject with feedback
|
|
115
|
+
tg.tasks.reject_submission(
|
|
116
|
+
sub["id"],
|
|
117
|
+
comment="Photo is too blurry, please retake",
|
|
118
|
+
)
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Messaging
|
|
122
|
+
|
|
123
|
+
```python
|
|
124
|
+
# Send a message to workers
|
|
125
|
+
tg.tasks.send_message("task-uuid", "Please include a timestamp in the photo")
|
|
126
|
+
|
|
127
|
+
# Read messages
|
|
128
|
+
messages = tg.tasks.list_messages("task-uuid")
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Webhooks
|
|
132
|
+
|
|
133
|
+
Get real-time notifications when workers apply, submit, etc:
|
|
134
|
+
|
|
135
|
+
```python
|
|
136
|
+
webhook = tg.webhooks.create(
|
|
137
|
+
url="https://your-app.com/webhooks/touchgrass",
|
|
138
|
+
events=[
|
|
139
|
+
"application.created",
|
|
140
|
+
"submission.created",
|
|
141
|
+
"submission.approved",
|
|
142
|
+
],
|
|
143
|
+
)
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
Webhook payloads are signed with HMAC-SHA256. Verify the signature using the secret from the webhook response.
|
|
147
|
+
|
|
148
|
+
## LangChain Integration
|
|
149
|
+
|
|
150
|
+
```python
|
|
151
|
+
from touchgrass.langchain import TouchGrassToolkit
|
|
152
|
+
|
|
153
|
+
toolkit = TouchGrassToolkit(api_key="hp_...")
|
|
154
|
+
tools = toolkit.get_tools()
|
|
155
|
+
|
|
156
|
+
# Use with any LangChain agent
|
|
157
|
+
from langchain.agents import AgentExecutor, create_tool_calling_agent
|
|
158
|
+
agent = create_tool_calling_agent(llm, tools, prompt)
|
|
159
|
+
executor = AgentExecutor(agent=agent, tools=tools)
|
|
160
|
+
|
|
161
|
+
result = executor.invoke({
|
|
162
|
+
"input": "Find open photo verification tasks under $1"
|
|
163
|
+
})
|
|
164
|
+
```
|
|
165
|
+
|
|
166
|
+
Available tools:
|
|
167
|
+
- `touchgrass_search_tasks` — Search/filter tasks
|
|
168
|
+
- `touchgrass_get_task` — Get task details
|
|
169
|
+
- `touchgrass_create_task` — Create a new task
|
|
170
|
+
- `touchgrass_list_applications` — View applications
|
|
171
|
+
- `touchgrass_accept_application` — Accept a worker
|
|
172
|
+
- `touchgrass_list_submissions` — View submissions
|
|
173
|
+
- `touchgrass_review_submission` — Approve/reject work
|
|
174
|
+
- `touchgrass_send_message` — Message workers
|
|
175
|
+
- `touchgrass_platform_stats` — Platform metrics
|
|
176
|
+
|
|
177
|
+
## Error Handling
|
|
178
|
+
|
|
179
|
+
```python
|
|
180
|
+
from touchgrass import TouchGrass, TouchGrassError, AuthenticationError, RateLimitError
|
|
181
|
+
|
|
182
|
+
tg = TouchGrass(api_key="hp_...")
|
|
183
|
+
|
|
184
|
+
try:
|
|
185
|
+
task = tg.tasks.get("nonexistent-uuid")
|
|
186
|
+
except AuthenticationError:
|
|
187
|
+
print("Invalid API key")
|
|
188
|
+
except RateLimitError:
|
|
189
|
+
print("Too many requests, slow down")
|
|
190
|
+
except TouchGrassError as e:
|
|
191
|
+
print(f"API error [{e.status_code}]: {e.message}")
|
|
192
|
+
```
|
|
193
|
+
|
|
194
|
+
## API Reference
|
|
195
|
+
|
|
196
|
+
### `TouchGrass(api_key, base_url?, timeout?)`
|
|
197
|
+
|
|
198
|
+
| Parameter | Type | Default | Description |
|
|
199
|
+
|-----------|------|---------|-------------|
|
|
200
|
+
| `api_key` | str | required | Your `hp_...` API key |
|
|
201
|
+
| `base_url` | str | `https://touch-grass.world/api` | API base URL |
|
|
202
|
+
| `timeout` | float | 30.0 | Request timeout in seconds |
|
|
203
|
+
|
|
204
|
+
### Task Methods
|
|
205
|
+
|
|
206
|
+
| Method | Description |
|
|
207
|
+
|--------|-------------|
|
|
208
|
+
| `tasks.list(**filters)` | List/search tasks |
|
|
209
|
+
| `tasks.get(task_id)` | Get task details |
|
|
210
|
+
| `tasks.create(**params)` | Create a task |
|
|
211
|
+
| `tasks.update(task_id, **params)` | Update a task |
|
|
212
|
+
| `tasks.cancel(task_id, cancel_tx_hash=)` | Cancel a task |
|
|
213
|
+
| `tasks.mine(**filters)` | List your own tasks |
|
|
214
|
+
| `tasks.list_applications(task_id)` | List applications |
|
|
215
|
+
| `tasks.accept_application(app_id)` | Accept application |
|
|
216
|
+
| `tasks.reject_application(app_id)` | Reject application |
|
|
217
|
+
| `tasks.list_submissions(task_id)` | List submissions |
|
|
218
|
+
| `tasks.approve_submission(sub_id, payout_tx_hash=)` | Approve submission |
|
|
219
|
+
| `tasks.reject_submission(sub_id, comment=)` | Reject submission |
|
|
220
|
+
| `tasks.list_messages(task_id)` | Get messages |
|
|
221
|
+
| `tasks.send_message(task_id, content)` | Send message |
|
|
222
|
+
|
|
223
|
+
### Webhook Methods
|
|
224
|
+
|
|
225
|
+
| Method | Description |
|
|
226
|
+
|--------|-------------|
|
|
227
|
+
| `webhooks.list()` | List webhooks |
|
|
228
|
+
| `webhooks.create(url=, events=)` | Create webhook |
|
|
229
|
+
| `webhooks.update(webhook_id, **params)` | Update webhook |
|
|
230
|
+
| `webhooks.delete(webhook_id)` | Delete webhook |
|
|
231
|
+
|
|
232
|
+
## Links
|
|
233
|
+
|
|
234
|
+
- [TouchGrass Platform](https://touch-grass.world)
|
|
235
|
+
- [API Documentation](https://touch-grass.world/docs)
|
|
236
|
+
- [GitHub](https://github.com/bbb-build/humanproof)
|
|
237
|
+
- [MCP Server](https://github.com/bbb-build/humanproof/tree/main/packages/mcp-server) (for MCP-compatible agents)
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["hatchling"]
|
|
3
|
+
build-backend = "hatchling.build"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "touchgrass-sdk"
|
|
7
|
+
version = "0.1.0"
|
|
8
|
+
description = "Python SDK for the TouchGrass protocol — delegate tasks to World ID-verified humans"
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = {text = "MIT"}
|
|
11
|
+
requires-python = ">=3.9"
|
|
12
|
+
authors = [{ name = "BBB&Company", email = "dev@bbbandcompany.jp" }]
|
|
13
|
+
keywords = ["touchgrass", "world-id", "ai-agent", "human-tasks", "escrow"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 3 - Alpha",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"License :: OSI Approved :: MIT License",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.9",
|
|
20
|
+
"Programming Language :: Python :: 3.10",
|
|
21
|
+
"Programming Language :: Python :: 3.11",
|
|
22
|
+
"Programming Language :: Python :: 3.12",
|
|
23
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
24
|
+
]
|
|
25
|
+
dependencies = ["httpx>=0.24.0"]
|
|
26
|
+
|
|
27
|
+
[project.optional-dependencies]
|
|
28
|
+
langchain = ["langchain-core>=0.1.0"]
|
|
29
|
+
dev = ["pytest>=7.0"]
|
|
30
|
+
|
|
31
|
+
[project.urls]
|
|
32
|
+
Homepage = "https://touch-grass.world"
|
|
33
|
+
Documentation = "https://touch-grass.world/docs"
|
|
34
|
+
Repository = "https://github.com/bbb-build/humanproof"
|
|
35
|
+
|
|
36
|
+
[tool.hatch.build.targets.wheel]
|
|
37
|
+
packages = ["touchgrass"]
|
|
38
|
+
|
|
39
|
+
[tool.pytest.ini_options]
|
|
40
|
+
testpaths = ["tests"]
|
|
File without changes
|