@tormentalabs/claude-code-wire-compat 0.7.1 → 0.8.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.
Files changed (88) hide show
  1. package/CHANGELOG.md +74 -0
  2. package/README.md +27 -4
  3. package/dist/account-features.d.ts +11 -0
  4. package/dist/account-features.d.ts.map +1 -0
  5. package/dist/account-features.js +98 -0
  6. package/dist/account-features.js.map +1 -0
  7. package/dist/anti-verbosity.d.ts.map +1 -1
  8. package/dist/anti-verbosity.js +3 -3
  9. package/dist/anti-verbosity.js.map +1 -1
  10. package/dist/betas.d.ts +74 -2
  11. package/dist/betas.d.ts.map +1 -1
  12. package/dist/betas.js +158 -18
  13. package/dist/betas.js.map +1 -1
  14. package/dist/build-request.d.ts.map +1 -1
  15. package/dist/build-request.js +201 -19
  16. package/dist/build-request.js.map +1 -1
  17. package/dist/contracts.d.ts +181 -2
  18. package/dist/contracts.d.ts.map +1 -1
  19. package/dist/contracts.js.map +1 -1
  20. package/dist/fingerprint.d.ts +28 -5
  21. package/dist/fingerprint.d.ts.map +1 -1
  22. package/dist/fingerprint.js +63 -5
  23. package/dist/fingerprint.js.map +1 -1
  24. package/dist/headers.d.ts +60 -1
  25. package/dist/headers.d.ts.map +1 -1
  26. package/dist/headers.js +176 -23
  27. package/dist/headers.js.map +1 -1
  28. package/dist/index.d.ts +4 -2
  29. package/dist/index.d.ts.map +1 -1
  30. package/dist/index.js +3 -1
  31. package/dist/index.js.map +1 -1
  32. package/dist/model-capabilities.d.ts +8 -4
  33. package/dist/model-capabilities.d.ts.map +1 -1
  34. package/dist/model-capabilities.js +14 -7
  35. package/dist/model-capabilities.js.map +1 -1
  36. package/dist/model-identity.d.ts +15 -2
  37. package/dist/model-identity.d.ts.map +1 -1
  38. package/dist/model-identity.js +44 -1
  39. package/dist/model-identity.js.map +1 -1
  40. package/dist/model-queries.d.ts +11 -1
  41. package/dist/model-queries.d.ts.map +1 -1
  42. package/dist/model-queries.js +51 -7
  43. package/dist/model-queries.js.map +1 -1
  44. package/dist/models.d.ts.map +1 -1
  45. package/dist/models.js +2 -2
  46. package/dist/models.js.map +1 -1
  47. package/dist/profile-behaviors.d.ts +72 -0
  48. package/dist/profile-behaviors.d.ts.map +1 -1
  49. package/dist/profile-behaviors.js +66 -15
  50. package/dist/profile-behaviors.js.map +1 -1
  51. package/dist/profiles/beta-registry-2.1.329.d.ts +229 -0
  52. package/dist/profiles/beta-registry-2.1.329.d.ts.map +1 -0
  53. package/dist/profiles/beta-registry-2.1.329.js +281 -0
  54. package/dist/profiles/beta-registry-2.1.329.js.map +1 -0
  55. package/dist/profiles/claude-code-2.1.329.d.ts +3 -0
  56. package/dist/profiles/claude-code-2.1.329.d.ts.map +1 -0
  57. package/dist/profiles/claude-code-2.1.329.js +466 -0
  58. package/dist/profiles/claude-code-2.1.329.js.map +1 -0
  59. package/dist/redaction.d.ts.map +1 -1
  60. package/dist/redaction.js +1 -0
  61. package/dist/redaction.js.map +1 -1
  62. package/dist/request-body.d.ts +27 -1
  63. package/dist/request-body.d.ts.map +1 -1
  64. package/dist/request-body.js +184 -16
  65. package/dist/request-body.js.map +1 -1
  66. package/dist/tools-used.d.ts +52 -0
  67. package/dist/tools-used.d.ts.map +1 -0
  68. package/dist/tools-used.js +116 -0
  69. package/dist/tools-used.js.map +1 -0
  70. package/package.json +5 -1
  71. package/src/account-features.ts +114 -0
  72. package/src/anti-verbosity.ts +8 -3
  73. package/src/betas.ts +252 -22
  74. package/src/build-request.ts +245 -22
  75. package/src/contracts.ts +185 -3
  76. package/src/fingerprint.ts +84 -7
  77. package/src/headers.ts +221 -21
  78. package/src/index.ts +10 -0
  79. package/src/model-capabilities.ts +16 -7
  80. package/src/model-identity.ts +62 -2
  81. package/src/model-queries.ts +71 -8
  82. package/src/models.ts +2 -1
  83. package/src/profile-behaviors.ts +150 -16
  84. package/src/profiles/beta-registry-2.1.329.ts +298 -0
  85. package/src/profiles/claude-code-2.1.329.ts +471 -0
  86. package/src/redaction.ts +1 -0
  87. package/src/request-body.ts +242 -17
  88. package/src/tools-used.ts +134 -0
