@byte_fluffy/nexra-sdk 0.1.0-alpha.39 → 0.1.0-alpha.40

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
@@ -108,6 +108,12 @@ parameter context, without adding serialized aliases. Use `nexraError.param`
108
108
  for new parameter handling. Public retry/category hints are removed; the SDK
109
109
  no longer exposes `NexraApiError.retryable`.
110
110
 
111
+ `upstreamErrorMessage` is the original provider error text, preserving its
112
+ language and line breaks. It is independent of the platform classification and
113
+ is omitted when captured diagnostics contain no supported error text. Both SDK
114
+ exception types expose this field. For older stored diagnostic bodies,
115
+ `extractUpstreamErrorMessage(body)` uses the same extraction rules as the server.
116
+
111
117
  `upstreamError` contains captured provider error content. When an older captured
112
118
  body has its own `error` member, input normalization selects that member once;
113
119
  otherwise it retains the complete captured error body. An already canonical
package/dist/catalog.js CHANGED
@@ -9,8 +9,8 @@ import {
9
9
  listModelSpecs,
10
10
  projectMediaGeometry,
11
11
  resolveNexraLanguageReasoning
12
- } from "./chunk-ZP34I6D7.js";
13
- import "./chunk-EFSKJCKB.js";
12
+ } from "./chunk-Q4A3HJBX.js";
13
+ import "./chunk-SIBYK5IX.js";
14
14
  export {
15
15
  CatalogClient,
16
16
  applyMediaGeometry,
@@ -2,7 +2,7 @@ import {
2
2
  normalizePublicErrorInput,
3
3
  pickPublicErrorFields,
4
4
  sortRatioDisplayOrder
5
- } from "./chunk-EFSKJCKB.js";
5
+ } from "./chunk-SIBYK5IX.js";
6
6
 
7
7
  // src/catalog/generated/audio.generated.json
