mech-client 0.7.0__tar.gz → 0.8.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.
Files changed (77) hide show
  1. {mech_client-0.7.0 → mech_client-0.8.0}/PKG-INFO +81 -2
  2. {mech_client-0.7.0 → mech_client-0.8.0}/README.md +80 -1
  3. mech_client-0.8.0/mech_client/__init__.py +3 -0
  4. mech_client-0.8.0/mech_client/abis/ComplementaryServiceMetadata.json +185 -0
  5. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/cli.py +92 -0
  6. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/configs/mechs.json +6 -0
  7. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/interact.py +1 -0
  8. mech_client-0.8.0/mech_client/mech_marketplace_tool_management.py +223 -0
  9. {mech_client-0.7.0 → mech_client-0.8.0}/pyproject.toml +1 -1
  10. mech_client-0.7.0/mech_client/__init__.py +0 -3
  11. {mech_client-0.7.0 → mech_client-0.8.0}/LICENSE +0 -0
  12. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/AgentMech.json +0 -0
  13. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/AgentRegistry.json +0 -0
  14. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/AgreementStoreManager.base.json +0 -0
  15. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/AgreementStoreManager.gnosis.json +0 -0
  16. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/BalanceTrackerFixedPriceNative.json +0 -0
  17. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/BalanceTrackerFixedPriceToken.json +0 -0
  18. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/BalanceTrackerNvmSubscriptionNative.json +0 -0
  19. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/BalanceTrackerNvmSubscriptionToken.json +0 -0
  20. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/DIDRegistry.base.json +0 -0
  21. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/DIDRegistry.gnosis.json +0 -0
  22. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/EscrowPaymentCondition.base.json +0 -0
  23. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/EscrowPaymentCondition.gnosis.json +0 -0
  24. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/IERC1155.json +0 -0
  25. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/IMech.json +0 -0
  26. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/IToken.json +0 -0
  27. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/LockPaymentCondition.base.json +0 -0
  28. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/LockPaymentCondition.gnosis.json +0 -0
  29. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/MechMarketplace.json +0 -0
  30. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/NFTSalesTemplate.base.json +0 -0
  31. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/NFTSalesTemplate.gnosis.json +0 -0
  32. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/NeverminedConfig.base.json +0 -0
  33. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/NeverminedConfig.gnosis.json +0 -0
  34. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/SubscriptionNFT.base.json +0 -0
  35. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/SubscriptionNFT.gnosis.json +0 -0
  36. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/SubscriptionProvider.base.json +0 -0
  37. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/SubscriptionProvider.gnosis.json +0 -0
  38. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/SubscriptionToken.base.json +0 -0
  39. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/TransferNFTCondition.base.json +0 -0
  40. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/abis/TransferNFTCondition.gnosis.json +0 -0
  41. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/acn.py +0 -0
  42. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/fetch_ipfs_hash.py +0 -0
  43. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/__init__.py +0 -0
  44. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/README.md +0 -0
  45. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/__init__.py +0 -0
  46. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/acn.proto +0 -0
  47. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/acn_pb2.py +0 -0
  48. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/custom_types.py +0 -0
  49. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/dialogues.py +0 -0
  50. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/message.py +0 -0
  51. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/protocol.yaml +0 -0
  52. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/serialization.py +0 -0
  53. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/tests/__init__.py +0 -0
  54. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/tests/test_acn.py +0 -0
  55. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/tests/test_acn_dialogues.py +0 -0
  56. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn/tests/test_acn_messages.py +0 -0
  57. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/README.md +0 -0
  58. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/__init__.py +0 -0
  59. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/acn_data_share.proto +0 -0
  60. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/acn_data_share_pb2.py +0 -0
  61. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/dialogues.py +0 -0
  62. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/message.py +0 -0
  63. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/protocol.yaml +0 -0
  64. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/serialization.py +0 -0
  65. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_dialogues.py +0 -0
  66. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/acn_data_share/tests/test_acn_data_share_messages.py +0 -0
  67. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/p2p_libp2p_client/README.md +0 -0
  68. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/p2p_libp2p_client/__init__.py +0 -0
  69. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/p2p_libp2p_client/connection.py +0 -0
  70. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/helpers/p2p_libp2p_client/connection.yaml +0 -0
  71. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/marketplace_interact.py +0 -0
  72. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/mech_tool_management.py +0 -0
  73. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/prompt_to_ipfs.py +0 -0
  74. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/push_to_ipfs.py +0 -0
  75. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/subgraph.py +0 -0
  76. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/to_png.py +0 -0
  77. {mech_client-0.7.0 → mech_client-0.8.0}/mech_client/wss.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: mech-client
3
- Version: 0.7.0
3
+ Version: 0.8.0
4
4
  Summary: Basic client to interact with a mech
5
5
  License: Apache-2.0
6
6
  Author: David Minarsch
