pixelkiln 0.122.1 → 0.124.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/cli.js +218 -21
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +150 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +396 -193
- package/dist/index.d.ts +396 -193
- package/dist/index.js +150 -13
- package/dist/index.js.map +1 -1
- package/docs/CHARACTERS_3D.md +274 -0
- package/docs/CLI.md +20 -3
- package/docs/COMFYUI.md +55 -1
- package/docs/MANIFEST.md +3 -2
- package/docs/README.md +1 -0
- package/docs/RESEARCH_3D.md +1010 -4
- package/docs/REVISIONS.md +29 -0
- package/docs/SKELETONS.md +55 -5
- package/package.json +1 -1
- package/schema/manifest.schema.json +5 -0
- package/skills/pixelkiln/references/pixellab.md +10 -0
package/dist/index.cjs
CHANGED
|
@@ -1165,6 +1165,13 @@ var RevisionSchema = import_zod.z.object({
|
|
|
1165
1165
|
* committed files rather than inline pixel data.
|
|
1166
1166
|
*/
|
|
1167
1167
|
keypointsFile: import_zod.z.string().min(1).optional(),
|
|
1168
|
+
/**
|
|
1169
|
+
* `animate-skeleton` only: have PixelLab write this many frames (3-15) of
|
|
1170
|
+
* motion from the asset's prompt, starting from the keypoints file's
|
|
1171
|
+
* `firstFrameKeypoints`, instead of posing every frame in the file. Works
|
|
1172
|
+
* with the 18 joints or a custom rig; the file's `frames` may then be empty.
|
|
1173
|
+
*/
|
|
1174
|
+
writeMotionFrames: import_zod.z.number().int().min(3).max(15).optional(),
|
|
1168
1175
|
/**
|
|
1169
1176
|
* `animate-skeleton` only: the body a joint's missing `depth` is taken
|
|
1170
1177
|
* from. PixelLab's default is `mannequin`; free string like `character`'s
|
|
@@ -1370,7 +1377,7 @@ var RevisionSchema = import_zod.z.object({
|
|
|
1370
1377
|
path: ["description"]
|
|
1371
1378
|
});
|
|
1372
1379
|
}
|
|
1373
|
-
for (const field of ["keypointsFile", "skeletonTemplate"]) {
|
|
1380
|
+
for (const field of ["keypointsFile", "skeletonTemplate", "writeMotionFrames"]) {
|
|
1374
1381
|
if (revision[field] !== void 0 && revision.mode !== "animate-skeleton") {
|
|
1375
1382
|
context.addIssue({
|
|
1376
1383
|
code: import_zod.z.ZodIssueCode.custom,
|
|
@@ -2378,9 +2385,9 @@ var LockEntrySchema = import_zod.z.object({
|
|
|
2378
2385
|
paletteImageSha256: import_zod.z.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
2379
2386
|
dithering: RevisionDitheringSchema.optional(),
|
|
2380
2387
|
ditheringStrength: import_zod.z.number().min(0).max(10).optional(),
|
|
2381
|
-
// 4-40 for animate/animate-pixminimax; animate-skeleton
|
|
2382
|
-
//
|
|
2383
|
-
frames: import_zod.z.number().int().min(
|
|
2388
|
+
// 4-40 for animate/animate-pixminimax; animate-skeleton takes 3-15, and
|
|
2389
|
+
// 1-15 with a custom rig, hence min(1) here.
|
|
2390
|
+
frames: import_zod.z.number().int().min(1).max(40).optional(),
|
|
2384
2391
|
fps: import_zod.z.number().int().min(1).max(60).optional(),
|
|
2385
2392
|
lastFrameSha256: import_zod.z.string().regex(/^[0-9a-f]{64}$/).optional(),
|
|
2386
2393
|
direction: CharacterDirectionSchema.optional(),
|
|
@@ -2727,10 +2734,79 @@ var SkeletonFrameSchema = import_zod2.z.array(SkeletonKeypointSchema).length(18)
|
|
|
2727
2734
|
seen.add(joint.label);
|
|
2728
2735
|
}
|
|
2729
2736
|
});
|
|
2730
|
-
var
|
|
2731
|
-
|
|
2732
|
-
|
|
2737
|
+
var RIG_SIDES = ["near", "mid", "far"];
|
|
2738
|
+
var RigJointSchema = import_zod2.z.object({
|
|
2739
|
+
name: import_zod2.z.string().min(1),
|
|
2740
|
+
parent: import_zod2.z.string().min(1).nullable(),
|
|
2741
|
+
side: import_zod2.z.enum(RIG_SIDES),
|
|
2742
|
+
estimate: import_zod2.z.enum(SKELETON_LABELS).nullable().optional()
|
|
2733
2743
|
}).strict();
|
|
2744
|
+
var SkeletonRigSchema = import_zod2.z.array(RigJointSchema).min(2).max(64).superRefine((rig, context) => {
|
|
2745
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2746
|
+
let roots = 0;
|
|
2747
|
+
for (const [index, joint] of rig.entries()) {
|
|
2748
|
+
if (seen.has(joint.name)) {
|
|
2749
|
+
context.addIssue({ code: import_zod2.z.ZodIssueCode.custom, message: `joint "${joint.name}" appears twice`, path: [index, "name"] });
|
|
2750
|
+
}
|
|
2751
|
+
if (joint.parent === null) roots++;
|
|
2752
|
+
else if (!seen.has(joint.parent)) {
|
|
2753
|
+
context.addIssue({
|
|
2754
|
+
code: import_zod2.z.ZodIssueCode.custom,
|
|
2755
|
+
message: `"${joint.name}" hangs from "${joint.parent}", which is not listed before it`,
|
|
2756
|
+
path: [index, "parent"]
|
|
2757
|
+
});
|
|
2758
|
+
}
|
|
2759
|
+
seen.add(joint.name);
|
|
2760
|
+
}
|
|
2761
|
+
if (roots !== 1) context.addIssue({ code: import_zod2.z.ZodIssueCode.custom, message: `a rig has exactly one root joint; this one has ${roots}` });
|
|
2762
|
+
});
|
|
2763
|
+
var RigKeypointSchema = import_zod2.z.object({
|
|
2764
|
+
label: import_zod2.z.string().min(1),
|
|
2765
|
+
x: import_zod2.z.number().min(0).max(1),
|
|
2766
|
+
y: import_zod2.z.number().min(0).max(1),
|
|
2767
|
+
z_index: import_zod2.z.number(),
|
|
2768
|
+
depth: import_zod2.z.number().optional()
|
|
2769
|
+
}).strict();
|
|
2770
|
+
var SkeletonSetSchema = import_zod2.z.object({
|
|
2771
|
+
rig: SkeletonRigSchema.optional(),
|
|
2772
|
+
kind: import_zod2.z.enum(["person", "four-legged", "other"]).nullable().optional(),
|
|
2773
|
+
firstFrameKeypoints: import_zod2.z.array(RigKeypointSchema),
|
|
2774
|
+
frames: import_zod2.z.array(import_zod2.z.array(RigKeypointSchema)).max(15).default([])
|
|
2775
|
+
}).strict().superRefine((set, context) => {
|
|
2776
|
+
const poses = [
|
|
2777
|
+
[set.firstFrameKeypoints, ["firstFrameKeypoints"]],
|
|
2778
|
+
...set.frames.map((frame, index) => [frame, ["frames", index]])
|
|
2779
|
+
];
|
|
2780
|
+
if (!set.rig && set.frames.length > 0 && set.frames.length < 3) {
|
|
2781
|
+
context.addIssue({ code: import_zod2.z.ZodIssueCode.custom, message: "18-joint poses need 3 to 15 frames (a custom rig takes 1)", path: ["frames"] });
|
|
2782
|
+
}
|
|
2783
|
+
for (const [pose, where] of poses) {
|
|
2784
|
+
if (set.rig) {
|
|
2785
|
+
const names = set.rig.map((joint) => joint.name);
|
|
2786
|
+
const labels = pose.map((joint) => joint.label);
|
|
2787
|
+
const missing = names.filter((name) => !labels.includes(name));
|
|
2788
|
+
const extra = labels.filter((label) => !names.includes(label));
|
|
2789
|
+
const twice = labels.filter((label, index) => labels.indexOf(label) !== index);
|
|
2790
|
+
if (missing.length || extra.length || twice.length) {
|
|
2791
|
+
context.addIssue({
|
|
2792
|
+
code: import_zod2.z.ZodIssueCode.custom,
|
|
2793
|
+
message: [
|
|
2794
|
+
missing.length ? `missing ${missing.slice(0, 3).join(", ")}` : "",
|
|
2795
|
+
extra.length ? `not in the rig: ${extra.slice(0, 3).join(", ")}` : "",
|
|
2796
|
+
twice.length ? `twice: ${twice.slice(0, 3).join(", ")}` : ""
|
|
2797
|
+
].filter(Boolean).join("; "),
|
|
2798
|
+
path: where
|
|
2799
|
+
});
|
|
2800
|
+
}
|
|
2801
|
+
} else {
|
|
2802
|
+
const result = SkeletonFrameSchema.safeParse(pose);
|
|
2803
|
+
if (!result.success) {
|
|
2804
|
+
const issue = result.error.issues[0];
|
|
2805
|
+
context.addIssue({ code: import_zod2.z.ZodIssueCode.custom, message: issue.message, path: [...where, ...issue.path] });
|
|
2806
|
+
}
|
|
2807
|
+
}
|
|
2808
|
+
}
|
|
2809
|
+
});
|
|
2734
2810
|
function parseSkeletonSet(json, file) {
|
|
2735
2811
|
const result = SkeletonSetSchema.safeParse(json);
|
|
2736
2812
|
if (!result.success) {
|
|
@@ -3077,6 +3153,11 @@ var EstimateSkeletonResponseSchema = import_zod3.z.object({
|
|
|
3077
3153
|
keypoints: import_zod3.z.array(SkeletonKeypointSchema).length(18),
|
|
3078
3154
|
usage: import_zod3.z.unknown().optional()
|
|
3079
3155
|
}).passthrough();
|
|
3156
|
+
var CustomSkeletonResultSchema = import_zod3.z.object({
|
|
3157
|
+
rig: SkeletonRigSchema,
|
|
3158
|
+
kind: import_zod3.z.enum(["person", "four-legged", "other"]).nullable().optional(),
|
|
3159
|
+
frames: import_zod3.z.array(import_zod3.z.array(RigKeypointSchema.extend({ z_index: import_zod3.z.number().default(0) }))).min(1)
|
|
3160
|
+
}).passthrough();
|
|
3080
3161
|
var CharacterSubmitSchema = import_zod3.z.object({
|
|
3081
3162
|
background_job_id: import_zod3.z.string().min(1),
|
|
3082
3163
|
character_id: import_zod3.z.string().min(1),
|
|
@@ -4854,9 +4935,11 @@ var PixelLabClient = class {
|
|
|
4854
4935
|
const body = {
|
|
4855
4936
|
first_frame: args.firstFrame,
|
|
4856
4937
|
first_frame_keypoints: args.firstFrameKeypoints,
|
|
4857
|
-
keypoints: args.keypoints,
|
|
4858
4938
|
direction: args.direction
|
|
4859
4939
|
};
|
|
4940
|
+
if (args.writeMotionFrames != null) body.write_motion_frames = args.writeMotionFrames;
|
|
4941
|
+
else body.keypoints = args.keypoints;
|
|
4942
|
+
if (args.rig) body.rig = args.rig;
|
|
4860
4943
|
if (args.view) body.view = args.view;
|
|
4861
4944
|
if (args.templateId) body.template_id = args.templateId;
|
|
4862
4945
|
if (args.action) body.action = args.action;
|
|
@@ -4890,6 +4973,48 @@ var PixelLabClient = class {
|
|
|
4890
4973
|
);
|
|
4891
4974
|
return { keypoints: res.keypoints, usage: res.usage };
|
|
4892
4975
|
}
|
|
4976
|
+
/**
|
|
4977
|
+
* `/estimate-custom-skeleton` (beta): builds a rig of any shape for a sprite
|
|
4978
|
+
* (a staff, a cape, wings, a tail) from `description` and `action`, and places
|
|
4979
|
+
* it on the image. A background job; this submits it and waits for the
|
|
4980
|
+
* result, polling every `intervalMs` (most finish in about a minute). 1
|
|
4981
|
+
* generation per 8 images. Measured on four sprites in November 2026: given a
|
|
4982
|
+
* figure "swinging the staff", it hung a three-joint staff from the wrist.
|
|
4983
|
+
*/
|
|
4984
|
+
async estimateCustomSkeleton(args, wait = {}) {
|
|
4985
|
+
const body = {
|
|
4986
|
+
images: [{ type: "base64", base64: args.image.base64, format: args.image.format }],
|
|
4987
|
+
direction: args.direction
|
|
4988
|
+
};
|
|
4989
|
+
if (args.view) body.view = args.view;
|
|
4990
|
+
if (args.description) body.description = args.description;
|
|
4991
|
+
if (args.action) body.action = args.action;
|
|
4992
|
+
const submitted = validateResponse(
|
|
4993
|
+
RevisionJobSubmitSchema,
|
|
4994
|
+
await this.request("/estimate-custom-skeleton", { method: "POST", body: JSON.stringify(body) }),
|
|
4995
|
+
"estimate-custom-skeleton"
|
|
4996
|
+
);
|
|
4997
|
+
const sleep3 = wait.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
|
|
4998
|
+
const deadline = Date.now() + (wait.timeoutMs ?? 5 * 6e4);
|
|
4999
|
+
for (; ; ) {
|
|
5000
|
+
const job = await this.getBackgroundJob(submitted.background_job_id);
|
|
5001
|
+
if (job.status === "completed") {
|
|
5002
|
+
const result = validateResponse(CustomSkeletonResultSchema, job.last_response, "estimate-custom-skeleton result");
|
|
5003
|
+
return {
|
|
5004
|
+
rig: result.rig,
|
|
5005
|
+
kind: result.kind ?? null,
|
|
5006
|
+
keypoints: result.frames[0],
|
|
5007
|
+
jobId: submitted.background_job_id,
|
|
5008
|
+
usage: job.usage ?? null
|
|
5009
|
+
};
|
|
5010
|
+
}
|
|
5011
|
+
if (job.status === "failed") throw new ProviderError("pixellab", `estimate-custom-skeleton job ${submitted.background_job_id} failed`);
|
|
5012
|
+
if (Date.now() > deadline) {
|
|
5013
|
+
throw new ProviderError("pixellab", `estimate-custom-skeleton job ${submitted.background_job_id} is still running; it was not charged until it finishes`);
|
|
5014
|
+
}
|
|
5015
|
+
await sleep3(wait.intervalMs ?? 5e3);
|
|
5016
|
+
}
|
|
5017
|
+
}
|
|
4893
5018
|
async getBackgroundJob(jobId) {
|
|
4894
5019
|
const raw = await this.request(`/background-jobs/${encodeURIComponent(jobId)}`);
|
|
4895
5020
|
return validateResponse(BackgroundJobSchema, raw, "background-jobs/{id}");
|
|
@@ -5802,6 +5927,8 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
|
|
|
5802
5927
|
enhancePrompt: spec.revision.enhancePrompt,
|
|
5803
5928
|
keypointsSha256: spec.revision.keypointsSha256,
|
|
5804
5929
|
skeletonTemplate: spec.revision.skeletonTemplate,
|
|
5930
|
+
// Only when set, so revisions made before it keep their hash.
|
|
5931
|
+
writeMotionFrames: spec.revision.writeMotionFrames,
|
|
5805
5932
|
description: spec.revision.description,
|
|
5806
5933
|
removalTask: spec.revision.removalTask,
|
|
5807
5934
|
convention: spec.revision.convention,
|
|
@@ -8562,8 +8689,12 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
8562
8689
|
if (width != null && height != null && (width > 256 || height > 256)) {
|
|
8563
8690
|
throw new Error(`PixelLab animate-skeleton source is ${width}x${height}; the API takes at most 256 pixels per side`);
|
|
8564
8691
|
}
|
|
8565
|
-
|
|
8566
|
-
|
|
8692
|
+
const rig = spec.revision.skeleton?.rig;
|
|
8693
|
+
const fewest = rig && spec.revision.writeMotionFrames == null ? 1 : 3;
|
|
8694
|
+
if (frames != null && (frames < fewest || frames > 15)) {
|
|
8695
|
+
throw new Error(
|
|
8696
|
+
spec.revision.skeleton && frames === 0 && spec.revision.writeMotionFrames == null ? `${spec.styleId}/${spec.assetId}: the keypoints file has no frames; add the motion's poses, or set revision.writeMotionFrames to have PixelLab write them` : `PixelLab animate-skeleton takes ${fewest} to 15 frames; the keypoints file has ${frames}`
|
|
8697
|
+
);
|
|
8567
8698
|
}
|
|
8568
8699
|
if (skeletonTemplate && !CHARACTER_TEMPLATES.includes(skeletonTemplate)) {
|
|
8569
8700
|
throw new Error(`PixelLab animate-skeleton template "${skeletonTemplate}" is not one of ${CHARACTER_TEMPLATES.join(", ")}`);
|
|
@@ -10203,15 +10334,19 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10203
10334
|
if (sha256(keypointsBytes) !== revision.keypointsSha256) {
|
|
10204
10335
|
throw new Error(`${spec.styleId}/${spec.assetId}: revision keypoints changed after the manifest was resolved`);
|
|
10205
10336
|
}
|
|
10337
|
+
const rig = revision.skeleton.rig;
|
|
10338
|
+
const templateId = revision.skeletonTemplate ?? (rig ? revision.skeleton.kind === "four-legged" ? "dog" : "mannequin" : void 0);
|
|
10206
10339
|
const res2 = await this.client.animateWithSkeletonV3({
|
|
10207
10340
|
firstFrame: image,
|
|
10208
10341
|
firstFrameKeypoints: revision.skeleton.firstFrameKeypoints,
|
|
10209
10342
|
keypoints: revision.skeleton.frames,
|
|
10343
|
+
...rig ? { rig } : {},
|
|
10344
|
+
...revision.writeMotionFrames != null ? { writeMotionFrames: revision.writeMotionFrames } : {},
|
|
10210
10345
|
direction: revision.direction,
|
|
10211
10346
|
// The style's camera, when it is one this endpoint knows; its enum is
|
|
10212
10347
|
// narrower than a style's free-string `view`.
|
|
10213
10348
|
...spec.view === "side" || spec.view === "low top-down" || spec.view === "high top-down" ? { view: spec.view } : {},
|
|
10214
|
-
templateId
|
|
10349
|
+
templateId,
|
|
10215
10350
|
action: spec.prompt,
|
|
10216
10351
|
description: revision.description,
|
|
10217
10352
|
seed: spec.seed,
|
|
@@ -14867,10 +15002,12 @@ async function resolveSpecs(loaded, filter) {
|
|
|
14867
15002
|
// The manifest's own `frames` field stays rejected for this
|
|
14868
15003
|
// mode (superRefine, types.ts) — the real frame count comes
|
|
14869
15004
|
// from the keypoints file once it exists, not a manifest
|
|
14870
|
-
// number, so plan can only know it once authored.
|
|
14871
|
-
|
|
15005
|
+
// number, so plan can only know it once authored. Written
|
|
15006
|
+
// motion has its count in the manifest instead.
|
|
15007
|
+
...asset.revision.writeMotionFrames != null ? { frames: asset.revision.writeMotionFrames } : keypoints ? { frames: keypoints.skeleton.frames.length } : {}
|
|
14872
15008
|
} : {},
|
|
14873
15009
|
...asset.revision.skeletonTemplate ? { skeletonTemplate: asset.revision.skeletonTemplate } : {},
|
|
15010
|
+
...asset.revision.writeMotionFrames != null ? { writeMotionFrames: asset.revision.writeMotionFrames } : {},
|
|
14874
15011
|
...asset.revision.description ? { description: asset.revision.description } : {},
|
|
14875
15012
|
...asset.revision.removalTask ? { removalTask: asset.revision.removalTask } : {},
|
|
14876
15013
|
...asset.revision.convention ? { convention: asset.revision.convention } : {},
|