@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/dist/cli.js CHANGED
@@ -466,6 +466,14 @@ var FixedStepClock = class {
466
466
  get isSeedFrame() {
467
467
  return this.prevNowMs === void 0;
468
468
  }
469
+ /**
470
+ * Time carried in the accumulator, in seconds: how far the frame's timestamp is
471
+ * past the last whole sub-step. Drivers extrapolate their state by it so what
472
+ * they emit is the state at the frame's time, not at the last sub-step.
473
+ */
474
+ get remainderS() {
475
+ return this.accumulatorS;
476
+ }
469
477
  /**
470
478
  * Fold `nowMs` into the accumulator and return how many {@link FIXED_DT_S}
471
479
  * sub-steps to run this frame. On the seed frame it only records the
@@ -801,7 +809,8 @@ var PhysicsMotion = class {
801
809
  const rig = this.rigs[index];
802
810
  const outParam = this.params.get(rig.output.parameter);
803
811
  const outDefault = outParam ? clamp(outParam.default, outParam.min, outParam.max) : 0;
804
- const value = outDefault + (st.x - st.lag) * rig.output.scale;
812
+ const x = st.x + st.v * this.clock.remainderS;
813
+ const value = outDefault + (x - st.lag) * rig.output.scale;
805
814
  const finite = Number.isFinite(value);
806
815
  if (!finite) this.resetCounts[index]++;
807
816
  this.sink(rig.output.parameter, finite ? value : outDefault);
@@ -2704,11 +2713,15 @@ var STANDARD_PARAMETER_INFO = [
2704
2713
  },
2705
2714
  {
2706
2715
  id: import_format9.StandardParameter.HairSwayX,
2707
- description: "Horizontal hair-sway driver. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2716
+ description: "Front hair's horizontal sway driver. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2708
2717
  },
2709
2718
  {
2710
2719
  id: import_format9.StandardParameter.HairSwayZ,
2711
- description: "Hair-sway driver behind a head tilt. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2720
+ description: "Front hair's sway driver behind a head tilt. Physics OUTPUT \u2014 driven by the spring, hosts should not set it directly."
2721
+ },
2722
+ {
2723
+ id: import_format9.StandardParameter.HairBackSway,
2724
+ 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
2725
  },
2713
2726
  {
2714
2727
  id: import_format9.StandardParameter.ArmLeft,
@@ -2746,6 +2759,22 @@ var STANDARD_PARAMETER_INFO = [
2746
2759
  function listStandardParameters() {
2747
2760
  return STANDARD_PARAMETER_INFO.map((p) => ({ ...p }));
2748
2761
  }
2762
+ function describeRigPlan() {
2763
+ return { fields: [...import_editor3.RIG_PLAN_FIELDS] };
2764
+ }
2765
+ function formatRigPlanReport(r) {
2766
+ const fields = import_editor3.RIG_PLAN_FIELDS.map((f) => {
2767
+ const value = `${f.path}=${r.effective[f.path]}`;
2768
+ const clamp2 = r.clamped.find((c) => c.field === f.path);
2769
+ if (clamp2 !== void 0) {
2770
+ const asked = r.requested[f.group]?.[f.key] ?? f.default;
2771
+ return `${value} (requested ${asked}, clamped at ${clamp2.bound})`;
2772
+ }
2773
+ const cue = r.overriddenBy[f.path];
2774
+ return cue === void 0 ? value : `${value} (fitted by ${cue})`;
2775
+ });
2776
+ return `RIGPLAN: ${fields.join(" ")}`;
2777
+ }
2749
2778
  function expectInput(label, fn) {
2750
2779
  try {
2751
2780
  return fn();
@@ -2794,6 +2823,9 @@ async function autoRigFromLayers(input) {
2794
2823
  `quantizeColors must be an integer in 2..256, got ${String(quantizeColors)}`
2795
2824
  );
2796
2825
  }
2826
+ if (input.style !== void 0) {
2827
+ throw new AutoRigInputError((0, import_editor3.styleRemovedMessage)("style"));
2828
+ }
2797
2829
  const turnTargets = input.turnTargets;
2798
2830
  if (turnTargets !== void 0) {
2799
2831
  if (typeof turnTargets !== "object" || turnTargets === null || Array.isArray(turnTargets)) {
@@ -2869,6 +2901,7 @@ async function autoRigFromLayers(input) {
2869
2901
  )?.denseCore;
2870
2902
  let turn;
2871
2903
  let patches;
2904
+ let rigPlan;
2872
2905
  let model;
2873
2906
  try {
2874
2907
  model = (0, import_editor3.generateIkiFromLayerSet)(
@@ -2882,7 +2915,10 @@ async function autoRigFromLayers(input) {
2882
2915
  onTurnSolved: (report) => {
2883
2916
  turn = report;
2884
2917
  },
2885
- ...input.style === void 0 ? {} : { style: input.style },
2918
+ ...input.rigPlan === void 0 ? {} : { rigPlan: input.rigPlan },
2919
+ onRigPlanResolved: (report) => {
2920
+ rigPlan = report;
2921
+ },
2886
2922
  ...input.patches === void 0 ? {} : {
2887
2923
  patches: input.patches,
2888
2924
  onPatchesApplied: (reports) => {
@@ -2894,7 +2930,7 @@ async function autoRigFromLayers(input) {
2894
2930
  }
2895
2931
  );
2896
2932
  } catch (e) {
2897
- if (!(e instanceof import_editor3.TurnTargetError || e instanceof import_editor3.LayerGeometryError || e instanceof import_editor3.PatchError)) {
2933
+ if (!(e instanceof import_editor3.TurnTargetError || e instanceof import_editor3.LayerGeometryError || e instanceof import_editor3.PatchError || e instanceof import_editor3.RigPlanError)) {
2898
2934
  throw e;
2899
2935
  }
2900
2936
  throw new AutoRigInputError(e.message);
@@ -2957,7 +2993,8 @@ async function autoRigFromLayers(input) {
2957
2993
  ...turn === void 0 ? {} : { turn },
2958
2994
  folds,
2959
2995
  physics,
2960
- ...patches === void 0 ? {} : { patches }
2996
+ ...patches === void 0 ? {} : { patches },
2997
+ rigPlan
2961
2998
  };
2962
2999
  } catch (err) {
2963
3000
  if (err instanceof AutoRigInputError)
@@ -5658,7 +5695,7 @@ function formatPatchReports(reports) {
5658
5695
  });
5659
5696
  }
5660
5697
  function createIkiMcpServer() {
5661
- const server = new import_mcp.McpServer({ name: "iki", version: "0.28.0" });
5698
+ const server = new import_mcp.McpServer({ name: "iki", version: "0.30.0" });
5662
5699
  server.registerTool(
5663
5700
  "validate_iki",
5664
5701
  {
@@ -5730,10 +5767,27 @@ function createIkiMcpServer() {
5730
5767
  };
5731
5768
  }
5732
5769
  );
5770
+ server.registerTool(
5771
+ "describe_rig_plan",
5772
+ {
5773
+ 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.",
5774
+ inputSchema: {}
5775
+ },
5776
+ async () => {
5777
+ const { fields } = describeRigPlan();
5778
+ const text = fields.map(
5779
+ (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" : ""}`
5780
+ ).join("\n");
5781
+ return {
5782
+ content: [{ type: "text", text }],
5783
+ structuredContent: { fields }
5784
+ };
5785
+ }
5786
+ );
5733
5787
  server.registerTool(
5734
5788
  "auto_rig_from_layers",
5735
5789
  {
5736
- 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.",
5790
+ 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.",
5737
5791
  inputSchema: {
5738
5792
  layers: import_zod.z.array(
5739
5793
  import_zod.z.object({
@@ -5758,15 +5812,24 @@ function createIkiMcpServer() {
5758
5812
  }).passthrough().optional().describe(
5759
5813
  "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."
5760
5814
  ),
5761
- style: import_zod.z.object({
5762
- turn: import_zod.z.number().optional(),
5763
- featureLead: import_zod.z.number().optional(),
5764
- hairFollow: import_zod.z.number().optional(),
5765
- outlineFollow: import_zod.z.number().optional(),
5766
- blink: import_zod.z.number().optional(),
5767
- sway: import_zod.z.number().optional()
5815
+ style: import_zod.z.unknown().optional().describe(
5816
+ "Removed in @ikijs/mcp 0.30.0: pass `rigPlan`. Any value here is refused with the field map."
5817
+ ),
5818
+ rigPlan: import_zod.z.object({
5819
+ turn: import_zod.z.object({
5820
+ amount: import_zod.z.number().optional(),
5821
+ featureLead: import_zod.z.number().optional(),
5822
+ eyeForeshorten: import_zod.z.number().optional(),
5823
+ noseLead: import_zod.z.number().optional()
5824
+ }).passthrough().optional(),
5825
+ hair: import_zod.z.object({
5826
+ follow: import_zod.z.number().optional(),
5827
+ outlineFollow: import_zod.z.number().optional(),
5828
+ sway: import_zod.z.number().optional()
5829
+ }).passthrough().optional(),
5830
+ eyes: import_zod.z.object({ blink: import_zod.z.number().optional() }).passthrough().optional()
5768
5831
  }).passthrough().optional().describe(
5769
- "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`."
5832
+ "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."
5770
5833
  ),
5771
5834
  patches: import_zod.z.array(
5772
5835
  import_zod.z.object({
@@ -5784,7 +5847,7 @@ function createIkiMcpServer() {
5784
5847
  why: import_zod.z.string().optional()
5785
5848
  }).passthrough()
5786
5849
  ).optional().describe(
5787
- "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."
5850
+ "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."
5788
5851
  )
5789
5852
  }
5790
5853
  },
@@ -5798,6 +5861,7 @@ function createIkiMcpServer() {
5798
5861
  });
5799
5862
  const text = r.ok ? [
5800
5863
  r.path,
5864
+ formatRigPlanReport(r.rigPlan),
5801
5865
  ...formatPatchReports(r.patches ?? []),
5802
5866
  ...formatFoldReport(r.folds, r.canvas),
5803
5867
  ...formatPhysicsReport(r.physics)