@sogni-ai/sogni-client 5.78.0 → 5.80.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/CHANGELOG.md +22 -0
- package/README.md +89 -2
- package/dist/Chat/_hostedToolsManifest.generated.js +20 -7
- package/dist/Chat/_hostedToolsManifest.generated.js.map +1 -1
- package/dist/Projects/createJobRequestMessage.js +72 -30
- package/dist/Projects/createJobRequestMessage.js.map +1 -1
- package/dist/Projects/index.d.ts +2 -0
- package/dist/Projects/index.js +11 -0
- package/dist/Projects/index.js.map +1 -1
- package/dist/Projects/types/index.d.ts +89 -3
- package/dist/Projects/types/index.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js.map +1 -1
- package/dist/lib/getUUID.d.ts +11 -0
- package/dist/lib/getUUID.js +32 -3
- package/dist/lib/getUUID.js.map +1 -1
- package/dist/lib/validation.js +6 -9
- package/dist/lib/validation.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist-esm/Chat/_hostedToolsManifest.generated.js +20 -7
- package/dist-esm/Chat/_hostedToolsManifest.generated.js.map +1 -1
- package/dist-esm/Projects/createJobRequestMessage.js +72 -30
- package/dist-esm/Projects/createJobRequestMessage.js.map +1 -1
- package/dist-esm/Projects/index.js +11 -0
- package/dist-esm/Projects/index.js.map +1 -1
- package/dist-esm/Projects/types/index.js.map +1 -1
- package/dist-esm/index.js.map +1 -1
- package/dist-esm/lib/getUUID.js +32 -3
- package/dist-esm/lib/getUUID.js.map +1 -1
- package/dist-esm/lib/validation.js +6 -9
- package/dist-esm/lib/validation.js.map +1 -1
- package/dist-esm/version.js +1 -1
- package/llms-full.txt +85 -0
- package/llms.txt +85 -0
- package/package.json +3 -3
- package/src/Chat/_hostedToolsManifest.generated.ts +20 -7
- package/src/Projects/createJobRequestMessage.ts +112 -20
- package/src/Projects/index.ts +11 -0
- package/src/Projects/types/index.ts +95 -3
- package/src/index.ts +6 -0
- package/src/lib/getUUID.ts +33 -4
- package/src/lib/validation.ts +2 -5
- package/src/version.ts +1 -1
|
@@ -875,14 +875,100 @@ export interface Sam3PromptBox {
|
|
|
875
875
|
label?: 'positive' | 'negative';
|
|
876
876
|
}
|
|
877
877
|
|
|
878
|
-
/**
|
|
878
|
+
/**
|
|
879
|
+
* A selection made from a drawn region instead of clicks, boxes or text. The
|
|
880
|
+
* region starts the tracker on the prompt frame, as a click does, so that
|
|
881
|
+
* frame's mask is the tracker's own shape for the region rather than the exact
|
|
882
|
+
* drawing, consistent with the frames around it. Draw it tight: background or
|
|
883
|
+
* a foreground object inside the region stays in the mask for several frames.
|
|
884
|
+
*/
|
|
885
|
+
export interface Sam3PromptMask {
|
|
886
|
+
/**
|
|
887
|
+
* 1 to 64 rings of `[x, y]` points, each 3 to 2048 points and 4096 points in
|
|
888
|
+
* total; a whole prompt holds at most 4096 across its objects and frames.
|
|
889
|
+
* Coordinates are normalized to the source frame (0 to 1, origin top
|
|
890
|
+
* left). Rings fill even-odd: a ring inside another ring is a hole.
|
|
891
|
+
*/
|
|
892
|
+
polygons: Array<Array<[number, number]>>;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
/**
|
|
896
|
+
* One object to select in a video: exactly one of `points` (with at most one
|
|
897
|
+
* box), `boxes`, `text` (with optional signed boxes) or `mask`.
|
|
898
|
+
*/
|
|
899
|
+
export interface Sam3VideoSelection extends Pick<
|
|
900
|
+
Sam3ImagePrompt,
|
|
901
|
+
'points' | 'boxes' | 'text' | 'threshold' | 'multimask'
|
|
902
|
+
> {
|
|
903
|
+
/**
|
|
904
|
+
* Select this drawn region. Not combinable with `points`, `boxes`, `text`,
|
|
905
|
+
* `threshold` or `multimask`; `objectIndex` must be 0 or absent.
|
|
906
|
+
*/
|
|
907
|
+
mask?: Sam3PromptMask;
|
|
908
|
+
/** Zero-based candidate in confidence order. Defaults to the best match. */
|
|
909
|
+
objectIndex?: number;
|
|
910
|
+
}
|
|
911
|
+
|
|
912
|
+
/** One prompted frame of `Sam3VideoPrompt.frames`: a selection plus the source frame it refers to. */
|
|
913
|
+
export type Sam3VideoFramePrompt = Sam3VideoSelection & {
|
|
914
|
+
/** Zero-based source frame. Each entry names a different frame. */
|
|
915
|
+
frameIndex: number;
|
|
916
|
+
};
|
|
917
|
+
|
|
918
|
+
/**
|
|
919
|
+
* A bounded prompt for SAM 3 video selection. Output is one hard binary mask
|
|
920
|
+
* video. By default it selects one object (`points`, `boxes` or `text`) on one
|
|
921
|
+
* frame and tracks it through the clip.
|
|
922
|
+
*
|
|
923
|
+
* `mask`, `objects`, `frames` and `memory` are optional and absent by default;
|
|
924
|
+
* a prompt without them behaves exactly as before.
|
|
925
|
+
*/
|
|
879
926
|
export interface Sam3VideoPrompt extends Omit<Sam3ImagePrompt, 'applyMask' | 'maxInstances'> {
|
|
880
|
-
/**
|
|
927
|
+
/**
|
|
928
|
+
* Zero-based source frame the selection refers to. Defaults to 0. Not used
|
|
929
|
+
* with `frames`, where each entry carries its own.
|
|
930
|
+
*/
|
|
881
931
|
frameIndex?: number;
|
|
882
|
-
/** Zero-based candidate
|
|
932
|
+
/** Zero-based text candidate or supplied box. Point prompts require 0. Defaults to 0. */
|
|
883
933
|
objectIndex?: number;
|
|
884
934
|
output?: 'mask';
|
|
885
935
|
edges?: 'hard';
|
|
936
|
+
/**
|
|
937
|
+
* Select a drawn region on the prompt frame instead of `points`, `boxes` or
|
|
938
|
+
* `text`. Not combinable with them, nor with `threshold` or `multimask`;
|
|
939
|
+
* `objectIndex` must be 0 or absent.
|
|
940
|
+
*/
|
|
941
|
+
mask?: Sam3PromptMask;
|
|
942
|
+
/**
|
|
943
|
+
* Track 2 to 16 objects together and merge them into one mask: a crowd, a
|
|
944
|
+
* figure plus the prop it holds, a monitor plus the webcam on it. Every
|
|
945
|
+
* object is selected on `frameIndex` and tracked jointly; every output frame
|
|
946
|
+
* is the union of their masks. Requires `combine: 'union'`. Put each object's
|
|
947
|
+
* selection inside its entry: the top-level `points`, `boxes`, `text`,
|
|
948
|
+
* `mask`, `threshold`, `multimask` and `objectIndex` are rejected alongside
|
|
949
|
+
* `objects`, and so is `frames`.
|
|
950
|
+
*/
|
|
951
|
+
objects?: Sam3VideoSelection[];
|
|
952
|
+
/** How `objects` combine into the output. Required with `objects`; `'union'` is the only value. */
|
|
953
|
+
combine?: 'union';
|
|
954
|
+
/**
|
|
955
|
+
* Prompt the same object on 2 to 8 different source frames. Each output frame
|
|
956
|
+
* takes the track from the nearest prompted frame (ties go to the earlier
|
|
957
|
+
* one), so the whole clip is still tracked about once. Use it for a loop
|
|
958
|
+
* whose last frame repeats its first (prompt frame 0 and the last frame with
|
|
959
|
+
* the same selection), or to correct drift mid-clip. Rejected together with
|
|
960
|
+
* the top-level `frameIndex`, the top-level selection fields and `objects`.
|
|
961
|
+
*/
|
|
962
|
+
frames?: Sam3VideoFramePrompt[];
|
|
963
|
+
/**
|
|
964
|
+
* How tracking carries from one 32-frame chunk to the next. `'chunk'` (the
|
|
965
|
+
* default, the original behaviour) seeds each chunk from the previous chunk's
|
|
966
|
+
* last mask; an object lost at the end of a chunk is not found again.
|
|
967
|
+
* `'anchor'` tracks every chunk from the prompt frame and its selection
|
|
968
|
+
* instead, so tracking errors do not carry from chunk to chunk and a lost
|
|
969
|
+
* object can be picked up again, but the mask can shift where a chunk starts.
|
|
970
|
+
*/
|
|
971
|
+
memory?: 'chunk' | 'anchor';
|
|
886
972
|
}
|
|
887
973
|
|
|
888
974
|
export interface Sam3ImagePrompt {
|
|
@@ -1408,6 +1494,12 @@ export interface VideoEstimateRequest {
|
|
|
1408
1494
|
keyframeCount?: number;
|
|
1409
1495
|
/** The job's `keyframes`; only their count is used, to price them. */
|
|
1410
1496
|
keyframes?: readonly unknown[];
|
|
1497
|
+
/**
|
|
1498
|
+
* SAM 3 video selection: the job's own `sam3VideoPrompt`. Only the options that
|
|
1499
|
+
* change its price are sent: the number of `objects` and the `memory` mode. A
|
|
1500
|
+
* prompt without them quotes exactly as before.
|
|
1501
|
+
*/
|
|
1502
|
+
sam3VideoPrompt?: Sam3VideoPrompt;
|
|
1411
1503
|
/**
|
|
1412
1504
|
* Combined duration of MiniMax H3 r2v reference-video input, in seconds.
|
|
1413
1505
|
* The estimate bills it at the selected output resolution/tier rate.
|
package/src/index.ts
CHANGED
|
@@ -67,7 +67,10 @@ import {
|
|
|
67
67
|
Pixal3dTemplateVariant,
|
|
68
68
|
Sam3ImagePrompt,
|
|
69
69
|
Sam3VideoPrompt,
|
|
70
|
+
Sam3VideoSelection,
|
|
71
|
+
Sam3VideoFramePrompt,
|
|
70
72
|
Sam3PromptBox,
|
|
73
|
+
Sam3PromptMask,
|
|
71
74
|
Sam3PromptPoint,
|
|
72
75
|
Sam3Selection,
|
|
73
76
|
ProjectParams,
|
|
@@ -360,7 +363,10 @@ export type {
|
|
|
360
363
|
Pixal3dTemplateVariant,
|
|
361
364
|
Sam3ImagePrompt,
|
|
362
365
|
Sam3VideoPrompt,
|
|
366
|
+
Sam3VideoSelection,
|
|
367
|
+
Sam3VideoFramePrompt,
|
|
363
368
|
Sam3PromptBox,
|
|
369
|
+
Sam3PromptMask,
|
|
364
370
|
Sam3PromptPoint,
|
|
365
371
|
Sam3Selection,
|
|
366
372
|
JobStatus,
|
package/src/lib/getUUID.ts
CHANGED
|
@@ -1,8 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
// Two hex digits per byte, ES6-safe (no padStart in this package's lib target).
|
|
2
|
+
const HEX: string[] = [];
|
|
3
|
+
for (let byte = 0; byte < 256; byte++) HEX.push((byte + 256).toString(16).slice(1));
|
|
2
4
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
/**
|
|
6
|
+
* A random (version 4) UUID drawn from the runtime's cryptographically secure
|
|
7
|
+
* generator. `crypto.randomUUID()` exists in Node.js and in browser pages served
|
|
8
|
+
* over HTTPS or localhost; a page served over plain HTTP has only
|
|
9
|
+
* `crypto.getRandomValues()`, so the same version 4 layout is built from it.
|
|
10
|
+
* A runtime with neither cannot produce an unpredictable id and throws: there
|
|
11
|
+
* is no Math.random fallback.
|
|
12
|
+
*
|
|
13
|
+
* Uppercase, because the Mac app uses uppercase UUIDs and Mac workers must be
|
|
14
|
+
* able to process the data.
|
|
15
|
+
*/
|
|
16
|
+
function getUUID(): string {
|
|
17
|
+
const webCrypto: Partial<Crypto> | undefined = globalThis.crypto;
|
|
18
|
+
if (typeof webCrypto?.randomUUID === 'function') {
|
|
19
|
+
return webCrypto.randomUUID().toUpperCase();
|
|
20
|
+
}
|
|
21
|
+
if (typeof webCrypto?.getRandomValues === 'function') {
|
|
22
|
+
const bytes = webCrypto.getRandomValues(new Uint8Array(16));
|
|
23
|
+
bytes[6] = (bytes[6] & 0x0f) | 0x40; // version 4
|
|
24
|
+
bytes[8] = (bytes[8] & 0x3f) | 0x80; // RFC 9562 variant
|
|
25
|
+
let out = '';
|
|
26
|
+
for (let i = 0; i < 16; i++) {
|
|
27
|
+
out += HEX[bytes[i]];
|
|
28
|
+
if (i === 3 || i === 5 || i === 7 || i === 9) out += '-';
|
|
29
|
+
}
|
|
30
|
+
return out.toUpperCase();
|
|
31
|
+
}
|
|
32
|
+
throw new Error(
|
|
33
|
+
'Sogni SDK: this runtime has no Web Crypto API (globalThis.crypto), so it cannot generate secure IDs'
|
|
34
|
+
);
|
|
6
35
|
}
|
|
7
36
|
|
|
8
37
|
export default getUUID;
|
package/src/lib/validation.ts
CHANGED
|
@@ -43,12 +43,9 @@ export function validateGptImageOptions(params: ImageProjectParams): void {
|
|
|
43
43
|
throw new Error('Unsupported GPT Image complexity');
|
|
44
44
|
if (
|
|
45
45
|
advancedFormat &&
|
|
46
|
-
(params.
|
|
47
|
-
params.gptImageMask ||
|
|
48
|
-
params.gptImageMaskUrl ||
|
|
49
|
-
params.gptImageMarkupUrl)
|
|
46
|
+
(params.gptImageMask || params.gptImageMaskUrl || params.gptImageMarkupUrl)
|
|
50
47
|
)
|
|
51
|
-
throw new Error('GIF output
|
|
48
|
+
throw new Error('GIF output cannot combine with masks or markup');
|
|
52
49
|
if (
|
|
53
50
|
params.outputFormat !== 'gif' &&
|
|
54
51
|
(params.gptImageFrameCount !== undefined || params.gptImageFrameDurationMs !== undefined)
|
package/src/version.ts
CHANGED