beecork 1.4.2 → 1.4.4
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/channels/whatsapp.js +15 -4
- package/dist/cli/commands.js +11 -4
- package/dist/index.js +40 -21
- package/package.json +2 -1
|
@@ -32,18 +32,29 @@ export class WhatsAppChannel {
|
|
|
32
32
|
this.sttProvider = stt;
|
|
33
33
|
this.ttsProvider = tts;
|
|
34
34
|
try {
|
|
35
|
-
const { default: makeWASocket, useMultiFileAuthState, DisconnectReason, downloadMediaMessage } = await import('@whiskeysockets/baileys');
|
|
35
|
+
const { default: makeWASocket, useMultiFileAuthState, DisconnectReason, downloadMediaMessage, fetchLatestBaileysVersion } = await import('@whiskeysockets/baileys');
|
|
36
36
|
const sessionPath = this.ctx.config.whatsapp?.sessionPath ?? `${process.env.HOME}/.beecork/whatsapp-session`;
|
|
37
37
|
fs.mkdirSync(sessionPath, { recursive: true, mode: 0o700 });
|
|
38
38
|
const { state, saveCreds } = await useMultiFileAuthState(sessionPath);
|
|
39
|
+
const { version } = await fetchLatestBaileysVersion().catch(() => ({ version: undefined }));
|
|
39
40
|
this.sock = makeWASocket({
|
|
40
41
|
auth: state,
|
|
41
|
-
|
|
42
|
+
version,
|
|
42
43
|
});
|
|
43
44
|
const sock = this.sock;
|
|
44
45
|
sock.ev.on('creds.update', saveCreds);
|
|
45
|
-
sock.ev.on('connection.update', (update) => {
|
|
46
|
-
const { connection, lastDisconnect } = update;
|
|
46
|
+
sock.ev.on('connection.update', async (update) => {
|
|
47
|
+
const { connection, lastDisconnect, qr } = update;
|
|
48
|
+
if (qr) {
|
|
49
|
+
try {
|
|
50
|
+
const qrcodeTerminal = await import('qrcode-terminal');
|
|
51
|
+
(qrcodeTerminal.default || qrcodeTerminal).generate(qr, { small: true });
|
|
52
|
+
logger.info('WhatsApp QR code displayed — scan with your phone');
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
logger.warn('WhatsApp QR code available but could not render. Install qrcode-terminal.');
|
|
56
|
+
}
|
|
57
|
+
}
|
|
47
58
|
if (connection === 'close') {
|
|
48
59
|
const reason = lastDisconnect?.error?.output?.statusCode;
|
|
49
60
|
if (reason !== DisconnectReason.loggedOut) {
|
package/dist/cli/commands.js
CHANGED
|
@@ -235,18 +235,25 @@ export async function updateBeecork(options) {
|
|
|
235
235
|
console.log('Stopping daemon before update...');
|
|
236
236
|
await stopDaemon();
|
|
237
237
|
}
|
|
238
|
-
console.log(
|
|
238
|
+
console.log(`Updating beecork from v${VERSION}...`);
|
|
239
239
|
try {
|
|
240
240
|
execSync('npm install -g beecork@latest', { stdio: 'inherit' });
|
|
241
|
-
|
|
241
|
+
const newVersion = execSync('npm view beecork version', { encoding: 'utf-8' }).trim();
|
|
242
|
+
console.log(`Update complete! v${VERSION} → v${newVersion}`);
|
|
242
243
|
}
|
|
243
244
|
catch {
|
|
244
245
|
console.error('Update failed. Try running: npm install -g beecork@latest');
|
|
245
246
|
}
|
|
246
|
-
// Restart if it was running
|
|
247
|
+
// Restart if it was running — spawn the NEW binary so the freshly installed
|
|
248
|
+
// code is used, not the stale in-memory code from before the update.
|
|
247
249
|
if (pid) {
|
|
248
250
|
console.log('Restarting daemon...');
|
|
249
|
-
|
|
251
|
+
try {
|
|
252
|
+
execSync('beecork start', { stdio: 'inherit' });
|
|
253
|
+
}
|
|
254
|
+
catch {
|
|
255
|
+
console.error('Could not restart daemon. Run "beecork start" manually.');
|
|
256
|
+
}
|
|
250
257
|
}
|
|
251
258
|
}
|
|
252
259
|
export async function sendMessage(message) {
|
package/dist/index.js
CHANGED
|
@@ -194,29 +194,48 @@ program
|
|
|
194
194
|
rl.close();
|
|
195
195
|
// Pair immediately — show QR code in this terminal
|
|
196
196
|
try {
|
|
197
|
-
const { default: makeWASocket, useMultiFileAuthState, DisconnectReason } = await import('@whiskeysockets/baileys');
|
|
197
|
+
const { default: makeWASocket, useMultiFileAuthState, DisconnectReason, fetchLatestBaileysVersion } = await import('@whiskeysockets/baileys');
|
|
198
198
|
fs.mkdirSync(sessionPath, { recursive: true, mode: 0o700 });
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
process.exit(1);
|
|
199
|
+
let attempts = 0;
|
|
200
|
+
const maxAttempts = 5;
|
|
201
|
+
const connect = async () => {
|
|
202
|
+
attempts++;
|
|
203
|
+
const { state, saveCreds } = await useMultiFileAuthState(sessionPath);
|
|
204
|
+
const { version } = await fetchLatestBaileysVersion().catch(() => ({ version: undefined }));
|
|
205
|
+
const sock = makeWASocket({ auth: state, version });
|
|
206
|
+
sock.ev.on('creds.update', saveCreds);
|
|
207
|
+
sock.ev.on('connection.update', async (update) => {
|
|
208
|
+
if (update.qr) {
|
|
209
|
+
try {
|
|
210
|
+
const qrcodeTerminal = await import('qrcode-terminal');
|
|
211
|
+
(qrcodeTerminal.default || qrcodeTerminal).generate(update.qr, { small: true });
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
console.log('QR data:', update.qr);
|
|
215
|
+
}
|
|
217
216
|
}
|
|
218
|
-
|
|
219
|
-
|
|
217
|
+
if (update.connection === 'open') {
|
|
218
|
+
console.log('\n✓ WhatsApp paired successfully!');
|
|
219
|
+
console.log(' You can now start the daemon: beecork start\n');
|
|
220
|
+
sock.end(undefined);
|
|
221
|
+
process.exit(0);
|
|
222
|
+
}
|
|
223
|
+
if (update.connection === 'close') {
|
|
224
|
+
const reason = update.lastDisconnect?.error?.output?.statusCode;
|
|
225
|
+
if (reason === DisconnectReason.loggedOut) {
|
|
226
|
+
console.log('\n✗ WhatsApp logged out. Please try again.\n');
|
|
227
|
+
process.exit(1);
|
|
228
|
+
}
|
|
229
|
+
if (attempts >= maxAttempts) {
|
|
230
|
+
console.log(`\n✗ Could not connect after ${maxAttempts} attempts. Please try again later.\n`);
|
|
231
|
+
process.exit(1);
|
|
232
|
+
}
|
|
233
|
+
console.log(`Connection dropped, retrying (${attempts}/${maxAttempts})...`);
|
|
234
|
+
setTimeout(connect, 3000);
|
|
235
|
+
}
|
|
236
|
+
});
|
|
237
|
+
};
|
|
238
|
+
await connect();
|
|
220
239
|
console.log('Scan the QR code above with your phone (WhatsApp → Linked Devices → Link a Device)');
|
|
221
240
|
console.log('Waiting for pairing... (Ctrl+C to cancel)\n');
|
|
222
241
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "beecork",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.4",
|
|
4
4
|
"description": "Claude Code always-on infrastructure — a phone number, a memory, and an alarm clock",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -26,6 +26,7 @@
|
|
|
26
26
|
"discord.js": "^14.26.2",
|
|
27
27
|
"node-cron": "^4.2.1",
|
|
28
28
|
"node-telegram-bot-api": "^0.67.0",
|
|
29
|
+
"qrcode-terminal": "^0.12.0",
|
|
29
30
|
"uuid": "^13.0.0"
|
|
30
31
|
},
|
|
31
32
|
"devDependencies": {
|