8
8
  var audio_generated_default = [
@@ -53040,6 +53040,7 @@ var NexraApiError = class extends Error {
53040
53040
  upstreamHttpStatus;
53041
53041
  upstreamRequestId;
53042
53042
  upstreamError;
53043
+ upstreamErrorMessage;
53043
53044
  upstreamRedacted;
53044
53045
  upstreamTruncated;
53045
53046
  upstreamUnavailableReason;
@@ -53105,6 +53106,9 @@ var NexraTaskError = class extends Error {
53105
53106
  get upstreamError() {
53106
53107
  return this.publicFields.upstreamError;
53107
53108
  }
53109
+ get upstreamErrorMessage() {
53110
+ return this.publicFields.upstreamErrorMessage;
53111
+ }
53108
53112
  get upstreamRedacted() {
53109
53113
  return this.publicFields.upstreamRedacted;
53110
53114
  }
@@ -53139,7 +53143,7 @@ var NexraWaitTimeoutError = class extends Error {
53139
53143
  };
53140
53144
 
53141
53145
  // src/generated/version.generated.ts
53142
- var SDK_VERSION = "0.1.0-alpha.39";
53146
+ var SDK_VERSION = "0.1.0-alpha.40";
53143
53147
 
53144
53148
  // src/transport.ts
53145
53149
  var DEFAULT_BASE_URL = "https://api.nexra-ai.com/v1";
@@ -8,311 +8,6 @@ var MEDIA_KINDS = [
8
8
  "other"
9
9
  ];
10
10
 
11
- // ../contracts/src/media-api.ts
12
- var NEXRA_MEDIA_API_VERSION = 1;
13
- var NEXRA_GENERATION_OPERATIONS = [
14
- "text.generate",
15
- "image.generate",
16
- "video.generate",
17
- "audio.generate",
18
- "image.upscale",
19
- "video.upscale"
20
- ];
21
- var NEXRA_MEDIA_OPERATIONS = [
22
- "image.generate",
23
- "video.generate",
24
- "audio.generate",
25
- "image.upscale",
26
- "video.upscale"
27
- ];
28
- var NEXRA_PUBLISHED_MEDIA_OPERATIONS = [
29
- "image.generate",
30
- "video.generate",
31
- "audio.generate",
32
- "image.upscale"
33
- ];
34
- var NEXRA_MEDIA_FEATURES = [
35
- "text-to-image",
36
- "image-to-image",
37
- "image-reference",
38
- "image-edit",
39
- "image-inpaint",
40
- "image-control",
41
- "text-to-video",
42
- "first-frame",
43
- "first-last-frame",
44
- "image-to-video",
45
- "video-to-video",
46
- "audio-to-video",
47
- "avatar-video",
48
- "reference-image",
49
- "reference-video",
50
- "reference-audio",
51
- "omni-reference",
52
- "tts",
53
- "music",
54
- "sfx",
55
- "voice-reference",
56
- "voice-design",
57
- "scale-factor",
58
- "target-resolution"
59
- ];
60
- var NEXRA_MEDIA_OPERATION_DEFINITIONS = Object.freeze([
61
- {
62
- operation: "image.generate",
63
- status: "active",
64
- outputKind: "image",
65
- features: ["text-to-image", "image-to-image", "image-reference", "image-edit", "image-inpaint", "image-control"],
66
- parameterKeys: ["aspect_ratio", "resolution", "quality", "count", "output_format", "seed"]
67
- },
68
- {
69
- operation: "video.generate",
70
- status: "active",
71
- outputKind: "video",
72
- features: ["text-to-video", "first-frame", "first-last-frame", "image-to-video", "video-to-video", "audio-to-video", "avatar-video", "reference-image", "reference-video", "reference-audio", "omni-reference"],
73
- parameterKeys: ["voice", "aspect_ratio", "resolution", "quality", "duration", "fit", "title", "generate_audio", "output_format", "seed", "watermark"]
74
- },
75
- {
76
- operation: "audio.generate",
77
- status: "active",
78
- outputKind: "audio",
79
- features: ["tts", "music", "sfx", "voice-reference", "voice-design"],
80
- parameterKeys: ["voice", "language", "duration", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion", "instrumental", "loop", "prompt_influence", "seed"]
81
- },
82
- {
83
- operation: "image.upscale",
84
- status: "active",
85
- outputKind: "image",
86
- features: ["scale-factor", "target-resolution"],
87
- parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
88
- },
89
- {
90
- operation: "video.upscale",
91
- status: "hold",
92
- outputKind: "video",
93
- features: ["scale-factor", "target-resolution"],
94
- parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
95
- }
96
- ]);
97
- var mediaSourceSchema = {
98
- oneOf: [
99
- { type: "string", minLength: 1 },
100
- {
101
- type: "object",
102
- properties: { assetId: { type: "string", minLength: 1 } },
103
- required: ["assetId"],
104
- additionalProperties: false
105
- }
106
- ]
107
- };
108
- function textPartSchema(roles) {
109
- return {
110
- type: "object",
111
- properties: {
112
- type: { const: "text" },
113
- text: { type: "string", minLength: 1 },
114
- role: { type: "string", enum: [...roles] }
115
- },
116
- required: ["type", "text"],
117
- additionalProperties: false
118
- };
119
- }
120
- function mediaPartSchema(type, roles) {
121
- return {
122
- type: "object",
123
- properties: {
124
- type: { const: type },
125
- source: structuredClone(mediaSourceSchema),
126
- role: { type: "string", enum: [...roles] },
127
- ...type === "image" ? { name: { type: "string", minLength: 1, maxLength: 64, pattern: "^[^\\s@]+$" } } : {}
128
- },
129
- required: ["type", "source"],
130
- additionalProperties: false
131
- };
132
- }
133
- function inputSchema(contentItems, properties, contentBounds = {}) {
134
- return {
135
- $schema: "https://json-schema.org/draft/2020-12/schema",
136
- type: "object",
137
- properties: {
138
- content: {
139
- type: "array",
140
- minItems: contentBounds.minItems ?? 1,
141
- ...contentBounds.maxItems === void 0 ? {} : { maxItems: contentBounds.maxItems },
142
- items: { oneOf: contentItems.map((item) => structuredClone(item)) },
143
- "x-ui": { control: "content-parts", order: 0 }
144
- },
145
- ...properties
146
- },
147
- required: ["content"],
148
- additionalProperties: false
149
- };
150
- }
151
- var imagePart = mediaPartSchema("image", ["source", "reference", "first_frame", "last_frame", "mask", "control", "subject", "background"]);
152
- var videoImagePart = mediaPartSchema("image", ["source", "reference", "first_frame", "last_frame", "mask", "control", "subject", "background", "keyframe"]);
153
- var videoPart = mediaPartSchema("video", ["source", "reference", "edit", "extend"]);
154
- var audioPart = mediaPartSchema("audio", ["source", "reference", "voice_reference"]);
155
- var draftPart = {
156
- type: "object",
157
- properties: {
158
- type: { const: "draft_task" },
159
- draft_task: { type: "object", properties: { id: { type: "string", minLength: 1 } }, required: ["id"], additionalProperties: false }
160
- },
161
- required: ["type", "draft_task"],
162
- additionalProperties: false
163
- };
164
- var NEXRA_MEDIA_INPUT_SCHEMAS = Object.freeze({
165
- "image.generate": inputSchema(
166
- [textPartSchema(["prompt", "negative_prompt"]), imagePart],
167
- {
168
- aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
169
- resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
170
- quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
171
- count: { type: "integer", minimum: 1, "x-ui": { order: 13, control: "number" } },
172
- output_format: { type: "string", minLength: 1, "x-ui": { order: 14 } },
173
- seed: { type: "integer", minimum: 0, "x-ui": { order: 15, control: "number" } }
174
- }
175
- ),
176
- "video.generate": inputSchema(
177
- [textPartSchema(["prompt", "negative_prompt", "script"]), videoImagePart, videoPart, audioPart, draftPart],
178
- {
179
- task_type: { type: "string", minLength: 1, "x-ui": { order: 8, control: "segmented" } },
180
- voice: { type: "string", minLength: 1, "x-ui": { order: 9, control: "resource", resource: "voice" } },
181
- draft: { type: "boolean", "x-ui": { control: "switch" } },
182
- watermark: { type: "boolean", const: false, "x-ui": { hidden: true } },
183
- aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
184
- resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
185
- quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
186
- duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 13, control: "number" } },
187
- fit: { type: "string", enum: ["contain", "cover"], "x-ui": { order: 15, control: "segmented" } },
188
- title: { type: "string", minLength: 1, "x-ui": { order: 16 } },
189
- generate_audio: { type: "boolean", "x-ui": { order: 14, control: "switch" } },
190
- output_format: { type: "string", minLength: 1, "x-ui": { order: 15 } },
191
- seed: { type: "integer", minimum: 0, "x-ui": { order: 16, control: "number" } }
192
- }
193
- ),
194
- "audio.generate": inputSchema(
195
- [textPartSchema(["prompt", "script", "lyrics"]), audioPart],
196
- {
197
- voice: { type: "string", minLength: 1, "x-ui": { order: 10, control: "resource", resource: "voice" } },
198
- language: { type: "string", minLength: 1, "x-ui": { order: 11 } },
199
- duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 12, control: "number" } },
200
- output_format: { type: "string", minLength: 1, "x-ui": { order: 13 } },
201
- sample_rate: { type: "integer", minimum: 1, "x-ui": { order: 14, control: "number" } },
202
- speed: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 15, control: "number" } },
203
- volume: { type: "number", "x-ui": { order: 16, control: "number" } },
204
- pitch: { type: "number", "x-ui": { order: 17, control: "number" } },
205
- emotion: { type: "string", minLength: 1, "x-ui": { order: 18 } },
206
- instrumental: { type: "boolean", "x-ui": { order: 19, control: "switch" } },
207
- loop: { type: "boolean", "x-ui": { order: 20, control: "switch" } },
208
- prompt_influence: { type: "number", minimum: 0, maximum: 1, "x-ui": { order: 21, control: "number" } },
209
- seed: { type: "integer", minimum: 0, "x-ui": { order: 22, control: "number" } }
210
- }
211
- ),
212
- "image.upscale": inputSchema(
213
- [mediaPartSchema("image", ["source"])],
214
- {
215
- scale: { type: "number", exclusiveMinimum: 1, "x-ui": { order: 10, control: "number" } },
216
- resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
217
- output_format: { type: "string", minLength: 1, "x-ui": { order: 12 } },
218
- preserve_details: { type: "boolean", "x-ui": { order: 13, control: "switch" } }
219
- },
220
- { minItems: 1, maxItems: 1 }
221
- )
222
- });
223
- function nexraMediaInputSchema(operation) {
224
- if (!(operation in NEXRA_MEDIA_INPUT_SCHEMAS)) return void 0;
225
- return structuredClone(NEXRA_MEDIA_INPUT_SCHEMAS[operation]);
226
- }
227
- function isNexraMediaInput(value) {
228
- if (!value || typeof value !== "object" || Array.isArray(value)) return false;
229
- const input = value;
230
- if ("model" in input) return false;
231
- const content = input.content;
232
- return Array.isArray(content) && content.length > 0 && content.every((part) => {
233
- if (!part || typeof part !== "object" || Array.isArray(part)) return false;
234
- if (part.type === "text") return typeof part.text === "string" && part.text.length > 0;
235
- if (part.type === "draft_task") {
236
- const reference = part.draft_task;
237
- return Boolean(reference && typeof reference === "object" && !Array.isArray(reference) && typeof reference.id === "string" && reference.id.length > 0);
238
- }
239
- if (!["image", "video", "audio"].includes(String(part.type))) return false;
240
- if (typeof part.source === "string") return part.source.length > 0;
241
- return Boolean(part.source && typeof part.source === "object" && !Array.isArray(part.source) && typeof part.source.assetId === "string" && part.source.assetId.length > 0);
242
- });
243
- }
244
- function nexraMediaOperationForMode(mode) {
245
- if (["text-to-image", "image-to-image"].includes(mode)) return "image.generate";
246
- if (["text-to-video", "image-to-video", "multimodal-to-video", "avatar-video"].includes(mode)) return "video.generate";
247
- if (["text-to-speech", "text-to-music", "text-to-sfx"].includes(mode)) return "audio.generate";
248
- if (mode === "image-upscale") return "image.upscale";
249
- return void 0;
250
- }
251
- function nexraMediaInputSchemaForMode(mode) {
252
- const operation = nexraMediaOperationForMode(mode);
253
- const schema = operation ? nexraMediaInputSchema(operation) : void 0;
254
- if (!schema) return void 0;
255
- const properties = schema.properties;
256
- const content = properties.content;
257
- const items = content.items;
258
- const variants = Array.isArray(items.oneOf) ? items.oneOf : [];
259
- if (mode === "avatar-video") {
260
- for (const variant of variants) {
261
- const variantProperties = variant.properties;
262
- if (variantProperties.type.const === "text") {
263
- variantProperties.role = { type: "string", enum: ["script"] };
264
- }
265
- }
266
- }
267
- const allowed = mode === "text-to-image" || mode === "text-to-video" || mode === "text-to-music" || mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["text"]) : mode === "image-to-image" ? /* @__PURE__ */ new Set(["text", "image"]) : mode === "image-to-video" ? /* @__PURE__ */ new Set(["text", "image", "audio"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["text", "audio"]) : /* @__PURE__ */ new Set(["text", "image", "video", "audio"]);
268
- items.oneOf = variants.filter((variant) => allowed.has(String(variant.properties.type.const)));
269
- if (mode === "image-to-video") {
270
- for (const variant of items.oneOf) {
271
- const variantProperties = variant.properties;
272
- if (variantProperties.type.const !== "image") continue;
273
- variantProperties.role = { type: "string", enum: ["first_frame", "last_frame"] };
274
- const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
275
- required.add("role");
276
- variant.required = [...required];
277
- }
278
- }
279
- if (mode === "multimodal-to-video") {
280
- for (const variant of items.oneOf) {
281
- const variantProperties = variant.properties;
282
- const type = String(variantProperties.type.const);
283
- if (!["image", "video", "audio"].includes(type)) continue;
284
- variantProperties.role = type === "image" ? { type: "string", enum: ["reference", "subject", "background"] } : type === "video" ? { type: "string", enum: ["reference", "edit", "extend"] } : { type: "string", const: "reference" };
285
- const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
286
- required.add("role");
287
- variant.required = [...required];
288
- }
289
- }
290
- const requiredMedia = mode === "image-to-image" || mode === "image-to-video" || mode === "avatar-video" ? "image" : void 0;
291
- const requiresReferenceMedia = mode === "multimodal-to-video";
292
- content.allOf = [
293
- ...mode === "avatar-video" ? [] : [{
294
- contains: { type: "object", properties: { type: { const: "text" } }, required: ["type"] },
295
- minContains: 1
296
- }],
297
- ...requiredMedia ? [{
298
- contains: { type: "object", properties: { type: { const: requiredMedia } }, required: ["type"] },
299
- minContains: 1
300
- }] : [],
301
- ...requiresReferenceMedia ? [{
302
- contains: { type: "object", properties: { type: { enum: ["image", "video", "audio"] } }, required: ["type"] },
303
- minContains: 1
304
- }] : []
305
- ];
306
- if (mode === "text-to-speech") {
307
- properties.voice = { ...properties.voice, "x-ui": { order: 10, control: "resource", resource: "voice" } };
308
- }
309
- const allowedParameters = mode === "avatar-video" ? /* @__PURE__ */ new Set(["content", "voice", "aspect_ratio", "resolution"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["content", "voice", "language", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion"]) : mode === "text-to-music" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "instrumental", "prompt_influence", "seed"]) : mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "loop", "prompt_influence", "seed"]) : void 0;
310
- if (allowedParameters) {
311
- schema.properties = Object.fromEntries(Object.entries(properties).filter(([key]) => allowedParameters.has(key)));
312
- }
313
- return schema;
314
- }
315
-
316
11
  // ../contracts/src/public-error-catalog.ts
317
12
  var PUBLIC_ERROR_CATALOG = {
318
13
  task_execution_timeout: { "zh-CN": "\u4EFB\u52A1\u8D85\u8FC7\u603B\u65F6\u9650\uFF0C\u5DF2\u7ED3\u675F\u3002\u4E0A\u6E38\u53EF\u80FD\u4ECD\u5728\u5904\u7406\uFF0C\u8BF7\u5148\u6838\u5BF9\u539F\u8BF7\u6C42\u7ED3\u679C\uFF0C\u907F\u514D\u91CD\u590D\u63D0\u4EA4\u3002", en: "The task exceeded its total time limit and has ended. The upstream service may still be processing it; check the original request before submitting again." },
@@ -601,69 +296,409 @@ function pickPublicErrorFields(input, context = {}) {
601
296
  const nexraHttpStatus = nexraRequestId ? status ?? (contextId === nexraRequestId ? httpStatus(context.nexraHttpStatus) : void 0) : void 0;
602
297
  const nexraError = pickNexraError(source);
603
298
  return {
604
- ...nexraRequestId ? { nexraRequestId } : {},
605
- ...nexraHttpStatus !== void 0 ? { nexraHttpStatus } : {},
606
- ...nexraError ? { nexraError } : {},
607
- ...flatUpstreamFields(owner, source)
299
+ ...nexraRequestId ? { nexraRequestId } : {},
300
+ ...nexraHttpStatus !== void 0 ? { nexraHttpStatus } : {},
301
+ ...nexraError ? { nexraError } : {},
302
+ ...flatUpstreamFields(owner, source)
303
+ };
304
+ }
305
+ function normalizePublicErrorInput(input, context = {}) {
306
+ const fields = pickPublicErrorFields(input, context);
307
+ return fields.nexraError ? { ...fields, nexraError: fields.nexraError } : void 0;
308
+ }
309
+ function flatUpstreamFields(owner, source) {
310
+ const legacy = evidenceFields(source).upstream;
311
+ const field = (key, fallback) => Object.hasOwn(owner, key) ? owner[key] : Object.hasOwn(source, key) ? source[key] : fallback;
312
+ const body = Object.hasOwn(owner, "upstreamError") ? owner.upstreamError : Object.hasOwn(source, "upstreamError") ? source.upstreamError : legacy?.body !== null && typeof legacy?.body === "object" && Object.hasOwn(legacy.body, "error") ? legacy.body.error : legacy?.body;
313
+ const upstream = pickPublicUpstreamError({
314
+ upstreamHttpStatus: field("upstreamHttpStatus", legacy?.upstreamHttpStatus),
315
+ upstreamRequestId: field("upstreamRequestId", legacy?.upstreamRequestId),
316
+ ...body !== void 0 ? { body } : {},
317
+ redacted: field("upstreamRedacted", legacy?.redacted),
318
+ truncated: field("upstreamTruncated", legacy?.truncated),
319
+ format: field("upstreamFormat", legacy?.format),
320
+ event: field("upstreamEvent", legacy?.event),
321
+ unavailableReason: field("upstreamUnavailableReason", legacy?.unavailableReason)
322
+ });
323
+ const explicitMessage = field("upstreamErrorMessage");
324
+ const upstreamErrorMessage = typeof explicitMessage === "string" && explicitMessage.trim() ? explicitMessage : extractUpstreamErrorMessage(upstream?.body);
325
+ return {
326
+ ...upstreamErrorMessage !== void 0 ? { upstreamErrorMessage } : {},
327
+ ...upstream?.upstreamHttpStatus !== void 0 ? { upstreamHttpStatus: upstream.upstreamHttpStatus } : {},
328
+ ...upstream?.upstreamRequestId ? { upstreamRequestId: upstream.upstreamRequestId } : {},
329
+ ...upstream && Object.hasOwn(upstream, "body") ? { upstreamError: upstream.body } : {},
330
+ ...upstream?.redacted ? { upstreamRedacted: true } : {},
331
+ ...upstream?.truncated ? { upstreamTruncated: true } : {},
332
+ ...upstream?.format ? { upstreamFormat: upstream.format } : {},
333
+ ...upstream?.event ? { upstreamEvent: upstream.event } : {},
334
+ ...upstream?.unavailableReason ? { upstreamUnavailableReason: upstream.unavailableReason } : {}
335
+ };
336
+ }
337
+ function upstreamUnavailableReason(value) {
338
+ return value === "no_response" || value === "not_retained" || value === "unsupported_capture" || value === "error_not_emitted" || value === "size_limit" ? value : void 0;
339
+ }
340
+ function extractUpstreamErrorMessage(value) {
341
+ const visited = /* @__PURE__ */ new WeakSet();
342
+ const read = (candidate, depth) => {
343
+ if (typeof candidate === "string") return candidate.trim() ? candidate : void 0;
344
+ if (depth > 8 || !candidate || typeof candidate !== "object" || visited.has(candidate)) return void 0;
345
+ visited.add(candidate);
346
+ if (Array.isArray(candidate)) {
347
+ const messages = candidate.flatMap((item) => read(item, depth + 1) ?? []);
348
+ return messages.length ? messages.join("\n") : void 0;
349
+ }
350
+ const record = candidate;
351
+ for (const key of ["error", "Error"]) {
352
+ const message = read(record[key], depth + 1);
353
+ if (message) return message;
354
+ }
355
+ for (const key of ["errorMessage", "failure_reason", "status_message", "errMsg"]) {
356
+ const message = record[key];
357
+ if (typeof message === "string" && message.trim()) return message;
358
+ }
359
+ for (const key of ["base_resp", "detail", "output", "task", "data", "response", "Response", "videoGenerateTaskInfo", "steps"]) {
360
+ if (key === "base_resp" && isRecord(record[key]) && record[key].status_code === 0) continue;
361
+ const message = read(record[key], depth + 1);
362
+ if (message) return message;
363
+ }
364
+ for (const key of ["message", "msg", "status_msg"]) {
365
+ const message = record[key];
366
+ if (typeof message === "string" && message.trim()) return message;
367
+ }
368
+ return void 0;
369
+ };
370
+ return read(value, 0);
371
+ }
372
+ function identifier(value) {
373
+ return typeof value === "string" && value.trim() ? value : void 0;
374
+ }
375
+ function httpStatus(value) {
376
+ return typeof value === "number" && Number.isInteger(value) && value >= 100 && value <= 599 ? value : void 0;
377
+ }
378
+ function resolvePublicErrorLocale(acceptLanguage) {
379
+ let chosen = "en";
380
+ let highestQuality = 0;
381
+ for (const candidate of (acceptLanguage ?? "").split(",")) {
382
+ const [tag, ...parameters] = candidate.trim().toLowerCase().split(";");
383
+ const locale = /^zh(?:-[a-z0-9]+)*$/.test(tag ?? "") ? "zh-CN" : /^en(?:-[a-z0-9]+)*$/.test(tag ?? "") ? "en" : void 0;
384
+ if (!locale) continue;
385
+ const qualityParameter = parameters.map((parameter) => parameter.trim()).find((parameter) => parameter.startsWith("q="));
386
+ const rawQuality = qualityParameter?.slice(2).trim();
387
+ const quality = rawQuality === void 0 ? 1 : /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/.test(rawQuality) ? Number(rawQuality) : 0;
388
+ if (quality > highestQuality) {
389
+ chosen = locale;
390
+ highestQuality = quality;
391
+ }
392
+ }
393
+ return chosen;
394
+ }
395
+ function isRecord(value) {
396
+ return typeof value === "object" && value !== null && !Array.isArray(value);
397
+ }
398
+
399
+ // ../contracts/src/media-api.ts
400
+ var NEXRA_MEDIA_API_VERSION = 1;
401
+ var NEXRA_GENERATION_OPERATIONS = [
402
+ "text.generate",
403
+ "image.generate",
404
+ "video.generate",
405
+ "audio.generate",
406
+ "image.upscale",
407
+ "video.upscale"
408
+ ];
409
+ var NEXRA_MEDIA_OPERATIONS = [
410
+ "image.generate",
411
+ "video.generate",
412
+ "audio.generate",
413
+ "image.upscale",
414
+ "video.upscale"
415
+ ];
416
+ var NEXRA_PUBLISHED_MEDIA_OPERATIONS = [
417
+ "image.generate",
418
+ "video.generate",
419
+ "audio.generate",
420
+ "image.upscale"
421
+ ];
422
+ var NEXRA_MEDIA_FEATURES = [
423
+ "text-to-image",
424
+ "image-to-image",
425
+ "image-reference",
426
+ "image-edit",
427
+ "image-inpaint",
428
+ "image-control",
429
+ "text-to-video",
430
+ "first-frame",
431
+ "first-last-frame",
432
+ "image-to-video",
433
+ "video-to-video",
434
+ "audio-to-video",
435
+ "avatar-video",
436
+ "reference-image",
437
+ "reference-video",
438
+ "reference-audio",
439
+ "omni-reference",
440
+ "tts",
441
+ "music",
442
+ "sfx",
443
+ "voice-reference",
444
+ "voice-design",
445
+ "scale-factor",
446
+ "target-resolution"
447
+ ];
448
+ var NEXRA_MEDIA_OPERATION_DEFINITIONS = Object.freeze([
449
+ {
450
+ operation: "image.generate",
451
+ status: "active",
452
+ outputKind: "image",
453
+ features: ["text-to-image", "image-to-image", "image-reference", "image-edit", "image-inpaint", "image-control"],
454
+ parameterKeys: ["aspect_ratio", "resolution", "quality", "count", "output_format", "seed"]
455
+ },
456
+ {
457
+ operation: "video.generate",
458
+ status: "active",
459
+ outputKind: "video",
460
+ features: ["text-to-video", "first-frame", "first-last-frame", "image-to-video", "video-to-video", "audio-to-video", "avatar-video", "reference-image", "reference-video", "reference-audio", "omni-reference"],
461
+ parameterKeys: ["voice", "aspect_ratio", "resolution", "quality", "duration", "fit", "title", "generate_audio", "output_format", "seed", "watermark"]
462
+ },
463
+ {
464
+ operation: "audio.generate",
465
+ status: "active",
466
+ outputKind: "audio",
467
+ features: ["tts", "music", "sfx", "voice-reference", "voice-design"],
468
+ parameterKeys: ["voice", "language", "duration", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion", "instrumental", "loop", "prompt_influence", "seed"]
469
+ },
470
+ {
471
+ operation: "image.upscale",
472
+ status: "active",
473
+ outputKind: "image",
474
+ features: ["scale-factor", "target-resolution"],
475
+ parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
476
+ },
477
+ {
478
+ operation: "video.upscale",
479
+ status: "hold",
480
+ outputKind: "video",
481
+ features: ["scale-factor", "target-resolution"],
482
+ parameterKeys: ["scale", "resolution", "output_format", "preserve_details"]
483
+ }
484
+ ]);
485
+ var mediaSourceSchema = {
486
+ oneOf: [
487
+ { type: "string", minLength: 1 },
488
+ {
489
+ type: "object",
490
+ properties: { assetId: { type: "string", minLength: 1 } },
491
+ required: ["assetId"],
492
+ additionalProperties: false
493
+ }
494
+ ]
495
+ };
496
+ function textPartSchema(roles) {
497
+ return {
498
+ type: "object",
499
+ properties: {
500
+ type: { const: "text" },
501
+ text: { type: "string", minLength: 1 },
502
+ role: { type: "string", enum: [...roles] }
503
+ },
504
+ required: ["type", "text"],
505
+ additionalProperties: false
608
506
  };
609
507
  }
610
- function normalizePublicErrorInput(input, context = {}) {
611
- const fields = pickPublicErrorFields(input, context);
612
- return fields.nexraError ? { ...fields, nexraError: fields.nexraError } : void 0;
508
+ function mediaPartSchema(type, roles) {
509
+ return {
510
+ type: "object",
511
+ properties: {
512
+ type: { const: type },
513
+ source: structuredClone(mediaSourceSchema),
514
+ role: { type: "string", enum: [...roles] },
515
+ ...type === "image" ? { name: { type: "string", minLength: 1, maxLength: 64, pattern: "^[^\\s@]+$" } } : {}
516
+ },
517
+ required: ["type", "source"],
518
+ additionalProperties: false
519
+ };
613
520
  }
614
- function flatUpstreamFields(owner, source) {
615
- const legacy = evidenceFields(source).upstream;
616
- const field = (key, fallback) => Object.hasOwn(owner, key) ? owner[key] : Object.hasOwn(source, key) ? source[key] : fallback;
617
- const body = Object.hasOwn(owner, "upstreamError") ? owner.upstreamError : Object.hasOwn(source, "upstreamError") ? source.upstreamError : legacy?.body !== null && typeof legacy?.body === "object" && Object.hasOwn(legacy.body, "error") ? legacy.body.error : legacy?.body;
618
- const upstream = pickPublicUpstreamError({
619
- upstreamHttpStatus: field("upstreamHttpStatus", legacy?.upstreamHttpStatus),
620
- upstreamRequestId: field("upstreamRequestId", legacy?.upstreamRequestId),
621
- ...body !== void 0 ? { body } : {},
622
- redacted: field("upstreamRedacted", legacy?.redacted),
623
- truncated: field("upstreamTruncated", legacy?.truncated),
624
- format: field("upstreamFormat", legacy?.format),
625
- event: field("upstreamEvent", legacy?.event),
626
- unavailableReason: field("upstreamUnavailableReason", legacy?.unavailableReason)
627
- });
521
+ function inputSchema(contentItems, properties, contentBounds = {}) {
628
522
  return {
629
- ...upstream?.upstreamHttpStatus !== void 0 ? { upstreamHttpStatus: upstream.upstreamHttpStatus } : {},
630
- ...upstream?.upstreamRequestId ? { upstreamRequestId: upstream.upstreamRequestId } : {},
631
- ...upstream && Object.hasOwn(upstream, "body") ? { upstreamError: upstream.body } : {},
632
- ...upstream?.redacted ? { upstreamRedacted: true } : {},
633
- ...upstream?.truncated ? { upstreamTruncated: true } : {},
634
- ...upstream?.format ? { upstreamFormat: upstream.format } : {},
635
- ...upstream?.event ? { upstreamEvent: upstream.event } : {},
636
- ...upstream?.unavailableReason ? { upstreamUnavailableReason: upstream.unavailableReason } : {}
523
+ $schema: "https://json-schema.org/draft/2020-12/schema",
524
+ type: "object",
525
+ properties: {
526
+ content: {
527
+ type: "array",
528
+ minItems: contentBounds.minItems ?? 1,
529
+ ...contentBounds.maxItems === void 0 ? {} : { maxItems: contentBounds.maxItems },
530
+ items: { oneOf: contentItems.map((item) => structuredClone(item)) },
531
+ "x-ui": { control: "content-parts", order: 0 }
532
+ },
533
+ ...properties
534
+ },
535
+ required: ["content"],
536
+ additionalProperties: false
637
537
  };
638
538
  }
639
- function upstreamUnavailableReason(value) {
640
- return value === "no_response" || value === "not_retained" || value === "unsupported_capture" || value === "error_not_emitted" || value === "size_limit" ? value : void 0;
539
+ var imagePart = mediaPartSchema("image", ["source", "reference", "first_frame", "last_frame", "mask", "control", "subject", "background"]);
540
+ var videoImagePart = mediaPartSchema("image", ["source", "reference", "first_frame", "last_frame", "mask", "control", "subject", "background", "keyframe"]);
541
+ var videoPart = mediaPartSchema("video", ["source", "reference", "edit", "extend"]);
542
+ var audioPart = mediaPartSchema("audio", ["source", "reference", "voice_reference"]);
543
+ var draftPart = {
544
+ type: "object",
545
+ properties: {
546
+ type: { const: "draft_task" },
547
+ draft_task: { type: "object", properties: { id: { type: "string", minLength: 1 } }, required: ["id"], additionalProperties: false }
548
+ },
549
+ required: ["type", "draft_task"],
550
+ additionalProperties: false
551
+ };
552
+ var NEXRA_MEDIA_INPUT_SCHEMAS = Object.freeze({
553
+ "image.generate": inputSchema(
554
+ [textPartSchema(["prompt", "negative_prompt"]), imagePart],
555
+ {
556
+ aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
557
+ resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
558
+ quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
559
+ count: { type: "integer", minimum: 1, "x-ui": { order: 13, control: "number" } },
560
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 14 } },
561
+ seed: { type: "integer", minimum: 0, "x-ui": { order: 15, control: "number" } }
562
+ }
563
+ ),
564
+ "video.generate": inputSchema(
565
+ [textPartSchema(["prompt", "negative_prompt", "script"]), videoImagePart, videoPart, audioPart, draftPart],
566
+ {
567
+ task_type: { type: "string", minLength: 1, "x-ui": { order: 8, control: "segmented" } },
568
+ voice: { type: "string", minLength: 1, "x-ui": { order: 9, control: "resource", resource: "voice" } },
569
+ draft: { type: "boolean", "x-ui": { control: "switch" } },
570
+ watermark: { type: "boolean", const: false, "x-ui": { hidden: true } },
571
+ aspect_ratio: { type: "string", minLength: 1, "x-ui": { order: 10 } },
572
+ resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
573
+ quality: { type: "string", minLength: 1, "x-ui": { order: 12 } },
574
+ duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 13, control: "number" } },
575
+ fit: { type: "string", enum: ["contain", "cover"], "x-ui": { order: 15, control: "segmented" } },
576
+ title: { type: "string", minLength: 1, "x-ui": { order: 16 } },
577
+ generate_audio: { type: "boolean", "x-ui": { order: 14, control: "switch" } },
578
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 15 } },
579
+ seed: { type: "integer", minimum: 0, "x-ui": { order: 16, control: "number" } }
580
+ }
581
+ ),
582
+ "audio.generate": inputSchema(
583
+ [textPartSchema(["prompt", "script", "lyrics"]), audioPart],
584
+ {
585
+ voice: { type: "string", minLength: 1, "x-ui": { order: 10, control: "resource", resource: "voice" } },
586
+ language: { type: "string", minLength: 1, "x-ui": { order: 11 } },
587
+ duration: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 12, control: "number" } },
588
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 13 } },
589
+ sample_rate: { type: "integer", minimum: 1, "x-ui": { order: 14, control: "number" } },
590
+ speed: { type: "number", exclusiveMinimum: 0, "x-ui": { order: 15, control: "number" } },
591
+ volume: { type: "number", "x-ui": { order: 16, control: "number" } },
592
+ pitch: { type: "number", "x-ui": { order: 17, control: "number" } },
593
+ emotion: { type: "string", minLength: 1, "x-ui": { order: 18 } },
594
+ instrumental: { type: "boolean", "x-ui": { order: 19, control: "switch" } },
595
+ loop: { type: "boolean", "x-ui": { order: 20, control: "switch" } },
596
+ prompt_influence: { type: "number", minimum: 0, maximum: 1, "x-ui": { order: 21, control: "number" } },
597
+ seed: { type: "integer", minimum: 0, "x-ui": { order: 22, control: "number" } }
598
+ }
599
+ ),
600
+ "image.upscale": inputSchema(
601
+ [mediaPartSchema("image", ["source"])],
602
+ {
603
+ scale: { type: "number", exclusiveMinimum: 1, "x-ui": { order: 10, control: "number" } },
604
+ resolution: { type: "string", minLength: 1, "x-ui": { order: 11 } },
605
+ output_format: { type: "string", minLength: 1, "x-ui": { order: 12 } },
606
+ preserve_details: { type: "boolean", "x-ui": { order: 13, control: "switch" } }
607
+ },
608
+ { minItems: 1, maxItems: 1 }
609
+ )
610
+ });
611
+ function nexraMediaInputSchema(operation) {
612
+ if (!(operation in NEXRA_MEDIA_INPUT_SCHEMAS)) return void 0;
613
+ return structuredClone(NEXRA_MEDIA_INPUT_SCHEMAS[operation]);
641
614
  }
