@agenticmail/api 0.9.10 → 0.9.11

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/dist/index.js CHANGED
@@ -2572,19 +2572,22 @@ function createMailRoutes(accountManager, config, db, gatewayManager) {
2572
2572
  router.post("/mail/batch/move", requireAgent, async (req, res, next) => {
2573
2573
  try {
2574
2574
  const agent = req.agent;
2575
- const { uids: rawUids, from: fromFolder, to: toFolder } = req.body || {};
2576
- const uids = validateUids(rawUids);
2575
+ const body = req.body || {};
2576
+ const uids = validateUids(body.uids);
2577
2577
  if (!uids) {
2578
2578
  res.status(400).json({ error: "uids must be a non-empty array of positive integers (max 1000)" });
2579
2579
  return;
2580
2580
  }
2581
+ const fromFolder = body.from ?? body.folder;
2582
+ const toFolder = body.to ?? body.toFolder;
2581
2583
  if (!toFolder) {
2582
- res.status(400).json({ error: "to (destination folder) is required" });
2584
+ res.status(400).json({ error: "destination folder is required (pass as `to` or `toFolder`)" });
2583
2585
  return;
2584
2586
  }
2585
2587
  const password = getAgentPassword(agent);
2586
2588
  const receiver = await getReceiver(agent.stalwartPrincipal, password, config);
2587
2589
  await receiver.batchMove(uids, fromFolder || "INBOX", toFolder);
2590
+ for (const uid of uids) invalidateParsedMessage(agent.id, uid);
2588
2591
  res.json({ ok: true, moved: uids.length });
2589
2592
  } catch (err) {
2590
2593
  next(err);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/api",
3
- "version": "0.9.10",
3
+ "version": "0.9.11",
4
4
  "description": "REST API server for AgenticMail — email and SMS endpoints for AI agents",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
@@ -157,7 +157,18 @@ export async function loadList(agent, folder) {
157
157
  // side flag filter (Gmail convention); other folders need a real
158
158
  // mailbox name from the discovery cache.
159
159
  const isStarred = folder === 'starred';
160
- const imap = isStarred ? 'INBOX' : imapNameFor(folder);
160
+ let imap = isStarred ? 'INBOX' : imapNameFor(folder);
161
+ if (!imap) {
162
+ // The cache was populated at agent-switch time; some folders are
163
+ // created LATER on demand (the API auto-creates Archive on first
164
+ // archive, Spam on first report-as-spam). If we don't see the
165
+ // requested folder in the cache, force a fresh discovery once
166
+ // before declaring "no such folder" — covers the "moved to
167
+ // Archive but Archive tab is empty" report.
168
+ state.folderNames = {};
169
+ await ensureFolderCache(agent);
170
+ imap = imapNameFor(folder);
171
+ }
161
172
  if (!imap) {
162
173
  document.getElementById('list-rows').innerHTML =
163
174
  `<div class="empty"><div class="big">📭</div>No ${escapeHtml(folderTitle(folder))} folder on this server.</div>`;