@primitivedotdev/sdk 0.8.0 → 0.10.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/dist/index.d.ts CHANGED
@@ -1,12 +1,12 @@
1
- import { AuthConfidence$1 as AuthConfidence, AuthVerdict$1 as AuthVerdict, DkimResult$1 as DkimResult, DkimSignature, DmarcPolicy$1 as DmarcPolicy, DmarcResult$1 as DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType$1 as EventType, ForwardAnalysis, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict$1 as ForwardVerdict, ForwardVerification, KnownWebhookEvent, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus$1 as ParsedStatus, RawContent, RawContentDownloadOnly, RawContentInline, SpfResult$1 as SpfResult, UnknownEvent, ValidateEmailAuthResult, WebhookAttachment, WebhookEvent } from "./types-CIOzt1FY.js";
2
- import { ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, buildForwardSubject$1 as buildForwardSubject, buildReplySubject$1 as buildReplySubject, formatAddress$1 as formatAddress, normalizeReceivedEmail$1 as normalizeReceivedEmail, parseHeaderAddress$1 as parseHeaderAddress } from "./received-email-C67Z7Dha.js";
3
- import { ForwardInput, PrimitiveApiError$1 as PrimitiveApiError, PrimitiveClient$1 as PrimitiveClient, PrimitiveClientOptions, ReplyInput, SendInput, SendResult, SendThreadInput, client$1 as client, createPrimitiveClient$1 as createPrimitiveClient } from "./index-D9lanVFt.js";
4
- import { DecodeRawEmailOptions, GenerateDownloadTokenOptions, HandleWebhookOptions, LEGACY_CONFIRMED_HEADER$1 as LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER$1 as LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS$1 as PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER$1 as PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER$1 as PRIMITIVE_SIGNATURE_HEADER, PrimitiveWebhookError$1 as PrimitiveWebhookError, RAW_EMAIL_ERRORS$1 as RAW_EMAIL_ERRORS, RawEmailDecodeError$1 as RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, STANDARD_WEBHOOK_ID_HEADER$1 as STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER$1 as STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER$1 as STANDARD_WEBHOOK_TIMESTAMP_HEADER, SignResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, VERIFICATION_ERRORS$1 as VERIFICATION_ERRORS, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION$1 as WEBHOOK_VERSION, WebhookErrorCode, WebhookHeaders, WebhookPayloadError$1 as WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError$1 as WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError$1 as WebhookVerificationError, WebhookVerificationErrorCode, confirmedHeaders$1 as confirmedHeaders, decodeRawEmail$1 as decodeRawEmail, emailReceivedEventJsonSchema$1 as emailReceivedEventJsonSchema, generateDownloadToken$1 as generateDownloadToken, getDownloadTimeRemaining$1 as getDownloadTimeRemaining, handleWebhook$1 as handleWebhook, isDownloadExpired$1 as isDownloadExpired, isEmailReceivedEvent$1 as isEmailReceivedEvent, isRawIncluded$1 as isRawIncluded, parseWebhookEvent$1 as parseWebhookEvent, receive$1 as receive, safeValidateEmailReceivedEvent$1 as safeValidateEmailReceivedEvent, signStandardWebhooksPayload$1 as signStandardWebhooksPayload, signWebhookPayload$1 as signWebhookPayload, validateEmailAuth$1 as validateEmailAuth, validateEmailReceivedEvent$1 as validateEmailReceivedEvent, verifyDownloadToken$1 as verifyDownloadToken, verifyRawEmailDownload$1 as verifyRawEmailDownload, verifyStandardWebhooksSignature$1 as verifyStandardWebhooksSignature, verifyWebhookSignature$1 as verifyWebhookSignature } from "./index-CuuP1JkG.js";
1
+ import { A as UnknownEvent, C as ParsedDataFailed, D as RawContentDownloadOnly, E as RawContent, M as WebhookAttachment, N as WebhookEvent, O as RawContentInline, S as ParsedDataComplete, T as ParsedStatus, _ as ForwardResultInline, a as DmarcPolicy, b as KnownWebhookEvent, c as EmailAnalysis, d as EventType, f as ForwardAnalysis, g as ForwardResultAttachmentSkipped, h as ForwardResultAttachmentAnalyzed, i as DkimSignature, j as ValidateEmailAuthResult, k as SpfResult, l as EmailAuth, m as ForwardResult, n as AuthVerdict, o as DmarcResult, p as ForwardOriginalSender, r as DkimResult, s as EmailAddress, t as AuthConfidence, u as EmailReceivedEvent, v as ForwardVerdict, w as ParsedError, x as ParsedData, y as ForwardVerification } from "./types-9vXGZjPd.js";
2
+ import { a as buildReplySubject, c as parseHeaderAddress, i as buildForwardSubject, n as ReceivedEmailAddress, o as formatAddress, r as ReceivedEmailThread, s as normalizeReceivedEmail, t as ReceivedEmail } from "./received-email-DNjpq_Wt.js";
3
+ import { a as PrimitiveApiError, c as PrimitiveClientOptions, d as SendResult, f as SendThreadInput, h as createPrimitiveClient, l as ReplyInput, n as ForwardInput, p as client, s as PrimitiveClient, u as SendInput } from "./index-K4KbjppU.js";
4
+ import { A as VerifyOptions, B as PAYLOAD_ERRORS, C as signStandardWebhooksPayload, D as PRIMITIVE_CONFIRMED_HEADER, E as LEGACY_SIGNATURE_HEADER, F as VerifyDownloadTokenResult, G as VERIFICATION_ERRORS, H as RAW_EMAIL_ERRORS, I as generateDownloadToken, J as WebhookPayloadErrorCode, K as WebhookErrorCode, L as verifyDownloadToken, M as verifyWebhookSignature, N as GenerateDownloadTokenOptions, O as PRIMITIVE_SIGNATURE_HEADER, P as VerifyDownloadTokenOptions, Q as WebhookVerificationErrorCode, R as safeValidateEmailReceivedEvent, S as StandardWebhooksVerifyOptions, T as LEGACY_CONFIRMED_HEADER, U as RawEmailDecodeError, V as PrimitiveWebhookError, W as RawEmailDecodeErrorCode, X as WebhookValidationErrorCode, Y as WebhookValidationError, Z as WebhookVerificationError, _ as emailReceivedEventJsonSchema, a as confirmedHeaders, b as STANDARD_WEBHOOK_TIMESTAMP_HEADER, c as handleWebhook, d as isRawIncluded, f as parseWebhookEvent, g as validateEmailAuth, h as WEBHOOK_VERSION, i as WebhookHeaders, j as signWebhookPayload, k as SignResult, l as isDownloadExpired, m as verifyRawEmailDownload, n as HandleWebhookOptions, o as decodeRawEmail, p as receive, q as WebhookPayloadError, r as ReceiveRequestOptions, s as getDownloadTimeRemaining, t as DecodeRawEmailOptions, u as isEmailReceivedEvent, v as STANDARD_WEBHOOK_ID_HEADER, w as verifyStandardWebhooksSignature, x as StandardWebhooksSignResult, y as STANDARD_WEBHOOK_SIGNATURE_HEADER, z as validateEmailReceivedEvent } from "./index-CbEivn3S.js";
5
5
 
