commune-ai 0.2.5 → 0.2.6

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
@@ -234,6 +234,48 @@ interface SearchResult {
234
234
  }
235
235
  ```
236
236
 
237
+ ## Spam Protection
238
+ Commune includes built-in spam detection and protection to keep your agent safe from malicious emails and prevent abuse.
239
+
240
+ ### Automatic Spam Detection
241
+ All incoming emails are automatically analyzed for spam patterns:
242
+ - Content analysis (spam keywords, suspicious patterns)
243
+ - URL validation (broken links, phishing detection)
244
+ - Sender reputation tracking
245
+ - Domain blacklist checking
246
+
247
+ Spam emails are automatically rejected before reaching your webhook, protecting your agent from:
248
+ - Phishing attempts
249
+ - Malicious links
250
+ - Mass spam campaigns
251
+ - Fraudulent content
252
+
253
+ ### Outbound Protection
254
+ Commune also protects your sending reputation:
255
+ - Rate limiting per organization tier
256
+ - Content validation for outbound emails
257
+ - Burst detection for mass mailing
258
+ - Automatic blocking of spam-like content
259
+
260
+ This ensures your domain maintains high deliverability and isn't flagged by email providers.
261
+
262
+ ### Spam Reporting
263
+ If a spam email gets through, you can report it:
264
+
265
+ ```ts
266
+ import { CommuneClient } from "@commune/sdk";
267
+ const client = new CommuneClient({ apiKey: process.env.COMMUNE_API_KEY! });
268
+
269
+ // Report a message as spam
270
+ await client.reportSpam({
271
+ message_id: "msg_123",
272
+ reason: "Unsolicited marketing email",
273
+ classification: "spam" // or "phishing", "malware", "other"
274
+ });
275
+ ```
276
+
277
+ The system learns from reports and automatically blocks repeat offenders.
278
+
237
279
  ## Context (conversation state)
238
280
  Commune stores conversation state so your agent can respond with context.
239
281
 
package/dist/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import type { AttachmentRecord, CreateDomainPayload, DomainEntry, InboxEntry, MessageListParams, SendMessagePayload, UnifiedMessage, SearchFilter, SearchOptions, SearchResult, IndexConversationPayload } from './types.js';
1
+ import type { AttachmentRecord, AttachmentUrl, CreateDomainPayload, DomainEntry, InboxEntry, MessageListParams, SendMessagePayload, UnifiedMessage, SearchFilter, SearchOptions, SearchResult, IndexConversationPayload } from './types.js';
2
2
  export type ClientOptions = {
3
3
  baseUrl?: string;
4
4
  apiKey: string;
@@ -72,6 +72,9 @@ export declare class CommuneClient {
72
72
  }>;
73
73
  };
74
74
  attachments: {
75
- get: (attachmentId: string) => Promise<AttachmentRecord>;
75
+ get: (attachmentId: string, options?: {
76
+ url?: boolean;
77
+ expiresIn?: number;
78
+ }) => Promise<AttachmentRecord | AttachmentUrl>;
76
79
  };
77
80
  }
package/dist/client.js CHANGED
@@ -128,7 +128,11 @@ export class CommuneClient {
128
128
  },
129
129
  };
130
130
  this.attachments = {
131
- get: async (attachmentId) => {
131
+ get: async (attachmentId, options) => {
132
+ if (options?.url) {
133
+ const expiresIn = options.expiresIn || 3600;
134
+ return this.request(`/api/attachments/${encodeURIComponent(attachmentId)}/url?expiresIn=${expiresIn}`);
135
+ }
132
136
  return this.request(`/api/attachments/${encodeURIComponent(attachmentId)}`);
133
137
  },
134
138
  };
package/dist/types.d.ts CHANGED
@@ -42,6 +42,22 @@ export interface AttachmentRecord {
42
42
  source: Channel;
43
43
  source_url?: string | null;
44
44
  download_error?: boolean;
45
+ storage_type?: 'cloudinary' | 'database';
46
+ cloudinary_url?: string | null;
47
+ cloudinary_public_id?: string | null;
48
+ }
49
+ export interface AttachmentMetadata {
50
+ attachment_id: string;
51
+ filename: string;
52
+ mime_type: string;
53
+ size: number;
54
+ }
55
+ export interface AttachmentUrl {
56
+ url: string;
57
+ expiresIn: number;
58
+ filename: string;
59
+ mimeType: string;
60
+ size: number;
45
61
  }
46
62
  export interface DomainWebhook {
47
63
  id?: string;
@@ -142,6 +158,7 @@ export interface InboundEmailWebhookPayload {
142
158
  email: unknown;
143
159
  message: UnifiedMessage;
144
160
  extractedData?: Record<string, any>;
161
+ attachments?: AttachmentMetadata[];
145
162
  }
146
163
  export interface ApiError {
147
164
  message?: string;
@@ -175,6 +192,9 @@ export interface SearchResult {
175
192
  participants: string[];
176
193
  threadId: string;
177
194
  timestamp: Date;
195
+ attachmentIds?: string[];
196
+ hasAttachments?: boolean;
197
+ attachmentCount?: number;
178
198
  };
179
199
  }
180
200
  export interface ConversationMetadata {
@@ -185,6 +205,9 @@ export interface ConversationMetadata {
185
205
  participants: string[];
186
206
  threadId: string;
187
207
  timestamp: Date;
208
+ attachmentIds?: string[];
209
+ hasAttachments?: boolean;
210
+ attachmentCount?: number;
188
211
  }
189
212
  export interface IndexConversationPayload {
190
213
  id: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "commune-ai",
3
- "version": "0.2.5",
3
+ "version": "0.2.6",
4
4
  "description": "Our email infrastructure - webhooks, threads, history, and semantic search",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",