@@ -251,8 +251,9 @@ mechx interact --prompts <prompt-1> --prompts <prompt-2> --priority-mech <priori
251
251
  ```
252
252
 
253
253
 
254
- ### List tools available for agents
254
+ ### List tools available for legacy mechs and marketplace mechs
255
255
 
256
+ #### For legacy mechs
256
257
  To list the tools available for a specific agent or for all agents, use the `tools-for-agents` command. You can specify an agent ID to get tools for a specific agent, or omit it to list tools for all agents.
257
258
 
258
259
  ```bash
@@ -293,8 +294,28 @@ You will see an output like this:
293
294
  +---------------------------------------------+-----------------------------------------------+
294
295
  ```
295
296
 
297
+ #### For marketplace mechs
298
+ To list the tools available for a specific marketplace mech, use the `tools-for-marketplace-mech` command. You can specify a service ID to get tools for a specific mech.
299
+
300
+ ```bash
301
+ mechx tools-for-marketplace-mech 1722 --chain-config gnosis
302
+ ```
303
+ ```bash
304
+ You will see an output like this:
305
+ +---------------------------------------------+-----------------------------------------------+
306
+ | Tool Name | Unique Identifier |
307
+ +=============================================+===============================================+
308
+ | claude-prediction-offline | 1722-claude-prediction-offline |
309
+ +---------------------------------------------+-----------------------------------------------+
310
+ | claude-prediction-online | 1722-claude-prediction-online |
311
+ +---------------------------------------------+-----------------------------------------------+
312
+ | deepmind-optimization | 1722-deepmind-optimization |
313
+ +---------------------------------------------+-----------------------------------------------+
314
+ ```
315
+
296
316
  ### Get Tool Description
297
317
 
318
+ #### For legacy mechs
298
319
  To get the description of a specific tool, use the `tool-description` command. You need to specify the unique identifier of the tool.
299
320
 
300
321
  ```bash
@@ -310,9 +331,26 @@ You will see an output like this:
310
331
  Description for tool 6-claude-prediction-offline: Makes a prediction using Claude
311
332
  ```
312
333
 
334
+ #### For marketplace mechs
335
+ To get the description of a specific tool, use the ` tool-description-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
336
+
337
+ ```bash
338
+ mechx tool-description-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
339
+ ```
340
+ Example usage:
341
+
342
+ ```bash
343
+ mechx tool-description-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
344
+ ```
345
+ You will see an output like this:
346
+ ```bash
347
+ Description for tool 1722-openai-gpt-4: Performs a request to OpenAI's GPT-4 model.
348
+ ```
349
+
313
350
 
314
351
  ### Get Tool Input/Output Schema
315
352
 
353
+ #### For legacy mechs
316
354
  To get the input/output schema of a specific tool, use the `tool_io_schema` command. You need to specify the unique identifier of the tool.
317
355
 
318
356
  ```bash
@@ -352,6 +390,47 @@ Output Schema:
352
390
  +-----------+---------+-----------------------------------------------+
353
391
  ```
354
392
 
393
+ #### For marketplace mechs
394
+ To get the input/output schema of a specific tool, use the `tool-io-schema-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
395
+
396
+ ```bash
397
+ mechx tool-io-schema-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
398
+ ```
399
+
400
+ Example usage:
401
+
402
+ ```bash
403
+ mechx tool-io-schema-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
404
+ ```
405
+ You will see an output like this:
406
+ ```bash
407
+ Tool Details:
408
+ Tool Details:
409
+ +------------------------+---------------------------------------------+
410
+ | Tool Name | Tool Description |
411
+ +========================+=============================================+
412
+ | OpenAI Request (GPT-4) | Performs a request to OpenAI's GPT-4 model. |
413
+ +------------------------+---------------------------------------------+
414
+ Input Schema:
415
+ +-------------+-----------------------------------------------+
416
+ | Field | Value |
417
+ +=============+===============================================+
418
+ | type | text |
419
+ +-------------+-----------------------------------------------+
420
+ | description | The request to relay to OpenAI's GPT-4 model. |
421
+ +-------------+-----------------------------------------------+
422
+ Output Schema:
423
+ +-----------+---------+-----------------------------------+
424
+ | Field | Type | Description |
425
+ +===========+=========+===================================+
426
+ | requestId | integer | Unique identifier for the request |
427
+ +-----------+---------+-----------------------------------+
428
+ | result | string | Response from OpenAI |
429
+ +-----------+---------+-----------------------------------+
430
+ | prompt | string | User prompt to send to OpenAI |
431
+ +-----------+---------+-----------------------------------+
432
+ ```
433
+
355
434
  > **:pencil2: Note** <br />
356
435
  > **If you encounter an "Out of gas" error when executing the Mech Client, you will need to increase the gas limit, e.g.,**
357
436
  >
@@ -228,8 +228,9 @@ mechx interact --prompts <prompt-1> --prompts <prompt-2> --priority-mech <priori
228
228
  ```