6
6
  //#region src/index.d.ts
7
-
8
7
  declare const primitive: {
9
8
  client: typeof client;
10
9
  receive: typeof receive;
11
- }; //#endregion
12
- export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, ForwardInput, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, GenerateDownloadTokenOptions, HandleWebhookOptions, KnownWebhookEvent, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, PrimitiveApiError, PrimitiveClient, PrimitiveClientOptions, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, ReplyInput, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SendInput, SendResult, SendThreadInput, SignResult, SpfResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, buildForwardSubject, buildReplySubject, client, confirmedHeaders, createPrimitiveClient, decodeRawEmail, primitive as default, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
10
+ };
11
+ //#endregion
12
+ export { AuthConfidence, AuthVerdict, DecodeRawEmailOptions, DkimResult, DkimSignature, DmarcPolicy, DmarcResult, EmailAddress, EmailAnalysis, EmailAuth, EmailReceivedEvent, EventType, ForwardAnalysis, type ForwardInput, ForwardOriginalSender, ForwardResult, ForwardResultAttachmentAnalyzed, ForwardResultAttachmentSkipped, ForwardResultInline, ForwardVerdict, ForwardVerification, GenerateDownloadTokenOptions, HandleWebhookOptions, KnownWebhookEvent, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedData, ParsedDataComplete, ParsedDataFailed, ParsedError, ParsedStatus, PrimitiveApiError, PrimitiveClient, type PrimitiveClientOptions, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawContent, RawContentDownloadOnly, RawContentInline, RawEmailDecodeError, RawEmailDecodeErrorCode, ReceiveRequestOptions, ReceivedEmail, ReceivedEmailAddress, ReceivedEmailThread, type ReplyInput, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, type SendInput, type SendResult, type SendThreadInput, SignResult, SpfResult, StandardWebhooksSignResult, StandardWebhooksVerifyOptions, UnknownEvent, VERIFICATION_ERRORS, ValidateEmailAuthResult, VerifyDownloadTokenOptions, VerifyDownloadTokenResult, VerifyOptions, WEBHOOK_VERSION, WebhookAttachment, WebhookErrorCode, WebhookEvent, WebhookHeaders, WebhookPayloadError, WebhookPayloadErrorCode, WebhookValidationError, WebhookValidationErrorCode, WebhookVerificationError, WebhookVerificationErrorCode, buildForwardSubject, buildReplySubject, client, confirmedHeaders, createPrimitiveClient, decodeRawEmail, primitive as default, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
package/dist/index.js CHANGED
@@ -1,14 +1,10 @@
1
- import "./address-parser-CfPHs3mE.js";
2
- import { buildForwardSubject, buildReplySubject, formatAddress, normalizeReceivedEmail, parseHeaderAddress } from "./received-email-Q6Cha3wc.js";
3
- import { PrimitiveApiError, PrimitiveClient, client, createPrimitiveClient } from "./api-BH8PnmHs.js";
4
- import { AuthConfidence, AuthVerdict, DkimResult, DmarcPolicy, DmarcResult, EventType, ForwardVerdict, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedStatus, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawEmailDecodeError, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, confirmedHeaders, decodeRawEmail, emailReceivedEventJsonSchema, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature } from "./webhook-2TALcBQz.js";
5
-
1
+ import { a as parseHeaderAddress, i as normalizeReceivedEmail, n as buildReplySubject, r as formatAddress, t as buildForwardSubject } from "./received-email-D6tKtWwW.js";
2
+ import { a as client, i as PrimitiveClient, r as PrimitiveApiError, s as createPrimitiveClient } from "./api-CLLpjjWy.js";
3
+ import { A as PRIMITIVE_CONFIRMED_HEADER, B as RAW_EMAIL_ERRORS, C as STANDARD_WEBHOOK_ID_HEADER, D as verifyStandardWebhooksSignature, E as signStandardWebhooksPayload, F as verifyDownloadToken, G as WebhookVerificationError, H as VERIFICATION_ERRORS, I as safeValidateEmailReceivedEvent, L as validateEmailReceivedEvent, M as signWebhookPayload, N as verifyWebhookSignature, O as LEGACY_CONFIRMED_HEADER, P as generateDownloadToken, R as PAYLOAD_ERRORS, S as emailReceivedEventJsonSchema, T as STANDARD_WEBHOOK_TIMESTAMP_HEADER, U as WebhookPayloadError, V as RawEmailDecodeError, W as WebhookValidationError, _ as DmarcResult, a as isDownloadExpired, b as ParsedStatus, c as parseWebhookEvent, d as WEBHOOK_VERSION, f as validateEmailAuth, g as DmarcPolicy, h as DkimResult, i as handleWebhook, j as PRIMITIVE_SIGNATURE_HEADER, k as LEGACY_SIGNATURE_HEADER, l as receive, m as AuthVerdict, n as decodeRawEmail, o as isEmailReceivedEvent, p as AuthConfidence, r as getDownloadTimeRemaining, s as isRawIncluded, t as confirmedHeaders, u as verifyRawEmailDownload, v as EventType, w as STANDARD_WEBHOOK_SIGNATURE_HEADER, x as SpfResult, y as ForwardVerdict, z as PrimitiveWebhookError } from "./webhook-zkN4wUTs.js";
6
4
  //#region src/index.ts
7
5
  const primitive = {
8
6
  client,
9
7
  receive
10
8
  };
11
- var src_default = primitive;
12
-
13
9
  //#endregion
14
- export { AuthConfidence, AuthVerdict, DkimResult, DmarcPolicy, DmarcResult, EventType, ForwardVerdict, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedStatus, PrimitiveApiError, PrimitiveClient, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawEmailDecodeError, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, buildForwardSubject, buildReplySubject, client, confirmedHeaders, createPrimitiveClient, decodeRawEmail, src_default as default, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
10
+ export { AuthConfidence, AuthVerdict, DkimResult, DmarcPolicy, DmarcResult, EventType, ForwardVerdict, LEGACY_CONFIRMED_HEADER, LEGACY_SIGNATURE_HEADER, PAYLOAD_ERRORS, PRIMITIVE_CONFIRMED_HEADER, PRIMITIVE_SIGNATURE_HEADER, ParsedStatus, PrimitiveApiError, PrimitiveClient, PrimitiveWebhookError, RAW_EMAIL_ERRORS, RawEmailDecodeError, STANDARD_WEBHOOK_ID_HEADER, STANDARD_WEBHOOK_SIGNATURE_HEADER, STANDARD_WEBHOOK_TIMESTAMP_HEADER, SpfResult, VERIFICATION_ERRORS, WEBHOOK_VERSION, WebhookPayloadError, WebhookValidationError, WebhookVerificationError, buildForwardSubject, buildReplySubject, client, confirmedHeaders, createPrimitiveClient, decodeRawEmail, primitive as default, emailReceivedEventJsonSchema, formatAddress, generateDownloadToken, getDownloadTimeRemaining, handleWebhook, isDownloadExpired, isEmailReceivedEvent, isRawIncluded, normalizeReceivedEmail, parseHeaderAddress, parseWebhookEvent, receive, safeValidateEmailReceivedEvent, signStandardWebhooksPayload, signWebhookPayload, validateEmailAuth, validateEmailReceivedEvent, verifyDownloadToken, verifyRawEmailDownload, verifyStandardWebhooksSignature, verifyWebhookSignature };
@@ -7,6 +7,82 @@ function flagName(parameterName) {
7
7
  function flagDescription(parameter) {
8
8
  return parameter.description ?? parameter.name;
9
9
  }
10
+ /**
11
+ * Render a one-shot description of a JSON Schema's top-level
12
+ * properties so an agent reading `<command> --help` can build a
13
+ * valid `--body` payload without probing the server. Pulled from
14
+ * the resolved request schema embedded on the manifest.
15
+ *
16
+ * Format prioritizes scanability over completeness: required
17
+ * fields first, each line is `<name> <type> [- description]`
18
+ * truncated to a reasonable width. Callers who need the full
19
+ * schema can run `primitive list-operations | jq` and read
20
+ * `requestSchema` directly.
21
+ */
22
+ function renderRequestSchemaSummary(schema) {
23
+ if (!schema || typeof schema !== "object")
24
+ return null;
25
+ const properties = schema.properties;
26
+ if (!properties || typeof properties !== "object")
27
+ return null;
28
+ const requiredArr = Array.isArray(schema.required)
29
+ ? schema.required.filter((k) => typeof k === "string")
30
+ : [];
31
+ const required = new Set(requiredArr);
32
+ const entries = Object.entries(properties)
33
+ .map(([name, raw]) => {
34
+ const propSchema = raw && typeof raw === "object" ? raw : {};
35
+ let type = "any";
36
+ const t = propSchema.type;
37
+ if (typeof t === "string") {
38
+ type = t;
39
+ if (type === "array") {
40
+ const items = propSchema.items;
41
+ if (items && typeof items === "object") {
42
+ const itemType = items.type;
43
+ if (typeof itemType === "string") {
44
+ type = `array<${itemType}>`;
45
+ }
46
+ }
47
+ }
48
+ }
49
+ else if (Array.isArray(t)) {
50
+ // Nullable shorthand the codegen normalizes to e.g. ["string","null"].
51
+ const nonNull = t.filter((s) => s !== "null");
52
+ type = nonNull.length === 1 ? `${nonNull[0]}?` : nonNull.join("|");
53
+ }
54
+ const description = typeof propSchema.description === "string"
55
+ ? propSchema.description.split("\n")[0].trim()
56
+ : "";
57
+ return {
58
+ name,
59
+ type,
60
+ description,
61
+ required: required.has(name),
62
+ };
63
+ })
64
+ .sort((a, b) => {
65
+ if (a.required !== b.required)
66
+ return a.required ? -1 : 1;
67
+ return a.name.localeCompare(b.name);
68
+ });
69
+ if (entries.length === 0)
70
+ return null;
71
+ const nameWidth = Math.min(24, Math.max(...entries.map((e) => e.name.length)));
72
+ const lines = ["Body fields (JSON --body):"];
73
+ const descMax = 78;
74
+ for (const e of entries) {
75
+ const flag = e.required ? " *" : " ";
76
+ const padName = e.name.padEnd(nameWidth);
77
+ const trimmedDesc = e.description.length > descMax
78
+ ? `${e.description.slice(0, descMax - 3)}...`
79
+ : e.description;
80
+ const desc = trimmedDesc ? ` ${trimmedDesc}` : "";
81
+ lines.push(`${flag} ${padName} ${e.type}${desc}`);
82
+ }
83
+ lines.push("(* = required)");
84
+ return lines.join("\n");
85
+ }
10
86
  export function flagForParameter(parameter) {
11
87
  const common = {
12
88
  description: flagDescription(parameter),
@@ -159,8 +235,20 @@ function collectValues(parameters, flags) {
159
235
  }
160
236
  export function createOperationCommand(operation) {
161
237
  const flags = buildFlags(operation);
238
+ // Append a "Body fields" summary to the description so agents
239
+ // running `<command> --help` learn the JSON shape immediately.
240
+ // Without this, `--help` only said "JSON request body" and agents
241
+ // had to probe the server with malformed payloads to discover
242
+ // required fields. (CLI agent walkthrough surfaced this.)
243
+ const baseDescription = operation.description ?? `${operation.method} ${operation.path}`;
244
+ const schemaSummary = operation.hasJsonBody
245
+ ? renderRequestSchemaSummary(operation.requestSchema)
246
+ : null;
247
+ const fullDescription = schemaSummary
248
+ ? `${baseDescription}\n\n${schemaSummary}`
249
+ : baseDescription;
162
250
  class OperationCommand extends Command {
163
- static description = operation.description ?? `${operation.method} ${operation.path}`;
251
+ static description = fullDescription;
164
252
  static flags = flags;
165
253
  static summary = operation.summary ?? `${operation.method} ${operation.path}`;
166
254
  async run() {
@@ -6,7 +6,6 @@
6
6
  * Run `pnpm generate:openapi` to regenerate.
7
7
  */
8
8
  declare const openapiDocument: Record<string, unknown>;
9
-
10
9
  //#endregion
11
10
  //#region src/openapi/operations.generated.d.ts
12
11
  /**
@@ -33,10 +32,16 @@ type PrimitiveOperationManifest = {
33
32
  path: string;
34
33
  pathParams: PrimitiveParameterManifest[];
35
34
  queryParams: PrimitiveParameterManifest[];
35
+ /**
36
+ * Resolved JSON Schema for the request body when `hasJsonBody` is
37
+ * true. `$ref`s into the OpenAPI components are inlined.
38
+ */
39
+ requestSchema: Record<string, unknown> | null;
36
40
  sdkName: string;
37
41
  summary: string | null;
38
42
  tag: string;
39
43
  tagCommand: string;
40
44
  };
41
- declare const operationManifest: PrimitiveOperationManifest[]; //#endregion
42
- export { PrimitiveOperationManifest, PrimitiveParameterManifest, openapiDocument, operationManifest };
45
+ declare const operationManifest: PrimitiveOperationManifest[];
46
+ //#endregion
47
+ export { type PrimitiveOperationManifest, type PrimitiveParameterManifest, openapiDocument, operationManifest };
@@ -842,6 +842,96 @@ export const openapiDocument = {
842
842
  }
843
843
  }
844
844
  },
845
+ "/emails/{id}/reply": {
846
+ "parameters": [
847
+ {
848
+ "$ref": "#/components/parameters/ResourceId"
849
+ }
850
+ ],
851
+ "post": {
852
+ "operationId": "replyToEmail",
853
+ "summary": "Reply to an inbound email",
854
+ "description": "Sends an outbound reply to the inbound email identified by `id`.\nThreading headers (`In-Reply-To`, `References`), recipient\nderivation (Reply-To, then From, then bare sender), and the\n`Re:` subject prefix are all derived server-side from the\nstored inbound row. The request body carries only the message\nbody and optional `wait` flag; passing any header or recipient\noverride is rejected by the schema (`additionalProperties:\nfalse`).\n\nForwards through the same gates as `/send-mail`: the response\nstatus, error envelope, and `idempotent_replay` flag mirror\nthe send-mail contract verbatim.\n",
855
+ "tags": [
856
+ "Sending"
857
+ ],
858
+ "requestBody": {
859
+ "required": true,
860
+ "content": {
861
+ "application/json": {
862
+ "schema": {
863
+ "$ref": "#/components/schemas/ReplyInput"
864
+ }
865
+ }
866
+ }
867
+ },
868
+ "responses": {
869
+ "200": {
870
+ "description": "Outbound relay result",
871
+ "content": {
872
+ "application/json": {
873
+ "schema": {
874
+ "allOf": [
875
+ {
876
+ "$ref": "#/components/schemas/SuccessEnvelope"
877
+ },
878
+ {
879
+ "type": "object",
880
+ "properties": {
881
+ "data": {
882
+ "$ref": "#/components/schemas/SendMailResult"
883
+ }
884
+ }
885
+ }
886
+ ]
887
+ }
888
+ }
889
+ }
890
+ },
891
+ "400": {
892
+ "$ref": "#/components/responses/ValidationError"
893
+ },
894
+ "401": {
895
+ "$ref": "#/components/responses/Unauthorized"
896
+ },
897
+ "403": {
898
+ "$ref": "#/components/responses/Forbidden"
899
+ },
900
+ "404": {
901
+ "$ref": "#/components/responses/NotFound"
902
+ },
903
+ "422": {
904
+ "description": "Inbound is not repliable: the row exists but lacks a\n`message_id` (no thread anchor) or a `recipient` (cannot\nderive the From address).\n",
905
+ "content": {
906
+ "application/json": {
907
+ "schema": {
908
+ "$ref": "#/components/schemas/ErrorResponse"
909
+ },
910
+ "example": {
911
+ "success": false,
912
+ "error": {
913
+ "code": "inbound_not_repliable",
914
+ "message": "inbound has no Message-ID; cannot anchor a reply thread"
915
+ }
916
+ }
917
+ }
918
+ }
919
+ },
920
+ "429": {
921
+ "$ref": "#/components/responses/RateLimited"
922
+ },
923
+ "500": {
924
+ "$ref": "#/components/responses/InternalError"
925
+ },
926
+ "502": {
927
+ "$ref": "#/components/responses/BadGateway"
928
+ },
929
+ "503": {
930
+ "$ref": "#/components/responses/ServiceUnavailable"
931
+ }
932
+ }
933
+ }
934
+ },
845
935
  "/emails/{id}/replay": {
846
936
  "parameters": [
847
937
  {
@@ -1661,7 +1751,7 @@ export const openapiDocument = {
1661
1751
  "example": {
1662
1752
  "success": false,
1663
1753
  "error": {
1664
- "code": "bad_gateway",
1754
+ "code": "outbound_unreachable",
1665
1755
  "message": "Outbound SMTP service request failed"
1666
1756
  }
1667
1757
  }
@@ -1811,7 +1901,6 @@ export const openapiDocument = {
1811
1901
  "internal_error",
1812
1902
  "conflict",
1813
1903
  "mx_conflict",
1814
- "bad_gateway",
1815
1904
  "outbound_disabled",
1816
1905
  "cannot_send_from_domain",
1817
1906
  "recipient_not_allowed",
@@ -1820,7 +1909,8 @@ export const openapiDocument = {
1820
1909
  "outbound_key_invalid",
1821
1910
  "outbound_capacity_exhausted",
1822
1911
  "outbound_response_malformed",
1823
- "outbound_relay_failed"
1912
+ "outbound_relay_failed",
1913
+ "inbound_not_repliable"
1824
1914
  ]
1825
1915
  },
1826
1916
  "message": {
@@ -2444,6 +2534,20 @@ export const openapiDocument = {
2444
2534
  "null"
2445
2535
  ]
2446
2536
  },
2537
+ "body_text": {
2538
+ "type": [
2539
+ "string",
2540
+ "null"
2541
+ ],
2542
+ "description": "Plain-text body parsed from the inbound MIME, matching the `email.parsed.body_text` field on the webhook payload. Null when the message had no text part or parsing failed."
2543
+ },
2544
+ "body_html": {
2545
+ "type": [
2546
+ "string",
2547
+ "null"
2548
+ ],
2549
+ "description": "HTML body parsed from the inbound MIME, matching the `email.parsed.body_html` field on the webhook payload. Null when the message had no HTML part or parsing failed."
2550
+ },
2447
2551
  "status": {
2448
2552
  "type": "string",
2449
2553
  "enum": [
@@ -2578,6 +2682,17 @@ export const openapiDocument = {
2578
2682
  "to_email": {
2579
2683
  "type": "string",
2580
2684
  "description": "Parsed to address (same as recipient)"
2685
+ },
2686
+ "from_known_address": {
2687
+ "type": "boolean",
2688
+ "description": "True when the inbound's sender address has a matching grant\nin the org's known-send-addresses list. Advisory: a true\nvalue does not by itself guarantee that a reply will be\naccepted by send-mail's gates; the per-send check at send\ntime remains authoritative.\n"
2689
+ },
2690
+ "replies": {
2691
+ "type": "array",
2692
+ "description": "Sent emails recorded as replies to this inbound, in send\norder (ascending). Populated when a customer's send-mail\nrequest carries an `in_reply_to` Message-ID that matches\nthis inbound's `message_id` in the same org. Includes\nattempts that were gate-denied, so the array reflects every\nrecorded reply attempt regardless of outcome.\n",
2693
+ "items": {
2694
+ "$ref": "#/components/schemas/EmailDetailReply"
2695
+ }
2581
2696
  }
2582
2697
  },
2583
2698
  "required": [
@@ -2590,7 +2705,48 @@ export const openapiDocument = {
2590
2705
  "received_at",
2591
2706
  "webhook_attempt_count",
2592
2707
  "from_email",
2593
- "to_email"
2708
+ "to_email",
2709
+ "replies"
2710
+ ]
2711
+ },
2712
+ "EmailDetailReply": {
2713
+ "type": "object",
2714
+ "properties": {
2715
+ "id": {
2716
+ "type": "string",
2717
+ "format": "uuid",
2718
+ "description": "Sent-email row id."
2719
+ },
2720
+ "status": {
2721
+ "$ref": "#/components/schemas/SentEmailStatus"
2722
+ },
2723
+ "to_address": {
2724
+ "type": "string",
2725
+ "description": "Recipient address as recorded on the sent_emails row."
2726
+ },
2727
+ "subject": {
2728
+ "type": [
2729
+ "string",
2730
+ "null"
2731
+ ]
2732
+ },
2733
+ "created_at": {
2734
+ "type": "string",
2735
+ "format": "date-time"
2736
+ },
2737
+ "queue_id": {
2738
+ "type": [
2739
+ "string",
2740
+ "null"
2741
+ ],
2742
+ "description": "Outbound relay queue identifier when available."
2743
+ }
2744
+ },
2745
+ "required": [
2746
+ "id",
2747
+ "status",
2748
+ "to_address",
2749
+ "created_at"
2594
2750
  ]
2595
2751
  },
2596
2752
  "SendMailInput": {
@@ -2680,6 +2836,31 @@ export const openapiDocument = {
2680
2836
  "wait_timeout"
2681
2837
  ]
2682
2838
  },
2839
+ "ReplyInput": {
2840
+ "type": "object",
2841
+ "additionalProperties": false,
2842
+ "description": "Body shape for `/emails/{id}/reply`. Intentionally narrow:\nrecipients (`to`), subject, and threading headers\n(`in_reply_to`, `references`) are derived server-side from\nthe inbound row referenced by the path id and are rejected by\n`additionalProperties` if passed (returns 400).\n\n`from` IS allowed because of legitimate use cases (display-name\naddition, replying from a different verified outbound address,\nmulti-team triage). Send-mail's per-send `canSendFrom` gate\nvalidates the from-domain regardless, so the override carries\nno extra privilege.\n",
2843
+ "properties": {
2844
+ "body_text": {
2845
+ "type": "string",
2846
+ "description": "Plain-text reply body. At least one of body_text or body_html is required. The combined UTF-8 byte length of body_text and body_html must be at most 262144 bytes (same cap as send-mail)."
2847
+ },
2848
+ "body_html": {
2849
+ "type": "string",
2850
+ "description": "HTML reply body. At least one of body_text or body_html is required."
2851
+ },
2852
+ "from": {
2853
+ "type": "string",
2854
+ "minLength": 3,
2855
+ "maxLength": 998,
2856
+ "description": "Optional override for the reply's From header. Defaults to\nthe inbound's recipient. Use to add a display name (`\"Acme\nSupport\" <agent@company.com>`) or to reply from a different\nverified outbound address (e.g. multi-team routing where\nsupport@ triages to billing@). The from-domain must be a\nverified outbound domain for your org, same as send-mail.\n"
2857
+ },
2858
+ "wait": {
2859
+ "type": "boolean",
2860
+ "description": "When true, wait for the first downstream SMTP delivery outcome before returning, mirroring the send-mail `wait` semantics."
2861
+ }
2862
+ }
2863
+ },
2683
2864
  "SendMailResult": {
2684
2865
  "type": "object",
2685
2866
  "properties": {
@@ -2736,6 +2917,10 @@ export const openapiDocument = {
2736
2917
  "smtp_response_text": {
2737
2918
  "type": "string",
2738
2919
  "description": "SMTP response text from the first downstream delivery outcome when wait is true."
2920
+ },
2921
+ "idempotent_replay": {
2922
+ "type": "boolean",
2923
+ "description": "True when the response replays a previously-recorded send\nkeyed by `client_idempotency_key` (same key, same canonical\npayload). False on a fresh send and on gate-denied\nresponses. Lets callers branch on cache state without\ndiffing fields.\n"
2739
2924
  }
2740
2925
  },
2741
2926
  "required": [
@@ -2746,7 +2931,8 @@ export const openapiDocument = {
2746
2931
  "rejected",
2747
2932
  "client_idempotency_key",
2748
2933
  "request_id",
2749
- "content_hash"
2934
+ "content_hash",
2935
+ "idempotent_replay"
2750
2936
  ]
2751
2937
  },
2752
2938
  "Endpoint": {