@howells/motif-sdk 0.5.1 → 0.6.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.cjs +22 -8
- package/dist/index.d.cts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +22 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2305,6 +2305,18 @@ function toHeaderRecord(headers) {
|
|
|
2305
2305
|
}
|
|
2306
2306
|
return headers;
|
|
2307
2307
|
}
|
|
2308
|
+
function requestIdFromBody(text) {
|
|
2309
|
+
let parsed;
|
|
2310
|
+
try {
|
|
2311
|
+
parsed = JSON.parse(text);
|
|
2312
|
+
} catch {
|
|
2313
|
+
return void 0;
|
|
2314
|
+
}
|
|
2315
|
+
if (!isRecord(parsed)) {
|
|
2316
|
+
return void 0;
|
|
2317
|
+
}
|
|
2318
|
+
return asString(parsed.request_id) ?? asString(parsed.requestId) ?? asString(parsed.trace_id);
|
|
2319
|
+
}
|
|
2308
2320
|
|
|
2309
2321
|
// src/tools.ts
|
|
2310
2322
|
var FAL_EXPLORE_CHECKED_AT = "2026-05-12";
|
|
@@ -2764,9 +2776,8 @@ var MotifServer = class {
|
|
|
2764
2776
|
return await this.getJobResult(job.value.endpoint, job.value.requestId);
|
|
2765
2777
|
}
|
|
2766
2778
|
if (status.value.status === "failed") {
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
);
|
|
2779
|
+
const message = status.value.error ?? "Queued generation failed";
|
|
2780
|
+
return (0, import_neverthrow.err)(new MotifError(message, 0, void 0, job.value.requestId));
|
|
2770
2781
|
}
|
|
2771
2782
|
await new Promise((resolve) => {
|
|
2772
2783
|
setTimeout(resolve, pollIntervalMs);
|
|
@@ -3165,11 +3176,10 @@ var MotifServer = class {
|
|
|
3165
3176
|
}
|
|
3166
3177
|
if (!response.ok) {
|
|
3167
3178
|
const text = await response.text();
|
|
3179
|
+
const message = `Request failed: ${response.status} ${text}`;
|
|
3180
|
+
const requestId = response.headers.get("x-fal-request-id") ?? requestIdFromBody(text);
|
|
3168
3181
|
return (0, import_neverthrow.err)(
|
|
3169
|
-
new MotifError(
|
|
3170
|
-
`Request failed: ${response.status} ${text}`,
|
|
3171
|
-
response.status
|
|
3172
|
-
)
|
|
3182
|
+
new MotifError(message, response.status, void 0, requestId)
|
|
3173
3183
|
);
|
|
3174
3184
|
}
|
|
3175
3185
|
return (0, import_neverthrow.ok)(response);
|
|
@@ -3229,11 +3239,15 @@ var MotifServer = class {
|
|
|
3229
3239
|
var MotifError = class extends Error {
|
|
3230
3240
|
status;
|
|
3231
3241
|
code;
|
|
3232
|
-
|
|
3242
|
+
/** fal's request-correlation id (from the `x-fal-request-id` header or the
|
|
3243
|
+
* error body). Ties a failure back to fal's dashboard/support. */
|
|
3244
|
+
requestId;
|
|
3245
|
+
constructor(message, status, code, requestId) {
|
|
3233
3246
|
super(message);
|
|
3234
3247
|
this.name = "MotifError";
|
|
3235
3248
|
this.status = status;
|
|
3236
3249
|
this.code = code;
|
|
3250
|
+
this.requestId = requestId;
|
|
3237
3251
|
}
|
|
3238
3252
|
};
|
|
3239
3253
|
function toMotifError(error) {
|
package/dist/index.d.cts
CHANGED
|
@@ -927,7 +927,10 @@ declare class MotifServer {
|
|
|
927
927
|
declare class MotifError extends Error {
|
|
928
928
|
readonly status: number;
|
|
929
929
|
readonly code?: string;
|
|
930
|
-
|
|
930
|
+
/** fal's request-correlation id (from the `x-fal-request-id` header or the
|
|
931
|
+
* error body). Ties a failure back to fal's dashboard/support. */
|
|
932
|
+
readonly requestId?: string;
|
|
933
|
+
constructor(message: string, status: number, code?: string, requestId?: string);
|
|
931
934
|
}
|
|
932
935
|
|
|
933
936
|
type FalToolInputKind = "image" | "images" | "video";
|
package/dist/index.d.ts
CHANGED
|
@@ -927,7 +927,10 @@ declare class MotifServer {
|
|
|
927
927
|
declare class MotifError extends Error {
|
|
928
928
|
readonly status: number;
|
|
929
929
|
readonly code?: string;
|
|
930
|
-
|
|
930
|
+
/** fal's request-correlation id (from the `x-fal-request-id` header or the
|
|
931
|
+
* error body). Ties a failure back to fal's dashboard/support. */
|
|
932
|
+
readonly requestId?: string;
|
|
933
|
+
constructor(message: string, status: number, code?: string, requestId?: string);
|
|
931
934
|
}
|
|
932
935
|
|
|
933
936
|
type FalToolInputKind = "image" | "images" | "video";
|
package/dist/index.js
CHANGED
|
@@ -2246,6 +2246,18 @@ function toHeaderRecord(headers) {
|
|
|
2246
2246
|
}
|
|
2247
2247
|
return headers;
|
|
2248
2248
|
}
|
|
2249
|
+
function requestIdFromBody(text) {
|
|
2250
|
+
let parsed;
|
|
2251
|
+
try {
|
|
2252
|
+
parsed = JSON.parse(text);
|
|
2253
|
+
} catch {
|
|
2254
|
+
return void 0;
|
|
2255
|
+
}
|
|
2256
|
+
if (!isRecord(parsed)) {
|
|
2257
|
+
return void 0;
|
|
2258
|
+
}
|
|
2259
|
+
return asString(parsed.request_id) ?? asString(parsed.requestId) ?? asString(parsed.trace_id);
|
|
2260
|
+
}
|
|
2249
2261
|
|
|
2250
2262
|
// src/tools.ts
|
|
2251
2263
|
var FAL_EXPLORE_CHECKED_AT = "2026-05-12";
|
|
@@ -2705,9 +2717,8 @@ var MotifServer = class {
|
|
|
2705
2717
|
return await this.getJobResult(job.value.endpoint, job.value.requestId);
|
|
2706
2718
|
}
|
|
2707
2719
|
if (status.value.status === "failed") {
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
);
|
|
2720
|
+
const message = status.value.error ?? "Queued generation failed";
|
|
2721
|
+
return err(new MotifError(message, 0, void 0, job.value.requestId));
|
|
2711
2722
|
}
|
|
2712
2723
|
await new Promise((resolve) => {
|
|
2713
2724
|
setTimeout(resolve, pollIntervalMs);
|
|
@@ -3106,11 +3117,10 @@ var MotifServer = class {
|
|
|
3106
3117
|
}
|
|
3107
3118
|
if (!response.ok) {
|
|
3108
3119
|
const text = await response.text();
|
|
3120
|
+
const message = `Request failed: ${response.status} ${text}`;
|
|
3121
|
+
const requestId = response.headers.get("x-fal-request-id") ?? requestIdFromBody(text);
|
|
3109
3122
|
return err(
|
|
3110
|
-
new MotifError(
|
|
3111
|
-
`Request failed: ${response.status} ${text}`,
|
|
3112
|
-
response.status
|
|
3113
|
-
)
|
|
3123
|
+
new MotifError(message, response.status, void 0, requestId)
|
|
3114
3124
|
);
|
|
3115
3125
|
}
|
|
3116
3126
|
return ok(response);
|
|
@@ -3170,11 +3180,15 @@ var MotifServer = class {
|
|
|
3170
3180
|
var MotifError = class extends Error {
|
|
3171
3181
|
status;
|
|
3172
3182
|
code;
|
|
3173
|
-
|
|
3183
|
+
/** fal's request-correlation id (from the `x-fal-request-id` header or the
|
|
3184
|
+
* error body). Ties a failure back to fal's dashboard/support. */
|
|
3185
|
+
requestId;
|
|
3186
|
+
constructor(message, status, code, requestId) {
|
|
3174
3187
|
super(message);
|
|
3175
3188
|
this.name = "MotifError";
|
|
3176
3189
|
this.status = status;
|
|
3177
3190
|
this.code = code;
|
|
3191
|
+
this.requestId = requestId;
|
|
3178
3192
|
}
|
|
3179
3193
|
};
|
|
3180
3194
|
function toMotifError(error) {
|