agentmail 0.5.13 → 0.5.15

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 (107) hide show
  1. package/dist/cjs/BaseClient.d.ts +3 -0
  2. package/dist/cjs/BaseClient.js +2 -2
  3. package/dist/cjs/api/errors/ConflictError.d.ts +6 -0
  4. package/dist/cjs/{serialization/resources/drafts/types/CreateDraftReplyAllRequest.js → api/errors/ConflictError.js} +18 -20
  5. package/dist/cjs/api/errors/index.d.ts +1 -0
  6. package/dist/cjs/api/errors/index.js +1 -0
  7. package/dist/cjs/api/resources/drafts/types/CreateDraftRequest.d.ts +17 -0
  8. package/dist/cjs/api/resources/drafts/types/UpdateDraftRequest.d.ts +22 -8
  9. package/dist/cjs/api/resources/drafts/types/index.d.ts +0 -3
  10. package/dist/cjs/api/resources/drafts/types/index.js +0 -3
  11. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.d.ts +19 -3
  12. package/dist/cjs/api/resources/inboxes/resources/drafts/client/Client.js +48 -2
  13. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.d.ts +15 -78
  14. package/dist/cjs/api/resources/inboxes/resources/messages/client/Client.js +41 -269
  15. package/dist/cjs/api/types/ErrorCode.d.ts +4 -0
  16. package/dist/cjs/api/types/ErrorDocs.d.ts +4 -0
  17. package/dist/cjs/api/types/ErrorFix.d.ts +4 -0
  18. package/dist/cjs/api/types/ErrorResponse.d.ts +3 -0
  19. package/dist/cjs/api/types/ValidationErrorResponse.d.ts +5 -1
  20. package/dist/cjs/api/types/index.d.ts +3 -0
  21. package/dist/cjs/api/types/index.js +3 -0
  22. package/dist/cjs/serialization/resources/drafts/types/CreateDraftRequest.d.ts +4 -0
  23. package/dist/cjs/serialization/resources/drafts/types/CreateDraftRequest.js +4 -0
  24. package/dist/cjs/serialization/resources/drafts/types/UpdateDraftRequest.d.ts +15 -8
  25. package/dist/cjs/serialization/resources/drafts/types/UpdateDraftRequest.js +15 -8
  26. package/dist/cjs/serialization/resources/drafts/types/index.d.ts +0 -3
  27. package/dist/cjs/serialization/resources/drafts/types/index.js +0 -3
  28. package/dist/cjs/serialization/types/ErrorCode.d.ts +7 -0
  29. package/dist/cjs/serialization/{resources/drafts/types/CreateDraftForwardRequest.js → types/ErrorCode.js} +3 -26
  30. package/dist/cjs/serialization/types/ErrorDocs.d.ts +7 -0
  31. package/dist/cjs/serialization/types/ErrorDocs.js +39 -0
  32. package/dist/cjs/serialization/types/ErrorFix.d.ts +7 -0
  33. package/dist/cjs/serialization/types/ErrorFix.js +39 -0
  34. package/dist/cjs/serialization/types/ErrorResponse.d.ts +6 -0
  35. package/dist/cjs/serialization/types/ErrorResponse.js +6 -0
  36. package/dist/cjs/serialization/types/ValidationErrorResponse.d.ts +8 -0
  37. package/dist/cjs/serialization/types/ValidationErrorResponse.js +8 -0
  38. package/dist/cjs/serialization/types/index.d.ts +3 -0
  39. package/dist/cjs/serialization/types/index.js +3 -0
  40. package/dist/cjs/version.d.ts +1 -1
  41. package/dist/cjs/version.js +1 -1
  42. package/dist/esm/BaseClient.d.mts +3 -0
  43. package/dist/esm/BaseClient.mjs +2 -2
  44. package/dist/esm/api/errors/ConflictError.d.mts +6 -0
  45. package/dist/esm/api/errors/ConflictError.mjs +17 -0
  46. package/dist/esm/api/errors/index.d.mts +1 -0
  47. package/dist/esm/api/errors/index.mjs +1 -0
  48. package/dist/esm/api/resources/drafts/types/CreateDraftRequest.d.mts +17 -0
  49. package/dist/esm/api/resources/drafts/types/UpdateDraftRequest.d.mts +22 -8
  50. package/dist/esm/api/resources/drafts/types/index.d.mts +0 -3
  51. package/dist/esm/api/resources/drafts/types/index.mjs +0 -3
  52. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.d.mts +19 -3
  53. package/dist/esm/api/resources/inboxes/resources/drafts/client/Client.mjs +49 -3
  54. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.d.mts +15 -78
  55. package/dist/esm/api/resources/inboxes/resources/messages/client/Client.mjs +42 -270
  56. package/dist/esm/api/types/ErrorCode.d.mts +4 -0
  57. package/dist/esm/api/types/ErrorDocs.d.mts +4 -0
  58. package/dist/esm/api/types/ErrorFix.d.mts +4 -0
  59. package/dist/esm/api/types/ErrorResponse.d.mts +3 -0
  60. package/dist/esm/api/types/ValidationErrorResponse.d.mts +5 -1
  61. package/dist/esm/api/types/index.d.mts +3 -0
  62. package/dist/esm/api/types/index.mjs +3 -0
  63. package/dist/esm/serialization/resources/drafts/types/CreateDraftRequest.d.mts +4 -0
  64. package/dist/esm/serialization/resources/drafts/types/CreateDraftRequest.mjs +4 -0
  65. package/dist/esm/serialization/resources/drafts/types/UpdateDraftRequest.d.mts +15 -8
  66. package/dist/esm/serialization/resources/drafts/types/UpdateDraftRequest.mjs +15 -8
  67. package/dist/esm/serialization/resources/drafts/types/index.d.mts +0 -3
  68. package/dist/esm/serialization/resources/drafts/types/index.mjs +0 -3
  69. package/dist/esm/serialization/types/ErrorCode.d.mts +7 -0
  70. package/dist/esm/serialization/types/ErrorCode.mjs +3 -0
  71. package/dist/esm/serialization/types/ErrorDocs.d.mts +7 -0
  72. package/dist/esm/serialization/types/ErrorDocs.mjs +3 -0
  73. package/dist/esm/serialization/types/ErrorFix.d.mts +7 -0
  74. package/dist/esm/serialization/types/ErrorFix.mjs +3 -0
  75. package/dist/esm/serialization/types/ErrorResponse.d.mts +6 -0
  76. package/dist/esm/serialization/types/ErrorResponse.mjs +6 -0
  77. package/dist/esm/serialization/types/ValidationErrorResponse.d.mts +8 -0
  78. package/dist/esm/serialization/types/ValidationErrorResponse.mjs +8 -0
  79. package/dist/esm/serialization/types/index.d.mts +3 -0
  80. package/dist/esm/serialization/types/index.mjs +3 -0
  81. package/dist/esm/version.d.mts +1 -1
  82. package/dist/esm/version.mjs +1 -1
  83. package/dist/llms.txt +13 -0
  84. package/package.json +1 -1
  85. package/reference.md +15 -263
  86. package/dist/cjs/api/resources/drafts/types/CreateDraftForwardRequest.d.ts +0 -21
  87. package/dist/cjs/api/resources/drafts/types/CreateDraftReplyAllRequest.d.ts +0 -17
  88. package/dist/cjs/api/resources/drafts/types/CreateDraftReplyRequest.d.ts +0 -22
  89. package/dist/cjs/serialization/resources/drafts/types/CreateDraftForwardRequest.d.ts +0 -30
  90. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyAllRequest.d.ts +0 -24
  91. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyRequest.d.ts +0 -32
  92. package/dist/cjs/serialization/resources/drafts/types/CreateDraftReplyRequest.js +0 -64
  93. package/dist/esm/api/resources/drafts/types/CreateDraftForwardRequest.d.mts +0 -21
  94. package/dist/esm/api/resources/drafts/types/CreateDraftReplyAllRequest.d.mts +0 -17
  95. package/dist/esm/api/resources/drafts/types/CreateDraftReplyRequest.d.mts +0 -22
  96. package/dist/esm/serialization/resources/drafts/types/CreateDraftForwardRequest.d.mts +0 -30
  97. package/dist/esm/serialization/resources/drafts/types/CreateDraftForwardRequest.mjs +0 -26
  98. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyAllRequest.d.mts +0 -24
  99. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyAllRequest.mjs +0 -20
  100. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyRequest.d.mts +0 -32
  101. package/dist/esm/serialization/resources/drafts/types/CreateDraftReplyRequest.mjs +0 -28
  102. /package/dist/cjs/api/{resources/drafts/types/CreateDraftForwardRequest.js → types/ErrorCode.js} +0 -0
  103. /package/dist/cjs/api/{resources/drafts/types/CreateDraftReplyAllRequest.js → types/ErrorDocs.js} +0 -0
  104. /package/dist/cjs/api/{resources/drafts/types/CreateDraftReplyRequest.js → types/ErrorFix.js} +0 -0
  105. /package/dist/esm/api/{resources/drafts/types/CreateDraftForwardRequest.mjs → types/ErrorCode.mjs} +0 -0
  106. /package/dist/esm/api/{resources/drafts/types/CreateDraftReplyAllRequest.mjs → types/ErrorDocs.mjs} +0 -0
  107. /package/dist/esm/api/{resources/drafts/types/CreateDraftReplyRequest.mjs → types/ErrorFix.mjs} +0 -0