@@ -0,0 +1,471 @@
1
+ // SPDX-License-Identifier: GPL-3.0-or-later
2
+
3
+ import type { ClaudeCodeProtocolProfile } from "../contracts.js";
4
+ import { COUNT_TOKENS_ENDPOINT } from "../count-tokens.js";
5
+
6
+ /*
7
+ * Protocol profile for genuine client 2.1.329.
8
+ *
9
+ * Provenance: extracted from the official 2.1.329 win32-x64 binary and
10
+ * recorded in `docs/protocol/versions/claude-code-2.1.329-analysis.md`. The
11
+ * scalars and the catalogue below were checked entry by entry against the
12
+ * extractor report for that build (`npm run extract:profile` over the carved
13
+ * multi-module dump), not against the 2.1.280 profile.
14
+ *
15
+ * The catalogue holds 24 entries in the extractor's order. The report also
16
+ * lists three bare dated ids at its end (`claude-haiku-4-5-20251001`,
17
+ * `claude-opus-4-1-20250805`, `claude-opus-4-5-20251101`). They carry no
18
+ * family, capabilities or limits: they belong to a second, unrelated model
19
+ * list that the widened search space of a multi-module dump picks up, exactly
20
+ * as three spurious entries leaked in at 2.1.280. They are EXCLUDED.
21
+ *
22
+ * Capability strings are copied verbatim from the report, including the ones
23
+ * `deriveCapabilitiesFromCatalogue` does not map (`total_tokens_reminder`,
24
+ * `tool_loaded_text`, `org_locked_thinking`, `silent_turn_reminder`, ...). The
25
+ * catalogue is a faithful transcription and the capability set is a free list
26
+ * of strings, so an unmapped string is data, not an error. `mid_conv_system`
27
+ * no longer appears on any entry: the beta graduated and the catalogue string
28
+ * went with it (analysis document section 5.3).
29
+ *
30
+ * Not modelled, as at 2.1.280: `supports_1m_suffix` (an entry declaring a
31
+ * 200000 window with nothing but that flag carries no `context` object), and
32
+ * the catalogue fields `advisor_rank`, `pricing`, `effort_cost_index`,
33
+ * `maximum_window`, `clamp_long_context_without_beta`, `fallback_chain`,
34
+ * `picker`, `deprecation`, `min_cli_version` and `slogan`.
35
+ *
36
+ * `runtimeVersion` and `oauthAuthorizeScopes` are optional profile data that
37
+ * older profiles omit, so their output is untouched. Both are `[LIVE]` values
38
+ * from a genuine 2.1.329 session and are data only: this package neither
39
+ * applies the runtime version (the caller still supplies
40
+ * `runtime.runtimeVersion`) nor builds an authorize URL.
41
+ */
42
+
43
+ function deepFreeze<T>(value: T): T {
44
+ if (value !== null && typeof value === "object") {
45
+ for (const key of Reflect.ownKeys(value)) {
46
+ deepFreeze(Reflect.get(value, key));
47
+ }
48
+ Object.freeze(value);
49
+ }
50
+ return value;
51
+ }
52
+
53
+ export const CLAUDE_CODE_2_1_329_PROFILE: ClaudeCodeProtocolProfile =
54
+ deepFreeze({
55
+ id: "claude-code-2.1.329-sdk-0.128.0",
56
+ cliVersion: "2.1.329",
57
+ sdkVersion: "0.128.0",
58
+ endpoint: "https://api.anthropic.com/v1/messages?beta=true",
59
+ countTokensEndpoint: COUNT_TOKENS_ENDPOINT,
60
+ entrypoint: "cli",
61
+ userAgent: "claude-cli/2.1.329 (external, cli)",
62
+ buildTime: "2026-11-19T16:23:05Z",
63
+ gitSha: "6a49dd29d929a6fe40c060bbccfeb5a7f037c958",
64
+ // [LIVE]. The interactive OAuth captures carry the billing block, so this
65
+ // is now evidenced rather than retained.
66
+ attributionHeaderEnabled: true,
67
+ provider: "anthropic",
68
+ anthropicVersion: "2023-06-01",
69
+ // `context_hint` remains off: the live default-path beta list contains no
70
+ // `context-hint` identifier.
71
+ contextHintEnabled: false,
72
+ /*
73
+ * The eleven flags of the 2.1.280 profile, unchanged. `afkModeEnabled`
74
+ * stays `false` and is RETAINED, not re-derived: its gates are still
75
+ * unresolved. The live interactive capture does list `afk-mode`; that is a
76
+ * recorded divergence of the default composition, not something this
77
+ * profile asserts.
78
+ */
79
+ betaPolicy: {
80
+ oauthAuthenticated: true,
81
+ experimentalBetasEnabled: true,
82
+ oneMillionContextEnabled: true,
83
+ interleavedThinkingEnabled: true,
84
+ interactive: true,
85
+ thinkingSummariesShown: false,
86
+ thinkingTokenCountEnabled: true,
87
+ narrationSummariesEnabled: false,
88
+ structuredOutputsEnabled: false,
89
+ afkModeEnabled: false,
90
+ cacheDiagnosisEnabled: true,
91
+ },
92
+ /** `X-Stainless-Runtime-Version` the genuine binary reports. [LIVE] */
93
+ runtimeVersion: "v26.12.1",
94
+ /** Scopes of the `claude auth login --claudeai` authorize URL. [LIVE] */
95
+ oauthAuthorizeScopes: [
96
+ "org:create_api_key",
97
+ "user:profile",
98
+ "user:inference",
99
+ "user:sessions:claude_code",
100
+ "user:mcp_servers",
101
+ "user:file_upload",
102
+ "user:plugins",
103
+ "user:privacy_consents:write",
104
+ "org:desktop_config",
105
+ ],
106
+ /**
107
+ * Verbatim genuine-client catalogue, 24 entries in the catalogue's own
108
+ * order. `defaultEffort` is policy exposed as catalogue data; this package
109
+ * must never apply it to a request.
110
+ */
111
+ supportedModels: {
112
+ "claude-3-5-haiku": {
113
+ family: "haiku",
114
+ capabilities: ["total_tokens_reminder", "tool_loaded_text"],
115
+ maxOutputTokens: { default: 8192, upper: 8192 },
116
+ },
117
+ "claude-haiku-4-5": {
118
+ family: "haiku",
119
+ capabilities: [
120
+ "context_management",
121
+ "total_tokens_reminder",
122
+ "tool_loaded_text",
123
+ ],
124
+ maxOutputTokens: { default: 32000, upper: 64000 },
125
+ },
126
+ // New at 2.1.329.
127
+ "claude-haiku-5-5": {
128
+ family: "haiku",
129
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
130
+ maxOutputTokens: { default: 128000, upper: 128000 },
131
+ capabilities: [
132
+ "effort",
133
+ "max_effort",
134
+ "xhigh_effort",
135
+ "adaptive_thinking",
136
+ "mid_conv_tool_change",
137
+ "context_management",
138
+ "rejects_disabled_thinking",
139
+ "per_turn_effort",
140
+ "lean_prompt",
141
+ "org_locked_thinking",
142
+ "haiku_5_5_early_stopping_guidance",
143
+ "total_tokens_reminder",
144
+ "tool_loaded_text",
145
+ ],
146
+ defaultEffort: "medium",
147
+ },
148
+ "claude-3-5-sonnet": {
149
+ family: "sonnet",
150
+ capabilities: ["total_tokens_reminder", "tool_loaded_text"],
151
+ maxOutputTokens: { default: 8192, upper: 8192 },
152
+ },
153
+ "claude-3-7-sonnet": {
154
+ family: "sonnet",
155
+ capabilities: ["total_tokens_reminder", "tool_loaded_text"],
156
+ maxOutputTokens: { default: 32000, upper: 64000 },
157
+ },
158
+ "claude-sonnet-4-0": {
159
+ family: "sonnet",
160
+ context: { window: 200000, supports1mBeta: true },
161
+ capabilities: [
162
+ "context_management",
163
+ "total_tokens_reminder",
164
+ "tool_loaded_text",
165
+ ],
166
+ maxOutputTokens: { default: 32000, upper: 64000 },
167
+ },
168
+ "claude-sonnet-4-5": {
169
+ family: "sonnet",
170
+ context: { window: 200000, supports1mBeta: true },
171
+ capabilities: [
172
+ "context_management",
173
+ "total_tokens_reminder",
174
+ "tool_loaded_text",
175
+ ],
176
+ maxOutputTokens: { default: 32000, upper: 64000 },
177
+ },
178
+ "claude-sonnet-4-6": {
179
+ family: "sonnet",
180
+ context: { window: 200000, supports1mBeta: true },
181
+ maxOutputTokens: { default: 32000, upper: 128000 },
182
+ capabilities: [
183
+ "effort",
184
+ "max_effort",
185
+ "adaptive_thinking",
186
+ "context_management",
187
+ "total_tokens_reminder",
188
+ "tool_loaded_text",
189
+ ],
190
+ },
191
+ "claude-sonnet-5": {
192
+ family: "sonnet",
193
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
194
+ maxOutputTokens: { default: 64000, upper: 128000 },
195
+ capabilities: [
196
+ "effort",
197
+ "max_effort",
198
+ "xhigh_effort",
199
+ "adaptive_thinking",
200
+ "context_management",
201
+ "total_tokens_reminder",
202
+ "tool_loaded_text",
203
+ ],
204
+ defaultEffort: "high",
205
+ },
206
+ // New at 2.1.329. The only entry carrying `silent_turn_reminder`.
207
+ "claude-sonnet-5-5": {
208
+ family: "sonnet",
209
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
210
+ maxOutputTokens: { default: 128000, upper: 128000 },
211
+ capabilities: [
212
+ "effort",
213
+ "max_effort",
214
+ "xhigh_effort",
215
+ "adaptive_thinking",
216
+ "mid_conv_tool_change",
217
+ "context_management",
218
+ "rejects_disabled_thinking",
219
+ "per_turn_effort",
220
+ "per_turn_timing",
221
+ "lean_prompt",
222
+ "refusal_fallback",
223
+ "silent_turn_reminder",
224
+ "org_locked_thinking",
225
+ "tool_loaded_text",
226
+ ],
227
+ defaultEffort: "medium",
228
+ },
229
+ "claude-opus-4-0": {
230
+ family: "opus",
231
+ capabilities: [
232
+ "context_management",
233
+ "total_tokens_reminder",
234
+ "tool_loaded_text",
235
+ ],
236
+ maxOutputTokens: { default: 32000, upper: 32000 },
237
+ },
238
+ "claude-opus-4-1": {
239
+ family: "opus",
240
+ capabilities: [
241
+ "context_management",
242
+ "total_tokens_reminder",
243
+ "tool_loaded_text",
244
+ ],
245
+ maxOutputTokens: { default: 32000, upper: 32000 },
246
+ },
247
+ "claude-opus-4-5": {
248
+ family: "opus",
249
+ capabilities: [
250
+ "context_management",
251
+ "total_tokens_reminder",
252
+ "tool_loaded_text",
253
+ ],
254
+ maxOutputTokens: { default: 32000, upper: 64000 },
255
+ },
256
+ "claude-opus-4-6": {
257
+ family: "opus",
258
+ context: { window: 200000, supports1mBeta: true },
259
+ maxOutputTokens: { default: 64000, upper: 128000 },
260
+ capabilities: [
261
+ "effort",
262
+ "max_effort",
263
+ "adaptive_thinking",
264
+ "context_management",
265
+ "total_tokens_reminder",
266
+ "tool_loaded_text",
267
+ ],
268
+ },
269
+ "claude-opus-4-7": {
270
+ family: "opus",
271
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
272
+ maxOutputTokens: { default: 64000, upper: 128000 },
273
+ capabilities: [
274
+ "effort",
275
+ "max_effort",
276
+ "xhigh_effort",
277
+ "adaptive_thinking",
278
+ "context_management",
279
+ "total_tokens_reminder",
280
+ "tool_loaded_text",
281
+ ],
282
+ defaultEffort: "xhigh",
283
+ },
284
+ "claude-opus-4-8": {
285
+ family: "opus",
286
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
287
+ maxOutputTokens: { default: 64000, upper: 128000 },
288
+ capabilities: [
289
+ "effort",
290
+ "max_effort",
291
+ "xhigh_effort",
292
+ "adaptive_thinking",
293
+ "mid_conv_tool_change",
294
+ "context_management",
295
+ "fast_mode",
296
+ "lean_prompt",
297
+ "total_tokens_reminder",
298
+ "tool_loaded_text",
299
+ "send_user_file_input_whole",
300
+ ],
301
+ defaultEffort: "high",
302
+ },
303
+ "claude-opus-5": {
304
+ family: "opus",
305
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
306
+ maxOutputTokens: { default: 64000, upper: 128000 },
307
+ capabilities: [
308
+ "effort",
309
+ "max_effort",
310
+ "xhigh_effort",
311
+ "adaptive_thinking",
312
+ "mid_conv_tool_change",
313
+ "context_management",
314
+ "thinking_disabled_effort_cap",
315
+ "fast_mode",
316
+ "lean_prompt",
317
+ "refusal_fallback",
318
+ "opus_5_prompt_bundle",
319
+ "total_tokens_reminder",
320
+ "tool_loaded_text",
321
+ "send_user_file_input_whole",
322
+ ],
323
+ defaultEffort: "high",
324
+ },
325
+ // Carries no `total_tokens_reminder`, as `claude-sonnet-5-5`,
326
+ // `claude-fable-5-2` and `claude-mythos-5-2` do not either.
327
+ "claude-opus-5-5": {
328
+ family: "opus",
329
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
330
+ maxOutputTokens: { default: 128000, upper: 128000 },
331
+ capabilities: [
332
+ "effort",
333
+ "max_effort",
334
+ "xhigh_effort",
335
+ "adaptive_thinking",
336
+ "rejects_disabled_thinking",
337
+ "mid_conv_tool_change",
338
+ "per_turn_effort",
339
+ "per_turn_timing",
340
+ "context_management",
341
+ "fast_mode",
342
+ "lean_prompt",
343
+ "refusal_fallback",
344
+ "opus_5_5_prompt_bundle",
345
+ "tool_loaded_text",
346
+ ],
347
+ defaultEffort: "medium",
348
+ },
349
+ "claude-fable-5": {
350
+ family: "fable",
351
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
352
+ maxOutputTokens: { default: 64000, upper: 128000 },
353
+ capabilities: [
354
+ "effort",
355
+ "max_effort",
356
+ "xhigh_effort",
357
+ "adaptive_thinking",
358
+ "rejects_disabled_thinking",
359
+ "mid_conv_tool_change",
360
+ "context_management",
361
+ "lean_prompt",
362
+ "fable_5_mitigations",
363
+ "refusal_fallback",
364
+ "total_tokens_reminder",
365
+ "tool_loaded_text",
366
+ ],
367
+ defaultEffort: "high",
368
+ },
369
+ "claude-fable-5-1": {
370
+ family: "fable",
371
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
372
+ maxOutputTokens: { default: 64000, upper: 128000 },
373
+ capabilities: [
374
+ "effort",
375
+ "max_effort",
376
+ "xhigh_effort",
377
+ "adaptive_thinking",
378
+ "rejects_disabled_thinking",
379
+ "mid_conv_tool_change",
380
+ "per_turn_effort",
381
+ "per_turn_timing",
382
+ "context_management",
383
+ "lean_prompt",
384
+ "fable_5_mitigations",
385
+ "refusal_fallback",
386
+ "fable_5_1_prompt_bundle",
387
+ "total_tokens_reminder",
388
+ "tool_loaded_text",
389
+ ],
390
+ defaultEffort: "high",
391
+ },
392
+ // New at 2.1.329. Declares `vertex_fast_mode` and `script_output_cost`,
393
+ // neither of which is mapped by this package.
394
+ "claude-fable-5-2": {
395
+ family: "fable",
396
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
397
+ maxOutputTokens: { default: 128000, upper: 128000 },
398
+ capabilities: [
399
+ "effort",
400
+ "max_effort",
401
+ "xhigh_effort",
402
+ "adaptive_thinking",
403
+ "rejects_disabled_thinking",
404
+ "mid_conv_tool_change",
405
+ "per_turn_effort",
406
+ "per_turn_timing",
407
+ "context_management",
408
+ "fast_mode",
409
+ "vertex_fast_mode",
410
+ "lean_prompt",
411
+ "script_output_cost",
412
+ "refusal_fallback",
413
+ "org_locked_thinking",
414
+ "fable_5_2_prompt_bundle",
415
+ ],
416
+ defaultEffort: "medium",
417
+ },
418
+ // The empty-of-features entry is a denial, not a gap: no effort, no
419
+ // adaptive thinking, only the two reminder strings.
420
+ "claude-mythos-5": {
421
+ family: "mythos",
422
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
423
+ maxOutputTokens: { default: 64000, upper: 128000 },
424
+ capabilities: ["total_tokens_reminder", "tool_loaded_text"],
425
+ },
426
+ "claude-mythos-5-1": {
427
+ family: "mythos",
428
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
429
+ maxOutputTokens: { default: 64000, upper: 128000 },
430
+ capabilities: [
431
+ "effort",
432
+ "max_effort",
433
+ "xhigh_effort",
434
+ "adaptive_thinking",
435
+ "rejects_disabled_thinking",
436
+ "mid_conv_tool_change",
437
+ "per_turn_timing",
438
+ "context_management",
439
+ "lean_prompt",
440
+ "fable_5_mitigations",
441
+ "fable_5_1_prompt_bundle",
442
+ "total_tokens_reminder",
443
+ "tool_loaded_text",
444
+ ],
445
+ defaultEffort: "high",
446
+ },
447
+ // New at 2.1.329.
448
+ "claude-mythos-5-2": {
449
+ family: "mythos",
450
+ context: { window: 1e6, native1m: true, supports1mBeta: true },
451
+ maxOutputTokens: { default: 128000, upper: 128000 },
452
+ capabilities: [
453
+ "effort",
454
+ "max_effort",
455
+ "xhigh_effort",
456
+ "adaptive_thinking",
457
+ "rejects_disabled_thinking",
458
+ "mid_conv_tool_change",
459
+ "per_turn_effort",
460
+ "per_turn_timing",
461
+ "context_management",
462
+ "fast_mode",
463
+ "vertex_fast_mode",
464
+ "lean_prompt",
465
+ "org_locked_thinking",
466
+ "fable_5_2_prompt_bundle",
467
+ ],
468
+ defaultEffort: "medium",
469
+ },
470
+ },
471
+ });
package/src/redaction.ts CHANGED
@@ -82,6 +82,7 @@ const PINNED_PROFILE_IDS: ReadonlySet<string> = new Set([
82
82
  "claude-code-2.1.195-sdk-0.94.0",
83
83
  "claude-code-2.1.233-sdk-0.112.1",
84
84
  "claude-code-2.1.280-sdk-0.112.1",
85
+ "claude-code-2.1.329-sdk-0.128.0",
85
86
  ]);
86
87
  const FORBIDDEN_KEYS = new Set(["__proto__", "prototype", "constructor"]);
87
88
  const SAFE_ERROR_CODES = new Set([