@ikijs/mcp 0.33.1 → 0.35.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.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { TurnTargets, RigPlan, RigPatch, IrisStrand, TurnSolveReport, PatchReport, RigPlanReport, RigPlanField } from '@ikijs/editor';
1
+ import { IkiModel, IkiOcclusion } from '@ikijs/format';
2
+ import { CustomPart, TurnTargets, RigPlan, RigPatch, RigBakes, IrisStrand, TurnSolveReport, PatchReport, RigPlanReport, RigPlanField } from '@ikijs/editor';
2
3
  export { RigPlanReport, TurnSolveReport } from '@ikijs/editor';
3
- import { IkiModel } from '@ikijs/format';
4
4
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
5
5
 
6
6
  /** A parameter setting to check the rig at; every other parameter rests at its default. */
@@ -118,6 +118,259 @@ interface PhysicsReport {
118
118
  offenders: PhysicsTarget[];
119
119
  }
120
120
 
121
+ /**
122
+ * What `auto_rig_from_layers` checks of `bakes` before it writes the rig: each
123
+ * baked custom part landed through the engine's own `landParts` at every stop
124
+ * and at the parameter's range ends where it holds the outermost stop, against
125
+ * the displacement the generator was asked for. The generator solves its
126
+ * offsets in closed form, so this is the check that the closed form and the
127
+ * player agree on the written model.
128
+ */
129
+
130
+ /** One baked part on one parameter, as the engine lands it. */
131
+ interface BakeCheck {
132
+ part: string;
133
+ param: string;
134
+ vertices: number;
135
+ /** The stops written, ascending (rest, implicit, is not among them). */
136
+ stops: number[];
137
+ /** The largest gap, over the part's vertices and the stops, between the
138
+ * displacement the bake asked for and the engine's, in canvas px. */
139
+ errorPx: number;
140
+ }
141
+
142
+ /**
143
+ * `probe_rig`: measuring a rigged model without rendering it. Where a point of
144
+ * a part lands in a pose, how far that is from where it rests, and the opaque
145
+ * runs of a layer PNG — the numbers a rigging program (or an agent checking
146
+ * a custom part) needs and a picture cannot give exactly.
147
+ *
148
+ * The landing is the engine's own `landParts`, so it is what the player draws.
149
+ * Frame: canvas px, origin top-left, x right, y down — the frame of the layer
150
+ * PNGs and of `describe_iki`'s boxes.
151
+ */
152
+
153
+ type ProbePoint = [number, number];
154
+ type ProbeQuery = {
155
+ op: "paint";
156
+ path: string;
157
+ } | {
158
+ op: "land" | "displacement";
159
+ part: string;
160
+ points: ProbePoint[];
161
+ pose?: Record<string, number>;
162
+ };
163
+ interface ProbeInput {
164
+ /** The rigged `.iki` to measure (resolved against cwd, under it). */
165
+ modelPath: string;
166
+ queries: ProbeQuery[];
167
+ /** A `.probe.json` under the working directory to write the results to. */
168
+ outputPath?: string;
169
+ }
170
+ /**
171
+ * The opaque (alpha >= 128) runs of a layer per canvas row. `rows[i]` holds
172
+ * the `[x0, x1)` runs (`x1` exclusive) of canvas row `y0 + i`; a row inside the
173
+ * painted range with none is `[]`. A layer with no opaque pixel gives
174
+ * `{ y0: 0, rows: [] }`.
175
+ */
176
+ interface PaintRuns {
177
+ y0: number;
178
+ rows: [number, number][][];
179
+ }
180
+ type ProbeQueryResult = ({
181
+ op: "paint";
182
+ } & PaintRuns) | {
183
+ op: "land" | "displacement";
184
+ part: string;
185
+ /** One per input point; `null` for a point outside the part's mesh. */
186
+ points: (ProbePoint | null)[];
187
+ };
188
+ type ProbeResult = {
189
+ ok: true;
190
+ results: ProbeQueryResult[];
191
+ } | {
192
+ ok: true;
193
+ outputPath: string;
194
+ lines: string[];
195
+ } | {
196
+ ok: false;
197
+ error: string;
198
+ };
199
+ /**
200
+ * Measure the model. Only caller-input failures (`AutoRigInputError`,
201
+ * `IkiFormatError`) come back as `{ ok: false, error }`. With `outputPath` the
202
+ * results go to that file and the return carries a line per query instead.
203
+ */
204
+ declare function probeRig(input: ProbeInput): Promise<ProbeResult>;
205
+
206
+ /**
207
+ * The per-part gate for custom parts, reported by `auto_rig_from_layers` and
208
+ * blocking the character loop's candidate: each custom part measured over a
209
+ * pose set for whether it folds, stays tied where it hangs from its anchor,
210
+ * keeps the art it hides hidden, and (rigid parts) does not bend.
211
+ *
212
+ * Every landing is the engine's own `landParts`, through `probe.ts`'s rest
213
+ * triangles, so the numbers are what the player draws. Lengths are in face
214
+ * widths (the `face` part's width), so nothing is tied to one canvas; the
215
+ * values are experiment C's gate over twin's 402 px face. Frame: canvas px,
216
+ * origin top-left, x right, y down.
217
+ */
218
+
219
+ /** A custom part as the gate reads it. */
220
+ interface CustomGatePart {
221
+ id: string;
222
+ /** The role the part is fixed against; its first part is the anchor. */
223
+ anchor: string;
224
+ /** Where the part meets the anchor, canvas px. */
225
+ tie: [number, number];
226
+ rigid?: boolean;
227
+ /** The roles of the entry's `occlusion.by`, when it declares one. Their
228
+ * paint gives the gate the cover it excuses a reading under; without it a
229
+ * declared occlusion excuses nothing. */
230
+ occludedBy?: string[];
231
+ }
232
+ interface CustomGateOptions {
233
+ /** Replaces the default pose set (`RIGID` still adds its stop midpoints). */
234
+ poses?: FoldPose[];
235
+ }
236
+ /**
237
+ * In face widths (squared for `EXPOSED`). Each is experiment C's gate v2 over
238
+ * twin's 402 px face, the only evidence there is, as a share of that face:
239
+ * `tie` 2 px, `slide` 40 px, `onAnchor` 6 px, `exposed` 150 px², `rigid` 1 px.
240
+ * The fold limit is the engine's own collapse threshold, read from its report.
241
+ */
242
+ declare const CUSTOM_GATE_LIMITS: {
243
+ readonly tie: 0.005;
244
+ readonly slide: 0.1;
245
+ readonly onAnchor: 0.015;
246
+ readonly exposed: 0.0009;
247
+ readonly rigid: 0.0025;
248
+ };
249
+ type CustomGateLimits = typeof CUSTOM_GATE_LIMITS & {
250
+ fold: number;
251
+ };
252
+ /** One measure's worst reading. `value` is in face widths (squared for an
253
+ * area), the limit's unit; null where the measure has no number (a tie off
254
+ * the mesh). */
255
+ interface CustomGateReadingBase {
256
+ value: number | null;
257
+ pose: string;
258
+ limit: number;
259
+ pass: boolean;
260
+ reason?: string;
261
+ }
262
+ /** A length: `px` is the same worst value in canvas px. */
263
+ interface CustomGateReading extends CustomGateReadingBase {
264
+ px: number | null;
265
+ }
266
+ /** An area (`EXPOSED`): `px2` is the same worst value in canvas px². */
267
+ interface CustomGateAreaReading extends CustomGateReadingBase {
268
+ px2: number | null;
269
+ }
270
+ interface CustomGateTip {
271
+ param: string;
272
+ /** The part's free end at the parameter's two ends, min then max. */
273
+ ends: {
274
+ value: number;
275
+ /** Canvas px. */
276
+ landed: ProbePoint | null;
277
+ /** The same point with the part's warps removed (its deformer alone), canvas px. */
278
+ bare: ProbePoint | null;
279
+ /** Distance from `bare` to `landed`, canvas px. */
280
+ fromBare: number | null;
281
+ }[];
282
+ /** Between the two landed positions, canvas px. */
283
+ travel: number | null;
284
+ }
285
+ interface CustomGatePartReport {
286
+ id: string;
287
+ anchor: string;
288
+ folds: {
289
+ ratio: number;
290
+ pose: string;
291
+ limit: number;
292
+ pass: boolean;
293
+ reason?: string;
294
+ };
295
+ tie: CustomGateReading;
296
+ slide: {
297
+ slide: CustomGateReading;
298
+ onAnchor: CustomGateReading;
299
+ /** How many poses of the set turn the head; 0 leaves both at 0. */
300
+ turningPoses: number;
301
+ pass: boolean;
302
+ };
303
+ exposed: {
304
+ /** Pixels both layers paint within 0.15 face widths of the tie. */
305
+ hiddenPx: number;
306
+ /** Where the head does not turn: limited. */
307
+ noTurn: CustomGateAreaReading;
308
+ /** Where it turns: reported, no limit. */
309
+ turning: {
310
+ value: number;
311
+ px2: number;
312
+ pose: string;
313
+ } | null;
314
+ pass: boolean;
315
+ };
316
+ rigid?: CustomGateReading;
317
+ tip: CustomGateTip[];
318
+ /** Only for a part that declares occlusion. Reported, never failing. */
319
+ hidden?: CustomGateHidden;
320
+ ok: boolean;
321
+ }
322
+ /** Where the amount leaves its rest value and first reaches 1, on one side of
323
+ * the key parameter's default; null where it never does. */
324
+ interface CustomGateHiddenSide {
325
+ leaves: number | null;
326
+ full: number | null;
327
+ }
328
+ interface CustomGateHidden {
329
+ /** Every occluder part id the model names. */
330
+ by: string[];
331
+ /** Those whose paint gives the gate cover; the rest fade (or are roles not
332
+ * passed) and give none. */
333
+ cover: string[];
334
+ parameter: string;
335
+ /** The parameter's default. */
336
+ default: number;
337
+ /** The amount with every parameter at its default. */
338
+ atRest: number;
339
+ below: CustomGateHiddenSide;
340
+ above: CustomGateHiddenSide;
341
+ /** Poses of the part's set that `TIE` and `SLIDE` left out, and how many of
342
+ * them turn the head. */
343
+ leftOut: number;
344
+ leftOutTurning: number;
345
+ /** Poses that do not turn the head and that `TIE` read. */
346
+ readNoTurn: number;
347
+ poses: number;
348
+ }
349
+ interface CustomGateReport {
350
+ ok: boolean;
351
+ faceWidth: number;
352
+ limits: CustomGateLimits;
353
+ poses: number;
354
+ parts: CustomGatePartReport[];
355
+ /** `<part> <LINE>` per limited line that failed, or `gate error: <message>`. */
356
+ failed: string[];
357
+ }
358
+ /** The report for a gate that threw: failed, naming the error, no parts. */
359
+ declare function failedCustomGate(model: IkiModel, error: unknown): CustomGateReport;
360
+ /**
361
+ * Measure every custom part of `model`. `paints` holds the opaque runs of each
362
+ * anchor role's layer and of each custom layer, by id. Throws `Error` on an
363
+ * inconsistent call (a part, anchor or paint the model or `paints` lacks):
364
+ * `auto_rig_from_layers` has validated those by then.
365
+ */
366
+ declare function checkCustomGate(model: IkiModel, parts: CustomGatePart[], paints: ReadonlyMap<string, PaintRuns>, options?: CustomGateOptions): CustomGateReport;
367
+ /**
368
+ * The gate as text: per part one `CUSTOM <id> <LINE>: …` line per measure
369
+ * (value in px and face widths, the pose, `pass` or `FAIL: <reason>`), then
370
+ * `CUSTOM GATE pass` or `CUSTOM GATE FAIL: <part LINE, …>`.
371
+ */
372
+ declare function formatCustomGate(report: CustomGateReport): string[];
373
+
121
374
  type ValidateResult = {
122
375
  ok: true;
123
376
  } | {
@@ -246,6 +499,21 @@ interface AutoRigInput {
246
499
  * rig, replayed on every rig of these inputs (see @ikijs/editor's
247
500
  * `RigPatch`). */
248
501
  patches?: RigPatch[];
502
+ /** Parts the auto-rigger has no role for (a twin tail, a hairpin), each from
503
+ * a canvas-sized PNG of its own, put in the model unrigged on `headDeformer`
504
+ * (see @ikijs/editor's `CustomPart`). Their pixels never reach the role
505
+ * parse or the measurements the head's width and turn are fitted to. */
506
+ customParts?: AutoRigCustomPartInput[];
507
+ /** Lattices that move the custom parts when a parameter does (see
508
+ * @ikijs/editor's `RigBakes`); needs `customParts`. The written model is
509
+ * landed through the engine and refused (`BAKE ERROR`, nothing written) when
510
+ * a stop is off by 0.1 px or more. */
511
+ bakes?: RigBakes;
512
+ }
513
+ /** One `customParts` entry: a `CustomPart` whose `layer` is read off `path`
514
+ * (a PNG the size of the role layers) instead of given. */
515
+ interface AutoRigCustomPartInput extends Omit<CustomPart, "layer"> {
516
+ path: string;
249
517
  }
250
518
  /** The turn cues a caller may pass, which is every one but `headHalfWidth`:
251
519
  * the pixels the shift fractions are fractions of are measured off the layers
@@ -259,8 +527,9 @@ type AutoRigResult = {
259
527
  height: number;
260
528
  };
261
529
  partCount: number;
262
- /** The atlas's embedded size: its data URI's length, summed over both
263
- * pages when a quantized rig puts the nose on a page of its own. */
530
+ /** The atlas's embedded size: its data URI's length, summed over
531
+ * every page: the nose's own under `quantizeColors`, and the custom
532
+ * parts' page. */
264
533
  atlasBytes: number;
265
534
  /** The head's half-width at the eye row, measured off the layers.
266
535
  * Absent when the opaque (alpha >= 128) union has no span there — a
@@ -344,10 +613,42 @@ type AutoRigResult = {
344
613
  * Always present on a rigged model; absent only from a server before
345
614
  * 0.30.0. */
346
615
  rigPlan: RigPlanReport;
616
+ /** Where each of `input.customParts` landed — present whenever
617
+ * `customParts` was passed, `[]` included, so a caller can tell this
618
+ * server from one that drops the field. `box` is the layer's alpha box
619
+ * in canvas px; `page` is the atlas page, the last one. `bakes` is
620
+ * present only when `bakes` was passed: one entry per baked part and
621
+ * parameter, as the engine lands it. `gate` is the per-part gate over
622
+ * the written model (`ok`, the limits, each part's measures); a failing
623
+ * one blocks the character loop's candidate, the model is written
624
+ * either way. Absent from a server before 0.34.0. */
625
+ customParts?: {
626
+ parts: CustomPartReport[];
627
+ bakes?: BakeCheck[];
628
+ gate: CustomGateReport;
629
+ };
347
630
  } | {
348
631
  ok: false;
349
632
  error: string;
350
633
  };
