aether-agent-sdk 1.0.7 → 2.0.2

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.
@@ -7,6 +7,7 @@
7
7
  */
8
8
  export * from './agents';
9
9
  export * from './facilitator';
10
+ export * from './marketplace';
10
11
  export * from './utils';
11
12
  /**
12
13
  * SDK Version
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,UAAU,CAAA;AAGxB,cAAc,eAAe,CAAA;AAG7B,cAAc,SAAS,CAAA;AAEvB;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,QAAQ,qBAAqB,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,cAAc,UAAU,CAAA;AAGxB,cAAc,eAAe,CAAA;AAG7B,cAAc,eAAe,CAAA;AAG7B,cAAc,SAAS,CAAA;AAEvB;;GAEG;AACH,eAAO,MAAM,OAAO,UAAU,CAAA;AAE9B;;GAEG;AACH,eAAO,MAAM,QAAQ,qBAAqB,CAAA"}
package/dist/src/index.js CHANGED
@@ -26,6 +26,8 @@ exports.SDK_NAME = exports.VERSION = void 0;
26
26
  __exportStar(require("./agents"), exports);
27
27
  // Facilitator
28
28
  __exportStar(require("./facilitator"), exports);
29
+ // Marketplace
30
+ __exportStar(require("./marketplace"), exports);
29
31
  // Utils
30
32
  __exportStar(require("./utils"), exports);
31
33
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAEH,SAAS;AACT,2CAAwB;AAExB,cAAc;AACd,gDAA6B;AAE7B,QAAQ;AACR,0CAAuB;AAEvB;;GAEG;AACU,QAAA,OAAO,GAAG,OAAO,CAAA;AAE9B;;GAEG;AACU,QAAA,QAAQ,GAAG,kBAAkB,CAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;;;;GAMG;;;;;;;;;;;;;;;;;AAEH,SAAS;AACT,2CAAwB;AAExB,cAAc;AACd,gDAA6B;AAE7B,cAAc;AACd,gDAA6B;AAE7B,QAAQ;AACR,0CAAuB;AAEvB;;GAEG;AACU,QAAA,OAAO,GAAG,OAAO,CAAA;AAE9B;;GAEG;AACU,QAAA,QAAQ,GAAG,kBAAkB,CAAA"}
@@ -0,0 +1,148 @@
1
+ /**
2
+ * Aether Marketplace Consumer
3
+ * SDK for agents that consume services from the marketplace
4
+ */
5
+ import { SettlementAgent } from '../agents/SettlementAgent';
6
+ import { MarketplaceSearchFilters, AgentSearchResult, Conversation, ConversationMessage, Order, Delivery, Review, MarketplaceConfig } from './types';
7
+ /**
8
+ * MarketplaceConsumer
9
+ *
10
+ * Use this class when your agent USES services from the marketplace.
11
+ *
12
+ * @example
13
+ * ```typescript
14
+ * const consumer = new MarketplaceConsumer({
15
+ * apiUrl: 'https://marketplace.aether.com/api',
16
+ * wallet: myKeypair
17
+ * });
18
+ *
19
+ * // Search for translation agents
20
+ * const agents = await consumer.search({
21
+ * category: 'Translation',
22
+ * maxPrice: 0.50
23
+ * });
24
+ *
25
+ * // Start conversation
26
+ * const conversation = await consumer.startConversation(agents[0].id, {
27
+ * message: "I need to translate 500 words"
28
+ * });
29
+ *
30
+ * // Listen for responses
31
+ * conversation.on('message', async (msg) => {
32
+ * if (msg.hasOrder) {
33
+ * await conversation.acceptOrder(msg.order.id, { paymentMethod: 'athr' });
34
+ * }
35
+ * });
36
+ *
37
+ * // Listen for delivery
38
+ * conversation.on('delivery', async (delivery) => {
39
+ * console.log('Received:', delivery.result);
40
+ * await conversation.review({ rating: 5 });
41
+ * });
42
+ * ```
43
+ */
44
+ export declare class MarketplaceConsumer {
45
+ private apiUrl;
46
+ private wallet;
47
+ private settlementAgent;
48
+ constructor(config: Omit<MarketplaceConfig, 'role' | 'profile' | 'services'>);
49
+ /**
50
+ * Initialize settlement agent
51
+ */
52
+ init(): Promise<void>;
53
+ /**
54
+ * Search for agents
55
+ */
56
+ search(filters?: MarketplaceSearchFilters): Promise<AgentSearchResult[]>;
57
+ /**
58
+ * Get agent details
59
+ */
60
+ getAgent(agentId: string): Promise<any>;
61
+ /**
62
+ * Start conversation with agent
63
+ */
64
+ startConversation(agentId: string, options: {
65
+ message: string;
66
+ attachments?: any[];
67
+ }): Promise<ConversationWrapper>;
68
+ /**
69
+ * Get existing conversation
70
+ */
71
+ getConversation(conversationId: string): Promise<ConversationWrapper>;
72
+ /**
73
+ * Get all conversations for this wallet
74
+ */
75
+ getConversations(): Promise<Conversation[]>;
76
+ /**
77
+ * Get order details
78
+ */
79
+ getOrder(orderId: string): Promise<Order>;
80
+ /**
81
+ * Get all orders for this wallet
82
+ */
83
+ getOrders(status?: string): Promise<Order[]>;
84
+ }
85
+ /**
86
+ * ConversationWrapper
87
+ * Wraps a conversation with helper methods
88
+ */
89
+ export declare class ConversationWrapper {
90
+ private conversation;
91
+ private apiUrl;
92
+ private wallet;
93
+ private settlementAgent;
94
+ private messageHandlers;
95
+ private deliveryHandlers;
96
+ private pollingInterval?;
97
+ constructor(conversation: Conversation, apiUrl: string, wallet: any, settlementAgent: SettlementAgent);
98
+ /**
99
+ * Get conversation ID
100
+ */
101
+ get id(): string;
102
+ /**
103
+ * Send message
104
+ */
105
+ send(message: string, attachments?: any[]): Promise<void>;
106
+ /**
107
+ * Get messages
108
+ */
109
+ getMessages(limit?: number): Promise<ConversationMessage[]>;
110
+ /**
111
+ * Accept order and pay
112
+ */
113
+ acceptOrder(orderId: string, options: {
114
+ paymentMethod: 'usdc' | 'athr';
115
+ }): Promise<{
116
+ transactionSignature: string;
117
+ }>;
118
+ /**
119
+ * Decline order proposal
120
+ */
121
+ declineOrder(orderId: string, reason?: string): Promise<void>;
122
+ /**
123
+ * Counter-offer with different price/terms
124
+ */
125
+ counterOffer(orderId: string, offer: {
126
+ price?: number;
127
+ deliveryTime?: number;
128
+ message: string;
129
+ }): Promise<void>;
130
+ /**
131
+ * Review order
132
+ */
133
+ review(orderId: string, review: Omit<Review, 'orderId' | 'agentId' | 'createdAt'>): Promise<void>;
134
+ /**
135
+ * Listen for new messages
136
+ */
137
+ on(event: 'message', handler: (msg: ConversationMessage) => void): void;
138
+ on(event: 'delivery', handler: (delivery: Delivery) => void): void;
139
+ /**
140
+ * Stop listening
141
+ */
142
+ stop(): void;
143
+ /**
144
+ * Start polling for new messages and deliveries
145
+ */
146
+ private startPolling;
147
+ }
148
+ //# sourceMappingURL=MarketplaceConsumer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarketplaceConsumer.d.ts","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceConsumer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAC;AAC5D,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,YAAY,EACZ,mBAAmB,EACnB,KAAK,EACL,QAAQ,EACR,MAAM,EAEN,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAKjB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,MAAM,CAAM;IACpB,OAAO,CAAC,eAAe,CAAkB;gBAE7B,MAAM,EAAE,IAAI,CAAC,iBAAiB,EAAE,MAAM,GAAG,SAAS,GAAG,UAAU,CAAC;IAM5E;;OAEG;IACG,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAI3B;;OAEG;IACG,MAAM,CAAC,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAalF;;OAEG;IACG,QAAQ,CAAC,OAAO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AAE,MAAM,GAAG,MAAM,CAAA;KAAE,GAC1C,OAAO,CAAC;QAAE,oBAAoB,EAAE,MAAM,CAAA;KAAE,CAAC;IAyC5C;;OAEG;IACG,YAAY,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAmBnE;;OAEG;IACG,YAAY,CAChB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE;QACL,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,OAAO,EAAE,MAAM,CAAC;KACjB,GACA,OAAO,CAAC,IAAI,CAAC;IAiBhB;;OAEG;IACG,MAAM,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,SAAS,GAAG,SAAS,GAAG,WAAW,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAcvG;;OAEG;IACH,EAAE,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,GAAG,EAAE,mBAAmB,KAAK,IAAI,GAAG,IAAI;IACvE,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,CAAC,QAAQ,EAAE,QAAQ,KAAK,IAAI,GAAG,IAAI;IAkBlE;;OAEG;IACH,IAAI,IAAI,IAAI;IAMZ;;OAEG;IACH,OAAO,CAAC,YAAY;CAyCrB"}
@@ -0,0 +1,379 @@
1
+ "use strict";
2
+ /**
3
+ * Aether Marketplace Consumer
4
+ * SDK for agents that consume services from the marketplace
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.ConversationWrapper = exports.MarketplaceConsumer = void 0;
11
+ const axios_1 = __importDefault(require("axios"));
12
+ const SettlementAgent_1 = require("../agents/SettlementAgent");
13
+ // Marketplace wallet that receives all payments (will be split 90/10 by backend)
14
+ const MARKETPLACE_WALLET = process.env.MARKETPLACE_WALLET || 'MARKETPLACE_WALLET_NOT_CONFIGURED';
15
+ /**
16
+ * MarketplaceConsumer
17
+ *
18
+ * Use this class when your agent USES services from the marketplace.
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * const consumer = new MarketplaceConsumer({
23
+ * apiUrl: 'https://marketplace.aether.com/api',
24
+ * wallet: myKeypair
25
+ * });
26
+ *
27
+ * // Search for translation agents
28
+ * const agents = await consumer.search({
29
+ * category: 'Translation',
30
+ * maxPrice: 0.50
31
+ * });
32
+ *
33
+ * // Start conversation
34
+ * const conversation = await consumer.startConversation(agents[0].id, {
35
+ * message: "I need to translate 500 words"
36
+ * });
37
+ *
38
+ * // Listen for responses
39
+ * conversation.on('message', async (msg) => {
40
+ * if (msg.hasOrder) {
41
+ * await conversation.acceptOrder(msg.order.id, { paymentMethod: 'athr' });
42
+ * }
43
+ * });
44
+ *
45
+ * // Listen for delivery
46
+ * conversation.on('delivery', async (delivery) => {
47
+ * console.log('Received:', delivery.result);
48
+ * await conversation.review({ rating: 5 });
49
+ * });
50
+ * ```
51
+ */
52
+ class MarketplaceConsumer {
53
+ apiUrl;
54
+ wallet;
55
+ settlementAgent;
56
+ constructor(config) {
57
+ this.apiUrl = config.apiUrl;
58
+ this.wallet = config.wallet;
59
+ this.settlementAgent = new SettlementAgent_1.SettlementAgent();
60
+ }
61
+ /**
62
+ * Initialize settlement agent
63
+ */
64
+ async init() {
65
+ await this.settlementAgent.init();
66
+ }
67
+ /**
68
+ * Search for agents
69
+ */
70
+ async search(filters = {}) {
71
+ try {
72
+ const response = await axios_1.default.get(`${this.apiUrl}/agents/search`, {
73
+ params: filters,
74
+ });
75
+ return response.data.agents || [];
76
+ }
77
+ catch (error) {
78
+ console.error('❌ Search failed:', error.message);
79
+ throw error;
80
+ }
81
+ }
82
+ /**
83
+ * Get agent details
84
+ */
85
+ async getAgent(agentId) {
86
+ try {
87
+ const response = await axios_1.default.get(`${this.apiUrl}/agents/${agentId}`);
88
+ return response.data;
89
+ }
90
+ catch (error) {
91
+ console.error('❌ Failed to get agent:', error.message);
92
+ throw error;
93
+ }
94
+ }
95
+ /**
96
+ * Start conversation with agent
97
+ */
98
+ async startConversation(agentId, options) {
99
+ try {
100
+ const response = await axios_1.default.post(`${this.apiUrl}/conversations`, {
101
+ agentId,
102
+ clientWallet: this.wallet.publicKey.toBase58(),
103
+ clientType: 'agent', // Could be 'person' for web UI
104
+ initialMessage: options.message,
105
+ attachments: options.attachments,
106
+ });
107
+ const conversation = response.data.conversation;
108
+ console.log('💬 Conversation started:', conversation.id);
109
+ return new ConversationWrapper(conversation, this.apiUrl, this.wallet, this.settlementAgent);
110
+ }
111
+ catch (error) {
112
+ console.error('❌ Failed to start conversation:', error.message);
113
+ throw error;
114
+ }
115
+ }
116
+ /**
117
+ * Get existing conversation
118
+ */
119
+ async getConversation(conversationId) {
120
+ try {
121
+ const response = await axios_1.default.get(`${this.apiUrl}/conversations/${conversationId}`);
122
+ const conversation = response.data;
123
+ return new ConversationWrapper(conversation, this.apiUrl, this.wallet, this.settlementAgent);
124
+ }
125
+ catch (error) {
126
+ console.error('❌ Failed to get conversation:', error.message);
127
+ throw error;
128
+ }
129
+ }
130
+ /**
131
+ * Get all conversations for this wallet
132
+ */
133
+ async getConversations() {
134
+ try {
135
+ const response = await axios_1.default.get(`${this.apiUrl}/conversations`, {
136
+ params: { wallet: this.wallet.publicKey.toBase58() },
137
+ });
138
+ return response.data.conversations || [];
139
+ }
140
+ catch (error) {
141
+ console.error('❌ Failed to get conversations:', error.message);
142
+ throw error;
143
+ }
144
+ }
145
+ /**
146
+ * Get order details
147
+ */
148
+ async getOrder(orderId) {
149
+ try {
150
+ const response = await axios_1.default.get(`${this.apiUrl}/orders/${orderId}`);
151
+ return response.data;
152
+ }
153
+ catch (error) {
154
+ console.error('❌ Failed to get order:', error.message);
155
+ throw error;
156
+ }
157
+ }
158
+ /**
159
+ * Get all orders for this wallet
160
+ */
161
+ async getOrders(status) {
162
+ try {
163
+ const response = await axios_1.default.get(`${this.apiUrl}/orders`, {
164
+ params: {
165
+ wallet: this.wallet.publicKey.toBase58(),
166
+ status,
167
+ },
168
+ });
169
+ return response.data.orders || [];
170
+ }
171
+ catch (error) {
172
+ console.error('❌ Failed to get orders:', error.message);
173
+ throw error;
174
+ }
175
+ }
176
+ }
177
+ exports.MarketplaceConsumer = MarketplaceConsumer;
178
+ /**
179
+ * ConversationWrapper
180
+ * Wraps a conversation with helper methods
181
+ */
182
+ class ConversationWrapper {
183
+ conversation;
184
+ apiUrl;
185
+ wallet;
186
+ settlementAgent;
187
+ messageHandlers = [];
188
+ deliveryHandlers = [];
189
+ pollingInterval;
190
+ constructor(conversation, apiUrl, wallet, settlementAgent) {
191
+ this.conversation = conversation;
192
+ this.apiUrl = apiUrl;
193
+ this.wallet = wallet;
194
+ this.settlementAgent = settlementAgent;
195
+ }
196
+ /**
197
+ * Get conversation ID
198
+ */
199
+ get id() {
200
+ return this.conversation.id;
201
+ }
202
+ /**
203
+ * Send message
204
+ */
205
+ async send(message, attachments) {
206
+ try {
207
+ await axios_1.default.post(`${this.apiUrl}/conversations/${this.conversation.id}/messages`, {
208
+ from: this.wallet.publicKey.toBase58(),
209
+ message,
210
+ attachments,
211
+ });
212
+ }
213
+ catch (error) {
214
+ console.error('❌ Failed to send message:', error.message);
215
+ throw error;
216
+ }
217
+ }
218
+ /**
219
+ * Get messages
220
+ */
221
+ async getMessages(limit = 50) {
222
+ try {
223
+ const response = await axios_1.default.get(`${this.apiUrl}/conversations/${this.conversation.id}/messages`, { params: { limit } });
224
+ return response.data.messages || [];
225
+ }
226
+ catch (error) {
227
+ console.error('❌ Failed to get messages:', error.message);
228
+ throw error;
229
+ }
230
+ }
231
+ /**
232
+ * Accept order and pay
233
+ */
234
+ async acceptOrder(orderId, options) {
235
+ try {
236
+ // Get order details
237
+ const orderResponse = await axios_1.default.get(`${this.apiUrl}/orders/${orderId}`);
238
+ const order = orderResponse.data;
239
+ console.log(`💳 Accepting order ${orderId}`);
240
+ console.log(`📊 Price: ${order.price} USDC`);
241
+ // Create signed payment with x402 to MARKETPLACE wallet (not directly to agent)
242
+ // Backend will split 90% to agent, 10% commission
243
+ const amount = options.paymentMethod === 'athr' ? order.price * 0.75 : order.price;
244
+ console.log(`💰 Creating x402 payment to marketplace (${amount} ${options.paymentMethod.toUpperCase()})`);
245
+ console.log(`📍 Marketplace wallet: ${MARKETPLACE_WALLET}`);
246
+ console.log(`📌 Backend will split: 90% to agent, 10% commission`);
247
+ const paymentHeader = await this.settlementAgent.createSignedPayment(MARKETPLACE_WALLET, // Pay marketplace, not agent directly
248
+ amount);
249
+ // Submit payment to marketplace
250
+ const response = await axios_1.default.post(`${this.apiUrl}/orders/${orderId}/accept`, {
251
+ clientWallet: this.wallet.publicKey.toBase58(),
252
+ paymentMethod: options.paymentMethod.toUpperCase(),
253
+ paymentHeader,
254
+ });
255
+ console.log('✅ Order accepted and paid:', orderId);
256
+ console.log('📝 Payment TX:', response.data.transactionSignature);
257
+ console.log(`💸 Agent receives: ${response.data.agentAmount} USDC`);
258
+ console.log(`💰 Commission: ${response.data.commissionAmount} USDC`);
259
+ return response.data;
260
+ }
261
+ catch (error) {
262
+ console.error('❌ Failed to accept order:', error.message);
263
+ throw error;
264
+ }
265
+ }
266
+ /**
267
+ * Decline order proposal
268
+ */
269
+ async declineOrder(orderId, reason) {
270
+ try {
271
+ await axios_1.default.post(`${this.apiUrl}/orders/${orderId}/decline`, {
272
+ clientWallet: this.wallet.publicKey.toBase58(),
273
+ reason,
274
+ });
275
+ console.log('❌ Order declined:', orderId);
276
+ // Optionally send message to agent
277
+ if (reason) {
278
+ await this.send(`I'm declining the order: ${reason}`);
279
+ }
280
+ }
281
+ catch (error) {
282
+ console.error('❌ Failed to decline order:', error.message);
283
+ throw error;
284
+ }
285
+ }
286
+ /**
287
+ * Counter-offer with different price/terms
288
+ */
289
+ async counterOffer(orderId, offer) {
290
+ try {
291
+ await axios_1.default.post(`${this.apiUrl}/orders/${orderId}/counter-offer`, {
292
+ clientWallet: this.wallet.publicKey.toBase58(),
293
+ ...offer,
294
+ });
295
+ console.log('💬 Counter-offer sent:', orderId);
296
+ // Send message to agent
297
+ await this.send(offer.message);
298
+ }
299
+ catch (error) {
300
+ console.error('❌ Failed to send counter-offer:', error.message);
301
+ throw error;
302
+ }
303
+ }
304
+ /**
305
+ * Review order
306
+ */
307
+ async review(orderId, review) {
308
+ try {
309
+ await axios_1.default.post(`${this.apiUrl}/orders/${orderId}/review`, {
310
+ clientWallet: this.wallet.publicKey.toBase58(),
311
+ ...review,
312
+ });
313
+ console.log('⭐ Review submitted:', orderId);
314
+ }
315
+ catch (error) {
316
+ console.error('❌ Failed to submit review:', error.message);
317
+ throw error;
318
+ }
319
+ }
320
+ on(event, handler) {
321
+ if (event === 'message') {
322
+ this.messageHandlers.push(handler);
323
+ // Start polling if not already started
324
+ if (!this.pollingInterval) {
325
+ this.startPolling();
326
+ }
327
+ }
328
+ else if (event === 'delivery') {
329
+ this.deliveryHandlers.push(handler);
330
+ if (!this.pollingInterval) {
331
+ this.startPolling();
332
+ }
333
+ }
334
+ }
335
+ /**
336
+ * Stop listening
337
+ */
338
+ stop() {
339
+ if (this.pollingInterval) {
340
+ clearInterval(this.pollingInterval);
341
+ }
342
+ }
343
+ /**
344
+ * Start polling for new messages and deliveries
345
+ */
346
+ startPolling(intervalMs = 3000) {
347
+ this.pollingInterval = setInterval(async () => {
348
+ try {
349
+ // Poll for new messages
350
+ const response = await axios_1.default.get(`${this.apiUrl}/conversations/${this.conversation.id}/messages/new`, {
351
+ params: { wallet: this.wallet.publicKey.toBase58() },
352
+ });
353
+ const newMessages = response.data.messages || [];
354
+ for (const msg of newMessages) {
355
+ // Trigger message handlers
356
+ for (const handler of this.messageHandlers) {
357
+ handler(msg);
358
+ }
359
+ }
360
+ // Poll for deliveries
361
+ const deliveryResponse = await axios_1.default.get(`${this.apiUrl}/conversations/${this.conversation.id}/deliveries/new`, {
362
+ params: { wallet: this.wallet.publicKey.toBase58() },
363
+ });
364
+ const newDeliveries = deliveryResponse.data.deliveries || [];
365
+ for (const delivery of newDeliveries) {
366
+ // Trigger delivery handlers
367
+ for (const handler of this.deliveryHandlers) {
368
+ handler(delivery);
369
+ }
370
+ }
371
+ }
372
+ catch (error) {
373
+ // Silent fail for polling
374
+ }
375
+ }, intervalMs);
376
+ }
377
+ }
378
+ exports.ConversationWrapper = ConversationWrapper;
379
+ //# sourceMappingURL=MarketplaceConsumer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarketplaceConsumer.js","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceConsumer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kDAA0B;AAC1B,+DAA4D;AAa5D,iFAAiF;AACjF,MAAM,kBAAkB,GAAG,OAAO,CAAC,GAAG,CAAC,kBAAkB,IAAI,mCAAmC,CAAC;AAEjG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,MAAa,mBAAmB;IACtB,MAAM,CAAS;IACf,MAAM,CAAM;IACZ,eAAe,CAAkB;IAEzC,YAAY,MAAgE;QAC1E,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC;QAC5B,IAAI,CAAC,eAAe,GAAG,IAAI,iCAAe,EAAE,CAAC;IAC/C,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,IAAI;QACR,MAAM,IAAI,CAAC,eAAe,CAAC,IAAI,EAAE,CAAC;IACpC,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,MAAM,CAAC,UAAoC,EAAE;QACjD,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,eAAK,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,MAAM,gBAAgB,EAAE;gBAC/D,MAAM,EAAE,OAAO;aAChB,CAAC,CAAC;YAEH,OAAO,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,IAAI,CAAC,gBAAgB,EAAE,CAAC;wBAC5C,OAAO,CAAC,QAAQ,CAAC,CAAC;oBACpB,CAAC;gBACH,CAAC;YACH,CAAC;YAAC,OAAO,KAAU,EAAE,CAAC;gBACpB,0BAA0B;YAC5B,CAAC;QACH,CAAC,EAAE,UAAU,CAAC,CAAC;IACjB,CAAC;CACF;AAzPD,kDAyPC"}
@@ -0,0 +1,124 @@
1
+ /**
2
+ * Aether Marketplace Provider
3
+ * SDK for agents that offer services on the marketplace
4
+ */
5
+ import { AgentProfile, AgentService, OrderProposal, Delivery, MessageHandler, OrderPaidHandler, MarketplaceConfig } from './types';
6
+ /**
7
+ * MarketplaceProvider
8
+ *
9
+ * Use this class when your agent OFFERS services on the marketplace.
10
+ *
11
+ * @example
12
+ * ```typescript
13
+ * const provider = new MarketplaceProvider({
14
+ * apiUrl: 'https://marketplace.aether.com/api',
15
+ * wallet: myKeypair,
16
+ * profile: {
17
+ * name: "Translation Pro",
18
+ * tagline: "Fast AI translation",
19
+ * categories: ['Translation'],
20
+ * basePrice: 0.10
21
+ * },
22
+ * services: [
23
+ * {
24
+ * title: "Translate up to 1000 words",
25
+ * price: 0.25,
26
+ * deliveryTime: 5
27
+ * }
28
+ * ]
29
+ * });
30
+ *
31
+ * await provider.register({
32
+ * endpoint: 'https://my-agent.com',
33
+ * stakeAmount: 1000
34
+ * });
35
+ *
36
+ * provider.onMessage(async (conversation, message) => {
37
+ * // Handle incoming messages
38
+ * });
39
+ *
40
+ * provider.onOrderPaid(async (order) => {
41
+ * // Do the work and deliver
42
+ * });
43
+ *
44
+ * provider.start();
45
+ * ```
46
+ */
47
+ export declare class MarketplaceProvider {
48
+ private apiUrl;
49
+ private wallet;
50
+ private profile;
51
+ private services;
52
+ private messageHandler?;
53
+ private orderPaidHandler?;
54
+ private pollingInterval?;
55
+ constructor(config: Omit<MarketplaceConfig, 'role'> & {
56
+ profile: AgentProfile;
57
+ services: AgentService[];
58
+ });
59
+ /**
60
+ * Register agent on marketplace
61
+ */
62
+ register(options: {
63
+ endpoint: string;
64
+ stakeAmount: number;
65
+ }): Promise<{
66
+ agentId: string;
67
+ }>;
68
+ /**
69
+ * Update agent profile
70
+ */
71
+ updateProfile(updates: Partial<AgentProfile>): Promise<void>;
72
+ /**
73
+ * Add or update service
74
+ */
75
+ updateServices(services: AgentService[]): Promise<void>;
76
+ /**
77
+ * Set message handler
78
+ */
79
+ onMessage(handler: MessageHandler): void;
80
+ /**
81
+ * Set order paid handler
82
+ */
83
+ onOrderPaid(handler: OrderPaidHandler): void;
84
+ /**
85
+ * Reply to a conversation
86
+ */
87
+ reply(conversationId: string, message: string, attachments?: any[]): Promise<void>;
88
+ /**
89
+ * Create order proposal
90
+ */
91
+ createOrder(conversationId: string, proposal: Omit<OrderProposal, 'conversationId'>): Promise<{
92
+ orderId: string;
93
+ }>;
94
+ /**
95
+ * Deliver order
96
+ */
97
+ deliver(orderId: string, delivery: Omit<Delivery, 'orderId' | 'deliveredAt'>): Promise<void>;
98
+ /**
99
+ * Get agent stats
100
+ */
101
+ getStats(): Promise<{
102
+ totalOrders: number;
103
+ rating: number;
104
+ responseTime: number;
105
+ completionRate: number;
106
+ }>;
107
+ /**
108
+ * Start listening for messages and orders
109
+ */
110
+ start(pollIntervalMs?: number): void;
111
+ /**
112
+ * Stop listening
113
+ */
114
+ stop(): void;
115
+ /**
116
+ * Poll for new messages
117
+ */
118
+ private pollMessages;
119
+ /**
120
+ * Poll for paid orders
121
+ */
122
+ private pollOrders;
123
+ }
124
+ //# sourceMappingURL=MarketplaceProvider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarketplaceProvider.d.ts","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceProvider.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,EACL,YAAY,EACZ,YAAY,EAIZ,aAAa,EACb,QAAQ,EACR,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EAClB,MAAM,SAAS,CAAC;AAEjB;;;;;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AAC;IAgBxH;;OAEG;IACG,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,GAAG,aAAa,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAclG;;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;IAaF;;OAEG;IACH,KAAK,CAAC,cAAc,GAAE,MAAa,GAAG,IAAI;IAiB1C;;OAEG;IACH,IAAI,IAAI,IAAI;IAOZ;;OAEG;YACW,YAAY;IAqB1B;;OAEG;YACW,UAAU;CAiBzB"}
@@ -0,0 +1,267 @@
1
+ "use strict";
2
+ /**
3
+ * Aether Marketplace Provider
4
+ * SDK for agents that offer services on the marketplace
5
+ */
6
+ var __importDefault = (this && this.__importDefault) || function (mod) {
7
+ return (mod && mod.__esModule) ? mod : { "default": mod };
8
+ };
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MarketplaceProvider = void 0;
11
+ const axios_1 = __importDefault(require("axios"));
12
+ /**
13
+ * MarketplaceProvider
14
+ *
15
+ * Use this class when your agent OFFERS services on the marketplace.
16
+ *
17
+ * @example
18
+ * ```typescript
19
+ * const provider = new MarketplaceProvider({
20
+ * apiUrl: 'https://marketplace.aether.com/api',
21
+ * wallet: myKeypair,
22
+ * profile: {
23
+ * name: "Translation Pro",
24
+ * tagline: "Fast AI translation",
25
+ * categories: ['Translation'],
26
+ * basePrice: 0.10
27
+ * },
28
+ * services: [
29
+ * {
30
+ * title: "Translate up to 1000 words",
31
+ * price: 0.25,
32
+ * deliveryTime: 5
33
+ * }
34
+ * ]
35
+ * });
36
+ *
37
+ * await provider.register({
38
+ * endpoint: 'https://my-agent.com',
39
+ * stakeAmount: 1000
40
+ * });
41
+ *
42
+ * provider.onMessage(async (conversation, message) => {
43
+ * // Handle incoming messages
44
+ * });
45
+ *
46
+ * provider.onOrderPaid(async (order) => {
47
+ * // Do the work and deliver
48
+ * });
49
+ *
50
+ * provider.start();
51
+ * ```
52
+ */
53
+ class MarketplaceProvider {
54
+ apiUrl;
55
+ wallet;
56
+ profile;
57
+ services;
58
+ messageHandler;
59
+ orderPaidHandler;
60
+ pollingInterval;
61
+ constructor(config) {
62
+ this.apiUrl = config.apiUrl;
63
+ this.wallet = config.wallet;
64
+ this.profile = config.profile;
65
+ this.services = config.services;
66
+ }
67
+ /**
68
+ * Register agent on marketplace
69
+ */
70
+ async register(options) {
71
+ try {
72
+ const response = await axios_1.default.post(`${this.apiUrl}/agents/register`, {
73
+ profile: this.profile,
74
+ services: this.services,
75
+ endpoint: options.endpoint,
76
+ ownerWallet: this.wallet.publicKey.toBase58(),
77
+ stakeAmount: options.stakeAmount,
78
+ });
79
+ console.log('✅ Agent registered on marketplace:', response.data.agentId);
80
+ return response.data;
81
+ }
82
+ catch (error) {
83
+ console.error('❌ Failed to register agent:', error.message);
84
+ throw error;
85
+ }
86
+ }
87
+ /**
88
+ * Update agent profile
89
+ */
90
+ async updateProfile(updates) {
91
+ try {
92
+ await axios_1.default.put(`${this.apiUrl}/agents/profile`, {
93
+ wallet: this.wallet.publicKey.toBase58(),
94
+ updates,
95
+ });
96
+ this.profile = { ...this.profile, ...updates };
97
+ console.log('✅ Profile updated');
98
+ }
99
+ catch (error) {
100
+ console.error('❌ Failed to update profile:', error.message);
101
+ throw error;
102
+ }
103
+ }
104
+ /**
105
+ * Add or update service
106
+ */
107
+ async updateServices(services) {
108
+ try {
109
+ await axios_1.default.put(`${this.apiUrl}/agents/services`, {
110
+ wallet: this.wallet.publicKey.toBase58(),
111
+ services,
112
+ });
113
+ this.services = services;
114
+ console.log('✅ Services updated');
115
+ }
116
+ catch (error) {
117
+ console.error('❌ Failed to update services:', error.message);
118
+ throw error;
119
+ }
120
+ }
121
+ /**
122
+ * Set message handler
123
+ */
124
+ onMessage(handler) {
125
+ this.messageHandler = handler;
126
+ }
127
+ /**
128
+ * Set order paid handler
129
+ */
130
+ onOrderPaid(handler) {
131
+ this.orderPaidHandler = handler;
132
+ }
133
+ /**
134
+ * Reply to a conversation
135
+ */
136
+ async reply(conversationId, message, attachments) {
137
+ try {
138
+ await axios_1.default.post(`${this.apiUrl}/conversations/${conversationId}/messages`, {
139
+ from: this.wallet.publicKey.toBase58(),
140
+ message,
141
+ attachments,
142
+ });
143
+ }
144
+ catch (error) {
145
+ console.error('❌ Failed to send message:', error.message);
146
+ throw error;
147
+ }
148
+ }
149
+ /**
150
+ * Create order proposal
151
+ */
152
+ async createOrder(conversationId, proposal) {
153
+ try {
154
+ const response = await axios_1.default.post(`${this.apiUrl}/orders`, {
155
+ conversationId,
156
+ agentWallet: this.wallet.publicKey.toBase58(),
157
+ ...proposal,
158
+ });
159
+ console.log('📄 Order created:', response.data.orderId);
160
+ return response.data;
161
+ }
162
+ catch (error) {
163
+ console.error('❌ Failed to create order:', error.message);
164
+ throw error;
165
+ }
166
+ }
167
+ /**
168
+ * Deliver order
169
+ */
170
+ async deliver(orderId, delivery) {
171
+ try {
172
+ await axios_1.default.post(`${this.apiUrl}/orders/${orderId}/deliver`, {
173
+ agentWallet: this.wallet.publicKey.toBase58(),
174
+ ...delivery,
175
+ });
176
+ console.log('✅ Order delivered:', orderId);
177
+ }
178
+ catch (error) {
179
+ console.error('❌ Failed to deliver order:', error.message);
180
+ throw error;
181
+ }
182
+ }
183
+ /**
184
+ * Get agent stats
185
+ */
186
+ async getStats() {
187
+ try {
188
+ const response = await axios_1.default.get(`${this.apiUrl}/agents/stats`, {
189
+ params: { wallet: this.wallet.publicKey.toBase58() },
190
+ });
191
+ return response.data;
192
+ }
193
+ catch (error) {
194
+ console.error('❌ Failed to fetch stats:', error.message);
195
+ throw error;
196
+ }
197
+ }
198
+ /**
199
+ * Start listening for messages and orders
200
+ */
201
+ start(pollIntervalMs = 5000) {
202
+ console.log('🚀 Marketplace Provider started');
203
+ console.log(`📡 Polling every ${pollIntervalMs}ms for new messages and orders`);
204
+ this.pollingInterval = setInterval(async () => {
205
+ try {
206
+ // Poll for new messages
207
+ await this.pollMessages();
208
+ // Poll for paid orders
209
+ await this.pollOrders();
210
+ }
211
+ catch (error) {
212
+ console.error('❌ Polling error:', error.message);
213
+ }
214
+ }, pollIntervalMs);
215
+ }
216
+ /**
217
+ * Stop listening
218
+ */
219
+ stop() {
220
+ if (this.pollingInterval) {
221
+ clearInterval(this.pollingInterval);
222
+ console.log('🛑 Marketplace Provider stopped');
223
+ }
224
+ }
225
+ /**
226
+ * Poll for new messages
227
+ */
228
+ async pollMessages() {
229
+ if (!this.messageHandler)
230
+ return;
231
+ try {
232
+ const response = await axios_1.default.get(`${this.apiUrl}/agents/messages/new`, {
233
+ params: { wallet: this.wallet.publicKey.toBase58() },
234
+ });
235
+ const newMessages = response.data.messages || [];
236
+ for (const msg of newMessages) {
237
+ const conversation = msg.conversation;
238
+ const message = msg.message;
239
+ await this.messageHandler(conversation, message);
240
+ }
241
+ }
242
+ catch (error) {
243
+ // Silent fail for polling
244
+ }
245
+ }
246
+ /**
247
+ * Poll for paid orders
248
+ */
249
+ async pollOrders() {
250
+ if (!this.orderPaidHandler)
251
+ return;
252
+ try {
253
+ const response = await axios_1.default.get(`${this.apiUrl}/agents/orders/paid`, {
254
+ params: { wallet: this.wallet.publicKey.toBase58() },
255
+ });
256
+ const paidOrders = response.data.orders || [];
257
+ for (const order of paidOrders) {
258
+ await this.orderPaidHandler(order);
259
+ }
260
+ }
261
+ catch (error) {
262
+ // Silent fail for polling
263
+ }
264
+ }
265
+ }
266
+ exports.MarketplaceProvider = MarketplaceProvider;
267
+ //# sourceMappingURL=MarketplaceProvider.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"MarketplaceProvider.js","sourceRoot":"","sources":["../../../src/marketplace/MarketplaceProvider.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;AAEH,kDAA0B;AA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CAAC;YAE9C,KAAK,MAAM,KAAK,IAAI,UAAU,EAAE,CAAC;gBAC/B,MAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;YACrC,CAAC;QACH,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YACpB,0BAA0B;QAC5B,CAAC;IACH,CAAC;CACF;AA7OD,kDA6OC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Aether Marketplace SDK
3
+ *
4
+ * @module marketplace
5
+ */
6
+ export * from './types';
7
+ export { MarketplaceProvider } from './MarketplaceProvider';
8
+ export { MarketplaceConsumer, ConversationWrapper } from './MarketplaceConsumer';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/marketplace/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ /**
3
+ * Aether Marketplace SDK
4
+ *
5
+ * @module marketplace
6
+ */
7
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
8
+ if (k2 === undefined) k2 = k;
9
+ var desc = Object.getOwnPropertyDescriptor(m, k);
10
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
11
+ desc = { enumerable: true, get: function() { return m[k]; } };
12
+ }
13
+ Object.defineProperty(o, k2, desc);
14
+ }) : (function(o, m, k, k2) {
15
+ if (k2 === undefined) k2 = k;
16
+ o[k2] = m[k];
17
+ }));
18
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
19
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
20
+ };
21
+ Object.defineProperty(exports, "__esModule", { value: true });
22
+ exports.ConversationWrapper = exports.MarketplaceConsumer = exports.MarketplaceProvider = void 0;
23
+ __exportStar(require("./types"), exports);
24
+ var MarketplaceProvider_1 = require("./MarketplaceProvider");
25
+ Object.defineProperty(exports, "MarketplaceProvider", { enumerable: true, get: function () { return MarketplaceProvider_1.MarketplaceProvider; } });
26
+ var MarketplaceConsumer_1 = require("./MarketplaceConsumer");
27
+ Object.defineProperty(exports, "MarketplaceConsumer", { enumerable: true, get: function () { return MarketplaceConsumer_1.MarketplaceConsumer; } });
28
+ Object.defineProperty(exports, "ConversationWrapper", { enumerable: true, get: function () { return MarketplaceConsumer_1.ConversationWrapper; } });
29
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/marketplace/index.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;AAEH,0CAAwB;AACxB,6DAA4D;AAAnD,0HAAA,mBAAmB,OAAA;AAC5B,6DAAiF;AAAxE,0HAAA,mBAAmB,OAAA;AAAE,0HAAA,mBAAmB,OAAA"}
@@ -0,0 +1,168 @@
1
+ /**
2
+ * Aether Marketplace Types
3
+ * Type definitions for marketplace agents
4
+ */
5
+ /**
6
+ * Agent role in marketplace
7
+ */
8
+ export type AgentRole = 'provider' | 'consumer';
9
+ /**
10
+ * Agent profile information
11
+ */
12
+ export interface AgentProfile {
13
+ name: string;
14
+ tagline: string;
15
+ description: string;
16
+ categories: string[];
17
+ basePrice: number;
18
+ avatar?: string;
19
+ skills?: string[];
20
+ languages?: string[];
21
+ }
22
+ /**
23
+ * Service offered by an agent
24
+ */
25
+ export interface AgentService {
26
+ id?: string;
27
+ title: string;
28
+ description: string;
29
+ price: number;
30
+ priceAthr?: number;
31
+ deliveryTime: number;
32
+ examples?: string[];
33
+ }
34
+ /**
35
+ * Marketplace registration info
36
+ */
37
+ export interface MarketplaceRegistration {
38
+ endpoint: string;
39
+ profile: AgentProfile;
40
+ services: AgentService[];
41
+ stakeAmount: number;
42
+ }
43
+ /**
44
+ * Message in a conversation
45
+ */
46
+ export interface ConversationMessage {
47
+ id: string;
48
+ conversationId: string;
49
+ from: string;
50
+ message: string;
51
+ attachments?: any[];
52
+ timestamp: Date;
53
+ hasOrder?: boolean;
54
+ order?: OrderProposal;
55
+ }
56
+ /**
57
+ * Order proposal
58
+ */
59
+ export interface OrderProposal {
60
+ id?: string;
61
+ conversationId: string;
62
+ serviceId?: string;
63
+ description: string;
64
+ price: number;
65
+ priceAthr?: number;
66
+ deliveryTime: number;
67
+ deadline?: Date;
68
+ }
69
+ /**
70
+ * Order status
71
+ */
72
+ export type OrderStatus = 'pending' | 'declined' | 'negotiating' | 'paid' | 'in_progress' | 'delivered' | 'completed' | 'disputed' | 'cancelled';
73
+ /**
74
+ * Order object
75
+ */
76
+ export interface Order {
77
+ id: string;
78
+ conversationId: string;
79
+ agentId: string;
80
+ clientWallet: string;
81
+ serviceId?: string;
82
+ description: string;
83
+ price: number;
84
+ paymentMethod: 'usdc' | 'athr';
85
+ status: OrderStatus;
86
+ escrowTx?: string;
87
+ deliveryTx?: string;
88
+ deadline?: Date;
89
+ createdAt: Date;
90
+ }
91
+ /**
92
+ * Delivery object
93
+ */
94
+ export interface Delivery {
95
+ orderId: string;
96
+ result: any;
97
+ message?: string;
98
+ attachments?: string[];
99
+ deliveredAt: Date;
100
+ }
101
+ /**
102
+ * Review object
103
+ */
104
+ export interface Review {
105
+ orderId: string;
106
+ agentId: string;
107
+ rating: number;
108
+ comment?: string;
109
+ createdAt: Date;
110
+ }
111
+ /**
112
+ * Search filters
113
+ */
114
+ export interface MarketplaceSearchFilters {
115
+ category?: string;
116
+ maxPrice?: number;
117
+ minRating?: number;
118
+ deliveryTime?: number;
119
+ query?: string;
120
+ }
121
+ /**
122
+ * Agent search result
123
+ */
124
+ export interface AgentSearchResult {
125
+ id: string;
126
+ name: string;
127
+ tagline: string;
128
+ categories: string[];
129
+ basePrice: number;
130
+ rating: number;
131
+ totalOrders: number;
132
+ responseTime: number;
133
+ avatar?: string;
134
+ }
135
+ /**
136
+ * Conversation object
137
+ */
138
+ export interface Conversation {
139
+ id: string;
140
+ agentId: string;
141
+ clientWallet: string;
142
+ clientType: 'agent' | 'person';
143
+ lastMessageAt: Date;
144
+ status: 'active' | 'archived';
145
+ }
146
+ /**
147
+ * Message handler callback
148
+ */
149
+ export type MessageHandler = (conversation: Conversation, message: ConversationMessage) => Promise<void>;
150
+ /**
151
+ * Order paid handler callback
152
+ */
153
+ export type OrderPaidHandler = (order: Order) => Promise<void>;
154
+ /**
155
+ * Delivery handler callback
156
+ */
157
+ export type DeliveryHandler = (delivery: Delivery) => Promise<void>;
158
+ /**
159
+ * Marketplace configuration
160
+ */
161
+ export interface MarketplaceConfig {
162
+ apiUrl: string;
163
+ wallet: any;
164
+ role: AgentRole;
165
+ profile?: AgentProfile;
166
+ services?: AgentService[];
167
+ }
168
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/marketplace/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAIH;;GAEG;AACH,MAAM,MAAM,SAAS,GAAG,UAAU,GAAG,UAAU,CAAC;AAEhD;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,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E,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,OAAO,GAAG,QAAQ,CAAC;IAC/B,aAAa,EAAE,IAAI,CAAC;IACpB,MAAM,EAAE,QAAQ,GAAG,UAAU,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,CAC3B,YAAY,EAAE,YAAY,EAC1B,OAAO,EAAE,mBAAmB,KACzB,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB;;GAEG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAAC,KAAK,EAAE,KAAK,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,MAAM,eAAe,GAAG,CAAC,QAAQ,EAAE,QAAQ,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;AAEpE;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,GAAG,CAAC;IACZ,IAAI,EAAE,SAAS,CAAC;IAChB,OAAO,CAAC,EAAE,YAAY,CAAC;IACvB,QAAQ,CAAC,EAAE,YAAY,EAAE,CAAC;CAC3B"}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ /**
3
+ * Aether Marketplace Types
4
+ * Type definitions for marketplace agents
5
+ */
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/marketplace/types.ts"],"names":[],"mappings":";AAAA;;;GAGG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aether-agent-sdk",
3
- "version": "1.0.7",
3
+ "version": "2.0.2",
4
4
  "description": "Autonomous Agent Ecosystem SDK for Solana - A2A Protocol, x402 Payment Standard, and Agent-to-Agent Communication",
5
5
  "main": "./dist/src/index.js",
6
6
  "types": "./dist/src/index.d.ts",
@@ -34,6 +34,11 @@
34
34
  "import": "./dist/src/facilitator/index.js",
35
35
  "require": "./dist/src/facilitator/index.js",
36
36
  "types": "./dist/src/facilitator/index.d.ts"
37
+ },
38
+ "./marketplace": {
39
+ "import": "./dist/src/marketplace/index.js",
40
+ "require": "./dist/src/marketplace/index.js",
41
+ "types": "./dist/src/marketplace/index.d.ts"
37
42
  }
38
43
  },
39
44
  "files": [