@framers/agentos-ext-channel-email 0.3.0 → 0.4.2

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.
Files changed (48) hide show
  1. package/README.md +70 -5
  2. package/dist/EmailChannelAdapter.d.ts +3 -1
  3. package/dist/EmailChannelAdapter.d.ts.map +1 -1
  4. package/dist/EmailChannelAdapter.js +3 -1
  5. package/dist/EmailChannelAdapter.js.map +1 -1
  6. package/dist/EmailService.d.ts +48 -16
  7. package/dist/EmailService.d.ts.map +1 -1
  8. package/dist/EmailService.js +130 -67
  9. package/dist/EmailService.js.map +1 -1
  10. package/dist/ResendTransport.d.ts +5 -2
  11. package/dist/ResendTransport.d.ts.map +1 -1
  12. package/dist/ResendTransport.js.map +1 -1
  13. package/dist/index.d.ts +5 -1
  14. package/dist/index.d.ts.map +1 -1
  15. package/dist/index.js +12 -2
  16. package/dist/index.js.map +1 -1
  17. package/dist/messageHeaders.d.ts +50 -10
  18. package/dist/messageHeaders.d.ts.map +1 -1
  19. package/dist/messageHeaders.js +175 -15
  20. package/dist/messageHeaders.js.map +1 -1
  21. package/dist/messageText.d.ts +9 -1
  22. package/dist/messageText.d.ts.map +1 -1
  23. package/dist/messageText.js +17 -1
  24. package/dist/messageText.js.map +1 -1
  25. package/dist/preferences/RecipientCapability.d.ts +100 -0
  26. package/dist/preferences/RecipientCapability.d.ts.map +1 -0
  27. package/dist/preferences/RecipientCapability.js +168 -0
  28. package/dist/preferences/RecipientCapability.js.map +1 -0
  29. package/dist/preferences/SuppressionStore.d.ts +72 -0
  30. package/dist/preferences/SuppressionStore.d.ts.map +1 -0
  31. package/dist/preferences/SuppressionStore.js +91 -0
  32. package/dist/preferences/SuppressionStore.js.map +1 -0
  33. package/dist/preferences/database.d.ts +34 -0
  34. package/dist/preferences/database.d.ts.map +1 -0
  35. package/dist/preferences/database.js +41 -0
  36. package/dist/preferences/database.js.map +1 -0
  37. package/dist/preferences/index.d.ts +15 -0
  38. package/dist/preferences/index.d.ts.map +1 -0
  39. package/dist/preferences/index.js +30 -0
  40. package/dist/preferences/index.js.map +1 -0
  41. package/dist/tools/extractCodes.js +1 -1
  42. package/dist/tools/extractCodes.js.map +1 -1
  43. package/dist/tools/reply.d.ts +2 -1
  44. package/dist/tools/reply.d.ts.map +1 -1
  45. package/dist/tools/reply.js +3 -2
  46. package/dist/tools/reply.js.map +1 -1
  47. package/manifest.json +4 -3
  48. package/package.json +3 -2
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.recipientCapabilityDdl = exports.SqlRecipientCapability = exports.suppressionStoreDdl = exports.SqlSuppressionStore = exports.SUPPRESSION_REASONS = exports.DEFAULT_SUPPRESSION_SCOPE = void 0;
4
+ exports.emailPreferencesDdl = emailPreferencesDdl;
5
+ /**
6
+ * @fileoverview The email pack's preference stores: the suppression record and recipient capabilities, each on a
7
+ * host's SQL database under a table prefix.
8
+ */
9
+ const RecipientCapability_js_1 = require("./RecipientCapability.js");
10
+ const SuppressionStore_js_1 = require("./SuppressionStore.js");
11
+ var SuppressionStore_js_2 = require("./SuppressionStore.js");
12
+ Object.defineProperty(exports, "DEFAULT_SUPPRESSION_SCOPE", { enumerable: true, get: function () { return SuppressionStore_js_2.DEFAULT_SUPPRESSION_SCOPE; } });
13
+ Object.defineProperty(exports, "SUPPRESSION_REASONS", { enumerable: true, get: function () { return SuppressionStore_js_2.SUPPRESSION_REASONS; } });
14
+ Object.defineProperty(exports, "SqlSuppressionStore", { enumerable: true, get: function () { return SuppressionStore_js_2.SqlSuppressionStore; } });
15
+ Object.defineProperty(exports, "suppressionStoreDdl", { enumerable: true, get: function () { return SuppressionStore_js_2.suppressionStoreDdl; } });
16
+ var RecipientCapability_js_2 = require("./RecipientCapability.js");
17
+ Object.defineProperty(exports, "SqlRecipientCapability", { enumerable: true, get: function () { return RecipientCapability_js_2.SqlRecipientCapability; } });
18
+ Object.defineProperty(exports, "recipientCapabilityDdl", { enumerable: true, get: function () { return RecipientCapability_js_2.recipientCapabilityDdl; } });
19
+ /**
20
+ * Both tables' DDL under one prefix, the suppression record's then the recipient capabilities', for a host whose one
21
+ * migration makes both. A host whose tables come from different migrations runs `suppressionStoreDdl` and
22
+ * `recipientCapabilityDdl` where each belongs.
23
+ *
24
+ * @param prefix A lower-case letter followed by at most 39 lower-case letters, digits or underscores.
25
+ * @throws RangeError when the prefix does not fit.
26
+ */
27
+ function emailPreferencesDdl(prefix) {
28
+ return `${(0, SuppressionStore_js_1.suppressionStoreDdl)(prefix)}\n${(0, RecipientCapability_js_1.recipientCapabilityDdl)(prefix)}`;
29
+ }
30
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/preferences/index.ts"],"names":[],"mappings":";;;AA0BA,kDAEC;AA5BD;;;GAGG;AACH,qEAAkE;AAClE,+DAA4D;AAG5D,6DAAiI;AAAxH,gIAAA,yBAAyB,OAAA;AAAE,0HAAA,mBAAmB,OAAA;AAAE,0HAAA,mBAAmB,OAAA;AAAE,0HAAA,mBAAmB,OAAA;AAEjG,mEAA0F;AAAjF,gIAAA,sBAAsB,OAAA;AAAE,gIAAA,sBAAsB,OAAA;AAQvD;;;;;;;GAOG;AACH,SAAgB,mBAAmB,CAAC,MAAc;IAChD,OAAO,GAAG,IAAA,yCAAmB,EAAC,MAAM,CAAC,KAAK,IAAA,+CAAsB,EAAC,MAAM,CAAC,EAAE,CAAC;AAC7E,CAAC"}
@@ -14,7 +14,7 @@ class EmailExtractCodesTool {
14
14
  this.inputSchema = {
15
15
  type: 'object',
16
16
  properties: {
17
- messageId: { type: 'string', description: 'Message ID of the email to extract codes from' },
17
+ messageId: { type: 'string', description: 'Message ID of the email to extract codes from, as emailRead or emailSearch gives it, such as <id@example.com>' },
18
18
  pattern: { type: 'string', description: 'Optional regex pattern to match codes (default: 4-8 digit numbers)' },
19
19
  },
20
20
  required: ['messageId'],
@@ -1 +1 @@
1
- {"version":3,"file":"extractCodes.js","sourceRoot":"","sources":["../../src/tools/extractCodes.ts"],"names":[],"mappings":";;;AAGA,MAAa,qBAAqB;IAkBhC,YAAoB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QAjBhC,OAAE,GAAG,mBAAmB,CAAC;QACzB,SAAI,GAAG,mBAAmB,CAAC;QAC3B,gBAAW,GAAG,4BAA4B,CAAC;QAC3C,gBAAW,GAAG,+EAA+E,CAAC;QAC9F,aAAQ,GAAG,eAAe,CAAC;QAC3B,YAAO,GAAG,OAAO,CAAC;QAClB,mBAAc,GAAG,KAAK,CAAC;QAEvB,gBAAW,GAAG;YACrB,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+CAA+C,EAAE;gBAC3F,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oEAAoE,EAAE;aAC/G;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB,CAAC;IAE0C,CAAC;IAE7C,KAAK,CAAC,OAAO,CAAC,IAGb;QACC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACzC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AA/BD,sDA+BC"}
1
+ {"version":3,"file":"extractCodes.js","sourceRoot":"","sources":["../../src/tools/extractCodes.ts"],"names":[],"mappings":";;;AAGA,MAAa,qBAAqB;IAkBhC,YAAoB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QAjBhC,OAAE,GAAG,mBAAmB,CAAC;QACzB,SAAI,GAAG,mBAAmB,CAAC;QAC3B,gBAAW,GAAG,4BAA4B,CAAC;QAC3C,gBAAW,GAAG,+EAA+E,CAAC;QAC9F,aAAQ,GAAG,eAAe,CAAC;QAC3B,YAAO,GAAG,OAAO,CAAC;QAClB,mBAAc,GAAG,KAAK,CAAC;QAEvB,gBAAW,GAAG;YACrB,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,+GAA+G,EAAE;gBAC3J,OAAO,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,oEAAoE,EAAE;aAC/G;YACD,QAAQ,EAAE,CAAC,WAAW,CAAC;SACxB,CAAC;IAE0C,CAAC;IAE7C,KAAK,CAAC,OAAO,CAAC,IAGb;QACC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YAC7E,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACzC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AA/BD,sDA+BC"}
@@ -30,7 +30,8 @@ export declare class EmailReplyTool {
30
30
  /**
31
31
  * Sends the reply through `EmailService.replyToEmail`. A `messageId` or `body` that is not a string, or an `html`
32
32
  * that is given and is not one, is refused before the original is read or anything is sent, with
33
- * `{ success: false, error }` naming the field.
33
+ * `{ success: false, error }` naming the field. A `messageId` that is not one message id, or that no message in the
34
+ * inbox has, is answered the same way before anything is sent, with an error that holds none of it.
34
35
  */
35
36
  execute(args: {
36
37
  messageId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../src/tools/reply.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,cAAc;IAmBb,OAAO,CAAC,OAAO;IAlB3B,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,WAAW,oBAAoB;IACxC,QAAQ,CAAC,WAAW,gHAAgH;IACpI,QAAQ,CAAC,QAAQ,mBAAmB;IACpC,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,cAAc,QAAQ;IAE/B,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;MAQlB;gBAEkB,OAAO,EAAE,YAAY;IAEzC;;;;OAIG;IACG,OAAO,CAAC,IAAI,EAAE;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAQ9D"}
1
+ {"version":3,"file":"reply.d.ts","sourceRoot":"","sources":["../../src/tools/reply.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEvD,qBAAa,cAAc;IAmBb,OAAO,CAAC,OAAO;IAlB3B,QAAQ,CAAC,EAAE,gBAAgB;IAC3B,QAAQ,CAAC,IAAI,gBAAgB;IAC7B,QAAQ,CAAC,WAAW,oBAAoB;IACxC,QAAQ,CAAC,WAAW,gHAAgH;IACpI,QAAQ,CAAC,QAAQ,mBAAmB;IACpC,QAAQ,CAAC,OAAO,WAAW;IAC3B,QAAQ,CAAC,cAAc,QAAQ;IAE/B,QAAQ,CAAC,WAAW;;;;;;;;;;;;;;;;;MAQlB;gBAEkB,OAAO,EAAE,YAAY;IAEzC;;;;;OAKG;IACG,OAAO,CAAC,IAAI,EAAE;QAClB,SAAS,EAAE,MAAM,CAAC;QAClB,IAAI,EAAE,MAAM,CAAC;QACb,IAAI,CAAC,EAAE,MAAM,CAAC;KACf,GAAG,OAAO,CAAC;QAAE,OAAO,EAAE,OAAO,CAAC;QAAC,IAAI,CAAC,EAAE,GAAG,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAQ9D"}
@@ -14,7 +14,7 @@ class EmailReplyTool {
14
14
  this.inputSchema = {
15
15
  type: 'object',
16
16
  properties: {
17
- messageId: { type: 'string', description: 'Message ID of the email to reply to' },
17
+ messageId: { type: 'string', description: 'Message ID of the email to reply to, as emailRead or emailSearch gives it, such as <id@example.com>' },
18
18
  body: { type: 'string', description: 'Plain text reply body' },
19
19
  html: { type: 'string', description: 'Optional HTML reply body' },
20
20
  },
@@ -24,7 +24,8 @@ class EmailReplyTool {
24
24
  /**
25
25
  * Sends the reply through `EmailService.replyToEmail`. A `messageId` or `body` that is not a string, or an `html`
26
26
  * that is given and is not one, is refused before the original is read or anything is sent, with
27
- * `{ success: false, error }` naming the field.
27
+ * `{ success: false, error }` naming the field. A `messageId` that is not one message id, or that no message in the
28
+ * inbox has, is answered the same way before anything is sent, with an error that holds none of it.
28
29
  */
29
30
  async execute(args) {
30
31
  try {
@@ -1 +1 @@
1
- {"version":3,"file":"reply.js","sourceRoot":"","sources":["../../src/tools/reply.ts"],"names":[],"mappings":";;;AAGA,MAAa,cAAc;IAmBzB,YAAoB,OAAqB;QAArB,YAAO,GAAP,OAAO,CAAc;QAlBhC,OAAE,GAAG,YAAY,CAAC;QAClB,SAAI,GAAG,YAAY,CAAC;QACpB,gBAAW,GAAG,gBAAgB,CAAC;QAC/B,gBAAW,GAAG,4GAA4G,CAAC;QAC3H,aAAQ,GAAG,eAAe,CAAC;QAC3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mBAAc,GAAG,IAAI,CAAC;QAEtB,gBAAW,GAAG;YACrB,IAAI,EAAE,QAAiB;YACvB,UAAU,EAAE;gBACV,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,qGAAqG,EAAE;gBACjJ,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,uBAAuB,EAAE;gBAC9D,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,WAAW,EAAE,0BAA0B,EAAE;aAClE;YACD,QAAQ,EAAE,CAAC,WAAW,EAAE,MAAM,CAAC;SAChC,CAAC;IAE0C,CAAC;IAE7C;;;;;OAKG;IACH,KAAK,CAAC,OAAO,CAAC,IAIb;QACC,IAAI,CAAC;YACH,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;YACrF,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;QACzC,CAAC;QAAC,OAAO,GAAQ,EAAE,CAAC;YAClB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,CAAC,OAAO,EAAE,CAAC;QAChD,CAAC;IACH,CAAC;CACF;AAvCD,wCAuCC"}
package/manifest.json CHANGED
@@ -2,8 +2,8 @@
2
2
  "$schema": "https://agentos.sh/schemas/extension-manifest-v1.json",
3
3
  "id": "com.framers.channels.email",
4
4
  "name": "Email Channel Extension",
5
- "version": "0.3.0",
6
- "description": "Bidirectional email integration: send through SMTP or Resend's HTTPS API, and read, search, extract verification codes and reply through IMAP.",
5
+ "version": "0.4.2",
6
+ "description": "Bidirectional email integration: send through SMTP or Resend's HTTPS API; read, search, extract verification codes and reply through IMAP; keep a suppression record and unsubscribe tokens on a SQL database.",
7
7
  "categories": ["channel", "communication"],
8
8
  "platforms": ["email"],
9
9
  "sdk": "nodemailer",
@@ -22,6 +22,7 @@
22
22
  "Read inbox and other IMAP folders",
23
23
  "Search emails by query, folder, and date range",
24
24
  "Extract verification codes and OTPs from email bodies",
25
- "Reply to email threads maintaining conversation context"
25
+ "Reply to email threads maintaining conversation context",
26
+ "Keep a suppression record and opaque unsubscribe tokens, stored as hashes, on a SQL database"
26
27
  ]
27
28
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@framers/agentos-ext-channel-email",
3
- "version": "0.3.0",
4
- "description": "Email channel adapter for AgentOS: send through SMTP or Resend's HTTPS API, and read, search, extract codes and reply through IMAP.",
3
+ "version": "0.4.2",
4
+ "description": "Email channel adapter for AgentOS: send through SMTP or Resend's HTTPS API; read, search, extract codes and reply through IMAP; keep a suppression record and unsubscribe tokens on a SQL database.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "license": "Apache-2.0",
@@ -22,6 +22,7 @@
22
22
  "nodemailer": "^10.0.16"
23
23
  },
24
24
  "devDependencies": {
25
+ "@framers/sql-storage-adapter": "^0.6.14",
25
26
  "@types/node": "^20.0.0",
26
27
  "typescript": "^5.0.0",
27
28
  "vitest": "^3.2.7",