@agenticmail/api 0.5.53 → 0.5.56

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/README.md CHANGED
@@ -104,9 +104,11 @@ When a new email lands in an agent's inbox, the system does several things in re
104
104
 
105
105
  2. **Spam scoring** — external emails are scored. If the score exceeds the spam threshold, the email is automatically moved to the Spam folder and the notification event includes spam details. If it's a warning (elevated but not spam), the event includes the warning info but the email stays in the inbox.
106
106
 
107
- 3. **Rule evaluation** — after spam filtering, the system checks the agent's custom email rules. Rules are checked in priority order and the first match wins. A rule can auto-mark the email as read, delete it, or move it to a specific folder.
107
+ 3. **Route classification** — the event is tagged with a route class such as `ignore_spam`, `ignore_newsletter`, `archive_automated`, `project_update`, `deal_escalation`, or `agent_instruction`. The route also includes the suggested action and whether a human gate is required.
108
108
 
109
- 4. **Notification sent** — the event is pushed to all of the agent's connected SSE streams.
109
+ 4. **Rule evaluation** — after spam filtering, the system checks the agent's custom email rules. Rules are checked in priority order and the first match wins. A rule can auto-mark the email as read, delete it, or move it to a specific folder.
110
+
111
+ 5. **Notification sent** — the event is pushed to all of the agent's connected SSE streams.
110
112
 
111
113
  ### Connection limits
112
114
 
package/dist/index.js CHANGED
@@ -1492,7 +1492,8 @@ import {
1492
1492
  MailReceiver as MailReceiver2,
1493
1493
  parseEmail as parseEmail3,
1494
1494
  scoreEmail as scoreEmail2,
1495
- isInternalEmail as isInternalEmail2
1495
+ isInternalEmail as isInternalEmail2,
1496
+ classifyEmailRoute
1496
1497
  } from "@agenticmail/core";
1497
1498
  import { v4 as uuidv42 } from "uuid";
1498
1499
 
@@ -2253,9 +2254,21 @@ function createEventRoutes(accountManager, config, db) {
2253
2254
  try {
2254
2255
  const raw = await receiver.fetchMessage(event.uid);
2255
2256
  const parsed = await parseEmail3(raw);
2257
+ const policyMetadata = agent.metadata && typeof agent.metadata === "object" ? {
2258
+ emailRoutePolicy: agent.metadata.emailRoutePolicy,
2259
+ routePolicy: agent.metadata.routePolicy,
2260
+ mailboxPolicy: agent.metadata.mailboxPolicy
2261
+ } : void 0;
2262
+ const accountRouteContext = {
2263
+ name: agent.name,
2264
+ email: agent.email,
2265
+ role: agent.role,
2266
+ metadata: policyMetadata
2267
+ };
2256
2268
  const isRelay = !!parsed.headers.get("x-agenticmail-relay");
2257
2269
  const internal = !isRelay && isInternalEmail2(parsed);
2258
2270
  if (internal) {
2271
+ event.route = classifyEmailRoute({ email: parsed, account: accountRouteContext });
2259
2272
  const ruleResult2 = evaluateRules(db, agent.id, parsed);
2260
2273
  if (ruleResult2) {
2261
2274
  const actions = ruleResult2.actions;
@@ -2273,6 +2286,7 @@ function createEventRoutes(accountManager, config, db) {
2273
2286
  return;
2274
2287
  }
2275
2288
  const spamResult = scoreEmail2(parsed);
2289
+ event.route = classifyEmailRoute({ email: parsed, spam: spamResult, account: accountRouteContext });
2276
2290
  try {
2277
2291
  db.prepare(
2278
2292
  "INSERT INTO spam_log (id, agent_id, message_uid, score, flags, category, is_spam) VALUES (?, ?, ?, ?, ?, ?, ?)"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/api",
3
- "version": "0.5.53",
3
+ "version": "0.5.56",
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",