@agenticmail/api 0.9.12 → 0.9.14

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
@@ -540,6 +540,23 @@ function createAccountRoutes(accountManager, db, config) {
540
540
  next(err);
541
541
  }
542
542
  });
543
+ router.patch("/accounts/:id/role", requireMaster, async (req, res, next) => {
544
+ try {
545
+ const role = req.body?.role;
546
+ if (typeof role !== "string" || !AGENT_ROLES.includes(role)) {
547
+ res.status(400).json({ error: `Invalid role. Must be one of: ${AGENT_ROLES.join(", ")}` });
548
+ return;
549
+ }
550
+ const updated = await accountManager.updateRole(req.params.id, role);
551
+ if (!updated) {
552
+ res.status(404).json({ error: "Agent not found" });
553
+ return;
554
+ }
555
+ res.json(sanitizeAgent(updated));
556
+ } catch (err) {
557
+ next(err);
558
+ }
559
+ });
543
560
  router.delete("/accounts/:id", requireMaster, async (req, res, next) => {
544
561
  try {
545
562
  const allAgents = await accountManager.list();
@@ -1546,12 +1563,27 @@ function createEventRoutes(accountManager, config, db) {
1546
1563
  } catch {
1547
1564
  }
1548
1565
  if (spamResult.isSpam) {
1566
+ let spamFolder = "Spam";
1549
1567
  try {
1550
- await receiver.createFolder("Spam");
1568
+ const folders = await receiver.listFolders();
1569
+ const junkRe = /^junk\b|junk mail|^spam\b|\[gmail\]\/spam/i;
1570
+ const existing = folders.find((f) => f.specialUse === "\\Junk")?.path ?? folders.find((f) => junkRe.test(f.name) || junkRe.test(f.path))?.path;
1571
+ if (existing) {
1572
+ spamFolder = existing;
1573
+ } else {
1574
+ try {
1575
+ await receiver.createFolder("Spam");
1576
+ } catch {
1577
+ }
1578
+ }
1551
1579
  } catch {
1580
+ try {
1581
+ await receiver.createFolder("Spam");
1582
+ } catch {
1583
+ }
1552
1584
  }
1553
- await receiver.moveMessage(event.uid, "INBOX", "Spam");
1554
- event.spam = { score: spamResult.score, category: spamResult.topCategory, movedToSpam: true };
1585
+ await receiver.moveMessage(event.uid, "INBOX", spamFolder);
1586
+ event.spam = { score: spamResult.score, category: spamResult.topCategory, movedToSpam: true, folder: spamFolder };
1555
1587
  broadcastNew(event);
1556
1588
  return;
1557
1589
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/api",
3
- "version": "0.9.12",
3
+ "version": "0.9.14",
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",
@@ -28,7 +28,7 @@
28
28
  "prepublishOnly": "npm run build"
29
29
  },
30
30
  "dependencies": {
31
- "@agenticmail/core": "^0.9.2",
31
+ "@agenticmail/core": "^0.9.3",
32
32
  "cors": "^2.8.5",
33
33
  "dotenv": "^16.4.7",
34
34
  "express": "^4.21.0",
Binary file