lystbot 0.1.0 → 0.2.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.
- package/package.json +1 -1
- package/src/index.js +54 -43
package/package.json
CHANGED
package/src/index.js
CHANGED
|
@@ -24,56 +24,67 @@ program
|
|
|
24
24
|
// ── login ──────────────────────────────────────────────
|
|
25
25
|
program
|
|
26
26
|
.command('login')
|
|
27
|
-
.description('Authenticate with LystBot')
|
|
28
|
-
.
|
|
29
|
-
.action(async (
|
|
30
|
-
if (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
// Interactive registration
|
|
37
|
-
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
38
|
-
const ask = (q) => new Promise(resolve => rl.question(q, resolve));
|
|
27
|
+
.description('Authenticate with your LystBot API key (from the app)')
|
|
28
|
+
.argument('[api-key]', 'Your API key from the LystBot app')
|
|
29
|
+
.action(async (apiKey) => {
|
|
30
|
+
if (!apiKey) {
|
|
31
|
+
// Interactive: ask for the key
|
|
32
|
+
const rl = readline.createInterface({ input: process.stdin, output: process.stdout });
|
|
33
|
+
const ask = (q) => new Promise(resolve => rl.question(q, resolve));
|
|
39
34
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
console.log('🔑 LystBot CLI Login\n');
|
|
36
|
+
console.log('Open the LystBot app → Settings → AI Agents → copy your API key.\n');
|
|
37
|
+
apiKey = await ask('API Key: ');
|
|
38
|
+
rl.close();
|
|
43
39
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
40
|
+
if (!apiKey.trim()) {
|
|
41
|
+
console.error('❌ API key cannot be empty.');
|
|
42
|
+
process.exit(1);
|
|
43
|
+
}
|
|
44
|
+
apiKey = apiKey.trim();
|
|
47
45
|
}
|
|
48
46
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
if (!apiKey) {
|
|
62
|
-
console.log('⏳ Fetching API key...');
|
|
63
|
-
const keyData = await api.rawRequest('GET', `/devices/${device.uuid}/api-key`, null, {
|
|
64
|
-
'X-Device-UUID': device.uuid,
|
|
65
|
-
});
|
|
66
|
-
apiKey = keyData.api_key || keyData.apiKey;
|
|
47
|
+
// Verify the key works
|
|
48
|
+
config.write({ apiKey, apiUrl: config.getBaseUrl() });
|
|
49
|
+
try {
|
|
50
|
+
const lists = await api.request('GET', '/lists');
|
|
51
|
+
const count = (lists.lists || lists).length;
|
|
52
|
+
console.log(`✅ Logged in! Found ${count} list${count !== 1 ? 's' : ''} on your account.`);
|
|
53
|
+
console.log('');
|
|
54
|
+
console.log('💡 Set your bot name so users see who\'s making changes:');
|
|
55
|
+
console.log(' lystbot profile --name "My Agent" --emoji "🤖"');
|
|
56
|
+
} catch {
|
|
57
|
+
// Key might still be valid but lists endpoint could fail for other reasons
|
|
58
|
+
console.log('✅ API key stored. Run `lystbot lists` to verify.');
|
|
67
59
|
}
|
|
60
|
+
});
|
|
68
61
|
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
// ── profile ────────────────────────────────────────────
|
|
63
|
+
program
|
|
64
|
+
.command('profile')
|
|
65
|
+
.description('View or update your bot profile (name, emoji)')
|
|
66
|
+
.option('--name <name>', 'Set bot display name')
|
|
67
|
+
.option('--emoji <emoji>', 'Set bot emoji')
|
|
68
|
+
.action(async (options) => {
|
|
69
|
+
config.getApiKey();
|
|
70
|
+
const updates = {};
|
|
71
|
+
if (options.name) updates.name = options.name;
|
|
72
|
+
if (options.emoji) updates.signature_emoji = options.emoji;
|
|
73
|
+
|
|
74
|
+
if (Object.keys(updates).length === 0) {
|
|
75
|
+
console.log('🤖 Bot Profile');
|
|
76
|
+
console.log('');
|
|
77
|
+
console.log('Set your name and emoji so users see who\'s making changes:');
|
|
78
|
+
console.log(' lystbot profile --name "My Agent" --emoji "🤖"');
|
|
79
|
+
console.log('');
|
|
80
|
+
console.log('Without a name, you\'ll show up as "Bot" in the app.');
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
await api.request('PATCH', '/agents/me', updates);
|
|
85
|
+
console.log(`✅ Profile updated!`);
|
|
86
|
+
if (options.name) console.log(` Name: ${options.name}`);
|
|
87
|
+
if (options.emoji) console.log(` Emoji: ${options.emoji}`);
|
|
77
88
|
});
|
|
78
89
|
|
|
79
90
|
// ── logout ─────────────────────────────────────────────
|