beast-agent 2.22.1 → 2.22.2

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/agent/engine.js +54 -30
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "beast-agent",
3
3
  "productName": "Beast Agent",
4
- "version": "2.22.1",
4
+ "version": "2.22.2",
5
5
  "description": "Ultra-fast local agent shell for Windows.",
6
6
  "author": "algokodcom (AlgoKod)",
7
7
  "license": "MIT",
@@ -6192,7 +6192,34 @@ Engine.prototype._agentDmSend = function (fromSid, args) {
6192
6192
  }
6193
6193
  }
6194
6194
  }
6195
- if (!target || !jobs.has(target)) {
6195
+ /* ANA OTURUM FALLBACK: chat oturumları this.cache'te yaşar (_bgJobs dışında).
6196
+ Finance trader → ana Beast DM zinciri böyle kapanır: ajan sahibine
6197
+ (ana sohbete) DM ile rapor verebilir. Eşleşme: bgTitle / title / kod. */
6198
+ if (!target) {
6199
+ const q = to.toLowerCase();
6200
+ for (const [sid, s] of this.cache) {
6201
+ if (sid === String(fromSid)) continue;
6202
+ if (!s || s.bgJob || s.isBotDm) continue;
6203
+ if (s.botId && s.botId !== 'beast') continue;
6204
+ const hay = [s.bgTitle, s.title, s.code].map((x) => String(x || '').toLowerCase());
6205
+ if (hay.some((x) => x && x.includes(q))) {
6206
+ target = sid;
6207
+ break;
6208
+ }
6209
+ }
6210
+ }
6211
+ if (String(target) === String(fromSid)) return { ok: false, error: 'kendine DM atılamaz' };
6212
+ const fromJob = jobs.get(String(fromSid));
6213
+ const toJob = jobs.get(target);
6214
+ const targetIsAgent = jobs.has(target);
6215
+ const mainChatSess = targetIsAgent ? null : this.cache.get(String(target)) || null;
6216
+ const targetIsMainChat = !!(
6217
+ mainChatSess &&
6218
+ !mainChatSess.bgJob &&
6219
+ !mainChatSess.isBotDm &&
6220
+ (!mainChatSess.botId || mainChatSess.botId === 'beast')
6221
+ );
6222
+ if (!targetIsAgent && !targetIsMainChat) {
6196
6223
  const titles = [...jobs.values()]
6197
6224
  .filter((j) => j && j.status === 'running' && j.title)
6198
6225
  .map((j) => j.title)
@@ -6202,32 +6229,25 @@ Engine.prototype._agentDmSend = function (fromSid, args) {
6202
6229
  error: 'hedef ajan bulunamadı: "' + to + '"' + (titles.length ? ' — koşan ajanlar: ' + titles.join(', ') : ''),
6203
6230
  };
6204
6231
  }
6205
- if (String(target) === String(fromSid)) return { ok: false, error: 'kendine DM atılamaz' };
6206
- const fromJob = jobs.get(String(fromSid));
6207
- const toJob = jobs.get(target);
6208
- /* FİNANS SINIRI: Beast Finance oturumu agent_dm kullansa bile finance
6209
- dünyasının DIŞINA ÇIKMAZ — yalnız finance ajanlarına DM atabilir
6210
- (trader ↔ GOLD işçisi ↔ finance işçileri). Finance dışı hedef reddedilir. */
6211
- const fromSess = this.cache.get(String(fromSid)) || null;
6212
- if (fromSess && fromSess.finance) {
6213
- const targetSess = this.cache.get(String(target)) || null;
6214
- if (!targetSess || !targetSess.finance) {
6215
- return {
6216
- ok: false,
6217
- error:
6218
- 'Beast Finance ajanı yalnız finance dünyasındaki ajanlara DM atabilir — hedef finance dışı: ' +
6219
- String((toJob && toJob.title) || to),
6220
- };
6221
- }
6222
- }
6232
+ /* TÜM ajanlar birbiriyle iletişim kurabilir — sınırsız DM (yalnız kendine
6233
+ DM atanamaz). Finance ajanları da dahil herkes herkesle konuşur. */
6223
6234
  /* konu etiketi: aynı konudaki DM'ler panelde AYNI oturumda toplanır */
6224
6235
  const topic = String((args && args.topic) || '').replace(/\s+/g, ' ').trim().slice(0, 60) || '(genel)';
6236
+ const fromTitle =
6237
+ fromJob && fromJob.title
6238
+ ? String(fromJob.title)
6239
+ : fromSess
6240
+ ? 'Beast · ' + String(fromSess.code || '')
6241
+ : 'Ajan';
6242
+ const toTitle = targetIsAgent
6243
+ ? String((toJob && toJob.title) || 'Ajan')
6244
+ : String((mainChatSess && (mainChatSess.bgTitle || mainChatSess.title)) || 'Beast');
6225
6245
  const dm = {
6226
6246
  at: new Date().toISOString(),
6227
6247
  from: String(fromSid),
6228
- fromTitle: (fromJob && fromJob.title) || 'Ajan',
6248
+ fromTitle,
6229
6249
  to: String(target),
6230
- toTitle: (toJob && toJob.title) || 'Ajan',
6250
+ toTitle,
6231
6251
  topic,
6232
6252
  text,
6233
6253
  };
@@ -6238,15 +6258,19 @@ Engine.prototype._agentDmSend = function (fromSid, args) {
6238
6258
  fs.writeFileSync(this._agentDmsFile, JSON.stringify({ dms: this._agentDms }, null, 2));
6239
6259
  } catch {}
6240
6260
  emitSafe(this, target, { type: 'agent-dm', ...dm });
6241
- /* teslim: hedef meşgulse pending kuyruğunda bekler, done olunca düşer.
6242
- Cevap zinciri AYNI thread'den sürsün diye topic geri bildirilir. */
6243
- (this._pendingReports = this._pendingReports || []).push({
6244
- parentId: target,
6245
- text:
6246
- `[AJAN DM — ${dm.fromTitle} · konu: "${topic}"]\n${text}\n` +
6247
- `(Cevabını agent_dm aracıyla ver — to: "${dm.fromTitle}", topic: "${topic}")`,
6248
- });
6249
- this.flushPendingReports(target);
6261
+ /* teslim: hedef AJANSA (arka plan işi / finance ajanı) mesaj olarak düşer —
6262
+ meşgulse pending kuyruğunda bekler, done olunca görünür.
6263
+ DÜZ CHAT OTURUMUNA (sahibin sohbet geçmişi) ENJEKTE ETMEYİZ — DM trafik
6264
+ yalnız AJAN DM konsolunda görünür, senin sohbetlerin karışmaz. */
6265
+ if (targetIsAgent) {
6266
+ (this._pendingReports = this._pendingReports || []).push({
6267
+ parentId: target,
6268
+ text:
6269
+ `[AJAN DM — ${dm.fromTitle} · konu: "${topic}"]\n${text}\n` +
6270
+ `(Cevabını agent_dm aracıyla ver — to: "${dm.fromTitle}", topic: "${topic}")`,
6271
+ });
6272
+ this.flushPendingReports(target);
6273
+ }
6250
6274
  return { ok: true, to: target, toTitle: dm.toTitle, topic };
6251
6275
  } catch (e) {
6252
6276
  return { ok: false, error: String((e && e.message) || e) };