beast-agent 2.30.0 → 2.30.1
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/agent/engine.js +41 -6
package/package.json
CHANGED
package/src/agent/engine.js
CHANGED
|
@@ -2494,7 +2494,6 @@ class Engine {
|
|
|
2494
2494
|
korunur — sadece içerik temizlenir, önek cache bozulmaz. Döndürür: kazanılan token */
|
|
2495
2495
|
_pruneSession(session) {
|
|
2496
2496
|
try {
|
|
2497
|
-
if (this.ctrls.has(session.id)) return 0;
|
|
2498
2497
|
const msgs = session.messages;
|
|
2499
2498
|
let total = 0, pruned = 0, turns = 0;
|
|
2500
2499
|
const targets = [];
|
|
@@ -2585,7 +2584,10 @@ class Engine {
|
|
|
2585
2584
|
`- kullanıcının hedefleri ve net talepleri\n` +
|
|
2586
2585
|
`- alınan kararlar, önemli bilgi parçaları (isim, sayı, dosya/klasör yolu, hata ve çözümü)\n` +
|
|
2587
2586
|
`- tamamlanan işler ve sonuçları\n` +
|
|
2588
|
-
|
|
2587
|
+
(session.finance
|
|
2588
|
+
? `- FİNANS İŞLEMLERİ (KRİTİK, atlama): açılan/kapatılan/güncellenen pozisyonlar — sembol, yön (AL/SAT), lot, giriş/SL/TP, kâr/zarar ve gerekçe; sonraki turlarda birebir hatırlanmalı\n`
|
|
2589
|
+
: '') +
|
|
2590
|
+
`Madde madde yaz, en fazla ${session.finance ? 180 : 120} kelime, başlık/selamlama yok. Alakasız ayrıntıyı at.\n\n` +
|
|
2589
2591
|
`# SOHBET PARÇASI\n${transcript}`;
|
|
2590
2592
|
const res = await chatOnce(
|
|
2591
2593
|
this.sel,
|
|
@@ -2687,6 +2689,25 @@ class Engine {
|
|
|
2687
2689
|
}
|
|
2688
2690
|
}
|
|
2689
2691
|
|
|
2692
|
+
/* SÜREKLİ ajan DM INBOX (bkz. flushPendingReports): tur aralığında biriken
|
|
2693
|
+
DM'ler yeni tur AÇMAZ; sıradaki planlı turun mesajına tek blok olarak
|
|
2694
|
+
eklenir — ajan-ajan sonsuz DM ping-pong'u ve bağlam şişmesi engellenir. */
|
|
2695
|
+
try {
|
|
2696
|
+
const jobRec = this._bgJobs && this._bgJobs.get(String(sessionId));
|
|
2697
|
+
if (jobRec && Array.isArray(jobRec.dmInbox) && jobRec.dmInbox.length) {
|
|
2698
|
+
const inbox = jobRec.dmInbox.splice(0);
|
|
2699
|
+
const boxText = inbox.join('\n\n').slice(0, 6000);
|
|
2700
|
+
const prefix =
|
|
2701
|
+
`[BEKLEYEN AJAN DM'LERİ — ${inbox.length} mesaj]\n${boxText}\n` +
|
|
2702
|
+
`(Tur aralığında biriken DM'ler. Bu turda değerlendir; yalnızca aksiyon/cevap GEREKİYORSA agent_dm ile TEK kısa cevap ver — teşekkür/onay/ack mesajı YAZMA.)\n\n`;
|
|
2703
|
+
if (typeof msg.content === 'string') {
|
|
2704
|
+
msg.content = prefix + msg.content;
|
|
2705
|
+
} else if (Array.isArray(msg.content) && msg.content[0] && typeof msg.content[0].text === 'string') {
|
|
2706
|
+
msg.content[0] = { ...msg.content[0], text: prefix + msg.content[0].text };
|
|
2707
|
+
}
|
|
2708
|
+
}
|
|
2709
|
+
} catch {}
|
|
2710
|
+
|
|
2690
2711
|
if (!String(typeof msg.content === 'string' ? msg.content : msg.content[0].text || '').trim()) return false;
|
|
2691
2712
|
/* #12 kişilik kalibrasyonu: kullanıcı cümlelerini örnek havuzuna düşür (Beast Code hariç — hız) */
|
|
2692
2713
|
if (!s.bcCode) {
|
|
@@ -3514,10 +3535,22 @@ class Engine {
|
|
|
3514
3535
|
this._pendingReports = [];
|
|
3515
3536
|
return;
|
|
3516
3537
|
}
|
|
3538
|
+
const job = this._bgJobs && this._bgJobs.get(String(sessionId));
|
|
3539
|
+
/* SÜREKLİ ajan (Beast Finance): DM/rapor teslimi YENİ TUR AÇMAZ — aksi
|
|
3540
|
+
halde ajanlar birbirine DM attıkça sonsuz tur döngüsü doğar (bağlam
|
|
3541
|
+
şişer, ajan hiç dinlenmez). Mesaj inbox'a yazılır; bir sonraki PLANLI
|
|
3542
|
+
turda send() tarafından tek blok halinde enjekte edilir. */
|
|
3543
|
+
const continuous = !!(job && job.continuous);
|
|
3517
3544
|
const rest = [];
|
|
3518
3545
|
for (const r of this._pendingReports) {
|
|
3519
3546
|
if (r.parentId !== sessionId) { rest.push(r); continue; }
|
|
3520
3547
|
if (this._deletedSessions && this._deletedSessions.has(sessionId)) continue;
|
|
3548
|
+
if (continuous) {
|
|
3549
|
+
job.dmInbox = job.dmInbox || [];
|
|
3550
|
+
job.dmInbox.push(String(r.text || '').slice(0, 4000));
|
|
3551
|
+
if (job.dmInbox.length > 20) job.dmInbox.splice(0, job.dmInbox.length - 20);
|
|
3552
|
+
continue;
|
|
3553
|
+
}
|
|
3521
3554
|
if (this.isBusy(sessionId)) { rest.push(r); continue; }
|
|
3522
3555
|
let sent = false;
|
|
3523
3556
|
try { sent = !!this.send(sessionId, { text: r.text }); } catch {}
|
|
@@ -3558,8 +3591,10 @@ class Engine {
|
|
|
3558
3591
|
_bgTrim(session) {
|
|
3559
3592
|
const max = Engine.BG_KEEP_MSGS;
|
|
3560
3593
|
const msgs = session.messages;
|
|
3561
|
-
/* bg işleri + Beast Code
|
|
3562
|
-
|
|
3594
|
+
/* bg işleri + Beast Code + SÜREKLİ finance ajanları: uzun geçmiş payload'ı
|
|
3595
|
+
şişirip yavaşlatır — finance ajanları binlerce tur döndüğü için bağlam
|
|
3596
|
+
tavanı onlara da şart */
|
|
3597
|
+
if ((!session.bgJob && !session.bcCode && !session.finance) || msgs.length <= max) return;
|
|
3563
3598
|
let keep = msgs.slice(-max);
|
|
3564
3599
|
/* GÜVENLİ SINIR: kesim bir assistant(tool_calls) + tool sonuç çiftini BÖLMESİN.
|
|
3565
3600
|
Yetim 'tool' mesajı ya da sonuçları pencere dışında kalan tool_calls'lı
|
|
@@ -6394,7 +6429,7 @@ Engine.prototype._agentDmSend = function (fromSid, args) {
|
|
|
6394
6429
|
parentId: m,
|
|
6395
6430
|
text:
|
|
6396
6431
|
`[AJAN DM (grup: "${g.title}") — ${dm.fromTitle} · konu: "${topic}"]\n${text}\n` +
|
|
6397
|
-
`(
|
|
6432
|
+
`(Cevap yalnızca aksiyon/karar GEREKİYORSA ver — agent_dm group: "${g.title}", to: "${dm.fromTitle}", topic: "${topic}"; teşekkür/onay yazma.)`,
|
|
6398
6433
|
});
|
|
6399
6434
|
this.flushPendingReports(m);
|
|
6400
6435
|
}
|
|
@@ -6419,7 +6454,7 @@ Engine.prototype._agentDmSend = function (fromSid, args) {
|
|
|
6419
6454
|
parentId: target,
|
|
6420
6455
|
text:
|
|
6421
6456
|
`[AJAN DM — ${dm.fromTitle} · konu: "${topic}"]\n${text}\n` +
|
|
6422
|
-
`(
|
|
6457
|
+
`(Cevap yalnızca aksiyon/karar GEREKİYORSA ver — agent_dm to: "${dm.fromTitle}", topic: "${topic}"; teşekkür/onay yazma.)`,
|
|
6423
6458
|
});
|
|
6424
6459
|
this.flushPendingReports(target);
|
|
6425
6460
|
}
|