beast-agent 2.35.0 → 2.35.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/main.js +48 -8
- package/src/preload.js +1 -0
- package/src/renderer/renderer.js +1 -0
package/package.json
CHANGED
package/src/main.js
CHANGED
|
@@ -317,6 +317,7 @@ let waHistory = new Map(); // jid -> [sid,...] bu sohbete ait tüm oturumlar
|
|
|
317
317
|
let waBcMode = new Set(); // jid -> BeastCode modu AKTİF (WhatsApp'tan uzaktan kodlama)
|
|
318
318
|
let waJidPn = new Map(); // jid -> gerçek telefon numarası (LID fallback için)
|
|
319
319
|
let waLastActiveJid = ''; // en son mesaj gelen WA sohbeti — kanal tek oturumunda cevap/dosya hedefi
|
|
320
|
+
let desktopActiveSid = ''; // masaüstü UI'da AÇIK olan oturum — proaktif not buraya işlenir
|
|
320
321
|
const WA_HISTORY_CAP = 20;
|
|
321
322
|
let tg = null;
|
|
322
323
|
let tgChats = new Map(); // telegram chatId -> aktif session id (hepsi KANAL TEK OTURUMUNA bağlı)
|
|
@@ -5081,11 +5082,34 @@ ipcMain.handle('sessions:create', () => {
|
|
|
5081
5082
|
return v;
|
|
5082
5083
|
});
|
|
5083
5084
|
ipcMain.handle('sessions:open', (_e, id) => engine.openSession(id));
|
|
5084
|
-
ipcMain.handle('sessions:delete', (_e, id) =>
|
|
5085
|
+
ipcMain.handle('sessions:delete', (_e, id) => {
|
|
5086
|
+
const sid = String(id || '');
|
|
5087
|
+
if (sid && sid === desktopActiveSid) desktopActiveSid = '';
|
|
5088
|
+
return engine.deleteSession(id);
|
|
5089
|
+
});
|
|
5090
|
+
/* masaüstü UI hangi sohbeti AÇIK tutuyorsa main'e bildirir: empati loop
|
|
5091
|
+
proaktif notu rastgele bir oturuma değil, kullanıcının gördüğü sohbete
|
|
5092
|
+
işler; meşgulse enjeksiyon kuyruğa girer, tur bitince geçmişe düşer */
|
|
5093
|
+
ipcMain.handle('sessions:active', (_e, id) => {
|
|
5094
|
+
const sid = String(id || '');
|
|
5095
|
+
if (!sid) {
|
|
5096
|
+
desktopActiveSid = '';
|
|
5097
|
+
return true;
|
|
5098
|
+
}
|
|
5099
|
+
try {
|
|
5100
|
+
if (sessionFileAlive(sid)) desktopActiveSid = sid;
|
|
5101
|
+
} catch {}
|
|
5102
|
+
return true;
|
|
5103
|
+
});
|
|
5085
5104
|
|
|
5086
5105
|
ipcMain.handle('agent:send', (_e, { sessionId, text }) => {
|
|
5087
5106
|
const raw = text && typeof text === 'object' ? String(text.text || '') : String(text ?? '');
|
|
5088
5107
|
const t = raw.trim();
|
|
5108
|
+
/* yazan sohbet = kullanıcının gördüğü sohbet: proaktif enjeksiyon hedefi */
|
|
5109
|
+
try {
|
|
5110
|
+
const asid = String(sessionId || '');
|
|
5111
|
+
if (asid && sessionFileAlive(asid)) desktopActiveSid = asid;
|
|
5112
|
+
} catch {}
|
|
5089
5113
|
/* BOT HAFIZA GARANTİSİ: aktif bot bir MÜŞTERİ botuysa, botId'siz (eskiden
|
|
5090
5114
|
kalma) oturumlar bu bota bağlanır — bot konuşması asla Beast'in global
|
|
5091
5115
|
hafızasıyla (SOUL/USER/MEMORY) yürümez. Var olan botId asla üstüne yazılmaz. */
|
|
@@ -7210,10 +7234,18 @@ function ensureDcSession(channelId) {
|
|
|
7210
7234
|
return dcSingleSid;
|
|
7211
7235
|
}
|
|
7212
7236
|
|
|
7213
|
-
/* Masaüstü
|
|
7214
|
-
|
|
7237
|
+
/* Masaüstü hedefi: kullanıcının AÇIK sohbeti önceliklidir — proaktif not
|
|
7238
|
+
nereye bakıyorsa oraya işlenir; meşgulse empatiInjectToSession kuyruğa alır.
|
|
7239
|
+
Açık sohbet bilinmiyorsa en güncel meşgul olmayan sohbet (kanal oturumları
|
|
7240
|
+
hariç — onlara kanal yoluyla zaten enjekte edildi); o da yoksa yeni oturum. */
|
|
7241
|
+
function empatiDesktopSid(exclude) {
|
|
7242
|
+
const skip = exclude instanceof Set ? exclude : null;
|
|
7243
|
+
try {
|
|
7244
|
+
if (desktopActiveSid && sessionFileAlive(desktopActiveSid)) return String(desktopActiveSid);
|
|
7245
|
+
} catch {}
|
|
7215
7246
|
try {
|
|
7216
7247
|
for (const v of engine.listSessions()) {
|
|
7248
|
+
if (skip && skip.has(String(v.id))) continue;
|
|
7217
7249
|
if (!engine.isBusy(v.id)) return String(v.id);
|
|
7218
7250
|
}
|
|
7219
7251
|
} catch {}
|
|
@@ -7234,14 +7266,17 @@ function empatiNotify(text, ev) {
|
|
|
7234
7266
|
const outWa = PROACTIVE_MARK + '\n' + text + (srcWa ? '\n' + srcWa : '');
|
|
7235
7267
|
const inject = empatiInjectText(ev, out);
|
|
7236
7268
|
const senders = [];
|
|
7269
|
+
const channelSids = new Set(); /* bu tur enjeksiyon ALAN kanal oturumları */
|
|
7237
7270
|
const tryWa = () => {
|
|
7238
7271
|
try {
|
|
7239
7272
|
const own = waOwnerNum();
|
|
7240
7273
|
if (own && wa && wa.connected) {
|
|
7241
7274
|
const jid = own + '@s.whatsapp.net';
|
|
7275
|
+
const sid = ensureWaSession(jid);
|
|
7276
|
+
channelSids.add(String(sid));
|
|
7242
7277
|
senders.push(() =>
|
|
7243
7278
|
Promise.resolve(sendWaSafe(jid, outWa))
|
|
7244
|
-
.then(() => empatiInjectToSession(
|
|
7279
|
+
.then(() => empatiInjectToSession(sid, inject))
|
|
7245
7280
|
.catch(() => {})
|
|
7246
7281
|
);
|
|
7247
7282
|
}
|
|
@@ -7251,9 +7286,11 @@ function empatiNotify(text, ev) {
|
|
|
7251
7286
|
try {
|
|
7252
7287
|
if (tg && tg.connected) {
|
|
7253
7288
|
for (const id of tgOwnerIds()) {
|
|
7289
|
+
const sid = ensureTgSession(String(id));
|
|
7290
|
+
channelSids.add(String(sid));
|
|
7254
7291
|
senders.push(() =>
|
|
7255
7292
|
Promise.resolve(sendTgSafe(id, outPlain))
|
|
7256
|
-
.then(() => empatiInjectToSession(
|
|
7293
|
+
.then(() => empatiInjectToSession(sid, inject))
|
|
7257
7294
|
.catch(() => {})
|
|
7258
7295
|
);
|
|
7259
7296
|
}
|
|
@@ -7265,9 +7302,11 @@ function empatiNotify(text, ev) {
|
|
|
7265
7302
|
if (dc && dc.connected) {
|
|
7266
7303
|
const outDc = out.replace('🫡 *Beast proaktif:*', '🫡 **Beast proaktif:**');
|
|
7267
7304
|
for (const id of dcOwnerIds()) {
|
|
7305
|
+
const sid = ensureDcSession(String(id));
|
|
7306
|
+
channelSids.add(String(sid));
|
|
7268
7307
|
senders.push(() =>
|
|
7269
7308
|
Promise.resolve(sendDcSafe(id, outDc))
|
|
7270
|
-
.then(() => empatiInjectToSession(
|
|
7309
|
+
.then(() => empatiInjectToSession(sid, inject))
|
|
7271
7310
|
.catch(() => {})
|
|
7272
7311
|
);
|
|
7273
7312
|
}
|
|
@@ -7289,8 +7328,9 @@ function empatiNotify(text, ev) {
|
|
|
7289
7328
|
gider (kanal kullanıcısı ham BAĞLAM bloğunu görmez, ajan görür). */
|
|
7290
7329
|
try {
|
|
7291
7330
|
if (win && !win.isDestroyed()) {
|
|
7292
|
-
const dsid = empatiDesktopSid();
|
|
7293
|
-
|
|
7331
|
+
const dsid = String(empatiDesktopSid(channelSids) || '');
|
|
7332
|
+
/* aynı oturuma kanal yoluyla zaten enjekte edildiyse TEKRAR yazma */
|
|
7333
|
+
if (dsid && !channelSids.has(dsid)) empatiInjectToSession(dsid, out);
|
|
7294
7334
|
win.webContents.send('agent:event', { type: 'proactive', sessionId: dsid, id: ev.id, level: ev.level, title: ev.title, text: out });
|
|
7295
7335
|
}
|
|
7296
7336
|
} catch {}
|
package/src/preload.js
CHANGED
|
@@ -10,6 +10,7 @@ contextBridge.exposeInMainWorld('beast', {
|
|
|
10
10
|
listSessions: () => ipcRenderer.invoke('sessions:list'),
|
|
11
11
|
createSession: () => ipcRenderer.invoke('sessions:create'),
|
|
12
12
|
openSession: (id) => ipcRenderer.invoke('sessions:open', id),
|
|
13
|
+
setActiveSession: (id) => ipcRenderer.invoke('sessions:active', id),
|
|
13
14
|
deleteSession: (id) => ipcRenderer.invoke('sessions:delete', id),
|
|
14
15
|
send: (sessionId, text) => ipcRenderer.invoke('agent:send', { sessionId, text }),
|
|
15
16
|
interrupt: (sessionId, reason) => ipcRenderer.invoke('agent:interrupt', sessionId, reason),
|
package/src/renderer/renderer.js
CHANGED