@sogni-ai/sogni-client 5.34.0 → 5.34.1
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/CHANGELOG.md +7 -0
- package/dist/Projects/Job.js +7 -0
- package/dist/Projects/Job.js.map +1 -1
- package/dist/Projects/Project.js +14 -0
- package/dist/Projects/Project.js.map +1 -1
- package/dist/Projects/createJobRequestMessage.js +4 -1
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +13 -1
- package/dist/Projects/index.js +23 -6
- package/dist/Projects/index.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist-esm/Projects/Job.js +8 -1
- package/dist-esm/Projects/Job.js.map +1 -1
- package/dist-esm/Projects/Project.js +14 -0
- package/dist-esm/Projects/Project.js.map +1 -1
- package/dist-esm/Projects/createJobRequestMessage.js +4 -1
- package/dist-esm/Projects/createJobRequestMessage.js.map +1 -1
- package/dist-esm/Projects/index.js +23 -6
- package/dist-esm/Projects/index.js.map +1 -1
- package/dist-esm/version.js +1 -1
- package/package.json +1 -1
- package/src/Projects/Job.ts +8 -1
- package/src/Projects/Project.ts +13 -0
- package/src/Projects/createJobRequestMessage.ts +3 -1
- package/src/Projects/index.ts +22 -6
- package/src/version.ts +1 -1
package/src/Projects/Job.ts
CHANGED
|
@@ -7,7 +7,7 @@ import getUUID from '../lib/getUUID.js';
|
|
|
7
7
|
import { EnhancementStrength } from './types/index.js';
|
|
8
8
|
import Project from './Project.js';
|
|
9
9
|
import { SupernetType } from '../ApiClient/WebSocketClient/types.js';
|
|
10
|
-
import { getEnhacementStrength } from './utils/index.js';
|
|
10
|
+
import { getEnhacementStrength, isSegmentationModel } from './utils/index.js';
|
|
11
11
|
import { TokenType } from '../types/token.js';
|
|
12
12
|
import has from 'lodash/has.js';
|
|
13
13
|
import type { JobProvenance } from './types/JobProvenance.js';
|
|
@@ -664,6 +664,13 @@ class Job extends DataEntity<JobData, JobEventMap> {
|
|
|
664
664
|
if (parentProjectParams.type !== 'image' || this.type !== 'image') {
|
|
665
665
|
throw new Error('Enhancement is only available for images');
|
|
666
666
|
}
|
|
667
|
+
// A segmentation result reports `type === 'image'` and would otherwise sail
|
|
668
|
+
// through the guard above, then be submitted as the starting image of a
|
|
669
|
+
// paid Flux render. A mask PNG (or its cut-out) has no prompt-to-pixels
|
|
670
|
+
// relationship to enhance, so this spends real Spark on a nonsense render.
|
|
671
|
+
if (isSegmentationModel(parentProjectParams.modelId)) {
|
|
672
|
+
throw new Error('Enhancement is not available for segmentation masks');
|
|
673
|
+
}
|
|
667
674
|
if (this.status !== 'completed') {
|
|
668
675
|
throw new Error('Job is not completed yet');
|
|
669
676
|
}
|
package/src/Projects/Project.ts
CHANGED
|
@@ -503,6 +503,19 @@ class Project extends DataEntity<ProjectData, ProjectEventMap> {
|
|
|
503
503
|
project: this
|
|
504
504
|
});
|
|
505
505
|
this._addJob(jobInstance);
|
|
506
|
+
// A job discovered for the first time through the REST snapshot needs
|
|
507
|
+
// the same sync a tracked job gets. `Job.fromRaw` only copies the
|
|
508
|
+
// legacy `resultUrl`/`imageUrl`/`videoUrl` fields, and a completed job
|
|
509
|
+
// whose media carries none of them — every GLB, and any record the
|
|
510
|
+
// server did not inline a URL for — would otherwise stay at
|
|
511
|
+
// `resultUrl: null` forever, so `waitForCompletion()` resolves with
|
|
512
|
+
// nothing. This mints the download URL exactly as the tracked path does.
|
|
513
|
+
try {
|
|
514
|
+
await jobInstance._syncWithRestData(job);
|
|
515
|
+
} catch (error) {
|
|
516
|
+
this._logger.error(error);
|
|
517
|
+
this._logger.error(`Failed to sync job ${jobInstance.id}`);
|
|
518
|
+
}
|
|
506
519
|
}
|
|
507
520
|
}
|
|
508
521
|
|
|
@@ -1576,8 +1576,10 @@ function createJobRequestMessage(id: string, params: ProjectParams, options: Mod
|
|
|
1576
1576
|
const jobRequest: Record<string, any> = {
|
|
1577
1577
|
...template,
|
|
1578
1578
|
keyFrames: [keyFrame],
|
|
1579
|
+
// Neither utility workflow has intermediate images to preview: SAM 3
|
|
1580
|
+
// returns one mask and Pixal3D a 3D reconstruction.
|
|
1579
1581
|
previews:
|
|
1580
|
-
params.modelId === SAM3_IMAGE_SEGMENT_WORKFLOW_ID
|
|
1582
|
+
params.modelId === SAM3_IMAGE_SEGMENT_WORKFLOW_ID || params.modelId === PIXAL3D_WORKFLOW_ID
|
|
1581
1583
|
? 0
|
|
1582
1584
|
: isImageParams(params)
|
|
1583
1585
|
? params.numberOfPreviews || 0
|
package/src/Projects/index.ts
CHANGED
|
@@ -402,13 +402,23 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
402
402
|
return isAudioModel(modelId);
|
|
403
403
|
}
|
|
404
404
|
|
|
405
|
-
/**
|
|
405
|
+
/**
|
|
406
|
+
* Check whether a model returns a 3D artifact through the media endpoint.
|
|
407
|
+
*
|
|
408
|
+
* The `pixal3d_` prefix is a positive override here, not merely a fallback
|
|
409
|
+
* for an unloaded catalog. That prefix is structural rather than curated:
|
|
410
|
+
* every Pixal3D workflow reconstructs a binary glTF, and the image download
|
|
411
|
+
* endpoint cannot serve one. A catalog that mislabels such a model as
|
|
412
|
+
* `image` therefore breaks every artifact download with no client-side
|
|
413
|
+
* recovery, so the SDK's own knowledge wins wherever it has any.
|
|
414
|
+
*
|
|
415
|
+
* The catalog stays authoritative for every model the SDK has no prefix
|
|
416
|
+
* knowledge of, so a future `media: 'model'` family needs no SDK release.
|
|
417
|
+
*/
|
|
406
418
|
isModelArtifactModelId(modelId: string): boolean {
|
|
419
|
+
if (isModelArtifactModel(modelId)) return true;
|
|
407
420
|
const model = this._supportedModels.data?.find((m) => m.id === modelId);
|
|
408
|
-
|
|
409
|
-
return model.media === 'model';
|
|
410
|
-
}
|
|
411
|
-
return isModelArtifactModel(modelId);
|
|
421
|
+
return model ? model.media === 'model' : false;
|
|
412
422
|
}
|
|
413
423
|
|
|
414
424
|
constructor(config: ApiConfig) {
|
|
@@ -1343,7 +1353,7 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
1343
1353
|
// SAM3 is a one-source/one-mask utility workflow. Normalize before Project
|
|
1344
1354
|
// construction so lifecycle completion and result MIME use the same values
|
|
1345
1355
|
// as the serialized request.
|
|
1346
|
-
|
|
1356
|
+
let normalizedData =
|
|
1347
1357
|
data.type === 'image' && data.modelId === 'sam3_image_segment_bf16'
|
|
1348
1358
|
? ({
|
|
1349
1359
|
...data,
|
|
@@ -1352,6 +1362,12 @@ class ProjectsApi extends ApiGroup<ProjectApiEvents> {
|
|
|
1352
1362
|
outputFormat: 'png'
|
|
1353
1363
|
} as ProjectParams)
|
|
1354
1364
|
: data;
|
|
1365
|
+
// Pixal3D reconstructs a 3D artifact, so there are no intermediate images
|
|
1366
|
+
// to preview. Normalize here as well as on the wire so the Project's own
|
|
1367
|
+
// params agree with the request that was actually sent.
|
|
1368
|
+
if (normalizedData.type === 'image' && isModelArtifactModel(normalizedData.modelId)) {
|
|
1369
|
+
normalizedData = { ...normalizedData, numberOfPreviews: 0 } as ProjectParams;
|
|
1370
|
+
}
|
|
1355
1371
|
const project = new Project({ ...normalizedData }, { api: this, logger: this.client.logger });
|
|
1356
1372
|
const modelOptions = await this.getModelOptions(normalizedData.modelId);
|
|
1357
1373
|
const requestParams = {
|
package/src/version.ts
CHANGED