634
+ interface CustomPartReport {
635
+ id: string;
636
+ box: {
637
+ x: number;
638
+ y: number;
639
+ w: number;
640
+ h: number;
641
+ };
642
+ mesh: {
643
+ vertices: number;
644
+ triangles: number;
645
+ };
646
+ order: number;
647
+ page: number;
648
+ /** What hides the part, as written on the model; only for a part that
649
+ * declares it. */
650
+ occlusion?: IkiOcclusion;
651
+ }
351
652
 
352
653
  /**
353
654
  * Decode role-named PNG file paths, auto-rig a model from them, atlas + embed
@@ -360,10 +661,10 @@ type AutoRigResult = {
360
661
  * and hair layers' opaque runs and the nose's dense core, returned as
361
662
  * `noseCore`); what the solve settled on comes back in `turn`. Under
362
663
  * `quantizeColors` the nose is atlased alone on a second, lossless page, which
363
- * the palette would otherwise rim; `atlasBytes` sums both pages. The
364
- * generator replays `input.patches` on the fresh rig before it validates and
365
- * reports the turn, and what each op moved comes back in `patches`; a refused
366
- * op writes nothing.
664
+ * the palette would otherwise rim; `atlasBytes` sums every page, the custom
665
+ * page included. The generator replays `input.patches` on the fresh rig before
666
+ * it validates and reports the turn, and what each op moved comes back in
667
+ * `patches`; a refused op writes nothing.
367
668
  *
368
669
  * Re-host of examples/editor/src/store.ts `importLayerSet` with the three DOM
369
670
  * pixel functions swapped for the sharp-backed ./node-images helpers; the pure
@@ -1102,6 +1403,11 @@ interface RenderPosesInput {
1102
1403
  sweep?: RequestedSweep;
1103
1404
  /** More sweeps, rendered after `sweep`, each into its own `<outDir>/<name>/`. */
