@ikijs/mcp 0.38.1 → 0.39.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/index.js CHANGED
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
31
31
  var index_exports = {};
32
32
  __export(index_exports, {
33
33
  CUSTOM_GATE_LIMITS: () => CUSTOM_GATE_LIMITS,
34
+ PLUGIN_ENV: () => PLUGIN_ENV,
34
35
  SWEEP_PRESETS: () => SWEEP_PRESETS,
35
36
  autoRigFromLayers: () => autoRigFromLayers,
36
37
  checkCustomGate: () => checkCustomGate,
@@ -59,6 +60,7 @@ __export(index_exports, {
59
60
  measureTurnReference: () => measureTurnReference,
60
61
  probeRig: () => probeRig,
61
62
  renderPoses: () => renderPoses,
63
+ toolGenerator: () => toolGenerator,
62
64
  validateIki: () => validateIki,
63
65
  viewIllustrationGrid: () => viewIllustrationGrid
64
66
  });
@@ -68,11 +70,32 @@ module.exports = __toCommonJS(index_exports);
68
70
  var getImportMetaUrl = () => typeof document === "undefined" ? new URL(`file:${__filename}`).href : document.currentScript && document.currentScript.tagName.toUpperCase() === "SCRIPT" ? document.currentScript.src : new URL("main.js", document.baseURI).href;
69
71
  var importMetaUrl = /* @__PURE__ */ getImportMetaUrl();
70
72
 
73
+ // src/generator.ts
74
+ var import_editor = require("@ikijs/editor");
75
+ var import_format = require("@ikijs/format");
76
+ var PLUGIN_ENV = "IKI_PLUGIN";
77
+ function toolGenerator(env = process.env) {
78
+ const generator = {
79
+ tool: `@ikijs/mcp@${"0.39.0"}`,
80
+ rigger: `@ikijs/editor@${import_editor.EDITOR_VERSION}`
81
+ };
82
+ const plugin = env[PLUGIN_ENV];
83
+ if (plugin === void 0 || plugin === "") return generator;
84
+ try {
85
+ return (0, import_format.parseIkiGenerator)({ ...generator, plugin });
86
+ } catch (e) {
87
+ if (!(e instanceof import_format.IkiFormatError)) throw e;
88
+ throw new import_format.IkiFormatError(
89
+ `the ${PLUGIN_ENV} environment variable is no label for a model: ${e.message}`
90
+ );
91
+ }
92
+ }
93
+
71
94
  // src/tools.ts
72
95
  var import_node_fs6 = require("fs");
73
96
  var import_node_path5 = __toESM(require("path"));
74
- var import_format11 = require("@ikijs/format");
75
- var import_editor4 = require("@ikijs/editor");
97
+ var import_format12 = require("@ikijs/format");
98
+ var import_editor5 = require("@ikijs/editor");
76
99
 
77
100
  // ../engine/src/math.ts
78
101
  function clamp(value, min, max) {
@@ -503,7 +526,7 @@ function occlusionAmount(occlusion, value) {
503
526
  }
504
527
 
505
528
  // ../engine/src/idle-motion.ts
506
- var import_format = require("@ikijs/format");
529
+ var import_format2 = require("@ikijs/format");
507
530
 
508
531
  // ../engine/src/frame-clock.ts
509
532
  var MAX_DT_MS = 100;
@@ -688,18 +711,18 @@ var IdleMotion = class {
688
711
  constructor(sink, options) {
689
712
  this.sink = sink;
690
713
  this.rng = options?.rng ?? Math.random;
691
- this.brows = [import_format.StandardParameter.BrowLeftY, import_format.StandardParameter.BrowRightY].map((id) => options?.parameters?.find((p) => p.id === id)).filter((p) => p !== void 0).map((p) => ({ id: p.id, rest: clamp(p.default, p.min, p.max) }));
714
+ this.brows = [import_format2.StandardParameter.BrowLeftY, import_format2.StandardParameter.BrowRightY].map((id) => options?.parameters?.find((p) => p.id === id)).filter((p) => p !== void 0).map((p) => ({ id: p.id, rest: clamp(p.default, p.min, p.max) }));
692
715
  this.drivenParameterIds = [
693
- import_format.StandardParameter.EyeOpenLeft,
694
- import_format.StandardParameter.EyeOpenRight,
716
+ import_format2.StandardParameter.EyeOpenLeft,
717
+ import_format2.StandardParameter.EyeOpenRight,
695
718
  ...this.brows.map((b) => b.id),
696
- import_format.StandardParameter.Breath,
697
- import_format.StandardParameter.EyeballX,
698
- import_format.StandardParameter.EyeballY,
699
- import_format.StandardParameter.AngleX,
700
- import_format.StandardParameter.AngleY,
701
- import_format.StandardParameter.AngleZ,
702
- import_format.StandardParameter.AmbientSway
719
+ import_format2.StandardParameter.Breath,
720
+ import_format2.StandardParameter.EyeballX,
721
+ import_format2.StandardParameter.EyeballY,
722
+ import_format2.StandardParameter.AngleX,
723
+ import_format2.StandardParameter.AngleY,
724
+ import_format2.StandardParameter.AngleZ,
725
+ import_format2.StandardParameter.AmbientSway
703
726
  ];
704
727
  this.nextBlinkAtMs = lerp(
705
728
  BLINK_INTERVAL_MIN_MS,
@@ -738,21 +761,21 @@ var IdleMotion = class {
738
761
  this.prevNowMs = nowMs;
739
762
  this.clockMs += dt;
740
763
  const eyeVal = this.advanceBlink();
741
- this.sink(import_format.StandardParameter.EyeOpenLeft, eyeVal);
742
- this.sink(import_format.StandardParameter.EyeOpenRight, eyeVal);
764
+ this.sink(import_format2.StandardParameter.EyeOpenLeft, eyeVal);
765
+ this.sink(import_format2.StandardParameter.EyeOpenRight, eyeVal);
743
766
  for (const { id, rest } of this.brows) {
744
767
  this.sink(id, rest + BROW_BLINK_DIP * (eyeVal - 1));
745
768
  }
746
769
  const breath = this.advanceBreath();
747
770
  this.advanceGaze(dt);
748
- this.sink(import_format.StandardParameter.Breath, breath);
749
- this.sink(import_format.StandardParameter.EyeballX, this.eyeX.value);
750
- this.sink(import_format.StandardParameter.EyeballY, this.eyeY.value);
771
+ this.sink(import_format2.StandardParameter.Breath, breath);
772
+ this.sink(import_format2.StandardParameter.EyeballX, this.eyeX.value);
773
+ this.sink(import_format2.StandardParameter.EyeballY, this.eyeY.value);
751
774
  this.advanceHead(dt, breath);
752
- this.sink(import_format.StandardParameter.AngleX, this.headX.value);
753
- this.sink(import_format.StandardParameter.AngleY, this.headY.value);
754
- this.sink(import_format.StandardParameter.AngleZ, this.headZ.value);
755
- this.sink(import_format.StandardParameter.AmbientSway, this.ambientSway());
775
+ this.sink(import_format2.StandardParameter.AngleX, this.headX.value);
776
+ this.sink(import_format2.StandardParameter.AngleY, this.headY.value);
777
+ this.sink(import_format2.StandardParameter.AngleZ, this.headZ.value);
778
+ this.sink(import_format2.StandardParameter.AmbientSway, this.ambientSway());
756
779
  }
757
780
  /**
758
781
  * Hold the gaze on (`x`, `y`), in EyeballX/Y units (+ is the viewer's right
@@ -782,16 +805,16 @@ var IdleMotion = class {
782
805
  // Private helpers
783
806
  // ---------------------------------------------------------------------------
784
807
  emitRestingPose() {
785
- this.sink(import_format.StandardParameter.EyeOpenLeft, 1);
786
- this.sink(import_format.StandardParameter.EyeOpenRight, 1);
808
+ this.sink(import_format2.StandardParameter.EyeOpenLeft, 1);
809
+ this.sink(import_format2.StandardParameter.EyeOpenRight, 1);
787
810
  for (const { id, rest } of this.brows) this.sink(id, rest);
788
- this.sink(import_format.StandardParameter.Breath, 0);
789
- this.sink(import_format.StandardParameter.EyeballX, 0);
790
- this.sink(import_format.StandardParameter.EyeballY, 0);
791
- this.sink(import_format.StandardParameter.AngleX, 0);
792
- this.sink(import_format.StandardParameter.AngleY, 0);
793
- this.sink(import_format.StandardParameter.AngleZ, 0);
794
- this.sink(import_format.StandardParameter.AmbientSway, 0);
811
+ this.sink(import_format2.StandardParameter.Breath, 0);
812
+ this.sink(import_format2.StandardParameter.EyeballX, 0);
813
+ this.sink(import_format2.StandardParameter.EyeballY, 0);
814
+ this.sink(import_format2.StandardParameter.AngleX, 0);
815
+ this.sink(import_format2.StandardParameter.AngleY, 0);
816
+ this.sink(import_format2.StandardParameter.AngleZ, 0);
817
+ this.sink(import_format2.StandardParameter.AmbientSway, 0);
795
818
  }
796
819
  /** Returns the current eye-open value (0..1) and advances blink state. */
797
820
  advanceBlink() {
@@ -878,7 +901,7 @@ var IdleMotion = class {
878
901
  };
879
902
 
880
903
  // ../engine/src/physics-motion.ts
881
- var import_format2 = require("@ikijs/format");
904
+ var import_format3 = require("@ikijs/format");
882
905
  function signedNormalized(value, param) {
883
906
  const rest = clamp(param.default, param.min, param.max);
884
907
  const den = Math.max(Math.abs(param.max - rest), Math.abs(rest - param.min));
@@ -906,7 +929,7 @@ var PhysicsMotion = class {
906
929
  constructor(rigs, params, read, sink) {
907
930
  this.rigs = rigs;
908
931
  this.inputs = rigs.map(
909
- (rig) => (0, import_format2.physicsInputs)(rig).map(({ parameter, weight, mode }) => ({
932
+ (rig) => (0, import_format3.physicsInputs)(rig).map(({ parameter, weight, mode }) => ({
910
933
  parameter,
911
934
  weight,
912
935
  lag: mode === "lag"
@@ -1163,25 +1186,25 @@ var HairChainMotion = class {
1163
1186
  };
1164
1187
 
1165
1188
  // ../engine/src/iki-motion.ts
1166
- var import_format5 = require("@ikijs/format");
1189
+ var import_format6 = require("@ikijs/format");
1167
1190
 
1168
1191
  // ../engine/src/clip-player.ts
1169
- var import_format3 = require("@ikijs/format");
1192
+ var import_format4 = require("@ikijs/format");
1170
1193
 
1171
1194
  // ../engine/src/expression-player.ts
1172
- var import_format4 = require("@ikijs/format");
1195
+ var import_format5 = require("@ikijs/format");
1173
1196
 
1174
1197
  // ../engine/src/iki-motion.ts
1175
1198
  var HEAD_AND_GAZE = /* @__PURE__ */ new Set([
1176
- import_format5.StandardParameter.AngleX,
1177
- import_format5.StandardParameter.AngleY,
1178
- import_format5.StandardParameter.AngleZ,
1179
- import_format5.StandardParameter.EyeballX,
1180
- import_format5.StandardParameter.EyeballY
1199
+ import_format6.StandardParameter.AngleX,
1200
+ import_format6.StandardParameter.AngleY,
1201
+ import_format6.StandardParameter.AngleZ,
1202
+ import_format6.StandardParameter.EyeballX,
1203
+ import_format6.StandardParameter.EyeballY
1181
1204
  ]);
1182
1205
 
1183
1206
  // ../engine/src/folds.ts
1184
- var import_format6 = require("@ikijs/format");
1207
+ var import_format7 = require("@ikijs/format");
1185
1208
 
1186
1209
  // ../engine/src/land.ts
1187
1210
  var UNIT_QUAD = [-0.5, -0.5, 0.5, -0.5, -0.5, 0.5, 0.5, 0.5];
@@ -1264,19 +1287,19 @@ function landParts(model, values, partIds) {
1264
1287
  var FLIP = 0;
1265
1288
  var COLLAPSE = 0.1;
1266
1289
  var ANGLES = [
1267
- import_format6.StandardParameter.AngleX,
1268
- import_format6.StandardParameter.AngleY,
1269
- import_format6.StandardParameter.AngleZ,
1270
- import_format6.StandardParameter.BodyAngleX,
1271
- import_format6.StandardParameter.BodyAngleY,
1272
- import_format6.StandardParameter.BodyAngleZ
1290
+ import_format7.StandardParameter.AngleX,
1291
+ import_format7.StandardParameter.AngleY,
1292
+ import_format7.StandardParameter.AngleZ,
1293
+ import_format7.StandardParameter.BodyAngleX,
1294
+ import_format7.StandardParameter.BodyAngleY,
1295
+ import_format7.StandardParameter.BodyAngleZ
1273
1296
  ];
1274
1297
  var CROSSES = [
1275
- [import_format6.StandardParameter.EyeOpenLeft],
1276
- [import_format6.StandardParameter.EyeOpenRight],
1277
- [import_format6.StandardParameter.MouthOpen],
1278
- [import_format6.StandardParameter.ArmLeft, import_format6.StandardParameter.ArmRight],
1279
- [import_format6.StandardParameter.ElbowLeft, import_format6.StandardParameter.ElbowRight]
1298
+ [import_format7.StandardParameter.EyeOpenLeft],
1299
+ [import_format7.StandardParameter.EyeOpenRight],
1300
+ [import_format7.StandardParameter.MouthOpen],
1301
+ [import_format7.StandardParameter.ArmLeft, import_format7.StandardParameter.ArmRight],
1302
+ [import_format7.StandardParameter.ElbowLeft, import_format7.StandardParameter.ElbowRight]
1280
1303
  ];
1281
1304
  function foldPoses(model) {
1282
1305
  const byId = new Map(
@@ -1494,7 +1517,7 @@ function classify(worst) {
1494
1517
  }
1495
1518
 
1496
1519
  // ../engine/src/physics-check.ts
1497
- var import_format7 = require("@ikijs/format");
1520
+ var import_format8 = require("@ikijs/format");
1498
1521
 
1499
1522
  // ../engine/src/physics-runs.ts
1500
1523
  var FRAME_MS = FIXED_DT_S * 1e3 * (1 + 1e-9);
@@ -1674,7 +1697,7 @@ function checkPhysics(model) {
1674
1697
  };
1675
1698
  const param = (id) => model.parameters.find((p) => p.id === id);
1676
1699
  const springs = (model.physics ?? []).map((rig) => {
1677
- const inputs = (0, import_format7.physicsInputs)(rig).map((i) => param(i.parameter));
1700
+ const inputs = (0, import_format8.physicsInputs)(rig).map((i) => param(i.parameter));
1678
1701
  const ids = inputs.map((p) => p.id);
1679
1702
  const output = param(rig.output.parameter);
1680
1703
  const ranged = inputs.flatMap((input) => {
@@ -2106,11 +2129,11 @@ function checkBakes(model, reports) {
2106
2129
  }
2107
2130
 
2108
2131
  // src/custom-gate.ts
2109
- var import_editor3 = require("@ikijs/editor");
2110
- var import_format9 = require("@ikijs/format");
2132
+ var import_editor4 = require("@ikijs/editor");
2133
+ var import_format10 = require("@ikijs/format");
2111
2134
 
2112
2135
  // src/fold-report.ts
2113
- var import_editor = require("@ikijs/editor");
2136
+ var import_editor2 = require("@ikijs/editor");
2114
2137
  function checkModelFolds(model, extraValues = []) {
2115
2138
  const declared = new Set(model.parameters.map((p) => p.id));
2116
2139
  return checkFolds(model, {
@@ -2120,7 +2143,7 @@ function checkModelFolds(model, extraValues = []) {
2120
2143
  // are shut-mouth poses too.
2121
2144
  expected: (target2, _pose, value) => {
2122
2145
  if (target2.kind !== "part") return false;
2123
- const shutBy = import_editor.SHUT_BY.get(target2.id);
2146
+ const shutBy = import_editor2.SHUT_BY.get(target2.id);
2124
2147
  return shutBy !== void 0 && declared.has(shutBy) && value(shutBy) === 0;
2125
2148
  }
2126
2149
  });
@@ -2130,7 +2153,7 @@ function formatFoldReport(report, canvas) {
2130
2153
  const closures = report.targets.flatMap((t) => {
2131
2154
  if (t.expected === void 0) return [];
2132
2155
  if (t.expected.ratio >= report.thresholds.collapse) return [];
2133
- const shutBy = import_editor.SHUT_BY.get(t.target.id);
2156
+ const shutBy = import_editor2.SHUT_BY.get(t.target.id);
2134
2157
  const at = shutBy === void 0 ? "" : ` at ${shutBy}=0`;
2135
2158
  return [`${t.target.id} ${ratioText(t.expected.ratio)}${at}`];
2136
2159
  });
@@ -2158,11 +2181,11 @@ function ratioText(ratio) {
2158
2181
 
2159
2182
  // src/probe.ts
2160
2183
  var import_node_fs2 = require("fs");
2161
- var import_format8 = require("@ikijs/format");
2184
+ var import_format9 = require("@ikijs/format");
2162
2185
 
2163
2186
  // src/node-images.ts
2164
2187
  var import_sharp = __toESM(require("sharp"));
2165
- var import_editor2 = require("@ikijs/editor");
2188
+ var import_editor3 = require("@ikijs/editor");
2166
2189
  async function decodePng(filePath) {
2167
2190
  try {
2168
2191
  const pipeline = (0, import_sharp.default)(filePath, { limitInputPixels: MAX_INPUT_PIXELS });
@@ -2186,7 +2209,7 @@ async function decodePng(filePath) {
2186
2209
  }
2187
2210
  }
2188
2211
  function detectAlphaBbox(rgba, width, height) {
2189
- const bbox = (0, import_editor2.detectAlphaBbox)(rgba, width, height);
2212
+ const bbox = (0, import_editor3.detectAlphaBbox)(rgba, width, height);
2190
2213
  if (bbox === null) {
2191
2214
  throw new AutoRigInputError("layer is empty after alpha threshold");
2192
2215
  }
@@ -2434,7 +2457,7 @@ async function probeRig(input) {
2434
2457
  "model path",
2435
2458
  input.modelPath
2436
2459
  );
2437
- const model = (0, import_format8.loadIkiModel)((0, import_node_fs2.readFileSync)(modelFile, "utf8"));
2460
+ const model = (0, import_format9.loadIkiModel)((0, import_node_fs2.readFileSync)(modelFile, "utf8"));
2438
2461
  if (!Array.isArray(input.queries) || input.queries.length === 0) {
2439
2462
  throw new AutoRigInputError("queries must be a non-empty list");
2440
2463
  }
@@ -2457,7 +2480,7 @@ async function probeRig(input) {
2457
2480
  lines: results.map(summarize)
2458
2481
  };
2459
2482
  } catch (e) {
2460
- if (e instanceof AutoRigInputError || e instanceof import_format8.IkiFormatError) {
2483
+ if (e instanceof AutoRigInputError || e instanceof import_format9.IkiFormatError) {
2461
2484
  return { ok: false, error: e.message };
2462
2485
  }
2463
2486
  throw e;
@@ -2650,9 +2673,9 @@ function checkCustomGate(model, parts, paints, options = {}) {
2650
2673
  const px2 = (twin) => Math.max(1, Math.round(twin * scale2));
2651
2674
  const cache = /* @__PURE__ */ new Map();
2652
2675
  const turnParam = model.parameters.find(
2653
- (p) => p.id === import_format9.StandardParameter.AngleX
2676
+ (p) => p.id === import_format10.StandardParameter.AngleX
2654
2677
  );
2655
- const turns = (pose) => turnParam !== void 0 && (pose.values[import_format9.StandardParameter.AngleX] ?? turnParam.default) !== turnParam.default;
2678
+ const turns = (pose) => turnParam !== void 0 && (pose.values[import_format10.StandardParameter.AngleX] ?? turnParam.default) !== turnParam.default;
2656
2679
  const bakedOf = (id) => {
2657
2680
  const part = model.parts.find((p) => p.id === id);
2658
2681
  return new Map(
@@ -2681,7 +2704,7 @@ function checkCustomGate(model, parts, paints, options = {}) {
2681
2704
  const all = new Map(poseSets.flat().map((p) => [p.name, p]));
2682
2705
  const reports = parts.map((part, n) => {
2683
2706
  const poses = poseSets[n];
2684
- const roleParts = (0, import_editor3.partIdsOfRole)(part.anchor).filter(
2707
+ const roleParts = (0, import_editor4.partIdsOfRole)(part.anchor).filter(
2685
2708
  (id) => model.parts.some((p) => p.id === id)
2686
2709
  );
2687
2710
  const anchorId = roleParts.find(
@@ -2765,7 +2788,7 @@ function checkCustomGate(model, parts, paints, options = {}) {
2765
2788
  const coverParts = [];
2766
2789
  if (occlusion !== void 0) {
2767
2790
  for (const role of part.occludedBy ?? []) {
2768
- for (const id of (0, import_editor3.partIdsOfRole)(role)) {
2791
+ for (const id of (0, import_editor4.partIdsOfRole)(role)) {
2769
2792
  const o = model.parts.find((p) => p.id === id);
2770
2793
  if (o === void 0 || !occlusion.by.includes(id)) continue;
2771
2794
  const steady = o.color[3] === 1 && (o.transform.opacity ?? 1) >= 1 && !(o.bindings ?? []).some((b) => b.channel === "opacity");
@@ -2825,7 +2848,7 @@ function checkCustomGate(model, parts, paints, options = {}) {
2825
2848
  const moved = [];
2826
2849
  for (let i = 0; i < posed.length; i += 2)
2827
2850
  moved.push([posed[i], posed[i + 1]]);
2828
- keep(worstOf.rigid, (0, import_editor3.rigidResidual)(restPoints, moved), pose.name);
2851
+ keep(worstOf.rigid, (0, import_editor4.rigidResidual)(restPoints, moved), pose.name);
2829
2852
  };
2830
2853
  for (const pose of poses) {
2831
2854
  const hiding = occlusion !== void 0 && hiddenAt(keyOf(pose.values));
@@ -3128,7 +3151,7 @@ function formatCustomGate(report) {
3128
3151
  // src/render-poses.ts
3129
3152
  var import_node_fs5 = require("fs");
3130
3153
  var import_node_path4 = __toESM(require("path"));
3131
- var import_format10 = require("@ikijs/format");
3154
+ var import_format11 = require("@ikijs/format");
3132
3155
 
3133
3156
  // src/render-browser.ts
3134
3157
  var import_node_child_process = require("child_process");
@@ -4063,9 +4086,9 @@ function planRenders(model, requested, sweep, sweeps) {
4063
4086
  }
4064
4087
  const bodyAngles = Object.fromEntries(
4065
4088
  [
4066
- import_format10.StandardParameter.BodyAngleX,
4067
- import_format10.StandardParameter.BodyAngleY,
4068
- import_format10.StandardParameter.BodyAngleZ
4089
+ import_format11.StandardParameter.BodyAngleX,
4090
+ import_format11.StandardParameter.BodyAngleY,
4091
+ import_format11.StandardParameter.BodyAngleZ
4069
4092
  ].filter((id) => model.parameters.some((p) => p.id === id)).map((id) => [id, -10])
4070
4093
  );
4071
4094
  const poses = [
@@ -4151,7 +4174,7 @@ function planRenders(model, requested, sweep, sweeps) {
4151
4174
  whole("full-elbow-r-45", { ParamElbowR: 45 }),
4152
4175
  whole("full-elbow-r-90", { ParamElbowR: 90 })
4153
4176
  );
4154
- if (model.parameters.some((p) => p.id === import_format10.StandardParameter.ArmPoseRight)) {
4177
+ if (model.parameters.some((p) => p.id === import_format11.StandardParameter.ArmPoseRight)) {
4155
4178
  poses.push(
4156
4179
  whole("full-pose-l", { ParamArmPoseL: 1 }),
4157
4180
  whole("full-pose-r", { ParamArmPoseR: 1 }),
@@ -4327,7 +4350,7 @@ async function renderPoses(input) {
4327
4350
  input.modelPath
4328
4351
  );
4329
4352
  const outDir = resolveOutputDir(input.outDir);
4330
- const model = (0, import_format10.loadIkiModel)((0, import_node_fs5.readFileSync)(modelFile, "utf8"));
4353
+ const model = (0, import_format11.loadIkiModel)((0, import_node_fs5.readFileSync)(modelFile, "utf8"));
4331
4354
  const plan = planRenders(model, input.poses, input.sweep, input.sweeps);
4332
4355
  const drawn = input.hideParts ? withoutParts(model, input.hideParts) : model;
4333
4356
  const browser = findBrowser();
@@ -4420,7 +4443,7 @@ async function renderPoses(input) {
4420
4443
  sweeps
4421
4444
  };
4422
4445
  } catch (error) {
4423
- if (error instanceof AutoRigInputError || error instanceof import_format10.IkiFormatError) {
4446
+ if (error instanceof AutoRigInputError || error instanceof import_format11.IkiFormatError) {
4424
4447
  return { ok: false, error: error.message };
4425
4448
  }
4426
4449
  throw error;
@@ -4430,10 +4453,10 @@ async function renderPoses(input) {
4430
4453
  // src/tools.ts
4431
4454
  function coerceModel(model) {
4432
4455
  try {
4433
- const parsed = typeof model === "string" ? (0, import_format11.loadIkiModel)(model) : (0, import_format11.parseIkiModel)(model);
4456
+ const parsed = typeof model === "string" ? (0, import_format12.loadIkiModel)(model) : (0, import_format12.parseIkiModel)(model);
4434
4457
  return { ok: true, model: parsed };
4435
4458
  } catch (e) {
4436
- if (e instanceof import_format11.IkiFormatError) return { ok: false, error: e.message };
4459
+ if (e instanceof import_format12.IkiFormatError) return { ok: false, error: e.message };
4437
4460
  throw e;
4438
4461
  }
4439
4462
  }
@@ -4530,6 +4553,7 @@ function describeIki(model) {
4530
4553
  motions,
4531
4554
  bustScale
4532
4555
  };
4556
+ if (m.generator !== void 0) summary.generator = m.generator;
4533
4557
  const face = m.parts.find((p) => p.id === "face");
4534
4558
  if (face !== void 0) summary.faceWidth = face.width;
4535
4559
  return { ok: true, summary };
@@ -4550,123 +4574,123 @@ function describeIkiAt(modelPath) {
4550
4574
  }
4551
4575
  var STANDARD_PARAMETER_INFO = [
4552
4576
  {
4553
- id: import_format11.StandardParameter.MouthOpen,
4577
+ id: import_format12.StandardParameter.MouthOpen,
4554
4578
  description: "Mouth open amount for lip-sync (0 closed .. 1 open)."
4555
4579
  },
4556
4580
  {
4557
- id: import_format11.StandardParameter.MouthForm,
4581
+ id: import_format12.StandardParameter.MouthForm,
4558
4582
  description: "Mouth form / smile (-1 .. 1)."
4559
4583
  },
4560
4584
  {
4561
- id: import_format11.StandardParameter.EyeOpenLeft,
4585
+ id: import_format12.StandardParameter.EyeOpenLeft,
4562
4586
  description: "Left eye open (0 closed .. 1 open). Drive with the right eye for a blink."
4563
4587
  },
4564
4588
  {
4565
- id: import_format11.StandardParameter.EyeOpenRight,
4589
+ id: import_format12.StandardParameter.EyeOpenRight,
4566
4590
  description: "Right eye open (0 closed .. 1 open)."
4567
4591
  },
4568
4592
  {
4569
- id: import_format11.StandardParameter.EyeballX,
4593
+ id: import_format12.StandardParameter.EyeballX,
4570
4594
  description: "Eyeball gaze, horizontal (-1 .. 1)."
4571
4595
  },
4572
4596
  {
4573
- id: import_format11.StandardParameter.EyeballY,
4597
+ id: import_format12.StandardParameter.EyeballY,
4574
4598
  description: "Eyeball gaze, vertical (-1 .. 1)."
4575
4599
  },
4576
4600
  {
4577
- id: import_format11.StandardParameter.AngleX,
4601
+ id: import_format12.StandardParameter.AngleX,
4578
4602
  description: "Head angle, horizontal degrees."
4579
4603
  },
4580
4604
  {
4581
- id: import_format11.StandardParameter.AngleY,
4605
+ id: import_format12.StandardParameter.AngleY,
4582
4606
  description: "Head angle, vertical degrees."
4583
4607
  },
4584
4608
  {
4585
- id: import_format11.StandardParameter.AngleZ,
4609
+ id: import_format12.StandardParameter.AngleZ,
4586
4610
  description: "Head tilt / roll degrees; positive tilts the top of the head toward the viewer's right (clockwise), as in Live2D."
4587
4611
  },
4588
4612
  {
4589
- id: import_format11.StandardParameter.BodyAngleX,
4613
+ id: import_format12.StandardParameter.BodyAngleX,
4590
4614
  description: "Body turn, degrees (-10 .. 10); positive turns the body toward the viewer's right, as AngleX does the head."
4591
4615
  },
4592
4616
  {
4593
- id: import_format11.StandardParameter.BodyAngleY,
4617
+ id: import_format12.StandardParameter.BodyAngleY,
4594
4618
  description: "Body lean, degrees (-10 .. 10); positive moves the upper body up, negative bows."
4595
4619
  },
4596
4620
  {
4597
- id: import_format11.StandardParameter.BodyAngleZ,
4621
+ id: import_format12.StandardParameter.BodyAngleZ,
4598
4622
  description: "Body tilt, degrees (-10 .. 10); positive tilts the top toward the viewer's right (clockwise), as AngleZ does the head."
4599
4623
  },
4600
4624
  {
4601
- id: import_format11.StandardParameter.Breath,
4625
+ id: import_format12.StandardParameter.Breath,
4602
4626
  description: "Idle breath (0 .. 1), cycled by the host."
4603
4627
  },
4604
4628
  {
4605
- id: import_format11.StandardParameter.AmbientSway,
4629
+ id: import_format12.StandardParameter.AmbientSway,
4606
4630
  description: "Ambient sway (-1 .. 1): a slow zero-mean drift the idle writes for physics rigs to follow (the auto-rig's hair in idle). Not a wind: no bias. Stays procedural under a declared Idle group, as Breath does."
4607
4631
  },
4608
4632
  {
4609
- id: import_format11.StandardParameter.BrowLeftY,
4633
+ id: import_format12.StandardParameter.BrowLeftY,
4610
4634
  description: "Left brow raise/lower (-1 .. 1)."
4611
4635
  },
4612
4636
  {
4613
- id: import_format11.StandardParameter.BrowRightY,
4637
+ id: import_format12.StandardParameter.BrowRightY,
4614
4638
  description: "Right brow raise/lower (-1 .. 1)."
4615
4639
  },
4616
4640
  {
4617
- id: import_format11.StandardParameter.BrowLeftAngle,
4641
+ id: import_format12.StandardParameter.BrowLeftAngle,
4618
4642
  description: "Left brow tilt/angle (-1 .. 1)."
4619
4643
  },
4620
4644
  {
4621
- id: import_format11.StandardParameter.BrowRightAngle,
4645
+ id: import_format12.StandardParameter.BrowRightAngle,
4622
4646
  description: "Right brow tilt/angle (-1 .. 1)."
4623
4647
  },
4624
4648
  {
4625
- id: import_format11.StandardParameter.Cheek,
4649
+ id: import_format12.StandardParameter.Cheek,
4626
4650
  description: "Cheek blush strength (0 .. 1), raised by an expression."
4627
4651
  },
4628
4652
  {
4629
- id: import_format11.StandardParameter.HairSwayX,
4653
+ id: import_format12.StandardParameter.HairSwayX,
4630
4654
  description: "Front hair's horizontal sway driver. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
4631
4655
  },
4632
4656
  {
4633
- id: import_format11.StandardParameter.HairSwayZ,
4657
+ id: import_format12.StandardParameter.HairSwayZ,
4634
4658
  description: "Front hair's sway driver behind a head tilt. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
4635
4659
  },
4636
4660
  {
4637
- id: import_format11.StandardParameter.HairBackSway,
4661
+ id: import_format12.StandardParameter.HairBackSway,
4638
4662
  description: "Back hair's sway driver behind the head turn, tilt and ambient drift, one spring slower than the front hair's so the two swing out of phase. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
4639
4663
  },
4640
4664
  {
4641
- id: import_format11.StandardParameter.ArmLeft,
4665
+ id: import_format12.StandardParameter.ArmLeft,
4642
4666
  description: "Left shoulder, degrees; positive raises the arm outward (mirrored on the right)."
4643
4667
  },
4644
4668
  {
4645
- id: import_format11.StandardParameter.ArmRight,
4669
+ id: import_format12.StandardParameter.ArmRight,
4646
4670
  description: "Right shoulder, degrees; positive raises the arm outward (mirrored on the left)."
4647
4671
  },
4648
4672
  {
4649
- id: import_format11.StandardParameter.ElbowLeft,
4673
+ id: import_format12.StandardParameter.ElbowLeft,
4650
4674
  description: "Left elbow, degrees; positive bends the forearm toward the body (the flexion of a hanging arm), negative a little outward (mirrored on the right)."
4651
4675
  },
4652
4676
  {
4653
- id: import_format11.StandardParameter.ElbowRight,
4677
+ id: import_format12.StandardParameter.ElbowRight,
4654
4678
  description: "Right elbow, degrees; positive bends the forearm toward the body (the flexion of a hanging arm), negative a little outward (mirrored on the left)."
4655
4679
  },
4656
4680
  {
4657
- id: import_format11.StandardParameter.ArmPoseLeft,
4681
+ id: import_format12.StandardParameter.ArmPoseLeft,
4658
4682
  description: "Left pose-forearm switch, 0..1; 0 the hanging forearm, 1 the drawn pose forearm, between them a crossfade of the two. Declared by auto-rigged models with a pose forearm."
4659
4683
  },
4660
4684
  {
4661
- id: import_format11.StandardParameter.ArmPoseRight,
4685
+ id: import_format12.StandardParameter.ArmPoseRight,
4662
4686
  description: "Right pose-forearm switch, 0..1; 0 the hanging forearm, 1 the drawn pose forearm, between them a crossfade of the two. Declared by auto-rigged models with a pose forearm."
4663
4687
  },
4664
4688
  {
4665
- id: import_format11.StandardParameter.ArmPoseAngleLeft,
4689
+ id: import_format12.StandardParameter.ArmPoseAngleLeft,
4666
4690
  description: "Left pose forearm's own small rotation about the elbow, degrees; positive tips the raised hand outward, away from the body (mirrored on the right)."
4667
4691
  },
4668
4692
  {
4669
- id: import_format11.StandardParameter.ArmPoseAngleRight,
4693
+ id: import_format12.StandardParameter.ArmPoseAngleRight,
4670
4694
  description: "Right pose forearm's own small rotation about the elbow, degrees; positive tips the raised hand outward, away from the body (mirrored on the left)."
4671
4695
  }
4672
4696
  ];
@@ -4674,10 +4698,10 @@ function listStandardParameters() {
4674
4698
  return STANDARD_PARAMETER_INFO.map((p) => ({ ...p }));
4675
4699
  }
4676
4700
  function describeRigPlan() {
4677
- return { fields: [...import_editor4.RIG_PLAN_FIELDS] };
4701
+ return { fields: [...import_editor5.RIG_PLAN_FIELDS] };
4678
4702
  }
4679
4703
  function formatRigPlanReport(r) {
4680
- const fields = import_editor4.RIG_PLAN_FIELDS.map((f) => {
4704
+ const fields = import_editor5.RIG_PLAN_FIELDS.map((f) => {
4681
4705
  const value = `${f.path}=${r.effective[f.path]}`;
4682
4706
  const clamp2 = r.clamped.find((c) => c.field === f.path);
4683
4707
  if (clamp2 !== void 0) {
@@ -4700,7 +4724,7 @@ function expectInput(label, fn) {
4700
4724
  }
4701
4725
  var LOSSLESS_PAGE_ROLE = "nose";
4702
4726
  async function renderAtlasPage(crops, quantizeColors) {
4703
- const layout = (0, import_editor4.packAtlas)(
4727
+ const layout = (0, import_editor5.packAtlas)(
4704
4728
  crops.map((c) => ({ id: c.id, width: c.width, height: c.height })),
4705
4729
  void 0,
4706
4730
  MAX_ATLAS_SIDE
@@ -4719,6 +4743,14 @@ async function renderAtlasPage(crops, quantizeColors) {
4719
4743
  }
4720
4744
  async function autoRigFromLayers(input) {
4721
4745
  try {
4746
+ if (input.generator !== void 0) {
4747
+ try {
4748
+ (0, import_format12.parseIkiGenerator)(input.generator);
4749
+ } catch (e) {
4750
+ if (e instanceof import_format12.IkiFormatError) throw new AutoRigInputError(e.message);
4751
+ throw e;
4752
+ }
4753
+ }
4722
4754
  const layers = input.layers;
4723
4755
  if (!Array.isArray(layers) || layers.length === 0) {
4724
4756
  throw new AutoRigInputError("layers must be a non-empty array");
@@ -4749,7 +4781,7 @@ async function autoRigFromLayers(input) {
4749
4781
  );
4750
4782
  }
4751
4783
  if (input.style !== void 0) {
4752
- throw new AutoRigInputError((0, import_editor4.styleRemovedMessage)("style"));
4784
+ throw new AutoRigInputError((0, import_editor5.styleRemovedMessage)("style"));
4753
4785
  }
4754
4786
  const turnTargets = input.turnTargets;
4755
4787
  if (turnTargets !== void 0) {
@@ -4771,7 +4803,7 @@ async function autoRigFromLayers(input) {
4771
4803
  );
4772
4804
  const rolePairs = expectInput(
4773
4805
  "role parsing",
4774
- () => (0, import_editor4.parseLayerRoles)(resolvedLayers.map((r) => r.fileName))
4806
+ () => (0, import_editor5.parseLayerRoles)(resolvedLayers.map((r) => r.fileName))
4775
4807
  );
4776
4808
  const roleByFileName = new Map(rolePairs.map((p) => [p.fileName, p.role]));
4777
4809
  let canvasW = 0;
@@ -4805,7 +4837,7 @@ async function autoRigFromLayers(input) {
4805
4837
  `canvas ${canvasW}x${canvasH} exceeds ${MAX_CANVAS_DIM}`
4806
4838
  );
4807
4839
  }
4808
- measurer = (0, import_editor4.createLayerSetMeasurer)({ width: canvasW, height: canvasH });
4840
+ measurer = (0, import_editor5.createLayerSetMeasurer)({ width: canvasW, height: canvasH });
4809
4841
  } else if (png.width !== canvasW || png.height !== canvasH) {
4810
4842
  throw new AutoRigInputError(
4811
4843
  `layer "${fileName}" size ${png.width}x${png.height} differs from canvas ${canvasW}x${canvasH}`
@@ -4849,7 +4881,7 @@ async function autoRigFromLayers(input) {
4849
4881
  `${at}.path size ${png.width}x${png.height} differs from canvas ${canvasW}x${canvasH}`
4850
4882
  );
4851
4883
  }
4852
- const bbox = (0, import_editor4.detectAlphaBbox)(png.rgba, png.width, png.height);
4884
+ const bbox = (0, import_editor5.detectAlphaBbox)(png.rgba, png.width, png.height);
4853
4885
  if (bbox === null) {
4854
4886
  throw new AutoRigInputError(
4855
4887
  `${at}.path "${import_node_path5.default.basename(resolved)}": layer is empty after alpha threshold`
@@ -4876,7 +4908,7 @@ async function autoRigFromLayers(input) {
4876
4908
  let bakeReports;
4877
4909
  let model;
4878
4910
  try {
4879
- model = (0, import_editor4.generateIkiFromLayerSet)(
4911
+ model = (0, import_editor5.generateIkiFromLayerSet)(
4880
4912
  measurement.layers,
4881
4913
  { width: canvasW, height: canvasH },
4882
4914
  {
@@ -4916,12 +4948,12 @@ async function autoRigFromLayers(input) {
4916
4948
  }
4917
4949
  );
4918
4950
  } catch (e) {
4919
- if (!(e instanceof import_editor4.TurnTargetError || e instanceof import_editor4.LayerGeometryError || e instanceof import_editor4.PatchError || e instanceof import_editor4.RigPlanError || e instanceof import_editor4.CustomPartError || e instanceof import_editor4.BakeError)) {
4951
+ if (!(e instanceof import_editor5.TurnTargetError || e instanceof import_editor5.LayerGeometryError || e instanceof import_editor5.PatchError || e instanceof import_editor5.RigPlanError || e instanceof import_editor5.CustomPartError || e instanceof import_editor5.BakeError)) {
4920
4952
  throw e;
4921
4953
  }
4922
4954
  throw new AutoRigInputError(e.message);
4923
4955
  }
4924
- const doc = new import_editor4.EditorDocument(model);
4956
+ const doc = new import_editor5.EditorDocument(model);
4925
4957
  const losslessCrop = quantizeColors === void 0 ? void 0 : crops.find((c) => c.id === LOSSLESS_PAGE_ROLE);
4926
4958
  const pages = losslessCrop === void 0 ? [await renderAtlasPage(crops, quantizeColors)] : [
4927
4959
  await renderAtlasPage(
@@ -4944,11 +4976,11 @@ async function autoRigFromLayers(input) {
4944
4976
  if (placement3 === void 0) {
4945
4977
  throw new Error(`auto-rig: no atlas placement for "${crop.id}"`);
4946
4978
  }
4947
- const uv = (0, import_editor4.uvRectFor)(placement3, {
4979
+ const uv = (0, import_editor5.uvRectFor)(placement3, {
4948
4980
  width: layout.pageWidth,
4949
4981
  height: layout.pageHeight
4950
4982
  });
4951
- return (0, import_editor4.partIdsOfRole)(crop.id).map((partId) => ({ partId, uv }));
4983
+ return (0, import_editor5.partIdsOfRole)(crop.id).map((partId) => ({ partId, uv }));
4952
4984
  })
4953
4985
  );
4954
4986
  if (customPage !== void 0) {
@@ -4959,7 +4991,7 @@ async function autoRigFromLayers(input) {
4959
4991
  );
4960
4992
  return {
4961
4993
  partId: crop.id,
4962
- uv: (0, import_editor4.uvRectFor)(placement3, {
4994
+ uv: (0, import_editor5.uvRectFor)(placement3, {
4963
4995
  width: customPage.layout.pageWidth,
4964
4996
  height: customPage.layout.pageHeight
4965
4997
  })
@@ -4976,7 +5008,7 @@ async function autoRigFromLayers(input) {
4976
5008
  patched = structuredClone(patched);
4977
5009
  patched.textures = allPages.map((p) => ({ source: p.dataUri }));
4978
5010
  if (losslessCrop !== void 0) {
4979
- for (const partId of (0, import_editor4.partIdsOfRole)(losslessCrop.id)) {
5011
+ for (const partId of (0, import_editor5.partIdsOfRole)(losslessCrop.id)) {
4980
5012
  patched.parts.find((p) => p.id === partId).texture.index = 1;
4981
5013
  }
4982
5014
  }
@@ -4984,7 +5016,9 @@ async function autoRigFromLayers(input) {
4984
5016
  patched.parts.find((p) => p.id === crop.id).texture.index = pages.length;
4985
5017
  }
4986
5018
  }
4987
- const finalModel = (0, import_format11.parseIkiModel)(patched);
5019
+ const finalModel = (0, import_format12.parseIkiModel)(
5020
+ input.generator === void 0 ? patched : { ...patched, generator: input.generator }
5021
+ );
4988
5022
  const bakes = bakeReports === void 0 ? void 0 : checkBakes(finalModel, bakeReports);
4989
5023
  writeFileAtomic(outPath, JSON.stringify(finalModel));
4990
5024
  const folds = checkModelFolds(finalModel);
@@ -5055,10 +5089,10 @@ async function autoRigFromLayers(input) {
5055
5089
  var import_node_fs8 = __toESM(require("fs"));
5056
5090
  var import_node_path10 = __toESM(require("path"));
5057
5091
  var import_sharp4 = __toESM(require("sharp"));
5058
- var import_editor14 = require("@ikijs/editor");
5092
+ var import_editor15 = require("@ikijs/editor");
5059
5093
 
5060
5094
  // src/trim.ts
5061
- var import_editor5 = require("@ikijs/editor");
5095
+ var import_editor6 = require("@ikijs/editor");
5062
5096
  var TRIM_THRESHOLD = 12;
5063
5097
  var STRAY_SPECK_FRACTION = 0.01;
5064
5098
  function luma(rgba, i) {
@@ -5087,7 +5121,7 @@ function boxWithoutStraySpecks(rgba, W, H) {
5087
5121
  while (depth > 0) {
5088
5122
  const p = stack[--depth];
5089
5123
  size++;
5090
- if (rgba[p * 4 + 3] >= import_editor5.ALPHA_OPAQUE) opaque = true;
5124
+ if (rgba[p * 4 + 3] >= import_editor6.ALPHA_OPAQUE) opaque = true;
5091
5125
  const px2 = p % W;
5092
5126
  const py = (p - px2) / W;
5093
5127
  setLeft = Math.min(setLeft, px2);
@@ -5129,7 +5163,7 @@ var import_node_path9 = __toESM(require("path"));
5129
5163
 
5130
5164
  // src/measure-arms.ts
5131
5165
  var import_node_path6 = __toESM(require("path"));
5132
- var import_editor6 = require("@ikijs/editor");
5166
+ var import_editor7 = require("@ikijs/editor");
5133
5167
  var ARM_ROLES = ["arm_L", "arm_R"];
5134
5168
  var CAP_OVERLAP = 0.5;
5135
5169
  var px = (v) => `${Number(v.toFixed(1))}`;
@@ -5158,7 +5192,7 @@ async function armWarnings(absDir, layers) {
5158
5192
  continue;
5159
5193
  }
5160
5194
  if (set === void 0) {
5161
- const measurer = (0, import_editor6.createLayerSetMeasurer)({
5195
+ const measurer = (0, import_editor7.createLayerSetMeasurer)({
5162
5196
  width: body.canvasW,
5163
5197
  height: body.canvasH
5164
5198
  });
@@ -5166,12 +5200,12 @@ async function armWarnings(absDir, layers) {
5166
5200
  }
5167
5201
  let g;
5168
5202
  try {
5169
- g = (0, import_editor6.armGeometry)(
5203
+ g = (0, import_editor7.armGeometry)(
5170
5204
  await measured(set.measurer, absDir, arm),
5171
5205
  set.body.bbox.x + set.body.bbox.w / 2 - body.canvasW / 2
5172
5206
  );
5173
5207
  } catch (err) {
5174
- if (err instanceof import_editor6.LayerGeometryError) {
5208
+ if (err instanceof import_editor7.LayerGeometryError) {
5175
5209
  warnings.push(
5176
5210
  `${arm}: ${err.message} \u2014 auto_rig_from_layers refuses it. Regenerate arm.png drawn hanging, shoulder at the top. Billed.`
5177
5211
  );
@@ -5199,7 +5233,7 @@ function capWarning(arm, g, body) {
5199
5233
  }
5200
5234
 
5201
5235
  // src/measure-hair-side.ts
5202
- var import_editor7 = require("@ikijs/editor");
5236
+ var import_editor8 = require("@ikijs/editor");
5203
5237
  var LOCK_ROLES = ["hair_side_R", "hair_side_L"];
5204
5238
  var VISIBLE_MIN_PX = 3;
5205
5239
  var LEAN_HH = 0.12;
@@ -5247,7 +5281,7 @@ async function hairSideWarnings(absDir, layers, inPlace = false) {
5247
5281
  }
5248
5282
  }
5249
5283
  if (mismatched) return warnings;
5250
- const measurer = (0, import_editor7.createLayerSetMeasurer)({
5284
+ const measurer = (0, import_editor8.createLayerSetMeasurer)({
5251
5285
  width: ref.canvasW,
5252
5286
  height: ref.canvasH
5253
5287
  });
@@ -5386,7 +5420,7 @@ function drawsTwoLocks(lock) {
5386
5420
  }
5387
5421
 
5388
5422
  // src/measure-forearm-pose.ts
5389
- var import_editor8 = require("@ikijs/editor");
5423
+ var import_editor9 = require("@ikijs/editor");
5390
5424
  var POSE_ROLES = ["forearm_pose_L", "forearm_pose_R"];
5391
5425
  var ARM_OF = {
5392
5426
  forearm_pose_L: "arm_L",
@@ -5420,7 +5454,7 @@ async function forearmPoseWarnings(absDir, layers) {
5420
5454
  continue;
5421
5455
  }
5422
5456
  if (layers.body === void 0) continue;
5423
- const measurer = (0, import_editor8.createLayerSetMeasurer)({
5457
+ const measurer = (0, import_editor9.createLayerSetMeasurer)({
5424
5458
  width: stats.canvasW,
5425
5459
  height: stats.canvasH
5426
5460
  });
@@ -5428,12 +5462,12 @@ async function forearmPoseWarnings(absDir, layers) {
5428
5462
  let armLayer;
5429
5463
  try {
5430
5464
  armLayer = await measured(measurer, absDir, arm);
5431
- a = (0, import_editor8.armGeometry)(armLayer, arm === "arm_R" ? Infinity : -Infinity);
5465
+ a = (0, import_editor9.armGeometry)(armLayer, arm === "arm_R" ? Infinity : -Infinity);
5432
5466
  } catch (err) {
5433
- if (err instanceof import_editor8.LayerGeometryError) continue;
5467
+ if (err instanceof import_editor9.LayerGeometryError) continue;
5434
5468
  throw err;
5435
5469
  }
5436
- const b = (0, import_editor8.forearmPoseGeometry)(await measured(measurer, absDir, pose));
5470
+ const b = (0, import_editor9.forearmPoseGeometry)(await measured(measurer, absDir, pose));
5437
5471
  warnings.push(...jointWarnings(pose, arm, stats, a, armLayer, b));
5438
5472
  }
5439
5473
  return warnings;
@@ -5473,11 +5507,11 @@ function jointWarnings(pose, arm, stats, a, armLayer, b) {
5473
5507
 
5474
5508
  // src/measure-lips.ts
5475
5509
  var import_node_path7 = __toESM(require("path"));
5476
- var import_editor10 = require("@ikijs/editor");
5510
+ var import_editor11 = require("@ikijs/editor");
5477
5511
 
5478
5512
  // src/compose-lips.ts
5479
5513
  var import_sharp2 = __toESM(require("sharp"));
5480
- var import_editor9 = require("@ikijs/editor");
5514
+ var import_editor10 = require("@ikijs/editor");
5481
5515
  var KEYED_SRC = "mouth_keyed.png";
5482
5516
  var INTERIOR_SRC = "mouth_interior.png";
5483
5517
  var KEY_CANDIDATE = 0.5;
@@ -5575,7 +5609,7 @@ function keyGreen(rgba, W, H) {
5575
5609
  let candidates = 0;
5576
5610
  for (let p = 0; p < n; p++) {
5577
5611
  const i = p * 4;
5578
- if (rgba[i + 3] < import_editor9.ALPHA_OPAQUE) continue;
5612
+ if (rgba[i + 3] < import_editor10.ALPHA_OPAQUE) continue;
5579
5613
  const excess = (rgba[i + 1] - Math.max(rgba[i], rgba[i + 2])) / 255;
5580
5614
  if (excess < KEY_CANDIDATE) continue;
5581
5615
  candidates++;
@@ -5602,7 +5636,7 @@ function keyGreen(rgba, W, H) {
5602
5636
  const dg = rgba[i + 1] - G[1];
5603
5637
  const db = rgba[i + 2] - G[2];
5604
5638
  const green = dr * dr + dg * dg + db * db <= KEY_FILL_DIST * KEY_FILL_DIST;
5605
- if (rgba[i + 3] < import_editor9.ALPHA_OPAQUE) {
5639
+ if (rgba[i + 3] < import_editor10.ALPHA_OPAQUE) {
5606
5640
  if (green) out[i + 3] = 0;
5607
5641
  } else if (green) {
5608
5642
  fill[p] = 1;
@@ -5778,7 +5812,7 @@ async function prepInterior(rgba, W, H) {
5778
5812
  for (let y = box3.y; y < box3.y + box3.h; y++) {
5779
5813
  for (let x = box3.x; x < box3.x + box3.w; x++) {
5780
5814
  const i = (y * cw + x) * 4;
5781
- if (crop[i + 3] < import_editor9.ALPHA_OPAQUE) continue;
5815
+ if (crop[i + 3] < import_editor10.ALPHA_OPAQUE) continue;
5782
5816
  count2++;
5783
5817
  for (let c = 0; c < 3; c++) all[c] += crop[i + c];
5784
5818
  if (luma(crop, i) < CAVITY_LUMA) {
@@ -5801,7 +5835,7 @@ function enclosedHole(frame, w, h) {
5801
5835
  const stack = new Int32Array(n);
5802
5836
  let depth = 0;
5803
5837
  const seed = (p) => {
5804
- if (!outside[p] && alpha(p) < import_editor9.ALPHA_OPAQUE) {
5838
+ if (!outside[p] && alpha(p) < import_editor10.ALPHA_OPAQUE) {
5805
5839
  outside[p] = 1;
5806
5840
  stack[depth++] = p;
5807
5841
  }
@@ -5824,7 +5858,7 @@ function enclosedHole(frame, w, h) {
5824
5858
  }
5825
5859
  const mask = new Uint8Array(n);
5826
5860
  for (let p = 0; p < n; p++) {
5827
- if (alpha(p) < import_editor9.ALPHA_OPAQUE && !outside[p]) mask[p] = 1;
5861
+ if (alpha(p) < import_editor10.ALPHA_OPAQUE && !outside[p]) mask[p] = 1;
5828
5862
  }
5829
5863
  const { label, sizes, boxes } = components(mask, w, h);
5830
5864
  const main = largest(sizes);
@@ -5851,7 +5885,7 @@ function enclosedHole(frame, w, h) {
5851
5885
  return { label, main, box: box3 };
5852
5886
  }
5853
5887
  function measureLips(layers, w, h) {
5854
- const measurer = (0, import_editor9.createLayerSetMeasurer)({ width: w, height: h });
5888
+ const measurer = (0, import_editor10.createLayerSetMeasurer)({ width: w, height: h });
5855
5889
  return new Map(
5856
5890
  Object.entries(layers).map(([role, rgba]) => [
5857
5891
  role,
@@ -5869,8 +5903,8 @@ function assertFoldContract(layers, w, h) {
5869
5903
  }
5870
5904
  byRole.set(role, layer);
5871
5905
  }
5872
- const opening = (0, import_editor9.mouthOpening)(byRole);
5873
- const runs = (0, import_editor9.columnRuns)(byRole.get("mouth_inner"));
5906
+ const opening = (0, import_editor10.mouthOpening)(byRole);
5907
+ const runs = (0, import_editor10.columnRuns)(byRole.get("mouth_inner"));
5874
5908
  for (let col = opening.x0; col <= opening.x1; col++) {
5875
5909
  const c = opening.at(col);
5876
5910
  const why = !runs.has(col) ? "has no interior run" : c.Tu > c.T ? `has a gap between the line and the interior (Tu ${c.Tu} > T ${c.T})` : c.T > c.lineTop || c.lineH <= 0 ? `has no line above the interior (T ${c.T}, line top ${c.lineTop})` : c.Bl < c.Bb ? `has a gap between the interior and the skin (Bl ${c.Bl} < Bb ${c.Bb})` : null;
@@ -5900,18 +5934,18 @@ async function splitLipSet(keyedPng, w, h, interior) {
5900
5934
  }
5901
5935
  const centre = Math.round((hb.x0 + hb.x1) / 2);
5902
5936
  let stroke = 0;
5903
- while (top[centre] - 1 - stroke >= 0 && alpha((top[centre] - 1 - stroke) * w + centre) >= import_editor9.ALPHA_OPAQUE)
5937
+ while (top[centre] - 1 - stroke >= 0 && alpha((top[centre] - 1 - stroke) * w + centre) >= import_editor10.ALPHA_OPAQUE)
5904
5938
  stroke++;
5905
5939
  const bandCap = BAND_CAP * Math.max(1, stroke);
5906
5940
  const skinRow = new Int32Array(w).fill(-1);
5907
5941
  const inM = new Uint8Array(n);
5908
5942
  for (let x = hb.x0; x <= hb.x1; x++) {
5909
5943
  let y = bot[x];
5910
- while (y < h && y - bot[x] < bandCap && alpha(y * w + x) >= import_editor9.ALPHA_OPAQUE && luma(frame, (y * w + x) * 4) < BAND_LUMA)
5944
+ while (y < h && y - bot[x] < bandCap && alpha(y * w + x) >= import_editor10.ALPHA_OPAQUE && luma(frame, (y * w + x) * 4) < BAND_LUMA)
5911
5945
  y++;
5912
5946
  for (let k = top[x]; k < y; k++) inM[k * w + x] = 1;
5913
5947
  let r = y;
5914
- while (r < h && alpha(r * w + x) < import_editor9.ALPHA_OPAQUE) r++;
5948
+ while (r < h && alpha(r * w + x) < import_editor10.ALPHA_OPAQUE) r++;
5915
5949
  if (r < h) {
5916
5950
  skinRow[x] = r;
5917
5951
  inM[r * w + x] = 1;
@@ -5921,7 +5955,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
5921
5955
  for (let y = 0; y < h; y++) {
5922
5956
  for (let x = 0; x < w; x++) {
5923
5957
  const p = y * w + x;
5924
- if (inM[p] || alpha(p) < import_editor9.ALPHA_OPAQUE) continue;
5958
+ if (inM[p] || alpha(p) < import_editor10.ALPHA_OPAQUE) continue;
5925
5959
  if (top[x] >= 0 && y < top[x]) continue;
5926
5960
  if (x > 0 && inM[p - 1] || x < w - 1 && inM[p + 1]) grown[p] = 1;
5927
5961
  }
@@ -5931,7 +5965,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
5931
5965
  if (x < 0 || x >= w) continue;
5932
5966
  let first = 0;
5933
5967
  while (first < h && !(grown[first * w + x] && !inM[first * w + x])) first++;
5934
- if (first > 0 && first < h && alpha((first - 1) * w + x) >= import_editor9.ALPHA_OPAQUE)
5968
+ if (first > 0 && first < h && alpha((first - 1) * w + x) >= import_editor10.ALPHA_OPAQUE)
5935
5969
  wall[x] = 1;
5936
5970
  }
5937
5971
  const gx = hb.x0 - 1;
@@ -5958,7 +5992,7 @@ async function splitLipSet(keyedPng, w, h, interior) {
5958
5992
  if (inOpening && skinRow[x] >= 0 && y >= skinRow[x]) copy(lower, p);
5959
5993
  if (!grown[p]) {
5960
5994
  const a = alpha(p);
5961
- if (a >= import_editor9.ALPHA_OPAQUE && a < 255 && besideHole(p, x, y)) {
5995
+ if (a >= import_editor10.ALPHA_OPAQUE && a < 255 && besideHole(p, x, y)) {
5962
5996
  inner.set(interior.cavity, p * 4);
5963
5997
  inner[p * 4 + 3] = 255 - a;
5964
5998
  }
@@ -6023,7 +6057,7 @@ async function restShiftOf(layers, width, height) {
6023
6057
  }
6024
6058
  byRole.set(role, layer);
6025
6059
  }
6026
- return (0, import_editor9.mouthRestShift)(byRole);
6060
+ return (0, import_editor10.mouthRestShift)(byRole);
6027
6061
  }
6028
6062
  async function closedLips(upper, lower, shift, left, top) {
6029
6063
  const shut = async (png, role) => {
@@ -6073,7 +6107,7 @@ async function closedLips(upper, lower, shift, left, top) {
6073
6107
  }
6074
6108
 
6075
6109
  // src/measure-lips.ts
6076
- var isLipLayerRole = (role) => import_editor10.LIP_ROLES.includes(role) || (0, import_editor10.isLipInsideRole)(role);
6110
+ var isLipLayerRole = (role) => import_editor11.LIP_ROLES.includes(role) || (0, import_editor11.isLipInsideRole)(role);
6077
6111
  var MIN_OPENING_ROWS = 8;
6078
6112
  var MIN_LINE_ROWS = 2;
6079
6113
  var GREEN_EXCESS = 40;
@@ -6081,8 +6115,8 @@ var INTERIOR_GAP_FRACTION = 0.05;
6081
6115
  var columns = (cols) => `${cols.length} column${cols.length === 1 ? "" : "s"} (first at x=${cols[0]})`;
6082
6116
  async function lipWarnings(absDir, layers, inPlace = false) {
6083
6117
  const warnings = [];
6084
- const present = import_editor10.LIP_ROLES.filter((role) => layers[role] !== void 0);
6085
- const inside = import_editor10.LIP_INSIDE_ROLES.filter((role) => layers[role] !== void 0);
6118
+ const present = import_editor11.LIP_ROLES.filter((role) => layers[role] !== void 0);
6119
+ const inside = import_editor11.LIP_INSIDE_ROLES.filter((role) => layers[role] !== void 0);
6086
6120
  if (present.length === 0) {
6087
6121
  if (inside.length > 0) {
6088
6122
  warnings.push(
@@ -6099,8 +6133,8 @@ async function lipWarnings(absDir, layers, inPlace = false) {
6099
6133
  `${present.join("/")}: the lip set cannot be mixed with ${legacy.join("/")} \u2014 auto_rig_from_layers refuses it. Remove one route: compose again with only mouth_keyed.png + mouth_interior.png, or without them.`
6100
6134
  );
6101
6135
  }
6102
- if (present.length < import_editor10.LIP_ROLES.length) {
6103
- const missing = import_editor10.LIP_ROLES.filter((role) => layers[role] === void 0);
6136
+ if (present.length < import_editor11.LIP_ROLES.length) {
6137
+ const missing = import_editor11.LIP_ROLES.filter((role) => layers[role] === void 0);
6104
6138
  warnings.push(
6105
6139
  `${present.join("/")}: partial lip set, missing ${missing.join("/")} \u2014 auto_rig_from_layers refuses it. Compose mouth_keyed.png + mouth_interior.png together, which cuts all three.`
6106
6140
  );
@@ -6131,18 +6165,18 @@ async function lipWarnings(absDir, layers, inPlace = false) {
6131
6165
  );
6132
6166
  }
6133
6167
  }
6134
- const measurer = (0, import_editor10.createLayerSetMeasurer)({
6168
+ const measurer = (0, import_editor11.createLayerSetMeasurer)({
6135
6169
  width: inner.canvasW,
6136
6170
  height: inner.canvasH
6137
6171
  });
6138
6172
  const set = /* @__PURE__ */ new Map();
6139
6173
  const green = [];
6140
- for (const role of import_editor10.LIP_ROLES) {
6174
+ for (const role of import_editor11.LIP_ROLES) {
6141
6175
  const fileName = `${role}.png`;
6142
6176
  const { rgba } = await decodePng(import_node_path7.default.join(absDir, fileName));
6143
6177
  set.set(role, measurer.add({ role, fileName, rgba }));
6144
6178
  for (let i = 0; i < rgba.length; i += 4) {
6145
- if (rgba[i + 3] >= import_editor10.ALPHA_OPAQUE && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > GREEN_EXCESS) {
6179
+ if (rgba[i + 3] >= import_editor11.ALPHA_OPAQUE && rgba[i + 1] - Math.max(rgba[i], rgba[i + 2]) > GREEN_EXCESS) {
6146
6180
  green.push(role);
6147
6181
  break;
6148
6182
  }
@@ -6150,15 +6184,15 @@ async function lipWarnings(absDir, layers, inPlace = false) {
6150
6184
  }
6151
6185
  let opening;
6152
6186
  try {
6153
- opening = (0, import_editor10.mouthOpening)(set);
6187
+ opening = (0, import_editor11.mouthOpening)(set);
6154
6188
  } catch (err) {
6155
- if (err instanceof import_editor10.LayerGeometryError) {
6189
+ if (err instanceof import_editor11.LayerGeometryError) {
6156
6190
  warnings.push(err.message);
6157
6191
  return { warnings };
6158
6192
  }
6159
6193
  throw err;
6160
6194
  }
6161
- const innerRuns = (0, import_editor10.columnRuns)(set.get("mouth_inner"));
6195
+ const innerRuns = (0, import_editor11.columnRuns)(set.get("mouth_inner"));
6162
6196
  const noInterior = [];
6163
6197
  const gap = [];
6164
6198
  const noLine = [];
@@ -6244,8 +6278,8 @@ async function lipWarnings(absDir, layers, inPlace = false) {
6244
6278
 
6245
6279
  // src/measure-turn.ts
6246
6280
  var import_node_path8 = __toESM(require("path"));
6247
- var import_editor11 = require("@ikijs/editor");
6248
6281
  var import_editor12 = require("@ikijs/editor");
6282
+ var import_editor13 = require("@ikijs/editor");
6249
6283
  var DEFAULT_IRIS = { hueMin: 230, hueMax: 300, satMin: 0.22 };
6250
6284
  var IRIS_V_MIN = 0.18;
6251
6285
  var IRIS_V_MAX = 0.95;
@@ -6395,7 +6429,7 @@ async function measureTurnImage(filePath, iris) {
6395
6429
  let transparent = false;
6396
6430
  if (hasAlpha) {
6397
6431
  for (let i = 0; i < n; i++) {
6398
- if (rgba[i * 4 + 3] < import_editor11.ALPHA_OPAQUE) {
6432
+ if (rgba[i * 4 + 3] < import_editor12.ALPHA_OPAQUE) {
6399
6433
  transparent = true;
6400
6434
  break;
6401
6435
  }
@@ -6406,7 +6440,7 @@ async function measureTurnImage(filePath, iris) {
6406
6440
  const fg = new Uint8Array(n);
6407
6441
  const value = new Float32Array(n);
6408
6442
  for (let i = 0; i < n; i++) {
6409
- if (rgba[i * 4 + 3] < import_editor11.ALPHA_OPAQUE) continue;
6443
+ if (rgba[i * 4 + 3] < import_editor12.ALPHA_OPAQUE) continue;
6410
6444
  const [hue, s, v] = rgbToHsv(rgba[i * 4], rgba[i * 4 + 1], rgba[i * 4 + 2]);
6411
6445
  if (maskMode === "alpha") {
6412
6446
  fg[i] = 1;
@@ -6472,12 +6506,12 @@ async function measureTurnImage(filePath, iris) {
6472
6506
  }
6473
6507
  const [irisL, irisR] = best.pair;
6474
6508
  const eyeRow = Math.round((irisL.cy + irisR.cy) / 2);
6475
- const { left, right } = (0, import_editor11.foregroundSpan)(
6509
+ const { left, right } = (0, import_editor12.foregroundSpan)(
6476
6510
  fg,
6477
6511
  width,
6478
6512
  height,
6479
- eyeRow - import_editor11.HEAD_BAND,
6480
- eyeRow + import_editor11.HEAD_BAND
6513
+ eyeRow - import_editor12.HEAD_BAND,
6514
+ eyeRow + import_editor12.HEAD_BAND
6481
6515
  );
6482
6516
  if (right <= left) {
6483
6517
  throw new AutoRigInputError(
@@ -6501,7 +6535,7 @@ async function measureTurnImage(filePath, iris) {
6501
6535
  left,
6502
6536
  right,
6503
6537
  cx: (left + right) / 2,
6504
- half: (0, import_editor11.headHalfOf)({ left, right })
6538
+ half: (0, import_editor12.headHalfOf)({ left, right })
6505
6539
  },
6506
6540
  pairCx: (irisL.cx + irisR.cx) / 2,
6507
6541
  eyeGap: irisR.cx - irisL.cx
@@ -6692,7 +6726,7 @@ function noseSpeckWarning({ core, part }, source) {
6692
6726
  `the layer's dense core is ${core.w}x${core.h} in its ${part.w}x${part.h} crop`,
6693
6727
  `auto_rig_from_layers turns and tilts the nose about its whole crop instead`
6694
6728
  ];
6695
- return `nose: ${found} \u2014 under ${import_editor12.SPECK_CORE_FRACTION} of its width or height, a speck: a lone nostril mark or highlight at alpha >= 128, not the drawing, so ${consequence}. Regenerate the nose with its shading painted denser, so the drawing itself reaches alpha 128. Billed.`;
6729
+ return `nose: ${found} \u2014 under ${import_editor13.SPECK_CORE_FRACTION} of its width or height, a speck: a lone nostril mark or highlight at alpha >= 128, not the drawing, so ${consequence}. Regenerate the nose with its shading painted denser, so the drawing itself reaches alpha 128. Billed.`;
6696
6730
  }
6697
6731
  async function lashOffSclera(eyePath, lashPath) {
6698
6732
  const eye2 = await decodePng(eyePath);
@@ -6830,10 +6864,10 @@ async function measureDir(absDir, noseSpeck, { inPlace = false } = {}) {
6830
6864
  warnings.push(noseSpeckWarning(noseSpeck, "compose"));
6831
6865
  } else if (!inPlace && layers.nose !== void 0) {
6832
6866
  const nose = await decodePng(import_node_path9.default.join(absDir, "nose.png"));
6833
- const core = (0, import_editor12.denseCoreOf)(nose.rgba, nose.width, nose.height);
6867
+ const core = (0, import_editor13.denseCoreOf)(nose.rgba, nose.width, nose.height);
6834
6868
  if (core !== null) {
6835
6869
  const crop = detectAlphaBbox(nose.rgba, nose.width, nose.height);
6836
- if ((0, import_editor12.isSpeckCore)(core, crop))
6870
+ if ((0, import_editor13.isSpeckCore)(core, crop))
6837
6871
  warnings.push(noseSpeckWarning({ core, part: crop }, "layer"));
6838
6872
  }
6839
6873
  }
@@ -6903,12 +6937,12 @@ function formatMeasureReport(result) {
6903
6937
 
6904
6938
  // src/compose-arms.ts
6905
6939
  var import_sharp3 = __toESM(require("sharp"));
6906
- var import_editor13 = require("@ikijs/editor");
6940
+ var import_editor14 = require("@ikijs/editor");
6907
6941
  var ARM_WIDTH = 0.4;
6908
6942
  var SHOULDER_DROP = 0.12;
6909
6943
  async function armPlacement(role, cfg, part, body) {
6910
6944
  const { data } = await (0, import_sharp3.default)(part.buf).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
6911
- const layer = (0, import_editor13.createLayerSetMeasurer)({ width: part.w, height: part.h }).add({
6945
+ const layer = (0, import_editor14.createLayerSetMeasurer)({ width: part.w, height: part.h }).add({
6912
6946
  role,
6913
6947
  fileName: "arm.png",
6914
6948
  rgba: data
@@ -6920,9 +6954,9 @@ async function armPlacement(role, cfg, part, body) {
6920
6954
  }
6921
6955
  let g;
6922
6956
  try {
6923
- g = (0, import_editor13.armGeometry)(layer, role === "arm_R" ? Infinity : -Infinity);
6957
+ g = (0, import_editor14.armGeometry)(layer, role === "arm_R" ? Infinity : -Infinity);
6924
6958
  } catch (err) {
6925
- if (err instanceof import_editor13.LayerGeometryError) {
6959
+ if (err instanceof import_editor14.LayerGeometryError) {
6926
6960
  throw new AutoRigInputError(`layout.${role}: ${err.message}`);
6927
6961
  }
6928
6962
  throw err;
@@ -6949,7 +6983,7 @@ async function armPlacement(role, cfg, part, body) {
6949
6983
  }
6950
6984
  async function poseGeometryOf(role, png, size, when) {
6951
6985
  const { data } = await (0, import_sharp3.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
6952
- const layer = (0, import_editor13.createLayerSetMeasurer)({
6986
+ const layer = (0, import_editor14.createLayerSetMeasurer)({
6953
6987
  width: size.w,
6954
6988
  height: size.h
6955
6989
  }).add({ role, fileName: "forearm_pose.png", rgba: data });
@@ -6958,7 +6992,7 @@ async function poseGeometryOf(role, png, size, when) {
6958
6992
  `layout.${role}: forearm_pose.png is empty after alpha threshold${when}`
6959
6993
  );
6960
6994
  }
6961
- return (0, import_editor13.forearmPoseGeometry)(layer);
6995
+ return (0, import_editor14.forearmPoseGeometry)(layer);
6962
6996
  }
6963
6997
  async function forearmPoseWidth(role, trimmed, elbowRun) {
6964
6998
  const g = await poseGeometryOf(role, trimmed.data, trimmed, "");
@@ -7256,18 +7290,18 @@ function keyWhiteToAlpha(rgba) {
7256
7290
  async function coreAndBoundsOf(png) {
7257
7291
  const { data, info } = await (0, import_sharp4.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
7258
7292
  return {
7259
- core: (0, import_editor12.denseCoreOf)(data, info.width, info.height),
7293
+ core: (0, import_editor13.denseCoreOf)(data, info.width, info.height),
7260
7294
  bounds: { x: 0, y: 0, w: info.width, h: info.height }
7261
7295
  };
7262
7296
  }
7263
7297
  async function hasCoverage(png) {
7264
7298
  const { data, info } = await (0, import_sharp4.default)(png).ensureAlpha().raw().toBuffer({ resolveWithObject: true });
7265
- return (0, import_editor14.detectAlphaBbox)(data, info.width, info.height) !== null;
7299
+ return (0, import_editor15.detectAlphaBbox)(data, info.width, info.height) !== null;
7266
7300
  }
7267
7301
  async function noseSizingOf(png) {
7268
7302
  const { core, bounds: bounds2 } = await coreAndBoundsOf(png);
7269
7303
  if (core === null) return { box: bounds2, whole: true };
7270
- if ((0, import_editor12.isSpeckCore)(core, bounds2)) {
7304
+ if ((0, import_editor13.isSpeckCore)(core, bounds2)) {
7271
7305
  return {
7272
7306
  box: bounds2,
7273
7307
  whole: true,
@@ -7389,7 +7423,7 @@ function detachedAboveWhite(rgba, W, H) {
7389
7423
  for (let p = 0; p < n; p++) {
7390
7424
  const alpha = rgba[p * 4 + 3];
7391
7425
  if (alpha > 0 && luma(rgba, p * 4) >= EYE_LASH_LUMA)
7392
- ink[p] = alpha >= import_editor14.ALPHA_OPAQUE ? 2 : 1;
7426
+ ink[p] = alpha >= import_editor15.ALPHA_OPAQUE ? 2 : 1;
7393
7427
  }
7394
7428
  const label = new Int32Array(n).fill(-1);
7395
7429
  const stack = new Int32Array(n);
@@ -7494,7 +7528,7 @@ async function prepEyeSplit(partsDir) {
7494
7528
  const lashCutoffY = minY + LASH_KEEP_FRACTION * (maxY - minY + 1);
7495
7529
  const detached = detachedAboveWhite(data, W, H);
7496
7530
  const isDark = (i) => data[i + 3] > 0 && luma(data, i) < EYE_LASH_LUMA;
7497
- const isLight = (i) => data[i + 3] >= import_editor14.ALPHA_OPAQUE && luma(data, i) >= EYE_LASH_LUMA;
7531
+ const isLight = (i) => data[i + 3] >= import_editor15.ALPHA_OPAQUE && luma(data, i) >= EYE_LASH_LUMA;
7498
7532
  const isWarm = (i) => data[i] - data[i + 2] >= EYE_LID_WARMTH;
7499
7533
  const whiteTop = new Int32Array(W).fill(-1);
7500
7534
  for (let x = 0; x < W; x++) {
@@ -7675,7 +7709,7 @@ async function composeLayersFromParts(input) {
7675
7709
  lip_lower: split2.lower,
7676
7710
  lip_upper: split2.upper
7677
7711
  }[role];
7678
- if ((0, import_editor14.isLipInsideRole)(role) && !await hasCoverage(buf)) {
7712
+ if ((0, import_editor15.isLipInsideRole)(role) && !await hasCoverage(buf)) {
7679
7713
  skipped.push(role);
7680
7714
  continue;
7681
7715
  }
@@ -7870,7 +7904,7 @@ async function composeLayersFromParts(input) {
7870
7904
  });
7871
7905
  }
7872
7906
  const restInput = (role, buf) => {
7873
- if (role === "mouth_inner" || (0, import_editor14.isLipInsideRole)(role)) return null;
7907
+ if (role === "mouth_inner" || (0, import_editor15.isLipInsideRole)(role)) return null;
7874
7908
  if (closed === void 0) return buf;
7875
7909
  if (role === "lip_upper") return closed.upper;
7876
7910
  if (role === "lip_lower") return closed.lower;
@@ -9765,6 +9799,7 @@ var IRIS_IOU = 0.7;
9765
9799
  var DISC_CLOSE = 2;
9766
9800
  var IRIS_MARGIN = 0.25;
9767
9801
  var LID_SIDE = 4;
9802
+ var LID_STREAK = 6;
9768
9803
  var EYE_EDGE = 2;
9769
9804
  var OPENING_SPARE = 2;
9770
9805
  var STROKE_PAST_SHARE = 0.5;
@@ -10091,35 +10126,85 @@ function lashCutOf(pic, all) {
10091
10126
  function upperLid(pic, f, eye2, c) {
10092
10127
  const { width } = pic;
10093
10128
  const { b, cx, cy, rx } = f;
10129
+ const mid = Math.min(b.y1, Math.floor(cy));
10094
10130
  const lid = new Int32Array(width).fill(-1);
10095
- const lashTop = new Int32Array(width).fill(-1);
10131
+ const dark = (x, y) => {
10132
+ const i = y * width + x;
10133
+ return eye2[i] === 1 && c.dark(i);
10134
+ };
10135
+ const ink = (x, y) => dark(x, y) && !c.nearIris(y * width + x);
10136
+ const softTop = (x, top) => {
10137
+ let y = top;
10138
+ while (y - 1 >= b.y0 && top - (y - 1) <= EYE_EDGE && dark(x, y - 1)) y--;
10139
+ return y;
10140
+ };
10141
+ const runEnd = (x, y, step) => {
10142
+ const inside = (r) => r >= b.y0 && r <= mid;
10143
+ for (; ; ) {
10144
+ while (inside(y + step) && ink(x, y + step)) y += step;
10145
+ let rows = 0;
10146
+ while (rows <= LID_STREAK) {
10147
+ const r = y + step * (rows + 1);
10148
+ if (!inside(r) || !dark(x, r) || ink(x, r)) break;
10149
+ rows++;
10150
+ }
10151
+ const next = y + step * (rows + 1);
10152
+ if (rows === 0 || rows > LID_STREAK || !inside(next) || !ink(x, next)) {
10153
+ return y;
10154
+ }
10155
+ y = next;
10156
+ }
10157
+ };
10158
+ const fromTop = (x) => {
10159
+ let run2 = null;
10160
+ let skin = false;
10161
+ for (let y = b.y0; y <= mid; y++) {
10162
+ if (!ink(x, y)) {
10163
+ if (eye2[y * width + x] === 0) skin = true;
10164
+ continue;
10165
+ }
10166
+ if (run2 !== null && !skin) break;
10167
+ const top = y;
10168
+ y = runEnd(x, y, 1);
10169
+ run2 = [softTop(x, top), y];
10170
+ skin = false;
10171
+ }
10172
+ return run2;
10173
+ };
10174
+ const fromInside = (x) => {
10175
+ let y = mid;
10176
+ if (ink(x, y)) return null;
10177
+ while (y >= b.y0 && !ink(x, y)) y--;
10178
+ if (y < b.y0) return null;
10179
+ return [softTop(x, runEnd(x, y, -1)), y];
10180
+ };
10181
+ const x0 = Math.max(b.x0, Math.ceil(cx - rx));
10182
+ const x1 = Math.min(b.x1, Math.floor(cx + rx));
10096
10183
  for (let x = b.x0; x <= b.x1; x++) {
10097
- const at = (y2) => y2 * width + x;
10098
- const lashInk = (y2) => eye2[at(y2)] === 1 && c.dark(at(y2)) && !c.nearIris(at(y2));
10099
- let y = b.y0;
10100
- while (y <= b.y1 && !(eye2[at(y)] && c.dark(at(y)))) y++;
10101
- const first = y;
10102
- while (y <= b.y1 && y - first < EYE_EDGE && !lashInk(y)) y++;
10103
- if (y > b.y1 || y >= cy || !lashInk(y)) continue;
10104
- lashTop[x] = first;
10105
- while (y + 1 <= Math.min(b.y1, Math.floor(cy)) && lashInk(y + 1)) y++;
10106
- lid[x] = y;
10184
+ if (x >= x0 && x <= x1) continue;
10185
+ const run2 = fromInside(x) ?? fromTop(x);
10186
+ if (run2) lid[x] = run2[1];
10107
10187
  }
10108
10188
  const thickness = (from, step) => {
10109
10189
  const t = [];
10110
10190
  for (let x = from; t.length < LID_SIDE && x >= b.x0 && x <= b.x1; x += step) {
10111
- if (lashTop[x] >= 0) t.push(lid[x] - lashTop[x] + 1);
10191
+ const run2 = fromInside(x) ?? fromTop(x);
10192
+ if (run2) t.push(run2[1] - run2[0] + 1);
10112
10193
  }
10113
10194
  return t.length > 0 ? median(t) : null;
10114
10195
  };
10115
10196
  const left = thickness(Math.floor(cx - rx) - 1, -1);
10116
10197
  const right = thickness(Math.ceil(cx + rx) + 1, 1);
10117
- if (left === null && right === null) return lid;
10118
- for (let x = Math.ceil(cx - rx); x <= Math.floor(cx + rx); x++) {
10119
- if (x < b.x0 || x > b.x1 || lashTop[x] < 0) continue;
10198
+ for (let x = x0; x <= x1; x++) {
10199
+ const run2 = fromTop(x);
10200
+ if (!run2) continue;
10201
+ if (left === null && right === null) {
10202
+ lid[x] = run2[1];
10203
+ continue;
10204
+ }
10120
10205
  const u = (x - (cx - rx)) / (2 * rx);
10121
10206
  const t = left === null ? right : right === null ? left : left + (right - left) * u;
10122
- lid[x] = Math.min(lid[x], lashTop[x] + Math.round(t) - 1);
10207
+ lid[x] = Math.min(run2[1], run2[0] + Math.round(t) - 1);
10123
10208
  }
10124
10209
  return lid;
10125
10210
  }
@@ -10143,9 +10228,12 @@ function lowerLidAcross(pic, f, eye2, c, lashCut, upper) {
10143
10228
  const runs = [];
10144
10229
  for (let k = 0; k < LID_SIDE; k++) {
10145
10230
  const x = from + k * step;
10146
- if (x < b.x0 || x > b.x1) break;
10147
- const run2 = runAt(x);
10148
- if (run2) runs.push(run2);
10231
+ const run2 = x < b.x0 || x > b.x1 ? null : runAt(x);
10232
+ const prev = runs[runs.length - 1];
10233
+ if (!run2 || prev && (run2[0] > prev[1] + LID_DRIFT || run2[1] < prev[0] - LID_DRIFT)) {
10234
+ return [];
10235
+ }
10236
+ runs.push(run2);
10149
10237
  }
10150
10238
  return runs;
10151
10239
  };
@@ -11008,7 +11096,7 @@ function cutFeatures(ctx, lipSet = false) {
11008
11096
  }
11009
11097
 
11010
11098
  // src/illustration-landmarks.ts
11011
- var import_editor15 = require("@ikijs/editor");
11099
+ var import_editor16 = require("@ikijs/editor");
11012
11100
  var DEFAULT_BROW_HALF_WIDTH = 8;
11013
11101
  var DEFAULT_BROW_TAIL_HALF_WIDTH = 5;
11014
11102
  var KEYS = {
@@ -11162,11 +11250,11 @@ function brow(path12, v, canvas) {
11162
11250
  tailHalfWidth: o.tailHalfWidth === void 0 ? DEFAULT_BROW_TAIL_HALF_WIDTH : positive(`${path12}.tailHalfWidth`, o.tailHalfWidth)
11163
11251
  };
11164
11252
  }
11165
- var YIELDED_PART_IDS = new Set(ARM_ROLES.flatMap((r) => (0, import_editor15.partIdsOfRole)(r)));
11253
+ var YIELDED_PART_IDS = new Set(ARM_ROLES.flatMap((r) => (0, import_editor16.partIdsOfRole)(r)));
11166
11254
  function isReservedId(id) {
11167
11255
  if (YIELDED_PART_IDS.has(id)) return true;
11168
11256
  try {
11169
- (0, import_editor15.partIdsOfRole)(id);
11257
+ (0, import_editor16.partIdsOfRole)(id);
11170
11258
  return true;
11171
11259
  } catch {
11172
11260
  return false;
@@ -12520,6 +12608,7 @@ function formatCutReport(r) {
12520
12608
  // src/server.ts
12521
12609
  var import_mcp = require("@modelcontextprotocol/sdk/server/mcp.js");
12522
12610
  var import_zod = require("zod");
12611
+ var import_format13 = require("@ikijs/format");
12523
12612
  function formatPatchReports(reports) {
12524
12613
  return reports.map((r) => {
12525
12614
  const at = Object.keys(r.at).sort().map((p) => `${p}=${r.at[p]}`).join(" ");
@@ -12541,7 +12630,7 @@ function formatBakeChecks(bakes) {
12541
12630
  );
12542
12631
  }
12543
12632
  function createIkiMcpServer() {
12544
- const server = new import_mcp.McpServer({ name: "iki", version: "0.38.1" });
12633
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.39.0" });
12545
12634
  server.registerTool(
12546
12635
  "validate_iki",
12547
12636
  {
@@ -12568,7 +12657,7 @@ function createIkiMcpServer() {
12568
12657
  server.registerTool(
12569
12658
  "describe_iki",
12570
12659
  {
12571
- description: "Summarizes a valid model's canvas/params/parts/deformers and its expressions and motion clips (with the descriptions a host picks them by); returns an error for an invalid model. It is also the patch writer's view of a rigged model: each part's rest box in model px and in bust-render px, each part's warp stops, each warp2d's stops, and faceWidth, which is what an auto_rig_from_layers `patches` op is aimed with. Pass exactly one of model or modelPath; prefer modelPath for a written rig so a large model never crosses your context.",
12660
+ description: "Summarizes a valid model's canvas/params/parts/deformers and its expressions and motion clips (with the descriptions a host picks them by), and its `generator` (what wrote it: tool, rigger and plugin, each name@version) when it records one; returns an error for an invalid model. It is also the patch writer's view of a rigged model: each part's rest box in model px and in bust-render px, each part's warp stops, each warp2d's stops, and faceWidth, which is what an auto_rig_from_layers `patches` op is aimed with. Pass exactly one of model or modelPath; prefer modelPath for a written rig so a large model never crosses your context.",
12572
12661
  inputSchema: {
12573
12662
  model: import_zod.z.unknown().optional().describe("Raw .iki model JSON (object or JSON string)"),
12574
12663
  modelPath: import_zod.z.string().optional().describe(
@@ -12633,7 +12722,7 @@ function createIkiMcpServer() {
12633
12722
  server.registerTool(
12634
12723
  "auto_rig_from_layers",
12635
12724
  {
12636
- description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, hair_side_L/hair_side_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, a side lock needs hair_front, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `RIGPLAN:` line (the result's `rigPlan`: `effective`, `clamped`, `overriddenBy`) follows the path and precedes the `PATCH` lines. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. With side locks and a `nose` (which `turn` needs) the `HAIRSIDE` lines follow the `PHYSICS` lines (the result's `turn.hairSide`), each naming the lock's role, report-only as well. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. A part can declare `occlusion` (hidden where named roles' paint covers it, by an amount keyed on a parameter; it needs 0.35.0, and an older server refuses the key as `INVALID: customParts[i]\u2026`); its `CUSTOM <id>:` line then ends `, hidden by <id>,<id>\u2026 on <parameter> at <value>:<amount> <value>:<amount>\u2026`, and the result's part carries `occlusion` (`by` as the part ids written, `parameter`, `stops`). The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error.",
12725
+ description: "Auto-rigs role-named PNG layers (face, eye_L/eye_R and either mouth or the lip set (mouth_inner + lip_lower + lip_upper, a mouth that folds open instead of crossfading) required; iris_L/R, brow_L/R, hair_front, body, arm_L/arm_R, forearm_pose_L/forearm_pose_R, hair_side_L/hair_side_R, mouth_tongue/mouth_teeth (only with the lip set: drawn under its lips and clipped to mouth_inner), etc. optional; an arm needs the body, a pose forearm needs its arm, a side lock needs hair_front, and a partial lip set, one mixed with mouth/mouth_open, or mouth_tongue/mouth_teeth without it is refused) into a renderable .iki written to disk. Pass full-canvas PNG file paths; returns the output path + summary (the model is NOT inlined). Filenames map to roles unless `fileName` is given. The result's `folds` is the written rig's fold report, printed after the path the way render_poses prints it, and report-only: a fold never refuses the rig. The `RIGPLAN:` line (the result's `rigPlan`: `effective`, `clamped`, `overriddenBy`) follows the path and precedes the `PATCH` lines. The `PHYSICS` lines follow the fold report (the result's `physics`), one per physics rig output \u2014 a spring's, or each chain segment's \u2014 reading ok, frozen or unstable with the step and idle amplitudes, or `PHYSICS: no rigs`; report-only too. With side locks and a `nose` (which `turn` needs) the `HAIRSIDE` lines follow the `PHYSICS` lines (the result's `turn.hairSide`), each naming the lock's role, report-only as well. `patches` (see its field) adds displacements to existing keyform stops of the freshly generated rig; each op then prints one line between the path and the fold report \u2014 `PATCH <i> <target> at <Param=v \u2026>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px`, with `(vertices)` in place of the columns and rows for a mesh part \u2014 and the result's `patches` carries the same reports (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`), present whenever `patches` was passed, `[]` included. An op the input schema accepts but the rig refuses comes back as `INVALID: patches[i]\u2026` and nothing is written; an op with a missing field or a field of the wrong type is the SDK's input validation error. `customParts` adds parts the rig has no role for (a twin tail, a hairpin), each from a canvas-sized PNG of its own, as an unrigged mesh on `headDeformer` after its `after` role's parts; it needs @ikijs/mcp 0.34.0, and an older server drops the field and returns no `customParts`. A part can declare `occlusion` (hidden where named roles' paint covers it, by an amount keyed on a parameter; it needs 0.35.0, and an older server refuses the key as `INVALID: customParts[i]\u2026`); its `CUSTOM <id>:` line then ends `, hidden by <id>,<id>\u2026 on <parameter> at <value>:<amount> <value>:<amount>\u2026`, and the result's part carries `occlusion` (`by` as the part ids written, `parameter`, `stops`). The result's `customParts` (`parts`: `id`, rest `box`, `mesh`, `order`, atlas `page`) is present whenever the input was passed, `[]` included, and one `CUSTOM <id>: \u2026` line per part follows the `HAIRSIDE` lines. `bakes` (see its field) moves the custom parts with a parameter and needs `customParts`; each part and parameter it moves then prints one `BAKE <part> <param>: <n> vertices, stops <values>, error <px> px` line after the `CUSTOM` lines (the result's `customParts.bakes`: `part`, `param`, `vertices`, `stops`, `errorPx`), the written model having been landed through the engine, and a stop off by 0.1 px or more comes back as `INVALID: BAKE ERROR <part> <param>=<value>: \u2026`, and a part the bake moves at rest as `INVALID: BAKE ERROR <part> at rest: \u2026`, with nothing written (the rig and the engine disagree: report it as a bug in the packages). Whenever `customParts` was passed, the written model is also measured per custom part (the result's `customParts.gate`: `ok`, `limits`, `parts`, `failed`) and the text ends with its lines, `CUSTOM <id> FOLDS|TIE|SLIDE|EXPOSED|RIGID|TIP: \u2026` then `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, \u2026>`, always the last line: a part's least triangle area ratio, its tie's displacement against the anchor where the head does not turn and where it does, the hidden art showing, how far a rigid part bends and where its free end lands, each in px and face widths with its worst pose; `TIP` never fails the gate and the other lines do. The model is written either way; from 0.34.0 on `customParts` always carries `gate` (a gate that throws still writes the file and ends the text `CUSTOM GATE FAIL: gate error: <message>`), so a result without `customParts` is from an older server and was never gated. The custom layers are not role layers: they are left out of the head's width and turn measurements, and an empty or wrong-size one, or an entry the rig refuses, comes back as `INVALID: customParts[i]\u2026` with nothing written. A missing field or one of the wrong type (a `tie` that is not two numbers, say) is refused by the schema itself, as the SDK's input validation error. The written model records what made it as `generator`: this server and the auto-rigger, each name@version, and the plugin named in the server's IKI_PLUGIN environment variable, if any; it is no input.",
12637
12726
  inputSchema: {
12638
12727
  layers: import_zod.z.array(
12639
12728
  import_zod.z.object({
@@ -12701,7 +12790,7 @@ function createIkiMcpServer() {
12701
12790
  ),
12702
12791
  occlusion: import_zod.z.object({
12703
12792
  by: import_zod.z.array(import_zod.z.string()).describe(
12704
- "Roles of the set whose paint hides the part (an arm role is its three parts); a non-empty list with no role repeated, each a role of the set. A role with a clipped or meshless part (`iris_L`, `forearm_pose_L`) is refused."
12793
+ "Roles of the set whose paint hides the part (an arm role is its three parts); a non-empty list with no role repeated, each a role of the set. A role with a clipped or meshless part (`iris_L`, a brow drawn on the face, `forearm_pose_L`) is refused."
12705
12794
  ),
12706
12795
  parameter: import_zod.z.string().describe(
12707
12796
  "Any declared parameter but a physics output (a spring's or a chain segment's)."
@@ -12777,8 +12866,19 @@ function createIkiMcpServer() {
12777
12866
  },
12778
12867
  async (args) => {
12779
12868
  try {
12869
+ let generator;
12870
+ try {
12871
+ generator = toolGenerator();
12872
+ } catch (e) {
12873
+ if (!(e instanceof import_format13.IkiFormatError)) throw e;
12874
+ return {
12875
+ content: [{ type: "text", text: `INVALID: ${e.message}` }],
12876
+ structuredContent: { ok: false, error: e.message }
12877
+ };
12878
+ }
12780
12879
  const r = await autoRigFromLayers({
12781
12880
  ...args,
12881
+ generator,
12782
12882
  // `.length(2)` makes each region span a pair, which its inferred
12783
12883
  // `number[]` cannot say.
12784
12884
  patches: args.patches,
@@ -13193,6 +13293,7 @@ crop ${r.crop.x},${r.crop.y} ${r.crop.w}x${r.crop.h} on the ${r.canvas.width}x${
13193
13293
  // Annotate the CommonJS export names for ESM import in node:
13194
13294
  0 && (module.exports = {
13195
13295
  CUSTOM_GATE_LIMITS,
13296
+ PLUGIN_ENV,
13196
13297
  SWEEP_PRESETS,
13197
13298
  autoRigFromLayers,
13198
13299
  checkCustomGate,
@@ -13221,6 +13322,7 @@ crop ${r.crop.x},${r.crop.y} ${r.crop.w}x${r.crop.h} on the ${r.canvas.width}x${
13221
13322
  measureTurnReference,
13222
13323
  probeRig,
13223
13324
  renderPoses,
13325
+ toolGenerator,
13224
13326
  validateIki,
13225
13327
  viewIllustrationGrid
13226
13328
  });