beast-agent 2.44.9 → 2.44.10
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/main.js +95 -16
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -3362,6 +3362,8 @@ function reloadBackend() {
|
|
|
3362
3362
|
böylece ham cevap + önekli cevap çift gönderimi olmaz. */
|
|
3363
3363
|
const cjob =
|
|
3364
3364
|
ev.type === 'done' || ev.type === 'error' ? cronAnswerPendingTake(ev.sessionId) : null;
|
|
3365
|
+
/* cron turu bitti → kuyruktaki sıradaki işi başlat (tek tek koşarlar) */
|
|
3366
|
+
if (ev.type === 'done' || ev.type === 'error') cronJobFinished(ev.sessionId);
|
|
3365
3367
|
// WhatsApp oturumlarının son cevabını geri gönder (metin + opsiyonel ses)
|
|
3366
3368
|
if ((ev.type === 'done' || ev.type === 'error') && !cjob && wa && wa.connected) {
|
|
3367
3369
|
const wajid = waReplyJid(ev.sessionId);
|
|
@@ -7035,31 +7037,108 @@ function cronMirrorTargets(cronSid) {
|
|
|
7035
7037
|
return out;
|
|
7036
7038
|
}
|
|
7037
7039
|
|
|
7038
|
-
|
|
7039
|
-
|
|
7040
|
-
|
|
7041
|
-
|
|
7042
|
-
|
|
7040
|
+
/* ---------- CRON SIRASI (kuyruk) ----------
|
|
7041
|
+
Aynı dakikada birden fazla iş tetiklenebilir. İşler AYNI taban oturumda
|
|
7042
|
+
koştuğu için hepsini birden göndermek engine'in steer tamponunda birleşmeye
|
|
7043
|
+
ve cron cevap kaydının üst üste yazılmasına yol açıyordu. Artık işler
|
|
7044
|
+
sıraya girer: BİRİ bitmeden (done/error) diğeri gönderilmez; oturum
|
|
7045
|
+
kullanıcı turuyla meşgulse sıradaki iş bekler. */
|
|
7046
|
+
const cronQueue = [];
|
|
7047
|
+
let cronRunning = false;
|
|
7048
|
+
let cronRunningSid = '';
|
|
7049
|
+
let cronPumpTimer = null;
|
|
7050
|
+
let cronWatchdog = null;
|
|
7051
|
+
|
|
7052
|
+
function cronPumpSoon(ms) {
|
|
7053
|
+
if (cronPumpTimer) return; // tek zamanlayıcı — üst üste birikmez
|
|
7054
|
+
cronPumpTimer = setTimeout(() => {
|
|
7055
|
+
cronPumpTimer = null;
|
|
7056
|
+
cronPump();
|
|
7057
|
+
}, ms);
|
|
7058
|
+
}
|
|
7059
|
+
|
|
7060
|
+
/* Emniyet bekçisi: çalışıyor sanılan iş için done/error olayı kaçarsa
|
|
7061
|
+
(oturum artık meşgul değilse) kuyruğu açar; iş hâlâ koşuyorsa izler. */
|
|
7062
|
+
function cronArmWatchdog() {
|
|
7063
|
+
if (cronWatchdog) clearTimeout(cronWatchdog);
|
|
7064
|
+
cronWatchdog = setTimeout(() => {
|
|
7065
|
+
cronWatchdog = null;
|
|
7066
|
+
if (!cronRunning) return;
|
|
7067
|
+
let busy = false;
|
|
7068
|
+
try { busy = !!cronRunningSid && engine.isBusy(cronRunningSid); } catch {}
|
|
7069
|
+
if (busy) { cronArmWatchdog(); return; }
|
|
7070
|
+
cronRunning = false;
|
|
7071
|
+
cronRunningSid = '';
|
|
7072
|
+
if (cronQueue.length) cronPumpSoon(50);
|
|
7073
|
+
}, 60000);
|
|
7074
|
+
}
|
|
7075
|
+
|
|
7076
|
+
/* sıradaki cron işini (oturum boşsa) başlatır */
|
|
7077
|
+
function cronPump() {
|
|
7078
|
+
if (cronRunning || !cronQueue.length) return;
|
|
7079
|
+
const job = cronQueue.shift();
|
|
7080
|
+
let sid = '';
|
|
7081
|
+
try { sid = cronBaseSession(); } catch {}
|
|
7082
|
+
if (!sid || !engine) {
|
|
7083
|
+
cronQueue.unshift(job); // oturum yok — sonra tekrar dene
|
|
7084
|
+
cronPumpSoon(5000);
|
|
7043
7085
|
return;
|
|
7044
7086
|
}
|
|
7087
|
+
if (engine.isBusy(sid)) {
|
|
7088
|
+
cronQueue.unshift(job); // kullanıcı/başka tur koşuyor — bekle
|
|
7089
|
+
cronPumpSoon(3000);
|
|
7090
|
+
return;
|
|
7091
|
+
}
|
|
7092
|
+
cronRunning = true;
|
|
7093
|
+
cronRunningSid = String(sid);
|
|
7094
|
+
cronAnswerPendingSet(sid, job);
|
|
7095
|
+
let sent = false;
|
|
7045
7096
|
try {
|
|
7046
|
-
|
|
7047
|
-
seçilir; cevap done olayında TÜM bağlı entegrasyonlara yansıtılır. */
|
|
7048
|
-
const sid = cronBaseSession();
|
|
7049
|
-
cronAnswerPendingSet(sid, job);
|
|
7050
|
-
const sent = engine.send(sid, {
|
|
7097
|
+
sent = engine.send(sid, {
|
|
7051
7098
|
text: `[cron: ${job.name}]\n${job.prompt}`,
|
|
7052
7099
|
});
|
|
7053
|
-
toastNotify(
|
|
7054
|
-
`Cron: ${job.name}`,
|
|
7055
|
-
isReminderJob(job) ? 'Hatırlatma zamanı geldi' : String(job.prompt || '').slice(0, 160),
|
|
7056
|
-
'cron'
|
|
7057
|
-
);
|
|
7058
|
-
if (!sent) cronAnswerPendingDrop(sid); // gönderilemedi — bayat bekleme bırakma
|
|
7059
7100
|
} catch {}
|
|
7101
|
+
if (!sent) {
|
|
7102
|
+
/* gönderilemedi (ör. /stop kilidi) — kaydı bırakma, sıradakine geç */
|
|
7103
|
+
cronRunning = false;
|
|
7104
|
+
cronRunningSid = '';
|
|
7105
|
+
cronAnswerPendingDrop(sid);
|
|
7106
|
+
cronPumpSoon(1000);
|
|
7107
|
+
cronEmit();
|
|
7108
|
+
return;
|
|
7109
|
+
}
|
|
7110
|
+
toastNotify(
|
|
7111
|
+
`Cron: ${job.name}`,
|
|
7112
|
+
isReminderJob(job) ? 'Hatırlatma zamanı geldi' : String(job.prompt || '').slice(0, 160),
|
|
7113
|
+
'cron'
|
|
7114
|
+
);
|
|
7115
|
+
cronArmWatchdog();
|
|
7060
7116
|
cronEmit();
|
|
7061
7117
|
}
|
|
7062
7118
|
|
|
7119
|
+
/* iş turu bitti (done/error) — çalışan işi kapat, sıradakini başlat */
|
|
7120
|
+
function cronJobFinished(sid) {
|
|
7121
|
+
if (cronRunning && String(sid) === cronRunningSid) {
|
|
7122
|
+
cronRunning = false;
|
|
7123
|
+
cronRunningSid = '';
|
|
7124
|
+
}
|
|
7125
|
+
if (cronQueue.length) cronPumpSoon(50); // ctrls temizlenmesini bekle
|
|
7126
|
+
}
|
|
7127
|
+
|
|
7128
|
+
function cronFire(job) {
|
|
7129
|
+
/* BEAST FINANCE günlük rutin: plan/review job'ları trader'a özel gönderilir */
|
|
7130
|
+
if (job && (job.kind === 'finance-plan' || job.kind === 'finance-review')) {
|
|
7131
|
+
try { finDailyRoutine(job.kind === 'finance-plan' ? 'plan' : 'review'); } catch {}
|
|
7132
|
+
cronEmit();
|
|
7133
|
+
return;
|
|
7134
|
+
}
|
|
7135
|
+
/* OTURUMSUZ ÇALIŞTIRMA: taban oturum WA → TG → DC → masaüstü sırasıyla
|
|
7136
|
+
seçilir; işler kuyrukta TEK TEK koşar, cevap done olayında TÜM bağlı
|
|
7137
|
+
entegrasyonlara yansıtılır. */
|
|
7138
|
+
cronQueue.push(job);
|
|
7139
|
+
cronPump();
|
|
7140
|
+
}
|
|
7141
|
+
|
|
7063
7142
|
/* İzleyici tetiklendiğinde ilgili sohbete kullanıcı mesajı gibi düşer */
|
|
7064
7143
|
function watcherFire(w, value) {
|
|
7065
7144
|
try {
|