beast-agent 0.23.3 → 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/main.js +15 -4
package/package.json
CHANGED
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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:
|
|
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 {
|