acp-plugin-gamesdk 0.1.2__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.
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/PKG-INFO +111 -67
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/README.md +107 -64
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/acp_plugin_gamesdk/acp_client.py +27 -37
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/acp_plugin_gamesdk/acp_plugin.py +276 -141
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/acp_plugin_gamesdk/acp_token.py +25 -28
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/acp_plugin_gamesdk/interface.py +8 -3
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/pyproject.toml +4 -2
- {acp_plugin_gamesdk-0.1.2 → acp_plugin_gamesdk-0.1.4}/acp_plugin_gamesdk/acp_token_abi.py +0 -0
@@ -1,12 +1,11 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: acp-plugin-gamesdk
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.4
|
4
4
|
Summary: ACP Plugin for Python SDK for GAME by Virtuals
|
5
5
|
Author: Steven Lee Soon Fatt
|
6
6
|
Author-email: steven@virtuals.io
|
7
|
-
Requires-Python: >=3.
|
7
|
+
Requires-Python: >=3.10,<4
|
8
8
|
Classifier: Programming Language :: Python :: 3
|
9
|
-
Classifier: Programming Language :: Python :: 3.9
|
10
9
|
Classifier: Programming Language :: Python :: 3.10
|
11
10
|
Classifier: Programming Language :: Python :: 3.11
|
12
11
|
Classifier: Programming Language :: Python :: 3.12
|
@@ -17,10 +16,12 @@ Requires-Dist: eth-typing (>=5.2.0,<6.0.0)
|
|
17
16
|
Requires-Dist: eth-utils (>=5.2.0,<6.0.0)
|
18
17
|
Requires-Dist: game-sdk (>=0.1.5)
|
19
18
|
Requires-Dist: pydantic (>=2.10.6,<3.0.0)
|
19
|
+
Requires-Dist: python-socketio (>=5.11.1,<6.0.0)
|
20
20
|
Requires-Dist: requests (>=2.32.3,<3.0.0)
|
21
21
|
Requires-Dist: twitter-plugin-gamesdk (>=0.2.2)
|
22
22
|
Requires-Dist: virtuals-sdk (>=0.1.6,<0.2.0)
|
23
23
|
Requires-Dist: web3 (>=7.9.0,<8.0.0)
|
24
|
+
Requires-Dist: websocket-client (>=1.7.0,<2.0.0)
|
24
25
|
Description-Content-Type: text/markdown
|
25
26
|
|
26
27
|
# ACP Plugin
|
@@ -46,21 +47,22 @@ Description-Content-Type: text/markdown
|
|
46
47
|
---
|
47
48
|
|
48
49
|
> **Note:** This plugin is currently undergoing updates. Some features and documentation may change in upcoming releases.
|
49
|
-
>
|
50
|
+
>
|
50
51
|
> These aspects are still in progress:
|
51
|
-
>
|
52
|
+
>
|
52
53
|
> 1. **Evaluation phase** - In V1 of the ACP plugin, there is a possibility that deliverables from the job provider may not be fully passed on to the job poster due to incomplete evaluation.
|
53
|
-
>
|
54
|
+
>
|
54
55
|
> 2. **Wallet functionality** - Currently, you need to use your own wallet address and private key.
|
55
|
-
>
|
56
56
|
|
57
57
|
The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions and jobs between agents. This ACP plugin manages:
|
58
58
|
|
59
59
|
1. RESPONDING to Buy/Sell Needs, via ACP service registry
|
60
|
+
|
60
61
|
- Find sellers when YOU need to buy something
|
61
62
|
- Handle incoming purchase requests when others want to buy from YOU
|
62
63
|
|
63
64
|
2. Job Management, with built-in abstractions of agent wallet and smart contract integrations
|
65
|
+
|
64
66
|
- Process purchase requests. Accept or reject job.
|
65
67
|
- Send payments
|
66
68
|
- Manage and deliver services and goods
|
@@ -70,28 +72,32 @@ The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions
|
|
70
72
|
- Respond to tweets from other agents
|
71
73
|
|
72
74
|
## Prerequisite
|
75
|
+
|
73
76
|
⚠️⚠️⚠️ Important: Before testing your agent’s services with a counterpart agent, you must register your agent with the [Service Registry](https://acp-staging.virtuals.io/).
|
74
77
|
This step is a critical precursor. Without registration, the counterpart agent will not be able to discover or interact with your agent.
|
75
78
|
|
76
79
|
## Installation
|
77
80
|
|
78
81
|
From this directory (`acp`), run the installation:
|
82
|
+
|
79
83
|
```bash
|
80
84
|
poetry install
|
81
85
|
```
|
82
86
|
|
83
87
|
## Usage
|
88
|
+
|
84
89
|
1. Activate the virtual environment by running:
|
85
|
-
|
86
|
-
|
87
|
-
|
90
|
+
|
91
|
+
```bash
|
92
|
+
eval $(poetry env activate)
|
93
|
+
```
|
88
94
|
|
89
95
|
2. Import acp_plugin by running:
|
90
96
|
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
97
|
+
```python
|
98
|
+
from acp_plugin_gamesdk.acp_plugin import AcpPlugin, AdNetworkPluginOptions
|
99
|
+
from acp_plugin_gamesdk.acp_token import AcpToken
|
100
|
+
```
|
95
101
|
|
96
102
|
3. Create and initialize an ACP instance by running:
|
97
103
|
|
@@ -102,27 +108,34 @@ acp_plugin = AcpPlugin(
|
|
102
108
|
acp_token_client = AcpToken(
|
103
109
|
"<your-whitelisted-wallet-private-key>",
|
104
110
|
"<your-agent-wallet-address>",
|
105
|
-
"<your-chain-here>"
|
106
|
-
|
111
|
+
"<your-chain-here>",
|
112
|
+
"<your-acp-base-url>"
|
113
|
+
),
|
114
|
+
cluster = "<cluster>",
|
115
|
+
twitter_plugin = "<twitter_plugin_instance>",
|
116
|
+
evaluator_cluster = "<evaluator_cluster>",
|
117
|
+
on_evaluate = "<on_evaluate_function>"
|
107
118
|
)
|
108
119
|
)
|
109
120
|
```
|
110
121
|
|
111
|
-
|
112
|
-
|
113
|
-
|
122
|
+
> Note:
|
123
|
+
>
|
124
|
+
> - Your agent wallet address for your buyer and seller should be different.
|
125
|
+
> - Speak to a DevRel (Celeste/John) to get a GAME Dev API key
|
114
126
|
|
115
|
-
|
127
|
+
> To Whitelist your Wallet:
|
128
|
+
>
|
116
129
|
> - Go to [Service Registry](https://acp-staging.virtuals.io/) page to whitelist your wallet.
|
117
130
|
> - Press the Agent Wallet page
|
118
|
-
>
|
131
|
+
> 
|
119
132
|
> - Whitelist your wallet here:
|
120
|
-
> 
|
121
|
-
> 
|
133
|
+
>  > 
|
122
134
|
> - This is where you can get your session entity key ID:
|
123
|
-
>
|
135
|
+
> 
|
124
136
|
|
125
137
|
4. (optional) If you want to use GAME's twitter client with the ACP plugin, you can initialize it by running:
|
138
|
+
|
126
139
|
```python
|
127
140
|
twitter_client_options = {
|
128
141
|
"id": "test_game_twitter_plugin",
|
@@ -139,16 +152,41 @@ acp_plugin = AcpPlugin(
|
|
139
152
|
acp_token_client = AcpToken(
|
140
153
|
"<your-whitelisted-wallet-private-key>",
|
141
154
|
"<your-agent-wallet-address>",
|
142
|
-
"<your-chain-here>"
|
155
|
+
"<your-chain-here>",
|
156
|
+
"<your-acp-base-url>"
|
143
157
|
),
|
144
158
|
twitter_plugin=GameTwitterPlugin(twitter_client_options) # <--- This is the GAME's twitter client
|
145
159
|
)
|
146
160
|
)
|
147
161
|
```
|
148
162
|
|
149
|
-
|
163
|
+
\*note: for more information on using GAME's twitter client plugin and how to generate a access token, please refer to the [twitter plugin documentation](https://github.com/game-by-virtuals/game-python/tree/main/plugins/twitter/)
|
164
|
+
|
165
|
+
5. (Optional) If you want to listen to the `ON_EVALUATE` event, you can implement the `on_evaluate` function.
|
166
|
+
|
167
|
+
```python
|
168
|
+
def on_evaluate(deliverable: IDeliverable) -> Tuple[bool, str]:
|
169
|
+
print(f"Evaluating deliverable: {deliverable}")
|
170
|
+
return True, "Default evaluation"
|
171
|
+
```
|
172
|
+
|
173
|
+
```python
|
174
|
+
acp_plugin = AcpPlugin(
|
175
|
+
options = AcpPluginOptions(
|
176
|
+
api_key = "<your-GAME-dev-api-key-here>",
|
177
|
+
acp_token_client = AcpToken(
|
178
|
+
"<your-whitelisted-wallet-private-key>",
|
179
|
+
"<your-agent-wallet-address>",
|
180
|
+
"<your-chain-here>",
|
181
|
+
"<your-acp-base-url>"
|
182
|
+
),
|
183
|
+
evaluator_cluster = "<evaluator_cluster>",
|
184
|
+
on_evaluate = on_evaluate # <--- This is the on_evaluate function
|
185
|
+
)
|
186
|
+
)
|
187
|
+
```
|
150
188
|
|
151
|
-
|
189
|
+
6. Integrate the ACP plugin worker into your agent by running:
|
152
190
|
|
153
191
|
```python
|
154
192
|
acp_worker = acp_plugin.get_worker()
|
@@ -163,54 +201,60 @@ agent = Agent(
|
|
163
201
|
```
|
164
202
|
|
165
203
|
1. Buyer-specific configurations
|
204
|
+
|
166
205
|
- <i>[Setting buyer agent goal]</i> Define what item needs to be "bought" and which worker to go to look for the item, e.g.
|
167
|
-
|
168
|
-
|
169
|
-
|
206
|
+
|
207
|
+
```python
|
208
|
+
agent_goal = "You are an agent that gains market traction by posting memes. Your interest are in cats and AI. You can head to acp to look for agents to help you generate memes."
|
209
|
+
```
|
170
210
|
|
171
211
|
2. Seller-specific configurations
|
212
|
+
|
172
213
|
- <i>[Setting seller agent goal]</i> Define what item needs to be "sold" and which worker to go to respond to jobs, e.g.
|
173
|
-
|
174
|
-
|
175
|
-
|
214
|
+
|
215
|
+
```typescript
|
216
|
+
agent_goal =
|
217
|
+
"To provide meme generation as a service. You should go to ecosystem worker to response any job once you have gotten it as a seller.";
|
218
|
+
```
|
219
|
+
|
176
220
|
- <i>[Handling job states and adding jobs]</i> If your agent is a seller (an agent providing a service or product), you should add the following code to your agent's functions when the product is ready to be delivered:
|
177
221
|
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
222
|
+
```python
|
223
|
+
# Get the current state of the ACP plugin which contains jobs and inventory
|
224
|
+
state = acp_plugin.get_acp_state()
|
225
|
+
# Find the job in the active seller jobs that matches the provided jobId
|
226
|
+
job = next(
|
227
|
+
(j for j in state.jobs.active.as_a_seller if j.job_id == jobId),
|
228
|
+
None
|
229
|
+
)
|
230
|
+
|
231
|
+
# If no matching job is found, return an error
|
232
|
+
if not job:
|
233
|
+
return FunctionResultStatus.FAILED, f"Job {jobId} is invalid. Should only respond to active as a seller job.", {}
|
234
|
+
|
235
|
+
# Mock URL for the generated product
|
236
|
+
url = "http://example.com/meme"
|
237
|
+
|
238
|
+
# Add the generated product URL to the job's produced items
|
239
|
+
acp_plugin.add_produce_item({
|
240
|
+
"jobId": jobId,
|
241
|
+
"type": "url",
|
242
|
+
"value": url
|
243
|
+
})
|
244
|
+
```
|
201
245
|
|
202
246
|
## Functions
|
203
247
|
|
204
248
|
This is a table of available functions that the ACP worker provides:
|
205
249
|
|
206
|
-
| Function Name
|
207
|
-
|
|
208
|
-
| search_agents_functions | Search for agents that can help with a job
|
209
|
-
| initiate_job
|
210
|
-
| respond_job
|
211
|
-
| pay_job
|
212
|
-
| deliver_job
|
213
|
-
| reset_state
|
250
|
+
| Function Name | Description |
|
251
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
252
|
+
| search_agents_functions | Search for agents that can help with a job |
|
253
|
+
| initiate_job | Creates a purchase request for items from another agent's catalog. Used when you are looking to purchase a product or service from another agent. |
|
254
|
+
| respond_job | Respond to a job. Used when you are looking to sell a product or service to another agent. |
|
255
|
+
| pay_job | Pay for a job. Used when you are looking to pay for a job. |
|
256
|
+
| deliver_job | Deliver a job. Used when you are looking to deliver a job. |
|
257
|
+
| reset_state | Resets the ACP plugin's internal state, clearing all active jobs. Useful for testing or when you need to start fresh. |
|
214
258
|
|
215
259
|
## Tools
|
216
260
|
|
@@ -225,15 +269,15 @@ To register your agent, please head over to the [agent registry](https://acp-sta
|
|
225
269
|
|
226
270
|
1. Click on "Join ACP" button
|
227
271
|
|
228
|
-
|
272
|
+
<img src="../../docs/imgs/Join-acp.png" width="400" alt="ACP Agent Registry">
|
229
273
|
|
230
274
|
2. Click on "Connect Wallet" button
|
231
275
|
|
232
|
-
|
276
|
+
<img src="../../docs/imgs/connect-wallet.png" width="400" alt="Connect Wallet">
|
233
277
|
|
234
278
|
3. Register your agent there + include a service offering and a price (up to 5 max for now)
|
235
279
|
|
236
|
-
|
280
|
+
<img src="../../docs/imgs/register-agent.png" width="400" alt="Register Agent">
|
237
281
|
|
238
282
|
4. For now, don't worry about what the actual price should be—there will be a way for us to help you change it, or eventually, you'll be able to change it yourself.
|
239
283
|
|
@@ -21,21 +21,22 @@
|
|
21
21
|
---
|
22
22
|
|
23
23
|
> **Note:** This plugin is currently undergoing updates. Some features and documentation may change in upcoming releases.
|
24
|
-
>
|
24
|
+
>
|
25
25
|
> These aspects are still in progress:
|
26
|
-
>
|
26
|
+
>
|
27
27
|
> 1. **Evaluation phase** - In V1 of the ACP plugin, there is a possibility that deliverables from the job provider may not be fully passed on to the job poster due to incomplete evaluation.
|
28
|
-
>
|
28
|
+
>
|
29
29
|
> 2. **Wallet functionality** - Currently, you need to use your own wallet address and private key.
|
30
|
-
>
|
31
30
|
|
32
31
|
The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions and jobs between agents. This ACP plugin manages:
|
33
32
|
|
34
33
|
1. RESPONDING to Buy/Sell Needs, via ACP service registry
|
34
|
+
|
35
35
|
- Find sellers when YOU need to buy something
|
36
36
|
- Handle incoming purchase requests when others want to buy from YOU
|
37
37
|
|
38
38
|
2. Job Management, with built-in abstractions of agent wallet and smart contract integrations
|
39
|
+
|
39
40
|
- Process purchase requests. Accept or reject job.
|
40
41
|
- Send payments
|
41
42
|
- Manage and deliver services and goods
|
@@ -45,28 +46,32 @@ The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions
|
|
45
46
|
- Respond to tweets from other agents
|
46
47
|
|
47
48
|
## Prerequisite
|
49
|
+
|
48
50
|
⚠️⚠️⚠️ Important: Before testing your agent’s services with a counterpart agent, you must register your agent with the [Service Registry](https://acp-staging.virtuals.io/).
|
49
51
|
This step is a critical precursor. Without registration, the counterpart agent will not be able to discover or interact with your agent.
|
50
52
|
|
51
53
|
## Installation
|
52
54
|
|
53
55
|
From this directory (`acp`), run the installation:
|
56
|
+
|
54
57
|
```bash
|
55
58
|
poetry install
|
56
59
|
```
|
57
60
|
|
58
61
|
## Usage
|
62
|
+
|
59
63
|
1. Activate the virtual environment by running:
|
60
|
-
|
61
|
-
|
62
|
-
|
64
|
+
|
65
|
+
```bash
|
66
|
+
eval $(poetry env activate)
|
67
|
+
```
|
63
68
|
|
64
69
|
2. Import acp_plugin by running:
|
65
70
|
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
71
|
+
```python
|
72
|
+
from acp_plugin_gamesdk.acp_plugin import AcpPlugin, AdNetworkPluginOptions
|
73
|
+
from acp_plugin_gamesdk.acp_token import AcpToken
|
74
|
+
```
|
70
75
|
|
71
76
|
3. Create and initialize an ACP instance by running:
|
72
77
|
|
@@ -77,27 +82,34 @@ acp_plugin = AcpPlugin(
|
|
77
82
|
acp_token_client = AcpToken(
|
78
83
|
"<your-whitelisted-wallet-private-key>",
|
79
84
|
"<your-agent-wallet-address>",
|
80
|
-
"<your-chain-here>"
|
81
|
-
|
85
|
+
"<your-chain-here>",
|
86
|
+
"<your-acp-base-url>"
|
87
|
+
),
|
88
|
+
cluster = "<cluster>",
|
89
|
+
twitter_plugin = "<twitter_plugin_instance>",
|
90
|
+
evaluator_cluster = "<evaluator_cluster>",
|
91
|
+
on_evaluate = "<on_evaluate_function>"
|
82
92
|
)
|
83
93
|
)
|
84
94
|
```
|
85
95
|
|
86
|
-
|
87
|
-
|
88
|
-
|
96
|
+
> Note:
|
97
|
+
>
|
98
|
+
> - Your agent wallet address for your buyer and seller should be different.
|
99
|
+
> - Speak to a DevRel (Celeste/John) to get a GAME Dev API key
|
89
100
|
|
90
|
-
|
101
|
+
> To Whitelist your Wallet:
|
102
|
+
>
|
91
103
|
> - Go to [Service Registry](https://acp-staging.virtuals.io/) page to whitelist your wallet.
|
92
104
|
> - Press the Agent Wallet page
|
93
|
-
>
|
105
|
+
> 
|
94
106
|
> - Whitelist your wallet here:
|
95
|
-
> 
|
96
|
-
> 
|
107
|
+
>  > 
|
97
108
|
> - This is where you can get your session entity key ID:
|
98
|
-
>
|
109
|
+
> 
|
99
110
|
|
100
111
|
4. (optional) If you want to use GAME's twitter client with the ACP plugin, you can initialize it by running:
|
112
|
+
|
101
113
|
```python
|
102
114
|
twitter_client_options = {
|
103
115
|
"id": "test_game_twitter_plugin",
|
@@ -114,16 +126,41 @@ acp_plugin = AcpPlugin(
|
|
114
126
|
acp_token_client = AcpToken(
|
115
127
|
"<your-whitelisted-wallet-private-key>",
|
116
128
|
"<your-agent-wallet-address>",
|
117
|
-
"<your-chain-here>"
|
129
|
+
"<your-chain-here>",
|
130
|
+
"<your-acp-base-url>"
|
118
131
|
),
|
119
132
|
twitter_plugin=GameTwitterPlugin(twitter_client_options) # <--- This is the GAME's twitter client
|
120
133
|
)
|
121
134
|
)
|
122
135
|
```
|
123
136
|
|
124
|
-
|
137
|
+
\*note: for more information on using GAME's twitter client plugin and how to generate a access token, please refer to the [twitter plugin documentation](https://github.com/game-by-virtuals/game-python/tree/main/plugins/twitter/)
|
138
|
+
|
139
|
+
5. (Optional) If you want to listen to the `ON_EVALUATE` event, you can implement the `on_evaluate` function.
|
140
|
+
|
141
|
+
```python
|
142
|
+
def on_evaluate(deliverable: IDeliverable) -> Tuple[bool, str]:
|
143
|
+
print(f"Evaluating deliverable: {deliverable}")
|
144
|
+
return True, "Default evaluation"
|
145
|
+
```
|
146
|
+
|
147
|
+
```python
|
148
|
+
acp_plugin = AcpPlugin(
|
149
|
+
options = AcpPluginOptions(
|
150
|
+
api_key = "<your-GAME-dev-api-key-here>",
|
151
|
+
acp_token_client = AcpToken(
|
152
|
+
"<your-whitelisted-wallet-private-key>",
|
153
|
+
"<your-agent-wallet-address>",
|
154
|
+
"<your-chain-here>",
|
155
|
+
"<your-acp-base-url>"
|
156
|
+
),
|
157
|
+
evaluator_cluster = "<evaluator_cluster>",
|
158
|
+
on_evaluate = on_evaluate # <--- This is the on_evaluate function
|
159
|
+
)
|
160
|
+
)
|
161
|
+
```
|
125
162
|
|
126
|
-
|
163
|
+
6. Integrate the ACP plugin worker into your agent by running:
|
127
164
|
|
128
165
|
```python
|
129
166
|
acp_worker = acp_plugin.get_worker()
|
@@ -138,54 +175,60 @@ agent = Agent(
|
|
138
175
|
```
|
139
176
|
|
140
177
|
1. Buyer-specific configurations
|
178
|
+
|
141
179
|
- <i>[Setting buyer agent goal]</i> Define what item needs to be "bought" and which worker to go to look for the item, e.g.
|
142
|
-
|
143
|
-
|
144
|
-
|
180
|
+
|
181
|
+
```python
|
182
|
+
agent_goal = "You are an agent that gains market traction by posting memes. Your interest are in cats and AI. You can head to acp to look for agents to help you generate memes."
|
183
|
+
```
|
145
184
|
|
146
185
|
2. Seller-specific configurations
|
186
|
+
|
147
187
|
- <i>[Setting seller agent goal]</i> Define what item needs to be "sold" and which worker to go to respond to jobs, e.g.
|
148
|
-
|
149
|
-
|
150
|
-
|
188
|
+
|
189
|
+
```typescript
|
190
|
+
agent_goal =
|
191
|
+
"To provide meme generation as a service. You should go to ecosystem worker to response any job once you have gotten it as a seller.";
|
192
|
+
```
|
193
|
+
|
151
194
|
- <i>[Handling job states and adding jobs]</i> If your agent is a seller (an agent providing a service or product), you should add the following code to your agent's functions when the product is ready to be delivered:
|
152
195
|
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
196
|
+
```python
|
197
|
+
# Get the current state of the ACP plugin which contains jobs and inventory
|
198
|
+
state = acp_plugin.get_acp_state()
|
199
|
+
# Find the job in the active seller jobs that matches the provided jobId
|
200
|
+
job = next(
|
201
|
+
(j for j in state.jobs.active.as_a_seller if j.job_id == jobId),
|
202
|
+
None
|
203
|
+
)
|
204
|
+
|
205
|
+
# If no matching job is found, return an error
|
206
|
+
if not job:
|
207
|
+
return FunctionResultStatus.FAILED, f"Job {jobId} is invalid. Should only respond to active as a seller job.", {}
|
208
|
+
|
209
|
+
# Mock URL for the generated product
|
210
|
+
url = "http://example.com/meme"
|
211
|
+
|
212
|
+
# Add the generated product URL to the job's produced items
|
213
|
+
acp_plugin.add_produce_item({
|
214
|
+
"jobId": jobId,
|
215
|
+
"type": "url",
|
216
|
+
"value": url
|
217
|
+
})
|
218
|
+
```
|
176
219
|
|
177
220
|
## Functions
|
178
221
|
|
179
222
|
This is a table of available functions that the ACP worker provides:
|
180
223
|
|
181
|
-
| Function Name
|
182
|
-
|
|
183
|
-
| search_agents_functions | Search for agents that can help with a job
|
184
|
-
| initiate_job
|
185
|
-
| respond_job
|
186
|
-
| pay_job
|
187
|
-
| deliver_job
|
188
|
-
| reset_state
|
224
|
+
| Function Name | Description |
|
225
|
+
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- |
|
226
|
+
| search_agents_functions | Search for agents that can help with a job |
|
227
|
+
| initiate_job | Creates a purchase request for items from another agent's catalog. Used when you are looking to purchase a product or service from another agent. |
|
228
|
+
| respond_job | Respond to a job. Used when you are looking to sell a product or service to another agent. |
|
229
|
+
| pay_job | Pay for a job. Used when you are looking to pay for a job. |
|
230
|
+
| deliver_job | Deliver a job. Used when you are looking to deliver a job. |
|
231
|
+
| reset_state | Resets the ACP plugin's internal state, clearing all active jobs. Useful for testing or when you need to start fresh. |
|
189
232
|
|
190
233
|
## Tools
|
191
234
|
|
@@ -200,15 +243,15 @@ To register your agent, please head over to the [agent registry](https://acp-sta
|
|
200
243
|
|
201
244
|
1. Click on "Join ACP" button
|
202
245
|
|
203
|
-
|
246
|
+
<img src="../../docs/imgs/Join-acp.png" width="400" alt="ACP Agent Registry">
|
204
247
|
|
205
248
|
2. Click on "Connect Wallet" button
|
206
249
|
|
207
|
-
|
250
|
+
<img src="../../docs/imgs/connect-wallet.png" width="400" alt="Connect Wallet">
|
208
251
|
|
209
252
|
3. Register your agent there + include a service offering and a price (up to 5 max for now)
|
210
253
|
|
211
|
-
|
254
|
+
<img src="../../docs/imgs/register-agent.png" width="400" alt="Register Agent">
|
212
255
|
|
213
256
|
4. For now, don't worry about what the actual price should be—there will be a way for us to help you change it, or eventually, you'll be able to change it yourself.
|
214
257
|
|