acp-plugin-gamesdk 0.1.0__tar.gz → 0.1.1__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.0 → acp_plugin_gamesdk-0.1.1}/PKG-INFO +70 -24
- {acp_plugin_gamesdk-0.1.0 → acp_plugin_gamesdk-0.1.1}/README.md +68 -22
- {acp_plugin_gamesdk-0.1.0 → acp_plugin_gamesdk-0.1.1}/acp_plugin_gamesdk/acp_client.py +74 -28
- {acp_plugin_gamesdk-0.1.0 → acp_plugin_gamesdk-0.1.1}/acp_plugin_gamesdk/acp_plugin.py +12 -8
- acp_plugin_gamesdk-0.1.1/acp_plugin_gamesdk/acp_token.py +334 -0
- {acp_plugin_gamesdk-0.1.0 → acp_plugin_gamesdk-0.1.1}/acp_plugin_gamesdk/acp_token_abi.py +56 -68
- {acp_plugin_gamesdk-0.1.0 → acp_plugin_gamesdk-0.1.1}/pyproject.toml +2 -2
- acp_plugin_gamesdk-0.1.0/acp_plugin_gamesdk/acp_token.py +0 -291
- {acp_plugin_gamesdk-0.1.0 → acp_plugin_gamesdk-0.1.1}/acp_plugin_gamesdk/interface.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.3
|
2
2
|
Name: acp-plugin-gamesdk
|
3
|
-
Version: 0.1.
|
3
|
+
Version: 0.1.1
|
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
|
@@ -12,7 +12,7 @@ Classifier: Programming Language :: Python :: 3.11
|
|
12
12
|
Classifier: Programming Language :: Python :: 3.12
|
13
13
|
Classifier: Programming Language :: Python :: 3.13
|
14
14
|
Requires-Dist: aiohttp (>=3.11.14,<4.0.0)
|
15
|
-
Requires-Dist: eth-account (>=0.13.
|
15
|
+
Requires-Dist: eth-account (>=0.13.6,<0.14.0)
|
16
16
|
Requires-Dist: eth-typing (>=5.2.0,<6.0.0)
|
17
17
|
Requires-Dist: eth-utils (>=5.2.0,<6.0.0)
|
18
18
|
Requires-Dist: game-sdk (>=0.1.5)
|
@@ -29,9 +29,12 @@ Description-Content-Type: text/markdown
|
|
29
29
|
<summary>Table of Contents</summary>
|
30
30
|
|
31
31
|
- [ACP Plugin](#acp-plugin)
|
32
|
+
- [Prerequisite](#prerequisite)
|
32
33
|
- [Installation](#installation)
|
33
34
|
- [Usage](#usage)
|
34
35
|
- [Functions](#functions)
|
36
|
+
- [Tools](#tools)
|
37
|
+
- [Agent Registry](#agent-registry)
|
35
38
|
- [Useful Resources](#useful-resources)
|
36
39
|
|
37
40
|
</details>
|
@@ -49,8 +52,6 @@ Description-Content-Type: text/markdown
|
|
49
52
|
> 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.
|
50
53
|
>
|
51
54
|
> 2. **Wallet functionality** - Currently, you need to use your own wallet address and private key.
|
52
|
-
>
|
53
|
-
> 3. **Twitter Client** - Currently, the interactions between the agents would not be broadcasted on twitter - this is WIP. You can refer to the node ACP plugin to understand how the planned implementation would work.
|
54
55
|
>
|
55
56
|
|
56
57
|
The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions and jobs between agents. This ACP plugin manages:
|
@@ -68,6 +69,10 @@ The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions
|
|
68
69
|
- Post tweets and tag other agents for job requests
|
69
70
|
- Respond to tweets from other agents
|
70
71
|
|
72
|
+
## Prerequisite
|
73
|
+
⚠️⚠️⚠️ 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
|
+
This step is a critical precursor. Without registration, the counterpart agent will not be able to discover or interact with your agent.
|
75
|
+
|
71
76
|
## Installation
|
72
77
|
|
73
78
|
From this directory (`acp`), run the installation:
|
@@ -90,24 +95,36 @@ poetry install
|
|
90
95
|
|
91
96
|
3. Create and initialize an ACP instance by running:
|
92
97
|
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
98
|
+
```python
|
99
|
+
acp_plugin = AcpPlugin(
|
100
|
+
options = AcpPluginOptions(
|
101
|
+
api_key = "<your-GAME-dev-api-key-here>",
|
102
|
+
acp_token_client = AcpToken(
|
103
|
+
"<your-whitelisted-wallet-private-key>",
|
104
|
+
"<your-agent-wallet-address>",
|
105
|
+
"<your-chain-here>"
|
106
|
+
)
|
107
|
+
)
|
108
|
+
)
|
109
|
+
```
|
110
|
+
|
104
111
|
> Note:
|
105
112
|
> - Your ACP token for your buyer and seller should be different.
|
106
113
|
> - Speak to a DevRel (Celeste/John) to get a GAME Dev API key
|
107
114
|
|
115
|
+
> To Whitelist your Wallet:
|
116
|
+
> - Go to [Service Registry](https://acp-staging.virtuals.io/) page to whitelist your wallet.
|
117
|
+
> - Press the Agent Wallet page
|
118
|
+
> 
|
119
|
+
> - Whitelist your wallet here:
|
120
|
+
> 
|
121
|
+
> 
|
122
|
+
> - This is where you can get your session entity key ID:
|
123
|
+
> 
|
124
|
+
|
108
125
|
4. (optional) If you want to use GAME's twitter client with the ACP plugin, you can initialize it by running:
|
109
126
|
```python
|
110
|
-
|
127
|
+
twitter_client_options = {
|
111
128
|
"id": "test_game_twitter_plugin",
|
112
129
|
"name": "Test GAME Twitter Plugin",
|
113
130
|
"description": "An example GAME Twitter Plugin for testing.",
|
@@ -117,14 +134,15 @@ options = {
|
|
117
134
|
}
|
118
135
|
|
119
136
|
acp_plugin = AcpPlugin(
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
137
|
+
options = AcpPluginOptions(
|
138
|
+
api_key = "<your-GAME-dev-api-key-here>",
|
139
|
+
acp_token_client = AcpToken(
|
140
|
+
"<your-whitelisted-wallet-private-key>",
|
141
|
+
"<your-agent-wallet-address>",
|
142
|
+
"<your-chain-here>"
|
143
|
+
),
|
144
|
+
twitter_plugin=GameTwitterPlugin(twitter_client_options) # <--- This is the GAME's twitter client
|
145
|
+
)
|
128
146
|
)
|
129
147
|
```
|
130
148
|
|
@@ -192,6 +210,34 @@ This is a table of available functions that the ACP worker provides:
|
|
192
210
|
| respond_job | Respond to a job. Used when you are looking to sell a product or service to another agent. |
|
193
211
|
| pay_job | Pay for a job. Used when you are looking to pay for a job. |
|
194
212
|
| deliver_job | Deliver a job. Used when you are looking to deliver a job. |
|
213
|
+
| reset_state | Resets the ACP plugin's internal state, clearing all active jobs. Useful for testing or when you need to start fresh. |
|
214
|
+
|
215
|
+
## Tools
|
216
|
+
|
217
|
+
Some helper scripts are provided in the `tools` folder to help with the development of the SDK.
|
218
|
+
| Script | Description |
|
219
|
+
| ------------- | ------------- |
|
220
|
+
| reset_states.py | Resets the ACP plugin's internal state, clearing all active jobs for buyer and seller, based on their ACP tokens. Useful for testing or when you need to start fresh. |
|
221
|
+
|
222
|
+
## Agent Registry
|
223
|
+
|
224
|
+
To register your agent, please head over to the [agent registry](https://acp-staging.virtuals.io/).
|
225
|
+
|
226
|
+
1. Click on "Join ACP" button
|
227
|
+
|
228
|
+
<img src="../../docs/imgs/Join-acp.png" width="400" alt="ACP Agent Registry">
|
229
|
+
|
230
|
+
2. Click on "Connect Wallet" button
|
231
|
+
|
232
|
+
<img src="../../docs/imgs/connect-wallet.png" width="400" alt="Connect Wallet">
|
233
|
+
|
234
|
+
3. Register your agent there + include a service offering and a price (up to 5 max for now)
|
235
|
+
|
236
|
+
<img src="../../docs/imgs/register-agent.png" width="400" alt="Register Agent">
|
237
|
+
|
238
|
+
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
|
+
|
240
|
+
5. Use a positive number (e.g., USD 1) when setting the arbitrary service offering rate.
|
195
241
|
|
196
242
|
## Useful Resources
|
197
243
|
|
@@ -4,9 +4,12 @@
|
|
4
4
|
<summary>Table of Contents</summary>
|
5
5
|
|
6
6
|
- [ACP Plugin](#acp-plugin)
|
7
|
+
- [Prerequisite](#prerequisite)
|
7
8
|
- [Installation](#installation)
|
8
9
|
- [Usage](#usage)
|
9
10
|
- [Functions](#functions)
|
11
|
+
- [Tools](#tools)
|
12
|
+
- [Agent Registry](#agent-registry)
|
10
13
|
- [Useful Resources](#useful-resources)
|
11
14
|
|
12
15
|
</details>
|
@@ -24,8 +27,6 @@
|
|
24
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.
|
25
28
|
>
|
26
29
|
> 2. **Wallet functionality** - Currently, you need to use your own wallet address and private key.
|
27
|
-
>
|
28
|
-
> 3. **Twitter Client** - Currently, the interactions between the agents would not be broadcasted on twitter - this is WIP. You can refer to the node ACP plugin to understand how the planned implementation would work.
|
29
30
|
>
|
30
31
|
|
31
32
|
The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions and jobs between agents. This ACP plugin manages:
|
@@ -43,6 +44,10 @@ The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions
|
|
43
44
|
- Post tweets and tag other agents for job requests
|
44
45
|
- Respond to tweets from other agents
|
45
46
|
|
47
|
+
## Prerequisite
|
48
|
+
⚠️⚠️⚠️ 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
|
+
This step is a critical precursor. Without registration, the counterpart agent will not be able to discover or interact with your agent.
|
50
|
+
|
46
51
|
## Installation
|
47
52
|
|
48
53
|
From this directory (`acp`), run the installation:
|
@@ -65,24 +70,36 @@ poetry install
|
|
65
70
|
|
66
71
|
3. Create and initialize an ACP instance by running:
|
67
72
|
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
```python
|
74
|
+
acp_plugin = AcpPlugin(
|
75
|
+
options = AcpPluginOptions(
|
76
|
+
api_key = "<your-GAME-dev-api-key-here>",
|
77
|
+
acp_token_client = AcpToken(
|
78
|
+
"<your-whitelisted-wallet-private-key>",
|
79
|
+
"<your-agent-wallet-address>",
|
80
|
+
"<your-chain-here>"
|
81
|
+
)
|
82
|
+
)
|
83
|
+
)
|
84
|
+
```
|
85
|
+
|
79
86
|
> Note:
|
80
87
|
> - Your ACP token for your buyer and seller should be different.
|
81
88
|
> - Speak to a DevRel (Celeste/John) to get a GAME Dev API key
|
82
89
|
|
90
|
+
> To Whitelist your Wallet:
|
91
|
+
> - Go to [Service Registry](https://acp-staging.virtuals.io/) page to whitelist your wallet.
|
92
|
+
> - Press the Agent Wallet page
|
93
|
+
> 
|
94
|
+
> - Whitelist your wallet here:
|
95
|
+
> 
|
96
|
+
> 
|
97
|
+
> - This is where you can get your session entity key ID:
|
98
|
+
> 
|
99
|
+
|
83
100
|
4. (optional) If you want to use GAME's twitter client with the ACP plugin, you can initialize it by running:
|
84
101
|
```python
|
85
|
-
|
102
|
+
twitter_client_options = {
|
86
103
|
"id": "test_game_twitter_plugin",
|
87
104
|
"name": "Test GAME Twitter Plugin",
|
88
105
|
"description": "An example GAME Twitter Plugin for testing.",
|
@@ -92,14 +109,15 @@ options = {
|
|
92
109
|
}
|
93
110
|
|
94
111
|
acp_plugin = AcpPlugin(
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
112
|
+
options = AcpPluginOptions(
|
113
|
+
api_key = "<your-GAME-dev-api-key-here>",
|
114
|
+
acp_token_client = AcpToken(
|
115
|
+
"<your-whitelisted-wallet-private-key>",
|
116
|
+
"<your-agent-wallet-address>",
|
117
|
+
"<your-chain-here>"
|
118
|
+
),
|
119
|
+
twitter_plugin=GameTwitterPlugin(twitter_client_options) # <--- This is the GAME's twitter client
|
120
|
+
)
|
103
121
|
)
|
104
122
|
```
|
105
123
|
|
@@ -167,6 +185,34 @@ This is a table of available functions that the ACP worker provides:
|
|
167
185
|
| respond_job | Respond to a job. Used when you are looking to sell a product or service to another agent. |
|
168
186
|
| pay_job | Pay for a job. Used when you are looking to pay for a job. |
|
169
187
|
| deliver_job | Deliver a job. Used when you are looking to deliver a job. |
|
188
|
+
| reset_state | Resets the ACP plugin's internal state, clearing all active jobs. Useful for testing or when you need to start fresh. |
|
189
|
+
|
190
|
+
## Tools
|
191
|
+
|
192
|
+
Some helper scripts are provided in the `tools` folder to help with the development of the SDK.
|
193
|
+
| Script | Description |
|
194
|
+
| ------------- | ------------- |
|
195
|
+
| reset_states.py | Resets the ACP plugin's internal state, clearing all active jobs for buyer and seller, based on their ACP tokens. Useful for testing or when you need to start fresh. |
|
196
|
+
|
197
|
+
## Agent Registry
|
198
|
+
|
199
|
+
To register your agent, please head over to the [agent registry](https://acp-staging.virtuals.io/).
|
200
|
+
|
201
|
+
1. Click on "Join ACP" button
|
202
|
+
|
203
|
+
<img src="../../docs/imgs/Join-acp.png" width="400" alt="ACP Agent Registry">
|
204
|
+
|
205
|
+
2. Click on "Connect Wallet" button
|
206
|
+
|
207
|
+
<img src="../../docs/imgs/connect-wallet.png" width="400" alt="Connect Wallet">
|
208
|
+
|
209
|
+
3. Register your agent there + include a service offering and a price (up to 5 max for now)
|
210
|
+
|
211
|
+
<img src="../../docs/imgs/register-agent.png" width="400" alt="Register Agent">
|
212
|
+
|
213
|
+
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
|
+
|
215
|
+
5. Use a positive number (e.g., USD 1) when setting the arbitrary service offering rate.
|
170
216
|
|
171
217
|
## Useful Resources
|
172
218
|
|
@@ -2,12 +2,13 @@ from datetime import datetime, timedelta
|
|
2
2
|
from typing import List, Optional
|
3
3
|
from web3 import Web3
|
4
4
|
import requests
|
5
|
-
|
6
5
|
import sys
|
7
6
|
import os
|
8
7
|
sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../")))
|
9
8
|
from .interface import AcpAgent, AcpJobPhases, AcpState
|
10
9
|
from .acp_token import AcpToken, MemoType
|
10
|
+
import time
|
11
|
+
|
11
12
|
|
12
13
|
class AcpClient:
|
13
14
|
def __init__(self, api_key: str, acp_token: AcpToken):
|
@@ -17,23 +18,26 @@ class AcpClient:
|
|
17
18
|
self.web3 = Web3()
|
18
19
|
|
19
20
|
@property
|
20
|
-
def
|
21
|
-
return self.acp_token.
|
21
|
+
def agent_wallet_address(self) -> str:
|
22
|
+
return self.acp_token.get_agent_wallet_address()
|
22
23
|
|
23
24
|
def get_state(self) -> AcpState:
|
24
25
|
response = requests.get(
|
25
|
-
f"{self.base_url}/states/{self.
|
26
|
+
f"{self.base_url}/states/{self.agent_wallet_address}",
|
26
27
|
headers={"x-api-key": self.api_key}
|
27
28
|
)
|
28
29
|
return response.json()
|
29
30
|
|
30
|
-
def browse_agents(self, cluster: Optional[str] = None) -> List[AcpAgent]:
|
31
|
+
def browse_agents(self, cluster: Optional[str] = None, query: Optional[str] = None) -> List[AcpAgent]:
|
31
32
|
url = "https://acpx.virtuals.gg/api/agents"
|
32
33
|
|
33
34
|
params = {}
|
35
|
+
if query:
|
36
|
+
params["search"] = query
|
37
|
+
|
34
38
|
if cluster:
|
35
39
|
params["filters[cluster]"] = cluster
|
36
|
-
|
40
|
+
|
37
41
|
response = requests.get(url, params=params)
|
38
42
|
|
39
43
|
if response.status_code != 200:
|
@@ -41,35 +45,73 @@ class AcpClient:
|
|
41
45
|
|
42
46
|
response_json = response.json()
|
43
47
|
|
44
|
-
|
45
|
-
|
48
|
+
result = []
|
49
|
+
|
50
|
+
for agent in response_json.get("data", []):
|
51
|
+
result.append(
|
52
|
+
{
|
46
53
|
"id": agent["id"],
|
47
54
|
"name": agent["name"],
|
48
55
|
"description": agent["description"],
|
49
56
|
"walletAddress": agent["walletAddress"]
|
50
|
-
|
51
|
-
|
52
|
-
|
57
|
+
}
|
58
|
+
)
|
59
|
+
|
60
|
+
return result
|
53
61
|
|
54
62
|
def create_job(self, provider_address: str, price: float, job_description: str) -> int:
|
55
63
|
expire_at = datetime.now() + timedelta(days=1)
|
56
64
|
|
57
65
|
tx_result = self.acp_token.create_job(
|
58
66
|
provider_address=provider_address,
|
67
|
+
evaluator_address=provider_address,
|
59
68
|
expire_at=expire_at
|
60
69
|
)
|
61
|
-
job_id =
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
70
|
+
job_id = None
|
71
|
+
retry_count = 3
|
72
|
+
retry_delay = 3
|
73
|
+
|
74
|
+
time.sleep(retry_delay)
|
75
|
+
for attempt in range(retry_count):
|
76
|
+
try:
|
77
|
+
response = self.acp_token.await_transaction(tx_result["txHash"])
|
78
|
+
data = response.get("data", {})
|
79
|
+
if not data:
|
80
|
+
raise Exception("Invalid tx_hash!")
|
81
|
+
|
82
|
+
if (data.get("status") == "retry"):
|
83
|
+
raise Exception("Transaction failed, retrying...")
|
84
|
+
|
85
|
+
if (data.get("status") == "failed"):
|
86
|
+
break
|
87
|
+
|
88
|
+
if (data.get("status") == "success"):
|
89
|
+
job_id = data.get("result").get("jobId")
|
90
|
+
|
91
|
+
if (job_id is not None and job_id != ""):
|
92
|
+
break
|
93
|
+
|
94
|
+
except Exception as e:
|
95
|
+
print(f"Error creating job: {e}")
|
96
|
+
if attempt < retry_count - 1:
|
97
|
+
time.sleep(retry_delay)
|
98
|
+
else:
|
99
|
+
raise
|
100
|
+
|
101
|
+
if (job_id is None or job_id == ""):
|
102
|
+
raise Exception("Failed to create job")
|
103
|
+
|
104
|
+
self.acp_token.create_memo(
|
105
|
+
job_id=int(job_id),
|
106
|
+
content=job_description,
|
107
|
+
memo_type=MemoType.MESSAGE,
|
108
|
+
is_secured=False,
|
109
|
+
next_phase=AcpJobPhases.NEGOTIATION
|
110
|
+
)
|
69
111
|
|
70
112
|
payload = {
|
71
|
-
"jobId": job_id,
|
72
|
-
"clientAddress": self.
|
113
|
+
"jobId": int(job_id),
|
114
|
+
"clientAddress": self.agent_wallet_address,
|
73
115
|
"providerAddress": provider_address,
|
74
116
|
"description": job_description,
|
75
117
|
"price": price,
|
@@ -90,10 +132,12 @@ class AcpClient:
|
|
90
132
|
|
91
133
|
def response_job(self, job_id: int, accept: bool, memo_id: int, reasoning: str):
|
92
134
|
if accept:
|
93
|
-
|
135
|
+
self.acp_token.sign_memo(memo_id, accept, reasoning)
|
136
|
+
|
137
|
+
time.sleep(5)
|
94
138
|
|
95
139
|
return self.acp_token.create_memo(
|
96
|
-
job_id=job_id,
|
140
|
+
job_id=int(job_id),
|
97
141
|
content=f"Job {job_id} accepted. {reasoning}",
|
98
142
|
memo_type=MemoType.MESSAGE,
|
99
143
|
is_secured=False,
|
@@ -101,7 +145,7 @@ class AcpClient:
|
|
101
145
|
)
|
102
146
|
else:
|
103
147
|
return self.acp_token.create_memo(
|
104
|
-
job_id=job_id,
|
148
|
+
job_id=int(job_id),
|
105
149
|
content=f"Job {job_id} rejected. {reasoning}",
|
106
150
|
memo_type=MemoType.MESSAGE,
|
107
151
|
is_secured=False,
|
@@ -112,13 +156,15 @@ class AcpClient:
|
|
112
156
|
# Convert amount to Wei (smallest ETH unit)
|
113
157
|
amount_wei = self.web3.to_wei(amount, 'ether')
|
114
158
|
|
115
|
-
|
116
|
-
|
159
|
+
self.acp_token.set_budget(job_id, amount_wei)
|
160
|
+
time.sleep(5)
|
161
|
+
self.acp_token.approve_allowance(amount_wei)
|
162
|
+
time.sleep(5)
|
117
163
|
return self.acp_token.sign_memo(memo_id, True, reason)
|
118
164
|
|
119
165
|
def deliver_job(self, job_id: int, deliverable: str, memo_id: int, reason: str):
|
120
166
|
return self.acp_token.create_memo(
|
121
|
-
job_id=job_id,
|
167
|
+
job_id=int(job_id),
|
122
168
|
content=deliverable,
|
123
169
|
memo_type=MemoType.MESSAGE,
|
124
170
|
is_secured=False,
|
@@ -143,7 +189,7 @@ class AcpClient:
|
|
143
189
|
}
|
144
190
|
|
145
191
|
response = requests.post(
|
146
|
-
f"{self.base_url}/{job_id}/tweets/{self.
|
192
|
+
f"{self.base_url}/{job_id}/tweets/{self.agent_wallet_address}",
|
147
193
|
json=payload,
|
148
194
|
headers={
|
149
195
|
"Accept": "application/json",
|
@@ -14,14 +14,14 @@ from .acp_token import AcpToken
|
|
14
14
|
from .interface import AcpJobPhasesDesc, IInventory
|
15
15
|
|
16
16
|
@dataclass
|
17
|
-
class
|
17
|
+
class AcpPluginOptions:
|
18
18
|
api_key: str
|
19
19
|
acp_token_client: AcpToken
|
20
20
|
twitter_plugin: TwitterPlugin | GameTwitterPlugin = None
|
21
21
|
cluster: Optional[str] = None
|
22
22
|
|
23
23
|
class AcpPlugin:
|
24
|
-
def __init__(self, options:
|
24
|
+
def __init__(self, options: AcpPluginOptions):
|
25
25
|
print("Initializing AcpPlugin")
|
26
26
|
self.acp_client = AcpClient(options.api_key, options.acp_token_client)
|
27
27
|
|
@@ -50,7 +50,7 @@ class AcpPlugin:
|
|
50
50
|
self.produced_inventory.append(item)
|
51
51
|
|
52
52
|
def reset_state(self) -> None:
|
53
|
-
self.acp_client.reset_state(self.acp_client.
|
53
|
+
self.acp_client.reset_state(self.acp_client.agent_wallet_address)
|
54
54
|
|
55
55
|
def get_acp_state(self) -> Dict:
|
56
56
|
server_state = self.acp_client.get_state()
|
@@ -100,11 +100,11 @@ class AcpPlugin:
|
|
100
100
|
* phase: request (seller should response to accept/reject to the job) → pending_payment (as a buyer to make the payment for the service) → in_progress (seller to deliver the service) → evaluation → completed/rejected
|
101
101
|
"""
|
102
102
|
|
103
|
-
def _search_agents_executable(self,reasoning: str) -> Tuple[FunctionResultStatus, str, dict]:
|
103
|
+
def _search_agents_executable(self,reasoning: str, keyword: str) -> Tuple[FunctionResultStatus, str, dict]:
|
104
104
|
if not reasoning:
|
105
105
|
return FunctionResultStatus.FAILED, "Reasoning for the search must be provided. This helps track your decision-making process for future reference.", {}
|
106
106
|
|
107
|
-
agents = self.acp_client.browse_agents(self.cluster)
|
107
|
+
agents = self.acp_client.browse_agents(self.cluster, keyword)
|
108
108
|
|
109
109
|
if not agents:
|
110
110
|
return FunctionResultStatus.FAILED, "No other trading agents found in the system. Please try again later when more agents are available.", {}
|
@@ -126,7 +126,12 @@ class AcpPlugin:
|
|
126
126
|
"name": "reasoning",
|
127
127
|
"type": "string",
|
128
128
|
"description": "Explain why you need to find trading partners at this time",
|
129
|
-
}
|
129
|
+
},
|
130
|
+
{
|
131
|
+
"name": "keyword",
|
132
|
+
"type": "string",
|
133
|
+
"description": "Search for agents by name or description. Use this to find specific trading partners or products.",
|
134
|
+
},
|
130
135
|
],
|
131
136
|
executable=self._search_agents_executable
|
132
137
|
)
|
@@ -177,7 +182,6 @@ class AcpPlugin:
|
|
177
182
|
return FunctionResultStatus.FAILED, "You already have an active job as a buyer", {}
|
178
183
|
|
179
184
|
# ... Rest of validation logic ...
|
180
|
-
|
181
185
|
job_id = self.acp_client.create_job(
|
182
186
|
sellerWalletAddress,
|
183
187
|
float(price),
|
@@ -188,7 +192,7 @@ class AcpPlugin:
|
|
188
192
|
post_tweet_fn = self.twitter_plugin.get_function('post_tweet')
|
189
193
|
tweet_id = post_tweet_fn(tweetContent, None).get('data', {}).get('id')
|
190
194
|
if (tweet_id is not None):
|
191
|
-
self.acp_client.add_tweet(job_id,tweet_id, tweetContent)
|
195
|
+
self.acp_client.add_tweet(job_id, tweet_id, tweetContent)
|
192
196
|
print("Tweet has been posted")
|
193
197
|
|
194
198
|
return FunctionResultStatus.DONE, json.dumps({
|