beast-agent 0.23.3 → 0.23.5

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "beast-agent",
3
3
  "productName": "Beast Agent",
4
- "version": "0.23.3",
4
+ "version": "0.23.5",
5
5
  "description": "Ultra-fast local agent shell for Windows.",
6
6
  "author": "algokodcom (AlgoKod)",
7
7
  "license": "MIT",
package/src/main.js CHANGED
@@ -1227,10 +1227,15 @@ async function emailList(opts = {}) {
1227
1227
  await client.connect();
1228
1228
  const lock = await client.getMailboxLock(opts.folder || 'INBOX');
1229
1229
  try {
1230
- let uids = opts.unread ? await client.search({ seen: false }) : await client.search({ all: true });
1230
+ /* uid:true OPTIONS'ta (2. argüman değil) UID SEARCH gerçek UID'leri döndürür */
1231
+ let uids = opts.unread
1232
+ ? await client.search({ seen: false }, { uid: true })
1233
+ : await client.search({ all: true }, { uid: true });
1231
1234
  uids = Array.isArray(uids) ? uids.slice(-limit) : [];
1235
+ if (!uids.length) return { ok: true, messages: [] };
1232
1236
  const messages = [];
1233
- for await (const m of client.fetch(uids, { uid: true, envelope: true })) {
1237
+ /* fetch'te de uid opsiyonu 3. argümanda UID FETCH */
1238
+ for await (const m of client.fetch(uids.map(String).join(','), { envelope: true }, { uid: true })) {
1234
1239
  const from = (m.envelope.from || [])
1235
1240
  .map((a) => (a.name ? `${a.name} <${a.address}>` : a.address))
1236
1241
  .join(', ');
@@ -1251,6 +1256,11 @@ async function emailRead(uid) {
1251
1256
  const cfg = emailCfg();
1252
1257
  if (!cfg.host || !cfg.user || !cfg.pass) return { ok: false, error: 'e-posta ayarlanmamış' };
1253
1258
  if (!ImapFlow) return { ok: false, error: 'imap modülü yok' };
1259
+ /* engine aracı args OBJESİ geçirir ({ uid: 12 }), düz değer çağıranlar da var — ikisini de kabul et.
1260
+ (Bug: obje Number()'a çevrilince NaN → "Invalid sequence set value") */
1261
+ const u0 = uid && typeof uid === 'object' ? uid.uid : uid;
1262
+ const u = Math.floor(Number(u0));
1263
+ if (!Number.isSafeInteger(u) || u <= 0) return { ok: false, error: 'geçersiz uid: ' + JSON.stringify(u0) };
1254
1264
  const client = new ImapFlow({
1255
1265
  host: cfg.host,
1256
1266
  port: Number(cfg.port) || 993,
@@ -1262,11 +1272,12 @@ async function emailRead(uid) {
1262
1272
  await client.connect();
1263
1273
  const lock = await client.getMailboxLock('INBOX');
1264
1274
  try {
1265
- for await (const m of client.fetch([Number(uid)], { uid: true, source: true })) {
1275
+ /* uid opsiyonu 3. argümanda — 'UID FETCH <u>' (yoksa seq number fetch edilir, yanlış mail gelir) */
1276
+ for await (const m of client.fetch(String(u), { source: true }, { uid: true })) {
1266
1277
  const raw = m.source.toString('utf8');
1267
1278
  const bodyPart = raw.split(/\r?\n\r?\n/).slice(1).join('\n\n') || raw;
1268
1279
  const text = htmlToText(bodyPart);
1269
- return { ok: true, uid: Number(uid), content: String(text || '').slice(0, 8000) };
1280
+ return { ok: true, uid: u, content: String(text || '').slice(0, 8000) };
1270
1281
  }
1271
1282
  return { ok: false, error: 'mail bulunamadı' };
1272
1283
  } finally {
@@ -2325,6 +2325,32 @@ async function renderTgAllow() {
2325
2325
  });
2326
2326
  c.appendChild(sel);
2327
2327
  }
2328
+
2329
+ /* SAHİP rolü — yalnız biri olabilir (WA ile aynı): tıkla → sahiplik devret */
2330
+ const isOwnerEntry = typeof entry === 'object' && !!entry.owner;
2331
+ const ownerBtn = document.createElement('span');
2332
+ ownerBtn.className = 'lk';
2333
+ ownerBtn.style.cssText = 'font-size:11px;padding:1px 6px;' + (isOwnerEntry ? 'color:#c9a227;font-weight:800' : '');
2334
+ ownerBtn.title = isOwnerEntry ? _t('wa_owner_title_on') : _t('wa_owner_title_off');
2335
+ ownerBtn.textContent = isOwnerEntry ? _t('wa_owner_on') : _t('wa_owner_off');
2336
+ ownerBtn.addEventListener('click', async () => {
2337
+ if (isOwnerEntry) return; // sahibi tekrar tıklamayla alma; önce başkasına devret
2338
+ const cur = await beast.tgGetAllow();
2339
+ const next = cur.map((e, i) => {
2340
+ if (typeof e === 'object' && e && e.owner) return { ...e, owner: false };
2341
+ if (i === idx) {
2342
+ const obj = typeof e === 'string' ? { id: e, name: '' } : { ...e };
2343
+ obj.owner = true;
2344
+ return obj;
2345
+ }
2346
+ return e;
2347
+ });
2348
+ const tgt = next[idx];
2349
+ await beast.tgSetAllow(next);
2350
+ renderTgAllow();
2351
+ toast('Sahip: ' + tgLabel(tgt));
2352
+ });
2353
+ c.appendChild(ownerBtn);
2328
2354
  }
2329
2355
  const x = document.createElement('span');
2330
2356
  x.className = 'x';
@@ -2364,7 +2390,13 @@ async function renderTgAllow() {
2364
2390
  v = v.startsWith('@') ? '@' + v.slice(1).replace(/[^\w]/g, '') : v.replace(/[^\d]/g, '');
2365
2391
  if (!v) { toast(_t('it_tg_id_ph')); return; }
2366
2392
  const botId = botSel && botSel.value ? { bot_id: botSel.value } : {};
2367
- await beast.tgSetAllow([...(await beast.tgGetAllow()), { id: v, name, ...botId }]);
2393
+ const next = [...(await beast.tgGetAllow()), { id: v, name, ...botId }];
2394
+ /* İLK EKLENEN KİŞİ OTOMATİK SAHİP — listede sahip yoksa en eski kayıt atanır
2395
+ (sahiplik sonradan chip'teki 'sahip yap' butonundan devredilebilir) */
2396
+ if (!next.some((e) => e && typeof e === 'object' && e.owner)) {
2397
+ if (next.length && typeof next[0] === 'object') next[0].owner = true;
2398
+ }
2399
+ await beast.tgSetAllow(next);
2368
2400
  inp.value = '';
2369
2401
  nameInp.value = '';
2370
2402
  renderTgAllow();