@oxygen-agent/cli 1.1014.1597 → 1.1014.1598
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -117,8 +117,30 @@ const MICROSOFT_BODY = /(microsoft exchange|exchange server|office\s?365)/i;
|
|
|
117
117
|
// Enhanced status code (RFC 3463): class.subject.detail, where subject/detail can
|
|
118
118
|
// be multi-digit (Google emits 5.7.708). Kept separate from the bare 3-digit SMTP
|
|
119
119
|
// reply so a caller can tell "550" from "5.7.1".
|
|
120
|
-
const ENHANCED_CODE = /\b
|
|
120
|
+
const ENHANCED_CODE = /\b[2-5]\.\d{1,3}\.\d{1,3}\b/;
|
|
121
121
|
const SMTP_REPLY_CODE = /\b([2-5]\d{2})\b/;
|
|
122
|
+
// Reported status fields outrank prose and SMTP examples in quoted help text.
|
|
123
|
+
// Exchange's 5.4.14 loop report includes a 5.1.1 help article and generic
|
|
124
|
+
// "Recipient Unknown" instructions before its actual status/diagnostic.
|
|
125
|
+
const REPORTED_ENHANCED_CODES = [
|
|
126
|
+
/(?:^|\n)[ \t]*Status[ \t]*:[ \t]*([2-5]\.\d{1,3}\.\d{1,3})\b/im,
|
|
127
|
+
/(?:^|\n)[ \t]*Diagnostic-Code[ \t]*:[ \t]*smtp[ \t]*;[ \t]*(?:[2-5]\d{2}[ -]+)?([2-5]\.\d{1,3}\.\d{1,3})\b/im,
|
|
128
|
+
/(?:^|\n)[ \t]*(?:Status[ \t]+code[ \t]*:?|Error[ \t]*:)[ \t]*(?:[2-5]\d{2}[ -]+)?([2-5]\.\d{1,3}\.\d{1,3})\b/im,
|
|
129
|
+
/\b(?:the response(?: from the remote server)? was|remote server returned)[ \t]*:?[ \t]*['"]?(?:[2-5]\d{2}[ -]+)?([2-5]\.\d{1,3}\.\d{1,3})\b/i,
|
|
130
|
+
/\b[2-5]\d{2}[ -]+([2-5]\.\d{1,3}\.\d{1,3})\b/,
|
|
131
|
+
/(?:^|\n)[ \t]*([2-5]\.\d{1,3}\.\d{1,3})\b/,
|
|
132
|
+
];
|
|
133
|
+
function readEnhancedStatusCode(haystack) {
|
|
134
|
+
for (const pattern of REPORTED_ENHANCED_CODES) {
|
|
135
|
+
const code = pattern.exec(haystack)?.[1];
|
|
136
|
+
if (code)
|
|
137
|
+
return code;
|
|
138
|
+
}
|
|
139
|
+
// Unscoped codes can retain a policy/quota/routing verdict, but cannot prove
|
|
140
|
+
// an invalid destination: that code may only be in a generic help article.
|
|
141
|
+
return haystack.match(/\b[2-5]\.\d{1,3}\.\d{1,3}\b/g)
|
|
142
|
+
?.find(code => !NO_SUCH_USER_CODE.test(code)) ?? null;
|
|
143
|
+
}
|
|
122
144
|
const REPUTATION_BLOCK = /\b5\.7\.\d{1,3}\b/;
|
|
123
145
|
const MAILBOX_FULL_CODE = /\b[45]\.2\.2\b/;
|
|
124
146
|
// 5.1.0 is a generic address-status failure, not proof the recipient is invalid.
|
|
@@ -156,21 +178,32 @@ function readProvider(from, haystack) {
|
|
|
156
178
|
return "microsoft";
|
|
157
179
|
return "unknown";
|
|
158
180
|
}
|
|
159
|
-
function readKind(subject, haystack, hasBody) {
|
|
181
|
+
function readKind(subject, haystack, hasBody, enhancedCode) {
|
|
160
182
|
// Order is load-bearing. A Google "(Delay)" report can quote block-sounding
|
|
161
183
|
// prose while the message is still queued, so the transient marker wins first;
|
|
162
184
|
// an explicit enhanced code then beats keyword matching, because "blocked" and
|
|
163
185
|
// "spam" appear in boilerplate that a 5.1.1 no-such-user report also carries.
|
|
164
186
|
if (/\(delay\)/i.test(subject))
|
|
165
187
|
return "delayed";
|
|
166
|
-
if (
|
|
167
|
-
|
|
168
|
-
|
|
188
|
+
if (enhancedCode) {
|
|
189
|
+
if (REPUTATION_BLOCK.test(enhancedCode))
|
|
190
|
+
return "provider_rejected";
|
|
191
|
+
if (MAILBOX_FULL_CODE.test(enhancedCode))
|
|
192
|
+
return "mailbox_full";
|
|
193
|
+
if (NO_SUCH_USER_CODE.test(enhancedCode))
|
|
194
|
+
return "no_such_user";
|
|
195
|
+
if (enhancedCode.startsWith("4."))
|
|
196
|
+
return "delayed";
|
|
197
|
+
// An explicit generic/routing failure is not address-nonexistence evidence,
|
|
198
|
+
// even when the surrounding help text suggests checking the address.
|
|
199
|
+
return "other";
|
|
200
|
+
}
|
|
201
|
+
if (MAILBOX_FULL_TEXT.test(haystack))
|
|
169
202
|
return "mailbox_full";
|
|
170
|
-
if (NO_SUCH_USER_CODE.test(haystack))
|
|
171
|
-
return "no_such_user";
|
|
172
203
|
if (PROVIDER_REJECTED_TEXT.test(haystack))
|
|
173
204
|
return "provider_rejected";
|
|
205
|
+
if (ENHANCED_CODE.test(haystack))
|
|
206
|
+
return "other";
|
|
174
207
|
if (NO_SUCH_USER_TEXT.test(haystack))
|
|
175
208
|
return "no_such_user";
|
|
176
209
|
if (TRANSIENT_CODE.test(haystack) || TRANSIENT_TEXT.test(haystack))
|
|
@@ -193,9 +226,10 @@ export function classifyDeliveryStatusNotification(input) {
|
|
|
193
226
|
if (!DSN_FROM_PATTERN.test(from) && !DSN_SUBJECT_PATTERN.test(subject))
|
|
194
227
|
return null;
|
|
195
228
|
const haystack = `${subject}\n${body}`;
|
|
196
|
-
const
|
|
229
|
+
const enhancedCode = readEnhancedStatusCode(haystack);
|
|
230
|
+
const smtpCode = enhancedCode ?? (ENHANCED_CODE.test(haystack) ? null : SMTP_REPLY_CODE.exec(haystack)?.[1] ?? null);
|
|
197
231
|
return {
|
|
198
|
-
kind: readKind(subject, haystack, body.trim().length > 0),
|
|
232
|
+
kind: readKind(subject, haystack, body.trim().length > 0, enhancedCode),
|
|
199
233
|
provider: readProvider(from, haystack),
|
|
200
234
|
recipient: readRecipient(haystack),
|
|
201
235
|
smtpCode,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const OXYGEN_BUILD_VERSION = "1.1014.
|
|
1
|
+
export declare const OXYGEN_BUILD_VERSION = "1.1014.1598";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// GENERATED by scripts/ci/version-stamp.mjs from VERSION + git history. Do not edit; do not commit.
|
|
2
|
-
export const OXYGEN_BUILD_VERSION = "1.1014.
|
|
2
|
+
export const OXYGEN_BUILD_VERSION = "1.1014.1598";
|