@@ -28,6 +28,9 @@ export interface BaseRequestOptions {
28
28
  /** Additional headers to include in the request. */
29
29
  headers?: Record<string, string | core.Supplier<string | null | undefined> | null | undefined>;
30
30
  }
31
+ export interface BaseIdempotentRequestOptions {
32
+ idempotencyKey?: string | undefined;
33
+ }
31
34
  export type NormalizedClientOptions<T extends BaseClientOptions = BaseClientOptions> = T & {
32
35
  logging: core.logging.Logger;
33
36
  authProvider?: core.AuthProvider;
@@ -43,8 +43,8 @@ function normalizeClientOptions(options) {
43
43
  const headers = (0, headers_js_1.mergeHeaders)({
44
44
  "X-Fern-Language": "JavaScript",
45
45
  "X-Fern-SDK-Name": "agentmail",
46
- "X-Fern-SDK-Version": "0.5.13",
47
- "User-Agent": "agentmail/0.5.13",
46
+ "X-Fern-SDK-Version": "0.5.15",
47
+ "User-Agent": "agentmail/0.5.15",
48
48
  "X-Fern-Runtime": core.RUNTIME.type,
49
49
  "X-Fern-Runtime-Version": core.RUNTIME.version,
50
50
  }, options === null || options === void 0 ? void 0 : options.headers);
@@ -0,0 +1,6 @@
1
+ import type * as core from "../../core/index.js";
2
+ import * as errors from "../../errors/index.js";
3
+ import type * as AgentMail from "../index.js";
4
+ export declare class ConflictError extends errors.AgentMailError {
5
+ constructor(body: AgentMail.ErrorResponse, rawResponse?: core.RawResponse);
6
+ }
@@ -34,23 +34,21 @@ var __importStar = (this && this.__importStar) || (function () {
34
34
  };
35
35
  })();
36
36
  Object.defineProperty(exports, "__esModule", { value: true });
37
- exports.CreateDraftReplyAllRequest = void 0;
38
- const core = __importStar(require("../../../../core/index.js"));
39
- const SendAttachment_js_1 = require("../../attachments/types/SendAttachment.js");
40
- const DraftClientId_js_1 = require("./DraftClientId.js");
41
- const DraftHtml_js_1 = require("./DraftHtml.js");
42
- const DraftLabels_js_1 = require("./DraftLabels.js");
43
- const DraftReplyTo_js_1 = require("./DraftReplyTo.js");
44
- const DraftSendAt_js_1 = require("./DraftSendAt.js");
45
- const DraftSubject_js_1 = require("./DraftSubject.js");
46
- const DraftText_js_1 = require("./DraftText.js");
47
- exports.CreateDraftReplyAllRequest = core.serialization.object({
48
- labels: DraftLabels_js_1.DraftLabels.optional(),
49
- replyTo: core.serialization.property("reply_to", DraftReplyTo_js_1.DraftReplyTo.optional()),
50
- subject: DraftSubject_js_1.DraftSubject.optional(),
51
- text: DraftText_js_1.DraftText.optional(),
52
- html: DraftHtml_js_1.DraftHtml.optional(),
53
- attachments: core.serialization.list(SendAttachment_js_1.SendAttachment).optional(),
54
- sendAt: core.serialization.property("send_at", DraftSendAt_js_1.DraftSendAt.optional()),
55
- clientId: core.serialization.property("client_id", DraftClientId_js_1.DraftClientId.optional()),
56
- });
37
+ exports.ConflictError = void 0;
38
+ const errors = __importStar(require("../../errors/index.js"));
39
+ class ConflictError extends errors.AgentMailError {
40
+ constructor(body, rawResponse) {
41
+ super({
42
+ message: "ConflictError",
43
+ statusCode: 409,
44
+ body: body,
45
+ rawResponse: rawResponse,
46
+ });
47
+ Object.setPrototypeOf(this, new.target.prototype);
48
+ if (Error.captureStackTrace) {
49
+ Error.captureStackTrace(this, this.constructor);
50
+ }
51
+ this.name = this.constructor.name;
52
+ }
53
+ }
54
+ exports.ConflictError = ConflictError;
@@ -1,3 +1,4 @@
1
+ export * from "./ConflictError.js";
1
2
  export * from "./IsTakenError.js";
2
3
  export * from "./NotFoundError.js";
3
4
  export * from "./UnprocessableError.js";
@@ -14,6 +14,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./ConflictError.js"), exports);
17
18
  __exportStar(require("./IsTakenError.js"), exports);
18
19
  __exportStar(require("./NotFoundError.js"), exports);
19
20
  __exportStar(require("./UnprocessableError.js"), exports);
@@ -1,4 +1,19 @@
1
1
  import type * as AgentMail from "../../../index.js";
2
+ /**
3
+ * Body for creating a draft. Supports plain, reply, reply-all, and forward
4
+ * drafts:
5
+ *
6
+ * - **Plain draft:** supply `to`, `subject`, `text`, etc.
7
+ * - **Reply:** set `in_reply_to` to a message ID. Recipients, subject, and
8
+ * threading are derived from that message. Set `reply_all` to address the
9
+ * whole thread (you then cannot also pass `to`, `cc`, or `bcc`).
10
+ * - **Forward:** set `forward_of` to a message ID. The subject and threading
11
+ * are derived from the source message, whose body and attachments are
12
+ * merged in at send time.
13
+ *
14
+ * `in_reply_to` and `forward_of` are mutually exclusive, and reading the
15
+ * referenced message requires `message_read` permission.
16
+ */
2
17
  export interface CreateDraftRequest {
3
18
  labels?: AgentMail.DraftLabels;
4
19
  replyTo?: AgentMail.DraftReplyTo;
@@ -11,6 +26,8 @@ export interface CreateDraftRequest {
11
26
  /** Attachments to include in draft. */
12
27
  attachments?: AgentMail.SendAttachment[];
13
28
  inReplyTo?: AgentMail.DraftInReplyTo;
29
+ forwardOf?: AgentMail.DraftForwardOf;
30
+ replyAll?: AgentMail.DraftReplyAll;
14
31
  sendAt?: AgentMail.DraftSendAt;
15
32
  clientId?: AgentMail.DraftClientId;
16
33
  }
@@ -1,11 +1,25 @@
1
1
  import type * as AgentMail from "../../../index.js";
2
+ /**
3
+ * Edit fields on an existing draft. A draft's kind (plain, reply, or forward)
4
+ * is fixed at creation and cannot be changed here. Omitting a field leaves it
5
+ * unchanged; passing `null` (or `[]` for a recipient field) clears it. Pass
6
+ * `send_at` to schedule or reschedule the draft, or `null` to un-schedule it.
7
+ */
2
8
  export interface UpdateDraftRequest {
3
- replyTo?: AgentMail.DraftReplyTo;
4
- to?: AgentMail.DraftTo;
5
- cc?: AgentMail.DraftCc;
6
- bcc?: AgentMail.DraftBcc;
7
- subject?: AgentMail.DraftSubject;
8
- text?: AgentMail.DraftText;
9
- html?: AgentMail.DraftHtml;
10
- sendAt?: AgentMail.DraftSendAt;
9
+ replyTo?: AgentMail.DraftReplyTo | null;
10
+ to?: AgentMail.DraftTo | null;
11
+ cc?: AgentMail.DraftCc | null;
12
+ bcc?: AgentMail.DraftBcc | null;
13
+ subject?: AgentMail.DraftSubject | null;
14
+ text?: AgentMail.DraftText | null;
15
+ html?: AgentMail.DraftHtml | null;
16
+ /** Attachments to add to the draft. */
17
+ addAttachments?: AgentMail.SendAttachment[];
18
+ /** IDs of attachments to remove from the draft. */
19
+ removeAttachments?: AgentMail.AttachmentId[];
20
+ /** Label or labels to add to the draft. */
21
+ addLabels?: AgentMail.DraftLabels;
22
+ /** Label or labels to remove from the draft. */
23
+ removeLabels?: AgentMail.DraftLabels;
24
+ sendAt?: AgentMail.DraftSendAt | null;
11
25
  }
@@ -1,6 +1,3 @@
1
- export * from "./CreateDraftForwardRequest.js";
2
- export * from "./CreateDraftReplyAllRequest.js";
3
- export * from "./CreateDraftReplyRequest.js";
4
1
  export * from "./CreateDraftRequest.js";
5
2
  export * from "./Draft.js";
6
3
  export * from "./DraftAttachments.js";
@@ -14,9 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./CreateDraftForwardRequest.js"), exports);
18
- __exportStar(require("./CreateDraftReplyAllRequest.js"), exports);
19
- __exportStar(require("./CreateDraftReplyRequest.js"), exports);
20
17
  __exportStar(require("./CreateDraftRequest.js"), exports);
21
18
  __exportStar(require("./Draft.js"), exports);
22
19
  __exportStar(require("./DraftAttachments.js"), exports);
@@ -1,4 +1,4 @@
1
- import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";
1
+ import type { BaseClientOptions, BaseIdempotentRequestOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";
2
2
  import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js";
3
3
  import * as core from "../../../../../../core/index.js";
4
4
  import * as AgentMail from "../../../../../index.js";
@@ -6,6 +6,8 @@ export declare namespace DraftsClient {
6
6
  type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
+ interface IdempotentRequestOptions extends RequestOptions, BaseIdempotentRequestOptions {
10
+ }
9
11
  }
10
12
  export declare class DraftsClient {
11
13
  protected readonly _options: NormalizedClientOptionsWithAuth<DraftsClient.Options>;
@@ -63,6 +65,12 @@ export declare class DraftsClient {
63
65
  getAttachment(inbox_id: AgentMail.inboxes.InboxId, draft_id: AgentMail.DraftId, attachment_id: AgentMail.AttachmentId, requestOptions?: DraftsClient.RequestOptions): core.HttpResponsePromise<AgentMail.AttachmentResponse>;
64
66
  private __getAttachment;
65
67
  /**
68
+ * Create a draft. Supply `in_reply_to` to create a reply draft (with
69
+ * `reply_all` to address the whole thread), whose recipients, subject, and
70
+ * threading are derived from the referenced message, or `forward_of` to
71
+ * create a forward draft, which derives the subject, threading, and
72
+ * forwarded content from the source but keeps recipients caller-supplied.
73
+ *
66
74
  * **CLI:**
67
75
  * ```bash
68
76
  * agentmail inboxes:drafts create --inbox-id <inbox_id> --to recipient@example.com --subject "Draft subject" --text "Draft body"
@@ -72,6 +80,7 @@ export declare class DraftsClient {
72
80
  * @param {AgentMail.CreateDraftRequest} request
73
81
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
74
82
  *
83
+ * @throws {@link AgentMail.ValidationError}
75
84
  * @throws {@link AgentMail.NotFoundError}
76
85
  *
77
86
  * @example
@@ -80,6 +89,10 @@ export declare class DraftsClient {
80
89
  create(inbox_id: AgentMail.inboxes.InboxId, request: AgentMail.CreateDraftRequest, requestOptions?: DraftsClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
81
90
  private __create;
82
91
  /**
92
+ * Edit fields on an existing draft. Passing `null` clears a field (or `[]`
93
+ * for a recipient field); `send_at: null` un-schedules a scheduled draft.
94
+ * A draft that is already being sent cannot be edited.
95
+ *
83
96
  * **CLI:**
84
97
  * ```bash
85
98
  * agentmail inboxes:drafts update --inbox-id <inbox_id> --draft-id <draft_id> --subject "Updated subject"
@@ -90,7 +103,9 @@ export declare class DraftsClient {
90
103
  * @param {AgentMail.UpdateDraftRequest} request
91
104
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
92
105
  *
106
+ * @throws {@link AgentMail.ValidationError}
93
107
  * @throws {@link AgentMail.NotFoundError}
108
+ * @throws {@link AgentMail.ConflictError}
94
109
  *
95
110
  * @example
96
111
  * await client.inboxes.drafts.update("inbox_id", "draft_id", {})
@@ -123,15 +138,16 @@ export declare class DraftsClient {
123
138
  * @param {AgentMail.inboxes.InboxId} inbox_id
124
139
  * @param {AgentMail.DraftId} draft_id
125
140
  * @param {AgentMail.UpdateMessageRequest} request
126
- * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
141
+ * @param {DraftsClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
127
142
  *
128
143
  * @throws {@link AgentMail.NotFoundError}
129
144
  * @throws {@link AgentMail.ValidationError}
145
+ * @throws {@link AgentMail.ConflictError}
130
146
  * @throws {@link AgentMail.MessageRejectedError}
131
147
  *
132
148
  * @example
133
149
  * await client.inboxes.drafts.send("inbox_id", "draft_id", {})
134
150
  */
135
- send(inbox_id: AgentMail.inboxes.InboxId, draft_id: AgentMail.DraftId, request: AgentMail.UpdateMessageRequest, requestOptions?: DraftsClient.RequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
151
+ send(inbox_id: AgentMail.inboxes.InboxId, draft_id: AgentMail.DraftId, request: AgentMail.UpdateMessageRequest, requestOptions?: DraftsClient.IdempotentRequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
136
152
  private __send;
137
153
  }
@@ -281,6 +281,12 @@ class DraftsClient {
281
281
  });
282
282
  }
283
283
  /**
284
+ * Create a draft. Supply `in_reply_to` to create a reply draft (with
285
+ * `reply_all` to address the whole thread), whose recipients, subject, and
286
+ * threading are derived from the referenced message, or `forward_of` to
287
+ * create a forward draft, which derives the subject, threading, and
288
+ * forwarded content from the source but keeps recipients caller-supplied.
289
+ *
284
290
  * **CLI:**
285
291
  * ```bash
286
292
  * agentmail inboxes:drafts create --inbox-id <inbox_id> --to recipient@example.com --subject "Draft subject" --text "Draft body"
@@ -290,6 +296,7 @@ class DraftsClient {
290
296
  * @param {AgentMail.CreateDraftRequest} request
291
297
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
292
298
  *
299
+ * @throws {@link AgentMail.ValidationError}
293
300
  * @throws {@link AgentMail.NotFoundError}
294
301
  *
295
302
  * @example
@@ -335,6 +342,14 @@ class DraftsClient {
335
342
  }
336
343
  if (_response.error.reason === "status-code") {
337
344
  switch (_response.error.statusCode) {
345
+ case 400:
346
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
347
+ unrecognizedObjectKeys: "passthrough",
348
+ allowUnrecognizedUnionMembers: true,
349
+ allowUnrecognizedEnumValues: true,
350
+ skipValidation: true,
351
+ breadcrumbsPrefix: ["response"],
352
+ }), _response.rawResponse);
338
353
  case 404:
339
354
  throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
340
355
  unrecognizedObjectKeys: "passthrough",
@@ -355,6 +370,10 @@ class DraftsClient {
355
370
  });
356
371
  }
357
372
  /**
373
+ * Edit fields on an existing draft. Passing `null` clears a field (or `[]`
374
+ * for a recipient field); `send_at: null` un-schedules a scheduled draft.
375
+ * A draft that is already being sent cannot be edited.
376
+ *
358
377
  * **CLI:**
359
378
  * ```bash
360
379
  * agentmail inboxes:drafts update --inbox-id <inbox_id> --draft-id <draft_id> --subject "Updated subject"
@@ -365,7 +384,9 @@ class DraftsClient {
365
384
  * @param {AgentMail.UpdateDraftRequest} request
366
385
  * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
367
386
  *
387
+ * @throws {@link AgentMail.ValidationError}
368
388
  * @throws {@link AgentMail.NotFoundError}
389
+ * @throws {@link AgentMail.ConflictError}
369
390
  *
370
391
  * @example
371
392
  * await client.inboxes.drafts.update("inbox_id", "draft_id", {})
@@ -410,6 +431,14 @@ class DraftsClient {
410
431
  }
411
432
  if (_response.error.reason === "status-code") {
412
433
  switch (_response.error.statusCode) {
434
+ case 400:
435
+ throw new AgentMail.ValidationError(serializers.ValidationErrorResponse.parseOrThrow(_response.error.body, {
436
+ unrecognizedObjectKeys: "passthrough",
437
+ allowUnrecognizedUnionMembers: true,
438
+ allowUnrecognizedEnumValues: true,
439
+ skipValidation: true,
440
+ breadcrumbsPrefix: ["response"],
441
+ }), _response.rawResponse);
413
442
  case 404:
414
443
  throw new AgentMail.NotFoundError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
415
444
  unrecognizedObjectKeys: "passthrough",
@@ -418,6 +447,14 @@ class DraftsClient {
418
447
  skipValidation: true,
419
448
  breadcrumbsPrefix: ["response"],
420
449
  }), _response.rawResponse);
450
+ case 409:
451
+ throw new AgentMail.ConflictError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
452
+ unrecognizedObjectKeys: "passthrough",
453
+ allowUnrecognizedUnionMembers: true,
454
+ allowUnrecognizedEnumValues: true,
455
+ skipValidation: true,
456
+ breadcrumbsPrefix: ["response"],
457
+ }), _response.rawResponse);
421
458
  default:
422
459
  throw new errors.AgentMailError({
423
460
  statusCode: _response.error.statusCode,
@@ -497,10 +534,11 @@ class DraftsClient {
497
534
  * @param {AgentMail.inboxes.InboxId} inbox_id
498
535
  * @param {AgentMail.DraftId} draft_id
499
536
  * @param {AgentMail.UpdateMessageRequest} request
500
- * @param {DraftsClient.RequestOptions} requestOptions - Request-specific configuration.
537
+ * @param {DraftsClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
501
538
  *
502
539
  * @throws {@link AgentMail.NotFoundError}
503
540
  * @throws {@link AgentMail.ValidationError}
541
+ * @throws {@link AgentMail.ConflictError}
504
542
  * @throws {@link AgentMail.MessageRejectedError}
505
543
  *
506
544
  * @example
@@ -513,7 +551,7 @@ class DraftsClient {
513
551
  return __awaiter(this, void 0, void 0, function* () {
514
552
  var _a, _b, _c, _d, _e, _f, _g, _h, _j;
515
553
  const _authRequest = yield this._options.authProvider.getAuthRequest();
516
- const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
554
+ const _headers = (0, headers_js_1.mergeHeaders)(_authRequest.headers, (_a = this._options) === null || _a === void 0 ? void 0 : _a.headers, (0, headers_js_1.mergeOnlyDefinedHeaders)({ "Idempotency-Key": requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.idempotencyKey }), requestOptions === null || requestOptions === void 0 ? void 0 : requestOptions.headers);
517
555
  const _response = yield core.fetcher({
518
556
  url: core.url.join((_b = (yield core.Supplier.get(this._options.baseUrl))) !== null && _b !== void 0 ? _b : ((_c = (yield core.Supplier.get(this._options.environment))) !== null && _c !== void 0 ? _c : environments.AgentMailEnvironment.Prod)
519
557
  .http, `/v0/inboxes/${core.url.encodePathParam(serializers.inboxes.InboxId.jsonOrThrow(inbox_id, { omitUndefined: true }))}/drafts/${core.url.encodePathParam(serializers.DraftId.jsonOrThrow(draft_id, { omitUndefined: true }))}/send`),
@@ -562,6 +600,14 @@ class DraftsClient {
562
600
  skipValidation: true,
563
601
  breadcrumbsPrefix: ["response"],
564
602
  }), _response.rawResponse);
603
+ case 409:
604
+ throw new AgentMail.ConflictError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
605
+ unrecognizedObjectKeys: "passthrough",
606
+ allowUnrecognizedUnionMembers: true,
607
+ allowUnrecognizedEnumValues: true,
608
+ skipValidation: true,
609
+ breadcrumbsPrefix: ["response"],
610
+ }), _response.rawResponse);
565
611
  case 403:
566
612
  throw new AgentMail.MessageRejectedError(serializers.ErrorResponse.parseOrThrow(_response.error.body, {
567
613
  unrecognizedObjectKeys: "passthrough",
@@ -1,4 +1,4 @@
1
- import type { BaseClientOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";
1
+ import type { BaseClientOptions, BaseIdempotentRequestOptions, BaseRequestOptions } from "../../../../../../BaseClient.js";
2
2
  import { type NormalizedClientOptionsWithAuth } from "../../../../../../BaseClient.js";
3
3
  import * as core from "../../../../../../core/index.js";
4
4
  import * as AgentMail from "../../../../../index.js";
@@ -6,6 +6,8 @@ export declare namespace MessagesClient {
6
6
  type Options = BaseClientOptions;
7
7
  interface RequestOptions extends BaseRequestOptions {
8
8
  }
9
+ interface IdempotentRequestOptions extends RequestOptions, BaseIdempotentRequestOptions {
10
+ }
9
11
  }
10
12
  export declare class MessagesClient {
11
13
  protected readonly _options: NormalizedClientOptionsWithAuth<MessagesClient.Options>;
@@ -200,16 +202,17 @@ export declare class MessagesClient {
200
202
  *
201
203
  * @param {AgentMail.inboxes.InboxId} inbox_id
202
204
  * @param {AgentMail.SendMessageRequest} request
203
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
205
+ * @param {MessagesClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
204
206
  *
205
207
  * @throws {@link AgentMail.ValidationError}
206
208
  * @throws {@link AgentMail.NotFoundError}
209
+ * @throws {@link AgentMail.ConflictError}
207
210
  * @throws {@link AgentMail.MessageRejectedError}
208
211
  *
209
212
  * @example
210
213
  * await client.inboxes.messages.send("inbox_id", {})
211
214
  */
212
- send(inbox_id: AgentMail.inboxes.InboxId, request: AgentMail.SendMessageRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
215
+ send(inbox_id: AgentMail.inboxes.InboxId, request: AgentMail.SendMessageRequest, requestOptions?: MessagesClient.IdempotentRequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
213
216
  private __send;
214
217
  /**
215
218
  * **CLI:**
@@ -220,16 +223,17 @@ export declare class MessagesClient {
220
223
  * @param {AgentMail.inboxes.InboxId} inbox_id
221
224
  * @param {AgentMail.MessageId} message_id
222
225
  * @param {AgentMail.ReplyToMessageRequest} request
223
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
226
+ * @param {MessagesClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
224
227
  *
225
228
  * @throws {@link AgentMail.ValidationError}
226
229
  * @throws {@link AgentMail.NotFoundError}
230
+ * @throws {@link AgentMail.ConflictError}
227
231
  * @throws {@link AgentMail.MessageRejectedError}
228
232
  *
229
233
  * @example
230
234
  * await client.inboxes.messages.reply("inbox_id", "message_id", {})
231
235
  */
232
- reply(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.ReplyToMessageRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
236
+ reply(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.ReplyToMessageRequest, requestOptions?: MessagesClient.IdempotentRequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
233
237
  private __reply;
234
238
  /**
235
239
  * **CLI:**
@@ -240,16 +244,17 @@ export declare class MessagesClient {
240
244
  * @param {AgentMail.inboxes.InboxId} inbox_id
241
245
  * @param {AgentMail.MessageId} message_id
242
246
  * @param {AgentMail.ReplyAllMessageRequest} request
243
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
247
+ * @param {MessagesClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
244
248
  *
245
249
  * @throws {@link AgentMail.ValidationError}
246
250
  * @throws {@link AgentMail.NotFoundError}
251
+ * @throws {@link AgentMail.ConflictError}
247
252
  * @throws {@link AgentMail.MessageRejectedError}
248
253
  *
249
254
  * @example
250
255
  * await client.inboxes.messages.replyAll("inbox_id", "message_id", {})
251
256
  */
252
- replyAll(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.ReplyAllMessageRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
257
+ replyAll(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.ReplyAllMessageRequest, requestOptions?: MessagesClient.IdempotentRequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
253
258
  private __replyAll;
254
259
  /**
255
260
  * **CLI:**
@@ -260,84 +265,16 @@ export declare class MessagesClient {
260
265
  * @param {AgentMail.inboxes.InboxId} inbox_id
261
266
  * @param {AgentMail.MessageId} message_id
262
267
  * @param {AgentMail.SendMessageRequest} request
263
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
268
+ * @param {MessagesClient.IdempotentRequestOptions} requestOptions - Request-specific configuration.
264
269
  *
265
270
  * @throws {@link AgentMail.ValidationError}
266
271
  * @throws {@link AgentMail.NotFoundError}
272
+ * @throws {@link AgentMail.ConflictError}
267
273
  * @throws {@link AgentMail.MessageRejectedError}
268
274
  *
269
275
  * @example
270
276
  * await client.inboxes.messages.forward("inbox_id", "message_id", {})
271
277
  */
272
- forward(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.SendMessageRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
278
+ forward(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.SendMessageRequest, requestOptions?: MessagesClient.IdempotentRequestOptions): core.HttpResponsePromise<AgentMail.SendMessageResponse>;
273
279
  private __forward;
274
- /**
275
- * Create a draft that replies to a message instead of sending it. The
276
- * recipients, subject, and threading are derived from the source message.
277
- * Send it later with `Send Draft`.
278
- *
279
- * **CLI:**
280
- * ```bash
281
- * agentmail inboxes:messages draft-reply --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"
282
- * ```
283
- *
284
- * @param {AgentMail.inboxes.InboxId} inbox_id
285
- * @param {AgentMail.MessageId} message_id
286
- * @param {AgentMail.CreateDraftReplyRequest} request
287
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
288
- *
289
- * @throws {@link AgentMail.ValidationError}
290
- * @throws {@link AgentMail.NotFoundError}
291
- *
292
- * @example
293
- * await client.inboxes.messages.draftReply("inbox_id", "message_id", {})
294
- */
295
- draftReply(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.CreateDraftReplyRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
296
- private __draftReply;
297
- /**
298
- * Create a draft that replies to every recipient of a message instead of
299
- * sending it. Recipients, subject, and threading are derived from the
300
- * source message. Send it later with `Send Draft`.
301
- *
302
- * **CLI:**
303
- * ```bash
304
- * agentmail inboxes:messages draft-reply-all --inbox-id <inbox_id> --message-id <message_id> --text "Reply text"
305
- * ```
306
- *
307
- * @param {AgentMail.inboxes.InboxId} inbox_id
308
- * @param {AgentMail.MessageId} message_id
309
- * @param {AgentMail.CreateDraftReplyAllRequest} request
310
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
311
- *
312
- * @throws {@link AgentMail.ValidationError}
313
- * @throws {@link AgentMail.NotFoundError}
314
- *
315
- * @example
316
- * await client.inboxes.messages.draftReplyAll("inbox_id", "message_id", {})
317
- */
318
- draftReplyAll(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.CreateDraftReplyAllRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
319
- private __draftReplyAll;
320
- /**
321
- * Create a draft that forwards a message instead of sending it. The subject
322
- * and threading are derived from the source message, whose body and
323
- * attachments are merged in at send time. Send it later with `Send Draft`.
324
- *
325
- * **CLI:**
326
- * ```bash
327
- * agentmail inboxes:messages draft-forward --inbox-id <inbox_id> --message-id <message_id> --to recipient@example.com
328
- * ```
329
- *
330
- * @param {AgentMail.inboxes.InboxId} inbox_id
331
- * @param {AgentMail.MessageId} message_id
332
- * @param {AgentMail.CreateDraftForwardRequest} request
333
- * @param {MessagesClient.RequestOptions} requestOptions - Request-specific configuration.
334
- *
335
- * @throws {@link AgentMail.ValidationError}
336
- * @throws {@link AgentMail.NotFoundError}
337
- *
338
- * @example
339
- * await client.inboxes.messages.draftForward("inbox_id", "message_id", {})
340
- */
341
- draftForward(inbox_id: AgentMail.inboxes.InboxId, message_id: AgentMail.MessageId, request: AgentMail.CreateDraftForwardRequest, requestOptions?: MessagesClient.RequestOptions): core.HttpResponsePromise<AgentMail.Draft>;
342
- private __draftForward;
343
280
  }