1104
1405
  sweeps?: RequestedSweep[];
1406
+ /**
1407
+ * Part ids left out of the drawn frames of this call, poses and sweeps alike.
1408
+ * The reports still read the whole model.
1409
+ */
1410
+ hideParts?: string[];
1105
1411
  }
1106
1412
  interface SweepOutput {
1107
1413
  name: string;
@@ -1158,15 +1464,16 @@ declare function renderPoses(input: RenderPosesInput): Promise<RenderPosesResult
1158
1464
 
1159
1465
  /**
1160
1466
  * The sweeps `render_poses` renders on request: an eased ±30 `ParamAngleX`
1161
- * turn, or the `turn-nod` box through every `ParamAngleX` × `ParamAngleY`
1162
- * stop, with the hair physics running. This file is their pure pieces — the
1163
- * schedules, the sheet picks, the kymograph row, the flipbook template and the
1164
- * output directory — all decided in Node; the page only draws what the
1165
- * {@link SweepSpec} says. The page script imports this file for TYPES only (it
1166
- * is bundled as a browser IIFE and must never pull in `node:fs`).
1467
+ * turn, the same curve on `ParamAngleZ` (`roll`), or the `turn-nod` box through
1468
+ * every `ParamAngleX` × `ParamAngleY` stop, with the hair physics running. This
1469
+ * file is their pure pieces — the schedules, the sheet picks, the kymograph
1470
+ * row, the flipbook template and the output directory — all decided in Node;
1471
+ * the page only draws what the {@link SweepSpec} says. The page script imports
1472
+ * this file for TYPES only (it is bundled as a browser IIFE and must never pull
1473
+ * in `node:fs`).
1167
1474
  */
1168
1475
 
1169
- declare const SWEEP_PRESETS: readonly ["turn", "turn-nod"];
1476
+ declare const SWEEP_PRESETS: readonly ["turn", "turn-nod", "roll"];
1170
1477
  type SweepPreset = (typeof SWEEP_PRESETS)[number];
1171
1478
  /** What the caller asks for. */
1172
1479
  interface RequestedSweep {
@@ -1223,4 +1530,4 @@ interface SweepManifest {
1223
1530
 
1224
1531
  declare function createIkiMcpServer(): McpServer;
1225
1532
 
1226
- export { type AutoRigInput, type AutoRigLayerInput, type AutoRigResult, type AutoRigTurnTargets, type ComposeInput, type ComposeResult, type DeformerSummary, type DescribeResult, type IkiSummary, type IrisBlob, type IrisColor, type LayoutOverride, type MeasureInput, type MeasureResult, type MeasureTurnInput, type MeasureTurnResult, type NodReport, type PartSummary, type RenderPosesInput, type RenderPosesResult, type RequestedPose, type RequestedSweep, SWEEP_PRESETS, type StandardParameterInfo, type SweepManifest, type SweepPreset, type SweepReport, type TurnImageMeasure, type TurnMeasurement, type ValidateResult, autoRigFromLayers, checkModelFolds, checkNod, checkSweep, composeLayersFromParts, createIkiMcpServer, describeIki, describeIkiAt, describeRigPlan, formatFoldReport, formatHairSideReport, formatMeasureReport, formatNodReport, formatPhysicsReport, formatRigPlanReport, formatSweepReport, formatTurnReport, listStandardParameters, measureLayers, measureTurnReference, renderPoses, validateIki };
1533
+ export { type AutoRigCustomPartInput, type AutoRigInput, type AutoRigLayerInput, type AutoRigResult, type AutoRigTurnTargets, type BakeCheck, CUSTOM_GATE_LIMITS, type ComposeInput, type ComposeResult, type CustomGateAreaReading, type CustomGateLimits, type CustomGateOptions, type CustomGatePart, type CustomGatePartReport, type CustomGateReading, type CustomGateReport, type CustomGateTip, type CustomPartReport, type DeformerSummary, type DescribeResult, type IkiSummary, type IrisBlob, type IrisColor, type LayoutOverride, type MeasureInput, type MeasureResult, type MeasureTurnInput, type MeasureTurnResult, type NodReport, type PaintRuns, type PartSummary, type ProbeInput, type ProbePoint, type ProbeQuery, type ProbeQueryResult, type ProbeResult, type RenderPosesInput, type RenderPosesResult, type RequestedPose, type RequestedSweep, SWEEP_PRESETS, type StandardParameterInfo, type SweepManifest, type SweepPreset, type SweepReport, type TurnImageMeasure, type TurnMeasurement, type ValidateResult, autoRigFromLayers, checkCustomGate, checkModelFolds, checkNod, checkSweep, composeLayersFromParts, createIkiMcpServer, describeIki, describeIkiAt, describeRigPlan, failedCustomGate, formatCustomGate, formatFoldReport, formatHairSideReport, formatMeasureReport, formatNodReport, formatPhysicsReport, formatRigPlanReport, formatSweepReport, formatTurnReport, listStandardParameters, measureLayers, measureTurnReference, probeRig, renderPoses, validateIki };