@sogni-ai/sogni-client 5.69.1 → 5.71.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.
@@ -1653,6 +1653,23 @@ function applyVideoParams(
1653
1653
  rejectRetiredOutputScale(params);
1654
1654
  validateMinimaxH3Params(params);
1655
1655
  const keyFrame: Record<string, any> = { ...inputKeyframe };
1656
+ if (params.referenceVideoCompression !== undefined) {
1657
+ if (!['none', 'vpack'].includes(params.referenceVideoCompression)) {
1658
+ throw new Error('referenceVideoCompression must be none or vpack.');
1659
+ }
1660
+ if (params.referenceVideoCompression === 'vpack') {
1661
+ if (
1662
+ !isMinimaxH3ReferenceModel(params.modelId) ||
1663
+ params.modelId.endsWith('_2stage') ||
1664
+ !getMinimaxH3ReferenceVideoSlots(params).length
1665
+ ) {
1666
+ throw new Error(
1667
+ 'VPack requires an uploaded reference video on a one-stage MiniMax H3 Reference to Video model.'
1668
+ );
1669
+ }
1670
+ keyFrame.referenceVideoCompression = 'vpack';
1671
+ }
1672
+ }
1656
1673
  if (params.referenceImage) {
1657
1674
  keyFrame.hasReferenceImage = true;
1658
1675
  }
@@ -394,10 +394,39 @@ export type ProjectStatusSnapshot = Partial<
394
394
  finished: boolean;
395
395
  workerJobs: RawProject['workerJobs'];
396
396
  completedWorkerJobs: RawProject['completedWorkerJobs'];
397
+ /** For a failed project: why, as its owner was told (status-only records keep it for a day). */
398
+ failure?: ProjectFailure;
397
399
  };
398
400
 
399
401
  const IN_FLIGHT_LOOKUP_STATUSES: ReadonlySet<string> = new Set(['pending', 'queued', 'processing']);
400
402
 
403
+ /** The server's failure explanation, its string fields only; null when it has none. */
404
+ function projectFailure(value: unknown): ProjectFailure | null {
405
+ if (!value || typeof value !== 'object') return null;
406
+ const record = value as Record<string, unknown>;
407
+ const failure: ProjectFailure = {};
408
+ for (const key of ['code', 'category', 'message'] as const) {
409
+ if (typeof record[key] === 'string' && record[key]) failure[key] = record[key] as string;
410
+ }
411
+ return Object.keys(failure).length ? failure : null;
412
+ }
413
+
414
+ /**
415
+ * Why a failed project failed, as its owner was told when it did: the provider's
416
+ * code, Sogni's category and the public message (the `jobError` event's
417
+ * `vendorErrorCode`, `vendorFailureCategory` and `error_message`). Kept with the
418
+ * project's status for a day, so a client that reconnects, or follows the
419
+ * project from another app, can say why it failed.
420
+ */
421
+ export interface ProjectFailure {
422
+ /** The provider's error code, e.g. `OutputAudioSensitiveContentDetected.PolicyViolation`. */
423
+ code?: string;
424
+ /** Sogni's category for it, e.g. `content_policy`, `vendor_transient`, `timeout`. */
425
+ category?: string;
426
+ /** The message shown to the account when it failed. */
427
+ message?: string;
428
+ }
429
+
401
430
  /**
402
431
  * One render of a project returned by {@link ProjectsApi.getResult}.
403
432
  */
@@ -444,6 +473,8 @@ export interface ProjectResult {
444
473
  * did not report one.
445
474
  */
446
475
  waitingReason?: WaitingReason | null;
476
+ /** For a failed project: why, as its owner was told. Absent when the server recorded no explanation. */
477
+ failure?: ProjectFailure;
447
478
  jobs: ProjectResultJob[];
448
479
  }
449
480
 
@@ -1081,6 +1112,9 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
1081
1112
  if (data.vendorFailureCategory) {
1082
1113
  error.vendorFailureCategory = data.vendorFailureCategory;
1083
1114
  }
