@agentuity/core 1.0.24 → 1.0.26

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.
@@ -8,8 +8,6 @@ import { safeStringify } from '../json.ts';
8
8
  export interface EmailAddress {
9
9
  id: string;
10
10
  email: string;
11
- project_id?: string;
12
- provider?: string;
13
11
  config?: Record<string, unknown>;
14
12
  created_by?: string;
15
13
  created_at: string;
@@ -27,6 +25,20 @@ export interface EmailDestination {
27
25
  updated_at?: string;
28
26
  }
29
27
 
28
+ export interface EmailProtocolConfig {
29
+ host: string;
30
+ port: number;
31
+ tls: string;
32
+ username: string;
33
+ password: string;
34
+ }
35
+
36
+ export interface EmailConnectionConfig {
37
+ email: string;
38
+ imap: EmailProtocolConfig;
39
+ pop3: EmailProtocolConfig;
40
+ }
41
+
30
42
  /**
31
43
  * An inbound email message
32
44
  */
@@ -39,7 +51,7 @@ export interface EmailInbound {
39
51
  html?: string;
40
52
  received_at?: string;
41
53
  headers?: Record<string, unknown>;
42
- attachments?: unknown[];
54
+ attachments?: EmailStoredAttachment[];
43
55
  }
44
56
 
45
57
  /**
@@ -56,7 +68,7 @@ export interface EmailOutbound {
56
68
  error?: string;
57
69
  created_at?: string;
58
70
  headers?: Record<string, unknown>;
59
- attachments?: unknown[];
71
+ attachments?: EmailStoredAttachment[];
60
72
  }
61
73
 
62
74
  /**
@@ -79,6 +91,25 @@ export interface EmailAttachment {
79
91
  contentType?: string;
80
92
  }
81
93
 
94
+ /**
95
+ * A stored email attachment with S3 location metadata.
96
+ * Returned by inbound/outbound email queries — different from EmailAttachment used for sending.
97
+ */
98
+ export interface EmailStoredAttachment {
99
+ /** The original filename */
100
+ filename: string;
101
+ /** The MIME content type */
102
+ content_type?: string;
103
+ /** File size in bytes */
104
+ size: number;
105
+ /** The S3 bucket name where the attachment is stored */
106
+ bucket: string;
107
+ /** The S3 object key */
108
+ key: string;
109
+ /** Optional pre-signed download URL */
110
+ url?: string;
111
+ }
112
+
82
113
  /**
83
114
  * Parameters for sending an email
84
115
  */
@@ -112,6 +143,11 @@ export interface EmailSendParams {
112
143
  * File attachments
113
144
  */
114
145
  attachments?: EmailAttachment[];
146
+
147
+ /**
148
+ * Custom email headers (e.g., In-Reply-To, References for threading)
149
+ */
150
+ headers?: Record<string, string>;
115
151
  }
116
152
 
117
153
  /**
@@ -163,6 +199,14 @@ export interface EmailService {
163
199
  */
164
200
  getAddress(id: string): Promise<EmailAddress | null>;
165
201
 
202
+ /**
203
+ * Get email connection settings (IMAP/POP3) for an address
204
+ *
205
+ * @param id - the email address ID
206
+ * @returns the connection configuration or null if not found
207
+ */
208
+ getConnectionConfig(id: string): Promise<EmailConnectionConfig | null>;
209
+
166
210
  /**
167
211
  * Delete an email address
168
212
  *
@@ -278,6 +322,18 @@ export interface EmailService {
278
322
  */
279
323
  getInbound(id: string): Promise<EmailInbound | null>;
280
324
 
325
+ /**
326
+ * Delete an inbound email by ID
327
+ *
328
+ * @param id - the inbound email ID
329
+ *
330
+ * @example
331
+ * ```typescript
332
+ * await email.deleteInbound('inb_abc123');
333
+ * ```
334
+ */
335
+ deleteInbound(id: string): Promise<void>;
336
+
281
337
  /**
282
338
  * List outbound emails
283
339
  *
@@ -309,6 +365,18 @@ export interface EmailService {
309
365
  * ```
310
366
  */
311
367
  getOutbound(id: string): Promise<EmailOutbound | null>;
368
+
369
+ /**
370
+ * Delete an outbound email by ID
371
+ *
372
+ * @param id - the outbound email ID
373
+ *
374
+ * @example
375
+ * ```typescript
376
+ * await email.deleteOutbound('out_abc123');
377
+ * ```
378
+ */
379
+ deleteOutbound(id: string): Promise<void>;
312
380
  }
