pixelkiln 0.100.0 → 0.102.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 CHANGED
@@ -67,8 +67,8 @@ function exitCodeFor(err) {
67
67
  }
68
68
 
69
69
  // src/cli/main.ts
70
- import { existsSync as existsSync47 } from "fs";
71
- import { readFile as readFile40 } from "fs/promises";
70
+ import { existsSync as existsSync49 } from "fs";
71
+ import { readFile as readFile43 } from "fs/promises";
72
72
 
73
73
  // src/cli/args.ts
74
74
  import path from "path";
@@ -124,8 +124,21 @@ var VALUE_FLAGS = [
124
124
  "--part",
125
125
  "--sprite",
126
126
  "--fps",
127
+ "--sprite-frames",
128
+ "--sprite-fps",
127
129
  "--artist",
128
130
  "--convention",
131
+ "--text",
132
+ "--mood",
133
+ "--visemes",
134
+ "--engine",
135
+ "--frame-ms",
136
+ "--hold-ms",
137
+ "--target",
138
+ "--tile-type",
139
+ "--lower",
140
+ "--upper",
141
+ "--transition",
129
142
  "--id",
130
143
  "--state",
131
144
  "--element",
@@ -220,6 +233,7 @@ var COMMANDS = [
220
233
  "sfx",
221
234
  "ui",
222
235
  "asset",
236
+ "talk",
223
237
  "help",
224
238
  "--help",
225
239
  "-h",
@@ -235,7 +249,8 @@ var TOOLS_SUBCOMMANDS = ["status", "install"];
235
249
  var TOOLS = ["editor"];
236
250
  var VFX_SUBCOMMANDS = ["make", "presets", "parts"];
237
251
  var MUSIC_SUBCOMMANDS = ["make", "style", "lyrics"];
238
- var ASSET_SUBCOMMANDS = ["canvas", "mirror", "import", "expand", "review", "export"];
252
+ var TALK_SUBCOMMANDS = ["visemes", "gif", "plan"];
253
+ var ASSET_SUBCOMMANDS = ["canvas", "mirror", "import", "save", "expand", "review", "export"];
239
254
  var UI_SUBCOMMANDS = ["show", "split", "states", "nine-slice", "pull"];
240
255
  function parseArgs(argv) {
241
256
  const [command = "help"] = argv;
@@ -332,6 +347,15 @@ function parseArgs(argv) {
332
347
  throw new UsageError(`Unknown vfx subcommand "${subcommand}". Known: ${VFX_SUBCOMMANDS.join(", ")}`);
333
348
  }
334
349
  if (rest[0] === subcommand) rest = rest.slice(1);
350
+ } else if (command === "talk") {
351
+ subcommand = rest[0];
352
+ if (subcommand === void 0 || subcommand.startsWith("-")) {
353
+ throw new UsageError(`talk needs a subcommand: ${TALK_SUBCOMMANDS.join(", ")}`);
354
+ }
355
+ if (!TALK_SUBCOMMANDS.includes(subcommand)) {
356
+ throw new UsageError(`Unknown talk subcommand "${subcommand}". Known: ${TALK_SUBCOMMANDS.join(", ")}`);
357
+ }
358
+ rest = rest.slice(1);
335
359
  } else if (command === "asset") {
336
360
  subcommand = rest[0];
337
361
  if (subcommand === void 0 || subcommand.startsWith("-")) {
@@ -543,6 +567,8 @@ function parseArgs(argv) {
543
567
  parts: list("--part"),
544
568
  sprite: get("--sprite"),
545
569
  fps: numberOption("--fps", { min: 1, max: 60, integer: true }),
570
+ spriteFrames: numberOption("--sprite-frames", { min: 1, max: 32, integer: true }),
571
+ spriteFps: numberOption("--sprite-fps", { min: 1, max: 60, integer: true }),
546
572
  gamePack: rest.includes("--game-pack"),
547
573
  mode: get("--mode"),
548
574
  strength: numberOption("--strength", { min: 0, max: 2 }),
@@ -552,6 +578,17 @@ function parseArgs(argv) {
552
578
  detailSoftness: numberOption("--detail-softness", { min: 0.6, max: 3 }),
553
579
  kind: get("--kind"),
554
580
  size: get("--size"),
581
+ saveTarget: get("--target"),
582
+ text: get("--text"),
583
+ mood: get("--mood"),
584
+ visemes: numberOption("--visemes", { min: 3, max: 12, integer: true }),
585
+ engine: get("--engine"),
586
+ frameMs: numberOption("--frame-ms", { min: 1, max: 5e3, integer: true }),
587
+ holdMs: numberOption("--hold-ms", { min: 0, max: 1e4, integer: true }),
588
+ tileType: get("--tile-type"),
589
+ lower: get("--lower"),
590
+ upper: get("--upper"),
591
+ transition: get("--transition"),
555
592
  animation: get("--animation"),
556
593
  direction: get("--direction"),
557
594
  keep: rest.includes("--keep"),
@@ -672,11 +709,19 @@ Commands
672
709
  first); ui nine-slice sets stretch insets (free); ui pull downloads
673
710
  every image with a ui.json record.
674
711
  asset PixelLab: upkeep for an object or character by --id. asset import
675
- stores your own PNG as an object; asset expand draws a 1-direction
712
+ stores your own PNG as an object (--kind tileset: a Wang sheet as
713
+ a tileset; --kind tiles: tile PNGs as a tile group); asset save
714
+ writes edited pixels back over a stored asset (--target) and
715
+ keeps what it replaced; asset expand draws a 1-direction
676
716
  object's other 7 (10-25 generations; asks first), asset review
677
717
  downloads them, then --keep or --discard; asset canvas resizes
678
718
  the canvas; asset mirror flips a loop's direction; asset export
679
719
  writes a zip, spritesheet, .aseprite or gif. All but expand free.
720
+ talk PixelLab: a talking portrait. talk visemes draws a portrait's mouth
721
+ positions once (--from <png> or --id <character>; 3-24
722
+ generations; asks first) and writes a strip and a .talk.json
723
+ record; talk gif lip-syncs --text to a GIF and talk plan prints
724
+ the frame plan for a game engine, both free.
680
725
  sfx PixelLab: a sound effect (--description, --seconds, --out); writes
681
726
  a WAV and a .sfx.json record. From 1 generation, by length.
682
727
 
@@ -708,15 +753,30 @@ Options
708
753
  --artist <a> vfx --description: lite (default) or pro
709
754
  --weight <w> font: Bold or Regular (default)
710
755
  --id <id> ui/asset: the PixelLab asset to work on
711
- --kind <kind> asset: object (default) or character; normal-map: what the
756
+ --kind <kind> asset: object (default) or character; asset import also
757
+ takes tileset and tiles; normal-map: what the
712
758
  picture is (character, object, topdown, side, iso, ui)
713
- --mode <mode> normal-map: lite (default, 0.1 generation) or pro (0.5)
759
+ --mode <mode> normal-map: lite (default, 0.1 generation) or pro (0.5);
760
+ asset import --kind tileset: topdown (default) or sidescroller
714
761
  --strength <n> normal-map: how far pixels tilt from the viewer, 0-2
715
762
  --outline-rounding <n> normal-map: how much the outline rounds off, 0-3
716
763
  --part-shapes <n> normal-map: how much the sprite's 3D parts add, 0-2
717
764
  --surface-detail <n> normal-map: the art's light and dark as bumps, 0-2
718
765
  --detail-softness <n> normal-map: blur of that detail in px, 0.6-3
719
- --size <WxH> asset canvas: the new canvas, in multiples of 4
766
+ --size <WxH> asset canvas: the new canvas, in multiples of 4;
767
+ asset import --kind tileset/tiles: the tile size, e.g. 32
768
+ --text <line> talk gif/plan: the line of dialogue, up to 500 characters
769
+ --mood <mood> talk: neutral (default), happy, angry, sad or surprised
770
+ --visemes <n> talk visemes/plan: mouth positions, 3, 5, 7 (default) or 12
771
+ --engine <e> talk visemes: v3 (default) or pixminimax
772
+ --frame-ms <n> talk gif/plan: milliseconds per mouth position (default 90)
773
+ --hold-ms <n> talk gif/plan: pause on the closed mouth at the end (default 600)
774
+ --target <target> asset save: character:<id>:<dir>, object:<id>[:<dir>],
775
+ gallery:<id>, gallery:new, or tileset:<id>
776
+ --tile-type <type> asset import --kind tiles: square_topdown, isometric,
777
+ oblique, hex, hex_pointy or octagon
778
+ --lower, --upper, --transition <text>
779
+ asset import --kind tileset: the terrains' descriptions
720
780
  --animation <id> asset mirror/export: an animation group id
721
781
  --direction <dir> asset mirror: the direction to flip; asset expand: the
722
782
  way the object faces now; asset export gif: the direction
@@ -747,6 +807,8 @@ Options
747
807
  --part <name> vfx: add a part (repeatable; vfx parts lists them)
748
808
  --sprite <ref> vfx: build around a sprite: a file, a URL, or character:<id>:<dir>
749
809
  --fps <n> vfx: frames per second, 1-60
810
+ --sprite-frames <n> vfx --description: --sprite is a strip of n equal frames (2-32)
811
+ --sprite-fps <n> vfx --description: how fast the sprite animation plays (default 12)
750
812
  --game-pack vfx: also download the game-pack ZIP
751
813
  --glyph-px <n> font: native glyph size, 8, 16 (default), 32, or 64
752
814
  --prune cache: remove invalid/unreferenced local cache data
@@ -1296,10 +1358,10 @@ function normalizeHex(value) {
1296
1358
  function sha256(data) {
1297
1359
  return createHash("sha256").update(data).digest("hex");
1298
1360
  }
1299
- async function sha256File(path63) {
1361
+ async function sha256File(path65) {
1300
1362
  return new Promise((resolve, reject) => {
1301
1363
  const hash = createHash("sha256");
1302
- const stream = createReadStream(path63);
1364
+ const stream = createReadStream(path65);
1303
1365
  stream.on("data", (chunk2) => hash.update(chunk2));
1304
1366
  stream.on("error", reject);
1305
1367
  stream.on("end", () => resolve(hash.digest("hex")));
@@ -1335,6 +1397,12 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
1335
1397
  tileType: spec.tileType,
1336
1398
  tileView: spec.tileView,
1337
1399
  tileFeature: spec.tileFeature,
1400
+ // `tiles` shape options added in November 2026, each only when set.
1401
+ buildingRoofProfile: spec.buildingRoofProfile,
1402
+ tileElevation: spec.tileElevation,
1403
+ tileStepSlope: spec.tileStepSlope,
1404
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
1405
+ tileBoundarySeed: spec.tileBoundarySeed,
1338
1406
  outlineMode: spec.outlineMode,
1339
1407
  isometricTileSize: spec.isometricTileSize,
1340
1408
  isometricTileShape: spec.isometricTileShape,
@@ -1453,7 +1521,11 @@ function specHash(spec, styleImageHashes, providerOptionIdentity = spec.provider
1453
1521
  fps: spec.vfx.fps,
1454
1522
  sprite: spec.vfx.sprite ? "reference" in spec.vfx.sprite ? spec.vfx.sprite.reference : spec.vfx.sprite.sha256 : void 0,
1455
1523
  description: spec.vfx.description,
1456
- artist: spec.vfx.description ? spec.vfx.artist : void 0
1524
+ artist: spec.vfx.description ? spec.vfx.artist : void 0,
1525
+ // Absent for a still sprite, so every effect made before strips
1526
+ // existed keeps its hash.
1527
+ spriteFrames: spec.vfx.spriteFrames,
1528
+ spriteFps: spec.vfx.spriteFps
1457
1529
  } : void 0,
1458
1530
  // A mirror's bytes come from its source's recorded outputs; the plan
1459
1531
  // compares those directly, so only the choice of source is identity.
@@ -1824,8 +1896,21 @@ var AssetVfxSchema = z.object({
1824
1896
  fps: z.number().int().min(1).max(60).optional(),
1825
1897
  name: z.string().min(1).optional(),
1826
1898
  description: z.string().trim().min(1).max(8e3).optional(),
1827
- artist: z.enum(["lite", "pro"]).optional()
1899
+ artist: z.enum(["lite", "pro"]).optional(),
1900
+ spriteFrames: z.number().int().min(1).max(32).optional(),
1901
+ spriteFps: z.number().int().min(1).max(60).optional()
1828
1902
  }).strict().superRefine((vfx, context) => {
1903
+ for (const key2 of ["spriteFrames", "spriteFps"]) {
1904
+ if (vfx[key2] === void 0) continue;
1905
+ if (vfx.description === void 0) {
1906
+ context.addIssue({ code: z.ZodIssueCode.custom, message: `${key2} describes the sprite sent to PixelLab's VFX artist; add a description`, path: [key2] });
1907
+ } else if (!vfx.sprite) {
1908
+ context.addIssue({ code: z.ZodIssueCode.custom, message: `${key2} describes a sprite strip; add a sprite`, path: [key2] });
1909
+ }
1910
+ }
1911
+ if (vfx.spriteFps !== void 0 && vfx.sprite && vfx.description !== void 0 && (vfx.spriteFrames ?? 1) < 2) {
1912
+ context.addIssue({ code: z.ZodIssueCode.custom, message: "spriteFps is the speed of a sprite strip; set spriteFrames to 2 or more", path: ["spriteFps"] });
1913
+ }
1829
1914
  if (vfx.description !== void 0) {
1830
1915
  for (const key2 of ["preset", "recipe", "parts", "fps"]) {
1831
1916
  if (vfx[key2] !== void 0) {
@@ -2363,6 +2448,33 @@ var StyleObjectSchema = z.object({
2363
2448
  * Wall storey height as its own camera angle in degrees (5-90),
2364
2449
  * decoupled from the ground's pitch. */
2365
2450
  buildingWallAngle: z.number().min(5).max(90).optional(),
2451
+ /**
2452
+ * `tileFeature: "building"` with `buildingLayout: "materials"` only. The
2453
+ * shape of the roof pieces' edges: `gable` (a straight slope, the API
2454
+ * default) or `round` (curved).
2455
+ */
2456
+ buildingRoofProfile: z.enum(["gable", "round"]).optional(),
2457
+ /**
2458
+ * `tileFeature: "tileset"` on square_topdown, isometric or oblique tiles.
2459
+ * Terrain height in pixels, 0 to 12: raises the first terrain into a
2460
+ * plateau with a cliff face down to the second. The API refuses a height
2461
+ * that does not fit the tile's top face and wall at its size and view.
2462
+ */
2463
+ tileElevation: z.number().int().min(0).max(12).optional(),
2464
+ /**
2465
+ * `tileFeature: "tileset"` with `tileElevation` above 0. How far the drop
2466
+ * spreads sideways: 0 a cliff straight down (the default) to 2 a gentle
2467
+ * slope.
2468
+ */
2469
+ tileStepSlope: z.number().min(0).max(2).optional(),
2470
+ /**
2471
+ * `tileFeature: "tileset"` only. How far the border between the terrains
2472
+ * meanders instead of running straight, 0 (the default) to 0.3. Tiles
2473
+ * still connect seamlessly.
2474
+ */
2475
+ tileBoundaryAmplitude: z.number().min(0).max(0.3).optional(),
2476
+ /** `tileFeature: "tileset"` with `tileBoundaryAmplitude`. Which meander: another number gives a different border. */
2477
+ tileBoundarySeed: z.number().int().min(0).optional(),
2366
2478
  /**
2367
2479
  * `tiles` generator only. How tile edges are drawn.
2368
2480
  *
@@ -2736,7 +2848,7 @@ var AssetDeriveSchema = z.object({
2736
2848
  /** scale: `nearest` (default) keeps hard edges; `box` averages the covered pixels. */
2737
2849
  mode: z.enum(["nearest", "box"]).optional()
2738
2850
  }).strict().superRefine((derive, context) => {
2739
- const issue = (message6, path63) => context.addIssue({ code: z.ZodIssueCode.custom, message: message6, path: [path63] });
2851
+ const issue = (message6, path65) => context.addIssue({ code: z.ZodIssueCode.custom, message: message6, path: [path65] });
2740
2852
  if (Boolean(derive.from) === Boolean(derive.file)) {
2741
2853
  issue("name exactly one source: `from` (an asset in this style) or `file` (a committed PNG)", derive.from ? "file" : "from");
2742
2854
  }
@@ -7228,6 +7340,53 @@ var ImportObjectSchema = z3.object({
7228
7340
  size: z3.object({ width: z3.number(), height: z3.number() }).passthrough(),
7229
7341
  image_url: z3.string()
7230
7342
  }).passthrough();
7343
+ var ImportTilesetSchema = z3.object({ tileset_id: z3.string().min(1), status: z3.string().default("completed") }).passthrough();
7344
+ var ImportTilesProSchema = z3.object({ tile_id: z3.string().min(1), status: z3.string().default("completed") }).passthrough();
7345
+ var SaveToAssetSchema = z3.object({
7346
+ action: z3.enum(["saved", "added", "unchanged"]),
7347
+ target: z3.string().min(1),
7348
+ kind: z3.string(),
7349
+ width: z3.number(),
7350
+ height: z3.number(),
7351
+ frame_count: z3.number(),
7352
+ changed_pixels: z3.number().default(0),
7353
+ previous_frames: z3.array(z3.object({ base64: z3.string().min(1) }).passthrough()).nullable().optional(),
7354
+ note: z3.string().nullable().optional(),
7355
+ maps: z3.string().nullable().optional()
7356
+ }).passthrough();
7357
+ var VocalAnimationSubmitSchema = z3.object({ background_job_id: z3.string().min(1), status: z3.string().default("processing") }).passthrough();
7358
+ var VocalAnimationJobSchema = z3.object({
7359
+ status: z3.string(),
7360
+ mood: z3.string().optional(),
7361
+ viseme_count: z3.number().optional(),
7362
+ character_id: z3.string().nullable().optional(),
7363
+ completed_visemes: z3.array(z3.string()).default([]),
7364
+ visemes: z3.record(z3.string(), z3.object({ base64: z3.string().min(1) }).passthrough()).nullable().optional(),
7365
+ moods_on_character: z3.array(z3.string()).nullable().optional(),
7366
+ grid_url: z3.string().nullable().optional(),
7367
+ viseme_order: z3.array(z3.string()).nullable().optional(),
7368
+ usage: z3.unknown().optional()
7369
+ }).passthrough();
7370
+ var TalkingGifSchema = z3.object({
7371
+ gif_base64: z3.string().min(1),
7372
+ frames: z3.number(),
7373
+ duration_ms: z3.number(),
7374
+ frame_ms: z3.number(),
7375
+ hold_ms: z3.number(),
7376
+ width: z3.number(),
7377
+ height: z3.number(),
7378
+ mood: z3.string().nullable().optional()
7379
+ }).passthrough();
7380
+ var LipSyncSchema = z3.object({
7381
+ text: z3.string(),
7382
+ total_ms: z3.number(),
7383
+ viseme_order: z3.array(z3.string()),
7384
+ frames: z3.array(z3.object({ viseme: z3.string(), column: z3.number(), duration_ms: z3.number(), text_offset: z3.number() }).passthrough()),
7385
+ mood: z3.string().nullable().optional(),
7386
+ grid_url: z3.string().nullable().optional(),
7387
+ row: z3.number().nullable().optional(),
7388
+ rows: z3.number().nullable().optional()
7389
+ }).passthrough();
7231
7390
  var ExpandRotationsSchema = z3.object({
7232
7391
  object_id: z3.string().min(1),
7233
7392
  background_job_id: z3.string().min(1),
@@ -7596,9 +7755,9 @@ var PixelLabClient = class {
7596
7755
  apiKey;
7597
7756
  http;
7598
7757
  /** Retries transport failures, 429, and 5xx; see http.ts for the policy. */
7599
- async request(path63, init) {
7758
+ async request(path65, init) {
7600
7759
  const auth = this.apiKey.startsWith("Bearer ") ? this.apiKey : `Bearer ${this.apiKey}`;
7601
- const res = await this.http(`${BASE}${path63}`, {
7760
+ const res = await this.http(`${BASE}${path65}`, {
7602
7761
  ...init,
7603
7762
  headers: {
7604
7763
  Authorization: auth,
@@ -7609,13 +7768,13 @@ var PixelLabClient = class {
7609
7768
  const text = await res.text();
7610
7769
  if (!res.ok) {
7611
7770
  const hint = res.status === 500 && text.includes("Failed to start any animation jobs") ? '; a skeleton-v3 loop needs a character with a stored 3D skeleton (a v3 base), use mode: "template" on a standard one' : "";
7612
- throw new PixelLabError(`${init?.method ?? "GET"} ${path63} \u2192 ${res.status}${hint}${refusalReason(res.status, text)}`, res.status, text);
7771
+ throw new PixelLabError(`${init?.method ?? "GET"} ${path65} \u2192 ${res.status}${hint}${refusalReason(res.status, text)}`, res.status, text);
7613
7772
  }
7614
7773
  if (!text) return {};
7615
7774
  try {
7616
7775
  return JSON.parse(text);
7617
7776
  } catch {
7618
- throw new Error(`${init?.method ?? "GET"} ${path63} returned invalid JSON`);
7777
+ throw new Error(`${init?.method ?? "GET"} ${path65} returned invalid JSON`);
7619
7778
  }
7620
7779
  }
7621
7780
  async balance() {
@@ -7730,6 +7889,11 @@ var PixelLabClient = class {
7730
7889
  if (args.buildingFloorDescription) body.building_floor_description = args.buildingFloorDescription;
7731
7890
  if (args.buildingFloor2Description) body.building_floor2_description = args.buildingFloor2Description;
7732
7891
  if (args.buildingWallAngle != null) body.building_wall_angle = args.buildingWallAngle;
7892
+ if (args.roofProfile) body.roof_profile = args.roofProfile;
7893
+ if (args.elevation != null) body.elevation = args.elevation;
7894
+ if (args.stepSlope != null) body.step_slope = args.stepSlope;
7895
+ if (args.boundaryAmplitude != null) body.boundary_amplitude = args.boundaryAmplitude;
7896
+ if (args.boundarySeed != null) body.boundary_seed = args.boundarySeed;
7733
7897
  if (args.outlineMode) body.outline_mode = args.outlineMode;
7734
7898
  if (args.seed != null) body.seed = args.seed;
7735
7899
  if (args.styleImages?.length) body.style_images = args.styleImages;
@@ -8147,10 +8311,10 @@ var PixelLabClient = class {
8147
8311
  const palette = args.paletteSwatchBase64 ? { color_image: { type: "base64", base64: args.paletteSwatchBase64, format: "png" }, force_colors: true } : {};
8148
8312
  const encode = (image) => ({ type: "base64", base64: image.base64, format: image.format });
8149
8313
  const south = args.reference?.south;
8150
- let path63;
8314
+ let path65;
8151
8315
  let body;
8152
8316
  if (args.mode === "v3") {
8153
- path63 = "/create-character-v3";
8317
+ path65 = "/create-character-v3";
8154
8318
  body = {
8155
8319
  description: args.description,
8156
8320
  image_size: imageSize,
@@ -8164,7 +8328,7 @@ var PixelLabClient = class {
8164
8328
  ...args.enhancePrompt ? { enhance_prompt: true } : {}
8165
8329
  };
8166
8330
  } else if (args.mode === "pro-flash") {
8167
- path63 = "/create-character-pro-flash";
8331
+ path65 = "/create-character-pro-flash";
8168
8332
  const traits = args.styleTraits;
8169
8333
  body = {
8170
8334
  description: args.description,
@@ -8188,7 +8352,7 @@ var PixelLabClient = class {
8188
8352
  } : {}
8189
8353
  };
8190
8354
  } else if (args.mode === "pro") {
8191
- path63 = "/create-character-pro";
8355
+ path65 = "/create-character-pro";
8192
8356
  body = {
8193
8357
  description: args.description,
8194
8358
  image_size: imageSize,
@@ -8202,7 +8366,7 @@ var PixelLabClient = class {
8202
8366
  ...!south && args.styleCharacterId ? { style_character_id: args.styleCharacterId } : {}
8203
8367
  };
8204
8368
  } else {
8205
- path63 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
8369
+ path65 = args.directions === 4 ? "/create-character-with-4-directions" : "/create-character-with-8-directions";
8206
8370
  body = {
8207
8371
  description: args.description,
8208
8372
  image_size: imageSize,
@@ -8220,8 +8384,8 @@ var PixelLabClient = class {
8220
8384
  };
8221
8385
  }
8222
8386
  if (args.mode === "pro" || args.mode === "pro-flash") Object.assign(body, targetPaletteBody(args.targetPalette));
8223
- const raw = await this.request(path63, { method: "POST", body: JSON.stringify(body) });
8224
- return validateResponse(CharacterSubmitSchema, raw, path63.slice(1));
8387
+ const raw = await this.request(path65, { method: "POST", body: JSON.stringify(body) });
8388
+ return validateResponse(CharacterSubmitSchema, raw, path65.slice(1));
8225
8389
  }
8226
8390
  /** A text edit of an existing character, applied to every direction and stored as a sibling. */
8227
8391
  async createCharacterState(args) {
@@ -8796,6 +8960,8 @@ var PixelLabClient = class {
8796
8960
  const body = { description: args.description };
8797
8961
  if (args.artist) body.artist = args.artist;
8798
8962
  if (args.sprite) body.sprite = { type: "base64", base64: args.sprite.base64, format: args.sprite.format };
8963
+ if (args.sprite && args.spriteFrames != null && args.spriteFrames > 1) body.sprite_frames = args.spriteFrames;
8964
+ if (args.sprite && args.spriteFps != null) body.sprite_fps = args.spriteFps;
8799
8965
  if (args.effectId) body.effect_id = args.effectId;
8800
8966
  if (args.conversation) body.conversation = args.conversation;
8801
8967
  if (args.name) body.name = args.name;
@@ -8940,6 +9106,108 @@ var PixelLabClient = class {
8940
9106
  "objects/import"
8941
9107
  );
8942
9108
  }
9109
+ /**
9110
+ * `POST /vocal-animation`: one expression's mouth positions for a portrait,
9111
+ * from an image (nothing stored; the frames come back inline) or from a
9112
+ * character's stored portrait (saved onto it). Paid; `pixminimax` costs 3
9113
+ * generations for 7 positions at any size, `v3` 3 to 24 by size.
9114
+ */
9115
+ async createVocalAnimation(args) {
9116
+ const body = {};
9117
+ if (args.portrait) body.portrait = { type: "base64", base64: args.portrait.base64, format: args.portrait.format };
9118
+ if (args.characterId) body.character_id = args.characterId;
9119
+ if (args.mood) body.mood = args.mood;
9120
+ if (args.visemeCount != null) body.viseme_count = args.visemeCount;
9121
+ if (args.engine) body.engine = args.engine;
9122
+ if (args.seed != null) body.seed = args.seed;
9123
+ return validateResponse(
9124
+ VocalAnimationSubmitSchema,
9125
+ await this.request("/vocal-animation", { method: "POST", body: JSON.stringify(body) }),
9126
+ "vocal-animation"
9127
+ );
9128
+ }
9129
+ /** `GET /vocal-animation/{job}`: the job's status, and its mouth positions once completed. Its bill is on `getBackgroundJob`. */
9130
+ async getVocalAnimation(jobId) {
9131
+ return validateResponse(VocalAnimationJobSchema, await this.request(`/vocal-animation/${encodeURIComponent(jobId)}`), "vocal-animation/{job}");
9132
+ }
9133
+ /** `POST /talking-gif`: a line of text lip-synced to a GIF from mouth positions already made. Free; answers at once. */
9134
+ async createTalkingGif(args) {
9135
+ const body = { text: args.text };
9136
+ if (args.visemes) {
9137
+ body.visemes = Object.fromEntries(Object.entries(args.visemes).map(([id, image]) => [id, { type: "base64", base64: image.base64, format: image.format }]));
9138
+ }
9139
+ if (args.characterId) body.character_id = args.characterId;
9140
+ if (args.mood) body.mood = args.mood;
9141
+ if (args.frameMs != null) body.frame_ms = args.frameMs;
9142
+ if (args.holdMs != null) body.hold_ms = args.holdMs;
9143
+ return validateResponse(TalkingGifSchema, await this.request("/talking-gif", { method: "POST", body: JSON.stringify(body) }), "talking-gif");
9144
+ }
9145
+ /** `POST /lip-sync`: which mouth position to show and for how long, for a line of text. Free; nothing is rendered. */
9146
+ async getLipSync(args) {
9147
+ const body = { text: args.text };
9148
+ if (args.characterId) body.character_id = args.characterId;
9149
+ if (args.mood) body.mood = args.mood;
9150
+ if (args.visemeCount != null) body.viseme_count = args.visemeCount;
9151
+ if (args.frameMs != null) body.frame_ms = args.frameMs;
9152
+ if (args.holdMs != null) body.hold_ms = args.holdMs;
9153
+ return validateResponse(LipSyncSchema, await this.request("/lip-sync", { method: "POST", body: JSON.stringify(body) }), "lip-sync");
9154
+ }
9155
+ /**
9156
+ * `POST /tilesets/import`: your own Wang sheet as a completed tileset, in
9157
+ * PixelLab's compact 4x4 layout or its 8-wide native one. Free. Send
9158
+ * `tileSize` whenever the sheet reads two ways: omitted, PixelLab takes the
9159
+ * 4x4 reading and cuts a native sheet into the wrong tiles.
9160
+ */
9161
+ async importTileset(args) {
9162
+ const body = {
9163
+ spritesheet: { type: "base64", base64: args.spritesheet.base64, format: args.spritesheet.format }
9164
+ };
9165
+ if (args.mode) body.tileset_mode = args.mode;
9166
+ if (args.tileSize != null) body.tile_size = { width: args.tileSize, height: args.tileSize };
9167
+ if (args.lowerDescription) body.lower_description = args.lowerDescription;
9168
+ if (args.upperDescription) body.upper_description = args.upperDescription;
9169
+ if (args.transitionDescription) body.transition_description = args.transitionDescription;
9170
+ if (args.name) body.name = args.name;
9171
+ return validateResponse(
9172
+ ImportTilesetSchema,
9173
+ await this.request("/tilesets/import", { method: "POST", body: JSON.stringify(body) }),
9174
+ "tilesets/import"
9175
+ );
9176
+ }
9177
+ /** `POST /tiles-pro/import`: 1 to 32 of your own tile PNGs as one completed tile group. Free. */
9178
+ async importTilesPro(args) {
9179
+ const body = {
9180
+ frames: args.frames.map((frame) => ({ type: "base64", base64: frame.base64, format: frame.format })),
9181
+ tile_type: args.tileType,
9182
+ tile_size: args.tileSize
9183
+ };
9184
+ if (args.description) body.description = args.description;
9185
+ if (args.tileView) body.tile_view = args.tileView;
9186
+ return validateResponse(
9187
+ ImportTilesProSchema,
9188
+ await this.request("/tiles-pro/import", { method: "POST", body: JSON.stringify(body) }),
9189
+ "tiles-pro/import"
9190
+ );
9191
+ }
9192
+ /**
9193
+ * `POST /save-to-asset`: write edited pixels back into a stored character
9194
+ * or object rotation, one direction of an animation, a gallery image or a
9195
+ * tileset sheet, or add a new gallery image (`gallery:new`). Free. The
9196
+ * image must match what it replaces in size and frame count. What was
9197
+ * there comes back as `previous_frames`; saving those again is the undo.
9198
+ */
9199
+ async saveToAsset(args) {
9200
+ const body = { target: args.target };
9201
+ if (args.image) body.image = { type: "base64", base64: args.image.base64, format: args.image.format };
9202
+ if (args.frames) body.frames = args.frames.map((frame) => ({ type: "base64", base64: frame.base64, format: frame.format }));
9203
+ if (args.name) body.name = args.name;
9204
+ if (args.description) body.description = args.description;
9205
+ return validateResponse(
9206
+ SaveToAssetSchema,
9207
+ await this.request("/save-to-asset", { method: "POST", body: JSON.stringify(body) }),
9208
+ "save-to-asset"
9209
+ );
9210
+ }
8943
9211
  /**
8944
9212
  * `POST /objects/{id}/expand-rotations`: draw the 7 missing directions of a
8945
9213
  * 1-direction object. The object then waits in `review-expansion` until
@@ -9484,27 +9752,64 @@ async function makeVfx(client2, opts) {
9484
9752
  }
9485
9753
  var VFX_ARTISTS = ["lite", "pro"];
9486
9754
  var VFX_ARTIST_MAX_SPRITE = 512;
9487
- function vfxArtistQuote(artist, sprite, change = false) {
9755
+ function vfxArtistQuote(artist, sprite, change = false, animated = false) {
9488
9756
  const table = {
9489
9757
  lite: { new: [1, 1, 3, 5], change: [1, 1, 2, 2] },
9490
9758
  pro: { new: [6, 8, 14, 28], change: [4, 4, 5, 8] }
9491
9759
  };
9492
9760
  const tier = sprite === "none" ? 0 : sprite === "unknown" ? 3 : sprite <= 128 ? 1 : sprite <= 256 ? 2 : 3;
9493
- return table[artist][change ? "change" : "new"][tier];
9761
+ const base = table[artist][change ? "change" : "new"][tier];
9762
+ return animated && tier > 0 ? base + VFX_ARTIST_ANIMATED_EXTRA[artist][tier - 1] : base;
9494
9763
  }
9764
+ var VFX_ARTIST_ANIMATED_EXTRA = { lite: [1, 1, 1], pro: [1, 2, 5] };
9765
+ var VFX_ARTIST_MAX_FRAMES = 32;
9766
+ var VFX_ARTIST_MAX_STRIP = 1024;
9495
9767
  function vfxArtistCeiling(quote) {
9496
9768
  return quote * 2;
9497
9769
  }
9498
- function vfxArtistSprite(bytes, label) {
9499
- const metadata = imageMetadata(bytes);
9500
- if (metadata?.format !== "png") throw new Error(`${label}: PixelLab's VFX artist takes a PNG sprite`);
9501
- const side = Math.max(metadata.width, metadata.height);
9770
+ function gifSize(bytes) {
9771
+ if (bytes.length < 10) return null;
9772
+ const magic = bytes.toString("ascii", 0, 6);
9773
+ if (magic !== "GIF87a" && magic !== "GIF89a") return null;
9774
+ return { width: bytes.readUInt16LE(6), height: bytes.readUInt16LE(8) };
9775
+ }
9776
+ function vfxArtistFrameSide(width, height, frames, label) {
9777
+ if (!Number.isInteger(frames) || frames < 1 || frames > VFX_ARTIST_MAX_FRAMES) {
9778
+ throw new Error(`${label}: a sprite strip holds 1 to ${VFX_ARTIST_MAX_FRAMES} frames, got ${frames}`);
9779
+ }
9780
+ if (width % frames !== 0) {
9781
+ throw new Error(`${label} is ${width}px wide, which does not divide into ${frames} equal frames`);
9782
+ }
9783
+ if (frames > 1 && width > VFX_ARTIST_MAX_STRIP) {
9784
+ throw new Error(
9785
+ `${label} is a ${width}px-wide strip; PixelLab's VFX artist takes a strip up to ${VFX_ARTIST_MAX_STRIP}px wide. Send fewer frames, or the animation as a GIF`
9786
+ );
9787
+ }
9788
+ const frameWidth = width / frames;
9789
+ const side = Math.max(frameWidth, height);
9502
9790
  if (side > VFX_ARTIST_MAX_SPRITE) {
9503
9791
  throw new Error(
9504
- `${label} is ${metadata.width}x${metadata.height}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
9792
+ `${label} is ${frameWidth}x${height}${frames > 1 ? " a frame" : ""}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
9505
9793
  );
9506
9794
  }
9507
- return { image: { base64: bytes.toString("base64"), format: "png" }, side };
9795
+ return side;
9796
+ }
9797
+ function vfxArtistSprite(bytes, label, frames = 1) {
9798
+ const gif = gifSize(bytes);
9799
+ if (gif) {
9800
+ if (frames !== 1) throw new Error(`${label} is a GIF, which brings its own frames; drop the frame count`);
9801
+ const side2 = Math.max(gif.width, gif.height);
9802
+ if (side2 > VFX_ARTIST_MAX_SPRITE) {
9803
+ throw new Error(
9804
+ `${label} is ${gif.width}x${gif.height}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
9805
+ );
9806
+ }
9807
+ return { image: { base64: bytes.toString("base64"), format: "gif" }, side: side2, animated: true };
9808
+ }
9809
+ const metadata = imageMetadata(bytes);
9810
+ if (metadata?.format !== "png") throw new Error(`${label}: PixelLab's VFX artist takes a PNG or GIF sprite`);
9811
+ const side = vfxArtistFrameSide(metadata.width, metadata.height, frames, label);
9812
+ return { image: { base64: bytes.toString("base64"), format: "png" }, side, animated: frames > 1 };
9508
9813
  }
9509
9814
  function vfxArtistFiles(raw) {
9510
9815
  const urlOf = (value) => {
@@ -9589,7 +9894,7 @@ async function makeVfxWithArtist(client2, opts) {
9589
9894
  }
9590
9895
  const progress2 = opts.onProgress ?? (() => {
9591
9896
  });
9592
- const sprite = opts.sprite ? vfxArtistSprite(await readFile7(opts.sprite), opts.sprite).image : void 0;
9897
+ const sprite = opts.sprite ? vfxArtistSprite(await readFile7(opts.sprite), opts.sprite, opts.spriteFrames ?? 1).image : void 0;
9593
9898
  const sleep3 = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
9594
9899
  const interval = opts.intervalMs ?? 6e3;
9595
9900
  const timeout = opts.timeoutMs ?? 10 * 6e4;
@@ -9597,6 +9902,8 @@ async function makeVfxWithArtist(client2, opts) {
9597
9902
  description: opts.description,
9598
9903
  artist: opts.artist,
9599
9904
  sprite,
9905
+ spriteFrames: sprite ? opts.spriteFrames : void 0,
9906
+ spriteFps: sprite ? opts.spriteFps : void 0,
9600
9907
  effectId: opts.effect,
9601
9908
  conversation: opts.effect ? opts.conversation : void 0,
9602
9909
  name: opts.name,
@@ -9641,7 +9948,7 @@ async function makeVfxWithArtist(client2, opts) {
9641
9948
  written[key2] = target;
9642
9949
  }
9643
9950
  const facts = vfxArtistFrameFacts(result, atlas);
9644
- const usage = job.usage ?? null;
9951
+ const usage2 = job.usage ?? null;
9645
9952
  const provenance = {
9646
9953
  version: 1,
9647
9954
  provider: "pixellab",
@@ -9654,6 +9961,8 @@ async function makeVfxWithArtist(client2, opts) {
9654
9961
  message: result.message,
9655
9962
  source: {
9656
9963
  ...opts.sprite ? { sprite: path14.relative(path14.dirname(paths.provenance), path14.resolve(opts.sprite)).split(path14.sep).join("/") } : {},
9964
+ ...opts.sprite && opts.spriteFrames && opts.spriteFrames > 1 ? { spriteFrames: opts.spriteFrames } : {},
9965
+ ...opts.sprite && opts.spriteFps ? { spriteFps: opts.spriteFps } : {},
9657
9966
  ...opts.effect ? { changed: opts.effect } : {}
9658
9967
  },
9659
9968
  ...facts,
@@ -9665,7 +9974,7 @@ async function makeVfxWithArtist(client2, opts) {
9665
9974
  ["sheet", "gif", "atlas", "gamePack", "normals"].filter((key2) => written[key2]).map((key2) => [key2, path14.basename(written[key2])])
9666
9975
  ),
9667
9976
  quotedGenerations: submitted.quoted_generations ?? null,
9668
- usage,
9977
+ usage: usage2,
9669
9978
  conversation: result.conversation,
9670
9979
  exportedAt: (/* @__PURE__ */ new Date()).toISOString()
9671
9980
  };
@@ -9682,7 +9991,7 @@ async function makeVfxWithArtist(client2, opts) {
9682
9991
  loop: result.loop,
9683
9992
  anchor: result.anchor,
9684
9993
  quotedGenerations: submitted.quoted_generations ?? null,
9685
- usage,
9994
+ usage: usage2,
9686
9995
  paths: written
9687
9996
  };
9688
9997
  }
@@ -9996,8 +10305,9 @@ function pixelLabObjectUrl(generator, objectId) {
9996
10305
  }
9997
10306
  function vfxArtistSpecQuote(spec) {
9998
10307
  const sprite = spec.vfx?.sprite;
9999
- const side = !sprite ? "none" : "file" in sprite && sprite.width != null && sprite.height != null ? Math.max(sprite.width, sprite.height) : "unknown";
10000
- return vfxArtistQuote(spec.vfx?.artist ?? "lite", side);
10308
+ const frames = spec.vfx?.spriteFrames ?? 1;
10309
+ const side = !sprite ? "none" : "file" in sprite && sprite.width != null && sprite.height != null ? Math.max(Math.ceil(sprite.width / frames), sprite.height) : "unknown";
10310
+ return vfxArtistQuote(spec.vfx?.artist ?? "lite", side, false, frames > 1);
10001
10311
  }
10002
10312
  function workbenchVfxUrls(exported) {
10003
10313
  const sheetFile = exported.files.find((file) => /\.png$/i.test(file));
@@ -10008,12 +10318,12 @@ function workbenchVfxUrls(exported) {
10008
10318
  ...atlasFile ? { atlas: `${exported.downloadBase}${encodeURIComponent(atlasFile)}` } : {}
10009
10319
  };
10010
10320
  }
10011
- function billedFromUsage(usage) {
10012
- if (!usage) return null;
10013
- if (usage.type === "usd" || usage.type === void 0 && typeof usage.usd === "number") {
10014
- return typeof usage.usd === "number" ? { amount: usage.usd, unit: "usd" } : null;
10321
+ function billedFromUsage(usage2) {
10322
+ if (!usage2) return null;
10323
+ if (usage2.type === "usd" || usage2.type === void 0 && typeof usage2.usd === "number") {
10324
+ return typeof usage2.usd === "number" ? { amount: usage2.usd, unit: "usd" } : null;
10015
10325
  }
10016
- if (typeof usage.generations === "number") return { amount: usage.generations, unit: "generations" };
10326
+ if (typeof usage2.generations === "number") return { amount: usage2.generations, unit: "generations" };
10017
10327
  return null;
10018
10328
  }
10019
10329
  function characterCost(spec) {
@@ -10336,6 +10646,7 @@ var PixelLabProvider = class _PixelLabProvider {
10336
10646
  `vfx sprite ${sprite.file} is ${sprite.width}x${sprite.height}; PixelLab's VFX artist takes up to ${VFX_ARTIST_MAX_SPRITE}x${VFX_ARTIST_MAX_SPRITE} (crop or pad it; never rescale pixel art)`
10337
10647
  );
10338
10648
  }
10649
+ if (spec.generator === "tiles") this.validateTileOptions(spec);
10339
10650
  const members = spec.revision?.sourceMembers;
10340
10651
  if (spec.revision && members && !MEMBER_SET_REVISION_MODES.includes(spec.revision.mode)) {
10341
10652
  throw new Error(
@@ -10607,6 +10918,31 @@ var PixelLabProvider = class _PixelLabProvider {
10607
10918
  );
10608
10919
  }
10609
10920
  }
10921
+ /** Where `/create-tiles-pro`'s newer shape options apply; elsewhere the API ignores or refuses them. */
10922
+ validateTileOptions(spec) {
10923
+ const tilesetOnly = {
10924
+ tileElevation: spec.tileElevation,
10925
+ tileStepSlope: spec.tileStepSlope,
10926
+ tileBoundaryAmplitude: spec.tileBoundaryAmplitude,
10927
+ tileBoundarySeed: spec.tileBoundarySeed
10928
+ };
10929
+ const set = Object.entries(tilesetOnly).filter(([, value]) => value != null).map(([field]) => field);
10930
+ if (set.length && spec.tileFeature !== "tileset") {
10931
+ throw new Error(`PixelLab tiles: ${set.join(", ")} shape a connectable terrain set; set tileFeature: "tileset"`);
10932
+ }
10933
+ if (spec.tileElevation != null && spec.tileElevation > 0 && spec.tileType && !["square_topdown", "isometric", "oblique"].includes(spec.tileType)) {
10934
+ throw new Error(`PixelLab tiles: tileElevation raises a plateau on square_topdown, isometric or oblique tiles, not "${spec.tileType}"`);
10935
+ }
10936
+ if (spec.tileStepSlope != null && !(spec.tileElevation != null && spec.tileElevation > 0)) {
10937
+ throw new Error("PixelLab tiles: tileStepSlope spreads the drop of a raised terrain; set tileElevation above 0");
10938
+ }
10939
+ if (spec.tileBoundarySeed != null && spec.tileBoundaryAmplitude == null) {
10940
+ throw new Error("PixelLab tiles: tileBoundarySeed picks tileBoundaryAmplitude's meander; set both or neither");
10941
+ }
10942
+ if (spec.buildingRoofProfile && !(spec.tileFeature === "building" && spec.buildingLayout === "materials")) {
10943
+ throw new Error(`PixelLab tiles: buildingRoofProfile shapes a building kit's roof pieces; set tileFeature: "building" with buildingLayout: "materials"`);
10944
+ }
10945
+ }
10610
10946
  /** `/create-tileset`'s own rules, beyond the enums both terrain endpoints share. */
10611
10947
  validateTopDownTerrain(spec) {
10612
10948
  if (spec.terrainShapeStyle && spec.terrainMode === "pro") {
@@ -11497,6 +11833,11 @@ var PixelLabProvider = class _PixelLabProvider {
11497
11833
  buildingFloorDescription: spec.buildingFloorDescription,
11498
11834
  buildingFloor2Description: spec.buildingFloor2Description,
11499
11835
  buildingWallAngle: spec.buildingWallAngle,
11836
+ roofProfile: spec.buildingRoofProfile,
11837
+ elevation: spec.tileElevation,
11838
+ stepSlope: spec.tileStepSlope,
11839
+ boundaryAmplitude: spec.tileBoundaryAmplitude,
11840
+ boundarySeed: spec.tileBoundarySeed,
11500
11841
  outlineMode: spec.outlineMode,
11501
11842
  seed: spec.seed,
11502
11843
  // TilesProStyleImage is flat and wants the reference's real dimensions,
@@ -11880,16 +12221,16 @@ var PixelLabProvider = class _PixelLabProvider {
11880
12221
  * member roles recorded so `pollCachedRevision` hands them back under the
11881
12222
  * same names the parent's set used.
11882
12223
  */
11883
- cacheCleanupResult(pngs, usage, roles, fps) {
12224
+ cacheCleanupResult(pngs, usage2, roles, fps) {
11884
12225
  const jobId = randomUUID3();
11885
12226
  if (!roles) {
11886
12227
  writeFileSync(path16.join(_PixelLabProvider.cacheDir(), `${jobId}.png`), pngs[0]);
11887
- return { jobId, metadata: { revisionUsage: usage } };
12228
+ return { jobId, metadata: { revisionUsage: usage2 } };
11888
12229
  }
11889
12230
  for (const [index, png] of pngs.entries()) {
11890
12231
  writeFileSync(path16.join(_PixelLabProvider.cacheDir(), `${jobId}-${index}.png`), png);
11891
12232
  }
11892
- return { jobId, metadata: { revisionUsage: usage, revisionMembers: roles, ...fps != null ? { revisionFps: fps } : {} } };
12233
+ return { jobId, metadata: { revisionUsage: usage2, revisionMembers: roles, ...fps != null ? { revisionFps: fps } : {} } };
11893
12234
  }
11894
12235
  /**
11895
12236
  * What a background job actually billed, once its own record is still
@@ -11902,8 +12243,8 @@ var PixelLabProvider = class _PixelLabProvider {
11902
12243
  try {
11903
12244
  const job = await this.client.getBackgroundJob(backgroundJobId);
11904
12245
  const nested = job.last_response?.billing_usage;
11905
- for (const usage of [job.usage, nested]) {
11906
- const billed = billedFromUsage(usage);
12246
+ for (const usage2 of [job.usage, nested]) {
12247
+ const billed = billedFromUsage(usage2);
11907
12248
  if (billed && !(billed.unit === "usd" && billed.amount === 0)) return billed;
11908
12249
  }
11909
12250
  return null;
@@ -12058,11 +12399,20 @@ var PixelLabProvider = class _PixelLabProvider {
12058
12399
  if (sha256(bytes) !== vfx.sprite.sha256) {
12059
12400
  throw new Error(`vfx sprite changed after the manifest was resolved: ${file}; run the command again`);
12060
12401
  }
12061
- sprite = vfxArtistSprite(bytes, `vfx sprite ${file}`).image;
12402
+ const taken = vfxArtistSprite(bytes, `vfx sprite ${file}`, vfx.spriteFrames ?? 1).image;
12403
+ if (taken.format !== "png") throw new Error(`vfx sprite must be a PNG: ${file}`);
12404
+ sprite = { base64: taken.base64, format: "png" };
12062
12405
  }
12063
12406
  const previous = context?.replacedMetadata?.vfx ?? context?.lastGenerationMetadata?.vfx;
12064
12407
  const artist = vfx.artist ?? "lite";
12065
- const submitted = await this.client.createVfx({ description: vfx.description, artist, sprite, name: vfx.name });
12408
+ const submitted = await this.client.createVfx({
12409
+ description: vfx.description,
12410
+ artist,
12411
+ sprite,
12412
+ spriteFrames: vfx.spriteFrames,
12413
+ spriteFps: vfx.spriteFps,
12414
+ name: vfx.name
12415
+ });
12066
12416
  return {
12067
12417
  jobId: submitted.background_job_id,
12068
12418
  metadata: {
@@ -12171,7 +12521,7 @@ var PixelLabProvider = class _PixelLabProvider {
12171
12521
  };
12172
12522
  }
12173
12523
  async pollCachedRevision(jobId, context) {
12174
- const usage = context?.metadata?.revisionUsage;
12524
+ const usage2 = context?.metadata?.revisionUsage;
12175
12525
  const roles = context?.metadata?.revisionMembers;
12176
12526
  const gone = {
12177
12527
  status: "failed",
@@ -12191,13 +12541,13 @@ var PixelLabProvider = class _PixelLabProvider {
12191
12541
  sourceUrl: sources[0].url,
12192
12542
  sources,
12193
12543
  ...frames && typeof fps === "number" ? { metadata: { frameSet: { fps, count: sources.length } } } : {},
12194
- billed: billedFromUsage(usage)
12544
+ billed: billedFromUsage(usage2)
12195
12545
  };
12196
12546
  }
12197
12547
  const file = path16.join(_PixelLabProvider.cacheDir(), `${jobId}.png`);
12198
12548
  if (!existsSync11(file)) return gone;
12199
12549
  const sourceUrl = `file://${file}`;
12200
- return { status: "ready", objectId: jobId, sourceUrl, sources: [{ url: sourceUrl }], billed: billedFromUsage(usage) };
12550
+ return { status: "ready", objectId: jobId, sourceUrl, sources: [{ url: sourceUrl }], billed: billedFromUsage(usage2) };
12201
12551
  }
12202
12552
  /**
12203
12553
  * A `normal-map` revision: a background job whose map is
@@ -12532,10 +12882,10 @@ var PixelLabProvider = class _PixelLabProvider {
12532
12882
  */
12533
12883
  async pollTerrain(tilesetId, context) {
12534
12884
  try {
12535
- const { tileset, usage, metadata } = await this.client.getTileset(tilesetId);
12885
+ const { tileset, usage: usage2, metadata } = await this.client.getTileset(tilesetId);
12536
12886
  const sidescroller = metadata.view === "side" || context?.spec?.terrainOrientation === "sidescroller";
12537
12887
  const backgroundJobId = context?.metadata?.backgroundJobId;
12538
- const billed = billedFromUsage(usage) ?? await this.billedForJob(backgroundJobId);
12888
+ const billed = billedFromUsage(usage2) ?? await this.billedForJob(backgroundJobId);
12539
12889
  const sources = [];
12540
12890
  const terrainTiles = [];
12541
12891
  for (const [index, tile] of tileset.tiles.entries()) {
@@ -12574,9 +12924,9 @@ var PixelLabProvider = class _PixelLabProvider {
12574
12924
  */
12575
12925
  async pollIsometricTile(tileId, context) {
12576
12926
  try {
12577
- const { image, usage } = await this.client.getIsometricTile(tileId);
12927
+ const { image, usage: usage2 } = await this.client.getIsometricTile(tileId);
12578
12928
  const backgroundJobId = context?.metadata?.backgroundJobId;
12579
- const billed = billedFromUsage(usage) ?? await this.billedForJob(backgroundJobId);
12929
+ const billed = billedFromUsage(usage2) ?? await this.billedForJob(backgroundJobId);
12580
12930
  const file = path16.join(_PixelLabProvider.cacheDir(), `${tileId}.png`);
12581
12931
  writeFileSync(file, Buffer.from(image.base64, "base64"));
12582
12932
  return {
@@ -12953,9 +13303,9 @@ var RetroDiffusionClient = class {
12953
13303
  if (!response.ok) throw new ProviderError("retrodiffusion", `Retro Diffusion download failed (${response.status})`, { status: response.status });
12954
13304
  return Buffer.from(await response.arrayBuffer());
12955
13305
  }
12956
- async call(path63, init = {}) {
13306
+ async call(path65, init = {}) {
12957
13307
  if (!this.token) throw new Error("RD_API_KEY is not set");
12958
- const response = await this.request(`${this.baseUrl}${path63}`, {
13308
+ const response = await this.request(`${this.baseUrl}${path65}`, {
12959
13309
  ...init,
12960
13310
  headers: {
12961
13311
  "Content-Type": "application/json",
@@ -14629,6 +14979,11 @@ async function resolveSpecs(loaded, filter) {
14629
14979
  buildingFloorDescription: generator === "tiles" ? style.buildingFloorDescription : void 0,
14630
14980
  buildingFloor2Description: generator === "tiles" ? style.buildingFloor2Description : void 0,
14631
14981
  buildingWallAngle: generator === "tiles" ? style.buildingWallAngle : void 0,
14982
+ buildingRoofProfile: generator === "tiles" ? style.buildingRoofProfile : void 0,
14983
+ tileElevation: generator === "tiles" ? style.tileElevation : void 0,
14984
+ tileStepSlope: generator === "tiles" ? style.tileStepSlope : void 0,
14985
+ tileBoundaryAmplitude: generator === "tiles" ? style.tileBoundaryAmplitude : void 0,
14986
+ tileBoundarySeed: generator === "tiles" ? style.tileBoundarySeed : void 0,
14632
14987
  outlineMode: generator === "tiles" ? style.outlineMode : void 0,
14633
14988
  terrainLowerDescription: generator === "terrain" ? terrainLowerDescription : void 0,
14634
14989
  terrainUpperDescription: generator === "terrain" ? terrainUpperDescription : void 0,
@@ -15246,6 +15601,9 @@ async function resolveVfxShape(root, assetId, vfx, defaultName) {
15246
15601
  } else if (spriteRef) {
15247
15602
  const image = await optionalRevisionImage(spriteRef, `assets.${assetId}.vfx.sprite`, vfx.description ? "png" : void 0);
15248
15603
  sprite = { file: spriteRef, sha256: image?.hash ?? null, width: image?.width ?? null, height: image?.height ?? null, format: image?.format ?? null };
15604
+ if (image && vfx.description && (vfx.spriteFrames ?? 1) > 1) {
15605
+ vfxArtistFrameSide(image.width, image.height, vfx.spriteFrames, `assets.${assetId}.vfx.sprite`);
15606
+ }
15249
15607
  }
15250
15608
  return {
15251
15609
  ...vfx.preset ? { preset: vfx.preset } : {},
@@ -15255,7 +15613,10 @@ async function resolveVfxShape(root, assetId, vfx, defaultName) {
15255
15613
  ...vfx.fps !== void 0 ? { fps: vfx.fps } : {},
15256
15614
  // The artist caps a name at 80 characters; a long default is cut, not refused.
15257
15615
  name: vfx.name ?? (vfx.description ? defaultName.slice(0, 80) : defaultName),
15258
- ...vfx.description ? { description: vfx.description, artist: vfx.artist ?? "lite" } : {}
15616
+ ...vfx.description ? { description: vfx.description, artist: vfx.artist ?? "lite" } : {},
15617
+ // A strip of one frame is a still: it is sent, priced and hashed as one.
15618
+ ...vfx.spriteFrames !== void 0 && vfx.spriteFrames > 1 ? { spriteFrames: vfx.spriteFrames } : {},
15619
+ ...vfx.spriteFps !== void 0 ? { spriteFps: vfx.spriteFps } : {}
15259
15620
  };
15260
15621
  }
15261
15622
  async function optionalRevisionImage(file, label, requiredFormat) {
@@ -16098,10 +16459,10 @@ function isSha256Hash(value) {
16098
16459
  function parseCache(value) {
16099
16460
  return HashCacheSchema.parse(value);
16100
16461
  }
16101
- async function loadCache(path63) {
16102
- if (!existsSync17(path63)) return { version: 1, hashes: {} };
16462
+ async function loadCache(path65) {
16463
+ if (!existsSync17(path65)) return { version: 1, hashes: {} };
16103
16464
  try {
16104
- const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile12(path63, "utf8")));
16465
+ const parsed = HashCacheSchema.safeParse(JSON.parse(await readFile12(path65, "utf8")));
16105
16466
  if (!parsed.success) return { version: 1, hashes: {} };
16106
16467
  return {
16107
16468
  version: 1,
@@ -16113,18 +16474,18 @@ async function loadCache(path63) {
16113
16474
  return { version: 1, hashes: {} };
16114
16475
  }
16115
16476
  }
16116
- async function saveCache(path63, cache) {
16477
+ async function saveCache(path65, cache) {
16117
16478
  const sorted = {};
16118
16479
  for (const key2 of Object.keys(cache.hashes).sort()) {
16119
16480
  const hash = cache.hashes[key2];
16120
16481
  if (!isSha256Hash(hash)) throw new Error(`Refusing to cache invalid SHA-256 for ${key2}`);
16121
16482
  sorted[key2] = hash;
16122
16483
  }
16123
- await mkdir8(pathModule.dirname(pathModule.resolve(path63)), { recursive: true });
16124
- const tmp = `${path63}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
16484
+ await mkdir8(pathModule.dirname(pathModule.resolve(path65)), { recursive: true });
16485
+ const tmp = `${path65}.${process.pid}.${Math.random().toString(36).slice(2)}.tmp`;
16125
16486
  try {
16126
16487
  await writeFile8(tmp, JSON.stringify({ version: 1, hashes: sorted }, null, 2) + "\n");
16127
- await rename6(tmp, path63);
16488
+ await rename6(tmp, path65);
16128
16489
  } finally {
16129
16490
  await rm5(tmp, { force: true });
16130
16491
  }
@@ -19126,11 +19487,11 @@ function createGallerySkeletonHandlers(opts) {
19126
19487
  }
19127
19488
  };
19128
19489
  }
19129
- function billedAmount(usage) {
19130
- if (!usage || typeof usage !== "object") return null;
19131
- const { type } = usage;
19490
+ function billedAmount(usage2) {
19491
+ if (!usage2 || typeof usage2 !== "object") return null;
19492
+ const { type } = usage2;
19132
19493
  if (type !== "usd" && type !== "generations") return null;
19133
- const amount = usage[type];
19494
+ const amount = usage2[type];
19134
19495
  return typeof amount === "number" && Number.isFinite(amount) ? { unit: type, amount } : null;
19135
19496
  }
19136
19497
  async function createSkeletonAnimation(manifestPath, request) {
@@ -24792,6 +25153,9 @@ async function runVfx(args) {
24792
25153
  if (!args.out) throw new UsageError("vfx needs --out <base>: <base>.png, .gif, .json, and .vfx.json are written");
24793
25154
  if (args.description !== void 0) return runVfxArtist(args, args.out);
24794
25155
  if (args.artist) throw new UsageError("--artist picks who draws a vfx --description; add one");
25156
+ if (args.spriteFrames !== void 0 || args.spriteFps !== void 0) {
25157
+ throw new UsageError("--sprite-frames and --sprite-fps describe the sprite sent to PixelLab's VFX artist; add a --description");
25158
+ }
24795
25159
  const starts = [args.preset, args.recipe, args.effect].filter(Boolean);
24796
25160
  if (starts.length > 1) throw new UsageError("vfx takes one of --preset, --recipe, or --effect, not several");
24797
25161
  if (starts.length === 0 && args.parts.length === 0) {
@@ -24859,12 +25223,19 @@ async function runVfxArtist(args, out) {
24859
25223
  }
24860
25224
  if (args.name && args.name.length > 80) throw new UsageError("vfx --description takes a --name of at most 80 characters");
24861
25225
  const paths = vfxOutputPaths(out);
24862
- const side = args.sprite ? vfxArtistSprite(await readFile33(args.sprite), args.sprite).side : "none";
25226
+ if ((args.spriteFrames !== void 0 || args.spriteFps !== void 0) && !args.sprite) {
25227
+ throw new UsageError("--sprite-frames and --sprite-fps describe a --sprite; add one");
25228
+ }
25229
+ const taken = args.sprite ? vfxArtistSprite(await readFile33(args.sprite), args.sprite, args.spriteFrames ?? 1) : void 0;
25230
+ if (args.spriteFps !== void 0 && !taken?.animated) {
25231
+ throw new UsageError("--sprite-fps is the speed of an animated sprite: a GIF, or a PNG strip with --sprite-frames 2 or more");
25232
+ }
25233
+ const side = taken?.side ?? "none";
24863
25234
  const conversation = args.effect ? await readVfxConversation(paths.provenance, args.effect) : void 0;
24864
- const quote = vfxArtistQuote(artist, args.effect && !args.sprite ? "unknown" : side, Boolean(conversation));
25235
+ const quote = vfxArtistQuote(artist, args.effect && !args.sprite ? "unknown" : side, Boolean(conversation), Boolean(taken?.animated));
24865
25236
  const ceiling = vfxArtistCeiling(quote);
24866
25237
  log(
24867
- ` vfx by PixelLab's ${artist} artist: "${description}"${args.sprite ? ` around ${args.sprite}` : ""} \u2192 ${paths.sheet} (+ .gif, .json, .vfx.json${args.gamePack ? ", -game.zip" : ""})`
25238
+ ` vfx by PixelLab's ${artist} artist: "${description}"${args.sprite ? ` around ${args.sprite}` : ""}${taken?.animated ? taken.image.format === "gif" ? " (an animated GIF)" : ` (a strip of ${args.spriteFrames} frames)` : ""} \u2192 ${paths.sheet} (+ .gif, .json, .vfx.json${args.gamePack ? ", -game.zip" : ""})`
24868
25239
  );
24869
25240
  if (args.effect) {
24870
25241
  log(
@@ -24886,6 +25257,8 @@ async function runVfxArtist(args, out) {
24886
25257
  description,
24887
25258
  artist,
24888
25259
  sprite: args.sprite,
25260
+ spriteFrames: args.spriteFrames,
25261
+ spriteFps: args.spriteFps,
24889
25262
  effect: args.effect,
24890
25263
  conversation,
24891
25264
  name: args.name,
@@ -24908,8 +25281,8 @@ async function runVfxArtist(args, out) {
24908
25281
  for (const file of [res.paths.sheet, res.paths.gif, res.paths.atlas, res.paths.gamePack, res.paths.normals, res.paths.provenance]) {
24909
25282
  if (file) log(` wrote ${file}`);
24910
25283
  }
24911
- const usage = res.usage;
24912
- if (typeof usage?.generations === "number") log(` billed ${usage.generations} generations (quoted ${res.quotedGenerations ?? "?"})`);
25284
+ const usage2 = res.usage;
25285
+ if (typeof usage2?.generations === "number") log(` billed ${usage2.generations} generations (quoted ${res.quotedGenerations ?? "?"})`);
24913
25286
  if (res.editUrl) log(` tweak it with sliders: ${res.editUrl}`);
24914
25287
  log(` change it: pixelkiln vfx --description "<what to change>" --effect ${res.effectId} --out ${out} --force`);
24915
25288
  log(` render it again for free with the workbench: pixelkiln vfx --effect ${res.effectId} --out <base>`);
@@ -25031,7 +25404,7 @@ async function generateMusic(client2, opts) {
25031
25404
  if (!opts.force) {
25032
25405
  for (const file of writes) if (existsSync40(file)) throw new Error(`${file} already exists; pass --force to replace it`);
25033
25406
  }
25034
- const usage = [];
25407
+ const usage2 = [];
25035
25408
  let quoted = null;
25036
25409
  let takes = [];
25037
25410
  let source;
@@ -25054,7 +25427,7 @@ async function generateMusic(client2, opts) {
25054
25427
  const made = await collectTakes(client2, submitted.songs, paths.takes, "song", opts);
25055
25428
  takes = made.takes;
25056
25429
  source = made.finished[0];
25057
- usage.push(await billedUsage(client2, submitted.background_job_id));
25430
+ usage2.push(await billedUsage(client2, submitted.background_job_id));
25058
25431
  }
25059
25432
  let loops = [];
25060
25433
  const snapshot = () => ({
@@ -25065,7 +25438,7 @@ async function generateMusic(client2, opts) {
25065
25438
  instrumental: source?.instrumental ?? instrumental,
25066
25439
  lyrics: source?.lyrics ?? opts.lyrics ?? "",
25067
25440
  quotedGenerations: quoted,
25068
- usage
25441
+ usage: usage2
25069
25442
  });
25070
25443
  const relative = (take) => ({ ...take, file: path50.basename(take.file) });
25071
25444
  const writeRecord = async (result2) => {
@@ -25117,7 +25490,7 @@ async function generateMusic(client2, opts) {
25117
25490
  const made = await collectTakes(client2, submitted.songs, paths.loops, "loop", opts);
25118
25491
  loops = made.takes;
25119
25492
  source ??= made.finished[0];
25120
- usage.push(await billedUsage(client2, submitted.background_job_id));
25493
+ usage2.push(await billedUsage(client2, submitted.background_job_id));
25121
25494
  }
25122
25495
  const result = snapshot();
25123
25496
  await writeRecord(result);
@@ -25616,11 +25989,12 @@ async function runUi(args) {
25616
25989
  }
25617
25990
 
25618
25991
  // src/cli/commands/asset.ts
25992
+ import { readFile as readFile36 } from "fs/promises";
25619
25993
  import path55 from "path";
25620
25994
 
25621
25995
  // src/pixellab-assets.ts
25622
25996
  import { existsSync as existsSync42 } from "fs";
25623
- import { mkdir as mkdir18, readFile as readFile35, writeFile as writeFile23 } from "fs/promises";
25997
+ import { mkdir as mkdir18, readdir as readdir3, readFile as readFile35, stat as stat5, writeFile as writeFile23 } from "fs/promises";
25624
25998
  import path54 from "path";
25625
25999
  var ASSET_KINDS = ["object", "character"];
25626
26000
  var EXPORT_FORMATS = ["zip", "spritesheet", "aseprite", "gif"];
@@ -25679,13 +26053,13 @@ async function expandObject(client2, id, opts) {
25679
26053
  opts.onProgress?.(status);
25680
26054
  if (status === "failed") throw new Error(`PixelLab could not expand object ${id}`);
25681
26055
  if (status !== "expanding") {
25682
- let usage = null;
26056
+ let usage2 = null;
25683
26057
  try {
25684
- usage = (await client2.getBackgroundJob(submitted.background_job_id)).usage ?? null;
26058
+ usage2 = (await client2.getBackgroundJob(submitted.background_job_id)).usage ?? null;
25685
26059
  } catch {
25686
- usage = null;
26060
+ usage2 = null;
25687
26061
  }
25688
- return { objectId: id, jobId: submitted.background_job_id, minGenerations: submitted.min_generations, maxGenerations: submitted.max_generations, status, usage };
26062
+ return { objectId: id, jobId: submitted.background_job_id, minGenerations: submitted.min_generations, maxGenerations: submitted.max_generations, status, usage: usage2 };
25689
26063
  }
25690
26064
  if (Date.now() - started > timeout) {
25691
26065
  throw new Error(`object ${id} is still expanding after ${Math.round(timeout / 1e3)} s; it keeps running upstream, and asset expand --keep or --discard finishes it later`);
@@ -25713,6 +26087,171 @@ async function pullExpansionReview(client2, id, opts) {
25713
26087
  }
25714
26088
  return { dir, existingDirection: review.existing_direction ?? null, files };
25715
26089
  }
26090
+ var TILESET_MODES = ["topdown", "sidescroller"];
26091
+ var IMPORT_TILE_TYPES = ["square_topdown", "isometric", "oblique", "hex", "hex_pointy", "octagon"];
26092
+ var SHEET_TILE_SIZES = [16, 24, 32, 48, 64];
26093
+ var IMPORT_MAX_TILES = 32;
26094
+ function tilesetSheetReadings(width, height) {
26095
+ if (height !== width && height !== width * 2) return [];
26096
+ const readings = [];
26097
+ if (SHEET_TILE_SIZES.includes(width / 4)) readings.push({ tileSize: width / 4, layout: "compact" });
26098
+ if (SHEET_TILE_SIZES.includes(width / 8)) readings.push({ tileSize: width / 8, layout: "native" });
26099
+ return readings;
26100
+ }
26101
+ function chooseTilesetSheetReading(file, width, height, tileSize) {
26102
+ const readings = tilesetSheetReadings(width, height);
26103
+ const describe = (reading) => `${reading.tileSize}px tiles (${reading.layout === "compact" ? "4 wide" : "8 wide"})`;
26104
+ if (readings.length === 0) {
26105
+ throw new Error(
26106
+ `${file} is ${width}x${height}, not a PixelLab tileset sheet: it takes a square sheet 4 or 8 tiles wide (or twice as tall, for a set with transitions) of 16, 24, 32, 48 or 64px tiles`
26107
+ );
26108
+ }
26109
+ if (tileSize === void 0) {
26110
+ if (readings.length > 1) {
26111
+ throw new Error(
26112
+ `${file} is ${width}x${height}, which reads as ${readings.map(describe).join(" or ")}; say which with --size ${readings.map((reading) => reading.tileSize).join(" or --size ")}`
26113
+ );
26114
+ }
26115
+ return readings[0];
26116
+ }
26117
+ const chosen = readings.find((reading) => reading.tileSize === tileSize);
26118
+ if (!chosen) throw new Error(`${file} is ${width}x${height}, which holds ${readings.map(describe).join(" or ")}, not ${tileSize}px tiles`);
26119
+ return chosen;
26120
+ }
26121
+ function readPng(bytes, file) {
26122
+ const metadata = imageMetadata(bytes);
26123
+ if (!metadata || metadata.format !== "png") throw new Error(`${file} is not a PNG`);
26124
+ return metadata;
26125
+ }
26126
+ async function importTilesetFile(client2, file, opts = {}) {
26127
+ const bytes = await readFile35(file);
26128
+ const { width, height } = readPng(bytes, file);
26129
+ const reading = chooseTilesetSheetReading(file, width, height, opts.tileSize);
26130
+ const mode2 = opts.mode ?? "topdown";
26131
+ if (mode2 === "sidescroller" && opts.upperDescription) throw new Error("a sidescroller tileset has one terrain, the platform; drop the upper description");
26132
+ const res = await client2.importTileset({
26133
+ spritesheet: { base64: bytes.toString("base64"), format: "png" },
26134
+ mode: mode2,
26135
+ // PixelLab cannot be told 48, and a 4-wide reading is the one it takes unprompted.
26136
+ tileSize: reading.tileSize === 48 ? void 0 : reading.tileSize,
26137
+ lowerDescription: opts.lowerDescription,
26138
+ upperDescription: opts.upperDescription,
26139
+ transitionDescription: opts.transitionDescription,
26140
+ name: opts.name
26141
+ });
26142
+ return { tilesetId: res.tileset_id, mode: mode2, tileSize: reading.tileSize, layout: reading.layout };
26143
+ }
26144
+ async function pngFilesAt(from) {
26145
+ if (!existsSync42(from)) throw new Error(`${from} does not exist`);
26146
+ if (!(await stat5(from)).isDirectory()) return [from];
26147
+ const names = (await readdir3(from)).filter((name) => /\.png$/i.test(name)).sort((a, b) => a.localeCompare(b, void 0, { numeric: true }));
26148
+ if (names.length === 0) throw new Error(`${from} holds no PNG files`);
26149
+ return names.map((name) => path54.join(from, name));
26150
+ }
26151
+ function importTileHeights(tileType, tileSize) {
26152
+ if (tileType === "square_topdown" || tileType === "octagon") return { min: tileSize, max: tileSize };
26153
+ if (tileType === "oblique") return { min: tileSize, max: tileSize * 2 };
26154
+ return { min: tileSize / 2, max: tileSize * 2 };
26155
+ }
26156
+ async function importTilesFiles(client2, from, opts) {
26157
+ if (!IMPORT_TILE_TYPES.includes(opts.tileType)) throw new Error(`tile type must be one of ${IMPORT_TILE_TYPES.join(", ")}`);
26158
+ if (!Number.isInteger(opts.tileSize) || opts.tileSize < 16 || opts.tileSize > 256) throw new Error("tile size is a whole number from 16 to 256");
26159
+ const files = await pngFilesAt(from);
26160
+ if (files.length > IMPORT_MAX_TILES) throw new Error(`${from} holds ${files.length} PNGs; PixelLab imports at most ${IMPORT_MAX_TILES} tiles in one group`);
26161
+ const heights = importTileHeights(opts.tileType, opts.tileSize);
26162
+ const frames = [];
26163
+ for (const file of files) {
26164
+ const bytes = await readFile35(file);
26165
+ const { width, height } = readPng(bytes, file);
26166
+ if (width !== opts.tileSize || height < heights.min || height > heights.max) {
26167
+ const tall = heights.min === heights.max ? `${heights.min}` : `${heights.min} to ${heights.max}`;
26168
+ throw new Error(`${file} is ${width}x${height}; a ${opts.tileSize}px ${opts.tileType} tile is ${opts.tileSize} wide and ${tall} tall`);
26169
+ }
26170
+ frames.push({ base64: bytes.toString("base64"), format: "png" });
26171
+ }
26172
+ const res = await client2.importTilesPro({ frames, tileType: opts.tileType, tileSize: opts.tileSize, description: opts.description, tileView: opts.tileView });
26173
+ return { tileId: res.tile_id, tiles: files.length, files };
26174
+ }
26175
+ function checkSaveTarget(target) {
26176
+ if (!/^(character:[^:]+:[^:]+(:[^:]+)?|object:[^:]+(:[^:]+){0,2}|gallery:[^:]+|tileset:[^:]+)$/.test(target)) {
26177
+ throw new Error(
26178
+ `--target "${target}" is not a place PixelLab can save to. Use character:<id>:<direction>, object:<id>[:<direction>], either with :<animation group id> added, gallery:<id>, gallery:new, or tileset:<id>`
26179
+ );
26180
+ }
26181
+ }
26182
+ function saveUndoDir(target, now = /* @__PURE__ */ new Date()) {
26183
+ const stamp = now.toISOString().replace(/[-:]/g, "").replace(/\.\d+Z$/, "Z");
26184
+ return path54.resolve("pixelkiln-undo", `${target.replace(/[^a-zA-Z0-9-]+/g, "_")}-${stamp}`);
26185
+ }
26186
+ async function writeUndo(frames, dir) {
26187
+ await mkdir18(dir, { recursive: true });
26188
+ const files = [];
26189
+ for (const [index, frame] of frames.entries()) {
26190
+ const file = path54.join(dir, frames.length === 1 ? "previous.png" : `previous-${String(index).padStart(2, "0")}.png`);
26191
+ await writeFile23(file, Buffer.from(frame.base64, "base64"));
26192
+ files.push(file);
26193
+ }
26194
+ return files;
26195
+ }
26196
+ async function saveToAssetFile(client2, target, from, opts = {}) {
26197
+ checkSaveTarget(target);
26198
+ if ((opts.name || opts.description) && target !== "gallery:new") throw new Error("a name and a description belong to a new gallery image: --target gallery:new");
26199
+ const files = await pngFilesAt(from).catch(async (error) => {
26200
+ if (existsSync42(from) && /\.gif$/i.test(from)) return [from];
26201
+ throw error;
26202
+ });
26203
+ let image;
26204
+ let frames;
26205
+ if (files.length === 1) {
26206
+ const bytes = await readFile35(files[0]);
26207
+ const gif = bytes.subarray(0, 4).toString("ascii") === "GIF8";
26208
+ if (!gif) readPng(bytes, files[0]);
26209
+ image = { base64: bytes.toString("base64"), format: gif ? "gif" : "png" };
26210
+ } else {
26211
+ if (files.length > 128) throw new Error(`${from} holds ${files.length} PNGs; PixelLab takes at most 128 frames`);
26212
+ let size;
26213
+ frames = [];
26214
+ for (const file of files) {
26215
+ const bytes = await readFile35(file);
26216
+ const { width, height } = readPng(bytes, file);
26217
+ if (size && size !== `${width}x${height}`) throw new Error(`${file} is ${width}x${height}, but the frames before it are ${size}; an animation's frames share one size`);
26218
+ size = `${width}x${height}`;
26219
+ frames.push({ base64: bytes.toString("base64"), format: "png" });
26220
+ }
26221
+ }
26222
+ const undoDir = opts.undoDir ? path54.resolve(opts.undoDir) : saveUndoDir(target);
26223
+ let res;
26224
+ try {
26225
+ res = await client2.saveToAsset({ target, image, frames, name: opts.name, description: opts.description });
26226
+ } catch (error) {
26227
+ if (error instanceof PixelLabError && error.body.startsWith("{")) {
26228
+ let previous;
26229
+ try {
26230
+ previous = JSON.parse(error.body).detail?.previous_frames;
26231
+ } catch {
26232
+ previous = void 0;
26233
+ }
26234
+ if (Array.isArray(previous) && previous.length && previous.every((frame) => typeof frame?.base64 === "string")) {
26235
+ const written = await writeUndo(previous, undoDir);
26236
+ throw new Error(`${error.message}. The save failed partway; what was stored before is in ${undoDir} (${written.length} frame(s)). Save it back to ${target} to restore it`);
26237
+ }
26238
+ }
26239
+ throw error;
26240
+ }
26241
+ const undo = res.action === "saved" && res.previous_frames?.length ? await writeUndo(res.previous_frames, undoDir) : [];
26242
+ return {
26243
+ action: res.action,
26244
+ target: res.target,
26245
+ kind: res.kind,
26246
+ width: res.width,
26247
+ height: res.height,
26248
+ frames: res.frame_count,
26249
+ changedPixels: res.changed_pixels,
26250
+ undo,
26251
+ note: res.note ?? null,
26252
+ maps: res.maps ?? null
26253
+ };
26254
+ }
25716
26255
 
25717
26256
  // src/cli/commands/asset.ts
25718
26257
  function loadKeys4(args) {
@@ -25730,7 +26269,16 @@ function requireId2(args) {
25730
26269
  }
25731
26270
  async function runAsset(args) {
25732
26271
  const emit = (value) => log(JSON.stringify({ version: 1, ...value }, null, 2));
26272
+ if (args.subcommand === "import" && (args.kind === "tileset" || args.kind === "tiles")) {
26273
+ await runTileImport(args, emit);
26274
+ return;
26275
+ }
26276
+ if (args.subcommand === "save") {
26277
+ await runSave(args, emit);
26278
+ return;
26279
+ }
25733
26280
  if (args.subcommand === "import") {
26281
+ if (args.kind && args.kind !== "object") throw new UsageError(`asset import takes --kind object (the default), tileset or tiles, got "${args.kind}"`);
25734
26282
  if (!args.from) throw new UsageError("asset import needs --from <png>: your own sprite, at most 256x256");
25735
26283
  if (args.dryRun) {
25736
26284
  log(` would import ${args.from} as a 1-direction object; nothing sent`);
@@ -25851,21 +26399,447 @@ async function runAsset(args) {
25851
26399
  if (args.json) emit({ ...res, format });
25852
26400
  else log(` wrote ${res.out} (${format}, ${res.bytes} bytes, free)`);
25853
26401
  }
26402
+ function tileSizeOf(args) {
26403
+ if (args.size === void 0) return void 0;
26404
+ if (!/^\d+$/.test(args.size.trim())) throw new UsageError(`--size is the tile size in pixels for a tile import, e.g. --size 32; got "${args.size}"`);
26405
+ return Number(args.size);
26406
+ }
26407
+ async function usage(work) {
26408
+ try {
26409
+ return await work();
26410
+ } catch (error) {
26411
+ if (error instanceof Error && !(error instanceof UsageError) && error.name === "Error") throw new UsageError(error.message);
26412
+ throw error;
26413
+ }
26414
+ }
26415
+ async function runTileImport(args, emit) {
26416
+ const tileSize = tileSizeOf(args);
26417
+ if (args.kind === "tileset") {
26418
+ if (!args.from) throw new UsageError("asset import --kind tileset needs --from <png>: a Wang sheet in PixelLab's layout");
26419
+ const mode2 = args.mode ?? "topdown";
26420
+ if (!TILESET_MODES.includes(mode2)) throw new UsageError(`--mode must be ${TILESET_MODES.join(" or ")} for a tileset import, got "${args.mode}"`);
26421
+ if (args.tileType) throw new UsageError("--tile-type belongs to --kind tiles; a tileset is a Wang sheet");
26422
+ const opts2 = { mode: mode2, tileSize, lowerDescription: args.lower, upperDescription: args.upper, transitionDescription: args.transition, name: args.name };
26423
+ if (args.dryRun) {
26424
+ const metadata = imageMetadata(await readFile36(args.from));
26425
+ if (!metadata || metadata.format !== "png") throw new UsageError(`${args.from} is not a PNG`);
26426
+ const reading = await usage(() => chooseTilesetSheetReading(args.from, metadata.width, metadata.height, tileSize));
26427
+ log(` would import ${args.from} as a ${mode2} tileset of ${reading.tileSize}px tiles (${reading.layout === "compact" ? "4 wide" : "8 wide"}); nothing sent`);
26428
+ return;
26429
+ }
26430
+ loadKeys4(args);
26431
+ const client3 = clientFromEnv();
26432
+ const res2 = await usage(() => importTilesetFile(client3, args.from, opts2));
26433
+ if (args.json) emit(res2);
26434
+ else log(` imported ${args.from} as ${mode2} tileset ${res2.tilesetId} (${res2.tileSize}px tiles, ${res2.layout === "compact" ? "4 wide" : "8 wide"}, free)`);
26435
+ return;
26436
+ }
26437
+ if (!args.from) throw new UsageError("asset import --kind tiles needs --from <png or directory>: one PNG per tile, up to 32");
26438
+ if (!args.tileType || !IMPORT_TILE_TYPES.includes(args.tileType)) {
26439
+ throw new UsageError(`asset import --kind tiles needs --tile-type, one of ${IMPORT_TILE_TYPES.join(", ")}`);
26440
+ }
26441
+ if (tileSize === void 0) throw new UsageError("asset import --kind tiles needs --size <pixels>: the tiles' width, 16 to 256");
26442
+ if (args.lower || args.upper || args.transition) throw new UsageError("--lower, --upper and --transition describe a tileset; describe tiles with --description");
26443
+ const opts = { tileType: args.tileType, tileSize, description: args.description };
26444
+ if (args.dryRun) {
26445
+ const res2 = await usage(() => importTilesFiles({ importTilesPro: async () => ({ tile_id: "dry-run", status: "completed" }) }, args.from, opts));
26446
+ log(` would import ${res2.tiles} ${args.tileType} tile(s) of ${tileSize}px from ${args.from} as one group; nothing sent`);
26447
+ return;
26448
+ }
26449
+ loadKeys4(args);
26450
+ const client2 = clientFromEnv();
26451
+ const res = await usage(() => importTilesFiles(client2, args.from, opts));
26452
+ if (args.json) emit(res);
26453
+ else log(` imported ${res.tiles} tile(s) from ${args.from} as tile group ${res.tileId} (${args.tileType}, ${tileSize}px, free)`);
26454
+ }
26455
+ async function runSave(args, emit) {
26456
+ const target = args.saveTarget;
26457
+ if (!target) {
26458
+ throw new UsageError("asset save needs --target: character:<id>:<direction>, object:<id>[:<direction>], gallery:<id>, gallery:new, or tileset:<id>");
26459
+ }
26460
+ if (!args.from) throw new UsageError("asset save needs --from: a PNG, an animated GIF, or a directory of PNG frames");
26461
+ await usage(() => checkSaveTarget(target));
26462
+ const adding = target === "gallery:new";
26463
+ const undoDir = args.out ? path55.resolve(args.out) : saveUndoDir(target);
26464
+ if (adding) log(` add ${args.from} to your PixelLab gallery as a new image (free)`);
26465
+ else {
26466
+ log(` save ${args.from} over ${target} on PixelLab (free)`);
26467
+ log(` it must match what is stored in size and frame count; what it replaces is written to ${undoDir}`);
26468
+ }
26469
+ if (args.dryRun) {
26470
+ log(" dry run: nothing sent");
26471
+ return;
26472
+ }
26473
+ if (!adding && !await confirm(` Replace the stored pixels of ${target}?`, args.yes)) return;
26474
+ loadKeys4(args);
26475
+ const client2 = clientFromEnv();
26476
+ const res = await usage(() => saveToAssetFile(client2, target, args.from, { name: args.name, description: args.description, undoDir }));
26477
+ if (args.json) {
26478
+ emit({ ...res });
26479
+ return;
26480
+ }
26481
+ if (res.action === "unchanged") log(` ${res.target}: no pixel differed, nothing written`);
26482
+ else if (res.action === "added") log(` added as ${res.target} (${res.width}x${res.height})`);
26483
+ else {
26484
+ log(` ${res.target}: ${res.kind} saved, ${res.width}x${res.height}, ${res.frames} frame(s), ${res.changedPixels} pixel(s) changed`);
26485
+ for (const file of res.undo) log(` kept the old pixels: ${file}`);
26486
+ if (res.undo.length) log(` undo: pixelkiln asset save --target ${res.target} --from ${res.undo.length === 1 ? res.undo[0] : path55.dirname(res.undo[0])} --yes`);
26487
+ }
26488
+ if (res.note) log(` ${res.note}`);
26489
+ if (res.maps) log(` ${res.maps}`);
26490
+ }
25854
26491
 
25855
- // src/cli/commands/quality.ts
26492
+ // src/cli/commands/talk.ts
26493
+ import { existsSync as existsSync44 } from "fs";
26494
+ import { mkdir as mkdir20, readFile as readFile38, writeFile as writeFile25 } from "fs/promises";
25856
26495
  import path57 from "path";
25857
- import { readFile as readFile37 } from "fs/promises";
25858
26496
 
25859
- // src/pipeline/quality-regression.ts
25860
- import path56 from "path";
26497
+ // src/pixellab-talk.ts
25861
26498
  import { existsSync as existsSync43 } from "fs";
25862
- import { readFile as readFile36 } from "fs/promises";
26499
+ import { mkdir as mkdir19, readFile as readFile37, writeFile as writeFile24 } from "fs/promises";
26500
+ import path56 from "path";
26501
+ var TALK_MOODS = ["neutral", "happy", "angry", "sad", "surprised"];
26502
+ var VISEME_COUNTS = [3, 5, 7, 12];
26503
+ var VISEME_ENGINES = ["v3", "pixminimax"];
26504
+ var PORTRAIT_MAX_SIDE = 256;
26505
+ var TALK_MAX_TEXT = 500;
26506
+ function visemeCost(engine, side, count) {
26507
+ const forSeven = engine === "pixminimax" ? 3 : side === "unknown" || side > 128 ? 24 : side > 64 ? 6 : 3;
26508
+ return Math.ceil(forSeven * count / 7);
26509
+ }
26510
+ function talkOutputPaths(out) {
26511
+ const base = path56.resolve(out.replace(/\.(png|json)$/i, "").replace(/\.(talk|visemes)$/i, ""));
26512
+ return { strip: `${base}.visemes.png`, record: `${base}.talk.json` };
26513
+ }
26514
+ function readPortrait(bytes, label) {
26515
+ const metadata = imageMetadata(bytes);
26516
+ if (metadata?.format !== "png") throw new Error(`${label} is not a PNG`);
26517
+ const side = Math.max(metadata.width, metadata.height);
26518
+ if (side > PORTRAIT_MAX_SIDE) {
26519
+ throw new Error(`${label} is ${metadata.width}x${metadata.height}; a portrait is at most ${PORTRAIT_MAX_SIDE}x${PORTRAIT_MAX_SIDE} (crop it; never rescale pixel art)`);
26520
+ }
26521
+ return { base64: bytes.toString("base64"), side };
26522
+ }
26523
+ function joinStrip(cells) {
26524
+ const decoded = cells.map((cell) => decodePng(cell));
26525
+ const { width, height } = decoded[0];
26526
+ if (decoded.some((cell) => cell.width !== width || cell.height !== height)) throw new Error("PixelLab's mouth positions came back in different sizes");
26527
+ const out = Buffer.alloc(width * decoded.length * height * 4);
26528
+ for (const [index, cell] of decoded.entries()) {
26529
+ for (let y = 0; y < height; y++) {
26530
+ Buffer.from(cell.pixels.buffer, cell.pixels.byteOffset + y * width * 4, width * 4).copy(out, (y * width * decoded.length + index * width) * 4);
26531
+ }
26532
+ }
26533
+ return { png: encodeRgbaPng(width * decoded.length, height, out), width, height };
26534
+ }
26535
+ function cutStrip(strip, columns, cell, row = 0) {
26536
+ const sheet = decodePng(strip);
26537
+ if (sheet.width !== cell.width * columns || sheet.height < cell.height * (row + 1)) {
26538
+ throw new Error(`the mouth-position strip is ${sheet.width}x${sheet.height}, not ${columns} cells of ${cell.width}x${cell.height}; it was changed after it was made`);
26539
+ }
26540
+ const pixels = Buffer.from(sheet.pixels.buffer, sheet.pixels.byteOffset, sheet.pixels.byteLength);
26541
+ return Array.from({ length: columns }, (_, index) => {
26542
+ const out = Buffer.alloc(cell.width * cell.height * 4);
26543
+ for (let y = 0; y < cell.height; y++) {
26544
+ pixels.copy(out, y * cell.width * 4, ((row * cell.height + y) * sheet.width + index * cell.width) * 4, ((row * cell.height + y) * sheet.width + (index + 1) * cell.width) * 4);
26545
+ }
26546
+ return encodeRgbaPng(cell.width, cell.height, out);
26547
+ });
26548
+ }
26549
+ async function makeVisemes(client2, opts) {
26550
+ if (Boolean(opts.portrait) === Boolean(opts.characterId)) throw new Error("give a portrait file or a character id, not both");
26551
+ const paths = talkOutputPaths(opts.out);
26552
+ if (!opts.force) {
26553
+ for (const file of [paths.strip, paths.record]) if (existsSync43(file)) throw new Error(`${file} already exists; pass --force to replace it`);
26554
+ }
26555
+ const progress2 = opts.onProgress ?? (() => {
26556
+ });
26557
+ const sleep3 = opts.sleep ?? ((ms) => new Promise((resolve) => setTimeout(resolve, ms)));
26558
+ const interval = opts.intervalMs ?? 8e3;
26559
+ const timeout = opts.timeoutMs ?? 10 * 6e4;
26560
+ const portrait = opts.portrait ? readPortrait(await readFile37(opts.portrait), opts.portrait) : void 0;
26561
+ const engine = opts.engine ?? "v3";
26562
+ const visemeCount = opts.visemeCount ?? 7;
26563
+ const submitted = await client2.createVocalAnimation({
26564
+ portrait: portrait ? { base64: portrait.base64, format: "png" } : void 0,
26565
+ characterId: opts.characterId,
26566
+ mood: opts.mood,
26567
+ visemeCount,
26568
+ engine,
26569
+ seed: opts.seed
26570
+ });
26571
+ const jobId = submitted.background_job_id;
26572
+ progress2(`submitted job ${jobId}`);
26573
+ const started = Date.now();
26574
+ let job;
26575
+ for (; ; ) {
26576
+ job = await client2.getVocalAnimation(jobId);
26577
+ if (job.status === "completed") break;
26578
+ if (job.status === "failed") throw new Error(`PixelLab vocal-animation job ${jobId} failed upstream`);
26579
+ if (Date.now() - started > timeout) {
26580
+ throw new Error(`PixelLab vocal-animation job ${jobId} is still ${job.status} after ${Math.round(timeout / 1e3)} s; it keeps running upstream, but this command has stopped waiting`);
26581
+ }
26582
+ progress2(`${job.completed_visemes.length} of ${visemeCount} mouth positions`);
26583
+ await sleep3(interval);
26584
+ }
26585
+ let strip;
26586
+ let visemeOrder;
26587
+ let cell;
26588
+ if (job.visemes) {
26589
+ visemeOrder = job.completed_visemes.filter((id) => job.visemes[id]);
26590
+ if (visemeOrder.length !== Object.keys(job.visemes).length) visemeOrder = Object.keys(job.visemes);
26591
+ const joined = joinStrip(visemeOrder.map((id) => Buffer.from(job.visemes[id].base64, "base64")));
26592
+ strip = joined.png;
26593
+ cell = { width: joined.width, height: joined.height };
26594
+ } else if (job.grid_url && job.viseme_order?.length) {
26595
+ strip = await client2.download(job.grid_url);
26596
+ visemeOrder = job.viseme_order;
26597
+ const sheet = imageMetadata(strip);
26598
+ if (!sheet) throw new Error(`PixelLab's mouth-position sheet for job ${jobId} is not a readable image`);
26599
+ const rows = Math.max(1, job.moods_on_character?.length ?? 1);
26600
+ cell = { width: sheet.width / visemeOrder.length, height: sheet.height / rows };
26601
+ } else {
26602
+ throw new Error(`PixelLab vocal-animation job ${jobId} finished with no mouth positions and no spritesheet`);
26603
+ }
26604
+ const usage2 = (await client2.getBackgroundJob(jobId).catch(() => null))?.usage ?? job.usage ?? null;
26605
+ await mkdir19(path56.dirname(paths.strip), { recursive: true });
26606
+ await writeFile24(paths.strip, strip);
26607
+ const record = {
26608
+ version: 1,
26609
+ provider: "pixellab",
26610
+ tool: "vocal-animation",
26611
+ engine,
26612
+ mood: job.mood ?? opts.mood ?? "neutral",
26613
+ visemeCount,
26614
+ visemeOrder,
26615
+ cell,
26616
+ strip: path56.basename(paths.strip),
26617
+ source: opts.portrait ? { portrait: path56.relative(path56.dirname(paths.record), path56.resolve(opts.portrait)).split(path56.sep).join("/") } : { characterId: opts.characterId },
26618
+ ...job.moods_on_character ? { moodsOnCharacter: job.moods_on_character } : {},
26619
+ jobId,
26620
+ usage: usage2,
26621
+ createdAt: (/* @__PURE__ */ new Date()).toISOString()
26622
+ };
26623
+ await writeFile24(paths.record, `${JSON.stringify(record, null, 2)}
26624
+ `);
26625
+ return { ...record, paths };
26626
+ }
26627
+ async function readTalkRecord(file) {
26628
+ let record;
26629
+ try {
26630
+ record = JSON.parse(await readFile37(file, "utf8"));
26631
+ } catch (error) {
26632
+ throw new Error(`${file} is not a readable .talk.json record: ${error instanceof Error ? error.message : String(error)}`);
26633
+ }
26634
+ if (record?.tool !== "vocal-animation" || !Array.isArray(record.visemeOrder) || !record.cell || !record.strip) {
26635
+ throw new Error(`${file} is not a .talk.json record from pixelkiln talk visemes`);
26636
+ }
26637
+ const stripFile = path56.resolve(path56.dirname(path56.resolve(file)), record.strip);
26638
+ if (!existsSync43(stripFile)) throw new Error(`${file} names ${record.strip}, which is missing beside it`);
26639
+ const row = Math.max(0, record.moodsOnCharacter?.indexOf(record.mood) ?? 0);
26640
+ const cells = cutStrip(await readFile37(stripFile), record.visemeOrder.length, record.cell, row);
26641
+ const visemes = Object.fromEntries(record.visemeOrder.map((id, index) => [id, { base64: cells[index].toString("base64"), format: "png" }]));
26642
+ return { record, visemes };
26643
+ }
26644
+ function checkText(text) {
26645
+ const line = text.trim();
26646
+ if (!line) throw new Error("the line of dialogue is empty");
26647
+ if (line.length > TALK_MAX_TEXT) throw new Error(`the line is ${line.length} characters; PixelLab lip-syncs at most ${TALK_MAX_TEXT}. Split it into shorter lines`);
26648
+ return line;
26649
+ }
26650
+ async function makeTalkingGif(client2, text, source, opts) {
26651
+ if (Boolean(source.record) === Boolean(source.characterId)) throw new Error("give a .talk.json record or a character id, not both");
26652
+ if (source.record && source.mood) throw new Error("a record holds one expression; --mood picks among a character's stored ones");
26653
+ const out = path56.extname(opts.out) ? path56.resolve(opts.out) : path56.resolve(`${opts.out}.gif`);
26654
+ if (existsSync43(out) && !opts.force) throw new Error(`${out} already exists; pass --force to replace it`);
26655
+ const line = checkText(text);
26656
+ const visemes = source.record ? (await readTalkRecord(source.record)).visemes : void 0;
26657
+ const res = await client2.createTalkingGif({ text: line, visemes, characterId: source.characterId, mood: source.mood, frameMs: opts.frameMs, holdMs: opts.holdMs });
26658
+ const bytes = Buffer.from(res.gif_base64, "base64");
26659
+ if (bytes.subarray(0, 4).toString("ascii") !== "GIF8") throw new Error(`PixelLab's talking GIF was not a GIF (${bytes.length} bytes)`);
26660
+ await mkdir19(path56.dirname(out), { recursive: true });
26661
+ await writeFile24(out, bytes);
26662
+ return { out, frames: res.frames, durationMs: res.duration_ms, frameMs: res.frame_ms, holdMs: res.hold_ms, width: res.width, height: res.height, bytes: bytes.length };
26663
+ }
26664
+ async function planLipSync(client2, text, source, opts = {}) {
26665
+ const given = [source.record, source.characterId, source.visemeCount].filter((value) => value !== void 0).length;
26666
+ if (given !== 1) throw new Error("give one of a .talk.json record, a character id, or a mouth-position count");
26667
+ const line = checkText(text);
26668
+ const record = source.record ? (await readTalkRecord(source.record)).record : void 0;
26669
+ const res = await client2.getLipSync({
26670
+ text: line,
26671
+ characterId: source.characterId,
26672
+ mood: source.characterId ? source.mood : void 0,
26673
+ visemeCount: record?.visemeCount ?? source.visemeCount,
26674
+ frameMs: opts.frameMs,
26675
+ holdMs: opts.holdMs
26676
+ });
26677
+ const column = record ? (id, fallback) => record.visemeOrder.includes(id) ? record.visemeOrder.indexOf(id) : fallback : (_id, fallback) => fallback;
26678
+ return {
26679
+ version: 1,
26680
+ text: res.text,
26681
+ totalMs: res.total_ms,
26682
+ visemeOrder: record?.visemeOrder ?? res.viseme_order,
26683
+ frames: res.frames.map((frame) => ({ viseme: frame.viseme, column: column(frame.viseme, frame.column), durationMs: frame.duration_ms, textOffset: frame.text_offset })),
26684
+ mood: record?.mood ?? res.mood ?? null,
26685
+ strip: record ? record.strip : res.grid_url ?? null,
26686
+ row: record ? Math.max(0, record.moodsOnCharacter?.indexOf(record.mood) ?? 0) : res.row ?? 0,
26687
+ cell: record?.cell ?? null
26688
+ };
26689
+ }
26690
+
26691
+ // src/cli/commands/talk.ts
26692
+ function loadKeys5(args) {
26693
+ loadEnvFiles(path57.dirname(path57.resolve(args.manifest)));
26694
+ loadEnvFiles(process.cwd());
26695
+ }
26696
+ function moodOf(args) {
26697
+ if (args.mood === void 0) return void 0;
26698
+ if (!TALK_MOODS.includes(args.mood)) throw new UsageError(`--mood must be one of ${TALK_MOODS.join(", ")}, got "${args.mood}"`);
26699
+ return args.mood;
26700
+ }
26701
+ function countOf(args) {
26702
+ if (args.visemes !== void 0 && !VISEME_COUNTS.includes(args.visemes)) {
26703
+ throw new UsageError(`--visemes must be ${VISEME_COUNTS.join(", ")}, got ${args.visemes}`);
26704
+ }
26705
+ return args.visemes;
26706
+ }
26707
+ function textOf(args) {
26708
+ const text = args.text?.trim();
26709
+ if (!text) throw new UsageError(`talk ${args.subcommand} needs --text "<the line of dialogue>"`);
26710
+ if (text.length > TALK_MAX_TEXT) throw new UsageError(`--text is ${text.length} characters; PixelLab lip-syncs at most ${TALK_MAX_TEXT}. Split it into shorter lines`);
26711
+ return text;
26712
+ }
26713
+ function sourceOf(args) {
26714
+ if (args.from && args.id) throw new UsageError("pass --from <record.talk.json> or --id <character id>, not both");
26715
+ if (args.from && !existsSync44(args.from)) throw new UsageError(`${args.from} does not exist; --from is the .talk.json record talk visemes wrote`);
26716
+ return { record: args.from, characterId: args.id };
26717
+ }
26718
+ async function runVisemes(args) {
26719
+ if (Boolean(args.from) === Boolean(args.id)) {
26720
+ throw new UsageError("talk visemes needs --from <portrait.png> (nothing is stored on PixelLab) or --id <character id> (saved onto the character), one of them");
26721
+ }
26722
+ if (!args.out) throw new UsageError("talk visemes needs --out <base>: it writes <base>.visemes.png and <base>.talk.json");
26723
+ if (args.text) throw new UsageError("talk visemes draws the mouth positions; lip-sync a line to them with talk gif --text");
26724
+ const engine = args.engine ?? "v3";
26725
+ if (!VISEME_ENGINES.includes(engine)) throw new UsageError(`--engine must be ${VISEME_ENGINES.join(" or ")}, got "${args.engine}"`);
26726
+ const mood = moodOf(args);
26727
+ const count = countOf(args) ?? 7;
26728
+ const paths = talkOutputPaths(args.out);
26729
+ let side = "unknown";
26730
+ if (args.from) {
26731
+ if (!existsSync44(args.from)) throw new UsageError(`${args.from} does not exist`);
26732
+ try {
26733
+ side = readPortrait(await readFile38(args.from), args.from).side;
26734
+ } catch (error) {
26735
+ throw new UsageError(error instanceof Error ? error.message : String(error));
26736
+ }
26737
+ }
26738
+ const cost = visemeCost(engine, side, count);
26739
+ log(
26740
+ ` ${count} mouth positions, ${mood ?? "neutral"}, by ${engine}, from ${args.from ?? `character ${args.id}'s stored portrait`} \u2192 ${paths.strip} (+ .talk.json)`
26741
+ );
26742
+ log(
26743
+ ` cost: about ${cost} generations` + (count === 7 ? " (PixelLab's published price)" : " (scaled from PixelLab's price for 7 positions; an estimate)") + (side === "unknown" && engine === "v3" ? "; priced as a 256px portrait, since the stored one's size is not known here" : "")
26744
+ );
26745
+ if (args.id) log(" the set is saved onto the character; every expression on one character must use the same --visemes");
26746
+ if (args.budget !== void 0 && args.budget < cost) throw new Error(`--budget ${args.budget} is below the ${cost} generations these mouth positions can cost`);
26747
+ if (args.dryRun) {
26748
+ log(" dry run: nothing sent");
26749
+ return;
26750
+ }
26751
+ if (!await confirm(` Spend about ${cost} generations on these mouth positions?`, args.yes)) return;
26752
+ loadKeys5(args);
26753
+ let last = "";
26754
+ const res = await makeVisemes(clientFromEnv(), {
26755
+ portrait: args.from,
26756
+ characterId: args.id,
26757
+ mood,
26758
+ visemeCount: count,
26759
+ engine,
26760
+ seed: args.seed,
26761
+ out: args.out,
26762
+ force: args.force,
26763
+ onProgress: (status) => {
26764
+ if (status !== last) log(` ${status}\u2026`);
26765
+ last = status;
26766
+ }
26767
+ });
26768
+ if (args.json) {
26769
+ log(JSON.stringify(res, null, 2));
26770
+ return;
26771
+ }
26772
+ log(` wrote ${res.paths.strip} (${res.visemeOrder.length} cells of ${res.cell.width}x${res.cell.height}: ${res.visemeOrder.join(", ")})`);
26773
+ log(` wrote ${res.paths.record}`);
26774
+ const usage2 = res.usage;
26775
+ if (typeof usage2?.generations === "number") log(` billed ${usage2.generations} generations`);
26776
+ log(` now free: pixelkiln talk gif --from ${res.paths.record} --text "<a line>" --out <file>`);
26777
+ }
26778
+ async function runGif(args) {
26779
+ const text = textOf(args);
26780
+ const source = sourceOf(args);
26781
+ if (!source.record && !source.characterId) throw new UsageError("talk gif needs --from <record.talk.json> or --id <character id>");
26782
+ if (!args.out) throw new UsageError("talk gif needs --out <file.gif>");
26783
+ if (args.visemes !== void 0) throw new UsageError("--visemes belongs to talk visemes and talk plan; a GIF uses the positions already made");
26784
+ const mood = moodOf(args);
26785
+ if (source.record && mood) throw new UsageError("a record holds one expression; --mood picks among a character's stored ones (--id)");
26786
+ if (args.dryRun) {
26787
+ log(` would lip-sync ${text.length} characters to a GIF (free); nothing sent`);
26788
+ return;
26789
+ }
26790
+ loadKeys5(args);
26791
+ const res = await makeTalkingGif(clientFromEnv(), text, { ...source, mood }, { out: args.out, frameMs: args.frameMs, holdMs: args.holdMs, force: args.force });
26792
+ if (args.json) log(JSON.stringify({ version: 1, ...res }, null, 2));
26793
+ else log(` wrote ${res.out} (${res.width}x${res.height}, ${res.frames} frames, ${(res.durationMs / 1e3).toFixed(2)} s, ${res.frameMs} ms a frame, free)`);
26794
+ }
26795
+ async function runPlan2(args) {
26796
+ const text = textOf(args);
26797
+ const source = sourceOf(args);
26798
+ const count = countOf(args);
26799
+ if ([source.record, source.characterId, count].filter((value) => value !== void 0).length !== 1) {
26800
+ throw new UsageError("talk plan needs one of --from <record.talk.json>, --id <character id>, or --visemes <n> for a bare preset");
26801
+ }
26802
+ const mood = moodOf(args);
26803
+ if (mood && !source.characterId) throw new UsageError("--mood picks among a character's stored expressions (--id)");
26804
+ if (args.dryRun) {
26805
+ log(` would plan ${text.length} characters of lip-sync (free); nothing sent`);
26806
+ return;
26807
+ }
26808
+ loadKeys5(args);
26809
+ const plan = await planLipSync(clientFromEnv(), text, { ...source, mood, visemeCount: count }, { frameMs: args.frameMs, holdMs: args.holdMs });
26810
+ const json = `${JSON.stringify(plan, null, 2)}
26811
+ `;
26812
+ if (!args.out) {
26813
+ log(json.trimEnd());
26814
+ return;
26815
+ }
26816
+ const out = path57.extname(args.out) ? path57.resolve(args.out) : path57.resolve(`${args.out}.json`);
26817
+ if (existsSync44(out) && !args.force) throw new Error(`${out} already exists; pass --force to replace it`);
26818
+ await mkdir20(path57.dirname(out), { recursive: true });
26819
+ await writeFile25(out, json);
26820
+ if (args.json) log(json.trimEnd());
26821
+ else log(` wrote ${out} (${plan.frames.length} frames, ${(plan.totalMs / 1e3).toFixed(2)} s, free)`);
26822
+ }
26823
+ async function runTalk(args) {
26824
+ if (args.subcommand === "visemes") return runVisemes(args);
26825
+ if (args.subcommand === "gif") return runGif(args);
26826
+ return runPlan2(args);
26827
+ }
26828
+
26829
+ // src/cli/commands/quality.ts
26830
+ import path59 from "path";
26831
+ import { readFile as readFile40 } from "fs/promises";
26832
+
26833
+ // src/pipeline/quality-regression.ts
26834
+ import path58 from "path";
26835
+ import { existsSync as existsSync45 } from "fs";
26836
+ import { readFile as readFile39 } from "fs/promises";
25863
26837
  import { z as z13 } from "zod";
25864
26838
  var SHA256_RE = /^[0-9a-f]{64}$/;
25865
26839
  var HEX_RE = /^#[0-9a-f]{6}$/;
25866
26840
  var MAX_REDMEAN_DISTANCE = 765;
25867
26841
  var QualityPathSchema = z13.string().min(1).refine(
25868
- (value) => !path56.posix.isAbsolute(value) && !value.includes("\\"),
26842
+ (value) => !path58.posix.isAbsolute(value) && !value.includes("\\"),
25869
26843
  "expected a portable relative path"
25870
26844
  );
25871
26845
  var DEFAULT_QUALITY_TOLERANCES = {
@@ -26012,10 +26986,10 @@ function measureDecodedImageQuality(png, digest2) {
26012
26986
  };
26013
26987
  }
26014
26988
  async function measureImageQuality(file) {
26015
- const absolute = path56.resolve(file);
26989
+ const absolute = path58.resolve(file);
26016
26990
  let bytes;
26017
26991
  try {
26018
- bytes = await readFile36(absolute);
26992
+ bytes = await readFile39(absolute);
26019
26993
  } catch (error) {
26020
26994
  throw new Error(`Cannot read quality image ${absolute}: ${message4(error)}`, { cause: error });
26021
26995
  }
@@ -26034,11 +27008,11 @@ function resolveQualityInputs(raw, inputsFilePath) {
26034
27008
  }
26035
27009
  const ids = parsed.data.map((entry) => entry.id);
26036
27010
  if (new Set(ids).size !== ids.length) throw new Error("--inputs contains a duplicate quality case id.");
26037
- const root = path56.dirname(path56.resolve(inputsFilePath));
27011
+ const root = path58.dirname(path58.resolve(inputsFilePath));
26038
27012
  return parsed.data.map((entry) => ({
26039
27013
  id: entry.id,
26040
- file: path56.resolve(root, entry.path),
26041
- ...entry.record ? { record: path56.resolve(root, entry.record) } : {},
27014
+ file: path58.resolve(root, entry.path),
27015
+ ...entry.record ? { record: path58.resolve(root, entry.record) } : {},
26042
27016
  tolerances: QualityToleranceSchema.parse({
26043
27017
  ...DEFAULT_QUALITY_TOLERANCES,
26044
27018
  ...entry.tolerances
@@ -26046,7 +27020,7 @@ function resolveQualityInputs(raw, inputsFilePath) {
26046
27020
  }));
26047
27021
  }
26048
27022
  function portableRelative2(from, to) {
26049
- return path56.relative(from, path56.resolve(to)).split(path56.sep).join("/") || ".";
27023
+ return path58.relative(from, path58.resolve(to)).split(path58.sep).join("/") || ".";
26050
27024
  }
26051
27025
  async function verifyRecordForImage(recordPath, imagePath) {
26052
27026
  const verification = await verifyArtifactBundle(recordPath);
@@ -26061,20 +27035,20 @@ async function verifyRecordForImage(recordPath, imagePath) {
26061
27035
  if (record.kind !== "refine" || options === null || typeof options !== "object" || options.schema !== "pixelkiln-quality") {
26062
27036
  throw new Error(`Quality record ${recordPath} is not a PixelKiln refinement record.`);
26063
27037
  }
26064
- const outputs = record.outputs.map((output) => path56.resolve(path56.dirname(recordPath), output.path));
26065
- if (!outputs.includes(path56.resolve(imagePath))) {
27038
+ const outputs = record.outputs.map((output) => path58.resolve(path58.dirname(recordPath), output.path));
27039
+ if (!outputs.includes(path58.resolve(imagePath))) {
26066
27040
  throw new Error(`Quality record ${recordPath} does not own ${imagePath}.`);
26067
27041
  }
26068
27042
  }
26069
27043
  async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
26070
27044
  if (!inputs.length) throw new Error("Cannot snapshot an empty quality baseline.");
26071
- const absolute = path56.resolve(baselinePath);
27045
+ const absolute = path58.resolve(baselinePath);
26072
27046
  for (const input of inputs) {
26073
- if (path56.resolve(input.file) === absolute || input.record && path56.resolve(input.record) === absolute) {
27047
+ if (path58.resolve(input.file) === absolute || input.record && path58.resolve(input.record) === absolute) {
26074
27048
  throw new Error(`Quality baseline output would overwrite an input: ${absolute}.`);
26075
27049
  }
26076
27050
  }
26077
- const root = path56.dirname(absolute);
27051
+ const root = path58.dirname(absolute);
26078
27052
  const cases = [];
26079
27053
  for (const input of [...inputs].sort((a, b) => a.id.localeCompare(b.id))) {
26080
27054
  const expected = await measureImageQuality(input.file);
@@ -26101,8 +27075,8 @@ async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
26101
27075
  cases
26102
27076
  });
26103
27077
  const data = Buffer.from(JSON.stringify(baseline, null, 2) + "\n");
26104
- if (existsSync43(absolute) && !options.force) {
26105
- const current = await readFile36(absolute);
27078
+ if (existsSync45(absolute) && !options.force) {
27079
+ const current = await readFile39(absolute);
26106
27080
  if (!current.equals(data)) {
26107
27081
  throw new OverwriteRefusedError(
26108
27082
  `Quality baseline already exists with different content: ${absolute}. Pass --force to replace it.`,
@@ -26114,13 +27088,13 @@ async function snapshotQualityBaseline(inputs, baselinePath, options = {}) {
26114
27088
  return { baseline, path: absolute, changed: result.changed.length > 0 };
26115
27089
  }
26116
27090
  async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
26117
- const absolute = path56.resolve(baselinePath);
26118
- if (!existsSync43(absolute)) {
27091
+ const absolute = path58.resolve(baselinePath);
27092
+ if (!existsSync45(absolute)) {
26119
27093
  throw new Error(`quality snapshot --only updates an existing baseline; ${absolute} does not exist. Run a full snapshot first.`);
26120
27094
  }
26121
27095
  let raw;
26122
27096
  try {
26123
- raw = JSON.parse(await readFile36(absolute, "utf8"));
27097
+ raw = JSON.parse(await readFile39(absolute, "utf8"));
26124
27098
  } catch (error) {
26125
27099
  throw new Error(`Could not read quality baseline ${absolute}: ${message4(error)}`, { cause: error });
26126
27100
  }
@@ -26130,12 +27104,12 @@ async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
26130
27104
  if (unknown.length) {
26131
27105
  throw new Error(`--only names ${unknown.join(", ")}, which the quality inputs do not list. Known: ${[...byId.keys()].sort().join(", ")}`);
26132
27106
  }
26133
- const root = path56.dirname(absolute);
27107
+ const root = path58.dirname(absolute);
26134
27108
  const cases = [...raw.cases];
26135
27109
  const report = [];
26136
27110
  for (const id of only) {
26137
27111
  const input = byId.get(id);
26138
- if (path56.resolve(input.file) === absolute || input.record && path56.resolve(input.record) === absolute) {
27112
+ if (path58.resolve(input.file) === absolute || input.record && path58.resolve(input.record) === absolute) {
26139
27113
  throw new Error(`Quality baseline output would overwrite an input: ${absolute}.`);
26140
27114
  }
26141
27115
  const expected = await measureImageQuality(input.file);
@@ -26165,16 +27139,16 @@ async function snapshotQualityCases(inputs, baselinePath, only, options = {}) {
26165
27139
  }
26166
27140
  const baseline = QualityBaselineSchema.parse({ ...raw, cases });
26167
27141
  const data = Buffer.from(JSON.stringify({ ...raw, cases }, null, 2) + "\n");
26168
- const current = await readFile36(absolute);
27142
+ const current = await readFile39(absolute);
26169
27143
  const changed = !current.equals(data);
26170
27144
  if (changed && !options.dryRun) await writeArtifactBundle([{ path: absolute, data }]);
26171
27145
  return { baseline, path: absolute, changed, cases: report };
26172
27146
  }
26173
27147
  async function readQualityBaseline(baselinePath) {
26174
- const absolute = path56.resolve(baselinePath);
27148
+ const absolute = path58.resolve(baselinePath);
26175
27149
  let raw;
26176
27150
  try {
26177
- raw = JSON.parse(await readFile36(absolute, "utf8"));
27151
+ raw = JSON.parse(await readFile39(absolute, "utf8"));
26178
27152
  } catch (error) {
26179
27153
  throw new Error(`Could not read quality baseline ${absolute}: ${message4(error)}`, { cause: error });
26180
27154
  }
@@ -26196,7 +27170,7 @@ async function readQualityBaseline(baselinePath) {
26196
27170
  throw new Error(
26197
27171
  `Invalid quality baseline ${absolute}:
26198
27172
  ` + parsed.error.issues.map((issue) => ` ${where(issue.path)}: ${issue.message}`).join("\n") + (missing.length ? `
26199
- Entries missing fields: re-measure them with \`pixelkiln quality snapshot --inputs <inputs> --out ${path56.basename(absolute)} --only ${missing.join(",")}\` rather than editing the JSON by hand.` : "")
27173
+ Entries missing fields: re-measure them with \`pixelkiln quality snapshot --inputs <inputs> --out ${path58.basename(absolute)} --only ${missing.join(",")}\` rather than editing the JSON by hand.` : "")
26200
27174
  );
26201
27175
  }
26202
27176
  return parsed.data;
@@ -26258,12 +27232,12 @@ function regressionViolations(expected, actual, tolerances) {
26258
27232
  return { violations, warnings };
26259
27233
  }
26260
27234
  async function checkQualityBaseline(baselinePath) {
26261
- const absolute = path56.resolve(baselinePath);
27235
+ const absolute = path58.resolve(baselinePath);
26262
27236
  const baseline = await readQualityBaseline(absolute);
26263
- const root = path56.dirname(absolute);
27237
+ const root = path58.dirname(absolute);
26264
27238
  const cases = [];
26265
27239
  for (const entry of baseline.cases) {
26266
- const file = path56.resolve(root, entry.file);
27240
+ const file = path58.resolve(root, entry.file);
26267
27241
  let actual = null;
26268
27242
  const violations = [];
26269
27243
  const warnings = [];
@@ -26276,7 +27250,7 @@ async function checkQualityBaseline(baselinePath) {
26276
27250
  violations.push(message4(error));
26277
27251
  }
26278
27252
  if (entry.record) {
26279
- const recordPath = path56.resolve(root, entry.record.path);
27253
+ const recordPath = path58.resolve(root, entry.record.path);
26280
27254
  try {
26281
27255
  const recordHash = await sha256File(recordPath);
26282
27256
  if (recordHash !== entry.record.sha256) violations.push("quality record hash changed");
@@ -26318,15 +27292,15 @@ async function runQuality(args) {
26318
27292
  if (!args.out) throw new Error("quality snapshot needs --out <pixelkiln.quality.json>.");
26319
27293
  let raw;
26320
27294
  try {
26321
- raw = JSON.parse(await readFile37(path57.resolve(args.inputs), "utf8"));
27295
+ raw = JSON.parse(await readFile40(path59.resolve(args.inputs), "utf8"));
26322
27296
  } catch (error) {
26323
27297
  throw new Error(
26324
- `Could not read quality inputs ${path57.resolve(args.inputs)}: ${error instanceof Error ? error.message : String(error)}`,
27298
+ `Could not read quality inputs ${path59.resolve(args.inputs)}: ${error instanceof Error ? error.message : String(error)}`,
26325
27299
  { cause: error }
26326
27300
  );
26327
27301
  }
26328
27302
  const inputs = resolveQualityInputs(raw, args.inputs);
26329
- if (path57.resolve(args.inputs) === path57.resolve(args.out)) {
27303
+ if (path59.resolve(args.inputs) === path59.resolve(args.out)) {
26330
27304
  throw new Error("quality snapshot --out must not overwrite its --inputs file.");
26331
27305
  }
26332
27306
  if (args.assets.length) {
@@ -26341,7 +27315,7 @@ async function runQuality(args) {
26341
27315
  }
26342
27316
  log(
26343
27317
  `
26344
- ${result2.changed ? args.dryRun ? "would write" : "wrote" : "no changes to"} ${path57.relative(process.cwd(), result2.path)}; other cases left as they were.`
27318
+ ${result2.changed ? args.dryRun ? "would write" : "wrote" : "no changes to"} ${path59.relative(process.cwd(), result2.path)}; other cases left as they were.`
26345
27319
  );
26346
27320
  return;
26347
27321
  }
@@ -26356,7 +27330,7 @@ async function runQuality(args) {
26356
27330
  }, null, 2));
26357
27331
  } else {
26358
27332
  log(
26359
- ` ${result.changed ? "wrote" : "unchanged"} ${path57.relative(process.cwd(), result.path)} (${result.baseline.cases.length} case(s))`
27333
+ ` ${result.changed ? "wrote" : "unchanged"} ${path59.relative(process.cwd(), result.path)} (${result.baseline.cases.length} case(s))`
26360
27334
  );
26361
27335
  log(` Review the tolerances, commit the baseline, then run quality check in CI.`);
26362
27336
  }
@@ -26382,12 +27356,12 @@ async function runQuality(args) {
26382
27356
  }
26383
27357
 
26384
27358
  // src/cli/commands/recipe.ts
26385
- import path59 from "path";
27359
+ import path61 from "path";
26386
27360
 
26387
27361
  // src/recipes.ts
26388
- import path58 from "path";
26389
- import { existsSync as existsSync44 } from "fs";
26390
- import { readdir as readdir3, readFile as readFile38 } from "fs/promises";
27362
+ import path60 from "path";
27363
+ import { existsSync as existsSync46 } from "fs";
27364
+ import { readdir as readdir4, readFile as readFile41 } from "fs/promises";
26391
27365
  import { fileURLToPath as fileURLToPath2 } from "url";
26392
27366
  import { z as z14 } from "zod";
26393
27367
  var SHA256_RE2 = /^[0-9a-f]{64}$/;
@@ -26396,7 +27370,7 @@ var VERSION_RE = /^\d+\.\d+\.\d+$/;
26396
27370
  var RECIPE_FILE = "pixelkiln.recipe.json";
26397
27371
  var RECIPE_DIR_TOKEN = "{{recipeDir}}";
26398
27372
  var PortablePathSchema = z14.string().min(1).refine((value) => {
26399
- if (value.includes("\\") || path58.posix.isAbsolute(value)) return false;
27373
+ if (value.includes("\\") || path60.posix.isAbsolute(value)) return false;
26400
27374
  const parts = value.split("/");
26401
27375
  return !parts.includes("") && !parts.includes(".") && !parts.includes("..");
26402
27376
  }, "expected a portable relative path without '.', '..', or backslashes");
@@ -26572,10 +27546,10 @@ function message5(error) {
26572
27546
  return error instanceof Error ? error.message : String(error);
26573
27547
  }
26574
27548
  async function readRecipeFile(recipePath, bundled) {
26575
- const absolute = path58.resolve(recipePath);
27549
+ const absolute = path60.resolve(recipePath);
26576
27550
  let raw;
26577
27551
  try {
26578
- raw = JSON.parse(await readFile38(absolute, "utf8"));
27552
+ raw = JSON.parse(await readFile41(absolute, "utf8"));
26579
27553
  } catch (error) {
26580
27554
  throw new Error(`Could not read recipe ${absolute}: ${message5(error)}`, { cause: error });
26581
27555
  }
@@ -26586,13 +27560,13 @@ async function readRecipeFile(recipePath, bundled) {
26586
27560
  ` + parsed.error.issues.map((issue) => ` ${issue.path.join(".") || "$"}: ${issue.message}`).join("\n")
26587
27561
  );
26588
27562
  }
26589
- return { recipe: parsed.data, authored: raw, path: absolute, dir: path58.dirname(absolute), bundled };
27563
+ return { recipe: parsed.data, authored: raw, path: absolute, dir: path60.dirname(absolute), bundled };
26590
27564
  }
26591
27565
  async function walkRecipeFiles(root) {
26592
- if (!existsSync44(root)) return [];
27566
+ if (!existsSync46(root)) return [];
26593
27567
  const out = [];
26594
- for (const entry of await readdir3(root, { withFileTypes: true })) {
26595
- const resolved = path58.join(root, entry.name);
27568
+ for (const entry of await readdir4(root, { withFileTypes: true })) {
27569
+ const resolved = path60.join(root, entry.name);
26596
27570
  if (entry.isDirectory()) out.push(...await walkRecipeFiles(resolved));
26597
27571
  else if (entry.isFile() && entry.name === RECIPE_FILE) out.push(resolved);
26598
27572
  }
@@ -26603,7 +27577,7 @@ function bundledRecipeRoot() {
26603
27577
  }
26604
27578
  async function listBundledRecipes(root = bundledRecipeRoot()) {
26605
27579
  const recipes = await Promise.all(
26606
- (await walkRecipeFiles(path58.resolve(root))).map((file) => readRecipeFile(file, true))
27580
+ (await walkRecipeFiles(path60.resolve(root))).map((file) => readRecipeFile(file, true))
26607
27581
  );
26608
27582
  return recipes.sort(
26609
27583
  (a, b) => a.recipe.id.localeCompare(b.recipe.id) || compareVersions(b.recipe.version, a.recipe.version)
@@ -26626,9 +27600,9 @@ function parseSelector(selector) {
26626
27600
  return { id: match[1], version: match[2] };
26627
27601
  }
26628
27602
  async function resolveRecipe(target, bundledRoot = bundledRecipeRoot()) {
26629
- const local = path58.resolve(target);
26630
- if (existsSync44(local)) {
26631
- const recipePath = path58.basename(local) === RECIPE_FILE ? local : path58.join(local, RECIPE_FILE);
27603
+ const local = path60.resolve(target);
27604
+ if (existsSync46(local)) {
27605
+ const recipePath = path60.basename(local) === RECIPE_FILE ? local : path60.join(local, RECIPE_FILE);
26632
27606
  return readRecipeFile(recipePath, false);
26633
27607
  }
26634
27608
  if (target.startsWith(".") || target.startsWith("/") || target.includes("\\")) {
@@ -26642,8 +27616,8 @@ async function resolveRecipe(target, bundledRoot = bundledRecipeRoot()) {
26642
27616
  return matches[0];
26643
27617
  }
26644
27618
  async function verifyFile(root, file) {
26645
- const absolute = path58.resolve(root, ...file.path.split("/"));
26646
- if (!existsSync44(absolute)) {
27619
+ const absolute = path60.resolve(root, ...file.path.split("/"));
27620
+ if (!existsSync46(absolute)) {
26647
27621
  return { path: file.path, expectedSha256: file.sha256, actualSha256: null, status: "missing" };
26648
27622
  }
26649
27623
  const actualSha256 = await sha256File(absolute);
@@ -26658,7 +27632,7 @@ async function verifyRecipe(target, options = {}) {
26658
27632
  const loaded = await resolveRecipe(target, options.bundledRoot);
26659
27633
  const actualIntegrity = recipeDigest(loaded.authored);
26660
27634
  const files = await Promise.all(loaded.recipe.files.map((file) => verifyFile(loaded.dir, file)));
26661
- const modelRoot = options.modelRoot ? path58.resolve(options.modelRoot) : null;
27635
+ const modelRoot = options.modelRoot ? path60.resolve(options.modelRoot) : null;
26662
27636
  const models = modelRoot ? await Promise.all(loaded.recipe.models.map(async (model) => ({
26663
27637
  ...await verifyFile(modelRoot, model),
26664
27638
  source: model.source,
@@ -26692,7 +27666,7 @@ async function verifyRecipe(target, options = {}) {
26692
27666
  };
26693
27667
  }
26694
27668
  function renderStyle(style, destination, cwd) {
26695
- const portableDir = path58.relative(cwd, destination).split(path58.sep).join("/") || ".";
27669
+ const portableDir = path60.relative(cwd, destination).split(path60.sep).join("/") || ".";
26696
27670
  const replace = (value) => {
26697
27671
  if (typeof value === "string") return value.replaceAll(RECIPE_DIR_TOKEN, portableDir);
26698
27672
  if (Array.isArray(value)) return value.map(replace);
@@ -26704,25 +27678,25 @@ function renderStyle(style, destination, cwd) {
26704
27678
  return replace(style);
26705
27679
  }
26706
27680
  async function installRecipe(target, options = {}) {
26707
- const cwd = path58.resolve(options.cwd ?? process.cwd());
27681
+ const cwd = path60.resolve(options.cwd ?? process.cwd());
26708
27682
  const loaded = await resolveRecipe(target, options.bundledRoot);
26709
27683
  const verification = await verifyRecipe(loaded.path);
26710
27684
  if (!verification.ok) {
26711
27685
  throw new Error(`Recipe ${loaded.recipe.id}@${loaded.recipe.version} failed integrity verification.`);
26712
27686
  }
26713
- const destination = options.out ? path58.resolve(cwd, options.out) : path58.join(cwd, "pixelkiln-recipes", ...loaded.recipe.id.split("/"), loaded.recipe.version);
27687
+ const destination = options.out ? path60.resolve(cwd, options.out) : path60.join(cwd, "pixelkiln-recipes", ...loaded.recipe.id.split("/"), loaded.recipe.version);
26714
27688
  const sources = [
26715
27689
  { path: RECIPE_FILE, source: loaded.path },
26716
- ...loaded.recipe.files.map((file) => ({ path: file.path, source: path58.join(loaded.dir, ...file.path.split("/")) }))
27690
+ ...loaded.recipe.files.map((file) => ({ path: file.path, source: path60.join(loaded.dir, ...file.path.split("/")) }))
26717
27691
  ];
26718
27692
  const files = await Promise.all(sources.map(async (file) => ({
26719
- path: path58.join(destination, ...file.path.split("/")),
26720
- data: await readFile38(file.source)
27693
+ path: path60.join(destination, ...file.path.split("/")),
27694
+ data: await readFile41(file.source)
26721
27695
  })));
26722
27696
  if (!options.force) {
26723
27697
  for (const file of files) {
26724
- if (!existsSync44(file.path)) continue;
26725
- const current = await readFile38(file.path);
27698
+ if (!existsSync46(file.path)) continue;
27699
+ const current = await readFile41(file.path);
26726
27700
  if (!current.equals(file.data)) {
26727
27701
  throw new OverwriteRefusedError(
26728
27702
  `Recipe destination has local changes: ${file.path}. Choose another --out or pass --force to replace declared recipe files.`,
@@ -26816,14 +27790,14 @@ async function runRecipe(args) {
26816
27790
  }, null, 2));
26817
27791
  } else {
26818
27792
  log(` installed ${result.recipe.id}@${result.recipe.version}`);
26819
- log(` ${path59.relative(process.cwd(), result.destination) || "."}`);
27793
+ log(` ${path61.relative(process.cwd(), result.destination) || "."}`);
26820
27794
  log(`
26821
27795
  Add this entry under your manifest's styles object:`);
26822
27796
  log(JSON.stringify({ [result.styleId]: result.style }, null, 2));
26823
27797
  if (result.recipe.models.length) {
26824
27798
  log(`
26825
27799
  Models are not downloaded automatically. Verify them with:`);
26826
- log(` pixelkiln recipe verify ${path59.relative(process.cwd(), result.destination)} --model-root <ComfyUI/models>`);
27800
+ log(` pixelkiln recipe verify ${path61.relative(process.cwd(), result.destination)} --model-root <ComfyUI/models>`);
26827
27801
  }
26828
27802
  }
26829
27803
  return;
@@ -26831,7 +27805,7 @@ async function runRecipe(args) {
26831
27805
  }
26832
27806
 
26833
27807
  // src/cli/commands/refine.ts
26834
- import path60 from "path";
27808
+ import path62 from "path";
26835
27809
  async function runRefine(args) {
26836
27810
  if (args.from || args.subcommand === "approve") {
26837
27811
  if (!args.from) {
@@ -26861,12 +27835,12 @@ async function runRefine(args) {
26861
27835
  ` recovered ${result3.detection.columns}x${result3.detection.rows} native grid (${result3.detection.confidence}: ${result3.detection.consensus})`
26862
27836
  );
26863
27837
  log(` enforced ${result3.palette.length}-color palette without dithering`);
26864
- log(` wrote ${path60.relative(process.cwd(), result3.output)}`);
26865
- log(` quality record: ${path60.relative(process.cwd(), result3.record)}`);
27838
+ log(` wrote ${path62.relative(process.cwd(), result3.output)}`);
27839
+ log(` quality record: ${path62.relative(process.cwd(), result3.record)}`);
26866
27840
  log(`
26867
27841
  Automated checks passed. Human 1\xD7 review is still required:`);
26868
27842
  log(
26869
- ` pixelkiln refine approve --from ${path60.relative(process.cwd(), result3.record)} --reviewer "Your Name"`
27843
+ ` pixelkiln refine approve --from ${path62.relative(process.cwd(), result3.record)} --reviewer "Your Name"`
26870
27844
  );
26871
27845
  }
26872
27846
  return;
@@ -26894,7 +27868,7 @@ async function runRefine(args) {
26894
27868
  if (args.json) log(JSON.stringify(result3, null, 2));
26895
27869
  else {
26896
27870
  log(
26897
- result3.options.frameSet ? ` approved ${result3.outputs.length} frames in ${path60.relative(process.cwd(), result3.record)} by ${args.reviewer.trim()}` : ` approved ${path60.relative(process.cwd(), result3.output)} by ${args.reviewer.trim()}`
27871
+ result3.options.frameSet ? ` approved ${result3.outputs.length} frames in ${path62.relative(process.cwd(), result3.record)} by ${args.reviewer.trim()}` : ` approved ${path62.relative(process.cwd(), result3.output)} by ${args.reviewer.trim()}`
26898
27872
  );
26899
27873
  }
26900
27874
  return;
@@ -26903,7 +27877,7 @@ async function runRefine(args) {
26903
27877
  if (args.json) {
26904
27878
  log(JSON.stringify(result2, null, 2));
26905
27879
  } else {
26906
- log(` ${result2.safe ? "release-ready" : "not release-ready"}: ${path60.relative(process.cwd(), result2.output || result2.record)}`);
27880
+ log(` ${result2.safe ? "release-ready" : "not release-ready"}: ${path62.relative(process.cwd(), result2.output || result2.record)}`);
26907
27881
  for (const reason of result2.reasons) log(` ${reason}`);
26908
27882
  }
26909
27883
  if (!result2.safe) process.exitCode = 1;
@@ -26949,7 +27923,7 @@ async function runRefine(args) {
26949
27923
  log(` ${item.state.padEnd(16)} ${item.key} ${item.reason}`);
26950
27924
  if (item.state === "needs-approval") {
26951
27925
  log(
26952
- ` pixelkiln refine approve --from ${path60.relative(process.cwd(), item.record)} --reviewer "Your Name"`
27926
+ ` pixelkiln refine approve --from ${path62.relative(process.cwd(), item.record)} --reviewer "Your Name"`
26953
27927
  );
26954
27928
  }
26955
27929
  }
@@ -26960,9 +27934,9 @@ async function runRefine(args) {
26960
27934
  }
26961
27935
 
26962
27936
  // src/cli/commands/skeleton.ts
26963
- import path61 from "path";
26964
- import { existsSync as existsSync45 } from "fs";
26965
- import { readFile as readFile39, writeFile as writeFile24 } from "fs/promises";
27937
+ import path63 from "path";
27938
+ import { existsSync as existsSync47 } from "fs";
27939
+ import { readFile as readFile42, writeFile as writeFile26 } from "fs/promises";
26966
27940
 
26967
27941
  // src/skeleton-preview.ts
26968
27942
  var RIGHT = [255, 140, 40, 255];
@@ -27073,12 +28047,12 @@ var Canvas = class {
27073
28047
  async function runEstimateSkeleton(args) {
27074
28048
  const image = args.target;
27075
28049
  if (!image) throw new UsageError("estimate-skeleton needs an image path: pixelkiln estimate-skeleton <image> [--out keypoints.json]");
27076
- if (args.out && existsSync45(path61.resolve(args.out)) && !args.force) {
28050
+ if (args.out && existsSync47(path63.resolve(args.out)) && !args.force) {
27077
28051
  throw new UsageError(`${args.out} already exists; pass --force to replace it`);
27078
28052
  }
27079
- loadEnvFiles(path61.dirname(path61.resolve(args.manifest)));
28053
+ loadEnvFiles(path63.dirname(path63.resolve(args.manifest)));
27080
28054
  loadEnvFiles(process.cwd());
27081
- const bytes = await readFile39(path61.resolve(image));
28055
+ const bytes = await readFile42(path63.resolve(image));
27082
28056
  const metadata = imageMetadata(bytes);
27083
28057
  if (!metadata) throw new UsageError(`${image} is not a readable PNG or JPEG`);
27084
28058
  const sizeProblem = estimateSkeletonSizeProblem(metadata.width, metadata.height);
@@ -27090,7 +28064,7 @@ async function runEstimateSkeleton(args) {
27090
28064
  const frames = args.frames ?? DEFAULT_SCAFFOLD_FRAMES;
27091
28065
  const json = JSON.stringify(scaffoldSkeletonSet(res.keypoints, frames), null, 2);
27092
28066
  if (args.out) {
27093
- await writeFile24(path61.resolve(args.out), json + "\n");
28067
+ await writeFile26(path63.resolve(args.out), json + "\n");
27094
28068
  log(` wrote ${args.out}: the estimated pose and ${frames} frames to edit`);
27095
28069
  log(` preview it with: pixelkiln skeleton-preview ${args.out} --from ${image}`);
27096
28070
  } else {
@@ -27103,8 +28077,8 @@ async function runSkeletonPreview(args) {
27103
28077
  let sourceFile2;
27104
28078
  let label;
27105
28079
  if (target.endsWith(".json")) {
27106
- keypointsFile = path61.resolve(target);
27107
- sourceFile2 = args.from ? path61.resolve(args.from) : void 0;
28080
+ keypointsFile = path63.resolve(target);
28081
+ sourceFile2 = args.from ? path63.resolve(args.from) : void 0;
27108
28082
  label = target;
27109
28083
  } else {
27110
28084
  const loaded = await loadManifest(args.manifest);
@@ -27116,31 +28090,31 @@ async function runSkeletonPreview(args) {
27116
28090
  );
27117
28091
  }
27118
28092
  keypointsFile = spec.revision.keypointsFile;
27119
- sourceFile2 = args.from ? path61.resolve(args.from) : spec.revision.sourceFile;
28093
+ sourceFile2 = args.from ? path63.resolve(args.from) : spec.revision.sourceFile;
27120
28094
  label = `${spec.styleId}/${spec.assetId}`;
27121
28095
  }
27122
- if (!existsSync45(keypointsFile)) throw new UsageError(`Keypoints file does not exist yet: ${keypointsFile}`);
28096
+ if (!existsSync47(keypointsFile)) throw new UsageError(`Keypoints file does not exist yet: ${keypointsFile}`);
27123
28097
  let json;
27124
28098
  try {
27125
- json = JSON.parse(await readFile39(keypointsFile, "utf8"));
28099
+ json = JSON.parse(await readFile42(keypointsFile, "utf8"));
27126
28100
  } catch (error) {
27127
28101
  throw new UsageError(`${keypointsFile} is not valid JSON: ${error instanceof Error ? error.message : String(error)}`);
27128
28102
  }
27129
28103
  const set = parseSkeletonSet(json, keypointsFile);
27130
28104
  let source;
27131
28105
  if (sourceFile2) {
27132
- if (!existsSync45(sourceFile2)) {
28106
+ if (!existsSync47(sourceFile2)) {
27133
28107
  log(` source image does not exist yet, drawing on a plain ground: ${sourceFile2}`);
27134
28108
  } else {
27135
- const bytes = await readFile39(sourceFile2);
28109
+ const bytes = await readFile42(sourceFile2);
27136
28110
  if (imageMetadata(bytes)?.format !== "png") throw new UsageError(`${sourceFile2} must be a PNG to preview over`);
27137
28111
  source = decodePng(bytes);
27138
28112
  }
27139
28113
  }
27140
- const out = path61.resolve(args.out ?? keypointsFile.replace(/\.json$/, "") + ".preview.png");
27141
- await writeFile24(out, renderSkeletonSheet(set, { source }));
28114
+ const out = path63.resolve(args.out ?? keypointsFile.replace(/\.json$/, "") + ".preview.png");
28115
+ await writeFile26(out, renderSkeletonSheet(set, { source }));
27142
28116
  log(` ${label}: ${set.frames.length} frames after the starting pose`);
27143
- const shown = path61.relative(process.cwd(), out);
28117
+ const shown = path63.relative(process.cwd(), out);
27144
28118
  log(` wrote ${shown.startsWith("..") ? out : shown}`);
27145
28119
  }
27146
28120
 
@@ -27186,15 +28160,15 @@ async function runTools(args) {
27186
28160
  }
27187
28161
 
27188
28162
  // src/cli/commands/workspace.ts
27189
- import path62 from "path";
27190
- import { existsSync as existsSync46 } from "fs";
28163
+ import path64 from "path";
28164
+ import { existsSync as existsSync48 } from "fs";
27191
28165
  async function runWorkspace(args) {
27192
- const workspacePath = path62.resolve(args.workspace ?? "pixelkiln.workspace.json");
27193
- const dir = path62.dirname(workspacePath);
28166
+ const workspacePath = path64.resolve(args.workspace ?? "pixelkiln.workspace.json");
28167
+ const dir = path64.dirname(workspacePath);
27194
28168
  if (args.subcommand === "add") {
27195
- const manifestPath = path62.resolve(args.target);
28169
+ const manifestPath = path64.resolve(args.target);
27196
28170
  const loadedTarget = await loadManifest(manifestPath);
27197
- const lockPath = args.explicitLock ? path62.resolve(args.explicitLock) : path62.join(path62.dirname(manifestPath), "pixelkiln.lock.json");
28171
+ const lockPath = args.explicitLock ? path64.resolve(args.explicitLock) : path64.join(path64.dirname(manifestPath), "pixelkiln.lock.json");
27198
28172
  const ws = await loadWorkspace(workspacePath);
27199
28173
  const id = args.name ?? loadedTarget.manifest.name;
27200
28174
  if (ws.projects.some((p) => p.id === id)) {
@@ -27214,10 +28188,10 @@ async function runWorkspace(args) {
27214
28188
  ...args.account ? { account: args.account } : {}
27215
28189
  };
27216
28190
  await saveWorkspace(workspacePath, { version: 1, projects: [...ws.projects, project] });
27217
- log(` registered "${id}" in ${path62.relative(process.cwd(), workspacePath)}`);
28191
+ log(` registered "${id}" in ${path64.relative(process.cwd(), workspacePath)}`);
27218
28192
  log(` manifest: ${project.manifest}`);
27219
28193
  log(` lock: ${project.lock}`);
27220
- if (!existsSync46(lockPath)) {
28194
+ if (!existsSync48(lockPath)) {
27221
28195
  log(
27222
28196
  ` warning: no lockfile there yet; this project contributes no claims until one is generated`
27223
28197
  );
@@ -27226,7 +28200,7 @@ async function runWorkspace(args) {
27226
28200
  }
27227
28201
  if (args.subcommand === "remove") {
27228
28202
  const ws = await loadWorkspace(workspacePath);
27229
- const resolvedTarget = path62.resolve(args.target);
28203
+ const resolvedTarget = path64.resolve(args.target);
27230
28204
  const match = ws.projects.find(
27231
28205
  (p) => p.id === args.target || resolveProject(dir, p).manifestPath === resolvedTarget
27232
28206
  );
@@ -27237,11 +28211,11 @@ async function runWorkspace(args) {
27237
28211
  version: 1,
27238
28212
  projects: ws.projects.filter((p) => p !== match)
27239
28213
  });
27240
- log(` removed "${match.id}" from ${path62.relative(process.cwd(), workspacePath)}`);
28214
+ log(` removed "${match.id}" from ${path64.relative(process.cwd(), workspacePath)}`);
27241
28215
  return;
27242
28216
  }
27243
28217
  if (args.subcommand === "list") {
27244
- if (!existsSync46(workspacePath)) {
28218
+ if (!existsSync48(workspacePath)) {
27245
28219
  throw new Error(`Workspace catalog not found: ${workspacePath}`);
27246
28220
  }
27247
28221
  const ws = await loadWorkspace(workspacePath);
@@ -27249,9 +28223,9 @@ async function runWorkspace(args) {
27249
28223
  if (args.json) {
27250
28224
  log(JSON.stringify({ version: 1, workspace: workspacePath, projects: ws.projects, diagnostics }, null, 2));
27251
28225
  } else if (!ws.projects.length) {
27252
- log(` no projects registered in ${path62.relative(process.cwd(), workspacePath)}`);
28226
+ log(` no projects registered in ${path64.relative(process.cwd(), workspacePath)}`);
27253
28227
  } else {
27254
- log(` ${ws.projects.length} project(s) in ${path62.relative(process.cwd(), workspacePath)}:`);
28228
+ log(` ${ws.projects.length} project(s) in ${path64.relative(process.cwd(), workspacePath)}:`);
27255
28229
  for (const p of ws.projects) {
27256
28230
  log(` ${p.id.padEnd(24)} ${p.manifest.padEnd(40)} (${p.provider}${p.account ? `, ${p.account}` : ""})`);
27257
28231
  }
@@ -27261,7 +28235,7 @@ async function runWorkspace(args) {
27261
28235
  return;
27262
28236
  }
27263
28237
  if (args.subcommand === "status") {
27264
- if (!existsSync46(workspacePath)) {
28238
+ if (!existsSync48(workspacePath)) {
27265
28239
  throw new Error(`Workspace catalog not found: ${workspacePath}`);
27266
28240
  }
27267
28241
  const ws = await loadWorkspace(workspacePath);
@@ -27269,7 +28243,7 @@ async function runWorkspace(args) {
27269
28243
  if (args.json) {
27270
28244
  log(JSON.stringify({ ...report, workspace: workspacePath }, null, 2));
27271
28245
  } else {
27272
- log(` workspace: ${path62.relative(process.cwd(), workspacePath)}`);
28246
+ log(` workspace: ${path64.relative(process.cwd(), workspacePath)}`);
27273
28247
  for (const p of report.projects) {
27274
28248
  if (p.error) {
27275
28249
  log(`
@@ -27323,8 +28297,8 @@ async function runHelp() {
27323
28297
  async function runVersion() {
27324
28298
  for (const up of ["../package.json", "../../package.json"]) {
27325
28299
  const url = new URL(up, import.meta.url);
27326
- if (!existsSync47(url)) continue;
27327
- const pkg = JSON.parse(await readFile40(url, "utf8"));
28300
+ if (!existsSync49(url)) continue;
28301
+ const pkg = JSON.parse(await readFile43(url, "utf8"));
27328
28302
  if (pkg.name === "pixelkiln") {
27329
28303
  log(`${pkg.name} ${pkg.version}`);
27330
28304
  return;
@@ -27379,7 +28353,8 @@ var RUNNERS = {
27379
28353
  music: runMusic,
27380
28354
  sfx: runSfx,
27381
28355
  ui: runUi,
27382
- asset: runAsset
28356
+ asset: runAsset,
28357
+ talk: runTalk
27383
28358
  };
27384
28359
  async function main(argv = process.argv.slice(2)) {
27385
28360
  const args = parseArgs(argv);