commune-ai 0.2.65 → 0.2.66
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 +5 -22
- package/dist/client.d.ts +8 -1
- package/dist/client.js +28 -0
- package/dist/index.d.ts +1 -1
- package/dist/types.d.ts +24 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -1,27 +1,10 @@
|
|
|
1
1
|
# commune-ai
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Agents are powerful, but users already live in **email**. Commune bridges that gap so:
|
|
9
|
-
- your agent is reachable where humans already work
|
|
10
|
-
- you don’t have to build deliverability, threading, or email plumbing
|
|
11
|
-
- you can ship an agent‑first experience in minutes, not weeks
|
|
12
|
-
|
|
13
|
-
In practice, Commune lets you:
|
|
14
|
-
- give an agent a real inbox on your domain
|
|
15
|
-
- respond in the correct email thread every time
|
|
16
|
-
- use **conversation state** to make smarter, context‑aware replies
|
|
17
|
-
|
|
18
|
-
## How it works (mental model)
|
|
19
|
-
1) Commune receives inbound email events.
|
|
20
|
-
2) Commune normalizes them into a **UnifiedMessage**.
|
|
21
|
-
3) Commune sends the UnifiedMessage to your webhook.
|
|
22
|
-
4) Your agent replies using one API call.
|
|
23
|
-
|
|
24
|
-
> By default, the SDK talks to the hosted Commune API. If you self‑host,\n> pass `baseUrl` to the client.
|
|
3
|
+
Email infrastructure for agents — set up an inbox and send your first email in 30 seconds. Programmatic inboxes (~1 line), consistent threads, setup and verify custom domains, send and receive attachments, structured data extraction.
|
|
4
|
+
|
|
5
|
+
```bash
|
|
6
|
+
npm install commune-ai
|
|
7
|
+
```
|
|
25
8
|
|
|
26
9
|
---
|
|
27
10
|
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { AttachmentRecord, AttachmentUrl, AttachmentUploadResponse, CreateDomainPayload, DomainEntry, InboxEntry, MessageListParams, SendMessagePayload, UnifiedMessage, SearchFilter, SearchOptions, SearchResult, IndexConversationPayload } from './types.js';
|
|
1
|
+
import type { AttachmentRecord, AttachmentUrl, AttachmentUploadResponse, CreateDomainPayload, DomainEntry, InboxEntry, MessageListParams, SendMessagePayload, UnifiedMessage, SearchFilter, SearchOptions, SearchResult, IndexConversationPayload, ThreadListParams, ThreadListResponse } from './types.js';
|
|
2
2
|
export type ClientOptions = {
|
|
3
3
|
baseUrl?: string;
|
|
4
4
|
apiKey: string;
|
|
@@ -71,6 +71,13 @@ export declare class CommuneClient {
|
|
|
71
71
|
success: boolean;
|
|
72
72
|
}>;
|
|
73
73
|
};
|
|
74
|
+
threads: {
|
|
75
|
+
list: (params: ThreadListParams) => Promise<ThreadListResponse>;
|
|
76
|
+
messages: (threadId: string, params?: {
|
|
77
|
+
limit?: number;
|
|
78
|
+
order?: "asc" | "desc";
|
|
79
|
+
}) => Promise<UnifiedMessage[]>;
|
|
80
|
+
};
|
|
74
81
|
attachments: {
|
|
75
82
|
upload: (content: string, filename: string, mimeType: string) => Promise<AttachmentUploadResponse>;
|
|
76
83
|
get: (attachmentId: string, options?: {
|
package/dist/client.js
CHANGED
|
@@ -127,6 +127,34 @@ export class CommuneClient {
|
|
|
127
127
|
});
|
|
128
128
|
},
|
|
129
129
|
};
|
|
130
|
+
this.threads = {
|
|
131
|
+
list: async (params) => {
|
|
132
|
+
const response = await this.fetcher(`${this.baseUrl}/v1/threads${buildQuery({
|
|
133
|
+
inbox_id: params.inbox_id,
|
|
134
|
+
domain_id: params.domain_id,
|
|
135
|
+
limit: params.limit,
|
|
136
|
+
cursor: params.cursor,
|
|
137
|
+
order: params.order,
|
|
138
|
+
})}`, {
|
|
139
|
+
headers: {
|
|
140
|
+
'Content-Type': 'application/json',
|
|
141
|
+
...(this.apiKey ? { Authorization: `Bearer ${this.apiKey}` } : {}),
|
|
142
|
+
...(this.headers || {}),
|
|
143
|
+
},
|
|
144
|
+
});
|
|
145
|
+
const data = await response.json();
|
|
146
|
+
if (!response.ok) {
|
|
147
|
+
throw new Error(data?.error || response.statusText);
|
|
148
|
+
}
|
|
149
|
+
return data;
|
|
150
|
+
},
|
|
151
|
+
messages: async (threadId, params) => {
|
|
152
|
+
return this.request(`/v1/threads/${encodeURIComponent(threadId)}/messages${buildQuery({
|
|
153
|
+
limit: params?.limit,
|
|
154
|
+
order: params?.order,
|
|
155
|
+
})}`);
|
|
156
|
+
},
|
|
157
|
+
};
|
|
130
158
|
this.attachments = {
|
|
131
159
|
upload: async (content, filename, mimeType) => {
|
|
132
160
|
return this.request('/api/attachments/upload', {
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { CommuneClient } from './client.js';
|
|
2
|
-
export type { ApiError, ApiResponse, AttachmentRecord, Channel, ConversationListParams, CreateDomainPayload, Direction, DomainEntry, DomainWebhook, InboxEntry, InboxWebhook, InboundEmailWebhookPayload, MessageListParams, MessageMetadata, Participant, ParticipantRole, SendMessagePayload, SvixHeaders, UnifiedMessage, } from './types.js';
|
|
2
|
+
export type { ApiError, ApiResponse, AttachmentRecord, Channel, ConversationListParams, CreateDomainPayload, Direction, DomainEntry, DomainWebhook, InboxEntry, InboxWebhook, InboundEmailWebhookPayload, MessageListParams, MessageMetadata, Participant, ParticipantRole, SendMessagePayload, SvixHeaders, Thread, ThreadListParams, ThreadListResponse, UnifiedMessage, } from './types.js';
|
|
3
3
|
export { verifyResendWebhook } from './webhooks.js';
|
|
4
4
|
export { createWebhookHandler } from './listener.js';
|
|
5
5
|
export type { CommuneWebhookEvent, CommuneWebhookHandlerContext, CreateWebhookHandlerOptions, } from './listener.js';
|
package/dist/types.d.ts
CHANGED
|
@@ -222,3 +222,27 @@ export interface IndexConversationPayload {
|
|
|
222
222
|
metadata: ConversationMetadata;
|
|
223
223
|
}
|
|
224
224
|
export type SearchType = 'vector' | 'agent';
|
|
225
|
+
export interface Thread {
|
|
226
|
+
thread_id: string;
|
|
227
|
+
subject?: string | null;
|
|
228
|
+
last_message_at: string;
|
|
229
|
+
first_message_at?: string | null;
|
|
230
|
+
message_count: number;
|
|
231
|
+
snippet?: string | null;
|
|
232
|
+
last_direction?: Direction | null;
|
|
233
|
+
inbox_id?: string | null;
|
|
234
|
+
domain_id?: string | null;
|
|
235
|
+
has_attachments?: boolean;
|
|
236
|
+
}
|
|
237
|
+
export interface ThreadListResponse {
|
|
238
|
+
data: Thread[];
|
|
239
|
+
next_cursor: string | null;
|
|
240
|
+
has_more: boolean;
|
|
241
|
+
}
|
|
242
|
+
export interface ThreadListParams {
|
|
243
|
+
inbox_id?: string;
|
|
244
|
+
domain_id?: string;
|
|
245
|
+
limit?: number;
|
|
246
|
+
cursor?: string;
|
|
247
|
+
order?: 'asc' | 'desc';
|
|
248
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "commune-ai",
|
|
3
|
-
"version": "0.2.
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "0.2.66",
|
|
4
|
+
"description": "Email infrastructure for agents — set up an inbox and send your first email in 30 seconds. Programmatic inboxes (~1 line), consistent threads, custom domains, attachments, and structured data.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|