pixelkiln 0.120.0 → 0.121.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 +41 -12
- package/dist/cli.js.map +1 -1
- package/dist/index.cjs +41 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +392 -258
- package/dist/index.d.ts +392 -258
- package/dist/index.js +41 -12
- package/dist/index.js.map +1 -1
- package/docs/CHARACTERS.md +36 -7
- package/docs/ENDPOINTS.md +1 -1
- package/docs/MANIFEST.md +1 -1
- package/package.json +1 -1
- package/schema/manifest.schema.json +7 -0
- package/skills/pixelkiln/references/pixellab.md +10 -0
package/dist/index.cjs
CHANGED
|
@@ -757,7 +757,15 @@ var CharacterPortraitSizeSchema = import_zod.z.union([
|
|
|
757
757
|
var CharacterPortraitSchema = import_zod.z.object({
|
|
758
758
|
/** The base or state to portray, in the same style. */
|
|
759
759
|
of: import_zod.z.string().min(1),
|
|
760
|
-
size: CharacterPortraitSizeSchema.default(64)
|
|
760
|
+
size: CharacterPortraitSizeSchema.default(64),
|
|
761
|
+
/** PixelLab's seed for this portrait, in place of the style's `seed`. Part of its identity. */
|
|
762
|
+
seed: import_zod.z.number().int().min(0).optional(),
|
|
763
|
+
/**
|
|
764
|
+
* Attach the drawn portrait to the parent's PixelLab character record, as
|
|
765
|
+
* PixelLab's own app shows it (the default). `false` leaves that record as
|
|
766
|
+
* it is, for a character used elsewhere. Not part of the portrait's identity.
|
|
767
|
+
*/
|
|
768
|
+
attach: import_zod.z.boolean().optional()
|
|
761
769
|
}).strict();
|
|
762
770
|
var MapScenePlacementSchema = import_zod.z.union([
|
|
763
771
|
import_zod.z.object({ oval: import_zod.z.number().min(0.05).max(0.95) }).strict(),
|
|
@@ -9335,7 +9343,17 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
9335
9343
|
});
|
|
9336
9344
|
return {
|
|
9337
9345
|
jobId: res2.background_job_id,
|
|
9338
|
-
metadata: {
|
|
9346
|
+
metadata: {
|
|
9347
|
+
character: {
|
|
9348
|
+
kind: "portrait",
|
|
9349
|
+
parentCharacterId: parentId,
|
|
9350
|
+
backgroundJobId: res2.background_job_id,
|
|
9351
|
+
// PixelLab expires finished jobs within about a day, so the seed sent is kept here;
|
|
9352
|
+
// poll replaces it with the one the job reports using.
|
|
9353
|
+
...spec.seed != null ? { seed: spec.seed } : {},
|
|
9354
|
+
...character.portrait.attach ? {} : { attach: false }
|
|
9355
|
+
}
|
|
9356
|
+
}
|
|
9339
9357
|
};
|
|
9340
9358
|
}
|
|
9341
9359
|
const animation = character.animation;
|
|
@@ -9509,16 +9527,21 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
9509
9527
|
const job = await this.client.getPortraitCharacterJob(jobId);
|
|
9510
9528
|
if (job.status === "failed") return { status: "failed", error: "portrait generation failed upstream" };
|
|
9511
9529
|
if (job.status !== "completed" || !job.download_url) return { status: "processing" };
|
|
9512
|
-
|
|
9530
|
+
const attach = meta?.parentCharacterId && meta.attach !== false ? meta.parentCharacterId : null;
|
|
9531
|
+
if (attach) {
|
|
9513
9532
|
const bytes = await this.client.download(job.download_url);
|
|
9514
|
-
await this.client.setCharacterPortrait(
|
|
9533
|
+
await this.client.setCharacterPortrait(attach, { base64: bytes.toString("base64"), format: "png" });
|
|
9515
9534
|
}
|
|
9535
|
+
const { billed, lastResponse } = await this.readFinishedJob(meta?.backgroundJobId);
|
|
9536
|
+
const seed = typeof lastResponse?.seed === "number" ? lastResponse.seed : meta?.seed;
|
|
9516
9537
|
return {
|
|
9517
9538
|
status: "ready",
|
|
9518
9539
|
objectId: jobId,
|
|
9519
9540
|
sourceUrl: job.download_url,
|
|
9520
9541
|
sources: [{ url: job.download_url }],
|
|
9521
|
-
billed
|
|
9542
|
+
billed,
|
|
9543
|
+
...seed != null ? { metadata: { character: { ...meta, seed } } } : {},
|
|
9544
|
+
...attach ? { note: `attached to character ${attach} on PixelLab` } : {}
|
|
9522
9545
|
};
|
|
9523
9546
|
} catch (err) {
|
|
9524
9547
|
if (err instanceof PixelLabError && err.status === 423) return { status: "processing" };
|
|
@@ -10246,17 +10269,22 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
10246
10269
|
* known", not a failure worth surfacing.
|
|
10247
10270
|
*/
|
|
10248
10271
|
async billedForJob(backgroundJobId) {
|
|
10249
|
-
|
|
10272
|
+
return (await this.readFinishedJob(backgroundJobId)).billed;
|
|
10273
|
+
}
|
|
10274
|
+
/** A finished background job's bill (see `billedForJob`) and its `last_response`, read once. */
|
|
10275
|
+
async readFinishedJob(backgroundJobId) {
|
|
10276
|
+
if (!backgroundJobId) return { billed: null, lastResponse: null };
|
|
10250
10277
|
try {
|
|
10251
10278
|
const job = await this.client.getBackgroundJob(backgroundJobId);
|
|
10279
|
+
const lastResponse = job.last_response ?? null;
|
|
10252
10280
|
const nested = job.last_response?.billing_usage;
|
|
10253
10281
|
for (const usage of [job.usage, nested]) {
|
|
10254
10282
|
const billed = billedFromUsage(usage);
|
|
10255
|
-
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return billed;
|
|
10283
|
+
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return { billed, lastResponse };
|
|
10256
10284
|
}
|
|
10257
|
-
return null;
|
|
10285
|
+
return { billed: null, lastResponse };
|
|
10258
10286
|
} catch {
|
|
10259
|
-
return null;
|
|
10287
|
+
return { billed: null, lastResponse: null };
|
|
10260
10288
|
}
|
|
10261
10289
|
}
|
|
10262
10290
|
async poll(jobId, generator, context) {
|
|
@@ -14315,7 +14343,8 @@ async function resolveSpecs(loaded, filter) {
|
|
|
14315
14343
|
outline: style.outline,
|
|
14316
14344
|
shading: style.shading,
|
|
14317
14345
|
detail: style.detail,
|
|
14318
|
-
|
|
14346
|
+
// A portrait may pin its own; it reaches the wire and the identity like the style's.
|
|
14347
|
+
seed: asset.portrait?.seed ?? style.seed,
|
|
14319
14348
|
uiPieces: generator === "uiAsset" ? asset.pieces : void 0,
|
|
14320
14349
|
uiElements: generator === "uiAsset" ? asset.elements : void 0,
|
|
14321
14350
|
uiColorPalette: generator === "uiAsset" || generator === "uiElement" ? style.uiColorPalette : void 0,
|
|
@@ -15212,7 +15241,7 @@ async function resolveCharacterShape(asset, style, kind, files) {
|
|
|
15212
15241
|
};
|
|
15213
15242
|
}
|
|
15214
15243
|
if (asset.portrait) {
|
|
15215
|
-
shape.portrait = { size: asset.portrait.size };
|
|
15244
|
+
shape.portrait = { size: asset.portrait.size, attach: asset.portrait.attach ?? true };
|
|
15216
15245
|
}
|
|
15217
15246
|
if (asset.animation) {
|
|
15218
15247
|
const animationMode = asset.animation.mode ?? (asset.animation.template ? "template" : "v3");
|
|
@@ -22167,7 +22196,7 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
22167
22196
|
billed: state.billed ?? entry.billed
|
|
22168
22197
|
});
|
|
22169
22198
|
result.completed++;
|
|
22170
|
-
log(` ready ${key3}`);
|
|
22199
|
+
log(` ready ${key3}${state.note ? ` (${state.note})` : ""}`);
|
|
22171
22200
|
} else if (state.status === "failed") {
|
|
22172
22201
|
upsert(lock, key3, { status: "failed", error: state.error });
|
|
22173
22202
|
result.failed++;
|