@corsair-dev/agentmail 0.1.0
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/LICENSE +191 -0
- package/dist/api.test.d.ts +2 -0
- package/dist/api.test.d.ts.map +1 -0
- package/dist/cache-message.d.ts +27 -0
- package/dist/cache-message.d.ts.map +1 -0
- package/dist/client.d.ts +18 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/endpoints/index.d.ts +106 -0
- package/dist/endpoints/index.d.ts.map +1 -0
- package/dist/endpoints/messages.d.ts +5 -0
- package/dist/endpoints/messages.d.ts.map +1 -0
- package/dist/endpoints/types.d.ts +252 -0
- package/dist/endpoints/types.d.ts.map +1 -0
- package/dist/error-handlers.d.ts +22 -0
- package/dist/error-handlers.d.ts.map +1 -0
- package/dist/index.d.ts +226 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1 -0
- package/dist/schema/database.d.ts +18 -0
- package/dist/schema/database.d.ts.map +1 -0
- package/dist/schema/index.d.ts +22 -0
- package/dist/schema/index.d.ts.map +1 -0
- package/dist/schema.test.d.ts +2 -0
- package/dist/schema.test.d.ts.map +1 -0
- package/dist/tsup.config.d.ts +3 -0
- package/dist/tsup.config.d.ts.map +1 -0
- package/dist/webhooks/index.d.ts +140 -0
- package/dist/webhooks/index.d.ts.map +1 -0
- package/dist/webhooks/matcher.test.d.ts +2 -0
- package/dist/webhooks/matcher.test.d.ts.map +1 -0
- package/dist/webhooks/message.d.ts +3 -0
- package/dist/webhooks/message.d.ts.map +1 -0
- package/dist/webhooks/types.d.ts +83 -0
- package/dist/webhooks/types.d.ts.map +1 -0
- package/package.json +45 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import type { AuthTypes, BindEndpoints, BindWebhooks, CorsairEndpoint, CorsairErrorHandler, CorsairPlugin, CorsairPluginContext, CorsairWebhook, KeyBuilderContext, PickAuth, PluginPermissionsConfig } from 'corsair/core';
|
|
2
|
+
import type { AgentMailEndpointInputs, AgentMailEndpointOutputs } from './endpoints/types';
|
|
3
|
+
import { AgentMailSchema } from './schema';
|
|
4
|
+
import type { AgentMailWebhookOutputs, MessageReceivedEvent } from './webhooks';
|
|
5
|
+
export type AgentMailPluginOptions = {
|
|
6
|
+
authType?: PickAuth<'api_key'>;
|
|
7
|
+
key?: string;
|
|
8
|
+
webhookSecret?: string;
|
|
9
|
+
hooks?: InternalAgentMailPlugin['hooks'];
|
|
10
|
+
webhookHooks?: InternalAgentMailPlugin['webhookHooks'];
|
|
11
|
+
errorHandlers?: CorsairErrorHandler;
|
|
12
|
+
permissions?: PluginPermissionsConfig<typeof agentMailEndpointsNested>;
|
|
13
|
+
};
|
|
14
|
+
export type AgentMailContext = CorsairPluginContext<typeof AgentMailSchema, AgentMailPluginOptions>;
|
|
15
|
+
export type AgentMailKeyBuilderContext = KeyBuilderContext<AgentMailPluginOptions>;
|
|
16
|
+
export type AgentMailBoundEndpoints = BindEndpoints<typeof agentMailEndpointsNested>;
|
|
17
|
+
type AgentMailEndpoint<K extends keyof AgentMailEndpointOutputs> = CorsairEndpoint<AgentMailContext, AgentMailEndpointInputs[K], AgentMailEndpointOutputs[K]>;
|
|
18
|
+
export type AgentMailEndpoints = {
|
|
19
|
+
messagesList: AgentMailEndpoint<'messagesList'>;
|
|
20
|
+
messagesGet: AgentMailEndpoint<'messagesGet'>;
|
|
21
|
+
messagesSend: AgentMailEndpoint<'messagesSend'>;
|
|
22
|
+
};
|
|
23
|
+
type AgentMailWebhook<K extends keyof AgentMailWebhookOutputs, TEvent> = CorsairWebhook<AgentMailContext, TEvent, AgentMailWebhookOutputs[K]>;
|
|
24
|
+
export type AgentMailWebhooks = {
|
|
25
|
+
messageReceived: AgentMailWebhook<'messageReceived', MessageReceivedEvent>;
|
|
26
|
+
};
|
|
27
|
+
declare const agentMailEndpointsNested: {
|
|
28
|
+
readonly messages: {
|
|
29
|
+
readonly get: AgentMailEndpoint<"messagesGet">;
|
|
30
|
+
readonly list: AgentMailEndpoint<"messagesList">;
|
|
31
|
+
readonly send: AgentMailEndpoint<"messagesSend">;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
declare const agentMailWebhooksNested: {
|
|
35
|
+
readonly message: {
|
|
36
|
+
readonly received: AgentMailWebhook<"messageReceived", {
|
|
37
|
+
[x: string]: unknown;
|
|
38
|
+
type: "event";
|
|
39
|
+
event_id: string;
|
|
40
|
+
event_type: "message.received";
|
|
41
|
+
message: {
|
|
42
|
+
[x: string]: unknown;
|
|
43
|
+
inbox_id: string;
|
|
44
|
+
thread_id: string;
|
|
45
|
+
message_id: string;
|
|
46
|
+
labels: string[];
|
|
47
|
+
timestamp: string;
|
|
48
|
+
from: string;
|
|
49
|
+
to: string[];
|
|
50
|
+
size: number;
|
|
51
|
+
updated_at: string;
|
|
52
|
+
created_at: string;
|
|
53
|
+
reply_to?: string[] | undefined;
|
|
54
|
+
cc?: string[] | undefined;
|
|
55
|
+
bcc?: string[] | undefined;
|
|
56
|
+
subject?: string | undefined;
|
|
57
|
+
preview?: string | undefined;
|
|
58
|
+
text?: string | undefined;
|
|
59
|
+
html?: string | undefined;
|
|
60
|
+
extracted_text?: string | undefined;
|
|
61
|
+
extracted_html?: string | undefined;
|
|
62
|
+
attachments?: {
|
|
63
|
+
[x: string]: unknown;
|
|
64
|
+
attachment_id: string;
|
|
65
|
+
size: number;
|
|
66
|
+
filename?: string | undefined;
|
|
67
|
+
content_type?: string | undefined;
|
|
68
|
+
content_disposition?: string | undefined;
|
|
69
|
+
content_id?: string | undefined;
|
|
70
|
+
}[] | undefined;
|
|
71
|
+
in_reply_to?: string | undefined;
|
|
72
|
+
references?: string[] | undefined;
|
|
73
|
+
headers?: Record<string, string> | undefined;
|
|
74
|
+
};
|
|
75
|
+
thread: {
|
|
76
|
+
[x: string]: unknown;
|
|
77
|
+
inbox_id: string;
|
|
78
|
+
thread_id: string;
|
|
79
|
+
labels: string[];
|
|
80
|
+
timestamp: string;
|
|
81
|
+
senders: string[];
|
|
82
|
+
recipients: string[];
|
|
83
|
+
last_message_id: string;
|
|
84
|
+
message_count: number;
|
|
85
|
+
size: number;
|
|
86
|
+
updated_at: string;
|
|
87
|
+
created_at: string;
|
|
88
|
+
received_timestamp?: string | undefined;
|
|
89
|
+
sent_timestamp?: string | undefined;
|
|
90
|
+
subject?: string | undefined;
|
|
91
|
+
preview?: string | undefined;
|
|
92
|
+
attachments?: {
|
|
93
|
+
[x: string]: unknown;
|
|
94
|
+
attachment_id: string;
|
|
95
|
+
size: number;
|
|
96
|
+
filename?: string | undefined;
|
|
97
|
+
content_type?: string | undefined;
|
|
98
|
+
content_disposition?: string | undefined;
|
|
99
|
+
content_id?: string | undefined;
|
|
100
|
+
}[] | undefined;
|
|
101
|
+
};
|
|
102
|
+
}>;
|
|
103
|
+
};
|
|
104
|
+
};
|
|
105
|
+
export type AgentMailBoundWebhooks = BindWebhooks<typeof agentMailWebhooksNested>;
|
|
106
|
+
export declare const agentMailEndpointSchemas: {
|
|
107
|
+
readonly 'messages.list': {
|
|
108
|
+
readonly input: import("zod").ZodObject<{
|
|
109
|
+
inbox_id: import("zod").ZodString;
|
|
110
|
+
limit: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
111
|
+
page_token: import("zod").ZodOptional<import("zod").ZodString>;
|
|
112
|
+
labels: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
113
|
+
before: import("zod").ZodOptional<import("zod").ZodString>;
|
|
114
|
+
after: import("zod").ZodOptional<import("zod").ZodString>;
|
|
115
|
+
ascending: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
116
|
+
include_spam: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
117
|
+
include_blocked: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
118
|
+
include_unauthenticated: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
119
|
+
include_trash: import("zod").ZodOptional<import("zod").ZodBoolean>;
|
|
120
|
+
from: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
121
|
+
to: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
122
|
+
subject: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
123
|
+
}, import("zod/v4/core").$strip>;
|
|
124
|
+
readonly output: import("zod").ZodObject<{
|
|
125
|
+
count: import("zod").ZodNumber;
|
|
126
|
+
messages: import("zod").ZodArray<import("zod").ZodObject<{
|
|
127
|
+
inbox_id: import("zod").ZodString;
|
|
128
|
+
thread_id: import("zod").ZodString;
|
|
129
|
+
message_id: import("zod").ZodString;
|
|
130
|
+
labels: import("zod").ZodArray<import("zod").ZodString>;
|
|
131
|
+
timestamp: import("zod").ZodString;
|
|
132
|
+
from: import("zod").ZodString;
|
|
133
|
+
to: import("zod").ZodArray<import("zod").ZodString>;
|
|
134
|
+
size: import("zod").ZodNumber;
|
|
135
|
+
updated_at: import("zod").ZodString;
|
|
136
|
+
created_at: import("zod").ZodString;
|
|
137
|
+
cc: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
138
|
+
bcc: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
139
|
+
subject: import("zod").ZodOptional<import("zod").ZodString>;
|
|
140
|
+
preview: import("zod").ZodOptional<import("zod").ZodString>;
|
|
141
|
+
attachments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
142
|
+
attachment_id: import("zod").ZodString;
|
|
143
|
+
size: import("zod").ZodNumber;
|
|
144
|
+
filename: import("zod").ZodOptional<import("zod").ZodString>;
|
|
145
|
+
content_type: import("zod").ZodOptional<import("zod").ZodString>;
|
|
146
|
+
content_disposition: import("zod").ZodOptional<import("zod").ZodString>;
|
|
147
|
+
content_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
148
|
+
}, import("zod/v4/core").$loose>>>;
|
|
149
|
+
in_reply_to: import("zod").ZodOptional<import("zod").ZodString>;
|
|
150
|
+
references: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
151
|
+
headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
|
|
152
|
+
}, import("zod/v4/core").$loose>>;
|
|
153
|
+
limit: import("zod").ZodNumber;
|
|
154
|
+
next_page_token: import("zod").ZodOptional<import("zod").ZodNullable<import("zod").ZodString>>;
|
|
155
|
+
}, import("zod/v4/core").$strip>;
|
|
156
|
+
};
|
|
157
|
+
readonly 'messages.get': {
|
|
158
|
+
readonly input: import("zod").ZodObject<{
|
|
159
|
+
inbox_id: import("zod").ZodString;
|
|
160
|
+
message_id: import("zod").ZodString;
|
|
161
|
+
}, import("zod/v4/core").$strip>;
|
|
162
|
+
readonly output: import("zod").ZodObject<{
|
|
163
|
+
inbox_id: import("zod").ZodString;
|
|
164
|
+
thread_id: import("zod").ZodString;
|
|
165
|
+
message_id: import("zod").ZodString;
|
|
166
|
+
labels: import("zod").ZodArray<import("zod").ZodString>;
|
|
167
|
+
timestamp: import("zod").ZodString;
|
|
168
|
+
from: import("zod").ZodString;
|
|
169
|
+
to: import("zod").ZodArray<import("zod").ZodString>;
|
|
170
|
+
size: import("zod").ZodNumber;
|
|
171
|
+
updated_at: import("zod").ZodString;
|
|
172
|
+
created_at: import("zod").ZodString;
|
|
173
|
+
cc: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
174
|
+
bcc: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
175
|
+
subject: import("zod").ZodOptional<import("zod").ZodString>;
|
|
176
|
+
preview: import("zod").ZodOptional<import("zod").ZodString>;
|
|
177
|
+
attachments: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodObject<{
|
|
178
|
+
attachment_id: import("zod").ZodString;
|
|
179
|
+
size: import("zod").ZodNumber;
|
|
180
|
+
filename: import("zod").ZodOptional<import("zod").ZodString>;
|
|
181
|
+
content_type: import("zod").ZodOptional<import("zod").ZodString>;
|
|
182
|
+
content_disposition: import("zod").ZodOptional<import("zod").ZodString>;
|
|
183
|
+
content_id: import("zod").ZodOptional<import("zod").ZodString>;
|
|
184
|
+
}, import("zod/v4/core").$loose>>>;
|
|
185
|
+
in_reply_to: import("zod").ZodOptional<import("zod").ZodString>;
|
|
186
|
+
references: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
187
|
+
headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
|
|
188
|
+
reply_to: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
189
|
+
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
190
|
+
html: import("zod").ZodOptional<import("zod").ZodString>;
|
|
191
|
+
extracted_text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
192
|
+
extracted_html: import("zod").ZodOptional<import("zod").ZodString>;
|
|
193
|
+
}, import("zod/v4/core").$loose>;
|
|
194
|
+
};
|
|
195
|
+
readonly 'messages.send': {
|
|
196
|
+
readonly input: import("zod").ZodObject<{
|
|
197
|
+
inbox_id: import("zod").ZodString;
|
|
198
|
+
labels: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
199
|
+
reply_to: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
|
|
200
|
+
to: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
|
|
201
|
+
cc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
|
|
202
|
+
bcc: import("zod").ZodOptional<import("zod").ZodUnion<readonly [import("zod").ZodString, import("zod").ZodArray<import("zod").ZodString>]>>;
|
|
203
|
+
subject: import("zod").ZodOptional<import("zod").ZodString>;
|
|
204
|
+
text: import("zod").ZodOptional<import("zod").ZodString>;
|
|
205
|
+
html: import("zod").ZodOptional<import("zod").ZodString>;
|
|
206
|
+
headers: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodString>>;
|
|
207
|
+
}, import("zod/v4/core").$strip>;
|
|
208
|
+
readonly output: import("zod").ZodObject<{
|
|
209
|
+
message_id: import("zod").ZodString;
|
|
210
|
+
thread_id: import("zod").ZodString;
|
|
211
|
+
}, import("zod/v4/core").$loose>;
|
|
212
|
+
};
|
|
213
|
+
};
|
|
214
|
+
declare const defaultAuthType: AuthTypes;
|
|
215
|
+
export declare const agentMailAuthConfig: {
|
|
216
|
+
readonly api_key: {
|
|
217
|
+
readonly account: readonly ["one"];
|
|
218
|
+
};
|
|
219
|
+
};
|
|
220
|
+
export type BaseAgentMailPlugin<T extends AgentMailPluginOptions> = CorsairPlugin<'agentmail', typeof AgentMailSchema, typeof agentMailEndpointsNested, typeof agentMailWebhooksNested, T, typeof defaultAuthType>;
|
|
221
|
+
export type InternalAgentMailPlugin = BaseAgentMailPlugin<AgentMailPluginOptions>;
|
|
222
|
+
export type ExternalAgentMailPlugin<T extends AgentMailPluginOptions> = BaseAgentMailPlugin<T>;
|
|
223
|
+
export declare function agentmail<const T extends AgentMailPluginOptions>(incomingOptions?: AgentMailPluginOptions & T): ExternalAgentMailPlugin<T>;
|
|
224
|
+
export type { AgentMailEndpointInputs, AgentMailEndpointOutputs, AgentMailMessage, AgentMailMessageSummary, MessagesGetInput, MessagesGetResponse, MessagesListInput, MessagesListResponse, MessagesSendInput, MessagesSendResponse, } from './endpoints/types';
|
|
225
|
+
export type { AgentMailWebhookOutputs, AgentMailWebhookPayload, MessageReceivedEvent, } from './webhooks/types';
|
|
226
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"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"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{AuthMissingError as K}from"corsair/core";import{logEventFromContext as x}from"corsair/core";async function d(n,t){if(!n.db.messages)return"";try{let i={id:t.message_id,inbox_id:t.inbox_id,thread_id:t.thread_id,message_id:t.message_id,labels:t.labels,timestamp:t.timestamp,from:t.from,to:t.to,size:t.size,updated_at:t.updated_at,created_at:t.created_at,subject:t.subject,preview:t.preview};return(await n.db.messages.upsertByEntityId(t.message_id,i))?.id||""}catch(i){return console.warn("Failed to save AgentMail message to database:",i),""}}import{ApiError as R,request as $}from"corsair/http";var c=class extends Error{constructor(i,o,a){super(i,a);this.code=o;this.name="AgentMailAPIError",a?.cause instanceof R&&(this.status=a.cause.status,this.statusText=a.cause.statusText,this.body=a.cause.body,this.retryAfter=a.cause.retryAfter)}status;statusText;body;retryAfter},D="https://api.agentmail.to/v0",S={enabled:!0,maxRetries:3,initialRetryDelay:1e3,backoffMultiplier:2,headerNames:{retryAfter:"Retry-After"}};async function y(n,t,i={}){let{method:o="GET",body:a,query:g}=i,l=o==="POST"||o==="PUT"||o==="PATCH",u={BASE:D,VERSION:"v0",WITH_CREDENTIALS:!1,CREDENTIALS:"omit",HEADERS:{Authorization:`Bearer ${t}`,"Content-Type":"application/json"}},h={method:o,url:n,body:l?a:void 0,mediaType:"application/json; charset=utf-8",query:g};try{return await $(u,h,{rateLimitConfig:l?{...S,enabled:!1,maxRetries:0}:S})}catch(p){throw p instanceof R?new c(p.message,String(p.status),{cause:p}):p instanceof Error?new c(p.message,void 0,{cause:p}):new c("Unknown error")}}var w=async(n,t)=>{let{inbox_id:i,...o}=t,a=Object.fromEntries(Object.entries(o).filter(([,l])=>l!==void 0)),g=await y(`inboxes/${encodeURIComponent(i)}/messages/send`,n.key,{method:"POST",body:a});return await x(n,"agentmail.messages.send",{inbox_id:i,message_id:g.message_id,thread_id:g.thread_id},"completed"),g},C=async(n,t)=>{let i=await y(`inboxes/${encodeURIComponent(t.inbox_id)}/messages/${encodeURIComponent(t.message_id)}`,n.key,{method:"GET"});return await d(n,i),await x(n,"agentmail.messages.get",{inbox_id:t.inbox_id,message_id:t.message_id},"completed"),i},P=async(n,t)=>{let{inbox_id:i,...o}=t,a=await y(`inboxes/${encodeURIComponent(i)}/messages`,n.key,{method:"GET",query:o});for(let g of a.messages)await d(n,g);return await x(n,"agentmail.messages.list",{inbox_id:i,count:a.count,returned:a.messages.length},"completed"),a};import{z as e}from"zod";var F=e.object({inbox_id:e.string(),limit:e.number().int().optional(),page_token:e.string().optional(),labels:e.array(e.string()).optional(),before:e.string().optional(),after:e.string().optional(),ascending:e.boolean().optional(),include_spam:e.boolean().optional(),include_blocked:e.boolean().optional(),include_unauthenticated:e.boolean().optional(),include_trash:e.boolean().optional(),from:e.array(e.string()).optional(),to:e.array(e.string()).optional(),subject:e.array(e.string()).optional()}),V=e.object({inbox_id:e.string(),message_id:e.string()}),f=e.union([e.string(),e.array(e.string())]),Q=e.object({inbox_id:e.string(),labels:e.array(e.string()).optional(),reply_to:f.optional(),to:f.optional(),cc:f.optional(),bcc:f.optional(),subject:e.string().optional(),text:e.string().optional(),html:e.string().optional(),headers:e.record(e.string(),e.string()).optional()}),J=e.object({attachment_id:e.string(),size:e.number(),filename:e.string().optional(),content_type:e.string().optional(),content_disposition:e.string().optional(),content_id:e.string().optional()}).loose(),I=e.object({inbox_id:e.string(),thread_id:e.string(),message_id:e.string(),labels:e.array(e.string()),timestamp:e.string(),from:e.string(),to:e.array(e.string()),size:e.number(),updated_at:e.string(),created_at:e.string(),cc:e.array(e.string()).optional(),bcc:e.array(e.string()).optional(),subject:e.string().optional(),preview:e.string().optional(),attachments:e.array(J).optional(),in_reply_to:e.string().optional(),references:e.array(e.string()).optional(),headers:e.record(e.string(),e.string()).optional()}).loose(),X=I.extend({reply_to:e.array(e.string()).optional(),text:e.string().optional(),html:e.string().optional(),extracted_text:e.string().optional(),extracted_html:e.string().optional()}),Y=e.object({count:e.number(),messages:e.array(I),limit:e.number(),next_page_token:e.string().nullable().optional()}),Z=e.object({message_id:e.string(),thread_id:e.string()}).loose(),M={messagesList:F,messagesGet:V,messagesSend:Q},b={messagesList:Y,messagesGet:X,messagesSend:Z};var A={get:C,list:P,send:w};import{ApiError as _}from"corsair/http";var T={RATE_LIMIT_ERROR:{match:n=>{if(n instanceof _&&n.status===429)return!0;let t=n.message.toLowerCase();return t.includes("rate_limited")||t.includes("rate limit")},handler:async n=>{let t;return n instanceof _&&n.retryAfter!==void 0&&(t=n.retryAfter),{maxRetries:5,headersRetryAfterMs:t}}},AUTH_ERROR:{match:n=>{if(n instanceof _&&n.status===401)return!0;let t=n.message.toLowerCase();return t.includes("unauthorized")||t.includes("invalid_auth")},handler:async()=>({maxRetries:0})},DEFAULT:{match:()=>!0,handler:async()=>({maxRetries:0})}};import{z as r}from"zod";var W=r.object({id:r.string(),inbox_id:r.string(),thread_id:r.string(),message_id:r.string(),labels:r.array(r.string()),timestamp:r.string(),from:r.string(),to:r.array(r.string()),size:r.number(),updated_at:r.string(),created_at:r.string(),subject:r.string().optional(),preview:r.string().optional()});var L={version:"1.0.0",entities:{messages:W}};import{logEventFromContext as ie}from"corsair/core";import O from"crypto";import{z as s}from"zod";var j=s.object({attachment_id:s.string(),size:s.number(),filename:s.string().optional(),content_type:s.string().optional(),content_disposition:s.string().optional(),content_id:s.string().optional()}).loose(),ee=s.object({inbox_id:s.string(),thread_id:s.string(),message_id:s.string(),labels:s.array(s.string()),timestamp:s.string(),from:s.string(),to:s.array(s.string()),size:s.number(),updated_at:s.string(),created_at:s.string(),reply_to:s.array(s.string()).optional(),cc:s.array(s.string()).optional(),bcc:s.array(s.string()).optional(),subject:s.string().optional(),preview:s.string().optional(),text:s.string().optional(),html:s.string().optional(),extracted_text:s.string().optional(),extracted_html:s.string().optional(),attachments:s.array(j).optional(),in_reply_to:s.string().optional(),references:s.array(s.string()).optional(),headers:s.record(s.string(),s.string()).optional()}).loose(),te=s.object({inbox_id:s.string(),thread_id:s.string(),labels:s.array(s.string()),timestamp:s.string(),senders:s.array(s.string()),recipients:s.array(s.string()),last_message_id:s.string(),message_count:s.number(),size:s.number(),updated_at:s.string(),created_at:s.string(),received_timestamp:s.string().optional(),sent_timestamp:s.string().optional(),subject:s.string().optional(),preview:s.string().optional(),attachments:s.array(j).optional()}).loose(),se=s.object({type:s.literal("event"),event_type:s.string(),event_id:s.string()}).loose(),m=se.extend({event_type:s.literal("message.received"),message:ee,thread:te});function B(n){if(typeof n=="string")try{let t=JSON.parse(n);return t===null||typeof t!="object"||Array.isArray(t)?null:t}catch{return null}return n===null||typeof n!="object"||Array.isArray(n)?null:n}function G(n){return t=>{let i=B(t.body);return i!==null&&i.event_type===n}}function z(n){if(!Object.keys(n.headers).some(o=>o.toLowerCase()==="svix-signature"))return!1;let i=B(n.body);return i!==null&&i.type==="event"&&i.event_type==="message.received"}function k(n,t){let i=t.toLowerCase();for(let[o,a]of Object.entries(n))if(o.toLowerCase()===i)return Array.isArray(a)?a[0]:a}function ne(n){return n.split(" ").map(t=>t.trim()).filter(Boolean).flatMap(t=>{let[i,o]=t.split(",",2);return i==="v1"&&o?[o]:[]})}function N(n,t){if(!t)return{valid:!1,error:"Missing webhook secret"};let i=n.rawBody;if(!i)return{valid:!1,error:"Missing raw body for signature verification"};let o=k(n.headers,"svix-id"),a=k(n.headers,"svix-timestamp"),g=k(n.headers,"svix-signature");if(!o)return{valid:!1,error:"Missing svix-id header"};if(!a)return{valid:!1,error:"Missing svix-timestamp header"};if(!g)return{valid:!1,error:"Missing svix-signature header"};let l=Number.parseInt(a,10)*1e3;if(Number.isNaN(l)||Math.abs(Date.now()-l)>300*1e3)return{valid:!1,error:"Webhook timestamp is too old or invalid"};if(!t.startsWith("whsec_"))return{valid:!1,error:"Malformed webhook secret"};let u=t.slice(6);if(!u)return{valid:!1,error:"Malformed webhook secret"};let h=ne(g);if(h.length===0)return{valid:!1,error:"Malformed svix-signature header"};let p=`${o}.${a}.${i}`,v=O.createHmac("sha256",Buffer.from(u,"base64")).update(p).digest();return h.some(U=>{let E=Buffer.from(U,"base64");return E.length===v.length&&O.timingSafeEqual(E,v)})?{valid:!0}:{valid:!1,error:"Invalid signature"}}var H={match:G("message.received"),handler:async(n,t)=>{let i=N(t,n.key);if(!i.valid)return{success:!1,statusCode:401,error:i.error||"Signature verification failed"};let o=m.safeParse(t.payload);if(!o.success)return{success:!1,statusCode:400,error:"Invalid AgentMail message.received payload"};let a=o.data,g=await d(n,a.message);return await ie(n,"agentmail.webhook.messageReceived",{event_id:a.event_id,inbox_id:a.message.inbox_id,message_id:a.message.message_id,thread_id:a.message.thread_id},"completed"),{success:!0,corsairEntityId:g,data:a}}};var q={received:H};var ae={messages:{get:A.get,list:A.list,send:A.send}},oe={message:{received:q.received}},re={"messages.list":{input:M.messagesList,output:b.messagesList},"messages.get":{input:M.messagesGet,output:b.messagesGet},"messages.send":{input:M.messagesSend,output:b.messagesSend}},ge={"message.received":{description:"A new email was received in an AgentMail inbox",payload:m,response:m}},pe="api_key",le={"messages.list":{riskLevel:"read",description:"List messages from an AgentMail inbox"},"messages.get":{riskLevel:"read",description:"Retrieve the complete details of an AgentMail message"},"messages.send":{riskLevel:"write",description:"Send an email using AgentMail"}},De={api_key:{account:["one"]}};function Fe(n={}){let t={...n,authType:n.authType??pe};return{id:"agentmail",schema:L,options:t,hooks:t.hooks,webhookHooks:t.webhookHooks,endpoints:ae,webhooks:oe,endpointMeta:le,endpointSchemas:re,webhookSchemas:ge,pluginWebhookMatcher:z,errorHandlers:{...T,...t.errorHandlers},keyBuilder:async(i,o)=>{if(o==="webhook"&&t.webhookSecret)return t.webhookSecret;if(o==="webhook")return await i.keys.get_webhook_signature()??"";if(o==="endpoint"&&t.key)return t.key;if(o==="endpoint"&&i.authType==="api_key"){let a=await i.keys.get_api_key();if(!a)throw new K("agentmail","api_key");return a}throw new K("agentmail","api_key")}}}export{De as agentMailAuthConfig,re as agentMailEndpointSchemas,Fe as agentmail};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export declare const AgentMailMessage: z.ZodObject<{
|
|
3
|
+
id: z.ZodString;
|
|
4
|
+
inbox_id: z.ZodString;
|
|
5
|
+
thread_id: z.ZodString;
|
|
6
|
+
message_id: z.ZodString;
|
|
7
|
+
labels: z.ZodArray<z.ZodString>;
|
|
8
|
+
timestamp: z.ZodString;
|
|
9
|
+
from: z.ZodString;
|
|
10
|
+
to: z.ZodArray<z.ZodString>;
|
|
11
|
+
size: z.ZodNumber;
|
|
12
|
+
updated_at: z.ZodString;
|
|
13
|
+
created_at: z.ZodString;
|
|
14
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
15
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
16
|
+
}, z.core.$strip>;
|
|
17
|
+
export type AgentMailMessage = z.infer<typeof AgentMailMessage>;
|
|
18
|
+
//# sourceMappingURL=database.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"database.d.ts","sourceRoot":"","sources":["../../schema/database.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAGxB,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;iBAc3B,CAAC;AAEH,MAAM,MAAM,gBAAgB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gBAAgB,CAAC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export declare const AgentMailSchema: {
|
|
2
|
+
readonly version: "1.0.0";
|
|
3
|
+
readonly entities: {
|
|
4
|
+
readonly messages: import("zod").ZodObject<{
|
|
5
|
+
id: import("zod").ZodString;
|
|
6
|
+
inbox_id: import("zod").ZodString;
|
|
7
|
+
thread_id: import("zod").ZodString;
|
|
8
|
+
message_id: import("zod").ZodString;
|
|
9
|
+
labels: import("zod").ZodArray<import("zod").ZodString>;
|
|
10
|
+
timestamp: import("zod").ZodString;
|
|
11
|
+
from: import("zod").ZodString;
|
|
12
|
+
to: import("zod").ZodArray<import("zod").ZodString>;
|
|
13
|
+
size: import("zod").ZodNumber;
|
|
14
|
+
updated_at: import("zod").ZodString;
|
|
15
|
+
created_at: import("zod").ZodString;
|
|
16
|
+
subject: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
|
+
preview: import("zod").ZodOptional<import("zod").ZodString>;
|
|
18
|
+
}, import("zod/v4/core").$strip>;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
export type { AgentMailMessage } from './database';
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../schema/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;CAKlB,CAAC;AAEX,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.test.d.ts","sourceRoot":"","sources":["../schema.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const _default: import("tsup").Options | import("tsup").Options[] | ((overrideOptions: import("tsup").Options) => import("tsup").Options | import("tsup").Options[] | Promise<import("tsup").Options | import("tsup").Options[]>);
|
|
2
|
+
export default _default;
|
|
3
|
+
//# sourceMappingURL=tsup.config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tsup.config.d.ts","sourceRoot":"","sources":["../tsup.config.ts"],"names":[],"mappings":";AAEA,wBAYG"}
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
export declare const MessageWebhooks: {
|
|
2
|
+
received: {
|
|
3
|
+
match: import("corsair/core").CorsairWebhookMatcher;
|
|
4
|
+
handler: import("corsair/core").CorsairWebhookHandler<import("..").AgentMailContext, {
|
|
5
|
+
[x: string]: unknown;
|
|
6
|
+
type: "event";
|
|
7
|
+
event_id: string;
|
|
8
|
+
event_type: "message.received";
|
|
9
|
+
message: {
|
|
10
|
+
[x: string]: unknown;
|
|
11
|
+
inbox_id: string;
|
|
12
|
+
thread_id: string;
|
|
13
|
+
message_id: string;
|
|
14
|
+
labels: string[];
|
|
15
|
+
timestamp: string;
|
|
16
|
+
from: string;
|
|
17
|
+
to: string[];
|
|
18
|
+
size: number;
|
|
19
|
+
updated_at: string;
|
|
20
|
+
created_at: string;
|
|
21
|
+
reply_to?: string[] | undefined;
|
|
22
|
+
cc?: string[] | undefined;
|
|
23
|
+
bcc?: string[] | undefined;
|
|
24
|
+
subject?: string | undefined;
|
|
25
|
+
preview?: string | undefined;
|
|
26
|
+
text?: string | undefined;
|
|
27
|
+
html?: string | undefined;
|
|
28
|
+
extracted_text?: string | undefined;
|
|
29
|
+
extracted_html?: string | undefined;
|
|
30
|
+
attachments?: {
|
|
31
|
+
[x: string]: unknown;
|
|
32
|
+
attachment_id: string;
|
|
33
|
+
size: number;
|
|
34
|
+
filename?: string | undefined;
|
|
35
|
+
content_type?: string | undefined;
|
|
36
|
+
content_disposition?: string | undefined;
|
|
37
|
+
content_id?: string | undefined;
|
|
38
|
+
}[] | undefined;
|
|
39
|
+
in_reply_to?: string | undefined;
|
|
40
|
+
references?: string[] | undefined;
|
|
41
|
+
headers?: Record<string, string> | undefined;
|
|
42
|
+
};
|
|
43
|
+
thread: {
|
|
44
|
+
[x: string]: unknown;
|
|
45
|
+
inbox_id: string;
|
|
46
|
+
thread_id: string;
|
|
47
|
+
labels: string[];
|
|
48
|
+
timestamp: string;
|
|
49
|
+
senders: string[];
|
|
50
|
+
recipients: string[];
|
|
51
|
+
last_message_id: string;
|
|
52
|
+
message_count: number;
|
|
53
|
+
size: number;
|
|
54
|
+
updated_at: string;
|
|
55
|
+
created_at: string;
|
|
56
|
+
received_timestamp?: string | undefined;
|
|
57
|
+
sent_timestamp?: string | undefined;
|
|
58
|
+
subject?: string | undefined;
|
|
59
|
+
preview?: string | undefined;
|
|
60
|
+
attachments?: {
|
|
61
|
+
[x: string]: unknown;
|
|
62
|
+
attachment_id: string;
|
|
63
|
+
size: number;
|
|
64
|
+
filename?: string | undefined;
|
|
65
|
+
content_type?: string | undefined;
|
|
66
|
+
content_disposition?: string | undefined;
|
|
67
|
+
content_id?: string | undefined;
|
|
68
|
+
}[] | undefined;
|
|
69
|
+
};
|
|
70
|
+
}, {
|
|
71
|
+
[x: string]: unknown;
|
|
72
|
+
type: "event";
|
|
73
|
+
event_id: string;
|
|
74
|
+
event_type: "message.received";
|
|
75
|
+
message: {
|
|
76
|
+
[x: string]: unknown;
|
|
77
|
+
inbox_id: string;
|
|
78
|
+
thread_id: string;
|
|
79
|
+
message_id: string;
|
|
80
|
+
labels: string[];
|
|
81
|
+
timestamp: string;
|
|
82
|
+
from: string;
|
|
83
|
+
to: string[];
|
|
84
|
+
size: number;
|
|
85
|
+
updated_at: string;
|
|
86
|
+
created_at: string;
|
|
87
|
+
reply_to?: string[] | undefined;
|
|
88
|
+
cc?: string[] | undefined;
|
|
89
|
+
bcc?: string[] | undefined;
|
|
90
|
+
subject?: string | undefined;
|
|
91
|
+
preview?: string | undefined;
|
|
92
|
+
text?: string | undefined;
|
|
93
|
+
html?: string | undefined;
|
|
94
|
+
extracted_text?: string | undefined;
|
|
95
|
+
extracted_html?: string | undefined;
|
|
96
|
+
attachments?: {
|
|
97
|
+
[x: string]: unknown;
|
|
98
|
+
attachment_id: string;
|
|
99
|
+
size: number;
|
|
100
|
+
filename?: string | undefined;
|
|
101
|
+
content_type?: string | undefined;
|
|
102
|
+
content_disposition?: string | undefined;
|
|
103
|
+
content_id?: string | undefined;
|
|
104
|
+
}[] | undefined;
|
|
105
|
+
in_reply_to?: string | undefined;
|
|
106
|
+
references?: string[] | undefined;
|
|
107
|
+
headers?: Record<string, string> | undefined;
|
|
108
|
+
};
|
|
109
|
+
thread: {
|
|
110
|
+
[x: string]: unknown;
|
|
111
|
+
inbox_id: string;
|
|
112
|
+
thread_id: string;
|
|
113
|
+
labels: string[];
|
|
114
|
+
timestamp: string;
|
|
115
|
+
senders: string[];
|
|
116
|
+
recipients: string[];
|
|
117
|
+
last_message_id: string;
|
|
118
|
+
message_count: number;
|
|
119
|
+
size: number;
|
|
120
|
+
updated_at: string;
|
|
121
|
+
created_at: string;
|
|
122
|
+
received_timestamp?: string | undefined;
|
|
123
|
+
sent_timestamp?: string | undefined;
|
|
124
|
+
subject?: string | undefined;
|
|
125
|
+
preview?: string | undefined;
|
|
126
|
+
attachments?: {
|
|
127
|
+
[x: string]: unknown;
|
|
128
|
+
attachment_id: string;
|
|
129
|
+
size: number;
|
|
130
|
+
filename?: string | undefined;
|
|
131
|
+
content_type?: string | undefined;
|
|
132
|
+
content_disposition?: string | undefined;
|
|
133
|
+
content_id?: string | undefined;
|
|
134
|
+
}[] | undefined;
|
|
135
|
+
};
|
|
136
|
+
}>;
|
|
137
|
+
};
|
|
138
|
+
};
|
|
139
|
+
export * from './types';
|
|
140
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../webhooks/index.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAE3B,CAAC;AAEF,cAAc,SAAS,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"matcher.test.d.ts","sourceRoot":"","sources":["../../webhooks/matcher.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"message.d.ts","sourceRoot":"","sources":["../../webhooks/message.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAOlD,eAAO,MAAM,QAAQ,EAAE,iBAAiB,CAAC,iBAAiB,CA2CzD,CAAC"}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import type { CorsairWebhookMatcher, RawWebhookRequest, WebhookRequest } from 'corsair/core';
|
|
2
|
+
import { z } from 'zod';
|
|
3
|
+
export declare const AgentMailWebhookPayloadSchema: z.ZodObject<{
|
|
4
|
+
type: z.ZodLiteral<"event">;
|
|
5
|
+
event_type: z.ZodString;
|
|
6
|
+
event_id: z.ZodString;
|
|
7
|
+
}, z.core.$loose>;
|
|
8
|
+
export type AgentMailWebhookPayload = z.infer<typeof AgentMailWebhookPayloadSchema>;
|
|
9
|
+
export declare const MessageReceivedEventSchema: z.ZodObject<{
|
|
10
|
+
type: z.ZodLiteral<"event">;
|
|
11
|
+
event_id: z.ZodString;
|
|
12
|
+
event_type: z.ZodLiteral<"message.received">;
|
|
13
|
+
message: z.ZodObject<{
|
|
14
|
+
inbox_id: z.ZodString;
|
|
15
|
+
thread_id: z.ZodString;
|
|
16
|
+
message_id: z.ZodString;
|
|
17
|
+
labels: z.ZodArray<z.ZodString>;
|
|
18
|
+
timestamp: z.ZodString;
|
|
19
|
+
from: z.ZodString;
|
|
20
|
+
to: z.ZodArray<z.ZodString>;
|
|
21
|
+
size: z.ZodNumber;
|
|
22
|
+
updated_at: z.ZodString;
|
|
23
|
+
created_at: z.ZodString;
|
|
24
|
+
reply_to: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
25
|
+
cc: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
26
|
+
bcc: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
27
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
28
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
29
|
+
text: z.ZodOptional<z.ZodString>;
|
|
30
|
+
html: z.ZodOptional<z.ZodString>;
|
|
31
|
+
extracted_text: z.ZodOptional<z.ZodString>;
|
|
32
|
+
extracted_html: z.ZodOptional<z.ZodString>;
|
|
33
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
34
|
+
attachment_id: z.ZodString;
|
|
35
|
+
size: z.ZodNumber;
|
|
36
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
37
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
38
|
+
content_disposition: z.ZodOptional<z.ZodString>;
|
|
39
|
+
content_id: z.ZodOptional<z.ZodString>;
|
|
40
|
+
}, z.core.$loose>>>;
|
|
41
|
+
in_reply_to: z.ZodOptional<z.ZodString>;
|
|
42
|
+
references: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
43
|
+
headers: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
44
|
+
}, z.core.$loose>;
|
|
45
|
+
thread: z.ZodObject<{
|
|
46
|
+
inbox_id: z.ZodString;
|
|
47
|
+
thread_id: z.ZodString;
|
|
48
|
+
labels: z.ZodArray<z.ZodString>;
|
|
49
|
+
timestamp: z.ZodString;
|
|
50
|
+
senders: z.ZodArray<z.ZodString>;
|
|
51
|
+
recipients: z.ZodArray<z.ZodString>;
|
|
52
|
+
last_message_id: z.ZodString;
|
|
53
|
+
message_count: z.ZodNumber;
|
|
54
|
+
size: z.ZodNumber;
|
|
55
|
+
updated_at: z.ZodString;
|
|
56
|
+
created_at: z.ZodString;
|
|
57
|
+
received_timestamp: z.ZodOptional<z.ZodString>;
|
|
58
|
+
sent_timestamp: z.ZodOptional<z.ZodString>;
|
|
59
|
+
subject: z.ZodOptional<z.ZodString>;
|
|
60
|
+
preview: z.ZodOptional<z.ZodString>;
|
|
61
|
+
attachments: z.ZodOptional<z.ZodArray<z.ZodObject<{
|
|
62
|
+
attachment_id: z.ZodString;
|
|
63
|
+
size: z.ZodNumber;
|
|
64
|
+
filename: z.ZodOptional<z.ZodString>;
|
|
65
|
+
content_type: z.ZodOptional<z.ZodString>;
|
|
66
|
+
content_disposition: z.ZodOptional<z.ZodString>;
|
|
67
|
+
content_id: z.ZodOptional<z.ZodString>;
|
|
68
|
+
}, z.core.$loose>>>;
|
|
69
|
+
}, z.core.$loose>;
|
|
70
|
+
}, z.core.$loose>;
|
|
71
|
+
export type MessageReceivedEvent = z.infer<typeof MessageReceivedEventSchema>;
|
|
72
|
+
export type AgentMailWebhookOutputs = {
|
|
73
|
+
messageReceived: MessageReceivedEvent;
|
|
74
|
+
};
|
|
75
|
+
export declare function parseBody(body: unknown): Record<string, unknown> | null;
|
|
76
|
+
export declare function createAgentMailMatch(eventType: string): CorsairWebhookMatcher;
|
|
77
|
+
/** Plugin-level matcher: Svix header + AgentMail event shape (string or object body). */
|
|
78
|
+
export declare function matchAgentMailPluginWebhook(request: RawWebhookRequest): boolean;
|
|
79
|
+
export declare function verifyAgentMailWebhookSignature(request: WebhookRequest<unknown>, secret?: string): {
|
|
80
|
+
valid: boolean;
|
|
81
|
+
error?: string;
|
|
82
|
+
};
|
|
83
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../webhooks/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,qBAAqB,EACrB,iBAAiB,EACjB,cAAc,EACd,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AA8DxB,eAAO,MAAM,6BAA6B;;;;iBAMjC,CAAC;AAEV,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,6BAA6B,CACpC,CAAC;AAEF,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAIrC,CAAC;AAEH,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,MAAM,MAAM,uBAAuB,GAAG;IACrC,eAAe,EAAE,oBAAoB,CAAC;CACtC,CAAC;AAIF,wBAAgB,SAAS,CAAC,IAAI,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAI,CAsBvE;AAED,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,qBAAqB,CAK7E;AAED,yFAAyF;AACzF,wBAAgB,2BAA2B,CAC1C,OAAO,EAAE,iBAAiB,GACxB,OAAO,CAYT;AA2BD,wBAAgB,+BAA+B,CAG9C,OAAO,EAAE,cAAc,CAAC,OAAO,CAAC,EAChC,MAAM,CAAC,EAAE,MAAM,GACb;IAAE,KAAK,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,CAoEpC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@corsair-dev/agentmail",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "AgentMail plugin for Corsair",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"dev-source": "./index.ts",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
"peerDependencies": {
|
|
17
|
+
"corsair": ">=0.1.0",
|
|
18
|
+
"zod": "^4.1.13"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@types/jest": "^29.5.14",
|
|
22
|
+
"dotenv": "^17.2.3",
|
|
23
|
+
"jest": "^29.7.0",
|
|
24
|
+
"ts-jest": "^29.4.9",
|
|
25
|
+
"tsup": "^8.0.1",
|
|
26
|
+
"typescript": "^5.9.3",
|
|
27
|
+
"zod": "4.1.13",
|
|
28
|
+
"corsair": "0.1.110"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"corsair",
|
|
32
|
+
"agentmail",
|
|
33
|
+
"plugin"
|
|
34
|
+
],
|
|
35
|
+
"author": "",
|
|
36
|
+
"license": "Apache-2.0",
|
|
37
|
+
"files": [
|
|
38
|
+
"dist"
|
|
39
|
+
],
|
|
40
|
+
"scripts": {
|
|
41
|
+
"build": "rm -rf dist && tsc --build --force && tsup",
|
|
42
|
+
"typecheck": "tsc --noEmit",
|
|
43
|
+
"test": "jest"
|
|
44
|
+
}
|
|
45
|
+
}
|