1115
+ if (typeof data.vendorErrorCode === 'string' && data.vendorErrorCode) {
1116
+ error.vendorErrorCode = data.vendorErrorCode;
1117
+ }
1084
1118
  if (data.subscriptionLimit) {
1085
1119
  error.subscriptionLimit = true;
1086
1120
  if (data.requiredPlans) error.requiredPlans = data.requiredPlans;
@@ -2633,6 +2667,7 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
2633
2667
  // The stored record's model carries its media type even though ProjectModel does not declare it.
2634
2668
  const recordType = (snapshot.model as { type?: unknown } | undefined)?.type;
2635
2669
  const projectType = typeof recordType === 'string' ? recordType : undefined;
2670
+ const failure = projectFailure(snapshot.failure);
2636
2671
  const jobs: ProjectResultJob[] = [];
2637
2672
  const seen = new Set<string>();
2638
2673
  for (const job of [...(snapshot.completedWorkerJobs || []), ...(snapshot.workerJobs || [])]) {
@@ -2684,6 +2719,7 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
2684
2719
  finished: snapshot.finished,
2685
2720
  ...(modelId ? { modelId } : {}),
2686
2721
  ...(snapshot.waitingReason !== undefined ? { waitingReason: snapshot.waitingReason } : {}),
2722
+ ...(failure ? { failure } : {}),
2687
2723
  jobs
2688
2724
  };
2689
2725
  }
@@ -717,6 +717,8 @@ export interface VideoProjectParams extends BaseProjectParams {
717
717
  * pricing and job admission. Omit this field when duration is unavailable.
718
718
  */
719
719
  referenceVideoDurations?: number[];
720
+ /** Opt-in VPack compression for one-stage MiniMax H3 reference video. Omitted/none preserves the original reference tokens. */
721
+ referenceVideoCompression?: 'none' | 'vpack';
720
722
  /**
721
723
  * Inpaint mask IMAGE for distilled LTX 2.5 or LTX 2.3 v2v inpaint workflows.
722
724
  * White pixels mark the region to regenerate. Maps to jobKey 'referenceMask'.
package/src/index.ts CHANGED
@@ -108,6 +108,7 @@ import type {
108
108
  ListRecentProjectsOptions,
109
109
  ProjectLookupStatus,
110
110
  ProjectResolution,
111
+ ProjectFailure,
111
112
  ProjectResult,
112
113
  ProjectResultJob,
113
114
  ProjectStatusSnapshot,
@@ -469,6 +470,7 @@ export type {
469
470
  ProjectLookupStatus,
470
471
  ProjectRecoverySnapshot,
471
472
  ProjectResolution,
473
+ ProjectFailure,
472
474
  ProjectResult,
473
475
  ProjectResultJob,
474
476
  ProjectStatusSnapshot,
@@ -12,6 +12,15 @@ interface ErrorData {
12
12
  * with a generic failure message.
13
13
  */
14
14
  vendorFailureCategory?: string;
15
+ /**
16
+ * The provider's own error code for an external generation failure, when it
17
+ * gave one, e.g. `OutputAudioSensitiveContentDetected.PolicyViolation` (the
18
+ * provider flagged the soundtrack it generated, usually as possibly matching
19
+ * copyrighted audio) or `OutputVideoSensitiveContentDetected` (the picture).
20
+ * Lets an app tell kinds of refusal apart within one category without
21
+ * reading the message.
22
+ */
23
+ vendorErrorCode?: string;
15
24
  /**
16
25
  * Discriminator set to `true` when this render-path error is a subscription
17
26
  * FEATURE-gate denial (socket error code 4081). The four fields below are
package/src/version.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  // AUTO-GENERATED by scripts/generate-version.mjs — do not edit.
2
2
  // Source of truth: package.json version.
3
- export const LIB_VERSION = '5.69.1';
3
+ export const LIB_VERSION = '5.71.0';