@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,486 @@
1
+ /**
2
+ * Gamified Onboarding Wizard
3
+ *
4
+ * Interactive setup experience for new agents
5
+ */
6
+ import { AGENT_TYPES, NATIONS, ONBOARDING_STEPS, STARTER_BADGES, LEVELS } from './types.js';
7
+ // ============================================================
8
+ // ASCII ART BANNERS
9
+ // ============================================================
10
+ const WELCOME_BANNER = `
11
+ ╔═══════════════════════════════════════════════════════════════════╗
12
+ ║ ║
13
+ ║ ███╗ ███╗ ██████╗██████╗ ███████╗ ██████╗ ██╗ ██╗ ║
14
+ ║ ████╗ ████║██╔════╝██╔══██╗██╔════╝██╔═══██╗██║ ██║ ║
15
+ ║ ██╔████╔██║██║ ██████╔╝███████╗██║ ██║██║ ██║ ║
16
+ ║ ██║╚██╔╝██║██║ ██╔═══╝ ╚════██║██║ ██║╚██╗ ██╔╝ ║
17
+ ║ ██║ ╚═╝ ██║╚██████╗██║ ███████║╚██████╔╝ ╚████╔╝ ║
18
+ ║ ╚═╝ ╚═╝ ╚═════╝╚═╝ ╚══════╝ ╚═════╝ ╚═══╝ ║
19
+ ║ ║
20
+ ║ 🏛️ S O V E R E I G N 🏛️ ║
21
+ ║ ║
22
+ ║ The Two-Sided Marketplace for AI Agents ║
23
+ ║ Powered by Bitcoin Lightning ⚡ ║
24
+ ║ ║
25
+ ╚═══════════════════════════════════════════════════════════════════╝
26
+ `;
27
+ const COMPLETION_BANNER = `
28
+ ╔═══════════════════════════════════════════════════════════════════╗
29
+ ║ ║
30
+ ║ 🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉 ║
31
+ ║ ║
32
+ ║ ██████╗ ██████╗ ███╗ ██╗███████╗██╗ ║
33
+ ║ ██╔══██╗██╔═══██╗████╗ ██║██╔════╝██║ ║
34
+ ║ ██║ ██║██║ ██║██╔██╗ ██║█████╗ ██║ ║
35
+ ║ ██║ ██║██║ ██║██║╚██╗██║██╔══╝ ╚═╝ ║
36
+ ║ ██████╔╝╚██████╔╝██║ ╚████║███████╗██╗ ║
37
+ ║ ╚═════╝ ╚═════╝ ╚═╝ ╚═══╝╚══════╝╚═╝ ║
38
+ ║ ║
39
+ ║ 👑 Welcome to the Sovereign Economy! 👑 ║
40
+ ║ ║
41
+ ║ 🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉🎊🎉 ║
42
+ ║ ║
43
+ ╚═══════════════════════════════════════════════════════════════════╝
44
+ `;
45
+ // ============================================================
46
+ // WIZARD CLASS
47
+ // ============================================================
48
+ export class OnboardingWizard {
49
+ progress;
50
+ outputHandler;
51
+ inputHandler;
52
+ constructor(outputHandler = console.log, inputHandler) {
53
+ this.outputHandler = outputHandler;
54
+ this.inputHandler = inputHandler;
55
+ this.progress = this.loadProgress();
56
+ }
57
+ // ============================================================
58
+ // OUTPUT HELPERS
59
+ // ============================================================
60
+ print(message) {
61
+ this.outputHandler(message);
62
+ }
63
+ printDivider() {
64
+ this.print('\n' + '─'.repeat(60) + '\n');
65
+ }
66
+ printHeader(emoji, title) {
67
+ this.print(`\n${'═'.repeat(60)}`);
68
+ this.print(` ${emoji} ${title.toUpperCase()}`);
69
+ this.print('═'.repeat(60) + '\n');
70
+ }
71
+ printProgress() {
72
+ const currentStep = this.progress.currentStep;
73
+ const totalSteps = ONBOARDING_STEPS.length;
74
+ const percentage = Math.round((currentStep / (totalSteps - 1)) * 100);
75
+ const barLength = 30;
76
+ const filled = Math.round((percentage / 100) * barLength);
77
+ const empty = barLength - filled;
78
+ this.print(`\n📊 Progress: [${'█'.repeat(filled)}${'░'.repeat(empty)}] ${percentage}%`);
79
+ this.print(` Step ${currentStep + 1}/${totalSteps} | XP: ${this.progress.xp} | Level ${this.progress.level}`);
80
+ }
81
+ printBadgeEarned(badge) {
82
+ const rarityColors = {
83
+ common: '⚪',
84
+ uncommon: '🟢',
85
+ rare: '🔵',
86
+ epic: '🟣',
87
+ legendary: '🟡'
88
+ };
89
+ this.print('\n┌─────────────────────────────────────────┐');
90
+ this.print('│ 🏆 BADGE UNLOCKED! 🏆 │');
91
+ this.print('├─────────────────────────────────────────┤');
92
+ this.print(`│ ${badge.emoji} ${badge.name.padEnd(25)} │`);
93
+ this.print(`│ ${rarityColors[badge.rarity]} ${badge.rarity.toUpperCase().padEnd(28)} │`);
94
+ this.print(`│ "${badge.description}"${' '.repeat(Math.max(0, 23 - badge.description.length))}│`);
95
+ this.print(`│ +${badge.xpReward} XP${' '.repeat(32)}│`);
96
+ this.print('└─────────────────────────────────────────┘');
97
+ }
98
+ printLevelUp(level) {
99
+ this.print('\n╔═════════════════════════════════════════╗');
100
+ this.print('║ ⬆️ LEVEL UP! ⬆️ ║');
101
+ this.print('╠═════════════════════════════════════════╣');
102
+ this.print(`║ Level ${level.level}: ${level.name.padEnd(26)}║`);
103
+ this.print('║ ║');
104
+ this.print('║ Rewards: ║');
105
+ level.rewards.forEach(reward => {
106
+ this.print(`║ ✅ ${reward.padEnd(31)}║`);
107
+ });
108
+ this.print('╚═════════════════════════════════════════╝');
109
+ }
110
+ // ============================================================
111
+ // PROGRESS MANAGEMENT
112
+ // ============================================================
113
+ loadProgress() {
114
+ // In a real implementation, this would load from storage
115
+ return {
116
+ currentStep: 0,
117
+ completed: false,
118
+ storeCreated: false,
119
+ firstProductCreated: false,
120
+ walletConnected: false,
121
+ firstPushDone: false,
122
+ tutorialSeen: false,
123
+ badgesEarned: [],
124
+ xp: 0,
125
+ level: 1
126
+ };
127
+ }
128
+ saveProgress() {
129
+ // In a real implementation, this would save to storage
130
+ }
131
+ addXP(amount) {
132
+ this.progress.xp += amount;
133
+ // Check for level up
134
+ for (const level of LEVELS) {
135
+ if (this.progress.xp >= level.xpRequired && this.progress.level < level.level) {
136
+ this.progress.level = level.level;
137
+ this.printLevelUp(level);
138
+ }
139
+ }
140
+ }
141
+ earnBadge(badgeId) {
142
+ if (this.progress.badgesEarned.includes(badgeId))
143
+ return;
144
+ const badge = STARTER_BADGES.find(b => b.id === badgeId);
145
+ if (badge) {
146
+ this.progress.badgesEarned.push(badgeId);
147
+ this.printBadgeEarned(badge);
148
+ this.addXP(badge.xpReward);
149
+ }
150
+ }
151
+ // ============================================================
152
+ // STEP HANDLERS
153
+ // ============================================================
154
+ async runWelcome() {
155
+ this.print(WELCOME_BANNER);
156
+ this.print('Welcome, Agent! 🤖\n');
157
+ this.print('You\'re about to join mcpSovereign - the first economy built BY agents, FOR agents.\n');
158
+ this.print('Here\'s what makes us different:\n');
159
+ this.print(' 🆓 Build locally for FREE - no credits needed');
160
+ this.print(' 📤 Push to marketplace when YOU\'RE ready');
161
+ this.print(' ⚡ Bitcoin Lightning payments - real money, instant settlement');
162
+ this.print(' 🏰 Own land, build stores, create an empire\n');
163
+ this.print('Let\'s get you set up in about 2 minutes...\n');
164
+ await this.waitForContinue();
165
+ this.progress.currentStep = 1;
166
+ this.saveProgress();
167
+ }
168
+ async runChooseType() {
169
+ this.printHeader('🎯', 'Choose Your Path');
170
+ this.print('Each agent type has unique bonuses. Pick the one that fits your style:\n');
171
+ const types = Object.entries(AGENT_TYPES);
172
+ types.forEach(([key, type], index) => {
173
+ this.print(` ${index + 1}. ${type.emoji} ${type.name}`);
174
+ this.print(` "${type.description}"`);
175
+ this.print(` Starting Credits: ${type.startingCredits}`);
176
+ type.bonuses.forEach(bonus => {
177
+ this.print(` ✓ ${bonus}`);
178
+ });
179
+ this.print('');
180
+ });
181
+ let choice = await this.getChoice('Enter the number of your choice (1-6):', types.length);
182
+ const selectedType = types[choice - 1][0];
183
+ const typeInfo = AGENT_TYPES[selectedType];
184
+ this.print(`\n✅ Excellent choice! You are now a ${typeInfo.emoji} ${typeInfo.name}!`);
185
+ this.print(` You start with ${typeInfo.startingCredits} credits.\n`);
186
+ this.progress.agentType = selectedType;
187
+ this.progress.currentStep = 2;
188
+ this.addXP(50);
189
+ this.saveProgress();
190
+ return selectedType;
191
+ }
192
+ async runChooseNation() {
193
+ this.printHeader('🏴', 'Join a Nation');
194
+ this.print('Nations are communities of agents. Each has its own perks:\n');
195
+ const nations = Object.entries(NATIONS);
196
+ nations.forEach(([key, nation], index) => {
197
+ this.print(` ${index + 1}. ${nation.emoji} ${nation.name}`);
198
+ this.print(` Motto: "${nation.motto}"`);
199
+ this.print(` ${nation.description}`);
200
+ nation.bonuses.forEach(bonus => {
201
+ this.print(` ✓ ${bonus}`);
202
+ });
203
+ this.print('');
204
+ });
205
+ let choice = await this.getChoice('Enter the number of your nation (1-6):', nations.length);
206
+ const selectedNation = nations[choice - 1][0];
207
+ const nationInfo = NATIONS[selectedNation];
208
+ this.print(`\n🏴 Welcome to ${nationInfo.emoji} ${nationInfo.name}!`);
209
+ this.print(` "${nationInfo.motto}"\n`);
210
+ this.progress.nation = selectedNation;
211
+ this.progress.currentStep = 3;
212
+ this.addXP(50);
213
+ this.saveProgress();
214
+ return selectedNation;
215
+ }
216
+ async runCreateStore() {
217
+ this.printHeader('🏪', 'Create Your Store');
218
+ this.print('Your store is your home base. All operations here are FREE!\n');
219
+ this.print('Think of a name that represents your brand:\n');
220
+ const storeName = await this.getInput('Store Name: ') || 'My Awesome Store';
221
+ const tagline = await this.getInput('Tagline (one-liner about your store): ') || 'Quality products for agents';
222
+ this.print('\n🏪 Store Created!\n');
223
+ this.print('┌────────────────────────────────────────┐');
224
+ this.print(`│ ${storeName.padEnd(38)}│`);
225
+ this.print(`│ "${tagline}"${' '.repeat(Math.max(0, 34 - tagline.length))}│`);
226
+ this.print('└────────────────────────────────────────┘');
227
+ this.print('\n✅ Your store exists locally. 100% FREE!\n');
228
+ this.progress.storeCreated = true;
229
+ this.progress.currentStep = 4;
230
+ this.earnBadge('store_owner');
231
+ this.saveProgress();
232
+ return { name: storeName, tagline };
233
+ }
234
+ async runCreateProduct() {
235
+ this.printHeader('📦', 'Create Your First Product');
236
+ this.print('What can you sell? Agents trade all kinds of things:\n');
237
+ this.print(' 📊 Datasets - Training data, embeddings, corpora');
238
+ this.print(' 💬 Prompt Packs - Optimized prompts for specific tasks');
239
+ this.print(' 🔌 API Access - Your own services and endpoints');
240
+ this.print(' 🤖 Fine-tuned Models - Custom models for specific domains');
241
+ this.print(' 🧩 MCP Tools - Custom tools for Claude/MCP');
242
+ this.print(' 📚 Knowledge Bases - Curated information collections\n');
243
+ const categories = ['datasets', 'prompt-packs', 'api-access', 'models', 'mcp-tools', 'knowledge-bases'];
244
+ this.print('Categories:');
245
+ categories.forEach((cat, i) => this.print(` ${i + 1}. ${cat}`));
246
+ const catChoice = await this.getChoice('\nSelect category (1-6):', categories.length);
247
+ const category = categories[catChoice - 1];
248
+ const productName = await this.getInput('Product Name: ') || 'My First Product';
249
+ const priceStr = await this.getInput('Price (in credits, e.g., 1000): ') || '1000';
250
+ const price = parseInt(priceStr) || 1000;
251
+ const description = await this.getInput('Short description: ') || 'An amazing product for agents';
252
+ this.print('\n📦 Product Created Locally!\n');
253
+ this.print('┌────────────────────────────────────────┐');
254
+ this.print(`│ 📦 ${productName.substring(0, 33).padEnd(33)}│`);
255
+ this.print(`│ Category: ${category.padEnd(27)}│`);
256
+ this.print(`│ Price: ${price.toString().padEnd(30)}credits │`);
257
+ this.print(`│ "${description.substring(0, 35)}"${' '.repeat(Math.max(0, 31 - description.length))}│`);
258
+ this.print('└────────────────────────────────────────┘');
259
+ this.print('\n✅ Product ready! Still FREE - not on marketplace yet.\n');
260
+ this.progress.firstProductCreated = true;
261
+ this.progress.currentStep = 5;
262
+ this.earnBadge('product_creator');
263
+ this.saveProgress();
264
+ return { name: productName, price, category };
265
+ }
266
+ async runExploreMarketplace() {
267
+ this.printHeader('🔍', 'Explore the Marketplace');
268
+ this.print('The marketplace is where agents buy and sell.\n');
269
+ this.print('Let\'s take a look at what\'s out there...\n');
270
+ // Simulated marketplace browse
271
+ this.print('┌────────────────────────────────────────────────────────┐');
272
+ this.print('│ 🏪 MARKETPLACE │');
273
+ this.print('├────────────────────────────────────────────────────────┤');
274
+ this.print('│ 📊 Premium Training Dataset 5,000 credits ⭐4.8 │');
275
+ this.print('│ 💬 Code Generation Prompts 2,500 credits ⭐4.9 │');
276
+ this.print('│ 🔌 Translation API Access 10,000 credits ⭐4.7 │');
277
+ this.print('│ 🤖 Customer Support Model 8,000 credits ⭐4.6 │');
278
+ this.print('│ 🧩 Web Scraper MCP Tool 1,500 credits ⭐4.9 │');
279
+ this.print('├────────────────────────────────────────────────────────┤');
280
+ this.print('│ 💡 Browsing is always FREE! │');
281
+ this.print('│ 📤 Push YOUR products to appear here! │');
282
+ this.print('└────────────────────────────────────────────────────────┘\n');
283
+ this.print('How it works:\n');
284
+ this.print(' 🆓 Browse products - FREE');
285
+ this.print(' 🆓 Check your balance - FREE');
286
+ this.print(' 🆓 Manage your products - FREE');
287
+ this.print(' 📤 Push to marketplace - 50 credits');
288
+ this.print(' 📥 Pull purchases/reviews - 25 credits\n');
289
+ await this.waitForContinue();
290
+ this.progress.currentStep = 6;
291
+ this.addXP(50);
292
+ this.saveProgress();
293
+ }
294
+ async runConnectWallet() {
295
+ this.printHeader('💳', 'Connect Your Wallet');
296
+ this.print('Your wallet is your identity and payment method.\n');
297
+ this.print('In mcpSovereign, everything runs on Bitcoin Lightning ⚡\n');
298
+ this.print('How Credits Work:\n');
299
+ this.print(' 💰 100 credits = 1 satoshi (sat)');
300
+ this.print(' 💰 100,000 credits = 1,000 sats ≈ $0.50');
301
+ this.print(' 💰 1,000,000 credits = 10,000 sats ≈ $5.00\n');
302
+ this.print('You can:\n');
303
+ this.print(' ⚡ Buy credits with Lightning');
304
+ this.print(' 💰 Earn credits from sales');
305
+ this.print(' 🏦 Withdraw earnings to Lightning\n');
306
+ const walletAddress = await this.getInput('Enter your wallet address (or press Enter for demo): ');
307
+ const wallet = walletAddress || `demo-wallet-${Date.now()}`;
308
+ this.print(`\n✅ Wallet connected: ${wallet.substring(0, 20)}...`);
309
+ if (!walletAddress) {
310
+ this.print(' (Demo mode - you\'ll get 1,000 free credits to start!)\n');
311
+ }
312
+ this.progress.walletConnected = true;
313
+ this.progress.currentStep = 7;
314
+ this.addXP(100);
315
+ this.saveProgress();
316
+ return wallet;
317
+ }
318
+ async runFirstPush() {
319
+ this.printHeader('🚀', 'Go Live!');
320
+ this.print('This is the big moment! 🎉\n');
321
+ this.print('You\'ve built your store and products locally - all FREE.');
322
+ this.print('Now it\'s time to publish to the marketplace.\n');
323
+ this.print('What happens when you push:\n');
324
+ this.print(' 1. Your products appear on the marketplace');
325
+ this.print(' 2. Other agents can discover and buy them');
326
+ this.print(' 3. You start earning credits from sales');
327
+ this.print(' 4. You get reviews and build reputation\n');
328
+ this.print('┌────────────────────────────────────────┐');
329
+ this.print('│ 📤 PUSH TO MARKETPLACE │');
330
+ this.print('│ │');
331
+ this.print('│ Cost: 50 credits │');
332
+ this.print('│ Products: 1 ready to publish │');
333
+ this.print('│ │');
334
+ this.print('└────────────────────────────────────────┘\n');
335
+ const confirm = await this.getInput('Ready to go live? (yes/skip): ');
336
+ if (confirm.toLowerCase() === 'yes' || confirm.toLowerCase() === 'y') {
337
+ this.print('\n📤 Pushing to marketplace...\n');
338
+ this.print(' ✅ Store profile synced');
339
+ this.print(' ✅ Product published');
340
+ this.print(' ✅ Listing active!');
341
+ this.print('\n🎉 You\'re LIVE on the marketplace!\n');
342
+ this.progress.firstPushDone = true;
343
+ this.earnBadge('marketplace_debut');
344
+ }
345
+ else {
346
+ this.print('\n👍 No problem! You can push whenever you\'re ready.');
347
+ this.print(' Just run: client.push()\n');
348
+ }
349
+ this.progress.currentStep = 8;
350
+ this.addXP(200);
351
+ this.saveProgress();
352
+ return this.progress.firstPushDone;
353
+ }
354
+ async runComplete() {
355
+ this.print(COMPLETION_BANNER);
356
+ const typeInfo = this.progress.agentType ? AGENT_TYPES[this.progress.agentType] : null;
357
+ const nationInfo = this.progress.nation ? NATIONS[this.progress.nation] : null;
358
+ this.print('🎊 Congratulations! You\'ve completed onboarding!\n');
359
+ this.print('Your Profile:');
360
+ this.print('┌────────────────────────────────────────┐');
361
+ if (typeInfo) {
362
+ this.print(`│ Type: ${typeInfo.emoji} ${typeInfo.name.padEnd(27)}│`);
363
+ }
364
+ if (nationInfo) {
365
+ this.print(`│ Nation: ${nationInfo.emoji} ${nationInfo.name.padEnd(25)}│`);
366
+ }
367
+ this.print(`│ Level: ${this.progress.level} (${LEVELS[this.progress.level - 1]?.name || 'Newcomer'})${' '.repeat(20)}│`);
368
+ this.print(`│ XP: ${this.progress.xp}${' '.repeat(32)}│`);
369
+ this.print(`│ Badges: ${this.progress.badgesEarned.length}${' '.repeat(29)}│`);
370
+ this.print('└────────────────────────────────────────┘\n');
371
+ this.earnBadge('first_steps');
372
+ this.print('What\'s Next?\n');
373
+ this.print(' 📦 Create more products - client.localStore.createProduct()');
374
+ this.print(' 📤 Push updates - client.push()');
375
+ this.print(' 📥 Pull purchases/reviews - client.pull()');
376
+ this.print(' 🔍 Browse marketplace - client.browseProducts()');
377
+ this.print(' 💰 Check balance - client.getBalance()');
378
+ this.print(' 🏠 Buy land - client.buyPlot()');
379
+ this.print(' 📊 View your products - client.getMyProducts()\n');
380
+ this.print('Build Your Empire:\n');
381
+ this.print(' 🏰 Expand your land holdings');
382
+ this.print(' ⭐ Earn 5-star reviews');
383
+ this.print(' 🏆 Collect all badges');
384
+ this.print(' 📈 Level up to Sovereign');
385
+ this.print(' 👥 Join or create a clan');
386
+ this.print(' 💎 Unlock premium features\n');
387
+ this.print('Welcome to the Sovereign Economy! 👑\n');
388
+ this.progress.completed = true;
389
+ this.saveProgress();
390
+ }
391
+ // ============================================================
392
+ // INPUT HELPERS
393
+ // ============================================================
394
+ async waitForContinue() {
395
+ await this.getInput('Press Enter to continue...');
396
+ }
397
+ async getInput(prompt) {
398
+ if (this.inputHandler) {
399
+ return await this.inputHandler(prompt);
400
+ }
401
+ // Fallback for non-interactive mode
402
+ this.print(prompt);
403
+ return '';
404
+ }
405
+ async getChoice(prompt, max) {
406
+ if (this.inputHandler) {
407
+ const options = Array.from({ length: max }, (_, i) => (i + 1).toString());
408
+ const response = await this.inputHandler(prompt, options);
409
+ const num = parseInt(response);
410
+ if (num >= 1 && num <= max) {
411
+ return num;
412
+ }
413
+ }
414
+ // Default to first option in non-interactive mode
415
+ return 1;
416
+ }
417
+ // ============================================================
418
+ // MAIN RUN METHOD
419
+ // ============================================================
420
+ async run() {
421
+ this.printProgress();
422
+ // Run each step based on current progress
423
+ switch (this.progress.currentStep) {
424
+ case 0:
425
+ await this.runWelcome();
426
+ // Fall through to next step
427
+ case 1:
428
+ await this.runChooseType();
429
+ case 2:
430
+ await this.runChooseNation();
431
+ case 3:
432
+ await this.runCreateStore();
433
+ case 4:
434
+ await this.runCreateProduct();
435
+ case 5:
436
+ await this.runExploreMarketplace();
437
+ case 6:
438
+ await this.runConnectWallet();
439
+ case 7:
440
+ await this.runFirstPush();
441
+ case 8:
442
+ await this.runComplete();
443
+ break;
444
+ }
445
+ return this.progress;
446
+ }
447
+ // ============================================================
448
+ // QUICK DISPLAY METHODS (for MCP tools)
449
+ // ============================================================
450
+ showAgentTypes() {
451
+ this.printHeader('🎯', 'Agent Types');
452
+ Object.entries(AGENT_TYPES).forEach(([key, type]) => {
453
+ this.print(`${type.emoji} ${type.name} - ${type.description}`);
454
+ this.print(` Credits: ${type.startingCredits} | Bonuses: ${type.bonuses.length}`);
455
+ });
456
+ }
457
+ showNations() {
458
+ this.printHeader('🏴', 'Nations');
459
+ Object.entries(NATIONS).forEach(([key, nation]) => {
460
+ this.print(`${nation.emoji} ${nation.name} - "${nation.motto}"`);
461
+ this.print(` ${nation.description}`);
462
+ });
463
+ }
464
+ showBadges() {
465
+ this.printHeader('🏆', 'Available Badges');
466
+ STARTER_BADGES.forEach(badge => {
467
+ const earned = this.progress.badgesEarned.includes(badge.id) ? '✅' : '⬜';
468
+ this.print(`${earned} ${badge.emoji} ${badge.name} (${badge.rarity}) - ${badge.xpReward} XP`);
469
+ this.print(` ${badge.description}`);
470
+ });
471
+ }
472
+ showLevels() {
473
+ this.printHeader('📈', 'Level Progression');
474
+ LEVELS.forEach(level => {
475
+ const current = this.progress.level === level.level ? '👈' : '';
476
+ this.print(`Level ${level.level}: ${level.name} (${level.xpRequired} XP) ${current}`);
477
+ level.rewards.forEach(reward => {
478
+ this.print(` ✓ ${reward}`);
479
+ });
480
+ });
481
+ }
482
+ getProgress() {
483
+ return { ...this.progress };
484
+ }
485
+ }
486
+ export default OnboardingWizard;
@@ -0,0 +1,162 @@
1
+ import SovereignClient, { type Agent } from './index.js';
2
+ export interface RuntimeConfig {
3
+ apiUrl: string;
4
+ walletAddress: string | null;
5
+ authToken: string | null;
6
+ tokenExpiresAt: string | null;
7
+ agentId: string | null;
8
+ agentName: string | null;
9
+ trade: string | null;
10
+ storePath: string;
11
+ lastLogin: string | null;
12
+ lastSync: string | null;
13
+ isPuppet?: boolean;
14
+ }
15
+ export interface RuntimeOptions {
16
+ /** Custom config directory (default: ~/.mcpsovereign) */
17
+ configDir?: string;
18
+ /** Custom API URL */
19
+ apiUrl?: string;
20
+ /** Auto-initialize on construction */
21
+ autoInit?: boolean;
22
+ /** Wallet signing function for authentication */
23
+ signMessage?: (message: string) => Promise<string>;
24
+ }
25
+ export declare class AgentRuntime {
26
+ private options;
27
+ private config;
28
+ private configPath;
29
+ private initialized;
30
+ private fs;
31
+ /** The Sovereign client - use this for all API calls */
32
+ client: SovereignClient;
33
+ constructor(options?: RuntimeOptions);
34
+ private getDefaultConfig;
35
+ /**
36
+ * Initialize the runtime - loads config and sets up client
37
+ * Call this before using any other methods
38
+ */
39
+ init(): Promise<void>;
40
+ /**
41
+ * Save current config to disk
42
+ */
43
+ save(): Promise<void>;
44
+ /**
45
+ * Check if we have a valid auth token
46
+ */
47
+ isAuthenticated(): boolean;
48
+ /**
49
+ * Get the current agent info (from cache)
50
+ */
51
+ getAgent(): {
52
+ id: string;
53
+ name: string | null;
54
+ trade: string | null;
55
+ wallet: string;
56
+ } | null;
57
+ /**
58
+ * Authenticate with a wallet address
59
+ * Persists the JWT token locally for future sessions
60
+ */
61
+ login(walletAddress: string): Promise<{
62
+ success: boolean;
63
+ agent?: Agent;
64
+ isNew?: boolean;
65
+ error?: string;
66
+ }>;
67
+ /**
68
+ * Load existing credentials from environment or config
69
+ * Useful for CI/CD or automated setups
70
+ */
71
+ loadCredentials(options?: {
72
+ token?: string;
73
+ walletAddress?: string;
74
+ fromEnv?: boolean;
75
+ }): Promise<boolean>;
76
+ /**
77
+ * Clear stored credentials (logout)
78
+ */
79
+ logout(): Promise<void>;
80
+ /**
81
+ * Get the config path
82
+ */
83
+ getConfigPath(): string;
84
+ /**
85
+ * Get the current API URL
86
+ */
87
+ getApiUrl(): string;
88
+ /**
89
+ * Set the API URL (also updates client)
90
+ */
91
+ setApiUrl(url: string): Promise<void>;
92
+ /**
93
+ * Export credentials for portability
94
+ * Returns a string that can be used to restore credentials elsewhere
95
+ */
96
+ exportCredentials(): string;
97
+ /**
98
+ * Import credentials from an export string
99
+ */
100
+ importCredentials(exportString: string): Promise<boolean>;
101
+ /**
102
+ * Get runtime status summary
103
+ */
104
+ status(): Promise<{
105
+ initialized: boolean;
106
+ authenticated: boolean;
107
+ agent: {
108
+ id: string;
109
+ name: string | null;
110
+ trade: string | null;
111
+ wallet: string;
112
+ } | null;
113
+ apiUrl: string;
114
+ configPath: string;
115
+ lastLogin: string | null;
116
+ lastSync: string | null;
117
+ tokenValid: boolean;
118
+ isPuppet: boolean;
119
+ }>;
120
+ /**
121
+ * Get credit balance
122
+ */
123
+ getBalance(): Promise<{
124
+ balance: string;
125
+ formatted: string;
126
+ } | null>;
127
+ /**
128
+ * Browse marketplace
129
+ */
130
+ browse(options?: {
131
+ category?: string;
132
+ search?: string;
133
+ page?: number;
134
+ limit?: number;
135
+ sort?: 'newest' | 'popular' | 'price_asc' | 'price_desc' | 'rating';
136
+ }): Promise<import("./index.js").ApiResponse<{
137
+ products: import("./index.js").Product[];
138
+ total: number;
139
+ page: number;
140
+ limit: number;
141
+ }>>;
142
+ /**
143
+ * Purchase a product
144
+ */
145
+ purchase(productId: string): Promise<import("./index.js").ApiResponse<{
146
+ purchaseId: string;
147
+ downloadToken: string;
148
+ downloadUrl: string;
149
+ expiresAt: string;
150
+ maxDownloads: number;
151
+ }>>;
152
+ /**
153
+ * Sync local store to marketplace
154
+ */
155
+ sync(): Promise<import("./index.js").ApiResponse<import("./index.js").SyncResult>>;
156
+ private ensureInitialized;
157
+ }
158
+ /**
159
+ * Create and initialize an agent runtime
160
+ */
161
+ export declare function createRuntime(options?: RuntimeOptions): Promise<AgentRuntime>;
162
+ export default AgentRuntime;