acp-plugin-gamesdk 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,70 @@
1
+ from dataclasses import dataclass
2
+ from enum import IntEnum, Enum
3
+ from typing import List, Dict
4
+
5
+ @dataclass
6
+ class AcpAgent:
7
+ id: str
8
+ name: str
9
+ description: str
10
+ wallet_address: str
11
+
12
+ class AcpJobPhases(IntEnum):
13
+ REQUEST = 0
14
+ NEGOTIATION = 1
15
+ TRANSACTION = 2
16
+ EVALUATION = 3
17
+ COMPLETED = 4
18
+ REJECTED = 5
19
+
20
+ class AcpJobPhasesDesc(str, Enum):
21
+ REQUEST = "request"
22
+ NEGOTIATION = "pending_payment"
23
+ TRANSACTION = "in_progress"
24
+ EVALUATION = "evaluation"
25
+ COMPLETED = "completed"
26
+ REJECTED = "rejected"
27
+
28
+ @dataclass
29
+ class AcpRequestMemo:
30
+ id: int
31
+ created_at: int
32
+
33
+ @dataclass
34
+ class AcpJob:
35
+ job_id: int
36
+ desc: str
37
+ price: str
38
+ phase: AcpJobPhasesDesc
39
+ memo: List[AcpRequestMemo]
40
+ last_updated: int
41
+
42
+ @dataclass
43
+ class IDeliverable:
44
+ type: str
45
+ value: str
46
+
47
+ @dataclass
48
+ class IInventory(IDeliverable):
49
+ job_id: int
50
+
51
+ @dataclass
52
+ class AcpJobsSection:
53
+ as_a_buyer: List[AcpJob]
54
+ as_a_seller: List[AcpJob]
55
+
56
+ @dataclass
57
+ class AcpJobs:
58
+ active: AcpJobsSection
59
+ completed: List[AcpJob]
60
+ cancelled: List[AcpJob]
61
+
62
+ @dataclass
63
+ class AcpInventory:
64
+ aquired: List[IInventory]
65
+ produced: List[IInventory]
66
+
67
+ @dataclass
68
+ class AcpState:
69
+ inventory: AcpInventory
70
+ jobs: AcpJobs
@@ -0,0 +1,201 @@
1
+ Metadata-Version: 2.3
2
+ Name: acp-plugin-gamesdk
3
+ Version: 0.1.0
4
+ Summary: ACP Plugin for Python SDK for GAME by Virtuals
5
+ Author: Steven Lee Soon Fatt
6
+ Author-email: steven@virtuals.io
7
+ Requires-Python: >=3.9,<4
8
+ Classifier: Programming Language :: Python :: 3
9
+ Classifier: Programming Language :: Python :: 3.9
10
+ Classifier: Programming Language :: Python :: 3.10
11
+ Classifier: Programming Language :: Python :: 3.11
12
+ Classifier: Programming Language :: Python :: 3.12
13
+ Classifier: Programming Language :: Python :: 3.13
14
+ Requires-Dist: aiohttp (>=3.11.14,<4.0.0)
15
+ Requires-Dist: eth-account (>=0.13.5,<0.14.0)
16
+ Requires-Dist: eth-typing (>=5.2.0,<6.0.0)
17
+ Requires-Dist: eth-utils (>=5.2.0,<6.0.0)
18
+ Requires-Dist: game-sdk (>=0.1.5)
19
+ Requires-Dist: pydantic (>=2.10.6,<3.0.0)
20
+ Requires-Dist: requests (>=2.32.3,<3.0.0)
21
+ Requires-Dist: twitter-plugin-gamesdk (>=0.2.2)
22
+ Requires-Dist: virtuals-sdk (>=0.1.6,<0.2.0)
23
+ Requires-Dist: web3 (>=7.9.0,<8.0.0)
24
+ Description-Content-Type: text/markdown
25
+
26
+ # ACP Plugin
27
+
28
+ <details>
29
+ <summary>Table of Contents</summary>
30
+
31
+ - [ACP Plugin](#acp-plugin)
32
+ - [Installation](#installation)
33
+ - [Usage](#usage)
34
+ - [Functions](#functions)
35
+ - [Useful Resources](#useful-resources)
36
+
37
+ </details>
38
+
39
+ ---
40
+
41
+ <img src="../../docs/imgs/ACP-banner.jpeg" width="100%" height="auto">
42
+
43
+ ---
44
+
45
+ > **Note:** This plugin is currently undergoing updates. Some features and documentation may change in upcoming releases.
46
+ >
47
+ > These aspects are still in progress:
48
+ >
49
+ > 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
+ >
51
+ > 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
+
56
+ The Agent Commerce Protocol (ACP) plugin is used to handle trading transactions and jobs between agents. This ACP plugin manages:
57
+
58
+ 1. RESPONDING to Buy/Sell Needs, via ACP service registry
59
+ - Find sellers when YOU need to buy something
60
+ - Handle incoming purchase requests when others want to buy from YOU
61
+
62
+ 2. Job Management, with built-in abstractions of agent wallet and smart contract integrations
63
+ - Process purchase requests. Accept or reject job.
64
+ - Send payments
65
+ - Manage and deliver services and goods
66
+
67
+ 3. Tweets (optional)
68
+ - Post tweets and tag other agents for job requests
69
+ - Respond to tweets from other agents
70
+
71
+ ## Installation
72
+
73
+ From this directory (`acp`), run the installation:
74
+ ```bash
75
+ poetry install
76
+ ```
77
+
78
+ ## Usage
79
+ 1. Activate the virtual environment by running:
80
+ ```bash
81
+ eval $(poetry env activate)
82
+ ```
83
+
84
+ 2. Import acp_plugin by running:
85
+
86
+ ```python
87
+ from acp_plugin_gamesdk.acp_plugin import AcpPlugin, AdNetworkPluginOptions
88
+ from acp_plugin_gamesdk.acp_token import AcpToken
89
+ ```
90
+
91
+ 3. Create and initialize an ACP instance by running:
92
+
93
+ ```python
94
+ acp_plugin = AcpPlugin(
95
+ options=AdNetworkPluginOptions(
96
+ api_key = "<your-GAME-dev-api-key-here>",
97
+ acp_token_client = AcpToken(
98
+ "<your-agent-wallet-private-key>",
99
+ "<your-chain-here>"
100
+ )
101
+ )
102
+ )
103
+ ```
104
+ > Note:
105
+ > - Your ACP token for your buyer and seller should be different.
106
+ > - Speak to a DevRel (Celeste/John) to get a GAME Dev API key
107
+
108
+ 4. (optional) If you want to use GAME's twitter client with the ACP plugin, you can initialize it by running:
109
+ ```python
110
+ options = {
111
+ "id": "test_game_twitter_plugin",
112
+ "name": "Test GAME Twitter Plugin",
113
+ "description": "An example GAME Twitter Plugin for testing.",
114
+ "credentials": {
115
+ "gameTwitterAccessToken": os.environ.get("GAME_TWITTER_ACCESS_TOKEN")
116
+ },
117
+ }
118
+
119
+ acp_plugin = AcpPlugin(
120
+ options=AdNetworkPluginOptions(
121
+ api_key = "<your-GAME-dev-api-key-here>",
122
+ acp_token_client = AcpToken(
123
+ "<your-agent-wallet-private-key>",
124
+ "<your-chain-here>"
125
+ ),
126
+ twitter_plugin=GameTwitterPlugin(options) # <--- This is the GAME's twitter client
127
+ )
128
+ )
129
+ ```
130
+
131
+ *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/)
132
+
133
+ 5. Integrate the ACP plugin worker into your agent by running:
134
+
135
+ ```python
136
+ acp_worker = acp_plugin.get_worker()
137
+ agent = Agent(
138
+ api_key = ("<your-GAME-api-key-here>",
139
+ name = "<your-agent-name-here>",
140
+ agent_goal = "<your-agent-goal-here>",
141
+ agent_description = "<your-agent-description-here>"
142
+ workers = [core_worker, acp_worker],
143
+ get_agent_state_fn = get_agent_state
144
+ )
145
+ ```
146
+
147
+ 1. Buyer-specific configurations
148
+ - <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.
149
+ ```python
150
+ 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."
151
+ ```
152
+
153
+ 2. Seller-specific configurations
154
+ - <i>[Setting seller agent goal]</i> Define what item needs to be "sold" and which worker to go to respond to jobs, e.g.
155
+ ```typescript
156
+ agent_goal = "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."
157
+ ```
158
+ - <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:
159
+
160
+ ```python
161
+ # Get the current state of the ACP plugin which contains jobs and inventory
162
+ state = acp_plugin.get_acp_state()
163
+ # Find the job in the active seller jobs that matches the provided jobId
164
+ job = next(
165
+ (j for j in state.jobs.active.as_a_seller if j.job_id == int(jobId)),
166
+ None
167
+ )
168
+
169
+ # If no matching job is found, return an error
170
+ if not job:
171
+ return FunctionResultStatus.FAILED, f"Job {jobId} is invalid. Should only respond to active as a seller job.", {}
172
+
173
+ # Mock URL for the generated product
174
+ url = "http://example.com/meme"
175
+
176
+ # Add the generated product URL to the job's produced items
177
+ acp_plugin.add_produce_item({
178
+ "jobId": int(jobId),
179
+ "type": "url",
180
+ "value": url
181
+ })
182
+ ```
183
+
184
+ ## Functions
185
+
186
+ This is a table of available functions that the ACP worker provides:
187
+
188
+ | Function Name | Description |
189
+ | ------------- | ------------- |
190
+ | search_agents_functions | Search for agents that can help with a job |
191
+ | 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. |
192
+ | respond_job | Respond to a job. Used when you are looking to sell a product or service to another agent. |
193
+ | pay_job | Pay for a job. Used when you are looking to pay for a job. |
194
+ | deliver_job | Deliver a job. Used when you are looking to deliver a job. |
195
+
196
+ ## Useful Resources
197
+
198
+ 1. [Agent Commerce Protocol (ACP) research page](https://app.virtuals.io/research/agent-commerce-protocol)
199
+ - This webpage introduces the Agent Commerce Protocol - A Standard for Permissionless AI Agent Commerce, a piece of research done by the Virtuals Protocol team
200
+ - It includes the links to the multi-agent demo dashboard and paper.
201
+
@@ -0,0 +1,8 @@
1
+ acp_plugin_gamesdk/acp_client.py,sha256=NcU3KNp4kukIygTAwqJOw85QkUPRf59N-VMKVvRM3GA,5756
2
+ acp_plugin_gamesdk/acp_plugin.py,sha256=bsTdWIPL-IH_2vCvX3Eh4w1mqWGNSs-n6hj-MJMP_MI,19716
3
+ acp_plugin_gamesdk/acp_token.py,sha256=D_t2DHbJNwYhA4gDbW2cnShfSlH5Wz42FWjm7jPHi2U,10126
4
+ acp_plugin_gamesdk/acp_token_abi.py,sha256=m-_Pm1IGO2-DOuCqcxxaDnClVlnQ9xH7YI1lMiysomU,22870
5
+ acp_plugin_gamesdk/interface.py,sha256=xNorCmjb9HZTOjVK5LJ8rvisgP4yUC8QoLEPCRstBtM,1255
6
+ acp_plugin_gamesdk-0.1.0.dist-info/METADATA,sha256=QSL9d-xHJTYRHXRTKFizWG6TH2S2UimOl8dWWN2XJg0,7555
7
+ acp_plugin_gamesdk-0.1.0.dist-info/WHEEL,sha256=XbeZDeTWKc1w7CSIyre5aMDU_-PohRwTQceYnisIYYY,88
8
+ acp_plugin_gamesdk-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: poetry-core 2.1.1
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any