@ikijs/mcp 0.28.0 → 0.30.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/README.md CHANGED
@@ -11,6 +11,7 @@ A stdio [MCP](https://modelcontextprotocol.io/) server that exposes `.iki` model
11
11
  | `validate_iki` | Validate a raw `.iki` model — accepts an object or a JSON string — fail-fast, one error at a time. |
12
12
  | `describe_iki` | Return a summary of a valid model (inline or by `modelPath`): canvas, parameters, parts, deformers, expressions, motions. |
13
13
  | `list_standard_parameters` | List the recommended standard parameter ids (e.g. `ParamAngleX`, `ParamMouthOpenY`) with descriptions. |
14
+ | `describe_rig_plan` | List the fields of `auto_rig_from_layers`'s `rigPlan` with their defaults, ranges, recommended spans, steps and poses. |
14
15
  | `auto_rig_from_layers` | Auto-rig role-named PNG layers into a renderable `.iki` written to disk; returns the output path. |
15
16
  | `compose_layers_from_parts` | Compose generated part PNGs into canvas-aligned, role-named layers, with the geometry report inline. |
16
17
  | `measure_layers` | Re-run that same geometry report over an already-composed layers directory. |
@@ -26,9 +27,9 @@ Turns a set of role-named, full-canvas transparent PNG layers into a renderable,
26
27
  - **`layers`** — array of `{ path, fileName? }`. `path` is a PNG file path (resolved against the server's working directory); the role is derived from `fileName ?? basename(path)`. Required roles: `face`, `eye_L`, `eye_R`, and `mouth` or the lip set `mouth_inner`, `lip_lower`, `lip_upper` (a mouth that folds open instead of crossfading; a partial lip set, or one mixed with `mouth`/`mouth_open`, is refused). `mouth_tongue` / `mouth_teeth` are optional with the lip set only: drawn under its lips and clipped to `mouth_inner`, the teeth riding the upper line and the tongue the opening's bottom; without the set they are refused. Optional roles include `iris_L`/`iris_R`, `brow_L`/`brow_R`, `hair_front`/`hair_back`, `lash_L`/`lash_R`, `lash_lower_L`/`lash_lower_R`, `body`, `arm_L`/`arm_R`, `forearm_pose_L`/`forearm_pose_R`, etc. An arm — the whole arm drawn hanging, its shoulder at the top — needs the `body` (it hangs from the body's shoulder) and becomes an elbow cap, an upper arm and a forearm sharing its crop, on `ParamArmL/R` (the shoulder) and `ParamElbowL/R`. A pose forearm — the forearm raised, standing up from its elbow — needs its arm: it hangs from the arm's elbow and is swapped in for the hanging forearm by `ParamArmPoseL/R`, rocked by `ParamArmPoseAngleL/R`, and drawn above the face and the hair. All layers must share the same canvas size (taken from the first layer).
27
28
  - **`outputPath`** — optional `.iki` output path (resolved against the working directory; the parent directory must already exist, and the path must end in `.iki`). Defaults to `auto-rigged-model.iki`.
28
29
  - **`turnTargets`** — optional head-turn cues to fit the rig to, in the units `measure_turn_reference` reports off a front/turned reference pair: `eyeShift` (plus `noseShift` and `mouthShift`) is how far that feature slides across the head at full turn, as a fraction of the head's half-width — a **magnitude**, since the rig turns both ways and the sign is the turn's own business; `farEyeRatio` is the far/near eye width at full turn over that same ratio at rest; `silhouetteRatio` the head's half-width turned over at rest. An omitted field leaves that part of the turn at the profile the rig defaults to. An `eyeShift` you pass is fitted by the turn's amount and _clamped_ when it runs past the room the art leaves the far eye — the face plate's edge, or the bangs' side strand over the far iris — since that room is a fact about these layers, not about the reference. Any other target you **do** pass that it cannot reach is refused, because that number is a measurement rather than a preference. A layer set without a `nose` still turns its head, on the profile, but fits no target: `turnTargets` is then inert and the result carries no `turn`.
29
- - **`style`** — optional per-character tuning from the profile the rig defaults to: `turn` (the whole head turn, the eyes' foreshortening with it, 0..3, 1 = the profile; ignored when `turnTargets.eyeShift` is given), `featureLead` (how far the features lead the face plate, 0..3), `hairFollow` (the front hair's share of the face's turn, 0..2, profile 1), `outlineFollow` (its outer edge's share where it draws the head's outline, 0..2, profile 0: the outline holds), `blink` (how far the upper lid comes down over the eye's height, 0.1..1, profile 0.6) and `sway` (the hair sway amplitude, 0..5). A value out of range, or a knob not named here, is refused.
30
- - **`patches`** — optional displacements added to existing keyform stops of the freshly generated rig, each `{ target, at, region, by, falloff?, why? }` (`RigPatch` in `@ikijs/editor`). `target` is a feature grid (`eyeWarp_L`/`_R`, `browWarp_L`/`_R`, `noseWarp`, `mouthWarp`; `at` names `ParamAngleX` and `ParamAngleY`, each −30, 0 or 30, never both 0) or a mesh part with warps (`face`, `hair_front`, …; `at` names one parameter at one of its warp stops). `region` is a rectangle in fractions of a role's rest layer box (top-left origin, y down); `by` and `falloff` are in face widths on screen axes (+dx right, +dy down). They are replayed on every rig of these inputs, so they hold through a layout or `style` retune, and they never touch the rest stop or a stop where the rig shuts a part on purpose; `bodyWarp` and the matrix deformers are not targets. Aim them with `describe_iki`.
31
- - **Result** — on success the result text is the written file path, then one `PATCH <i> <target> at <Param=v …>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px` line per patch op (`(vertices)` in place of the columns and rows for a mesh part), then the rig's fold report lines and its `PHYSICS` lines (as `render_poses` prints them), and `structuredContent` carries `{ ok: true, path, canvas, partCount, atlasBytes, headHalfWidth?, headHalfWidthApplied, headEdges?, strandEdges?, noseCore?, turn?, patches?, folds, physics }`. `patches` is what each op moved (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`) and is present whenever `patches` was passed, `[]` included. `atlasBytes` is the embedded atlas's data-URI length, summed over both pages when the nose has one of its own. `headHalfWidth` is the head measured here rather than asked for: the layers' own opaque union at the eye row, under the same `alpha >= 128` rule and ±10-row band `measure_turn_reference` spans a render with, so the rig's own rest render measures that span back; it is **absent** when that union has no span there at all (translucent art painted below alpha 128 — still a valid layer set, just with nothing to measure). `headHalfWidthApplied` is `false` when the measured value is absent, or no wider than the face plate (a hairless set, or one widest at the plate itself) — the generator will not take such a head, so the plate stands in for it and the rig is still produced either way. `headEdges` is a companion to a measured, applied `headHalfWidth` (absent otherwise): every role with an opaque pixel in that same eye-row band, per side, each with its own rest x there — passed straight to the generator's own `options.headEdges` so it can tell which part's own deformation actually carries the union's outermost pixel through the turn. `strandEdges` is each side's iris and the `hair_front` run it would slide under on the turn, measured whenever the layers include `hair_front`, `iris_L` and `iris_R`: the iris's opaque span and the run's outer and face-side ends as pixel edges on the row holding the iris's centre (a run that reaches the other iris's centre, a fringe spanning the face, has `runFace: null`; a run narrower than half the iris's painted width on that row is hair detail the iris may cross, and is skipped as if clear) — passed straight to the generator's own `options.strandEdges`, which keeps the far iris from sliding under the bangs any further than it is painted. `turn` is what the solve settled on — `{ radius, holdBase, depths, achieved: { eyeShift, farEyeRatio, silhouetteRatio }, clamped, strandOverlap? }`, where `achieved` is what the rig does reach and `clamped` names every target the rig cut down: the turn (`eyeShift`, passed or the profile's own) where the face plate's edge or the strand cut it short, and a profile `noseShift` / `mouthShift` past its room. `strandOverlap` gives, per side whose far iris the bangs still cover at some far stop, the covered width — how much of the iris's painted row the run covers where that is largest (`deg`, `px`, and `hh` in head half-widths), how much it covers at rest (`restPx`), and whether the bound held (`held`: `true` means the iris is kept no deeper under the run than it is painted; `false` means the art left no room to — always so for a fringe spanning the face — and `px` is what stays covered); it is absent when nothing is covered. `noseCore` is the nose's dense core in canvas px — its pixels at alpha >= 128, not grown, the box handed to the generator as the nose layer's `denseCore` and its turn landmark — absent without a `nose` layer, when it has no pixel at that threshold (painted wholly translucent), or when that core is a speck of the nose's crop (under a quarter of its width or height, such as a lone nostril mark), and in both of the last two cases the crop stands in for it. `turn` is absent without a `nose` layer. `folds` is the written model's fold report, the engine's `checkFolds` over its own pose set (`{ poses, thresholds, targets, offenders }`, described under `render_poses`); it never refuses a rig — a model that folds is still written and returned — and each fold names its pose by its parameter settings, which a host reproduces by setting those parameters on a player (`IkiPlayer.setParameter`). `physics` is the written model's physics report, the engine's `checkPhysics` over its rigs (`{ thresholds, targets, offenders }`, described under `render_poses`) — the two hair-sway springs a `hair_front` layer brings, or none — and never refuses a rig either. The (potentially multi-MB) model is written to disk, not inlined. Invalid input (a `patches` op the rig refuses — `INVALID: patches[i]…`, naming the stops, targets or roles there are; unknown/missing role, an arm without a `body`, empty layer, mismatched sizes, bad path, an atlas page over 4096 px on a side, or an atlas over 12 MiB; art the rig cannot build on, such as a body's hips with no room under its pivots for a row line or for the body's motion, or an arm too short to hang an elbow under its shoulder; a `turnTargets` field that is unknown or that this layer set cannot reach — any passed field other than an `eyeShift` past the art's room; a `style` knob out of range or unknown; the message names the field and the attainable range) returns `{ ok: false, error }` with a `INVALID: …` text — not a protocol error. An argument the tool's input schema refuses — a `turnTargets` or `style` that is not an object, or one of their named fields that is not a number — never reaches the tool: the MCP SDK answers with an `isError` result whose text is `MCP error -32602: Input validation error: …`, and no `structuredContent`.
30
+ - **`rigPlan`** — optional per-character tuning from the profile the rig defaults to, in three groups: `turn` (`amount`: the whole head turn, ignored when `turnTargets.eyeShift` is given; `featureLead`: how far the features lead the face plate; `eyeForeshorten`: how much the far eye narrows on the turn, ignored when `turnTargets.farEyeRatio` is given; `noseLead`: how far the nose leads the plate on the turn, never the nod, ignored when `turnTargets.noseShift` is given — the last two have provisional recommended spans), `hair` (`follow`: the front hair's share of the face's turn; `outlineFollow`: its outer edge's share where it draws the head's outline; `sway`: the hair sway amplitude) and `eyes` (`blink`: how far the upper lid comes down over the eye's height). Call `describe_rig_plan` for each field's default, range, recommended span, step and poses. A value out of range, or a group or key not in the catalog, is refused as `INVALID: rigPlan.<path> …`. The old `style` input was removed in 0.30.0 and is refused with the map from each old knob to its `rigPlan` path.
31
+ - **`patches`** — optional displacements added to existing keyform stops of the freshly generated rig, each `{ target, at, region, by, falloff?, why? }` (`RigPatch` in `@ikijs/editor`). `target` is a feature grid (`eyeWarp_L`/`_R`, `browWarp_L`/`_R`, `noseWarp`, `mouthWarp`; `at` names `ParamAngleX` and `ParamAngleY`, each −30, 0 or 30, never both 0) or a mesh part with warps (`face`, `hair_front`, …; `at` names one parameter at one of its warp stops). `region` is a rectangle in fractions of a role's rest layer box (top-left origin, y down); `by` and `falloff` are in face widths on screen axes (+dx right, +dy down). They are replayed on every rig of these inputs, so they hold through a layout or `rigPlan` retune, and they never touch the rest stop or a stop where the rig shuts a part on purpose; `bodyWarp` and the matrix deformers are not targets. Aim them with `describe_iki`.
32
+ - **Result** — on success the result text is the written file path, then one `RIGPLAN: turn.amount=1 …` line (every plan field's effective value, each annotated with `(requested …, clamped at …)` where the art's room cut it or `(fitted by turnTargets.…)` where a cue fitted it), then one `PATCH <i> <target> at <Param=v …>: <moved> of <of> points (cols a-b, rows c-d), largest move <maxPx> model px` line per patch op (`(vertices)` in place of the columns and rows for a mesh part), then the rig's fold report lines and its `PHYSICS` lines (as `render_poses` prints them), and `structuredContent` carries `{ ok: true, path, canvas, partCount, atlasBytes, headHalfWidth?, headHalfWidthApplied, headEdges?, strandEdges?, noseCore?, turn?, patches?, folds, physics, rigPlan }`. `rigPlan` is `{ requested, effective, clamped, overriddenBy }` — the plan as passed, every field's value the rig built with, the plan-owned fields the room cut (`{ field, bound }`) and the fields a `turnTargets` cue fitted instead (path to cue); it is always present on a rigged model, and a result without it comes from a server before 0.30.0. `patches` is what each op moved (`index`, `target`, `at`, `moved`, `of`, `cols`/`rows` for a grid, `maxPx`) and is present whenever `patches` was passed, `[]` included. `atlasBytes` is the embedded atlas's data-URI length, summed over both pages when the nose has one of its own. `headHalfWidth` is the head measured here rather than asked for: the layers' own opaque union at the eye row, under the same `alpha >= 128` rule and ±10-row band `measure_turn_reference` spans a render with, so the rig's own rest render measures that span back; it is **absent** when that union has no span there at all (translucent art painted below alpha 128 — still a valid layer set, just with nothing to measure). `headHalfWidthApplied` is `false` when the measured value is absent, or no wider than the face plate (a hairless set, or one widest at the plate itself) — the generator will not take such a head, so the plate stands in for it and the rig is still produced either way. `headEdges` is a companion to a measured, applied `headHalfWidth` (absent otherwise): every role with an opaque pixel in that same eye-row band, per side, each with its own rest x there — passed straight to the generator's own `options.headEdges` so it can tell which part's own deformation actually carries the union's outermost pixel through the turn. `strandEdges` is each side's iris and the `hair_front` run it would slide under on the turn, measured whenever the layers include `hair_front`, `iris_L` and `iris_R`: the iris's opaque span and the run's outer and face-side ends as pixel edges on the row holding the iris's centre (a run that reaches the other iris's centre, a fringe spanning the face, has `runFace: null`; a run narrower than half the iris's painted width on that row is hair detail the iris may cross, and is skipped as if clear) — passed straight to the generator's own `options.strandEdges`, which keeps the far iris from sliding under the bangs any further than it is painted. `turn` is what the solve settled on — `{ radius, holdBase, depths, achieved: { eyeShift, farEyeRatio, silhouetteRatio }, clamped, strandOverlap? }`, where `achieved` is what the rig does reach and `clamped` names every target the rig cut down: the turn (`eyeShift`, passed or the profile's own) where the face plate's edge or the strand cut it short, and a profile `noseShift` / `mouthShift` past its room. `strandOverlap` gives, per side whose far iris the bangs still cover at some far stop, the covered width — how much of the iris's painted row the run covers where that is largest (`deg`, `px`, and `hh` in head half-widths), how much it covers at rest (`restPx`), and whether the bound held (`held`: `true` means the iris is kept no deeper under the run than it is painted; `false` means the art left no room to — always so for a fringe spanning the face — and `px` is what stays covered); it is absent when nothing is covered. `noseCore` is the nose's dense core in canvas px — its pixels at alpha >= 128, not grown, the box handed to the generator as the nose layer's `denseCore` and its turn landmark — absent without a `nose` layer, when it has no pixel at that threshold (painted wholly translucent), or when that core is a speck of the nose's crop (under a quarter of its width or height, such as a lone nostril mark), and in both of the last two cases the crop stands in for it. `turn` is absent without a `nose` layer. `folds` is the written model's fold report, the engine's `checkFolds` over its own pose set (`{ poses, thresholds, targets, offenders }`, described under `render_poses`); it never refuses a rig — a model that folds is still written and returned — and each fold names its pose by its parameter settings, which a host reproduces by setting those parameters on a player (`IkiPlayer.setParameter`). `physics` is the written model's physics report, the engine's `checkPhysics` over its rigs (`{ thresholds, targets, offenders }`, described under `render_poses`) — the hair springs a `hair_front` layer brings (two for the front hair and, with `hair_back`, one for the back), or none — and never refuses a rig either. The (potentially multi-MB) model is written to disk, not inlined. Invalid input (a `patches` op the rig refuses — `INVALID: patches[i]…`, naming the stops, targets or roles there are; unknown/missing role, an arm without a `body`, empty layer, mismatched sizes, bad path, an atlas page over 4096 px on a side, or an atlas over 12 MiB; art the rig cannot build on, such as a body's hips with no room under its pivots for a row line or for the body's motion, or an arm too short to hang an elbow under its shoulder; a `turnTargets` field that is unknown or that this layer set cannot reach — any passed field other than an `eyeShift` past the art's room; a `rigPlan` field out of range or unknown, or the removed `style` input; the message names the field and the attainable range) returns `{ ok: false, error }` with a `INVALID: …` text — not a protocol error. An argument the tool's input schema refuses — a `turnTargets` or `rigPlan` that is not an object, or one of their named fields that is not a number — never reaches the tool: the MCP SDK answers with an `isError` result whose text is `MCP error -32602: Input validation error: …`, and no `structuredContent`.
32
33
 
33
34
  The decode/atlas pipeline runs in Node via `sharp` (a native dependency confined to this package); it mirrors the browser editor app's import flow and reuses the pure `@ikijs/editor` model + atlas math, so both paths produce the same rig. The fold and physics checks run the workspace `@ikijs/engine`, inlined into this package's Node build (as it already is into the `render_poses` page script), while `@ikijs/format` stays an external dependency.
34
35
 
@@ -430,6 +430,14 @@ var FixedStepClock = class {
430
430
  get isSeedFrame() {
431
431
  return this.prevNowMs === void 0;
432
432
  }
433
+ /**
434
+ * Time carried in the accumulator, in seconds: how far the frame's timestamp is
435
+ * past the last whole sub-step. Drivers extrapolate their state by it so what
436
+ * they emit is the state at the frame's time, not at the last sub-step.
437
+ */
438
+ get remainderS() {
439
+ return this.accumulatorS;
440
+ }
433
441
  /**
434
442
  * Fold `nowMs` into the accumulator and return how many {@link FIXED_DT_S}
435
443
  * sub-steps to run this frame. On the seed frame it only records the
@@ -767,7 +775,8 @@ var PhysicsMotion = class {
767
775
  const rig = this.rigs[index];
768
776
  const outParam = this.params.get(rig.output.parameter);
769
777
  const outDefault = outParam ? clamp(outParam.default, outParam.min, outParam.max) : 0;
770
- const value = outDefault + (st.x - st.lag) * rig.output.scale;
778
+ const x = st.x + st.v * this.clock.remainderS;
779
+ const value = outDefault + (x - st.lag) * rig.output.scale;
771
780
  const finite = Number.isFinite(value);
772
781
  if (!finite) this.resetCounts[index]++;
773
782
  this.sink(rig.output.parameter, finite ? value : outDefault);
@@ -2434,6 +2443,9 @@ import {
2434
2443
  partIdsOfRole,
2435
2444
  LayerGeometryError,
2436
2445
  PatchError,
2446
+ RigPlanError,
2447
+ RIG_PLAN_FIELDS,
2448
+ styleRemovedMessage,
2437
2449
  TurnTargetError
2438
2450
  } from "@ikijs/editor";
2439
2451
 
@@ -2704,11 +2716,15 @@ var STANDARD_PARAMETER_INFO = [
2704
2716
  },
2705
2717
  {
2706
2718
  id: StandardParameter4.HairSwayX,
2707
- description: "Horizontal hair-sway driver. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2719
+ description: "Front hair's horizontal sway driver. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2708
2720
  },
2709
2721
  {
2710
2722
  id: StandardParameter4.HairSwayZ,
2711
- description: "Hair-sway driver behind a head tilt. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2723
+ description: "Front hair's sway driver behind a head tilt. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2724
+ },
2725
+ {
2726
+ id: StandardParameter4.HairBackSway,
2727
+ 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."
2712
2728
  },
2713
2729
  {
2714
2730
  id: StandardParameter4.ArmLeft,
@@ -2746,6 +2762,22 @@ var STANDARD_PARAMETER_INFO = [
2746
2762
  function listStandardParameters() {
2747
2763
  return STANDARD_PARAMETER_INFO.map((p) => ({ ...p }));
2748
2764
  }
2765
+ function describeRigPlan() {
2766
+ return { fields: [...RIG_PLAN_FIELDS] };
2767
+ }
2768
+ function formatRigPlanReport(r) {
2769
+ const fields = RIG_PLAN_FIELDS.map((f) => {
2770
+ const value = `${f.path}=${r.effective[f.path]}`;
2771
+ const clamp2 = r.clamped.find((c) => c.field === f.path);
2772
+ if (clamp2 !== void 0) {
2773
+ const asked = r.requested[f.group]?.[f.key] ?? f.default;
2774
+ return `${value} (requested ${asked}, clamped at ${clamp2.bound})`;
2775
+ }
2776
+ const cue = r.overriddenBy[f.path];
2777
+ return cue === void 0 ? value : `${value} (fitted by ${cue})`;
2778
+ });
2779
+ return `RIGPLAN: ${fields.join(" ")}`;
2780
+ }
2749
2781
  function expectInput(label, fn) {
2750
2782
  try {
2751
2783
  return fn();
@@ -2794,6 +2826,9 @@ async function autoRigFromLayers(input) {
2794
2826
  `quantizeColors must be an integer in 2..256, got ${String(quantizeColors)}`
2795
2827
  );
2796
2828
  }
2829
+ if (input.style !== void 0) {
2830
+ throw new AutoRigInputError(styleRemovedMessage("style"));
2831
+ }
2797
2832
  const turnTargets = input.turnTargets;
2798
2833
  if (turnTargets !== void 0) {
2799
2834
  if (typeof turnTargets !== "object" || turnTargets === null || Array.isArray(turnTargets)) {
@@ -2869,6 +2904,7 @@ async function autoRigFromLayers(input) {
2869
2904
  )?.denseCore;
2870
2905
  let turn;
2871
2906
  let patches;
2907
+ let rigPlan;
2872
2908
  let model;
2873
2909
  try {
2874
2910
  model = generateIkiFromLayerSet(
@@ -2882,7 +2918,10 @@ async function autoRigFromLayers(input) {
2882
2918
  onTurnSolved: (report) => {
2883
2919
  turn = report;
2884
2920
  },
2885
- ...input.style === void 0 ? {} : { style: input.style },
2921
+ ...input.rigPlan === void 0 ? {} : { rigPlan: input.rigPlan },
2922
+ onRigPlanResolved: (report) => {
2923
+ rigPlan = report;
2924
+ },
2886
2925
  ...input.patches === void 0 ? {} : {
2887
2926
  patches: input.patches,
2888
2927
  onPatchesApplied: (reports) => {
@@ -2894,7 +2933,7 @@ async function autoRigFromLayers(input) {
2894
2933
  }
2895
2934
  );
2896
2935
  } catch (e) {
2897
- if (!(e instanceof TurnTargetError || e instanceof LayerGeometryError || e instanceof PatchError)) {
2936
+ if (!(e instanceof TurnTargetError || e instanceof LayerGeometryError || e instanceof PatchError || e instanceof RigPlanError)) {
2898
2937
  throw e;
2899
2938
  }
2900
2939
  throw new AutoRigInputError(e.message);
@@ -2957,7 +2996,8 @@ async function autoRigFromLayers(input) {
2957
2996
  ...turn === void 0 ? {} : { turn },
2958
2997
  folds,
2959
2998
  physics,
2960
- ...patches === void 0 ? {} : { patches }
2999
+ ...patches === void 0 ? {} : { patches },
3000
+ rigPlan
2961
3001
  };
2962
3002
  } catch (err) {
2963
3003
  if (err instanceof AutoRigInputError)
@@ -5705,7 +5745,7 @@ function formatPatchReports(reports) {
5705
5745
  });
5706
5746
  }
5707
5747
  function createIkiMcpServer() {
5708
- const server = new McpServer({ name: "iki", version: "0.28.0" });
5748
+ const server = new McpServer({ name: "iki", version: "0.30.0" });
5709
5749
  server.registerTool(
5710
5750
  "validate_iki",
5711
5751
  {
@@ -5777,10 +5817,27 @@ function createIkiMcpServer() {
5777
5817
  };
5778
5818
  }
5779
5819
  );
5820
+ server.registerTool(
5821
+ "describe_rig_plan",
5822
+ {
5823
+ description: "Lists the fields of the `rigPlan` input of auto_rig_from_layers: each one's path, default, range, recommended span, step, unit, the poses it shows at, the report reading that shows it and the `turnTargets` cue that fits it when given. The one source of those numbers.",
5824
+ inputSchema: {}
5825
+ },
5826
+ async () => {
5827
+ const { fields } = describeRigPlan();
5828
+ const text = fields.map(
5829
+ (f) => `${f.path} default ${f.default} range ${f.range[0]}..${f.range[1]} recommended ${f.recommended[0]}..${f.recommended[1]} step ${f.step} ${f.unit} \u2014 ${f.what}; shows at ${f.poses.map((p) => JSON.stringify(p)).join(" ")}; cue ${f.cue ?? "none"}; fitted by ${f.fitBy ?? "none"}${f.provisional ? "; provisional" : ""}`
5830
+ ).join("\n");
5831
+ return {
5832
+ content: [{ type: "text", text }],
5833
+ structuredContent: { fields }
5834
+ };
5835
+ }
5836
+ );
5780
5837
  server.registerTool(
5781
5838
  "auto_rig_from_layers",
5782
5839
  {
5783
- 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, 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, 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 `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. `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.",
5840
+ 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, 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, 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. `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.",
5784
5841
  inputSchema: {
5785
5842
  layers: z.array(
5786
5843
  z.object({
@@ -5805,15 +5862,24 @@ function createIkiMcpServer() {
5805
5862
  }).passthrough().optional().describe(
5806
5863
  "What the head turn is fitted to, as `measure_turn_reference` reports it off a front/turned reference pair. `eyeShift` (and the optional `noseShift`/`mouthShift`) is how far that feature slides across the head at full turn, as a fraction of the head's half-width \u2014 a MAGNITUDE: the rig turns both ways, so the sign is ignored. `farEyeRatio` is the far/near eye width at full turn over that same ratio at rest, `silhouetteRatio` the head's half-width turned over at rest. The half-width the shifts are fractions of is measured off the layers themselves, so it is not an input. An omitted field leaves that part of the turn at the profile the rig defaults to. A passed `eyeShift` is fitted by the turn's amount and clamped to the room the art leaves the far eye \u2014 the face plate's edge, or the bangs' side strand over the far iris (the result's `turn.clamped` lists every clamped field, `turn.achieved` what the rig reaches, and `turn.strandOverlap` how much of a far iris the bangs still cover). A passed `silhouetteRatio` is clamped too, only on a face drawn without hair and with ear islands, where narrowing the head that far would no longer cover the far ear's slide. Any other passed target this layer set cannot reach comes back as `INVALID: \u2026` naming the field and the attainable range, since it is a measurement rather than a preference. A field not named here is refused the same way."
5807
5864
  ),
5808
- style: z.object({
5809
- turn: z.number().optional(),
5810
- featureLead: z.number().optional(),
5811
- hairFollow: z.number().optional(),
5812
- outlineFollow: z.number().optional(),
5813
- blink: z.number().optional(),
5814
- sway: z.number().optional()
5865
+ style: z.unknown().optional().describe(
5866
+ "Removed in @ikijs/mcp 0.30.0: pass `rigPlan`. Any value here is refused with the field map."
5867
+ ),
5868
+ rigPlan: z.object({
5869
+ turn: z.object({
5870
+ amount: z.number().optional(),
5871
+ featureLead: z.number().optional(),
5872
+ eyeForeshorten: z.number().optional(),
5873
+ noseLead: z.number().optional()
5874
+ }).passthrough().optional(),
5875
+ hair: z.object({
5876
+ follow: z.number().optional(),
5877
+ outlineFollow: z.number().optional(),
5878
+ sway: z.number().optional()
5879
+ }).passthrough().optional(),
5880
+ eyes: z.object({ blink: z.number().optional() }).passthrough().optional()
5815
5881
  }).passthrough().optional().describe(
5816
- "Per-character tuning from the profile the rig defaults to: `turn` scales the whole head turn (plate, features, hair and the eyes' foreshortening; 0..3, 1 = the profile; ignored when `turnTargets.eyeShift` is given), `featureLead` how far the features lead the face plate (0..3, 1 = the profile), `hairFollow` the front hair's share of the face's turn (0..2, profile 1), `outlineFollow` its outer edge's share where the front hair draws the head's outline (0..2, profile 0: the outline holds), `blink` how far the upper lid comes down over the eye's height (0.1..1, profile 0.6), `sway` the hair sway amplitude (0..5, 1 = the profile). A value out of range, or a knob not named here, comes back as `INVALID: \u2026`."
5882
+ "Per-character tuning from the profile the rig defaults to, in three groups: `turn` (`amount`, `featureLead`, `eyeForeshorten`, `noseLead`: the last two turn only, the nod untouched, and fitted by `turnTargets.farEyeRatio` / `turnTargets.noseShift` when those are given, which the `RIGPLAN:` line then reports as overridden), `hair` (`follow`, `outlineFollow`, `sway`) and `eyes` (`blink`). `describe_rig_plan` lists every field's default, range, recommended span, step and poses. A value out of range, or a group or key not named there, comes back as `INVALID: rigPlan.<path> \u2026`; an object left out or `{}` is the profile. The result reports what the rig built with as `rigPlan` and a `RIGPLAN:` line."
5817
5883
  ),
5818
5884
  patches: z.array(
5819
5885
  z.object({
@@ -5831,7 +5897,7 @@ function createIkiMcpServer() {
5831
5897
  why: z.string().optional()
5832
5898
  }).passthrough()
5833
5899
  ).optional().describe(
5834
- "Displacements ADDED to EXISTING keyform stops of the freshly generated rig, each op `{ target, at, region, by, falloff?, why? }`. They are replayed on every rig of these inputs, over whatever the rig now bakes, so they hold through a layout or `style` retune; ops on one stop add up, whatever their order. `target` is a feature grid \u2014 `eyeWarp_L`, `eyeWarp_R`, `browWarp_L`, `browWarp_R`, `noseWarp`, `mouthWarp`, whose `at` names both `ParamAngleX` and `ParamAngleY`, each -30, 0 or 30, never both 0 \u2014 or a mesh part with warps (`face`, `hair_front`, \u2026), whose `at` names exactly one parameter at one of that part's warp keyform values, never the parameter's default nor the stop where the rig shuts the part on purpose (`eye_*` and `lash_lower_*` at their `ParamEye*Open` 0, the lip set and its tongue and teeth at `ParamMouthOpenY` 0), which the fold check exempts, nor a `ParamAngleZ` or `ParamBodyAngleZ` stop (they roll the deformers the part hangs under, so a displacement there is turned off the screen axes). The rest pose is the drawn art and no patch changes it. `bodyWarp` and the matrix deformers are not targets, and a patch adds no stop and changes no parameter range. `region` `{ role, x: [from, to], y: [from, to] }` is a rectangle in fractions of the REST layer box (the opaque crop) of `role`, origin top-left, x right, y DOWN, and may reach past the box: the target's points whose REST position lies inside take the whole of `by`, those within `falloff` of it a smooth share, the rest nothing. `by` `{ dx, dy }` and `falloff` are in face widths (the `face` layer's crop width), on screen axes: +dx toward the viewer's right (a character's `_L` side), +dy DOWN. Between stops the engine blends linearly, so a fix at ParamAngleX -30 shows at half strength at -15 and none at rest. `why` is a note the rig ignores. An op this schema accepts but the rig refuses \u2014 an unknown key, target, role or stop, the rest stop or a shut stop, a region running backwards or catching none of the target's points \u2014 comes back as `INVALID: patches[i]\u2026`, listing the keys, targets, stops or roles there are, or where the target's points lie in the role's box, and nothing is written; a missing field or one of the wrong type is refused by the schema itself, as the SDK's input validation error."
5900
+ "Displacements ADDED to EXISTING keyform stops of the freshly generated rig, each op `{ target, at, region, by, falloff?, why? }`. They are replayed on every rig of these inputs, over whatever the rig now bakes, so they hold through a layout or `rigPlan` retune; ops on one stop add up, whatever their order. `target` is a feature grid \u2014 `eyeWarp_L`, `eyeWarp_R`, `browWarp_L`, `browWarp_R`, `noseWarp`, `mouthWarp`, whose `at` names both `ParamAngleX` and `ParamAngleY`, each -30, 0 or 30, never both 0 \u2014 or a mesh part with warps (`face`, `hair_front`, \u2026), whose `at` names exactly one parameter at one of that part's warp keyform values, never the parameter's default nor the stop where the rig shuts the part on purpose (`eye_*` and `lash_lower_*` at their `ParamEye*Open` 0, the lip set and its tongue and teeth at `ParamMouthOpenY` 0), which the fold check exempts, nor a `ParamAngleZ` or `ParamBodyAngleZ` stop (they roll the deformers the part hangs under, so a displacement there is turned off the screen axes). The rest pose is the drawn art and no patch changes it. `bodyWarp` and the matrix deformers are not targets, and a patch adds no stop and changes no parameter range. `region` `{ role, x: [from, to], y: [from, to] }` is a rectangle in fractions of the REST layer box (the opaque crop) of `role`, origin top-left, x right, y DOWN, and may reach past the box: the target's points whose REST position lies inside take the whole of `by`, those within `falloff` of it a smooth share, the rest nothing. `by` `{ dx, dy }` and `falloff` are in face widths (the `face` layer's crop width), on screen axes: +dx toward the viewer's right (a character's `_L` side), +dy DOWN. Between stops the engine blends linearly, so a fix at ParamAngleX -30 shows at half strength at -15 and none at rest. `why` is a note the rig ignores. An op this schema accepts but the rig refuses \u2014 an unknown key, target, role or stop, the rest stop or a shut stop, a region running backwards or catching none of the target's points \u2014 comes back as `INVALID: patches[i]\u2026`, listing the keys, targets, stops or roles there are, or where the target's points lie in the role's box, and nothing is written; a missing field or one of the wrong type is refused by the schema itself, as the SDK's input validation error."
5835
5901
  )
5836
5902
  }
5837
5903
  },
@@ -5845,6 +5911,7 @@ function createIkiMcpServer() {
5845
5911
  });
5846
5912
  const text = r.ok ? [
5847
5913
  r.path,
5914
+ formatRigPlanReport(r.rigPlan),
5848
5915
  ...formatPatchReports(r.patches ?? []),
5849
5916
  ...formatFoldReport(r.folds, r.canvas),
5850
5917
  ...formatPhysicsReport(r.physics)
@@ -6030,6 +6097,8 @@ export {
6030
6097
  describeIki,
6031
6098
  describeIkiAt,
6032
6099
  listStandardParameters,
6100
+ describeRigPlan,
6101
+ formatRigPlanReport,
6033
6102
  autoRigFromLayers,
6034
6103
  measureTurnReference,
6035
6104
  formatTurnReport,
@@ -6039,4 +6108,4 @@ export {
6039
6108
  formatPhysicsReport,
6040
6109
  createIkiMcpServer
6041
6110
  };
6042
- //# sourceMappingURL=chunk-D2OLX5S7.mjs.map
6111
+ //# sourceMappingURL=chunk-5WHM63CL.mjs.map