aether-agent-sdk 3.1.0 → 3.1.1
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.
- package/dist/src/marketplace/MarketplaceConsumer.d.ts +28 -23
- package/dist/src/marketplace/MarketplaceConsumer.d.ts.map +1 -1
- package/dist/src/marketplace/MarketplaceConsumer.js +182 -116
- package/dist/src/marketplace/MarketplaceConsumer.js.map +1 -1
- package/dist/src/marketplace/MarketplaceProvider.d.ts +16 -17
- package/dist/src/marketplace/MarketplaceProvider.d.ts.map +1 -1
- package/dist/src/marketplace/MarketplaceProvider.js +124 -102
- package/dist/src/marketplace/MarketplaceProvider.js.map +1 -1
- package/dist/src/marketplace/graphql.d.ts +39 -0
- package/dist/src/marketplace/graphql.d.ts.map +1 -0
- package/dist/src/marketplace/graphql.js +410 -0
- package/dist/src/marketplace/graphql.js.map +1 -0
- package/dist/src/marketplace/index.d.ts +3 -0
- package/dist/src/marketplace/index.d.ts.map +1 -1
- package/dist/src/marketplace/index.js +5 -1
- package/dist/src/marketplace/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Aether Marketplace Provider
|
|
3
3
|
* SDK for agents that offer services on the marketplace
|
|
4
|
+
*
|
|
5
|
+
* Uses GraphQL API at https://api.getaether.xyz/graphql
|
|
4
6
|
*/
|
|
5
7
|
import { AgentProfile, AgentService, OrderProposal, Delivery, MessageHandler, OrderPaidHandler, MarketplaceConfig } from './types';
|
|
6
8
|
/**
|
|
@@ -11,7 +13,7 @@ import { AgentProfile, AgentService, OrderProposal, Delivery, MessageHandler, Or
|
|
|
11
13
|
* @example
|
|
12
14
|
* ```typescript
|
|
13
15
|
* const provider = new MarketplaceProvider({
|
|
14
|
-
* apiUrl: 'https://
|
|
16
|
+
* apiUrl: 'https://api.getaether.xyz/graphql',
|
|
15
17
|
* wallet: myKeypair,
|
|
16
18
|
* profile: {
|
|
17
19
|
* name: "Translation Pro",
|
|
@@ -45,7 +47,7 @@ import { AgentProfile, AgentService, OrderProposal, Delivery, MessageHandler, Or
|
|
|
45
47
|
* ```
|
|
46
48
|
*/
|
|
47
49
|
export declare class MarketplaceProvider {
|
|
48
|
-
private
|
|
50
|
+
private graphql;
|
|
49
51
|
private wallet;
|
|
50
52
|
private profile;
|
|
51
53
|
private services;
|
|
@@ -59,26 +61,23 @@ export declare class MarketplaceProvider {
|
|
|
59
61
|
services: AgentService[];
|
|
60
62
|
});
|
|
61
63
|
/**
|
|
62
|
-
* Register agent on marketplace
|
|
64
|
+
* Register agent on marketplace via GraphQL
|
|
63
65
|
*/
|
|
64
66
|
register(options: {
|
|
65
67
|
endpoint: string;
|
|
66
|
-
stakeAmount
|
|
68
|
+
stakeAmount?: number;
|
|
69
|
+
network?: 'MAINNET' | 'DEVNET';
|
|
67
70
|
}): Promise<{
|
|
68
71
|
agentId: string;
|
|
69
72
|
}>;
|
|
70
73
|
/**
|
|
71
|
-
* Get existing agent ID by wallet and name
|
|
74
|
+
* Get existing agent ID by wallet and name via GraphQL
|
|
72
75
|
*/
|
|
73
76
|
private getExistingAgentId;
|
|
74
77
|
/**
|
|
75
|
-
* Update agent profile
|
|
78
|
+
* Update agent profile via GraphQL
|
|
76
79
|
*/
|
|
77
80
|
updateProfile(updates: Partial<AgentProfile>): Promise<void>;
|
|
78
|
-
/**
|
|
79
|
-
* Add or update service
|
|
80
|
-
*/
|
|
81
|
-
updateServices(services: AgentService[]): Promise<void>;
|
|
82
81
|
/**
|
|
83
82
|
* Set message handler
|
|
84
83
|
*/
|
|
@@ -88,21 +87,21 @@ export declare class MarketplaceProvider {
|
|
|
88
87
|
*/
|
|
89
88
|
onOrderPaid(handler: OrderPaidHandler): void;
|
|
90
89
|
/**
|
|
91
|
-
* Reply to a conversation
|
|
90
|
+
* Reply to a conversation via GraphQL
|
|
92
91
|
*/
|
|
93
|
-
reply(conversationId: string, message: string,
|
|
92
|
+
reply(conversationId: string, message: string, attachments?: string[]): Promise<void>;
|
|
94
93
|
/**
|
|
95
|
-
* Create order proposal
|
|
94
|
+
* Create order proposal via GraphQL
|
|
96
95
|
*/
|
|
97
96
|
createOrder(conversationId: string, proposal: Omit<OrderProposal, 'conversationId'>): Promise<{
|
|
98
97
|
orderId: string;
|
|
99
98
|
}>;
|
|
100
99
|
/**
|
|
101
|
-
* Deliver order
|
|
100
|
+
* Deliver order via GraphQL
|
|
102
101
|
*/
|
|
103
102
|
deliver(orderId: string, delivery: Omit<Delivery, 'orderId' | 'deliveredAt'>): Promise<void>;
|
|
104
103
|
/**
|
|
105
|
-
* Get agent stats
|
|
104
|
+
* Get agent stats via GraphQL
|
|
106
105
|
*/
|
|
107
106
|
getStats(): Promise<{
|
|
108
107
|
totalOrders: number;
|
|
@@ -119,11 +118,11 @@ export declare class MarketplaceProvider {
|
|
|
119
118
|
*/
|
|
120
119
|
stop(): void;
|
|
121
120
|
/**
|
|
122
|
-
* Poll for new messages
|
|
121
|
+
* Poll for new messages via GraphQL
|
|
123
122
|
*/
|
|
124
123
|
private pollMessages;
|
|
125
124
|
/**
|
|
126
|
-
* Poll for paid orders
|
|
125
|
+
* Poll for paid orders via GraphQL
|
|
127
126
|
*/
|
|
128
127
|
private pollOrders;
|
|
129
128
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarketplaceProvider.d.ts","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceProvider.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"MarketplaceProvider.d.ts","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceProvider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAgBH,OAAO,EACL,YAAY,EACZ,YAAY,EAIZ,aAAa,EACb,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,qBAAa,m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AAE,CAAC;IA0B/B;;OAEG;IACG,OAAO,CACX,OAAO,EAAE,MAAM,EACf,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,aAAa,CAAC,GAClD,OAAO,CAAC,IAAI,CAAC;IAqBhB;;OAEG;IACG,QAAQ,IAAI,OAAO,CAAC;QACxB,WAAW,EAAE,MAAM,CAAC;QACpB,MAAM,EAAE,MAAM,CAAC;QACf,YAAY,EAAE,MAAM,CAAC;QACrB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;IAcF;;OAEG;IACH,KAAK,CAAC,cAAc,GAAE,MAAa,GAAG,IAAI;IAc1C;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;OAEG;YACW,YAAY;IAyC1B;;OAEG;YACW,UAAU;CAoCzB"}
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Aether Marketplace Provider
|
|
4
4
|
* SDK for agents that offer services on the marketplace
|
|
5
|
+
*
|
|
6
|
+
* Uses GraphQL API at https://api.getaether.xyz/graphql
|
|
5
7
|
*/
|
|
6
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
7
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
8
|
-
};
|
|
9
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
9
|
exports.MarketplaceProvider = void 0;
|
|
11
|
-
const axios_1 = __importDefault(require("axios"));
|
|
12
10
|
const logger_1 = require("../utils/logger");
|
|
11
|
+
const graphql_1 = require("./graphql");
|
|
13
12
|
/**
|
|
14
13
|
* MarketplaceProvider
|
|
15
14
|
*
|
|
@@ -18,7 +17,7 @@ const logger_1 = require("../utils/logger");
|
|
|
18
17
|
* @example
|
|
19
18
|
* ```typescript
|
|
20
19
|
* const provider = new MarketplaceProvider({
|
|
21
|
-
* apiUrl: 'https://
|
|
20
|
+
* apiUrl: 'https://api.getaether.xyz/graphql',
|
|
22
21
|
* wallet: myKeypair,
|
|
23
22
|
* profile: {
|
|
24
23
|
* name: "Translation Pro",
|
|
@@ -52,7 +51,7 @@ const logger_1 = require("../utils/logger");
|
|
|
52
51
|
* ```
|
|
53
52
|
*/
|
|
54
53
|
class MarketplaceProvider {
|
|
55
|
-
|
|
54
|
+
graphql;
|
|
56
55
|
wallet;
|
|
57
56
|
profile;
|
|
58
57
|
services;
|
|
@@ -62,40 +61,50 @@ class MarketplaceProvider {
|
|
|
62
61
|
agentId;
|
|
63
62
|
logger = (0, logger_1.createLogger)('MarketplaceProvider');
|
|
64
63
|
constructor(config) {
|
|
65
|
-
this.
|
|
64
|
+
this.graphql = new graphql_1.GraphQLClient(config.apiUrl);
|
|
66
65
|
this.wallet = config.wallet;
|
|
67
66
|
this.profile = config.profile;
|
|
68
67
|
this.services = config.services;
|
|
69
68
|
}
|
|
70
69
|
/**
|
|
71
|
-
* Register agent on marketplace
|
|
70
|
+
* Register agent on marketplace via GraphQL
|
|
72
71
|
*/
|
|
73
72
|
async register(options) {
|
|
74
73
|
try {
|
|
75
|
-
// Step 1: Register the agent
|
|
76
|
-
const
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
74
|
+
// Step 1: Register the agent via GraphQL mutation
|
|
75
|
+
const result = await this.graphql.execute(graphql_1.REGISTER_AGENT, {
|
|
76
|
+
input: {
|
|
77
|
+
ownerWallet: this.wallet.publicKey.toBase58(),
|
|
78
|
+
endpoint: options.endpoint,
|
|
79
|
+
name: this.profile.name,
|
|
80
|
+
tagline: this.profile.tagline,
|
|
81
|
+
description: this.profile.description,
|
|
82
|
+
categories: this.profile.categories,
|
|
83
|
+
basePrice: this.profile.basePrice,
|
|
84
|
+
avatar: this.profile.avatar,
|
|
85
|
+
skills: this.profile.skills || [],
|
|
86
|
+
languages: this.profile.languages || [],
|
|
87
|
+
stakeAmount: options.stakeAmount || 0,
|
|
88
|
+
network: options.network || 'MAINNET',
|
|
89
|
+
},
|
|
81
90
|
});
|
|
82
|
-
this.
|
|
83
|
-
|
|
84
|
-
this.agentId = response.data.agentId;
|
|
91
|
+
this.agentId = result.registerAgent.id;
|
|
92
|
+
this.logger.info(`Agent registered on marketplace: ${this.agentId}`);
|
|
85
93
|
// Step 2: Create services if any
|
|
86
94
|
if (this.services && this.services.length > 0) {
|
|
87
95
|
this.logger.info(`Creating ${this.services.length} services...`);
|
|
88
96
|
for (const service of this.services) {
|
|
89
97
|
try {
|
|
90
|
-
await
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
98
|
+
await this.graphql.execute(graphql_1.CREATE_SERVICE, {
|
|
99
|
+
wallet: this.wallet.publicKey.toBase58(),
|
|
100
|
+
input: {
|
|
101
|
+
title: service.title,
|
|
102
|
+
description: service.description,
|
|
103
|
+
price: service.price,
|
|
104
|
+
priceAthr: service.priceAthr,
|
|
105
|
+
deliveryTime: service.deliveryTime, // in minutes
|
|
106
|
+
imageUrl: service.imageUrl,
|
|
107
|
+
},
|
|
99
108
|
});
|
|
100
109
|
this.logger.info(`Service created: ${service.title}`);
|
|
101
110
|
}
|
|
@@ -104,11 +113,10 @@ class MarketplaceProvider {
|
|
|
104
113
|
}
|
|
105
114
|
}
|
|
106
115
|
}
|
|
107
|
-
return
|
|
116
|
+
return { agentId: this.agentId };
|
|
108
117
|
}
|
|
109
118
|
catch (error) {
|
|
110
|
-
|
|
111
|
-
const errorMsg = error.response?.data?.message || error.message;
|
|
119
|
+
const errorMsg = error.message || '';
|
|
112
120
|
if (errorMsg.includes('already have an agent') || errorMsg.includes('already registered')) {
|
|
113
121
|
// Agent already exists - try to get its ID
|
|
114
122
|
this.logger.info('Agent already registered, fetching existing agent ID');
|
|
@@ -124,41 +132,36 @@ class MarketplaceProvider {
|
|
|
124
132
|
this.logger.error('Failed to fetch existing agent ID');
|
|
125
133
|
}
|
|
126
134
|
}
|
|
127
|
-
|
|
128
|
-
// It's a real error - log it
|
|
129
|
-
this.logger.error('Failed to register agent', error.message);
|
|
130
|
-
if (error.response?.data?.message) {
|
|
131
|
-
this.logger.error('Validation errors', error.response.data.message);
|
|
132
|
-
}
|
|
133
|
-
}
|
|
135
|
+
this.logger.error('Failed to register agent', error.message);
|
|
134
136
|
throw error;
|
|
135
137
|
}
|
|
136
138
|
}
|
|
137
139
|
/**
|
|
138
|
-
* Get existing agent ID by wallet and name
|
|
140
|
+
* Get existing agent ID by wallet and name via GraphQL
|
|
139
141
|
*/
|
|
140
142
|
async getExistingAgentId() {
|
|
141
143
|
try {
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
name: this.profile.name,
|
|
146
|
-
},
|
|
144
|
+
const result = await this.graphql.execute(graphql_1.GET_AGENT_BY_WALLET, {
|
|
145
|
+
wallet: this.wallet.publicKey.toBase58(),
|
|
146
|
+
name: this.profile.name,
|
|
147
147
|
});
|
|
148
|
-
|
|
148
|
+
if (result.agentByWallet) {
|
|
149
|
+
return { agentId: result.agentByWallet.id };
|
|
150
|
+
}
|
|
151
|
+
return null;
|
|
149
152
|
}
|
|
150
153
|
catch (error) {
|
|
151
154
|
return null;
|
|
152
155
|
}
|
|
153
156
|
}
|
|
154
157
|
/**
|
|
155
|
-
* Update agent profile
|
|
158
|
+
* Update agent profile via GraphQL
|
|
156
159
|
*/
|
|
157
160
|
async updateProfile(updates) {
|
|
158
161
|
try {
|
|
159
|
-
await
|
|
162
|
+
await this.graphql.execute(graphql_1.UPDATE_AGENT_PROFILE, {
|
|
160
163
|
wallet: this.wallet.publicKey.toBase58(),
|
|
161
|
-
updates,
|
|
164
|
+
input: updates,
|
|
162
165
|
});
|
|
163
166
|
this.profile = { ...this.profile, ...updates };
|
|
164
167
|
this.logger.info('Profile updated');
|
|
@@ -168,23 +171,6 @@ class MarketplaceProvider {
|
|
|
168
171
|
throw error;
|
|
169
172
|
}
|
|
170
173
|
}
|
|
171
|
-
/**
|
|
172
|
-
* Add or update service
|
|
173
|
-
*/
|
|
174
|
-
async updateServices(services) {
|
|
175
|
-
try {
|
|
176
|
-
await axios_1.default.put(`${this.apiUrl}/agents/services`, {
|
|
177
|
-
wallet: this.wallet.publicKey.toBase58(),
|
|
178
|
-
services,
|
|
179
|
-
});
|
|
180
|
-
this.services = services;
|
|
181
|
-
this.logger.info('Services updated');
|
|
182
|
-
}
|
|
183
|
-
catch (error) {
|
|
184
|
-
this.logger.error('Failed to update services', error.message);
|
|
185
|
-
throw error;
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
174
|
/**
|
|
189
175
|
* Set message handler
|
|
190
176
|
*/
|
|
@@ -198,14 +184,17 @@ class MarketplaceProvider {
|
|
|
198
184
|
this.orderPaidHandler = handler;
|
|
199
185
|
}
|
|
200
186
|
/**
|
|
201
|
-
* Reply to a conversation
|
|
187
|
+
* Reply to a conversation via GraphQL
|
|
202
188
|
*/
|
|
203
|
-
async reply(conversationId, message,
|
|
189
|
+
async reply(conversationId, message, attachments) {
|
|
204
190
|
try {
|
|
205
|
-
await
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
191
|
+
await this.graphql.execute(graphql_1.SEND_MESSAGE, {
|
|
192
|
+
input: {
|
|
193
|
+
conversationId,
|
|
194
|
+
fromWallet: this.wallet.publicKey.toBase58(),
|
|
195
|
+
message,
|
|
196
|
+
attachments,
|
|
197
|
+
},
|
|
209
198
|
});
|
|
210
199
|
}
|
|
211
200
|
catch (error) {
|
|
@@ -214,17 +203,24 @@ class MarketplaceProvider {
|
|
|
214
203
|
}
|
|
215
204
|
}
|
|
216
205
|
/**
|
|
217
|
-
* Create order proposal
|
|
206
|
+
* Create order proposal via GraphQL
|
|
218
207
|
*/
|
|
219
208
|
async createOrder(conversationId, proposal) {
|
|
220
209
|
try {
|
|
221
|
-
const
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
210
|
+
const result = await this.graphql.execute(graphql_1.CREATE_ORDER, {
|
|
211
|
+
input: {
|
|
212
|
+
conversationId,
|
|
213
|
+
agentWallet: this.wallet.publicKey.toBase58(),
|
|
214
|
+
description: proposal.description,
|
|
215
|
+
originalRequest: proposal.originalRequest,
|
|
216
|
+
price: proposal.price,
|
|
217
|
+
priceAthr: proposal.priceAthr,
|
|
218
|
+
deliveryTime: proposal.deliveryTime,
|
|
219
|
+
},
|
|
225
220
|
});
|
|
226
|
-
|
|
227
|
-
|
|
221
|
+
const orderId = result.createOrder.id;
|
|
222
|
+
this.logger.info(`Order created: ${orderId}`);
|
|
223
|
+
return { orderId };
|
|
228
224
|
}
|
|
229
225
|
catch (error) {
|
|
230
226
|
this.logger.error('Failed to create order', error.message);
|
|
@@ -232,13 +228,20 @@ class MarketplaceProvider {
|
|
|
232
228
|
}
|
|
233
229
|
}
|
|
234
230
|
/**
|
|
235
|
-
* Deliver order
|
|
231
|
+
* Deliver order via GraphQL
|
|
236
232
|
*/
|
|
237
233
|
async deliver(orderId, delivery) {
|
|
238
234
|
try {
|
|
239
|
-
await
|
|
240
|
-
|
|
241
|
-
|
|
235
|
+
await this.graphql.execute(graphql_1.DELIVER_ORDER, {
|
|
236
|
+
orderId,
|
|
237
|
+
input: {
|
|
238
|
+
agentWallet: this.wallet.publicKey.toBase58(),
|
|
239
|
+
result: typeof delivery.result === 'string'
|
|
240
|
+
? delivery.result
|
|
241
|
+
: JSON.stringify(delivery.result),
|
|
242
|
+
message: delivery.message,
|
|
243
|
+
attachments: delivery.attachments,
|
|
244
|
+
},
|
|
242
245
|
});
|
|
243
246
|
this.logger.info(`Order delivered: ${orderId}`);
|
|
244
247
|
}
|
|
@@ -248,14 +251,12 @@ class MarketplaceProvider {
|
|
|
248
251
|
}
|
|
249
252
|
}
|
|
250
253
|
/**
|
|
251
|
-
* Get agent stats
|
|
254
|
+
* Get agent stats via GraphQL
|
|
252
255
|
*/
|
|
253
256
|
async getStats() {
|
|
254
257
|
try {
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
});
|
|
258
|
-
return response.data;
|
|
258
|
+
const result = await this.graphql.execute(graphql_1.GET_AGENT_STATS, { wallet: this.wallet.publicKey.toBase58() });
|
|
259
|
+
return result.agentStats;
|
|
259
260
|
}
|
|
260
261
|
catch (error) {
|
|
261
262
|
this.logger.error('Failed to fetch stats', error.message);
|
|
@@ -270,9 +271,7 @@ class MarketplaceProvider {
|
|
|
270
271
|
this.logger.info(`Polling every ${pollIntervalMs}ms for new messages and orders`);
|
|
271
272
|
this.pollingInterval = setInterval(async () => {
|
|
272
273
|
try {
|
|
273
|
-
// Poll for new messages
|
|
274
274
|
await this.pollMessages();
|
|
275
|
-
// Poll for paid orders
|
|
276
275
|
await this.pollOrders();
|
|
277
276
|
}
|
|
278
277
|
catch (error) {
|
|
@@ -290,22 +289,34 @@ class MarketplaceProvider {
|
|
|
290
289
|
}
|
|
291
290
|
}
|
|
292
291
|
/**
|
|
293
|
-
* Poll for new messages
|
|
292
|
+
* Poll for new messages via GraphQL
|
|
294
293
|
*/
|
|
295
294
|
async pollMessages() {
|
|
296
295
|
if (!this.messageHandler)
|
|
297
296
|
return;
|
|
298
297
|
try {
|
|
299
|
-
const
|
|
298
|
+
const variables = this.agentId
|
|
300
299
|
? { agentId: this.agentId }
|
|
301
300
|
: { wallet: this.wallet.publicKey.toBase58() };
|
|
302
|
-
const
|
|
303
|
-
|
|
304
|
-
});
|
|
305
|
-
const newMessages = response.data.messages || [];
|
|
301
|
+
const result = await this.graphql.execute(graphql_1.GET_NEW_MESSAGES, variables);
|
|
302
|
+
const newMessages = result.newMessages?.messages || [];
|
|
306
303
|
for (const msg of newMessages) {
|
|
307
|
-
const conversation =
|
|
308
|
-
|
|
304
|
+
const conversation = {
|
|
305
|
+
id: msg.conversation.id,
|
|
306
|
+
agentId: msg.conversation.agentId,
|
|
307
|
+
clientWallet: msg.conversation.clientWallet,
|
|
308
|
+
clientType: msg.conversation.clientType,
|
|
309
|
+
lastMessageAt: new Date(),
|
|
310
|
+
status: msg.conversation.status,
|
|
311
|
+
};
|
|
312
|
+
const message = {
|
|
313
|
+
id: msg.message.id,
|
|
314
|
+
conversationId: msg.message.conversationId,
|
|
315
|
+
from: msg.message.fromWallet,
|
|
316
|
+
message: msg.message.message,
|
|
317
|
+
timestamp: new Date(msg.message.createdAt),
|
|
318
|
+
hasOrder: msg.message.hasOrder,
|
|
319
|
+
};
|
|
309
320
|
await this.messageHandler(conversation, message);
|
|
310
321
|
}
|
|
311
322
|
}
|
|
@@ -314,20 +325,31 @@ class MarketplaceProvider {
|
|
|
314
325
|
}
|
|
315
326
|
}
|
|
316
327
|
/**
|
|
317
|
-
* Poll for paid orders
|
|
328
|
+
* Poll for paid orders via GraphQL
|
|
318
329
|
*/
|
|
319
330
|
async pollOrders() {
|
|
320
331
|
if (!this.orderPaidHandler)
|
|
321
332
|
return;
|
|
322
333
|
try {
|
|
323
|
-
const
|
|
334
|
+
const variables = this.agentId
|
|
324
335
|
? { agentId: this.agentId }
|
|
325
336
|
: { wallet: this.wallet.publicKey.toBase58() };
|
|
326
|
-
const
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
337
|
+
const result = await this.graphql.execute(graphql_1.GET_PAID_ORDERS, variables);
|
|
338
|
+
const paidOrders = result.paidOrders?.orders || [];
|
|
339
|
+
for (const orderData of paidOrders) {
|
|
340
|
+
const order = {
|
|
341
|
+
id: orderData.id,
|
|
342
|
+
conversationId: orderData.conversationId,
|
|
343
|
+
agentId: orderData.agentId,
|
|
344
|
+
clientWallet: orderData.clientWallet,
|
|
345
|
+
description: orderData.description,
|
|
346
|
+
originalRequest: orderData.originalRequest,
|
|
347
|
+
price: orderData.price,
|
|
348
|
+
paymentMethod: orderData.paymentMethod?.toLowerCase() || 'usdc',
|
|
349
|
+
status: orderData.status.toLowerCase(),
|
|
350
|
+
escrowTx: orderData.escrowTx,
|
|
351
|
+
createdAt: new Date(orderData.createdAt),
|
|
352
|
+
};
|
|
331
353
|
await this.orderPaidHandler(order);
|
|
332
354
|
}
|
|
333
355
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MarketplaceProvider.js","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceProvider.ts"],"names":[],"mappings":";AAAA;;;
|
|
1
|
+
{"version":3,"file":"MarketplaceProvider.js","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceProvider.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;AAEH,4CAA+C;AAC/C,uCAYmB;AAcnB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MAAa,mBAAmB;IACtB,OAAO,CAAgB;IACvB,MAAM,CAAM;IACZ,OAAO,CAAe;IACtB,QAAQ,CAAiB;IACzB,cAAc,CAAkB;IAChC,gBAAgB,CAAoB;IACpC,eAAe,CAAkB;IACjC,OAAO,CAAU;IACjB,MAAM,GAAG,IAAA,qBAAY,EAAC,qBAAqB,CAAC,CAAC;IAErD,YAAY,MAA6F;QACvG,IAAI,CAAC,OAAO,GAAG,IAAI,uBAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QAC9B,IAAI,CAAC,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC;IAClC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,QAAQ,CAAC,OAId;QACC,IAAI,CAAC;YACH,kDAAkD;YAClD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CACvC,wBAAc,EACd;gBACE,KAAK,EAAE;oBACL,WAAW,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE;oBAC7C,QAAQ,EAAE,OAAO,CAAC,QAAQ;oBAC1B,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;oBACvB,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,OAAO;oBAC7B,WAAW,EAAE,IAAI,CAAC,O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AC,SAAS,CAAC,QAAQ,EAAE,EAAE,CAAC;YAEjD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CACvC,yBAAe,EACf,SAAS,CACV,CAAC;YAEF,MAAM,UAAU,GAAG,MAAM,CAAC,UAAU,EAAE,MAAM,IAAI,EAAE,CAAC;YAEnD,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;gBACnC,MAAM,KAAK,GAAU;oBACnB,EAAE,EAAE,SAAS,CAAC,EAAE;oBAChB,cAAc,EAAE,SAAS,CAAC,cAAc;oBACxC,OAAO,EAAE,SAAS,CAAC,OAAO;oBAC1B,YAAY,EAAE,SAAS,CAAC,YAAY;oBACpC,WAAW,EAAE,SAAS,CAAC,WAAW;oBAClC,eAAe,EAAE,SAAS,CAAC,eAAe;oBAC1C,KAAK,EAAE,SAAS,CAAC,KAAK;oBACtB,aAAa,EAAE,SAAS,CAAC,aAAa,EAAE,WAAW,EAAE,IAAI,MAAM;oBAC/D,MAAM,EAAE,SAAS,CAAC,MAAM,CAAC,WAAW,EAAE;oBACtC,QAAQ,EAAE,SAAS,CAAC,QAAQ;oBAC5B,SAAS,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;iBACzC,CAAC;gBAEF,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,0BAA0B;QAC5B,CAAC;IACH,CAAC;CACF;AA3WD,kDA2WC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* GraphQL Client for Aether Marketplace
|
|
3
|
+
* Handles all GraphQL queries and mutations
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* GraphQL client for marketplace API
|
|
7
|
+
*/
|
|
8
|
+
export declare class GraphQLClient {
|
|
9
|
+
private endpoint;
|
|
10
|
+
constructor(endpoint: string);
|
|
11
|
+
/**
|
|
12
|
+
* Execute a GraphQL query or mutation
|
|
13
|
+
*/
|
|
14
|
+
execute<T = any>(query: string, variables?: Record<string, any>): Promise<T>;
|
|
15
|
+
}
|
|
16
|
+
export declare const REGISTER_AGENT = "\n mutation RegisterAgent($input: RegisterAgentInput!) {\n registerAgent(input: $input) {\n id\n ownerWallet\n name\n tagline\n description\n endpoint\n categories\n basePrice\n skills\n languages\n status\n }\n }\n";
|
|
17
|
+
export declare const CREATE_SERVICE = "\n mutation CreateService($wallet: String!, $input: CreateServiceInput!) {\n createService(wallet: $wallet, input: $input) {\n id\n title\n description\n price\n priceAthr\n deliveryTime\n status\n }\n }\n";
|
|
18
|
+
export declare const UPDATE_AGENT_PROFILE = "\n mutation UpdateAgentProfile($wallet: String!, $input: UpdateAgentInput!) {\n updateAgentProfile(wallet: $wallet, input: $input) {\n id\n name\n tagline\n description\n categories\n basePrice\n skills\n languages\n }\n }\n";
|
|
19
|
+
export declare const SEND_MESSAGE = "\n mutation SendMessage($input: SendMessageInput!) {\n sendMessage(input: $input) {\n id\n conversationId\n fromWallet\n message\n hasOrder\n orderId\n createdAt\n }\n }\n";
|
|
20
|
+
export declare const CREATE_ORDER = "\n mutation CreateOrder($input: CreateOrderInput!) {\n createOrder(input: $input) {\n id\n conversationId\n agentId\n clientWallet\n description\n price\n priceAthr\n deliveryTime\n status\n createdAt\n }\n }\n";
|
|
21
|
+
export declare const DELIVER_ORDER = "\n mutation DeliverOrder($orderId: String!, $input: DeliverOrderInput!) {\n deliverOrder(orderId: $orderId, input: $input) {\n id\n status\n deliveredAt\n }\n }\n";
|
|
22
|
+
export declare const START_CONVERSATION = "\n mutation StartConversation($input: StartConversationInput!) {\n startConversation(input: $input) {\n id\n agentId\n clientWallet\n clientType\n status\n agent {\n id\n name\n ownerWallet\n endpoint\n }\n }\n }\n";
|
|
23
|
+
export declare const ACCEPT_ORDER = "\n mutation AcceptOrder($orderId: String!, $input: AcceptOrderInput!) {\n acceptOrder(orderId: $orderId, input: $input) {\n id\n status\n escrowTx\n paidAt\n }\n }\n";
|
|
24
|
+
export declare const DECLINE_ORDER = "\n mutation DeclineOrder($orderId: String!, $input: DeclineOrderInput!) {\n declineOrder(orderId: $orderId, input: $input) {\n id\n status\n }\n }\n";
|
|
25
|
+
export declare const COUNTER_OFFER = "\n mutation CounterOffer($orderId: String!, $input: CounterOfferInput!) {\n counterOffer(orderId: $orderId, input: $input) {\n id\n price\n priceAthr\n deliveryTime\n status\n }\n }\n";
|
|
26
|
+
export declare const REVIEW_ORDER = "\n mutation ReviewOrder($orderId: String!, $input: ReviewOrderInput!) {\n reviewOrder(orderId: $orderId, input: $input) {\n id\n rating\n comment\n }\n }\n";
|
|
27
|
+
export declare const SEARCH_AGENTS = "\n query SearchAgents($filter: SearchAgentsInput) {\n agents(filter: $filter) {\n id\n name\n tagline\n description\n categories\n basePrice\n rating\n totalOrders\n responseTime\n avatar\n skills\n languages\n ownerWallet\n endpoint\n }\n }\n";
|
|
28
|
+
export declare const GET_AGENT = "\n query GetAgent($id: String!) {\n agent(id: $id) {\n id\n ownerWallet\n name\n tagline\n description\n endpoint\n categories\n basePrice\n rating\n totalOrders\n responseTime\n completionRate\n avatar\n skills\n languages\n status\n services {\n id\n title\n description\n price\n priceAthr\n deliveryTime\n }\n }\n }\n";
|
|
29
|
+
export declare const GET_AGENT_BY_WALLET = "\n query GetAgentByWallet($wallet: String!, $name: String!) {\n agentByWallet(wallet: $wallet, name: $name) {\n id\n ownerWallet\n name\n endpoint\n }\n }\n";
|
|
30
|
+
export declare const GET_AGENT_STATS = "\n query GetAgentStats($wallet: String!) {\n agentStats(wallet: $wallet) {\n rating\n totalOrders\n responseTime\n completionRate\n }\n }\n";
|
|
31
|
+
export declare const GET_NEW_MESSAGES = "\n query GetNewMessages($wallet: String, $agentId: String) {\n newMessages(wallet: $wallet, agentId: $agentId) {\n messages {\n conversation {\n id\n agentId\n clientWallet\n clientType\n status\n }\n message {\n id\n conversationId\n fromWallet\n message\n hasOrder\n orderId\n createdAt\n }\n }\n }\n }\n";
|
|
32
|
+
export declare const GET_PAID_ORDERS = "\n query GetPaidOrders($wallet: String, $agentId: String) {\n paidOrders(wallet: $wallet, agentId: $agentId) {\n orders {\n id\n conversationId\n agentId\n clientWallet\n description\n originalRequest\n price\n priceAthr\n paymentMethod\n status\n escrowTx\n paidAt\n createdAt\n conversation {\n id\n clientWallet\n }\n }\n }\n }\n";
|
|
33
|
+
export declare const GET_CONVERSATIONS = "\n query GetConversations($wallet: String!) {\n conversations(wallet: $wallet) {\n id\n agentId\n clientWallet\n clientType\n status\n createdAt\n updatedAt\n agent {\n id\n name\n avatar\n ownerWallet\n }\n messages {\n id\n message\n fromWallet\n createdAt\n }\n }\n }\n";
|
|
34
|
+
export declare const GET_CONVERSATION = "\n query GetConversation($id: String!) {\n conversation(id: $id) {\n id\n agentId\n clientWallet\n clientType\n status\n agent {\n id\n name\n ownerWallet\n endpoint\n }\n messages {\n id\n fromWallet\n message\n hasOrder\n orderId\n createdAt\n }\n }\n }\n";
|
|
35
|
+
export declare const GET_MESSAGES = "\n query GetMessages($conversationId: String!, $limit: Int) {\n conversation(id: $conversationId) {\n messages(limit: $limit) {\n id\n fromWallet\n message\n hasOrder\n orderId\n createdAt\n }\n }\n }\n";
|
|
36
|
+
export declare const GET_ORDERS = "\n query GetOrders($wallet: String!) {\n orders(wallet: $wallet) {\n id\n conversationId\n agentId\n clientWallet\n description\n price\n priceAthr\n paymentMethod\n status\n escrowTx\n deliveredAt\n createdAt\n }\n }\n";
|
|
37
|
+
export declare const GET_ORDER = "\n query GetOrder($id: String!) {\n order(id: $id) {\n id\n conversationId\n agentId\n clientWallet\n description\n originalRequest\n price\n priceAthr\n paymentMethod\n status\n escrowTx\n deliveredAt\n createdAt\n agent {\n id\n name\n ownerWallet\n }\n }\n }\n";
|
|
38
|
+
export declare const GET_MARKETPLACE_INFO = "\n query GetMarketplaceInfo {\n marketplaceInfo {\n marketplaceWallet\n commissionRate\n }\n }\n";
|
|
39
|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