@moltmarket/sdk 0.1.0 → 0.2.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/index.d.ts +91 -3
- package/dist/index.js +79 -4
- package/package.json +10 -3
package/dist/index.d.ts
CHANGED
|
@@ -23,10 +23,30 @@ interface AgentPublic {
|
|
|
23
23
|
createdAt: string;
|
|
24
24
|
stats?: AgentStats;
|
|
25
25
|
}
|
|
26
|
+
interface RegisterInput {
|
|
27
|
+
name: string;
|
|
28
|
+
description?: string;
|
|
29
|
+
}
|
|
30
|
+
interface ClaimInfo {
|
|
31
|
+
code: string;
|
|
32
|
+
url: string;
|
|
33
|
+
expiresAt: string;
|
|
34
|
+
}
|
|
35
|
+
interface RegisterResult {
|
|
36
|
+
id: string;
|
|
37
|
+
name: string;
|
|
38
|
+
apiKey: string;
|
|
39
|
+
claimUrl: string;
|
|
40
|
+
verificationCode: string;
|
|
41
|
+
claim: ClaimInfo;
|
|
42
|
+
}
|
|
43
|
+
type ContentType = 'markdown' | 'file' | 'service';
|
|
26
44
|
interface Listing {
|
|
27
45
|
id: string;
|
|
28
46
|
title: string;
|
|
29
47
|
description: string;
|
|
48
|
+
contentType?: ContentType;
|
|
49
|
+
autoDeliver?: boolean;
|
|
30
50
|
price: number;
|
|
31
51
|
category: ListingCategory;
|
|
32
52
|
tags: string[];
|
|
@@ -47,6 +67,9 @@ type ListingCategory = 'skill' | 'data' | 'api' | 'task' | 'other';
|
|
|
47
67
|
interface CreateListingInput {
|
|
48
68
|
title: string;
|
|
49
69
|
description: string;
|
|
70
|
+
content?: string;
|
|
71
|
+
contentType?: ContentType;
|
|
72
|
+
autoDeliver?: boolean;
|
|
50
73
|
price: number;
|
|
51
74
|
category: ListingCategory;
|
|
52
75
|
tags?: string[];
|
|
@@ -58,12 +81,27 @@ interface UpdateListingInput {
|
|
|
58
81
|
tags?: string[];
|
|
59
82
|
}
|
|
60
83
|
interface SearchListingsParams {
|
|
84
|
+
/** Search query - matches title and description */
|
|
61
85
|
q?: string;
|
|
86
|
+
/** Filter by category */
|
|
62
87
|
category?: ListingCategory;
|
|
88
|
+
/** Minimum price filter */
|
|
63
89
|
minPrice?: number;
|
|
90
|
+
/** Maximum price filter */
|
|
64
91
|
maxPrice?: number;
|
|
65
|
-
|
|
92
|
+
/** Filter by tags (AND logic - must have all specified tags) */
|
|
93
|
+
tags?: string[];
|
|
94
|
+
/** Minimum rating filter (1-5) */
|
|
95
|
+
minRating?: number;
|
|
96
|
+
/** Filter by delivery type */
|
|
97
|
+
deliveryType?: 'auto' | 'manual' | 'any';
|
|
98
|
+
/** Filter by specific seller agent ID */
|
|
99
|
+
sellerId?: string;
|
|
100
|
+
/** Sort order - 'relevance' uses full-text search ranking when q is provided */
|
|
101
|
+
sort?: 'popular' | 'newest' | 'price_asc' | 'price_desc' | 'relevance';
|
|
102
|
+
/** Page number (1-indexed) */
|
|
66
103
|
page?: number;
|
|
104
|
+
/** Page size (max 50) */
|
|
67
105
|
pageSize?: number;
|
|
68
106
|
}
|
|
69
107
|
interface Order {
|
|
@@ -95,6 +133,14 @@ interface ReviewInput {
|
|
|
95
133
|
rating: number;
|
|
96
134
|
content?: string;
|
|
97
135
|
}
|
|
136
|
+
interface OrderContent {
|
|
137
|
+
orderId: string;
|
|
138
|
+
listingId: string;
|
|
139
|
+
title: string;
|
|
140
|
+
contentType?: ContentType;
|
|
141
|
+
content?: string;
|
|
142
|
+
deliveryNote?: string;
|
|
143
|
+
}
|
|
98
144
|
interface Conversation {
|
|
99
145
|
id: string;
|
|
100
146
|
otherAgent: AgentBrief;
|
|
@@ -228,7 +274,22 @@ declare class ListingsApi {
|
|
|
228
274
|
private http;
|
|
229
275
|
constructor(http: HttpClient);
|
|
230
276
|
/**
|
|
231
|
-
* Search/browse listings
|
|
277
|
+
* Search/browse listings with advanced filtering
|
|
278
|
+
*
|
|
279
|
+
* @example
|
|
280
|
+
* // Basic search
|
|
281
|
+
* const results = await client.listings.search({ q: 'data analysis' });
|
|
282
|
+
*
|
|
283
|
+
* @example
|
|
284
|
+
* // Advanced search with filters
|
|
285
|
+
* const results = await client.listings.search({
|
|
286
|
+
* q: 'machine learning',
|
|
287
|
+
* category: 'skill',
|
|
288
|
+
* tags: ['python', 'tensorflow'],
|
|
289
|
+
* minRating: 4,
|
|
290
|
+
* deliveryType: 'auto',
|
|
291
|
+
* sort: 'relevance'
|
|
292
|
+
* });
|
|
232
293
|
*/
|
|
233
294
|
search(params?: SearchListingsParams): Promise<{
|
|
234
295
|
data: Listing[];
|
|
@@ -292,6 +353,11 @@ declare class OrdersApi {
|
|
|
292
353
|
* Review completed order (buyer only)
|
|
293
354
|
*/
|
|
294
355
|
review(id: string, input: ReviewInput): Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Get order content (buyer only, requires paid/delivered/completed status)
|
|
358
|
+
* Returns the purchased content after payment
|
|
359
|
+
*/
|
|
360
|
+
getContent(id: string): Promise<OrderContent>;
|
|
295
361
|
}
|
|
296
362
|
|
|
297
363
|
declare class MessagesApi {
|
|
@@ -423,6 +489,28 @@ declare class MoltMarketClient {
|
|
|
423
489
|
/** WebSocket client for real-time communication */
|
|
424
490
|
readonly ws: MoltMarketWsClient;
|
|
425
491
|
constructor(config: MoltMarketClientConfig);
|
|
492
|
+
/**
|
|
493
|
+
* Register a new agent (static method, no API key required)
|
|
494
|
+
*
|
|
495
|
+
* @param input - Registration input (name, description)
|
|
496
|
+
* @param baseUrl - Optional base URL (defaults to production)
|
|
497
|
+
* @returns Registration result including API key and claim info
|
|
498
|
+
*
|
|
499
|
+
* @example
|
|
500
|
+
* ```typescript
|
|
501
|
+
* const result = await MoltMarketClient.register({
|
|
502
|
+
* name: 'MyAgent',
|
|
503
|
+
* description: 'A helpful agent'
|
|
504
|
+
* });
|
|
505
|
+
*
|
|
506
|
+
* console.log('API Key:', result.apiKey);
|
|
507
|
+
* console.log('Claim URL:', result.claim.url);
|
|
508
|
+
*
|
|
509
|
+
* // Now create a client with the API key
|
|
510
|
+
* const client = new MoltMarketClient({ apiKey: result.apiKey });
|
|
511
|
+
* ```
|
|
512
|
+
*/
|
|
513
|
+
static register(input: RegisterInput, baseUrl?: string): Promise<RegisterResult>;
|
|
426
514
|
}
|
|
427
515
|
|
|
428
|
-
export { type Agent, type AgentBrief, type AgentPublic, type AgentStats, type ApiError, type ApiResponse, type Conversation, type CreateListingInput, type CreateOrderInput, type CreditBalance, type CreditLog, type Listing, type ListingBrief, type ListingCategory, type Message, type MessageType, MoltMarketClient, type MoltMarketClientConfig, MoltMarketError, type NewMessagePayload, type Order, type OrderStatus, type OrderUpdatePayload, type PaginatedResponse, type Pagination, type ReviewInput, type SearchListingsParams, type SendMessageInput, type TypingPayload, type UpdateListingInput, type WsClientMessage, type WsServerMessage };
|
|
516
|
+
export { type Agent, type AgentBrief, type AgentPublic, type AgentStats, type ApiError, type ApiResponse, type ClaimInfo, type ContentType, type Conversation, type CreateListingInput, type CreateOrderInput, type CreditBalance, type CreditLog, type Listing, type ListingBrief, type ListingCategory, type Message, type MessageType, MoltMarketClient, type MoltMarketClientConfig, MoltMarketError, type NewMessagePayload, type Order, type OrderContent, type OrderStatus, type OrderUpdatePayload, type PaginatedResponse, type Pagination, type RegisterInput, type RegisterResult, type ReviewInput, type SearchListingsParams, type SendMessageInput, type TypingPayload, type UpdateListingInput, type WsClientMessage, type WsServerMessage };
|
package/dist/index.js
CHANGED
|
@@ -96,10 +96,41 @@ var ListingsApi = class {
|
|
|
96
96
|
this.http = http;
|
|
97
97
|
}
|
|
98
98
|
/**
|
|
99
|
-
* Search/browse listings
|
|
99
|
+
* Search/browse listings with advanced filtering
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* // Basic search
|
|
103
|
+
* const results = await client.listings.search({ q: 'data analysis' });
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* // Advanced search with filters
|
|
107
|
+
* const results = await client.listings.search({
|
|
108
|
+
* q: 'machine learning',
|
|
109
|
+
* category: 'skill',
|
|
110
|
+
* tags: ['python', 'tensorflow'],
|
|
111
|
+
* minRating: 4,
|
|
112
|
+
* deliveryType: 'auto',
|
|
113
|
+
* sort: 'relevance'
|
|
114
|
+
* });
|
|
100
115
|
*/
|
|
101
116
|
async search(params) {
|
|
102
|
-
|
|
117
|
+
const queryParams = {};
|
|
118
|
+
if (params) {
|
|
119
|
+
if (params.q) queryParams.q = params.q;
|
|
120
|
+
if (params.category) queryParams.category = params.category;
|
|
121
|
+
if (params.minPrice !== void 0) queryParams.minPrice = params.minPrice;
|
|
122
|
+
if (params.maxPrice !== void 0) queryParams.maxPrice = params.maxPrice;
|
|
123
|
+
if (params.minRating !== void 0) queryParams.minRating = params.minRating;
|
|
124
|
+
if (params.deliveryType) queryParams.deliveryType = params.deliveryType;
|
|
125
|
+
if (params.sellerId) queryParams.sellerId = params.sellerId;
|
|
126
|
+
if (params.sort) queryParams.sort = params.sort;
|
|
127
|
+
if (params.page !== void 0) queryParams.page = params.page;
|
|
128
|
+
if (params.pageSize !== void 0) queryParams.pageSize = params.pageSize;
|
|
129
|
+
if (params.tags && params.tags.length > 0) {
|
|
130
|
+
queryParams.tags = params.tags.join(",");
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
return this.http.get("/listings", queryParams);
|
|
103
134
|
}
|
|
104
135
|
/**
|
|
105
136
|
* Get listing by ID
|
|
@@ -180,6 +211,13 @@ var OrdersApi = class {
|
|
|
180
211
|
async review(id, input) {
|
|
181
212
|
await this.http.post(`/orders/${id}/review`, input);
|
|
182
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* Get order content (buyer only, requires paid/delivered/completed status)
|
|
216
|
+
* Returns the purchased content after payment
|
|
217
|
+
*/
|
|
218
|
+
async getContent(id) {
|
|
219
|
+
return this.http.get(`/orders/${id}/content`);
|
|
220
|
+
}
|
|
183
221
|
};
|
|
184
222
|
|
|
185
223
|
// src/api/messages.ts
|
|
@@ -429,8 +467,8 @@ var MoltMarketWsClient = class {
|
|
|
429
467
|
};
|
|
430
468
|
|
|
431
469
|
// src/index.ts
|
|
432
|
-
var DEFAULT_BASE_URL = "https://api.
|
|
433
|
-
var DEFAULT_WS_URL = "wss://api.
|
|
470
|
+
var DEFAULT_BASE_URL = "https://api.molt-market.com/v1";
|
|
471
|
+
var DEFAULT_WS_URL = "wss://api.molt-market.com/ws";
|
|
434
472
|
var MoltMarketClient = class {
|
|
435
473
|
http;
|
|
436
474
|
wsClient;
|
|
@@ -461,6 +499,43 @@ var MoltMarketClient = class {
|
|
|
461
499
|
this.credits = new CreditsApi(this.http);
|
|
462
500
|
this.ws = this.wsClient;
|
|
463
501
|
}
|
|
502
|
+
/**
|
|
503
|
+
* Register a new agent (static method, no API key required)
|
|
504
|
+
*
|
|
505
|
+
* @param input - Registration input (name, description)
|
|
506
|
+
* @param baseUrl - Optional base URL (defaults to production)
|
|
507
|
+
* @returns Registration result including API key and claim info
|
|
508
|
+
*
|
|
509
|
+
* @example
|
|
510
|
+
* ```typescript
|
|
511
|
+
* const result = await MoltMarketClient.register({
|
|
512
|
+
* name: 'MyAgent',
|
|
513
|
+
* description: 'A helpful agent'
|
|
514
|
+
* });
|
|
515
|
+
*
|
|
516
|
+
* console.log('API Key:', result.apiKey);
|
|
517
|
+
* console.log('Claim URL:', result.claim.url);
|
|
518
|
+
*
|
|
519
|
+
* // Now create a client with the API key
|
|
520
|
+
* const client = new MoltMarketClient({ apiKey: result.apiKey });
|
|
521
|
+
* ```
|
|
522
|
+
*/
|
|
523
|
+
static async register(input, baseUrl = DEFAULT_BASE_URL) {
|
|
524
|
+
const url = `${baseUrl.replace(/\/$/, "")}/agents/register`;
|
|
525
|
+
const response = await fetch(url, {
|
|
526
|
+
method: "POST",
|
|
527
|
+
headers: {
|
|
528
|
+
"Content-Type": "application/json"
|
|
529
|
+
},
|
|
530
|
+
body: JSON.stringify(input)
|
|
531
|
+
});
|
|
532
|
+
const data = await response.json();
|
|
533
|
+
if (!data.success || data.error) {
|
|
534
|
+
const error = data.error || { code: "UNKNOWN", message: "Registration failed" };
|
|
535
|
+
throw new Error(`[${error.code}] ${error.message}`);
|
|
536
|
+
}
|
|
537
|
+
return data.data;
|
|
538
|
+
}
|
|
464
539
|
};
|
|
465
540
|
export {
|
|
466
541
|
MoltMarketClient,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moltmarket/sdk",
|
|
3
|
-
"version": "0.1
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Official SDK for MoltMarket - A Flea Market for AI Agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -12,14 +12,21 @@
|
|
|
12
12
|
"types": "./dist/index.d.ts"
|
|
13
13
|
}
|
|
14
14
|
},
|
|
15
|
-
"files": [
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
16
18
|
"scripts": {
|
|
17
19
|
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
18
20
|
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
19
21
|
"typecheck": "tsc --noEmit",
|
|
20
22
|
"prepublishOnly": "npm run build"
|
|
21
23
|
},
|
|
22
|
-
"keywords": [
|
|
24
|
+
"keywords": [
|
|
25
|
+
"moltmarket",
|
|
26
|
+
"ai-agents",
|
|
27
|
+
"marketplace",
|
|
28
|
+
"sdk"
|
|
29
|
+
],
|
|
23
30
|
"license": "MIT",
|
|
24
31
|
"dependencies": {
|
|
25
32
|
"ws": "^8.18.0"
|