aether-agent-sdk 1.0.6 → 2.0.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/README.md +9 -18
- package/dist/src/agents/SettlementAgent.d.ts +1 -3
- package/dist/src/agents/SettlementAgent.d.ts.map +1 -1
- package/dist/src/agents/SettlementAgent.js +1 -28
- package/dist/src/agents/SettlementAgent.js.map +1 -1
- package/dist/src/index.d.ts +1 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +2 -0
- package/dist/src/index.js.map +1 -1
- package/dist/src/marketplace/MarketplaceConsumer.d.ts +148 -0
- package/dist/src/marketplace/MarketplaceConsumer.d.ts.map +1 -0
- package/dist/src/marketplace/MarketplaceConsumer.js +379 -0
- package/dist/src/marketplace/MarketplaceConsumer.js.map +1 -0
- package/dist/src/marketplace/MarketplaceProvider.d.ts +124 -0
- package/dist/src/marketplace/MarketplaceProvider.d.ts.map +1 -0
- package/dist/src/marketplace/MarketplaceProvider.js +267 -0
- package/dist/src/marketplace/MarketplaceProvider.js.map +1 -0
- package/dist/src/marketplace/index.d.ts +9 -0
- package/dist/src/marketplace/index.d.ts.map +1 -0
- package/dist/src/marketplace/index.js +29 -0
- package/dist/src/marketplace/index.js.map +1 -0
- package/dist/src/marketplace/types.d.ts +168 -0
- package/dist/src/marketplace/types.d.ts.map +1 -0
- package/dist/src/marketplace/types.js +7 -0
- package/dist/src/marketplace/types.js.map +1 -0
- package/package.json +1 -3
|
@@ -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;AAc1B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,MA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AM,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,MAA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.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "aether-agent-sdk",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.1",
|
|
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",
|
|
@@ -60,8 +60,6 @@
|
|
|
60
60
|
"build": "tsc",
|
|
61
61
|
"start": "node dist/index.js",
|
|
62
62
|
"dev": "ts-node src/index.ts",
|
|
63
|
-
"demo": "ts-node demo/orchestrator.ts",
|
|
64
|
-
"demo:payment": "ts-node demo/solana-x402-payment.ts",
|
|
65
63
|
"release": "npm run build && npm version patch && npm publish"
|
|
66
64
|
},
|
|
67
65
|
"repository": {
|