229
229
 
230
230
 
231
- ### List tools available for agents
231
+ ### List tools available for legacy mechs and marketplace mechs
232
232
 
233
+ #### For legacy mechs
233
234
  To list the tools available for a specific agent or for all agents, use the `tools-for-agents` command. You can specify an agent ID to get tools for a specific agent, or omit it to list tools for all agents.
234
235
 
235
236
  ```bash
@@ -270,8 +271,28 @@ You will see an output like this:
270
271
  +---------------------------------------------+-----------------------------------------------+
271
272
  ```
272
273
 
274
+ #### For marketplace mechs
275
+ To list the tools available for a specific marketplace mech, use the `tools-for-marketplace-mech` command. You can specify a service ID to get tools for a specific mech.
276
+
277
+ ```bash
278
+ mechx tools-for-marketplace-mech 1722 --chain-config gnosis
279
+ ```
280
+ ```bash
281
+ You will see an output like this:
282
+ +---------------------------------------------+-----------------------------------------------+
283
+ | Tool Name | Unique Identifier |
284
+ +=============================================+===============================================+
285
+ | claude-prediction-offline | 1722-claude-prediction-offline |
286
+ +---------------------------------------------+-----------------------------------------------+
287
+ | claude-prediction-online | 1722-claude-prediction-online |
288
+ +---------------------------------------------+-----------------------------------------------+
289
+ | deepmind-optimization | 1722-deepmind-optimization |
290
+ +---------------------------------------------+-----------------------------------------------+
291
+ ```
292
+
273
293
  ### Get Tool Description
274
294
 
295
+ #### For legacy mechs
275
296
  To get the description of a specific tool, use the `tool-description` command. You need to specify the unique identifier of the tool.
276
297
 
277
298
  ```bash
@@ -287,9 +308,26 @@ You will see an output like this:
287
308
  Description for tool 6-claude-prediction-offline: Makes a prediction using Claude
288
309
  ```
289
310
 
311
+ #### For marketplace mechs
312
+ To get the description of a specific tool, use the ` tool-description-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
313
+
314
+ ```bash
315
+ mechx tool-description-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
316
+ ```
317
+ Example usage:
318
+
319
+ ```bash
320
+ mechx tool-description-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
321
+ ```
322
+ You will see an output like this:
323
+ ```bash
324
+ Description for tool 1722-openai-gpt-4: Performs a request to OpenAI's GPT-4 model.
325
+ ```
326
+
290
327
 
291
328
  ### Get Tool Input/Output Schema
292
329
 
330
+ #### For legacy mechs
293
331
  To get the input/output schema of a specific tool, use the `tool_io_schema` command. You need to specify the unique identifier of the tool.
294
332
 
295
333
  ```bash
@@ -329,6 +367,47 @@ Output Schema:
329
367
  +-----------+---------+-----------------------------------------------+
