beast-agent 0.23.2 → 0.23.4
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/bus.js +6 -1
- package/src/main.js +21 -5
package/package.json
CHANGED
package/src/agent/bus.js
CHANGED
|
@@ -170,8 +170,13 @@ async function startMailIdle(getCfg) {
|
|
|
170
170
|
while (running.mailIdle) {
|
|
171
171
|
let ImapFlow = null;
|
|
172
172
|
try {
|
|
173
|
-
|
|
173
|
+
/* imapflow yeni sürümlerde named export ({ ImapFlow }) — her şekli çöz */
|
|
174
|
+
const _if = require('imapflow');
|
|
175
|
+
ImapFlow = (_if && (_if.ImapFlow || _if.default)) || (typeof _if === 'function' ? _if : null);
|
|
174
176
|
} catch {
|
|
177
|
+
ImapFlow = null;
|
|
178
|
+
}
|
|
179
|
+
if (!ImapFlow) {
|
|
175
180
|
log('imapflow yok — mail:new kapalı');
|
|
176
181
|
return;
|
|
177
182
|
}
|
package/src/main.js
CHANGED
|
@@ -179,7 +179,12 @@ let waAwaitingRestart = false;
|
|
|
179
179
|
|
|
180
180
|
let ImapFlow = null;
|
|
181
181
|
let nodemailer = null;
|
|
182
|
-
|
|
182
|
+
/* imapflow yeni sürümlerde named export ({ ImapFlow }) verir, eskisi direkt
|
|
183
|
+
class'tı — her iki şekli de (ve ESM default'unu) kapsayacak şekilde çöz */
|
|
184
|
+
try {
|
|
185
|
+
const _if = require('imapflow');
|
|
186
|
+
ImapFlow = (_if && (_if.ImapFlow || _if.default)) || (typeof _if === 'function' ? _if : null);
|
|
187
|
+
} catch {}
|
|
183
188
|
try { nodemailer = require('nodemailer'); } catch {}
|
|
184
189
|
|
|
185
190
|
const APP_DIR = path.join(app.getPath('appData'), 'beast');
|
|
@@ -1222,10 +1227,15 @@ async function emailList(opts = {}) {
|
|
|
1222
1227
|
await client.connect();
|
|
1223
1228
|
const lock = await client.getMailboxLock(opts.folder || 'INBOX');
|
|
1224
1229
|
try {
|
|
1225
|
-
|
|
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 });
|
|
1226
1234
|
uids = Array.isArray(uids) ? uids.slice(-limit) : [];
|
|
1235
|
+
if (!uids.length) return { ok: true, messages: [] };
|
|
1227
1236
|
const messages = [];
|
|
1228
|
-
|
|
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 })) {
|
|
1229
1239
|
const from = (m.envelope.from || [])
|
|
1230
1240
|
.map((a) => (a.name ? `${a.name} <${a.address}>` : a.address))
|
|
1231
1241
|
.join(', ');
|
|
@@ -1246,6 +1256,11 @@ async function emailRead(uid) {
|
|
|
1246
1256
|
const cfg = emailCfg();
|
|
1247
1257
|
if (!cfg.host || !cfg.user || !cfg.pass) return { ok: false, error: 'e-posta ayarlanmamış' };
|
|
1248
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) };
|
|
1249
1264
|
const client = new ImapFlow({
|
|
1250
1265
|
host: cfg.host,
|
|
1251
1266
|
port: Number(cfg.port) || 993,
|
|
@@ -1257,11 +1272,12 @@ async function emailRead(uid) {
|
|
|
1257
1272
|
await client.connect();
|
|
1258
1273
|
const lock = await client.getMailboxLock('INBOX');
|
|
1259
1274
|
try {
|
|
1260
|
-
|
|
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 })) {
|
|
1261
1277
|
const raw = m.source.toString('utf8');
|
|
1262
1278
|
const bodyPart = raw.split(/\r?\n\r?\n/).slice(1).join('\n\n') || raw;
|
|
1263
1279
|
const text = htmlToText(bodyPart);
|
|
1264
|
-
return { ok: true, uid:
|
|
1280
|
+
return { ok: true, uid: u, content: String(text || '').slice(0, 8000) };
|
|
1265
1281
|
}
|
|
1266
1282
|
return { ok: false, error: 'mail bulunamadı' };
|
|
1267
1283
|
} finally {
|