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/cli.js
CHANGED
|
@@ -2010,7 +2010,15 @@ var CharacterPortraitSizeSchema = z.union([
|
|
|
2010
2010
|
var CharacterPortraitSchema = z.object({
|
|
2011
2011
|
/** The base or state to portray, in the same style. */
|
|
2012
2012
|
of: z.string().min(1),
|
|
2013
|
-
size: CharacterPortraitSizeSchema.default(64)
|
|
2013
|
+
size: CharacterPortraitSizeSchema.default(64),
|
|
2014
|
+
/** PixelLab's seed for this portrait, in place of the style's `seed`. Part of its identity. */
|
|
2015
|
+
seed: z.number().int().min(0).optional(),
|
|
2016
|
+
/**
|
|
2017
|
+
* Attach the drawn portrait to the parent's PixelLab character record, as
|
|
2018
|
+
* PixelLab's own app shows it (the default). `false` leaves that record as
|
|
2019
|
+
* it is, for a character used elsewhere. Not part of the portrait's identity.
|
|
2020
|
+
*/
|
|
2021
|
+
attach: z.boolean().optional()
|
|
2014
2022
|
}).strict();
|
|
2015
2023
|
var MapScenePlacementSchema = z.union([
|
|
2016
2024
|
z.object({ oval: z.number().min(0.05).max(0.95) }).strict(),
|
|
@@ -13042,7 +13050,17 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13042
13050
|
});
|
|
13043
13051
|
return {
|
|
13044
13052
|
jobId: res2.background_job_id,
|
|
13045
|
-
metadata: {
|
|
13053
|
+
metadata: {
|
|
13054
|
+
character: {
|
|
13055
|
+
kind: "portrait",
|
|
13056
|
+
parentCharacterId: parentId,
|
|
13057
|
+
backgroundJobId: res2.background_job_id,
|
|
13058
|
+
// PixelLab expires finished jobs within about a day, so the seed sent is kept here;
|
|
13059
|
+
// poll replaces it with the one the job reports using.
|
|
13060
|
+
...spec.seed != null ? { seed: spec.seed } : {},
|
|
13061
|
+
...character.portrait.attach ? {} : { attach: false }
|
|
13062
|
+
}
|
|
13063
|
+
}
|
|
13046
13064
|
};
|
|
13047
13065
|
}
|
|
13048
13066
|
const animation = character.animation;
|
|
@@ -13216,16 +13234,21 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13216
13234
|
const job = await this.client.getPortraitCharacterJob(jobId);
|
|
13217
13235
|
if (job.status === "failed") return { status: "failed", error: "portrait generation failed upstream" };
|
|
13218
13236
|
if (job.status !== "completed" || !job.download_url) return { status: "processing" };
|
|
13219
|
-
|
|
13237
|
+
const attach = meta?.parentCharacterId && meta.attach !== false ? meta.parentCharacterId : null;
|
|
13238
|
+
if (attach) {
|
|
13220
13239
|
const bytes = await this.client.download(job.download_url);
|
|
13221
|
-
await this.client.setCharacterPortrait(
|
|
13240
|
+
await this.client.setCharacterPortrait(attach, { base64: bytes.toString("base64"), format: "png" });
|
|
13222
13241
|
}
|
|
13242
|
+
const { billed, lastResponse } = await this.readFinishedJob(meta?.backgroundJobId);
|
|
13243
|
+
const seed = typeof lastResponse?.seed === "number" ? lastResponse.seed : meta?.seed;
|
|
13223
13244
|
return {
|
|
13224
13245
|
status: "ready",
|
|
13225
13246
|
objectId: jobId,
|
|
13226
13247
|
sourceUrl: job.download_url,
|
|
13227
13248
|
sources: [{ url: job.download_url }],
|
|
13228
|
-
billed
|
|
13249
|
+
billed,
|
|
13250
|
+
...seed != null ? { metadata: { character: { ...meta, seed } } } : {},
|
|
13251
|
+
...attach ? { note: `attached to character ${attach} on PixelLab` } : {}
|
|
13229
13252
|
};
|
|
13230
13253
|
} catch (err) {
|
|
13231
13254
|
if (err instanceof PixelLabError && err.status === 423) return { status: "processing" };
|
|
@@ -13953,17 +13976,22 @@ var PixelLabProvider = class _PixelLabProvider {
|
|
|
13953
13976
|
* known", not a failure worth surfacing.
|
|
13954
13977
|
*/
|
|
13955
13978
|
async billedForJob(backgroundJobId) {
|
|
13956
|
-
|
|
13979
|
+
return (await this.readFinishedJob(backgroundJobId)).billed;
|
|
13980
|
+
}
|
|
13981
|
+
/** A finished background job's bill (see `billedForJob`) and its `last_response`, read once. */
|
|
13982
|
+
async readFinishedJob(backgroundJobId) {
|
|
13983
|
+
if (!backgroundJobId) return { billed: null, lastResponse: null };
|
|
13957
13984
|
try {
|
|
13958
13985
|
const job = await this.client.getBackgroundJob(backgroundJobId);
|
|
13986
|
+
const lastResponse = job.last_response ?? null;
|
|
13959
13987
|
const nested = job.last_response?.billing_usage;
|
|
13960
13988
|
for (const usage2 of [job.usage, nested]) {
|
|
13961
13989
|
const billed = billedFromUsage(usage2);
|
|
13962
|
-
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return billed;
|
|
13990
|
+
if (billed && !(billed.unit === "usd" && billed.amount === 0)) return { billed, lastResponse };
|
|
13963
13991
|
}
|
|
13964
|
-
return null;
|
|
13992
|
+
return { billed: null, lastResponse };
|
|
13965
13993
|
} catch {
|
|
13966
|
-
return null;
|
|
13994
|
+
return { billed: null, lastResponse: null };
|
|
13967
13995
|
}
|
|
13968
13996
|
}
|
|
13969
13997
|
async poll(jobId, generator, context) {
|
|
@@ -16693,7 +16721,8 @@ async function resolveSpecs(loaded, filter) {
|
|
|
16693
16721
|
outline: style.outline,
|
|
16694
16722
|
shading: style.shading,
|
|
16695
16723
|
detail: style.detail,
|
|
16696
|
-
|
|
16724
|
+
// A portrait may pin its own; it reaches the wire and the identity like the style's.
|
|
16725
|
+
seed: asset.portrait?.seed ?? style.seed,
|
|
16697
16726
|
uiPieces: generator === "uiAsset" ? asset.pieces : void 0,
|
|
16698
16727
|
uiElements: generator === "uiAsset" ? asset.elements : void 0,
|
|
16699
16728
|
uiColorPalette: generator === "uiAsset" || generator === "uiElement" ? style.uiColorPalette : void 0,
|
|
@@ -17587,7 +17616,7 @@ async function resolveCharacterShape(asset, style, kind, files) {
|
|
|
17587
17616
|
};
|
|
17588
17617
|
}
|
|
17589
17618
|
if (asset.portrait) {
|
|
17590
|
-
shape.portrait = { size: asset.portrait.size };
|
|
17619
|
+
shape.portrait = { size: asset.portrait.size, attach: asset.portrait.attach ?? true };
|
|
17591
17620
|
}
|
|
17592
17621
|
if (asset.animation) {
|
|
17593
17622
|
const animationMode = asset.animation.mode ?? (asset.animation.template ? "template" : "v3");
|
|
@@ -25628,7 +25657,7 @@ async function poll(provider, lock, lockPath, opts = {}) {
|
|
|
25628
25657
|
billed: state.billed ?? entry.billed
|
|
25629
25658
|
});
|
|
25630
25659
|
result.completed++;
|
|
25631
|
-
log2(` ready ${key3}`);
|
|
25660
|
+
log2(` ready ${key3}${state.note ? ` (${state.note})` : ""}`);
|
|
25632
25661
|
} else if (state.status === "failed") {
|
|
25633
25662
|
upsert(lock, key3, { status: "failed", error: state.error });
|
|
25634
25663
|
result.failed++;
|