330
368
  ```
331
369
 
370
+ #### For marketplace mechs
371
+ To get the input/output schema of a specific tool, use the `tool-io-schema-for-marketplace-mech` command. You need to specify the unique identifier of the tool.
372
+
373
+ ```bash
374
+ mechx tool-io-schema-for-marketplace-mech <unique_identifier> --chain-config <chain_config>
375
+ ```
376
+
377
+ Example usage:
378
+
379
+ ```bash
380
+ mechx tool-io-schema-for-marketplace-mech 1722-openai-gpt-4 --chain-config gnosis
381
+ ```
382
+ You will see an output like this:
383
+ ```bash
384
+ Tool Details:
385
+ Tool Details:
386
+ +------------------------+---------------------------------------------+
387
+ | Tool Name | Tool Description |
388
+ +========================+=============================================+
389
+ | OpenAI Request (GPT-4) | Performs a request to OpenAI's GPT-4 model. |
390
+ +------------------------+---------------------------------------------+
391
+ Input Schema:
392
+ +-------------+-----------------------------------------------+
393
+ | Field | Value |
394
+ +=============+===============================================+
395
+ | type | text |
396
+ +-------------+-----------------------------------------------+
397
+ | description | The request to relay to OpenAI's GPT-4 model. |
398
+ +-------------+-----------------------------------------------+
399
+ Output Schema:
400
+ +-----------+---------+-----------------------------------+
401
+ | Field | Type | Description |
402
+ +===========+=========+===================================+
403
+ | requestId | integer | Unique identifier for the request |
404
+ +-----------+---------+-----------------------------------+
405
+ | result | string | Response from OpenAI |
406
+ +-----------+---------+-----------------------------------+
407
+ | prompt | string | User prompt to send to OpenAI |
408
+ +-----------+---------+-----------------------------------+
409
+ ```
410
+
332
411
  > **:pencil2: Note** <br />
333
412
  > **If you encounter an "Out of gas" error when executing the Mech Client, you will need to increase the gas limit, e.g.,**
334
413
  >
@@ -0,0 +1,3 @@
1
+ """Mech client."""
2
+
3
+ __version__ = "0.8.0"
@@ -0,0 +1,185 @@
1
+ [
2
+ {
3
+ "inputs": [
4
+ {
5
+ "internalType": "address",
6
+ "name": "_serviceRegistry",
7
+ "type": "address"
8
+ }
9
+ ],
10
+ "stateMutability": "nonpayable",
11
+ "type": "constructor"
12
+ },
13
+ {
14
+ "inputs": [],
15
+ "name": "ReentrancyGuard",
16
+ "type": "error"
17
+ },
18
+ {
19
+ "inputs": [
20
+ {
21
+ "internalType": "address",
22
+ "name": "account",
23
+ "type": "address"
24
+ }
25
+ ],
26
+ "name": "UnauthorizedAccount",
27
+ "type": "error"
28
+ },
29
+ {
30
+ "inputs": [],
31
+ "name": "ZeroAddress",
32
+ "type": "error"
33
+ },
34
+ {
35
+ "anonymous": false,
36
+ "inputs": [
37
+ {
38
+ "indexed": true,
39
+ "internalType": "uint256",
40
+ "name": "serviceId",
41
+ "type": "uint256"
42
+ },
43
+ {
44
+ "indexed": true,
45
+ "internalType": "bytes32",
46
+ "name": "hash",
47
+ "type": "bytes32"
48
+ }
49
+ ],
50
+ "name": "ComplementaryMetadataUpdated",
51
+ "type": "event"
52
+ },
53
+ {
54
+ "inputs": [],
55
+ "name": "CID_PREFIX",
56
+ "outputs": [
57
+ {
58
+ "internalType": "string",
59
+ "name": "",
60
+ "type": "string"
61
+ }
62
+ ],
63
+ "stateMutability": "view",
64
+ "type": "function"
65
+ },
66
+ {
67
+ "inputs": [],
68
+ "name": "VERSION",
69
+ "outputs": [
70
+ {
71
+ "internalType": "string",
72
+ "name": "",
73
+ "type": "string"
74
+ }
75
+ ],
76
+ "stateMutability": "view",
77
+ "type": "function"
78
+ },
79
+ {
80
+ "inputs": [],
81
+ "name": "baseURI",
82
+ "outputs": [
83
+ {
84
+ "internalType": "string",
85
+ "name": "",
86
+ "type": "string"
87
+ }
88
+ ],
89
+ "stateMutability": "view",
90
+ "type": "function"
91
+ },
92
+ {
93
+ "inputs": [
94
+ {
95
+ "internalType": "uint256",
96
+ "name": "serviceId",
97
+ "type": "uint256"
98
+ },
99
+ {
100
+ "internalType": "bytes32",
101
+ "name": "hash",
102
+ "type": "bytes32"
103
+ }
104
+ ],
105
+ "name": "changeHash",
106
+ "outputs": [],
107
+ "stateMutability": "nonpayable",
108
+ "type": "function"
109
+ },
110
+ {
111
+ "inputs": [
112
+ {
113
+ "internalType": "address",
114
+ "name": "account",
115
+ "type": "address"
116
+ },
117
+ {
118
+ "internalType": "uint256",
119
+ "name": "serviceId",
120
+ "type": "uint256"
121
+ }
122
+ ],
123
+ "name": "isAbleChangeHash",
124
+ "outputs": [
125
+ {
126
+ "internalType": "bool",
127
+ "name": "",
128
+ "type": "bool"
129
+ }
130
+ ],
131
+ "stateMutability": "view",
132
+ "type": "function"
133
+ },
134
+ {
135
+ "inputs": [
136
+ {
137
+ "internalType": "uint256",
138
+ "name": "",
139
+ "type": "uint256"
140
+ }
141
+ ],
142
+ "name": "mapServiceHashes",
143
+ "outputs": [
144
+ {
145
+ "internalType": "bytes32",
146
+ "name": "",
147
+ "type": "bytes32"
148
+ }
149
+ ],
150
+ "stateMutability": "view",
151
+ "type": "function"
152
+ },
153
+ {
154
+ "inputs": [],
155
+ "name": "serviceRegistry",
156
+ "outputs": [
157
+ {
158
+ "internalType": "address",
159
+ "name": "",
160
+ "type": "address"
161
+ }
162
+ ],
163
+ "stateMutability": "view",
164
+ "type": "function"
165
+ },
166
+ {
167
+ "inputs": [
168
+ {
169
+ "internalType": "uint256",
170
+ "name": "serviceId",
171
+ "type": "uint256"
172
+ }
173
+ ],
174
+ "name": "tokenURI",
175
+ "outputs": [
176
+ {
177
+ "internalType": "string",
178
+ "name": "",
179
+ "type": "string"
180
+ }
181
+ ],
182
+ "stateMutability": "view",
183
+ "type": "function"
184
+ }
185
+ ]
@@ -31,6 +31,17 @@ from mech_client.interact import interact as interact_
31
31
  from mech_client.marketplace_interact import (
32
32
  marketplace_interact as marketplace_interact_,
33
33
  )
34
+ from mech_client.mech_marketplace_tool_management import (
35
+ extract_input_schema,
36
+ extract_output_schema,
37
+ )
38
+ from mech_client.mech_marketplace_tool_management import (
39
+ get_tool_description as get_tool_description_for_marketplace_mech,
40
+ )
41
+ from mech_client.mech_marketplace_tool_management import (
42
+ get_tool_io_schema as get_tool_io_schema_for_marketplace_mech,
43
+ )
44
+ from mech_client.mech_marketplace_tool_management import get_tools_for_marketplace_mech
34
45
  from mech_client.mech_tool_management import (
35
46
  get_tool_description,
36
47
  get_tool_io_schema,
@@ -353,6 +364,84 @@ def tool_io_schema(tool_id: str, chain_config: str) -> None:
353
364
  click.echo(f"Network or I/O error: {str(e)}")
354
365
 
355
366
 
367
+ @click.command(name="tools-for-marketplace-mech")
368
+ @click.argument(
369
+ "service-id",
370
+ type=int,
371
+ )
372
+ @click.option("--chain-config", default="gnosis", help="Chain configuration to use.")
373
+ def tools_for_marketplace_mech(service_id: int, chain_config: str) -> None:
374
+ """Fetch and display tools for marketplace mechs."""
375
+ try:
376
+ result = get_tools_for_marketplace_mech(service_id, chain_config)
377
+
378
+ headers = ["Tool Name", "Unique Identifier"]
379
+ data: List[Tuple[str, ...]] = [
380
+ (
381
+ str(tool.tool_name),
382
+ str(tool.unique_identifier),
383
+ )
384
+ for tool in result.tools
385
+ ]
386
+
387
+ click.echo(tabulate(data, headers=headers, tablefmt="grid"))
388
+
389
+ except (KeyError, TypeError) as e:
390
+ click.echo(f"Error processing tool data: {str(e)}")
391
+ except IOError as e:
392
+ click.echo(f"Network or I/O error: {str(e)}")
393
+
394
+
395
+ @click.command(name="tool-description-for-marketplace-mech")
396
+ @click.argument("tool_id")
397
+ @click.option("--chain-config", default="gnosis", help="Chain configuration to use.")
398
+ def tool_description_for_marketplace_mech(tool_id: str, chain_config: str) -> None:
399
+ """Fetch and display the description of a specific tool for marketplace mechs."""
400
+ try:
401
+ description = get_tool_description_for_marketplace_mech(tool_id, chain_config)
402
+ click.echo(f"Description for tool {tool_id}: {description}")
403
+ except KeyError as e:
404
+ click.echo(f"Tool not found or missing description: {str(e)}")
405
+ except IOError as e:
406
+ click.echo(f"Network or I/O error: {str(e)}")
407
+
408
+
409
+ @click.command(name="tool-io-schema-for-marketplace-mech")
410
+ @click.argument("tool_id")
411
+ @click.option("--chain-config", default="gnosis", help="Chain configuration to use.")
412
+ def tool_io_schema_for_marketplace_mech(tool_id: str, chain_config: str) -> None:
413
+ """Fetch and display the tool's name and description along with the input/output schema for a specific tool for marketplace mechs."""
414
+ try:
415
+ result = get_tool_io_schema_for_marketplace_mech(tool_id, chain_config)
416
+
417
+ name = result["name"]
418
+ description = result["description"]
419
+ input_schema = extract_input_schema(result["input"])
420
+ output_schema = extract_output_schema(result["output"])
421
+
422
+ click.echo("Tool Details:")
423
+ click.echo(
424
+ tabulate(
425
+ [[name, description]],
426
+ headers=["Tool Name", "Tool Description"],
427
+ tablefmt="grid",
428
+ )
429
+ )
430
+
431
+ click.echo("Input Schema:")
432
+ click.echo(tabulate(input_schema, headers=["Field", "Value"], tablefmt="grid"))
433
+ click.echo("Output Schema:")
434
+ click.echo(
435
+ tabulate(
436
+ output_schema, headers=["Field", "Type", "Description"], tablefmt="grid"
437
+ )
438
+ )
439
+ except KeyError as e:
440
+ click.echo(f"Error accessing schema data: {str(e)}")
441
+ except IOError as e:
442
+ click.echo(f"Network or I/O error: {str(e)}")
443
+
444
+
356
445
  @click.command(name="deposit-native")
357
446
  @click.argument("amount_to_deposit")
358
447
  @click.option(
@@ -423,8 +512,11 @@ cli.add_command(prompt_to_ipfs)
423
512
  cli.add_command(push_to_ipfs)
424
513
  cli.add_command(to_png)
425
514
  cli.add_command(tools_for_agents)
515
+ cli.add_command(tools_for_marketplace_mech)
426
516
  cli.add_command(tool_io_schema)
517
+ cli.add_command(tool_io_schema_for_marketplace_mech)
427
518
  cli.add_command(tool_description)
519
+ cli.add_command(tool_description_for_marketplace_mech)
428
520
  cli.add_command(deposit_native)
429
521
  cli.add_command(deposit_token)
430
522
  cli.add_command(nvm_subscribe)
@@ -3,6 +3,7 @@
3
3
  "agent_registry_contract": "0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA",
4
4
  "service_registry_contract": "0x9338b5153AE39BB89f50468E608eD9d764B755fD",
5
5
  "mech_marketplace_contract": "0x735FAAb1c4Ec41128c367AFb5c3baC73509f70bB",
6
+ "complementary_metadata_hash_address": "0x0598081D48FB80B0A7E52FAD2905AE9beCd6fC69",
6
7
  "rpc_url": "https://rpc.eu-central-2.gateway.fm/v4/gnosis/non-archival/mainnet",
7
8
  "wss_endpoint": "wss://rpc.gnosischain.com/wss",
8
9
  "ledger_config": {
@@ -21,6 +22,7 @@
21
22
  "agent_registry_contract": "0xa4799B083E0068732456EF45ff9fe5c683658327",
22
23
  "service_registry_contract": "0xE3607b00E75f6405248323A9417ff6b39B244b50",
23
24
  "mech_marketplace_contract": "0x0000000000000000000000000000000000000000",
25
+ "complementary_metadata_hash_address": "0x0000000000000000000000000000000000000000",
24
26
  "rpc_url": "https://arbitrum.llamarpc.com",
25
27
  "wss_endpoint": "wss://arbitrum.gateway.tenderly.co",
26
28
  "ledger_config": {
@@ -39,6 +41,7 @@
39
41
  "agent_registry_contract": "0x984cf72FDe8B5aA910e9e508aC5e007ae5BDcC9C",
40
42
  "service_registry_contract": "0xE3607b00E75f6405248323A9417ff6b39B244b50",
41
43
  "mech_marketplace_contract": "0x0000000000000000000000000000000000000000",
44
+ "complementary_metadata_hash_address": "0x0000000000000000000000000000000000000000",
42
45
  "rpc_url": "https://polygon-bor-rpc.publicnode.com",
43
46
  "wss_endpoint": "wss://polygon.gateway.tenderly.co",
44
47
  "ledger_config": {
@@ -57,6 +60,7 @@
57
60
  "agent_registry_contract": "0x88DE734655184a09B70700aE4F72364d1ad23728",
58
61
  "service_registry_contract": "0x3C1fF68f5aa342D296d4DEe4Bb1cACCA912D95fE",
59
62
  "mech_marketplace_contract": "0xf24eE42edA0fc9b33B7D41B06Ee8ccD2Ef7C5020",
63
+ "complementary_metadata_hash_address": "0x28C1edC7CEd549F7f80B732fDC19f0370160707d",
60
64
  "rpc_url": "https://base.llamarpc.com",
61
65
  "wss_endpoint": "wss://base.gateway.tenderly.co",
62
66
  "ledger_config": {
@@ -75,6 +79,7 @@
75
79
  "agent_registry_contract": "0xE49CB081e8d96920C38aA7AB90cb0294ab4Bc8EA",
76
80
  "service_registry_contract": "0xE3607b00E75f6405248323A9417ff6b39B244b50",
77
81
  "mech_marketplace_contract": "0x0000000000000000000000000000000000000000",
82
+ "complementary_metadata_hash_address": "0x0000000000000000000000000000000000000000",
78
83
  "rpc_url": "https://forno.celo.org",
79
84
  "wss_endpoint": "wss://forno.celo.org/ws",
80
85
  "ledger_config": {
@@ -93,6 +98,7 @@
93
98
  "agent_registry_contract": "0x75D529FAe220bC8db714F0202193726b46881B76",
94
99
  "service_registry_contract": "0x3d77596beb0f130a4415df3D2D8232B3d3D31e44",
95
100
  "mech_marketplace_contract": "0x0000000000000000000000000000000000000000",
101
+ "complementary_metadata_hash_address": "0x0000000000000000000000000000000000000000",
96
102
  "rpc_url": "https://mainnet.optimism.io",
97
103
  "wss_endpoint": "wss://optimism.gateway.tenderly.co",
98
104
  "ledger_config": {
@@ -120,6 +120,7 @@ class MechConfig: # pylint: disable=too-many-instance-attributes
120
120
 
121
121
  agent_registry_contract: str
122
122
  service_registry_contract: str
123
+ complementary_metadata_hash_address: str
123
124
  rpc_url: str
124
125
  wss_endpoint: str
125
126
  ledger_config: LedgerConfig
@@ -0,0 +1,223 @@
1
+ """Module for managing mechanical tools and their interactions with blockchain."""
2
+
3
+ import json
4
+ from dataclasses import asdict, dataclass
5
+ from pathlib import Path
6
+ from typing import Any, Dict, List, Optional, Tuple
7
+
8
+ import requests
9
+ from aea_ledger_ethereum import EthereumApi
10
+
11
+ from mech_client.marketplace_interact import ADDRESS_ZERO, get_contract, get_mech_config
12
+
13
+
14
+ ABI_DIR_PATH = Path(__file__).parent / "abis"
15
+ COMPLEMENTARY_METADATA_HASH_ABI_PATH = (
16
+ ABI_DIR_PATH / "ComplementaryServiceMetadata.json"
17
+ )
18
+ ENCODING = "utf-8"
19
+ DEFAULT_TIMEOUT = 10
20
+ TOOLS = "tools"
21
+ TOOL_METADATA = "toolMetadata"
22
+ DEFAULT_CONFIG = "gnosis"
23
+
24
+
25
+ @dataclass
26
+ class ToolInfo:
27
+ """Tool info"""
28
+
29
+ tool_name: str
30
+ unique_identifier: str
31
+
32
+
33
+ @dataclass
34
+ class ToolsForMarketplaceMech:
35
+ """Tools info list"""
36
+
37
+ service_id: int
38
+ tools: List[ToolInfo]
39
+
40
+
41
+ def fetch_tools(
42
+ service_id: int,
43
+ ledger_api: EthereumApi,
44
+ complementary_metadata_hash_address: str,
45
+ contract_abi_path: Path,
46
+ ) -> Dict[str, Any]:
47
+ """Fetch tools for specified mech's service ID."""
48
+ with open(contract_abi_path, encoding=ENCODING) as f:
49
+ abi = json.load(f)
50
+
51
+ metadata_contract = get_contract(
52
+ contract_address=complementary_metadata_hash_address,
53
+ abi=abi,
54
+ ledger_api=ledger_api,
55
+ )
56
+ metadata_uri = metadata_contract.functions.tokenURI(service_id).call()
57
+ return requests.get(metadata_uri, timeout=DEFAULT_TIMEOUT).json()
58
+
59
+
60
+ def get_mech_tools(
61
+ service_id: int, chain_config: str = DEFAULT_CONFIG
62
+ ) -> Optional[Dict[str, Any]]:
63
+ """
64
+ Fetch tools for a given mech's service ID.
65
+
66
+ :param service_id: The service ID of the mech.
67
+ :param chain_config: The chain configuration to use (default is "gnosis").
68
+ :return: A dictionary containing the JSON response from the `tokenURI` contract call, typically including tools and metadata.
69
+ """
70
+ # Get the mech configuration
71
+ mech_config = get_mech_config(chain_config)
72
+ ledger_config = mech_config.ledger_config
73
+
74
+ # Setup Ethereum API
75
+ ledger_api = EthereumApi(**asdict(ledger_config))
76
+
77
+ if mech_config.complementary_metadata_hash_address == ADDRESS_ZERO:
78
+ print(f"Metadata hash not yet implemented on {chain_config}")
79
+ return None
80
+
81
+ try:
82
+ # Fetch tools for the given mech's service ID
83
+ return fetch_tools(
84
+ service_id=service_id,
85
+ ledger_api=ledger_api,
86
+ complementary_metadata_hash_address=mech_config.complementary_metadata_hash_address,
87
+ contract_abi_path=COMPLEMENTARY_METADATA_HASH_ABI_PATH,
88
+ )
89
+ except (json.JSONDecodeError, NotImplementedError) as e:
90
+ print(f"An error occurred while fetching tools for mech with {service_id}: {e}")
91
+ return None
92
+
93
+
94
+ def get_tools_for_marketplace_mech(
95
+ service_id: int, chain_config: str = DEFAULT_CONFIG
96
+ ) -> ToolsForMarketplaceMech:
97
+ """
98
+ Retrieve tools for specified mech's service id.
99
+
100
+ :param service_id: specific mech's service ID to fetch tools for.
101
+ :param chain_config: The chain configuration to use.
102
+ :return: Dictionary of tools with identifiers or a mapping of service IDs to tools.
103
+ """
104
+ empty_response = ToolsForMarketplaceMech(service_id=service_id, tools=[])
105
+
106
+ try:
107
+ result = get_mech_tools(service_id, chain_config)
108
+ if result is None:
109
+ return empty_response
110
+
111
+ tools = result.get(TOOLS, [])
112
+ tool_metadata = result.get(TOOL_METADATA, {})
113
+ if not isinstance(tools, list) or not isinstance(tool_metadata, dict):
114
+ return empty_response
115
+
116
+ tools_with_ids = [
117
+ ToolInfo(tool_name=tool, unique_identifier=f"{service_id}-{tool}")
118
+ for tool in tools
119
+ ]
120
+ return ToolsForMarketplaceMech(service_id=service_id, tools=tools_with_ids)
121
+
122
+ except (json.JSONDecodeError, NotImplementedError) as e:
123
+ print(f"Error in get_tools_for_marketplace_mech: {str(e)}")
124
+ raise
125
+
126
+
127
+ def get_tool_description(
128
+ unique_identifier: str, chain_config: str = DEFAULT_CONFIG
129
+ ) -> str:
130
+ """
131
+ Fetch the description of a specific tool based on a unique identifier.
132
+
133
+ :param unique_identifier: The unique identifier for the tool.
134
+ :param chain_config: The chain configuration to use.
135
+ :return: Description of the tool or a default message if not available.
136
+ """
137
+ default_response = "Description not available"
138
+
139
+ _, tool_info = _get_tool_metadata(unique_identifier, chain_config)
140
+ return (
141
+ tool_info.get("description", default_response)
142
+ if tool_info
143
+ else default_response
144
+ )
145
+
146
+
147
+ def get_tool_io_schema(
148
+ unique_identifier: str, chain_config: str = DEFAULT_CONFIG
149
+ ) -> Dict[str, Any]:
150
+ """
151
+ Fetch the input and output schema along with tool name and description of a specific tool based on a unique identifier.
152
+
153
+ :param unique_identifier: The unique identifier for the tool.
154
+ :param chain_config: The chain configuration to use.
155
+ :return: Dictionary containing name, description, input and output schemas.
156
+ """
157
+ _, tool_info = _get_tool_metadata(unique_identifier, chain_config)
158
+ if tool_info:
159
+ return {
160
+ "name": tool_info.get("name", {}),
161
+ "description": tool_info.get("description", {}),
162
+ "input": tool_info.get("input", {}),
163
+ "output": tool_info.get("output", {}),
164
+ }
165
+
166
+ return {"input": {}, "output": {}}
167
+
168
+
169
+ def _get_tool_metadata(
170
+ unique_identifier: str, chain_config: str = DEFAULT_CONFIG
171
+ ) -> Tuple[str, Optional[Dict[str, Any]]]:
172
+ """
173
+ Helper function to extract tool metadata from the chain config and unique identifier.
174
+
175
+ :param unique_identifier: The unique identifier in the format "<service_id>-<tool_name>".
176
+ :param chain_config: The chain configuration to use.
177
+ :return: Tuple of tool name and its metadata dictionary (or None if not found).
178
+ """
179
+ service_id_str, *tool_parts = unique_identifier.split("-")
180
+ try:
181
+ service_id = int(service_id_str)
182
+ except ValueError as exc:
183
+ raise ValueError(
184
+ f"Unexpected unique identifier format: {unique_identifier}"
185
+ ) from exc
186
+ tool_name = "-".join(tool_parts)
187
+
188
+ result = get_mech_tools(service_id, chain_config)
189
+
190
+ if isinstance(result, dict):
191
+ tool_metadata = result.get(TOOL_METADATA, {})
192
+ tool_info = tool_metadata.get(tool_name)
193
+ if isinstance(tool_info, dict):
194
+ return tool_name, tool_info
195
+
196
+ return tool_name, None
197
+
198
+
199
+ def extract_input_schema(input_data: Dict[str, Any]) -> List[Tuple[str, Any]]:
200
+ """
201
+ Extract the schema from input data.
202
+
203
+ :param input_data: A dictionary representing the input data.
204
+ :return: A list of key-value pairs representing the input schema.
205
+ """
206
+ return [(key, input_data[key]) for key in input_data]
207
+
208
+
209
+ def extract_output_schema(output_data: Dict[str, Any]) -> List[Tuple[str, str, str]]:
210
+ """
211
+ Extract the output schema from the output data.
212
+
213
+ :param output_data: A dictionary representing the output data.
214
+ :return: A list of list of tuples representing the output schema.
215
+ """
216
+ schema = output_data.get("schema", {})
217
+ if "properties" not in schema:
218
+ return []
219
+
220
+ return [
221
+ (key, value.get("type", ""), value.get("description", ""))
222
+ for key, value in schema["properties"].items()
223
+ ]
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = "mech-client"
3
- version = "0.7.0"
3
+ version = "0.8.0"
4
4
  description = "Basic client to interact with a mech"
5
5
  authors = ["David Minarsch <david.minarsch@googlemail.com>"]
6
6
  readme = "README.md"
@@ -1,3 +0,0 @@
1
- """Mech client."""
2
-
3
- __version__ = "0.7.0"
File without changes