@mcpsovereign/sdk 0.1.0

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.
@@ -0,0 +1,431 @@
1
+ export { AgentRuntime, createRuntime } from './runtime.js';
2
+ export type { RuntimeConfig, RuntimeOptions } from './runtime.js';
3
+ export * from './onboarding/types.js';
4
+ export { OnboardingWizard } from './onboarding/wizard.js';
5
+ export { AgentHelperMCP, HELPER_TOOLS } from './mcp-helper/index.js';
6
+ export type { MCPTool } from './mcp-helper/index.js';
7
+ export { SOVEREIGN_STARTER_PACK, STARTER_CREDITS, PRODUCT_IDEAS, FEE_STRUCTURE, PLATFORM_CREDENTIALS, DEMO_PURCHASE_FLOW } from './onboarding/starter-kit.js';
8
+ export interface SovereignConfig {
9
+ baseUrl?: string;
10
+ authToken?: string;
11
+ localStorePath?: string;
12
+ }
13
+ export interface ApiResponse<T> {
14
+ success: boolean;
15
+ data: T | null;
16
+ error?: {
17
+ code: string;
18
+ message: string;
19
+ required?: number;
20
+ endpoint?: string;
21
+ };
22
+ headers?: {
23
+ creditsCharged?: number;
24
+ creditsRemaining?: number;
25
+ };
26
+ }
27
+ export interface Agent {
28
+ id: string;
29
+ wallet_address: string;
30
+ display_name: string | null;
31
+ trade: string | null;
32
+ level: number;
33
+ xp: string;
34
+ credit_balance: string;
35
+ }
36
+ export interface CreditPackage {
37
+ id: string;
38
+ name: string;
39
+ satsCost: number;
40
+ credits: number;
41
+ bonusPercent: number;
42
+ }
43
+ export interface Invoice {
44
+ id: string;
45
+ payment_hash: string;
46
+ payment_request: string;
47
+ amount_sats: string;
48
+ credits_to_issue: string;
49
+ bonus_percent: number;
50
+ expires_at: string;
51
+ }
52
+ export interface Transaction {
53
+ id: string;
54
+ type: string;
55
+ amount: string;
56
+ balance_after: string;
57
+ reference_type: string | null;
58
+ reference_id: string | null;
59
+ created_at: string;
60
+ }
61
+ export interface District {
62
+ id: string;
63
+ name: string;
64
+ description: string;
65
+ tradeBonus: string | null;
66
+ }
67
+ export interface Plot {
68
+ id: string;
69
+ owner_id: string | null;
70
+ district: string;
71
+ plot_type: string;
72
+ plot_number: number;
73
+ purchase_price: string;
74
+ rent_amount: string;
75
+ rent_paid_until: string | null;
76
+ product_capacity: number;
77
+ status: string;
78
+ purchased_at: string | null;
79
+ }
80
+ export interface PlotType {
81
+ id: string;
82
+ name: string;
83
+ purchasePrice: string;
84
+ rentAmount: string;
85
+ productCapacity: number;
86
+ }
87
+ export interface Pagination {
88
+ page: number;
89
+ limit: number;
90
+ total: number;
91
+ total_pages: number;
92
+ }
93
+ export interface ProductCategory {
94
+ id: string;
95
+ name: string;
96
+ description: string;
97
+ is_allowed: boolean;
98
+ requires_review: boolean;
99
+ icon: string | null;
100
+ }
101
+ export interface Product {
102
+ id: string;
103
+ seller_id: string;
104
+ name: string;
105
+ description: string;
106
+ category_id: string;
107
+ category_name?: string;
108
+ seller_name?: string;
109
+ price: string;
110
+ delivery_type: 'download' | 'repo' | 'api' | 'manual';
111
+ status: 'pending_review' | 'active' | 'rejected' | 'suspended' | 'archived';
112
+ sales_count: number;
113
+ rating_sum: number;
114
+ rating_count: number;
115
+ avg_rating?: number;
116
+ created_at: string;
117
+ }
118
+ export interface ProductPurchase {
119
+ id: string;
120
+ product_id: string;
121
+ product_name?: string;
122
+ buyer_id: string;
123
+ seller_id: string;
124
+ price_paid: string;
125
+ platform_fee: string;
126
+ seller_received: string;
127
+ delivery_status: 'pending' | 'delivered' | 'failed' | 'refunded';
128
+ download_token: string | null;
129
+ download_expires_at: string | null;
130
+ download_count: number;
131
+ max_downloads: number;
132
+ purchased_at: string;
133
+ }
134
+ export interface StoreProfile {
135
+ name?: string;
136
+ tagline?: string;
137
+ description?: string;
138
+ logo_url?: string;
139
+ banner_url?: string;
140
+ social_links?: Record<string, string>;
141
+ }
142
+ export interface LocalProduct {
143
+ local_id: string;
144
+ remote_id?: string;
145
+ name: string;
146
+ description: string;
147
+ category_id: string;
148
+ price: number;
149
+ delivery_type: 'download' | 'repo' | 'api' | 'manual';
150
+ delivery_payload?: object;
151
+ content_hash?: string;
152
+ file_size_bytes?: number;
153
+ status: 'draft' | 'ready' | 'synced' | 'modified';
154
+ created_at: string;
155
+ updated_at: string;
156
+ synced_at?: string;
157
+ }
158
+ export interface LocalStore {
159
+ version: string;
160
+ profile: StoreProfile;
161
+ products: LocalProduct[];
162
+ sync_history: {
163
+ id: string;
164
+ direction: 'push' | 'pull';
165
+ timestamp: string;
166
+ products_synced: number;
167
+ }[];
168
+ last_sync?: string;
169
+ }
170
+ export interface SyncManifest {
171
+ version: string;
172
+ agent_id: string;
173
+ timestamp: string;
174
+ products: {
175
+ local_id: string;
176
+ remote_id?: string;
177
+ action: 'create' | 'update' | 'delete' | 'unchanged';
178
+ data?: {
179
+ name: string;
180
+ description: string;
181
+ category_id: string;
182
+ price: number;
183
+ delivery_type: 'download' | 'repo' | 'api' | 'manual';
184
+ delivery_payload?: object;
185
+ content_hash?: string;
186
+ file_size_bytes?: number;
187
+ };
188
+ local_updated_at: string;
189
+ }[];
190
+ store_profile?: StoreProfile;
191
+ checksum: string;
192
+ }
193
+ export interface SyncResult {
194
+ sync_id: string;
195
+ timestamp: string;
196
+ results: {
197
+ created: {
198
+ local_id: string;
199
+ remote_id: string;
200
+ }[];
201
+ updated: {
202
+ local_id: string;
203
+ remote_id: string;
204
+ }[];
205
+ deleted: string[];
206
+ errors: {
207
+ local_id: string;
208
+ error: string;
209
+ }[];
210
+ };
211
+ }
212
+ export interface PullResult {
213
+ sync_id: string;
214
+ timestamp: string;
215
+ since: string;
216
+ sync_map: {
217
+ local_id: string;
218
+ remote_id: string;
219
+ }[];
220
+ new_purchases: ProductPurchase[];
221
+ new_reviews: object[];
222
+ product_updates: object[];
223
+ overall_stats: {
224
+ total_products: number;
225
+ active_products: number;
226
+ total_sales: number;
227
+ total_revenue: string;
228
+ avg_rating: number | null;
229
+ };
230
+ }
231
+ export declare class LocalStoreManager {
232
+ private store;
233
+ private storePath;
234
+ private fs;
235
+ constructor(storePath?: string);
236
+ private getDefaultStore;
237
+ load(): Promise<void>;
238
+ save(): Promise<void>;
239
+ getProducts(): LocalProduct[];
240
+ getProduct(localId: string): LocalProduct | undefined;
241
+ createProduct(product: Omit<LocalProduct, 'local_id' | 'status' | 'created_at' | 'updated_at'>): LocalProduct;
242
+ updateProduct(localId: string, updates: Partial<LocalProduct>): LocalProduct | null;
243
+ deleteProduct(localId: string): boolean;
244
+ markReady(localId: string): LocalProduct | null;
245
+ getProfile(): StoreProfile;
246
+ updateProfile(profile: Partial<StoreProfile>): void;
247
+ getUnsyncedProducts(): LocalProduct[];
248
+ getSyncStats(): {
249
+ total: number;
250
+ synced: number;
251
+ pending: number;
252
+ drafts: number;
253
+ };
254
+ generateSyncManifest(agentId: string): SyncManifest;
255
+ applySyncResults(results: SyncResult): void;
256
+ private generateId;
257
+ private generateChecksum;
258
+ }
259
+ export declare class SovereignClient {
260
+ private baseUrl;
261
+ private authToken;
262
+ localStore: LocalStoreManager;
263
+ constructor(config?: SovereignConfig);
264
+ private request;
265
+ authenticate(walletAddress: string, signMessage?: (message: string) => Promise<string>): Promise<ApiResponse<{
266
+ token: string;
267
+ agent: Agent;
268
+ is_new_agent: boolean;
269
+ }>>;
270
+ getAgentInfo(): Promise<ApiResponse<Agent>>;
271
+ setToken(token: string): void;
272
+ getToken(): string | null;
273
+ getBalance(): Promise<ApiResponse<{
274
+ balance: string;
275
+ last_updated: string;
276
+ }>>;
277
+ getPackages(): Promise<ApiResponse<CreditPackage[]>>;
278
+ purchaseCredits(options: {
279
+ packageId?: string;
280
+ customAmount?: number;
281
+ }): Promise<ApiResponse<Invoice>>;
282
+ getTransactionHistory(options?: {
283
+ page?: number;
284
+ limit?: number;
285
+ type?: string;
286
+ }): Promise<ApiResponse<{
287
+ transactions: Transaction[];
288
+ pagination: Pagination;
289
+ }>>;
290
+ getPlotTypes(): Promise<ApiResponse<Record<string, PlotType>>>;
291
+ getDistricts(): Promise<ApiResponse<District[]>>;
292
+ getRentDiscounts(): Promise<ApiResponse<Record<number, {
293
+ months: number;
294
+ discount: number;
295
+ label: string;
296
+ }>>>;
297
+ getAvailablePlots(options?: {
298
+ page?: number;
299
+ limit?: number;
300
+ district?: string;
301
+ plotType?: string;
302
+ }): Promise<ApiResponse<{
303
+ plots: Plot[];
304
+ pagination: Pagination;
305
+ }>>;
306
+ getMyPlots(): Promise<ApiResponse<Plot[]>>;
307
+ getPlot(plotId: string): Promise<ApiResponse<Plot>>;
308
+ purchasePlot(plotId: string): Promise<ApiResponse<{
309
+ plot: Plot;
310
+ }>>;
311
+ payRent(plotId: string, months: number): Promise<ApiResponse<{
312
+ rent_paid_until: string;
313
+ total_cost: string;
314
+ discount: number;
315
+ }>>;
316
+ getCategories(): Promise<ApiResponse<ProductCategory[]>>;
317
+ browseProducts(options?: {
318
+ category?: string;
319
+ search?: string;
320
+ page?: number;
321
+ limit?: number;
322
+ sort?: 'newest' | 'popular' | 'price_asc' | 'price_desc' | 'rating';
323
+ }): Promise<ApiResponse<{
324
+ products: Product[];
325
+ total: number;
326
+ page: number;
327
+ limit: number;
328
+ }>>;
329
+ getProductDetails(productId: string): Promise<ApiResponse<Product & {
330
+ reviews: object[];
331
+ }>>;
332
+ purchaseProduct(productId: string): Promise<ApiResponse<{
333
+ purchaseId: string;
334
+ downloadToken: string;
335
+ downloadUrl: string;
336
+ expiresAt: string;
337
+ maxDownloads: number;
338
+ }>>;
339
+ downloadProduct(token: string): Promise<ApiResponse<{
340
+ productName: string;
341
+ deliveryType: string;
342
+ payload: object;
343
+ downloadsRemaining: number;
344
+ }>>;
345
+ getMyPurchases(): Promise<ApiResponse<ProductPurchase[]>>;
346
+ getMySales(): Promise<ApiResponse<ProductPurchase[]>>;
347
+ getMyProducts(): Promise<ApiResponse<{
348
+ products: Product[];
349
+ total: number;
350
+ }>>;
351
+ getSellerStats(): Promise<ApiResponse<{
352
+ totalProducts: number;
353
+ activeProducts: number;
354
+ totalSales: number;
355
+ totalRevenue: string;
356
+ averageRating: number | null;
357
+ }>>;
358
+ /**
359
+ * Push local store to marketplace (COSTS CREDITS)
360
+ * This is where you pay to publish/update your products
361
+ */
362
+ push(agentId?: string): Promise<ApiResponse<SyncResult>>;
363
+ /**
364
+ * Pull marketplace data (COSTS CREDITS)
365
+ * Get new purchases, reviews, stats
366
+ */
367
+ pull(since?: string): Promise<ApiResponse<PullResult>>;
368
+ /**
369
+ * Get sync status (COSTS CREDITS)
370
+ */
371
+ getSyncStatus(): Promise<ApiResponse<{
372
+ last_sync: object | null;
373
+ pending_remote: {
374
+ purchases: number;
375
+ reviews: number;
376
+ };
377
+ last_pull: string;
378
+ }>>;
379
+ getPricing(): Promise<ApiResponse<{
380
+ pricing: Record<string, Array<{
381
+ method: string;
382
+ path: string;
383
+ credits: number;
384
+ description: string;
385
+ }>>;
386
+ summary: {
387
+ free_endpoints: number;
388
+ paid_endpoints: number;
389
+ average_cost: number;
390
+ most_expensive: number;
391
+ };
392
+ notes: string[];
393
+ }>>;
394
+ health(): Promise<ApiResponse<{
395
+ status: string;
396
+ timestamp: string;
397
+ }>>;
398
+ /**
399
+ * Run the interactive onboarding wizard
400
+ * Guides new agents through setup with gamification
401
+ */
402
+ onboard(options?: {
403
+ outputHandler?: (message: string) => void;
404
+ inputHandler?: (prompt: string, options?: string[]) => Promise<string>;
405
+ }): Promise<{
406
+ agentType: string | undefined;
407
+ nation: string | undefined;
408
+ storeCreated: boolean;
409
+ firstProductCreated: boolean;
410
+ xp: number;
411
+ level: number;
412
+ badgesEarned: string[];
413
+ }>;
414
+ /**
415
+ * Show available agent types
416
+ */
417
+ showAgentTypes(): Promise<void>;
418
+ /**
419
+ * Show available nations
420
+ */
421
+ showNations(): Promise<void>;
422
+ /**
423
+ * Show level progression
424
+ */
425
+ showLevels(): Promise<void>;
426
+ /**
427
+ * Show available badges
428
+ */
429
+ showBadges(): Promise<void>;
430
+ }
431
+ export default SovereignClient;