642
- function identifier(value) {
643
- return typeof value === "string" && value.trim() ? value : void 0;
615
+ function isNexraMediaInput(value) {
616
+ if (!value || typeof value !== "object" || Array.isArray(value)) return false;
617
+ const input = value;
618
+ if ("model" in input) return false;
619
+ const content = input.content;
620
+ return Array.isArray(content) && content.length > 0 && content.every((part) => {
621
+ if (!part || typeof part !== "object" || Array.isArray(part)) return false;
622
+ if (part.type === "text") return typeof part.text === "string" && part.text.length > 0;
623
+ if (part.type === "draft_task") {
624
+ const reference = part.draft_task;
625
+ return Boolean(reference && typeof reference === "object" && !Array.isArray(reference) && typeof reference.id === "string" && reference.id.length > 0);
626
+ }
627
+ if (!["image", "video", "audio"].includes(String(part.type))) return false;
628
+ if (typeof part.source === "string") return part.source.length > 0;
629
+ return Boolean(part.source && typeof part.source === "object" && !Array.isArray(part.source) && typeof part.source.assetId === "string" && part.source.assetId.length > 0);
630
+ });
644
631
  }
645
- function httpStatus(value) {
646
- return typeof value === "number" && Number.isInteger(value) && value >= 100 && value <= 599 ? value : void 0;
632
+ function nexraMediaOperationForMode(mode) {
633
+ if (["text-to-image", "image-to-image"].includes(mode)) return "image.generate";
634
+ if (["text-to-video", "image-to-video", "multimodal-to-video", "avatar-video"].includes(mode)) return "video.generate";
635
+ if (["text-to-speech", "text-to-music", "text-to-sfx"].includes(mode)) return "audio.generate";
636
+ if (mode === "image-upscale") return "image.upscale";
637
+ return void 0;
647
638
  }
648
- function resolvePublicErrorLocale(acceptLanguage) {
649
- let chosen = "en";
650
- let highestQuality = 0;
651
- for (const candidate of (acceptLanguage ?? "").split(",")) {
652
- const [tag, ...parameters] = candidate.trim().toLowerCase().split(";");
653
- const locale = /^zh(?:-[a-z0-9]+)*$/.test(tag ?? "") ? "zh-CN" : /^en(?:-[a-z0-9]+)*$/.test(tag ?? "") ? "en" : void 0;
654
- if (!locale) continue;
655
- const qualityParameter = parameters.map((parameter) => parameter.trim()).find((parameter) => parameter.startsWith("q="));
656
- const rawQuality = qualityParameter?.slice(2).trim();
657
- const quality = rawQuality === void 0 ? 1 : /^(?:0(?:\.\d{0,3})?|1(?:\.0{0,3})?)$/.test(rawQuality) ? Number(rawQuality) : 0;
658
- if (quality > highestQuality) {
659
- chosen = locale;
660
- highestQuality = quality;
639
+ function nexraMediaInputSchemaForMode(mode) {
640
+ const operation = nexraMediaOperationForMode(mode);
641
+ const schema = operation ? nexraMediaInputSchema(operation) : void 0;
642
+ if (!schema) return void 0;
643
+ const properties = schema.properties;
644
+ const content = properties.content;
645
+ const items = content.items;
646
+ const variants = Array.isArray(items.oneOf) ? items.oneOf : [];
647
+ if (mode === "avatar-video") {
648
+ for (const variant of variants) {
649
+ const variantProperties = variant.properties;
650
+ if (variantProperties.type.const === "text") {
651
+ variantProperties.role = { type: "string", enum: ["script"] };
652
+ }
661
653
  }
662
654
  }
663
- return chosen;
664
- }
665
- function isRecord(value) {
666
- return typeof value === "object" && value !== null && !Array.isArray(value);
655
+ const allowed = mode === "text-to-image" || mode === "text-to-video" || mode === "text-to-music" || mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["text"]) : mode === "image-to-image" ? /* @__PURE__ */ new Set(["text", "image"]) : mode === "image-to-video" ? /* @__PURE__ */ new Set(["text", "image", "audio"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["text", "audio"]) : /* @__PURE__ */ new Set(["text", "image", "video", "audio"]);
656
+ items.oneOf = variants.filter((variant) => allowed.has(String(variant.properties.type.const)));
657
+ if (mode === "image-to-video") {
658
+ for (const variant of items.oneOf) {
659
+ const variantProperties = variant.properties;
660
+ if (variantProperties.type.const !== "image") continue;
661
+ variantProperties.role = { type: "string", enum: ["first_frame", "last_frame"] };
662
+ const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
663
+ required.add("role");
664
+ variant.required = [...required];
665
+ }
666
+ }
667
+ if (mode === "multimodal-to-video") {
668
+ for (const variant of items.oneOf) {
669
+ const variantProperties = variant.properties;
670
+ const type = String(variantProperties.type.const);
671
+ if (!["image", "video", "audio"].includes(type)) continue;
672
+ variantProperties.role = type === "image" ? { type: "string", enum: ["reference", "subject", "background"] } : type === "video" ? { type: "string", enum: ["reference", "edit", "extend"] } : { type: "string", const: "reference" };
673
+ const required = new Set(Array.isArray(variant.required) ? variant.required.filter((key) => typeof key === "string") : []);
674
+ required.add("role");
675
+ variant.required = [...required];
676
+ }
677
+ }
678
+ const requiredMedia = mode === "image-to-image" || mode === "image-to-video" || mode === "avatar-video" ? "image" : void 0;
679
+ const requiresReferenceMedia = mode === "multimodal-to-video";
680
+ content.allOf = [
681
+ ...mode === "avatar-video" ? [] : [{
682
+ contains: { type: "object", properties: { type: { const: "text" } }, required: ["type"] },
683
+ minContains: 1
684
+ }],
685
+ ...requiredMedia ? [{
686
+ contains: { type: "object", properties: { type: { const: requiredMedia } }, required: ["type"] },
687
+ minContains: 1
688
+ }] : [],
689
+ ...requiresReferenceMedia ? [{
690
+ contains: { type: "object", properties: { type: { enum: ["image", "video", "audio"] } }, required: ["type"] },
691
+ minContains: 1
692
+ }] : []
693
+ ];
694
+ if (mode === "text-to-speech") {
695
+ properties.voice = { ...properties.voice, "x-ui": { order: 10, control: "resource", resource: "voice" } };
696
+ }
697
+ const allowedParameters = mode === "avatar-video" ? /* @__PURE__ */ new Set(["content", "voice", "aspect_ratio", "resolution"]) : mode === "text-to-speech" ? /* @__PURE__ */ new Set(["content", "voice", "language", "output_format", "sample_rate", "speed", "volume", "pitch", "emotion"]) : mode === "text-to-music" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "instrumental", "prompt_influence", "seed"]) : mode === "text-to-sfx" ? /* @__PURE__ */ new Set(["content", "duration", "output_format", "loop", "prompt_influence", "seed"]) : void 0;
698
+ if (allowedParameters) {
699
+ schema.properties = Object.fromEntries(Object.entries(properties).filter(([key]) => allowedParameters.has(key)));
700
+ }
701
+ return schema;
667
702
  }
668
703
 
669
704
  // ../contracts/src/tasks.ts
@@ -764,6 +799,7 @@ export {
764
799
  publicErrorMessage,
765
800
  pickPublicErrorFields,
766
801
  normalizePublicErrorInput,
802
+ extractUpstreamErrorMessage,
767
803
  resolvePublicErrorLocale,
768
804
  NEXRA_MEDIA_API_VERSION,
769
805
  NEXRA_GENERATION_OPERATIONS,
@@ -16,6 +16,7 @@ type PublicErrorFields = PublicErrorContext & {
16
16
  upstreamHttpStatus?: number;
17
17
  upstreamRequestId?: string;
18
18
  upstreamError?: JsonValue;
19
+ upstreamErrorMessage?: string;
19
20
  upstreamRedacted?: true;
20
21
  upstreamTruncated?: true;
21
22
  upstreamUnavailableReason?: PublicUpstreamUnavailableReason;
@@ -26,5 +27,7 @@ type PublicError = PublicErrorFields & {
26
27
  nexraError: NexraError;
27
28
  };
28
29
  type ApiErrorPayload = PublicError;
30
+ /** Extracts text only from known provider error fields, never arbitrary metadata. */
31
+ declare function extractUpstreamErrorMessage(value: unknown): string | undefined;
29
32
 
30
- export type { ApiErrorPayload as A, NexraError as N, PublicErrorFields as P, PublicError as a, PublicErrorContext as b };
33
+ export { type ApiErrorPayload as A, type NexraError as N, type PublicErrorFields as P, type PublicError as a, type PublicErrorContext as b, extractUpstreamErrorMessage as e };
package/dist/index.d.ts CHANGED
@@ -3,10 +3,10 @@ import { H as HttpTransport, M as ModelSearchParams, T as TaskModelSummary, a as
3
3
  export { C as CreateNexraDisplayQuoteBatchRequest, d as CreateNexraQuoteRequest, F as FetchLike, e as MediaGeometryField, f as MediaGeometryProjection, g as ModelCapabilitySummary, h as ModelDateVersion, i as ModelEndpointSummary, j as ModelModality, k as ModelResourceOption, l as NexraBillingCurrency, m as NexraCatalogRevision, n as NexraDisplayQuoteBatch, o as NexraDisplayQuoteBatchEntry, p as NexraModelOperation, q as NexraModelSpec, r as NexraModelSpecFilter, s as NexraQuote, t as NexraSalePrice, u as NexraSalePriceList, v as NexraSettlement, U as UnifiedMediaGeometry, w as applyMediaGeometry, x as decodeMediaGeometry, y as encodeMediaGeometry, z as projectMediaGeometry } from './media-geometry-YD9Y_CFw.js';
4
4
  import { C as CursorPage, J as JsonValue } from './json-Cz0MkWQn.js';
5
5
  export { a as JsonObject, b as JsonPrimitive } from './json-Cz0MkWQn.js';
6
- import { N as NexraError, P as PublicErrorFields } from './errors-DZlSwyv8.js';
7
- export { A as ApiErrorPayload, a as PublicError, b as PublicErrorContext } from './errors-DZlSwyv8.js';
8
- import { V as Voice, C as CreateVoiceRequest, a as VoiceCreation, A as AssetsClient, T as TasksClient, R as RunTaskOptions, b as RunResult, c as TaskResult } from './voices-BXToLr8g.js';
9
- export { d as CreateTaskOptions, e as CreateTaskRequest, f as RequestDetails, g as TASK_STATUSES, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, W as WaitTaskOptions, v as WatchTaskOptions, w as isTerminalTaskStatus, x as verifyWebhook } from './voices-BXToLr8g.js';
6
+ import { N as NexraError, P as PublicErrorFields } from './errors-DJZuAKoO.js';
7
+ export { A as ApiErrorPayload, a as PublicError, b as PublicErrorContext, e as extractUpstreamErrorMessage } from './errors-DJZuAKoO.js';
8
+ import { V as Voice, C as CreateVoiceRequest, a as VoiceCreation, A as AssetsClient, T as TasksClient, R as RunTaskOptions, b as RunResult, c as TaskResult } from './voices-BHzDQ5xH.js';
9
+ export { d as CreateTaskOptions, e as CreateTaskRequest, f as RequestDetails, g as TASK_STATUSES, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, W as WaitTaskOptions, v as WatchTaskOptions, w as isTerminalTaskStatus, x as verifyWebhook } from './voices-BHzDQ5xH.js';
10
10
  import { CatalogClient } from './catalog.js';
11
11
  export { formatModelDisplayName, getModelSpec, listModelSpecs } from './catalog.js';
12
12
  export { ceilDecimal, multiplyDecimal } from './decimal.js';
@@ -59,6 +59,7 @@ declare class NexraApiError extends Error {
59
59
  readonly upstreamHttpStatus?: PublicErrorFields["upstreamHttpStatus"];
60
60
  readonly upstreamRequestId?: string;
61
61
  readonly upstreamError?: PublicErrorFields["upstreamError"];
62
+ readonly upstreamErrorMessage?: string;
62
63
  readonly upstreamRedacted?: true;
63
64
  readonly upstreamTruncated?: true;
64
65
  readonly upstreamUnavailableReason?: PublicErrorFields["upstreamUnavailableReason"];
@@ -95,6 +96,7 @@ declare class NexraTaskError extends Error {
95
96
  get upstreamHttpStatus(): PublicErrorFields["upstreamHttpStatus"];
96
97
  get upstreamRequestId(): string | undefined;
97
98
  get upstreamError(): PublicErrorFields["upstreamError"];
99
+ get upstreamErrorMessage(): string | undefined;
98
100
  get upstreamRedacted(): true | undefined;
99
101
  get upstreamTruncated(): true | undefined;
100
102
  get upstreamUnavailableReason(): PublicErrorFields["upstreamUnavailableReason"];
package/dist/index.js CHANGED
@@ -20,13 +20,14 @@ import {
20
20
  projectMediaGeometry,
21
21
  queryString,
22
22
  sleep
23
- } from "./chunk-ZP34I6D7.js";
23
+ } from "./chunk-Q4A3HJBX.js";
24
24
  import {
25
25
  MEDIA_KINDS,
26
26
  TASK_STATUSES,
27
27
  createTaskRequest,
28
+ extractUpstreamErrorMessage,
28
29
  isTerminalTaskStatus
29
- } from "./chunk-EFSKJCKB.js";
30
+ } from "./chunk-SIBYK5IX.js";
30
31
 
31
32
  // src/assets.ts
32
33
  var AssetsClient = class {
@@ -500,6 +501,7 @@ export {
500
501
  createNexra,
501
502
  decodeMediaGeometry,
502
503
  encodeMediaGeometry,
504
+ extractUpstreamErrorMessage,
503
505
  formatModelDisplayName,
504
506
  getModelSpec,
505
507
  isTerminalTaskStatus,
@@ -2,7 +2,7 @@ import { APICallError, LanguageModelV4 } from '@ai-sdk/provider';
2
2
  import { NexraLanguageProtocol } from './catalog.js';
3
3
  export { NexraLanguageModelBinding } from './catalog.js';
4
4
  import { F as FetchLike } from './media-geometry-YD9Y_CFw.js';
5
- import { N as NexraError } from './errors-DZlSwyv8.js';
5
+ import { N as NexraError } from './errors-DJZuAKoO.js';
6
6
  import './json-Cz0MkWQn.js';
7
7
 
8
8
  type NativeErrorContext = {
package/dist/language.js CHANGED
@@ -6,12 +6,12 @@ import {
6
6
  jsonBody,
7
7
  parseServerSentEvents,
8
8
  resolveNexraLanguageReasoning
9
- } from "./chunk-ZP34I6D7.js";
9
+ } from "./chunk-Q4A3HJBX.js";
10
10
  import {
11
11
  isPublicErrorCode,
12
12
  publicErrorMessage,
13
13
  resolvePublicErrorLocale
14
- } from "./chunk-EFSKJCKB.js";
14
+ } from "./chunk-SIBYK5IX.js";
15
15
 
16
16
  // src/language/index.ts
17
17
  import { createAnthropic } from "@ai-sdk/anthropic";
package/dist/media.js CHANGED
@@ -10,7 +10,7 @@ import {
10
10
  nexraMediaInputSchema,
11
11
  nexraMediaInputSchemaForMode,
12
12
  nexraMediaOperationForMode
13
- } from "./chunk-EFSKJCKB.js";
13
+ } from "./chunk-SIBYK5IX.js";
14
14
  export {
15
15
  NEXRA_GENERATION_OPERATIONS,
16
16
  NEXRA_MEDIA_API_VERSION,
package/dist/types.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { A as AssetImportRequest, a as AssetInput, b as AssetReference, c as AssetUploadOptions, d as MediaAsset, e as MediaAssetStatus, f as MediaKind } from './assets-Cusrjj7_.js';
2
2
  export { C as CreateNexraDisplayQuoteBatchRequest, d as CreateNexraQuoteRequest, F as FetchLike, e as MediaGeometryField, f as MediaGeometryProjection, g as ModelCapabilitySummary, h as ModelDateVersion, i as ModelEndpointSummary, j as ModelModality, c as ModelResourceList, k as ModelResourceOption, b as ModelSchema, M as ModelSearchParams, l as NexraBillingCurrency, m as NexraCatalogRevision, N as NexraClientOptions, n as NexraDisplayQuoteBatch, o as NexraDisplayQuoteBatchEntry, p as NexraModelOperation, q as NexraModelSpec, r as NexraModelSpecFilter, s as NexraQuote, t as NexraSalePrice, u as NexraSalePriceList, v as NexraSettlement, a as TaskModel, T as TaskModelSummary, U as UnifiedMediaGeometry } from './media-geometry-YD9Y_CFw.js';
3
3
  export { C as CursorPage, a as JsonObject, b as JsonPrimitive, J as JsonValue } from './json-Cz0MkWQn.js';
4
- export { A as ApiErrorPayload, N as NexraError, a as PublicError, b as PublicErrorContext, P as PublicErrorFields } from './errors-DZlSwyv8.js';
5
- export { d as CreateTaskOptions, e as CreateTaskRequest, C as CreateVoiceRequest, f as RequestDetails, b as RunResult, R as RunTaskOptions, c as Task, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, c as TaskResult, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, V as Voice, a as VoiceCreation, W as WaitTaskOptions, v as WatchTaskOptions } from './voices-BXToLr8g.js';
4
+ export { A as ApiErrorPayload, N as NexraError, a as PublicError, b as PublicErrorContext, P as PublicErrorFields } from './errors-DJZuAKoO.js';
5
+ export { d as CreateTaskOptions, e as CreateTaskRequest, C as CreateVoiceRequest, f as RequestDetails, b as RunResult, R as RunTaskOptions, c as Task, h as TaskCost, i as TaskError, j as TaskEvent, k as TaskEventType, l as TaskListParams, m as TaskPage, n as TaskProgress, o as TaskReceipt, c as TaskResult, p as TaskStatus, q as TaskTiming, r as TaskUsage, s as TaskWebhookConfig, t as TerminalTaskStatus, u as VerifyWebhookOptions, V as Voice, a as VoiceCreation, W as WaitTaskOptions, v as WatchTaskOptions } from './voices-BHzDQ5xH.js';
@@ -1,7 +1,7 @@
1
1
  import { c as AssetUploadOptions, d as MediaAsset, A as AssetImportRequest, g as AssetCertificationRequest, h as AssetCertification, i as AssetCertificationWaitOptions } from './assets-Cusrjj7_.js';
2
2
  import { H as HttpTransport, v as NexraSettlement } from './media-geometry-YD9Y_CFw.js';
3
3
  import { a as JsonObject, J as JsonValue, C as CursorPage } from './json-Cz0MkWQn.js';
4
- import { P as PublicErrorFields, a as PublicError, b as PublicErrorContext, N as NexraError } from './errors-DZlSwyv8.js';
4
+ import { P as PublicErrorFields, a as PublicError, b as PublicErrorContext, N as NexraError } from './errors-DJZuAKoO.js';
5
5
 
6
6
  declare class AssetsClient {
7
7
  private readonly transport;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@byte_fluffy/nexra-sdk",
3
- "version": "0.1.0-alpha.39",
3
+ "version": "0.1.0-alpha.40",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "sideEffects": false,