313
381
 
314
382
  /**
@@ -384,10 +452,7 @@ export class EmailStorageService implements EmailService {
384
452
  }
385
453
 
386
454
  async getAddress(id: string): Promise<EmailAddress | null> {
387
- const url = buildUrl(
388
- this.#baseUrl,
389
- `/email/2025-03-17/addresses/${encodeURIComponent(id)}`
390
- );
455
+ const url = buildUrl(this.#baseUrl, `/email/2025-03-17/addresses/${encodeURIComponent(id)}`);
391
456
  const signal = AbortSignal.timeout(30_000);
392
457
  const res = await this.#adapter.invoke<unknown>(url, {
393
458
  method: 'GET',
@@ -408,12 +473,34 @@ export class EmailStorageService implements EmailService {
408
473
  throw await toServiceException('GET', url, res.response);
409
474
  }
410
475
 
411
- async deleteAddress(id: string): Promise<void> {
476
+ async getConnectionConfig(id: string): Promise<EmailConnectionConfig | null> {
412
477
  const url = buildUrl(
413
478
  this.#baseUrl,
414
- `/email/2025-03-17/addresses/${encodeURIComponent(id)}`
479
+ `/email/2025-03-17/addresses/${encodeURIComponent(id)}/connection`
415
480
  );
416
481
  const signal = AbortSignal.timeout(30_000);
482
+ const res = await this.#adapter.invoke<unknown>(url, {
483
+ method: 'GET',
484
+ signal,
485
+ telemetry: {
486
+ name: 'agentuity.email.getConnectionConfig',
487
+ attributes: {
488
+ id,
489
+ },
490
+ },
491
+ });
492
+ if (res.response.status === 404) {
493
+ return null;
494
+ }
495
+ if (res.ok) {
496
+ return unwrap<EmailConnectionConfig>(res.data, 'connection');
497
+ }
498
+ throw await toServiceException('GET', url, res.response);
499
+ }
500
+
501
+ async deleteAddress(id: string): Promise<void> {
502
+ const url = buildUrl(this.#baseUrl, `/email/2025-03-17/addresses/${encodeURIComponent(id)}`);
503
+ const signal = AbortSignal.timeout(30_000);
417
504
  const res = await this.#adapter.invoke<unknown>(url, {
418
505
  method: 'DELETE',
419
506
  signal,
@@ -531,6 +618,9 @@ export class EmailStorageService implements EmailService {
531
618
  ...(a.contentType && { content_type: a.contentType }),
532
619
  }));
533
620
  }
621
+ if (params.headers && Object.keys(params.headers).length > 0) {
622
+ body.headers = params.headers;
623
+ }
534
624
 
535
625
  const res = await this.#adapter.invoke<unknown>(url, {
536
626
  method: 'POST',
@@ -583,10 +673,7 @@ export class EmailStorageService implements EmailService {
583
673
  }
584
674
 
585
675
  async getInbound(id: string): Promise<EmailInbound | null> {
586
- const url = buildUrl(
587
- this.#baseUrl,
588
- `/email/2025-03-17/inbound/${encodeURIComponent(id)}`
589
- );
676
+ const url = buildUrl(this.#baseUrl, `/email/2025-03-17/inbound/${encodeURIComponent(id)}`);
590
677
  const signal = AbortSignal.timeout(30_000);
591
678
  const res = await this.#adapter.invoke<unknown>(url, {
592
679
  method: 'GET',
@@ -607,6 +694,25 @@ export class EmailStorageService implements EmailService {
607
694
  throw await toServiceException('GET', url, res.response);
608
695
  }
609
696
 
697
+ async deleteInbound(id: string): Promise<void> {
698
+ const url = buildUrl(this.#baseUrl, `/email/2025-03-17/inbound/${encodeURIComponent(id)}`);
699
+ const signal = AbortSignal.timeout(30_000);
700
+ const res = await this.#adapter.invoke<unknown>(url, {
701
+ method: 'DELETE',
702
+ signal,
703
+ telemetry: {
704
+ name: 'agentuity.email.deleteInbound',
705
+ attributes: {
706
+ id,
707
+ },
708
+ },
709
+ });
710
+ if (res.ok || res.response.status === 404) {
711
+ return;
712
+ }
713
+ throw await toServiceException('DELETE', url, res.response);
714
+ }
715
+
610
716
  async listOutbound(addressId?: string): Promise<EmailOutbound[]> {
611
717
  const queryParams = new URLSearchParams();
612
718
  if (addressId) {
@@ -639,10 +745,7 @@ export class EmailStorageService implements EmailService {
639
745
  }
640
746
 
641
747
  async getOutbound(id: string): Promise<EmailOutbound | null> {
642
- const url = buildUrl(
643
- this.#baseUrl,
644
- `/email/2025-03-17/outbound/${encodeURIComponent(id)}`
645
- );
748
+ const url = buildUrl(this.#baseUrl, `/email/2025-03-17/outbound/${encodeURIComponent(id)}`);
646
749
  const signal = AbortSignal.timeout(30_000);
647
750
  const res = await this.#adapter.invoke<unknown>(url, {
648
751
  method: 'GET',
@@ -662,4 +765,23 @@ export class EmailStorageService implements EmailService {
662
765
  }
663
766
  throw await toServiceException('GET', url, res.response);
664
767
  }
768
+
769
+ async deleteOutbound(id: string): Promise<void> {
770
+ const url = buildUrl(this.#baseUrl, `/email/2025-03-17/outbound/${encodeURIComponent(id)}`);
771
+ const signal = AbortSignal.timeout(30_000);
772
+ const res = await this.#adapter.invoke<unknown>(url, {
773
+ method: 'DELETE',
774
+ signal,
775
+ telemetry: {
776
+ name: 'agentuity.email.deleteOutbound',
777
+ attributes: {
778
+ id,
779
+ },
780
+ },
781
+ });
782
+ if (res.ok || res.response.status === 404) {
783
+ return;
784
+ }
785
+ throw await toServiceException('DELETE', url, res.response);
786
+ }
665
787
  }
@@ -9,5 +9,23 @@ export * from './session.ts';
9
9
  export * from './stream.ts';
10
10
  export * from './task.ts';
11
11
  export * from './vector.ts';
12
+ export { WebhookService } from './webhook.ts';
13
+ export type {
14
+ Webhook,
15
+ WebhookDestination,
16
+ WebhookReceipt,
17
+ WebhookDelivery,
18
+ CreateWebhookParams,
19
+ UpdateWebhookParams,
20
+ CreateWebhookDestinationParams,
21
+ WebhookListResult,
22
+ WebhookGetResult,
23
+ WebhookCreateResult,
24
+ UpdateWebhookResult,
25
+ CreateDestinationResult,
26
+ ListDestinationsResult,
27
+ WebhookReceiptListResult,
28
+ WebhookDeliveryListResult,
29
+ } from './webhook.ts';
12
30
  export * from './email.ts';
13
31
  export { buildUrl, toServiceException, toPayload, fromResponse } from './_util.ts';